www.pudn.com > NetPaw.rar > NetPawDoc.h


// NetPawDoc.h :  CNetPawDoc 类的接口 
// 
#pragma once 
 
// our downloading profile 
#define PROFILE_NPJ  _T("\\profile.npj") 
 
// for UpdateAllViews lHint 
#define UPDATE_PARTIAL 0 
#define UPDATE_ALL 1 
#define MAX_CONNECTIONS 15 
 
enum _MGRFOLDERS 
{ 
	FOLDER_DOWNLDING = 0, 
	FOLDER_DOWNLDED, 
	FOLDER_FAVORITES, 
	MAX_DEFAULT_FOLDERS 
}; 
 
// these structure are designed for recording download items 
typedef struct _DLFILEITEM 
{ 
	WORD wSeperator; // 0A0D 
	WORD wBlocksToDo; // un-finished block 
	LONGLONG nFileLength; 
	LONGLONG nBytesDone; 
	double dUsedTime; 
	TCHAR szUrl[MAX_PATH]; 
	TCHAR szReferer[MAX_PATH]; 
	TCHAR szWebInfo[MAX_PATH/2]; 
	//SEGMENT_S arBlocks[wBlocksToDo]; 
} DLFILEITEM_S; 
 
typedef struct _FOLDERCLASS 
{ 
	DWORD dwSeperator; // 0D0A0D0A 
	WORD wClass; // 0-downloading, 01-downloaded, 02-favorites 
	WORD wItems; // items under downloading or downloaded 
	//DLFILEITEM_S stItem[wItems]; 
} FOLDERCLASS_S; 
 
typedef struct _FILEHDR 
{ 
	WORD wMagicWord; // 4E50 
	WORD wReserved; // 0000 
	DWORD dwCrc; // 32 bit CRC, header not included 
	//FOLDERCLASS_S stDlClass; 
} FILEHDR_S; 
 
 
class CCrc32; 
class CDownloadFile; 
class CNetPawDoc : public CDocument 
{ 
protected: // 仅从序列化创建 
	CNetPawDoc(); 
	DECLARE_DYNCREATE(CNetPawDoc) 
 
// 重写 
public: 
	virtual BOOL OnNewDocument(); 
	virtual void Serialize(CArchive& ar); 
 
// 实现 
public: 
	virtual ~CNetPawDoc(); 
#ifdef _DEBUG 
	virtual void AssertValid() const; 
	virtual void Dump(CDumpContext& dc) const; 
#endif 
 
// 生成的消息映射函数 
protected: 
	DECLARE_MESSAGE_MAP() 
 
protected: 
	CString m_sProfName; 
	CCrc32 *m_pCrc32; 
 
public: 
	map m_mapDownldFile; 
	list m_lstDownloaded; 
	map m_mapFavorites; 
	int m_nMaxSpeed; 
 
	// for downloading file 
	LONGLONG GetSelFileLen(void); 
	CDownloadFile* GetSelDownFile(void); 
	void DeleteDlFile(CDownloadFile* pDlFile); 
	CDownloadFile* NewDownldFile( DLFILEITEM_S *pstDlFileIt ); 
 
	// for downloaded items 
	DONEITEM_S* GetSelDownloaded(void); 
	void DeleteDownlded(DONEITEM_S* pDoneIt); 
	void NotifyFileDone(CDownloadFile* pDlFile); 
 
	// save profile method 
	void SaveProfile(void); 
	void SaveDownldFile(CFile *pFile); 
	void SaveDownldedFile(CFile *pFile); 
	void SaveFavorites(CFile *pFile); 
	void WriteCrc32(LPCTSTR szFileName); 
 
	// load profile method 
	BOOL CheckCRC32(LPCTSTR szFileName); 
	void LoadProfile(void); 
	void LoadDownldFile(CFile *pFile); 
	void LoadDownldedFile(CFile *pFile); 
	void LoadFavorites(CFile *pFile); 
};