Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qhostinfo.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QHOSTINFO_H
6#define QHOSTINFO_H
7
8#include <QtNetwork/qtnetworkglobal.h>
9#include <QtCore/qlist.h>
10#include <QtCore/qscopedpointer.h>
11#include <QtNetwork/qhostaddress.h>
12
14
15
16class QObject;
18
19class Q_NETWORK_EXPORT QHostInfo
20{
21 Q_GADGET
22public:
23 enum HostInfoError {
24 NoError,
25 HostNotFound,
26 UnknownError
27 };
28
29 explicit QHostInfo(int lookupId = -1);
30 QHostInfo(const QHostInfo &d);
31 QHostInfo(QHostInfo &&other) noexcept : d_ptr(std::exchange(other.d_ptr, nullptr)) {}
32 QHostInfo &operator=(const QHostInfo &d);
33 QHostInfo &operator=(QHostInfo &&other) noexcept { swap(other); return *this; }
34 ~QHostInfo();
35
36 void swap(QHostInfo &other) noexcept { qt_ptr_swap(d_ptr, other.d_ptr); }
37
38 QString hostName() const;
39 void setHostName(const QString &name);
40
41 QList<QHostAddress> addresses() const;
42 void setAddresses(const QList<QHostAddress> &addresses);
43
44 HostInfoError error() const;
45 void setError(HostInfoError error);
46
47 QString errorString() const;
48 void setErrorString(const QString &errorString);
49
50 void setLookupId(int id);
51 int lookupId() const;
52
53#if QT_NETWORK_REMOVED_SINCE(6, 7)
54 static int lookupHost(const QString &name, QObject *receiver, const char *member);
55#endif
56 static int lookupHost(const QString &name, const QObject *receiver, const char *member);
57 static void abortHostLookup(int lookupId);
58
59 static QHostInfo fromName(const QString &name);
60 static QString localHostName();
61 static QString localDomainName();
62
63#ifdef Q_QDOC
64 template<typename Functor>
65 static int lookupHost(const QString &name, const QObject *context, Functor functor);
66#else
67 // lookupHost to a callable (with context)
68 template <typename Functor>
69 static inline int lookupHost(const QString &name,
70 const typename QtPrivate::ContextTypeForFunctor<Functor>::ContextType *receiver,
71 Functor &&func)
72 {
73 using Prototype = void(*)(QHostInfo);
74 QtPrivate::AssertCompatibleFunctions<Prototype, Functor>();
75 return lookupHostImpl(name, receiver,
76 QtPrivate::makeCallableObject<Prototype>(std::forward<Functor>(func)),
77 nullptr);
78 }
79#endif // Q_QDOC
80
81#ifndef QT_NO_CONTEXTLESS_CONNECT
82 // lookupHost to a callable (without context)
83 template <typename Functor>
84 static inline int lookupHost(const QString &name, Functor &&slot)
85 {
86 return lookupHost(name, nullptr, std::forward<Functor>(slot));
87 }
88#endif // QT_NO_CONTEXTLESS_CONNECT
89
90private:
91 QHostInfoPrivate *d_ptr;
92 Q_DECLARE_PRIVATE(QHostInfo)
93
94 static int lookupHostImpl(const QString &name,
95 const QObject *receiver,
96 QtPrivate::QSlotObjectBase *slotObj,
97 const char *member);
98
99 friend QHostInfo Q_NETWORK_EXPORT qt_qhostinfo_lookup(const QString &name, QObject *receiver,
100 const char *member, bool *valid, int *id);
101};
102
104
105QT_END_NAMESPACE
106
107QT_DECL_METATYPE_EXTERN(QHostInfo, Q_NETWORK_EXPORT)
108
109#endif // QHOSTINFO_H
The QHostInfo class provides static functions for host name lookups.
Definition qhostinfo.h:20
QNetworkReplyImplPrivate * m_reply
QNetworkAccessBackend::SecurityFeatures m_securityFeatures
QNetworkAccessBackend::IOFeatures m_ioFeatures
QNetworkAccessManagerPrivate * m_manager
std::shared_ptr< QNonContiguousByteDevice > uploadByteDevice
QNetworkAccessBackend::TargetTypes m_targetTypes
QStringList backendSupportedSchemes() const
QNetworkAccessBackend * findBackend(QNetworkAccessManager::Operation op, const QNetworkRequest &request)
std::vector< InternalNotifications > pendingNotifications
void setDownloadBuffer(QSharedPointer< char > sp, qint64 size)
void error(QNetworkReply::NetworkError code, const QString &errorString)
void appendDownstreamDataDownloadBuffer(qint64, qint64)
QSharedPointer< char > downloadBufferPointer
QNetworkAccessBackend * backend
void appendDownstreamData(QIODevice *data)
void setup(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice *outgoingData)
void emitUploadProgress(qint64 bytesSent, qint64 bytesTotal)
void backendNotify(InternalNotifications notification)
std::shared_ptr< QRingBuffer > outgoingDataBuffer
QAbstractNetworkCache * networkCache() const
void appendDownstreamData(QByteDataBuffer &data)
char * getDownloadBuffer(qint64 size)
void consume(qint64 count)
void sslErrors(const QList< QSslError > &errors)
QList< QNetworkProxy > proxyList
void redirectionRequested(const QUrl &target)
void setCachingEnabled(bool enable)
virtual qint64 bytesAvailable() const override
Returns the number of bytes available for reading with QIODevice::read().
virtual qint64 readData(char *data, qint64 maxlen) override
virtual void ignoreSslErrorsImplementation(const QList< QSslError > &errors) override
virtual void setReadBufferSize(qint64 size) override
Sets the size of the read buffer to be size bytes.
virtual void close() override
Closes this device for reading.
virtual void abort() override
Aborts the operation immediately and closes any network connections still open.
virtual bool event(QEvent *) override
void void void void _q_bufferOutgoingDataFinished()) protected void setSslConfigurationImplementation(const QSslConfiguration &configuration) override
virtual void ignoreSslErrors() override
If this function is called, SSL errors related to network connection will be ignored,...
The QNetworkReply class contains the data and headers for a request sent with QNetworkAccessManager.
The QSslPreSharedKeyAuthenticator class provides authentication data for pre shared keys (PSK) cipher...
Q_DECLARE_TYPEINFO(QNetworkReplyImplPrivate::InternalNotifications, Q_PRIMITIVE_TYPE)