Back to index

im-sdk  12.3.91
IMSvr.hh
Go to the documentation of this file.
00001 #ifndef IMSVR_HH_
00002 #define IMSVR_HH_
00003 #include <vector>
00004 #include <bitset>
00005 #include "basictype.hh"
00006 #include "IMAccept.hh"
00007 #include "IMAuth.hh"
00008 #include "IMUserMgr.hh"
00009 #include "IMUtil.hh"
00010 #include "IMKeyUtils.hh"
00011 #include "lexmlconf.h"
00012 
00013 class IMSvrCfg;
00014 class IMConnection;
00015 class LEMgr;
00016 class IMProtocol;
00017 
00018 class IMSvr : public IMAccept
00019 {
00020     IMSvrCfg *pcfg;
00021     IMUserMgr usermgr;
00022     LEMgr *plemgr;
00023     IMProtocol *pimprotocol;
00024 
00025     IMConnection* create_imconnection(
00026        IMUser *puser,
00027        const string &hostname
00028     );
00029 
00030     enum {
00031         CAUGHT_SIGTERM,
00032         CAUGHT_SIGHUP,
00033         CAUGHT_LAST
00034     };
00035 
00036     std::bitset<CAUGHT_LAST> signal_flag;
00037 
00038   protected:
00039     // configuration methods.
00040     bool config_lepath(
00041        const char* lepath
00042     );
00043     bool config_listenaddress(
00044        IMSocketAddressVec& addrvec
00045     );
00046     bool config_le (
00047        const char* lepath,
00048        IIIMLEXMLConf &xml,
00049        bool preferred_loading
00050     );
00051     bool set_nsmap_config (
00052        IMNsMapStruct *nsmp,
00053        int num_entries
00054     );
00055 
00056   public:
00057     // IMAccept realization.
00058 
00059     virtual bool request_accept(
00060        int fd
00061     );
00062     virtual IMHandler* request_connect(
00063        int fd,
00064        const u16string &username,
00065        const string &hostname,
00066        const u16string &password,
00067        const IMAuthList &authlist
00068     );
00069     
00070   public:
00071     LEMgr* get_lemgr()
00072     { return plemgr; }
00073 
00074     IMKeySpecList get_conversionkeys() const;
00075 
00076     enum IMSVR_EXIT_CODE {
00077            IMSVR_EXIT_SUCCESS = 0,
00078            IMSVR_CONFIG_ERROR = 100,
00079            IMSVR_SYSTEM_ERROR = 255
00080     };
00081 
00082     void reload();
00083     void terminate();
00084     int start();
00085     IMSvr(IMSvrCfg *p_cfg);
00086     virtual ~IMSvr();
00087 
00088   friend class IMSvrCfg;
00089 };
00090 
00091 #endif /* not IMSVR_HH_ */
00092 
00093 /* Local Variables: */
00094 /* c-file-style: "iiim-project" */
00095 /* End: */