|
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 task.BringToForeground(); |
|
48 } |
|
49 else // Launch Calendar into day view |
|
50 { |
|
51 TApaAppInfo appInfo; |
|
52 RApaLsSession lsSession; |
|
53 if( lsSession.Connect() == KErrNone ) |
|
54 { |
|
55 CleanupClosePushL( lsSession ); |
|
56 |
|
57 if( lsSession.GetAppInfo( appInfo, KCalendarAppUID ) == KErrNone ) |
|
58 { |
|
59 CApaCommandLine* cmdLine = CApaCommandLine::NewLC(); |
|
60 cmdLine->SetExecutableNameL( appInfo.iFullName ); |
|
61 cmdLine->SetCommandL( EApaCommandRun ); |
|
62 cmdLine->SetTailEndL( tailBuf ); |
|
63 |
|
64 lsSession.StartApp( *cmdLine ); |
|
65 CleanupStack::PopAndDestroy( cmdLine ); |
|
66 } |
|
67 CleanupStack::PopAndDestroy(); // lsSession, cannot use pop parameter here! |
|
68 } |
|
69 } |
|
70 CleanupStack::PopAndDestroy( 2, tail ); |
|
71 } |
|
72 |
|
73 void TAiCalendarFocusData::CommandTailL( HBufC16*& aTailBuffer ) |
|
74 { |
|
75 /* |
|
76 Command line parameters: |
|
77 |
|
78 Opening calendar views: |
|
79 -------------- |
|
80 (opens on today if omitted) |
|
81 "DAY" |
|
82 "WEEK" |
|
83 "MONTH" |
|
84 "TODO" |
|
85 |
|
86 Opening on today: |
|
87 --------------------------------- |
|
88 "TODAY" |
|
89 |
|
90 Opening on specific day - focused by time: |
|
91 ---------------------------------------------------------------------- |
|
92 --- |
|
93 "DATE YYYY MM DD HH MM SS MMMMMM" |
|
94 (Getting TTime to provide above string: TTime::FormatL: "%F%Y %M %D %H %T %S %C") |
|
95 |
|
96 Opening editor: |
|
97 -------------- |
|
98 (using entries local UID) |
|
99 "LUID 1234567890" |
|
100 |
|
101 Opening viewer: |
|
102 -------------- |
|
103 (using entries local UID) |
|
104 "LUIDVIEWER 1234567890" |
|
105 |
|
106 */ |
|
107 switch( iType ) |
|
108 { |
|
109 case EAI2CalOpenEvent: |
|
110 { |
|
111 aTailBuffer = HBufC::NewLC( KAICal2DefaultBufferLen ); // "DATE YYYY MM DD HH MM SS MMMMMM" |
|
112 if( !iOpenInViewer ) |
|
113 { |
|
114 aTailBuffer->Des().Append( KAICal2CmdLUID ); |
|
115 } |
|
116 else |
|
117 { |
|
118 aTailBuffer->Des().Append( KAICal2CmdLUIDViewer ); |
|
119 } |
|
120 aTailBuffer->Des().AppendNum( iLocalUid ); |
|
121 CleanupStack::Pop( aTailBuffer ); |
|
122 break; |
|
123 } |
|
124 case EAI2CalOpenOnEventDay: |
|
125 { |
|
126 aTailBuffer = HBufC::NewLC( KAICal2DefaultBufferLen ); // "DATE YYYY MM DD HH MM SS MMMMMM" |
|
127 TPtr ptr( aTailBuffer->Des() ); |
|
128 TTime todayStart; |
|
129 todayStart.HomeTime(); |
|
130 const TDateTime x( todayStart.DateTime().Year(), |
|
131 todayStart.DateTime().Month(), |
|
132 todayStart.DateTime().Day(), 0, 0, 0, 0 ); |
|
133 if( iEntryTime < x ) |
|
134 { |
|
135 todayStart.FormatL( ptr, KAICal2CmdTimeFormat ); |
|
136 } |
|
137 else |
|
138 { |
|
139 iEntryTime.FormatL( ptr, KAICal2CmdTimeFormat ); |
|
140 } |
|
141 aTailBuffer->Des().Insert( 0, KAICal2CmdDAY ); |
|
142 CleanupStack::Pop( aTailBuffer ); |
|
143 break; |
|
144 } |
|
145 default: |
|
146 { |
|
147 aTailBuffer = KAICal2CmdTODAY().AllocL(); |
|
148 break; |
|
149 } |
|
150 } |
|
151 |
|
152 } |
|
153 |