locsrv_plat/map_image_api/tsrc/testprovider/src/testproviderappui.cpp
branchRCL_3
changeset 44 2b4ea9893b66
parent 42 02ba3f1733c6
child 45 6b6920c56e2f
equal deleted inserted replaced
42:02ba3f1733c6 44:2b4ea9893b66
     1 /*
       
     2 * Copyright (c) 2004-2005 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:  Implements the CTestProviderAppUi class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <aknnavi.h>
       
    20 #include <aknnavide.h>
       
    21 #include <w32std.h>
       
    22 #include <EikServerApp.h>
       
    23 
       
    24 #include "debug.h"
       
    25 
       
    26 #include "testproviderappview.h"
       
    27 #include "testprovidernaviview.h"
       
    28 #include "testprovidermapview.h"
       
    29 
       
    30 #include "testproviderappui.h"
       
    31 
       
    32 // ============================ MEMBER FUNCTIONS ===============================
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 // -----------------------------------------------------------------------------
       
    36 //
       
    37 CTestProviderAppUi::CTestProviderAppUi()
       
    38     {
       
    39     }
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 void CTestProviderAppUi::ConstructL()
       
    45     {
       
    46     BaseConstructL(EAknEnableSkin);
       
    47 
       
    48     if ( !iEikonEnv->StartedAsServerApp() )
       
    49         {
       
    50         CAknAppUi::Exit();	
       
    51         }
       
    52 /*
       
    53     CEikAppServer* server = iEikonEnv->AppServer();
       
    54     if ( server )
       
    55         {
       
    56         iShutter = new ( ELeave ) CShutter( *server );
       
    57         iShutter->ConstructL();
       
    58         
       
    59         const TTimeIntervalMicroSeconds32 KShutdownDelay = 2 * 1000 * 1000;
       
    60         iShutter->Go();After( KShutdownDelay );
       
    61         }
       
    62 */        
       
    63     }
       
    64 
       
    65 // -----------------------------------------------------------------------------
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 CTestProviderAppUi::~CTestProviderAppUi()
       
    69     {
       
    70     delete iNaviLabel;
       
    71     
       
    72     delete iAppView;
       
    73     if ( iNaviView )
       
    74         {
       
    75         RemoveFromStack( iNaviView );
       
    76         }
       
    77     delete iNaviView;
       
    78     if ( iMapView )
       
    79         {
       
    80         RemoveFromStack( iMapView );
       
    81         }
       
    82     delete iMapView;
       
    83 /*
       
    84     if ( iShutter )
       
    85         {
       
    86         iShutter->Cancel();
       
    87         delete iShutter;
       
    88         }
       
    89 */        
       
    90     LOG("application destroyed");
       
    91     }
       
    92 
       
    93 // -----------------------------------------------------------------------------
       
    94 // -----------------------------------------------------------------------------
       
    95 //
       
    96 void CTestProviderAppUi::HandleCommandL( TInt aCommand )
       
    97     {
       
    98     switch(aCommand)
       
    99         {
       
   100         case EAknSoftkeyBack:
       
   101             {
       
   102     	    Exit( EEikCmdExit ); 
       
   103         	break;
       
   104             }
       
   105             
       
   106         case EEikCmdExit:
       
   107         case EAknSoftkeyExit:
       
   108             {
       
   109             Exit( EAknCmdExit ); // this will close client also
       
   110         	break;
       
   111             }
       
   112         default:
       
   113             break;
       
   114         }
       
   115     }
       
   116 
       
   117 // -----------------------------------------------------------------------------
       
   118 // -----------------------------------------------------------------------------
       
   119 //
       
   120 void CTestProviderAppUi::Exit( TInt aReason )
       
   121     {
       
   122     CEikAppServer* server = iEikonEnv->AppServer();
       
   123     if ( server )
       
   124     	{
       
   125         server->NotifyServerExit( aReason );
       
   126     	}
       
   127     CAknAppUi::Exit();	
       
   128     }
       
   129 
       
   130 // -----------------------------------------------------------------------------
       
   131 // -----------------------------------------------------------------------------
       
   132 //
       
   133 TBool CTestProviderAppUi::ProcessCommandParametersL( CApaCommandLine &aCommandLine )
       
   134     {
       
   135     iParentWg = aCommandLine.ParentWindowGroupID();
       
   136     LOG1("parent window group id %d", iParentWg );
       
   137     
       
   138     return CAknAppUi::ProcessCommandParametersL( aCommandLine );
       
   139     }
       
   140 
       
   141 // -----------------------------------------------------------------------------
       
   142 // -----------------------------------------------------------------------------
       
   143 //
       
   144 void CTestProviderAppUi::DynInitMenuPaneL(TInt /*aResourceId*/, CEikMenuPane* /*aMenuPane*/)
       
   145     {
       
   146     }
       
   147 
       
   148 // -----------------------------------------------------------------------------
       
   149 // -----------------------------------------------------------------------------
       
   150 //
       
   151 void CTestProviderAppUi::PostConstructL()
       
   152     {
       
   153 /*
       
   154     // Create TestProvider view
       
   155     CTestProviderAppView* TestProviderAppView = CTestProviderAppView::NewLC();
       
   156     AddViewL(TestProviderView); // Transfer ownership to base class
       
   157     CleanupStack::Pop(TestProviderView);
       
   158 
       
   159     // Activate TestProvider view
       
   160     TestProviderView->ActivateViewL(TestProviderView->ViewId());
       
   161 */
       
   162     }
       
   163 
       
   164 // -----------------------------------------------------------------------------
       
   165 // -----------------------------------------------------------------------------
       
   166 //
       
   167 CTestProviderNaviView& CTestProviderAppUi::ShowNaviViewL()
       
   168     {
       
   169     if ( !iNaviView )
       
   170         {
       
   171         _LIT( KNavigation, "Navigation" );
       
   172         SetNaviPaneTitleL( KNavigation );
       
   173         
       
   174         iNaviView = CTestProviderNaviView::NewL( ClientRect() );
       
   175         AddToStackL( iNaviView );
       
   176         }
       
   177     return *iNaviView;    
       
   178     }
       
   179 
       
   180 // -----------------------------------------------------------------------------
       
   181 // -----------------------------------------------------------------------------
       
   182 //
       
   183 CTestProviderMapView& CTestProviderAppUi::ShowMapViewL()
       
   184     {
       
   185     if ( !iMapView )
       
   186         {
       
   187         _LIT( KMapView, "MapView" );
       
   188         SetNaviPaneTitleL( KMapView );
       
   189         
       
   190         iMapView = CTestProviderMapView::NewL( ClientRect() );
       
   191         AddToStackL( iMapView );
       
   192         }
       
   193     return *iMapView;
       
   194     }
       
   195 
       
   196 // -----------------------------------------------------------------------------
       
   197 // -----------------------------------------------------------------------------
       
   198 //
       
   199 TBool CTestProviderAppUi::IsChainedMode()
       
   200     {
       
   201     return ( iParentWg != 0 );
       
   202     }
       
   203 
       
   204 // -----------------------------------------------------------------------------
       
   205 // -----------------------------------------------------------------------------
       
   206 //
       
   207 TBool CTestProviderAppUi::IsAnyViewOpen()
       
   208     {
       
   209     return iMapView || iNaviView;
       
   210     }
       
   211 
       
   212 // ----------------------------------------------------------------------------
       
   213 // ----------------------------------------------------------------------------
       
   214 //
       
   215 CEikStatusPane* CTestProviderAppUi::StatusPane()
       
   216     {
       
   217     return CEikonEnv::Static()->AppUiFactory()->StatusPane();
       
   218     }
       
   219     
       
   220 // ----------------------------------------------------------------------------
       
   221 // ----------------------------------------------------------------------------
       
   222 //
       
   223 void CTestProviderAppUi::SetNaviPaneTitleL( const TDesC& aPaneTitle )
       
   224     {
       
   225     if ( !iNaviPane )
       
   226         {
       
   227         iNaviPane = static_cast<CAknNavigationControlContainer*>(
       
   228                 StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) );
       
   229         }
       
   230 
       
   231     if ( iNaviLabel )
       
   232         {
       
   233         CAknNavigationDecorator* naviLabel = iNaviPane->CreateNavigationLabelL( aPaneTitle );
       
   234         CleanupStack::PushL( naviLabel );
       
   235 
       
   236         iNaviPane->ReplaceL( *iNaviLabel, *naviLabel );
       
   237 
       
   238         delete iNaviLabel;
       
   239         iNaviLabel = naviLabel;
       
   240 
       
   241         CleanupStack::Pop( naviLabel );
       
   242         }
       
   243     else
       
   244         {
       
   245         iNaviLabel = iNaviPane->CreateNavigationLabelL( aPaneTitle );
       
   246         iNaviPane->PushL( *iNaviLabel );
       
   247         }
       
   248     }    
       
   249 /*
       
   250 // -----------------------------------------------------------------------------
       
   251 // -----------------------------------------------------------------------------
       
   252 //
       
   253 CTestProviderAppUi::CShutter::CShutter( CTestProviderAppServer& aServer ) 
       
   254 : CTimer( CActive::EPriorityIdle ),
       
   255   iServer( aServer )
       
   256     {
       
   257     CActiveScheduler::Add( this );
       
   258     }
       
   259 
       
   260 // -----------------------------------------------------------------------------
       
   261 // -----------------------------------------------------------------------------
       
   262 //
       
   263 void CTestProviderAppUi::CShutter::ConstructL()
       
   264     {
       
   265     CTimer::ConstructL();
       
   266     }
       
   267 
       
   268 // -----------------------------------------------------------------------------
       
   269 // -----------------------------------------------------------------------------
       
   270 //
       
   271 void CTestProviderAppUi::CShutter::RunL()
       
   272     {
       
   273     if ( iServer.IsFree() )
       
   274         {
       
   275         iAppUi.Exit( EAknCmdExit );
       
   276         }
       
   277     else
       
   278         {
       
   279         Go();
       
   280         }
       
   281     }
       
   282 
       
   283 // -----------------------------------------------------------------------------
       
   284 // -----------------------------------------------------------------------------
       
   285 //
       
   286 void CTestProviderAppUi::CShutter::Go()
       
   287     {
       
   288     const TTimeIntervalMicroSeconds32 KShutdownDelay = 2 * 1000 * 1000;
       
   289     iShutter->After( KShutdownDelay );
       
   290     }
       
   291 */