i18npthdr.c
来自「linux 下的 oxim 输入法,简单易用.」· C语言 代码 · 共 1,849 行 · 第 1/4 页
C
1,849 行
#endif}static void EncodingNegotiatonMessageProc (XIMS ims, IMProtocol *call_data, unsigned char *p){ Xi18n i18n_core = ims->protocol; FrameMgr fm; FmStatus status; CARD16 byte_length; extern XimFrameRec encoding_negotiation_fr[]; extern XimFrameRec encoding_negotiation_reply_fr[]; register int i, total_size; unsigned char *reply = NULL; IMEncodingNegotiationStruct *enc_nego = (IMEncodingNegotiationStruct *) &call_data->encodingnego; CARD16 connect_id = call_data->any.connect_id; CARD16 input_method_ID; fm = FrameMgrInit (encoding_negotiation_fr, (char *) p, _Xi18nNeedSwap (i18n_core, connect_id)); FrameMgrGetToken (fm, input_method_ID); /* get ENCODING STR field */ FrameMgrGetToken (fm, byte_length); if (byte_length > 0) { enc_nego->encoding = (XIMStr *) malloc (sizeof (XIMStr)*10); memset (enc_nego->encoding, 0, sizeof (XIMStr)*10); i = 0; while (FrameMgrIsIterLoopEnd (fm, &status) == False) { char *name; int str_length; FrameMgrGetToken (fm, str_length); FrameMgrSetSize (fm, str_length); enc_nego->encoding[i].length = str_length; FrameMgrGetToken (fm, name); enc_nego->encoding[i].name = malloc (str_length + 1); strncpy (enc_nego->encoding[i].name, name, str_length); enc_nego->encoding[i].name[str_length] = '\0'; i++; } /*endwhile*/ enc_nego->encoding_number = i; } /*endif*/ /* get ENCODING INFO field */ FrameMgrGetToken (fm, byte_length); if (byte_length > 0) { enc_nego->encodinginfo = (XIMStr *) malloc (sizeof (XIMStr)*10); memset (enc_nego->encoding, 0, sizeof (XIMStr)*10); i = 0; while (FrameMgrIsIterLoopEnd (fm, &status) == False) { char *name; int str_length; FrameMgrGetToken (fm, str_length); FrameMgrSetSize (fm, str_length); enc_nego->encodinginfo[i].length = str_length; FrameMgrGetToken (fm, name); enc_nego->encodinginfo[i].name = malloc (str_length + 1); strncpy (enc_nego->encodinginfo[i].name, name, str_length); enc_nego->encodinginfo[i].name[str_length] = '\0'; i++; } /*endwhile*/ enc_nego->encoding_info_number = i; } /*endif*/ enc_nego->enc_index = ChooseEncoding (i18n_core, enc_nego); enc_nego->category = 0;#ifdef PROTOCOL_RICH if (i18n_core->address.improto) { if (!(i18n_core->address.improto(ims, call_data))) return; /*endif*/ } /*endif*/#endif /* PROTOCOL_RICH */ FrameMgrFree (fm); fm = FrameMgrInit (encoding_negotiation_reply_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; } /*endif*/ memset (reply, 0, total_size); FrameMgrSetBuffer (fm, reply); FrameMgrPutToken (fm, input_method_ID); FrameMgrPutToken (fm, enc_nego->category); FrameMgrPutToken (fm, enc_nego->enc_index); _Xi18nSendMessage (ims, connect_id, XIM_ENCODING_NEGOTIATION_REPLY, 0, reply, total_size); XFree (reply); /* free data for encoding list */ if (enc_nego->encoding) { for (i = 0; i < (int) enc_nego->encoding_number; i++) XFree (enc_nego->encoding[i].name); /*endfor*/ XFree (enc_nego->encoding); } /*endif*/ if (enc_nego->encodinginfo) { for (i = 0; i < (int) enc_nego->encoding_info_number; i++) XFree (enc_nego->encodinginfo[i].name); /*endfor*/ XFree (enc_nego->encodinginfo); } /*endif*/ FrameMgrFree (fm);}void PreeditStartReplyMessageProc (XIMS ims, IMProtocol *call_data, unsigned char *p){ Xi18n i18n_core = ims->protocol; FrameMgr fm; extern XimFrameRec preedit_start_reply_fr[]; IMPreeditCBStruct *preedit_CB = (IMPreeditCBStruct *) &call_data->preedit_callback; CARD16 connect_id = call_data->any.connect_id; CARD16 input_method_ID; fm = FrameMgrInit (preedit_start_reply_fr, (char *) p, _Xi18nNeedSwap (i18n_core, connect_id)); /* get data */ FrameMgrGetToken (fm, input_method_ID); FrameMgrGetToken (fm, preedit_CB->icid); FrameMgrGetToken (fm, preedit_CB->todo.return_value); FrameMgrFree (fm); if (i18n_core->address.improto) { if (!(i18n_core->address.improto (ims, call_data))) return; /*endif*/ } /*endif*/}void PreeditCaretReplyMessageProc (XIMS ims, IMProtocol *call_data, unsigned char *p){ Xi18n i18n_core = ims->protocol; FrameMgr fm; extern XimFrameRec preedit_caret_reply_fr[]; IMPreeditCBStruct *preedit_CB = (IMPreeditCBStruct *) &call_data->preedit_callback; XIMPreeditCaretCallbackStruct *caret = (XIMPreeditCaretCallbackStruct *) & preedit_CB->todo.caret; CARD16 connect_id = call_data->any.connect_id; CARD16 input_method_ID; fm = FrameMgrInit (preedit_caret_reply_fr, (char *) p, _Xi18nNeedSwap (i18n_core, connect_id)); /* get data */ FrameMgrGetToken (fm, input_method_ID); FrameMgrGetToken (fm, preedit_CB->icid); FrameMgrGetToken (fm, caret->position); FrameMgrFree (fm); if (i18n_core->address.improto) { if (!(i18n_core->address.improto(ims, call_data))) return; /*endif*/ } /*endif*/}void StrConvReplyMessageProc (XIMS ims, IMProtocol *call_data, unsigned char *p){ return;}static void AddQueue (Xi18nClient *client, unsigned char *p){ XIMPending *new; XIMPending *last; if ((new = (XIMPending *) malloc (sizeof (XIMPending))) == NULL) return; /*endif*/ new->p = p; new->next = (XIMPending *) NULL; if (!client->pending) { client->pending = new; } else { for (last = client->pending; last->next; last = last->next) ; /*endfor*/ last->next = new; } /*endif*/ return;}static void ProcessQueue (XIMS ims, CARD16 connect_id){ Xi18n i18n_core = ims->protocol; Xi18nClient *client = (Xi18nClient *) _Xi18nFindClient (i18n_core, connect_id); while (client->sync == False && client->pending) { XimProtoHdr *hdr = (XimProtoHdr *) client->pending->p; unsigned char *p1 = (unsigned char *) (hdr + 1); IMProtocol call_data; call_data.major_code = hdr->major_opcode; call_data.any.minor_code = hdr->minor_opcode; call_data.any.connect_id = connect_id; switch (hdr->major_opcode) { case XIM_FORWARD_EVENT: ForwardEventMessageProc(ims, &call_data, p1); break; } /*endswitch*/ XFree (hdr); { XIMPending *old = client->pending; client->pending = old->next; XFree (old); } } /*endwhile*/ return;}void _Xi18nMessageHandler (XIMS ims, CARD16 connect_id, unsigned char *p, Bool *delete){ XimProtoHdr *hdr = (XimProtoHdr *)p; unsigned char *p1 = (unsigned char *)(hdr + 1); IMProtocol call_data; Xi18n i18n_core = ims->protocol; Xi18nClient *client; client = (Xi18nClient *) _Xi18nFindClient (i18n_core, connect_id); if (hdr == (XimProtoHdr *) NULL) return; /*endif*/ memset (&call_data, 0, sizeof(IMProtocol)); call_data.major_code = hdr->major_opcode; call_data.any.minor_code = hdr->minor_opcode; call_data.any.connect_id = connect_id; switch (call_data.major_code) { case XIM_CONNECT:#ifdef XIM_DEBUG DebugLog("-- XIM_CONNECT\n");#endif ConnectMessageProc (ims, &call_data, p1); break; case XIM_DISCONNECT:#ifdef XIM_DEBUG DebugLog("-- XIM_DISCONNECT\n");#endif DisConnectMessageProc (ims, &call_data); break; case XIM_OPEN:#ifdef XIM_DEBUG DebugLog("-- XIM_OPEN\n");#endif OpenMessageProc (ims, &call_data, p1); break; case XIM_CLOSE:#ifdef XIM_DEBUG DebugLog("-- XIM_CLOSE\n");#endif CloseMessageProc (ims, &call_data, p1); break; case XIM_QUERY_EXTENSION:#ifdef XIM_DEBUG DebugLog("-- XIM_QUERY_EXTENSION\n");#endif QueryExtensionMessageProc (ims, &call_data, p1); break; case XIM_GET_IM_VALUES:#ifdef XIM_DEBUG DebugLog("-- XIM_GET_IM_VALUES\n");#endif GetIMValuesMessageProc (ims, &call_data, p1); break; case XIM_CREATE_IC:#ifdef XIM_DEBUG DebugLog("-- XIM_CREATE_IC\n");#endif CreateICMessageProc (ims, &call_data, p1); break; case XIM_SET_IC_VALUES:#ifdef XIM_DEBUG DebugLog("-- XIM_SET_IC_VALUES\n");#endif SetICValuesMessageProc (ims, &call_data, p1); break; case XIM_GET_IC_VALUES:#ifdef XIM_DEBUG DebugLog("-- XIM_GET_IC_VALUES\n");#endif GetICValuesMessageProc (ims, &call_data, p1); break; case XIM_SET_IC_FOCUS:#ifdef XIM_DEBUG DebugLog("-- XIM_SET_IC_FOCUS\n");#endif SetICFocusMessageProc (ims, &call_data, p1); break; case XIM_UNSET_IC_FOCUS:#ifdef XIM_DEBUG DebugLog("-- XIM_UNSET_IC_FOCUS\n");#endif UnsetICFocusMessageProc (ims, &call_data, p1); break; case XIM_DESTROY_IC:#ifdef XIM_DEBUG DebugLog("-- XIM_DESTROY_IC\n");#endif DestroyICMessageProc (ims, &call_data, p1); break; case XIM_RESET_IC:#ifdef XIM_DEBUG DebugLog("-- XIM_RESET_IC\n");#endif ResetICMessageProc (ims, &call_data, p1); break; case XIM_FORWARD_EVENT:#ifdef XIM_DEBUG DebugLog("-- XIM_FORWARD_EVENT\n");#endif if (client->sync == True) { AddQueue (client, p); *delete = False; } else { ForwardEventMessageProc (ims, &call_data, p1); } break; case XIM_EXTENSION:#ifdef XIM_DEBUG DebugLog("-- XIM_EXTENSION\n");#endif ExtensionMessageProc (ims, &call_data, p1); break; case XIM_SYNC:#ifdef XIM_DEBUG DebugLog("-- XIM_SYNC\n");#endif break; case XIM_SYNC_REPLY:#ifdef XIM_DEBUG DebugLog("-- XIM_SYNC_REPLY\n");#endif SyncReplyMessageProc (ims, &call_data, p1); ProcessQueue (ims, connect_id); break; case XIM_TRIGGER_NOTIFY:#ifdef XIM_DEBUG DebugLog("-- XIM_TRIGGER_NOTIFY\n");#endif TriggerNotifyMessageProc (ims, &call_data, p1); break; case XIM_ENCODING_NEGOTIATION:#ifdef XIM_DEBUG DebugLog("-- XIM_ENCODING_NEGOTIATION\n");#endif EncodingNegotiatonMessageProc (ims, &call_data, p1); break; case XIM_PREEDIT_START_REPLY:#ifdef XIM_DEBUG DebugLog("-- XIM_PREEDIT_START_REPLY\n");#endif PreeditStartReplyMessageProc (ims, &call_data, p1); break; case XIM_PREEDIT_CARET_REPLY:#ifdef XIM_DEBUG DebugLog("-- XIM_PREEDIT_CARET_REPLY\n");#endif PreeditCaretReplyMessageProc (ims, &call_data, p1); break; case XIM_STR_CONVERSION_REPLY:#ifdef XIM_DEBUG DebugLog("-- XIM_STR_CONVERSION_REPLY\n");#endif StrConvReplyMessageProc (ims, &call_data, p1); break; } /*endswitch*/}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?