instantmessagesalert/src/cimalertpropertyobserver.cpp
branchRCL_3
changeset 29 9a48e301e94b
parent 0 5e5d6b214f4f
equal deleted inserted replaced
28:3104fc151679 29:9a48e301e94b
       
     1 /*
       
     2 * Copyright (c) 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:  Publish & Subscribe property change observer implementation
       
    15 *
       
    16 */ 
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include "cimalertpropertyobserver.h"
       
    20 #include "mimalertpropertynotificationobserver.h"
       
    21 
       
    22 #include <bautils.h>
       
    23 #include <barsc.h>
       
    24 #include <e32property.h>
       
    25 
       
    26 
       
    27 // ============================ MEMBER FUNCTIONS ===============================
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // CIMAlertPropertyObserver::CIMAlertPropertyObserver
       
    31 // C++ default constructor can NOT contain any code, that
       
    32 // might leave.
       
    33 // -----------------------------------------------------------------------------
       
    34 //
       
    35 CIMAlertPropertyObserver::CIMAlertPropertyObserver( 
       
    36         MIMAlertPropertyNotificationObserver& aObserver )
       
    37     : CActive( CActive::EPriorityLow ),
       
    38       iObserver( aObserver )
       
    39     {
       
    40     CActiveScheduler::Add( this );
       
    41     }
       
    42 
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // CIMAlertPropertyObserver::NewL
       
    46 // Two-phased constructor.
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 CIMAlertPropertyObserver* CIMAlertPropertyObserver::NewL( 
       
    50         MIMAlertPropertyNotificationObserver& aObserver )
       
    51     {
       
    52     CIMAlertPropertyObserver* self = new( ELeave ) CIMAlertPropertyObserver( aObserver );
       
    53     return self;
       
    54     }
       
    55 
       
    56 
       
    57 // Destructor
       
    58 CIMAlertPropertyObserver::~CIMAlertPropertyObserver()
       
    59     {
       
    60     if( IsActive() )
       
    61         {
       
    62         Cancel();
       
    63         }
       
    64     }
       
    65 
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // CIMAlertPropertyObserver::ObservePropertyChangeL
       
    69 // (other items were commented in a header).
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 void CIMAlertPropertyObserver::ObservePropertyChangeL( TUid aCategory, TUint aKey )
       
    73     {
       
    74 	if( IsActive() )
       
    75 		{
       
    76 		return;
       
    77 		}
       
    78     User::LeaveIfError( iProperty.Attach( aCategory, aKey ) );
       
    79 	iKey = aKey;
       
    80 	iCategory = aCategory;
       
    81     iProperty.Subscribe( iStatus );
       
    82     SetActive();
       
    83     }
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 // CIMAlertPropertyObserver::CancelObserve
       
    87 // (other items were commented in a header).
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 void CIMAlertPropertyObserver::CancelObserve()
       
    91     {
       
    92     if( IsActive() )
       
    93         {
       
    94         Cancel();
       
    95         }
       
    96 	}
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 // CIMAlertPropertyObserver::RunL
       
   100 // (other items were commented in a header).
       
   101 // -----------------------------------------------------------------------------
       
   102 //
       
   103 void CIMAlertPropertyObserver::RunL()
       
   104     {
       
   105 	iProperty.Subscribe( iStatus );
       
   106 	SetActive();
       
   107     iObserver.HandlePropertyNotificationEventL( iCategory, iKey );      
       
   108     }
       
   109 
       
   110 // -----------------------------------------------------------------------------
       
   111 // CIMAlertPropertyObserver::DoCancel
       
   112 // (other items were commented in a header).
       
   113 // -----------------------------------------------------------------------------
       
   114 //
       
   115 void CIMAlertPropertyObserver::DoCancel()
       
   116     {
       
   117     iProperty.Cancel();
       
   118     }
       
   119 
       
   120 // -----------------------------------------------------------------------------
       
   121 // CIMAlertPropertyObserver::Category
       
   122 // (other items were commented in a header).
       
   123 // -----------------------------------------------------------------------------
       
   124 //
       
   125 TUid CIMAlertPropertyObserver::Category()
       
   126 	{
       
   127 	return iCategory;
       
   128 	}
       
   129 
       
   130 // -----------------------------------------------------------------------------
       
   131 // CIMAlertPropertyObserver::Key
       
   132 // (other items were commented in a header).
       
   133 // -----------------------------------------------------------------------------
       
   134 //
       
   135 TUint CIMAlertPropertyObserver::Key()
       
   136 	{
       
   137 	return iKey;
       
   138 	}
       
   139 
       
   140 //  End of File