Fix code for TDIS-5396
[framework/osp/social.git] / src / FScl_OrganizationImpl.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         FScl_OrganizationImpl.cpp
19 * @brief        This is the implementation for _OrganizationImpl class.
20 *
21 * This file contains definitions of @e _OrganizationImpl class.
22 */
23
24 #include <FBaseSysLog.h>
25 #include <FSclOrganization.h>
26 #include <FIoFile.h>
27 #include "FScl_OrganizationImpl.h"
28
29 using namespace Tizen::Base;
30 using namespace Tizen::Io;
31
32 namespace Tizen { namespace Social
33 {
34
35 _OrganizationImpl::_OrganizationImpl(void)
36 : __type(ORGANIZATION_TYPE_WORK)
37 , __isLogoPathChanged(false)
38 {
39
40 }
41
42 _OrganizationImpl::_OrganizationImpl(const _OrganizationImpl& rhs)
43 {
44         __name = rhs.__name;
45         __jobTitle = rhs.__jobTitle;
46         __department = rhs.__department;
47         __role = rhs.__role;
48         __agent = rhs.__agent;
49         __label = rhs.__label;
50         __location = rhs.__location;
51         __description = rhs.__description;
52         __phoneticName = rhs.__phoneticName;
53         __logoPath = rhs.__logoPath;
54         __type = rhs.__type;
55         __isLogoPathChanged = rhs.__isLogoPathChanged;
56 }
57
58 _OrganizationImpl::~_OrganizationImpl(void)
59 {
60
61 }
62
63 _OrganizationImpl&
64 _OrganizationImpl::operator =(const _OrganizationImpl& rhs)
65 {
66         if (this == &rhs)
67         {
68                 return *this;
69         }
70
71         __name = rhs.__name;
72         __jobTitle = rhs.__jobTitle;
73         __department = rhs.__department;
74         __role = rhs.__role;
75         __agent = rhs.__agent;
76         __label = rhs.__label;
77         __location = rhs.__location;
78         __description = rhs.__description;
79         __phoneticName = rhs.__phoneticName;
80         __logoPath = rhs.__logoPath;
81         __type = rhs.__type;
82         __isLogoPathChanged = rhs.__isLogoPathChanged;
83
84         return *this;
85 }
86
87 bool
88 _OrganizationImpl::operator ==(const _OrganizationImpl& rhs) const
89 {
90         if (__name != rhs.__name)
91         {
92                 return false;
93         }
94
95         if (__jobTitle != rhs.__jobTitle)
96         {
97                 return false;
98         }
99
100         if (__department != rhs.__department)
101         {
102                 return false;
103         }
104
105         if (__role != rhs.__role)
106         {
107                 return false;
108         }
109
110         if (__agent != rhs.__agent)
111         {
112                 return false;
113         }
114
115         if (__label != rhs.__label)
116         {
117                 return false;
118         }
119
120         if (__location != rhs.__location)
121         {
122                 return false;
123         }
124
125         if (__description != rhs.__description)
126         {
127                 return false;
128         }
129
130         if (__phoneticName != rhs.__phoneticName)
131         {
132                 return false;
133         }
134
135         if (__logoPath != rhs.__logoPath)
136         {
137                 return false;
138         }
139
140         if (__type != rhs.__type)
141         {
142                 return false;
143         }
144
145         return true;
146 }
147
148 bool
149 _OrganizationImpl::operator !=(const _OrganizationImpl& rhs) const
150 {
151         return !(*this == rhs);
152 }
153
154 bool
155 _OrganizationImpl::Equals(const Object& rhs) const
156 {
157         const _OrganizationImpl* pOrganization = dynamic_cast<const _OrganizationImpl*>(&rhs);
158         if (pOrganization == null)
159         {
160                 return false;
161         }
162
163         return *this == *pOrganization;
164 }
165
166 int
167 _OrganizationImpl::GetHashCode(void) const
168 {
169         int hash = __name.GetHashCode();
170         hash += __jobTitle.GetHashCode();
171         hash += __department.GetHashCode();
172         hash += __role.GetHashCode();
173         hash += __agent.GetHashCode();
174         hash += __label.GetHashCode();
175         hash += __location.GetHashCode();
176         hash += __description.GetHashCode();
177         hash += __phoneticName.GetHashCode();
178         hash += __logoPath.GetHashCode();
179         hash += __type;
180
181         return hash;
182 }
183
184 String
185 _OrganizationImpl::GetName(void) const
186 {
187         return __name;
188 }
189
190 String
191 _OrganizationImpl::GetJobTitle(void) const
192 {
193         return __jobTitle;
194 }
195
196 String
197 _OrganizationImpl::GetDepartment(void) const
198 {
199         return __department;
200 }
201
202 String
203 _OrganizationImpl::GetRole(void) const
204 {
205         return __role;
206 }
207
208 String
209 _OrganizationImpl::GetAgent(void) const
210 {
211         return __agent;
212 }
213
214 OrganizationType
215 _OrganizationImpl::GetType(void) const
216 {
217         return __type;
218 }
219
220 String
221 _OrganizationImpl::GetLabel(void) const
222 {
223         return __label;
224 }
225
226 String
227 _OrganizationImpl::GetLocation(void) const
228 {
229         return __location;
230 }
231
232 String
233 _OrganizationImpl::GetDescription(void) const
234 {
235         return __description;
236 }
237
238 String
239 _OrganizationImpl::GetPhoneticName(void) const
240 {
241         return __phoneticName;
242 }
243
244 String
245 _OrganizationImpl::GetLogoPath(void) const
246 {
247         return __logoPath;
248 }
249
250 void
251 _OrganizationImpl::SetName(const String& name)
252 {
253         __name = name;
254 }
255
256 void
257 _OrganizationImpl::SetJobTitle(const String& jobTitle)
258 {
259         __jobTitle = jobTitle;
260 }
261
262 void
263 _OrganizationImpl::SetDepartment(const String& department)
264 {
265         __department = department;
266 }
267
268 void
269 _OrganizationImpl::SetRole(const String& role)
270 {
271         __role = role;
272 }
273
274 void
275 _OrganizationImpl::SetAgent(const String& agent)
276 {
277         __agent = agent;
278 }
279
280 void
281 _OrganizationImpl::SetType(OrganizationType type)
282 {
283         __type = type;
284 }
285
286 void
287 _OrganizationImpl::SetLabel(const String& label)
288 {
289         __label = label;
290 }
291
292 void
293 _OrganizationImpl::SetLocation(const String& location)
294 {
295         __location = location;
296 }
297
298 void
299 _OrganizationImpl::SetDescription(const String& description)
300 {
301         __description = description;
302 }
303
304 void
305 _OrganizationImpl::SetPhoneticName(const Tizen::Base::String& phoneticName)
306 {
307         __phoneticName = phoneticName;
308 }
309
310 result
311 _OrganizationImpl::SetLogo(const Tizen::Base::String& filePath)
312 {
313         if (!filePath.IsEmpty())
314         {
315                 bool fileExist = File::IsFileExist(filePath);
316                 SysTryReturn(NID_SCL, GetLastResult() != E_ILLEGAL_ACCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
317                 SysTryReturn(NID_SCL, GetLastResult() != E_INVALID_ARG, E_INVALID_ARG, E_INVALID_ARG, "[%s] The length of the specified filePath exceeds system limitations..", GetErrorMessage(E_INVALID_ARG));
318                 SysTryReturn(NID_SCL, fileExist, E_FILE_NOT_FOUND, E_FILE_NOT_FOUND, "[%s] The specified file is not found.", GetErrorMessage(E_FILE_NOT_FOUND));
319         }
320
321         __logoPath = filePath;
322         __isLogoPathChanged = true;
323
324         return E_SUCCESS;
325 }
326
327 bool
328 _OrganizationImpl::IsEmpty(void) const
329 {
330         if (!__name.IsEmpty())
331         {
332                 return false;
333         }
334
335         if (!__jobTitle.IsEmpty())
336         {
337                 return false;
338         }
339
340         if (!__role.IsEmpty())
341         {
342                 return false;
343         }
344
345         if (!__agent.IsEmpty())
346         {
347                 return false;
348         }
349
350         if (!__department.IsEmpty())
351         {
352                 return false;
353         }
354
355         if (!__location.IsEmpty())
356         {
357                 return false;
358         }
359
360         if (!__description.IsEmpty())
361         {
362                 return false;
363         }
364
365         if (!__phoneticName.IsEmpty())
366         {
367                 return false;
368         }
369
370         if (!__logoPath.IsEmpty())
371         {
372                 return false;
373         }
374
375         return true;
376 }
377
378 bool
379 _OrganizationImpl::IsLogoPathChanged(void) const
380 {
381         return __isLogoPathChanged;
382 }
383
384 result
385 _OrganizationImpl::SetLogoPath(const Tizen::Base::String& filePath)
386 {
387         __logoPath = filePath;
388
389         return E_SUCCESS;
390 }
391
392 const _OrganizationImpl*
393 _OrganizationImpl::GetInstance(const Organization& organization)
394 {
395         return organization.__pOrganizationImpl;
396 }
397
398 _OrganizationImpl*
399 _OrganizationImpl::GetInstance(Organization& organization)
400 {
401         return organization.__pOrganizationImpl;
402 }
403
404 }} // Tizen::Social