diff -r 000000000000 -r 1bce908db942 natfw/natfwicecandidatehandler/inc/icecandidatehandlerdefs.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/natfw/natfwicecandidatehandler/inc/icecandidatehandlerdefs.h Tue Feb 02 01:04:58 2010 +0200 @@ -0,0 +1,138 @@ +/* +* Copyright (c) 2006 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: +* +*/ + + + + +#ifndef ICECANDIDATEHANDLERDEFS_H +#define ICECANDIDATEHANDLERDEFS_H + +#include +#include + +class CNATFWPluginApi; + +_LIT8( KNatPluginIdNokiaStun, "nokia.stun" ); +_LIT8( KNatPluginIdNokiaTurn, "nokia.turn" ); +_LIT8( KNatPluginIdNokiaIce, "nokia.ice" ); +_LIT8( KNatPluginIdNokiaHost, "nokia.host" ); + +_LIT8( KNatPluginTypeStun, "stun" ); +_LIT8( KNatPluginTypeTurn, "turn" ); +_LIT8( KNatPluginTypeIce, "ice" ); +_LIT8( KNatPluginTypeHost, "host" ); + +const TInt KErrRoleConflict = 487; + +template +class CleanupResetAndDestroy + { + +public: + inline static void PushL( T& aRef ); + +private: + static void ResetAndDestroy( TAny *aPtr ); + }; + +template +inline void CleanupResetAndDestroyPushL( T& aRef ); + +template +inline void CleanupResetAndDestroy::PushL( T& aRef ) + { CleanupStack::PushL( TCleanupItem( &ResetAndDestroy, &aRef ) ); } + +template +void CleanupResetAndDestroy::ResetAndDestroy( TAny *aPtr ) + { + if ( aPtr ) + { + static_cast( aPtr )->ResetAndDestroy(); + } + } + +template +inline void CleanupResetAndDestroyPushL( T& aRef ) + { CleanupResetAndDestroy::PushL( aRef ); } + +class TCounter + { +public: + + TCounter( TUint aStreamId ) + : + iStreamId( aStreamId ), + iCount( 0 ) { } + + TCounter( TUint aStreamId, TInt aCount ) + : + iStreamId( aStreamId ), + iCount( aCount ) { } + + TUint StreamId() const { return iStreamId; } + TUint Count() const { return iCount; } + + TBool operator==( TInt aCount ) const + { return ( iCount == aCount ); } + + TBool operator!=( TInt aCount ) const + { return ( iCount != aCount ); } + + TCounter operator++( TInt ) + { TCounter temp = *this; ++iCount; return temp; } + + TCounter& operator++() + { ++iCount; return *this; } + + TCounter operator--( TInt ) + { TCounter temp = *this; --iCount; return temp; } + + TCounter& operator--() + { --iCount; return *this; } + + static TBool MatchStreamId( + const TCounter& aCnt1, + const TCounter& aCnt2 ) + { + return ( aCnt1.StreamId() == aCnt2.StreamId() ); + } + +private: + + TCounter(); + TUint iStreamId; + TInt iCount; + }; + +class TIceUtils + { +public: + static TBool MatchAddresses( + const TInetAddr& aAddr1, const TInetAddr& aAddr2 ) + { + // CmpAddr does not interpret IPv4 and IPv4-mapped/compatible addresses + // as same even if they represent same address. Thus extra testing is + // needed to handle that case. + TBool isMatch = + ( aAddr1.CmpAddr( aAddr2 ) || ( aAddr1.Address() == aAddr2.Address() + && aAddr1.Port() == aAddr2.Port() ) ); + return isMatch; + } + }; + + +#endif // ICECANDIDATEHANDLERDEFS_H