Back to index

im-sdk  12.3.91
le_interface.c
Go to the documentation of this file.
00001 #include <stdio.h>
00002 
00003 #include "le_object.h"
00004 #include "le_info.h"
00005 
00006 Bool if_le_OpenIF(iml_if_t *);
00007 Bool if_le_CloseIF(iml_if_t *);
00008 Bool if_le_GetIFValue(iml_if_t *, IMArgList, int);
00009 Bool if_le_SetIFValue(iml_if_t *, IMArgList, int);
00010 Bool if_le_OpenDesktop(iml_desktop_t *, IMArgList, int);
00011 Bool if_le_CloseDesktop(iml_desktop_t *);
00012 Bool if_le_CreateSC(iml_session_t *, IMArgList, int);
00013 Bool if_le_DestroySC(iml_session_t *);
00014 Bool if_le_GetSCValue(iml_session_t *, IMArgList, int);
00015 Bool if_le_SetSCValue(iml_session_t *, IMArgList, int);
00016 IMText *if_le_ResetSC(iml_session_t *);
00017 void if_le_SetSCFocus(iml_session_t *);
00018 void if_le_UnsetSCFocus(iml_session_t *);
00019 void if_le_SendEvent(iml_session_t *, IMInputEvent * ev);
00020 
00021 /* IF Method */
00022 if_methods_t le_methods = {
00023     if_le_OpenIF,
00024     if_le_CloseIF,
00025     if_le_GetIFValue,
00026     if_le_SetIFValue,
00027     if_le_OpenDesktop,
00028     if_le_CloseDesktop,
00029     if_le_CreateSC,
00030     if_le_DestroySC,
00031     if_le_GetSCValue,
00032     if_le_SetSCValue,
00033     if_le_ResetSC,
00034     if_le_SetSCFocus,
00035     if_le_UnsetSCFocus,
00036     if_le_SendEvent
00037 };
00038 
00039 LeInfoRec   *le_info = NULL;
00040 LeObjectRec *le_object = NULL;
00041 
00042 /* htt_server get the IF information when start htt_server */
00043 void if_GetIfInfo(IMArgList args, int num_args)
00044 {
00045     int i;
00046 
00047     DEBUG_printf("if_GetIfInfo(), num_args: %d\n", num_args);
00048 
00049     if (le_info == NULL) {
00050        le_info = (LeInfoRec *) le_info_new();
00051        if (le_info == NULL)
00052            return;
00053     }
00054 
00055     le_info_print(le_info);
00056 
00057     if (le_object == NULL) {
00058         le_object = (LeObjectRec *)le_object_new();
00059     }
00060     if (le_object == NULL)
00061         return;
00062 
00063     for (i = 0; i < num_args; i++, args++) {
00064        switch (args->id) {
00065        case IF_VERSION:
00066            args->value = (IMArgVal) le_object->version;
00067            break;
00068        case IF_METHOD_TABLE:
00069            args->value = (IMArgVal) & le_methods;
00070            break;
00071        case IF_LE_NAME:
00072            args->value = (IMArgVal) le_object->lename;
00073            break;
00074        case IF_SUPPORTED_LOCALES:
00075            args->value = (IMArgVal) le_object->locales;
00076            break;
00077        case IF_SUPPORTED_OBJECTS:
00078            args->value = (IMArgVal) le_object->objects;
00079            break;
00080        case IF_NEED_THREAD_LOCK:
00081            args->value = (IMArgVal) LE_OK;
00082            break;
00083        default:
00084            break;
00085        }
00086     }
00087 }
00088 
00089 /* Open the IF interface */
00090 Bool if_le_OpenIF(iml_if_t * If)
00091 {
00092     DEBUG_printf("if_le_OpenIF()\n");
00093 
00094     return LE_OK;
00095 }
00096 
00097 /* Close the IF interface */
00098 Bool if_le_CloseIF(iml_if_t * If)
00099 {
00100     DEBUG_printf("if_le_CloseIF()\n");
00101 
00102     le_object_destroy(le_object);
00103     le_object = NULL;
00104 
00105     le_info_destroy(le_info);
00106     le_info = NULL;
00107 
00108     return LE_OK;
00109 }
00110 
00111 Bool if_le_GetIFValue(iml_if_t * If, IMArgList args, int num_args)
00112 {
00113     DEBUG_printf("if_le_GetIFValue()\n");
00114     return LE_OK;
00115 }
00116 
00117 Bool if_le_SetIFValue(iml_if_t * If, IMArgList args, int num_args)
00118 {
00119     DEBUG_printf("if_le_SetIFValue()\n");
00120     return LE_OK;
00121 }
00122 
00123 Bool if_le_OpenDesktop(iml_desktop_t * desktop, IMArgList args,
00124                      int num_args)
00125 {
00126     DEBUG_printf("if_le_OpenDesktop(), desktop: %p, user: %s, host: %s\n",
00127                desktop, desktop->user_name, desktop->host_name);
00128 
00129     le_desktop_create(desktop);
00130     return LE_OK;
00131 }
00132 
00133 Bool if_le_CloseDesktop(iml_desktop_t * desktop)
00134 {
00135     DEBUG_printf("if_le_CloseDesktop(), desktop: %p\n", desktop);
00136 
00137     le_desktop_destroy(desktop);
00138     return LE_OK;
00139 }
00140 
00141 Bool if_le_CreateSC(iml_session_t * s, IMArgList args, int num_args)
00142 {
00143     DEBUG_printf("if_le_CreateSC(), s: %p, num_args: %d\n", s, num_args);
00144 
00145     s->specific_data = NULL;
00146     le_session_create(s);
00147     return LE_OK;
00148 }
00149 
00150 Bool if_le_DestroySC(iml_session_t * s)
00151 {
00152     DEBUG_printf("if_le_DestroySC(), s: %p\n", s);
00153 
00154     le_session_destroy(s);
00155     return LE_OK;
00156 }
00157 
00158 Bool if_le_GetSCValue(iml_session_t * s, IMArgList args, int num_args)
00159 {
00160     DEBUG_printf("if_le_GetSCValue(), s: %p\n", s);
00161     return LE_OK;
00162 }
00163 
00164 Bool if_le_SetSCValue(iml_session_t * s, IMArgList args, int num_args)
00165 {
00166     int i;
00167     IMArg *p = args;
00168 
00169     DEBUG_printf("if_le_SetSCValue(), s: %p\n", s);
00170 
00171     le_session_set_as_desktop_current_session(s);
00172 
00173     for (i = 0; i < num_args; i++, p++) {
00174        switch (p->id) {
00175        case SC_TRIGGER_ON_NOTIFY:
00176            DEBUG_printf("  SC_TRIGGER_ON_NOTIFY\n");
00177            le_session_set_conversion_status(s, CONVERSION_ON);
00178            break;
00179        case SC_TRIGGER_OFF_NOTIFY:
00180            DEBUG_printf("  SC_TRIGGER_OFF_NOTIFY\n");
00181            le_session_set_conversion_status(s, CONVERSION_OFF);
00182            break;
00183        case SC_REALIZE:
00184            DEBUG_printf("  SC_REALIZE\n");
00185            break;
00186        case SC_CLIENT_LOCALE:
00187            DEBUG_printf("  SC_CLIENT_LOCALE: [%s]\n", p->value);
00188             le_session_set_locale(s, p->value);
00189            break;
00190        default:
00191            break;
00192        }
00193     }
00194     return LE_OK;
00195 }
00196 
00197 IMText *if_le_ResetSC(iml_session_t * s)
00198 {
00199     DEBUG_printf("if_le_ResetSC(), s: %p\n", s);
00200 
00201     IMText *im_text = (IMText *) le_session_reset(s);
00202     return (IMText *) im_text;
00203 }
00204 
00205 void if_le_SetSCFocus(iml_session_t * s)
00206 {
00207     DEBUG_printf("if_le_SetSCFocus(), s: %p\n", s);
00208 
00209     le_session_set_focus_in(s);
00210     return;
00211 }
00212 
00213 void if_le_UnsetSCFocus(iml_session_t * s)
00214 {
00215     DEBUG_printf("if_le_UnsetSCFocus(), s: %p\n", s);
00216 
00217     le_session_set_focus_out(s);
00218     return;
00219 }
00220 
00221 void if_le_SendEvent(iml_session_t * s, IMInputEvent * ev)
00222 {
00223     DEBUG_printf("if_le_SendEvent(), desktop: %p, session: %p\n", s->desktop, s);
00224 
00225     if (ev) {
00226        if (ev->type == IM_EventKeyList) {
00227            DEBUG_printf("Keyboard Event\n");
00228            le_session_process_key_event(s, (IMKeyListEvent *) ev);
00229        }
00230     }
00231 }