|
1 /* |
|
2 * Copyright (c) 2007-2009 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: ESMR UI launcher object implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "emailtrace.h" |
|
20 #include "cesmruilauncher.h" |
|
21 #include "tesmrinputparams.h" |
|
22 #include "cesmrviewerctrl.h" |
|
23 |
|
24 #include <utf.h> |
|
25 #include <CAgnEntryUi.h> |
|
26 #include <cmrmailboxutils.h> |
|
27 #include <CalenInterimUtils2.h> |
|
28 //<cmail> |
|
29 #include "FreestyleEmailUiConstants.h" |
|
30 #include "cfsmailmessage.h" |
|
31 #include "fsmtmsuids.h" |
|
32 #include <coemain.h> |
|
33 #include <coeaui.h> |
|
34 #include "esmricalvieweropcodes.hrh" |
|
35 //</cmail> |
|
36 |
|
37 // Unnamed namespace for local definitions |
|
38 namespace { |
|
39 |
|
40 /** |
|
41 * Test if a calendar entry can be shown in mr viewer |
|
42 * |
|
43 * @param aEntry Reference to calendar entry. |
|
44 * @return ETrue if this entry can be shown in viewer |
|
45 */ |
|
46 TBool CanBeShownInMRViewerL( |
|
47 const CCalEntry& aEntry ) |
|
48 { |
|
49 TBool retValue( EFalse ); |
|
50 CCalEntry::TMethod method( aEntry.MethodL() ); |
|
51 |
|
52 if ( CCalEntry::EMethodRequest == method || |
|
53 CCalEntry::EMethodCancel == method ) |
|
54 { |
|
55 retValue = ETrue; |
|
56 } |
|
57 return retValue; |
|
58 } |
|
59 |
|
60 }//namespace |
|
61 |
|
62 // ======== MEMBER FUNCTIONS ======== |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // CESMRUiLauncher::CESMRUiLauncher |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 inline CESMRUiLauncher::CESMRUiLauncher( |
|
69 CCalSession& aCalSession, |
|
70 TESMRInputParams& aInputParameters, |
|
71 MAgnEntryUiCallback& aAgnCallback ) |
|
72 : CESMRIcalViewerAsyncCommand( EESMRLaunchUI, aCalSession ), |
|
73 iInputParameters( aInputParameters ), |
|
74 iAgnCallback( aAgnCallback ) |
|
75 { |
|
76 FUNC_LOG; |
|
77 //do nothing |
|
78 } |
|
79 |
|
80 // --------------------------------------------------------------------------- |
|
81 // CESMRUiLauncher::~CESMRUiLauncher |
|
82 // --------------------------------------------------------------------------- |
|
83 // |
|
84 CESMRUiLauncher::~CESMRUiLauncher() |
|
85 { |
|
86 FUNC_LOG; |
|
87 delete iViewerController; iViewerController = NULL; |
|
88 } |
|
89 |
|
90 // --------------------------------------------------------------------------- |
|
91 // CESMRUiLauncher::NewL |
|
92 // --------------------------------------------------------------------------- |
|
93 // |
|
94 CESMRUiLauncher* CESMRUiLauncher::NewL( |
|
95 CCalSession& aCalSession, |
|
96 TESMRInputParams& aInputParameters, |
|
97 MAgnEntryUiCallback& aAgnCallback ) |
|
98 { |
|
99 FUNC_LOG; |
|
100 CESMRUiLauncher* self = |
|
101 NewLC( |
|
102 aCalSession, |
|
103 aInputParameters, |
|
104 aAgnCallback ); |
|
105 |
|
106 CleanupStack::Pop( self ); |
|
107 return self; |
|
108 } |
|
109 |
|
110 // --------------------------------------------------------------------------- |
|
111 // CESMRUiLauncher::NewLC |
|
112 // --------------------------------------------------------------------------- |
|
113 // |
|
114 CESMRUiLauncher* CESMRUiLauncher::NewLC( |
|
115 CCalSession& aCalSession, |
|
116 TESMRInputParams& aInputParameters, |
|
117 MAgnEntryUiCallback& aAgnCallback ) |
|
118 { |
|
119 FUNC_LOG; |
|
120 CESMRUiLauncher* self = |
|
121 new (ELeave) CESMRUiLauncher( |
|
122 aCalSession, |
|
123 aInputParameters, |
|
124 aAgnCallback ); |
|
125 |
|
126 CleanupStack::PushL( self ); |
|
127 self->ConstructL(); |
|
128 return self; |
|
129 } |
|
130 |
|
131 // --------------------------------------------------------------------------- |
|
132 // CESMRUiLauncher::ConstructL |
|
133 // --------------------------------------------------------------------------- |
|
134 // |
|
135 void CESMRUiLauncher::ConstructL() |
|
136 { |
|
137 FUNC_LOG; |
|
138 iResult.iOpType = OperationType(); |
|
139 iResult.iResultCode = KErrNone; |
|
140 } |
|
141 |
|
142 // --------------------------------------------------------------------------- |
|
143 // CESMRUiLauncher::ExecuteAsyncCommandL |
|
144 // --------------------------------------------------------------------------- |
|
145 // |
|
146 void CESMRUiLauncher::ExecuteAsyncCommandL() |
|
147 { |
|
148 FUNC_LOG; |
|
149 iResult.iMessage = Message(); |
|
150 |
|
151 TRAP( iResult.iResultCode, ExecuteAsyncCommandInternalL() ); |
|
152 |
|
153 if ( KErrArgument == iResult.iResultCode ) |
|
154 { |
|
155 iResult.iResultCode = KErrNotSupported; |
|
156 Observer()->OperationError( iResult ); |
|
157 } |
|
158 else if ( KErrNone != iResult.iResultCode ) |
|
159 { |
|
160 Observer()->OperationError( iResult ); |
|
161 } |
|
162 else |
|
163 { |
|
164 Observer()->OperationCompleted( iResult ); |
|
165 } |
|
166 } |
|
167 |
|
168 // --------------------------------------------------------------------------- |
|
169 // CESMRUiLauncher::CancelAsyncCommand |
|
170 // --------------------------------------------------------------------------- |
|
171 // |
|
172 void CESMRUiLauncher::CancelAsyncCommand() |
|
173 { |
|
174 FUNC_LOG; |
|
175 delete iViewerController; |
|
176 iViewerController = NULL; |
|
177 } |
|
178 |
|
179 // --------------------------------------------------------------------------- |
|
180 // CESMRUiLauncher::LaunchMRViewerL |
|
181 // --------------------------------------------------------------------------- |
|
182 // |
|
183 void CESMRUiLauncher::LaunchMRViewerL() |
|
184 { |
|
185 FUNC_LOG; |
|
186 // Constructing input parameters |
|
187 MAgnEntryUi::TAgnEntryUiInParams inParams( |
|
188 KFSEmailUiUid, |
|
189 CalSession(), |
|
190 MAgnEntryUi::EViewEntry ); |
|
191 |
|
192 // Set time for input parameters |
|
193 TCalTime startTime = iInputParameters.iCalEntry->StartTimeL(); |
|
194 TCalTime::TTimeMode timemode = startTime.TimeMode(); |
|
195 if (timemode == TCalTime::EFloating ) |
|
196 { |
|
197 inParams.iInstanceDate.SetTimeLocalFloatingL ( |
|
198 startTime.TimeLocalL() ); |
|
199 } |
|
200 else |
|
201 { |
|
202 inParams.iInstanceDate.SetTimeLocalFloatingL ( |
|
203 startTime.TimeUtcL() ); |
|
204 } |
|
205 inParams.iMsgSession = NULL; |
|
206 inParams.iSpare = (TInt)(&iInputParameters); |
|
207 |
|
208 // Output parameters |
|
209 MAgnEntryUi::TAgnEntryUiOutParams outParams; |
|
210 |
|
211 // Launch Entry UI |
|
212 RPointerArray<CCalEntry> entries; |
|
213 CleanupClosePushL(entries); |
|
214 entries.AppendL(iInputParameters.iCalEntry); |
|
215 |
|
216 delete iViewerController; iViewerController = NULL; |
|
217 |
|
218 TUid mtmUid( TUid::Uid(KUidMsgTypeFsMtmVal) ); |
|
219 //CAgnEntryUi resolves Meeting request viewer based on mtm uid |
|
220 TBuf8<KMaxUidName> mrMtm; |
|
221 CnvUtfConverter::ConvertFromUnicodeToUtf8( |
|
222 mrMtm, |
|
223 mtmUid.Name() ); |
|
224 |
|
225 // If meeting requests are not supported --> Opened in meeting viewer |
|
226 // 1) FS meeting viewer is FS calendar is used |
|
227 // 2) S60 meeting editor if S60 calendar is used. |
|
228 delete iViewerController; iViewerController = NULL; |
|
229 iViewerController = |
|
230 CESMRViewerController::NewL( |
|
231 mrMtm, |
|
232 entries, |
|
233 inParams, |
|
234 outParams, |
|
235 iAgnCallback ); |
|
236 |
|
237 iViewerController->ExecuteL(); |
|
238 CleanupStack::PopAndDestroy(&entries); |
|
239 |
|
240 delete iViewerController; iViewerController = NULL; |
|
241 } |
|
242 |
|
243 // --------------------------------------------------------------------------- |
|
244 // CESMRUiLauncher::LaunchEmailViewerUiL |
|
245 // --------------------------------------------------------------------------- |
|
246 // |
|
247 void CESMRUiLauncher::LaunchEmailViewerUiL() |
|
248 { |
|
249 FUNC_LOG; |
|
250 User::Leave( KErrNotSupported ); |
|
251 } |
|
252 |
|
253 // --------------------------------------------------------------------------- |
|
254 // CESMRUiLauncher::ExecuteAsyncCommandInternalL |
|
255 // --------------------------------------------------------------------------- |
|
256 // |
|
257 void CESMRUiLauncher::ExecuteAsyncCommandInternalL() |
|
258 { |
|
259 FUNC_LOG; |
|
260 if ( iInputParameters.iCalEntry && |
|
261 CanBeShownInMRViewerL(*iInputParameters.iCalEntry ) ) |
|
262 { |
|
263 LaunchMRViewerL(); |
|
264 } |
|
265 else |
|
266 { |
|
267 LaunchEmailViewerUiL(); |
|
268 } |
|
269 } |
|
270 |
|
271 // EOF |
|
272 |