CategoryFileDB.h
资源名称:GGBT.rar [点击查看]
上传用户:lds876
上传日期:2013-05-25
资源大小:567k
文件大小:3k
源码类别:
P2P编程
开发平台:
Visual C++
- // CategoryFileDB.h: interface for the CCategoryFileDB class.
- //
- //////////////////////////////////////////////////////////////////////
- #if !defined(AFX_CATEGORYFILEDB_H__B8B8E016_0450_41EB_A7C2_424943981800__INCLUDED_)
- #define AFX_CATEGORYFILEDB_H__B8B8E016_0450_41EB_A7C2_424943981800__INCLUDED_
- #if _MSC_VER > 1000
- #pragma once
- #endif // _MSC_VER > 1000
- #include "ctrlext.h"
- class CCategoryBarWnd;
- class CFileDBItem;
- class CVal;
- class CSetupRegister;
- class CCategoryFileDB : public CTreeCtrlEx
- {
- public:
- class CCategoryDBItem
- {
- public :
- CCategoryDBItem(string strDefaultDirectory, long lDirectoryID)
- {
- m_strDefaultDirectory = strDefaultDirectory;
- m_lDirectoryID = lDirectoryID;
- }
- long m_lDirectoryID;
- string m_strDefaultDirectory;
- vector<CFileDBItem*> m_vFileDBItems;
- };
- public:
- CCategoryFileDB();
- virtual ~CCategoryFileDB();
- BOOL CreateEx(CWnd *pParent, CRect &rc, long lParam, CSetupRegister* pSetupRegister );
- CTreeCursor findCursorByDirid(long lDirectoryID);
- void NewDatabase();
- bool OpenDBFile(string strDatabasePath);
- void SaveAs(string strDatabasePath);
- void Save();
- bool IsModifyed();
- void SetModifed(bool bModified = true);
- string GetDatabaseName();
- string GetDatabaseFullPath();
- string GetDBSavePath() const;
- CSetupRegister* GetSetupRegister() const;
- // data
- CTreeCursor m_curRoot;
- CTreeCursor m_curDownloading;
- CTreeCursor m_curDownloaded;
- CTreeCursor m_curRecycle;
- protected:
- string _GetDBSavePath(const string strDatabaseFileName) const;
- void LoadDBFile();
- void SaveDatabase(string strDatabasePath);
- bool LoadDatabase(string strDatabasePath);
- virtual void DeleteAllData(CTreeCursor& curDel);
- // bool IsLinkFileDBItem(CTreeCursor curItem, CFileDBItem* pFileDBItem);
- // data
- CSetupRegister* m_pSetupRegister;
- bool m_bNoNotifications;
- long m_lDirectoryIDMax;
- enum ImageIDS{IID_ROOT = 0, IID_DOWNLOADED_DIRECTORY, IID_DOWNLOADING_DIRECTORY, IID_RECYCLE, IID_DIRECTORY};
- class CUnclosed
- {
- public:
- CUnclosed(CFileDBItem* pFileDBItem, HTREEITEM hTreeItem)
- {
- m_pFileDBItem = pFileDBItem;
- m_hTreeItem = hTreeItem;
- }
- CFileDBItem* m_pFileDBItem;
- HTREEITEM m_hTreeItem;
- };
- vector<CUnclosed> m_vUncloseds;
- private:
- CVal* bencode_rec(CTreeCursor& curItem);
- CVal* bencode_FileDBItems(vector<CFileDBItem*>& vFileDbItems);
- bool bdencode_FileDBItems(CVal* pVal, vector<CFileDBItem*>& vFileDbItems, HTREEITEM hTreeItem);
- bool bdencode_rec(CVal* pVal, CTreeCursor& curItem);
- CVal* bencode_UnNeededFiles(vector<CSize>& vUnNeededFiles);
- bool bdencode_UnNeedFiles(CVal* pVal, vector<CSize>& vFileDbItems);
- // bool LoadGenerateLinks();
- // CFileDBItem* GetLinkTrueFileDBItem(CFileDBItem* pLinkFileDBItem);
- static CTreeCursor findCursorByDiridRec(CTreeCursor curItem, long lDirectoryID);
- string m_strDatabaseFileName;
- static string GetDefaultDatabasePath();
- bool m_bModified;
- // string GetDBSavePath();
- // void SetDBSavePath(CSetupRegister* pSetupRegister);
- // string m_strDBSavePath;
- };
- #endif // !defined(AFX_CATEGORYFILEDB_H__B8B8E016_0450_41EB_A7C2_424943981800__INCLUDED_)