phonebookui/Phonebook2/USIMThinExtension/src/CPsu2ThinUIExtensionPlugin.cpp
changeset 0 e686773b3f54
child 3 04ab22b956c2
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2005-2007 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:  Phonebook 2 USIM Thin UI extension plugin.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "CPsu2ThinUIExtensionPlugin.h"
       
    21 
       
    22 // Phonebook 2
       
    23 #include "CPsu2CopySimContactsCmd.h"
       
    24 #include <Pbk2USimUI.hrh>
       
    25 #include <Pbk2USimUIRes.rsg>
       
    26 #include <Pbk2Commands.rsg>
       
    27 #include <MPbk2ContactUiControl.h>
       
    28 #include <MPbk2StartupMonitor.h>
       
    29 #include "CPsu2CheckAvailabeSimStore.h"
       
    30 
       
    31 // Virtual Phonebook
       
    32 #include <VPbkSimStoreFactory.h>
       
    33 #include <MVPbkSimPhone.h>
       
    34 #include <VPbkContactStoreUris.h>
       
    35 
       
    36 // System includes
       
    37 #include <eikmenup.h>
       
    38 
       
    39 #include <Pbk2Debug.h>
       
    40 
       
    41 /// Unnamed namespace for local definitions
       
    42 namespace {
       
    43 
       
    44 /// All stores in "SIM Memory" cascade menu
       
    45 const TUint32 KAllSimStores=
       
    46     MVPbkSimPhone::KVPbkCapsSDNSupported |
       
    47     MVPbkSimPhone::KVPbkCapsFDNSupported |
       
    48     MVPbkSimPhone::KVPbkCapsONSupported;
       
    49     
       
    50 /**
       
    51  * Dims given menu item from given menu pane.
       
    52  *
       
    53  * @param aMenuPane     Menu pane where menu item resides.
       
    54  * @param aCommandId    Id of the menu item to dim.
       
    55  */
       
    56 void DimMenuItem( CEikMenuPane& aMenuPane, TInt aCommandId )
       
    57     {
       
    58     TInt pos = KErrNotFound;
       
    59     if ( aMenuPane.MenuItemExists( aCommandId, pos ) )
       
    60         {
       
    61         aMenuPane.SetItemDimmed( aCommandId, ETrue );
       
    62         }
       
    63     }
       
    64 
       
    65 } /// namespace
       
    66 
       
    67 
       
    68 // --------------------------------------------------------------------------
       
    69 // CPsu2CopySimContactsCmd::CPsu2CopySimContactsCmd
       
    70 // --------------------------------------------------------------------------
       
    71 //
       
    72 CPsu2ThinUIExtensionPlugin::CPsu2ThinUIExtensionPlugin()
       
    73     {
       
    74     }
       
    75 
       
    76 // --------------------------------------------------------------------------
       
    77 // CPsu2ThinUIExtensionPlugin::~CPsu2ThinUIExtensionPlugin
       
    78 // --------------------------------------------------------------------------
       
    79 //
       
    80 CPsu2ThinUIExtensionPlugin::~CPsu2ThinUIExtensionPlugin()
       
    81     {
       
    82     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING
       
    83             ("CPsu2ThinUIExtensionPlugin::~CPsu2ThinUIExtensionPlugin(0x%x)"), this);
       
    84     
       
    85     delete iStoreChecker;
       
    86     delete iCopySimContactsCmd;
       
    87     delete iPhone;
       
    88     }
       
    89 
       
    90 // --------------------------------------------------------------------------
       
    91 // CPsu2ThinUIExtensionPlugin::NewL
       
    92 // --------------------------------------------------------------------------
       
    93 //
       
    94 CPsu2ThinUIExtensionPlugin* CPsu2ThinUIExtensionPlugin::NewL()
       
    95     {
       
    96     CPsu2ThinUIExtensionPlugin* self =
       
    97         new( ELeave ) CPsu2ThinUIExtensionPlugin;
       
    98     CleanupStack::PushL( self );
       
    99     self->ConstructL();
       
   100     CleanupStack::Pop( self );
       
   101     return self;
       
   102     }
       
   103 
       
   104 // --------------------------------------------------------------------------
       
   105 // CPsu2ThinUIExtensionPlugin::ConstructL
       
   106 // --------------------------------------------------------------------------
       
   107 //
       
   108 void CPsu2ThinUIExtensionPlugin::ConstructL()
       
   109     {
       
   110     iServiceTable.Reset();
       
   111     iPhone = VPbkSimStoreFactory::CreatePhoneL();
       
   112     iPhone->OpenL( *this );
       
   113     }
       
   114 
       
   115 // --------------------------------------------------------------------------
       
   116 // CPsu2ThinUIExtensionPlugin::DynInitMenuPaneL
       
   117 // --------------------------------------------------------------------------
       
   118 //
       
   119 void CPsu2ThinUIExtensionPlugin::DynInitMenuPaneL
       
   120         ( TInt aResourceId, CEikMenuPane* aMenuPane,
       
   121           MPbk2ContactUiControl& aControl )
       
   122     {
       
   123     switch (aResourceId)
       
   124         {
       
   125         case R_PHONEBOOK2_NAMESLIST_OTHER_MEMORIES_MENU_PLACEHOLDER:
       
   126             {
       
   127             if ( iServiceTable.IsOff( KAllSimStores ) ||
       
   128  //                aControl.ContactsMarked() || 
       
   129                  ( iStoreChecker &&
       
   130                    !iStoreChecker->IsContactsAvailabe(
       
   131                         VPbkContactStoreUris::SimGlobalOwnNumberUri()) &&
       
   132 //SDN not shown in sim menu anymore (in ECE)
       
   133 //                 !iStoreChecker->IsContactsAvailabe(
       
   134 //                      VPbkContactStoreUris::SimGlobalSdnUri()) &&
       
   135                    iServiceTable.IsOff( MVPbkSimPhone::KVPbkCapsFDNSupported )
       
   136                  ) 
       
   137                )
       
   138                 {
       
   139                 // Dim "SIM Memory" cascading menu if there are no
       
   140                 // SIM stores to launch, or there are marked items
       
   141                 DimMenuItem(*aMenuPane, EPsu2CmdCascadingSimMemory);
       
   142                 }
       
   143             break;
       
   144             }
       
   145 
       
   146         case R_PSU2_CASCADING_SIM_MEMORY_MENU_PANE:
       
   147             {
       
   148             // My number dimmed until index bug is corrected in SIM server
       
   149             if ( iServiceTable.IsOff
       
   150                     ( MVPbkSimPhone::KVPbkCapsONSupported ) ||
       
   151                  ( iStoreChecker &&
       
   152                   !iStoreChecker->IsContactsAvailabe(
       
   153                     VPbkContactStoreUris::SimGlobalOwnNumberUri() ) ) )
       
   154                 {
       
   155                 // "My Number" item
       
   156                 DimMenuItem( *aMenuPane, EPsu2CmdLaunchOwnNumberView );
       
   157                 }
       
   158 //SDN not shown in sim menu anymore so dim it always (in ECE)               
       
   159 //          if ( iServiceTable.IsOff
       
   160 //                  ( MVPbkSimPhone::KVPbkCapsSDNSupported ) ||
       
   161 //               ( iStoreChecker &&                    
       
   162 //                !iStoreChecker->IsContactsAvailabe(
       
   163 //                  VPbkContactStoreUris::SimGlobalSdnUri() ) ) )
       
   164                 {
       
   165                 // "Service Dialing" item
       
   166                 DimMenuItem( *aMenuPane, EPsu2CmdLaunchServiceDialingView );
       
   167                 }
       
   168             if ( iServiceTable.IsOff
       
   169                     ( MVPbkSimPhone::KVPbkCapsFDNSupported ) )
       
   170                 {
       
   171                 // "Fixed Dialing" item
       
   172                 DimMenuItem( *aMenuPane, EPsu2CmdLaunchFixedDialingView );
       
   173                 }
       
   174             break;
       
   175             }
       
   176         default:
       
   177             {
       
   178             // Do nothing
       
   179             break;
       
   180             }
       
   181         }
       
   182     }
       
   183 
       
   184 // --------------------------------------------------------------------------
       
   185 // CPsu2ThinUIExtensionPlugin::ExtensionStartupL
       
   186 // --------------------------------------------------------------------------
       
   187 //
       
   188 void CPsu2ThinUIExtensionPlugin::ExtensionStartupL
       
   189         ( MPbk2StartupMonitor& aStartupMonitor)
       
   190     {
       
   191     aStartupMonitor.RegisterEventsL( *this );
       
   192     }
       
   193 
       
   194 // --------------------------------------------------------------------------
       
   195 // CPsu2ThinUIExtensionPlugin::PhoneOpened
       
   196 // --------------------------------------------------------------------------
       
   197 //
       
   198 void CPsu2ThinUIExtensionPlugin::PhoneOpened( MVPbkSimPhone& aPhone )
       
   199     {
       
   200     iServiceTable.SetServiceTable( aPhone.ServiceTable() );
       
   201     }
       
   202 
       
   203 // --------------------------------------------------------------------------
       
   204 // CPsu2ThinUIExtensionPlugin::PhoneError
       
   205 // --------------------------------------------------------------------------
       
   206 //
       
   207 void CPsu2ThinUIExtensionPlugin::PhoneError
       
   208         ( MVPbkSimPhone& /*aPhone*/, TErrorIdentifier /*aIdentifier*/,
       
   209           TInt /*aError*/ )
       
   210     {
       
   211     iServiceTable.Reset();
       
   212     }
       
   213 
       
   214 // --------------------------------------------------------------------------
       
   215 // CPsu2ThinUIExtensionPlugin::ServiceTableUpdated
       
   216 // --------------------------------------------------------------------------
       
   217 //
       
   218 void CPsu2ThinUIExtensionPlugin::ServiceTableUpdated( TUint32 aServiceTable )
       
   219     {
       
   220     iServiceTable.SetServiceTable( aServiceTable );
       
   221     }
       
   222 
       
   223 // --------------------------------------------------------------------------
       
   224 // CPsu2ThinUIExtensionPlugin::FixedDiallingStatusChanged
       
   225 // --------------------------------------------------------------------------
       
   226 //
       
   227 void CPsu2ThinUIExtensionPlugin::FixedDiallingStatusChanged
       
   228         ( TInt /*aFDNStatus*/ )
       
   229     {
       
   230     // Do nothing
       
   231     }
       
   232 
       
   233 // --------------------------------------------------------------------------
       
   234 // CPsu2ThinUIExtensionPlugin::ContactUiReadyL
       
   235 // --------------------------------------------------------------------------
       
   236 //
       
   237 void CPsu2ThinUIExtensionPlugin::ContactUiReadyL
       
   238         ( MPbk2StartupMonitor& aStartupMonitor )
       
   239     {
       
   240     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING
       
   241             ("CPsu2ThinUIExtensionPlugin::ContactUiReadyL(0x%x) (0x%x) (0x%x)"), this, iStoreChecker, iCopySimContactsCmd);
       
   242 
       
   243     aStartupMonitor.DeregisterEvents( *this );
       
   244 
       
   245     if ( !iCopySimContactsCmd )
       
   246         {
       
   247         MPbk2Command* cmd = CPsu2CopySimContactsCmd::NewL( aStartupMonitor );
       
   248         cmd->ExecuteLD();
       
   249         iCopySimContactsCmd = cmd;
       
   250         iCopySimContactsCmd->AddObserver( *this );
       
   251         }
       
   252     
       
   253     delete iStoreChecker; //needed when alwaysOn enabled
       
   254     iStoreChecker = NULL; 
       
   255     iStoreChecker = CPsu2CheckAvailabeSimStore::NewL();
       
   256     }
       
   257 
       
   258 // --------------------------------------------------------------------------
       
   259 // CPsu2ThinUIExtensionPlugin::CommandFinished
       
   260 // --------------------------------------------------------------------------
       
   261 //
       
   262 void CPsu2ThinUIExtensionPlugin::CommandFinished
       
   263         ( const MPbk2Command& /*aCommand*/ )
       
   264     {
       
   265     delete iCopySimContactsCmd;
       
   266     iCopySimContactsCmd = NULL;
       
   267     }
       
   268 
       
   269 //  End of File