CategoryFileDB.h
上传用户:lds876
上传日期:2013-05-25
资源大小:567k
文件大小:3k
源码类别:

P2P编程

开发平台:

Visual C++

  1. // CategoryFileDB.h: interface for the CCategoryFileDB class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_CATEGORYFILEDB_H__B8B8E016_0450_41EB_A7C2_424943981800__INCLUDED_)
  5. #define AFX_CATEGORYFILEDB_H__B8B8E016_0450_41EB_A7C2_424943981800__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. #include "ctrlext.h"
  10. class CCategoryBarWnd;
  11. class CFileDBItem;
  12. class CVal;
  13. class CSetupRegister;
  14. class CCategoryFileDB  : public CTreeCtrlEx
  15. {
  16. public:
  17. class CCategoryDBItem
  18. {
  19. public :
  20. CCategoryDBItem(string strDefaultDirectory, long lDirectoryID)
  21. {
  22. m_strDefaultDirectory = strDefaultDirectory;
  23. m_lDirectoryID = lDirectoryID;
  24. }
  25. long m_lDirectoryID;
  26. string  m_strDefaultDirectory;
  27. vector<CFileDBItem*> m_vFileDBItems;
  28. };
  29. public:
  30. CCategoryFileDB();
  31. virtual ~CCategoryFileDB();
  32. BOOL CreateEx(CWnd *pParent, CRect &rc, long lParam, CSetupRegister* pSetupRegister );
  33. CTreeCursor findCursorByDirid(long lDirectoryID);
  34. void NewDatabase();
  35. bool OpenDBFile(string strDatabasePath);
  36. void SaveAs(string strDatabasePath);
  37. void Save();
  38. bool IsModifyed();
  39. void SetModifed(bool bModified = true);
  40. string GetDatabaseName();
  41. string GetDatabaseFullPath();
  42. string GetDBSavePath() const;
  43. CSetupRegister* GetSetupRegister() const;
  44. // data
  45. CTreeCursor m_curRoot;
  46. CTreeCursor m_curDownloading;
  47. CTreeCursor m_curDownloaded;
  48. CTreeCursor m_curRecycle;
  49. protected:
  50. string _GetDBSavePath(const string strDatabaseFileName) const;
  51. void LoadDBFile();
  52. void SaveDatabase(string strDatabasePath);
  53. bool LoadDatabase(string strDatabasePath);
  54. virtual void DeleteAllData(CTreeCursor& curDel);
  55. // bool IsLinkFileDBItem(CTreeCursor curItem, CFileDBItem* pFileDBItem);
  56. // data
  57. CSetupRegister* m_pSetupRegister;
  58. bool m_bNoNotifications;
  59. long m_lDirectoryIDMax;
  60. enum ImageIDS{IID_ROOT = 0, IID_DOWNLOADED_DIRECTORY, IID_DOWNLOADING_DIRECTORY, IID_RECYCLE, IID_DIRECTORY};
  61. class CUnclosed
  62. {
  63. public:
  64. CUnclosed(CFileDBItem* pFileDBItem, HTREEITEM hTreeItem)
  65. {
  66. m_pFileDBItem = pFileDBItem;
  67. m_hTreeItem = hTreeItem;
  68. }
  69. CFileDBItem* m_pFileDBItem;
  70. HTREEITEM m_hTreeItem;
  71. };
  72. vector<CUnclosed> m_vUncloseds;
  73. private:
  74. CVal* bencode_rec(CTreeCursor& curItem);
  75. CVal* bencode_FileDBItems(vector<CFileDBItem*>& vFileDbItems);
  76. bool bdencode_FileDBItems(CVal* pVal, vector<CFileDBItem*>& vFileDbItems, HTREEITEM hTreeItem);
  77. bool bdencode_rec(CVal* pVal, CTreeCursor& curItem);
  78. CVal* bencode_UnNeededFiles(vector<CSize>& vUnNeededFiles);
  79. bool bdencode_UnNeedFiles(CVal* pVal, vector<CSize>& vFileDbItems);
  80. // bool LoadGenerateLinks();
  81. // CFileDBItem* GetLinkTrueFileDBItem(CFileDBItem* pLinkFileDBItem);
  82. static CTreeCursor findCursorByDiridRec(CTreeCursor curItem, long lDirectoryID);
  83. string m_strDatabaseFileName;
  84. static string GetDefaultDatabasePath();
  85. bool m_bModified;
  86. // string GetDBSavePath();
  87. // void SetDBSavePath(CSetupRegister* pSetupRegister);
  88. // string m_strDBSavePath;
  89. };
  90. #endif // !defined(AFX_CATEGORYFILEDB_H__B8B8E016_0450_41EB_A7C2_424943981800__INCLUDED_)