0
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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 the License "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 |
// INCLUDE FILES
|
|
19 |
#include "cusbpnserver.h"
|
|
20 |
#include "cusbpnserversession.h"
|
|
21 |
#include "cusbpninterface.h"
|
|
22 |
#include "usbpntrace.h"
|
|
23 |
|
|
24 |
#include "osttracedefinitions.h"
|
|
25 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
26 |
#include "cusbpnserverTraces.h"
|
|
27 |
#endif
|
|
28 |
|
|
29 |
// EXTERNAL DATA STRUCTURES
|
|
30 |
// EXTERNAL FUNCTION PROTOTYPES
|
|
31 |
// CONSTANTS
|
|
32 |
// MACROS
|
|
33 |
// LOCAL CONSTANTS AND MACROS
|
|
34 |
// MODULE DATA STRUCTURES
|
|
35 |
// LOCAL FUNCTION PROTOTYPES
|
|
36 |
// FORWARD DECLARATIONS
|
|
37 |
//class ?FORWARD_CLASSNAME;
|
|
38 |
|
|
39 |
// ============================= LOCAL FUNCTIONS ===============================
|
|
40 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
41 |
|
|
42 |
// -----------------------------------------------------------------------------
|
|
43 |
// CUsbPnServer::CUsbPnServer
|
|
44 |
// C++ default constructor can NOT contain any code, that
|
|
45 |
// might leave.
|
|
46 |
// -----------------------------------------------------------------------------
|
|
47 |
//
|
|
48 |
CUsbPnServer::CUsbPnServer()
|
|
49 |
:CServer2(CActive::EPriorityStandard)
|
|
50 |
,iSessionCount(0)
|
|
51 |
{
|
|
52 |
OstTrace0( TRACE_NORMAL, CUSBPNSERVER_CUSBPNSERVER_ENTRY, "CUsbPnServer::CUsbPnServer" );
|
|
53 |
C_TRACE( ( _T( "CUsbPnServer::CUsbPnServer()" ) ) );
|
|
54 |
|
|
55 |
OstTrace0( TRACE_NORMAL, CUSBPNSERVER_CUSBPNSERVER_EXIT, "CUsbPnServer::CUsbPnServer - return" );
|
|
56 |
C_TRACE( ( _T( "CUsbPnServer::CUsbPnServer() - return" ) ) );
|
|
57 |
}
|
|
58 |
|
|
59 |
// -----------------------------------------------------------------------------
|
|
60 |
// CUsbPnServer::ConstructL
|
|
61 |
// Symbian 2nd phase constructor can leave.
|
|
62 |
// -----------------------------------------------------------------------------
|
|
63 |
//
|
|
64 |
void CUsbPnServer::ConstructL()
|
|
65 |
{
|
|
66 |
OstTrace0( TRACE_NORMAL, CUSBPNSERVER_CONSTRUCTL_ENTRY, "CUsbPnServer::ConstructL" );
|
|
67 |
C_TRACE( ( _T( "CUsbPnServer::ConstructL()" ) ) );
|
|
68 |
|
|
69 |
StartL( KUsbPnServerName );
|
|
70 |
iInterface = CUsbPnInterface::NewL();
|
|
71 |
|
|
72 |
OstTrace0( TRACE_NORMAL, CUSBPNSERVER_CONSTRUCTL_EXIT, "CUsbPnServer::ConstructL - return void" );
|
|
73 |
C_TRACE( ( _T( "CUsbPnServer::ConstructL() - return void" ) ) );
|
|
74 |
}
|
|
75 |
|
|
76 |
// -----------------------------------------------------------------------------
|
|
77 |
// CUsbPnServer::NewL
|
|
78 |
// Two-phased constructor.
|
|
79 |
// -----------------------------------------------------------------------------
|
|
80 |
//
|
|
81 |
CUsbPnServer* CUsbPnServer::NewL()
|
|
82 |
{
|
|
83 |
OstTrace0( TRACE_NORMAL, CUSBPNSERVER_NEWL_ENTRY, "CUsbPnServer::NewL" );
|
|
84 |
C_TRACE( ( _T( "CUsbPnServer::NewL()" ) ) );
|
|
85 |
|
|
86 |
CUsbPnServer* self = new( ELeave ) CUsbPnServer;
|
|
87 |
|
|
88 |
CleanupStack::PushL( self );
|
|
89 |
self->ConstructL();
|
|
90 |
CleanupStack::Pop( self );
|
|
91 |
|
|
92 |
OstTrace1( TRACE_NORMAL, CUSBPNSERVER_NEWL_EXIT, "CUsbPnServer::NewL - return;self=%x", self );
|
|
93 |
C_TRACE( ( _T( "CUsbPnServer::NewL() - return 0x%x" ), self ) );
|
|
94 |
return self;
|
|
95 |
}
|
|
96 |
|
|
97 |
|
|
98 |
// Destructor
|
|
99 |
CUsbPnServer::~CUsbPnServer()
|
|
100 |
{
|
|
101 |
OstTrace0( TRACE_NORMAL, CUSBPNSERVER_CUSBPNSERVER_DESTRUCTOR_ENTRY, "CUsbPnServer::~CUsbPnServer" );
|
|
102 |
C_TRACE( ( _T( "CUsbPnServer::~CUsbPnServer()" ) ) );
|
|
103 |
|
|
104 |
if( iInterface )
|
|
105 |
{
|
|
106 |
delete iInterface;
|
|
107 |
}
|
|
108 |
iInterface = NULL;
|
|
109 |
iSessionCount = 0;
|
|
110 |
|
|
111 |
OstTrace0( TRACE_NORMAL, CUSBPNSERVER_CUSBPNSERVER_DESTRUCTOR_EXIT, "CUsbPnServer::~CUsbPnServer - return" );
|
|
112 |
C_TRACE( ( _T( "CUsbPnServer::~CUsbPnServer() - return" ) ) );
|
|
113 |
}
|
|
114 |
|
|
115 |
|
|
116 |
// -----------------------------------------------------------------------------
|
|
117 |
// CUsbPnServer::NewSessionL
|
|
118 |
// ?implementation_description
|
|
119 |
// (other items were commented in a header).
|
|
120 |
// -----------------------------------------------------------------------------
|
|
121 |
//
|
|
122 |
CSession2* CUsbPnServer::NewSessionL(
|
|
123 |
const TVersion& aVersion,
|
|
124 |
const RMessage2& aMessage ) const
|
|
125 |
{
|
|
126 |
OstTrace0( TRACE_NORMAL, CUSBPNSERVER_NEWSESSIONL_ENTRY, "CUsbPnServer::NewSessionL" );
|
|
127 |
C_TRACE( ( _T( "CUsbPnServer::NewSessionL()" ) ) );
|
|
128 |
|
|
129 |
aMessage.HasCapabilityL( ECapabilityCommDD );
|
|
130 |
|
|
131 |
CSession2* session = new(ELeave) CUsbPnServerSession( const_cast<CUsbPnServer&>(*this) );
|
|
132 |
|
|
133 |
OstTrace1( TRACE_NORMAL, CUSBPNSERVER_NEWSESSIONL_EXIT, "CUsbPnServer::NewSessionL - return;session=%x", session );
|
|
134 |
C_TRACE( ( _T( "CUsbPnServer::NewSessionL() - return 0x%x" ), session ) );
|
|
135 |
|
|
136 |
return session;
|
|
137 |
}
|
|
138 |
// -----------------------------------------------------------------------------
|
|
139 |
// CUsbPnServer::SessionOpened
|
|
140 |
// ?implementation_description
|
|
141 |
// (other items were commented in a header).
|
|
142 |
// -----------------------------------------------------------------------------
|
|
143 |
//
|
|
144 |
void CUsbPnServer::SessionOpened()
|
|
145 |
{
|
|
146 |
OstTrace0( TRACE_NORMAL, CUSBPNSERVER_SESSIONOPENED_ENTRY, "CUsbPnServer::SessionOpened" );
|
|
147 |
C_TRACE( ( _T( "CUsbPnServer::SessionOpened()" ) ) );
|
|
148 |
|
|
149 |
iSessionCount++;
|
|
150 |
OstTrace1( TRACE_NORMAL, CUSBPNSERVER_SESSIONOPENED, "CUsbPnServer::SessionOpened - session count = 0x%x", iSessionCount );
|
|
151 |
C_TRACE( ( _T( "CUsbPnServer::SessionOpened() - session count = 0x%x" ), iSessionCount ) );
|
|
152 |
|
|
153 |
OstTrace0( TRACE_NORMAL, CUSBPNSERVER_SESSIONOPENED_EXIT, "CUsbPnServer::SessionOpened - return void" );
|
|
154 |
C_TRACE( ( _T( "CUsbPnServer::SessionOpened() - return void" ) ) );
|
|
155 |
}
|
|
156 |
|
|
157 |
// -----------------------------------------------------------------------------
|
|
158 |
// CUsbPnServer::SessionClosed
|
|
159 |
// ?implementation_description
|
|
160 |
// (other items were commented in a header).
|
|
161 |
// -----------------------------------------------------------------------------
|
|
162 |
//
|
|
163 |
void CUsbPnServer::SessionClosed()
|
|
164 |
{
|
|
165 |
OstTrace0( TRACE_NORMAL, CUSBPNSERVER_SESSIONCLOSED_ENTRY, "CUsbPnServer::SessionClosed" );
|
|
166 |
C_TRACE( ( _T( "CUsbPnServer::SessionClosed()" ) ) );
|
|
167 |
|
|
168 |
iSessionCount--;
|
|
169 |
OstTrace1( TRACE_NORMAL, CUSBPNSERVER_SESSIONCLOSED, "CUsbPnServer::SessionClosed - session count = 0x%x", iSessionCount );
|
|
170 |
C_TRACE( ( _T( "CUsbPnServer::SessionClosed() - session count = 0x%x" ), iSessionCount ) );
|
|
171 |
|
|
172 |
if( iSessionCount == 0 )
|
|
173 |
{
|
|
174 |
OstTrace0( TRACE_NORMAL, CUSBPNSERVER_SESSIONCLOSED_DUP1, "CUsbPnServer::SessionClosed - shutdown USBPNServer" );
|
|
175 |
C_TRACE( ( _T( "CUsbPnServer::SessionClosed() - shutdown USBPNServer" ) ) );
|
|
176 |
CActiveScheduler::Stop();
|
|
177 |
}
|
|
178 |
|
|
179 |
OstTrace0( TRACE_NORMAL, CUSBPNSERVER_SESSIONCLOSED_EXIT, "CUsbPnServer::SessionClosed - return void" );
|
|
180 |
C_TRACE( ( _T( "CUsbPnServer::SessionClosed() - return void" ) ) );
|
|
181 |
}
|
|
182 |
|
|
183 |
// -----------------------------------------------------------------------------
|
|
184 |
// CUsbPnServer::Detach
|
|
185 |
// Deletes interface so it's safe for class controller's Stop() to return
|
|
186 |
// (other items were commented in a header).
|
|
187 |
// -----------------------------------------------------------------------------
|
|
188 |
//
|
|
189 |
void CUsbPnServer::Detach()
|
|
190 |
{
|
|
191 |
OstTrace0( TRACE_NORMAL, CUSBPNSERVER_DETACH_ENTRY, "CUsbPnServer::Detach" );
|
|
192 |
C_TRACE( ( _T( "CUsbPnServer::Detach()" ) ) );
|
|
193 |
|
|
194 |
// Delete delete interface if last session and it exists
|
|
195 |
if( (iSessionCount < 2) && (iInterface) )
|
|
196 |
{
|
|
197 |
delete iInterface;
|
|
198 |
}
|
|
199 |
iInterface = NULL;
|
|
200 |
|
|
201 |
OstTrace0( TRACE_NORMAL, CUSBPNSERVER_DETACH_EXIT, "CUsbPnServer::Detach - return void" );
|
|
202 |
C_TRACE( ( _T( "CUsbPnServer::Detach() - return void" ) ) );
|
|
203 |
}
|
|
204 |
|
|
205 |
// ========================== OTHER EXPORTED FUNCTIONS =========================
|
|
206 |
|
|
207 |
// End of File
|