Back to index

im-sdk  12.3.91
iiimp.h
Go to the documentation of this file.
00001 #if !defined(IIIMP_H)
00002 #define IIIMP_H
00003 
00004 
00005 #include <sys/types.h>
00006 #include <stdlib.h>
00007 #include <sys/stat.h>
00008 #include <unistd.h>
00009 #include <dirent.h>
00010 
00011 #include <iiimp-opcode.h>
00012 #include <iiimp-data.h>
00013 #include <iiimp-keycode.h>
00014 
00015 
00016 #ifdef __cplusplus
00017 extern "C" {
00018 #endif
00019 
00020 
00021 /*
00022  * IIIMF public type
00023  */
00024 
00025 typedef struct iiimf_im            IIIMF_im;
00026 typedef struct iiimf_ic            IIIMF_ic;
00027 
00028 typedef enum {
00029        IIIMF_ROLE_CLIENT    = 1,
00030        IIIMF_ROLE_SERVER    = 0
00031 } IIIMF_role;
00032 
00033 typedef enum {
00034        IIIMF_MESSAGE_HANDLER_STATUS_ERROR = -1,
00035        IIIMF_MESSAGE_HANDLER_STATUS_NORMAL       = 0,
00036        IIIMF_MESSAGE_HANDLER_STATUS_STOP  = 1
00037 } IIIMF_message_handler_status;
00038 
00039 typedef struct iiimf_message_handler_entry IIIMF_message_handler_entry;
00040 
00041 
00042 /* general return status */
00043 
00044 typedef enum {
00045        IIIMF_STATUS_FAIL                  = -1,
00046        IIIMF_STATUS_SUCCESS               = 0,
00047 
00048        IIIMF_STATUS_MALLOC                = 11,
00049        IIIMF_STATUS_ARGUMENT                     = 12,
00050        IIIMF_STATUS_PROTOCOL_VERSION             = 13,
00051 
00052        IIIMF_STATUS_CONFIG                = 51,
00053        IIIMF_STATUS_ROLE                  = 52,
00054 
00055        IIIMF_STATUS_OPCODE                = 101,
00056 
00057        IIIMF_STATUS_SEQUENCE_REQUEST             = 201,
00058        IIIMF_STATUS_SEQUENCE_REPLY        = 202,
00059        IIIMF_STATUS_SEQUENCE_ROLE         = 203,
00060        IIIMF_STATUS_SEQUENCE_STATE        = 204,
00061        IIIMF_STATUS_SEQUENCE_NEST         = 205,
00062 
00063        IIIMF_STATUS_IM_INVALID                   = 501,
00064        IIIMF_STATUS_IC_INVALID                   = 502,
00065 
00066        IIIMF_STATUS_STREAM                = 1001,
00067        IIIMF_STATUS_STREAM_SEND           = 1002,
00068        IIIMF_STATUS_STREAM_RECEIVE        = 1003,
00069        IIIMF_STATUS_PACKET                = 1004,
00070        IIIMF_STATUS_INVALID_ID                   = 1005,
00071        IIIMF_STATUS_TIMEOUT               = 1006,
00072        IIIMF_STATUS_CONNECTION_CLOSED          = 2001,
00073 
00074        IIIMF_STATUS_IIIMCF_START          = 10000,
00075        IIIMF_STATUS_NO_ATTR_VALUE         = 10001,
00076        IIIMF_STATUS_NO_TEXT_PROPERTY             = 10002,
00077        IIIMF_STATUS_NO_EVENT                     = 10003,
00078        IIIMF_STATUS_NO_PREEDIT                   = 10004,
00079        IIIMF_STATUS_NO_LOOKUP_CHOICE             = 10005,
00080        IIIMF_STATUS_NO_STATUS_TEXT        = 10006,
00081        IIIMF_STATUS_NO_COMMITTED_TEXT            = 10007,
00082        IIIMF_STATUS_CLIENT_RESET_BY_PEER  = 10008,
00083        IIIMF_STATUS_INVALID_EVENT_TYPE           = 10009,
00084        IIIMF_STATUS_EVENT_NOT_FORWARDED   = 10010,
00085        IIIMF_STATUS_COMPONENT_DUPLICATED_NAME    = 10011,
00086        IIIMF_STATUS_COMPONENT_FAIL        = 10012,
00087        IIIMF_STATUS_NO_COMPONENT          = 10013,
00088        IIIMF_STATUS_STATIC_EVENT_FLOW            = 10014,
00089        IIIMF_STATUS_FAIL_TO_EVENT_DISPATCH       = 10015,
00090        IIIMF_STATUS_NO_AUX                = 10016,
00091        IIIMF_STATUS_NOT_TRIGGER_KEY              = 10017,
00092        IIIMF_STATUS_COMPONENT_INDIFFERENT = 10018
00093 } IIIMF_status;
00094 
00095 
00096 /*
00097  * The structure iiimf_stream_proc_data shall be defined by the
00098  * implementor of stream procedures.
00099  */
00100 typedef struct iiimf_stream_proc_data     IIIMF_stream_proc_data;
00101 
00102 typedef struct IIIMF_stream IIIMF_stream;
00103 typedef void* IIIMF_stream_private;
00104 
00105 typedef IIIMF_status (* IIIMF_stream_proc_read)(
00106                                    IIIMF_stream_private        private_data,
00107                                    void *                      buf,
00108                                    size_t                      nbyte);
00109 
00110 typedef IIIMF_status (* IIIMF_stream_proc_write)(
00111                                    IIIMF_stream_private        private_data,
00112                                    const void *                buf,
00113                                    size_t                      nbyte);
00114 
00115 typedef IIIMF_status (* IIIMF_message_handler_call_func)(
00116                                           IIIMF_im *    im,
00117                                           IIIMP_message *      message);
00118 
00119 typedef IIIMF_message_handler_status      (* IIIMF_message_handler)(
00120                                           IIIMF_im *    im,
00121                                           IIIMF_ic *    ic,
00122                                           IIIMP_message *      m);
00123 
00124 typedef enum {
00125        IIIMF_MESSAGE_HANDLER_REGISTER_PLACE_HEAD = 0,
00126        IIIMF_MESSAGE_HANDLER_REGISTER_PLACE_TAIL = 1,
00127        IIIMF_MESSAGE_HANDLER_REGISTER_PLACE_BEFORE = 2,
00128        IIIMF_MESSAGE_HANDLER_REGISTER_PLACE_AFTER = 3
00129 } IIIMF_message_handler_register_place;
00130 
00131 
00132 /* miscellaneous function */
00133 
00134 extern void          iiimf_perror(IIIMF_status status, const char * str);
00135 
00136 /* data_s */
00137 
00138 extern IIIMP_data_s *       iiimp_data_s_new(void);
00139 extern IIIMP_data_s *       iiimp_data_s_with_protocol_version_new(int protocol_version);
00140 extern int           iiimp_data_s_get_protocol_version(IIIMP_data_s * data_s);
00141 extern IIIMF_status  iiimp_data_s_limit_protocol_version(IIIMP_data_s * data_s, int version);
00142 extern int           iiimp_data_s_capability(IIIMP_data_s * data_s, int capability);
00143 extern void          iiimp_data_s_delete(IIIMP_data_s * im);
00144 
00145 /* stream */
00146 
00147 extern IIIMF_status  iiimf_create_stream(IIIMF_stream_proc_read       proc_read,
00148                                        IIIMF_stream_proc_write proc_write,
00149                                        IIIMF_stream_private    priv_data,
00150                                        int                     timeout,
00151                                        IIIMF_stream **         stream_ret);
00152 
00153 extern void          iiimf_stream_delete(IIIMF_stream * stream);
00154 
00155 extern IIIMF_status  iiimf_stream_send(IIIMF_stream *   stream,
00156                                      IIIMP_data_s *     data_s,
00157                                      IIIMP_message *    message);
00158 
00159 extern IIIMF_status  iiimf_stream_receive(IIIMF_stream *       stream,
00160                                         IIIMP_data_s *  data_s,
00161                                         IIIMP_message **       message);
00162 
00163 /* stream by socket */
00164 extern IIIMF_status     iiimf_connect_socket_stream(const char *      node,
00165                                               const char *     service,
00166                                               int                 timeout,
00167                                               IIIMF_stream ** stream_ret);
00168 
00169 extern IIIMF_status  iiimf_listen_socket_stream(const char *   node,
00170                                              const char *      service,
00171                                              int                 timeout,
00172                                              IIIMF_stream ** stream_ret);
00173 
00174 extern IIIMF_status  iiimf_accept_socket_stream(IIIMF_stream *  stream,
00175                                              IIIMF_stream ** stream_ret);
00176 
00177 extern IIIMF_status  iiimf_delete_socket_stream(IIIMF_stream *  stream);
00178 
00179 /* stream by TLS */
00180 extern IIIMF_status     iiimf_tls_supported(void);
00181 
00182 extern IIIMF_status     iiimf_connect_tls_stream(const char *  node,
00183                                               const char *     service,
00184                                               int                 timeout,
00185                                               IIIMF_stream ** stream_ret);
00186 
00187 extern IIIMF_status  iiimf_listen_tls_stream(const char *      node,
00188                                              const char *      service,
00189                                              int                 timeout,
00190                                              IIIMF_stream ** stream_ret);
00191 
00192 extern IIIMF_status  iiimf_accept_tls_stream(IIIMF_stream *  stream,
00193                                              IIIMF_stream ** stream_ret);
00194 
00195 extern IIIMF_status  iiimf_delete_tls_stream(IIIMF_stream *  stream);
00196 
00197 extern IIIMF_status     iiimf_tls_set_certificate(IIIMF_stream *  stream,
00198                                                      const char *cert_file,
00199                                                      const char *key_file,
00200                                                      const char *ca_file,
00201                                                      const char *ca_path);
00202 
00203 /* request send and receive */
00204 
00205 extern IIIMF_status  iiimf_request_send(IIIMF_im *             im,
00206                                       IIIMF_ic *        ic,
00207                                       IIIMP_message *   message);
00208 
00209 extern IIIMF_status  iiimf_request_loop(IIIMF_im * im);
00210 
00211 extern IIIMF_status  iiimf_request_reply(IIIMF_im *            im,
00212                                        IIIMF_ic *              ic,
00213                                        IIIMP_message *  message);
00214 
00215 
00216 /* IIIMF_im data */
00217 
00218 extern IIIMF_status  iiimf_im_new(IIIMF_role            role,
00219                                  const char *    server_node,
00220                                  const char *    service,
00221                                  void *          client_data,
00222                                  IIIMF_im **     im_ret);
00223 
00224 extern void          iiimf_im_delete(IIIMF_im * im);
00225 
00226 extern IIIMP_data_s *       iiimf_im_data_s(IIIMF_im * im);
00227 
00228 extern void *        iiimf_im_data_get(IIIMF_im * im);
00229 
00230 extern void *        iiimf_im_data_set(IIIMF_im * im, void * data);
00231 
00232 extern IIIMF_status  iiimf_im_fd_set(IIIMF_im * im, int fd);
00233 
00234 extern IIIMF_status  iiimf_im_timeout_set(IIIMF_im * im, int fd);
00235 
00236 extern IIIMF_status  iiimf_im_start(IIIMF_im * im);
00237 
00238 extern IIIMF_status  iiimf_im_end(IIIMF_im * im);
00239 
00240 extern IIIMF_status  iiimf_im_server_accept(IIIMF_im *  im,
00241                                           void *        client_data,
00242                                           IIIMF_im **   im_ret);
00243 
00244 extern IIIMF_status  iiimf_im_client_type_set(
00245                             IIIMF_im *    im,
00246                             const char *  type);
00247 
00248 extern IIIMF_status  iiimf_im_user_set(
00249                             IIIMF_im *    im,
00250                             const char *  username,
00251                             const char *  password);
00252 
00253 extern int           iiimf_im_id(IIIMF_im * im);
00254 
00255 
00256 /* IIIMF_ic data */
00257 
00258 extern IIIMF_status  iiimf_ic_new(IIIMF_im *            im,
00259                                  void *          client_data,
00260                                  IIIMF_ic **     ic_ret);
00261 
00262 extern void          iiimf_ic_delete(IIIMF_ic * ic);
00263 
00264 extern IIIMF_status  iiimf_ic_id_set(IIIMF_ic *  ic,
00265                                    int           ic_id);
00266 
00267 extern void *        iiimf_ic_data_get(IIIMF_ic * ic);
00268 
00269 extern void *        iiimf_ic_data_set(IIIMF_ic * ic, void * data);
00270 
00271 extern IIIMF_status  iiimf_ic_langauage_set(IIIMF_ic *  ic,
00272                                           const char *  language);
00273 
00274 extern IIIMF_status  iiimf_ic_input_method_set(IIIMF_ic *      ic,
00275                                             const char *       input_method);
00276 
00277 extern IIIMF_status  iiimf_ic_preedit_maximum_length_set(
00278                                    IIIMF_ic *    ic,
00279                                    int           preedit_maximum_length);
00280 
00281 extern int           iiimf_ic_id(IIIMF_ic * ic);
00282 
00283 
00284 /* role data */
00285 
00286 extern const char *  iiimf_role_data_client_user_name(IIIMF_im * im);
00287 
00288 extern const char *  iiimf_role_data_client_home_dir(IIIMF_im * im);
00289 
00290 extern const char *  iiimf_role_data_client_node(IIIMF_im * im);
00291 
00292 extern const char *  iiimf_role_data_client_server_node(IIIMF_im * im);
00293 
00294 extern const char *  iiimf_role_data_client_service(IIIMF_im * im);
00295 
00296 extern IIIMF_status  iiimf_role_data_client_auth_password(
00297                             IIIMF_im *    im,
00298                             char **              password_ret);
00299 
00300 
00301 /* message handler */
00302 
00303 extern IIIMF_status  iiimf_message_handler_register(
00304                             IIIMF_im *                         im,
00305                             int                                opcode,
00306                             IIIMF_message_handler                     handler,
00307                             const char *                       name,
00308                             IIIMF_message_handler_register_place      place,
00309                             const char *                       anchor);
00310 
00311 extern IIIMF_status  iiimf_message_handler_unregister(
00312                             IIIMF_im *           im,
00313                             int                  opcode,
00314                             IIIMF_message_handler       handler);
00315 
00316 extern IIIMF_status  iiimf_message_handler_unregister_name(
00317                             IIIMF_im *           im,
00318                             const char *         name);
00319 
00320 
00321 /* data utility */
00322 extern IIIMF_status  iiimf_data_string_ascii_new(IIIMP_data_s *       data_s,
00323                                               const char *     ptr,
00324                                               IIIMP_string **  ret);
00325 
00326 extern IIIMF_status  iiimf_data_im_connect(IIIMF_im *   im,
00327                                          IIIMP_message **      message_ret);
00328 
00329 extern IIIMF_status  iiimf_data_client_descriptor(
00330                             IIIMF_im *                  im,
00331                             IIIMP_client_descriptor **  data_ret);
00332 
00333 
00334 #ifdef __cplusplus
00335 }
00336 #endif
00337 
00338 #endif /* !IIIMP_H */