javacommons/comms/ipclib/clientserver/src.s60/commsserver.cpp
changeset 21 2a9601315dfc
equal deleted inserted replaced
18:e8e63152f320 21:2a9601315dfc
       
     1 /*
       
     2 * Copyright (c) 2008 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: CCommsServer implements the Symbian IPC server
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <e32std.h>
       
    20 
       
    21 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    22 #include <e32def_private.h>
       
    23 #endif
       
    24 
       
    25 #include "logger.h"
       
    26 
       
    27 #include "commssession.h"
       
    28 #include "commsserver.h"
       
    29 #include "commspermissions.h"
       
    30 #include "common.h"
       
    31 
       
    32 namespace java
       
    33 {
       
    34 namespace comms
       
    35 {
       
    36 
       
    37 const TInt KRangeCnt = 1;
       
    38 const TInt Ranges[KRangeCnt] =
       
    39 {
       
    40     0
       
    41 };
       
    42 
       
    43 const TUint8 PolicyInds[] =
       
    44 {
       
    45     CPolicyServer::EAlwaysPass
       
    46 };
       
    47 
       
    48 const CPolicyServer::TPolicy Policy =
       
    49 {
       
    50     CPolicyServer::EAlwaysPass,    // on connect
       
    51     KRangeCnt,
       
    52     Ranges,
       
    53     PolicyInds,
       
    54     0 // Mandatory spare
       
    55 };
       
    56 
       
    57 CCommsServer::CCommsServer(IpcListener& aListener)
       
    58         : CPolicyServer(EPriorityStandard, Policy, ESharableSessions), mListener(aListener)
       
    59 {
       
    60 }
       
    61 
       
    62 CCommsServer::~CCommsServer()
       
    63 {
       
    64 }
       
    65 
       
    66 
       
    67 CSession2* CCommsServer::NewSessionL(const TVersion& /* aVersion */, const RMessage2& aMessage) const
       
    68 {
       
    69     int permissions = getPermissions(aMessage);
       
    70     return new(ELeave) CCommsSession(mListener, permissions);
       
    71 }
       
    72 
       
    73 void CCommsServer::StartL(const TDesC& aName)
       
    74 {
       
    75     CPolicyServer::StartL(aName);
       
    76 }
       
    77 
       
    78 int CCommsServer::getPermissions(const RMessage2& aMessage) const
       
    79 {
       
    80     int permissions = 0;
       
    81 
       
    82     if (aMessage.HasCapability(ECapabilityWriteDeviceData,
       
    83                                __PLATSEC_DIAGNOSTIC_STRING("javacomms: certificate management not allowed")))
       
    84     {
       
    85         permissions |= MANAGE_CERTIFICATES;
       
    86     }
       
    87 
       
    88     if (aMessage.HasCapability(ECapabilityTrustedUI,
       
    89                                __PLATSEC_DIAGNOSTIC_STRING("javacomms: install application not allowed")))
       
    90     {
       
    91         permissions |= INSTALL_APPLICATION;
       
    92     }
       
    93 
       
    94     if (aMessage.HasCapability(ECapabilityNetworkControl,
       
    95                                __PLATSEC_DIAGNOSTIC_STRING("javacomms: launch application not allowed")))
       
    96     {
       
    97         permissions |= LAUNCH_APPLICATION;
       
    98     }
       
    99 
       
   100     if (aMessage.HasCapability(ECapabilityPowerMgmt,
       
   101                                __PLATSEC_DIAGNOSTIC_STRING("javacomms: stop application not allowed")))
       
   102     {
       
   103         permissions |= STOP_APPLICATION;
       
   104     }
       
   105 
       
   106     return permissions;
       
   107 }
       
   108 
       
   109 } // namespace comms
       
   110 } // namespace java