Back to index

im-sdk  12.3.91
Functions
SunIMPub.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

iml_instiml_execute_iml_wrapper (iml_session_t *s, iml_inst **rrv)
iml_if_tif_OpenIF (const char *if_path, const char *if_name, const char *locale, Bool call_openif)
void if_CloseIF (iml_if_t *iml_if, Bool call_closeif)
Bool if_GetIFValues (iml_if_t *, IMArgList, int)
Bool if_SetIFValues (iml_if_t *, IMArgList, int)
iml_session_tif_CreateSC (iml_if_t *, IMArgList, int)
Bool if_DestroySC (iml_session_t *)
Bool if_DestroySC_WithoutDesktopDestruction (iml_session_t *)
Bool if_GetSCValues (iml_session_t *, IMArgList, int)
Bool if_SetSCValues (iml_session_t *, IMArgList, int)
void if_SendEvent (iml_session_t *, IMInputEvent *)
IMTextif_ResetSC (iml_session_t *)
void if_SetSCFocus (iml_session_t *)
void if_UnsetSCFocus (iml_session_t *)
void sunim_slot_manager_init ()
iml_session_timl_construct_session (iml_desktop_t *, IMArgList, int)
iml_desktop_tnew_user (iml_if_t *If, const char *user_name, const char *host_name, const char *display_id)
void del_user (iml_desktop_t *desktop)
void add_session_to_desktop (iml_session_t *s)
iml_instiml_duplicate_inst (iml_inst *pinst)
void iml_delete_inst (iml_inst *pinst)
int IMText_duplicate2 (IMText *pdest, IMText *psrc)
IMTextIMText_duplicate (IMText *psrc)
void IMText_delete2 (IMText *ptext)
void IMText_delete (IMText *ptext)

Function Documentation

Definition at line 1736 of file SunIM.c.

void del_user ( iml_desktop_t desktop)

Definition at line 631 of file SunIM.c.

{
    iml_if_t *If = desktop->If;
    iml_desktop_list p, *prev;
    for (prev = &If->desktop_list; (p = *prev) != 0; prev = &p->next) {
        if (strcmp(p->user_name, desktop->user_name) == 0 &&
           strcmp(p->host_name, desktop->host_name) == 0 &&
           strcmp(p->display_id, desktop->display_id) == 0) {
#ifdef DEBUG
            printf("LE %s: %s@%s is deleted\n", If->if_name, p->user_name, p->host_name);
#endif
            *prev = p->next;
            free(p->user_name);
            free(p->host_name);
            free(p->display_id);
            free(p);
            If->desktop_count--;
            break;
        }
        if (p->next == NULL) {
            break;
        }
    }
}
void if_CloseIF ( iml_if_t iml_if,
Bool  call_closeif 
)

Definition at line 238 of file SunIM.c.

{
    if(call_openif == True) {
        If->ifm->if_CloseIF(If);
    }

    if (If->m_wrapper) {
        free (If->m_wrapper);
    }
    if (If->m) {
        free(If->m);
    }
    if (If->locale) {
        free(If->locale);
    }
    if (If->if_name) {
        free(If->if_name);
    }
    if (If->ifpath_name) {
        free(If->ifpath_name);
    }

    close_le_module(If->dl_module);

    free(If);
}
iml_session_t* if_CreateSC ( iml_if_t ,
IMArgList  ,
int   
)

Definition at line 304 of file SunIM.c.

{
    iml_session_t *s = NULL;
    Bool ret;
    IMArg *p = args;
    int i;
    
    iml_desktop_t *desktop = (iml_desktop_t *) 0;
    
    char *user_name = (char *) 0;
    char *host_name = (char *) 0;
    char *display_id = (char *) 0;
    
    for (i = 0; i < n_args; i++, p++) {
        if (p->id == UI_USER_NAME) {
            user_name = p->value;
        } else if (p->id == UI_HOST_NAME) {
            host_name = p->value;
        } else if (p->id == UI_DISPLAY_ID) {
            display_id = p->value;
        }
    }
    
    if (!user_name || !host_name || !display_id) {
        return NULL;
    }
    SUNIM_LOCK(desktop_mutex);
    desktop = find_user(If, user_name, host_name, display_id);
    if (!desktop) {
        desktop = new_user(If, user_name, host_name, display_id);
        ret = If->ifm->if_OpenDesktop(desktop, args, n_args);
        if (ret == False) {
            del_user(desktop);
           SUNIM_UNLOCK(desktop_mutex);
            return NULL;
        }
        /* Initialize the listener_id and listener_count */
        desktop->listener_id = 0;
        desktop->listener_count = 0;
    }
    /*
     * All LE specific remote file loading and hotkey registration 
     * has to be completed before unlocking desktop, if each connection
     * is assigned to one thread. If each user is assigned to one thread
     * locking is not needed.
     */
    SUNIM_UNLOCK(desktop_mutex);
    s = iml_construct_session(desktop, args, n_args);
    
    if (s) {
        add_session_to_desktop(s);
    }
    return s;
}

Definition at line 422 of file SunIM.c.

{
    if (s) {
        Bool ret;
        iml_desktop_t *desktop = s->desktop;
       iml_if_t *iml_if = s->If;

        ret = if_DestroySC_WithoutDesktopDestruction(s);
        if (!desktop->session_list) {
            iml_if->ifm->if_CloseDesktop(desktop);
            del_user(desktop);
        }
        return ret;
    }
    return False;
}

Definition at line 364 of file SunIM.c.

{
    if (s) {
       int i;
        Bool ret;
       IMFeedbackList *flist;
        
        ret = s->If->ifm->if_DestroySC(s);
        
        s->If->m->iml_delete(s);
        s->If->m->iml_delete2(s);
        
        remove_session_from_desktop(s);
        
        if (s->status_cache.text && s->status_cache.text->text.utf_chars) {
            free((char *) s->status_cache.text->text.utf_chars);
       }
        if (s->status_cache.text && s->status_cache.text->feedback) {
           for(i=0;i<DEFAULTStatusCacheSize;i++){
              flist=&s->status_cache.text->feedback[i];
              if(flist){
                  free(flist->feedbacks);
              }
           }
           free(s->status_cache.text->feedback);
       }

        if (s->status_cache.text) {
            free((char *) s->status_cache.text);
       }

        if (s->PreEditTextInfo.text && s->PreEditTextInfo.text->text.utf_chars) {
            free((char *) s->PreEditTextInfo.text->text.utf_chars);
       }
        if (s->PreEditTextInfo.text && s->PreEditTextInfo.text->feedback) {
           for(i=0;i<s->PreEditTextBufferSize;i++){
              flist=&s->PreEditTextInfo.text->feedback[i];
              if(flist){
                  free(flist->feedbacks);
              }
           }
           free(s->PreEditTextInfo.text->feedback);
        }

        if (s->PreEditTextInfo.text) {
            free((char *) s->PreEditTextInfo.text);
       }
        
        free(s);
        
        return ret;
    }
    return False;
}
Bool if_GetIFValues ( iml_if_t ,
IMArgList  ,
int   
)

Definition at line 269 of file SunIM.c.

{
    if (If) {
        return If->ifm->if_GetIFValues(If, args, n_args);
    }
    return False;
}
Bool if_GetSCValues ( iml_session_t ,
IMArgList  ,
int   
)

Definition at line 457 of file SunIM.c.

{
    if (s) {
       Bool ret=s->If->ifm->if_GetSCValues(s, args, n_args);
        s->If->m->iml_delete(s);
        return ret;
    }
    return False;
}
iml_if_t* if_OpenIF ( const char *  if_path,
const char *  if_name,
const char *  locale,
Bool  call_openif 
)

Definition at line 201 of file SunIM.c.

{
    iml_if_t *If;
    If = (iml_if_t *) calloc(1, sizeof(iml_if_t));
    If->hkm = (IMHotkeyManagerStruct *) 0;
    if (NULL != getenv("IIIMD_NSFIO_OLD")) {
       If->nsc_get_function = nsc_GetFunction;
    } else {
       extern void * fop_get_function(const char *);
       If->nsc_get_function = fop_get_function;
    }
    If->hkc_get_function = hkc_GetFunction;
    If->updateSupportedLocales = updateSupportedLocales;
    If->switchLEProfile = switchLEProfile;

    if (if_configure(If, if_path, if_name, if_locale, call_openif) == False) {
        if (If->locale) {
            free(If->locale);
        }
        if (If->if_name) {
            free(If->if_name);
        }
        if (If->ifpath_name) {
            free(If->ifpath_name);
        }
        free(If);
        If = NULL;
    }
    return If;
}

Definition at line 472 of file SunIM.c.

{
    IMText *prs = NULL;
    if (s) {
        s->If->m->iml_delete(s);
        prs = s->If->ifm->if_ResetSC(s);
       if(!prs){
           s->If->m->iml_delete(s);
       }
    }
    return prs;
}
void if_SendEvent ( iml_session_t ,
IMInputEvent  
)

Definition at line 525 of file SunIM.c.

{
    if (s) {
        s->If->ifm->if_SendEvent(s, e);
        s->If->m->iml_delete(s);
    }
    return;
}
Bool if_SetIFValues ( iml_if_t ,
IMArgList  ,
int   
)

Definition at line 282 of file SunIM.c.

{
    if (If) {
        return If->ifm->if_SetIFValues(If, args, n_args);
    }
    return False;
}

Definition at line 488 of file SunIM.c.

{
    iml_inst *rv = NULL;
    iml_inst *lp;
    if (s) {
        if (s->status_cache.text->char_length) {
            lp = s->If->m->iml_make_status_start_inst(s);
            s->If->m->iml_link_inst_tail(&rv, lp);
            lp = s->If->m->iml_make_status_draw_inst(s, s->status_cache.text);
            s->If->m->iml_link_inst_tail(&rv, lp);
            lp = s->If->m->iml_execute(s, &rv);
        }
        s->If->ifm->if_SetSCFocus(s);
        s->If->m->iml_delete(s);
    }
    return;
}
Bool if_SetSCValues ( iml_session_t ,
IMArgList  ,
int   
)

Definition at line 442 of file SunIM.c.

{
    if (s) {
        Bool ret = s->If->ifm->if_SetSCValues(s, args, n_args);
        s->If->m->iml_delete(s);
        return ret;
    }
    return False;
}

Definition at line 509 of file SunIM.c.

{
    iml_inst *lp;

    if (s) {
        lp = s->If->m->iml_make_status_done_inst(s);
        s->If->m->iml_execute(s, &lp);
        s->If->ifm->if_UnsetSCFocus(s);
        s->If->m->iml_delete(s);
    }
    return;
}

Definition at line 555 of file SunIM.c.

{
    iml_if_t *If = desktop->If;
    iml_session_t *s;
    int i;
    Bool ret;
    
    s = (iml_session_t *) calloc(1, sizeof(iml_session_t));
    s->desktop = desktop;
    s->If = If;
    s->next = NULL;

#ifdef ENABLE_EIMIL
    if (If->eh != EIMIL_VOID_HANDLE)
       EIMIL_duplicate_handle(&s->eh, If->eh);
#endif

    if ((ret=If->ifm->if_CreateSC(s, args, num_args)) == False){
        free(s);
        return NULL;
    }

    s->status_cache.text = (IMText *) calloc(1, sizeof(IMText));
    s->status_cache.text->encoding = UTF16_CODESET;
    s->status_cache.text->feedback = (IMFeedbackList *) calloc(1, sizeof(IMFeedbackList) * DEFAULTStatusCacheSize);
    s->status_cache.text->text.utf_chars = (UTFCHAR *) calloc(1, sizeof(UTFCHAR) * DEFAULTStatusCacheSize);
    s->status_cache.text->char_length = 0;
    s->status_cache.text->count_annotations = 0;
    s->status_cache.text->annotations = NULL;
    for (i = 0; i < DEFAULTStatusCacheSize; i++) {
        IMFeedbackList *fbl = &s->status_cache.text->feedback[i];
        fbl->feedbacks = (IMFeedback *) calloc(1, sizeof(IMFeedback)*DEFAULTFeedbackSize);
    }

    s->PreEditTextInfo.text = (IMText *) calloc(1, sizeof(IMText));
    s->PreEditTextInfo.text->encoding = UTF16_CODESET;
    s->PreEditTextInfo.text->text.utf_chars = (UTFCHAR *) calloc(1, sizeof(UTFCHAR) * DEFAULTPreEditTextBufferSize);
    s->PreEditTextInfo.text->feedback = (IMFeedbackList *) calloc(1, sizeof(IMFeedbackList) * DEFAULTPreEditAttrBufferSize);
    for (i = 0; i < DEFAULTPreEditTextBufferSize; i++) {
        IMFeedbackList *fbl = &s->PreEditTextInfo.text->feedback[i];
        fbl->feedbacks = (IMFeedback *) calloc(1, sizeof(IMFeedback)*DEFAULTFeedbackSize);
    }

    s->PreEditTextBufferSize = DEFAULTPreEditTextBufferSize;
    s->PreEditAttrBufferSize = DEFAULTPreEditAttrBufferSize;

    return (iml_session_t *) s;
}
void iml_delete_inst ( iml_inst pinst)

Definition at line 409 of file IMLSubr.c.

{
    int op = pinst->opcode & ~IMM_CB_RESULT_REQUIRED;

    switch (op) {
      case IMM_COMMIT:
      case IMM_RESET_RETURN:
       imli_delete_operand_imtext(pinst);
       return;
      case IMM_PREEDIT_DRAW:
       imli_delete_preedit_draw(pinst);
       return;
      case IMM_STATUS_DRAW:
       imli_delete_status_draw(pinst);
       return;
      case IMM_LOOKUP_DRAW:
       imli_delete_lookup_draw(pinst);
       return;
      case IMM_AUX_START_2:
      case IMM_AUX_DONE_2:
       imli_delete_aux_basic(pinst);
       return;
      case IMM_AUX_DRAW_2:
       imli_delete_aux_draw(pinst);
       return;
      case IMM_KEYPRESS:
      case IMM_LOOKUP_PROCESS:
      case IMM_LOOKUP_START:
      case IMM_SET_STATUS:
      default:
       imli_delete_short(pinst);
       return;
    }

    /* notreached */
    return;
}

Definition at line 274 of file IMLSubr.c.

{
    int op = pinst->opcode & ~IMM_CB_RESULT_REQUIRED;

    switch (op) {
      case IMM_KEYPRESS:
       return imli_duplicate_keypress(pinst);
      case IMM_COMMIT:
      case IMM_RESET_RETURN:
       return imli_duplicate_operand_imtext(pinst);
      case IMM_SET_STATUS:
       return imli_duplicate_set_status(pinst);
      case IMM_PREEDIT_DRAW:
       return imli_duplicate_preedit_draw(pinst);
      case IMM_STATUS_DRAW:
       return imli_duplicate_status_draw(pinst);
      case IMM_LOOKUP_START:
       return imli_duplicate_lookup_start(pinst);
      case IMM_LOOKUP_DRAW:
       return imli_duplicate_lookup_draw(pinst);
      case IMM_LOOKUP_PROCESS:
       return imli_duplicate_lookup_process(pinst);
      case IMM_AUX_START_2:
      case IMM_AUX_DONE_2:
       return  imli_duplicate_aux_basic(pinst);
      case IMM_AUX_DRAW_2:
       return imli_duplicate_aux_draw(pinst);
      case IMM_NS_LISTENER:
       return imli_duplicate_ns_listener(pinst);
      default:
       return imli_duplicate_short(pinst);
    }

    /* notreached */
    return NULL;
}

Definition at line 662 of file LE.cpp.

{
    IMLExec *pimlex = (IMLExec*) s->SessionContext;

#ifdef DEBUG
    {
       int op;
       iml_inst *pcur;

       for (pcur = *rrv; pcur != (iml_inst*)0; pcur = pcur->next) {
           op = pcur->opcode & ~IMM_CB_RESULT_REQUIRED;
           if (!pimlex)
              LOG_DEBUG("Missing IML inst. (%d)", op);
           else
              LOG_DEBUG("Issuing IML inst. (%d)", op);
       }
    }
#endif

    if (!pimlex) return NULL;
    return pimlex->push_insts(rrv);
}
void IMText_delete ( IMText ptext)

Definition at line 606 of file IMLSubr.c.

{
    IMText_delete2(ptext);
    free(ptext);
}
void IMText_delete2 ( IMText ptext)

Definition at line 569 of file IMLSubr.c.

{
    int i, j;

    if (ptext->text.utf_chars)
       free(ptext->text.utf_chars);

    if (ptext->feedback) {
       IMFeedbackList *pfbl = ptext->feedback;
       for (i = 0;
            i < ptext->char_length;
            i++, pfbl++) {
           if (pfbl->feedbacks) free(pfbl->feedbacks);
       }
       free(ptext->feedback);
    }

    if (ptext->annotations) {
       IMAnnotation *pima = ptext->annotations;
       for (i = 0;
            i < ptext->count_annotations;
            i++, pima++) {
           IMAnnotationValue *pimav = pima->values;
           for (j = 0;
               j < pima->num_values;
               j++, pimav++) {
              if (pimav->value) free(pimav->value);
           }
           if (pima->values) free(pima->values);
       }
       free(ptext->annotations);
    }
}

Definition at line 551 of file IMLSubr.c.

{
    IMText *pdest;

    if (!psrc) return NULL;

    pdest = (IMText*) malloc(sizeof(IMText));
    if (!pdest) return NULL;
    if (!IMText_duplicate2(pdest, psrc)) {
       free(pdest);
       return NULL;
    }
    return pdest;
}
int IMText_duplicate2 ( IMText pdest,
IMText psrc 
)

Definition at line 454 of file IMLSubr.c.

{
    int i, j;
    IMFeedbackList *pfbl;
    IMFeedbackList *pfbls;

    *pdest = *psrc;
    pdest->text.utf_chars = NULL;
    pdest->feedback = NULL;
    pdest->annotations = NULL;

    if (psrc->char_length > 0) {
       if (psrc->text.utf_chars) {
           UTFCHAR *pu = (UTFCHAR*) malloc(sizeof(UTFCHAR)
                                       * psrc->char_length);
           if (!pu) {
              IMText_delete2(pdest);
              return 0;
           }
           memcpy(pu, psrc->text.utf_chars, sizeof(UTFCHAR) * psrc->char_length);
           pdest->text.utf_chars = pu;
       }

       if (psrc->feedback) {
           pfbl = (IMFeedbackList*) malloc(sizeof(IMFeedbackList)
                                       * psrc->char_length);
           if (!pfbl) {
              IMText_delete2(pdest);
              return 0;
           }
           memset(pfbl, 0, sizeof(IMFeedbackList) * psrc->char_length);
           pdest->feedback = pfbl;

           pfbls = psrc->feedback;
           for (i = 0;
               i < psrc->char_length;
               i++, pfbl++, pfbls++) {
              if (pfbls->count_feedbacks > 0) {
                  pfbl->feedbacks = (IMFeedback*) malloc(sizeof(IMFeedback) * pfbls->count_feedbacks);
                  if (!pfbl->feedbacks) {
                     IMText_delete2(pdest);
                     return 0;
                  }
                  memcpy(pfbl->feedbacks, pfbls->feedbacks,
                        sizeof(IMFeedback) * pfbls->count_feedbacks);
                  pfbl->count_feedbacks = pfbls->count_feedbacks;
              }
           }
       }
    }

    if (psrc->count_annotations > 0) {
       IMAnnotation *pima, *pimas;
       IMAnnotationValue *pimavs;

       pima = (IMAnnotation*) malloc(sizeof(IMAnnotation)
                                  * psrc->count_annotations);
       if (!pima) {
           IMText_delete2(pdest);
           return 0;
       }
       memset(pima, 0, sizeof(IMAnnotation) * psrc->count_annotations);
       pdest->annotations = pima;
       pimas = psrc->annotations;
       for (i = 0;
            i < psrc->count_annotations;
            i++, pima++, pimas++) {
           IMAnnotationValue *pimav = (IMAnnotationValue*) malloc(sizeof(IMAnnotationValue)
                                                           * pimas->num_values);
           if (!pimav) {
              IMText_delete2(pdest);
              return 0;
           }
           memset(pimav, 0, sizeof(IMAnnotationValue) * pimas->num_values);
           *pima = *pimas;
           pima->values = pimav;
           pimavs = pimas->values;
           for (j = 0;
               j < pimas->num_values;
               j++, pimav++, pimavs++) {
              *pimav = *pimavs;
              pimav->value = malloc(pimav->len);
              if (!pimav->value) {
                  IMText_delete2(pdest);
                  return 0;
              }
              memcpy(pimav->value, pimavs->value, pimav->len);
           }
       }
    }

    return 1;
}
iml_desktop_t* new_user ( iml_if_t If,
const char *  user_name,
const char *  host_name,
const char *  display_id 
)

Definition at line 1691 of file SunIM.c.

{
    iml_desktop_t *p = (iml_desktop_t *) calloc(1, sizeof(iml_desktop_t));

    p->addListenerToDesktop = add_listener_to_desktop;
    p->lookupListenerFromDesktop = lookup_listener_from_desktop;
    p->deleteListenerFromDesktop = delete_listener_from_desktop;

    p->user_name = strdup(user_name);
    p->host_name = strdup(host_name);
    p->display_id = strdup(display_id);
    p->next = If->desktop_list;
    p->If = If;
    If->desktop_list = p;
    If->desktop_count++;
#ifdef DEBUG
    printf("LE %s: %s@%s is entered\n", If->if_name, user_name, host_name);
#endif
    return (iml_desktop_t *) p;
}

Definition at line 1059 of file SunIMSubr.c.

{
#ifdef sun
#elif   WIN32
    if ((memory_block_mutex = CreateMutex(NULL, FALSE, NULL)) == 0) {
        printf("WIN32 Thread: CreateMutex() ERROR\n");
        return;
    }
#else  /* Linux */
#endif
}