phoneapp/phoneuiutils/src/cphonepublishsubscriberao.cpp
changeset 0 5f000ab63145
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     1 /*
       
     2 * Copyright (c) 2005 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:  see header description
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDES
       
    20 #include <e32svr.h>
       
    21 #include "cphonepublishsubscriberao.h"
       
    22 #include "phonelogger.h"
       
    23 
       
    24 // CONSTANTS
       
    25 
       
    26 // ============================= MEMBER FUNCTIONS =============================
       
    27 
       
    28 // ----------------------------------------------------------------------------
       
    29 // CPhonePublishSubscriberAO::NewL()
       
    30 // ----------------------------------------------------------------------------
       
    31 CPhonePublishSubscriberAO* CPhonePublishSubscriberAO::NewL( 
       
    32     MPhonePubSubObserver* aPubSubObserver, 
       
    33     const TUid& aCategory, 
       
    34     const TUint aKey )
       
    35     {
       
    36     CPhonePublishSubscriberAO* self = 
       
    37         new (ELeave) CPhonePublishSubscriberAO( 
       
    38             aPubSubObserver, aCategory, aKey );
       
    39 
       
    40     return self;
       
    41     }
       
    42 
       
    43 // ----------------------------------------------------------------------------
       
    44 // CPhonePublishSubscriberAO::Subscribe()
       
    45 // ----------------------------------------------------------------------------
       
    46 void CPhonePublishSubscriberAO::Subscribe()
       
    47     {
       
    48     iProperty.Subscribe( iStatus );
       
    49     SetActive();
       
    50     }
       
    51 
       
    52 // ----------------------------------------------------------------------------
       
    53 // CPhonePublishSubscriberAO::CPhonePublishSubscriberAO()
       
    54 // ----------------------------------------------------------------------------
       
    55 CPhonePublishSubscriberAO::CPhonePublishSubscriberAO( 
       
    56     MPhonePubSubObserver* aPubSubObserver, 
       
    57     const TUid& aCategory, 
       
    58     const TUint aKey ) :
       
    59     CActive( EPriorityStandard ),
       
    60     iPubSubObserver( aPubSubObserver ),
       
    61     iCategory( aCategory ),
       
    62     iKey( aKey )
       
    63     {
       
    64     CActiveScheduler::Add( this );
       
    65     iProperty.Attach( iCategory, iKey );
       
    66     }
       
    67 
       
    68 // ----------------------------------------------------------------------------
       
    69 // CPhonePublishSubscriberAO::RunL()
       
    70 // ----------------------------------------------------------------------------
       
    71 void CPhonePublishSubscriberAO::RunL()
       
    72     {
       
    73     Subscribe();
       
    74     
       
    75     // Get the value     
       
    76     TInt value( 0 );
       
    77     iProperty.Get( iCategory, iKey, value );
       
    78 
       
    79     // Notify the observer
       
    80     iPubSubObserver->HandlePropertyChangedL( iCategory, iKey, value );
       
    81     }
       
    82 
       
    83 // ----------------------------------------------------------------------------
       
    84 // CPhonePublishSubscriberAO::DoCancel()
       
    85 // ----------------------------------------------------------------------------
       
    86 void CPhonePublishSubscriberAO::DoCancel()
       
    87     {
       
    88     iProperty.Cancel();
       
    89     }
       
    90 
       
    91 // ----------------------------------------------------------------------------
       
    92 // CPhonePublishSubscriberAO::RunError()
       
    93 // ----------------------------------------------------------------------------
       
    94 TInt CPhonePublishSubscriberAO::RunError( TInt aError )
       
    95     {    
       
    96     __PHONELOG1( 
       
    97         EBasic, 
       
    98         EPhonePhoneapp, 
       
    99         "CPhonePublishSubscriberAO::RunError: error: %d", 
       
   100         aError );
       
   101 
       
   102     return aError;
       
   103     }
       
   104 
       
   105 // ----------------------------------------------------------------------------
       
   106 // CPhonePublishSubscriberAO::~CPhonePublishSubscriberAO()
       
   107 // ----------------------------------------------------------------------------
       
   108 CPhonePublishSubscriberAO::~CPhonePublishSubscriberAO()
       
   109     {
       
   110     Cancel();
       
   111     iProperty.Close();
       
   112     }
       
   113 
       
   114 // ----------------------------------------------------------------------------
       
   115 // CPhonePublishSubscriberAO::Category()
       
   116 // ----------------------------------------------------------------------------
       
   117 const TUid CPhonePublishSubscriberAO::Category() const
       
   118     {
       
   119     return iCategory;
       
   120     }
       
   121 
       
   122 // ----------------------------------------------------------------------------
       
   123 // CPhonePublishSubscriberAO::Key()
       
   124 // ----------------------------------------------------------------------------
       
   125 TUint CPhonePublishSubscriberAO::Key() const
       
   126     {
       
   127     return iKey;
       
   128     }
       
   129 
       
   130 // End of File