|
2010-04-08
, 01:08
|
Posts: 1,048 |
Thanked: 979 times |
Joined on Mar 2008
@ SF Bay Area
|
#2
|
|
2010-04-08
, 05:52
|
|
Posts: 754 |
Thanked: 630 times |
Joined on Sep 2009
@ London
|
#3
|
The Following 4 Users Say Thank You to krk969 For This Useful Post: | ||
|
2010-04-08
, 12:12
|
Posts: 17 |
Thanked: 42 times |
Joined on Feb 2010
|
#4
|
void retry() { QNetworkInterface wlan = QNetworkInterface::interfaceFromName("wlan0"); QNetworkInterface gprs = QNetworkInterface::interfaceFromName("gprs0"); if( (wlan.isValid() && wlan.flags().testFlag(QNetworkInterface::IsUp)) || (gprs.isValid() && gprs.flags().testFlag(QNetworkInterface::IsUp)) ) { qDebug() << "Connection found."; } else { qDebug() << "No connection found on retry, retrying again"; QTimer::singleShot(500, this, SLOT(retry())); } }
|
2010-10-04
, 06:02
|
Posts: 27 |
Thanked: 8 times |
Joined on Jan 2009
@ Singapore
|
#5
|
Thanks for the ideas guys,
I checked QTcpSocket, but this opens the connections window (as I suppose it should really).
krk969; rather than make a connection, what I want to achieve is to check whether there currently is a connection. Initially, I can just fire off a QNetworkRequest; if there is a connection, I'll get some data, if not, I can find out through the appropriate error. If there is no such connection, what I want to do is to silently poll to wait for a connection.
After some digging, what I've found is, until bearer management is implemented for Maemo/MeeGo, QNetworkInterface can be used. The N900 can be connected by either gprs or wlan. So what I do:
This works well; the only issue it does suffer from is that if the N900 is connected via usb in PC suite mode, wlan0 reports that it is connected even if not connected to a wifi network (I guess this is because I'm using mad developer tools with USB mode g_ether). In such a state, it's therefore not possible to really detect whether the wifi is really connected, but this can be handled by the error messages given by QNetworkReply.Code:void retry() { QNetworkInterface wlan = QNetworkInterface::interfaceFromName("wlan0"); QNetworkInterface gprs = QNetworkInterface::interfaceFromName("gprs0"); if( (wlan.isValid() && wlan.flags().testFlag(QNetworkInterface::IsUp)) || (gprs.isValid() && gprs.flags().testFlag(QNetworkInterface::IsUp)) ) { qDebug() << "Connection found."; } else { qDebug() << "No connection found on retry, retrying again"; QTimer::singleShot(500, this, SLOT(retry())); } }
|
2010-10-08
, 08:20
|
Posts: 34 |
Thanked: 32 times |
Joined on May 2010
@ Hamilton, New Zealand
|
#6
|
|
2010-10-08
, 09:56
|
Posts: 16 |
Thanked: 18 times |
Joined on Sep 2010
|
#7
|
I'm using a QNetworkAccessManager object to fire off GET requests, however I find that if the device does not have a network connection it automatically connects to my 3G provider. What I'd like is to have it pop up the standard internet connection selection window to allow the user to select the internet access point to use.
#include <icd/dbus_api.h>
static QDBusConnection dBusConnection = QDBusConnection::systemBus();
ICD::ICD(QObject *parent)
: QObject(parent)
{
QDBusInterface *dBusInterface = new QDBusInterface(ICD_DBUS_API_INTERFACE, ICD_DBUS_API_PATH,
ICD_DBUS_API_INTERFACE, dBusConnection);
//From dbus_api.h: Request the 'Select connection' dialog;
//Only connectiviy UIs should be using this function.
dBusInterface->call(ICD_DBUS_API_SELECT_REQ,
QVariant((unsigned int)ICD_CONNECTION_FLAG_USER_EVENT));
}
The Following User Says Thank You to laitiju For This Useful Post: | ||
|
2010-10-08
, 10:51
|
Posts: 34 |
Thanked: 32 times |
Joined on May 2010
@ Hamilton, New Zealand
|
#8
|
This depends on user settings. If the user has disabled the connect automatically, then the dialog is shown.
|
2010-10-11
, 08:36
|
Posts: 27 |
Thanked: 8 times |
Joined on Jan 2009
@ Singapore
|
#9
|
I'm using QNetworkManager to make some requests over the internet. My problem is that I don't seem to have the tools to let me work out the connectivity of the device.
For example, if I have a QNetworkManager object called manager, and I call
manager->post(request, requestData);
If the user has connection to the internet, everything is fine. If not, then what will happen is that an error will be generated, which I can handle, and the connection window will popup, allowing the user to choose a connection.
What I'd like to do is to poll to see if the user is connected somehow. I can do this by retrying the request, because this would re-open the connection window (spamming the user with it while, for example, the device is establishing the connection the user previously selected).
Any ideas?
Stewart