|
1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Resolver for remote items |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 #ifndef UPNPREMOTEITEMRESOLVER_H |
|
24 #define UPNPREMOTEITEMRESOLVER_H |
|
25 |
|
26 // INCLUDES |
|
27 #include <e32base.h> |
|
28 #include "upnpitemresolver.h" // base class |
|
29 #include "upnpabstractbrowsingsessionobserver.h" // base class |
|
30 |
|
31 // FORWARD DECLARATIONS |
|
32 class MUPnPAVBrowsingSession; |
|
33 class CUpnpItem; |
|
34 class CUpnpElement; |
|
35 class MUPnPResourceSelector; |
|
36 |
|
37 // CLASS DECLARATION |
|
38 |
|
39 /** |
|
40 * Resolves remote upnp items from a plain item id. |
|
41 * This resolving is done by executing a upnp metadata browse, or |
|
42 * possibly several ones of those. |
|
43 * |
|
44 * @lib upnpavcontrollerhelper.lib |
|
45 * @since S60 3.2 |
|
46 */ |
|
47 class CUPnPRemoteItemResolver |
|
48 : public CUPnPAbstractBrowsingSessionObserver |
|
49 , public MUPnPItemResolver |
|
50 { |
|
51 public: // construction/destruction |
|
52 |
|
53 /** |
|
54 * static constructor. |
|
55 * |
|
56 * @since Series 60 3.2 |
|
57 * @param aItemId, item to be resolved |
|
58 * @param aHostSession, browsing session |
|
59 * @param aSelector, resource selector |
|
60 * @param aBrowseFilter, filter |
|
61 * @return RemoteItemResolver instance |
|
62 */ |
|
63 static CUPnPRemoteItemResolver* NewL( |
|
64 const TDesC8& aItemId, |
|
65 MUPnPAVBrowsingSession& aHostSession, |
|
66 MUPnPResourceSelector& aSelector, |
|
67 const TDesC8& aBrowseFilter ); |
|
68 |
|
69 /** |
|
70 * destructor |
|
71 * @since Series 60 3.2 |
|
72 */ |
|
73 virtual ~CUPnPRemoteItemResolver(); |
|
74 |
|
75 private: // private construction part |
|
76 |
|
77 /** |
|
78 * default constructor. |
|
79 * |
|
80 * @since Series 60 3.2 |
|
81 * @param aItemId, item to be resolved |
|
82 * @param aHostSession, browsing session |
|
83 * @param aSelector, resource selector |
|
84 * @param aBrowseFilter, filter |
|
85 */ |
|
86 CUPnPRemoteItemResolver( |
|
87 const TDesC8& aItemId, |
|
88 MUPnPAVBrowsingSession& aHostSession, |
|
89 MUPnPResourceSelector& aSelector, |
|
90 const TDesC8& aBrowseFilter ); |
|
91 |
|
92 /** |
|
93 * 2nd phase constructor. |
|
94 * |
|
95 * @since Series 60 3.2 |
|
96 * @param aItemId, item to be resolved |
|
97 * @param aHostSession, browsing session |
|
98 * @param aSelector, resource selector |
|
99 * @param aBrowseFilter, filter |
|
100 */ |
|
101 void ConstructL( |
|
102 const TDesC8& aItemId, |
|
103 MUPnPAVBrowsingSession& aHostSession, |
|
104 MUPnPResourceSelector& aSelector, |
|
105 const TDesC8& aBrowseFilter ); |
|
106 |
|
107 |
|
108 public: // the interface |
|
109 |
|
110 /** |
|
111 * see UPnPItemResolver |
|
112 */ |
|
113 void ResolveL( |
|
114 MUPnPItemResolverObserver& aObserver ); |
|
115 |
|
116 /** |
|
117 * see UPnPItemResolver |
|
118 */ |
|
119 const CUpnpItem& Item() const; |
|
120 |
|
121 |
|
122 /** |
|
123 * see UPnPItemResolver |
|
124 */ |
|
125 const CUpnpElement& Resource() const; |
|
126 |
|
127 |
|
128 protected: // MUPnPAVBrowsingSessionObserver |
|
129 |
|
130 /** |
|
131 * see MUPnPAVBrowsingSessionObserver |
|
132 */ |
|
133 void BrowseResponse( |
|
134 const TDesC8& aBrowseResponse, |
|
135 TInt aError, |
|
136 TInt aMatches, |
|
137 TInt aTotalCount, |
|
138 const TDesC8& aUpdateId |
|
139 ); |
|
140 |
|
141 |
|
142 private: // private methods |
|
143 |
|
144 /** |
|
145 * after receiving the result object, processes it: |
|
146 * either continues browsing recursively or calls back |
|
147 * notifying the object is ready to be fetched. |
|
148 */ |
|
149 void ProcessResultObjectL( const CUpnpObject* aResult ); |
|
150 |
|
151 /** |
|
152 * Completes ongoing async operation |
|
153 */ |
|
154 void Complete( TInt aError ); |
|
155 |
|
156 /** |
|
157 * Clean up all resources |
|
158 */ |
|
159 void Cleanup(); |
|
160 |
|
161 /** |
|
162 * internal state machinery |
|
163 */ |
|
164 enum TInternalState { |
|
165 EStateIdle, // no data, ready for starting |
|
166 EStateActive, // browsing for data |
|
167 EStateReady // Data exists |
|
168 }; |
|
169 |
|
170 /** |
|
171 * Handles the parsing of the browse response. |
|
172 * |
|
173 * @since S60 3.2 |
|
174 * @param aBrowseResponse (const TDesC8&) the browse response |
|
175 */ |
|
176 void BrowseResponseL( const TDesC8& aBrowseResponse ); |
|
177 |
|
178 private: // members |
|
179 |
|
180 // item to resolve (Owned) |
|
181 HBufC8* iItemId; |
|
182 |
|
183 // the host browsing session |
|
184 MUPnPAVBrowsingSession& iBrowsingSession; |
|
185 |
|
186 // selector interface to use |
|
187 MUPnPResourceSelector& iSelector; |
|
188 |
|
189 // filter used in browse |
|
190 const TDesC8& iBrowseFilter; |
|
191 |
|
192 // observer for the resolver. NOT OWNED |
|
193 MUPnPItemResolverObserver* iObserver; |
|
194 |
|
195 // state of the class |
|
196 TInternalState iState; |
|
197 |
|
198 // counter for browse resursion |
|
199 TInt iRecursionDepth; |
|
200 |
|
201 // the first level browse result item (Owned). |
|
202 CUpnpItem* iFirstLevelItem; |
|
203 |
|
204 // optional: last level browse result item, if first level |
|
205 // is a pointer object (Owned). |
|
206 CUpnpItem* iLastLevelItem; |
|
207 |
|
208 // The selected resource within the last level item. NOT OWNED |
|
209 const CUpnpElement* iResource; |
|
210 |
|
211 }; |
|
212 |
|
213 |
|
214 #endif // UPNPREMOTEITEMRESOLVER_H |
|
215 |
|
216 // End of File |