Commit 668d7395 authored by Lorn Potter's avatar Lorn Potter

update to fix these and make things work better

parent 21ba09e5
......@@ -2,7 +2,7 @@
<node>
<interface name="com.jolla.Connectiond">
<signal name="connectionRequest"/>
<signal name="configurationNeeded"/>
<signal name="wlanConfigurationNeeded"/>
<signal name="errorReported">
<arg direction="out" type="s" name="error"/>
</signal>
......@@ -15,6 +15,9 @@
<arg direction="out" type="a{sv}" name="fields"/>
<annotation value="QVariantMap" name="org.qtproject.QtDBus.QtTypeName.In1"/>
</signal>
<signal name="connectionState">
<arg direction="out" type="s" name="state"/>
</signal>
<method name="sendConnectReply">
<arg direction="in" type="s" name="in0"/>
<arg direction="in" type="i" name="in1"/>
......
......@@ -9,8 +9,8 @@
* before re-generating it.
*/
#ifndef CONNADAPTOR_H_1363743442
#define CONNADAPTOR_H_1363743442
#ifndef CONNADAPTOR_H_1363752885
#define CONNADAPTOR_H_1363752885
#include <QtCore/QObject>
#include <QtDBus/QtDBus>
......@@ -44,6 +44,9 @@ class ConnAdaptor: public QDBusAbstractAdaptor
" <arg direction=\"out\" type=\"a{sv}\" name=\"fields\"/>\n"
" <annotation value=\"QVariantMap\" name=\"org.qtproject.QtDBus.QtTypeName.In1\"/>\n"
" </signal>\n"
" <signal name=\"connectionState\">\n"
" <arg direction=\"out\" type=\"s\" name=\"state\"/>\n"
" </signal>\n"
" <method name=\"sendConnectReply\">\n"
" <arg direction=\"in\" type=\"s\" name=\"in0\"/>\n"
" <arg direction=\"in\" type=\"i\" name=\"in1\"/>\n"
......@@ -68,6 +71,7 @@ public Q_SLOTS: // METHODS
void sendUserReply(const QVariantMap &input);
Q_SIGNALS: // SIGNALS
void connectionRequest();
void connectionState(const QString &state);
void errorReported(const QString &error);
void requestBrowser(const QString &url);
void userInputCanceled();
......
......@@ -13,6 +13,7 @@ QT -= gui
INCLUDEPATH += libconnman-qt
#INCLUDEPATH += lipstick
OTHER_FILES += com.jolla.Connectiond.xml
......@@ -29,7 +30,7 @@ HEADERS+= \
connadaptor.h
LIBS += -lconnman-qt4
# LIBS += -llipstick
#LIBS += -llipstick
target.path = /usr/bin
INSTALLS += target
......
......@@ -36,9 +36,11 @@ QConnectionManager* QConnectionManager::self = NULL;
QConnectionManager::QConnectionManager(QObject *parent) :
QObject(parent),
netman(NetworkManagerFactory::createInstance()),
netService(0),
okToConnect(0),
currentNetworkState(QString()),
currentType(QString())
currentType(QString()),
serviceConnect(0)
{
connectionAdaptor = new ConnAdaptor(this);
QDBusConnection dbus = QDBusConnection::sessionBus();
......@@ -99,6 +101,7 @@ void QConnectionManager::onUserInputCanceled()
// from useragent
void QConnectionManager::onErrorReported(const QString &error)
{
qDebug() << Q_FUNC_INFO << error;
Q_EMIT errorReported(error);
}
......@@ -107,8 +110,6 @@ void QConnectionManager::onConnectionRequest()
{
qDebug() << Q_FUNC_INFO;
if (!autoConnect()) {
qDebug() << Q_FUNC_INFO << "emit connectionRequest";
Q_EMIT connectionRequest();
}
}
......@@ -125,31 +126,30 @@ void QConnectionManager::sendConnectReply(const QString &in0, int in1)
void QConnectionManager::sendUserReply(const QVariantMap &input)
{
qDebug() << Q_FUNC_INFO << input;
ua->sendUserReply(input);
}
void QConnectionManager::networkStateChanged(const QString &state)
{
if (serviceConnect)
return;
QString msg;
if (currentNetworkState == "idle" && state == "association") {
if (currentNetworkState == "idle" && state == "ready") {
msg = "Connecting...";
} else if (currentNetworkState == "ready" && state == "online") {
msg = "Connected";
} else if (state == "offline") {
msg = "Offline";
} else if (state == "idle") {
msg = "Disconnected";
}
qDebug() << Q_FUNC_INFO << currentNetworkState << state << msg;
Q_EMIT connectionState(msg);
// NotificationManager *manager = NotificationManager::instance();
// QVariantHash hints;
// hints.insert(NotificationManager::HINT_URGENCY, 2);
// hints.insert(NotificationManager::HINT_CATEGORY, "device.error");
// hints.insert(NotificationManager::HINT_PREVIEW_BODY, msg);
// manager->Notify(qApp->applicationName(), 0, QString(), QString(), QString(), QStringList(), hints, -1);
// if (!msg.isEmpty()) {
// emit serviceStateChanged(msg);
// }
// if (!msg.isEmpty()) {
// emit serviceStateChanged(msg);
// }
currentNetworkState = state;
}
......@@ -157,14 +157,19 @@ void QConnectionManager::onServiceAdded(const QString &servicePath)
{
// qDebug() << Q_FUNC_INFO << servicePath;
if (okToConnect) {
NetworkService *netService;
if (netService) {
delete netService;
netService = 0;
}
netService = new NetworkService(this);
netService->setPath(servicePath);
if (netService->favorite()) {
serviceConnect = true;
QObject::connect(netService, SIGNAL(stateChanged(QString)),
this,SLOT(stateChanged(QString)));
this,SLOT(stateChanged(QString)), Qt::UniqueConnection);
QObject::connect(netService, SIGNAL(connectRequestFailed(QString)),
this,SLOT(serviceErrorChanged(QString)));
this,SLOT(serviceErrorChanged(QString)), Qt::UniqueConnection);
netService->requestConnect();
}
}
......@@ -173,38 +178,29 @@ void QConnectionManager::onServiceAdded(const QString &servicePath)
void QConnectionManager::serviceErrorChanged(const QString &error)
{
qDebug() << Q_FUNC_INFO << error;
// NotificationManager *manager = NotificationManager::instance();
// QVariantHash hints;
// hints.insert(NotificationManager::HINT_URGENCY, 1);
// hints.insert(NotificationManager::HINT_CATEGORY, "device.error");
// hints.insert(NotificationManager::HINT_PREVIEW_BODY, error);
// manager->Notify(qApp->applicationName(), 0, QString(), QString(), QString(), QStringList(), hints, -1);
Q_EMIT errorReported(error);
}
void QConnectionManager::stateChanged(const QString &state)
{
Q_UNUSED(state)
// QString msg;
// if (currentNetworkState == "idle" && state == "association") {
// msg = "Connecting...";
// } else if (currentNetworkState == "ready" && state == "online") {
// msg = "Connected";
// } else if (state == "offline") {
// msg = "Offline";
// }
// qDebug() << Q_FUNC_INFO << currentNetworkState << state << msg;
//// NotificationManager *manager = NotificationManager::instance();
//// QVariantHash hints;
//// hints.insert(NotificationManager::HINT_URGENCY, 2);
//// hints.insert(NotificationManager::HINT_CATEGORY, "device.error");
//// hints.insert(NotificationManager::HINT_PREVIEW_BODY, msg);
//// manager->Notify(qApp->applicationName(), 0, QString(), QString(), QString(), QStringList(), hints, -1);
QString msg;
if ((currentNetworkState == "idle" && state == "association")
|| (currentNetworkState == "association" && state == "configuration")
|| (currentNetworkState == "configuration" && state == "ready")) {
msg = "Connecting...";
} else if (currentNetworkState == "ready" && state == "online") {
msg = "Connected";
serviceConnect = false;
} else if (state == "offline") {
msg = "Offline";
}
qDebug() << Q_FUNC_INFO << currentNetworkState << state << msg;
Q_EMIT connectionState(msg);
// if (!msg.isEmpty()) {
// emit serviceStateChanged(msg);
// }
// currentNetworkState = state;
currentNetworkState = state;
}
bool QConnectionManager::autoConnect()
......@@ -216,20 +212,17 @@ bool QConnectionManager::autoConnect()
Q_FOREACH (NetworkService *service, serviceList) {
if(service->autoConnect() && service->favorite()) {
serviceConnect = true;
QObject::connect(service, SIGNAL(stateChanged(QString)),
this,SLOT(stateChanged(QString)));
this,SLOT(stateChanged(QString)), Qt::UniqueConnection);
QObject::connect(service, SIGNAL(connectRequestFailed(QString)),
this,SLOT(serviceErrorChanged(QString)));
this,SLOT(serviceErrorChanged(QString)), Qt::UniqueConnection);
service->requestConnect();
qDebug() << Q_FUNC_INFO << true;
return true;
}
}
}
qDebug() << Q_FUNC_INFO << false;
return false;
}
......@@ -246,7 +239,8 @@ void QConnectionManager::connectToType(const QString &type)
netTech.setPowered(true);
}
QStringList servicesList = netman->servicesList(type);
qDebug() << servicesList;
qDebug() << servicesList;
if (servicesList.isEmpty()) {
if (type == "wifi") {
......@@ -256,7 +250,10 @@ qDebug() << servicesList;
onScanFinished();
}
} else {
NetworkService *netService;
if (netService) {
delete netService;
netService = 0;
}
netService = new NetworkService(this);
bool needConfig = false;
Q_FOREACH (const QString path, servicesList) {
......@@ -266,16 +263,15 @@ qDebug() << servicesList;
if (netService->favorite()) {
qDebug() << "power on, fav";
needConfig = false;
serviceConnect = true;
QObject::connect(netService, SIGNAL(stateChanged(QString)),
this,SLOT(stateChanged(QString)));
this,SLOT(stateChanged(QString)), Qt::UniqueConnection);
QObject::connect(netService, SIGNAL(connectRequestFailed(QString)),
this,SLOT(serviceErrorChanged(QString)));
this,SLOT(serviceErrorChanged(QString)), Qt::UniqueConnection);
qDebug() << Q_FUNC_INFO << "just connect to this thing";
//window->rootContext()->setContextProperty("connecting", QVariant(true));
// NetworkTechnology *tech = netman->getTechnology(netService->type());
// tech->setIdleTimeout(120);
......
......@@ -29,6 +29,7 @@ class SessionAgent;
class ConnAdaptor;
class NetworkManager;
class NetworkService;
class QConnectionManager : public QObject
{
......@@ -48,6 +49,7 @@ Q_SIGNALS:
void errorReported(const QString &error);
void connectionRequest();
void wlanConfigurationNeeded();
void connectionState(const QString &state);
public Q_SLOTS:
......@@ -77,9 +79,12 @@ private:
bool autoConnect();
NetworkManager *netman;
NetworkService *netService;
bool okToConnect;
QString currentNetworkState;
QString currentType;
bool serviceConnect;
private slots:
void onScanFinished();
......
......@@ -49,6 +49,7 @@ ConnectionAgentPlugin::~ConnectionAgentPlugin()
void ConnectionAgentPlugin::sendUserReply(const QVariantMap &input)
{
qDebug() << Q_FUNC_INFO;
QDBusPendingReply<> reply = connManagerInterface->sendUserReply(input);
if (reply.isError()) {
qDebug() << Q_FUNC_INFO << reply.error().message();
......@@ -89,6 +90,7 @@ void ConnectionAgentPlugin::onUserInputRequested(const QString &service, const Q
QVariantMap vmap = qdbus_cast<QVariantMap>(arg);
map.insert(i.key(), vmap);
}
qDebug() << Q_FUNC_INFO << map;
Q_EMIT userInputRequested(service, map);
}
......@@ -127,6 +129,9 @@ void ConnectionAgentPlugin::connectToConnectiond(QString)
connect(connManagerInterface,SIGNAL(errorReported(QString)),
this,SLOT(onErrorReported(QString)));
connect(connManagerInterface,SIGNAL(connectionState(QString)),
this,SLOT(onConnectionState(QString)));
connect(connManagerInterface,SIGNAL(requestBrowser(QString)),
this,SLOT(onRequestBrowser(QString)));
......@@ -147,3 +152,9 @@ void ConnectionAgentPlugin::onWlanConfigurationNeeded()
qDebug() << Q_FUNC_INFO;
Q_EMIT wlanConfigurationNeeded();
}
void ConnectionAgentPlugin::onConnectionState(const QString &state)
{
qDebug() << Q_FUNC_INFO << state;
Q_EMIT connectionState(state);
}
......@@ -42,6 +42,7 @@ signals:
void errorReported(const QString &error);
void connectionRequest();
void wlanConfigurationNeeded();
void connectionState(const QString &state);
private:
com::jolla::Connectiond *connManagerInterface;
......@@ -53,6 +54,7 @@ private slots:
void onUserInputRequested(const QString &service, const QVariantMap &fields);
void onConnectionRequested();
void onWlanConfigurationNeeded();
void onConnectionState(const QString &state);
void connectToConnectiond(const QString = QString());
void connectiondUnregistered(const QString = QString());
......
......@@ -6,7 +6,7 @@ CONFIG += qt plugin
uri = com.jolla.connection
#create client
system(qdbusxml2cpp ../connd/com.jolla.Connectiond.xml -c ConnectionManagerInterface -p connectionamanagerinterface)
#system(qdbusxml2cpp ../connd/com.jolla.Connectiond.xml -c ConnectionManagerInterface -p connectionamanagerinterface)
SOURCES += \
connectionagentplugin_plugin.cpp \
......
......@@ -8,8 +8,8 @@
* Do not edit! All changes made to it will be lost.
*/
#ifndef CONNECTIONAMANAGERINTERFACE_H_1363743454
#define CONNECTIONAMANAGERINTERFACE_H_1363743454
#ifndef CONNECTIONAMANAGERINTERFACE_H_1363759925
#define CONNECTIONAMANAGERINTERFACE_H_1363759925
#include <QtCore/QObject>
#include <QtCore/QByteArray>
......@@ -59,6 +59,7 @@ public Q_SLOTS: // METHODS
Q_SIGNALS: // SIGNALS
void connectionRequest();
void connectionState(const QString &state);
void errorReported(const QString &error);
void requestBrowser(const QString &url);
void userInputCanceled();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment