Back to index

im-sdk  12.3.91
Functions | Variables
le.c File Reference
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <limits.h>
#include "le.h"
#include "encode.h"
#include "xaux_locale.h"
#include "le_proc.h"

Go to the source code of this file.

Functions

Bool if_le_OpenIF (iml_if_t *)
Bool if_le_CloseIF (iml_if_t *)
Bool if_le_GetIFValue (iml_if_t *, IMArgList, int)
Bool if_le_SetIFValue (iml_if_t *, IMArgList, int)
Bool if_le_OpenDesktop (iml_desktop_t *, IMArgList, int)
Bool if_le_CloseDesktop (iml_desktop_t *)
Bool if_le_CreateSC (iml_session_t *, IMArgList, int)
Bool if_le_DestroySC (iml_session_t *)
Bool if_le_GetSCValue (iml_session_t *, IMArgList, int)
Bool if_le_SetSCValue (iml_session_t *, IMArgList, int)
IMTextif_le_ResetSC (iml_session_t *)
void if_le_SetSCFocus (iml_session_t *)
void if_le_UnsetSCFocus (iml_session_t *)
void if_le_SendEvent (iml_session_t *, IMInputEvent *ev)
int get_list_of_supported_locales ()
Bool is_trigger_on_required (unit_desktop_t *udp, char *locale)
unit_desktop_tcreate_unit_desktop ()
void add_unit_desktop (unit_desktop_t *udp)
unit_desktop_tfind_unit_desktop_by_sc (iml_session_t *)
int CpyUTFCHAR (char *src, UTFCHAR *dest)
IMHotkeyProfileStructget_hkp_from_hkm (int)
void get_line (char *buf, int size, char **curptr, char *line)
void unit_desktop_init (unit_desktop_t *udp)
int unit_desktop_add_listener (unit_desktop_t *udp, iml_session_t *s)
int unit_desktop_load_engines (unit_desktop_t *udp, iml_desktop_t *desktop)
void unit_desktop_set_curr_profile_id (unit_desktop_t *udp, int profile_id)
int unit_desktop_get_curr_profile_id (unit_desktop_t *udp)
void unit_desktop_switch_hotkey_profile (unit_desktop_t *udp, iml_session_t *s)
void unit_desktop_done (unit_desktop_t *udp)
IMEBufferRecime_buffer_malloc ()
void ime_buffer_free (IMEBuffer)
void proc_key_event (unit_desktop_t *, iml_session_t *, IMKeyListEvent *)
void process_hotkey_event (unit_desktop_t *, iml_session_t *, IMKeyListEvent *)
void proc_key_switch_conversion_event (unit_desktop_t *, iml_session_t *, int, char *)
IMHotkeyManagerStructparse_hotkey_config_file (IMLEName *, char *)
void printHotkeyManager (IMHotkeyManagerStruct *)
IMHotkeyManagerStructif_GetHotKeyInfo (IMLEName *a_le_name)
void if_GetIfInfo (IMArgList args, int num_args)
unit_if_tunit_if ()

Variables

if_methods_t le_methods
char lename_string []
UTFCHAR lename_utf_string []
char default_locale_id
IMLEName lename = {lename_string, lename_utf_string }
static IMObjectDescriptorStructobjects = NULL
static IMHotkeyManagerStructg_hkms = NULL
static Bool add_listener_flag = False
IMLocale locales [MAX_SUPPORTED_LOCALES]
int n_Supported_Locales
unit_if_tUIf

Function Documentation

int CpyUTFCHAR ( char *  src,
UTFCHAR dest 
)

Definition at line 736 of file le.c.

{
    int i;

    for(i=0;*src;i++){
       *dest++ = *src++;
    }
    *dest = 0;
    return i;
}

Here is the caller graph for this function:

Definition at line 285 of file le.c.

{
    unit_desktop_t *udp = (unit_desktop_t *) calloc(1, sizeof(unit_desktop_t));
    udp->next = unit_if()->ud_list;
    return udp;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 310 of file le.c.

{
    unit_desktop_list udl, *prev;

    if (UIf->ud_list == NULL) {
       return (unit_desktop_t *) NULL; 
    }
    for (prev = &UIf->ud_list; (udl = *prev) != 0; prev = &udl->next) {
        if (udl->s) {
           if (udl->s->desktop == s->desktop)
              return udl;
        } else if ((udl->s == 0) && (udl->next == NULL)) {
           return udl;
       }
    }
    return (unit_desktop_t *) NULL; 
}

Here is the caller graph for this function:

Definition at line 751 of file le.c.

{
    int i;
    IMHotkeyProfileStruct *hkp = NULL;

    if (g_hkms) {
       if (g_hkms->hkps) {
           for (i=0; i<g_hkms->num_hotkey_profiles; i++) {
              if (g_hkms->hkps[i].profile_id == profile_id) {
                  hkp = (IMHotkeyProfileStruct *) calloc(1, sizeof(IMHotkeyProfileStruct));
                  hkp->profile_id = g_hkms->hkps[i].profile_id;
                  hkp->scope = g_hkms->hkps[i].scope;
                  hkp->name = g_hkms->hkps[i].name;
                  hkp->num_hotkeys = g_hkms->hkps[i].num_hotkeys;
                  hkp->hks = g_hkms->hkps[i].hks;
                  return hkp;
                }
           }
       }
    }
    return hkp;
}

Here is the caller graph for this function:

int get_line ( char *  buf,
int  size,
char **  curptr,
char *  line 
)

Definition at line 860 of file unit_input.c.

{
    int line_ptr, n;
    char line_buf[MAX_LINE_LEN]; 
    char *ptr;

    char *p = ((0 == *curptr)?*curptr=buf:*curptr);
    char *pp = p;

    line_ptr = 0;
    line[0] = '\0';

    n = *curptr - buf;
    if (n >= size) { /* No more data to read */
       return 0;
    }

    /* get line with no space */
    while(1) {
        if (*p == '\n' || *p == '\0') {
            *p++;
            continue;
        }

       /* chop one line */
       while (*p != '\n') p++ ;
       /* pp to p is one line, just as fgets returns */
       memcpy(line_buf, pp, p-pp);
       line_buf[p-pp]='\0';

       ptr = line_buf;

       /* skip preceding space keys */
       while(*ptr && isspace(*ptr)) ptr++;

       /* if is space line, get new line */
       if (*ptr == '\n' || *ptr == '\0')
           continue;

       while(*ptr != '\n' && *ptr != '\0' && line_ptr < MAX_LINE_LEN)
           line[line_ptr++] = *ptr++;

       /* trim right space */
       while (isspace(line[line_ptr-1])) line_ptr--;
       line[line_ptr] = '\0';

       /* if the line end with '\', then continue read the next line */
       if (line[line_ptr-1] == '\\') {
           line_ptr--;
           line[line_ptr] = '\0';
           continue;
       } 
       break;
    }

    *curptr = p+1 ;

    if (line[0] == '\0') return 0;
    if (line[0] == COMMENT) return -1; 
    return line_ptr;
}

Here is the caller graph for this function:

Definition at line 637 of file le.c.

{
    char      file_name[PATH_MAX], line[MAX_LINE_LEN]; 
    char        *file_buf, *curr_ptr;
    char      keyCodeName[NAME_MAX], modifierName[NAME_MAX];
    char      locale_name[NAME_MAX], *kptr, *ptr;
    
    int       len, n, nfread, fsize, fd;
    int       locale_flag = ENCODE_ERROR;
    int       generic_flag = 0;
    int       switch_to_next_locale_flag = 0;
    int       switch_to_prev_locale_flag = 0;
    int       switch_layout_flag = 0;
    FILE      *fp;
    struct stat buf;

    n = 0;

    memset((char *)keyCodeName,'\0',sizeof(keyCodeName));
    memset((char *)modifierName,'\0',sizeof(modifierName));

    snprintf(file_name, sizeof(file_name), "%s/%s/%s",  DEFAULT_ENGINE_PATH, 
            XAUX_LOCALE_NAME, 
            SYSTEM_PROFILE_NAME);

    log_f("get_list_of_supported_locales: file name :%s\n",file_name);
    fp = fopen(file_name, "r");
    if (! fp)
       return (-1);

    fd = fileno((FILE *)fp);
    if (fstat(fd, &buf) < 0) {
        return -1;
    }
    fsize = buf.st_size;
    log_f("get_list_of_supported_locales: fsize [%d]\n",fsize);
    file_buf = (char *)calloc(fsize, sizeof(char));
    nfread = fread(file_buf, fsize, 1, fp);
    log_f("get_list_of_supported_locales: nfread [%d]\n",nfread);

    curr_ptr = 0;

    do {
        get_line(file_buf, fsize, &curr_ptr, line);

       if (line[0] == '\0') break;
       if (line[0] == '#') continue;

       len = strlen(line);
       if (line[0] == '[' && line[len-1] == ']') {
           /* compute locale_flag */
           ptr = line + 1;
           while(isspace(*ptr)) ptr++;

           memset((char *)locale_name,'\0',sizeof(locale_name));
           /* get locale section name */
           kptr = locale_name;
           while (*ptr && !isspace(*ptr) && *ptr!=']') 
              *(kptr++) = *(ptr++);
           *kptr = '\0';

           /* get locale section name */
           if (!strcasecmp(locale_name, COMMON_ENGINE_PATH))
              locale_flag = ENCODES_NUM;
           else if(!strcasecmp(locale_name, GENERIC_IM_TABLE_NAME)){
              generic_flag = 1;
              continue;
           }else if(!strcasecmp(locale_name, SWITCH_TO_NEXT_LOCALE)){
                switch_to_next_locale_flag = 1;
              continue;
           }else if(!strcasecmp(locale_name, SWITCH_TO_PREV_LOCALE)){
              switch_to_prev_locale_flag = 1;
              continue;
           }else if(!strcasecmp(locale_name, SWITCH_LAYOUT_NAME)){
              switch_layout_flag = 1;
              continue;
           } 

           if(!generic_flag)
              locale_flag = get_encodeid_from_locale(locale_name);
           else{
              locale_flag = ENCODES_NUM;

              locales[n].id = (char *)strdup(locale_name);
              locales[n].name = (UTFCHAR *)calloc(strlen(locale_name)+1,sizeof(UTFCHAR));
              CpyUTFCHAR(locale_name, locales[n].name);
              n++;
           }
           continue;
       }else
           continue;
    } while (1);
    locales[n].id = (char *)NULL;
    locales[n].name = (UTFCHAR *)NULL;
    fclose(fp);
    return(n);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 132 of file le.c.

{
    char file_name[PATH_MAX];

    snprintf(file_name, sizeof(file_name),"%s/%s/%s", 
                 DEFAULT_ENGINE_PATH, XAUX_LOCALE_NAME, HOTKEY_CONFIG_FILE);

    log_f("if_GetHotkeyInfo: file_name [%s]\n", file_name);

    g_hkms = parse_hotkey_config_file(a_le_name, file_name);

    /*
     * printHotkeyManager(g_hkms);
     */

    return g_hkms;
}

Here is the call graph for this function:

void if_GetIfInfo ( IMArgList  args,
int  num_args 
)

Definition at line 153 of file le.c.

{
    int i;

    log_f("if_GetIfInfo == num_args:%d\n", num_args);

    n_Supported_Locales =  get_list_of_supported_locales();
    log_f("n_Supported_Locales [%d]\n",n_Supported_Locales);

    for (i = 0; i < num_args; i++, args++) {
       switch (args->id) {
         case IF_VERSION:
          args->value = (IMArgVal) "1.2";
          break;
         case IF_METHOD_TABLE:
          args->value = (IMArgVal) & le_methods;
          break;
         case IF_LE_NAME:
          args->value = (IMArgVal) & lename;
          break;
         case IF_SUPPORTED_LOCALES:
          args->value = (IMArgVal) & locales;
          break;
         case IF_SUPPORTED_OBJECTS:
          args->value = (IMArgVal) objects; 
          break;
         case IF_NEED_THREAD_LOCK:
          args->value = (IMArgVal) True;
          break;
         default:
          break;
       }
    }
}

Here is the call graph for this function:

Bool if_le_CreateSC ( iml_session_t s,
IMArgList  args,
int  num_args 
)
Bool if_le_GetIFValue ( iml_if_t If,
IMArgList  args,
int  num_args 
)
Bool if_le_GetSCValue ( iml_session_t s,
IMArgList  args,
int  num_args 
)
Bool if_le_OpenDesktop ( iml_desktop_t desktop,
IMArgList  args,
int  num_args 
)
void if_le_SendEvent ( iml_session_t s,
IMInputEvent ev 
)
Bool if_le_SetIFValue ( iml_if_t If,
IMArgList  args,
int  num_args 
)
Bool if_le_SetSCValue ( iml_session_t s,
IMArgList  args,
int  num_args 
)

Definition at line 103 of file le_proc.c.

{
    int i;

    if (ime_buffer->inputkey_buf) free(ime_buffer->inputkey_buf);
    if (ime_buffer->preedit_buf)  free(ime_buffer->preedit_buf);
    if (ime_buffer->prev_preedit_buf)  free(ime_buffer->prev_preedit_buf);
    if (ime_buffer->status_buf)   free(ime_buffer->status_buf);
    if (ime_buffer->commit_buf)   free(ime_buffer->commit_buf);

    for (i =0; i<MAX_CANDIDATES_NUM; i++) {
       if (ime_buffer->lookup_buf[i])
           free(ime_buffer->lookup_buf[i]);
       if (ime_buffer->candidates_buf[i])
           free(ime_buffer->candidates_buf[i]);
       if (ime_buffer->additions_buf[i])
           free(ime_buffer->additions_buf[i]);
    }
       
    if (ime_buffer->lookup_buf)
       free(ime_buffer->lookup_buf);
    if (ime_buffer->candidates_buf)
       free(ime_buffer->candidates_buf);
    if (ime_buffer->additions_buf)
       free(ime_buffer->additions_buf);

    free(ime_buffer);
}

Definition at line 57 of file le_proc.c.

{
    int i;
    IMEBuffer ime_buffer;

    ime_buffer = (IMEBufferRec *)calloc(1, sizeof(IMEBufferRec));

    ime_buffer->inputkey_buf = (int *)calloc(MAX_INPUT_KEY_NUM, sizeof(int));       
    ime_buffer->preedit_buf = (unsigned char *)calloc(MAX_PREEDIT_CHAR_NUM, sizeof(char));
    ime_buffer->prev_preedit_buf = (unsigned char *)calloc(MAX_PREEDIT_CHAR_NUM, sizeof(char));
    ime_buffer->status_buf = (unsigned char *)calloc(MAX_STATUS_CHAR_NUM, sizeof(char));
    ime_buffer->commit_buf = (unsigned char *)calloc(MAX_COMMIT_CHAR_NUM, sizeof(char));

    ime_buffer->lookup_buf = (unsigned char **)calloc(MAX_CANDIDATES_NUM, sizeof(unsigned char *));
    ime_buffer->candidates_buf = (unsigned char **)calloc(MAX_CANDIDATES_NUM, sizeof(unsigned char *));
    ime_buffer->additions_buf = (unsigned char **)calloc(MAX_CANDIDATES_NUM, sizeof(unsigned char *));

    if (      (ime_buffer == NULL) ||
              (ime_buffer->inputkey_buf == NULL) ||
              (ime_buffer->preedit_buf == NULL) ||
              (ime_buffer->prev_preedit_buf == NULL) ||
              (ime_buffer->status_buf == NULL) ||
              (ime_buffer->commit_buf == NULL) ||
              (ime_buffer->lookup_buf == NULL) ||
              (ime_buffer->candidates_buf == NULL) ||
              (ime_buffer->additions_buf == NULL) )
       goto Error;

    for (i =0; i<MAX_CANDIDATES_NUM; i++) {
       ime_buffer->lookup_buf[i] = (unsigned char *)calloc(MAX_CANDIDATE_CHAR_NUM, sizeof(char));
       ime_buffer->candidates_buf[i] = (unsigned char *)calloc(MAX_CANDIDATE_CHAR_NUM, sizeof(char));
       ime_buffer->additions_buf[i] = (unsigned char *)calloc(MAX_CANDIDATE_CHAR_NUM, sizeof(char));

       if (   (ime_buffer->lookup_buf[i] == NULL) ||
              (ime_buffer->candidates_buf[i] == NULL) ||
              (ime_buffer->additions_buf[i] == NULL) )
           goto Error;
    }

    return(ime_buffer);

Error:
    ime_buffer_free(ime_buffer);
    return(NULL);
}

Here is the call graph for this function:

Bool is_trigger_on_required ( unit_desktop_t udp,
char *  locale 
)

Definition at line 618 of file le.c.

{
    int i;

    for (i=0 ; i<udp->gEngine_Num ; i++) {
        /*
        log_f("udp->modeList[%d]->locale_name [%s], locale [%s]\n", i, udp->modeList[i]->locale_name, locale);
        log_f("udp->modeList[%d]->default_state [%s]\n", i, udp->modeList[i]->default_state);
        */
       if ((!strcmp(udp->modeList[i]->locale_name, locale)) && (!strcmp(udp->modeList[i]->default_state, (char *)"CONV_ON")))
           return True;
    }
    return False;
}

Definition at line 230 of file hotkey_config.c.

{
   IMHotkeyManagerStruct *hkm;
   IMHotkeyProfileStruct *hkp;
   xmlDocPtr doc;
   xmlNodePtr cur;
   int i;

   LIBXML_TEST_VERSION

   xmlKeepBlanksDefault(0);

   /*
    * build an XML tree from the configuration file
    */

   doc = xmlParseFile(filename);
   if (doc == NULL) return(NULL);

   /*
    * Check if the document is of the right kind
    */
   
   cur = xmlDocGetRootElement(doc);
   if (cur == NULL) {
     printf("Empty document ..\n");
     xmlFreeDoc(doc);
     return(NULL);
   }

   /*
    * Allocate the structure to be returned.
    */

   hkm = (IMHotkeyManagerStruct *) calloc(1, sizeof(IMHotkeyManagerStruct));
   if (hkm == NULL) {
     printf("parse_hotkey_config_file: calloc error \n");
     xmlFreeDoc(doc);
     return(NULL);
   }

   /*
    * Now, walk the tree.
    */

   /* First level we expect just le */
   if (!xmlStrcmp(cur->name, (const xmlChar *)"le")) {
     cur = cur->xmlChildrenNode;
   } else {
     printf("Invalid configuration file ..\n");
     xmlFreeDoc(doc);
     return(NULL);
   }
   
   while (cur != NULL) {
     if (!xmlStrcmp(cur->name, (const xmlChar *)"name")) {
       char *le_name = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
       cur = cur->next;
     }
     if (!xmlStrcmp(cur->name, (const xmlChar *)"text") || !xmlStrcmp(cur->name, (const xmlChar *)"comment")) {
       cur = cur->next;
     }
     if (!xmlStrcmp(cur->name, (const xmlChar *)"num_hotkey_profiles")) {
       hkm->num_hotkey_profiles = atoi(xmlNodeListGetString(doc, cur->xmlChildrenNode, 1));
       hkm->hkps = (IMHotkeyProfileStruct *)calloc(hkm->num_hotkey_profiles, sizeof(IMHotkeyProfileStruct));
       cur = cur->next;
     }
     if (!xmlStrcmp(cur->name, (const xmlChar *)"hotkey_profile")) {
       for (i=0; i<hkm->num_hotkey_profiles; i++) {
         /*
         hkm->hkps[i] = (IMHotkeyProfileStruct *)parseHotkeyProfile(doc, cur);
         */
         hkp = parseHotkeyProfile(doc, cur);
         hkm->hkps[i].profile_id = hkp->profile_id;
         hkm->hkps[i].scope = hkp->scope;
         hkm->hkps[i].name = le_name;
         hkm->hkps[i].num_hotkeys = hkp->num_hotkeys;
         hkm->hkps[i].hks = hkp->hks;
         if (cur)
           cur = cur->next;
       }
     }
   }
  
   return hkm;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 321 of file hotkey_config.c.

{
   int i, j, k;

   printf("\nprintHotkeyManager: num_hotkey_profiles [%d]\n", hkm->num_hotkey_profiles);
   for (i=0; i<hkm->num_hotkey_profiles; i++) {
     printf("\n++++ HOTKEY PROFILE: id [%d]\n", hkm->hkps[i].profile_id);
     printf("++++ scope [%d]\n", hkm->hkps[i].scope);
     printf("++++ num_hotkeys [%d]\n", hkm->hkps[i].num_hotkeys);
     for (j=0; j<hkm->hkps[i].num_hotkeys; j++) {
       printf("\n++++++ HOTKEY: state_flag [%d]\n", hkm->hkps[i].hks[j].state_flag);
       printf("++++++ HOTKEY: action_flag [%d]\n", hkm->hkps[i].hks[j].action_flag);
       printf("++++++ HOTKEY: label [%s]\n", hkm->hkps[i].hks[j].label);
       printf("++++++ HOTKEY: nkeys [%d]\n", hkm->hkps[i].hks[j].nkeys);
       for (k=0; k<hkm->hkps[i].hks[j].nkeys; k++) {
         printf("\n++++++++ KEYS: keyCode [%d]\n", hkm->hkps[i].hks[j].keys[k].keyCode);
         printf("++++++++ KEYS: modifier [%d]\n", hkm->hkps[i].hks[j].keys[k].modifier);
       }
     }
   }
}

Definition at line 66 of file key_event.c.

{
    MyDataPerSession *session_data = (MyDataPerSession *) s->specific_data;
    IMKeyEventStruct *key_event = (IMKeyEventStruct *) keylistevent->keylist;
    char *cur_locale_string;
    char *cur_engine_string;
    int i,  key_ret, engine_id;
    int feid = 0, leid = 0;
    int keyCode, Modifier, keyChar;

    keyCode = key_event->keyCode;
    keyChar = key_event->keyChar;
    Modifier = key_event->modifier;

    cur_locale_string = (char *)alloca(256 * sizeof(char));
    cur_engine_string = (char *)alloca(256 * sizeof(char));

    (void) memset((char *)cur_locale_string,'\0',256);
    (void) memset((char *)cur_engine_string,'\0',256);

    /* if no input methods in language engine. */
    if (udp->gEngine_Num <=0) {
       log_f("udp->gEngine_Num is zero \n");
       iml_sendback_key(s, key_event);
       return;
    }

    key_ret = map_keyevent_to_immkey(udp, key_event);
    engine_id = session_data->paletteaux_status.engine_id;

    switch (key_ret) {
       /* English status <----> Non-English status */
      case ENGLISH_NONENGLISH_SWITCH_KEY:
       proc_key_switch_conversion_event(udp, s, CONVERSION_OFF, (char *)NULL);
       return;

       /* Bound Switching between Input Methods */
      case ROUND_SWITCH_KEY:
       proc_key_round_switch_ime_event(udp, s);
       return;

    }

    if ((keyCode == udp->nextLocaleKeycode) && (Modifier == udp->nextLocaleModifier)) {
       switch_to_next_lang(s, udp, engine_id);
       return;
    }

    if ((keyCode == udp->prevLocaleKeycode) && (Modifier == udp->prevLocaleModifier)) {
       switch_to_prev_lang(s, udp, engine_id);
       return;
    }

    if((keyCode == udp->layoutNameKeyCode) && (Modifier == udp->layoutNameModifier)){ 
       /*  Changing keyboard layout Name */
       log_f("Changing Layout: engine_id [%d]\n",engine_id);
       (void) strncpy((char *)cur_locale_string, udp->modeList[engine_id]->locale_name, strlen( udp->modeList[engine_id]->locale_name));
       log_f("Changing Layout: cur_locale_string [%s]\n",cur_locale_string);
       (void) strncpy((char *)cur_engine_string, udp->modeList[engine_id]->engine_name, strlen(udp->modeList[engine_id]->engine_name));
       log_f("Changing Layout: engine_name [%s]\n",cur_engine_string);

       for(i=0; i< udp->locale_Num; i++){
           if(!strcmp(cur_locale_string, udp->localeList[i].locale_name)){
              feid = udp->localeList[i].firstEngineId;
              leid = udp->localeList[i].lastEngineId;
           }
       }
       log_f("Changing Layout: feid [%d] leid [%d]\n",feid, leid);
       for (i = engine_id; i<= udp->gEngine_Num; i++) {
           if(!strcmp(cur_locale_string, udp->modeList[i]->locale_name)){
              if(!strcmp(cur_engine_string, udp->modeList[i]->engine_name)){
                  log_f("Engine EQUAL <%s>\n",udp->modeList[i]->engine_name);
                  if(engine_id == leid){
                     log_f("engine_id == leid \n");
                     le_switch_engine(udp, s, feid, True);
                     break;
                  }
              }else{
                  log_f("Engine NOT EQUAL engine_name <%s>\n",udp->modeList[i]->engine_name);
                  log_f("NOT EQUAL engine_id <%d>\n",udp->modeList[i]->engine_id);
                  le_switch_engine(udp, s, udp->modeList[i]->engine_id, True);
                  break;
              }
           }
       }
       return;
    }
    proc_key_output(udp, s, key_event);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void proc_key_switch_conversion_event ( unit_desktop_t ,
iml_session_t ,
int  ,
char *   
)

Definition at line 364 of file key_event.c.

{
    MyDataPerSession *session_data = (MyDataPerSession *) s->specific_data;
    MyDataPerDesktop *desktop_data = (MyDataPerDesktop *)(s->desktop->specific_data);
    int engine_id, i;
    char locale_id, system_locale_id;

    log_f("ENGLISH_NONENGLISH SWITCH IME KEY, on:%d\n", on);

    le_clear_ime_buffer(s, session_data->ime_buffer);

    session_data->paletteaux_status.on = on;
    engine_id = session_data->paletteaux_status.engine_id;
    log_f("proc_key_switch_conversion_event: engine_id <%d>\n", engine_id);
    if (on == CONVERSION_OFF) {
       log_f("Inside CONVERSION_OFF \n");
       le_status_draw(udp, s);
       iml_conversion_off(s);
    } else {
       log_f("Inside CONVERSION_ON \n");
       iml_conversion_on(s);
       if (engine_id != 0xff) {
           log_f("engine_id != 0xff \n");
           le_switch_engine(udp, s, engine_id, True);
       }
    }

    if (on == CONVERSION_ON && engine_id == 0xff) {
       if (to_locale == NULL || to_locale[0] == '\0'){
           log_f("key_event: to_locale is NULL \n");
           system_locale_id = desktop_data->aux_locale_id;
           log_f("keyevent.c: system_locale_id <%d>\n",system_locale_id);
           engine_id = 0;
           for (i = 0; i< udp->gEngine_Num; i++) {
              locale_id = udp->gEngine_Info[i]->core.baseinfo.locale_id;
              log_f("keyevent.c: system_locale_id <%d> locale_id <%d>\n",system_locale_id,locale_id);
              if (locale_id == system_locale_id || locale_id == ENCODES_NUM) {
                  engine_id = i;
                  break;
              }
           }
       }else{
           log_f("key_event: to_locale is Not NULL \n");
           for (i = 0; i< udp->gEngine_Num; i++) {
              if(!strcmp(to_locale, udp->modeList[i]->locale_name)){
                  engine_id = i;
                  break;
              }
           }
       }
       log_f("engine_id:%d\n", engine_id);
       le_switch_engine(udp, s, engine_id, True);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 160 of file key_event.c.

{
    MyDataPerSession *session_data = (MyDataPerSession *) s->specific_data;
    IMKeyEventStruct *key_event = (IMKeyEventStruct *) keylistevent->keylist;
    int key_ret;
    int keyCode, Modifier, keyChar;
    int on = session_data->paletteaux_status.on;

    keyCode = key_event->keyCode;
    keyChar = key_event->keyChar;
    Modifier = key_event->modifier;

    /* Incase of Hotkey Event, keylistEvent->n_operation holds the Hotkey_ID and   */ 
    /* keylistEvent->n_key holds the Index of KEYEVENT in LISTofKEYEVENT in HOTKEY */

    log_f("process_hotkey_event: session [%x], udp [0x%x], Hotkey ID [%d], Index [%d] \n", s, udp, keylistevent->n_operation, keylistevent->n_key);

    /* if no input methods in language engine. */
    if (udp->gEngine_Num <=0) {
       log_f("udp->gEngine_Num is zero \n");
       iml_sendback_key(s, key_event);
       return;
    }

    key_ret = map_keyevent_to_immkey(udp, key_event);

    switch (key_ret) {
       /* If the incoming key is Hotkey (deadkey) and                  */
       /* 1. If Client conversion mode is turned OFF, then             */
       /*    - turn ON the conversion and set hotkey_flag as          */
       /*      IME_HOTKEY_START (this flag will be changed by Xctim    */
       /*      to IME_HOTKEY_END after completing the deadkey          */
       /*      composition and committing it)                          */
       /*    - session_data->ime_buffer->conv_flag helps restore       */
       /*      the original CONVERSION MODE of the client              */
       /*    - In this case, since conv_flag = CONVERSION_OFF,         */
       /*      once the deadkey operation is completed, conversion     */
       /*      will be turned OFF                                      */
       /* 2. If Client conversion mode is turned ON, then              */
       /*    - In this case, since conv_flag = CONVERSION_ON,          */
       /*      once the deadkey operation is completed, conversion     */
       /*      will still be turned ON.                                */
       /*    - process the key input                                   */

      case IME_DEADKEY_AS_HOTKEY:
      {
        if (!on) {
          session_data->paletteaux_status.engine_id = 0xff;
          proc_key_switch_conversion_event(udp, s, CONVERSION_ON, (char *)"en");
          session_data->ime_buffer->hotkey_flag = IME_HOTKEY_START;
          session_data->ime_buffer->conv_flag = CONVERSION_OFF;
        } else {
          session_data->ime_buffer->conv_flag = CONVERSION_ON;
        }
        proc_key_output(udp, s, key_event);
        return;
      }

      case IME_COMPOSE_KEY_AS_HOTKEY:
      {
        if (!on) {
          session_data->paletteaux_status.engine_id = 0xff;
          proc_key_switch_conversion_event(udp, s, CONVERSION_ON, (char *)"en");
          session_data->ime_buffer->hotkey_flag = IME_HOTKEY_START;
          session_data->ime_buffer->conv_flag = CONVERSION_OFF;
        } else {
          session_data->ime_buffer->conv_flag = CONVERSION_ON;
        }
        key_event->keyCode = IM_VK_T;
        key_event->keyChar = IM_VK_T;
        key_event->modifier = IM_CTRL_MASK|IM_SHIFT_MASK ;

        proc_key_output(udp, s, key_event);
        return;
      }

      case IME_EURO_KEY_AS_HOTKEY:
      {
       session_data->ime_buffer->hotkey_flag = IME_HOTKEY_COMMIT;
        if (!on) {
          session_data->paletteaux_status.engine_id = 0xff;
           proc_hotkey_conversion_event(udp, s, CONVERSION_ON, (char *)"en");
          session_data->ime_buffer->conv_flag = CONVERSION_OFF;
        } else {
          session_data->ime_buffer->conv_flag = CONVERSION_ON;
        }
        proc_key_output(udp, s, key_event);
        return;
      }
    }
    proc_key_output(udp, s, key_event);
}

Here is the call graph for this function:

Definition at line 612 of file unit_input.c.

{
    char          file_name[PATH_MAX];
    iml_nsl       *nsl;
    void          *nsl_callback;

    nsl_callback = unit_ns_callback;

    nsl = calloc(1, sizeof(iml_nsl));
    snprintf(file_name, sizeof(file_name), "%s/%s", XAUX_LOCALE_NAME, SYSTEM_PROFILE_NAME);
    nsl->path_name = file_name ;
    nsl->calldata = udp ; /* anything unit need */
    s->If->m->iml_add_listener(s, "iiim.le.io.listener", nsl_callback, nsl);
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1049 of file unit_input.c.

{
    int i;
    char *name;

    for (i=0; i<udp->gEngine_Num; i++) {
       name = udp->gEngine_Info[i]->core.baseinfo.ename;
       if (name) free(name);

       name = udp->gEngine_Info[i]->core.envinfo.lang_name;
       if (name) free(name);

       name = udp->gEngine_Info[i]->core.envinfo.locale_name;
       if (name) free(name);

       udp->gEngine_Info[i]->so_methods->IME_Close(&(udp->gEngine_Info[i]->core));
       dlclose(udp->gEngine_Info[i]->so_handler);
       free((char *)udp->gEngine_Info[i]);

       name = udp->modeList[i]->locale_name;
       if (name) free(name);

       name = udp->modeList[i]->nlocale_name;
       if (name) free(name);

       name = udp->modeList[i]->nlayout_name;
       if (name) free(name);

       name = udp->modeList[i]->engine_name;
       if (name) free(name);

       free((char *)udp->modeList[i]);
       udp->modeList[i] = 0;
    }
    udp->gEngine_Num = 0;

    for(i=0; i<udp->locale_Num; i++){
       name = udp->localeList[i].locale_name;
       if (name) free(name);
    }
    free((LocaleList *)udp->localeList);
    udp->localeList = 0;
}

Here is the caller graph for this function:

Definition at line 641 of file unit_input.c.

{
    return udp->curr_hotkey_profile_id;
}

Definition at line 358 of file unit_input.c.

                                       {
    int i;

    if (udp->gEngine_Num > 0)
       return;

    udp->gEngine_Num = 0;
    udp->locale_Num = 0;
    udp->nextLocaleKeycode = 0;
    udp->nextLocaleModifier = 0;
    udp->prevLocaleKeycode = 0;
    udp->prevLocaleModifier = 0;
    udp->layoutNameKeyCode = 0;
    udp->layoutNameModifier = 0;
    udp->curr_hotkey_profile_id = -1;
    udp->localeList = (LocaleList *)NULL;
    for (i=0; i<MAX_ENGINE_NUM; i++)
       udp->gEngine_Info[i] = NULL;

    return;
}

Here is the caller graph for this function:

int unit_desktop_load_engines ( unit_desktop_t udp,
iml_desktop_t desktop 
)

Definition at line 670 of file unit_input.c.

{
    iml_nsc          *nsc;
    int              ns_id;
    char             file_name[PATH_MAX];
    int              fd, size, nread;
    char             *file_buf;
    struct stat      stat_buf;
    /*
    struct dirent    *dirp;
    DIR              *Dp;
    */
    FILE             *fp;
    iml_nsc_create_t le_nsc_create;
    iml_nsc_free_t   le_nsc_free;
#ifdef NSC_FIO_SET
    iml_nsc_basic_fioset_t *bfio;
#else
    iml_nsc_open_t le_open; 
    iml_nsc_stat_t le_stat;
    iml_nsc_read_t le_read;
    iml_nsc_close_t le_close;
    iml_nsc_umask_t le_umask;
    /*
    iml_nsc_lstat_t le_lstat;
    iml_nsc_opendir_t le_opendir;
    iml_nsc_readdir_t le_readdir;
    iml_nsc_closedir_t le_closedir;
    iml_nsc_mkdir_t le_mkdir;
    */
#endif

    le_nsc_create = (iml_nsc_create_t) (desktop->If->nsc_get_function("_nsc_create"));
    le_nsc_free = (iml_nsc_free_t) (desktop->If->nsc_get_function("_nsc_free"));

    nsc = le_nsc_create("unitle", IML_NSC_TYPE_DESKTOP, desktop);

#ifdef NSC_FIO_SET
    bfio = (iml_nsc_basic_fioset_t *) (desktop->If->nsc_get_function("_nsc_basicfioset"));
#else
    le_open = (iml_nsc_open_t) (desktop->If->nsc_get_function("open"));
    le_stat = (iml_nsc_stat_t) (desktop->If->nsc_get_function("stat"));
    le_read = (iml_nsc_read_t) (desktop->If->nsc_get_function("read"));
    le_close = (iml_nsc_close_t) (desktop->If->nsc_get_function("close"));
    le_umask = (iml_nsc_umask_t) (desktop->If->nsc_get_function("umask"));
    /*
    le_lstat = (iml_nsc_lstat_t) (desktop->If->nsc_get_function("lstat"));
    le_opendir = (iml_nsc_opendir_t) (desktop->If->nsc_get_function("opendir"));
    le_readdir = (iml_nsc_readdir_t) (desktop->If->nsc_get_function("readdir"));
    le_closedir = (iml_nsc_closedir_t) (desktop->If->nsc_get_function("closedir"));
    le_mkdir = (iml_nsc_mkdir_t) (desktop->If->nsc_get_function("mkdir"));
    */
#endif

    if (!le_umask) {
      log_f("iml_nsc_umask_t() not supported \n");
    }

    size = -1;
    snprintf(file_name, sizeof(file_name), "%s/%s/%s/%s", VAR_LE_DIR, XAUX_LOCALE_NAME, desktop->user_name, SYSTEM_PROFILE_NAME);

#ifdef NSC_FIO_SET
    if ((ns_id = bfio->open(nsc, file_name, O_RDWR)) < 0) {
#else
    if ((ns_id = le_open(nsc, file_name, O_RDWR )) < 0) {
#endif
/*
       log_f("open error [%d] [%s]\n", errno, sys_errlist[errno]);
*/
       log_f("Namespace not defined, read from default location \n");
       snprintf(file_name, sizeof(file_name), "%s/%s/%s",  DEFAULT_ENGINE_PATH, XAUX_LOCALE_NAME, SYSTEM_PROFILE_NAME);
       log_f("file name :%s\n",file_name);
       fp = fopen(file_name, "r");
       if (! fp)
           return (-1);
       fd = fileno((FILE *)fp);
       if (fstat(fd, &stat_buf) < 0) {
           return -1;
       }
       size = stat_buf.st_size;
       log_f("size [%d]\n",size);
       file_buf = (char *)calloc(size, sizeof(char));
       nread = fread(file_buf, size, 1, fp);
       log_f("nread [%d]\n",nread);
       unit_ns_read_config(udp, file_buf, size);
       if (numLocales) {
           desktop->If->updateSupportedLocales(desktop, &leName, loc, numLocales);
       }
       fclose(fp);
       return 0;
    }

    memset(&stat_buf, '\0', sizeof(stat_buf));
#ifdef NSC_FIO_SET
    if ((bfio->stat(nsc, ns_id, &stat_buf)) < 0) {
       bfio->close(nsc, ns_id);
#else
    if ((le_stat(nsc, file_name, &stat_buf)) < 0) {
        le_close(nsc, ns_id);
#endif
       le_nsc_free(nsc);
       return 0;
    }

    if (stat_buf.st_size) {
       file_buf = (char *) calloc(stat_buf.st_size, sizeof(char));
#ifdef NSC_FIO_SET
       nread = bfio->read(nsc, ns_id, file_buf, stat_buf.st_size);
       if (nread <= 0) {
           log_f("Error in read file \n");
           bfio->close(nsc, ns_id);
           return -1;
       }
#else
        nread = le_read(nsc, ns_id, file_buf, stat_buf.st_size);
        if (nread <= 0) {
            log_f("Error in read file \n");
            le_close(nsc, ns_id);
            return -1;
        }
#endif
       unit_ns_read_config(udp, file_buf, stat_buf.st_size);
  
       if (numLocales) {
           desktop->If->updateSupportedLocales(desktop, &leName, loc, numLocales);
       }
    }
    le_close(nsc, ns_id);
    le_nsc_free(nsc);

    /*
      memset(&stat_buf, '\0', sizeof(stat_buf));
#ifdef NSC_FIO_SET
      if ((bfio->lstat(nsc, file_name, &stat_buf)) < 0) {
      bfio->close(nsc, ns_id);
      le_nsc_free(nsc);
      return 0;
      }
      bfio->close(nsc, ns_id);
#else
      if ((le_lstat(nsc, file_name, &stat_buf)) < 0) {
      le_close(nsc, ns_id);
      le_nsc_free(nsc);
      return 0;
      }
      le_close(nsc, ns_id);
#endif
      log_f("UNIT: file_size from lstat [%ld]\n",stat_buf.st_size);
      log_f("UNIT: mtime from lstat [%ld]\n",stat_buf.st_mtime);

#ifdef NSC_FIO_SET
      memset((char *)file_name,'\0',sizeof(file_name));
      snprintf(file_name, sizeof(file_name), "%s/%s/%s", VAR_LE_DIR, XAUX_LOCALE_NAME, desktop->user_name);
      Dp = bfio->opendir(nsc, file_name);
      while ((dirp = bfio->readdir(nsc, Dp)) != NULL) {
      log_f("UNIT: d_reclen [%x]\n", dirp->d_reclen);
      log_f("UNIT: d_name [%s]\n", dirp->d_name);
      }
      bfio->closedir(nsc, Dp);

      memset((char *)file_name,'\0',sizeof(file_name));
      snprintf(file_name, sizeof(file_name), "%s/%s/%s/%s", VAR_LE_DIR, XAUX_LOCALE_NAME, desktop->user_name, "testMKDIR");

      bfio->mkdir(nsc, file_name, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
#else
      memset((char *)file_name,'\0',sizeof(file_name));
      snprintf(file_name, sizeof(file_name), "%s/%s/%s", VAR_LE_DIR, XAUX_LOCALE_NAME, desktop->user_name);
      Dp = le_opendir(nsc, file_name);
      while ((dirp = le_readdir(nsc, Dp)) != NULL) {
      log_f("UNIT: d_reclen [%x]\n", dirp->d_reclen);
      log_f("UNIT: d_name [%s]\n", dirp->d_name);
      }
      le_closedir(nsc, Dp);

      memset((char *)file_name,'\0',sizeof(file_name));
      snprintf(file_name, sizeof(file_name), "%s/%s/%s/%s", VAR_LE_DIR, XAUX_LOCALE_NAME, desktop->user_name, "testMKDIR");

      le_mkdir(nsc, file_name, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
#endif

      le_nsc_free(nsc);
    */

    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unit_desktop_set_curr_profile_id ( unit_desktop_t udp,
int  profile_id 
)

Definition at line 632 of file unit_input.c.

{
    udp->curr_hotkey_profile_id = profile_id;
}

Here is the caller graph for this function:

Definition at line 649 of file unit_input.c.

{
    iml_hkc       *hkc;
    iml_hkc_create_t le_hkc_create;
    iml_hkc_free_t le_hkc_free;

    le_hkc_create = (iml_hkc_create_t) (s->desktop->If->hkc_get_function("_hkc_create"));
    le_hkc_free = (iml_hkc_free_t) (s->desktop->If->hkc_get_function("_hkc_free"));

    hkc = le_hkc_create("unitle", IML_HKC_TYPE_DESKTOP, s->desktop);

    unit_desktop_set_curr_profile_id(udp, IME_HOTKEY_PROFILE_TWO);
    s->desktop->If->switchLEProfile(s, IME_HOTKEY_PROFILE_TWO, &leName);

    le_hkc_free(hkc);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 269 of file le.c.

{
    if (!UIf) {
       UIf = (unit_if_t *)calloc(1, sizeof(unit_if_t));
       UIf->create_unit_desktop = create_unit_desktop;
       UIf->add_unit_desktop = add_unit_desktop;
       UIf->find_unit_desktop_by_sc = find_unit_desktop_by_sc;
       UIf->ud_count = 0;
    } 
    if (!UIf) 
       log_f("calloc/realloc error in unit_if() \n");

    return UIf;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 118 of file le.c.

Definition at line 30 of file define.c.

Definition at line 116 of file le.c.

Definition at line 113 of file le.c.

char lename_string[]

Definition at line 165 of file CannaLE.c.

Definition at line 4 of file le_define.c.

Definition at line 119 of file le.c.

Definition at line 120 of file le.c.

Definition at line 114 of file le.c.

Definition at line 121 of file le.c.