00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012 #ifndef __Wastebin_h__
00013 #define __Wastebin_h__
00014
00015 #define wxDBI_SQLITE
00016 #include <wx/dbi.h>
00017
00018 namespace Waste
00019 {
00020
00021 class File
00022 {
00023
00024
00025 public:
00026 File
00027 (
00028 const wxString& sPathName,
00029 const wxString& sFileType
00030 );
00031
00032 protected:
00033 File
00034 (
00035 const wxString& sPathName,
00036 time_t nAccessTime,
00037 time_t nModificationTime,
00038 time_t nCreationTime,
00039 #ifdef __UNIX__
00040 mode_t nPermissions,
00041 #endif // def __UNIX__
00042 const wxString& sFileType,
00043 bool bIsFile
00044 );
00045
00046
00047
00048 public:
00049 wxString GetPathName() const;
00050 time_t GetAccessTime() const;
00051 time_t GetModificationTime() const;
00052 time_t GetCreationTime() const;
00053 #ifdef __UNIX__
00054 mode_t GetPermissions() const;
00055 #endif // def __UNIX__
00056 wxString GetFileType() const;
00057 bool GetIsFile() const;
00058 virtual void Dump() const;
00059
00060
00061 protected:
00062 wxString m_sPathName;
00063 wxString m_sFileType;
00064 bool m_bIsFile;
00065 time_t m_nAccessTime;
00066 time_t m_nModificationTime;
00067 time_t m_nCreationTime;
00068 #ifdef __UNIX__
00069 mode_t m_nPermissions;
00070 #endif // def __UNIX__
00071 };
00072
00077 class WastebinFile : public File
00078 {
00079
00080 friend class Bin;
00081
00082
00083 protected:
00084 WastebinFile
00085 (
00086 int nItemId,
00087 const wxString& sPathName,
00088 time_t nDeletionTime,
00089 time_t nAccessTime,
00090 time_t nModificationTime,
00091 time_t nCreationTime,
00092 #ifdef __UNIX__
00093 mode_t nPermissions,
00094 #endif // def __UNIX__
00095 const wxString& sFileType,
00096 bool bIsFile
00097 );
00098
00099
00100 public:
00101 int GetItemId() const;
00102 time_t GetDeletionTime() const;
00103 virtual void Dump() const;
00104
00105
00106 private:
00107 int m_nItemId;
00108 time_t m_nDeletionTime;
00109 };
00110
00115 class RestoreFile : public WastebinFile
00116 {
00117
00118 friend class Bin;
00119
00120
00121 protected:
00122 RestoreFile
00123 (
00124 int nItemId,
00125 const wxString& sPathName,
00126 time_t nDeletionTime,
00127 time_t nAccessTime,
00128 time_t nModificationTime,
00129 time_t nCreationTime,
00130 #ifdef __UNIX__
00131 mode_t nPermissions,
00132 #endif // def __UNIX__
00133 const wxString& sFileType,
00134 bool bIsFile,
00135 const wxString& sNameInWastebin
00136 );
00137
00138
00139 public:
00140 bool Restore();
00141 virtual void Dump() const;
00142
00143
00144 private:
00145 wxString m_sNameInWastebin;
00146 };
00147
00148 class Bin : private wx::DBI::SQLite
00149 {
00150
00151 public:
00152 typedef bool (* EnumerateWastebinCallbackType)(const WastebinFile&);
00153
00154
00155 public:
00156 Bin(const wxString& sWastebinPath);
00157
00158
00159
00160 public:
00161 bool Empty();
00162 int GetCount();
00163 void Enumerate(const EnumerateWastebinCallbackType fnCallback);
00164 virtual void Dump();
00165
00166 int Throw(File& dli);
00167 void Delete(int nItemId);
00179 bool Restore(int nItemId, wxString& sPathName);
00180
00181 private:
00182 void OpenDatabase(const wxString& sWastebinDatabasePathName);
00183
00184
00185 private:
00186 wxString m_sWastebinPath;
00187 wxString m_sWastebinFilesPath;
00188 wx::DBI::StatementCache m_stc;
00189 };
00190
00191 }
00192
00193 #endif // ndef __Wastebin_h__