Back to index

im-sdk  12.3.91
IIIMP_ICState.hh
Go to the documentation of this file.
00001 #ifndef IIIMP_ICSTATE_HH_
00002 #define IIIMP_ICSTATE_HH_
00003 #include <list>
00004 #include <iiimp.h>
00005 #include "basictype.hh"
00006 #include "ICState.hh"
00007 #include "IIIMP_hotkey.hh"
00008 #include "IIIMP_IMState.hh"
00009 #include "IMConnection.hh"
00010 #include "IMInputContext.hh"
00011 #include "IMSvr.hh"
00012 #include "LEMgr.hh"
00013 
00014 // State transition: N<->R<->W(<->R<->W...)
00015 
00016 class IIIMP_ICState_REQUESTED;
00017 class IIIMP_ICState : public ICState
00018 {
00019     IIIMP_IMState *pims;
00020     LangIMList langimlist;
00021     
00022     virtual bool state_send_available_p()
00023     { return false; }
00024 
00025     virtual void destroy();
00026 
00027   protected:
00028     struct SharedState {
00029        bool conversion_mode;
00030        bool preedit;
00031        bool status;
00032        bool lookup_choice;
00033     };
00034     SharedState *pshared;
00035     IIIMP_hotkey *ihk;
00036     IIIMP_IMState *get_iiimp_imstate()
00037     { return (IIIMP_IMState*) get_imstate(); }
00038 
00039     bool send(
00040        IIIMP_message *pmes,
00041        bool deletep
00042     )
00043     { return get_iiimp_imstate()->send(pmes, deletep); }
00044 
00045     IIIMP_ICState_REQUESTED* start_request();
00046 
00047     IIIMP_ICState(
00048        CARD16BIT ic_id,
00049        IIIMP_IMState* piiims,
00050        ICHandler *pich,
00051        IMLExec_ICState *pimlex
00052     );
00053 
00054   public:
00055     iml_session_t *get_iml_session ();
00056     iml_methods_t *get_iml_methods ();
00057 
00058     IIIMPTrans* get_iiimptrans()
00059     { return get_iiimp_imstate()->get_iiimptrans(); }
00060 
00061     // IIIMP_hotkey_profile* get_hotkey_profile()
00062     // { return get_iiimp_imstate()->get_hotkey_profile(); }
00063 
00064     bool conversion_enable_p()
00065     { return pshared->conversion_mode; }
00066 
00067     IMLangList *get_langlist (iml_desktop_t *);
00068     bool create_langimlist ();
00069     LangIMList *get_langimlist ();
00070 
00071     virtual bool message_proc(
00072        void *message
00073     );
00074 
00075     static IIIMP_ICState* create(
00076        CARD16BIT ic_id,
00077        IIIMP_IMState* piiims,
00078        ICHandler *pich
00079     );
00080 
00081     IMInputContext *get_iminputcontext ()
00082     {
00083        IMInputContext *pimic;
00084        pimic = dynamic_cast<IMInputContext *>(get_ichandler());
00085        return pimic;
00086     }
00087  
00088     IMSvr *get_imsvr ();
00089     LEMgr *get_lemgr ();
00090 
00091     virtual ~IIIMP_ICState();
00092   friend class IIIMP_hotkey;
00093 };
00094 
00095 class IIIMP_ICState_REQUESTED : public IIIMP_ICState
00096 {
00097 
00098     IIIMP_ICState *pprev_state;
00099 
00100     // Restore REQUESTED->initial or prev WAITING state.
00101     bool finish();
00102     // Transit REQUESTED->WAITING state.
00103     bool wait(
00104        int opcode
00105     );
00106     bool wait_aux(
00107        int opcode,
00108        int index,
00109        const u16string& imname
00110     );
00111     virtual bool state_send_available_p()
00112     { return true; }
00113 
00114   protected:
00115     IIIMP_message *preply;
00116 
00117   public:
00118     virtual bool message_proc(
00119        void *message
00120     );
00121 
00122     virtual bool dealing();
00123 
00124   public:
00125     // REQUEST functions.
00126     bool toggle_server_convmode(
00127        bool flag
00128     );
00129     bool set_values(
00130        IIIMP_message *pmes
00131     );
00132     bool toggle_icfocus(
00133        bool flag
00134     );
00135     bool reset();
00136     bool aux_setvalues(
00137        IIIMP_message *pmes
00138     );
00139     bool aux_getvalues(
00140        IIIMP_message *pmes
00141     );
00142     bool forward_event(
00143        IIIMP_message *pmes
00144     );
00145     bool forward_event_with_operations(
00146        IIIMP_message *pmes
00147     );
00148     bool destroyic();
00149 
00150   public:
00151     // IC operation handlers.
00152     virtual int toggle_client_convmode(
00153        bool flag
00154     );
00155     virtual int forward_keyevent(
00156        IMKeyEventStruct *pkeyevent
00157     );
00158     virtual int commit_string(
00159        IMText *pimtext
00160     );
00161     virtual int preedit_start();
00162     virtual int draw_preedit(
00163        IMPreeditDrawCallbackStruct *pimpdraw
00164     );
00165     virtual int preedit_done();
00166     virtual int status_start();
00167     virtual int draw_status(
00168        IMStatusDrawCallbackStruct *pimsdraw
00169     );
00170     virtual int status_done();
00171     virtual int lookup_start(
00172        IMLookupStartCallbackStruct *pimls
00173     );
00174     virtual int draw_lookup(
00175        IMLookupDrawCallbackStruct *pimld
00176     );
00177     virtual int lookup_process(
00178        IMLookupProcessCallbackStruct *pimlp
00179     );
00180     virtual int lookup_done();
00181     virtual int aux_start(
00182        IMAuxStartCallbackStruct *pimauxstart
00183     );
00184     virtual int draw_aux(
00185        IMAuxDrawCallbackStruct *pimauxdraw
00186     );
00187     virtual int aux_done(
00188        IMAuxDoneCallbackStruct *pimauxdone
00189     );
00190 
00191   public:
00192     IIIMP_ICState_REQUESTED(
00193        IIIMP_ICState *pbase
00194     );
00195 };
00196 
00197 class IIIMP_ICState_WAITING : public IIIMP_ICState
00198 {
00199     IIIMP_ICState_REQUESTED *pstreq;
00200     int opcode;
00201     int index;
00202     u16string imname;
00203     u16string filename;
00204     bool wait_aux_message;
00205     bool wait_ns_message;
00206 
00207     void initialize()
00208     { index = -1; }
00209     bool waiting_aux_message_p()
00210     { return (index >= 0); }
00211     void restore_state();
00212     bool match_waiting_message(IIIMP_message *pmes);
00213     virtual bool state_send_available_p()
00214     { return false; }
00215 
00216   public:
00217     virtual bool message_proc(
00218        void *message
00219     );
00220     // waiting for a normal message.
00221     IIIMP_ICState_WAITING(
00222        IIIMP_ICState_REQUESTED *pbase,
00223        int opcode
00224     );
00225     // waiting for a AUX message.
00226     IIIMP_ICState_WAITING(
00227        IIIMP_ICState_REQUESTED *pbase,
00228        int opcode,
00229        int index,
00230        const u16string& imname
00231     );
00232     virtual ~IIIMP_ICState_WAITING()
00233     {
00234        //TODO:we have to remove picsr if suddenly deleted...
00235     }
00236 };
00237 
00238 #endif /* not IIIMP_IMSTATE_HH_ */
00239 
00240 /* Local Variables: */
00241 /* c-file-style: "iiim-project" */
00242 /* End: */