|
1 /* |
|
2 * Copyright (c) 2009-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 * Initial Contributors: |
|
9 * Nokia Corporation - initial contribution. |
|
10 * Contributors: |
|
11 * |
|
12 * Description: |
|
13 * MSRP Implementation |
|
14 * |
|
15 */ |
|
16 |
|
17 // CLASS HEADER |
|
18 #include "CMSRPServer.h" |
|
19 |
|
20 // INTERNAL INCLUDE FILES |
|
21 #include "MSRPCommon.h" |
|
22 #include "MSRPServerCommon.h" |
|
23 #include "CMSRPServerSession.h" |
|
24 #include "CMSRPConnectionManager.h" |
|
25 #include "TStateFactory.h" |
|
26 |
|
27 // ============================ MEMBER FUNCTIONS =============================== |
|
28 |
|
29 // ----------------------------------------------------------------------------- |
|
30 // CMSRPServer::CMSRPServer |
|
31 // Constructor |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 CMSRPServer::CMSRPServer() : |
|
35 CPolicyServer( EPriorityStandard, MSRPServerPolicy, ESharableSessions ) |
|
36 { |
|
37 MSRPLOG( "MSRPServer: CMSRPServer::CMSRPServer enter" ) |
|
38 MSRPLOG( "MSRPServer: CMSRPServer::CMSRPServer exit" ) |
|
39 } |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CMSRPServer::ConstructL |
|
43 // 2nd phase constructor |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 void CMSRPServer::ConstructL() |
|
47 { |
|
48 MSRPLOG( "MSRPServer: CMSRPServer::ConstructL enter" ) |
|
49 |
|
50 //const TInt err( Start( KMSRPServerName ) ); |
|
51 //__ASSERT_ALWAYS( err == KErrNone, PanicServer( EMSRPServerStartError ) ); |
|
52 StartL( KMSRPServerName ); |
|
53 |
|
54 MSRPLOG( "MSRPServer: CMSRPServer::ConstructL exit" ) |
|
55 } |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CMSRPServer::NewL |
|
59 // Two-phased constructor. |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 CMSRPServer* CMSRPServer::NewLC() |
|
63 { |
|
64 MSRPLOG( "MSRPServer::NewL enter" ) |
|
65 |
|
66 CMSRPServer* self = new( ELeave ) CMSRPServer(); |
|
67 |
|
68 CleanupStack::PushL( self ); |
|
69 self->ConstructL(); |
|
70 |
|
71 MSRPLOG( "CMSRPServer::NewL exit" ) |
|
72 return self; |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CMSRPServer::~CMSRPServer |
|
77 // destructor |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 CMSRPServer::~CMSRPServer() |
|
81 { |
|
82 MSRPLOG( "CMSRPServer::~CMSRPServer enter" ) |
|
83 |
|
84 if( iStateFactory ) |
|
85 { |
|
86 delete iStateFactory; |
|
87 iStateFactory = NULL; |
|
88 } |
|
89 |
|
90 delete iConnectionManager; |
|
91 MSRPLOG( "CMSRPServer::~CMSRPServer exit" ) |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CMSRPServer::NewSessionL |
|
96 // Creates new session if the clients version number matches with server |
|
97 // version number |
|
98 // (other items were commented in a header). |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 CSession2* CMSRPServer::NewSessionL( |
|
102 const TVersion &aVersion, // Clients version of the server |
|
103 const RMessage2& /*aMessage*/ ) const // Message |
|
104 { |
|
105 MSRPLOG( "CMSRPServer::NewSessionL enter" ) |
|
106 |
|
107 // Check we're the right version. |
|
108 TVersion versionInfo( KMSRPServerMajorVersionNumber, |
|
109 KMSRPServerMinorVersionNumber, |
|
110 KMSRPServerBuildVersionNumber ); |
|
111 |
|
112 if ( !User::QueryVersionSupported( versionInfo, aVersion ) ) |
|
113 { |
|
114 User::Leave( KErrNotSupported ); |
|
115 } |
|
116 |
|
117 // let's create the session |
|
118 CMSRPServer* self = const_cast< CMSRPServer* >( this ); |
|
119 CMSRPServerSession* session = |
|
120 CMSRPServerSession::NewL( *self ); |
|
121 |
|
122 MSRPLOG( "CMSRPServer::NewSessionL exit" ) |
|
123 return session; |
|
124 } |
|
125 |
|
126 // ---------------------------------------------------------------------------- |
|
127 // CMSRPServer::ConnectionManager |
|
128 // ---------------------------------------------------------------------------- |
|
129 // |
|
130 MMSRPConnectionManager& CMSRPServer::ConnectionManager() const |
|
131 { |
|
132 return *iConnectionManager; |
|
133 } |
|
134 |
|
135 CStateFactory& CMSRPServer::StateFactory() const |
|
136 { |
|
137 return *iStateFactory; |
|
138 } |
|
139 |
|
140 |
|
141 // ---------------------------------------------------------------------------- |
|
142 // CMSRPServer::SessionCreated |
|
143 // ---------------------------------------------------------------------------- |
|
144 // |
|
145 void CMSRPServer::SessionCreated() |
|
146 { |
|
147 MSRPLOG2( "CMSRPServer::SessionCreated enter, count = %d", iSessionCount ) |
|
148 iSessionCount++; |
|
149 MSRPLOG2( "CMSRPServer::SessionCreated exit, count = %d", iSessionCount ) |
|
150 } |
|
151 |
|
152 |
|
153 // ---------------------------------------------------------------------------- |
|
154 // CMSRPServer::SessionCreated |
|
155 // ---------------------------------------------------------------------------- |
|
156 // |
|
157 void CMSRPServer::CreatingSubSessionL( const TUint aIapID ) |
|
158 { |
|
159 MSRPLOG( "CMSRPServer::CreatingSubSessionL ") |
|
160 if ( !iConnectionManager ) |
|
161 { |
|
162 iConnectionManager = CMSRPConnectionManager::NewL( aIapID,*this ); |
|
163 } |
|
164 |
|
165 if ( !iStateFactory ) |
|
166 { |
|
167 iStateFactory = CStateFactory::NewL( ); |
|
168 } |
|
169 MSRPLOG( "CMSRPServer::SubSessionCreated exit") |
|
170 } |
|
171 |
|
172 |
|
173 // ---------------------------------------------------------------------------- |
|
174 // CMSRPServer::SessionDeleted |
|
175 // ---------------------------------------------------------------------------- |
|
176 // |
|
177 void CMSRPServer::SessionDeleted() |
|
178 { |
|
179 iSessionCount--; |
|
180 if( !iSessionCount ) |
|
181 { |
|
182 delete iConnectionManager; |
|
183 iConnectionManager = NULL; |
|
184 CActiveScheduler::Stop(); |
|
185 } |
|
186 } |
|
187 |
|
188 void CMSRPServer::HandleError(TInt /*aError*/, TInt /*aStatus*/, MMSRPConnection& /*aConnection*/) |
|
189 { |
|
190 |
|
191 // Really no use of the observer. Connection errors should be informed via Connection!! |
|
192 |
|
193 } |
|
194 |
|
195 |
|
196 // End of File |