Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Symbian^3 Calendar API (Chinese)

From Wiki
Jump to: navigation, search
Article Metadata

兼容于
平台:
Symbian^3

文章
Levin_Wei 在 11 May 2010 创建
最后由 hamishwillee 在 30 May 2013 编辑



Symbian^3中的calendar API有比较大的修改,与之前的版本相比,操作更加方便,并且增加了新的格式iCalendar

Contents

新功能

附件

日历项中的附件内容可以是一个uri、图片、摘记、声音片段等。

地理位置

记录了一组经纬度数据

Logging

为日历项增加logging

扩展搜索功能

在之前的搜索功能基础上进行扩展,通过更多的方式进行日历项的搜索

可移动存储

支持从可移动存储介质上进行读取、存储日历文件。

look back

连接Calendar Server

旧方法:

CCalSession* iCalSession = CCalSession::NewL();

新方法:

//使用已连接的CCalSession.
CCalSession* iSharedSession = CCalSession::NewL();
CCalSession* iNewSession = CCalSession::NewL(*iSharedSession);

Calendar Entries

//创建一个日历项.
CCalEntry::NewL(TType aType, HbufC8 *aUid, TMethod aMethod, TUint aSeqNum,
const TCalTime& aRecurrenceId,CalCommon::TRecurrenRange aRange);
//设置日历项的内容.
CCalEntry::SetSummaryL(const TDesC &aSummary); //主题
CCalEntry::SetLocationL(const TDesC &aLocation); //地点
CCalEntry::SetDescriptionL(const TDesC &aDescription); //描述
//设置日历项时间
CCalEntry::SetStartAndEndDateL(const TCalTime &aStartTime, const TCalTime &aEndTime);
CCalEntry::SetLastModifiedDateL(const TCalTime &aModifiedTime);
//设置重复时间
CCalEntry::SetRDatesL(const RArray<TCalTime> &aRDateList);
CCalEntry::SetExceptionDatesL(const RArray<TCalTime> &aExDateList);
设置日历项状态
CCalEntry::SetStatusL(TStatus aStatus);
//设置访问限制
CCalEntry::SetReplicationStatusL(TReplicationStatus aReplicationStatus);
CCalEntry::SetPriorityL(TUint aPriority); //优先级

Calendar Views

//Entry View
CCalEntryView::FetchL();
CCalEntryView::UpdateL();
CCalEntryView::StoreL();
CCalEntryView::DeleteL();
//Instance View
CCalInstanceView::FindInstanceL(RPointerArray<CCalInstance> &aInstanceList,
CalCommon::TCalViewFilter aCalViewFilter, const CalCommon::TCalTimeRange &aTimerange,
const TCalSearchParams &aSearchParams);
//CCalInstanceView中其他的APIs
CCalInstanceView::NextInstanceL(CalCommon::TCalViewFilter aCalViewFilter,
const TCalTime &aStartDate) const;
CCalInstanceView::PreviousInstanceL(CalCommon::TCalViewFilter aCalViewFilter,
const TCalTime &aStartDate) const;
CCalInstanceView::DeleteL(CCalInstance *aInstance,
CalCommon::TRecurrenceRange aWhichInstances);
//多个calendar文件搜索(新API)
CCalInstanceView::NewL(RPointerArray<CCalSession> &aSessions);
CCalInstanceView::FindInstanceByUidL(TCalCollectionId aCollectionId,
const TDesC8 &aUid, const TCalTime &aInstanceTime);
CCalInstanceView::FindInstanceL(const CCalFindInstanceSettings &aSettings,
const TCalInstanceId &aInstanceId);

附件功能

概述

一个日历项可以有多个附件。
通过CCalAttachment来访问日历项中的附件
可以用一个二进制描述符来标示文件,也可以用一个文件句柄来标示
一个文件附件只可以有一个Content ID,Content ID只有在该附件作为一个message的一部分才用得到

文件句柄作为日历项的附件

User::LeaveIfError(iFs.ShareProtected());
RFile fileHandle;
fileHandle.Open(iFs, AttachmentFileName, EFileWrite);
CleanupColsePushL(fileHandle);
CCalAttachment* attachment = CCalAttachment::NewFileL(fileHandle);
CleanupStack::PopAndDestroy(&fileHandle);
CleanupStack::PushL(attachment);
//…set attachment properties
calEntry->AddAttachmentL(*attachment);
CleanupStack::Pop(attachment);

注意:被选中的文件已经被移动到了日历存储中。

二进制数据作为日历项的附件

CCalAttachment* attachment = CCalAttachment::NewFileL(binaryData);
CleanupStack::PushL(attachment);
//…set attachment properties
calEntry->AddAttachmentL(*attachment);
CleanupStack::Pop(attachment);

URI作为日历项的附件

//uriAttachment是一个DesC8的描述符
CCalAttachment* attachment = CCalAttachment::NewFileL(uriAttachment);
CleanupStack::PushL(attachment);
//…set attachment properties
calEntry->AddAttachmentL(*attachment);
CleanupStack::Pop(attachment);

创建一个包含日历项和其附件的message

CCalAttachment* attachment = calEntry->AttachmentL(attachmentIndex);
If(attachment->FileAttachment() != NULL)
{
//generate a content ID for the attachment

//set the content ID on this attachment
attachment->FileAttachment()->SetContentIdL(contentId);
}
//从calEntry中抽取日历数据

接收一个包含日历项和其附件的message

CCalAttachment* attachment = calEntry->AttachmentL(attachmentIndex);
//判断附件是否为文件类型,然后取得Content ID
If( attachment->FileAttachment() != NULL && attachment->FileAttachment()->ContentId.Length() > 0)
{
RFile fileHandle;
//resolve the content ID to find the attachment file handle

//set the file handle on this attachment
attachment->FileAttachment()->SetResourceL(fileHandle);
}

可移动存储介质

可以正常进行操作,但是要注意,移动介质可以移除,所以建议使用RFs::NotifyChange()来监测移动存储介质。

GEO属性

增加了地理位置属性,存储内容为经纬度。
注意:
vCalendar中的地理位置存储格式为:GEO:37.24, -17.87
iCalendar中的地理位置存储格式为:37.359475;-122.583859

扩展搜索功能

CCalInstanceView::FindInstanceL(RPointerArray< CCalInstance > &aInstanceList,
CalCommon::TCalViewFilter aCalViewFilter, const CalCommon::TCalTimeRange &aTimeRange)

之前通过该API对日历项进行搜索时,只能通过日历项内容和时间范围来搜索
在Symbian^3中,扩展了搜索功能,可以对一下内容进行搜索:
Summary
Description
Location
Organizer Common Name
Organizer Address
Organizer Sent-By
Attendee Common Name
Attendee Address
Attendee Sent-By

CCalInstanceIterator* CCalInstanceView::FindInstanceL(
const CCalFindInstanceSettings& aSettings) const

要搜索的设置全部在CCalFindInstanceSettings中进行设置

This page was last modified on 30 May 2013, at 04:40.
339 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×