|
1 /* |
|
2 * Copyright (c) 2006-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: Header for upnpcontentserver |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 #ifndef __UPNPCONTENTSERVER_H__ |
|
24 #define __UPNPCONTENTSERVER_H__ |
|
25 |
|
26 // INCLUDES |
|
27 #include <e32base.h> |
|
28 #include "upnpconnectionmonitorobserver.h" |
|
29 #include "upnpconnectionmonitor.h" |
|
30 #include "upnpcontentserverhandler.h" |
|
31 #include "upnpcontentserversession.h" |
|
32 |
|
33 // FORWARD DECLARATIONS |
|
34 class CUPnPPeriodic; |
|
35 |
|
36 // Server shutdown delay in microseconds (2.5s) |
|
37 const TInt KShutdownTimeout = 2500000; |
|
38 |
|
39 // FORWARD DECLARATIONS |
|
40 class CUpnpContentServerSession; |
|
41 |
|
42 /** |
|
43 * A server class to initialize server. |
|
44 * |
|
45 * @since S60 3.1 |
|
46 */ |
|
47 class CUpnpContentServer : public CPolicyServer, |
|
48 public MUPnPConnectionMonitorObserver |
|
49 { |
|
50 public: |
|
51 /** |
|
52 * A Method to initialize the CleanupStack and the ActiveScheduler. |
|
53 * Creates an instance of CUpnpContentServer. |
|
54 * @param None. |
|
55 * @return KErrNone, if successful, otherwise one of the other system-wide |
|
56 * error codes. |
|
57 */ |
|
58 static TInt LaunchServerL(); |
|
59 |
|
60 /** |
|
61 * 2-phased constructor. |
|
62 */ |
|
63 static CUpnpContentServer* NewL(); |
|
64 |
|
65 /** |
|
66 * C++ destructor. |
|
67 */ |
|
68 virtual ~CUpnpContentServer(); |
|
69 |
|
70 /** |
|
71 * Returns pointer CUpnpContentserverHandler instanse |
|
72 * @since S60 3.1 |
|
73 */ |
|
74 CUpnpContentServerHandler* Handler() const; |
|
75 |
|
76 /** |
|
77 * Decrements session counter |
|
78 * @since S60 3.1 |
|
79 */ |
|
80 void RemoveSession(); |
|
81 |
|
82 /** |
|
83 * Decrements session counter |
|
84 * @since S60 3.1 |
|
85 */ |
|
86 void AddSession(); |
|
87 |
|
88 /** |
|
89 * Indicates if server can be stopped |
|
90 * @since S60 3.1 |
|
91 * @ return ETrue if there is no other session open |
|
92 */ |
|
93 TBool CanStop() const; |
|
94 |
|
95 /** |
|
96 * Stop the server with delay |
|
97 * @since S60 3.1 |
|
98 */ |
|
99 void Stop(); |
|
100 |
|
101 /** |
|
102 * Perform the shutdown of the server |
|
103 * @return KErrNone |
|
104 */ |
|
105 static TInt Shutdown( TAny* aPtr ); |
|
106 |
|
107 /** |
|
108 * Start the connection monitor if not yet started |
|
109 * Register for connection lost events |
|
110 * @since S60 3.1 |
|
111 */ |
|
112 TInt RequestConnectionLostL( const TInt aIapId ); |
|
113 |
|
114 /** |
|
115 * Stop the connection monitor if only session |
|
116 * unregister the session from connection monitoring |
|
117 * @since S60 3.1 |
|
118 */ |
|
119 void CancelConnectionLostL(); |
|
120 |
|
121 public: |
|
122 /** |
|
123 * From CServer2, creates a new session. |
|
124 */ |
|
125 CSession2* NewSessionL( const TVersion& aVersion, |
|
126 const RMessage2& aMessage ) const; |
|
127 |
|
128 protected: |
|
129 /** |
|
130 * From CServer2, handle possible leaves |
|
131 */ |
|
132 TInt RunError( TInt aError ); |
|
133 |
|
134 private: |
|
135 /** |
|
136 * C++ constructor. |
|
137 */ |
|
138 CUpnpContentServer(); |
|
139 |
|
140 /** |
|
141 * 2nd phase constructor. |
|
142 */ |
|
143 void ConstructL( ); |
|
144 |
|
145 private: |
|
146 /** |
|
147 * From MUPnPConnectionMonitorObserver |
|
148 * Inform all sessions that connection has been lost |
|
149 * @since S60 3.1 |
|
150 */ |
|
151 void ConnectionLost(); |
|
152 |
|
153 |
|
154 private: |
|
155 |
|
156 /** |
|
157 * Server has an object container index which |
|
158 * creates an object container for each session |
|
159 * owned |
|
160 */ |
|
161 CObjectConIx* iContainerIndex; |
|
162 |
|
163 /** |
|
164 * Pointer to handler |
|
165 * owned |
|
166 */ |
|
167 CUpnpContentServerHandler* iHandler; |
|
168 |
|
169 /** |
|
170 * Session count |
|
171 */ |
|
172 TInt iSessionCount; |
|
173 |
|
174 /** |
|
175 * Connection monitor handle |
|
176 */ |
|
177 CUPnPConnectionMonitor* iConMon; |
|
178 |
|
179 /** |
|
180 * Id of the active IAP |
|
181 */ |
|
182 TInt iActiveIapId; |
|
183 |
|
184 /** |
|
185 * Delayer for the server shutdown |
|
186 */ |
|
187 CUPnPPeriodic* iIdle; |
|
188 |
|
189 }; |
|
190 |
|
191 |
|
192 #endif // __UPNPCONTENTSERVER_H__ |
|
193 |