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