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_Identified Class Reference

#include <IIIMP_IMState.hh>

Inheritance diagram for IIIMP_IMState_Identified:
Inheritance graph
[legend]
Collaboration diagram for IIIMP_IMState_Identified:
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_Identified (IIIMP_IMState *pimt, IMHandler *pimh, int proto_version)
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

void exit_from_identified ()
IIIMP_imattribute * create_object_descriptors ()
IIIMP_languagecreate_language_list (const IMLangList *plangs)
IIIMP_imeinfocreate_imeinfo_list (const IMImeInfoList *pimeinfos)
IIIMP_imattribute * create_input_method_descriptors ()
bool set_data_to_client ()
IIIMP_imattribute * get_imattribute (IIIMP_card16 id)
virtual bool message_proc (void *message)

Friends

int update_supported_langlist_for_le (IMLEName *lename, IMLocale *locales, int nLocales)
int switch_le_profile (IMLEName *lename)
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 76 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

IIIMP_IMState_Identified::IIIMP_IMState_Identified ( IIIMP_IMState pimt,
IMHandler pimh,
int  proto_version 
)

Definition at line 938 of file IIIMP_IMState.cpp.

  : IIIMP_IMState(*pimt, proto_version)
{
    set_imhandler(pimh);
}

Here is the call graph for this function:


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:

Definition at line 445 of file IIIMP_IMState.cpp.

{
    IIIMP_imeinfo *pil = NULL, *pil2, *pilh;
    IIIMP_string *pime_id, *pimename, *pversion, *pdescription, *pauthor, *pcopyright, *preserved1, *preserved2;
    u16string ime_id;
    IIIMP_data_s *pdata_s = get_iiimptrans()->get_data_s();
    IMImeInfoList::const_iterator it;
    int i = 0;

    if (!pimeinfos) return NULL;

    pilh = NULL;
    for (it = pimeinfos->begin(); it != pimeinfos->end(); it++) {

       ime_id = it->get_ime_id ();
        pime_id = iiimp_string_new(pdata_s,
                                ime_id.size(),
                                ime_id.data());
       if (!pime_id) goto memory_error;

        pimename = iiimp_string_new(pdata_s,
                                it->get_imename().size(),
                                it->get_imename().data());
       if (!pimename) goto memory_error;

        pversion = iiimp_string_new(pdata_s,
                                it->get_version().size(),
                                it->get_version().data());
       if (!pversion) goto memory_error;

        pdescription = iiimp_string_new(pdata_s,
                                it->get_description().size(),
                                it->get_description().data());
       if (!pdescription) goto memory_error;

        pauthor = iiimp_string_new(pdata_s,
                                it->get_author().size(),
                                it->get_author().data());
       if (!pauthor) goto memory_error;

        pcopyright = iiimp_string_new(pdata_s,
                                it->get_copyright().size(),
                                it->get_copyright().data());
       if (!pcopyright) goto memory_error;

        preserved1 = iiimp_string_new(pdata_s,
                                it->get_reserved1().size(),
                                it->get_reserved1().data());
       if (!preserved1) goto memory_error;

        preserved2 = iiimp_string_new(pdata_s,
                                it->get_reserved2().size(),
                                it->get_reserved2().data());
       if (!preserved2) goto memory_error;

        pil2 = iiimp_imeinfo_new(pdata_s, 
                            (int)it->get_enable(), 
                            pime_id,
                            pimename, 
                            pversion, 
                            pdescription, 
                            pauthor,
                            pcopyright, 
                            preserved1, 
                            preserved2);

        if (!pil2) {
            goto memory_error;
        }

        if (!pilh) {
            pilh = pil2;
        } else {
            pil->next = pil2;
        }
        pil = pil2;
    }

    return pilh;

memory_error:
    if (pilh) iiimp_imeinfo_delete(pdata_s, pilh);
    // TODO!! we have to throw an exception.
    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 535 of file IIIMP_IMState.cpp.

{
    const IMDescriptorList *pimdlist = get_imhandler()->get_imdesclist(NULL);

    if (!pimdlist) return NULL;

    IIIMP_imattribute *pima = NULL;
    IIIMP_data_s *pdata_s = get_iiimptrans()->get_data_s();
    IIIMP_string *pidname, *pihrn, *pidomain;
    IIIMP_inputmethod_descriptor *pimdh, *pimd = NULL, *pimd2;
    IIIMP_language *pil;
    IIIMP_imeinfo *imeinfo;

    IMDescriptorList::const_iterator it;

    pimdh = NULL;

    for (it = pimdlist->begin(); it != pimdlist->end(); it++) {
       pidname = pihrn = NULL;

       pidname = iiimp_string_new(pdata_s,
                               it->get_imname().size(),
                               it->get_imname().data());

       pihrn = iiimp_string_new(pdata_s,
                             it->get_hrn().size(),
                             it->get_hrn().data());

       /* Currently adopt an empty string
          as reverse domain name. */
       pidomain = iiimp_string_new(pdata_s, 0, NULL);

       if (!pidname || !pihrn || !pidomain) {
           goto memory_error;
       }

       pil = create_language_list(it->get_languages());
       imeinfo = create_imeinfo_list (it->get_imeinfos());
       pimd2 = iiimp_inputmethod_descriptor2_new(pdata_s,
                                            it->get_attribid(),
                                            pidname,
                                            pihrn,
                                            pil,
                                            pidomain,
                                            imeinfo);

       if (!pimd2) goto memory_error;

       if (!pimdh) {
           pimdh = pimd2;
       } else {
           pimd->next = pimd2;
       }
       pimd = pimd2;
    }
    if (!pimdh) return NULL;

    pima = iiimp_imattribute_inputmethod_descriptor_new(pdata_s,
                                                 IIIMP_IMATTRIBUTE_INPUT_METHOD_LIST,
                                                 0, pimdh);
    if (!pima) goto memory_error;

    return pima;

memory_error:
    if (pima) {
       iiimp_imattribute_delete(pdata_s, pima);
    } else {
       if (pidname) iiimp_string_delete(pdata_s, pidname);
       if (pihrn) iiimp_string_delete(pdata_s, pihrn);
       if (pidomain) iiimp_string_delete(pdata_s, pidomain);
       for (pimd = pimdh; pimd; pimd = pimd->next) {
           iiimp_inputmethod_descriptor_delete(pdata_s, pimd);
       }
    }
    // TODO!! we have to throw an exception.
    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 389 of file IIIMP_IMState.cpp.

{
    IIIMP_language *pil = NULL, *pil2, *pilh;
    IIIMP_string *pihrn, *piid;
    u16string langid;
    IIIMP_data_s *pdata_s = get_iiimptrans()->get_data_s();
    IMLangList::const_iterator it;

    if (!plangs) return NULL;

    pilh = NULL;
    for (it = plangs->begin(); it != plangs->end(); it++) {
       pihrn = piid = NULL;

       pihrn = iiimp_string_new(pdata_s,
                             it->get_hrn().size(),
                             it->get_hrn().data());
       if (!pihrn) goto memory_error;

       langid = it->get_id();
       piid = iiimp_string_new(pdata_s,
                            langid.size(),
                            langid.data());
       if (!piid) {
           iiimp_string_delete(pdata_s, pihrn);
           goto memory_error;
       }

       pil2 = iiimp_language_new(pdata_s, pihrn, piid);
       
       if (!pil2) {
           iiimp_string_delete(pdata_s, pihrn);
           iiimp_string_delete(pdata_s, piid);
           goto memory_error;
       }

       if (!pilh) {
           pilh = pil2;
       } else {
           pil->next = pil2;
       }
       pil = pil2;
    }

    return pilh;

memory_error:
    if (pilh) iiimp_language_delete(pdata_s, pilh);
    // TODO!! we have to throw an exception.
    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

IIIMP_imattribute * IIIMP_IMState_Identified::create_object_descriptors ( ) [private]

Definition at line 308 of file IIIMP_IMState.cpp.

{
    const IMObjectWithDescList *podlist = get_imhandler()->get_imobjectdesclist();

    if (!podlist) return NULL;

    IIIMP_imattribute *pima = NULL;
    IIIMP_data_s *pdata_s = get_iiimptrans()->get_data_s();
    IIIMP_string *pidomain = NULL, *pihrn = NULL, *pisig = NULL, *piscope = NULL;
    IIIMP_object_descriptor *piodh, *piod = NULL, *piod2;
    IIIMP_card16 predefined;

    IMObjectWithDescList::const_iterator it;
    IMObjectWithDesc *pod;

    piodh = NULL;
    for (it = podlist->begin(); it != podlist->end(); it++) {
       pod = *it;
       if (pod->get_category() < 0) continue;
       predefined = convert_IMObject_type_to_iiimp_predefined_attribid(pod->get_type());

       pidomain = pihrn = pisig = piscope = NULL;

       pidomain = iiimp_string_new(pdata_s,
                                pod->get_domain().size(),
                                pod->get_domain().data());
       pihrn = iiimp_string_new(pdata_s,
                             pod->get_hrn().size(),
                             pod->get_hrn().data());
       pisig = iiimp_string_new(pdata_s,
                             pod->get_signature().size(),
                             pod->get_signature().data());
       piscope = iiimp_string_new(pdata_s,
                               pod->get_scope().size(),
                               pod->get_scope().data());

       if (!pidomain || !pihrn || !pisig || !piscope) {
           goto memory_error;
       }
       piod2 = iiimp_object_descriptor_new(pdata_s,
                                       pod->get_category(),
                                       pod->get_object_size(),
                                       predefined, pod->get_attribid(),
                                       pidomain, pihrn, pisig, piscope);
       if (!piod2) goto memory_error;

       if (!piodh) {
           piodh = piod2;
       } else {
           piod->next = piod2;
       }
       piod = piod2;
    }

    if (!piodh) return NULL;

    pima = iiimp_imattribute_object_descriptor_new(pdata_s,
                                             IIIMP_IMATTRIBUTE_OBJECT_DESCRIPTOR_LIST,
                                             0, piodh);
    if (!pima) goto memory_error;

    return pima;

memory_error:
    if (pima) {
       iiimp_imattribute_delete(pdata_s, pima);
    } else {
       if (pidomain) iiimp_string_delete(pdata_s, pidomain);
       if (pihrn) iiimp_string_delete(pdata_s, pihrn);
       if (pisig) iiimp_string_delete(pdata_s, pisig);
       if (piscope) iiimp_string_delete(pdata_s, piscope);
       for (piod = piodh; piod; piod = piod->next) {
           iiimp_object_descriptor_delete(pdata_s, piod);
       }
    }
    // TODO!! we have to throw an exception.
    return NULL;
}

Here is the call graph for this function:

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:

IIIMP_imattribute * IIIMP_IMState_Identified::get_imattribute ( IIIMP_card16  id) [private]

Definition at line 663 of file IIIMP_IMState.cpp.

{
    IIIMP_imattribute *pimattr;
    IIIMP_data_s *pdata_s = get_iiimptrans()->get_data_s();
    IMObject *pobj = IMObjectMgr::get_instance()->get_object_from_attribid(id);
    if (!pobj || !pobj->downloadablep()) return NULL;
    switch (pobj->get_type()) {
      case IMObject::BINARY_GUI:
      case IMObject::BINARY_LWE:
      {
         IIIMP_binaryfile_object *pbobj;
         IIIMP_string *pipath;
         IMObjectWithDesc *pod = (IMObjectWithDesc*) pobj;

         pipath = iiimp_string_new(pdata_s,
                                pod->get_path().size(),
                                pod->get_path().data());
         if (!pipath) goto memory_error;
         pbobj = iiimp_binaryfile_object_new(pdata_s, pipath);
         if (!pbobj) {
             iiimp_string_delete(pdata_s, pipath);
             goto memory_error;
         }
         if (pobj->get_type() == IMObject::BINARY_GUI) {
             pimattr = iiimp_imattribute_binary_gui_object_new(pdata_s,
                                                        id, id,
                                                        pbobj);
         } else {
             pimattr = iiimp_imattribute_binary_light_weight_engine_new(pdata_s,
                                                                id, id,
                                                                pbobj);
         }
         if (!pimattr) {
             iiimp_binaryfile_object_delete(pdata_s, pbobj);
             goto memory_error;
         }
      }
      break;
      case IMObject::JAVA_GUI:
      case IMObject::JAVA_LWE:
      {
         IIIMP_jarfile_object *pjobj;
         IIIMP_string *piclassnamesh, *piclassnames = NULL, *piclassnames2;
         IMObjectWithDesc *pod = (IMObjectWithDesc*) pobj;

         const CARD8BIT *pbr = pod->get_binary_representation();
         if (!pbr) return NULL;

         piclassnamesh = NULL;
         const list<u16string> &classes = pod->get_classes();
         list<u16string>::const_iterator it;
         for (it = classes.begin(); it != classes.end(); it++) {
             piclassnames2 = iiimp_string_new(pdata_s,
                                          it->size(),
                                          it->data());
             if (!piclassnames2) {
                if (piclassnamesh)
                    iiimp_string_delete(pdata_s, piclassnamesh);
                goto memory_error;
             }
             if (!piclassnamesh) {
                piclassnamesh = piclassnames2;
             } else {
                piclassnames->next = piclassnames2;
             }
             piclassnames = piclassnames2;
         }
         pjobj = iiimp_jarfile_object_new(pdata_s, piclassnamesh,
                                      pod->get_object_size(),
                                      pbr);
         if (!pjobj) {
             iiimp_string_delete(pdata_s, piclassnamesh);
             goto memory_error;
         }
         if (pobj->get_type() == IMObject::JAVA_GUI) {
             pimattr = iiimp_imattribute_jar_gui_object_new(pdata_s, id, id, pjobj);
         } else {
             pimattr = iiimp_imattribute_jar_light_weight_engine_object_new(pdata_s,
                                                                    id, id,
                                                                    pjobj);
         }
         if (!pimattr) {
             iiimp_jarfile_object_delete(pdata_s, pjobj);
             goto memory_error;
         }
      }
      break;

      default:
       return NULL;
    }

    return pimattr;

memory_error:
    // TODO: throw exception.
    return NULL;
}

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:

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

Reimplemented from IIIMP_IMState.

Definition at line 765 of file IIIMP_IMState.cpp.

{
    IIIMP_message *pmes = (IIIMP_message*) message;

    switch (pmes->opcode) {
      case IM_GETIMVALUES:
      {
         IIIMP_imattribute *pimattrh, *pimattr = NULL, *pimattr2;
         IIIMP_card16_list *pcl = pmes->v.getimvalues.attr_list;
         IIIMP_card16 *ptr = pcl->ptr;
         pimattrh = NULL;
         for (int i = 0; i < pcl->count; i++, ptr++) {
             pimattr2 = get_imattribute(*ptr);
             if (!pimattr2) continue;
             if (!pimattrh) {
                pimattrh = pimattr2;
             } else {
                pimattr->next = pimattr2;
             }
             pimattr = pimattr2;
         }
         if (!send(iiimp_getimvalues_reply_new(get_iiimptrans()->get_data_s(),
                                          get_im_id(),
                                          pimattrh),
                  true))
             return false;
         break;
      }
      break;
      case IM_SETIMVALUES:
      {
         IIIMP_imattribute *pima = pmes->v.setimvalues.attr_list;
         switch(pima->id) {
           case IIIMP_IMATTRIBUTE_CLIENT_DESCRIPTOR:
           {
              IIIMP_client_descriptor *pcd = pima->value.client_descriptor;

              IMHandler::ClientAttrList attrs;
              if (pcd->type) {
                  attrs.push_back(IMHandler::ClientAttr(IMHandler::CLIENT_NAME,
                                                   CONV_IIIMP_STR(pcd->type)));
              }
              if (pcd->os_name) {
                  attrs.push_back(IMHandler::ClientAttr(IMHandler::OS_NAME,
                                                   CONV_IIIMP_STR(pcd->os_name)));
              }
              if (pcd->arch) {
                  attrs.push_back(IMHandler::ClientAttr(IMHandler::OS_ARCH,
                                                   CONV_IIIMP_STR(pcd->arch)));
              }
              if (pcd->version) {
                  attrs.push_back(IMHandler::ClientAttr(IMHandler::OS_VERSION,
                                                   CONV_IIIMP_STR(pcd->version)));
              }
              if (pcd->X_display_name) {
                  attrs.push_back(IMHandler::ClientAttr(IMHandler::X_DISPLAY_NAME,
                                                   CONV_IIIMP_STR(pcd->X_display_name)));
              }
              if (pcd->X_server_vendor) {
                  attrs.push_back(IMHandler::ClientAttr(IMHandler::X_SERVER_VENDOR,
                                                   CONV_IIIMP_STR(pcd->X_server_vendor)));
              }

              if (!(get_imhandler()->set_client_info(attrs)))
                  return false;

              set_data_to_client();

              if (!send(iiimp_setimvalues_reply_new(get_iiimptrans()->get_data_s(),
                                                get_im_id()),
                       true))
                  return false;
              break;
           }

           default:
            LOG_ERROR("Unknown attribid:%d.", pima->id);
            return false;
         }
      }
      break;

      case IM_CREATEIC:
      {
         IIIMP_icattribute *pattr = pmes->v.createic.attr_list;
         ICAttribute icattr = convert_iiimp_icattr(pattr);
         ICHandler *pich = get_imhandler()->createic(icattr);
         if (!pich) {
             LOG_ERROR("Fail to create new ic (ICHandler).");
             return false;
         }
         CARD16BIT ic_id;
         if (!new_ic_id(ic_id)) return false;
         IIIMP_ICState *pics = IIIMP_ICState::create(ic_id, this, pich);
         if (!pics) {
             pich->destroy(NULL);
             LOG_ERROR("Fail to create new ic (IIIMP_ICState).");
             return false;
         }
         add_icstate(pics);

         if (!send(iiimp_createic_reply_new(get_iiimptrans()->get_data_s(),
                                        get_im_id(),
                                        ic_id),
                  true))
             return false;

          u16string curr_input_lang = icattr.get_inputlanguage();

          if (!get_register_hotkey_flag()) {
             iml_desktop_t *idt = pich->get_current_desktop();
             IIIMLEXMLConf *uconf = NULL;
             HotKeyList *hlist = NULL;
             string conffile = ".iiim/le.xml.conf";

#if 0 /* disable reading the user-specific configuration ATM */
             /* load the user-specific configuration */
             uconf = iiim_le_xmlconf_new(conffile.c_str());
             if (uconf) {
                iiim_le_xmlconf_load_with_nsio(uconf, idt);
                hlist = iiim_le_xmlconf_get_hotkey_list(uconf, curr_input_lang.get_charstr());
             }
#endif
             if (hlist == NULL) {
                /* try to read the global configuration */
                if (uconf)
                    iiim_le_xmlconf_free(uconf);
                uconf = iiim_le_xmlconf_new(XMLCONFDIR "/le.xml.conf");
                if (uconf) {
                       iiim_le_xmlconf_load_file(uconf);
                       hlist = iiim_le_xmlconf_get_hotkey_list(uconf, curr_input_lang.get_charstr());
                }
             }
             send_hotkeys(curr_input_lang, hlist);
             send_trigger_keys();
             iiim_le_xmlconf_free(uconf);

             switch_hotkey_profile();
             set_register_hotkey_flag(true);
          }
      }
      break;

      case IM_DISCONNECT:
      {
         // reset_state() will delete `this'.
         bool flag;
         CARD16BIT im_id = get_im_id();
         IIIMPTrans *ptrans = get_iiimptrans();

         cleanup_ic();
         
         flag = send(iiimp_disconnect_reply_new(ptrans->get_data_s(),
                                           im_id),
                    true);
         reset_state();
         if (!flag) return false;
      }
      break;

      case IM_SETIMVALUES_REPLY:
       // reply message.  Currently, simply ignore it.
       break;

      default:
       LOG_ERROR("Invalid opcode:%d.  (Authentication is requied.)", pmes->opcode);
       return false;
    }
    return true;
}

Here is the call graph for this function:

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:

Definition at line 616 of file IIIMP_IMState.cpp.

{
    IIIMP_imattribute *pima, *pima_objdesc, *pima_imdesc, *pima_capability, *pima_last;
    IIIMP_card32_list * capability;

    pima_objdesc = create_object_descriptors();

    if (check_protocol_version(3))
       /* Send it only to clients of version 3 or later. */
       pima_imdesc = create_input_method_descriptors();
    else
       pima_imdesc = NULL;

    if (pima_objdesc) {
       pima = pima_objdesc;
       pima->next = pima_imdesc;
       pima_last = pima->next;
    } else {
       pima = pima_imdesc;
       pima_last = pima;
    }

    capability = iiimp_card32_list_bit_set(get_iiimptrans()->get_data_s(),
                                      NULL,
                                      IIIMP_CAPABILITY_FILE_OPERATION);
    capability = iiimp_card32_list_bit_set(get_iiimptrans()->get_data_s(),
                                      capability,
                                      IIIMP_CAPABILITY_KEY_RELEASE);
    pima_capability =
       iiimp_imattribute_capability_new(
           get_iiimptrans()->get_data_s(), IIIMP_IMATTRIBUTE_CAPABILITY,
           0, capability);
    if (NULL == pima) {
       pima = pima_capability;
       pima_last = pima;
    } else {
       pima_last->next = pima_capability;
       pima_last = pima_last->next;
    }

    if (!send(iiimp_setimvalues_new(get_iiimptrans()->get_data_s(),
                                get_im_id(), pima), true))
       return false;
    return true;
}

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 switch_le_profile ( IMLEName lename) [friend]
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;
}
int update_supported_langlist_for_le ( IMLEName lename,
IMLocale locales,
int  nLocales 
) [friend]

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