|
1 /* |
|
2 * Copyright (c) 2006 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: Daemon class implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <featmgr.h> |
|
20 #include <locodplugin.hrh> |
|
21 #include <locodserviceplugin.h> |
|
22 |
|
23 #include "locodserviceman.h" |
|
24 #include "locodservice.h" |
|
25 #include "debug.h" |
|
26 #include "utils.h" |
|
27 |
|
28 // ======== MEMBER FUNCTIONS ======== |
|
29 |
|
30 // --------------------------------------------------------------------------- |
|
31 // NewL |
|
32 // --------------------------------------------------------------------------- |
|
33 // |
|
34 CLocodServiceMan* CLocodServiceMan::NewL() |
|
35 { |
|
36 CLocodServiceMan* self = new (ELeave) CLocodServiceMan(); |
|
37 CleanupStack::PushL(self); |
|
38 self->ConstructL(); |
|
39 CleanupStack::Pop(self); |
|
40 return self; |
|
41 } |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // C++ destructor |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 CLocodServiceMan::~CLocodServiceMan() |
|
48 { |
|
49 Cancel(); |
|
50 iServices.ResetAndDestroy(); |
|
51 iServices.Close(); |
|
52 |
|
53 TRACE_FUNC |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 // CActive method, the request is only completed when there is no service |
|
58 // to manage, so all the service plugins are destroyed |
|
59 // --------------------------------------------------------------------------- |
|
60 // |
|
61 void CLocodServiceMan::RunL() |
|
62 { |
|
63 TRACE_FUNC_ENTRY |
|
64 if(iStatus ==KErrNone) |
|
65 { |
|
66 iServices.ResetAndDestroy(); |
|
67 } |
|
68 TRACE_FUNC_EXIT |
|
69 } |
|
70 |
|
71 // --------------------------------------------------------------------------- |
|
72 // CActive method |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 void CLocodServiceMan::DoCancel() |
|
76 { |
|
77 |
|
78 } |
|
79 |
|
80 // --------------------------------------------------------------------------- |
|
81 // CActive method |
|
82 // --------------------------------------------------------------------------- |
|
83 // |
|
84 TInt CLocodServiceMan::RunError(TInt/* aReason */) |
|
85 { |
|
86 return KErrNone; |
|
87 } |
|
88 |
|
89 |
|
90 // --------------------------------------------------------------------------- |
|
91 // NotifyBearerStatus |
|
92 // --------------------------------------------------------------------------- |
|
93 // |
|
94 void CLocodServiceMan::NotifyBearerStatus(TLocodBearer aBearer, TBool aStatus) |
|
95 { |
|
96 TRACE_INFO((_L(" [BRRST] status of 0x%04x changes to %d"), aBearer, aStatus)) |
|
97 TInt oldStatus = iBearerStatus; |
|
98 if (aStatus) |
|
99 { |
|
100 iBearerStatus |= aBearer; |
|
101 } |
|
102 else |
|
103 { |
|
104 iBearerStatus &= (~aBearer); |
|
105 } |
|
106 TRACE_INFO((_L(" [BRRST] [OLD] 0x%08x [NEW] 0x%08x"), oldStatus, iBearerStatus)) |
|
107 if (iBearerStatus && !iServices.Count()) |
|
108 { |
|
109 TRAP_IGNORE(LoadServicesL()); |
|
110 } |
|
111 TInt count = iServices.Count(); |
|
112 for (TInt i = 0; i < count; i++) |
|
113 { |
|
114 if(iBearerStatus != oldStatus) |
|
115 { |
|
116 iServices[i]->ManageService(aBearer, aStatus); |
|
117 } |
|
118 } |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------------------------- |
|
122 // Call back method from service plugins. This is called when the services has been |
|
123 // managed by the plug ins. |
|
124 // --------------------------------------------------------------------------- |
|
125 // |
|
126 void CLocodServiceMan::ManageServiceCompleted(TLocodBearer aBearer, |
|
127 TBool aStatus, TUid aServiceImplUid, TInt err) |
|
128 { |
|
129 TInt count = iServices.Count(); |
|
130 for (TInt i = 0; i < count; i++) |
|
131 { |
|
132 if (iServices[i]->Plugin().ImplementationUid() == aServiceImplUid) |
|
133 { |
|
134 iServices[i]->ManageServiceCompleted(aBearer, aStatus, err); |
|
135 break; |
|
136 } |
|
137 } |
|
138 |
|
139 if (!iBearerStatus) |
|
140 { |
|
141 for (TInt i = 0; i < count; i++) |
|
142 { |
|
143 if (iServices[i]->HasServiceToManage()) |
|
144 { |
|
145 return; |
|
146 } |
|
147 } |
|
148 |
|
149 if(!IsActive()) |
|
150 { |
|
151 iStatus = KRequestPending; |
|
152 SetActive(); |
|
153 TRequestStatus* status = &iStatus; |
|
154 User::RequestComplete(status, KErrNone); |
|
155 } |
|
156 |
|
157 } |
|
158 } |
|
159 |
|
160 // --------------------------------------------------------------------------- |
|
161 // c++ constructor |
|
162 // --------------------------------------------------------------------------- |
|
163 // |
|
164 CLocodServiceMan::CLocodServiceMan() : CActive(CActive::EPriorityStandard),iUidDun(TUid::Uid(KFeatureIdDialupNetworking)) |
|
165 { |
|
166 CActiveScheduler::Add(this); |
|
167 TRACE_FUNC_THIS |
|
168 } |
|
169 |
|
170 // --------------------------------------------------------------------------- |
|
171 // 2nd phase construction |
|
172 // --------------------------------------------------------------------------- |
|
173 // |
|
174 void CLocodServiceMan::ConstructL() |
|
175 { |
|
176 |
|
177 } |
|
178 |
|
179 // --------------------------------------------------------------------------- |
|
180 // Loaded all service plug ins who has implemented the KLOCODSERVICEINTERFACEUID |
|
181 // --------------------------------------------------------------------------- |
|
182 // |
|
183 void CLocodServiceMan::LoadServicesL() |
|
184 { |
|
185 TRACE_FUNC_ENTRY |
|
186 TRACE_INFO((_L("Load interface 0x%08X"), KLOCODSERVICEINTERFACEUID)) |
|
187 const TUid KServicePluginInterface = TUid::Uid(KLOCODSERVICEINTERFACEUID); |
|
188 RImplInfoPtrArray implementations; |
|
189 const TEComResolverParams noResolverParams; |
|
190 REComSession::ListImplementationsL(KServicePluginInterface, |
|
191 noResolverParams, |
|
192 KRomOnlyResolverUid, |
|
193 implementations); |
|
194 CleanupResetDestroyClosePushL(implementations); |
|
195 const TUint count = implementations.Count(); |
|
196 TRACE_INFO((_L(" [BRRST] Service Plug in found %d"), count)) |
|
197 for ( TUint ii = 0 ; ii < count ; ++ii ) |
|
198 { |
|
199 CImplementationInformation* impl = implementations[ii]; |
|
200 TRACE_INFO((_L("Service: feature %d, name '%S', ROM only %d"), |
|
201 impl->ImplementationUid().iUid, &(impl->DisplayName()), impl->RomOnly())) |
|
202 if (FeatureManager::FeatureSupported(impl->ImplementationUid().iUid)) |
|
203 { |
|
204 TRACE_INFO((_L("Feature found"))) |
|
205 TLocodServicePluginParams params(impl->ImplementationUid(), *this); |
|
206 CLocodServicePlugin* srvcplugin = CLocodServicePlugin::NewL(params); |
|
207 CleanupStack::PushL(srvcplugin); |
|
208 CLocodService* service = CLocodService::NewL(*srvcplugin); |
|
209 CleanupStack::Pop(srvcplugin); |
|
210 CleanupStack::PushL(service); |
|
211 iServices.AppendL(service); |
|
212 CleanupStack::Pop(service); |
|
213 } |
|
214 } |
|
215 CleanupStack::PopAndDestroy(&implementations); |
|
216 TRACE_FUNC_EXIT |
|
217 } |
|
218 |
|
219 |
|
220 |