Back to index

im-sdk  12.3.91
Classes | Functions | Variables
testEIMIL.c File Reference
#include <stdio.h>
#include "SunIM.h"
#include <EIMIL.h>

Go to the source code of this file.

Classes

struct  TestEIMILSession

Functions

Bool if_testEIMIL_OpenIF ()
Bool if_testEIMIL_CloseIF ()
Bool if_testEIMIL_GetIFValue ()
Bool if_testEIMIL_SetIFValue ()
Bool if_testEIMIL_OpenDesktop ()
Bool if_testEIMIL_CloseDesktop ()
Bool if_testEIMIL_CreateSC ()
Bool if_testEIMIL_DestroySC ()
Bool if_testEIMIL_GetSCValue ()
Bool if_testEIMIL_SetSCValue ()
IMTextif_testEIMIL_ResetSC ()
void if_testEIMIL_SetSCFocus ()
void if_testEIMIL_UnsetSCFocus ()
void if_testEIMIL_SendEvent ()
static TestEIMILSessiontestEIMIL_session_data (iml_session_t *s)
static EIMIL_handle testEIMIL_handle (iml_session_t *s)
static iml_session_ttestEIMIL_session (EIMIL_handle eh)
void init_objects ()
static IMFeedbackListcreate_feedback (iml_session_t *s, int size)
static IMTextcreate_IMText (iml_session_t *s, int len)
static IMTextUTFCHAR_to_IMText (iml_session_t *s, UTFCHAR *p)
static IMTextASCIZ_to_IMText (iml_session_t *s, unsigned char *p)
static void testEIMIL_preedit_draw (iml_session_t *s)
static void testEIMIL_preedit_done (iml_session_t *s)
static int testEIMIL_event_handler (EIMIL_handle eh, EIMIL_event *pevent)
static int testEIMIL_uichange_handler (EIMIL_handle eh, EIMIL_value *pval, int uichange_flags)
static void send_commit (iml_session_t *s, IMText *p, int executep)
static Bool testEIMIL_register_class (char *if_path)
static Bool testEIMIL_init (char *if_path)
void testEIMIL_status_draw (iml_session_t *s)
void testEIMIL_start_lookup_choice (iml_session_t *s, iml_inst **prrv, int num)
void testEIMIL_show_lookup_choice (iml_session_t *s)
void testEIMIL_lookup_choice_done (iml_session_t *s)
void testEIMIL_make_conversion_off (iml_session_t *s)
void testEIMIL_make_conversion_on (iml_session_t *s)
void if_GetIfInfo (IMArgList args, int num_args)
Bool if_testEIMIL_OpenIF (iml_if_t *If)
Bool if_testEIMIL_CloseIF (iml_if_t *If)
Bool if_testEIMIL_GetIFValue (iml_if_t *If, IMArgList args, int num_args)
Bool if_testEIMIL_SetIFValue (iml_if_t *If, IMArgList args, int num_args)
Bool if_testEIMIL_OpenDesktop (iml_desktop_t *desktop, IMArgList args, int num_args)
Bool if_testEIMIL_CloseDesktop (iml_desktop_t *desktop)
Bool if_testEIMIL_CreateSC (iml_session_t *s, IMArgList args, int num_args)
Bool if_testEIMIL_DestroySC (iml_session_t *s)
IMTextif_testEIMIL_ResetSC (iml_session_t *s)
Bool if_testEIMIL_SetSCValue (iml_session_t *s, IMArgList args, int num)
Bool if_testEIMIL_GetSCValue (iml_session_t *s, IMArgList args, int num_args)
void if_testEIMIL_SetSCFocus (iml_session_t *s)
void if_testEIMIL_UnsetSCFocus (iml_session_t *s)
void if_testEIMIL_SendEvent (iml_session_t *s, IMInputEvent *ev)

Variables

static char testEIMIL_class [] = "org.OpenI18N.testEIMIL"
static char testEIMIL_confdir [] = "../locale/common/testEIMIL"
if_methods_t testEIMIL_method_table
UTFCHAR lename_string [] = {0x304B, 0x3093, 0x306A, 0x4C, 0x45, 0x0}
UTFCHAR jahrn_string [] = {0x65E5, 0x672C, 0x8A9E, 0x0}
UTFCHAR lookup_choice_title [] = {0x5019, 0x88DC, 0x9078, 0x629E, 0x0}
static IMLEName lename
static IMLocale locales []
IMObjectDescriptorStructobjects = NULL
static EIMIL_handle eh_initial

Class Documentation

struct TestEIMILSession

Definition at line 102 of file testEIMIL.c.

Class Members
int conv_flag
EIMIL_handle eh
int luc_start
int preedit_start
int status_start

Function Documentation

static IMText* ASCIZ_to_IMText ( iml_session_t s,
unsigned char *  p 
) [static]

Definition at line 198 of file testEIMIL.c.

{
    IMText *pit;
    UTFCHAR *pu;
    int len = strlen(p);

    pit = create_IMText(s, len);
    if (!pit) return NULL;

    pu = pit->text.utf_chars;
    for (;;) {
       *pu++ = *p++;
       if (!*p) break;
    }

    return pit;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static IMFeedbackList* create_feedback ( iml_session_t s,
int  size 
) [static]

Definition at line 143 of file testEIMIL.c.

{
    int i;
    IMFeedbackList *feedback, *fbl;
    IMFeedback *fb;
    
    if (!s) return NULL;

    feedback = ((IMFeedbackList *)
              s->If->m->iml_new(s, sizeof(IMFeedbackList) * size));
    for (i = 0; i < size; i++) {
        IMFeedbackList *fbl = &feedback[i];
        fbl->count_feedbacks = 1;
       fb = ((IMFeedback *) s->If->m->iml_new(s, sizeof(IMFeedback) * 4));
       fbl->feedbacks = fb;
        memset(fbl->feedbacks, 0, sizeof(IMFeedback) * 4);
    }
    return feedback;
}
static IMText* create_IMText ( iml_session_t s,
int  len 
) [static]

Definition at line 164 of file testEIMIL.c.

{
    int i;
    IMText *p;
    
    if (!s) return NULL;

    p = (IMText *) s->If->m->iml_new(s, sizeof(IMText));
    memset(p, 0, sizeof(IMText));
    p->encoding = UTF16_CODESET;
    p->text.utf_chars = ((UTFCHAR *)
                      s->If->m->iml_new(s, sizeof(UTFCHAR) * (len + 1)));
    p->char_length = len;
    p->feedback = create_feedback(s, len);

    return p;
}

Here is the call graph for this function:

void if_GetIfInfo ( IMArgList  args,
int  num_args 
)

Definition at line 521 of file testEIMIL.c.

{
    int i;
    init_objects();
    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) &testEIMIL_method_table;
          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:

Definition at line 603 of file testEIMIL.c.

{
    return True;
}

Definition at line 564 of file testEIMIL.c.

Here is the call graph for this function:

Bool if_testEIMIL_CreateSC ( iml_session_t s,
IMArgList  args,
int  num_args 
)

Definition at line 611 of file testEIMIL.c.

{
    EIMIL_handle eh;
    TestEIMILSession *pes = (TestEIMILSession*) malloc(sizeof(TestEIMILSession));

    if (!pes) return False;

    if (!EIMIL_duplicate_handle(&eh, eh_initial)) return False;
    EIMIL_set_private(eh, s);

    pes->eh = eh;
    s->specific_data = (void*) pes;

    return True;
}

Here is the call graph for this function:

Definition at line 632 of file testEIMIL.c.

Here is the call graph for this function:

Bool if_testEIMIL_GetIFValue ( iml_if_t If,
IMArgList  args,
int  num_args 
)

Definition at line 573 of file testEIMIL.c.

{
    return True;
}
Bool if_testEIMIL_GetSCValue ( iml_session_t s,
IMArgList  args,
int  num_args 
)

Definition at line 691 of file testEIMIL.c.

{
    int i;
    IMArg *p = args;

    /* Canna uses at least LATIN, HIRAGANA, KATAKANA,
       and KANJI scripts.
       That's all to it? */
    static int charsubset[] = {
        67,                 /* LATIN */
        47,                 /* HIRAGANA */
        48,                 /* KATAKANA */
        71,                 /* KANJI */
        0
    };

    for (i = 0; i < num_args; i++, p++) {
        switch (p->id) {
            case SC_SUPPORTED_CHARACTER_SUBSETS:
                /* specify CHARACTER_SUBSETS */
                p->value = (IMArgVal) charsubset;
                break;
            default:
                break;
            }
    }
    return True;
}
Bool if_testEIMIL_OpenDesktop ( iml_desktop_t desktop,
IMArgList  args,
int  num_args 
)

Definition at line 593 of file testEIMIL.c.

{
    return True;
}

Definition at line 556 of file testEIMIL.c.

{
    return testEIMIL_init(If->ifpath_name);
}

Here is the call graph for this function:

Definition at line 642 of file testEIMIL.c.

Here is the call graph for this function:

Definition at line 733 of file testEIMIL.c.

{
    int n;
    EIMIL_value **ppevs;
    EIMIL_handle eh = testEIMIL_handle(s);

    n = EIMIL_construct_events_from_IMInputEvent(ev, &ppevs);
    for (; n > 0; n--, ppevs++) {
       if (ppevs) EIMIL_send_event(eh, *ppevs);
    }
    return;
}

Here is the call graph for this function:

Bool if_testEIMIL_SetIFValue ( iml_if_t If,
IMArgList  args,
int  num_args 
)

Definition at line 583 of file testEIMIL.c.

{
    return True;
}

Definition at line 721 of file testEIMIL.c.

Here is the call graph for this function:

Bool if_testEIMIL_SetSCValue ( iml_session_t s,
IMArgList  args,
int  num 
)

Definition at line 660 of file testEIMIL.c.

{
    int i;
    IMArg *p = args;

    for (i = 0; i < num; i++, p++) {
        switch (p->id) {
       case SC_TRIGGER_ON_NOTIFY:
           testEIMIL_make_conversion_on(s);
           break;
       case SC_TRIGGER_OFF_NOTIFY:
           testEIMIL_make_conversion_off(s);
           break;
       case SC_REALIZE:
           /* currently do nothing. */
           break;
       case SC_LOOKUP_LABELTYPE:
           break;
       default:
           break;
       }
    }

    return True;
}

Here is the call graph for this function:

Definition at line 727 of file testEIMIL.c.

{
    /* do nothing. */
}
void init_objects ( )

Definition at line 134 of file testEIMIL.c.

{
}
static void send_commit ( iml_session_t s,
IMText p,
int  executep 
) [static]

Definition at line 314 of file testEIMIL.c.

{
    iml_inst *lp;
    iml_inst *rrv = NULL;

    lp = s->If->m->iml_make_commit_inst(s, p);
    s->If->m->iml_link_inst_tail(&rrv, lp);
    if (executep) {
       s->If->m->iml_execute(s, &rrv);
    }
    return;
}
static int testEIMIL_event_handler ( EIMIL_handle  eh,
EIMIL_event pevent 
) [static]

Definition at line 264 of file testEIMIL.c.

{
    iml_inst *lp;
    iml_session_t *s = testEIMIL_session(eh);
    IMInputEvent *piev;

    piev = EIMIL_convert_event_to_IMInputEvent(pevent);

    if (piev) {
       IMKeyListEvent *pimkev = (IMKeyListEvent*) piev;
       /* I don't process this keyevent.  Return it. */
       lp = s->If->m->iml_make_keypress_inst(s, ((IMKeyEventStruct *)
                                            pimkev->keylist));
       s->If->m->iml_execute(s, &lp);
    }

    return 1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static EIMIL_handle testEIMIL_handle ( iml_session_t s) [static]

Definition at line 118 of file testEIMIL.c.

{
    return ((TestEIMILSession*)(s->specific_data))->eh;
}

Here is the caller graph for this function:

static Bool testEIMIL_init ( char *  if_path) [static]

Definition at line 361 of file testEIMIL.c.

{
    unsigned char *pfile;
    if (eh_initial) return True;

    testEIMIL_register_class(if_path);
    pfile = EIMIL_find_file(testEIMIL_class, "default.xml");
    if (!pfile) return False;
    if (!EIMIL_parse_file(&eh_initial, pfile)) return False;
    EIMIL_register_handler(eh_initial,
                        testEIMIL_event_handler,
                        NULL, NULL);

    return True;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 481 of file testEIMIL.c.

{
    TestEIMILSession *pes = testEIMIL_session_data(s);
    if (pes->luc_start == True) {
       iml_inst *lp;
        lp = s->If->m->iml_make_lookup_done_inst(s);
       s->If->m->iml_execute(s, &lp);
        pes->luc_start = False;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 493 of file testEIMIL.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 506 of file testEIMIL.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static void testEIMIL_preedit_done ( iml_session_t s) [static]

Definition at line 248 of file testEIMIL.c.

{
    TestEIMILSession *pes = testEIMIL_session_data(s);
    if (pes->preedit_start == True) {
       iml_inst *lp;
        lp = s->If->m->iml_make_preedit_done_inst(s);
       s->If->m->iml_execute(s, &lp);
        pes->preedit_start = False;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void testEIMIL_preedit_draw ( iml_session_t s) [static]

Definition at line 224 of file testEIMIL.c.

{
    iml_inst *lp;
    iml_inst *rrv = NULL;
    IMText *p;
    TestEIMILSession *pes = testEIMIL_session_data(s);

    if (pes->preedit_start == False) {
        lp = s->If->m->iml_make_preedit_start_inst(s);
        s->If->m->iml_link_inst_tail(&rrv, lp);
        pes->preedit_start = True;
    }

    // TODO
    p = ASCIZ_to_IMText(s, "test");

    lp = s->If->m->iml_make_preedit_draw_inst(s, p);
    s->If->m->iml_link_inst_tail(&rrv, lp);
    s->If->m->iml_execute(s, &rrv);
}

Here is the call graph for this function:

static Bool testEIMIL_register_class ( char *  if_path) [static]

Definition at line 336 of file testEIMIL.c.

{
    char *buf;
    int ipsize;

    ipsize = strlen(if_path);
    if (ipsize < 1) return False;
    buf = (char*) malloc((ipsize + 2) * sizeof(char)
                      + sizeof(testEIMIL_confdir));
    strcpy(buf, if_path);
    buf[ipsize] = '/';
    buf[ipsize + 1] = '\0';
    strcat(buf, testEIMIL_confdir);

    if (!EIMIL_register_class(testEIMIL_class, buf))
       return False;

    return True;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static iml_session_t* testEIMIL_session ( EIMIL_handle  eh) [static]

Definition at line 124 of file testEIMIL.c.

{
    return (iml_session_t*) EIMIL_get_private(eh);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 112 of file testEIMIL.c.

{
    return (TestEIMILSession*)(s->specific_data);
}

Here is the caller graph for this function:

Definition at line 439 of file testEIMIL.c.

{
    int num;
    iml_inst *lp;
    iml_inst *rrv = NULL;
    IMText *p;
    IMLookupDrawCallbackStruct *draw;
    TestEIMILSession *pes = testEIMIL_session_data(s);

    draw = ((IMLookupDrawCallbackStruct *)
           s->If->m->iml_new(s, sizeof(IMLookupDrawCallbackStruct)));
    memset(draw, 0, sizeof(IMLookupDrawCallbackStruct));
    draw->title = UTFCHAR_to_IMText(s, lookup_choice_title);

    /* set choices */
    {
       /* TODO */
#if 0
       fprintf(stderr, "draw->index_of_first_candidate=%x\n",
              draw->index_of_first_candidate);
       fprintf(stderr, "draw->index_of_last_candidate=%x\n",
              draw->index_of_last_candidate);
       fprintf(stderr, "draw->n_choices=%x\n",
              draw->n_choices);
       fprintf(stderr, "draw->choices=%x\n",
              draw->choices);
       fprintf(stderr, "draw->choices->label=%x\n",
              draw->choices->label);
       fprintf(stderr, "draw->max_len=%x\n", max_len);
       fprintf(stderr, "draw->index_of_current_candidate=%x\n",
              draw->index_of_current_candidate);
#endif
    }
    testEIMIL_start_lookup_choice(s, &rrv, num);
    lp = s->If->m->iml_make_lookup_draw_inst(s, draw);
    s->If->m->iml_link_inst_tail(&rrv, lp);
    s->If->m->iml_execute(s, &rrv);
}

Here is the call graph for this function:

void testEIMIL_start_lookup_choice ( iml_session_t s,
iml_inst **  prrv,
int  num 
)

Definition at line 409 of file testEIMIL.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 380 of file testEIMIL.c.

{
    iml_inst *lp;
    iml_inst *rrv = NULL;
    IMText *p;
    TestEIMILSession *pes = testEIMIL_session_data(s);

    if (pes->conv_flag) {
       p = ASCIZ_to_IMText(s, "ON");
    } else {
       p = ASCIZ_to_IMText(s, "OFF");
    }
    if (!p) return;

    if (pes->status_start == False) {
        lp = s->If->m->iml_make_status_start_inst(s);
        s->If->m->iml_link_inst_tail(&rrv, lp);
        pes->status_start = True;
    }

    lp = s->If->m->iml_make_status_draw_inst(s, p);
    s->If->m->iml_link_inst_tail(&rrv, lp);
    
    s->If->m->iml_execute(s, &rrv);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int testEIMIL_uichange_handler ( EIMIL_handle  eh,
EIMIL_value pval,
int  uichange_flags 
) [static]

Definition at line 287 of file testEIMIL.c.

Here is the call graph for this function:

static IMText* UTFCHAR_to_IMText ( iml_session_t s,
UTFCHAR p 
) [static]

Definition at line 183 of file testEIMIL.c.

{
    IMText *pit;
    UTFCHAR *p2 = p;
    int len;

    for (len = 0;*p2;p2++) len++;
    pit = create_IMText(s, len);
    if (!pit) return NULL;
    memcpy(pit->text.utf_chars, p, (len + 1) * sizeof(UTFCHAR));

    return pit;
}

Here is the call graph for this function:


Variable Documentation

Definition at line 358 of file testEIMIL.c.

UTFCHAR jahrn_string[] = {0x65E5, 0x672C, 0x8A9E, 0x0}

Definition at line 86 of file testEIMIL.c.

IMLEName lename [static]
Initial value:
 {
    "testEIMIL", lename_string     
}

Definition at line 89 of file testEIMIL.c.

UTFCHAR lename_string[] = {0x304B, 0x3093, 0x306A, 0x4C, 0x45, 0x0}

Definition at line 85 of file testEIMIL.c.

IMLocale locales[] [static]
Initial value:
 {
    {"ja", jahrn_string},   
    NULL
}

Definition at line 93 of file testEIMIL.c.

UTFCHAR lookup_choice_title[] = {0x5019, 0x88DC, 0x9078, 0x629E, 0x0}

Definition at line 87 of file testEIMIL.c.

Definition at line 133 of file testEIMIL.c.

char testEIMIL_class[] = "org.OpenI18N.testEIMIL" [static]

Definition at line 47 of file testEIMIL.c.

char testEIMIL_confdir[] = "../locale/common/testEIMIL" [static]

Definition at line 48 of file testEIMIL.c.