author | William Roberts <williamr@symbian.org> |
Tue, 16 Mar 2010 16:12:26 +0000 | |
branch | Symbian2 |
changeset 2 | 2fe1408b6811 |
permissions | -rw-r--r-- |
williamr@2 | 1 |
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
williamr@2 | 2 |
// All rights reserved. |
williamr@2 | 3 |
// This component and the accompanying materials are made available |
williamr@2 | 4 |
// under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members |
williamr@2 | 5 |
// which accompanies this distribution, and is available |
williamr@2 | 6 |
// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". |
williamr@2 | 7 |
// |
williamr@2 | 8 |
// Initial Contributors: |
williamr@2 | 9 |
// Nokia Corporation - initial contribution. |
williamr@2 | 10 |
// |
williamr@2 | 11 |
// Contributors: |
williamr@2 | 12 |
// |
williamr@2 | 13 |
// Description: |
williamr@2 | 14 |
// |
williamr@2 | 15 |
|
williamr@2 | 16 |
#include <ecom/ecom.h> |
williamr@2 | 17 |
|
williamr@2 | 18 |
const TUid KUidImMobilityPolicy = {0x10283066}; |
williamr@2 | 19 |
|
williamr@2 | 20 |
/** |
williamr@2 | 21 |
CleanUpEComSmsInfoArray function for cleanup support of locally declared arrays. |
williamr@2 | 22 |
*/ |
williamr@2 | 23 |
void CleanUpEComInfoArray(TAny* aInfoArray) |
williamr@2 | 24 |
{ |
williamr@2 | 25 |
RImplInfoPtrArray* infoArray = (static_cast<RImplInfoPtrArray*>(aInfoArray)); |
williamr@2 | 26 |
infoArray->ResetAndDestroy(); |
williamr@2 | 27 |
infoArray->Close(); |
williamr@2 | 28 |
} |
williamr@2 | 29 |
|
williamr@2 | 30 |
/** |
williamr@2 | 31 |
Static factory constructor. |
williamr@2 | 32 |
|
williamr@2 | 33 |
@return The constructed CImMobilityPolicyPlugin object |
williamr@2 | 34 |
*/ |
williamr@2 | 35 |
inline CImMobilityPolicyPlugin* CImMobilityPolicyPlugin::NewL() |
williamr@2 | 36 |
{ |
williamr@2 | 37 |
RImplInfoPtrArray implInfoArray; |
williamr@2 | 38 |
TCleanupItem cleanup(CleanUpEComInfoArray, &implInfoArray); |
williamr@2 | 39 |
CleanupStack::PushL(cleanup); |
williamr@2 | 40 |
|
williamr@2 | 41 |
// get all implementations of the mobility policy plugin interface |
williamr@2 | 42 |
REComSession::ListImplementationsL(KUidImMobilityPolicy, implInfoArray); |
williamr@2 | 43 |
TInt count = implInfoArray.Count(); |
williamr@2 | 44 |
|
williamr@2 | 45 |
if (count == 0) |
williamr@2 | 46 |
{ |
williamr@2 | 47 |
implInfoArray.ResetAndDestroy(); |
williamr@2 | 48 |
implInfoArray.Close(); |
williamr@2 | 49 |
CleanupStack::PopAndDestroy(&implInfoArray); |
williamr@2 | 50 |
User::Leave(KErrNotFound); |
williamr@2 | 51 |
} |
williamr@2 | 52 |
|
williamr@2 | 53 |
CImMobilityPolicyPlugin* interface = NULL; |
williamr@2 | 54 |
|
williamr@2 | 55 |
for (TInt impl = 0; impl < count; ++impl) |
williamr@2 | 56 |
{ |
williamr@2 | 57 |
if (implInfoArray[impl]->VendorId() != 0x70000001) |
williamr@2 | 58 |
{ |
williamr@2 | 59 |
interface = REINTERPRET_CAST( |
williamr@2 | 60 |
CImMobilityPolicyPlugin*, |
williamr@2 | 61 |
REComSession::CreateImplementationL( |
williamr@2 | 62 |
implInfoArray[impl]->ImplementationUid(), |
williamr@2 | 63 |
_FOFF(CImMobilityPolicyPlugin, iDtor_ID_Key))); |
williamr@2 | 64 |
} |
williamr@2 | 65 |
} |
williamr@2 | 66 |
|
williamr@2 | 67 |
if (!interface) |
williamr@2 | 68 |
{ |
williamr@2 | 69 |
interface = REINTERPRET_CAST( |
williamr@2 | 70 |
CImMobilityPolicyPlugin*, |
williamr@2 | 71 |
REComSession::CreateImplementationL( |
williamr@2 | 72 |
implInfoArray[0]->ImplementationUid(), |
williamr@2 | 73 |
_FOFF(CImMobilityPolicyPlugin, iDtor_ID_Key))); |
williamr@2 | 74 |
} |
williamr@2 | 75 |
|
williamr@2 | 76 |
implInfoArray.ResetAndDestroy(); |
williamr@2 | 77 |
implInfoArray.Close(); |
williamr@2 | 78 |
CleanupStack::PopAndDestroy(&implInfoArray); |
williamr@2 | 79 |
return interface; |
williamr@2 | 80 |
} |
williamr@2 | 81 |
|
williamr@2 | 82 |
/** |
williamr@2 | 83 |
Class constructor. |
williamr@2 | 84 |
*/ |
williamr@2 | 85 |
inline CImMobilityPolicyPlugin::CImMobilityPolicyPlugin() |
williamr@2 | 86 |
{ |
williamr@2 | 87 |
} |
williamr@2 | 88 |
|
williamr@2 | 89 |
/** |
williamr@2 | 90 |
Class destructor. |
williamr@2 | 91 |
Destroy the ECOM implementation |
williamr@2 | 92 |
*/ |
williamr@2 | 93 |
inline CImMobilityPolicyPlugin::~CImMobilityPolicyPlugin() |
williamr@2 | 94 |
{ |
williamr@2 | 95 |
REComSession::DestroyedImplementation(iDtor_ID_Key); |
williamr@2 | 96 |
} |
williamr@2 | 97 |
|
williamr@2 | 98 |
|
williamr@2 | 99 |
|
williamr@2 | 100 |
|
williamr@2 | 101 |