Minor changes
This commit is contained in:
parent
5f1c7b8c56
commit
0eb3f019c9
8 changed files with 28 additions and 25 deletions
|
@ -160,6 +160,7 @@ void Daemon::onDeviceReachableStatusChanged()
|
||||||
if (!device->reachable()) {
|
if (!device->reachable()) {
|
||||||
|
|
||||||
if (!device->paired()) {
|
if (!device->paired()) {
|
||||||
|
qDebug() << "Destroying device";
|
||||||
Q_EMIT deviceRemoved(id);
|
Q_EMIT deviceRemoved(id);
|
||||||
mDevices.remove(id);
|
mDevices.remove(id);
|
||||||
device->deleteLater();
|
device->deleteLater();
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
Device::Device(const QString& id, const QString& name)
|
Device::Device(const QString& id, const QString& name)
|
||||||
{
|
{
|
||||||
|
|
||||||
m_deviceId = id;
|
m_deviceId = id;
|
||||||
m_deviceName = name;
|
m_deviceName = name;
|
||||||
m_paired = true;
|
m_paired = true;
|
||||||
|
@ -32,6 +33,7 @@ Device::Device(const QString& id, const QString& name)
|
||||||
|
|
||||||
Device::Device(const QString& id, const QString& name, DeviceLink* link)
|
Device::Device(const QString& id, const QString& name, DeviceLink* link)
|
||||||
{
|
{
|
||||||
|
|
||||||
m_deviceId = id;
|
m_deviceId = id;
|
||||||
m_deviceName = name;
|
m_deviceName = name;
|
||||||
m_paired = false;
|
m_paired = false;
|
||||||
|
@ -45,23 +47,11 @@ Device::Device(const QString& id, const QString& name, DeviceLink* link)
|
||||||
QDBusConnection::sessionBus().registerObject("/modules/kdeconnect/devices/"+id, this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors);
|
QDBusConnection::sessionBus().registerObject("/modules/kdeconnect/devices/"+id, this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors);
|
||||||
|
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
Device::Device(const QString& id, const QString& name, DeviceLink* link)
|
Device::~Device()
|
||||||
{
|
{
|
||||||
m_deviceId = id;
|
|
||||||
m_deviceName = id; //Temporary name
|
|
||||||
m_paired = false;
|
|
||||||
m_knownIdentiy = false;
|
|
||||||
|
|
||||||
addLink(link);
|
|
||||||
|
|
||||||
NetworkPackage identityRequest;
|
|
||||||
identityRequest.setType("IDENTITY_REQUEST");
|
|
||||||
link->sendPackage(identityRequest);
|
|
||||||
|
|
||||||
QDBusConnection::sessionBus().registerObject("/modules/kdeconnect/Devices/"+id, this);
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
bool Device::hasPlugin(const QString& name)
|
bool Device::hasPlugin(const QString& name)
|
||||||
{
|
{
|
||||||
|
@ -123,9 +113,11 @@ void Device::setPair(bool b)
|
||||||
if (b) {
|
if (b) {
|
||||||
qDebug() << name() << "paired";
|
qDebug() << name() << "paired";
|
||||||
config->group("devices").group("paired").group(id()).writeEntry("name",name());
|
config->group("devices").group("paired").group(id()).writeEntry("name",name());
|
||||||
|
Q_EMIT reachableStatusChanged();
|
||||||
} else {
|
} else {
|
||||||
qDebug() << name() << "unpaired";
|
qDebug() << name() << "unpaired";
|
||||||
config->group("devices").group("paired").deleteGroup(id());
|
config->group("devices").group("paired").deleteGroup(id());
|
||||||
|
//Do not Q_EMIT reachableStatusChanged() because we do not want it to suddenly disappear from device list
|
||||||
}
|
}
|
||||||
reloadPlugins();
|
reloadPlugins();
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,9 +46,7 @@ public:
|
||||||
//Device known via an incoming connection sent to us via a devicelink, we know everything but we don't trust it yet
|
//Device known via an incoming connection sent to us via a devicelink, we know everything but we don't trust it yet
|
||||||
Device(const QString& id, const QString& name, DeviceLink* dl);
|
Device(const QString& id, const QString& name, DeviceLink* dl);
|
||||||
|
|
||||||
//Device known via discovery, we know nothing and have to ask for a presentation package
|
virtual ~Device();
|
||||||
//(not supported yet, do we need it or we can rely on the device presenging itself?)
|
|
||||||
//Device(const QString& id, DeviceLink* dl);
|
|
||||||
|
|
||||||
QString id() const { return m_deviceId; }
|
QString id() const { return m_deviceId; }
|
||||||
QString name() const { return m_deviceName; }
|
QString name() const { return m_deviceName; }
|
||||||
|
|
|
@ -29,7 +29,7 @@ K_EXPORT_PLUGIN( KdeConnectPluginFactory("kdeconnect_notifications", "kdeconnect
|
||||||
NotificationsPlugin::NotificationsPlugin(QObject* parent, const QVariantList& args)
|
NotificationsPlugin::NotificationsPlugin(QObject* parent, const QVariantList& args)
|
||||||
: KdeConnectPlugin(parent, args)
|
: KdeConnectPlugin(parent, args)
|
||||||
{
|
{
|
||||||
trayIcon = new KStatusNotifierItem(parent);
|
trayIcon = new KStatusNotifierItem(this);
|
||||||
trayIcon->setIconByName("smartphone");
|
trayIcon->setIconByName("smartphone");
|
||||||
trayIcon->setTitle(device()->name());
|
trayIcon->setTitle(device()->name());
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,6 @@ class NotificationsPlugin
|
||||||
: public KdeConnectPlugin
|
: public KdeConnectPlugin
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
KStatusNotifierItem* trayIcon;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit NotificationsPlugin(QObject *parent, const QVariantList &args);
|
explicit NotificationsPlugin(QObject *parent, const QVariantList &args);
|
||||||
|
@ -40,6 +39,9 @@ public:
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
virtual bool receivePackage(const NetworkPackage& np);
|
virtual bool receivePackage(const NetworkPackage& np);
|
||||||
|
|
||||||
|
private:
|
||||||
|
KStatusNotifierItem* trayIcon;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -46,8 +46,8 @@ bool PingPlugin::receivePackage(const NetworkPackage& np)
|
||||||
KNotification* notification = new KNotification("pingReceived"); //KNotification::Persistent
|
KNotification* notification = new KNotification("pingReceived"); //KNotification::Persistent
|
||||||
notification->setPixmap(KIcon("dialog-ok").pixmap(48, 48));
|
notification->setPixmap(KIcon("dialog-ok").pixmap(48, 48));
|
||||||
notification->setComponentData(KComponentData("kdeconnect", "kdeconnect"));
|
notification->setComponentData(KComponentData("kdeconnect", "kdeconnect"));
|
||||||
notification->setTitle("Ping!");
|
notification->setTitle(device()->name());
|
||||||
notification->setText(device()->name());
|
notification->setText("Ping!");
|
||||||
notification->sendEvent();
|
notification->sendEvent();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -60,7 +60,7 @@ KNotification* TelephonyPlugin::createNotification(const NetworkPackage& np)
|
||||||
//TODO: return NULL if !debug
|
//TODO: return NULL if !debug
|
||||||
type = "unknownEvent";
|
type = "unknownEvent";
|
||||||
icon = "pda";
|
icon = "pda";
|
||||||
content = "Unknown notification type: " + event;
|
content = "Unknown telephony event: " + event;
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "Creating notification with type:" << type;
|
qDebug() << "Creating notification with type:" << type;
|
||||||
|
|
14
kcm/kcm.cpp
14
kcm/kcm.cpp
|
@ -120,9 +120,19 @@ void KdeConnectKcm::deviceSelected(const QModelIndex& current)
|
||||||
void KdeConnectKcm::trustedStateChanged(bool b)
|
void KdeConnectKcm::trustedStateChanged(bool b)
|
||||||
{
|
{
|
||||||
if (!currentDevice) return;
|
if (!currentDevice) return;
|
||||||
currentDevice->setPair(b);
|
QDBusPendingReply<void> pendingReply = currentDevice->setPair(b);
|
||||||
|
pendingReply.waitForFinished();
|
||||||
|
if (pendingReply.isValid()) {
|
||||||
|
//If dbus was down, calling this would make kcm crash
|
||||||
devicesModel->deviceStatusChanged(currentDevice->id());
|
devicesModel->deviceStatusChanged(currentDevice->id());
|
||||||
|
} else {
|
||||||
|
//Revert checkbox
|
||||||
|
disconnect(kcmUi->trust_checkbox, SIGNAL(toggled(bool)),
|
||||||
|
this, SLOT(trustedStateChanged(bool)));
|
||||||
|
kcmUi->trust_checkbox->setCheckState(b? Qt::Unchecked : Qt::Checked);
|
||||||
|
connect(kcmUi->trust_checkbox, SIGNAL(toggled(bool)),
|
||||||
|
this, SLOT(trustedStateChanged(bool)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KdeConnectKcm::pluginsConfigChanged()
|
void KdeConnectKcm::pluginsConfigChanged()
|
||||||
|
|
Loading…
Reference in a new issue