Archived:Calendar Exporter Symbian API
Archived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.
Article Metadata
Code Example
Source file: Media:CalenderImpportExport.zip
Compatibility
Platform(s): S60 3rd Edition, FP2
Article
Keywords: Calendar Exporter API
Created: User:Technical writer 1
(13 Jun 2008)
Last edited: lpvalente
(04 Oct 2012)
Note: :This API is not part of the public SDK. It can be found in the SDK API Plug-in.
Contents |
Purpose
The Calendar Exporter API provides functions to export agenda entries to vCalendar data.
Header files
#include <calsession.h>
#include <calprogresscallback.h>
#include <calentryview.h>
#include <calenexporter.h>
#include <caliterator.h>
#include <f32file.h>
#include <S32FILE.H>
#include <agnexportobserver.h>
Libraries used
efsrv.lib calinterimapi.lib calenimp.lib estor.lib
Code example
The CCalSession is the interface to the Calendar file. The instantiation of CCalSession will result in a connection to the Calendar Server.
void CCalendarEventsEngine::ConstructL()
{
iCalSession = CCalSession::NewL();
//Open the default calendar file
iCalSession->OpenL(iCalSession->DefaultFileNameL());
iWaiter =new (ELeave) CActiveSchedulerWait;
// calender exporter
iExporter=CCalenExporter::NewL(*iCalSession);
}
Virtual functions
// Called during calendar entry view creation
void CCalendarEventsEngine::Progress(TInt aProgress)
{
}
// Called on completion of calendar entry view creation
void CCalendarEventsEngine::Completed(TInt aError)
{
iWaiter->AsyncStop();
}
// Returns whether or not progress notification is required
TBool CCalendarEventsEngine::NotifyProgress()
{
// Progress notification is required
return ETrue;
}
The following code exports calender entries to a file:
void CCalendarEventsEngine::ExportEntriesL()
{
if(iWaiter->IsStarted())
{
iWaiter->AsyncStop();
}
// view class for accessing calendar entries
iCalEntryView = CCalEntryView::NewL(*iCalSession,*this);
iWaiter->Start();
// An iterator for iterating though all the entries in the calendar store
CCalIter* calIter = CCalIter::NewL(*iCalSession);
TBuf8<150> iterUID;
// An array of calender entries
RPointerArray<CCalEntry> calEntryArray;
iterUID = calIter->FirstL();
// calender entries file
_LIT(KFile,"C:\\CalEntriesFile.txt");
User::LeaveIfError(iFs.Connect());
TInt err = iRWriteStream.Open(iFs,KFile,EFileWrite);
if(err !=KErrNone)
{
User::LeaveIfError(iRWriteStream.Create(iFs, KFile, EFileWrite));
}
while (iterUID != KNullDesC8)
{
// get entries associated with this UID
iCalEntryView->FetchL(iterUID, calEntryArray);
for (TInt k=0; k<calEntryArray.Count();k++)
{
// get information from this entry
CCalEntry* calEntry = calEntryArray[k];
// export calender entry
iExporter->ExportVCalL(*calEntry,iRWriteStream);
}
iterUID = calIter->NextL();
};
calEntryArray.ResetAndDestroy();
delete calIter;
delete iCalEntryView;
iRWriteStream.Close();
iFs.Close();
}
Sample application
The following sample application is tested in the S60 3rd Edition, FP2 emulator. File:CalenderImpportExport.zip

