Back to index

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

#include <IMSvr.hh>

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

List of all members.

Public Types

enum  IMSVR_EXIT_CODE { IMSVR_EXIT_SUCCESS = 0, IMSVR_CONFIG_ERROR = 100, IMSVR_SYSTEM_ERROR = 255 }

Public Member Functions

virtual bool request_accept (int fd)
virtual IMHandlerrequest_connect (int fd, const u16string &username, const string &hostname, const u16string &password, const IMAuthList &authlist)
LEMgrget_lemgr ()
IMKeySpecList get_conversionkeys () const
void reload ()
void terminate ()
int start ()
 IMSvr (IMSvrCfg *p_cfg)
virtual ~IMSvr ()

Protected Member Functions

bool config_lepath (const char *lepath)
bool config_listenaddress (IMSocketAddressVec &addrvec)
bool config_le (const char *lepath, IIIMLEXMLConf &xml, bool preferred_loading)
bool set_nsmap_config (IMNsMapStruct *nsmp, int num_entries)

Private Types

enum  { CAUGHT_SIGTERM, CAUGHT_SIGHUP, CAUGHT_LAST }

Private Member Functions

IMConnectioncreate_imconnection (IMUser *puser, const string &hostname)

Private Attributes

IMSvrCfgpcfg
IMUserMgr usermgr
LEMgrplemgr
IMProtocolpimprotocol
std::bitset< CAUGHT_LASTsignal_flag

Friends

class IMSvrCfg

Detailed Description

Definition at line 18 of file IMSvr.hh.


Member Enumeration Documentation

anonymous enum [private]
Enumerator:
CAUGHT_SIGTERM 
CAUGHT_SIGHUP 
CAUGHT_LAST 

Definition at line 30 of file IMSvr.hh.

Enumerator:
IMSVR_EXIT_SUCCESS 
IMSVR_CONFIG_ERROR 
IMSVR_SYSTEM_ERROR 

Definition at line 76 of file IMSvr.hh.


Constructor & Destructor Documentation

IMSvr::IMSvr ( IMSvrCfg p_cfg)

Definition at line 163 of file IMSvr.cpp.

  :
    pcfg(p_cfg)
{
    plemgr = NULL;
    pimprotocol = NULL;
}
IMSvr::~IMSvr ( ) [virtual]

Definition at line 172 of file IMSvr.cpp.

{
    if (plemgr) delete plemgr;
    if (pimprotocol) delete pimprotocol;
}

Member Function Documentation

bool IMSvr::config_le ( const char *  lepath,
IIIMLEXMLConf &  xml,
bool  preferred_loading 
) [protected]

Definition at line 23 of file IMSvr.cpp.

{
    LEMgr *plm = new LEMgr (lepath, xml, preferred_loading);

    if (!plm)
       return false;
    if (plemgr)
       delete plemgr;
    plemgr = plm;

    return true;
}

Here is the caller graph for this function:

bool IMSvr::config_lepath ( const char *  lepath) [protected]

Definition at line 11 of file IMSvr.cpp.

{
    LEMgr *plm = new LEMgr(lepath);
    if (!plm) return false;
    if (plemgr) delete plemgr;
    plemgr = plm;
    return true;
}

Here is the caller graph for this function:

bool IMSvr::config_listenaddress ( IMSocketAddressVec addrvec) [protected]

Definition at line 51 of file IMSvr.cpp.

{
    IIIMProtocol *pimp = new IIIMProtocol(this);
    if (!pimp) return false;

    pimp->set_server_listen_address(addrvec);
    if (pimprotocol)
       delete pimprotocol;
    pimprotocol = pimp;

    return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

IMConnection * IMSvr::create_imconnection ( IMUser puser,
const string &  hostname 
) [private]

Definition at line 128 of file IMSvr.cpp.

{
    IMConnection* pc;

    pc = new IMConnection(this, puser, hostname);
    if (!pc) return NULL;

    return pc;
}

Here is the caller graph for this function:

Definition at line 67 of file IMSvr.cpp.

{
    return IMKeyParser(pcfg->get_strval(IMSvrCfg::CONVERSIONKEYS)).get_parsedkeys();
}

Here is the call graph for this function:

Here is the caller graph for this function:

LEMgr* IMSvr::get_lemgr ( ) [inline]

Definition at line 71 of file IMSvr.hh.

    { return plemgr; }

Here is the caller graph for this function:

void IMSvr::reload ( )

Definition at line 99 of file IMSvr.cpp.

{
    // NOTICE:
    // this function is called by signal handler.
    // so we must use signal-safe function in it.
    signal_flag.set(CAUGHT_SIGHUP, true);
}

Here is the caller graph for this function:

bool IMSvr::request_accept ( int  fd) [virtual]

Implements IMAccept.

Definition at line 118 of file IMSvr.cpp.

{
    if (usermgr.fd_ok(fd)) return true;

    return false;
}

Here is the call graph for this function:

IMHandler * IMSvr::request_connect ( int  fd,
const u16string username,
const string &  hostname,
const u16string password,
const IMAuthList authlist 
) [virtual]

Implements IMAccept.

Definition at line 142 of file IMSvr.cpp.

{
    IMUser *puser;
    IMConnection *pimc;

    // TODO
    if (!username.get_charstr()) return NULL;
    puser = usermgr.create_imuser(fd, username.get_charstr(), password.get_charstr());
    if (!puser) return NULL;
    pimc = create_imconnection(puser, hostname);
    if (!pimc) return NULL;

    return pimc;
}

Here is the call graph for this function:

bool IMSvr::set_nsmap_config ( IMNsMapStruct nsmp,
int  num_entries 
) [protected]

Definition at line 41 of file IMSvr.cpp.

{
    plemgr->set_nsmap_config(nsmp, num_entries);
    return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int IMSvr::start ( )

Definition at line 73 of file IMSvr.cpp.

{
    if (!pcfg->configure(this)) return IMSVR_CONFIG_ERROR;
    ASSERT(plemgr);
    ASSERT(pimprotocol);

    for(;;) {
        IMState *pims = pimprotocol->accept();
        if (pims) {
            IMScheduler::get_instance()->start(this, pimprotocol, pims);
        }
        if (signal_flag.test(CAUGHT_SIGHUP)) {
            // received HUP signal
            plemgr->reload();
        }
        if (signal_flag.test(CAUGHT_SIGTERM)) {
            // received TERM signal
            break;
        }
        signal_flag.reset();
    }

    return IMSVR_EXIT_SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void IMSvr::terminate ( )

Definition at line 108 of file IMSvr.cpp.

{
    // NOTICE:
    // this function is called by signal handler.
    // so we must use signal-safe function in it.
    signal_flag.set(CAUGHT_SIGTERM, true);
    return;
}

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class IMSvrCfg [friend]

Definition at line 88 of file IMSvr.hh.


Member Data Documentation

IMSvrCfg* IMSvr::pcfg [private]

Definition at line 20 of file IMSvr.hh.

Definition at line 23 of file IMSvr.hh.

LEMgr* IMSvr::plemgr [private]

Definition at line 22 of file IMSvr.hh.

std::bitset<CAUGHT_LAST> IMSvr::signal_flag [private]

Definition at line 36 of file IMSvr.hh.

Definition at line 21 of file IMSvr.hh.


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