diff options
| -rw-r--r-- | .build.yml | 165 | ||||
| -rw-r--r-- | .github/dependabot.yml | 8 | ||||
| -rwxr-xr-x | .github/workflows/archlinux.sh | 44 | ||||
| -rwxr-xr-x | .github/workflows/builds.sh | 38 | ||||
| -rw-r--r-- | .github/workflows/builds.yml | 77 | ||||
| -rwxr-xr-x | .github/workflows/debian.sh | 53 | ||||
| -rwxr-xr-x | .github/workflows/fedora.sh | 43 | ||||
| -rw-r--r-- | .github/workflows/release.yml | 26 | ||||
| -rwxr-xr-x | .github/workflows/ubuntu.sh | 53 | ||||
| -rw-r--r-- | .travis.yml | 74 | ||||
| -rw-r--r-- | capplet/gsm-properties-dialog.c | 4 | ||||
| -rw-r--r-- | capplet/msm-desktop-app-dialog.c | 10 | ||||
| -rw-r--r-- | configure.ac | 27 | ||||
| -rw-r--r-- | mate-session/Makefile.am | 26 | ||||
| -rw-r--r-- | mate-session/gsm-app.c | 135 | ||||
| -rw-r--r-- | mate-session/gsm-app.h | 11 | ||||
| -rw-r--r-- | mate-session/gsm-manager.c | 17 | ||||
| -rw-r--r-- | mate-session/gsm-util.c | 14 |
18 files changed, 510 insertions, 315 deletions
diff --git a/.build.yml b/.build.yml deleted file mode 100644 index 671f9ac..0000000 --- a/.build.yml +++ /dev/null @@ -1,165 +0,0 @@ -########################################################## -# THE FOLLOWING LINES IS USED BY docker-build -########################################################## -requires: - archlinux: - # Useful URL: https://git.archlinux.org/svntogit/community.git/tree/mate-session-manager - - autoconf-archive - - clang - - dbus-glib - - gcc - - git - - gtk3 - - intltool - - libsm - - make - - mate-common - - mate-desktop - - python - - systemd - - which - - xtrans - - debian: - # Useful URL: https://github.com/mate-desktop/debian-packages - # Useful URL: https://salsa.debian.org/debian-mate-team/mate-session-manager - - autoconf-archive - - autopoint - - clang - - clang-tools - - cppcheck - - gcc - - git - - intltool - - libdbus-glib-1-dev - - libgl1-mesa-dev - - libgles2-mesa-dev - - libglib2.0-dev - - libgtk-3-dev - - libice-dev - - libsm-dev - - libstartup-notification0-dev - - libsystemd-dev - - libx11-dev - - libxau-dev - - libxext-dev - - libxrender-dev - - libxt-dev - - libxtst-dev - - make - - mate-common - - xmlto - - xsltproc - - fedora: - # Useful URL: https://src.fedoraproject.org/cgit/rpms/mate-session-manager.git - - autoconf-archive - - clang - - clang-analyzer - - cppcheck-htmlreport - - dbus-glib-devel - - desktop-file-utils - - gcc - - git - - gtk3-devel - - libSM-devel - - libXtst-devel - - make - - mate-common - - mesa-libGLES-devel - - pango-devel - - redhat-rpm-config - - systemd-devel - - xmlto - - xorg-x11-xtrans-devel - - ubuntu: - - autoconf-archive - - autopoint - - clang - - clang-tools - - gcc - - git - - intltool - - libdbus-glib-1-dev - - libgl1-mesa-dev - - libgles2-mesa-dev - - libglib2.0-dev - - libgtk-3-dev - - libice-dev - - libsm-dev - - libstartup-notification0-dev - - libsystemd-dev - - libx11-dev - - libxau-dev - - libxext-dev - - libxrender-dev - - libxt-dev - - libxtst-dev - - make - - mate-common - - xmlto - - xsltproc - -variables: - - 'CHECKERS=" - -enable-checker deadcode.DeadStores - -enable-checker alpha.deadcode.UnreachableCode - -enable-checker alpha.core.CastSize - -enable-checker alpha.core.CastToStruct - -enable-checker alpha.core.IdenticalExpr - -enable-checker alpha.core.SizeofPtr - -enable-checker alpha.security.ArrayBoundV2 - -enable-checker alpha.security.MallocOverflow - -enable-checker alpha.security.ReturnPtrRange - -enable-checker alpha.unix.SimpleStream - -enable-checker alpha.unix.cstring.BufferOverlap - -enable-checker alpha.unix.cstring.NotNullTerminated - -enable-checker alpha.unix.cstring.OutOfBounds - -enable-checker alpha.core.FixedAddr - -enable-checker security.insecureAPI.strcpy"' - -before_scripts: - -build_scripts: - - if [ ${DISTRO_NAME} == "debian" ];then - - export CFLAGS+=" -Wsign-compare" - - cppcheck --enable=warning,style,performance,portability,information,missingInclude . - - fi - - - NOCONFIGURE=1 ./autogen.sh - - scan-build $CHECKERS ./configure --enable-compile-warnings=maximum - - if [ $CPU_COUNT -gt 1 ]; then - - if [ ${DISTRO_NAME} == "debian" ];then - - scan-build $CHECKERS --keep-cc --use-cc=clang --use-c++=clang++ -o html-report make -j $CPU_COUNT - - make clean - - fi - - scan-build $CHECKERS --keep-cc -o html-report make -j $CPU_COUNT - - else - - if [ ${DISTRO_NAME} == "debian" ];then - - scan-build $CHECKERS --keep-cc --use-cc=clang --use-c++=clang++ -o html-report make - - make clean - - fi - - scan-build $CHECKERS --keep-cc -o html-report make - - fi - -after_scripts: - - if [ ${DISTRO_NAME} == "fedora" ];then - - cppcheck --xml --output-file=cppcheck.xml --enable=warning,style,performance,portability,information,missingInclude . - - cppcheck-htmlreport --title=${REPO_NAME} --file=cppcheck.xml --report-dir=cppcheck-htmlreport - - ./gen-index -l 20 - - fi - - make distcheck - -releases: - draft: false - prerelease: false - checksum: true - file_glob: true - files: mate-session-manager-*.tar.xz - github_release: - tags: true - overwrite: true - base_version: 1.20.0 - notify_servers: - - https://release.mate-desktop.org/release diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..80851cd --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,8 @@ +# Enable dependabot to keep our GHA pins automatically +# updated, so we don't fall too far behind in the future +version: 2 +updates: + - package-ecosystem: github-actions + directory: "/" + schedule: + interval: weekly diff --git a/.github/workflows/archlinux.sh b/.github/workflows/archlinux.sh new file mode 100755 index 0000000..3ebcf03 --- /dev/null +++ b/.github/workflows/archlinux.sh @@ -0,0 +1,44 @@ +#!/usr/bin/bash + +set -eo pipefail + +# Use grouped output messages +infobegin() { + echo "::group::${1}" +} +infoend() { + echo "::endgroup::" +} + +# Required packages on Archlinux +requires=( + ccache # Use ccache to speed up build + clang # Build with clang on Archlinux +) + +# https://gitlab.archlinux.org/archlinux/packaging/packages/mate-session-manager +requires+=( + autoconf-archive + dbus-glib + gcc + gettext + git + glib2-devel + gtk3 + libsm + make + mate-common + mate-desktop + python + systemd + which + xtrans +) + +infobegin "Update system" +pacman --noconfirm -Syu +infoend + +infobegin "Install dependency packages" +pacman --noconfirm -S ${requires[@]} +infoend diff --git a/.github/workflows/builds.sh b/.github/workflows/builds.sh new file mode 100755 index 0000000..b192d97 --- /dev/null +++ b/.github/workflows/builds.sh @@ -0,0 +1,38 @@ +#!/usr/bin/bash + +set -e +set -o pipefail + +CPUS=$(grep processor /proc/cpuinfo | wc -l) + +# Use grouped output messages +infobegin() { + echo "::group::${1}" +} +infoend() { + echo "::endgroup::" +} + +if [ -f autogen.sh ]; then + infobegin "Configure (autotools)" + NOCONFIGURE=1 ./autogen.sh + ./configure --prefix=/usr --enable-compile-warnings=maximum || { + cat config.log + exit 1 + } + infoend + + infobegin "Build (autotools)" + make -j ${CPUS} + infoend + + infobegin "Check (autotools)" + make -j ${CPUS} check || { + true + } + infoend + + infobegin "Distcheck (autotools)" + make -j ${CPUS} distcheck + infoend +fi diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml new file mode 100644 index 0000000..8382478 --- /dev/null +++ b/.github/workflows/builds.yml @@ -0,0 +1,77 @@ +name: CI Build + +on: + push: + branches: + - master + pull_request: + branches: + - master + workflow_dispatch: + +# cancel already running builds of the same branch or pull request +concurrency: + group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.head_ref || github.sha }} + cancel-in-progress: true + + +jobs: + build: + name: Build on ${{matrix.container}} (using ${{matrix.cc}}) + runs-on: ubuntu-latest + container: + image: ${{matrix.container}} + + strategy: + fail-fast: false # don't cancel other jobs in the matrix if one fails + matrix: + container: + [ + "debian:testing", + "fedora:latest", + "ubuntu:rolling", + "archlinux:latest", + ] + cc: ["gcc"] + cxx: ["g++"] + include: + - container: "archlinux:latest" + cc: "clang" + cxx: "clang++" + + env: + # Speed up build with ccache + CC: ccache ${{ matrix.cc }} + CXX: ccache ${{ matrix.cxx }} + CONTAINER: ${{ matrix.container }} + + steps: + - name: Setup environment variables + id: distro-name + shell: bash + run: | + split=(${CONTAINER//:/ }) + distro=${split[0]} + short_sha=${SHA:0:8} + echo "DISTRO=$distro" | tee -a $GITHUB_ENV + - name: Install git command + shell: bash + run: | + echo "::group::Install git ..." + apt-get update -qq && apt-get install --assume-yes git || true + dnf update -y && dnf install -y git || true + pacman --noconfirm -Sy git || true + echo "::endgroup::" + - name: Repository checkout + uses: actions/checkout@v6 + with: + submodules: "true" + - name: Install dependency packages + run: .github/workflows/${{ env.DISTRO }}.sh + - name: Enable ccache to speed up builds + uses: hendrikmuhs/[email protected] + with: + key: ${{ env.DISTRO }}-${{ matrix.cc }} + + - name: Build the source code + run: .github/workflows/builds.sh diff --git a/.github/workflows/debian.sh b/.github/workflows/debian.sh new file mode 100755 index 0000000..3592010 --- /dev/null +++ b/.github/workflows/debian.sh @@ -0,0 +1,53 @@ +#!/usr/bin/bash + +set -eo pipefail + +# Use grouped output messages +infobegin() { + echo "::group::${1}" +} +infoend() { + echo "::endgroup::" +} + +# Required packages on Debian +requires=( + ccache # Use ccache to speed up build +) + +requires+=( + autoconf-archive + autopoint + gcc + git + intltool + libdbus-glib-1-dev + libgl1-mesa-dev + libgles2-mesa-dev + libglib2.0-dev + libgtk-3-dev + libice-dev + libsm-dev + libstartup-notification0-dev + libsystemd-dev + libx11-dev + libxau-dev + libxext-dev + libxrender-dev + libxt-dev + libxtst-dev + make + mate-common + xmlto + xsltproc +) + +infobegin "Update system" +apt-get update -qq +infoend + +infobegin "Install dependency packages" +env DEBIAN_FRONTEND=noninteractive \ + apt-get install --assume-yes \ + ${requires[@]} +infoend diff --git a/.github/workflows/fedora.sh b/.github/workflows/fedora.sh new file mode 100755 index 0000000..14405fb --- /dev/null +++ b/.github/workflows/fedora.sh @@ -0,0 +1,43 @@ +#!/usr/bin/bash + +set -eo pipefail + +# Use grouped output messages +infobegin() { + echo "::group::${1}" +} +infoend() { + echo "::endgroup::" +} + +# Required packages on Fedora +requires=( + ccache # Use ccache to speed up build +) + +requires+=( + autoconf-archive + dbus-glib-devel + desktop-file-utils + gcc + git + gtk3-devel + libSM-devel + libXtst-devel + make + mate-common + mesa-libGLES-devel + pango-devel + redhat-rpm-config + systemd-devel + xmlto + xorg-x11-xtrans-devel +) + +infobegin "Update system" +dnf update -y +infoend + +infobegin "Install dependency packages" +dnf install -y ${requires[@]} +infoend diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d2aaea9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,26 @@ +name: Release Version +on: + push: + tags: + - "v*.*.*" + +jobs: + release: + name: Release New Version + runs-on: ubuntu-latest + steps: + - name: Repository checkout + uses: actions/checkout@v6 + with: + submodules: "true" + + - name: Install dependency packages + run: sudo .github/workflows/ubuntu.sh + + - name: Build the source code + run: .github/workflows/builds.sh autotools + - name: Create github release + run: | + gh release create ${{ github.ref_name }} --title ${{ github.ref_name }} --generate-notes mate-session-manager-*.tar.xz + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/ubuntu.sh b/.github/workflows/ubuntu.sh new file mode 100755 index 0000000..6bfff4a --- /dev/null +++ b/.github/workflows/ubuntu.sh @@ -0,0 +1,53 @@ +#!/usr/bin/bash + +set -eo pipefail + +# Use grouped output messages +infobegin() { + echo "::group::${1}" +} +infoend() { + echo "::endgroup::" +} + +# Required packages on Ubuntu +requires=( + ccache # Use ccache to speed up build +) + +requires+=( + autoconf-archive + autopoint + gcc + git + intltool + libdbus-glib-1-dev + libgl1-mesa-dev + libgles2-mesa-dev + libglib2.0-dev + libgtk-3-dev + libice-dev + libsm-dev + libstartup-notification0-dev + libsystemd-dev + libx11-dev + libxau-dev + libxext-dev + libxrender-dev + libxt-dev + libxtst-dev + make + mate-common + xmlto + xsltproc +) + +infobegin "Update system" +apt-get update -y +infoend + +infobegin "Install dependency packages" +env DEBIAN_FRONTEND=noninteractive \ + apt-get install --assume-yes \ + ${requires[@]} +infoend diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 5561e28..0000000 --- a/.travis.yml +++ /dev/null @@ -1,74 +0,0 @@ -dist: jammy -language: shell -os: linux -services: - - docker -addons: - apt: - packages: - - python3-pip - - python3-setuptools - -branches: - except: - - gh-pages - -before_install: - - curl -Ls -o docker-build https://github.com/mate-desktop/mate-dev-scripts/raw/master/travis/docker-build - - curl -Ls -o gen-index https://github.com/mate-desktop/mate-dev-scripts/raw/master/travis/gen-index.sh - - chmod +x docker-build gen-index - -install: - - pip3 install PyGithub - - ./docker-build --name ${DISTRO} --config .build.yml --install - -script: - - ./docker-build --name ${DISTRO} --verbose --config .build.yml --build scripts - -notifications: - irc: - if: (tag OR branch = master) AND - repo = "mate-desktop/mate-session-manager" - channels: - - "irc.libera.chat#mate-dev" - template: - - "[%{repository_name}] %{author}: %{commit_subject}" - - "[%{branch}] %{commit} %{message} %{build_url}" - on_success: never - on_failure: always - -deploy: - - provider: pages - edge: true - token: $GITHUB_TOKEN - keep_history: false - committer_from_gh: true - target_branch: gh-pages - local_dir: html-report - strategy: git - on: - all_branches: true - condition: ${DISTRO} =~ ^fedora.*$ - - provider: script - edge: true - script: ./docker-build --verbose --config .build.yml --release github - on: - tags: true - condition: "${TRAVIS_TAG} =~ ^v.*$ && ${DISTRO} =~ ^fedora.*$" - -after_success: - - 'if [[ "$TRAVIS_SECURE_ENV_VARS" == "true" && "$TRAVIS_PULL_REQUEST" != "false" && ${DISTRO} =~ ^fedora.*$ ]]; then - REPO_SLUG_ARRAY=(${TRAVIS_REPO_SLUG//\// }); - REPO_NAME=${REPO_SLUG_ARRAY[1]}; - URL="https://${REPO_NAME}.mate-desktop.dev"; - COMMENT="Code analysis completed"; - curl -H "Authorization: token $GITHUB_TOKEN" -X POST - -d "{\"state\": \"success\", \"description\": \"$COMMENT\", \"context\":\"scan-build\", \"target_url\": \"$URL\"}" - https://api.github.com/repos/${TRAVIS_REPO_SLUG}/statuses/${TRAVIS_PULL_REQUEST_SHA}; - fi' - -env: -# - DISTRO="archlinux:latest" - - DISTRO="debian:testing" - - DISTRO="fedora:latest" -# - DISTRO="ubuntu:rolling" diff --git a/capplet/gsm-properties-dialog.c b/capplet/gsm-properties-dialog.c index d05d564..a6170bc 100644 --- a/capplet/gsm-properties-dialog.c +++ b/capplet/gsm-properties-dialog.c @@ -410,7 +410,9 @@ on_desktop_add_app_clicked (GtkWidget *widget, filename = msm_dektop_app_dialog_get_selected (MSM_DESKTOP_APP_DIALOG (desktop_add_dialog)); if (filename != NULL) { - gsp_app_copy_desktop_file (g_filename_to_uri (filename, NULL, NULL)); + gchar *uri = g_filename_to_uri (filename, NULL, NULL); + gsp_app_copy_desktop_file (uri); + g_free (uri); } } diff --git a/capplet/msm-desktop-app-dialog.c b/capplet/msm-desktop-app-dialog.c index cb0c3dd..a0b2951 100644 --- a/capplet/msm-desktop-app-dialog.c +++ b/capplet/msm-desktop-app-dialog.c @@ -71,9 +71,14 @@ list_filter_app_func (GtkListBoxRow *row, g_string_ascii_up (s1); g_string_ascii_up (s2); - if (strstr (s2->str, s1->str) != NULL) + if (strstr (s2->str, s1->str) != NULL) { + g_string_free (s1, TRUE); + g_string_free (s2, TRUE); return TRUE; + } + g_string_free (s1, TRUE); + g_string_free (s2, TRUE); return FALSE; } @@ -254,7 +259,7 @@ create_app_info_row (GAppInfo *app) gtk_grid_attach_next_to (GTK_GRID (grid), label2, label, GTK_POS_BOTTOM, 1, 1); gtk_container_add (GTK_CONTAINER (row), grid); - g_object_set_data (G_OBJECT (row), "appinfo", app); + g_object_set_data_full(G_OBJECT(row), "appinfo", g_object_ref(app), g_object_unref); return row; } @@ -294,6 +299,7 @@ msm_desktop_app_dialog_new (GspAppManager *manager) } } } + g_list_free_full (apps, g_object_unref); return GTK_WIDGET (dialog); } diff --git a/configure.ac b/configure.ac index fd7f6a0..c6d13c9 100644 --- a/configure.ac +++ b/configure.ac @@ -84,6 +84,26 @@ fi AM_CONDITIONAL([HAVE_GLESV2], [test "x$have_glesv2" = "xyes"]) dnl ==================================================================== +dnl libcanberra (optional) for sound events +dnl ==================================================================== + +AC_ARG_WITH([libcanberra], + AS_HELP_STRING([--without-libcanberra], [Disable sound events (default: auto)]), + [with_libcanberra=$withval], [with_libcanberra=auto]) + +have_libcanberra=no +if test "x$with_libcanberra" != "xno"; then + PKG_CHECK_MODULES(LIBCANBERRA, libcanberra-gtk3, + [AC_DEFINE(HAVE_LIBCANBERRA, 1, [Define if libcanberra-gtk3 is available]) + have_libcanberra=yes], have_libcanberra=no) + if test "x$have_libcanberra" = xno -a "x$with_libcanberra" = xyes; then + AC_MSG_ERROR([libcanberra support requested but library not found]) + fi +fi +AC_SUBST(LIBCANBERRA_CFLAGS) +AC_SUBST(LIBCANBERRA_LIBS) + +dnl ==================================================================== dnl Option to set the default window manager dnl ==================================================================== AC_ARG_WITH(default-wm, @@ -120,6 +140,12 @@ if test "x$with_systemd" != "xno" ; then AC_DEFINE(HAVE_SYSTEMD, 1, [systemd support]) AC_SUBST(SYSTEMD_CFLAGS) AC_SUBST(SYSTEMD_LIBS) + PKG_CHECK_EXISTS([libsystemd], + [systemd_pkgconfig=libsystemd], + [systemd_pkgconfig=libsystemd-login]) + PKG_CHECK_EXISTS([$systemd_pkgconfig >= 248],, + [AC_DEFINE([SYSTEMD_STRICT_ENV], [1], + [Use strict environment variable validation for systemd < 248])]) fi fi AM_CONDITIONAL(HAVE_SYSTEMD, test "x$use_systemd" = "xyes") @@ -379,5 +405,6 @@ echo " XTest support: ${have_xtest} Build documentation: ${enable_docbook_docs} Native Language support: ${USE_NLS} + Libcanberra support: ${have_libcanberra} " diff --git a/mate-session/Makefile.am b/mate-session/Makefile.am index 448ee76..43b861b 100644 --- a/mate-session/Makefile.am +++ b/mate-session/Makefile.am @@ -23,8 +23,6 @@ mate_session_SOURCES = \ gsm-xsmp-client.c \ gsm-dbus-client.h \ gsm-dbus-client.c \ - gsm-marshal.h \ - gsm-marshal.c \ gsm-consolekit.c \ gsm-consolekit.h \ gsm-systemd.c \ @@ -55,7 +53,8 @@ mate_session_SOURCES = \ gsm-session-save.c \ gsm-session-save.h \ gsm-xsmp-server.c \ - gsm-xsmp-server.h + gsm-xsmp-server.h \ + $(BUILT_SOURCES) mate_session_CPPFLAGS = \ $(AM_CPPFLAGS) \ @@ -63,6 +62,7 @@ mate_session_CPPFLAGS = \ $(SM_CFLAGS) \ $(ICE_CFLAGS) \ $(XEXT_CFLAGS) \ + $(LIBCANBERRA_CFLAGS) \ -I$(top_srcdir)/mate-submodules/libegg \ -DLOCALE_DIR=\""$(datadir)/locale"\" \ -DDATA_DIR=\""$(datadir)/mate-session"\" \ @@ -82,7 +82,8 @@ mate_session_LDADD = \ $(MATE_SESSION_LIBS) \ $(SYSTEMD_LIBS) \ $(LIBELOGIND_LIBS) \ - $(EXECINFO_LIBS) + $(EXECINFO_LIBS) \ + $(LIBCANBERRA_LIBS) libgsmutil_la_SOURCES = \ gsm-util.c \ @@ -97,6 +98,15 @@ test_inhibit_LDADD = $(MATE_SESSION_LIBS) test_client_dbus_SOURCES = test-client-dbus.c test_client_dbus_LDADD = $(MATE_SESSION_LIBS) +org.gnome.SessionManager.App.h: org.gnome.SessionManager.App.xml Makefile.am + $(AM_V_GEN) gdbus-codegen --interface-prefix org.gnome.SessionManager.App. \ + --generate-c-code org.gnome.SessionManager.App \ + --c-namespace Gsm \ + --annotate "org.gnome.SessionManager.App" "org.gtk.GDBus.C.Name" ExportedApp \ + $(srcdir)/org.gnome.SessionManager.App.xml +org.gnome.SessionManager.App.c: org.gnome.SessionManager.App.h + @: # generated as a side-effect + gsm-marshal.c: gsm-marshal.list $(AM_V_GEN)echo "#include \"gsm-marshal.h\"" > $@ && \ $(GLIB_GENMARSHAL) $< --prefix=gsm_marshal --body >> $@ @@ -110,9 +120,6 @@ gsm-manager-glue.h: org.gnome.SessionManager.xml Makefile.am gsm-client-glue.h: org.gnome.SessionManager.Client.xml Makefile.am $(AM_V_GEN)dbus-binding-tool --prefix=gsm_client --mode=glib-server --output=gsm-client-glue.h $(srcdir)/org.gnome.SessionManager.Client.xml -gsm-app-glue.h: org.gnome.SessionManager.App.xml Makefile.am - $(AM_V_GEN)dbus-binding-tool --prefix=gsm_app --mode=glib-server --output=gsm-app-glue.h $(srcdir)/org.gnome.SessionManager.App.xml - gsm-inhibitor-glue.h: org.gnome.SessionManager.Inhibitor.xml Makefile.am $(AM_V_GEN)dbus-binding-tool --prefix=gsm_inhibitor --mode=glib-server --output=gsm-inhibitor-glue.h $(srcdir)/org.gnome.SessionManager.Inhibitor.xml @@ -122,11 +129,12 @@ gsm-presence-glue.h: org.gnome.SessionManager.Presence.xml Makefile.am BUILT_SOURCES = \ gsm-marshal.c \ gsm-marshal.h \ + org.gnome.SessionManager.App.h \ + org.gnome.SessionManager.App.c \ gsm-manager-glue.h \ gsm-presence-glue.h \ gsm-inhibitor-glue.h \ - gsm-client-glue.h \ - gsm-app-glue.h + gsm-client-glue.h EXTRA_DIST = \ README \ diff --git a/mate-session/gsm-app.c b/mate-session/gsm-app.c index 6d7a058..0260b21 100644 --- a/mate-session/gsm-app.c +++ b/mate-session/gsm-app.c @@ -28,14 +28,15 @@ #include <string.h> #include "gsm-app.h" -#include "gsm-app-glue.h" +#include "org.gnome.SessionManager.App.h" typedef struct { char *id; char *app_id; int phase; char *startup_id; - DBusGConnection *connection; + GDBusConnection *connection; + GsmExportedApp *skeleton; } GsmAppPrivate; enum { @@ -71,6 +72,52 @@ gsm_app_error_quark (void) } +static gboolean +gsm_app_get_app_id (GsmExportedApp *skeleton, + GDBusMethodInvocation *invocation, + GsmApp *app) +{ + const gchar *id; + + if (GSM_APP_GET_CLASS (app)->impl_get_app_id == NULL) { + g_dbus_method_invocation_return_error (invocation, + GSM_APP_ERROR, GSM_APP_ERROR_GENERAL, + "App ID not available"); + return TRUE; + } + + id = GSM_APP_GET_CLASS (app)->impl_get_app_id (app); + gsm_exported_app_complete_get_app_id (skeleton, invocation, + id != NULL ? id : ""); + + return TRUE; +} + +static gboolean +gsm_app_get_startup_id (GsmExportedApp *skeleton, + GDBusMethodInvocation *invocation, + GsmApp *app) +{ + GsmAppPrivate *priv; + + priv = gsm_app_get_instance_private (app); + gsm_exported_app_complete_get_startup_id (skeleton, invocation, priv->startup_id); + + return TRUE; +} + +static gboolean +gsm_app_get_phase (GsmExportedApp *skeleton, + GDBusMethodInvocation *invocation, + GsmApp *app) +{ + GsmAppPrivate *priv; + + priv = gsm_app_get_instance_private (app); + gsm_exported_app_complete_get_phase (skeleton, invocation, priv->phase); + return TRUE; +} + static guint32 get_next_app_serial (void) { @@ -90,20 +137,38 @@ register_app (GsmApp *app) { GError *error; GsmAppPrivate *priv; + GsmExportedApp *skeleton; error = NULL; priv = gsm_app_get_instance_private (app); - priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); - if (priv->connection == NULL) { - if (error != NULL) { - g_critical ("error getting session bus: %s", error->message); - g_error_free (error); - } + priv->connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); + if (error != NULL) { + g_critical ("error getting session bus: %s", error->message); + g_error_free (error); + return FALSE; + } + + skeleton = gsm_exported_app_skeleton_new (); + priv->skeleton = skeleton; + g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (skeleton), + priv->connection, priv->id, + &error); + + if (error != NULL) { + g_critical ("error registering app on session bus: %s", error->message); + g_error_free (error); + g_clear_object (&priv->skeleton); + g_clear_object (&priv->connection); return FALSE; } - dbus_g_connection_register_g_object (priv->connection, priv->id, G_OBJECT (app)); + g_signal_connect (skeleton, "handle-get-app-id", + G_CALLBACK (gsm_app_get_app_id), app); + g_signal_connect (skeleton, "handle-get-phase", + G_CALLBACK (gsm_app_get_phase), app); + g_signal_connect (skeleton, "handle-get-startup-id", + G_CALLBACK (gsm_app_get_startup_id), app); return TRUE; } @@ -134,7 +199,7 @@ gsm_app_constructor (GType type, } static void -gsm_app_init (GsmApp *app) +gsm_app_init (GsmApp G_GNUC_UNUSED *app) { } @@ -185,7 +250,7 @@ static void gsm_app_set_property (GObject *object, guint prop_id, const GValue *value, - GParamSpec *pspec) + GParamSpec *pspec G_GNUC_UNUSED) { GsmApp *app = GSM_APP (object); @@ -208,7 +273,7 @@ static void gsm_app_get_property (GObject *object, guint prop_id, GValue *value, - GParamSpec *pspec) + GParamSpec *pspec G_GNUC_UNUSED) { GsmAppPrivate *priv; GsmApp *app = GSM_APP (object); @@ -244,6 +309,14 @@ gsm_app_dispose (GObject *object) g_free (priv->id); priv->id = NULL; + if (priv->skeleton != NULL) { + g_dbus_interface_skeleton_unexport_from_connection (G_DBUS_INTERFACE_SKELETON (priv->skeleton), + priv->connection); + g_clear_object (&priv->skeleton); + } + + g_clear_object (&priv->connection); + G_OBJECT_CLASS (gsm_app_parent_class)->dispose (object); } @@ -316,8 +389,6 @@ gsm_app_class_init (GsmAppClass *klass) g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - - dbus_g_object_type_install_info (GSM_TYPE_APP, &dbus_glib_gsm_app_object_info); } const char * @@ -501,39 +572,3 @@ gsm_app_died (GsmApp *app) g_signal_emit (app, signals[DIED], 0); } - -gboolean -gsm_app_get_app_id (GsmApp *app, - char **id, - GError **error) -{ - g_return_val_if_fail (GSM_IS_APP (app), FALSE); - *id = g_strdup (GSM_APP_GET_CLASS (app)->impl_get_app_id (app)); - return TRUE; -} - -gboolean -gsm_app_get_startup_id (GsmApp *app, - char **id, - GError **error) -{ - GsmAppPrivate *priv; - g_return_val_if_fail (GSM_IS_APP (app), FALSE); - - priv = gsm_app_get_instance_private (app); - *id = g_strdup (priv->startup_id); - return TRUE; -} - -gboolean -gsm_app_get_phase (GsmApp *app, - guint *phase, - GError **error) -{ - GsmAppPrivate *priv; - g_return_val_if_fail (GSM_IS_APP (app), FALSE); - - priv = gsm_app_get_instance_private (app); - *phase = priv->phase; - return TRUE; -} diff --git a/mate-session/gsm-app.h b/mate-session/gsm-app.h index 96a06d1..8c2424a 100644 --- a/mate-session/gsm-app.h +++ b/mate-session/gsm-app.h @@ -104,17 +104,6 @@ gboolean gsm_app_has_autostart_condition (GsmApp *app, void gsm_app_registered (GsmApp *app); int gsm_app_peek_autostart_delay (GsmApp *app); -/* exported to bus */ -gboolean gsm_app_get_app_id (GsmApp *app, - char **id, - GError **error); -gboolean gsm_app_get_startup_id (GsmApp *app, - char **id, - GError **error); -gboolean gsm_app_get_phase (GsmApp *app, - guint *phase, - GError **error); - G_END_DECLS #endif /* __GSM_APP_H__ */ diff --git a/mate-session/gsm-manager.c b/mate-session/gsm-manager.c index 37ca39d..d67bed1 100644 --- a/mate-session/gsm-manager.c +++ b/mate-session/gsm-manager.c @@ -65,6 +65,10 @@ #endif #include "gsm-session-save.h" +#ifdef HAVE_LIBCANBERRA +#include <canberra-gtk.h> +#endif + #define GSM_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSM_TYPE_MANAGER, GsmManagerPrivate)) #define GSM_MANAGER_DBUS_PATH "/org/gnome/SessionManager" @@ -1548,6 +1552,13 @@ do_phase_query_end_session (GsmManager *manager) data.flags = 0; priv = gsm_manager_get_instance_private (manager); +#ifdef HAVE_LIBCANBERRA + ca_context_play (ca_gtk_context_get (), 0, + CA_PROP_EVENT_ID, "desktop-logout", + CA_PROP_EVENT_DESCRIPTION, "Session logout", + NULL); +#endif + if (priv->logout_mode == GSM_MANAGER_LOGOUT_MODE_FORCE) { data.flags |= GSM_CLIENT_END_SESSION_FLAG_FORCEFUL; } @@ -1620,6 +1631,12 @@ start_phase (GsmManager *manager) break; case GSM_MANAGER_PHASE_RUNNING: g_signal_emit (manager, signals[SESSION_RUNNING], 0); +#ifdef HAVE_LIBCANBERRA + ca_context_play (ca_gtk_context_get (), 0, + CA_PROP_EVENT_ID, "desktop-login", + CA_PROP_EVENT_DESCRIPTION, "Session login", + NULL); +#endif update_idle (manager); break; case GSM_MANAGER_PHASE_QUERY_END_SESSION: diff --git a/mate-session/gsm-util.c b/mate-session/gsm-util.c index 6b7f7db..5da30d2 100644 --- a/mate-session/gsm-util.c +++ b/mate-session/gsm-util.c @@ -501,6 +501,13 @@ gsm_util_update_activation_environment (const char *variable, return environment_updated; } +#define ENV_NAME_PATTERN "[a-zA-Z_][a-zA-Z0-9_]*" +#ifdef SYSTEMD_STRICT_ENV +#define ENV_VALUE_PATTERN "(?:[ \t\n]|[^[:cntrl:]])*" +#else +#define ENV_VALUE_PATTERN ".*" +#endif + gboolean gsm_util_export_activation_environment (GError **error) { @@ -519,13 +526,14 @@ gsm_util_export_activation_environment (GError **error) return FALSE; } - name_regex = g_regex_new ("^[a-zA-Z_][a-zA-Z0-9_]*$", G_REGEX_OPTIMIZE, 0, error); + name_regex = g_regex_new ("^" ENV_NAME_PATTERN "$", G_REGEX_OPTIMIZE, 0, error); if (name_regex == NULL) { return FALSE; } - value_regex = g_regex_new ("^(?:[ \t\n]|[^[:cntrl:]])*$", G_REGEX_OPTIMIZE, 0, error); + + value_regex = g_regex_new ("^" ENV_VALUE_PATTERN "$", G_REGEX_OPTIMIZE, 0, error); if (value_regex == NULL) { return FALSE; @@ -597,7 +605,7 @@ gsm_util_export_user_environment (GError **error) return FALSE; } - regex = g_regex_new ("^[a-zA-Z_][a-zA-Z0-9_]*=(?:[ \t\n]|[^[:cntrl:]])*$", G_REGEX_OPTIMIZE, 0, error); + regex = g_regex_new ("^" ENV_NAME_PATTERN "=" ENV_VALUE_PATTERN "$", G_REGEX_OPTIMIZE, 0, error); if (regex == NULL) { return FALSE; |
