emailuis/emailui/src/FreestyleMessageHeaderURLEventHandler.cpp
branchRCL_3
changeset 8 e1b6206813b4
parent 4 e7aa27f58ae1
child 11 0396474f30f5
equal deleted inserted replaced
4:e7aa27f58ae1 8:e1b6206813b4
    17 
    17 
    18 #include "FreestyleMessageHeaderURLEventHandler.h"
    18 #include "FreestyleMessageHeaderURLEventHandler.h"
    19 #include "FreestyleMessageHeaderURL.h"
    19 #include "FreestyleMessageHeaderURL.h"
    20 #include "FreestyleEmailUiConstants.h"
    20 #include "FreestyleEmailUiConstants.h"
    21 #include "FreestyleEmailUiUtilities.h"
    21 #include "FreestyleEmailUiUtilities.h"
    22 #include "CFSMailMessage.h"
    22 #include "cfsmailmessage.h"
    23 #include "FreestyleEmailUiAppui.h"
    23 #include "FreestyleEmailUiAppui.h"
    24 #include "FreestyleEmailUiHtmlViewerView.h"
    24 #include "FreestyleEmailUiHtmlViewerView.h"
    25 #include "FreestyleEmailUi.hrh"
    25 #include "FreestyleEmailUi.hrh"
    26 #include "FreestyleEmailUi.rsg"
    26 #include "FreestyleEmailUi.rsg"
    27 #include "FSHtmlReloadAO.h"
    27 #include "FSHtmlReloadAO.h"
    28 
    28 
    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 
    36 
    36 EXPORT_C CFreestyleMessageHeaderURLEventHandler* CFreestyleMessageHeaderURLEventHandler::NewL( 
    37 EXPORT_C CFreestyleMessageHeaderURLEventHandler* CFreestyleMessageHeaderURLEventHandler::NewL( 
    37         CFreestyleEmailUiAppUi& aAppUi, 
    38         CFreestyleEmailUiAppUi& aAppUi, 
    38         CFsEmailUiHtmlViewerView& aView )
    39         CFsEmailUiHtmlViewerView& aView )
    39     {
    40     {
    64 CFreestyleMessageHeaderURLEventHandler::~CFreestyleMessageHeaderURLEventHandler ()
    65 CFreestyleMessageHeaderURLEventHandler::~CFreestyleMessageHeaderURLEventHandler ()
    65     {
    66     {
    66     delete iMessageHeaderURL;
    67     delete iMessageHeaderURL;
    67     delete iHTMLReloadAO; 
    68     delete iHTMLReloadAO; 
    68     if( iEmailAddressStylusPopup )
    69     if( iEmailAddressStylusPopup )
    69     	{
    70         {
    70 		delete iEmailAddressStylusPopup; 
    71         delete iEmailAddressStylusPopup; 
    71     	}
    72         }
    72     
    73     
    73     if( iAttachmentStylusPopup )
    74     if( iAttachmentStylusPopup )
    74 		{
    75         {
    75 		delete iAttachmentStylusPopup; 
    76         delete iAttachmentStylusPopup; 
    76 		}
    77         }
    77     
    78     
    78     if( iWebAddressStylusPopup )
    79     if( iWebAddressStylusPopup )
    79 		{
    80         {
    80 		delete iWebAddressStylusPopup; 
    81         delete iWebAddressStylusPopup; 
    81 		}   
    82         }   
    82     
    83     
    83     delete iUrl;
    84     delete iUrl;
    84     }
    85     }
    85 
    86 
    86 EXPORT_C TBool CFreestyleMessageHeaderURLEventHandler::HandleEventL( const TDesC& aUri )
    87 EXPORT_C TBool CFreestyleMessageHeaderURLEventHandler::HandleEventL( const TDesC& aUri )
    90     
    91     
    91     if ( ! CFreestyleMessageHeaderURL::IsMessageHeaderURL( aUri ) )
    92     if ( ! CFreestyleMessageHeaderURL::IsMessageHeaderURL( aUri ) )
    92         {
    93         {
    93         //Handle http and https links
    94         //Handle http and https links
    94         if( ( aUri.FindF( KURLHttpPrefix ) ) == 0 
    95         if( ( aUri.FindF( KURLHttpPrefix ) ) == 0 
    95         		||( aUri.FindF( KURLHttpsPrefix ) ) == 0 )
    96                 ||( aUri.FindF( KURLHttpsPrefix ) ) == 0 )
    96         	{
    97             {
    97         	if ( iUrl )
    98             if ( iUrl )
    98         		{
    99                 {
    99         		delete iUrl;
   100                 delete iUrl;
   100         		iUrl = NULL;
   101                 iUrl = NULL;
   101         		}
   102                 }
   102         	iUrl = aUri.AllocL();
   103             iUrl = aUri.AllocL();
   103         	LaunchWebAddressMenuL( );
   104             LaunchWebAddressMenuL( );
   104         	return ETrue;
   105             return ETrue;
   105         	}         
   106             }         
   106         //Link wasn't handled
   107         //Link wasn't handled
   107         return EFalse;
   108         return EFalse;
   108         }
   109         }
   109     else
   110     else
   110         {
   111         {
   119             }
   120             }
   120 
   121 
   121         else if ( ( iMessageHeaderURL->Type()->CompareF( KURLTypeAttachment ) == 0 ) )
   122         else if ( ( iMessageHeaderURL->Type()->CompareF( KURLTypeAttachment ) == 0 ) )
   122             {
   123             {
   123             LaunchAttachmentMenuL( FindAttachmentL( *iMessageHeaderURL ) );
   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 );
   124             }
   132             }
   125         iMenuVisible=EFalse;
   133         iMenuVisible=EFalse;
   126         if( iPendingReload )
   134         if( iPendingReload )
   127             {
   135             {
   128             //Load web page aysnchronously
   136             //Load web page aysnchronously
   156     CCoeEnv::Static()->CreateResourceReaderLC( reader, R_STYLUS_POPUP_MENU_HTML_VIEW_EMAIL_ADDRESS );
   164     CCoeEnv::Static()->CreateResourceReaderLC( reader, R_STYLUS_POPUP_MENU_HTML_VIEW_EMAIL_ADDRESS );
   157     iEmailAddressStylusPopup->ConstructFromResourceL( reader );
   165     iEmailAddressStylusPopup->ConstructFromResourceL( reader );
   158     CleanupStack::PopAndDestroy(); //resource reader
   166     CleanupStack::PopAndDestroy(); //resource reader
   159          
   167          
   160     iEmailAddressStylusPopup->SetItemDimmed( EFsEmailUiCmdActionsRemoteLookup, 
   168     iEmailAddressStylusPopup->SetItemDimmed( EFsEmailUiCmdActionsRemoteLookup, 
   161 											 !iView.IsRemoteLookupSupportedL() ); 
   169                                              !iView.IsRemoteLookupSupportedL() ); 
   162     iEmailAddressStylusPopup->SetPosition( iAppUi.ClientRect().Center(), 
   170     iEmailAddressStylusPopup->SetPosition( iAppUi.ClientRect().Center(), 
   163 										   CAknStylusPopUpMenu::EPositionTypeRightBottom );
   171                                            CAknStylusPopUpMenu::EPositionTypeRightBottom );
   164     iEmailAddressStylusPopup->ShowMenu();
   172     iEmailAddressStylusPopup->ShowMenu();
   165     }
   173     }
   166 
   174 
   167 //From MEikMenuObserver
   175 //From MEikMenuObserver
   168 void CFreestyleMessageHeaderURLEventHandler::ProcessCommandL( TInt aCommand )
   176 void CFreestyleMessageHeaderURLEventHandler::ProcessCommandL( TInt aCommand )
   169 	{
   177     {
   170 	
   178     
   171 	switch ( aCommand )
   179     switch ( aCommand )
   172 		{
   180         {
   173 		case EFsEmailUiCmdActionsReply:
   181         case EFsEmailUiCmdActionsReply:
   174 		case EFsEmailUiCmdActionsAddContact:
   182         case EFsEmailUiCmdActionsAddContact:
   175 		case EFsEmailUiCmdActionsRemoteLookup:
   183         case EFsEmailUiCmdActionsRemoteLookup:
   176 		case EFsEmailUiCmdActionsCopyToClipboard:
   184         case EFsEmailUiCmdActionsCopyToClipboard:
   177 			{
   185         case EFsEmailUiCmdActionsContactDetails:
   178 			iView.HandleEmailAddressCommandL( aCommand, *iMessageHeaderURL->ItemId() );
   186             {
   179 			break;
   187             iView.HandleEmailAddressCommandL( aCommand, *iMessageHeaderURL->ItemId() );
   180 			}
   188             break;
   181 			
   189             }
   182 		case EFsEmailUiCmdCancelDownload:
   190             
   183 			{
   191         case EFsEmailUiCmdCancelDownload:
   184 			iView.CancelAttachmentL( FindAttachmentL( *iMessageHeaderURL ) );
   192             {
   185 			break;
   193             iView.CancelAttachmentL( FindAttachmentL( *iMessageHeaderURL ) );
   186 			}
   194             break;
   187 			
   195             }
   188 		case EFsEmailUiCmdOpenAttachment:
   196             
   189 			{
   197         case EFsEmailUiCmdOpenAttachment:
   190 			iView.OpenAttachmentL( FindAttachmentL( *iMessageHeaderURL ) );
   198             {
   191 			break;
   199             iView.OpenAttachmentL( FindAttachmentL( *iMessageHeaderURL ) );
   192 			}
   200             break;
   193 			
   201             }
   194 		case EFsEmailUiCmdSave:
   202             
   195 			{
   203         case EFsEmailUiCmdSave:
   196 			iView.SaveAttachmentL( FindAttachmentL( *iMessageHeaderURL ) );
   204             {
   197 			break;
   205             iView.SaveAttachmentL( FindAttachmentL( *iMessageHeaderURL ) );
   198 			}
   206             break;
   199 			
   207             }
   200 		case EFsEmailUiCmdSaveAll:
   208             
   201 			{
   209         case EFsEmailUiCmdSaveAll:
   202 			iView.SaveAllAttachmentsL( );
   210             {
   203 			break;  	
   211             iView.SaveAllAttachmentsL( );
   204 			}
   212             break;      
   205 			
   213             }
   206 		case EFsEmailUiCmdActionsOpenWeb:
   214             
   207 		case EFsEmailUiCmdActionsAddBookmark:
   215         case EFsEmailUiCmdActionsOpenWeb:
   208 		case EFsEmailUiCmdActionsCopyWWWAddressToClipboard:
   216         case EFsEmailUiCmdActionsAddBookmark:
   209 			{
   217         case EFsEmailUiCmdActionsCopyWWWAddressToClipboard:
   210 			iView.HandleWebAddressCommandL( aCommand, *iUrl );
   218             {
   211 			break;
   219             iView.HandleWebAddressCommandL( aCommand, *iUrl );
   212 			}
   220             break;
   213 			
   221             }
   214 		}
   222             
   215 	}
   223         }
       
   224     }
   216 
   225 
   217 const TAttachmentData& CFreestyleMessageHeaderURLEventHandler::FindAttachmentL( 
   226 const TAttachmentData& CFreestyleMessageHeaderURLEventHandler::FindAttachmentL( 
   218         const CFreestyleMessageHeaderURL& aAttachmentUrl )
   227         const CFreestyleMessageHeaderURL& aAttachmentUrl )
   219     {
   228     {
   220     User::LeaveIfNull( iAttachmentsListModel );
   229     User::LeaveIfNull( iAttachmentsListModel );
   321             {
   330             {
   322             iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdSaveAll, EFalse );
   331             iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdSaveAll, EFalse );
   323             }         
   332             }         
   324         }
   333         }
   325     iAttachmentStylusPopup->SetPosition( iAppUi.ClientRect().Center(), 
   334     iAttachmentStylusPopup->SetPosition( iAppUi.ClientRect().Center(), 
   326     								     CAknStylusPopUpMenu::EPositionTypeRightBottom );
   335                                          CAknStylusPopUpMenu::EPositionTypeRightBottom );
   327     iAttachmentStylusPopup->ShowMenu();
   336     iAttachmentStylusPopup->ShowMenu();
   328     }
   337     }
   329 
   338 
   330 //Open the Avkon stylus popup when a web address link was pressed
   339 //Open the Avkon stylus popup when a web address link was pressed
   331 void CFreestyleMessageHeaderURLEventHandler::LaunchWebAddressMenuL()
   340 void CFreestyleMessageHeaderURLEventHandler::LaunchWebAddressMenuL()
   346     CCoeEnv::Static()->CreateResourceReaderLC( reader, R_STYLUS_POPUP_MENU_HTML_VIEW_WEB_ADDRESS );
   355     CCoeEnv::Static()->CreateResourceReaderLC( reader, R_STYLUS_POPUP_MENU_HTML_VIEW_WEB_ADDRESS );
   347     iWebAddressStylusPopup->ConstructFromResourceL( reader );
   356     iWebAddressStylusPopup->ConstructFromResourceL( reader );
   348     CleanupStack::PopAndDestroy(); //resource reader
   357     CleanupStack::PopAndDestroy(); //resource reader
   349  
   358  
   350     iWebAddressStylusPopup->SetPosition( iAppUi.ClientRect().Center(), 
   359     iWebAddressStylusPopup->SetPosition( iAppUi.ClientRect().Center(), 
   351 										   CAknStylusPopUpMenu::EPositionTypeRightBottom );
   360                                            CAknStylusPopUpMenu::EPositionTypeRightBottom );
   352     iWebAddressStylusPopup->ShowMenu();
   361     iWebAddressStylusPopup->ShowMenu();
   353     }
   362     }
   354 
   363 
   355 //From MEikMenuObserver
   364 //From MEikMenuObserver
   356 void CFreestyleMessageHeaderURLEventHandler::SetEmphasis(CCoeControl* /*aMenuControl*/,TBool /*aEmphasis*/)
   365 void CFreestyleMessageHeaderURLEventHandler::SetEmphasis(CCoeControl* /*aMenuControl*/,TBool /*aEmphasis*/)
   357 	{
   366     {
   358 	}
   367     }
   359 
   368 
   360 void CFreestyleMessageHeaderURLEventHandler::DismissMenuAndReload()
   369 void CFreestyleMessageHeaderURLEventHandler::DismissMenuAndReload()
   361     {
   370     {
   362         CFSEmailUiActionMenu::Dismiss(ETrue);
   371         CFSEmailUiActionMenu::Dismiss(ETrue);
   363         iPendingReload=ETrue;
   372         iPendingReload=ETrue;