modify license, permission and remove ^M char
[platform/framework/native/uifw.git] / src / ui / FUi_ClipboardItemImpl.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an ”AS IS” BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file                FUi_ClipboardItemImpl.cpp
20  * @brief               This is the implementation file for the _ClipboardItemImpl class.
21  */
22
23 #include <new>
24 #include <FBaseResult.h>
25 #include <FUiClipboardItem.h>
26 #include <FBaseSysLog.h>
27 #include "FUi_ClipboardItemImpl.h"
28 #include "FUi_ClipboardItem.h"
29
30 using namespace Tizen::Base;
31
32 namespace Tizen { namespace Ui
33 {
34
35 _ClipboardItemImpl*
36 _ClipboardItemImpl::CreateInstanceN(ClipboardItem* pPublic, ClipboardDataType type, const Object& data)
37 {
38         _ClipboardItem* pItemCore = _ClipboardItem::CreateInstanceN(type, data);
39
40         _ClipboardItemImpl* pItemImpl = null;
41
42         result r = GetLastResult();
43         if ((r == E_OUT_OF_MEMORY) || (r == E_INVALID_ARG) || (r == E_SYSTEM))
44         {
45                 SysLogException(NID_UI, r, "[%s] Propagating.", GetErrorMessage(r));
46                 goto CATCH;
47         }
48         else if (r != E_SUCCESS)
49         {
50                 SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
51                 goto CATCH;
52         }
53
54         pItemImpl = new (std::nothrow) _ClipboardItemImpl(pPublic, pItemCore);
55         SysTryCatch(NID_UI, pItemImpl, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
56
57         SetLastResult(E_SUCCESS);
58
59         return pItemImpl;
60
61 CATCH:
62         if (pItemCore)
63         {
64                 delete pItemCore;
65         }
66
67         return null;
68 }
69
70 ClipboardDataType
71 _ClipboardItemImpl::GetDataType(void) const
72 {
73         return GetCore().GetDataType();
74 }
75
76 Object*
77 _ClipboardItemImpl::GetData(void) const
78 {
79         return const_cast<Object*>(GetCore().GetData());
80 }
81
82 const ClipboardItem&
83 _ClipboardItemImpl::GetPublic(void) const
84 {
85         return *__pPublic;
86 }
87
88 ClipboardItem&
89 _ClipboardItemImpl::GetPublic(void)
90 {
91         return *__pPublic;
92 }
93
94 const _ClipboardItem&
95 _ClipboardItemImpl::GetCore(void) const
96 {
97         return *__pCore;
98 }
99
100 _ClipboardItem&
101 _ClipboardItemImpl::GetCore(void)
102 {
103         return *__pCore;
104 }
105
106 _ClipboardItemImpl*
107 _ClipboardItemImpl::GetInstance(ClipboardItem& clipboardItem)
108 {
109         return clipboardItem.__pImpl;
110 }
111
112 const _ClipboardItemImpl*
113 _ClipboardItemImpl::GetInstance(const ClipboardItem& clipboardItem)
114 {
115         return static_cast<const _ClipboardItemImpl*> (clipboardItem.__pImpl);
116 }
117
118 _ClipboardItemImpl::_ClipboardItemImpl(ClipboardItem* pPublic, _ClipboardItem* pCore)
119         : __pPublic(pPublic)
120         , __pCore(pCore)
121 {
122 }
123
124 _ClipboardItemImpl::~_ClipboardItemImpl(void)
125 {
126         if (__pCore)
127         {
128                 delete __pCore;
129                 __pCore = null;
130         }
131 }
132
133 }} // Tizen::Ui