commsfwsupport/commselements/NetSubscribe/src/NetSubscriber.cpp
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     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  @file
       
    18  @internalComponent
       
    19 */
       
    20 
       
    21 #include "NetPSSignal.h"
       
    22 
       
    23 using namespace NetSubscribe;
       
    24 
       
    25 void TEventClientData::SignalErrorL( TInt aError )
       
    26 	{
       
    27 	if ( Event()->iErrHandler )
       
    28 		{
       
    29 		(Event()->iErrHandler)(Event()->iThis, aError);
       
    30 		}
       
    31 	};
       
    32 
       
    33 void TEventDataArray::DispatchL( const Meta::SMetaData* aData, TInt aErr ) 
       
    34 	{
       
    35 	for (TInt n = 0; n < Count(); n++)
       
    36 		{
       
    37 		TEventClientData& data = (*this)[n];
       
    38 		if ( aErr == KErrNone )
       
    39 			{
       
    40 			data.SignalL( aData );
       
    41 			}
       
    42 		else
       
    43 			{
       
    44 			data.SignalErrorL( aErr );
       
    45 			}
       
    46 		}
       
    47 	}
       
    48 
       
    49 TInt TEventDataArray::RegisterL( const TEventClientData& aData ) 
       
    50 	{
       
    51 	if (Find( aData.Event() ) != KErrNotFound)
       
    52 		{
       
    53 		User::Leave(KErrAlreadyExists);
       
    54 		}
       
    55 	AppendL( aData );
       
    56 	return Count();
       
    57 	}
       
    58 
       
    59 TInt TEventDataArray::DeRegister( const TEventBase* aEvent )
       
    60 	{
       
    61 	TInt n = Find( aEvent );
       
    62 	if ( n != KErrNotFound )
       
    63 		{
       
    64 		Remove(n);
       
    65 		}
       
    66 	return Count();
       
    67 	}
       
    68 
       
    69 TInt TEventDataArray::Find( const TEventBase* aEvent )
       
    70 	{
       
    71 	TInt n = 0;
       
    72 	TInt count = Count();
       
    73 	for (; n < count && (*this)[n].Event() != aEvent; n++)
       
    74 		{
       
    75 		}
       
    76 	return n < Count() ? n : KErrNotFound;
       
    77 	}
       
    78 	
       
    79 XSignal::~XSignal()
       
    80 	/**
       
    81 	virtual destructor so that the right instance destructor can be reached
       
    82 	*/
       
    83 	{
       
    84 	iData.Close();
       
    85 	}
       
    86 	
       
    87 TInt CSignalActive::RunError(TInt aError)
       
    88 	{
       
    89 	for (TInt n = 0; n < iData.Count(); n++)
       
    90 		{
       
    91 		TRAP_IGNORE(iData[n].SignalErrorL( aError ));
       
    92 		}
       
    93 	return KErrNone;
       
    94 	}
       
    95