Back to index

im-sdk  12.3.91
SunIMMthd.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  SUNIMMTHD_H
00043 #define  SUNIMMTHD_H
00044 
00045 #include <stdio.h>
00046 #include <sys/types.h>
00047 #include <dirent.h>
00048 #include <fcntl.h>
00049 #include <unistd.h>
00050 #include <utime.h>
00051 #include <sys/stat.h>
00052 #include <sys/uio.h>
00053 #include <sys/time.h>
00054 #include "IMProtocolStruct.h"
00055 
00056 #if defined(sun)
00057 #include <thread.h>
00058 #elif defined(WIN32)
00059 #include <windows.h>
00060 #else
00061 #include <pthread.h>
00062 #endif
00063 
00064 #ifdef ENABLE_EIMIL
00065 #include <EIMIL.h>
00066 #endif
00067 
00068 #ifdef __cplusplus
00069 extern "C" {
00070 #endif
00071 
00072 typedef struct _iml_nsc *iml_nsc_t;
00073 typedef struct _iml_hkc *iml_hkc_t;
00074 typedef struct _iml_desktop_t *iml_desktop_list;
00075 typedef struct _iml_session *iml_session;
00076 typedef struct _iml_if_t *iml_if;
00077 typedef struct _iml_aux *iml_aux;
00078 typedef iml_session iml_session_list;
00079 
00080 typedef void *(*iml_nsc_create_t) (const char *, int , void *);
00081 typedef void (*iml_nsc_free_t) (iml_nsc_t);
00082 typedef int (*iml_nsc_open_t) (iml_nsc_t, const char *, int, ...);
00083 typedef size_t (*iml_nsc_read_t) (iml_nsc_t, int, void *, size_t);
00084 typedef size_t (*iml_nsc_write_t) (iml_nsc_t, int, void *, size_t);
00085 typedef int (*iml_nsc_close_t) (iml_nsc_t, int);
00086 typedef int (*iml_nsc_mkdir_t) (iml_nsc_t, const char *, mode_t);
00087 typedef int (*iml_nsc_rmdir_t) (iml_nsc_t, const char *);
00088 typedef int (*iml_nsc_symlink_t) (iml_nsc_t, const char *, const char *);
00089 typedef int (*iml_nsc_stat_t) (iml_nsc_t, const char *, struct stat *);
00090 typedef int (*iml_nsc_lstat_t) (iml_nsc_t, const char *, struct stat *);
00091 typedef off_t (*iml_nsc_lseek_t) (iml_nsc_t, int, off_t, int);
00092 typedef int (*iml_nsc_unlink_t) (iml_nsc_t, const char *);
00093 typedef int (*iml_nsc_rename_t) (iml_nsc_t, const char *, const char *);
00094 typedef int (*iml_nsc_fcntl_t) (iml_nsc_t, int, int, int);
00095 typedef int (*iml_nsc_truncate_t) (iml_nsc_t, const char *, off_t);
00096 typedef int (*iml_nsc_ftruncate_t) (iml_nsc_t, int, off_t);
00097 typedef DIR *(*iml_nsc_opendir_t) (iml_nsc_t, const char *);
00098 typedef struct dirent *(*iml_nsc_readdir_t) (iml_nsc_t, DIR *);
00099 typedef int (*iml_nsc_closedir_t) (iml_nsc_t, DIR *);
00100 typedef int (*iml_nsc_access_t) (iml_nsc_t, const char *, int);
00101 typedef int (*iml_nsc_chmod_t) (iml_nsc_t, const char *, mode_t);
00102 typedef int (*iml_nsc_chown_t) (iml_nsc_t, const char *, uid_t, gid_t);
00103 typedef long (*iml_nsc_fpathconf_t) (iml_nsc_t, int, int);
00104 typedef int (*iml_nsc_fstat_t) (iml_nsc_t, int, struct stat *);
00105 typedef int (*iml_nsc_link_t) (iml_nsc_t, const char *, const char *);
00106 typedef long (*iml_nsc_pathconf_t) (iml_nsc_t, char *, int);
00107 typedef ssize_t (*iml_nsc_readv_t) (iml_nsc_t, int, const struct iovec *, int);
00108 typedef ssize_t (*iml_nsc_writev_t) (iml_nsc_t, int, const struct iovec *, int);
00109 typedef long (*iml_nsc_ulimit_t) (iml_nsc_t, int, long);
00110 typedef mode_t (*iml_nsc_umask_t) (iml_nsc_t, mode_t);
00111 typedef int (*iml_nsc_utime_t) (iml_nsc_t, const char *, const struct utimbuf *);
00112 typedef int (*iml_nsc_utimes_t) (iml_nsc_t, char *, struct timeval *);
00113 
00114 typedef struct _iml_file_status {
00115   char* path_name;
00116   int ns_id;
00117   char **d_name;
00118   int **d_reclen;
00119   int nitems;
00120   int fd;
00121   DIR *dirp;
00122   struct _iml_file_status *next;
00123 } iml_file_status_t;
00124 
00125 typedef iml_file_status_t *file_status_list;
00126 
00127 typedef struct _iml_nsc_private {
00128   int location;
00129   int ns_type;
00130   void *ns_owner;
00131   file_status_list fslist;
00132 } iml_nsc_private;
00133 
00134 typedef struct _iml_nsc {
00135     iml_nsc_private *value;
00136 } iml_nsc;
00137 
00138 typedef struct _iml_hkc_private {
00139   int hk_type;
00140   void *hk_owner;
00141 } iml_hkc_private;
00142 
00143 typedef void *(*iml_hkc_create_t) (const char *, int , void *);
00144 typedef void (*iml_hkc_free_t) (iml_hkc_t);
00145 
00146 typedef struct _iml_hkc {
00147     iml_hkc_private *value;
00148 } iml_hkc;
00149 
00150 typedef struct _iml_nsl {
00151     char *path_name;
00152     void *calldata;
00153 } iml_nsl;
00154 
00155 typedef struct _iml_nsc_basic_fioset {
00156     int (*open) (iml_nsc_t, const char *, int, ...);
00157     size_t (*read) (iml_nsc_t, int, void *, size_t);
00158     int (*stat) (iml_nsc_t, const char *, struct stat *);
00159     size_t (*write) (iml_nsc_t, int, void *, size_t);
00160     int (*close) (iml_nsc_t, int);
00161     int (*mkdir) (iml_nsc_t, const char *, mode_t);
00162     int (*rmdir) (iml_nsc_t, const char *);
00163     int (*symlink) (iml_nsc_t, const char *, const char *);
00164     int (*lstat) (iml_nsc_t, const char *, struct stat *);
00165     int (*creat) (iml_nsc_t, const char *, mode_t);
00166     off_t (*lseek) (iml_nsc_t, int, off_t, int);
00167     int (*unlink) (iml_nsc_t, const char *);
00168     int (*rename) (iml_nsc_t, const char *, const char *);
00169     int (*fcntl) (iml_nsc_t, int, int, int);
00170     int (*truncate) (iml_nsc_t, const char *, off_t);
00171     DIR *(*opendir) (iml_nsc_t, const char *);
00172     struct dirent *(*readdir) (iml_nsc_t, DIR *);
00173     int (*closedir) (iml_nsc_t, DIR *);
00174     int (*fstat) (iml_nsc_t, int, struct stat *);
00175     int (*ftruncate) (iml_nsc_t, int, off_t);
00176 } iml_nsc_basic_fioset_t;
00177 
00178 typedef int listener_id_t;
00179 
00180 typedef struct _iml_listener {
00181     iml_session s;
00182     char* listener_name ;
00183     listener_id_t listener_id ; /* identify the listener */
00184     void* (*listener)(listener_id_t listener_id, 
00185                       int size, /* Size of the file read */
00186                     void* public_data, /* buf contain the data retrieved */
00187                     void* private_data /* data passed via addlistener */
00188     );
00189     void* private_data ; /* store the "value" passed by addlistner */
00190     struct _iml_listener *next;    /* link */
00191 } iml_listener_t ;
00192 
00193 typedef iml_listener_t *iml_listener_list;
00194 
00195 typedef struct _iml_desktop_t {
00196     /* public */
00197     iml_if If;                            /* parent IF */
00198 
00199     char *user_name;               /* user info */
00200     char *host_name;               /* user info */
00201     char *display_id;                     /* user info */
00202 
00203     void *specific_data;           /* specific data for desktop */
00204 
00205     iml_session_list session_list;
00206     int session_count;
00207 
00208     /* private */
00209     struct _iml_desktop_t *next;   /* link */
00210 
00211 /*
00212  * Added to bottom for binary compatibility 
00213  */
00214     /* public */
00215     listener_id_t (*addListenerToDesktop)(iml_session, void *, void *); 
00216     iml_listener_t *(*lookupListenerFromDesktop)(iml_session, int) ;
00217     void (*deleteListenerFromDesktop)(iml_session, int);
00218 
00219     /* private */
00220     int listener_id;
00221     int listener_count;
00222     iml_listener_list l_list ;
00223 
00224 }   iml_desktop_t;
00225 
00226 typedef struct _iml_methods {
00227     iml_inst *(*iml_make_preedit_start_inst) (iml_session);
00228     iml_inst *(*iml_make_preedit_draw_inst) (iml_session, IMText *);
00229     iml_inst *(*iml_make_preedit_draw_with_chgpos_inst) (iml_session, IMText *, int, int, int);
00230     iml_inst *(*iml_make_preedit_erase_inst) (iml_session);
00231     iml_inst *(*iml_make_preedit_caret_inst) (iml_session, int);
00232     iml_inst *(*iml_make_preedit_done_inst) (iml_session);
00233 
00234     iml_inst *(*iml_make_status_start_inst) (iml_session);
00235     iml_inst *(*iml_make_status_draw_inst) (iml_session, IMText *);
00236     iml_inst *(*iml_make_status_done_inst) (iml_session);
00237 
00238     iml_inst *(*iml_make_lookup_start_inst) (iml_session, IMLookupStartCallbackStruct *);
00239     iml_inst *(*iml_make_lookup_draw_inst) (iml_session, IMLookupDrawCallbackStruct *);
00240     iml_inst *(*iml_make_lookup_done_inst) (iml_session);
00241 
00242     iml_inst *(*iml_make_start_conversion_inst) (iml_session);
00243     iml_inst *(*iml_make_end_conversion_inst) (iml_session);
00244 
00245     iml_inst *(*iml_make_commit_inst) (iml_session, IMText *);
00246     iml_inst *(*iml_make_keypress_inst) (iml_session, IMKeyEventStruct *);
00247 
00248     iml_inst *(*iml_make_aux_start_inst) (iml_session, IMAuxStartCallbackStruct *);
00249     iml_inst *(*iml_make_aux_draw_inst) (iml_session, IMAuxDrawCallbackStruct *);
00250     iml_inst *(*iml_make_aux_done_inst) (iml_session, IMAuxDoneCallbackStruct *);
00251     void *(*iml_new) (iml_session, int);
00252     void *(*iml_new2) (iml_session, int);
00253     void *(*iml_delete) (iml_session);
00254     void *(*iml_delete2) (iml_session);
00255 
00256     iml_inst *(*iml_link_inst_tail) (iml_inst **, iml_inst *);
00257     iml_inst *(*iml_execute) (iml_session, iml_inst **);
00258 
00259     int (*iml_add_listener)(iml_session, char *, void *, void *);
00260     int (*iml_delete_listener)(iml_session, int listener_id);
00261 
00262     void *(*iml_getvalue) (iml_session, char *, void *);
00263     void (*iml_setvalue) (iml_session, char *, void *);
00264 
00265 }   iml_methods_t;
00266 
00267 /* Convenient functions, which are the wrapper of low level of iml methods */
00268 typedef struct _iml_methods_wrapper {
00269   void (*iml_commit) (iml_session, UTFCHAR *);
00270   void (*iml_forward_keypress) (iml_session, IMKeyEventStruct *);
00271   void (*iml_conversion_on) (iml_session);
00272   void (*iml_conversion_off) (iml_session);
00273   void (*iml_status_start) (iml_session);
00274   void (*iml_status_end) (iml_session);
00275   void (*iml_status_draw) (iml_session, UTFCHAR *);
00276   void (*iml_preedit_start) (iml_session);
00277   void (*iml_preedit_end) (iml_session);
00278   void (*iml_preedit_draw) (iml_session, UTFCHAR *, int);
00279   void (*iml_lookup_start) (iml_session, LayoutInfo *);
00280   void (*iml_lookup_end) (iml_session);
00281   void (*iml_lookup_draw) (iml_session, int, UTFCHAR **,
00282                         IMFeedbackList **, UTFCHAR **,
00283                         IMFeedbackList **, UTFCHAR *,
00284                         IMFeedbackList *, int, int);
00285   void (*iml_aux_start) (iml_session, char *);
00286   void (*iml_aux_done) (iml_session, char *);
00287   void (*iml_aux_draw) (iml_session, char *, int, int *, int, int *, UTFCHAR **);
00288 } iml_methods_wrapper_t;
00289 
00290 typedef struct _if_methods {
00291     Bool(*if_OpenIF) (iml_if);
00292     Bool(*if_CloseIF) (iml_if);
00293     Bool(*if_GetIFValues) (iml_if, IMArgList, int);
00294     Bool(*if_SetIFValues) (iml_if, IMArgList, int);
00295 
00296     Bool(*if_OpenDesktop) (iml_desktop_t *, IMArgList, int);
00297     Bool(*if_CloseDesktop) (iml_desktop_t *);
00298 
00299     Bool(*if_CreateSC) (iml_session, IMArgList, int);
00300     Bool(*if_DestroySC) (iml_session);
00301     Bool(*if_GetSCValues) (iml_session, IMArgList, int);
00302     Bool(*if_SetSCValues) (iml_session, IMArgList, int);
00303 
00304     IMText *(*if_ResetSC) (iml_session);
00305 
00306     void (*if_SetSCFocus) (iml_session);
00307     void (*if_UnsetSCFocus) (iml_session);
00308 
00309     void (*if_SendEvent) (iml_session, IMInputEvent *);
00310 }   if_methods_t;
00311 
00312 enum IM_HOTKEY_SCOPE {
00313   GLOBAL_HOTKEY = 0x0,
00314   SESSION_SPECIFIC_HOTKEY = 0x1
00315 };
00316 
00317 enum IML_CONTEXT_ID {
00318   IML_NSC_TYPE_LE = 1,
00319   IML_NSC_TYPE_DESKTOP,
00320   IML_HKC_TYPE_LE,
00321   IML_HKC_TYPE_DESKTOP,
00322   IML_CONTEXT_NUM
00323 };
00324 
00325 enum IML_NS_LOCATION_ID {
00326   NS_LOCAL = 1,
00327   NS_REMOTE,
00328   NS_DATABASE,
00329   NS_LOCATION_NUM
00330 };
00331 
00332 /*
00333  * Per interface data structure
00334  */
00335 typedef struct _IMHotkeyStruct {
00336   char *label;
00337   int state_flag;
00338   int action_flag;
00339   int nkeys;
00340   IMKeyEventStruct *keys;
00341 } IMHotkeyStruct;
00342 
00343 typedef struct _IMHotkeyProfileStruct {
00344   IMLEName *name;
00345   int profile_id;
00346   int scope;
00347   int num_hotkeys;
00348   IMHotkeyStruct *hks;
00349 } IMHotkeyProfileStruct;
00350 
00351 typedef struct _IMHotkeyManagerStruct {
00352   int num_hotkey_profiles;
00353   IMHotkeyProfileStruct *hkps;
00354 } IMHotkeyManagerStruct;
00355 
00356 typedef struct _IMNsMapStruct {
00357   char *if_name;
00358   char *src_entry;
00359   char *dest_entry;
00360   char *location;
00361 } IMNsMapStruct;
00362 
00363 typedef struct _iml_if_t {
00364     /* public */
00365     char *if_name;                        /* id */
00366     char *if_version;                            /* version */
00367     char *locale;                         /* locale */
00368 
00369     iml_methods_t *m;                            /* link for iml methods */
00370 
00371     iml_desktop_list desktop_list;        /* list for child desktop */
00372     int desktop_count;
00373 
00374     char *ifpath_name;                           /* location of if module */
00375 
00376     /* private */
00377     if_methods_t *ifm;
00378 
00379     void *dl_module;
00380 
00381     IMLEName *lename;
00382     IMLocale *locale_list;
00383     IMObjectDescriptorStruct *object_list;
00384     Bool xsunim;
00385     Bool need_thread_lock;
00386 #ifdef USE_SUNIM_ADAPTER
00387     Bool need_adapter;
00388 #endif /* USE_SUNIM_ADAPTER */
00389 
00390 #ifdef ENABLE_EIMIL
00391     EIMIL_handle eh;
00392 #endif
00393 
00394 /*
00395  * Added to bottom for binary compatibility
00396  */
00397     IMHotkeyManagerStruct *hkm;
00398 
00399     void *(*nsc_get_function) (const char *);
00400     void *(*hkc_get_function) (const char *);
00401 
00402     /* Method for updating the supported language list per LE */
00403     int (*updateSupportedLocales) (iml_desktop_t *, IMLEName *, IMLocale *, int);
00404 
00405     /* Method for switching hotkey profiles from LE */
00406     int (*switchLEProfile) (iml_session, int, IMLEName *);
00407 
00408     int num_nsm_entries;
00409     IMNsMapStruct *ns_map;
00410 
00411     Bool need_keyrelease;
00412     IMEInfo *imeinfo_list;
00413 
00414     iml_methods_wrapper_t *m_wrapper; /* convenient functions */
00415 }   iml_if_t;
00416 
00417 typedef enum {
00418        IF_VERSION = 1,
00419        IF_METHOD_TABLE,
00420        IF_LE_NAME,
00421        IF_SUPPORTED_LOCALES,
00422        IF_SUPPORTED_OBJECTS,
00423 #ifdef USE_SUNIM_ADAPTER
00424        IF_NEED_THREAD_LOCK,
00425        IF_HAVE_LOCALE_DEPENDENCY,
00426 #else  /* USE_SUNIM_ADAPTER */
00427        IF_NEED_THREAD_LOCK,
00428 #endif /* USE_SUNIM_ADAPTER */
00429 
00430        /* EIMIL extension */
00431        IF_EIMIL_HANDLE = 0x100,
00432 
00433        /* LE extension */
00434        IF_SUPPORTED_KEYRELEASE,
00435        IF_SUPPORTED_IMEINFO
00436 
00437 }   IF_Attribute;
00438 
00439 typedef enum {
00440        SC_REALIZE = 1,
00441        SC_TRIGGER_ON_NOTIFY,
00442        SC_TRIGGER_OFF_NOTIFY,
00443        SC_SUPPORTED_CHARACTER_SUBSETS,
00444 
00445        SC_PREFERED_OBJECTS = 64,
00446        SC_SUPPORTED_CLASSES = 65,
00447        SC_LOOKUP_NROWS = 100,             /* for compatibility purpose */
00448        SC_LOOKUP_NCOLS,                   /* for compatibility purpose */
00449        SC_LOOKUP_LABELTYPE,        /* for compatibility purpose */
00450 
00451        SC_CLIENT_LOCALE = 200,
00452        SC_CLIENT_CHARACTER_SUBSETS,
00453        SC_CLIENT_INPUT_METHOD_NAME,
00454        SC_CLIENT_INPUT_METHOD_ENGINE
00455 }   SC_Attribute;
00456 
00457 typedef enum {
00458        UI_USER_NAME = 1,
00459        UI_HOST_NAME,
00460        UI_DISPLAY_ID,
00461        UI_PROTOCOL_TYPE,
00462        UI_CLIENT_TYPE,
00463        UI_OS_NAME,
00464        UI_OS_ARCH,
00465        UI_OS_VERSION,
00466        UI_XSERVER_VENDOR,
00467        UI_AUTH_PASSWD
00468 }   UI_Attribute;
00469 
00470 #define       MAX_UI_ATTRIBUTE     UI_AUTH_PASSWD
00471 
00472 #define UI_PROTOCOL_TYPE_IIIMP     "IIIMP"
00473 #define UI_PROTOCOL_TYPE_XIMP      "XIMP"
00474 #define UI_PROTOCOL_TYPE_XIMCP     "XIMCP"
00475 
00476 #define UI_CLIENT_TYPE_JAVA "JAVA"
00477 #define UI_CLIENT_TYPE_X    "X"
00478 #define UI_CLIENT_TYPE_UNKNOWN     "Unknown"
00479 
00480 #ifdef __cplusplus
00481 }
00482 #endif
00483 
00484 #endif                      /* SUNIMMTHD_H */
00485 /* Local Variables: */
00486 /* c-file-style: "iiim-project" */
00487 /* End: */