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
4#ifndef QHOSTINFO_H
5#define QHOSTINFO_H
6
7#include <QtNetwork/qtnetworkglobal.h>
8#include <QtCore/qlist.h>
9#include <QtCore/qscopedpointer.h>
10#include <QtNetwork/qhostaddress.h>
11
13
14
15class QObject;
17
18class Q_NETWORK_EXPORT QHostInfo
19{
20 Q_GADGET
21public:
22 enum HostInfoError {
23 NoError,
24 HostNotFound,
25 UnknownError
26 };
27
28 explicit QHostInfo(int lookupId = -1);
29 QHostInfo(const QHostInfo &d);
30 QHostInfo(QHostInfo &&other) noexcept : d_ptr(std::exchange(other.d_ptr, nullptr)) {}
31 QHostInfo &operator=(const QHostInfo &d);
32 QHostInfo &operator=(QHostInfo &&other) noexcept { swap(other); return *this; }
33 ~QHostInfo();
34
35 void swap(QHostInfo &other) noexcept { qt_ptr_swap(d_ptr, other.d_ptr); }
36
37 QString hostName() const;
38 void setHostName(const QString &name);
39
40 QList<QHostAddress> addresses() const;
41 void setAddresses(const QList<QHostAddress> &addresses);
42
43 HostInfoError error() const;
44 void setError(HostInfoError error);
45
46 QString errorString() const;
47 void setErrorString(const QString &errorString);
48
49 void setLookupId(int id);
50 int lookupId() const;
51
52#if QT_NETWORK_REMOVED_SINCE(6, 7)
53 static int lookupHost(const QString &name, QObject *receiver, const char *member);
54#endif
55 static int lookupHost(const QString &name, const QObject *receiver, const char *member);
56 static void abortHostLookup(int lookupId);
57
58 static QHostInfo fromName(const QString &name);
59 static QString localHostName();
60 static QString localDomainName();
61
62#ifdef Q_QDOC
63 template<typename Functor>
64 static int lookupHost(const QString &name, const QObject *context, Functor functor);
65#else
66 // lookupHost to a callable (with context)
67 template <typename Functor>
68 static inline int lookupHost(const QString &name,
69 const typename QtPrivate::ContextTypeForFunctor<Functor>::ContextType *receiver,
70 Functor &&func)
71 {
72 using Prototype = void(*)(QHostInfo);
73 QtPrivate::AssertCompatibleFunctions<Prototype, Functor>();
74 return lookupHostImpl(name, receiver,
75 QtPrivate::makeCallableObject<Prototype>(std::forward<Functor>(func)),
76 nullptr);
77 }
78#endif // Q_QDOC
79
80#ifndef QT_NO_CONTEXTLESS_CONNECT
81 // lookupHost to a callable (without context)
82 template <typename Functor>
83 static inline int lookupHost(const QString &name, Functor &&slot)
84 {
85 return lookupHost(name, nullptr, std::forward<Functor>(slot));
86 }
87#endif // QT_NO_CONTEXTLESS_CONNECT
88
89private:
90 QHostInfoPrivate *d_ptr;
91 Q_DECLARE_PRIVATE(QHostInfo)
92
93 static int lookupHostImpl(const QString &name,
94 const QObject *receiver,
95 QtPrivate::QSlotObjectBase *slotObj,
96 const char *member);
97
98 friend QHostInfo Q_NETWORK_EXPORT qt_qhostinfo_lookup(const QString &name, QObject *receiver,
99 const char *member, bool *valid, int *id);
100};
101
103
104QT_END_NAMESPACE
105
106QT_DECL_METATYPE_EXTERN(QHostInfo, Q_NETWORK_EXPORT)
107
108#endif // QHOSTINFO_H
The QHostInfo class provides static functions for host name lookups.
Definition qhostinfo.h:19
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 close down 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...
Combined button and popup list for selecting options.
Q_DECLARE_TYPEINFO(QNetworkReplyImplPrivate::InternalNotifications, Q_PRIMITIVE_TYPE)