RemoteInterface.h
资源名称:warftpd.zip [点击查看]
上传用户:surprise9
上传日期:2007-01-04
资源大小:426k
文件大小:4k
源码类别:
Ftp客户端
开发平台:
Visual C++
- // This is part of the WAR SOFTWARE SERIES initiated by Jarle Aase
- // Copyright 1996 by Jarle Aase. All rights reserved.
- // See the "War Software Series Licende Agreement" for details concerning
- // use and distribution.
- // ---
- // This source code, executables and programs containing source code or
- // binaries or proprietetary technology from the War Software Series are
- // NOT alloed used, viewed or tested by any governmental agencies in
- // any countries. This includes the government, departments, police,
- // military etc.
- // ---
- // This file is intended for use with Tab space = 2
- // Created and maintained in MSVC Developer Studio
- // ---
- // NAME : RemoteInterface.h
- // PURPOSE : General header file for all War Software that use WarClientLib.dll
- // PROGRAM :
- // DATE : Nov. 9 1996
- // AUTHOR : Jarle Aase
- // ---
- // REVISION HISTORY
- //
- ///////////////////////////////////////////////////////////////////////////////////////
- // Remote connection interface
- // One syncronous and one async return channel
- class CRemoteRequest
- {
- public:
- int m_Type;
- CCmdArgs *m_RequestQueue;
- CString m_Request;
- CString *m_ReplyBuf;
- CWnd *m_cWnd;
- int m_Msg;
- BOOL (* m_Func)(int nErrorCode, LPVOID ReplyBuf, LPVOID Arg);
- LPVOID m_FuncArg;
- CCriticalSection m_Lock;
- BOOL m_IsReleased;
- };
- enum // Request types
- {
- RQ_SINGLE,
- RQ_MULTIPLE,
- RQ_INVALID
- };
- class DLL_WAR_SOFTWARE_ CRemoteInterface : public CSock
- {
- public:
- CLinkedList m_RequestQueue;
- CString m_CurrentRequest;
- CString m_CurrentReply;
- int CurrentQueueIndex;
- CCmdArgs *CurrentRequestQueue;
- CCmdArgs *CurrentReplyQueue;
- CLinkedList CurrentServerReply;
- CLinkedList CurrentServerNotifications;
- CString m_InBuf;
- LPCSTR m_LastLineInBuf;
- CString m_OutBuf;
- CWarTimer m_ConnectionTimer;
- CString m_UserName;
- CString m_UserPwd;
- CString m_PreperedCommand; // Used to transfere the PORT command
- // Direct file download
- HANDLE m_FileHandle;
- DWORD m_BytesLeftToDownload;
- DWORD m_BytesToDownload;
- CString m_FileName; // Original file name
- CString m_TempFileName; // Real file name
- public:
- CRemoteInterface();
- ~CRemoteInterface();
- BOOL OpenRemote(LPCSTR Address, UINT Port, int Service,
- LPCSTR UserName, LPCSTR UserPwd);
- virtual void OnOpen(int nErrorCode);
- BOOL Request(LPCSTR Request, CString &cReplyBuf,
- CWnd *cWnd = NULL, int nMsg = 0,
- BOOL (* Func)(int nErrorCode, LPVOID ReplyBuf, LPVOID Arg) = NULL,
- LPVOID Arg = NULL, HANDLE *CancelHndl = NULL);
- BOOL Request(CRemoteRequest *Req);
- virtual BOOL OnRequest(int nErrorCode, CRemoteRequest *Req);
- BOOL RequestMulti(CCmdArgs *RequestList,
- CWnd *cWnd = NULL, int nMsg = 0,
- BOOL (* Func)(int nErrorCode, LPVOID ReplyBuf, LPVOID Arg) = NULL,
- LPVOID Arg = NULL);
- virtual void OnRequestMulti(int nErrorCode,
- CRemoteRequest *Req);
- virtual BOOL OnNotification(int nErrorCode, LPSTR Notification);
- static BOOL Req(HANDLE Remote, LPCSTR RequestText,
- CString& ReplyBuf, int timeout = INFINITE);
- static BOOL ReqCallback(int nErrorCode, LPVOID ReplyBuf,
- LPVOID Arg);
- BOOL CancelRequest(HANDLE h);
- BOOL Abort();
- // CSock overrides
- virtual void OnConnect( int nErrorCode );
- virtual void OnSend( int nErrorCode );
- virtual void OnReceive( int nErrorCode );
- virtual void OnClose( int nErrorCode );
- virtual void OnClientLogNotify(LPCSTR Text);
- protected:
- virtual BOOL NotifyRequest(int nErrorCode);
- virtual void OnServerMessage( int nErrorCode );
- BOOL ProcessRequest(int nErrorCode);
- BOOL DoSend();
- BOOL SendCmd(LPCSTR Format, ...);
- virtual BOOL _SendCmd(LPCSTR Command);
- };