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