commonuis/CommonUi/src/FindItemMenu.cpp
branchRCL_3
changeset 16 71dd06cfe933
parent 15 08e69e956a8c
child 51 fcdfafb36fe7
equal deleted inserted replaced
15:08e69e956a8c 16:71dd06cfe933
    51 #include <AiwServiceHandler.h> // CAiwServiceHandler
    51 #include <AiwServiceHandler.h> // CAiwServiceHandler
    52 #include <AiwContactAssignDataTypes.h> // AiwContactAssign
    52 #include <AiwContactAssignDataTypes.h> // AiwContactAssign
    53 #endif // !RD_VIRTUAL_PHONEBOOK
    53 #endif // !RD_VIRTUAL_PHONEBOOK
    54 
    54 
    55 #include "finditem.hrh"
    55 #include "finditem.hrh"
    56 #include <FindItemui.rsg>
    56 #include <finditemui.rsg>
    57 #include <aknnotewrappers.h>
    57 #include <aknnotewrappers.h>
    58 
    58 
    59 // add to gallery related
    59 // add to gallery related
    60 #include <AknCommonDialogs.h>
    60 #include <AknCommonDialogs.h>
    61 
    61 
   353             iFindItemCommandId + 3,
   353             iFindItemCommandId + 3,
   354             0,
   354             0,
   355             0,
   355             0,
   356             *iFindItemUrlItemString );
   356             *iFindItemUrlItemString );
   357         }
   357         }
   358     }
       
   359 	
       
   360 // -----------------------------------------------------------------------------
       
   361 // HasSelection
       
   362 //  Returns ETrue if editor has highlighted text
       
   363 // -----------------------------------------------------------------------------
       
   364 //
       
   365 TBool CFindItemMenu::HasSelection() const
       
   366     {
       
   367     TBool retval ( EFalse );
       
   368     if ( iAutomaticFind )
       
   369         {
       
   370         retval = iAutomaticFind->HasSelection();
       
   371         }
       
   372     return retval;
       
   373     }
   358     }
   374 
   359 
   375 // -----------------------------------------------------------------------------
   360 // -----------------------------------------------------------------------------
   376 // AddMenuItemL
   361 // AddMenuItemL
   377 //  Adds the menu item to menupane
   362 //  Adds the menu item to menupane
   554     TInt index = iIndex;
   539     TInt index = iIndex;
   555 
   540 
   556     TBuf<KMaxMenuTextLength> tempBuf;
   541     TBuf<KMaxMenuTextLength> tempBuf;
   557 
   542 
   558     // Adds menu items depending the selected item
   543     // Adds menu items depending the selected item
   559     if ( HasSelection() )
   544     switch ( itemType )
   560         {
   545         {
   561         switch ( itemType )
   546         case CItemFinder::EPhoneNumber:
   562             {
   547             {
   563             case CItemFinder::EPhoneNumber:
   548 #ifdef RD_VOIP_REL_2_2
       
   549             if ( FeatureManager::FeatureSupported(KFeatureIdCommonVoip ) )
   564                 {
   550                 {
   565 #ifdef RD_VOIP_REL_2_2
   551                 // show call menu if allowed
   566                 if ( FeatureManager::FeatureSupported(KFeatureIdCommonVoip ) )
   552                 if ( !( iMenuItemFlags & CFindItemMenu::ECallItem ) )
   567                     {
       
   568                     // show call menu if allowed
       
   569                     if ( !( iMenuItemFlags & CFindItemMenu::ECallItem ) )
       
   570                         {
       
   571                         // Call
       
   572                         iCoeEnv->ReadResourceL( tempBuf, R_FINDITEMMENU_CALL );
       
   573                         AddMenuItemL(
       
   574                             *iMenuPane,
       
   575                             EFindItemCmdCall,
       
   576                             ( iIsContextMenu ? EFindItemContextMenuPlaceHolder : index ),
       
   577                             0,
       
   578                             tempBuf );
       
   579                         }
       
   580                      // if context menu, we will show call item anyway
       
   581                      else if ( iIsContextMenu )
       
   582                         {
       
   583                         // Call
       
   584                         iCoeEnv->ReadResourceL( tempBuf, R_FINDITEMMENU_CALL );
       
   585                         AddMenuItemL(
       
   586                             *iMenuPane,
       
   587                             EFindItemCmdCall,
       
   588                             EFindItemContextMenuPlaceHolder,
       
   589                             0,
       
   590                             tempBuf );
       
   591                         }
       
   592                     }
       
   593                 else
       
   594                     {
   553                     {
   595                     // Call
   554                     // Call
   596                     iCoeEnv->ReadResourceL( tempBuf, R_FINDITEMMENU_CALL );
   555                     iCoeEnv->ReadResourceL( tempBuf, R_FINDITEMMENU_CALL );
   597                     AddMenuItemL(
   556                     AddMenuItemL(
   598                         *iMenuPane,
   557                         *iMenuPane,
   599                         EFindItemCmdCall,
   558                         EFindItemCmdCall,
   600                         ( iIsContextMenu ? EFindItemContextMenuPlaceHolder : index ),
   559                         ( iIsContextMenu ? EFindItemContextMenuPlaceHolder : index ),
   601                         0,
   560                         0,
   602                         tempBuf );
   561                         tempBuf );
   603                     }
   562                     }
   604                 index = EFindItemCmdCall;
   563                  // if context menu, we will show call item anyway
   605 #else
   564                  else if ( iIsContextMenu )
       
   565                     {
       
   566                     // Call
       
   567                     iCoeEnv->ReadResourceL( tempBuf, R_FINDITEMMENU_CALL );
       
   568                     AddMenuItemL(
       
   569                         *iMenuPane,
       
   570                         EFindItemCmdCall,
       
   571                         EFindItemContextMenuPlaceHolder,
       
   572                         0,
       
   573                         tempBuf );
       
   574                     }
       
   575                 }
       
   576             else
       
   577                 {
   606                 // Call
   578                 // Call
   607                 iCoeEnv->ReadResourceL( tempBuf, R_FINDITEMMENU_CALL );
   579                 iCoeEnv->ReadResourceL( tempBuf, R_FINDITEMMENU_CALL );
   608                 AddMenuItemL(
   580                 AddMenuItemL(
   609                     *iMenuPane,
   581                     *iMenuPane,
   610                     EFindItemCmdCall,
   582                     EFindItemCmdCall,
   611                     ( iIsContextMenu ? EFindItemContextMenuPlaceHolder : index ),
   583                     ( iIsContextMenu ? EFindItemContextMenuPlaceHolder : index ),
   612                     0,
   584                     0,
   613                     tempBuf );
   585                     tempBuf );
   614                 index = EFindItemCmdCall;
   586                 }
       
   587             index = EFindItemCmdCall;
       
   588 #else
       
   589             // Call
       
   590             iCoeEnv->ReadResourceL( tempBuf, R_FINDITEMMENU_CALL );
       
   591             AddMenuItemL(
       
   592                 *iMenuPane,
       
   593                 EFindItemCmdCall,
       
   594                 ( iIsContextMenu ? EFindItemContextMenuPlaceHolder : index ),
       
   595                 0,
       
   596                 tempBuf );
       
   597             index = EFindItemCmdCall;
   615 #endif // RD_VOIP_REL_2_2
   598 #endif // RD_VOIP_REL_2_2
   616                 // Write
   599             // Write
       
   600             iCoeEnv->ReadResourceL( tempBuf, R_FINDITEMMENU_MESSAGE_SUB );
       
   601             AddMenuItemL(
       
   602                 *iMenuPane,
       
   603                 EFindItemSubMenuSend,
       
   604                 index,
       
   605                0,//R_FINDITEM_NUMBER_MESSAGE_SUBMENU,
       
   606                 tempBuf );
       
   607             index = EFindItemSubMenuSend;
       
   608 
       
   609             break;
       
   610             }
       
   611         case CItemFinder::EUrlAddress:
       
   612             {
       
   613             iCoeEnv->ReadResourceL( tempBuf, R_FINDITEMMENU_GOTO_URL );
       
   614 
       
   615             // check if not rstp    
       
   616             if ( iAutomaticFind->CurrentItemExt().iItemDescriptor->FindF( KRtspUrlAddress ) == KErrNotFound )
       
   617                 {
       
   618                 AddMenuItemL(
       
   619                     *iMenuPane,
       
   620                     EFindItemCmdGoToUrl,
       
   621                     ( iIsContextMenu ? EFindItemContextMenuPlaceHolder : index ),
       
   622                     0,
       
   623                     tempBuf);
       
   624                 index = EFindItemCmdGoToUrl;
       
   625 
       
   626                 if ( !iIsContextMenu )
       
   627                     {
       
   628                     // Add bookmark
       
   629                     iCoeEnv->ReadResourceL(
       
   630                         tempBuf, R_FINDITEMMENU_ADD_BOOKMARK );
       
   631                     AddMenuItemL(
       
   632                         *iMenuPane,
       
   633                         EFindItemCmdAddToBookmark,
       
   634                         index,
       
   635                         0,
       
   636                         tempBuf );
       
   637                     index = EFindItemCmdAddToBookmark;
       
   638                     }
       
   639                 }
       
   640             else
       
   641                 {
       
   642                 AddMenuItemL(
       
   643                     *iMenuPane,
       
   644                     EFindItemCmdGoToRstp,
       
   645                     ( iIsContextMenu ? EFindItemContextMenuPlaceHolder : index ),
       
   646                     0,
       
   647                     tempBuf );
       
   648                 index = EFindItemCmdGoToRstp;
       
   649 
       
   650                 if ( !iIsContextMenu )
       
   651                     {
       
   652                     iCoeEnv->ReadResourceL(
       
   653                         tempBuf, R_FINDITEMMENU_ADD_TO_GALLERY );
       
   654                     AddMenuItemL(
       
   655                         *iMenuPane,
       
   656                         EFindItemCmdAddToGallery,
       
   657                         index,
       
   658                         0,
       
   659                         tempBuf );
       
   660                     index = EFindItemCmdAddToGallery;
       
   661                     }
       
   662                 }
       
   663             break;
       
   664             }
       
   665         case CItemFinder::EEmailAddress:
       
   666             {
       
   667             // Checks VoIP profile count and local variation
       
   668             if ( iIsContextMenu && iFindItemVoIPExtension->VoIPProfilesExistL() )
       
   669                 {
       
   670                 //Call
       
   671                 iCoeEnv->ReadResourceL( tempBuf, R_FINDITEMMENU_CALL );
       
   672                 AddMenuItemL(
       
   673                     *iMenuPane,
       
   674                     EFindItemCmdCall,
       
   675                     EFindItemContextMenuPlaceHolder,
       
   676                     0,
       
   677                     tempBuf );
       
   678                 index = EFindItemCmdCall; // Replaces the call ui menu when email
       
   679                                           // field is selected.
       
   680                 }
       
   681 
       
   682             // Write
       
   683             if( iEmailOverSmsFeatureSupported || iMMSFeatureSupported ||
       
   684                 iEmailUiFeatureSupported ) // Sometimes submenu can be empty.
       
   685                 {
   617                 iCoeEnv->ReadResourceL( tempBuf, R_FINDITEMMENU_MESSAGE_SUB );
   686                 iCoeEnv->ReadResourceL( tempBuf, R_FINDITEMMENU_MESSAGE_SUB );
   618                 AddMenuItemL(
   687                 AddMenuItemL(
   619                     *iMenuPane,
   688                     *iMenuPane,
   620                     EFindItemSubMenuSend,
   689                     EFindItemSubMenuSend,
   621                     index,
   690                     ( ( iIsContextMenu &&
   622                    0,//R_FINDITEM_NUMBER_MESSAGE_SUBMENU,
   691                         !iFindItemVoIPExtension->VoIPProfilesExistL() ) ?
       
   692                             EFindItemContextMenuPlaceHolder : index ),
       
   693                     0,//R_FINDITEM_EMAIL_MESSAGE_SUBMENU,
   623                     tempBuf );
   694                     tempBuf );
   624                 index = EFindItemSubMenuSend;
   695                 index = EFindItemSubMenuSend;
   625     
       
   626                 break;
       
   627                 }
   696                 }
   628             case CItemFinder::EUrlAddress:
   697             break;
   629                 {
   698             }
   630                 iCoeEnv->ReadResourceL( tempBuf, R_FINDITEMMENU_GOTO_URL );
   699         case CItemFinder::EUriScheme:
   631     
   700             {
   632                 // check if not rstp    
   701             // Use
   633                 if ( iAutomaticFind->CurrentItemExt().iItemDescriptor->FindF( KRtspUrlAddress ) == KErrNotFound )
   702             iCoeEnv->ReadResourceL( tempBuf, R_QTN_OPTIONS_SCHEME_USE );
   634                     {
   703             AddMenuItemL(
   635                     AddMenuItemL(
   704                 *iMenuPane,
   636                         *iMenuPane,
   705                 EFindItemCmdUse,
   637                         EFindItemCmdGoToUrl,
   706                 ( iIsContextMenu ? EFindItemContextMenuPlaceHolder : index ),
   638                         ( iIsContextMenu ? EFindItemContextMenuPlaceHolder : index ),
   707                 0,
   639                         0,
   708                 tempBuf );
   640                         tempBuf);
   709             index = EFindItemCmdUse;
   641                     index = EFindItemCmdGoToUrl;
   710             break;
   642     
   711             }
   643                     if ( !iIsContextMenu )
   712         default:
   644                         {
   713             {
   645                         // Add bookmark
   714             // Something else, probably nothing selected or new type which we
   646                         iCoeEnv->ReadResourceL(
   715             // don't support.
   647                             tempBuf, R_FINDITEMMENU_ADD_BOOKMARK );
   716             break;
   648                         AddMenuItemL(
   717             }
   649                             *iMenuPane,
   718         }
   650                             EFindItemCmdAddToBookmark,
       
   651                             index,
       
   652                             0,
       
   653                             tempBuf );
       
   654                         index = EFindItemCmdAddToBookmark;
       
   655                         }
       
   656                     }
       
   657                 else
       
   658                     {
       
   659                     AddMenuItemL(
       
   660                         *iMenuPane,
       
   661                         EFindItemCmdGoToRstp,
       
   662                         ( iIsContextMenu ? EFindItemContextMenuPlaceHolder : index ),
       
   663                         0,
       
   664                         tempBuf );
       
   665                     index = EFindItemCmdGoToRstp;
       
   666     
       
   667                     if ( !iIsContextMenu )
       
   668                         {
       
   669                         iCoeEnv->ReadResourceL(
       
   670                             tempBuf, R_FINDITEMMENU_ADD_TO_GALLERY );
       
   671                         AddMenuItemL(
       
   672                             *iMenuPane,
       
   673                             EFindItemCmdAddToGallery,
       
   674                             index,
       
   675                             0,
       
   676                             tempBuf );
       
   677                         index = EFindItemCmdAddToGallery;
       
   678                         }
       
   679                     }
       
   680                 break;
       
   681                 }
       
   682             case CItemFinder::EEmailAddress:
       
   683                 {
       
   684                 // Checks VoIP profile count and local variation
       
   685                 if ( iIsContextMenu && iFindItemVoIPExtension->VoIPProfilesExistL() )
       
   686                     {
       
   687                     //Call
       
   688                     iCoeEnv->ReadResourceL( tempBuf, R_FINDITEMMENU_CALL );
       
   689                     AddMenuItemL(
       
   690                         *iMenuPane,
       
   691                         EFindItemCmdCall,
       
   692                         EFindItemContextMenuPlaceHolder,
       
   693                         0,
       
   694                         tempBuf );
       
   695                     index = EFindItemCmdCall; // Replaces the call ui menu when email
       
   696                                               // field is selected.
       
   697                     }
       
   698     
       
   699                 // Write
       
   700                 if( iEmailOverSmsFeatureSupported || iMMSFeatureSupported ||
       
   701                     iEmailUiFeatureSupported ) // Sometimes submenu can be empty.
       
   702                     {
       
   703                     iCoeEnv->ReadResourceL( tempBuf, R_FINDITEMMENU_MESSAGE_SUB );
       
   704                     AddMenuItemL(
       
   705                         *iMenuPane,
       
   706                         EFindItemSubMenuSend,
       
   707                         ( ( iIsContextMenu &&
       
   708                             !iFindItemVoIPExtension->VoIPProfilesExistL() ) ?
       
   709                                 EFindItemContextMenuPlaceHolder : index ),
       
   710                         0,//R_FINDITEM_EMAIL_MESSAGE_SUBMENU,
       
   711                         tempBuf );
       
   712                     index = EFindItemSubMenuSend;
       
   713                     }
       
   714                 break;
       
   715                 }
       
   716             case CItemFinder::EUriScheme:
       
   717                 {
       
   718                 // Use
       
   719                 iCoeEnv->ReadResourceL( tempBuf, R_QTN_OPTIONS_SCHEME_USE );
       
   720                 AddMenuItemL(
       
   721                     *iMenuPane,
       
   722                     EFindItemCmdUse,
       
   723                     ( iIsContextMenu ? EFindItemContextMenuPlaceHolder : index ),
       
   724                     0,
       
   725                     tempBuf );
       
   726                 index = EFindItemCmdUse;
       
   727                 break;
       
   728                 }
       
   729             default:
       
   730                 {
       
   731                 // Something else, probably nothing selected or new type which we
       
   732                 // don't support.
       
   733                 break;
       
   734                 }
       
   735             }
       
   736         }
       
   737     
       
   738     // Call
   719     // Call
   739     if ( HasSelection() && (
   720     if (
   740         ( itemType == CItemFinder::ENoneSelected ) &&
   721         ( itemType == CItemFinder::ENoneSelected ) &&
   741         (
   722         (
   742             (
   723             (
   743             iSenderDescriptor->Length() &&
   724             iSenderDescriptor->Length() &&
   744             iSenderDescType == CItemFinder::EPhoneNumber ||
   725             iSenderDescType == CItemFinder::EPhoneNumber ||
   750             ( iCallbackNumber && iCallbackNumber->Length()  ) )
   731             ( iCallbackNumber && iCallbackNumber->Length()  ) )
   751 
   732 
   752         ||
   733         ||
   753             ( itemType == CItemFinder::EEmailAddress &&
   734             ( itemType == CItemFinder::EEmailAddress &&
   754             iFindItemVoIPExtension->VoIPProfilesExistL() &&
   735             iFindItemVoIPExtension->VoIPProfilesExistL() &&
   755             !iIsContextMenu ) )
   736             !iIsContextMenu )
   756         )
   737         )
   757         {
   738         {
   758 #ifdef RD_VOIP_REL_2_2
   739 #ifdef RD_VOIP_REL_2_2
   759         if ( FeatureManager::FeatureSupported(KFeatureIdCommonVoip ) )
   740         if ( FeatureManager::FeatureSupported(KFeatureIdCommonVoip ) )
   760             {
   741             {
   840               HBufC* item = iAutomaticFind->CurrentSelection().AllocLC();  
   821               HBufC* item = iAutomaticFind->CurrentSelection().AllocLC();  
   841               len = item->Length();
   822               len = item->Length();
   842               CleanupStack::PopAndDestroy( ); 
   823               CleanupStack::PopAndDestroy( ); 
   843               }
   824               }
   844 
   825 
   845         if( HasSelection() && ( (!iAutomaticFind || len != 0) && 
   826         if( (!iAutomaticFind || len != 0) && 
   846             highlight &&        
   827             highlight &&        
   847             ( itemType != CItemFinder::ENoneSelected || 
   828             ( itemType != CItemFinder::ENoneSelected || 
   848             iSenderHighlighted ) ) )
   829             iSenderHighlighted ) )
   849             {
   830             {
   850             iCoeEnv->ReadResourceL( tempBuf, R_FINDITEMMENU_COPY );
   831             iCoeEnv->ReadResourceL( tempBuf, R_FINDITEMMENU_COPY );
   851             AddMenuItemL(
   832             AddMenuItemL(
   852                 *iMenuPane,
   833                 *iMenuPane,
   853                 EFindItemCmdCopy,
   834                 EFindItemCmdCopy,
   858 
   839 
   859        
   840        
   860         }
   841         }
   861 
   842 
   862      // Add to contacts
   843      // Add to contacts
   863      if ( HasSelection() && ( ( itemType != CItemFinder::EUriScheme ) &&
   844      if ( ( itemType != CItemFinder::EUriScheme ) &&
   864         !( itemType == CItemFinder::EUrlAddress &&
   845         !( itemType == CItemFinder::EUrlAddress &&
   865         iIsContextMenu ) &&
   846         iIsContextMenu ) &&
   866         ( ( ( ( !iIsSenderKnown &&
   847         ( ( ( ( !iIsSenderKnown &&
   867         iSenderDescriptor->Length() ) ||
   848         iSenderDescriptor->Length() ) ||
   868         iCallbackNumber ) &&
   849         iCallbackNumber ) &&
   869         itemType == CItemFinder::ENoneSelected ) ||
   850         itemType == CItemFinder::ENoneSelected ) ||
   870         itemType != CItemFinder::ENoneSelected ) ) )
   851         itemType != CItemFinder::ENoneSelected ) )
   871         {
   852         {
   872         AddMenuItemL(
   853         AddMenuItemL(
   873             *iMenuPane,
   854             *iMenuPane,
   874             EFindItemCmdCreateContactCard,
   855             EFindItemCmdCreateContactCard,
   875             index,
   856             index,
  1697 // -----------------------------------------------------------------------------
  1678 // -----------------------------------------------------------------------------
  1698 void CFindItemMenu::CopyToClipboardL()
  1679 void CFindItemMenu::CopyToClipboardL()
  1699     {       
  1680     {       
  1700     HBufC* item = 0;
  1681     HBufC* item = 0;
  1701     TInt len = 0;
  1682     TInt len = 0;
  1702     if ( iAutomaticFind && iAutomaticFind->CurrentSelection().Length() > 0 )
  1683     if ( iAutomaticFind && iAutomaticFind->CurrentItemExt().iItemType != CItemFinder::ENoneSelected )
  1703         {
  1684         {
  1704         item = iAutomaticFind->CurrentSelection().AllocLC();                        
  1685         item = iAutomaticFind->CurrentSelection().AllocLC();                        
  1705         len = item->Length();
       
  1706         }
       
  1707     else if ( iAutomaticFind && iAutomaticFind->CurrentItemExt().iItemDescriptor )
       
  1708         {
       
  1709         item = iAutomaticFind->CurrentItemExt().iItemDescriptor->AllocLC();
       
  1710         len = item->Length();
  1686         len = item->Length();
  1711         }
  1687         }
  1712     else if( iSenderHighlighted )
  1688     else if( iSenderHighlighted )
  1713         {
  1689         {
  1714         item = iSenderDisplayText->AllocLC();
  1690         item = iSenderDisplayText->AllocLC();