Back to index

im-sdk  12.3.91
Functions | Variables
le_interface.c File Reference
#include <stdio.h>
#include <iconv.h>
#include "le_object.h"
#include "le_info.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)
void if_GetIfInfo (IMArgList args, int num_args)

Variables

if_methods_t le_methods
LeInfoRecle_info = NULL
LeObjectRecle_object = NULL

Function Documentation

void if_GetIfInfo ( IMArgList  args,
int  num_args 
)

Definition at line 44 of file le_interface.c.

{
    int i;

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

    if (le_object == NULL) {
        le_object = (LeObjectRec *)le_object_new();
    }
    if (le_object == NULL)
        return;

    /*
     * get the input method information
     */
    if (le_info == NULL) {
      le_info = (LeInfoRec *) le_info_new();
      if (le_info == NULL)
       return;
    }

    for (i = 0; i < num_args; i++, args++) {
       switch (args->id) {
       case IF_VERSION:
           args->value = (IMArgVal) le_object->version;
           break;
       case IF_METHOD_TABLE:
           args->value = (IMArgVal) & le_methods;
           break;
       case IF_LE_NAME:
           args->value = (IMArgVal) le_object->lename;
           break;
       case IF_SUPPORTED_LOCALES:
           args->value = (IMArgVal) le_object->locales;
           break;
       case IF_SUPPORTED_OBJECTS:
           args->value = (IMArgVal) le_object->objects;
           break;
       case IF_NEED_THREAD_LOCK:
           args->value = (IMArgVal) LE_OK;
           break;
       case IF_SUPPORTED_IMEINFO:
           if (le_info && le_info->ime_modules)
            {
              ImeModuleContextRec **imm = le_info->ime_modules;
              iconv_t *cd = iconv_open ("UTF-8", "BIG5");
              iconv_t *ucd = iconv_open ("UTF-16", "UTF-8");
              IMEInfo *info = (IMEInfo *)malloc (sizeof (IMEInfo) * (le_info->num_ime_modules + 1));
              int k;

              /*
               * the localized inforatmion is in Big5 encoding, need to convert to
               * UTF-16, the internal encoding within IIIM
               */
              memset (info, 0, sizeof (IMEInfo) * (le_info->num_ime_modules + 1));
              for (k=0; k < le_info->num_ime_modules; ++k)
                {
                  ImeInfoRec *imeinfo = imm[k]->ime_module->info;
                  char *utfname;
                  char *inbuf;
                  int inbytesleft;
                  char *outbuf;
                  int outbytesleft;
                  UTFCHAR u16_buf[256], *pu;
                  int num_chars = 0;

                  info[k].enable = imm[k]->enabled;
                  info[k].ime_id = strdup (imeinfo->uuid);
                  if (imeinfo->encoding == ENCODE_UTF8)
                    utfname = strdup (imeinfo->name);
                  else
                     {
                       /*
                        * the localized info is in Big5 encoding, need to convert
                        * to UTF-16, the internal encoding used in IIIM
                        */
                       char utf_buf[1024];

                       inbuf = imeinfo->name;
                       inbytesleft = strlen (imeinfo->name);
                       outbuf = utf_buf;
                       outbytesleft = 1024;

                       memset (utf_buf, 0, 1024);

                       /* convert to UTF-8 at first */
                       iconv (cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
                       utfname = strdup (utf_buf);
                     }

                  memset (u16_buf, 0, 256 * sizeof (UTFCHAR));
                  inbuf = utfname;
                  inbytesleft = strlen (utfname);
                  outbuf = u16_buf;
                  outbytesleft = 256 * sizeof (UTFCHAR);

                  iconv (ucd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
                  pu = u16_buf;
                  while (*pu) {++pu; ++num_chars;}

                  pu = (UTFCHAR *)malloc (sizeof (UTFCHAR) * (num_chars + 1));
                  memcpy (pu, u16_buf, sizeof (UTFCHAR) * (num_chars + 1));
                  info[k].imename = pu;

                  free (utfname);
                }

              iconv_close (cd);
              iconv_close (ucd);

              args->value = (IMArgVal)info;
            }
           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 
)

Variable Documentation

Definition at line 40 of file le_interface.c.

Definition at line 41 of file le_interface.c.