fix code style
This commit is contained in:
parent
cc6a99ef92
commit
0172f7265b
|
@ -11,14 +11,14 @@
|
||||||
#include "dbus/udisks2drive.h"
|
#include "dbus/udisks2drive.h"
|
||||||
#include "dbus/udisks2job.h"
|
#include "dbus/udisks2job.h"
|
||||||
|
|
||||||
const QString Udisks2Lister::udisks2service_ = "org.freedesktop.UDisks2";
|
constexpr char Udisks2Lister::udisks2_service_[];
|
||||||
|
|
||||||
Udisks2Lister::Udisks2Lister() {
|
Udisks2Lister::Udisks2Lister() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Udisks2Lister::~Udisks2Lister() {
|
Udisks2Lister::~Udisks2Lister() {
|
||||||
qLog(Debug) << __PRETTY_FUNCTION__;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList Udisks2Lister::DeviceUniqueIDs() {
|
QStringList Udisks2Lister::DeviceUniqueIDs() {
|
||||||
|
@ -95,7 +95,7 @@ void Udisks2Lister::UnmountDevice(const QString &id) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
OrgFreedesktopUDisks2FilesystemInterface filesystem(
|
OrgFreedesktopUDisks2FilesystemInterface filesystem(
|
||||||
udisks2service_,
|
udisks2_service_,
|
||||||
device_data_[id].dbus_path,
|
device_data_[id].dbus_path,
|
||||||
QDBusConnection::systemBus());
|
QDBusConnection::systemBus());
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ void Udisks2Lister::UnmountDevice(const QString &id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
OrgFreedesktopUDisks2DriveInterface drive(
|
OrgFreedesktopUDisks2DriveInterface drive(
|
||||||
udisks2service_,
|
udisks2_service_,
|
||||||
device_data_[id].dbus_drive_path,
|
device_data_[id].dbus_drive_path,
|
||||||
QDBusConnection::systemBus());
|
QDBusConnection::systemBus());
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ void Udisks2Lister::UpdateDeviceFreeSpace(const QString &id) {
|
||||||
|
|
||||||
void Udisks2Lister::Init() {
|
void Udisks2Lister::Init() {
|
||||||
udisks2_interface_.reset(new OrgFreedesktopDBusObjectManagerInterface(
|
udisks2_interface_.reset(new OrgFreedesktopDBusObjectManagerInterface(
|
||||||
udisks2service_,
|
udisks2_service_,
|
||||||
"/org/freedesktop/UDisks2",
|
"/org/freedesktop/UDisks2",
|
||||||
QDBusConnection::systemBus()));
|
QDBusConnection::systemBus()));
|
||||||
|
|
||||||
|
@ -178,18 +178,18 @@ void Udisks2Lister::DBusInterfaceAdded(const QDBusObjectPath &path,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
std::shared_ptr<OrgFreedesktopUDisks2JobInterface> job = std::make_shared<OrgFreedesktopUDisks2JobInterface>(
|
std::shared_ptr<OrgFreedesktopUDisks2JobInterface> job = std::make_shared<OrgFreedesktopUDisks2JobInterface>(
|
||||||
udisks2service_,
|
udisks2_service_,
|
||||||
path.path(),
|
path.path(),
|
||||||
QDBusConnection::systemBus());
|
QDBusConnection::systemBus());
|
||||||
|
|
||||||
if (!job->isValid())
|
if (!job->isValid())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
bool isMountJob = false;
|
bool is_mount_job = false;
|
||||||
if (job->operation() == "filesystem-mount")
|
if (job->operation() == "filesystem-mount")
|
||||||
isMountJob = true;
|
is_mount_job = true;
|
||||||
else if (job->operation() == "filesystem-unmount")
|
else if (job->operation() == "filesystem-unmount")
|
||||||
isMountJob = false;
|
is_mount_job = false;
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -203,10 +203,10 @@ void Udisks2Lister::DBusInterfaceAdded(const QDBusObjectPath &path,
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&jobs_lock_);
|
QMutexLocker locker(&jobs_lock_);
|
||||||
qLog(Debug) << "Adding pending job | DBus Path = " << job->path()
|
qLog(Debug) << "Adding pending job | DBus Path = " << job->path()
|
||||||
<< " | IsMountJob = " << isMountJob
|
<< " | IsMountJob = " << is_mount_job
|
||||||
<< " | First partition = " << mountedPartitions.at(0).path();
|
<< " | First partition = " << mountedPartitions.at(0).path();
|
||||||
mounting_jobs_[path].dbus_interface = job;
|
mounting_jobs_[path].dbus_interface = job;
|
||||||
mounting_jobs_[path].isMount = isMountJob;
|
mounting_jobs_[path].is_mount = is_mount_job;
|
||||||
mounting_jobs_[path].mounted_partitions = mountedPartitions;
|
mounting_jobs_[path].mounted_partitions = mountedPartitions;
|
||||||
connect(job.get(), SIGNAL(Completed(bool, const QString&)),
|
connect(job.get(), SIGNAL(Completed(bool, const QString&)),
|
||||||
SLOT(JobCompleted(bool, const QString&)));
|
SLOT(JobCompleted(bool, const QString&)));
|
||||||
|
@ -271,7 +271,7 @@ void Udisks2Lister::JobCompleted(bool success, const QString &message) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
qLog(Debug) << "Pending Job Completed | Path = " << job->path()
|
qLog(Debug) << "Pending Job Completed | Path = " << job->path()
|
||||||
<< " | Mount? = " << mounting_jobs_[jobPath].isMount
|
<< " | Mount? = " << mounting_jobs_[jobPath].is_mount
|
||||||
<< " | Success = " << success;
|
<< " | Success = " << success;
|
||||||
|
|
||||||
for (const auto &mountedObject : mounting_jobs_[jobPath].mounted_partitions) {
|
for (const auto &mountedObject : mounting_jobs_[jobPath].mounted_partitions) {
|
||||||
|
@ -279,7 +279,7 @@ void Udisks2Lister::JobCompleted(bool success, const QString &message) {
|
||||||
if (partitionData.dbus_path.isEmpty())
|
if (partitionData.dbus_path.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
mounting_jobs_[jobPath].isMount ?
|
mounting_jobs_[jobPath].is_mount ?
|
||||||
HandleFinishedMountJob(partitionData) : HandleFinishedUnmountJob(partitionData, mountedObject);
|
HandleFinishedMountJob(partitionData) : HandleFinishedUnmountJob(partitionData, mountedObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -316,11 +316,11 @@ void Udisks2Lister::HandleFinishedUnmountJob(const Udisks2Lister::PartitionData
|
||||||
Udisks2Lister::PartitionData Udisks2Lister::ReadPartitionData(const QDBusObjectPath &path) {
|
Udisks2Lister::PartitionData Udisks2Lister::ReadPartitionData(const QDBusObjectPath &path) {
|
||||||
PartitionData result;
|
PartitionData result;
|
||||||
OrgFreedesktopUDisks2FilesystemInterface filesystem(
|
OrgFreedesktopUDisks2FilesystemInterface filesystem(
|
||||||
udisks2service_,
|
udisks2_service_,
|
||||||
path.path(),
|
path.path(),
|
||||||
QDBusConnection::systemBus());
|
QDBusConnection::systemBus());
|
||||||
OrgFreedesktopUDisks2BlockInterface block(
|
OrgFreedesktopUDisks2BlockInterface block(
|
||||||
udisks2service_,
|
udisks2_service_,
|
||||||
path.path(),
|
path.path(),
|
||||||
QDBusConnection::systemBus());
|
QDBusConnection::systemBus());
|
||||||
|
|
||||||
|
@ -329,7 +329,7 @@ Udisks2Lister::PartitionData Udisks2Lister::ReadPartitionData(const QDBusObjectP
|
||||||
&& !filesystem.mountPoints().empty()) {
|
&& !filesystem.mountPoints().empty()) {
|
||||||
|
|
||||||
OrgFreedesktopUDisks2DriveInterface drive(
|
OrgFreedesktopUDisks2DriveInterface drive(
|
||||||
udisks2service_,
|
udisks2_service_,
|
||||||
block.drive().path(),
|
block.drive().path(),
|
||||||
QDBusConnection::systemBus());
|
QDBusConnection::systemBus());
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
#pragma once
|
#ifndef UDISKS2LISTER_H
|
||||||
|
#define UDISKS2LISTER_H
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include <QReadWriteLock>
|
|
||||||
#include <QMutex>
|
|
||||||
#include <QStringList>
|
|
||||||
#include <QDBusArgument>
|
#include <QDBusArgument>
|
||||||
|
#include <QMutex>
|
||||||
|
#include <QReadWriteLock>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
#include "devicelister.h"
|
#include "devicelister.h"
|
||||||
#include "dbus/metatypes.h"
|
#include "dbus/metatypes.h"
|
||||||
|
@ -20,24 +21,24 @@ public:
|
||||||
Udisks2Lister();
|
Udisks2Lister();
|
||||||
~Udisks2Lister();
|
~Udisks2Lister();
|
||||||
|
|
||||||
QStringList DeviceUniqueIDs();
|
QStringList DeviceUniqueIDs() override;
|
||||||
QVariantList DeviceIcons(const QString &id);
|
QVariantList DeviceIcons(const QString &id) override;
|
||||||
QString DeviceManufacturer(const QString &id);
|
QString DeviceManufacturer(const QString &id) override;
|
||||||
QString DeviceModel(const QString &id);
|
QString DeviceModel(const QString &id) override;
|
||||||
quint64 DeviceCapacity(const QString &id);
|
quint64 DeviceCapacity(const QString &id) override;
|
||||||
quint64 DeviceFreeSpace(const QString &id);
|
quint64 DeviceFreeSpace(const QString &id) override;
|
||||||
QVariantMap DeviceHardwareInfo(const QString &id);
|
QVariantMap DeviceHardwareInfo(const QString &id) override;
|
||||||
|
|
||||||
QString MakeFriendlyName(const QString &id);
|
QString MakeFriendlyName(const QString &id) override;
|
||||||
QList<QUrl> MakeDeviceUrls(const QString &id);
|
QList<QUrl> MakeDeviceUrls(const QString &id) override;
|
||||||
|
|
||||||
void UnmountDevice(const QString &id);
|
void UnmountDevice(const QString &id) override;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void UpdateDeviceFreeSpace(const QString &id);
|
void UpdateDeviceFreeSpace(const QString &id) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void Init();
|
void Init() override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void DBusInterfaceAdded(const QDBusObjectPath &path, const InterfacesAndProperties &ifaces);
|
void DBusInterfaceAdded(const QDBusObjectPath &path, const InterfacesAndProperties &ifaces);
|
||||||
|
@ -50,7 +51,7 @@ private:
|
||||||
QList<QDBusObjectPath> GetMountedPartitionsFromDBusArgument(const QDBusArgument &input);
|
QList<QDBusObjectPath> GetMountedPartitionsFromDBusArgument(const QDBusArgument &input);
|
||||||
|
|
||||||
struct Udisks2Job {
|
struct Udisks2Job {
|
||||||
bool isMount = true;
|
bool is_mount = true;
|
||||||
QList<QDBusObjectPath> mounted_partitions;
|
QList<QDBusObjectPath> mounted_partitions;
|
||||||
std::shared_ptr<OrgFreedesktopUDisks2JobInterface> dbus_interface;
|
std::shared_ptr<OrgFreedesktopUDisks2JobInterface> dbus_interface;
|
||||||
};
|
};
|
||||||
|
@ -89,5 +90,7 @@ private:
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<OrgFreedesktopDBusObjectManagerInterface> udisks2_interface_;
|
std::unique_ptr<OrgFreedesktopDBusObjectManagerInterface> udisks2_interface_;
|
||||||
|
|
||||||
static const QString udisks2service_;
|
static constexpr char udisks2_service_[] = "org.freedesktop.UDisks2";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif // UDISKS2LISTER_H
|
||||||
|
|
Loading…
Reference in New Issue