[N_SE-32914, 33582] Fixed priority converting codes
[framework/osp/social.git] / src / FSclCalendar.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 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  * @file                FSclCalendar.cpp
19  * @brief               This is the implementation for Calendar class.
20  *
21  * This file contains definitions of @e Calendar class.
22  */
23
24 #include <new>
25 #include <FSclCalendar.h>
26 #include <FBaseSysLog.h>
27 #include "FScl_CalendarImpl.h"
28
29 using namespace Tizen::Base;
30
31 namespace Tizen { namespace Social
32 {
33
34 Calendar::Calendar(CalendarItemType itemType)
35 : Record(RECORD_TYPE_CALENDAR)
36 , __pCalendarImpl(null)
37 {
38         __pCalendarImpl = new (std::nothrow) _CalendarImpl(itemType);
39         SysTryReturnVoidResult(NID_SCL, __pCalendarImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
40 }
41
42 Calendar::Calendar(const Calendar& rhs)
43 : Record(rhs)
44 , __pCalendarImpl(null)
45 {
46         __pCalendarImpl = new (std::nothrow) _CalendarImpl(*rhs.__pCalendarImpl);
47         SysTryReturnVoidResult(NID_SCL, __pCalendarImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
48 }
49
50 Calendar::~Calendar(void)
51 {
52         delete __pCalendarImpl;
53 }
54
55 Calendar&
56 Calendar::operator =(const Calendar& rhs)
57 {
58         if (this == &rhs)
59         {
60                 return *this;
61         }
62
63         Record::operator=(rhs);
64
65         *__pCalendarImpl = *rhs.__pCalendarImpl;
66
67         return *this;
68 }
69
70 bool
71 Calendar::Equals(const Tizen::Base::Object& rhs) const
72 {
73         const Calendar* pCalendar = dynamic_cast<const Calendar*>(&rhs);
74
75         if (pCalendar == null)
76         {
77                 return false;
78         }
79
80         return (Record::GetRecordId() == pCalendar->GetRecordId());
81 }
82
83 int
84 Calendar::GetHashCode(void) const
85 {
86         int hashCode = 17;
87
88         hashCode = static_cast<int>(( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ Record::GetRecordId());
89
90         return hashCode;
91 }
92
93 String
94 Calendar::GetName(void) const
95 {
96         return __pCalendarImpl->GetName();
97 }
98
99 CalendarItemType
100 Calendar::GetItemType(void) const
101 {
102         return __pCalendarImpl->GetItemType();
103 }
104
105 AccountId
106 Calendar::GetAccountId(void) const
107 {
108         return __pCalendarImpl->GetAccountId();
109 }
110
111 result
112 Calendar::GetColor(byte& red, byte& green, byte& blue) const
113 {
114         result r = __pCalendarImpl->GetColor(red, green, blue);
115         SysTryReturnResult(NID_SCL, r == E_SUCCESS, r, "Propagating.");
116
117         return E_SUCCESS;
118 }
119
120 void
121 Calendar::SetName(const Tizen::Base::String& name)
122 {
123         __pCalendarImpl->SetName(name);
124 }
125
126 void
127 Calendar::SetColor(byte red, byte green, byte blue)
128 {
129         __pCalendarImpl->SetColor(red, green, blue);
130 }
131
132 void
133 Calendar::ClearColor(void)
134 {
135         __pCalendarImpl->ClearColor();
136 }
137
138 }}      // Tizen::Social