Minor changes

This commit is contained in:
Albert Vaca 2013-08-16 09:27:32 +02:00
parent 5f1c7b8c56
commit 0eb3f019c9
8 changed files with 28 additions and 25 deletions

View file

@ -160,6 +160,7 @@ void Daemon::onDeviceReachableStatusChanged()
if (!device->reachable()) {
if (!device->paired()) {
qDebug() << "Destroying device";
Q_EMIT deviceRemoved(id);
mDevices.remove(id);
device->deleteLater();

View file

@ -18,6 +18,7 @@
Device::Device(const QString& id, const QString& name)
{
m_deviceId = id;
m_deviceName = name;
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)
{
m_deviceId = id;
m_deviceName = name;
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);
}
/*
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)
{
@ -123,9 +113,11 @@ void Device::setPair(bool b)
if (b) {
qDebug() << name() << "paired";
config->group("devices").group("paired").group(id()).writeEntry("name",name());
Q_EMIT reachableStatusChanged();
} else {
qDebug() << name() << "unpaired";
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();
}

View file

@ -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(const QString& id, const QString& name, DeviceLink* dl);
//Device known via discovery, we know nothing and have to ask for a presentation package
//(not supported yet, do we need it or we can rely on the device presenging itself?)
//Device(const QString& id, DeviceLink* dl);
virtual ~Device();
QString id() const { return m_deviceId; }
QString name() const { return m_deviceName; }

View file

@ -29,7 +29,7 @@ K_EXPORT_PLUGIN( KdeConnectPluginFactory("kdeconnect_notifications", "kdeconnect
NotificationsPlugin::NotificationsPlugin(QObject* parent, const QVariantList& args)
: KdeConnectPlugin(parent, args)
{
trayIcon = new KStatusNotifierItem(parent);
trayIcon = new KStatusNotifierItem(this);
trayIcon->setIconByName("smartphone");
trayIcon->setTitle(device()->name());
}

View file

@ -31,7 +31,6 @@ class NotificationsPlugin
: public KdeConnectPlugin
{
Q_OBJECT
KStatusNotifierItem* trayIcon;
public:
explicit NotificationsPlugin(QObject *parent, const QVariantList &args);
@ -40,6 +39,9 @@ public:
public Q_SLOTS:
virtual bool receivePackage(const NetworkPackage& np);
private:
KStatusNotifierItem* trayIcon;
};
#endif

View file

@ -46,8 +46,8 @@ bool PingPlugin::receivePackage(const NetworkPackage& np)
KNotification* notification = new KNotification("pingReceived"); //KNotification::Persistent
notification->setPixmap(KIcon("dialog-ok").pixmap(48, 48));
notification->setComponentData(KComponentData("kdeconnect", "kdeconnect"));
notification->setTitle("Ping!");
notification->setText(device()->name());
notification->setTitle(device()->name());
notification->setText("Ping!");
notification->sendEvent();
return true;

View file

@ -60,7 +60,7 @@ KNotification* TelephonyPlugin::createNotification(const NetworkPackage& np)
//TODO: return NULL if !debug
type = "unknownEvent";
icon = "pda";
content = "Unknown notification type: " + event;
content = "Unknown telephony event: " + event;
}
qDebug() << "Creating notification with type:" << type;

View file

@ -120,9 +120,19 @@ void KdeConnectKcm::deviceSelected(const QModelIndex& current)
void KdeConnectKcm::trustedStateChanged(bool b)
{
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());
} 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()