|
1 /* |
|
2 * Copyright (c) 2002-2004 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: State machine for message loading |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "MailLog.h" |
|
22 #include "MailUtils.h" |
|
23 #include "MailLoadStateInline.h" |
|
24 #include "MailLoadStateMessageAttachment.h" |
|
25 #include "MailLoadStateMachine.h" |
|
26 #include "MsgMailViewerHtmlConv.h" |
|
27 #include <MailPlainView.rsg> |
|
28 #include <MMailAppUiInterface.h> |
|
29 #include <CMailMessage.h> |
|
30 #include <StringLoader.h> |
|
31 |
|
32 // ============================ MEMBER FUNCTIONS =============================== |
|
33 |
|
34 /// images |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CLoadInlineImages::MessageLoadingL |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 void CLoadInlineImages::MessageLoadingL( TInt aStatus, CMailMessage& aMessage ) |
|
40 { |
|
41 if( aStatus == CMailMessage::ELinkedFileReady ) |
|
42 { |
|
43 TRAPD( err, AddAttachmentsToAppUiL( aMessage ) ); |
|
44 |
|
45 // Complete observer regardless of result |
|
46 TRequestStatus* observer = iLoadStatus; |
|
47 User::RequestComplete( observer, err ); |
|
48 |
|
49 // Then leave this method if error occurred |
|
50 User::LeaveIfError( err ); |
|
51 } |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CLoadInlineImages::CLoadInlineImages |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 CLoadInlineImages::CLoadInlineImages( |
|
59 MMailAppUiInterface* aAppUI, |
|
60 MStateMachine& aStateMachine ) |
|
61 { |
|
62 iAppUI = aAppUI; |
|
63 iStateMachine = &aStateMachine; |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CLoadInlineImages::~CLoadInlineImages |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 CLoadInlineImages::~CLoadInlineImages() |
|
71 { |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // CLoadInlineImages::NextStateL |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 MLoadState* CLoadInlineImages::NextStateL() |
|
79 { |
|
80 RPointerArray<HBufC>* array = iStateMachine->GetIdArray(); |
|
81 if ( array && array->Count() ) |
|
82 { |
|
83 return new( ELeave ) CLoadInlineImages( iAppUI, *iStateMachine ); |
|
84 } |
|
85 return new( ELeave ) CLoadAttachedMessages( iAppUI ); |
|
86 } |
|
87 |
|
88 // ----------------------------------------------------------------------------- |
|
89 // CLoadInlineImages::MakeRequestL |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 void CLoadInlineImages::MakeRequestL( |
|
93 TRequestStatus& aStatus, |
|
94 CMailMessage& aMessage ) |
|
95 { |
|
96 iLoadStatus = &aStatus; |
|
97 RPointerArray<HBufC>* array = iStateMachine->GetIdArray(); |
|
98 if ( array && array->Count() ) |
|
99 { |
|
100 HBufC* item = (*array)[0]; |
|
101 //LOG1( "CLoadInlineImages::MakeRequestL inlineIdArray: %S", &*item ); |
|
102 aMessage.LoadLinkedHtmlContentL( |
|
103 KNullDesC(), |
|
104 *item, |
|
105 *this ); |
|
106 delete item; |
|
107 array->Remove(0); // remove item pointer from array |
|
108 aStatus = KRequestPending; |
|
109 } |
|
110 else |
|
111 { |
|
112 // Nothing to do, so complete immediately |
|
113 aStatus = KRequestPending; |
|
114 TRequestStatus* observer = iLoadStatus; |
|
115 User::RequestComplete( observer, KErrNone ); |
|
116 } |
|
117 } |
|
118 |
|
119 // ----------------------------------------------------------------------------- |
|
120 // CLoadInlineImages::AddAttachmentsToAppUiL |
|
121 // ----------------------------------------------------------------------------- |
|
122 // |
|
123 void CLoadInlineImages::AddAttachmentsToAppUiL( CMailMessage& aMessage ) |
|
124 { |
|
125 RFile linkedHtml = aMessage.LinkedHtmlContent(); |
|
126 if ( linkedHtml.SubSessionHandle() != 0 ) |
|
127 { |
|
128 CleanupClosePushL( linkedHtml ); |
|
129 CMsvAttachment* message = CMsvAttachment::NewL( |
|
130 CMsvAttachment::EMsvFile ); |
|
131 CleanupStack::PushL( message ); |
|
132 TInt contentSize(0); |
|
133 linkedHtml.Size( contentSize ); |
|
134 message->SetSize( contentSize ); |
|
135 TFileName fileName; |
|
136 linkedHtml.Name( fileName ); |
|
137 message->SetAttachmentNameL( fileName ); |
|
138 message->SetComplete( ETrue ); |
|
139 message->SetId( aMessage.LinkedHtmlId() ); |
|
140 iAppUI->AddAttachmentL( *message, EFalse ); |
|
141 CleanupStack::PopAndDestroy(2); // CSI: 47 # message, linkedHtml |
|
142 } |
|
143 } |
|
144 |
|
145 // End of File |