Fix : Search APIs don't return exception despite the content in DB doesn't match...
[platform/framework/native/content.git] / inc / FCntContentInfo.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 /**
17  * @file                        FCntContentInfo.h
18  * @brief               This is the header file for the %ContentInfo class.
19  *
20  * This header file contains the declarations of the %ContentInfo class.
21  */
22
23 #ifndef _FCNT_CONTENT_INFO_H_
24 #define _FCNT_CONTENT_INFO_H_
25
26 #include <FBaseUuId.h>
27 #include <FBaseDateTime.h>
28 #include <FCntTypes.h>
29 #include <FLocCoordinates.h>
30
31 namespace Tizen { namespace Graphics
32 {
33 class Bitmap;
34 }}
35
36 namespace Tizen { namespace Content
37 {
38
39 class _ContentInfoImpl;
40
41 /**
42  * @class       ContentInfo
43  * @brief       This class provides methods to manage the content information.
44  *
45  * @since       2.0
46  *
47  * @final       This class is not intended for extension.
48  *
49  * The %ContentInfo class is an abstract base class. @n
50  * ImageContentInfo, AudioContentInfo, VideoContentInfo, and OtherContentInfo are derived from the %ContentInfo class.
51  *
52  * When a user creates content, its content information is created as a new pair. @n
53  * When a user deletes content, its content information is deleted from the content database. @n
54  * This class provides methods to get or to set the specific content information. @n
55  * The physical file is not updated even if the set methods are called.
56  *
57  * For more information on the different types of content information, see <a href="../org.tizen.native.appprogramming/html/guide/content/device_content_mgmt.htm">Device Content Management</a>.
58  *
59  * The following example demonstrates how to use the %ContentInfo class.
60  *
61  * @code
62  * result
63  * MyClass::TestContentInfo(void)
64  * {
65  *              result r = E_SUCCESS;
66  *
67  *              ContentId contentId;
68  *              ContentManager contentManager;
69  *              r = contentManager.Construct();
70  *              TryReturn(!IsFailed(r), r, "Construct failed.");
71  *
72  *              ImageContentInfo imageContentInfo;
73  *              r = imageContentInfo.Construct(null);
74  *              TryReturn(!IsFailed(r), r, "Construct failed.");
75  *
76  *              Tizen::Base::String sourcePath = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/flower.jpg";
77  *              Tizen::Base::String destPath = Tizen::System::Environment::GetMediaPath() + L"Images/flower.jpg";
78  *
79  *              contentId = contentManager.CreateContent(sourcePath, destPath, false, &imageContentInfo);
80  *              TryReturn(Tizen::Base::UuId::GetInvalidUuId() != contentId, GetLastResult(), "CreateContent failed.");
81  *
82  *              return r;
83  * }
84  * @endcode
85  */
86 class _OSP_EXPORT_ ContentInfo
87         : public Tizen::Base::Object
88 {
89 public:
90         /**
91          * This destructor overrides Tizen::Base::Object::~Object().
92          *
93          * @since               2.0
94          */
95         virtual ~ContentInfo(void);
96
97         /**
98          * @if OSPDEPREC
99          * Initializes this instance of %ContentInfo with the specified parameters.
100          *
101          * @brief       <i> [Deprecated] </i>
102          * @deprecated This method is deprecated as there is a problem in managing the user-defined thumbnail and device coordinates.
103          * @since                       2.0
104          *
105          * @return                      An error code
106          * @param[in]   contentPath           The content path
107          * @param[in]   thumbnailPath       The thumbnail path
108          * @param[in]   setGps                 Set to @c true to save the device's last known coordinates in the %ContentInfo instance, @n
109          *                                                else @c false
110          * @endif
111          */
112         virtual result Construct(const Tizen::Base::String& contentPath, const Tizen::Base::String& thumbnailPath = L"", bool setGps = false) = 0;
113
114         /**
115          * Gets the content ID.
116          *
117          * @since               2.0
118          *
119          * @return              The content ID
120          */
121         ContentId GetContentId(void) const;
122
123         /**
124          * Gets the content type.
125          *
126          * @since               2.0
127          *
128          * @return              The content type
129          */
130         ContentType GetContentType(void) const;
131
132         /**
133          * Gets the mime type.
134          *
135          * @since               2.0
136          *
137          * @return              The mime type
138          */
139         Tizen::Base::String GetMimeType(void) const;
140
141         /**
142          * Gets the date and time of the added content.
143          *
144          * @since               2.0
145          *
146          * @return              The added time to database (GMT)
147          */
148         Tizen::Base::DateTime GetDateTime(void) const;
149
150         /**
151          * Gets the file size of the content.
152          *
153          * @since               2.0
154          *
155          * @return              The file size of the content
156          */
157         unsigned long GetContentSize(void) const;
158
159         /**
160          * Gets the content name.
161          *
162          * @since               2.0
163          *
164          * @return              The content name
165          * @remarks     The content name is not a file name.
166          */
167         Tizen::Base::String GetContentName(void) const;
168
169         /**
170          * Gets the file path of the content.
171          *
172          * @since               2.0
173          *
174          * @return              The file path of the content
175          */
176         Tizen::Base::String GetContentPath(void) const;
177
178         /**
179          * Gets the coordinates of the location.
180          *
181          * @since               2.0
182          *
183          * @return              A reference to the coordinates
184          */
185         const Tizen::Locations::Coordinates& GetCoordinates(void) const;
186
187         /**
188          * Sets the coordinates of the location.
189          *
190          * @since                       2.0
191          *
192          * @return                      An error code
193          * @param[in]   coordinates                     The user-defined coordinates
194          * @exception   E_SUCCESS                       The method is successful.
195          */
196         result SetCoordinates(const Tizen::Locations::Coordinates& coordinates);
197
198         /**
199          * Sets the location tag.
200          *
201          * @since                       2.0
202          *
203          * @return                      An error code
204          * @param[in]   locationTag                     The new location tag
205          * @exception   E_SUCCESS           The method is successful.
206          * @exception   E_INVALID_ARG           The length of the input data exceeds the maximum limit of 45 characters.
207          */
208         result SetLocationTag(const Tizen::Base::String& locationTag);
209
210         /**
211          * Gets the location tag.
212          *
213          * @since               2.0
214          *
215          * @return              The location tag
216          */
217         Tizen::Base::String GetLocationTag(void) const;
218
219         /**
220          * Sets the rating.
221          *
222          * @since                       2.0
223          *
224          * @return                      An error code
225          * @param[in]   rating                          The new rating
226          * @exception   E_SUCCESS           The method is successful.
227          * @exception   E_INVALID_ARG           The length of the input data exceeds the maximum limit of 45 characters.
228          */
229         result SetRating(const Tizen::Base::String& rating);
230
231         /**
232          * Gets the rating.
233          *
234          * @since               2.0
235          *
236          * @return              The rating
237          */
238         Tizen::Base::String GetRating(void) const;
239
240         /**
241          * Sets the category.
242          *
243          * @since                       2.0
244          *
245          * @return                      An error code
246          * @param[in]   category                                The new category
247          * @exception   E_SUCCESS           The method is successful.
248          * @exception   E_INVALID_ARG           The length of the input data exceeds the maximum limit of 45 characters.
249          */
250         result SetCategory(const Tizen::Base::String& category);
251
252         /**
253          * Gets the category.
254          *
255          * @since               2.0
256          *
257          * @return              The category
258          */
259         Tizen::Base::String GetCategory(void) const;
260
261         /**
262          * Sets the description.
263          *
264          * @since                       2.0
265          *
266          * @return                      An error code
267          * @param[in]   description                             The new description
268          * @exception   E_SUCCESS           The method is successful.
269          * @exception   E_INVALID_ARG           The length of the input data exceeds the maximum limit of 140 characters.
270          */
271         result SetDescription(const Tizen::Base::String& description);
272
273         /**
274          * Gets the description.
275          *
276          * @since               2.0
277          *
278          * @return              The description
279          */
280         Tizen::Base::String GetDescription(void) const;
281
282         /**
283          * Gets the thumbnail image.
284          *
285          * @if OSPCOMPAT
286          * @brief       <i> [Compatibility] </i>
287          * @endif
288          * @since                       2.0
289          * @if OSPCOMPAT
290          * @compatibility This method has compatibility issues with OSP compatible applications. @n
291          *                                       For more information, see @ref CompContentInfoGetThumbnailNPage "here".
292          * @endif
293          *
294          * @return                      A pointer to the thumbnail image
295          * @exception   E_SUCCESS                                       The method is successful.
296          * @exception   E_DATA_NOT_FOUND                The thumbnail image does not exist.
297          * @remarks     The specific error code can be accessed using the GetLastResult() method.
298          */
299         Tizen::Graphics::Bitmap* GetThumbnailN(void) const;
300
301         /**
302          * @if OSPCOMPAT
303          * @page                CompContentInfoGetThumbnailNPage Compatibility for GetThumbnailN().
304          * @section     CompContentInfoGetThumbnailNPageIssueSection Issue
305          *                              The thumbnail size of this method in OSP compatible applications has the following issues: @n
306          *                              <DIV> The size is changed from 80x60 pixels to the size of image which is returned from the platform since %Tizen API 2.1.</DIV>
307          *
308          * @endif
309          */
310
311         /**
312          * Checks whether the content is DRM protected.
313          *
314          * @since               2.0
315          *
316          * @return              @c true if this content has DRM, @n
317          *                                      else @c false
318          */
319         bool IsDrmProtected(void) const;
320
321         /**
322          * Gets the keyword.
323          *
324          * @since               2.0
325          *
326          * @return              The keyword
327          */
328         Tizen::Base::String GetKeyword(void) const;
329
330         /**
331          * Sets the content name.
332          *
333          * @since                       2.0
334          *
335          * @return                      An error code
336          * @param[in]   contentName                     The new content name
337          * @exception   E_SUCCESS           The method is successful.
338          * @exception   E_INVALID_ARG           The length of the input data exceeds the maximum limit of 45 characters.
339          */
340         result SetContentName(const Tizen::Base::String& contentName);
341
342         /**
343          * Sets the keyword.
344          *
345          * @since                       2.0
346          *
347          * @return                      An error code
348          * @param[in]   keyword                                 The new keyword
349          * @exception   E_SUCCESS           The method is successful.
350          * @exception   E_INVALID_ARG           The length of the input data exceeds the maximum limit of 45 characters.
351          */
352         result SetKeyword(const Tizen::Base::String& keyword);
353
354         /**
355          * Sets the author.
356          *
357          * @since                       2.0
358          *
359          * @return                      An error code
360          * @param[in]   author                                  The new author
361          * @exception   E_SUCCESS           The method is successful.
362          * @exception   E_INVALID_ARG           The length of the input data exceeds the maximum limit of 45 characters.
363          */
364         result SetAuthor(const Tizen::Base::String& author);
365
366         /**
367          * Gets the author.
368          *
369          * @since               2.0
370          *
371          * @return              The author
372          */
373         Tizen::Base::String GetAuthor(void) const;
374
375         /**
376          * Sets the provider.
377          *
378          * @since                       2.0
379          *
380          * @return                      An error code
381          * @param[in]   provider                                        The new content provider
382          * @exception   E_SUCCESS           The method is successful.
383          * @exception   E_INVALID_ARG           The length of the input data exceeds the maximum limit of 45 characters.
384          */
385         result SetProvider(const Tizen::Base::String& provider);
386
387         /**
388          * Gets the provider.
389          *
390          * @since               2.0
391          *
392          * @return              The content provider
393          */
394         Tizen::Base::String GetProvider(void) const;
395
396         /**
397          * Gets the media format.
398          *
399          * @since               2.0
400          *
401          * @return              The media format
402          */
403         Tizen::Base::String GetMediaFormat(void) const;
404
405 protected:
406
407         //
408         // This class is for internal use only.
409         // Using this class can cause behavioral, security-related, and consistency-related issues in the application.
410         //
411         class _ContentData
412         {
413         public:
414                 _ContentData()
415                         : contentId(Tizen::Base::UuId::GetInvalidUuId())
416                         , storageType(0)
417                         , contentType(CONTENT_TYPE_UNKNOWN)
418                         , contentSize(0)
419                         , latitude(-200.0)
420                         , longitude(-200.0)
421                         , altitude(-200.0)
422                         , isDrm(false)
423                         , pThumbnailPath(null)
424                         , pAuthor(null)
425                         , pCategory(null)
426                         , pContentName(null)
427                         , pDescription(null)
428                         , pKeyword(null)
429                         , pLocationTag(null)
430                         , pProvider(null)
431                         , pRating(null) {}
432
433                 ContentId contentId;
434                 int storageType;
435                 ContentType contentType;
436                 unsigned long contentSize;
437                 Tizen::Base::DateTime dateTime;
438                 double latitude;
439                 double longitude;
440                 double altitude;
441                 bool isDrm;
442                 Tizen::Base::String contentPath;
443                 Tizen::Base::String mimeType;
444                 Tizen::Base::String* pThumbnailPath;
445                 Tizen::Base::String* pAuthor;
446                 Tizen::Base::String* pCategory;
447                 Tizen::Base::String* pContentName;
448                 Tizen::Base::String* pDescription;
449                 Tizen::Base::String* pKeyword;
450                 Tizen::Base::String* pLocationTag;
451                 Tizen::Base::String* pProvider;
452                 Tizen::Base::String* pRating;
453         };
454
455         /**
456          * This is the default constructor for this class.
457          *
458          * @since               2.0
459          */
460         ContentInfo(void);
461
462         //
463         // This method is for internal use only.
464         // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
465         //
466         // Sets the content data.
467         //
468         // @since           2.0
469         //
470         // @return                      An error code
471         // @param[in]   pContentData                            The content data
472         // @exception   E_SUCCESS               The method is successful.
473         // @exception   E_INVALID_ARG                   The specified input parameter is invalid.
474         // @exception   E_OUT_OF_MEMORY The memory is insufficient.
475         //
476         result SetContentData(const _ContentData* pContentData);
477
478 private:
479
480         /**
481          * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
482          */
483         ContentInfo(const ContentInfo& rhs);
484
485         /**
486          * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
487          */
488         ContentInfo& operator =(const ContentInfo& rhs);
489
490 private:
491         _ContentInfoImpl* __pContentInfoImpl;
492         mutable Tizen::Locations::Coordinates __coordinates;
493
494         friend class _ContentInfoImpl;
495         friend class _ContentInfoHelper;
496
497 };  // ContentInfo
498
499 }}  // Tizen::Content
500
501 #endif  // _FCNT_CONTENT_INFO_H_