×
Namespaces

Variants
Actions

日历导出API

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata

代码示例
文章
hoolee 在 29 Aug 2008 创建
最后由 hamishwillee 在 15 Dec 2011 编辑

CS001028


  • 开发伙伴平台:

S60 3rd Edition, FP2


  • 详细描述

这个API不是公开的SDK中的一部分,可以在SDK API Plug-in里找到。


Contents

目的

日历导出API提供了将议事日程导出到vCalendar数据的功能。


头文件

#include <calsession.h>
#include <calprogresscallback.h>
#include <calentryview.h>
#include <calenexporter.h>
#include <caliterator.h>
#include <f32file.h>
#include <S32FILE.H>
#include <agnexportobserver.h>


链接库的使用

efsrv.lib calinterimapi.lib calenimp.lib estor.lib


代码示例

CCalSession为操作日历文件的接口,这里的CCalSession的实例将链接到日历服务程序

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);
}


虚函数

// 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;
}

下列代码将日历数据导到一个文件中:

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();
}


示例程序

这里有一个运行在S60第三版FP2模拟器上的示例代码File:CalenderImpportExport.zip

This page was last modified on 15 December 2011, at 09:02.
67 page views in the last 30 days.