Device listing in kcm
This commit is contained in:
parent
1bdd3eb97b
commit
5027b7ee8e
7 changed files with 24 additions and 16 deletions
|
@ -55,7 +55,10 @@ void AvahiAnnouncer::readPendingNotifications()
|
||||||
//log.write(datagram);
|
//log.write(datagram);
|
||||||
qDebug() << ("AvahiAnnouncer incomming udp datagram: " + 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);
|
Device* device = new Device(id, name);
|
||||||
DeviceLink* dl = new UdpDeviceLink(device, sender, 10600);
|
DeviceLink* dl = new UdpDeviceLink(device, sender, 10600);
|
||||||
|
@ -74,6 +77,7 @@ AvahiAnnouncer::~AvahiAnnouncer()
|
||||||
|
|
||||||
void AvahiAnnouncer::setDiscoverable(bool b)
|
void AvahiAnnouncer::setDiscoverable(bool b)
|
||||||
{
|
{
|
||||||
|
qDebug() << "Avahi scanning";
|
||||||
if (b) service->publishAsync();
|
if (b) service->publishAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ QString Daemon::listVisibleDevices()
|
||||||
|
|
||||||
void Daemon::startDiscovery(int timeOut)
|
void Daemon::startDiscovery(int timeOut)
|
||||||
{
|
{
|
||||||
|
qDebug() << "Start discovery";
|
||||||
//Listen to incomming connections
|
//Listen to incomming connections
|
||||||
Q_FOREACH (Announcer* a, announcers) {
|
Q_FOREACH (Announcer* a, announcers) {
|
||||||
a->setDiscoverable(true);
|
a->setDiscoverable(true);
|
||||||
|
|
|
@ -40,8 +40,9 @@ NetworkPackage NetworkPackage::fromString(QByteArray s)
|
||||||
|
|
||||||
NetworkPackage pp(id);
|
NetworkPackage pp(id);
|
||||||
|
|
||||||
ss >> pp.mDeviceId;
|
std::string deviceId;
|
||||||
qDebug() << pp.mDeviceId;
|
ss >> deviceId;
|
||||||
|
pp.mDeviceId = QString::fromStdString(deviceId);
|
||||||
|
|
||||||
ss >> pp.mTime;
|
ss >> pp.mTime;
|
||||||
|
|
||||||
|
@ -55,7 +56,6 @@ NetworkPackage NetworkPackage::fromString(QByteArray s)
|
||||||
ss.get(); //Skip ws
|
ss.get(); //Skip ws
|
||||||
ss.read(c,bodyLenght);
|
ss.read(c,bodyLenght);
|
||||||
pp.mBody = QString::fromAscii(c,bodyLenght);
|
pp.mBody = QString::fromAscii(c,bodyLenght);
|
||||||
qDebug() << pp.mBody;
|
|
||||||
|
|
||||||
ss >> pp.mIsCancel;
|
ss >> pp.mIsCancel;
|
||||||
|
|
||||||
|
|
|
@ -37,9 +37,10 @@ public:
|
||||||
static NetworkPackage fromString(QByteArray);
|
static NetworkPackage fromString(QByteArray);
|
||||||
QByteArray toString() const;
|
QByteArray toString() const;
|
||||||
|
|
||||||
|
long id() const { return mId; }
|
||||||
|
QString deviceId() const { return mDeviceId; }
|
||||||
QString type() const { return mType; }
|
QString type() const { return mType; }
|
||||||
QString body() const { return mBody; }
|
QString body() const { return mBody; }
|
||||||
long id() const { return mId; }
|
|
||||||
bool isCancel() const { return mIsCancel; }
|
bool isCancel() const { return mIsCancel; }
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,8 +48,8 @@ public:
|
||||||
private:
|
private:
|
||||||
|
|
||||||
long mId;
|
long mId;
|
||||||
long mDeviceId;
|
|
||||||
long mTime;
|
long mTime;
|
||||||
|
QString mDeviceId;
|
||||||
QString mType;
|
QString mType;
|
||||||
QString mBody;
|
QString mBody;
|
||||||
QVariant mExtra;
|
QVariant mExtra;
|
||||||
|
|
|
@ -52,7 +52,6 @@ private Q_SLOTS:
|
||||||
void removeButtonClicked();
|
void removeButtonClicked();
|
||||||
void currentChanged(const QModelIndex& current, const QModelIndex& previous);
|
void currentChanged(const QModelIndex& current, const QModelIndex& previous);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::KdeConnectKcmUi* kcmUi;
|
Ui::KdeConnectKcmUi* kcmUi;
|
||||||
DaemonDbusInterface dbusInterface;
|
DaemonDbusInterface dbusInterface;
|
||||||
|
|
|
@ -36,6 +36,8 @@ AddDeviceWizard::AddDeviceWizard(QWidget* parent)
|
||||||
|
|
||||||
wizardUi->listView->setModel(discoveredDevicesList);
|
wizardUi->listView->setModel(discoveredDevicesList);
|
||||||
|
|
||||||
|
dbusInterface->startDiscovery(123456789);
|
||||||
|
|
||||||
connect(this,SIGNAL(currentIdChanged(int)),this,SLOT(pageChanged(int)));
|
connect(this,SIGNAL(currentIdChanged(int)),this,SLOT(pageChanged(int)));
|
||||||
|
|
||||||
connect(dbusInterface, SIGNAL(deviceDiscovered(QString, QString)), this, SLOT(deviceDiscovered(QString,QString)));
|
connect(dbusInterface, SIGNAL(deviceDiscovered(QString, QString)), this, SLOT(deviceDiscovered(QString,QString)));
|
||||||
|
@ -46,11 +48,6 @@ AddDeviceWizard::AddDeviceWizard(QWidget* parent)
|
||||||
void AddDeviceWizard::pageChanged(int id)
|
void AddDeviceWizard::pageChanged(int id)
|
||||||
{
|
{
|
||||||
qDebug() << id;
|
qDebug() << id;
|
||||||
//QWizardPage* p = page(id);
|
|
||||||
if (id == 1) {
|
|
||||||
dbusInterface->startDiscovery(10);
|
|
||||||
//Show "scanning"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddDeviceWizard::deviceDiscovered(QString id, QString name)
|
void AddDeviceWizard::deviceDiscovered(QString id, QString name)
|
||||||
|
|
13
letsgo.sh
13
letsgo.sh
|
@ -5,17 +5,24 @@
|
||||||
. ~/.bashrc
|
. ~/.bashrc
|
||||||
|
|
||||||
KDE_BUILD_CONFIRMATION=false
|
KDE_BUILD_CONFIRMATION=false
|
||||||
|
export VERBOSE=1
|
||||||
|
|
||||||
if kdebuild; then
|
if kdebuild; then
|
||||||
|
|
||||||
killall kded4
|
killall kded4 2> /dev/null
|
||||||
while killall -9 kded4; do
|
while killall -9 kded4 2> /dev/null; do
|
||||||
true
|
true
|
||||||
done
|
done
|
||||||
|
|
||||||
#qdbus org.kde.kded /kded unloadModule androidshine
|
#qdbus org.kde.kded /kded unloadModule androidshine
|
||||||
#qdbus org.kde.kded /kded loadModule 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
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue