Skip to content

Commit

Permalink
[developermode] Expose username. Contributes to JB#30044
Browse files Browse the repository at this point in the history
  • Loading branch information
Joona Petrell committed Dec 10, 2015
1 parent b162ec4 commit 0c73320
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/developermodesettings.cpp
Expand Up @@ -36,6 +36,8 @@
#include <QFile>
#include <QDir>
#include <QDBusReply>
#include <getdef.h>
#include <pwd.h>

/* Symbolic constants */
#define PROGRESS_INDETERMINATE (-1)
Expand Down Expand Up @@ -239,12 +241,21 @@ DeveloperModeSettings::DeveloperModeSettings(QObject *parent)
, m_wlanIpAddress("-")
, m_usbInterface(USB_NETWORK_FALLBACK_INTERFACE)
, m_usbIpAddress(USB_NETWORK_FALLBACK_IP)
, m_username("nemo")
, m_developerModeEnabled(false)
, m_remoteLoginEnabled(false) // TODO: Read (from password manager?)
, m_workerWorking(false)
, m_workerStatus(Idle)
, 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);

/* Messages to worker */
Expand Down Expand Up @@ -294,6 +305,12 @@ DeveloperModeSettings::usbIpAddress() const
return m_usbIpAddress;
}

QString
DeveloperModeSettings::username() const
{
return m_username;
}

bool
DeveloperModeSettings::developerModeEnabled() const
{
Expand Down
6 changes: 6 additions & 0 deletions src/developermodesettings.h
Expand Up @@ -55,6 +55,10 @@ class DeveloperModeSettings : public QObject
READ usbIpAddress
NOTIFY usbIpAddressChanged)

Q_PROPERTY(QString username
READ username
CONSTANT)

Q_PROPERTY(bool developerModeEnabled
READ developerModeEnabled
NOTIFY developerModeEnabledChanged)
Expand Down Expand Up @@ -90,6 +94,7 @@ class DeveloperModeSettings : public QObject

QString wlanIpAddress() const;
QString usbIpAddress() const;
QString username() const;
bool developerModeEnabled() const;
bool remoteLoginEnabled() const;
bool workerWorking() const;
Expand Down Expand Up @@ -129,6 +134,7 @@ private slots:
QString m_wlanIpAddress;
QString m_usbInterface;
QString m_usbIpAddress;
QString m_username;
bool m_developerModeEnabled;
bool m_remoteLoginEnabled;
bool m_workerWorking;
Expand Down
2 changes: 1 addition & 1 deletion src/src.pro
Expand Up @@ -7,7 +7,7 @@ QT += qml dbus systeminfo
QT -= gui

CONFIG += link_pkgconfig
PKGCONFIG += profile mlite5 timed-qt5
PKGCONFIG += profile mlite5 timed-qt5 libshadowutils

system(qdbusxml2cpp -p mceiface.h:mceiface.cpp mce.xml)

Expand Down

0 comments on commit 0c73320

Please sign in to comment.