author | vnuitven <> |
Mon, 06 Sep 2010 18:50:40 +0530 | |
branch | rcs |
changeset 50 | 1d8943dd8be6 |
parent 49 | 64c62431ac08 |
permissions | -rw-r--r-- |
49 | 1 |
/* |
50
1d8943dd8be6
changed copy right year to 2010 for all newly added files
vnuitven <>
parents:
49
diff
changeset
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
49 | 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: Provides MSRP support |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
20 |
||
21 |
// INCLUDE FILES |
|
22 |
#include "mccmsrpmanager.h" |
|
23 |
#include "mccinternalcodecs.h" |
|
24 |
#include "mmccevents.h" |
|
25 |
#include "mccsubcontrollerlogs.h" |
|
26 |
#include "mccresources.h" |
|
27 |
#include "mccqoshandler.h" |
|
28 |
#include "mccinternaldef.h" |
|
29 |
#include <CommDbConnPref.h> |
|
30 |
#include "mccmsrpinterface.h" |
|
31 |
#include "mccmsrpsink.h" |
|
32 |
#include "mccmsrpsource.h" |
|
33 |
#include <CMSRP.h> |
|
34 |
#include <CMSRPSession.h> |
|
35 |
#include <MsrpCommon.h> |
|
36 |
#include <MMSRPSessionObserver.h> |
|
37 |
#include <uri8.h> |
|
38 |
||
39 |
// LOCAL CONSTANTS AND MACROS |
|
40 |
||
41 |
// ============================= LOCAL FUNCTIONS =============================== |
|
42 |
||
43 |
||
44 |
void CMccMsrpManager::ConnectStatus( TInt aStatus ) |
|
45 |
{ |
|
46 |
__SUBCONTROLLER_INT1("CMccMsrpManager::ConnectStatus : status is", aStatus ) |
|
47 |
iConnectStatus = aStatus; |
|
48 |
__ASSERT_ALWAYS(iMsrpSession, User::Leave(KErrNotReady)); |
|
49 |
if ( aStatus == KErrNone) |
|
50 |
{ |
|
51 |
// Send file is requested |
|
52 |
if (iFileSendRequested ) |
|
53 |
{ |
|
54 |
__SUBCONTROLLER( "CMccMsrpManager::ConnectStatus: SendFileL is issued" ) |
|
55 |
||
56 |
iMsrpSession->NotifyProgress(iFTProgressNotification); |
|
57 |
TFileName fileName; |
|
58 |
fileName.Copy(iFileName->Des()); |
|
59 |
TInt error = iMsrpSession->SendFile(fileName, iFileType->Des()); |
|
60 |
if (error != KErrNone && iMsrpSessionOb !=NULL ) |
|
61 |
iMsrpSessionOb->SendFileNotification(error); |
|
62 |
} |
|
63 |
else if (iFileReceiveRequested) |
|
64 |
{ // receive file is requested |
|
65 |
__SUBCONTROLLER( "CMccMsrpManager::ConnectStatus: ReceiveFile is issued" ) |
|
66 |
||
67 |
iMsrpSession->NotifyProgress(iFTProgressNotification); |
|
68 |
TFileName fileName; |
|
69 |
fileName.Copy(iFileName->Des()); |
|
70 |
TInt error = iMsrpSession->ReceiveFile(fileName, iFileSize, iFileType->Des()); |
|
71 |
if (error != KErrNone && iMsrpSessionOb !=NULL) |
|
72 |
{ |
|
73 |
iMsrpSessionOb->ReceiveFileNotification(error); |
|
74 |
} |
|
75 |
} |
|
76 |
} |
|
77 |
else |
|
78 |
{ |
|
79 |
if (iFileSendRequested ) |
|
80 |
{ |
|
81 |
if (iMsrpSessionOb !=NULL ) |
|
82 |
iMsrpSessionOb->SendFileNotification(aStatus); |
|
83 |
} |
|
84 |
else |
|
85 |
{ |
|
86 |
if (iMsrpSessionOb !=NULL ) |
|
87 |
iMsrpSessionOb->ReceiveFileNotification(aStatus); |
|
88 |
} |
|
89 |
} |
|
90 |
//CActiveScheduler::Stop(); |
|
91 |
__SUBCONTROLLER( "CMccMsrpManager::ConnectStatus:exit" ) |
|
92 |
} |
|
93 |
||
94 |
||
95 |
||
96 |
// ============================ MEMBER FUNCTIONS =============================== |
|
97 |
||
98 |
// ----------------------------------------------------------------------------- |
|
99 |
// CMccMsrpManager::CMccMsrpManager |
|
100 |
// C++ default constructor can NOT contain any code, that |
|
101 |
// might leave. |
|
102 |
// ----------------------------------------------------------------------------- |
|
103 |
// |
|
104 |
CMccMsrpManager::CMccMsrpManager( |
|
105 |
MAsyncEventHandler& aHandler, |
|
106 |
MMccResources& aMccResources) : |
|
107 |
iEventHandler( aHandler ), |
|
108 |
iMccResources( aMccResources ) |
|
109 |
{ |
|
110 |
ifirstTime = ETrue; |
|
111 |
iFileSendRequested = EFalse; |
|
112 |
iFileReceiveRequested = EFalse; |
|
113 |
iIsRegisteredForConnOb = EFalse; |
|
114 |
iRefCountForMSRPSession = 0; |
|
115 |
} |
|
116 |
||
117 |
// ----------------------------------------------------------------------------- |
|
118 |
// CMccMsrpManager::ConstructL |
|
119 |
// Symbian 2nd phase constructor can leave. |
|
120 |
// ----------------------------------------------------------------------------- |
|
121 |
// |
|
122 |
void CMccMsrpManager::ConstructL(TUid /*aUID*/) |
|
123 |
{ |
|
124 |
__SUBCONTROLLER( "CMccMsrpManager::ConstructL" ) |
|
125 |
||
126 |
//iMsrp = CMSRP::NewL(aUID); |
|
127 |
||
128 |
iMsrpObserver = CMsrpCallbackMgrObserver::NewL(iEventHandler); |
|
129 |
||
130 |
iFileShare = NULL; |
|
131 |
iFileName = NULL; |
|
132 |
iFileType = NULL; |
|
133 |
iMsrpSessionOb = NULL; |
|
134 |
||
135 |
__SUBCONTROLLER( "CMccMsrpManager::ConstructL exit" ) |
|
136 |
} |
|
137 |
||
138 |
// ----------------------------------------------------------------------------- |
|
139 |
// CMccMsrpManager::NewL |
|
140 |
// Static constructor. |
|
141 |
// ----------------------------------------------------------------------------- |
|
142 |
// |
|
143 |
CMccMsrpManager* CMccMsrpManager::NewL(MAsyncEventHandler& aHandler, MMccResources& aMccResources, TUid aUID) |
|
144 |
{ |
|
145 |
__SUBCONTROLLER( "CMccMsrpManager::NewL" ) |
|
146 |
CMccMsrpManager* self = new (ELeave) CMccMsrpManager( aHandler, aMccResources ); |
|
147 |
CleanupStack::PushL( self ); |
|
148 |
self->ConstructL(aUID); |
|
149 |
CleanupStack::Pop( self ); |
|
150 |
return self; |
|
151 |
} |
|
152 |
||
153 |
||
154 |
// ----------------------------------------------------------------------------- |
|
155 |
// CMccMsrpManager::SetLinkId |
|
156 |
// ----------------------------------------------------------------------------- |
|
157 |
// |
|
158 |
void CMccMsrpManager::SetLinkId( TUint32 aLinkId ) |
|
159 |
{ |
|
160 |
iLinkId = aLinkId; |
|
161 |
} |
|
162 |
||
163 |
// ----------------------------------------------------------------------------- |
|
164 |
// CMccMsrpManager::~CMccMsrpManager |
|
165 |
// Destructor |
|
166 |
// ----------------------------------------------------------------------------- |
|
167 |
// |
|
168 |
CMccMsrpManager::~CMccMsrpManager() |
|
169 |
{ |
|
170 |
__SUBCONTROLLER( "CMccMsrpManager::~CMccMsrpManager" ) |
|
171 |
||
172 |
if ( NULL != iMsrpSession ) |
|
173 |
{ |
|
174 |
iMsrp->CloseMSRPSession(iMsrpSession); |
|
175 |
} |
|
176 |
if ( NULL != iMsrpObserver ) |
|
177 |
{ |
|
178 |
delete iMsrpObserver; |
|
179 |
} |
|
180 |
delete iFileName; |
|
181 |
delete iFileType; |
|
182 |
__SUBCONTROLLER( "CMccMsrpManager::~CMccMsrpManager, exit" ) |
|
183 |
} |
|
184 |
||
185 |
// ----------------------------------------------------------------------------- |
|
186 |
// CMccMsrpManager::GetLocalIpAddressesL |
|
187 |
// ----------------------------------------------------------------------------- |
|
188 |
// |
|
189 |
TDes8& CMccMsrpManager::GetLocalMSRPPath( ) |
|
190 |
{ |
|
191 |
return iLocalMsrpPath; |
|
192 |
} |
|
193 |
||
194 |
||
195 |
// ----------------------------------------------------------------------------- |
|
196 |
// CMccMsrpManager::SetLocalMSRPPath |
|
197 |
// ----------------------------------------------------------------------------- |
|
198 |
// |
|
199 |
void CMccMsrpManager::SetLocalMSRPPath(TDesC8& aMsrpPath ) |
|
200 |
{ |
|
201 |
iLocalMsrpPath.Zero(); |
|
202 |
iLocalMsrpPath = aMsrpPath; |
|
203 |
} |
|
204 |
||
205 |
||
206 |
CMSRPSession* CMccMsrpManager::GetMsrpSession() |
|
207 |
{ |
|
208 |
iRefCountForMSRPSession++; |
|
209 |
return iMsrpSession; |
|
210 |
} |
|
211 |
||
212 |
// ----------------------------------------------------------------------------- |
|
213 |
// CMccMsrpManager::GetLocalIpAddressesL |
|
214 |
// ----------------------------------------------------------------------------- |
|
215 |
// |
|
216 |
void CMccMsrpManager::GetLocalIpAddressesL( TMccCreateLink& aClientData ) |
|
217 |
{ |
|
218 |
__SUBCONTROLLER( "CMccMsrpManager::GetLocalIpAddressesL, entry" ) |
|
219 |
||
220 |
// Extract the local address and port from msrp path |
|
221 |
if (iLocalMsrpPath.Length() > 0) |
|
222 |
{ |
|
223 |
TUriParser8 parser; |
|
224 |
TInt parseValue = parser.Parse(iLocalMsrpPath); |
|
225 |
||
226 |
TBuf8<50> host = parser.Extract(EUriHost); |
|
227 |
TBuf16<60> hostBuf16; |
|
228 |
hostBuf16.Copy(host); |
|
229 |
TLex hostLex(hostBuf16); |
|
230 |
TInt32 addr; |
|
231 |
hostLex.Val(addr); |
|
232 |
||
233 |
TBuf8<10> portBuf = parser.Extract(EUriPort); |
|
234 |
TBuf16<10> portBuf16; |
|
235 |
portBuf16.Copy(portBuf); |
|
236 |
TLex lex(portBuf16); |
|
237 |
TInt Port; |
|
238 |
lex.Val(Port); |
|
239 |
||
240 |
TInetAddr addr1(addr, Port ); |
|
241 |
aClientData.iLocalAddress = addr1; |
|
242 |
||
243 |
__SUBCONTROLLER_INT1("CMccMsrpManager::GetLocalIpAddressesL: Host no",addr) |
|
244 |
__SUBCONTROLLER_INT1("CMccMsrpManager::GetLocalIpAddressesL: Port no", Port) |
|
245 |
__SUBCONTROLLER( "CMccMsrpManager::GetLocalIpAddressesL, exit" ) |
|
246 |
} |
|
247 |
__SUBCONTROLLER( "CMccMsrpManager::GetLocalIpAddressesL, exit" ) |
|
248 |
} |
|
249 |
||
250 |
||
251 |
||
252 |
||
253 |
// ----------------------------------------------------------------------------- |
|
254 |
// CMccMsrpManager::CreateSessionL |
|
255 |
// Creates RTP session and adds session to SessionArray |
|
256 |
// ----------------------------------------------------------------------------- |
|
257 |
// |
|
258 |
CMSRPSession* CMccMsrpManager::CreateMSRPSessionL(MMSRPSessionObserver &aObserver, TUint aIapId) |
|
259 |
{ |
|
260 |
__SUBCONTROLLER( "CMccMsrpManager::CreateMSRPSessionL: Entry" ) |
|
261 |
iMsrpSession = iMsrp->CreateMSRPSessionL(aObserver, aIapId) ; |
|
262 |
||
263 |
__ASSERT_ALWAYS(iMsrpSession != NULL, User::Leave(KErrArgument)); |
|
264 |
||
265 |
iLocalMsrpPath.Zero(); |
|
266 |
iLocalMsrpPath = iMsrpSession->LocalMSRPPath(); |
|
267 |
iMsrpSessionOb = &aObserver; |
|
268 |
||
269 |
__SUBCONTROLLER( "CMccMsrpManager::CreateMSRPSessionL : Exit" ) |
|
270 |
return iMsrpSession; |
|
271 |
} |
|
272 |
||
273 |
||
274 |
// ----------------------------------------------------------------------------- |
|
275 |
// CMccMsrpManager::CreateTransmitStreamL |
|
276 |
// Creates a new transmit stream based on given parameters |
|
277 |
// ----------------------------------------------------------------------------- |
|
278 |
// |
|
279 |
TUint32 CMccMsrpManager::CreateTransmitStreamL( MDataSink& aSink, |
|
280 |
const TMccCodecInfo& /*aCodecInfo*/ ) |
|
281 |
{ |
|
282 |
__SUBCONTROLLER( "CMccMsrpManager::CreateTransmitStreamL" ) |
|
283 |
TUint32 streamId( 0 ); |
|
284 |
if (!iIsRegisteredForConnOb) |
|
285 |
{ |
|
286 |
iMsrpObserver->RegisterConnectionObserver(*this); |
|
287 |
iIsRegisteredForConnOb = ETrue; |
|
288 |
} |
|
289 |
||
290 |
CMccMsrpSink& dSink = static_cast<CMccMsrpSink&>( aSink ); |
|
291 |
||
292 |
TMccMsrpSessionParams sessMsrpParams (iMsrp, iMsrpSession); |
|
293 |
||
294 |
dSink.SetSessionParamsL( sessMsrpParams ); |
|
295 |
||
296 |
return streamId; |
|
297 |
} |
|
298 |
||
299 |
||
300 |
// ----------------------------------------------------------------------------- |
|
301 |
// CMccMsrpManager::CreateReceiveStreamL |
|
302 |
// Creates a new receive stream based on given parameters |
|
303 |
// ----------------------------------------------------------------------------- |
|
304 |
// |
|
305 |
TUint32 CMccMsrpManager::CreateReceiveStreamL( MDataSource& aSource, |
|
306 |
const TMccCodecInfo& /*aCodecInfo*/ ) |
|
307 |
{ |
|
308 |
__SUBCONTROLLER( "CMccMsrpManager::CreateReceiveStreamL" ) |
|
309 |
TUint32 streamId( 0 ); |
|
310 |
||
311 |
CMccMsrpSource& dSource = static_cast<CMccMsrpSource&>( aSource ); |
|
312 |
TMccMsrpSessionParams sessParams( iMsrp, iMsrpSession, iMsrpObserver); |
|
313 |
if (!iIsRegisteredForConnOb ) |
|
314 |
{ |
|
315 |
// register connection observer if not registered yet |
|
316 |
iMsrpObserver->RegisterConnectionObserver(*this); |
|
317 |
} |
|
318 |
if (! iFileShare ) |
|
319 |
{ |
|
320 |
iMsrpObserver->RegisterDataObserver(dSource); |
|
321 |
} |
|
322 |
||
323 |
return streamId; |
|
324 |
} |
|
325 |
||
326 |
||
327 |
// ----------------------------------------------------------------------------- |
|
328 |
// CMccMsrpManager::SetFileShareAttrbs() |
|
329 |
// stores the File Sharing attributes |
|
330 |
// ----------------------------------------------------------------------------- |
|
331 |
// |
|
332 |
void CMccMsrpManager::SetFileShareAttrbs(HBufC16* aFileName, |
|
333 |
TInt aFileSize, |
|
334 |
HBufC8* aFileType, |
|
335 |
TBool aFTProgressNotification) |
|
336 |
{ |
|
337 |
__SUBCONTROLLER( "CMccMsrpManager::SetFileShareAttrbs, entry" ) |
|
338 |
iFileShare = ETrue; |
|
339 |
if (NULL != aFileName ) |
|
340 |
iFileName = aFileName->Des().Alloc(); |
|
341 |
iFileSize = aFileSize; |
|
342 |
if (NULL != aFileType ) |
|
343 |
iFileType = aFileType->Des().Alloc(); |
|
344 |
iFTProgressNotification = aFTProgressNotification; |
|
345 |
__SUBCONTROLLER( "CMccMsrpManager::SetFileShareAttrbs: file share attrbs set. exit" ) |
|
346 |
} |
|
347 |
||
348 |
||
349 |
// ----------------------------------------------------------------------------- |
|
350 |
// CMccMsrpManager::SetRemoteMsrpPathL |
|
351 |
// Sets remote MSRP path for MSRP stack to either connect or listen |
|
352 |
// ----------------------------------------------------------------------------- |
|
353 |
// |
|
354 |
TInt CMccMsrpManager::SetRemoteMsrpPathL( |
|
355 |
const TDes8& aRemoteMsrpPath, |
|
356 |
const TDes8& aConnStatus ) |
|
357 |
{ |
|
358 |
__SUBCONTROLLER( "CMccMsrpManager::SetRemoteMsrpPathL, entry" ) |
|
359 |
//Connection Setup. active , actpass, passive |
|
360 |
// check the remote partys preference for the connection negotiaiton |
|
361 |
TInt conn1 = aConnStatus.Find(_L8("passive")); |
|
362 |
TInt conn2 = aConnStatus.Find(_L8("active")); |
|
363 |
||
364 |
if(conn1 != KErrNotFound) |
|
365 |
{ |
|
366 |
__SUBCONTROLLER( "CMccMsrpManager::SetRemoteMsrpPathL::Connect, entry" ) |
|
367 |
||
368 |
// Wait for Synchronization |
|
369 |
User::After(1500000); |
|
370 |
User::LeaveIfError( iMsrpSession->Connect( aRemoteMsrpPath )); |
|
371 |
||
372 |
if (iFileShare || NULL!= iFileName) |
|
373 |
{ |
|
374 |
__SUBCONTROLLER( "CMccMsrpManager::SetRemoteMsrpPathL File Send is requested" ) |
|
375 |
iFileSendRequested = ETrue; |
|
376 |
} |
|
377 |
} |
|
378 |
else |
|
379 |
{ |
|
380 |
__SUBCONTROLLER( "CMccMsrpManager::SetRemoteMsrpPathL::Listen, entry" ) |
|
381 |
User::LeaveIfError( iMsrpSession->Listen( aRemoteMsrpPath )); |
|
382 |
if (iFileShare || NULL!=iFileName) |
|
383 |
{ |
|
384 |
__SUBCONTROLLER( "CMccMsrpManager::SetRemoteMsrpPathL File receive is requested" ) |
|
385 |
iFileReceiveRequested = ETrue; |
|
386 |
} |
|
387 |
} |
|
388 |
ifirstTime = EFalse; |
|
389 |
return KErrNone; |
|
390 |
} |
|
391 |
||
392 |
||
393 |
// ----------------------------------------------------------------------------- |
|
394 |
// CMccMsrpManager::SendFileNotification |
|
395 |
// Notifies that the entire file has been sent successfully |
|
396 |
// ----------------------------------------------------------------------------- |
|
397 |
// |
|
398 |
void CMccMsrpManager::SendFileNotification(TBool /*aStatus*/) |
|
399 |
{ |
|
400 |
__SUBCONTROLLER( "CMccMsrpManager::SendFileNotification, entry" ) |
|
401 |
// reset the value as the request for the file transfer is completed |
|
402 |
iFileSendRequested = EFalse; |
|
403 |
} |
|
404 |
||
405 |
||
406 |
||
407 |
// ----------------------------------------------------------------------------- |
|
408 |
// CMccMsrpManager::SendFileNotification |
|
409 |
// Notifies that the entire file has been received successfully |
|
410 |
// ----------------------------------------------------------------------------- |
|
411 |
// |
|
412 |
void CMccMsrpManager::ReceiveFileNotification(TBool /*status*/) |
|
413 |
{ |
|
414 |
__SUBCONTROLLER( "CMccMsrpManager::ReceiveFileNotification, entry" ) |
|
415 |
// reset the value as the request for the file transfer is completed |
|
416 |
iFileReceiveRequested = EFalse; |
|
417 |
} |
|
418 |
||
419 |
||
420 |
||
421 |
// ----------------------------------------------------------------------------- |
|
422 |
// CMccMsrpManager::SetMsrpObject |
|
423 |
// Sets CMsrp object. not owned |
|
424 |
// ----------------------------------------------------------------------------- |
|
425 |
// |
|
426 |
void CMccMsrpManager::SetMsrpObject(CMSRP* aMsrpObject) |
|
427 |
{ |
|
428 |
iMsrp = aMsrpObject; |
|
429 |
} |