|
1 /* |
|
2 * Copyright (c) 2002 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: Mail message HTML view |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "MailLog.h" |
|
21 #include "CMailMessageHtmlView.h" |
|
22 #include "msgmailviewer.hrh" |
|
23 #include "CMailHtmlBodyControl.h" |
|
24 #include "CHtmlMailLoadStateMachine.h" |
|
25 #include "mailmessageutils.h" |
|
26 #include <MMailAppUiInterface.h> |
|
27 #include <CMailMessage.h> |
|
28 #include <MsgEditorView.h> // CMsgEditorView |
|
29 #include <MsgMailViewer.rsg> |
|
30 #include <FindItem.hrh> |
|
31 #include <FindItemMenu.rsg> |
|
32 #include <centralrepository.h> |
|
33 #include <CommonUiInternalCRKeys.h> |
|
34 #include <MMSVATTACHMENTMANAGER.H> |
|
35 #include <ImumInternalApi.h> |
|
36 #include <ImumInSettingsKeys.h> |
|
37 #include <ImumInSettingsData.h> |
|
38 |
|
39 |
|
40 // Messaging |
|
41 #include <SenduiMtmUids.h> |
|
42 #include <MIUTSET.h> |
|
43 #include <MsgEditor.hrh> // Control types |
|
44 |
|
45 |
|
46 // CONSTANTS |
|
47 |
|
48 // ============================ MEMBER FUNCTIONS =============================== |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CMailMessageHtmlView::CMailMessageHtmlView |
|
52 // C++ default constructor can NOT contain any code, that |
|
53 // might leave. |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 CMailMessageHtmlView::CMailMessageHtmlView() |
|
57 { |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CMailMessageHtmlView::NewL |
|
62 // Two-phased constructor. |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 CMailMessageHtmlView* CMailMessageHtmlView::NewL() |
|
66 { |
|
67 return new(ELeave) CMailMessageHtmlView (); |
|
68 } |
|
69 |
|
70 // Destructor |
|
71 CMailMessageHtmlView::~CMailMessageHtmlView() |
|
72 { |
|
73 delete iHtmlBodyControl; |
|
74 } |
|
75 |
|
76 // ----------------------------------------------------------------------------- |
|
77 // CMailMessageHtmlView::DynInitOptionsMenuL |
|
78 // (other items were commented in a header). |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 void CMailMessageHtmlView::DynInitMenuPaneL( |
|
82 TInt aResourceId,CEikMenuPane* aMenuPane) |
|
83 { |
|
84 if ( aResourceId == R_MSGMAILVIEWER_OPTIONS_MENU2 || |
|
85 aResourceId == R_FINDITEMMENU_MENU ) |
|
86 { |
|
87 TInt index(0); |
|
88 /* TInt value(0); |
|
89 // Create the session |
|
90 CRepository* crSession = CRepository::NewLC( KCRUidCommonUi ); |
|
91 // Get the value of AutomaticHighlight key |
|
92 crSession->Get( KCuiAutomaticHighlight, value ); |
|
93 |
|
94 if (value) |
|
95 { |
|
96 aMenuPane->SetItemDimmed(EFindItemCmdDisableAutoFind, ETrue); |
|
97 } |
|
98 else |
|
99 { |
|
100 aMenuPane->SetItemDimmed(EFindItemCmdEnableAutoFind, ETrue); |
|
101 } |
|
102 |
|
103 aMenuPane->SetItemDimmed(EMsgMailViewerCmdCreateContact, |
|
104 iHtmlBodyControl->BrowserControl().IsFocused()); |
|
105 */ |
|
106 // + 1 -> next to delete |
|
107 iHtmlBodyControl->BrowserControl().AddOptionMenuItemsL( |
|
108 *aMenuPane, aResourceId, index); |
|
109 } |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CMailMessageHtmlView::HandleCommandL |
|
114 // (other items were commented in a header). |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 TBool CMailMessageHtmlView::HandleCommandL(TInt aCommand) |
|
118 { |
|
119 TBool consumed(EFalse); |
|
120 LOG1("CMailMessageHtmlView::HandleCommandL aCommand:%d", |
|
121 aCommand); |
|
122 iHtmlBodyControl->BrowserControl().HandleCommandL(aCommand); |
|
123 return consumed; |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // CMailMessageHtmlView::HandleKeyEventL |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 TKeyResponse CMailMessageHtmlView::HandleKeyEventL( |
|
131 const TKeyEvent& aKeyEvent, |
|
132 TEventCode aType) |
|
133 { |
|
134 TKeyResponse consumed( EKeyWasNotConsumed ); |
|
135 LOG2("CMailMessageHtmlView::HandleKeyEventL aKeyEvent:%d aType:%d", |
|
136 aKeyEvent.iCode, aType); |
|
137 if ( aKeyEvent.iCode == EKeyLeftArrow && |
|
138 iAppUI->IsNextMessageAvailableL(EFalse) ) |
|
139 { |
|
140 iAppUI->NextMessageL(EFalse); |
|
141 consumed = EKeyWasConsumed; |
|
142 } |
|
143 else if ( aKeyEvent.iCode == EKeyRightArrow && |
|
144 iAppUI->IsNextMessageAvailableL(ETrue)) |
|
145 { |
|
146 iAppUI->NextMessageL(ETrue); |
|
147 consumed = EKeyWasConsumed; |
|
148 } |
|
149 else |
|
150 { |
|
151 consumed = iHtmlBodyControl->BrowserControl().OfferKeyEventL( |
|
152 aKeyEvent, aType ); |
|
153 } |
|
154 |
|
155 return consumed; |
|
156 } |
|
157 |
|
158 // ----------------------------------------------------------------------------- |
|
159 // CMailMessageHtmlView::MessageLoadL |
|
160 // ----------------------------------------------------------------------------- |
|
161 // |
|
162 void CMailMessageHtmlView::MessageLoadL(TInt aState, CMailMessage& aMessage) |
|
163 { |
|
164 if (aState == CMailMessage::EHeaderReady) |
|
165 { |
|
166 if( !HtmlSettingValueL( aMessage ) ) |
|
167 { |
|
168 User::Leave(KErrNotSupported); |
|
169 } |
|
170 } |
|
171 } |
|
172 // ----------------------------------------------------------------------------- |
|
173 // CMailMessageHtmlView::ViewMessageL |
|
174 // ----------------------------------------------------------------------------- |
|
175 // |
|
176 void CMailMessageHtmlView::ViewMessageL( |
|
177 CMailMessage& aMessage, |
|
178 MMailAppUiInterface& aUICallBack, |
|
179 TUint& aParams) |
|
180 { |
|
181 iAppUI = &aUICallBack; |
|
182 iMessage = &aMessage; |
|
183 |
|
184 // Set data |
|
185 CImHeader* header = aMessage.MessageHeader(); |
|
186 SetHeaderControlTextL(aMessage, *header); |
|
187 CreateBrControlL(); |
|
188 |
|
189 iLoadStateMachine = CHtmlLoadStateMachine::NewL( |
|
190 iAppUI, |
|
191 aMessage, |
|
192 *iHtmlBodyControl ); |
|
193 iLoadStateMachine->StartL(); |
|
194 aParams |= EMailUseDefaultNaviPane; |
|
195 } |
|
196 |
|
197 // ----------------------------------------------------------------------------- |
|
198 // CMailMessageHtmlView::CreateBrControlL |
|
199 // ----------------------------------------------------------------------------- |
|
200 // |
|
201 void CMailMessageHtmlView::CreateBrControlL() |
|
202 { |
|
203 CMailHtmlBodyControl* htmlBodyControl = |
|
204 CMailHtmlBodyControl::NewLC( *iMessage, *iAppUI ); |
|
205 iAppUI->AddControlL(*htmlBodyControl); |
|
206 iHtmlBodyControl = htmlBodyControl; |
|
207 CleanupStack::Pop(); // htmlBodyControl |
|
208 } |
|
209 |
|
210 // ----------------------------------------------------------------------------- |
|
211 // CMailMessageHtmlView::SetHeaderControlTextL |
|
212 // ----------------------------------------------------------------------------- |
|
213 // |
|
214 void CMailMessageHtmlView::SetHeaderControlTextL( |
|
215 CMailMessage& aMessage, CImHeader& aHeader) |
|
216 { |
|
217 if ( MailMessageUtils::IsOutgoingL( aMessage ) ) |
|
218 { |
|
219 CDesCArray& toRecipients = aHeader.ToRecipients(); |
|
220 if (toRecipients.Count()) |
|
221 { |
|
222 iAppUI->AddControlL(EMsgComponentIdTo); |
|
223 iAppUI->SetAddressFieldTextL( |
|
224 EMsgComponentIdTo, |
|
225 toRecipients); |
|
226 } |
|
227 } |
|
228 else |
|
229 { |
|
230 HBufC* from = aHeader.From().AllocLC(); |
|
231 if ( from->Length() ) |
|
232 { |
|
233 iAppUI->AddControlL(EMsgComponentIdFrom); |
|
234 iAppUI->SetAddressFieldTextL( |
|
235 EMsgComponentIdFrom, |
|
236 *from); |
|
237 } |
|
238 CleanupStack::PopAndDestroy(); // from |
|
239 } |
|
240 |
|
241 CDesCArray& ccRecipients = aHeader.CcRecipients(); |
|
242 if (ccRecipients.Count()) |
|
243 { |
|
244 iAppUI->AddControlL(EMsgComponentIdCc); |
|
245 iAppUI->SetAddressFieldTextL( |
|
246 EMsgComponentIdCc, |
|
247 ccRecipients); |
|
248 } |
|
249 |
|
250 CDesCArray& bccRecipients = aHeader.BccRecipients(); |
|
251 if (bccRecipients.Count()) |
|
252 { |
|
253 iAppUI->AddControlL(EMsgComponentIdBcc); |
|
254 iAppUI->SetAddressFieldTextL( |
|
255 EMsgComponentIdBcc, |
|
256 bccRecipients); |
|
257 } |
|
258 |
|
259 iAppUI->AddControlL(EMsgComponentIdSubject); |
|
260 iAppUI->SetSubjectL(aHeader.Subject()); |
|
261 } |
|
262 |
|
263 // ----------------------------------------------------------------------------- |
|
264 // CMailMessageHtmlView::HtmlSettingValueL |
|
265 // ----------------------------------------------------------------------------- |
|
266 // |
|
267 TBool CMailMessageHtmlView::HtmlSettingValueL( CMailMessage& aMessage ) |
|
268 { |
|
269 TBool retValue( EFalse ); |
|
270 // Use OpenHtml mail setting value in HTML plugin |
|
271 TMsvEmailEntry message = aMessage.MessageEntry(); |
|
272 if ( message.MHTMLEmail() ) |
|
273 { |
|
274 CImumInternalApi* api = CreateEmailApiLC( aMessage.Session() ); |
|
275 CImumInSettingsData* settings = |
|
276 api->MailboxServicesL().LoadMailboxSettingsL( |
|
277 message.iServiceId ); |
|
278 CleanupStack::PushL( settings ); |
|
279 |
|
280 settings->GetAttr( TImumInSettings::EKeyOpenHtmlMail, retValue ); |
|
281 |
|
282 CleanupStack::PopAndDestroy( settings ); |
|
283 settings = NULL; |
|
284 CleanupStack::PopAndDestroy( api ); |
|
285 api = NULL; |
|
286 } |
|
287 |
|
288 return retValue; |
|
289 } |
|
290 |
|
291 // End of File |