|
1 /** @file |
|
2 * Copyright (c) 2005-2006 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: Message handler |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include "upnpmessagehandler.h" |
|
20 #define KLogFile _L("UpnpMessageHandler.txt") |
|
21 #include "upnpcustomlog.h" |
|
22 |
|
23 const TVersion KServerSupportedVersion( KMessageHandlerMajorVersionNumber, |
|
24 KMessageHandlerMinorVersionNumber, KMessageHandlerBuildVersionNumber ); |
|
25 |
|
26 // ================= MEMBER FUNCTIONS ======================= |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // CUpnpMessageHandler::CUpnpMessageHandler |
|
30 // C++ default constructor can NOT contain any code, that |
|
31 // might leave. |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 CUpnpMessageHandler::CUpnpMessageHandler() |
|
35 { |
|
36 LOG_FUNC_NAME; |
|
37 } |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CUpnpMessageHandler::~CUpnpMessageHandler |
|
41 // Destructor. |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 CUpnpMessageHandler::~CUpnpMessageHandler() |
|
45 { |
|
46 LOG_FUNC_NAME; |
|
47 iObservers.Close(); |
|
48 delete iEngine; |
|
49 } |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CUpnpMessageHandler::NewLC |
|
53 // Two-phased constructor. |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 CUpnpSymbianServerBase* CUpnpMessageHandler::NewLC() |
|
57 { |
|
58 LOG_FUNC_NAME; |
|
59 CUpnpMessageHandler* messageHandler = new (ELeave) CUpnpMessageHandler(); |
|
60 CleanupStack::PushL( messageHandler ); |
|
61 messageHandler->ConstructL() ; |
|
62 return messageHandler; |
|
63 } |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // CUpnpMessageHandler::ConstructL |
|
67 // Symbian 2nd phase constructor can leave. |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 void CUpnpMessageHandler::ConstructL() |
|
71 { |
|
72 LOG_FUNC_NAME; |
|
73 BaseConstructL(); |
|
74 iEngine = CUpnpMessageHandlerEngine::NewL( *this ); |
|
75 } |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CUpnpMessageHandler::ServerName |
|
79 // Return name of the server |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 const TDesC& CUpnpMessageHandler::ServerName() const |
|
83 { |
|
84 return KMessageHandlerName; |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CUpnpMessageHandler::NewSessionL |
|
89 // Create new session. |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 CSession2* CUpnpMessageHandler::NewSessionL( const RMessage2& /*aMsg*/) const |
|
93 { |
|
94 LOG_FUNC_NAME; |
|
95 return CUpnpMessageHandlerSession::NewL( |
|
96 *const_cast<CUpnpMessageHandler*> ( this ), *iEngine ); |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // CUpnpMessageHandler::SupportedVersion |
|
101 // Gets server supported version. |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 TVersion CUpnpMessageHandler::SupportedVersion() const |
|
105 { |
|
106 return KServerSupportedVersion; |
|
107 } |
|
108 |
|
109 // ============================= LOCAL FUNCTIONS =============================== |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // E32Main entry point. |
|
113 // Returns: KErrNone |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 TInt E32Main() |
|
117 { |
|
118 return CUpnpMessageHandler::StartServer( KMessageHandlerThreadName, |
|
119 CUpnpMessageHandler::NewLC ); |
|
120 } |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // CUpnpMessageHandler::DeviceListUpdateL |
|
124 // Update device list. |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 void CUpnpMessageHandler::DeviceListUpdateL() |
|
128 { |
|
129 LOG_FUNC_NAME; |
|
130 // Inform every Observer (every session) that the device list has changed |
|
131 for ( TInt i(0); i < iObservers.Count(); i++ ) |
|
132 { |
|
133 iObservers[i]->DeviceListChangeL(); |
|
134 } |
|
135 } |
|
136 |
|
137 // ----------------------------------------------------------------------------- |
|
138 // CUpnpMessageHandler::AddObserverL |
|
139 // Add observer. |
|
140 // ----------------------------------------------------------------------------- |
|
141 // |
|
142 void CUpnpMessageHandler::AddObserverL( MMessageHandlerObserver* aObserver ) |
|
143 { |
|
144 LOG_FUNC_NAME; |
|
145 iObservers.InsertL( aObserver, iObservers.Count() ); |
|
146 } |
|
147 |
|
148 // ----------------------------------------------------------------------------- |
|
149 // CUpnpMessageHandler::RemoveObserver |
|
150 // Remove observer. |
|
151 // ----------------------------------------------------------------------------- |
|
152 // |
|
153 void CUpnpMessageHandler::RemoveObserver( MMessageHandlerObserver* aObserver ) |
|
154 { |
|
155 LOG_FUNC_NAME; |
|
156 LOGS1( "CUpnpMessageHandler::RemoveObserver - Count: %d", iObservers.Count()); |
|
157 |
|
158 for ( TInt i(0); i < iObservers.Count(); i++ ) |
|
159 { |
|
160 if ( iObservers[i] == aObserver ) |
|
161 { |
|
162 LOGS1( "CUpnpMessageHandler::RemoveObserver - Removed osb: %d",i); |
|
163 iObservers.Remove( i ); |
|
164 iObservers.Compress(); |
|
165 } |
|
166 } |
|
167 } |
|
168 |
|
169 // ----------------------------------------------------------------------------- |
|
170 // CUpnpMessageHandler::RunError |
|
171 // RunError is called when RunL leaves. |
|
172 // ----------------------------------------------------------------------------- |
|
173 // |
|
174 TInt CUpnpMessageHandler::RunError( TInt aError ) |
|
175 { |
|
176 LOG_FUNC_NAME; |
|
177 iStartingError = aError; |
|
178 return CUpnpSymbianServerBase::RunError( aError ); |
|
179 } |
|
180 |
|
181 // ----------------------------------------------------------------------------- |
|
182 // CUpnpMessageHandler::IsSsdpStarted |
|
183 // Set function for iSsdpStarted |
|
184 // ----------------------------------------------------------------------------- |
|
185 // |
|
186 TBool CUpnpMessageHandler::IsSsdpStarted() |
|
187 { |
|
188 return iSsdpStarted; |
|
189 } |
|
190 |
|
191 // ----------------------------------------------------------------------------- |
|
192 // CUpnpMessageHandler::GetError |
|
193 // ----------------------------------------------------------------------------- |
|
194 // |
|
195 TInt CUpnpMessageHandler::StartingError() |
|
196 { |
|
197 return iStartingError; |
|
198 } |
|
199 |
|
200 // ----------------------------------------------------------------------------- |
|
201 // CUpnpMessageHandler::SetStarted |
|
202 // Set function for iSsdpStarted |
|
203 // ----------------------------------------------------------------------------- |
|
204 // |
|
205 void CUpnpMessageHandler::SetSsdpStarted( TBool aStarted ) |
|
206 { |
|
207 iSsdpStarted = aStarted; |
|
208 } |
|
209 |
|
210 // ----------------------------------------------------------------------------- |
|
211 // CUpnpMessageHandler::Sessions |
|
212 // Returns client sessions |
|
213 // ----------------------------------------------------------------------------- |
|
214 // |
|
215 TDblQueIter< CSession2 >& CUpnpMessageHandler::Sessions() |
|
216 { |
|
217 return iSessionIter; |
|
218 } |
|
219 |
|
220 // ----------------------------------------------------------------------------- |
|
221 // CUpnpMessageHandler::IPListChange |
|
222 // Notify all observers |
|
223 // ----------------------------------------------------------------------------- |
|
224 // |
|
225 void CUpnpMessageHandler::IPListChange() |
|
226 { |
|
227 #ifdef RD_UPNP_REMOTE_ACCESS |
|
228 for(TInt i(0); i < iObservers.Count(); i++) |
|
229 { |
|
230 iObservers[i]->IPListChange(); |
|
231 } |
|
232 #endif |
|
233 } |
|
234 |
|
235 // End of File |