|
1 /* |
|
2 * Copyright (c) 2005 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 * Provides Postcard MTM UI methods. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 |
|
23 #include <apgcli.h> // RApaLsSession |
|
24 #include <MuiuMsvUiServiceUtilities.h> // DiskSpaceBelow.., MsvUiServiceUtil.. |
|
25 #include <MtmExtendedCapabilities.hrh> // MtmUiFlags |
|
26 #include <mmsconst.h> // KUidMsgTypeMultimedia |
|
27 #include <mmsclient.h> // Client MTM |
|
28 #include <mmssettings.h> // MMS Engine settings |
|
29 #include <mmssettingsdialog.h> |
|
30 #include <bautils.h> // FileExists |
|
31 #include <data_caging_path_literals.hrh> |
|
32 #include <featmgr.h> |
|
33 #include <bldvariant.hrh> |
|
34 |
|
35 #include "PostcardMtmConst.h" |
|
36 #include "PostcardUi.h" |
|
37 #include "PostcardUiPanic.h" |
|
38 |
|
39 // MACROS |
|
40 |
|
41 // LOCAL CONSTANTS AND MACROS |
|
42 _LIT( KPostcardUiResourceFile,"PostcardUi.rsc"); |
|
43 _LIT( KPostcardDriveZ,"z:"); |
|
44 |
|
45 const TInt KZero = 0; //constant for memory check |
|
46 |
|
47 // MODULE DATA STRUCTURES |
|
48 |
|
49 // LOCAL FUNCTION PROTOTYPES |
|
50 |
|
51 // ==================== LOCAL FUNCTIONS ==================== |
|
52 |
|
53 // --------------------------------------------------------- |
|
54 // NewPostcardUiL |
|
55 // Factory function |
|
56 // --------------------------------------------------------- |
|
57 // |
|
58 EXPORT_C CBaseMtmUi* NewPostcardUiL( CBaseMtm& aMtm, CRegisteredMtmDll& aRegisteredDll ) |
|
59 { |
|
60 // Get supported features from feature manager. |
|
61 FeatureManager::InitializeLibL(); |
|
62 if ( !FeatureManager::FeatureSupported( KFeatureIdMmsPostcard ) ) |
|
63 { |
|
64 FeatureManager::UnInitializeLib(); |
|
65 User::Leave( KErrNotSupported ); |
|
66 } |
|
67 FeatureManager::UnInitializeLib(); |
|
68 |
|
69 return CPostcardUi::NewL( aMtm, aRegisteredDll ); |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------- |
|
73 // Panic |
|
74 // PostcardUi Panic function |
|
75 // --------------------------------------------------------- |
|
76 // |
|
77 GLDEF_C void Panic( TPostcardUiPanic aPanic ) |
|
78 { |
|
79 User::Panic( _L("PostcardUi"), aPanic ); |
|
80 } |
|
81 |
|
82 |
|
83 // ================= MEMBER FUNCTIONS ======================= |
|
84 |
|
85 // --------------------------------------------------------- |
|
86 // CPostcardUi::CPostcardUi |
|
87 // C++ default constructor can NOT contain any code, that |
|
88 // might leave. |
|
89 // --------------------------------------------------------- |
|
90 // |
|
91 CPostcardUi::CPostcardUi( CBaseMtm& aBaseMtm, CRegisteredMtmDll& aRegisteredMtmDll ) |
|
92 : CBaseMtmUi( aBaseMtm, aRegisteredMtmDll ), iPocaAppId( KUidPostcardId ) |
|
93 { |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------- |
|
97 // CPostcardUi::ConstructL |
|
98 // Symbian OS default constructor can leave. |
|
99 // --------------------------------------------------------- |
|
100 // |
|
101 void CPostcardUi::ConstructL() |
|
102 { |
|
103 LOGTEXT( _L8( "PostcardUi::ConstructL" ) ); |
|
104 CBaseMtmUi::ConstructL(); |
|
105 LOGTEXT( _L8( "PostcardUi::ConstructL Base construct OK" ) ); |
|
106 iSettingsHandler = CMmsSettingsHandler::NewL( static_cast<CMmsClientMtm&>( iBaseMtm ) ); |
|
107 LOGTEXT( _L8( "PostcardUi::ConstructL End" ) ); |
|
108 } |
|
109 |
|
110 // --------------------------------------------------------- |
|
111 // CPostcardUi::NewL |
|
112 // Two-phased constructor. |
|
113 // --------------------------------------------------------- |
|
114 // |
|
115 CPostcardUi* CPostcardUi::NewL( CBaseMtm& aBaseMtm, CRegisteredMtmDll& aRegisteredMtmDll ) |
|
116 { |
|
117 LOGTEXT( _L8( "PostcardUi::NewL" ) ); |
|
118 CPostcardUi* self = new ( ELeave ) CPostcardUi( aBaseMtm, aRegisteredMtmDll ); |
|
119 |
|
120 CleanupStack::PushL( self ); |
|
121 self->ConstructL(); |
|
122 CleanupStack::Pop( self ); |
|
123 |
|
124 LOGTEXT( _L8( "PostcardUi::NewL end" ) ); |
|
125 return self; |
|
126 } |
|
127 |
|
128 |
|
129 // --------------------------------------------------------- |
|
130 // CPostcardUi::~CPostcardUi |
|
131 // Destructor |
|
132 // --------------------------------------------------------- |
|
133 // |
|
134 CPostcardUi::~CPostcardUi() |
|
135 { |
|
136 LOGTEXT( _L8( "PostcardUi::~CPostcardUi" ) ); |
|
137 delete iSettingsHandler; |
|
138 } |
|
139 |
|
140 // --------------------------------------------------------- |
|
141 // CPostcardUi::CreateL |
|
142 // Launches MMS editor for creating a new message. |
|
143 // --------------------------------------------------------- |
|
144 // |
|
145 CMsvOperation* CPostcardUi::CreateL( const TMsvEntry& aEntry, |
|
146 CMsvEntry& aParent, |
|
147 TRequestStatus& aStatus ) |
|
148 { |
|
149 LOGTEXT( _L8( "PostcardUi::CreateL" ) ); |
|
150 __ASSERT_DEBUG( aEntry.iMtm == Type(), Panic( EPostcardWrongMtmType ) ); |
|
151 __ASSERT_DEBUG( aEntry.iType == KUidMsvMessageEntry, Panic( EPostcardNotAMessage ) ); |
|
152 |
|
153 CheckDiskSpaceL( ); |
|
154 |
|
155 CMmsSettingsDialog::TMmsExitCode exitCode = |
|
156 CMmsSettingsDialog::EMmsExternalInterrupt; |
|
157 |
|
158 if ( !CheckSettingsL( exitCode ) ) |
|
159 { |
|
160 TUint32 ap = iSettingsHandler->MmsSettings()->AccessPoint( 0 ); |
|
161 if( exitCode==CMmsSettingsDialog::EMmsBack && ApExistsL( ap ) ) |
|
162 { //settings saved |
|
163 return LaunchEditorApplicationL( aStatus, aParent.Session(), ECreateNewMessage ); |
|
164 } |
|
165 else |
|
166 { //user selects exit and settings not saved |
|
167 return CompleteSettingsOperationL( aStatus, exitCode ); |
|
168 } |
|
169 } |
|
170 else |
|
171 { |
|
172 // OK - open the editor |
|
173 return LaunchEditorApplicationL( aStatus, aParent.Session(), ECreateNewMessage ); |
|
174 } |
|
175 } |
|
176 |
|
177 // --------------------------------------------------------- |
|
178 // CPostcardUi::CheckSettingsL() const |
|
179 // Check MMS service settings |
|
180 // --------------------------------------------------------- |
|
181 // |
|
182 TBool CPostcardUi::CheckSettingsL( CMmsSettingsDialog::TMmsExitCode& aExitCode ) const |
|
183 { |
|
184 // reload the settings |
|
185 iSettingsHandler->RefreshSettingsL( ); |
|
186 return iSettingsHandler->CheckSettingsL( aExitCode ); |
|
187 } |
|
188 |
|
189 // --------------------------------------------------------- |
|
190 // CPostcardUi::OpenL |
|
191 // Handles request to open existing message server entry (message/service) |
|
192 // --------------------------------------------------------- |
|
193 // |
|
194 CMsvOperation* CPostcardUi::OpenL( TRequestStatus& /*aStatus*/ ) |
|
195 { |
|
196 User::Leave( KErrNotSupported ); |
|
197 return NULL; |
|
198 } |
|
199 |
|
200 // --------------------------------------------------------- |
|
201 // CPostcardUi::OpenL |
|
202 // Opens the first entry in a selection |
|
203 // --------------------------------------------------------- |
|
204 // |
|
205 CMsvOperation* CPostcardUi::OpenL( TRequestStatus& /*aStatus*/, |
|
206 const CMsvEntrySelection& /*aSelection*/ ) |
|
207 { |
|
208 User::Leave( KErrNotSupported ); |
|
209 return NULL; |
|
210 } |
|
211 |
|
212 // --------------------------------------------------------- |
|
213 // CPostcardUi::CloseL |
|
214 // --------------------------------------------------------- |
|
215 // |
|
216 CMsvOperation* CPostcardUi::CloseL( TRequestStatus& /*aStatus*/ ) |
|
217 { |
|
218 User::Leave( KErrNotSupported ); |
|
219 return NULL; |
|
220 } |
|
221 |
|
222 // --------------------------------------------------------- |
|
223 // CPostcardUi::CloseL |
|
224 // --------------------------------------------------------- |
|
225 // |
|
226 CMsvOperation* CPostcardUi::CloseL( TRequestStatus& /*aStatus*/, |
|
227 const CMsvEntrySelection& /*aSelection*/ ) |
|
228 { |
|
229 User::Leave( KErrNotSupported ); |
|
230 return NULL; |
|
231 } |
|
232 |
|
233 // --------------------------------------------------------- |
|
234 // CPostcardUi::EditL |
|
235 // Opens a message (editor) or service (settings dialog) for editing. |
|
236 // --------------------------------------------------------- |
|
237 // |
|
238 CMsvOperation* CPostcardUi::EditL( TRequestStatus& aStatus ) |
|
239 { |
|
240 LOGTEXT(_L8("PostcardUi::EditL")); |
|
241 TMsvEntry entry = iBaseMtm.Entry().Entry(); |
|
242 __ASSERT_DEBUG( entry.iMtm == Type(), Panic( EPostcardWrongMtmType ) ); |
|
243 __ASSERT_DEBUG( entry.iType == KUidMsvMessageEntry, Panic( EPostcardNotAMessage ) ); |
|
244 CMsvOperation* msvoperation = NULL; |
|
245 |
|
246 switch ( entry.iType.iUid ) |
|
247 { |
|
248 case KUidMsvMessageEntryValue: |
|
249 { |
|
250 LOGTEXT(_L8("PostcardUi::EditL dealing with message")); |
|
251 |
|
252 CheckDiskSpaceL( ); |
|
253 |
|
254 CMmsSettingsDialog::TMmsExitCode exitCode = |
|
255 CMmsSettingsDialog::EMmsExternalInterrupt; |
|
256 |
|
257 if ( !CheckSettingsL( exitCode ) ) |
|
258 { |
|
259 TUint32 ap = iSettingsHandler->MmsSettings()->AccessPoint( 0 ); |
|
260 //settings saved with valid access point |
|
261 if( !( exitCode==CMmsSettingsDialog::EMmsBack && ApExistsL( ap ) ) ) |
|
262 { |
|
263 return CompleteSettingsOperationL( aStatus, exitCode ); |
|
264 } |
|
265 } |
|
266 |
|
267 if ( iBaseMtm.Entry().Entry().Connected() ) |
|
268 { |
|
269 User::Leave( KErrLocked ); |
|
270 } |
|
271 |
|
272 CMsvEntry* cEntry = Session().GetEntryL( iBaseMtm.Entry().Entry().Id() ); |
|
273 CleanupStack::PushL( cEntry ); |
|
274 |
|
275 TMsvEntry tEntry = cEntry->Entry(); |
|
276 tEntry.iMtm = KUidMsgTypeMultimedia; |
|
277 tEntry.iBioType = KUidMsgSubTypeMmsPostcard.iUid; |
|
278 cEntry->ChangeL( tEntry ); |
|
279 CleanupStack::PopAndDestroy( cEntry ); |
|
280 |
|
281 LOGTEXT( _L8( "PostcardUi::EditL launching editor" ) ); |
|
282 msvoperation = LaunchEditorApplicationL( aStatus, iBaseMtm.Entry().Session() ); |
|
283 } |
|
284 break; |
|
285 |
|
286 case KUidMsvServiceEntryValue: |
|
287 case KUidMsvAttachmentEntryValue: // flow through |
|
288 case KUidMsvFolderEntryValue: // flow through |
|
289 default: |
|
290 User::Leave( KErrNotSupported ); |
|
291 break; |
|
292 } |
|
293 |
|
294 LOGTEXT(_L8("PostcardUi::EditL end")); |
|
295 return msvoperation; |
|
296 } |
|
297 |
|
298 // --------------------------------------------------------- |
|
299 // CPostcardUi::EditL |
|
300 // --------------------------------------------------------- |
|
301 // |
|
302 CMsvOperation* CPostcardUi::EditL( TRequestStatus& aStatus, |
|
303 const CMsvEntrySelection& aSelection ) |
|
304 { |
|
305 BaseMtm().SwitchCurrentEntryL( aSelection[0] ); |
|
306 return EditL( aStatus ); |
|
307 } |
|
308 |
|
309 // --------------------------------------------------------- |
|
310 // CPostcardUi::ViewL |
|
311 // Opens the message for reading in Viewer. |
|
312 // --------------------------------------------------------- |
|
313 // |
|
314 CMsvOperation* CPostcardUi::ViewL( TRequestStatus& /*aStatus*/ ) |
|
315 { |
|
316 User::Leave( KErrNotSupported ); |
|
317 return NULL; |
|
318 } |
|
319 |
|
320 // --------------------------------------------------------- |
|
321 // CPostcardUi::ViewL |
|
322 // --------------------------------------------------------- |
|
323 // |
|
324 CMsvOperation* CPostcardUi::ViewL( TRequestStatus& /*aStatus*/, |
|
325 const CMsvEntrySelection& /*aSelection*/ ) |
|
326 { |
|
327 User::Leave( KErrNotSupported ); |
|
328 return NULL; |
|
329 } |
|
330 |
|
331 // ----------------------------------------------------------------------------- |
|
332 // CPostcardUi::LaunchEditorApplicationL() |
|
333 // Does the actual opening. |
|
334 // ----------------------------------------------------------------------------- |
|
335 // |
|
336 CMsvOperation* CPostcardUi::LaunchEditorApplicationL( TRequestStatus& aStatus, |
|
337 CMsvSession& aSession, |
|
338 TEditorType aEditorType ) |
|
339 { |
|
340 LOGTEXT(_L8("PostcardUi::LaunchEditorApplicationL")); |
|
341 |
|
342 TEditorParameters temp; |
|
343 temp.iSpecialAppId = iPocaAppId; // We want to use the special Poca application |
|
344 |
|
345 if ( iBaseMtm.HasContext() ) |
|
346 { |
|
347 temp.iId = iBaseMtm.Entry().EntryId(); |
|
348 } |
|
349 |
|
350 switch( aEditorType ) |
|
351 { |
|
352 case ECreateNewMessage: |
|
353 temp.iFlags|=EMsgCreateNewMessage ; |
|
354 temp.iId=KMsvDraftEntryIdValue; |
|
355 break; |
|
356 case EEditExisting: // No need for action |
|
357 case EReadOnly: // Never happens |
|
358 default: |
|
359 break; |
|
360 }; |
|
361 |
|
362 temp.iFlags &= ~( EMtmUiFlagEditorPreferEmbedded|EMtmUiFlagEditorNoWaitForExit ); |
|
363 |
|
364 temp.iFlags |= ( Preferences() & EMtmUiFlagEditorPreferEmbedded?EMsgLaunchEditorEmbedded:0 ); |
|
365 |
|
366 TPckgC<TEditorParameters> paramPack( temp ); |
|
367 |
|
368 LOGTEXT(_L8("PostcardUi::LaunchEditorApplicationL just before calling EditorLauncher")); |
|
369 return MsgEditorLauncher::LaunchEditorApplicationL( aSession, KUidMsgTypeMultimedia, aStatus, temp, _L(""), paramPack ); |
|
370 } |
|
371 |
|
372 // --------------------------------------------------------- |
|
373 // CPostcardUi::ForwardL |
|
374 // --------------------------------------------------------- |
|
375 // |
|
376 CMsvOperation* CPostcardUi::ForwardL( TMsvId /*aDestination*/, |
|
377 TMsvPartList /*aPartList*/, |
|
378 TRequestStatus& /*aCompletionStatus*/ ) |
|
379 { |
|
380 User::Leave( KErrNotSupported ); |
|
381 return NULL; |
|
382 } |
|
383 |
|
384 // --------------------------------------------------------- |
|
385 // CPostcardUi::ReplyL |
|
386 // --------------------------------------------------------- |
|
387 // |
|
388 CMsvOperation* CPostcardUi::ReplyL( TMsvId /*aDestination*/, |
|
389 TMsvPartList /*aPartList*/, |
|
390 TRequestStatus& /*aCompletionStatus*/ ) |
|
391 { |
|
392 User::Leave( KErrNotSupported ); |
|
393 return NULL; |
|
394 } |
|
395 |
|
396 // --------------------------------------------------------- |
|
397 // CPostcardUi::CancelL |
|
398 // Suspends sending of the selected messages (if possible) |
|
399 // --------------------------------------------------------- |
|
400 // |
|
401 CMsvOperation* CPostcardUi::CancelL( TRequestStatus& /*aStatus*/, |
|
402 const CMsvEntrySelection& /*aSelection*/ ) |
|
403 { |
|
404 User::Leave( KErrNotSupported ); |
|
405 return NULL; |
|
406 } |
|
407 |
|
408 |
|
409 // --------------------------------------------------------- |
|
410 // CPostcardUi::GetResourceFileName |
|
411 // --------------------------------------------------------- |
|
412 // |
|
413 void CPostcardUi::GetResourceFileName( TFileName& aFileName ) const |
|
414 { |
|
415 TFileName tmpName; |
|
416 |
|
417 // Append the Resource Files Directory |
|
418 tmpName.Append( KDC_MTM_RESOURCE_DIR ); |
|
419 // Append the Ressource File Name |
|
420 tmpName.Append( KPostcardUiResourceFile ); |
|
421 |
|
422 // Obtain the drive where the DLL is installed |
|
423 TFileName dllDrive; |
|
424 Dll::FileName( dllDrive ); |
|
425 |
|
426 // Obtain the Complete path for the Resource File |
|
427 TParse parse; |
|
428 parse.Set( dllDrive, NULL, NULL ); |
|
429 parse.Set( parse.Drive(), &tmpName, NULL ); |
|
430 TFileName fileName; |
|
431 fileName.Append( parse.FullName()); |
|
432 |
|
433 // Get language of resource file |
|
434 BaflUtils::NearestLanguageFile( Session().FileSession( ), fileName ); |
|
435 |
|
436 if( !BaflUtils::FileExists( Session().FileSession( ), fileName) ) |
|
437 { // If it's not on dll drive -> try Z |
|
438 fileName.Replace( 0, 2, KPostcardDriveZ ); |
|
439 BaflUtils::NearestLanguageFile( Session().FileSession( ), fileName ); |
|
440 } |
|
441 |
|
442 aFileName = fileName; |
|
443 |
|
444 return; |
|
445 } |
|
446 |
|
447 // --------------------------------------------------------- |
|
448 // CMsvOperation* CPostcardUi::OpenServiceSettingsDialogL(TRequestStatus& aCompletionStatus) |
|
449 // Handles MMS service settings |
|
450 // --------------------------------------------------------- |
|
451 // |
|
452 CMsvOperation* CPostcardUi::OpenServiceSettingsDialogL( TRequestStatus& aCompletionStatus ) |
|
453 { |
|
454 return iSettingsHandler->OpenServiceSettingsDialogL( aCompletionStatus ); |
|
455 } |
|
456 |
|
457 // --------------------------------------------------------- |
|
458 // CMsvOperation* CPostcardUi::CompleteSettingsOperationL( |
|
459 // TRequestStatus& aCompletionStatus, const CMmsSettingsDialog::TMmsExitCode& aExitCode) |
|
460 // Creates completed operation after settings dialog closing with appropriate parameters. |
|
461 // --------------------------------------------------------- |
|
462 // |
|
463 CMsvOperation* CPostcardUi::CompleteSettingsOperationL( |
|
464 TRequestStatus& aCompletionStatus, |
|
465 const CMmsSettingsDialog::TMmsExitCode& aExitCode /* = CMmsSettingsDialog::EMmsExternalInterrupt */ ) |
|
466 { |
|
467 return iSettingsHandler->CompleteSettingsOperationL( |
|
468 aCompletionStatus, |
|
469 aExitCode ); |
|
470 } |
|
471 |
|
472 // --------------------------------------------------------- |
|
473 // TInt CPostcardUi::LaunchSettingsDialogL( |
|
474 // CMmsSettingsDialog::TMmsExitCode& aExitCode ) |
|
475 // Opens either MMS Service Settings or MMS Sending Settings dialog. |
|
476 // --------------------------------------------------------- |
|
477 // |
|
478 void CPostcardUi::LaunchSettingsDialogL( |
|
479 CMmsSettingsDialog::TMmsExitCode& aExitCode ) const |
|
480 { |
|
481 iSettingsHandler->LaunchSettingsDialogL( aExitCode ); |
|
482 } |
|
483 |
|
484 // --------------------------------------------------------- |
|
485 // CPostcardUi::ApExistsL |
|
486 // --------------------------------------------------------- |
|
487 // |
|
488 TBool CPostcardUi::ApExistsL( TUint32 aAp ) |
|
489 { |
|
490 return iSettingsHandler->ApExistsL( aAp ); |
|
491 } |
|
492 |
|
493 // --------------------------------------------------------- |
|
494 // CPostcardUi::CheckDiskSpaceL |
|
495 // --------------------------------------------------------- |
|
496 // |
|
497 void CPostcardUi::CheckDiskSpaceL( ) |
|
498 { |
|
499 if( MsvUiServiceUtilities::DiskSpaceBelowCriticalLevelL( |
|
500 Session( ), |
|
501 KZero ) ) |
|
502 { |
|
503 User::Leave( KErrDiskFull ); |
|
504 } |
|
505 } |
|
506 |
|
507 // End of File |