Back to index

im-sdk  12.3.91
Classes | Defines | Functions
sequence.h File Reference
#include <iiimp-data.h>
#include <iiimp.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  IIIMF_message_pending

Defines

#define IIIMF_MESSAGE_ATTR_ACTIVE_MASK   (0x000FFF00)
#define IIIMF_MESSAGE_ATTR_SEND   (0x00000000)
#define IIIMF_MESSAGE_ATTR_RECEIVE   (0x00000001)
#define IIIMF_MESSAGE_ATTR_ROLE_DIRECTION_MASK   (0x00000001)
#define IIIMF_MESSAGE_ATTR_NONE   (0x00000000)
#define IIIMF_MESSAGE_ATTR_ROLE_CLIENT   (0x00000000)
#define IIIMF_MESSAGE_ATTR_ROLE_SERVER   (0x00000001)
#define IIIMF_MESSAGE_ATTR_ROLE_BOTH   (0x00000002)
#define IIIMF_MESSAGE_ATTR_REQUEST   (0x00000010)
#define IIIMF_MESSAGE_ATTR_REPLY   (0x00000020)
#define IIIMF_MESSAGE_ATTR_NO_REPLY   (0x00000040)
#define IIIMF_MESSAGE_ATTR_IM_ACTIVE   (0x00000100)
#define IIIMF_MESSAGE_ATTR_IM_IM_CONNECT   (0x00000200)
#define IIIMF_MESSAGE_ATTR_IC_ACTIVE   (0x00001000)
#define IIIMF_MESSAGE_ATTR_STATUS_ACTIVE   (0x00002000)
#define IIIMF_MESSAGE_ATTR_PREEDIT_ACTIVE   (0x00004000)
#define IIIMF_MESSAGE_ATTR_LOOKUP_CHOICE_ACTIVE   (0x00008000)
#define IIIMF_MESSAGE_ATTR_AUX_ACTIVE   (0x00010000)

Functions

IIIMF_status iiimf_message_sequence (IIIMF_im *im, IIIMF_ic *ic, IIIMP_message *message, int direction)

Class Documentation

struct IIIMF_message_pending

Definition at line 34 of file sequence.h.

Class Members
int direction
int opcode

Define Documentation

#define IIIMF_MESSAGE_ATTR_ACTIVE_MASK   (0x000FFF00)

Definition at line 14 of file sequence.h.

#define IIIMF_MESSAGE_ATTR_AUX_ACTIVE   (0x00010000)

Definition at line 31 of file sequence.h.

#define IIIMF_MESSAGE_ATTR_IC_ACTIVE   (0x00001000)

Definition at line 27 of file sequence.h.

#define IIIMF_MESSAGE_ATTR_IM_ACTIVE   (0x00000100)

Definition at line 25 of file sequence.h.

#define IIIMF_MESSAGE_ATTR_IM_IM_CONNECT   (0x00000200)

Definition at line 26 of file sequence.h.

#define IIIMF_MESSAGE_ATTR_LOOKUP_CHOICE_ACTIVE   (0x00008000)

Definition at line 30 of file sequence.h.

#define IIIMF_MESSAGE_ATTR_NO_REPLY   (0x00000040)

Definition at line 24 of file sequence.h.

#define IIIMF_MESSAGE_ATTR_NONE   (0x00000000)

Definition at line 18 of file sequence.h.

#define IIIMF_MESSAGE_ATTR_PREEDIT_ACTIVE   (0x00004000)

Definition at line 29 of file sequence.h.

#define IIIMF_MESSAGE_ATTR_RECEIVE   (0x00000001)

Definition at line 16 of file sequence.h.

#define IIIMF_MESSAGE_ATTR_REPLY   (0x00000020)

Definition at line 23 of file sequence.h.

#define IIIMF_MESSAGE_ATTR_REQUEST   (0x00000010)

Definition at line 22 of file sequence.h.

#define IIIMF_MESSAGE_ATTR_ROLE_BOTH   (0x00000002)

Definition at line 21 of file sequence.h.

#define IIIMF_MESSAGE_ATTR_ROLE_CLIENT   (0x00000000)

Definition at line 19 of file sequence.h.

#define IIIMF_MESSAGE_ATTR_ROLE_DIRECTION_MASK   (0x00000001)

Definition at line 17 of file sequence.h.

#define IIIMF_MESSAGE_ATTR_ROLE_SERVER   (0x00000001)

Definition at line 20 of file sequence.h.

#define IIIMF_MESSAGE_ATTR_SEND   (0x00000000)

Definition at line 15 of file sequence.h.

#define IIIMF_MESSAGE_ATTR_STATUS_ACTIVE   (0x00002000)

Definition at line 28 of file sequence.h.


Function Documentation

IIIMF_status iiimf_message_sequence ( IIIMF_im *  im,
IIIMF_ic *  ic,
IIIMP_message message,
int  direction 
)

Definition at line 170 of file sequence.c.

{
    IIIMF_status            status;
    int                            attr_cur;
    int                            attr;
    int                            attr_active;
    int                            opcode_reply;
    IIIMF_message_pending * mp;

    status = IIIMF_STATUS_SUCCESS;

    attr = message_attribute[message->opcode];

    if ((0 == (IIIMF_MESSAGE_ATTR_ROLE_BOTH & attr)) &&
       ((IIIMF_MESSAGE_ATTR_ROLE_DIRECTION_MASK & attr) ==
        (im->role ^ direction))) {
       return IIIMF_STATUS_SEQUENCE_ROLE;
    }

    attr_cur = ((NULL == ic) ? im->state : (im->state | ic->state));

    attr_active = (IIIMF_MESSAGE_ATTR_ACTIVE_MASK & attr);
    if (attr_active != (attr_active & attr_cur)) {
       return IIIMF_STATUS_SEQUENCE_STATE;
    }

    if (0 != (IIIMF_MESSAGE_ATTR_REPLY & attr)) {
       /*
        * REPLY message must follow REQUEST message
        */
       if (im->message_depth <= 0) {
           return IIIMF_STATUS_SEQUENCE_REQUEST;
       }

       im->message_depth -= 1;
       mp = (im->message_pending + im->message_depth);
       opcode_reply = iiimf_opcode_reply_internal(mp->opcode);

       if ((message->opcode != opcode_reply) || (direction == mp->direction)) {
           return IIIMF_STATUS_SEQUENCE_REQUEST;
       }

    } else {
       opcode_reply = iiimf_opcode_reply_internal(message->opcode);
       if (IM_NOP != opcode_reply) {
           if (im->message_depth_maximum <= im->message_depth) {
              return IIIMF_STATUS_SEQUENCE_NEST;
           }
           mp = (im->message_pending + im->message_depth);
           mp->opcode = message->opcode;
           mp->direction = direction;
           im->message_depth += 1;
       }
    }

    switch (message->opcode) {
    case IM_CONNECT:
       im->state |= IIIMF_MESSAGE_ATTR_IM_IM_CONNECT;
       break;

    case IM_CONNECT_REPLY:
       if (-1 == im->im_id) {
           im->im_id = message->im_id;
       } else if (message->im_id != im->im_id) {
           return IIIMF_STATUS_SEQUENCE_STATE;
       }
       im->state &= ~IIIMF_MESSAGE_ATTR_IM_IM_CONNECT;
       im->state |= IIIMF_MESSAGE_ATTR_IM_ACTIVE;
       break;

    case IM_DISCONNECT:
       break;

    case IM_DISCONNECT_REPLY:
       im->state &= IIIMF_MESSAGE_ATTR_NONE;
       break;

    case IM_REGISTER_TRIGGER_KEYS:
       if ((0 != (IIIMF_MESSAGE_ATTR_IM_ACTIVE & im->state)) ||
           (0 == (IIIMF_MESSAGE_ATTR_IM_IM_CONNECT & im->state))) {
           return IIIMF_STATUS_SEQUENCE_STATE;
       }
       im->im_id = message->im_id;
       break;

    case IM_TRIGGER_NOTIFY:
    case IM_TRIGGER_NOTIFY_REPLY:
    case IM_SETIMVALUES:
    case IM_SETIMVALUES_REPLY:
    case IM_GETIMVALUES:
    case IM_GETIMVALUES_REPLY:
    case IM_FORWARD_EVENT:
    case IM_FORWARD_EVENT_REPLY:
    case IM_COMMIT_STRING:
    case IM_FORWARD_EVENT_WITH_OPERATIONS:
    case IM_FORWARD_EVENT_WITH_OPERATIONS_REPLY:
    case IM_CREATEIC:
       break;

    case IM_CREATEIC_REPLY:
       im->state |= IIIMF_MESSAGE_ATTR_IC_ACTIVE;
       ic->ic_id = message->ic_id;
       break;

    case IM_DESTROYIC:
       break;

    case IM_DESTROYIC_REPLY:
       im->state &= ~(IIIMF_MESSAGE_ATTR_IC_ACTIVE |
                     IIIMF_MESSAGE_ATTR_STATUS_ACTIVE |
                     IIIMF_MESSAGE_ATTR_PREEDIT_ACTIVE |
                     IIIMF_MESSAGE_ATTR_LOOKUP_CHOICE_ACTIVE |
                     IIIMF_MESSAGE_ATTR_AUX_ACTIVE);
       break;

    case IM_SETICVALUES:
    case IM_SETICVALUES_REPLY:
    case IM_GETICVALUES:
    case IM_GETICVALUES_REPLY:
    case IM_SETICFOCUS:
    case IM_SETICFOCUS_REPLY:
    case IM_UNSETICFOCUS:
    case IM_UNSETICFOCUS_REPLY:
    case IM_RESETIC:
    case IM_RESETIC_REPLY:
    case IM_PREEDIT_START:
       break;

    case IM_PREEDIT_START_REPLY:
       im->state |= IIIMF_MESSAGE_ATTR_PREEDIT_ACTIVE;
       break;

    case IM_PREEDIT_DRAW:
    case IM_PREEDIT_DRAW_REPLY:
    case IM_PREEDIT_DONE:
       break;

    case IM_PREEDIT_DONE_REPLY:

       im->state &= ~IIIMF_MESSAGE_ATTR_PREEDIT_ACTIVE;
       break;

    case IM_STATUS_START:
       break;

    case IM_STATUS_START_REPLY:
       im->state |= IIIMF_MESSAGE_ATTR_STATUS_ACTIVE;
       break;

    case IM_STATUS_DRAW:
    case IM_STATUS_DRAW_REPLY:
    case IM_STATUS_DONE:
       break;

    case IM_STATUS_DONE_REPLY:
       im->state &= ~IIIMF_MESSAGE_ATTR_STATUS_ACTIVE;
       break;

    case IM_LOOKUP_CHOICE_START:
       break;

    case IM_LOOKUP_CHOICE_START_REPLY:
       im->state |= IIIMF_MESSAGE_ATTR_LOOKUP_CHOICE_ACTIVE;
       break;

    case IM_LOOKUP_CHOICE_DRAW:
    case IM_LOOKUP_CHOICE_DRAW_REPLY:
    case IM_LOOKUP_CHOICE_DONE:
       break;

    case IM_LOOKUP_CHOICE_DONE_REPLY:
       im->state &= ~IIIMF_MESSAGE_ATTR_LOOKUP_CHOICE_ACTIVE;
       break;

    case IM_LOOKUP_CHOICE_PROCESS:
    case IM_LOOKUP_CHOICE_PROCESS_REPLY:
    case IM_AUX_START:
       break;

    case IM_AUX_START_REPLY:
       im->state |= IIIMF_MESSAGE_ATTR_AUX_ACTIVE;
       break;

    case IM_AUX_DRAW:
    case IM_AUX_DRAW_REPLY:
    case IM_AUX_DONE:
       break;

    case IM_AUX_DONE_REPLY:
       im->state &= ~IIIMF_MESSAGE_ATTR_AUX_ACTIVE;
       break;

    case IM_AUX_SETVALUES:
    case IM_AUX_SETVALUES_REPLY:
       break;

    case IM_AUX_GETVALUES:
    case IM_AUX_GETVALUES_REPLY:
       break;
    }

    return status;
}

Here is the caller graph for this function: