|
1 // Copyright (c) 2008-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 #ifndef __CUPNPPUBLISHER_H_ |
|
17 #define __CUPNPPUBLISHER_H_ |
|
18 #include <e32math.h> |
|
19 #include <upnpparamset.h> |
|
20 #include <pnpparameterbundle.h> |
|
21 #include <mpnpobserver.h> |
|
22 |
|
23 const TInt KMicroTime = 1000000; |
|
24 /* Used to send publish advertisements to the network.Also periodic refreshment |
|
25 of these advertisements is done |
|
26 @internalComponent |
|
27 */ |
|
28 class CUPnPPublisher : public CBase |
|
29 { |
|
30 public: |
|
31 static CUPnPPublisher* NewL ( RSubConnection& aSubConnection ); |
|
32 ~CUPnPPublisher(); |
|
33 void SubmitRequestL( const RPnPParameterBundle& aServiceInfo ); |
|
34 void NotifyResultsL(RPnPParameterBundleBase& aBundle); |
|
35 |
|
36 public: |
|
37 inline TBool IsService(); |
|
38 |
|
39 private: |
|
40 CUPnPPublisher(RSubConnection& aSubConnection ); |
|
41 static TInt AdvertisementRefresh(TAny* aPtr); |
|
42 inline TUint64 CalculatePeriod (TInt aTime); |
|
43 inline RSubConnection& SubConnection(); |
|
44 void ConstructL(); |
|
45 void ValidateOtherFieldsL(const CUPnPDeviceRegisterParamSet& aDeviceParam); |
|
46 void ValidateIconList(const CUPnPDeviceRegisterParamSet& aDeviceParam); |
|
47 void CopyWithIconInfoL ( const CUPnPDeviceRegisterParamSet& aDeviceParam, RPnPParameterBundleBase& aBundle ); |
|
48 void StoreIconListL ( const CUPnPIconList& aIconList, RBuf8& aBuffer ); |
|
49 |
|
50 MPnPObserver* iObserver; |
|
51 RSubConnection& iSubConnection; |
|
52 CPeriodic* iPeriodTimer; |
|
53 TBool iService; |
|
54 TInt iPeriod; |
|
55 TInt iTime; |
|
56 }; |
|
57 |
|
58 /* Used to calculate the period of refeshing the advertisement given the cache time |
|
59 For convenience, the period is kept at 1/3rd of the cache time |
|
60 @param aTime The cache control time |
|
61 @return The period time |
|
62 */ |
|
63 TUint64 CUPnPPublisher::CalculatePeriod(TInt aTime) |
|
64 { |
|
65 const TUint64 divisor = 3; |
|
66 TUint64 temp; // Placeholder |
|
67 TUint64 q = Math::UDivMod64(aTime,divisor,temp); |
|
68 return q; |
|
69 } |
|
70 |
|
71 RSubConnection& CUPnPPublisher::SubConnection() |
|
72 { |
|
73 return iSubConnection; |
|
74 } |
|
75 |
|
76 TBool CUPnPPublisher::IsService() |
|
77 { |
|
78 return iService; |
|
79 } |
|
80 |
|
81 #endif /*CUPNPPUBLISHER_H_*/ |