|
1 /* |
|
2 * Copyright (c) 2002-2007 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: A store that doesn't have a cache in the TSY side. |
|
15 * Uses ETel RMobilePhoneBookStore |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include "CBasicStore.h" |
|
23 |
|
24 #include "VPbkSimStoreImplError.h" |
|
25 #include "CPhone.h" |
|
26 #include "CMultipleReadCmd.h" |
|
27 #include "CWriteCmd.h" |
|
28 #include "CDeleteCmd.h" |
|
29 #include "TVPbkSimStoreProperty.h" |
|
30 #include "CVPbkSimCommandStore.h" |
|
31 #include "CSequentialCompositeCmd.h" |
|
32 |
|
33 // From VPbkSimStoreCommon |
|
34 #include <RVPbkStreamedIntArray.h> |
|
35 |
|
36 // System includes |
|
37 #include <etelmm.h> |
|
38 |
|
39 // From VPbkEng |
|
40 #include <VPbkDebug.h> |
|
41 |
|
42 namespace VPbkSimStoreImpl { |
|
43 |
|
44 // ============================ MEMBER FUNCTIONS =============================== |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // CBasicStore::CBasicStore |
|
48 // C++ default constructor can NOT contain any code, that |
|
49 // might leave. |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CBasicStore::CBasicStore( TStoreParams& aParams ) |
|
53 : CStoreBase( aParams ), |
|
54 iETelInfoPckg( iETelStoreInfo ) |
|
55 { |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CBasicStore::ConstructL |
|
60 // Symbian 2nd phase constructor can leave. |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 void CBasicStore::ConstructL() |
|
64 { |
|
65 CStoreBase::ConstructL(); |
|
66 } |
|
67 |
|
68 // Destructor |
|
69 CBasicStore::~CBasicStore() |
|
70 { |
|
71 CancelRequests(); |
|
72 iETelStore.Close(); |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CBasicStore::SaveL |
|
77 // ----------------------------------------------------------------------------- |
|
78 // |
|
79 MVPbkSimStoreOperation* CBasicStore::SaveL( const TDesC8& aData, |
|
80 TInt& aSimIndex, MVPbkSimContactObserver& aObserver ) |
|
81 { |
|
82 CWriteCmd* cmd = CWriteCmd::NewL( *this, aData, aSimIndex, aObserver ); |
|
83 cmd->Execute(); |
|
84 return cmd; |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CBasicStore::DeleteL |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 MVPbkSimStoreOperation* CBasicStore::DeleteL( |
|
92 RVPbkStreamedIntArray& aSimIndexes, |
|
93 MVPbkSimContactObserver& aObserver ) |
|
94 { |
|
95 CDeleteCmd* cmd = CDeleteCmd::NewL( *this, aSimIndexes, aObserver ); |
|
96 cmd->Execute(); |
|
97 return cmd; |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // CBasicStore::GetGsmStoreProperties |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 TInt CBasicStore::GetGsmStoreProperties( |
|
105 TVPbkGsmStoreProperty& aGsmProperties ) const |
|
106 { |
|
107 aGsmProperties.iCaps = ConvertETelStoreCaps( iETelStoreInfo.iCaps ); |
|
108 aGsmProperties.iMaxNumLength = iETelStoreInfo.iMaxNumLength; |
|
109 aGsmProperties.iMaxTextLength = iETelStoreInfo.iMaxTextLength; |
|
110 aGsmProperties.iTotalEntries = iETelStoreInfo.iTotalEntries; |
|
111 aGsmProperties.iUsedEntries = iETelStoreInfo.iUsedEntries; |
|
112 return KErrNone; |
|
113 } |
|
114 |
|
115 // ----------------------------------------------------------------------------- |
|
116 // CBasicStore::DestroyAllCommands |
|
117 // ----------------------------------------------------------------------------- |
|
118 // |
|
119 TInt CBasicStore::GetUSimStoreProperties( |
|
120 TVPbkUSimStoreProperty& aUSimProperties ) const |
|
121 { |
|
122 aUSimProperties.iMaxAnrLength = KVPbkSimStorePropertyUndefined; |
|
123 aUSimProperties.iMaxEmailLength = KVPbkSimStorePropertyUndefined; |
|
124 aUSimProperties.iMaxGroupNameLength = KVPbkSimStorePropertyUndefined; |
|
125 aUSimProperties.iMaxNumOfAnrs = KVPbkSimStorePropertyUndefined; |
|
126 aUSimProperties.iMaxNumOfEmails = KVPbkSimStorePropertyUndefined; |
|
127 aUSimProperties.iMaxNumOfGroupNames = KVPbkSimStorePropertyUndefined; |
|
128 aUSimProperties.iMaxNumOfScndNames = KVPbkSimStorePropertyUndefined; |
|
129 aUSimProperties.iMaxScndNameLength = KVPbkSimStorePropertyUndefined; |
|
130 return KErrNone; |
|
131 } |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // CBasicStore::ETelStoreBase |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 RMobilePhoneStore& CBasicStore::ETelStoreBase() |
|
138 { |
|
139 return iETelStore; |
|
140 } |
|
141 |
|
142 // ----------------------------------------------------------------------------- |
|
143 // CBasicStore::ETelStoreInfo |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 RMobilePhoneStore::TMobilePhoneStoreInfoV1& CBasicStore::ETelStoreInfo() |
|
147 { |
|
148 return iETelStoreInfo; |
|
149 } |
|
150 |
|
151 // ----------------------------------------------------------------------------- |
|
152 // CBasicStore::ETelStoreInfoPackge |
|
153 // ----------------------------------------------------------------------------- |
|
154 // |
|
155 TDes8& CBasicStore::ETelStoreInfoPackge() |
|
156 { |
|
157 return iETelInfoPckg; |
|
158 } |
|
159 |
|
160 // ----------------------------------------------------------------------------- |
|
161 // CBasicStore::OpenETelStoreL |
|
162 // ----------------------------------------------------------------------------- |
|
163 // |
|
164 void CBasicStore::OpenETelStoreL() |
|
165 { |
|
166 // Opens the RMobilePhoneBookStore subsubsession. |
|
167 // params: phone, store name and store type. |
|
168 User::LeaveIfError( iETelStore.Open( Phone().ETelPhone(), |
|
169 ETelName() /*, ETelStoreType( Identifier() )*/ ) ); |
|
170 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING( |
|
171 "VPbkSimStoreImpl: RMobilePhoneBookStore::Open h%d %S"), |
|
172 iETelStore.SubSessionHandle(),&ETelName()); |
|
173 } |
|
174 |
|
175 // ----------------------------------------------------------------------------- |
|
176 // CBasicStore::OpenETelStoreL |
|
177 // ----------------------------------------------------------------------------- |
|
178 // |
|
179 void CBasicStore::CloseETelStore() |
|
180 { |
|
181 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING( |
|
182 "VPbkSimStoreImpl: RMobilePhoneBookStore::Close h%d %S"), |
|
183 iETelStore.SubSessionHandle(), &ETelName()); |
|
184 iETelStore.Close(); |
|
185 } |
|
186 |
|
187 // ----------------------------------------------------------------------------- |
|
188 // CBasicStore::CreateInitCommandL |
|
189 // ----------------------------------------------------------------------------- |
|
190 // |
|
191 MVPbkSimCommand* CBasicStore::CreateInitCommandL( |
|
192 MVPbkSimCommandObserver& aObserver ) |
|
193 { |
|
194 // Create a init command chain |
|
195 CCompositeCmdBase* cmdChain = CSequentialCompositeCmd::NewLC(); |
|
196 cmdChain->AddObserverL( aObserver ); |
|
197 |
|
198 // Get phonebook information to know the current state of the phonebook |
|
199 AddGetInfoCmdToChainL( *cmdChain ); |
|
200 |
|
201 // Start reading contacts after the total amount of contacts is known |
|
202 AddMultipleReadCmdToChainL( *cmdChain, KErrNotFound, KErrNotFound ); |
|
203 |
|
204 CleanupStack::Pop( cmdChain ); |
|
205 return cmdChain; |
|
206 } |
|
207 |
|
208 // ----------------------------------------------------------------------------- |
|
209 // CBasicStore::CreateUpdateCommandL |
|
210 // ----------------------------------------------------------------------------- |
|
211 // |
|
212 MVPbkSimCommand* CBasicStore::CreateUpdateCommandL( TInt aSimIndex ) |
|
213 { |
|
214 // Create a update command chain |
|
215 CCompositeCmdBase* cmdChain = CSequentialCompositeCmd::NewLC(); |
|
216 |
|
217 // Read the changed contact |
|
218 AddMultipleReadCmdToChainL( *cmdChain, aSimIndex, aSimIndex ); |
|
219 |
|
220 // Get phonebook information to know the current state of the phonebook |
|
221 AddGetInfoCmdToChainL( *cmdChain ); |
|
222 |
|
223 CleanupStack::Pop( cmdChain ); |
|
224 return cmdChain; |
|
225 } |
|
226 |
|
227 // ----------------------------------------------------------------------------- |
|
228 // CBasicStore::CreateUpdateCommandUsingRefL |
|
229 // ----------------------------------------------------------------------------- |
|
230 // |
|
231 MVPbkSimCommand* CBasicStore::CreateUpdateCommandUsingRefL( TInt& aSimIndexRef ) |
|
232 { |
|
233 // Create a update command chain |
|
234 CCompositeCmdBase* cmdChain = CSequentialCompositeCmd::NewLC(); |
|
235 |
|
236 // Read the changed contact |
|
237 cmdChain->AddSubCommandL( |
|
238 CMultipleReadCmd::NewLC( *this, aSimIndexRef ) ); |
|
239 CleanupStack::Pop(); // CMultipleReadCmd |
|
240 |
|
241 // Get phonebook information to know the current state of the phonebook |
|
242 AddGetInfoCmdToChainL( *cmdChain ); |
|
243 |
|
244 CleanupStack::Pop( cmdChain ); |
|
245 return cmdChain; |
|
246 } |
|
247 |
|
248 // ----------------------------------------------------------------------------- |
|
249 // CBasicStore::AddMultipleReadCmdToChainL |
|
250 // ----------------------------------------------------------------------------- |
|
251 // |
|
252 void CBasicStore::AddMultipleReadCmdToChainL( CCompositeCmdBase& aCmdChain, |
|
253 TInt aFromSimIndex, TInt aToSimIndex ) |
|
254 { |
|
255 CMultipleReadCmd* readCmd = NULL; |
|
256 if ( aFromSimIndex != KErrNotFound && aToSimIndex != KErrNotFound ) |
|
257 { |
|
258 readCmd = CMultipleReadCmd::NewLC( *this, aFromSimIndex, |
|
259 aToSimIndex ); |
|
260 } |
|
261 else |
|
262 { |
|
263 readCmd = CMultipleReadCmd::NewLC( *this ); |
|
264 } |
|
265 |
|
266 aCmdChain.AddSubCommandL( readCmd ); |
|
267 CleanupStack::Pop( readCmd ); |
|
268 } |
|
269 } // namespace VPbkSimStoreImpl |
|
270 // End of File |