QtMobility bearer management - qt

I'm creating a Qt Symbian application and need to connect to internet. In some way I need to let the user choose a connection ONCE when the app starts or use the DEFAULT connection if that is enabled.
Before I just used qt_SetDefaultIap() to set the connection on start. It worked perfect but now I need to use QtMobility instead. I have tried the following in QMainWindow when my app starts:
QNetworkConfigurationManager manager;
const bool selectIap = (manager.capabilities()& QNetworkConfigurationManager::CanStartAndStopInterfaces);
QNetworkConfiguration defaultIap = manager.defaultConfiguration();
if(!defaultIap.isValid() && (!selectIap && defaultIap.state() != QNetworkConfiguration::Active))
{
// let the user know that there is no access point available
}
session = new QNetworkSession(defaultIap,this);
session->open();
But there must be something I'm missing as the application always asks the user to choose connection each time it uses internet not just once as I want. And even if I choose a connection the application asks three times. EDIT: It works on Nokia 5800 but not on N97.
This seems to be a problem for many people as it has been discussed before:
http://discussion.forum.nokia.com/forum/showthread.php?196396-how-to-use-QNetworkConfigurationManager-to-handle-access-point
http://discussion.forum.nokia.com/forum/showthread.php?199401-How-to-use-bearer-management-to-select-access-point
http://discussion.forum.nokia.com/forum/showthread.php?199472-How-can-I-set-the-best-one-access-point-as-default
Any ideas on how to get this working?

if your phone settings are set as 'Always ask' in (5800) Menu -> Settings -> Destinations -> Options -> Default connection, then QNetworkConfigurationManager.defaultConfiguration() will return the UserChoice configuration, which will always popup a query.
If you wish to control which access point is really used, then you could enumerate/list the configurations (QNetworkConfigurationManager::allConfigurations(), choose the one you want, and then create a QNetworkSession based on it and call QNetworkSession::open(). After that if you instantiate and use e.g. QNetworkAccessManager to perform web queries, they should use that configuration "automatically".

Related

No such interface 'org.freedesktop.DBus.Properties' on object at path /org/freedesktop/NetworkManager/ActiveConnection/

I start my qt application in the user's .profile file (not root) to make the app start on boot. Sometimes when my application start, it reports an warning as below:
"No such interface 'org.freedesktop.DBus.Properties' on object at path /org/freedesktop/NetworkManager/ActiveConnection/1"
I searched on google but did not find a explanation.
It seems my app is still working fine, but I want to locate the problem.
The application is running on ubuntu and using Qt5.
Thanks in advance.
Edit
I tried to debug dbus based on Eligijus Pupeikis's help with running:
gdbus introspect --system \
--dest org.freedesktop.NetworkManager \
--object-path /org/freedesktop/NetworkManager/ActiveConnection
it returns:
node /org/freedesktop/NetworkManager/ActiveConnection {
node 0 {
};
};
So, this means there is no such object just as the error message said, right?
And also, this gns3 team member says this problem is about Qt and Ubuntu.
Does this mean I don't need to solve it? I not familiar with the relationship between dbus and qt.
Most likely there is no such object "/org/freedesktop/NetworkManager/ActiveConnection/1" and because of that it can't find 'org.freedesktop.DBus.Properties' interface.
From documentation org.freedesktop.NetworkManager.Connection.Active :
Objects that implement the Connection.Active interface represent an attempt to connect to a network using the details provided by a Connection object. The Connection.Active object tracks the life-cycle of the connection attempt and if successful indicates whether the connected network is the "default" or preferred network for access. NetworkManager has the concept of connections, which can be thought of as settings, a profile or a configuration that can be applied on a networking device. Such settings-connections are exposed as D-Bus object and the active-connection expresses this relationship between device and settings-connection. At any time a settings-connection can only be activated on one device and vice versa. However, during activation and deactivation multiple active-connections can reference the same device or settings-connection as they are waiting to be activated or to be deactivated.
You can't know that that ActiveConnection object with specifically index 1 exists so you need to check by reading ActiveConnections property from /org/freedesktop/NetworkManager object's org.freedesktop.NetworkManager interface.
To have better visualize and understand how it looks I suggest D-Bus debugger. If you are using Gnome check out D-Feet.

Guidelines for robust synchronisation of mobile client (iOS, Swift) with Realm Object Server

I have used the techniques in the RealmTask tutorial (https://realm.io/docs/tutorials/realmtasks/ ) to get a demonstration of synchronisation with the Realm Object Server working. However, as mentioned in realm mobile platform, how to connect while offline? , it is difficult to find design guidelines on realising a robust app in the presence of intermittent network connectivity. For example, the network might not be available when the app is first run, and in the tutorial example I think the login attempt would just time out after say 30 seconds.
From various sources, I have tried to outline an implementation approach on the client and have come up with the following:
=============================================================
At start-up of app
Create login credentials with
SyncCredentials.usernamePassword()
Check whether user credentials already exist using
SyncUser.all
If so, get the correct user using the appropriate key (UserId)
If a user is obtained, get the Realm configuration using
realmConfiguration = Realm.Configuration(SyncConfiguration(user, realmURL))
Attempt a log-in with
SyncUser.logIn with SyncCredentials
On completion, put the following on the main DispatchQueue (async)
realmConfiguration = Realm.Configuration(SyncConfiguration(user, realmURL))
if not logged in, repeat login attempts every N minutes until successful? E.g. to handle the situation when the network is unavailable when the app is started, but then becomes available?
Launch the rest of the app, making realmConfiguration available.
However, only access the Realm if realmConfiguration has been set up. Design the app so that it handles the scenario of realmConfiguration not being set up.
=============================================================
Is the above approach sensible, or is there a better solution?
Katsumi from Realm here. Our RealmTasks demo application may help you.
https://github.com/realm-demos/realm-tasks/tree/master/RealmTasks%20Apple
First, check whether the user has logged in or not at launched the app.
if configureDefaultRealm() {
window?.rootViewController = ContainerViewController()
window?.makeKeyAndVisible()
} else {
window?.rootViewController = UIViewController()
window?.makeKeyAndVisible()
logIn(animated: false)
}
https://github.com/realm-demos/realm-tasks/blob/master/RealmTasks%20Apple/RealmTasks%20iOS/AppDelegate.swift#L35
If the user has been logged in before, you can use user object that was cached before. (SyncUser.current or SyncUser.all)
If there is no cached user object (The user is the first time to use the app, or the user re-installs the app), show login view to signing up/in.
The former case (Use the cached user object) doesn't require network access, so you don't need to care about the offline situation.
The latter case (The user should signing up/in) requires network access, in that case, the best practice depends on the specification of the app. It is enough to show a just alert view that indicates requiring network for some apps, or use standalone Realm and then migrate synced realm after the app will be online.

Is there an equivalent of DeviceNetworkInformation.NetworkAvailabilityChanged event on UWP?

I'm converting my Windows Phone 8 Silverlight to UWP and I can't find an equivalent to DeviceNetworkInformation.NetworkAvailabilityChanged event in UWP
I know that on UWP we have to use ConnectionProfile to get info about user's connection (Wifi, 3G, etc...)
ConnectionProfile InternetConnectionProfile = NetworkInformation.GetInternetConnectionProfile();
But it seems that there are no events to check if the Internet becomes unavailable in ConnectionProfile object.
Does anyone know how to do this in UWP?
Thanks
There might be no equivalent of DeviceNetworkInformation.NetworkAvailabilityChanged Event in UWP APIs by now. But we can achieve this by combining NetworkInformation.NetworkStatusChanged event with ConnectionProfile.GetNetworkConnectivityLevel method.
Ref Remarks in ConnectionProfile.GetNetworkConnectivityLevel:
The recommended process for determining the network connectivity level is to register a handler for the NetworkStatusChanged event on the NetworkInformation class. When a notification is received of a network status change, obtain the new connectivity level by calling the GetNetworkConnectivityLevel method on the profile returned by the GetInternetConnectionProfile method. The returned network connectivity level can then be stored for later use when needed. This also ensures that the correct ConnectionProfile is checked.
Following is a simple sample:
NetworkInformation.NetworkStatusChanged += (s) =>
{
var profile = NetworkInformation.GetInternetConnectionProfile();
var isInternetConnected = profile != null && profile.GetNetworkConnectivityLevel() == NetworkConnectivityLevel.InternetAccess;
};
Also you can encapsulate this into an event like in this blog: How to react to network availability changes in Windows Store apps.

Creating an Asterisk "application" to send GET requests from an endpoint via Phone Prompt

To start off, I'd like to state that this is my first dive into Asterisk related applications, and that I'm mostly a web developer.
My workplace uses an MSP that installed Asterisk/FreePBX to manage our phone systems. The GUI is pretty intuitive and after reading and getting a bit lost I figured I'd come here and see how to go about setting this up.
I was tasked with building a simple application to reset user passwords through both a web interface (completed) and a phone interface - by dialing a number, dialing their ID card #, and then having their password reset. I'm a Systems Administrator and have access to all necessary applications, servers, etc. I can pick things up fairly easy and I was told I'd have enough time to figure this out and get it done.
This is what I need in terms of pseudocode when the user calls a specific extension:
recording('pwResetCardID'); // Play a "Please enter your ID # to reset PW" greeting.
function getCardID() {
cardID = input(); // Input 4-5 digits using the dialpad and save it to a var.
verify = get('http://some.site/endpoint/cardid/'.$cardid); // Send a GET request.
if verify { // If we got a successful response (200)
recording('pwChanged'); // Tell the user their password has changed
} else { //
recording('errorCardID'); // Otherwise tell them to try again
getCardID(); // Recur the function.
}
}
getCardID();
If the cardID is valid, their PW is changed on the other end of my node.js application, and I simply need the GET request to be sent out and the user notified of the success (or failure)
You can start from doc describing asterisk dialplan
Probably need use func_CURL, Read application, Playbavk and Goto
You need put new dialplan in extensions_custom.conf and setup use it via custom apps module

setting static IP for wifi connection in QT

I am trying to create a QT based application that scan and connect WiFi networks. I am using this example as a reference code.
Is it possible to assign static IP for the WiFi connection using QNetworkConfiguration or any related class ?
How to authenticate the networks that are password protected ?
thanks in advance......
I have created a net work session using the below code set..
void BearerMonitor::createNewSessionFromQml(QString ssid)
{
QList<QNetworkConfiguration> allConfigurations = manager.allConfigurations();
while (!allConfigurations.isEmpty()) {
QNetworkConfiguration config = allConfigurations.takeFirst();
if(config.name()==ssid)
createSessionFor(config);
}
}
SessionWidget::SessionWidget(const QNetworkConfiguration &config, QObject *parent):QObject(parent)
{
session = new QNetworkSession(config, this);
session->open();
}
No you can't. At least not with just Qt APIs.
Please read this and in particular this. QNetworkConfiguration is just a facility to manage network configurations. Editing such configurations is demanded to native code / OS interactions. From the second link:
Note that the QNetworkConfiguration object only provides limited information about the configuration details themselves. It's main purpose is to act as a configuration identifier through which link layer connections can be created, destroyed and monitored.
Even the "start/stop network interfaces" claim is not entirely true since such a feature is available only in certain OSs (not the mobile ones). See the "Platform capabilities" section of the second link for more details about that.
The same reasoning applies to the password question. Once a network is registed in the OS with the corresponding password (because of native code or the user physically registering it) a new configuration is available to the NetworkConfigurationManager, granted that the list of configurations is updated via updateConfigurations(). The new configuration contains the password but you can't edit it from Qt APIs.
Native code is the only solution, as said. Still, Apple does not want you to mess up with WiFi programatically since private APIs for that cannot be used in iOS > 5.1 (the oldest version supported by Qt as for Qt 5.4).

Resources