|
1 /* |
|
2 * Copyright (c) 2005-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: fctbcpfloorcontrolimpl.h |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef __CTBCPFLOORCONTROLIMPL_H__ |
|
22 #define __CTBCPFLOORCONTROLIMPL_H__ |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32base.h> |
|
26 #include <e32std.h> |
|
27 #include <e32def.h> |
|
28 #include <in_sock.h> |
|
29 #include "fcconnectioncontainer.h" |
|
30 #include "fcsender.h" |
|
31 #include "fcreceiver.h" |
|
32 #include "fcmessageobserver.h" |
|
33 #include "fcconnectionnotifier.h" |
|
34 #include "fcnotifier.h" |
|
35 #include "fcinterface.h" |
|
36 |
|
37 _LIT8(KTBCP, "TBCP"); |
|
38 |
|
39 // FORWARD DECLARATIONS |
|
40 class MFCMessageObserver; |
|
41 class CFCConnectionContainer; |
|
42 class CFCSender; |
|
43 class CFCReceiver; |
|
44 |
|
45 /** |
|
46 * Class provides functions for connecting, sending and receiving |
|
47 * |
|
48 * CTBCPFloorControlImpl Class provides functions for Sending |
|
49 * |
|
50 * @lib FCTBCP.lib |
|
51 * @since S60 v3.0 |
|
52 */ |
|
53 class CTBCPFloorControlImpl : public CFCInterface, |
|
54 public MFCConnectionNotifier, public MFCNotifier |
|
55 { |
|
56 public: |
|
57 /** |
|
58 * Constructs an object; leaves on failure. |
|
59 * @param aInitParams an interface for requesting floor control events |
|
60 * @return new instance |
|
61 */ |
|
62 static CTBCPFloorControlImpl* NewL(TAny* aInitParams); |
|
63 |
|
64 /** |
|
65 * Destructor |
|
66 */ |
|
67 ~CTBCPFloorControlImpl(); |
|
68 |
|
69 public: //From MFCPlugIn |
|
70 /** |
|
71 * Gets supported Floor contrl PlugIn Name (e.g. TBCP); |
|
72 * @return supported Floor control plugins name |
|
73 * |
|
74 */ |
|
75 const TDesC8& Name () const; |
|
76 |
|
77 /** |
|
78 * Sends the Data to the predefined addresses |
|
79 * @param aData, sending via this plugIn |
|
80 * |
|
81 */ |
|
82 void SendToNetL(HBufC8* aData); |
|
83 |
|
84 /** |
|
85 * Opens the connection with the predefined IAP id and socket server |
|
86 */ |
|
87 void ConnectL(TBool aReceiver); |
|
88 |
|
89 /** |
|
90 * Sets IAPID |
|
91 * @param aIapId |
|
92 * |
|
93 */ |
|
94 void SetIapId(TUint32 aIapId); |
|
95 |
|
96 /** |
|
97 * Sets Specified Address and Port which will connect to |
|
98 * @param aAddr, aRemote Addr |
|
99 * @param aPort, aRemote Port |
|
100 */ |
|
101 void SetAddressL(const TDesC& aAddr, TUint aPort); |
|
102 |
|
103 /** |
|
104 * Sets Specified Local Port |
|
105 * @param aPort, aLocal Port |
|
106 */ |
|
107 void SetLocalPort(TUint aPort); |
|
108 |
|
109 /** |
|
110 * Stops the connection, Sending and Receving |
|
111 * Socket is not closed yet |
|
112 */ |
|
113 void Stop(); |
|
114 |
|
115 public: //FRom MFCConnectionNotifier |
|
116 /** |
|
117 * CallBack function for ConnectionConainer |
|
118 * @param aError, aError for the connection status |
|
119 */ |
|
120 void ConnectionStarted( TInt aError ); |
|
121 |
|
122 /** |
|
123 * function for ConnectionStarted |
|
124 * @param aError, aError for the connection status |
|
125 */ |
|
126 void ConnectionStartedL(TInt aError); |
|
127 |
|
128 public: // From MFCNotifier |
|
129 /** |
|
130 * CallBack function for Sending and Receiving |
|
131 * @param aError, aError for the sending status |
|
132 */ |
|
133 void ErrorNotify( TInt aErrCode); |
|
134 |
|
135 /** |
|
136 * Receives the Data from predefined addr and port |
|
137 * @param aData, Receving Data |
|
138 */ |
|
139 void ReceivedData(HBufC8* aData); |
|
140 |
|
141 private: // New functions |
|
142 |
|
143 /** |
|
144 * Starts to Listen to the predefined Addr and Port |
|
145 */ |
|
146 void StartListen(); |
|
147 |
|
148 /** |
|
149 * Socket is reset and open again |
|
150 */ |
|
151 void ResetSocketL(); |
|
152 |
|
153 /** |
|
154 * CancelSending |
|
155 */ |
|
156 void CancelSend(); |
|
157 |
|
158 private: |
|
159 /** |
|
160 * Constructor |
|
161 * @param aObserver, MFCMessageObserver |
|
162 * @return An initialized instance of this class. |
|
163 */ |
|
164 CTBCPFloorControlImpl(MFCMessageObserver &aObserver); |
|
165 |
|
166 void ConstructL(); |
|
167 |
|
168 private://data |
|
169 RSocketServ iSocketServ; |
|
170 RSocket iSocket; |
|
171 CFCSender* iSender; |
|
172 CFCReceiver* iReceiver; |
|
173 CFCConnectionContainer* iConnection; |
|
174 MFCMessageObserver& iMsgObserver; |
|
175 TUint32 iIapId; |
|
176 TInetAddr iRemoteAddr; |
|
177 TUint iLocalPort; |
|
178 TBool iStartListen; |
|
179 |
|
180 private: // For testing purposes |
|
181 friend class UT_CTBCPFloorControlImpl; |
|
182 }; |
|
183 |
|
184 #endif // end of __CTBCPFLOORCONTROLIMPL_H__ |
|
185 |
|
186 // End of File |