2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @brief This is the implementation for Url class.
21 * This file contains definitions of @e Url class.
25 #include <FApp_AppInfo.h>
26 #include <FBaseSysLog.h>
27 #include "FScl_UrlImpl.h"
29 using namespace Tizen::App;
30 using namespace Tizen::Base;
32 namespace Tizen { namespace Social
37 __pUrlImpl = new (std::nothrow) _UrlImpl();
38 SysTryReturnVoidResult(NID_SCL, __pUrlImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
41 Url::Url(UrlType type, const String& url)
43 __pUrlImpl = new (std::nothrow) _UrlImpl(type, url);
44 SysTryReturnVoidResult(NID_SCL, __pUrlImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
47 Url::Url(const Url& rhs)
49 __pUrlImpl = new (std::nothrow) _UrlImpl(*rhs.__pUrlImpl);
50 SysTryReturnVoidResult(NID_SCL, __pUrlImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
59 Url::operator =(const Url& rhs)
66 *__pUrlImpl = *rhs.__pUrlImpl;
72 Url::operator ==(const Url& rhs) const
74 return *__pUrlImpl == *rhs.__pUrlImpl;
78 Url::operator !=(const Url& rhs) const
80 return !(*this == rhs);
84 Url::Equals(const Object& rhs) const
86 const Url* pUrl = dynamic_cast<const Url*>(&rhs);
93 return __pUrlImpl->Equals(*pUrl->__pUrlImpl);
97 Url::GetHashCode(void) const
99 return __pUrlImpl->GetHashCode();
103 Url::GetType(void) const
105 UrlType type = __pUrlImpl->GetType();
107 if (type == URL_TYPE_CUSTOM && (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
109 type = URL_TYPE_OTHER;
116 Url::GetUrl(void) const
118 String url = __pUrlImpl->GetUrl();
120 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
122 if (url.GetLength() > MAX_URL_LENGTH)
124 url.SetLength(MAX_URL_LENGTH);
132 Url::SetType(UrlType type)
134 __pUrlImpl->SetType(type);
138 Url::SetUrl(const String& url)
140 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
142 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));
145 return __pUrlImpl->SetUrl(url);
149 Url::GetLabel(void) const
151 return __pUrlImpl->GetLabel();
155 Url::SetLabel(const String& label)
157 __pUrlImpl->SetLabel(label);