|
1 /* |
|
2 * Copyright (c) 2005-2009 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 * Version : %version: 1.1.2.2.7 % |
|
12 * |
|
13 * Contributors: |
|
14 * |
|
15 * Description: |
|
16 * Loads/unloads plugins and handles messaging between plugins and server class. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <e32std.h> // User:: ( User class declaration ) |
|
23 #include <btaccPluginUid.h> |
|
24 #include "btaccTypes.h" |
|
25 #include "basrvpluginman.h" |
|
26 #include "btaccObserver.h" |
|
27 #include "btaccPlugin.h" // Plugin interface |
|
28 #include "debug.h" |
|
29 #include "btaccParams.h" // T-class consisting of parameteres sent to plugins |
|
30 #include "utils.h" |
|
31 |
|
32 // CONSTANTS |
|
33 |
|
34 // ================= MEMBER FUNCTIONS ======================= |
|
35 |
|
36 // --------------------------------------------------------- |
|
37 // NewL |
|
38 // --------------------------------------------------------- |
|
39 // |
|
40 CBasrvPluginMan* CBasrvPluginMan::NewL() |
|
41 { |
|
42 CBasrvPluginMan* self=new(ELeave) CBasrvPluginMan(); |
|
43 return self; |
|
44 } |
|
45 |
|
46 // Destructor |
|
47 CBasrvPluginMan::~CBasrvPluginMan() |
|
48 { |
|
49 TRACE_FUNC |
|
50 UnloadPlugins(); |
|
51 iPlugins.Close(); |
|
52 } |
|
53 |
|
54 void CBasrvPluginMan::AccInUse() |
|
55 { |
|
56 TRACE_FUNC |
|
57 TInt count = iPlugins.Count(); |
|
58 for (TInt i = 0; i < count; i++) |
|
59 { |
|
60 iPlugins[i]->AccInUse(); |
|
61 } |
|
62 } |
|
63 |
|
64 void CBasrvPluginMan::AccOutOfUse() |
|
65 { |
|
66 TRACE_FUNC |
|
67 TInt count = iPlugins.Count(); |
|
68 for (TInt i = 0; i < count; i++) |
|
69 { |
|
70 iPlugins[i]->AccOutOfUse(); |
|
71 } |
|
72 } |
|
73 |
|
74 TInt CBasrvPluginMan::AvailablePlugins() |
|
75 { |
|
76 TInt avai = 0; |
|
77 TInt count = iPlugins.Count(); |
|
78 for (TInt i = 0; i < count; i++) |
|
79 { |
|
80 avai |= iPlugins[i]->PluginType(); |
|
81 } |
|
82 return avai; |
|
83 } |
|
84 |
|
85 void CBasrvPluginMan::LoadPluginsL(MBTAccObserver& aObserver) |
|
86 { |
|
87 TRACE_FUNC |
|
88 if (iPlugins.Count()) |
|
89 { |
|
90 return; |
|
91 } |
|
92 const TUid KUidBTAccPluginInterface = TUid::Uid(KBTAccPluginInterfaceUid); |
|
93 RImplInfoPtrArray implementations; |
|
94 const TEComResolverParams noResolverParams; |
|
95 REComSession::ListImplementationsL(KUidBTAccPluginInterface, |
|
96 noResolverParams, |
|
97 KRomOnlyResolverUid, |
|
98 implementations); |
|
99 CleanupResetDestroyClosePushL(implementations); |
|
100 const TUint count = implementations.Count(); |
|
101 |
|
102 TRACE_INFO((_L("number of implementations of plugin interface: %d"), count)) |
|
103 CBTAccPlugin* plugin( NULL ); |
|
104 TInt err; |
|
105 for (TUint i = 0 ; i < count; ++i) |
|
106 { |
|
107 CImplementationInformation* impl = implementations[i]; |
|
108 TPluginParams params(impl->ImplementationUid(), aObserver); |
|
109 // If loading a plugin failed, |
|
110 // the consequence is the service provided by this plugin is not available. |
|
111 // Other services that have been successfully loaded are still usable. |
|
112 TRAP( err, plugin = CBTAccPlugin::NewL(params) ); |
|
113 if ( !err ) |
|
114 { |
|
115 CleanupStack::PushL(plugin); |
|
116 iPlugins.AppendL(plugin); |
|
117 CleanupStack::Pop(plugin); |
|
118 } |
|
119 TRACE_INFO((_L("Load plugin \'%S\', err %d"), &(impl->DisplayName()), err ) ); |
|
120 } |
|
121 |
|
122 CleanupStack::PopAndDestroy(&implementations); |
|
123 if (!iPlugins.Count()) |
|
124 { |
|
125 LEAVE(KErrNotFound); |
|
126 } |
|
127 } |
|
128 |
|
129 // --------------------------------------------------------- |
|
130 // CBasrvPluginMan::UnloadPlugins |
|
131 // --------------------------------------------------------- |
|
132 // |
|
133 void CBasrvPluginMan::UnloadPlugins() |
|
134 { |
|
135 TRACE_FUNC |
|
136 iPlugins.ResetAndDestroy(); |
|
137 REComSession::FinalClose(); |
|
138 } |
|
139 |
|
140 CBTAccPlugin* CBasrvPluginMan::Plugin(TProfiles aProfile) |
|
141 { |
|
142 TInt count = iPlugins.Count(); |
|
143 for (TInt i = 0; i < count; i++) |
|
144 { |
|
145 if (iPlugins[i]->PluginType() & aProfile) |
|
146 { |
|
147 return iPlugins[i]; |
|
148 } |
|
149 } |
|
150 return NULL; |
|
151 } |
|
152 |
|
153 TInt CBasrvPluginMan::AudioLinkLatency() |
|
154 { |
|
155 TRACE_FUNC |
|
156 CBTAccPlugin* plugin = Plugin(EAnyMonoAudioProfiles); |
|
157 |
|
158 if (plugin) |
|
159 { |
|
160 return plugin->AudioLinkLatency(); |
|
161 } |
|
162 else |
|
163 { |
|
164 return 0; |
|
165 } |
|
166 } |
|
167 |
|
168 CBasrvPluginMan::CBasrvPluginMan() |
|
169 { |
|
170 } |
|
171 |
|
172 // End of file |