|
1 /* |
|
2 * Copyright (c) 2010 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: List query dialog suitable for verifier plug-in use. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "lpdglobalplugindialog.h" |
|
21 #include "lpddlgobserver.h" |
|
22 #include "lpdrequestorprocessor.h" |
|
23 |
|
24 #include <lbs/EPos_CPosContactRequestor.h> |
|
25 #include <lbs/EPos_CPosServiceRequestor.h> |
|
26 #include <lbs/EPos_CPosRequestor.h> |
|
27 #include <hbsymbianvariant.h> |
|
28 #include <hbtextresolversymbian.h> |
|
29 #include <systemtoneservice.h> |
|
30 #include <e32des16.h> |
|
31 |
|
32 _LIT(KNotifReqSeperator,","); |
|
33 _LIT(KHeadingKey, "heading"); |
|
34 _LIT(KQueryTextKey, "queryText"); |
|
35 _LIT(KQueryText2Key, "queryText2"); |
|
36 _LIT(KRequestorKey, "requestor"); |
|
37 _LIT(KVerificationDlgType, "hb.posverifiction.dialog/1.0"); |
|
38 _LIT(KLocTsFileName, "lilocationmw_"); |
|
39 _LIT(KLocTsFilePath, "z://resource/qt/translations/"); |
|
40 _LIT(KLocTsAFileAltPath, "c://resource/"); |
|
41 //Translation String Ids |
|
42 //Verification Dialog |
|
43 _LIT(KRequestHeading, "txt_loe_title_location_request"); |
|
44 _LIT(KSingleshotDecisionRejected, "txt_loe_info_your_location_will_not_be_shared_by_d"); |
|
45 _LIT(KSingleshotDecisionAccepted, "txt_loe_info_your_location_will_be_shared_by_defau"); |
|
46 _LIT(KSingleshotDecisionNotAvailable, "txt_loe_info_your_location_will_be_shared_with"); |
|
47 _LIT(KPeriodicDecisionRejected, "txt_loe_info_your_location_will_not_be_shared_peri"); |
|
48 _LIT(KPeriodicDecisionAccepted, "txt_loe_info_your_location_will_be_shared_periodic"); |
|
49 _LIT(KPeriodicDecisionNotAvailable, "txt_loe_info_you_location_will_be_shared_periodica"); |
|
50 _LIT(KRequestorText, "txt_loe_info_location_was_requested_by"); |
|
51 _LIT(KUnknownRequestor, "txt_loe_info_unknown_requestor"); |
|
52 //Notification |
|
53 _LIT(KNotificationNotSent, "txt_loe_dpophead_your_location_not_sent_to"); |
|
54 _LIT(KNotificationSent, "txt_loe_dpophead_your_location_sent_to"); |
|
55 |
|
56 const TInt KNotificationTimeout = 15000; |
|
57 const TInt KMaxSize = 1024; |
|
58 const TInt KVariantMaxSize = 256; |
|
59 // ============================ MEMBER FUNCTIONS =============================== |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CLpdGlobalPluginDialog::CLpdGlobalPluginDialog |
|
63 // C++ default constructor can NOT contain any code, that |
|
64 // might leave. |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 CLpdGlobalPluginDialog::CLpdGlobalPluginDialog( |
|
68 MLpdDlgObserver& aCallBack |
|
69 ) |
|
70 : iCallBack( aCallBack ), |
|
71 iMsgBox(NULL), |
|
72 iNotification(NULL), |
|
73 iRequestInfo(NULL) |
|
74 { |
|
75 } |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CLpdGlobalPluginDialog::ConstructL |
|
79 // Two-phased constructor. |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 void CLpdGlobalPluginDialog::ConstructL() |
|
83 { |
|
84 iMsgBox = CHbDeviceDialogSymbian::NewL(); |
|
85 iNotification = CHbDeviceNotificationDialogSymbian::NewL(this); |
|
86 TBool result = |
|
87 HbTextResolverSymbian::Init(KLocTsFileName, KLocTsFilePath); |
|
88 if (!result) |
|
89 { |
|
90 HbTextResolverSymbian::Init(KLocTsFileName, KLocTsAFileAltPath); |
|
91 } |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CLpdGlobalPluginDialog::NewL |
|
96 // Two-phased constructor. |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 CLpdGlobalPluginDialog* CLpdGlobalPluginDialog::NewL( |
|
100 MLpdDlgObserver& aCallBack) |
|
101 { |
|
102 CLpdGlobalPluginDialog* self = |
|
103 new( ELeave ) CLpdGlobalPluginDialog( aCallBack); |
|
104 CleanupStack::PushL(self); |
|
105 self->ConstructL(); |
|
106 CleanupStack::Pop(self); |
|
107 return self; |
|
108 } |
|
109 |
|
110 // Destructor |
|
111 CLpdGlobalPluginDialog::~CLpdGlobalPluginDialog() |
|
112 { |
|
113 delete iMsgBox; |
|
114 iMsgBox = NULL; |
|
115 |
|
116 delete iNotification; |
|
117 iNotification = NULL; |
|
118 |
|
119 delete iRequestInfo; |
|
120 iRequestInfo=NULL; |
|
121 |
|
122 } |
|
123 |
|
124 |
|
125 // ----------------------------------------------------------------------------- |
|
126 // CLpdGlobalPluginDialog::RunLD |
|
127 // (other items were commented in a header). |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 void CLpdGlobalPluginDialog::RunVerificationQueryL() |
|
131 { |
|
132 mSymbianVariantMap = CHbSymbianVariantMap::NewL(); |
|
133 CleanupStack::PushL(mSymbianVariantMap); |
|
134 |
|
135 AddVerDlgHeadingParamL(); |
|
136 AddQueryTextParamL(); |
|
137 AddRequestorsParamL(); |
|
138 CSystemToneService* sts = CSystemToneService::Create(); |
|
139 iMsgBox->Show(KVerificationDlgType, *mSymbianVariantMap, this); |
|
140 if( sts ) |
|
141 { |
|
142 sts->PlayTone(CSystemToneService::ELocationRequest); |
|
143 } |
|
144 CSystemToneService::Delete(sts); |
|
145 CleanupStack::Pop(mSymbianVariantMap); |
|
146 } |
|
147 |
|
148 void CLpdGlobalPluginDialog::RunNotificationL() |
|
149 { |
|
150 if( EPosDecisionByRequestSource == iRequestInfo->iNotifReason || |
|
151 EPosVerificationTimeout == iRequestInfo->iNotifReason ) |
|
152 { |
|
153 if ( EPosDecisionAccepted == iRequestInfo->iRequestDecision ) |
|
154 { |
|
155 HBufC* title = HbTextResolverSymbian::LoadL(KNotificationSent); |
|
156 CleanupStack::PushL(title); |
|
157 iNotification->SetTitleL(title->Des()); |
|
158 CleanupStack::PopAndDestroy(title); |
|
159 } |
|
160 if( EPosDecisionRejected == iRequestInfo->iRequestDecision ) |
|
161 { |
|
162 HBufC* title = HbTextResolverSymbian::LoadL(KNotificationNotSent); |
|
163 CleanupStack::PushL(title); |
|
164 iNotification->SetTitleL(title->Des()); |
|
165 CleanupStack::PopAndDestroy(title); |
|
166 } |
|
167 } |
|
168 else |
|
169 { |
|
170 // Not supported |
|
171 User::Leave(KErrNotSupported); |
|
172 } |
|
173 TBuf<KMaxSize> buf; |
|
174 |
|
175 TInt count= iRequestInfo->iRequestors.Count(); |
|
176 if( count == 0 ) |
|
177 { |
|
178 HBufC* requestor = HbTextResolverSymbian::LoadL(KUnknownRequestor); |
|
179 CleanupStack::PushL(requestor); |
|
180 buf.Append(requestor->Des()); |
|
181 CleanupStack::PopAndDestroy(requestor); |
|
182 } |
|
183 else |
|
184 { |
|
185 for(TInt i=0;i< count;i++ ) |
|
186 { |
|
187 if(i!=0) |
|
188 { |
|
189 buf.Append(KNotifReqSeperator); |
|
190 } |
|
191 buf.Append(iRequestInfo->iRequestors[i]->RequestorIdString()); |
|
192 } |
|
193 } |
|
194 iNotification->SetTextL(buf); |
|
195 iNotification->SetTimeout(KNotificationTimeout); |
|
196 iNotification->EnableTouchActivation(ETrue); |
|
197 iNotification->ShowL(); |
|
198 } |
|
199 |
|
200 // ----------------------------------------------------------------------------- |
|
201 // CLpdGlobalPluginDialog::SetMessageTextL |
|
202 // (other items were commented in a header). |
|
203 // ----------------------------------------------------------------------------- |
|
204 // |
|
205 void CLpdGlobalPluginDialog::SetRequestInfoL( CLpdRequestorProcessor* aRequestInfo ) |
|
206 { |
|
207 if(iRequestInfo) |
|
208 { |
|
209 // clear and create again if already has been set before |
|
210 delete iRequestInfo; |
|
211 iRequestInfo=NULL; |
|
212 } |
|
213 iRequestInfo=CLpdRequestorProcessor::NewL(); |
|
214 |
|
215 iRequestInfo->iDialogType=aRequestInfo->iDialogType; |
|
216 iRequestInfo->iNotifReason=aRequestInfo->iNotifReason; |
|
217 iRequestInfo->iRequestDecision=aRequestInfo->iRequestDecision; |
|
218 iRequestInfo->iRequestType=aRequestInfo->iRequestType; |
|
219 |
|
220 const RPointerArray<CPosRequestor>& requestors = aRequestInfo->iRequestors; |
|
221 |
|
222 TInt count = requestors.Count(); |
|
223 for(TInt i=0; i< count; i++ ) |
|
224 { |
|
225 CPosRequestor::TRequestorIdFormat idFormat; |
|
226 TPtrC idString; |
|
227 idFormat=requestors[i]->RequestorIdFormat(); |
|
228 idString.Set(requestors[i]->RequestorIdString()); |
|
229 |
|
230 if( CPosRequestor::ERequestorService==requestors[i]->RequestType()) |
|
231 { |
|
232 CPosServiceRequestor* service = CPosServiceRequestor::NewL(idFormat,idString); |
|
233 CleanupStack::PushL(service); |
|
234 // Ownership transferred |
|
235 iRequestInfo->iRequestors.Append(service); |
|
236 CleanupStack::Pop(service); |
|
237 } |
|
238 else |
|
239 { |
|
240 CPosContactRequestor* contact = CPosContactRequestor::NewL(idFormat,idString); |
|
241 CleanupStack::PushL(contact); |
|
242 // Ownership transferred |
|
243 iRequestInfo->iRequestors.Append(contact); |
|
244 CleanupStack::Pop(contact); |
|
245 } |
|
246 |
|
247 } |
|
248 } |
|
249 |
|
250 |
|
251 |
|
252 void CLpdGlobalPluginDialog::Cancel() |
|
253 { |
|
254 // Close any running dialogs if any.Close() doesnt have any effect if dialog is not running |
|
255 isCancelled = ETrue; |
|
256 iMsgBox->Cancel(); |
|
257 iNotification->Close(); |
|
258 } |
|
259 |
|
260 void CLpdGlobalPluginDialog::NotificationDialogActivated( |
|
261 const CHbDeviceNotificationDialogSymbian */*aDialog*/) |
|
262 { |
|
263 // Complete with KErrNone now |
|
264 TRAP_IGNORE(iCallBack.HandleDlgDismissedL( KErrNone )); |
|
265 } |
|
266 |
|
267 void CLpdGlobalPluginDialog::NotificationDialogClosed( |
|
268 const CHbDeviceNotificationDialogSymbian */*aDialog*/, |
|
269 TInt aCompletionCode) |
|
270 { |
|
271 TRAP_IGNORE(iCallBack.HandleDlgDismissedL( aCompletionCode )); |
|
272 } |
|
273 |
|
274 void CLpdGlobalPluginDialog::DataReceived(CHbSymbianVariantMap& /*aData*/) |
|
275 { |
|
276 mDissmissed = ETrue; |
|
277 TRAP_IGNORE(iCallBack.HandleDlgDismissedL( KErrAccessDenied )); |
|
278 } |
|
279 |
|
280 void CLpdGlobalPluginDialog::DeviceDialogClosed(TInt /*aCompletionCode*/) |
|
281 { |
|
282 if (!mDissmissed && !isCancelled) |
|
283 { |
|
284 TRAP_IGNORE(iCallBack.HandleDlgDismissedL( KErrNone )); |
|
285 } |
|
286 } |
|
287 |
|
288 void CLpdGlobalPluginDialog::AddVerDlgHeadingParamL() |
|
289 { |
|
290 HBufC* headingText = HbTextResolverSymbian::LoadL(KRequestHeading); |
|
291 CleanupStack::PushL(headingText); |
|
292 CHbSymbianVariant* heading = CHbSymbianVariant::NewL(headingText, |
|
293 CHbSymbianVariant::EDes); |
|
294 CleanupStack::PushL(heading); |
|
295 mSymbianVariantMap->Add(KHeadingKey, heading ); |
|
296 CleanupStack::Pop(heading); |
|
297 CleanupStack::PopAndDestroy(headingText); |
|
298 } |
|
299 |
|
300 void CLpdGlobalPluginDialog::AddQueryTextParamL() |
|
301 { |
|
302 HBufC * value = HBufC::NewL(KVariantMaxSize); |
|
303 CleanupStack::PushL(value); |
|
304 HBufC * value2 = HBufC::NewL(KVariantMaxSize); |
|
305 CleanupStack::PushL(value2); |
|
306 HBufC* requestorText = HbTextResolverSymbian::LoadL(KRequestorText); |
|
307 CleanupStack::PushL(requestorText); |
|
308 |
|
309 if (CPosRequestor::ERequestSingleShot == iRequestInfo->iRequestType) |
|
310 { |
|
311 if (EPosDecisionNotAvailable == iRequestInfo->iRequestDecision) |
|
312 { |
|
313 HBufC* queryText = HbTextResolverSymbian::LoadL( |
|
314 KSingleshotDecisionNotAvailable); |
|
315 CleanupStack::PushL(queryText); |
|
316 value->Des().Copy(queryText->Des()); |
|
317 CleanupStack::PopAndDestroy(queryText); |
|
318 } |
|
319 else if (EPosDecisionAccepted == iRequestInfo->iRequestDecision) |
|
320 { |
|
321 HBufC* queryText = HbTextResolverSymbian::LoadL( |
|
322 KSingleshotDecisionAccepted); |
|
323 CleanupStack::PushL(queryText); |
|
324 value->Des().Copy(queryText->Des()); |
|
325 value2->Des().Copy(requestorText->Des()); |
|
326 CleanupStack::PopAndDestroy(queryText); |
|
327 } |
|
328 else if (EPosDecisionRejected == iRequestInfo->iRequestDecision) |
|
329 { |
|
330 HBufC* queryText = HbTextResolverSymbian::LoadL( |
|
331 KSingleshotDecisionRejected); |
|
332 CleanupStack::PushL(queryText); |
|
333 value->Des().Copy(queryText->Des()); |
|
334 value2->Des().Copy(requestorText->Des()); |
|
335 CleanupStack::PopAndDestroy(queryText); |
|
336 } |
|
337 } |
|
338 |
|
339 else if (CPosRequestor::ERequestPeriodic == iRequestInfo->iRequestType) |
|
340 { |
|
341 if (EPosDecisionNotAvailable == iRequestInfo->iRequestDecision) |
|
342 { |
|
343 HBufC* queryText = HbTextResolverSymbian::LoadL( |
|
344 KPeriodicDecisionNotAvailable); |
|
345 CleanupStack::PushL(queryText); |
|
346 value->Des().Copy(queryText->Des()); |
|
347 CleanupStack::PopAndDestroy(queryText); |
|
348 } |
|
349 else if (EPosDecisionAccepted == iRequestInfo->iRequestDecision) |
|
350 { |
|
351 HBufC* queryText = HbTextResolverSymbian::LoadL( |
|
352 KPeriodicDecisionAccepted); |
|
353 CleanupStack::PushL(queryText); |
|
354 value->Des().Copy(queryText->Des()); |
|
355 value2->Des().Copy(requestorText->Des()); |
|
356 CleanupStack::PopAndDestroy(queryText); |
|
357 } |
|
358 else if (EPosDecisionRejected == iRequestInfo->iRequestDecision) |
|
359 { |
|
360 HBufC* queryText = HbTextResolverSymbian::LoadL( |
|
361 KPeriodicDecisionRejected); |
|
362 CleanupStack::PushL(queryText); |
|
363 value->Des().Copy(queryText->Des()); |
|
364 value2->Des().Copy(requestorText->Des()); |
|
365 CleanupStack::PopAndDestroy(queryText); |
|
366 } |
|
367 } |
|
368 else |
|
369 { |
|
370 // Not supported |
|
371 User::Leave(KErrNotSupported); |
|
372 } |
|
373 |
|
374 CHbSymbianVariant* queryText = CHbSymbianVariant::NewL(value, |
|
375 CHbSymbianVariant::EDes); |
|
376 CleanupStack::PushL(queryText); |
|
377 |
|
378 CHbSymbianVariant* queryText2 = CHbSymbianVariant::NewL(value2, |
|
379 CHbSymbianVariant::EDes); |
|
380 CleanupStack::PushL(queryText2); |
|
381 |
|
382 if (value2->Length()!= 0) |
|
383 { |
|
384 mSymbianVariantMap->Add(KQueryText2Key, queryText2); |
|
385 } |
|
386 mSymbianVariantMap->Add(KQueryTextKey, queryText); |
|
387 CleanupStack::Pop(queryText2); |
|
388 CleanupStack::Pop(queryText); |
|
389 CleanupStack::PopAndDestroy(3); |
|
390 } |
|
391 |
|
392 void CLpdGlobalPluginDialog::AddRequestorsParamL() |
|
393 { |
|
394 |
|
395 CDesC16ArrayFlat* array = new CDesC16ArrayFlat(8); |
|
396 TInt reqCount = iRequestInfo->iRequestors.Count(); |
|
397 if (!reqCount) |
|
398 { |
|
399 HBufC* requestor = HbTextResolverSymbian::LoadL(KUnknownRequestor); |
|
400 CleanupStack::PushL(requestor); |
|
401 array->AppendL(requestor->Des()); |
|
402 CleanupStack::PopAndDestroy(requestor); |
|
403 } |
|
404 else |
|
405 { |
|
406 for (TInt i = 0; i < reqCount; ++i) |
|
407 { |
|
408 array->AppendL(iRequestInfo->iRequestors[i]->RequestorIdString()); |
|
409 } |
|
410 } |
|
411 |
|
412 TInt count = array->MdcaCount(); |
|
413 MDesCArray* marray = static_cast<MDesCArray*> (array); |
|
414 CHbSymbianVariant* requestors = CHbSymbianVariant::NewL(marray, |
|
415 CHbSymbianVariant::EDesArray); |
|
416 mSymbianVariantMap->Add(KRequestorKey, requestors); |
|
417 } |
|
418 |
|
419 // End of file |
|
420 |