Back to index

im-sdk  12.3.91
Defines | Functions | Variables
le_services.c File Reference
#include <stdio.h>
#include "le_info.h"
#include "le_session.h"
#include "le_aux_protocol.h"

Go to the source code of this file.

Defines

#define IMM_SERVICE_VERSION   0x0101
#define COMPOSITE_STYLE   0

Functions

ImeInfo le_get_ime_info (ImeInputContext)
ImeEncoding le_get_session_encoding (ImeInputContext)
ImmResult le_show_preedit (ImeInputContext)
ImmResult le_hide_preedit (ImeInputContext)
ImmResult le_update_preedit (ImeInputContext, ImePreedit)
ImmResult le_move_preedit_caret (ImeInputContext, int)
ImmResult le_show_candidates (ImeInputContext)
ImmResult le_hide_candidates (ImeInputContext)
ImmResult le_update_candidates (ImeInputContext, ImeCandidates)
ImmResult le_commit (ImeInputContext, unsigned char *)
ImHandle le_show_aux (ImeInputContext, const char *)
ImmResult le_hide_aux (ImeInputContext, ImHandle)
ImmResult le_send_aux_data (ImeEvent event)
void * le_get_ime_data (ImeInputContext, int)
ImmResult le_set_ime_data (ImeInputContext, int, void *)
void * le_load_user_profile (ImeInputContext, const char *, int *)
ImmResult le_free_user_profile (void *)
ImmResult le_save_user_profile (ImeInputContext, const char *, void *, int)
ImmResult le_beep (ImeInputContext, ImeBeepType)
ImeKeyType le_map_keyevent (ImeKey)
ImePropertyListRecle_get_ime_properties (ImeInputContext)
static void dupIMText (ImeTextRec *dst, ImeTextRec *src)
static void dupPreedit (ImePreeditRec *dst, ImePreeditRec *src)
static void dupCandidates (ImeCandidatesRec *dst, ImeCandidatesRec *src)
void freeImPreeditInternal (ImePreeditRec *dst)
void freeImCandidatesInternal (ImeCandidatesRec *dst)
ImmResult le_show_preedit_atomic (ImeInputContext ime_input_context, int backup)
ImmResult le_hide_preedit_atomic (ImeInputContext ime_input_context, int backup)
ImmResult le_update_preedit_atomic (ImeInputContext ime_input_context, ImePreedit ime_preedit, int backup)
ImmResult le_show_candidates_atomic (ImeInputContext ime_input_context, int backup)
ImmResult le_hide_candidates_atomic (ImeInputContext ime_input_context, int backup)
ImmResult le_update_candidates_atomic (ImeInputContext ime_input_context, ImeCandidates ime_candidates, int backup)

Variables

ImmServicesRec le_services

Define Documentation

#define COMPOSITE_STYLE   0

Definition at line 106 of file le_services.c.

#define IMM_SERVICE_VERSION   0x0101

Definition at line 8 of file le_services.c.


Function Documentation

static void dupCandidates ( ImeCandidatesRec dst,
ImeCandidatesRec src 
) [static]

Definition at line 134 of file le_services.c.

{
    int i;

    *dst = *src;
    if (src->title) dst->title = (unsigned char*)strdup(src->title);
    if (src->numbers) dst->numbers = (unsigned char*)strdup(src->numbers);
    dst->candidates = NULL;
    if (src->count) {
        dst->candidates = (ImeTextRec*)calloc(src->count, sizeof(ImeTextRec));
        for (i=0; i < src->count; ++i) {
            dupIMText(&(dst->candidates[i]), &(src->candidates[i]));
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void dupIMText ( ImeTextRec dst,
ImeTextRec src 
) [static]

Definition at line 108 of file le_services.c.

{
    int i;

    if (src) {
        *dst = *src;
        if (src->text) {
            dst->text = (unsigned char*)strdup((char*)src->text);
        }
        if (src->feedbacks) {
            dst->feedbacks = (ImeFeedbackRec*)calloc(src->count_feedbacks,
                                                     sizeof(ImeFeedbackRec));
            for (i = 0; i <  src->count_feedbacks; ++i)
                dst->feedbacks[i] = src->feedbacks[i];
        }
    } else {
        memset(dst, 0, sizeof(ImeTextRec));
    }
}

Here is the caller graph for this function:

static void dupPreedit ( ImePreeditRec dst,
ImePreeditRec src 
) [static]

Definition at line 128 of file le_services.c.

{
    *dst = *src;
    dupIMText(&dst->preedit, &src->preedit);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 157 of file le_services.c.

{
    int i;

    if (dst->title) free(dst->title);
    if (dst->numbers) free(dst->numbers);
    if (dst->candidates) {
        for (i=0; i < dst->count; ++i) {
            if (dst->candidates[i].text) free(dst->candidates[i].text);
            if (dst->candidates[i].feedbacks) free(dst->candidates[i].feedbacks);
        }
        free(dst->candidates);
    }
    memset(dst, 0, sizeof(ImeCandidatesRec));
}

Definition at line 150 of file le_services.c.

{
    if (dst->preedit.text) free(dst->preedit.text);
    if (dst->preedit.feedbacks) free(dst->preedit.feedbacks);
    memset(dst, 0, sizeof(ImePreeditRec));
}
ImmResult le_beep ( ImeInputContext  ime_input_context,
ImeBeepType  ime_beep_type 
)
ImmResult le_commit ( ImeInputContext  ime_input_context,
unsigned char *  commit_buf 
)
void* le_get_ime_data ( ImeInputContext  ime_input_context,
int  scope 
)
ImeInfo le_get_ime_info ( ImeInputContext  ime_input_context)
ImmResult le_hide_aux ( ImeInputContext  ime_input_context,
ImHandle  im_handle 
)
ImmResult le_hide_candidates_atomic ( ImeInputContext  ime_input_context,
int  backup 
)

Definition at line 326 of file le_services.c.

{
    LeSessionContextRec *le_session_context = (LeSessionContextRec *) ime_input_context;
    iml_session_t *s = NULL;

    if (le_session_context == NULL)
        return (IMM_FAIL);

    s = (iml_session_t *) le_session_context->s;
    if (s == NULL)
        return (IMM_FAIL);

    if (backup) {
        le_session_context->candidates_show = 0;
    }

    if (session_get_pc_aux_name(le_session_context)) {
        le_hide_compositeaux_candidates_notify(s, session_get_pc_aux_name(le_session_context));
        return (IMM_OK);
    }

    le_iml_lookup_enddraw(s);

    return (IMM_OK);
}

Here is the call graph for this function:

ImmResult le_hide_preedit ( ImeInputContext  ime_input_context)
ImmResult le_hide_preedit_atomic ( ImeInputContext  ime_input_context,
int  backup 
)

Definition at line 195 of file le_services.c.

{
    iml_session_t *s = NULL;
    LeSessionContextRec *le_session_context = (LeSessionContextRec *)ime_input_context;

    if (le_session_context == NULL || (s =le_session_context->s) == NULL)
        return (IMM_FAIL);

    if (backup) le_session_context->preedit_show = 0;

    if (session_get_pc_aux_name(le_session_context))
        le_hide_compositeaux_preedit_notify(s, session_get_pc_aux_name(le_session_context));
    else
        le_iml_preedit_enddraw(s);
    return (IMM_OK);
}

Here is the call graph for this function:

void* le_load_user_profile ( ImeInputContext  ic,
const char *  category,
int *  psz 
)
ImmResult le_move_preedit_caret ( ImeInputContext  ime_input_context,
int  index 
)
ImmResult le_save_user_profile ( ImeInputContext  ic,
const char *  category,
void *  buf,
int  sz 
)
ImmResult le_set_ime_data ( ImeInputContext  ime_input_context,
int  scope,
void *  pdata 
)
ImHandle le_show_aux ( ImeInputContext  ime_input_context,
const char *  aux_name 
)
ImmResult le_show_candidates_atomic ( ImeInputContext  ime_input_context,
int  backup 
)

Definition at line 280 of file le_services.c.

{
  LeSessionContextRec *le_session_context =
      (LeSessionContextRec *) ime_input_context;
  iml_session_t *s = NULL;
  LayoutInfo layout;
  int layout_type_vertical = 1;
  int layout_capacity = 10;
  int composite_style = 0;

  if (le_session_context == NULL)
      return (IMM_FAIL);

  s = (iml_session_t *) le_session_context->s;
  if (s == NULL)
      return (IMM_FAIL);

  if (backup) {
      le_session_context->candidates_show = 1;
  }

  if (session_get_pc_aux_name(le_session_context)) {
      le_show_compositeaux_candidates_notify(s, session_get_pc_aux_name(le_session_context));
      return (IMM_OK);
  }

  layout.choice_per_window = layout_capacity;
  if (layout_type_vertical) {
      layout.ncolumns = 1;
      layout.nrows = layout_capacity;
      layout.drawUpDirection = DrawUpVertically;
  } else {
      layout.ncolumns = layout_capacity;
      layout.nrows = 1;
      layout.drawUpDirection = DrawUpHorizontally;
  }

  le_iml_lookup_start(s, &layout);
  return (IMM_OK);
}

Here is the call graph for this function:

ImmResult le_show_preedit ( ImeInputContext  ime_input_context)
ImmResult le_show_preedit_atomic ( ImeInputContext  ime_input_context,
int  backup 
)

Definition at line 173 of file le_services.c.

{
    iml_session_t *s = NULL;
    LeSessionContextRec *le_session_context = (LeSessionContextRec *) ime_input_context;

    if (le_session_context == NULL || (s =le_session_context->s) == NULL)
        return (IMM_FAIL);

    if (backup) le_session_context->preedit_show = 1;
    if (session_get_pc_aux_name(le_session_context)) {
        le_show_compositeaux_preedit_notify(s, session_get_pc_aux_name(le_session_context));
    } else {
        le_iml_preedit_start(s);
    }
    return (IMM_OK);
}

Here is the call graph for this function:

ImmResult le_update_candidates ( ImeInputContext  ime_input_context,
ImeCandidates  ime_candidates 
)
ImmResult le_update_candidates_atomic ( ImeInputContext  ime_input_context,
ImeCandidates  ime_candidates,
int  backup 
)

Definition at line 357 of file le_services.c.

{
    UTFCHAR **lookup_strs;
    UTFCHAR **label_strs;

    int from_len, to_left, ret, i, num_candidates;
    ImeEncoding encoding;

    LeSessionContextRec *le_session_context = (LeSessionContextRec *)ime_input_context;

    if ((le_session_context == NULL) || ((le_session_context->s) == NULL) || (ime_candidates == NULL))
        return (IMM_FAIL);

    iml_session_t *s = le_session_context->s;

    if (backup && (ime_candidates != &le_session_context->candidates_backup)) {
        freeImCandidatesInternal(&le_session_context->candidates_backup);
        dupCandidates(&le_session_context->candidates_backup, ime_candidates);
    }

    num_candidates = ime_candidates->count;

    encoding = le_session_get_current_ime_encoding(s);
    if (encoding == ENCODE_INVALID)
        return (IMM_FAIL);

    if (session_get_pc_aux_name(le_session_context)) {
        le_update_compositeaux_candidates_notify(le_session_context, 
                                                 session_get_pc_aux_name(le_session_context), 
                                                 ime_candidates);
        return (IMM_OK);
    }

    lookup_strs = (UTFCHAR **) calloc(num_candidates, sizeof(UTFCHAR *));
    if (lookup_strs == NULL)
        return (IMM_FAIL);

    label_strs = (UTFCHAR **) calloc(num_candidates, sizeof(UTFCHAR *));
    if (label_strs == NULL)
        return (IMM_FAIL);

    UTFCHAR tmp_buf[1024], label_buf[64];
    UTFCHAR *tmp_ptr = tmp_buf;

    if (ime_candidates->numbers) {
        from_len = strlen(ime_candidates->numbers);
        to_left = 64 * sizeof(UTFCHAR);
        memset(tmp_buf, 0, to_left);
        tmp_ptr = label_buf;
        ret = Convert_Native_To_UTF16(encoding, ime_candidates->numbers,
                                      from_len, (char **) &tmp_ptr,
                                      (size_t *) & to_left);
    }

    for (i = 0; i < num_candidates; i++) {
        if (ime_candidates->candidates[i].text == NULL)
            continue;

        from_len = strlen(ime_candidates->candidates[i].text);
        to_left = 1024;
        memset(tmp_buf, 0, sizeof(UTFCHAR) * 1024);
        tmp_ptr = tmp_buf;
        ret = Convert_Native_To_UTF16(encoding,
                                      ime_candidates->candidates[i].text,
                                      from_len,
                                      (char **) &tmp_ptr,
                                      (size_t *) & to_left);
        if (ret == -1) {
            tmp_buf[0] = 0x20;
            tmp_buf[1] = 0;
        }

        lookup_strs[i] =
            (UTFCHAR *) calloc(1024 - to_left + 1, sizeof(UTFCHAR));
        if (lookup_strs[i] == NULL)
            continue;

        UTFCHARCpy(lookup_strs[i], tmp_buf);

        label_strs[i] = (UTFCHAR *) calloc(3, sizeof(UTFCHAR));
        if (label_strs[i] == NULL)
            continue;
        label_strs[i][0] =
            (ime_candidates->numbers) ? (label_buf[i]) : ('1' + i);
        label_strs[i][1] = '.';
        label_strs[i][2] = 0;
    }

    le_iml_lookup_draw(s, num_candidates, lookup_strs, NULL, label_strs,
                       NULL, NULL, NULL, 0,
                       (ime_candidates->horizental) ? 0 : 1);

    for (i = 0; i < num_candidates; i++) {
        if (lookup_strs[i])
            free((char *) lookup_strs[i]);
        if (label_strs[i])
            free((char *) label_strs[i]);
    }
    free((char *) lookup_strs);
    free((char *) label_strs);

    return (IMM_OK);
}

Here is the call graph for this function:

ImmResult le_update_preedit ( ImeInputContext  ime_input_context,
ImePreedit  ime_preedit 
)
ImmResult le_update_preedit_atomic ( ImeInputContext  ime_input_context,
ImePreedit  ime_preedit,
int  backup 
)

Definition at line 217 of file le_services.c.

{
    int from_len, to_left, ret;
    ImeEncoding encoding;

    LeSessionContextRec *le_session_context = (LeSessionContextRec *)ime_input_context;

    if ((le_session_context == NULL) || (ime_preedit == NULL) || (le_session_context->s == NULL))
        return (IMM_FAIL);

    iml_session_t *s = (le_session_context->s);

    if (backup && (ime_preedit != &le_session_context->preedit_backup)) {
        freeImPreeditInternal(&le_session_context->preedit_backup);
        dupPreedit(&le_session_context->preedit_backup, ime_preedit);
    }

    encoding = le_session_get_current_ime_encoding(s);
    if (encoding == ENCODE_INVALID)
        return (IMM_FAIL);

    if (session_get_pc_aux_name(le_session_context)) {
        le_update_compositeaux_preedit_notify(le_session_context, 
                                              session_get_pc_aux_name(le_session_context), 
                                              ime_preedit);
        return (IMM_OK);
    }

    UTFCHAR tmp_buf[1024] = {0};
    UTFCHAR *tmp_ptr = tmp_buf;

    if (ime_preedit->preedit.text && ime_preedit->preedit.text[0]) {
        from_len = strlen(ime_preedit->preedit.text);
        to_left = 1024;
        memset(tmp_buf, 0, sizeof(UTFCHAR) * 1024);
        ret = Convert_Native_To_UTF16(encoding,
                                      ime_preedit->preedit.text,
                                      from_len,
                                      (char **) &tmp_ptr,
                                      (size_t *) & to_left);
        if (ret == -1)
            return (IMM_FAIL);
    }

    le_iml_preedit_start(s);
    le_iml_preedit_draw(s, tmp_buf, ime_preedit->caret);

    return (IMM_OK);
}

Here is the call graph for this function:


Variable Documentation

Definition at line 32 of file le_services.c.