|
1 /* |
|
2 * Copyright (c) 2007 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 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef TESTSERVER_H |
|
22 #define TESTSERVER_H |
|
23 |
|
24 #include <e32base.h> |
|
25 #include <e32std.h> |
|
26 #include <es_sock.h> |
|
27 |
|
28 #include "timeouttimer.h" |
|
29 |
|
30 class TInetAddr; |
|
31 |
|
32 |
|
33 /** |
|
34 * ?one_line_short_description |
|
35 * |
|
36 * ?more_complete_description |
|
37 * |
|
38 * @lib ?library |
|
39 * @since S60 ?S60_version *** for example, S60 v3.0 |
|
40 */ |
|
41 class MTestServerObserver |
|
42 { |
|
43 |
|
44 public: |
|
45 |
|
46 enum TServerNotify |
|
47 { |
|
48 EConnecting = 1, |
|
49 EConnected, |
|
50 EDisconnected, |
|
51 EShutdownTimer |
|
52 }; |
|
53 |
|
54 virtual void Notify( TServerNotify aNotify, TInt aError ) = 0; |
|
55 }; |
|
56 |
|
57 |
|
58 /** |
|
59 * ?one_line_short_description |
|
60 * |
|
61 * ?more_complete_description |
|
62 * |
|
63 * @lib ?library |
|
64 * @since S60 ?S60_version *** for example, S60 v3.0 |
|
65 */ |
|
66 class CTestServer : public CActive, public MTimeoutNotifier |
|
67 { |
|
68 public: |
|
69 static CTestServer* NewL( MTestServerObserver* aObserver ); |
|
70 static CTestServer* NewLC( MTestServerObserver* aObserver ); |
|
71 virtual ~CTestServer(); |
|
72 |
|
73 void OpenL( TInetAddr& aAddr, TUint aTimeoutTime = 0 ); |
|
74 |
|
75 protected: // from CActive |
|
76 void RunL(); |
|
77 void DoCancel(); |
|
78 |
|
79 protected: // from MTimeoutNotifier |
|
80 void TimerExpired(); |
|
81 |
|
82 private: |
|
83 CTestServer( MTestServerObserver* aObserver ); |
|
84 void ConstructL(); |
|
85 |
|
86 private: // members |
|
87 |
|
88 enum TTestServerState |
|
89 { |
|
90 EServerDisconnected = 0, |
|
91 EServerConnected, |
|
92 EServerWaitingConnection |
|
93 }; |
|
94 |
|
95 MTestServerObserver* iObserver; |
|
96 TTestServerState iState; |
|
97 RSocket iSocket; |
|
98 RSocket iListenSocket; |
|
99 RSocketServ iServer; |
|
100 CTimeOutTimer* iTimer; |
|
101 }; |
|
102 |
|
103 #endif // TESTSERVER_H |