[SCM] kdeconnect packaging branch, master, updated. debian/0.9g-1-1183-g9d69498
Maximiliano Curia
maxy at moszumanska.debian.org
Fri Oct 14 14:26:39 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/kdeconnect.git;a=commitdiff;h=5fbd33e
The following commit has been merged in the master branch:
commit 5fbd33e8c5a57bfd97669c7976c35700c4606ac6
Author: Albert Vaca <albertvaka at gmail.com>
Date: Tue Jul 2 01:50:32 2013 +0200
Implemented communication wizard -> kcm
Renamed androidshine -> kdeconnect
---
CMakeLists.txt | 2 +-
daemon/CMakeLists.txt | 12 ++--
daemon/daemon.cpp | 9 ++-
daemon/device.cpp | 2 +-
.../{androidshine.desktop => kdeconnect.desktop} | 8 +--
.../{androidshine.notifyrc => kdeconnect.notifyrc} | 0
.../notificationpackagereceiver.cpp | 2 +-
kcm/daemondbusinterface.cpp | 2 +-
kcm/devicesmodel.cpp | 73 +++++++++++++++++-----
kcm/devicesmodel.h | 24 +++++--
kcm/kcm.cpp | 14 +++++
kcm/kcm.h | 8 ++-
kcm/wizard.cpp | 51 ++++++++++++---
kcm/wizard.h | 13 +++-
letsgo.sh | 6 +-
test/CMakeLists.txt | 8 +--
16 files changed, 177 insertions(+), 57 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index acef29b..8293e97 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,4 @@
-project(androidshine)
+project(kdeconnect)
cmake_minimum_required(VERSION 2.6)
find_package(KDE4 REQUIRED)
diff --git a/daemon/CMakeLists.txt b/daemon/CMakeLists.txt
index 70a501b..d075f8f 100644
--- a/daemon/CMakeLists.txt
+++ b/daemon/CMakeLists.txt
@@ -1,4 +1,4 @@
-set(kded_androidshine_SRCS
+set(kded_kdeconnect_SRCS
announcers/announcer.cpp
announcers/fakeannouncer.cpp
@@ -19,9 +19,9 @@ set(kded_androidshine_SRCS
${CMAKE_CURRENT_BINARY_DIR}/org.kde.kdeconnect.xml
)
-kde4_add_plugin(kded_androidshine ${kded_androidshine_SRCS})
+kde4_add_plugin(kded_kdeconnect ${kded_kdeconnect_SRCS})
-target_link_libraries(kded_androidshine
+target_link_libraries(kded_kdeconnect
${KDE4_KDECORE_LIBS}
${KDE4_KDEUI_LIBS}
kdnssd
@@ -37,6 +37,6 @@ qt4_generate_dbus_interface(
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.kde.kdeconnect.xml DESTINATION ${DBUS_INTERFACES_INSTALL_DIR})
-install(TARGETS kded_androidshine DESTINATION ${PLUGIN_INSTALL_DIR})
-install(FILES androidshine.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kded)
-install(FILES androidshine.notifyrc DESTINATION ${DATA_INSTALL_DIR}/androidshine)
+install(TARGETS kded_kdeconnect DESTINATION ${PLUGIN_INSTALL_DIR})
+install(FILES kdeconnect.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kded)
+install(FILES kdeconnect.notifyrc DESTINATION ${DATA_INSTALL_DIR}/kdeconnect)
diff --git a/daemon/daemon.cpp b/daemon/daemon.cpp
index e4a1708..d988415 100644
--- a/daemon/daemon.cpp
+++ b/daemon/daemon.cpp
@@ -36,8 +36,8 @@
#include <iomanip>
#include <iostream>
-K_PLUGIN_FACTORY(AndroidShineFactory, registerPlugin<Daemon>();)
-K_EXPORT_PLUGIN(AndroidShineFactory("androidshine", "androidshine"))
+K_PLUGIN_FACTORY(KdeConnectFactory, registerPlugin<Daemon>();)
+K_EXPORT_PLUGIN(KdeConnectFactory("kdeconnect", "kdeconnect"))
void Daemon::linkTo(DeviceLink* dl)
{
@@ -58,13 +58,17 @@ Daemon::Daemon(QObject *parent, const QList<QVariant>&)
qDebug() << "GO GO GO!";
//TODO: Do not hardcode the load of the package receivers
+ //use: https://techbase.kde.org/Development/Tutorials/Services/Plugins
packageReceivers.push_back(new NotificationPackageReceiver());
packageReceivers.push_back(new PauseMusicPackageReceiver());
//TODO: Do not hardcode the load of the device locators
+ //use: https://techbase.kde.org/Development/Tutorials/Services/Plugins
announcers.insert(new AvahiAnnouncer());
announcers.insert(new FakeAnnouncer());
+ //TODO: Add package emitters
+
//TODO: Read paired devices from config
//pairedDevices.push_back(new Device("MyAndroid","MyAndroid"));
@@ -77,7 +81,6 @@ Daemon::Daemon(QObject *parent, const QList<QVariant>&)
this,SLOT(deviceConnection(DeviceLink*)));
}
-
}
QString Daemon::listVisibleDevices()
diff --git a/daemon/device.cpp b/daemon/device.cpp
index 30d8cda..6850a80 100644
--- a/daemon/device.cpp
+++ b/daemon/device.cpp
@@ -3,6 +3,6 @@
Device::Device(const QString& id, const QString& name) {
mDeviceId = id;
mDeviceName = name;
- QDBusConnection::sessionBus().registerObject("module/androidshine/Devices/"+id, this);
+ QDBusConnection::sessionBus().registerObject("module/kdeconnect/Devices/"+id, this);
}
diff --git a/daemon/androidshine.desktop b/daemon/kdeconnect.desktop
similarity index 60%
rename from daemon/androidshine.desktop
rename to daemon/kdeconnect.desktop
index 985c5f0..b8610c6 100644
--- a/daemon/androidshine.desktop
+++ b/daemon/kdeconnect.desktop
@@ -2,12 +2,12 @@
Type=Service
Icon=preferences-system-power-management
X-KDE-ServiceTypes=KDEDModule
-X-KDE-Library=androidshine
-X-KDE-DBus-ModuleName=androidshine
+X-KDE-Library=kdeconnect
+X-KDE-DBus-ModuleName=kdeconnect
X-KDE-Kded-autoload=true
X-KDE-Kded-load-on-demand=false
X-KDE-Kded-phase=1
-Name=Android shine
+Name=KDE Connect
-Comment=Android shiny backend
+Comment=Connect KDE with your smartphone
diff --git a/daemon/androidshine.notifyrc b/daemon/kdeconnect.notifyrc
similarity index 100%
rename from daemon/androidshine.notifyrc
rename to daemon/kdeconnect.notifyrc
diff --git a/daemon/packagereceivers/notificationpackagereceiver.cpp b/daemon/packagereceivers/notificationpackagereceiver.cpp
index 22b035b..9e8985c 100644
--- a/daemon/packagereceivers/notificationpackagereceiver.cpp
+++ b/daemon/packagereceivers/notificationpackagereceiver.cpp
@@ -62,7 +62,7 @@ KNotification* NotificationPackageReceiver::createNotification(const NetworkPack
KNotification* notification = new KNotification(type); //KNotification::Persistent
notification->setPixmap(KIcon(icon).pixmap(48, 48));
- notification->setComponentData(KComponentData("androidshine", "androidshine"));
+ notification->setComponentData(KComponentData("kdeconnect", "kdeconnect"));
notification->setTitle(title);
notification->setText(np.body());
diff --git a/kcm/daemondbusinterface.cpp b/kcm/daemondbusinterface.cpp
index c2d49e0..7b5a802 100644
--- a/kcm/daemondbusinterface.cpp
+++ b/kcm/daemondbusinterface.cpp
@@ -21,7 +21,7 @@
#include "daemondbusinterface.h"
DaemonDbusInterface::DaemonDbusInterface(QObject* parent)
- : OrgKdeKdeconnectInterface("org.kde.kdeconnect", "/modules/androidshine", QDBusConnection::sessionBus(), parent)
+ : OrgKdeKdeconnectInterface("org.kde.kdeconnect", "/modules/kdeconnect", QDBusConnection::sessionBus(), parent)
{
}
\ No newline at end of file
diff --git a/kcm/devicesmodel.cpp b/kcm/devicesmodel.cpp
index 9bf3375..9f47c12 100644
--- a/kcm/devicesmodel.cpp
+++ b/kcm/devicesmodel.cpp
@@ -21,22 +21,63 @@
*/
#include "devicesmodel.h"
+#include <ksharedconfig.h>
+#include <QDebug>
+#include <KConfigGroup>
DevicesModel::DevicesModel(QObject *parent)
: QAbstractItemModel(parent)
{
+
}
DevicesModel::~DevicesModel()
{
}
+void DevicesModel::loadPaired()
+{
+
+ //TODO: Load from daemon, so we can know if they are currently connected or not
+
+ removeRows(0,rowCount());
+
+ KSharedConfigPtr config = KSharedConfig::openConfig("kdeconnectrc");
+ const KConfigGroup& known = config->group("devices").group("paired");
+ const QStringList& list = known.groupList();
+
+ const QString defaultName("unnamed");
+
+ Q_FOREACH(QString id, list) {
+
+ const KConfigGroup& data = known.group(id);
+ const QString& name = data.readEntry<QString>("name",defaultName);
+
+ //qDebug() << id << name;
+
+ addDevice(id,name,Visible);
+
+ }
+
+}
+
+void DevicesModel::addDevice(QString id, QString name, DevicesModel::DeviceStatus status)
+{
+ int rown = rowCount();
+ insertRows(rown,1);
+ setData(index(rown,0),QVariant(id),IdModelRole);
+ setData(index(rown,0),QVariant(name),NameModelRole);
+ setData(index(rown,0),QVariant(PairedConnected),StatusModelRole);
+ emit dataChanged(index(rown,0),index(rown,0));
+}
+
+
int DevicesModel::columnCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
- return 1;
+ return 1; //We are not using the second dimension at all
}
QVariant DevicesModel::data(const QModelIndex &index, int role) const
@@ -46,15 +87,13 @@ QVariant DevicesModel::data(const QModelIndex &index, int role) const
}
switch (role) {
case IconModelRole:
- //return m_deviceList[index.row()].m_icon;
+ return QPixmap(); //TODO: Return a pixmap to represent the status
+ case IdModelRole:
+ return m_deviceList[index.row()].id;
case NameModelRole:
- //return m_deviceList[index.row()].m_device->name();
- case AliasModelRole:
- //return m_deviceList[index.row()].m_device->alias();
- case DeviceTypeModelRole:
- //return m_deviceList[index.row()].m_deviceType;
- case DeviceModelRole:
- //return QVariant::fromValue<void*>(m_deviceList[index.row()].m_device);
+ return m_deviceList[index.row()].name;
+ case StatusModelRole:
+ return m_deviceList[index.row()].status;
default:
break;
}
@@ -68,16 +107,16 @@ bool DevicesModel::setData(const QModelIndex &index, const QVariant &value, int
}
switch (role) {
case IconModelRole:
- //m_deviceList[index.row()].m_icon = value.value<QPixmap>();
+ qDebug() << "Icon can not be assigned to, change status instead";
break;
- case DeviceTypeModelRole:
- //m_deviceList[index.row()].m_deviceType = value.toString();
+ case IdModelRole:
+ m_deviceList[index.row()].id = value.toString();
+ break;
+ case NameModelRole:
+ m_deviceList[index.row()].name = value.toString();
break;
- case DeviceModelRole: {
- //Device *const device = static_cast<Device*>(value.value<void*>());
- //m_deviceList[index.row()].m_device = device;
- //connect(device, SIGNAL(propertyChanged(QString,QVariant)),this, SIGNAL(layoutChanged()));
- }
+ case StatusModelRole:
+ m_deviceList[index.row()].status = (DeviceStatus)value.toInt();
break;
default:
return false;
diff --git a/kcm/devicesmodel.h b/kcm/devicesmodel.h
index 6fdb600..531d02f 100644
--- a/kcm/devicesmodel.h
+++ b/kcm/devicesmodel.h
@@ -33,12 +33,19 @@ class DevicesModel
{
public:
enum ModelRoles {
- IconModelRole = 0,
- NameModelRole,
- AliasModelRole,
- DeviceTypeModelRole,
- DeviceModelRole,
- LastModelRole
+ NameModelRole = Qt::DisplayRole,
+ IconModelRole = Qt::DecorationRole,
+ IdModelRole = Qt::UserRole,
+ StatusModelRole
+ };
+
+ enum DeviceStatus {
+ Missing = 0,
+ Visible,
+ Connected,
+ PairedMissing = 10,
+ PairedVisible,
+ PairedConnected,
};
DevicesModel(QObject *parent = 0);
@@ -53,10 +60,15 @@ public:
virtual bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
virtual bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
+ void loadPaired();
+ void addDevice(QString id, QString name, DeviceStatus status);
+
+
private:
struct Device {
QString id;
QString name;
+ DeviceStatus status;
};
QList<Device> m_deviceList;
};
diff --git a/kcm/kcm.cpp b/kcm/kcm.cpp
index f155584..c3cdf74 100644
--- a/kcm/kcm.cpp
+++ b/kcm/kcm.cpp
@@ -44,16 +44,24 @@ KdeConnectKcm::KdeConnectKcm(QWidget *parent, const QVariantList&)
, dbusInterface(this)
, pairedDevicesList(this)
, addDeviceWizard(this)
+ , config(KSharedConfig::openConfig("kdeconnectrc"))
{
+ pairedDevicesList.loadPaired();
+
kcmUi->setupUi(this);
+ //config->group("devices").group("paired").group("123456").writeEntry("name","Ultra-fake device");
+ //config->group("devices").group("paired").group("987654").writeEntry("name","Ultra-fake device");
+ //pairedDevicesList.updateFromConfig();
+
kcmUi->deviceList->setIconSize(QSize(32,32));
kcmUi->deviceList->setModel(&pairedDevicesList);
connect(kcmUi->addButton, SIGNAL(clicked(bool)), this, SLOT(addButtonClicked()));
connect(kcmUi->removeButton, SIGNAL(clicked(bool)), this, SLOT(removeButtonClicked()));
+ connect(&addDeviceWizard,SIGNAL(deviceAdded(QString,QString)),this, SLOT(deviceAdded(QString,QString)));
}
KdeConnectKcm::~KdeConnectKcm()
@@ -71,6 +79,12 @@ void KdeConnectKcm::removeButtonClicked()
}
+void KdeConnectKcm::deviceAdded(QString id,QString name)
+{
+ qDebug() << "Succesfully paired: " + id;
+ pairedDevicesList.addDevice(id,name,DevicesModel::PairedConnected);
+}
+
void KdeConnectKcm::currentChanged(const QModelIndex& current, const QModelIndex& previous)
{
diff --git a/kcm/kcm.h b/kcm/kcm.h
index b159b61..9c66b2d 100644
--- a/kcm/kcm.h
+++ b/kcm/kcm.h
@@ -25,8 +25,10 @@
#include <QDBusConnection>
#include <kcmodule.h>
+#include <ksharedconfig.h>
#include "wizard.h"
+#include "devicesmodel.h"
class Create;
class QModelIndex;
@@ -51,12 +53,14 @@ private Q_SLOTS:
void addButtonClicked();
void removeButtonClicked();
void currentChanged(const QModelIndex& current, const QModelIndex& previous);
-
+ void deviceAdded(QString id, QString name);
+
private:
Ui::KdeConnectKcmUi* kcmUi;
DaemonDbusInterface dbusInterface;
- QStandardItemModel pairedDevicesList;
+ DevicesModel pairedDevicesList;
AddDeviceWizard addDeviceWizard;
+ KSharedConfigPtr config;
};
diff --git a/kcm/wizard.cpp b/kcm/wizard.cpp
index 80ef6fe..90012c9 100644
--- a/kcm/wizard.cpp
+++ b/kcm/wizard.cpp
@@ -19,43 +19,60 @@
*/
#include "wizard.h"
+#include "devicesmodel.h"
#include <QDebug>
#include <QStandardItemModel>
+#include <kdebug.h>
+
#include "ui_wizard.h"
AddDeviceWizard::AddDeviceWizard(QWidget* parent)
: QWizard(parent)
, wizardUi(new Ui::Wizard())
, dbusInterface(new DaemonDbusInterface(this))
- , discoveredDevicesList(new QStandardItemModel(this))
+ , discoveredDevicesList(new DevicesModel(this))
{
wizardUi->setupUi(this);
- wizardUi->listView->setModel(discoveredDevicesList);
+ connect(wizardUi->listView,SIGNAL(activated(QModelIndex)),this,SLOT(deviceSelected(QModelIndex)));
- dbusInterface->startDiscovery(123456789);
+ wizardUi->listView->setModel(discoveredDevicesList);
connect(this,SIGNAL(currentIdChanged(int)),this,SLOT(pageChanged(int)));
+ connect(this,SIGNAL(accepted()),this,SLOT(wizardFinished()));
+
connect(dbusInterface, SIGNAL(deviceDiscovered(QString, QString)), this, SLOT(deviceDiscovered(QString,QString)));
//connect(dbusInterface, SIGNAL(deviceLost(QString)), this, SLOT(deviceLost(QString)));
+ dbusInterface->startDiscovery(123456789);
+
}
+void AddDeviceWizard::wizardFinished()
+{
+ if (selectedIndex.row() > 0 && selectedIndex.row() < discoveredDevicesList->rowCount()) {
+ QString name = discoveredDevicesList->data(selectedIndex,DevicesModel::NameModelRole).toString();
+ QString id = discoveredDevicesList->data(selectedIndex,DevicesModel::IdModelRole).toString();
+ emit deviceAdded(name,id);
+ }
+}
+
+
void AddDeviceWizard::pageChanged(int id)
{
qDebug() << id;
+ if (id == 2) {
+ //TODO: Do the actual pairing in this page
+ }
}
void AddDeviceWizard::deviceDiscovered(QString id, QString name)
{
- QStandardItem* item = new QStandardItem(name);
- item->setData(id);
-
- discoveredDevicesList->appendRow(item);
+ discoveredDevicesList->addDevice(id,name,DevicesModel::Visible);
}
/*
void AddDeviceWizard::deviceLost(QString id)
@@ -68,6 +85,26 @@ void AddDeviceWizard::discoveryFinished(bool success)
}
+void AddDeviceWizard::restart()
+{
+ selectedIndex = QModelIndex();
+ QWizard::restart();
+}
+
+
+void AddDeviceWizard::show()
+{
+ restart();
+ QWizard::show();
+}
+
+void AddDeviceWizard::deviceSelected(const QModelIndex& index)
+{
+ qDebug() << "Selected: " + index.row();
+ selectedIndex = index;
+ next();
+}
+
AddDeviceWizard::~AddDeviceWizard()
{
delete wizardUi;
diff --git a/kcm/wizard.h b/kcm/wizard.h
index 40ce755..161acb7 100644
--- a/kcm/wizard.h
+++ b/kcm/wizard.h
@@ -25,6 +25,7 @@
#include <QObject>
#include "daemondbusinterface.h"
+#include "devicesmodel.h"
namespace Ui {
class Wizard;
@@ -39,6 +40,8 @@ class AddDeviceWizard : public QWizard
public:
AddDeviceWizard(QWidget* parent);
~AddDeviceWizard();
+ void show();
+ void restart();
private Q_SLOTS:
void pageChanged(int id);
@@ -47,10 +50,18 @@ private Q_SLOTS:
//void deviceLost(QString id);
void discoveryFinished(bool success);
+ void deviceSelected(const QModelIndex& index);
+
+ void wizardFinished();
+
+Q_SIGNALS:
+ void deviceAdded(QString id, QString name);
+
private:
Ui::Wizard* wizardUi;
DaemonDbusInterface* dbusInterface;
- QStandardItemModel* discoveredDevicesList;
+ DevicesModel* discoveredDevicesList;
+ QModelIndex selectedIndex;
};
#endif // WIZARD_H
diff --git a/letsgo.sh b/letsgo.sh
index 704c6a5..c9e0e08 100755
--- a/letsgo.sh
+++ b/letsgo.sh
@@ -14,14 +14,14 @@ if kdebuild; then
true
done
- #qdbus org.kde.kded /kded unloadModule androidshine
- #qdbus org.kde.kded /kded loadModule androidshine
+ #qdbus org.kde.kded /kded unloadModule kdeconnect
+ #qdbus org.kde.kded /kded loadModule kdeconnect
if [ ""$1 == "--nodaemon" ]; then
echo "nodaemon"
kded4 --nofork
else
- kded4 2>&1 | grep -v "^kded(" &
+ kded4 --nofork # 2>&1 | grep -v "^kded(" &
fi
fi
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 92851e5..1c16c40 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,10 +1,10 @@
-set(kded_androidshine_tests_SRCS
+set(kded_kdeconnect_tests_SRCS
backendtests.cpp
)
-kde4_add_unit_test(kded_androidshine_tests ${kded_androidshine_tests_SRCS})
+kde4_add_unit_test(kded_kdeconnect_tests ${kded_kdeconnect_tests_SRCS})
-target_link_libraries(kded_androidshine_tests
+target_link_libraries(kded_kdeconnect_tests
${KDE4_KDECORE_LIBS}
${KDE4_KDEUI_LIBS}
kdnssd
@@ -12,5 +12,5 @@ target_link_libraries(kded_androidshine_tests
${QT_QTNETWORK_LIBRARY}
)
-add_test(kded_androidshine_tests ${CMAKE_CURRENT_BINARY_DIR}/kded_androidshine_tests)
+add_test(kded_kdeconnect_tests ${CMAKE_CURRENT_BINARY_DIR}/kded_kdeconnect_tests)
--
kdeconnect packaging
More information about the pkg-kde-commits
mailing list