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