Back to index

im-sdk  12.3.91
IMProtocolStruct.h
Go to the documentation of this file.
00001 /*
00002   Copyright 1990-2001 Sun Microsystems, Inc. All Rights Reserved.
00003 
00004   Permission is hereby granted, free of charge, to any person obtaining a
00005   copy of this software and associated documentation files (the
00006   "Software"), to deal in the Software without restriction, including
00007   without limitation the rights to use, copy, modify, merge, publish,
00008   distribute, sublicense, and/or sell copies of the Software, and to
00009   permit persons to whom the Software is furnished to do so, subject to
00010   the following conditions: The above copyright notice and this
00011   permission notice shall be included in all copies or substantial
00012   portions of the Software.
00013 
00014 
00015   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00016   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00017   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00018   IN NO EVENT SHALL THE OPEN GROUP OR SUN MICROSYSTEMS, INC. BE LIABLE
00019   FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
00020   CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
00021   THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE EVEN IF
00022   ADVISED IN ADVANCE OF THE POSSIBILITY OF SUCH DAMAGES.
00023 
00024 
00025   Except as contained in this notice, the names of The Open Group and/or
00026   Sun Microsystems, Inc. shall not be used in advertising or otherwise to
00027   promote the sale, use or other dealings in this Software without prior
00028   written authorization from The Open Group and/or Sun Microsystems,
00029   Inc., as applicable.
00030 
00031 
00032   X Window System is a trademark of The Open Group
00033 
00034   OSF/1, OSF/Motif and Motif are registered trademarks, and OSF, the OSF
00035   logo, LBX, X Window System, and Xinerama are trademarks of the Open
00036   Group. All other trademarks and registered trademarks mentioned herein
00037   are the property of their respective owners. No right, title or
00038   interest in or to any trademark, service mark, logo or trade name of
00039   Sun Microsystems, Inc. or its licensors is granted.
00040 
00041 */
00042 #ifndef _improtocolstruct_hh
00043 #define _improtocolstruct_hh
00044 
00045 #ifdef HAVE_CONFIG_H
00046 #include <config.h>
00047 #endif
00048 
00049 #include "syscfg.h"
00050 
00051 #ifndef Bool
00052 typedef enum {
00053   True=1, False=0
00054 } Bool;
00055 #endif
00056 
00057 #define IMID int
00058 
00059 typedef unsigned short UTFCHAR;
00060 
00061 #define NoSymbol        0L
00062 #define BufferOverflow         -1
00063 #define LookupNone             1
00064 #define LookupChars            2
00065 #define LookupKeySym           3
00066 #define LookupBoth             4
00067 
00068 typedef enum {
00069   IM_DECORATION_FEEDBACK = 0,      /* IMNormal, IMReverse, IMUnderline */
00070   IM_FOREGROUND_RGB_FEEDBACK = 1,
00071   IM_BACKGROUND_RGB_FEEDBACK = 2,
00072   IM_UNDERLINE_RGB_FEEDBACK = 3
00073 } IMFeedbackType;
00074 
00075 typedef enum {
00076   IM_ANNOTATION_INPUT_STRING = 1,
00077   IM_ANNOTATION_READING = 2,
00078   IM_ANNOTATION_SPEECH = 3,
00079   IM_ANNOTATION_CLAUSE = 4,
00080 
00081   IM_ANNOTATION_FEEDBACK = 0x10,
00082   IM_ANNOTATION_CURRENT = 0x12,
00083   IM_ANNOTATION_CANDIDATES = 0x11,
00084   IM_ANNOTATION_SELECTED_CANDIDATES = 0x12
00085 } IMAnnotationType;
00086 
00087 typedef struct _IMAnnotationValue {
00088   int start_pos;
00089   int end_pos;
00090   int len;
00091   void *value;
00092 } IMAnnotationValue;
00093 
00094 #define IM_FEEDBACK_COUNT(feedbacks) feedbacks->count_feedbacks
00095 #define IM_FEEDBACK_TYPE(feedback) feedback->type
00096 #define IM_FEEDBACK_VALUE(feedback) feedback->value
00097 
00098 #define IM_RGB_COLOR(RED,GREEN,BLUE)      (int)((RED<<16) + (GREEN<<8) + BLUE)
00099 #define IM_RGB_COLOR_RED(COLOR)           (int)(COLOR>>16)
00100 #define IM_RGB_COLOR_GREEN(COLOR)  (int)((COLOR>>8)&0x00ff)
00101 #define IM_RGB_COLOR_BLUE(COLOR)   (int)(COLOR&0x0000ff)
00102 
00103 typedef struct _IMFeedback {
00104   IMFeedbackType type;
00105   int   value;                     /* depends on id-type */
00106 } IMFeedback;
00107 
00108 typedef struct _IMFeedbackList {
00109   unsigned int count_feedbacks;
00110   IMFeedback  *feedbacks;
00111 } IMFeedbackList;
00112 
00113 typedef struct _IMAnnotation {
00114   int type;  /* IMAnnotationType */
00115   int num_values;
00116   IMAnnotationValue   *values;
00117 } IMAnnotation;
00118 
00119 typedef enum {
00120   UTF16_CODESET = 0,
00121   JAEUC_CODESET = 1,
00122   JAPCK_CODESET = 2,
00123   ZHEUC_CODESET = 3,
00124   ZHGBK_CODESET = 4,
00125   TWEUC_CODESET = 5,
00126   TWBIG5_CODESET = 6,
00127   KOEUC_CODESET = 7,
00128   UTF8_CODESET = 8,
00129   UTF32_CODESET = 9
00130 } IMEncoding;
00131 
00132 /* 
00133  * Define the structure used to exchange text
00134  */
00135 typedef struct _IMText {
00136   IMEncoding    encoding;
00137   unsigned int         char_length;
00138   union {
00139     UTFCHAR     *utf_chars; /* UTF16 */
00140     char        *native_chars;/* non-UTF16  */
00141   } text;
00142   IMFeedbackList  *feedback;
00143   unsigned int    count_annotations;
00144   IMAnnotation         *annotations;
00145 } IMText;
00146 
00147 enum MODE {
00148   READ_ONLY = (1 << 0),
00149   WRITE_ONLY = (1 << 1),
00150   READ_WRITE = (1 << 2),
00151   APPEND = (1 << 3),
00152   CREAT = (1 << 4),
00153   NONBLOCK = (1 << 5)
00154 };
00155 
00156 typedef struct _IMNSListenerStruct {
00157   struct _IMNSListenerStruct* self ; 
00158   unsigned int  listener_id;
00159   char          *filename;
00160 } IMNSListenerStruct;
00161 
00162 /*
00163 typedef struct _IMReadNSStruct {
00164   struct _IMReadNSStruct* self ; 
00165   unsigned int  listener_id;
00166   char          *filename;
00167 } IMReadNSStruct;
00168 */
00169 
00170 /* Operation related Data structures */
00171 typedef struct _IMOperation {
00172   unsigned int id;          /* operation id */
00173   int length;                 /* length of value */
00174   void *value;                /* contents, contents in ccdef case */
00175 } IMOperation, *IMOperationList;
00176 
00177 /*
00178  * Event Type
00179  */
00180 
00181 typedef enum {
00182   IM_EventKeyList = 1,
00183   IM_EventString = 2,
00184   IM_EventText = 3,
00185   IM_EventAux = 4,          /* duplicated to IM_EventAuxSet - 
00186                                left for compatibility */
00187   IM_EventAuxSet = 4,
00188   IM_EventAuxGet = 5,
00189   IM_EventX = 100
00190 } IM_Event_Type;
00191 
00192 /*
00193  * a key event for IMKeyListEvent
00194  */
00195 
00196 typedef struct _IMKeyEventStruct {
00197   int keyCode;
00198   int keyChar;
00199   int modifier;
00200   int time_stamp;
00201 } IMKeyEventStruct, *IMKeyList;
00202 
00203 /*
00204  * keylist event
00205  */
00206 typedef struct _IMKeyListEvent {
00207   int type;
00208   int n_operation;
00209   IMOperationList operation_list;
00210 
00211   int n_key;
00212   IMKeyList keylist;
00213 } IMKeyListEvent;
00214 
00215 /*
00216  * Data structures for Preedit
00217  */
00218 
00219 #define IMNormal               0
00220 #define IMReverse              1
00221 #define IMUnderline            2
00222 
00223 typedef struct _IMPreeditDrawCallbackStruct {
00224   int caret;          /* Cursor offset within pre-edit string */
00225   int chg_first;      /* Starting change position */
00226   int chg_length;     /* Length of the change in character count */
00227   IMText *text;
00228 } IMPreeditDrawCallbackStruct;
00229 
00230 typedef enum {
00231   IMForwardChar, IMBackwardChar,
00232   IMForwardWord, IMBackwardWord,
00233   IMCaretUp, IMCaretDown,
00234   IMNextLine, IMPreviousLine,
00235   IMLineStart, IMLineEnd,
00236   IMAbsolutePosition,
00237   IMDontChange
00238 } IMCaretDirection;
00239 
00240 typedef enum {
00241   IMIsInvisible,     /* Disable caret feedback */
00242   IMIsPrimary,       /* UI defined caret feedback */
00243   IMIsSecondary      /* UI defined caret feedback */
00244 } IMCaretStyle;
00245 
00246 typedef struct _IMPreeditCaretCallbackStruct {
00247   int position;               /* Caret offset within pre-edit string */
00248   IMCaretDirection direction; /* Caret moves direction */
00249   IMCaretStyle style;         /* Feedback of the caret */
00250 } IMPreeditCaretCallbackStruct;
00251 
00252 struct IMPreeditStruct {
00253   union {
00254     int return_value;
00255     IMPreeditDrawCallbackStruct draw;
00256     IMPreeditCaretCallbackStruct caret;
00257   } todo;
00258 };
00259 
00260 /*
00261  * Data structures for Status 
00262  */ 
00263 typedef struct _IMStatusDrawCallbackStruct {
00264   IMText *text;
00265 } IMStatusDrawCallbackStruct;
00266 
00267 struct IMStatusStruct {
00268   union {
00269     IMStatusDrawCallbackStruct draw;      /* StatusDraw */
00270   } todo;
00271 };
00272 
00273 /*
00274  * Data structures for Lookup
00275  */
00276 
00277 #define IM_LUC_LABEL_NONE               0
00278 #define IM_LUC_LABEL_NUMERIC            1
00279 #define IM_LUC_LABEL_ALPHABETIC         2
00280 #define IM_LUC_LABEL_ALPHA_UPPER        3
00281 
00282 typedef enum {
00283   HasNotBeenNegotiated = 0,
00284   IMIsMaster = 1,
00285   CBIsMaster  = 2
00286 } WhoIsMaster;
00287  
00288 typedef enum {
00289   DrawUpHorizontally = 0,
00290   DrawUpVertically = 1
00291 } DrawUpDirection;
00292  
00293 typedef enum {
00294   IMOwnsLabel = 0 ,
00295   CBOwnsLabel = 1
00296 } WhoOwnsLabel;
00297 
00298 typedef struct _LayoutInfo {
00299   int choice_per_window;  /* Number of choices can be display
00300                         * in the region
00301                         */
00302   int nrows;
00303   int ncolumns;
00304   DrawUpDirection drawUpDirection ;
00305   WhoOwnsLabel whoOwnsLabel;      /* For callback to tell XIM
00306                                * whether it wants to control
00307                                * what label should be for the choices.
00308                                */
00309   int luc_is_rootwindow;
00310   int label_type;
00311   int root_width;
00312   int root_lines;
00313   int e_width_per_can;
00314   int max_width_per_car;
00315 } LayoutInfo;
00316 
00317 typedef struct _IMLookupStartCallbackStruct {
00318   IMKeyListEvent *event;
00319   WhoIsMaster whoIsMaster;    /* For callback to tell whether is
00320                             * going to be a master */
00321   LayoutInfo *IMPreference;
00322   LayoutInfo *CBPreference;
00323 }   IMLookupStartCallbackStruct;
00324 
00325 typedef struct _IMChoiceObject {
00326   IMText *label;
00327   IMText *value;
00328 } IMChoiceObject;
00329 
00330 typedef struct _IMLookupDrawCallbackStruct {
00331   IMChoiceObject *choices;       /* the lookup choices */
00332   int n_choices;      /* Total number of lookup choices */
00333   int max_len;        /* Max number of characters per
00334                      * choice item
00335                      */
00336   int index_of_first_candidate ;
00337   int index_of_last_candidate ;
00338   int index_of_current_candidate ;
00339   IMText *title;
00340 } IMLookupDrawCallbackStruct;
00341 
00342 typedef enum {
00343   LookupIndex=0,
00344   LookupPage=1
00345 } IMLookupProcessOperationType;
00346 
00347 typedef enum {
00348   LookupNextPage=1,
00349   LookupPrevPage=2,
00350   LookupFirstPage=3,
00351   LookupLastPage=4
00352 } IMLookupProcessPageOperationType;
00353 
00354 typedef struct _IMLookupProcessCallbackStruct {
00355   IMLookupProcessOperationType type;
00356   /* Index(#0) index_of_choice_selected */
00357   /* Page(#1)  page_operation_id */
00358   union {
00359     int index_of_choice_selected;/* Set by callback for the
00360                               * selected choice.
00361                               * IM_UNKNOW_KEYSYM and
00362                               * IM_UNDETERMINED are
00363                               * also possible value.
00364                               */
00365     IMLookupProcessPageOperationType page_operation_id;
00366   } value;
00367 } IMLookupProcessCallbackStruct;
00368 
00369 /*
00370  * Values for IMLookupProcessCallbackStruct.index_of_choice_selected
00371  */
00372 #define         IM_UNKNOWN_KEYSYM       0x77777777
00373 #define         IM_UNDETERMINED 0x77777776
00374 #define         IM_UNKNOWN_CONTROL      0x77777775
00375 
00376 
00377 struct IMLookupStruct {
00378   union {
00379     IMLookupStartCallbackStruct start;    /* LookupStart */
00380     IMLookupDrawCallbackStruct draw;      /* LookupDraw */
00381     IMLookupProcessCallbackStruct process;       /* LookupProcess */
00382   } todo;
00383 };
00384 
00385 /*
00386  * Data structures for Auxiliary 
00387  */
00388 typedef struct _IMAuxBasicCallbackStruct {
00389   char *aux_name;
00390   int  aux_index;    /* do not use in 2.0 */
00391 } IMAuxBasicCallbackStruct, IMAuxStartCallbackStruct, IMAuxDoneCallbackStruct;
00392 
00393 typedef struct _IMAuxDrawCallbackStruct {
00394   char *aux_name;
00395   int  aux_index;    /* do not use in 2.0 */
00396   int  count_integer_values;
00397   int  *integer_values;
00398   int  count_string_values;
00399   IMText *string_values;
00400 } IMAuxDrawCallbackStruct;
00401 
00402 struct IMAuxStruct {
00403   union {
00404     IMAuxStartCallbackStruct start; /* AuxStart */
00405     IMAuxDrawCallbackStruct draw;   /* AuxDraw  */
00406     IMAuxDoneCallbackStruct done;   /* AuxDone  */
00407   } todo;
00408 };
00409 
00410 /*
00411  * Object Downloading
00412  */
00413 
00414 typedef enum {
00415   IM_GUI_OBJECT = 0,
00416   IM_LWE_OBJECT = 1,
00417   IM_SYNTAX_RULE_OBJECT = 2,
00418   IM_MANAGER_RULE_OBJECT = 3,
00419   IM_PRELOADING_LWE_OBJECT = 4
00420 }   IMObjectCategory;
00421 
00422 typedef enum {
00423   IM_DOWNLOADINGOBJECT_JARGUI_TYPE = 0x1031,
00424   IM_DOWNLOADINGOBJECT_JARLWE_TYPE = 0x1032,
00425   IM_DOWNLOADINGOBJECT_CCDEF_TYPE = 0x1030,
00426   IM_DOWNLOADINGOBJECT_EIMIL_TYPE = 0x1030,
00427 
00428   IM_DOWNLOADINGOBJECT_BINGUI_TYPE = 0x1033,
00429   IM_DOWNLOADINGOBJECT_BINLWE_TYPE = 0x1034,
00430 
00431   IM_DOWNLOADINGOBJECT_SGUI_TYPE = 0x1035,
00432   IM_DOWNLOADINGOBJECT_SLWE_TYPE = 0x1036
00433 }   IMObjectType;
00434 
00435 typedef struct _IMObjectDescriptorStruct {
00436   char *leid;                 /* id for LE, `sampleja' */
00437   IMObjectType type;
00438   unsigned int id;          /* assigined dynamically by LELookup */
00439   unsigned int size;        /* object size */
00440 
00441   char **class_names;              /* only for JARFILE_OBJECT */
00442   unsigned int count_names; /* count of class names */
00443                             /* only for CCDEF */
00444   UTFCHAR *name;            /* HRN */
00445   int name_length;          /* HRN len in UTF16-char unit */
00446   char *domain;               /* reversed domain */
00447   char *path;               /* path for object */
00448   char *scope;              /* usability id or `generic' */
00449 
00450   /* only for CCDEF */
00451   char *signature;          /* Object signature */
00452   char *basepath;           /* base path for include tag */
00453   char *encoding;           /* encoding of CCDEF */
00454 } IMObjectDescriptorStruct;
00455 
00456 #define GLOBAL_HOTKEY 0x0
00457 #define SESSION_SPECIFIC_HOTKEY 0x1
00458 
00459 typedef struct _IMHotkey {
00460   int hotkey_id;
00461   int state_flag;
00462   int action_flag;
00463   int nkeys;
00464   IMKeyEventStruct *keys;
00465 } IMHotkey;
00466 
00467 typedef struct _IMHotkeyProfileStruct {
00468   int profile_id;
00469   int scope;
00470   int num_hotkeys;
00471   IMHotkey *hks;
00472   struct _IMHotkeyProfileStruct *next;
00473 } IMHotkeyProfileStruct;
00474 
00475 /*
00476  * string event
00477  */
00478 typedef struct _IMStringEvent {
00479   int type;
00480   int n_operation;
00481   IMOperationList operation_list;
00482   UTFCHAR *string;
00483 } IMStringEvent;
00484 
00485 /*
00486  * text event
00487  */
00488 typedef struct _IMTextEvent {
00489   int type;
00490   int n_operation;
00491   IMOperationList operation_list;
00492   IMText *text;
00493 } IMTextEvent;
00494 
00495 /*
00496  * event for Auxiliary
00497  */
00498 typedef struct _IMAuxEvent {
00499   int type;
00500   IMAuxDrawCallbackStruct *aux;
00501 } IMAuxEvent;
00502 
00503 typedef struct _IMAuxGetEvent {
00504   int type;
00505   IMAuxDrawCallbackStruct *fromaux;       /* AUX -> LE */
00506   IMAuxDrawCallbackStruct *toaux;  /* LE -> AUX */
00507 } IMAuxGetEvent;
00508 
00509 /*
00510  * event for X, only for XSunIM's if_FilterEvent()
00511  */
00512 typedef struct _IMXEvent {
00513   int type;
00514   void *xevent;
00515 } IMXEvent;
00516 
00517 /*
00518  * IMInputEvent
00519  */
00520 typedef union IMInputEvent_ {
00521   int type;
00522   IMKeyListEvent keylist;
00523   IMTextEvent text;
00524   IMStringEvent string;
00525   IMAuxEvent aux;
00526   IMAuxGetEvent auxget;
00527   IMXEvent xevent;
00528 } IMInputEvent;
00529 
00530 /*
00531  * IC & IM ATTRIBID
00532  */
00533 
00534 enum IM_ATTRIBID {
00535   INPUTMETHOD_LIST = 0x1001,
00536   OBJECT_DESCRIPTER_LIST = 0x1010,
00537   CLIENT_DESCRIPTER = 0x1011,
00538   CCDEF = 0x1030,
00539   GUI_OBJECT = 0x1031,
00540   LWE_OBJECT = 0x1032
00541 };
00542 
00543 enum IC_ATTRIBID {
00544   IC_INPUT_LANGUAGE = 1,
00545   IC_CHARACTER_SUBSETS = 2,
00546   IC_INPUT_METHOD = 3,
00547   IC_PREFERED_OBJECT = 4,
00548   IC_SUPPORTED_CLASSES = 5
00549 };
00550 
00551 
00552 /*
00553  * Data structures for sync up.
00554  */
00555 
00556 typedef struct IMTransaction {
00557   CARD32BIT opid;
00558   CARD32BIT trid;
00559 } IMTransaction;
00560 
00561 #define IM_TRANSACTION_NOP_ID 0
00562 #define IM_DIFFERENTIAL_FLAG_NILP(dflag) ((dflag) & 0x1)
00563 
00564 typedef struct IMDifferential {
00565   CARD32BIT symid;
00566   int nil;
00567   int number;
00568   int bool_val;
00569   CARD32BIT ch;
00570   IMInputEvent ev;
00571   int chg_first;
00572   int chg_len;
00573   IMText text;
00574 } IMDifferential;
00575 
00576 #define SYMBOLID_TYPE(symid) (((symid) >> 16) & 0xFF)
00577 
00578 enum IM_SYMBOL_TYPE {
00579   IM_SYMBOL_ATTRIBID = 0,
00580 
00581   IM_SYMBOL_VARIABLE_NUMBER = 1,
00582   IM_SYMBOL_VARIABLE_BOOL = 2,
00583   IM_SYMBOL_VARIABLE_CHAR = 3,
00584   IM_SYMBOL_VARIABLE_MTEXT = 4,
00585   IM_SYMBOL_VARIABLE_EVENT = 5,
00586 
00587   IM_SYMBOL_PROPERTY_MASK = 0x10,
00588   IM_SYMBOL_PROPERTY_NUMBER = IM_SYMBOL_PROPERTY_MASK | IM_SYMBOL_VARIABLE_NUMBER,
00589   IM_SYMBOL_PROPERTY_BOOL = IM_SYMBOL_PROPERTY_MASK | IM_SYMBOL_VARIABLE_BOOL,
00590   IM_SYMBOL_PROPERTY_CHAR = IM_SYMBOL_PROPERTY_MASK | IM_SYMBOL_VARIABLE_CHAR,
00591   IM_SYMBOL_PROPERTY_MTEXT = IM_SYMBOL_PROPERTY_MASK | IM_SYMBOL_VARIABLE_MTEXT,
00592 
00593   IM_SYMBOL_OPERATION = 0x20
00594 };
00595 
00596 typedef struct IMProp {
00597   int type;
00598   int count;
00599   union vals {
00600     IMText *mtexts;
00601     int *numbers;
00602     int *bools;
00603     CARD32BIT *chars;
00604   } vals;
00605 } IMProp;
00606 
00607 typedef struct IMSymbol {
00608   char *symname;
00609   CARD32BIT symid;
00610 } IMSymbol;
00611 
00612 #endif