|
1 /* |
|
2 * Copyright (c) 2002-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: |
|
15 * Sms Ui Mtm. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 |
|
23 // Specific includes |
|
24 #include <SMUM.rsg> // resource ids |
|
25 #include <etelmm.h> |
|
26 #include <smuthdr.h> // for CSmsHeader |
|
27 #include <smutset.h> // CSmsNumber |
|
28 #include <smscmds.h> // TSmsMtmCommand |
|
29 #include <aknViewAppUi.h> // iAvkonViewAppUi |
|
30 #include <MtmExtendedCapabilities.hrh> |
|
31 // Standard includes |
|
32 #include <txtrich.h> // CRichText |
|
33 #include <aknnotewrappers.h> |
|
34 // Comms includes |
|
35 #include <MuiuMsgEditorLauncher.h> // MsgEditorLauncher |
|
36 #include <MsgBioUids.h> // KMsgBioUidPictureMsg |
|
37 #include <akninputblock.h> // CAknInputBlock |
|
38 #include <Muiumsginfo.h> // CMsgInfoMessageInfoDialog |
|
39 #include <MuiuOperationWait.h> // MuiuOperationWait |
|
40 // other includes |
|
41 #include <StringLoader.h> // StringLoader |
|
42 #include <ErrorUI.h> // CErrorUI |
|
43 |
|
44 #include <centralrepository.h> |
|
45 #include <messaginginternalcrkeys.h> |
|
46 #include <messagingvariant.hrh> |
|
47 #include <BTSapDomainPSKeys.h> // KPSUidBluetoothSapConnectionState, KBTSapConnectionState |
|
48 #include <startupdomainpskeys.h> |
|
49 #include <gmsModel.h> |
|
50 |
|
51 #include <e32property.h> // RProperty |
|
52 #include <PSVariables.h> // RProperty |
|
53 #include <sacls.h> |
|
54 |
|
55 #include <csmsaccount.h> |
|
56 #include <csmsemailfields.h> // CSmsEmailFields |
|
57 // locals |
|
58 #include "SmumSettingsDialogGSM.h" // CSmumMainSettingsDialogGSM |
|
59 #include "SmumUtil.h" // SmumUtil |
|
60 #include "SMSU.HRH" // for KMtmUiFunctionSimDialog |
|
61 #include "SMSU.H" // CSmsMtmUi |
|
62 #include "smsui.pan" // panics |
|
63 #include "simdlgplugininterface.h" |
|
64 #include "BioOpenOp.h" // CBioOpenOp |
|
65 #include "MsgSimSCNumberDetector.h" // CMsgSimOperation |
|
66 |
|
67 // Includes for fix to error SPAN-6B7K33 |
|
68 #include <rmmcustomapi.h> |
|
69 #include <mmtsy_names.h> |
|
70 |
|
71 //For logging |
|
72 #include "SmumLogging.h" |
|
73 |
|
74 // LOCAL CONSTANTS AND MACROS |
|
75 const TInt KMaxSubjectLength = 30; |
|
76 const TInt KSmumAdditionalCharsStringLength = 7; |
|
77 const TUint KSmumLRMarker = 0x200E; |
|
78 const TUint KSmumChineseOffset = 8; |
|
79 _LIT( KSmsuResourceFile, "SMUM" ); |
|
80 _LIT( KSmumSpace, " " ); |
|
81 _LIT( KSmumCharLeftAddressIterator, "<" ); |
|
82 _LIT( KSmumCharRightAddressIterator, ">" ); |
|
83 _LIT( KSmumCharCommaAndSpace, ", " ); |
|
84 _LIT( KSmumSmsService, "Sms Service" ); |
|
85 _LIT( KSmumChinaCountryCode, "+86"); |
|
86 _LIT( KSmumInternationalPrefix, "+"); |
|
87 |
|
88 // Default values, if shared data reading fails |
|
89 const TInt KDefDeliveryReport = 1; |
|
90 const TInt KDefValidityPeriod = 1440; |
|
91 const TInt KDefMessageConversion = 0; |
|
92 const TInt KDefPreferredConnection = 3; |
|
93 const TInt KDefReplyViaSameCentre = 0; |
|
94 // Constants for sms initialization |
|
95 const TInt KInitializationReady = 2; |
|
96 const TInt KInitializationReadSim = 3; |
|
97 |
|
98 // MEMBER FUNCTIONS |
|
99 |
|
100 // Factory constructor function |
|
101 CSmsMtmUi* CSmsMtmUi::NewL( CBaseMtm& aBaseMtm, CRegisteredMtmDll& aRegisteredMtmDll ) |
|
102 { |
|
103 SMUMLOGGER_ENTERFN(" CSmsMtmUi::NewL"); |
|
104 CSmsMtmUi* smsmtmui=new ( ELeave ) CSmsMtmUi( aBaseMtm, aRegisteredMtmDll ); |
|
105 CleanupStack::PushL( smsmtmui ); |
|
106 smsmtmui->ConstructL(); |
|
107 CleanupStack::Pop(); |
|
108 SMUMLOGGER_LEAVEFN(" CSmsMtmUi::NewL"); |
|
109 return smsmtmui; |
|
110 } |
|
111 |
|
112 // C++ constructor can NOT contain any code, that |
|
113 // might leave. |
|
114 CSmsMtmUi::CSmsMtmUi( CBaseMtm& aBaseMtm, CRegisteredMtmDll& aRegisteredMtmDll ): |
|
115 CBaseMtmUi( aBaseMtm, aRegisteredMtmDll ) |
|
116 { |
|
117 } |
|
118 |
|
119 // Symbian OS default constructor can leave. |
|
120 void CSmsMtmUi::ConstructL() |
|
121 { |
|
122 SMUMLOGGER_ENTERFN(" CSmsMtmUi::ConstructL"); |
|
123 CBaseMtmUi::ConstructL(); |
|
124 |
|
125 TInt err( KErrGeneral ); |
|
126 // connect etel server |
|
127 User::LeaveIfError( iServer.Connect() ); |
|
128 // load tsy |
|
129 err = iServer.LoadPhoneModule( KMmTsyModuleName ); |
|
130 if ( err != KErrAlreadyExists ) |
|
131 { |
|
132 // may return also KErrAlreadyExists if some other |
|
133 // is already loaded the tsy module. And that is |
|
134 // not an error. |
|
135 User::LeaveIfError( err ); |
|
136 } |
|
137 User::LeaveIfError( iPhone.Open( iServer, KMmTsyPhoneName ) ); |
|
138 |
|
139 // Error resolver |
|
140 iErrorResolver = CTextResolver::NewL( *iCoeEnv ); |
|
141 // Create the session |
|
142 iCenRepSession = CRepository::NewL( KCRUidSmum ); |
|
143 // create sim-dialog plugin interface |
|
144 iSimDlgPluginIntf = CSimDlgPluginInterface::NewL(*this, Session()); |
|
145 SMUMLOGGER_LEAVEFN(" CSmsMtmUi::ConstructL"); |
|
146 } |
|
147 |
|
148 // Destructor |
|
149 CSmsMtmUi::~CSmsMtmUi() |
|
150 { |
|
151 SMUMLOGGER_ENTERFN(" CSmsMtmUi::~CSmsMtmUi"); |
|
152 //close ETel connection |
|
153 if (iServer.Handle()) |
|
154 { |
|
155 iPhone.Close(); |
|
156 iServer.UnloadPhoneModule(KMmTsyModuleName); |
|
157 iServer.Close(); |
|
158 } |
|
159 delete iErrorResolver; |
|
160 delete iCenRepSession; |
|
161 delete iSimDlgPluginIntf; |
|
162 SMUMLOGGER_LEAVEFN(" CSmsMtmUi::~CSmsMtmUi"); |
|
163 } |
|
164 |
|
165 // --------------------------------------------------------- |
|
166 // CSmsMtmUi::CreateL |
|
167 // |
|
168 // --------------------------------------------------------- |
|
169 CMsvOperation* CSmsMtmUi::CreateL(const TMsvEntry& aEntry, CMsvEntry& aParent, TRequestStatus& aStatus) |
|
170 { |
|
171 SMUMLOGGER_ENTERFN(" CSmsMtmUi::CreateL"); |
|
172 // Create a Sms message (services are provided "for nothing", created invisibly by the UI layer. |
|
173 __ASSERT_DEBUG( aEntry.iMtm == Type(), Panic( ESmsuWrongMtmType )); |
|
174 __ASSERT_DEBUG( aEntry.iType == KUidMsvMessageEntry, Panic( ESmsuNotAMessage )); |
|
175 __ASSERT_DEBUG( aParent.Entry().iServiceId == KMsvLocalServiceIndexEntryId || |
|
176 aParent.Entry().iServiceId == KMsvNullIndexEntryId, Panic( ESmsuMessageNotLocal )); |
|
177 __ASSERT_DEBUG(( aParent.Entry().iType == KUidMsvFolderEntry && |
|
178 aParent.Entry().iServiceId == KMsvLocalServiceIndexEntryId), |
|
179 Panic( ESmsuMessageParentNotLocalFolder )); |
|
180 |
|
181 if( !CheckEntry( aEntry )) |
|
182 { |
|
183 User::Leave( KErrNotSupported ); // Not SMS, or not a message |
|
184 } |
|
185 |
|
186 CheckAndEnsureSmsServiceOkL( ETrue, ETrue, ETrue ); |
|
187 |
|
188 SMUMLOGGER_LEAVEFN(" CSmsMtmUi::CreateL"); |
|
189 return LaunchEditorApplicationL( aStatus, aParent.Session(), ECreateNewMessage ); |
|
190 } |
|
191 |
|
192 // --------------------------------------------------------- |
|
193 // CSmsMtmUi::OpenL |
|
194 // |
|
195 // --------------------------------------------------------- |
|
196 CMsvOperation* CSmsMtmUi::OpenL(TRequestStatus& aStatus) |
|
197 { |
|
198 SMUMLOGGER_ENTERFN(" CSmsMtmUi::OpenL"); |
|
199 |
|
200 __ASSERT_DEBUG( |
|
201 BaseMtm().Entry().Entry().iMtm == Type(), Panic( ESmsuWrongMtmType )); |
|
202 __ASSERT_DEBUG( BaseMtm().Entry().Entry().iType != |
|
203 KUidMsvFolderEntry, Panic( ESmsuFoldersNotSupported )); |
|
204 __ASSERT_DEBUG( BaseMtm().Entry().Entry().iType != KUidMsvAttachmentEntry, |
|
205 Panic( ESmsuAttachmentsNotSupported )); |
|
206 |
|
207 const TMsvEntry myEntry = BaseMtm().Entry().Entry(); |
|
208 if( myEntry.iType == KUidMsvFolderEntry || myEntry.iType == KUidMsvAttachmentEntry ) |
|
209 { |
|
210 User::Leave(KErrNotSupported); |
|
211 } |
|
212 else if ( myEntry.iType == KUidMsvMessageEntry ) |
|
213 { |
|
214 CheckAndEnsureSmsServiceOkL( ETrue, ETrue, ETrue ); |
|
215 } |
|
216 else // Lint |
|
217 { |
|
218 } |
|
219 CSmsClientMtm& smsClientMtm = SmsClientMtm(); |
|
220 smsClientMtm.LoadMessageL(); |
|
221 const CSmsPDU::TSmsPDUType pduType = smsClientMtm.SmsHeader().Type(); |
|
222 CSmsPDU& pdu = smsClientMtm.SmsHeader().Message().SmsPDU(); |
|
223 TSmsDataCodingScheme::TSmsClass smsClass; |
|
224 pdu.Class( smsClass ); |
|
225 /* |
|
226 Fix to error SPAN-6B7K33 |
|
227 In case this happens to be an unread message stored on sim, |
|
228 TSY sets the status of the message to 'read' on the sim also. |
|
229 */ |
|
230 if( pduType == CSmsPDU::ESmsDeliver && |
|
231 smsClass == TSmsDataCodingScheme::ESmsClass2) |
|
232 { |
|
233 CSmsDeliver& deliv = smsClientMtm.SmsHeader().Deliver(); |
|
234 |
|
235 TTime scTime; |
|
236 TInt scQh; |
|
237 deliv.ServiceCenterTimeStamp(scTime, scQh); |
|
238 |
|
239 RMmCustomAPI ca; |
|
240 if ( KErrNone == ca.Open( iPhone ) ) |
|
241 { |
|
242 ca.SetSimMessageStatusRead( scTime, scQh ); |
|
243 ca.Close(); |
|
244 } |
|
245 } |
|
246 // Check are we dealing with delivery raport |
|
247 // No support for 8-bit non GMS messages |
|
248 if ( !(pduType == CSmsPDU::ESmsDeliver || pduType == CSmsPDU::ESmsSubmit) || |
|
249 ( pdu.Alphabet() == TSmsDataCodingScheme::ESmsAlphabet8Bit && !IsBioTypeSupported( myEntry ) ) ) |
|
250 { |
|
251 if ( myEntry.Unread() ) |
|
252 { |
|
253 // Mark the entry as read |
|
254 CMsvEntry* cEntry = &(BaseMtm().Entry()); |
|
255 TMsvEntry entry = cEntry->Entry(); |
|
256 entry.SetUnread( EFalse ); |
|
257 cEntry->ChangeL( entry ); |
|
258 } |
|
259 |
|
260 TSmsSmumProgress progress; |
|
261 progress.iError = KErrNotSupported; |
|
262 progress.iType = TSmsSmumProgress::ESmsSmumSmsOpening; |
|
263 TSmsSmumProgressBuf progressBuf( progress ); |
|
264 |
|
265 SMUMLOGGER_ENTERFN(" CSmsMtmUi::OpenL - completedOp"); |
|
266 return CMsvCompletedOperation::NewL( |
|
267 Session(), |
|
268 Type(), |
|
269 progressBuf, |
|
270 KMsvLocalServiceIndexEntryId, |
|
271 aStatus, |
|
272 KErrNotSupported ); |
|
273 } |
|
274 |
|
275 if (KMsvDraftEntryIdValue == myEntry.Parent()) |
|
276 { |
|
277 SMUMLOGGER_ENTERFN(" CSmsMtmUi::OpenL- EditL"); |
|
278 return EditL( aStatus ); |
|
279 } |
|
280 else |
|
281 { |
|
282 SMUMLOGGER_ENTERFN(" CSmsMtmUi::OpenL- viewL"); |
|
283 return ViewL( aStatus ); |
|
284 } |
|
285 } |
|
286 |
|
287 // --------------------------------------------------------- |
|
288 // CSmsMtmUi::CloseL |
|
289 // |
|
290 // --------------------------------------------------------- |
|
291 CMsvOperation* CSmsMtmUi::CloseL(TRequestStatus& /*aStatus*/) |
|
292 { |
|
293 SMUMLOGGER_ENTERFN(" CSmsMtmUi::CloseL"); |
|
294 User::Leave( KErrNotSupported ); |
|
295 SMUMLOGGER_LEAVEFN(" CSmsMtmUi::CloseL"); |
|
296 return NULL; |
|
297 } |
|
298 |
|
299 // --------------------------------------------------------- |
|
300 // CSmsMtmUi::EditL |
|
301 // |
|
302 // --------------------------------------------------------- |
|
303 CMsvOperation* CSmsMtmUi::EditL( TRequestStatus& aStatus ) |
|
304 { |
|
305 SMUMLOGGER_ENTERFN(" CSmsMtmUi::EditL"); |
|
306 __ASSERT_DEBUG( BaseMtm().Entry().Entry().iMtm == |
|
307 Type(), Panic( ESmsuWrongMtmType )); |
|
308 |
|
309 CMsvOperation* msvoperation = NULL; |
|
310 |
|
311 if( BaseMtm().Entry().Entry().iBioType != 0 ) |
|
312 { // BIO msg |
|
313 msvoperation = CBioOpenOp::NewL( |
|
314 Session(), |
|
315 aStatus, |
|
316 BaseMtm().Entry().EntryId(), |
|
317 Preferences()); |
|
318 } |
|
319 else |
|
320 { // not BIO msg |
|
321 // What kind of entry are we going to edit? |
|
322 switch ( iBaseMtm.Entry().Entry().iType.iUid ) |
|
323 { |
|
324 case KUidMsvServiceEntryValue: |
|
325 CheckAndEnsureSmsServiceOkL( ETrue, ETrue, ETrue ); |
|
326 msvoperation = LaunchSettingsDialogL( aStatus ); |
|
327 break; |
|
328 case KUidMsvMessageEntryValue: |
|
329 if ( BaseMtm().Entry().Entry().ReadOnly() ) |
|
330 { |
|
331 User::Leave(KErrAccessDenied); |
|
332 } |
|
333 msvoperation = LaunchEditorApplicationL( aStatus, iBaseMtm.Entry().Session()); |
|
334 break; |
|
335 case KUidMsvFolderEntryValue: |
|
336 case KUidMsvAttachmentEntryValue: |
|
337 default: |
|
338 #if defined( _DEBUG ) |
|
339 Panic( ESmsuWrongEntryType ); |
|
340 #else |
|
341 User::Leave( KErrNotSupported ); |
|
342 #endif |
|
343 } |
|
344 } |
|
345 |
|
346 SMUMLOGGER_LEAVEFN(" CSmsMtmUi::EditL"); |
|
347 return msvoperation; |
|
348 } |
|
349 |
|
350 // --------------------------------------------------------- |
|
351 // CSmsMtmUi::ViewL |
|
352 // |
|
353 // --------------------------------------------------------- |
|
354 CMsvOperation* CSmsMtmUi::ViewL( TRequestStatus& aStatus ) |
|
355 { |
|
356 SMUMLOGGER_ENTERFN(" CSmsMtmUi::ViewL"); |
|
357 __ASSERT_DEBUG( BaseMtm().Entry().Entry().iMtm == Type(), |
|
358 Panic( EBioViewNotAllowed )); |
|
359 |
|
360 CMsvOperation* msvoperation = NULL; |
|
361 |
|
362 if( iBaseMtm.Entry().Entry().iType.iUid == KUidMsvMessageEntryValue ) |
|
363 { |
|
364 msvoperation = LaunchEditorApplicationL( aStatus, iBaseMtm.Entry().Session(), EReadOnly); |
|
365 } |
|
366 else |
|
367 { |
|
368 #if defined( _DEBUG ) |
|
369 Panic( ESmsuWrongEntryType ); |
|
370 #else |
|
371 User::Leave( KErrNotSupported ); |
|
372 #endif |
|
373 } |
|
374 SMUMLOGGER_LEAVEFN(" CSmsMtmUi::ViewL"); |
|
375 |
|
376 return msvoperation; |
|
377 } |
|
378 |
|
379 // --------------------------------------------------------- |
|
380 // CSmsMtmUi::OpenL |
|
381 // |
|
382 // --------------------------------------------------------- |
|
383 CMsvOperation* CSmsMtmUi::OpenL( TRequestStatus& aStatus, const CMsvEntrySelection& aSelection ) |
|
384 { |
|
385 SMUMLOGGER_ENTERFN(" CSmsMtmUi::OpenL"); |
|
386 __ASSERT_DEBUG( aSelection.Count() > 0, Panic( ESmsuEmptySelection )); |
|
387 |
|
388 // Open the first entry in the selection |
|
389 BaseMtm().SwitchCurrentEntryL( aSelection[0] ); |
|
390 SMUMLOGGER_LEAVEFN(" CSmsMtmUi::OpenL"); |
|
391 return OpenL( aStatus ); |
|
392 } |
|
393 |
|
394 // --------------------------------------------------------- |
|
395 // CSmsMtmUi::CloseL |
|
396 // |
|
397 // --------------------------------------------------------- |
|
398 CMsvOperation* CSmsMtmUi::CloseL( TRequestStatus& /*aStatus*/, const CMsvEntrySelection& /*aSelection*/ ) |
|
399 { |
|
400 SMUMLOGGER_WRITE(" CSmsMtmUi::CloseL"); |
|
401 User::Leave( KErrNotSupported ); |
|
402 return NULL; |
|
403 } |
|
404 |
|
405 // --------------------------------------------------------- |
|
406 // CSmsMtmUi::EditL |
|
407 // |
|
408 // --------------------------------------------------------- |
|
409 CMsvOperation* CSmsMtmUi::EditL( TRequestStatus& aStatus, const CMsvEntrySelection& aSelection ) |
|
410 { |
|
411 SMUMLOGGER_ENTERFN(" CSmsMtmUi::EditL - AGAIN"); |
|
412 __ASSERT_ALWAYS( aSelection.Count() > 0 , Panic( ESmsuEmptySelection )); |
|
413 |
|
414 // Edit the first entry in the selection |
|
415 BaseMtm().SwitchCurrentEntryL( aSelection[0] ); |
|
416 SMUMLOGGER_LEAVEFN(" CSmsMtmUi::EditL - AGAIN"); |
|
417 return EditL( aStatus ); |
|
418 } |
|
419 |
|
420 // --------------------------------------------------------- |
|
421 // CSmsMtmUi::ViewL |
|
422 // |
|
423 // --------------------------------------------------------- |
|
424 CMsvOperation* CSmsMtmUi::ViewL( TRequestStatus& aStatus, const CMsvEntrySelection& aSelection ) |
|
425 { |
|
426 SMUMLOGGER_ENTERFN(" CSmsMtmUi::ViewL - AGAIN"); |
|
427 __ASSERT_DEBUG( aSelection.Count() > 0, Panic( ESmsuEmptySelection )); |
|
428 |
|
429 // View the first entry in the selection |
|
430 BaseMtm().SwitchCurrentEntryL( aSelection[0] ); |
|
431 SMUMLOGGER_LEAVEFN(" CSmsMtmUi::ViewL - AGAIN"); |
|
432 return ViewL( aStatus ); |
|
433 } |
|
434 |
|
435 // --------------------------------------------------------- |
|
436 // CSmsMtmUi::CancelL |
|
437 // |
|
438 // --------------------------------------------------------- |
|
439 CMsvOperation* CSmsMtmUi::CancelL( TRequestStatus& aStatus, const CMsvEntrySelection& aSelection ) |
|
440 { |
|
441 SMUMLOGGER_ENTERFN(" CSmsMtmUi::CancelL"); |
|
442 TInt loop = aSelection.Count(); |
|
443 |
|
444 __ASSERT_DEBUG( loop > 0, Panic( ESmsuEmptySelection )); |
|
445 |
|
446 CMsvEntry* entry = Session().GetEntryL( aSelection[0] ); |
|
447 CleanupStack::PushL( entry ); |
|
448 |
|
449 while ( loop-- ) |
|
450 { |
|
451 entry->SetEntryL( aSelection[loop] ); |
|
452 TMsvEntry tempEntry = entry->Entry(); |
|
453 tempEntry.SetSendingState( KMsvSendStateSuspended ); |
|
454 tempEntry.iDate.UniversalTime(); |
|
455 tempEntry.iRelatedId = tempEntry.iServiceId; |
|
456 tempEntry.iServiceId = KMsvLocalServiceIndexEntryId; |
|
457 entry->ChangeL( tempEntry ); |
|
458 } |
|
459 |
|
460 CleanupStack::PopAndDestroy();// entry |
|
461 |
|
462 TSmsProgressBuf progress; |
|
463 Session().ServiceProgress( SmsClientMtm().ServiceId(), progress ); //ignore error |
|
464 |
|
465 TBuf8<1> dummy; |
|
466 dummy.Zero(); |
|
467 SMUMLOGGER_LEAVEFN(" CSmsMtmUi::CancelL"); |
|
468 return CBaseMtmUi::InvokeAsyncFunctionL( ESmsMtmCommandDeleteSchedule, aSelection, aStatus, dummy ); |
|
469 } |
|
470 |
|
471 // --------------------------------------------------------- |
|
472 // CSmsMtmUi::DeleteFromL |
|
473 // |
|
474 // --------------------------------------------------------- |
|
475 CMsvOperation* CSmsMtmUi::DeleteFromL( const CMsvEntrySelection& /*aSelection*/, TRequestStatus& /*aStatus*/ ) |
|
476 { |
|
477 SMUMLOGGER_WRITE(" CSmsMtmUi::DeleteFromL"); |
|
478 User::Leave( KErrNotSupported ); |
|
479 return NULL; |
|
480 } |
|
481 |
|
482 // --------------------------------------------------------- |
|
483 // CSmsMtmUi::DeleteServiceL |
|
484 // |
|
485 // --------------------------------------------------------- |
|
486 CMsvOperation* CSmsMtmUi::DeleteServiceL( const TMsvEntry& /*aService*/, TRequestStatus& /*aStatus*/ ) |
|
487 { |
|
488 SMUMLOGGER_WRITE(" CSmsMtmUi::DeleteServiceL"); |
|
489 User::Leave( KErrNotSupported ); |
|
490 return NULL; |
|
491 } |
|
492 |
|
493 // --------------------------------------------------------- |
|
494 // CSmsMtmUi::ReplyL |
|
495 // |
|
496 // --------------------------------------------------------- |
|
497 CMsvOperation* CSmsMtmUi::ReplyL( |
|
498 TMsvId aDestination, |
|
499 TMsvPartList /*aPartlist*/, |
|
500 TRequestStatus& aCompletionStatus ) |
|
501 { |
|
502 SMUMLOGGER_ENTERFN(" CSmsMtmUi::ReplyL"); |
|
503 CheckAndEnsureSmsServiceOkL( ETrue, ETrue, ETrue ); |
|
504 |
|
505 // Set params |
|
506 TEditorParameters editorParams; |
|
507 editorParams.iFlags |= EMsgReplyToMessageSender; |
|
508 |
|
509 editorParams.iId = BaseMtm().Entry().EntryId(); |
|
510 editorParams.iDestinationFolderId = aDestination; |
|
511 editorParams.iFlags &=~ ( EMtmUiFlagEditorPreferEmbedded | EMtmUiFlagEditorNoWaitForExit ); |
|
512 editorParams.iFlags |= ( Preferences() & EMtmUiFlagEditorPreferEmbedded ? EMsgLaunchEditorEmbedded : 0 ); |
|
513 editorParams.iFlags |= ( Preferences() & EMtmUiFlagEditorNoWaitForExit ? 0 : EMsgLaunchEditorThenWait ); |
|
514 |
|
515 SMUMLOGGER_LEAVEFN(" CSmsMtmUi::ReplyL"); |
|
516 return MsgEditorLauncher::LaunchEditorApplicationL(Session(), Type(), aCompletionStatus, editorParams, KNullDesC /*, paramPack*/); |
|
517 } |
|
518 |
|
519 // --------------------------------------------------------- |
|
520 // CSmsMtmUi::ForwardL |
|
521 // |
|
522 // --------------------------------------------------------- |
|
523 CMsvOperation* CSmsMtmUi::ForwardL( |
|
524 TMsvId aDestination, |
|
525 TMsvPartList /*aPartList*/, |
|
526 TRequestStatus& aCompletionStatus ) |
|
527 { |
|
528 SMUMLOGGER_ENTERFN(" CSmsMtmUi::ForwardL"); |
|
529 CheckAndEnsureSmsServiceOkL( ETrue, ETrue, ETrue ); |
|
530 |
|
531 // Set params |
|
532 TEditorParameters editorParams; |
|
533 editorParams.iFlags |= EMsgForwardMessage; |
|
534 |
|
535 editorParams.iId = BaseMtm().Entry().EntryId(); |
|
536 editorParams.iFlags &=~ ( EMtmUiFlagEditorPreferEmbedded | EMtmUiFlagEditorNoWaitForExit ); |
|
537 editorParams.iFlags |= ( Preferences() & EMtmUiFlagEditorPreferEmbedded ? EMsgLaunchEditorEmbedded : 0 ); |
|
538 editorParams.iFlags |= (Preferences() & EMtmUiFlagEditorNoWaitForExit ? 0 : EMsgLaunchEditorThenWait ); |
|
539 editorParams.iDestinationFolderId = aDestination; |
|
540 |
|
541 SMUMLOGGER_LEAVEFN(" CSmsMtmUi::ForwardL"); |
|
542 return MsgEditorLauncher::LaunchEditorApplicationL(Session(), Type(), aCompletionStatus, editorParams, KNullDesC /*, paramPack*/); |
|
543 } |
|
544 |
|
545 // In the following two functions, the user has chosen to move or copy the message |
|
546 // to a service i.e. send it. |
|
547 // |
|
548 |
|
549 // --------------------------------------------------------- |
|
550 // CSmsMtmUi::CopyToL |
|
551 // |
|
552 // --------------------------------------------------------- |
|
553 CMsvOperation* CSmsMtmUi::CopyToL( const CMsvEntrySelection& aSelection, TRequestStatus& aStatus ) |
|
554 { |
|
555 return CopyMoveToL( aSelection, aStatus, ETrue ); |
|
556 } |
|
557 |
|
558 // --------------------------------------------------------- |
|
559 // CSmsMtmUi::MoveToL |
|
560 // |
|
561 // --------------------------------------------------------- |
|
562 CMsvOperation* CSmsMtmUi::MoveToL( const CMsvEntrySelection& aSelection, TRequestStatus& aStatus ) |
|
563 { |
|
564 return CopyMoveToL( aSelection, aStatus, EFalse ); |
|
565 } |
|
566 |
|
567 // --------------------------------------------------------- |
|
568 // CSmsMtmUi::CopyMoveToL |
|
569 // |
|
570 // --------------------------------------------------------- |
|
571 CMsvOperation* CSmsMtmUi::CopyMoveToL( |
|
572 const CMsvEntrySelection& aSelection, |
|
573 TRequestStatus& aStatus, |
|
574 TBool aCopyOnly ) |
|
575 { |
|
576 SMUMLOGGER_ENTERFN(" CSmsMtmUi::CopyMoveToL"); |
|
577 __ASSERT_DEBUG( |
|
578 BaseMtm().Entry().Entry().iMtm == Type(), Panic( ESmsuWrongMtmType )); |
|
579 __ASSERT_DEBUG( |
|
580 BaseMtm().Entry().Entry().iType == KUidMsvServiceEntry, |
|
581 Panic( ESmsuNotAServiceEntry )); |
|
582 |
|
583 TInt count = aSelection.Count(); |
|
584 __ASSERT_DEBUG( count > 0 , Panic( ESmsuEmptySelection )); |
|
585 |
|
586 // --- Carry out the operation --- |
|
587 TMsvEntry smsServiceEntry( BaseMtm().Entry().Entry()); |
|
588 CMsvEntry* parentEntry= Session().GetEntryL( aSelection[count-1] ); |
|
589 CleanupStack::PushL( parentEntry ); |
|
590 |
|
591 //Must set the sending state of Suspended messages to Waiting, otherwise they will not send |
|
592 while ( count-- ) |
|
593 { |
|
594 parentEntry->SetEntryL( aSelection[count] ); |
|
595 TMsvEntry entry( parentEntry->Entry()); |
|
596 switch ( entry.SendingState()) |
|
597 { |
|
598 case KMsvSendStateSuspended: |
|
599 case KMsvSendStateUponRequest: |
|
600 case KMsvSendStateScheduled: |
|
601 case KMsvSendStateResend: |
|
602 case KMsvSendStateFailed: |
|
603 entry.SetSendingState( KMsvSendStateWaiting ); |
|
604 parentEntry->ChangeL( entry ); |
|
605 break; |
|
606 default: |
|
607 break; |
|
608 } |
|
609 } |
|
610 |
|
611 parentEntry->SetEntryL( parentEntry->Entry().Parent()); |
|
612 |
|
613 // Do the copy/move |
|
614 CMsvOperation* op= aCopyOnly ? |
|
615 parentEntry->CopyL( aSelection, smsServiceEntry.Id(), aStatus ) : |
|
616 parentEntry->MoveL( aSelection, smsServiceEntry.Id(), aStatus ); |
|
617 |
|
618 CleanupStack::PopAndDestroy(); //parentEntry |
|
619 SMUMLOGGER_LEAVEFN(" CSmsMtmUi::CopyMoveToL"); |
|
620 return op; |
|
621 } |
|
622 |
|
623 // Copy/move from commands return KErrNotSupported because SMS messages are |
|
624 // automatically placed in the inbox after being received. Should therefore |
|
625 // be no need for this kind of thing. |
|
626 |
|
627 // --------------------------------------------------------- |
|
628 // CSmsMtmUi::CopyFromL |
|
629 // |
|
630 // --------------------------------------------------------- |
|
631 CMsvOperation* CSmsMtmUi::CopyFromL( |
|
632 const CMsvEntrySelection& /*aSelection*/, |
|
633 TMsvId /*aTargetId*/, |
|
634 TRequestStatus& /*aStatus*/ ) |
|
635 { |
|
636 SMUMLOGGER_WRITE(" CSmsMtmUi::CopyFromL"); |
|
637 User::Leave( KErrNotSupported ); |
|
638 return NULL; |
|
639 } |
|
640 |
|
641 // --------------------------------------------------------- |
|
642 // CSmsMtmUi::MoveFromL |
|
643 // |
|
644 // --------------------------------------------------------- |
|
645 CMsvOperation* CSmsMtmUi::MoveFromL( |
|
646 const CMsvEntrySelection& /*aSelection*/, |
|
647 TMsvId /*aTargetId*/, |
|
648 TRequestStatus& /*aStatus*/ ) |
|
649 { |
|
650 SMUMLOGGER_WRITE(" CSmsMtmUi::MoveFromL"); |
|
651 User::Leave( KErrNotSupported ); |
|
652 return NULL; |
|
653 } |
|
654 |
|
655 // --------------------------------------------------------- |
|
656 // CSmsMtmUi::QueryCapability |
|
657 // |
|
658 // --------------------------------------------------------- |
|
659 TInt CSmsMtmUi::QueryCapability( TUid aCapability, TInt& aResponse ) |
|
660 { |
|
661 SMUMLOGGER_WRITE(" CSmsMtmUi::QueryCapability"); |
|
662 switch ( aCapability.iUid ) |
|
663 { |
|
664 case KUidMsvMtmQuerySupportValidateService: |
|
665 case KUidMsvMtmUiQueryMessagingInitialisation: |
|
666 case KUidMsvMtmQueryFactorySettings: |
|
667 { |
|
668 aResponse=ETrue; |
|
669 return KErrNone; |
|
670 } |
|
671 default: |
|
672 return CBaseMtmUi::QueryCapability(aCapability, aResponse); |
|
673 } |
|
674 } |
|
675 |
|
676 // --------------------------------------------------------- |
|
677 // CSmsMtmUi::InvokeSyncFunctionL |
|
678 // |
|
679 // --------------------------------------------------------- |
|
680 void CSmsMtmUi::InvokeSyncFunctionL( |
|
681 TInt aFunctionId, |
|
682 const CMsvEntrySelection& aSelection, |
|
683 TDes8& aParameter ) |
|
684 { |
|
685 SMUMLOGGER_ENTERFN("CSmsMtmUi::InvokeSyncFunctionL"); |
|
686 switch ( aFunctionId ) |
|
687 { |
|
688 case KMtmUiFunctionMessageInfo: |
|
689 { |
|
690 ShowMessageInfoL( ); |
|
691 break; |
|
692 } |
|
693 case KMtmUiFunctionValidateService: |
|
694 { |
|
695 CheckAndEnsureSmsServiceOkL( ETrue, ETrue, ETrue ); |
|
696 |
|
697 // Suppose everything is ok, because function above didn't Leave. |
|
698 // return the result via aParameter as a TInt packaged into a TDes8 |
|
699 TPckgBuf<TInt> resultPackage( KErrNone ); |
|
700 aParameter.Copy( resultPackage ); |
|
701 break; |
|
702 } |
|
703 case KMtmUiFunctionSimDialog: |
|
704 { |
|
705 TInt simState = CheckSimStateL(); |
|
706 TInt phoneOnOff( ESAPhoneOn ); |
|
707 TInt err = RProperty::Get( KUidSystemCategory, KUidPhonePwrValue, phoneOnOff ); |
|
708 if( simState == ESimNotPresent ) // Sim removed |
|
709 { |
|
710 // Show note and exit |
|
711 HBufC* noteString = StringLoader::LoadLC( R_QTN_SU_NOTE_INSERT_SIM, iCoeEnv ); |
|
712 CAknInformationNote* note = new ( ELeave ) CAknInformationNote( ETrue ); |
|
713 note->ExecuteLD( *noteString ); |
|
714 CleanupStack::PopAndDestroy(); // noteString |
|
715 } |
|
716 else if( err || phoneOnOff == ESAPhoneOff ) |
|
717 { |
|
718 // Show note and exit |
|
719 HBufC* noteString = StringLoader::LoadLC( R_QTN_OFFLINE_NOT_POSSIBLE, iCoeEnv ); |
|
720 CAknInformationNote* note = new ( ELeave ) CAknInformationNote( ETrue ); |
|
721 note->ExecuteLD( *noteString ); |
|
722 CleanupStack::PopAndDestroy(); // noteString |
|
723 } |
|
724 else // Sim is present |
|
725 { |
|
726 // Check if the Sim access profile is on |
|
727 TInt btSapState( EBTSapNotConnected ); |
|
728 TInt err = RProperty::Get( |
|
729 KPSUidBluetoothSapConnectionState, |
|
730 KBTSapConnectionState, |
|
731 btSapState ); |
|
732 if ( err ) |
|
733 { // Reset |
|
734 btSapState = EBTSapNotConnected; |
|
735 } |
|
736 if( EBTSapNotConnected == btSapState ) // Normal case |
|
737 { |
|
738 CheckAndEnsureSmsServiceOkL( ETrue, ETrue, ETrue ); |
|
739 //launch sim-dialog |
|
740 iSimDlgPluginIntf->LaunchL(); |
|
741 } |
|
742 else // Sim Access Profile is on |
|
743 { |
|
744 // Show note and exit |
|
745 HBufC* noteString = StringLoader::LoadLC( R_QTN_OFFLINE_NOT_POSSIBLE_SAP, iCoeEnv ); |
|
746 CAknInformationNote* note = new ( ELeave ) CAknInformationNote( ETrue ); |
|
747 note->ExecuteLD( *noteString ); |
|
748 CleanupStack::PopAndDestroy(); // noteString |
|
749 } |
|
750 } |
|
751 break; |
|
752 } |
|
753 case KMtmUiMessagingInitialisation: |
|
754 case KMtmUiFunctionRestoreFactorySettings: |
|
755 { |
|
756 TMsvId serviceEntryId = KMsvNullIndexEntryId; |
|
757 serviceEntryId = CreateSmsServiceL( EFalse ); |
|
758 __ASSERT_DEBUG( serviceEntryId, Panic( ESmsuNotAServiceEntry )); |
|
759 CreateDefaultSettingsL( serviceEntryId, ( aFunctionId == KMtmUiMessagingInitialisation ) ); |
|
760 break; |
|
761 } |
|
762 default: |
|
763 CBaseMtmUi::InvokeSyncFunctionL( aFunctionId, aSelection, aParameter ); |
|
764 SMUMLOGGER_LEAVEFN("CSmsMtmUi::InvokeSyncFunctionL- DEFAULT"); |
|
765 return; |
|
766 } |
|
767 SMUMLOGGER_LEAVEFN("CSmsMtmUi::InvokeSyncFunctionL"); |
|
768 } |
|
769 |
|
770 // --------------------------------------------------------- |
|
771 // CSmsMtmUi::InvokeAsyncFunctionL |
|
772 // |
|
773 // --------------------------------------------------------- |
|
774 CMsvOperation* CSmsMtmUi::InvokeAsyncFunctionL( |
|
775 TInt aFunctionId, |
|
776 const CMsvEntrySelection& aSelection, |
|
777 TRequestStatus& aCompletionStatus, |
|
778 TDes8& aParameter ) |
|
779 { |
|
780 SMUMLOGGER_WRITE("CSmsMtmUi::InvokeAsyncFunctionL"); |
|
781 |
|
782 // Invoke asynchronous functions supported by client |
|
783 switch ( aFunctionId ) |
|
784 { |
|
785 case KMtmUiFunctionMessageInfo: |
|
786 { |
|
787 return ShowMessageInfoL( aCompletionStatus, aParameter ); |
|
788 } |
|
789 default: |
|
790 { |
|
791 return CBaseMtmUi::InvokeAsyncFunctionL( aFunctionId, aSelection, aCompletionStatus, aParameter ); |
|
792 } |
|
793 } |
|
794 } |
|
795 |
|
796 // --------------------------------------------------------- |
|
797 // CSmsMtmUi::DisplayProgressSummary |
|
798 // |
|
799 // --------------------------------------------------------- |
|
800 TInt CSmsMtmUi::DisplayProgressSummary( const TDesC8& aProgress ) const |
|
801 { |
|
802 SMUMLOGGER_ENTERFN("CSmsMtmUi::DisplayProgressSummary"); |
|
803 |
|
804 // Check are we surely dealing with sms progress |
|
805 const TInt progressSize = aProgress.Size(); |
|
806 |
|
807 if ( progressSize == sizeof( TSmsSmumProgress )) |
|
808 {// yes, smum-progress |
|
809 TSmsSmumProgressBuf smumProgressPack; |
|
810 smumProgressPack.Copy( aProgress ); |
|
811 TSmsSmumProgress smumProgress( smumProgressPack()); |
|
812 |
|
813 // Show "not supported"-notes if msg cannot be shown |
|
814 if ( smumProgress.iError == KErrNotSupported && |
|
815 smumProgress.iType == TSmsSmumProgress::ESmsSmumSmsOpening ) |
|
816 { |
|
817 TRAP_IGNORE |
|
818 ( |
|
819 HBufC* string = StringLoader::LoadLC( R_QTN_MCE_INFO_MESSAGE_NOT_OPENED, iCoeEnv ); |
|
820 CAknInformationNote* note = new ( ELeave ) CAknInformationNote( ETrue ); |
|
821 note->ExecuteLD( *string ); |
|
822 CleanupStack::PopAndDestroy(); // string |
|
823 ) |
|
824 } |
|
825 } |
|
826 else if ( progressSize == sizeof( TSmsProgress )) |
|
827 {// yes, sms-progress |
|
828 TSmsProgressBuf progressPack; |
|
829 progressPack.Copy( aProgress ); |
|
830 TSmsProgress progress ( progressPack()); |
|
831 |
|
832 if ( progress.iError && ( progress.iType != TSmsProgress::ESmsProgressTypeSending )) |
|
833 { |
|
834 TRAP_IGNORE( |
|
835 const TDesC& errorTxt = iErrorResolver->ResolveErrorString( progress.iError ); |
|
836 CAknErrorNote* note = new ( ELeave ) CAknErrorNote(); |
|
837 note->ExecuteLD( errorTxt ); ); |
|
838 } |
|
839 } |
|
840 else |
|
841 {// not sms progress, don't care |
|
842 return KErrCancel; |
|
843 } |
|
844 |
|
845 SMUMLOGGER_LEAVEFN("CSmsMtmUi::DisplayProgressSummary - no err"); |
|
846 return KErrNone; |
|
847 } |
|
848 |
|
849 // --------------------------------------------------------- |
|
850 // CSmsMtmUi::LaunchSettingsDialogL |
|
851 // |
|
852 // --------------------------------------------------------- |
|
853 CMsvOperation* CSmsMtmUi::LaunchSettingsDialogL( TRequestStatus& aStatus ) |
|
854 { |
|
855 SMUMLOGGER_ENTERFN("CSmsMtmUi::LaunchSettingsDialogL"); |
|
856 __ASSERT_DEBUG( |
|
857 BaseMtm().Entry().Entry().iMtm == Type(), Panic( ESmsuWrongMtmType )); |
|
858 __ASSERT_DEBUG( |
|
859 BaseMtm().Entry().Entry().iType.iUid == |
|
860 KUidMsvServiceEntryValue, Panic( ESmsuNotAServiceEntry )); |
|
861 TInt exitCode = ESmumSmsSettingsInitialvalue; |
|
862 TInt err = KErrNone; |
|
863 // load settings |
|
864 CSmsSettings* smsSettings = CSmsSettings::NewLC(); |
|
865 CSmsAccount* smsAccount = CSmsAccount::NewLC(); |
|
866 TRAPD( error, smsAccount->LoadSettingsL( *smsSettings ) ); |
|
867 if ( error == KErrNone ) |
|
868 { |
|
869 // Launch the service settings dialog on the current entry |
|
870 TInt notUsed( 0 ); |
|
871 CSmumMainSettingsDialog* mainSettingsDialog = CSmumMainSettingsDialog::NewL( |
|
872 *smsSettings, ESmumMainSmsSettings, exitCode, notUsed ); |
|
873 mainSettingsDialog->ExecuteLD( R_MAIN_SETTINGS_DIALOG ); |
|
874 // Try to save, continue anyway |
|
875 TRAP( err, smsAccount->SaveSettingsL( *smsSettings ) ); |
|
876 } |
|
877 else |
|
878 { |
|
879 User::Leave( error ); |
|
880 } |
|
881 CleanupStack::PopAndDestroy( 2 ); // smsSettings, smsAccount |
|
882 // Check if user wants to exit to idle = ESmumSmsSettingsMenuExit |
|
883 // (...in system exits system keeps closing apps one by one until all down, not done here...) |
|
884 if ( exitCode == ESmumSmsSettingsMenuExit ) |
|
885 { // Exiting... |
|
886 err = EEikCmdExit; |
|
887 } |
|
888 |
|
889 SMUMLOGGER_LEAVEFN("CSmsMtmUi::LaunchSettingsDialogL"); |
|
890 |
|
891 return CMsvCompletedOperation::NewL( |
|
892 Session(), |
|
893 Type(), |
|
894 KNullDesC8, |
|
895 KMsvLocalServiceIndexEntryId, |
|
896 aStatus, |
|
897 err); |
|
898 } |
|
899 |
|
900 // --------------------------------------------------------- |
|
901 // CSmsMtmUi::LaunchEditorApplicationL |
|
902 // |
|
903 // --------------------------------------------------------- |
|
904 CMsvOperation* CSmsMtmUi::LaunchEditorApplicationL( |
|
905 TRequestStatus& aStatus, |
|
906 CMsvSession& aSession, |
|
907 TEditorType aEditorType, |
|
908 TMsvId aParentId ) |
|
909 { |
|
910 SMUMLOGGER_ENTERFN("CSmsMtmUi::LaunchEditorApplicationL"); |
|
911 |
|
912 TEditorParameters temp; |
|
913 temp.iFlags &=~ ( EMtmUiFlagEditorPreferEmbedded | EMtmUiFlagEditorNoWaitForExit ); |
|
914 temp.iFlags |= ( Preferences() & EMtmUiFlagEditorPreferEmbedded ? EMsgLaunchEditorEmbedded : 0 ); |
|
915 temp.iFlags |= ( Preferences() & EMtmUiFlagEditorNoWaitForExit ? 0 : EMsgLaunchEditorThenWait ); |
|
916 |
|
917 if ( iBaseMtm.HasContext()) |
|
918 { |
|
919 temp.iId = iBaseMtm.Entry().EntryId(); |
|
920 } |
|
921 |
|
922 switch( aEditorType ) |
|
923 { |
|
924 case EReadOnly: |
|
925 temp.iFlags |= EMsgReadOnly; |
|
926 break; |
|
927 case ECreateNewMessage: |
|
928 temp.iFlags |= EMsgCreateNewMessage ; |
|
929 temp.iId = aParentId; |
|
930 break; |
|
931 case EEditExisting: |
|
932 default: |
|
933 break; |
|
934 } |
|
935 SMUMLOGGER_LEAVEFN("CSmsMtmUi::LaunchEditorApplicationL"); |
|
936 |
|
937 return MsgEditorLauncher::LaunchEditorApplicationL( |
|
938 aSession, |
|
939 Type(), |
|
940 aStatus, |
|
941 temp, |
|
942 KNullDesC, |
|
943 KNullDesC8 ); |
|
944 } |
|
945 |
|
946 // --------------------------------------------------------- |
|
947 // CSmsMtmUi::GetResourceFileName |
|
948 // |
|
949 // --------------------------------------------------------- |
|
950 void CSmsMtmUi::GetResourceFileName( TFileName& aFileName ) const |
|
951 { |
|
952 aFileName = KSmsuResourceFile; |
|
953 } |
|
954 |
|
955 // --------------------------------------------------------- |
|
956 // CSmsMtmUi::CheckEntry |
|
957 // |
|
958 // --------------------------------------------------------- |
|
959 TBool CSmsMtmUi::CheckEntry( const TMsvEntry& aEntry ) const |
|
960 { |
|
961 // Ensures that the TMsvEntry is a suitable candidate for treatment by |
|
962 // this MtmUi layer. |
|
963 return aEntry.iType == KUidMsvMessageEntry && aEntry.iMtm == Type(); |
|
964 } |
|
965 |
|
966 // --------------------------------------------------------- |
|
967 // CSmsMtmUi::CreateSmsServiceL |
|
968 // |
|
969 // --------------------------------------------------------- |
|
970 TMsvId CSmsMtmUi::CreateSmsServiceL( TBool aNoServiceNoCheckNeeded ) |
|
971 { |
|
972 SMUMLOGGER_ENTERFN("CSmsMtmUi::CreateSmsServiceL"); |
|
973 // Keep shared data uptodate |
|
974 SetSharedDataL( |
|
975 KSmumSmsStatus, |
|
976 1 );// sms initialisation in progress |
|
977 |
|
978 // Check for service if needed |
|
979 TMsvId serviceEntryId = KMsvNullIndexEntryId; |
|
980 TInt err = KErrNone; |
|
981 if ( !aNoServiceNoCheckNeeded ) |
|
982 { |
|
983 TRAP( err, serviceEntryId = ServiceIdL()); |
|
984 } |
|
985 |
|
986 // If no service, create one |
|
987 if ( err == KErrNotFound || aNoServiceNoCheckNeeded ) |
|
988 { |
|
989 TMsvEntry entry; |
|
990 entry.iMtm = KUidMsgTypeSMS; |
|
991 entry.iType = KUidMsvServiceEntry; |
|
992 entry.SetReadOnly( EFalse ); |
|
993 entry.SetVisible( EFalse ); |
|
994 entry.iDate.HomeTime(); |
|
995 entry.iDetails.Set( KSmumSmsService ); |
|
996 CMsvEntry* root = Session().GetEntryL( KMsvRootIndexEntryId ); |
|
997 CleanupStack::PushL( root ); |
|
998 // In case no root store, create one... |
|
999 if ( !root->HasStoreL() ) |
|
1000 { |
|
1001 // --- The entry does not have a store. EditStoreL() will create one --- |
|
1002 CMsvStore* store = root->EditStoreL(); |
|
1003 CleanupStack::PushL( store ); |
|
1004 store->CommitL(); |
|
1005 CleanupStack::PopAndDestroy(); // store |
|
1006 store = NULL; // destroyed |
|
1007 } |
|
1008 root->CreateL( entry ); |
|
1009 CleanupStack::PopAndDestroy(); // root |
|
1010 BaseMtm().SwitchCurrentEntryL( entry.Id()); |
|
1011 serviceEntryId = entry.Id(); |
|
1012 iNewSmsSettings = ETrue; |
|
1013 } |
|
1014 else |
|
1015 { |
|
1016 User::LeaveIfError( err ); |
|
1017 } |
|
1018 |
|
1019 SMUMLOGGER_LEAVEFN("CSmsMtmUi::CreateSmsServiceL"); |
|
1020 return serviceEntryId; |
|
1021 } |
|
1022 |
|
1023 // --------------------------------------------------------- |
|
1024 // CSmsMtmUi::ServiceIdL |
|
1025 // |
|
1026 // --------------------------------------------------------- |
|
1027 TMsvId CSmsMtmUi::ServiceIdL() |
|
1028 { |
|
1029 SMUMLOGGER_ENTERFN("CSmsMtmUi::ServiceIdL"); |
|
1030 TMsvId id = KMsvNullIndexEntryId; |
|
1031 CMsvEntry* root = Session().GetEntryL(KMsvRootIndexEntryId); |
|
1032 CleanupStack::PushL(root); |
|
1033 TSmsUtilities::ServiceIdL(*root, id); |
|
1034 CleanupStack::PopAndDestroy(root); |
|
1035 |
|
1036 SMUMLOGGER_LEAVEFN("CSmsMtmUi::ServiceIdL"); |
|
1037 return id; |
|
1038 } |
|
1039 |
|
1040 // --------------------------------------------------------- |
|
1041 // CSmsMtmUi::ReadDefaultSettingsFromSharedDataL |
|
1042 // |
|
1043 // --------------------------------------------------------- |
|
1044 void CSmsMtmUi::ReadDefaultSettingsFromSharedDataL( CSmsSettings* aServiceSettings ) |
|
1045 { |
|
1046 SMUMLOGGER_ENTERFN("CSmsMtmUi::ReadDefaultSettingsFromSharedDataL"); |
|
1047 if ( iCenRepSession ) |
|
1048 { |
|
1049 TInt readedSetting; |
|
1050 // Delivery report |
|
1051 if ( iCenRepSession->Get( KSmumDeliveryReport, readedSetting ) != KErrNone ) |
|
1052 { |
|
1053 readedSetting = KDefDeliveryReport; |
|
1054 } |
|
1055 aServiceSettings->SetDeliveryReport( readedSetting ); |
|
1056 |
|
1057 // Validity period |
|
1058 if ( iCenRepSession->Get( KSmumValidityPeriod, readedSetting ) != KErrNone ) |
|
1059 { |
|
1060 readedSetting = KDefValidityPeriod; |
|
1061 } |
|
1062 aServiceSettings->SetValidityPeriod( readedSetting ); |
|
1063 |
|
1064 // Message conversion |
|
1065 if ( iCenRepSession->Get( KSmumMessageConversion, readedSetting ) != KErrNone ) |
|
1066 { |
|
1067 readedSetting = KDefMessageConversion; |
|
1068 } |
|
1069 aServiceSettings->SetMessageConversion(( TSmsPIDConversion ) readedSetting ); |
|
1070 |
|
1071 // Preferred connection |
|
1072 if ( iCenRepSession->Get( KSmumPreferredConnection, readedSetting ) != KErrNone ) |
|
1073 { |
|
1074 readedSetting = KDefPreferredConnection; |
|
1075 } |
|
1076 aServiceSettings->SetSmsBearer( ( CSmsSettings::TMobileSmsBearer ) readedSetting ); |
|
1077 |
|
1078 // Reply via same centre |
|
1079 if(iCenRepSession->Get( KSmumRemoveReplyViaSameCentre, readedSetting ) != KErrNone ) |
|
1080 { |
|
1081 if( iCenRepSession->Get( KSmumReplyViaSameCentre, readedSetting ) != KErrNone ) |
|
1082 { |
|
1083 readedSetting = KDefReplyViaSameCentre; |
|
1084 } |
|
1085 } |
|
1086 else |
|
1087 { |
|
1088 if(!readedSetting) |
|
1089 { |
|
1090 if( iCenRepSession->Get( KSmumReplyViaSameCentre, readedSetting ) != KErrNone ) |
|
1091 { |
|
1092 readedSetting = KDefReplyViaSameCentre; |
|
1093 } |
|
1094 } |
|
1095 } |
|
1096 |
|
1097 aServiceSettings->SetReplyPath( readedSetting ); |
|
1098 |
|
1099 } |
|
1100 SMUMLOGGER_LEAVEFN("CSmsMtmUi::ReadDefaultSettingsFromSharedDataL"); |
|
1101 } |
|
1102 |
|
1103 // --------------------------------------------------------- |
|
1104 // CSmsMtmUi::CopySCentresFromOldToNewSettingsL |
|
1105 // |
|
1106 // --------------------------------------------------------- |
|
1107 void CSmsMtmUi::CopySCentresFromOldToNewSettingsL(CSmsSettings* aServiceSettings) |
|
1108 { |
|
1109 SMUMLOGGER_ENTERFN("CSmsMtmUi::CopySCentresFromOldToNewSettingsL"); |
|
1110 // Copy Service centres from old setting to new settings |
|
1111 CSmsSettings* oldServiceSettings = &SmsClientMtm().ServiceSettings(); |
|
1112 TInt serviceCentres = oldServiceSettings->ServiceCenterCount(); |
|
1113 // Do copying, if we have something to copy |
|
1114 if ( serviceCentres ) |
|
1115 { |
|
1116 for ( TInt loop=0; loop < serviceCentres; loop++ ) |
|
1117 { |
|
1118 aServiceSettings->AddServiceCenterL( |
|
1119 oldServiceSettings->GetServiceCenter( loop ).Name(), |
|
1120 oldServiceSettings->GetServiceCenter( loop ).Address()); |
|
1121 } |
|
1122 aServiceSettings->SetDefaultServiceCenter( |
|
1123 oldServiceSettings->DefaultServiceCenter()); |
|
1124 } |
|
1125 SMUMLOGGER_LEAVEFN("CSmsMtmUi::CopySCentresFromOldToNewSettingsL"); |
|
1126 } |
|
1127 |
|
1128 // --------------------------------------------------------- |
|
1129 // CSmsMtmUi::CreateDefaultSettingsL |
|
1130 // |
|
1131 // --------------------------------------------------------- |
|
1132 void CSmsMtmUi::CreateDefaultSettingsL( TMsvId aServiceId, TBool aMailInit ) |
|
1133 { |
|
1134 SMUMLOGGER_ENTERFN("CSmsMtmUi::CreateDefaultSettingsL"); |
|
1135 CSmsSettings* serviceSettings = CSmsSettings::NewL(); |
|
1136 CleanupStack::PushL( serviceSettings ); |
|
1137 CSmsAccount* smsAccount = CSmsAccount::NewLC(); |
|
1138 // Read the RFS related settings from shared data. |
|
1139 TInt originalCount = 0; |
|
1140 if ( aMailInit ) |
|
1141 { |
|
1142 smsAccount->LoadSettingsL( *serviceSettings ); |
|
1143 originalCount = serviceSettings->ServiceCenterCount(); |
|
1144 } |
|
1145 |
|
1146 if ( !originalCount ) |
|
1147 { |
|
1148 ReadDefaultSettingsFromSharedDataL( serviceSettings ); |
|
1149 |
|
1150 // Rest of the sms settings, which are fixed. |
|
1151 serviceSettings->SetValidityPeriodFormat( TSmsFirstOctet::ESmsVPFInteger ); //relative |
|
1152 serviceSettings->SetDelivery( ESmsDeliveryImmediately ); |
|
1153 serviceSettings->SetCanConcatenate( ETrue ); |
|
1154 serviceSettings->SetStatusReportHandling( CSmsSettings::EMoveReportToInboxInvisible ); |
|
1155 serviceSettings->SetSpecialMessageHandling( CSmsSettings::EMoveReportToInboxVisible ); |
|
1156 serviceSettings->SetRejectDuplicate( ETrue ); |
|
1157 TInt descriptionLength = KSmsDescriptionLength; |
|
1158 // Read the value for description length |
|
1159 CRepository* repository = CRepository::NewLC( KCRUidMuiuSettings ); |
|
1160 if (KErrNone == repository->Get(KMuiuDescriptionLength, descriptionLength)) |
|
1161 { |
|
1162 //Make sure value is not zero |
|
1163 descriptionLength = Max(descriptionLength, KSmsDescriptionLength); |
|
1164 } |
|
1165 CleanupStack::PopAndDestroy(); // repository |
|
1166 serviceSettings->SetDescriptionLength( descriptionLength ); |
|
1167 // Set saving to commsdb |
|
1168 serviceSettings->SetCommDbAction( CSmsSettings::EStoreToCommDb ); |
|
1169 serviceSettings->SetSmsBearerAction( CSmsSettings::EStoreToCommDb ); |
|
1170 |
|
1171 // If we're refreshing old settings (RFS:normal level) |
|
1172 // then copy the scentres from old to new. |
|
1173 if ( !iNewSmsSettings ) |
|
1174 { |
|
1175 CopySCentresFromOldToNewSettingsL( serviceSettings ); |
|
1176 } |
|
1177 } |
|
1178 else |
|
1179 { |
|
1180 iNewSmsSettings = EFalse; |
|
1181 } |
|
1182 |
|
1183 // Save settings |
|
1184 CMsvEntry* service = Session().GetEntryL( aServiceId ); |
|
1185 CleanupStack::PushL( service ); |
|
1186 CMsvStore* msvstore = service->EditStoreL(); |
|
1187 CleanupStack::PushL( msvstore ); |
|
1188 |
|
1189 TInt maxTries( 5 ); |
|
1190 TBool done( EFalse ); |
|
1191 while ( maxTries && !done ) |
|
1192 { |
|
1193 TRAPD( err, smsAccount->SaveSettingsL( *serviceSettings ) ); |
|
1194 if ( err == KErrNone ) |
|
1195 { |
|
1196 done = ETrue; |
|
1197 } |
|
1198 else if ( err == KErrLocked ) |
|
1199 { |
|
1200 // Some other thread has locked (probably the CommDb) repository. |
|
1201 // Wait a while and retry. |
|
1202 User::After( 100000 ); // 0.1 seconds |
|
1203 maxTries--; |
|
1204 } |
|
1205 else |
|
1206 { |
|
1207 User::Leave( err ); |
|
1208 } |
|
1209 } |
|
1210 |
|
1211 msvstore->CommitL(); |
|
1212 CleanupStack::PopAndDestroy( 2 ); // msvstore, service |
|
1213 |
|
1214 // Keep shared data uptodate |
|
1215 if ( iNewSmsSettings ) |
|
1216 { // Let's try reading SCs from SIM |
|
1217 SetSharedDataL( |
|
1218 KSmumSmsStatus, |
|
1219 KInitializationReadSim ); // notify NCN to read SCs from SIM |
|
1220 iNewSmsSettings = EFalse; |
|
1221 } |
|
1222 else |
|
1223 { |
|
1224 SetSharedDataL( |
|
1225 KSmumSmsStatus, |
|
1226 KInitializationReady ); // sms initialisation ready |
|
1227 } |
|
1228 CleanupStack::PopAndDestroy( 2 ); // serviceSettings, smsAccount |
|
1229 SMUMLOGGER_LEAVEFN("CSmsMtmUi::CreateDefaultSettingsL"); |
|
1230 } |
|
1231 |
|
1232 // --------------------------------------------------------- |
|
1233 // CSmsMtmUi::ShowMessageInfoL |
|
1234 // |
|
1235 // --------------------------------------------------------- |
|
1236 void CSmsMtmUi::ShowMessageInfoL() const |
|
1237 { |
|
1238 SMUMLOGGER_WRITE("CSmsMtmUi::ShowMessageInfoL"); |
|
1239 ConstructAndShowInfoDialogL(); |
|
1240 } |
|
1241 |
|
1242 // --------------------------------------------------------- |
|
1243 // CSmsMtmUi::ShowMessageInfoL |
|
1244 // |
|
1245 // --------------------------------------------------------- |
|
1246 CMsvOperation* CSmsMtmUi::ShowMessageInfoL(TRequestStatus& aCompletionStatus, TDes8& /*aParameter*/) const |
|
1247 { |
|
1248 SMUMLOGGER_WRITE("CSmsMtmUi::ShowMessageInfoL(...)"); |
|
1249 ConstructAndShowInfoDialogL(); |
|
1250 return CMsvCompletedOperation::NewL( |
|
1251 Session(), KUidMsvLocalServiceMtm, KNullDesC8, |
|
1252 KMsvLocalServiceIndexEntryId, aCompletionStatus, KErrNone ); |
|
1253 } |
|
1254 |
|
1255 // --------------------------------------------------------- |
|
1256 // CSmsMtmUi::ConstructAndShowInfoDialogL |
|
1257 // |
|
1258 // --------------------------------------------------------- |
|
1259 void CSmsMtmUi::ConstructAndShowInfoDialogL() const |
|
1260 { |
|
1261 SMUMLOGGER_ENTERFN("CSmsMtmUi::ConstructAndShowInfoDialogL"); |
|
1262 CSmsClientMtm& smsClientMtm = SmsClientMtm(); |
|
1263 smsClientMtm.LoadMessageL(); |
|
1264 CSmsHeader& smsHeader = smsClientMtm.SmsHeader(); |
|
1265 TMsgInfoMessageInfoData infoData; |
|
1266 TBool emailMessage( EFalse ); |
|
1267 |
|
1268 //Get info if local timestamping needed for SMS |
|
1269 CRepository* cenRep = CRepository::NewLC( KCRUidMuiuVariation ); |
|
1270 TBool useLocalSmsTimeStamp = EFalse; |
|
1271 TBool useChineseTimezoneOverriding = EFalse; |
|
1272 TInt featureFlags = 0; |
|
1273 |
|
1274 cenRep->Get(KMuiuSmsFeatures, featureFlags); |
|
1275 CleanupStack::PopAndDestroy(cenRep); |
|
1276 useLocalSmsTimeStamp = (featureFlags & KSmsFeatureIdUseLocalTimeStamp); |
|
1277 useChineseTimezoneOverriding = (featureFlags & KSmsFeatureIdOverrideChineseTimeZone); |
|
1278 |
|
1279 //Make sure only one flag is enabled |
|
1280 if( useChineseTimezoneOverriding ) |
|
1281 { |
|
1282 useLocalSmsTimeStamp = EFalse; |
|
1283 } |
|
1284 |
|
1285 // Check if we are dealing with E-mail sms message |
|
1286 // We use TP-PID as the only validation rule |
|
1287 CSmsPDU& pdu = smsHeader.Message().SmsPDU(); |
|
1288 if( pdu.ProtocolIdentifierPresent() ) |
|
1289 { |
|
1290 if( pdu.PIDType() == TSmsProtocolIdentifier::ESmsPIDTelematicInterworking && |
|
1291 pdu.TelematicDeviceIndicator() == TSmsProtocolIdentifier::ESmsTelematicDevice && |
|
1292 pdu.TelematicDeviceType() == TSmsProtocolIdentifier::ESmsInternetElectronicMail ) |
|
1293 { |
|
1294 emailMessage = ETrue; |
|
1295 } |
|
1296 } |
|
1297 const TMsvEntry tentry = smsClientMtm.Entry().Entry(); |
|
1298 |
|
1299 // Subject |
|
1300 HBufC* subject = NULL; |
|
1301 // Set the subject text |
|
1302 GetSubjectTextL( tentry, smsClientMtm, subject, emailMessage ); |
|
1303 CleanupStack::PushL( subject ); |
|
1304 infoData.iSubject.Set( *subject ); |
|
1305 |
|
1306 // Holds the message info text for both sms and bio messages |
|
1307 HBufC* messageType = NULL; |
|
1308 if( tentry.iBioType ) |
|
1309 { //this is a bio message which has been created on the phone |
|
1310 TInt resourceId = GetBioResourceId( tentry ); |
|
1311 if ( resourceId != KErrNotFound ) |
|
1312 { |
|
1313 messageType = iEikonEnv->AllocReadResourceLC( resourceId ); |
|
1314 infoData.iType.Set( *messageType ); |
|
1315 } |
|
1316 else |
|
1317 { |
|
1318 infoData.iType.Set( tentry.iDescription ); |
|
1319 } |
|
1320 } |
|
1321 else |
|
1322 { |
|
1323 //sms type |
|
1324 messageType = StringLoader::LoadLC( R_QTN_SMS_MINFO_TYPE_SMS, iCoeEnv ); |
|
1325 infoData.iType.Set( *messageType ); |
|
1326 } |
|
1327 |
|
1328 //sms date and time |
|
1329 TInt type = smsHeader.Type(); |
|
1330 TTime smsDate; |
|
1331 |
|
1332 TInt notUsed = 0; |
|
1333 if ( CSmsPDU::ESmsDeliver == type || CSmsPDU::ESmsStatusReport == type ) |
|
1334 { |
|
1335 //UTC time or local time |
|
1336 if( useLocalSmsTimeStamp ) |
|
1337 { |
|
1338 smsDate = tentry.iDate; |
|
1339 } |
|
1340 else if( useChineseTimezoneOverriding ) |
|
1341 { |
|
1342 //get Service Center address and recipient's address. Check if chinese countrycode |
|
1343 //is found or if national number |
|
1344 if ( (pdu.ServiceCenterAddress()).Find( KSmumChinaCountryCode ) != KErrNotFound || |
|
1345 smsHeader.FromAddress().Find( KSmumChinaCountryCode ) != KErrNotFound || |
|
1346 ( pdu.ServiceCenterAddress().Find( KSmumInternationalPrefix ) == KErrNotFound && |
|
1347 smsHeader.FromAddress().Find( KSmumInternationalPrefix ) == KErrNotFound ) ) |
|
1348 { |
|
1349 CSmsDeliver& deliv = smsHeader.Deliver(); |
|
1350 |
|
1351 TTime smsstackSCTime; // In UTC time |
|
1352 TTime origSCTime; // In local time |
|
1353 TTime utcSCTime; |
|
1354 |
|
1355 TInt origSCQuarterHours; |
|
1356 deliv.ServiceCenterTimeStamp( smsstackSCTime, origSCQuarterHours ); |
|
1357 |
|
1358 //Calculate orig (local) time from SMSStack's SC-time |
|
1359 TInt offsetInHours = origSCQuarterHours * CSmsMessage::E15MinutesRepresentedInSeconds; |
|
1360 TTimeIntervalSeconds offsetFromUTCToLocal( offsetInHours ); |
|
1361 origSCTime = smsstackSCTime + offsetFromUTCToLocal; |
|
1362 |
|
1363 //subtract 8 eight hours ( = Chinese timezone offset ) |
|
1364 TTimeIntervalSeconds chineseOffset( KSmumChineseOffset * 60 * 60 ); |
|
1365 utcSCTime = origSCTime - chineseOffset; |
|
1366 |
|
1367 smsDate = utcSCTime; |
|
1368 } |
|
1369 else |
|
1370 {//make sure smsDate is not empty |
|
1371 smsHeader.Deliver().ServiceCenterTimeStamp( smsDate, notUsed ); |
|
1372 } |
|
1373 } |
|
1374 else |
|
1375 { |
|
1376 smsHeader.Deliver().ServiceCenterTimeStamp( smsDate, notUsed ); |
|
1377 } |
|
1378 |
|
1379 } |
|
1380 else |
|
1381 { |
|
1382 // message entry time is in UTC time |
|
1383 smsDate = tentry.iDate; |
|
1384 } |
|
1385 |
|
1386 infoData.iDateTime = smsDate; |
|
1387 // |
|
1388 // Recipient info |
|
1389 if ( CSmsPDU::ESmsDeliver == type ) |
|
1390 { // want to show 'viewer' type fields |
|
1391 //sms 'from' field |
|
1392 HBufC* senderNumber = smsHeader.FromAddress().AllocLC(); |
|
1393 HBufC* fromText = HBufC::NewLC( |
|
1394 tentry.iDetails.Length() |
|
1395 + senderNumber->Length() |
|
1396 // for the chars: '<' '>' 2 x KSmumLRMarker |
|
1397 + KSmumAdditionalCharsStringLength ); |
|
1398 |
|
1399 if ( !emailMessage ) // TP-PID sms |
|
1400 { |
|
1401 // Do we have alias? |
|
1402 if ( senderNumber->Compare( tentry.iDetails )) |
|
1403 { // yes |
|
1404 TPtr fromTextPtr = fromText->Des(); |
|
1405 fromTextPtr.Append( tentry.iDetails ); |
|
1406 fromTextPtr.Append( KSmumSpace ); |
|
1407 fromTextPtr.Append( KSmumLRMarker ); |
|
1408 fromTextPtr.Append( KSmumCharLeftAddressIterator ); |
|
1409 fromTextPtr.Append( *senderNumber ); |
|
1410 fromTextPtr.Append( KSmumCharRightAddressIterator ); |
|
1411 fromTextPtr.Append( KSmumLRMarker ); |
|
1412 infoData.iFrom.Set( *fromText ); |
|
1413 } |
|
1414 else |
|
1415 { // no |
|
1416 infoData.iFrom.Set( *senderNumber ); |
|
1417 } |
|
1418 } |
|
1419 else |
|
1420 { // TP-PID set for interworking with email |
|
1421 TPtr fromTextPtr = fromText->Des(); |
|
1422 fromTextPtr.Append( tentry.iDetails ); |
|
1423 infoData.iFrom.Set( *fromText ); |
|
1424 } |
|
1425 |
|
1426 CMsgInfoMessageInfoDialog* infoDialog = CMsgInfoMessageInfoDialog::NewL(); |
|
1427 infoDialog->ExecuteLD( infoData, CMsgInfoMessageInfoDialog::ESmsViewer ); |
|
1428 |
|
1429 CleanupStack::PopAndDestroy( 2 ); // senderNumber, fromText |
|
1430 } |
|
1431 else |
|
1432 { //editType is ETrue, want to show 'editor' type fields |
|
1433 //sms 'to:' list |
|
1434 HBufC* toList = TurnRecipientsArrayIntoStringLC( |
|
1435 smsHeader.Recipients(), |
|
1436 emailMessage ); |
|
1437 |
|
1438 infoData.iTo.Set( *toList ); |
|
1439 |
|
1440 CMsgInfoMessageInfoDialog* infoDialog = CMsgInfoMessageInfoDialog::NewL(); |
|
1441 if( tentry.iBioType ) |
|
1442 { |
|
1443 infoDialog->ExecuteLD( infoData, CMsgInfoMessageInfoDialog::EBiosEditor ); |
|
1444 } |
|
1445 else |
|
1446 { |
|
1447 infoDialog->ExecuteLD( infoData, CMsgInfoMessageInfoDialog::ESmsEditor ); |
|
1448 } |
|
1449 |
|
1450 CleanupStack::PopAndDestroy(toList); |
|
1451 } |
|
1452 if ( messageType ) |
|
1453 { |
|
1454 CleanupStack::PopAndDestroy( messageType ); |
|
1455 } |
|
1456 if ( subject ) |
|
1457 { |
|
1458 CleanupStack::PopAndDestroy( subject ); |
|
1459 } |
|
1460 SMUMLOGGER_LEAVEFN("CSmsMtmUi::ConstructAndShowInfoDialogL"); |
|
1461 } |
|
1462 |
|
1463 // --------------------------------------------------------- |
|
1464 // CSmsMtmUi::ExtractTitleFromGMSBodyL |
|
1465 // |
|
1466 // --------------------------------------------------------- |
|
1467 HBufC* CSmsMtmUi::ExtractTitleFromGMSBodyL( const CRichText& aBody, TInt aMaxLength ) const |
|
1468 { |
|
1469 SMUMLOGGER_ENTERFN("CSmsMtmUi::ExtractTitleFromGMSBodyL"); |
|
1470 CGmsModel* model = CGmsModel::NewL(CCoeEnv::Static()->FsSession(), KErrCorrupt); |
|
1471 CleanupStack::PushL(model); |
|
1472 model->ImportGMSL(aBody); |
|
1473 HBufC* text = model->TextAsHBufC16LC(); |
|
1474 HBufC* result = NULL; |
|
1475 if (text->Length() <= aMaxLength) |
|
1476 { |
|
1477 result = text->AllocL(); |
|
1478 } |
|
1479 else |
|
1480 { |
|
1481 // length is greater than max |
|
1482 result = text->Left(aMaxLength).AllocL(); |
|
1483 } |
|
1484 CleanupStack::PopAndDestroy(2, model); // text model |
|
1485 SMUMLOGGER_LEAVEFN("CSmsMtmUi::ExtractTitleFromGMSBodyL"); |
|
1486 return result; |
|
1487 } |
|
1488 |
|
1489 // --------------------------------------------------------- |
|
1490 // CSmsMtmUi::TurnRecipientsArrayIntoStringLC |
|
1491 // |
|
1492 // --------------------------------------------------------- |
|
1493 HBufC* CSmsMtmUi::TurnRecipientsArrayIntoStringLC( |
|
1494 const CArrayPtrFlat<CSmsNumber>& aRecip, |
|
1495 const TBool aEmailMessage ) const |
|
1496 { |
|
1497 //calc length of string needed |
|
1498 SMUMLOGGER_ENTERFN("CSmsMtmUi::TurnRecipientsArrayIntoStringLC"); |
|
1499 TInt stringLength = 0; |
|
1500 TInt index; |
|
1501 HBufC* toList = NULL; |
|
1502 if ( !aEmailMessage ) |
|
1503 { |
|
1504 TInt count = aRecip.Count(); |
|
1505 for( index = 0; index < count; index++ ) |
|
1506 { |
|
1507 stringLength += aRecip[index]->Name().Length(); |
|
1508 stringLength += aRecip[index]->Address().Length(); |
|
1509 // for the 7 chars: '<' '>' ', ' 2 x KSmumLRMarker, ' ' |
|
1510 stringLength += KSmumAdditionalCharsStringLength; |
|
1511 } |
|
1512 //construct string |
|
1513 toList = HBufC::NewLC( stringLength ); |
|
1514 TPtr toListPtr = toList->Des(); |
|
1515 // Loop through recipients |
|
1516 for( index=0; index < count; index++ ) |
|
1517 { |
|
1518 TPtrC name = aRecip[index]->Name(); |
|
1519 TPtrC number = aRecip[index]->Address(); |
|
1520 if( name.Length() ) |
|
1521 { |
|
1522 toListPtr.Append( name ); |
|
1523 toListPtr.Append( KSmumSpace ); |
|
1524 toListPtr.Append( KSmumLRMarker ); |
|
1525 toListPtr.Append( KSmumCharLeftAddressIterator ); |
|
1526 toListPtr.Append( number ); |
|
1527 toListPtr.Append( KSmumCharRightAddressIterator ); |
|
1528 toListPtr.Append( KSmumLRMarker ); |
|
1529 } |
|
1530 else |
|
1531 { |
|
1532 toListPtr.Append( number ); |
|
1533 } |
|
1534 |
|
1535 if ( index < ( count - 1 )) // comma needed? |
|
1536 { |
|
1537 toListPtr.Append( KSmumCharCommaAndSpace ); |
|
1538 } |
|
1539 } |
|
1540 } |
|
1541 else // Loop the Email addresses |
|
1542 { |
|
1543 CSmsHeader& smsHeader = SmsClientMtm().SmsHeader(); |
|
1544 const MDesCArray& array = smsHeader.EmailFields().Addresses(); |
|
1545 TInt emailAddressCount = array.MdcaCount(); |
|
1546 for( index = 0; index < emailAddressCount; index++ ) |
|
1547 { |
|
1548 stringLength += array.MdcaPoint(index).Length() + 2; |
|
1549 } |
|
1550 toList = HBufC::NewLC( stringLength ); |
|
1551 TPtr toListPtr = toList->Des(); |
|
1552 for( index = 0; index < emailAddressCount; index++ ) |
|
1553 { |
|
1554 toListPtr.Append( array.MdcaPoint(index) ); |
|
1555 if ( index < ( emailAddressCount - 1 ) ) // comma needed? |
|
1556 { |
|
1557 toListPtr.Append( KSmumCharCommaAndSpace ); |
|
1558 } |
|
1559 } |
|
1560 |
|
1561 } |
|
1562 SMUMLOGGER_LEAVEFN("CSmsMtmUi::TurnRecipientsArrayIntoStringLC"); |
|
1563 return toList; |
|
1564 } |
|
1565 |
|
1566 // --------------------------------------------------------- |
|
1567 // CSmsMtmUi::SetSharedDataL |
|
1568 // |
|
1569 // --------------------------------------------------------- |
|
1570 void CSmsMtmUi::SetSharedDataL( const TUint32 aId, const TInt aVal ) |
|
1571 { |
|
1572 if( iCenRepSession ) |
|
1573 { |
|
1574 //IMPORT_C TInt Set(TUint32 aId, TInt aVal); |
|
1575 iCenRepSession->Set( aId, aVal ); |
|
1576 } |
|
1577 } |
|
1578 |
|
1579 // --------------------------------------------------------- |
|
1580 // CSmsMtmUi::CheckAndEnsureSmsServiceOkL |
|
1581 // |
|
1582 // --------------------------------------------------------- |
|
1583 TInt CSmsMtmUi::CheckAndEnsureSmsServiceOkL( TBool aCreateService, TBool aCreateStore, TBool aFetchSMSCs ) |
|
1584 { |
|
1585 SMUMLOGGER_ENTERFN("CSmsMtmUi::CheckAndEnsureSmsServiceOkL"); |
|
1586 TInt recreation = ESmsReCreatedNone; |
|
1587 TMsvId currContext = iBaseMtm.Entry().Entry().Id(); // take current context to safe |
|
1588 TMsvId serviceEntryId = KMsvNullIndexEntryId; |
|
1589 |
|
1590 // Check first do we have service entry... |
|
1591 TRAPD( err, serviceEntryId = ServiceIdL()); |
|
1592 if ( err == KErrNotFound && aCreateService ) |
|
1593 { // ...no, let's create one |
|
1594 serviceEntryId = CreateSmsServiceL( ETrue ); |
|
1595 __ASSERT_DEBUG( serviceEntryId, Panic( ESmsuNotAServiceEntry )); |
|
1596 iNewSmsSettings = EFalse; |
|
1597 CreateDefaultSettingsL( serviceEntryId ); |
|
1598 recreation = ESmsReCreatedService; |
|
1599 iBaseMtm.SwitchCurrentEntryL( currContext ); |
|
1600 } |
|
1601 else if ( err == KErrNone ) |
|
1602 { |
|
1603 // If service ok, then check do we have msg store for it... |
|
1604 iBaseMtm.SwitchCurrentEntryL( serviceEntryId ); |
|
1605 if ( !iBaseMtm.Entry().HasStoreL() && aCreateStore ) |
|
1606 { // ...no, let's create one |
|
1607 iNewSmsSettings = EFalse; |
|
1608 CreateDefaultSettingsL( serviceEntryId ); |
|
1609 recreation = recreation ? ESmsReCreatedBoth : ESmsReCreatedServicesStore; |
|
1610 } |
|
1611 iBaseMtm.SwitchCurrentEntryL( currContext ); |
|
1612 } |
|
1613 else // Lint |
|
1614 { |
|
1615 } |
|
1616 |
|
1617 // Read SMSC from SIM, if some recreation done |
|
1618 if ( ( recreation != ESmsReCreatedNone ) && aFetchSMSCs ) |
|
1619 { |
|
1620 if ( KErrNone != ReadSMSCsFromSIML()) |
|
1621 { |
|
1622 // Something went wrong, notify NCN to read SCs from SIM in next boot |
|
1623 SetSharedDataL( |
|
1624 KSmumSmsStatus, |
|
1625 KInitializationReadSim ); |
|
1626 } |
|
1627 } |
|
1628 |
|
1629 SMUMLOGGER_LEAVEFN("CSmsMtmUi::CheckAndEnsureSmsServiceOkL"); |
|
1630 return recreation; |
|
1631 } |
|
1632 |
|
1633 // --------------------------------------------------------- |
|
1634 // CSmsMtmUi::ReadSMSCsFromSIML |
|
1635 // --------------------------------------------------------- |
|
1636 TInt CSmsMtmUi::ReadSMSCsFromSIML() |
|
1637 { |
|
1638 SMUMLOGGER_ENTERFN("CSmsMtmUi::ReadSMSCsFromSIML"); |
|
1639 CMuiuOperationWait* wait = CMuiuOperationWait::NewLC(); |
|
1640 CMsgSimOperation* simOperation = CMsgSimOperation::NewL( wait->iStatus ); |
|
1641 CleanupStack::PushL( simOperation ); |
|
1642 wait->Start(); |
|
1643 TInt returnValue = wait->iStatus.Int(); |
|
1644 CleanupStack::PopAndDestroy( 2 ); // wait, simOperation |
|
1645 SMUMLOGGER_LEAVEFN("CSmsMtmUi::ReadSMSCsFromSIML"); |
|
1646 return returnValue; |
|
1647 } |
|
1648 |
|
1649 // --------------------------------------------------------- |
|
1650 // CSmsMtmUi::CheckSimOkL |
|
1651 // --------------------------------------------------------- |
|
1652 TInt CSmsMtmUi::CheckSimStateL() |
|
1653 { |
|
1654 SMUMLOGGER_ENTERFN("CSmsMtmUi::CheckSimStateL"); |
|
1655 TInt simState( ESimUsable ); |
|
1656 TInt err = RProperty::Get( KPSUidStartup, KPSSimStatus, simState ); |
|
1657 if ( err != KErrNone ) |
|
1658 { |
|
1659 simState = ESimNotPresent; |
|
1660 } |
|
1661 SMUMLOGGER_LEAVEFN("CSmsMtmUi::CheckSimStateL"); |
|
1662 return simState; |
|
1663 } |
|
1664 |
|
1665 // --------------------------------------------------------- |
|
1666 // CSmsMtmUi::GetSubjectTextL |
|
1667 // --------------------------------------------------------- |
|
1668 void CSmsMtmUi::GetSubjectTextL( |
|
1669 const TMsvEntry& aTEntry, |
|
1670 const CSmsClientMtm& aSmsClientMtm, |
|
1671 HBufC*& aSubject, |
|
1672 TBool aIsEmailMessage /*= EFalse*/) const |
|
1673 { |
|
1674 SMUMLOGGER_ENTERFN("CSmsMtmUi::GetSubjectTextL"); |
|
1675 // show subject only if email-over-sms |
|
1676 TInt subLength = aSmsClientMtm.SmsHeader().EmailFields().Subject().Length(); |
|
1677 if ( !aTEntry.iBioType && aIsEmailMessage && subLength) |
|
1678 { |
|
1679 // dialog truncates text to fit screen width and |
|
1680 // adds '...' so we don't need to do it here |
|
1681 TBuf<KMaxSubjectLength> subjText; |
|
1682 // Read the subject from CSmsHeader |
|
1683 subjText = |
|
1684 aSmsClientMtm.SmsHeader().EmailFields().Subject().Left( KMaxSubjectLength ); |
|
1685 subjText.TrimAll(); |
|
1686 aSubject = subjText.AllocL(); |
|
1687 } |
|
1688 else |
|
1689 { // Alloc as empty so it can be pushed to CleanupStack |
|
1690 aSubject = KNullDesC().AllocL(); |
|
1691 } |
|
1692 SMUMLOGGER_LEAVEFN("CSmsMtmUi::GetSubjectTextL"); |
|
1693 } |
|
1694 |
|
1695 // --------------------------------------------------------- |
|
1696 // CSmsMtmUi::GetBioResourceId |
|
1697 // --------------------------------------------------------- |
|
1698 TInt CSmsMtmUi::GetBioResourceId( const TMsvEntry& aTEntry ) const |
|
1699 { |
|
1700 SMUMLOGGER_ENTERFN("CSmsMtmUi::GetBioResourceId"); |
|
1701 TInt resourceId( KErrNotFound ); |
|
1702 if ( aTEntry.iBioType == KMsgBioUidVCard.iUid ) |
|
1703 { |
|
1704 resourceId = R_QTN_SM_INFO_BUSINESS_CARD; |
|
1705 } |
|
1706 else if ( aTEntry.iBioType == KMsgBioUidVCalendar.iUid ) |
|
1707 { |
|
1708 resourceId = R_QTN_SM_INFO_CALENDAR; |
|
1709 } |
|
1710 else if ( aTEntry.iBioType == KMsgBioUidWmlBrSettings.iUid ) |
|
1711 { |
|
1712 resourceId = R_QTN_SM_TITLE_CONFIGURATION; |
|
1713 } |
|
1714 else if ( aTEntry.iBioType == KMsgBioUidPictureMsg.iUid ) |
|
1715 { |
|
1716 resourceId = R_QTN_SM_INFO_GMS; |
|
1717 } |
|
1718 else |
|
1719 { |
|
1720 // Don't change the resourceId |
|
1721 } |
|
1722 SMUMLOGGER_LEAVEFN("CSmsMtmUi::GetBioResourceId"); |
|
1723 return resourceId; |
|
1724 } |
|
1725 |
|
1726 // --------------------------------------------------------- |
|
1727 // CSmsMtmUi::GetBioResourceId |
|
1728 // --------------------------------------------------------- |
|
1729 TBool CSmsMtmUi::IsBioTypeSupported( const TMsvEntry& aTEntry ) const |
|
1730 { |
|
1731 SMUMLOGGER_WRITE("CSmsMtmUi::IsBioTypeSupported"); |
|
1732 TBool retryVal( EFalse ); |
|
1733 if ( aTEntry.iBioType == KMsgBioUidVCard.iUid || |
|
1734 aTEntry.iBioType == KMsgBioUidVCalendar.iUid || |
|
1735 aTEntry.iBioType == KMsgBioUidWmlBrSettings.iUid || |
|
1736 aTEntry.iBioType == KMsgBioUidPictureMsg.iUid ) |
|
1737 { |
|
1738 retryVal = ETrue; |
|
1739 } |
|
1740 else |
|
1741 { |
|
1742 } |
|
1743 return retryVal; |
|
1744 } |
|
1745 // End of File |