Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add dbus adaptor classes for file manager #2550

Merged
merged 2 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions src/config/dbus/AccessControlAdaptor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// SPDX-FileCopyrightText: 2024 - 2025 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include "src/config/dbus/AccessControlAdaptor.h"

Check warning on line 5 in src/config/dbus/AccessControlAdaptor.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "src/config/dbus/AccessControlAdaptor.h" not found.

Check warning on line 5 in src/config/dbus/AccessControlAdaptor.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: "src/config/dbus/AccessControlAdaptor.h" not found.
#include <QtCore/QMetaObject>

Check warning on line 6 in src/config/dbus/AccessControlAdaptor.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtCore/QMetaObject> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 6 in src/config/dbus/AccessControlAdaptor.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QtCore/QMetaObject> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtCore/QByteArray>

Check warning on line 7 in src/config/dbus/AccessControlAdaptor.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtCore/QByteArray> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 7 in src/config/dbus/AccessControlAdaptor.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QtCore/QByteArray> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtCore/QList>

Check warning on line 8 in src/config/dbus/AccessControlAdaptor.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtCore/QList> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 8 in src/config/dbus/AccessControlAdaptor.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QtCore/QList> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtCore/QMap>

Check warning on line 9 in src/config/dbus/AccessControlAdaptor.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtCore/QMap> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 9 in src/config/dbus/AccessControlAdaptor.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QtCore/QMap> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtCore/QString>

Check warning on line 10 in src/config/dbus/AccessControlAdaptor.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtCore/QString> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 10 in src/config/dbus/AccessControlAdaptor.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QtCore/QString> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtCore/QStringList>

Check warning on line 11 in src/config/dbus/AccessControlAdaptor.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtCore/QStringList> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 11 in src/config/dbus/AccessControlAdaptor.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QtCore/QStringList> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtCore/QVariant>

Check warning on line 12 in src/config/dbus/AccessControlAdaptor.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtCore/QVariant> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 12 in src/config/dbus/AccessControlAdaptor.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QtCore/QVariant> not found. Please note: Cppcheck does not need standard library headers to get proper results.

/*
* Implementation of adaptor class AccessControlAdaptor
*/

AccessControlAdaptor::AccessControlAdaptor(QObject *parent)
: QDBusAbstractAdaptor(parent)
{
// constructor
setAutoRelaySignals(true);
}

AccessControlAdaptor::~AccessControlAdaptor()
{
// destructor
}

void AccessControlAdaptor::ChangeDiskPassword(const QString &oldPwd, const QString &newPwd)
{
// handle method call org.deepin.Filemanager.AccessControlManager.ChangeDiskPassword
QMetaObject::invokeMethod(parent(), "ChangeDiskPassword", Q_ARG(QString, oldPwd), Q_ARG(QString, newPwd));
}

bool AccessControlAdaptor::Chmod(const QString &path, uint mode)
{
// handle method call org.deepin.Filemanager.AccessControlManager.Chmod
bool out0;
QMetaObject::invokeMethod(parent(), "Chmod", Q_RETURN_ARG(bool, out0), Q_ARG(QString, path), Q_ARG(uint, mode));
return out0;
}

58 changes: 58 additions & 0 deletions src/config/dbus/AccessControlAdaptor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// SPDX-FileCopyrightText: 2024 - 2025 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#ifndef ACCESSCONTROLADAPTOR_H
#define ACCESSCONTROLADAPTOR_H

#include <QtCore/QObject>
#include <QtDBus/QtDBus>
QT_BEGIN_NAMESPACE
class QByteArray;
template<class T> class QList;
template<class Key, class Value> class QMap;
class QString;
class QStringList;
class QVariant;
QT_END_NAMESPACE

/*
* Adaptor class for interface org.deepin.Filemanager.AccessControlManager
*/
class AccessControlAdaptor: public QDBusAbstractAdaptor
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.deepin.Filemanager.AccessControlManager")
Q_CLASSINFO("D-Bus Introspection", ""
" <interface name=\"org.deepin.Filemanager.AccessControlManager\">\n"
" <signal name=\"DiskPasswordChecked\">\n"
" <arg direction=\"out\" type=\"i\" name=\"code\"/>\n"
" </signal>\n"
" <signal name=\"DiskPasswordChanged\">\n"
" <arg direction=\"out\" type=\"i\" name=\"code\"/>\n"
" </signal>\n"
" <method name=\"ChangeDiskPassword\">\n"
" <arg direction=\"in\" type=\"s\" name=\"oldPwd\"/>\n"
" <arg direction=\"in\" type=\"s\" name=\"newPwd\"/>\n"
" </method>\n"
" <method name=\"Chmod\">\n"
" <arg direction=\"out\" type=\"b\"/>\n"
" <arg direction=\"in\" type=\"s\" name=\"path\"/>\n"
" <arg direction=\"in\" type=\"u\" name=\"mode\"/>\n"
" </method>\n"
" </interface>\n"
"")
public:
AccessControlAdaptor(QObject *parent);
virtual ~AccessControlAdaptor();

public: // PROPERTIES
public Q_SLOTS: // METHODS
void ChangeDiskPassword(const QString &oldPwd, const QString &newPwd);
bool Chmod(const QString &path, uint mode);
Q_SIGNALS: // SIGNALS
void DiskPasswordChanged(int code);
void DiskPasswordChecked(int code);
};

#endif
87 changes: 87 additions & 0 deletions src/config/dbus/DeviceManagerAdaptor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// SPDX-FileCopyrightText: 2024 - 2025 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include "src/config/dbus/DeviceManagerAdaptor.h"

Check warning on line 5 in src/config/dbus/DeviceManagerAdaptor.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "src/config/dbus/DeviceManagerAdaptor.h" not found.

Check warning on line 5 in src/config/dbus/DeviceManagerAdaptor.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: "src/config/dbus/DeviceManagerAdaptor.h" not found.
#include <QtCore/QMetaObject>

Check warning on line 6 in src/config/dbus/DeviceManagerAdaptor.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtCore/QMetaObject> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 6 in src/config/dbus/DeviceManagerAdaptor.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QtCore/QMetaObject> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtCore/QByteArray>
#include <QtCore/QList>
#include <QtCore/QMap>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QVariant>

/*
* Implementation of adaptor class DeviceManagerAdaptor
*/

DeviceManagerAdaptor::DeviceManagerAdaptor(QObject *parent)
: QDBusAbstractAdaptor(parent)
{
// constructor
setAutoRelaySignals(true);
}

DeviceManagerAdaptor::~DeviceManagerAdaptor()
{
// destructor
}

void DeviceManagerAdaptor::DetachAllMountedDevices()
{
// handle method call org.deepin.Filemanager.Daemon.DeviceManager.DetachAllMountedDevices
QMetaObject::invokeMethod(parent(), "DetachAllMountedDevices");
}

void DeviceManagerAdaptor::DetachBlockDevice(const QString &id)
{
// handle method call org.deepin.Filemanager.Daemon.DeviceManager.DetachBlockDevice
QMetaObject::invokeMethod(parent(), "DetachBlockDevice", Q_ARG(QString, id));
}

void DeviceManagerAdaptor::DetachProtocolDevice(const QString &id)
{
// handle method call org.deepin.Filemanager.Daemon.DeviceManager.DetachProtocolDevice
QMetaObject::invokeMethod(parent(), "DetachProtocolDevice", Q_ARG(QString, id));
}

QStringList DeviceManagerAdaptor::GetBlockDevicesIdList(int opts)
{
// handle method call org.deepin.Filemanager.Daemon.DeviceManager.GetBlockDevicesIdList
QStringList out0;
QMetaObject::invokeMethod(parent(), "GetBlockDevicesIdList", Q_RETURN_ARG(QStringList, out0), Q_ARG(int, opts));
return out0;
}

QStringList DeviceManagerAdaptor::GetProtocolDevicesIdList()
{
// handle method call org.deepin.Filemanager.Daemon.DeviceManager.GetProtocolDevicesIdList
QStringList out0;
QMetaObject::invokeMethod(parent(), "GetProtocolDevicesIdList", Q_RETURN_ARG(QStringList, out0));
return out0;
}

bool DeviceManagerAdaptor::IsMonotorWorking()
{
// handle method call org.deepin.Filemanager.Daemon.DeviceManager.IsMonotorWorking
bool out0;
QMetaObject::invokeMethod(parent(), "IsMonotorWorking", Q_RETURN_ARG(bool, out0));
return out0;
}

QVariantMap DeviceManagerAdaptor::QueryBlockDeviceInfo(const QString &id, bool reload)
{
// handle method call org.deepin.Filemanager.Daemon.DeviceManager.QueryBlockDeviceInfo
QVariantMap out0;
QMetaObject::invokeMethod(parent(), "QueryBlockDeviceInfo", Q_RETURN_ARG(QVariantMap, out0), Q_ARG(QString, id), Q_ARG(bool, reload));
return out0;
}

QVariantMap DeviceManagerAdaptor::QueryProtocolDeviceInfo(const QString &id, bool reload)
{
// handle method call org.deepin.Filemanager.Daemon.DeviceManager.QueryProtocolDeviceInfo
QVariantMap out0;
QMetaObject::invokeMethod(parent(), "QueryProtocolDeviceInfo", Q_RETURN_ARG(QVariantMap, out0), Q_ARG(QString, id), Q_ARG(bool, reload));
return out0;
}

152 changes: 152 additions & 0 deletions src/config/dbus/DeviceManagerAdaptor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
// SPDX-FileCopyrightText: 2024 - 2025 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#ifndef DEVICEMANAGERADAPTOR_H
#define DEVICEMANAGERADAPTOR_H

#include <QtCore/QObject>
#include <QtDBus/QtDBus>
QT_BEGIN_NAMESPACE
class QByteArray;
template<class T> class QList;
template<class Key, class Value> class QMap;
class QString;
class QStringList;
class QVariant;
QT_END_NAMESPACE

/*
* Adaptor class for interface org.deepin.Filemanager.Daemon.DeviceManager
*/
class DeviceManagerAdaptor: public QDBusAbstractAdaptor
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.deepin.Filemanager.Daemon.DeviceManager")
Q_CLASSINFO("D-Bus Introspection", ""
" <interface name=\"org.deepin.Filemanager.Daemon.DeviceManager\">\n"
" <signal name=\"SizeUsedChanged\">\n"
" <arg direction=\"out\" type=\"s\" name=\"id\"/>\n"
" <arg direction=\"out\" type=\"x\" name=\"total\"/>\n"
" <arg direction=\"out\" type=\"x\" name=\"free\"/>\n"
" </signal>\n"
" <signal name=\"NotifyDeviceBusy\">\n"
" <arg direction=\"out\" type=\"s\" name=\"id\"/>\n"
" <arg direction=\"out\" type=\"s\" name=\"action\"/>\n"
" </signal>\n"
" <signal name=\"BlockDriveAdded\"/>\n"
" <signal name=\"BlockDriveRemoved\"/>\n"
" <signal name=\"BlockDeviceAdded\">\n"
" <arg direction=\"out\" type=\"s\" name=\"id\"/>\n"
" </signal>\n"
" <signal name=\"BlockDeviceRemoved\">\n"
" <arg direction=\"out\" type=\"s\" name=\"id\"/>\n"
" <arg direction=\"out\" type=\"s\" name=\"oldMpt\"/>\n"
" </signal>\n"
" <signal name=\"BlockDeviceFilesystemAdded\">\n"
" <arg direction=\"out\" type=\"s\" name=\"id\"/>\n"
" </signal>\n"
" <signal name=\"BlockDeviceFilesystemRemoved\">\n"
" <arg direction=\"out\" type=\"s\" name=\"id\"/>\n"
" </signal>\n"
" <signal name=\"BlockDeviceMounted\">\n"
" <arg direction=\"out\" type=\"s\" name=\"id\"/>\n"
" <arg direction=\"out\" type=\"s\" name=\"mountPoint\"/>\n"
" </signal>\n"
" <signal name=\"BlockDeviceUnmounted\">\n"
" <arg direction=\"out\" type=\"s\" name=\"id\"/>\n"
" <arg direction=\"out\" type=\"s\" name=\"oldMpt\"/>\n"
" </signal>\n"
" <signal name=\"BlockDevicePropertyChanged\">\n"
" <arg direction=\"out\" type=\"s\" name=\"id\"/>\n"
" <arg direction=\"out\" type=\"s\" name=\"property\"/>\n"
" <arg direction=\"out\" type=\"v\" name=\"value\"/>\n"
" </signal>\n"
" <signal name=\"BlockDeviceUnlocked\">\n"
" <arg direction=\"out\" type=\"s\" name=\"id\"/>\n"
" <arg direction=\"out\" type=\"s\" name=\"clearDeviceId\"/>\n"
" </signal>\n"
" <signal name=\"BlockDeviceLocked\">\n"
" <arg direction=\"out\" type=\"s\" name=\"id\"/>\n"
" </signal>\n"
" <signal name=\"ProtocolDeviceAdded\">\n"
" <arg direction=\"out\" type=\"s\" name=\"id\"/>\n"
" </signal>\n"
" <signal name=\"ProtocolDeviceRemoved\">\n"
" <arg direction=\"out\" type=\"s\" name=\"id\"/>\n"
" <arg direction=\"out\" type=\"s\" name=\"oldMpt\"/>\n"
" </signal>\n"
" <signal name=\"ProtocolDeviceMounted\">\n"
" <arg direction=\"out\" type=\"s\" name=\"id\"/>\n"
" <arg direction=\"out\" type=\"s\" name=\"mountPoint\"/>\n"
" </signal>\n"
" <signal name=\"ProtocolDeviceUnmounted\">\n"
" <arg direction=\"out\" type=\"s\" name=\"id\"/>\n"
" <arg direction=\"out\" type=\"s\" name=\"oldMpt\"/>\n"
" </signal>\n"
" <method name=\"IsMonotorWorking\">\n"
" <arg direction=\"out\" type=\"b\"/>\n"
" </method>\n"
" <method name=\"DetachBlockDevice\">\n"
" <arg direction=\"in\" type=\"s\" name=\"id\"/>\n"
" </method>\n"
" <method name=\"DetachProtocolDevice\">\n"
" <arg direction=\"in\" type=\"s\" name=\"id\"/>\n"
" </method>\n"
" <method name=\"DetachAllMountedDevices\"/>\n"
" <method name=\"GetBlockDevicesIdList\">\n"
" <arg direction=\"out\" type=\"as\"/>\n"
" <arg direction=\"in\" type=\"i\" name=\"opts\"/>\n"
" </method>\n"
" <method name=\"QueryBlockDeviceInfo\">\n"
" <arg direction=\"out\" type=\"a{sv}\"/>\n"
" <annotation value=\"QVariantMap\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
" <arg direction=\"in\" type=\"s\" name=\"id\"/>\n"
" <arg direction=\"in\" type=\"b\" name=\"reload\"/>\n"
" </method>\n"
" <method name=\"GetProtocolDevicesIdList\">\n"
" <arg direction=\"out\" type=\"as\"/>\n"
" </method>\n"
" <method name=\"QueryProtocolDeviceInfo\">\n"
" <arg direction=\"out\" type=\"a{sv}\"/>\n"
" <annotation value=\"QVariantMap\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
" <arg direction=\"in\" type=\"s\" name=\"id\"/>\n"
" <arg direction=\"in\" type=\"b\" name=\"reload\"/>\n"
" </method>\n"
" </interface>\n"
"")
public:
DeviceManagerAdaptor(QObject *parent);
virtual ~DeviceManagerAdaptor();

public: // PROPERTIES
public Q_SLOTS: // METHODS
void DetachAllMountedDevices();
void DetachBlockDevice(const QString &id);
void DetachProtocolDevice(const QString &id);
QStringList GetBlockDevicesIdList(int opts);
QStringList GetProtocolDevicesIdList();
bool IsMonotorWorking();
QVariantMap QueryBlockDeviceInfo(const QString &id, bool reload);
QVariantMap QueryProtocolDeviceInfo(const QString &id, bool reload);
Q_SIGNALS: // SIGNALS
void BlockDeviceAdded(const QString &id);
void BlockDeviceFilesystemAdded(const QString &id);
void BlockDeviceFilesystemRemoved(const QString &id);
void BlockDeviceLocked(const QString &id);
void BlockDeviceMounted(const QString &id, const QString &mountPoint);
void BlockDevicePropertyChanged(const QString &id, const QString &property, const QDBusVariant &value);
void BlockDeviceRemoved(const QString &id, const QString &oldMpt);
void BlockDeviceUnlocked(const QString &id, const QString &clearDeviceId);
void BlockDeviceUnmounted(const QString &id, const QString &oldMpt);
void BlockDriveAdded();
void BlockDriveRemoved();
void NotifyDeviceBusy(const QString &id, const QString &action);
void ProtocolDeviceAdded(const QString &id);
void ProtocolDeviceMounted(const QString &id, const QString &mountPoint);
void ProtocolDeviceRemoved(const QString &id, const QString &oldMpt);
void ProtocolDeviceUnmounted(const QString &id, const QString &oldMpt);
void SizeUsedChanged(const QString &id, qlonglong total, qlonglong free);
};

#endif
Loading
Loading