usbmgmt/usbmgr/device/classdrivers/ncm/classimplementation/ncmpktdrv/server/src/ncmserver.cpp
branchRCL_3
changeset 15 f92a4f87e424
equal deleted inserted replaced
14:d3e8e7d462dd 15:f92a4f87e424
       
     1 /*
       
     2 * Copyright (c) 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 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalComponent
       
    21 */
       
    22 
       
    23 
       
    24 #include "ncmserver.h"
       
    25 #include "ncmsession.h"
       
    26 #include "ncmserversecuritypolicy.h"
       
    27 #include "ncmserverconsts.h"
       
    28 
       
    29 
       
    30 CNcmServer* CNcmServer::NewL(CNcmEngine& aEngine)
       
    31     {
       
    32     CNcmServer* self = new(ELeave) CNcmServer(aEngine);
       
    33     CleanupStack::PushL(self);
       
    34     TInt err = self->Start(KNcmServerName);
       
    35     // KErrAlreadyExists is a success case (c.f. transient server boilerplate
       
    36     // code).
       
    37     if ( err != KErrAlreadyExists )
       
    38         {
       
    39         User::LeaveIfError(err);
       
    40         }
       
    41     CleanupStack::Pop(self);
       
    42     return self;
       
    43     }
       
    44 
       
    45 CNcmServer::~CNcmServer()
       
    46     {
       
    47     }
       
    48 
       
    49 CNcmServer::CNcmServer(CNcmEngine& aEngine)
       
    50  :  CPolicyServer(CActive::EPriorityStandard, KNcmServerPolicy, ESharableSessions),
       
    51     iNcmEngine(aEngine)
       
    52     {
       
    53     }
       
    54 
       
    55 CSession2* CNcmServer::NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const
       
    56     {
       
    57     //Validate session as coming from UsbSvr
       
    58     static _LIT_SECURITY_POLICY_S0(KSidPolicy, 0x101fe1db);
       
    59     TBool auth = KSidPolicy.CheckPolicy(aMessage);
       
    60     if(!auth)
       
    61         {
       
    62         User::Leave(KErrPermissionDenied);
       
    63         }
       
    64 
       
    65     // Version number check...
       
    66     TVersion v( KNcmSrvMajorVersionNumber,
       
    67                 KNcmSrvMinorVersionNumber,
       
    68                 KNcmSrvBuildNumber);
       
    69 
       
    70     if ( !User::QueryVersionSupported(v, aVersion) )
       
    71         {
       
    72         User::Leave(KErrNotSupported);
       
    73         }
       
    74 
       
    75     CNcmSession* sess = CNcmSession::NewL(iNcmEngine);
       
    76     return sess;
       
    77     }