Develop and Download Open Source Software

Browse CVS Repository

Contents of /tombo/Tombo/Src/Repository.h

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.26 - (show annotations) (download) (as text)
Wed Aug 23 15:31:54 2006 UTC (17 years, 7 months ago) by hirami
Branch: MAIN
CVS Tags: B231, B230, Tombo_2_0b2, Tombo_2_0b3, Tombo_2_0b1, Tombo_2_0b4, B228, B229, B226, B227, B224, B225, B222, B223, HEAD
Changes since 1.25: +27 -16 lines
File MIME type: text/x-chdr
- Multi repository support(yet completed)
- Fixes to YAE
	* Hang up when *.tdt points invalid position.

1 #ifndef REPOSITORY_H
2 #define REPOSITORY_H
3
4 class TString;
5 class TomboURI;
6 class RepositoryImpl;
7 class URIOption;
8 class URIList;
9
10 class NoteAttribute;
11
12 #include "VarBuffer.h"
13
14 /////////////////////////////////////////
15 // Option flag definitions
16 /////////////////////////////////////////
17
18 #define NOTE_OPTIONMASK_ENCRYPTED 1
19 #define NOTE_OPTIONMASK_SAFEFILE 2
20 #define NOTE_OPTIONMASK_VALID 4
21 #define NOTE_OPTIONMASK_ICON 8
22
23 /////////////////////////////////////////
24 // Custom error code
25 /////////////////////////////////////////
26
27 #define ERROR_TOMBO_REP_CODE_BASE_ERROR (0x24000000)
28 #define ERROR_TOMBO_REP_CODE_BASE_WARN (0x22000000)
29 #define ERROR_TOMBO_REP_CODE_BASE_INFO (0x21000000)
30
31 #define ERROR_TOMBO_E_INVALIDURI (ERROR_TOMBO_REP_CODE_BASE_ERROR + 1)
32 #define ERROR_TOMBO_E_SOME_ERROR_OCCURED (ERROR_TOMBO_REP_CODE_BASE_ERROR + 2)
33 #define ERROR_TOMBO_E_RMFILE_FAILED (ERROR_TOMBO_REP_CODE_BASE_ERROR + 3)
34 #define ERROR_TOMBO_E_RMDIR_FAILED (ERROR_TOMBO_REP_CODE_BASE_ERROR + 4)
35
36 #define ERROR_TOMBO_W_DELETEOLD_FAILED (ERROR_TOMBO_REP_CODE_BASE_WARN + 1)
37 #define ERROR_TOMBO_W_OTHERFILE_EXISTS (ERROR_TOMBO_REP_CODE_BASE_ERROR + 2)
38 #define ERROR_TOMBO_W_OPERATION_NOT_PERMITTED (ERROR_TOMBO_REP_CODE_BASE_ERROR + 3)
39
40 #define ERROR_TOMBO_I_OPERATION_NOT_PERFORMED (ERROR_TOMBO_REP_CODE_BASE_INFO + 1)
41 #define ERROR_TOMBO_I_GET_PASSWORD_CANCELED (ERROR_TOMBO_REP_CODE_BASE_INFO + 2)
42
43 /////////////////////////////////////////
44 // GetList results
45 /////////////////////////////////////////
46
47 #define TOMBO_REPO_GETLIST_FAIL 0
48 #define TOMBO_REPO_GETLIST_SUCCESS 1
49 #define TOMBO_REPO_GETLIST_PARTIAL 2
50
51 /////////////////////////////////////////
52 // Sub repository type
53 /////////////////////////////////////////
54
55 #define TOMBO_REPO_SUBREPO_TYPE_INVALID 0
56 #define TOMBO_REPO_SUBREPO_TYPE_LOCALFILE 1
57 #define TOMBO_REPO_SUBREPO_TYPE_VFOLDER 2
58
59 //////////////////////////////////////////////////////////////
60 // Repository enumeration interface
61 //////////////////////////////////////////////////////////////
62
63 class IEnumRepository {
64 public:
65 virtual URIList *GetChild(const TomboURI *pFolderURI, BOOL bSkipEncrypt, BOOL bLooseDecrypt, BOOL *pLoose) = 0;
66 virtual BOOL GetOption(const TomboURI *pURI, URIOption *pOption) = 0;
67 virtual BOOL GetHeadLine(const TomboURI *pURI, TString *pHeadLine) = 0;
68 };
69
70 //////////////////////////////////////////////////////////////
71 // Repository
72 //////////////////////////////////////////////////////////////
73 // Repository is an abstraction of TOMBO's notes/folder tree.
74
75 class Repository : public IEnumRepository {
76
77 protected:
78 RepositoryImpl *pDefaultImpl;
79 TVector<RepositoryImpl*> vSubRepository;
80
81 // Get real physical path from URI.
82 //
83 // This method may be not supported by some RepositoryImpl type.
84 BOOL GetPhysicalPath(const TomboURI *pURI, TString *pFullPath);
85
86 // get sub repository reference assciated with the URI
87 RepositoryImpl *GetAssocSubRepository(const TomboURI *pURI);
88 public:
89
90 Repository();
91 ~Repository();
92
93 BOOL Init();
94 BOOL ClearSubRepository();
95
96 // Add sub repository. pImpl instance is controled under Repository so do not delete pImpl by caller.
97 BOOL AddSubRepository(RepositoryImpl *pImpl);
98
99 ////////////////////////////
100 // Note/folder operations
101
102 BOOL Update(const TomboURI *pCurrentURI, LPCTSTR pData, TomboURI *pNewURI, TString *pNewHeadLine);
103 BOOL GetHeadLine(const TomboURI *pURI, TString *pHeadLine);
104
105 BOOL Delete(const TomboURI *pURI, URIOption *pOption);
106 BOOL Copy(const TomboURI *pCopyFrom, const TomboURI *pCopyTo, URIOption *pOption);
107 BOOL Move(const TomboURI *pMoveFrom, const TomboURI *pMoveTo, URIOption *pOption);
108
109 BOOL ExecuteAssoc(const TomboURI *pURI, ExeAppType nType);
110 BOOL MakeFolder(const TomboURI *pParent, LPCTSTR pFolderName);
111
112 // Rename headline
113 // Repository data is updated if necessary.
114 BOOL ChangeHeadLine(const TomboURI *pURI, LPCTSTR pReqNewHeadLine, URIOption *pOption);
115
116 LPTSTR GetNoteData(const TomboURI *pURI);
117 LPBYTE GetNoteDataNative(const TomboURI *pURI, LPDWORD pSize);
118
119 // Get URI the a item attached to.
120 // ex. : tombo://repo/a/b/c/ -> tombo://repo/a/b/c/
121 // : tombo://repo/a/b/c/d.txt -> tombo://repo/a/b/c/
122 BOOL GetAttachURI(const TomboURI *pBase, TomboURI *pAttached);
123
124 // for use search only.
125 BOOL GetFileName(const TomboURI *pURI, TString *pName);
126
127 // Get notes under the url.
128 URIList *GetChild(const TomboURI *pFolderURI, BOOL bSkipEncrypt, BOOL bLooseDecrypt, BOOL *pLoose);
129
130 // Decide URI
131 BOOL RequestAllocateURI(const TomboURI *pBaseURI, LPCTSTR pText, TString *pHeadLine, TomboURI *pURI, const TomboURI *pTemplateURI);
132
133 ////////////////////////////
134 // File attribute functions
135
136 // get option from URI
137 //
138 // if NOTE_OPTIONMASK_VALID is set by pOption, bValid and bFolder is effective.
139 // if NOTE_OPTIONMASK_ENCRYPTED is set, bEncrypt is effective.
140 // if NOTE_OPTIONMASK_SAFEFILE is set, bSafeFile is effective.
141 BOOL GetOption(const TomboURI *pURI, URIOption *pOption);
142
143 // set option from URI
144 //
145 // if NOTE_OPTIONMASK_ENCRYPTED is set and bEncrypt is TRUE and bSafeFile is FALSE, encrypt to the URI by normal mode.
146 // if NOTE_OPTIONMASK_ENCRYPTED is set and bEncrypt is TRUE and bSafeFile is TRUE, encrypt to the URI by safefile mode.
147 // if NOTE_OPTIONMASK_ENCRYPTED is set and bEncrypt is FALSE, decrypt to the URI.
148 //
149 // In current implimentation, change normal mode <-> safe file mode is not supported.
150 BOOL SetOption(const TomboURI *pCurrentURI, URIOption *pOption);
151
152 BOOL GetAttribute(const TomboURI *pURI, NoteAttribute *pAttribute);
153 BOOL SetAttribute(const TomboURI *pURI, const NoteAttribute *pAttribute);
154 // get note attributes.
155 // TODO: merged to GetAttribute.
156 BOOL GetNoteAttribute(const TomboURI *pURI, UINT64 *pLastUpdate, UINT64 *pCreateDate, UINT64 *pFileSize);
157
158 /////////////////////////////
159 // helper function
160
161 // Check the URI data is encrypted
162 BOOL IsEncrypted(const TomboURI *pURI);
163
164 /////////////////////////////
165 // sub repository IF
166 DWORD GetNumOfSubRepository();
167 DWORD GetSubRepositoryType(DWORD nIndex);
168 LPCTSTR GetSubRepositoryName(DWORD nIndex);
169 const TomboURI *GetSubRepositoryRootURI(DWORD nIndex);
170 LPTSTR GetSubRepoXMLSaveString(DWORD nIndex);
171
172 static RepositoryImpl *CreateSubRepo(LPCWSTR pName, const WCHAR **atts);
173 };
174
175 //////////////////////////////////////////////////////////////
176 // URI option
177 //////////////////////////////////////////////////////////////
178
179 class URIOption {
180 public:
181 URIOption(DWORD flg = 0) : nFlg(flg), pNewURI(NULL), pNewHeadLine(NULL) {}
182 ~URIOption() { delete pNewURI; delete pNewHeadLine; }
183
184 // request section
185 DWORD nFlg;
186 BOOL bEncrypt;
187 BOOL bSafeFileName;
188 BOOL bValid;
189 BOOL bFolder;
190
191 int iIcon;
192
193 // result info section
194 // if these value is not set by NULL, delete when NoteOption is deleted.
195 TString *pNewHeadLine;
196 TomboURI *pNewURI;
197 };
198
199 //////////////////////////////////////////////////////////////
200 // File Attribute
201 //////////////////////////////////////////////////////////////
202
203 class NoteAttribute {
204 public:
205 DWORD nCursorPos;
206 BOOL bReadOnly;
207 };
208
209 //////////////////////////////////////////////////////////////
210 // Global definitions
211 //////////////////////////////////////////////////////////////
212
213 extern Repository g_Repository;
214
215 #endif

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26