1 /* |
|
2 * Copyright (c) 2010 Sun Microsystems, Inc. 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 Contributor: |
|
10 * Maximilian Odendahl |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Caldav setting items |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "caldavsettingitems.h" |
|
19 |
|
20 #include <StringLoader.h> |
|
21 #include <aknnotewrappers.h> |
|
22 #include <cmapplicationsettingsui.h> |
|
23 #include <CommDbConnPref.h> |
|
24 #include <UTF.H> |
|
25 |
|
26 #include <caldavsession.h> |
|
27 #include "calencaldavplugin.h" |
|
28 #include <calencaldavplugindata.rsg> |
|
29 |
|
30 #define KMAXSETTINGLENGTH 500 |
|
31 |
|
32 #define KTIMETWOWEEKS 14 |
|
33 #define KTIMETHREEMONTH 30*3 |
|
34 #define KTIMESIXMONTH 30*6 |
|
35 #define KTIMEALL 1000 |
|
36 |
|
37 #define KTIMEALWAYSON 0 |
|
38 #define KTIMEONEMINUTE 1 |
|
39 #define KTIMEFIVEMINUTES 5 |
|
40 #define KTIMEFIFTEENMINUTES 15 |
|
41 #define KTIMETHIRTYMINUTES 30 |
|
42 |
|
43 /** |
|
44 * show a global info note |
|
45 */ |
|
46 void ShowNoteL(TInt aResource) |
|
47 { |
|
48 HBufC* text = StringLoader::LoadLC(aResource); |
|
49 CAknConfirmationNote* note = new (ELeave) CAknConfirmationNote(); |
|
50 note->ExecuteLD(*text); |
|
51 CleanupStack::PopAndDestroy(text); |
|
52 } |
|
53 |
|
54 /** |
|
55 * CCalDavTextSettingItem::CCalDavTextSettingItem |
|
56 * default constructor |
|
57 */ |
|
58 CCalDavTextSettingItem::CCalDavTextSettingItem(TInt aId, |
|
59 CCalDavSession* aSession) : |
|
60 CAknTextSettingItem(aId, iInternalValue), iSession(aSession) |
|
61 { |
|
62 |
|
63 } |
|
64 |
|
65 /** |
|
66 * CCalDavTextSettingItem::~CCalDavTextSettingItem |
|
67 * destructor |
|
68 */ |
|
69 CCalDavTextSettingItem::~CCalDavTextSettingItem() |
|
70 { |
|
71 delete iCalendar; |
|
72 } |
|
73 |
|
74 /** |
|
75 * CCalDavTextSettingItem::NewLC |
|
76 * 1st-phase construction |
|
77 */ |
|
78 CCalDavTextSettingItem* CCalDavTextSettingItem::NewLC(TInt aId, |
|
79 CCalDavSession* aSession, const TDesC &aCalendar) |
|
80 { |
|
81 CCalDavTextSettingItem* self = new (ELeave) CCalDavTextSettingItem(aId, |
|
82 aSession); |
|
83 CleanupStack::PushL(self); |
|
84 self->ConstructL(aCalendar); |
|
85 return self; |
|
86 } |
|
87 |
|
88 /** |
|
89 * CCalDavTextSettingItem::NewL |
|
90 * 1st-phase construction |
|
91 */ |
|
92 CCalDavTextSettingItem* CCalDavTextSettingItem::NewL(TInt aId, |
|
93 CCalDavSession* aSession, const TDesC &aCalendar) |
|
94 { |
|
95 CCalDavTextSettingItem* self = CCalDavTextSettingItem::NewLC(aId, aSession, |
|
96 aCalendar); |
|
97 CleanupStack::Pop(); // self; |
|
98 return self; |
|
99 } |
|
100 |
|
101 /** |
|
102 * CCalDavTextSettingItem::ConstructL |
|
103 * 2nd-phase construction |
|
104 */ |
|
105 void CCalDavTextSettingItem::ConstructL(const TDesC &aCalendar) |
|
106 { |
|
107 iCalendar = aCalendar.AllocL(); |
|
108 HBufC* title = NULL; |
|
109 TInt page = 0; |
|
110 switch (Identifier()) |
|
111 { |
|
112 case ECalDavSettingUrl: |
|
113 title = StringLoader::LoadLC(R_CALDAV_URL); |
|
114 page = R_URL_SETTING_PAGE; |
|
115 break; |
|
116 case ECalDavSettingUser: |
|
117 title = StringLoader::LoadLC(R_CALDAV_USERNAME); |
|
118 page = R_USERNAME_SETTING_PAGE; |
|
119 break; |
|
120 case ECalDavSettingPassword: |
|
121 title = StringLoader::LoadLC(R_CALDAV_PASSWORD); |
|
122 page = R_PASSWORD_SETTING_PAGE; |
|
123 break; |
|
124 } |
|
125 SetEmptyItemTextL(KNullDesC); |
|
126 CAknTextSettingItem::ConstructL(EFalse, 0, *title, NULL,page, -1); |
|
127 CleanupStack::PopAndDestroy(title); |
|
128 } |
|
129 |
|
130 /** |
|
131 * CCalDavTextSettingItem::EditItemL |
|
132 * Edits the item |
|
133 */ |
|
134 void CCalDavTextSettingItem::EditItemL(TBool aCalledFromMenu) |
|
135 { |
|
136 TBool enabled; |
|
137 iSession->EnabledSync(*iCalendar, enabled); |
|
138 if (enabled) |
|
139 { |
|
140 HBufC* text = StringLoader::LoadLC(R_CALDAV_QUERY_DISCONNECT); |
|
141 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
|
142 if (dlg->ExecuteLD(R_QUERY, *text)) |
|
143 { |
|
144 CAknTextSettingItem::EditItemL(aCalledFromMenu); |
|
145 // TODO: disable Enabled-Setting-Item |
|
146 } |
|
147 CleanupStack::PopAndDestroy(text); |
|
148 } |
|
149 else |
|
150 CAknTextSettingItem::EditItemL(aCalledFromMenu); |
|
151 } |
|
152 |
|
153 /** |
|
154 * CCalDavTextSettingItem::StoreL |
|
155 * Stores the item |
|
156 */ |
|
157 void CCalDavTextSettingItem::StoreL() |
|
158 { |
|
159 CAknTextSettingItem::StoreL(); |
|
160 |
|
161 HBufC8* text = CnvUtfConverter::ConvertFromUnicodeToUtf8L(iInternalValue); |
|
162 CleanupStack::PushL(text); |
|
163 |
|
164 switch (Identifier()) |
|
165 { |
|
166 case ECalDavSettingUrl: |
|
167 iSession->SetUrl(*iCalendar, *text); |
|
168 break; |
|
169 case ECalDavSettingUser: |
|
170 iSession->SetUsername(*iCalendar, *text); |
|
171 break; |
|
172 case ECalDavSettingPassword: |
|
173 iSession->SetPassword(*iCalendar, *text); |
|
174 break; |
|
175 } |
|
176 CleanupStack::PopAndDestroy(text); |
|
177 |
|
178 if (iEnableSettingItem) |
|
179 { |
|
180 iEnableSettingItem->LoadL(); |
|
181 iEnableSettingItem->UpdateListBoxTextL(); |
|
182 } |
|
183 } |
|
184 |
|
185 /** |
|
186 * CCalDavTextSettingItem::LoadL |
|
187 * loades the item |
|
188 */ |
|
189 void CCalDavTextSettingItem::LoadL() |
|
190 { |
|
191 HBufC8* buf = HBufC8::NewL(KMAXSETTINGLENGTH); |
|
192 TPtr8 ptr(buf->Des()); |
|
193 switch (Identifier()) |
|
194 { |
|
195 case ECalDavSettingUrl: |
|
196 iSession->Url(*iCalendar, ptr); |
|
197 break; |
|
198 case ECalDavSettingUser: |
|
199 iSession->Username(*iCalendar, ptr); |
|
200 break; |
|
201 case ECalDavSettingPassword: |
|
202 iSession->Password(*iCalendar, ptr); |
|
203 break; |
|
204 } |
|
205 CnvUtfConverter::ConvertToUnicodeFromUtf8(iInternalValue, ptr); |
|
206 delete buf; |
|
207 CAknTextSettingItem::LoadL(); |
|
208 } |
|
209 |
|
210 /** |
|
211 * CCalDavTextSettingItem::StoreL |
|
212 * Save a pointer to the Enable Item, this is used to set current |
|
213 * enable/disable state |
|
214 */ |
|
215 void CCalDavTextSettingItem::SetEnableSettingItem(CAknSettingItem* aItem) |
|
216 { |
|
217 iEnableSettingItem = aItem; |
|
218 } |
|
219 |
|
220 /** |
|
221 * CCalDavPasswordSettingItem::CCalDavPasswordSettingItem |
|
222 * default constructor |
|
223 */ |
|
224 CCalDavPasswordSettingItem::CCalDavPasswordSettingItem(TInt aId, |
|
225 CCalDavSession* aSession) : |
|
226 CAknPasswordSettingItem(aId, CAknPasswordSettingItem::EAlpha, |
|
227 iInternalValue), iSession(aSession) |
|
228 { |
|
229 |
|
230 } |
|
231 |
|
232 /** |
|
233 * CCalDavPasswordSettingItem::~CCalDavPasswordSettingItem |
|
234 * default destructor |
|
235 */ |
|
236 CCalDavPasswordSettingItem::~CCalDavPasswordSettingItem() |
|
237 { |
|
238 delete iCalendar; |
|
239 } |
|
240 |
|
241 /** |
|
242 * CCalDavPasswordSettingItem::NewLC |
|
243 * first phase construction |
|
244 */ |
|
245 CCalDavPasswordSettingItem* CCalDavPasswordSettingItem::NewLC(TInt aId, |
|
246 CCalDavSession* aSession, const TDesC &aCalendar) |
|
247 { |
|
248 CCalDavPasswordSettingItem* self = new (ELeave) CCalDavPasswordSettingItem( |
|
249 aId, aSession); |
|
250 CleanupStack::PushL(self); |
|
251 self->ConstructL(aCalendar); |
|
252 return self; |
|
253 } |
|
254 |
|
255 /** |
|
256 * CCalDavPasswordSettingItem::NewL |
|
257 * first phase construction |
|
258 */ |
|
259 CCalDavPasswordSettingItem* CCalDavPasswordSettingItem::NewL(TInt aId, |
|
260 CCalDavSession* aSession, const TDesC &aCalendar) |
|
261 { |
|
262 CCalDavPasswordSettingItem* self = CCalDavPasswordSettingItem::NewLC(aId, |
|
263 aSession, aCalendar); |
|
264 CleanupStack::Pop(); // self; |
|
265 return self; |
|
266 } |
|
267 |
|
268 /** |
|
269 * CCalDavPasswordSettingItem::SetEnableSettingItem |
|
270 * Save a pointer to the Enable Item, this is used to set current |
|
271 * enable/disable state |
|
272 */ |
|
273 void CCalDavPasswordSettingItem::SetEnableSettingItem(CAknSettingItem* aItem) |
|
274 { |
|
275 iEnableSettingItem = aItem; |
|
276 } |
|
277 |
|
278 /** |
|
279 * CCalDavPasswordSettingItem::ConstructL |
|
280 * second phase construction |
|
281 */ |
|
282 void CCalDavPasswordSettingItem::ConstructL(const TDesC &aCalendar) |
|
283 { |
|
284 iCalendar = aCalendar.AllocL(); |
|
285 HBufC* title = NULL; |
|
286 TInt page = 0; |
|
287 switch (Identifier()) |
|
288 { |
|
289 case ECalDavSettingPassword: |
|
290 title = StringLoader::LoadLC(R_CALDAV_PASSWORD); |
|
291 page = R_PASSWORD_SETTING_PAGE; |
|
292 break; |
|
293 } |
|
294 SetEmptyItemTextL(KNullDesC); |
|
295 CAknPasswordSettingItem::ConstructL(EFalse, 0, *title, NULL,page, -1); |
|
296 CleanupStack::PopAndDestroy(title); |
|
297 } |
|
298 |
|
299 /** |
|
300 * CCalDavPasswordSettingItem::EditItemL |
|
301 * edits the item |
|
302 */ |
|
303 void CCalDavPasswordSettingItem::EditItemL(TBool aCalledFromMenu) |
|
304 { |
|
305 TBool enabled; |
|
306 iSession->EnabledSync(*iCalendar, enabled); |
|
307 if (enabled) |
|
308 { |
|
309 HBufC* text = StringLoader::LoadLC(R_CALDAV_QUERY_DISCONNECT); |
|
310 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
|
311 if (dlg->ExecuteLD(R_QUERY, *text)) |
|
312 CAknPasswordSettingItem::EditItemL(aCalledFromMenu); |
|
313 CleanupStack::PopAndDestroy(text); |
|
314 } |
|
315 else |
|
316 CAknPasswordSettingItem::EditItemL(aCalledFromMenu); |
|
317 CAknSettingItem::UpdateListBoxTextL(); |
|
318 } |
|
319 |
|
320 /** |
|
321 * CCalDavPasswordSettingItem::StoreL |
|
322 * stores the item |
|
323 */ |
|
324 void CCalDavPasswordSettingItem::StoreL() |
|
325 { |
|
326 CAknPasswordSettingItem::StoreL(); |
|
327 |
|
328 HBufC8* text = CnvUtfConverter::ConvertFromUnicodeToUtf8L(iInternalValue); |
|
329 CleanupStack::PushL(text); |
|
330 |
|
331 switch (Identifier()) |
|
332 { |
|
333 case ECalDavSettingPassword: |
|
334 iSession->SetPassword(*iCalendar, *text); |
|
335 break; |
|
336 } |
|
337 CleanupStack::PopAndDestroy(text); |
|
338 } |
|
339 |
|
340 /** |
|
341 * CCalDavPasswordSettingItem::LoadL |
|
342 * loads the item |
|
343 */ |
|
344 void CCalDavPasswordSettingItem::LoadL() |
|
345 { |
|
346 HBufC8* buf = HBufC8::NewL(KMAXSETTINGLENGTH); |
|
347 TPtr8 ptr(buf->Des()); |
|
348 switch (Identifier()) |
|
349 { |
|
350 case ECalDavSettingPassword: |
|
351 iSession->Password(*iCalendar, ptr); |
|
352 break; |
|
353 } |
|
354 CnvUtfConverter::ConvertToUnicodeFromUtf8(iInternalValue, ptr); |
|
355 delete buf; |
|
356 CAknPasswordSettingItem::LoadL(); |
|
357 } |
|
358 |
|
359 /** |
|
360 * CCalDavBooleanSettingItem::CCalDavBooleanSettingItem |
|
361 * default constructor |
|
362 */ |
|
363 CCalDavBooleanSettingItem::CCalDavBooleanSettingItem(TInt aId, |
|
364 CCalDavSession* aSession) : |
|
365 CAknBinaryPopupSettingItem(aId, iInternalValue), iSession(aSession) |
|
366 { |
|
367 |
|
368 } |
|
369 |
|
370 /** |
|
371 * CCalDavBooleanSettingItem::~CCalDavBooleanSettingItem |
|
372 * default destructor |
|
373 */ |
|
374 CCalDavBooleanSettingItem::~CCalDavBooleanSettingItem() |
|
375 { |
|
376 delete iCalendar; |
|
377 } |
|
378 |
|
379 /** |
|
380 * CCalDavBooleanSettingItem::NewLC |
|
381 * first phase construction |
|
382 */ |
|
383 CCalDavBooleanSettingItem* CCalDavBooleanSettingItem::NewLC(TInt aId, |
|
384 CCalDavSession* aSession, const TDesC &aCalendar) |
|
385 { |
|
386 CCalDavBooleanSettingItem* self = new (ELeave) CCalDavBooleanSettingItem( |
|
387 aId, aSession); |
|
388 CleanupStack::PushL(self); |
|
389 self->ConstructL(aCalendar); |
|
390 return self; |
|
391 } |
|
392 |
|
393 /** |
|
394 * CCalDavBooleanSettingItem::NewLC |
|
395 * first phase construction |
|
396 */ |
|
397 CCalDavBooleanSettingItem* CCalDavBooleanSettingItem::NewL(TInt aId, |
|
398 CCalDavSession* aSession, const TDesC &aCalendar) |
|
399 { |
|
400 CCalDavBooleanSettingItem* self = CCalDavBooleanSettingItem::NewLC(aId, |
|
401 aSession, aCalendar); |
|
402 CleanupStack::Pop(); // self; |
|
403 return self; |
|
404 } |
|
405 |
|
406 /** |
|
407 * CCalDavBooleanSettingItem::ConstructL |
|
408 * second phase construction |
|
409 */ |
|
410 void CCalDavBooleanSettingItem::ConstructL(const TDesC &aCalendar) |
|
411 { |
|
412 iCalendar = aCalendar.AllocL(); |
|
413 HBufC* title = NULL; |
|
414 TInt text = 0; |
|
415 TInt page = R_CALDAV_BINARY_PAGE; |
|
416 switch (Identifier()) |
|
417 { |
|
418 case ECalDavSettingKeepServer: |
|
419 title = StringLoader::LoadLC(R_CALDAV_CONFLICTACTION); |
|
420 text = R_CALDAV_CONFLICTACTION_TEXTS; |
|
421 break; |
|
422 case ECalDavSettingSyncImmediate: |
|
423 title = StringLoader::LoadLC(R_CALDAV_IMMEDIATESYNC); |
|
424 text = R_CALDAV_IMMEDIATESYNC_TEXTS; |
|
425 break; |
|
426 case ECalDavSettingEnable: |
|
427 title = StringLoader::LoadLC(R_CALDAV_ENABLE); |
|
428 text = R_CALDAV_ENABLE_TEXTS; |
|
429 break; |
|
430 } |
|
431 SetEmptyItemTextL(KNullDesC); |
|
432 CAknBinaryPopupSettingItem::ConstructL(EFalse, 0, *title, NULL,page, |
|
433 EAknCtPopupSettingList, NULL, text); |
|
434 CleanupStack::PopAndDestroy(title); |
|
435 } |
|
436 |
|
437 /** |
|
438 * CCalDavBooleanSettingItem::EditItemL |
|
439 * edits the item |
|
440 */ |
|
441 void CCalDavBooleanSettingItem::EditItemL(TBool aCalledFromMenu) |
|
442 { |
|
443 if (Identifier() == ECalDavSettingEnable) |
|
444 { |
|
445 TBool enabled_old; |
|
446 iSession->EnabledSync(*iCalendar, enabled_old); |
|
447 if (enabled_old) |
|
448 { |
|
449 HBufC* text = StringLoader::LoadLC(R_CALDAV_QUERY_DISCONNECT); |
|
450 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
|
451 if (dlg->ExecuteLD(R_QUERY, *text)) |
|
452 { |
|
453 iSession->Disable(*iCalendar); |
|
454 CAknBinaryPopupSettingItem::EditItemL(aCalledFromMenu); |
|
455 } |
|
456 CleanupStack::PopAndDestroy(text); |
|
457 } |
|
458 else |
|
459 { |
|
460 iSession->Enable(*iCalendar); |
|
461 // TODO: progressbar |
|
462 TBool enabled_new; |
|
463 iSession->EnabledSync(*iCalendar, enabled_new); |
|
464 if (!enabled_new) |
|
465 { |
|
466 ShowNoteL(R_CALDAV_QUERY_FAIL); |
|
467 } |
|
468 else |
|
469 { |
|
470 ShowNoteL(R_CALDAV_QUERY_SUCCESS); |
|
471 CAknBinaryPopupSettingItem::EditItemL(aCalledFromMenu); |
|
472 } |
|
473 } |
|
474 } |
|
475 else |
|
476 CAknBinaryPopupSettingItem::EditItemL(aCalledFromMenu); |
|
477 } |
|
478 |
|
479 /** |
|
480 * CCalDavBooleanSettingItem::StoreL |
|
481 * stores the item |
|
482 */ |
|
483 void CCalDavBooleanSettingItem::StoreL() |
|
484 { |
|
485 CAknBinaryPopupSettingItem::StoreL(); |
|
486 |
|
487 switch (Identifier()) |
|
488 { |
|
489 case ECalDavSettingKeepServer: |
|
490 iSession->SetKeepServerEntry(*iCalendar, iInternalValue); |
|
491 break; |
|
492 case ECalDavSettingSyncImmediate: |
|
493 iSession->SetImmediateSync(*iCalendar, iInternalValue); |
|
494 break; |
|
495 } |
|
496 } |
|
497 |
|
498 /** |
|
499 * CCalDavBooleanSettingItem::LoadL |
|
500 * loads the item |
|
501 */ |
|
502 void CCalDavBooleanSettingItem::LoadL() |
|
503 { |
|
504 switch (Identifier()) |
|
505 { |
|
506 case ECalDavSettingKeepServer: |
|
507 iSession->KeepServerEntry(*iCalendar, iInternalValue); |
|
508 break; |
|
509 case ECalDavSettingSyncImmediate: |
|
510 iSession->ImmediateSync(*iCalendar, iInternalValue); |
|
511 break; |
|
512 case ECalDavSettingEnable: |
|
513 iSession->EnabledSync(*iCalendar, iInternalValue); |
|
514 break; |
|
515 } |
|
516 CAknBinaryPopupSettingItem::LoadL(); |
|
517 } |
|
518 |
|
519 /** |
|
520 * CCalDavEnumeratedTextSettingItem::CCalDavEnumeratedTextSettingItem |
|
521 * default constructor |
|
522 */ |
|
523 CCalDavEnumeratedTextSettingItem::CCalDavEnumeratedTextSettingItem(TInt aId, |
|
524 CCalDavSession* aSession) : |
|
525 CAknEnumeratedTextPopupSettingItem(aId, iInternalValue), iSession(aSession) |
|
526 { |
|
527 |
|
528 } |
|
529 |
|
530 /** |
|
531 * CCalDavEnumeratedTextSettingItem::~CCalDavEnumeratedTextSettingItem |
|
532 * default destructor |
|
533 */ |
|
534 CCalDavEnumeratedTextSettingItem::~CCalDavEnumeratedTextSettingItem() |
|
535 { |
|
536 delete iCalendar; |
|
537 } |
|
538 |
|
539 /** |
|
540 * CCalDavEnumeratedTextSettingItem::NewLC |
|
541 * first phase construction |
|
542 */ |
|
543 CCalDavEnumeratedTextSettingItem* CCalDavEnumeratedTextSettingItem::NewLC( |
|
544 TInt aId, CCalDavSession* aSession, const TDesC &aCalendar) |
|
545 { |
|
546 CCalDavEnumeratedTextSettingItem* self = |
|
547 new (ELeave) CCalDavEnumeratedTextSettingItem(aId, aSession); |
|
548 CleanupStack::PushL(self); |
|
549 self->ConstructL(aCalendar); |
|
550 return self; |
|
551 } |
|
552 |
|
553 /** |
|
554 * CCalDavEnumeratedTextSettingItem::NewL |
|
555 * first phase construction |
|
556 */ |
|
557 CCalDavEnumeratedTextSettingItem* CCalDavEnumeratedTextSettingItem::NewL( |
|
558 TInt aId, CCalDavSession* aSession, const TDesC &aCalendar) |
|
559 { |
|
560 CCalDavEnumeratedTextSettingItem* self = |
|
561 CCalDavEnumeratedTextSettingItem::NewLC(aId, aSession, aCalendar); |
|
562 CleanupStack::Pop(); // self; |
|
563 return self; |
|
564 } |
|
565 |
|
566 /** |
|
567 * CCalDavEnumeratedTextSettingItem::ConstructL |
|
568 * second phase construction |
|
569 */ |
|
570 void CCalDavEnumeratedTextSettingItem::ConstructL(const TDesC &aCalendar) |
|
571 { |
|
572 iCalendar = aCalendar.AllocL(); |
|
573 HBufC* title = NULL; |
|
574 TInt text = 0; |
|
575 TInt page = R_CALDAV_BINARY_PAGE; |
|
576 switch (Identifier()) |
|
577 { |
|
578 case ECalDavSettingSyncRange: |
|
579 title = StringLoader::LoadLC(R_CALDAV_RANGE); |
|
580 text = R_CALDAV_RANGE_TEXTS; |
|
581 break; |
|
582 case ECalDavSettingSyncInterval: |
|
583 title = StringLoader::LoadLC(R_CALDAV_TIME); |
|
584 text = R_CALDAV_TIME_TEXTS; |
|
585 break; |
|
586 |
|
587 } |
|
588 SetEmptyItemTextL(KNullDesC); |
|
589 CAknEnumeratedTextSettingItem::ConstructL(EFalse, 0, *title, NULL,page, |
|
590 EAknCtPopupSettingList, NULL, text); |
|
591 CleanupStack::PopAndDestroy(title); |
|
592 } |
|
593 |
|
594 /** |
|
595 * CCalDavEnumeratedTextSettingItem::EditItemL |
|
596 * edits the item |
|
597 */ |
|
598 void CCalDavEnumeratedTextSettingItem::EditItemL(TBool aCalledFromMenu) |
|
599 { |
|
600 CAknEnumeratedTextPopupSettingItem::EditItemL(aCalledFromMenu); |
|
601 } |
|
602 |
|
603 /** |
|
604 * CCalDavEnumeratedTextSettingItem::StoreL |
|
605 * stores the item |
|
606 */ |
|
607 void CCalDavEnumeratedTextSettingItem::StoreL() |
|
608 { |
|
609 CAknEnumeratedTextPopupSettingItem::StoreL(); |
|
610 |
|
611 switch (iInternalValue) |
|
612 { |
|
613 case 0: |
|
614 { |
|
615 if (Identifier() == ECalDavSettingSyncRange) |
|
616 iSession->SetPastDays(*iCalendar, TTimeIntervalDays( |
|
617 KTIMETWOWEEKS)); |
|
618 else |
|
619 iSession->SetSyncInterval(*iCalendar, TTimeIntervalMinutes( |
|
620 KTIMEALWAYSON)); |
|
621 break; |
|
622 } |
|
623 case 1: |
|
624 { |
|
625 if (Identifier() == ECalDavSettingSyncRange) |
|
626 iSession->SetPastDays(*iCalendar, TTimeIntervalDays( |
|
627 KTIMETHREEMONTH)); |
|
628 else |
|
629 iSession->SetSyncInterval(*iCalendar, TTimeIntervalMinutes( |
|
630 KTIMEONEMINUTE)); |
|
631 break; |
|
632 } |
|
633 case 2: |
|
634 { |
|
635 if (Identifier() == ECalDavSettingSyncRange) |
|
636 iSession->SetPastDays(*iCalendar, TTimeIntervalDays( |
|
637 KTIMESIXMONTH)); |
|
638 else |
|
639 iSession->SetSyncInterval(*iCalendar, TTimeIntervalMinutes( |
|
640 KTIMEFIVEMINUTES)); |
|
641 break; |
|
642 } |
|
643 case 3: |
|
644 { |
|
645 if (Identifier() == ECalDavSettingSyncRange) |
|
646 iSession->SetPastDays(*iCalendar, TTimeIntervalDays(KTIMEALL)); |
|
647 else |
|
648 iSession->SetSyncInterval(*iCalendar, TTimeIntervalMinutes( |
|
649 KTIMEFIFTEENMINUTES)); |
|
650 break; |
|
651 } |
|
652 case 4: |
|
653 { |
|
654 if (Identifier() == ECalDavSettingSyncInterval) |
|
655 iSession->SetSyncInterval(*iCalendar, TTimeIntervalMinutes( |
|
656 KTIMETHIRTYMINUTES)); |
|
657 break; |
|
658 } |
|
659 default: |
|
660 if (Identifier() == ECalDavSettingSyncRange) |
|
661 iSession->SetPastDays(*iCalendar, TTimeIntervalDays( |
|
662 KTIMETWOWEEKS)); |
|
663 else |
|
664 iSession->SetSyncInterval(*iCalendar, TTimeIntervalMinutes( |
|
665 KTIMEALWAYSON)); |
|
666 |
|
667 break; |
|
668 } |
|
669 } |
|
670 |
|
671 /** |
|
672 * CCalDavEnumeratedTextSettingItem::LoadL |
|
673 * loads the item |
|
674 */ |
|
675 void CCalDavEnumeratedTextSettingItem::LoadL() |
|
676 { |
|
677 switch (Identifier()) |
|
678 { |
|
679 case ECalDavSettingSyncRange: |
|
680 { |
|
681 TTimeIntervalDays days; |
|
682 iSession->PastDays(*iCalendar, days); |
|
683 switch (days.Int()) |
|
684 { |
|
685 case KTIMETWOWEEKS: |
|
686 { |
|
687 iInternalValue = 0; |
|
688 break; |
|
689 } |
|
690 case KTIMETHREEMONTH: |
|
691 { |
|
692 iInternalValue = 1; |
|
693 break; |
|
694 } |
|
695 case KTIMESIXMONTH: |
|
696 { |
|
697 iInternalValue = 2; |
|
698 break; |
|
699 } |
|
700 case KTIMEALL: |
|
701 { |
|
702 iInternalValue = 3; |
|
703 break; |
|
704 } |
|
705 default: |
|
706 iInternalValue = 0; |
|
707 break; |
|
708 } |
|
709 break; |
|
710 } |
|
711 case ECalDavSettingSyncInterval: |
|
712 { |
|
713 TTimeIntervalMinutes minutes; |
|
714 iSession->SyncInterval(*iCalendar, minutes); |
|
715 switch (minutes.Int()) |
|
716 { |
|
717 case KTIMEALWAYSON: |
|
718 { |
|
719 iInternalValue = 0; |
|
720 break; |
|
721 } |
|
722 case KTIMEONEMINUTE: |
|
723 { |
|
724 iInternalValue = 1; |
|
725 break; |
|
726 } |
|
727 case KTIMEFIVEMINUTES: |
|
728 { |
|
729 iInternalValue = 2; |
|
730 break; |
|
731 } |
|
732 case KTIMEFIFTEENMINUTES: |
|
733 { |
|
734 iInternalValue = 3; |
|
735 break; |
|
736 } |
|
737 case KTIMETHIRTYMINUTES: |
|
738 { |
|
739 iInternalValue = 4; |
|
740 break; |
|
741 } |
|
742 default: |
|
743 iInternalValue = 0; |
|
744 break; |
|
745 } |
|
746 break; |
|
747 } |
|
748 } |
|
749 CAknEnumeratedTextPopupSettingItem::LoadL(); |
|
750 } |
|
751 |
|
752 /** |
|
753 * CCalDavAccessPointSettingItem::NewL |
|
754 * first phase construction |
|
755 */ |
|
756 CCalDavAccessPointSettingItem* CCalDavAccessPointSettingItem::NewL( |
|
757 TInt aSettingId, CCalDavSession* aSession, const TDesC &aCalendar) |
|
758 { |
|
759 CCalDavAccessPointSettingItem * item = |
|
760 new (ELeave) CCalDavAccessPointSettingItem(aSettingId, aSession); |
|
761 CleanupStack::PushL(item); |
|
762 item->ConstructL(aCalendar); |
|
763 CleanupStack::Pop(item); |
|
764 return item; |
|
765 } |
|
766 |
|
767 /** |
|
768 * CCalDavAccessPointSettingItem::CCalDavAccessPointSettingItem |
|
769 * default constructor |
|
770 */ |
|
771 CCalDavAccessPointSettingItem::CCalDavAccessPointSettingItem(TInt aSettingId, |
|
772 CCalDavSession* aSession) : |
|
773 CAknSettingItem(aSettingId), iSession(aSession) |
|
774 { |
|
775 } |
|
776 |
|
777 /** |
|
778 * CCalDavAccessPointSettingItem::~CCalDavAccessPointSettingItem |
|
779 * default destructor |
|
780 */ |
|
781 CCalDavAccessPointSettingItem::~CCalDavAccessPointSettingItem() |
|
782 { |
|
783 delete iSettingText; |
|
784 } |
|
785 |
|
786 /** |
|
787 * CCalDavAccessPointSettingItem::ConstructL |
|
788 * second phase construction |
|
789 */ |
|
790 void CCalDavAccessPointSettingItem::ConstructL(const TDesC &/*aCalendar*/) |
|
791 { |
|
792 SetEmptyItemTextL(KNullDesC); |
|
793 HBufC* title = StringLoader::LoadLC(R_CALDAV_ACCESS_POINT); |
|
794 CAknSettingItem::ConstructL(EFalse, 0, *title, NULL,0, 0); |
|
795 CleanupStack::PopAndDestroy(title); |
|
796 |
|
797 _LIT(hi,"Default Connection"); |
|
798 iSettingText = hi().Alloc(); |
|
799 } |
|
800 |
|
801 /** |
|
802 * CCalDavAccessPointSettingItem::EditItemL |
|
803 * edits the item |
|
804 */ |
|
805 void CCalDavAccessPointSettingItem::EditItemL(TBool /*aCalledFromMenu*/) |
|
806 { |
|
807 delete iSettingText; |
|
808 iSettingText = NULL; |
|
809 |
|
810 TCmSettingSelection userSelection; |
|
811 userSelection.iId = 0; |
|
812 userSelection.iResult = CMManager::EDefaultConnection; |
|
813 |
|
814 CCmApplicationSettingsUi* settings = CCmApplicationSettingsUi::NewL(); |
|
815 CleanupStack::PushL(settings); |
|
816 TUint listedItems = CMManager::EShowDefaultConnection |
|
817 | CMManager::EShowDestinations | CMManager::EShowConnectionMethods; |
|
818 TBearerFilterArray filter; |
|
819 settings->RunApplicationSettingsL(userSelection, listedItems, filter); |
|
820 CleanupStack::PopAndDestroy(settings); |
|
821 |
|
822 switch (userSelection.iResult) |
|
823 { |
|
824 case CMManager::EDestination: |
|
825 { |
|
826 TConnSnapPref prefs; |
|
827 prefs.SetSnap(userSelection.iId); |
|
828 // iSettingText = |
|
829 // iConnection.Start( prefs, iStatus ); |
|
830 break; |
|
831 } |
|
832 case CMManager::EConnectionMethod: |
|
833 { |
|
834 TCommDbConnPref prefs; |
|
835 prefs.SetIapId(userSelection.iId); |
|
836 prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt); |
|
837 |
|
838 // iConnection.Start( prefs, iStatus ); |
|
839 // iSettingText = |
|
840 break; |
|
841 } |
|
842 case CMManager::EDefaultConnection: |
|
843 { |
|
844 // iConnection.Start( iStatus ); |
|
845 // iSettingText = |
|
846 break; |
|
847 } |
|
848 } |
|
849 UpdateListBoxTextL(); |
|
850 } |
|
851 |
|
852 /** |
|
853 * CCalDavAccessPointSettingItem::SettingTextL |
|
854 * returns the setting text |
|
855 */ |
|
856 const TDesC& CCalDavAccessPointSettingItem::SettingTextL() |
|
857 { |
|
858 if (!iSettingText) |
|
859 { |
|
860 return CAknSettingItem::SettingTextL(); |
|
861 } |
|
862 else if (iSettingText->Length() == 0) |
|
863 { |
|
864 return CAknSettingItem::SettingTextL(); |
|
865 } |
|
866 |
|
867 return *iSettingText; |
|
868 } |
|
869 |
|
870 /** |
|
871 * CCalDavAccessPointSettingItem::StoreL |
|
872 * stores the item |
|
873 */ |
|
874 void CCalDavAccessPointSettingItem::StoreL() |
|
875 { |
|
876 CAknSettingItem::StoreL(); |
|
877 } |
|
878 |
|
879 /** |
|
880 * CCalDavAccessPointSettingItem::LoadL |
|
881 * loads the item |
|
882 */ |
|
883 void CCalDavAccessPointSettingItem::LoadL() |
|
884 { |
|
885 //CAknSettingItem::Load(); |
|
886 } |
|
887 // End of File |
|