|
1 /** @file |
|
2 * Copyright (c) 2005-2006 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: CUpnpDlnaFilter declaration. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef UPNPDLNAFILTER_H |
|
19 #define UPNPDLNAFILTER_H |
|
20 |
|
21 // INCLUDES |
|
22 #include <e32std.h> |
|
23 #include <e32base.h> |
|
24 #include <f32file.h> |
|
25 #include "upnphttpservertransactioncreator.h" |
|
26 |
|
27 class MUpnpContentDirectoryDataFinder; |
|
28 class CUpnpHttpMessage; |
|
29 class CUpnpDlnaProtocolInfo; |
|
30 class CUpnpSecurityManager; |
|
31 class CUpnpHttpFileServeTransaction; |
|
32 class CUpnpHttpFileReceiveTransaction; |
|
33 class CUpnpDlnaFilterHeaders; |
|
34 class TUpnpDlnaCorelation; |
|
35 |
|
36 // CLASS DECLARATION |
|
37 |
|
38 /** |
|
39 * CUpnpDlnaFilter |
|
40 * |
|
41 */ |
|
42 NONSHARABLE_CLASS( CUpnpDlnaFilter ) : public CBase, |
|
43 public MUpnpHttpServerTransactionCreator |
|
44 { |
|
45 public: |
|
46 // Public Constructors and destructor |
|
47 |
|
48 /** |
|
49 * Destructor. |
|
50 */ |
|
51 ~CUpnpDlnaFilter(); |
|
52 |
|
53 /** |
|
54 * Two-phased constructor. |
|
55 */ |
|
56 static CUpnpDlnaFilter* NewL( MUpnpContentDirectoryDataFinder* aFinder, |
|
57 CUpnpSecurityManager* aSecurityManager ); |
|
58 |
|
59 /** |
|
60 * Two-phased constructor. |
|
61 */ |
|
62 static CUpnpDlnaFilter* NewLC( MUpnpContentDirectoryDataFinder* aFinder, |
|
63 CUpnpSecurityManager* aSecurityManager ); |
|
64 |
|
65 //from MUpnpHttpServerTransactionCreator |
|
66 virtual void NewTransactionL( |
|
67 const TDesC8& aMethod, const TDesC8& aUri, |
|
68 const TInetAddr& aSender, CUpnpHttpServerTransaction*& aResultTrans ); |
|
69 |
|
70 //from MUpnpHttpServerTransactionCreator |
|
71 |
|
72 /** |
|
73 * Checks correctness of path to, requested in HTTP message, file and |
|
74 * changes its format to be compliant with Symbian's file system. |
|
75 * @since Series60 2.6 |
|
76 * @param aMsg HTTP message containing file request. |
|
77 * @param aPathWithNewMethod reference which is filled with formated path |
|
78 * to requested file. |
|
79 **/ |
|
80 void FormatPathL( CUpnpHttpFileServeTransaction *aTransaction, TDes &aPath ); |
|
81 |
|
82 /** |
|
83 * Add appropriate directives to http header according to DLNA specification |
|
84 * @param aTransaction http transaction |
|
85 * @return KErrNone header prepared successfully, otherwise -EHttpNotFound |
|
86 * If DLNA correlations are wrong error from then it returns an error |
|
87 */ |
|
88 TInt PrepareHeaderL( CUpnpHttpFileServeTransaction &aTransaction ); |
|
89 |
|
90 /** |
|
91 * Method checks DLNA transferMode for POST messages. |
|
92 * @since Series60 2.6 |
|
93 * @param aPostMessage - incoming POST message with upload to be saved in file. |
|
94 * @return ETrue if POST can be accepted. |
|
95 **/ |
|
96 TInt CheckDLNAPostCorrelationsL(CUpnpHttpFileReceiveTransaction& aTransaction); |
|
97 |
|
98 /** |
|
99 * Determines download path basing on incomming POST message and media path got |
|
100 * from server. Result is saved in iInFilename. |
|
101 * If file should not be saved, flag iSaveToFile will be set to EFalse. |
|
102 * @since Series60 2.6 |
|
103 * @param aPostMessage - incoming POST message with upload to be saved in file. |
|
104 * @return download path or NULL in case of error |
|
105 */ |
|
106 HBufC* DetermineDownloadPathL(CUpnpHttpFileReceiveTransaction& aTransaction); |
|
107 |
|
108 //security manager getter |
|
109 CUpnpSecurityManager* SecurityManager(); |
|
110 |
|
111 //file server session getter |
|
112 RFs& FileSession(); |
|
113 |
|
114 /** |
|
115 * Check if resource is accessible |
|
116 * @param aFileName data source file name |
|
117 * @param aSender sender |
|
118 * @return KErrNone if resource is accessible, otherwise -EHttpNotFound |
|
119 */ |
|
120 TInt AuthorizeRequestL( const TDesC& aFileName, const TInetAddr& aSender ); |
|
121 |
|
122 public: |
|
123 // protected |
|
124 // Private Constructors |
|
125 |
|
126 /** |
|
127 * Constructor for performing 1st stage construction |
|
128 */ |
|
129 CUpnpDlnaFilter( MUpnpContentDirectoryDataFinder* aFinder, |
|
130 CUpnpSecurityManager* aSecurityManager ); |
|
131 |
|
132 /** |
|
133 * EPOC default constructor for performing 2nd stage construction |
|
134 */ |
|
135 void ConstructL(); |
|
136 |
|
137 private: |
|
138 |
|
139 /** |
|
140 * Find protocolInfo by contentUri (Not by importUri) and extract 3rd field, |
|
141 * using ContentDirectory. |
|
142 * @param aFullContentUri uri to be searched in database |
|
143 * (full value of resource with IP:port prefix). |
|
144 * @return a3rdhField 3rdhField from protocolInfo (if it is DLNA compatible) which is |
|
145 * related to founded resource. Ownership is transfered to the caller. |
|
146 */ |
|
147 HBufC8* CUpnpDlnaFilter::ThirdFieldFromCdL( const TDesC8& aContentUri ); |
|
148 |
|
149 /** |
|
150 * Gets name of file with content for given object's id. |
|
151 * @param aObjectId id of the ContentDirecotry object holding the content |
|
152 * @param aFileName pointer to buffer in which the name of the file will be returned. |
|
153 * Buffer for aFileName has to allocated first. |
|
154 */ |
|
155 void GetMediaFileNameL( TInt aObjectId, TPtr& aFileName ); |
|
156 |
|
157 /** |
|
158 * Find a folder shared from DB (ContentDirectory). |
|
159 * @param aUrlPath Name of URL path that needs to be found and converted |
|
160 * to aFolderPath |
|
161 * @param aFileName Name of shared file (can be null if just folder is looking for). |
|
162 * @param aSystemPath Name of shared folder. |
|
163 * @return KErrNone or another of the system error codes. |
|
164 */ |
|
165 TInt FindSharedFolderDBL(const TDesC8& aUrlPath, const TDesC8& aFileName, |
|
166 HBufC8*& aSystemPath); |
|
167 |
|
168 /** |
|
169 * Checks if specified URI exists in database and returns object id for |
|
170 * given URI or KErrNotFound if URI is no registered in database. |
|
171 * @param aImportUri uri to be searched in databse. |
|
172 * @return objId if successful or KErrnone if object wasn't found. |
|
173 */ |
|
174 TInt CheckImportUriL( TDesC8& aImportUri ); |
|
175 |
|
176 /** |
|
177 * Checks DLNA correlations for given message. |
|
178 * @since Series60 2.6 |
|
179 * @param aMessage message for which correlations check will be performed |
|
180 * exists for given message. |
|
181 * @return KErrNone if no HTTPerror problem occurs |
|
182 **/ |
|
183 TInt CheckDLNACorrelationsL( CUpnpHttpFileServeTransaction& aTransaction ); |
|
184 |
|
185 |
|
186 /** |
|
187 * Method returns content type of a resource |
|
188 * @since Series60 3.2 |
|
189 * @param aMessage, aMime, aFilename |
|
190 * @return KErrNone if mime type retrieved with no errors |
|
191 **/ |
|
192 TInt GetContentTypeL( CUpnpHttpFileServeTransaction &aTransaction, HBufC8*& aMime, |
|
193 const TDesC16& aFilename ); |
|
194 |
|
195 |
|
196 CUpnpDlnaProtocolInfo* ProtocolInfoL( const TDesC8& aContentUri ); |
|
197 |
|
198 void AddHeaderIfNotEmptyL( const TDesC8& aHeaderName, |
|
199 CUpnpHttpFileServeTransaction& aTransaction ); |
|
200 |
|
201 |
|
202 HBufC* MakeFileNameUniqueL( const TDesC& aFilename, RFs& aFs ); |
|
203 |
|
204 HBufC* PreparePostfixToMakeFileUniqueL( const TDesC& aFilename, RFs& aFs ); |
|
205 |
|
206 HBufC* PrepareBaseFileNameL( const TDesC& aFilename, RFs& aFs ); |
|
207 |
|
208 TInt CheckCorelationL( CUpnpHttpFileServeTransaction& aTransaction, |
|
209 TUpnpDlnaCorelation& aDlnaCorelation ); |
|
210 |
|
211 TInt CheckTransferModeL( CUpnpHttpFileServeTransaction& aTransaction, |
|
212 TUpnpDlnaCorelation& aDlnaCorelation ); |
|
213 |
|
214 TInt AppendCorelationHeadersL( CUpnpHttpFileServeTransaction& aTransaction, |
|
215 TUpnpDlnaCorelation& aDlnaCorelation, TDesC8& aTransferMode ); |
|
216 |
|
217 protected: |
|
218 |
|
219 // Pointer to ContentDirectoryDataFinder implementation. |
|
220 // Not owned. |
|
221 MUpnpContentDirectoryDataFinder* iCdDataFinder; |
|
222 |
|
223 CUpnpSecurityManager* iSecurityManager; |
|
224 |
|
225 // protocol info for dlna corelation |
|
226 CUpnpDlnaProtocolInfo* iProtocolInfo; |
|
227 |
|
228 RFs iFs; |
|
229 |
|
230 }; |
|
231 |
|
232 #endif // UPNPDLNAFILTER_H |
|
233 // End Of File |