emailuis/emailui/src/FreestyleMessageHeaderURLEventHandler.cpp
changeset 4 e7aa27f58ae1
parent 2 5253a20d2a1e
child 8 e1b6206813b4
equal deleted inserted replaced
3:a4d6f1ea0416 4:e7aa27f58ae1
    57 void CFreestyleMessageHeaderURLEventHandler::ConstructL()
    57 void CFreestyleMessageHeaderURLEventHandler::ConstructL()
    58     {
    58     {
    59     iMessageHeaderURL = CFreestyleMessageHeaderURL::NewL();   
    59     iMessageHeaderURL = CFreestyleMessageHeaderURL::NewL();   
    60     iHTMLReloadAO = CFSHtmlReloadAO::NewL(iView);
    60     iHTMLReloadAO = CFSHtmlReloadAO::NewL(iView);
    61     
    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     
       
    92     }
    62     }
    93 
    63 
    94 CFreestyleMessageHeaderURLEventHandler::~CFreestyleMessageHeaderURLEventHandler ()
    64 CFreestyleMessageHeaderURLEventHandler::~CFreestyleMessageHeaderURLEventHandler ()
    95     {
    65     {
    96     delete iMessageHeaderURL;
    66     delete iMessageHeaderURL;
   128         		{
    98         		{
   129         		delete iUrl;
    99         		delete iUrl;
   130         		iUrl = NULL;
   100         		iUrl = NULL;
   131         		}
   101         		}
   132         	iUrl = aUri.AllocL();
   102         	iUrl = aUri.AllocL();
   133         	LaunchWebAddressMenu( );
   103         	LaunchWebAddressMenuL( );
   134         	return ETrue;
   104         	return ETrue;
   135         	}         
   105         	}         
   136         //Link wasn't handled
   106         //Link wasn't handled
   137         return EFalse;
   107         return EFalse;
   138         }
   108         }
   167  * Launches the avkon stylus popup and dims the inappropriate menu items and handles the user
   137  * Launches the avkon stylus popup and dims the inappropriate menu items and handles the user
   168  * menu item selection.
   138  * menu item selection.
   169  * @param aType the type of the link the user selected
   139  * @param aType the type of the link the user selected
   170  */
   140  */
   171 void CFreestyleMessageHeaderURLEventHandler::LaunchEmailAddressMenuL()
   141 void CFreestyleMessageHeaderURLEventHandler::LaunchEmailAddressMenuL()
   172     {     
   142     {
       
   143     
       
   144     //Change the creation of the stylus menu here to avoid crash when calling SetItemDimmed(ETrue) multiple times 
       
   145     //on same instance of the menu (if created only once in constructor).
       
   146     //Creating the menu everytime the user clicks on the link avoids this crash however performance is affected.
       
   147     if( iEmailAddressStylusPopup)
       
   148        {
       
   149        delete iEmailAddressStylusPopup;
       
   150        iEmailAddressStylusPopup = NULL;
       
   151        }
       
   152    
       
   153     TPoint point( 0, 0 );
       
   154     iEmailAddressStylusPopup = CAknStylusPopUpMenu::NewL( this , point );
       
   155     TResourceReader reader;
       
   156     CCoeEnv::Static()->CreateResourceReaderLC( reader, R_STYLUS_POPUP_MENU_HTML_VIEW_EMAIL_ADDRESS );
       
   157     iEmailAddressStylusPopup->ConstructFromResourceL( reader );
       
   158     CleanupStack::PopAndDestroy(); //resource reader
       
   159          
   173     iEmailAddressStylusPopup->SetItemDimmed( EFsEmailUiCmdActionsRemoteLookup, 
   160     iEmailAddressStylusPopup->SetItemDimmed( EFsEmailUiCmdActionsRemoteLookup, 
   174 											 !iView.IsRemoteLookupSupportedL() ); 
   161 											 !iView.IsRemoteLookupSupportedL() ); 
   175     iEmailAddressStylusPopup->SetPosition( iAppUi.ClientRect().Center(), 
   162     iEmailAddressStylusPopup->SetPosition( iAppUi.ClientRect().Center(), 
   176 										   CAknStylusPopUpMenu::EPositionTypeRightBottom );
   163 										   CAknStylusPopUpMenu::EPositionTypeRightBottom );
   177     iEmailAddressStylusPopup->ShowMenu();
   164     iEmailAddressStylusPopup->ShowMenu();
   271 void CFreestyleMessageHeaderURLEventHandler::LaunchAttachmentMenuL( 
   258 void CFreestyleMessageHeaderURLEventHandler::LaunchAttachmentMenuL( 
   272         const TAttachmentData& aAttachment )
   259         const TAttachmentData& aAttachment )
   273     {
   260     {
   274     ASSERT( iAppUi.DownloadInfoMediator() );
   261     ASSERT( iAppUi.DownloadInfoMediator() );
   275     
   262     
       
   263     //Change the creation of the stylus menu here to avoid crash when calling SetItemDimmed(ETrue) multiple times 
       
   264     //on same instance of the menu (if created only once in constructor).
       
   265     //Creating the menu everytime the user clicks on the link avoids this crash however performance is affected.
       
   266     if( iAttachmentStylusPopup )
       
   267        {
       
   268        delete iAttachmentStylusPopup;
       
   269        iAttachmentStylusPopup = NULL;
       
   270        }
       
   271     TPoint point( 0, 0 );
       
   272     iAttachmentStylusPopup = CAknStylusPopUpMenu::NewL( this , point );
       
   273     TResourceReader reader;
       
   274     CCoeEnv::Static()->CreateResourceReaderLC( reader, R_STYLUS_POPUP_MENU_HTML_VIEW_ATTACHMENT );
       
   275     iAttachmentStylusPopup->ConstructFromResourceL( reader );
       
   276     CleanupStack::PopAndDestroy(); //resource reader
       
   277     
       
   278     
   276     //Dim all item by default
   279     //Dim all item by default
   277     iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdOpenAttachment, ETrue );
   280     iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdOpenAttachment, ETrue );
   278     iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdSave, ETrue );
   281     iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdSave, ETrue );
   279     iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdSaveAll, ETrue );
   282     iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdSaveAll, ETrue );
   280     iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdCancelDownload, ETrue );   
   283     iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdCancelDownload, ETrue );   
   323     								     CAknStylusPopUpMenu::EPositionTypeRightBottom );
   326     								     CAknStylusPopUpMenu::EPositionTypeRightBottom );
   324     iAttachmentStylusPopup->ShowMenu();
   327     iAttachmentStylusPopup->ShowMenu();
   325     }
   328     }
   326 
   329 
   327 //Open the Avkon stylus popup when a web address link was pressed
   330 //Open the Avkon stylus popup when a web address link was pressed
   328 void CFreestyleMessageHeaderURLEventHandler::LaunchWebAddressMenu()
   331 void CFreestyleMessageHeaderURLEventHandler::LaunchWebAddressMenuL()
   329     {
   332     {
       
   333     
       
   334     //Change the creation of the stylus menu here to avoid crash when calling SetItemDimmed(ETrue) multiple times 
       
   335     //on same instance of the menu (if created only once in constructor).
       
   336     //Creating the menu everytime the user clicks on the link avoids this crash however performance is affected.
       
   337     if( iWebAddressStylusPopup )
       
   338         {
       
   339         delete iWebAddressStylusPopup;
       
   340         iWebAddressStylusPopup = NULL;
       
   341         }
       
   342     
       
   343     TPoint point( 0, 0 );
       
   344     iWebAddressStylusPopup = CAknStylusPopUpMenu::NewL( this , point );
       
   345     TResourceReader reader;
       
   346     CCoeEnv::Static()->CreateResourceReaderLC( reader, R_STYLUS_POPUP_MENU_HTML_VIEW_WEB_ADDRESS );
       
   347     iWebAddressStylusPopup->ConstructFromResourceL( reader );
       
   348     CleanupStack::PopAndDestroy(); //resource reader
       
   349  
   330     iWebAddressStylusPopup->SetPosition( iAppUi.ClientRect().Center(), 
   350     iWebAddressStylusPopup->SetPosition( iAppUi.ClientRect().Center(), 
   331 										   CAknStylusPopUpMenu::EPositionTypeRightBottom );
   351 										   CAknStylusPopUpMenu::EPositionTypeRightBottom );
   332     iWebAddressStylusPopup->ShowMenu();
   352     iWebAddressStylusPopup->ShowMenu();
   333     }
   353     }
   334 
   354