|
1 /* |
|
2 * Copyright (c) 2007-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 "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 * ACM server. |
|
16 * |
|
17 */ |
|
18 |
|
19 /** |
|
20 @file |
|
21 @internalComponent |
|
22 */ |
|
23 |
|
24 #include <usb/usblogger.h> |
|
25 #include "acmserver.h" |
|
26 #include "acmsession.h" |
|
27 #include "acmserversecuritypolicy.h" |
|
28 #include "acmserverconsts.h" |
|
29 |
|
30 #ifdef __FLOG_ACTIVE |
|
31 _LIT8(KLogComponent, "ECACM"); |
|
32 #endif |
|
33 |
|
34 CAcmServer* CAcmServer::NewL(MAcmController& aAcmController) |
|
35 { |
|
36 LOG_STATIC_FUNC_ENTRY |
|
37 |
|
38 CAcmServer* self = new(ELeave) CAcmServer(aAcmController); |
|
39 CleanupStack::PushL(self); |
|
40 TInt err = self->Start(KAcmServerName); |
|
41 // KErrAlreadyExists is a success case (c.f. transient server boilerplate |
|
42 // code). |
|
43 if ( err != KErrAlreadyExists ) |
|
44 { |
|
45 LEAVEIFERRORL(err); |
|
46 } |
|
47 CleanupStack::Pop(self); |
|
48 return self; |
|
49 } |
|
50 |
|
51 CAcmServer::~CAcmServer() |
|
52 { |
|
53 LOG_FUNC |
|
54 } |
|
55 |
|
56 CAcmServer::CAcmServer(MAcmController& aAcmController) |
|
57 : CPolicyServer(CActive::EPriorityStandard, KAcmServerPolicy), |
|
58 iAcmController(aAcmController) |
|
59 { |
|
60 } |
|
61 |
|
62 CSession2* CAcmServer::NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const |
|
63 { |
|
64 LOG_FUNC |
|
65 |
|
66 //Validate session as coming from UsbSvr |
|
67 static _LIT_SECURITY_POLICY_S0(KSidPolicy, 0x101fe1db); |
|
68 TBool auth = KSidPolicy.CheckPolicy(aMessage); |
|
69 if(!auth) |
|
70 { |
|
71 LEAVEIFERRORL(KErrPermissionDenied); |
|
72 } |
|
73 |
|
74 // Version number check... |
|
75 TVersion v( KAcmSrvMajorVersionNumber, |
|
76 KAcmSrvMinorVersionNumber, |
|
77 KAcmSrvBuildNumber); |
|
78 |
|
79 if ( !User::QueryVersionSupported(v, aVersion) ) |
|
80 { |
|
81 LEAVEIFERRORL(KErrNotSupported); |
|
82 } |
|
83 |
|
84 CAcmSession* sess = CAcmSession::NewL(iAcmController); |
|
85 LOGTEXT2(_L8("\tsess = 0x%08x"), sess); |
|
86 return sess; |
|
87 } |