|
1 // fcalendar.cpp |
|
2 // |
|
3 // Copyright (c) 2009 - 2010 Accenture. All rights reserved. |
|
4 // This component and the accompanying materials are made available |
|
5 // under the terms of the "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 // Accenture - Initial contribution |
|
11 // |
|
12 |
|
13 #include "caliterator.h" |
|
14 #include <calsession.h> |
|
15 #include <calentryview.h> |
|
16 #include <calentry.h> |
|
17 #include <calalarm.h> |
|
18 #include <calrrule.h> |
|
19 #include <caluser.h> |
|
20 #include <calprogresscallback.h> |
|
21 #include <fshell/ioutils.h> |
|
22 |
|
23 using namespace IoUtils; |
|
24 |
|
25 |
|
26 // Destroy the RPointerArray |
|
27 void DestroyCalEntryRPointerArray(TAny* aPtr) |
|
28 { |
|
29 RPointerArray<CCalEntry>* self = static_cast<RPointerArray<CCalEntry>*> (aPtr); |
|
30 self->ResetAndDestroy(); |
|
31 } |
|
32 |
|
33 |
|
34 |
|
35 enum TCurrentOperation |
|
36 { |
|
37 ECONewEntryView, |
|
38 ECONone |
|
39 }; |
|
40 |
|
41 class CCmdCalendar : public CCommandBase, public MCalProgressCallBack |
|
42 { |
|
43 public: |
|
44 static CCommandBase* NewLC(); |
|
45 ~CCmdCalendar(); |
|
46 private: |
|
47 CCmdCalendar(); |
|
48 |
|
49 void DoListEntryL(); |
|
50 void DoDeleteEntryL(); |
|
51 void DoAddEntryL(); |
|
52 void DoChangeEntryL(); |
|
53 |
|
54 void ReadCmdLineAmendEntryContentL(CCalEntry& aEntry); |
|
55 void ListGSDetailL(const TDesC8& aGlobalId, TInt aVerboseLevel); |
|
56 void PrintEntryDetailL(CCalEntry* aEntry, TInt aVerboseLevel); |
|
57 |
|
58 void PrintAcceptedOptions(); |
|
59 |
|
60 TInt CheckAlarmAlertServer(); |
|
61 |
|
62 static const TDesC* UidName(TUid aUid); |
|
63 static const TDesC* EntryMethodToString(CCalEntry::TMethod aEntryMethod); |
|
64 static const TDesC* EntryStatusToString(CCalEntry::TStatus aEntryStatus); |
|
65 static const TDesC* EntryTypeToString(CCalEntry::TType aEntryType); |
|
66 static const TDesC* RepeatTypeToString(TCalRRule::TType aType); |
|
67 void PrintTime(const TTime& aTime, TBool aNewline); |
|
68 private: // From CCommandBase. |
|
69 virtual const TDesC& Name() const; |
|
70 virtual void DoRunL(); |
|
71 virtual void ArgumentsL(RCommandArgumentList& aArguments); |
|
72 virtual void OptionsL(RCommandOptionList& aOptions); |
|
73 |
|
74 private: //MCalProgressCallBack |
|
75 virtual void Progress(TInt aPercentageCompleted); |
|
76 virtual void Completed(TInt aError); |
|
77 virtual TBool NotifyProgress(); |
|
78 |
|
79 private: |
|
80 CActiveSchedulerWait* iActiveWait; |
|
81 TCurrentOperation iCurOpr; |
|
82 |
|
83 CCalSession* iCalSes; |
|
84 CCalEntryView* iEntryView; |
|
85 |
|
86 RArray<TBool> iVerbose; |
|
87 HBufC* iOptFileName; //calendar database file full path |
|
88 TInt iOptLocalId; //local ID |
|
89 HBufC* iOptGlobalID; |
|
90 CCalEntry::TType iOptType; |
|
91 HBufC* iOptSummary; |
|
92 HBufC* iOptStartTime; |
|
93 HBufC* iOptEndTime; |
|
94 |
|
95 |
|
96 enum |
|
97 { |
|
98 EListEntry, |
|
99 EDeleteEntry, |
|
100 EAddEntry, |
|
101 EChangeEntry, |
|
102 } iCommand; |
|
103 }; |
|
104 |
|
105 CCommandBase* CCmdCalendar::NewLC() |
|
106 { |
|
107 CCmdCalendar* self = new(ELeave) CCmdCalendar(); |
|
108 CleanupStack::PushL(self); |
|
109 self->BaseConstructL(); |
|
110 return self; |
|
111 } |
|
112 |
|
113 CCmdCalendar::CCmdCalendar() |
|
114 { |
|
115 iCurOpr = ECONone; |
|
116 iActiveWait = new (ELeave) CActiveSchedulerWait; |
|
117 } |
|
118 |
|
119 |
|
120 CCmdCalendar::~CCmdCalendar() |
|
121 { |
|
122 delete iOptFileName; |
|
123 delete iOptGlobalID; |
|
124 delete iOptSummary; |
|
125 delete iOptStartTime; |
|
126 delete iOptEndTime; |
|
127 delete iEntryView; |
|
128 delete iCalSes; |
|
129 delete iActiveWait; |
|
130 iVerbose.Close(); |
|
131 } |
|
132 |
|
133 ////////////////////////////////////////////////////// |
|
134 |
|
135 //virtual |
|
136 void CCmdCalendar::Progress(TInt /*aPercentageCompleted*/) |
|
137 { |
|
138 ; |
|
139 } |
|
140 |
|
141 //virtual |
|
142 void CCmdCalendar::Completed(TInt /*aError*/) |
|
143 { |
|
144 TBool bWaitStarted = iActiveWait->IsStarted(); |
|
145 ASSERT(bWaitStarted); |
|
146 (void)bWaitStarted; |
|
147 |
|
148 if (iCurOpr == ECONewEntryView) |
|
149 { |
|
150 iActiveWait->AsyncStop(); |
|
151 } |
|
152 |
|
153 iCurOpr = ECONone; |
|
154 } |
|
155 |
|
156 TBool CCmdCalendar::NotifyProgress() |
|
157 { |
|
158 return ETrue; |
|
159 } |
|
160 |
|
161 const TDesC& CCmdCalendar::Name() const |
|
162 { |
|
163 _LIT(KName, "fcalendar"); |
|
164 return KName; |
|
165 } |
|
166 |
|
167 void CCmdCalendar::ArgumentsL(RCommandArgumentList& aArguments) |
|
168 { |
|
169 _LIT(KArgCommand, "command"); |
|
170 aArguments.AppendEnumL((TInt&)iCommand, KArgCommand); |
|
171 } |
|
172 |
|
173 void CCmdCalendar::OptionsL(RCommandOptionList& aOptions) |
|
174 { |
|
175 _LIT(KOptVerbose, "verbose"); |
|
176 aOptions.AppendBoolL(iVerbose, KOptVerbose); |
|
177 |
|
178 _LIT(KOptFile, "file"); |
|
179 aOptions.AppendStringL(iOptFileName, KOptFile); |
|
180 |
|
181 _LIT(KOptLocalId, "local_id"); |
|
182 aOptions.AppendUintL((TUint&)iOptLocalId, KOptLocalId); |
|
183 |
|
184 _LIT(KOptGlobalId, "global_id"); |
|
185 aOptions.AppendStringL(iOptGlobalID, KOptGlobalId); |
|
186 |
|
187 _LIT(KOptType, "type"); |
|
188 aOptions.AppendEnumL((TInt&)iOptType, KOptType); |
|
189 |
|
190 _LIT(KOptSummary, "summary"); |
|
191 aOptions.AppendStringL(iOptSummary, KOptSummary); |
|
192 |
|
193 _LIT(KOptStartTime, "start_time"); |
|
194 aOptions.AppendStringL(iOptStartTime, KOptStartTime); |
|
195 |
|
196 _LIT(KOptEndTime, "end_time"); |
|
197 aOptions.AppendStringL(iOptEndTime, KOptEndTime); |
|
198 } |
|
199 |
|
200 //calendar have dependency on !AlamAlertServer, |
|
201 //this server is usually part of eikon and not likely to be started separately |
|
202 //we need to check if this server is up and running, |
|
203 //if not, no point to contiune |
|
204 // |
|
205 //return: |
|
206 //-1 (KErrNotFound): this server is not running |
|
207 //0 (KErrNone): OK |
|
208 TInt CCmdCalendar::CheckAlarmAlertServer() |
|
209 { |
|
210 TInt Ret; |
|
211 TInt Res; |
|
212 TFindServer findASServer(_L("!AlarmAlertServer")); |
|
213 TFullName name; |
|
214 Res = findASServer.Next(name); |
|
215 |
|
216 if (Res==KErrNotFound ) |
|
217 Ret = KErrNotFound; |
|
218 else |
|
219 Ret = KErrNone; |
|
220 |
|
221 return Ret; |
|
222 } |
|
223 |
|
224 |
|
225 void CCmdCalendar::DoRunL() |
|
226 { |
|
227 TInt res; |
|
228 res = CheckAlarmAlertServer(); |
|
229 LeaveIfErr(res, _L("!AlarmAlertServer not running")); |
|
230 |
|
231 TRAPD(err, iCalSes = CCalSession::NewL() ); |
|
232 LeaveIfErr(err, _L("Could not connect to Calendar server")); |
|
233 |
|
234 //open the calendar database file |
|
235 if (iOptFileName && iOptFileName->Length()>0 ) |
|
236 { |
|
237 Printf(_L("Calendar Database file: %S \r\n"), iOptFileName); |
|
238 } |
|
239 else |
|
240 { |
|
241 Printf(_L("Calendar Database file unspecified, by default S60 database file is c:Calendar\r\n")); |
|
242 delete iOptFileName; iOptFileName = NULL; |
|
243 iOptFileName = HBufC::NewL(128); |
|
244 *iOptFileName = _L("c:Calendar"); |
|
245 } |
|
246 |
|
247 //open database file |
|
248 TRAP(err, iCalSes->OpenL(*iOptFileName) ); |
|
249 LeaveIfErr(err, _L("Could not open database file")); |
|
250 |
|
251 //Create an entry view |
|
252 iCurOpr = ECONewEntryView; |
|
253 TRAP(err, iEntryView = CCalEntryView::NewL(*iCalSes, *this)); |
|
254 LeaveIfErr(err, _L("Could not create entry view")); |
|
255 |
|
256 //entry view takes a long time to build index, and we must not do anything |
|
257 //until we received callback, therefore, must wait here. |
|
258 iActiveWait->Start(); |
|
259 |
|
260 /////////////////////////////////////////////////////////////////////////// |
|
261 |
|
262 switch (iCommand) |
|
263 { |
|
264 case EListEntry: |
|
265 DoListEntryL(); |
|
266 break; |
|
267 case EDeleteEntry: |
|
268 DoDeleteEntryL(); |
|
269 break; |
|
270 case EAddEntry: |
|
271 DoAddEntryL(); |
|
272 break; |
|
273 case EChangeEntry: |
|
274 DoChangeEntryL(); |
|
275 break; |
|
276 }; |
|
277 |
|
278 } |
|
279 |
|
280 void CCmdCalendar::DoChangeEntryL() |
|
281 { |
|
282 //compulsory: globalid, these can not be changed later |
|
283 if (!iOptGlobalID || iOptGlobalID->Length()== 0) |
|
284 LeaveIfErr(KErrArgument, _L("No global id specified. Use -g to specify one")); |
|
285 |
|
286 //type cannot be changed by calendar API, warning user of this fact |
|
287 if (iOptions.IsPresent(&iOptType)) |
|
288 { |
|
289 Printf(_L("Type is not allowed to change, this option (-t) will be ignored.\r\n")); |
|
290 } |
|
291 |
|
292 RPointerArray<CCalEntry> CalEntryArray; |
|
293 CleanupStack::PushL(TCleanupItem(DestroyCalEntryRPointerArray, &CalEntryArray)); |
|
294 |
|
295 TBuf8<128> TmpGlobalId; |
|
296 TmpGlobalId.Copy(*iOptGlobalID); |
|
297 HBufC8* pGlobalId = HBufC8::New(128); |
|
298 CleanupStack::PushL(pGlobalId); |
|
299 *pGlobalId = TmpGlobalId; |
|
300 |
|
301 //do an extra check if the same global ID is already used. |
|
302 iEntryView->FetchL(*pGlobalId, CalEntryArray); |
|
303 CleanupStack::PopAndDestroy(pGlobalId); |
|
304 pGlobalId = NULL; //this HBufC is owned by CalEntry |
|
305 |
|
306 TInt Cnt = CalEntryArray.Count(); |
|
307 if (Cnt == 0) |
|
308 LeaveIfErr(KErrNotFound, _L("No such Global ID.")); |
|
309 |
|
310 Printf(_L("%d entries found\r\n"), Cnt); |
|
311 |
|
312 CCalEntry* pEntry = CalEntryArray[0]; |
|
313 |
|
314 //amend necessary calendar entry properties |
|
315 ReadCmdLineAmendEntryContentL(*pEntry); |
|
316 |
|
317 TInt SucessfulEntryCnt = 0; |
|
318 iEntryView->UpdateL(CalEntryArray, SucessfulEntryCnt); |
|
319 |
|
320 Printf(_L("%d entries changed\r\n"), SucessfulEntryCnt); |
|
321 |
|
322 CleanupStack::PopAndDestroy(); |
|
323 } |
|
324 |
|
325 void CCmdCalendar::DoAddEntryL() |
|
326 { |
|
327 //compulsory: globalid, type, these can not be changed later |
|
328 if (!iOptGlobalID || iOptGlobalID->Length()== 0) |
|
329 LeaveIfErr(KErrArgument, _L("No global id specified. Use -g to specify one")); |
|
330 if (!iOptions.IsPresent(&iOptType)) |
|
331 LeaveIfErr(KErrArgument, _L("No type specified. Use -t to specify one")); |
|
332 |
|
333 RPointerArray<CCalEntry> CalEntryArray; |
|
334 CleanupStack::PushL(TCleanupItem(DestroyCalEntryRPointerArray, &CalEntryArray)); |
|
335 |
|
336 TBuf8<128> TmpGlobalId; |
|
337 TmpGlobalId.Copy(*iOptGlobalID); |
|
338 HBufC8* pGlobalId = HBufC8::New(128); |
|
339 CleanupStack::PushL(pGlobalId); |
|
340 *pGlobalId = TmpGlobalId; |
|
341 |
|
342 //do an extra check if the same global ID is already used. |
|
343 //if yes, then adding with such global id is not allowed |
|
344 { |
|
345 iEntryView->FetchL(*pGlobalId, CalEntryArray); |
|
346 TInt Cnt = CalEntryArray.Count(); |
|
347 if (Cnt > 0) |
|
348 LeaveIfErr(KErrAlreadyExists, _L("The same Global ID is already used.")); |
|
349 } |
|
350 |
|
351 CCalEntry* pEntry = CCalEntry::NewL(iOptType, pGlobalId, |
|
352 CCalEntry::EMethodNone, 0); |
|
353 CleanupStack::Pop(pGlobalId); |
|
354 pGlobalId = NULL; //this HBufC is owned by CalEntry |
|
355 |
|
356 CalEntryArray.Append(pEntry); |
|
357 |
|
358 //amend necessary calendar entry properties |
|
359 ReadCmdLineAmendEntryContentL(*pEntry); |
|
360 |
|
361 TInt SucessfulEntryCnt = 0; |
|
362 iEntryView->StoreL(CalEntryArray, SucessfulEntryCnt); |
|
363 |
|
364 Printf(_L("%d entries added\r\n"), SucessfulEntryCnt); |
|
365 |
|
366 CleanupStack::PopAndDestroy(); |
|
367 } |
|
368 |
|
369 void CCmdCalendar::DoDeleteEntryL() |
|
370 { |
|
371 //TInt VerboseLevel = iVerbose.Count(); |
|
372 if (iOptGlobalID && iOptGlobalID->Length()) |
|
373 { |
|
374 RPointerArray<CCalEntry> CalEntryArray; |
|
375 CleanupStack::PushL(TCleanupItem(DestroyCalEntryRPointerArray, &CalEntryArray)); |
|
376 |
|
377 //FetchL is not Async |
|
378 //and there will be new CCalEntry objects generared |
|
379 //and pointer stored in CalEntryArray |
|
380 TBuf8<256> GlobalID; |
|
381 GlobalID.Copy(*iOptGlobalID); |
|
382 |
|
383 iEntryView->FetchL(GlobalID, CalEntryArray); |
|
384 |
|
385 TInt EntryCount = CalEntryArray.Count(); |
|
386 Printf(_L("%d Entries found\r\n"), EntryCount); |
|
387 |
|
388 for (TInt i=0; i<EntryCount; i++) |
|
389 { |
|
390 CCalEntry* pEntry = CalEntryArray[0]; |
|
391 CalEntryArray.Remove(0); |
|
392 |
|
393 CleanupStack::PushL(pEntry); |
|
394 iEntryView->DeleteL(*pEntry); |
|
395 CleanupStack::PopAndDestroy(pEntry); |
|
396 } |
|
397 |
|
398 Printf(_L("%d Entries deleted\r\n"), EntryCount); |
|
399 CleanupStack::PopAndDestroy(); |
|
400 } |
|
401 else |
|
402 { |
|
403 LeaveIfErr(KErrArgument, _L("No global id specified. Use -g to specify one")); |
|
404 } |
|
405 } |
|
406 |
|
407 //list all agenda entry in the agenda server |
|
408 void CCmdCalendar::DoListEntryL() |
|
409 { |
|
410 TInt VerboseLevel = iVerbose.Count(); |
|
411 |
|
412 CCalIter* pIter = CCalIter::NewL(*iCalSes); |
|
413 CleanupStack::PushL(pIter); |
|
414 |
|
415 const TDesC8* pGlb = &(pIter->FirstL()); |
|
416 TBuf<128> GlbId; |
|
417 |
|
418 while(*pGlb != KNullDesC8) |
|
419 { |
|
420 GlbId.Copy(*pGlb); |
|
421 Printf(_L("================================\r\n")); |
|
422 Printf(_L("Group Scheduling Entry, Global ID: %S\r\n"), &GlbId); |
|
423 ListGSDetailL(*pGlb, VerboseLevel); |
|
424 |
|
425 pGlb = &(pIter->NextL()); |
|
426 } |
|
427 |
|
428 CleanupStack::PopAndDestroy(pIter); |
|
429 } |
|
430 |
|
431 //this function read user command line options, |
|
432 //and amend the corresponding Entry properties |
|
433 // |
|
434 void CCmdCalendar::ReadCmdLineAmendEntryContentL(CCalEntry& aEntry) |
|
435 { |
|
436 TInt res; |
|
437 //summary is optional |
|
438 if (iOptSummary && iOptSummary->Length() > 0) |
|
439 aEntry.SetSummaryL(*iOptSummary); |
|
440 |
|
441 TCalTime StartTime = aEntry.StartTimeL(); |
|
442 TCalTime EndTime = aEntry.EndTimeL(); |
|
443 |
|
444 if (iOptStartTime && iOptStartTime->Length() > 0) |
|
445 { |
|
446 TTime Tmp(Time::NullTTime()); |
|
447 res = Tmp.Parse(*iOptStartTime); |
|
448 if (res >= 0) |
|
449 { |
|
450 Printf(_L("StartTime recognised as ") ); |
|
451 PrintTime(Tmp, ETrue); |
|
452 StartTime.SetTimeUtcL(Tmp); |
|
453 } |
|
454 else |
|
455 { |
|
456 Printf(_L("Start Date/Time format not recogised.\r\n") ); |
|
457 } |
|
458 } |
|
459 if (iOptEndTime && iOptEndTime->Length() > 0) |
|
460 { |
|
461 TTime Tmp(Time::NullTTime()); |
|
462 res = Tmp.Parse(*iOptEndTime); |
|
463 if (res >= 0) |
|
464 { |
|
465 Printf(_L("EndTime recognised as ") ); |
|
466 PrintTime(Tmp, ETrue); |
|
467 EndTime.SetTimeUtcL(Tmp); |
|
468 } |
|
469 else |
|
470 { |
|
471 Printf(_L("End Date/Time format not recogised.\r\n") ); |
|
472 } |
|
473 |
|
474 } |
|
475 |
|
476 aEntry.SetStartAndEndTimeL(StartTime, EndTime); |
|
477 |
|
478 if (iOptLocalId) |
|
479 { |
|
480 TCalLocalUid LocalId = (TCalLocalUid) iOptLocalId; |
|
481 aEntry.SetLocalUidL(LocalId); |
|
482 } |
|
483 } |
|
484 |
|
485 |
|
486 //verbose level |
|
487 //-v = 1, -vv = 2 |
|
488 // |
|
489 void CCmdCalendar::ListGSDetailL(const TDesC8& aGlobalId, TInt aVerboseLevel) |
|
490 { |
|
491 RPointerArray<CCalEntry> CalEntryArray; |
|
492 CleanupStack::PushL(TCleanupItem(DestroyCalEntryRPointerArray, &CalEntryArray)); |
|
493 |
|
494 //FetchL is not Async |
|
495 //and there will be new CCalEntry objects generared |
|
496 //and pointer stored in CalEntryArray |
|
497 iEntryView->FetchL(aGlobalId, CalEntryArray); |
|
498 |
|
499 TInt Count = CalEntryArray.Count(); |
|
500 for (TInt i=0; i<Count; i++) |
|
501 { |
|
502 CCalEntry* pCalEntry= CalEntryArray[0]; |
|
503 CalEntryArray.Remove(0); |
|
504 CleanupStack::PushL(pCalEntry); |
|
505 |
|
506 //make sure leave does not occur inside this scope, |
|
507 //or contents in CalEntryArray may not be cleaned |
|
508 TRAP_IGNORE(PrintEntryDetailL(pCalEntry, aVerboseLevel)); |
|
509 |
|
510 CleanupStack::PopAndDestroy(pCalEntry); |
|
511 } |
|
512 |
|
513 |
|
514 CleanupStack::PopAndDestroy(); |
|
515 } |
|
516 |
|
517 |
|
518 void CCmdCalendar::PrintEntryDetailL(CCalEntry* aEntry, TInt aVerboseLevel) |
|
519 { |
|
520 //this matches the Group Scheduling global ID, no need to print it out |
|
521 //const TDesC8& EntryID = aEntry->UidL(); |
|
522 |
|
523 //for verbose level 0 |
|
524 //entry type, summery, start time, end time, priority |
|
525 CCalEntry::TType EntryType = aEntry->EntryTypeL(); |
|
526 const TDesC& EntrySummary = aEntry->SummaryL(); |
|
527 TCalTime EntryStartTime = aEntry->StartTimeL(); |
|
528 TCalTime EntryEndTime = aEntry->EndTimeL(); |
|
529 |
|
530 TCalTime EntryCompTime = aEntry->CompletedTimeL(); |
|
531 TCalTime EntryModDate = aEntry->LastModifiedDateL(); |
|
532 |
|
533 TUint EntryPriority = aEntry->PriorityL(); |
|
534 |
|
535 Printf(_L("Type:%S Priority: %u Summary:%S\r\n"), |
|
536 EntryTypeToString(EntryType), EntryPriority, &EntrySummary); |
|
537 |
|
538 Printf(_L(" StartTime:")); |
|
539 PrintTime(EntryStartTime.TimeUtcL(), EFalse); |
|
540 |
|
541 Printf(_L(" EndTime:")); |
|
542 PrintTime(EntryEndTime.TimeUtcL(), EFalse); |
|
543 |
|
544 Printf(_L("\r\n")); |
|
545 Printf(_L(" CompletedTime:")); |
|
546 PrintTime(EntryCompTime.TimeUtcL(), EFalse); |
|
547 |
|
548 Printf(_L(" Last Modified:")); |
|
549 PrintTime(EntryModDate.TimeUtcL(), EFalse); |
|
550 |
|
551 Printf(_L("\r\n")); |
|
552 |
|
553 |
|
554 if (aVerboseLevel < 1) |
|
555 return; |
|
556 |
|
557 //local id, location, status, method, description |
|
558 TCalLocalUid EntryLocalId = aEntry->LocalUidL(); |
|
559 const TDesC& EntryLocation = aEntry->LocationL(); |
|
560 CCalEntry::TStatus EntryStatus = aEntry->StatusL(); |
|
561 CCalEntry::TMethod EntryMethod = aEntry->MethodL(); |
|
562 const TDesC& EntryDesc = aEntry->DescriptionL(); |
|
563 TInt EntrySequenceNo = aEntry->SequenceNumberL(); |
|
564 |
|
565 Printf(_L(" LocalId:%u, SeqNo:%d,Location:%S Description:%S\r\n"), |
|
566 EntryLocalId, EntrySequenceNo, &EntryLocation, &EntryDesc); |
|
567 Printf(_L(" Status:%S Method:%S\r\n"), |
|
568 EntryStatusToString(EntryStatus), EntryMethodToString(EntryMethod)); |
|
569 |
|
570 |
|
571 //alarm |
|
572 CCalAlarm* pAlarm = aEntry->AlarmL(); |
|
573 TPtrC AlarmYesNo = (pAlarm)?_L("Yes"):_L("No"); |
|
574 Printf(_L(" Alarm: %S "), &AlarmYesNo); |
|
575 |
|
576 if (pAlarm && aVerboseLevel > 1) |
|
577 { |
|
578 CleanupStack::PushL(pAlarm); |
|
579 const TDesC& AlarmSound = pAlarm->AlarmSoundNameL(); |
|
580 TTimeIntervalMinutes AlarmOffset = pAlarm->TimeOffset(); |
|
581 |
|
582 Printf(_L("AlarmSound:%S, MinutesInAdvance:%d"), |
|
583 &AlarmSound, AlarmOffset.Int()); |
|
584 |
|
585 //CCalContent is optional, will be included from calalarm if it's present |
|
586 #ifdef __CALCONTENT_H__ |
|
587 CCalContent* pAlarmContent = pAlarm->AlarmAction(); |
|
588 if (pAlarmContent) |
|
589 { |
|
590 const TDesC8& AlarmContent = pAlarmContent->Content(); |
|
591 const TDesC8& AlarmMime = pAlarmContent->MimeType(); |
|
592 |
|
593 Printf(_L8("\r\nAlarmContent:%S, AlarmMime:%S "), |
|
594 &AlarmContent, &AlarmMime); |
|
595 |
|
596 } |
|
597 #endif |
|
598 CleanupStack::PopAndDestroy(pAlarm); |
|
599 } |
|
600 Printf(_L("\r\n")); |
|
601 |
|
602 //repeat rules |
|
603 TCalRRule RepeatRule; |
|
604 TBool bRepeat = aEntry->GetRRuleL(RepeatRule); |
|
605 TPtrC RepeatYesNo = (bRepeat)?_L("Yes"):_L("No"); |
|
606 Printf(_L(" Repeat: %S "), &RepeatYesNo); |
|
607 |
|
608 if (bRepeat && aVerboseLevel > 1) |
|
609 { |
|
610 TCalRRule::TType RepeatType = RepeatRule.Type(); |
|
611 TInt RepeatInterval = RepeatRule.Interval(); |
|
612 TUint RepeatCount = RepeatRule.Count(); |
|
613 |
|
614 Printf(_L("RepeatType: %S Interval: %d Count:%u\r\n"), |
|
615 RepeatTypeToString(RepeatType), RepeatInterval, RepeatCount); |
|
616 TCalTime RepeatStart = RepeatRule.DtStart(); |
|
617 TCalTime RepeatUntil = RepeatRule.Until(); |
|
618 |
|
619 Printf(_L(" RepeatStart:")); |
|
620 PrintTime(RepeatStart.TimeUtcL(), EFalse); |
|
621 |
|
622 Printf(_L(" RepeatUntil:")); |
|
623 PrintTime(RepeatUntil.TimeUtcL(), EFalse); |
|
624 } |
|
625 Printf(_L("\r\n")); |
|
626 |
|
627 //attendee, in most of phone implementation it is not used |
|
628 RPointerArray<CCalAttendee>& AttendeeArray = aEntry->AttendeesL(); |
|
629 TInt AttendeeCnt = AttendeeArray.Count(); |
|
630 TPtrC AttendeeYesNo = (AttendeeCnt>0)?_L("Yes"):_L("No"); |
|
631 Printf(_L(" Attendee: %S "), &AttendeeYesNo); |
|
632 |
|
633 if (AttendeeCnt>0 && aVerboseLevel > 1) |
|
634 { |
|
635 for (TInt i=0; i<AttendeeCnt; i++) |
|
636 { |
|
637 CCalAttendee* pAttendee = AttendeeArray[i]; |
|
638 const TDesC& AttendeeName = pAttendee->CommonName(); |
|
639 Printf(_L("Attendee:%S "), &AttendeeName); |
|
640 } |
|
641 } |
|
642 Printf(_L("\r\n")); |
|
643 |
|
644 } |
|
645 |
|
646 //print the accepted options from the command line |
|
647 void CCmdCalendar::PrintAcceptedOptions() |
|
648 { |
|
649 } |
|
650 |
|
651 |
|
652 void CCmdCalendar::PrintTime(const TTime& aTime, TBool aNewline) |
|
653 { |
|
654 |
|
655 TTime NullTime = Time::NullTTime(); |
|
656 if (aTime == NullTime) |
|
657 { |
|
658 Printf(_L("(NullTime)")); |
|
659 } |
|
660 else |
|
661 { |
|
662 _LIT8(KDateTimeFormat, "%d-%02d-%02d %02d:%02d:%02d"); |
|
663 TDateTime dt = aTime.DateTime(); |
|
664 Printf(KDateTimeFormat, dt.Year(), dt.Month()+1, dt.Day()+1, dt.Hour(), dt.Minute(), dt.Second()); |
|
665 } |
|
666 |
|
667 if (aNewline) Printf(_L("\r\n")); |
|
668 } |
|
669 |
|
670 |
|
671 #define CASE_LIT(x) case x: { _LIT(KName, #x); return &KName; } |
|
672 |
|
673 |
|
674 const TDesC* CCmdCalendar::RepeatTypeToString(TCalRRule::TType aType) |
|
675 { |
|
676 switch(aType) |
|
677 { |
|
678 CASE_LIT(TCalRRule::EInvalid) |
|
679 CASE_LIT(TCalRRule::EDaily) |
|
680 CASE_LIT(TCalRRule::EWeekly) |
|
681 CASE_LIT(TCalRRule::EMonthly) |
|
682 CASE_LIT(TCalRRule::EYearly) |
|
683 default: |
|
684 { |
|
685 _LIT(KUnknown, "Unknown"); |
|
686 return &KUnknown; |
|
687 } |
|
688 } |
|
689 } |
|
690 |
|
691 const TDesC* CCmdCalendar::EntryMethodToString(CCalEntry::TMethod aEntryMethod) |
|
692 { |
|
693 switch(aEntryMethod) |
|
694 { |
|
695 CASE_LIT(CCalEntry::EMethodNone) |
|
696 CASE_LIT(CCalEntry::EMethodPublish) |
|
697 CASE_LIT(CCalEntry::EMethodRequest) |
|
698 CASE_LIT(CCalEntry::EMethodReply) |
|
699 CASE_LIT(CCalEntry::EMethodAdd) |
|
700 CASE_LIT(CCalEntry::EMethodCancel) |
|
701 CASE_LIT(CCalEntry::EMethodRefresh) |
|
702 CASE_LIT(CCalEntry::EMethodCounter) |
|
703 CASE_LIT(CCalEntry::EMethodDeclineCounter) |
|
704 default: |
|
705 { |
|
706 _LIT(KUnknown, "Unknown"); |
|
707 return &KUnknown; |
|
708 } |
|
709 } |
|
710 } |
|
711 |
|
712 const TDesC* CCmdCalendar::EntryStatusToString(CCalEntry::TStatus aEntryStatus) |
|
713 { |
|
714 switch(aEntryStatus) |
|
715 { |
|
716 CASE_LIT(CCalEntry::ETentative) |
|
717 CASE_LIT(CCalEntry::EConfirmed) |
|
718 CASE_LIT(CCalEntry::ECancelled) |
|
719 CASE_LIT(CCalEntry::ETodoNeedsAction) |
|
720 CASE_LIT(CCalEntry::ETodoCompleted) |
|
721 CASE_LIT(CCalEntry::ETodoInProcess) |
|
722 CASE_LIT(CCalEntry::ENullStatus) |
|
723 default: |
|
724 { |
|
725 _LIT(KUnknown, "Unknown"); |
|
726 return &KUnknown; |
|
727 } |
|
728 } |
|
729 } |
|
730 |
|
731 const TDesC* CCmdCalendar::EntryTypeToString(CCalEntry::TType aEntryType) |
|
732 { |
|
733 switch(aEntryType) |
|
734 { |
|
735 CASE_LIT(CCalEntry::EAppt) |
|
736 CASE_LIT(CCalEntry::ETodo) |
|
737 CASE_LIT(CCalEntry::EEvent) |
|
738 CASE_LIT(CCalEntry::EReminder) |
|
739 CASE_LIT(CCalEntry::EAnniv) |
|
740 default: |
|
741 { |
|
742 _LIT(KUnknown, "Unknown"); |
|
743 return &KUnknown; |
|
744 } |
|
745 } |
|
746 } |
|
747 |
|
748 const TDesC* CCmdCalendar::UidName(TUid aUid) |
|
749 { |
|
750 switch (aUid.iUid) |
|
751 { |
|
752 |
|
753 default: |
|
754 { |
|
755 _LIT(KUnknown, "Unknown"); |
|
756 return &KUnknown; |
|
757 } |
|
758 } |
|
759 } |
|
760 |
|
761 ////////////////////////////////////////////////////////////////////////////////////////////// |
|
762 |
|
763 |
|
764 EXE_BOILER_PLATE(CCmdCalendar) |
|
765 |