|
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 // @file |
|
15 // @internalComponent |
|
16 // |
|
17 // |
|
18 |
|
19 #ifndef __UPNPCONTROLSCPR_H |
|
20 #define __UPNPCONTROLSCPR_H |
|
21 |
|
22 #include <comms-infras/corescpr.h> |
|
23 #include <comms-infras/ss_nodemessages.h> |
|
24 |
|
25 #include <upnpparamset.h> |
|
26 #include <upnp/pnpextparameterfamily.h> |
|
27 #include <rmemchunk.h> |
|
28 |
|
29 #include "upnpctrlcpr.h" |
|
30 #include "upnpscpr.h" |
|
31 |
|
32 using namespace Messages; |
|
33 |
|
34 |
|
35 //Forward Declarations |
|
36 namespace UPnPControlSCprStates |
|
37 { |
|
38 class TStoreRequestParams; |
|
39 class TSendRequestParamResponse; |
|
40 class TInitiateActivities; |
|
41 } |
|
42 |
|
43 |
|
44 // Subscription Information Element |
|
45 class CSubscriptionInfo: public CBase |
|
46 { |
|
47 public: |
|
48 CSubscriptionInfo ( TNodeId& aFlowId ) |
|
49 : iSeqKey ( -1 ), iDataClient ( aFlowId ) |
|
50 { } |
|
51 |
|
52 ~CSubscriptionInfo ( ) |
|
53 { |
|
54 iPublishUrl.Close ( ); |
|
55 iSid.Close ( ); |
|
56 } |
|
57 |
|
58 void SetPublishUrlL ( const TDesC8& aUrl ) |
|
59 { |
|
60 iPublishUrl.Close ( ); |
|
61 iPublishUrl.CreateL ( aUrl ); |
|
62 } |
|
63 |
|
64 void SetSidL ( RMemChunk& aSid ) |
|
65 { |
|
66 iSid.CreateMaxL ( aSid.Length ( ) ); |
|
67 aSid.CopyOut ( iSid ); |
|
68 } |
|
69 |
|
70 TInt iSeqKey; |
|
71 TNodeId iDataClient; |
|
72 RBuf8 iPublishUrl; |
|
73 RBuf8 iSid; |
|
74 }; |
|
75 |
|
76 class CUPnPControlSubConnectionProvider : public CUPnPSubConnectionProvider |
|
77 { |
|
78 friend class UPnPControlSCprStates::TStoreRequestParams; |
|
79 friend class UPnPControlSCprStates::TSendRequestParamResponse; |
|
80 friend class UPnPControlSCprStates::TInitiateActivities; |
|
81 |
|
82 public: |
|
83 static CUPnPControlSubConnectionProvider* NewL ( CSubConnectionProviderFactoryBase& aFactory ); |
|
84 virtual ~CUPnPControlSubConnectionProvider ( ); |
|
85 |
|
86 |
|
87 TNodeId UdpClientFlow ( ); |
|
88 TNodeId UdpServerFlow ( ); |
|
89 TNodeId TcpServerFlow ( ); |
|
90 void SetUdpServerFlow ( const TNodeId& aCommsId ); |
|
91 void SetTcpServerFlow ( const TNodeId& aCommsId ); |
|
92 void SetUdpClientFlow ( const TNodeId& aCommsId ); |
|
93 |
|
94 inline TBool SetClosing ( ); |
|
95 inline TBool IsClosing ( ); |
|
96 inline const TDesC8& Callback() const; |
|
97 |
|
98 void AddResponseParamSetL ( XParameterSetBase* aResponseSet, const TUint32 aFamilyId); |
|
99 |
|
100 void AddSubscriptionInfoL(CSubscriptionInfo* aSubscriptionInfo); |
|
101 void RemoveSubscriptionInfo ( const TDesC8& aSid ); |
|
102 CSubscriptionInfo* GetSubscriptionInfoByUrl( const TDesC8& aPublishUrl ); |
|
103 CSubscriptionInfo* GetSubscriptionInfoBySid ( const TDesC8& aSid ); |
|
104 CUPnPControlConnectionProvider& ConnectionProvider ( ); |
|
105 |
|
106 private: |
|
107 CUPnPControlSubConnectionProvider ( CSubConnectionProviderFactoryBase& aFactory, const MeshMachine::TNodeActivityMap& aActivityMap ); |
|
108 void ConstructL ( ); |
|
109 virtual void ReceivedL ( const Messages::TRuntimeCtxId& aSender, const Messages::TNodeId& aRecipient, Messages::TSignatureBase& aMessage ); |
|
110 void HandlePassThroughMessage ( MeshMachine::TNodeContextBase& aContext ); |
|
111 |
|
112 void InitiateActivitiesL ( ); |
|
113 void InitiateRequestL ( RParameterFamily& aReqFamily ); |
|
114 void ClearResponseParamL ( ); |
|
115 void NotifySubConnectionIfResultsAvailable ( ); |
|
116 TBool CheckForResultsAvailability ( TUint32& aFamilyId ); |
|
117 RParameterFamily GetUPnPFamilyById ( TUint32 aFamilyId ); |
|
118 void CleanupEventQueuedResponses ( const TDesC8& aUrl, TUint aFamilyId ); |
|
119 |
|
120 // Enqueue's event for CSubConnection, if not closing |
|
121 void NotifySubConnectionL ( const TUint32 aResponseFamilyId ); |
|
122 |
|
123 void GenerateCallbackUrlL ( ); |
|
124 |
|
125 public: |
|
126 struct TFlowInfo |
|
127 { |
|
128 TAppProtAddr iAppProtAddr; |
|
129 TNodeId iDataClient; |
|
130 }; |
|
131 RArray<TFlowInfo> iFlowInfo; |
|
132 TBool iTcpSrvFlowCreateRequested; |
|
133 |
|
134 private: |
|
135 RCFParameterFamilyBundle iResponseBundle; |
|
136 RParameterFamilyBundle iRequestBundle; |
|
137 RParameterFamilyBundle iQueueBundle; |
|
138 |
|
139 |
|
140 TBool iResponseBlocked; |
|
141 TNodeId iUdpClientFlow; |
|
142 TNodeId iUdpServerFlow; |
|
143 TNodeId iTcpServerFlow; |
|
144 |
|
145 RBuf8 iCallbackUrl; |
|
146 RPointerArray<CSubscriptionInfo> iSubscriptions; |
|
147 }; |
|
148 |
|
149 inline TNodeId CUPnPControlSubConnectionProvider::UdpClientFlow ( ) |
|
150 { |
|
151 return iUdpClientFlow; |
|
152 } |
|
153 |
|
154 inline void CUPnPControlSubConnectionProvider::SetUdpClientFlow ( const TNodeId& aCommsId ) |
|
155 { |
|
156 iUdpClientFlow = aCommsId; |
|
157 } |
|
158 |
|
159 inline TNodeId CUPnPControlSubConnectionProvider::UdpServerFlow ( ) |
|
160 { |
|
161 return iUdpServerFlow; |
|
162 } |
|
163 |
|
164 inline void CUPnPControlSubConnectionProvider::SetUdpServerFlow ( const TNodeId& aCommsId ) |
|
165 { |
|
166 iUdpServerFlow = aCommsId; |
|
167 } |
|
168 |
|
169 inline TNodeId CUPnPControlSubConnectionProvider::TcpServerFlow ( ) |
|
170 { |
|
171 return iTcpServerFlow; |
|
172 } |
|
173 |
|
174 inline void CUPnPControlSubConnectionProvider::SetTcpServerFlow ( const TNodeId& aCommsId ) |
|
175 { |
|
176 iTcpServerFlow = aCommsId; |
|
177 } |
|
178 |
|
179 const TDesC8& CUPnPControlSubConnectionProvider::Callback ( ) const |
|
180 { |
|
181 return iCallbackUrl; |
|
182 } |
|
183 |
|
184 TBool CUPnPControlSubConnectionProvider::IsClosing ( ) |
|
185 { |
|
186 // Note: this API is not helping as UPnP parallel activities |
|
187 // may have same id value |
|
188 // return CountActivities ( ECFActivityDestroy ) == 1 ? ETrue : EFalse; |
|
189 // check if control client i.e CSubConnection is joined or not |
|
190 RNodeInterface* cc = GetFirstClient<TDefaultClientMatchPolicy> ( TCFClientType::ECtrl ); |
|
191 return cc == NULL ? ETrue : EFalse; |
|
192 } |
|
193 |
|
194 #endif // UPNPCONTROLSCPR_H |