locsrv_plat/map_image_api/tsrc/testprovider/src/testproviderappserver.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:  Implementation of CTestProviderAppServer
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <mnappserviceuids.hrh>
       
    20 #include "debug.h"
       
    21 
       
    22 #include <e32property.h>
       
    23 #include <lbsposition.h>
       
    24 #include <epos_cposlandmark.h>
       
    25 
       
    26 #include "testprovidergeocodingservice.h"
       
    27 #include "testprovidernavigationservice.h"
       
    28 #include "testprovidermapviewservice.h"
       
    29 
       
    30 #ifdef RD_MAPNAV_BITMAP_ACCESS
       
    31 #include "testprovidermapimageservice.h"
       
    32 #endif
       
    33 
       
    34 #include "testproviderappui.h"
       
    35 #include "testproviderappserver.h"
       
    36 
       
    37 #include "testproviderdump.h"
       
    38 
       
    39 // ============================ MEMBER FUNCTIONS ===============================
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 CTestProviderAppServer::~CTestProviderAppServer()
       
    45     {
       
    46     if ( iListener )
       
    47         {
       
    48         iListener->Cancel();
       
    49         delete iListener;
       
    50         }
       
    51 
       
    52     LOG("server destroyed");
       
    53     }
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 void CTestProviderAppServer::ConstructL( const TDesC& aFixedServerName )
       
    59     {
       
    60     CAknAppServer::ConstructL( aFixedServerName );
       
    61     
       
    62     iListener = new (ELeave) CTestCommandListener( TCallBack( TestCommandCallback, this ) );
       
    63     iListener->Start();
       
    64     }
       
    65 
       
    66 // ---------------------------------------------------------------------------
       
    67 // ---------------------------------------------------------------------------
       
    68 //
       
    69 TInt CTestProviderAppServer::TestCommandCallback( TAny* aPtr )
       
    70     {
       
    71     CTestProviderAppServer* self =    
       
    72         static_cast<CTestProviderAppServer*> ( aPtr );
       
    73         
       
    74     TRAP_IGNORE( self->HandleTestCommandL() );
       
    75     return EFalse;
       
    76     }
       
    77 
       
    78 // ---------------------------------------------------------------------------
       
    79 // ---------------------------------------------------------------------------
       
    80 //
       
    81 void CTestProviderAppServer::HandleTestCommandL()
       
    82     {
       
    83     iListener->Property().Get( iTestCommand );
       
    84     LOG1("test command changed %d ", iTestCommand );
       
    85     
       
    86     if ( iTestCommand == EServerActionExit )
       
    87         {
       
    88         AppUi()->ProcessCommandL( EAknCmdExit );
       
    89         }
       
    90     else
       
    91     if ( iMapViewService )
       
    92         {
       
    93         iMapViewService->HandleTestCommandL( iTestCommand );
       
    94         }
       
    95     else 
       
    96     if ( iNavigationService )
       
    97         {
       
    98         iNavigationService->HandleTestCommandL( iTestCommand );
       
    99         }
       
   100     else 
       
   101     if ( iGeocodingService )
       
   102         {
       
   103         iGeocodingService->HandleTestCommandL( iTestCommand );
       
   104         }
       
   105     else
       
   106 #ifdef RD_MAPNAV_BITMAP_ACCESS
       
   107     if ( iMapImageService )
       
   108         {
       
   109         iMapImageService->HandleTestCommandL( iTestCommand );
       
   110         }
       
   111     else
       
   112 #endif
       
   113         {
       
   114         }
       
   115     }
       
   116 
       
   117 // -----------------------------------------------------------------------------
       
   118 // -----------------------------------------------------------------------------
       
   119 //
       
   120 EXPORT_C CApaAppServiceBase* CTestProviderAppServer::CreateServiceL(TUid aServiceType) const
       
   121     {
       
   122     RProcess process;
       
   123     RProperty property;
       
   124     
       
   125     TProcessId id = process.Id();
       
   126     TPckg<TProcessId> packId( id );
       
   127 
       
   128     property.Define( TUid::Uid( KPropCategoryUid ), KPropKeyProcessId, RProperty::EByteArray );
       
   129     property.Set( TUid::Uid( KPropCategoryUid ), KPropKeyProcessId, packId );
       
   130 
       
   131     LOG1("CreateServiceL, svcUid = %X", aServiceType.iUid);
       
   132     switch ( aServiceType.iUid )
       
   133         {
       
   134         case KMnAppGeocodingService:
       
   135             return CreateGeocodingServiceL();
       
   136             
       
   137         case KMnAppNavigationService:
       
   138             return CreateNavigationServiceL();
       
   139             
       
   140         case KMnAppMapViewService:
       
   141             return CreateMapViewServiceL();
       
   142             
       
   143 #ifdef RD_MAPNAV_BITMAP_ACCESS
       
   144         case KMnAppMapImageService:
       
   145             return CreateMapImageServiceL();
       
   146 #endif
       
   147 
       
   148         default:
       
   149             return CAknAppServer::CreateServiceL( aServiceType );
       
   150         }
       
   151     }
       
   152 
       
   153 // -----------------------------------------------------------------------------
       
   154 // -----------------------------------------------------------------------------
       
   155 //
       
   156 EXPORT_C void CTestProviderAppServer::HandleAllClientsClosed()
       
   157     {
       
   158     LOG( "HandleAllClientsClosed" );
       
   159 
       
   160     // create fresh dump to signal successful exit
       
   161     // TRAP_IGNORE( DumpEmptyL() );
       
   162     iBusy = EFalse;
       
   163     CAknAppServer::HandleAllClientsClosed();
       
   164     }
       
   165     
       
   166 // -----------------------------------------------------------------------------
       
   167 // -----------------------------------------------------------------------------
       
   168 //
       
   169 CTestProviderGeocodingService* CTestProviderAppServer::CreateGeocodingServiceL() const
       
   170     {
       
   171     LOG( "CreateGeocodingServiceL" );
       
   172     __ASSERT_DEBUG( !iGeocodingService, Panic( KErrAlreadyExists ) );
       
   173     iGeocodingService = CTestProviderGeocodingService::NewL();
       
   174     TRAP_IGNORE( DumpEmptyL() );
       
   175     iBusy = ETrue;
       
   176     return iGeocodingService;
       
   177     }
       
   178 
       
   179 // -----------------------------------------------------------------------------
       
   180 // -----------------------------------------------------------------------------
       
   181 //
       
   182 CTestProviderNavigationService* CTestProviderAppServer::CreateNavigationServiceL() const
       
   183     {
       
   184     LOG( "CreateNavigationServiceL" );
       
   185     __ASSERT_DEBUG( !iNavigationService, Panic( KErrAlreadyExists ) );
       
   186     iNavigationService = CTestProviderNavigationService::NewL();
       
   187     TRAP_IGNORE( DumpEmptyL() );
       
   188     iBusy = ETrue;
       
   189     return iNavigationService;
       
   190     }
       
   191 
       
   192 // -----------------------------------------------------------------------------
       
   193 // -----------------------------------------------------------------------------
       
   194 //
       
   195 CTestProviderMapViewService* CTestProviderAppServer::CreateMapViewServiceL() const
       
   196     {
       
   197     LOG( "CreateMapViewServiceL" );
       
   198     __ASSERT_DEBUG( !iMapViewService, Panic( KErrAlreadyExists ) );
       
   199     iMapViewService = CTestProviderMapViewService::NewL();
       
   200     TRAP_IGNORE( DumpEmptyL() );
       
   201     iBusy = ETrue;
       
   202     return iMapViewService;
       
   203     }
       
   204 
       
   205 #ifdef RD_MAPNAV_BITMAP_ACCESS
       
   206 // -----------------------------------------------------------------------------
       
   207 // -----------------------------------------------------------------------------
       
   208 //
       
   209 CTestProviderMapImageService* CTestProviderAppServer::CreateMapImageServiceL() const
       
   210     {
       
   211     LOG( "CreateMapImageServiceL" );
       
   212     __ASSERT_DEBUG( !iMapImageService, Panic( KErrAlreadyExists ) );
       
   213     iMapImageService = CTestProviderMapImageService::NewL();
       
   214     TRAP_IGNORE( DumpEmptyL() );
       
   215     iBusy = ETrue;
       
   216     return iMapImageService;
       
   217     }
       
   218 #endif
       
   219 
       
   220 // -----------------------------------------------------------------------------
       
   221 // -----------------------------------------------------------------------------
       
   222 //
       
   223 CTestProviderAppUi* CTestProviderAppServer::AppUi() const
       
   224     {
       
   225     CTestProviderAppUi* ui = (CTestProviderAppUi*) CEikonEnv::Static()->AppUi();
       
   226     if ( !ui )
       
   227         {
       
   228         LOG("UI not found!");
       
   229         }
       
   230     return ui;
       
   231     }
       
   232 
       
   233 // -----------------------------------------------------------------------------
       
   234 // -----------------------------------------------------------------------------
       
   235 //
       
   236 void CTestProviderAppServer::DumpEmptyL() const
       
   237     {
       
   238     CTestProviderDump* dump = CTestProviderDump::NewLC();
       
   239     dump->AddRunModeL( AppUi()->IsChainedMode() );
       
   240     dump->CommitL();
       
   241     CleanupStack::PopAndDestroy( dump );
       
   242     }
       
   243     
       
   244 // -----------------------------------------------------------------------------
       
   245 // -----------------------------------------------------------------------------
       
   246 //
       
   247 TBool CTestProviderAppServer::IsFree()
       
   248     {
       
   249     return !iBusy;
       
   250     }