|
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Implements the avdtp reporting transport session |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalComponent |
|
21 */ |
|
22 |
|
23 #include "avdtpReportingSession.h" |
|
24 #include "avdtp.h" |
|
25 #include "avdtpStream.h" |
|
26 #include "avdtpsap.h" |
|
27 |
|
28 CReportingSession* CReportingSession::NewLC(CAvdtpProtocol& aProtocol, |
|
29 CAvdtpSAP& aSAP, CAVStream& aStream) |
|
30 { |
|
31 CReportingSession* s = new (ELeave) CReportingSession(aProtocol, aSAP, aStream); |
|
32 CleanupStack::PushL(s); |
|
33 s->ConstructL(); |
|
34 return s; |
|
35 } |
|
36 |
|
37 CReportingSession* CReportingSession::NewL(CAvdtpProtocol& aProtocol, |
|
38 CAvdtpSAP& aSAP, CAVStream& aStream) |
|
39 { |
|
40 CReportingSession* s = CReportingSession::NewLC(aProtocol, aSAP, aStream); |
|
41 CleanupStack::Pop(); |
|
42 return s; |
|
43 } |
|
44 |
|
45 CReportingSession::CReportingSession(CAvdtpProtocol& aProtocol, CAvdtpSAP& aSAP, CAVStream& aStream) |
|
46 : CUserPlaneTransportSession(aProtocol, aSAP, EReporting, aStream) |
|
47 { |
|
48 |
|
49 } |
|
50 |
|
51 void CReportingSession::ConstructL() |
|
52 { |
|
53 CUserPlaneTransportSession::ConstructL(); |
|
54 |
|
55 // Balking is set to true. This allows the circular buffer to wrap |
|
56 // and overwrite the oldest data. |
|
57 User::LeaveIfError(iSendPool.Create(4, ETrue)); |
|
58 User::LeaveIfError(iReceivePool.Create(4, ETrue)); |
|
59 } |
|
60 |
|
61 TInt CReportingSession::DoActiveOpen() |
|
62 { |
|
63 __ASSERT_DEBUG(iStream, Panic(EAvdtpTransportSessionBaseNotCheckStream)); |
|
64 |
|
65 TInt ret = KErrGeneral; |
|
66 |
|
67 // add session to the stream |
|
68 ret = iStream->AddSession(EReporting,*this,iTransportChannel); |
|
69 if (ret!=KErrNone) |
|
70 { |
|
71 // not erroring the stream, as it's not it's fault |
|
72 // and it may not exist anyway! |
|
73 iStream = NULL; |
|
74 iSAP.Error(ret); |
|
75 } |
|
76 |
|
77 return ret; |
|
78 } |
|
79 |
|
80 TInt CReportingSession::Send(RMBufChain& aData, TUint /*aOptions*/, TSockAddr* /*aAddr*/) |
|
81 { |
|
82 TInt wrote = iTransportChannel->SendPacket(EReporting, aData); |
|
83 if (!wrote) |
|
84 { |
|
85 iTransportChannelBlocked = ETrue; |
|
86 } |
|
87 return wrote; |
|
88 } |
|
89 |
|
90 |
|
91 void CReportingSession::CanSend() |
|
92 { |
|
93 // drain some pool? or just tell sap? |
|
94 iTransportChannelBlocked = EFalse; |
|
95 |
|
96 } |