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