31
|
1 |
/*
|
|
2 |
* Copyright (c) 2006-2006 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: Storage handler
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
#ifndef CBSSTORAGEMANAGER_H
|
|
21 |
#define CBSSTORAGEMANAGER_H
|
|
22 |
|
|
23 |
#include <e32base.h>
|
|
24 |
#include <f32file.h>
|
|
25 |
|
|
26 |
class CBSSession;
|
|
27 |
class CBSIBYWriter;
|
|
28 |
class MBSElement;
|
|
29 |
class CBSStorage;
|
|
30 |
class RWriteStream;
|
|
31 |
|
|
32 |
|
|
33 |
/**
|
|
34 |
* Storage handler
|
|
35 |
*
|
|
36 |
* @lib .exe
|
|
37 |
* @since S60 v3.2
|
|
38 |
*/
|
|
39 |
class CBSStorageManager : public CBase
|
|
40 |
{
|
|
41 |
public:
|
|
42 |
|
|
43 |
static CBSStorageManager* NewL( CBSSession* aSession, const TDesC& aAppId );
|
|
44 |
|
|
45 |
static CBSStorageManager* NewLC( CBSSession* aSession, const TDesC& aAppId );
|
|
46 |
|
|
47 |
~CBSStorageManager();
|
|
48 |
|
|
49 |
|
|
50 |
/**
|
|
51 |
* Initializes the transaction to the
|
|
52 |
* storagemanager
|
|
53 |
*
|
|
54 |
* @since S60 3.2
|
|
55 |
* @return none
|
|
56 |
*/
|
|
57 |
void ConnectTransactionL(const TDesC& aAppId,
|
|
58 |
const TDesC& aBrandId,
|
|
59 |
TLanguage aLanguageId,
|
|
60 |
TBool aAppending = EFalse,
|
|
61 |
TInt aReserved = 0 );
|
|
62 |
|
|
63 |
|
|
64 |
/**
|
|
65 |
* Create a new storage and set it to current.
|
|
66 |
*
|
|
67 |
* @since S60 3.2
|
|
68 |
* @return none
|
|
69 |
*/
|
|
70 |
void CreateStorageL();
|
|
71 |
|
|
72 |
/**
|
|
73 |
* Return the count of storages
|
|
74 |
*
|
|
75 |
* @since S60 3.2
|
|
76 |
* @return count of elements
|
|
77 |
*/
|
|
78 |
TInt StorageCount();
|
|
79 |
|
|
80 |
/**
|
|
81 |
* Get stored storage at index or current storage.
|
|
82 |
*
|
|
83 |
* @since S60 3.2
|
|
84 |
* @param aIndex index of storage to fetch.
|
|
85 |
* @return Stored storage
|
|
86 |
*/
|
|
87 |
CBSStorage* Storage( TInt aIndex );
|
|
88 |
CBSStorage* Storage();
|
|
89 |
|
|
90 |
/**
|
|
91 |
* Externalize storage files into file system
|
|
92 |
*
|
|
93 |
* @since S60 3.2
|
|
94 |
* @param aFs filesystem handle
|
|
95 |
* @param aBaseDir Base directory for writing
|
|
96 |
* @return the new brand version
|
|
97 |
*/
|
|
98 |
TInt WriteStorageFilesL();
|
|
99 |
|
|
100 |
void CancelTransactionL();
|
|
101 |
|
|
102 |
void BrandHandleL( const TDesC& aAppId,
|
|
103 |
const TDesC& aBrandId,
|
|
104 |
TLanguage aLanguageId,
|
|
105 |
RFile& aFile,
|
|
106 |
TInt aReserved );
|
|
107 |
|
|
108 |
void FileElementHandleL( const TDesC& aAppId,
|
|
109 |
const TDesC& aBrandId,
|
|
110 |
const TDesC& aFileName,
|
|
111 |
const TDesC& aLanguageBuf,
|
|
112 |
RFile& aFile );
|
|
113 |
|
|
114 |
void CleanupFileL( const TDesC& aFileName );
|
|
115 |
|
|
116 |
TPtrC FilenameWithoutVersion( const TDesC& aFileName );
|
|
117 |
|
|
118 |
/**
|
|
119 |
* Externalize storage files into file system
|
|
120 |
*
|
|
121 |
* @since S60 3.2
|
|
122 |
* @param aFileName the name of the installed file
|
|
123 |
* including path
|
|
124 |
* @return the filename without path component
|
|
125 |
*/
|
|
126 |
HBufC* InstallFileLC( const TDesC& aFileName );
|
|
127 |
|
|
128 |
void RemoveBrandL( const TDesC& aAppId,
|
|
129 |
const TDesC& aBrandId,
|
|
130 |
TLanguage aLanguageId,
|
|
131 |
TInt aReserved = 0);
|
|
132 |
|
|
133 |
void RemoveApplicationL( const TDesC& aAppId );
|
|
134 |
|
|
135 |
TInt NextAvailableVersionL();
|
|
136 |
void SetVersion( TInt aVersionId );
|
|
137 |
|
|
138 |
TInt GetNewestVersionL( const TDesC& aAppId,
|
|
139 |
const TDesC& aBrandId,
|
|
140 |
TLanguage aLanguageId,
|
|
141 |
TPtr* aDrive = NULL);
|
|
142 |
TInt WriteIbyFiles();
|
|
143 |
|
|
144 |
void LockStorage();
|
|
145 |
|
|
146 |
void ReleaseLockL();
|
|
147 |
|
|
148 |
TBool CheckBrandDiscarded(const TDesC& aAppId,
|
|
149 |
const TDesC& aBrandId) ;
|
|
150 |
static HBufC* ConstructDiscardBrandFileNameL( const TDesC& aAppId,
|
|
151 |
const TDesC& aBrandId );
|
|
152 |
|
|
153 |
static HBufC* FullDiscardBrandFileNameLC( TDesC& aFilename ) ;
|
|
154 |
|
|
155 |
TInt isActualBrandInstalledL ( const TDesC& aAppId, const TDesC& aBrandId, TLanguage aLanguage);
|
|
156 |
private:
|
|
157 |
|
|
158 |
CBSStorageManager();
|
|
159 |
|
|
160 |
void ConstructL( CBSSession* aSession, const TDesC& aAppId );
|
|
161 |
|
|
162 |
HBufC* ConstructFileNameL( TInt aVersion = 0 );
|
|
163 |
|
|
164 |
HBufC* ConstructFileNameL( const TDesC& aAppId,
|
|
165 |
const TDesC& aBrandId,
|
|
166 |
TLanguage aLanguage,
|
|
167 |
TInt aReserved = 0 );
|
|
168 |
|
|
169 |
void CleanupTransaction();
|
|
170 |
|
|
171 |
HBufC* FullFileNameLC( const TDesC& aFilename, TBool aForceCDrive = EFalse );
|
|
172 |
|
|
173 |
TInt ReadVersionL( const TDesC& aFilename );
|
|
174 |
|
|
175 |
HBufC* FindAvailableVersionL( TInt aCurrentVersion, TInt& aNewVersion );
|
|
176 |
|
|
177 |
TBool IsBaseFileL( const TDesC& aFileName );
|
|
178 |
|
|
179 |
|
|
180 |
/**
|
|
181 |
* Mark a brand package as discarded. Future attempts to create an
|
|
182 |
* access to this brand package will fail.
|
|
183 |
*
|
|
184 |
* @since S60 3.2
|
|
185 |
* @param aAppId a application id
|
|
186 |
* @param aBrandId a brand id
|
|
187 |
*/
|
|
188 |
void MarkBrandAsDiscardedL( const TDesC& aAppId,
|
|
189 |
const TDesC& aBrandId );
|
|
190 |
|
|
191 |
private: // Data
|
|
192 |
|
|
193 |
// Own. Array of stored storages.
|
|
194 |
RPointerArray<CBSStorage> iStorages;
|
|
195 |
|
|
196 |
// Index of currently active storage
|
|
197 |
TInt iCurrent;
|
|
198 |
|
|
199 |
// IBY writer
|
|
200 |
CBSIBYWriter* iWriter;
|
|
201 |
|
|
202 |
RFs iFs;
|
|
203 |
TBool iActive;
|
|
204 |
|
|
205 |
HBufC* iAppId;
|
|
206 |
HBufC* iBrandId;
|
|
207 |
HBufC* iLanguageId;
|
|
208 |
TLanguage iLanguageIdNum;
|
|
209 |
|
|
210 |
// Own. Proposed file name
|
|
211 |
HBufC* iFilename;
|
|
212 |
|
|
213 |
// Proposed directory (points to iFilename)
|
|
214 |
TPtrC iDir;
|
|
215 |
|
|
216 |
// doesn't own: the server
|
|
217 |
CBSSession* iSession;
|
|
218 |
|
|
219 |
TBool iAppending;
|
|
220 |
|
|
221 |
HBufC* iIbyFile;
|
|
222 |
TInt iReserved;
|
|
223 |
|
|
224 |
};
|
|
225 |
|
|
226 |
#endif //CBSSTORAGEMANAGER_H
|