DBus communication working

This commit is contained in:
Albert Vaca 2013-06-25 21:19:17 +02:00
parent df12667f10
commit 800de8836f
6 changed files with 98 additions and 17 deletions

View file

@ -24,6 +24,7 @@
#include "packagereceivers/pausemusicpackagereceiver.h"
#include "announcers/avahiannouncer.h"
#include "announcers/fakeannouncer.h"
#include "devicelinks/echodevicelink.h"
#include <QtNetwork/QUdpSocket>
#include <QFile>
@ -38,7 +39,8 @@
K_PLUGIN_FACTORY(AndroidShineFactory, registerPlugin<Daemon>();)
K_EXPORT_PLUGIN(AndroidShineFactory("androidshine", "androidshine"))
void Daemon::linkTo(DeviceLink* dl) {
void Daemon::linkTo(DeviceLink* dl)
{
linkedDevices.append(dl);
@ -86,8 +88,6 @@ QString Daemon::listVisibleDevices()
ret << std::setw(20) << "Name";
ret << std::endl;
emit deviceAdded("hola","hola");
Q_FOREACH (Device* d, visibleDevices) {
ret << std::setw(20) << d->id().toStdString();
ret << std::setw(20) << d->name().toStdString();
@ -101,6 +101,7 @@ QString Daemon::listVisibleDevices()
bool Daemon::pairDevice(QString id)
{
//TODO
linkedDevices.append(new EchoDeviceLink(new Device(id,"fake-to-the-max")));
return true;
}
@ -109,7 +110,9 @@ QString Daemon::listLinkedDevices()
QString ret;
Q_FOREACH (DeviceLink* dl, linkedDevices) {
ret += dl->device()->name() + "(" + dl->device()->id() + ")";
if (!ret.isEmpty()) ret += "\n";
//ret += dl->device()->name() + "(" + dl->device()->id() + ")";
ret += dl->device()->id();
}
return ret;

View file

@ -1,6 +1,7 @@
set(kcm_SRCS
kcm.cpp
wizard.cpp
)
qt4_add_dbus_interface(

View file

@ -20,6 +20,7 @@
#include "kcm.h"
#include "ui_kcm.h"
#include "ui_wizard.h"
#include <QtGui/QLabel>
#include <QtGui/QMenu>
@ -39,7 +40,8 @@ K_EXPORT_PLUGIN(KdeConnectKcmFactory("kdeconnect-kcm", "kdeconnect-kcm"))
KdeConnectKcm::KdeConnectKcm(QWidget *parent, const QVariantList&)
: KCModule(KdeConnectKcmFactory::componentData(), parent)
, dbusInterface("org.kde.kded", "/modules/androidshine", QDBusConnection::sessionBus(), this)
, dbusInterface("org.kde.kdeconnect", "/modules/androidshine", QDBusConnection::sessionBus(), this)
, wizard(this)
{
m_ui = new Ui::KdeConnectKcmUi();
@ -48,18 +50,11 @@ KdeConnectKcm::KdeConnectKcm(QWidget *parent, const QVariantList&)
m_model = new QStandardItemModel(this);
m_ui->deviceList->setIconSize(QSize(32,32));
m_ui->deviceList->setModel(m_model);
//m_ui->deviceList->setSelectionModel(m_selectionModel);
connect(&dbusInterface, SIGNAL(deviceAdded(QString, QString)), this, SLOT(deviceAdded(QString)));
connect(&dbusInterface, SIGNAL(deviceRemoved(QString, QString)), this, SLOT(deviceRemoved(QString)));
// dbusInterface.pairDevice("holalala");
//TODO: Listen to the objectManager signals objectAdded and objectRemoved, que el daemon exportara
//dbusInterface = new QDBusInterface("com.hal.wlan", "/com/hal/wlan/com/hal/wlan", "com.hal.wlan", QDBusConnection::SessionBus(), this);
//dbusInterface->connection().connect("com.hal.wlan", "/com/hal/wlan/com/hal/wlan", "com.hal.wlan", "status_changed", this, SLOT(deviceAdded())
//m_selectionModel = new QItemSelectionModel(m_model);
//connect(m_selectionModel, SIGNAL(currentChanged(QModelIndex,QModelIndex)), SLOT(currentChanged(QModelIndex,QModelIndex)));
//m_selectionModel->setCurrentIndex(m_model->index(0), QItemSelectionModel::SelectCurrent);
connect(&dbusInterface, SIGNAL(deviceAdded(QString, QString)), this, SLOT(deviceAdded(QString, QString)));
connect(&dbusInterface, SIGNAL(deviceRemoved(QString)), this, SLOT(deviceRemoved(QString)));
connect(m_ui->removeButton, SIGNAL(clicked(bool)), this, SLOT(removeButtonClicked()));
connect(m_ui->addButton, SIGNAL(clicked(bool)), this, SLOT(addButtonClicked()));
@ -73,7 +68,7 @@ KdeConnectKcm::~KdeConnectKcm()
void KdeConnectKcm::addButtonClicked()
{
m_model->appendRow(new QStandardItem("lalal"));
}
void KdeConnectKcm::removeButtonClicked()
@ -88,7 +83,8 @@ void KdeConnectKcm::currentChanged(const QModelIndex& current, const QModelIndex
void KdeConnectKcm::deviceAdded(QString id, QString name) //TODO: Rebre mes coses...
{
m_model->appendRow(new QStandardItem("hola"));
//m_model->appendRow(new QStandardItem(id));
wizard.show();
}
void KdeConnectKcm::deviceRemoved(QString id)

View file

@ -26,6 +26,7 @@
#include <kcmodule.h>
#include "wizard.h"
#include "daemoninterface.h"
class Create;
@ -59,6 +60,7 @@ private:
OrgKdeKdeconnectInterface dbusInterface;
Ui::KdeConnectKcmUi* m_ui;
QStandardItemModel* m_model;
AddDeviceWizard wizard;
};

40
kcm/wizard.cpp Normal file
View file

@ -0,0 +1,40 @@
/*
* Copyright 2013 Albert Vaca <albertvaka@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "wizard.h"
#include <QDebug>
#include "ui_wizard.h"
AddDeviceWizard::AddDeviceWizard(QWidget* parent)
: QWizard(parent)
{
qDebug() << "HA";
m_wizard = new Ui::Wizard();
m_wizard->setupUi(this);
}
AddDeviceWizard::~AddDeviceWizard()
{
delete m_wizard;
}

39
kcm/wizard.h Normal file
View file

@ -0,0 +1,39 @@
/*
* Copyright 2013 Albert Vaca <albertvaka@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef WIZARD_H
#define WIZARD_H
#include <QWizard>
namespace Ui {
class Wizard;
}
class AddDeviceWizard : public QWizard
{
public:
AddDeviceWizard(QWidget* parent);
~AddDeviceWizard();
private:
Ui::Wizard* m_wizard;
};
#endif // WIZARD_H