Commit d8086f29 authored by piggz's avatar piggz

[media] Add env variable for external media

Allow the environment variable HYBRIS_EXTERNAL_MEDIA_EXPRESSION
to define the regular expression to be used for external media
detection.
parent 26cc3aef
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#include "logging_p.h" #include "logging_p.h"
#include <QFile> #include <QFile>
#include <QRegularExpression> #include <QtGlobal>
#include <blkid/blkid.h> #include <blkid/blkid.h>
#include <linux/limits.h> #include <linux/limits.h>
...@@ -45,14 +45,18 @@ ...@@ -45,14 +45,18 @@
static const auto userName = QString(qgetenv("USER")); static const auto userName = QString(qgetenv("USER"));
static const auto externalMountPath = QString("/run/media/%1/").arg(userName); static const auto externalMountPath = QString("/run/media/%1/").arg(userName);
static const QRegularExpression externalMedia(QString("^%1$").arg(externalDevice));
PartitionManagerPrivate *PartitionManagerPrivate::sharedInstance = nullptr; PartitionManagerPrivate *PartitionManagerPrivate::sharedInstance = nullptr;
PartitionManagerPrivate::PartitionManagerPrivate() PartitionManagerPrivate::PartitionManagerPrivate()
{ {
Q_ASSERT(!sharedInstance); Q_ASSERT(!sharedInstance);
QString env = qgetenv("HYBRIS_EXTERNAL_MEDIA_EXPRESSION");
if (env.isEmpty()) {
env = externalDevice;
}
externalMedia = QRegularExpression(QString("^%1$").arg(env));
sharedInstance = this; sharedInstance = this;
m_udisksMonitor.reset(new UDisks2::Monitor(this)); m_udisksMonitor.reset(new UDisks2::Monitor(this));
connect(m_udisksMonitor.data(), &UDisks2::Monitor::status, this, &PartitionManagerPrivate::status); connect(m_udisksMonitor.data(), &UDisks2::Monitor::status, this, &PartitionManagerPrivate::status);
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <QMap> #include <QMap>
#include <QVector> #include <QVector>
#include <QScopedPointer> #include <QScopedPointer>
#include <QRegularExpression>
namespace UDisks2 { namespace UDisks2 {
class Monitor; class Monitor;
...@@ -77,6 +78,8 @@ public: ...@@ -77,6 +78,8 @@ public:
QStringList supportedFileSystems() const; QStringList supportedFileSystems() const;
bool externalStoragesPopulated() const; bool externalStoragesPopulated() const;
QRegularExpression externalMedia;
signals: signals:
void partitionChanged(const Partition &partition); void partitionChanged(const Partition &partition);
void partitionAdded(const Partition &partition); void partitionAdded(const Partition &partition);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment