×
Namespaces

Variants
Actions

日程导入API

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

代码示例
文章
hoolee 在 06 Feb 2009 创建
最后由 hamishwillee 在 15 Dec 2011 编辑

CS001027


  • 开发伙伴平台:

S60 3rd Edition, FP2


  • 详细描述

日历导入API提供了一个类可以将一个vCalendar导入到S60日程兼容的CCalEntry中。


头文件

#include <calsession.h>
#include <calprogresscallback.h>
#include <calentryview.h>
#include <calenimporter.h>
#include <f32file.h>
#include <S32FILE.H>
#include <agnimportobserver.h>


链接库

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


示例代码 CCalSession是日程文件的接口。它的实例将可以和日程服务程序链接。

void CCalendarEventsEngine::ConstructL()
{
iCalSession = CCalSession::NewL();
//Open the default calendar file
iCalSession->OpenL(iCalSession->DefaultFileNameL());
iWaiter =new (ELeave) CActiveSchedulerWait;
// calender importer
iImporter=CCalenImporter::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::ImportEntriesL()
{
// calender entries file
_LIT(KFile,"C:\\CalEntriesFile.txt");
User::LeaveIfError(iFs.Connect());
TInt err = iRReadStream.Open(iFs,KFile,EFileRead);
// An array of calender entries
RPointerArray<CCalEntry> calEntryArray;
iImporter->ImportVCalendarL(iRReadStream,calEntryArray);
for (TInt k=0; k<calEntryArray.Count();k++)
{
// get information from this entry
CCalEntry* calEntry = calEntryArray[k];
TPtrC description = calEntry->SummaryL();
if(iWaiter->IsStarted())
{
iWaiter->AsyncStop();
}
// View class for accessing calendar entries
iCalEntryView = CCalEntryView::NewL(*iCalSession,*this);
iWaiter->Start();
TInt success(0);
iCalEntryView->StoreL(calEntryArray, success);
delete iCalEntryView;
}
calEntryArray.ResetAndDestroy();
iRReadStream.Close();
iFs.Close();
}

示例程序 下列示例已经在S60第三版FP2模拟器上测试过:File:CalenderImpportExport.zip

This page was last modified on 15 December 2011, at 09:08.
61 page views in the last 30 days.
×