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