telephonyserverplugins/simtsy/src/CSimPubSubChange.cpp
changeset 0 3553901f7fa8
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 
       
    17 #include <e32base.h>
       
    18 #include <e32cons.h>
       
    19 #include <e32property.h>
       
    20 #include "CSimPubSubChange.h"
       
    21 
       
    22 
       
    23 CSimPubSubChange::CSimPubSubChange(MPubSubChangeCallback* aCallback, CSimPubSub::TPubSubProperty aProperty)
       
    24 	: CActive(EPriorityStandard),  iCallback(aCallback), iPSProperty(aProperty)
       
    25 	{
       
    26 	CActiveScheduler::Add(this);
       
    27 	}
       
    28 	
       
    29 CSimPubSubChange* CSimPubSubChange::NewL(MPubSubChangeCallback* aCallback, CSimPubSub::TPubSubProperty aProperty)
       
    30 	{
       
    31 	CSimPubSubChange* self = new (ELeave) CSimPubSubChange(aCallback, aProperty);
       
    32 	CleanupStack::PushL(self);
       
    33 	self->ConstructL();
       
    34 	CleanupStack::Pop(self);
       
    35 	return self;
       
    36 	}
       
    37 	
       
    38 void CSimPubSubChange::ConstructL()
       
    39 	{
       
    40 	iProp.Attach(iPSProperty.iCategory, iPSProperty.iKey);
       
    41 	iProp.Subscribe(iStatus);
       
    42 	SetActive();
       
    43 	}
       
    44 
       
    45 CSimPubSubChange::~CSimPubSubChange()
       
    46 	{ 
       
    47 	Cancel();
       
    48 	iProp.Close();
       
    49 	}
       
    50 
       
    51 void CSimPubSubChange::RunL()
       
    52 	{
       
    53 	//Resubscribe before retrieving the value so we don't miss any changes
       
    54 	TInt status = iStatus.Int();
       
    55 	iProp.Subscribe(iStatus);
       
    56 	SetActive();
       
    57 	
       
    58 	if(status == KErrNone)
       
    59 		{
       
    60 		TInt newStat;
       
    61 		TInt ret = iProp.Get(iPSProperty.iCategory, iPSProperty.iKey, newStat);
       
    62 		if (ret == KErrNone)
       
    63 			{
       
    64 			iCallback->PubSubCallback(newStat);
       
    65 			}	
       
    66 		}	
       
    67 	}
       
    68 
       
    69 void CSimPubSubChange::DoCancel()
       
    70 	{
       
    71 	iProp.Cancel();
       
    72 	}