remove return on void function
[framework/osp/social.git] / src / FSclUrl.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                FSclUrl.cpp
18  * @brief               This is the implementation for Url class.
19  *
20  * This file contains definitions of @e Url class.
21  */
22
23 #include <FSclUrl.h>
24 #include <FApp_AppInfo.h>
25 #include <FBaseSysLog.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 Url::Url(void)
35 {
36         __pUrlImpl = new (std::nothrow) _UrlImpl();
37         SysTryReturnVoidResult(NID_SCL, __pUrlImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
38 }
39
40 Url::Url(UrlType type, const String& url)
41 {
42         __pUrlImpl = new (std::nothrow) _UrlImpl(type, url);
43         SysTryReturnVoidResult(NID_SCL, __pUrlImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
44 }
45
46 Url::Url(const Url& rhs)
47 {
48         __pUrlImpl = new (std::nothrow) _UrlImpl(*rhs.__pUrlImpl);
49         SysTryReturnVoidResult(NID_SCL, __pUrlImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
50 }
51
52 Url::~Url(void)
53 {
54         delete __pUrlImpl;
55 }
56
57 Url&
58 Url::operator =(const Url& rhs)
59 {
60         if (this == &rhs)
61         {
62                 return *this;
63         }
64
65         *__pUrlImpl = *rhs.__pUrlImpl;
66
67         return *this;
68 }
69
70 bool
71 Url::operator ==(const Url& rhs) const
72 {
73         return *__pUrlImpl == *rhs.__pUrlImpl;
74 }
75
76 bool
77 Url::operator !=(const Url& rhs) const
78 {
79         return !(*this == rhs);
80 }
81
82 bool
83 Url::Equals(const Object& rhs) const
84 {
85         const Url* pUrl = dynamic_cast<const Url*>(&rhs);
86
87         if (pUrl == null)
88         {
89                 return false;
90         }
91
92         return __pUrlImpl->Equals(*pUrl->__pUrlImpl);
93 }
94
95 int
96 Url::GetHashCode(void) const
97 {
98         return __pUrlImpl->GetHashCode();
99 }
100
101 UrlType
102 Url::GetType(void) const
103 {
104         UrlType type =  __pUrlImpl->GetType();
105
106         if (type == URL_TYPE_CUSTOM  && (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
107         {
108                 type =  URL_TYPE_OTHER;
109         }
110
111         return type;
112 }
113
114 String
115 Url::GetUrl(void) const
116 {
117         String url = __pUrlImpl->GetUrl();
118
119         if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
120         {
121                 if (url.GetLength() > MAX_URL_LENGTH)
122                 {
123                         url.SetLength(MAX_URL_LENGTH);
124                 }
125         }
126
127         return url;
128 }
129
130 void
131 Url::SetType(UrlType type)
132 {
133         __pUrlImpl->SetType(type);
134 }
135
136 result
137 Url::SetUrl(const String& url)
138 {
139         if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
140         {
141                 SysTryReturn(NID_SCL, url.GetLength() <= MAX_URL_LENGTH, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The length of the url exceeds MAX_URL_LENGTH", GetErrorMessage(E_INVALID_ARG));
142         }
143
144         return __pUrlImpl->SetUrl(url);
145 }
146
147 String
148 Url::GetLabel(void) const
149 {
150         return __pUrlImpl->GetLabel();
151 }
152
153 void
154 Url::SetLabel(const String& label)
155 {
156         __pUrlImpl->SetLabel(label);
157 }
158
159 }} // Tizen::Social