diff --git a/.gitignore b/.gitignore index 378eac2..3c23d28 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ build +lxqt-admin.kdev4 +*/translations/lxqt-admin diff --git a/AUTHORS b/AUTHORS index b633203..f200f7c 100644 --- a/AUTHORS +++ b/AUTHORS @@ -2,7 +2,7 @@ Upstream Authors: LXQt team: http://lxqt.org Copyright: - Copyright (c) 2014 LXQt team + Copyright (c) 2014-2016 LXQt team License: LGPL-2.1+ The full text of the licenses can be found in the 'COPYING' file. diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000..15f5264 --- /dev/null +++ b/CHANGELOG @@ -0,0 +1,99 @@ + +lxqt-admin-0.11.0 / 2016-09-24 +============================== + + * user: Add failure message box + * user: Provide icon name in polkit policy + * Update README.md + * Add Catalan translations + * Add copyright headers + * Add Arabic Translations for Desktop Files + * lxqt-admin-user: Fix a change password crash + * lxqt-admin-user: Makes the Refresh toolbar button visible + * lxqt-admin-time: Adjust dialog size on startup + * Update openSUSE section in README + * Update README.md + * Support NTP and Local RTC settings with timedated provided by systemd. Code cleanup. + * Replace calling timedatectl command with calling its dbus interface instead and provide proper error messages. + * Use dbus interface of timedate systemd daemon instead of timedatectl command. + * Add the ability to update group members. + * Support changing of user password. + * Show group members. + * Try to use a helper script and polkit policy configurations to do user admin. + * Remove liboobs dependency from lxqt-admin-time and use timedatectl to handle all time configurations. + * Try to handle timezones with timedatectl provided by systemd instead of liboobs. + * Add groupmod + * Try to remove liboobs dependency. + * Add README.md + * build: Use external translations + * ts-files removal (#32) + * Bump years to 2016 + * Don't track IDE settings + * Italian translation update + * Russian translations update Remove duplicated ru_RU translations + * updated: *_hu.ts + +0.10.0 / 2015-10-31 +=================== + + * Fix license file + * Add Greek (el) translation + * Rename LxQt to LXQt everywhere + * Removed invisible dialog titles. Updated template. Added german translation. + * Handles CMake policy CMP0063 + * Initialize in the same order of declaration in the class definition + * Use the LXQtCompilerSettings CMake module + * Updates the build system to use the Targets infrastructure + * Remove trailing whitespaces + * Create lxqt-admin-time_hr.ts + * Create lxqt-admin-user_hr.ts + * Hungarian translations added + * Create lxqt-admin-time_it.desktop + * Create lxqt-admin-user_it.desktop + * Initial Polish translation + * Create lxqt-admin-user_it.desktop + * lxqt-admin-user: set minimum default GID value for new group to 1000 + * Initial Polish translation + +0.9.0 / 2015-01-25 +================== + + * Create lxqt-admin-user_it.desktop + * Create lxqt-admin-user_it.ts + * Create lxqt-admin-time_it.ts + * Add Portuguese language + * Added Japanese translation + * Unify naming for a unique lxqt. No more suffixes + * Update Russian translation + * Updates translations sources + * Whole GUI of time/date setup has been rewritten from scratch the app has now style of LXQT config dialogs based on LxQt::ConfigDialog the time and date setting is divided into one configuration widget and timezone selection is divided into second config widget + * Add icon to config window + * Add .gitignore + * Make use of QApplication::exec() + * Use the new LxQt::SingleApplication + * CMakeLists.txt maintenance. + * Update translation a little more + * Add Russian translation + * updates Translations + * Updates the translations infrastructure + * Drop Qt4 support in CMakeLists.txt in subfolders + * Drop Qt4 support in code + * Clean up CMakeLists.txt and drop Qt 4 + +0.8.0 / 2014-06-21 +================== + + * simplify Qt version switching + * Support build with Qt5. + * Use new LXQt header files. + * Update copyright notice. + * Support changing group members. + * Support adding/removing/editing users and groups. + * Redesign the UI. + * Add a group configuration dialog. + * Improve user dialog. + * Add a user config dialog. + * Update time every seconds unless it's changed manually by the user. + * Add basic skeleton for lxqt-admin-user tool. + * Add a very basic time config tool, lxqt-admin-time. + * Initial commit. diff --git a/CMakeLists.txt b/CMakeLists.txt index cd1fcc7..eec38e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,12 +11,6 @@ find_package(Qt5Widgets REQUIRED QUIET) find_package(lxqt REQUIRED QUIET) find_package(KF5WindowSystem REQUIRED QUIET) -find_package(PkgConfig) -pkg_check_modules(OOBS REQUIRED - glib-2.0 - liboobs-1 -) - include(LXQtCompilerSettings NO_POLICY_SCOPE) include(LXQtTranslate) diff --git a/README.md b/README.md new file mode 100644 index 0000000..ca9083b --- /dev/null +++ b/README.md @@ -0,0 +1,67 @@ +# lxqt-admin + +## Overview + +This repository is providing two GUI tools to adjust settings of the operating system LXQt is running on. + +Both are using [polkit](https://www.freedesktop.org/wiki/Software/polkit/) to handle permissions. +In contrast to the specific backends described below earlier versions of lxqt-admin were relying on [system-tools-backends](http://system-tools-backends.freedesktop.org) and their wrapper [liboobs](https://github.com/GNOME/liboobs). These were replaced as both go unmaintained for years and were hence dropped from many distributions heavily restricting the usage of lxqt-admin. As long as they can be built it should still be possible to compile lxqt-admin release ≤ 0.10 against them in order to make use of it on platforms lacking systemd like BSD. + +### Time and date configuration + +Adjusts time and date. Binary is `lxqt-admin-time`. + +![lxqt-admin-time](lxqt-admin-time.png) + +It is using `systemd-timedated` as backend which is accessed by its D-Bus interface. Among other this means the option +to sync the system time by NTP is relying on `systemd-timesyncd` as backend. + +### User and Group Settings + +Management of users and groups. Binary is `lxqt-admin-user`. + +![lxqt-admin-user](lxqt-admin-user.png) + +The backend is a script `lxqt-admin-user-helper`. By default it is in turn using the shadow tools to do the actual work. +The script can be modified to use different tools, though. + +## Installing + +### Compiling sources + +Runtime dependencies are polkit and [liblxqt](https://github.com/lxde/liblxqt). A polkit agent should be available with [lxqt-policykit](https://github.com/lxde/lxqt-policykit/) representing the first choice in LXQt. +Additional build dependencies are CMake and optionally Git to pull latest VCS checkouts. The localization files were outsourced to repository [lxqt-l10n](https://github.com/lxde/lxqt-l10n) so the corresponding dependencies are needed, too. Please refer to this repository's `README.md` for further information. + +Code configuration is handled by CMake. CMake variable `CMAKE_INSTALL_PREFIX` will normally have to be set to `/usr`. + +To build run `make`, to install `make install` which accepts variable `DESTDIR` as usual. + +### Binary packages + +#### Arch Linux + +[AUR](https://aur.archlinux.org) packages `lxqt-admin` and `lxqt-admin-git` are providing the current stable release and the +actual master checkout at compile time as usual. +Note that package `lxqt-admin` had to be kept in the AUR due to lack of the dependency liboobs as depicted [above](#overview). +So it will be transferred to community as of release 0.11. + +#### Debian + +Package `lxqt-admin` is available in the official repositories as of Debian stretch. + +#### Fedora + +Fedora doesn't provide lxqt-admin so far due to lack of the dependency liboobs as depicted [above](#overview). This will hopefully change +once release LXQt release 0.11 makes it into the Fedora repositories. + +#### openSUSE + +openSUSE does not ship with lxqt-admin in it's standard repositories since the functionality is covered by openSUSE's [YaST](http://yast.github.io/). +However it is still possible to install it on openSUSE. The package and its dependencies, like the [above](#overview) mentioned, outdated liboobs are available through the [X11:LXQt](https://build.opensuse.org/project/show/X11:LXQt) repository. + +## Usage + +Much like similar tools provided by [lxqt-config](https://github.com/lxde/lxqt-config) the tools of lxqt-admin can be launched from the [Configuration Center](https://github.com/lxde/lxqt-config#configuration-center) as well as from the panel's main menu - Preferences - LXQt settings. + +The actual usage should be self-explanatory. To apply settings the GUI of the polkit authentication agent that's in use is +launched to acquire the root password. diff --git a/debian/.gitignore b/debian/.gitignore index 9a4da58..dd3db13 100644 --- a/debian/.gitignore +++ b/debian/.gitignore @@ -1,6 +1,7 @@ /*.debhelper /*.log /*.substvars +/debhelper-build-stamp /files /lxqt-admin/ diff --git a/debian/changelog b/debian/changelog index 5e4ff3d..f99e014 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,28 @@ +lxqt-admin (0.11.0-2) unstable; urgency=medium + + * Cherry-picking new upstream version 0.11.0 + * Synced debian foo with experimental + * Bumped compat to 10 + * Removed --parallel from rules, standard compat 10 + * Bumped minimum version debhelper (>= 10) + * Bumped minimum version liblxqt0-dev (>= 0.11.0) + * Bumped minimum version libqt5xdg-dev (>= 2.0.0) + * Added build dependency libqt5xdgiconloader-dev (>= 2.0.0) + * Added build dependency libqt5svg5-dev + * Removed build dependency liboobs-1-dev + * Added recommends lxqt-admin-l10n + * Added a lintian-override for lxqt-admin-user-helper + * Exported LC_ALL=C.UTF-8 - define language settings for reproducible + builds + * Fixed VCS-Fields, use https + * Bumped copyright years + * Added hardening to rules + * Added translation control to rules + * Set CMAKE_BUILD_TYPE=RelWithDebInfo + * Added README.md to docs + + -- Alf Gaida Tue, 18 Oct 2016 01:54:42 +0200 + lxqt-admin (0.10.0-3) unstable; urgency=medium * Remove dbg package in favor of dbgsym. diff --git a/debian/compat b/debian/compat index ec63514..f599e28 100644 --- a/debian/compat +++ b/debian/compat @@ -1 +1 @@ -9 +10 diff --git a/debian/control b/debian/control index 99f49fb..e14ff61 100644 --- a/debian/control +++ b/debian/control @@ -5,26 +5,28 @@ Uploaders: Alf Gaida , Andrew Lee (李健秋) Section: x11 Priority: optional -Build-Depends: debhelper (>= 9), +Build-Depends: debhelper (>= 10), cmake (>= 3.0.2), - liboobs-1-dev, libkf5windowsystem-dev, - liblxqt0-dev (>= 0.10.0), + liblxqt0-dev (>= 0.11.0), + libqt5svg5-dev, libqt5x11extras5-dev, - libqt5xdg-dev (>= 1.3.0), + libqt5xdg-dev (>= 2.0.0), + libqt5xdgiconloader-dev (>= 2.0.0), libx11-dev, pkg-config, qttools5-dev, qttools5-dev-tools -Standards-Version: 3.9.6 -Vcs-Browser: http://anonscm.debian.org/cgit/pkg-lxqt/lxqt-admin.git/?h=debian/sid -Vcs-Git: git://anonscm.debian.org/pkg-lxqt/lxqt-admin.git -b debian/sid +Standards-Version: 3.9.8 +Vcs-Browser: https://anonscm.debian.org/cgit/pkg-lxqt/lxqt-admin.git/?h=debian/sid +Vcs-Git: https://anonscm.debian.org/git/pkg-lxqt/lxqt-admin.git -b debian/sid Homepage: https://github.com/lxde/lxqt-admin Package: lxqt-admin Architecture: any Depends: ${misc:Depends}, ${shlibs:Depends} +Recommends: lxqt-admin-l10n Description: Admin tools for LXQt Admin tools for LXQt, as of now: * lxqt-admin-time diff --git a/debian/copyright b/debian/copyright index 22d4d2d..eb0eb7b 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,14 +1,14 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: lxqt-admin Source: https://github.com/lxde/lxqt-admin Files: * -Copyright: 2014-2015 LXQt team +Copyright: 2014-2016 LXQt team 2014 Hong Jen Yee (PCMan) License: LGPL-2.1+ Files: debian/* -Copyright: 2014-2015 Alf Gaida +Copyright: 2014-2016 Alf Gaida 2015 Andrew Lee (李健秋) License: LGPL-2.1+ diff --git a/debian/docs b/debian/docs index 62deb04..9a30530 100644 --- a/debian/docs +++ b/debian/docs @@ -1 +1,2 @@ AUTHORS +README.md \ No newline at end of file diff --git a/debian/lintian-overrides b/debian/lintian-overrides index 0fddfc3..04bbfe7 100644 --- a/debian/lintian-overrides +++ b/debian/lintian-overrides @@ -1,6 +1,7 @@ # there will be no manual for a foreseable time lxqt-admin: binary-without-manpage usr/bin/lxqt-admin-time lxqt-admin: binary-without-manpage usr/bin/lxqt-admin-user +lxqt-admin: binary-without-manpage usr/bin/lxqt-admin-user-helper # the category is right, but not in freedesktop right now lxqt-admin: desktop-entry-invalid-category LXQt usr/share/applications/lxqt-admin-time.desktop diff --git a/debian/rules b/debian/rules index c250dd7..9dbedc2 100755 --- a/debian/rules +++ b/debian/rules @@ -1,9 +1,15 @@ #!/usr/bin/make -f -#export DH_VERBOSE=1 +# export DH_VERBOSE=1 +export LC_ALL=C.UTF-8 export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed +export DEB_BUILD_MAINT_OPTIONS = hardening=+all %: - dh ${@} --buildsystem cmake \ - --parallel + dh ${@} --buildsystem cmake +override_dh_auto_configure: + dh_auto_configure -- \ + -DPULL_TRANSLATIONS=OFF\ + -DUPDATE_TRANSLATIONS=OFF\ + -DCMAKE_BUILD_TYPE=RelWithDebInfo diff --git a/debian/upstream/signing-key.asc b/debian/upstream/signing-key.asc index 05cd1df..4936633 100644 --- a/debian/upstream/signing-key.asc +++ b/debian/upstream/signing-key.asc @@ -1,63 +1,50 @@ -----BEGIN PGP PUBLIC KEY BLOCK----- -Version: GnuPG v2.0.22 (GNU/Linux) -mQINBFJevCYBEACx+Hvy+Vsuf+V5jeLUnzjAmHoy8DfTeGWr3ts30IapLHrfi0+U -WpzNnISO77yTr4VNboVZH+GHM/rnPfieODfB4ZW6CZLlInMSKUXcgQsEqXpyBZhA -Ib/SPy2bOfHly1uRJes0uRDsH5+v/hD74sByfnjQlrvI68O6wvGZmDFMNNPVO8+/ -OWBSBNkBuVrrZOMSPsLwQGJ4UtUQ4whburaPJG4VZJc5DLbzJGbEuACc0IAEYJS3 -7AfXVXn4j4Gc9F3o1xTUnbOBnwGPquWwUIm3FM7Ec2OdkvMt3EwvnkMAfeVrq3iE -FDD/KZTxdL0BZH3QD8gB7Jm4v4f3Nkobg6JCvCbcH3wBdZW4mASbwWzfRaDC2zHb -ErTglD7PpShLKZZ0pr9okWZEGw4Ku3q8ALi1JXK/ePTmsBlvkVskOJ3Nnd0avgH4 -+Q/vZoKfH8EhNY745rI+8CE9iv6V9XiSUt4CKEWAENt4A8hq6U2vV+jZv3B6AgD7 -ZjiI59yD4YuYubu8rCnNizTgh1voVw3ietknn/x2H5yH8fByWZ5uL87C0ky/uma6 -ZGbiiAtM4kdkyDMrfRV5nlEG9EKAGPVu5mjeSCrfkETwZ9OFPz1AuDye4ZEXrrcC -iRQ7RX6/GtW18aHER0kzGnfwx5KJzkDrRBY8A2PdXLBcrsN4WpK9EX01PQARAQAB -tCNKZXJvbWUgTGVjbGFuY2hlIDxqZXJvbWVAbGVjbGFuLmNoPokCPwQTAQIAKQUC -Ul68JgIbAwUJAeEzgAcLCQgHAwIBBhUIAgkKCwQWAgMBAh4BAheAAAoJEDfgrx/a -SPNzSHIP/1ewXcC0TFBcvDD7MrIP7anyNfiWfW7cxkR8GSamkg6HTa6Ndyr1FFjJ -OoDFUP37jWhu59CsHxs2D0zRWJktezfvElscRgqbHcdpIznqsGdI8hXCZafhBGVb -sdAB2LRawcXGxnXt7XajPcSVwLWRE62caBqohznU2iWvI780WNjEbZoA0LhZwaFF -UUPJm8ea9v0IkZVKUyg9WONZ1U7FEG9SaEiSpI8kJdx1fvCwZVDV/NRO5GqnJaho -P1LCne4YdwS6pt1/fRgk32IHxxZfHlLzLHxb6v1JmIg72x28qCmGyK9oFBDbbnYu -6Aq8XbHogOrD5vJM2Pfm2IhV0+JHOjfQbddv8tsAH1M+LI+tToXmg5st1AU3wnTn -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 -=fF8P +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 +=h7ww -----END PGP PUBLIC KEY BLOCK----- diff --git a/debian/watch b/debian/watch index 4b09067..14dc696 100644 --- a/debian/watch +++ b/debian/watch @@ -1,3 +1,3 @@ -version=3 +version=4 opts="pgpsigurlmangle=s/$/.asc/" \ - https://github.com/lxde/lxqt-admin/releases .*/([\d\.]+).tar.gz + https://github.com/lxde/lxqt-admin/releases .*/lxqt-admin-([\d\.]+).tar.xz diff --git a/lxqt-admin-time.png b/lxqt-admin-time.png new file mode 100644 index 0000000..b3e3a85 Binary files /dev/null and b/lxqt-admin-time.png differ diff --git a/lxqt-admin-time/CMakeLists.txt b/lxqt-admin-time/CMakeLists.txt index 28ce566..c6fc6aa 100644 --- a/lxqt-admin-time/CMakeLists.txt +++ b/lxqt-admin-time/CMakeLists.txt @@ -3,13 +3,13 @@ project(lxqt-admin-time) # build static helper class first include_directories ( ${CMAKE_CURRENT_BINARY_DIR} - ${OOBS_INCLUDE_DIRS} ) set ( lxqt-admin-time_HDRS timeadmindialog.h datetime.h timezone.h + timedatectl.h ) set ( lxqt-admin-time_SRCS @@ -17,6 +17,7 @@ set ( lxqt-admin-time_SRCS timeadmindialog.cpp datetime.cpp timezone.cpp + timedatectl.cpp ) set ( lxqt-admin-time_MOCS @@ -42,6 +43,16 @@ lxqt_translate_ts(lxqt-admin-time_QM_FILES ${lxqt-admin-time_UIS} INSTALL_DIR "${LXQT_TRANSLATIONS_DIR}/${PROJECT_NAME}" + PULL_TRANSLATIONS + ${PULL_TRANSLATIONS} + CLEAN_TRANSLATIONS + ${CLEAN_TRANSLATIONS} + TRANSLATIONS_REPO + ${TRANSLATIONS_REPO} + TRANSLATIONS_REFSPEC + ${TRANSLATIONS_REFSPEC} + REPO_SUBDIR + "lxqt-admin/${PROJECT_NAME}" ) lxqt_translate_desktop(DESKTOP_FILES @@ -64,8 +75,8 @@ add_executable(lxqt-admin-time target_link_libraries(lxqt-admin-time KF5::WindowSystem Qt5::Widgets + Qt5::DBus lxqt - ${OOBS_LIBRARIES} ) install(TARGETS lxqt-admin-time RUNTIME DESTINATION bin) diff --git a/lxqt-admin-time/datetime.cpp b/lxqt-admin-time/datetime.cpp index 7e5dbcf..10cd8bf 100644 --- a/lxqt-admin-time/datetime.cpp +++ b/lxqt-admin-time/datetime.cpp @@ -31,15 +31,16 @@ #include #include -DateTime::DateTime(QWidget *parent) : +DateTimePage::DateTimePage(bool useNtp, bool localRtc, QWidget *parent) : QWidget(parent), - ui(new Ui::DateTime) + ui(new Ui::DateTime), + mUseNtp(useNtp), + mLocalRtc(localRtc) { ui->setupUi(this); mTimer = new QTimer(this); connect(mTimer,SIGNAL(timeout()),SLOT(timeout())); - //highlight today QDate date = QDate::currentDate(); QTextCharFormat format = ui->calendar->dateTextFormat(date); @@ -51,43 +52,56 @@ DateTime::DateTime(QWidget *parent) : reload(); } -DateTime::~DateTime() +DateTimePage::~DateTimePage() { delete ui; } -void DateTime::timeout() +void DateTimePage::timeout() { ui->edit_time->blockSignals(true); ui->edit_time->setTime(QTime::currentTime()); ui->edit_time->blockSignals(false); } -void DateTime::reload() +void DateTimePage::reload() { ui->calendar->setSelectedDate(QDate::currentDate()); ui->edit_time->setTime(QTime::currentTime()); + + ui->localRTC->setChecked(mLocalRtc); + ui->ntp->setChecked(mUseNtp); + mTimer->start(1000); mModified = 0; - emit changed(mModified); + emit changed(); } -void DateTime::on_edit_time_userTimeChanged(const QTime &time) +void DateTimePage::on_edit_time_userTimeChanged(const QTime &time) { mModified |= M_TIME; mTimer->stop(); - - emit changed(mModified); + emit changed(); } -QDateTime DateTime::dateTime() const +QDateTime DateTimePage::dateTime() const { QDateTime dt(ui->calendar->selectedDate(),ui->edit_time->time()); return dt; } -void DateTime::on_calendar_selectionChanged() +bool DateTimePage::useNtp() const +{ + return ui->ntp->isChecked(); +} + +bool DateTimePage::localRtc() const +{ + return ui->localRTC->isChecked(); +} + +void DateTimePage::on_calendar_selectionChanged() { QDate date = ui->calendar->selectedDate(); if (date != QDate::currentDate()) @@ -98,6 +112,32 @@ void DateTime::on_calendar_selectionChanged() { mModified &= ~M_DATE; } + emit changed(); +} + +void DateTimePage::on_ntp_toggled(bool toggled) +{ + if(toggled != mUseNtp) + { + mModified |= M_NTP; + } + else + { + mModified &= ~M_NTP; + } + emit changed(); +} - emit changed(mModified); +void DateTimePage::on_localRTC_toggled(bool toggled) +{ + if(toggled != mLocalRtc) + { + mModified |= M_LOCAL_RTC; + } + else + { + mModified &= ~M_LOCAL_RTC; + } + emit changed(); } + diff --git a/lxqt-admin-time/datetime.h b/lxqt-admin-time/datetime.h index 2913cda..81f39c3 100644 --- a/lxqt-admin-time/datetime.h +++ b/lxqt-admin-time/datetime.h @@ -34,38 +34,46 @@ namespace Ui { class DateTime; } -class DateTime : public QWidget +class DateTimePage : public QWidget { Q_OBJECT public: - explicit DateTime(QWidget *parent = 0); - ~DateTime(); + explicit DateTimePage(bool useNtp, bool localRtc, QWidget *parent = 0); + ~DateTimePage(); - enum modified_enum {M_DATE = 0x1, M_TIME = 0x2}; - Q_DECLARE_FLAGS(modified_t, modified_enum) + enum ModifiedFlag {M_DATE = (1 << 0), M_TIME = (1 << 1), M_NTP = (1 << 2), M_LOCAL_RTC = (1 << 3)}; + Q_DECLARE_FLAGS(ModifiedFlags,ModifiedFlag) + + ModifiedFlags modified() const + { + return mModified; + } QDateTime dateTime() const; - inline modified_t modified() const {return mModified;} + bool useNtp() const; + bool localRtc() const; public Q_SLOTS: void reload(); - private Q_SLOTS: void on_edit_time_userTimeChanged(const QTime &time); void timeout(); void on_calendar_selectionChanged(); + void on_ntp_toggled(bool toggled); + void on_localRTC_toggled(bool toggled); Q_SIGNALS: - void changed(bool); + void changed(); private: Ui::DateTime *ui; QTimer * mTimer; - modified_t mModified; + bool mUseNtp; + bool mLocalRtc; + ModifiedFlags mModified; }; -Q_DECLARE_OPERATORS_FOR_FLAGS(DateTime::modified_t) #endif // DATETIME_H diff --git a/lxqt-admin-time/datetime.ui b/lxqt-admin-time/datetime.ui index 781d761..c74fa3f 100644 --- a/lxqt-admin-time/datetime.ui +++ b/lxqt-admin-time/datetime.ui @@ -6,8 +6,8 @@ 0 0 - 354 - 308 + 365 + 323 @@ -16,7 +16,7 @@ 50 - + @@ -64,6 +64,20 @@ + + + + Enable network time synchronization (NTP) + + + + + + + RTC is in local time + + + @@ -77,24 +91,41 @@ - - - - - 75 - true - - - - <html><head/><body><p>Saving changes requires admin permissions.<br>You will be requested after clicking close button</p></body></html> - - - true - - - - + + + ntp + toggled(bool) + calendar + setDisabled(bool) + + + 221 + 269 + + + 228 + 162 + + + + + ntp + toggled(bool) + edit_time + setDisabled(bool) + + + 105 + 260 + + + 173 + 55 + + + + diff --git a/lxqt-admin-time/timeadmindialog.cpp b/lxqt-admin-time/timeadmindialog.cpp index e5d319d..af4f21d 100644 --- a/lxqt-admin-time/timeadmindialog.cpp +++ b/lxqt-admin-time/timeadmindialog.cpp @@ -31,82 +31,59 @@ #include #include #include +#include #include "datetime.h" #include "timezone.h" - #define ZONETAB_PATH "/usr/share/zoneinfo/zone.tab" TimeAdminDialog::TimeAdminDialog(QWidget *parent): - LXQt::ConfigDialog(tr("Time and date configuration"),new LXQt::Settings("TimeDate"), parent), - mTimeConfig(OOBS_TIME_CONFIG(oobs_time_config_get())), - mUserLogedIn(false) + LXQt::ConfigDialog(tr("Time and date configuration"),new LXQt::Settings("TimeDate"), parent) { - oobs_object_update(OOBS_OBJECT(mTimeConfig)); - setMinimumSize(QSize(400,400)); mWindowTitle = windowTitle(); - - mDateTimeWidget = new DateTime(this); + mDateTimeWidget = new DateTimePage(mTimeDateCtl.useNtp(), mTimeDateCtl.localRtc(), this); addPage(mDateTimeWidget,tr("Date and time")); connect(this,SIGNAL(reset()),mDateTimeWidget,SLOT(reload())); - connect(mDateTimeWidget,&DateTime::changed,this,&TimeAdminDialog::onChanged); - mDateTimeWidget->setProperty("pModified",M_TIMEDATE); + connect(mDateTimeWidget,&DateTimePage::changed,this,&TimeAdminDialog::onChanged); QStringList zones; QString currentZone; loadTimeZones(zones,currentZone); - mTimezoneWidget = new Timezone(zones,currentZone,this); + mTimezoneWidget = new TimezonePage(zones,currentZone,this); addPage(mTimezoneWidget,tr("Timezone")); - connect(this,&TimeAdminDialog::reset,mTimezoneWidget,&Timezone::reload); - connect(mTimezoneWidget,&Timezone::changed,this,&TimeAdminDialog::onChanged); - mTimezoneWidget->setProperty("pModified",M_TIMEZONE); + connect(this,&TimeAdminDialog::reset,mTimezoneWidget,&TimezonePage::reload); + connect(mTimezoneWidget,&TimezonePage::changed,this,&TimeAdminDialog::onChanged); + + setButtons(QDialogButtonBox::Ok|QDialogButtonBox::Cancel); + connect(this, &LXQt::ConfigDialog::clicked, this, &TimeAdminDialog::onButtonClicked); + adjustSize(); } TimeAdminDialog::~TimeAdminDialog() { - if(mTimeConfig) - g_object_unref(mTimeConfig); } -void TimeAdminDialog::onChanged(bool ch) +void TimeAdminDialog::onChanged() { - widgets_modified_enum flag = (widgets_modified_enum) - sender()->property("pModified").toUInt(); - ch ? mWidgetsModified |= flag : mWidgetsModified &= ~flag; showChangedStar(); } void TimeAdminDialog::showChangedStar() { - if (mWidgetsModified) + if(mTimezoneWidget->isChanged() || mDateTimeWidget->modified()) setWindowTitle(mWindowTitle + "*"); else setWindowTitle(mWindowTitle); } -void TimeAdminDialog::closeEvent(QCloseEvent *event) -{ - //save changes to system - if (mWidgetsModified) - { - if (logInUser()) - { - saveChangesToSystem(); - event->accept(); - } - else - { - event->ignore(); - } - } -} - void TimeAdminDialog::loadTimeZones(QStringList & timeZones, QString & currentTimezone) { + currentTimezone = mTimeDateCtl.timeZone(); + timeZones.clear(); QFile file(ZONETAB_PATH); if(file.open(QIODevice::ReadOnly)) @@ -124,44 +101,61 @@ void TimeAdminDialog::loadTimeZones(QStringList & timeZones, QString & currentTi } file.close(); } - currentTimezone = QString::fromLatin1(oobs_time_config_get_timezone(mTimeConfig)); } void TimeAdminDialog::saveChangesToSystem() { - QByteArray timeZone = mTimezoneWidget->timezone().toLatin1(); - // FIXME: currently timezone settings does not work. is this a bug of system-tools-backend? - if(!timeZone.isEmpty() && mWidgetsModified.testFlag(M_TIMEZONE)) - oobs_time_config_set_timezone(mTimeConfig, timeZone.constData()); + QString errorMessage; + if(mTimezoneWidget->isChanged()) + { + QString timeZone = mTimezoneWidget->timezone(); + if(!timeZone.isEmpty()) + { + if(false == mTimeDateCtl.setTimeZone(timeZone, errorMessage)) { + QMessageBox::critical(this, tr("Error"), errorMessage); + } + } + } + + auto modified = mDateTimeWidget->modified(); + bool useNtp = mDateTimeWidget->useNtp(); + if(modified.testFlag(DateTimePage::M_NTP)) + { + if(false == mTimeDateCtl.setUseNtp(useNtp, errorMessage)) { + QMessageBox::critical(this, tr("Error"), errorMessage); + } + } - if(mWidgetsModified.testFlag(M_TIMEDATE)) + if(modified.testFlag(DateTimePage::M_LOCAL_RTC)) { - QDate d = mDateTimeWidget->dateTime().date(); - QTime t = mDateTimeWidget->dateTime().time(); - // oobs seems to use 0 based month - oobs_time_config_set_time(mTimeConfig, d.year(), d.month() - 1, d.day(), t.hour(), t.minute(), t.second()); + if(false == mTimeDateCtl.setLocalRtc(mDateTimeWidget->localRtc(), errorMessage)) { + QMessageBox::critical(this, tr("Error"), errorMessage); + } + } + + // we can only change the date & time explicitly when NTP is disabled. + if(false == useNtp) + { + if(modified.testFlag(DateTimePage::M_DATE) || modified.testFlag(DateTimePage::M_TIME)) + { + if(false == mTimeDateCtl.setDateTime(mDateTimeWidget->dateTime(), errorMessage)) { + QMessageBox::critical(this, tr("Error"), errorMessage); + } + } } - oobs_object_commit(OOBS_OBJECT(mTimeConfig)); } -bool TimeAdminDialog::logInUser() +void TimeAdminDialog::onButtonClicked(QDialogButtonBox::StandardButton button) { - if (mUserLogedIn) - return true; - - GError* err = NULL; - if(oobs_object_authenticate(OOBS_OBJECT(mTimeConfig), &err)) + if(button == QDialogButtonBox::Ok) { - mUserLogedIn = true; - return true; + saveChangesToSystem(); + accept(); } - else if(err) + else if(button == QDialogButtonBox::Cancel) { - QMessageBox::critical(this, tr("Authentication Error"), QString::fromUtf8(err->message)); - g_error_free(err); + reject(); } - - return false; } diff --git a/lxqt-admin-time/timeadmindialog.h b/lxqt-admin-time/timeadmindialog.h index 2b0c2f5..a71d828 100644 --- a/lxqt-admin-time/timeadmindialog.h +++ b/lxqt-admin-time/timeadmindialog.h @@ -26,13 +26,10 @@ * END_COMMON_COPYRIGHT_HEADER */ #include -#include -#include -#include -#include +#include "timedatectl.h" -class DateTime; -class Timezone; +class DateTimePage; +class TimezonePage; class TimeAdminDialog: public LXQt::ConfigDialog { @@ -42,30 +39,18 @@ public: TimeAdminDialog(QWidget * parent = NULL) ; ~TimeAdminDialog(); - - typedef enum {M_TIMEDATE = 1 , M_TIMEZONE = 0x2} widgets_modified_enum; - Q_DECLARE_FLAGS(widgets_modified_t, widgets_modified_enum) - -protected: - virtual void closeEvent(QCloseEvent * event); - private Q_SLOTS: - void onChanged(bool); + void onChanged(); + void onButtonClicked(QDialogButtonBox::StandardButton button); private: - bool logInUser(); void saveChangesToSystem(); void loadTimeZones(QStringList & timeZones, QString & currentTimezone); void showChangedStar(); private: - OobsTimeConfig* mTimeConfig; - DateTime * mDateTimeWidget; - Timezone * mTimezoneWidget; - bool mUserLogedIn; + TimeDateCtl mTimeDateCtl; + DateTimePage * mDateTimeWidget; + TimezonePage * mTimezoneWidget; QString mWindowTitle; - widgets_modified_t mWidgetsModified; }; - -Q_DECLARE_METATYPE(TimeAdminDialog::widgets_modified_enum) -Q_DECLARE_OPERATORS_FOR_FLAGS(TimeAdminDialog::widgets_modified_t) diff --git a/lxqt-admin-time/timedatectl.cpp b/lxqt-admin-time/timedatectl.cpp new file mode 100644 index 0000000..adb8ff6 --- /dev/null +++ b/lxqt-admin-time/timedatectl.cpp @@ -0,0 +1,112 @@ +/* BEGIN_COMMON_COPYRIGHT_HEADER + * (c)LGPL2+ + * + * LXQt - a lightweight, Qt based, desktop toolset + * http://lxqt.org + * + * Copyright: 2016 LXQt team + * Authors: + * Hong Jen Yee (PCMan) + * + * This program or library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * END_COMMON_COPYRIGHT_HEADER */ + +#include "timedatectl.h" +#include +#include +#include +#include +#include + + +TimeDateCtl::TimeDateCtl() +{ + mIface = new QDBusInterface(QStringLiteral("org.freedesktop.timedate1"), + QStringLiteral("/org/freedesktop/timedate1"), + QStringLiteral("org.freedesktop.timedate1"), + QDBusConnection::systemBus()); +} + +TimeDateCtl::~TimeDateCtl() +{ + delete mIface; +} + +QString TimeDateCtl::timeZone() const +{ + return mIface->property("Timezone").toString(); +} + +bool TimeDateCtl::setTimeZone(QString timeZone, QString& errorMessage) +{ + mIface->call("SetTimezone", timeZone, true); + QDBusError err = mIface->lastError(); + if(err.isValid()) + { + errorMessage = err.message(); + return false; + } + return true; +} + +bool TimeDateCtl::setDateTime(QDateTime dateTime, QString& errorMessage) +{ + // the timedatectl dbus service accepts "usec" input. + // Qt can only get "msec" => convert to usec here. + mIface->call("SetTime", dateTime.toMSecsSinceEpoch() * 1000, false, true); + QDBusError err = mIface->lastError(); + if(err.isValid()) + { + errorMessage = err.message(); + return false; + } + return true; +} + +bool TimeDateCtl::useNtp() const +{ + return mIface->property("NTP").toBool(); +} + +bool TimeDateCtl::setUseNtp(bool value, QString& errorMessage) +{ + mIface->call("SetNTP", value, true); + QDBusError err = mIface->lastError(); + if(err.isValid()) + { + errorMessage = err.message(); + return false; + } + return true; +} + +bool TimeDateCtl::localRtc() const +{ + return mIface->property("LocalRTC").toBool(); +} + +bool TimeDateCtl::setLocalRtc(bool value, QString& errorMessage) +{ + mIface->call("SetLocalRTC", value, false, true); + QDBusError err = mIface->lastError(); + if(err.isValid()) + { + errorMessage = err.message(); + return false; + } + return true; +} diff --git a/lxqt-admin-time/timedatectl.h b/lxqt-admin-time/timedatectl.h new file mode 100644 index 0000000..2c25e88 --- /dev/null +++ b/lxqt-admin-time/timedatectl.h @@ -0,0 +1,57 @@ +/* BEGIN_COMMON_COPYRIGHT_HEADER + * (c)LGPL2+ + * + * LXQt - a lightweight, Qt based, desktop toolset + * http://lxqt.org + * + * Copyright: 2016 LXQt team + * Authors: + * Hong Jen Yee (PCMan) + * + * This program or library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * END_COMMON_COPYRIGHT_HEADER */ + +#ifndef TIMEDATECTL_H +#define TIMEDATECTL_H + +#include +#include + +class QDBusInterface; + +class TimeDateCtl +{ +public: + explicit TimeDateCtl(); + ~TimeDateCtl(); + + bool useNtp() const; + bool setUseNtp(bool value, QString& errorMessage); + + bool localRtc() const; + bool setLocalRtc(bool value, QString& errorMessage); + + QString timeZone() const; + bool setTimeZone(QString timeZone, QString& errorMessage); + + bool setDateTime(QDateTime dateTime, QString& errorMessage); + +private: + QDBusInterface* mIface; +}; + +#endif // TIMEDATECTL_H diff --git a/lxqt-admin-time/timezone.cpp b/lxqt-admin-time/timezone.cpp index 2be3778..d6c90c7 100644 --- a/lxqt-admin-time/timezone.cpp +++ b/lxqt-admin-time/timezone.cpp @@ -28,7 +28,7 @@ #include "timezone.h" #include "ui_timezone.h" -Timezone::Timezone(const QStringList & zones, const QString & currentimezone, QWidget *parent) : +TimezonePage::TimezonePage(const QStringList & zones, const QString & currentimezone, QWidget *parent) : QWidget(parent), ui(new Ui::Timezone), mZoneChanged(false), @@ -47,12 +47,12 @@ Timezone::Timezone(const QStringList & zones, const QString & currentimezone, QW reload(); } -Timezone::~Timezone() +TimezonePage::~TimezonePage() { delete ui; } -void Timezone::reload() +void TimezonePage::reload() { ui->list_zones->setCurrentRow(-1); mZoneChanged = false; @@ -60,10 +60,10 @@ void Timezone::reload() if (list.count()) ui->list_zones->setCurrentItem(list.at(0)); - emit changed(mZoneChanged); + emit changed(); } -QString Timezone::timezone() const +QString TimezonePage::timezone() const { if (ui->list_zones->currentItem()) return ui->list_zones->currentItem()->text(); @@ -71,16 +71,17 @@ QString Timezone::timezone() const return QString(); } -void Timezone::on_list_zones_itemActivated(QListWidgetItem * item) +void TimezonePage::on_list_zones_itemSelectionChanged() { - bool old = mZoneChanged; + QList selected = ui->list_zones->selectedItems(); + if(selected.empty()) + return; + QListWidgetItem *item = selected.first(); mZoneChanged = item->text() != ui->label_timezone->text(); - - if (mZoneChanged != old) - emit changed(mZoneChanged); + emit changed(); } -void Timezone::on_edit_filter_textChanged(const QString &arg1) +void TimezonePage::on_edit_filter_textChanged(const QString &arg1) { QRegExp reg(arg1, Qt::CaseInsensitive,QRegExp::Wildcard); ui->list_zones->clear(); diff --git a/lxqt-admin-time/timezone.h b/lxqt-admin-time/timezone.h index 072ecb6..8565b5d 100644 --- a/lxqt-admin-time/timezone.h +++ b/lxqt-admin-time/timezone.h @@ -35,13 +35,13 @@ class Timezone; } class QListWidgetItem; -class Timezone : public QWidget +class TimezonePage : public QWidget { Q_OBJECT public: - explicit Timezone(const QStringList & zones, const QString & currentimezone, QWidget *parent = 0); - ~Timezone(); + explicit TimezonePage(const QStringList & zones, const QString & currentimezone, QWidget *parent = 0); + ~TimezonePage(); QString timezone() const; inline bool isChanged() const {return mZoneChanged;} @@ -49,10 +49,10 @@ public slots: void reload(); Q_SIGNALS: - void changed(bool); + void changed(); private slots: - void on_list_zones_itemActivated(QListWidgetItem *item); + void on_list_zones_itemSelectionChanged(); void on_edit_filter_textChanged(const QString &arg1); private: diff --git a/lxqt-admin-time/timezone.ui b/lxqt-admin-time/timezone.ui index 21000fc..960735d 100644 --- a/lxqt-admin-time/timezone.ui +++ b/lxqt-admin-time/timezone.ui @@ -42,22 +42,6 @@ - - - - - 75 - true - - - - <html><head/><body><p>Saving changes requires admin permissions.<br>You will be requested after clicking close button</p></body></html> - - - true - - - diff --git a/lxqt-admin-time/translations/lxqt-admin-time.ts b/lxqt-admin-time/translations/lxqt-admin-time.ts deleted file mode 100644 index e5617de..0000000 --- a/lxqt-admin-time/translations/lxqt-admin-time.ts +++ /dev/null @@ -1,78 +0,0 @@ - - - - - DateTime - - - Time: - - - - - HH:mm:ss - - - - - Date: - - - - - <html><head/><body><p>Saving changes requires admin permissions.<br>You will be requested after clicking close button</p></body></html> - - - - - TimeAdminDialog - - - Time and date configuration - - - - - Date and time - - - - - Timezone - - - - - Authentication Error - - - - - Timezone - - - Your current timezone: - - - - - TextLabel - - - - - Filter - - - - - <html><head/><body><p>Saving changes requires admin permissions.<br>You will be requested after clicking close button</p></body></html> - - - - - None - - - - diff --git a/lxqt-admin-time/translations/lxqt-admin-time_ar.desktop b/lxqt-admin-time/translations/lxqt-admin-time_ar.desktop new file mode 100644 index 0000000..cb6847b --- /dev/null +++ b/lxqt-admin-time/translations/lxqt-admin-time_ar.desktop @@ -0,0 +1,4 @@ +#TRANSLATIONS +Name[ar]=التّاريخ والوقت +GenericName[ar]=إعدادات التّاريخ والوقت +Comment[ar]=اضبط تاريخ النّظام ووقته diff --git a/lxqt-admin-time/translations/lxqt-admin-time_ca.desktop b/lxqt-admin-time/translations/lxqt-admin-time_ca.desktop new file mode 100644 index 0000000..cb225de --- /dev/null +++ b/lxqt-admin-time/translations/lxqt-admin-time_ca.desktop @@ -0,0 +1,3 @@ +Name[ca]=Data i hora +GenericName[ca]=Ajusts de la data i l'hora +Comment[ca]=Configureu la data i l'hora del vostre sistema diff --git a/lxqt-admin-time/translations/lxqt-admin-time_de.ts b/lxqt-admin-time/translations/lxqt-admin-time_de.ts deleted file mode 100644 index 489b7b3..0000000 --- a/lxqt-admin-time/translations/lxqt-admin-time_de.ts +++ /dev/null @@ -1,79 +0,0 @@ - - - - - DateTime - - - Time: - Zeit: - - - - HH:mm:ss - No need to translate. - - - - - Date: - Datum: - - - - <html><head/><body><p>Saving changes requires admin permissions.<br>You will be requested after clicking close button</p></body></html> - <html><head/><body><p>Das Sichern der Einstellungen benötigt Administrator-Rechte.<br>Nach dem Betätigen der Schließen-Schaltfläche wird die Berechtigung eingeholt.</p></body></html> - - - - TimeAdminDialog - - - Time and date configuration - Zeit und Datum einstellen - - - - Date and time - Datum und Zeit - - - - Timezone - Zeitzone - - - - Authentication Error - Authentifizierungsfehler - - - - Timezone - - - Your current timezone: - Derzeitige Zeitzone: - - - - TextLabel - Textfeld - - - - Filter - Filter - - - - <html><head/><body><p>Saving changes requires admin permissions.<br>You will be requested after clicking close button</p></body></html> - <html><head/><body><p>Das Sichern der Einstellungen benötigt Administrator-Rechte.<br>Nach dem Betätigen der Schließen-Schaltfläche wird die Berechtigung eingeholt.</p></body></html> - - - - None - Keine - - - diff --git a/lxqt-admin-time/translations/lxqt-admin-time_el.ts b/lxqt-admin-time/translations/lxqt-admin-time_el.ts deleted file mode 100644 index 6680baf..0000000 --- a/lxqt-admin-time/translations/lxqt-admin-time_el.ts +++ /dev/null @@ -1,78 +0,0 @@ - - - - - DateTime - - - Time: - Ώρα: - - - - HH:mm:ss - HH:mm:ss - - - - Date: - Ημερομηνία: - - - - <html><head/><body><p>Saving changes requires admin permissions.<br>You will be requested after clicking close button</p></body></html> - <html><head/><body><p>Η αποθήκευση των αλλαγών απαιτεί δικαιώματα διαχειριστή.<br>Θα ερωτηθείτε αφού κάνετε κλικ στο κουμπί του κλεισίματος</p></body></html> - - - - TimeAdminDialog - - - Time and date configuration - Διαμόρφωση της ώρας και της ημερομηνίας - - - - Date and time - Ημερομηνία και ώρα - - - - Timezone - Ωρολογιακή ζώνη - - - - Authentication Error - Σφάλμα πιστοποίησης - - - - Timezone - - - Your current timezone: - Η τρέχουσα ζώνη ώρας: - - - - TextLabel - Ετικέτα κειμένου - - - - Filter - Φίλτρο - - - - <html><head/><body><p>Saving changes requires admin permissions.<br>You will be requested after clicking close button</p></body></html> - <html><head/><body><p>Η αποθήκευση των αλλαγών απαιτεί δικαιώματα διαχειριστή.<br>Θα ερωτηθείτε αφού κάνετε κλικ στο κουμπί του κλεισίματος</p></body></html> - - - - None - Καμία - - - diff --git a/lxqt-admin-time/translations/lxqt-admin-time_hr.ts b/lxqt-admin-time/translations/lxqt-admin-time_hr.ts deleted file mode 100644 index 07388a4..0000000 --- a/lxqt-admin-time/translations/lxqt-admin-time_hr.ts +++ /dev/null @@ -1,98 +0,0 @@ - - - - - DateTime - - - Form - - - - - Time and date setup - Postavke datuma i vremena - - - - Time: - Vrijeme: - - - - HH:mm:ss - HH:mm:ss - - - - Date: - Nadnevak - - - - <html><head/><body><p>Saving changes requires admin permissions.<br>You will be requested after clicking close button</p></body></html> - <html><head/><body><p>Spremanje pronjena zahtjeva adminstracijske dozvole.<br>Biti će zatražene nakon što kliknete na dugme zatvori</p></body></html> - - - - TimeAdminDialog - - - Time and date configuration - Konfiguracija vremena i nadnevka - - - - Date and time - Nadnevak i vrijeme - - - - Timezone - Vremenska zona - - - - Authentication Error - - - - - Timezone - - - Form - - - - - Timezone setup - Postavljanje vremenske zone - - - - Your current timezone: - Vaša trenutna vremenska zona - - - - TextLabel - - - - - Filter - - - - - <html><head/><body><p>Saving changes requires admin permissions.<br>You will be requested after clicking close button</p></body></html> - <html><head/><body><p>Spremanje pronjena zahtjeva adminstracijske dozvole.<br>Biti će zatražene nakon što kliknete na dugme zatvori</p></body></html> - - - - None - Nijedan - - - diff --git a/lxqt-admin-time/translations/lxqt-admin-time_hu.ts b/lxqt-admin-time/translations/lxqt-admin-time_hu.ts deleted file mode 100644 index 41f65c1..0000000 --- a/lxqt-admin-time/translations/lxqt-admin-time_hu.ts +++ /dev/null @@ -1,98 +0,0 @@ - - - - - DateTime - - - Form - Űrlap - - - - Time and date setup - Dátum és időbeállítás - - - - Time: - Idő: - - - - HH:mm:ss - - - - - Date: - Dátum: - - - - <html><head/><body><p>Saving changes requires admin permissions.<br>You will be requested after clicking close button</p></body></html> - <html><head/><body><p>Változtatások csak rendszergazdaként menthetők,<br>jelszóbekérés a kilépés után.</p></body></html> - - - - TimeAdminDialog - - - Time and date configuration - Dátum és időbeállítások - - - - Date and time - Dátum és idő - - - - Timezone - Időzóna - - - - Authentication Error - Hitelesítési hiba - - - - Timezone - - - Form - Űrlap - - - - Timezone setup - Időzóna beállítás - - - - Your current timezone: - Mostani időzóna: - - - - TextLabel - Szövegcím - - - - Filter - Szűrő - - - - <html><head/><body><p>Saving changes requires admin permissions.<br>You will be requested after clicking close button</p></body></html> - <html><head/><body><p>Változtatások csak rendszergazdaként menthetők,<br>jelszóbekérés a kilépés után.</p></body></html> - - - - None - Nincs - - - diff --git a/lxqt-admin-time/translations/lxqt-admin-time_it.ts b/lxqt-admin-time/translations/lxqt-admin-time_it.ts deleted file mode 100644 index a8c2224..0000000 --- a/lxqt-admin-time/translations/lxqt-admin-time_it.ts +++ /dev/null @@ -1,100 +0,0 @@ - - - - - DateTime - - - Form - - - - - Time and date setup - Imposta data e ora - - - - Time: - Ora: - - - - HH:mm:ss - - - - - Date: - Data: - - - - <html><head/><body><p>Saving changes requires admin permissions.<br>You will be requested after clicking close button</p></body></html> - Il salvataggio richiede privilegi di amministratore, -saranno chiesti dopo la chiusura di questa finestra. - - - - TimeAdminDialog - - - Time and date configuration - Configura data e ora - - - - Date and time - Data e ora - - - - Timezone - Fuso orario - - - - Authentication Error - Errore di autenticazione - - - - Timezone - - - Form - - - - - Timezone setup - Configura fuso orario - - - - Your current timezone: - Fuso orario attuale: - - - - TextLabel - nessuno - - - - Filter - Filtro - - - - <html><head/><body><p>Saving changes requires admin permissions.<br>You will be requested after clicking close button</p></body></html> - Il salvataggio richiede privilegi di amministratore, -saranno chiesti dopo la chiusura di questa finestra. - - - - None - - - - diff --git a/lxqt-admin-time/translations/lxqt-admin-time_ja.ts b/lxqt-admin-time/translations/lxqt-admin-time_ja.ts deleted file mode 100644 index d22a1a0..0000000 --- a/lxqt-admin-time/translations/lxqt-admin-time_ja.ts +++ /dev/null @@ -1,98 +0,0 @@ - - - - - DateTime - - - Form - フォーム - - - - Time and date setup - 日時設定 - - - - Time: - 時刻: - - - - HH:mm:ss - HH:mm:ss - - - - Date: - 日付 - - - - <html><head/><body><p>Saving changes requires admin permissions.<br>You will be requested after clicking close button</p></body></html> - <html><head/><body><p>変更の保存には管理権限が必要です。<br>閉じるボタンを押した直後に要求されるでしょう。</p></body></html> - - - - TimeAdminDialog - - - Time and date configuration - 日時設定 - - - - Date and time - 日時 - - - - Timezone - タイムゾーン - - - - Authentication Error - 認証エラー - - - - Timezone - - - Form - フォーム - - - - Timezone setup - タイムゾーン設定 - - - - Your current timezone: - 現在のタイムゾーン - - - - TextLabel - テキストラベル - - - - Filter - フィルター - - - - <html><head/><body><p>Saving changes requires admin permissions.<br>You will be requested after clicking close button</p></body></html> - <html><head/><body><p>変更の保存には管理権限が必要です。<br>閉じるボタンを押した直後に要求されるでしょう。</p></body></html> - - - - None - なし - - - diff --git a/lxqt-admin-time/translations/lxqt-admin-time_pl.ts b/lxqt-admin-time/translations/lxqt-admin-time_pl.ts deleted file mode 100644 index d56adac..0000000 --- a/lxqt-admin-time/translations/lxqt-admin-time_pl.ts +++ /dev/null @@ -1,98 +0,0 @@ - - - - - DateTime - - - Form - - - - - Time and date setup - Konfiguracja daty i czasu - - - - Time: - Czas: - - - - HH:mm:ss - - - - - Date: - Data: - - - - <html><head/><body><p>Saving changes requires admin permissions.<br>You will be requested after clicking close button</p></body></html> - <html><head/><body><p>Zapisywanie zmian wymaga uprawnień administratora.<br>Zostaniesz poproszony o hasło.</p></body></html> - - - - TimeAdminDialog - - - Time and date configuration - Konfiguracja daty i czasu - - - - Date and time - Data i czas - - - - Timezone - Strefa czasowa - - - - Authentication Error - Błąd autoryzacji - - - - Timezone - - - Form - - - - - Timezone setup - Ustawienia strefy czasowej - - - - Your current timezone: - Twoja aktualna strefa czasowa: - - - - TextLabel - - - - - Filter - Filtr - - - - <html><head/><body><p>Saving changes requires admin permissions.<br>You will be requested after clicking close button</p></body></html> - <html><head/><body><p>Zapisywanie zmian wymaga uprawnień administratora.<br>Zostaniesz poproszony o hasło.</p></body></html> - - - - None - Żadna - - - diff --git a/lxqt-admin-time/translations/lxqt-admin-time_pt.ts b/lxqt-admin-time/translations/lxqt-admin-time_pt.ts deleted file mode 100644 index b19df01..0000000 --- a/lxqt-admin-time/translations/lxqt-admin-time_pt.ts +++ /dev/null @@ -1,98 +0,0 @@ - - - - - DateTime - - - Form - Formulário - - - - Time and date setup - Configuração de data e hora - - - - Time: - Hora: - - - - HH:mm:ss - H:mm:ss - - - - Date: - Data: - - - - <html><head/><body><p>Saving changes requires admin permissions.<br>You will be requested after clicking close button</p></body></html> - <html><head/><body><p>A gravação de alterações requer permissões de administrador.<br>A senha será solicitada ao clicar em Fechar.</p></body></html> - - - - TimeAdminDialog - - - Time and date configuration - Configuração de data e hora - - - - Date and time - Data e hora - - - - Timezone - Fuso horário - - - - Authentication Error - Erro de autenticação - - - - Timezone - - - Form - Formulário - - - - Timezone setup - Configuração de fuso horário - - - - Your current timezone: - O seu fuso horário: - - - - TextLabel - Texto - - - - Filter - Filtrar - - - - <html><head/><body><p>Saving changes requires admin permissions.<br>You will be requested after clicking close button</p></body></html> - <html><head/><body><p>A gravação de alterações requer permissões de administrador.<br>A senha será solicitada ao clicar em Fechar.</p></body></html> - - - - None - Nenhum - - - diff --git a/lxqt-admin-time/translations/lxqt-admin-time_ru.ts b/lxqt-admin-time/translations/lxqt-admin-time_ru.ts deleted file mode 100644 index 943422a..0000000 --- a/lxqt-admin-time/translations/lxqt-admin-time_ru.ts +++ /dev/null @@ -1,83 +0,0 @@ - - - - - DateTime - - - Time and date setup - Настройка даты и времени - - - - Time: - Время: - - - - HH:mm:ss - ЧЧ:мм:сс - - - - Date: - Дата: - - - - <html><head/><body><p>Saving changes requires admin permissions.<br>You will be requested after clicking close button</p></body></html> - <html><head/><body><p>Для сохранения изменений необходимы права администратора.<br>Пароль будет запрошен после нажатия на кнопку «Закрыть»</p></body></html> - - - - TimeAdminDialog - - - Time and date configuration - Настройки даты и времени - - - - Date and time - Дата и время - - - - Timezone - Часовой пояс - - - - Authentication Error - Ошибка аутентификации - - - - Timezone - - - Timezone setup - Настройки часового пояса - - - - Your current timezone: - Ваш текущий часовой пояс: - - - - Filter - Фильтр - - - - <html><head/><body><p>Saving changes requires admin permissions.<br>You will be requested after clicking close button</p></body></html> - <html><head/><body><p>Для сохранения изменений необходимы права администратора.<br>Пароль будет запрошен после нажатия на кнопку «Закрыть»</p></body></html> - - - - None - Нет - - - diff --git a/lxqt-admin-time/translations/lxqt-admin-time_ru_RU.desktop b/lxqt-admin-time/translations/lxqt-admin-time_ru_RU.desktop deleted file mode 100644 index fdf42d9..0000000 --- a/lxqt-admin-time/translations/lxqt-admin-time_ru_RU.desktop +++ /dev/null @@ -1,6 +0,0 @@ -[Desktop Entry] -Name[ru_RU]=Дата и время -GenericName[ru_RU]=Настройки даты и времени -Comment[ru_RU]=Настроить дату и время вашей системы - -#TRANSLATIONS_DIR=translations diff --git a/lxqt-admin-time/translations/lxqt-admin-time_ru_RU.ts b/lxqt-admin-time/translations/lxqt-admin-time_ru_RU.ts deleted file mode 100644 index e3c6e68..0000000 --- a/lxqt-admin-time/translations/lxqt-admin-time_ru_RU.ts +++ /dev/null @@ -1,83 +0,0 @@ - - - - - DateTime - - - Time and date setup - Настройка даты и времени - - - - Time: - Время: - - - - HH:mm:ss - ЧЧ:мм:сс - - - - Date: - Дата: - - - - <html><head/><body><p>Saving changes requires admin permissions.<br>You will be requested after clicking close button</p></body></html> - <html><head/><body><p>Для сохранения изменений необходимы права администратора.<br>Пароль будет запрошен после нажатия на кнопку «Закрыть»</p></body></html> - - - - TimeAdminDialog - - - Time and date configuration - Настройки даты и времени - - - - Date and time - Дата и время - - - - Timezone - Часовой пояс - - - - Authentication Error - Ошибка аутентификации - - - - Timezone - - - Timezone setup - Настройки часового пояса - - - - Your current timezone: - Ваш текущий часовой пояс: - - - - Filter - Фильтр - - - - <html><head/><body><p>Saving changes requires admin permissions.<br>You will be requested after clicking close button</p></body></html> - <html><head/><body><p>Для сохранения изменений необходимы права администратора.<br>Пароль будет запрошен после нажатия на кнопку «Закрыть»</p></body></html> - - - - None - Нет - - - diff --git a/lxqt-admin-user.png b/lxqt-admin-user.png new file mode 100644 index 0000000..12fd972 Binary files /dev/null and b/lxqt-admin-user.png differ diff --git a/lxqt-admin-user/CMakeLists.txt b/lxqt-admin-user/CMakeLists.txt index e3fc857..5619363 100644 --- a/lxqt-admin-user/CMakeLists.txt +++ b/lxqt-admin-user/CMakeLists.txt @@ -3,7 +3,6 @@ project(lxqt-admin-user) # build static helper class first include_directories ( ${CMAKE_CURRENT_BINARY_DIR} - ${OOBS_INCLUDE_DIRS} ) set ( lxqt-admin-user_SRCS @@ -11,12 +10,14 @@ set ( lxqt-admin-user_SRCS mainwindow.cpp userdialog.cpp groupdialog.cpp + usermanager.cpp ) set ( lxqt-admin-user_MOCS mainwindow.h userdialog.h groupdialog.h + usermanager.h ) set( lxqt-admin-user_UIS @@ -37,6 +38,16 @@ lxqt_translate_ts(lxqt-admin-user_QM_FILES ${lxqt-admin-user_UIS} INSTALL_DIR "${LXQT_TRANSLATIONS_DIR}/${PROJECT_NAME}" + PULL_TRANSLATIONS + ${PULL_TRANSLATIONS} + CLEAN_TRANSLATIONS + ${CLEAN_TRANSLATIONS} + TRANSLATIONS_REPO + ${TRANSLATIONS_REPO} + TRANSLATIONS_REFSPEC + ${TRANSLATIONS_REFSPEC} + REPO_SUBDIR + "lxqt-admin/${PROJECT_NAME}" ) lxqt_translate_desktop(DESKTOP_FILES @@ -59,8 +70,17 @@ target_link_libraries(lxqt-admin-user KF5::WindowSystem Qt5::Widgets lxqt - ${OOBS_LIBRARIES} ) install(TARGETS lxqt-admin-user RUNTIME DESTINATION bin) install(FILES ${DESKTOP_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications) + +# for policykit +# manpage for pcmanfm-qt +configure_file( + "org.lxqt.lxqt-admin-user.policy.in" + "${CMAKE_CURRENT_BINARY_DIR}/org.lxqt.lxqt-admin-user.policy" + @ONLY +) +install(PROGRAMS "lxqt-admin-user-helper" DESTINATION bin) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/org.lxqt.lxqt-admin-user.policy" DESTINATION "share/polkit-1/actions") diff --git a/lxqt-admin-user/groupdialog.cpp b/lxqt-admin-user/groupdialog.cpp index fd7fc43..fc60446 100644 --- a/lxqt-admin-user/groupdialog.cpp +++ b/lxqt-admin-user/groupdialog.cpp @@ -20,111 +20,60 @@ #include "groupdialog.h" #include +#include "usermanager.h" +#include #define DEFAULT_GID_MIN 1000 #define DEFAULT_GID_MAX 32768 -GroupDialog::GroupDialog(OobsGroup *group, QWidget *parent, Qt::WindowFlags f): +GroupDialog::GroupDialog(UserManager* userManager, GroupInfo* group, QWidget *parent, Qt::WindowFlags f): QDialog(parent, f), - mGroup(group ? OOBS_GROUP(g_object_ref(group)) : NULL) + mUserManager(userManager), + mGroup(group) { ui.setupUi(this); + ui.groupName->setText(group->name()); + ui.gid->setValue(group->gid()); - OobsGroupsConfig* groupsConfig = OOBS_GROUPS_CONFIG(oobs_groups_config_get()); - if(group) // edit an exiting group - { - ui.groupName->setReadOnly(true); - ui.groupName->setText(oobs_group_get_name(group)); - mOldGId = oobs_group_get_gid(group); - ui.gid->setValue(mOldGId); - } - else // create a new group - { - mOldGId = -1; - ui.gid->setValue(oobs_groups_config_find_free_gid(groupsConfig, DEFAULT_GID_MIN, DEFAULT_GID_MAX)); - } - - GList* groupUsers = oobs_group_get_users(mGroup); // all users in this group + const QStringList& members = group->members(); // all users in this group // load all users - OobsUsersConfig* usersConfig = OOBS_USERS_CONFIG(oobs_users_config_get()); - OobsList* users = oobs_users_config_get_users(usersConfig); - if(users) + for(const UserInfo* user: userManager->users()) { - OobsListIter it; - gboolean valid = oobs_list_get_iter_first(users, &it); - while(valid) - { - OobsUser* user = OOBS_USER(oobs_list_get(users, &it)); - QListWidgetItem* item = new QListWidgetItem(); - item->setText(oobs_user_get_login_name(user)); - item->setFlags(Qt::ItemIsEnabled|Qt::ItemIsUserCheckable|Qt::ItemIsSelectable); - if(g_list_find(groupUsers, user)) // the user is in this group - item->setCheckState(Qt::Checked); - else - item->setCheckState(Qt::Unchecked); - QVariant obj = QVariant::fromValue(user); - item->setData(Qt::UserRole, obj); - ui.userList->addItem(item); - valid = oobs_list_iter_next(users, &it); - } + QListWidgetItem* item = new QListWidgetItem(); + item->setText(user->name()); + item->setFlags(Qt::ItemIsEnabled|Qt::ItemIsUserCheckable|Qt::ItemIsSelectable); + if(members.indexOf(user->name()) != -1) // the user is in this group + item->setCheckState(Qt::Checked); + else + item->setCheckState(Qt::Unchecked); + QVariant obj = QVariant::fromValue((void*)user); + item->setData(Qt::UserRole, obj); + ui.userList->addItem(item); } - g_list_free(groupUsers); } GroupDialog::~GroupDialog() { - if(mGroup) - g_object_unref(mGroup); } void GroupDialog::accept() { - OobsGroupsConfig* groupsConfig = OOBS_GROUPS_CONFIG(oobs_groups_config_get()); - gid_t gid = ui.gid->value(); - if(gid != mOldGId && oobs_groups_config_is_gid_used(groupsConfig, gid)) + QString groupName = ui.groupName->text(); + if(groupName.isEmpty()) { - QMessageBox::critical(this, tr("Error"), tr("The group ID is in use.")); + QMessageBox::critical(this, tr("Error"), tr("The group name cannot be empty.")); return; } - - if(!mGroup) // create a new group - { - QByteArray groupName = ui.groupName->text().toLatin1(); - if(groupName.isEmpty()) - { - QMessageBox::critical(this, tr("Error"), tr("The group name cannot be empty.")); - return; - } - if(oobs_groups_config_is_name_used(groupsConfig, groupName)) - { - QMessageBox::critical(this, tr("Error"), tr("The group name is in use.")); - return; - } - mGroup = oobs_group_new(groupName); - } - oobs_group_set_gid(mGroup, gid); + mGroup->setName(groupName); + mGroup->setGid(ui.gid->value()); // update users - GList* groupUsers = oobs_group_get_users(mGroup); // all users in this group - int rowCount = ui.userList->count(); - for(int row = 0; row < rowCount; ++row) - { + mGroup->removeAllMemberss(); + for(int row = 0; row < ui.userList->count(); ++row) { QListWidgetItem* item = ui.userList->item(row); - QVariant obj = item->data(Qt::UserRole); - OobsUser* user = OOBS_USER(obj.value()); - if(g_list_find(groupUsers, user)) // the user belongs to this group previously - { - if(item->checkState() == Qt::Unchecked) // it's unchecked, remove it - oobs_group_remove_user(mGroup, user); - } - else // the user does not belong to this group previously - { - if(item->checkState() == Qt::Checked) // it's checked, we want it! - oobs_group_add_user(mGroup, user); + if(item->checkState() == Qt::Checked) { + mGroup->addMember(item->text()); } } - g_list_free(groupUsers); - - oobs_object_commit(OOBS_OBJECT(mGroup)); QDialog::accept(); } diff --git a/lxqt-admin-user/groupdialog.h b/lxqt-admin-user/groupdialog.h index d8743a1..43e3dda 100644 --- a/lxqt-admin-user/groupdialog.h +++ b/lxqt-admin-user/groupdialog.h @@ -23,32 +23,24 @@ #include #include "ui_groupdialog.h" -#include -#include -#include + +class GroupInfo; +class UserManager; class GroupDialog : public QDialog { Q_OBJECT public: - GroupDialog(OobsGroup* group = NULL, QWidget *parent = NULL, Qt::WindowFlags f = 0); + GroupDialog(UserManager* userManager, GroupInfo* group, QWidget *parent = nullptr, Qt::WindowFlags f = 0); ~GroupDialog(); - OobsGroup* group() - { - return mGroup; - } - virtual void accept(); -private: - bool hasUser(OobsUser* user); - private: Ui::GroupDialog ui; - OobsGroup* mGroup; - gid_t mOldGId; + UserManager* mUserManager; + GroupInfo* mGroup; }; #endif // GROUPDIALOG_H diff --git a/lxqt-admin-user/groupdialog.ui b/lxqt-admin-user/groupdialog.ui index 3010c10..1bfe419 100644 --- a/lxqt-admin-user/groupdialog.ui +++ b/lxqt-admin-user/groupdialog.ui @@ -26,6 +26,9 @@ + + Default + 32768 diff --git a/lxqt-admin-user/lxqt-admin-user-helper b/lxqt-admin-user/lxqt-admin-user-helper new file mode 100755 index 0000000..24e4c39 --- /dev/null +++ b/lxqt-admin-user/lxqt-admin-user-helper @@ -0,0 +1,13 @@ +#!/bin/sh +case "$1" in +# we only allow executing these commands +useradd|usermod|userdel|groupadd|groupmod|groupdel|passwd|gpasswd) + # TODO: platforms using different commands can add wrapper scripts here. + export LC_ALL=C + exec "$@" + ;; +*) + echo "Command '$1' is not allowed!" + exit 1 + ;; +esac diff --git a/lxqt-admin-user/mainwindow.cpp b/lxqt-admin-user/mainwindow.cpp index 1cce210..62428f1 100644 --- a/lxqt-admin-user/mainwindow.cpp +++ b/lxqt-admin-user/mainwindow.cpp @@ -21,161 +21,125 @@ #include "mainwindow.h" #include #include +#include +#include +#include +#include #include "userdialog.h" #include "groupdialog.h" +#include "usermanager.h" MainWindow::MainWindow(): QMainWindow(), - mUsersConfig(OOBS_USERS_CONFIG(oobs_users_config_get())), - mGroupsConfig(OOBS_GROUPS_CONFIG(oobs_groups_config_get())) + mUserManager(new UserManager(this)) { ui.setupUi(this); connect(ui.actionAdd, SIGNAL(triggered(bool)), SLOT(onAdd())); connect(ui.actionDelete, SIGNAL(triggered(bool)), SLOT(onDelete())); connect(ui.actionProperties, SIGNAL(triggered(bool)), SLOT(onEditProperties())); - connect(ui.actionRefresh, SIGNAL(triggered(bool)), SLOT(onRefresh())); + connect(ui.actionChangePasswd, SIGNAL(triggered(bool)), SLOT(onChangePasswd())); + connect(ui.actionRefresh, SIGNAL(triggered(bool)), SLOT(reload())); - onRefresh(); // load the settings + connect(ui.userList, &QListWidget::activated, this, &MainWindow::onRowActivated); + connect(ui.groupList, &QListWidget::activated, this, &MainWindow::onRowActivated); - g_signal_connect(mUsersConfig, "changed" , G_CALLBACK(onUsersConfigChanged), this); - g_signal_connect(mGroupsConfig, "changed" , G_CALLBACK(onGroupsConfigChanged), this); + connect(mUserManager, &UserManager::changed, this, &MainWindow::reload); + reload(); } MainWindow::~MainWindow() { - if(mUsersConfig) - { - g_signal_handlers_disconnect_by_func(mUsersConfig, (void*)G_CALLBACK(onUsersConfigChanged), this); - g_object_unref(mUsersConfig); - } - if(mGroupsConfig) - g_object_unref(mGroupsConfig); } -void MainWindow::loadUsers() +void MainWindow::reloadUsers() { ui.userList->clear(); - OobsList* users = oobs_users_config_get_users(mUsersConfig); - if(users) + const auto& users = mUserManager->users(); + for(const UserInfo* user: users) { - OobsListIter it; - gboolean valid = oobs_list_get_iter_first(users, &it); - while(valid) + uid_t uid = user->uid(); + if(uid > 499 && !user->shell().isEmpty()) // exclude system users { - GObject* obj = oobs_list_get(users, &it); - OobsUser* user = OOBS_USER(obj); - uid_t uid = oobs_user_get_uid(user); - if(uid > 499 && oobs_user_get_shell(user)) // exclude system users - { - QString fullName = QString::fromUtf8(oobs_user_get_full_name(user)); - QString loginName = QString::fromLatin1(oobs_user_get_login_name(user)); - QString homeDir = QString::fromLocal8Bit(oobs_user_get_home_directory(user)); - QString groupName; - OobsGroup* group = oobs_user_get_main_group(user); - if(group) - groupName = QString::fromLatin1(oobs_group_get_name(group)); - - QTreeWidgetItem* item = new QTreeWidgetItem(); - item->setData(0, Qt::DisplayRole, loginName); - QVariant obj = QVariant::fromValue(user); - item->setData(0, Qt::UserRole, obj); - item->setData(1, Qt::DisplayRole, uid); - item->setData(2, Qt::DisplayRole, fullName); - item->setData(3, Qt::DisplayRole, groupName); - item->setData(4, Qt::DisplayRole, homeDir); - ui.userList->addTopLevelItem(item); + QTreeWidgetItem* item = new QTreeWidgetItem(); + item->setData(0, Qt::DisplayRole, user->name()); + QVariant obj = QVariant::fromValue((void*)user); + item->setData(0, Qt::UserRole, obj); + item->setData(1, Qt::DisplayRole, uid); + item->setData(2, Qt::DisplayRole, user->fullName()); + GroupInfo* group = mUserManager->findGroupInfo(user->gid()); + if(group != nullptr) { + item->setData(3, Qt::DisplayRole, group->name()); } - valid = oobs_list_iter_next(users, &it); + item->setData(4, Qt::DisplayRole, user->homeDir()); + ui.userList->addTopLevelItem(item); } } } -void MainWindow::loadGroups() +void MainWindow::reloadGroups() { ui.groupList->clear(); // load groups - OobsList* groups = oobs_groups_config_get_groups(mGroupsConfig); - if(groups) + const auto& groups = mUserManager->groups(); + for(const GroupInfo* group: groups) { - OobsListIter it; - gboolean valid = oobs_list_get_iter_first(groups, &it); - while(valid) - { - OobsGroup* group = OOBS_GROUP(oobs_list_get(groups, &it)); - QTreeWidgetItem* item = new QTreeWidgetItem(); - item->setData(0, Qt::DisplayRole, QString::fromLatin1(oobs_group_get_name(group))); - QVariant obj = QVariant::fromValue(group); - item->setData(0, Qt::UserRole, obj); - item->setData(1, Qt::DisplayRole, oobs_group_get_gid(group)); - ui.groupList->addTopLevelItem(item); - valid = oobs_list_iter_next(groups, &it); - } + QTreeWidgetItem* item = new QTreeWidgetItem(); + item->setData(0, Qt::DisplayRole, group->name()); + QVariant obj = QVariant::fromValue((void*)group); + item->setData(0, Qt::UserRole, obj); + item->setData(1, Qt::DisplayRole, group->gid()); + item->setData(2, Qt::DisplayRole, group->members().join(", ")); + ui.groupList->addTopLevelItem(item); } } -OobsUser *MainWindow::userFromItem(QTreeWidgetItem *item) -{ - if(item) - { - QVariant obj = item->data(0, Qt::UserRole); - OobsUser* user = OOBS_USER(obj.value()); - return user; - } - return NULL; +void MainWindow::reload() { + reloadUsers(); + reloadGroups(); } -OobsGroup* MainWindow::groupFromItem(QTreeWidgetItem *item) +UserInfo *MainWindow::userFromItem(QTreeWidgetItem *item) { if(item) { QVariant obj = item->data(0, Qt::UserRole); - return OOBS_GROUP(obj.value()); + return reinterpret_cast(obj.value()); } - return NULL; + return nullptr; } -template -bool MainWindow::authenticate(T *obj) +GroupInfo* MainWindow::groupFromItem(QTreeWidgetItem *item) { - GError* err = NULL; - if(!oobs_object_authenticate(OOBS_OBJECT(obj), &err)) + if(item) { - if(err) - { - QMessageBox::critical(this, tr("Error"), QString::fromUtf8(err->message)); - g_error_free(err); - } - return false; + QVariant obj = item->data(0, Qt::UserRole); + return reinterpret_cast(obj.value()); } - return true; + return nullptr; } void MainWindow::onAdd() { if(ui.tabWidget->currentIndex() == PageUsers) { - if(authenticate(mUsersConfig)) + UserInfo newUser; + UserDialog dlg(mUserManager, &newUser, this); + if(dlg.exec() == QDialog::Accepted) { - UserDialog dlg(NULL, this); - if(dlg.exec() == QDialog::Accepted) - { - OobsUser* user = dlg.user(); - oobs_users_config_add_user(mUsersConfig, user); - oobs_object_commit(OOBS_OBJECT(mUsersConfig)); + mUserManager->addUser(&newUser); + QByteArray newPasswd; + if(getNewPassword(newUser.name(), newPasswd)) { + mUserManager->changePassword(&newUser, newPasswd); } } } else if (ui.tabWidget->currentIndex() == PageGroups) { - if(authenticate(mGroupsConfig)) + GroupInfo newGroup; + GroupDialog dlg(mUserManager, &newGroup, this); + if(dlg.exec() == QDialog::Accepted) { - GroupDialog dlg(NULL, this); - if(dlg.exec() == QDialog::Accepted) - { - OobsGroup* group = dlg.group(); - oobs_groups_config_add_group(mGroupsConfig, group); - oobs_object_commit(OOBS_OBJECT(mGroupsConfig)); - } + mUserManager->addGroup(&newGroup); } } } @@ -185,65 +149,116 @@ void MainWindow::onDelete() if(ui.tabWidget->currentIndex() == PageUsers) { QTreeWidgetItem* item = ui.userList->currentItem(); - OobsUser* user = userFromItem(item); + UserInfo* user = userFromItem(item); if(user) { if(QMessageBox::question(this, tr("Confirm"), tr("Are you sure you want to delete the selected user?"), QMessageBox::Ok|QMessageBox::Cancel) == QMessageBox::Ok) { - oobs_users_config_delete_user(mUsersConfig, user); - oobs_object_commit(OOBS_OBJECT(mUsersConfig)); + mUserManager->deleteUser(user); } } } else if(ui.tabWidget->currentIndex() == PageGroups) { QTreeWidgetItem* item = ui.groupList->currentItem(); - OobsGroup* group = groupFromItem(item); + GroupInfo* group = groupFromItem(item); if(group) { if(QMessageBox::question(this, tr("Confirm"), tr("Are you sure you want to delete the selected group?"), QMessageBox::Ok|QMessageBox::Cancel) == QMessageBox::Ok) { - oobs_groups_config_delete_group(mGroupsConfig, group); - oobs_object_commit(OOBS_OBJECT(mGroupsConfig)); + mUserManager->deleteGroup(group); } } } } +bool MainWindow::getNewPassword(const QString& name, QByteArray& passwd) { + QInputDialog dlg(this); + dlg.setTextEchoMode(QLineEdit::Password); + dlg.setLabelText(tr("Input the new password for %1:").arg(name)); + QLineEdit* edit = dlg.findChild(QString()); + if(edit) { + // NOTE: do we need to add a validator to limit the input? + // QRegExpValidator* validator = new QRegExpValidator(QRegExp(QStringLiteral("\\w*")), edit); + // edit->setValidator(validator); + } + if(dlg.exec() == QDialog::Accepted) { + passwd = dlg.textValue().toUtf8(); + if(passwd.isEmpty()) { + if(QMessageBox::question(this, tr("Confirm"), tr("Are you sure you want to set a empty password?"), QMessageBox::Ok|QMessageBox::Cancel) != QMessageBox::Ok) + return false; + } + return true; + } + return false; +} + +void MainWindow::onChangePasswd() { + QString name; + UserInfo* user = nullptr; + GroupInfo* group = nullptr; + if(ui.tabWidget->currentIndex() == PageUsers) + { + QTreeWidgetItem* item = ui.userList->currentItem(); + user = userFromItem(item); + if (!user) + return; + + name = user->name(); + } + else if(ui.tabWidget->currentIndex() == PageGroups) + { + QTreeWidgetItem* item = ui.groupList->currentItem(); + group = groupFromItem(item); + if (!group) + return; + + name = group->name(); + } + + QByteArray newPasswd; + if(getNewPassword(name, newPasswd)) { + if(user) { + mUserManager->changePassword(user, newPasswd); + } + if(group) { + mUserManager->changePassword(group, newPasswd); + } + } +} + +void MainWindow::onRowActivated(const QModelIndex& index) +{ + onEditProperties(); +} + void MainWindow::onEditProperties() { if(ui.tabWidget->currentIndex() == PageUsers) { QTreeWidgetItem* item = ui.userList->currentItem(); - OobsUser* user = userFromItem(item); - if(user) - { - if(authenticate(mUsersConfig)) + UserInfo* user = userFromItem(item); + if(user) { + UserInfo newSettings(*user); + UserDialog dlg(mUserManager, &newSettings, this); + if(dlg.exec() == QDialog::Accepted) { - UserDialog dlg(user, this); - dlg.exec(); + mUserManager->modifyUser(user, &newSettings); } } } else if(ui.tabWidget->currentIndex() == PageGroups) { QTreeWidgetItem* item = ui.groupList->currentItem(); - OobsGroup* group = groupFromItem(item); - if(group) - { - if(authenticate(mGroupsConfig)) + GroupInfo* group = groupFromItem(item); + if(group) { + GroupInfo newSettings(*group); + GroupDialog dlg(mUserManager, &newSettings, this); + if(dlg.exec() == QDialog::Accepted) { - GroupDialog dlg(group, this); - dlg.exec(); + mUserManager->modifyGroup(group, &newSettings); } } } } -void MainWindow::onRefresh() -{ - oobs_object_update(OOBS_OBJECT(mUsersConfig)); - loadUsers(); - oobs_object_update(OOBS_OBJECT(mGroupsConfig)); - loadGroups(); -} diff --git a/lxqt-admin-user/mainwindow.h b/lxqt-admin-user/mainwindow.h index f3edd50..8e9d6e0 100644 --- a/lxqt-admin-user/mainwindow.h +++ b/lxqt-admin-user/mainwindow.h @@ -24,9 +24,9 @@ #include #include "ui_mainwindow.h" -#include -#include -#include +class UserInfo; +class GroupInfo; +class UserManager; class MainWindow : public QMainWindow { @@ -44,34 +44,23 @@ public: virtual ~MainWindow(); private: - void loadUsers(); - void loadGroups(); - OobsUser* userFromItem(QTreeWidgetItem* item); - OobsGroup* groupFromItem(QTreeWidgetItem *item); - - template - bool authenticate(T* obj); - - static void onUsersConfigChanged(OobsObject* obj, MainWindow* _this) - { - _this->loadUsers(); - } - - static void onGroupsConfigChanged(OobsObject* obj, MainWindow* _this) - { - _this->loadGroups(); - } + UserInfo* userFromItem(QTreeWidgetItem* item); + GroupInfo* groupFromItem(QTreeWidgetItem *item); + bool getNewPassword(const QString& name, QByteArray& passwd); + void reloadUsers(); + void reloadGroups(); private Q_SLOTS: void onAdd(); void onDelete(); void onEditProperties(); - void onRefresh(); + void onChangePasswd(); + void reload(); + void onRowActivated(const QModelIndex& index); private: Ui::MainWindow ui; - OobsUsersConfig* mUsersConfig; - OobsGroupsConfig* mGroupsConfig; + UserManager* mUserManager; }; #endif // MAINWINDOW_H diff --git a/lxqt-admin-user/mainwindow.ui b/lxqt-admin-user/mainwindow.ui index 37e505b..75a4ce7 100644 --- a/lxqt-admin-user/mainwindow.ui +++ b/lxqt-admin-user/mainwindow.ui @@ -6,8 +6,8 @@ 0 0 - 640 - 480 + 676 + 362 @@ -15,7 +15,16 @@ - + + 0 + + + 0 + + + 0 + + 0 @@ -42,9 +51,6 @@ false - - false - Login Name @@ -107,6 +113,11 @@ Group ID + + + Members + + @@ -134,14 +145,14 @@ + - - + .. Add @@ -153,8 +164,7 @@ - - + .. Delete @@ -166,8 +176,7 @@ - - + .. Properties @@ -179,8 +188,7 @@ - - + .. Refresh @@ -189,6 +197,18 @@ Refresh the lists + + + + .. + + + Change Password + + + Change password for the selected user or group + + diff --git a/lxqt-admin-user/org.lxqt.lxqt-admin-user.policy.in b/lxqt-admin-user/org.lxqt.lxqt-admin-user.policy.in new file mode 100644 index 0000000..b479b86 --- /dev/null +++ b/lxqt-admin-user/org.lxqt.lxqt-admin-user.policy.in @@ -0,0 +1,18 @@ + + + + + + Authentication is required for user administration + preferences-system + + auth_admin + auth_admin + auth_admin_keep + + @CMAKE_INSTALL_PREFIX@/bin/lxqt-admin-user-helper + + + diff --git a/lxqt-admin-user/translations/lxqt-admin-user.ts b/lxqt-admin-user/translations/lxqt-admin-user.ts deleted file mode 100644 index b21e617..0000000 --- a/lxqt-admin-user/translations/lxqt-admin-user.ts +++ /dev/null @@ -1,263 +0,0 @@ - - - - - GroupDialog - - - Group Settings - - - - - Group name: - - - - - Group ID: - - - - - Users belong to this group: - - - - - - - Error - - - - - The group ID is in use. - - - - - The group name cannot be empty. - - - - - The group name is in use. - - - - - MainWindow - - - User and Group Settings - - - - - &Users - - - - - Login Name - - - - - User ID - - - - - Full Name - - - - - Group - - - - - Home Directory - - - - - Show system users (for advanced users only) - - - - - &Groups - - - - - Name - - - - - Group ID - - - - - toolBar - - - - - Add - - - - - Add new users or groups - - - - - Delete - - - - - Delete selected item - - - - - Properties - - - - - edit properties of the selected item - - - - - Refresh - - - - - Refresh the lists - - - - - Error - - - - - - Confirm - - - - - Are you sure you want to delete the selected user? - - - - - Are you sure you want to delete the selected group? - - - - - UserDialog - - - User Settings - - - - - General - - - - - Full name: - - - - - Login name: - - - - - Set password: - - - - - User ID: - - - - - Main group: - - - - - Advanced - - - - - Login shell: - - - - - Home directory: - - - - - Change password: - - - - - - - Error - - - - - The user ID is in use. - - - - - The user name cannot be empty. - - - - - The user name is in use. - - - - - Confirm - - - - - Are you sure you want to use an "empty password" for the user? - - - - diff --git a/lxqt-admin-user/translations/lxqt-admin-user_ar.desktop b/lxqt-admin-user/translations/lxqt-admin-user_ar.desktop new file mode 100644 index 0000000..713e07e --- /dev/null +++ b/lxqt-admin-user/translations/lxqt-admin-user_ar.desktop @@ -0,0 +1,4 @@ +#TRANSLATIONS +Name[ar]=المستخدمون والمجموعات +GenericName[ar]=إعدادات المستخدمون والمجموعات +Comment[ar]=اضبط مستخدمو النّظام ومجموعاته diff --git a/lxqt-admin-user/translations/lxqt-admin-user_ca.desktop b/lxqt-admin-user/translations/lxqt-admin-user_ca.desktop new file mode 100644 index 0000000..e8ed741 --- /dev/null +++ b/lxqt-admin-user/translations/lxqt-admin-user_ca.desktop @@ -0,0 +1,3 @@ +Name[ca]=Usuaris i grups +GenericName[ca]=Ajusts dels usuaris i dels grups +Comment[ca]=Configureu els usuaris i els grups del vostre sistema diff --git a/lxqt-admin-user/translations/lxqt-admin-user_de.ts b/lxqt-admin-user/translations/lxqt-admin-user_de.ts deleted file mode 100644 index 7201449..0000000 --- a/lxqt-admin-user/translations/lxqt-admin-user_de.ts +++ /dev/null @@ -1,263 +0,0 @@ - - - - - GroupDialog - - - Group Settings - Gruppeneinstellungen - - - - Group name: - Gruppen-Name: - - - - Group ID: - Gruppen-ID: - - - - Users belong to this group: - Benutzer in dieser Gruppe: - - - - - - Error - Fehler - - - - The group ID is in use. - Die Gruppen-ID existiert bereits. - - - - The group name cannot be empty. - Der Gruppen-Name kann nicht leer sein. - - - - The group name is in use. - Der Gruppen-Name existiert bereits. - - - - MainWindow - - - User and Group Settings - Nutzer- und Gruppeneinstellungen - - - - &Users - &Nutzer - - - - Login Name - Anmeldename - - - - User ID - Nutzer-ID - - - - Full Name - Vollständiger Name - - - - Group - Gruppe - - - - Home Directory - Nutzerverzeichnis - - - - Show system users (for advanced users only) - Systemnutzer anzeigen (nur für erfahrene Nutzer) - - - - &Groups - &Gruppen - - - - Name - Name - - - - Group ID - Gruppen-ID - - - - toolBar - Werkzeugleiste - - - - Add - Hinzufügen - - - - Add new users or groups - Neue Nutzer oder Gruppen hinzufügen - - - - Delete - Entfernen - - - - Delete selected item - Ausgewähltes Element löschen - - - - Properties - Eigenschaften - - - - edit properties of the selected item - Eigenschaften des ausgewählten Elements editieren - - - - Refresh - Erneuern - - - - Refresh the lists - Listen erneuern - - - - Error - Fehler - - - - - Confirm - Bestätigen - - - - Are you sure you want to delete the selected user? - Wollen Sie den ausgewählten Nutzer wirklich löschen? - - - - Are you sure you want to delete the selected group? - Wollen Sie die ausgewählte Gruppe wirklich löschen? - - - - UserDialog - - - User Settings - Nutzereinstellungen - - - - General - Allgemein - - - - Full name: - Vollständiger Name: - - - - Login name: - Anmeldename: - - - - Set password: - Kennwort setzen: - - - - User ID: - Nutzer-ID: - - - - Main group: - Hauptgruppe: - - - - Advanced - Erweitert - - - - Login shell: - Befehlsinterpreter (shell): - - - - Home directory: - Nutzerverzeichnis: - - - - Change password: - Kennwort ändern: - - - - - - Error - Fehler - - - - The user ID is in use. - Die Nutzer-ID existiert bereits. - - - - The user name cannot be empty. - Der Nutzername kann nicht leer sein. - - - - The user name is in use. - Der Nutzername existiert bereits. - - - - Confirm - Bestätigen - - - - Are you sure you want to use an "empty password" for the user? - Wollen Sie wirklich ein "leeres Kennwort" für den Nutzer vergeben? - - - diff --git a/lxqt-admin-user/translations/lxqt-admin-user_el.ts b/lxqt-admin-user/translations/lxqt-admin-user_el.ts deleted file mode 100644 index a52e208..0000000 --- a/lxqt-admin-user/translations/lxqt-admin-user_el.ts +++ /dev/null @@ -1,263 +0,0 @@ - - - - - GroupDialog - - - Group Settings - Ρυθμίσεις ομάδας - - - - Group name: - Όνομα ομάδας: - - - - Group ID: - Αναγνωριστικό ομάδας: - - - - Users belong to this group: - Χρήστες που ανήκουν στην ομάδα: - - - - - - Error - Σφάλμα - - - - The group ID is in use. - Το αναγνωριστικό της ομάδας χρησιμοποιείται ήδη. - - - - The group name cannot be empty. - Το όνομα της ομάδας δεν μπορεί να είναι κενό. - - - - The group name is in use. - Το όνομα της ομάδας χρησιμοποιείται ήδη. - - - - MainWindow - - - User and Group Settings - Ρυθμίσεις χρηστών και ομάδων - - - - &Users - &Χρήστες - - - - Login Name - Όνομα χρήστη - - - - User ID - Αναγνωριστικό χρήστη - - - - Full Name - Πλήρες όνομα - - - - Group - Ομάδα - - - - Home Directory - Προσωπικός κατάλογος - - - - Show system users (for advanced users only) - Εμφάνιση των χρηστών του συστήματος (μόνο για προηγμένους χρήστες) - - - - &Groups - &Ομάδες - - - - Name - Όνομα - - - - Group ID - Αναγνωριστικό ομάδας - - - - toolBar - Γραμμή εργαλείων - - - - Add - Προσθήκη - - - - Add new users or groups - Προσθήκη νέων χρηστών ή ομάδων - - - - Delete - Διαγραφή - - - - Delete selected item - Διαγραφή του επιλεγμένου αντικειμένου - - - - Properties - Ιδιότητες - - - - edit properties of the selected item - Επεξεργασία των ιδιοτήτων για το επιλεγμένο αντικείμενο - - - - Refresh - Ανανέωση - - - - Refresh the lists - Ανανέωση της λίστας - - - - Error - Σφάλμα - - - - - Confirm - Επιβεβαίωση - - - - Are you sure you want to delete the selected user? - Είστε σίγουρος-η ότι θέλετε να διαγράψετε τον επιλεγμένο χρήστη; - - - - Are you sure you want to delete the selected group? - Είστε σίγουρος-η ότι θέλετε να διαγράψετε την επιλεγμένη ομάδα; - - - - UserDialog - - - User Settings - Ρυθμίσεις χρήστη - - - - General - Γενικά - - - - Full name: - Πλήρες όνομα: - - - - Login name: - Όνομα χρήστη: - - - - Set password: - Ορισμός του κωδικού πρόσβασης: - - - - User ID: - Αναγνωριστικό χρήστη: - - - - Main group: - Κύρια ομάδα: - - - - Advanced - Προηγμένο - - - - Login shell: - Κέλυφος σύνδεσης: - - - - Home directory: - Προσωπικός κατάλογος: - - - - Change password: - Αλλαγή του κωδικού πρόσβασης: - - - - - - Error - Σφάλμα - - - - The user ID is in use. - Το αναγνωριστικό του χρήστη χρησιμοποιείται ήδη. - - - - The user name cannot be empty. - Το όνομα χρήστη δεν μπορεί να είναι κενό. - - - - The user name is in use. - Το όνομα του χρήστη χρησιμοποιείται ήδη. - - - - Confirm - Επιβεβαίωση - - - - Are you sure you want to use an "empty password" for the user? - Είστε σίγουρος-η ότι θέλετε να χρησιμοποιήσετε έναν «κενό κωδικό πρόσβασης» για τον χρήστη; - - - diff --git a/lxqt-admin-user/translations/lxqt-admin-user_hr.ts b/lxqt-admin-user/translations/lxqt-admin-user_hr.ts deleted file mode 100644 index 13967d6..0000000 --- a/lxqt-admin-user/translations/lxqt-admin-user_hr.ts +++ /dev/null @@ -1,263 +0,0 @@ - - - - - GroupDialog - - - Group Settings - Postavke grupe - - - - Group name: - Ime grupe: - - - - Group ID: - ID grupe - - - - Users belong to this group: - Korisnici koji pripadaju ovoj grupi - - - - - - Error - Greška - - - - The group ID is in use. - ID grupe je u uporabi. - - - - The group name cannot be empty. - Ime grupe ne može biti prazno. - - - - The group name is in use. - Ime grupe je u uporabi. - - - - MainWindow - - - User and Group Settings - Postavke korisnika i grupe - - - - &Users - &Korisnici - - - - Login Name - Ime prijave - - - - User ID - ID korisnika - - - - Full Name - Puno ime - - - - Group - Grupa - - - - Home Directory - Osobna mapa - - - - Show system users (for advanced users only) - - - - - &Groups - &Grupe - - - - Name - Ime - - - - Group ID - ID grupe - - - - toolBar - alatna traka - - - - Add - Dodaj - - - - Add new users or groups - Dodaj nove korisnike ili grupe - - - - Delete - Izbriši - - - - Delete selected item - Izbriši odabranu stavku - - - - Properties - Svojstva - - - - edit properties of the selected item - uredi svojstva odabrane stavke - - - - Refresh - Osvježi - - - - Refresh the lists - Osvježi liste - - - - Error - Greška - - - - - Confirm - Potvrdi - - - - Are you sure you want to delete the selected user? - Jeste li sigurni da želite izbrisati odabranoga korisnika? - - - - Are you sure you want to delete the selected group? - Jeste li sigurni da želite izbrisati odabranu grupu? - - - - UserDialog - - - User Settings - Postavke korisnika - - - - General - Općenito - - - - Full name: - Puno ime: - - - - Login name: - Ime prijave: - - - - Set password: - Postavi lozinku: - - - - User ID: - ID korisnika: - - - - Main group: - Glavna grupa: - - - - Advanced - Napredno - - - - Login shell: - Ljuska prijave: - - - - Home directory: - Osobna mapa: - - - - Change password: - Promjeni lozinku: - - - - - - Error - Greška - - - - The user ID is in use. - ID korisnika je u uporabi. - - - - The user name cannot be empty. - Korisničko ime ne može biti prazno. - - - - The user name is in use. - Korisničko ime je u uoprabi. - - - - Confirm - Potvrdi - - - - Are you sure you want to use an "empty password" for the user? - Jeste li sigurni da želite koristiti "praznu lozinku" za korisnika? - - - diff --git a/lxqt-admin-user/translations/lxqt-admin-user_hu.ts b/lxqt-admin-user/translations/lxqt-admin-user_hu.ts deleted file mode 100644 index 24e4806..0000000 --- a/lxqt-admin-user/translations/lxqt-admin-user_hu.ts +++ /dev/null @@ -1,263 +0,0 @@ - - - - - GroupDialog - - - Group Settings - Csoportbeállítás - - - - Group name: - Csoportnév: - - - - Group ID: - Csoport ID - - - - Users belong to this group: - A csoport tagjai: - - - - - - Error - Hiba - - - - The group ID is in use. - Csoport ID foglalt. - - - - The group name cannot be empty. - Csoportnév nem lehet üres. - - - - The group name is in use. - Csoportnév foglalt. - - - - MainWindow - - - User and Group Settings - Felhasználók és csoportok - - - - &Users - &Felhasználók - - - - Login Name - Bejelenkezési név - - - - User ID - Felhasználó ID - - - - Full Name - Teljes név - - - - Group - Csoport - - - - Home Directory - Saját könyvtár - - - - Show system users (for advanced users only) - Rendszer felhasználók is látszanak (csak haladóknak) - - - - &Groups - &Csoportok - - - - Name - Név - - - - Group ID - Csoport ID - - - - toolBar - eszközsáv - - - - Add - Hozzáad - - - - Add new users or groups - Új felhasználó, vagy csoport hozzáadása - - - - Delete - Törlés - - - - Delete selected item - Kiválasztott törlése - - - - Properties - Tulajdonságok - - - - edit properties of the selected item - A választott elem módosítása - - - - Refresh - Frisítés - - - - Refresh the lists - Lista frissítése - - - - Error - Hiba - - - - - Confirm - Megerősítés - - - - Are you sure you want to delete the selected user? - Tényleg töröljük az illető felhasználót? - - - - Are you sure you want to delete the selected group? - Tényleg töröljük az illető csoportot? - - - - UserDialog - - - User Settings - Felhasználó beállítása - - - - General - Alap - - - - Full name: - Teljes név: - - - - Login name: - Bejelenkezési név: - - - - Set password: - Jelszóbeállítás: - - - - User ID: - Felhasználó ID: - - - - Main group: - Főcsoport - - - - Advanced - Bővített - - - - Login shell: - Parancsértelmező: - - - - Home directory: - Saját könyvtár: - - - - Change password: - Jelszóváltoztatás: - - - - - - Error - Hiba - - - - The user ID is in use. - Felhasználó ID foglalt. - - - - The user name cannot be empty. - Felhasználónév nem lehet üres. - - - - The user name is in use. - Felhasználónév foglalt. - - - - Confirm - Megerősítés - - - - Are you sure you want to use an "empty password" for the user? - Üres legyen a jelszava a felhasználónak? - - - diff --git a/lxqt-admin-user/translations/lxqt-admin-user_it.ts b/lxqt-admin-user/translations/lxqt-admin-user_it.ts deleted file mode 100644 index 5a71d1c..0000000 --- a/lxqt-admin-user/translations/lxqt-admin-user_it.ts +++ /dev/null @@ -1,264 +0,0 @@ - - - - - GroupDialog - - - Group Settings - Gestione gruppi - - - - Group name: - Nome del gruppo: - - - - Group ID: - ID gruppo: - - - - Users belong to this group: - Utenti appartenenti: - - - - - - Error - Errore - - - - The group ID is in use. - ID già in uso - - - - The group name cannot be empty. - Il nome non può essere vuoto. - - - - The group name is in use. - Il nome è già in uso. - - - - MainWindow - - - User and Group Settings - Impostazioni utenti e gruppi - - - - &Users - remove &_ in source - Utenti - - - - Login Name - Nome Login - - - - User ID - ID utente - - - - Full Name - Nome completo - - - - Group - Gruppo - - - - Home Directory - Cartella Home - - - - Show system users (for advanced users only) - Mostra utenti di sistema (avanzato) - - - - &Groups - Gruppi - - - - Name - Nome - - - - Group ID - ID gruppo - - - - toolBar - - - - - Add - Aggiungi - - - - Add new users or groups - Aggiungi utenti o gruppi nuovi - - - - Delete - Cancella - - - - Delete selected item - Cancella selezionato - - - - Properties - Proprietà - - - - edit properties of the selected item - Modifica proprietà - - - - Refresh - Aggiorna - - - - Refresh the lists - Aggiorna lista - - - - Error - Errore - - - - - Confirm - Conferma - - - - Are you sure you want to delete the selected user? - Si è sicuro di voler cancellare l'utente selezionato? - - - - Are you sure you want to delete the selected group? - Si è sicuro di voler cancellare il gruppo selezionato? - - - - UserDialog - - - User Settings - Impostazioni utente - - - - General - Generali - - - - Full name: - Nome completo: - - - - Login name: - Nome al Login: - - - - Set password: - Scegli il password: - - - - User ID: - ID utente - - - - Main group: - Gruppo principale: - - - - Advanced - Avanzate: - - - - Login shell: - Shell del login: - - - - Home directory: - Cartella home: - - - - Change password: - Cambia password: - - - - - - Error - Errore - - - - The user ID is in use. - ID già in uso. - - - - The user name cannot be empty. - Il nome non può essere vuoto. - - - - The user name is in use. - Il nome è già in uso. - - - - Confirm - Conferma - - - - Are you sure you want to use an "empty password" for the user? - Si è sicuro di volere un password vuoto per l'utente? - - - diff --git a/lxqt-admin-user/translations/lxqt-admin-user_ja.ts b/lxqt-admin-user/translations/lxqt-admin-user_ja.ts deleted file mode 100644 index c26805c..0000000 --- a/lxqt-admin-user/translations/lxqt-admin-user_ja.ts +++ /dev/null @@ -1,263 +0,0 @@ - - - - - GroupDialog - - - Group Settings - グループ設定 - - - - Group name: - グループ名: - - - - Group ID: - グループID: - - - - Users belong to this group: - このグループに属しているユーザー: - - - - - - Error - エラー - - - - The group ID is in use. - そのグループIDはすでに使われています - - - - The group name cannot be empty. - グループ名を入力する必要があります - - - - The group name is in use. - そのグループ名はすでに使われています - - - - MainWindow - - - User and Group Settings - ユーザーとグループの設定 - - - - &Users - ユーザー(&U) - - - - Login Name - ログイン名 - - - - User ID - ユーザーID - - - - Full Name - フルネーム - - - - Group - グループ - - - - Home Directory - ホームディレクトリー - - - - Show system users (for advanced users only) - システムユーザーを表示(上級者専用) - - - - &Groups - グループ(&G) - - - - Name - 名前 - - - - Group ID - グループID - - - - toolBar - ツールバー - - - - Add - 追加 - - - - Add new users or groups - 新しいユーザーまたはグループを追加 - - - - Delete - 削除 - - - - Delete selected item - 選択した項目を削除 - - - - Properties - プロパティー - - - - edit properties of the selected item - 選択した項目のプロパティーを編集 - - - - Refresh - 再読込み - - - - Refresh the lists - リストを再読込み - - - - Error - エラー - - - - - Confirm - 確認 - - - - Are you sure you want to delete the selected user? - 本当に、選択したユーザーを削除してよいですか? - - - - Are you sure you want to delete the selected group? - 本当に、選択したグループを削除してよいですか? - - - - UserDialog - - - User Settings - ユーザー設定 - - - - General - 一般 - - - - Full name: - フルネーム: - - - - Login name: - ログイン名: - - - - Set password: - パスワードを設定: - - - - User ID: - ユーザーID: - - - - Main group: - メイングループ: - - - - Advanced - 高度 - - - - Login shell: - ログインシェル: - - - - Home directory: - ホームディレクトリー: - - - - Change password: - パスワードを変更: - - - - - - Error - エラー - - - - The user ID is in use. - そのユーザーIDはすでに使われています - - - - The user name cannot be empty. - ユーザー名を入力する必要があります - - - - The user name is in use. - そのユーザー名はすでに使われています - - - - Confirm - 確認 - - - - Are you sure you want to use an "empty password" for the user? - 本当に、空のパスワードをそのユーザーに設定してよいですか? - - - diff --git a/lxqt-admin-user/translations/lxqt-admin-user_pl.ts b/lxqt-admin-user/translations/lxqt-admin-user_pl.ts deleted file mode 100644 index 104584b..0000000 --- a/lxqt-admin-user/translations/lxqt-admin-user_pl.ts +++ /dev/null @@ -1,263 +0,0 @@ - - - - - GroupDialog - - - Group Settings - Ustawienia Grup - - - - Group name: - Nazwa grupy: - - - - Group ID: - ID grupy: - - - - Users belong to this group: - Użytkownicy należący do tej grupy: - - - - - - Error - Błąd - - - - The group ID is in use. - ID grupy jest już w użyciu. - - - - The group name cannot be empty. - Nazwa grupy nie może być pusta. - - - - The group name is in use. - Ta nazwa grupy jest już w użyciu. - - - - MainWindow - - - User and Group Settings - Ustawienia użytkowników i grup - - - - &Users - &Użytkownicy - - - - Login Name - Login - - - - User ID - ID użytkownika - - - - Full Name - Pełna nazwa - - - - Group - Grupa - - - - Home Directory - Katalog domowy - - - - Show system users (for advanced users only) - Pokaż użytkowników systemowych (dla zaawansowanych) - - - - &Groups - &Grupy - - - - Name - Nazwa - - - - Group ID - ID grupy - - - - toolBar - Pasek narzędzi - - - - Add - Dodaj - - - - Add new users or groups - Dodaj nowych użytkowników lub grupy - - - - Delete - Usuń - - - - Delete selected item - Usuń zaznaczoną pozycję - - - - Properties - Właściwości - - - - edit properties of the selected item - edytuj właściwości dla wybranej pozycji - - - - Refresh - Odśwież - - - - Refresh the lists - Odśwież listę - - - - Error - Błąd - - - - - Confirm - Potwierdzenie - - - - Are you sure you want to delete the selected user? - Czy na pewno chcesz usunąć wybranego użytkownika? - - - - Are you sure you want to delete the selected group? - Czy na pewno chcesz usunąć wybraną grupę? - - - - UserDialog - - - User Settings - Ustawienia użytkownika - - - - General - Ogólne - - - - Full name: - Pełna nazwa: - - - - Login name: - Login: - - - - Set password: - Ustaw hasło: - - - - User ID: - ID użytkownika: - - - - Main group: - Grupa główna: - - - - Advanced - Zaawansowane - - - - Login shell: - Powłoka: - - - - Home directory: - Katalog domowy: - - - - Change password: - Zmień hasło: - - - - - - Error - Błąd - - - - The user ID is in use. - To ID użytkownika jest już w użyciu. - - - - The user name cannot be empty. - Nazwa użytkownika nie może być pusta. - - - - The user name is in use. - Ta nazwa użytkownika jest już w użyciu. - - - - Confirm - Potwierdzenie - - - - Are you sure you want to use an "empty password" for the user? - Czy na pewno chcesz użyć "pustego hasła" dla tego użytkownika? - - - diff --git a/lxqt-admin-user/translations/lxqt-admin-user_pt.ts b/lxqt-admin-user/translations/lxqt-admin-user_pt.ts deleted file mode 100644 index c3eb94e..0000000 --- a/lxqt-admin-user/translations/lxqt-admin-user_pt.ts +++ /dev/null @@ -1,263 +0,0 @@ - - - - - GroupDialog - - - Group Settings - Definições de grupo - - - - Group name: - Nome do grupo: - - - - Group ID: - ID do grupo: - - - - Users belong to this group: - Utilizadores pertencentes a este grupo: - - - - - - Error - Erro - - - - The group ID is in use. - O ID do grupo já está em utilização. - - - - The group name cannot be empty. - O nome do grupo não pode estar vazio. - - - - The group name is in use. - O nome do grupo já está em utilização. - - - - MainWindow - - - User and Group Settings - Definições de grupo e utilizador - - - - &Users - &Utilizadores - - - - Login Name - Nome de acesso - - - - User ID - ID de utilizador - - - - Full Name - Nome completo - - - - Group - Grupo - - - - Home Directory - Pasta pessoal - - - - Show system users (for advanced users only) - Mostrar utilizadores de sistema - - - - &Groups - &Grupos - - - - Name - Nome - - - - Group ID - ID do grupo - - - - toolBar - Barra de ferramentas - - - - Add - Adicionar - - - - Add new users or groups - Adicionar utilizadores ou grupos - - - - Delete - Eliminar - - - - Delete selected item - Eliminar item selecionado - - - - Properties - Propriedades - - - - edit properties of the selected item - Editar propriedades do item selecionado - - - - Refresh - Atualizar - - - - Refresh the lists - Atualizar as listas - - - - Error - Erro - - - - - Confirm - Confirmação - - - - Are you sure you want to delete the selected user? - Tem a certeza que quer eliminar o utilizador selecionado? - - - - Are you sure you want to delete the selected group? - Tem a certeza que quer eliminar o grupo selecionado? - - - - UserDialog - - - User Settings - Definições de utilizador - - - - General - Geral - - - - Full name: - Nome completo: - - - - Login name: - Nome de acesso: - - - - Set password: - Definir senha: - - - - User ID: - ID de utilizador: - - - - Main group: - Grupo principal: - - - - Advanced - Avançado - - - - Login shell: - Consola de acesso: - - - - Home directory: - Pasta pessoal: - - - - Change password: - Mudar senha: - - - - - - Error - Erro - - - - The user ID is in use. - O ID do utilizador já está em utilização. - - - - The user name cannot be empty. - O nome de utilizador não pode estar vazio. - - - - The user name is in use. - O nome de utilizador já está em utilização. - - - - Confirm - Confirmação - - - - Are you sure you want to use an "empty password" for the user? - Tem a certeza que quer definir uma senha vazia para o utilizador? - - - diff --git a/lxqt-admin-user/translations/lxqt-admin-user_ru.ts b/lxqt-admin-user/translations/lxqt-admin-user_ru.ts deleted file mode 100644 index b20efea..0000000 --- a/lxqt-admin-user/translations/lxqt-admin-user_ru.ts +++ /dev/null @@ -1,263 +0,0 @@ - - - - - GroupDialog - - - Group Settings - Настройки группы - - - - Group name: - Имя группы: - - - - Group ID: - ID группы: - - - - Users belong to this group: - Пользователи, относящиеся к этой группе: - - - - - - Error - Ошибка - - - - The group ID is in use. - ID группы уже используется. - - - - The group name cannot be empty. - Имя группы не может быть пустым. - - - - The group name is in use. - Имя группы уже используется. - - - - MainWindow - - - User and Group Settings - Настройки пользователя и группы - - - - &Users - &Пользователи - - - - Login Name - Логин пользователя - - - - User ID - ID пользователя - - - - Full Name - Полное имя - - - - Group - Группа - - - - Home Directory - Домашний каталог - - - - Show system users (for advanced users only) - Показывать системных пользователей (только для продвинутых пользователей) - - - - &Groups - &Группы - - - - Name - Имя - - - - Group ID - ID группы - - - - toolBar - Панель - - - - Add - Добавить - - - - Add new users or groups - Добавить новых пользователей или группы - - - - Delete - Удалить - - - - Delete selected item - Удалить выбранный элемент - - - - Properties - Свойства - - - - edit properties of the selected item - Редактировать свойства выделенного элемента - - - - Refresh - Обновить - - - - Refresh the lists - Обновить список - - - - Error - Ошибка - - - - - Confirm - Подтвердить - - - - Are you sure you want to delete the selected user? - Вы действительно хотите удалить выбранного пользователя? - - - - Are you sure you want to delete the selected group? - Вы действительно хотите удалить выбранную группу? - - - - UserDialog - - - User Settings - Настройки пользователя - - - - General - Общие - - - - Full name: - Полное имя: - - - - Login name: - Логин пользователя: - - - - Set password: - Установить пароль: - - - - User ID: - ID пользователя: - - - - Main group: - Главная группа: - - - - Advanced - Расширенные - - - - Login shell: - Оболочка: - - - - Home directory: - Домашний каталог: - - - - Change password: - Изменить пароль: - - - - - - Error - Ошибка - - - - The user ID is in use. - Пользовательский ID уже используется. - - - - The user name cannot be empty. - Имя пользователя не может быть пустым. - - - - The user name is in use. - Имя пользователя уже используется. - - - - Confirm - Подтвердить - - - - Are you sure you want to use an "empty password" for the user? - Вы действительно хотите использовать пустой пароль для этого пользователя? - - - diff --git a/lxqt-admin-user/translations/lxqt-admin-user_ru_RU.desktop b/lxqt-admin-user/translations/lxqt-admin-user_ru_RU.desktop deleted file mode 100644 index 372cdf4..0000000 --- a/lxqt-admin-user/translations/lxqt-admin-user_ru_RU.desktop +++ /dev/null @@ -1,6 +0,0 @@ -[Desktop Entry] -Name[ru_RU]=Пользователи и группы -GenericName[ru_RU]=Настройки пользователей и групп -Comment[ru_RU]=Настроить пользователей и группы вашей системы - -#TRANSLATIONS_DIR=translations diff --git a/lxqt-admin-user/translations/lxqt-admin-user_ru_RU.ts b/lxqt-admin-user/translations/lxqt-admin-user_ru_RU.ts deleted file mode 100644 index 6cfc4da..0000000 --- a/lxqt-admin-user/translations/lxqt-admin-user_ru_RU.ts +++ /dev/null @@ -1,263 +0,0 @@ - - - - - GroupDialog - - - Group Settings - Настройки группы - - - - Group name: - Имя группы: - - - - Group ID: - ID группы: - - - - Users belong to this group: - Пользователи, относящиеся к этой группе: - - - - - - Error - Ошибка - - - - The group ID is in use. - ID группы уже используется. - - - - The group name cannot be empty. - Имя группы не может быть пустым. - - - - The group name is in use. - Имя группы уже используется. - - - - MainWindow - - - User and Group Settings - Настройки пользователя и группы - - - - &Users - &Пользователи - - - - Login Name - Логин пользователя - - - - User ID - ID пользователя - - - - Full Name - Полное имя - - - - Group - Группа - - - - Home Directory - Домашний каталог - - - - Show system users (for advanced users only) - Показывать системных пользователей (только для продвинутых пользователей) - - - - &Groups - &Группы - - - - Name - Имя - - - - Group ID - ID группы - - - - toolBar - Панель - - - - Add - Добавить - - - - Add new users or groups - Добавить новых пользователей или группы - - - - Delete - Удалить - - - - Delete selected item - Удалить выбранный элемент - - - - Properties - Свойства - - - - edit properties of the selected item - Редактировать свойства выделенного элемента - - - - Refresh - Обновить - - - - Refresh the lists - Обновить список - - - - Error - Ошибка - - - - - Confirm - Подтвердить - - - - Are you sure you want to delete the selected user? - Вы действительно хотите удалить выбранного пользователя? - - - - Are you sure you want to delete the selected group? - Вы действительно хотите удалить выбранную группу? - - - - UserDialog - - - User Settings - Настройки пользователя - - - - General - Общие - - - - Full name: - Полное имя: - - - - Login name: - Логин пользователя: - - - - Set password: - Установить пароль: - - - - User ID: - ID пользователя: - - - - Main group: - Главная группа: - - - - Advanced - Расширенные - - - - Login shell: - Оболочка: - - - - Home directory: - Домашний каталог: - - - - Change password: - Изменить пароль: - - - - - - Error - Ошибка - - - - The user ID is in use. - Пользовательский ID уже используется. - - - - The user name cannot be empty. - Имя пользователя не может быть пустым. - - - - The user name is in use. - Имя пользователя уже используется. - - - - Confirm - Подтвердить - - - - Are you sure you want to use an "empty password" for the user? - Вы действительно хотите использовать пустой пароль для этого пользователя? - - - diff --git a/lxqt-admin-user/userdialog.cpp b/lxqt-admin-user/userdialog.cpp index 292df06..7dbd770 100644 --- a/lxqt-admin-user/userdialog.cpp +++ b/lxqt-admin-user/userdialog.cpp @@ -20,76 +20,65 @@ #include "userdialog.h" #include +#include +#include +#include "usermanager.h" #define DEFAULT_UID_MIN 1000 #define DEFAULT_UID_MAX 32768 -UserDialog::UserDialog(OobsUser* user, QWidget* parent): - QDialog(), - mUser(user ? OOBS_USER(g_object_ref(user)) : NULL), +UserDialog::UserDialog(UserManager* userManager, UserInfo* user, QWidget* parent): + QDialog(parent), + mUserManager(userManager), + mUser(user), mFullNameChanged(false), mHomeDirChanged(false) { ui.setupUi(this); - + bool isNewUser = (user->uid() == 0 && user->name().isEmpty()); // load all groups - OobsGroupsConfig* groupsConfig = OOBS_GROUPS_CONFIG(oobs_groups_config_get()); - OobsList* groups = oobs_groups_config_get_groups(groupsConfig); - if(groups) + for(const GroupInfo* group: mUserManager->groups()) { - OobsListIter it; - gboolean valid = oobs_list_get_iter_first(groups, &it); - while(valid) + ui.mainGroup->addItem(group->name()); + + QListWidgetItem* item = new QListWidgetItem(); + item->setText(group->name()); + item->setFlags(Qt::ItemIsEnabled|Qt::ItemIsUserCheckable|Qt::ItemIsSelectable); + if(!isNewUser) { - OobsGroup* group = OOBS_GROUP(oobs_list_get(groups, &it)); - ui.mainGroup->addItem(oobs_group_get_name(group)); - valid = oobs_list_iter_next(groups, &it); + if(group->hasMember(user->name()) || user->gid() == group->gid()) // the user is in this group + item->setCheckState(Qt::Checked); + else + item->setCheckState(Qt::Unchecked); } + else + item->setCheckState(Qt::Unchecked); + ui.groupList->addItem(item); } - connect(ui.loginName, SIGNAL(textChanged(QString)), SLOT(onLoginNameChanged(QString))); - OobsUsersConfig* userConfig = OOBS_USERS_CONFIG(oobs_users_config_get()); - - // add known shells to the combo box for selection - GList* shells = oobs_users_config_get_available_shells(userConfig); - for(GList* l = shells; l; l = l->next) - { - const char* shell = (const char*)l->data; - ui.loginShell->addItem(QLatin1String(shell)); - } + ui.loginShell->addItems(mUserManager->availableShells()); - if(user) // edit an existing user + if(isNewUser) // new user { - mOldUid = oobs_user_get_uid(user); - ui.loginName->setReadOnly(true); - ui.loginName->setText(oobs_user_get_login_name(user)); - ui.changePasswd->setText(tr("Change password:")); - ui.uid->setValue(mOldUid); - ui.fullName->setText(oobs_user_get_full_name(user)); - ui.loginShell->setEditText(oobs_user_get_shell(user)); - ui.homeDir->setText(QString::fromLocal8Bit(oobs_user_get_home_directory(user))); - - OobsGroup* group = oobs_user_get_main_group(user); - ui.mainGroup->setEditText(oobs_group_get_name(group)); + ui.mainGroup->setCurrentIndex(-1); + ui.loginShell->setCurrentIndex(-1); } - else // create a new user + else // edit an existing user { - mOldUid = -1; - ui.loginName->setReadOnly(false); - ui.loginName->setFocus(); - ui.changePasswd->setChecked(true); - ui.uid->setValue(oobs_users_config_find_free_uid(userConfig, DEFAULT_UID_MIN, DEFAULT_UID_MAX)); - ui.loginShell->setEditText(oobs_users_config_get_default_shell(userConfig)); - ui.mainGroup->setCurrentIndex(-1); + ui.loginName->setText(user->name()); + ui.uid->setValue(user->uid()); + ui.fullName->setText(user->fullName()); + ui.loginShell->setEditText(user->shell()); + ui.homeDir->setText(user->homeDir()); + GroupInfo* group = userManager->findGroupInfo(user->gid()); + if(group) + ui.mainGroup->setEditText(group->name()); } - } UserDialog::~UserDialog() { - if(mUser) - g_object_unref(mUser); } void UserDialog::onLoginNameChanged(const QString& text) @@ -121,61 +110,33 @@ void UserDialog::onHomeDirChanged(const QString& text) void UserDialog::accept() { - OobsUsersConfig* usersConfig = OOBS_USERS_CONFIG(oobs_users_config_get()); - uid_t uid = ui.uid->value(); - if(uid != mOldUid && oobs_users_config_is_uid_used(usersConfig, uid)) + mUser->setUid(ui.uid->value()); + QString loginName = ui.loginName->text(); + if(loginName.isEmpty()) { - QMessageBox::critical(this, tr("Error"), tr("The user ID is in use.")); + QMessageBox::critical(this, tr("Error"), tr("The user name cannot be empty.")); return; } + mUser->setName(loginName); + mUser->setFullName(ui.fullName->text()); - bool createNew; - if(mUser) - createNew = false; - else - { - createNew = true; - QByteArray loginName = ui.loginName->text().toLatin1(); - if(loginName.isEmpty()) - { - QMessageBox::critical(this, tr("Error"), tr("The user name cannot be empty.")); - return; - } - if(oobs_users_config_is_login_used(usersConfig, loginName)) - { - QMessageBox::critical(this, tr("Error"), tr("The user name is in use.")); - return; - } - mUser = oobs_user_new(loginName); - } - oobs_user_set_uid(mUser, uid); + mUser->setHomeDir(ui.homeDir->text()); - QByteArray fullName = ui.fullName->text().toUtf8(); - oobs_user_set_full_name(mUser, fullName); + // main group + QString groupName = ui.mainGroup->currentText(); + if(!groupName.isEmpty()) { + GroupInfo* group = mUserManager->findGroupInfo(groupName); + if(group) + mUser->setGid(group->gid()); + } - // change password - if(ui.changePasswd->isChecked()) - { - QByteArray passwd = ui.passwd->text().toLatin1(); - if(passwd.isEmpty()) // show warnings if the password is empty - { - if(QMessageBox::warning(this, tr("Confirm"), tr("Are you sure you want to use an \"empty password\" for the user?"), QMessageBox::Yes|QMessageBox::No) == QMessageBox::Yes) - oobs_user_set_password_empty(mUser, true); + // other groups + mUser->removeAllGroups(); + for(int row = 0; row < ui.groupList->count(); ++row) { + QListWidgetItem* item = ui.groupList->item(row); + if(item->checkState() == Qt::Checked) { + mUser->addGroup(item->text()); } - else - oobs_user_set_password(mUser, passwd); } - - QByteArray homeDir = ui.homeDir->text().toLocal8Bit(); - oobs_user_set_home_directory(mUser, homeDir); - - // main group - OobsGroupsConfig* groupsConfig = OOBS_GROUPS_CONFIG(oobs_groups_config_get()); - QByteArray groupName = ui.mainGroup->currentText().toLatin1(); - OobsGroup* group = oobs_groups_config_get_from_name(groupsConfig, groupName); - oobs_user_set_main_group(mUser, group); - - if(!createNew) - oobs_object_commit_async(OOBS_OBJECT(mUser), NULL, NULL); QDialog::accept(); } diff --git a/lxqt-admin-user/userdialog.h b/lxqt-admin-user/userdialog.h index 23bb8ee..368787d 100644 --- a/lxqt-admin-user/userdialog.h +++ b/lxqt-admin-user/userdialog.h @@ -23,23 +23,19 @@ #include #include "ui_userdialog.h" -#include -#include -#include +#include "usermanager.h" + +class UserManager; +class UserInfo; class UserDialog : public QDialog { Q_OBJECT public: - UserDialog(OobsUser* user = NULL, QWidget* parent = NULL); + UserDialog(UserManager* userManager, UserInfo* user, QWidget* parent = nullptr); ~UserDialog(); - OobsUser* user() - { - return mUser; - } - virtual void accept(); private Q_SLOTS: @@ -49,14 +45,8 @@ private Q_SLOTS: private: Ui::UserDialog ui; - OobsUser* mUser; - uid_t mOldUid; -#if 0 - QByteArray mOldLoginName; - QByteArray mOldFullName; - QByteArray mOldGroupName; - QByteArray mOldHomeDir; -#endif + UserManager* mUserManager; + UserInfo* mUser; bool mFullNameChanged; bool mHomeDirChanged; diff --git a/lxqt-admin-user/userdialog.ui b/lxqt-admin-user/userdialog.ui index 4e349cc..7e226c7 100644 --- a/lxqt-admin-user/userdialog.ui +++ b/lxqt-admin-user/userdialog.ui @@ -27,16 +27,6 @@ QFormLayout::AllNonFixedFieldsGrow - - - - Full name: - - - - - - @@ -48,44 +38,40 @@ - + - Set password: + Full name: - - - false - - - QLineEdit::Password + + + + + + User ID: - + + + Default + 32768 - - - User ID: - - - - Main group: - + true @@ -94,6 +80,30 @@ + + + Groups + + + + + + The user belongs to the following groups: + + + + + + + + 0 + 1 + + + + + + Advanced @@ -173,21 +183,5 @@ - - changePasswd - toggled(bool) - passwd - setEnabled(bool) - - - 71 - 125 - - - 192 - 129 - - - diff --git a/lxqt-admin-user/usermanager.cpp b/lxqt-admin-user/usermanager.cpp new file mode 100644 index 0000000..0238948 --- /dev/null +++ b/lxqt-admin-user/usermanager.cpp @@ -0,0 +1,393 @@ +/* BEGIN_COMMON_COPYRIGHT_HEADER + * (c)LGPL2+ + * + * LXQt - a lightweight, Qt based, desktop toolset + * http://lxqt.org + * + * Copyright: 2016 LXQt team + * Authors: + * Hong Jen Yee (PCMan) + * + * This program or library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * END_COMMON_COPYRIGHT_HEADER */ + +#include "usermanager.h" +#include +#include +#include +#include +#include +#include +#include +#include + +static const QString PASSWD_FILE = QStringLiteral("/etc/passwd"); +static const QString GROUP_FILE = QStringLiteral("/etc/group"); +static const QString LOGIN_DEFS_FILE = QStringLiteral("/etc/login.defs"); + +UserManager::UserManager(QObject *parent): + QObject(parent), + mWatcher(new QFileSystemWatcher(QStringList() << PASSWD_FILE << GROUP_FILE, this)) +{ + loadUsersAndGroups(); + connect(mWatcher, &QFileSystemWatcher::fileChanged, this, &UserManager::onFileChanged); +} + +UserManager::~UserManager() { + qDeleteAll(mUsers); + qDeleteAll(mGroups); +} + +void UserManager::loadUsersAndGroups() +{ + // load groups + setgrent(); + struct group * grp; + while((grp = getgrent())) { + GroupInfo* group = new GroupInfo(grp); + mGroups.append(group); + // add members of this group + for(char** member_name = grp->gr_mem; *member_name; ++member_name) { + group->addMember(QString::fromLatin1(*member_name)); + } + } + endgrent(); + std::sort(mGroups.begin(), mGroups.end(), [](GroupInfo* g1, GroupInfo* g2) { + return g1->name() < g2->name(); + }); + + // load users + setpwent(); + struct passwd * pw; + while((pw = getpwent())) { + UserInfo* user = new UserInfo(pw); + mUsers.append(user); + // add groups to this user + for(const GroupInfo* group: mGroups) { + if(group->hasMember(user->name())) { + user->addGroup(group->name()); + } + } + } + endpwent(); + std::sort(mUsers.begin(), mUsers.end(), [](UserInfo*& u1, UserInfo*& u2) { + return u1->name() < u2->name(); + }); +} + +// load settings from /etc/login.defs +void UserManager::loadLoginDefs() { + // FIXME: parse /etc/login.defs to get max UID, max system UID...etc. + QFile file(LOGIN_DEFS_FILE); + if(file.open(QIODevice::ReadOnly)) { + while(!file.atEnd()) { + QByteArray line = file.readLine().trimmed(); + if(line.isEmpty() || line.startsWith('#')) + continue; + QStringList parts = QString::fromUtf8(line).split(QRegExp("\\s"), QString::SkipEmptyParts); + if(parts.length() >= 2) { + QString& key = parts[0]; + QString& val = parts[1]; + if(key == QLatin1Literal("SYS_UID_MIN")) { + } + else if(key == QLatin1Literal("SYS_UID_MAX")) { + } + else if(key == QLatin1Literal("UID_MIN")) { + } + else if(key == QLatin1Literal("UID_MAX")) { + } + else if(key == QLatin1Literal("SYS_GID_MIN")) { + } + else if(key == QLatin1Literal("SYS_GID_MAX")) { + } + else if(key == QLatin1Literal("GID_MIN")) { + } + else if(key == QLatin1Literal("GID_MAX")) { + } + } + } + file.close(); + } +} + + +UserInfo* UserManager::findUserInfo(const char* name) { + auto it = std::find_if(mUsers.begin(), mUsers.end(), [name](const UserInfo* user) { + return user->name() == name; + }); + return it != mUsers.end() ? *it : nullptr; +} + +UserInfo* UserManager::findUserInfo(QString name) { + auto it = std::find_if(mUsers.begin(), mUsers.end(), [name](const UserInfo* user) { + return user->name() == name; + }); + return it != mUsers.end() ? *it : nullptr; +} + +UserInfo* UserManager::findUserInfo(uid_t uid) { + auto it = std::find_if(mUsers.begin(), mUsers.end(), [uid](const UserInfo* user) { + return user->uid() == uid; + }); + return it != mUsers.end() ? *it : nullptr; +} + +GroupInfo* UserManager::findGroupInfo(const char* name) { + auto it = std::find_if(mGroups.begin(), mGroups.end(), [name](const GroupInfo* group) { + return group->name() == name; + }); + return it != mGroups.end() ? *it : nullptr; +} + +GroupInfo* UserManager::findGroupInfo(QString name) { + auto it = std::find_if(mGroups.begin(), mGroups.end(), [name](const GroupInfo* group) { + return group->name() == name; + }); + return it != mGroups.end() ? *it : nullptr; +} + +GroupInfo* UserManager::findGroupInfo(gid_t gid) { + auto it = std::find_if(mGroups.begin(), mGroups.end(), [gid](const GroupInfo* group) { + return group->gid() == gid; + }); + return it != mGroups.end() ? *it : nullptr; +} + +void UserManager::reload() { + mWatcher->addPath(PASSWD_FILE); + mWatcher->addPath(GROUP_FILE); + + qDeleteAll(mUsers); // free the old UserInfo objects + mUsers.clear(); + + qDeleteAll(mGroups); // free the old GroupInfo objects + mGroups.clear(); + + loadUsersAndGroups(); + Q_EMIT changed(); +} + +void UserManager::onFileChanged(const QString &path) { + // QFileSystemWatcher is very broken and has a ridiculous design. + // we get "fileChanged()" when the file is deleted or modified, + // but there is no way to distinguish them. If the file is deleted, + // the QFileSystemWatcher stop working silently. Hence we workaround + // this by remove the paths from the watcher and add them back again + // to force the creation of new notifiers. + mWatcher->removePath(PASSWD_FILE); + mWatcher->removePath(GROUP_FILE); + QTimer::singleShot(500, this, &UserManager::reload); +} + +bool UserManager::pkexec(const QStringList& command, const QByteArray& stdinData) { + Q_ASSERT(!command.isEmpty()); + QProcess process; + qDebug() << command; + QStringList args; + args << QStringLiteral("--disable-internal-agent") + << QStringLiteral("lxqt-admin-user-helper") + << command; + process.start(QStringLiteral("pkexec"), args); + if(!stdinData.isEmpty()) { + process.waitForStarted(); + process.write(stdinData); + process.waitForBytesWritten(); + process.closeWriteChannel(); + } + process.waitForFinished(-1); + QByteArray pkexec_error = process.readAllStandardError(); + qDebug() << pkexec_error; + const bool succeeded = process.exitCode() == 0; + if (!succeeded) + { + QMessageBox * msg = new QMessageBox{QMessageBox::Critical, tr("lxqt-admin-user") + , tr("Action (%1) failed:
%2
").arg(command[0]).arg(pkexec_error.constData())}; + msg->setAttribute(Qt::WA_DeleteOnClose, true); + msg->show(); + } + return succeeded; +} + +bool UserManager::addUser(UserInfo* user) { + if(!user || user->name().isEmpty()) + return false; + QStringList command; + command << QStringLiteral("useradd"); + if(user->uid() != 0) { + command << QStringLiteral("-u") << QString::number(user->uid()); + } + if(!user->homeDir().isEmpty()) { + command << QStringLiteral("-d") << user->homeDir(); + command << QStringLiteral("-m"); // create the user's home directory if it does not exist. + } + if(!user->shell().isEmpty()) { + command << QStringLiteral("-s") << user->shell(); + } + if(!user->fullName().isEmpty()) { + command << QStringLiteral("-c") << user->fullName(); + } + if(user->gid() != 0) { + command << QStringLiteral("-g") << QString::number(user->gid()); + } + if(!user->groups().isEmpty()) { // set group membership + command << QStringLiteral("-G") << user->groups().join(','); + } + command << user->name(); + return pkexec(command); +} + +bool UserManager::modifyUser(UserInfo* user, UserInfo* newSettings) { + if(!user || user->name().isEmpty() || !newSettings) + return false; + + QStringList command; + command << QStringLiteral("usermod"); + if(newSettings->uid() != user->uid()) + command << QStringLiteral("-u") << QString::number(newSettings->uid()); + + if(newSettings->homeDir() != user->homeDir()) { + command << QStringLiteral("-d") << newSettings->homeDir(); + // command << QStringLiteral("-m"); // create the user's home directory if it does not exist. + } + if(newSettings->shell() != user->shell()) { + command << QStringLiteral("-s") << newSettings->shell(); + } + + if(newSettings->fullName() != user->fullName()) + command << QStringLiteral("-c") << newSettings->fullName(); + if(newSettings->gid() != user->gid()) + command << QStringLiteral("-g") << QString::number(newSettings->gid()); + + if(newSettings->name() != user->name()) // change login name + command << QStringLiteral("-l") << newSettings->name(); + + if(newSettings->groups() != user->groups()) { // change group membership + command << QStringLiteral("-G") << newSettings->groups().join(','); + } + + command << user->name(); + return pkexec(command); +} + +bool UserManager::deleteUser(UserInfo* user) { + if(!user || user->name().isEmpty()) + return false; + + QStringList command; + command << QStringLiteral("userdel"); + command << user->name(); + return pkexec(command); +} + +bool UserManager::changePassword(UserInfo* user, QByteArray newPasswd) { + // In theory, the current user should be able to use "passwd" to + // reset his/her own password without root permission, but... + // /usr/bin/passwd is a setuid program running as root and QProcess + // does not seem to capture its stdout... So... requires root for now. + if(geteuid() == user->uid()) { + // FIXME: there needs to be a way to let a user change his/her own password. + // Maybe we can use our pkexec helper script to achieve this. + } + QStringList command; + command << QStringLiteral("passwd"); + command << user->name(); + + // we need to type the new password for two times. + QByteArray stdinData; + stdinData += newPasswd; + stdinData += "\n"; + stdinData += newPasswd; + stdinData += "\n"; + return pkexec(command, stdinData); +} + +bool UserManager::addGroup(GroupInfo* group) { + if(!group || group->name().isEmpty()) + return false; + + QStringList command; + command << QStringLiteral("groupadd"); + if(group->gid() != 0) { + command << QStringLiteral("-g") << QString::number(group->gid()); + } + command << group->name(); + return pkexec(command); +} + +bool UserManager::modifyGroup(GroupInfo* group, GroupInfo* newSettings) { + if(!group || group->name().isEmpty() || !newSettings) + return false; + QStringList command; + command << QStringLiteral("groupmod"); + if(newSettings->gid() != group->gid()) + command << QStringLiteral("-g") << QString::number(newSettings->gid()); + if(newSettings->name() != group->name()) + command << QStringLiteral("-n") << newSettings->name(); + command << group->name(); + if(!pkexec(command)) + return false; + + // if group members are changed, use gpasswd to reset members + if(newSettings->members() != group->members()) { + command.clear(); + command << QStringLiteral("gpasswd"); + command << QStringLiteral("-M"); // Set the list of group members. + command << newSettings->members().join(','); + command << group->name(); + return pkexec(command); + } + return true; +} + +bool UserManager::deleteGroup(GroupInfo* group) { + if(!group || group->name().isEmpty()) + return false; + QStringList command; + command << QStringLiteral("groupdel"); + command << group->name(); + return pkexec(command); +} + +bool UserManager::changePassword(GroupInfo* group, QByteArray newPasswd) { + QStringList command; + command << QStringLiteral("gpasswd"); + command << group->name(); + + // we need to type the new password for two times. + QByteArray stdinData = newPasswd; + stdinData += "\n"; + stdinData += newPasswd; + stdinData += "\n"; + return pkexec(command, stdinData); +} + +const QStringList& UserManager::availableShells() { + if(mAvailableShells.isEmpty()) { + QFile file("/etc/shells"); + if(file.open(QIODevice::ReadOnly)) { + while(!file.atEnd()) { + QByteArray line = file.readLine().trimmed(); + if(line.isEmpty() || line.startsWith('#')) + continue; + mAvailableShells.append(QString::fromLocal8Bit(line)); + } + file.close(); + } + } + return mAvailableShells; +} + diff --git a/lxqt-admin-user/usermanager.h b/lxqt-admin-user/usermanager.h new file mode 100644 index 0000000..648a609 --- /dev/null +++ b/lxqt-admin-user/usermanager.h @@ -0,0 +1,239 @@ +/* BEGIN_COMMON_COPYRIGHT_HEADER + * (c)LGPL2+ + * + * LXQt - a lightweight, Qt based, desktop toolset + * http://lxqt.org + * + * Copyright: 2016 LXQt team + * Authors: + * Hong Jen Yee (PCMan) + * + * This program or library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * END_COMMON_COPYRIGHT_HEADER */ + +#ifndef USERMANAGER_H +#define USERMANAGER_H + +#include +#include +#include +#include +#include + +class QFileSystemWatcher; + +class UserInfo +{ +public: + explicit UserInfo():mUid(0), mGid(0) { + } + explicit UserInfo(struct passwd* pw): + mUid(pw->pw_uid), + mGid(pw->pw_gid), + mName(QString::fromLatin1(pw->pw_name)), + mFullName(QString::fromUtf8(pw->pw_gecos)), + mShell(QString::fromLocal8Bit(pw->pw_shell)), + mHomeDir(QString::fromLocal8Bit(pw->pw_dir)) + { + } + + uid_t uid()const { + return mUid; + } + void setUid(uid_t uid) { + mUid = uid; + } + + gid_t gid() const { + return mGid; + } + + void setGid(gid_t gid) { + mGid = gid; + } + + QString name() const { + return mName; + } + + void setName(const QString& name) { + mName = name; + } + + QString fullName() const { + return mFullName; + } + void setFullName(const QString& fullName) { + mFullName = fullName; + } + + QString shell() const { + return mShell; + } + void setShell(const QString& shell) { + mShell = shell; + } + + QString homeDir() const { + return mHomeDir; + } + void setHomeDir(const QString& homeDir) { + mHomeDir = homeDir; + } + + const QStringList& groups() const { + return mGroups; + } + + void addGroup(const QString& group) { + mGroups.append(group); + } + + void removeGroup(const QString& group) { + mGroups.removeOne(group); + } + + void removeAllGroups() { + mGroups.clear(); + } + + bool hasGroup(const QString& group) { + return mGroups.contains(group); + } + +private: + uid_t mUid; + gid_t mGid; + QString mName; + QString mFullName; + QString mShell; + QString mHomeDir; + QStringList mGroups; +}; + +class GroupInfo +{ +public: + explicit GroupInfo(): mGid(0) { + } + explicit GroupInfo(struct group* grp): + mGid(grp->gr_gid), + mName(grp->gr_name) + { + } + + gid_t gid() const { + return mGid; + } + void setGid(gid_t gid) { + mGid = gid; + } + + QString name() const { + return mName; + } + void setName(const QString& name) { + mName = name; + } + + const QStringList& members() const { + return mMembers; + } + + void setMembers(const QStringList& members) { + mMembers = members; + } + + void addMember(const QString& userName) { + mMembers.append(userName); + } + + void removeMember(const QString& userName) { + mMembers.removeOne(userName); + } + + void removeAllMemberss() { + mMembers.clear(); + } + + bool hasMember(const QString& userName) const { + return mMembers.contains(userName); + } + +private: + gid_t mGid; + QString mName; + QStringList mMembers; +}; + +class UserManager : public QObject +{ + Q_OBJECT +public: + explicit UserManager(QObject *parent = 0); + ~UserManager(); + + const QList& users() const { + return mUsers; + } + + const QList& groups() const { + return mGroups; + } + + const QStringList& availableShells(); + + bool addUser(UserInfo* user); + bool modifyUser(UserInfo* user, UserInfo* newSettings); + bool deleteUser(UserInfo* user); + bool changePassword(UserInfo* user, QByteArray newPasswd); + + bool addGroup(GroupInfo* group); + bool modifyGroup(GroupInfo* group, GroupInfo* newSettings); + bool deleteGroup(GroupInfo* group); + bool changePassword(GroupInfo* group, QByteArray newPasswd); + + // FIXME: add APIs to change group membership with "gpasswd" + + UserInfo* findUserInfo(const char* name); + UserInfo* findUserInfo(QString name); + UserInfo* findUserInfo(uid_t uid); + + GroupInfo* findGroupInfo(const char* name); + GroupInfo* findGroupInfo(QString name); + GroupInfo* findGroupInfo(gid_t gid); + +private: + void loadUsersAndGroups(); + void loadLoginDefs(); + bool pkexec(const QStringList &command, const QByteArray &stdinData = QByteArray()); + +Q_SIGNALS: + void changed(); + +protected Q_SLOTS: + void onFileChanged(const QString &path); + void reload(); + +private: + QList mUsers; + QList mGroups; + QFileSystemWatcher* mWatcher; + QStringList mAvailableShells; +}; + +#endif // USERMANAGER_H diff --git a/lxqt-admin.kdev4 b/lxqt-admin.kdev4 deleted file mode 100644 index 4115283..0000000 --- a/lxqt-admin.kdev4 +++ /dev/null @@ -1,3 +0,0 @@ -[Project] -Manager=KDevCMakeManager -Name=lxqt-admin