============================
The Internal Flow Of Docking
============================

Introduction
============
The miniChinput (C2K version) added a features known as chicon. chicon is a KDE panel applet, which is packaged as another package. The internals of both software, however, is related depends on a interface.

The primarily function of chicon and the docking.o of miniChinput is to provide a channel, that, user can control via external programs. Under the current implementation, it is totally possible for write some other chicon-like program to do the similar thing, as long as the program follows the 'protocol'. The terms 'protoco' is so quoted because, the it was far from complete and really lack of features. The current design is only for control the Input Method, and Chi / Eng switching. The implementation of the protocol is greatly depends on the core structure, which will described shortly.

The original Chinput has also provide a powerful features, if compare with chicon + miniChinput, which is called ZWinPro. The reason to remove the support for ZWinPro and implements a new protocol from the ground up is based on the technologies underly. Chinput + ZWinPro use the X Window Intercommunication Protocol, however, chicon + miniChinput is using Unix domain socket as the means. The features provided by ZWinPro is overkill and actually, it is decided and removed by the original author of miniChinput. Nevertheless, using the Unix Domain Socket as the comunication medium between chicon and miniChinput can take the following advantages:
    Easier to implements, esp. either side of the comm. is not native X program.
    Faster, and can be more robust.

Internal Structures and Command
===============================
The key components of the communication scene is the data structure, which is defined in "docking.h". For your convinience, a breif comments for the related files is followed:
    docking.h      ---- Major Data Structures and Constant are defined here
    docking.c      ---- Define function which is used control the flow
    dock_net.c     ---- Define function for lower level socket and fcntl purpose

The structure "DockMessage" is the main stone, it is used to pack message and details every message between miniChinput and chicon.

The field 'message_type' define the message type of each message, this must be either one of:
    HZ_DOCK_INIT
    HZ_DOCK_INIT_ACK
    HZ_DOCK_QUIT
    HZ_DOCK_REQUEST_LIST
    HZ_DOCK_REPLY_LIST
    HZ_DOCK_CHANGE_IM
    HZ_DOCK_SYNC_QUERY
    HZ_DOCK_SYNC_REPLY

The field 'im_index' indicate the current Input Method of being used. It is a reference to the array 'im_record'. The current state is English Input, the value will be -1. Whenever, a message of 'REQUEST_LIST', 'CHANGE_IM', and 'SYNC_REPLY' is packed and sent, these field must be set.

The field 'im_record_cnt' is a int which is the 'number of record' of the array im_record. Whenever the im_record must be set, this field must also set to indicate the upper bound of the array.

The field 'im_record' is an array of type IMRecord, each IMRecord element consist of the information of different input method available for the chicon, in order to provide menu for user to choose about input methods. Inside the IMRecord structure, the field 'im_index' is a reference of the input method to the internal data of miniChinput. When user select an input method from menu, chicon will send a 'HZ_DOCK_CHANGE_IM' message to miniChinput, the DockMessage.im_index will be field with this record. On the other hand, miniChinput can easily change Input Method using this index to reference the internal data. The 'im_en_name' is used to store the English name of a Input Method. This is important for chicon to manage the names of each Input Method.
