00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "CalWrite.h"
00018
00019 CCalWrite* CCalWrite::NewL()
00020 {
00021 CCalWrite* self = new (ELeave) CCalWrite();
00022 CleanupStack::PushL(self);
00023 self->ConstructL();
00024 CleanupStack::Pop(self);
00025 return self;
00026 }
00027
00028 CCalWrite::~CCalWrite()
00029 {
00030 delete iCalView;
00031 delete iCalSes;
00032 }
00033
00034 void CCalWrite::ConstructL()
00035 {
00036 iCalSes = CCalSession::NewL();
00037 const TDesC& name = iCalSes->DefaultFileNameL();
00038 TRAPD(error, iCalSes->CreateCalFileL(name));
00039 if (error != KErrAlreadyExists)
00040 {
00041 User::LeaveIfError(error);
00042 }
00043 iCalSes->OpenL(KNullDesC());
00044 iCalView = CCalEntryView::NewL(*iCalSes, *this);
00045 }
00046
00047 CCalEntryView& CCalWrite::CalView()
00048 {
00049 return *iCalView;
00050 }
00051
00052 void CCalWrite::ExportEventL(TCalLocalUid aEventId, RWriteStream& aOutput)
00053 {
00054 CCalEntry* entry = iCalView->FetchL(aEventId);
00055 if (NULL != entry)
00056 {
00057 CleanupStack::PushL(entry);
00058 CCalDataExchange* exch = CCalDataExchange::NewL(*iCalSes);
00059 CleanupStack::PushL(exch);
00060 RPointerArray<CCalEntry> array;
00061 CleanupClosePushL(array);
00062 array.AppendL(entry);
00063
00064 exch->ExportL(KUidVCalendar, aOutput, array);
00065 CleanupStack::PopAndDestroy(&array);
00066 CleanupStack::PopAndDestroy(exch);
00067 CleanupStack::PopAndDestroy(entry);
00068 }
00069 }
00070
00071 void CCalWrite::ImportEventL(RReadStream& aInput)
00072 {
00073 RPointerArray<CCalEntry> array;
00074 CleanupResetAndDestroyPushL(array);
00075 CCalDataExchange* exch = CCalDataExchange::NewL(*iCalSes);
00076 CleanupStack::PushL(exch);
00077 exch->ImportL(KUidVCalendar, aInput, array, 0, 1);
00078 CleanupStack::PopAndDestroy(exch);
00079
00080 CleanupStack::PopAndDestroy(&array);
00081 }
00082
00083
00084