phonebookui/Phonebook2/ccapplication/ccamycardplugin/src/ccappmycardcontainer.cpp
branchRCL_3
changeset 3 04ab22b956c2
parent 0 e686773b3f54
child 15 e8e3147d53eb
equal deleted inserted replaced
0:e686773b3f54 3:04ab22b956c2
    28 
    28 
    29 #include <MPbk2ContactNameFormatter.h>
    29 #include <MPbk2ContactNameFormatter.h>
    30 #include <MVPbkStoreContact.h>
    30 #include <MVPbkStoreContact.h>
    31 #include <CPbk2IconArray.h>
    31 #include <CPbk2IconArray.h>
    32 #include <Pbk2UIControls.rsg>
    32 #include <Pbk2UIControls.rsg>
    33 #include <mpbk2command.h>
    33 #include <MPbk2Command.h>
    34 #include <pbk2menufilteringflags.hrh>
    34 #include <Pbk2MenuFilteringFlags.hrh>
    35 #include <mvpbkcontactlink.h>
    35 #include <MVPbkContactLink.h>
    36 
    36 
    37 #include "ccappmycard.hrh"
    37 #include "ccappmycard.hrh"
    38 #include "ccappmycard.h"
    38 #include "ccappmycard.h"
    39 #include "ccappmycardcontainer.h"
    39 #include "ccappmycardcontainer.h"
    40 #include "ccappmycardcommon.h"
    40 #include "ccappmycardcommon.h"
    64 #include <Pbk2DataCaging.hrh>
    64 #include <Pbk2DataCaging.hrh>
    65 #include <pbk2nameordercenrep.h>
    65 #include <pbk2nameordercenrep.h>
    66 #include <centralrepository.h>
    66 #include <centralrepository.h>
    67 #include <Phonebook2PrivateCRKeys.h>
    67 #include <Phonebook2PrivateCRKeys.h>
    68 
    68 
       
    69 #include <CPbk2ApplicationServices.h>
       
    70 #include <CPbk2ServiceManager.h>
       
    71 #include <TPbk2IconId.h>
       
    72 #include <CPbk2IconInfo.h>
       
    73 
       
    74 
    69 // unnamed namespace
    75 // unnamed namespace
    70 namespace
    76 namespace
    71 {
    77 {
    72 _LIT( KMyCardIconDefaultFileName, "\\resource\\apps\\phonebook2ece.mif" );
    78 _LIT( KMyCardIconDefaultFileName, "\\resource\\apps\\phonebook2ece.mif" );
    73 const TText KLineChange = '\n';
    79 const TText KLineChange = '\n';
   103     delete iListBox;
   109     delete iListBox;
   104     delete iImageLoader;
   110     delete iImageLoader;
   105     delete iFactoryExtensionNotifier;
   111     delete iFactoryExtensionNotifier;
   106     delete iViewLauncher;
   112     delete iViewLauncher;
   107     delete iImageSelectionPopup;
   113     delete iImageSelectionPopup;
       
   114     delete iLongTapDetector; 
       
   115     delete iDetailsPopup;
   108     }
   116     }
   109 
   117 
   110 // ----------------------------------------------------------------------------
   118 // ----------------------------------------------------------------------------
   111 // CCCAppMyCardContainer::ConstructL()
   119 // CCCAppMyCardContainer::ConstructL()
   112 // ----------------------------------------------------------------------------
   120 // ----------------------------------------------------------------------------
   138 
   146 
   139     // Create icons for listbox.
   147     // Create icons for listbox.
   140     TResourceReader reader;
   148     TResourceReader reader;
   141     iCoeEnv->CreateResourceReaderLC( reader, R_PBK2_FIELDTYPE_ICONS );
   149     iCoeEnv->CreateResourceReaderLC( reader, R_PBK2_FIELDTYPE_ICONS );
   142     CPbk2IconArray* iconArray = CPbk2IconArray::NewL( reader );
   150     CPbk2IconArray* iconArray = CPbk2IconArray::NewL( reader );
       
   151   
       
   152     // Calculate preferred size for xsp service icons.
       
   153     TRect mainPane;
       
   154     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPane );
       
   155     TAknLayoutRect listLayoutRect;
       
   156     listLayoutRect.LayoutRect(
       
   157         mainPane,
       
   158         AknLayoutScalable_Avkon::list_single_graphic_pane_g1(0).LayoutLine() );
       
   159     TSize size( listLayoutRect.Rect().Size() );
       
   160         
       
   161     // Add xsp service icons
       
   162     CPbk2ApplicationServices* appServices = CPbk2ApplicationServices::InstanceL();
       
   163     CPbk2ServiceManager& servMan = appServices->ServiceManager();
       
   164     
       
   165     const CPbk2ServiceManager::RServicesArray& services = servMan.Services();
       
   166     TUid uid;
       
   167     uid.iUid = KPbk2ServManId;
       
   168     
       
   169     for( TInt i = 0; i < services.Count(); i++ )
       
   170         {
       
   171         const CPbk2ServiceManager::TService& service = services[i];
       
   172         
       
   173         if ( service.iBitmapId && service.iBitmap )
       
   174             {
       
   175             AknIconUtils::SetSize(
       
   176                       service.iBitmap,
       
   177                       size );
       
   178             AknIconUtils::SetSize(
       
   179                       service.iMask,
       
   180                       size );
       
   181             TPbk2IconId id = TPbk2IconId( uid, service.iBitmapId );
       
   182             CPbk2IconInfo* info = CPbk2IconInfo::NewLC(
       
   183                id, service.iBitmap, service.iMask, size );
       
   184             iconArray->AppendIconL( info );
       
   185             CleanupStack::Pop( info );
       
   186             }        
       
   187         }
       
   188     
       
   189     Release( appServices );
       
   190         
   143     iListBox->ItemDrawer()->ColumnData()->SetIconArray( iconArray );
   191     iListBox->ItemDrawer()->ColumnData()->SetIconArray( iconArray );
   144     CleanupStack::PopAndDestroy(); // reader
   192     CleanupStack::PopAndDestroy(); // reader
   145 
   193 
   146     // Create listbox model
   194     // Create listbox model
   147     iModel = CCCAppMyCardListBoxModel::NewL(
   195     iModel = CCCAppMyCardListBoxModel::NewL(
   153         KAknsIIDQsnBgAreaMain, TRect(0, 0, 0, 0), EFalse );
   201         KAknsIIDQsnBgAreaMain, TRect(0, 0, 0, 0), EFalse );
   154 
   202 
   155     // Start observing now that the class is ready
   203     // Start observing now that the class is ready
   156     iListBox->SetListBoxObserver( this );
   204     iListBox->SetListBoxObserver( this );
   157     iPlugin.MyCard().AddObserverL( this );
   205     iPlugin.MyCard().AddObserverL( this );
   158 
       
   159 
   206 
   160     if( iPlugin.MyCard().IsContactLinkReady() )
   207     if( iPlugin.MyCard().IsContactLinkReady() )
   161     	{
   208     	{
   162         CCCAppStatusControl* statusControl = iHeaderCtrl->StatusControl();
   209         CCCAppStatusControl* statusControl = iHeaderCtrl->StatusControl();
   163     	if( statusControl )
   210     	if( statusControl )
   167 		iControlLink = ETrue;
   214 		iControlLink = ETrue;
   168     	}
   215     	}
   169     iFactoryExtensionNotifier = CCCaFactoryExtensionNotifier::NewL();
   216     iFactoryExtensionNotifier = CCCaFactoryExtensionNotifier::NewL();
   170 
   217 
   171     TCallBack callBack( CCCAppMyCardContainer::CheckExtensionFactoryL, this );
   218     TCallBack callBack( CCCAppMyCardContainer::CheckExtensionFactoryL, this );
   172     iFactoryExtensionNotifier->ObserveExtensionFactory( callBack );
   219     iFactoryExtensionNotifier->ObserveExtensionFactoryL( callBack );
       
   220     
       
   221     iLongTapDetector = CAknLongTapDetector::NewL( this );
   173     CCA_DP(KMyCardLogFile, CCA_L("<-CCCAppMyCardContainer::ConstructL()"));
   222     CCA_DP(KMyCardLogFile, CCA_L("<-CCCAppMyCardContainer::ConstructL()"));
   174     }
   223     }
   175 
       
   176 
   224 
   177 /**
   225 /**
   178  * Gets a digit from a descriptor.
   226  * Gets a digit from a descriptor.
   179  *
   227  *
   180  * @param aReaderToBuf  Resource reader pointed to a descriptor resource.
   228  * @param aReaderToBuf  Resource reader pointed to a descriptor resource.
   191         {
   239         {
   192         result = TChar(ptr[0]).GetNumericValue();
   240         result = TChar(ptr[0]).GetNumericValue();
   193         }
   241         }
   194 
   242 
   195     CleanupStack::PopAndDestroy( orderBuf );
   243     CleanupStack::PopAndDestroy( orderBuf );
       
   244     
   196     return result;
   245     return result;
   197     }
   246     }
   198 
       
   199 
   247 
   200 // ----------------------------------------------------------------------------
   248 // ----------------------------------------------------------------------------
   201 // CCCAppMyCardContainer::ResolveNameOrderL()
   249 // CCCAppMyCardContainer::ResolveNameOrderL()
   202 // ----------------------------------------------------------------------------
   250 // ----------------------------------------------------------------------------
   203 //
   251 //
   319     TRect listPaneRect( listPaneLayoutRect.Rect() );
   367     TRect listPaneRect( listPaneLayoutRect.Rect() );
   320     iListBox->SetRect( listPaneRect );
   368     iListBox->SetRect( listPaneRect );
   321     
   369     
   322 	delete iImageSelectionPopup;
   370 	delete iImageSelectionPopup;
   323 	iImageSelectionPopup = NULL;
   371 	iImageSelectionPopup = NULL;
       
   372 	
       
   373 	delete iDetailsPopup;
       
   374 	iDetailsPopup = NULL;
       
   375 	
       
   376 	if( iImageLoader )
       
   377 	    {
       
   378         TRAP_IGNORE( iImageLoader->ResizeImageL(iHeaderCtrl->ThumbnailSize()));
       
   379 	    }
   324 	
   380 	
   325     DrawDeferred();
   381     DrawDeferred();
   326     }
   382     }
   327 
   383 
   328 // ----------------------------------------------------------------------------
   384 // ----------------------------------------------------------------------------
   442         
   498         
   443         // start loading image
   499         // start loading image
   444         if( !iImageLoader )
   500         if( !iImageLoader )
   445             {
   501             {
   446             // lazy initialization
   502             // lazy initialization
   447             iImageLoader = CCCAppMyCardImageLoader::NewL(
   503             iImageLoader = CCCAppMyCardImageLoader::NewL( *this );
   448                 mycard.ContactManager(), *this );
       
   449             }
   504             }
   450         iImageLoader->LoadContactImageL( mycard.StoreContact() );
   505         iImageLoader->LoadContactImageL( mycard.StoreContact(), 
       
   506                 iHeaderCtrl->ThumbnailSize() );
   451         }
   507         }
   452 
   508 
   453     if( iPlugin.MyCard().IsContactLinkReady() && !iControlLink )
   509     if( iPlugin.MyCard().IsContactLinkReady() && !iControlLink )
   454 		{
   510 		{
   455         CCCAppStatusControl* statusControl = iHeaderCtrl->StatusControl();
   511         CCCAppStatusControl* statusControl = iHeaderCtrl->StatusControl();
   511         {
   567         {
   512         case EEventEnterKeyPressed:
   568         case EEventEnterKeyPressed:
   513         case EEventItemDoubleClicked:
   569         case EEventItemDoubleClicked:
   514         case EEventItemSingleClicked:
   570         case EEventItemSingleClicked:
   515             {
   571             {
       
   572             // Don't open the editor if stylusMenu opened using longTap 
       
   573             if( iLongTapHandled ) 
       
   574                 {
       
   575                 iLongTapHandled = EFalse;
       
   576                 return;
       
   577                 }
       
   578             
   516             // start the editor and pass tapped field index
   579             // start the editor and pass tapped field index
   517             iPlugin.EditL( FocusedFieldIndex() );
   580             iPlugin.EditL( FocusedFieldIndex() );
   518             break;
   581             break;
   519             }
   582             }
   520         default:
   583         default:
   544 	{
   607 	{
   545     // Contact info control has no parent control
   608     // Contact info control has no parent control
   546     return NULL;
   609     return NULL;
   547 	}
   610 	}
   548 
   611 
   549 
       
   550 
       
   551 // --------------------------------------------------------------------------
   612 // --------------------------------------------------------------------------
   552 // CCCAppMyCardContainer::NumberOfContacts
   613 // CCCAppMyCardContainer::NumberOfContacts
   553 // --------------------------------------------------------------------------
   614 // --------------------------------------------------------------------------
   554 //
   615 //
   555 TInt CCCAppMyCardContainer::NumberOfContacts() const
   616 TInt CCCAppMyCardContainer::NumberOfContacts() const
   592 void CCCAppMyCardContainer::SetFocusedContactL(
   653 void CCCAppMyCardContainer::SetFocusedContactL(
   593     const MVPbkBaseContact& /*aContact*/ )
   654     const MVPbkBaseContact& /*aContact*/ )
   594 	{
   655 	{
   595     // do nothing
   656     // do nothing
   596 	}
   657 	}
   597 
       
   598 
   658 
   599 // --------------------------------------------------------------------------
   659 // --------------------------------------------------------------------------
   600 // CCCAppMyCardContainer::SetFocusedContactL
   660 // CCCAppMyCardContainer::SetFocusedContactL
   601 // --------------------------------------------------------------------------
   661 // --------------------------------------------------------------------------
   602 //
   662 //
   697 MVPbkContactLinkArray* CCCAppMyCardContainer::SelectedContactsL() const
   757 MVPbkContactLinkArray* CCCAppMyCardContainer::SelectedContactsL() const
   698 	{
   758 	{
   699     // No selection support in contact info control
   759     // No selection support in contact info control
   700     return NULL;
   760     return NULL;
   701 	}
   761 	}
   702 
       
   703 
       
   704 
   762 
   705 // --------------------------------------------------------------------------
   763 // --------------------------------------------------------------------------
   706 // CCCAppMyCardContainer::SelectedContactsOrFocusedContactL
   764 // CCCAppMyCardContainer::SelectedContactsOrFocusedContactL
   707 // --------------------------------------------------------------------------
   765 // --------------------------------------------------------------------------
   708 //
   766 //
   785     TBool /*aSelected*/)
   843     TBool /*aSelected*/)
   786 	{
   844 	{
   787     // Not supported
   845     // Not supported
   788 	}
   846 	}
   789 
   847 
   790 
       
   791 
       
   792 // --------------------------------------------------------------------------
   848 // --------------------------------------------------------------------------
   793 // CCCAppMyCardContainer::DynInitMenuPaneL
   849 // CCCAppMyCardContainer::DynInitMenuPaneL
   794 // --------------------------------------------------------------------------
   850 // --------------------------------------------------------------------------
   795 //
   851 //
   796 void CCCAppMyCardContainer::DynInitMenuPaneL(
   852 void CCCAppMyCardContainer::DynInitMenuPaneL(
   803 // --------------------------------------------------------------------------
   859 // --------------------------------------------------------------------------
   804 // CCCAppMyCardContainer::ProcessCommandL
   860 // CCCAppMyCardContainer::ProcessCommandL
   805 // --------------------------------------------------------------------------
   861 // --------------------------------------------------------------------------
   806 //
   862 //
   807 void CCCAppMyCardContainer::ProcessCommandL(TInt /*aCommandId*/) const
   863 void CCCAppMyCardContainer::ProcessCommandL(TInt /*aCommandId*/) const
   808 	{
   864         {
   809     // Nothing to do
   865     // Nothing to do
   810 	}
   866         }
   811 
   867 
   812 // --------------------------------------------------------------------------
   868 // --------------------------------------------------------------------------
   813 // CCCAppMyCardContainer::UpdateAfterCommandExecution
   869 // CCCAppMyCardContainer::UpdateAfterCommandExecution
   814 // --------------------------------------------------------------------------
   870 // --------------------------------------------------------------------------
   815 //
   871 //
   869 	{
   925 	{
   870     // No find box in this control
   926     // No find box in this control
   871     return KNullDesC;
   927     return KNullDesC;
   872 	}
   928 	}
   873 
   929 
   874 
       
   875 
       
   876 // --------------------------------------------------------------------------
   930 // --------------------------------------------------------------------------
   877 // CCCAppMyCardContainer::ResetFindL
   931 // CCCAppMyCardContainer::ResetFindL
   878 // --------------------------------------------------------------------------
   932 // --------------------------------------------------------------------------
   879 //
   933 //
   880 void CCCAppMyCardContainer::ResetFindL()
   934 void CCCAppMyCardContainer::ResetFindL()
   898 void CCCAppMyCardContainer::HideThumbnail()
   952 void CCCAppMyCardContainer::HideThumbnail()
   899 	{
   953 	{
   900     // Do nothing
   954     // Do nothing
   901 	}
   955 	}
   902 
   956 
   903 
       
   904 // --------------------------------------------------------------------------
   957 // --------------------------------------------------------------------------
   905 // CCCAppMyCardContainer::SetBlank
   958 // CCCAppMyCardContainer::SetBlank
   906 // --------------------------------------------------------------------------
   959 // --------------------------------------------------------------------------
   907 //
   960 //
   908 void CCCAppMyCardContainer::SetBlank( TBool /*aBlank*/ )
   961 void CCCAppMyCardContainer::SetBlank( TBool /*aBlank*/ )
   909 	{
   962 	{
   910     // This control does not support blanking
   963     // This control does not support blanking
   911 	}
   964 	}
   912 
   965 
   913 
       
   914 // --------------------------------------------------------------------------
   966 // --------------------------------------------------------------------------
   915 // CCCAppMyCardContainer::RegisterCommand
   967 // CCCAppMyCardContainer::RegisterCommand
   916 // --------------------------------------------------------------------------
   968 // --------------------------------------------------------------------------
   917 //
   969 //
   918 void CCCAppMyCardContainer::RegisterCommand( MPbk2Command* aCommand )
   970 void CCCAppMyCardContainer::RegisterCommand( MPbk2Command* aCommand )
   919 	{
   971 	{
   920     iCommand = aCommand;
   972     iCommand = aCommand;
   921 	}
   973 	}
   922 
       
   923 
   974 
   924 // --------------------------------------------------------------------------
   975 // --------------------------------------------------------------------------
   925 // CCCAppMyCardContainer::SetTextL
   976 // CCCAppMyCardContainer::SetTextL
   926 // --------------------------------------------------------------------------
   977 // --------------------------------------------------------------------------
   927 //
   978 //
  1000             {
  1051             {
  1001             iHeaderCtrl->SetLabel2TextL( firstName );
  1052             iHeaderCtrl->SetLabel2TextL( firstName );
  1002             iHeaderCtrl->SetLabel1TextL( lastName );
  1053             iHeaderCtrl->SetLabel1TextL( lastName );
  1003             break;
  1054             break;
  1004             }
  1055             }
  1005         }
  1056         }    
  1006     
       
  1007 	}
  1057 	}
  1008 
  1058 
  1009 //------------------------------------------------------------------------------
  1059 //------------------------------------------------------------------------------
  1010 // void CCCAppMyCardContainer::MyCardHeaderControlClickL()
  1060 // void CCCAppMyCardContainer::MyCardHeaderControlClickL()
  1011 //------------------------------------------------------------------------------
  1061 //------------------------------------------------------------------------------
  1042     PosToScreenCoordinates( this, aPos );
  1092     PosToScreenCoordinates( this, aPos );
  1043    
  1093    
  1044     iImageSelectionPopup->SetPosition( aPos );
  1094     iImageSelectionPopup->SetPosition( aPos );
  1045     iImageSelectionPopup->ShowMenu();   
  1095     iImageSelectionPopup->ShowMenu();   
  1046 }
  1096 }
       
  1097  
       
  1098 // ----------------------------------------------------------------------------
       
  1099 // CCCAppMyCardContainer::HandleLongTapEventL()
       
  1100 // ----------------------------------------------------------------------------
       
  1101 //
       
  1102 void CCCAppMyCardContainer::HandleLongTapEventL( const TPoint& /*aPenEventLocation*/, 
       
  1103                                     const TPoint& /*aPenEventScreenLocation*/ )
       
  1104     {       
       
  1105     if( iDetailsPopup )
       
  1106         {
       
  1107         iLongTapHandled = ETrue;
       
  1108         iDetailsPopup->ShowMenu();
       
  1109         }
       
  1110     }
       
  1111  
       
  1112 // ----------------------------------------------------------------------------
       
  1113 // CCCAppCommLauncherContainer::HandlePointerEventL()
       
  1114 // ----------------------------------------------------------------------------
       
  1115 //
       
  1116 void CCCAppMyCardContainer::HandlePointerEventL(
       
  1117     const TPointerEvent& aPointerEvent )
       
  1118     {               
       
  1119     TInt index;
       
  1120     TPoint pos = aPointerEvent.iPosition;
       
  1121     
       
  1122     if ( iListBox->View()->XYPosToItemIndex( aPointerEvent.iPosition, index ) )
       
  1123        {
       
  1124        iLongTapDetector->PointerEventL( aPointerEvent );
       
  1125          
       
  1126        if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
       
  1127            {
       
  1128            // Pressed Down Effect
       
  1129            iListBox->View()->ItemDrawer()->SetFlags(
       
  1130                    CListItemDrawer::EPressedDownState );
       
  1131            }
       
  1132        }
       
  1133 
       
  1134    if ( !iDetailsPopup )
       
  1135       {
       
  1136       iDetailsPopup = CAknStylusPopUpMenu::NewL( &iPlugin, aPointerEvent.iPosition ); 
       
  1137       TInt resourceReaderId = R_MYCARD_CONTACT_COPY_DETAIL_STYLUS_MENU; 
       
  1138       TResourceReader reader;
       
  1139       iCoeEnv->CreateResourceReaderLC( reader , resourceReaderId );
       
  1140       iDetailsPopup->ConstructFromResourceL( reader );
       
  1141       CleanupStack::PopAndDestroy(); // reader
       
  1142       }
       
  1143       
       
  1144     PosToScreenCoordinates( this, pos );    
       
  1145     iDetailsPopup->SetPosition( pos );      
       
  1146    
       
  1147     CCoeControl::HandlePointerEventL( aPointerEvent );              
       
  1148     }
  1047 
  1149 
  1048 // ---------------------------------------------------------------------------
  1150 // ---------------------------------------------------------------------------
  1049 // PosToScreenCoordinates
  1151 // CCCAppCommLauncherContainer::PosToScreenCoordinates
  1050 // ---------------------------------------------------------------------------
  1152 // ---------------------------------------------------------------------------
  1051 //
  1153 //
  1052 void CCCAppMyCardContainer::PosToScreenCoordinates( 
  1154 void CCCAppMyCardContainer::PosToScreenCoordinates( 
  1053         CCoeControl* aControl, TPoint& aPos )
  1155         CCoeControl* aControl, TPoint& aPos )
  1054      {
  1156      {