phonebookui/Phonebook2/ServerApplication/src/CPbk2ServerAppAppUi.cpp
changeset 0 e686773b3f54
child 35 4ae315f230bc
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 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     }
       
   107 
       
   108 // --------------------------------------------------------------------------
       
   109 // CPbk2ServerAppAppUi::StoreManager
       
   110 // --------------------------------------------------------------------------
       
   111 //
       
   112 CPbk2StoreManager& CPbk2ServerAppAppUi::StoreManager() const
       
   113     {
       
   114     MPbk2ApplicationServices2* appServicesExtension =
       
   115         reinterpret_cast<MPbk2ApplicationServices2*>
       
   116             ( iAppServices->MPbk2ApplicationServicesExtension(
       
   117                 KMPbk2ApplicationServicesExtension2Uid ) );
       
   118     
       
   119     return appServicesExtension->StoreManager();
       
   120     }
       
   121 
       
   122 // --------------------------------------------------------------------------
       
   123 // CPbk2ServerAppAppUi::ChangeStatuspaneLayoutL
       
   124 // --------------------------------------------------------------------------
       
   125 //
       
   126 void CPbk2ServerAppAppUi::ChangeStatuspaneLayoutL
       
   127         (  TPbk2ServerAppStatusPaneLayout aLayout )
       
   128     {
       
   129     TInt currentstatuspane = StatusPane()->CurrentLayoutResId();
       
   130     switch ( aLayout )
       
   131         {
       
   132         case EStatusPaneLayoutEmpty:
       
   133             {
       
   134             if( currentstatuspane != R_AVKON_STATUS_PANE_LAYOUT_EMPTY )
       
   135                 {
       
   136                 CEikStatusPane* sp = StatusPane();
       
   137                  // Fetch pointer to the title pane control
       
   138                 sp->SwitchLayoutL(
       
   139                     R_AVKON_STATUS_PANE_LAYOUT_EMPTY );
       
   140                 // To draw the skin on the toolbar requires the toolbar
       
   141                 // to be visible. Skin drawing is handled by platform. 
       
   142                 // Not drawing the skin could result in the toolbar area in 
       
   143                 // landscape orientation being a strange value. 
       
   144                 CAknToolbar* toolbar = CurrentFixedToolbar();
       
   145                 if ( toolbar )
       
   146                     {
       
   147                     toolbar->SetToolbarVisibility( ETrue );
       
   148                     }
       
   149                 }
       
   150             break;
       
   151             }
       
   152 
       
   153         case EStatusPaneLayoutUsual:
       
   154             {
       
   155             if ( currentstatuspane !=  R_AVKON_STATUS_PANE_LAYOUT_USUAL )
       
   156                 {
       
   157                 StatusPane()->SwitchLayoutL(
       
   158                     R_AVKON_STATUS_PANE_LAYOUT_USUAL );
       
   159                 }
       
   160             break;
       
   161             }
       
   162 
       
   163         default:
       
   164             {
       
   165             // Do nothing
       
   166             break;
       
   167             }
       
   168         }
       
   169     }
       
   170 
       
   171 // --------------------------------------------------------------------------
       
   172 // CPbk2ServerAppAppUi:ActiveView
       
   173 // --------------------------------------------------------------------------
       
   174 //
       
   175 CPbk2AppViewBase* CPbk2ServerAppAppUi::ActiveView() const
       
   176     {
       
   177     // Not supported in Server App
       
   178     return NULL;
       
   179     }
       
   180 
       
   181 // --------------------------------------------------------------------------
       
   182 // CPbk2ServerAppAppUi::Pbk2ViewExplorer
       
   183 // --------------------------------------------------------------------------
       
   184 //
       
   185 MPbk2ViewExplorer* CPbk2ServerAppAppUi::Pbk2ViewExplorer() const
       
   186     {
       
   187     // Not supported in Server App
       
   188     return NULL;
       
   189     }
       
   190 
       
   191 // --------------------------------------------------------------------------
       
   192 // CPbk2ServerAppAppUi::Pbk2StartupMonitor
       
   193 // --------------------------------------------------------------------------
       
   194 //
       
   195 MPbk2StartupMonitor* CPbk2ServerAppAppUi::Pbk2StartupMonitor() const
       
   196     {
       
   197     // Not supported in Server App
       
   198     return NULL;
       
   199     }
       
   200 
       
   201 // --------------------------------------------------------------------------
       
   202 // CPbk2ServerAppAppUi::TabGroups
       
   203 // --------------------------------------------------------------------------
       
   204 //
       
   205 CPbk2TabGroupContainer* CPbk2ServerAppAppUi::TabGroups() const
       
   206     {
       
   207     // Not supported in Server App
       
   208     return NULL;
       
   209     }
       
   210 
       
   211 // --------------------------------------------------------------------------
       
   212 // CPbk2ServerAppAppUi::KeyEventHandler
       
   213 // --------------------------------------------------------------------------
       
   214 //
       
   215 MPbk2KeyEventHandler& CPbk2ServerAppAppUi::KeyEventHandler()
       
   216     {
       
   217     return *this;
       
   218     }
       
   219 
       
   220 // --------------------------------------------------------------------------
       
   221 // CPbk2ServerAppAppUi::ApplicationServices
       
   222 // --------------------------------------------------------------------------
       
   223 //
       
   224 MPbk2ApplicationServices& CPbk2ServerAppAppUi::ApplicationServices() const
       
   225     {
       
   226     return *iAppServices;
       
   227     }
       
   228 
       
   229 // --------------------------------------------------------------------------
       
   230 // CPbk2ServerAppAppUi::HandleCommandL
       
   231 // --------------------------------------------------------------------------
       
   232 //
       
   233 void CPbk2ServerAppAppUi::HandleCommandL( TInt aCommand )
       
   234     {
       
   235     switch ( aCommand )
       
   236         {
       
   237         case EEikCmdExit: // FALLTHROUGH
       
   238         case EAknCmdExit:
       
   239             {
       
   240             Exit();
       
   241             break;
       
   242             }
       
   243         default:
       
   244             {
       
   245             CAknAppUi::HandleCommandL( aCommand );
       
   246             break;
       
   247             }
       
   248         }
       
   249     }
       
   250 
       
   251 // --------------------------------------------------------------------------
       
   252 // CPbk2ServerAppAppUi::ExitApplication
       
   253 // --------------------------------------------------------------------------
       
   254 //
       
   255 void CPbk2ServerAppAppUi::ExitApplication()
       
   256     {
       
   257     Exit();
       
   258     }
       
   259 
       
   260 // --------------------------------------------------------------------------
       
   261 // CPbk2ServerAppAppUi::Pbk2ProcessKeyEventL
       
   262 // --------------------------------------------------------------------------
       
   263 //
       
   264 TBool CPbk2ServerAppAppUi::Pbk2ProcessKeyEventL
       
   265         ( const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/ )
       
   266     {
       
   267     return EFalse;
       
   268     }
       
   269 
       
   270 // --------------------------------------------------------------------------
       
   271 // CPbk2ServerAppAppUi::LocalVariationFeatureEnabled
       
   272 // --------------------------------------------------------------------------
       
   273 //
       
   274 TBool CPbk2ServerAppAppUi::LocalVariationFeatureEnabled( TInt aFeatureFlag )
       
   275     {
       
   276     TBool ret( EFalse );
       
   277     TInt lvFlags( KErrNotFound );
       
   278     CRepository* key = NULL;
       
   279     // Read local variation flags
       
   280     TRAPD( err, key =
       
   281             CRepository::NewL( TUid::Uid( KCRUidPhonebook ) ) );
       
   282     // If NewL fails do not set iLVFlags, new query is made next time
       
   283     if ( err == KErrNone )
       
   284         {
       
   285         err = key->Get( KPhonebookLocalVariationFlags, lvFlags );
       
   286         if ( err != KErrNone )
       
   287             {
       
   288             // If there were problems reading the flags,
       
   289             // assume everything is off
       
   290             lvFlags = 0;
       
   291             }
       
   292         delete key;
       
   293         }
       
   294 
       
   295     if ( lvFlags != KErrNotFound )
       
   296         {
       
   297         ret = lvFlags & aFeatureFlag;
       
   298         }
       
   299 
       
   300     return ret;
       
   301     }
       
   302 
       
   303 void CPbk2ServerAppAppUi::HandleWsEventL(const TWsEvent& aEvent,CCoeControl* aDestination)
       
   304     {
       
   305     TKeyEvent keyEvent = *aEvent.Key();
       
   306     TInt type = aEvent.Type();
       
   307     
       
   308     // Filter out all the EEventKeyUp and EEventKeyDown send key
       
   309     // events. This avoids launching the dailer unnecessarily
       
   310     if (!(keyEvent.iScanCode == EStdKeyYes
       
   311           && (type == EEventKeyUp || type == EEventKeyDown)))
       
   312         {
       
   313         CAknAppUi::HandleWsEventL( aEvent, aDestination );
       
   314         }
       
   315     }
       
   316 
       
   317 // End of File