|
1 /* |
|
2 * Copyright (c) 2005 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: This class manages the collection of protocol-specific database manager |
|
15 * implementations. |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <ecom/ecom.h> |
|
23 #include <EPos_LandmarksDbManagerUids.hrh> |
|
24 #include <EPos_LandmarksErrors.h> |
|
25 #include <EPos_CPosLmDatabaseManagerPluginBase.h> |
|
26 #include "EPos_CPosLmDbManPluginInfo.h" |
|
27 #include "EPos_CPosLmDbManPluginStore.h" |
|
28 |
|
29 // ================= LOCAL FUNCTIONS ======================== |
|
30 |
|
31 void CleanupImplInfoPointerArray(TAny* aArray) |
|
32 { |
|
33 (reinterpret_cast<RImplInfoPtrArray*>(aArray))->ResetAndDestroy(); |
|
34 } |
|
35 |
|
36 |
|
37 |
|
38 // ================= MEMBER FUNCTIONS ======================= |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // CPosLmDbManPluginStore::CPosLmDbManPluginStore |
|
42 // C++ default constructor can NOT contain any code, that |
|
43 // might leave. |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 CPosLmDbManPluginStore::CPosLmDbManPluginStore() |
|
47 { |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CPosLmDbManPluginStore::ConstructL |
|
52 // Symbian 2nd phase constructor can leave. |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 void CPosLmDbManPluginStore::ConstructL(TAny* aConstructionParams) |
|
56 { |
|
57 |
|
58 // List implementations that support this protocol |
|
59 TUid interfaceUid; |
|
60 interfaceUid.iUid = KPosLmDbManagerBaseIfUid; |
|
61 |
|
62 RImplInfoPtrArray implInfoArray; |
|
63 CleanupStack::PushL(TCleanupItem(CleanupImplInfoPointerArray, |
|
64 &implInfoArray)); |
|
65 |
|
66 REComSession::ListImplementationsL(interfaceUid, implInfoArray); |
|
67 TInt count = implInfoArray.Count(); |
|
68 |
|
69 if (count == 0) |
|
70 { |
|
71 User::Leave(KErrNotSupported); |
|
72 } |
|
73 |
|
74 for (TInt i = 0; i < count; i++) |
|
75 { |
|
76 TUid implementationUid = |
|
77 reinterpret_cast<CImplementationInformation*>(implInfoArray[i])-> |
|
78 ImplementationUid(); |
|
79 |
|
80 CPosLmDbManPluginInfo* plugin = |
|
81 CPosLmDbManPluginInfo::NewLC( |
|
82 implementationUid, aConstructionParams); |
|
83 |
|
84 iPlugins.AppendL(plugin); |
|
85 CleanupStack::Pop(plugin); |
|
86 } |
|
87 |
|
88 CleanupStack::PopAndDestroy(&implInfoArray); |
|
89 |
|
90 } |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // CPosLmDbManPluginStore::NewL |
|
94 // Two-phased constructor. |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 CPosLmDbManPluginStore* CPosLmDbManPluginStore::NewL( |
|
98 TAny* aConstructionParams) |
|
99 { |
|
100 CPosLmDbManPluginStore* self = new( ELeave ) CPosLmDbManPluginStore; |
|
101 CleanupStack::PushL(self); |
|
102 self->ConstructL(aConstructionParams); |
|
103 CleanupStack::Pop(self); |
|
104 return self; |
|
105 } |
|
106 |
|
107 // Destructor |
|
108 CPosLmDbManPluginStore::~CPosLmDbManPluginStore() |
|
109 { |
|
110 iPlugins.ResetAndDestroy(); |
|
111 } |
|
112 |
|
113 |
|
114 // --------------------------------------------------------- |
|
115 // CPosLmDbManPluginStore::GetInstanceL |
|
116 // |
|
117 // (other items were commented in a header). |
|
118 // --------------------------------------------------------- |
|
119 // |
|
120 CPosLmDatabaseManagerPluginBase* CPosLmDbManPluginStore::GetInstanceL( |
|
121 const TDesC& aProtocol) |
|
122 { |
|
123 TBool found = EFalse; |
|
124 TInt count = iPlugins.Count(); |
|
125 TInt index; |
|
126 |
|
127 for (index = 0; index < count && !found; index++) |
|
128 { |
|
129 if (aProtocol == iPlugins[index]->Instance()->Protocol()) |
|
130 { |
|
131 found = ETrue; |
|
132 } |
|
133 } |
|
134 if (!found) |
|
135 { |
|
136 User::Leave(KErrNotSupported); |
|
137 } |
|
138 return iPlugins[--index]->Instance(); |
|
139 } |
|
140 |
|
141 // --------------------------------------------------------- |
|
142 // CPosLmDbManPluginStore::NumberOfInstances |
|
143 // |
|
144 // (other items were commented in a header). |
|
145 // --------------------------------------------------------- |
|
146 // |
|
147 TInt CPosLmDbManPluginStore::NumberOfInstances() const |
|
148 { |
|
149 return iPlugins.Count(); |
|
150 } |
|
151 |
|
152 // --------------------------------------------------------- |
|
153 // CPosLmDbManPluginStore::GetInstanceAt |
|
154 // |
|
155 // (other items were commented in a header). |
|
156 // --------------------------------------------------------- |
|
157 // |
|
158 CPosLmDatabaseManagerPluginBase* CPosLmDbManPluginStore::GetInstanceAt( |
|
159 TInt aIndex) |
|
160 { |
|
161 return iPlugins[aIndex]->Instance(); |
|
162 } |
|
163 |
|
164 |
|
165 // End of File |