Back to index

im-sdk  12.3.91
Classes | Public Types | Public Member Functions | Protected Member Functions | Private Attributes | Friends
IMState Class Reference

#include <IMState.hh>

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

List of all members.

Classes

struct  IMShared

Public Types

enum  CONTEXT_ID_SPECIAL { INVALID_CONTEXT_ID = -1 }
typedef map< CARD16BIT, ICState * > ICStateMap

Public Member Functions

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)
virtual void destroy ()
 IMState (IMState &x, int x_protocol_version=-1)
 IMState (CARD16BIT x_im_id, IMProtocol *x_pimp, IMHandler *x_pimh, int x_protocol_version)

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 ()
virtual bool message_proc (void *message)=0
virtual ~IMState ()

Private Attributes

IMStatepbase_state
IMStatepproc_state
IMSharedpshared
int protocol_version

Friends

class ICState

Detailed Description

Definition at line 14 of file IMState.hh.


Class Documentation

struct IMState::IMShared

Definition at line 20 of file IMState.hh.

Collaboration diagram for IMState::IMShared:
Class Members
IIIMP_hotkey_profile * hotkey_profile
ICStateMap icmap
CARD16BIT im_id
IMHandler * pimh
IMProtocol * pimp
bool register_hotkey_flag

Member Typedef Documentation

typedef map<CARD16BIT, ICState*> IMState::ICStateMap

Definition at line 17 of file IMState.hh.


Member Enumeration Documentation

Enumerator:
INVALID_CONTEXT_ID 

Definition at line 101 of file IMState.hh.

                            {
           INVALID_CONTEXT_ID = -1
    };

Constructor & Destructor Documentation

IMState::~IMState ( ) [protected, virtual]

Definition at line 31 of file IMState.cpp.

{
  if (!substatep()) {
    cleanup_ic();
    delete pshared->hotkey_profile;
    if (pshared && pshared->pimh) pshared->pimh->destroy();
    delete pshared;
    if (pproc_state) delete pproc_state;
  }
}

Here is the call graph for this function:

IMState::IMState ( IMState x,
int  x_protocol_version = -1 
) [inline]

Definition at line 120 of file IMState.hh.

    {
       pshared = x.pshared;
       pproc_state = NULL;
       pbase_state = &x;
       if ((x_protocol_version > 0)
           && (x_protocol_version < x.protocol_version)) {
           protocol_version = x_protocol_version;
       } else {
           protocol_version = x.protocol_version;
       }
    }
IMState::IMState ( CARD16BIT  x_im_id,
IMProtocol x_pimp,
IMHandler x_pimh,
int  x_protocol_version 
)

Definition at line 13 of file IMState.cpp.

{
  pshared = new IMShared();
  pshared->im_id = x_im_id;
  pshared->pimp = x_pimp;
  pshared->pimh = x_pimh;
  pshared->hotkey_profile = new IIIMP_hotkey_profile();
  pshared->register_hotkey_flag = false;
  protocol_version = x_protocol_version;
  pproc_state = NULL;
  pbase_state = this;
}

Member Function Documentation

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

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]

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]

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]

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:

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

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:

void IMState::destroy ( ) [virtual]

Reimplemented in IIIMP_IMState.

Definition at line 82 of file IMState.cpp.

{
    if (!substatep()) pshared->pimp->remove_imstate(this);
    delete this;
}

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 
)

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]

Definition at line 55 of file IMState.hh.

Here is the caller graph for this function:

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]

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:

CARD16BIT IMState::get_im_id ( ) const [inline]

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]

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]

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]

Definition at line 49 of file IMState.hh.

    { return pshared->pimp; }

Here is the caller graph for this function:

bool IMState::get_register_hotkey_flag ( ) const [inline]

Definition at line 89 of file IMState.hh.

Here is the caller graph for this function:

virtual bool IMState::message_proc ( void *  message) [protected, pure virtual]

Implemented in IIIMP_IMState_Session, IIIMP_IMState_Identified, and IIIMP_IMState.

Here is the caller graph for this function:

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

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]

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]

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:

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

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]

Definition at line 86 of file IMState.hh.

Here is the caller graph for this function:

bool IMState::substatep ( ) [inline]

Definition at line 77 of file IMState.hh.

    { return (pbase_state != this); }

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class ICState [friend]

Definition at line 142 of file IMState.hh.


Member Data Documentation

Definition at line 28 of file IMState.hh.

Definition at line 29 of file IMState.hh.

Definition at line 31 of file IMState.hh.

Definition at line 30 of file IMState.hh.


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