Commit 0c73320b authored by jpetrell's avatar jpetrell

[developermode] Expose username. Contributes to JB#30044

parent b162ec41
...@@ -36,6 +36,8 @@ ...@@ -36,6 +36,8 @@
#include <QFile> #include <QFile>
#include <QDir> #include <QDir>
#include <QDBusReply> #include <QDBusReply>
#include <getdef.h>
#include <pwd.h>
/* Symbolic constants */ /* Symbolic constants */
#define PROGRESS_INDETERMINATE (-1) #define PROGRESS_INDETERMINATE (-1)
...@@ -239,12 +241,21 @@ DeveloperModeSettings::DeveloperModeSettings(QObject *parent) ...@@ -239,12 +241,21 @@ DeveloperModeSettings::DeveloperModeSettings(QObject *parent)
, m_wlanIpAddress("-") , m_wlanIpAddress("-")
, m_usbInterface(USB_NETWORK_FALLBACK_INTERFACE) , m_usbInterface(USB_NETWORK_FALLBACK_INTERFACE)
, m_usbIpAddress(USB_NETWORK_FALLBACK_IP) , m_usbIpAddress(USB_NETWORK_FALLBACK_IP)
, m_username("nemo")
, m_developerModeEnabled(false) , m_developerModeEnabled(false)
, m_remoteLoginEnabled(false) // TODO: Read (from password manager?) , m_remoteLoginEnabled(false) // TODO: Read (from password manager?)
, m_workerWorking(false) , m_workerWorking(false)
, m_workerStatus(Idle) , m_workerStatus(Idle)
, m_workerProgress(PROGRESS_INDETERMINATE) , m_workerProgress(PROGRESS_INDETERMINATE)
{ {
int uid = getdef_num("UID_MIN", -1);
struct passwd *pwd;
if ((pwd = getpwuid(uid)) != NULL) {
m_username = QString(pwd->pw_name);
} else {
qWarning() << "Failed to return username using getpwuid()";
}
m_worker->moveToThread(&m_worker_thread); m_worker->moveToThread(&m_worker_thread);
/* Messages to worker */ /* Messages to worker */
...@@ -294,6 +305,12 @@ DeveloperModeSettings::usbIpAddress() const ...@@ -294,6 +305,12 @@ DeveloperModeSettings::usbIpAddress() const
return m_usbIpAddress; return m_usbIpAddress;
} }
QString
DeveloperModeSettings::username() const
{
return m_username;
}
bool bool
DeveloperModeSettings::developerModeEnabled() const DeveloperModeSettings::developerModeEnabled() const
{ {
......
...@@ -55,6 +55,10 @@ class DeveloperModeSettings : public QObject ...@@ -55,6 +55,10 @@ class DeveloperModeSettings : public QObject
READ usbIpAddress READ usbIpAddress
NOTIFY usbIpAddressChanged) NOTIFY usbIpAddressChanged)
Q_PROPERTY(QString username
READ username
CONSTANT)
Q_PROPERTY(bool developerModeEnabled Q_PROPERTY(bool developerModeEnabled
READ developerModeEnabled READ developerModeEnabled
NOTIFY developerModeEnabledChanged) NOTIFY developerModeEnabledChanged)
...@@ -90,6 +94,7 @@ public: ...@@ -90,6 +94,7 @@ public:
QString wlanIpAddress() const; QString wlanIpAddress() const;
QString usbIpAddress() const; QString usbIpAddress() const;
QString username() const;
bool developerModeEnabled() const; bool developerModeEnabled() const;
bool remoteLoginEnabled() const; bool remoteLoginEnabled() const;
bool workerWorking() const; bool workerWorking() const;
...@@ -129,6 +134,7 @@ private: ...@@ -129,6 +134,7 @@ private:
QString m_wlanIpAddress; QString m_wlanIpAddress;
QString m_usbInterface; QString m_usbInterface;
QString m_usbIpAddress; QString m_usbIpAddress;
QString m_username;
bool m_developerModeEnabled; bool m_developerModeEnabled;
bool m_remoteLoginEnabled; bool m_remoteLoginEnabled;
bool m_workerWorking; bool m_workerWorking;
......
...@@ -7,7 +7,7 @@ QT += qml dbus systeminfo ...@@ -7,7 +7,7 @@ QT += qml dbus systeminfo
QT -= gui QT -= gui
CONFIG += link_pkgconfig CONFIG += link_pkgconfig
PKGCONFIG += profile mlite5 timed-qt5 PKGCONFIG += profile mlite5 timed-qt5 libshadowutils
system(qdbusxml2cpp -p mceiface.h:mceiface.cpp mce.xml) system(qdbusxml2cpp -p mceiface.h:mceiface.cpp mce.xml)
......
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