41da4d4f03b21e06405dfef54a38af8bebfe4da4
[platform/framework/native/content.git] / src / FCntOtherContentInfo.cpp
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                FCntOtherContentInfo.cpp
18  * @brief               This is the implementation file for the %OtherContentInfo class.
19  *
20  * This file contains implementation of the %OtherContentInfo class.
21  */
22
23 #include <FBaseSysLog.h>
24 #include <FCntOtherContentInfo.h>
25 #include "FCnt_OtherContentInfoImpl.h"
26 #include "FCnt_ContentInfoHelper.h"
27
28 using namespace Tizen::Base;
29
30 namespace Tizen { namespace Content
31 {
32
33 OtherContentInfo::OtherContentInfo(void)
34         : __isCreated(false)
35         , __pOtherContentInfoImpl(null)
36 {
37
38 }
39
40 OtherContentInfo::~OtherContentInfo(void)
41 {
42         delete __pOtherContentInfoImpl;
43 }
44
45 result
46 OtherContentInfo::Construct(const String& contentPath, const String& thumbnailPath, bool setGps)
47 {
48         result r = E_SUCCESS;
49
50         SysAssertf(__pOtherContentInfoImpl == null,
51                         "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
52
53         _OtherContentInfoImpl* pOtherContentInfoImpl = new (std::nothrow) _OtherContentInfoImpl();
54         SysTryReturnResult(NID_CNT, pOtherContentInfoImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Construct failed.");
55
56         r = pOtherContentInfoImpl->Construct(contentPath, thumbnailPath, setGps);
57         SysTryCatch(NID_CNT, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
58
59         _ContentInfoHelper::SetContentInfoImpl(this, pOtherContentInfoImpl);
60
61         __pOtherContentInfoImpl = pOtherContentInfoImpl;
62
63         return r;
64
65 CATCH:
66         delete pOtherContentInfoImpl;
67
68         return r;
69 }
70
71 result
72 OtherContentInfo::Construct(const String* pContentPath)
73 {
74         result r = E_SUCCESS;
75
76         SysAssertf(__pOtherContentInfoImpl == null,
77                         "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
78
79         _OtherContentInfoImpl* pOtherContentInfoImpl = new (std::nothrow) _OtherContentInfoImpl();
80         SysTryReturnResult(NID_CNT, pOtherContentInfoImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Construct failed.");
81
82         r = pOtherContentInfoImpl->Construct(pContentPath);
83         SysTryCatch(NID_CNT, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
84
85         _ContentInfoHelper::SetContentInfoImpl(this, pOtherContentInfoImpl);
86
87         __pOtherContentInfoImpl = pOtherContentInfoImpl;
88
89         return r;
90
91 CATCH:
92         delete pOtherContentInfoImpl;
93
94         return r;
95 }
96
97 }}