|
1 /* |
|
2 * Copyright (c) 2002 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 * Active object to load mtm's background after mce start. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <featmgr.h> // CR : 401-1806 |
|
23 #include <MTMStore.h> |
|
24 #include <mtmuids.h> // KUidMtmQueryCanSendMsg |
|
25 #include <mtud.hrh> // EMtudCommandSendAs |
|
26 #include <mtudreg.h> |
|
27 #include <MtmExtendedCapabilities.hrh> //KUidMsvMtmUiQueryExtendedGetMailProgress |
|
28 |
|
29 #include <SenduiMtmUids.h> |
|
30 #include "MceIdleMtmLoader.h" |
|
31 #include "MceLogText.h" |
|
32 #include "MsgFunctionInfo.h" |
|
33 //cmail update |
|
34 #define KUidMsgTypeFsMtmVal 0x2001F406 |
|
35 //cmail update |
|
36 |
|
37 // LOCAL FUNCTION PROTOTYPES |
|
38 |
|
39 // ================= MEMBER FUNCTIONS ======================= |
|
40 |
|
41 // C++ default constructor can NOT contain any code that |
|
42 // might leave. |
|
43 // |
|
44 CMceIdleMtmLoader::CMceIdleMtmLoader( |
|
45 CMtmStore& aMtmStore, |
|
46 CUidNameArray& aMsgTypesWritePopup, |
|
47 CUidNameArray& aMsgTypesWriteSubmenu, |
|
48 CUidNameArray& aMsgTypesSettings, |
|
49 CMsgFuncArray& aMTMFunctionsArray, |
|
50 CMtmUiDataRegistry& aUiRegistry ) |
|
51 : CActive( CActive::EPriorityIdle ), |
|
52 iUiRegistry( aUiRegistry ), |
|
53 iMtmStore(aMtmStore), |
|
54 iMsgTypesWritePopup( aMsgTypesWritePopup ), |
|
55 iMsgTypesWriteSubmenu( aMsgTypesWriteSubmenu ), |
|
56 iMsgTypesSettings( aMsgTypesSettings ), |
|
57 iMTMFunctionsArray( aMTMFunctionsArray ), |
|
58 iAudioMsgEnabled (EFalse), |
|
59 iPostcardEnabled (EFalse) |
|
60 { |
|
61 CActiveScheduler::Add(this); |
|
62 } |
|
63 |
|
64 // destructor |
|
65 CMceIdleMtmLoader::~CMceIdleMtmLoader() |
|
66 { |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------- |
|
70 // CMceIdleMtmLoader::StartL |
|
71 // --------------------------------------------------------- |
|
72 // |
|
73 void CMceIdleMtmLoader::StartL(CMsvSession& /*aSession*/, TBool aAudioMsgEnabled, TBool aPostcardEnabled) |
|
74 { |
|
75 MCELOGGER_ENTERFN("CMceIdleMtmLoader::StartL()"); |
|
76 iMsgTypesWriteSubmenu.Reset(); |
|
77 iMsgTypesWritePopup.Reset(); |
|
78 iMsgTypesSettings.Reset(); |
|
79 iMTMFunctionsArray.Reset(); |
|
80 iRegMtmIndex = 0; |
|
81 iAudioMsgEnabled = aAudioMsgEnabled ; // CR : 401-1806 |
|
82 iPostcardEnabled = aPostcardEnabled ; // CR : 401-1806 |
|
83 QueueLoad(); |
|
84 MCELOGGER_LEAVEFN("CMceIdleMtmLoader::StartL()"); |
|
85 } |
|
86 |
|
87 |
|
88 // --------------------------------------------------------- |
|
89 // CMceIdleMtmLoader::FinishL |
|
90 // --------------------------------------------------------- |
|
91 // |
|
92 void CMceIdleMtmLoader::FinishL(TBool aAudioMsgEnabled, TBool aPostcardEnabled) |
|
93 { |
|
94 MCELOGGER_ENTERFN("CMceIdleMtmLoader::FinishL()"); |
|
95 iAudioMsgEnabled = aAudioMsgEnabled ; // CR : 401-1806 |
|
96 iPostcardEnabled = aPostcardEnabled ; // CR : 401-1806 |
|
97 |
|
98 if(IsActive()) |
|
99 { |
|
100 // First consume the outstanding completion. |
|
101 Cancel(); |
|
102 // Now load the remaining MTMs synchronously. |
|
103 while(iRegMtmIndex < iUiRegistry.NumRegisteredMtmDlls()) |
|
104 { |
|
105 LoadMtmL( iUiRegistry.MtmTypeUid(iRegMtmIndex) ); |
|
106 iRegMtmIndex++; |
|
107 } |
|
108 |
|
109 MCELOGGER_WRITE_TIMESTAMP("Time: "); |
|
110 |
|
111 // And finally sort the array. |
|
112 SortAndChangeSmsMmsEmailFirstL(); |
|
113 } |
|
114 MCELOGGER_LEAVEFN("CMceIdleMtmLoader::FinishL()"); |
|
115 } |
|
116 |
|
117 |
|
118 // --------------------------------------------------------- |
|
119 // CMceIdleMtmLoader::DoCancel |
|
120 // --------------------------------------------------------- |
|
121 // |
|
122 void CMceIdleMtmLoader::DoCancel() |
|
123 { |
|
124 } |
|
125 |
|
126 |
|
127 // --------------------------------------------------------- |
|
128 // CMceIdleMtmLoader::RunL |
|
129 // --------------------------------------------------------- |
|
130 // |
|
131 void CMceIdleMtmLoader::RunL() |
|
132 { |
|
133 MCELOGGER_ENTERFN("CMceIdleMtmLoader::RunL()"); |
|
134 LoadMtmL(iUiRegistry.MtmTypeUid(iRegMtmIndex) ); |
|
135 iRegMtmIndex++; |
|
136 QueueLoad(); |
|
137 if(!IsActive()) |
|
138 { |
|
139 // Sort the array after all MTMs loaded. |
|
140 SortAndChangeSmsMmsEmailFirstL(); |
|
141 |
|
142 MCELOGGER_WRITE("CMceIdleMtmLoader: Mtm loading finished"); |
|
143 MCELOGGER_WRITE_TIMESTAMP("Time: "); |
|
144 |
|
145 |
|
146 } |
|
147 MCELOGGER_LEAVEFN("CMceIdleMtmLoader::RunL()"); |
|
148 } |
|
149 |
|
150 |
|
151 // --------------------------------------------------------- |
|
152 // CMceIdleMtmLoader::QueueLoad |
|
153 // --------------------------------------------------------- |
|
154 // |
|
155 void CMceIdleMtmLoader::QueueLoad() |
|
156 { |
|
157 MCELOGGER_ENTERFN("CMceIdleMtmLoader::QueueLoad()"); |
|
158 const TInt mtmCount = iUiRegistry.NumRegisteredMtmDlls(); |
|
159 if( iRegMtmIndex < mtmCount ) |
|
160 { |
|
161 TRequestStatus *s = &iStatus; |
|
162 User::RequestComplete(s, KErrNone); |
|
163 SetActive(); |
|
164 } |
|
165 MCELOGGER_LEAVEFN("CMceIdleMtmLoader::QueueLoad()"); |
|
166 } |
|
167 |
|
168 |
|
169 // --------------------------------------------------------- |
|
170 // CMceIdleMtmLoader::LoadMtmL |
|
171 // --------------------------------------------------------- |
|
172 // |
|
173 void CMceIdleMtmLoader::LoadMtmL( TUid aMtmType ) |
|
174 { |
|
175 MCELOGGER_ENTERFN("CMceIdleMtmLoader::LoadMtmL()"); |
|
176 MCELOGGER_WRITE_FORMAT("Loading %x", aMtmType.iUid ); |
|
177 // CR : 401-1806 |
|
178 FeatureManager::InitializeLibL(); |
|
179 TBool newPostcardVal = EFalse; |
|
180 TBool newAudioMsgVal = EFalse; |
|
181 TBool cMailVal = EFalse; |
|
182 newAudioMsgVal = FeatureManager::FeatureSupported( KFeatureIdAudioMessaging ); |
|
183 newPostcardVal = FeatureManager::FeatureSupported( KFeatureIdMmsPostcard ); |
|
184 cMailVal = FeatureManager::FeatureSupported( KFeatureIdFfEmailFramework ); |
|
185 FeatureManager::UnInitializeLib(); |
|
186 if ( aMtmType == KSenduiMtmAudioMessageUid && newAudioMsgVal != iAudioMsgEnabled ) |
|
187 { |
|
188 iMtmStore.ReleaseMtmUiData(aMtmType); |
|
189 } |
|
190 if ( aMtmType == KSenduiMtmPostcardUid && newPostcardVal != iPostcardEnabled) |
|
191 { |
|
192 iMtmStore.ReleaseMtmUiData(aMtmType); |
|
193 } |
|
194 CBaseMtmUiData* uiData = NULL; |
|
195 TRAPD(err, ( uiData = &(iMtmStore.MtmUiDataL(aMtmType)) ) ); |
|
196 if(err != KErrNone) |
|
197 { |
|
198 return; |
|
199 } |
|
200 |
|
201 TInt response; |
|
202 TUid canSend; |
|
203 canSend.iUid = KUidMsvMtmQuerySupportEditor ; |
|
204 |
|
205 TInt canSendResponse=uiData->QueryCapability(canSend, response); |
|
206 if ( canSendResponse != KErrNone ) |
|
207 { |
|
208 canSend.iUid = KUidMtmQueryCanCreateNewMsgValue; |
|
209 canSendResponse = uiData->QueryCapability( canSend, response ); |
|
210 } |
|
211 |
|
212 TBool foundPopup = EFalse; |
|
213 TBool foundSubmenu = EFalse; |
|
214 const CArrayFix<CBaseMtmUiData::TMtmUiFunction>& funcs = |
|
215 uiData->MtmSpecificFunctions(); |
|
216 const TInt numFuncs = funcs.Count(); |
|
217 |
|
218 for (TInt funcIndex = 0; funcIndex < numFuncs; funcIndex++ ) |
|
219 { |
|
220 CBaseMtmUiData::TMtmUiFunction func = funcs.At(funcIndex); |
|
221 |
|
222 if ( (func.iFlags&EMtudCommandTransferSend) || |
|
223 (func.iFlags&EMtudCommandTransferReceive) ) |
|
224 { |
|
225 if ( canSendResponse == KErrNone && |
|
226 func.iFunctionId == KMtmUiMceWriteMessageSubmenu ) |
|
227 { |
|
228 iMsgTypesWriteSubmenu.AppendL( TUidNameInfo( |
|
229 aMtmType, |
|
230 func.iCaption ) ); |
|
231 foundSubmenu = ETrue; |
|
232 } |
|
233 else if ( canSendResponse == KErrNone && |
|
234 func.iFunctionId == KMtmUiMceWriteMessagePopup ) |
|
235 { |
|
236 iMsgTypesWritePopup.AppendL( TUidNameInfo( |
|
237 aMtmType, |
|
238 func.iCaption ) ); |
|
239 foundPopup = ETrue; |
|
240 } |
|
241 else if ( func.iFunctionId == KMtmUiMceSettings ) |
|
242 { |
|
243 iMsgTypesSettings.AppendL( TUidNameInfo( |
|
244 aMtmType, |
|
245 func.iCaption ) ); |
|
246 } |
|
247 else |
|
248 { |
|
249 iMTMFunctionsArray.AppendL( |
|
250 TMsgFunctionInfo( |
|
251 func.iCaption, |
|
252 func.iPreferredHotKeyKeyCode, |
|
253 func.iPreferredHotKeyModifiers, |
|
254 func.iFunctionId, |
|
255 func.iFlags, |
|
256 aMtmType) ); |
|
257 } |
|
258 } |
|
259 } // end for |
|
260 |
|
261 |
|
262 if ( canSendResponse == KErrNone ) |
|
263 { |
|
264 if ( !foundPopup ) |
|
265 { |
|
266 iMsgTypesWritePopup.AppendL( TUidNameInfo( |
|
267 aMtmType, |
|
268 iUiRegistry.RegisteredMtmDllInfo(aMtmType).HumanReadableName() |
|
269 )); |
|
270 } |
|
271 |
|
272 if ( !foundSubmenu ) |
|
273 { |
|
274 //cmail update |
|
275 if(!(cMailVal && (aMtmType.iUid == KUidMsgTypeFsMtmVal))) |
|
276 { |
|
277 iMsgTypesWriteSubmenu.AppendL( TUidNameInfo( |
|
278 aMtmType, |
|
279 iUiRegistry.RegisteredMtmDllInfo(aMtmType).HumanReadableName() |
|
280 )); |
|
281 } |
|
282 //cmail update |
|
283 } |
|
284 } |
|
285 |
|
286 MCELOGGER_LEAVEFN("CMceIdleMtmLoader::LoadMtmL()"); |
|
287 } |
|
288 |
|
289 // --------------------------------------------------------- |
|
290 // CMceIdleMtmLoader::SortAndChangeSmsMmsEmailFirstL |
|
291 // --------------------------------------------------------- |
|
292 // |
|
293 void CMceIdleMtmLoader::SortAndChangeSmsMmsEmailFirstL() |
|
294 { |
|
295 iMsgTypesSettings.Sort(ECmpFolded); |
|
296 iMsgTypesWritePopup.Sort(ECmpFolded); |
|
297 iMsgTypesWriteSubmenu.Sort(ECmpFolded); |
|
298 |
|
299 ChangeMsgTypeTopL( iMsgTypesSettings, KSenduiMtmPostcardUid ); |
|
300 ChangeMsgTypeTopL( iMsgTypesWritePopup, KSenduiMtmPostcardUid ); |
|
301 ChangeMsgTypeTopL( iMsgTypesWriteSubmenu, KSenduiMtmPostcardUid ); |
|
302 |
|
303 ChangeMsgTypeTopL( iMsgTypesSettings, KSenduiMtmSyncMLEmailUid ); |
|
304 ChangeMsgTypeTopL( iMsgTypesWritePopup, KSenduiMtmSyncMLEmailUid ); |
|
305 ChangeMsgTypeTopL( iMsgTypesWriteSubmenu, KSenduiMtmSyncMLEmailUid ); |
|
306 |
|
307 ChangeMsgTypeTopL( iMsgTypesSettings, KSenduiMtmSmtpUid ); |
|
308 ChangeMsgTypeTopL( iMsgTypesWritePopup, KSenduiMtmSmtpUid ); |
|
309 ChangeMsgTypeTopL( iMsgTypesWriteSubmenu, KSenduiMtmSmtpUid ); |
|
310 |
|
311 ChangeMsgTypeTopL( iMsgTypesSettings, KSenduiMtmAudioMessageUid ); |
|
312 ChangeMsgTypeTopL( iMsgTypesWritePopup, KSenduiMtmAudioMessageUid ); |
|
313 ChangeMsgTypeTopL( iMsgTypesWriteSubmenu, KSenduiMtmAudioMessageUid ); |
|
314 |
|
315 // SMS & MMS still have own settings although the editor is common. |
|
316 ChangeMsgTypeTopL( iMsgTypesSettings, KSenduiMtmMmsUid ); |
|
317 ChangeMsgTypeTopL( iMsgTypesSettings, KSenduiMtmSmsUid ); |
|
318 ChangeMsgTypeTopL( iMsgTypesWritePopup, KSenduiMtmUniMessageUid ); |
|
319 ChangeMsgTypeTopL( iMsgTypesWriteSubmenu, KSenduiMtmUniMessageUid ); |
|
320 } |
|
321 // --------------------------------------------------------- |
|
322 // CMceIdleMtmLoader::ChangeMsgTypeTopL |
|
323 // --------------------------------------------------------- |
|
324 // |
|
325 void CMceIdleMtmLoader::ChangeMsgTypeTopL( CUidNameArray& aArray, TUid aMsgType ) const |
|
326 { |
|
327 TInt loop = 0; |
|
328 // first change email to the top |
|
329 for (loop=1; loop < aArray.Count(); loop++) |
|
330 { |
|
331 if (aArray[loop].iUid == aMsgType) |
|
332 { |
|
333 TUidNameInfo info = aArray[loop]; |
|
334 aArray.InsertL( 0, info ); |
|
335 aArray.Delete( loop+1 ); |
|
336 break; |
|
337 } |
|
338 } |
|
339 } |
|
340 |
|
341 // End of File |