author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:11:15 +0300 | |
branch | RCL_3 |
changeset 80 | 726fba06891a |
parent 70 | 968773a0b6ef |
permissions | -rw-r--r-- |
64 | 1 |
/* |
2 |
* Copyright (c) 2007-2008 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: Message header URL event handler |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
#include "FreestyleMessageHeaderURLEventHandler.h" |
|
19 |
#include "FreestyleMessageHeaderURL.h" |
|
20 |
#include "FreestyleEmailUiConstants.h" |
|
21 |
#include "FreestyleEmailUiUtilities.h" |
|
22 |
#include "cfsmailmessage.h" |
|
23 |
#include "FreestyleEmailUiAppui.h" |
|
24 |
#include "FreestyleEmailUiHtmlViewerView.h" |
|
25 |
#include "FreestyleEmailUi.hrh" |
|
26 |
#include "FreestyleEmailUi.rsg" |
|
27 |
#include "FSHtmlReloadAO.h" |
|
28 |
||
29 |
#include <aknnotewrappers.h> |
|
30 |
#include <aknstyluspopupmenu.h> |
|
31 |
#include <brctldefs.h> |
|
32 |
#include <e32std.h> |
|
33 |
#include <eikmobs.h> |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
34 |
#include <coemain.h> |
64 | 35 |
#include <schemehandler.h> |
36 |
||
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
37 |
EXPORT_C CFreestyleMessageHeaderURLEventHandler* CFreestyleMessageHeaderURLEventHandler::NewL( |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
38 |
CFreestyleEmailUiAppUi& aAppUi, |
64 | 39 |
CFsEmailUiHtmlViewerView& aView ) |
40 |
{ |
|
41 |
CFreestyleMessageHeaderURLEventHandler* obj = new (ELeave) CFreestyleMessageHeaderURLEventHandler( aAppUi, aView ); |
|
42 |
CleanupStack::PushL( obj ); |
|
43 |
obj->ConstructL(); |
|
44 |
CleanupStack::Pop( obj ); |
|
45 |
return obj; |
|
46 |
} |
|
47 |
||
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
48 |
CFreestyleMessageHeaderURLEventHandler::CFreestyleMessageHeaderURLEventHandler( |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
49 |
CFreestyleEmailUiAppUi& aAppUi, |
64 | 50 |
CFsEmailUiHtmlViewerView& aView ) |
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
51 |
: iAppUi( aAppUi ), |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
52 |
iView( aView ), |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
53 |
iMailMessage( NULL ), |
64 | 54 |
iAttachmentsListModel( NULL ) |
55 |
{ |
|
56 |
} |
|
57 |
||
58 |
void CFreestyleMessageHeaderURLEventHandler::ConstructL() |
|
59 |
{ |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
60 |
iMessageHeaderURL = CFreestyleMessageHeaderURL::NewL(); |
64 | 61 |
iHTMLReloadAO = CFSHtmlReloadAO::NewL(iView); |
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
62 |
|
64 | 63 |
} |
64 |
||
65 |
CFreestyleMessageHeaderURLEventHandler::~CFreestyleMessageHeaderURLEventHandler () |
|
66 |
{ |
|
67 |
delete iMessageHeaderURL; |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
68 |
delete iHTMLReloadAO; |
64 | 69 |
if( iEmailAddressStylusPopup ) |
70 |
{ |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
71 |
delete iEmailAddressStylusPopup; |
64 | 72 |
} |
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
73 |
|
64 | 74 |
if( iAttachmentStylusPopup ) |
75 |
{ |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
76 |
delete iAttachmentStylusPopup; |
64 | 77 |
} |
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
78 |
|
64 | 79 |
if( iWebAddressStylusPopup ) |
80 |
{ |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
81 |
delete iWebAddressStylusPopup; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
82 |
} |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
83 |
|
64 | 84 |
delete iUrl; |
85 |
} |
|
86 |
||
87 |
EXPORT_C TBool CFreestyleMessageHeaderURLEventHandler::HandleEventL( const TDesC& aUri ) |
|
88 |
{ |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
89 |
iMailMessage = iView.CurrentMessage(); |
64 | 90 |
iAttachmentsListModel = iView.CurrentAttachmentsListModel(); |
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
91 |
|
64 | 92 |
if ( ! CFreestyleMessageHeaderURL::IsMessageHeaderURL( aUri ) ) |
93 |
{ |
|
94 |
//Handle http and https links |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
95 |
if( ( aUri.FindF( KURLHttpPrefix ) ) == 0 |
64 | 96 |
||( aUri.FindF( KURLHttpsPrefix ) ) == 0 ) |
97 |
{ |
|
98 |
if ( iUrl ) |
|
99 |
{ |
|
100 |
delete iUrl; |
|
101 |
iUrl = NULL; |
|
102 |
} |
|
103 |
iUrl = aUri.AllocL(); |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
104 |
LaunchWebAddressMenuL( ); |
64 | 105 |
return ETrue; |
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
106 |
} |
64 | 107 |
//Link wasn't handled |
108 |
return EFalse; |
|
109 |
} |
|
110 |
else |
|
111 |
{ |
|
112 |
//URL is of the message header format, hence parse it |
|
113 |
iMessageHeaderURL->InternalizeL( aUri ); |
|
114 |
iMenuVisible = ETrue; |
|
115 |
if ( ( iMessageHeaderURL->Type()->CompareF( KURLTypeTo ) == 0 ) |
|
116 |
|| ( iMessageHeaderURL->Type()->CompareF( KURLTypeFrom ) == 0 ) |
|
117 |
|| ( iMessageHeaderURL->Type()->CompareF( KURLTypeCc ) == 0 ) ) |
|
118 |
{ |
|
119 |
LaunchEmailAddressMenuL( ); |
|
120 |
} |
|
121 |
||
122 |
else if ( ( iMessageHeaderURL->Type()->CompareF( KURLTypeAttachment ) == 0 ) ) |
|
123 |
{ |
|
124 |
LaunchAttachmentMenuL( FindAttachmentL( *iMessageHeaderURL ) ); |
|
125 |
} |
|
126 |
else if ( iMessageHeaderURL->Type()->CompareF( KURLTypeSubject ) ) |
|
127 |
{ |
|
128 |
CSchemeHandler* handler = CSchemeHandler::NewL( aUri ); |
|
129 |
CleanupStack::PushL( handler ); |
|
130 |
handler->HandleUrlStandaloneL(); |
|
131 |
CleanupStack::PopAndDestroy( handler ); |
|
132 |
} |
|
133 |
iMenuVisible=EFalse; |
|
134 |
if( iPendingReload ) |
|
135 |
{ |
|
136 |
//Load web page aysnchronously |
|
137 |
iHTMLReloadAO->ReloadPageAysnc(); |
|
138 |
iPendingReload=EFalse; |
|
139 |
} |
|
140 |
return ETrue; |
|
141 |
} |
|
142 |
} |
|
143 |
||
144 |
/* |
|
145 |
* Launches the avkon stylus popup and dims the inappropriate menu items and handles the user |
|
146 |
* menu item selection. |
|
147 |
* @param aType the type of the link the user selected |
|
148 |
*/ |
|
149 |
void CFreestyleMessageHeaderURLEventHandler::LaunchEmailAddressMenuL() |
|
150 |
{ |
|
151 |
if ( LaunchEmailAddressMenuHWKeyL() ) |
|
152 |
{ |
|
153 |
return; |
|
154 |
} |
|
155 |
||
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
156 |
//Change the creation of the stylus menu here to avoid crash when calling SetItemDimmed(ETrue) multiple times |
64 | 157 |
//on same instance of the menu (if created only once in constructor). |
158 |
//Creating the menu everytime the user clicks on the link avoids this crash however performance is affected. |
|
159 |
if( iEmailAddressStylusPopup) |
|
160 |
{ |
|
161 |
delete iEmailAddressStylusPopup; |
|
162 |
iEmailAddressStylusPopup = NULL; |
|
163 |
} |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
164 |
|
64 | 165 |
TPoint point( 0, 0 ); |
166 |
iEmailAddressStylusPopup = CAknStylusPopUpMenu::NewL( this , point ); |
|
167 |
TResourceReader reader; |
|
168 |
CCoeEnv::Static()->CreateResourceReaderLC( reader, R_STYLUS_POPUP_MENU_HTML_VIEW_EMAIL_ADDRESS ); |
|
169 |
iEmailAddressStylusPopup->ConstructFromResourceL( reader ); |
|
170 |
CleanupStack::PopAndDestroy(); //resource reader |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
171 |
|
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
172 |
iEmailAddressStylusPopup->SetItemDimmed( EFsEmailUiCmdActionsRemoteLookup, |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
173 |
!iView.IsRemoteLookupSupportedL() ); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
174 |
iEmailAddressStylusPopup->SetPosition( iAppUi.ClientRect().Center(), |
64 | 175 |
CAknStylusPopUpMenu::EPositionTypeRightBottom ); |
176 |
iEmailAddressStylusPopup->ShowMenu(); |
|
177 |
} |
|
178 |
TBool CFreestyleMessageHeaderURLEventHandler::LaunchEmailAddressMenuHWKeyL() |
|
179 |
{ |
|
180 |
TInt wsEventType = iAppUi.LastSeenWsEventType(); |
|
181 |
if ( wsEventType != EEventKey ) |
|
182 |
{ |
|
183 |
return EFalse; // only hw key event handled here |
|
184 |
} |
|
185 |
||
186 |
CFreestylePopupMenu* popup = CFreestylePopupMenu::NewL( R_STYLUS_POPUP_MENU_HTML_VIEW_EMAIL_ADDRESS ); |
|
187 |
CleanupStack::PushL( popup ); |
|
188 |
||
189 |
popup->SetDimmed( EFsEmailUiCmdActionsRemoteLookup, |
|
190 |
!iView.IsRemoteLookupSupportedL() ); |
|
191 |
||
192 |
TInt commandId = popup->LaunchPopupMenuL(); |
|
193 |
||
194 |
CleanupStack::PopAndDestroy( popup ); |
|
195 |
||
196 |
if ( commandId != KErrCancel ) |
|
197 |
{ |
|
198 |
ProcessCommandL( commandId ); |
|
199 |
} |
|
200 |
||
201 |
return ETrue; |
|
202 |
} |
|
203 |
||
204 |
//From MEikMenuObserver |
|
205 |
void CFreestyleMessageHeaderURLEventHandler::ProcessCommandL( TInt aCommand ) |
|
206 |
{ |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
207 |
|
64 | 208 |
switch ( aCommand ) |
209 |
{ |
|
210 |
case EFsEmailUiCmdActionsReply: |
|
211 |
case EFsEmailUiCmdActionsAddContact: |
|
212 |
case EFsEmailUiCmdActionsRemoteLookup: |
|
213 |
case EFsEmailUiCmdActionsCopyToClipboard: |
|
214 |
case EFsEmailUiCmdActionsContactDetails: |
|
215 |
{ |
|
216 |
iView.HandleEmailAddressCommandL( aCommand, *iMessageHeaderURL->ItemId() ); |
|
217 |
break; |
|
218 |
} |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
219 |
|
64 | 220 |
case EFsEmailUiCmdCancelDownload: |
221 |
{ |
|
222 |
iView.CancelAttachmentL( FindAttachmentL( *iMessageHeaderURL ) ); |
|
223 |
break; |
|
224 |
} |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
225 |
|
64 | 226 |
case EFsEmailUiCmdCancelAllDownloads: |
227 |
{ |
|
228 |
iView.CancelAllAttachmentsL(); |
|
229 |
break; |
|
230 |
} |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
231 |
|
64 | 232 |
case EFsEmailUiCmdOpenAttachment: |
233 |
{ |
|
234 |
iView.OpenAttachmentL( FindAttachmentL( *iMessageHeaderURL ) ); |
|
235 |
break; |
|
236 |
} |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
237 |
|
64 | 238 |
case EFsEmailUiCmdSave: |
239 |
{ |
|
240 |
iView.SaveAttachmentL( FindAttachmentL( *iMessageHeaderURL ) ); |
|
241 |
break; |
|
242 |
} |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
243 |
|
64 | 244 |
case EFsEmailUiCmdSaveAll: |
245 |
{ |
|
246 |
iView.SaveAllAttachmentsL( ); |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
247 |
break; |
64 | 248 |
} |
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
249 |
|
64 | 250 |
case EFsEmailUiCmdActionsOpenWeb: |
251 |
case EFsEmailUiCmdActionsAddBookmark: |
|
252 |
case EFsEmailUiCmdActionsCopyWWWAddressToClipboard: |
|
253 |
{ |
|
254 |
iView.HandleWebAddressCommandL( aCommand, *iUrl ); |
|
255 |
break; |
|
256 |
} |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
257 |
|
64 | 258 |
} |
259 |
} |
|
260 |
||
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
261 |
const TAttachmentData& CFreestyleMessageHeaderURLEventHandler::FindAttachmentL( |
64 | 262 |
const CFreestyleMessageHeaderURL& aAttachmentUrl ) |
263 |
{ |
|
264 |
User::LeaveIfNull( iAttachmentsListModel ); |
|
265 |
TUint id; |
|
266 |
TLex parser( *aAttachmentUrl.ItemId() ); |
|
267 |
parser.Val( id ); |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
268 |
|
64 | 269 |
TInt found = KErrNotFound; |
270 |
for (TInt i=0; i<iAttachmentsListModel->GetModel().Count(); i++) |
|
271 |
{ |
|
272 |
if ( iAttachmentsListModel->GetModel()[i].partData.iMessagePartId.Id() == id ) |
|
273 |
{ |
|
274 |
found = i; |
|
275 |
break; |
|
276 |
} |
|
277 |
} |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
278 |
|
64 | 279 |
if ( found == KErrNotFound ) |
280 |
{ |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
281 |
// Probably, only the headers were downloaded. Check if attachments |
64 | 282 |
// were downloaded later. |
283 |
if( iMailMessage ) |
|
284 |
{ |
|
285 |
iAttachmentsListModel->UpdateListL( iMailMessage ); |
|
286 |
} |
|
287 |
for (TInt i=0; i<iAttachmentsListModel->GetModel().Count(); i++) |
|
288 |
{ |
|
289 |
if ( iAttachmentsListModel->GetModel()[i].partData.iMessagePartId.Id() == id ) |
|
290 |
{ |
|
291 |
found = i; |
|
292 |
break; |
|
293 |
} |
|
294 |
} |
|
295 |
||
296 |
if ( found == KErrNotFound ) |
|
297 |
{ |
|
298 |
User::Leave( KErrNotFound ); |
|
299 |
} |
|
300 |
} |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
301 |
|
64 | 302 |
return iAttachmentsListModel->GetModel()[found]; |
303 |
} |
|
304 |
||
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
305 |
void CFreestyleMessageHeaderURLEventHandler::LaunchAttachmentMenuL( |
64 | 306 |
const TAttachmentData& aAttachment ) |
307 |
{ |
|
308 |
ASSERT( iAppUi.DownloadInfoMediator() ); |
|
309 |
||
310 |
if ( LaunchAttachmentMenuHWKeyL( aAttachment ) ) |
|
311 |
{ |
|
312 |
return; |
|
313 |
} |
|
314 |
//Change the creation of the stylus menu here to avoid crash when calling SetItemDimmed(ETrue) multiple times |
|
315 |
//on same instance of the menu (if created only once in constructor). |
|
316 |
//Creating the menu everytime the user clicks on the link avoids this crash however performance is affected. |
|
317 |
if( iAttachmentStylusPopup ) |
|
318 |
{ |
|
319 |
delete iAttachmentStylusPopup; |
|
320 |
iAttachmentStylusPopup = NULL; |
|
321 |
} |
|
322 |
TPoint point( 0, 0 ); |
|
323 |
iAttachmentStylusPopup = CAknStylusPopUpMenu::NewL( this , point ); |
|
324 |
TResourceReader reader; |
|
325 |
CCoeEnv::Static()->CreateResourceReaderLC( reader, R_STYLUS_POPUP_MENU_HTML_VIEW_ATTACHMENT ); |
|
326 |
iAttachmentStylusPopup->ConstructFromResourceL( reader ); |
|
327 |
CleanupStack::PopAndDestroy(); //resource reader |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
328 |
|
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
329 |
|
64 | 330 |
//Dim all item by default |
331 |
iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdOpenAttachment, ETrue ); |
|
332 |
iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdSave, ETrue ); |
|
333 |
iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdSaveAll, ETrue ); |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
334 |
iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdCancelDownload, ETrue ); |
64 | 335 |
iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdCancelAllDownloads, ETrue ); |
336 |
||
337 |
const TBool isMessage( iAttachmentsListModel->IsMessage( aAttachment ) ); |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
338 |
|
64 | 339 |
if ( iAppUi.DownloadInfoMediator()->IsDownloading( aAttachment.partData.iMessagePartId ) ) |
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
340 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
341 |
iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdCancelDownload, EFalse ); |
64 | 342 |
} |
343 |
else if ( aAttachment.downloadProgress == KComplete ) |
|
344 |
{ |
|
345 |
iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdOpenAttachment, EFalse ); |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
346 |
|
64 | 347 |
// block saving of embedded messages if needed. |
348 |
if ( iView.IsEmbeddedMsgView() ) |
|
349 |
{ |
|
350 |
if ( iView.IsEmbeddedMsgSavingAllowed() || !isMessage ) |
|
351 |
{ |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
352 |
iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdSave, EFalse ); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
353 |
} |
64 | 354 |
} |
355 |
else |
|
356 |
{ |
|
357 |
iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdSave, isMessage && !iView.IsEmbeddedMsgSavingAllowed() ); |
|
358 |
} |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
359 |
|
64 | 360 |
if ( iAttachmentsListModel->GetModel().Count() > 1 ) |
361 |
{ |
|
362 |
// Save all cannot be shown if there is one message attachment and saving is not supported |
|
363 |
if ( !( iAttachmentsListModel->IsThereAnyMessageAttachments() && !iView.IsEmbeddedMsgSavingAllowed() ) ) |
|
364 |
{ |
|
365 |
// In embedded message mode, save all needs to be blocked if there |
|
366 |
// are any message type attachments. This is due to limitations of Activesync plugin. |
|
367 |
if( !(iView.IsEmbeddedMsgView() && iAttachmentsListModel->IsThereAnyMessageAttachments()) ) |
|
368 |
{ |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
369 |
iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdSaveAll, EFalse ); |
64 | 370 |
} |
371 |
} |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
372 |
} |
64 | 373 |
} |
374 |
else |
|
375 |
{ |
|
376 |
iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdOpenAttachment, EFalse ); |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
377 |
iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdSave, isMessage ); |
64 | 378 |
if ( iAttachmentsListModel->GetModel().Count() > 1 ) |
379 |
{ |
|
380 |
iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdSaveAll, |
|
381 |
iAttachmentsListModel->IsThereAnyMessageAttachments() && !iView.IsEmbeddedMsgSavingAllowed() ); |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
382 |
} |
64 | 383 |
} |
384 |
||
385 |
if ( iAttachmentsListModel->IsMultiplyDownloadsOngoing() ) |
|
386 |
{ |
|
387 |
iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdCancelAllDownloads, EFalse ); |
|
388 |
} |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
389 |
|
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
390 |
iAttachmentStylusPopup->SetPosition( iAppUi.LastSeenPointerPosition(), |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
391 |
CAknStylusPopUpMenu::EPositionTypeLeftTop ); |
64 | 392 |
iAttachmentStylusPopup->ShowMenu(); |
393 |
} |
|
394 |
||
395 |
TBool CFreestyleMessageHeaderURLEventHandler::LaunchAttachmentMenuHWKeyL( |
|
396 |
const TAttachmentData& aAttachment ) |
|
397 |
{ |
|
398 |
ASSERT( iAppUi.DownloadInfoMediator() ); |
|
399 |
||
400 |
TInt wsEventType = iAppUi.LastSeenWsEventType(); |
|
401 |
if ( wsEventType != EEventKey ) |
|
402 |
{ |
|
403 |
return EFalse; // only hw key event handled here |
|
404 |
} |
|
405 |
||
406 |
CFreestylePopupMenu* popup = CFreestylePopupMenu::NewL( R_STYLUS_POPUP_MENU_HTML_VIEW_ATTACHMENT ); |
|
407 |
CleanupStack::PushL( popup ); |
|
408 |
||
409 |
//Dim all item by default |
|
410 |
popup->SetDimmed( EFsEmailUiCmdOpenAttachment, ETrue ); |
|
411 |
popup->SetDimmed( EFsEmailUiCmdSave, ETrue ); |
|
412 |
popup->SetDimmed( EFsEmailUiCmdSaveAll, ETrue ); |
|
413 |
popup->SetDimmed( EFsEmailUiCmdCancelDownload, ETrue ); |
|
414 |
popup->SetDimmed( EFsEmailUiCmdCancelAllDownloads, ETrue ); |
|
415 |
||
416 |
const TBool isMessage( iAttachmentsListModel->IsMessage( aAttachment ) ); |
|
417 |
||
418 |
if ( iAppUi.DownloadInfoMediator()->IsDownloading( aAttachment.partData.iMessagePartId ) ) |
|
419 |
{ |
|
420 |
popup->SetDimmed( EFsEmailUiCmdCancelDownload, EFalse ); |
|
421 |
} |
|
422 |
else if ( aAttachment.downloadProgress == KComplete ) |
|
423 |
{ |
|
424 |
popup->SetDimmed( EFsEmailUiCmdOpenAttachment, EFalse ); |
|
425 |
||
426 |
// block saving of embedded messages if needed. |
|
427 |
if ( iView.IsEmbeddedMsgView() ) |
|
428 |
{ |
|
429 |
if ( iView.IsEmbeddedMsgSavingAllowed() || !isMessage ) |
|
430 |
{ |
|
431 |
popup->SetDimmed( EFsEmailUiCmdSave, EFalse ); |
|
432 |
} |
|
433 |
} |
|
434 |
else |
|
435 |
{ |
|
436 |
popup->SetDimmed( EFsEmailUiCmdSave, isMessage && !iView.IsEmbeddedMsgSavingAllowed() ); |
|
437 |
} |
|
438 |
||
439 |
if ( iAttachmentsListModel->GetModel().Count() > 1 ) |
|
440 |
{ |
|
441 |
// Save all cannot be shown if there is one message attachment and saving is not supported |
|
442 |
if ( !( iAttachmentsListModel->IsThereAnyMessageAttachments() && !iView.IsEmbeddedMsgSavingAllowed() ) ) |
|
443 |
{ |
|
444 |
// In embedded message mode, save all needs to be blocked if there |
|
445 |
// are any message type attachments. This is due to limitations of Activesync plugin. |
|
446 |
if( !(iView.IsEmbeddedMsgView() && iAttachmentsListModel->IsThereAnyMessageAttachments()) ) |
|
447 |
{ |
|
448 |
popup->SetDimmed( EFsEmailUiCmdSaveAll, EFalse ); |
|
449 |
} |
|
450 |
} |
|
451 |
} |
|
452 |
} |
|
453 |
else |
|
454 |
{ |
|
455 |
popup->SetDimmed( EFsEmailUiCmdOpenAttachment, EFalse ); |
|
456 |
popup->SetDimmed( EFsEmailUiCmdSave, isMessage ); |
|
457 |
if ( iAttachmentsListModel->GetModel().Count() > 1 ) |
|
458 |
{ |
|
459 |
popup->SetDimmed( EFsEmailUiCmdSaveAll, |
|
460 |
iAttachmentsListModel->IsThereAnyMessageAttachments() && !iView.IsEmbeddedMsgSavingAllowed() ); |
|
461 |
} |
|
462 |
} |
|
463 |
||
464 |
if ( iAttachmentsListModel->IsMultiplyDownloadsOngoing() ) |
|
465 |
{ |
|
466 |
popup->SetDimmed( EFsEmailUiCmdCancelAllDownloads, EFalse ); |
|
467 |
} |
|
468 |
||
469 |
TInt commandId = popup->LaunchPopupMenuL(); |
|
470 |
||
471 |
CleanupStack::PopAndDestroy( popup ); |
|
472 |
||
473 |
if ( commandId != KErrCancel ) |
|
474 |
{ |
|
475 |
ProcessCommandL( commandId ); |
|
476 |
} |
|
477 |
||
478 |
return ETrue; |
|
479 |
} |
|
480 |
//Open the Avkon stylus popup when a web address link was pressed |
|
481 |
void CFreestyleMessageHeaderURLEventHandler::LaunchWebAddressMenuL() |
|
482 |
{ |
|
483 |
if ( LaunchWebAddressMenuHWKeyL() ) |
|
484 |
{ |
|
485 |
return; |
|
486 |
} |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
487 |
|
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
488 |
//Change the creation of the stylus menu here to avoid crash when calling SetItemDimmed(ETrue) multiple times |
64 | 489 |
//on same instance of the menu (if created only once in constructor). |
490 |
//Creating the menu everytime the user clicks on the link avoids this crash however performance is affected. |
|
491 |
if( iWebAddressStylusPopup ) |
|
492 |
{ |
|
493 |
delete iWebAddressStylusPopup; |
|
494 |
iWebAddressStylusPopup = NULL; |
|
495 |
} |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
496 |
|
64 | 497 |
TPoint point( 0, 0 ); |
498 |
iWebAddressStylusPopup = CAknStylusPopUpMenu::NewL( this , point ); |
|
499 |
TResourceReader reader; |
|
500 |
CCoeEnv::Static()->CreateResourceReaderLC( reader, R_STYLUS_POPUP_MENU_HTML_VIEW_WEB_ADDRESS ); |
|
501 |
iWebAddressStylusPopup->ConstructFromResourceL( reader ); |
|
502 |
CleanupStack::PopAndDestroy(); //resource reader |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
503 |
|
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
504 |
iWebAddressStylusPopup->SetPosition( iAppUi.ClientRect().Center(), |
64 | 505 |
CAknStylusPopUpMenu::EPositionTypeRightBottom ); |
506 |
iWebAddressStylusPopup->ShowMenu(); |
|
507 |
} |
|
508 |
||
509 |
TBool CFreestyleMessageHeaderURLEventHandler::LaunchWebAddressMenuHWKeyL() |
|
510 |
{ |
|
511 |
TInt wsEventType = iAppUi.LastSeenWsEventType(); |
|
512 |
if ( wsEventType != EEventKey ) |
|
513 |
{ |
|
514 |
return EFalse; // only hw key event handled here |
|
515 |
} |
|
516 |
||
517 |
CFreestylePopupMenu* popup = CFreestylePopupMenu::NewL( R_STYLUS_POPUP_MENU_HTML_VIEW_WEB_ADDRESS ); |
|
518 |
CleanupStack::PushL( popup ); |
|
519 |
||
520 |
TInt commandId = popup->LaunchPopupMenuL(); |
|
521 |
||
522 |
CleanupStack::PopAndDestroy( popup ); |
|
523 |
||
524 |
if ( commandId != KErrCancel ) |
|
525 |
{ |
|
526 |
ProcessCommandL( commandId ); |
|
527 |
} |
|
528 |
||
529 |
return ETrue; |
|
530 |
} |
|
531 |
||
532 |
||
533 |
//From MEikMenuObserver |
|
534 |
void CFreestyleMessageHeaderURLEventHandler::SetEmphasis(CCoeControl* /*aMenuControl*/,TBool /*aEmphasis*/) |
|
535 |
{ |
|
536 |
} |
|
537 |
||
538 |
void CFreestyleMessageHeaderURLEventHandler::DismissMenuAndReload() |
|
539 |
{ |
|
540 |
CFSEmailUiActionMenu::Dismiss(ETrue); |
|
541 |
iPendingReload=ETrue; |
|
542 |
} |
|
543 |
TBool CFreestyleMessageHeaderURLEventHandler::IsMenuVisible() |
|
544 |
{ |
|
545 |
return iMenuVisible; |
|
546 |
} |
|
547 |
/****************************************************************************** |
|
548 |
* class CFreestylePopupMenu |
|
549 |
******************************************************************************/ |
|
550 |
||
551 |
||
552 |
CFreestylePopupMenu* CFreestylePopupMenu::NewL( TInt aResourceId ) |
|
553 |
{ |
|
554 |
CFreestylePopupMenu* self = new (ELeave) CFreestylePopupMenu( aResourceId ); |
|
555 |
CleanupStack::PushL( self ); |
|
556 |
self->ConstructL(); |
|
557 |
CleanupStack::Pop( self ); |
|
558 |
return self; |
|
559 |
} |
|
560 |
||
561 |
CFreestylePopupMenu::CFreestylePopupMenu( TInt aResourceId ) |
|
562 |
{ |
|
563 |
iResourceId = aResourceId; |
|
564 |
} |
|
565 |
||
566 |
void CFreestylePopupMenu::ConstructL() |
|
567 |
{ |
|
568 |
TResourceReader reader; |
|
569 |
CCoeEnv::Static()->CreateResourceReaderLC( reader, iResourceId ); |
|
570 |
||
571 |
ConstructFromResourceL( reader ); |
|
572 |
||
573 |
CleanupStack::PopAndDestroy(); // TResourceReader |
|
574 |
} |
|
575 |
||
576 |
CFreestylePopupMenu::~CFreestylePopupMenu() |
|
577 |
{ |
|
578 |
iItemList.Close(); |
|
579 |
} |
|
580 |
||
581 |
TInt CFreestylePopupMenu::LaunchPopupMenuL() |
|
582 |
{ |
|
583 |
TInt selectedOption = KErrNotFound; |
|
584 |
CDesCArrayFlat* arr = new (ELeave) CDesCArrayFlat( 5 ); |
|
585 |
CleanupStack::PushL( arr ); |
|
586 |
||
587 |
TInt count = iItemList.Count(); |
|
588 |
for ( TInt i=0; i<count; i++ ) |
|
589 |
{ |
|
590 |
TPopupMenuItem& item = iItemList[i]; |
|
591 |
item.iListIndex = KErrNotFound; |
|
592 |
if ( !item.iDimmed ) |
|
593 |
{ |
|
594 |
arr->AppendL( item.iText ); |
|
595 |
item.iListIndex = arr->MdcaCount() - 1; |
|
596 |
} |
|
597 |
} |
|
598 |
||
599 |
CAknListQueryDialog* dialog = new (ELeave) CAknListQueryDialog( &selectedOption ); |
|
600 |
dialog->PrepareLC( R_DRAFT_QUERY_DIALOG ); |
|
601 |
dialog->SetItemTextArray( arr ); |
|
602 |
dialog->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
603 |
||
604 |
TInt ret = dialog->RunLD(); |
|
605 |
||
606 |
CleanupStack::PopAndDestroy( arr ); |
|
607 |
||
608 |
TInt commandId = KErrCancel; |
|
609 |
if ( ret ) |
|
610 |
{ |
|
611 |
commandId = CommandIdFromListIndex( selectedOption ); |
|
612 |
} |
|
613 |
||
614 |
return commandId; |
|
615 |
} |
|
616 |
||
617 |
||
618 |
void CFreestylePopupMenu::SetDimmed( TInt aCommandId, TBool aDimmed ) |
|
619 |
{ |
|
620 |
TInt count = iItemList.Count(); |
|
621 |
||
622 |
for ( TInt i=0; i<count; i++ ) |
|
623 |
{ |
|
624 |
TPopupMenuItem& item = iItemList[i]; |
|
625 |
if ( item.iCommandId == aCommandId ) |
|
626 |
{ |
|
627 |
item.iDimmed = aDimmed; |
|
628 |
break; |
|
629 |
} |
|
630 |
} |
|
631 |
} |
|
632 |
||
633 |
||
634 |
TInt CFreestylePopupMenu::CommandIdFromListIndex( TInt aListIndex ) |
|
635 |
{ |
|
636 |
TInt ret = KErrCancel; |
|
637 |
||
638 |
TInt count = iItemList.Count(); |
|
639 |
||
640 |
for ( TInt i=0; i<count; i++ ) |
|
641 |
{ |
|
642 |
TPopupMenuItem& item = iItemList[i]; |
|
643 |
if ( item.iListIndex == aListIndex ) |
|
644 |
{ |
|
645 |
ret = item.iCommandId; |
|
646 |
break; |
|
647 |
} |
|
648 |
} |
|
649 |
||
650 |
return ret; |
|
651 |
} |
|
652 |
||
653 |
void CFreestylePopupMenu::ConstructFromResourceL( TResourceReader& aReader ) |
|
654 |
{ |
|
655 |
TInt count = aReader.ReadInt16(); |
|
656 |
||
657 |
for ( TInt i=0; i<count; i++ ) |
|
658 |
{ |
|
659 |
TPopupMenuItem item; |
|
660 |
||
661 |
TPtrC ptr = aReader.ReadTPtrC(); |
|
662 |
StrCopy( item.iText, ptr ); |
|
663 |
item.iCommandId = aReader.ReadInt32(); |
|
664 |
item.iDimmed = EFalse; |
|
665 |
item.iListIndex = KErrNotFound; |
|
666 |
iItemList.AppendL( item ); |
|
667 |
||
668 |
aReader.ReadInt32(); // extension link |
|
669 |
} |
|
670 |
} |
|
671 |
||
672 |
void CFreestylePopupMenu::StrCopy( TDes& aTarget, const TDesC& aSource ) |
|
673 |
{ |
|
674 |
TInt len = aTarget.MaxLength(); |
|
675 |
if( len < aSource.Length() ) |
|
676 |
{ |
|
677 |
aTarget.Copy( aSource.Left( len ) ); |
|
678 |
} |
|
679 |
else |
|
680 |
{ |
|
681 |
aTarget.Copy( aSource ); |
|
682 |
} |
|
683 |
} |
|
684 |