Esempio n. 1
0
static int xi18n_syncXlib (XIMS ims, XPointer xp)
{
    IMProtocol *call_data = (IMProtocol *)xp;
    Xi18n i18n_core = ims->protocol;
    IMSyncXlibStruct *sync_xlib;

    extern XimFrameRec sync_fr[];
    FrameMgr fm;
    CARD16 connect_id = call_data->any.connect_id;
    int total_size;
    unsigned char *reply;

    sync_xlib = (IMSyncXlibStruct *) &call_data->sync_xlib;
    fm = FrameMgrInit (sync_fr, NULL,
                       _Xi18nNeedSwap (i18n_core, connect_id));
    total_size = FrameMgrGetTotalSize(fm);
    reply = (unsigned char *) malloc (total_size);
    if (!reply) {
        _Xi18nSendMessage (ims, connect_id, XIM_ERROR, 0, 0, 0);
        return False;
    }
    memset (reply, 0, total_size);
    FrameMgrSetBuffer (fm, reply);

    /* input input-method ID */
    FrameMgrPutToken (fm, connect_id);
    /* input input-context ID */
    FrameMgrPutToken (fm, sync_xlib->icid);
    _Xi18nSendMessage (ims, connect_id, XIM_SYNC, 0, reply, total_size);
    
    FrameMgrFree (fm);
    XFree(reply);
    return True;
}
Esempio n. 2
0
static void GetCardAttribute (char *rec, XICAttribute *list, int need_swap)
{
    FrameMgr fm;
    unsigned char *recp = (unsigned char *) rec;

    GetAttrHeader (recp, list, need_swap);
    recp += sizeof (CARD16)*2;

    if (list->value_length == sizeof (CARD8))
    {
        memmove (recp, list->value, list->value_length);
    }
    else if (list->value_length == sizeof (CARD16))
    {
        INT16 *value = (INT16 *) list->value;
        extern XimFrameRec short_fr[];

        fm = FrameMgrInit (short_fr, (char *) recp, need_swap);
        /* put data */
        FrameMgrPutToken (fm, *value);
        FrameMgrFree (fm);
    }
    else if (list->value_length == sizeof (CARD32))
    {
        INT32 *value = (INT32 *) list->value;
        extern XimFrameRec long_fr[];

        fm = FrameMgrInit (long_fr, (char *) recp, need_swap);
        /* put data */
        FrameMgrPutToken (fm, *value);
        FrameMgrFree (fm);
    }
    /*endif*/
}
Esempio n. 3
0
/* get IC values */
static void GetAttrHeader (unsigned char *rec,
                           XICAttribute *list,
                           int need_swap)
{
    FrameMgr fm;
    extern XimFrameRec attr_head_fr[];

    fm = FrameMgrInit (attr_head_fr, (char *) rec, need_swap);
    /* put data */
    FrameMgrPutToken (fm, list->attribute_id);
    FrameMgrPutToken (fm, list->value_length);
    FrameMgrFree (fm);
}
Esempio n. 4
0
void _Xi18nSendMessage(XIMS ims,
                       CARD16 connect_id,
                       CARD8 major_opcode,
                       CARD8 minor_opcode,
                       unsigned char *data,
                       long length)
{
    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;

    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 == NULL) {
        _Xi18nSendMessage(ims, connect_id, XIM_ERROR, 0, 0, 0);
        return;
    }
    /*endif*/
    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;
    memcpy(reply, reply_hdr, header_size);
    replyp += header_size;
    memcpy(replyp, data, length);

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

    XFree(reply);
    XFree(reply_hdr);
    FrameMgrFree(fm);
}
Esempio n. 5
0
static void GetPointAttribute (char *rec, XICAttribute *list, int need_swap)
{
    FrameMgr fm;
    extern XimFrameRec xpoint_fr[];
    XPoint *rect = (XPoint *) list->value;
    unsigned char *recp = (unsigned char *) rec;

    GetAttrHeader (recp, list, need_swap);
    recp += sizeof(CARD16)*2;

    fm = FrameMgrInit (xpoint_fr, (char *) recp, need_swap);
    /* put data */
    FrameMgrPutToken (fm, rect->x);
    FrameMgrPutToken (fm, rect->y);
    FrameMgrFree (fm);
}
Esempio n. 6
0
static void GetFontAttribute(char *rec, XICAttribute *list, int need_swap)
{
    FrameMgr fm;
    extern XimFrameRec fontset_fr[];
    char *base_name = (char *) list->value;
    unsigned char *recp = (unsigned char *) rec;

    GetAttrHeader (recp, list, need_swap);
    recp += sizeof (CARD16)*2;

    fm = FrameMgrInit (fontset_fr, (char *)recp, need_swap);
    /* put data */
    FrameMgrSetSize (fm, list->value_length);
    FrameMgrPutToken (fm, list->value_length);
    FrameMgrPutToken (fm, base_name);
    FrameMgrFree (fm);
}
Esempio n. 7
0
void _Xi18nSetEventMask(XIMS ims,
                        CARD16 connect_id,
                        CARD16 im_id,
                        CARD16 ic_id,
                        CARD32 forward_mask,
                        CARD32 sync_mask)
{
    Xi18n i18n_core = ims->protocol;
    FrameMgr fm;
    extern XimFrameRec set_event_mask_fr[];
    unsigned char *reply = NULL;
    register int total_size;

    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;
    /*endif*/
    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);

    FrameMgrFree(fm);
    XFree(reply);
}
Esempio n. 8
0
/* called from GetICValueMessageProc */
void _Xi18nGetIC (XIMS ims, IMProtocol *call_data, unsigned char *p)
{
    Xi18n i18n_core = ims->protocol;
    FrameMgr fm;
    FmStatus status;
    extern XimFrameRec get_ic_values_fr[];
    extern XimFrameRec get_ic_values_reply_fr[];
    CARD16 byte_length;
    register int total_size;
    unsigned char *reply = NULL;
    XICAttribute *preedit_ret = NULL;
    XICAttribute *status_ret = NULL;
    register int i;
    register int number;
    int iter_count;
    CARD16 *attrID_list;
    XICAttribute pre_attr[IC_SIZE];
    XICAttribute sts_attr[IC_SIZE];
    XICAttribute ic_attr[IC_SIZE];
    CARD16 pre_count = 0;
    CARD16 sts_count = 0;
    CARD16 ic_count = 0;
    IMChangeICStruct *getic = (IMChangeICStruct *) &call_data->changeic;
    CARD16 connect_id = call_data->any.connect_id;
    CARD16 input_method_ID;

    memset (pre_attr, 0, sizeof (XICAttribute)*IC_SIZE);
    memset (sts_attr, 0, sizeof (XICAttribute)*IC_SIZE);
    memset (ic_attr, 0, sizeof (XICAttribute)*IC_SIZE);

    fm = FrameMgrInit (get_ic_values_fr,
                       (char *) p,
                       _Xi18nNeedSwap (i18n_core, connect_id));

    /* get data */
    FrameMgrGetToken (fm, input_method_ID);
    FrameMgrGetToken (fm, getic->icid);
    FrameMgrGetToken (fm, byte_length);

    attrID_list = (CARD16 *) malloc (sizeof (CARD16)*IC_SIZE);  /* bogus */
    memset (attrID_list, 0, sizeof (CARD16)*IC_SIZE);

    number = 0;
    while (FrameMgrIsIterLoopEnd (fm, &status) == False)
        FrameMgrGetToken (fm, attrID_list[number++]);
    /*endwhile*/
    FrameMgrFree (fm);

    i = 0;
    while (i < number)
    {
        int read_number;
        
        if (IsNestedList (i18n_core, attrID_list[i]))
        {
            if (attrID_list[i] == i18n_core->address.preeditAttr_id)
            {
                read_number = GetICValue (i18n_core,
                                          &pre_attr[pre_count],
                                          &attrID_list[i],
                                          number);
                i += read_number + 1;
                pre_count += read_number;
            }
            else if (attrID_list[i] == i18n_core->address.statusAttr_id)
            {
                read_number = GetICValue (i18n_core,
                                          &sts_attr[sts_count],
                                          &attrID_list[i],
                                          number);
                i += read_number + 1;
                sts_count += read_number;
            }
            else
            {
                /* another nested list.. possible? */
            }
            /*endif*/
        }
        else
        {
            read_number = GetICValue (i18n_core,
                                      &ic_attr[ic_count],
                                      &attrID_list[i],
                                      number);
            i += read_number;
            ic_count += read_number;
        }
        /*endif*/
    }
    /*endwhile*/
    getic->preedit_attr_num = pre_count;
    getic->status_attr_num = sts_count;
    getic->ic_attr_num = ic_count;
    getic->preedit_attr = pre_attr;
    getic->status_attr = sts_attr;
    getic->ic_attr = ic_attr;
    if (i18n_core->address.improto)
    {
        if (!(i18n_core->address.improto (ims, call_data)))
            return;
        /*endif*/
	if (_Xi18nNeedSwap (i18n_core, connect_id))
	  SwapAttributes(getic->ic_attr, getic->ic_attr_num);
    }
    /*endif*/
    iter_count = getic->ic_attr_num;

    preedit_ret = CreateNestedList (i18n_core->address.preeditAttr_id,
                                    getic->preedit_attr,
                                    getic->preedit_attr_num,
                                    _Xi18nNeedSwap (i18n_core, connect_id));
    if (preedit_ret)
        iter_count++;
    /*endif*/
    status_ret = CreateNestedList (i18n_core->address.statusAttr_id,
                                   getic->status_attr,
                                   getic->status_attr_num,
                                   _Xi18nNeedSwap (i18n_core, connect_id));
    if (status_ret)
        iter_count++;
    /*endif*/

    fm = FrameMgrInit (get_ic_values_reply_fr,
                       NULL,
                       _Xi18nNeedSwap (i18n_core, connect_id));

    /* set iteration count for list of ic_attribute */
    FrameMgrSetIterCount (fm, iter_count);

    /* set length of BARRAY item in xicattribute_fr */
    for (i = 0;  i < (int) getic->ic_attr_num;  i++)
        FrameMgrSetSize (fm, ic_attr[i].value_length);
    /*endfor*/
    
    if (preedit_ret)
        FrameMgrSetSize (fm, preedit_ret->value_length);
    /*endif*/
    if (status_ret)
        FrameMgrSetSize (fm, status_ret->value_length);
    /*endif*/
    total_size = FrameMgrGetTotalSize (fm);
    reply = (unsigned char *) malloc (total_size);
    if (reply == NULL)
    {
        _Xi18nSendMessage (ims, connect_id, XIM_ERROR, 0, 0, 0);
        return;
    }
    /*endif*/
    memset (reply, 0, total_size);
    FrameMgrSetBuffer (fm, reply);

    FrameMgrPutToken (fm, input_method_ID);
    FrameMgrPutToken (fm, getic->icid);

    for (i = 0;  i < (int) getic->ic_attr_num;  i++)
    {
        FrameMgrPutToken (fm, ic_attr[i].attribute_id);
        FrameMgrPutToken (fm, ic_attr[i].value_length);
        FrameMgrPutToken (fm, ic_attr[i].value);
    }
    /*endfor*/
    if (preedit_ret)
    {
        FrameMgrPutToken (fm, preedit_ret->attribute_id);
        FrameMgrPutToken (fm, preedit_ret->value_length);
        FrameMgrPutToken (fm, preedit_ret->value);
    }
    /*endif*/
    if (status_ret)
    {
        FrameMgrPutToken (fm, status_ret->attribute_id);
        FrameMgrPutToken (fm, status_ret->value_length);
        FrameMgrPutToken (fm, status_ret->value);
    }
    /*endif*/
    _Xi18nSendMessage (ims,
                       connect_id,
                       XIM_GET_IC_VALUES_REPLY,
                       0,
                       reply,
                       total_size);
    XFree (reply);
    XFree (attrID_list);

    for (i = 0;  i < (int) getic->ic_attr_num;  i++)
    {
	if (getic->ic_attr[i].name)
	    XFree (getic->ic_attr[i].name);
	/*endif*/
        if (getic->ic_attr[i].value)
            XFree (getic->ic_attr[i].value);
        /*endif*/
    }
    /*endfor*/
    for (i = 0;  i < (int) getic->preedit_attr_num;  i++)
    {
	if (getic->preedit_attr[i].name)
	    XFree (getic->preedit_attr[i].name);
	/*endif*/
	if (getic->preedit_attr[i].value)
	    XFree (getic->preedit_attr[i].value);
	/*endif*/
    }
    /*endfor*/
    for (i = 0;  i < (int) getic->status_attr_num;  i++)
    {
	if (getic->status_attr[i].name)
	    XFree (getic->status_attr[i].name);
	/*endif*/
	if (getic->status_attr[i].value)
	    XFree (getic->status_attr[i].value);
	/*endif*/
    }
    /*endfor*/
    
    if (preedit_ret)
    {
        XFree (preedit_ret->value);
        XFree (preedit_ret);
    }
    /*endif*/
    if (status_ret)
    {
        XFree (status_ret->value);
        XFree (status_ret);
    }
    /*endif*/
    FrameMgrFree (fm);
}
Esempio n. 9
0
/* called from CreateICMessageProc and SetICValueMessageProc */
void _Xi18nChangeIC (XIMS ims,
                     IMProtocol *call_data,
                     unsigned char *p,
                     int create_flag)
{
    Xi18n i18n_core = ims->protocol;
    FrameMgr fm;
    FmStatus status;
    CARD16 byte_length;
    register int total_size;
    unsigned char *reply = NULL;
    register int i;
    register int attrib_num;
    XICAttribute *attrib_list;
    XICAttribute pre_attr[IC_SIZE];
    XICAttribute sts_attr[IC_SIZE];
    XICAttribute ic_attr[IC_SIZE];
    CARD16 preedit_ic_num = 0;
    CARD16 status_ic_num = 0;
    CARD16 ic_num = 0;
    CARD16 connect_id = call_data->any.connect_id;
    IMChangeICStruct *changeic = (IMChangeICStruct *) &call_data->changeic;
    extern XimFrameRec create_ic_fr[];
    extern XimFrameRec create_ic_reply_fr[];
    extern XimFrameRec set_ic_values_fr[];
    extern XimFrameRec set_ic_values_reply_fr[];
    CARD16 input_method_ID;
 
    void *value_buf = NULL;
    void *value_buf_ptr;

    register int total_value_length = 0;

    memset (pre_attr, 0, sizeof (XICAttribute)*IC_SIZE);
    memset (sts_attr, 0, sizeof (XICAttribute)*IC_SIZE);
    memset (ic_attr, 0, sizeof (XICAttribute)*IC_SIZE);

    if (create_flag == True)
    {
        fm = FrameMgrInit (create_ic_fr,
                           (char *) p,
                           _Xi18nNeedSwap (i18n_core, connect_id));
        /* get data */
        FrameMgrGetToken (fm, input_method_ID);
        FrameMgrGetToken (fm, byte_length);
    }
    else
    {
        fm = FrameMgrInit (set_ic_values_fr,
                           (char *) p,
                           _Xi18nNeedSwap (i18n_core, connect_id));
        /* get data */
        FrameMgrGetToken (fm, input_method_ID);
        FrameMgrGetToken (fm, changeic->icid);
        FrameMgrGetToken (fm, byte_length);
    }
    /*endif*/
    attrib_list = (XICAttribute *) malloc (sizeof (XICAttribute)*IC_SIZE);
    if (!attrib_list)
    {
        _Xi18nSendMessage (ims, connect_id, XIM_ERROR, 0, 0, 0);
        return;
    }
    /*endif*/
    memset (attrib_list, 0, sizeof(XICAttribute)*IC_SIZE);

    attrib_num = 0;
    while (FrameMgrIsIterLoopEnd (fm, &status) == False)
    {
        void *value;
        int value_length;
        
        FrameMgrGetToken (fm, attrib_list[attrib_num].attribute_id);
        FrameMgrGetToken (fm, value_length);
        FrameMgrSetSize (fm, value_length);
        attrib_list[attrib_num].value_length = value_length;
        FrameMgrGetToken (fm, value);
        attrib_list[attrib_num].value = (void *) malloc (value_length + 1);
        memmove (attrib_list[attrib_num].value, value, value_length);
	((char *)attrib_list[attrib_num].value)[value_length] = '\0';
        attrib_num++;
        total_value_length += (value_length + 1);
    }
    /*endwhile*/

    value_buf = (void *) malloc (total_value_length);
    value_buf_ptr = value_buf;

    if (!value_buf)
    {
        _Xi18nSendMessage (ims, connect_id, XIM_ERROR, 0, 0, 0);
        for (i = 0;  i < attrib_num;  i++)
            XFree (attrib_list[i].value);
        /*endfor*/
        XFree (attrib_list);
        return;
    }
    /*endif*/

    for (i = 0;  i < attrib_num;  i++)
    {
        CARD16 number;
        
        if (IsNestedList (i18n_core, attrib_list[i].attribute_id))
        {
            if (attrib_list[i].attribute_id
                == i18n_core->address.preeditAttr_id)
            {
                ReadICValue (i18n_core,
                             attrib_list[i].attribute_id,
                             attrib_list[i].value_length,
                             attrib_list[i].value,
                             &pre_attr[preedit_ic_num],
                             &number,
                             _Xi18nNeedSwap(i18n_core, connect_id),
                             &value_buf_ptr);
                preedit_ic_num += number;
            }
            else if (attrib_list[i].attribute_id == i18n_core->address.statusAttr_id)
            {
                ReadICValue (i18n_core,
                             attrib_list[i].attribute_id,
                             attrib_list[i].value_length,
                             attrib_list[i].value,
                             &sts_attr[status_ic_num],
                             &number,
                             _Xi18nNeedSwap (i18n_core, connect_id),
                             &value_buf_ptr);
                status_ic_num += number;
            }
            else
            {
                /* another nested list.. possible? */
            }
            /*endif*/
        }
        else
        {
            ReadICValue (i18n_core,
                         attrib_list[i].attribute_id,
                         attrib_list[i].value_length,
                         attrib_list[i].value,
                         &ic_attr[ic_num],
                         &number,
                         _Xi18nNeedSwap (i18n_core, connect_id),
                         &value_buf_ptr);
            ic_num += number;
        }
        /*endif*/
    }
    /*endfor*/
    for (i = 0;  i < attrib_num;  i++)
        XFree (attrib_list[i].value);
    /*endfor*/
    XFree (attrib_list);

    FrameMgrFree (fm);

    changeic->preedit_attr_num = preedit_ic_num;
    changeic->status_attr_num = status_ic_num;
    changeic->ic_attr_num = ic_num;
    changeic->preedit_attr = pre_attr;
    changeic->status_attr = sts_attr;
    changeic->ic_attr = ic_attr;

    if (i18n_core->address.improto)
    {
        if (!(i18n_core->address.improto(ims, call_data))) {
            XFree (value_buf);
            return;
        }
        /*endif*/
    }

    XFree (value_buf);

    /*endif*/
    if (create_flag == True)
    {
        fm = FrameMgrInit (create_ic_reply_fr,
                           NULL,
                           _Xi18nNeedSwap (i18n_core, connect_id));
    }
    else
    {
        fm = FrameMgrInit (set_ic_values_reply_fr,
                           NULL,
                           _Xi18nNeedSwap (i18n_core, connect_id));
    }
    /*endif*/
    total_size = FrameMgrGetTotalSize (fm);
    reply = (unsigned char *) malloc (total_size);
    
    if (!reply)
    {
        _Xi18nSendMessage (ims, connect_id, XIM_ERROR, 0, 0, 0);
        return;
    }
    /*endif*/
    memset (reply, 0, total_size);
    FrameMgrSetBuffer (fm, reply);

    FrameMgrPutToken (fm, input_method_ID);
    FrameMgrPutToken (fm, changeic->icid);

    if (create_flag == True)
    {
        _Xi18nSendMessage (ims,
                           connect_id,
                           XIM_CREATE_IC_REPLY,
                           0,
                           reply,
                           total_size);
    }
    else
    {
        _Xi18nSendMessage (ims,
                           connect_id,
                           XIM_SET_IC_VALUES_REPLY,
                           0,
                           reply,
                           total_size);
    }
    /*endif*/
    if (create_flag == True)
    {
        int on_key_num = i18n_core->address.on_keys.count_keys;
        int off_key_num = i18n_core->address.off_keys.count_keys;

        if (on_key_num == 0  &&  off_key_num == 0)
        {
            long mask;

            if (i18n_core->address.imvalue_mask & I18N_FILTERMASK)
                mask = i18n_core->address.filterevent_mask;
            else
                mask = DEFAULT_FILTER_MASK;
            /*endif*/
            /* static event flow is default */
            _Xi18nSetEventMask (ims,
                                connect_id,
                                input_method_ID,
                                changeic->icid,
                                mask,
                                ~mask);
        }
        /*endif*/
    }
    /*endif*/
    FrameMgrFree (fm);
    XFree(reply);
}
Esempio n. 10
0
void _Xi18nSendTriggerKey(XIMS ims, CARD16 connect_id)
{
    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;
    /*endif*/

    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;
    /*endif*/
    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);
    }
    /*endfor*/
    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);
    }
    /*endfor*/
    _Xi18nSendMessage(ims,
                      connect_id,
                      XIM_REGISTER_TRIGGERKEYS,
                      0,
                      reply,
                      total_size);
    FrameMgrFree(fm);
    XFree(reply);
}
Esempio n. 11
0
static Status xi18n_commit (XIMS ims, XPointer xp)
{
    Xi18n i18n_core = ims->protocol;
    IMCommitStruct *call_data = (IMCommitStruct *)xp;
    FrameMgr fm;
    extern XimFrameRec commit_chars_fr[];
    extern XimFrameRec commit_both_fr[];
    register int total_size;
    unsigned char *reply = NULL;
    CARD16 str_length;

    call_data->flag |= XimSYNCHRONUS;  /* always sync */

    if (!(call_data->flag & XimLookupKeySym)
        &&
        (call_data->flag & XimLookupChars))
    {
        fm = FrameMgrInit (commit_chars_fr,
                           NULL,
                           _Xi18nNeedSwap (i18n_core, call_data->connect_id));

        /* set length of STRING8 */
        str_length = strlen (call_data->commit_string);
        FrameMgrSetSize (fm, str_length);
        total_size = FrameMgrGetTotalSize (fm);
        reply = (unsigned char *) malloc (total_size);
        if (!reply)
        {
            _Xi18nSendMessage (ims,
                               call_data->connect_id,
                               XIM_ERROR,
                               0,
                               0,
                               0);
            return False;
        }
        /*endif*/
        memset (reply, 0, total_size);
        FrameMgrSetBuffer (fm, reply);

        str_length = FrameMgrGetSize (fm);
        FrameMgrPutToken (fm, call_data->connect_id);
        FrameMgrPutToken (fm, call_data->icid);
        FrameMgrPutToken (fm, call_data->flag);
        FrameMgrPutToken (fm, str_length);
        FrameMgrPutToken (fm, call_data->commit_string);
    }
    else
    {
        fm = FrameMgrInit (commit_both_fr,
                           NULL,
                           _Xi18nNeedSwap (i18n_core, call_data->connect_id));
        /* set length of STRING8 */
        str_length = strlen (call_data->commit_string);
        if (str_length > 0)
            FrameMgrSetSize (fm, str_length);
        /*endif*/
        total_size = FrameMgrGetTotalSize (fm);
        reply = (unsigned char *) malloc (total_size);
        if (!reply)
        {
            _Xi18nSendMessage (ims,
                               call_data->connect_id,
                               XIM_ERROR,
                               0,
                               0,
                               0);
            return False;
        }
        /*endif*/
        FrameMgrSetBuffer (fm, reply);
        FrameMgrPutToken (fm, call_data->connect_id);
        FrameMgrPutToken (fm, call_data->icid);
        FrameMgrPutToken (fm, call_data->flag);
        FrameMgrPutToken (fm, call_data->keysym);
        if (str_length > 0)
        {
            str_length = FrameMgrGetSize (fm);
            FrameMgrPutToken (fm, str_length);
            FrameMgrPutToken (fm, call_data->commit_string);
        }
        /*endif*/
    }
    /*endif*/
    _Xi18nSendMessage (ims,
                       call_data->connect_id,
                       XIM_COMMIT,
                       0,
                       reply,
                       total_size);
    FrameMgrFree (fm);
    XFree (reply);
    
    return True;
}
Esempio n. 12
0
static Status xi18n_forwardEvent (XIMS ims, XPointer xp)
{
    Xi18n i18n_core = ims->protocol;
    IMForwardEventStruct *call_data = (IMForwardEventStruct *)xp;
    FrameMgr fm;
    extern XimFrameRec forward_event_fr[];
    register int total_size;
    unsigned char *reply = NULL;
    unsigned char *replyp;
    CARD16 serial;
    int event_size;
    Xi18nClient *client;

    client = (Xi18nClient *) _Xi18nFindClient (i18n_core, call_data->connect_id);

    /* create FrameMgr */
    fm = FrameMgrInit (forward_event_fr,
                       NULL,
                       _Xi18nNeedSwap (i18n_core, call_data->connect_id));

    total_size = FrameMgrGetTotalSize (fm);
    event_size = sizeof (xEvent);
    reply = (unsigned char *) malloc (total_size + event_size);
    if (!reply)
    {
        _Xi18nSendMessage (ims,
                           call_data->connect_id,
                           XIM_ERROR,
                           0,
                           0,
                           0);
        return False;
    }
    /*endif*/
    memset (reply, 0, total_size + event_size);
    FrameMgrSetBuffer (fm, reply);
    replyp = reply;

    call_data->sync_bit = 1; 	/* always sync */
    client->sync = True;

    FrameMgrPutToken (fm, call_data->connect_id);
    FrameMgrPutToken (fm, call_data->icid);
    FrameMgrPutToken (fm, call_data->sync_bit);

    replyp += total_size;
    EventToWireEvent (&(call_data->event),
                      (xEvent *) replyp,
                      &serial,
                      _Xi18nNeedSwap (i18n_core, call_data->connect_id));

    FrameMgrPutToken (fm, serial);

    _Xi18nSendMessage (ims,
                       call_data->connect_id,
                       XIM_FORWARD_EVENT,
                       0,
                       reply,
                       total_size + event_size);

    XFree (reply);
    FrameMgrFree (fm);

    return True;
}
Esempio n. 13
0
static void EventToWireEvent (XEvent *ev, xEvent *event,
			      CARD16 *serial, Bool byte_swap)
{
    FrameMgr fm;
    extern XimFrameRec wire_keyevent_fr[];
    extern XimFrameRec short_fr[];
    BYTE b;
    CARD16 c16;
    CARD32 c32;

    *serial = (CARD16)(ev->xany.serial >> 16);
    switch (ev->type) {
      case KeyPress:
      case KeyRelease:
	{
	    XKeyEvent *kev = (XKeyEvent*)ev;
	    /* create FrameMgr */
	    fm = FrameMgrInit(wire_keyevent_fr, (char *)(&(event->u)), byte_swap);

	    /* set values */
	    b = (BYTE)kev->type;          FrameMgrPutToken(fm, b);
	    b = (BYTE)kev->keycode;       FrameMgrPutToken(fm, b);
	    c16 = (CARD16)(kev->serial & (unsigned long)0xffff);
					  FrameMgrPutToken(fm, c16);
	    c32 = (CARD32)kev->time;      FrameMgrPutToken(fm, c32);
	    c32 = (CARD32)kev->root;      FrameMgrPutToken(fm, c32);
	    c32 = (CARD32)kev->window;    FrameMgrPutToken(fm, c32);
	    c32 = (CARD32)kev->subwindow; FrameMgrPutToken(fm, c32);
	    c16 = (CARD16)kev->x_root;    FrameMgrPutToken(fm, c16);
	    c16 = (CARD16)kev->y_root;    FrameMgrPutToken(fm, c16);
	    c16 = (CARD16)kev->x;         FrameMgrPutToken(fm, c16);
	    c16 = (CARD16)kev->y;         FrameMgrPutToken(fm, c16);
	    c16 = (CARD16)kev->state;     FrameMgrPutToken(fm, c16);
	    b = (BYTE)kev->same_screen;   FrameMgrPutToken(fm, b);
	}
	break;
      default:
	  /* create FrameMgr */
	  fm = FrameMgrInit(short_fr, (char *)(&(event->u.u.sequenceNumber)),
			    byte_swap);
	  c16 = (CARD16)(ev->xany.serial & (unsigned long)0xffff);
	  FrameMgrPutToken(fm, c16);
	  break;
    }
    /* free FrameMgr */
    FrameMgrFree(fm);
}