mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 18:55:38 +08:00
refs #485 URL/URL list
* added constructor for CUrlList * added registration of metadata of fail over class * default port support for getPort
This commit is contained in:
committed by
Mathew Sutcliffe
parent
ce3edc37d0
commit
92a36890eb
@@ -28,6 +28,7 @@ namespace BlackMisc
|
|||||||
CTextMessageList::registerMetadata();
|
CTextMessageList::registerMetadata();
|
||||||
CUrl::registerMetadata();
|
CUrl::registerMetadata();
|
||||||
CUrlList::registerMetadata();
|
CUrlList::registerMetadata();
|
||||||
|
CFailoverUrlList::registerMetadata();
|
||||||
CUser::registerMetadata();
|
CUser::registerMetadata();
|
||||||
CUserList::registerMetadata();
|
CUserList::registerMetadata();
|
||||||
CVoiceCapabilities::registerMetadata();
|
CVoiceCapabilities::registerMetadata();
|
||||||
|
|||||||
@@ -56,6 +56,12 @@ namespace BlackMisc
|
|||||||
return m_path;
|
return m_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CUrl::getPort() const
|
||||||
|
{
|
||||||
|
if (m_port > 0) { return m_port; }
|
||||||
|
return protocolToDefaultPort(this->getScheme());
|
||||||
|
}
|
||||||
|
|
||||||
bool CUrl::hasPort() const
|
bool CUrl::hasPort() const
|
||||||
{
|
{
|
||||||
return m_port >= 0;
|
return m_port >= 0;
|
||||||
@@ -128,6 +134,11 @@ namespace BlackMisc
|
|||||||
this->setQuery(url.query());
|
this->setQuery(url.query());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QNetworkRequest CUrl::toNetworkRequest() const
|
||||||
|
{
|
||||||
|
return QNetworkRequest(this->toQUrl());
|
||||||
|
}
|
||||||
|
|
||||||
CUrl CUrl::withAppendedPath(const QString &path) const
|
CUrl CUrl::withAppendedPath(const QString &path) const
|
||||||
{
|
{
|
||||||
if (path.isEmpty()) { return *this; }
|
if (path.isEmpty()) { return *this; }
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include "blackmisc/blackmiscexport.h"
|
#include "blackmisc/blackmiscexport.h"
|
||||||
#include "blackmisc/valueobject.h"
|
#include "blackmisc/valueobject.h"
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
#include <QNetworkRequest>
|
||||||
|
|
||||||
namespace BlackMisc
|
namespace BlackMisc
|
||||||
{
|
{
|
||||||
@@ -75,7 +76,7 @@ namespace BlackMisc
|
|||||||
bool hasPath() const { return !m_path.isEmpty(); }
|
bool hasPath() const { return !m_path.isEmpty(); }
|
||||||
|
|
||||||
//! Get port
|
//! Get port
|
||||||
int getPort() const { return m_port; }
|
int getPort() const;
|
||||||
|
|
||||||
//! Set port
|
//! Set port
|
||||||
void setPort(int port) { m_port = port; }
|
void setPort(int port) { m_port = port; }
|
||||||
@@ -113,6 +114,9 @@ namespace BlackMisc
|
|||||||
//! To QUrl
|
//! To QUrl
|
||||||
void setQUrl(const QUrl &url);
|
void setQUrl(const QUrl &url);
|
||||||
|
|
||||||
|
//! To request
|
||||||
|
QNetworkRequest toNetworkRequest() const;
|
||||||
|
|
||||||
//! Append path
|
//! Append path
|
||||||
CUrl withAppendedPath(const QString &path) const;
|
CUrl withAppendedPath(const QString &path) const;
|
||||||
|
|
||||||
|
|||||||
@@ -163,6 +163,10 @@ namespace BlackMisc
|
|||||||
CUrlList(other), m_maxTrials(maxTrials)
|
CUrlList(other), m_maxTrials(maxTrials)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
CFailoverUrlList::CFailoverUrlList(const CUrlList &urlIst) :
|
||||||
|
CUrlList(urlIst)
|
||||||
|
{ }
|
||||||
|
|
||||||
CUrlList CFailoverUrlList::getWithoutFailed() const
|
CUrlList CFailoverUrlList::getWithoutFailed() const
|
||||||
{
|
{
|
||||||
CUrlList urls(*this);
|
CUrlList urls(*this);
|
||||||
|
|||||||
@@ -90,6 +90,9 @@ namespace BlackMisc
|
|||||||
//! Construct from a base class object.
|
//! Construct from a base class object.
|
||||||
CFailoverUrlList(const CSequence<CUrl> &other, int maxTrials = 2);
|
CFailoverUrlList(const CSequence<CUrl> &other, int maxTrials = 2);
|
||||||
|
|
||||||
|
//! From url list
|
||||||
|
CFailoverUrlList(const CUrlList &urlIst);
|
||||||
|
|
||||||
//! All failed URLs
|
//! All failed URLs
|
||||||
const CUrlList &getFailedUrls() const { return m_failedUrls; }
|
const CUrlList &getFailedUrls() const { return m_failedUrls; }
|
||||||
|
|
||||||
@@ -117,6 +120,7 @@ namespace BlackMisc
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(BlackMisc::Network::CUrlList)
|
Q_DECLARE_METATYPE(BlackMisc::Network::CUrlList)
|
||||||
|
Q_DECLARE_METATYPE(BlackMisc::Network::CFailoverUrlList)
|
||||||
Q_DECLARE_METATYPE(BlackMisc::CCollection<BlackMisc::Network::CUrl>)
|
Q_DECLARE_METATYPE(BlackMisc::CCollection<BlackMisc::Network::CUrl>)
|
||||||
Q_DECLARE_METATYPE(BlackMisc::CSequence<BlackMisc::Network::CUrl>)
|
Q_DECLARE_METATYPE(BlackMisc::CSequence<BlackMisc::Network::CUrl>)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user