eventsui/eventsmgmtui/src/evtmgmtuimapnavigationadapter.cpp
branchRCL_3
changeset 17 1fc85118c3ae
parent 16 8173571d354e
child 18 870918037e16
equal deleted inserted replaced
16:8173571d354e 17:1fc85118c3ae
     1 /*
       
     2 * Copyright (c) 2006 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:  Applications interface class to map and navigation use cases
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <epos_poslandmarkserialization.h>
       
    21 #include <EPos_CPosLandmark.h>
       
    22 #include <AiwGenericParam.h>
       
    23 #include <eikenv.h>
       
    24 #include <StringLoader.h>
       
    25 #include <evtmgmtui.rsg>
       
    26 #include <AiwServiceHandler.h>
       
    27 #include <AiwCommon.h> 
       
    28 #include <mnaiwservices.h>
       
    29 #include <mnmapview.h>
       
    30 #include <mnprovider.h>
       
    31 #include <mnproviderfinder.h>
       
    32 
       
    33 #include "evtdebug.h"
       
    34 #include "evtmgmtuimapnavigationadapter.h"
       
    35 
       
    36 // ============================ MEMBER FUNCTIONS ===============================
       
    37 
       
    38 // -----------------------------------------------------------------------------
       
    39 // CEvtMgmtUiMapNavigationAdapter::CLmkMapNavigationInterface
       
    40 // C++ default constructor can NOT contain any code, that
       
    41 // might leave.
       
    42 // -----------------------------------------------------------------------------
       
    43 CEvtMgmtUiMapNavigationAdapter::CEvtMgmtUiMapNavigationAdapter()
       
    44 	{	
       
    45 	}
       
    46 
       
    47 // -----------------------------------------------------------------------------
       
    48 // CEvtMgmtUiMapNavigationAdapter::ConstructL
       
    49 // Symbian 2nd phase constructor can leave.
       
    50 // -----------------------------------------------------------------------------
       
    51 void CEvtMgmtUiMapNavigationAdapter::ConstructL()
       
    52 	{
       
    53 	iAiwServiceHandler = CAiwServiceHandler::NewL();
       
    54 	iInList = CAiwGenericParamList::NewL();
       
    55     iOutList = CAiwGenericParamList::NewL();  
       
    56 	}
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // CEvtMgmtUiMapNavigationAdapter::NewL
       
    60 // Symbian 1st phase constructor can leave.
       
    61 // -----------------------------------------------------------------------------
       
    62 CEvtMgmtUiMapNavigationAdapter* CEvtMgmtUiMapNavigationAdapter::NewL()
       
    63 	{	
       
    64 	CEvtMgmtUiMapNavigationAdapter* self = new (ELeave) CEvtMgmtUiMapNavigationAdapter();
       
    65 	CleanupStack::PushL( self );
       
    66 	self->ConstructL();
       
    67 	CleanupStack::Pop();//self
       
    68 	return self;
       
    69 	}
       
    70 	
       
    71 // -----------------------------------------------------------------------------
       
    72 // CEvtMgmtUiMapNavigationAdapter::NewLC
       
    73 // Symbian 1st phase constructor can leave.
       
    74 // -----------------------------------------------------------------------------
       
    75 CEvtMgmtUiMapNavigationAdapter* CEvtMgmtUiMapNavigationAdapter::NewLC()
       
    76     {   
       
    77     CEvtMgmtUiMapNavigationAdapter* self = new (ELeave) CEvtMgmtUiMapNavigationAdapter();
       
    78     CleanupStack::PushL( self );
       
    79     self->ConstructL();
       
    80     CleanupStack::Pop();//self
       
    81     return self;
       
    82     }
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // CEvtMgmtUiMapNavigationAdapter::~CEvtMgmtUiMapNavigationAdapter
       
    86 // C++ Destructor
       
    87 // -----------------------------------------------------------------------------
       
    88  CEvtMgmtUiMapNavigationAdapter::~CEvtMgmtUiMapNavigationAdapter()
       
    89 	{	
       
    90 	delete iAiwServiceHandler;    
       
    91 	iAiwServiceHandler = NULL;
       
    92     delete iInList;
       
    93     iInList = NULL;
       
    94     delete iOutList;   
       
    95     iOutList = NULL;  
       
    96 	}
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 // CEvtMgmtUiMapNavigationAdapter::ShowOnMapL
       
   100 // It will show location on map
       
   101 // -----------------------------------------------------------------------------
       
   102 void CEvtMgmtUiMapNavigationAdapter::ShowOnMapL( const TCoordinate& aCoordinate )
       
   103     {
       
   104     CPosLandmark* lmk = CPosLandmark::NewLC();
       
   105     TLocality locality;
       
   106     HBufC8* lmBuf;
       
   107     
       
   108     //set location
       
   109     locality.SetCoordinate( aCoordinate.Latitude(), aCoordinate.Longitude(), aCoordinate.Altitude() );
       
   110  
       
   111     lmk->SetPositionL(locality);
       
   112     
       
   113     //set  in parameters
       
   114     iInList->Reset();
       
   115     lmBuf =PosLandmarkSerialization::PackL( *lmk );
       
   116     CleanupStack::PushL( lmBuf );
       
   117     TAiwGenericParam param( EGenericParamLandmark, TAiwVariant( *lmBuf ) );     
       
   118     iInList->AppendL( param );       
       
   119     TMnAiwCommonOptionsParam options;
       
   120     options.iRunChained = EFalse;
       
   121     TPckg<TMnAiwCommonOptionsParam> optionsPack( options );
       
   122     TAiwGenericParam optParam( EGenericParamMnCommonOptions, TAiwVariant( optionsPack ) );
       
   123     iInList->AppendL( optParam );
       
   124             
       
   125     //show location on map
       
   126     iAiwServiceHandler->AttachL( R_EVTMGMTUI_AIW_INTEREST_SHOWONMAP );
       
   127     iAiwServiceHandler->ExecuteServiceCmdL( KAiwCmdMnShowMap, *iInList, *iOutList, 0, this ); 
       
   128     
       
   129     CleanupStack::PopAndDestroy( 2 ); //lmbuf, lmk
       
   130     }
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // CEvtMgmtUiMapNavigationAdapter::NavigateToPlaceL
       
   134 // It will navigate to location
       
   135 // -----------------------------------------------------------------------------
       
   136 void CEvtMgmtUiMapNavigationAdapter::NavigateToPlaceL(  const TCoordinate& aCoordinate )
       
   137     {
       
   138     CPosLandmark* lmk = CPosLandmark::NewLC();
       
   139     TLocality locality;
       
   140     HBufC8* lmBuf;
       
   141     
       
   142     //set location
       
   143     locality.SetCoordinate( aCoordinate.Latitude(), aCoordinate.Longitude(), aCoordinate.Altitude() );
       
   144     lmk->SetPositionL(locality);
       
   145     
       
   146     //set in parameters
       
   147     iInList->Reset();
       
   148     lmBuf =PosLandmarkSerialization::PackL( *lmk );
       
   149     CleanupStack::PushL( lmBuf );
       
   150     TAiwGenericParam param( EGenericParamLandmark, TAiwVariant( *lmBuf ) );     
       
   151     iInList->AppendL( param );       
       
   152     TMnAiwCommonOptionsParam options;
       
   153     options.iRunChained = EFalse;
       
   154     TPckg<TMnAiwCommonOptionsParam> optionsPack( options );
       
   155     TAiwGenericParam optParam( EGenericParamMnCommonOptions, TAiwVariant( optionsPack ) );
       
   156     iInList->AppendL( optParam );
       
   157         
       
   158     //navigate to location
       
   159     iAiwServiceHandler->AttachL( R_EVTMGMTUI_AIW_INTEREST_NAVIGATETO );
       
   160     iAiwServiceHandler->ExecuteServiceCmdL( KAiwCmdMnNavigateTo, *iInList, *iOutList, 0, this ); 
       
   161     
       
   162     CleanupStack::PopAndDestroy( 2 ); //lmbuf, lmk
       
   163     }
       
   164         
       
   165         
       
   166 // -----------------------------------------------------------------------------
       
   167 // CEvtMgmtUiMapNavigationAdapter::MapServiceProvidersL
       
   168 // It will return total map service providers.
       
   169 // @ret total number of map service providers
       
   170 // -----------------------------------------------------------------------------
       
   171 //
       
   172 TInt CEvtMgmtUiMapNavigationAdapter::MapServiceProvidersL()
       
   173         {
       
   174         RPointerArray<CMnProvider> providers;
       
   175         // get all providers
       
   176         MnProviderFinder::FindProvidersL( providers );
       
   177         TInt total = providers.Count();
       
   178         providers.ResetAndDestroy();
       
   179         providers.Close();
       
   180         Debug(_L("Total map service providers = %d"), total);
       
   181         return total;
       
   182         }
       
   183 
       
   184 // -----------------------------------------------------------------------------
       
   185 // CEvtMgmtUiMapNavigationAdapter::HandleNotifyL
       
   186 // Derived from MAiwNotifyCallback
       
   187 // -----------------------------------------------------------------------------
       
   188  TInt CEvtMgmtUiMapNavigationAdapter::HandleNotifyL( TInt /*aCmdId*/, 
       
   189                                                         TInt /*aEventId*/, 
       
   190                                                         CAiwGenericParamList& /*aEventParamList*/,
       
   191                                                         const CAiwGenericParamList& /*aInParamList*/ )
       
   192     {
       
   193     return KErrNone;
       
   194     }
       
   195 // End of file