|
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 * CPhone |
|
16 * Stores the state of the phone. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 #ifndef __CPHONE_H__ |
|
23 #define __CPHONE_H__ |
|
24 |
|
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 "../ThreadLibrary/CAThread.h" |
|
44 #include "MTInterfaces.h" |
|
45 #include "CDatalinkNull.h" |
|
46 #include "CDatalinkPacketise.h" |
|
47 #include "CTCPTEChannel.h" |
|
48 #include "CUDPAirInterface.h" |
|
49 #include "CLogPPPFilter.h" |
|
50 |
|
51 |
|
52 /******************************************************************************* |
|
53 * |
|
54 * Definitions |
|
55 * |
|
56 ******************************************************************************/ |
|
57 #define FILTER_NONE 0 |
|
58 #define FILTER_PPP 1 |
|
59 |
|
60 |
|
61 /******************************************************************************* |
|
62 * |
|
63 * Types |
|
64 * |
|
65 ******************************************************************************/ |
|
66 typedef enum { |
|
67 MTL_SUCCESS, |
|
68 MTL_INVALID_FILTER_CONFIG, |
|
69 MTL_INVALID_DATALINK_LAYER, |
|
70 MTL_FAILED_TO_CREATE_AIR_INTERFACE_THREAD, |
|
71 MTL_FAILED_TO_CREATE_TE_CHANNEL_THREAD, |
|
72 MTL_FAILED_TO_CREATE_MAIN_THREAD, |
|
73 MTL_TE_CHANNEL_SOCKET_ALREADY_SET, |
|
74 MTL_INVALID_STATE, |
|
75 } MTError; |
|
76 |
|
77 // This structure is defined in mobster.x |
|
78 #ifndef __MOBSTER_H__ |
|
79 typedef enum { |
|
80 DL_INVALID, |
|
81 DL_NULL, |
|
82 DL_PACKETISE |
|
83 } TDatalinkLayer; |
|
84 #endif |
|
85 |
|
86 typedef enum { |
|
87 MTS_INIT, |
|
88 MTS_RUNNING, |
|
89 MTS_SHUTDOWN_ALL_BUT_MAIN, |
|
90 MTS_SHUTDOWN_ALL, |
|
91 } MTStatus; |
|
92 |
|
93 /******************************************************************************* |
|
94 * |
|
95 * Class Definition |
|
96 * |
|
97 ******************************************************************************/ |
|
98 class CPhone |
|
99 { |
|
100 public: |
|
101 // Construction |
|
102 CPhone(); |
|
103 ~CPhone(); |
|
104 |
|
105 // Control interface |
|
106 MTError StartPhone( int aPhoneID, int aDatalinkConfig, int aFilterConfig, int *aErrCode ); |
|
107 MTError StopPhone(); |
|
108 MTError GetLocalUUAddress( struct sockaddr_in *sockaddr ); |
|
109 MTError GetRemoteUUAddress( struct sockaddr_in *sockaddr ); |
|
110 MTError SetRemoteUUAddress( struct sockaddr_in sockaddr ); |
|
111 MTError SetTeSocket( int aSock ); |
|
112 MTStatus GetStatus(); |
|
113 CLog *GetLog(); |
|
114 |
|
115 private: |
|
116 MTError InternalInitialisePhone( int aPhoneID, int aDatalinkConfig, int aFilterConfig, int *aErrCode ); |
|
117 MTError InternalRunPhone( int *aErrCode ); |
|
118 void CleanupState( int aRequestSource ); |
|
119 MTError CreateDatalinkLayer( int aDatalinkConfig ); |
|
120 void DeleteDatalinkLayer(); |
|
121 MTError CreateFilters( int aFilterConfig ); |
|
122 void DeleteFilters(); |
|
123 |
|
124 // Thread entry point |
|
125 friend int MainThreadProc( CPhone *aPhone ); |
|
126 friend int AirInterfaceThreadProc( CPhone *aPhone ); |
|
127 friend int TEChannelThreadProc( CPhone *aPhone ); |
|
128 |
|
129 private: |
|
130 // Device logfile |
|
131 CLog iLog; |
|
132 |
|
133 // All the data associated with the phone |
|
134 TPhoneData iPhoneData; |
|
135 |
|
136 // Air Interface |
|
137 CUDPAirInterface iUdpAirInterface; |
|
138 |
|
139 // TE Channel |
|
140 CTcpTeChannel iTcpTeChannel; |
|
141 |
|
142 // Flags |
|
143 int iExitFlag; |
|
144 MTStatus iStatus; |
|
145 |
|
146 // Filters |
|
147 CLogPppFilter iFilterPpp; |
|
148 IFilter *iFilter; |
|
149 |
|
150 // Datalink Layer |
|
151 CDatalinkNull *iDatalinkNull; |
|
152 CDatalinkPacketise *iDatalinkPacketise; |
|
153 IProcessData *iProcessData; |
|
154 |
|
155 // Handles for each of the threads |
|
156 CAThread iMainThread; |
|
157 CAThread iAirInterfaceThread; |
|
158 CAThread iTEChannelThread; |
|
159 }; |
|
160 |
|
161 #endif //__CPHONE_H__ |