usbengines/usbwatcher/src/cusbwatcherserver.cpp
changeset 35 9d8b04ca6939
parent 0 1e05558e2206
equal deleted inserted replaced
34:7858bc6ead78 35:9d8b04ca6939
       
     1 /*
       
     2 * Copyright (c) 2006-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:  USB Watcher server class implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <e32svr.h>
       
    20 #include "usbwatchershared.h"
       
    21 #include "cusbwatcherserver.h"
       
    22 #include "cusbwatchersession.h"
       
    23 #include "usbwatcherserversecuritypolicy.h"
       
    24 #include "cusbwatcher.h"
       
    25 #include "debug.h"
       
    26 
       
    27 // ----------------------------------------------------------------------------
       
    28 // Symbian two-phase constructor
       
    29 // ----------------------------------------------------------------------------
       
    30 //
       
    31 CUsbWatcherServer* CUsbWatcherServer::NewLC()
       
    32     {
       
    33     LOG_FUNC
       
    34 
       
    35     CUsbWatcherServer* r = new ( ELeave ) CUsbWatcherServer();
       
    36     CleanupStack::PushL( r );
       
    37     r->StartL( KUsbWatcherServerName );
       
    38     r->ConstructL();
       
    39     return r;
       
    40     }
       
    41 
       
    42 // ----------------------------------------------------------------------------
       
    43 // Destructor
       
    44 // ----------------------------------------------------------------------------
       
    45 //
       
    46 CUsbWatcherServer::~CUsbWatcherServer()
       
    47     {
       
    48     LOG_FUNC
       
    49 
       
    50     delete iUsbWatcher;
       
    51     }
       
    52 
       
    53 // ----------------------------------------------------------------------------
       
    54 // C++ constructor
       
    55 // ----------------------------------------------------------------------------
       
    56 //
       
    57 CUsbWatcherServer::CUsbWatcherServer()
       
    58      : CPolicyServer( EPriorityHigh, KUsbWatcherServerPolicy )
       
    59     {
       
    60     LOG_FUNC
       
    61 
       
    62     }
       
    63 
       
    64 // ----------------------------------------------------------------------------
       
    65 // Second-phase constructor
       
    66 // ----------------------------------------------------------------------------
       
    67 //
       
    68 void CUsbWatcherServer::ConstructL()
       
    69     {
       
    70     LOG_FUNC
       
    71 
       
    72     iUsbWatcher = CUsbWatcher::NewL();
       
    73     }
       
    74 
       
    75 // ----------------------------------------------------------------------------
       
    76 // Create a new session
       
    77 // ----------------------------------------------------------------------------
       
    78 //
       
    79 CSession2* CUsbWatcherServer::NewSessionL( const TVersion &aVersion,
       
    80         const RMessage2& aMessage ) const
       
    81     {
       
    82     LOG_FUNC
       
    83 
       
    84     (void)aMessage;//Remove compiler warning
       
    85 
       
    86     TVersion v( KUsbWatcherSrvMajorVersionNumber,
       
    87         KUsbWatcherSrvMinorVersionNumber, KUsbWatcherSrvBuildVersionNumber );
       
    88 
       
    89     if ( !User::QueryVersionSupported( v, aVersion ) )
       
    90         {
       
    91         LEAVE( KErrNotSupported );
       
    92         }
       
    93 
       
    94     CUsbWatcherServer* ncThis = const_cast< CUsbWatcherServer* >( this );
       
    95 
       
    96     CUsbWatcherSession* sess = CUsbWatcherSession::NewL( ncThis );
       
    97 
       
    98     return sess;
       
    99     }
       
   100 
       
   101 // ----------------------------------------------------------------------------
       
   102 // Error handle
       
   103 // ----------------------------------------------------------------------------
       
   104 //
       
   105 void CUsbWatcherServer::Error( TInt aError )
       
   106     {
       
   107     LOG_FUNC
       
   108 
       
   109     LOG1( "Error = %d", aError );
       
   110     Message().Complete( aError );
       
   111     LOG( "Restarting..." );
       
   112     ReStart();
       
   113     }
       
   114 
       
   115 // End of file