|
1 /* |
|
2 * Copyright (c) 2010 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 * Main implementation of Wlan Sniffer Keepalive application. |
|
16 */ |
|
17 |
|
18 #ifndef WSFKEEPALIVE_H |
|
19 #define WSFKEEPALIVE_H |
|
20 |
|
21 // System includes |
|
22 |
|
23 // User includes |
|
24 |
|
25 #include "wsfkeepalivetimer.h" |
|
26 |
|
27 // Forward declarations |
|
28 |
|
29 class CWsfKeepaliveConnMon; |
|
30 class CWsfKeepaliveConnMonDisc; |
|
31 class CWsfKeepaliveEsock; |
|
32 |
|
33 // External data types |
|
34 |
|
35 // Global function prototypes |
|
36 |
|
37 // Constants |
|
38 |
|
39 // Class declaration |
|
40 |
|
41 /** |
|
42 * Main implementation of Wlan Sniffer Keepalive application. |
|
43 * |
|
44 * This class contains the actual application logic, which monitors |
|
45 * Wlan connections and keeps them alive, if needed. |
|
46 */ |
|
47 class CWsfKeepalive : public CBase, public MWsfKeepaliveTimerNotify |
|
48 { |
|
49 // Friend classes: |
|
50 friend class CWsfKeepaliveTestSuite; |
|
51 |
|
52 public: |
|
53 |
|
54 // Data types |
|
55 |
|
56 // Constants |
|
57 |
|
58 /** Invalid/not available connection ID */ |
|
59 static const TUint KInvalidConnectionId = 0; |
|
60 |
|
61 /** Constructors */ |
|
62 |
|
63 /** |
|
64 * Two-phased constructor. |
|
65 * |
|
66 * @return New object allocated from heap |
|
67 */ |
|
68 static CWsfKeepalive* NewL(); |
|
69 |
|
70 /**> Destructor */ |
|
71 virtual ~CWsfKeepalive(); |
|
72 |
|
73 public: |
|
74 |
|
75 /** |
|
76 * Timer expiration handler. Disconnects the monitored connection, |
|
77 * if needed. Restarts timer, if needed. |
|
78 * |
|
79 * @param aError Status of the timer event |
|
80 */ |
|
81 void TimerExpired( TInt aError ); |
|
82 |
|
83 /** |
|
84 * Wlan connection event handler. Shares and starts to monitor the |
|
85 * opened connection, if necessary. |
|
86 * |
|
87 * @param aConnectionId ID of the opened connection |
|
88 * @param aIapId IAP ID of the opened connection |
|
89 */ |
|
90 void WlanConnectionOpenedL( TUint aConnectionId, TUint aIapId ); |
|
91 |
|
92 /** |
|
93 * Wlan connection event handler. Stops monitoring the connection. |
|
94 */ |
|
95 void WlanConnectionClosed(); |
|
96 |
|
97 protected: |
|
98 |
|
99 private: |
|
100 |
|
101 CWsfKeepalive(); |
|
102 |
|
103 void ConstructL(); |
|
104 |
|
105 TBool OpenedByWlanSniffer( TUint aConnectionId ); |
|
106 |
|
107 TBool NoRealClients( TUint aConnectionId ); |
|
108 |
|
109 void SetState( TUint aState ); |
|
110 |
|
111 private: // Data |
|
112 |
|
113 // Constants |
|
114 |
|
115 /** |
|
116 * State values for the keepalive implementation |
|
117 */ |
|
118 enum |
|
119 { |
|
120 /** Not monitoring any connection */ |
|
121 EInactive, |
|
122 /** Monitoring connection, which has no real clients */ |
|
123 EActiveNoClients, |
|
124 /** Monitoring connection, which has one or more real clients */ |
|
125 EActiveWithClients |
|
126 }; |
|
127 |
|
128 /** |
|
129 * Timer for polling users of a connection |
|
130 */ |
|
131 CWsfKeepaliveTimer* iTimer; |
|
132 |
|
133 /** |
|
134 * Connection Monitor class reference |
|
135 */ |
|
136 CWsfKeepaliveConnMon* iConnMon; |
|
137 |
|
138 /** |
|
139 * Connection Disconnector class reference |
|
140 */ |
|
141 CWsfKeepaliveConnMonDisc* iConnMonDisc; |
|
142 |
|
143 /** |
|
144 * RConnection handler class reference |
|
145 */ |
|
146 CWsfKeepaliveEsock* iEsock; |
|
147 |
|
148 /** |
|
149 * Time when keepalive started for monitored connection |
|
150 */ |
|
151 TTime iKeepaliveStart; |
|
152 |
|
153 /** |
|
154 * ID of monitored connection, KInvalidConnectionId if not valid |
|
155 */ |
|
156 TUint iConnectionId; |
|
157 |
|
158 /** |
|
159 * State of the keepalive implementation |
|
160 */ |
|
161 TUint iState; |
|
162 }; |
|
163 |
|
164 #endif // WSFKEEPALIVE_H |