diff -r 000000000000 -r f5a58ecadc66 servicediscoveryandcontrol/pnp/test/upnp/Client/upnpplugin/inc/cupnppublisher.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/servicediscoveryandcontrol/pnp/test/upnp/Client/upnpplugin/inc/cupnppublisher.h Tue Feb 02 01:12:20 2010 +0200 @@ -0,0 +1,81 @@ +// Copyright (c) 2008-2009 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 __CUPNPPUBLISHER_H_ +#define __CUPNPPUBLISHER_H_ +#include +#include +#include +#include + +const TInt KMicroTime = 1000000; +/* Used to send publish advertisements to the network.Also periodic refreshment + of these advertisements is done + @internalComponent + */ +class CUPnPPublisher : public CBase + { +public: + static CUPnPPublisher* NewL ( RSubConnection& aSubConnection ); + ~CUPnPPublisher(); + void SubmitRequestL( const RPnPParameterBundle& aServiceInfo ); + void NotifyResultsL(RPnPParameterBundleBase& aBundle); + +public: + inline TBool IsService(); + +private: + CUPnPPublisher(RSubConnection& aSubConnection ); + static TInt AdvertisementRefresh(TAny* aPtr); + inline TUint64 CalculatePeriod (TInt aTime); + inline RSubConnection& SubConnection(); + void ConstructL(); + void ValidateOtherFieldsL(const CUPnPDeviceRegisterParamSet& aDeviceParam); + void ValidateIconList(const CUPnPDeviceRegisterParamSet& aDeviceParam); + void CopyWithIconInfoL ( const CUPnPDeviceRegisterParamSet& aDeviceParam, RPnPParameterBundleBase& aBundle ); + void StoreIconListL ( const CUPnPIconList& aIconList, RBuf8& aBuffer ); + + MPnPObserver* iObserver; + RSubConnection& iSubConnection; + CPeriodic* iPeriodTimer; + TBool iService; + TInt iPeriod; + TInt iTime; + }; + +/* Used to calculate the period of refeshing the advertisement given the cache time + For convenience, the period is kept at 1/3rd of the cache time + @param aTime The cache control time + @return The period time + */ +TUint64 CUPnPPublisher::CalculatePeriod(TInt aTime) + { + const TUint64 divisor = 3; + TUint64 temp; // Placeholder + TUint64 q = Math::UDivMod64(aTime,divisor,temp); + return q; + } + +RSubConnection& CUPnPPublisher::SubConnection() + { + return iSubConnection; + } + +TBool CUPnPPublisher::IsService() + { + return iService; + } + +#endif /*CUPNPPUBLISHER_H_*/