// // Copyright (c) 2012 Samsung Electronics Co., Ltd. // // Licensed under the Apache License, Version 2.0 (the License); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // /** * @file FSclUrl.cpp * @brief This is the implementation for Url class. * * This file contains definitions of @e Url class. */ #include #include #include #include "FScl_UrlImpl.h" using namespace Tizen::App; using namespace Tizen::Base; namespace Tizen { namespace Social { Url::Url(void) { __pUrlImpl = new (std::nothrow) _UrlImpl(); SysTryReturnVoidResult(NID_SCL, __pUrlImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); } Url::Url(UrlType type, const String& url) { __pUrlImpl = new (std::nothrow) _UrlImpl(type, url); SysTryReturnVoidResult(NID_SCL, __pUrlImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); } Url::Url(const Url& rhs) { __pUrlImpl = new (std::nothrow) _UrlImpl(*rhs.__pUrlImpl); SysTryReturnVoidResult(NID_SCL, __pUrlImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); } Url::~Url(void) { delete __pUrlImpl; } Url& Url::operator =(const Url& rhs) { if (this == &rhs) { return *this; } *__pUrlImpl = *rhs.__pUrlImpl; return *this; } bool Url::operator ==(const Url& rhs) const { return *__pUrlImpl == *rhs.__pUrlImpl; } bool Url::operator !=(const Url& rhs) const { return !(*this == rhs); } bool Url::Equals(const Object& rhs) const { const Url* pUrl = dynamic_cast(&rhs); if (pUrl == null) { return false; } return __pUrlImpl->Equals(*pUrl->__pUrlImpl); } int Url::GetHashCode(void) const { return __pUrlImpl->GetHashCode(); } UrlType Url::GetType(void) const { UrlType type = __pUrlImpl->GetType(); if (type == URL_TYPE_CUSTOM && (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())) { type = URL_TYPE_OTHER; } return type; } String Url::GetUrl(void) const { String url = __pUrlImpl->GetUrl(); if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()) { if (url.GetLength() > MAX_URL_LENGTH) { url.SetLength(MAX_URL_LENGTH); } } return url; } void Url::SetType(UrlType type) { __pUrlImpl->SetType(type); } result Url::SetUrl(const String& url) { if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()) { 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)); } return __pUrlImpl->SetUrl(url); } String Url::GetLabel(void) const { return __pUrlImpl->GetLabel(); } void Url::SetLabel(const String& label) { __pUrlImpl->SetLabel(label); } }} // Tizen::Social