Commit 32b45729 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 34793172
......@@ -35,7 +35,7 @@
#include "logging_p.h"
#include <QFile>
#include <QRegularExpression>
#include <QtGlobal>
#include <blkid/blkid.h>
#include <linux/limits.h>
......@@ -45,14 +45,18 @@
static const auto userName = QString(qgetenv("USER"));
static const auto externalMountPath = QString("/run/media/%1/").arg(userName);
static const QRegularExpression externalMedia(QString("^%1$").arg(externalDevice));
PartitionManagerPrivate *PartitionManagerPrivate::sharedInstance = nullptr;
PartitionManagerPrivate::PartitionManagerPrivate()
{
Q_ASSERT(!sharedInstance);
QString env = qgetenv("HYBRIS_EXTERNAL_MEDIA_EXPRESSION");
if (env.isEmpty()) {
env = externalDevice;
}
externalMedia = QRegularExpression(QString("^%1$").arg(env));
sharedInstance = this;
m_udisksMonitor.reset(new UDisks2::Monitor(this));
connect(m_udisksMonitor.data(), &UDisks2::Monitor::status, this, &PartitionManagerPrivate::status);
......
......@@ -38,6 +38,7 @@
#include <QMap>
#include <QVector>
#include <QScopedPointer>
#include <QRegularExpression>
namespace UDisks2 {
class Monitor;
......@@ -77,6 +78,8 @@ public:
QStringList supportedFileSystems() const;
bool externalStoragesPopulated() const;
QRegularExpression externalMedia;
signals:
void partitionChanged(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