|
1 /* |
|
2 * Copyright (c) 2002 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: SyncML Obex server internal server module |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __NSMLOBEXCOMMSERVER_H__ |
|
21 #define __NSMLOBEXCOMMSERVER_H__ |
|
22 |
|
23 // --------------------------------------------------------------------------------------- |
|
24 // Includes |
|
25 // --------------------------------------------------------------------------------------- |
|
26 #include <e32base.h> |
|
27 |
|
28 // --------------------------------------------------------------------------------------- |
|
29 // Constants |
|
30 // --------------------------------------------------------------------------------------- |
|
31 static const TInt KTimeOutInSeconds = 1800; |
|
32 |
|
33 // --------------------------------------------------------------------------------------- |
|
34 // Class forwards |
|
35 // --------------------------------------------------------------------------------------- |
|
36 class CNSmlObexCommSession; |
|
37 class CNSmlTimeOut; |
|
38 |
|
39 // --------------------------------------------------------------------------------------- |
|
40 // Server |
|
41 // --------------------------------------------------------------------------------------- |
|
42 class CNSmlObexCommServer : public CServer2 |
|
43 { |
|
44 public: |
|
45 IMPORT_C static CNSmlObexCommServer* NewL( const TDesC& aServerName ); |
|
46 IMPORT_C virtual ~CNSmlObexCommServer(); |
|
47 |
|
48 protected: |
|
49 virtual CSession2* NewSessionL( const TVersion& aVersion, const RMessage2& aMessage ) const; |
|
50 |
|
51 private: |
|
52 CNSmlObexCommServer(); |
|
53 void ConstructL(); |
|
54 |
|
55 void IncrementSessions(); |
|
56 void DecrementSessions(); |
|
57 void Shutdown(); |
|
58 |
|
59 private: |
|
60 friend class CNSmlObexCommSession; |
|
61 |
|
62 RMessagePtr2 iClientReceiveMsg; |
|
63 TBool iClientWaitingReceivePacket; |
|
64 CNSmlTimeOut* iClientReceiveTimeOut; |
|
65 |
|
66 RMessagePtr2 iServerGetSendMsg; |
|
67 TBool iServerWaitingSendPacket; |
|
68 CNSmlTimeOut* iServerGetSendTimeOut; |
|
69 |
|
70 RMessagePtr2 iServerListenDisconnectMsg; |
|
71 TBool iServerListeningDisconnect; |
|
72 |
|
73 TBool iClientDisconnected; |
|
74 HBufC8* iSendBuffer; |
|
75 HBufC8* iRecvBuffer; |
|
76 TBool iSendReady; |
|
77 TBool iRecvReady; |
|
78 |
|
79 TInt iSessionCount; |
|
80 }; |
|
81 |
|
82 // --------------------------------------------------------------------------------------- |
|
83 // CNSmlObexCommServer session |
|
84 // --------------------------------------------------------------------------------------- |
|
85 class CNSmlObexCommSession : public CSession2 |
|
86 { |
|
87 public: |
|
88 static CNSmlObexCommSession* NewL( CNSmlObexCommServer& aServer ); |
|
89 void ServiceL( const RMessage2& aMessage ); |
|
90 void DispatchMessageL( const RMessage2& aMessage ); |
|
91 |
|
92 protected: |
|
93 // ObexClientSession |
|
94 void Disconnect( const RMessagePtr2& aMessage ); |
|
95 void SendL( const RMessagePtr2& aMessage ); |
|
96 void ReceiveL( const RMessagePtr2& aMessage ); |
|
97 void CancelReceive( const RMessagePtr2& aMessage ); |
|
98 void ReceiveTimeout(); |
|
99 |
|
100 // ObexServerSession |
|
101 void SetReceivedPacketL( const RMessagePtr2& aMessage ); |
|
102 void GetSendPacketL( const RMessagePtr2& aMessage ); |
|
103 void CancelGetSendPacket( const RMessagePtr2& aMessage ); |
|
104 void GetSendTimeout(); |
|
105 void ListenDisconnect( const RMessagePtr2& aMessage ); |
|
106 void CancelListenDisconnect( const RMessagePtr2& aMessage ); |
|
107 |
|
108 private: |
|
109 void ConstructL(); |
|
110 CNSmlObexCommSession( CNSmlObexCommServer& aServer ); |
|
111 ~CNSmlObexCommSession(); |
|
112 void PanicClient( TInt aReason ) const; |
|
113 |
|
114 void ClientReceivePacketL(); |
|
115 void ServerGetSendPacketL(); |
|
116 void ServerHandleDisconnect( TInt aResult ); |
|
117 void DoCancelGetSendPacket(); |
|
118 private: |
|
119 CNSmlObexCommServer& iServer; |
|
120 }; |
|
121 |
|
122 // --------------------------------------------------------------------------------------- |
|
123 // CNSmlTimeOut |
|
124 // --------------------------------------------------------------------------------------- |
|
125 typedef void (CNSmlObexCommSession::*TNSmlTimeoutCallback)(); |
|
126 |
|
127 class CNSmlTimeOut : public CActive |
|
128 { |
|
129 public: |
|
130 static CNSmlTimeOut* NewL(); |
|
131 ~CNSmlTimeOut(); |
|
132 void RunL(); |
|
133 void DoCancel(); |
|
134 |
|
135 void StartTimeoutHandling( CNSmlObexCommSession* aThis, TNSmlTimeoutCallback aCallback ); |
|
136 private: |
|
137 CNSmlTimeOut(); |
|
138 private: |
|
139 RTimer iTimer; |
|
140 CNSmlObexCommSession* iThis; |
|
141 TNSmlTimeoutCallback iCallback; |
|
142 }; |
|
143 |
|
144 #endif // __NSMLOBEXCOMMSERVER_H__ |