1 /* |
|
2 * Copyright (c) 2005 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: Methods for the SyncML Appserver starter notifier |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <eikenv.h> // Eikon environment |
|
22 #include <SyncMLClient.h> |
|
23 #include <SyncMLClientDS.h> |
|
24 #include <SyncMLClientDM.h> |
|
25 #include <SyncService.h> |
|
26 #include <aknnotewrappers.h> |
|
27 #include <s32mem.h> |
|
28 #include <in_sock.h> |
|
29 #include <StringLoader.h> // Localisation stringloader |
|
30 #include <aknlists.h> |
|
31 #include <avkon.mbg> |
|
32 #include <aknconsts.h> |
|
33 #include <utf.h> |
|
34 #include <SyncMLNotifier.rsg> // Own resources |
|
35 #include "SyncMLDlgNotifier.h" // Class definition |
|
36 #include "SyncMLTimedMessageQuery.h" |
|
37 #include "SyncMLAppLaunchNotifier.h" |
|
38 #include "SyncMLNotifDebug.h" |
|
39 #include "SyncMLTimedInputTextQuery.h" |
|
40 #include "SyncMLTimedDateQuery.h" |
|
41 #include "SyncMLTimedNumberQueryDialog.h" |
|
42 #include "SyncMLAknPopUplist.h" |
|
43 |
|
44 // CONSTANTS |
|
45 const TInt KSyncMLuSecsInSec = 1000000; // Microseconds in a second |
|
46 |
|
47 // ============================ MEMBER FUNCTIONS =============================== |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // CSyncMLDlgNotifier::NewL |
|
51 // Two-phased constructor. |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 CSyncMLDlgNotifier* CSyncMLDlgNotifier::NewL( |
|
55 CSyncMLAppLaunchNotifier* aAppLaunchNotif ) |
|
56 { |
|
57 FLOG( _L("[SmlNotif]\t CSyncMLDlgNotifier::NewL()") ); |
|
58 CSyncMLDlgNotifier* self = new (ELeave) CSyncMLDlgNotifier( aAppLaunchNotif ); |
|
59 CleanupStack::PushL( self ); |
|
60 self->ConstructL(); |
|
61 CleanupStack::Pop( self ); |
|
62 FLOG( _L("[SmlNotif]\t CSyncMLDlgNotifier::NewL() completed") ); |
|
63 return self; |
|
64 } |
|
65 |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // Destructor |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 CSyncMLDlgNotifier::~CSyncMLDlgNotifier() |
|
72 { |
|
73 Cancel(); // Free own resources |
|
74 if(iListItems) |
|
75 { |
|
76 delete iListItems; |
|
77 iListItems = NULL; |
|
78 } |
|
79 if(iChunk.Handle()) |
|
80 { |
|
81 iChunk.Close(); |
|
82 } |
|
83 } |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // CSyncMLDlgNotifier::EnableSyncProgressNoteL |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 void CSyncMLDlgNotifier::EnableSyncProgressNoteL( TBool aEnable ) |
|
90 { |
|
91 FTRACE( FPrint( _L( |
|
92 "[SmlNotif]\t CSyncMLDlgNotifier::EnableSyncProgressNoteL(), aEnable = %d" ), |
|
93 aEnable ) ); |
|
94 |
|
95 TSmlJobId currentJobId( KErrNotFound ); |
|
96 TSmlUsageType usageType; |
|
97 TUint serviceId = 0; |
|
98 RSyncMLSession syncSession; |
|
99 CleanupClosePushL( syncSession ); |
|
100 |
|
101 syncSession.OpenL(); |
|
102 syncSession.CurrentJobL( currentJobId, usageType ); |
|
103 syncSession.Close(); |
|
104 CleanupStack::Pop( &syncSession ); |
|
105 |
|
106 if ( currentJobId != KErrNotFound ) |
|
107 { |
|
108 switch( usageType ) |
|
109 { |
|
110 case ESmlDataSync: |
|
111 serviceId = KDataSyncServiceStart; |
|
112 break; |
|
113 case ESmlDevMan: |
|
114 serviceId = KDevManServiceStart; |
|
115 break; |
|
116 default: |
|
117 User::Leave( KErrArgument ); |
|
118 break; |
|
119 } |
|
120 |
|
121 // There should be a valid pointer to the application launcher |
|
122 // notifier, but we can survive without it. Therefore we'll just |
|
123 // check for it to prevent a crash. |
|
124 if ( iAppLaunchNotif ) |
|
125 { |
|
126 CSyncService* syncService = iAppLaunchNotif->SyncServiceL( serviceId ); |
|
127 if ( syncService ) |
|
128 { |
|
129 syncService->EnableProgressNoteL( aEnable ); |
|
130 } |
|
131 } |
|
132 } |
|
133 else |
|
134 { |
|
135 User::Leave( KErrNotFound ); |
|
136 } |
|
137 FLOG( _L("[SmlNotif]\t CSyncMLDlgNotifier::EnableSyncProgressNoteL() completed") ); |
|
138 } |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // CSyncMLDlgNotifier::RegisterL |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 CSyncMLDlgNotifier::TNotifierInfo CSyncMLDlgNotifier::RegisterL() |
|
145 { |
|
146 FLOG( _L("[SmlNotif]\t CSyncMLDlgNotifier::RegisterL()") ); |
|
147 iInfo.iUid = KSyncMLDlgNotifierUid; |
|
148 iInfo.iChannel = KSmlDlgChannel; |
|
149 iInfo.iPriority = ENotifierPriorityHigh; |
|
150 FLOG( _L("[SmlNotif]\t CSyncMLDlgNotifier::RegisterL() completed") ); |
|
151 return iInfo; |
|
152 } |
|
153 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // CSyncMLDlgNotifier::GetParamsL |
|
156 // Initialize parameters and check if device is already |
|
157 // in registry. Jump to RunL as soon as possible. |
|
158 // ----------------------------------------------------------------------------- |
|
159 // |
|
160 void CSyncMLDlgNotifier::GetParamsL( const TDesC8& aBuffer, |
|
161 TInt aReplySlot, |
|
162 const RMessagePtr2& aMessage ) |
|
163 { |
|
164 FLOG( _L("[SmlNotif]\t CSyncMLDlgNotifier::GetParamsL()") ); |
|
165 const TChar KDRSeparator('-'); |
|
166 const TChar KChoiceItemSeparator(','); |
|
167 if ( iReplySlot != NULL || iNeedToCompleteMessage ) |
|
168 { |
|
169 User::Leave( KErrInUse ); |
|
170 } |
|
171 |
|
172 if ( AutoLockOnL() ) |
|
173 { |
|
174 // The phone is locked, access denied. |
|
175 // Write results back to caller and complete message. |
|
176 aMessage.Complete( KErrLocked ); |
|
177 iNeedToCompleteMessage = EFalse; |
|
178 return; |
|
179 } |
|
180 |
|
181 iMessage = aMessage; |
|
182 iNeedToCompleteMessage = ETrue; |
|
183 iReplySlot = aReplySlot; |
|
184 |
|
185 TSyncMLDlgNotifParams param; |
|
186 TPckgC<TSyncMLDlgNotifParams> pckg( param ); |
|
187 pckg.Set( aBuffer ); |
|
188 iNoteType = pckg().iNoteType; |
|
189 iServerMsg.Copy( pckg().iServerMsg.Left( KSyncMLMaxServerMsgLength ) ); |
|
190 iMaxTime = pckg().iMaxTime; |
|
191 iMaxlen = pckg().iMaxLength; |
|
192 //check for iDR is there are not |
|
193 iDR.Copy( pckg().iDR.Left( KSyncMLMaxDefaultResponseMsgLength ) ); |
|
194 iIT = pckg().iIT; |
|
195 iET = pckg().iET; |
|
196 //verification of other params as like maxtime |
|
197 if ( iMaxlen <= 0 || iMaxlen >KSyncMLMaxDefaultResponseMsgLength ) |
|
198 { |
|
199 iMaxlen = KSyncMLMaxDefaultResponseMsgLength; |
|
200 } |
|
201 |
|
202 if ( iIT < ESyncMLInputTypeAlphaNumeric || iIT > ESyncMLInputTypeIPAddress ) |
|
203 { |
|
204 iIT = ESyncMLInputTypeAlphaNumeric; |
|
205 } |
|
206 |
|
207 if ( iET < ESyncMLEchoTypeText || iET > ESyncMLEchoTypePassword ) |
|
208 { |
|
209 iET = ESyncMLEchoTypeText; |
|
210 } |
|
211 |
|
212 if( iServerMsg.Length() == 0 ) |
|
213 { |
|
214 HBufC* stringholder = NULL; |
|
215 stringholder = StringLoader::LoadLC( R_DEFAULT_ALERT_HEADING ); |
|
216 iServerMsg.Copy( stringholder->Des() ); |
|
217 CleanupStack::PopAndDestroy( stringholder ); |
|
218 } |
|
219 if ( iMaxTime < 0 ) |
|
220 { |
|
221 iMaxTime = 0; |
|
222 } |
|
223 if (iNoteType == ESyncMLSingleChoiceQuery || iNoteType == ESyncMLMultiChoiceQuery ) |
|
224 { |
|
225 iNumberOfItems = pckg().iNumberOfItems; |
|
226 if(iNumberOfItems > 0) |
|
227 { |
|
228 iListItems = new (ELeave) CDesCArrayFlat( iNumberOfItems ); |
|
229 } |
|
230 else |
|
231 { |
|
232 aMessage.Complete( KErrCancel ); |
|
233 iNeedToCompleteMessage = EFalse; |
|
234 return; |
|
235 } |
|
236 TPtrC8 listitemsptr; |
|
237 TBuf<KSyncMLChoiceItemsLengthBuffer> listlengtharray; |
|
238 User::LeaveIfError(iChunk.OpenGlobal(pckg().iChunkName,EFalse)); |
|
239 TInt size1 = iChunk.Size(); |
|
240 listitemsptr.Set(iChunk.Base(),size1); |
|
241 HBufC* databuf = NULL; |
|
242 TRAPD(errC, databuf = CnvUtfConverter::ConvertToUnicodeFromUtf8L(listitemsptr)); |
|
243 iChunk.Close(); |
|
244 if(errC) |
|
245 { |
|
246 aMessage.Complete( errC ); |
|
247 iNeedToCompleteMessage = EFalse; |
|
248 return; |
|
249 } |
|
250 CleanupStack::PushL(databuf); |
|
251 TPtr listitems = databuf->Des(); |
|
252 listlengtharray=pckg().iItemLength; |
|
253 TPtrC temp1,temp2,temp3,temp4; |
|
254 TInt currlen=0,itemlength=0; |
|
255 TInt prevcommapos=0; |
|
256 TBuf<4> checkon(_L("0\t")); |
|
257 TBuf<4> checkoff(_L("1\t")); |
|
258 for(TInt i=0;i<listlengtharray.Length();i++) |
|
259 { |
|
260 if(listlengtharray[i]== KChoiceItemSeparator ) |
|
261 { |
|
262 if(prevcommapos) |
|
263 { |
|
264 temp1.Set(listlengtharray.LeftTPtr(i)); |
|
265 temp2.Set(temp1.Right(i-(prevcommapos+1))); |
|
266 prevcommapos= i; |
|
267 } |
|
268 else //firsttime finding comma |
|
269 { |
|
270 prevcommapos= i; |
|
271 temp1.Set(listlengtharray.LeftTPtr(i)); |
|
272 temp2.Set(temp1.Right(i)); |
|
273 } |
|
274 TLex lexval; |
|
275 lexval.Assign(temp2); |
|
276 lexval.Val(itemlength); |
|
277 temp3.Set(listitems.Left(currlen + itemlength)); |
|
278 temp4.Set(temp3.Right(itemlength)); |
|
279 currlen += itemlength; |
|
280 HBufC* item1 = HBufC::NewLC(temp4.Length()+3); |
|
281 if(iNoteType == ESyncMLMultiChoiceQuery) |
|
282 { |
|
283 item1->Des().Append(checkoff);//by default dont show check on |
|
284 } |
|
285 item1->Des().Append(temp4); |
|
286 iListItems->AppendL(item1->Des()); |
|
287 CleanupStack::PopAndDestroy(1);//item,dataBuf16 |
|
288 } |
|
289 } |
|
290 CleanupStack::PopAndDestroy(1); |
|
291 } |
|
292 SetActive(); |
|
293 iStatus = KRequestPending; |
|
294 TRequestStatus* stat = &iStatus; |
|
295 User::RequestComplete( stat, KErrNone ); |
|
296 |
|
297 FTRACE( FPrint( _L( |
|
298 "[SmlNotif]\t CSyncMLDlgNotifier::GetParamsL() completed, iNoteType = %d, iTimeout = %d, iServerMsg = " ), |
|
299 iNoteType, iMaxTime ) ); |
|
300 FTRACE( FPrint( _L( |
|
301 "[SmlNotif]\t \"%S\"" ), |
|
302 &iServerMsg ) ); |
|
303 } |
|
304 |
|
305 // ----------------------------------------------------------------------------- |
|
306 // CSyncMLDlgNotifier::Cancel |
|
307 // ----------------------------------------------------------------------------- |
|
308 // |
|
309 void CSyncMLDlgNotifier::Cancel() |
|
310 { |
|
311 FLOG(_L("[SmlNotif]\t CSyncMLDlgNotifier::Cancel()")); |
|
312 |
|
313 CSyncMLNotifierBase::Cancel(); |
|
314 |
|
315 FLOG(_L("[SmlNotif]\t CSyncMLDlgNotifier::Cancel() completed")); |
|
316 } |
|
317 |
|
318 // ----------------------------------------------------------------------------- |
|
319 // CSyncMLDlgNotifier::RunL |
|
320 // Ask user response and return it to caller. |
|
321 // Store device into registry if user has accepted authorisation. |
|
322 // ----------------------------------------------------------------------------- |
|
323 // |
|
324 void CSyncMLDlgNotifier::RunL() |
|
325 { |
|
326 FLOG(_L("[SmlNotif]\t CSyncMLDlgNotifier::RunL()")); |
|
327 const TChar KDRSeparator('-'); |
|
328 const TChar KChoiceItemSeparator(','); |
|
329 TInt result( KErrNone ); |
|
330 EndKeyPress = EFalse; |
|
331 // Turn lights on and deactivate apps -key |
|
332 // |
|
333 TurnLightsOn(); |
|
334 |
|
335 switch( iNoteType ) |
|
336 { |
|
337 case ESyncMLInfoNote: |
|
338 { |
|
339 CAknInformationNote* infoNote = new (ELeave) CAknInformationNote; |
|
340 TInt maxtime = iMaxTime * KSyncMLuSecsInSec; |
|
341 if ( maxtime < 0 ) |
|
342 { |
|
343 maxtime = 0; |
|
344 } |
|
345 infoNote->SetTimeout( (CAknNoteDialog::TTimeout) maxtime ); |
|
346 result = infoNote->ExecuteLD( iServerMsg ); |
|
347 if ( result == KErrNone ) |
|
348 { |
|
349 result = EAknSoftkeyOk; |
|
350 } |
|
351 break; |
|
352 } |
|
353 case ESyncMLErrorNote: |
|
354 { |
|
355 CAknErrorNote* errNote = new (ELeave) CAknErrorNote; |
|
356 TInt maxtime = iMaxTime * KSyncMLuSecsInSec; |
|
357 if ( maxtime < 0 ) |
|
358 { |
|
359 maxtime = 0; |
|
360 } |
|
361 errNote->SetTimeout( (CAknNoteDialog::TTimeout) maxtime ); |
|
362 result = errNote->ExecuteLD( iServerMsg ); |
|
363 if ( result == KErrNone ) |
|
364 { |
|
365 result = EAknSoftkeyOk; |
|
366 }; |
|
367 break; |
|
368 } |
|
369 case ESyncMLOkQuery: |
|
370 { |
|
371 FLOG( _L("[SmlNotif]\t CSyncMLDlgNotifier::RunL() Ok/Empty query shown") ); |
|
372 |
|
373 CSyncMLTimedMessageQuery* dlg = |
|
374 CSyncMLTimedMessageQuery::NewL( iServerMsg, iMaxTime ); |
|
375 |
|
376 // Pushed dialog is popped inside RunLD |
|
377 dlg->PrepareLC( R_SML_MESSAGE_QUERY ); |
|
378 dlg->ButtonGroupContainer().SetCommandSetL( |
|
379 R_AVKON_SOFTKEYS_OK_EMPTY__OK ); |
|
380 EnableSyncProgressNoteL( EFalse ); |
|
381 result = dlg->RunLD(); |
|
382 dlg = NULL; |
|
383 EnableSyncProgressNoteL( ETrue ); |
|
384 break; |
|
385 } |
|
386 |
|
387 case ESyncMLQueryNote: // This enumeration will be removed. |
|
388 case ESyncMLYesNoQuery: |
|
389 { |
|
390 FLOG( _L("[SmlNotif]\t CSyncMLDlgNotifier::RunL() Yes/No query shown") ); |
|
391 CSyncMLTimedMessageQuery* dlg = |
|
392 CSyncMLTimedMessageQuery::NewL( iServerMsg, iMaxTime ); |
|
393 // Pushed dialog is popped inside RunLD |
|
394 dlg->PrepareLC( R_SML_MESSAGE_QUERY ); |
|
395 dlg->ButtonGroupContainer().SetCommandSetL( |
|
396 R_AVKON_SOFTKEYS_YES_NO__YES ); |
|
397 EnableSyncProgressNoteL( EFalse ); |
|
398 result = dlg->RunLD(); |
|
399 dlg = NULL; |
|
400 EnableSyncProgressNoteL( ETrue ); |
|
401 break; |
|
402 } |
|
403 case ESyncMLSingleChoiceQuery: |
|
404 { |
|
405 FLOG( _L("[SmlNotif]\t CSyncMLDlgNotifier::RunL() single choice list query") ); |
|
406 if ( iNumberOfItems > 0 ) |
|
407 { |
|
408 SuppressAppSwitching( ETrue ); |
|
409 EnableSyncProgressNoteL( EFalse ); |
|
410 CEikFormattedCellListBox* listBox = new ( ELeave ) |
|
411 CAknSinglePopupMenuStyleListBox; |
|
412 CleanupStack::PushL( listBox ); |
|
413 CSyncMLAknPopUpList* popupList = |
|
414 CSyncMLAknPopUpList::NewL( (CAknSingleHeadingPopupMenuStyleListBox*)listBox, |
|
415 R_AVKON_SOFTKEYS_OK_CANCEL__OK, |
|
416 AknPopupLayouts::EMenuWindow,iMaxTime ); |
|
417 CleanupStack::PushL( popupList ); |
|
418 listBox->ConstructL( popupList, ( EAknListBoxSelectionList | EAknListBoxLoopScrolling ) ); |
|
419 listBox->Model()->SetItemTextArray( iListItems ); |
|
420 listBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
421 listBox->ItemDrawer()->FormattedCellData()->EnableMarqueeL( ETrue ); |
|
422 listBox->HandleItemAdditionL(); |
|
423 listBox->CreateScrollBarFrameL( ETrue ); |
|
424 listBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
425 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); |
|
426 TInt defaultindex = 0; |
|
427 TLex drval(iDR); |
|
428 drval.Val(defaultindex); |
|
429 if(defaultindex > 0) |
|
430 defaultindex--; |
|
431 else |
|
432 defaultindex = 0; |
|
433 listBox->SetCurrentItemIndex(defaultindex); |
|
434 popupList->SetTitleL( iServerMsg ); |
|
435 CleanupStack::Pop( popupList ); |
|
436 FLOG( _L("[SmlNotif]\t CSyncMLDlgNotifier::RunL() single choice list query shown") ); |
|
437 result = popupList->ExecuteLD(); |
|
438 FLOG( _L("[SmlNotif]\t CSyncMLDlgNotifier::RunL() single choice list query dismissed") ); |
|
439 popupList = NULL; |
|
440 if ( result ) |
|
441 { |
|
442 reply.irettext.Num(listBox->CurrentItemIndex()+1); |
|
443 } |
|
444 reply.iretval = result; |
|
445 CleanupStack::PopAndDestroy( listBox ); // Destroys also the icon array |
|
446 EnableSyncProgressNoteL( ETrue ); |
|
447 SuppressAppSwitching( EFalse ); |
|
448 } |
|
449 else |
|
450 { |
|
451 reply.iretval = result; |
|
452 } |
|
453 TSyncMLDlgNotifReturnParamsPckg pkg(reply); |
|
454 iMessage.WriteL(iReplySlot,pkg); |
|
455 break; |
|
456 } |
|
457 case ESyncMLMultiChoiceQuery: |
|
458 { |
|
459 if ( iNumberOfItems > 0 ) |
|
460 { |
|
461 SuppressAppSwitching( ETrue ); |
|
462 EnableSyncProgressNoteL( EFalse ); |
|
463 // create listbox |
|
464 // list item string format: "0\tLabel" where 0 is an index to icon array |
|
465 CEikFormattedCellListBox* listBox = |
|
466 new ( ELeave ) CAknSingleGraphicPopupMenuStyleListBox; |
|
467 CleanupStack::PushL( listBox ); |
|
468 // create popup |
|
469 CSyncMLAknPopUpList* popup = |
|
470 CSyncMLAknPopUpList::NewL((CAknSingleHeadingPopupMenuStyleListBox*) listBox, |
|
471 R_AVKON_SOFTKEYS_OK_CANCEL__MARK , |
|
472 AknPopupLayouts::EMenuWindow,iMaxTime); |
|
473 CleanupStack::PushL( popup ); |
|
474 popup->SetTitleL(iServerMsg ); |
|
475 #ifdef RD_SCALABLE_UI_V2 |
|
476 if( AknLayoutUtils::PenEnabled() ) |
|
477 { |
|
478 listBox->ConstructL( popup, EAknListBoxStylusMultiselectionList ); |
|
479 } |
|
480 else |
|
481 { |
|
482 listBox->ConstructL( popup, EAknListBoxMultiselectionList ); |
|
483 } |
|
484 #else |
|
485 listBox->ConstructL( popup, EAknListBoxMultiselectionList ); |
|
486 #endif |
|
487 listBox->CreateScrollBarFrameL(ETrue); |
|
488 listBox->ScrollBarFrame()-> |
|
489 SetScrollBarVisibilityL( |
|
490 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto ); |
|
491 SetIconsL(listBox); |
|
492 listBox->Model()->SetItemTextArray( iListItems ); |
|
493 listBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
494 listBox->SetCurrentItemIndex(iDefindex); |
|
495 listBox->ItemDrawer()->FormattedCellData()->EnableMarqueeL( ETrue ); |
|
496 listBox->HandleItemAdditionL(); |
|
497 // set all items as selected |
|
498 TInt count( listBox->Model()->NumberOfItems() ); |
|
499 TBuf<20> drcheck; |
|
500 for( TInt index( 0 ); index < count; index++ ) |
|
501 { |
|
502 drcheck.Zero(); |
|
503 drcheck.Append(KDRSeparator); |
|
504 drcheck.AppendNum(index+1); |
|
505 drcheck.Append(KDRSeparator); |
|
506 if(iDR.Find(drcheck) >= KErrNone) |
|
507 { |
|
508 listBox->View()->SelectItemL( index ); |
|
509 } |
|
510 } |
|
511 // launch popup |
|
512 result = popup->ExecuteLD(); |
|
513 // No leaving functions allowed between executeLD and CleanupStack::Pop(). |
|
514 CleanupStack::Pop( popup ); |
|
515 /// Own: ListBox selection array |
|
516 const CArrayFix<TInt>* iSelectionArray; |
|
517 if( result ) |
|
518 { |
|
519 iSelectionArray = listBox->View()->SelectionIndexes(); |
|
520 TBuf<20> temp; |
|
521 TBuf<KSyncMLMaxAlertResultLength> temp1; |
|
522 for(TInt i=iSelectionArray->Count()-1;i>=0;i--) |
|
523 { |
|
524 temp.Num(iSelectionArray->At(i)+1); |
|
525 if((temp1.Length() + temp.Length()) < KSyncMLMaxAlertResultLength ) |
|
526 { |
|
527 temp1.Append(temp); |
|
528 temp1.Append(KDRSeparator); |
|
529 } |
|
530 else{ |
|
531 break; |
|
532 } |
|
533 } |
|
534 reply.irettext.Append(temp1); |
|
535 // delete iSelectionArray; this deletion taken care in ~CEIKLISTBOX (eiklbx.cpp) |
|
536 } |
|
537 reply.iretval = result; |
|
538 CleanupStack::PopAndDestroy(); // listBox |
|
539 EnableSyncProgressNoteL( ETrue ); |
|
540 SuppressAppSwitching( EFalse ); |
|
541 } |
|
542 else |
|
543 { |
|
544 reply.iretval = result; |
|
545 } |
|
546 TSyncMLDlgNotifReturnParamsPckg pkg(reply); |
|
547 iMessage.WriteL(iReplySlot,pkg); |
|
548 break; |
|
549 } |
|
550 case ESyncMLInputQuery: //For 1102 alert |
|
551 { |
|
552 FLOG( _L("[SmlNotif]\t CSyncMLDlgNotifier::RunL() Input query shown") ); |
|
553 // For input text server alert |
|
554 |
|
555 SuppressAppSwitching( ETrue ); |
|
556 |
|
557 switch( iIT ) |
|
558 { |
|
559 case ESyncMLInputTypeAlphaNumeric: //Alphanumeric Input type |
|
560 { |
|
561 |
|
562 InputTypeAlphaNumericL(result); |
|
563 break; |
|
564 } |
|
565 |
|
566 case ESyncMLInputTypeNumeric: //Numeric Input type |
|
567 { |
|
568 InputTypeNumericL(result); |
|
569 break; |
|
570 } |
|
571 |
|
572 case ESyncMLInputTypeDate: //Date Input type |
|
573 { |
|
574 InputTypeDateL(result); |
|
575 break; |
|
576 } |
|
577 |
|
578 case ESyncMLInputTypeTime: //Time Input type |
|
579 {//create TTime from TBuf iDR |
|
580 //hhmmss |
|
581 InputTypeTimeL(result); |
|
582 break; |
|
583 } |
|
584 |
|
585 case ESyncMLInputTypePhoneNumber: //Phone Number Input type |
|
586 { |
|
587 InputTypePhoneNumberL(result); |
|
588 break; |
|
589 } |
|
590 |
|
591 case ESyncMLInputTypeIPAddress: //IP Address Input type |
|
592 { |
|
593 TBuf<KSyncMLMaxDefaultResponseMsgLength> InputText(iDR); |
|
594 TInetAddr destAddr; |
|
595 destAddr.Input(iDR); |
|
596 EnableSyncProgressNoteL( EFalse );//coment out when using test app |
|
597 CAknIpAddressQueryDialog* dlg = CAknIpAddressQueryDialog::NewL (destAddr); |
|
598 CleanupStack::PushL(dlg); |
|
599 dlg->SetPromptL(iServerMsg); |
|
600 CleanupStack::Pop(); //dlg |
|
601 result=dlg->ExecuteLD( R_NEWALERT_IP_QUERY ); |
|
602 dlg=NULL; |
|
603 destAddr.Output(InputText); |
|
604 reply.iretval = result; |
|
605 reply.irettext=InputText; |
|
606 EnableSyncProgressNoteL( ETrue );//coment out when using test app |
|
607 break; |
|
608 } |
|
609 |
|
610 default: |
|
611 { |
|
612 User::Leave( KErrArgument ); |
|
613 } |
|
614 } |
|
615 SuppressAppSwitching( EFalse ); |
|
616 TSyncMLDlgNotifReturnParamsPckg pkg(reply); |
|
617 iMessage.WriteL(iReplySlot,pkg); |
|
618 break; |
|
619 } |
|
620 //#endif |
|
621 |
|
622 default: // Unhandled note type |
|
623 { |
|
624 FLOG(_L("[SmlNotif]\t CSyncMLDlgNotifier::RunL() Note type not handled")); |
|
625 User::Leave( KErrArgument ); |
|
626 break; |
|
627 } |
|
628 } |
|
629 // Complete message, if not cancelled |
|
630 if ( iNeedToCompleteMessage ) |
|
631 { |
|
632 FLOG(_L("[SmlNotif]\t CSyncMLDlgNotifier::RunL() completing the message")); |
|
633 switch ( result ) |
|
634 { |
|
635 case EAknSoftkeyYes: |
|
636 case EAknSoftkeyOk: |
|
637 case ETrue: |
|
638 { |
|
639 FLOG(_L("[SmlNotif]\t CSyncMLDlgNotifier::RunL() completing the message with KErrNone")); |
|
640 iMessage.Complete( KErrNone ); |
|
641 break; |
|
642 } |
|
643 case EAknSoftkeyCancel: |
|
644 case EAknSoftkeyNo: |
|
645 case KErrNone: // Pressing "Cancel" or "No" may return zero |
|
646 { |
|
647 FLOG(_L("[SmlNotif]\t CSyncMLDlgNotifier::RunL() completing the message with KErrCancel")); |
|
648 iMessage.Complete( KErrCancel ); |
|
649 break; |
|
650 } |
|
651 default: |
|
652 { |
|
653 iMessage.Complete( result ); |
|
654 break; |
|
655 } |
|
656 } |
|
657 } |
|
658 |
|
659 iNeedToCompleteMessage = EFalse; |
|
660 iReplySlot = NULL; |
|
661 |
|
662 iServerMsg = KNullDesC; |
|
663 |
|
664 FLOG(_L("[SmlNotif]\t CSyncMLDlgNotifier::RunL() completed")); |
|
665 } |
|
666 |
|
667 // ----------------------------------------------------------------------------- |
|
668 // CSyncMLDlgNotifier::CSyncMLDlgNotifier |
|
669 // C++ default constructor can NOT contain any code, that |
|
670 // might leave. |
|
671 // ----------------------------------------------------------------------------- |
|
672 // |
|
673 CSyncMLDlgNotifier::CSyncMLDlgNotifier( CSyncMLAppLaunchNotifier* aAppLaunchNotif ) |
|
674 : iAppLaunchNotif( aAppLaunchNotif ),iListItems(NULL),iDefindex(0) |
|
675 { |
|
676 } |
|
677 |
|
678 // ----------------------------------------------------------------------------- |
|
679 // CSyncMLDlgNotifier::InputTypeAlphaNumericL(TInt & result) |
|
680 // Process if input type is alphanumeric |
|
681 // ----------------------------------------------------------------------------- |
|
682 // |
|
683 void CSyncMLDlgNotifier::InputTypeAlphaNumericL(TInt & result) |
|
684 { |
|
685 FLOG( _L("[SmlNotif]\t CSyncMLDlgNotifier::InputTypeAlphaNumericL() startedd") ); |
|
686 TBuf<KSyncMLMaxDefaultResponseMsgLength> InputText(iDR); |
|
687 if( iET == ESyncMLEchoTypePassword ) //for pwd ET |
|
688 { |
|
689 CSyncMLTimedInputTextQuery* dlg = CSyncMLTimedInputTextQuery::NewL( InputText, iServerMsg, EndKeyPress, iMaxTime); |
|
690 dlg->SetMaxLength( iMaxlen ); |
|
691 EnableSyncProgressNoteL( EFalse );//coment out when using test app |
|
692 result = dlg->ExecuteLD( R_NEWALERT_DATA_PWD_QUERY ); |
|
693 if(EndKeyPress) |
|
694 { |
|
695 result = KErrAbort; |
|
696 } |
|
697 reply.iretval = result; |
|
698 reply.irettext=InputText; |
|
699 dlg=NULL; |
|
700 EnableSyncProgressNoteL( ETrue );//coment out when using test app |
|
701 } |
|
702 else |
|
703 { |
|
704 CSyncMLTimedInputTextQuery* dlg = CSyncMLTimedInputTextQuery::NewL( InputText,iServerMsg, EndKeyPress, iMaxTime); |
|
705 dlg->SetMaxLength( iMaxlen ); |
|
706 EnableSyncProgressNoteL( EFalse );//coment out when using test app |
|
707 result = dlg->ExecuteLD( R_INPUTTEXT_DATA_QUERY ); |
|
708 if(EndKeyPress ) |
|
709 { |
|
710 result = KErrAbort; |
|
711 } |
|
712 reply.iretval = result; |
|
713 reply.irettext=InputText; |
|
714 dlg=NULL; |
|
715 EnableSyncProgressNoteL( ETrue );//coment out when using test app |
|
716 } |
|
717 FLOG( _L("[SmlNotif]\t CSyncMLDlgNotifier::InputTypeAlphaNumericL() completed") ); |
|
718 } |
|
719 |
|
720 // ----------------------------------------------------------------------------- |
|
721 // CSyncMLDlgNotifier::InputTypeNumericL(TInt & result) |
|
722 // Process if input type is numeric |
|
723 // ----------------------------------------------------------------------------- |
|
724 // |
|
725 void CSyncMLDlgNotifier::InputTypeNumericL(TInt & result) |
|
726 { |
|
727 FLOG( _L("[SmlNotif]\t CSyncMLDlgNotifier::InputTypeNumericL() started") ); |
|
728 TBuf<KSyncMLMaxDefaultResponseMsgLength> InputText(iDR); |
|
729 TReal value = 0; |
|
730 TLex data(iDR); |
|
731 if( iDR.Length() != 0 ) |
|
732 { |
|
733 data.Val(value); |
|
734 } |
|
735 if ( iET == ESyncMLEchoTypePassword ) |
|
736 { |
|
737 TChar ch = '0'; |
|
738 for (TInt i=0;i<iDR.Length();i++) |
|
739 { |
|
740 ch=iDR[i]; |
|
741 if( ch!='+' || ch!='-' || ch!='.' ) |
|
742 { |
|
743 if( !ch.IsDigit() ) |
|
744 { |
|
745 InputText.Zero(); |
|
746 break; |
|
747 } |
|
748 } |
|
749 } |
|
750 CSyncMLTimedInputTextQuery* dlg = CSyncMLTimedInputTextQuery::NewL( InputText, iServerMsg, EndKeyPress, iMaxTime); |
|
751 dlg->SetMaxLength( iMaxlen ); |
|
752 EnableSyncProgressNoteL( EFalse );//coment out when using test app |
|
753 result = dlg->ExecuteLD( R_NEWALERT_NUMERIC_PWD_QUERY ); |
|
754 dlg = NULL; |
|
755 if(EndKeyPress) |
|
756 { |
|
757 result = KErrAbort; |
|
758 } |
|
759 } |
|
760 else |
|
761 { |
|
762 CSyncMLTimedNumberQueryDialog* dlg = |
|
763 CSyncMLTimedNumberQueryDialog::NewL( value, iServerMsg, EndKeyPress, iMaxTime); |
|
764 |
|
765 EnableSyncProgressNoteL( EFalse );//coment out when using test app |
|
766 result = dlg->ExecuteLD( R_NEWALERT_NUMBER_QUERY ); |
|
767 dlg = NULL; |
|
768 if(EndKeyPress) |
|
769 { |
|
770 result = KErrAbort; |
|
771 } |
|
772 reply.iretval = result; |
|
773 data.Val( value ); |
|
774 _LIT(KSendFormat ,"%10.10f"); |
|
775 InputText.Format ( KSendFormat, value ); |
|
776 } |
|
777 reply.iretval = result; |
|
778 reply.irettext= InputText; |
|
779 |
|
780 EnableSyncProgressNoteL( ETrue );//coment out when using test app |
|
781 |
|
782 FLOG( _L("[SmlNotif]\t CSyncMLDlgNotifier::InputTypeNumericL() completed") ); |
|
783 } |
|
784 |
|
785 // ----------------------------------------------------------------------------- |
|
786 // CSyncMLDlgNotifier::InputTypeDateL(TInt & result) |
|
787 // Process if input type is Date |
|
788 // ----------------------------------------------------------------------------- |
|
789 // |
|
790 void CSyncMLDlgNotifier::InputTypeDateL(TInt & result) |
|
791 { |
|
792 FLOG( _L("[SmlNotif]\t CSyncMLDlgNotifier::InputTypeDateL() started") ); |
|
793 |
|
794 TTime date(_L("00010101:")); |
|
795 TInt BadData = 1; |
|
796 TChar ch = '0'; |
|
797 for (TInt i=0;i<iDR.Length();i++) |
|
798 { |
|
799 ch=iDR[i]; |
|
800 if(!ch.IsDigit()) |
|
801 { |
|
802 BadData=0; |
|
803 break; |
|
804 } |
|
805 } |
|
806 if( iDR.Length() != 0 && iDR.Length()==8 && BadData ) |
|
807 { |
|
808 //iDR.Append(':'); |
|
809 TBuf <9> revdate; |
|
810 revdate.Append(iDR.Mid(4,4)); |
|
811 revdate.Append(iDR.Mid(2,2)); |
|
812 revdate.Append(iDR.Left(2)); |
|
813 revdate.Append(':'); |
|
814 date.Set( revdate ); |
|
815 } |
|
816 CSyncMLTimedDateQuery* dlg = CSyncMLTimedDateQuery::NewL( date, iServerMsg,EndKeyPress , iMaxTime); |
|
817 EnableSyncProgressNoteL( EFalse );//coment out when using test app |
|
818 result = dlg->ExecuteLD(R_NEWALERT_DATE_QUERY); |
|
819 |
|
820 if(EndKeyPress) |
|
821 { |
|
822 result = KErrAbort;//0-keypress 1-ok,0-cancel,-1=end key |
|
823 } |
|
824 reply.iretval = result; |
|
825 _LIT(KDateFormat,"%F%D%M%Y"); |
|
826 TBuf <20> StringDate; |
|
827 date.FormatL(StringDate, KDateFormat); |
|
828 reply.irettext=StringDate; |
|
829 dlg = NULL; |
|
830 EnableSyncProgressNoteL( ETrue );//comented out for emulator testing |
|
831 |
|
832 FLOG( _L("[SmlNotif]\t CSyncMLDlgNotifier::InputTypeDateL() completed") ); |
|
833 } |
|
834 |
|
835 // ----------------------------------------------------------------------------- |
|
836 // CSyncMLDlgNotifier::InputTypeTimeL(TInt & result) |
|
837 // Process if input type is Time |
|
838 // ----------------------------------------------------------------------------- |
|
839 // |
|
840 void CSyncMLDlgNotifier::InputTypeTimeL(TInt & result) |
|
841 { |
|
842 FLOG( _L("[SmlNotif]\t CSyncMLDlgNotifier::InputTypeTimeL() started") ); |
|
843 |
|
844 //create TTime from TBuf iDR |
|
845 //hhmmss |
|
846 TTime IpTime(_L("120000.")); |
|
847 TInt BadData=1; |
|
848 TChar ch= '0'; |
|
849 for (TInt i=0;i<iDR.Length();i++) |
|
850 { |
|
851 ch=iDR[i]; |
|
852 if(!ch.IsDigit()) |
|
853 { |
|
854 BadData=0; |
|
855 break; |
|
856 } |
|
857 } |
|
858 if( iDR.Length() != 0 && iDR.Length() == 6 && BadData ) |
|
859 { |
|
860 iDR.Append('.'); |
|
861 IpTime.Set( iDR ); |
|
862 } |
|
863 CSyncMLTimedDateQuery* dlg = |
|
864 CSyncMLTimedDateQuery::NewL( IpTime, iServerMsg, EndKeyPress, iMaxTime); |
|
865 EnableSyncProgressNoteL( EFalse );//comented out for emulator testing |
|
866 result = dlg->ExecuteLD(R_NEWALERT_TIME_QUERY); |
|
867 if(EndKeyPress) |
|
868 { |
|
869 result = KErrAbort;//0-keypress 1-ok,0-cancel,-1=end key |
|
870 } |
|
871 reply.iretval = result; |
|
872 _LIT(KTimeFormat,"%F%H%T%S"); |
|
873 TBuf <20> StringTime; |
|
874 IpTime.FormatL(StringTime, KTimeFormat); |
|
875 reply.irettext=StringTime; |
|
876 dlg = NULL; |
|
877 EnableSyncProgressNoteL( ETrue );//coment out when using test app |
|
878 |
|
879 FLOG( _L("[SmlNotif]\t CSyncMLDlgNotifier::InputTypeTimeL() completed") ); |
|
880 } |
|
881 |
|
882 // ----------------------------------------------------------------------------- |
|
883 // CSyncMLDlgNotifier::InputTypePhoneNumberL(TInt & result) |
|
884 // Process if input type is Phone number |
|
885 // ----------------------------------------------------------------------------- |
|
886 // |
|
887 void CSyncMLDlgNotifier::InputTypePhoneNumberL(TInt & result) |
|
888 { |
|
889 FLOG( _L("[SmlNotif]\t CSyncMLDlgNotifier::InputTypePhoneNumberL() started") ); |
|
890 TBuf<KSyncMLMaxDefaultResponseMsgLength> InputText(iDR); |
|
891 EnableSyncProgressNoteL( EFalse );//comented out for emulator testing |
|
892 TInt ret=0; |
|
893 for(TInt i=0;i<iDR.Length();i++) |
|
894 { |
|
895 if(iDR[i] == 'p' || iDR[i] == 'w' || iDR[i] == '+' || iDR[i] == '*' ||iDR[i] == '#') |
|
896 { |
|
897 if( iDR[i] == '+' && i > 0) |
|
898 { |
|
899 ret = -1; |
|
900 break; |
|
901 } |
|
902 else |
|
903 { |
|
904 continue; |
|
905 } |
|
906 } |
|
907 else |
|
908 { |
|
909 TChar ch=iDR[i] ; |
|
910 if(!ch.IsDigit()) |
|
911 { |
|
912 ret = -1; |
|
913 break; |
|
914 } |
|
915 } |
|
916 } |
|
917 |
|
918 if(ret == -1) |
|
919 InputText.Zero(); |
|
920 CSyncMLTimedInputTextQuery* dlg = CSyncMLTimedInputTextQuery::NewL(InputText,iServerMsg, EndKeyPress, iMaxTime); |
|
921 dlg->SetMaxLength( iMaxlen ); |
|
922 result = dlg->ExecuteLD( R_NEWALERT_PHONE_QUERY ); |
|
923 if(EndKeyPress ) |
|
924 { |
|
925 result = KErrAbort; |
|
926 } |
|
927 reply.iretval = result; |
|
928 reply.irettext=InputText; |
|
929 dlg=NULL; |
|
930 EnableSyncProgressNoteL( ETrue );//coment out when using test app |
|
931 FLOG( _L("[SmlNotif]\t CSyncMLDlgNotifier::InputTypePhoneNumberL() completed") ); |
|
932 } |
|
933 |
|
934 // ----------------------------------------------------------------------------- |
|
935 // CSyncMLDlgNotifier::SetIconsL() |
|
936 // Sets the icons to multiselection/markable list |
|
937 // ----------------------------------------------------------------------------- |
|
938 void CSyncMLDlgNotifier::SetIconsL(CEikFormattedCellListBox* aListBox) |
|
939 { |
|
940 CAknIconArray* iconArray = new( ELeave ) CAknIconArray( 1 ); |
|
941 CleanupStack::PushL( iconArray ); |
|
942 CFbsBitmap* checkboxOnBitmap = NULL; |
|
943 CFbsBitmap* checkboxOnBitmapMask = NULL; |
|
944 CFbsBitmap* checkboxOffBitmap = NULL; |
|
945 CFbsBitmap* checkboxOffBitmapMask = NULL; |
|
946 |
|
947 //CListItemDrawer is using this logical color as default for its marked icons |
|
948 TRgb defaultColor; |
|
949 defaultColor = iEikEnv->Color( EColorControlText ); |
|
950 |
|
951 // Create 'ON' checkbox icon |
|
952 AknsUtils::CreateColorIconLC( AknsUtils::SkinInstance(), |
|
953 KAknsIIDQgnIndiCheckboxOn, |
|
954 KAknsIIDQsnIconColors, |
|
955 EAknsCIQsnIconColorsCG13, |
|
956 checkboxOnBitmap, |
|
957 checkboxOnBitmapMask, |
|
958 KAvkonBitmapFile, |
|
959 EMbmAvkonQgn_indi_checkbox_on, |
|
960 EMbmAvkonQgn_indi_checkbox_on_mask, |
|
961 defaultColor |
|
962 ); |
|
963 |
|
964 CGulIcon* checkboxOnIcon = CGulIcon::NewL( checkboxOnBitmap, checkboxOnBitmapMask ); |
|
965 // cleanup checkboxOnBitmap, checkboxOnBitmapMask |
|
966 CleanupStack::Pop( checkboxOnBitmapMask ); |
|
967 CleanupStack::Pop( checkboxOnBitmap ); |
|
968 |
|
969 CleanupStack::PushL( checkboxOnIcon ); |
|
970 iconArray->AppendL( checkboxOnIcon ); |
|
971 |
|
972 // Create 'OFF' checkbox icon |
|
973 AknsUtils::CreateColorIconLC( AknsUtils::SkinInstance(), |
|
974 KAknsIIDQgnIndiCheckboxOff, |
|
975 KAknsIIDQsnIconColors, |
|
976 EAknsCIQsnIconColorsCG13, |
|
977 checkboxOffBitmap, |
|
978 checkboxOffBitmapMask, |
|
979 KAvkonBitmapFile, |
|
980 EMbmAvkonQgn_indi_checkbox_off, |
|
981 EMbmAvkonQgn_indi_checkbox_off_mask, |
|
982 defaultColor |
|
983 ); |
|
984 |
|
985 CGulIcon* checkboxOffIcon = CGulIcon::NewL( checkboxOffBitmap, checkboxOffBitmapMask ); |
|
986 // cleanup checkboxOffBitmap, checkboxOffBitmapMask |
|
987 CleanupStack::Pop( checkboxOffBitmapMask ); //WILL BE DELETED BY CGUIICON |
|
988 CleanupStack::Pop( checkboxOffBitmap ); //WILL BE DELETED BY CGUIICON |
|
989 |
|
990 |
|
991 CleanupStack::PushL( checkboxOffIcon ); |
|
992 iconArray->AppendL( checkboxOffIcon ); |
|
993 aListBox->ItemDrawer()->ColumnData()->SetIconArray( iconArray ); // changes ownership |
|
994 |
|
995 // cleanup checkboxOnIcon, checkboxOffIcon, iconArray |
|
996 CleanupStack::Pop( checkboxOffIcon ); //WILL BE DELETED BY CGUIICON |
|
997 CleanupStack::Pop( checkboxOnIcon ); //WILL BE DELETED BY CGUIICON |
|
998 CleanupStack::Pop( iconArray );//WILL BE DELETED BY CFormattedCellListBoxData:: |
|
999 |
|
1000 } |
|
1001 |
|
1002 // End of File |
|