gssettingsuis/Gs/GSFramework/src/GSPubSubsListener.cpp
author Pat Downey <patd@symbian.org>
Wed, 01 Sep 2010 12:20:44 +0100
branchRCL_3
changeset 54 7e0eff37aedb
parent 0 8c5d936e5675
permissions -rw-r--r--
Revert incorrect RCL_3 drop: Revision: 201033 Kit: 201035

/*
* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  Publish and subscribe settings listener.
*
*/


// INCLUDE FILES
#include <gspubsubslistener.h>
#include <mgssettingpsobserver.h>


// ============================ MEMBER FUNCTIONS ===============================

// -----------------------------------------------------------------------------
// CGSPubSubsListener::CGSPubSubsListener
// C++ constructor can NOT contain any code, that
// might leave.
// -----------------------------------------------------------------------------
//
CGSPubSubsListener::CGSPubSubsListener( const TUid aUid, const TInt aKey, 
                                       MGSSettingPSObserver* aObserver ) 
    : CActive( CActive::EPriorityStandard )
    {
    iUid = aUid;
    iId = aKey;
    iCallback = aObserver;
    }

// -----------------------------------------------------------------------------
// CGSPubSubsListener::~CGSPubSubsListener
// Destructor.
// -----------------------------------------------------------------------------
//
EXPORT_C CGSPubSubsListener::~CGSPubSubsListener()
    {
    Cancel();
    iProperty.Close();
    }

// -----------------------------------------------------------------------------
// CGSPubSubsListener::RunL
// From CActive.
// -----------------------------------------------------------------------------
//
void CGSPubSubsListener::RunL()
    {
    const TRequestStatus status( iStatus );
    StartListening();
    iCallback->HandleNotifyPSL( iUid, iId, status );
    }

// -----------------------------------------------------------------------------
// CGSPubSubsListener::DoCancel
// From CActive.
// -----------------------------------------------------------------------------
//
void CGSPubSubsListener::DoCancel()
    {
    iProperty.Cancel();
    }

// -----------------------------------------------------------------------------
// CGSPubSubsListener::RunError
// From CActive.
// -----------------------------------------------------------------------------
//
TInt CGSPubSubsListener::RunError( TInt /*aError*/ )
    {
    return KErrNone;
    }

// -----------------------------------------------------------------------------
// CGSPubSubsListener::NewL
//
// Symbian OS two phased constructor
// -----------------------------------------------------------------------------
//
EXPORT_C CGSPubSubsListener* CGSPubSubsListener::NewL( const TUid aUid, const TInt aKey,
                                              MGSSettingPSObserver* aObserver )
    {
    CGSPubSubsListener* self = new( ELeave ) 
        CGSPubSubsListener( aUid, aKey, aObserver );
    CleanupStack::PushL( self );
    self->ConstructL();
    CleanupStack::Pop();
    return self;
    }

// -----------------------------------------------------------------------------
// CGSPubSubsListener::StartListening
// -----------------------------------------------------------------------------
//
void CGSPubSubsListener::StartListening() 
    {
    iProperty.Subscribe( iStatus );
    SetActive();
    }

// -----------------------------------------------------------------------------
// CGSPubSubsListener::ConstructL
//
// Symbian OS default constructor
// -----------------------------------------------------------------------------
//
void CGSPubSubsListener::ConstructL()
    {
    CActiveScheduler::Add( this );
    
    User::LeaveIfError ( iProperty.Attach( iUid, iId, EOwnerThread ) );
    StartListening();
    }

// -----------------------------------------------------------------------------
// CGSPubSubsListener::Get
// Read integer value.
// -----------------------------------------------------------------------------
//
EXPORT_C TInt CGSPubSubsListener::Get( TInt& aVal )
    {
    return iProperty.Get( iUid, iId, aVal );
    }

// -----------------------------------------------------------------------------
// CGSPubSubsListener::Get
// Read binary value.
// -----------------------------------------------------------------------------
//
EXPORT_C TInt CGSPubSubsListener::Get( TDes8& aVal )
    {
    return iProperty.Get( iUid, iId, aVal );
    }
  
// -----------------------------------------------------------------------------
// CGSPubSubsListener::Get
// Read string value.
// -----------------------------------------------------------------------------
//      
EXPORT_C TInt CGSPubSubsListener::Get( TDes16& aVal )
    {
    return iProperty.Get( iUid, iId, aVal );
    }

// End of File