From 5027b7ee8eb732a9edf9b282a0ce513bb5828d41 Mon Sep 17 00:00:00 2001 From: Albert Vaca Date: Thu, 27 Jun 2013 14:33:51 +0200 Subject: [PATCH] Device listing in kcm --- daemon/announcers/avahiannouncer.cpp | 6 +++++- daemon/daemon.cpp | 2 +- daemon/networkpackage.cpp | 6 +++--- daemon/networkpackage.h | 5 +++-- kcm/kcm.h | 1 - kcm/wizard.cpp | 7 ++----- letsgo.sh | 13 ++++++++++--- 7 files changed, 24 insertions(+), 16 deletions(-) diff --git a/daemon/announcers/avahiannouncer.cpp b/daemon/announcers/avahiannouncer.cpp index 756a05093..a78e3b0cb 100644 --- a/daemon/announcers/avahiannouncer.cpp +++ b/daemon/announcers/avahiannouncer.cpp @@ -55,7 +55,10 @@ void AvahiAnnouncer::readPendingNotifications() //log.write(datagram); qDebug() << ("AvahiAnnouncer incomming udp datagram: " + datagram); - QString id, name; + NetworkPackage np = NetworkPackage::fromString(datagram); + + QString id = np.deviceId(); + QString name = np.body(); Device* device = new Device(id, name); DeviceLink* dl = new UdpDeviceLink(device, sender, 10600); @@ -74,6 +77,7 @@ AvahiAnnouncer::~AvahiAnnouncer() void AvahiAnnouncer::setDiscoverable(bool b) { + qDebug() << "Avahi scanning"; if (b) service->publishAsync(); } diff --git a/daemon/daemon.cpp b/daemon/daemon.cpp index 4139344bf..e4a1708b8 100644 --- a/daemon/daemon.cpp +++ b/daemon/daemon.cpp @@ -101,7 +101,7 @@ QString Daemon::listVisibleDevices() void Daemon::startDiscovery(int timeOut) { - + qDebug() << "Start discovery"; //Listen to incomming connections Q_FOREACH (Announcer* a, announcers) { a->setDiscoverable(true); diff --git a/daemon/networkpackage.cpp b/daemon/networkpackage.cpp index 81bf46efb..574f850c7 100644 --- a/daemon/networkpackage.cpp +++ b/daemon/networkpackage.cpp @@ -40,8 +40,9 @@ NetworkPackage NetworkPackage::fromString(QByteArray s) NetworkPackage pp(id); - ss >> pp.mDeviceId; - qDebug() << pp.mDeviceId; + std::string deviceId; + ss >> deviceId; + pp.mDeviceId = QString::fromStdString(deviceId); ss >> pp.mTime; @@ -55,7 +56,6 @@ NetworkPackage NetworkPackage::fromString(QByteArray s) ss.get(); //Skip ws ss.read(c,bodyLenght); pp.mBody = QString::fromAscii(c,bodyLenght); - qDebug() << pp.mBody; ss >> pp.mIsCancel; diff --git a/daemon/networkpackage.h b/daemon/networkpackage.h index 2cc692e7d..2466a46b7 100644 --- a/daemon/networkpackage.h +++ b/daemon/networkpackage.h @@ -37,9 +37,10 @@ public: static NetworkPackage fromString(QByteArray); QByteArray toString() const; + long id() const { return mId; } + QString deviceId() const { return mDeviceId; } QString type() const { return mType; } QString body() const { return mBody; } - long id() const { return mId; } bool isCancel() const { return mIsCancel; } @@ -47,8 +48,8 @@ public: private: long mId; - long mDeviceId; long mTime; + QString mDeviceId; QString mType; QString mBody; QVariant mExtra; diff --git a/kcm/kcm.h b/kcm/kcm.h index 5ca136874..b159b616f 100644 --- a/kcm/kcm.h +++ b/kcm/kcm.h @@ -52,7 +52,6 @@ private Q_SLOTS: void removeButtonClicked(); void currentChanged(const QModelIndex& current, const QModelIndex& previous); - private: Ui::KdeConnectKcmUi* kcmUi; DaemonDbusInterface dbusInterface; diff --git a/kcm/wizard.cpp b/kcm/wizard.cpp index 639fd107d..80ef6fe2b 100644 --- a/kcm/wizard.cpp +++ b/kcm/wizard.cpp @@ -36,6 +36,8 @@ AddDeviceWizard::AddDeviceWizard(QWidget* parent) wizardUi->listView->setModel(discoveredDevicesList); + dbusInterface->startDiscovery(123456789); + connect(this,SIGNAL(currentIdChanged(int)),this,SLOT(pageChanged(int))); connect(dbusInterface, SIGNAL(deviceDiscovered(QString, QString)), this, SLOT(deviceDiscovered(QString,QString))); @@ -46,11 +48,6 @@ AddDeviceWizard::AddDeviceWizard(QWidget* parent) void AddDeviceWizard::pageChanged(int id) { qDebug() << id; - //QWizardPage* p = page(id); - if (id == 1) { - dbusInterface->startDiscovery(10); - //Show "scanning" - } } void AddDeviceWizard::deviceDiscovered(QString id, QString name) diff --git a/letsgo.sh b/letsgo.sh index 04610f2fd..704c6a569 100755 --- a/letsgo.sh +++ b/letsgo.sh @@ -5,17 +5,24 @@ . ~/.bashrc KDE_BUILD_CONFIRMATION=false +export VERBOSE=1 if kdebuild; then - killall kded4 - while killall -9 kded4; do + killall kded4 2> /dev/null + while killall -9 kded4 2> /dev/null; do true done #qdbus org.kde.kded /kded unloadModule androidshine #qdbus org.kde.kded /kded loadModule androidshine - kded4 2>&1 | grep -v "^kded(" & + + if [ ""$1 == "--nodaemon" ]; then + echo "nodaemon" + kded4 --nofork + else + kded4 2>&1 | grep -v "^kded(" & + fi fi