TThhee XXIIMM TTrraannssppoorrtt SSppeecciiffiiccaattiioonn RReevviissiioonn 00..11 XX VVeerrssiioonn 1111,, RReelleeaassee 77 lliibbXX1111 11..33..22 Takashi Fujiwara FUJITSU LIMITED _A_B_S_T_R_A_C_T This specification describes the transport layer interfaces between Xlib and IM Server, which makes various channels usable such as X protocol or, TCP/IP, DECnet and etc. Copyright © 1994 by FUJITSU LIMITED Permission to use, copy, modify, and distribute this docu‐ mentation for any purpose and without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. Fujitsu makes no representa‐ tions about the suitability for any purpose of the informa‐ tion in this document. This documentation is provided as is without express or implied warranty. Copyright © 1994 X Consortium Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documenta‐ tion files (the ‘‘Software’’), to deal in the Software with‐ out restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the fol‐ lowing conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED ‘‘AS IS’’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PUR‐ POSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSOR‐ TIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name of the X Con‐ sortium shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the X Consortium. _X _W_i_n_d_o_w _S_y_s_t_e_m is a trademark of The Open Group. _1_. _I_n_t_r_o_d_u_c_t_i_o_n The Xlib XIM implementation is layered into three functions, a protocol layer, an interface layer and a transport layer. The purpose of this layering is to make the protocol inde‐ pendent of transport implementation. Each function of these layers are: _T_h_e _p_r_o_t_o_c_o_l _l_a_y_e_r implements overall function of XIM and calls the interface layer functions when it needs to commu‐ nicate to IM Server. _T_h_e _i_n_t_e_r_f_a_c_e _l_a_y_e_r separates the implementation of the transport layer from the protocol layer, in other words, it provides implementation independent hook for the transport layer functions. _T_h_e _t_r_a_n_s_p_o_r_t _l_a_y_e_r handles actual data communication with IM Server. It is done by a set of several functions named transporters. This specification describes the interface layer and the transport layer, which makes various communication channels usable such as X protocol or, TCP/IP, DECnet, STREAM, etc., and provides the information needed for adding another new transport layer. In addition, sample implementations for the transporter using the X connection is described in sec‐ tion 4. _2_. _I_n_i_t_i_a_l_i_z_a_t_i_o_n _2_._1_. _R_e_g_i_s_t_e_r_i_n_g _s_t_r_u_c_t_u_r_e _t_o _i_n_i_t_i_a_l_i_z_e The structure typed as TransportSW contains the list of the transport layer the specific implementations supports. typedef struct { char *transport_name; Bool (*config); } TransportSW; _t_r_a_n_s_p_o_r_t___n_a_m_e name of transport(*1) _c_o_n_f_i_g initial configuration function _________________________ (*1) Refer to "The Input Method Protocol: Appendix B" 11 XXIIMM TTrraannssppoorrtt SSppeecciiffiiccaattiioonn lliibbXX1111 11..33..22 A sample entry for the Xlib supporting transporters is shown below: TransportSW _XimTransportRec[] = { /* char _*_: _* _t_r_a_n_s_p_o_r_t___n_a_m_e, Bool _(_*_c_o_n_f_i_g_)_(_) */ ‘‘X’’, _XimXConf, ‘‘tcp’’, _XimTransConf, ‘‘local’’, _XimTransConf, ‘‘decnet’’, _XimTransConf, ‘‘streams’’, _XimTransConf, (char *)NULL, (Bool (*)())NULL, }; _2_._2_. _I_n_i_t_i_a_l_i_z_a_t_i_o_n _f_u_n_c_t_i_o_n The following function will be called once when Xlib config‐ ures the transporter functions. Bool (*config)(_i_m, _t_r_a_n_s_p_o_r_t___d_a_t_a) XIM _i_m; char _*_t_r_a_n_s_p_o_r_t___d_a_t_a; _i_m Specifies XIM structure address. _t_r_a_n_s_p_o_r_t___d_a_t_a Specifies the data specific to the transporter, in IM Server address. (*1) This function must setup the transporter function pointers. The actual _c_o_n_f_i_g function will be chosen by IM Server at the pre‐connection time, matching by the _t_r_a_n_s_p_o_r_t___n_a_m_e specified in the __XXiimmTTrraannssppoorrttRReecc array; The specific mem‐ bers of XimProto structure listed below must be initialized so that point they appropriate transporter functions. If the specified transporter has been configured success‐ fully, this function returns True. There is no Alternative Entry for config function itself. The structure XimProto contains the following function pointers: _________________________ (*1) Refer to "The Input Method Protocol: Appendix B" 22 XXIIMM TTrraannssppoorrtt SSppeecciiffiiccaattiioonn lliibbXX1111 11..33..22 Bool (*connect)(); /* Open connection */ Bool (*shutdown)(); /* Close connection */ Bool (*write)(); /* Write data */ Bool (*read)(); /* Read data */ Bool (*flush)(); /* Flush data buffer */ Bool (*register_dispatcher)();/* Register asynchronous data handler */ Bool (*call_dispatcher)();/* Call dispatcher */ These functions are called when Xlib needs to communicate the IM Server. These functions must process the appropriate procedure described below. _3_. _T_h_e _i_n_t_e_r_f_a_c_e_/_t_r_a_n_s_p_o_r_t _l_a_y_e_r _f_u_n_c_t_i_o_n_s Following functions are used for the transport interface. Table 3‐1; The Transport Layer Functions. ┌───────────────────────┬─────────────────────┬──────────┐ │ _A_l_t_e_r_n_a_t_i_v_e _E_n_t_r_y │ _X_i_m_P_r_o_t_o _m_e_m_b_e_r │ _S_e_c_t_i_o_n │ │ _(_I_n_t_e_r_f_a_c_e _L_a_y_e_r_) │ _(_T_r_a_n_s_p_o_r_t _L_a_y_e_r_) │ │ ├───────────────────────┼─────────────────────┼──────────┤ │__XXiimmCCoonnnneecctt │ connect │ 3.1 │ ├───────────────────────┼─────────────────────┼──────────┤ │__XXiimmSShhuuttddoowwnn │ shutdown │ 3.2 │ ├───────────────────────┼─────────────────────┼──────────┤ │__XXiimmWWrriittee │ write │ 3.3 │ ├───────────────────────┼─────────────────────┼──────────┤ │__XXiimmRReeaadd │ read │ 3.4 │ ├───────────────────────┼─────────────────────┼──────────┤ │__XXiimmFFlluusshh │ flush │ 3.5 │ ├───────────────────────┼─────────────────────┼──────────┤ │__XXiimmRReeggiisstteerrDDiissppaattcchheerr │ register_dispatcher │ 3.6 │ ├───────────────────────┼─────────────────────┼──────────┤ │__XXiimmCCaallllDDiissppaattcchheerr │ call_dispatcher │ 3.7 │ └───────────────────────┴─────────────────────┴──────────┘ The Protocol layer calls the above functions using the Alternative Entry in the left column. The transport imple‐ mentation defines XimProto member function in the right col‐ umn. The Alternative Entry is provided so as to make easier to implement the Protocol Layer. _3_._1_. _O_p_e_n_i_n_g _c_o_n_n_e_c_t_i_o_n When XXOOppeennIIMM is called, the following function is called to connect with the IM Server. Bool (*connect)(_i_m) XIM _i_m; 33 XXIIMM TTrraannssppoorrtt SSppeecciiffiiccaattiioonn lliibbXX1111 11..33..22 _i_m Specifies XIM structure address. This function must establishes the connection to the IM Server. If the connection is established successfully, this function returns True. The Alternative Entry for this func‐ tion is: Bool _XimConnect(_i_m) XIM _i_m; _i_m Specifies XIM structure address. _3_._2_. _C_l_o_s_i_n_g _c_o_n_n_e_c_t_i_o_n When XXCClloosseeIIMM is called, the following function is called to disconnect the connection with the IM Server. The Alterna‐ tive Entry for this function is: Bool (*shutdown)(_i_m) XIM _i_m; _i_m Specifies XIM structure address. This function must close connection with the IM Server. If the connection is closed successfully, this function returns True. The Alternative Entry for this function is: Bool _XimShutdown(_i_m) XIM _i_m; _i_m Specifies XIM structure address. _3_._3_. _W_r_i_t_i_n_g _d_a_t_a The following function is called, when Xlib needs to write data to the IM Server. Bool (*write)(_i_m, _l_e_n, _d_a_t_a) XIM _i_m; INT16 _l_e_n; XPointer _d_a_t_a; _i_m Specifies XIM structure address. _l_e_n Specifies the length of writing data. _d_a_t_a Specifies the writing data. 44 XXIIMM TTrraannssppoorrtt SSppeecciiffiiccaattiioonn lliibbXX1111 11..33..22 This function writes the _d_a_t_a to the IM Server, regardless of the contents. The number of bytes is passed to _l_e_n. The writing data is passed to _d_a_t_a. If data is sent success‐ fully, the function returns True. Refer to "The Input Method Protocol" for the contents of the writing data. The Alterna‐ tive Entry for this function is: Bool _XimWrite(_i_m, _l_e_n, _d_a_t_a) XIM _i_m; INT16 _l_e_n; XPointer _d_a_t_a; _i_m Specifies XIM structure address. _l_e_n Specifies the length of writing data. _d_a_t_a Specifies the writing data. _3_._4_. _R_e_a_d_i_n_g _d_a_t_a The following function is called when Xlib waits for response from IM server synchronously. Bool (*read)(_i_m, _r_e_a_d___b_u_f, _b_u_f___l_e_n, _r_e_t___l_e_n) XIM _i_m; XPointer _r_e_a_d___b_u_f; int _b_u_f___l_e_n; int _*_r_e_t___l_e_n; _i_m Specifies XIM structure address. _r_e_a_d___b_u_f Specifies the buffer to store data. _b_u_f___l_e_n Specifies the size of the _b_u_f_f_e_r _r_e_t___l_e_n Specifies the length of stored data. This function stores the read data in _r_e_a_d___b_u_f, which size is specified as _b_u_f___l_e_n. The size of data is set to _r_e_t___l_e_n. This function return True, if the data is read normally or reading data is completed. The Alternative Entry for this function is: Bool _XimRead(_i_m, _r_e_t___l_e_n, _b_u_f, _b_u_f___l_e_n, _p_r_e_d_i_c_a_t_e, _p_r_e_d_i_c_a_t_e___a_r_g) XIM _i_m; INT16 _*_r_e_t___l_e_n; XPointer _b_u_f; int _b_u_f___l_e_n; Bool _(_*_p_r_e_d_i_c_a_t_e_)_(_); XPointer _p_r_e_d_i_c_a_t_e___a_r_g; 55 XXIIMM TTrraannssppoorrtt SSppeecciiffiiccaattiioonn lliibbXX1111 11..33..22 _i_m Specifies XIM structure address. _r_e_t___l_e_n Specifies the size of the _d_a_t_a buffer. _b_u_f Specifies the buffer to store data. _b_u_f___l_e_n Specifies the length of _b_u_f_f_e_r. _p_r_e_d_i_c_a_t_e Specifies the predicate for the XIM data. _p_r_e_d_i_c_a_t_e___a_r_g Specifies the predicate specific data. The predicate procedure indicates whether the _d_a_t_a is for the XIM or not. _l_e_n This function stores the read data in _b_u_f, which size is specified as _b_u_f___l_e_n. The size of data is set to _r_e_t___l_e_n. If _p_r_e_e_d_i_c_a_t_e_(_) returns True, this function returns True. If not, it calls the registered callback function. The procedure and its arguments are: Bool (*predicate)(_i_m, _l_e_n, _d_a_t_a, _p_r_e_d_i_c_a_t_e___a_r_g) XIM _i_m; INT16 _l_e_n; XPointer _d_a_t_a; XPointer _p_r_e_d_i_c_a_t_e___a_r_g; _i_m Specifies XIM structure address. _l_e_n Specifies the size of the _d_a_t_a buffer. _d_a_t_a Specifies the buffer to store data. _p_r_e_d_i_c_a_t_e___a_r_g Specifies the predicate specific data. _3_._5_. _F_l_u_s_h_i_n_g _b_u_f_f_e_r The following function is called when Xlib needs to flush the data. void (*flush)(_i_m) XIM _i_m; _i_m Specifies XIM structure address. This function must flush the data stored in internal buffer on the transport layer. If data transfer is completed, the function returns True. The Alternative Entry for this 66 XXIIMM TTrraannssppoorrtt SSppeecciiffiiccaattiioonn lliibbXX1111 11..33..22 function is: void _XimFlush(_i_m) XIM _i_m; _i_m Specifies XIM structure address. _3_._6_. _R_e_g_i_s_t_e_r_i_n_g _a_s_y_n_c_h_r_o_n_o_u_s _d_a_t_a _h_a_n_d_l_e_r Xlib needs to handle asynchronous response from IM Server. This is because some of the XIM data occur asynchronously to X events. Those data will be handled in the _F_i_l_t_e_r, and the _F_i_l_t_e_r will call asynchronous data handler in the protocol layer. Then it calls dispatchers in the transport layer. The dis‐ patchers are implemented by the protocol layer. This func‐ tion must store the information and prepare for later call of the dispatchers using __XXiimmCCaallllDDiissppaattcchheerr. When multiple dispatchers are registered, they will be called sequentially in order of registration, on arrival of asynchronous data. The register_dispatcher is declared as following: Bool (*register_dispatcher)(_i_m, _d_i_s_p_a_t_c_h_e_r, _c_a_l_l___d_a_t_a) XIM _i_m; Bool _(_*_d_i_s_p_a_t_c_h_e_r_)_(_); XPointer _c_a_l_l___d_a_t_a; _i_m Specifies XIM structure address. _d_i_s_p_a_t_c_h_e_rSpecifies the dispatcher function to register. _c_a_l_l___d_a_t_a Specifies a parameter for the _d_i_s_p_a_t_c_h_e_r. The dispatcher is a function of the following type: Bool (*dispatcher)(_i_m, _l_e_n, _d_a_t_a, _c_a_l_l___d_a_t_a) XIM _i_m; INT16 _l_e_n; XPointer _d_a_t_a; XPointer _c_a_l_l___d_a_t_a; _i_m Specifies XIM structure address. _l_e_n Specifies the size of the _d_a_t_a buffer. _d_a_t_a Specifies the buffer to store data. 77 XXIIMM TTrraannssppoorrtt SSppeecciiffiiccaattiioonn lliibbXX1111 11..33..22 _c_a_l_l___d_a_t_a Specifies a parameter passed to the register_dis‐ patcher. The dispatcher is provided by the protocol layer. They are called once for every asynchronous data, in order of regis‐ tration. If the data is used, it must return True. other‐ wise, it must return False. If the dispatcher function returns True, the Transport Layer assume that the data has been processed by the upper layer. The Alternative Entry for this function is: Bool _XimRegisterDispatcher(_i_m, _d_i_s_p_a_t_c_h_e_r, _c_a_l_l___d_a_t_a) XIM _i_m; Bool _(_*_d_i_s_p_a_t_c_h_e_r_)_(_); XPointer _c_a_l_l___d_a_t_a; _i_m Specifies XIM structure address. _d_i_s_p_a_t_c_h_e_rSpecifies the dispatcher function to register. _c_a_l_l___d_a_t_a Specifies a parameter for the _d_i_s_p_a_t_c_h_e_r. _3_._7_. _C_a_l_l_i_n_g _d_i_s_p_a_t_c_h_e_r The following function is used to call the registered dis‐ patcher function, when the asynchronous response from IM Server has arrived. Bool (*call_dispatcher)(_i_m, _l_e_n, _d_a_t_a) XIM _i_m; INT16 _l_e_n; XPointer _d_a_t_a; _i_m Specifies XIM structure address. _l_e_n Specifies the size of _d_a_t_a buffer. _d_a_t_a Specifies the buffer to store data. The call_dispatcher must call the dispatcher function, in order of their registration. _l_e_n and _d_a_t_a are the data passed to register_dispatcher. The return values are checked at each invocation, and if it finds True, it immediately return with true for its return value. It is depend on the upper layer whether the read data is XIM Protocol packet unit or not. The Alternative Entry for this function is: 88 XXIIMM TTrraannssppoorrtt SSppeecciiffiiccaattiioonn lliibbXX1111 11..33..22 Bool _XimCallDispatcher(_i_m, _l_e_n, _d_a_t_a) XIM _i_m; INT16 _l_e_n; XPointer _c_a_l_l___d_a_t_a; 99 │ │ │ XXIIMM TTrraannssppoorrtt SSppeecciiffiiccaa│ttiioonn lliibbXX1111 11..33..22 │ │ _4_. _S_a_m_p_l_e _i_m_p_l_e_m_e_n_t_a_t_i│_o_n_s _f_o_r _t_h_e _T_r_a_n_s_p_o_r_t _L_a_y_e_r │ Sample implementations │for the transporter using the X con‐ nection is described he│re. │ │ _4_._1_. _X _T_r_a_n_s_p_o_r_t │ │ At the beginning of the│X Transport connection for the XIM transport mechanism, tw│o different windows must be created either in an Xlib XIM o│r in an IM Server, with which the Xlib and the IM Server │exchange the XIM transports by using the ClientMessage event│s and Window Properties. In the fol‐ lowing, the window crea│ted by the Xlib is referred as the "client communication w│indow", and on the other hand, the window created by the I│M Server is referred as the "IMS com‐ munication window". │ │ │ _4_._1_._1_. _C_o_n_n_e_c_t_i_o_n │ │ In order to establish a│connection, a communication window is created. A ClientMe│ssage in the following event’s format is sent to the owner wi│ndow of XIM_SERVER selection, which the IM Server has creat│ed. │ Refer to "The Input Met│hod Protocol" for the XIM_SERVER atom. │ │ Table 4‐1; The Clie│ntMessage sent to the IMS window. │ ───────────────────────┼──────────────────────────────────────────────── _S_t_r_u_c_t_u_r_e _M_e_m_b_e_r │ _C_o_n_t_e_n_t_s ───────────────────────┼──────────────────────────────────────────────── int type │ ClientMessage u_long serial │ Set by the X Window System Bool send_event │ Set by the X Window System Display *display │ The display to which connects Window window │ IMS Window ID Atom message_type │ XInternAtom(display, ‘‘_XIM_XCONNECT’’, False) int format │ 32 long data.l[0] │ client communication window ID long data.l[1] │ client‐major‐transport‐version (*1) long data.l[2] │ client‐major‐transport‐version (*1) ───────────────────────┴──────────────────────────────────────────────── In order to establish the connection (to notify the IM Server communication window), the IM Server sends a ClientMessage in the following event’s format to the client communication window. Table 4‐2; The ClientMessage sent by IM Server. 1100 │ │ │ XXIIMM TTrraannssppoorrtt SSppeecciiffiiccaa│ttiioonn lliibbXX1111 11..33..22 │ │ ───────────────────────┼─────────────────────────────────────────────────────── _S_t_r_u_c_t_u_r_e _M_e_m_b_e_r │ _C_o_n_t_e_n_t_s ───────────────────────┼─────────────────────────────────────────────────────── int type │ ClientMessage u_long serial │ Set by the X Window System Bool send_event │ Set by the X Window System Display *display │ The display to which connects Window window │ client communication window ID Atom message_type │ XInternAtom(display, ‘‘_XIM_XCONNECT’’, False) int format │ 32 long data.l[0] │ IMS communication window ID long data.l[1] │ server‐major‐transport‐version (*1) long data.l[2] │ server‐minor‐transport‐version (*1) long data.l[3] │ dividing size between ClientMessage and Property (*2) ───────────────────────┴─────────────────────────────────────────────────────── (*1) major/minor‐transport‐version The read/write method is decided by the combina‐ tion of major/minor‐transport‐version, as follows: Table 4‐3; The read/write method and the major/minor‐transport‐version ┌──────────────────┬───────────────────────────────────────┐ │_T_r_a_n_s_p_o_r_t_‐_v_e_r_s_i_o_n │ _r_e_a_d_/_w_r_i_t_e │ ├────────┬─────────┼───────────────────────────────────────┤ │ _m_a_j_o_r │ _m_i_n_o_r │ │ ├────────┼─────────┼───────────────────────────────────────┤ │ 0 │ 0 │ only‐CM & Property‐with‐CM │ │ │ 1 │ only‐CM & multi‐CM │ │ │ 2 │ only‐CM & multi‐CM & Property‐with‐CM │ ├────────┼─────────┼───────────────────────────────────────┤ │ 1 │ 0 │ PropertyNotify │ ├────────┼─────────┼───────────────────────────────────────┤ │ 2 │ 0 │ only‐CM & PropertyNotify │ │ │ 1 │ only‐CM & multi‐CM & PropertyNotify │ └────────┴─────────┴───────────────────────────────────────┘ only‐CM : data is sent via a ClientMessage multi‐CM : data is sent via multiple ClientMessages Property‐with‐CM : data is written in Property, and its Atom is send via ClientMessage PropertyNotify : data is written in Property, and its Atom is send via PropertyNotify The method to decide major/minor‐transport‐version is as follows: (1) The client sends 0 as major/minor‐transport‐ 1111 │ │ │ XXIIMM TTrraannssppoorrtt SSppeecciiffiiccaattiioonn │ lliibbXX1111 11..33..22 │ │ version to the IM │Server. The client must support all methods in Tab│le 4‐3. The client may send another number as │major/minor‐transport‐version to use other method t│han the above in the future. │ (2) The IM Server send│s its major/minor‐transport‐ver‐ sion number to the│client. The client sends data using the method s│pecified by the IM Server. │ (3) If major/minor‐tra│nsport‐version number is not available, it is r│egarded as 0. │ │ (*2) dividing size between C│lientMessage and Property If data is sent vi│a both of multi‐CM and Property, specify the dividi│ng size between ClientMessage and Property. The │data, which is smaller than this size, is sent via │multi‐CM (or only‐CM), and the data, which is lag│er than this size, is sent via Property. │ │ │ _4_._1_._2_. _r_e_a_d_/_w_r_i_t_e │ │ The data is transferred via │either ClientMessage or Window Property in the X Window Sys│tem. │ │ _4_._1_._2_._1_. _F_o_r_m_a_t _f_o_r _t_h_e _d_a_t│_a _f_r_o_m _t_h_e _C_l_i_e_n_t _t_o _t_h_e _I_M _S_e_r_v_e_r │ │ _C_l_i_e_n_t_M_e_s_s_a_g_e │ │ If data is sent via Cli│entMessage event, the format is as follows: │ │ Table 4‐4; The ClientMe│ssage event’s format (first or middle) │ ───────────────────────┼──────────────────────────────────────────────── _S_t_r_u_c_t_u_r_e _M_e_m_b_e_r │ _C_o_n_t_e_n_t_s ───────────────────────┼──────────────────────────────────────────────── int type │ ClientMessage u_long serial │ Set by the X Window System Bool send_event │ Set by the X Window System Display *display │ The display to which connects Window window │ IMS communication window ID Atom message_type │ XInternAtom(display, ‘‘_XIM_MOREDATA’’, False) int format │ 8 char data.b[20] │ (read/write DATA : 20 byte) ───────────────────────┴──────────────────────────────────────────────── Table 4‐5; The ClientMessage event’s format (only or last) 1122 │ │ │ │ │ │ XXIIMM TTrraannssppoorrtt SSppeecciiffiiccaattii│oonn │ lliibbXX1111 11..33..22 │ │ │ │ ────────────────────┼──┼──────────────────────────────────────────────── _S_t_r_u_c_t_u_r_e _M_e_m_b_e_r │ │ _C_o_n_t_e_n_t_s ────────────────────┼──┼──────────────────────────────────────────────── int type │ │ ClientMessage u_long serial │ │ Set by the X Window System Bool send_event│ │ Set by the X Window System Display *display │ │ The display to which connects Window window │ │ IMS communication window ID Atom message_ty│pe │ XInternAtom(display, ‘‘_XIM_PROTOCOL’’, False) int format │ │ 8 char data.b[20]│ │ (read/write DATA : MAX 20 byte) (*1) ────────────────────┼──┴──────────────────────────────────────────────── │ │ (*1) If the data is │smaller than 20 byte, all data other than avai│lable data must be 0. │ _P_r_o_p_e_r_t_y │ │ In the case of large│data, data will be sent via the Window Property for │the efficiency. There are the fol‐ lowing two methods t│o notify Property, and transport‐ version is decided w│hich method is used. │ │ (1) The XChangeProp│erty function is used to store data in the client c│ommunication window, and Atom of the stored data│is notified to the IM Server via ClientMessage e│vent. │ (2) The XChangeProp│erty function is used to store data in the client c│ommunication window, and Atom of the stored data│is notified to the IM Server via PropertyNotify │event. │ The arguments of the│XChangeProperty are as follows: │ Table 4‐6; The │XChangeProperty event’s format │ ────────────────────┼──────────────────────────────── _A_r_g_u_m_e_n_t │ _C_o_n_t_e_n_t_s ────────────────────┼──────────────────────────────── Display *display │ The display to which connects Window window │ IMS communication window ID Atom property │ read/write property Atom (*1) Atom type │ XA_STRING int format │ 8 int mode │ PropModeAppend u_char *data │ read/write DATA int nelements │ length of DATA ────────────────────┴──────────────────────────────── 1133 │ │ │ XXIIMM TTrraannssppoorrtt SSppeecciiffiiccaattiioonn │ lliibbXX1111 11..33..22 │ │ (*1) The read/write pro│perty ATOM allocates the follow‐ ing strings by XXIInn│tteerrnnAAttoomm. ‘‘_clientXXX’│’ │ The client changes the │property with the mode of Prop‐ ModeAppend and the IM S│erver will read it with the delete mode i.e. (delet│e = True). │ If Atom is notified via│ClientMessage event, the format of the ClientMessage is│as follows: │ Table 4‐7; The ClientMe│ssage event’s format to send Atom│of property │ ───────────────────────┼──────────────────────────────────────────────── _S_t_r_u_c_t_u_r_e _M_e_m_b_e_r │ _C_o_n_t_e_n_t_s ───────────────────────┼──────────────────────────────────────────────── int type │ ClientMessage u_long serial │ Set by the X Window System Bool send_event │ Set by the X Window System Display *display │ The display to which connects Window window │ IMS communication window ID Atom message_type │ XInternAtom(display, ‘‘_XIM_PROTOCOL’’, False) int format │ 32 long data.l[0] │ length of read/write property Atom long data.l[1] │ read/write property Atom ───────────────────────┴──────────────────────────────────────────────── │ │ │ _4_._1_._2_._2_. _F_o_r_m_a_t _f_o_r _t_h_e _d_a_t│_a _f_r_o_m _t_h_e _I_M _S_e_r_v_e_r _t_o _t_h_e _C_l_i_e_n_t │ │ _C_l_i_e_n_t_M_e_s_s_a_g_e │ │ The format of the Clien│tMessage is as follows: │ Table 4‐8; The ClientMe│ssage event’s format (first or middle) │ ───────────────────────┼──────────────────────────────────────────────── _S_t_r_u_c_t_u_r_e _M_e_m_b_e_r │ _C_o_n_t_e_n_t_s ───────────────────────┼──────────────────────────────────────────────── int type │ ClientMessage u_long serial │ Set by the X Window System Bool send_event │ Set by the X Window System Display *display │ The display to which connects Window window │ client communication window ID Atom message_type │ XInternAtom(display, ‘‘_XIM_MOREDATA’’, False) int format │ 8 char data.b[20] │ (read/write DATA : 20 byte) ───────────────────────┴──────────────────────────────────────────────── Table 4‐9; The ClientMessage event’s format (only or last) 1144 │ │ │ │ │ │ XXIIMM TTrraannssppoorrtt SSppeecciiffiiccaattii│oonn │ lliibbXX1111 11..33..22 │ │ │ │ ────────────────────┼──┼──────────────────────────────────────────────── _S_t_r_u_c_t_u_r_e _M_e_m_b_e_r │ │ _C_o_n_t_e_n_t_s ────────────────────┼──┼──────────────────────────────────────────────── int type │ │ ClientMessage u_long serial │ │ Set by the X Window System Bool send_event│ │ Set by the X Window System Display *display │ │ The display to which connects Window window │ │ client communication window ID Atom message_ty│pe │ XInternAtom(display, ‘‘_XIM_PROTOCOL’’, False) int format │ │ 8 char data.b[20]│ │ (read/write DATA : MAX 20 byte) (*1) ────────────────────┼──┴──────────────────────────────────────────────── │ │ │ (*1) If the data siz│e is smaller than 20 bytes, all data other than│available data must be 0. │ _P_r_o_p_e_r_t_y │ │ In the case of large│data, data will be sent via the Window Property for │the efficiency. There are the fol‐ lowing two methods t│o notify Property, and transport‐ version is decided w│hich method is used. │ │ (1) The XChangeProp│erty function is used to store data in the IMS comm│unication window, and Atom of the property is sen│t via the ClientMessage event. │ (2) The XChangeProp│erty function is used to store data in the IMS comm│unication window, and Atom of the property is sen│t via PropertyNotify event. │ The arguments of the│XChangeProperty are as follows: │ Table 4‐10; The │XChangeProperty event’s format │ ────────────────────┼────────────────────────────────── _A_r_g_u_m_e_n_t │ _C_o_n_t_e_n_t_s ────────────────────┼────────────────────────────────── Display *display │ The display which to connects Window window │ client communication window ID Atom property │ read/write property Atom (*1) Atom type │ XA_STRING int format │ 8 int mode │ PropModeAppend u_char *data │ read/write DATA int nelements │ length of DATA ────────────────────┴────────────────────────────────── (*1) The read/write property ATOM allocates some 1155 │ │ │ XXIIMM TTrraannssppoorrtt SSppeecciiffiiccaattiioonn │ lliibbXX1111 11..33..22 │ │ strings, which are│not allocated by the client, by XXIInntteerrnnAAttoomm. │ │ The IM Server changes t│he property with the mode of PropModeAppend and the │client reads it with the delete mode, i.e. (delete = Tr│ue). │ If Atom is notified via│ClientMessage event, the format of the ClientMessage is│as follows: │ Table 4‐11; The ClientM│essage event’s format to send Atom│of property │ ───────────────────────┼──────────────────────────────────────────────── _S_t_r_u_c_t_u_r_e _M_e_m_b_e_r │ _C_o_n_t_e_n_t_s ───────────────────────┼──────────────────────────────────────────────── int type │ ClientMessage u_long serial │ Set by the X Window System Bool send_event │ Set by the X Window System Display *display │ The display to which connects Window window │ client communication window ID Atom message_type │ XInternAtom(display, ‘‘_XIM_PROTOCOL’’, False) int format │ 32 long data.l[0] │ length of read/write property ATOM long data.l[1] │ read/write property ATOM ───────────────────────┴──────────────────────────────────────────────── _4_._1_._3_. _C_l_o_s_i_n_g _C_o_n_n_e_c_t_i_o_n If the client disconnect with the IM Server, shutdown func‐ tion should free the communication window properties and etc.. _5_. _R_e_f_e_r_e_n_c_e_s [1] Masahiko Narita and Hideki Hiura, _‘_‘_T_h_e _I_n_p_u_t _M_e_t_h_o_d _P_r_o_t_o_c_o_l_’_’ 1166