diff --git a/plugins/disk-mount/dbus/com.deepin.daemon.DiskMount.xml b/plugins/disk-mount/dbus/com.deepin.daemon.DiskMount.xml new file mode 100644 index 000000000..f0ad16d00 --- /dev/null +++ b/plugins/disk-mount/dbus/com.deepin.daemon.DiskMount.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/disk-mount/dbus/dbusdiskmount.cpp b/plugins/disk-mount/dbus/dbusdiskmount.cpp new file mode 100644 index 000000000..faa781e8f --- /dev/null +++ b/plugins/disk-mount/dbus/dbusdiskmount.cpp @@ -0,0 +1,30 @@ +/* + * This file was generated by qdbusxml2cpp version 0.8 + * Command line was: qdbusxml2cpp -c DBusDiskMount -p dbusdiskmount com.deepin.daemon.DiskMount.xml + * + * qdbusxml2cpp is Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * This file may have been hand-edited. Look for HAND-EDIT comments + * before re-generating it. + */ + +#include "dbusdiskmount.h" + +/* + * Implementation of interface class DBusDiskMount + */ + +DBusDiskMount::DBusDiskMount(QObject *parent) + : QDBusAbstractInterface("com.deepin.daemon.DiskMount", "/com/deepin/daemon/DiskMount", staticInterfaceName(), QDBusConnection::sessionBus(), parent) +{ + DiskInfo::registerMetaType(); + + QDBusConnection::sessionBus().connect(this->service(), this->path(), "org.freedesktop.DBus.Properties", "PropertiesChanged","sa{sv}as", this, SLOT(__propertyChanged__(QDBusMessage))); +} + +DBusDiskMount::~DBusDiskMount() +{ + QDBusConnection::sessionBus().disconnect(service(), path(), "org.freedesktop.DBus.Properties", "PropertiesChanged", "sa{sv}as", this, SLOT(propertyChanged(QDBusMessage))); +} + diff --git a/plugins/disk-mount/dbus/dbusdiskmount.h b/plugins/disk-mount/dbus/dbusdiskmount.h new file mode 100644 index 000000000..7a121f35d --- /dev/null +++ b/plugins/disk-mount/dbus/dbusdiskmount.h @@ -0,0 +1,113 @@ +/* + * This file was generated by qdbusxml2cpp version 0.8 + * Command line was: qdbusxml2cpp -c DBusDiskMount -p dbusdiskmount com.deepin.daemon.DiskMount.xml + * + * qdbusxml2cpp is Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * Do not edit! All changes made to it will be lost. + */ + +#ifndef DBUSDISKMOUNT_H_1468893654 +#define DBUSDISKMOUNT_H_1468893654 + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "variant/diskinfo.h" + +/* + * Proxy class for interface com.deepin.daemon.DiskMount + */ +class DBusDiskMount: public QDBusAbstractInterface +{ + Q_OBJECT + + Q_SLOT void __propertyChanged__(const QDBusMessage& msg) + { + QList arguments = msg.arguments(); + if (3 != arguments.count()) + return; + QString interfaceName = msg.arguments().at(0).toString(); + if (interfaceName !="com.deepin.daemon.DiskMount") + return; + QVariantMap changedProps = qdbus_cast(arguments.at(1).value()); + foreach(const QString &prop, changedProps.keys()) { + const QMetaObject* self = metaObject(); + for (int i=self->propertyOffset(); i < self->propertyCount(); ++i) { + QMetaProperty p = self->property(i); + if (p.name() == prop) { + Q_EMIT p.notifySignal().invoke(this); + } + } + } + } +public: + static inline const char *staticInterfaceName() + { return "com.deepin.daemon.DiskMount"; } + +public: + explicit DBusDiskMount(QObject *parent = 0); + + ~DBusDiskMount(); + + Q_PROPERTY(DiskInfoList DiskList READ diskList NOTIFY DiskListChanged) + inline DiskInfoList diskList() const + { return qvariant_cast< DiskInfoList >(property("DiskList")); } + +public Q_SLOTS: // METHODS + inline QDBusPendingReply<> Eject(const QString &in0) + { + QList argumentList; + argumentList << QVariant::fromValue(in0); + return asyncCallWithArgumentList(QStringLiteral("Eject"), argumentList); + } + + inline QDBusPendingReply ListDisk() + { + QList argumentList; + return asyncCallWithArgumentList(QStringLiteral("ListDisk"), argumentList); + } + + inline QDBusPendingReply<> Mount(const QString &in0) + { + QList argumentList; + argumentList << QVariant::fromValue(in0); + return asyncCallWithArgumentList(QStringLiteral("Mount"), argumentList); + } + + inline QDBusPendingReply QueryDisk(const QString &in0) + { + QList argumentList; + argumentList << QVariant::fromValue(in0); + return asyncCallWithArgumentList(QStringLiteral("QueryDisk"), argumentList); + } + + inline QDBusPendingReply<> Unmount(const QString &in0) + { + QList argumentList; + argumentList << QVariant::fromValue(in0); + return asyncCallWithArgumentList(QStringLiteral("Unmount"), argumentList); + } + +Q_SIGNALS: // SIGNALS + void Changed(int in0, const QString &in1); + void Error(const QString &in0, const QString &in1); +// begin property changed signals +void DiskListChanged(); +}; + +namespace com { + namespace deepin { + namespace daemon { + typedef ::DBusDiskMount DiskMount; + } + } +} +#endif diff --git a/plugins/disk-mount/dbus/variant/diskinfo.cpp b/plugins/disk-mount/dbus/variant/diskinfo.cpp new file mode 100644 index 000000000..ac3d23e4e --- /dev/null +++ b/plugins/disk-mount/dbus/variant/diskinfo.cpp @@ -0,0 +1,65 @@ +#include "diskinfo.h" + +DiskInfo::DiskInfo() +{ + +} + +void DiskInfo::registerMetaType() +{ + qRegisterMetaType("DiskInfo"); + qDBusRegisterMetaType(); + + qRegisterMetaType("DiskInfoList"); + qDBusRegisterMetaType(); +} + +QDebug operator<<(QDebug debug, const DiskInfo &info) +{ + debug << info.m_id << info.m_name << info.m_type << info.m_path << info.m_mountPoint << info.m_icon; + debug << '\t' << info.m_unmountable << '\t' << info.m_ejectable; + debug << '\t' << info.m_usedSize << '\t' << info.m_totalSize; + debug << endl; + + return debug; +} + +const QDataStream &operator>>(QDataStream &args, DiskInfo &info) +{ + args >> info.m_id >> info.m_name >> info.m_type >> info.m_path >> info.m_mountPoint >> info.m_icon; + args >> info.m_unmountable >> info.m_ejectable; + args >> info.m_usedSize >> info.m_totalSize; + + return args; +} + +const QDBusArgument &operator>>(const QDBusArgument &args, DiskInfo &info) +{ + args.beginStructure(); + args >> info.m_id >> info.m_name >> info.m_type >> info.m_path >> info.m_mountPoint >> info.m_icon; + args >> info.m_unmountable >> info.m_ejectable; + args >> info.m_usedSize >> info.m_totalSize; + args.endStructure(); + + return args; +} + +QDataStream &operator<<(QDataStream &args, const DiskInfo &info) +{ + args << info.m_id << info.m_name << info.m_type << info.m_path << info.m_mountPoint << info.m_icon; + args << info.m_unmountable << info.m_ejectable; + args << info.m_usedSize << info.m_totalSize; + + return args; +} + +QDBusArgument &operator<<(QDBusArgument &args, const DiskInfo &info) +{ + args.beginStructure(); + args << info.m_id << info.m_name << info.m_type << info.m_path << info.m_mountPoint << info.m_icon; + args << info.m_unmountable << info.m_ejectable; + args << info.m_usedSize << info.m_totalSize; + args.endStructure(); + + return args; +} diff --git a/plugins/disk-mount/dbus/variant/diskinfo.h b/plugins/disk-mount/dbus/variant/diskinfo.h new file mode 100644 index 000000000..a06dc8844 --- /dev/null +++ b/plugins/disk-mount/dbus/variant/diskinfo.h @@ -0,0 +1,41 @@ +#ifndef DISKINFO_H +#define DISKINFO_H + +#include +#include +#include +#include + +class DiskInfo +{ +public: + DiskInfo(); + static void registerMetaType(); + + friend QDebug operator<<(QDebug debug, const DiskInfo &info); + friend QDBusArgument &operator<<(QDBusArgument &args, const DiskInfo &info); + friend QDataStream &operator<<(QDataStream &args, const DiskInfo &info); + friend const QDBusArgument &operator>>(const QDBusArgument &args, DiskInfo &info); + friend const QDataStream &operator>>(QDataStream &args, DiskInfo &info); + +public: + QString m_id; + QString m_name; + QString m_type; + QString m_path; + QString m_mountPoint; + QString m_icon; + + bool m_unmountable; + bool m_ejectable; + + quint64 m_usedSize; + quint64 m_totalSize; +}; + +typedef QList DiskInfoList; + +Q_DECLARE_METATYPE(DiskInfo) +Q_DECLARE_METATYPE(DiskInfoList) + +#endif // DISKINFO_H diff --git a/plugins/disk-mount/disk-mount.pro b/plugins/disk-mount/disk-mount.pro index 8ca5ac817..e70409fe2 100644 --- a/plugins/disk-mount/disk-mount.pro +++ b/plugins/disk-mount/disk-mount.pro @@ -1,7 +1,7 @@ include(../../interfaces/interfaces.pri) -QT += widgets svg +QT += widgets svg dbus TEMPLATE = lib CONFIG += plugin c++11 link_pkgconfig PKGCONFIG += @@ -11,10 +11,14 @@ DESTDIR = $$_PRO_FILE_PWD_/../ DISTFILES += disk-mount.json HEADERS += \ - diskmountplugin.h + diskmountplugin.h \ + dbus/dbusdiskmount.h \ + dbus/variant/diskinfo.h SOURCES += \ - diskmountplugin.cpp + diskmountplugin.cpp \ + dbus/dbusdiskmount.cpp \ + dbus/variant/diskinfo.cpp target.path = $${PREFIX}/lib/dde-dock/plugins/ INSTALLS += target diff --git a/plugins/disk-mount/diskmountplugin.cpp b/plugins/disk-mount/diskmountplugin.cpp index 58d27aee4..2c63bd473 100644 --- a/plugins/disk-mount/diskmountplugin.cpp +++ b/plugins/disk-mount/diskmountplugin.cpp @@ -1,9 +1,11 @@ #include "diskmountplugin.h" DiskMountPlugin::DiskMountPlugin(QObject *parent) - : QObject(parent) -{ + : QObject(parent), + m_diskInter(new DBusDiskMount(this)) +{ + qDebug() << m_diskInter->diskList(); } const QString DiskMountPlugin::pluginName() const diff --git a/plugins/disk-mount/diskmountplugin.h b/plugins/disk-mount/diskmountplugin.h index 71784d10a..4866c22fa 100644 --- a/plugins/disk-mount/diskmountplugin.h +++ b/plugins/disk-mount/diskmountplugin.h @@ -2,6 +2,7 @@ #define DISKMOUNTPLUGIN_H #include "pluginsiteminterface.h" +#include "dbus/dbusdiskmount.h" class DiskMountPlugin : public QObject, PluginsItemInterface { @@ -16,6 +17,9 @@ public: void init(PluginProxyInterface *proxyInter); QWidget *itemWidget(const QString &itemKey); + +private: + DBusDiskMount *m_diskInter; }; #endif // DISKMOUNTPLUGIN_H