Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[nemo-systemsettings] Add UserModel. Fixes JB#49173
Implement model that lists users and allows creating, removing and
changing their names. Users are listed with libc operations while
changing them requires user-managerd DBus daemon. Information is also
updated when users are changed through user-managerd. Note that UserInfo
doesn't have guarantees of keeping the user in sync unless UserModel is
created.

User creation happens through placeholder element that must be used to
set user's full name before calling createUser. Placeholder is always
the last row of the user list.

Signed-off-by: Tomi Leppänen <tomi.leppanen@jolla.com>
  • Loading branch information
Tomin1 committed Mar 23, 2020
1 parent f43d52b commit 6eab714
Show file tree
Hide file tree
Showing 8 changed files with 478 additions and 3 deletions.
2 changes: 2 additions & 0 deletions rpm/nemo-qml-plugin-systemsettings.spec
Expand Up @@ -12,6 +12,7 @@ Requires: connman
Requires: mce >= 1.83.0
Requires: libsailfishkeyprovider >= 0.0.14
Requires: connman-qt5 >= 1.2.21
Requires: user-managerd
Requires(post): coreutils
BuildRequires: pkgconfig(Qt5Qml)
BuildRequires: pkgconfig(Qt5SystemInfo)
Expand All @@ -33,6 +34,7 @@ BuildRequires: pkgconfig(packagekitqt5)
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(sailfishaccesscontrol)
BuildRequires: pkgconfig(libsystemd)
BuildRequires: pkgconfig(sailfishusermanager)

%description
%{summary}.
Expand Down
1 change: 1 addition & 0 deletions src/logging.cpp
Expand Up @@ -34,3 +34,4 @@
Q_LOGGING_CATEGORY(lcVpnLog, "org.sailfishos.settings.vpn", QtWarningMsg)
Q_LOGGING_CATEGORY(lcDeveloperModeLog, "org.sailfishos.settings.developermode", QtWarningMsg)
Q_LOGGING_CATEGORY(lcMemoryCardLog, "org.sailfishos.settings.memorycard", QtWarningMsg)
Q_LOGGING_CATEGORY(lcUsersLog, "org.sailfishos.settings.users", QtWarningMsg)
1 change: 1 addition & 0 deletions src/logging_p.h
Expand Up @@ -37,5 +37,6 @@
Q_DECLARE_LOGGING_CATEGORY(lcVpnLog)
Q_DECLARE_LOGGING_CATEGORY(lcDeveloperModeLog)
Q_DECLARE_LOGGING_CATEGORY(lcMemoryCardLog)
Q_DECLARE_LOGGING_CATEGORY(lcUsersLog)

#endif
2 changes: 2 additions & 0 deletions src/plugin/plugin.cpp
Expand Up @@ -52,6 +52,7 @@
#include "deviceinfo.h"
#include "nfcsettings.h"
#include "userinfo.h"
#include "usermodel.h"

template<class T>
static QObject *api_factory(QQmlEngine *, QJSEngine *)
Expand Down Expand Up @@ -93,6 +94,7 @@ class SystemSettingsPlugin : public QQmlExtensionPlugin
qmlRegisterType<DeviceInfo>(uri, 1, 0, "DeviceInfo");
qmlRegisterType<NfcSettings>(uri, 1, 0, "NfcSettings");
qmlRegisterType<UserInfo>(uri, 1, 0, "UserInfo");
qmlRegisterType<UserModel>(uri, 1, 0, "UserModel");
}
};

Expand Down
8 changes: 5 additions & 3 deletions src/src.pro
Expand Up @@ -7,7 +7,7 @@ QT -= gui

CONFIG += c++11 hide_symbols link_pkgconfig
PKGCONFIG += profile mlite5 mce timed-qt5 libshadowutils blkid libcrypto nemomodels-qt5 libsailfishkeyprovider connman-qt5 glib-2.0
PKGCONFIG += ssu-sysinfo nemodbus packagekitqt5 libsystemd
PKGCONFIG += ssu-sysinfo nemodbus packagekitqt5 libsystemd sailfishusermanager

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

Expand Down Expand Up @@ -38,7 +38,8 @@ SOURCES += \
udisks2blockdevices.cpp \
udisks2job.cpp \
udisks2monitor.cpp \
userinfo.cpp
userinfo.cpp \
usermodel.cpp

PUBLIC_HEADERS = \
languagemodel.h \
Expand All @@ -62,7 +63,8 @@ PUBLIC_HEADERS = \
deviceinfo.h \
locationsettings.h \
timezoneinfo.h \
userinfo.h
userinfo.h \
usermodel.h

HEADERS += \
$$PUBLIC_HEADERS \
Expand Down
3 changes: 3 additions & 0 deletions src/userinfo.h
Expand Up @@ -39,6 +39,7 @@
#include "systemsettingsglobal.h"

class UserInfoPrivate;
class UserModel;

class SYSTEMSETTINGS_EXPORT UserInfo: public QObject
{
Expand All @@ -51,6 +52,8 @@ class SYSTEMSETTINGS_EXPORT UserInfo: public QObject
Q_PROPERTY(int uid READ uid NOTIFY uidChanged)
Q_PROPERTY(bool current READ current CONSTANT)

friend class UserModel;

public:
enum UserType {
User = 0,
Expand Down

0 comments on commit 6eab714

Please sign in to comment.