|
1 /* |
|
2 * Copyright (c) 2005-2008 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: UPnP framework's common utility functions |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef UPNPCOMMONUTILS_H |
|
20 #define UPNPCOMMONUTILS_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <upnpobject.h> |
|
25 #include <f32file.h> |
|
26 |
|
27 // DATA TYPES |
|
28 enum TUPnPItemType |
|
29 { |
|
30 ETypeAudio = 0, |
|
31 ETypeVideo, |
|
32 ETypeImage, |
|
33 ETypePlaylist, |
|
34 ETypeOther |
|
35 }; |
|
36 |
|
37 // FORWARD DECLARATIONS |
|
38 class CUpnpItem; |
|
39 class CUpnpContainer; |
|
40 class CUpnpContainerList; |
|
41 class CUpnpAttribute; |
|
42 class TInetAddr; |
|
43 |
|
44 // CONSTANTS |
|
45 // upload directory |
|
46 _LIT( KUpnpUploadDirectory, "Download\\Media\\" ); |
|
47 |
|
48 // CLASS DECLARATION |
|
49 |
|
50 /** |
|
51 * UPnP Framework's common utility functions |
|
52 * |
|
53 * @lib upnputilities.lib |
|
54 * @since S60 3.0 |
|
55 */ |
|
56 class UPnPCommonUtils |
|
57 { |
|
58 |
|
59 public: // Business logic methods |
|
60 |
|
61 /** |
|
62 * Returns status whether memory card is inserted or not. |
|
63 * |
|
64 * @since S60 3.0 |
|
65 * @return TBool indicating the status of memory card |
|
66 */ |
|
67 IMPORT_C static TBool MemoryCardStateL(); |
|
68 |
|
69 /** |
|
70 * Resolves the MIME type of a file by it's content, using the |
|
71 * platform MIME recognizer. Leaves in error cases. |
|
72 * |
|
73 * @since S60 3.0 |
|
74 * @param TDesC8& file name (with full path info) |
|
75 * @return HBufC8* mime type |
|
76 */ |
|
77 IMPORT_C static HBufC8* ResolveMimeTypeL( |
|
78 const TDesC& aFileName ); |
|
79 |
|
80 /** |
|
81 * Resolves the MIME type of a file by it's extension. Leaves in error |
|
82 * cases. |
|
83 * |
|
84 * @since S60 3.0 |
|
85 * @param TDesC& const, file name (with full path info) |
|
86 * @return HBufC8* mime type |
|
87 */ |
|
88 IMPORT_C static HBufC8* GetMimeTypeByExtensionL( |
|
89 const TDesC& aFileName ); |
|
90 |
|
91 /** |
|
92 * Resolves the type of a file. Leaves in error cases. |
|
93 * |
|
94 * @since S60 3.0 |
|
95 * @param TDesC8& file name (with full path info) |
|
96 * @return TUPnPItemType file type |
|
97 */ |
|
98 IMPORT_C static TUPnPItemType ResolveFileTypeL( |
|
99 const TDesC& aFileName ); |
|
100 |
|
101 /** |
|
102 * Replaces IP address and port number placeholders of the RES |
|
103 * element's URI string of the given item. |
|
104 * |
|
105 * @since S60 3.1 |
|
106 * @param aItem (CUpnpItem&) the item which RES element's URI is to be |
|
107 * updated |
|
108 * @param aAddress (const TInetAddr&) the address and port number of |
|
109 * the updated URI |
|
110 */ |
|
111 IMPORT_C static void ReplacePlaceHolderInURIL( |
|
112 CUpnpItem& aItem, |
|
113 const TInetAddr& aAddress ); |
|
114 |
|
115 /** |
|
116 * Replaces the illegal filename characters of the given filename |
|
117 * string and returns a new fixed filename string. The following |
|
118 * characters are replaced with an underscore: >, <, ", \, /, *, |, |
|
119 * : and ?. 8bit version. |
|
120 * |
|
121 * @since S60 3.1 |
|
122 * @param aFileName (const TDesC8&) filename to be checked |
|
123 * @return HBufC8* fixed filename string |
|
124 **/ |
|
125 IMPORT_C static HBufC8* ReplaceIllegalFilenameCharactersL( |
|
126 const TDesC8& aFileName ); |
|
127 |
|
128 /** |
|
129 * Replaces the illegal filename characters of the given filename |
|
130 * string and returns a new fixed filename string. The following |
|
131 * characters are replaced with an underscore: >, <, ", \, /, *, |, |
|
132 * : and ?. 16bit version. |
|
133 * |
|
134 * @since S60 3.1 |
|
135 * @param aFileName (const TDesC&) filename to be checked |
|
136 * @return HBufC* fixed filename string |
|
137 **/ |
|
138 IMPORT_C static HBufC* ReplaceIllegalFilenameCharactersL( |
|
139 const TDesC& aFileName ); |
|
140 |
|
141 /** |
|
142 * Checks if the given CUpnpObject is a playlist container. Leaves if |
|
143 * the given object is not correctly formed. |
|
144 * |
|
145 * @since S60 3.1 |
|
146 * @param aContainer (const CUpnpObject&) filename to be checked |
|
147 * @return TBool |
|
148 **/ |
|
149 IMPORT_C static TBool IsPlaylistContainerL( |
|
150 const CUpnpObject& aContainer ); |
|
151 |
|
152 /** |
|
153 * Return container with given title from list of containers |
|
154 * |
|
155 * @since S60 3.1 |
|
156 * @param aList List containig containers to search |
|
157 * @param aTitle Title to search for |
|
158 * @return CUpnpContainer* The pointer to container, NULL if |
|
159 * not found |
|
160 **/ |
|
161 IMPORT_C static CUpnpContainer* FindContainerByTitle( |
|
162 const CUpnpContainerList& aList, const TDesC8& aTitle ); |
|
163 |
|
164 /** |
|
165 * Convert TInt to TDesC8 |
|
166 * @since S60 3.1 |
|
167 * @param aObject TInt to convert |
|
168 */ |
|
169 IMPORT_C static HBufC8* IntToDesC8LC( const TInt& aObject ); |
|
170 |
|
171 /** |
|
172 * Convert TDesC8 to TInt |
|
173 * @since S60 3.1 |
|
174 * @param aObject Descriptor to convert |
|
175 */ |
|
176 IMPORT_C static TInt DesC8ToInt( const TDesC8& aObject ); |
|
177 |
|
178 /** |
|
179 * Converts TTime to UPnP date string |
|
180 * |
|
181 * @since S60 3.1 |
|
182 * @param aTime time |
|
183 * @return UPnP date as a heap descriptor |
|
184 */ |
|
185 IMPORT_C static HBufC* TTimeToUPnPDateL( TTime aTime ); |
|
186 |
|
187 |
|
188 /** |
|
189 * Rename the downloaded file to %s_upnpfwtemp(%s is original filename) |
|
190 * used in play remote item on local device |
|
191 * @since S60 3.1 |
|
192 * |
|
193 * @param aFilePath original file path |
|
194 * @return HBufC pointer to the new filepath |
|
195 */ |
|
196 IMPORT_C static HBufC* UPnPCommonUtils::RenameFileL( const TDesC& aFilePath ); |
|
197 |
|
198 /** |
|
199 * Delete upnp genereated temporary files from download locations |
|
200 * both from phone memory and memory card |
|
201 * Leave in case of fatal errors |
|
202 * @since S60 3.1 |
|
203 * |
|
204 */ |
|
205 IMPORT_C static void DeleteTempFilesL(); |
|
206 |
|
207 |
|
208 /** |
|
209 * Checks if device supports images |
|
210 * |
|
211 * @since S60 3.1 |
|
212 * @param TDesC8& protocolinfo |
|
213 * @return TBool |
|
214 */ |
|
215 IMPORT_C static TBool IsImageSupported( |
|
216 const TDesC8& aProtocolInfo ); |
|
217 |
|
218 |
|
219 /** |
|
220 * Checks if device supports audio |
|
221 * |
|
222 * @since S60 3.1 |
|
223 * @param TDesC8& protocolinfo |
|
224 * @return TBool |
|
225 */ |
|
226 IMPORT_C static TBool IsAudioSupported( |
|
227 const TDesC8& aProtocolInfo ); |
|
228 |
|
229 |
|
230 /** |
|
231 * Checks if device supports video |
|
232 * |
|
233 * @since S60 3.1 |
|
234 * @param TDesC8& protocolinfo |
|
235 * @return TBool |
|
236 */ |
|
237 IMPORT_C static TBool IsVideoSupported( |
|
238 const TDesC8& aProtocolInfo ); |
|
239 |
|
240 /** |
|
241 * Return the file extension according a mime type |
|
242 * |
|
243 * @since S60 3.2 |
|
244 * @param const TDesC8& mime type |
|
245 * @return file extension |
|
246 */ |
|
247 IMPORT_C static HBufC* FileExtensionByMimeTypeL( |
|
248 const TDesC8& aMimeType ); |
|
249 |
|
250 /** |
|
251 * Removes the tab character of the given text |
|
252 * string and returns a new fixed file title string. |
|
253 * |
|
254 * @since S60 3.2.3 |
|
255 * @param aText (const TDesC8&) listboxe item text to be checked |
|
256 * @return HBufC8* fixed text string |
|
257 **/ |
|
258 IMPORT_C static HBufC8* FixListboxItemTextL( |
|
259 const TDesC8& aText ); |
|
260 }; |
|
261 |
|
262 |
|
263 #endif // UPNPCOMMONUTILS_H |
|
264 |
|
265 // End of File |