accessoryservices/accessoryserver/src/Server/AccSrvWiredConnectionPublisher.cpp
changeset 0 4e1aa6a622a0
child 7 1fc153c72b60
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     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:  CAccSrvWiredConnectionPublihser implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <accessoryservicesinternalpskeys.h>
       
    20 #include "AccSrvWiredConnectionPublisher.h"
       
    21 #include "acc_debug.h"
       
    22 
       
    23 _LIT_SECURITY_POLICY_C1( KWiredConnectionReadPolicy, ECapabilityReadDeviceData );
       
    24 _LIT_SECURITY_POLICY_S0( KWiredConnectionWritePolicy, KPSUidAccessoryServices.iUid );
       
    25 
       
    26 // ======== MEMBER FUNCTIONS ========
       
    27 
       
    28 // ---------------------------------------------------------------------------
       
    29 // CAccSrvWiredConnectionPublisher::NewL
       
    30 // ---------------------------------------------------------------------------
       
    31 //
       
    32 CAccSrvWiredConnectionPublisher* CAccSrvWiredConnectionPublisher::NewL()
       
    33     {
       
    34     COM_TRACE_( "[AccFW:AccServer] CAccSrvWiredConnectionPublisher::NewL" );
       
    35     CAccSrvWiredConnectionPublisher* self = CAccSrvWiredConnectionPublisher::NewLC();
       
    36     CleanupStack::Pop( self );
       
    37     COM_TRACE_( "[AccFW:AccServer] CCAccSrvWiredConnectionPublisher::NewL - return self" );
       
    38     return self;
       
    39     }
       
    40 
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // CAccSrvWiredConnectionPublisher::NewLC
       
    44 // ---------------------------------------------------------------------------
       
    45 //
       
    46 CAccSrvWiredConnectionPublisher* CAccSrvWiredConnectionPublisher::NewLC()
       
    47     {
       
    48     COM_TRACE_( "[AccFW:AccServer] CAccSrvWiredConnectionPublisher::NewLC" );
       
    49     CAccSrvWiredConnectionPublisher* self = new( ELeave ) CAccSrvWiredConnectionPublisher;
       
    50     CleanupStack::PushL( self );
       
    51     self->ConstructL();
       
    52     COM_TRACE_( "[AccFW:AccServer] CCAccSrvWiredConnectionPublisher::NewLC - return self" );
       
    53     return self;
       
    54     }
       
    55 
       
    56 
       
    57 // ---------------------------------------------------------------------------
       
    58 // CAccSrvWiredConnectionPublisher::~CAccSrvWiredConnectionPublisher
       
    59 // ---------------------------------------------------------------------------
       
    60 //
       
    61 CAccSrvWiredConnectionPublisher::~CAccSrvWiredConnectionPublisher()
       
    62     {
       
    63     COM_TRACE_( "[AccFW:AccServer] CAccSrvWiredConnectionPublisher::~CAccSrvWiredConnectionPublisher" );
       
    64     
       
    65     iProperty.Close();
       
    66     
       
    67     COM_TRACE_( "[AccFW:AccServer] CAccSrvWiredConnectionPublisher::~CAccSrvWiredConnectionPublisher - end" );
       
    68     }
       
    69 
       
    70 // ---------------------------------------------------------------------------
       
    71 // CAccSrvWiredConnectionPublisher::HandleConnectL
       
    72 // ---------------------------------------------------------------------------
       
    73 //
       
    74 void CAccSrvWiredConnectionPublisher::HandleConnectL( const TAccPolGenericID& aGenericID )
       
    75     {
       
    76     TUint32 physConnCaps( aGenericID.PhysicalConnectionCaps() );
       
    77     
       
    78     COM_TRACE_2( "[AccFW:AccServer] CAccSrvWiredConnectionPublisher::HandleConnectL: physConnCaps=0x%x, iConnectionCount=%d", 
       
    79                         physConnCaps, iConnectionCount );
       
    80     
       
    81     if ( physConnCaps & KPCWired )
       
    82         {
       
    83         if ( !iConnectionCount++ )
       
    84             {
       
    85             // first detected wired connection, publish it 
       
    86             COM_TRACE_( "[AccFW:AccServer] CAccSrvWiredConnectionPublisher::HandleConnectL: WIRED CONNECTED" );
       
    87             
       
    88             User::LeaveIfError( iProperty.Set( EAccSrvcsWiredConnConnected ) );
       
    89             }
       
    90         }
       
    91     COM_TRACE_( "[AccFW:AccServer] CCAccSrvWiredConnectionPublisher::HandleConnectL - return void" );
       
    92     }
       
    93 
       
    94 // ---------------------------------------------------------------------------
       
    95 // CAccSrvWiredConnectionPublisher::HandleDisconnectL
       
    96 // ---------------------------------------------------------------------------
       
    97 //
       
    98 void CAccSrvWiredConnectionPublisher::HandleDisconnectL( const TAccPolGenericID& aGenericID )
       
    99     {
       
   100     TUint32 physConnCaps( aGenericID.PhysicalConnectionCaps() );
       
   101     
       
   102     COM_TRACE_2( "[AccFW:AccServer] CAccSrvWiredConnectionPublisher::HandleDisconnectL: physConnCaps=0x%x, iConnectionCount=%d", 
       
   103                         physConnCaps, iConnectionCount );
       
   104     
       
   105     if ( (physConnCaps & KPCWired) && iConnectionCount )
       
   106         {
       
   107         if ( !(--iConnectionCount) )
       
   108             {
       
   109             // last wired connection disconnected
       
   110             COM_TRACE_( "[AccFW:AccServer] CAccSrvWiredConnectionPublisher::HandleDisconnectL: WIRED DISCONNECTED" );
       
   111             
       
   112             User::LeaveIfError( iProperty.Set( EAccSrvcsWiredConnDisconnected ) );
       
   113             }
       
   114         }
       
   115     COM_TRACE_( "[AccFW:AccServer] CCAccSrvWiredConnectionPublisher::HandleDisconnectL - return void" );
       
   116     }
       
   117 
       
   118 // ---------------------------------------------------------------------------
       
   119 // CAccSrvWiredConnectionPublisher::CAccSrvWiredConnectionPublisher
       
   120 // ---------------------------------------------------------------------------
       
   121 //
       
   122 CAccSrvWiredConnectionPublisher::CAccSrvWiredConnectionPublisher() :
       
   123     iConnectionCount( 0 )
       
   124     {
       
   125     }
       
   126     
       
   127 // ---------------------------------------------------------------------------
       
   128 // CAccSrvWiredConnectionPublisher::ConstructL
       
   129 // ---------------------------------------------------------------------------
       
   130 //
       
   131 void CAccSrvWiredConnectionPublisher::ConstructL()
       
   132     {
       
   133     COM_TRACE_( "[AccFW:AccServer] CAccSrvWiredConnectionPublisher::ConstructL" );
       
   134     User::LeaveIfError( RProperty::Define( KPSUidAccessoryServices, 
       
   135                                            KAccSrvcsWiredConnection,
       
   136                                            RProperty::EInt,
       
   137                                            KWiredConnectionReadPolicy,
       
   138                                            KWiredConnectionWritePolicy ) );
       
   139     
       
   140     User::LeaveIfError( iProperty.Attach( KPSUidAccessoryServices, 
       
   141                                           KAccSrvcsWiredConnection ) );
       
   142     
       
   143     User::LeaveIfError( iProperty.Set( EAccSrvcsWiredConnUninitialized ) );
       
   144     
       
   145     COM_TRACE_( "[AccFW:AccServer] CCAccSrvWiredConnectionPublisher::ConstructL - return void" );
       
   146     }
       
   147