|
1 /* |
|
2 * Copyright (c) 2006-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: Provides CUniEditorDocument class methods. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // ========== INCLUDE FILES ================================ |
|
21 |
|
22 #include <eikenv.h> |
|
23 #include <eikdoc.h> |
|
24 |
|
25 #include <msvstd.h> // TMsvEntry |
|
26 #include <msvapi.h> |
|
27 #include <msvuids.h> // Msgs Uids |
|
28 #include <mtclbase.h> // CBaseMtm |
|
29 #include <mmsvattachmentmanager.h> |
|
30 #include <cmsvattachment.h> |
|
31 #include <cmsvmimeheaders.h> |
|
32 |
|
33 #include <bautils.h> |
|
34 |
|
35 #include <charconv.h> // Character Converter |
|
36 |
|
37 #include <mmsclient.h> // Client Mtm API |
|
38 #include <MuiuMsvUiServiceUtilities.h> // Disk space check |
|
39 #include <MuiuOperationWait.h> // CMuiuOperationWait |
|
40 #include <MsgAttachmentInfo.h> |
|
41 #include <msgmediacontrol.h> // TMsgMediaControlId |
|
42 |
|
43 // Features |
|
44 #include <featmgr.h> |
|
45 #include <bldvariant.hrh> |
|
46 #include <messagingvariant.hrh> |
|
47 |
|
48 #include <centralrepository.h> // link against centralrepository.lib |
|
49 #include <MmsEngineInternalCRKeys.h> |
|
50 #include <messaginginternalcrkeys.h> // for Central Repository keys |
|
51 |
|
52 #include <SendUiConsts.h> // for KSenduiMtmSms/MmsUid |
|
53 |
|
54 #include <RCustomerServiceProfileCache.h> // CSP bits |
|
55 #include <fileprotectionresolver.h> |
|
56 |
|
57 // Msg Media |
|
58 #include <MmsConformance.h> |
|
59 #include <MsgMediaInfo.h> |
|
60 |
|
61 // UniModel stuff |
|
62 #include <unidatamodel.h> |
|
63 #include <uniobjectlist.h> |
|
64 #include <unidatautils.h> |
|
65 |
|
66 // UniUtils stuff |
|
67 #include <uniobjectsmodel.h> |
|
68 |
|
69 #include <mmssettingsdefs.h> |
|
70 |
|
71 // MTM's |
|
72 #include "UniMsvEntry.h" |
|
73 #include "UniClientMtm.h" // Client Mtm API |
|
74 |
|
75 #include "UniPluginApi.h" |
|
76 #include "UniEditorUids.hrh" |
|
77 |
|
78 #include "UniEditorDocument.h" |
|
79 #include "UniEditorAppUi.h" |
|
80 #include "UniEditorObjectsModelObserver.h" |
|
81 #include "UniEditorLogging.h" |
|
82 #include "UniEditorEnum.h" |
|
83 |
|
84 // ========== CONSTANTS ==================================== |
|
85 |
|
86 // Length of one 7bit normal sms |
|
87 const TInt KFirstNormalSmsLength = 160; |
|
88 |
|
89 // Length of one 8bit sms |
|
90 // const TInt KFirst8bitSmsLength = 133; |
|
91 |
|
92 // Length of one unicode sms |
|
93 const TInt KFirstUnicodeSmsLength = 70; |
|
94 |
|
95 // Submsg length for normal 7bit sms |
|
96 const TInt KNormalConcatenationInterval = 153; |
|
97 |
|
98 // Submsg length for 8bit sms |
|
99 // const TInt K8bitConcatenationInterval = 128; |
|
100 |
|
101 // Submsg length for unicode sms |
|
102 const TInt KUnicodeConcatenationInterval = 67; |
|
103 |
|
104 |
|
105 const TInt KDefaultMaxSize = 300 * 1024; |
|
106 const TInt KDefaultMaxSmsSize = 10; |
|
107 const TInt KMaxSmsSizeByStandard = 30; |
|
108 const TInt KDefaultSmsRecipients = 20; |
|
109 const TInt KDefaultMmsRecipients = 100; |
|
110 |
|
111 // Char conv plugin ID (private Sms editor plugin) |
|
112 const TUint KSmsEdSmsStrictPluginID = 0x101F85CD; |
|
113 |
|
114 const TInt KUniMmsUploadImageWidth = 1600; |
|
115 const TInt KUniMmsUploadImageHeight = 1200; |
|
116 |
|
117 // --------------------------------------------------------- |
|
118 // CUniEditorDocument::Constructor |
|
119 // --------------------------------------------------------- |
|
120 // |
|
121 CUniEditorDocument::CUniEditorDocument( CEikApplication& aApp, CCoeEnv& aCoeEnv ) : |
|
122 CMsgEditorDocument( aApp ), |
|
123 iEnvironment( static_cast<CEikonEnv*>( &aCoeEnv ) ), |
|
124 iFs( aCoeEnv.FsSession() ), |
|
125 iMessageType( EUniReadOnly ), |
|
126 iDataModel( NULL ), |
|
127 iCharConverter( NULL ), |
|
128 iCurrentSlide( 0 ), |
|
129 iMaxMessageSize( KDefaultMaxSize ), |
|
130 iAddressSize( -1 ), |
|
131 iSubjectSize( -1 ), |
|
132 iMaxMmsRecipients( 100 ), |
|
133 iMaxSmsRecipients( 20 ), // Read from CR |
|
134 iMaxConcatenatedSms( KDefaultMaxSmsSize ), // Read from CR |
|
135 iAbsMaxConcatenatedSms( KDefaultMaxSmsSize ), // Read from CR |
|
136 iCreationMode( EMmsCreationModeWarning ), |
|
137 iNonConfCount( 0 ), |
|
138 iMaxImageWidth( KMmsUniImageSmallWidth ), |
|
139 iMaxImageHeight( KMmsUniImageSmallHeight ), |
|
140 iSupportedFeatures( 0 ), |
|
141 iPrevSaveType( EClosingSave ), |
|
142 iBodyState( EUniSms ), |
|
143 iHeaderState( EUniSms ), |
|
144 iFlags( 0 ), |
|
145 iCSPBits( 255 ), |
|
146 iSmsPlugin( NULL ), |
|
147 iMmsPlugin( NULL ), |
|
148 iAbsMaxSmsCharacters( 0 ) |
|
149 { |
|
150 } |
|
151 |
|
152 // --------------------------------------------------------- |
|
153 // CUniEditorDocument::ConstructL |
|
154 // --------------------------------------------------------- |
|
155 // |
|
156 void CUniEditorDocument::ConstructL() |
|
157 { |
|
158 CMsgEditorDocument::ConstructL(); |
|
159 |
|
160 TInt maxSize = KDefaultMaxSize; |
|
161 TInt creationMode = EMmsCreationModeWarning; |
|
162 TInt features = 0; |
|
163 |
|
164 // MmsEngine / MaxSendSize + CreationMode |
|
165 CRepository* repository = CRepository::NewL( KCRUidMmsEngine ); |
|
166 CleanupStack::PushL( repository ); |
|
167 |
|
168 if ( repository->Get( KMmsEngineMaximumSendSize, maxSize ) == KErrNone ) |
|
169 { |
|
170 iMaxMessageSize = maxSize; |
|
171 } |
|
172 |
|
173 if ( repository->Get( KMmsEngineCreationMode, creationMode ) == KErrNone ) |
|
174 { |
|
175 iCreationMode = creationMode; |
|
176 } |
|
177 |
|
178 CleanupStack::PopAndDestroy( repository ); |
|
179 |
|
180 // MUIU / MmsFeatures / SmsFeatures |
|
181 TBool emailOverSmsVariationOn = EFalse; |
|
182 |
|
183 repository = CRepository::NewL( KCRUidMuiuVariation ); |
|
184 CleanupStack::PushL( repository ); |
|
185 |
|
186 if ( repository->Get( KMuiuMmsFeatures, features ) == KErrNone ) |
|
187 { |
|
188 if ( features & KMmsFeatureIdEditorSubjectField ) |
|
189 { |
|
190 iSupportedFeatures |= EUniFeatureSubject; |
|
191 } |
|
192 |
|
193 if ( features & KMmsFeatureIdUserCreationMode ) |
|
194 { |
|
195 iFlags |= EUniDocumentCreationModeUserChangeable; |
|
196 } |
|
197 } |
|
198 |
|
199 if ( repository->Get( KMuiuSmsFeatures, features ) == KErrNone ) |
|
200 { |
|
201 if ( features & KSmsFeatureIdEmailOverSms ) |
|
202 { |
|
203 emailOverSmsVariationOn = ETrue; |
|
204 } |
|
205 } |
|
206 |
|
207 if ( repository->Get( KMuiuUniEditorFeatures, features ) == KErrNone ) |
|
208 { |
|
209 if ( features & KUniEditorFeatureIdRestrictedReplySms ) |
|
210 { |
|
211 iFlags |= EUniDocumentRestrictedReplySms; |
|
212 } |
|
213 if ( features & KUniEditorFeatureIdRestrictedReplyMms ) |
|
214 { |
|
215 iFlags |= EUniDocumentRestrictedReplyMms; |
|
216 } |
|
217 } |
|
218 |
|
219 if ( repository->Get( KMuiuMceFeatures, features ) == KErrNone ) |
|
220 { |
|
221 if ( features & KMceFeatureIdCSPSupport ) |
|
222 { |
|
223 iFlags |= EUniDocumentCSPBitsSupported; |
|
224 } |
|
225 } |
|
226 |
|
227 CleanupStack::PopAndDestroy( repository ); |
|
228 |
|
229 // MMS Engine CR |
|
230 repository = CRepository::NewL( KUidMmsServerMtm ); |
|
231 CleanupStack::PushL( repository ); |
|
232 |
|
233 TInt temp = 0; |
|
234 if ( repository->Get( KMmsEngineImageWidth, temp ) == KErrNone ) |
|
235 { |
|
236 iMaxImageWidth = temp; |
|
237 } |
|
238 |
|
239 if ( repository->Get( KMmsEngineImageHeight, temp ) == KErrNone ) |
|
240 { |
|
241 iMaxImageHeight = temp; |
|
242 } |
|
243 |
|
244 CleanupStack::PopAndDestroy( repository ); |
|
245 |
|
246 // Just to make sure the size is at least "small" |
|
247 iMaxImageWidth = Max( KMmsUniImageSmallWidth, iMaxImageWidth ); |
|
248 iMaxImageHeight = Max( KMmsUniImageSmallHeight, iMaxImageHeight ); |
|
249 |
|
250 // SMUM CR |
|
251 repository = CRepository::NewL( KCRUidSmum ); |
|
252 CleanupStack::PushL( repository ); |
|
253 |
|
254 if ( repository->Get( KSmumMaxSubMsgCount, iAbsMaxConcatenatedSms ) || |
|
255 iAbsMaxConcatenatedSms < 1 || |
|
256 iAbsMaxConcatenatedSms > KMaxSmsSizeByStandard ) |
|
257 { |
|
258 // Unreasonable count, change it back to 30 ( S60 default ) |
|
259 iAbsMaxConcatenatedSms = KMaxSmsSizeByStandard; |
|
260 } |
|
261 |
|
262 CleanupStack::PopAndDestroy( repository ); |
|
263 |
|
264 // UniEditor CR |
|
265 repository = CRepository::NewL( KCRUidUniEditor ); |
|
266 CleanupStack::PushL( repository ); |
|
267 |
|
268 if ( repository->Get( KUniEditorSoftLimitSubMsgCount, iMaxConcatenatedSms ) || |
|
269 iMaxConcatenatedSms < 1 || |
|
270 iMaxConcatenatedSms > iAbsMaxConcatenatedSms ) |
|
271 { |
|
272 // Unreasonable count, change it back to abs max |
|
273 iMaxConcatenatedSms = iAbsMaxConcatenatedSms; |
|
274 } |
|
275 |
|
276 if ( repository->Get( KUniEditorSoftLimitRecipientCount, iMaxSmsRecipients ) != KErrNone || |
|
277 iMaxSmsRecipients < 0) |
|
278 { |
|
279 // Unreasonable count, change it back to default value |
|
280 iMaxSmsRecipients = KDefaultSmsRecipients; |
|
281 } |
|
282 if(iMaxSmsRecipients == 0 ) |
|
283 { |
|
284 iMaxSmsRecipients = KMaxTInt; |
|
285 } |
|
286 |
|
287 if ( repository->Get( KUniEditorMaxRecipientCount, iMaxMmsRecipients ) != KErrNone || |
|
288 iMaxMmsRecipients < 0 ) |
|
289 { |
|
290 // Unreasonable count, change it back to default value |
|
291 iMaxMmsRecipients = KDefaultMmsRecipients; |
|
292 } |
|
293 if ( iMaxMmsRecipients == 0 ) |
|
294 { |
|
295 iMaxMmsRecipients = KMaxTInt; |
|
296 } |
|
297 TBool softlimitenable; |
|
298 if ( repository->Get( KUniEditorSoftLimitEnable, softlimitenable ) != KErrNone || !softlimitenable ) |
|
299 { |
|
300 // Softlimit disabled so its value is same as hardlimit |
|
301 iMaxConcatenatedSms = iAbsMaxConcatenatedSms; |
|
302 } |
|
303 repository->Get( KUniEditorMaxSmsCharacterCount, iAbsMaxSmsCharacters ); |
|
304 |
|
305 TInt maxSlideCount( 0 ); |
|
306 repository->Get( KUniEditorMaxSlideCount, maxSlideCount ); |
|
307 |
|
308 iSmsSizeWarningBytes = 0; |
|
309 repository->Get(KUniEditorSMSSizeWarning, iSmsSizeWarningBytes); |
|
310 |
|
311 CleanupStack::PopAndDestroy( repository ); |
|
312 |
|
313 if ( !iMaxMessageSize ) |
|
314 { |
|
315 //iMaxMessageSize == 0 means "anything goes" so set the size as large value as possible. |
|
316 iMaxMessageSize = KMaxTUint32; |
|
317 } |
|
318 |
|
319 // Read CSP bits from SIM |
|
320 RCustomerServiceProfileCache* cspProfile = new (ELeave) RCustomerServiceProfileCache; |
|
321 TInt error = cspProfile->Open(); |
|
322 |
|
323 UNILOGGER_WRITEF( _L("UniEditor: Customer service profile opened = %d" ), error ); |
|
324 if ( error == KErrNone ) |
|
325 { |
|
326 if ( emailOverSmsVariationOn ) |
|
327 { |
|
328 UNILOGGER_WRITE( "UniEditor: Email over SMS enabled" ); |
|
329 |
|
330 // EmailOverSms bit was variated ON so let's check the bit from SIM |
|
331 // Get tele services flags from CSP |
|
332 RMobilePhone::TCspValueAdded params; |
|
333 // Read the CPHS bit so we know if EmailOverSms is supported |
|
334 error = cspProfile->CspCPHSValueAddedServices( params ); |
|
335 |
|
336 UNILOGGER_WRITEF( _L("UniEditor: CspCPHSValueAddedServices read = %d" ), error ); |
|
337 |
|
338 if ( error == KErrNone && |
|
339 params >= 0 && |
|
340 params & RMobilePhone::KCspSMMOEmail ) |
|
341 { |
|
342 UNILOGGER_WRITE( "UniEditor: Email over SMS supported by SIM" ); |
|
343 |
|
344 // It's supported |
|
345 iFlags |= EUniDocumentEMailOverSms; |
|
346 } |
|
347 } |
|
348 |
|
349 if ( iFlags & EUniDocumentCSPBitsSupported ) |
|
350 { |
|
351 // Get tele services flags from CSP |
|
352 RMobilePhone::TCspTeleservices params2; |
|
353 // Read the TeleServices byte so we know which settings are supported |
|
354 error = cspProfile->CspTeleServices( params2 ); |
|
355 |
|
356 UNILOGGER_WRITEF( _L("UniEditor: CSP read = %d" ), error ); |
|
357 |
|
358 if ( KErrNone == error && params2 >= 0 ) |
|
359 { |
|
360 UNILOGGER_WRITEF( _L("UniEditor: CSP bits = %b" ), params2 ); |
|
361 |
|
362 iCSPBits = params2; |
|
363 } |
|
364 } |
|
365 |
|
366 cspProfile->Close(); |
|
367 } |
|
368 |
|
369 delete cspProfile; |
|
370 |
|
371 PrepareMtmL( TUid::Uid( KUidUniMtm ) ); |
|
372 |
|
373 iDataModel = CUniDataModel::NewL( iFs, Mtm() ); |
|
374 iDataModel->SmilModel().SetMaxSlideCount( maxSlideCount ); |
|
375 } |
|
376 |
|
377 // ---------------------------------------------------- |
|
378 // CUniEditorDocument::NewL |
|
379 // ---------------------------------------------------- |
|
380 // |
|
381 CUniEditorDocument* CUniEditorDocument::NewL( CEikApplication& aApp, |
|
382 CCoeEnv& aCoeEnv ) |
|
383 { |
|
384 CUniEditorDocument* self = new ( ELeave ) CUniEditorDocument( aApp, aCoeEnv ); |
|
385 |
|
386 CleanupStack::PushL( self ); |
|
387 self->ConstructL(); |
|
388 CleanupStack::Pop( self ); |
|
389 |
|
390 return self; |
|
391 } |
|
392 |
|
393 // --------------------------------------------------------- |
|
394 // CUniEditorDocument::~CUniEditorDocument |
|
395 // |
|
396 // Destructor. |
|
397 // --------------------------------------------------------- |
|
398 // |
|
399 CUniEditorDocument::~CUniEditorDocument() |
|
400 { |
|
401 delete iDataModel; |
|
402 delete iCharConverter; |
|
403 delete iSmsPlugin; |
|
404 delete iMmsPlugin; |
|
405 delete iObjectObserver; |
|
406 } |
|
407 |
|
408 // ---------------------------------------------------- |
|
409 // CUniEditorDocument::CreateAppUiL |
|
410 // ---------------------------------------------------- |
|
411 // |
|
412 CEikAppUi* CUniEditorDocument::CreateAppUiL() |
|
413 { |
|
414 CUniEditorAppUi* appui = new ( ELeave ) CUniEditorAppUi; |
|
415 |
|
416 iObjectObserver = new ( ELeave ) CUniEditorObjectsModelObserver( *this, *appui ); |
|
417 AttachmentModel().SetObserver( iObjectObserver ); |
|
418 |
|
419 return appui; |
|
420 } |
|
421 |
|
422 // --------------------------------------------------------- |
|
423 // CUniEditorDocument::DefaultMsgFolder |
|
424 // --------------------------------------------------------- |
|
425 // |
|
426 TMsvId CUniEditorDocument::DefaultMsgFolder() const |
|
427 { |
|
428 return KMsvGlobalOutBoxIndexEntryIdValue; |
|
429 } |
|
430 |
|
431 // --------------------------------------------------------- |
|
432 // CUniEditorDocument::DefaultMsgService |
|
433 // --------------------------------------------------------- |
|
434 // |
|
435 TMsvId CUniEditorDocument::DefaultMsgService() const |
|
436 { |
|
437 return KMsvLocalServiceIndexEntryIdValue; |
|
438 } |
|
439 |
|
440 // --------------------------------------------------------- |
|
441 // CUniEditorDocument::CreateNewL |
|
442 // --------------------------------------------------------- |
|
443 // |
|
444 TMsvId CUniEditorDocument::CreateNewL(TMsvId /* aServiceId */, TMsvId aDestFolder ) |
|
445 { |
|
446 // Can only create to draft |
|
447 if ( aDestFolder != KMsvDraftEntryIdValue ) |
|
448 { |
|
449 User::Leave( KErrNotSupported ); |
|
450 } |
|
451 return Mtm().CreateNewEntryL( aDestFolder ); |
|
452 } |
|
453 |
|
454 // --------------------------------------------------------- |
|
455 // CUniEditorDocument::CreateNewAttachmentModelL |
|
456 // |
|
457 // Creates new objects model object (virtual from CMsgEditorDocument). |
|
458 // --------------------------------------------------------- |
|
459 // |
|
460 CMsgAttachmentModel* CUniEditorDocument::CreateNewAttachmentModelL( TBool aReadOnly ) |
|
461 { |
|
462 return CUniObjectsModel::NewL( aReadOnly ); |
|
463 } |
|
464 |
|
465 // --------------------------------------------------------- |
|
466 // CUniEditorDocument::Mtm |
|
467 // --------------------------------------------------------- |
|
468 // |
|
469 CUniClientMtm& CUniEditorDocument::Mtm() |
|
470 { |
|
471 return static_cast <CUniClientMtm&> ( CMsgEditorDocument::Mtm() ); |
|
472 } |
|
473 |
|
474 // --------------------------------------------------------- |
|
475 // CUniEditorDocument::MtmUi |
|
476 // --------------------------------------------------------- |
|
477 // |
|
478 CUniMtmUi& CUniEditorDocument::MtmUiL() |
|
479 { |
|
480 return static_cast <CUniMtmUi&> ( CMsgEditorDocument::MtmUiL() ); |
|
481 } |
|
482 |
|
483 |
|
484 // --------------------------------------------------------- |
|
485 // CUniEditorDocument::EntryChangedL |
|
486 // Intentionally empty implementation. |
|
487 // --------------------------------------------------------- |
|
488 // |
|
489 void CUniEditorDocument::EntryChangedL() |
|
490 { |
|
491 } |
|
492 |
|
493 // --------------------------------------------------------- |
|
494 // CUniEditorDocument::PrepareContextL |
|
495 // --------------------------------------------------------- |
|
496 // |
|
497 TMsvId CUniEditorDocument::PrepareContextL( TMsvId aContext ) |
|
498 { |
|
499 TMsvId service; |
|
500 TMsvEntry entry; |
|
501 User::LeaveIfError( Session().GetEntry( aContext, service, entry ) ); |
|
502 |
|
503 if ( entry.iMtm.iUid == KUidUniMtm ) |
|
504 { |
|
505 return aContext; |
|
506 } |
|
507 |
|
508 TMsvId newId = KMsvNullIndexEntryIdValue; |
|
509 |
|
510 if ( entry.iMtm == KSenduiMtmSmsUid ) |
|
511 { |
|
512 __ASSERT_DEBUG( !iSmsPlugin, Panic( EUniAlreadyExists ) ); |
|
513 |
|
514 delete iSmsPlugin; |
|
515 iSmsPlugin = NULL; |
|
516 |
|
517 iSmsPlugin = CUniEditorPlugin::NewL( TUid::Uid( KUidUniEditorSmsPlugin ), |
|
518 Session(), |
|
519 Mtm() ); |
|
520 |
|
521 newId = iSmsPlugin->ConvertFromL( aContext ); |
|
522 } |
|
523 else if ( entry.iMtm == KSenduiMtmMmsUid ) |
|
524 { |
|
525 __ASSERT_DEBUG( !iMmsPlugin, Panic( EUniAlreadyExists ) ); |
|
526 |
|
527 delete iMmsPlugin; |
|
528 iMmsPlugin = NULL; |
|
529 |
|
530 iMmsPlugin = CUniEditorPlugin::NewL( TUid::Uid( KUidUniEditorMmsPlugin ), |
|
531 Session(), |
|
532 Mtm() ); |
|
533 newId = iMmsPlugin->ConvertFromL( aContext ); |
|
534 } |
|
535 else |
|
536 { |
|
537 User::Leave( KErrNotSupported ); |
|
538 } |
|
539 |
|
540 return newId; |
|
541 } |
|
542 |
|
543 // --------------------------------------------------------- |
|
544 // CUniEditorDocument::ChangeContextL |
|
545 // --------------------------------------------------------- |
|
546 // |
|
547 TMsvId CUniEditorDocument::ChangeContextL( const TEditorParameters& aParameters ) |
|
548 { |
|
549 TMsvId id( KMsvNullIndexEntryIdValue ); |
|
550 |
|
551 const TMsvId src = aParameters.iId; |
|
552 const TMsvId dest = aParameters.iDestinationFolderId; |
|
553 const TMsvPartList parts = aParameters.iPartList; |
|
554 |
|
555 if ( aParameters.iFlags & EMsgReplyToMessageSender || |
|
556 aParameters.iFlags & EMsgReplyToMessageAll ) |
|
557 { |
|
558 id = DoReplyForwardL( ETrue, src, dest, parts ); |
|
559 } |
|
560 else if (aParameters.iFlags & EMsgForwardMessage) |
|
561 { |
|
562 id = DoReplyForwardL( EFalse, src, dest, parts ); |
|
563 } |
|
564 else |
|
565 { |
|
566 User::Leave( KErrArgument ); |
|
567 } |
|
568 |
|
569 return id; |
|
570 } |
|
571 |
|
572 // --------------------------------------------------------- |
|
573 // CUniEditorDocument::DoReplyForwardL |
|
574 // --------------------------------------------------------- |
|
575 // |
|
576 TMsvId CUniEditorDocument::DoReplyForwardL( |
|
577 TBool aReply, |
|
578 TMsvId aSrc, |
|
579 TMsvId aDest, |
|
580 TMsvPartList aParts ) |
|
581 { |
|
582 TMsvId newId; |
|
583 TMsvId service; |
|
584 TMsvEntry entry; |
|
585 User::LeaveIfError( Session().GetEntry( aSrc, service, entry ) ); |
|
586 CUniEditorPlugin* plugin = NULL; |
|
587 |
|
588 if ( entry.iMtm == KSenduiMtmSmsUid ) |
|
589 { |
|
590 __ASSERT_DEBUG( !iSmsPlugin, Panic( EUniAlreadyExists ) ); |
|
591 |
|
592 delete iSmsPlugin; |
|
593 iSmsPlugin = NULL; |
|
594 |
|
595 iSmsPlugin = CUniEditorPlugin::NewL( TUid::Uid( KUidUniEditorSmsPlugin ), |
|
596 Session(), |
|
597 Mtm() ); |
|
598 plugin = iSmsPlugin; |
|
599 if( iFlags & EUniDocumentRestrictedReplySms ) |
|
600 { |
|
601 if( aReply ) |
|
602 { |
|
603 Mtm().SetMessageTypeSetting( EUniMessageTypeSettingSms ); |
|
604 Mtm().SetMessageTypeLocking( EUniMessageTypeLocked ); |
|
605 } |
|
606 } |
|
607 } |
|
608 else if ( entry.iMtm == KSenduiMtmMmsUid || |
|
609 entry.iMtm == KSenduiMMSNotificationUid ) |
|
610 { |
|
611 __ASSERT_DEBUG( !iMmsPlugin, Panic( EUniAlreadyExists ) ); |
|
612 |
|
613 delete iMmsPlugin; |
|
614 iMmsPlugin = NULL; |
|
615 |
|
616 iMmsPlugin = CUniEditorPlugin::NewL( TUid::Uid( KUidUniEditorMmsPlugin ), |
|
617 Session(), |
|
618 Mtm() ); |
|
619 plugin = iMmsPlugin; |
|
620 if ( iFlags & EUniDocumentRestrictedReplyMms ) |
|
621 { |
|
622 if ( aReply ) |
|
623 { |
|
624 Mtm().SetMessageTypeSetting( EUniMessageTypeSettingMms ); |
|
625 Mtm().SetMessageTypeLocking( EUniMessageTypeLocked ); |
|
626 } |
|
627 } |
|
628 } |
|
629 if ( !plugin ) |
|
630 { |
|
631 User::Leave( KErrNotSupported ); |
|
632 } |
|
633 |
|
634 if ( aReply ) |
|
635 { |
|
636 newId = plugin->CreateReplyL( aSrc, aDest, aParts ); |
|
637 } |
|
638 else |
|
639 { |
|
640 newId = plugin->CreateForwardL( aSrc, aDest, aParts ); |
|
641 } |
|
642 return newId; |
|
643 } |
|
644 |
|
645 // --------------------------------------------------------- |
|
646 // CUniEditorDocument::SetMessageType |
|
647 // --------------------------------------------------------- |
|
648 // |
|
649 void CUniEditorDocument::SetMessageType() |
|
650 { |
|
651 TMsvEntry tEntry = Entry(); |
|
652 |
|
653 const TInt flags = LaunchFlags(); |
|
654 |
|
655 if ( flags & EMsgCreateNewMessage ) |
|
656 { |
|
657 iMessageType = EUniNewMessage; |
|
658 } |
|
659 else if ( flags & ( EMsgReplyToMessageSender | EMsgReplyToMessageAll ) ) |
|
660 { |
|
661 iMessageType = EUniReply; |
|
662 } |
|
663 else if ( flags & EMsgForwardMessage || |
|
664 TUniMsvEntry::IsForwardedMessage( tEntry ) ) |
|
665 { |
|
666 iMessageType = EUniForward; |
|
667 } |
|
668 else if ( TUniMsvEntry::IsEditorOriented( tEntry ) ) |
|
669 { |
|
670 iMessageType = EUniOpenFromDraft; |
|
671 } |
|
672 else |
|
673 { |
|
674 iMessageType = EUniSendUi; |
|
675 } |
|
676 } |
|
677 |
|
678 // --------------------------------------------------------- |
|
679 // MessageSize |
|
680 // |
|
681 // --------------------------------------------------------- |
|
682 // |
|
683 TInt CUniEditorDocument::MessageSize( TBool aSmilEstimate /*= EFalse*/ ) |
|
684 { |
|
685 TInt msgSizeBytes( 0 ); |
|
686 |
|
687 msgSizeBytes = iDataModel->ObjectList().ObjectByteSize(); |
|
688 |
|
689 TBool addSmilSize = ETrue; |
|
690 |
|
691 if ( iDataModel->SmilType() == EMmsSmil ) |
|
692 { |
|
693 if ( !msgSizeBytes ) |
|
694 { |
|
695 // MMS SMIL & no objects |
|
696 // -> Consider message (body) empty |
|
697 addSmilSize = EFalse; |
|
698 } |
|
699 } |
|
700 else |
|
701 { |
|
702 // Not MMS SMIL |
|
703 // -> make sure SmilModel estimate size is not used. |
|
704 aSmilEstimate = EFalse; |
|
705 } |
|
706 |
|
707 if ( addSmilSize ) |
|
708 { |
|
709 if ( aSmilEstimate ) |
|
710 { |
|
711 msgSizeBytes += iDataModel->SmilModel().SmilComposeSize(); |
|
712 } |
|
713 else |
|
714 { |
|
715 msgSizeBytes += iDataModel->SmilList().SmilByteSize(); |
|
716 } |
|
717 } |
|
718 |
|
719 msgSizeBytes += iDataModel->AttachmentList().ObjectByteSize(); |
|
720 |
|
721 // if "iSubjectSize" is not initialized get the size from MTM |
|
722 if ( iSubjectSize < 0 ) |
|
723 { |
|
724 // CMmsClientMtm::SubjectL() is non-leaving! |
|
725 TPtrC subject; |
|
726 TRAP_IGNORE( subject.Set( Mtm().SubjectL() ) ); |
|
727 iSubjectSize = CUniDataUtils::UTF8Size( subject ); |
|
728 } |
|
729 |
|
730 msgSizeBytes += iSubjectSize; |
|
731 |
|
732 return msgSizeBytes; |
|
733 } |
|
734 |
|
735 // ---------------------------------------------------- |
|
736 // DeleteAttachmentL |
|
737 // ---------------------------------------------------- |
|
738 // |
|
739 void CUniEditorDocument::DeleteAttachmentL( TInt aSlideNum, |
|
740 CUniObject* aObject, |
|
741 TBool aAttachmentObject ) |
|
742 { |
|
743 // This should be called only from Objects view |
|
744 |
|
745 // If SMIL is not MMS SMIL remove is only possible |
|
746 // for attachments in Objects view. |
|
747 |
|
748 if ( !aAttachmentObject ) |
|
749 { |
|
750 //SmilModel takes care of the whole delete procedure |
|
751 iDataModel->SmilModel().RemoveObjectL( aSlideNum, aObject ); |
|
752 } |
|
753 else |
|
754 { |
|
755 iDataModel->AttachmentList().RemoveObjectL( aObject ); |
|
756 delete aObject; |
|
757 } |
|
758 } |
|
759 |
|
760 // ---------------------------------------------------- |
|
761 // GetAttachmentFileL |
|
762 // ---------------------------------------------------- |
|
763 // |
|
764 RFile CUniEditorDocument::GetAttachmentFileL( TMsvAttachmentId aId ) |
|
765 { |
|
766 RFile file; |
|
767 |
|
768 CMsvStore* store = Mtm().Entry().ReadStoreL(); |
|
769 CleanupStack::PushL( store ); |
|
770 |
|
771 MMsvAttachmentManager& manager = store->AttachmentManagerL(); |
|
772 |
|
773 file = manager.GetAttachmentFileL( aId ); |
|
774 |
|
775 CleanupStack::PopAndDestroy( store ); |
|
776 |
|
777 return file; |
|
778 } |
|
779 |
|
780 // ---------------------------------------------------- |
|
781 // UpdatedNonConformantCount |
|
782 // ---------------------------------------------------- |
|
783 // |
|
784 TInt CUniEditorDocument::UpdatedNonConformantCount() const |
|
785 { |
|
786 TInt countNonConformant( 0 ); |
|
787 TInt countSuppObjects = iDataModel->ObjectList().Count(); |
|
788 TInt i( 0 ); |
|
789 for (i = 0; i < countSuppObjects ; i++ ) |
|
790 { |
|
791 CUniObject* obj = iDataModel->ObjectList().GetByIndex( i ); |
|
792 if ( obj ) |
|
793 { |
|
794 if( iDataModel->MmsConformance().MediaConformance( *obj->MediaInfo() ).iConfClass == |
|
795 EMmsClassUnclassified ) |
|
796 { |
|
797 countNonConformant++; |
|
798 } |
|
799 } |
|
800 } |
|
801 TInt countAttObjects = iDataModel->AttachmentList().Count(); |
|
802 for (i = 0; i < countAttObjects ; i++ ) |
|
803 { |
|
804 CUniObject* obj = iDataModel->AttachmentList().GetByIndex( i ); |
|
805 if ( obj ) |
|
806 { |
|
807 if( iDataModel->MmsConformance().MediaConformance( *obj->MediaInfo() ).iConfClass == |
|
808 EMmsClassUnclassified ) |
|
809 { |
|
810 countNonConformant++; |
|
811 } |
|
812 } |
|
813 } |
|
814 return countNonConformant; |
|
815 } |
|
816 |
|
817 // ---------------------------------------------------- |
|
818 // CUniEditorDocument::CreateCharConverterL |
|
819 // ---------------------------------------------------- |
|
820 // |
|
821 void CUniEditorDocument::CreateCharConverterL( TUniMessageCharSetSupport aMode ) |
|
822 { |
|
823 delete iCharConverter; |
|
824 iCharConverter = NULL; |
|
825 |
|
826 iCharConverter = CCnvCharacterSetConverter::NewL(); |
|
827 |
|
828 // TODO: Error situation needs to be handled somehow |
|
829 CCnvCharacterSetConverter::TAvailability available = |
|
830 CCnvCharacterSetConverter::ENotAvailable; |
|
831 |
|
832 if ( aMode == EUniMessageCharSetFull || |
|
833 aMode == EUniMessageCharSetFullLocked ) |
|
834 { |
|
835 // For Full CharacterSet support we use |
|
836 // S60 SmsStrict converter plug-in |
|
837 available = iCharConverter->PrepareToConvertToOrFromL( KSmsEdSmsStrictPluginID, |
|
838 iFs ); |
|
839 } |
|
840 else |
|
841 { |
|
842 // For Reduced support we use converter plug-in |
|
843 // provided by Symbian |
|
844 available = iCharConverter->PrepareToConvertToOrFromL( KCharacterSetIdentifierSms7Bit, |
|
845 iFs ); |
|
846 } |
|
847 |
|
848 if ( available == CCnvCharacterSetConverter::ENotAvailable ) |
|
849 { |
|
850 __ASSERT_DEBUG( EFalse, Panic( EUniCharConvNotFound ) ); |
|
851 User::Leave( KErrNotFound ); |
|
852 } |
|
853 |
|
854 iCharConverter->SetDowngradeForExoticLineTerminatingCharacters( |
|
855 CCnvCharacterSetConverter::EDowngradeExoticLineTerminatingCharactersToJustLineFeed ); |
|
856 |
|
857 iCharSetSupport = aMode; |
|
858 } |
|
859 |
|
860 // ---------------------------------------------------- |
|
861 // CUniEditorDocument::LaunchPlugings |
|
862 // |
|
863 // TRAP's needed as some plugins might not be available |
|
864 // at all in some variants. |
|
865 // ---------------------------------------------------- |
|
866 // |
|
867 void CUniEditorDocument::LaunchPlugings() |
|
868 { |
|
869 // This might have been set in PrepareContextL or DoReplyForwardL |
|
870 // if not -> construct them here |
|
871 if( !iSmsPlugin ) |
|
872 { |
|
873 TRAP_IGNORE( iSmsPlugin = CUniEditorPlugin::NewL( TUid::Uid( KUidUniEditorSmsPlugin ), |
|
874 Session(), |
|
875 Mtm() ) ); |
|
876 } |
|
877 |
|
878 if( !iMmsPlugin ) |
|
879 { |
|
880 TRAP_IGNORE( iMmsPlugin = CUniEditorPlugin::NewL( TUid::Uid( KUidUniEditorMmsPlugin ), |
|
881 Session(), |
|
882 Mtm() ) ); |
|
883 } |
|
884 } |
|
885 |
|
886 // ---------------------------------------------------- |
|
887 // CUniEditorDocument::MaxImageSize |
|
888 // ---------------------------------------------------- |
|
889 // |
|
890 TSize CUniEditorDocument::MaxImageSize() const |
|
891 { |
|
892 TMsvEntry tEntry = Entry(); |
|
893 |
|
894 if ( TUniMsvEntry::IsMmsUpload( tEntry ) ) |
|
895 { |
|
896 return TSize( KUniMmsUploadImageWidth, KUniMmsUploadImageHeight ); |
|
897 } |
|
898 else |
|
899 { |
|
900 return TSize( iMaxImageWidth, iMaxImageHeight ); |
|
901 } |
|
902 } |
|
903 |
|
904 // ---------------------------------------------------- |
|
905 // CUniEditorDocument::SuperDistributableObjectCount |
|
906 // ---------------------------------------------------- |
|
907 // |
|
908 TInt CUniEditorDocument::SuperDistributableObjectCount() const |
|
909 { |
|
910 TInt resultCount( 0 ); |
|
911 TInt countSuppObjects = iDataModel->ObjectList().Count(); |
|
912 TInt i( 0 ); |
|
913 for ( i = 0; i < countSuppObjects ; i++ ) |
|
914 { |
|
915 CUniObject* obj = iDataModel->ObjectList().GetByIndex( i ); |
|
916 if ( obj->MediaInfo() && |
|
917 obj->MediaInfo()->Protection() & EFileProtSuperDistributable ) |
|
918 { |
|
919 resultCount++; |
|
920 } |
|
921 } |
|
922 TInt countAttObjects = iDataModel->AttachmentList().Count(); |
|
923 for ( i = 0; i < countAttObjects ; i++ ) |
|
924 { |
|
925 CUniObject* obj = iDataModel->AttachmentList().GetByIndex( i ); |
|
926 if ( obj->MediaInfo() && |
|
927 obj->MediaInfo()->Protection() & EFileProtSuperDistributable ) |
|
928 { |
|
929 resultCount++; |
|
930 } |
|
931 } |
|
932 return resultCount; |
|
933 } |
|
934 |
|
935 // ---------------------------------------------------- |
|
936 // CUniEditorDocument::UniState |
|
937 // ---------------------------------------------------- |
|
938 // |
|
939 TUniState CUniEditorDocument::UniState() const |
|
940 { |
|
941 CUniClientMtm& mtm = static_cast <CUniClientMtm&> ( CMsgEditorDocument::Mtm() ); |
|
942 |
|
943 if ( mtm.MessageTypeLocking() == EUniMessageTypeLocked ) |
|
944 { |
|
945 // Ok, message type is locked |
|
946 if ( mtm.MessageTypeSetting() == EUniMessageTypeSettingSms ) |
|
947 { |
|
948 // Locked to SMS - it must be SMS |
|
949 return EUniSms; |
|
950 } |
|
951 else if ( iBodyState == EUniSms && |
|
952 iHeaderState == EUniSms && |
|
953 mtm.MessageTypeSetting() == EUniMessageTypeSettingAutomatic ) |
|
954 { |
|
955 // locked to auto and both body and headers are SMS -> SMS |
|
956 return EUniSms; |
|
957 } |
|
958 else |
|
959 { |
|
960 // otherwise it's MMS |
|
961 return EUniMms; |
|
962 } |
|
963 } |
|
964 else |
|
965 { |
|
966 // type is not locked |
|
967 if ( iBodyState == EUniSms && |
|
968 iHeaderState == EUniSms && |
|
969 mtm.MessageTypeSetting() != EUniMessageTypeSettingMms ) |
|
970 { |
|
971 // type is not mms and both body and headers are sms |
|
972 return EUniSms; |
|
973 } |
|
974 else |
|
975 { |
|
976 // otherwise it's MMS |
|
977 return EUniMms; |
|
978 } |
|
979 } |
|
980 } |
|
981 |
|
982 // ---------------------------------------------------- |
|
983 // CUniEditorDocument::SmsCharacterLimits |
|
984 // ---------------------------------------------------- |
|
985 // |
|
986 void CUniEditorDocument::SmsCharacterLimits( TInt& aSinglePartLength, |
|
987 TInt& aConcatenatedPartLength ) const |
|
988 { |
|
989 if ( UnicodeCharacterMode() ) |
|
990 { |
|
991 aSinglePartLength = KFirstUnicodeSmsLength; |
|
992 aConcatenatedPartLength = KUnicodeConcatenationInterval; |
|
993 } |
|
994 else |
|
995 { |
|
996 aSinglePartLength = KFirstNormalSmsLength; |
|
997 aConcatenatedPartLength = KNormalConcatenationInterval; |
|
998 } |
|
999 } |
|
1000 |
|
1001 // ---------------------------------------------------- |
|
1002 // CUniEditorDocument::GetLanguageSpecificAltEncodingType |
|
1003 // @return the alternate encoding type based on input language id. |
|
1004 // Turkish SMS-PREQ2265 specific |
|
1005 // |
|
1006 // NOTE: In future based on the new requirements, new language(supporting NLT) and the corresponding |
|
1007 // alternate encoding type can be added to this function and used appropriately |
|
1008 // ---------------------------------------------------- |
|
1009 |
|
1010 TSmsEncoding CUniEditorDocument::GetLanguageSpecificAltEncodingType(TInt aLangId) |
|
1011 { |
|
1012 TSmsEncoding alternateEncodingType = ESmsEncodingNone; |
|
1013 switch(aLangId) |
|
1014 { |
|
1015 case ELangTurkish: |
|
1016 { |
|
1017 alternateEncodingType = ESmsEncodingTurkishSingleShift; |
|
1018 break; |
|
1019 } |
|
1020 default: |
|
1021 { |
|
1022 break; |
|
1023 } |
|
1024 } |
|
1025 return alternateEncodingType; |
|
1026 } |
|
1027 |
|
1028 // End of File |