wvuing/IMPSServiceSettingsUI/SharedDataSrc/CIMPSSystemNotifierSystemAgent.cpp
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2004 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:  Publish & Subscribe property change observer implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "MIMPSSystemNotifierObserver.h"
       
    22 #include "CIMPSSystemNotifierSystemAgent.h"
       
    23 #include "IMPSSystemNotifyDefs.h"
       
    24 #include "IMPSCommonUiDebugPrint.h"
       
    25 
       
    26 #include <sacls.h>
       
    27 
       
    28 // ============================ MEMBER FUNCTIONS ===============================
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // CIMPSSystemNotifierSystemAgent::CIMPSSystemNotifierSystemAgent
       
    32 // C++ default constructor can NOT contain any code, that
       
    33 // might leave.
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 CIMPSSystemNotifierSystemAgent::CIMPSSystemNotifierSystemAgent(
       
    37     MIMPSSystemNotifierObserver& aObserver,
       
    38     const TUid aKey
       
    39 )
       
    40         : CActive( CActive::EPriorityStandard ),
       
    41         iObserver( aObserver ),
       
    42         iKey( aKey )
       
    43     {
       
    44     CActiveScheduler::Add( this );
       
    45     }
       
    46 
       
    47 // -----------------------------------------------------------------------------
       
    48 // CIMPSSystemNotifierSystemAgent::ConstructL
       
    49 // Symbian 2nd phase constructor can leave.
       
    50 // -----------------------------------------------------------------------------
       
    51 //
       
    52 void CIMPSSystemNotifierSystemAgent::ConstructL()
       
    53     {
       
    54     User::LeaveIfError( iSysAgent.Connect() );
       
    55     }
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 // CIMPSSystemNotifierSystemAgent::NewL
       
    59 // Two-phased constructor.
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 CIMPSSystemNotifierSystemAgent* CIMPSSystemNotifierSystemAgent::NewL(
       
    63     MIMPSSystemNotifierObserver& aObserver,
       
    64     TUid aKey )
       
    65     {
       
    66     CIMPSSystemNotifierSystemAgent* self =
       
    67         new( ELeave ) CIMPSSystemNotifierSystemAgent( aObserver, aKey );
       
    68 
       
    69     CleanupStack::PushL( self );
       
    70     self->ConstructL();
       
    71     CleanupStack::Pop();
       
    72 
       
    73     return self;
       
    74     }
       
    75 
       
    76 
       
    77 // Destructor
       
    78 CIMPSSystemNotifierSystemAgent::~CIMPSSystemNotifierSystemAgent()
       
    79     {
       
    80     if ( IsActive() )
       
    81         {
       
    82         Cancel();
       
    83         }
       
    84     iSysAgent.Close();
       
    85     }
       
    86 
       
    87 
       
    88 // -----------------------------------------------------------------------------
       
    89 // CIMPSSystemNotifierSystemAgent::Subscribe
       
    90 // (other items were commented in a header).
       
    91 // -----------------------------------------------------------------------------
       
    92 //
       
    93 TInt CIMPSSystemNotifierSystemAgent::Subscribe()
       
    94     {
       
    95     if ( IsActive() )
       
    96         {
       
    97         return KErrNone;
       
    98         }
       
    99 
       
   100     iAgentEvent.SetRequestStatus( iStatus );
       
   101     iAgentEvent.SetUid( iKey );
       
   102 
       
   103     iSysAgent.NotifyOnEvent( iAgentEvent );
       
   104     SetActive();
       
   105     return KErrNone;
       
   106     }
       
   107 
       
   108 // -----------------------------------------------------------------------------
       
   109 // CIMPSSystemNotifierSystemAgent::UnSubscribe
       
   110 // (other items were commented in a header).
       
   111 // -----------------------------------------------------------------------------
       
   112 //
       
   113 void CIMPSSystemNotifierSystemAgent::UnSubscribe()
       
   114     {
       
   115     if ( IsActive() )
       
   116         {
       
   117         Cancel();
       
   118         }
       
   119     }
       
   120 
       
   121 // -----------------------------------------------------------------------------
       
   122 // CIMPSSystemNotifierSystemAgent::GetIntKey
       
   123 // (other items were commented in a header).
       
   124 // -----------------------------------------------------------------------------
       
   125 //
       
   126 TInt CIMPSSystemNotifierSystemAgent::GetIntKey( TInt& aValue )
       
   127     {
       
   128     aValue = iSysAgent.GetState( iKey );
       
   129     return KErrNone;
       
   130     }
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // CIMPSSystemNotifierSystemAgent::RunL
       
   134 // (other items were commented in a header).
       
   135 // -----------------------------------------------------------------------------
       
   136 //
       
   137 void CIMPSSystemNotifierSystemAgent::RunL()
       
   138     {
       
   139     TInt value( iAgentEvent.State() );
       
   140     iSysAgent.NotifyOnEvent( iAgentEvent );
       
   141     SetActive();
       
   142     iObserver.HandleSystemNotifierEventL( iKey, value );
       
   143     }
       
   144 
       
   145 // -----------------------------------------------------------------------------
       
   146 // CIMPSSystemNotifierSystemAgent::DoCancel
       
   147 // (other items were commented in a header).
       
   148 // -----------------------------------------------------------------------------
       
   149 //
       
   150 void CIMPSSystemNotifierSystemAgent::DoCancel()
       
   151     {
       
   152     iSysAgent.NotifyEventCancel();
       
   153     }
       
   154 
       
   155