|
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: Provides AudioMessage MTM UI methods. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include <apgcli.h> |
|
22 #include <MuiuMsvUiServiceUtilities.h> |
|
23 #include <MtmExtendedCapabilities.hrh> |
|
24 #include <mmsconst.h> |
|
25 #include <mmsclient.h> |
|
26 #include <mmssettings.h> |
|
27 #include <mmssettingsdialog.h> |
|
28 #include <featmgr.h> |
|
29 |
|
30 #include "AudioMessageLogging.h" |
|
31 #include "audiomessageui.h" |
|
32 #include "audiomessageuipanic.h" |
|
33 |
|
34 #define iMmsClient ( static_cast<CMmsClientMtm&>( iBaseMtm ) ) |
|
35 |
|
36 _LIT( KAMSUiResourceFile,"AudioMessageMtm"); |
|
37 _LIT( KAMSEmpty,"" ); |
|
38 _LIT( KAmsUiMtmPanicText,"AMSUi" ); |
|
39 const TInt KZero = 0; //constant for memory check |
|
40 |
|
41 const TUid KUidAMSId = {0x1020745A}; |
|
42 |
|
43 // ======== LOCAL FUNCTIONS ======== |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // NewAudioMessageUiL |
|
47 // Factory function |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 EXPORT_C CBaseMtmUi* NewAudioMessageUiL( CBaseMtm& aMtm, CRegisteredMtmDll& aRegisteredDll ) |
|
51 { |
|
52 FeatureManager::InitializeLibL(); |
|
53 if ( !FeatureManager::FeatureSupported( KFeatureIdAudioMessaging ) ) |
|
54 { |
|
55 FeatureManager::UnInitializeLib(); |
|
56 User::Leave( KErrNotSupported ); |
|
57 } |
|
58 FeatureManager::UnInitializeLib(); |
|
59 |
|
60 return CAudioMessageUi::NewL( aMtm, aRegisteredDll ); |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // Panic |
|
65 // CAudioMessageUi Panic function |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 GLDEF_C void Panic( TAMSUiPanic aPanic ) |
|
69 { |
|
70 User::Panic( KAmsUiMtmPanicText, aPanic ); |
|
71 } |
|
72 |
|
73 |
|
74 // ======== MEMBER FUNCTIONS ======== |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // C++ default constructor can NOT contain any code, that |
|
78 // might leave. |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 CAudioMessageUi::CAudioMessageUi( CBaseMtm& aBaseMtm, CRegisteredMtmDll& aRegisteredMtmDll ) |
|
82 : CBaseMtmUi( aBaseMtm, aRegisteredMtmDll ), iAmsAppId( KUidAMSId ) |
|
83 { |
|
84 } |
|
85 |
|
86 void CAudioMessageUi::ConstructL() |
|
87 { |
|
88 AMSLOGGER_WRITE( "CAudioMessageUi::ConstructL" ); |
|
89 CBaseMtmUi::ConstructL(); |
|
90 AMSLOGGER_WRITE( "CAudioMessageUi::ConstructL Base construct OK" ) ; |
|
91 iSettingsHandler = CMmsSettingsHandler::NewL( iMmsClient ); |
|
92 AMSLOGGER_WRITE( "CAudioMessageUi::ConstructL End" ); |
|
93 } |
|
94 |
|
95 CAudioMessageUi* CAudioMessageUi::NewL( CBaseMtm& aBaseMtm, CRegisteredMtmDll& aRegisteredMtmDll ) |
|
96 { |
|
97 AMSLOGGER_WRITE( "CAudioMessageUi::NewL" ); |
|
98 CAudioMessageUi* self = new ( ELeave ) CAudioMessageUi( aBaseMtm, aRegisteredMtmDll ); |
|
99 |
|
100 CleanupStack::PushL( self ); |
|
101 self->ConstructL(); |
|
102 CleanupStack::Pop(); |
|
103 |
|
104 AMSLOGGER_WRITE( "CAudioMessageUi::NewL end" ); |
|
105 return self; |
|
106 } |
|
107 |
|
108 |
|
109 CAudioMessageUi::~CAudioMessageUi() |
|
110 { |
|
111 AMSLOGGER_WRITE( "AMSUi::~CAudioMessageUi" ); |
|
112 delete iSettingsHandler; |
|
113 } |
|
114 |
|
115 // --------------------------------------------------------------------------- |
|
116 // Launches Ams for creating a new message. |
|
117 // --------------------------------------------------------------------------- |
|
118 // |
|
119 CMsvOperation* CAudioMessageUi::CreateL( const TMsvEntry& aEntry, |
|
120 CMsvEntry& aParent, |
|
121 TRequestStatus& aStatus ) |
|
122 { |
|
123 AMSLOGGER_WRITE( "CAudioMessageUi::CreateL" ); |
|
124 |
|
125 __ASSERT_DEBUG( aEntry.iMtm == Type(), Panic( EAMSWrongMtmType ) ); |
|
126 __ASSERT_DEBUG( aEntry.iType == KUidMsvMessageEntry, Panic( EAMSNotAMessage ) ); |
|
127 |
|
128 CheckDiskSpaceL( ); |
|
129 |
|
130 CMmsSettingsDialog::TMmsExitCode exitCode = |
|
131 CMmsSettingsDialog::EMmsExternalInterrupt; |
|
132 |
|
133 if ( !CheckSettingsL( exitCode ) ) |
|
134 { |
|
135 TUint32 ap = iSettingsHandler->MmsSettings()->AccessPoint( 0 ); |
|
136 if( exitCode==CMmsSettingsDialog::EMmsBack && ApExistsL( ap ) ) |
|
137 { //settings saved |
|
138 return LaunchEditorApplicationL( aStatus, aParent.Session(), ECreateNewMessage ); |
|
139 } |
|
140 else |
|
141 { //user selects exit and settings not saved |
|
142 return CompleteSettingsOperationL( aStatus, exitCode ); |
|
143 } |
|
144 } |
|
145 else |
|
146 { |
|
147 // OK - open the editor |
|
148 return LaunchEditorApplicationL( aStatus, aParent.Session(), ECreateNewMessage ); |
|
149 } |
|
150 } |
|
151 |
|
152 TBool CAudioMessageUi::CheckSettingsL( CMmsSettingsDialog::TMmsExitCode& aExitCode ) const |
|
153 { |
|
154 // reload the settings |
|
155 iSettingsHandler->RefreshSettingsL( ); |
|
156 return iSettingsHandler->CheckSettingsL( aExitCode ); |
|
157 } |
|
158 |
|
159 // --------------------------------------------------------------------------- |
|
160 // Handles request to open existing message server entry (message/service) |
|
161 // --------------------------------------------------------------------------- |
|
162 // |
|
163 CMsvOperation* CAudioMessageUi::OpenL( TRequestStatus& /*aStatus*/ ) |
|
164 { |
|
165 User::Leave( KErrNotSupported ); |
|
166 return NULL; |
|
167 } |
|
168 |
|
169 // --------------------------------------------------------------------------- |
|
170 // Opens the first entry in a selection |
|
171 // --------------------------------------------------------------------------- |
|
172 // |
|
173 CMsvOperation* CAudioMessageUi::OpenL( TRequestStatus& /*aStatus*/, |
|
174 const CMsvEntrySelection& /*aSelection*/ ) |
|
175 { |
|
176 User::Leave( KErrNotSupported ); |
|
177 return NULL; |
|
178 } |
|
179 |
|
180 CMsvOperation* CAudioMessageUi::CloseL( TRequestStatus& /*aStatus*/ ) |
|
181 { |
|
182 User::Leave( KErrNotSupported ); |
|
183 return NULL; |
|
184 } |
|
185 |
|
186 CMsvOperation* CAudioMessageUi::CloseL( TRequestStatus& /*aStatus*/, |
|
187 const CMsvEntrySelection& /*aSelection*/ ) |
|
188 { |
|
189 User::Leave( KErrNotSupported ); |
|
190 return NULL; |
|
191 } |
|
192 |
|
193 // --------------------------------------------------------------------------- |
|
194 // Opens a message (editor) or service (settings dialog) for editing. |
|
195 // --------------------------------------------------------------------------- |
|
196 // |
|
197 CMsvOperation* CAudioMessageUi::EditL( TRequestStatus& aStatus ) |
|
198 { |
|
199 AMSLOGGER_WRITE( "CAudioMessageUi::EditL" ); |
|
200 |
|
201 TMsvEntry entry = iBaseMtm.Entry().Entry(); |
|
202 __ASSERT_DEBUG( entry.iMtm == Type(), Panic( EAMSWrongMtmType ) ); |
|
203 __ASSERT_DEBUG( entry.iType == KUidMsvMessageEntry, Panic( EAMSNotAMessage ) ); |
|
204 CMsvOperation* msvoperation = NULL; |
|
205 |
|
206 switch ( entry.iType.iUid ) |
|
207 { |
|
208 case KUidMsvMessageEntryValue: |
|
209 { |
|
210 AMSLOGGER_WRITE( "CAudioMessageUi::EditL dealing with message" ); |
|
211 |
|
212 CheckDiskSpaceL( ); |
|
213 |
|
214 CMmsSettingsDialog::TMmsExitCode exitCode = |
|
215 CMmsSettingsDialog::EMmsExternalInterrupt; |
|
216 |
|
217 if ( !CheckSettingsL( exitCode ) ) |
|
218 { |
|
219 TUint32 ap = iSettingsHandler->MmsSettings()->AccessPoint( 0 ); |
|
220 //settings saved with valid access point |
|
221 if( !( exitCode==CMmsSettingsDialog::EMmsBack && ApExistsL( ap ) ) ) |
|
222 { |
|
223 return CompleteSettingsOperationL( aStatus, exitCode ); |
|
224 } |
|
225 } |
|
226 |
|
227 |
|
228 if ( iBaseMtm.Entry().Entry().Connected() ) |
|
229 { |
|
230 User::Leave( KErrLocked ); |
|
231 } |
|
232 |
|
233 CMsvEntry* cEntry = Session().GetEntryL( iBaseMtm.Entry().Entry().Id() ); |
|
234 CleanupStack::PushL( cEntry ); |
|
235 |
|
236 TMsvEntry tEntry = cEntry->Entry(); |
|
237 tEntry.iMtm = KUidMsgTypeMultimedia; |
|
238 tEntry.iBioType = KUidMsgSubTypeMmsAudioMsg.iUid; |
|
239 |
|
240 cEntry->ChangeL( tEntry ); |
|
241 CleanupStack::PopAndDestroy( cEntry ); |
|
242 |
|
243 AMSLOGGER_WRITE( "CAudioMessageUi::EditL launching editor" ); |
|
244 msvoperation = LaunchEditorApplicationL( aStatus, iBaseMtm.Entry().Session() ); |
|
245 } |
|
246 break; |
|
247 |
|
248 case KUidMsvServiceEntryValue: |
|
249 case KUidMsvAttachmentEntryValue: // flow through |
|
250 case KUidMsvFolderEntryValue: // flow through |
|
251 default: |
|
252 User::Leave( KErrNotSupported ); |
|
253 break; |
|
254 } |
|
255 |
|
256 AMSLOGGER_WRITE( "AMSUi::EditL end" ); |
|
257 return msvoperation; |
|
258 } |
|
259 |
|
260 CMsvOperation* CAudioMessageUi::EditL( TRequestStatus& aStatus, |
|
261 const CMsvEntrySelection& aSelection ) |
|
262 { |
|
263 BaseMtm().SwitchCurrentEntryL( aSelection[0] ); |
|
264 return EditL( aStatus ); |
|
265 } |
|
266 |
|
267 // --------------------------------------------------------------------------- |
|
268 // Opens the message for reading in Viewer. |
|
269 // --------------------------------------------------------------------------- |
|
270 // |
|
271 CMsvOperation* CAudioMessageUi::ViewL( TRequestStatus& /*aStatus*/ ) |
|
272 { |
|
273 User::Leave( KErrNotSupported ); |
|
274 return NULL; |
|
275 } |
|
276 |
|
277 CMsvOperation* CAudioMessageUi::ViewL( TRequestStatus& /*aStatus*/, |
|
278 const CMsvEntrySelection& /*aSelection*/ ) |
|
279 { |
|
280 User::Leave( KErrNotSupported ); |
|
281 return NULL; |
|
282 } |
|
283 |
|
284 // --------------------------------------------------------------------------- |
|
285 // Does the actual opening. |
|
286 // --------------------------------------------------------------------------- |
|
287 // |
|
288 CMsvOperation* CAudioMessageUi::LaunchEditorApplicationL( TRequestStatus& aStatus, |
|
289 CMsvSession& aSession, |
|
290 TEditorType aEditorType ) |
|
291 { |
|
292 AMSLOGGER_WRITE( "AMSUi::LaunchEditorApplicationL" ); |
|
293 |
|
294 TEditorParameters temp; |
|
295 |
|
296 temp.iSpecialAppId =iAmsAppId; |
|
297 if ( iBaseMtm.HasContext() ) |
|
298 { |
|
299 temp.iId = iBaseMtm.Entry().EntryId(); |
|
300 } |
|
301 |
|
302 switch( aEditorType ) |
|
303 { |
|
304 case ECreateNewMessage: |
|
305 temp.iFlags|=EMsgCreateNewMessage ; |
|
306 temp.iId=KMsvDraftEntryIdValue; |
|
307 break; |
|
308 case EEditExisting: // No need for action |
|
309 case EReadOnly: // Never happens |
|
310 default: |
|
311 break; |
|
312 }; |
|
313 |
|
314 temp.iFlags &= ~( EMtmUiFlagEditorPreferEmbedded|EMtmUiFlagEditorNoWaitForExit ); |
|
315 |
|
316 temp.iFlags |= ( Preferences() & EMtmUiFlagEditorPreferEmbedded?EMsgLaunchEditorEmbedded:0 ); |
|
317 |
|
318 TPckgC<TEditorParameters> paramPack( temp ); |
|
319 |
|
320 AMSLOGGER_WRITE( "CAudioMessageUi::LaunchEditorApplicationL just before calling EditorLauncher" ); |
|
321 return MsgEditorLauncher::LaunchEditorApplicationL( aSession, |
|
322 KUidMsgTypeMultimedia, aStatus, temp, KAMSEmpty, paramPack ); |
|
323 } |
|
324 |
|
325 CMsvOperation* CAudioMessageUi::ForwardL( TMsvId /*aDestination*/, |
|
326 TMsvPartList /*aPartList*/, |
|
327 TRequestStatus& /*aCompletionStatus*/ ) |
|
328 { |
|
329 User::Leave( KErrNotSupported ); |
|
330 return NULL; |
|
331 } |
|
332 |
|
333 CMsvOperation* CAudioMessageUi::ReplyL( TMsvId /*aDestination*/, |
|
334 TMsvPartList /*aPartList*/, |
|
335 TRequestStatus& /*aCompletionStatus*/ ) |
|
336 { |
|
337 User::Leave( KErrNotSupported ); |
|
338 return NULL; |
|
339 } |
|
340 |
|
341 // --------------------------------------------------------------------------- |
|
342 // Suspends sending of the selected messages (if possible) |
|
343 // --------------------------------------------------------------------------- |
|
344 // |
|
345 CMsvOperation* CAudioMessageUi::CancelL( TRequestStatus& /*aStatus*/, |
|
346 const CMsvEntrySelection& /*aSelection*/ ) |
|
347 { |
|
348 User::Leave( KErrNotSupported ); |
|
349 return NULL; |
|
350 } |
|
351 |
|
352 void CAudioMessageUi::GetResourceFileName( TFileName& aFileName ) const |
|
353 { |
|
354 aFileName = KAMSUiResourceFile; |
|
355 } |
|
356 |
|
357 // --------------------------------------------------------------------------- |
|
358 // Handles MMS service settings |
|
359 // --------------------------------------------------------------------------- |
|
360 // |
|
361 CMsvOperation* CAudioMessageUi::OpenServiceSettingsDialogL( TRequestStatus& |
|
362 aCompletionStatus ) |
|
363 { |
|
364 return iSettingsHandler->OpenServiceSettingsDialogL( aCompletionStatus ); |
|
365 } |
|
366 |
|
367 // --------------------------------------------------------------------------- |
|
368 // Creates completed operation after settings dialog closing with appropriate |
|
369 // parameters. |
|
370 // --------------------------------------------------------------------------- |
|
371 // |
|
372 CMsvOperation* CAudioMessageUi::CompleteSettingsOperationL( |
|
373 TRequestStatus& aCompletionStatus, |
|
374 const CMmsSettingsDialog::TMmsExitCode& aExitCode ) |
|
375 { |
|
376 return iSettingsHandler->CompleteSettingsOperationL( |
|
377 aCompletionStatus, |
|
378 aExitCode ); |
|
379 } |
|
380 |
|
381 // --------------------------------------------------------------------------- |
|
382 // Opens either MMS Service Settings or MMS Sending Settings dialog. |
|
383 // --------------------------------------------------------------------------- |
|
384 // |
|
385 void CAudioMessageUi::LaunchSettingsDialogL( |
|
386 CMmsSettingsDialog::TMmsExitCode& aExitCode ) const |
|
387 { |
|
388 iSettingsHandler->LaunchSettingsDialogL( aExitCode ); |
|
389 } |
|
390 |
|
391 // --------------------------------------------------------------------------- |
|
392 // CAudioMessageUi::ApExistsL |
|
393 // --------------------------------------------------------------------------- |
|
394 // |
|
395 TBool CAudioMessageUi::ApExistsL( TUint32 aAp ) |
|
396 { |
|
397 return iSettingsHandler->ApExistsL( aAp ); |
|
398 } |
|
399 |
|
400 void CAudioMessageUi::CheckDiskSpaceL( ) |
|
401 { |
|
402 if( MsvUiServiceUtilities::DiskSpaceBelowCriticalLevelL( |
|
403 Session( ), |
|
404 KZero ) ) |
|
405 { |
|
406 User::Leave( KErrDiskFull ); |
|
407 } |
|
408 } |
|
409 |