79
|
1 |
/*
|
|
2 |
* Copyright (c) 2006,2007 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: UniEditor header.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
// INCLUDE FILES
|
|
21 |
|
|
22 |
#include <eikrted.h>
|
|
23 |
#include <txtrich.h> // CRichText
|
|
24 |
|
|
25 |
#include <centralrepository.h> // link against centralrepository.lib
|
|
26 |
#include <messaginginternalcrkeys.h> // for Central Repository keys
|
|
27 |
#include <MuiuMsvUiServiceUtilities.h>
|
|
28 |
|
|
29 |
#include <mmsgenutils.h>
|
|
30 |
|
|
31 |
#include <messagingvariant.hrh>
|
|
32 |
|
|
33 |
#include <MsgExpandableControl.h>
|
|
34 |
#include <MsgAddressControl.h>
|
|
35 |
#include <MsgAttachmentControl.h>
|
|
36 |
#include <MsgRecipientItem.h>
|
|
37 |
|
|
38 |
#include <MsgMediaInfo.h>
|
|
39 |
|
|
40 |
#include <unimsventry.h>
|
|
41 |
#include <UniEditor.rsg>
|
|
42 |
#include <unidatautils.h>
|
|
43 |
#include <uniaddresshandler.h>
|
|
44 |
|
|
45 |
#include "UniEditorEnum.h" // Panic
|
|
46 |
#include "UniEditorDocument.h"
|
|
47 |
#include "UniEditorHeader.h"
|
|
48 |
|
|
49 |
|
|
50 |
// ==========================================================
|
|
51 |
|
|
52 |
// EXTERNAL DATA STRUCTURES
|
|
53 |
|
|
54 |
// EXTERNAL FUNCTION PROTOTYPES
|
|
55 |
|
|
56 |
// CONSTANTS
|
|
57 |
const TInt KUniCharAt = '@';
|
|
58 |
const TInt KUniMaxSubject = 40;
|
|
59 |
const TUint KZeroWidthNonJoiner = 0x200C;
|
|
60 |
// MACROS
|
|
61 |
|
|
62 |
// LOCAL CONSTANTS AND MACROS
|
|
63 |
|
|
64 |
// MODULE DATA STRUCTURES
|
|
65 |
|
|
66 |
// LOCAL FUNCTION PROTOTYPES
|
|
67 |
|
|
68 |
// ================= MEMBER FUNCTIONS =======================
|
|
69 |
|
|
70 |
// ---------------------------------------------------------
|
|
71 |
// CUniEditorHeader::NewL
|
|
72 |
//
|
|
73 |
// Two-phased constructor.
|
|
74 |
// ---------------------------------------------------------
|
|
75 |
//
|
|
76 |
CUniEditorHeader* CUniEditorHeader::NewL( CUniClientMtm& aMtm,
|
|
77 |
CUniEditorDocument& aDoc,
|
|
78 |
CMsgEditorView& aView,
|
|
79 |
RFs& aFs )
|
|
80 |
{
|
|
81 |
CUniEditorHeader* self = new ( ELeave ) CUniEditorHeader( aMtm, aDoc, aView, aFs );
|
|
82 |
|
|
83 |
CleanupStack::PushL( self );
|
|
84 |
self->ConstructL();
|
|
85 |
CleanupStack::Pop( self );
|
|
86 |
|
|
87 |
return self;
|
|
88 |
}
|
|
89 |
|
|
90 |
// ---------------------------------------------------------
|
|
91 |
// CUniEditorHeader::CUniEditorHeader
|
|
92 |
//
|
|
93 |
// Constructor.
|
|
94 |
// ---------------------------------------------------------
|
|
95 |
//
|
|
96 |
CUniEditorHeader::CUniEditorHeader( CUniClientMtm& aMtm,
|
|
97 |
CUniEditorDocument& aDoc,
|
|
98 |
CMsgEditorView& aView,
|
|
99 |
RFs& aFs ):
|
|
100 |
CUniBaseHeader( aMtm, aView, aFs ),
|
|
101 |
iDoc( aDoc),
|
|
102 |
iLongestEmail( 0 )
|
|
103 |
{
|
|
104 |
}
|
|
105 |
|
|
106 |
// ---------------------------------------------------------
|
|
107 |
// CUniEditorHeader::ConstructL
|
|
108 |
// ---------------------------------------------------------
|
|
109 |
//
|
|
110 |
void CUniEditorHeader::ConstructL()
|
|
111 |
{
|
|
112 |
AddHeadersVariationL( TUniMsvEntry::IsMmsUpload( iMtm.Entry().Entry() ) );
|
|
113 |
AddHeadersConfigL();
|
|
114 |
|
|
115 |
iAddDelayed = EUniFeatureTo;
|
|
116 |
|
|
117 |
iDoc.DataModel()->AttachmentList().SetListObserver( this );
|
|
118 |
TPtrC cvsubject = iMtm.SubjectL();
|
|
119 |
TUint value = 0;
|
|
120 |
if( cvsubject.Length() != 0 )
|
|
121 |
{
|
|
122 |
TLex Cv( cvsubject);
|
|
123 |
Cv.Val( value );
|
|
124 |
if(value == KZeroWidthNonJoiner)
|
|
125 |
{
|
|
126 |
iDoc.SetLaunchFromCvAttachment(ETrue);
|
|
127 |
iMtm.SetSubjectL(KNullDesC());
|
|
128 |
}
|
|
129 |
}
|
|
130 |
|
|
131 |
const TPtrC subject = iMtm.SubjectL();
|
|
132 |
|
|
133 |
TBool lockedSMS = EFalse;
|
|
134 |
if ( iDoc.Mtm().MessageTypeSetting() == EUniMessageTypeSettingSms )
|
|
135 |
{
|
|
136 |
lockedSMS = ETrue;
|
|
137 |
}
|
|
138 |
|
|
139 |
if ( iAddHeadersVariation & EUniFeatureSubject )
|
|
140 |
{
|
|
141 |
// Subject is supported
|
|
142 |
if ( !( iAddHeadersVariation & EUniFeatureSubjectConfigurable ) )
|
|
143 |
{
|
|
144 |
// and it's not configurable -> it's always on
|
|
145 |
iAddDelayed |= EUniFeatureSubject;
|
|
146 |
}
|
|
147 |
else if ( iAddHeadersConfig & EUniFeatureSubject &&
|
|
148 |
!lockedSMS )
|
|
149 |
{
|
|
150 |
// or it's currently configured on and we are not on locked SMS mode.
|
|
151 |
iAddDelayed |= EUniFeatureSubject;
|
|
152 |
}
|
|
153 |
else if ( subject.Length() )
|
|
154 |
{
|
|
155 |
// or there's something in the subject
|
|
156 |
iAddDelayed |= EUniFeatureSubject;
|
|
157 |
}
|
|
158 |
}
|
|
159 |
|
|
160 |
// check adding into other field than 'home' field
|
|
161 |
TInt addIntoOther( 0 );
|
|
162 |
TInt addressesInStore = MtmAddressTypes();
|
|
163 |
|
|
164 |
// configured or variated on but contains data
|
|
165 |
if ( !lockedSMS &&
|
|
166 |
( iAddHeadersConfig & EUniFeatureCc ||
|
|
167 |
( iAddHeadersVariation & EUniFeatureCc &&
|
|
168 |
addressesInStore & EUniFeatureCc ) ) )
|
|
169 |
{
|
|
170 |
iAddDelayed |= EUniFeatureCc;
|
|
171 |
}
|
|
172 |
else if ( !( iAddHeadersVariation & EUniFeatureCc ) &&
|
|
173 |
addressesInStore & EUniFeatureCc )
|
|
174 |
{
|
|
175 |
// show in the other field if variated off
|
|
176 |
addIntoOther |= EUniFeatureCc;
|
|
177 |
}
|
|
178 |
|
|
179 |
// configured or variated on but contains data
|
|
180 |
if ( !lockedSMS &&
|
|
181 |
( iAddHeadersConfig & EUniFeatureBcc ||
|
|
182 |
( iAddHeadersVariation & EUniFeatureBcc &&
|
|
183 |
addressesInStore & EUniFeatureBcc ) ) )
|
|
184 |
{
|
|
185 |
iAddDelayed |= EUniFeatureBcc;
|
|
186 |
}
|
|
187 |
else if ( !( iAddHeadersVariation & EUniFeatureBcc ) &&
|
|
188 |
addressesInStore & EUniFeatureBcc )
|
|
189 |
{
|
|
190 |
// show in the other field if variated off
|
|
191 |
addIntoOther |= EUniFeatureBcc;
|
|
192 |
}
|
|
193 |
|
|
194 |
if ( iDoc.DataModel()->AttachmentList().Count() > 0 )
|
|
195 |
{
|
|
196 |
iAddDelayed |= EUniFeatureAttachment;
|
|
197 |
}
|
|
198 |
|
|
199 |
DoAddToViewL( ETrue );
|
|
200 |
|
|
201 |
// Add data to those which are not configured but are variated off and contains data
|
|
202 |
// CMsgEditorAppUi must set Document always modified!
|
|
203 |
// Its is done in CUniEditorLaunchOperation::DoHandleMessageL()
|
|
204 |
// Variation has changed On->Off and message opened from Drafts
|
|
205 |
if ( addIntoOther & EUniFeatureCc )
|
|
206 |
{
|
|
207 |
iHeaders[EHeaderAddressTo].iAddressHandler->CopyAddressesFromMtmL( EMsvRecipientCc, ETrue );
|
|
208 |
}
|
|
209 |
if ( addIntoOther & EUniFeatureBcc &&
|
|
210 |
iHeaders[EHeaderAddressCc].iAddressHandler )
|
|
211 |
{
|
|
212 |
iHeaders[EHeaderAddressCc].iAddressHandler->CopyAddressesFromMtmL( EMsvRecipientBcc, ETrue );
|
|
213 |
}
|
|
214 |
else if ( addIntoOther & EUniFeatureBcc )
|
|
215 |
{
|
|
216 |
iHeaders[EHeaderAddressTo].iAddressHandler->CopyAddressesFromMtmL( EMsvRecipientBcc, ETrue );
|
|
217 |
}
|
|
218 |
|
|
219 |
if ( iDoc.MessageType() == EUniReply )
|
|
220 |
{
|
|
221 |
RemoveDuplicateAddressesL();
|
|
222 |
}
|
|
223 |
}
|
|
224 |
|
|
225 |
// ---------------------------------------------------------
|
|
226 |
// CUniEditorHeader::~CUniEditorHeader
|
|
227 |
// ---------------------------------------------------------
|
|
228 |
//
|
|
229 |
CUniEditorHeader::~CUniEditorHeader()
|
|
230 |
{
|
|
231 |
}
|
|
232 |
|
|
233 |
// ---------------------------------------------------------
|
|
234 |
// CUniEditorHeader::AddHeadersAddL
|
|
235 |
// ---------------------------------------------------------
|
|
236 |
//
|
|
237 |
void CUniEditorHeader::AddHeadersAddL(TInt aFlags)
|
|
238 |
{
|
|
239 |
if ( !aFlags )
|
|
240 |
{
|
|
241 |
// nothing to add
|
|
242 |
return;
|
|
243 |
}
|
|
244 |
|
|
245 |
// don't use anything, which is variated off
|
|
246 |
aFlags &= iAddHeadersVariation;
|
|
247 |
|
|
248 |
// do not add anything existing
|
|
249 |
if ( iHeaders[EHeaderAddressCc].iControl )
|
|
250 |
{
|
|
251 |
aFlags &= ( ~EUniFeatureCc );
|
|
252 |
}
|
|
253 |
if ( iHeaders[EHeaderAddressBcc].iControl )
|
|
254 |
{
|
|
255 |
aFlags &= ( ~EUniFeatureBcc );
|
|
256 |
}
|
|
257 |
if ( iHeaders[EHeaderSubject].iControl )
|
|
258 |
{
|
|
259 |
aFlags &= ( ~EUniFeatureSubject );
|
|
260 |
}
|
|
261 |
if ( iHeaders[EHeaderAttachment].iControl )
|
|
262 |
{
|
|
263 |
aFlags &= ( ~EUniFeatureAttachment );
|
|
264 |
}
|
|
265 |
|
|
266 |
iAddDelayed = aFlags;
|
|
267 |
|
|
268 |
// Test whether on the first slide.
|
|
269 |
// Check whether we can add immediately.
|
|
270 |
// Adding can be done only when on first slide.
|
|
271 |
if ( iHeaders[EHeaderAddressTo].iOwned )
|
|
272 |
{
|
|
273 |
return;
|
|
274 |
}
|
|
275 |
|
|
276 |
DoAddToViewL(EFalse); // do no read data
|
|
277 |
}
|
|
278 |
|
|
279 |
// ---------------------------------------------------------
|
|
280 |
// CUniEditorHeader::AddHeadersDeleteL
|
|
281 |
// ---------------------------------------------------------
|
|
282 |
//
|
|
283 |
void CUniEditorHeader::AddHeadersDeleteL( TInt aFlags,
|
|
284 |
TBool aContentModified)
|
|
285 |
{
|
|
286 |
if ( !aFlags )
|
|
287 |
{
|
|
288 |
return;
|
|
289 |
}
|
|
290 |
|
|
291 |
// Test whether on the first slide.
|
|
292 |
if ( !iHeaders[EHeaderAddressTo].iOwned )
|
|
293 |
{
|
|
294 |
RemoveFromViewL( aFlags );
|
|
295 |
}
|
|
296 |
|
|
297 |
for (TInt i = EHeaderAddressCc; i <= EHeaderAttachment; i++ )
|
|
298 |
{
|
|
299 |
TInt flag = EUniFeatureCc;
|
|
300 |
if ( i == EHeaderAddressBcc )
|
|
301 |
{
|
|
302 |
flag = EUniFeatureBcc;
|
|
303 |
}
|
|
304 |
else if ( i == EHeaderSubject )
|
|
305 |
{
|
|
306 |
flag = EUniFeatureSubject;
|
|
307 |
}
|
|
308 |
else if ( i == EHeaderAttachment )
|
|
309 |
{
|
|
310 |
flag = EUniFeatureAttachment;
|
|
311 |
}
|
|
312 |
|
|
313 |
if ( iHeaders[i].iOwned &&
|
|
314 |
aFlags & flag )
|
|
315 |
{
|
|
316 |
delete iHeaders[i].iControl;
|
|
317 |
iHeaders[i].iControl = NULL;
|
|
318 |
|
|
319 |
delete iHeaders[i].iAddressHandler;
|
|
320 |
iHeaders[i].iAddressHandler = NULL;
|
|
321 |
}
|
|
322 |
}
|
|
323 |
if ( aContentModified )
|
|
324 |
{
|
|
325 |
iView.SetControlsModified ( ETrue );
|
|
326 |
}
|
|
327 |
}
|
|
328 |
|
|
329 |
// ---------------------------------------------------------
|
|
330 |
// CUniEditorHeader::InsertRecipientL
|
|
331 |
// ---------------------------------------------------------
|
|
332 |
//
|
|
333 |
void CUniEditorHeader::InsertRecipientL(TAddressData& aData,
|
|
334 |
THeaderFields aRecipientType,
|
|
335 |
TBool aReadContent)
|
|
336 |
{
|
|
337 |
// cannot add existing control
|
|
338 |
__ASSERT_DEBUG( !aData.iControl, Panic( EUniIllegalArgument ) );
|
|
339 |
|
|
340 |
TInt res( R_UNIEDITOR_TO );
|
|
341 |
|
|
342 |
if ( aRecipientType == EHeaderAddressCc )
|
|
343 |
{
|
|
344 |
res = R_UNIEDITOR_CC;
|
|
345 |
}
|
|
346 |
else if ( aRecipientType == EHeaderAddressBcc )
|
|
347 |
{
|
|
348 |
res = R_UNIEDITOR_BCC;
|
|
349 |
}
|
|
350 |
else if ( aRecipientType != EHeaderAddressTo )
|
|
351 |
{
|
|
352 |
return;
|
|
353 |
}
|
|
354 |
|
|
355 |
iView.AddControlFromResourceL( res,
|
|
356 |
EMsgAddressControl,
|
|
357 |
ControlIndexForAdding( aRecipientType ),
|
|
358 |
EMsgHeader );
|
|
359 |
|
|
360 |
aData.iControl = static_cast<CMsgAddressControl*>
|
|
361 |
( iView.ControlById( aData.iControlType ) );
|
|
362 |
aData.iOwned = EFalse;
|
|
363 |
|
|
364 |
TBool addInvalidRecipient = EFalse;
|
|
365 |
|
|
366 |
if( TUniMsvEntry::IsMmsUpload( iMtm.Entry().Entry() ) )
|
|
367 |
{
|
|
368 |
aData.iControl->SetReadOnly( ETrue );
|
|
369 |
addInvalidRecipient = ETrue;
|
|
370 |
}
|
|
371 |
|
|
372 |
if( TUniMsvEntry::IsEditorOriented( iMtm.Entry().Entry() ) )
|
|
373 |
{
|
|
374 |
addInvalidRecipient = ETrue;
|
|
375 |
}
|
|
376 |
|
|
377 |
aData.iAddressHandler = CUniAddressHandler::NewL(
|
|
378 |
iMtm,
|
|
379 |
*static_cast<CMsgAddressControl*>(aData.iControl),
|
|
380 |
*( iView.ControlEnv() ) );
|
|
381 |
|
|
382 |
if ( aReadContent )
|
|
383 |
{
|
|
384 |
aData.iAddressHandler->CopyAddressesFromMtmL(aData.iRecipientTypeValue, addInvalidRecipient );
|
|
385 |
}
|
|
386 |
}
|
|
387 |
|
|
388 |
// ---------------------------------------------------------
|
|
389 |
// CUniEditorHeader::InsertSubjectL
|
|
390 |
// ---------------------------------------------------------
|
|
391 |
//
|
|
392 |
void CUniEditorHeader::InsertSubjectL( TBool aReadContent )
|
|
393 |
{
|
|
394 |
iView.AddControlFromResourceL( R_UNIEDITOR_SUBJECT,
|
|
395 |
EMsgExpandableControl,
|
|
396 |
ControlIndexForAdding( EHeaderSubject ),
|
|
397 |
EMsgHeader );
|
|
398 |
iHeaders[EHeaderSubject].iControl = static_cast<CMsgExpandableControl*>
|
|
399 |
( iView.ControlById( EMsgComponentIdSubject ) );
|
|
400 |
iHeaders[EHeaderSubject].iOwned = EFalse;
|
|
401 |
|
|
402 |
if ( aReadContent )
|
|
403 |
{
|
|
404 |
const TPtrC subject = iMtm.SubjectL();
|
|
405 |
if ( subject.Length() )
|
|
406 |
{
|
|
407 |
iHeaders[EHeaderSubject].iControl->Editor().SetTextL( &subject );
|
|
408 |
}
|
|
409 |
}
|
|
410 |
}
|
|
411 |
|
|
412 |
// ---------------------------------------------------------
|
|
413 |
// CUniEditorHeader::InsertAttachmentL
|
|
414 |
// ---------------------------------------------------------
|
|
415 |
//
|
|
416 |
void CUniEditorHeader::InsertAttachmentL( TBool aReadContent )
|
|
417 |
{
|
|
418 |
CMsgAttachmentControl* attachmentControl = CMsgAttachmentControl::NewL( iView, iView );
|
|
419 |
|
|
420 |
if ( iDoc.CurrentSlide() == 0 )
|
|
421 |
{
|
|
422 |
CleanupStack::PushL( attachmentControl );
|
|
423 |
iView.AddControlL( attachmentControl,
|
|
424 |
EMsgComponentIdAttachment,
|
|
425 |
ControlIndexForAdding( EHeaderAttachment ),
|
|
426 |
EMsgHeader );
|
|
427 |
CleanupStack::Pop( attachmentControl );
|
|
428 |
|
|
429 |
iHeaders[EHeaderAttachment].iControl =
|
|
430 |
static_cast<CMsgAttachmentControl*>( iView.ControlById( EMsgComponentIdAttachment ) );
|
|
431 |
|
|
432 |
iHeaders[EHeaderAttachment].iOwned = EFalse;
|
|
433 |
}
|
|
434 |
else
|
|
435 |
{
|
|
436 |
iHeaders[EHeaderAttachment].iControl = attachmentControl;
|
|
437 |
iHeaders[EHeaderAttachment].iOwned = ETrue;
|
|
438 |
}
|
|
439 |
|
|
440 |
if ( aReadContent )
|
|
441 |
{
|
|
442 |
CUniObjectList& attaList = iDoc.DataModel()->AttachmentList();
|
|
443 |
|
|
444 |
for( TInt index = 0; index < attaList.Count(); index++ )
|
|
445 |
{
|
|
446 |
TParsePtrC fileParser( attaList.GetByIndex( index )->MediaInfo()->FullFilePath() );
|
|
447 |
|
|
448 |
attachmentControl->AppendAttachmentL( fileParser.NameAndExt() );
|
|
449 |
}
|
|
450 |
|
|
451 |
}
|
|
452 |
}
|
|
453 |
|
|
454 |
// ---------------------------------------------------------
|
|
455 |
// CUniEditorHeader::RemoveAttachmentL
|
|
456 |
// ---------------------------------------------------------
|
|
457 |
//
|
|
458 |
void CUniEditorHeader::RemoveAttachmentL()
|
|
459 |
{
|
|
460 |
if ( iDoc.CurrentSlide() == 0 )
|
|
461 |
{
|
|
462 |
iView.DeleteControlL( EMsgComponentIdAttachment );
|
|
463 |
}
|
|
464 |
else
|
|
465 |
{
|
|
466 |
delete iHeaders[EHeaderAttachment].iControl;
|
|
467 |
}
|
|
468 |
|
|
469 |
iHeaders[EHeaderAttachment].iControl = NULL;
|
|
470 |
iHeaders[EHeaderAttachment].iOwned = EFalse;
|
|
471 |
}
|
|
472 |
|
|
473 |
// ---------------------------------------------------------
|
|
474 |
// CUniEditorHeader::CopyAddressesToMtmL
|
|
475 |
// ---------------------------------------------------------
|
|
476 |
//
|
|
477 |
TBool CUniEditorHeader::CopyAddressesToMtmL( TBool aDocumentHeaderModified)
|
|
478 |
{
|
|
479 |
TBool modified = EFalse;
|
|
480 |
if ( aDocumentHeaderModified )
|
|
481 |
{
|
|
482 |
modified = ETrue;
|
|
483 |
}
|
|
484 |
if ( modified )
|
|
485 |
{
|
|
486 |
// variation has changed On->Off and message opened from Drafts
|
|
487 |
iHeaders[EHeaderAddressTo].iAddressHandler->
|
|
488 |
RemoveAddressesFromMtmL( iHeaders[EHeaderAddressTo].iRecipientTypeValue );
|
|
489 |
iHeaders[EHeaderAddressTo].iAddressHandler->
|
|
490 |
RemoveAddressesFromMtmL( iHeaders[EHeaderAddressCc].iRecipientTypeValue );
|
|
491 |
iHeaders[EHeaderAddressTo].iAddressHandler->
|
|
492 |
RemoveAddressesFromMtmL( iHeaders[EHeaderAddressBcc].iRecipientTypeValue );
|
|
493 |
}
|
|
494 |
for (TInt i = EHeaderAddressTo; i <= EHeaderAddressBcc ; i++ )
|
|
495 |
{
|
|
496 |
// all or nothing
|
|
497 |
if ( iHeaders[i].iControl
|
|
498 |
&& modified )
|
|
499 |
{
|
|
500 |
if ( iHeaders[i].iAddressHandler )
|
|
501 |
{
|
|
502 |
iHeaders[i].iAddressHandler->CopyAddressesToMtmL(
|
|
503 |
iHeaders[i].iRecipientTypeValue);
|
|
504 |
}
|
|
505 |
modified = ETrue;
|
|
506 |
}
|
|
507 |
}
|
|
508 |
return modified;
|
|
509 |
}
|
|
510 |
|
|
511 |
// ---------------------------------------------------------
|
|
512 |
// CUniEditorHeader::CopyHeadersToMtmL
|
|
513 |
// ---------------------------------------------------------
|
|
514 |
//
|
|
515 |
TBool CUniEditorHeader::CopyHeadersToMtmL( TBool aDocumentHeaderModified,
|
|
516 |
TBool aSaveToMtm )
|
|
517 |
{
|
|
518 |
TBool modified = EFalse;
|
|
519 |
if ( aDocumentHeaderModified )
|
|
520 |
{
|
|
521 |
modified = ETrue;
|
|
522 |
}
|
|
523 |
CMsgExpandableControl* subj = iHeaders[EHeaderSubject].iControl;
|
|
524 |
|
|
525 |
if ( subj && modified )
|
|
526 |
{
|
|
527 |
TInt length = subj->TextContent().DocumentLength();
|
|
528 |
|
|
529 |
if( length )
|
|
530 |
{
|
|
531 |
TBuf<KUniMaxSubject> description;
|
|
532 |
description.Zero();
|
|
533 |
|
|
534 |
// Copying as pure text from the editor which may contain emoticons.
|
|
535 |
|
|
536 |
HBufC *text = subj->Editor().GetTextInHBufL();
|
|
537 |
CleanupStack::PushL( text );
|
|
538 |
description.Copy( text->Ptr(), length );
|
|
539 |
CleanupStack::PopAndDestroy( text );
|
|
540 |
iMtm.SetSubjectL( description );
|
|
541 |
modified = ETrue;
|
|
542 |
}
|
|
543 |
else
|
|
544 |
{
|
|
545 |
iMtm.SetSubjectL( KNullDesC() );
|
|
546 |
}
|
|
547 |
}
|
|
548 |
// variation has changed On->Off and message opened from Drafts
|
|
549 |
else if ( modified )
|
|
550 |
{
|
|
551 |
iMtm.SetSubjectL( KNullDesC() );
|
|
552 |
}
|
|
553 |
|
|
554 |
modified = CopyAddressesToMtmL (modified);
|
|
555 |
if ( modified
|
|
556 |
&& aSaveToMtm )
|
|
557 |
{
|
|
558 |
iMtm.SaveMessageL();
|
|
559 |
}
|
|
560 |
|
|
561 |
return modified;
|
|
562 |
}
|
|
563 |
|
|
564 |
// ---------------------------------------------------------
|
|
565 |
// CUniEditorHeader::VerifyAddressesL
|
|
566 |
// ---------------------------------------------------------
|
|
567 |
//
|
|
568 |
TBool CUniEditorHeader::VerifyAddressesL( TBool& aModified, TBool aAcceptEmails )
|
|
569 |
{
|
|
570 |
aModified = EFalse;
|
|
571 |
TBool modified = EFalse;
|
|
572 |
TBool ret = ETrue;
|
|
573 |
for (TInt i = EHeaderAddressTo; i <= EHeaderAddressBcc ; i++ )
|
|
574 |
{
|
|
575 |
// all or nothing
|
|
576 |
if ( iHeaders[i].iAddressHandler )
|
|
577 |
{
|
|
578 |
CMsgCheckNames::TMsgAddressSelectType
|
|
579 |
msgType = aAcceptEmails?CMsgCheckNames::EMsgTypeMms:CMsgCheckNames::EMsgTypeSms;
|
|
580 |
iHeaders[i].iAddressHandler->SetValidAddressType( msgType );
|
|
581 |
TBool retTemp = iHeaders[i].iAddressHandler->VerifyAddressesL( modified );
|
|
582 |
if ( modified )
|
|
583 |
{
|
|
584 |
aModified = ETrue;
|
|
585 |
}
|
|
586 |
if ( !retTemp )
|
|
587 |
{
|
|
588 |
// unvalidated addresses
|
|
589 |
ret = EFalse;
|
|
590 |
break;
|
|
591 |
}
|
|
592 |
}
|
|
593 |
}
|
|
594 |
return ret;
|
|
595 |
}
|
|
596 |
|
|
597 |
// ---------------------------------------------------------
|
|
598 |
// CUniEditorHeader::NeedsVerificationL
|
|
599 |
// ---------------------------------------------------------
|
|
600 |
//
|
|
601 |
TBool CUniEditorHeader::NeedsVerificationL()
|
|
602 |
{
|
|
603 |
CMsgRecipientArray* recipients = NULL;
|
|
604 |
for (TInt currentHeader = EHeaderAddressTo; currentHeader <= EHeaderAddressBcc ; currentHeader++ )
|
|
605 |
{
|
|
606 |
// all or nothing
|
|
607 |
if ( iHeaders[currentHeader].iAddressHandler )
|
|
608 |
{
|
|
609 |
recipients =
|
|
610 |
static_cast<CMsgAddressControl*>( iHeaders[currentHeader].iControl )->GetRecipientsL();
|
|
611 |
|
|
612 |
for( TInt currentRecipient = 0; currentRecipient < recipients->Count(); currentRecipient++ )
|
|
613 |
{
|
|
614 |
if( !(recipients->At( currentRecipient )->IsVerified() ) )
|
|
615 |
{
|
|
616 |
return ETrue;
|
|
617 |
}
|
|
618 |
}
|
|
619 |
}
|
|
620 |
}
|
|
621 |
return EFalse;
|
|
622 |
}
|
|
623 |
|
|
624 |
// ---------------------------------------------------------
|
|
625 |
// CUniEditorHeader::AddRecipientL
|
|
626 |
// ---------------------------------------------------------
|
|
627 |
//
|
|
628 |
TBool CUniEditorHeader::AddRecipientL( CMsgBaseControl* aFocusedControl,
|
|
629 |
MObjectProvider* /*aParent*/,
|
|
630 |
TBool aIncludeEmailAddresses,
|
|
631 |
TBool& aInvalid )
|
|
632 |
{
|
|
633 |
TBool added = EFalse;
|
|
634 |
|
|
635 |
// note order of for ()
|
|
636 |
for ( TInt i = EHeaderAddressBcc; i >= EHeaderAddressTo ; i-- )
|
|
637 |
{
|
|
638 |
CMsgCheckNames::TMsgAddressSelectType msgType = aIncludeEmailAddresses ? CMsgCheckNames::EMsgTypeMms:
|
|
639 |
CMsgCheckNames::EMsgTypeSms;
|
|
640 |
if ( iHeaders[i].iControl == aFocusedControl &&
|
|
641 |
iHeaders[i].iAddressHandler )
|
|
642 |
{
|
|
643 |
iHeaders[i].iAddressHandler->SetValidAddressType( msgType );
|
|
644 |
added = iHeaders[i].iAddressHandler->AddRecipientL( aInvalid );
|
|
645 |
break;
|
|
646 |
}
|
|
647 |
|
|
648 |
// if focus on any other control, add to To: recipient list
|
|
649 |
if ( i == EHeaderAddressTo &&
|
|
650 |
iHeaders[EHeaderAddressTo].iAddressHandler )
|
|
651 |
{
|
|
652 |
iHeaders[i].iAddressHandler->SetValidAddressType( msgType );
|
|
653 |
added = iHeaders[i].iAddressHandler->AddRecipientL( aInvalid );
|
|
654 |
}
|
|
655 |
}
|
|
656 |
|
|
657 |
return added;
|
|
658 |
}
|
|
659 |
|
|
660 |
// ---------------------------------------------------------
|
|
661 |
// CUniEditorHeader::RemoveDuplicateAddressesL
|
|
662 |
// ---------------------------------------------------------
|
|
663 |
//
|
|
664 |
TBool CUniEditorHeader::RemoveDuplicateAddressesL()
|
|
665 |
{
|
|
666 |
TBool retVal = EFalse;
|
|
667 |
CArrayPtrFlat<CMsgAddressControl>* addressControls = new ( ELeave ) CArrayPtrFlat<CMsgAddressControl>( 3 );
|
|
668 |
CleanupStack::PushL( addressControls );
|
|
669 |
|
|
670 |
if ( AddressControl( CUniBaseHeader::EHeaderAddressTo ) )
|
|
671 |
{
|
|
672 |
addressControls->AppendL( AddressControl( CUniBaseHeader::EHeaderAddressTo ) );
|
|
673 |
}
|
|
674 |
if ( AddressControl( CUniBaseHeader::EHeaderAddressCc ) )
|
|
675 |
{
|
|
676 |
addressControls->AppendL( AddressControl( CUniBaseHeader::EHeaderAddressCc ) );
|
|
677 |
}
|
|
678 |
if ( AddressControl( CUniBaseHeader::EHeaderAddressBcc ) )
|
|
679 |
{
|
|
680 |
addressControls->AppendL( AddressControl( CUniBaseHeader::EHeaderAddressBcc ) );
|
|
681 |
}
|
|
682 |
|
|
683 |
retVal = CUniAddressHandler::RemoveDuplicateAddressesL( *addressControls );
|
|
684 |
CleanupStack::PopAndDestroy( addressControls );
|
|
685 |
return retVal;
|
|
686 |
}
|
|
687 |
|
|
688 |
// ---------------------------------------------------------
|
|
689 |
// CUniEditorHeader::IsHeaderSmsL
|
|
690 |
// ---------------------------------------------------------
|
|
691 |
//
|
|
692 |
TBool CUniEditorHeader::IsHeaderSmsL()
|
|
693 |
{
|
|
694 |
// Is one of the following visible and do they have content
|
|
695 |
CMsgRecipientArray* recipients = NULL;
|
|
696 |
|
|
697 |
if ( iHeaders[EHeaderAddressCc].iControl )
|
|
698 |
{
|
|
699 |
// CC is visible
|
|
700 |
recipients = static_cast<CMsgAddressControl*>( iHeaders[EHeaderAddressCc].iControl )->GetRecipientsL();
|
|
701 |
|
|
702 |
if ( recipients &&
|
|
703 |
recipients->Count() > 0 )
|
|
704 |
{
|
|
705 |
// There are recipients -> this is not sms
|
|
706 |
iLongestEmail = 0;
|
|
707 |
return EFalse;
|
|
708 |
}
|
|
709 |
}
|
|
710 |
|
|
711 |
if ( iHeaders[EHeaderAddressBcc].iControl )
|
|
712 |
{
|
|
713 |
// BCC is visible
|
|
714 |
recipients = static_cast<CMsgAddressControl*>( iHeaders[EHeaderAddressBcc].iControl )->GetRecipientsL();
|
|
715 |
|
|
716 |
if ( recipients &&
|
|
717 |
recipients->Count() > 0 )
|
|
718 |
{ // there are recipients -> this is not sms
|
|
719 |
iLongestEmail = 0;
|
|
720 |
return EFalse;
|
|
721 |
}
|
|
722 |
}
|
|
723 |
|
|
724 |
// Are there too many recipients in To field?
|
|
725 |
if ( iHeaders[CUniEditorHeader::EHeaderAddressTo].iControl )
|
|
726 |
{
|
|
727 |
recipients = static_cast<CMsgAddressControl*>( iHeaders[EHeaderAddressTo].iControl )->GetRecipientsL();
|
|
728 |
|
|
729 |
if ( recipients &&
|
|
730 |
recipients->Count() > iDoc.MaxSmsRecipients() )
|
|
731 |
{
|
|
732 |
iLongestEmail = 0;
|
|
733 |
return EFalse;
|
|
734 |
}
|
|
735 |
|
|
736 |
// Refresh the longest email address length
|
|
737 |
RefreshLongestEmailAddressL();
|
|
738 |
|
|
739 |
if ( !iDoc.EmailOverSmsSupported() )
|
|
740 |
{
|
|
741 |
for ( TInt i = 0; i < recipients->Count(); i++ )
|
|
742 |
{
|
|
743 |
if ( IsValidEmailAddress( recipients->At( i )->Address()->Des() ) )
|
|
744 |
{
|
|
745 |
return EFalse;
|
|
746 |
}
|
|
747 |
}
|
|
748 |
}
|
|
749 |
}
|
|
750 |
return ETrue;
|
|
751 |
}
|
|
752 |
|
|
753 |
// ---------------------------------------------------------
|
|
754 |
// CUniEditorHeader::ObjectAddedL
|
|
755 |
// ---------------------------------------------------------
|
|
756 |
//
|
|
757 |
void CUniEditorHeader::ObjectAddedL( CUniObjectList* aList,
|
|
758 |
CUniObject* aObject,
|
|
759 |
TInt aIndex )
|
|
760 |
{
|
|
761 |
if ( aObject &&
|
|
762 |
aList == &iDoc.DataModel()->AttachmentList() )
|
|
763 |
{
|
|
764 |
if ( !iHeaders[CUniEditorHeader::EHeaderAttachment].iControl )
|
|
765 |
{
|
|
766 |
InsertAttachmentL( EFalse );
|
|
767 |
}
|
|
768 |
|
|
769 |
CMsgAttachmentControl* attachmentControl =
|
|
770 |
static_cast<CMsgAttachmentControl*>(
|
|
771 |
iHeaders[CUniEditorHeader::EHeaderAttachment].iControl );
|
|
772 |
|
|
773 |
TParsePtrC fileParser( aObject->MediaInfo()->FullFilePath() );
|
|
774 |
|
|
775 |
attachmentControl->InsertAttachmentL( fileParser.NameAndExt(), aIndex );
|
|
776 |
}
|
|
777 |
}
|
|
778 |
|
|
779 |
// ---------------------------------------------------------
|
|
780 |
// CUniEditorHeader::ObjectRemovedL
|
|
781 |
// ---------------------------------------------------------
|
|
782 |
//
|
|
783 |
void CUniEditorHeader::ObjectRemovedL( CUniObjectList* aList,
|
|
784 |
CUniObject* aObject,
|
|
785 |
TInt aIndex )
|
|
786 |
{
|
|
787 |
if ( aObject &&
|
|
788 |
aList == &iDoc.DataModel()->AttachmentList() )
|
|
789 |
{
|
|
790 |
CMsgAttachmentControl* attachmentControl =
|
|
791 |
static_cast<CMsgAttachmentControl*>(
|
|
792 |
iHeaders[CUniEditorHeader::EHeaderAttachment].iControl );
|
|
793 |
|
|
794 |
if ( attachmentControl )
|
|
795 |
{
|
|
796 |
TParsePtrC fileParser( aObject->MediaInfo()->FullFilePath() );
|
|
797 |
TPtrC plainFileName = fileParser.NameAndExt();
|
|
798 |
|
|
799 |
HBufC* attachmentName = attachmentControl->Attachment( aIndex ).AllocLC();
|
|
800 |
|
|
801 |
if ( plainFileName.Match( *attachmentName ) )
|
|
802 |
{
|
|
803 |
attachmentControl->RemoveAttachmentL( aIndex );
|
|
804 |
}
|
|
805 |
else
|
|
806 |
{
|
|
807 |
attachmentControl->RemoveAttachmentL( plainFileName );
|
|
808 |
}
|
|
809 |
|
|
810 |
CleanupStack::PopAndDestroy( attachmentName );
|
|
811 |
}
|
|
812 |
|
|
813 |
if ( aList->Count() == 0 )
|
|
814 |
{
|
|
815 |
RemoveAttachmentL();
|
|
816 |
}
|
|
817 |
}
|
|
818 |
}
|
|
819 |
|
|
820 |
// ---------------------------------------------------------
|
|
821 |
// CUniEditorHeader::RefreshLongestEmailAddressL
|
|
822 |
// ---------------------------------------------------------
|
|
823 |
//
|
|
824 |
void CUniEditorHeader::RefreshLongestEmailAddressL()
|
|
825 |
{
|
|
826 |
TInt longestOne = 0;
|
|
827 |
if ( iDoc.EmailOverSmsSupported() && iHeaders[CUniEditorHeader::EHeaderAddressTo].iControl )
|
|
828 |
{
|
|
829 |
CMsgRecipientArray* recipients = NULL;
|
|
830 |
recipients = static_cast<CMsgAddressControl*>
|
|
831 |
( iHeaders[CUniEditorHeader::EHeaderAddressTo].iControl )->GetRecipientsL();
|
|
832 |
for( TInt i = 0; i < recipients->Count(); i++ )
|
|
833 |
{
|
|
834 |
if( IsValidEmailAddress( recipients->At( i )->Address()->Des() ) )
|
|
835 |
{
|
|
836 |
if( recipients->At( i )->Address()->Length() > longestOne )
|
|
837 |
{
|
|
838 |
longestOne = recipients->At( i )->Address()->Length();
|
|
839 |
}
|
|
840 |
}
|
|
841 |
}
|
|
842 |
}
|
|
843 |
iLongestEmail = longestOne;
|
|
844 |
}
|
|
845 |
|
|
846 |
// ---------------------------------------------------------
|
|
847 |
// CUniEditorHeader::ControlIndexForAdding
|
|
848 |
// ---------------------------------------------------------
|
|
849 |
//
|
|
850 |
TInt CUniEditorHeader::ControlIndexForAdding( TInt aControlToAdd )
|
|
851 |
{
|
|
852 |
TInt index = 0;
|
|
853 |
switch( aControlToAdd )
|
|
854 |
{
|
|
855 |
case EHeaderAttachment:
|
|
856 |
{
|
|
857 |
if ( iHeaders[EHeaderSubject].iControl &&
|
|
858 |
iHeaders[EHeaderSubject].iControl->IsVisible() )
|
|
859 |
{
|
|
860 |
index++;
|
|
861 |
}
|
|
862 |
} // Ok to flow thru
|
|
863 |
case EHeaderSubject:
|
|
864 |
{
|
|
865 |
if ( iHeaders[EHeaderAddressBcc].iControl &&
|
|
866 |
iHeaders[EHeaderAddressBcc].iControl->IsVisible() )
|
|
867 |
{
|
|
868 |
index++;
|
|
869 |
}
|
|
870 |
} // Ok to flow thru
|
|
871 |
case EHeaderAddressBcc:
|
|
872 |
{
|
|
873 |
if ( iHeaders[EHeaderAddressCc].iControl &&
|
|
874 |
iHeaders[EHeaderAddressCc].iControl->IsVisible() )
|
|
875 |
{
|
|
876 |
index++;
|
|
877 |
}
|
|
878 |
} // Ok to flow thru
|
|
879 |
case EHeaderAddressCc:
|
|
880 |
{
|
|
881 |
if ( iHeaders[EHeaderAddressTo].iControl &&
|
|
882 |
iHeaders[EHeaderAddressTo].iControl->IsVisible() )
|
|
883 |
{
|
|
884 |
index++;
|
|
885 |
}
|
|
886 |
|
|
887 |
break;
|
|
888 |
}
|
|
889 |
default:
|
|
890 |
{
|
|
891 |
break;
|
|
892 |
}
|
|
893 |
}
|
|
894 |
|
|
895 |
return index;
|
|
896 |
}
|
|
897 |
|
|
898 |
// ---------------------------------------------------------
|
|
899 |
// CUniEditorHeader::ShowInvalidContactNotesL
|
|
900 |
// ---------------------------------------------------------
|
|
901 |
//
|
|
902 |
void CUniEditorHeader::ShowInvalidContactNotesL()
|
|
903 |
{
|
|
904 |
for (TInt i = EHeaderAddressTo; i <= EHeaderAddressBcc ; i++ )
|
|
905 |
{
|
|
906 |
// all or nothing
|
|
907 |
if ( iHeaders[i].iAddressHandler )
|
|
908 |
{
|
|
909 |
iHeaders[i].iAddressHandler->ShowInvalidRecipientInfoNotesL();
|
|
910 |
}
|
|
911 |
}
|
|
912 |
}
|
|
913 |
|
|
914 |
// ---------------------------------------------------------
|
|
915 |
// CUniEditorHeader::IsValidEmailAddress
|
|
916 |
// ---------------------------------------------------------
|
|
917 |
//
|
|
918 |
TBool CUniEditorHeader::IsValidEmailAddress( const TDesC& aAddress )
|
|
919 |
{
|
|
920 |
// valid email address contains at least 3 characters
|
|
921 |
if( aAddress.Length() >= 3 )
|
|
922 |
{
|
|
923 |
// search for @ from the address. however, it can't be the first or the last item
|
|
924 |
for ( TInt i = 1; i < aAddress.Length() - 1; i++ )
|
|
925 |
{
|
|
926 |
if ( aAddress[ i ] == KUniCharAt )
|
|
927 |
{
|
|
928 |
return ETrue;
|
|
929 |
}
|
|
930 |
}
|
|
931 |
}
|
|
932 |
return EFalse;
|
|
933 |
}
|
|
934 |
|
|
935 |
|
|
936 |
|
|
937 |
|
|
938 |
// End of File
|