locationmapnavfw/aiwprovider/src/mnfetchaddresshandler.cpp
branchRCL_3
changeset 44 2b4ea9893b66
parent 42 02ba3f1733c6
child 45 6b6920c56e2f
equal deleted inserted replaced
42:02ba3f1733c6 44:2b4ea9893b66
     1 /*
       
     2 * Copyright (c) 2005-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:  CMnFetchAddressHandler class implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <e32base.h>
       
    20 
       
    21 #include <AiwGenericParam.hrh>
       
    22 #include <AiwCommon.hrh>
       
    23 
       
    24 #include <EPos_CPosLandmark.h>
       
    25 #include <epos_poslandmarkserialization.h>
       
    26 
       
    27 #include <mngeocoder.h>
       
    28 
       
    29 #include "mnaiwdebug.h"
       
    30 #include "mnaiwinternal.h"
       
    31 #include "mnfetchaddresshandler.h"
       
    32 
       
    33 // ================= LOCAL FUNCTIONS =======================
       
    34 
       
    35 // ================= MEMBER FUNCTIONS =======================
       
    36 
       
    37 // -----------------------------------------------------------------------------
       
    38 // -----------------------------------------------------------------------------
       
    39 //
       
    40 CMnFetchAddressHandler::CMnFetchAddressHandler( CMnProvider& aProvider )
       
    41 :   CMnGeocodingCmdHandlerBase( aProvider )
       
    42     {
       
    43     }
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48 CMnFetchAddressHandler* CMnFetchAddressHandler::NewL( 
       
    49     CMnProvider& aProvider,
       
    50     TRunMode aRunMode )
       
    51     {
       
    52     CMnFetchAddressHandler* self = 
       
    53         new (ELeave) CMnFetchAddressHandler( aProvider );
       
    54     CleanupStack::PushL( self );        
       
    55     self->ConstructL( aRunMode );
       
    56     CleanupStack::Pop( self );        
       
    57     return self;
       
    58     }
       
    59 
       
    60 // -----------------------------------------------------------------------------
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 void CMnFetchAddressHandler::ConstructL( TRunMode aRunMode )
       
    64     {
       
    65     LOG("CMnFetchAddressHandler::ConstructL in");
       
    66 
       
    67     CMnGeocodingCmdHandlerBase::ConstructL( aRunMode );
       
    68 
       
    69     LOG("CMnFetchAddressHandler::ConstructL out");
       
    70     }
       
    71 
       
    72 // ================= INTERNAL FUNCTIONS =======================
       
    73 
       
    74 // -----------------------------------------------------------------------------
       
    75 //  From class CMnAiwCommandHandlerBase
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 void CMnFetchAddressHandler::DoStartL()
       
    79     {
       
    80     LOG("CMnFetchAddressHandler::DoStartL in");
       
    81     
       
    82     if ( iLandmarkData.Size() )
       
    83         {
       
    84         CPosLandmark* lm = PosLandmarkSerialization::UnpackL( iLandmarkData );
       
    85         CleanupStack::PushL( lm );
       
    86 
       
    87         Geocoder().FindAddressByCoordinateL( *lm, iStatus );
       
    88         
       
    89         CleanupStack::PopAndDestroy( lm );
       
    90         }
       
    91     else    
       
    92         {
       
    93         User::Leave( KErrArgument );
       
    94         }
       
    95 
       
    96     LOG("CMnFetchAddressHandler::DoStartL out");
       
    97     }
       
    98 
       
    99 // -----------------------------------------------------------------------------
       
   100 //  From class CActive
       
   101 // -----------------------------------------------------------------------------
       
   102 //
       
   103 void CMnFetchAddressHandler::RunL()
       
   104     {
       
   105     LOG("CMnFetchAddressHandler::RunL in");
       
   106     
       
   107     TInt result = iStatus.Int();
       
   108     if ( result == KErrNone )
       
   109         {
       
   110         CPosLandmark* lm = CPosLandmark::NewLC();
       
   111         Geocoder().RetrieveGeocodingResultL( *lm );
       
   112         WriteLandmarkL( *lm );
       
   113         CleanupStack::PopAndDestroy( lm );
       
   114         }
       
   115     Done( result );
       
   116     LOG("CMnFetchAddressHandler::RunL out");
       
   117     }
       
   118 
       
   119 // -----------------------------------------------------------------------------
       
   120 //  From class CActive
       
   121 // -----------------------------------------------------------------------------
       
   122 //
       
   123 void CMnFetchAddressHandler::DoCancel()
       
   124     {
       
   125     Geocoder().Cancel();
       
   126     }