messagingfw/deprecate/senduiservices/src_old/propertyobserver.cpp
branchRCL_3
changeset 22 d2c4c66342f3
equal deleted inserted replaced
21:e5b3a2155e1a 22:d2c4c66342f3
       
     1 /*
       
     2 * Copyright (c) 2006 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:   Notifies SendUI to refresh its local sending service list
       
    15 *                if list in Central Repository is updated.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #include <e32base.h>
       
    22 #include <e32property.h>
       
    23 
       
    24 #include "propertyobserver.h"
       
    25 #include "senduiproperty.h"
       
    26 #include "senduiimpl.h"
       
    27 
       
    28 // ======== LOCAL FUNCTIONS ========
       
    29 
       
    30 // ---------------------------------------------------------------------------
       
    31 // NewL
       
    32 // ---------------------------------------------------------------------------
       
    33 //
       
    34 CPropertyObserver* CPropertyObserver::NewL( CSendUiImpl* aParent)
       
    35     {
       
    36     CPropertyObserver* self = new ( ELeave ) CPropertyObserver( aParent );
       
    37     CleanupStack::PushL( self );
       
    38     self->ConstructL();
       
    39     CleanupStack::Pop( self );
       
    40     return self;
       
    41     }
       
    42 
       
    43 // ---------------------------------------------------------------------------
       
    44 // Destructor
       
    45 // ---------------------------------------------------------------------------
       
    46 //
       
    47 CPropertyObserver::~CPropertyObserver()
       
    48     {
       
    49     iPropertyUpdateOperation.Close();
       
    50     Cancel();
       
    51     }
       
    52 // ---------------------------------------------------------------------------
       
    53 // ConstructL
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 void CPropertyObserver::ConstructL()
       
    57     {
       
    58    
       
    59     User::LeaveIfError( iPropertyUpdateOperation.Attach( KPSUidSendUiProperty, KSendUiUpdateOperation  ));
       
    60     iPropertyUpdateOperation.Subscribe( iStatus );
       
    61     SetActive();
       
    62 
       
    63     }
       
    64 
       
    65 // ---------------------------------------------------------------------------
       
    66 // Constructor
       
    67 // ---------------------------------------------------------------------------
       
    68 //
       
    69 CPropertyObserver::CPropertyObserver( CSendUiImpl* aParent )
       
    70     : CActive( CActive::EPriorityStandard ),
       
    71     iParent( aParent)
       
    72     {
       
    73     CActiveScheduler::Add( this );
       
    74     }
       
    75 
       
    76 // ---------------------------------------------------------------------------
       
    77 // From class CActive
       
    78 // ---------------------------------------------------------------------------
       
    79 //
       
    80 void CPropertyObserver::DoCancel()
       
    81     {
       
    82     iPropertyUpdateOperation.Close();
       
    83     }
       
    84 
       
    85 // ---------------------------------------------------------------------------
       
    86 // From class CActive
       
    87 // ---------------------------------------------------------------------------
       
    88 //
       
    89 void CPropertyObserver::RunL()
       
    90     {
       
    91     TInt value;
       
    92     if ( iPropertyUpdateOperation.Get( value ) != KErrNotFound 
       
    93          && value == KSendUiUpdateOperationDone )
       
    94         {
       
    95         iParent->GetServicesL();
       
    96         }
       
    97     iPropertyUpdateOperation.Subscribe( iStatus );
       
    98     SetActive();
       
    99     }
       
   100