Back to index

im-sdk  12.3.91
Defines | Functions | Variables
sequence.c File Reference
#include <iiimp.h>
#include "input-method.h"
#include "input-context.h"
#include "sequence.h"
#include "opcode-reply.h"

Go to the source code of this file.

Defines

#define ATTR_NONE   IIIMF_MESSAGE_ATTR_NONE
#define ROLE_CLIENT   IIIMF_MESSAGE_ATTR_ROLE_CLIENT
#define ROLE_SERVER   IIIMF_MESSAGE_ATTR_ROLE_SERVER
#define ROLE_BOTH   IIIMF_MESSAGE_ATTR_ROLE_BOTH
#define REQUEST   IIIMF_MESSAGE_ATTR_REQUEST
#define REPLY   IIIMF_MESSAGE_ATTR_REPLY
#define NO_REPLY   IIIMF_MESSAGE_ATTR_NO_REPLY
#define IM_ACTIVE   IIIMF_MESSAGE_ATTR_IM_ACTIVE
#define IC_ACTIVE   IIIMF_MESSAGE_ATTR_IC_ACTIVE
#define STATUS_ACTIVE   IIIMF_MESSAGE_ATTR_STATUS_ACTIVE
#define PREEDIT_ACTIVE   IIIMF_MESSAGE_ATTR_PREEDIT_ACTIVE
#define LUC_ACTIVE   IIIMF_MESSAGE_ATTR_LOOKUP_CHOICE_ACTIVE
#define AUX_ACTIVE   IIIMF_MESSAGE_ATTR_AUX_ACTIVE

Functions

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

Variables

static const int message_attribute [128]

Define Documentation

Definition at line 9 of file sequence.c.

Definition at line 21 of file sequence.c.

Definition at line 17 of file sequence.c.

Definition at line 16 of file sequence.c.

Definition at line 20 of file sequence.c.

Definition at line 15 of file sequence.c.

Definition at line 19 of file sequence.c.

Definition at line 14 of file sequence.c.

Definition at line 13 of file sequence.c.

Definition at line 12 of file sequence.c.

Definition at line 10 of file sequence.c.

Definition at line 11 of file sequence.c.

Definition at line 18 of file sequence.c.


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:


Variable Documentation

const int message_attribute[128] [static]

Definition at line 24 of file sequence.c.