43 #include "../qnetworksession_impl.h" 45 #include <QtNetwork/private/qnetworkconfiguration_p.h> 47 #include <QtCore/qthread.h> 48 #include <QtCore/qmutex.h> 49 #include <QtCore/qcoreapplication.h> 50 #include <QtCore/qstringlist.h> 52 #include <QtCore/qdebug.h> 53 #include <QtCore/private/qcoreapplication_p.h> 56 #include "../platformdefs_win.h" 60 #include <sys/socket.h> 61 #include <sys/ioctl.h> 63 #include <net/if_arp.h> 67 #ifndef QT_NO_BEARERMANAGEMENT 71 #ifndef QT_NO_NETWORKINTERFACE 82 FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
83 if (handle == INVALID_HANDLE_VALUE)
89 &medium,
sizeof(medium), &bytesWritten, 0);
98 &physicalMedium,
sizeof(physicalMedium), &bytesWritten, 0);
111 switch (physicalMedium) {
119 #ifdef BEARER_MANAGEMENT_DEBUG 120 qDebug() <<
"Physical Medium" << physicalMedium;
126 #ifdef BEARER_MANAGEMENT_DEBUG 127 qDebug() << medium << physicalMedium;
129 #elif defined(Q_OS_LINUX) 130 int sock = socket(AF_INET, SOCK_DGRAM, 0);
133 strncpy(request.ifr_name, interface.
toLocal8Bit().
data(),
sizeof(request.ifr_name));
134 int result = ioctl(sock, SIOCGIFHWADDR, &request);
137 if (result >= 0 && request.ifr_hwaddr.sa_family == ARPHRD_ETHER)
195 #ifndef QT_NO_NETWORKINTERFACE 209 while (!interfaces.
isEmpty()) {
212 if (!interface.isValid())
224 if (interface.index())
235 name = interface.name();
244 bool changed =
false;
253 if (ptr->
name != name) {
263 if (ptr->
state != state) {
362 #endif // QT_NO_BEARERMANAGEMENT BearerType
Specifies the type of bearer used by a configuration.
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
uint qHash(const QProcEnvKey &key)
bool requiresPolling() const
#define QT_END_NAMESPACE
This macro expands to.
void lock()
Locks the mutex.
char * data()
Returns a pointer to the data stored in the byte array.
QNetworkConfiguration::StateFlags state
static QNetworkConfiguration::BearerType qGetInterfaceType(const QString &interface)
void configurationChanged(QNetworkConfigurationPrivatePointer config)
void unlock()
Unlocks this mutex locker.
QNetworkSession::State sessionStateForId(const QString &id)
State
This enum describes the connectivity state of the session.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QString getInterfaceFromId(const QString &id)
The QString class provides a Unicode character string.
QNetworkSessionPrivate * createSessionBackend()
The QObject class is the base class of all Qt objects.
QNetworkConfiguration::BearerType bearerType
Q_INVOKABLE void requestUpdate()
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
void relock()
Relocks an unlocked mutex locker.
Q_CORE_EXPORT void qDebug(const char *,...)
bool hasIdentifier(const QString &id)
#define QT_BEGIN_NAMESPACE
This macro expands to.
QHash< QString, QNetworkConfigurationPrivatePointer > accessPointConfigurations
T takeFirst()
Removes the first item in the list and returns it.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
void disconnectFromId(const QString &id)
const T value(const Key &key) const
Returns the value associated with the key key.
QGenericEngine(QObject *parent=0)
The QStringList class provides a list of strings.
void configurationAdded(QNetworkConfigurationPrivatePointer config)
QNetworkConfigurationManager::Capabilities capabilities() const
const T * ptr(const T &t)
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
void unlock()
Unlocks the mutex.
Q_INVOKABLE void initialize()
static QNetworkInterface interfaceFromIndex(int index)
Returns a QNetworkInterface object for the interface whose internal ID is index.
QNetworkConfigurationPrivatePointer defaultConfiguration()
int remove(const Key &key)
Removes all the items that have the key key from the map.
void connectToId(const QString &id)
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
QExplicitlySharedDataPointer< QNetworkConfigurationPrivate > QNetworkConfigurationPrivatePointer
QNetworkConfiguration::Type type
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
iterator insert(const Key &key, const T &value)
Inserts a new item with the key key and a value of value.
static QList< QNetworkInterface > allInterfaces()
Returns a listing of all the network interfaces found on the host machine.
void configurationRemoved(QNetworkConfigurationPrivatePointer config)
bool contains(const Key &key) const
Returns true if the map contains an item with key key; otherwise returns false.
void connectionError(const QString &id, QBearerEngineImpl::ConnectionError error)
The QNetworkInterface class provides a listing of the host's IP addresses and network interfaces...
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
QMap< QString, QString > configurationInterface
The QList class is a template class that provides lists.
int removeAll(const T &t)
Removes all occurrences of value in the list and returns the number of entries removed.