|
1 /* |
|
2 * Copyright (c) 2005-2009 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: |
|
15 * CTCPTEChannel |
|
16 * MSL Channel for the mobile termination. Sends and receives data over a TCP |
|
17 * socket. This end is the server and listens on a address / port. |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 |
|
23 #ifndef __CTCPTECHANNEL_H__ |
|
24 #define __CTCPTECHANNEL_H__ |
|
25 |
|
26 /******************************************************************************* |
|
27 * |
|
28 * System Includes |
|
29 * |
|
30 ******************************************************************************/ |
|
31 #ifdef WIN32 |
|
32 #include <winsock2.h> |
|
33 #else |
|
34 #include <sys/types.h> |
|
35 #include <sys/socket.h> |
|
36 #endif |
|
37 |
|
38 /******************************************************************************* |
|
39 * |
|
40 * Local Includes |
|
41 * |
|
42 ******************************************************************************/ |
|
43 #include "MTInterfaces.h" |
|
44 #include "CLog.h" |
|
45 |
|
46 /******************************************************************************* |
|
47 * |
|
48 * Definitions |
|
49 * |
|
50 ******************************************************************************/ |
|
51 #define KBUFFSIZE 4096 |
|
52 |
|
53 |
|
54 /******************************************************************************* |
|
55 * |
|
56 * Types |
|
57 * |
|
58 ******************************************************************************/ |
|
59 typedef enum |
|
60 { |
|
61 CE_NONE, |
|
62 CE_RECEIVE_FAILED, |
|
63 CE_SOCKET_ALREADY_SET |
|
64 } TChannelError; |
|
65 |
|
66 |
|
67 /******************************************************************************* |
|
68 * |
|
69 * Class Definition |
|
70 * |
|
71 ******************************************************************************/ |
|
72 class CTcpTeChannel : public ITEChannel |
|
73 { |
|
74 public: |
|
75 // Construction |
|
76 CTcpTeChannel( TPhoneData *aPhoneData, CLog *aLog ); |
|
77 virtual ~CTcpTeChannel(); |
|
78 |
|
79 // Set connections |
|
80 void SetDatalink( IProcessData *aDatalink ); |
|
81 void SetFilter( IFilter *aFilter ); |
|
82 TChannelError SetSocket( int aSocket ); |
|
83 |
|
84 // Control |
|
85 TChannelError ListenOnChannel( int *aErrCode ); |
|
86 void StopChannel(); |
|
87 |
|
88 // ITEChannel |
|
89 virtual TDataPathError SendPacket( char *data, int len, int *aErrCode ); |
|
90 |
|
91 private: |
|
92 void CleanupChannel(); |
|
93 int GetSocketError(); |
|
94 |
|
95 private: |
|
96 TPhoneData *iPhoneData; |
|
97 IProcessData *iDatalink; |
|
98 IFilter *iFilter; |
|
99 CLog *iLog; |
|
100 int iSock; |
|
101 int iExitFlag; |
|
102 int iSocketSetFlag; |
|
103 char iStreamBuffer[KBUFFSIZE]; |
|
104 }; |
|
105 |
|
106 #endif //__CTCPTECHANNEL_H__ |