|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Set of helpers to retireve etelmm lists |
|
15 // Contains the CTestCanceller class declaration. |
|
16 // |
|
17 // |
|
18 |
|
19 /** |
|
20 @file |
|
21 @internalTechnology |
|
22 */ |
|
23 |
|
24 |
|
25 #ifndef LISTRETRIEVALHELPERS_H |
|
26 #define LISTRETRIEVALHELPERS_H |
|
27 |
|
28 #include <e32base.h> |
|
29 #include "etelmm.h" |
|
30 #include <mmretrieve.h> |
|
31 |
|
32 //canceller class that is used to cancel an outstanding list retrieval operation |
|
33 class CTestCanceller : public CAsyncOneShot |
|
34 { |
|
35 public: |
|
36 CTestCanceller(CActive*); |
|
37 ~CTestCanceller(); |
|
38 private: |
|
39 |
|
40 void ConstructL(); |
|
41 void RunL(); |
|
42 private: |
|
43 CActive* iRetrieve;// not owned by this |
|
44 }; |
|
45 |
|
46 const TInt ECancelAfterStart = 1; |
|
47 //Base helper class for retrieving etelmm lists. |
|
48 //NOTE: CRetrieveListHelperBase owns the list and therefore it should not be explicitly deleted. |
|
49 //Usage: The helper class encaspulates all the fucntionality needed to retrieve a list. It will create & install |
|
50 //an active scheuler if required and will delete it on cleaning up the object. |
|
51 /* |
|
52 Example instantiation, usage & deletion |
|
53 |
|
54 CRetrieveMobilePhoneSmsListExec* gsmsmslist = CRetrieveMobilePhoneSmsListHelper::NewL(store); |
|
55 CleanupStack::PushL(gsmsmslist); |
|
56 CMobilePhoneGsmSmsList* list = gsmsmslist->DoGetList(err, ECancelAfterStart); |
|
57 //list owned by CRetrieveMobilePhoneSmsListExec an therefore does not need pushing onto cleanup stack or explicitly deleting. |
|
58 CleanupStack::PopAndDestroy(); //gsmsmslist |
|
59 */ |
|
60 |
|
61 template<class TRetriever, class TList, class TSubSess> |
|
62 class CRetrieveListHelperBase : public CActive |
|
63 { |
|
64 public: |
|
65 ~CRetrieveListHelperBase(); |
|
66 |
|
67 public: |
|
68 inline void CancelListRetrieval(); |
|
69 inline TList* DoGetList(TInt& aCompletionErr, TInt aCancelAfterStart = 0); |
|
70 |
|
71 protected: //pure virtuals |
|
72 virtual void CreateEtelRetrieverL() = 0; //implement this to create the etelmm list retrieval object |
|
73 virtual void StartListRetrieval() = 0; //implement this to start list retrieval |
|
74 virtual TAny* GetListL() = 0; //implement this to get the list returned from the retrieval |
|
75 |
|
76 protected: |
|
77 CRetrieveListHelperBase(TSubSess& aPhone); |
|
78 inline TList* RetrieveListAndCompletionError(TInt& aCompletionError); |
|
79 void ConstructL(); |
|
80 virtual void RunL(); |
|
81 virtual void DoCancel(); |
|
82 |
|
83 protected: |
|
84 TRetriever* iRetrieve; //owned |
|
85 TSubSess& iSubSess; //not owned |
|
86 private: |
|
87 CActiveScheduler* iScheduler; //owned |
|
88 CTestCanceller* iCanceller; //owned |
|
89 TList* iList; //owned |
|
90 }; |
|
91 |
|
92 template<class TRetriever, class TList, class TSubSess> |
|
93 inline TList* CRetrieveListHelperBase<TRetriever, TList, TSubSess>::DoGetList(TInt& aCompletionErr, TInt aCancelAfterStart) |
|
94 { |
|
95 delete iList; //delete old list to allow multiple list retrievals off same instance. |
|
96 iList = NULL; |
|
97 StartListRetrieval(); |
|
98 SetActive(); |
|
99 if(aCancelAfterStart) |
|
100 { |
|
101 CancelListRetrieval(); |
|
102 } |
|
103 CActiveScheduler::Start(); //start scheduler |
|
104 //get results |
|
105 return RetrieveListAndCompletionError(aCompletionErr); |
|
106 } |
|
107 |
|
108 template<class TRetriever, class TList, class TSubSess> |
|
109 inline void CRetrieveListHelperBase<TRetriever, TList, TSubSess>::CancelListRetrieval() |
|
110 { |
|
111 iCanceller->Call(); |
|
112 } |
|
113 |
|
114 template<class TRetriever, class TList, class TSubSess> |
|
115 inline TList* CRetrieveListHelperBase<TRetriever, TList, TSubSess>::RetrieveListAndCompletionError(TInt& aCompletionError) |
|
116 { |
|
117 aCompletionError = iStatus.Int(); |
|
118 //delete any old lists |
|
119 delete iList; |
|
120 TRAP_IGNORE(iList = static_cast<TList*>(GetListL())); |
|
121 return iList; |
|
122 } |
|
123 |
|
124 // |
|
125 // enum will be used for CRetrieveMobilePhoneDetectedNetworksHelper class |
|
126 enum TListVersion |
|
127 /** |
|
128 * This List is used by DetecetedNetworks and NAM store list retriever objects. |
|
129 */ |
|
130 { |
|
131 ERetrieveListV1, |
|
132 ERetrieveListV2, |
|
133 ERetrieveListV4, |
|
134 ERetrieveListV5, |
|
135 ERetrieveListV8, |
|
136 }; |
|
137 //Declarations for concrete implementations of CRetrieveListHelper |
|
138 //One for each CRetrieveMobilePhoneXXX |
|
139 typedef CRetrieveListHelperBase<CRetrieveMobilePhoneDetectedNetworks, CMobilePhoneNetworkList, RMobilePhone> CRetrieveMobilePhoneDetectedNetworksExec; |
|
140 class CRetrieveMobilePhoneDetectedNetworksHelper : public CRetrieveListHelperBase<CRetrieveMobilePhoneDetectedNetworks, CMobilePhoneNetworkList, RMobilePhone> |
|
141 { |
|
142 public: |
|
143 static CRetrieveMobilePhoneDetectedNetworksExec* NewL(RMobilePhone& aSubSess, TListVersion aListNumber); |
|
144 protected: |
|
145 CRetrieveMobilePhoneDetectedNetworksHelper(RMobilePhone& aPhone,TListVersion aListNumber); |
|
146 protected: //from CRetrieveListHelper |
|
147 virtual void CreateEtelRetrieverL(); |
|
148 virtual void StartListRetrieval(); |
|
149 virtual TAny* GetListL(); |
|
150 private: |
|
151 TListVersion iListVersionToRetrieve; |
|
152 }; |
|
153 // |
|
154 typedef CRetrieveListHelperBase<CRetrieveMobilePhoneSmsList, CMobilePhoneGsmSmsList, RMobilePhoneStore> CRetrieveMobilePhoneSmsListExec; |
|
155 class CRetrieveMobilePhoneSmsListHelper : public CRetrieveListHelperBase<CRetrieveMobilePhoneSmsList, CMobilePhoneGsmSmsList, RMobilePhoneStore> |
|
156 { |
|
157 public: |
|
158 static CRetrieveMobilePhoneSmsListExec* NewL(RMobilePhoneStore& aSubSess, TInt aStartIndex=-1, TInt aBatchSize=-1); |
|
159 protected: |
|
160 CRetrieveMobilePhoneSmsListHelper(RMobilePhoneStore& aSubSess, TInt aStartIndex, TInt aBatchSize); |
|
161 protected: //from CRetrieveListHelper |
|
162 virtual void CreateEtelRetrieverL(); |
|
163 virtual void StartListRetrieval(); |
|
164 virtual TAny* GetListL(); |
|
165 private: |
|
166 TInt iStartIndex; |
|
167 TInt iBatchSize; |
|
168 }; |
|
169 // |
|
170 typedef CRetrieveListHelperBase<CRetrieveMobilePhoneCFList, CMobilePhoneCFList, RMobilePhone> CRetrieveMobilePhoneCFListExec; |
|
171 class CRetrieveMobilePhoneCFListHelper : public CRetrieveListHelperBase<CRetrieveMobilePhoneCFList, CMobilePhoneCFList, RMobilePhone> |
|
172 { |
|
173 public: |
|
174 static CRetrieveMobilePhoneCFListExec* NewL(RMobilePhone& aSubSess, RMobilePhone::TMobilePhoneCFCondition aCondition, RMobilePhone::TMobileService aServiceGroup,RMobilePhone::TMobileInfoLocation aLocation = RMobilePhone::EInfoLocationCachePreferred ); |
|
175 protected: |
|
176 CRetrieveMobilePhoneCFListHelper(RMobilePhone& aPhone, RMobilePhone::TMobilePhoneCFCondition aCondition, RMobilePhone::TMobileService aServiceGroup,RMobilePhone::TMobileInfoLocation aLocation = RMobilePhone::EInfoLocationCachePreferred); |
|
177 protected: //from CRetrieveListHelper |
|
178 virtual void CreateEtelRetrieverL(); |
|
179 virtual void StartListRetrieval(); |
|
180 virtual TAny* GetListL(); |
|
181 private: |
|
182 RMobilePhone::TMobilePhoneCFCondition iCondition; |
|
183 RMobilePhone::TMobileService iServiceGroup; |
|
184 RMobilePhone::TMobileInfoLocation iLocation; |
|
185 }; |
|
186 // |
|
187 typedef CRetrieveListHelperBase<CRetrieveMobilePhoneCBList, CMobilePhoneCBList, RMobilePhone> CRetrieveMobilePhoneCBListExec; |
|
188 class CRetrieveMobilePhoneCBListHelper : public CRetrieveListHelperBase<CRetrieveMobilePhoneCBList, CMobilePhoneCBList, RMobilePhone> |
|
189 { |
|
190 public: |
|
191 static CRetrieveMobilePhoneCBListExec* NewL(RMobilePhone& aSubSess, RMobilePhone::TMobilePhoneCBCondition aCondition, RMobilePhone::TMobileInfoLocation aLocation); |
|
192 protected: |
|
193 CRetrieveMobilePhoneCBListHelper(RMobilePhone& aPhone, RMobilePhone::TMobilePhoneCBCondition aCondition,RMobilePhone::TMobileInfoLocation aLocation); |
|
194 protected: //from CRetrieveListHelper |
|
195 virtual void CreateEtelRetrieverL(); |
|
196 virtual void StartListRetrieval(); |
|
197 virtual TAny* GetListL(); |
|
198 private: |
|
199 RMobilePhone::TMobilePhoneCBCondition iCondition; |
|
200 RMobilePhone::TMobileInfoLocation iLocation; |
|
201 }; |
|
202 |
|
203 // |
|
204 typedef CRetrieveListHelperBase<CRetrieveMobilePhoneCWList, CMobilePhoneCWList, RMobilePhone> CRetrieveMobilePhoneCWListExec; |
|
205 class CRetrieveMobilePhoneCWListHelper : public CRetrieveListHelperBase<CRetrieveMobilePhoneCWList, CMobilePhoneCWList, RMobilePhone> |
|
206 { |
|
207 public: |
|
208 static CRetrieveMobilePhoneCWListExec* NewL(RMobilePhone& aSubSess); |
|
209 protected: |
|
210 CRetrieveMobilePhoneCWListHelper(RMobilePhone& aPhone); |
|
211 protected: //from CRetrieveListHelper |
|
212 virtual void CreateEtelRetrieverL(); |
|
213 virtual void StartListRetrieval(); |
|
214 virtual TAny* GetListL(); |
|
215 }; |
|
216 |
|
217 |
|
218 // |
|
219 typedef CRetrieveListHelperBase<CRetrieveMobilePhoneCcbsList, CMobilePhoneCcbsList, RMobilePhone> CRetrieveMobilePhoneCcbsListExec; |
|
220 class CRetrieveMobilePhoneCcbsListHelper : public CRetrieveListHelperBase<CRetrieveMobilePhoneCcbsList, CMobilePhoneCcbsList, RMobilePhone> |
|
221 { |
|
222 public: |
|
223 static CRetrieveMobilePhoneCcbsListExec* NewL(RMobilePhone& aSubSess); |
|
224 protected: |
|
225 CRetrieveMobilePhoneCcbsListHelper(RMobilePhone& aPhone); |
|
226 protected: //from CRetrieveListHelper |
|
227 virtual void CreateEtelRetrieverL(); |
|
228 virtual void StartListRetrieval(); |
|
229 virtual TAny* GetListL(); |
|
230 }; |
|
231 |
|
232 |
|
233 // |
|
234 typedef CRetrieveListHelperBase<CRetrieveMobilePhoneSmspList, CMobilePhoneSmspList, RMobileSmsMessaging> CRetrieveMobilePhoneSmspListExec; |
|
235 class CRetrieveMobilePhoneSmspListHelper : public CRetrieveListHelperBase<CRetrieveMobilePhoneSmspList, CMobilePhoneSmspList, RMobileSmsMessaging> |
|
236 { |
|
237 public: |
|
238 static CRetrieveMobilePhoneSmspListExec* NewL(RMobileSmsMessaging& aSubSess); |
|
239 protected: |
|
240 CRetrieveMobilePhoneSmspListHelper(RMobileSmsMessaging& aPhone); |
|
241 protected: //from CRetrieveListHelper |
|
242 virtual void CreateEtelRetrieverL(); |
|
243 virtual void StartListRetrieval(); |
|
244 virtual TAny* GetListL(); |
|
245 }; |
|
246 |
|
247 |
|
248 // |
|
249 typedef CRetrieveListHelperBase<CRetrieveMobilePhoneBroadcastIdList, CMobilePhoneBroadcastIdList, RMobileBroadcastMessaging> CRetrieveMobilePhoneBroadcastIdListExec; |
|
250 class CRetrieveMobilePhoneBroadcastIdListHelper : public CRetrieveListHelperBase<CRetrieveMobilePhoneBroadcastIdList, CMobilePhoneBroadcastIdList, RMobileBroadcastMessaging> |
|
251 { |
|
252 public: |
|
253 static CRetrieveMobilePhoneBroadcastIdListExec* NewL(RMobileBroadcastMessaging& aSubSess,RMobileBroadcastMessaging::TMobileBroadcastIdType aIdType); |
|
254 protected: |
|
255 CRetrieveMobilePhoneBroadcastIdListHelper(RMobileBroadcastMessaging& aPhone, RMobileBroadcastMessaging::TMobileBroadcastIdType aIdType); |
|
256 protected: //from CRetrieveListHelper |
|
257 virtual void CreateEtelRetrieverL(); |
|
258 virtual void StartListRetrieval(); |
|
259 virtual TAny* GetListL(); |
|
260 private: |
|
261 RMobileBroadcastMessaging::TMobileBroadcastIdType iIdType; |
|
262 }; |
|
263 |
|
264 |
|
265 |
|
266 // |
|
267 |
|
268 // |
|
269 typedef CRetrieveListHelperBase<CRetrieveMobilePhoneNamList, CMobilePhoneNamList, RMobilePhoneStore> CRetrieveMobilePhoneNamListExec; |
|
270 class CRetrieveMobilePhoneNamListHelper : public CRetrieveListHelperBase<CRetrieveMobilePhoneNamList, CMobilePhoneNamList, RMobilePhoneStore> |
|
271 { |
|
272 public: |
|
273 static CRetrieveMobilePhoneNamListExec* NewL(RMobilePhoneStore& aSubSess, TInt aNamId, TListVersion aNamList); |
|
274 protected: |
|
275 CRetrieveMobilePhoneNamListHelper(RMobilePhoneStore& aPhone,TInt iNamId, TListVersion iNamList); |
|
276 protected: //from CRetrieveListHelper |
|
277 virtual void CreateEtelRetrieverL(); |
|
278 virtual void StartListRetrieval(); |
|
279 virtual TAny* GetListL(); |
|
280 private: |
|
281 TInt iNamId; |
|
282 TListVersion iListVersionToRetrieve; |
|
283 }; |
|
284 |
|
285 |
|
286 // |
|
287 typedef CRetrieveListHelperBase<CRetrieveMobilePhoneONList, CMobilePhoneONList, RMobilePhoneStore> CRetrieveMobilePhoneONListExec; |
|
288 class CRetrieveMobilePhoneONListHelper : public CRetrieveListHelperBase<CRetrieveMobilePhoneONList, CMobilePhoneONList, RMobilePhoneStore> |
|
289 { |
|
290 public: |
|
291 static CRetrieveMobilePhoneONListExec* NewL(RMobilePhoneStore& aSubSess); |
|
292 protected: |
|
293 CRetrieveMobilePhoneONListHelper(RMobilePhoneStore& aPhone); |
|
294 protected: //from CRetrieveListHelper |
|
295 virtual void CreateEtelRetrieverL(); |
|
296 virtual void StartListRetrieval(); |
|
297 virtual TAny* GetListL(); |
|
298 }; |
|
299 |
|
300 |
|
301 // |
|
302 |
|
303 // |
|
304 typedef CRetrieveListHelperBase<CRetrieveMobilePhoneENList, CMobilePhoneENList, RMobilePhoneStore> CRetrieveMobilePhoneENListExec; |
|
305 class CRetrieveMobilePhoneENListHelper : public CRetrieveListHelperBase<CRetrieveMobilePhoneENList, CMobilePhoneENList, RMobilePhoneStore> |
|
306 { |
|
307 public: |
|
308 static CRetrieveMobilePhoneENListExec* NewL(RMobilePhoneStore& aSubSess); |
|
309 protected: |
|
310 CRetrieveMobilePhoneENListHelper(RMobilePhoneStore& aPhone); |
|
311 protected: //from CRetrieveListHelper |
|
312 virtual void CreateEtelRetrieverL(); |
|
313 virtual void StartListRetrieval(); |
|
314 virtual TAny* GetListL(); |
|
315 }; |
|
316 |
|
317 |
|
318 // |
|
319 |
|
320 // |
|
321 typedef CRetrieveListHelperBase<CRetrieveMobilePhonePreferredNetworks, CMobilePhoneStoredNetworkList, RMobilePhone> CRetrieveMobilePhonePreferredNetworksExec; |
|
322 class CRetrieveMobilePhonePreferredNetworksHelper : public CRetrieveListHelperBase<CRetrieveMobilePhonePreferredNetworks, CMobilePhoneStoredNetworkList, RMobilePhone> |
|
323 { |
|
324 public: |
|
325 static CRetrieveMobilePhonePreferredNetworksExec* NewL(RMobilePhone& aSubSess); |
|
326 protected: |
|
327 CRetrieveMobilePhonePreferredNetworksHelper(RMobilePhone& aPhone); |
|
328 protected: //from CRetrieveListHelper |
|
329 virtual void CreateEtelRetrieverL(); |
|
330 virtual void StartListRetrieval(); |
|
331 virtual TAny* GetListL(); |
|
332 }; |
|
333 |
|
334 |
|
335 // |
|
336 |
|
337 #endif //LISTRETRIEVALHELPERS_H |