_itf = new QDBusInterface (ICD_DBUS_API_INTERFACE, ICD_DBUS_API_PATH, ICD_DBUS_API_INTERFACE, _bus);
_bus.connect (ICD_DBUS_API_INTERFACE, ICD_DBUS_API_PATH, ICD_DBUS_API_INTERFACE, ICD_DBUS_API_STATE_SIG,
this, SLOT (stateSignal (const QDBusMessage&)));
+ _conn_counter = 0;
requestState ();
}
void ConnectionChecker::stateSignal (const QDBusMessage& msg)
{
- if (msg.arguments ().count () == 8) {
- unsigned int status = msg.arguments ().value (7).value<unsigned int>();
+ if (msg.arguments ().count () != 8)
+ return;
- updateState (status == ICD_STATE_CONNECTED, msg.arguments ().value (3).toString ());
- }
+ unsigned int state = msg.arguments ().value (7).value<unsigned int>();
+ QString net = msg.arguments ().value (3).toString ();
+
+ if (state == ICD_STATE_CONNECTED)
+ _conn_counter++;
+ if (state == ICD_STATE_DISCONNECTED)
+ _conn_counter--;
+
+ if (state == ICD_STATE_CONNECTED || !_conn_counter)
+ updateState (state == ICD_STATE_CONNECTED, net);
}
new_net = Net_WLAN;
else if (net_type.startsWith ("GPRS") || net_type.startsWith ("DUN_GSM"))
new_net = Net_GSM;
- if (new_net != _net_type) {
- _net_type = new_net;
- type_changed (_net_type);
- }
+ }
+
+ if (new_net != _net_type) {
+ _net_type = new_net;
+ type_changed (_net_type);
}
}