43 #include "../qnetworksession_impl.h" 46 #include <QThreadStorage> 47 #include <QStringList> 50 #include <bps/netstatus.h> 52 #ifndef QT_NO_BEARERMANAGEMENT 54 #ifdef QBBENGINE_DEBUG 55 #define qBearerDebug qDebug 57 #define qBearerDebug QT_NO_QDEBUG_MACRO 62 static inline void cleanup(netstatus_interface_list_t *list)
64 netstatus_free_interfaces(list);
70 static inline void cleanup(
char *interface)
90 case NETSTATUS_INTERFACE_TYPE_USB:
91 case NETSTATUS_INTERFACE_TYPE_WIRED:
94 case NETSTATUS_INTERFACE_TYPE_WIFI:
97 case NETSTATUS_INTERFACE_TYPE_BLUETOOTH_DUN:
100 case NETSTATUS_INTERFACE_TYPE_CELLULAR:
107 case NETSTATUS_INTERFACE_TYPE_VPN:
108 case NETSTATUS_INTERFACE_TYPE_BB:
109 case NETSTATUS_INTERFACE_TYPE_UNKNOWN:
126 previousEventFilter(0),
127 pollingRequired(false),
171 if (netstatus_request_events(0) != BPS_SUCCESS) {
193 netstatus_interface_list_t interfaceList;
195 if ((netstatus_get_interfaces(&interfaceList)) != BPS_SUCCESS) {
205 for (
int i = 0; i < interfaceList.num_interfaces; i++) {
206 const char *
interface = interfaceList.interfaces[i];
222 if (!currentConfigurations.
contains(
id))
264 if (netstatus_get_default_interface(&interface) != BPS_SUCCESS)
294 bps_event_t *
const event =
static_cast<bps_event_t *
>(message);
298 QBBEngine *
self = instanceStorage()->localData()->instance;
302 if (bps_event_get_domain(
event) == netstatus_get_domain())
303 self->filterEvent(
event);
305 if (
self->previousEventFilter)
306 return self->previousEventFilter(message);
322 netstatus_interface_details_t *details = 0;
324 if (netstatus_get_interface_details(interface, &details) != BPS_SUCCESS) {
334 const netstatus_interface_type_t
type = netstatus_interface_get_type(details);
335 const netstatus_ip_status_t ipStatus = netstatus_interface_get_ip_status(details);
337 netstatus_free_interface_details(&details);
341 if (ipStatus == NETSTATUS_IP_STATUS_OK)
349 bool changed =
false;
358 if (ptr->
name != name) {
368 if (ptr->
state != state) {
373 const netstatus_ip_status_t oldIpStatus = ptr->oldIpStatus;
374 ptr->oldIpStatus = ipStatus;
387 if (oldIpStatus != ipStatus) {
388 if (ipStatus != NETSTATUS_IP_STATUS_OK
389 && ipStatus != NETSTATUS_IP_STATUS_ERROR_NOT_UP
390 && ipStatus != NETSTATUS_IP_STATUS_ERROR_NOT_CONFIGURED) {
436 #endif // QT_NO_BEARERMANAGEMENT BearerType
Specifies the type of bearer used by a configuration.
#define QT_END_NAMESPACE
This macro expands to.
EngineInstanceHolder(QBBEngine *engine)
int remove(const Key &key)
Removes all the items that have the key from the hash.
static QString idForName(const QString &name)
QNetworkConfiguration::StateFlags state
static QAbstractEventDispatcher * instance(QThread *thread=0)
Returns a pointer to the event dispatcher object for the specified thread.
void configurationChanged(QNetworkConfigurationPrivatePointer config)
void disconnectFromId(const QString &id)
void unlock()
Unlocks this mutex locker.
State
This enum describes the connectivity state of the session.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QBBEngine(QObject *parent=0)
The QString class provides a Unicode character string.
The QObject class is the base class of all Qt objects.
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
QNetworkConfiguration::BearerType bearerType
const T value(const Key &key) const
Returns the value associated with the key.
static void cleanup(netstatus_interface_list_t *list)
The QScopedPointer class stores a pointer to a dynamically allocated object, and deletes it upon dest...
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
QAbstractEventDispatcher::EventFilter previousEventFilter
QNetworkConfigurationManager::Capabilities capabilities() const
#define QT_BEGIN_NAMESPACE
This macro expands to.
QHash< QString, QNetworkConfigurationPrivatePointer > accessPointConfigurations
bool contains(const T &value) const
void updateConfiguration(const char *interface)
The QStringList class provides a list of strings.
void configurationAdded(QNetworkConfigurationPrivatePointer config)
Q_CORE_EXPORT void qWarning(const char *,...)
Q_INVOKABLE void requestUpdate()
static QNetworkConfiguration::BearerType interfaceType(netstatus_interface_type_t type)
const T * ptr(const T &t)
QNetworkSessionPrivate * createSessionBackend()
static void cleanup(char *interface)
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
QExplicitlySharedDataPointer< QNetworkConfigurationPrivate > QNetworkConfigurationPrivatePointer
QHash< QString, QString > configurationInterface
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...
EventFilter setEventFilter(EventFilter filter)
Replaces the event filter function for this QAbstractEventDispatcher with filter and returns the repl...
static bool filterEvent(void *message)
bool singleShot
This static function calls a slot after a given time interval.
void configurationRemoved(QNetworkConfigurationPrivatePointer config)
Q_GLOBAL_STATIC(QThreadStorage< EngineInstanceHolder *>, instanceStorage)
QString getInterfaceFromId(const QString &id)
#define Q_FOREACH(variable, container)
Same as foreach(variable, container).
Q_INVOKABLE void initialize()
bool requiresPolling() const
void connectionError(const QString &id, QBearerEngineImpl::ConnectionError error)
void removeConfiguration(const QString &id)
The QThreadStorage class provides per-thread data storage.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
bool hasIdentifier(const QString &id)
void connectToId(const QString &id)
QNetworkSession::State sessionStateForId(const QString &id)
QNetworkConfigurationPrivatePointer defaultConfiguration()