phonebookui/Speeddial/ControlSrc/SpdiaControl_platsec.cpp
changeset 0 e686773b3f54
child 3 04ab22b956c2
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:     A utility that provides services to both the Speeddial and
       
    15 *                PhoneBook applications for getting and setting speeddial
       
    16 *                number configuration.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include <bldvariant.hrh>
       
    23 #include <gulicon.h>
       
    24 #include <akncontext.h>
       
    25 #include <akntitle.h>
       
    26 #include <AknQueryDialog.h>
       
    27 #include <aknlists.h>
       
    28 #include <bautils.h>
       
    29 #include <aknnotedialog.h>
       
    30 #include <aknnotecontrol.h>
       
    31 #include <aknnotewrappers.h>
       
    32 #include <sysutil.h>
       
    33 #include <ErrorUI.h>
       
    34 #include <vmnumber.h>
       
    35 #include <centralrepository.h>
       
    36 #include <SettingsInternalCRKeys.h>
       
    37 #include <SpeeddialPrivateCRKeys.h>
       
    38 #include <telvmbxsettingscrkeys.h>
       
    39 #include <voicemailboxdomaincrkeys.h>
       
    40 #include <CPbkContactEngine.h>      // Phonebook Engine
       
    41 #include <CPbkContactItem.h>        // Phonebook Contact
       
    42 #include <CPbkFieldInfo.h>          // Phonebook Field
       
    43 #include <CPbkSingleItemFetchDlg.h>    // Phonebook Single Entry Fetch API
       
    44 #include <CPbkContactChangeNotifier.h>
       
    45 #include <RPbkViewResourceFile.h>  // Phonebook view dll resource file loader
       
    46 #include <StringLoader.h>
       
    47 #include <Spdctrl.rsg>
       
    48 #include <spdctrl.mbg>
       
    49 #include <avkon.mbg>
       
    50 #include <gdi.h>
       
    51 #include <AknIconArray.h>
       
    52 #include <CPbkThumbnailManager.h>
       
    53 #include <aknlayoutscalable_apps.cdl.h>
       
    54 #include <layoutmetadata.cdl.h>
       
    55 #include <AknsBasicBackgroundControlContext.h>
       
    56 #include <AknsDrawUtils.h>
       
    57 #include <AknsUtils.h>
       
    58 #include <AknIconUtils.h>
       
    59 #include <applayout.cdl.h>
       
    60 #include <data_caging_path_literals.hrh>
       
    61 #include <f32file.h>
       
    62 #include <featmgr.h>
       
    63 #include "SpdiaGrid.h"
       
    64 #include "SpdiaGridDlg.h"
       
    65 #include "SpdiaIndexData.h"
       
    66 #include "SpdiaControl.h"
       
    67 #include "SpdiaControl.hrh"
       
    68 #include "Speeddial.laf"
       
    69 #include "SpdiaPanic.h"
       
    70 #include <SettingsInternalCRKeys.h>
       
    71 #include "speeddial.hrh"
       
    72 
       
    73 #include <aknViewAppUi.h>
       
    74 #include <aknnavi.h> 
       
    75 #include <aknnavide.h> 
       
    76 
       
    77 // const TUint KShortcutKey0('0');  // not referenced
       
    78 const TInt KDialBmpCount = 9;
       
    79 const TInt KDialHindiBmpCount = 9;
       
    80 
       
    81 const TUint KDialBmp[KDialBmpCount] =
       
    82     {
       
    83     //EMbmSpdctrlQgn_graf_quick_one,
       
    84 #ifdef __SCALABLE_ICONS
       
    85     EMbmSpdctrlQgn_menu_smsvo,
       
    86 #else
       
    87     EMbmSpdctrlQgn_menu_smsvo_lst,
       
    88 #endif
       
    89     EMbmSpdctrlQgn_graf_quick_two,
       
    90     EMbmSpdctrlQgn_graf_quick_three,
       
    91     EMbmSpdctrlQgn_graf_quick_four,
       
    92     EMbmSpdctrlQgn_graf_quick_five,
       
    93     EMbmSpdctrlQgn_graf_quick_six,
       
    94     EMbmSpdctrlQgn_graf_quick_seven,
       
    95     EMbmSpdctrlQgn_graf_quick_eight,
       
    96     EMbmSpdctrlQgn_graf_quick_nine
       
    97     };
       
    98 
       
    99 const TUint KDialBmpMask[KDialBmpCount] =
       
   100     {
       
   101     //EMbmSpdctrlQgn_graf_quick_one_mask_soft,
       
   102 #ifdef __SCALABLE_ICONS
       
   103     EMbmSpdctrlQgn_menu_smsvo_mask,
       
   104 #else
       
   105     EMbmSpdctrlQgn_menu_smsvo_lst_mask,
       
   106 #endif
       
   107     EMbmSpdctrlQgn_graf_quick_two_mask,
       
   108     EMbmSpdctrlQgn_graf_quick_three_mask,
       
   109     EMbmSpdctrlQgn_graf_quick_four_mask,
       
   110     EMbmSpdctrlQgn_graf_quick_five_mask,
       
   111     EMbmSpdctrlQgn_graf_quick_six_mask,
       
   112     EMbmSpdctrlQgn_graf_quick_seven_mask,
       
   113     EMbmSpdctrlQgn_graf_quick_eight_mask,
       
   114     EMbmSpdctrlQgn_graf_quick_nine_mask
       
   115     };
       
   116     
       
   117 const TUint KDialHindiBmp[KDialHindiBmpCount] =
       
   118 	{
       
   119    //EMbmSpdctrlQgn_graf_quick_one,
       
   120 #ifdef __SCALABLE_ICONS
       
   121     EMbmSpdctrlQgn_menu_smsvo,
       
   122 #else
       
   123     EMbmSpdctrlQgn_menu_smsvo_lst,
       
   124 #endif
       
   125     EMbmSpdctrlQgn_graf_deva_quick_two,
       
   126     EMbmSpdctrlQgn_graf_deva_quick_three,
       
   127     EMbmSpdctrlQgn_graf_deva_quick_four,
       
   128     EMbmSpdctrlQgn_graf_deva_quick_five,
       
   129     EMbmSpdctrlQgn_graf_deva_quick_six,
       
   130     EMbmSpdctrlQgn_graf_deva_quick_seven,
       
   131     EMbmSpdctrlQgn_graf_deva_quick_eight,
       
   132     EMbmSpdctrlQgn_graf_deva_quick_nine
       
   133   	};
       
   134 
       
   135 const TUint KDialHindiBmpMask[KDialHindiBmpCount] =
       
   136 	{
       
   137    //EMbmSpdctrlQgn_graf_quick_one,
       
   138 #ifdef __SCALABLE_ICONS
       
   139     EMbmSpdctrlQgn_menu_smsvo_mask,
       
   140 #else
       
   141     EMbmSpdctrlQgn_menu_smsvo_lst_mask,
       
   142 #endif
       
   143     EMbmSpdctrlQgn_graf_deva_quick_two_mask,
       
   144     EMbmSpdctrlQgn_graf_deva_quick_three_mask,
       
   145     EMbmSpdctrlQgn_graf_deva_quick_four_mask,
       
   146     EMbmSpdctrlQgn_graf_deva_quick_five_mask,
       
   147     EMbmSpdctrlQgn_graf_deva_quick_six_mask,
       
   148     EMbmSpdctrlQgn_graf_deva_quick_seven_mask,
       
   149     EMbmSpdctrlQgn_graf_deva_quick_eight_mask,
       
   150     EMbmSpdctrlQgn_graf_deva_quick_nine_mask
       
   151   	}; 	
       
   152   	 
       
   153 const TInt KCellRowCount(3);
       
   154 const TInt KCellColCount(3);
       
   155 const TInt KVoiceMail(0);
       
   156 const TInt KLayoutCount(5);
       
   157 const TInt KNullIndexData(-1);
       
   158 const TInt32 KVmbxUid(0x100058F5) ;
       
   159 const TInt KOperatorNameLength(100);
       
   160 const TInt KIconsCount(13);
       
   161 const TInt KIconsIdCount(11);
       
   162 const TInt KIconsMaskCount(11);
       
   163 
       
   164 _LIT(KNullCell, "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t%d\t");
       
   165 _LIT(KDesTab, "\t");
       
   166 _LIT(KDesTab2, "\t\t");
       
   167 
       
   168 /// Unnamed namespace for local definitions
       
   169 namespace {
       
   170 
       
   171 CPbkContactItem* OpenContactL( 
       
   172         CPbkContactEngine* aEngine, 
       
   173         TContactItemId aId )
       
   174     {
       
   175     CPbkContactItem* item = NULL;
       
   176     TRAPD(err, item = aEngine->OpenContactL(aId));
       
   177     if (err != KErrNone)    
       
   178         {
       
   179         CCoeEnv::Static()->HandleError(err);
       
   180         }
       
   181     User::LeaveIfError(err);
       
   182     
       
   183     return item;
       
   184     }
       
   185 
       
   186 } /// namespace
       
   187 
       
   188 
       
   189 // ---------------------------------------------------------
       
   190 // E32Dll(TDllReason)
       
   191 // Entry point function for Symbian dll
       
   192 // Returns: KErrNone: No error
       
   193 // ---------------------------------------------------------
       
   194 //
       
   195 
       
   196 
       
   197 
       
   198 // ================= MEMBER FUNCTIONS =======================
       
   199 
       
   200 // ---------------------------------------------------------
       
   201 // CSpdiaControl::NewL
       
   202 //
       
   203 // ---------------------------------------------------------
       
   204 //
       
   205 EXPORT_C CSpdiaControl* CSpdiaControl::NewL()
       
   206     {
       
   207     CSpdiaControl* self = new(ELeave) CSpdiaControl();
       
   208     CleanupStack::PushL(self);
       
   209     self->ConstructL();
       
   210     CleanupStack::Pop();  // self
       
   211     return self;
       
   212     }
       
   213 
       
   214 // ---------------------------------------------------------
       
   215 // CSpdiaControl::NewL
       
   216 //
       
   217 // ---------------------------------------------------------
       
   218 //
       
   219 EXPORT_C CSpdiaControl* CSpdiaControl::NewL(CPbkContactEngine& aPbkEngine)
       
   220     {
       
   221     CSpdiaControl* self = new(ELeave) CSpdiaControl(&aPbkEngine);
       
   222     CleanupStack::PushL(self);
       
   223     self->ConstructL();
       
   224     CleanupStack::Pop();  // self
       
   225     return self;
       
   226     }
       
   227 
       
   228 // ---------------------------------------------------------
       
   229 // CSpdiaControl::AssignDialNumberL
       
   230 // Function called when assigning a speed dial
       
   231 // from the Idle state.
       
   232 // ---------------------------------------------------------
       
   233 //
       
   234 EXPORT_C TBool CSpdiaControl::AssignDialNumberL(
       
   235              TInt aLocation, CEikStatusPane* /*aStatusPane*/)
       
   236     {
       
   237     TBool result(EFalse);
       
   238     TInt index(Index(aLocation));
       
   239 
       
   240     TInt vmbxSupport = 0;
       
   241     CRepository* vmbxSupported = CRepository::NewL( KCRUidVideoMailbox );
       
   242     vmbxSupported->Get( KVideoMbxSupport, vmbxSupport );
       
   243     delete vmbxSupported;
       
   244     
       
   245     TInt vmbxPos;
       
   246     CRepository*  vmbxKey2 = CRepository::NewL( KCRUidTelVideoMailbox );
       
   247     vmbxKey2->Get( KTelVideoMbxKey, vmbxPos );
       
   248     delete vmbxKey2;
       
   249     TInt vdoIndex( Index( vmbxPos ) );
       
   250     
       
   251     if ( index != VMBoxPosition() && 
       
   252         ( !vmbxSupport || index != vdoIndex ) && 
       
   253         ( aLocation > 0 && aLocation <= iSdmCount) )
       
   254         {
       
   255         result = ETrue;
       
   256         if (ContactId(index) == KNullContactId)
       
   257             {
       
   258             // Assign it now?
       
   259             iQueryDialog = CAknQueryDialog::NewL(CAknQueryDialog::ENoTone);
       
   260             TBool resDialog(EFalse);
       
   261             TRAPD(error,
       
   262                 resDialog = iQueryDialog->ExecuteLD(R_SPDIA_QUERY_ASSIGN) );
       
   263             iQueryDialog = NULL;
       
   264             User::LeaveIfError(error);
       
   265             if (!resDialog)
       
   266                 {
       
   267                 result = EFalse;
       
   268                 }
       
   269             }
       
   270 
       
   271         if (result)
       
   272             {
       
   273             iPopupDialog = ETrue;
       
   274             
       
   275             result = AssignDialIndexL(index);
       
   276             
       
   277             
       
   278             }
       
   279            iPopupDialog = EFalse;
       
   280         }
       
   281     return result;
       
   282     }
       
   283 
       
   284 // ---------------------------------------------------------
       
   285 // CSpdiaControl::ExecuteLD
       
   286 //
       
   287 // ---------------------------------------------------------
       
   288 //
       
   289 EXPORT_C TInt CSpdiaControl::ExecuteLD(
       
   290              TContactItemId aId, TInt aFieldIdx)
       
   291     {
       
   292     // Live up to the "D"
       
   293     CleanupStack::PushL(this);
       
   294 
       
   295     // Check if the item is available now, otherwise leave happens
       
   296     // Open current contact now, in order to get the lock.
       
   297     CPbkContactItem* item = OpenContactL( iEngine, aId );
       
   298     CleanupStack::PushL(item);
       
   299 
       
   300     // Create a CPbkFetchEntryDlg dialog
       
   301     TInt dial;
       
   302     iGridDlg = CSpdiaGridDlg::NewL(dial, *this);
       
   303 
       
   304     CEikAppUi* pAppUi = NULL;
       
   305     CAknNavigationDecorator *pNaviDecorator = NULL;
       
   306     CAknTitlePane* titlePane = NULL;
       
   307     HBufC* title = NULL;
       
   308     pAppUi = CEikonEnv::Static()->EikAppUi();
       
   309     if ( pAppUi )
       
   310         {
       
   311         CEikStatusPane* StatusPane = ((CAknAppUi*) pAppUi)->StatusPane();
       
   312         TUid naviPaneUid;
       
   313         naviPaneUid.iUid = EEikStatusPaneUidNavi;
       
   314         CAknNavigationControlContainer*naviPane = (CAknNavigationControlContainer *) StatusPane->ControlL(naviPaneUid);
       
   315         pNaviDecorator = naviPane->Top();
       
   316         if ( pNaviDecorator )
       
   317             {
       
   318             pNaviDecorator->MakeVisible( EFalse );
       
   319             pNaviDecorator->DrawNow();
       
   320             }
       
   321         
       
   322         titlePane =  STATIC_CAST(CAknTitlePane*, StatusPane->ControlL( TUid::Uid(EEikStatusPaneUidTitle) ) );
       
   323         title = titlePane->Text()->AllocLC();
       
   324         }
       
   325         
       
   326     // Execute the CPbkFetchEntryDlg dialog
       
   327     TInt result(ETrue);
       
   328     TRAPD(error, result = iGridDlg->ExecuteLD(R_SPDIA_GRID_DIALOG));
       
   329     iGridDlg = NULL;
       
   330     iIconArray = NULL;
       
   331 
       
   332     if ( pNaviDecorator )
       
   333         {
       
   334         pNaviDecorator->MakeVisible( ETrue );
       
   335         pNaviDecorator->DrawNow();
       
   336         }
       
   337     if ( title )
       
   338         {
       
   339         titlePane->SetText( title );
       
   340         CleanupStack::Pop();  // title
       
   341         titlePane->DrawNow();
       
   342         }
       
   343         
       
   344     // Check errors
       
   345     User::LeaveIfError(error);
       
   346 
       
   347     // unlock the item( contact ) so that it can be removed or assigend after back from speedial grid
       
   348     // delete item;
       
   349     iEngine->CloseContactL(aId);
       
   350     CleanupStack::PopAndDestroy();  // item
       
   351     
       
   352     if (result && !CheckSpaceBelowCriticalLevelL())
       
   353         {
       
   354         AssignDialL(aId, aFieldIdx, dial);
       
   355         }
       
   356     
       
   357     // Cleanup and return
       
   358     CleanupStack::PopAndDestroy();  // this
       
   359     return (result);
       
   360     }
       
   361 
       
   362 // ---------------------------------------------------------
       
   363 // CSpdiaControl::Cancel
       
   364 //
       
   365 // ---------------------------------------------------------
       
   366 //
       
   367 EXPORT_C void CSpdiaControl::Cancel()
       
   368     {
       
   369     if ( iPbkSingleItem )
       
   370         {
       
   371         delete iPbkSingleItem;
       
   372         iPbkSingleItem = NULL;
       
   373         }
       
   374     
       
   375     if ( iQueryDialog )
       
   376         {
       
   377         delete iQueryDialog;
       
   378         iQueryDialog = NULL;	
       
   379         }
       
   380     
       
   381         iSaveDlg = ETrue;
       
   382     }
       
   383 
       
   384 // ---------------------------------------------------------
       
   385 // CSpdiaControl::DialNumberL
       
   386 //
       
   387 // ---------------------------------------------------------
       
   388 //
       
   389 EXPORT_C TBool CSpdiaControl::DialNumberL(TInt aLocation,
       
   390                 TDes& aPhoneNumber, CEikStatusPane* /*aStatusPane*/)
       
   391     {
       
   392     TBool result(ETrue);
       
   393     TInt index(Index(aLocation));
       
   394     if (index == VMBoxPosition())
       
   395         {
       
   396         result = VoiceMailL(aPhoneNumber);
       
   397         }
       
   398     else
       
   399         {
       
   400         if (ContactId(index) == KNullContactId)
       
   401             {
       
   402             result = AssignDialNumberL(aLocation);
       
   403             }
       
   404         if (result)
       
   405             {
       
   406             aPhoneNumber = (*iSdmArray)[index].PhoneNumber();
       
   407             }
       
   408         }
       
   409     return result;
       
   410     }
       
   411 
       
   412 // ---------------------------------------------------------
       
   413 // CSpdiaControl::CSpdiaControl
       
   414 //
       
   415 // ---------------------------------------------------------
       
   416 //
       
   417 CSpdiaControl::CSpdiaControl()
       
   418   : iIconsCount( KIconsCount ), iIconsIdCount( KIconsIdCount  ), iIconsMaskCount( KIconsMaskCount )    
       
   419     {
       
   420     if ( !( FeatureManager::FeatureSupported( KFeatureIdCommonVoip ) ) ) 
       
   421         { 
       
   422         iIconsCount -= 1; 
       
   423         iIconsIdCount -= 1; 
       
   424         iIconsMaskCount  -= 1; 
       
   425         } 
       
   426     }
       
   427 // ---------------------------------------------------------
       
   428 // CSpdiaControl::InitializeArray
       
   429 //
       
   430 // ---------------------------------------------------------
       
   431 void CSpdiaControl::InitializeArray()
       
   432     {
       
   433     iDialSkinBmp->Append( KAknsIIDQgnMenuSmsvoLst );
       
   434     iDialSkinBmp->Append( KAknsIIDQgnGrafQuickTwo );
       
   435     iDialSkinBmp->Append( KAknsIIDQgnGrafQuickThree );
       
   436     iDialSkinBmp->Append( KAknsIIDQgnGrafQuickFour );
       
   437     iDialSkinBmp->Append( KAknsIIDQgnGrafQuickFive );
       
   438     iDialSkinBmp->Append( KAknsIIDQgnGrafQuickSix );
       
   439     iDialSkinBmp->Append( KAknsIIDQgnGrafQuickSeven );
       
   440     iDialSkinBmp->Append( KAknsIIDQgnGrafQuickEight );
       
   441     iDialSkinBmp->Append( KAknsIIDQgnGrafQuickNine );
       
   442 
       
   443     iSkinIcons->Append( KAknsIIDQgnPropNrtypPhone );
       
   444     iSkinIcons->Append( KAknsIIDQgnPropNrtypHome );
       
   445     iSkinIcons->Append( KAknsIIDQgnPropNrtypWork );
       
   446     iSkinIcons->Append( KAknsIIDQgnPropNrtypMobile );
       
   447     iSkinIcons->Append( KAknsIIDQgnPropNrtypVideo );
       
   448     iSkinIcons->Append( KAknsIIDQgnPropNrtypFax );
       
   449     iSkinIcons->Append( KAknsIIDQgnPropNrtypPager );
       
   450     iSkinIcons->Append( KAknsIIDQgnPropNrtypCar );
       
   451     if ( FeatureManager::FeatureSupported(KFeatureIdCommonVoip) )
       
   452     	{
       
   453         iSkinIcons->Append( KAknsIIDQgnPropNrtypVoip );  
       
   454         }
       
   455     iSkinIcons->Append( KAknsIIDQgnPropNrtypAssistant );
       
   456     iSkinIcons->Append(KAknsIIDQgnPropEmpty);
       
   457     iSkinIcons->Append( KAknsIIDQgnPropNrtypEmail );
       
   458     iSkinIcons->Append( KAknsIIDQgnPropNrtypAddress );
       
   459     
       
   460     // LOCAL CONSTANTS AND MACROS
       
   461     //This order is based on 'Standard field ids' (PbkFields.hrh)
       
   462     iIcons->Append( EMbmAvkonQgn_prop_nrtyp_phone );
       
   463     iIcons->Append( EMbmAvkonQgn_prop_nrtyp_home );
       
   464     iIcons->Append( EMbmAvkonQgn_prop_nrtyp_work );
       
   465     iIcons->Append( EMbmAvkonQgn_prop_nrtyp_mobile  );
       
   466     iIcons->Append( EMbmAvkonQgn_prop_nrtyp_video  );
       
   467     iIcons->Append( EMbmAvkonQgn_prop_nrtyp_fax  );
       
   468     iIcons->Append( EMbmAvkonQgn_prop_nrtyp_pager  );
       
   469     iIcons->Append( EMbmAvkonQgn_prop_nrtyp_car  );
       
   470     if ( FeatureManager::FeatureSupported(KFeatureIdCommonVoip) )
       
   471     	{
       
   472         iIcons->Append( EMbmAvkonQgn_prop_nrtyp_voip   );
       
   473     	}
       
   474     iIcons->Append( EMbmAvkonQgn_prop_nrtyp_assistant  );
       
   475     iIcons->Append( EMbmAvkonQgn_prop_empty);
       
   476     iIcons->Append( EMbmAvkonQgn_prop_nrtyp_email  );
       
   477     iIcons->Append( EMbmAvkonQgn_prop_nrtyp_address );
       
   478     
       
   479     iIconsId->Append( EPbkqgn_prop_nrtyp_phone  );
       
   480     iIconsId->Append( EPbkqgn_prop_nrtyp_home );
       
   481     iIconsId->Append( EPbkqgn_prop_nrtyp_work );
       
   482     iIconsId->Append( EPbkqgn_prop_nrtyp_mobile  );
       
   483     iIconsId->Append( EPbkqgn_prop_nrtyp_video  );
       
   484     iIconsId->Append( EPbkqgn_prop_nrtyp_fax  );
       
   485     iIconsId->Append( EPbkqgn_prop_nrtyp_pager  );
       
   486     iIconsId->Append( EPbkqgn_prop_nrtyp_car  );
       
   487     if ( FeatureManager::FeatureSupported(KFeatureIdCommonVoip) )
       
   488     	{
       
   489     	iIconsId->Append( EPbkqgn_prop_nrtyp_voip   );
       
   490     	}
       
   491     iIconsId->Append( EPbkqgn_prop_nrtyp_assistant  );
       
   492     iIconsId->Append( EPbkqgn_prop_nrtyp_empty);
       
   493     
       
   494     iIconsMask->Append( EMbmAvkonQgn_prop_nrtyp_phone_mask );
       
   495     iIconsMask->Append( EMbmAvkonQgn_prop_nrtyp_home_mask );
       
   496     iIconsMask->Append( EMbmAvkonQgn_prop_nrtyp_work_mask );
       
   497     iIconsMask->Append( EMbmAvkonQgn_prop_nrtyp_mobile_mask  );
       
   498     iIconsMask->Append( EMbmAvkonQgn_prop_nrtyp_video_mask  );
       
   499     iIconsMask->Append( EMbmAvkonQgn_prop_nrtyp_fax_mask  );
       
   500     iIconsMask->Append( EMbmAvkonQgn_prop_nrtyp_pager_mask  );
       
   501     iIconsMask->Append( EMbmAvkonQgn_prop_nrtyp_car_mask  );
       
   502     if ( FeatureManager::FeatureSupported(KFeatureIdCommonVoip) )
       
   503     	{
       
   504     	iIconsMask->Append( EMbmAvkonQgn_prop_nrtyp_voip_mask   );
       
   505     	}
       
   506     iIconsMask->Append( EMbmAvkonQgn_prop_nrtyp_assistant_mask  );
       
   507     iIconsMask->Append( EMbmAvkonQgn_prop_empty_mask);
       
   508     }
       
   509 // ---------------------------------------------------------
       
   510 // CSpdiaControl::CSpdiaControl
       
   511 //
       
   512 // ---------------------------------------------------------
       
   513 //
       
   514 CSpdiaControl::CSpdiaControl( CPbkContactEngine* aPbkEngine )
       
   515     : iEngine( aPbkEngine ), iExEngine( ETrue ), iFocusedGrid( KNullIndexData ), 
       
   516     iIconsCount( KIconsCount ), iIconsIdCount( KIconsIdCount  ), iIconsMaskCount( KIconsMaskCount )  
       
   517     {
       
   518     }
       
   519 
       
   520 // ---------------------------------------------------------
       
   521 // CSpdiaControl::~CSpdiaControl
       
   522 //
       
   523 // ---------------------------------------------------------
       
   524 //
       
   525 EXPORT_C CSpdiaControl::~CSpdiaControl()
       
   526     {
       
   527     //delete iThumbFactory;
       
   528     delete iManager;
       
   529     delete iShadowLayout;
       
   530 
       
   531     delete iPbkNotifier;
       
   532     if ( iGridUsed == EGridNoUse )
       
   533         {
       
   534         if ( iIconArray )
       
   535             {
       
   536             iIconArray->ResetAndDestroy();
       
   537             delete iIconArray;
       
   538             }
       
   539         }
       
   540     if (!iExEngine)
       
   541         {
       
   542         delete iEngine;
       
   543         }
       
   544 
       
   545     ResetArray();
       
   546     delete iSdmArray;
       
   547 
       
   548     delete iPbkSingleItem;
       
   549     delete iQueryDialog;
       
   550 
       
   551     if (iPbkResourceFile != NULL)
       
   552         {
       
   553         iPbkResourceFile->Close();
       
   554         }
       
   555     delete iPbkResourceFile;
       
   556 
       
   557     if (iCoeEnv != NULL)
       
   558         {
       
   559         iCoeEnv->DeleteResourceFile(iFileOffset);
       
   560         }
       
   561     delete iBgContext;
       
   562 
       
   563     if ( iDialSkinBmp != NULL )
       
   564         {
       
   565         iDialSkinBmp->Close();
       
   566         }
       
   567     delete iDialSkinBmp;
       
   568 
       
   569     if ( iSkinIcons !=  NULL )
       
   570         {
       
   571         iSkinIcons->Close();
       
   572         }
       
   573     delete iSkinIcons;
       
   574     if ( iIcons !=  NULL ) 
       
   575         { 
       
   576         iIcons->Close(); 
       
   577         } 
       
   578     delete iIcons; 
       
   579        
       
   580     if ( iIconsId !=  NULL ) 
       
   581         { 
       
   582         iIconsId->Close(); 
       
   583         } 
       
   584     delete iIconsId; 
       
   585        
       
   586     if ( iIconsMask !=  NULL ) 
       
   587         { 
       
   588         iIconsMask->Close(); 
       
   589         } 
       
   590     delete iIconsMask; 
       
   591     }
       
   592 
       
   593 // ---------------------------------------------------------
       
   594 // CSpdiaControl::VoiceMailL
       
   595 //
       
   596 // ---------------------------------------------------------
       
   597 //
       
   598 EXPORT_C TBool CSpdiaControl::VoiceMailL(TDes& aNumber)
       
   599     {
       
   600     TBool result(ETrue);
       
   601 
       
   602     RVmbxNumber vmbx;
       
   603     CleanupClosePushL(vmbx); // So that Close() is called if a leave happens.
       
   604     if ( vmbx.Open() == KErrNone )
       
   605         {
       
   606         TInt err1 = vmbx.GetVmbxNumber( aNumber );
       
   607         TInt err2 = vmbx.GetVideoMbxNumber( aNumber );
       
   608                     
       
   609         if ( ( err1 == KErrNotFound || err1 == KErrNotSupported ) &&
       
   610              ( err2 == KErrNotFound || err2 == KErrNotSupported ))
       
   611             {
       
   612             iType = vmbx.SelectTypeL( EVmbxDefine );
       
   613             }
       
   614         else 
       
   615             {
       
   616             iType = vmbx.SelectTypeL( EVmbxCall );
       
   617             }   
       
   618         
       
   619         if( iType == EVmbxIP && !vmbx.IsVoIPProfilesFound() )
       
   620             {
       
   621             TInt err( vmbx.GetVmbxAddressL( aNumber ) );
       
   622             if ( err != KErrNone )
       
   623                 {
       
   624                 aNumber.Zero();
       
   625                 if (err != KErrNotFound || !vmbx.QueryAddressL( EVmbxNotDefinedQuery, aNumber ) )
       
   626                     {
       
   627                     result = EFalse;
       
   628                     }
       
   629                 }
       
   630             }
       
   631         else if( iType == EVmbxVideo )
       
   632             {
       
   633             TInt err( vmbx.GetVideoMbxNumber( aNumber ) );
       
   634             if ( err != KErrNone  )
       
   635                 {
       
   636                 aNumber.Zero();
       
   637                 if ( err != KErrNotFound ||!vmbx.QueryVideoMbxNumberL( EVmbxNotDefinedQuery, aNumber) )
       
   638                     {
       
   639                     result = EFalse;
       
   640                     }
       
   641                 }            
       
   642             }
       
   643         else if ( iType ==EVmbx )
       
   644             {
       
   645             TInt err( vmbx.GetVmbxNumber( aNumber ) );
       
   646             if ( err != KErrNone )
       
   647                 {
       
   648                 aNumber.Zero();
       
   649                 if (err != KErrNotFound || !vmbx.QueryNumberL( EVmbxNotDefinedQuery, aNumber ) )
       
   650                     {
       
   651                     result = EFalse;
       
   652                     }
       
   653                 }
       
   654             }
       
   655         else
       
   656             {
       
   657             result = EFalse;
       
   658             }
       
   659         }
       
   660     CleanupStack::PopAndDestroy();  // It will call vmbx.Close()
       
   661     return result;
       
   662     }
       
   663 
       
   664 // ---------------------------------------------------------
       
   665 // CSpdiaControl::PbkEngine
       
   666 // phone book engine pointer
       
   667 // ---------------------------------------------------------
       
   668 //
       
   669 EXPORT_C CPbkContactEngine* CSpdiaControl::PbkEngine() const
       
   670     {
       
   671     return iEngine;
       
   672     }
       
   673 
       
   674 // ---------------------------------------------------------
       
   675 // CSpdiaControl::Index
       
   676 //
       
   677 // ---------------------------------------------------------
       
   678 //
       
   679 EXPORT_C TInt CSpdiaControl::Index(TInt aDial) const
       
   680     {
       
   681     return ( aDial - 1 );
       
   682     }
       
   683 
       
   684 // ---------------------------------------------------------
       
   685 // CSpdiaControl::Number
       
   686 // An interface for accessing index data array
       
   687 // ---------------------------------------------------------
       
   688 //
       
   689 EXPORT_C TInt CSpdiaControl::Number(TInt aIndex) const
       
   690     {
       
   691     return (*iSdmArray)[aIndex].Number();
       
   692     }
       
   693 
       
   694 // ---------------------------------------------------------
       
   695 // CSpdiaControl::ContactId
       
   696 // An interface for accessing index data array
       
   697 // ---------------------------------------------------------
       
   698 //
       
   699 EXPORT_C TContactItemId CSpdiaControl::ContactId(TInt aIndex) const
       
   700     {
       
   701     return (*iSdmArray)[aIndex].ContactId();
       
   702     }
       
   703 
       
   704 // ---------------------------------------------------------
       
   705 // CSpdiaControl::PhoneDialNumber
       
   706 // An interface for accessing index data array.
       
   707 // ---------------------------------------------------------
       
   708 //
       
   709 EXPORT_C const TDesC& CSpdiaControl::PhoneDialNumber(TInt aDial) const
       
   710     {
       
   711     return (*iSdmArray)[Index(aDial)].TelNumber();
       
   712     }
       
   713 
       
   714 // ---------------------------------------------------------
       
   715 // CSpdiaControl::PhoneNumber
       
   716 // An interface for accessing index data array.
       
   717 // ---------------------------------------------------------
       
   718 //
       
   719 EXPORT_C const TDesC& CSpdiaControl::PhoneNumber(TInt aIndex) const
       
   720     {
       
   721     return (*iSdmArray)[aIndex].PhoneNumber();
       
   722     }
       
   723 
       
   724 // ---------------------------------------------------------
       
   725 // CSpdiaControl::ContactTitleL
       
   726 // phone book access
       
   727 // ---------------------------------------------------------
       
   728 EXPORT_C HBufC* CSpdiaControl::ContactTitleL(TContactItemId aCid, TBool aUnnamed)
       
   729     {
       
   730     HBufC* title = NULL;
       
   731     if (aCid != KNullContactId)
       
   732         {
       
   733         CPbkContactItem* item =
       
   734                 iEngine->ReadContactLC(aCid);
       
   735         if ((title = item->GetContactTitleOrNullL()) == NULL && aUnnamed)
       
   736             {
       
   737             title = iEngine->UnnamedTitle().AllocL();
       
   738             }
       
   739         CleanupStack::PopAndDestroy(); // item
       
   740         }
       
   741 
       
   742     return title;
       
   743     }
       
   744 
       
   745 // ---------------------------------------------------------
       
   746 // CSpdiaControl::ThumbIndex
       
   747 // An interface for accessing index data array.
       
   748 // ---------------------------------------------------------
       
   749 //
       
   750 EXPORT_C TInt CSpdiaControl::ThumbIndex(TInt aIndex) const
       
   751     {
       
   752     return (*iSdmArray)[aIndex].ThumbIndex();
       
   753     }
       
   754 
       
   755 // ---------------------------------------------------------
       
   756 // CSpdiaControl::IconIndex
       
   757 // An interface for accessing index data array.
       
   758 // ---------------------------------------------------------
       
   759 //
       
   760 EXPORT_C TInt CSpdiaControl::IconIndex(TInt aIndex) const
       
   761     {
       
   762     TInt index = (*iSdmArray)[aIndex].IconIndex();
       
   763     if (index >= 0)
       
   764         {
       
   765         return ( *iIconsMask )[index - iSdmCount];
       
   766         }
       
   767     return index;
       
   768     }
       
   769 
       
   770 // ---------------------------------------------------------
       
   771 // CSpdiaControl::NumberType
       
   772 // An interface for accessing phone number type.
       
   773 // Number types are defined in PbkFields.hrh.
       
   774 // ---------------------------------------------------------
       
   775 //
       
   776 EXPORT_C TInt CSpdiaControl::NumberType(TInt aIndex) const
       
   777     {
       
   778     return (*iSdmArray)[aIndex].FieldId();
       
   779     }
       
   780 
       
   781 // ---------------------------------------------------------
       
   782 // CSpdiaControl::IconArray
       
   783 // An interface for accessing index data array.
       
   784 // ---------------------------------------------------------
       
   785 //
       
   786 EXPORT_C CArrayPtr<CGulIcon>* CSpdiaControl::IconArray() const
       
   787     {
       
   788     return iIconArray;
       
   789     }
       
   790 
       
   791 // ---------------------------------------------------------
       
   792 // CSpdiaControl::CreateGridDataL
       
   793 //
       
   794 // ---------------------------------------------------------
       
   795 //
       
   796 EXPORT_C TBool CSpdiaControl::CreateGridDataL(
       
   797                 CAknGrid* aGrid, TBool aIndex)
       
   798     {
       
   799     iGrid = aGrid;
       
   800     if (iGridUsed == EGridNoUse)
       
   801         {
       
   802         iGridUsed = EGridUse;
       
   803         }
       
   804 
       
   805     // The specified index is updated.
       
   806     if (aIndex >= 0)
       
   807         {
       
   808         return UpdateIndexDataL(aIndex);
       
   809         }
       
   810 
       
   811     // All items are updated.
       
   812     CDesCArray* array =
       
   813         STATIC_CAST(CDesCArray*, aGrid->Model()->ItemTextArray());
       
   814     array->Reset();
       
   815     InitIndexDataL();
       
   816     if (SetIconArrayL(iIconArray) > 0)
       
   817         {
       
   818         SetOperationsL();
       
   819         }
       
   820 
       
   821     TKeyArrayFix key(TSpdiaIndexData::OffsetValue(
       
   822                     TSpdiaIndexData::EIndex), ECmpTInt);
       
   823     iSdmArray->Sort(key);
       
   824 
       
   825     TRAPD(err, SetItemDataL(*array));
       
   826     if (err)
       
   827         {
       
   828         array->Reset();
       
   829         User::Leave(err);
       
   830         }
       
   831 
       
   832     CFormattedCellListBoxData* list = aGrid->ItemDrawer()->FormattedCellData();
       
   833     if (list->IconArray() == NULL)
       
   834         {
       
   835         aGrid->ItemDrawer()->FormattedCellData()->SetIconArrayL(iIconArray);
       
   836         }
       
   837 
       
   838     return ETrue;
       
   839     }
       
   840 
       
   841 // ---------------------------------------------------------
       
   842 // CSpdiaControl::CheckingIfPopUpNeeded
       
   843 // Internal rutine to check if pop up has to be shown
       
   844 // to enable the One-Key-Dialling setting.
       
   845 // ---------------------------------------------------------
       
   846 //
       
   847 
       
   848 EXPORT_C TBool CSpdiaControl::CheckingIfPopUpNeeded()
       
   849     {
       
   850 		TBool result(ETrue);
       
   851 		TRAP_IGNORE(result = CheckingIfPopUpNeededL());
       
   852 		
       
   853 		return result;
       
   854     }
       
   855 
       
   856 // ---------------------------------------------------------
       
   857 // CSpdiaControl::CheckingIfPopUpNeededL
       
   858 // Internal rutine to check if pop up has to be shown
       
   859 // to enable the One-Key-Dialling setting.
       
   860 // ---------------------------------------------------------
       
   861 //
       
   862 
       
   863 TBool CSpdiaControl::CheckingIfPopUpNeededL()
       
   864     {
       
   865     TBool gridEmpty( ETrue );
       
   866     TInt  gridIndex( 1 );
       
   867     TInt value;
       
   868     TBool result( ETrue );
       
   869 
       
   870     CRepository* repository = CRepository::NewL( KCRUidTelephonySettings );
       
   871     repository->Get( KSettingsOneKeyDialling, value );
       
   872 
       
   873     if ( value == 0 )
       
   874         {
       
   875         while ( ( gridIndex < 9 ) && gridEmpty )
       
   876             {
       
   877             if ( CSpdiaControl::ContactId( gridIndex ) != KNullContactId )
       
   878                 {
       
   879                 gridEmpty=EFalse;
       
   880                 }
       
   881             ++gridIndex;
       
   882             }
       
   883         if ( gridEmpty )
       
   884             {
       
   885             iSaveDlg = EFalse;     
       
   886             if( iSaveDlg )
       
   887                 {
       
   888                 delete repository;
       
   889                 return EFalse;
       
   890                 }
       
   891 
       
   892             repository->Set( KSettingsOneKeyDialling, 1 );
       
   893             }
       
   894         }
       
   895     delete repository;
       
   896     return result;
       
   897     }
       
   898 
       
   899 // ---------------------------------------------------------
       
   900 // CSpdiaControl::AssignDialIndexL
       
   901 // Function called when the access is done through
       
   902 // the speed dial application.
       
   903 // ---------------------------------------------------------
       
   904 //
       
   905 EXPORT_C TBool CSpdiaControl::AssignDialIndexL(TInt aIndex)
       
   906     {
       
   907     TBool result(EFalse);
       
   908     HBufC* prompt = NULL;
       
   909     TBuf<KOperatorNameLength> operatorName;
       
   910     CAknTitlePane* title = NULL;
       
   911 
       
   912     if (iBooleanVarForAddingDialogVariation)
       
   913         {
       
   914         if(iPopupDialog)
       
   915             {
       
   916             if(!CSpdiaControl::CheckingIfPopUpNeeded())
       
   917                 return result;
       
   918             }
       
   919         }
       
   920     else
       
   921         {   // do nothing
       
   922         }
       
   923 
       
   924     if(iPopupDialog)
       
   925         {
       
   926     		CEikStatusPane *sp = CEikonEnv::Static()->AppUiFactory()->StatusPane();
       
   927         title =  STATIC_CAST(CAknTitlePane*, sp->ControlL( TUid::Uid(EEikStatusPaneUidTitle) ) );
       
   928         prompt = StringLoader::LoadLC(R_QTN_SPDIA_TITLE, iCoeEnv);
       
   929         operatorName.Copy(*title->Text());
       
   930         title->SetTextL(*prompt);
       
   931         title->MakeVisible(ETrue);
       
   932         CleanupStack::PopAndDestroy(prompt); 
       
   933         }
       
   934     // Contact id before selection is saved.
       
   935     TContactItemId id(ContactId(aIndex));
       
   936     CContactDatabase::TContactViewFilter filter( CContactDatabase::EPhonable );
       
   937     
       
   938     // No filtering if VoIP is supported.
       
   939     TInt VoIPSupported( 0 );
       
   940     if ( FeatureManager::FeatureSupported( KFeatureIdCommonVoip ) )
       
   941         {
       
   942         CRepository* voiprepository = CRepository::NewL( KCRUidTelephonySettings );
       
   943         voiprepository->Get( KDynamicVoIP, VoIPSupported );
       
   944         delete voiprepository;
       
   945     
       
   946         if ( 0 < VoIPSupported )
       
   947             {
       
   948             filter = CContactDatabase::EUnfiltered; 
       
   949             }
       
   950         }
       
   951     
       
   952     CContactViewBase& filteredView = iEngine->FilteredContactsViewL( filter );        
       
   953 
       
   954     CPbkSingleItemFetchDlg::TParams params;
       
   955     // The array of fieldId to display is made.
       
   956     CPbkFieldIdArray* fieldIds = new (ELeave) CPbkFieldIdArray();
       
   957     CleanupStack::PushL(fieldIds);
       
   958     fieldIds->AppendL(EPbkFieldIdPhoneNumberStandard);
       
   959     fieldIds->AppendL(EPbkFieldIdPhoneNumberHome);
       
   960     fieldIds->AppendL(EPbkFieldIdPhoneNumberWork);
       
   961     fieldIds->AppendL(EPbkFieldIdPhoneNumberMobile);
       
   962 		fieldIds->AppendL(EPbkFieldIdAssistantNumber);//changed 
       
   963 		fieldIds->AppendL(EPbkFieldIdCarNumber);//changed
       
   964     fieldIds->AppendL(EPbkFieldIdPhoneNumberVideo);
       
   965     fieldIds->AppendL(EPbkFieldIdFaxNumber);
       
   966     fieldIds->AppendL(EPbkFieldIdPagerNumber);
       
   967     if ( VoIPSupported )
       
   968         {
       
   969         fieldIds->AppendL(EPbkFieldIdVOIP);  
       
   970         }
       
   971     params.iFieldIdArray = fieldIds;
       
   972     params.iContactView = &filteredView;
       
   973     iPbkSingleItem = CPbkSingleItemFetchDlg::NewL(params, *iEngine);
       
   974 
       
   975     TRAPD(error, result = iPbkSingleItem->ExecuteLD());
       
   976     iPbkSingleItem = NULL;
       
   977     User::LeaveIfError(error);
       
   978 
       
   979     CleanupStack::PushL(params.iContactItem);
       
   980     if (result && params.iContactItem != NULL)
       
   981         {
       
   982         result = ETrue;
       
   983         // It is already assigned from other applications.
       
   984         if (id == KNullContactId && ContactId(aIndex) != KNullContactId)
       
   985             {
       
   986             id = ContactId(aIndex);
       
   987             }
       
   988 
       
   989         if (result && !CheckSpaceBelowCriticalLevelL())
       
   990             {
       
   991             if (id != KNullContactId)
       
   992                 {
       
   993                 RemoveDialIndexL(aIndex, EFalse);
       
   994                 (*iSdmArray)[aIndex].SetContactId(KNullContactId);
       
   995                 }
       
   996 
       
   997             CPbkContactItem* item =
       
   998             iEngine->OpenContactL(params.iContactItem->Id());
       
   999             CleanupStack::PushL(item);
       
  1000 
       
  1001             TPhCltTelephoneNumber phonenumber;
       
  1002             params.iContactItemField->GetTextL(phonenumber);
       
  1003             CPbkFieldInfo& info = params.iContactItemField->FieldInfo();
       
  1004 
       
  1005             CPbkFieldArray& array = item->CardFields();
       
  1006             for (TInt index(0); index < array.Count(); ++index)
       
  1007                 {
       
  1008                 if (array[index].ItemField().Id() ==
       
  1009                         params.iContactItemField->ItemField().Id())
       
  1010                     {
       
  1011                     iEngine->SetFieldAsSpeedDialL(*item,
       
  1012                                         index, (*iSdmArray)[aIndex].Number());
       
  1013                     (*iSdmArray)[aIndex].SetContactId(params.iContactItem->Id());
       
  1014                     (*iSdmArray)[aIndex].SetPhoneNumber(phonenumber);
       
  1015                     (*iSdmArray)[aIndex].SetIconIndex(FindIconIndex(info.IconId()));
       
  1016                     (*iSdmArray)[aIndex].SetThumbIndex(aIndex, NULL);
       
  1017                     index = array.Count();
       
  1018                     }
       
  1019                 }
       
  1020             iEngine->CloseContactL(params.iContactItem->Id());
       
  1021             CleanupStack::PopAndDestroy();  // item
       
  1022             }
       
  1023         }
       
  1024     CleanupStack::PopAndDestroy(2); // params.iContactItem, fieldIds
       
  1025     if(iPopupDialog)
       
  1026         {
       
  1027         title->SetTextL(operatorName);
       
  1028         }
       
  1029     return result;
       
  1030     }
       
  1031 
       
  1032 // ---------------------------------------------------------
       
  1033 // CSpdiaControl::RemoveDialIndexL
       
  1034 // phone book access
       
  1035 // ---------------------------------------------------------
       
  1036 //
       
  1037 EXPORT_C TBool CSpdiaControl::RemoveDialIndexL(TInt aIndex, TBool aConfirmation)
       
  1038     {
       
  1039     TBool release(ETrue);
       
  1040 
       
  1041     if (release)
       
  1042         {
       
  1043         TContactItemId cid((*iSdmArray)[aIndex].ContactId());
       
  1044         TInt pos((*iSdmArray)[aIndex].Number());
       
  1045         release = EFalse;
       
  1046         if (cid != KNullContactId && (aIndex >= 0 && aIndex < iSdmCount))
       
  1047             {
       
  1048             iEngine->RemoveSpeedDialFieldL(cid, pos);
       
  1049             (*iSdmArray)[aIndex].SetContactId(KNullContactId);
       
  1050             release = ETrue;
       
  1051             }
       
  1052         }
       
  1053     return release;
       
  1054     }
       
  1055 
       
  1056 // ---------------------------------------------------------
       
  1057 // deprecated
       
  1058 //
       
  1059 // ---------------------------------------------------------
       
  1060 //
       
  1061 EXPORT_C TBool CSpdiaControl::AssignNumberL(TInt /*aIndex*/,
       
  1062                                     CEikStatusPane* /*aStatusPane*/,
       
  1063                                     CCoeControl* /*aContainer*/,
       
  1064                                     TBool /*aConfirmation*/)
       
  1065     {
       
  1066     __ASSERT_DEBUG(0, Panic(ESdmPanicNotSupported));
       
  1067     return EFalse;
       
  1068     }
       
  1069 
       
  1070 EXPORT_C void CSpdiaControl::ApplyCellSpdiaPaneStyleL(
       
  1071                         CAknGrid& /*aListBox*/, TSize& /*aSize*/)
       
  1072     {
       
  1073     __ASSERT_DEBUG(0, Panic(ESdmPanicNotSupported));
       
  1074     }
       
  1075 
       
  1076 EXPORT_C void CSpdiaControl::DrawShadow(
       
  1077     CWindowGc& /*aGc*/,
       
  1078     const TSize& /*aSize*/ )
       
  1079     {
       
  1080     __ASSERT_DEBUG(0, Panic(ESdmPanicNotSupported));
       
  1081     }
       
  1082 
       
  1083 // ---------------------------------------------------------
       
  1084 // CSpdiaContainer::SetLayout
       
  1085 //
       
  1086 // ---------------------------------------------------------
       
  1087 //
       
  1088 EXPORT_C void CSpdiaControl::SetLayout(const TRect& aRect)
       
  1089     {
       
  1090     //Scalable UI.
       
  1091     if ( AknLayoutUtils::ScalableLayoutInterfaceAvailable() )
       
  1092         {
       
  1093         TRect			   	 mainPaneRect ;
       
  1094         TRect 			   	 statusPaneRect;
       
  1095         TAknLayoutRect     	 mainQdialRect;
       
  1096         TAknLayoutRect     	 gridQdialPaneRect;
       
  1097         TAknLayoutRect     	 cellQdialPaneRect;
       
  1098         TAknWindowLineLayout cellQdialPane;
       
  1099         TInt 				 varient =0;
       
  1100 			
       
  1101         if ( Layout_Meta_Data::IsLandscapeOrientation() )
       
  1102             {
       
  1103             AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane,mainPaneRect);
       
  1104             AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EStatusPane,statusPaneRect);
       
  1105             mainPaneRect.iTl = statusPaneRect.iTl;
       
  1106             mainPaneRect.iBr.iY = mainPaneRect.iBr.iY - statusPaneRect.iTl.iY;
       
  1107             varient =1;
       
  1108             if ( AknLayoutUtils::PenEnabled() )
       
  1109                 {
       
  1110                 mainPaneRect.iTl -= statusPaneRect.iTl;
       
  1111                 mainPaneRect.iBr.iY +=statusPaneRect.iTl.iY;
       
  1112                 }
       
  1113             }
       
  1114         else
       
  1115             {
       
  1116             AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane,mainPaneRect);
       
  1117             AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EStatusPane,statusPaneRect);
       
  1118             mainPaneRect.iTl= statusPaneRect.iTl;
       
  1119             if ( AknLayoutUtils::PenEnabled() )
       
  1120                 {
       
  1121                 mainPaneRect.iTl -= statusPaneRect.iTl;
       
  1122                 }
       
  1123             }
       
  1124 		
       
  1125         SetRect( mainPaneRect );
       
  1126 		
       
  1127         mainQdialRect.LayoutRect(mainPaneRect,AknLayoutScalable_Apps::main_qdial_pane().LayoutLine());
       
  1128         gridQdialPaneRect.LayoutRect(mainQdialRect.Rect(),AknLayoutScalable_Apps::grid_qdial_pane().LayoutLine());
       
  1129         cellQdialPaneRect.LayoutRect(gridQdialPaneRect.Rect(),AknLayoutScalable_Apps::cell_qdial_pane(0,0).LayoutLine());
       
  1130         cellQdialPane = AknLayoutScalable_Apps::cell_qdial_pane_g4(varient).LayoutLine();
       
  1131 			
       
  1132         TInt Cnt = 0;
       
  1133 			
       
  1134         for(TInt rowSize=0;rowSize < 3; rowSize++)
       
  1135             {
       
  1136             for(TInt column=0;column < 3; column++)
       
  1137                 {
       
  1138                 icellLayout[Cnt].LayoutRect(gridQdialPaneRect.Rect(),AknLayoutScalable_Apps::cell_qdial_pane(column,rowSize).LayoutLine());	
       
  1139                 Cnt ++ ;	
       
  1140                 }
       
  1141             }
       
  1142 				
       
  1143 
       
  1144         (*iShadowLayout)[CSpdiaGrid::EtnCIF].LayoutRect(cellQdialPaneRect.Rect(),cellQdialPane
       
  1145 	            /*sdm_tn_shadow_cif_c,
       
  1146 	            sdm_tn_shadow_cif_l,
       
  1147 	            sdm_tn_shadow_cif_t,
       
  1148 	            sdm_tn_shadow_cif_r,
       
  1149 	            sdm_tn_shadow_cif_b,
       
  1150 	            sdm_tn_shadow_cif_w,
       
  1151 	            sdm_tn_shadow_cif_h*/);
       
  1152 
       
  1153         (*iShadowLayout)[CSpdiaGrid::EtnVGA90].LayoutRect(cellQdialPaneRect.Rect(),cellQdialPane
       
  1154 	            /*sdm_tn_shadow_vga90_c,
       
  1155 	            sdm_tn_shadow_vga90_l,
       
  1156 	            sdm_tn_shadow_vga90_t,
       
  1157 	            sdm_tn_shadow_vga90_r,
       
  1158 	            sdm_tn_shadow_vga90_b,
       
  1159 	            sdm_tn_shadow_vga90_w,
       
  1160 	            sdm_tn_shadow_vga90_h*/);
       
  1161 
       
  1162         (*iShadowLayout)[CSpdiaGrid::EtnVGA].LayoutRect(cellQdialPaneRect.Rect(),cellQdialPane
       
  1163 	            /*sdm_tn_shadow_vga_c,
       
  1164 	            sdm_tn_shadow_vga_l,
       
  1165 	            sdm_tn_shadow_vga_t,
       
  1166 	            sdm_tn_shadow_vga_r,
       
  1167 	            sdm_tn_shadow_vga_b,
       
  1168 	            sdm_tn_shadow_vga_w,
       
  1169 	            sdm_tn_shadow_vga_h*/);
       
  1170 
       
  1171         (*iShadowLayout)[CSpdiaGrid::EtnCOM].LayoutRect(cellQdialPaneRect.Rect(),cellQdialPane
       
  1172 	            /*sdm_tn_shadow_com_c,
       
  1173 	            sdm_tn_shadow_com_l,
       
  1174 	            sdm_tn_shadow_com_t,
       
  1175 	            sdm_tn_shadow_com_r,
       
  1176 	            sdm_tn_shadow_com_b,
       
  1177 	            sdm_tn_shadow_com_w,
       
  1178 	            sdm_tn_shadow_com_h*/);         
       
  1179         }
       
  1180     else
       
  1181         {
       
  1182         TAknWindowLineLayout lScr = AknLayout::screen();
       
  1183         TAknWindowLineLayout lCtrlPane = AknLayout::control_pane(TRect( TPoint(lScr.il, lScr.it), TSize(lScr.iW, lScr.iH) ));
       
  1184         SetRect(TRect( TPoint(lScr.il, lScr.it), TSize(lScr.iW, lScr.iH - lCtrlPane.iH) ) );
       
  1185 
       
  1186         (*iShadowLayout)[CSpdiaGrid::EtnCIF90].LayoutRect(aRect,AppLayout::Cell_pane_elements__qdial__Line_1()
       
  1187             /*sdm_tn_shadow_cif90_c,
       
  1188             sdm_tn_shadow_cif90_l,
       
  1189             sdm_tn_shadow_cif90_t,
       
  1190             sdm_tn_shadow_cif90_r,
       
  1191             sdm_tn_shadow_cif90_b,
       
  1192             sdm_tn_shadow_cif90_w,
       
  1193             sdm_tn_shadow_cif90_h*/);
       
  1194         (*iShadowLayout)[CSpdiaGrid::EtnCIF].LayoutRect(aRect,AppLayout::Cell_pane_elements__qdial__Line_4()
       
  1195             /*sdm_tn_shadow_cif_c,
       
  1196             sdm_tn_shadow_cif_l,
       
  1197             sdm_tn_shadow_cif_t,
       
  1198             sdm_tn_shadow_cif_r,
       
  1199             sdm_tn_shadow_cif_b,
       
  1200             sdm_tn_shadow_cif_w,
       
  1201             sdm_tn_shadow_cif_h*/);
       
  1202         (*iShadowLayout)[CSpdiaGrid::EtnVGA90].LayoutRect(aRect,AppLayout::Cell_pane_elements__qdial__Line_7()
       
  1203             /*sdm_tn_shadow_vga90_c,
       
  1204             sdm_tn_shadow_vga90_l,
       
  1205             sdm_tn_shadow_vga90_t,
       
  1206             sdm_tn_shadow_vga90_r,
       
  1207             sdm_tn_shadow_vga90_b,
       
  1208             sdm_tn_shadow_vga90_w,
       
  1209             sdm_tn_shadow_vga90_h*/);
       
  1210         (*iShadowLayout)[CSpdiaGrid::EtnVGA].LayoutRect(aRect,AppLayout::Cell_pane_elements__qdial__Line_10()
       
  1211             /*sdm_tn_shadow_vga_c,
       
  1212             sdm_tn_shadow_vga_l,
       
  1213             sdm_tn_shadow_vga_t,
       
  1214             sdm_tn_shadow_vga_r,
       
  1215             sdm_tn_shadow_vga_b,
       
  1216             sdm_tn_shadow_vga_w,
       
  1217             sdm_tn_shadow_vga_h*/);
       
  1218         (*iShadowLayout)[CSpdiaGrid::EtnCOM].LayoutRect(aRect,AppLayout::Cell_pane_elements__qdial__Line_13()
       
  1219             /*sdm_tn_shadow_com_c,
       
  1220             sdm_tn_shadow_com_l,
       
  1221             sdm_tn_shadow_com_t,
       
  1222             sdm_tn_shadow_com_r,
       
  1223             sdm_tn_shadow_com_b,
       
  1224             sdm_tn_shadow_com_w,
       
  1225             sdm_tn_shadow_com_h*/);
       
  1226 		    }
       
  1227     }
       
  1228 
       
  1229 // ---------------------------------------------------------
       
  1230 // deprecated
       
  1231 //
       
  1232 // ---------------------------------------------------------
       
  1233 //
       
  1234 EXPORT_C TInt CSpdiaControl::Size() const
       
  1235     {
       
  1236     __ASSERT_DEBUG(0, Panic(ESdmPanicNotSupported));
       
  1237     return KCellRowCount;
       
  1238     }
       
  1239 
       
  1240 // ---------------------------------------------------------
       
  1241 // CSpdiaControl::VMBoxPosition
       
  1242 //
       
  1243 // ---------------------------------------------------------
       
  1244 //
       
  1245 EXPORT_C TInt CSpdiaControl::VMBoxPosition() const
       
  1246     {
       
  1247     return KVoiceMail;
       
  1248     }
       
  1249 
       
  1250 // ---------------------------------------------------------
       
  1251 // CSpdiaControl::SpdIconIndex
       
  1252 // An interface for accessing index data array.
       
  1253 // ---------------------------------------------------------
       
  1254 //
       
  1255 EXPORT_C TInt CSpdiaControl::SpdIconIndex(TInt aIndex) const
       
  1256     {
       
  1257     return (*iSdmArray)[aIndex].IconIndex();
       
  1258     }
       
  1259 
       
  1260 // ---------------------------------------------------------
       
  1261 // CSpdiaControl::CreateDataL
       
  1262 // Set grid used flag and calls CreateDataL.
       
  1263 // ---------------------------------------------------------
       
  1264 //
       
  1265 TBool CSpdiaControl::CreateDataL(const CAknGrid& aGrid)
       
  1266     {
       
  1267     iGridUsed = EGridUseAndUpdate;
       
  1268 
       
  1269     return CreateGridDataL(CONST_CAST(CAknGrid*, &aGrid), KNullIndexData);
       
  1270     }
       
  1271 
       
  1272 // ---------------------------------------------------------
       
  1273 // CSpdiaControl::PbkThumbnailGetComplete
       
  1274 //
       
  1275 // ---------------------------------------------------------
       
  1276 //
       
  1277 void CSpdiaControl::PbkThumbnailGetComplete
       
  1278         (MPbkThumbnailOperation& aOperation, CFbsBitmap* aBitmap)
       
  1279    {
       
  1280    TRAP_IGNORE(PbkThumbnailGetCompleteL(aOperation, aBitmap )); 	
       
  1281    }
       
  1282    
       
  1283 // ---------------------------------------------------------
       
  1284 // CSpdiaControl::PbkThumbnailGetCompleteL
       
  1285 //
       
  1286 // ---------------------------------------------------------
       
  1287 //
       
  1288 void CSpdiaControl::PbkThumbnailGetCompleteL
       
  1289         (MPbkThumbnailOperation& aOperation, CFbsBitmap* aBitmap)
       
  1290     {
       
  1291     TInt index(HasOperation(aOperation));
       
  1292     if ( index != KNullIndexData )
       
  1293         {
       
  1294         if ( AknLayoutUtils::ScalableLayoutInterfaceAvailable() )
       
  1295             {
       
  1296             CAknIcon* icon = CAknIcon::NewL();
       
  1297             icon->SetBitmap(aBitmap);
       
  1298 
       
  1299             // create mask
       
  1300             CFbsBitmap* mask = new (ELeave) CFbsBitmap();
       
  1301 
       
  1302             TSize size = aBitmap->SizeInPixels();
       
  1303             mask->Create(size,EGray2);
       
  1304 
       
  1305             CFbsBitGc* fbsBitGc = CFbsBitGc::NewL();
       
  1306             CleanupStack::PushL( fbsBitGc );
       
  1307             CFbsBitmapDevice* bmpDevice = CFbsBitmapDevice::NewL( mask );
       
  1308             CleanupStack::PushL( bmpDevice );
       
  1309             bmpDevice->Resize( size );
       
  1310             fbsBitGc->Activate( bmpDevice );
       
  1311 
       
  1312             fbsBitGc->SetPenStyle(CGraphicsContext::ENullPen);
       
  1313             fbsBitGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
  1314 
       
  1315             fbsBitGc->SetBrushColor(KRgbBlack); 
       
  1316             fbsBitGc->DrawRect( TRect( size ) );
       
  1317 
       
  1318             CleanupStack::PopAndDestroy( 2, fbsBitGc ); // bmpDevice and fbsBitGc
       
  1319 
       
  1320             icon->SetMask(mask);
       
  1321 
       
  1322             // this creates both scalable icon and mask
       
  1323             CAknIcon* scaledIcon = AknIconUtils::CreateIconL(icon);
       
  1324 
       
  1325             TSize thumbnailSize = GetThumbnailSize();
       
  1326 
       
  1327             AknIconUtils::SetSize(scaledIcon->Bitmap(),thumbnailSize,EAspectRatioPreservedAndUnusedSpaceRemoved);
       
  1328             AknIconUtils::SetSize(scaledIcon->Mask(),thumbnailSize,EAspectRatioPreservedAndUnusedSpaceRemoved);
       
  1329 
       
  1330             CFbsBitmap* bmp = new (ELeave) CFbsBitmap();
       
  1331             CFbsBitmap* msk = new (ELeave) CFbsBitmap();
       
  1332             TInt err = msk->Duplicate( scaledIcon->Mask()->Handle() ); 
       
  1333             TInt err1 = bmp->Duplicate( scaledIcon->Bitmap()->Handle() );			
       
  1334 
       
  1335 			
       
  1336             delete (*iIconArray)[index];
       
  1337             (*iIconArray)[index] = NULL;
       
  1338             (*iIconArray)[index] = CGulIcon::NewL(bmp,msk);
       
  1339             // set the text array of grid
       
  1340             (*iSdmArray)[index].SetThumbIndex(index,bmp);
       
  1341             ChangeIndexDataL(index, (*iSdmArray)[index]);
       
  1342             if ((*iSdmArray)[index].LastThumb())
       
  1343                 {
       
  1344                 DrawNow();
       
  1345                 iGrid->DrawNow(); 
       
  1346                 }			
       
  1347             delete scaledIcon;
       
  1348             }       
       
  1349         else
       
  1350             {
       
  1351             // set the scaled bitmap to the array of icons
       
  1352             delete (*iIconArray)[index];
       
  1353             (*iIconArray)[index] = NULL;
       
  1354             (*iIconArray)[index] = CGulIcon::NewL(aBitmap);
       
  1355             // set the text array of grid
       
  1356             (*iSdmArray)[index].SetThumbIndex(index, aBitmap);
       
  1357             ChangeIndexDataL(index, (*iSdmArray)[index]);
       
  1358             if ((*iSdmArray)[index].LastThumb())
       
  1359                 {
       
  1360                 DrawNow();
       
  1361                 iGrid->DrawNow();
       
  1362                 }
       
  1363             }
       
  1364         delete &aOperation;
       
  1365         (*iSdmArray)[index].SetOperation(NULL);
       
  1366         delete (*iSdmArray)[index].ContactItem();
       
  1367         (*iSdmArray)[index].SetContactItem(NULL);
       
  1368         }
       
  1369     }
       
  1370 
       
  1371 // ---------------------------------------------------------
       
  1372 // CSpdiaControl::PbkThumbnailGetFailed
       
  1373 //
       
  1374 // ---------------------------------------------------------
       
  1375 //
       
  1376 void CSpdiaControl::PbkThumbnailGetFailed
       
  1377         (MPbkThumbnailOperation& aOperation,
       
  1378         TInt /*aError*/)
       
  1379     {
       
  1380     TInt index(HasOperation(aOperation));
       
  1381     if (index != KNullIndexData)
       
  1382         {
       
  1383         delete &aOperation;
       
  1384         (*iSdmArray)[index].SetOperation(NULL);
       
  1385         delete (*iSdmArray)[index].ContactItem();
       
  1386         (*iSdmArray)[index].SetContactItem(NULL);
       
  1387         }
       
  1388     }
       
  1389 
       
  1390 // ---------------------------------------------------------
       
  1391 // CSpdiaContainer::Draw
       
  1392 //
       
  1393 // ---------------------------------------------------------
       
  1394 //
       
  1395 void CSpdiaControl::Draw(const TRect& /*aRect*/) const
       
  1396     {
       
  1397     CWindowGc& gc = SystemGc();
       
  1398 //    gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
       
  1399 //    gc.Clear();
       
  1400 
       
  1401    AknsDrawUtils::Background(
       
  1402        AknsUtils::SkinInstance(),
       
  1403        AknsDrawUtils::ControlContext(this),
       
  1404        this,
       
  1405        gc,
       
  1406        Rect() );
       
  1407 
       
  1408     DrawShadow(gc);
       
  1409     }
       
  1410 
       
  1411 // ---------------------------------------------------------
       
  1412 // CSpdiaContainer::HandleDatabaseEventL
       
  1413 // Handles an database event of type aEventType.
       
  1414 // ---------------------------------------------------------
       
  1415 //
       
  1416 void CSpdiaControl::HandleDatabaseEventL(
       
  1417          TContactDbObserverEvent /*aEvent*/)
       
  1418     {
       
  1419     // An update flag will be updated if the grid is used.
       
  1420     // Other than this, index data is updated.
       
  1421     if (iGridUsed != EGridUse)
       
  1422         {
       
  1423         InitIndexDataL();
       
  1424         if ( iGridDlg )
       
  1425             {
       
  1426             CreateGridDataL( ( CAknGrid* )iGrid , KNullIndexData );
       
  1427             iGrid->DrawNow();
       
  1428             
       
  1429             // The grid from 2 to 9 has the possibility to show the dialog,
       
  1430             // and the related index is the value from 1 to 8.
       
  1431             if ( iFocusedGrid != KNullIndexData 
       
  1432                 && ( iFocusedGrid >= 1 && iFocusedGrid < 9 ) 
       
  1433                 && iQueryDialog  )
       
  1434                 {
       
  1435                 TContactItemId id( ( *iSdmArray )[iFocusedGrid].ContactId() );          	
       
  1436                 if ( id == KNullContactId )
       
  1437                     {
       
  1438                     delete iQueryDialog;
       
  1439                     iQueryDialog = NULL;
       
  1440                     }
       
  1441                 }
       
  1442             }
       
  1443         }
       
  1444     }
       
  1445 
       
  1446 // ---------------------------------------------------------
       
  1447 // CSpdiaControl::ConstructL
       
  1448 //
       
  1449 // ---------------------------------------------------------
       
  1450 //
       
  1451 void CSpdiaControl::ConstructL()
       
  1452     {
       
  1453     TInt tmp = 1;
       
  1454 
       
  1455    	_LIT(KMbmFileName, "Z:spdctrl.mbm");
       
  1456     _LIT(KRscFileName, "Z:spdctrl.rsc" );
       
  1457 
       
  1458     TParse* fpMbm = new(ELeave) TParse ();
       
  1459     fpMbm->Set (KMbmFileName, &KDC_APP_BITMAP_DIR, NULL);
       
  1460     iBmpPath.Copy(fpMbm ->FullName());
       
  1461     delete fpMbm;
       
  1462     fpMbm=NULL;
       
  1463 
       
  1464     TParse* fpRsc = new(ELeave) TParse ();
       
  1465     fpRsc->Set (KRscFileName, &KDC_RESOURCE_FILES_DIR, NULL);
       
  1466     iRscPath.Copy(fpRsc ->FullName());
       
  1467     delete fpRsc;
       
  1468     fpRsc=NULL;
       
  1469 
       
  1470     CRepository* repository = CRepository::NewLC(KCRUidSpeedDialLV);
       
  1471     repository->Get( KSpeedDialLVFlags, tmp );
       
  1472 
       
  1473     //variable that will be used to variate the code.
       
  1474     // if 0 release is 2.1 and code shouldnt be used
       
  1475     // if 1 release is 2.x (where x:5, 6, ... )and the dialog should be used.
       
  1476 
       
  1477     iBooleanVarForAddingDialogVariation  = ( tmp == 1);
       
  1478 	
       
  1479     CleanupStack::PopAndDestroy();
       
  1480 
       
  1481     if (iEngine == NULL)
       
  1482         {
       
  1483         TRAPD(error,iEngine = CPbkContactEngine::NewL());
       
  1484         iError = error;
       
  1485         if(error !=KErrNone)   
       
  1486             {
       
  1487             delete iEngine ;	
       
  1488             iEngine = NULL;
       
  1489             return ;	
       
  1490             }
       
  1491         }
       
  1492       
       
  1493     if ( iEngine )    
       
  1494         {
       
  1495         iPbkNotifier = iEngine->CreateContactChangeNotifierL(this);
       
  1496         }
       
  1497     iPbkResourceFile = new (ELeave) RPbkViewResourceFile(*iCoeEnv);
       
  1498     if (!iPbkResourceFile->IsOpen())
       
  1499         {
       
  1500         iPbkResourceFile->OpenL();
       
  1501         }
       
  1502 
       
  1503     TFileName fileName(iRscPath);
       
  1504     BaflUtils::NearestLanguageFile(iCoeEnv->FsSession(), fileName);
       
  1505     iFileOffset = iCoeEnv->AddResourceFileL(fileName);
       
  1506 
       
  1507     iSdmCount = KCellRowCount * KCellColCount;
       
  1508     iGridUsed = EGridNoUse;
       
  1509 
       
  1510     iIconArray = new (ELeave)CAknIconArray(iSdmCount);
       
  1511     iSdmArray = new (ELeave) CArrayFixFlat<TSpdiaIndexData> (iSdmCount);
       
  1512 
       
  1513     iDialSkinBmp = new (ELeave)RArray<TAknsItemID>(KArraySize);
       
  1514     iSkinIcons = new (ELeave)RArray<TAknsItemID>(KArraySize);
       
  1515     iIcons = new (ELeave)RArray<TInt>(iIconsCount);
       
  1516     iIconsId = new (ELeave)RArray<TInt>(iIconsIdCount);
       
  1517     iIconsMask = new (ELeave)RArray<TInt>(iIconsMaskCount);
       
  1518     iShadowLayout = new (ELeave) CArrayFixFlat<TAknLayoutRect> (KLayoutCount);
       
  1519     for (TInt i(0); i < KLayoutCount; ++i)
       
  1520         {
       
  1521         TAknLayoutRect rect;
       
  1522         iShadowLayout->AppendL(rect);
       
  1523         }
       
  1524 
       
  1525     InitIndexDataL();
       
  1526     InitializeArray();
       
  1527 
       
  1528     // create skin context
       
  1529     // Size is set in SizeChanged()
       
  1530     iBgContext = CAknsBasicBackgroundControlContext::NewL(
       
  1531         KAknsIIDQsnBgAreaMainQdial,
       
  1532         TRect(0,0,0,0),
       
  1533         EFalse );
       
  1534         iPopupDialog = EFalse;
       
  1535 
       
  1536     iType = EVmbx;
       
  1537     }
       
  1538 
       
  1539 // ---------------------------------------------------------
       
  1540 // CSpdiaControl::InitIndexDataL
       
  1541 // The SDM control data is initialized.
       
  1542 // ---------------------------------------------------------
       
  1543 //
       
  1544 void CSpdiaControl::InitIndexDataL()
       
  1545     {
       
  1546     // The dialog of grid is not closed.
       
  1547     if (iIconArray != NULL)
       
  1548         {
       
  1549         ResetArray();
       
  1550         iSdmArray->Reset();
       
  1551         for (TInt i(0); i < iSdmCount; ++i)
       
  1552             {
       
  1553             TSpdiaIndexData data;
       
  1554             SetIndexDataL(i, data);
       
  1555             iSdmArray->AppendL(data);
       
  1556             }
       
  1557         }
       
  1558     }
       
  1559 
       
  1560 // ---------------------------------------------------------
       
  1561 // CSpdiaControl::ThumbType
       
  1562 // An interface for accessing index data array.
       
  1563 // ---------------------------------------------------------
       
  1564 //
       
  1565 TInt CSpdiaControl::ThumbType(TInt aIndex) const
       
  1566     {
       
  1567     return ConvThumbType((*iSdmArray)[aIndex].ThumbSize());
       
  1568     }
       
  1569 
       
  1570 // ---------------------------------------------------------
       
  1571 // CSpdiaControl::ThumbType
       
  1572 // An interface for accessing index data array.
       
  1573 // ---------------------------------------------------------
       
  1574 //
       
  1575 TSize CSpdiaControl::ThumbSize(TInt aIndex) const
       
  1576     {
       
  1577     return (*iSdmArray)[aIndex].ThumbSize();
       
  1578     }
       
  1579 
       
  1580 
       
  1581 // ---------------------------------------------------------
       
  1582 // CSpdiaControl::IconPositionL
       
  1583 // phone book access
       
  1584 // ---------------------------------------------------------
       
  1585 //
       
  1586 TInt CSpdiaControl::IconPositionL(const CPbkContactItem& aItem, TInt aDial, TInt& aFieldId)
       
  1587     {
       
  1588     TInt index(KNullIndexData);
       
  1589     CPbkFieldArray& fields = aItem.CardFields();
       
  1590     for (TInt fieldIdx(0); index == KNullIndexData &&
       
  1591                     fieldIdx < fields.Count(); ++fieldIdx)
       
  1592         {
       
  1593         TPbkContactItemField& field = fields[fieldIdx];
       
  1594         CArrayFix<TInt>* array = field.SpeedDialIndexesL();
       
  1595         if (array)
       
  1596             {
       
  1597             for (TInt i(0); index < 0 && i < array->Count(); ++i)
       
  1598                 {
       
  1599                 if (aDial == (*array)[i])
       
  1600                     {
       
  1601                     index = FindIconIndex(field.FieldInfo().IconId());
       
  1602                     aFieldId = field.FieldInfo().FieldId();
       
  1603                     }
       
  1604                 }
       
  1605             delete array;
       
  1606             }
       
  1607         }
       
  1608     return index;
       
  1609     }
       
  1610 
       
  1611 // ---------------------------------------------------------
       
  1612 // CSpdiaControl::FindIconIndex
       
  1613 //
       
  1614 // ---------------------------------------------------------
       
  1615 //
       
  1616 TInt CSpdiaControl::FindIconIndex(TInt aId) const
       
  1617     {
       
  1618     TInt index(KNullIndexData);
       
  1619     for (TInt n(0); index == KNullIndexData && n < iIconsIdCount; ++n)
       
  1620         {
       
  1621         if ( ( *iIconsId )[n] == ( TUint )aId )
       
  1622             {
       
  1623             index = n + iSdmCount;
       
  1624             }
       
  1625         }
       
  1626     return index;
       
  1627     }
       
  1628 
       
  1629 // ---------------------------------------------------------
       
  1630 // CSpdiaControl::DeleteIconArray
       
  1631 // Deletes the old icons.
       
  1632 // ---------------------------------------------------------
       
  1633 EXPORT_C void CSpdiaControl::DeleteIconArray()
       
  1634     {
       
  1635     if( iIconArray )
       
  1636         {
       
  1637         iIconArray->ResetAndDestroy();
       
  1638         delete iIconArray;
       
  1639         iIconArray = NULL;
       
  1640         }
       
  1641     }
       
  1642 
       
  1643 // ---------------------------------------------------------
       
  1644 // CSpdiaControl::ReloadIconArray
       
  1645 // Reloads the new skin icons.
       
  1646 // ---------------------------------------------------------
       
  1647 EXPORT_C void CSpdiaControl::ReloadIconArray()
       
  1648     {
       
  1649 		TRAP_IGNORE(ReloadIconArrayL());
       
  1650     }
       
  1651 // ---------------------------------------------------------
       
  1652 // CSpdiaControl::ReloadIconArrayL
       
  1653 // Reloads the new skin icons.
       
  1654 // ---------------------------------------------------------
       
  1655 void CSpdiaControl::ReloadIconArrayL()
       
  1656     {
       
  1657     if ( NULL == iIconArray )
       
  1658         {
       
  1659         iIconArray = new (ELeave)CAknIconArray(iSdmCount);
       
  1660         }
       
  1661     SetIconArrayL(iIconArray);
       
  1662     }
       
  1663 	
       
  1664 // ---------------------------------------------------------
       
  1665 // CSpdiaControl::SetIconArrayL
       
  1666 //
       
  1667 // ---------------------------------------------------------
       
  1668 //
       
  1669 TInt CSpdiaControl::SetIconArrayL(CArrayPtrFlat<CGulIcon>* aArray)
       
  1670     {
       
  1671     CFbsBitmap* bitmap,*mask;
       
  1672     bitmap = NULL;
       
  1673     mask= NULL;
       
  1674     MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
       
  1675     if (!iManager)
       
  1676         {
       
  1677         iManager = CPbkThumbnailManager::NewL(*iEngine);
       
  1678         }
       
  1679 
       
  1680     if ( aArray != NULL )
       
  1681         {
       
  1682         aArray->ResetAndDestroy();
       
  1683         }
       
  1684     else
       
  1685         {
       
  1686         return 0;
       
  1687         }
       
  1688 	
       
  1689     TInt vmbxSupport = 0;
       
  1690     CRepository* vmbxSupported = CRepository::NewL( KCRUidVideoMailbox );
       
  1691     vmbxSupported->Get( KVideoMbxSupport, vmbxSupport );
       
  1692     delete vmbxSupported;
       
  1693     
       
  1694     TInt vmbxPos;
       
  1695     CRepository*  vmbxKey2 = CRepository::NewL( KCRUidTelVideoMailbox );
       
  1696     vmbxKey2->Get( KTelVideoMbxKey, vmbxPos );
       
  1697     delete vmbxKey2;
       
  1698     TInt vdoIndex( Index( vmbxPos ) );    
       
  1699     
       
  1700     TInt existThumb(0);
       
  1701     for (TInt index(0); index < iSdmArray->Count(); index++)
       
  1702         {
       
  1703         if ( index == 0 )
       
  1704             {
       
  1705             TUid uidVmbx;
       
  1706             uidVmbx.iUid =KVmbxUid;
       
  1707             AknsUtils::CreateAppIconLC( skinInstance,uidVmbx, EAknsAppIconTypeContext,bitmap ,mask);		
       
  1708             CleanupStack::Pop(2);
       
  1709             }
       
  1710         else if ( index == 1 && ( vmbxSupport && vdoIndex == 1 ) )
       
  1711             {
       
  1712             AknsUtils::CreateIconL( skinInstance, (*iDialSkinBmp)[index], bitmap, mask, 
       
  1713                 iBmpPath, EMbmSpdctrlQgn_prop_video_mb, EMbmSpdctrlQgn_prop_video_mb_mask );
       
  1714             }
       
  1715         else
       
  1716             {
       
  1717             if( User::Language()== ELangHindi)
       
  1718                 {
       
  1719                 AknsUtils::CreateIconL(skinInstance, (*iDialSkinBmp)[index],bitmap,mask,iBmpPath,KDialHindiBmp[index],  KDialHindiBmpMask[index] );	
       
  1720                 }
       
  1721             else
       
  1722                 {
       
  1723                 AknsUtils::CreateIconL(skinInstance, (*iDialSkinBmp)[index],bitmap,mask,iBmpPath,KDialBmp[index],  KDialBmpMask[index] );	
       
  1724                 }
       
  1725             }
       
  1726         CGulIcon* icon = CGulIcon::NewL(bitmap,mask);
       
  1727         CleanupStack::PushL(icon);
       
  1728         aArray->AppendL(icon);
       
  1729 
       
  1730         if (CreateIndexIconL(index,
       
  1731             (*iSdmArray)[index], existThumb > 0? EFalse: ETrue))
       
  1732             {
       
  1733             ++existThumb;
       
  1734             }
       
  1735         CleanupStack::Pop(); // icon
       
  1736         }
       
  1737 
       
  1738     // Add icons
       
  1739     for (TInt i(0); i < iIconsIdCount; ++i)
       
  1740         {
       
  1741         AknsUtils::CreateIconL(skinInstance, (*iSkinIcons)[i],bitmap,mask,AknIconUtils::AvkonIconFileName(),( *iIcons )[i], ( *iIconsMask )[i] );
       
  1742         aArray->AppendL(CGulIcon::NewL(bitmap,mask));
       
  1743         }
       
  1744 
       
  1745     return existThumb;
       
  1746     }
       
  1747 
       
  1748 // ---------------------------------------------------------
       
  1749 // CSpdiaContainer::ItemDescriptorL
       
  1750 //
       
  1751 // ---------------------------------------------------------
       
  1752 //
       
  1753 HBufC* CSpdiaControl::ItemDescriptorLC(TInt aIndex,
       
  1754                             const TSpdiaIndexData& aSdmData)
       
  1755     {
       
  1756     HBufC* des = NULL;
       
  1757     if (aSdmData.ContactId() != KNullContactId)
       
  1758         {
       
  1759         des = CreateItemDescriptorLC(aSdmData);
       
  1760         }
       
  1761     else
       
  1762         {
       
  1763         des = HBufC::NewLC(KNullCell.iTypeLength);
       
  1764         des->Des().Format(KNullCell, aIndex);
       
  1765         }
       
  1766     return des;
       
  1767     }
       
  1768 
       
  1769 // ---------------------------------------------------------
       
  1770 // CSpdiaContainer::CreateItemDescriptorL
       
  1771 //
       
  1772 // ---------------------------------------------------------
       
  1773 //
       
  1774 HBufC* CSpdiaControl::CreateItemDescriptorLC(const TSpdiaIndexData& aSdmData)
       
  1775     {
       
  1776     HBufC* des = HBufC::NewLC(KApaMaxAppCaption);
       
  1777     TPtr ptr(des->Des());
       
  1778 
       
  1779     // thumb type
       
  1780     TInt type(CSpdiaGrid::EText);
       
  1781     if (aSdmData.ThumbIndex() >= 0)
       
  1782         {
       
  1783         type = ConvThumbType(aSdmData.ThumbSize());
       
  1784         }
       
  1785 
       
  1786     // Text
       
  1787     if (type == CSpdiaGrid::EText)
       
  1788         {
       
  1789         ptr.Append(KDesTab);       // 1
       
  1790         if (aSdmData.IconIndex() >= 0)
       
  1791             {
       
  1792             ptr.AppendNum(aSdmData.IconIndex());
       
  1793             }
       
  1794         AppendTextL(aSdmData, ptr); //  2,3,4
       
  1795         }
       
  1796     else
       
  1797         {
       
  1798         // icon + text + text + text
       
  1799         ptr.Append(KDesTab2);       // 1, 2
       
  1800         ptr.Append(KDesTab2);       // 2
       
  1801         }
       
  1802 
       
  1803     // thumbnail 5-14
       
  1804     for (TInt i(CSpdiaGrid::EtnCIF90); i <= CSpdiaGrid::EtnCOM; ++i)
       
  1805         {
       
  1806         AppendThumbnail(aSdmData, ptr, (type == i? ETrue: EFalse));
       
  1807         }
       
  1808 
       
  1809     // number
       
  1810     ptr.Append(KDesTab);        // 15
       
  1811     // check
       
  1812     ptr.Append(KDesTab);        // 16
       
  1813 
       
  1814     return des;
       
  1815     }
       
  1816 
       
  1817 // ---------------------------------------------------------
       
  1818 // CSpdiaContainer::AppendTextL
       
  1819 // output Text1\tText2\tText3\t
       
  1820 // ---------------------------------------------------------
       
  1821 //
       
  1822 void CSpdiaControl::AppendTextL(const TSpdiaIndexData& aSdmData, TPtr& aText)
       
  1823     {
       
  1824     CPbkContactItem* item = iEngine->ReadContactLC(aSdmData.ContactId());
       
  1825     if (item == NULL)
       
  1826         {
       
  1827         aText.Append(KDesTab2);
       
  1828         aText.Append(KDesTab2);
       
  1829         }
       
  1830     else
       
  1831         {
       
  1832         TPbkContactItemField* lastNameField =
       
  1833             FindFieldL(*item, EPbkFieldIdLastName);     // Last Name
       
  1834         TPbkContactItemField* firstNameField  =
       
  1835             FindFieldL(*item, EPbkFieldIdFirstName);  // First Name
       
  1836         TPbkContactItemField* companyNameField =
       
  1837             FindFieldL(*item, EPbkFieldIdCompanyName);
       
  1838 
       
  1839         aText.Append(KDesTab);             // 2
       
  1840         if (!lastNameField && !firstNameField && !companyNameField)
       
  1841             {
       
  1842             aText.Append(aSdmData.PhoneNumber());
       
  1843             aText.Append(KDesTab);         // 3
       
  1844             }
       
  1845         else if (!lastNameField && !firstNameField)
       
  1846             {
       
  1847             aText.Append(companyNameField->Text());
       
  1848             aText.Append(KDesTab);         // 3
       
  1849             }
       
  1850         else
       
  1851             {
       
  1852             if (lastNameField)
       
  1853                 {
       
  1854                 aText.Append(lastNameField->Text());
       
  1855                 aText.Append(KDesTab);     // 3
       
  1856                 }
       
  1857             if (firstNameField)
       
  1858                 {
       
  1859                 aText.Append(firstNameField->Text());
       
  1860                 }
       
  1861             if (!lastNameField)
       
  1862                 {
       
  1863                 aText.Append(KDesTab);     // 3
       
  1864                 }
       
  1865             }
       
  1866         aText.Append(KDesTab);             // 4
       
  1867         }
       
  1868     CleanupStack::PopAndDestroy(); // item
       
  1869     }
       
  1870 
       
  1871 // ---------------------------------------------------------
       
  1872 // CSpdiaContainer::FindFieldL
       
  1873 //
       
  1874 // ---------------------------------------------------------
       
  1875 //
       
  1876 TPbkContactItemField* CSpdiaControl::FindFieldL(
       
  1877               CPbkContactItem& aItem, TPbkFieldId aFieldId)
       
  1878     {
       
  1879     TPbkContactItemField* field = aItem.FindField(aFieldId);
       
  1880     if (field)
       
  1881         {
       
  1882         HBufC* buf = field->Text().AllocL();
       
  1883         buf->Des().Trim();
       
  1884         if (buf->Des().Length() == 0)
       
  1885             {
       
  1886             field = NULL;
       
  1887             }
       
  1888         delete buf;
       
  1889         }
       
  1890     return field;
       
  1891     }
       
  1892 // ---------------------------------------------------------
       
  1893 // CSpdiaContainer::AppendThumbnail
       
  1894 // output \tThumbnail\ticon
       
  1895 // ---------------------------------------------------------
       
  1896 //
       
  1897 void CSpdiaControl::AppendThumbnail(
       
  1898     const TSpdiaIndexData& aSdmData,
       
  1899     TPtr& aText,
       
  1900     TBool aFixedLocation )
       
  1901     {
       
  1902     if (!aFixedLocation)
       
  1903         {
       
  1904         aText.Append(KDesTab2);
       
  1905         return;
       
  1906         }
       
  1907 
       
  1908     aText.Append(KDesTab);
       
  1909     if (aSdmData.ThumbIndex() >= 0)
       
  1910         {
       
  1911         aText.AppendNum(aSdmData.ThumbIndex());
       
  1912         }
       
  1913 
       
  1914     aText.Append(KDesTab);
       
  1915     if (aSdmData.IconIndex() >= 0)
       
  1916         {
       
  1917         aText.AppendNum(aSdmData.IconIndex());
       
  1918         }
       
  1919     }
       
  1920 
       
  1921 // ---------------------------------------------------------
       
  1922 // CSpdiaContainer::ConvThumbType
       
  1923 // Returns
       
  1924 //      EtnVGA  : 640 x 480 40 x 30 VGA
       
  1925 //      EtnVGA90: 480 x 640 30 x 40 VGA turned
       
  1926 //      EtnCIF  : 352 x 288 44 x 36 CIF
       
  1927 //      EtnCIF90: 288 x 352 36 x 44 CIF turned
       
  1928 //      EtnCOM  : othre
       
  1929 // ---------------------------------------------------------
       
  1930 //
       
  1931 TInt CSpdiaControl::ConvThumbType(const TSize& aSize) const
       
  1932     {
       
  1933     // Scalable UI
       
  1934     TAknWindowLineLayout  vga;
       
  1935     TAknWindowLineLayout  cif;
       
  1936     if( AknLayoutUtils::ScalableLayoutInterfaceAvailable() )
       
  1937         {
       
  1938         vga = AknLayoutScalable_Apps::popup_phob_thumbnail_window_g2().LayoutLine();
       
  1939         cif = AknLayoutScalable_Apps::popup_phob_thumbnail_window_g1().LayoutLine();//image
       
  1940         }
       
  1941     else
       
  1942         {
       
  1943         vga = AppLayout::Thumbnail_pop_up_window_elements_Line_1();
       
  1944         cif = AppLayout::Thumbnail_pop_up_window_elements_Line_3();
       
  1945         }
       
  1946     TInt type(CSpdiaGrid::EtnCOM);
       
  1947 
       
  1948     if (aSize.iWidth == cif.iH//SDM_TN_CIF_HEIGHT
       
  1949             && aSize.iHeight == cif.iW)// SDM_TN_CIF_WIDTH)
       
  1950         {
       
  1951         type = CSpdiaGrid::EtnCIF90;
       
  1952         }
       
  1953     else if (aSize.iWidth == cif.iW &&//SDM_TN_CIF_WIDTH &&
       
  1954                     aSize.iHeight ==  cif.iH)//SDM_TN_CIF_HEIGHT)
       
  1955         {
       
  1956         type = CSpdiaGrid::EtnCIF;
       
  1957         }
       
  1958     else if (aSize.iWidth == vga.iH &&//SDM_TN_VGA_HEIGHT &&
       
  1959                     aSize.iHeight == vga.iW )//SDM_TN_VGA_WIDTH)
       
  1960         {
       
  1961         type = CSpdiaGrid::EtnVGA90;
       
  1962         }
       
  1963     else if (aSize.iWidth == vga.iW &&//SDM_TN_VGA_WIDTH &&
       
  1964                     aSize.iHeight == vga.iH)//SDM_TN_VGA_HEIGHT)
       
  1965         {
       
  1966         type = CSpdiaGrid::EtnVGA;
       
  1967         }
       
  1968 
       
  1969     return type;
       
  1970     }
       
  1971 
       
  1972 
       
  1973 // ---------------------------------------------------------
       
  1974 // CSpdiaContainer::SetOperationsL
       
  1975 //
       
  1976 // ---------------------------------------------------------
       
  1977 //
       
  1978 void CSpdiaControl::SetOperationsL()
       
  1979     {
       
  1980     for (TInt index(iSdmArray->Count() -1); index > 0; --index)
       
  1981         {
       
  1982         TSpdiaIndexData& data = (*iSdmArray)[index];
       
  1983         if (data.ContactItem() != NULL)
       
  1984             {
       
  1985             data.SetOperation(
       
  1986                     iManager->GetThumbnailAsyncL(*this, *data.ContactItem()));
       
  1987             }
       
  1988         }
       
  1989     }
       
  1990 
       
  1991 // ---------------------------------------------------------
       
  1992 // CSpdiaContainer::SetItemDataL
       
  1993 //
       
  1994 // ---------------------------------------------------------
       
  1995 //
       
  1996 void CSpdiaControl::SetItemDataL(CDesCArray& aArray)
       
  1997     {
       
  1998     for (TInt loop(0); loop < iSdmCount; loop++)
       
  1999         {
       
  2000         TSpdiaIndexData& data = (*iSdmArray)[loop];
       
  2001 
       
  2002         aArray.AppendL(ItemDescriptorLC(loop, data)->Des());
       
  2003         CleanupStack::PopAndDestroy(); // des
       
  2004         }
       
  2005     }
       
  2006 
       
  2007 
       
  2008 // ---------------------------------------------------------
       
  2009 // CSpdiaContainer::AssignDialL
       
  2010 // Function called when assigning speed dial from phone book
       
  2011 // application
       
  2012 // ---------------------------------------------------------
       
  2013 //
       
  2014 void CSpdiaControl::AssignDialL(TContactItemId aId, TInt aFieldIdx, TInt aDial)
       
  2015     {
       
  2016     if (iBooleanVarForAddingDialogVariation)
       
  2017         {
       
  2018         if(!CSpdiaControl::CheckingIfPopUpNeeded())
       
  2019             return;
       
  2020         }
       
  2021     else
       
  2022         {   // do nothing
       
  2023         }
       
  2024 
       
  2025     TInt index(Index(aDial));
       
  2026     TPhCltTelephoneNumber phonenumber;
       
  2027     TContactItemId id(ContactId(index));
       
  2028     
       
  2029     if (id != KNullContactId)
       
  2030         {
       
  2031         RemoveDialIndexL(index, EFalse);
       
  2032         }
       
  2033     
       
  2034     CPbkContactItem* item = OpenContactL( iEngine, aId );
       
  2035     CleanupStack::PushL(item);
       
  2036 
       
  2037     CPbkFieldArray& fields = item->CardFields();
       
  2038     TInt fieldCount = fields.Count();   
       
  2039     
       
  2040     if ( aFieldIdx < fieldCount )
       
  2041         {
       
  2042         TPbkContactItemField& field = fields[aFieldIdx];
       
  2043         field.GetTextL(phonenumber); 
       
  2044         phonenumber.Trim();
       
  2045         iEngine->SetFieldAsSpeedDialL(*item, aFieldIdx, aDial); 
       
  2046 		
       
  2047         iEngine->CloseContactL(aId);
       
  2048         CleanupStack::PopAndDestroy();  // item
       
  2049 	
       
  2050         HBufC* prompt =
       
  2051             StringLoader::LoadLC(R_SPDIA_TEXT_KEY_ASSIGNED, aDial, iCoeEnv);
       
  2052         CAknConfirmationNote* note = new (ELeave)CAknConfirmationNote();
       
  2053         note->ExecuteLD(*prompt);
       
  2054         CleanupStack::PopAndDestroy(); // prompt
       
  2055         }
       
  2056     else 
       
  2057         {
       
  2058         iEngine->CloseContactL(aId);
       
  2059         CleanupStack::PopAndDestroy();  // item
       
  2060         }
       
  2061     }
       
  2062 
       
  2063 // ---------------------------------------------------------
       
  2064 // CCalenNoteForm::CheckSpaceBelowCriticalLevelL
       
  2065 // Checks if the Flash File System storage will fall below
       
  2066 // Critical Level. Warning will be displayed if sotrage
       
  2067 // is below Critical Level.
       
  2068 // (other items were commented in a header).
       
  2069 // ---------------------------------------------------------
       
  2070 //
       
  2071 TBool CSpdiaControl::CheckSpaceBelowCriticalLevelL()
       
  2072     {
       
  2073     TBool retcode(EFalse);
       
  2074 
       
  2075     if (SysUtil::FFSSpaceBelowCriticalLevelL(&(iCoeEnv->FsSession())))
       
  2076         {
       
  2077         CErrorUI* errorUi = CErrorUI::NewLC();
       
  2078         errorUi->ShowGlobalErrorNoteL(KErrDiskFull);
       
  2079         CleanupStack::PopAndDestroy(); // errorUi
       
  2080         retcode = ETrue;
       
  2081         }
       
  2082     return retcode;
       
  2083     }
       
  2084 
       
  2085 // ---------------------------------------------------------
       
  2086 // CSpdiaContainer::HasOperation
       
  2087 //
       
  2088 // ---------------------------------------------------------
       
  2089 //
       
  2090 TInt CSpdiaControl::HasOperation(const MPbkThumbnailOperation& aOperation)
       
  2091     {
       
  2092     for (TInt index(0); index < iSdmArray->Count(); index++)
       
  2093         {
       
  2094         if ((*iSdmArray)[index].Operation() == &aOperation)
       
  2095             {
       
  2096             return index;
       
  2097             }
       
  2098         }
       
  2099     return KNullIndexData;
       
  2100     }
       
  2101 
       
  2102 // ---------------------------------------------------------
       
  2103 // CSpdiaContainer::ResetArray
       
  2104 //
       
  2105 // ---------------------------------------------------------
       
  2106 //
       
  2107 void CSpdiaControl::ResetArray()
       
  2108     {
       
  2109     if(iSdmArray!= NULL)
       
  2110         {
       
  2111         for (TInt index(0); index < iSdmArray->Count(); index++)
       
  2112             {
       
  2113             delete (*iSdmArray)[index].ContactItem();
       
  2114             delete (*iSdmArray)[index].Operation();
       
  2115             }
       
  2116         }
       
  2117     }
       
  2118 
       
  2119 // ---------------------------------------------------------
       
  2120 // CSpdiaContainer::UpdateIndexDataL
       
  2121 //
       
  2122 // ---------------------------------------------------------
       
  2123 //
       
  2124 TBool CSpdiaControl::UpdateIndexDataL(TInt aIndex)
       
  2125     {
       
  2126     CFbsBitmap* bitmap,*mask;
       
  2127     bitmap = NULL;
       
  2128     mask= NULL;
       
  2129     MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
       
  2130 	
       
  2131 
       
  2132     TSpdiaIndexData& data = (*iSdmArray)[aIndex];
       
  2133     delete (*iIconArray)[aIndex];
       
  2134     (*iIconArray)[aIndex] = NULL;
       
  2135     TFileName bmpPath(iBmpPath);
       
  2136     
       
  2137     if(User::Language() == ELangHindi)
       
  2138         {
       
  2139         AknsUtils::CreateIconL(skinInstance, (*iDialSkinBmp)[aIndex],bitmap,mask,bmpPath,KDialHindiBmp[aIndex],  KDialHindiBmpMask[aIndex] );	
       
  2140         }
       
  2141     else 
       
  2142         {
       
  2143         AknsUtils::CreateIconL(skinInstance, (*iDialSkinBmp)[aIndex],bitmap,mask,bmpPath,KDialBmp[aIndex],  KDialBmpMask[aIndex] );
       
  2144         }
       
  2145     (*iIconArray)[aIndex] = CGulIcon::NewL(bitmap,mask);
       
  2146 	
       
  2147     data.ResetThumbIndex();
       
  2148     if (CreateIndexIconL(aIndex, data, ETrue))
       
  2149         {
       
  2150         data.SetOperation(
       
  2151             iManager->GetThumbnailAsyncL(*this, *data.ContactItem()));
       
  2152         }
       
  2153     else
       
  2154         {
       
  2155         ChangeIndexDataL(aIndex, data);
       
  2156         iGrid->DrawNow();
       
  2157         }
       
  2158     return ETrue;
       
  2159     }
       
  2160 
       
  2161 // ---------------------------------------------------------
       
  2162 // CSpdiaContainer::SetIndexDataL
       
  2163 // phone book access
       
  2164 // ---------------------------------------------------------
       
  2165 //
       
  2166 void CSpdiaControl::SetIndexDataL(TInt aIndex, TSpdiaIndexData& aSdmData)
       
  2167     {
       
  2168     TPhCltTelephoneNumber phonenumber;
       
  2169 
       
  2170     aSdmData.SetIndex(aIndex);
       
  2171     aSdmData.SetPhoneNumber(KNullDesC);
       
  2172     aSdmData.SetNumber(aIndex + 1);
       
  2173     aSdmData.SetContactId(iEngine->GetSpeedDialFieldL(
       
  2174                              aIndex + 1, phonenumber));
       
  2175     if (aSdmData.ContactId() != KNullContactId)
       
  2176         {
       
  2177         phonenumber.Trim();
       
  2178         if (phonenumber.Length() > 0)
       
  2179             {
       
  2180             aSdmData.SetPhoneNumber(phonenumber);
       
  2181             }
       
  2182         else
       
  2183             {
       
  2184             iEngine->RemoveSpeedDialFieldL(aSdmData.ContactId(), aIndex + 1);
       
  2185             aSdmData.SetContactId(KNullContactId);
       
  2186             }
       
  2187         }
       
  2188     }
       
  2189 
       
  2190 // ---------------------------------------------------------
       
  2191 // CSpdiaContainer::ChangeIndexDataL
       
  2192 //
       
  2193 // ---------------------------------------------------------
       
  2194 //
       
  2195 void CSpdiaControl::ChangeIndexDataL(
       
  2196     TInt aIndex,
       
  2197     const TSpdiaIndexData& aSdmData )
       
  2198     {
       
  2199     CDesCArray* array = STATIC_CAST(CDesCArray*,
       
  2200                         iGrid->Model()->ItemTextArray());
       
  2201     HBufC* des = ItemDescriptorLC(aIndex, aSdmData);
       
  2202     array->Delete(aIndex);
       
  2203     array->InsertL(aIndex, *des);
       
  2204     CleanupStack::PopAndDestroy(); // des
       
  2205     }
       
  2206 
       
  2207 // ---------------------------------------------------------
       
  2208 // CSpdiaContainer::CreateIndexIconL
       
  2209 //
       
  2210 // ---------------------------------------------------------
       
  2211 //
       
  2212 TBool CSpdiaControl::CreateIndexIconL(TInt aIndex,
       
  2213                  TSpdiaIndexData& aSdmData, TBool aSetUpdateThumb)
       
  2214     {
       
  2215     TBool existThumb(EFalse);
       
  2216 
       
  2217     if (aSdmData.ContactId() != KNullContactId)
       
  2218         {
       
  2219         CPbkContactItem* item = iEngine->ReadContactL(aSdmData.ContactId());
       
  2220         TInt fieldId(EPbkFieldIdNone);
       
  2221         aSdmData.SetIconIndex(IconPositionL(*item, aIndex + 1, fieldId));
       
  2222         aSdmData.SetFieldId( fieldId );  // set number type
       
  2223 
       
  2224         if (iManager->HasThumbnail(*item))
       
  2225             {
       
  2226             existThumb = ETrue;
       
  2227             aSdmData.SetContactItem(item);
       
  2228 
       
  2229             if (aSetUpdateThumb)
       
  2230                 {
       
  2231                 aSdmData.SetLastThumb(ETrue);
       
  2232                 }
       
  2233             aSdmData.SetThumbIndex(aIndex, NULL);
       
  2234             }
       
  2235         else
       
  2236             {
       
  2237             delete item;
       
  2238             }
       
  2239         }
       
  2240     return existThumb;
       
  2241     }
       
  2242 
       
  2243 // ---------------------------------------------------------
       
  2244 // CSpdiaContainer::DrawShadow
       
  2245 //
       
  2246 // ---------------------------------------------------------
       
  2247 //
       
  2248 void CSpdiaControl::DrawShadow(CWindowGc& aGc) const
       
  2249     {
       
  2250     //TSize size(cell_spdia_item_w, cell_spdia_item_h);
       
  2251     //Scalable UI.
       
  2252     TAknWindowLineLayout area;
       
  2253     if( AknLayoutUtils::ScalableLayoutInterfaceAvailable() )
       
  2254         {
       
  2255         area = AknLayoutScalable_Apps::cell_qdial_pane(0,0).LayoutLine();           
       
  2256         }
       
  2257     else
       
  2258         {
       
  2259         area = AppLayout::cell_qdial_pane(0,0);
       
  2260         }
       
  2261 	
       
  2262     TSize size(area.iW, area.iH);
       
  2263     aGc.SetPenColor(AKN_LAF_COLOR(SDM_TN_SHADOW_COROL));
       
  2264     TInt count(iSdmArray->Count());
       
  2265     //TRect rect(TPoint(spdia_main_pane_grid_l, spdia_main_pane_grid_t), size);
       
  2266     //Scalable UI
       
  2267     if( AknLayoutUtils::ScalableLayoutInterfaceAvailable() )
       
  2268         {
       
  2269         area = AknLayoutScalable_Apps::grid_qdial_pane().LayoutLine();
       
  2270         }
       
  2271     else
       
  2272         {
       
  2273         area = AppLayout::Speed_Dial_descendants_Line_1();
       
  2274         }
       
  2275     TRect rect(TPoint(area.il, area.it), size);
       
  2276     for (TInt i(0); i < count; ++i)
       
  2277         {
       
  2278         if (ThumbIndex(i) >= 0)
       
  2279             {
       
  2280             TInt type(ThumbType(i));
       
  2281             TRect rc((*iShadowLayout)[type].Rect());
       
  2282             if (type == CSpdiaGrid::EtnCOM)
       
  2283                 {
       
  2284                 TSize image(ThumbSize(i));
       
  2285                 image.iWidth = Min(image.iWidth, rc.Width());
       
  2286                 image.iHeight = Min(image.iHeight, rc.Height());
       
  2287                 rc = TRect(TPoint(0,0), image);
       
  2288                 TInt x(Max(0, (size.iWidth - image.iWidth) / 2) + 2);
       
  2289                 TInt y(Max(0, (size.iHeight - image.iHeight) / 2) + 2);
       
  2290                 rc.Move(x, y);
       
  2291                 }
       
  2292             rc.Move(rect.iTl.iX, rect.iTl.iY);
       
  2293             aGc.DrawRect(rc);
       
  2294             }
       
  2295         rect.Move(size.iWidth, 0);
       
  2296         if (((i + 1)/ KCellColCount) * KCellRowCount == i + 1)
       
  2297             {
       
  2298             rect.Move(-(KCellColCount * size.iWidth), size.iHeight);
       
  2299             }
       
  2300         }
       
  2301     }
       
  2302 
       
  2303 // ---------------------------------------------------------
       
  2304 // CSpdiaControl::MopSupplyObject()
       
  2305 // Pass skin information if need.
       
  2306 // ---------------------------------------------------------
       
  2307 //
       
  2308 TTypeUid::Ptr CSpdiaControl::MopSupplyObject(TTypeUid aId)
       
  2309     {
       
  2310     if(aId.iUid == MAknsControlContext::ETypeId)
       
  2311         {
       
  2312         return MAknsControlContext::SupplyMopObject( aId, iBgContext );
       
  2313         }
       
  2314     return CCoeControl::MopSupplyObject( aId );
       
  2315     }
       
  2316 
       
  2317 // ---------------------------------------------------------
       
  2318 // CSpdiaControl::SizeChanged()
       
  2319 // ---------------------------------------------------------
       
  2320 //
       
  2321 void CSpdiaControl::SizeChanged()
       
  2322     {
       
  2323     iBgContext->SetRect( Rect() );
       
  2324     }
       
  2325 
       
  2326 
       
  2327 // ---------------------------------------------------------
       
  2328 // CSpdiaControl::VoiceMailTypeL
       
  2329 //
       
  2330 // ---------------------------------------------------------
       
  2331 //
       
  2332 EXPORT_C TInt CSpdiaControl::VoiceMailType()
       
  2333     {
       
  2334     return iType;
       
  2335     }
       
  2336     
       
  2337 // ---------------------------------------------------------
       
  2338 // CSpdiaControl::GetThumbnailSize()
       
  2339 // Gets actual size of thumbnial to be drawn
       
  2340 // ---------------------------------------------------------
       
  2341 //
       
  2342 TSize CSpdiaControl::GetThumbnailSize()
       
  2343     {
       
  2344     TRect mainPaneRect ;
       
  2345     TRect statusPaneRect;
       
  2346     TInt  varient =0;
       
  2347 
       
  2348     if (Layout_Meta_Data::IsLandscapeOrientation())
       
  2349         {
       
  2350         AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane,mainPaneRect);
       
  2351         AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EStatusPane,statusPaneRect);
       
  2352         mainPaneRect.iTl = statusPaneRect.iTl;
       
  2353         mainPaneRect.iBr.iY = mainPaneRect.iBr.iY - statusPaneRect.iTl.iY;
       
  2354         varient =1;
       
  2355         }
       
  2356     else
       
  2357         {
       
  2358         AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane,mainPaneRect);
       
  2359         AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EStatusPane,statusPaneRect);
       
  2360         mainPaneRect.iTl= statusPaneRect.iTl;
       
  2361         }
       
  2362 		
       
  2363     TAknLayoutRect mainGridPaneRect;
       
  2364     TAknLayoutRect gridPaneRect;
       
  2365     TAknLayoutRect cellPaneRect;
       
  2366     TAknLayoutRect thumbPaneRect;
       
  2367 	
       
  2368     mainGridPaneRect.LayoutRect(mainPaneRect,AknLayoutScalable_Apps::main_qdial_pane());//main grid pane
       
  2369     gridPaneRect.LayoutRect(mainGridPaneRect.Rect(),AknLayoutScalable_Apps::grid_qdial_pane());//main grid pane
       
  2370     cellPaneRect.LayoutRect(gridPaneRect.Rect(),AknLayoutScalable_Apps::cell_qdial_pane(0,0));
       
  2371     thumbPaneRect.LayoutRect(cellPaneRect.Rect(),AknLayoutScalable_Apps::thumbnail_qdial_pane(varient));
       
  2372 
       
  2373     return thumbPaneRect.Rect().Size();
       
  2374     }
       
  2375 // ---------------------------------------------------------
       
  2376 // CSpdiaControl::GetSpdCtrlLastError()
       
  2377 // retuns last error 
       
  2378 // ---------------------------------------------------------
       
  2379 //	
       
  2380 EXPORT_C TInt CSpdiaControl::GetSpdCtrlLastError()
       
  2381     {
       
  2382     return iError;
       
  2383     }
       
  2384 // End of File