Qt 4.8
Public Functions | Private Slots | Properties | List of all members
QGenericEngine Class Reference

#include <qgenericengine.h>

Inheritance diagram for QGenericEngine:
QBearerEngineImpl QBearerEngine QObject

Public Functions

QNetworkConfigurationManager::Capabilities capabilities () const
 
void connectToId (const QString &id)
 
QNetworkSessionPrivatecreateSessionBackend ()
 
QNetworkConfigurationPrivatePointer defaultConfiguration ()
 
void disconnectFromId (const QString &id)
 
QString getInterfaceFromId (const QString &id)
 
bool hasIdentifier (const QString &id)
 
Q_INVOKABLE void initialize ()
 
 QGenericEngine (QObject *parent=0)
 
Q_INVOKABLE void requestUpdate ()
 
bool requiresPolling () const
 
QNetworkSession::State sessionStateForId (const QString &id)
 
 ~QGenericEngine ()
 
- Public Functions inherited from QBearerEngineImpl
virtual quint64 bytesReceived (const QString &)
 
virtual quint64 bytesWritten (const QString &)
 
 QBearerEngineImpl (QObject *parent=0)
 
virtual quint64 startTime (const QString &)
 
 ~QBearerEngineImpl ()
 
- Public Functions inherited from QBearerEngine
bool configurationsInUse () const
 
 QBearerEngine (QObject *parent=0)
 
virtual ~QBearerEngine ()
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Private Slots

void doRequestUpdate ()
 

Properties

QMap< QString, QStringconfigurationInterface
 

Additional Inherited Members

- Public Types inherited from QBearerEngineImpl
enum  ConnectionError { InterfaceLookupError = 0, ConnectError, OperationNotSupported, DisconnectionError }
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QBearerEngineImpl
void connectionError (const QString &id, QBearerEngineImpl::ConnectionError error)
 
- Signals inherited from QBearerEngine
void configurationAdded (QNetworkConfigurationPrivatePointer config)
 
void configurationChanged (QNetworkConfigurationPrivatePointer config)
 
void configurationRemoved (QNetworkConfigurationPrivatePointer config)
 
void updateCompleted ()
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QBearerEngine
QHash< QString, QNetworkConfigurationPrivatePointeraccessPointConfigurations
 
QMutex mutex
 
QHash< QString, QNetworkConfigurationPrivatePointersnapConfigurations
 
QHash< QString, QNetworkConfigurationPrivatePointeruserChoiceConfigurations
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 57 of file qgenericengine.h.

Constructors and Destructors

◆ QGenericEngine()

QGenericEngine::QGenericEngine ( QObject parent = 0)

Definition at line 147 of file qgenericengine.cpp.

148 : QBearerEngineImpl(parent)
149 {
150  //workaround for deadlock in __cxa_guard_acquire with webkit on macos x
151  //initialise the Q_GLOBAL_STATIC in same thread as the AtomicallyInitializedStatic
153 }
QBearerEngineImpl(QObject *parent=0)
static QNetworkInterface interfaceFromIndex(int index)
Returns a QNetworkInterface object for the interface whose internal ID is index.

◆ ~QGenericEngine()

QGenericEngine::~QGenericEngine ( )

Definition at line 155 of file qgenericengine.cpp.

156 {
157 }

Functions

◆ capabilities()

QNetworkConfigurationManager::Capabilities QGenericEngine::capabilities ( ) const
virtual

◆ connectToId()

void QGenericEngine::connectToId ( const QString id)
virtual

Implements QBearerEngineImpl.

Definition at line 173 of file qgenericengine.cpp.

174 {
176 }
#define emit
Definition: qobjectdefs.h:76
void connectionError(const QString &id, QBearerEngineImpl::ConnectionError error)

◆ createSessionBackend()

QNetworkSessionPrivate * QGenericEngine::createSessionBackend ( )
virtual

Implements QBearerEngine.

Definition at line 344 of file qgenericengine.cpp.

◆ defaultConfiguration()

QNetworkConfigurationPrivatePointer QGenericEngine::defaultConfiguration ( )
virtual

Implements QBearerEngine.

Definition at line 349 of file qgenericengine.cpp.

350 {
352 }
QExplicitlySharedDataPointer< QNetworkConfigurationPrivate > QNetworkConfigurationPrivatePointer

◆ disconnectFromId()

void QGenericEngine::disconnectFromId ( const QString id)
virtual

Implements QBearerEngineImpl.

Definition at line 178 of file qgenericengine.cpp.

179 {
181 }
#define emit
Definition: qobjectdefs.h:76
void connectionError(const QString &id, QBearerEngineImpl::ConnectionError error)

◆ doRequestUpdate

void QGenericEngine::doRequestUpdate ( )
privateslot

Definition at line 193 of file qgenericengine.cpp.

Referenced by initialize(), and requestUpdate().

194 {
195 #ifndef QT_NO_NETWORKINTERFACE
196  QMutexLocker locker(&mutex);
197 
198  // Immediately after connecting with a wireless access point
199  // QNetworkInterface::allInterfaces() will sometimes return an empty list. Calling it again a
200  // second time results in a non-empty list. If we loose interfaces we will end up removing
201  // network configurations which will break current sessions.
203  if (interfaces.isEmpty())
204  interfaces = QNetworkInterface::allInterfaces();
205 
206  QStringList previous = accessPointConfigurations.keys();
207 
208  // create configuration for each interface
209  while (!interfaces.isEmpty()) {
210  QNetworkInterface interface = interfaces.takeFirst();
211 
212  if (!interface.isValid())
213  continue;
214 
215  // ignore loopback interface
216  if (interface.flags() & QNetworkInterface::IsLoopBack)
217  continue;
218 
219  // ignore WLAN interface handled in separate engine
220  if (qGetInterfaceType(interface.name()) == QNetworkConfiguration::BearerWLAN)
221  continue;
222 
223  uint identifier;
224  if (interface.index())
225  identifier = qHash(QLatin1String("generic:") + QString::number(interface.index()));
226  else
227  identifier = qHash(QLatin1String("generic:") + interface.hardwareAddress());
228 
229  const QString id = QString::number(identifier);
230 
231  previous.removeAll(id);
232 
233  QString name = interface.humanReadableName();
234  if (name.isEmpty())
235  name = interface.name();
236 
237  QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Defined;
238  if ((interface.flags() & QNetworkInterface::IsRunning) && !interface.addressEntries().isEmpty())
240 
241  if (accessPointConfigurations.contains(id)) {
243 
244  bool changed = false;
245 
246  ptr->mutex.lock();
247 
248  if (!ptr->isValid) {
249  ptr->isValid = true;
250  changed = true;
251  }
252 
253  if (ptr->name != name) {
254  ptr->name = name;
255  changed = true;
256  }
257 
258  if (ptr->id != id) {
259  ptr->id = id;
260  changed = true;
261  }
262 
263  if (ptr->state != state) {
264  ptr->state = state;
265  changed = true;
266  }
267 
268  ptr->mutex.unlock();
269 
270  if (changed) {
271  locker.unlock();
273  locker.relock();
274  }
275  } else {
277 
278  ptr->name = name;
279  ptr->isValid = true;
280  ptr->id = id;
281  ptr->state = state;
283  ptr->bearerType = qGetInterfaceType(interface.name());
284 
285  accessPointConfigurations.insert(id, ptr);
286  configurationInterface.insert(id, interface.name());
287 
288  locker.unlock();
290  locker.relock();
291  }
292  }
293 
294  while (!previous.isEmpty()) {
296  accessPointConfigurations.take(previous.takeFirst());
297 
299 
300  locker.unlock();
302  locker.relock();
303  }
304 
305  locker.unlock();
306 #endif
307 
309 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
uint qHash(const QProcEnvKey &key)
Definition: qprocess_p.h:96
void lock()
Locks the mutex.
Definition: qmutex.cpp:151
QNetworkConfiguration::StateFlags state
static QNetworkConfiguration::BearerType qGetInterfaceType(const QString &interface)
void configurationChanged(QNetworkConfigurationPrivatePointer config)
void updateCompleted()
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
QNetworkConfiguration::BearerType bearerType
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
QHash< QString, QNetworkConfigurationPrivatePointer > accessPointConfigurations
T takeFirst()
Removes the first item in the list and returns it.
Definition: qlist.h:489
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
const char * name
#define emit
Definition: qobjectdefs.h:76
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
void configurationAdded(QNetworkConfigurationPrivatePointer config)
unsigned int uint
Definition: qglobal.h:996
const T * ptr(const T &t)
void unlock()
Unlocks the mutex.
Definition: qmutex.cpp:296
int remove(const Key &key)
Removes all the items that have the key key from the map.
Definition: qmap.h:662
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
QNetworkConfiguration::Type type
iterator insert(const Key &key, const T &value)
Inserts a new item with the key key and a value of value.
Definition: qmap.h:559
static QList< QNetworkInterface > allInterfaces()
Returns a listing of all the network interfaces found on the host machine.
void configurationRemoved(QNetworkConfigurationPrivatePointer config)
The QNetworkInterface class provides a listing of the host&#39;s IP addresses and network interfaces...
QMap< QString, QString > configurationInterface
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
int removeAll(const T &t)
Removes all occurrences of value in the list and returns the number of entries removed.
Definition: qlist.h:770

◆ getInterfaceFromId()

QString QGenericEngine::getInterfaceFromId ( const QString id)
virtual

Implements QBearerEngineImpl.

Definition at line 159 of file qgenericengine.cpp.

160 {
161  QMutexLocker locker(&mutex);
162 
163  return configurationInterface.value(id);
164 }
const T value(const Key &key) const
Returns the value associated with the key key.
Definition: qmap.h:499
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
QMap< QString, QString > configurationInterface

◆ hasIdentifier()

bool QGenericEngine::hasIdentifier ( const QString id)
virtual

Implements QBearerEngine.

Definition at line 166 of file qgenericengine.cpp.

167 {
168  QMutexLocker locker(&mutex);
169 
170  return configurationInterface.contains(id);
171 }
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
bool contains(const Key &key) const
Returns true if the map contains an item with key key; otherwise returns false.
Definition: qmap.h:553
QMap< QString, QString > configurationInterface

◆ initialize()

void QGenericEngine::initialize ( )

Definition at line 183 of file qgenericengine.cpp.

184 {
185  doRequestUpdate();
186 }

◆ requestUpdate()

void QGenericEngine::requestUpdate ( )

Definition at line 188 of file qgenericengine.cpp.

189 {
190  doRequestUpdate();
191 }

◆ requiresPolling()

bool QGenericEngine::requiresPolling ( ) const
virtual

Reimplemented from QBearerEngine.

Definition at line 355 of file qgenericengine.cpp.

356 {
357  return true;
358 }

◆ sessionStateForId()

QNetworkSession::State QGenericEngine::sessionStateForId ( const QString id)
virtual

Implements QBearerEngineImpl.

Definition at line 311 of file qgenericengine.cpp.

312 {
313  QMutexLocker locker(&mutex);
314 
316 
317  if (!ptr)
319 
320  QMutexLocker configLocker(&ptr->mutex);
321 
322  if (!ptr->isValid) {
326  } else if ((ptr->state & QNetworkConfiguration::Discovered) ==
331  } else if ((ptr->state & QNetworkConfiguration::Undefined) ==
334  }
335 
337 }
QNetworkConfiguration::StateFlags state
QHash< QString, QNetworkConfigurationPrivatePointer > accessPointConfigurations
const T * ptr(const T &t)
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101

Properties

◆ configurationInterface

QMap<QString, QString> QGenericEngine::configurationInterface
private

Definition at line 88 of file qgenericengine.h.

Referenced by doRequestUpdate(), getInterfaceFromId(), and hasIdentifier().


The documentation for this class was generated from the following files: