|
1 /* |
|
2 * Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * MMS viewer header |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 |
|
23 #include <eikrted.h> |
|
24 |
|
25 #include <commonphoneparser.h> |
|
26 |
|
27 #include <mmsgenutils.h> |
|
28 #include <mmsmsventry.h> |
|
29 |
|
30 #include <messagingvariant.hrh> |
|
31 |
|
32 #include <MsgExpandableControl.h> |
|
33 #include <MsgAddressControl.h> |
|
34 |
|
35 #include <MmsViewer.rsg> |
|
36 #include "MmsViewer.hrh" |
|
37 #include "MmsViewerHeader.h" |
|
38 |
|
39 #include <mmsclient.h> |
|
40 #include <MsgMediaInfo.h> |
|
41 #include <MsgAttachmentControl.h> |
|
42 #include <uniaddresshandler.h> |
|
43 #include <uniobjectlist.h> |
|
44 #include "UniMmsViewerDocument.h" |
|
45 |
|
46 |
|
47 // ========================================================== |
|
48 |
|
49 // EXTERNAL DATA STRUCTURES |
|
50 |
|
51 // EXTERNAL FUNCTION PROTOTYPES |
|
52 |
|
53 // CONSTANTS |
|
54 |
|
55 // MACROS |
|
56 |
|
57 // LOCAL CONSTANTS AND MACROS |
|
58 |
|
59 // MODULE DATA STRUCTURES |
|
60 |
|
61 // LOCAL FUNCTION PROTOTYPES |
|
62 GLREF_C void Panic( TMmsViewerExceptions aPanic ); |
|
63 |
|
64 // ================= MEMBER FUNCTIONS ======================= |
|
65 |
|
66 // --------------------------------------------------------- |
|
67 // CMmsViewerHeader::CMmsViewerHeader |
|
68 // |
|
69 // Constructor. |
|
70 // --------------------------------------------------------- |
|
71 // |
|
72 CMmsViewerHeader::CMmsViewerHeader( CMmsClientMtm& aMtm, |
|
73 CUniObjectList& aAttachmentList, |
|
74 CMsgEditorView& aView, |
|
75 RFs& aFs ) |
|
76 : CUniBaseHeader( aMtm, aView, aFs ), |
|
77 iAttachmentList( aAttachmentList ) |
|
78 { |
|
79 } |
|
80 |
|
81 |
|
82 // --------------------------------------------------------- |
|
83 // CMmsViewerHeader::ConstructL |
|
84 // |
|
85 // |
|
86 // --------------------------------------------------------- |
|
87 // |
|
88 void CMmsViewerHeader::ConstructL( ) |
|
89 { |
|
90 |
|
91 AddHeadersVariationL( EFalse ); |
|
92 AddHeadersConfigL( ); |
|
93 |
|
94 // subject is shown, if configured or contains data |
|
95 // (even if variated off ) |
|
96 const TPtrC subject = iMtm.SubjectL(); |
|
97 if ( iAddHeadersConfig & EUniFeatureSubject |
|
98 || subject.Length() ) |
|
99 { |
|
100 iAddDelayed |= EUniFeatureSubject; |
|
101 } |
|
102 iAddDelayed |= EUniFeatureAttachment; |
|
103 TBool mobileTerminated( ETrue ); |
|
104 TInt addressesInStore = MtmAddressTypes(); |
|
105 |
|
106 TMmsMsvEntry mmsEntry = |
|
107 static_cast<TMmsMsvEntry>( iMtm.Entry().Entry() ); |
|
108 mobileTerminated = mmsEntry.IsMobileTerminated(); |
|
109 if ( mobileTerminated ) |
|
110 { |
|
111 iAddDelayed |= EUniFeatureFrom; |
|
112 } |
|
113 else |
|
114 { |
|
115 // see also below necessity of the To: field |
|
116 if ( addressesInStore & EUniFeatureTo ) |
|
117 { |
|
118 iAddDelayed |= EUniFeatureTo; |
|
119 } |
|
120 |
|
121 if ( iAddHeadersVariation & EUniFeatureCc |
|
122 && addressesInStore & EUniFeatureCc ) |
|
123 { |
|
124 // variated on and contains data |
|
125 iAddDelayed |= EUniFeatureCc; |
|
126 } |
|
127 // show in the other field if variated off |
|
128 else if ( ! ( iAddHeadersVariation & EUniFeatureCc ) |
|
129 && addressesInStore & EUniFeatureCc ) |
|
130 { |
|
131 // Cc: data exists, add it into To: |
|
132 iAddDelayed |= EUniFeatureTo; |
|
133 iAddIntoOtherCc |= EUniFeatureTo; |
|
134 } |
|
135 |
|
136 if ( iAddHeadersVariation & EUniFeatureBcc |
|
137 && addressesInStore & EUniFeatureBcc ) |
|
138 { |
|
139 // variated on and contains data |
|
140 iAddDelayed |= EUniFeatureBcc; |
|
141 } |
|
142 // show in the other field if variated off |
|
143 else if ( ! ( iAddHeadersVariation & EUniFeatureBcc ) |
|
144 && addressesInStore & EUniFeatureBcc ) |
|
145 { |
|
146 if ( iAddHeadersVariation & EUniFeatureCc ) |
|
147 { |
|
148 // Bcc: data exists, add it into Cc: |
|
149 iAddDelayed |= EUniFeatureCc; |
|
150 iAddIntoOtherBcc |= EUniFeatureCc; |
|
151 } |
|
152 else |
|
153 { |
|
154 // No Cc:, must be added into To: |
|
155 iAddDelayed |= EUniFeatureTo; |
|
156 iAddIntoOtherBcc |= EUniFeatureTo; |
|
157 } |
|
158 } |
|
159 |
|
160 } |
|
161 DoAddToViewL( ETrue ); |
|
162 } |
|
163 |
|
164 // --------------------------------------------------------- |
|
165 // CMmsViewerHeader::NewL |
|
166 // |
|
167 // Two-phased constructor. |
|
168 // --------------------------------------------------------- |
|
169 // |
|
170 CMmsViewerHeader* CMmsViewerHeader::NewL( CMmsClientMtm& aMtm, |
|
171 CUniObjectList& aAttachmentList, |
|
172 CMsgEditorView& aView, |
|
173 RFs& aFs ) |
|
174 { |
|
175 CMmsViewerHeader* self = new ( ELeave ) CMmsViewerHeader( |
|
176 aMtm, aAttachmentList, aView, aFs ); |
|
177 CleanupStack::PushL( self ); |
|
178 self->ConstructL( ); |
|
179 CleanupStack::Pop( self ); |
|
180 return self; |
|
181 } |
|
182 |
|
183 // --------------------------------------------------------- |
|
184 // CMmsViewerHeader::~CMmsViewerHeader |
|
185 // --------------------------------------------------------- |
|
186 CMmsViewerHeader::~CMmsViewerHeader() |
|
187 { |
|
188 delete iAlias; |
|
189 } |
|
190 |
|
191 // --------------------------------------------------------- |
|
192 // InsertRecipientL |
|
193 // --------------------------------------------------------- |
|
194 void CMmsViewerHeader::InsertRecipientL(TAddressData& aData, |
|
195 THeaderFields aRecipientType, |
|
196 TBool aReadContent) |
|
197 { |
|
198 TInt res( R_MMSVIEWER_TO ); |
|
199 TInt flag( EUniFeatureTo ); |
|
200 |
|
201 if ( aRecipientType == EHeaderAddressCc ) |
|
202 { |
|
203 res = R_MMSVIEWER_CC; |
|
204 flag = EUniFeatureCc; |
|
205 } |
|
206 else if ( aRecipientType == EHeaderAddressBcc ) |
|
207 { |
|
208 res = R_MMSVIEWER_BCC; |
|
209 flag = EUniFeatureBcc; |
|
210 } |
|
211 else if ( aRecipientType != EHeaderAddressTo ) |
|
212 { |
|
213 return; |
|
214 } |
|
215 |
|
216 DoInsertRecipientL( aData, |
|
217 res, |
|
218 aReadContent, |
|
219 flag ); // read from MTM |
|
220 } |
|
221 |
|
222 // --------------------------------------------------------- |
|
223 // DoInsertRecipientL |
|
224 // --------------------------------------------------------- |
|
225 void CMmsViewerHeader::DoInsertRecipientL( TAddressData& aData, |
|
226 TInt aResource, |
|
227 TBool /*aReadContent*/, |
|
228 TInt aAddHeadersRecipientType ) |
|
229 { |
|
230 // cannot add existing control |
|
231 __ASSERT_DEBUG( !aData.iControl, Panic( EMmsViewerNullPointer ) ); |
|
232 |
|
233 const CMsvRecipientList& addresses = iMtm.AddresseeList(); |
|
234 iView.AddControlFromResourceL( aResource, |
|
235 EMsgAddressControl, |
|
236 EMsgAppendControl, |
|
237 EMsgHeader ); |
|
238 aData.iControl = static_cast<CMsgAddressControl*> |
|
239 ( iView.ControlById( aData.iControlType ) ); |
|
240 aData.iOwned = EFalse; |
|
241 |
|
242 CMsgRecipientList* recipientList = CMsgRecipientList::NewL(); |
|
243 CleanupStack::PushL( recipientList ); |
|
244 |
|
245 TInt count = addresses.Count(); |
|
246 TMsvRecipientTypeValues msvRecipientType( aData.iRecipientTypeValue ); |
|
247 for (TInt k = aData.iRecipientTypeValue; k <= EMsvRecipientBcc ; k++ ) |
|
248 { |
|
249 // on the first round copy 'native' addresses then additional headers |
|
250 if ( k == 1 |
|
251 && iAddIntoOtherCc & aAddHeadersRecipientType ) |
|
252 { |
|
253 msvRecipientType = EMsvRecipientCc; |
|
254 } |
|
255 else if ( k == 2 |
|
256 && iAddIntoOtherBcc & aAddHeadersRecipientType ) |
|
257 { |
|
258 msvRecipientType = EMsvRecipientBcc; |
|
259 } |
|
260 if ( k > aData.iRecipientTypeValue |
|
261 && msvRecipientType == aData.iRecipientTypeValue ) |
|
262 { |
|
263 // no update in the initial value |
|
264 continue; |
|
265 } |
|
266 |
|
267 for ( TInt i = 0; i < count; i++) |
|
268 { |
|
269 if ( addresses.Type(i) == msvRecipientType ) |
|
270 { |
|
271 CMsgRecipientItem* recipient = CMsgRecipientItem::NewLC( |
|
272 TMmsGenUtils::Alias( addresses[i] ), |
|
273 TMmsGenUtils::PureAddress( addresses[i] ) ); |
|
274 recipient->SetVerified( ETrue ); |
|
275 recipientList->AppendL( recipient ); |
|
276 CleanupStack::Pop( recipient ); |
|
277 recipient = NULL; |
|
278 } |
|
279 } |
|
280 } |
|
281 static_cast<CMsgAddressControl*>( aData.iControl )->AddRecipientsL( *recipientList ); |
|
282 aData.iControl->Editor().SetCursorPosL( 0, EFalse ); |
|
283 |
|
284 CleanupStack::PopAndDestroy( recipientList ); |
|
285 } |
|
286 |
|
287 // --------------------------------------------------------- |
|
288 // InsertFromL |
|
289 // --------------------------------------------------------- |
|
290 void CMmsViewerHeader::InsertFromL( TBool /*aReadContent*/ ) |
|
291 { |
|
292 iView.AddControlFromResourceL( R_MMSVIEWER_FROM, EMsgAddressControl, EMsgAppendControl, EMsgHeader ); |
|
293 iHeaders[EHeaderAddressFrom].iControl = static_cast<CMsgAddressControl*> |
|
294 ( iView.ControlById( EMsgComponentIdFrom ) ); |
|
295 iHeaders[EHeaderAddressFrom].iOwned = EFalse; |
|
296 |
|
297 const TPtrC sender = static_cast<CMmsClientMtm&>(iMtm).Sender(); |
|
298 const TPtrC details = iMtm.Entry().Entry().iDetails; |
|
299 |
|
300 if ( sender.Length() ) |
|
301 { |
|
302 iSenderType = MsvUiServiceUtilitiesInternal::ResolveAddressTypeL( |
|
303 TMmsGenUtils::PureAddress( sender ), |
|
304 CommonPhoneParser::ESMSNumber ); |
|
305 |
|
306 if ( iSenderType != EMuiuAddressTypePhoneNumber ) |
|
307 { |
|
308 //We trust on that there won't be illegal addresses |
|
309 //in received messages |
|
310 iSenderType = EMuiuAddressTypeEmail; |
|
311 } |
|
312 |
|
313 //Check if MMS engine has put an alias into iDetails field |
|
314 if ( sender.Compare( details ) != 0 ) |
|
315 { |
|
316 TPtrC alias = KNullDesC(); |
|
317 if ( details.Length() && !iAlias ) |
|
318 { |
|
319 iAlias = details.AllocL( ); |
|
320 alias.Set( *iAlias ); |
|
321 } |
|
322 |
|
323 // Resolve whether this is remote alias. Local alias takes precedence |
|
324 TPtrC tempAlias( TMmsGenUtils::Alias( sender ) ); |
|
325 if ( iAlias |
|
326 && tempAlias.Length() |
|
327 && !tempAlias.CompareF( *iAlias ) ) |
|
328 |
|
329 { |
|
330 iRemoteAlias = ETrue; |
|
331 } |
|
332 |
|
333 MVPbkContactLink* link = NULL; |
|
334 static_cast<CMsgAddressControl*>( iHeaders[EHeaderAddressFrom].iControl ) |
|
335 ->AddRecipientL( alias, |
|
336 TMmsGenUtils::PureAddress( sender ), |
|
337 ETrue, |
|
338 link ); |
|
339 } |
|
340 else |
|
341 { |
|
342 MVPbkContactLink* link = NULL; |
|
343 static_cast<CMsgAddressControl*>( iHeaders[EHeaderAddressFrom].iControl ) |
|
344 ->AddRecipientL( TMmsGenUtils::Alias( sender ), |
|
345 TMmsGenUtils::PureAddress( sender ), |
|
346 ETrue, |
|
347 link ); |
|
348 } |
|
349 } |
|
350 } |
|
351 |
|
352 // --------------------------------------------------------- |
|
353 // RemoveSubjectContentL |
|
354 // --------------------------------------------------------- |
|
355 // |
|
356 void CMmsViewerHeader::RemoveSubjectContentL( ) |
|
357 { |
|
358 if ( iHeaders[EHeaderSubject].iControl |
|
359 && iHeaders[EHeaderSubject].iControl->Editor().TextLength() ) |
|
360 { |
|
361 // without this change Japanese pictographs in subject field |
|
362 // appear on slides 2,... |
|
363 iHeaders[EHeaderSubject].iControl->Editor().SetCursorPosL( 0, EFalse ); |
|
364 TPtrC nullPtrC( KNullDesC() ); |
|
365 iHeaders[EHeaderSubject].iControl->Editor().SetTextL( &nullPtrC ); |
|
366 } |
|
367 } |
|
368 |
|
369 |
|
370 // --------------------------------------------------------- |
|
371 // RestoreSubjectContentL |
|
372 // --------------------------------------------------------- |
|
373 // |
|
374 void CMmsViewerHeader::RestoreSubjectContentL() |
|
375 { |
|
376 InsertSubjectL( ETrue ); |
|
377 } |
|
378 |
|
379 // --------------------------------------------------------- |
|
380 // InsertSubjectL |
|
381 // --------------------------------------------------------- |
|
382 // |
|
383 void CMmsViewerHeader::InsertSubjectL( TBool /*aReadContent*/ ) |
|
384 { |
|
385 HBufC* subject = iMtm.SubjectL().AllocLC(); |
|
386 TPtr subjectPtr = subject->Des(); |
|
387 subjectPtr.Trim(); |
|
388 if ( subjectPtr.Length() |
|
389 && !iHeaders[EHeaderSubject].iControl ) |
|
390 { |
|
391 iView.AddControlFromResourceL( R_MMSVIEWER_SUBJECT, EMsgExpandableControl, EMsgAppendControl, EMsgHeader ); |
|
392 iHeaders[EHeaderSubject].iControl = static_cast<CMsgExpandableControl*> |
|
393 ( iView.ControlById( EMsgComponentIdSubject ) ); |
|
394 iHeaders[EHeaderSubject].iOwned = EFalse; |
|
395 |
|
396 iHeaders[EHeaderSubject].iControl->Editor().SetTextL( subject ); |
|
397 } |
|
398 else if ( subjectPtr.Length() |
|
399 && iHeaders[EHeaderSubject].iControl |
|
400 && !iHeaders[EHeaderSubject].iControl->Editor().TextLength() ) |
|
401 { |
|
402 iHeaders[EHeaderSubject].iControl->Editor().SetTextL( subject ); |
|
403 } |
|
404 CleanupStack::PopAndDestroy(); //subject |
|
405 } |
|
406 |
|
407 // --------------------------------------------------------- |
|
408 // CUniEditorHeader::InsertAttachmentL |
|
409 // --------------------------------------------------------- |
|
410 // |
|
411 void CMmsViewerHeader::InsertAttachmentL( TBool /*aReadContent*/) |
|
412 { |
|
413 if ( iAttachmentList.Count() ) |
|
414 { |
|
415 CMsgAttachmentControl* attachmentControl = CMsgAttachmentControl::NewL( iView, iView ); |
|
416 CleanupStack::PushL( attachmentControl ); |
|
417 iView.AddControlL( attachmentControl, |
|
418 EMsgComponentIdAttachment, |
|
419 EMsgAppendControl, |
|
420 EMsgHeader ); |
|
421 CleanupStack::Pop( attachmentControl ); |
|
422 |
|
423 iHeaders[EHeaderAttachment].iControl = |
|
424 static_cast<CMsgAttachmentControl*>( iView.ControlById( EMsgComponentIdAttachment ) ); |
|
425 |
|
426 iHeaders[EHeaderAttachment].iOwned = EFalse; |
|
427 |
|
428 for( TInt index = 0; index < iAttachmentList.Count(); index++ ) |
|
429 { |
|
430 TParsePtrC fileParser( iAttachmentList.GetByIndex( index )->MediaInfo()->FullFilePath() ); |
|
431 attachmentControl->AppendAttachmentL( fileParser.NameAndExt() ); |
|
432 } |
|
433 } |
|
434 |
|
435 } |
|
436 |
|
437 |
|
438 // --------------------------------------------------------- |
|
439 // RemoveAttachmentL |
|
440 // --------------------------------------------------------- |
|
441 // |
|
442 void CMmsViewerHeader::RemoveAttachmentL( ) |
|
443 { |
|
444 RemoveFromViewL( EUniFeatureAttachment ); |
|
445 } |
|
446 |
|
447 // End of File |