|
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: Mail message plain view |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "MailLog.h" |
|
21 #include "MailUtils.h" |
|
22 #include "CMailMessagePlainView.h" |
|
23 #include "MailLoadStateMachine.h" |
|
24 #include "mailmessageutils.h" |
|
25 #include <MailPlainView.rsg> |
|
26 #include <MMailAppUiInterface.h> |
|
27 #include <CMailMessage.h> |
|
28 #include <SenduiMtmUids.h> |
|
29 #include <miutset.h> |
|
30 #include <MsgEditor.hrh> // Control types |
|
31 #include <avkon.hrh> |
|
32 #include <akntabgrp.h> |
|
33 #include <aknnavide.h> |
|
34 #include <StringLoader.h> |
|
35 |
|
36 // CONSTANTS |
|
37 _LIT(KMailPlainViewResourceFile, "z:MailPlainView.rsc"); |
|
38 |
|
39 // ============================ MEMBER FUNCTIONS =============================== |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CMailMessagePlainView::CMailMessagePlainView |
|
43 // C++ default constructor can NOT contain any code, that |
|
44 // might leave. |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 CMailMessagePlainView::CMailMessagePlainView() {} |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // CWPEmailAdapter::NewL |
|
51 // Two-phased constructor. |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 CMailMessagePlainView* CMailMessagePlainView::NewL() |
|
55 { |
|
56 CMailMessagePlainView* self = new(ELeave) CMailMessagePlainView; |
|
57 return self; |
|
58 } |
|
59 |
|
60 // Destructor |
|
61 CMailMessagePlainView::~CMailMessagePlainView() |
|
62 { |
|
63 delete iLoadStateMachine; |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CMailMessagePlainView::DynInitOptionsMenuL |
|
68 // (other items were commented in a header). |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 void CMailMessagePlainView::DynInitMenuPaneL( |
|
72 TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/) |
|
73 { } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CMailMessagePlainView::HandleCommandL |
|
77 // ----------------------------------------------------------------------------- |
|
78 // |
|
79 TBool CMailMessagePlainView::HandleCommandL(TInt /*aCommand*/) |
|
80 { |
|
81 return EFalse; |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CMailMessagePlainView::HandleKeyEventL |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 TKeyResponse CMailMessagePlainView::HandleKeyEventL( |
|
89 const TKeyEvent& /*aKeyEvent*/, |
|
90 TEventCode /*aType*/) |
|
91 { |
|
92 return EKeyWasNotConsumed; |
|
93 } |
|
94 |
|
95 // ----------------------------------------------------------------------------- |
|
96 // CMailMessagePlainView::MessageLoadL |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 void CMailMessagePlainView::MessageLoadL( |
|
100 TInt /*aState*/, CMailMessage& /*aMessage*/) |
|
101 { |
|
102 // Deside here if this message belongs to this plugin. |
|
103 // Do nothing. (PlainView plug-in "can" show all messages) |
|
104 } |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CMailMessagePlainView::ViewMessageL |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 void CMailMessagePlainView::ViewMessageL(CMailMessage& aMessage, |
|
111 MMailAppUiInterface& aUICallBack, TUint& aParams) |
|
112 { |
|
113 iAppUI = &aUICallBack; |
|
114 // ref to message header |
|
115 CImHeader* header = aMessage.MessageHeader(); |
|
116 SetHeaderControlTextL(aMessage, *header); |
|
117 SetBodyControlTextL(aMessage); |
|
118 delete iLoadStateMachine; |
|
119 iLoadStateMachine = NULL; |
|
120 iLoadStateMachine = CLoadStateMachine::NewL( |
|
121 iAppUI, |
|
122 aMessage ); |
|
123 iLoadStateMachine->StartL(); |
|
124 aParams |= EMailUseDefaultNaviPane; |
|
125 } |
|
126 // ----------------------------------------------------------------------------- |
|
127 // CMailMessagePlainView::ResourceFile |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 const TDesC& CMailMessagePlainView::ResourceFile() |
|
131 { |
|
132 return KMailPlainViewResourceFile; |
|
133 } |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // CMailMessagePlainView::AddCcAndBccConstrolsL |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 void CMailMessagePlainView::AddCcAndBccConstrolsL( CImHeader& aHeader ) |
|
140 { |
|
141 CDesCArray& ccRecipients = aHeader.CcRecipients(); |
|
142 if (ccRecipients.Count()) |
|
143 { |
|
144 iAppUI->AddControlL(EMsgComponentIdCc); |
|
145 iAppUI->SetAddressFieldTextL( |
|
146 EMsgComponentIdCc, |
|
147 ccRecipients); |
|
148 } |
|
149 |
|
150 CDesCArray& bccRecipients = aHeader.BccRecipients(); |
|
151 if (bccRecipients.Count()) |
|
152 { |
|
153 iAppUI->AddControlL(EMsgComponentIdBcc); |
|
154 iAppUI->SetAddressFieldTextL( |
|
155 EMsgComponentIdBcc, |
|
156 bccRecipients); |
|
157 } |
|
158 } |
|
159 |
|
160 // ----------------------------------------------------------------------------- |
|
161 // CMailMessagePlainView::SetBodyControlTextL |
|
162 // ----------------------------------------------------------------------------- |
|
163 // |
|
164 void CMailMessagePlainView::SetBodyControlTextL(CMailMessage& aMessage) |
|
165 { |
|
166 // HTML body is set by iLoadStateMachine |
|
167 if ( !aMessage.MessageEntry().MHTMLEmail() ) |
|
168 { |
|
169 iAppUI->SetBodyTextL(*aMessage.MessageBody()); |
|
170 iAppUI->ViewMessageComplete(); |
|
171 } |
|
172 } |
|
173 |
|
174 // ----------------------------------------------------------------------------- |
|
175 // CMailMessagePlainView::SetHeaderControlTextL |
|
176 // ----------------------------------------------------------------------------- |
|
177 // |
|
178 void CMailMessagePlainView::SetHeaderControlTextL( |
|
179 CMailMessage& aMessage, CImHeader& aHeader) |
|
180 { |
|
181 if ( MailMessageUtils::IsOutgoingL( aMessage ) ) |
|
182 { |
|
183 CDesCArray& toRecipients = aHeader.ToRecipients(); |
|
184 if (toRecipients.Count()) |
|
185 { |
|
186 iAppUI->AddControlL(EMsgComponentIdTo); |
|
187 iAppUI->SetAddressFieldTextL( |
|
188 EMsgComponentIdTo, |
|
189 toRecipients); |
|
190 } |
|
191 AddCcAndBccConstrolsL( aHeader ); |
|
192 } |
|
193 else |
|
194 { |
|
195 HBufC* from = aHeader.From().AllocLC(); |
|
196 if ( from->Length() ) |
|
197 { |
|
198 iAppUI->AddControlL(EMsgComponentIdFrom); |
|
199 iAppUI->SetAddressFieldTextL( |
|
200 EMsgComponentIdFrom, |
|
201 *from); |
|
202 } |
|
203 CleanupStack::PopAndDestroy(); // from |
|
204 } |
|
205 |
|
206 iAppUI->AddControlL(EMsgComponentIdSubject); |
|
207 iAppUI->SetSubjectL(aHeader.Subject()); |
|
208 } |
|
209 |
|
210 // End of File |