agenda.cpp
来自「在手机操作系统symbina上使用的一个脚本扩展语言的代码实现,可以参考用于自己」· C++ 代码 · 共 2,012 行 · 第 1/4 页
CPP
2,012 行
{
CAgnTodoList* list = CAgnTodoList::NewL();
// default to display crossed out entries
list->SetDisplayCrossedOutEntries(ETrue);
aAPI.Push((TInt32)list);
}
/* ----------------------------------------------------------------------
Find an existing todo list in file by list index number
OPL parameters:
index number of todo list, first is 0
OPL return value:
Handle to todo list, or 0 if no more
---------------------------------------------------------------------- */
void CAgendaOpx::LiAtL(OplAPI& aAPI,CAgendaOpx& aOpx)
{
//TAgnId i(aAPI.PopInt32());
TInt32 i=aAPI.PopInt32();
TInt32 h=0;
if (i<0)
User::Leave(KOplErrInvalidArgs);
CArrayFixFlat<TAgnTodoListId>* TodoListIds = aOpx.iModel->TodoListIdsL();
if (i<TodoListIds->Count())
{
TAgnId id=(*TodoListIds)[i].Value();
h=(TInt32)aOpx.iModel->FetchTodoListL(id);
}
delete TodoListIds;
aAPI.Push((TInt32)h);
}
/* ----------------------------------------------------------------------
Set the name of a todo list
OPL parameters:
Handle of todo list
String text
OPL return value:
None
---------------------------------------------------------------------- */
void CAgendaOpx::LiSetTitleL(OplAPI& aAPI,CAgendaOpx& /*aOpx*/)
{
TPtrC name = aAPI.PopString();
CAgnTodoList* list = (CAgnTodoList*)aAPI.PopInt32();
// FIX ME: should really check for duplicate todo list name here
if (list==NULL || name.Length()==0)
User::Leave(KOplErrInvalidArgs);
list->SetName(name);
aAPI.Push(0.0);
}
/* ----------------------------------------------------------------------
Set the list order
OPL parameters:
Handle of todo
order:
0=manual
1=by date
2=by priority
OPL return value:
None
---------------------------------------------------------------------- */
void CAgendaOpx::LiSetOrderL(OplAPI& aAPI,CAgendaOpx& /*aOpx*/)
{
TInt16 order = aAPI.PopInt16();
CAgnTodoList* list = (CAgnTodoList*)aAPI.PopInt32();
if (list==NULL || order<0 || order>2)
User::Leave(KOplErrInvalidArgs);
list->SetSortOrder((CAgnTodoList::TSortOrder)order);
aAPI.Push(0.0);
}
/* ----------------------------------------------------------------------
Set whether to display todo's in other views (with time)
OPL parameters:
Handle of todo list
Whether to display, 1=true, 0=false
Display hour
Display minute
OPL return value:
None
---------------------------------------------------------------------- */
void CAgendaOpx::LiSetViewDisplayL(OplAPI& aAPI,CAgendaOpx& /*aOpx*/)
{
TInt32 minute = aAPI.PopInt32();
TInt32 hour = aAPI.PopInt32();
TInt16 display = aAPI.PopInt16();
CAgnTodoList* list = (CAgnTodoList*)aAPI.PopInt32();
if (list==NULL || hour<0 || hour>24 || minute<0 || minute>60)
User::Leave(KOplErrInvalidArgs);
if (display)
{
list->SetDisplayEntriesInOtherViews(ETrue);
list->SetDefaultDisplayTimeInOtherViews(hour*60+minute);
}
else
{
list->SetDisplayEntriesInOtherViews(EFalse);
}
aAPI.Push(0.0);
}
/* ----------------------------------------------------------------------
Returns the todo list id
OPL parameters:
Handle of todo list
OPL return value:
Id
---------------------------------------------------------------------- */
void CAgendaOpx::LiGetIdL(OplAPI& aAPI,CAgendaOpx& /*aOpx*/)
{
CAgnTodoList* list = (CAgnTodoList*)aAPI.PopInt32();
if (list==NULL)
User::Leave(KOplErrInvalidArgs);
aAPI.Push((TInt32)list->Id().Value());
}
/* ----------------------------------------------------------------------
Get the title of a todo list
OPL parameters:
Handle of todo
OPL return value:
name of todo list
---------------------------------------------------------------------- */
void CAgendaOpx::LiGetTitleL(OplAPI& aAPI,CAgendaOpx& /*aOpx*/)
{
CAgnTodoList* list = (CAgnTodoList*)aAPI.PopInt32();
if (list==NULL)
User::Leave(KOplErrInvalidArgs);
aAPI.PushL(list->Name());
}
/* ----------------------------------------------------------------------
Get the order type of a todo list
OPL parameters:
Handle of todo list
OPL return value:
order:
0=manual
1=by date
2=by priority
---------------------------------------------------------------------- */
void CAgendaOpx::LiGetOrderL(OplAPI& aAPI,CAgendaOpx& /*aOpx*/)
{
CAgnTodoList* list = (CAgnTodoList*)aAPI.PopInt32();
if (list==NULL)
User::Leave(KOplErrInvalidArgs);
aAPI.Push((TInt16)list->SortOrder());
}
/* ----------------------------------------------------------------------
Get whether displays todo's in other views (with time)
OPL parameters:
Handle of todo list
Display hour
Display minute
OPL return value:
None
---------------------------------------------------------------------- */
void CAgendaOpx::LiGetViewDisplayL(OplAPI& aAPI,CAgendaOpx& /*aOpx*/)
{
TAny* minute=aAPI.PopPtrInt32();
TAny* hour=aAPI.PopPtrInt32();
CAgnTodoList* list = (CAgnTodoList*)aAPI.PopInt32();
if (list==NULL)
User::Leave(KOplErrInvalidArgs);
if (list->DisplayEntriesInOtherViews())
{
TInt m=list->DefaultDisplayTimeInOtherViews().Int();
TInt h=m/60;
aAPI.PutLong(hour,h);
aAPI.PutLong(minute,m-h*60);
aAPI.Push((TInt16)1);
}
else
{
aAPI.Push((TInt16)0);
}
}
/* ----------------------------------------------------------------------
Free a todo list
OPL parameters:
Handle of todo list
OPL return value:
None
---------------------------------------------------------------------- */
void CAgendaOpx::LiFreeL(OplAPI& aAPI,CAgendaOpx& /*aOpx*/)
{
CAgnTodoList* list = (CAgnTodoList*)aAPI.PopInt32();
if (list==NULL)
User::Leave(KOplErrInvalidArgs);
delete list;
aAPI.Push(0.0);
}
/* ======================================================================
Internal utility methods start here
====================================================================== */
/* ----------------------------------------------------------------------
Close down agenda file - see OpenL() & CloseL() methods
---------------------------------------------------------------------- */
void CAgendaOpx::DoCloseL(CAgendaOpx& aOpx)
{
delete aOpx.iModel;
aOpx.iModel = NULL; // use as flag to indicate closed
if (aOpx.iAgnServ)
{
aOpx.iAgnServ->Close();
delete aOpx.iAgnServ;
aOpx.iAgnServ=NULL;
}
delete aOpx.iAgnIter;
aOpx.iAgnIter=NULL;
}
/* ----------------------------------------------------------------------
Convert an entry to the appropriate entry subclass
---------------------------------------------------------------------- */
TInt32 CAgendaOpx::CastEntryL(CAgnEntry *entry)
{
switch (entry->Type())
{
case CAgnEntry::EAppt:
return (TInt32)entry->CastToAppt();
case CAgnEntry::ETodo:
return (TInt32)entry->CastToTodo();
case CAgnEntry::EEvent:
return (TInt32)entry->CastToEvent();
case CAgnEntry::EAnniv:
return (TInt32)entry->CastToAnniv();
default:
User::Leave(KOplErrRecord);
}
return 0; // to keep compiler happy
}
/* ----------------------------------------------------------------------
Check type of an entry matches expected type
---------------------------------------------------------------------- */
void CAgendaOpx::CheckEntryType(CAgnEntry *entry, CAgnEntry::TType type)
{
if (entry==NULL || entry->Type()!=type)
User::Leave(KOplErrInvalidArgs);
}
/* ======================================================================
OPX framework methods start here
====================================================================== */
void CAgendaOpx::RunL(TInt aProcNum)
{
switch (aProcNum)
{
case EAgnOpen:
OpenL(iOplAPI,*this);
break;
case EAgnClose:
CloseL(iOplAPI,*this);
break;
case EAgnAdd:
AddL(iOplAPI,*this);
break;
case EAgnModify:
ModifyL(iOplAPI,*this);
break;
case EAgnDelete:
DeleteL(iOplAPI,*this);
break;
case EAgnFetch:
FetchL(iOplAPI,*this);
break;
case EAgnFirstEntry:
FirstEntryL(iOplAPI,*this);
break;
case EAgnNextEntry:
NextEntryL(iOplAPI,*this);
break;
case EAgnEnNewAppt:
EnNewApptL(iOplAPI,*this);
break;
case EAgnEnNewTodo:
EnNewTodoL(iOplAPI,*this);
break;
case EAgnEnNewEvent:
EnNewEventL(iOplAPI,*this);
break;
case EAgnEnNewAnniv:
EnNewAnnivL(iOplAPI,*this);
break;
case EAgnEnSetText:
EnSetTextL(iOplAPI,*this);
break;
case EAgnEnSetSymbol:
EnSetSymbolL(iOplAPI,*this);
break;
case EAgnEnSetAlarm:
EnSetAlarmL(iOplAPI,*this);
break;
case EAgnEnSetCrossOut:
EnSetCrossOutL(iOplAPI,*this);
break;
case EAgnEnSetTentative:
EnSetTentativeL(iOplAPI,*this);
break;
case EAgnEnGetId:
EnGetIdL(iOplAPI,*this);
break;
case EAgnEnGetType:
EnGetTypeL(iOplAPI,*this);
break;
case EAgnEnGetText:
EnGetTextL(iOplAPI,*this);
break;
case EAgnEnGetSymbol:
EnGetSymbolL(iOplAPI,*this);
break;
case EAgnEnGetAlarm:
EnGetAlarmL(iOplAPI,*this);
break;
case EAgnEnGetCrossOut:
EnGetCrossOutL(iOplAPI,*this);
break;
case EAgnEnGetTentative:
EnGetTentativeL(iOplAPI,*this);
break;
case EAgnEnFree:
EnFreeL(iOplAPI,*this);
break;
case EAgnApSetStartTime:
ApSetStartTimeL(iOplAPI,*this);
break;
case EAgnApSetEndTime:
ApSetEndTimeL(iOplAPI,*this);
break;
case EAgnApGetStartTime:
ApGetStartTimeL(iOplAPI,*this);
break;
case EAgnApGetEndTime:
ApGetEndTimeL(iOplAPI,*this);
break;
case EAgnTdAt:
TdAtL(iOplAPI,*this);
break;
case EAgnTdSetList:
TdSetListL(iOplAPI,*this);
break;
case EAgnTdSetPriority:
TdSetPriorityL(iOplAPI,*this);
break;
case EAgnTdSetDueDate:
TdSetDueDateL(iOplAPI,*this);
break;
case EAgnTdSetDuration:
TdSetDurationL(iOplAPI,*this);
break;
case EAgnTdGetList:
TdGetListL(iOplAPI,*this);
break;
case EAgnTdGetPriority:
TdGetPriorityL(iOplAPI,*this);
break;
case EAgnTdGetDueDate:
TdGetDueDateL(iOplAPI,*this);
break;
case EAgnTdGetDuration:
TdGetDurationL(iOplAPI,*this);
break;
case EAgnEvSetStartDate:
EvSetStartDateL(iOplAPI,*this);
break;
case EAgnEvSetEndDate:
EvSetEndDateL(iOplAPI,*this);
break;
case EAgnEvGetStartDate:
EvGetStartDateL(iOplAPI,*this);
break;
case EAgnEvGetEndDate:
EvGetEndDateL(iOplAPI,*this);
break;
case EAgnAnSetDate:
AnSetDateL(iOplAPI,*this);
break;
case EAgnAnSetShow:
AnSetShowL(iOplAPI,*this);
break;
case EAgnAnGetDate:
AnGetDateL(iOplAPI,*this);
break;
case EAgnAnGetShow:
AnGetShowL(iOplAPI,*this);
break;
case EAgnLiAdd:
LiAddL(iOplAPI,*this);
break;
case EAgnLiModify:
LiModifyL(iOplAPI,*this);
break;
case EAgnLiDelete:
LiDeleteL(iOplAPI,*this);
break;
case EAgnLiFetch:
LiFetchL(iOplAPI,*this);
break;
case EAgnLiNew:
LiNewL(iOplAPI,*this);
break;
case EAgnLiAt:
LiAtL(iOplAPI,*this);
break;
case EAgnLiSetTitle:
LiSetTitleL(iOplAPI,*this);
break;
case EAgnLiSetOrder:
LiSetOrderL(iOplAPI,*this);
break;
case EAgnLiSetViewDisplay:
LiSetViewDisplayL(iOplAPI,*this);
break;
case EAgnLiGetId:
LiGetIdL(iOplAPI,*this);
break;
case EAgnLiGetTitle:
LiGetTitleL(iOplAPI,*this);
break;
case EAgnLiGetOrder:
LiGetOrderL(iOplAPI,*this);
break;
case EAgnLiGetViewDisplay:
LiGetViewDisplayL(iOplAPI,*this);
break;
case EAgnLiFree:
LiFreeL(iOplAPI,*this);
break;
case EAgnLiChangePosition:
LiChangePositionL(iOplAPI,*this);
break;
case EAgnEnGetStatus:
EnGetStatusL(iOplAPI,*this);
break;
default:
User::Leave(KOplErrOpxProcNotFound);
}
};
TBool CAgendaOpx::CheckVersion(TInt aVersion)
{
if ((aVersion & 0xFF00) > (KAgendaVersion & 0xFF00))
return EFalse;
else
return ETrue;
}
EXPORT_C COpxBase* NewOpxL(OplAPI& aOplAPI)
{
CAgendaOpx* tls=((CAgendaOpx*)Dll::Tls());
if (tls==NULL)
{
tls=CAgendaOpx::NewL(aOplAPI);
Dll::SetTls(tls);
}
return (COpxBase *)tls;
}
EXPORT_C TUint Version()
{
return KAgendaVersion;
}
GLDEF_C TInt E32Dll(TDllReason /*aReason*/)
{
return KErrNone;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?