Back to index

im-sdk  12.3.91
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Friends
IIIMP_IMState_Session Class Reference

#include <IIIMP_IMState.hh>

Inheritance diagram for IIIMP_IMState_Session:
Inheritance graph
[legend]
Collaboration diagram for IIIMP_IMState_Session:
Collaboration graph
[legend]

List of all members.

Public Types

typedef pair< u16string, string > UserHostPair
typedef std::multimap
< UserHostPair, IIIMP_IMState * > 
UserIMStateMap
enum  CONTEXT_ID_SPECIAL { INVALID_CONTEXT_ID = -1 }
typedef map< CARD16BIT, ICState * > ICStateMap

Public Member Functions

 IIIMP_IMState_Session (IIIMP_IMState_Identified *pimt)
bool send_trigger_keys ()
bool send_hotkeys (const u16string &curr_input_lang, HotKeyList *hlist)
bool switch_hotkey_profile ()
void create (IIIMP_IMState *pims)
bool send (IIIMP_message *pmes, bool deletep=false)
IIIMPTransget_iiimptrans ()
bool substatep ()
CARD16BIT get_im_id () const
IIIMP_hotkey_profileget_hotkey_profile () const
void set_register_hotkey_flag (bool flag)
bool get_register_hotkey_flag () const
ICStateget_icstate (CARD16BIT ic_id)
bool dispatch (CARD16BIT im_id, CARD16BIT ic_id, void *message)
bool deliver (void *message)

Static Public Member Functions

static IIIMP_IMStateget_imstate_from_desktop (iml_desktop_t *desktop)

Protected Member Functions

void add_icstate (ICState *pics)
void remove_icstate (ICState *pics)
void reset_state ()
void change_state (IMState &newstate)
IMProtocolget_improtocol ()
IMHandlerget_imhandler ()
void set_imhandler (IMHandler *pimh)
int get_current_protocol_version ()
bool check_protocol_version (int version)
IMAcceptget_imaccept ()
bool new_ic_id (CARD16BIT &newid) const
void cleanup_ic ()

Private Member Functions

virtual bool message_proc (void *message)

Friends

int update_supported_langlist_for_le (iml_desktop_t *desktop, IMLEName *lename, IMLocale *locales, int nLocales)
int switch_le_profile (iml_desktop_t *desktop, IMLEName *lename)
class ICState

Detailed Description

Definition at line 115 of file IIIMP_IMState.hh.


Member Typedef Documentation

typedef map<CARD16BIT, ICState*> IMState::ICStateMap [inherited]

Definition at line 17 of file IMState.hh.

typedef pair<u16string, string> IIIMP_IMState::UserHostPair [inherited]

Definition at line 15 of file IIIMP_IMState.hh.

typedef std::multimap<UserHostPair, IIIMP_IMState *> IIIMP_IMState::UserIMStateMap [inherited]

Definition at line 16 of file IIIMP_IMState.hh.


Member Enumeration Documentation

enum IMState::CONTEXT_ID_SPECIAL [inherited]
Enumerator:
INVALID_CONTEXT_ID 

Definition at line 101 of file IMState.hh.

                            {
           INVALID_CONTEXT_ID = -1
    };

Constructor & Destructor Documentation


Member Function Documentation

void IMState::add_icstate ( ICState pics) [protected, inherited]

Definition at line 49 of file IMState.cpp.

{
    CARD16BIT ic_id = pics->get_ic_id();
    ICStateMap& icmap = pshared->icmap;
    ASSERT(icmap.find(ic_id) == icmap.end());
    icmap[ic_id] = pics;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void IMState::change_state ( IMState newstate) [inline, protected, inherited]

Definition at line 42 of file IMState.hh.

    { 
       IMState *p = pbase_state;
       if (p->pproc_state) delete p->pproc_state;
       p->pproc_state = &newstate;
    }

Here is the caller graph for this function:

bool IMState::check_protocol_version ( int  version) [inline, protected, inherited]

Definition at line 61 of file IMState.hh.

    { return (get_current_protocol_version() >= version); }

Here is the call graph for this function:

Here is the caller graph for this function:

void IMState::cleanup_ic ( ) [protected, inherited]

Definition at line 69 of file IMState.cpp.

{
    ICStateMap::iterator it, it2;
    ICStateMap& icmap = pshared->icmap;
    for (it = icmap.begin(); it != icmap.end();) {
       it2 = it;
       it++;
       // this operation may invalidate it2.
       it2->second->destroy();
    }
}

Here is the caller graph for this function:

void IIIMP_IMState::create ( IIIMP_IMState pims) [inherited]

Here is the caller graph for this function:

bool IMState::deliver ( void *  message) [inline, inherited]

Definition at line 109 of file IMState.hh.

    {
       if (pproc_state)
           return pproc_state->message_proc(message);
       return message_proc(message);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

bool IMState::dispatch ( CARD16BIT  im_id,
CARD16BIT  ic_id,
void *  message 
) [inherited]

Definition at line 89 of file IMState.cpp.

{
    if ((im_id != void_im_id) && (im_id != get_im_id())) {
       LOG_ERROR("Invalid im_id(%d).  This must be %d.",
                (int) im_id, (int) get_im_id());
       return false;
    }
    if (ic_id != void_ic_id) {
       ICStateMap::iterator it;

       it = pshared->icmap.find(ic_id);
       if (it != pshared->icmap.end()) {
           it->second->deliver(message);
           return true;
       } else {
           LOG_ERROR("Invalid ic_id(%d).  This ic_id is never issued.",
                    (int) ic_id);
       }
    } else {
       deliver(message);
       return true;
    }
    LOG_ERROR("Invalid im_id and ic_id (%d, %d)",
             (int) im_id, (int) ic_id);
    return false;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int IMState::get_current_protocol_version ( ) [inline, protected, inherited]

Definition at line 55 of file IMState.hh.

Here is the caller graph for this function:

IIIMP_hotkey_profile* IMState::get_hotkey_profile ( ) const [inline, inherited]

Definition at line 83 of file IMState.hh.

    { return pshared->hotkey_profile; }

Here is the caller graph for this function:

ICState* IMState::get_icstate ( CARD16BIT  ic_id) [inline, inherited]

Definition at line 92 of file IMState.hh.

    {
       ICStateMap *pmap = &pshared->icmap;
       ICStateMap::iterator it;
       it = pmap->find(ic_id);
       if (it == pmap->end()) return NULL;
       return it->second;
    }

Here is the caller graph for this function:

IIIMPTrans* IIIMP_IMState::get_iiimptrans ( ) [inline, inherited]

Definition at line 47 of file IIIMP_IMState.hh.

    { return pimt; }

Here is the caller graph for this function:

CARD16BIT IMState::get_im_id ( ) const [inline, inherited]

Definition at line 80 of file IMState.hh.

    { return pshared->im_id; }

Here is the caller graph for this function:

IMAccept * IMState::get_imaccept ( ) [protected, inherited]

Definition at line 43 of file IMState.cpp.

{
    return get_improtocol()->pimaccept;
}

Here is the call graph for this function:

Here is the caller graph for this function:

IMHandler* IMState::get_imhandler ( ) [inline, protected, inherited]

Definition at line 51 of file IMState.hh.

    { return pshared->pimh; }

Here is the caller graph for this function:

IMProtocol* IMState::get_improtocol ( ) [inline, protected, inherited]

Definition at line 49 of file IMState.hh.

    { return pshared->pimp; }

Here is the caller graph for this function:

Definition at line 948 of file IIIMP_IMState.cpp.

{
    UserIMStateMap::iterator it;

    for (it = IIIMP_IMState::user_imstate_map.begin(); it != IIIMP_IMState::user_imstate_map.end(); ++it) {
      const UserHostPair& p = it->first;
      u16string username = p.first;
      string hostname = p.second;
      unsigned int pos_colon;
      string d = string(desktop->display_id);
      pos_colon = d.find(':');
      string display_id = d.substr(pos_colon, d.size());
      string hnameDpy1 = string(desktop->host_name) + string(desktop->display_id);
      string hnameDpy = string(desktop->host_name) + string(display_id);
      if (strcmp(desktop->user_name, username.get_charstr()) == 0 &&
         strcmp(hnameDpy.c_str(), hostname.c_str()) == 0) {
       return it->second;
      }
    }

    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool IMState::get_register_hotkey_flag ( ) const [inline, inherited]

Definition at line 89 of file IMState.hh.

Here is the caller graph for this function:

virtual bool IIIMP_IMState_Session::message_proc ( void *  message) [private, virtual]

Reimplemented from IIIMP_IMState.

bool IMState::new_ic_id ( CARD16BIT &  newid) const [protected, inherited]

Definition at line 121 of file IMState.cpp.

{
    int tid, size;
    ICStateMap *pmap = &pshared->icmap;

    size = pmap->size();
    for (tid = size + 1; ; ) {
       if (pmap->find(tid) == pmap->end()) {
           newid = tid;
           return true;
       }
       tid++;
       if (tid > ic_id_max) {
           tid = 1;
       }
       if (tid == size) {
           LOG_ERROR("Could not allocate new input context.");
           return false;
       }
    }
// not reached
    return false;
}

Here is the caller graph for this function:

void IMState::remove_icstate ( ICState pics) [protected, inherited]

Definition at line 60 of file IMState.cpp.

{
    pshared->icmap.erase(pics->get_ic_id());
}

Here is the call graph for this function:

Here is the caller graph for this function:

void IMState::reset_state ( ) [inline, protected, inherited]

Definition at line 36 of file IMState.hh.

    {
       IMState *p = pbase_state;
       if (p->pproc_state) delete p->pproc_state;
       p->pproc_state = NULL;
    }

Here is the caller graph for this function:

bool IIIMP_IMState::send ( IIIMP_message pmes,
bool  deletep = false 
) [inherited]

Definition at line 64 of file IIIMP_IMState.cpp.

{
    if (!pmes) return false;
    // TODO...
    pimt->send(pmes);
    if (deletep)
       iiimp_message_delete(pimt->get_data_s(), pmes);
    return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool IIIMP_IMState::send_hotkeys ( const u16string curr_input_lang,
HotKeyList *  hlist 
) [inherited]

Definition at line 138 of file IIIMP_IMState.cpp.

{
    IIIMP_data_s *pdata_s = get_iiimptrans()->get_data_s();
    HOTKEY_LIST *hklist = (HOTKEY_LIST *)NULL;
    int i, profile_id, num_profiles, n_hotkeys;
    IMKeySpecList onkeys;
    IMKeySpecList offkeys;
    IIIMP_card16 scope_and_profile_id;
    IMHotkeyProfileStruct *hkps = const_cast<IMHotkeyProfileStruct *>(get_imhandler()->get_hotkey_profiles(&num_profiles));
    IMHotkeyStruct *hks;
    HotKeyList *tmp;

    if (hlist != NULL) {
       for (tmp = hlist; tmp != NULL; tmp = tmp->next) {
           LOG_DEBUG("Registering a trigger key <%s[%d]>%s[%d]", tmp->hotkey->modifiers, tmp->hotkey->modmask, tmp->hotkey->key, tmp->hotkey->keycode);
           onkeys.push_back(IMKeySpec(tmp->hotkey->keycode, 0, tmp->hotkey->modmask, 0));
       }
    } else {
       get_imhandler()->get_triggerkeys(onkeys, offkeys);
       onkeys.push_back(IMKeySpec(IM_VK_KANJI, 0, 0, 0));
       onkeys.push_back(IMKeySpec(IM_VK_KANJI, 0, IM_ALT_MASK, 0));
       if (strstr(curr_input_lang.get_charstr(), (char *)"ja") ||
           strstr(curr_input_lang.get_charstr(), (char *)"ko")) {
           LOG_DEBUG("For ja/ko locale clients, Shift+space is enabled for hotkey\n");
           onkeys.push_back(IMKeySpec(IM_VK_SPACE, 0, IM_SHIFT_MASK, 0));
       }
    }
    hks = get_hotkey_profile()->get_super_hotkeys(onkeys, curr_input_lang.get_charstr(), &n_hotkeys);
    get_hotkey_profile()->init_hotkey_profile_list(hkps, num_profiles);
    get_hotkey_profile()->add_super_hotkey_profiles(curr_input_lang, hks, n_hotkeys);
    num_profiles = get_hotkey_profile()->get_num_profiles();
    for (int i = 0; i < n_hotkeys; i++) {
       free(hks[i].label);
       delete [] hks[i].keys;
    }
    delete [] hks;

    for (i = 0; i < num_profiles; i++) {
       hklist = get_hotkey_profile()->retrive_hotkeys(pdata_s, i, &profile_id);
       scope_and_profile_id = (GLOBAL_HOTKEY << 15) | profile_id;
       if (!send(iiimp_register_hotkeys_new(pdata_s, get_im_id(), scope_and_profile_id, hklist), true))
           return false;
       scope_and_profile_id = 0;
       hklist = (HOTKEY_LIST *)NULL;
    }
    return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool IIIMP_IMState::send_trigger_keys ( ) [inherited]

Definition at line 99 of file IIIMP_IMState.cpp.

{
    int i;
    int profile_id = get_hotkey_profile()->get_default_hotkey_profile_id();
    const IMKeySpecList *keylist = get_hotkey_profile()->retrieve_trigger_keys(profile_id);

    if (keylist != NULL) {
       IIIMP_keyevent_list *pion;
       IIIMP_keyevent_list *pioff;
       IIIMP_keyevent *keys = new IIIMP_keyevent[keylist->size()];
       IIIMP_data_s *pdata_s = get_iiimptrans()->get_data_s();
       IMKeySpecList::const_iterator it;

       for (i = 0, it = keylist->begin(); it != keylist->end(), i < keylist->size(); it++, i++) {
           keys[i].keycode = it->get_keycode();
           keys[i].keychar = it->get_keychar();
           keys[i].modifier = it->get_modifier();
           keys[i].time_stamp = it->get_timestamp();
       }
       pion = iiimp_keyevent_list_new(pdata_s, i, keys);
       pioff = iiimp_keyevent_list_new(pdata_s, i, keys);
       delete[] keys;
       if (!pion || !pioff) {
           if (pion)
              iiimp_keyevent_list_delete(pdata_s, pion);
           if (pioff)
              iiimp_keyevent_list_delete(pdata_s, pioff);
           return false;
       }
       if (!send(iiimp_register_trigger_keys_new(pdata_s, get_im_id(), pion, pioff), true))
           return false;

       return true;
    }

    return false;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void IMState::set_imhandler ( IMHandler pimh) [inline, protected, inherited]

Definition at line 53 of file IMState.hh.

    { pshared->pimh = pimh; }

Here is the caller graph for this function:

void IMState::set_register_hotkey_flag ( bool  flag) [inline, inherited]

Definition at line 86 of file IMState.hh.

Here is the caller graph for this function:

bool IMState::substatep ( ) [inline, inherited]

Definition at line 77 of file IMState.hh.

    { return (pbase_state != this); }

Here is the caller graph for this function:

Definition at line 190 of file IIIMP_IMState.cpp.

{
    IIIMP_data_s *pdata_s = get_iiimptrans()->get_data_s();
    IIIMP_card16 scope_and_profile_id;
    IIIMP_card16 profile_id = get_hotkey_profile()->get_default_hotkey_profile_id();
    LOG_DEBUG("Switching Hotkey Profile to default [%d]\n", profile_id);
    scope_and_profile_id = (GLOBAL_HOTKEY << 15) | profile_id;
    if (!send(iiimp_select_hotkey_profile_new(pdata_s, get_im_id(), scope_and_profile_id), true))
       return false;
    return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class ICState [friend, inherited]

Definition at line 142 of file IMState.hh.

int switch_le_profile ( iml_desktop_t desktop,
IMLEName lename 
) [friend, inherited]
int update_supported_langlist_for_le ( iml_desktop_t desktop,
IMLEName lename,
IMLocale locales,
int  nLocales 
) [friend, inherited]

Definition at line 1124 of file IIIMP_IMState.cpp.

{
    IIIMP_IMState *xims = IIIMP_IMState::get_imstate_from_desktop(desktop);

    if (xims == NULL)
       return false;
    // Update LEMgr's IMDescriptorList

    xims->get_imhandler()->update_imdesclist(lename, locales, nLocales);

    // TODO!! Send the updated IMDescriptorList to Client using IM_SETIMVALUES
    // IIIMP_IMState_Identified *xims_id = new IIIMP_IMState_Identified(xims, xims->get_imhandler(), xims->get_current_protocol_version());
    // xims_id->set_data_to_client();
    // receive_message = xims->get_iiimptrans()->receive();

    return true;
}

The documentation for this class was generated from the following file: