|
1 /* |
|
2 * Copyright (c) 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 "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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_NCDSTORAGECLIENT_H |
|
20 #define C_NCDSTORAGECLIENT_H |
|
21 |
|
22 #include <e32base.h> |
|
23 |
|
24 #include "ncdstorageclient.h" |
|
25 #include "ncdstorageowner.h" |
|
26 |
|
27 class CNcdStorage; |
|
28 |
|
29 /** |
|
30 * Storage client implementation |
|
31 * |
|
32 * Each of the provider's clients can have their own storages. |
|
33 * CNcdStorageClient handles all storages of a client. |
|
34 * |
|
35 */ |
|
36 class CNcdStorageClient : public CBase, public MNcdStorageClient, |
|
37 public MNcdStorageOwner |
|
38 { |
|
39 public: |
|
40 |
|
41 /** |
|
42 * Creator |
|
43 * |
|
44 * @param aOwner Owner of this client |
|
45 * @param aUid UID of this client |
|
46 * @return A new storage client |
|
47 */ |
|
48 static CNcdStorageClient* NewL( MNcdStorageOwner& aOwner, |
|
49 const TDesC& aUid ); |
|
50 |
|
51 |
|
52 /** |
|
53 * Creator |
|
54 * |
|
55 * @param aOwner Owner of this client |
|
56 * @param aUid UID of this client |
|
57 * @return A new storage client |
|
58 */ |
|
59 static CNcdStorageClient* NewLC( MNcdStorageOwner& aOwner, |
|
60 const TDesC& aUid ); |
|
61 |
|
62 |
|
63 /** |
|
64 * Destructor |
|
65 */ |
|
66 virtual ~CNcdStorageClient(); |
|
67 |
|
68 |
|
69 public: // From MNcdStorageClient |
|
70 |
|
71 /** |
|
72 * @see MNcdStorageClient::CreateStorageL() |
|
73 */ |
|
74 MNcdStorage& CreateStorageL( const TDesC& aNamespace ); |
|
75 |
|
76 |
|
77 /** |
|
78 * @see MNcdStorageClient::StorageL() |
|
79 */ |
|
80 MNcdStorage& StorageL( const TDesC& aNamespace ); |
|
81 |
|
82 |
|
83 /** |
|
84 * @see MNcdStorageClient::RemoveStorageL() |
|
85 */ |
|
86 void RemoveStorageL( const TDesC& aNamespace ); |
|
87 |
|
88 /** |
|
89 * @see MNcdStorageClient::ClientUid() |
|
90 */ |
|
91 const TDesC& ClientUid() const; |
|
92 |
|
93 |
|
94 /** |
|
95 * @see MNcdStorageClient::NamespacesL() |
|
96 */ |
|
97 MDesCArray* NamespacesLC() const; |
|
98 |
|
99 public: // From MNcdStorageOwner |
|
100 |
|
101 /** |
|
102 * @see MNcdStorageOwner::AppendRoot() |
|
103 */ |
|
104 void AppendRoot( TDes& aPath ) const; |
|
105 |
|
106 |
|
107 /** |
|
108 * @see MNcdStorageOwner::FileSession() |
|
109 */ |
|
110 RFs& FileSession(); |
|
111 |
|
112 |
|
113 /** |
|
114 * @see MNcdStorageOwner::FileManager() |
|
115 */ |
|
116 CFileMan& FileManager(); |
|
117 |
|
118 private: |
|
119 |
|
120 /** |
|
121 * Constructor |
|
122 * |
|
123 * @param aOwner Owner of this client |
|
124 */ |
|
125 CNcdStorageClient( MNcdStorageOwner& aOwner ); |
|
126 |
|
127 |
|
128 void ConstructL( const TDesC& aUid ); |
|
129 |
|
130 |
|
131 /** |
|
132 * Searches for a storage that matches the given namespace |
|
133 * |
|
134 * @param aNamespace |
|
135 * @return Index in iStorages |
|
136 */ |
|
137 TInt FindStorageByNamespace( const TDesC& aNamespace ) const; |
|
138 |
|
139 |
|
140 /** |
|
141 * Creates a storage for each found subdirectory |
|
142 * |
|
143 * @param aPath |
|
144 */ |
|
145 //void CreateStoragesFromFileSystemL( const TDesC& aPath ); |
|
146 |
|
147 |
|
148 /** |
|
149 * Reads namespaces and their corresponding directories from |
|
150 * the namespace file and creates storage clients |
|
151 */ |
|
152 void ReadNamespacesL(); |
|
153 |
|
154 /** |
|
155 * Saves namespaces to disk |
|
156 */ |
|
157 void SaveNamespacesL(); |
|
158 |
|
159 /** |
|
160 * Checks if the given directory is a subdirectory of the root |
|
161 * |
|
162 * @param aDir Directory |
|
163 * @return ETrue if the directory is found |
|
164 */ |
|
165 TBool DirectoryExistsL( const TDesC& aDir ); |
|
166 |
|
167 private: // data |
|
168 |
|
169 MNcdStorageOwner& iOwner; |
|
170 RBuf iUid; |
|
171 RPointerArray<CNcdStorage> iStorages; |
|
172 }; |
|
173 |
|
174 |
|
175 #endif // C_NCDSTORAGECLIENT |