|
1 /* |
|
2 * Copyright (c) 2010 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 Geo coding interface class. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "posreversegeocodeinterface.h" |
|
19 #include "posreversegeocodeinterface.hrh" |
|
20 |
|
21 #include <ecom.h> |
|
22 |
|
23 // static cleanup function |
|
24 static void RImpleInfoPtrArrayCleanup( TAny* aArray ) |
|
25 { |
|
26 static_cast<RImplInfoPtrArray*>( aArray )->ResetAndDestroy(); |
|
27 } |
|
28 |
|
29 |
|
30 //------------------------------------------------------------------------------ |
|
31 // CPosReverseGeocodeInterface::NewL |
|
32 //------------------------------------------------------------------------------ |
|
33 EXPORT_C CPosReverseGeocodeInterface* CPosReverseGeocodeInterface::NewL( |
|
34 MPosReverseGeocodeObserver& aObserver ) |
|
35 { |
|
36 RImplInfoPtrArray implInfoPtrArray; |
|
37 TCleanupItem arrayCleanup( RImpleInfoPtrArrayCleanup, &implInfoPtrArray ); |
|
38 CleanupStack::PushL(arrayCleanup); |
|
39 |
|
40 TUid implementationUID; |
|
41 |
|
42 REComSession::ListImplementationsL( TUid::Uid(KPosReverseGeoCodeInterfaceId), |
|
43 implInfoPtrArray ); |
|
44 |
|
45 if( implInfoPtrArray.Count() == 0 ) |
|
46 { |
|
47 implInfoPtrArray.ResetAndDestroy(); |
|
48 User::Leave( KErrNotFound ); |
|
49 } |
|
50 |
|
51 const CImplementationInformation* pluginInformation = implInfoPtrArray[0]; |
|
52 implementationUID = pluginInformation->ImplementationUid(); |
|
53 |
|
54 TAny* ptr = REComSession::CreateImplementationL( implementationUID, |
|
55 _FOFF(CPosReverseGeocodeInterface,iDtor_ID_Key), |
|
56 reinterpret_cast<TAny*>( &aObserver )); |
|
57 REComSession::FinalClose(); |
|
58 CleanupStack::PopAndDestroy(); // arrayCleanup |
|
59 return reinterpret_cast<CPosReverseGeocodeInterface*>(ptr); |
|
60 } |
|
61 |
|
62 //---------------------------------------------------------------------------------- |
|
63 // CPosReverseGeocodeInterface::~CPosReverseGeocodeInterface |
|
64 //---------------------------------------------------------------------------------- |
|
65 EXPORT_C CPosReverseGeocodeInterface::~CPosReverseGeocodeInterface() |
|
66 { |
|
67 REComSession::DestroyedImplementation(iDtor_ID_Key); |
|
68 } |