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_object == NULL) {
00050         le_object = (LeObjectRec *)le_object_new();
00051     }
00052     if (le_object == NULL)
00053         return;
00054 
00055     for (i = 0; i < num_args; i++, args++) {
00056        switch (args->id) {
00057        case IF_VERSION:
00058            args->value = (IMArgVal) le_object->version;
00059            break;
00060        case IF_METHOD_TABLE:
00061            args->value = (IMArgVal) & le_methods;
00062            break;
00063        case IF_LE_NAME:
00064            args->value = (IMArgVal) le_object->lename;
00065            break;
00066        case IF_SUPPORTED_LOCALES:
00067            args->value = (IMArgVal) le_object->locales;
00068            break;
00069        case IF_SUPPORTED_OBJECTS:
00070            args->value = (IMArgVal) le_object->objects;
00071            break;
00072        case IF_NEED_THREAD_LOCK:
00073            args->value = (IMArgVal) LE_OK;
00074            break;
00075        default:
00076            break;
00077        }
00078     }
00079 }
00080 
00081 /* Open the IF interface */
00082 Bool if_le_OpenIF(iml_if_t * If)
00083 {
00084     DEBUG_printf("if_le_OpenIF()\n");
00085 
00086     if (le_info == NULL) {
00087        le_info = (LeInfoRec *) le_info_new();
00088        if (le_info == NULL)
00089            return (LE_FAIL);
00090     }
00091 
00092     le_info_print(le_info);
00093     return (LE_OK);
00094 }
00095 
00096 /* Close the IF interface */
00097 Bool if_le_CloseIF(iml_if_t * If)
00098 {
00099     DEBUG_printf("if_le_CloseIF()\n");
00100 
00101     le_object_destroy(le_object);
00102     le_object = NULL;
00103 
00104     le_info_destroy(le_info);
00105     le_info = NULL;
00106 
00107     return (LE_OK);
00108 }
00109 
00110 Bool if_le_GetIFValue(iml_if_t * If, IMArgList args, int num_args)
00111 {
00112     DEBUG_printf("if_le_GetIFValue()\n");
00113     return (LE_OK);
00114 }
00115 
00116 Bool if_le_SetIFValue(iml_if_t * If, IMArgList args, int num_args)
00117 {
00118     DEBUG_printf("if_le_SetIFValue()\n");
00119     return (LE_OK);
00120 }
00121 
00122 Bool if_le_OpenDesktop(iml_desktop_t * desktop, IMArgList args,
00123                      int num_args)
00124 {
00125     DEBUG_printf("if_le_OpenDesktop(), desktop: %p, user: %s, host: %s\n",
00126                desktop, desktop->user_name, desktop->host_name);
00127 
00128     le_desktop_create(desktop);
00129     return (LE_OK);
00130 }
00131 
00132 Bool if_le_CloseDesktop(iml_desktop_t * desktop)
00133 {
00134     DEBUG_printf("if_le_CloseDesktop(), desktop: %p\n", desktop);
00135 
00136     le_desktop_destroy(desktop);
00137     return (LE_OK);
00138 }
00139 
00140 Bool if_le_CreateSC(iml_session_t * s, IMArgList args, int num_args)
00141 {
00142     DEBUG_printf("if_le_CreateSC(), s: %p, num_args: %d\n", s, num_args);
00143 
00144     s->specific_data = NULL;
00145     le_session_create(s);
00146     return (LE_OK);
00147 }
00148 
00149 Bool if_le_DestroySC(iml_session_t * s)
00150 {
00151     DEBUG_printf("if_le_DestroySC(), s: %p\n", s);
00152 
00153     le_session_destroy(s);
00154     return (LE_OK);
00155 }
00156 
00157 Bool if_le_GetSCValue(iml_session_t * s, IMArgList args, int num_args)
00158 {
00159     DEBUG_printf("if_le_GetSCValue(), s: %p\n", s);
00160     return (LE_OK);
00161 }
00162 
00163 Bool if_le_SetSCValue(iml_session_t * s, IMArgList args, int num_args)
00164 {
00165     int i;
00166     IMArg *p = args;
00167 
00168     DEBUG_printf("if_le_SetSCValue(), s: %p\n", s);
00169 
00170     le_session_set_as_desktop_current_session(s);
00171 
00172     for (i = 0; i < num_args; i++, p++) {
00173        switch (p->id) {
00174        case SC_TRIGGER_ON_NOTIFY:
00175            DEBUG_printf("  SC_TRIGGER_ON_NOTIFY\n");
00176            le_session_set_conversion_status(s, CONVERSION_ON);
00177            break;
00178        case SC_TRIGGER_OFF_NOTIFY:
00179            DEBUG_printf("  SC_TRIGGER_OFF_NOTIFY\n");
00180            le_session_set_conversion_status(s, CONVERSION_OFF);
00181            break;
00182        case SC_REALIZE:
00183            DEBUG_printf("  SC_REALIZE\n");
00184            break;
00185        case SC_CLIENT_LOCALE:
00186            DEBUG_printf("  SC_CLIENT_LOCALE: [%s]\n", p->value);
00187            break;
00188        default:
00189            break;
00190        }
00191     }
00192     return (LE_OK);
00193 }
00194 
00195 IMText *if_le_ResetSC(iml_session_t * s)
00196 {
00197     DEBUG_printf("if_le_ResetSC(), s: %p\n", s);
00198 
00199     IMText *im_text = (IMText *) le_session_reset(s);
00200     return (IMText *) im_text;
00201 }
00202 
00203 void if_le_SetSCFocus(iml_session_t * s)
00204 {
00205     DEBUG_printf("if_le_SetSCFocus(), s: %p\n", s);
00206 
00207     le_session_set_focus_in(s);
00208     return;
00209 }
00210 
00211 void if_le_UnsetSCFocus(iml_session_t * s)
00212 {
00213     DEBUG_printf("if_le_UnsetSCFocus(), s: %p\n", s);
00214 
00215     le_session_set_focus_out(s);
00216     return;
00217 }
00218 
00219 void if_le_SendEvent(iml_session_t * s, IMInputEvent * ev)
00220 {
00221     DEBUG_printf("if_le_SendEvent(), desktop: %p, session: %p\n", s->desktop, s);
00222 
00223     if (ev) {
00224        if (ev->type == IM_EventKeyList) {
00225            DEBUG_printf("Keyboard Event\n");
00226            le_session_process_key_event(s, (IMKeyListEvent *) ev);
00227 #if 0
00228        } else if (ev->type == IM_EventAux) {
00229            DEBUG_printf("Aux Event\n");
00230            le_session_process_aux_event(s, (IMAuxEvent *) ev);
00231 #endif
00232        }
00233     }
00234 }