|
1 // Copyright (c) 2005-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 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @internalTechnology |
|
19 */ |
|
20 |
|
21 #ifndef AVCTPBODY_H |
|
22 #define AVCTPBODY_H |
|
23 |
|
24 #include <es_sock.h> |
|
25 #include <avctpservices.h> |
|
26 |
|
27 #define __ASSERT_BTADDR(d) __ASSERT_DEBUG((d) != TBTDevAddr(0), Panic(EAvctpNullBTDevAddr)); |
|
28 |
|
29 // Forward declarations |
|
30 class CAvctpSender; |
|
31 class CAvctpReceiver; |
|
32 class CAvctpRemoteDevices; |
|
33 class CAvctpCloser; |
|
34 |
|
35 |
|
36 NONSHARABLE_CLASS(TPrimaryChannelProxy) |
|
37 : public MAvctpChannel |
|
38 { |
|
39 public: |
|
40 TPrimaryChannelProxy(CAvctpBody& aBody); |
|
41 |
|
42 private: // from MAvctpChannel |
|
43 TInt MacAttachRequest(const TBTDevAddr& aBTDevice); |
|
44 TBool MacIsAttached(const TBTDevAddr& aBTDevice); |
|
45 void MacCancelAttach(const TBTDevAddr& aBTDevice); |
|
46 TInt MacDetachRequest(const TBTDevAddr& aBTDevice); |
|
47 TInt MacSendMessage(const TBTDevAddr& aBTDevice, |
|
48 SymbianAvctp::TTransactionLabel aTransactionLabel, |
|
49 SymbianAvctp::TMessageType aType, |
|
50 const TDesC8& aMessageInformation); |
|
51 void MacCancelSend(); |
|
52 |
|
53 private: |
|
54 CAvctpBody& iBody; |
|
55 }; |
|
56 |
|
57 NONSHARABLE_CLASS(TSecondaryChannelProxy) |
|
58 : public MAvctpChannel |
|
59 { |
|
60 public: |
|
61 TSecondaryChannelProxy(CAvctpBody& aBody); |
|
62 |
|
63 private: // from MAvctpChannel |
|
64 TInt MacAttachRequest(const TBTDevAddr& aBTDevice); |
|
65 TBool MacIsAttached(const TBTDevAddr& aBTDevice); |
|
66 void MacCancelAttach(const TBTDevAddr& aBTDevice); |
|
67 TInt MacDetachRequest(const TBTDevAddr& aBTDevice); |
|
68 TInt MacSendMessage(const TBTDevAddr& aBTDevice, |
|
69 SymbianAvctp::TTransactionLabel aTransactionLabel, |
|
70 SymbianAvctp::TMessageType aType, |
|
71 const TDesC8& aMessageInformation); |
|
72 void MacCancelSend(); |
|
73 |
|
74 private: |
|
75 CAvctpBody& iBody; |
|
76 }; |
|
77 |
|
78 |
|
79 /** |
|
80 This class is the handle of the RAvctp / CAvctpBody pair. |
|
81 It implements the AVCTP interface presented by RAvctp. |
|
82 It owns a couple of Sender/Receiver for the primary channel and a couple for the secondary channel. |
|
83 CAvctpSender and CAvctpReceiver are active objects. |
|
84 @internalComponent |
|
85 */ |
|
86 NONSHARABLE_CLASS(CAvctpBody) : public CBase |
|
87 { |
|
88 public: |
|
89 static CAvctpBody* NewL(MAvctpEventNotify& aNotify, SymbianAvctp::TPid aPid, MAvctpChannel*& aPrimaryChannel); |
|
90 static CAvctpBody* NewLC(MAvctpEventNotify& aNotify, SymbianAvctp::TPid aPid, MAvctpChannel*& aPrimaryChannel); |
|
91 ~CAvctpBody(); |
|
92 |
|
93 // Methods to support RAvctp |
|
94 void Close(RAvctp::TCloseType aImmediacy); |
|
95 void CloseGracefully(); |
|
96 TInt PrimaryChannelAttachRequest(const TBTDevAddr& aBTDevice); |
|
97 TBool IsAttached(const TBTDevAddr& aBTDevice); |
|
98 TInt PrimaryChannelDetachRequest(const TBTDevAddr& aBTDevice); |
|
99 TInt SendMessage(const TBTDevAddr& aBTDevice, |
|
100 SymbianAvctp::TTransactionLabel aTransactionLabel, |
|
101 SymbianAvctp::TMessageType aType, |
|
102 const TDesC8& aMessageInformation, |
|
103 TBool aIsSecondChannel); |
|
104 void PrimaryChannelCancelAttach(const TBTDevAddr& aBTDevice); |
|
105 void PrimaryChannelCancelSend(); |
|
106 |
|
107 TInt InstallSecondaryChannel(MAvctpEventNotify& aSecondChannelObserver, MAvctpChannel*& aSecondaryChannel); |
|
108 TInt SecondaryChannelAttachRequest(const TBTDevAddr& aBTDevice); |
|
109 TInt SecondaryChannelDetachRequest(const TBTDevAddr& aBTDevice); |
|
110 void SecondaryChannelCancelAttach(const TBTDevAddr& aBTDevice); |
|
111 void SecondaryChannelCancelSend(); |
|
112 void UninstallSecondaryChannel(RAvctp::TCloseType aImmediacy); |
|
113 |
|
114 private: |
|
115 CAvctpBody(MAvctpEventNotify& aNotify, SymbianAvctp::TPid aPid); |
|
116 void ConstructL(MAvctpChannel*& aPrimaryChannel); |
|
117 void DoInstallSecondaryChannelL(MAvctpEventNotify& aSecondChannelObserver, MAvctpChannel*& aSecondaryChannel); |
|
118 |
|
119 private: |
|
120 |
|
121 MAvctpEventNotify& iNotify; |
|
122 SymbianAvctp::TPid iPid; |
|
123 |
|
124 RSocketServ iSocketServ; |
|
125 RSocket iAvctpPrimaryDataSocket; |
|
126 RSocket iAvctpSecondaryDataSocket; |
|
127 |
|
128 // Proxy classes for handling requests for different channels. |
|
129 TPrimaryChannelProxy* iPrimaryChannelProxy; |
|
130 TSecondaryChannelProxy* iSecondaryChannelProxy; |
|
131 |
|
132 // Active objects to deal with the primary channel data socket |
|
133 CAvctpSender* iPrimaryChannelSender; |
|
134 CAvctpReceiver* iPrimaryChannelReceiver; |
|
135 |
|
136 // Active objects to deal with the secondary channel data socket |
|
137 CAvctpSender* iSecondaryChannelSender; |
|
138 CAvctpReceiver* iSecondaryChannelReceiver; |
|
139 MAvctpEventNotify* iSecondaryChannelNotify; //non-owned |
|
140 |
|
141 // Active Object to manage the TransportControl socket. |
|
142 CAvctpRemoteDevices* iRemoteDevices; |
|
143 }; |
|
144 |
|
145 #endif // AVCTPBODY_H |