mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
add disk mount dbus
Change-Id: I08ae8daed9aec3d005b50575a4571a9df0ffec90
This commit is contained in:
parent
429abf7505
commit
3fdb1db032
31
plugins/disk-mount/dbus/com.deepin.daemon.DiskMount.xml
Normal file
31
plugins/disk-mount/dbus/com.deepin.daemon.DiskMount.xml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<interface name="com.deepin.daemon.DiskMount">
|
||||||
|
<method name="Eject">
|
||||||
|
<arg type="s" direction="in"></arg>
|
||||||
|
</method>
|
||||||
|
<method name="ListDisk">
|
||||||
|
<arg type="a(ssssssbbtt)" direction="out"></arg>
|
||||||
|
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="DiskInfoList"/>
|
||||||
|
</method>
|
||||||
|
<method name="Mount">
|
||||||
|
<arg type="s" direction="in"></arg>
|
||||||
|
</method>
|
||||||
|
<method name="QueryDisk">
|
||||||
|
<arg type="s" direction="in"></arg>
|
||||||
|
<arg type="(ssssssbbtt)" direction="out"></arg>
|
||||||
|
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="DiskInfo"/>
|
||||||
|
</method>
|
||||||
|
<method name="Unmount">
|
||||||
|
<arg type="s" direction="in"></arg>
|
||||||
|
</method>
|
||||||
|
<signal name="Changed">
|
||||||
|
<arg type="i"></arg>
|
||||||
|
<arg type="s"></arg>
|
||||||
|
</signal>
|
||||||
|
<signal name="Error">
|
||||||
|
<arg type="s"></arg>
|
||||||
|
<arg type="s"></arg>
|
||||||
|
</signal>
|
||||||
|
<property name="DiskList" type="a(ssssssbbtt)" access="read">
|
||||||
|
<annotation name="org.qtproject.QtDBus.QtTypeName" value="DiskInfoList"/>
|
||||||
|
</property>
|
||||||
|
</interface>
|
30
plugins/disk-mount/dbus/dbusdiskmount.cpp
Normal file
30
plugins/disk-mount/dbus/dbusdiskmount.cpp
Normal file
@ -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)));
|
||||||
|
}
|
||||||
|
|
113
plugins/disk-mount/dbus/dbusdiskmount.h
Normal file
113
plugins/disk-mount/dbus/dbusdiskmount.h
Normal file
@ -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 <QtCore/QObject>
|
||||||
|
#include <QtCore/QByteArray>
|
||||||
|
#include <QtCore/QList>
|
||||||
|
#include <QtCore/QMap>
|
||||||
|
#include <QtCore/QString>
|
||||||
|
#include <QtCore/QStringList>
|
||||||
|
#include <QtCore/QVariant>
|
||||||
|
#include <QtDBus/QtDBus>
|
||||||
|
|
||||||
|
#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<QVariant> 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<QVariantMap>(arguments.at(1).value<QDBusArgument>());
|
||||||
|
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<QVariant> argumentList;
|
||||||
|
argumentList << QVariant::fromValue(in0);
|
||||||
|
return asyncCallWithArgumentList(QStringLiteral("Eject"), argumentList);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QDBusPendingReply<DiskInfoList> ListDisk()
|
||||||
|
{
|
||||||
|
QList<QVariant> argumentList;
|
||||||
|
return asyncCallWithArgumentList(QStringLiteral("ListDisk"), argumentList);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QDBusPendingReply<> Mount(const QString &in0)
|
||||||
|
{
|
||||||
|
QList<QVariant> argumentList;
|
||||||
|
argumentList << QVariant::fromValue(in0);
|
||||||
|
return asyncCallWithArgumentList(QStringLiteral("Mount"), argumentList);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QDBusPendingReply<DiskInfo> QueryDisk(const QString &in0)
|
||||||
|
{
|
||||||
|
QList<QVariant> argumentList;
|
||||||
|
argumentList << QVariant::fromValue(in0);
|
||||||
|
return asyncCallWithArgumentList(QStringLiteral("QueryDisk"), argumentList);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QDBusPendingReply<> Unmount(const QString &in0)
|
||||||
|
{
|
||||||
|
QList<QVariant> 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
|
65
plugins/disk-mount/dbus/variant/diskinfo.cpp
Normal file
65
plugins/disk-mount/dbus/variant/diskinfo.cpp
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
#include "diskinfo.h"
|
||||||
|
|
||||||
|
DiskInfo::DiskInfo()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DiskInfo::registerMetaType()
|
||||||
|
{
|
||||||
|
qRegisterMetaType<DiskInfo>("DiskInfo");
|
||||||
|
qDBusRegisterMetaType<DiskInfo>();
|
||||||
|
|
||||||
|
qRegisterMetaType<DiskInfoList>("DiskInfoList");
|
||||||
|
qDBusRegisterMetaType<DiskInfoList>();
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
41
plugins/disk-mount/dbus/variant/diskinfo.h
Normal file
41
plugins/disk-mount/dbus/variant/diskinfo.h
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#ifndef DISKINFO_H
|
||||||
|
#define DISKINFO_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QDataStream>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QtDBus>
|
||||||
|
|
||||||
|
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<DiskInfo> DiskInfoList;
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(DiskInfo)
|
||||||
|
Q_DECLARE_METATYPE(DiskInfoList)
|
||||||
|
|
||||||
|
#endif // DISKINFO_H
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
include(../../interfaces/interfaces.pri)
|
include(../../interfaces/interfaces.pri)
|
||||||
|
|
||||||
QT += widgets svg
|
QT += widgets svg dbus
|
||||||
TEMPLATE = lib
|
TEMPLATE = lib
|
||||||
CONFIG += plugin c++11 link_pkgconfig
|
CONFIG += plugin c++11 link_pkgconfig
|
||||||
PKGCONFIG +=
|
PKGCONFIG +=
|
||||||
@ -11,10 +11,14 @@ DESTDIR = $$_PRO_FILE_PWD_/../
|
|||||||
DISTFILES += disk-mount.json
|
DISTFILES += disk-mount.json
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
diskmountplugin.h
|
diskmountplugin.h \
|
||||||
|
dbus/dbusdiskmount.h \
|
||||||
|
dbus/variant/diskinfo.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
diskmountplugin.cpp
|
diskmountplugin.cpp \
|
||||||
|
dbus/dbusdiskmount.cpp \
|
||||||
|
dbus/variant/diskinfo.cpp
|
||||||
|
|
||||||
target.path = $${PREFIX}/lib/dde-dock/plugins/
|
target.path = $${PREFIX}/lib/dde-dock/plugins/
|
||||||
INSTALLS += target
|
INSTALLS += target
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
#include "diskmountplugin.h"
|
#include "diskmountplugin.h"
|
||||||
|
|
||||||
DiskMountPlugin::DiskMountPlugin(QObject *parent)
|
DiskMountPlugin::DiskMountPlugin(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent),
|
||||||
{
|
|
||||||
|
|
||||||
|
m_diskInter(new DBusDiskMount(this))
|
||||||
|
{
|
||||||
|
qDebug() << m_diskInter->diskList();
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString DiskMountPlugin::pluginName() const
|
const QString DiskMountPlugin::pluginName() const
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define DISKMOUNTPLUGIN_H
|
#define DISKMOUNTPLUGIN_H
|
||||||
|
|
||||||
#include "pluginsiteminterface.h"
|
#include "pluginsiteminterface.h"
|
||||||
|
#include "dbus/dbusdiskmount.h"
|
||||||
|
|
||||||
class DiskMountPlugin : public QObject, PluginsItemInterface
|
class DiskMountPlugin : public QObject, PluginsItemInterface
|
||||||
{
|
{
|
||||||
@ -16,6 +17,9 @@ public:
|
|||||||
void init(PluginProxyInterface *proxyInter);
|
void init(PluginProxyInterface *proxyInter);
|
||||||
|
|
||||||
QWidget *itemWidget(const QString &itemKey);
|
QWidget *itemWidget(const QString &itemKey);
|
||||||
|
|
||||||
|
private:
|
||||||
|
DBusDiskMount *m_diskInter;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DISKMOUNTPLUGIN_H
|
#endif // DISKMOUNTPLUGIN_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user