|
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 //mockups below: |
|
19 #include "containerstore.h" |
|
20 #include "containerstorecontentmanager.h" |
|
21 #include "containerstoreutils.h" |
|
22 |
|
23 |
|
24 /*static*/ CContainerStore* CContainerStore::NewL() |
|
25 { |
|
26 CContainerStore* self = new (ELeave) CContainerStore; |
|
27 |
|
28 CleanupStack::PushL( self ); |
|
29 self->ConstructL(); |
|
30 CleanupStack::Pop( self ); |
|
31 |
|
32 return self; |
|
33 } |
|
34 |
|
35 void CContainerStore::ConstructL() |
|
36 { |
|
37 iContentManager = new (ELeave) CContainerStoreContentManager; |
|
38 iUtils = CContainerStoreUtils::NewL(); |
|
39 } |
|
40 |
|
41 CContainerStore::CContainerStore() : |
|
42 iSequence( 0 ), iInTransaction( EFalse ), iLeaveAfter( -1 ) |
|
43 { |
|
44 } |
|
45 |
|
46 CContainerStore::~CContainerStore() |
|
47 { |
|
48 delete iUtils; |
|
49 delete iContentManager; |
|
50 } |
|
51 |
|
52 TContainerId CContainerStore::CreateContainerL( |
|
53 TContainerId aType, |
|
54 TContainerId aParentId, |
|
55 TContainerId aGrandparentId, |
|
56 const TDesC8& aProperties, |
|
57 TContainerId aId ) |
|
58 { |
|
59 SimulateLeaveL(); |
|
60 |
|
61 return 0; |
|
62 } |
|
63 |
|
64 void CContainerStore::CommitContainerL( |
|
65 TContainerId aId, |
|
66 TContainerId aParentId, |
|
67 TContainerId aMailBoxId, |
|
68 MContainerStoreObserver* aObserver, |
|
69 TContainerId aCopiedFromOriginalMsgId ) |
|
70 { |
|
71 SimulateLeaveL(); |
|
72 } |
|
73 |
|
74 void CContainerStore::BeginDatabaseTransactionLC() |
|
75 { |
|
76 SimulateLeaveL(); |
|
77 iInTransaction = ETrue; |
|
78 } |
|
79 |
|
80 void CContainerStore::CommitDatabaseTransactionL() |
|
81 { |
|
82 SimulateLeaveL(); |
|
83 iInTransaction = EFalse; |
|
84 } |
|
85 |
|
86 void CContainerStore::AllocateIdsBlockL( |
|
87 RArray<TContainerId>& aIds, |
|
88 TInt aBlockSize ) |
|
89 { |
|
90 SimulateLeaveL(); |
|
91 for ( TInt i = 0; i < aBlockSize; ++i ) |
|
92 { |
|
93 aIds.Append( ++iSequence ); |
|
94 } |
|
95 } |
|
96 |
|
97 TBool CContainerStore::IsEncryptionEnabled() |
|
98 { |
|
99 return EFalse; |
|
100 } |
|
101 |
|
102 CContainerStoreUtils& CContainerStore::StoreUtils() |
|
103 { |
|
104 return *iUtils; |
|
105 } |
|
106 |
|
107 CContainerStoreContentManager& CContainerStore::ContentManager() |
|
108 { |
|
109 return *iContentManager; |
|
110 } |
|
111 |
|
112 const TDesC& CContainerStore::PrivatePath() const |
|
113 { |
|
114 return iUtils->PrivatePath(); |
|
115 } |
|
116 |
|
117 void CContainerStore::SetLeaveAfter( TInt aLeaveAfter ) |
|
118 { |
|
119 iLeaveAfter = aLeaveAfter; |
|
120 } |
|
121 |
|
122 void CContainerStore::SimulateLeaveL() |
|
123 { |
|
124 if ( 0 == iLeaveAfter ) |
|
125 { |
|
126 User::Leave( KErrGeneral ); |
|
127 } |
|
128 else if ( 0 < iLeaveAfter ) |
|
129 { |
|
130 --iLeaveAfter; |
|
131 } |
|
132 } |
|
133 |
|
134 ///////////////////////////////////// |
|
135 // CContainerStoreContentManager // |
|
136 ///////////////////////////////////// |
|
137 |
|
138 CContainerStoreContentManager::CContainerStoreContentManager() : |
|
139 iLeaveAfter( -1 ) |
|
140 { |
|
141 |
|
142 } |
|
143 |
|
144 void CContainerStoreContentManager::SetLeaveAfter( TInt aLeaveAfter ) |
|
145 { |
|
146 iLeaveAfter = aLeaveAfter; |
|
147 } |
|
148 |
|
149 void CContainerStoreContentManager::SimulateLeaveL() |
|
150 { |
|
151 if ( 0 == iLeaveAfter ) |
|
152 { |
|
153 User::Leave( KErrGeneral ); |
|
154 } |
|
155 else if ( 0 < iLeaveAfter ) |
|
156 { |
|
157 --iLeaveAfter; |
|
158 } |
|
159 } |
|
160 |
|
161 void CContainerStoreContentManager::ReplaceFileWithFileL( |
|
162 RFile& aSource, |
|
163 const TDesC& aTarget ) |
|
164 { |
|
165 SimulateLeaveL(); |
|
166 } |
|
167 |
|
168 void CContainerStoreContentManager::PrependBufferAndMoveFileL( |
|
169 const TDesC& aSource, |
|
170 const TDesC& aTarget, |
|
171 const TDesC8& aPrepend ) |
|
172 { |
|
173 SimulateLeaveL(); |
|
174 } |
|
175 |
|
176 TInt CContainerStoreContentManager::TransferContentFile( |
|
177 TContainerId aId, |
|
178 const TDesC& aContentPath ) |
|
179 { |
|
180 return KErrNone; |
|
181 } |
|
182 |
|
183 |
|
184 /////////////////////////////// |
|
185 // CContainerStoreUtils // |
|
186 /////////////////////////////// |
|
187 |
|
188 CContainerStoreUtils* CContainerStoreUtils::NewL() |
|
189 { |
|
190 |
|
191 CContainerStoreUtils* self = new (ELeave) CContainerStoreUtils(); |
|
192 |
|
193 CleanupStack::PushL( self ); |
|
194 self->ConstructL(); |
|
195 CleanupStack::Pop( self ); |
|
196 |
|
197 return self; |
|
198 } |
|
199 |
|
200 void CContainerStoreUtils::ConstructL() |
|
201 { |
|
202 User::LeaveIfError( iFs.Connect() ); |
|
203 |
|
204 User::LeaveIfError( iPrivatePath.Create( KMaxPath ) ); |
|
205 iFs.PrivatePath( iPrivatePath ); |
|
206 } |
|
207 |
|
208 CContainerStoreUtils::CContainerStoreUtils() |
|
209 { |
|
210 |
|
211 } |
|
212 |
|
213 CContainerStoreUtils::~CContainerStoreUtils() |
|
214 { |
|
215 iPrivatePath.Close(); |
|
216 iFs.Close(); |
|
217 } |
|
218 |
|
219 const TDesC& CContainerStoreUtils::PrivatePath() const |
|
220 { |
|
221 return iPrivatePath; |
|
222 } |
|
223 |
|
224 RFs& CContainerStoreUtils::FileSystem() |
|
225 { |
|
226 return iFs; |
|
227 } |
|
228 |
|
229 void CContainerStoreUtils::LeaveIfLowDiskSpaceL( TUint aBytesToWrite ) |
|
230 { |
|
231 |
|
232 } |