- // CSHelper.h: interface for the CCSHelper class.
- #ifndef _CSHELPER_H
- #define _CSHELPER_H
- #include "socket.h"
- //================================================
- //
- //Class Name : CCSHelper
- //
- //Description: Client and Server helper class.
- //
- //Create Time: 2004-07-04
- //
- //================================================
- class CCSHelper
- {
- public:
- CCSHelper();
- virtual ~CCSHelper();
- bool Start(void); //start the cs helper functions.
- void Stop(void); //stop the cs helper functions.
- const int GetClientID(); //get local agent's identity.
- const string& GetClientName();//get local agent's display name.
- //process agent rename action
- bool AGRename(LPCSTR lpszNewName, const int nAGID);
- //process agent state update requirement
- bool SendAGState(void);
- //process agent's identity authentication
- bool SendAGAuthor(AUTHORINFO &authorinfo);
- //verifying current administrator user twice
- bool VerifyCurrentUser(void);
- //process agent sql requiement
- CGuiRecordSet* SendAGUsrSql(LPCSTR lpszUsrSql, bool &bSuccessful, bool bReturnRecordset = true);
- BOOL UpdateAgentsContents(void); //update local "agents.db" table
- BOOL UpdateDepartsContents(void); //update local "departs.db" table
- public:
- //return refresh thread can be terminated flag.
- const bool RefThreadCanTerminate(void);
- //return cycconnecting server thread can be terminated flag.
- const bool CycConnThreadCanTerminate(void);
- //main thread entry.
- static DWORD CALLBACK CSRefThreadProc(LPVOID lpParameter);
- //c-s socket loop connecting thread
- static DWORD CALLBACK CycConnectCSThread(LPVOID lpParameters);
- public:
- //C-S helper object states
- typedef enum { CHS_IDLE = 0, CHS_UPTAGSTATE = 1, CHS_UPTAGUSRLIST = 2, CHS_COMPLEX = CHS_UPTAGSTATE | CHS_UPTAGUSRLIST } CSHLPERSTATE;
- //server ip and port.
- string m_sserverip;
- DWORD m_dwserverport;
- //c-cs socket object.
- CXWinClientSocket m_hlpsock;
- //current C-S helper object state
- CCSHelper::CSHLPERSTATE m_chstate;
- private:
- //read connection configure
- bool ReadConnConfigure(void);
- //first authentication action
- bool FirstAuthor(void);
- //receive ACK package from peer socket
- bool RecvAnswer(KAGENTPACK &agkpack);
- //receiving file from server.
- bool ReceiveFile(string &sDestFile);
- //process recordset xml file.
- bool ProcessSQLRSXML(LPCSTR szSQLTxt, string &sFileName, bool bReturnRecordset = true);
- private:
- bool m_bactived; //activity flag.
- int m_nAGID; //agent id.
- string m_sAGName; //agent name.
- bool m_bcanterminate; //thread terminated signal.
- bool m_bcanexitconnectcs;//flag connecting c-s socket thread whether can be terminated ?
- HANDLE m_hrefthread, //system contents refreshing thread.
- m_hconcsthread; //connecting c-s socket thread handle.
- };
- #endif //_CSHELPER_H