49 { |
54 { |
50 } |
55 } |
51 |
56 |
52 void CFreestyleMessageHeaderURLEventHandler::ConstructL() |
57 void CFreestyleMessageHeaderURLEventHandler::ConstructL() |
53 { |
58 { |
54 iMessageHeaderURL = CFreestyleMessageHeaderURL::NewL(); |
59 iMessageHeaderURL = CFreestyleMessageHeaderURL::NewL(); |
|
60 iHTMLReloadAO = CFSHtmlReloadAO::NewL(iView); |
|
61 |
|
62 if(!iEmailAddressStylusPopup) |
|
63 { |
|
64 TPoint point( 0, 0 ); |
|
65 iEmailAddressStylusPopup = CAknStylusPopUpMenu::NewL( this , point ); |
|
66 TResourceReader reader; |
|
67 CCoeEnv::Static()->CreateResourceReaderLC( reader, R_STYLUS_POPUP_MENU_HTML_VIEW_EMAIL_ADDRESS ); |
|
68 iEmailAddressStylusPopup->ConstructFromResourceL( reader ); |
|
69 CleanupStack::PopAndDestroy(); //resource reader |
|
70 } |
|
71 |
|
72 if( !iAttachmentStylusPopup ) |
|
73 { |
|
74 TPoint point( 0, 0 ); |
|
75 iAttachmentStylusPopup = CAknStylusPopUpMenu::NewL( this , point ); |
|
76 TResourceReader reader; |
|
77 CCoeEnv::Static()->CreateResourceReaderLC( reader, R_STYLUS_POPUP_MENU_HTML_VIEW_ATTACHMENT ); |
|
78 iAttachmentStylusPopup->ConstructFromResourceL( reader ); |
|
79 CleanupStack::PopAndDestroy(); //resource reader |
|
80 } |
|
81 |
|
82 if( !iWebAddressStylusPopup ) |
|
83 { |
|
84 TPoint point( 0, 0 ); |
|
85 iWebAddressStylusPopup = CAknStylusPopUpMenu::NewL( this , point ); |
|
86 TResourceReader reader; |
|
87 CCoeEnv::Static()->CreateResourceReaderLC( reader, R_STYLUS_POPUP_MENU_HTML_VIEW_WEB_ADDRESS ); |
|
88 iWebAddressStylusPopup->ConstructFromResourceL( reader ); |
|
89 CleanupStack::PopAndDestroy(); //resource reader |
|
90 } |
|
91 |
55 } |
92 } |
56 |
93 |
57 CFreestyleMessageHeaderURLEventHandler::~CFreestyleMessageHeaderURLEventHandler () |
94 CFreestyleMessageHeaderURLEventHandler::~CFreestyleMessageHeaderURLEventHandler () |
58 { |
95 { |
59 delete iMessageHeaderURL; |
96 delete iMessageHeaderURL; |
|
97 delete iHTMLReloadAO; |
|
98 if( iEmailAddressStylusPopup ) |
|
99 { |
|
100 delete iEmailAddressStylusPopup; |
|
101 } |
|
102 |
|
103 if( iAttachmentStylusPopup ) |
|
104 { |
|
105 delete iAttachmentStylusPopup; |
|
106 } |
|
107 |
|
108 if( iWebAddressStylusPopup ) |
|
109 { |
|
110 delete iWebAddressStylusPopup; |
|
111 } |
|
112 |
|
113 delete iUrl; |
60 } |
114 } |
61 |
115 |
62 EXPORT_C TBool CFreestyleMessageHeaderURLEventHandler::HandleEventL( const TDesC& aUri ) |
116 EXPORT_C TBool CFreestyleMessageHeaderURLEventHandler::HandleEventL( const TDesC& aUri ) |
63 { |
117 { |
64 iMailMessage = iView.CurrentMessage(); |
118 iMailMessage = iView.CurrentMessage(); |
65 iAttachmentsListModel = iView.CurrentAttachmentsListModel(); |
119 iAttachmentsListModel = iView.CurrentAttachmentsListModel(); |
66 |
120 |
67 if ( ! CFreestyleMessageHeaderURL::IsMessageHeaderURL( aUri ) ) |
121 if ( ! CFreestyleMessageHeaderURL::IsMessageHeaderURL( aUri ) ) |
68 { |
122 { |
|
123 //Handle http and https links |
|
124 if( ( aUri.FindF( KURLHttpPrefix ) ) == 0 |
|
125 ||( aUri.FindF( KURLHttpsPrefix ) ) == 0 ) |
|
126 { |
|
127 if ( iUrl ) |
|
128 { |
|
129 delete iUrl; |
|
130 iUrl = NULL; |
|
131 } |
|
132 iUrl = aUri.AllocL(); |
|
133 LaunchWebAddressMenu( ); |
|
134 return ETrue; |
|
135 } |
|
136 //Link wasn't handled |
69 return EFalse; |
137 return EFalse; |
70 } |
138 } |
71 else |
139 else |
72 { |
140 { |
73 //URL is of the message header format, hence parse it |
141 //URL is of the message header format, hence parse it |
74 iMessageHeaderURL->InternalizeL( aUri ); |
142 iMessageHeaderURL->InternalizeL( aUri ); |
75 |
143 iMenuVisible = ETrue; |
76 if ( ( iMessageHeaderURL->Type()->CompareF( KURLTypeTo ) == 0 ) |
144 if ( ( iMessageHeaderURL->Type()->CompareF( KURLTypeTo ) == 0 ) |
77 || ( iMessageHeaderURL->Type()->CompareF( KURLTypeFrom ) == 0 ) |
145 || ( iMessageHeaderURL->Type()->CompareF( KURLTypeFrom ) == 0 ) |
78 || ( iMessageHeaderURL->Type()->CompareF( KURLTypeCc ) == 0 ) ) |
146 || ( iMessageHeaderURL->Type()->CompareF( KURLTypeCc ) == 0 ) ) |
79 { |
147 { |
80 LaunchEmailAddressMenuL( *iMessageHeaderURL ); |
148 LaunchEmailAddressMenuL( ); |
81 } |
149 } |
82 |
150 |
83 else if ( ( iMessageHeaderURL->Type()->CompareF( KURLTypeAttachment ) == 0 ) ) |
151 else if ( ( iMessageHeaderURL->Type()->CompareF( KURLTypeAttachment ) == 0 ) ) |
84 { |
152 { |
85 LaunchAttachmentMenuL( FindAttachmentL( *iMessageHeaderURL ) ); |
153 LaunchAttachmentMenuL( FindAttachmentL( *iMessageHeaderURL ) ); |
86 } |
154 } |
87 |
155 iMenuVisible=EFalse; |
|
156 if( iPendingReload ) |
|
157 { |
|
158 //Load web page aysnchronously |
|
159 iHTMLReloadAO->ReloadPageAysnc(); |
|
160 iPendingReload=EFalse; |
|
161 } |
88 return ETrue; |
162 return ETrue; |
89 } |
163 } |
90 } |
164 } |
91 |
165 |
92 /* |
166 /* |
93 * Launches the menu and populates it with the appropriate menu items and handles the user |
167 * Launches the avkon stylus popup and dims the inappropriate menu items and handles the user |
94 * menu item selection. |
168 * menu item selection. |
95 * @param aType the type of the link the user selected |
169 * @param aType the type of the link the user selected |
96 */ |
170 */ |
97 void CFreestyleMessageHeaderURLEventHandler::LaunchEmailAddressMenuL( |
171 void CFreestyleMessageHeaderURLEventHandler::LaunchEmailAddressMenuL() |
98 const CFreestyleMessageHeaderURL& iMessageHeaderURL ) |
172 { |
99 { |
173 iEmailAddressStylusPopup->SetItemDimmed( EFsEmailUiCmdActionsRemoteLookup, |
100 CFSEmailUiActionMenu::RemoveAllL(); |
174 !iView.IsRemoteLookupSupportedL() ); |
101 |
175 iEmailAddressStylusPopup->SetPosition( iAppUi.ClientRect().Center(), |
102 RArray<TActionMenuCustomItemId> uids; |
176 CAknStylusPopUpMenu::EPositionTypeRightBottom ); |
103 CleanupClosePushL( uids ); |
177 iEmailAddressStylusPopup->ShowMenu(); |
104 uids.Append( FsEActionMenuCall ); |
178 } |
105 uids.Append( FsEActionMenuCreateMessage ); |
179 |
106 uids.Append( FsEActionMenuCreateEmail ); |
180 //From MEikMenuObserver |
107 uids.Append( FsEActionMenuContactDetails ); |
181 void CFreestyleMessageHeaderURLEventHandler::ProcessCommandL( TInt aCommand ) |
108 uids.Append( FsEActionMenuAddToContacts ); |
182 { |
109 |
183 |
110 if ( iView.IsRemoteLookupSupportedL() ) |
184 switch ( aCommand ) |
111 { |
185 { |
112 uids.Append( FsEActionMenuRemoteLookup ); |
186 case EFsEmailUiCmdActionsReply: |
113 } |
187 case EFsEmailUiCmdActionsAddContact: |
114 |
188 case EFsEmailUiCmdActionsRemoteLookup: |
115 |
189 case EFsEmailUiCmdActionsCopyToClipboard: |
116 for ( TInt i = 0; i < uids.Count(); i++ ) |
190 { |
117 { |
191 iView.HandleEmailAddressCommandL( aCommand, *iMessageHeaderURL->ItemId() ); |
118 CFSEmailUiActionMenu::AddCustomItemL( uids[i] ); ///here is where you add stuff |
192 break; |
119 } |
193 } |
120 |
194 |
121 CleanupStack::PopAndDestroy( &uids ); |
195 case EFsEmailUiCmdCancelDownload: |
122 TActionMenuCustomItemId menuResult = CFSEmailUiActionMenu::ExecuteL( EFscCenter ); |
196 { |
123 |
197 iView.CancelAttachmentL( FindAttachmentL( *iMessageHeaderURL ) ); |
124 if ( menuResult != FsEActionMenuCasItemSelectedAndExecuted && |
198 break; |
125 menuResult != FsEActionMenuDismissed ) |
199 } |
126 { |
200 |
127 HandleEmailAddressActionMenuCommandL( menuResult, iMessageHeaderURL ); |
201 case EFsEmailUiCmdOpenAttachment: |
128 } |
202 { |
129 } |
203 iView.OpenAttachmentL( FindAttachmentL( *iMessageHeaderURL ) ); |
130 |
204 break; |
131 void CFreestyleMessageHeaderURLEventHandler::HandleEmailAddressActionMenuCommandL( |
205 } |
132 TActionMenuCustomItemId aSelectedActionMenuItem, |
206 |
133 const CFreestyleMessageHeaderURL& iMessageHeaderURL ) |
207 case EFsEmailUiCmdSave: |
134 { |
208 { |
135 TInt command( 0 ); |
209 iView.SaveAttachmentL( FindAttachmentL( *iMessageHeaderURL ) ); |
136 |
210 break; |
137 switch ( aSelectedActionMenuItem ) |
211 } |
138 { |
212 |
139 case FsEActionMenuCreateEmail: // Create message |
213 case EFsEmailUiCmdSaveAll: |
140 { |
214 { |
141 command = EFsEmailUiCmdActionsReply; |
215 iView.SaveAllAttachmentsL( ); |
142 } |
216 break; |
143 break; |
217 } |
144 case FsEActionMenuAddToContacts: // Add to Contacts |
218 |
145 { |
219 case EFsEmailUiCmdActionsOpenWeb: |
146 command = FsEActionMenuAddToContacts; |
220 case EFsEmailUiCmdActionsAddBookmark: |
147 } |
221 case EFsEmailUiCmdActionsCopyWWWAddressToClipboard: |
148 break; |
222 { |
149 case FsEActionMenuCall: // Call |
223 iView.HandleWebAddressCommandL( aCommand, *iUrl ); |
150 { |
224 break; |
151 command = EFsEmailUiCmdActionsCall; |
225 } |
152 } |
226 |
153 break; |
227 } |
154 case FsEActionMenuCreateMessage: // Create message |
228 } |
155 { |
|
156 command = EFsEmailUiCmdActionsCreateMessage; |
|
157 } |
|
158 break; |
|
159 case FsEActionMenuContactDetails: // Contact details |
|
160 { |
|
161 command = EFsEmailUiCmdActionsContactDetails; |
|
162 } |
|
163 break; |
|
164 case FsEActionMenuRemoteLookup: // Remote lookup |
|
165 { |
|
166 command = EFsEmailUiCmdActionsRemoteLookup; |
|
167 } |
|
168 break; |
|
169 } |
|
170 |
|
171 iView.HandleEmailAddressCommandL( command, *iMessageHeaderURL.ItemId() ); |
|
172 } |
|
173 |
229 |
174 const TAttachmentData& CFreestyleMessageHeaderURLEventHandler::FindAttachmentL( |
230 const TAttachmentData& CFreestyleMessageHeaderURLEventHandler::FindAttachmentL( |
175 const CFreestyleMessageHeaderURL& aAttachmentUrl ) |
231 const CFreestyleMessageHeaderURL& aAttachmentUrl ) |
176 { |
232 { |
177 User::LeaveIfNull( iAttachmentsListModel ); |
233 User::LeaveIfNull( iAttachmentsListModel ); |
214 |
270 |
215 void CFreestyleMessageHeaderURLEventHandler::LaunchAttachmentMenuL( |
271 void CFreestyleMessageHeaderURLEventHandler::LaunchAttachmentMenuL( |
216 const TAttachmentData& aAttachment ) |
272 const TAttachmentData& aAttachment ) |
217 { |
273 { |
218 ASSERT( iAppUi.DownloadInfoMediator() ); |
274 ASSERT( iAppUi.DownloadInfoMediator() ); |
219 CFSEmailUiActionMenu::RemoveAllL(); |
275 |
|
276 //Dim all item by default |
|
277 iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdOpenAttachment, ETrue ); |
|
278 iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdSave, ETrue ); |
|
279 iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdSaveAll, ETrue ); |
|
280 iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdCancelDownload, ETrue ); |
220 |
281 |
221 if ( iAppUi.DownloadInfoMediator()->IsDownloading( aAttachment.partData.iMessagePartId ) ) |
282 if ( iAppUi.DownloadInfoMediator()->IsDownloading( aAttachment.partData.iMessagePartId ) ) |
222 { |
283 { |
223 CFSEmailUiActionMenu::AddCustomItemL( FsEActionAttachmentCancelDownload ); |
284 iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdCancelDownload, EFalse ); |
224 } |
285 } |
225 else if ( aAttachment.downloadProgress == KComplete ) |
286 else if ( aAttachment.downloadProgress == KComplete ) |
226 { |
287 { |
227 CFSEmailUiActionMenu::AddCustomItemL( FsEActionAttachmentOpen ); |
288 iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdOpenAttachment, EFalse ); |
228 |
289 |
229 // block saving of embedded messages if needed. |
290 // block saving of embedded messages if needed. |
230 if ( iView.IsEmbeddedMsgView() ) |
291 if ( iView.IsEmbeddedMsgView() ) |
231 { |
292 { |
232 if ( iView.IsEmbeddedMsgSavingAllowed() || !iAttachmentsListModel->IsMessage( aAttachment ) ) |
293 if ( iView.IsEmbeddedMsgSavingAllowed() || !iAttachmentsListModel->IsMessage( aAttachment ) ) |
233 { |
294 { |
234 CFSEmailUiActionMenu::AddCustomItemL( FsEActionAttachmentSave ); |
295 iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdSave, EFalse ); |
235 } |
296 } |
236 |
|
237 } |
297 } |
238 else |
298 else |
239 { |
299 { |
240 CFSEmailUiActionMenu::AddCustomItemL( FsEActionAttachmentSave ); |
300 iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdSave, EFalse ); |
241 } |
301 } |
242 |
302 |
243 if ( iAttachmentsListModel->GetModel().Count() > 1 ) |
303 if ( iAttachmentsListModel->GetModel().Count() > 1 ) |
244 { |
304 { |
245 // In embedded message mode, save all needs to be blocked if there |
305 // In embedded message mode, save all needs to be blocked if there |
246 // are any message type attachments. This is due to limitations of Activesync plugin. |
306 // are any message type attachments. This is due to limitations of Activesync plugin. |
247 if( !(iView.IsEmbeddedMsgView() && iAttachmentsListModel->IsThereAnyMessageAttachments()) ) |
307 if( !(iView.IsEmbeddedMsgView() && iAttachmentsListModel->IsThereAnyMessageAttachments()) ) |
248 { |
308 { |
249 CFSEmailUiActionMenu::AddCustomItemL( FsEActionAttachmentSaveAll ); |
309 iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdSaveAll, EFalse ); |
250 } |
310 } |
251 |
|
252 } |
311 } |
253 } |
312 } |
254 else |
313 else |
255 { |
314 { |
256 CFSEmailUiActionMenu::AddCustomItemL( FsEActionAttachmentOpen ); |
315 iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdOpenAttachment, EFalse ); |
257 CFSEmailUiActionMenu::AddCustomItemL( FsEActionAttachmentSave ); |
316 iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdSave, EFalse ); |
258 if ( iAttachmentsListModel->GetModel().Count() > 1 ) |
317 if ( iAttachmentsListModel->GetModel().Count() > 1 ) |
259 { |
318 { |
260 CFSEmailUiActionMenu::AddCustomItemL( FsEActionAttachmentSaveAll ); |
319 iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdSaveAll, EFalse ); |
261 } |
320 } |
262 } |
321 } |
263 |
322 iAttachmentStylusPopup->SetPosition( iAppUi.ClientRect().Center(), |
264 TActionMenuCustomItemId menuResult = CFSEmailUiActionMenu::ExecuteL( EFscCenter ); |
323 CAknStylusPopUpMenu::EPositionTypeRightBottom ); |
265 |
324 iAttachmentStylusPopup->ShowMenu(); |
266 if ( menuResult != FsEActionMenuCasItemSelectedAndExecuted && |
325 } |
267 menuResult != FsEActionMenuDismissed ) |
326 |
268 { |
327 //Open the Avkon stylus popup when a web address link was pressed |
269 HandAttachmentActionMenuCommandL( menuResult, aAttachment ); |
328 void CFreestyleMessageHeaderURLEventHandler::LaunchWebAddressMenu() |
270 } |
329 { |
271 } |
330 iWebAddressStylusPopup->SetPosition( iAppUi.ClientRect().Center(), |
272 |
331 CAknStylusPopUpMenu::EPositionTypeRightBottom ); |
273 void CFreestyleMessageHeaderURLEventHandler::HandAttachmentActionMenuCommandL( |
332 iWebAddressStylusPopup->ShowMenu(); |
274 TActionMenuCustomItemId aSelectedActionMenuItem, |
333 } |
275 const TAttachmentData& aAttachment ) |
334 |
276 { |
335 //From MEikMenuObserver |
277 switch ( aSelectedActionMenuItem ) |
336 void CFreestyleMessageHeaderURLEventHandler::SetEmphasis(CCoeControl* /*aMenuControl*/,TBool /*aEmphasis*/) |
278 { |
337 { |
279 case FsEActionAttachmentCancelDownload: |
338 } |
280 iView.CancelAttachmentL( aAttachment ); |
339 |
281 break; |
340 void CFreestyleMessageHeaderURLEventHandler::DismissMenuAndReload() |
282 |
341 { |
283 case FsEActionAttachmentOpen: |
342 CFSEmailUiActionMenu::Dismiss(ETrue); |
284 iView.OpenAttachmentL( aAttachment ); |
343 iPendingReload=ETrue; |
285 break; |
344 } |
286 |
345 TBool CFreestyleMessageHeaderURLEventHandler::IsMenuVisible() |
287 case FsEActionAttachmentSave: |
346 { |
288 iView.SaveAttachmentL( aAttachment ); |
347 return iMenuVisible; |
289 break; |
348 } |
290 |
|
291 case FsEActionAttachmentSaveAll: |
|
292 iView.SaveAllAttachmentsL(); |
|
293 break; |
|
294 |
|
295 case FsEActionAttachmentClearFetchedContent: |
|
296 iView.RemoveAttachmentContentL( aAttachment ); |
|
297 break; |
|
298 |
|
299 case FsEActionAttachmentDownload: |
|
300 iView.DownloadAttachmentL( aAttachment ); |
|
301 break; |
|
302 |
|
303 case FsEActionAttachmentDownloadAll: |
|
304 iView.DownloadAllAttachmentsL(); |
|
305 break; |
|
306 |
|
307 case FsEActionAttachmentViewAll: |
|
308 iView.OpenAttachmentsListViewL(); |
|
309 break; |
|
310 } |
|
311 } |
|
312 |
|
313 |
|