Modify the spec file for secure log
[framework/osp/social.git] / src / FScl_ImAddressImpl.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_ImAddressImpl.cpp
18 * @brief        This is the implementation for _ImAddressImpl class.
19 *
20 * This file contains definitions of @e _ImAddressImpl class.
21 */
22
23 #include <FSclImAddress.h>
24 #include <FApp_AppInfo.h>
25 #include <FBaseSysLog.h>
26 #include "FScl_ImAddressImpl.h"
27
28 using namespace Tizen::App;
29 using namespace Tizen::Base;
30
31 namespace Tizen { namespace Social
32 {
33
34 extern const wchar_t IM_ADDRESS_AIM[] = L"AIM";
35 extern const wchar_t IM_ADDRESS_GOOGLE_TALK[] = L"Google Talk";
36 extern const wchar_t IM_ADDRESS_ICQ[] = L"ICQ";
37 extern const wchar_t IM_ADDRESS_JABBER[] = L"Jabber";
38 extern const wchar_t IM_ADDRESS_MSN[] = L"MSN";
39 extern const wchar_t IM_ADDRESS_QQ[] = L"QQ";
40 extern const wchar_t IM_ADDRESS_SKYPE[] = L"Skype";
41 extern const wchar_t IM_ADDRESS_YAHOO[] = L"Yahoo";
42 extern const wchar_t IM_ADDRESS_IRC[] = L"IRC";
43 extern const wchar_t IM_ADDRESS_FACEBOOK[] = L"Facebook";
44
45 _ImAddressImpl::_ImAddressImpl(void)
46 {
47         //empty body
48 }
49
50 _ImAddressImpl::_ImAddressImpl(const String& serviceProviderName, const String& imAddress)
51         : __serviceProviderName(serviceProviderName)
52         , __imAddress(imAddress)
53 {
54         //empty body
55 }
56
57 _ImAddressImpl::_ImAddressImpl(const _ImAddressImpl& rhs)
58 {
59         __serviceProviderName = rhs.__serviceProviderName;
60         __imAddress = rhs.__imAddress;
61 }
62
63 _ImAddressImpl::~_ImAddressImpl(void)
64 {
65         // empty body.
66 }
67
68 _ImAddressImpl&
69 _ImAddressImpl::operator =(const _ImAddressImpl& rhs)
70 {
71         if (this == &rhs)
72         {
73                 return *this;
74         }
75
76         __serviceProviderName = rhs.__serviceProviderName;
77         __imAddress = rhs.__imAddress;
78
79         return *this;
80 }
81
82 bool
83 _ImAddressImpl::operator ==(const _ImAddressImpl& rhs) const
84 {
85         if (__serviceProviderName == rhs.__serviceProviderName && __imAddress == rhs.__imAddress)
86         {
87                 return true;
88         }
89
90         return false;
91 }
92
93 bool
94 _ImAddressImpl::operator !=(const _ImAddressImpl& rhs) const
95 {
96         return !(*this  == rhs);
97 }
98
99 bool
100 _ImAddressImpl::Equals(const Object& rhs) const
101 {
102         const _ImAddressImpl* pImAddress = dynamic_cast<const _ImAddressImpl*>(&rhs);
103         if (pImAddress == null)
104         {
105                 return false;
106         }
107
108         return (*this == *pImAddress);
109 }
110
111 int
112 _ImAddressImpl::GetHashCode(void) const
113 {
114         int hashCode = 0;
115
116         hashCode = __serviceProviderName.GetHashCode();
117         hashCode += __imAddress.GetHashCode();
118
119         return hashCode;
120 }
121
122 String
123 _ImAddressImpl::GetServiceProviderName(void) const
124 {
125         return __serviceProviderName;
126 }
127
128 String
129 _ImAddressImpl::GetImAddress(void) const
130 {
131         return __imAddress;
132 }
133
134 void
135 _ImAddressImpl::SetServiceProviderName(const String& serviceProviderName)
136 {
137         __serviceProviderName = serviceProviderName;
138 }
139
140 result
141 _ImAddressImpl::SetImAddress(const String& imAddress)
142 {
143         SysTryReturn(NID_SCL, !imAddress.IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The imAddress is an empty string.", GetErrorMessage(E_INVALID_ARG));
144
145         __imAddress = imAddress;
146
147         return E_SUCCESS;
148 }
149
150 const _ImAddressImpl*
151 _ImAddressImpl::GetInstance(const ImAddress& imAddress)
152 {
153         return imAddress.__pImAddressImpl;
154 }
155
156 _ImAddressImpl*
157 _ImAddressImpl::GetInstance(ImAddress& imAddress)
158 {
159         return imAddress.__pImAddressImpl;
160 }
161
162
163 }} // Tizen::Social