Back to index

im-sdk  12.3.91
status.c
Go to the documentation of this file.
00001 /*
00002   status.c
00003 */
00004 
00005 #include <stdlib.h>
00006 #include "iiimcfint.h"
00007 
00008 IIIMF_status
00009 iiimcf_toggle_status(
00010     IIIMCF_context_rec *pc,
00011     int flag
00012 )
00013 {
00014     if (flag && !IIIMCF_IS_ENABLED(pc, IIIMCF_CONTEXT_STATUS_ENABLED)) {
00015        IIIMCF_SET_STATE(pc, IIIMCF_CONTEXT_STATUS_ENABLED);
00016        IIIMCF_SET_STATE_CHANGE(pc, IIIMCF_STATE_STATUS_CHANGED);
00017        return iiimcf_store_simple_event(pc, IIIMCF_EVENT_TYPE_UI_STATUS_START);
00018     } else if (!flag && IIIMCF_IS_ENABLED(pc, IIIMCF_CONTEXT_STATUS_ENABLED)) {
00019        IIIMCF_RESET_STATE(pc, IIIMCF_CONTEXT_STATUS_ENABLED);
00020        IIIMCF_SET_STATE_CHANGE(pc, IIIMCF_STATE_STATUS_CHANGED);
00021        return iiimcf_store_simple_event(pc, IIIMCF_EVENT_TYPE_UI_STATUS_DONE);
00022     }
00023 
00024     return IIIMF_STATUS_SUCCESS;
00025 }
00026 
00027 IIIMF_status
00028 iiimcf_update_status(
00029     IIIMCF_context_rec *pc,
00030     IIIMP_message *pmes
00031 )
00032 {
00033     IIIMF_status st;
00034     IIIMP_contents *pcon = pmes->v.status_draw.status;
00035     ASSERT(pmes->opcode == IM_STATUS_DRAW);
00036 
00037     st = iiimcf_convert_iiimp_contents_to_text(pcon, &pc->status_text);
00038     if (st != IIIMF_STATUS_SUCCESS) return st;
00039 
00040     /* 
00041        Strictly speaking, we should not enable status here.
00042        However, ATOK/X never send IM_STATUS_START, we cannot
00043        help enabling status text by IM_STATUS_DRAW as well...
00044      */
00045     if (!IIIMCF_IS_ENABLED(pc, IIIMCF_CONTEXT_STATUS_ENABLED)) {
00046        st = iiimcf_toggle_status(pc, 1);
00047        if (st != IIIMF_STATUS_SUCCESS) return st;
00048     }
00049 
00050     IIIMCF_SET_STATE_CHANGE(pc, IIIMCF_STATE_STATUS_CHANGED);
00051 
00052     return iiimcf_store_simple_event(pc, IIIMCF_EVENT_TYPE_UI_STATUS_CHANGE);
00053 }
00054 
00055 IIIMF_status
00056 iiimcf_get_status_text(
00057     IIIMCF_context context,
00058     IIIMCF_text *ptext
00059 )
00060 {
00061     IIIMCF_context_rec *pc = (IIIMCF_context_rec*) context;
00062 
00063     if (IIIMCF_IS_IC_INVALID(pc)) return IIIMF_STATUS_IC_INVALID;
00064     if ((!IIIMCF_IS_ENABLED(pc, IIIMCF_CONTEXT_STATUS_ENABLED))
00065        || (!IIIMCF_IS_VALID_TEXT(&pc->status_text)))
00066        return IIIMF_STATUS_NO_STATUS_TEXT;
00067     
00068     *ptext = &pc->status_text;
00069 
00070     return IIIMF_STATUS_SUCCESS;
00071 }
00072 
00073 /* Local Variables: */
00074 /* c-file-style: "iiim-project" */
00075 /* End: */