2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @brief This is the implementation for Url class.
20 * This file contains definitions of @e Url class.
24 #include <FApp_AppInfo.h>
25 #include <FBaseSysLog.h>
26 #include "FScl_UrlImpl.h"
28 using namespace Tizen::App;
29 using namespace Tizen::Base;
31 namespace Tizen { namespace Social
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));
40 Url::Url(UrlType type, const String& url)
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));
46 Url::Url(const Url& rhs)
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));
58 Url::operator =(const Url& rhs)
65 *__pUrlImpl = *rhs.__pUrlImpl;
71 Url::operator ==(const Url& rhs) const
73 return *__pUrlImpl == *rhs.__pUrlImpl;
77 Url::operator !=(const Url& rhs) const
79 return !(*this == rhs);
83 Url::Equals(const Object& rhs) const
85 const Url* pUrl = dynamic_cast<const Url*>(&rhs);
92 return __pUrlImpl->Equals(*pUrl->__pUrlImpl);
96 Url::GetHashCode(void) const
98 return __pUrlImpl->GetHashCode();
102 Url::GetType(void) const
104 UrlType type = __pUrlImpl->GetType();
106 if (type == URL_TYPE_CUSTOM && (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
108 type = URL_TYPE_OTHER;
115 Url::GetUrl(void) const
117 String url = __pUrlImpl->GetUrl();
119 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
121 if (url.GetLength() > MAX_URL_LENGTH)
123 url.SetLength(MAX_URL_LENGTH);
131 Url::SetType(UrlType type)
133 __pUrlImpl->SetType(type);
137 Url::SetUrl(const String& url)
139 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
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));
144 return __pUrlImpl->SetUrl(url);
148 Url::GetLabel(void) const
150 return __pUrlImpl->GetLabel();
154 Url::SetLabel(const String& label)
156 __pUrlImpl->SetLabel(label);