Merge "Export internal APIs needed by samsung-socil" into tizen_2.1
[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
43 _ImAddressImpl::_ImAddressImpl(void)
44 {
45         //empty body
46 }
47
48 _ImAddressImpl::_ImAddressImpl(const String& serviceProviderName, const String& imAddress)
49         : __serviceProviderName(serviceProviderName)
50         , __imAddress(imAddress)
51 {
52         //empty body
53 }
54
55 _ImAddressImpl::_ImAddressImpl(const _ImAddressImpl& rhs)
56 {
57         __serviceProviderName = rhs.__serviceProviderName;
58         __imAddress = rhs.__imAddress;
59 }
60
61 _ImAddressImpl::~_ImAddressImpl(void)
62 {
63         // empty body.
64 }
65
66 _ImAddressImpl&
67 _ImAddressImpl::operator =(const _ImAddressImpl& rhs)
68 {
69         if (this == &rhs)
70         {
71                 return *this;
72         }
73
74         __serviceProviderName = rhs.__serviceProviderName;
75         __imAddress = rhs.__imAddress;
76
77         return *this;
78 }
79
80 bool
81 _ImAddressImpl::operator ==(const _ImAddressImpl& rhs) const
82 {
83         if (__serviceProviderName == rhs.__serviceProviderName && __imAddress == rhs.__imAddress)
84         {
85                 return true;
86         }
87
88         return false;
89 }
90
91 bool
92 _ImAddressImpl::operator !=(const _ImAddressImpl& rhs) const
93 {
94         return !(*this  == rhs);
95 }
96
97 bool
98 _ImAddressImpl::Equals(const Object& rhs) const
99 {
100         const _ImAddressImpl* pImAddress = dynamic_cast<const _ImAddressImpl*>(&rhs);
101         if (pImAddress == null)
102         {
103                 return false;
104         }
105
106         return (*this == *pImAddress);
107 }
108
109 int
110 _ImAddressImpl::GetHashCode(void) const
111 {
112         int hashCode = 0;
113
114         hashCode = __serviceProviderName.GetHashCode();
115         hashCode += __imAddress.GetHashCode();
116
117         return hashCode;
118 }
119
120 String
121 _ImAddressImpl::GetServiceProviderName(void) const
122 {
123         return __serviceProviderName;
124 }
125
126 String
127 _ImAddressImpl::GetImAddress(void) const
128 {
129         return __imAddress;
130 }
131
132 void
133 _ImAddressImpl::SetServiceProviderName(const String& serviceProviderName)
134 {
135         __serviceProviderName = serviceProviderName;
136 }
137
138 result
139 _ImAddressImpl::SetImAddress(const String& imAddress)
140 {
141         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));
142
143         __imAddress = imAddress;
144
145         return E_SUCCESS;
146 }
147
148 const _ImAddressImpl*
149 _ImAddressImpl::GetInstance(const ImAddress& imAddress)
150 {
151         return imAddress.__pImAddressImpl;
152 }
153
154 _ImAddressImpl*
155 _ImAddressImpl::GetInstance(ImAddress& imAddress)
156 {
157         return imAddress.__pImAddressImpl;
158 }
159
160
161 }} // Tizen::Social