qthighway/xqserviceipc/xqserviceipcserver/xqserviceipcserver_apasymbianserver.cpp
branchRCL_3
changeset 10 cd2778e5acfe
parent 9 5d007b20cfd0
child 11 19a54be74e5e
equal deleted inserted replaced
9:5d007b20cfd0 10:cd2778e5acfe
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 *
       
     5 * This program is free software: you can redistribute it and/or modify
       
     6 * it under the terms of the GNU Lesser General Public License as published by
       
     7 * the Free Software Foundation, version 2.1 of the License.
       
     8 * 
       
     9 * This program is distributed in the hope that it will be useful,
       
    10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12 * GNU Lesser General Public License for more details.
       
    13 *
       
    14 * You should have received a copy of the GNU Lesser General Public License
       
    15 * along with this program.  If not, 
       
    16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/".
       
    17 *
       
    18 * Description:  Symbian implementation for IPC server
       
    19 *
       
    20 */
       
    21 
       
    22 #include "xqservicelog.h"
       
    23 
       
    24 #include "xqserviceipcserver_apasymbianserver.h"
       
    25 #include "xqserviceipcserver_apasymbiansession.h"
       
    26 
       
    27 namespace QtService
       
    28 {
       
    29 // Server Security Policy
       
    30 const TUint KServerRangeCount = 2;
       
    31 const TInt KServerRanges[KServerRangeCount] = { 
       
    32                 0, //range is [0-1)
       
    33                 2 //range is [2-KMaxTInt] 
       
    34                 };
       
    35 const TUint8 KSeverElementsIndex[KServerRangeCount] = { 
       
    36                 0,
       
    37                 CPolicyServer::ENotSupported };
       
    38 
       
    39 const CPolicyServer::TPolicyElement KServerPolicyElements[] = { {
       
    40                 _INIT_SECURITY_POLICY_C1(ECapabilityWriteDeviceData),
       
    41                 CPolicyServer::EFailClient } };
       
    42 
       
    43 const CPolicyServer::TPolicy KServerPolicy = {
       
    44                 CPolicyServer::EAlwaysPass, //specifies all connect attempts should pass
       
    45                 KServerRangeCount, KServerRanges, KSeverElementsIndex,
       
    46                 KServerPolicyElements };
       
    47 
       
    48 enum
       
    49 {
       
    50     EServerPriority = CActive::EPriorityStandard
       
    51 };
       
    52 
       
    53 // ======== MEMBER FUNCTIONS ========
       
    54 
       
    55 /*!
       
    56     \class CApaSymbianServer
       
    57     \brief Symbian client server implementation
       
    58 */
       
    59 
       
    60 /*!
       
    61     Constructor.
       
    62 */
       
    63 CApaSymbianServer::CApaSymbianServer() /*:
       
    64 CPolicyServer( EServerPriority,  KServerPolicy)*/                                                 
       
    65 {
       
    66     XQSERVICE_DEBUG_PRINT("CApaSymbianServer::CApaSymbianServer");
       
    67     SetPriority(EServerPriority);
       
    68 }
       
    69 
       
    70 /*!
       
    71     2nd phased constructor
       
    72 */
       
    73 void CApaSymbianServer::ConstructL()
       
    74 {
       
    75 }
       
    76 
       
    77 /*!
       
    78     Two phased constructor
       
    79 */
       
    80 CApaSymbianServer* CApaSymbianServer::NewL()
       
    81 {
       
    82     XQSERVICE_DEBUG_PRINT("CApaSymbianServer::NewL");
       
    83     CApaSymbianServer* self = new( ELeave ) CApaSymbianServer;
       
    84     CleanupStack::PushL(self);
       
    85     self->ConstructL();
       
    86     CleanupStack::Pop(self);
       
    87     return self;
       
    88 }
       
    89 
       
    90 /*!
       
    91     Destructor
       
    92 */
       
    93 CApaSymbianServer::~CApaSymbianServer()
       
    94 {
       
    95     XQSERVICE_DEBUG_PRINT("CApaSymbianServer::~CApaSymbianServer");
       
    96 }
       
    97 
       
    98 /*!
       
    99     Start listening for new service requests.
       
   100     \param aServerName name of the server.
       
   101     \return true if successful.
       
   102 */
       
   103 bool CApaSymbianServer::listen( const QString& aServerName )
       
   104 {
       
   105     XQSERVICE_DEBUG_PRINT("CApaSymbianServer::listen");
       
   106     XQSERVICE_DEBUG_PRINT("aServerName: %s", qPrintable(aServerName));
       
   107     bool listening(true);
       
   108 
       
   109     // Needs to be here becuase Q_Ptr isonly set after constructor of public
       
   110     iObserver = Observer();
       
   111     TPtrC serverName(reinterpret_cast<const TUint16*> (aServerName.utf16()));
       
   112     TInt err=0;
       
   113     TRAP( err, StartL(serverName) );
       
   114     XQSERVICE_DEBUG_PRINT("listen status=%d", err);
       
   115     if (err != KErrNone) {
       
   116         listening = false;
       
   117     }
       
   118     // Complete the server rendezvous that th client started
       
   119     XQSERVICE_DEBUG_PRINT("CApaSymbianServer::Rendezvouz");
       
   120     RProcess::Rendezvous(KErrNone);
       
   121     XQSERVICE_DEBUG_PRINT("CApaSymbianServer::Rendezvouz done");
       
   122     XQSERVICE_DEBUG_PRINT("listening: %d", listening);
       
   123     return listening;
       
   124 }
       
   125 
       
   126 /*!
       
   127     Shutdown the server and stop serving clients.
       
   128 */
       
   129 void CApaSymbianServer::disconnect()
       
   130 {
       
   131     XQSERVICE_DEBUG_PRINT("CApaSymbianServer::disconnect");
       
   132     // Symbian Servers do not have disconnect, 
       
   133     // the process has to exit
       
   134 }
       
   135 
       
   136 /*!
       
   137     Create a new session, derived from CPolicyServer.
       
   138     \param aVersion Version of the server.
       
   139     \param aMessage Message object.
       
   140 */
       
   141 CSession2* CApaSymbianServer::NewSessionL(const TVersion& aVersion,
       
   142                                           const RMessage2& aMessage) const
       
   143 {
       
   144     XQSERVICE_DEBUG_PRINT("CApaSymbianServer::NewSessionL");
       
   145     TVersion v(1, 0, 0);
       
   146     if (!User::QueryVersionSupported(v, aVersion)) {
       
   147         XQSERVICE_DEBUG_PRINT("Not supported version");
       
   148         User::Leave(KErrNotSupported);
       
   149     }
       
   150 
       
   151     // Create a new Symbian Session for the client
       
   152   return CApaServerSymbianSession::NewL(iObserver);
       
   153 }
       
   154 
       
   155 CPolicyServer::TCustomResult CApaSymbianServer::CreateServiceSecurityCheckL
       
   156                                     ( TUid /*aServiceType*/, 
       
   157                                       const RMessage2& /*aMsg*/, 
       
   158                                       TInt& /*aAction*/,
       
   159                                       TSecurityInfo& /*aMissing*/ )
       
   160 {
       
   161     XQSERVICE_DEBUG_PRINT("CApaSymbianServer::CreateServiceSecurityCheckL");
       
   162     return CPolicyServer::EPass;
       
   163 }
       
   164 
       
   165 }
       
   166 
       
   167 // END OF FILE