From 800de8836f5bccf9fb274b78006ed3c4e8eeac7e Mon Sep 17 00:00:00 2001 From: Albert Vaca Date: Tue, 25 Jun 2013 21:19:17 +0200 Subject: [PATCH] DBus communication working --- daemon/daemon.cpp | 11 +++++++---- kcm/CMakeLists.txt | 1 + kcm/kcm.cpp | 22 +++++++++------------- kcm/kcm.h | 2 ++ kcm/wizard.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ kcm/wizard.h | 39 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 98 insertions(+), 17 deletions(-) create mode 100644 kcm/wizard.cpp create mode 100644 kcm/wizard.h diff --git a/daemon/daemon.cpp b/daemon/daemon.cpp index f2c1215f9..f443f6e1b 100644 --- a/daemon/daemon.cpp +++ b/daemon/daemon.cpp @@ -24,6 +24,7 @@ #include "packagereceivers/pausemusicpackagereceiver.h" #include "announcers/avahiannouncer.h" #include "announcers/fakeannouncer.h" +#include "devicelinks/echodevicelink.h" #include #include @@ -38,7 +39,8 @@ K_PLUGIN_FACTORY(AndroidShineFactory, registerPlugin();) 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; diff --git a/kcm/CMakeLists.txt b/kcm/CMakeLists.txt index ceaa39612..58c02c65c 100644 --- a/kcm/CMakeLists.txt +++ b/kcm/CMakeLists.txt @@ -1,6 +1,7 @@ set(kcm_SRCS kcm.cpp + wizard.cpp ) qt4_add_dbus_interface( diff --git a/kcm/kcm.cpp b/kcm/kcm.cpp index 01f8ccf76..39310708a 100644 --- a/kcm/kcm.cpp +++ b/kcm/kcm.cpp @@ -20,6 +20,7 @@ #include "kcm.h" #include "ui_kcm.h" +#include "ui_wizard.h" #include #include @@ -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) diff --git a/kcm/kcm.h b/kcm/kcm.h index c99b0087e..85818b4d0 100644 --- a/kcm/kcm.h +++ b/kcm/kcm.h @@ -26,6 +26,7 @@ #include +#include "wizard.h" #include "daemoninterface.h" class Create; @@ -59,6 +60,7 @@ private: OrgKdeKdeconnectInterface dbusInterface; Ui::KdeConnectKcmUi* m_ui; QStandardItemModel* m_model; + AddDeviceWizard wizard; }; diff --git a/kcm/wizard.cpp b/kcm/wizard.cpp new file mode 100644 index 000000000..ef222c9b0 --- /dev/null +++ b/kcm/wizard.cpp @@ -0,0 +1,40 @@ +/* + * Copyright 2013 Albert Vaca + * + * 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 . + */ + +#include "wizard.h" + +#include + +#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; +} diff --git a/kcm/wizard.h b/kcm/wizard.h new file mode 100644 index 000000000..ccd44aade --- /dev/null +++ b/kcm/wizard.h @@ -0,0 +1,39 @@ +/* + * Copyright 2013 Albert Vaca + * + * 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 . + */ + +#ifndef WIZARD_H +#define WIZARD_H + +#include + +namespace Ui { + class Wizard; +} + +class AddDeviceWizard : public QWizard +{ +public: + AddDeviceWizard(QWidget* parent); + ~AddDeviceWizard(); +private: + Ui::Wizard* m_wizard; +}; + +#endif // WIZARD_H