Initialize Tizen 2.3
[framework/osp/social.git] / src / FScl_UrlImpl.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_UrlImpl.cpp
18  * @brief               This is the implementation for _UrlImpl class.
19  *
20  * This file contains definitions of @e _UrlImpl class.
21  */
22
23 #include <FBaseSysLog.h>
24 #include <FSclUrl.h>
25 #include <FApp_AppInfo.h>
26 #include "FScl_UrlImpl.h"
27
28 using namespace Tizen::App;
29 using namespace Tizen::Base;
30
31 namespace Tizen { namespace Social
32 {
33
34 _UrlImpl::_UrlImpl(void)
35         : __type(URL_TYPE_PERSONAL)
36 {
37         //empty body
38 }
39
40 _UrlImpl::_UrlImpl(UrlType type, const String& url)
41         : __type(type)
42         , __url(url)
43 {
44
45 }
46
47 _UrlImpl::_UrlImpl(const _UrlImpl& rhs)
48 {
49         __type = rhs.__type;
50         __label = rhs.__label;
51         __url = rhs.__url;
52 }
53
54 _UrlImpl::~_UrlImpl(void)
55 {
56         // empty body.
57 }
58
59 _UrlImpl&
60 _UrlImpl::operator =(const _UrlImpl& rhs)
61 {
62         if (this == &rhs)
63         {
64                 return *this;
65         }
66
67         __type = rhs.__type;
68         __label = rhs.__label;
69         __url = rhs.__url;
70
71         return *this;
72 }
73
74 bool
75 _UrlImpl::operator ==(const _UrlImpl& rhs) const
76 {
77         if (__type == rhs.__type && __label == rhs.__label && __url == rhs.__url)
78         {
79                 return true;
80         }
81
82         return false;
83 }
84
85 bool
86 _UrlImpl::operator !=(const _UrlImpl& rhs) const
87 {
88         return !(*this == rhs);
89 }
90
91 bool
92 _UrlImpl::Equals(const Object& rhs) const
93 {
94         const _UrlImpl* pUrl = dynamic_cast<const _UrlImpl*>(&rhs);
95
96         if (pUrl == null)
97         {
98                 return false;
99         }
100
101         return (*this == *pUrl);
102 }
103
104 int
105 _UrlImpl::GetHashCode(void) const
106 {
107         int hashCode = 0;
108
109         hashCode = __type;
110         hashCode += __label.GetHashCode();
111         hashCode += __url.GetHashCode();
112
113         return hashCode;
114 }
115
116 UrlType
117 _UrlImpl::GetType(void) const
118 {
119         return __type;
120 }
121
122 String
123 _UrlImpl::GetUrl(void) const
124 {
125         return __url;
126 }
127
128 void
129 _UrlImpl::SetType(UrlType type)
130 {
131         __type = type;
132 }
133
134 result
135 _UrlImpl::SetUrl(const String& url)
136 {
137         SysTryReturn(NID_SCL,  !url.IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The url is empty", GetErrorMessage(E_INVALID_ARG));
138
139         __url = url;
140
141         return E_SUCCESS;
142 }
143
144 String
145 _UrlImpl::GetLabel(void) const
146 {
147         return __label;
148 }
149
150 void
151 _UrlImpl::SetLabel(const String& label)
152 {
153         __label = label;
154 }
155
156 const _UrlImpl*
157 _UrlImpl::GetInstance(const Url& url)
158 {
159         return url.__pUrlImpl;
160 }
161
162 _UrlImpl*
163 _UrlImpl::GetInstance(Url& url)
164 {
165         return url.__pUrlImpl;
166 }
167
168
169 }} // Tizen::Social