phonebookui/Phonebook2/ServerApplication/src/CPbk2ServerAppAppUi.cpp
branchRCL_3
changeset 63 f4a778e096c2
child 64 c1e8ba0c2b16
equal deleted inserted replaced
62:5b6f26637ad3 63:f4a778e096c2
       
     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 application server application UI.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "CPbk2ServerAppAppUi.h"
       
    20 
       
    21 // Phonebook 2
       
    22 #include "CPbk2ServerAppDocument.h"
       
    23 #include "MPbk2ApplicationServices.h"
       
    24 #include "MPbk2ApplicationServices2.h"
       
    25 
       
    26 #include <Pbk2DataCaging.hrh>
       
    27 #include <Phonebook2PrivateCRKeys.h>
       
    28 
       
    29 // Virtual Phonebook
       
    30 #include <VPbkVariant.hrh>
       
    31 
       
    32 // System includes
       
    33 #include <centralrepository.h>
       
    34 #include <eikspane.h>
       
    35 #include <avkon.rsg>
       
    36 #include <akntoolbar.h>
       
    37 #include <akntitle.h>
       
    38 
       
    39 /// Unnamed namespace for local definitions
       
    40 namespace {
       
    41 
       
    42 _LIT( KPbk2CommandsDllResFileName, "Pbk2Commands.rsc" );
       
    43 _LIT( KPbk2UiControlsDllResFileName, "Pbk2UiControls.rsc" );
       
    44 _LIT( KPbk2CommonUiDllResFileName, "Pbk2CommonUi.rsc" );
       
    45 
       
    46 } /// namespace
       
    47 
       
    48 // --------------------------------------------------------------------------
       
    49 // CPbk2ServerAppAppUi::CPbk2ServerAppAppUi
       
    50 // --------------------------------------------------------------------------
       
    51 //
       
    52 CPbk2ServerAppAppUi::CPbk2ServerAppAppUi():
       
    53         iUiControlsResourceFile( *iCoeEnv ),
       
    54         iCommandsResourceFile( *iCoeEnv ),
       
    55         iCommonUiResourceFile( *iCoeEnv )
       
    56     {
       
    57     }
       
    58 
       
    59 // --------------------------------------------------------------------------
       
    60 // CPbk2ServerAppAppUi::~CPbk2ServerAppAppUi
       
    61 // --------------------------------------------------------------------------
       
    62 //
       
    63 CPbk2ServerAppAppUi::~CPbk2ServerAppAppUi()
       
    64     {
       
    65     iUiControlsResourceFile.Close();
       
    66     iCommandsResourceFile.Close();
       
    67     iCommonUiResourceFile.Close();
       
    68     }
       
    69 
       
    70 // --------------------------------------------------------------------------
       
    71 // CPbk2ServerAppAppUi::ConstructL
       
    72 // --------------------------------------------------------------------------
       
    73 //
       
    74 void CPbk2ServerAppAppUi::ConstructL()
       
    75     {
       
    76     // Init base class
       
    77     if ( LocalVariationFeatureEnabled( EVPbkLVEnableMiddleSoftKey ) )
       
    78         {     
       
    79         BaseConstructL( EAknEnableSkin | EAknEnableMSK | EAknSingleClickCompatible );
       
    80         }
       
    81     else
       
    82         {
       
    83         BaseConstructL( EAknEnableSkin | EAknSingleClickCompatible );
       
    84         }
       
    85     
       
    86     iUiControlsResourceFile.OpenL
       
    87         ( KPbk2RomFileDrive, KDC_RESOURCE_FILES_DIR,
       
    88           KPbk2UiControlsDllResFileName );
       
    89 
       
    90     iCommandsResourceFile.OpenL
       
    91         ( KPbk2RomFileDrive, KDC_RESOURCE_FILES_DIR,
       
    92           KPbk2CommandsDllResFileName );
       
    93 
       
    94     iCommonUiResourceFile.OpenL
       
    95         ( KPbk2RomFileDrive, KDC_RESOURCE_FILES_DIR,
       
    96           KPbk2CommonUiDllResFileName );
       
    97 
       
    98     CPbk2ServerAppDocument* document =
       
    99         static_cast<CPbk2ServerAppDocument*>( Document() );
       
   100     iAppServices = document->ApplicationServicesL();
       
   101     document->CreateGlobalsL();
       
   102 
       
   103     // Make sure that we are using empty statuspane layout
       
   104     ChangeStatuspaneLayoutL( CPbk2ServerAppAppUi::EStatusPaneLayoutEmpty );
       
   105     
       
   106     CEikStatusPane* statusPane = StatusPane();
       
   107     if (statusPane && statusPane->PaneCapabilities(
       
   108         TUid::Uid(EEikStatusPaneUidTitle)).IsPresent())
       
   109         {
       
   110         CAknTitlePane* titlePane = static_cast<CAknTitlePane*>
       
   111             (statusPane->ControlL(TUid::Uid(EEikStatusPaneUidTitle)));
       
   112         if (titlePane->Text())
       
   113             {            
       
   114             titlePane->SetTextL(KNullDesC);
       
   115             }
       
   116         }
       
   117     
       
   118     }
       
   119 
       
   120 // --------------------------------------------------------------------------
       
   121 // CPbk2ServerAppAppUi::StoreManager
       
   122 // --------------------------------------------------------------------------
       
   123 //
       
   124 CPbk2StoreManager& CPbk2ServerAppAppUi::StoreManager() const
       
   125     {
       
   126     MPbk2ApplicationServices2* appServicesExtension =
       
   127         reinterpret_cast<MPbk2ApplicationServices2*>
       
   128             ( iAppServices->MPbk2ApplicationServicesExtension(
       
   129                 KMPbk2ApplicationServicesExtension2Uid ) );
       
   130     
       
   131     return appServicesExtension->StoreManager();
       
   132     }
       
   133 
       
   134 // --------------------------------------------------------------------------
       
   135 // CPbk2ServerAppAppUi::ChangeStatuspaneLayoutL
       
   136 // --------------------------------------------------------------------------
       
   137 //
       
   138 void CPbk2ServerAppAppUi::ChangeStatuspaneLayoutL
       
   139         (  TPbk2ServerAppStatusPaneLayout aLayout )
       
   140     {
       
   141     TInt currentstatuspane = StatusPane()->CurrentLayoutResId();
       
   142     switch ( aLayout )
       
   143         {
       
   144         case EStatusPaneLayoutEmpty:
       
   145             {
       
   146             if( currentstatuspane != R_AVKON_STATUS_PANE_LAYOUT_EMPTY )
       
   147                 {
       
   148                 CEikStatusPane* sp = StatusPane();
       
   149                  // Fetch pointer to the title pane control
       
   150                 sp->SwitchLayoutL(
       
   151                     R_AVKON_STATUS_PANE_LAYOUT_EMPTY );
       
   152                 // To draw the skin on the toolbar requires the toolbar
       
   153                 // to be visible. Skin drawing is handled by platform. 
       
   154                 // Not drawing the skin could result in the toolbar area in 
       
   155                 // landscape orientation being a strange value. 
       
   156                 CAknToolbar* toolbar = CurrentFixedToolbar();
       
   157                 if ( toolbar )
       
   158                     {
       
   159                     toolbar->SetToolbarVisibility( ETrue );
       
   160                     }
       
   161                 }
       
   162             break;
       
   163             }
       
   164 
       
   165         case EStatusPaneLayoutUsual:
       
   166             {
       
   167             if ( currentstatuspane !=  R_AVKON_STATUS_PANE_LAYOUT_USUAL )
       
   168                 {
       
   169                 StatusPane()->SwitchLayoutL(
       
   170                     R_AVKON_STATUS_PANE_LAYOUT_USUAL );
       
   171                 }
       
   172             break;
       
   173             }
       
   174 
       
   175         default:
       
   176             {
       
   177             // Do nothing
       
   178             break;
       
   179             }
       
   180         }
       
   181     }
       
   182 
       
   183 // --------------------------------------------------------------------------
       
   184 // CPbk2ServerAppAppUi:ActiveView
       
   185 // --------------------------------------------------------------------------
       
   186 //
       
   187 CPbk2AppViewBase* CPbk2ServerAppAppUi::ActiveView() const
       
   188     {
       
   189     // Not supported in Server App
       
   190     return NULL;
       
   191     }
       
   192 
       
   193 // --------------------------------------------------------------------------
       
   194 // CPbk2ServerAppAppUi::Pbk2ViewExplorer
       
   195 // --------------------------------------------------------------------------
       
   196 //
       
   197 MPbk2ViewExplorer* CPbk2ServerAppAppUi::Pbk2ViewExplorer() const
       
   198     {
       
   199     // Not supported in Server App
       
   200     return NULL;
       
   201     }
       
   202 
       
   203 // --------------------------------------------------------------------------
       
   204 // CPbk2ServerAppAppUi::Pbk2StartupMonitor
       
   205 // --------------------------------------------------------------------------
       
   206 //
       
   207 MPbk2StartupMonitor* CPbk2ServerAppAppUi::Pbk2StartupMonitor() const
       
   208     {
       
   209     // Not supported in Server App
       
   210     return NULL;
       
   211     }
       
   212 
       
   213 // --------------------------------------------------------------------------
       
   214 // CPbk2ServerAppAppUi::TabGroups
       
   215 // --------------------------------------------------------------------------
       
   216 //
       
   217 CPbk2TabGroupContainer* CPbk2ServerAppAppUi::TabGroups() const
       
   218     {
       
   219     // Not supported in Server App
       
   220     return NULL;
       
   221     }
       
   222 
       
   223 // --------------------------------------------------------------------------
       
   224 // CPbk2ServerAppAppUi::KeyEventHandler
       
   225 // --------------------------------------------------------------------------
       
   226 //
       
   227 MPbk2KeyEventHandler& CPbk2ServerAppAppUi::KeyEventHandler()
       
   228     {
       
   229     return *this;
       
   230     }
       
   231 
       
   232 // --------------------------------------------------------------------------
       
   233 // CPbk2ServerAppAppUi::ApplicationServices
       
   234 // --------------------------------------------------------------------------
       
   235 //
       
   236 MPbk2ApplicationServices& CPbk2ServerAppAppUi::ApplicationServices() const
       
   237     {
       
   238     return *iAppServices;
       
   239     }
       
   240 
       
   241 // --------------------------------------------------------------------------
       
   242 // CPbk2ServerAppAppUi::HandleCommandL
       
   243 // --------------------------------------------------------------------------
       
   244 //
       
   245 void CPbk2ServerAppAppUi::HandleCommandL( TInt aCommand )
       
   246     {
       
   247     switch ( aCommand )
       
   248         {
       
   249         case EEikCmdExit: // FALLTHROUGH
       
   250         case EAknCmdExit:
       
   251             {
       
   252             Exit();
       
   253             break;
       
   254             }
       
   255         default:
       
   256             {
       
   257             CAknAppUi::HandleCommandL( aCommand );
       
   258             break;
       
   259             }
       
   260         }
       
   261     }
       
   262 
       
   263 // --------------------------------------------------------------------------
       
   264 // CPbk2ServerAppAppUi::ExitApplication
       
   265 // --------------------------------------------------------------------------
       
   266 //
       
   267 void CPbk2ServerAppAppUi::ExitApplication()
       
   268     {
       
   269     Exit();
       
   270     }
       
   271 
       
   272 // --------------------------------------------------------------------------
       
   273 // CPbk2ServerAppAppUi::Pbk2ProcessKeyEventL
       
   274 // --------------------------------------------------------------------------
       
   275 //
       
   276 TBool CPbk2ServerAppAppUi::Pbk2ProcessKeyEventL
       
   277         ( const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/ )
       
   278     {
       
   279     return EFalse;
       
   280     }
       
   281 
       
   282 // --------------------------------------------------------------------------
       
   283 // CPbk2ServerAppAppUi::LocalVariationFeatureEnabled
       
   284 // --------------------------------------------------------------------------
       
   285 //
       
   286 TBool CPbk2ServerAppAppUi::LocalVariationFeatureEnabled( TInt aFeatureFlag )
       
   287     {
       
   288     TBool ret( EFalse );
       
   289     TInt lvFlags( KErrNotFound );
       
   290     CRepository* key = NULL;
       
   291     // Read local variation flags
       
   292     TRAPD( err, key =
       
   293             CRepository::NewL( TUid::Uid( KCRUidPhonebook ) ) );
       
   294     // If NewL fails do not set iLVFlags, new query is made next time
       
   295     if ( err == KErrNone )
       
   296         {
       
   297         err = key->Get( KPhonebookLocalVariationFlags, lvFlags );
       
   298         if ( err != KErrNone )
       
   299             {
       
   300             // If there were problems reading the flags,
       
   301             // assume everything is off
       
   302             lvFlags = 0;
       
   303             }
       
   304         delete key;
       
   305         }
       
   306 
       
   307     if ( lvFlags != KErrNotFound )
       
   308         {
       
   309         ret = lvFlags & aFeatureFlag;
       
   310         }
       
   311 
       
   312     return ret;
       
   313     }
       
   314 
       
   315 void CPbk2ServerAppAppUi::HandleWsEventL(const TWsEvent& aEvent,CCoeControl* aDestination)
       
   316     {
       
   317     TKeyEvent keyEvent = *aEvent.Key();
       
   318     TInt type = aEvent.Type();
       
   319     
       
   320     // Filter out all the EEventKeyUp and EEventKeyDown send key
       
   321     // events. This avoids launching the dailer unnecessarily
       
   322     if (!(keyEvent.iScanCode == EStdKeyYes
       
   323           && (type == EEventKeyUp || type == EEventKeyDown)))
       
   324         {
       
   325         CAknAppUi::HandleWsEventL( aEvent, aDestination );
       
   326         }
       
   327     }
       
   328 
       
   329 // End of File