Back to index

im-sdk  12.3.91
le_services.c
Go to the documentation of this file.
00001 #include <stdio.h>
00002 
00003 #include "le_info.h"
00004 #include "le_session.h"
00005 
00006 #include "le_aux_protocol.h"
00007 
00008 #define IMM_SERVICE_VERSION 0x0101
00009 
00010 ImeInfo le_get_ime_info(ImeInputContext);
00011 ImeEncoding le_get_session_encoding(ImeInputContext);
00012 ImmResult le_show_preedit(ImeInputContext);
00013 ImmResult le_hide_preedit(ImeInputContext);
00014 ImmResult le_update_preedit(ImeInputContext, ImePreedit);
00015 ImmResult le_move_preedit_caret(ImeInputContext, int);
00016 ImmResult le_show_candidates(ImeInputContext);
00017 ImmResult le_hide_candidates(ImeInputContext);
00018 ImmResult le_update_candidates(ImeInputContext, ImeCandidates);
00019 ImmResult le_commit(ImeInputContext, unsigned char *);
00020 ImHandle le_show_aux(ImeInputContext, const char *);
00021 ImmResult le_hide_aux(ImeInputContext, ImHandle);
00022 ImmResult le_send_aux_data(ImeEvent event);
00023 void *le_get_ime_data(ImeInputContext, int);
00024 ImmResult le_set_ime_data(ImeInputContext, int, void *);
00025 void *le_load_user_profile(ImeInputContext, const char *, int *);
00026 ImmResult le_free_user_profile(void *);
00027 ImmResult le_save_user_profile(ImeInputContext, const char *, void *, int);
00028 ImmResult le_beep(ImeInputContext, ImeBeepType);
00029 ImeKeyType le_map_keyevent(ImeKey);
00030 ImePropertyListRec *le_get_ime_properties(ImeInputContext);
00031 
00032 ImmServicesRec le_services = {
00033     IMM_SERVICE_VERSION,    /* version */
00034     le_get_ime_info,        /* ImmGetImeInfo */
00035     le_get_session_encoding,       /* ImmGetClientEncoding */
00036     le_show_preedit,        /* ImmShowPreedit */
00037     le_hide_preedit,        /* ImmHidePreedit */
00038     le_update_preedit,             /* ImmUpdatePreedit */
00039     le_move_preedit_caret,  /* ImmMovePreeditCaret */
00040     le_show_candidates,            /* ImmShowCandidates */
00041     le_hide_candidates,            /* ImmHideCandidates */
00042     le_update_candidates,   /* ImmUpdateCandidates */
00043     le_commit,                     /* ImmCommit */
00044     le_show_aux,            /* ImmStartAux */
00045     le_hide_aux,            /* ImmCloseAux */
00046     le_send_aux_data,              /* ImmSendUiMessage */
00047     le_get_ime_data,        /* ImmGetData */
00048     le_set_ime_data,        /* ImmGetData */
00049     le_load_user_profile,   /* ImmLoadUserProfile */
00050     le_free_user_profile,   /* ImmFreeUserProfile */
00051     le_save_user_profile,   /* ImmSaveUserProfile */
00052     le_beep,                /* ImmBeep */
00053     le_map_keyevent,        /* ImmPrefilterKey */
00054     le_get_ime_properties,  /* ImmGetPropertyList */
00055 #if 0
00056     NULL,                   /* ImmRegisterPreeditUI */
00057     NULL,                   /* ImmRegisterCandidateUI */
00058     NULL,                   /* ImmUnregisterPreeditUI */
00059     NULL,                   /* ImmUnregisterCandidateUI */
00060     NULL,                   /* ImmConfigIme */
00061     NULL,                   /* ImmGetICAttribute */
00062     NULL,                   /* ImmSetICAttribute */
00063     NULL,                   /* ImmSendRegisterWords */
00064     NULL,                   /* ImmLoadIcon */
00065     NULL                    /* ImmFreeIcon */
00066 #endif
00067 };
00068 
00069 ImeInfo le_get_ime_info(ImeInputContext ime_input_context)
00070 {
00071     LeSessionContextRec *le_session_context =
00072         (LeSessionContextRec *) ime_input_context;
00073     ImeModuleRec *ime_module = NULL;
00074 
00075     if (le_session_context == NULL)
00076         return (NULL);
00077 
00078     if (le_session_context->s == NULL)
00079         return (NULL);
00080 
00081     ime_module =
00082         (ImeModuleRec *)
00083         le_session_get_current_ime_module(le_session_context->s);
00084     if (ime_module == NULL)
00085         return (NULL);
00086 
00087     return (ime_module->info);
00088 }
00089 
00090 ImeEncoding le_get_session_encoding(ImeInputContext ime_input_context)
00091 {
00092     LeSessionContextRec *le_session_context =
00093         (LeSessionContextRec *) ime_input_context;
00094     iml_session_t *s = NULL;
00095 
00096     if (le_session_context == NULL)
00097         return (ENCODE_UTF8);
00098 
00099     s = (iml_session_t *) le_session_context->s;
00100     if (s == NULL)
00101         return (ENCODE_UTF8);
00102 
00103     return (le_session_get_client_encoding(s));
00104 }
00105 
00106 #define COMPOSITE_STYLE 0
00107 
00108 static void dupIMText(ImeTextRec* dst, ImeTextRec* src)
00109 {
00110     int i;
00111 
00112     if (src) {
00113         *dst = *src;
00114         if (src->text) {
00115             dst->text = (unsigned char*)strdup((char*)src->text);
00116         }
00117         if (src->feedbacks) {
00118             dst->feedbacks = (ImeFeedbackRec*)calloc(src->count_feedbacks,
00119                                                      sizeof(ImeFeedbackRec));
00120             for (i = 0; i <  src->count_feedbacks; ++i)
00121                 dst->feedbacks[i] = src->feedbacks[i];
00122         }
00123     } else {
00124         memset(dst, 0, sizeof(ImeTextRec));
00125     }
00126 }
00127 
00128 static void dupPreedit(ImePreeditRec* dst, ImePreeditRec * src)
00129 {
00130     *dst = *src;
00131     dupIMText(&dst->preedit, &src->preedit);
00132 }
00133 
00134 static void dupCandidates(ImeCandidatesRec* dst, ImeCandidatesRec*src)
00135 {
00136     int i;
00137 
00138     *dst = *src;
00139     if (src->title) dst->title = (unsigned char*)strdup(src->title);
00140     if (src->numbers) dst->numbers = (unsigned char*)strdup(src->numbers);
00141     dst->candidates = NULL;
00142     if (src->count) {
00143         dst->candidates = (ImeTextRec*)calloc(src->count, sizeof(ImeTextRec));
00144         for (i=0; i < src->count; ++i) {
00145             dupIMText(&(dst->candidates[i]), &(src->candidates[i]));
00146         }
00147     }
00148 }
00149 
00150 void freeImPreeditInternal(ImePreeditRec* dst)
00151 {
00152     if (dst->preedit.text) free(dst->preedit.text);
00153     if (dst->preedit.feedbacks) free(dst->preedit.feedbacks);
00154     memset(dst, 0, sizeof(ImePreeditRec));
00155 }
00156 
00157 void freeImCandidatesInternal(ImeCandidatesRec* dst)
00158 {
00159     int i;
00160 
00161     if (dst->title) free(dst->title);
00162     if (dst->numbers) free(dst->numbers);
00163     if (dst->candidates) {
00164         for (i=0; i < dst->count; ++i) {
00165             if (dst->candidates[i].text) free(dst->candidates[i].text);
00166             if (dst->candidates[i].feedbacks) free(dst->candidates[i].feedbacks);
00167         }
00168         free(dst->candidates);
00169     }
00170     memset(dst, 0, sizeof(ImeCandidatesRec));
00171 }
00172 
00173 ImmResult le_show_preedit_atomic(ImeInputContext ime_input_context, int backup)
00174 {
00175     iml_session_t *s = NULL;
00176     LeSessionContextRec *le_session_context = (LeSessionContextRec *) ime_input_context;
00177 
00178     if (le_session_context == NULL || (s =le_session_context->s) == NULL)
00179         return (IMM_FAIL);
00180 
00181     if (backup) le_session_context->preedit_show = 1;
00182     if (session_get_pc_aux_name(le_session_context)) {
00183         le_show_compositeaux_preedit_notify(s, session_get_pc_aux_name(le_session_context));
00184     } else {
00185         le_iml_preedit_start(s);
00186     }
00187     return (IMM_OK);
00188 }
00189 
00190 ImmResult le_show_preedit(ImeInputContext ime_input_context)
00191 {
00192     le_show_preedit_atomic(ime_input_context, 1);
00193 }
00194 
00195 ImmResult le_hide_preedit_atomic(ImeInputContext ime_input_context, int backup)
00196 {
00197     iml_session_t *s = NULL;
00198     LeSessionContextRec *le_session_context = (LeSessionContextRec *)ime_input_context;
00199 
00200     if (le_session_context == NULL || (s =le_session_context->s) == NULL)
00201         return (IMM_FAIL);
00202 
00203     if (backup) le_session_context->preedit_show = 0;
00204 
00205     if (session_get_pc_aux_name(le_session_context))
00206         le_hide_compositeaux_preedit_notify(s, session_get_pc_aux_name(le_session_context));
00207     else
00208         le_iml_preedit_enddraw(s);
00209     return (IMM_OK);
00210 }
00211 
00212 ImmResult le_hide_preedit(ImeInputContext ime_input_context)
00213 {
00214     return le_hide_preedit_atomic(ime_input_context, 1);
00215 }
00216 
00217 ImmResult le_update_preedit_atomic(ImeInputContext  ime_input_context,
00218                                   ImePreedit        ime_preedit,
00219                                   int               backup)
00220 {
00221     int from_len, to_left, ret;
00222     ImeEncoding encoding;
00223 
00224     LeSessionContextRec *le_session_context = (LeSessionContextRec *)ime_input_context;
00225 
00226     if ((le_session_context == NULL) || (ime_preedit == NULL) || (le_session_context->s == NULL))
00227         return (IMM_FAIL);
00228 
00229     iml_session_t *s = (le_session_context->s);
00230 
00231     if (backup && (ime_preedit != &le_session_context->preedit_backup)) {
00232         freeImPreeditInternal(&le_session_context->preedit_backup);
00233         dupPreedit(&le_session_context->preedit_backup, ime_preedit);
00234     }
00235 
00236     encoding = le_session_get_current_ime_encoding(s);
00237     if (encoding == ENCODE_INVALID)
00238         return (IMM_FAIL);
00239 
00240     if (session_get_pc_aux_name(le_session_context)) {
00241         le_update_compositeaux_preedit_notify(le_session_context, 
00242                                               session_get_pc_aux_name(le_session_context), 
00243                                               ime_preedit);
00244         return (IMM_OK);
00245     }
00246 
00247     UTFCHAR tmp_buf[1024] = {0};
00248     UTFCHAR *tmp_ptr = tmp_buf;
00249 
00250     if (ime_preedit->preedit.text && ime_preedit->preedit.text[0]) {
00251         from_len = strlen(ime_preedit->preedit.text);
00252         to_left = 1024;
00253         memset(tmp_buf, 0, sizeof(UTFCHAR) * 1024);
00254         ret = Convert_Native_To_UTF16(encoding,
00255                                       ime_preedit->preedit.text,
00256                                       from_len,
00257                                       (char **) &tmp_ptr,
00258                                       (size_t *) & to_left);
00259         if (ret == -1)
00260             return (IMM_FAIL);
00261     }
00262 
00263     le_iml_preedit_start(s);
00264     le_iml_preedit_draw(s, tmp_buf, ime_preedit->caret);
00265 
00266     return (IMM_OK);
00267 }
00268 
00269 ImmResult le_update_preedit(ImeInputContext ime_input_context,
00270                             ImePreedit      ime_preedit)
00271 {
00272     le_update_preedit_atomic(ime_input_context, ime_preedit, 1);
00273 }
00274 
00275 ImmResult le_move_preedit_caret(ImeInputContext ime_input_context,
00276                                 int             index)
00277 {
00278 }
00279 
00280 ImmResult le_show_candidates_atomic(ImeInputContext ime_input_context, int backup)
00281 {
00282   LeSessionContextRec *le_session_context =
00283       (LeSessionContextRec *) ime_input_context;
00284   iml_session_t *s = NULL;
00285   LayoutInfo layout;
00286   int layout_type_vertical = 1;
00287   int layout_capacity = 10;
00288   int composite_style = 0;
00289 
00290   if (le_session_context == NULL)
00291       return (IMM_FAIL);
00292 
00293   s = (iml_session_t *) le_session_context->s;
00294   if (s == NULL)
00295       return (IMM_FAIL);
00296 
00297   if (backup) {
00298       le_session_context->candidates_show = 1;
00299   }
00300 
00301   if (session_get_pc_aux_name(le_session_context)) {
00302       le_show_compositeaux_candidates_notify(s, session_get_pc_aux_name(le_session_context));
00303       return (IMM_OK);
00304   }
00305 
00306   layout.choice_per_window = layout_capacity;
00307   if (layout_type_vertical) {
00308       layout.ncolumns = 1;
00309       layout.nrows = layout_capacity;
00310       layout.drawUpDirection = DrawUpVertically;
00311   } else {
00312       layout.ncolumns = layout_capacity;
00313       layout.nrows = 1;
00314       layout.drawUpDirection = DrawUpHorizontally;
00315   }
00316 
00317   le_iml_lookup_start(s, &layout);
00318   return (IMM_OK);
00319 }
00320 
00321 ImmResult le_show_candidates(ImeInputContext ime_input_context)
00322 {
00323     le_show_candidates_atomic(ime_input_context, 1);
00324 }
00325 
00326 ImmResult le_hide_candidates_atomic(ImeInputContext ime_input_context, int backup)
00327 {
00328     LeSessionContextRec *le_session_context = (LeSessionContextRec *) ime_input_context;
00329     iml_session_t *s = NULL;
00330 
00331     if (le_session_context == NULL)
00332         return (IMM_FAIL);
00333 
00334     s = (iml_session_t *) le_session_context->s;
00335     if (s == NULL)
00336         return (IMM_FAIL);
00337 
00338     if (backup) {
00339         le_session_context->candidates_show = 0;
00340     }
00341 
00342     if (session_get_pc_aux_name(le_session_context)) {
00343         le_hide_compositeaux_candidates_notify(s, session_get_pc_aux_name(le_session_context));
00344         return (IMM_OK);
00345     }
00346 
00347     le_iml_lookup_enddraw(s);
00348 
00349     return (IMM_OK);
00350 }
00351 
00352 ImmResult le_hide_candidates(ImeInputContext ime_input_context)
00353 {
00354     le_hide_candidates_atomic(ime_input_context, 1);
00355 }
00356 
00357 ImmResult le_update_candidates_atomic(ImeInputContext ime_input_context,
00358                                       ImeCandidates ime_candidates, int backup)
00359 {
00360     UTFCHAR **lookup_strs;
00361     UTFCHAR **label_strs;
00362 
00363     int from_len, to_left, ret, i, num_candidates;
00364     ImeEncoding encoding;
00365 
00366     LeSessionContextRec *le_session_context = (LeSessionContextRec *)ime_input_context;
00367 
00368     if ((le_session_context == NULL) || ((le_session_context->s) == NULL) || (ime_candidates == NULL))
00369         return (IMM_FAIL);
00370 
00371     iml_session_t *s = le_session_context->s;
00372 
00373     if (backup && (ime_candidates != &le_session_context->candidates_backup)) {
00374         freeImCandidatesInternal(&le_session_context->candidates_backup);
00375         dupCandidates(&le_session_context->candidates_backup, ime_candidates);
00376     }
00377 
00378     num_candidates = ime_candidates->count;
00379 
00380     encoding = le_session_get_current_ime_encoding(s);
00381     if (encoding == ENCODE_INVALID)
00382         return (IMM_FAIL);
00383 
00384     if (session_get_pc_aux_name(le_session_context)) {
00385         le_update_compositeaux_candidates_notify(le_session_context, 
00386                                                  session_get_pc_aux_name(le_session_context), 
00387                                                  ime_candidates);
00388         return (IMM_OK);
00389     }
00390 
00391     lookup_strs = (UTFCHAR **) calloc(num_candidates, sizeof(UTFCHAR *));
00392     if (lookup_strs == NULL)
00393         return (IMM_FAIL);
00394 
00395     label_strs = (UTFCHAR **) calloc(num_candidates, sizeof(UTFCHAR *));
00396     if (label_strs == NULL)
00397         return (IMM_FAIL);
00398 
00399     UTFCHAR tmp_buf[1024], label_buf[64];
00400     UTFCHAR *tmp_ptr = tmp_buf;
00401 
00402     if (ime_candidates->numbers) {
00403         from_len = strlen(ime_candidates->numbers);
00404         to_left = 64 * sizeof(UTFCHAR);
00405         memset(tmp_buf, 0, to_left);
00406         tmp_ptr = label_buf;
00407         ret = Convert_Native_To_UTF16(encoding, ime_candidates->numbers,
00408                                       from_len, (char **) &tmp_ptr,
00409                                       (size_t *) & to_left);
00410     }
00411 
00412     for (i = 0; i < num_candidates; i++) {
00413         if (ime_candidates->candidates[i].text == NULL)
00414             continue;
00415 
00416         from_len = strlen(ime_candidates->candidates[i].text);
00417         to_left = 1024;
00418         memset(tmp_buf, 0, sizeof(UTFCHAR) * 1024);
00419         tmp_ptr = tmp_buf;
00420         ret = Convert_Native_To_UTF16(encoding,
00421                                       ime_candidates->candidates[i].text,
00422                                       from_len,
00423                                       (char **) &tmp_ptr,
00424                                       (size_t *) & to_left);
00425         if (ret == -1) {
00426             tmp_buf[0] = 0x20;
00427             tmp_buf[1] = 0;
00428         }
00429 
00430         lookup_strs[i] =
00431             (UTFCHAR *) calloc(1024 - to_left + 1, sizeof(UTFCHAR));
00432         if (lookup_strs[i] == NULL)
00433             continue;
00434 
00435         UTFCHARCpy(lookup_strs[i], tmp_buf);
00436 
00437         label_strs[i] = (UTFCHAR *) calloc(3, sizeof(UTFCHAR));
00438         if (label_strs[i] == NULL)
00439             continue;
00440         label_strs[i][0] =
00441             (ime_candidates->numbers) ? (label_buf[i]) : ('1' + i);
00442         label_strs[i][1] = '.';
00443         label_strs[i][2] = 0;
00444     }
00445 
00446     le_iml_lookup_draw(s, num_candidates, lookup_strs, NULL, label_strs,
00447                        NULL, NULL, NULL, 0,
00448                        (ime_candidates->horizental) ? 0 : 1);
00449 
00450     for (i = 0; i < num_candidates; i++) {
00451         if (lookup_strs[i])
00452             free((char *) lookup_strs[i]);
00453         if (label_strs[i])
00454             free((char *) label_strs[i]);
00455     }
00456     free((char *) lookup_strs);
00457     free((char *) label_strs);
00458 
00459     return (IMM_OK);
00460 }
00461 
00462 ImmResult le_update_candidates(ImeInputContext ime_input_context,
00463                                ImeCandidates ime_candidates)
00464 {
00465     le_update_candidates_atomic(ime_input_context, ime_candidates, 1);
00466 }
00467 
00468 #if 0
00469 ImmResult le_update_candidates_layout(ImeInputContext ime_input_context,
00470                                       ImeCandidatesLayout
00471                                       ime_candidates_layout)
00472 {
00473     LeSessionContextRec *le_session_context =
00474         (LeSessionContextRec *) ime_input_context;
00475     iml_session_t *s = NULL;
00476     LayoutInfo layout;
00477 
00478     if (le_session_context == NULL)
00479         return (IMM_FAIL);
00480 
00481     s = (iml_session_t *) le_session_context->s;
00482     if (s == NULL)
00483         return (IMM_FAIL);
00484 
00485     layout.choice_per_window = ime_candidates_layout->capacity;
00486     if (ime_candidates_layout->direction == ImeCandidatesVertically) {
00487         layout.ncolumns = 1;
00488         layout.nrows = ime_candidates_layout->capacity;
00489         layout.drawUpDirection = DrawUpVertically;
00490     } else {
00491         layout.ncolumns = ime_candidates_layout->capacity;
00492         layout.nrows = 1;
00493         layout.drawUpDirection = DrawUpHorizontally;
00494     }
00495 
00496     le_iml_lookup_start(s, &layout);
00497     return (IMM_OK);
00498 }
00499 #endif
00500 
00501 ImmResult le_commit(ImeInputContext ime_input_context,
00502                     unsigned char *commit_buf)
00503 {
00504     LeSessionContextRec *le_session_context =
00505         (LeSessionContextRec *) ime_input_context;
00506     iml_session_t *s = NULL;
00507     UTFCHAR tmp_buf[1024];
00508     UTFCHAR *tmp_ptr = tmp_buf;
00509     int from_len, to_left, ret;
00510     ImeEncoding encoding;
00511 
00512     if (le_session_context == NULL)
00513         return (IMM_FAIL);
00514     if (commit_buf == NULL)
00515         return (IME_FAIL);
00516 #if 0
00517     if (ime_commit == NULL)
00518         return (IMM_FAIL);
00519 #endif
00520 
00521     s = (iml_session_t *) le_session_context->s;
00522     if (s == NULL)
00523         return (IMM_FAIL);
00524 
00525     encoding = le_session_get_current_ime_encoding(s);
00526     if (encoding == ENCODE_INVALID)
00527         return (IMM_FAIL);
00528 
00529     from_len = strlen(commit_buf);
00530     to_left = 1024;
00531     memset(tmp_buf, 0, sizeof(UTFCHAR) * 1024);
00532     ret = Convert_Native_To_UTF16(encoding,
00533                                   commit_buf,
00534                                   from_len,
00535                                   (char **) &tmp_ptr,
00536                                   (size_t *) & to_left);
00537     if (ret == -1)
00538         return (IMM_FAIL);
00539 
00540     le_iml_commit(s, tmp_buf);
00541     return (IMM_OK);
00542 }
00543 
00544 ImHandle le_show_aux(ImeInputContext ime_input_context,  const char *aux_name)
00545 {
00546     iml_session_t *s = NULL;
00547     int command = COMMONAUX_SHOW_NOTIFY;
00548     LeSessionContextRec *le_session_context = (LeSessionContextRec *)ime_input_context;
00549 
00550     if (aux_name == NULL || le_session_context == NULL || ((s =le_session_context->s) == NULL))
00551         return (IMM_FAIL);
00552 
00553     DEBUG_printf("Show aux window %s for session 0x%x\n", aux_name, s);
00554 
00555     le_iml_aux_start(s, aux_name);
00556 
00557     le_iml_aux_draw(s, aux_name, 1, &command, 0, NULL, NULL);
00558 
00559     return (IMM_OK);
00560 }
00561 
00562 ImmResult le_hide_aux(ImeInputContext ime_input_context, ImHandle im_handle)
00563 {
00564     iml_session_t *s = NULL;
00565     int command = COMMONAUX_HIDE_NOTIFY;
00566     unsigned char *aux_name = (unsigned char *) im_handle;
00567     LeSessionContextRec *le_session_context = (LeSessionContextRec *) ime_input_context;
00568 
00569     if (aux_name == NULL || le_session_context == NULL || ((s =le_session_context->s) == NULL))
00570         return (IMM_FAIL);
00571 
00572     DEBUG_printf("Show aux window %s for session 0x%x\n", aux_name, s);
00573 
00574     le_iml_aux_draw(s, aux_name, 1, &command, 0, NULL, NULL);
00575 
00576     return (IMM_OK);
00577 }
00578 
00579 ImmResult le_send_aux_data(ImeEvent event)
00580 {
00581     return (IMM_OK);
00582 }
00583 
00584 void *le_get_ime_data(ImeInputContext ime_input_context, int scope)
00585 {
00586     LeSessionContextRec *le_session_context =
00587         (LeSessionContextRec *) ime_input_context;
00588 
00589     if (le_session_context == NULL)
00590         return (NULL);
00591 
00592     if (scope == IME_SCOPE_SESSION) {
00593         return (le_session_context->ime_session_data);
00594     } else if (scope == IME_SCOPE_DESKTOP) {
00595         return (le_session_context->ime_desktop_data);
00596     } else if (scope == IME_SCOPE_USER) {
00597         return (le_session_context->ime_user_data);
00598     }
00599 #if 0
00600     iml_session_t *s = NULL;
00601     s = (iml_session_t *) le_session_context->s;
00602     if (s == NULL)
00603         return (IMM_FAIL);
00604 
00605     return (le_session_context->ime_user_data);
00606 #endif
00607 }
00608 
00609 ImmResult le_set_ime_data(ImeInputContext ime_input_context, int scope,
00610                           void *pdata)
00611 {
00612     LeSessionContextRec *le_session_context =
00613         (LeSessionContextRec *) ime_input_context;
00614 
00615     if (le_session_context == NULL)
00616         return (IMM_FAIL);
00617 
00618     if (scope == IME_SCOPE_SESSION) {
00619         le_session_context->ime_session_data = pdata;
00620     } else if (scope == IME_SCOPE_DESKTOP) {
00621         le_session_context->ime_desktop_data = pdata;
00622     } else if (scope == IME_SCOPE_USER) {
00623         le_session_context->ime_user_data = pdata;
00624     }
00625     return (IMM_OK);
00626 }
00627 
00628 void *le_load_user_profile(ImeInputContext ic, const char *category,
00629                            int *psz)
00630 {
00631     return (NULL);
00632 }
00633 
00634 ImmResult le_free_user_profile(void *buf)
00635 {
00636     return (IMM_OK);
00637 }
00638 
00639 ImmResult le_save_user_profile(ImeInputContext ic, const char *category,
00640                                void *buf, int sz)
00641 {
00642     return (IMM_OK);
00643 }
00644 
00645 ImmResult le_beep(ImeInputContext ime_input_context,
00646                   ImeBeepType ime_beep_type)
00647 {
00648     LeSessionContextRec *le_session_context =
00649         (LeSessionContextRec *) ime_input_context;
00650     iml_session_t *s = NULL;
00651 
00652     if (le_session_context == NULL)
00653         return (IMM_FAIL);
00654 
00655     s = (iml_session_t *) le_session_context->s;
00656     if (s == NULL)
00657         return (IMM_FAIL);
00658 
00659     le_beep_paletteaux_notify(s, ime_beep_type);
00660     return (IMM_OK);
00661 }
00662 
00663 ImeKeyType le_map_keyevent(ImeKey ime_key)
00664 {
00665     int keycode = ime_key->keycode;
00666     int keychar = ime_key->keychar;
00667     int modifier = ime_key->modifier;
00668 
00669     DEBUG_printf
00670         ("le_map_keyevent: keycode: 0x%x, keychar:0x%x, modifier: 0x%x\n",
00671          keycode, keychar, modifier);
00672 
00673     /* Normal Alphameric key */
00674     if ((keycode >= IME_VK_COMMA && keycode <= IME_VK_CLOSE_BRACKET) ||
00675        (keycode >= IME_VK_AMPERSAND && keycode <= IME_VK_UNDERSCORE) ||
00676         (keycode == IME_VK_QUOTE) || (keycode == IME_VK_BACK_QUOTE)) {
00677         if (!(modifier & IME_CTRL_MASK) &&
00678             !(modifier & IME_META_MASK) &&
00679             !(modifier & IME_ALT_MASK) &&
00680            !(modifier & IME_ALT_GRAPH_MASK))
00681             return (keychar);
00682     }
00683 
00684     /* Special key */
00685     if (modifier == 0) {
00686         switch (keycode) {
00687         case IME_VK_ESCAPE:
00688             return (IME_FILTERED_KEY_ESCAPE);
00689         case IME_VK_ENTER:
00690             return (IME_FILTERED_KEY_ENTER);
00691         case IME_VK_SPACE:
00692             return (IME_FILTERED_KEY_SPACEBAR);
00693         case IME_VK_PAGE_UP:
00694             return (IME_FILTERED_KEY_PAGEUP);
00695         case IME_VK_PAGE_DOWN:
00696             return (IME_FILTERED_KEY_PAGEDOWN);
00697         case IME_VK_INSERT:
00698             return (IME_FILTERED_KEY_INSERT);
00699         case IME_VK_DELETE:
00700             return (IME_FILTERED_KEY_DELETE);
00701         case IME_VK_BACK_SPACE:
00702             return (IME_FILTERED_KEY_BACKSPACE);
00703         case IME_VK_HOME:
00704             return (IME_FILTERED_KEY_HOME);
00705         case IME_VK_END:
00706             return (IME_FILTERED_KEY_END);
00707         case IME_VK_LEFT:
00708             return (IME_FILTERED_KEY_LEFT);
00709         case IME_VK_RIGHT:
00710             return (IME_FILTERED_KEY_RIGHT);
00711         case IME_VK_UP:
00712             return (IME_FILTERED_KEY_UP);
00713         case IME_VK_DOWN:
00714             return (IME_FILTERED_KEY_DOWN);
00715         }
00716     }
00717     return (IME_FILTERED_KEY_UNUSED);
00718 }
00719 
00720 ImePropertyListRec *le_get_ime_properties(ImeInputContext ime_input_context)
00721 {
00722     LeSessionContextRec *le_session_context =
00723         (LeSessionContextRec *) ime_input_context;
00724     ImePropertyListRec *pl;
00725 
00726     if (le_session_context == NULL)
00727         return (NULL);
00728     if (le_session_context->s == NULL)
00729         return (NULL);
00730 
00731     pl = (ImePropertyListRec *)
00732        le_session_get_current_ime_module_property_list(le_session_context->s);
00733 
00734     return (pl);
00735 }