|
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 local items |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 #ifndef UPNPLOCALITEMRESOLVER_H |
|
24 #define UPNPLOCALITEMRESOLVER_H |
|
25 |
|
26 // INCLUDES |
|
27 #include <e32base.h> |
|
28 #include "upnpavbrowsingsessionobserver.h" // base class |
|
29 #include "upnpitemresolver.h" // base class |
|
30 #include <upnpmediaserverclient.h> // a member |
|
31 |
|
32 // FORWARD DECLARATIONS |
|
33 class MUPnPAVController; |
|
34 class MUPnPAVBrowsingSession; |
|
35 class CUpnpFileSharing; |
|
36 class CUpnpItem; |
|
37 class CUpnpSecAccessController; |
|
38 class CUPnPPeriodic; |
|
39 |
|
40 // CLASS DECLARATION |
|
41 |
|
42 /** |
|
43 * Resolves remote upnp items from a plain item id. |
|
44 * This resolving is done by executing a upnp metadata browse, or |
|
45 * possibly several ones of those. |
|
46 * |
|
47 * @lib upnpavcontrollerhelper.lib |
|
48 * @since S60 3.2 |
|
49 */ |
|
50 class CUPnPLocalItemResolver |
|
51 : public CActive |
|
52 , public MUPnPAVBrowsingSessionObserver |
|
53 , public MUPnPItemResolver |
|
54 { |
|
55 public: // construction/destruction |
|
56 |
|
57 /** |
|
58 * static constructor |
|
59 * |
|
60 * @since Series 60 3.2 |
|
61 * @param aFilePath, local item to be resolved |
|
62 * @param aAvController, AVController |
|
63 * @param aSelector, resource selector |
|
64 * @param aOptimisationFlags flags to optimise the algorithm |
|
65 * @return LocaltemResolver instance |
|
66 */ |
|
67 static CUPnPLocalItemResolver* NewL( |
|
68 const TDesC& aFilePath, |
|
69 MUPnPAVController& aAvController, |
|
70 MUPnPResourceSelector& aSelector, |
|
71 TInt aOptimisationFlags ); |
|
72 |
|
73 /** |
|
74 * destructor |
|
75 * @since Series 60 3.2 |
|
76 */ |
|
77 virtual ~CUPnPLocalItemResolver(); |
|
78 |
|
79 private: |
|
80 |
|
81 /** |
|
82 * default constructor |
|
83 * |
|
84 * @since Series 60 3.2 |
|
85 * @param aAvController, AVController |
|
86 * @param aSelector, resource selector |
|
87 */ |
|
88 CUPnPLocalItemResolver( |
|
89 MUPnPAVController& aAvController, |
|
90 MUPnPResourceSelector& aSelector, |
|
91 TInt aOptimisationFlags ); |
|
92 |
|
93 /** |
|
94 * 2nd phase constructor |
|
95 * |
|
96 * @param aFilePath, local item to be resolved |
|
97 */ |
|
98 void ConstructL( const TDesC& aFilePath ); |
|
99 |
|
100 private: // Business logic methods |
|
101 |
|
102 /** |
|
103 * Allows/denied access to the files to which the given item's res- |
|
104 * elements are pointing. |
|
105 * |
|
106 * @since Series 60 3.2 |
|
107 * @param aItem the item |
|
108 * @param aAccessAllowed ETrue to allow and EFalse to deny the access |
|
109 */ |
|
110 void SetAccesstoItemResources( CUpnpItem& aItem, TBool aAccessAllowed ); |
|
111 |
|
112 public: // the interface |
|
113 |
|
114 /** |
|
115 * see UPnPItemResolver |
|
116 */ |
|
117 void ResolveL( |
|
118 MUPnPItemResolverObserver& aObserver |
|
119 ); |
|
120 |
|
121 /** |
|
122 * see UPnPItemResolver |
|
123 */ |
|
124 const CUpnpItem& Item() const; |
|
125 |
|
126 |
|
127 /** |
|
128 * see UPnPItemResolver |
|
129 */ |
|
130 const CUpnpElement& Resource() const; |
|
131 |
|
132 protected: // From CActive |
|
133 |
|
134 /** |
|
135 * See CActive |
|
136 */ |
|
137 void RunL(); |
|
138 |
|
139 /** |
|
140 * See CActive |
|
141 */ |
|
142 void DoCancel(); |
|
143 |
|
144 /** |
|
145 * See CActive |
|
146 */ |
|
147 TInt RunError( TInt aError ); |
|
148 |
|
149 protected: // overrides to CUPnPBrowsingSessionObserverProxy |
|
150 |
|
151 |
|
152 /** |
|
153 * see MUPnPAVSessionObserverBase |
|
154 */ |
|
155 void ReserveLocalMSServicesCompleted( TInt aError ); |
|
156 |
|
157 |
|
158 private: // private methods |
|
159 |
|
160 /** |
|
161 * initiate the sharing process |
|
162 */ |
|
163 void DoShareL(); |
|
164 |
|
165 /** |
|
166 * initiate the unsharing process |
|
167 */ |
|
168 void DoUnshareL(); |
|
169 |
|
170 /** |
|
171 * Completes ongoing async operation |
|
172 */ |
|
173 void Complete( TInt aError ); |
|
174 |
|
175 /** |
|
176 * Clean up all resources |
|
177 */ |
|
178 void Cleanup(); |
|
179 |
|
180 /** |
|
181 * internal state machinery |
|
182 */ |
|
183 enum TInternalState { |
|
184 EStateIdle, // no data, ready for starting |
|
185 EStateCreatingItem, // CreateItemFromFileLC called |
|
186 EStateStartingMS, // starting the local mediaserver |
|
187 EStateSharing, // sharing the local file |
|
188 EStateUnsharing, // unsharing the local file |
|
189 EStateReady, // Ready. Can free. |
|
190 EStateCancel // command to cancel ongoing process |
|
191 }; |
|
192 |
|
193 private: // Call back methods of MUPnPAVBrowsingSessionObserver |
|
194 |
|
195 /* Not used */ |
|
196 void BrowseResponse( |
|
197 const TDesC8& /*aBrowseResponse*/, |
|
198 TInt /*aError*/, |
|
199 TInt /*aMatches*/, |
|
200 TInt /*aTotalCount*/, |
|
201 const TDesC8& /*aUpdateId*/ |
|
202 ) {} |
|
203 void SearchResponse( |
|
204 const TDesC8& /*aSearchResponse*/, |
|
205 TInt /*aError*/, |
|
206 TInt /*aMatches*/, |
|
207 TInt /*aTotalCount*/, |
|
208 const TDesC8& /*aUpdateId*/ |
|
209 ) {} |
|
210 void SearchCapabilitiesResponse( |
|
211 TInt /*aError*/, |
|
212 const TDesC8& /*aSearchCapabilities*/ |
|
213 ) {} |
|
214 void CreateContainerResponse( TInt /*aError*/, |
|
215 const TDesC8& /*aObjectId*/ ) {} |
|
216 void DeleteObjectResponse( TInt /*aError*/ ) {} |
|
217 |
|
218 void MediaServerDisappeared( |
|
219 TUPnPDeviceDisconnectedReason /*aReason*/ ) {} |
|
220 |
|
221 |
|
222 private: // Timer callback |
|
223 /** |
|
224 * timer callback |
|
225 * unsharing is sometimes jammed and timer is used for cancelling |
|
226 * unshare call |
|
227 */ |
|
228 static TInt TimerExpired( TAny* aArg ); |
|
229 |
|
230 private: // members |
|
231 |
|
232 // local file path (Owned). |
|
233 HBufC* iFilePath; |
|
234 |
|
235 // avcontroller |
|
236 MUPnPAVController& iAvController; |
|
237 |
|
238 // temporary session for starting local mediaserver |
|
239 MUPnPAVBrowsingSession* iTempSession; |
|
240 |
|
241 // resource selector |
|
242 MUPnPResourceSelector& iSelector; |
|
243 |
|
244 // observer for this utility. Note: NOT OWNED |
|
245 MUPnPItemResolverObserver* iObserver; |
|
246 |
|
247 // state of the class |
|
248 TInternalState iState; |
|
249 |
|
250 // the first level browse result item (Owned). |
|
251 CUpnpItem* iSharedItem; |
|
252 |
|
253 // The selected resource within the last level item. |
|
254 const CUpnpElement* iResource; |
|
255 |
|
256 // The mediaserver (required to get the server IP address) |
|
257 RUpnpMediaServerClient iMediaServer; |
|
258 |
|
259 // optimisation flags |
|
260 TInt iOptimisationFlags; |
|
261 |
|
262 // S60 file sharing metadata interface |
|
263 CUpnpFileSharing* iFileSharing; |
|
264 |
|
265 // security access controller |
|
266 CUpnpSecAccessController* iAccessController; |
|
267 |
|
268 // wait until unshare finishes |
|
269 CActiveSchedulerWait* iWait; |
|
270 |
|
271 // timer to cancel unshare |
|
272 CUPnPPeriodic* iTimer; |
|
273 }; |
|
274 |
|
275 |
|
276 #endif // UPNPLOCALITEMRESOLVER_H |
|
277 |
|
278 // End of File |