Back to index

im-sdk  12.3.91
request-reply.c
Go to the documentation of this file.
00001 #include <stdlib.h>
00002 #if defined(lint) && defined(HAVE_NOTE_H)
00003 #include <note.h>
00004 #endif /* lint && HAVE_NOTE_H */
00005 
00006 #include <iiimp-data.h>
00007 #include <iiimp.h>
00008 
00009 #include "request-reply.h"
00010 #include "input-method.h"
00011 #include "input-context.h"
00012 #include "stream.h"
00013 #include "opcode-reply.h"
00014 #include "sequence.h"
00015 
00016 
00017 static uchar_t *
00018 message_reply_pack_nop(
00019     IIIMF_im *              im,
00020     IIIMF_ic *              ic,
00021     int                     opcode,
00022     IIIMP_message *  m,
00023     size_t *         nbyte)
00024 {
00025 #if defined(lint) && defined(HAVE_NOTE_H)
00026     NOTE(ARGUNUSED(im, ic, opcode, m, nbyte))
00027 #endif /* lint && HAVE_NOTE_H */
00028     return NULL;
00029 }
00030 
00031 
00032 static uchar_t *
00033 message_simple_im_reply_pack(
00034     IIIMF_im *              im,
00035     IIIMF_ic *              ic,
00036     int                     opcode,
00037     IIIMP_message *  m,
00038     size_t *         nbyte)
00039 {
00040 #if defined(lint) && defined(HAVE_NOTE_H)
00041     NOTE(ARGUNUSED(ic, m))
00042 #endif /* lint && HAVE_NOTE_H */
00043     return iiimp_simple_pack(im->data_s, opcode, im->im_id, 0, nbyte);
00044 }
00045 
00046 
00047 static uchar_t *
00048 message_simple_ic_reply_pack(
00049     IIIMF_im *              im,
00050     IIIMF_ic *              ic,
00051     int                     opcode,
00052     IIIMP_message *  m,
00053     size_t *         nbyte)
00054 {
00055 #if defined(lint) && defined(HAVE_NOTE_H)
00056     NOTE(ARGUNUSED(m))
00057 #endif /* lint && HAVE_NOTE_H */
00058     return iiimp_simple_pack(im->data_s, opcode, im->im_id, ic->ic_id, nbyte);
00059 }
00060 
00061 
00062 static uchar_t *
00063 message_im_connect_reply_pack(
00064     IIIMF_im *              im,
00065     IIIMF_ic *              ic,
00066     int                     opcode,
00067     IIIMP_message *  m,
00068     size_t *         nbyte)
00069 {
00070 #if defined(lint) && defined(HAVE_NOTE_H)
00071     NOTE(ARGUNUSED(ic, opcode, m))
00072 #endif /* lint && HAVE_NOTE_H */
00073     return iiimp_connect_reply_pack(im->data_s, im->im_id, im->language_list,
00074                                 nbyte);
00075 }
00076 
00077 
00078 static uchar_t *
00079 message_im_getimvalues_reply_pack(
00080     IIIMF_im *              im,
00081     IIIMF_ic *              ic,
00082     int                     opcode,
00083     IIIMP_message *  m,
00084     size_t *         nbyte)
00085 {
00086 #if defined(lint) && defined(HAVE_NOTE_H)
00087     NOTE(ARGUNUSED(ic, opcode, m))
00088 #endif /* lint && HAVE_NOTE_H */
00089     return iiimp_getimvalues_reply_pack(im->data_s, im->im_id, NULL, nbyte);
00090 }
00091 
00092 
00093 static uchar_t *
00094 message_im_forward_event_with_operations_reply_pack(
00095     IIIMF_im *              im,
00096     IIIMF_ic *              ic,
00097     int                     opcode,
00098     IIIMP_message *  m,
00099     size_t *         nbyte)
00100 {
00101 #if defined(lint) && defined(HAVE_NOTE_H)
00102     NOTE(ARGUNUSED(opcode, m))
00103 #endif /* lint && HAVE_NOTE_H */
00104     return iiimp_forward_event_with_operations_reply_pack(im->data_s, im->im_id,
00105                                                    ic->ic_id, NULL,
00106                                                    nbyte);
00107 }
00108 
00109 
00110 static uchar_t *
00111 message_im_geticvalues_reply_pack(
00112     IIIMF_im *              im,
00113     IIIMF_ic *              ic,
00114     int                     opcode,
00115     IIIMP_message *  m,
00116     size_t *         nbyte)
00117 {
00118 #if defined(lint) && defined(HAVE_NOTE_H)
00119     NOTE(ARGUNUSED(opcode, m))
00120 #endif /* lint && HAVE_NOTE_H */
00121     return iiimp_geticvalues_reply_pack(im->data_s, im->im_id, ic->ic_id, NULL,
00122                                    nbyte);
00123 }
00124 
00125 
00126 static uchar_t *
00127 message_preedit_start_reply_pack(
00128     IIIMF_im *              im,
00129     IIIMF_ic *              ic,
00130     int                     opcode,
00131     IIIMP_message *  m,
00132     size_t *         nbyte)
00133 {
00134 #if defined(lint) && defined(HAVE_NOTE_H)
00135     NOTE(ARGUNUSED(opcode, m))
00136 #endif /* lint && HAVE_NOTE_H */
00137     return iiimp_preedit_start_reply_pack(im->data_s, im->im_id, ic->ic_id,
00138                                      ic->preedit_maximum_length, nbyte);
00139 }
00140 
00141 
00142 static uchar_t *
00143 message_aux_simple_reply_pack(
00144     IIIMF_im *              im,
00145     IIIMF_ic *              ic,
00146     int                     opcode,
00147     IIIMP_message *  m,
00148     size_t *         nbyte)
00149 {
00150     return iiimp_aux_simple_pack(im->data_s, opcode, im->im_id, ic->ic_id,
00151                              m->v.aux_simple.class_index,
00152                              m->v.aux_simple.input_method_name, nbyte);
00153 }
00154 
00155 static uchar_t *
00156 message_aux_value_reply_pack(
00157     IIIMF_im *              im,
00158     IIIMF_ic *              ic,
00159     int                     opcode,
00160     IIIMP_message *  m,
00161     size_t *         nbyte)
00162 {
00163     return iiimp_aux_value_pack(im->data_s, opcode, im->im_id, ic->ic_id,
00164                             m->v.aux_value.class_index,
00165                             m->v.aux_value.input_method_name,
00166                             m->v.aux_value.integer_value,
00167                             m->v.aux_value.string_value,
00168                             nbyte);
00169 }
00170 
00171 typedef uchar_t *    (* IIIMP_message_reply_pack_func)(
00172                             IIIMF_im *    im,
00173                             IIIMF_ic *    ic,
00174                             int           opcode,
00175                             IIIMP_message *      m,
00176                             size_t *      nbyte);
00177 
00178 
00179 static IIIMP_message_reply_pack_func message_reply_pack_func[] = {
00180        message_reply_pack_nop,            /* 0 */
00181 
00182        message_reply_pack_nop,            /* IM_CONNECT */
00183        message_im_connect_reply_pack,     /* IM_CONNECT_REPLY */
00184        message_reply_pack_nop,            /* IM_DISCONNECT */
00185        message_simple_im_reply_pack,      /* IM_DISCONNECT_REPLY */
00186        message_reply_pack_nop,            /* IM_REGISTER_TRIGGER_KEYS */
00187        message_reply_pack_nop,            /* IM_TRIGGER_NOTIFY */
00188        message_simple_ic_reply_pack,      /* IM_TRIGGER_NOTIFY_REPLY */
00189        message_reply_pack_nop,            /* IM_SETIMVALUES */
00190        message_simple_im_reply_pack,      /* IM_SETIMVALUES_REPLY */
00191        message_reply_pack_nop,            /* IM_GETIMVALUES */
00192        message_im_getimvalues_reply_pack,
00193                                    /* IM_GETIMVALUES_REPLY */
00194 
00195        message_reply_pack_nop,            /* IM_FORWARD_EVENT */
00196        message_simple_ic_reply_pack,      /* IM_FORWARD_EVENT_REPLY */
00197        message_reply_pack_nop,            /* IM_COMMIT_STRING */
00198        message_reply_pack_nop,            /* IM_FORWARD_EVENT_WITH_OPERATIONS */
00199        message_im_forward_event_with_operations_reply_pack,
00200                               /* IM_FORWARD_EVENT_WITH_OPERATIONS_REPLY */
00201 
00202        message_reply_pack_nop,            /* 17 */
00203        message_reply_pack_nop,            /* 18 */
00204        message_reply_pack_nop,            /* 19 */
00205 
00206        message_reply_pack_nop,            /* IM_CREATEIC */
00207        message_simple_im_reply_pack,      /* IM_CREATEIC_REPLY */
00208        message_reply_pack_nop,            /* IM_DESTROYIC */
00209        message_simple_ic_reply_pack,      /* IM_DESTROYIC_REPLY */
00210        message_reply_pack_nop,            /* IM_SETICVALUES */
00211        message_simple_ic_reply_pack,      /* IM_SETICVALUES_REPLY */
00212        message_reply_pack_nop,            /* IM_GETICVALUES */
00213        message_im_geticvalues_reply_pack,
00214                                    /* IM_GETICVALUES_REPLY */
00215        message_reply_pack_nop,            /* IM_SETICFOCUS */
00216        message_simple_ic_reply_pack,      /* IM_SETICFOCUS_REPLY */
00217        message_reply_pack_nop,            /* IM_UNSETICFOCUS */
00218        message_simple_ic_reply_pack,      /* IM_UNSETICFOCUS_REPLY */
00219        message_reply_pack_nop,            /* IM_RESETIC */
00220        message_simple_ic_reply_pack,      /* IM_RESETIC_REPLY */
00221 
00222        message_reply_pack_nop,            /* 34 */
00223        message_reply_pack_nop,            /* 35 */
00224        message_reply_pack_nop,            /* 36 */
00225        message_reply_pack_nop,            /* 37 */
00226        message_reply_pack_nop,            /* 38 */
00227        message_reply_pack_nop,            /* 39 */
00228 
00229        message_reply_pack_nop,            /* IM_PREEDIT_START */
00230        message_preedit_start_reply_pack,
00231                                    /* IM_PREEDIT_START_REPLY */
00232        message_reply_pack_nop,            /* IM_PREEDIT_DRAW */
00233        message_simple_ic_reply_pack,      /* IM_PREEDIT_DRAW_REPLY */
00234        message_reply_pack_nop,            /* 44 */
00235        message_reply_pack_nop,            /* 45 */
00236        message_reply_pack_nop,            /* IM_PREEDIT_DONE */
00237        message_simple_ic_reply_pack,      /* IM_PREEDIT_DONE_REPLY */
00238 
00239        message_reply_pack_nop,            /* 48 */
00240        message_reply_pack_nop,            /* 49 */
00241 
00242        message_reply_pack_nop,            /* IM_STATUS_START */
00243        message_simple_ic_reply_pack,      /* IM_STATUS_START_REPLY */
00244        message_reply_pack_nop,            /* IM_STATUS_DRAW */
00245        message_simple_ic_reply_pack,      /* IM_STATUS_DRAW_REPLY */
00246        message_reply_pack_nop,            /* IM_STATUS_DONE */
00247        message_simple_ic_reply_pack,      /* IM_STATUS_DONE_REPLY */
00248 
00249        message_reply_pack_nop,            /* 56 */
00250        message_reply_pack_nop,            /* 57 */
00251        message_reply_pack_nop,            /* 58 */
00252        message_reply_pack_nop,            /* 59 */
00253        message_reply_pack_nop,            /* 60 */
00254        message_reply_pack_nop,            /* 61 */
00255        message_reply_pack_nop,            /* 62 */
00256        message_reply_pack_nop,            /* 63 */
00257        message_reply_pack_nop,            /* 64 */
00258        message_reply_pack_nop,            /* 65 */
00259        message_reply_pack_nop,            /* 66 */
00260        message_reply_pack_nop,            /* 67 */
00261        message_reply_pack_nop,            /* 68 */
00262        message_reply_pack_nop,            /* 69 */
00263 
00264        message_reply_pack_nop,            /* IM_LOOKUP_CHOICE_START */
00265        message_simple_ic_reply_pack,      /* IM_LOOKUP_CHOICE_START_REPLY */
00266        message_reply_pack_nop,            /* IM_LOOKUP_CHOICE_DRAW */
00267        message_simple_ic_reply_pack,      /* IM_LOOKUP_CHOICE_DRAW_REPLY */
00268        message_reply_pack_nop,            /* IM_LOOKUP_CHOICE_DONE */
00269        message_simple_ic_reply_pack,      /* IM_LOOKUP_CHOICE_DONE_REPLY */
00270        message_reply_pack_nop,            /* IM_LOOKUP_CHOICE_PROCESS */
00271        message_simple_ic_reply_pack,      /* IM_LOOKUP_CHOICE_PROCESS_REPLY */
00272 
00273        message_reply_pack_nop,            /* 78 */
00274        message_reply_pack_nop,            /* 79 */
00275        message_reply_pack_nop,            /* 80 */
00276        message_reply_pack_nop,            /* 81 */
00277        message_reply_pack_nop,            /* 82 */
00278        message_reply_pack_nop,            /* 83 */
00279        message_reply_pack_nop,            /* 84 */
00280        message_reply_pack_nop,            /* 85 */
00281        message_reply_pack_nop,            /* 86 */
00282        message_reply_pack_nop,            /* 87 */
00283        message_reply_pack_nop,            /* 88 */
00284        message_reply_pack_nop,            /* 89 */
00285 
00286        message_reply_pack_nop,            /* IM_AUX_START */
00287        message_aux_simple_reply_pack,     /* IM_AUX_START_REPLY */
00288        message_reply_pack_nop,            /* IM_AUX_DRAW */
00289        message_aux_simple_reply_pack,     /* IM_AUX_DRAW_REPLY */
00290        message_reply_pack_nop,            /* IM_AUX_DONE */
00291        message_aux_simple_reply_pack,     /* IM_AUX_DONE_REPLY */
00292        message_reply_pack_nop,            /* IM_AUX_SETVALUES */
00293        message_aux_simple_reply_pack,     /* IM_AUX_SETVALUES_REPLY */
00294        message_reply_pack_nop,            /* IM_AUX_GETVALUES */
00295        message_aux_value_reply_pack,      /* IM_AUX_GETVALUES_REPLY */
00296 
00297        message_reply_pack_nop,            /* 100 */
00298        message_reply_pack_nop,            /* 101 */
00299        message_reply_pack_nop,            /* 102 */
00300        message_reply_pack_nop,            /* 103 */
00301        message_reply_pack_nop,            /* 104 */
00302        message_reply_pack_nop,            /* 105 */
00303        message_reply_pack_nop,            /* 106 */
00304        message_reply_pack_nop,            /* 107 */
00305        message_reply_pack_nop,            /* 108 */
00306        message_reply_pack_nop,            /* 109 */
00307        message_reply_pack_nop,            /* 110 */
00308        message_reply_pack_nop,            /* 111 */
00309        message_reply_pack_nop,            /* 112 */
00310        message_reply_pack_nop,            /* 113 */
00311        message_reply_pack_nop,            /* 114 */
00312        message_reply_pack_nop,            /* 115 */
00313        message_reply_pack_nop,            /* 116 */
00314        message_reply_pack_nop,            /* 117 */
00315        message_reply_pack_nop,            /* 118 */
00316        message_reply_pack_nop,            /* 119 */
00317        message_reply_pack_nop,            /* 120 */
00318        message_reply_pack_nop,            /* 121 */
00319        message_reply_pack_nop,            /* 122 */
00320        message_reply_pack_nop,            /* 123 */
00321        message_reply_pack_nop,            /* 124 */
00322        message_reply_pack_nop,            /* 125 */
00323        message_reply_pack_nop,            /* 126 */
00324        message_reply_pack_nop             /* 127 */
00325 };
00326 
00327 
00328 IIIMF_status
00329 iiimf_request_reply(
00330     IIIMF_im *              im,
00331     IIIMF_ic *              ic,
00332     IIIMP_message *  message_original)
00333 {
00334     IIIMF_status     status;
00335     uchar_t *        message;
00336     size_t           nbyte;
00337     int                     opcode;
00338     IIIMP_message    message_dummy;
00339 
00340     opcode = iiimf_opcode_reply_internal(message_original->opcode);
00341     if (IM_NOP == opcode) return IIIMF_STATUS_SUCCESS;
00342 
00343     message_dummy.opcode = opcode;
00344     message_dummy.length = 8;
00345     message_dummy.im_id = message_original->im_id;
00346     message_dummy.ic_id = message_original->ic_id;
00347     status = iiimf_message_sequence(im, ic, &message_dummy,
00348                                 IIIMF_MESSAGE_ATTR_SEND);
00349     if (IIIMF_STATUS_SUCCESS != status) {
00350        if (IIIMF_STATUS_SEQUENCE_REQUEST == status) {
00351            return IIIMF_STATUS_SUCCESS;
00352        } else {
00353            return status;
00354        }
00355     }
00356 
00357     message = message_reply_pack_func[opcode](im, ic, opcode, message_original,
00358                                          &nbyte);
00359     if (NULL == message) return IIIMF_STATUS_FAIL;
00360 
00361     status = im->stream->proc_write(im->stream->private_data, message, nbyte);
00362 
00363     free(message);
00364 
00365     return status;
00366 }
00367 
00368 
00369 /* Local Variables: */
00370 /* c-file-style: "iiim-project" */
00371 /* End: */