phonebookui/Phonebook2/USIMExtension/src/CPsu2OwnNumbersView.cpp
changeset 0 e686773b3f54
child 21 9da50d567e3c
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2002-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 Own Numbers view.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "CPsu2OwnNumbersView.h"
       
    20 
       
    21 // Phonebook 2
       
    22 #include "CPsu2OwnNumberControl.h"
       
    23 #include "CPsu2ViewManager.h"
       
    24 #include <CPbk2UIExtensionView.h>
       
    25 #include <MPbk2ViewActivationTransaction.h>
       
    26 #include <CPbk2AppUiBase.h>
       
    27 #include <MPbk2ViewExplorer.h>
       
    28 #include <Pbk2USimUIRes.rsg>
       
    29 #include <CPbk2ControlContainer.h>
       
    30 #include <Pbk2MenuFilteringFlags.hrh>
       
    31 #include <CPbk2ContactUiControlSubstitute.h>
       
    32 #include <MPbk2CommandHandler.h>
       
    33 #include <MPbk2ApplicationServices.h>
       
    34 
       
    35 // Virtual Phonebook
       
    36 #include <MVPbkContactStore.h>
       
    37 #include <MVPbkContactStoreInfo.h>
       
    38 #include <CVPbkContactManager.h>
       
    39 #include <MVPbkContactStoreList.h>
       
    40 #include <VPbkContactStoreUris.h>
       
    41 #include <MVPbkContactViewBase.h>
       
    42 
       
    43 // System includes
       
    44 #include <csxhelp/phob.hlp.hrh>
       
    45 #include <StringLoader.h>
       
    46 #include <eikbtgpc.h>
       
    47 #include <avkon.rsg>
       
    48 #include <AknUtils.h>
       
    49 
       
    50 
       
    51 // --------------------------------------------------------------------------
       
    52 // CPsu2OwnNumbersView::CPsu2OwnNumbersView
       
    53 // --------------------------------------------------------------------------
       
    54 //
       
    55 CPsu2OwnNumbersView::CPsu2OwnNumbersView
       
    56         ( CPbk2UIExtensionView& aExtensionView,
       
    57           CPsu2ViewManager& aViewManager ):
       
    58             iExtensionView( aExtensionView ),
       
    59             iViewManager( aViewManager )
       
    60     {
       
    61     }
       
    62 
       
    63 // --------------------------------------------------------------------------
       
    64 // CPsu2OwnNumbersView::~CPsu2OwnNumbersView
       
    65 // --------------------------------------------------------------------------
       
    66 //
       
    67 CPsu2OwnNumbersView::~CPsu2OwnNumbersView()
       
    68     {
       
    69     delete iContainer;
       
    70     }
       
    71 
       
    72 // --------------------------------------------------------------------------
       
    73 // CPsu2OwnNumbersView::NewL
       
    74 // --------------------------------------------------------------------------
       
    75 //
       
    76 CPsu2OwnNumbersView* CPsu2OwnNumbersView::NewL
       
    77         ( CPbk2UIExtensionView& aExtensionView,
       
    78           CPsu2ViewManager& aViewManager )
       
    79     {
       
    80     CPsu2OwnNumbersView* self =
       
    81         new( ELeave ) CPsu2OwnNumbersView( aExtensionView, aViewManager );
       
    82     return self;
       
    83     }
       
    84 
       
    85 // --------------------------------------------------------------------------
       
    86 // CPsu2OwnNumbersView::DoActivateL
       
    87 // --------------------------------------------------------------------------
       
    88 //
       
    89 void CPsu2OwnNumbersView::DoActivateL(const TVwsViewId& aPrevViewId,
       
    90             TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/)
       
    91     {
       
    92     // Load FDN title
       
    93     HBufC* title = StringLoader::LoadLC( R_TEXT_OWN_NUMBER_LIST );
       
    94 
       
    95     MPbk2ViewActivationTransaction* viewActivationTransaction =
       
    96         Phonebook2::Pbk2AppUi()->Pbk2ViewExplorer()->HandleViewActivationLC
       
    97             ( iExtensionView.Id(), aPrevViewId, title, NULL,
       
    98               Phonebook2::EUpdateNaviPane | Phonebook2::EUpdateTitlePane );
       
    99 
       
   100     CreateControlsL();
       
   101     iContainer->ActivateL();
       
   102 
       
   103     viewActivationTransaction->Commit();
       
   104     CleanupStack::PopAndDestroy(2 , title); // viewActivationTransaction
       
   105     UpdateCbasL();
       
   106 
       
   107     iViewManager.RegisterStoreAndView();
       
   108     }
       
   109 
       
   110 // --------------------------------------------------------------------------
       
   111 // CPsu2OwnNumbersView::DoDeactivate
       
   112 // --------------------------------------------------------------------------
       
   113 //
       
   114 void CPsu2OwnNumbersView::DoDeactivate()
       
   115     {
       
   116     if (iContainer)
       
   117         {
       
   118         CCoeEnv::Static()->AppUi()->RemoveFromStack(iContainer);
       
   119         // Store current state, safe to ignore. There's no real harm,
       
   120         // if theres no stored state when activating this view again
       
   121         delete iContainer;
       
   122         iContainer = NULL;
       
   123         // iControl is owned by iContainer and it is deleted too
       
   124         iControl = NULL;
       
   125         }
       
   126 
       
   127     iViewManager.DeregisterStoreAndView();
       
   128     }
       
   129 
       
   130 // --------------------------------------------------------------------------
       
   131 // CPsu2OwnNumbersView::NameListControlResourceId
       
   132 // --------------------------------------------------------------------------
       
   133 //
       
   134 TInt CPsu2OwnNumbersView::NameListControlResourceId() const
       
   135     {
       
   136     return R_PSU2_OWN_NUMBER_NAME_LIST_CONTROL;
       
   137     }
       
   138 
       
   139 // --------------------------------------------------------------------------
       
   140 // CPsu2OwnNumbersView::HandleStatusPaneSizeChange
       
   141 // --------------------------------------------------------------------------
       
   142 //
       
   143 void CPsu2OwnNumbersView::HandleStatusPaneSizeChange()
       
   144     {
       
   145     // Resize the container to fill the client rectangle
       
   146     if (iContainer)
       
   147         {
       
   148         iContainer->SetRect(iExtensionView.ClientRect());
       
   149         }
       
   150     }
       
   151 
       
   152 // --------------------------------------------------------------------------
       
   153 // CPsu2OwnNumbersView::ViewStateLC
       
   154 // --------------------------------------------------------------------------
       
   155 //
       
   156 CPbk2ViewState* CPsu2OwnNumbersView::ViewStateLC() const
       
   157     {
       
   158     CPbk2ViewState* state = NULL;
       
   159     if ( iControl )
       
   160         {
       
   161         iControl->ControlStateL();
       
   162         }
       
   163     CleanupStack::PushL( state );
       
   164     return state;
       
   165     }
       
   166 
       
   167 // --------------------------------------------------------------------------
       
   168 // CPsu2OwnNumbersView::HandleCommandKeyL
       
   169 // --------------------------------------------------------------------------
       
   170 //
       
   171 TBool CPsu2OwnNumbersView::HandleCommandKeyL(
       
   172         const TKeyEvent& aKeyEvent,
       
   173         TEventCode aType )
       
   174     {
       
   175     TBool result( EFalse );
       
   176     if( aKeyEvent.iCode == EKeyPhoneSend && aType == EEventKey  )
       
   177         {
       
   178         if ( iControl->NumberOfContacts() > 0 )
       
   179             {
       
   180             HandleCommandL(EPbk2CmdCall);
       
   181             }
       
   182         result = ETrue;
       
   183         }
       
   184     return result;
       
   185     }
       
   186 
       
   187 // --------------------------------------------------------------------------
       
   188 // CPsu2OwnNumbersView::HandlePointerEventL
       
   189 // --------------------------------------------------------------------------
       
   190 //
       
   191 void CPsu2OwnNumbersView::HandlePointerEventL(
       
   192         const TPointerEvent& /*aPointerEvent*/ )
       
   193     {
       
   194     // Do nothing
       
   195     }
       
   196 
       
   197 // --------------------------------------------------------------------------
       
   198 // CPsu2OwnNumbersView::GetViewSpecificMenuFilteringFlagsL
       
   199 // --------------------------------------------------------------------------
       
   200 //
       
   201 TInt CPsu2OwnNumbersView::GetViewSpecificMenuFilteringFlagsL() const
       
   202     {
       
   203     return KPbk2MenuFilteringFlagsNone;
       
   204     }
       
   205 
       
   206 // --------------------------------------------------------------------------
       
   207 // CPsu2OwnNumbersView::HandleCommandL
       
   208 // --------------------------------------------------------------------------
       
   209 //
       
   210 void CPsu2OwnNumbersView::HandleCommandL(TInt aCommand)
       
   211     {
       
   212     if ( iControl )
       
   213         {
       
   214         // No command handling in this class, forward to Commands
       
   215         if ( !Phonebook2::Pbk2AppUi()->ApplicationServices().
       
   216               CommandHandlerL()->HandleCommandL
       
   217                 (aCommand, *iControl, &iExtensionView))
       
   218             {
       
   219             iControl->ProcessCommandL(aCommand);
       
   220             Phonebook2::Pbk2AppUi()->HandleCommandL(aCommand);
       
   221             // Update cbas, if command handler is consuming the command
       
   222             // postcommandexecution is updating cbas
       
   223             UpdateCbasL();
       
   224             }        
       
   225         }
       
   226     }
       
   227 
       
   228 // --------------------------------------------------------------------------
       
   229 // CPsu2OwnNumbersView::DynInitMenuPaneL
       
   230 // --------------------------------------------------------------------------
       
   231 //
       
   232 void CPsu2OwnNumbersView::DynInitMenuPaneL(TInt /*aResourceId*/,
       
   233         CEikMenuPane* /*aMenuPane*/ )
       
   234     {
       
   235     // no filtering here
       
   236     }
       
   237 
       
   238 // --------------------------------------------------------------------------
       
   239 // CPsu2OwnNumbersView::HandleLongTapEventL
       
   240 // --------------------------------------------------------------------------
       
   241 //
       
   242 void CPsu2OwnNumbersView::HandleLongTapEventL(
       
   243     const TPoint& /*aPenEventLocation*/,
       
   244     const TPoint& /*aPenEventScreenLocation*/)
       
   245     {
       
   246     // Do nothing
       
   247     }
       
   248 
       
   249 // --------------------------------------------------------------------------
       
   250 // CPsu2OwnNumbersView::CreateControlsL
       
   251 // --------------------------------------------------------------------------
       
   252 //
       
   253 void CPsu2OwnNumbersView::CreateControlsL()
       
   254     {
       
   255     if ( !iContainer )
       
   256         {
       
   257         // Create the container and control
       
   258         CContainer* container = CContainer::NewLC
       
   259             ( &iExtensionView, &iExtensionView, iExtensionView );
       
   260 
       
   261         container->SetHelpContext(
       
   262             TCoeHelpContext( iExtensionView.ApplicationUid(),
       
   263                              KPHOB_HLP_MY_NUMBERS ));
       
   264 
       
   265         CPsu2OwnNumberControl* control = CPsu2OwnNumberControl::NewL
       
   266             ( iViewManager.CurrentSimView(), container );
       
   267         CleanupStack::PushL(control);
       
   268 
       
   269         // takes ownership of the control
       
   270         container->SetControl( control, iExtensionView.ClientRect() );
       
   271         CleanupStack::Pop(control);
       
   272 
       
   273         CCoeEnv::Static()->AppUi()->AddToStackL(iExtensionView, container);
       
   274         CleanupStack::Pop(container);
       
   275         iContainer = container;
       
   276         iControl = control;
       
   277         }
       
   278 
       
   279     }
       
   280 // --------------------------------------------------------------------------
       
   281 // CPsu2OwnNumbersView::UpdateCbasL
       
   282 // --------------------------------------------------------------------------
       
   283 //
       
   284 void CPsu2OwnNumbersView::UpdateCbasL()
       
   285     {
       
   286     // Set middle softkey as empty
       
   287     iExtensionView.Cba()->SetCommandSetL
       
   288         ( R_PSU_OWN_SOFTKEYS_OPTIONS_BACK_EMPTY );
       
   289     iExtensionView.Cba()->DrawDeferred();
       
   290     }
       
   291 
       
   292 ///  End of File