Back to index

im-sdk  12.3.91
Functions
i18nUtil.c File Reference
#include <X11/Xlib.h>
#include "X11R6IMProtoData.h"
#include "Xi18n.h"
#include "FrameMgr.h"

Go to the source code of this file.

Functions

Xi18nClient_Xi18nFindClient (Xi18n, CARD16)
int _Xi18nNeedSwap (Xi18n i18n_core, CARD16 connect_id)
Xi18nClient_Xi18nNewClient (Xi18n i18n_core)
void _Xi18nDeleteClient (Xi18n i18n_core, CARD16 connect_id)
void _Xi18nSendMessage (XIMS ims, CARD16 connect_id, CARD8 major_opcode, CARD8 minor_opcode, unsigned char *data, long length)
void _Xi18nSendTriggerKey (XIMS ims, CARD16 connect_id)
void _Xi18nSetEventMask (XIMS ims, CARD16 connect_id, CARD16 im_id, CARD16 ic_id, CARD32 forward_mask, CARD32 sync_mask)

Function Documentation

void _Xi18nDeleteClient ( Xi18n  i18n_core,
CARD16  connect_id 
)

Definition at line 83 of file i18nUtil.c.

{
    Xi18nClient *target = _Xi18nFindClient(i18n_core, connect_id);
    Xi18nClient *ccp, *ccp0;

    for (ccp = i18n_core->address.clients, ccp0 = NULL;
        ccp != NULL;
        ccp0 = ccp, ccp = ccp->next) {
       if (ccp == target) {
           if (ccp0 == NULL) {
              i18n_core->address.clients = ccp->next;
           } else {
              ccp0->next = ccp->next;
           }
           /* put it back to free list */
           target->next = i18n_core->address.free_clients;
           i18n_core->address.free_clients = target;
           return;
       }
    }
    return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Xi18nClient* _Xi18nFindClient ( Xi18n  i18n_core,
CARD16  connect_id 
)

Definition at line 70 of file i18nUtil.c.

{
    Xi18nClient *client = i18n_core->address.clients;

    while (client != NULL) {
       if (client->connect_id == connect_id)
         return client;
       client = client->next;
    }
    return NULL;
}

Here is the caller graph for this function:

int _Xi18nNeedSwap ( Xi18n  i18n_core,
CARD16  connect_id 
)

Definition at line 37 of file i18nUtil.c.

{
    CARD8 im_byteOrder = i18n_core->address.im_byteOrder;
    Xi18nClient *client = _Xi18nFindClient(i18n_core, connect_id);
    
    return (client->byte_order != im_byteOrder);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 46 of file i18nUtil.c.

{
    static CARD16 connect_id = 0;
    Xi18nClient *client;

    if (i18n_core->address.free_clients != NULL) {
       client = i18n_core->address.free_clients;
       i18n_core->address.free_clients = client->next;
    } else {
       client = (Xi18nClient *)malloc(sizeof(Xi18nClient));
    }
    memset(client, 0, sizeof(Xi18nClient));
    client->connect_id = ++connect_id;
    client->pending = (XIMPending *)NULL;
    client->sync = False;
    client->byte_order = '?';      /* initial value */
    memset(&client->pending, 0, sizeof(XIMPending *));
    client->next = i18n_core->address.clients;
    i18n_core->address.clients = client;

    return (Xi18nClient *)client;
}

Here is the caller graph for this function:

void _Xi18nSendMessage ( XIMS  ims,
CARD16  connect_id,
CARD8  major_opcode,
CARD8  minor_opcode,
unsigned char *  data,
long  length 
)

Definition at line 107 of file i18nUtil.c.

{
    Xi18n i18n_core = ims->protocol;
    FrameMgr fm;
    extern XimFrameRec packet_header_fr[];
    unsigned char *reply_hdr = NULL;
    int header_size;
    unsigned char *reply = NULL;
    unsigned char *replyp;
    int reply_length;
    long p_len = length/4;

    /* create FrameMgr */
    fm = FrameMgrInit(packet_header_fr, NULL,
                    _Xi18nNeedSwap(i18n_core, connect_id));

    header_size = FrameMgrGetTotalSize(fm);
    reply_hdr = (unsigned char *)malloc(header_size);
    if (!reply_hdr) {
       _Xi18nSendMessage(ims, connect_id, XIM_ERROR, 0, 0, 0);
       return;
    }
    FrameMgrSetBuffer(fm, reply_hdr);

    /* put data */
    FrameMgrPutToken(fm, major_opcode);
    FrameMgrPutToken(fm, minor_opcode);
    FrameMgrPutToken(fm, p_len);

    reply_length = header_size + length;
    reply = (unsigned char *)malloc(reply_length);
    replyp = reply;
    memmove(reply, reply_hdr, header_size);
    replyp += header_size;
    memmove(replyp, data, length);

    i18n_core->methods.send(ims, connect_id, reply, reply_length);

    XFree(reply_hdr);
    XFree(reply);
    /* free FrameMgr */
    FrameMgrFree(fm);

    return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void _Xi18nSendTriggerKey ( XIMS  ims,
CARD16  connect_id 
)

Definition at line 156 of file i18nUtil.c.

{
    Xi18n i18n_core = ims->protocol;
    FrameMgr fm;
    extern XimFrameRec register_triggerkeys_fr[];
    XIMTriggerKey *on_keys = i18n_core->address.on_keys.keylist;
    XIMTriggerKey *off_keys = i18n_core->address.off_keys.keylist;
    int on_key_num = i18n_core->address.on_keys.count_keys;
    int off_key_num = i18n_core->address.off_keys.count_keys;
    unsigned char *reply = NULL;
    register int i, total_size;
    CARD16 im_id;

    if (on_key_num == 0 && off_key_num == 0)
      return;

    /* create FrameMgr */
    fm = FrameMgrInit(register_triggerkeys_fr, NULL,
                    _Xi18nNeedSwap(i18n_core, connect_id));

    /* set iteration count for on-keys list */
    FrameMgrSetIterCount(fm, on_key_num);
    /* set iteration count for off-keys list */
    FrameMgrSetIterCount(fm, off_key_num);

    /* get total_size */
    total_size = FrameMgrGetTotalSize(fm);

    reply = (unsigned char *)malloc(total_size);
    if (!reply) {
       return;
    }
    memset(reply, 0, total_size);
    FrameMgrSetBuffer(fm, reply);

    /* Right now XIM_OPEN_REPLY hasn't been sent to this new client, so
       the input-method-id is still invalid, and should be set to zero...
       Reter to $(XC)/lib/X11/imDefLkup.c:_XimRegisterTriggerKeysCallback
     */
    im_id = 0;
    FrameMgrPutToken(fm, im_id); /* input-method-id */
    for (i = 0; i < on_key_num; i++) {
       FrameMgrPutToken(fm, on_keys[i].keysym);
       FrameMgrPutToken(fm, on_keys[i].modifier);
       FrameMgrPutToken(fm, on_keys[i].modifier_mask);
    }
    for (i = 0; i < off_key_num; i++) {
       FrameMgrPutToken(fm, off_keys[i].keysym);
       FrameMgrPutToken(fm, off_keys[i].modifier);
       FrameMgrPutToken(fm, off_keys[i].modifier_mask);
    }

    _Xi18nSendMessage(ims, connect_id, XIM_REGISTER_TRIGGERKEYS, 0,
                    reply, total_size);

    XFree(reply);
    /* free FrameMgr */
    FrameMgrFree(fm);

    return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void _Xi18nSetEventMask ( XIMS  ims,
CARD16  connect_id,
CARD16  im_id,
CARD16  ic_id,
CARD32  forward_mask,
CARD32  sync_mask 
)

Definition at line 219 of file i18nUtil.c.

{
    Xi18n i18n_core = ims->protocol;
    FrameMgr fm;
    extern XimFrameRec set_event_mask_fr[];
    unsigned char *reply = NULL;
    register int total_size;

    /* create FrameMgr */
    fm = FrameMgrInit(set_event_mask_fr, NULL,
                    _Xi18nNeedSwap(i18n_core, connect_id));

    total_size = FrameMgrGetTotalSize(fm);
    reply = (unsigned char *)malloc(total_size);
    if (!reply) {
       return;
    }
    memset(reply, 0, total_size);
    FrameMgrSetBuffer(fm, reply);

    FrameMgrPutToken(fm, im_id);   /* input-method-id */
    FrameMgrPutToken(fm, ic_id);   /* input-context-id */
    FrameMgrPutToken(fm, forward_mask);
    FrameMgrPutToken(fm, sync_mask);

    _Xi18nSendMessage(ims, connect_id,
                    XIM_SET_EVENT_MASK, 0, reply, total_size);

    XFree(reply);
    /* free FrameMgr */
    FrameMgrFree(fm);

    return;
}

Here is the call graph for this function:

Here is the caller graph for this function: