satengine/SatServer/Engine/src/csatmediatoreventprovider.cpp
changeset 0 ff3b6d0fd310
child 5 7237db0d9fca
equal deleted inserted replaced
-1:000000000000 0:ff3b6d0fd310
       
     1 /*
       
     2 * Copyright (c) 2005-2007 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:  Provides events to mediator event consumer.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include    <featmgr.h>
       
    21 #include    <centralrepository.h>
       
    22 #include    <MediatorDomainUIDs.h>
       
    23 #include    <MediatorEventProvider.h>
       
    24 #include    <SecondaryDisplay/secondarydisplaysatapi.h>
       
    25 
       
    26 #include    "SATPrivateCRKeys.h"
       
    27 #include    "csatmediatoreventprovider.h"
       
    28 #include    "SatLog.h"
       
    29 
       
    30 using namespace MediatorService;
       
    31 
       
    32 // ======== MEMBER FUNCTIONS ========
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 // CSatMediatorEventProvider::NewL
       
    36 // Two-phased constructor.
       
    37 // -----------------------------------------------------------------------------
       
    38 //
       
    39 CSatMediatorEventProvider* CSatMediatorEventProvider::NewL()
       
    40     {
       
    41     LOG( NORMAL, "SATENGINE: CSatMediatorEventProvider::NewL calling" )
       
    42 
       
    43     CSatMediatorEventProvider* self =
       
    44         new ( ELeave ) CSatMediatorEventProvider();
       
    45     CleanupStack::PushL( self );
       
    46     self->ConstructL();
       
    47     CleanupStack::Pop();
       
    48 
       
    49     LOG( NORMAL, "SATENGINE: CSatMediatorEventProvider::NewL exiting" )
       
    50     return self;
       
    51     }
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // CSatMediatorEventProvider::~CSatMediatorEventProvider
       
    55 // Destructor.
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 CSatMediatorEventProvider::~CSatMediatorEventProvider()
       
    59     {
       
    60     LOG( NORMAL, "SATENGINE: CSatMediatorEventProvider::\
       
    61         ~CSatMediatorEventProvider calling" )
       
    62 
       
    63     if ( iEventProvider )
       
    64         {
       
    65         iEventProvider->UnregisterEvent( KMediatorSecondaryDisplayDomain,
       
    66                                          KCatSAT,
       
    67                                          EMsgAnySatCommand );
       
    68         delete iEventProvider;
       
    69         iEventProvider = NULL;
       
    70         }
       
    71 
       
    72     LOG( NORMAL,
       
    73         "SATENGINE: CSatMediatorEventProvider::\
       
    74             ~CSatMediatorEventProvider exiting" )
       
    75     }
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // CSatMediatorEventProvider::RaiseSatEvent
       
    79 //
       
    80 // -----------------------------------------------------------------------------
       
    81 //
       
    82 TInt CSatMediatorEventProvider::RaiseSatEvent( const TDesC8& aData )
       
    83     {
       
    84 
       
    85     LOG( NORMAL, "SATENGINE: CSatMediatorEventProvider \
       
    86         ::RaiseSatEvent calling" )
       
    87     TInt retVal( KErrNone );
       
    88     // If SAT Event is registered, raise SAT event
       
    89     if ( iRegistered )
       
    90         {
       
    91         LOG( NORMAL, "SATENGINE: CSatMediatorEventProvider \
       
    92         ::RaiseSatEvent iRegistered true" )
       
    93 #ifdef ENABLE_SAT_LOGGING
       
    94         const TSatCommandPckg* eventPckg =
       
    95             reinterpret_cast<const TSatCommandPckg*> ( aData.Ptr() );
       
    96         const TSatCommandData& eventData =
       
    97             reinterpret_cast<const TSatCommandData&> ( *eventPckg );
       
    98 
       
    99         LOG2( DETAILED,
       
   100         "SATENGINE: CSatMediatorEventProvider::RaiseSatEvent: \
       
   101         cmdNumber: 0x%2X", eventData.iPCmdNumber )
       
   102         LOG2( DETAILED,
       
   103         "SATENGINE: CSatMediatorEventProvider::RaiseSatEvent: AlphaId: %S",
       
   104         &eventData.iAlphaId )
       
   105         LOG2( DETAILED,
       
   106         "SATENGINE: CSatMediatorEventProvider::RaiseSatEvent: \
       
   107         duration[s]: 0x%2X", eventData.iDuration.iNumOfUnits )
       
   108         LOG2( DETAILED,
       
   109         "SATENGINE: CSatMediatorEventProvider::RaiseSatEvent: IconID: 0x%2X",
       
   110         eventData.iIconID.iIdentifier )
       
   111 #endif
       
   112         retVal = iEventProvider->RaiseEvent(
       
   113                                             KMediatorSecondaryDisplayDomain,
       
   114                                             KCatSAT,
       
   115                                             EMsgAnySatCommand,
       
   116                                             TVersion( KVersionMajor,
       
   117                                                       KVersionMinor,
       
   118                                                       KVersionBuild ),
       
   119                                             aData );
       
   120         }
       
   121 
       
   122     LOG2( NORMAL, "SATENGINE: CSatMediatorEventProvider\
       
   123           ::RaiseSatEvent exiting, retVal: %d", retVal )
       
   124     return retVal;
       
   125     }
       
   126 
       
   127 // -----------------------------------------------------------------------------
       
   128 // CSatMediatorEventProvider::CoverUiSupported
       
   129 //
       
   130 // -----------------------------------------------------------------------------
       
   131 //
       
   132 TBool CSatMediatorEventProvider::CoverUiSupported()
       
   133     {
       
   134     LOG( NORMAL, "SATENGINE: CSatMediatorEventProvider \
       
   135         ::CoverUiSupported calling-exiting" )
       
   136     return iCoverUiSupported;
       
   137     }
       
   138 
       
   139 // -----------------------------------------------------------------------------
       
   140 // CSatMediatorEventProvider::CSatMediatorEventProvider
       
   141 // C++ default constructor can NOT contain any code, that might leave.
       
   142 // -----------------------------------------------------------------------------
       
   143 //
       
   144 CSatMediatorEventProvider::CSatMediatorEventProvider() :
       
   145     iRegistered( EFalse ),
       
   146     iCoverUiSupported( EFalse ),
       
   147     iEventProvider( NULL )
       
   148     {
       
   149     LOG( NORMAL,
       
   150         "SATENGINE: CSatMediatorEventProvider::CSatMediatorEventProvider \
       
   151         calling-exiting" )
       
   152     }
       
   153 
       
   154 // -----------------------------------------------------------------------------
       
   155 // CSatMediatorEventProvider::ConstructL
       
   156 // Two-phased constructor.
       
   157 // -----------------------------------------------------------------------------
       
   158 //
       
   159 void CSatMediatorEventProvider::ConstructL()
       
   160     {
       
   161     LOG( NORMAL, "SATENGINE: CSatMediatorEventProvider::ConstructL calling" )
       
   162 
       
   163     // Store Cover UI supported information
       
   164     CUiSupportedL();
       
   165 
       
   166     // If Cover UI is supported, register SAT Event
       
   167     if ( iCoverUiSupported )
       
   168         {
       
   169         LOG( NORMAL, "SATENGINE: CSatMediatorEventProvider::ConstructL \
       
   170              iCoverUiSupported true" )
       
   171         iEventProvider = CMediatorEventProvider::NewL();
       
   172 
       
   173         User::LeaveIfError( iEventProvider->RegisterEvent(
       
   174                     KMediatorSecondaryDisplayDomain,
       
   175                     KCatSAT,
       
   176                     EMsgAnySatCommand,
       
   177                     TVersion( KVersionMajor, KVersionMinor, KVersionBuild ),
       
   178                     TCapabilitySet( ECapabilitySwEvent ) ) );
       
   179 
       
   180         iRegistered = ETrue;
       
   181         }
       
   182 
       
   183     LOG( NORMAL, "SATENGINE: CSatMediatorEventProvider::ConstructL exiting" )
       
   184     }
       
   185 
       
   186 // -----------------------------------------------------------------------------
       
   187 // CSatMediatorEventProvider::CUiSupportedL
       
   188 //
       
   189 // -----------------------------------------------------------------------------
       
   190 //
       
   191 void CSatMediatorEventProvider::CUiSupportedL()
       
   192     {
       
   193     LOG( NORMAL,
       
   194         "SATENGINE: CSatMediatorEventProvider::CoverUiSupported calling" )
       
   195 
       
   196     TBool coverui( EFalse );
       
   197 
       
   198     // Check if Cover UI presents from Feature Manager
       
   199     FeatureManager::InitializeLibL();
       
   200     coverui = FeatureManager::FeatureSupported( KFeatureIdCoverDisplay );
       
   201     FeatureManager::UnInitializeLib();
       
   202 
       
   203     // Check SAT internal flag for Cover UI
       
   204     TInt satCoverUi( 0 );
       
   205     CRepository* repository = CRepository::NewL( KCRUidSatServer );
       
   206     repository->StartTransaction( CRepository::EReadTransaction );
       
   207     repository->Get( KSatSecondaryDisplaySupport, satCoverUi );
       
   208     delete repository;
       
   209     repository = NULL;
       
   210 
       
   211     // Store Supported information
       
   212     iCoverUiSupported = TBool( coverui & satCoverUi );
       
   213     LOG2( SIMPLE,"CSatMediatorEventProvider::CUiSupportedL \
       
   214           KSatSecondaryDisplaySupport:%d", satCoverUi )
       
   215     LOG( NORMAL,
       
   216         "SATENGINE: CSatMediatorEventProvider::CoverUiSupported exiting" )
       
   217     }
       
   218