66
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "aicalendarplugin2focusdata.h"
|
|
19 |
#include <eikenv.h> // For CEikonEnv
|
|
20 |
#include <apgtask.h>
|
|
21 |
#include <apgcli.h>
|
|
22 |
|
|
23 |
void TAiCalendarFocusData::LaunchCalendarApplicationL()
|
|
24 |
{
|
|
25 |
CEikonEnv* eikenv = CEikonEnv::Static();
|
|
26 |
if( !eikenv )
|
|
27 |
{
|
|
28 |
return;
|
|
29 |
}
|
|
30 |
TApaTaskList taskList( eikenv->WsSession() );
|
|
31 |
TApaTask task = taskList.FindApp( KCalendarAppUID );
|
|
32 |
|
|
33 |
HBufC16* tail = NULL;
|
|
34 |
CommandTailL( tail );
|
|
35 |
CleanupStack::PushL( tail );
|
|
36 |
|
|
37 |
// copy the 16-bit data into 8-bit buffer
|
|
38 |
HBufC8* paramBuf = HBufC8::NewLC( tail->Size() );
|
|
39 |
TPtr8 tailBuf = paramBuf->Des();
|
|
40 |
tailBuf.Copy( reinterpret_cast<const TUint8*>( tail->Ptr() ),
|
|
41 |
tail->Size() );
|
|
42 |
|
|
43 |
if( task.Exists() ) // Calendar already open
|
|
44 |
{
|
|
45 |
const TUid dummyUID = { 0x0 };
|
|
46 |
task.SendMessage( dummyUID, tailBuf );
|
|
47 |
}
|
|
48 |
else // Launch Calendar into day view
|
|
49 |
{
|
|
50 |
TApaAppInfo appInfo;
|
|
51 |
RApaLsSession lsSession;
|
|
52 |
if( lsSession.Connect() == KErrNone )
|
|
53 |
{
|
|
54 |
CleanupClosePushL( lsSession );
|
|
55 |
|
|
56 |
if( lsSession.GetAppInfo( appInfo, KCalendarAppUID ) == KErrNone )
|
|
57 |
{
|
|
58 |
CApaCommandLine* cmdLine = CApaCommandLine::NewLC();
|
|
59 |
cmdLine->SetExecutableNameL( appInfo.iFullName );
|
|
60 |
cmdLine->SetCommandL( EApaCommandRun );
|
|
61 |
cmdLine->SetTailEndL( tailBuf );
|
|
62 |
|
|
63 |
lsSession.StartApp( *cmdLine );
|
|
64 |
CleanupStack::PopAndDestroy( cmdLine );
|
|
65 |
}
|
|
66 |
CleanupStack::PopAndDestroy(); // lsSession, cannot use pop parameter here!
|
|
67 |
}
|
|
68 |
}
|
|
69 |
CleanupStack::PopAndDestroy( 2, tail );
|
|
70 |
}
|
|
71 |
|
|
72 |
void TAiCalendarFocusData::CommandTailL( HBufC16*& aTailBuffer )
|
|
73 |
{
|
|
74 |
/*
|
|
75 |
Command line parameters:
|
|
76 |
|
|
77 |
Opening calendar views:
|
|
78 |
--------------
|
|
79 |
(opens on today if omitted)
|
|
80 |
"DAY"
|
|
81 |
"WEEK"
|
|
82 |
"MONTH"
|
|
83 |
"TODO"
|
|
84 |
|
|
85 |
Opening on today:
|
|
86 |
---------------------------------
|
|
87 |
"TODAY"
|
|
88 |
|
|
89 |
Opening on specific day - focused by time:
|
|
90 |
----------------------------------------------------------------------
|
|
91 |
---
|
|
92 |
"DATE YYYY MM DD HH MM SS MMMMMM"
|
|
93 |
(Getting TTime to provide above string: TTime::FormatL: "%F%Y %M %D %H %T %S %C")
|
|
94 |
|
|
95 |
Opening editor:
|
|
96 |
--------------
|
|
97 |
(using entries local UID)
|
|
98 |
"LUID 1234567890"
|
|
99 |
|
|
100 |
Opening viewer:
|
|
101 |
--------------
|
|
102 |
(using entries local UID)
|
|
103 |
"LUIDVIEWER 1234567890"
|
|
104 |
|
|
105 |
*/
|
|
106 |
switch( iType )
|
|
107 |
{
|
|
108 |
case EAI2CalOpenEvent:
|
|
109 |
{
|
|
110 |
aTailBuffer = HBufC::NewLC( KAICal2DefaultBufferLen ); // "DATE YYYY MM DD HH MM SS MMMMMM"
|
|
111 |
if( !iOpenInViewer )
|
|
112 |
{
|
|
113 |
aTailBuffer->Des().Append( KAICal2CmdLUID );
|
|
114 |
}
|
|
115 |
else
|
|
116 |
{
|
|
117 |
aTailBuffer->Des().Append( KAICal2CmdLUIDViewer );
|
|
118 |
}
|
|
119 |
aTailBuffer->Des().AppendNum( iLocalUid );
|
|
120 |
CleanupStack::Pop( aTailBuffer );
|
|
121 |
break;
|
|
122 |
}
|
|
123 |
case EAI2CalOpenOnEventDay:
|
|
124 |
{
|
|
125 |
aTailBuffer = HBufC::NewLC( KAICal2DefaultBufferLen ); // "DATE YYYY MM DD HH MM SS MMMMMM"
|
|
126 |
TPtr ptr( aTailBuffer->Des() );
|
|
127 |
TTime todayStart;
|
|
128 |
todayStart.HomeTime();
|
|
129 |
const TDateTime x( todayStart.DateTime().Year(),
|
|
130 |
todayStart.DateTime().Month(),
|
|
131 |
todayStart.DateTime().Day(), 0, 0, 0, 0 );
|
|
132 |
if( iEntryTime < x )
|
|
133 |
{
|
|
134 |
todayStart.FormatL( ptr, KAICal2CmdTimeFormat );
|
|
135 |
}
|
|
136 |
else
|
|
137 |
{
|
|
138 |
iEntryTime.FormatL( ptr, KAICal2CmdTimeFormat );
|
|
139 |
}
|
|
140 |
aTailBuffer->Des().Insert( 0, KAICal2CmdDAY );
|
|
141 |
CleanupStack::Pop( aTailBuffer );
|
|
142 |
break;
|
|
143 |
}
|
|
144 |
default:
|
|
145 |
{
|
|
146 |
aTailBuffer = KAICal2CmdTODAY().AllocL();
|
|
147 |
break;
|
|
148 |
}
|
|
149 |
}
|
|
150 |
|
|
151 |
}
|
|
152 |
|