Fix : Remove exception handling codes at the sample code
[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 set 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  * #include <FApp.h>
63  * #include <FBase.h>
64  * #include <FContent.h>
65  * #include <FSystem.h>
66  *
67  * using namespace Tizen::Content;
68  *
69  * result
70  * MyClass::TestContentInfo(void)
71  * {
72  *              ContentManager contentManager;
73  *              result r = contentManager.Construct();
74  *
75  *              ImageContentInfo imageContentInfo;
76  *              r = imageContentInfo.Construct(null);
77  *
78  *              Tizen::Base::String sourcePath = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/flower.jpg";
79  *              Tizen::Base::String destPath = Tizen::System::Environment::GetMediaPath() + L"Images/flower.jpg";
80  *
81  *              ContentId contentId = contentManager.CreateContent(sourcePath, destPath, false, &imageContentInfo);
82  *              r = GetLastResult();
83  *
84  *              return r;
85  * }
86  * @endcode
87  */
88 class _OSP_EXPORT_ ContentInfo
89         : public Tizen::Base::Object
90 {
91 public:
92         /**
93          * This destructor overrides Tizen::Base::Object::~Object().
94          *
95          * @since               2.0
96          */
97         virtual ~ContentInfo(void);
98
99         /**
100          * @if OSPDEPREC
101          * Initializes this instance of %ContentInfo with the specified parameters.
102          *
103          * @brief          <i> [Deprecated] </i>
104          * @deprecated This method is deprecated as there is a problem in managing the user-defined thumbnail and device coordinates.
105          * @since                       2.0
106          *
107          * @return              An error code
108          * @param[in]   contentPath         The content path
109          * @param[in]   thumbnailPath       The thumbnail path
110          * @param[in]   setGps              Set to @c true to save the device's last known coordinates of the %ContentInfo instance, @n
111          *                                  else @c false
112          * @endif
113          */
114         virtual result Construct(const Tizen::Base::String& contentPath, const Tizen::Base::String& thumbnailPath = L"", bool setGps = false) = 0;
115
116         /**
117          * Gets the content ID.
118          *
119          * @since               2.0
120          *
121          * @return              The content ID
122          */
123         ContentId GetContentId(void) const;
124
125         /**
126          * Gets the content type.
127          *
128          * @since               2.0
129          *
130          * @return              The content type
131          */
132         ContentType GetContentType(void) const;
133
134         /**
135          * Gets the MIME type.
136          *
137          * @since               2.0
138          *
139          * @return              The MIME type
140          */
141         Tizen::Base::String GetMimeType(void) const;
142
143         /**
144          * Gets the date and time of the added content.
145          *
146          * @since               2.0
147          *
148          * @return              The added time to database (GMT)
149          */
150         Tizen::Base::DateTime GetDateTime(void) const;
151
152         /**
153          * Gets the file size of the content.
154          *
155          * @since               2.0
156          *
157          * @return              The file size of the content
158          */
159         unsigned long GetContentSize(void) const;
160
161         /**
162          * Gets the content name.
163          *
164          * @since               2.0
165          *
166          * @return              The content name
167          * @remarks         The content name is not a file name.
168          */
169         Tizen::Base::String GetContentName(void) const;
170
171         /**
172          * Gets the file path of the content.
173          *
174          * @since               2.0
175          *
176          * @return              The file path of the content
177          */
178         Tizen::Base::String GetContentPath(void) const;
179
180         /**
181          * Gets the coordinates of the location.
182          *
183          * @since               2.0
184          *
185          * @return  A reference to the Tizen::Locations::Coordinates instance
186          */
187         const Tizen::Locations::Coordinates& GetCoordinates(void) const;
188
189         /**
190          * Sets the coordinates of the location.
191          *
192          * @since                       2.0
193          *
194          * @return              An error code
195          * @param[in]   coordinates                     The user-defined coordinates
196          * @exception   E_SUCCESS                       The method is successful.
197          */
198         result SetCoordinates(const Tizen::Locations::Coordinates& coordinates);
199
200         /**
201          * Sets the location tag.
202          *
203          * @since                       2.0
204          *
205          * @return              An error code
206          * @param[in]   locationTag                     The new location tag
207          * @exception   E_SUCCESS           The method is successful.
208          * @exception   E_INVALID_ARG           The length of the input data exceeds the maximum limit of 45 characters.
209          */
210         result SetLocationTag(const Tizen::Base::String& locationTag);
211
212         /**
213          * Gets the location tag.
214          *
215          * @since               2.0
216          *
217          * @return              The location tag
218          */
219         Tizen::Base::String GetLocationTag(void) const;
220
221         /**
222          * Sets the rating.
223          *
224          * @since                       2.0
225          *
226          * @return              An error code
227          * @param[in]   rating                          The new rating
228          * @exception   E_SUCCESS           The method is successful.
229          * @exception   E_INVALID_ARG           The length of the input data exceeds the maximum limit of 45 characters.
230          */
231         result SetRating(const Tizen::Base::String& rating);
232
233         /**
234          * Gets the rating.
235          *
236          * @since               2.0
237          *
238          * @return              The rating
239          */
240         Tizen::Base::String GetRating(void) const;
241
242         /**
243          * Sets the category.
244          *
245          * @since                       2.0
246          *
247          * @return              An error code
248          * @param[in]   category                        The new category
249          * @exception   E_SUCCESS           The method is successful.
250          * @exception   E_INVALID_ARG           The length of the input data exceeds the maximum limit of 45 characters.
251          */
252         result SetCategory(const Tizen::Base::String& category);
253
254         /**
255          * Gets the category.
256          *
257          * @since               2.0
258          *
259          * @return              The category
260          */
261         Tizen::Base::String GetCategory(void) const;
262
263         /**
264          * Sets the description.
265          *
266          * @since                       2.0
267          *
268          * @return              An error code
269          * @param[in]   description                     The new description
270          * @exception   E_SUCCESS           The method is successful.
271          * @exception   E_INVALID_ARG           The length of the input data exceeds the maximum limit of 140 characters.
272          */
273         result SetDescription(const Tizen::Base::String& description);
274
275         /**
276          * Gets the description.
277          *
278          * @since               2.0
279          *
280          * @return              The description
281          */
282         Tizen::Base::String GetDescription(void) const;
283
284         /**
285          * Gets the thumbnail image.
286          *
287          * @if OSPCOMPAT
288          * @brief       <i> [Compatibility] </i>
289          * @endif
290          * @since                       2.0
291          * @if OSPCOMPAT
292          * @compatibility This method has compatibility issues with OSP compatible applications. @n
293          *                                For more information, see @ref CompContentInfoGetThumbnailNPage "here".
294          * @endif
295          *
296          * @return              A pointer to the thumbnail image
297          * @exception   E_SUCCESS                               The method is successful.
298          * @exception   E_DATA_NOT_FOUND                The thumbnail image does not exist.
299          * @remarks     The specific error code can be accessed using the GetLastResult() method.
300          */
301         Tizen::Graphics::Bitmap* GetThumbnailN(void) const;
302
303         /**
304          * @if OSPCOMPAT
305          * @page        CompContentInfoGetThumbnailNPage Compatibility for GetThumbnailN().
306          * @section     CompContentInfoGetThumbnailNPageIssueSection Issue
307          *                      The thumbnail size of this method in OSP compatible applications has the following issues: @n
308          *                      <DIV> The size is changed from 80x60 pixels to the size of the image which is returned from the platform since %Tizen API 2.1.</DIV>
309          *
310          * @endif
311          */
312
313         /**
314          * Checks whether the content is DRM protected.
315          *
316          * @since               2.0
317          *
318          * @return              @c true if this content has DRM, @n
319          *                              else @c false
320          */
321         bool IsDrmProtected(void) const;
322
323         /**
324          * Gets the keyword.
325          *
326          * @since               2.0
327          *
328          * @return              The keyword
329          */
330         Tizen::Base::String GetKeyword(void) const;
331
332         /**
333          * Sets the content name.
334          *
335          * @since                       2.0
336          *
337          * @return              An error code
338          * @param[in]   contentName                     The new content name
339          * @exception   E_SUCCESS           The method is successful.
340          * @exception   E_INVALID_ARG           The length of the input data exceeds the maximum limit of 45 characters.
341          */
342         result SetContentName(const Tizen::Base::String& contentName);
343
344         /**
345          * Sets the keyword.
346          *
347          * @since               2.0
348          *
349          * @return              An error code
350          * @param[in]   keyword                         The new keyword
351          * @exception   E_SUCCESS           The method is successful.
352          * @exception   E_INVALID_ARG           The length of the input data exceeds the maximum limit of 45 characters.
353          */
354         result SetKeyword(const Tizen::Base::String& keyword);
355
356         /**
357          * Sets the author.
358          *
359          * @since                       2.0
360          *
361          * @return              An error code
362          * @param[in]   author                          The new author
363          * @exception   E_SUCCESS           The method is successful.
364          * @exception   E_INVALID_ARG           The length of the input data exceeds the maximum limit of 45 characters.
365          */
366         result SetAuthor(const Tizen::Base::String& author);
367
368         /**
369          * Gets the author.
370          *
371          * @since               2.0
372          *
373          * @return              The author
374          */
375         Tizen::Base::String GetAuthor(void) const;
376
377         /**
378          * Sets the provider.
379          *
380          * @since                       2.0
381          *
382          * @return              An error code
383          * @param[in]   provider                        The new content provider
384          * @exception   E_SUCCESS           The method is successful.
385          * @exception   E_INVALID_ARG           The length of the input data exceeds the maximum limit of 45 characters.
386          */
387         result SetProvider(const Tizen::Base::String& provider);
388
389         /**
390          * Gets the provider.
391          *
392          * @since               2.0
393          *
394          * @return              The content provider
395          */
396         Tizen::Base::String GetProvider(void) const;
397
398         /**
399          * Gets the media format.
400          *
401          * @since               2.0
402          *
403          * @return              The media format
404          */
405         Tizen::Base::String GetMediaFormat(void) const;
406
407 protected:
408
409         //
410         // This class is for internal use only.
411         // Using this class can cause behavioral, security-related, and consistency-related issues in the application.
412         //
413         class _ContentData
414         {
415         public:
416                 _ContentData()
417                         : contentId(Tizen::Base::UuId::GetInvalidUuId())
418                         , storageType(0)
419                         , contentType(CONTENT_TYPE_UNKNOWN)
420                         , contentSize(0)
421                         , latitude(-200.0)
422                         , longitude(-200.0)
423                         , altitude(-200.0)
424                         , isDrm(false)
425                         , pThumbnailPath(null)
426                         , pAuthor(null)
427                         , pCategory(null)
428                         , pContentName(null)
429                         , pDescription(null)
430                         , pKeyword(null)
431                         , pLocationTag(null)
432                         , pProvider(null)
433                         , pRating(null) {}
434
435                 ContentId contentId;
436                 int storageType;
437                 ContentType contentType;
438                 unsigned long contentSize;
439                 Tizen::Base::DateTime dateTime;
440                 double latitude;
441                 double longitude;
442                 double altitude;
443                 bool isDrm;
444                 Tizen::Base::String contentPath;
445                 Tizen::Base::String mimeType;
446                 Tizen::Base::String* pThumbnailPath;
447                 Tizen::Base::String* pAuthor;
448                 Tizen::Base::String* pCategory;
449                 Tizen::Base::String* pContentName;
450                 Tizen::Base::String* pDescription;
451                 Tizen::Base::String* pKeyword;
452                 Tizen::Base::String* pLocationTag;
453                 Tizen::Base::String* pProvider;
454                 Tizen::Base::String* pRating;
455         };
456
457         /**
458          * This is the default constructor for this class.
459          *
460          * @since               2.0
461          */
462         ContentInfo(void);
463
464         //
465         // This method is for internal use only.
466         // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
467         //
468         // Sets the content data.
469         //
470         // @since           2.0
471         //
472         // @return                      An error code
473         // @param[in]   pContentData                            The content data
474         // @exception   E_SUCCESS               The method is successful.
475         // @exception   E_INVALID_ARG                   The specified input parameter is invalid.
476         // @exception   E_OUT_OF_MEMORY The memory is insufficient.
477         //
478         result SetContentData(const _ContentData* pContentData);
479
480 private:
481
482         /**
483          * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
484          */
485         ContentInfo(const ContentInfo& rhs);
486
487         /**
488          * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
489          */
490         ContentInfo& operator =(const ContentInfo& rhs);
491
492 private:
493         _ContentInfoImpl* __pContentInfoImpl;
494         mutable Tizen::Locations::Coordinates __coordinates;
495
496         friend class _ContentInfoImpl;
497         friend class _ContentInfoHelper;
498
499 };  // ContentInfo
500
501 }}  // Tizen::Content
502
503 #endif  // _FCNT_CONTENT_INFO_H_