|
1 /* |
|
2 * Copyright (c) 2007-2008 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: connection manager |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "cossprotocolconnectionmanager.h" |
|
19 #include "cossprotocolservererrorhandler.h" |
|
20 #include "ccontactsynchandler.h" |
|
21 #include <e32std.h> |
|
22 #include <e32base.h> |
|
23 #include <ximpobjectfactory.h> |
|
24 #include <ximpprotocolconnectionhost.h> |
|
25 #include <ximpstatus.h> |
|
26 #include "xmppservicesettingsapi.h" |
|
27 #include "xmppparams.h" //from xmppsettingsapi |
|
28 |
|
29 #include "xmppsettingsfetcher.h" |
|
30 #include "xmppparameters.h" |
|
31 #include "waittimer.h" |
|
32 |
|
33 #include <spsettings.h> |
|
34 #include <spentry.h> |
|
35 #include <spproperty.h> |
|
36 |
|
37 // ======== MEMBER FUNCTIONS ======== |
|
38 |
|
39 // --------------------------------------------------------------------------- |
|
40 // COSSProtocolConnectionManager::COSSProtocolConnectionManager() |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 COSSProtocolConnectionManager::COSSProtocolConnectionManager() |
|
44 { |
|
45 } |
|
46 |
|
47 |
|
48 // --------------------------------------------------------------------------- |
|
49 // COSSProtocolConnectionManager::ConstructL() |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 void COSSProtocolConnectionManager::ConstructL() |
|
53 { |
|
54 iXmppParams = CXmppParameters::NewL(); |
|
55 iTimer = CWaitTimer::NewL (*this); |
|
56 iTimer->StartListeningL(); //start listening message queue updation |
|
57 iNotifier = CPresenceNotificationHandler::NewL ( *this ); |
|
58 iNotifier->StartListeningL(); //start listening presence notifications |
|
59 iSearchKeyStore = CSearchKeyStore::NewL(); |
|
60 iContactManager = COSSContactManager::NewL( *this ); |
|
61 |
|
62 } |
|
63 |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // COSSProtocolConnectionManager::NewL() |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 COSSProtocolConnectionManager* COSSProtocolConnectionManager::NewL() |
|
70 { |
|
71 |
|
72 COSSProtocolConnectionManager* self = new ( ELeave ) |
|
73 COSSProtocolConnectionManager(); |
|
74 |
|
75 CleanupStack::PushL ( self ); |
|
76 |
|
77 self->ConstructL(); |
|
78 CleanupStack::Pop ( self ); |
|
79 |
|
80 return self; |
|
81 } |
|
82 |
|
83 |
|
84 // --------------------------------------------------------------------------- |
|
85 // COSSProtocolConnectionManager::~COSSProtocolConnectionManager() |
|
86 // --------------------------------------------------------------------------- |
|
87 // |
|
88 COSSProtocolConnectionManager::~COSSProtocolConnectionManager() |
|
89 { |
|
90 delete iXmppParams; |
|
91 delete iNotifier; |
|
92 delete iRecvHandler; |
|
93 delete iServerErrorHandler; |
|
94 delete iAddNotificationHanlder; |
|
95 delete iContactSyncHandler; |
|
96 delete iUserName; |
|
97 delete iPassword; |
|
98 delete iTimer; |
|
99 delete iGroupId; |
|
100 delete iContactManager; |
|
101 delete iSearchKeyStore; |
|
102 if(iServiceName) |
|
103 { |
|
104 delete iServiceName; |
|
105 } |
|
106 } |
|
107 |
|
108 |
|
109 // --------------------------------------------------------------------------- |
|
110 // COSSProtocolConnectionManager::Username |
|
111 // --------------------------------------------------------------------------- |
|
112 // |
|
113 TDesC& COSSProtocolConnectionManager::UserName() |
|
114 { |
|
115 return *iUserName; |
|
116 } |
|
117 |
|
118 |
|
119 // --------------------------------------------------------------------------- |
|
120 // COSSProtocolConnectionManager::Password |
|
121 // --------------------------------------------------------------------------- |
|
122 // |
|
123 TDesC& COSSProtocolConnectionManager::Password() |
|
124 { |
|
125 return *iPassword; |
|
126 } |
|
127 |
|
128 // --------------------------------------------------------------------------- |
|
129 // COSSProtocolConnectionManager::GroupID |
|
130 // --------------------------------------------------------------------------- |
|
131 // |
|
132 TDesC& COSSProtocolConnectionManager::GroupId() |
|
133 { |
|
134 return *iGroupId; |
|
135 } |
|
136 |
|
137 // --------------------------------------------------------------------------- |
|
138 // COSSProtocolConnectionManager::GroupID |
|
139 // --------------------------------------------------------------------------- |
|
140 // |
|
141 void COSSProtocolConnectionManager::SetGroupIDL(TDesC& aGroupId) |
|
142 { |
|
143 HBufC* tmpId = aGroupId.AllocL(); |
|
144 delete iGroupId; |
|
145 iGroupId=NULL; |
|
146 iGroupId = tmpId ; |
|
147 } |
|
148 |
|
149 // --------------------------------------------------------------------------- |
|
150 // COSSProtocolConnectionManager::XmppParams |
|
151 // --------------------------------------------------------------------------- |
|
152 // |
|
153 CXmppParameters& COSSProtocolConnectionManager::XmppParams() |
|
154 { |
|
155 return *iXmppParams; |
|
156 } |
|
157 |
|
158 |
|
159 // --------------------------------------------------------------------------- |
|
160 // COSSProtocolConnectionManager::DataHandler() |
|
161 // --------------------------------------------------------------------------- |
|
162 // |
|
163 CWaitTimer& COSSProtocolConnectionManager::DataHandler() |
|
164 { |
|
165 return *iTimer; |
|
166 } |
|
167 |
|
168 // --------------------------------------------------------------------------- |
|
169 // COSSProtocolConnectionManager::HandleToHost() |
|
170 // --------------------------------------------------------------------------- |
|
171 // |
|
172 MXIMPProtocolConnectionHost& COSSProtocolConnectionManager::HandleToHost() |
|
173 { |
|
174 return *iHostHandle; |
|
175 } |
|
176 |
|
177 |
|
178 // --------------------------------------------------------------------------- |
|
179 // COSSProtocolConnectionManager::SetHost() |
|
180 // --------------------------------------------------------------------------- |
|
181 // |
|
182 void COSSProtocolConnectionManager::SetHost ( MXIMPProtocolConnectionHost& aHost ) |
|
183 { |
|
184 iHostHandle = &aHost; |
|
185 } |
|
186 |
|
187 // --------------------------------------------------------------------------- |
|
188 // COSSProtocolConnectionManager::SetConnectionParamsL() |
|
189 // --------------------------------------------------------------------------- |
|
190 // |
|
191 void COSSProtocolConnectionManager::SetConnectionParamsL ( const TDesC& aUserName, |
|
192 const TDesC& aPassword, |
|
193 const TInt32 aServiceId ) |
|
194 { |
|
195 |
|
196 // first store the login parameters |
|
197 |
|
198 HBufC* tmpBuf = aUserName.AllocL(); |
|
199 delete iUserName; |
|
200 iUserName = tmpBuf; |
|
201 |
|
202 tmpBuf = aPassword.AllocL(); |
|
203 delete iPassword; |
|
204 iPassword = tmpBuf; |
|
205 |
|
206 SetConnectionParamsL( aServiceId, EFalse ); |
|
207 } |
|
208 |
|
209 |
|
210 // --------------------------------------------------------------------------- |
|
211 // COSSProtocolConnectionManager::ManufactureDataHandlerL() |
|
212 // --------------------------------------------------------------------------- |
|
213 // |
|
214 void COSSProtocolConnectionManager::ManufactureDataHandlerL() |
|
215 { |
|
216 if(!iIsDataHandlerReady) |
|
217 { |
|
218 iRecvHandler = CReceiveMessageHandler::NewL ( *this ); |
|
219 iRecvHandler->StartListeningL();//start listening incoming messages |
|
220 iServerErrorHandler = COssprotocolServerErrorHandler::NewL ( *this ); |
|
221 iServerErrorHandler->StartListeningL();//start listening incoming messages |
|
222 iAddNotificationHanlder = CAddContactNotificationHandler::NewL ( *this ); |
|
223 iContactSyncHandler = CContactSyncHandler::NewL(*this); |
|
224 iContactSyncHandler->StartListening(); // listening for contacts changes |
|
225 iIsDataHandlerReady = ETrue; |
|
226 } |
|
227 } |
|
228 |
|
229 // --------------------------------------------------------------------------- |
|
230 // COSSProtocolConnectionManager::SetConnectionParamsL |
|
231 // --------------------------------------------------------------------------- |
|
232 // |
|
233 TInt COSSProtocolConnectionManager::SetConnectionParamsL ( const TUint32 aServiceId , TBool aReadNeeded /* = ETrue*/ ) |
|
234 { |
|
235 // Get the service setting id and service name |
|
236 TInt error = KErrNone; |
|
237 |
|
238 CSPSettings* settings = CSPSettings::NewLC(); |
|
239 |
|
240 if(aReadNeeded) |
|
241 { |
|
242 TInt settingsId = 0; |
|
243 CSPProperty* property = CSPProperty::NewLC(); |
|
244 settings->FindPropertyL( aServiceId, |
|
245 ESubPropertyIMSettingsId, |
|
246 *property ); |
|
247 if ( property ) |
|
248 { |
|
249 property->GetValue( settingsId ); |
|
250 } |
|
251 // read settings |
|
252 |
|
253 error = CXmppSettingsFetcher::ReadSettingsL ( settingsId, *iXmppParams ); //settings id is used to read settings |
|
254 |
|
255 CleanupStack::PopAndDestroy(); // property |
|
256 |
|
257 } |
|
258 // read service name |
|
259 CSPEntry* entry = CSPEntry::NewLC(); |
|
260 settings->FindEntryL( aServiceId, *entry ) ; |
|
261 |
|
262 // set the service name to presence cache updater |
|
263 if(iServiceName) |
|
264 { |
|
265 delete iServiceName; |
|
266 iServiceName = NULL; |
|
267 } |
|
268 iServiceName = entry->GetServiceName().AllocL(); |
|
269 CleanupStack::PopAndDestroy(2); // entry, settings |
|
270 |
|
271 return error; |
|
272 } |
|
273 // --------------------------------------------------------------------------- |
|
274 // COSSProtocolConnectionManager::PresenceAuthGrantReqList() |
|
275 // --------------------------------------------------------------------------- |
|
276 // |
|
277 RArray< HBufC >* COSSProtocolConnectionManager::PresenceAuthGrantReqList() |
|
278 { |
|
279 return &iPresenceAuthGrantReqList; |
|
280 } |
|
281 |
|
282 // --------------------------------------------------------------------------- |
|
283 // COSSProtocolConnectionManager::ReleaseConnectionL() |
|
284 // --------------------------------------------------------------------------- |
|
285 // |
|
286 void COSSProtocolConnectionManager::ReleaseConnectionL() |
|
287 { |
|
288 if( iTimer ) |
|
289 { |
|
290 iTimer->IssueReleaseRequestL(); |
|
291 } |
|
292 } |
|
293 |
|
294 // --------------------------------------------------------------------------- |
|
295 // COSSProtocolConnectionManager::IsServerDisconnect() |
|
296 // --------------------------------------------------------------------------- |
|
297 // |
|
298 TBool COSSProtocolConnectionManager::IsServerDisconnect() |
|
299 { |
|
300 return iTimer->IsServerDisconnect(); |
|
301 } |
|
302 // --------------------------------------------------------------------------- |
|
303 // COSSProtocolConnectionManager::SetImHost |
|
304 // --------------------------------------------------------------------------- |
|
305 // |
|
306 |
|
307 void COSSProtocolConnectionManager::SetImHost(MProtocolImDataHost& aHost) |
|
308 { |
|
309 iHost = &aHost ; |
|
310 } |
|
311 // --------------------------------------------------------------------------- |
|
312 // COSSProtocolConnectionManager::GetImHost() |
|
313 // --------------------------------------------------------------------------- |
|
314 // |
|
315 MProtocolImDataHost& COSSProtocolConnectionManager::GetImHost() |
|
316 { |
|
317 return *iHost; |
|
318 } |
|
319 |
|
320 // --------------------------------------------------------------------------- |
|
321 // COSSProtocolConnectionManager::GetAddNotificationHandler() |
|
322 // --------------------------------------------------------------------------- |
|
323 // |
|
324 CAddContactNotificationHandler& COSSProtocolConnectionManager::GetAddNotificationHandler() |
|
325 { |
|
326 return *iAddNotificationHanlder; |
|
327 } |
|
328 // --------------------------------------------------------------------------- |
|
329 // COSSProtocolConnectionManager::SetSearchHost |
|
330 // --------------------------------------------------------------------------- |
|
331 // |
|
332 void COSSProtocolConnectionManager::SetSearchHost(MProtocolSearchDataHost& aSearchHost) |
|
333 { |
|
334 iSearchHost = &aSearchHost ; |
|
335 } |
|
336 // --------------------------------------------------------------------------- |
|
337 // COSSProtocolConnectionManager::GetSearchHost() |
|
338 // --------------------------------------------------------------------------- |
|
339 // |
|
340 MProtocolSearchDataHost& COSSProtocolConnectionManager::GetSearchHost() |
|
341 { |
|
342 return *iSearchHost; |
|
343 } |
|
344 // --------------------------------------------------------------------------- |
|
345 // COSSProtocolConnectionManager::GetSearchKeyStore() |
|
346 // --------------------------------------------------------------------------- |
|
347 // |
|
348 CSearchKeyStore& COSSProtocolConnectionManager::GetSearchKeyStore() |
|
349 { |
|
350 return *iSearchKeyStore; |
|
351 } |
|
352 |
|
353 // --------------------------------------------------------------------------- |
|
354 // COSSProtocolConnectionManager::GetContactManager() |
|
355 // --------------------------------------------------------------------------- |
|
356 // |
|
357 COSSContactManager& COSSProtocolConnectionManager::GetContactManager() |
|
358 { |
|
359 return *iContactManager; |
|
360 } |
|
361 // --------------------------------------------------------------------------- |
|
362 // COSSProtocolConnectionManager::ServiceName() |
|
363 // --------------------------------------------------------------------------- |
|
364 // |
|
365 const TDesC& COSSProtocolConnectionManager::ServiceName() |
|
366 { |
|
367 return *iServiceName; |
|
368 } |
|
369 // End of File |
|
370 |
|
371 |