diff options
author | Ted Gould <ted@gould.cx> | 2011-08-19 14:53:29 -0500 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2011-08-19 14:53:29 -0500 |
commit | 8c4cd9001609ddd0ab6d2a30aa456bc4a67fa8a0 (patch) | |
tree | 1c13f554a5cbf54ac86a0663d1aedb40cd1870fc | |
parent | 9c47ca97c6471ff44e44ad0403237ac054333fc2 (diff) | |
parent | 92cb2ff94b4efb98437639a7c37fa894efa03556 (diff) | |
download | ayatana-indicator-session-8c4cd9001609ddd0ab6d2a30aa456bc4a67fa8a0.tar.gz ayatana-indicator-session-8c4cd9001609ddd0ab6d2a30aa456bc4a67fa8a0.tar.bz2 ayatana-indicator-session-8c4cd9001609ddd0ab6d2a30aa456bc4a67fa8a0.zip |
Merge U. Desktop
39 files changed, 5769 insertions, 1230 deletions
@@ -3,15 +3,19 @@ Alexander Sack Christoph Korn Cody Russell + Conor Curran + Daniel van Vugt David Barth Gabor Kelemen Ken VanDine Kyle Nitzsche Luke Yelavich Marc Deslauriers + Marco Trevisan (Treviño) Martin Pitt Matthew Rasmus Michael Terry + Neil Jagdish Patel Robert Ancell Ted Gould vish @@ -1,5 +1,473 @@ # Generated by Makefile. Do not edit. +2011-08-18 Conor Curran <conor.curran@canonical.com> + + Ellipses fixes + +2011-08-18 Conor Curran <conor.curran@canonical.com> + + merged the ellipsis strings fixes + +2011-06-12 Gabor Kelemen <kelemeng@gnome.hu> + + Use ellipsis character instead of full stops. Fixes LP: 621339 + +2011-08-18 Conor Curran <conor.curran@canonical.com> + + merge in the big fix branch + +2011-08-18 Conor Curran <conor.curran@canonical.com> + + greeter mode uses to flag whether we are showing the user menu or not + +2011-08-18 Conor Curran <conor.curran@canonical.com> + + merged mterry's move over to gsettings + +2011-08-17 Michael Terry <michael.terry@canonical.com> + + don't start/lock the screensaver from the login screen + +2011-08-18 Conor Curran <conor.curran@canonical.com> + + ted's merge in for correctly checking active sessions plus UI now correct with regards active sessions and guest session is also in + +2011-08-17 Ted Gould <ted@gould.cx> + + Debugging info and a protection + +2011-08-17 Ted Gould <ted@gould.cx> + + After setting up the signals get the initial list of sessions + +2011-08-17 Ted Gould <ted@gould.cx> + + Updated to DBus interface files currently in ConsoleKit and added the seat files as well + +2011-08-17 Conor Curran <conor.curran@canonical.com> + + added some trace to the add sessions for user method + +2011-08-17 Conor Curran <conor.curran@canonical.com> + + put guest item in place and fixed ticked icon on user menu + +2011-08-18 Conor Curran <conor.curran@canonical.com> + + updates item fix and restart awareness plus correct icons + +2011-08-12 Conor Curran <conor.curran@canonical.com> + + fixed the misguided software available flag + +2011-08-10 Conor Curran <conor.curran@canonical.com> + + bumped for new release + +2011-08-10 Conor Curran <conor.curran@canonical.com> + + restart fix + +2011-08-10 Conor Curran <conor.curran@canonical.com> + + add the restart to the shutdown dialog + +2011-08-10 Conor Curran <conor.curran@canonical.com> + + updated the ignores + +2011-08-10 Conor Curran <conor.curran@canonical.com> + + add the new greeter mode + +2011-08-03 Michael Terry <michael.terry@canonical.com> + + when used in a greeter, don't show settings links, the user switcher, or log out links + +2011-08-10 Conor Curran <conor.curran@canonical.com> + + printer support corrected + +2011-08-02 Michael Terry <michael.terry@canonical.com> + + use correct printers command + +2011-08-10 Conor Curran <conor.curran@canonical.com> + + merge the gudev work + +2011-08-09 Conor Curran <conor.curran@canonical.com> + + segfault found and fixed + +2011-08-09 Conor Curran <conor.curran@canonical.com> + + fixed memory leaks + +2011-08-05 Conor Curran <conor.curran@canonical.com> + + cater for scsi type 3 and 6 devices + +2011-08-04 Conor Curran <conor.curran@canonical.com> + + correct callbacks in place for scanners and webcams + +2011-08-04 Conor Curran <conor.curran@canonical.com> + + trace around this seg fault + +2011-08-04 Conor Curran <conor.curran@canonical.com> + + destroying hash tables in finalize + +2011-08-04 Conor Curran <conor.curran@canonical.com> + + stop leaking tonnes of glists + +2011-08-04 Conor Curran <conor.curran@canonical.com> + + duplicate key input error + +2011-08-04 Conor Curran <conor.curran@canonical.com> + + add scsi scanner detection support + +2011-08-03 Conor Curran <conor.curran@canonical.com> + + refactor of the udev mgr - working nicely + +2011-08-03 Conor Curran <conor.curran@canonical.com> + + webcams working nicely + +2011-08-02 Conor Curran <conor.curran@canonical.com> + + certain usb webcams sorted + +2011-08-01 Conor Curran <conor.curran@canonical.com> + + usb scanners in place + +2011-08-01 Conor Curran <conor.curran@canonical.com> + + usb scanner rules almost there + +2011-07-29 Conor Curran <conor.curran@canonical.com> + + half way through those usb scanner udev rules + +2011-07-27 Conor Curran <conor.curran@canonical.com> + + convenience method added to handle the insertion and startup detection of scanners + +2011-07-27 Conor Curran <conor.curran@canonical.com> + + refactor with a more generic utility function + +2011-07-27 Conor Curran <conor.curran@canonical.com> + + udev scanner detection working at startup + +2011-07-26 Conor Curran <conor.curran@canonical.com> + + pattern established as to how to handle these sane rules + +2011-07-26 Conor Curran <conor.curran@canonical.com> + + research trace for devices in udev + +2011-07-26 Conor Curran <conor.curran@canonical.com> + + fixed gudev segfault + +2011-07-25 Conor Curran <conor.curran@canonical.com> + + the beginnings of the udev work + +2011-08-10 Conor Curran <conor.curran@canonical.com> + + merged the lightdb dbus changes and the apt restartrequired awareness + +2011-08-09 Conor Curran <conor.curran@canonical.com> + + and the actual code + +2011-08-05 Conor Curran <conor.curran@canonical.com> + + watch for the restart flag and change the menuitem's title + +2011-08-02 Michael Terry <michael.terry@canonical.com> + + update to use LightDM's new interface + +2011-07-28 Michael Terry <michael.terry@canonical.com> + + update interface with LightDM + +2011-07-22 Conor Curran <conor.curran@canonical.com> + + uncomment the disconnect method + +2011-07-22 Conor Curran <conor.curran@canonical.com> + + moving to 0.3.0 + +2011-07-22 Conor Curran <conor.curran@canonical.com> + + added new files to the po index + +2011-07-22 Conor Curran <conor.curran@canonical.com> + + bumped version in configure ac in prep for release + +2011-07-22 Conor Curran <conor.curran@canonical.com> + + apt item partially working + +2011-07-22 Conor Curran <conor.curran@canonical.com> + + apt progress now reflected dynamically in the menu + +2011-07-22 Conor Curran <conor.curran@canonical.com> + + transaction object now properly disposed of + +2011-07-22 Conor Curran <conor.curran@canonical.com> + + suspend plugged back in plus both it and hibernate menuitems should now be sensitive to changes coming from upower + +2011-07-22 Conor Curran <conor.curran@canonical.com> + + Device menu torn apart and put back together, apt communication up and going + +2011-07-22 Conor Curran <conor.curran@canonical.com> + + fixed issues + +2011-07-21 Conor Curran <conor.curran@canonical.com> + + apt transactions working nicely + +2011-07-21 Conor Curran <conor.curran@canonical.com> + + apt item now sensitive to updates available + +2011-07-21 Conor Curran <conor.curran@canonical.com> + + properties changed signal is being triggered + +2011-07-21 Conor Curran <conor.curran@canonical.com> + + transaction object in place + +2011-07-21 Conor Curran <conor.curran@canonical.com> + + trying to figure out if upgrades are needed in progress + +2011-07-20 Conor Curran <conor.curran@canonical.com> + + signals and methods from apt are working somewhat + +2011-07-20 Conor Curran <conor.curran@canonical.com> + + apt watcher now controlling menuitem with signals and methods in place + +2011-07-19 Conor Curran <conor.curran@canonical.com> + + apt watcher coming along nicely + +2011-07-19 Conor Curran <conor.curran@canonical.com> + + all items in place, now for the gudev backend + +2011-07-19 Conor Curran <conor.curran@canonical.com> + + settings dialog in place + +2011-07-19 Conor Curran <conor.curran@canonical.com> + + system added to device menu, more tidying as we go + +2011-07-19 Conor Curran <conor.curran@canonical.com> + + add the udev mgr files + +2011-07-22 Conor Curran <conor.curran@canonical.com> + + merged Neil's pointer fix + +2011-07-21 Neil Jagdish Patel <neil.patel@canonical.com> + + Always send the actual pointers to the entry not pointers to copies + +2011-07-19 Conor Curran <conor.curran@canonical.com> + + merged in the device menu split out + +2011-07-18 Conor Curran <conor.curran@canonical.com> + + device menu has been isolated + +2011-07-18 Conor Curran <conor.curran@canonical.com> + + session menu mgr in progress + +2011-07-19 Conor Curran <conor.curran@canonical.com> + + merged dialog behaviour fix + +2011-07-08 Daniel van Vugt <vanvugt@gmail.com> + + Keep Log Out / Restart / Shut Down dialogs on top (LP: #807357) + +2011-07-18 Conor Curran <conor.curran@canonical.com> + + user menu abstracted + +2011-07-15 Conor Curran <conor.curran@canonical.com> + + user menu nicely separated for now, next the session menu + +2011-07-15 Conor Curran <conor.curran@canonical.com> + + first step - it compiles + +2011-07-15 Conor Curran <conor.curran@canonical.com> + + please tidy up that user manager + +2011-07-15 Conor Curran <conor.curran@canonical.com> + + please tidy up that user manager + +2011-07-18 Conor Curran <conor.curran@canonical.com> + + merged Trevino's gtk2 compilation fix + +2011-07-09 Marco Trevisan (Treviño) <mail@3v1n0.net> + + configure.ac: include the indicator dir in output + +2011-07-09 Marco Trevisan (Treviño) <mail@3v1n0.net> + + Get support for gtk+2.0 back + + indicator-session can still be compiled with gtk, using the + --with-gtk=2 configure flag (I've changed it to match the + other indicators). + +2011-07-14 Conor Curran <conor.curran@canonical.com> + + bumped release version + +2011-07-14 Conor Curran <conor.curran@canonical.com> + + merge in the big menu reorg + +2011-07-14 Conor Curran <conor.curran@canonical.com> + + changed default return value of get location to 0 + +2011-07-14 Conor Curran <conor.curran@canonical.com> + + ref sink instead of ref on the images and menus + +2011-07-14 Conor Curran <conor.curran@canonical.com> + + get location overridden and debugs tidied up + +2011-07-14 Conor Curran <conor.curran@canonical.com> + + dynamic user menu hiding on the way# + +2011-07-13 Conor Curran <conor.curran@canonical.com> + + user label fixed for now + +2011-07-13 Conor Curran <conor.curran@canonical.com> + + tidied up signals and methods for the session service so as the users real name should be available and not the icon, icon should not change on the panel + +2011-07-12 Conor Curran <conor.curran@canonical.com> + + correct icon on the user panel + +2011-07-12 Conor Curran <conor.curran@canonical.com> + + radio button for is-current-user handled + +2011-07-12 Conor Curran <conor.curran@canonical.com> + + the beginnings of the custom user item + +2011-07-11 Conor Curran <conor.curran@canonical.com> + + online accounts item added@ + +2011-07-11 Conor Curran <conor.curran@canonical.com> + + user account items shown, items rearranged + +2011-07-11 Conor Curran <conor.curran@canonical.com> + + tidied user menu + +2011-07-11 Conor Curran <conor.curran@canonical.com> + + merged trunk to keep up with changes + +2011-07-07 Conor Curran <conor.curran@canonical.com> + + icon updates for the user menu panel + +2011-07-07 Conor Curran <conor.curran@canonical.com> + + user label is now updated dynamically + +2011-07-07 Conor Curran <conor.curran@canonical.com> + + added the username to the panel + +2011-07-07 Conor Curran <conor.curran@canonical.com> + + icon now being shown on the panel for devices + +2011-07-07 Conor Curran <conor.curran@canonical.com> + + merged ted's fixes + +2011-07-06 Ted Gould <ted@gould.cx> + + Making sure that users has the same dbus name as session as there is one process. + +2011-07-06 Ted Gould <ted@gould.cx> + + Remvoing unused result + +2011-07-06 Conor Curran <conor.curran@canonical.com> + + tidy up + +2011-07-05 Conor Curran <conor.curran@canonical.com> + + code tidied, menu splittage in progress + +2011-07-05 Conor Curran <conor.curran@canonical.com> + + split out the menus + +2011-07-04 Conor Curran <conor.curran@canonical.com> + + menus split somewhat + +2011-07-02 Conor Curran <conor.curran@canonical.com> + + compiling at least + +2011-07-01 Conor Curran <conor.curran@canonical.com> + + initial menu reshuffle in progress + 2011-07-07 Ted Gould <ted@gould.cx> 0.2.92 @@ -803,7 +803,7 @@ with_gnu_ld with_sysroot enable_libtool_lock enable_silent_rules -with_indicator_gtk +with_gtk with_gconf_source with_gconf_schema_file_dir enable_schemas_install @@ -1472,7 +1472,7 @@ Optional Packages: --with-gnu-ld assume the C compiler uses GNU ld [default=no] --with-sysroot=DIR Search for dependent libraries within DIR (or the compiler's sysroot if not specified). - --with-indicator-gtk Which version of gtk to use for the indicator + --with-gtk Which version of gtk to use for the indicator [default=3] --with-gconf-source=sourceaddress Config database for installing schema files. @@ -2759,7 +2759,7 @@ fi # Define the identity of the package. PACKAGE=indicator-session - VERSION=0.2.92 + VERSION=0.3.2 cat >>confdefs.h <<_ACEOF @@ -12780,11 +12780,11 @@ DBUSMENUGTK_REQUIRED_VERSION=0.3.91 POLKIT_REQUIRED_VERSION=0.92 -# Check whether --with-indicator-gtk was given. -if test "${with_indicator_gtk+set}" = set; then : - withval=$with_indicator_gtk; +# Check whether --with-gtk was given. +if test "${with_gtk+set}" = set; then : + withval=$with_gtk; else - with_indicator_gtk=3 + with_gtk=3 fi @@ -12908,7 +12908,7 @@ $as_echo "no" >&6; } PKG_CONFIG="" fi fi -if test "x$with_indicator_gtk" = x3; then : +if test "x$with_gtk" = x3; then : pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for APPLET" >&5 @@ -13019,7 +13019,7 @@ $as_echo "yes" >&6; } fi -elif test "x$with_indicator_gtk" = x2; then : +elif test "x$with_gtk" = x2; then : pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for APPLET" >&5 @@ -13142,6 +13142,7 @@ fi DBUSMENUGLIB_REQUIRED_VERSION=0.1.1 +if test "x$with_gtk" = x3; then : pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SESSIONSERVICE" >&5 @@ -13152,23 +13153,26 @@ if test -n "$SESSIONSERVICE_CFLAGS"; then elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"dbusmenu-glib-0.4 >= \$DBUSMENUGLIB_REQUIRED_VERSION - dbusmenu-gtk3-0.4 >= \$DBUSMENUGTK_REQUIRED_VERSION - dbus-glib-1 - gio-unix-2.0 - indicator3-0.4 >= \$INDICATOR_REQUIRED_VERSION\""; } >&5 + dbusmenu-gtk3-0.4 >= \$DBUSMENUGTK_REQUIRED_VERSION + dbus-glib-1 + gudev-1.0 + gio-unix-2.0 + indicator3-0.4 >= \$INDICATOR_REQUIRED_VERSION\""; } >&5 ($PKG_CONFIG --exists --print-errors "dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION - dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION - dbus-glib-1 - gio-unix-2.0 - indicator3-0.4 >= $INDICATOR_REQUIRED_VERSION") 2>&5 + dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION + dbus-glib-1 + gudev-1.0 + gio-unix-2.0 + indicator3-0.4 >= $INDICATOR_REQUIRED_VERSION") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_SESSIONSERVICE_CFLAGS=`$PKG_CONFIG --cflags "dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION - dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION - dbus-glib-1 - gio-unix-2.0 - indicator3-0.4 >= $INDICATOR_REQUIRED_VERSION" 2>/dev/null` + dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION + dbus-glib-1 + gudev-1.0 + gio-unix-2.0 + indicator3-0.4 >= $INDICATOR_REQUIRED_VERSION" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -13181,23 +13185,26 @@ if test -n "$SESSIONSERVICE_LIBS"; then elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"dbusmenu-glib-0.4 >= \$DBUSMENUGLIB_REQUIRED_VERSION - dbusmenu-gtk3-0.4 >= \$DBUSMENUGTK_REQUIRED_VERSION - dbus-glib-1 - gio-unix-2.0 - indicator3-0.4 >= \$INDICATOR_REQUIRED_VERSION\""; } >&5 + dbusmenu-gtk3-0.4 >= \$DBUSMENUGTK_REQUIRED_VERSION + dbus-glib-1 + gudev-1.0 + gio-unix-2.0 + indicator3-0.4 >= \$INDICATOR_REQUIRED_VERSION\""; } >&5 ($PKG_CONFIG --exists --print-errors "dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION - dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION - dbus-glib-1 - gio-unix-2.0 - indicator3-0.4 >= $INDICATOR_REQUIRED_VERSION") 2>&5 + dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION + dbus-glib-1 + gudev-1.0 + gio-unix-2.0 + indicator3-0.4 >= $INDICATOR_REQUIRED_VERSION") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_SESSIONSERVICE_LIBS=`$PKG_CONFIG --libs "dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION - dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION - dbus-glib-1 - gio-unix-2.0 - indicator3-0.4 >= $INDICATOR_REQUIRED_VERSION" 2>/dev/null` + dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION + dbus-glib-1 + gudev-1.0 + gio-unix-2.0 + indicator3-0.4 >= $INDICATOR_REQUIRED_VERSION" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -13219,25 +13226,28 @@ else fi if test $_pkg_short_errors_supported = yes; then SESSIONSERVICE_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION - dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION - dbus-glib-1 - gio-unix-2.0 - indicator3-0.4 >= $INDICATOR_REQUIRED_VERSION" 2>&1` + dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION + dbus-glib-1 + gudev-1.0 + gio-unix-2.0 + indicator3-0.4 >= $INDICATOR_REQUIRED_VERSION" 2>&1` else SESSIONSERVICE_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION - dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION - dbus-glib-1 - gio-unix-2.0 - indicator3-0.4 >= $INDICATOR_REQUIRED_VERSION" 2>&1` + dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION + dbus-glib-1 + gudev-1.0 + gio-unix-2.0 + indicator3-0.4 >= $INDICATOR_REQUIRED_VERSION" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$SESSIONSERVICE_PKG_ERRORS" >&5 as_fn_error $? "Package requirements (dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION - dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION - dbus-glib-1 - gio-unix-2.0 - indicator3-0.4 >= $INDICATOR_REQUIRED_VERSION) were not met: + dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION + dbus-glib-1 + gudev-1.0 + gio-unix-2.0 + indicator3-0.4 >= $INDICATOR_REQUIRED_VERSION) were not met: $SESSIONSERVICE_PKG_ERRORS @@ -13270,10 +13280,152 @@ $as_echo "yes" >&6; } fi +elif test "x$with_gtk" = x2; then : +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for SESSIONSERVICE" >&5 +$as_echo_n "checking for SESSIONSERVICE... " >&6; } + +if test -n "$SESSIONSERVICE_CFLAGS"; then + pkg_cv_SESSIONSERVICE_CFLAGS="$SESSIONSERVICE_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"dbusmenu-glib-0.4 >= \$DBUSMENUGLIB_REQUIRED_VERSION + dbusmenu-gtk-0.4 >= \$DBUSMENUGTK_REQUIRED_VERSION + gudev-1.0 + dbus-glib-1 + gio-unix-2.0 + indicator-0.4 >= \$INDICATOR_REQUIRED_VERSION\""; } >&5 + ($PKG_CONFIG --exists --print-errors "dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION + dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION + gudev-1.0 + dbus-glib-1 + gio-unix-2.0 + indicator-0.4 >= $INDICATOR_REQUIRED_VERSION") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_SESSIONSERVICE_CFLAGS=`$PKG_CONFIG --cflags "dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION + dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION + gudev-1.0 + dbus-glib-1 + gio-unix-2.0 + indicator-0.4 >= $INDICATOR_REQUIRED_VERSION" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$SESSIONSERVICE_LIBS"; then + pkg_cv_SESSIONSERVICE_LIBS="$SESSIONSERVICE_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"dbusmenu-glib-0.4 >= \$DBUSMENUGLIB_REQUIRED_VERSION + dbusmenu-gtk-0.4 >= \$DBUSMENUGTK_REQUIRED_VERSION + gudev-1.0 + dbus-glib-1 + gio-unix-2.0 + indicator-0.4 >= \$INDICATOR_REQUIRED_VERSION\""; } >&5 + ($PKG_CONFIG --exists --print-errors "dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION + dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION + gudev-1.0 + dbus-glib-1 + gio-unix-2.0 + indicator-0.4 >= $INDICATOR_REQUIRED_VERSION") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_SESSIONSERVICE_LIBS=`$PKG_CONFIG --libs "dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION + dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION + gudev-1.0 + dbus-glib-1 + gio-unix-2.0 + indicator-0.4 >= $INDICATOR_REQUIRED_VERSION" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + SESSIONSERVICE_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION + dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION + gudev-1.0 + dbus-glib-1 + gio-unix-2.0 + indicator-0.4 >= $INDICATOR_REQUIRED_VERSION" 2>&1` + else + SESSIONSERVICE_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION + dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION + gudev-1.0 + dbus-glib-1 + gio-unix-2.0 + indicator-0.4 >= $INDICATOR_REQUIRED_VERSION" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$SESSIONSERVICE_PKG_ERRORS" >&5 + + as_fn_error $? "Package requirements (dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION + dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION + gudev-1.0 + dbus-glib-1 + gio-unix-2.0 + indicator-0.4 >= $INDICATOR_REQUIRED_VERSION) were not met: + +$SESSIONSERVICE_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +Alternatively, you may set the environment variables SESSIONSERVICE_CFLAGS +and SESSIONSERVICE_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +Alternatively, you may set the environment variables SESSIONSERVICE_CFLAGS +and SESSIONSERVICE_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. + +To get pkg-config, see <http://pkg-config.freedesktop.org/>. +See \`config.log' for more details" "$LINENO" 5; } +else + SESSIONSERVICE_CFLAGS=$pkg_cv_SESSIONSERVICE_CFLAGS + SESSIONSERVICE_LIBS=$pkg_cv_SESSIONSERVICE_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +fi + + +fi + +if test "x$with_gtk" = x3; then : + pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GTKLOGOUTHELPER" >&5 $as_echo_n "checking for GTKLOGOUTHELPER... " >&6; } @@ -13283,14 +13435,14 @@ if test -n "$GTKLOGOUTHELPER_CFLAGS"; then elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gtk+-3.0 >= \$GTK3_REQUIRED_VERSION - polkit-gobject-1 >= \$POLKIT_REQUIRED_VERSION\""; } >&5 + polkit-gobject-1 >= \$POLKIT_REQUIRED_VERSION\""; } >&5 ($PKG_CONFIG --exists --print-errors "gtk+-3.0 >= $GTK3_REQUIRED_VERSION - polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION") 2>&5 + polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_GTKLOGOUTHELPER_CFLAGS=`$PKG_CONFIG --cflags "gtk+-3.0 >= $GTK3_REQUIRED_VERSION - polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION" 2>/dev/null` + polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -13303,14 +13455,14 @@ if test -n "$GTKLOGOUTHELPER_LIBS"; then elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gtk+-3.0 >= \$GTK3_REQUIRED_VERSION - polkit-gobject-1 >= \$POLKIT_REQUIRED_VERSION\""; } >&5 + polkit-gobject-1 >= \$POLKIT_REQUIRED_VERSION\""; } >&5 ($PKG_CONFIG --exists --print-errors "gtk+-3.0 >= $GTK3_REQUIRED_VERSION - polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION") 2>&5 + polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_GTKLOGOUTHELPER_LIBS=`$PKG_CONFIG --libs "gtk+-3.0 >= $GTK3_REQUIRED_VERSION - polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION" 2>/dev/null` + polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -13332,16 +13484,16 @@ else fi if test $_pkg_short_errors_supported = yes; then GTKLOGOUTHELPER_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "gtk+-3.0 >= $GTK3_REQUIRED_VERSION - polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION" 2>&1` + polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION" 2>&1` else GTKLOGOUTHELPER_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "gtk+-3.0 >= $GTK3_REQUIRED_VERSION - polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION" 2>&1` + polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$GTKLOGOUTHELPER_PKG_ERRORS" >&5 as_fn_error $? "Package requirements (gtk+-3.0 >= $GTK3_REQUIRED_VERSION - polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION) were not met: + polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION) were not met: $GTKLOGOUTHELPER_PKG_ERRORS @@ -13374,6 +13526,111 @@ $as_echo "yes" >&6; } fi +elif test "x$with_gtk" = x2; then : + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GTKLOGOUTHELPER" >&5 +$as_echo_n "checking for GTKLOGOUTHELPER... " >&6; } + +if test -n "$GTKLOGOUTHELPER_CFLAGS"; then + pkg_cv_GTKLOGOUTHELPER_CFLAGS="$GTKLOGOUTHELPER_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gtk+-2.0 >= \$GTK_REQUIRED_VERSION + polkit-gobject-1 >= \$POLKIT_REQUIRED_VERSION\""; } >&5 + ($PKG_CONFIG --exists --print-errors "gtk+-2.0 >= $GTK_REQUIRED_VERSION + polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_GTKLOGOUTHELPER_CFLAGS=`$PKG_CONFIG --cflags "gtk+-2.0 >= $GTK_REQUIRED_VERSION + polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$GTKLOGOUTHELPER_LIBS"; then + pkg_cv_GTKLOGOUTHELPER_LIBS="$GTKLOGOUTHELPER_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gtk+-2.0 >= \$GTK_REQUIRED_VERSION + polkit-gobject-1 >= \$POLKIT_REQUIRED_VERSION\""; } >&5 + ($PKG_CONFIG --exists --print-errors "gtk+-2.0 >= $GTK_REQUIRED_VERSION + polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_GTKLOGOUTHELPER_LIBS=`$PKG_CONFIG --libs "gtk+-2.0 >= $GTK_REQUIRED_VERSION + polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + GTKLOGOUTHELPER_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "gtk+-2.0 >= $GTK_REQUIRED_VERSION + polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION" 2>&1` + else + GTKLOGOUTHELPER_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "gtk+-2.0 >= $GTK_REQUIRED_VERSION + polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$GTKLOGOUTHELPER_PKG_ERRORS" >&5 + + as_fn_error $? "Package requirements (gtk+-2.0 >= $GTK_REQUIRED_VERSION + polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION) were not met: + +$GTKLOGOUTHELPER_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +Alternatively, you may set the environment variables GTKLOGOUTHELPER_CFLAGS +and GTKLOGOUTHELPER_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +Alternatively, you may set the environment variables GTKLOGOUTHELPER_CFLAGS +and GTKLOGOUTHELPER_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. + +To get pkg-config, see <http://pkg-config.freedesktop.org/>. +See \`config.log' for more details" "$LINENO" 5; } +else + GTKLOGOUTHELPER_CFLAGS=$pkg_cv_GTKLOGOUTHELPER_CFLAGS + GTKLOGOUTHELPER_LIBS=$pkg_cv_GTKLOGOUTHELPER_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +fi + + +fi + @@ -13584,7 +13841,7 @@ fi if test "x$with_localinstall" = "xyes"; then INDICATORDIR="${libdir}/indicators/2/" INDICATORICONSDIR="${datadir}/indicator-applet/icons/" -elif test "x$with_indicator_gtk" = x2; then +elif test "x$with_gtk" = x2; then INDICATORDIR=`$PKG_CONFIG --variable=indicatordir indicator-0.4` INDICATORICONSDIR=`$PKG_CONFIG --variable=iconsdir indicator-0.4` else @@ -16788,12 +17045,14 @@ fi SUS Indicator Configuration: Prefix: $prefix - Indicator GTK: $with_indicator_gtk + Indicator Dir: $INDICATORDIR + Indicator GTK: $with_gtk " >&5 $as_echo "$as_me: SUS Indicator Configuration: Prefix: $prefix - Indicator GTK: $with_indicator_gtk + Indicator Dir: $INDICATORDIR + Indicator GTK: $with_gtk " >&6;} diff --git a/configure.ac b/configure.ac index 4f2cb04..9f6b1ab 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ AC_INIT(src/indicator-session.c) AC_PREREQ(2.53) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(indicator-session, 0.2.92) +AM_INIT_AUTOMAKE(indicator-session, 0.3.2) AM_MAINTAINER_MODE @@ -31,18 +31,18 @@ INDICATOR_REQUIRED_VERSION=0.3.19 DBUSMENUGTK_REQUIRED_VERSION=0.3.91 POLKIT_REQUIRED_VERSION=0.92 -AC_ARG_WITH([indicator-gtk], - [AS_HELP_STRING([--with-indicator-gtk], +AC_ARG_WITH([gtk], + [AS_HELP_STRING([--with-gtk], [Which version of gtk to use for the indicator @<:@default=3@:>@])], [], - [with_indicator_gtk=3]) + [with_gtk=3]) -AS_IF([test "x$with_indicator_gtk" = x3], +AS_IF([test "x$with_gtk" = x3], [PKG_CHECK_MODULES(APPLET, gtk+-3.0 >= $GTK3_REQUIRED_VERSION indicator3-0.4 >= $INDICATOR_REQUIRED_VERSION dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION) ], - [test "x$with_indicator_gtk" = x2], + [test "x$with_gtk" = x2], [PKG_CHECK_MODULES(APPLET, gtk+-2.0 >= $GTK_REQUIRED_VERSION indicator-0.4 >= $INDICATOR_REQUIRED_VERSION dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION) @@ -54,17 +54,36 @@ AC_SUBST(APPLET_LIBS) DBUSMENUGLIB_REQUIRED_VERSION=0.1.1 -PKG_CHECK_MODULES(SESSIONSERVICE, dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION - dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION - dbus-glib-1 - gio-unix-2.0 - indicator3-0.4 >= $INDICATOR_REQUIRED_VERSION) +AS_IF([test "x$with_gtk" = x3], + [PKG_CHECK_MODULES(SESSIONSERVICE, dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION + dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION + dbus-glib-1 + gudev-1.0 + gio-unix-2.0 + indicator3-0.4 >= $INDICATOR_REQUIRED_VERSION) + ], + [test "x$with_gtk" = x2], + [PKG_CHECK_MODULES(SESSIONSERVICE, dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION + dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION + gudev-1.0 + dbus-glib-1 + gio-unix-2.0 + indicator-0.4 >= $INDICATOR_REQUIRED_VERSION) + ] +) AC_SUBST(SESSIONERVICE_CFLAGS) AC_SUBST(SESSIONERVICE_LIBS) -PKG_CHECK_MODULES(GTKLOGOUTHELPER, gtk+-3.0 >= $GTK3_REQUIRED_VERSION - polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION) +AS_IF([test "x$with_gtk" = x3], + [PKG_CHECK_MODULES(GTKLOGOUTHELPER, gtk+-3.0 >= $GTK3_REQUIRED_VERSION + polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION) + ], + [test "x$with_gtk" = x2], + [PKG_CHECK_MODULES(GTKLOGOUTHELPER, gtk+-2.0 >= $GTK_REQUIRED_VERSION + polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION) + ] +) AC_SUBST(GTKLOGOUTHELPER_CFLAGS) @@ -94,7 +113,7 @@ AC_ARG_ENABLE(localinstall, AS_HELP_STRING([--enable-localinstall], [install all if test "x$with_localinstall" = "xyes"; then INDICATORDIR="${libdir}/indicators/2/" INDICATORICONSDIR="${datadir}/indicator-applet/icons/" -elif test "x$with_indicator_gtk" = x2; then +elif test "x$with_gtk" = x2; then INDICATORDIR=`$PKG_CONFIG --variable=indicatordir indicator-0.4` INDICATORICONSDIR=`$PKG_CONFIG --variable=iconsdir indicator-0.4` else @@ -179,5 +198,6 @@ AC_MSG_NOTICE([ SUS Indicator Configuration: Prefix: $prefix - Indicator GTK: $with_indicator_gtk + Indicator Dir: $INDICATORDIR + Indicator GTK: $with_gtk ]) diff --git a/debian/changelog b/debian/changelog index 64dd44b..64eb53c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,64 @@ -indicator-session (0.2.92-0ubuntu1~ppa1) oneiric; urgency=low +indicator-session (0.3.2-0ubuntu1) oneiric; urgency=low + * New upstream release. + - Top-right bar shows "nvalid UTF-8]" (LP: #811852) + - Don't display 'updates available' when there aren't any (LP: #819495) + - guest item in user menu (LP: #827909) + - user menu shows all users with active sessions (LP: #827932) + - Use ellipsis consistently in the indicator-session strings (LP: #621339) + - ftbfs with gcc-4.6 -Werror (LP: #793105) + - lightdm asks for password when resuming from suspend even when no one + is logged in (LP: #812804) + + -- Ken VanDine <ken.vandine@canonical.com> Thu, 18 Aug 2011 14:30:06 -0400 + +indicator-session (0.3.1-0ubuntu2) oneiric; urgency=low + + * debian/rules: run intltool-update to update the translations template + (lp: #820705) + + -- Sebastien Bacher <seb128@ubuntu.com> Thu, 11 Aug 2011 17:09:08 +0200 + +indicator-session (0.3.1-0ubuntu1) oneiric; urgency=low + + * New upstream release. + - restart is missing from SessionMenu (LP: #815077) + - Don't allow starting programs via the greeter indicators (LP: #811853) + - Printer menu item should launch system-config-printer (LP: #818602) + - gudev integration + - apt restart required awareness + * debian/control + - Added build depends on libgudev-1.0-dev + + -- Ken VanDine <ken.vandine@canonical.com> Wed, 10 Aug 2011 16:23:33 -0400 + +indicator-session (0.3.0-0ubuntu1) oneiric; urgency=low + + * New upstream release. + - fixed bug where the user menu wouldn't open in unity (LP: #812728) + - Include apt, settings and device menus + * debian/rules + - Updated gtk configure args + + -- Ken VanDine <ken.vandine@canonical.com> Fri, 22 Jul 2011 13:41:08 -0400 + +indicator-session (0.2.93-0ubuntu1) oneiric; urgency=low + + * New upstream release. + * debian/control + - Added Replaces indicator-me + + -- Ken VanDine <ken.vandine@canonical.com> Thu, 14 Jul 2011 14:29:15 -0400 + +indicator-session (0.2.92-0ubuntu2) oneiric; urgency=low + + * src/session-service.c: drop g_debug leftover which broke the build + + -- Sebastien Bacher <seb128@ubuntu.com> Fri, 08 Jul 2011 11:52:43 +0200 + +indicator-session (0.2.92-0ubuntu1) oneiric; urgency=low + + [ Ted Gould ] * New upstream release. (0.2.91) * Integrates with LightDM now * Moved to libindicator 0.4 @@ -7,7 +66,11 @@ indicator-session (0.2.92-0ubuntu1~ppa1) oneiric; urgency=low * Fixed dist'ing the XML files * debian/control: Move suggests from gdm to lightdm - -- Ted Gould <ted@ubuntu.com> Thu, 07 Jul 2011 11:29:48 -0500 + [ Ken VanDine ] + * debian/control + - bumped build depends for libindicator to >= 0.3.90 + + -- Ken VanDine <ken.vandine@canonical.com> Thu, 07 Jul 2011 14:59:44 -0400 indicator-session (0.2.90-0ubuntu3) oneiric; urgency=low diff --git a/debian/control b/debian/control index a5cb161..af1db07 100644 --- a/debian/control +++ b/debian/control @@ -8,9 +8,10 @@ Build-Depends: debhelper (>= 5.0), libgtk-3-dev, libgconf2-dev, libdbus-glib-1-dev, + libgudev-1.0-dev, gnome-doc-utils, - libindicator-dev (>= 0.3.19), - libindicator3-dev (>= 0.3.19), + libindicator-dev (>= 0.3.90), + libindicator3-dev (>= 0.3.90), libdbusmenu-glib-dev (>= 0.3.90), libdbusmenu-gtk-dev (>= 0.3.94), libdbusmenu-gtk3-dev (>= 0.3.94), @@ -27,7 +28,8 @@ Depends: ${shlibs:Depends}, ${misc:Depends}, upower Recommends: indicator-applet (>= 0.2) | indicator-renderer Suggests: lightdm Conflicts: gdm (<= 2.27.4-0ubuntu9), indicator-sus -Replaces: indicator-sus +Replaces: indicator-sus, indicator-me +Breaks: indicator-me Description: Indicator showing session management, status and user switching. This indicator is designed to be placed on the right side of a panel and give the user easy control for changing their instant message status. diff --git a/debian/rules b/debian/rules index c8bc001..bee840d 100755 --- a/debian/rules +++ b/debian/rules @@ -9,8 +9,8 @@ include /usr/share/cdbs/1/class/gnome.mk DEB_MAKE_DESTDIRSKEL = $(CURDIR)/debian/tmp/@FLAVOR@ DEB_DESTDIR = $(CURDIR)/debian/tmp/$(cdbs_make_curflavor)/ -DEB_CONFIGURE_FLAGS_gtk2 = --with-indicator-gtk=2 -DEB_CONFIGURE_FLAGS_gtk3 = --with-indicator-gtk=3 +DEB_CONFIGURE_FLAGS_gtk2 = --with-gtk=2 +DEB_CONFIGURE_FLAGS_gtk3 = --with-gtk=3 DEB_CONFIGURE_EXTRA_FLAGS = --disable-static LDFLAGS += -Wl,-z,defs -Wl,--as-needed @@ -22,3 +22,5 @@ common-install-arch:: find debian/tmp -name \*.la -delete find debian/tmp -name \*.a -delete find debian/tmp -name classic-desktop.sh | xargs chmod +x + cd po; intltool-update --pot --verbose + diff --git a/po/POTFILES.in b/po/POTFILES.in index c2256c1..08eff5f 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -7,3 +7,6 @@ src/gtk-logout-helper.c src/dialog.c src/indicator-session.c src/session-service.c +src/apt-watcher.c +src/device-menu-mgr.c +src/user-menu-mgr.c diff --git a/src/Makefile.am b/src/Makefile.am index df0ec0f..3bfd790 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -14,6 +14,8 @@ libsession_la_SOURCES = \ gen-session-dbus.xml.h \ dbus-shared-names.h \ dbusmenu-shared.h \ + user-widget.c \ + user-widget.h \ accounts-service-client.h \ accounts-service-user-client.h libsession_la_CFLAGS = \ @@ -23,19 +25,26 @@ libsession_la_CFLAGS = \ libsession_la_LIBADD = $(APPLET_LIBS) libsession_la_LDFLAGS = -module -avoid-version -consolekit-manager-client.h: $(srcdir)/consolekit-manager.xml +consolekit-manager-client.h: $(srcdir)/org.freedesktop.ConsoleKit.Manager.xml dbus-binding-tool \ --prefix=_consolekit_manager_client \ --mode=glib-client \ --output=consolekit-manager-client.h \ - $(srcdir)/consolekit-manager.xml + $(srcdir)/org.freedesktop.ConsoleKit.Manager.xml -consolekit-session-client.h: $(srcdir)/consolekit-session.xml +consolekit-seat-client.h: $(srcdir)/org.freedesktop.ConsoleKit.Seat.xml + dbus-binding-tool \ + --prefix=_consolekit_seat_client \ + --mode=glib-client \ + --output=consolekit-seat-client.h \ + $(srcdir)/org.freedesktop.ConsoleKit.Seat.xml + +consolekit-session-client.h: $(srcdir)/org.freedesktop.ConsoleKit.Session.xml dbus-binding-tool \ --prefix=_consolekit_session_client \ --mode=glib-client \ --output=consolekit-session-client.h \ - $(srcdir)/consolekit-session.xml + $(srcdir)/org.freedesktop.ConsoleKit.Session.xml display-manager-client.h: $(srcdir)/display-manager.xml dbus-binding-tool \ @@ -89,7 +98,18 @@ indicator_session_service_SOURCES = \ dbusmenu-shared.h \ gconf-helper.c \ users-service-dbus.h \ - users-service-dbus.c + users-service-dbus.c \ + user-menu-mgr.h \ + user-menu-mgr.c \ + device-menu-mgr.h \ + device-menu-mgr.c \ + apt-watcher.h \ + apt-watcher.c \ + apt-transaction.h \ + apt-transaction.c \ + udev-mgr.h \ + udev-mgr.c \ + sane-rules.h indicator_session_service_CFLAGS = \ $(SESSIONSERVICE_CFLAGS) \ $(GCONF_CFLAGS) \ @@ -130,6 +150,7 @@ gtk_logout_helper_LDADD = \ BUILT_SOURCES = \ consolekit-manager-client.h \ + consolekit-seat-client.h \ consolekit-session-client.h \ display-manager-client.h \ gen-session-dbus.xml.c \ @@ -139,8 +160,9 @@ BUILT_SOURCES = \ accounts-service-user-client.h EXTRA_DIST = \ - consolekit-manager.xml \ - consolekit-session.xml \ + org.freedesktop.ConsoleKit.Manager.xml \ + org.freedesktop.ConsoleKit.Seat.xml \ + org.freedesktop.ConsoleKit.Session.xml \ display-manager.xml \ session-dbus.xml \ upower.xml \ diff --git a/src/Makefile.in b/src/Makefile.in index 4baae5f..ae051cb 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -73,7 +73,8 @@ am__installdirs = "$(DESTDIR)$(sessionlibdir)" \ LTLIBRARIES = $(sessionlib_LTLIBRARIES) am__DEPENDENCIES_1 = libsession_la_DEPENDENCIES = $(am__DEPENDENCIES_1) -am_libsession_la_OBJECTS = libsession_la-indicator-session.lo +am_libsession_la_OBJECTS = libsession_la-indicator-session.lo \ + libsession_la-user-widget.lo libsession_la_OBJECTS = $(am_libsession_la_OBJECTS) AM_V_lt = $(am__v_lt_$(V)) am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) @@ -99,7 +100,12 @@ am_indicator_session_service_OBJECTS = \ indicator_session_service-session-dbus.$(OBJEXT) \ indicator_session_service-gen-session-dbus.xml.$(OBJEXT) \ indicator_session_service-gconf-helper.$(OBJEXT) \ - indicator_session_service-users-service-dbus.$(OBJEXT) + indicator_session_service-users-service-dbus.$(OBJEXT) \ + indicator_session_service-user-menu-mgr.$(OBJEXT) \ + indicator_session_service-device-menu-mgr.$(OBJEXT) \ + indicator_session_service-apt-watcher.$(OBJEXT) \ + indicator_session_service-apt-transaction.$(OBJEXT) \ + indicator_session_service-udev-mgr.$(OBJEXT) indicator_session_service_OBJECTS = \ $(am_indicator_session_service_OBJECTS) indicator_session_service_DEPENDENCIES = $(am__DEPENDENCIES_1) \ @@ -310,6 +316,8 @@ libsession_la_SOURCES = \ gen-session-dbus.xml.h \ dbus-shared-names.h \ dbusmenu-shared.h \ + user-widget.c \ + user-widget.h \ accounts-service-client.h \ accounts-service-user-client.h @@ -334,7 +342,18 @@ indicator_session_service_SOURCES = \ dbusmenu-shared.h \ gconf-helper.c \ users-service-dbus.h \ - users-service-dbus.c + users-service-dbus.c \ + user-menu-mgr.h \ + user-menu-mgr.c \ + device-menu-mgr.h \ + device-menu-mgr.c \ + apt-watcher.h \ + apt-watcher.c \ + apt-transaction.h \ + apt-transaction.c \ + udev-mgr.h \ + udev-mgr.c \ + sane-rules.h indicator_session_service_CFLAGS = \ $(SESSIONSERVICE_CFLAGS) \ @@ -376,6 +395,7 @@ gtk_logout_helper_LDADD = \ ############### BUILT_SOURCES = \ consolekit-manager-client.h \ + consolekit-seat-client.h \ consolekit-session-client.h \ display-manager-client.h \ gen-session-dbus.xml.c \ @@ -385,8 +405,9 @@ BUILT_SOURCES = \ accounts-service-user-client.h EXTRA_DIST = \ - consolekit-manager.xml \ - consolekit-session.xml \ + org.freedesktop.ConsoleKit.Manager.xml \ + org.freedesktop.ConsoleKit.Seat.xml \ + org.freedesktop.ConsoleKit.Session.xml \ display-manager.xml \ session-dbus.xml \ upower.xml \ @@ -523,13 +544,19 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gtk_logout_helper-dialog.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gtk_logout_helper-gconf-helper.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gtk_logout_helper-gtk-logout-helper.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_session_service-apt-transaction.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_session_service-apt-watcher.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_session_service-device-menu-mgr.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_session_service-gconf-helper.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_session_service-gen-session-dbus.xml.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_session_service-lock-helper.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_session_service-session-dbus.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_session_service-session-service.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_session_service-udev-mgr.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_session_service-user-menu-mgr.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_session_service-users-service-dbus.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsession_la-indicator-session.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsession_la-user-widget.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @@ -563,6 +590,14 @@ libsession_la-indicator-session.lo: indicator-session.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsession_la_CFLAGS) $(CFLAGS) -c -o libsession_la-indicator-session.lo `test -f 'indicator-session.c' || echo '$(srcdir)/'`indicator-session.c +libsession_la-user-widget.lo: user-widget.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsession_la_CFLAGS) $(CFLAGS) -MT libsession_la-user-widget.lo -MD -MP -MF $(DEPDIR)/libsession_la-user-widget.Tpo -c -o libsession_la-user-widget.lo `test -f 'user-widget.c' || echo '$(srcdir)/'`user-widget.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsession_la-user-widget.Tpo $(DEPDIR)/libsession_la-user-widget.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='user-widget.c' object='libsession_la-user-widget.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsession_la_CFLAGS) $(CFLAGS) -c -o libsession_la-user-widget.lo `test -f 'user-widget.c' || echo '$(srcdir)/'`user-widget.c + gtk_logout_helper-gtk-logout-helper.o: gtk-logout-helper.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gtk_logout_helper_CFLAGS) $(CFLAGS) -MT gtk_logout_helper-gtk-logout-helper.o -MD -MP -MF $(DEPDIR)/gtk_logout_helper-gtk-logout-helper.Tpo -c -o gtk_logout_helper-gtk-logout-helper.o `test -f 'gtk-logout-helper.c' || echo '$(srcdir)/'`gtk-logout-helper.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/gtk_logout_helper-gtk-logout-helper.Tpo $(DEPDIR)/gtk_logout_helper-gtk-logout-helper.Po @@ -707,6 +742,86 @@ indicator_session_service-users-service-dbus.obj: users-service-dbus.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_session_service_CFLAGS) $(CFLAGS) -c -o indicator_session_service-users-service-dbus.obj `if test -f 'users-service-dbus.c'; then $(CYGPATH_W) 'users-service-dbus.c'; else $(CYGPATH_W) '$(srcdir)/users-service-dbus.c'; fi` +indicator_session_service-user-menu-mgr.o: user-menu-mgr.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_session_service_CFLAGS) $(CFLAGS) -MT indicator_session_service-user-menu-mgr.o -MD -MP -MF $(DEPDIR)/indicator_session_service-user-menu-mgr.Tpo -c -o indicator_session_service-user-menu-mgr.o `test -f 'user-menu-mgr.c' || echo '$(srcdir)/'`user-menu-mgr.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_session_service-user-menu-mgr.Tpo $(DEPDIR)/indicator_session_service-user-menu-mgr.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='user-menu-mgr.c' object='indicator_session_service-user-menu-mgr.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_session_service_CFLAGS) $(CFLAGS) -c -o indicator_session_service-user-menu-mgr.o `test -f 'user-menu-mgr.c' || echo '$(srcdir)/'`user-menu-mgr.c + +indicator_session_service-user-menu-mgr.obj: user-menu-mgr.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_session_service_CFLAGS) $(CFLAGS) -MT indicator_session_service-user-menu-mgr.obj -MD -MP -MF $(DEPDIR)/indicator_session_service-user-menu-mgr.Tpo -c -o indicator_session_service-user-menu-mgr.obj `if test -f 'user-menu-mgr.c'; then $(CYGPATH_W) 'user-menu-mgr.c'; else $(CYGPATH_W) '$(srcdir)/user-menu-mgr.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_session_service-user-menu-mgr.Tpo $(DEPDIR)/indicator_session_service-user-menu-mgr.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='user-menu-mgr.c' object='indicator_session_service-user-menu-mgr.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_session_service_CFLAGS) $(CFLAGS) -c -o indicator_session_service-user-menu-mgr.obj `if test -f 'user-menu-mgr.c'; then $(CYGPATH_W) 'user-menu-mgr.c'; else $(CYGPATH_W) '$(srcdir)/user-menu-mgr.c'; fi` + +indicator_session_service-device-menu-mgr.o: device-menu-mgr.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_session_service_CFLAGS) $(CFLAGS) -MT indicator_session_service-device-menu-mgr.o -MD -MP -MF $(DEPDIR)/indicator_session_service-device-menu-mgr.Tpo -c -o indicator_session_service-device-menu-mgr.o `test -f 'device-menu-mgr.c' || echo '$(srcdir)/'`device-menu-mgr.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_session_service-device-menu-mgr.Tpo $(DEPDIR)/indicator_session_service-device-menu-mgr.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='device-menu-mgr.c' object='indicator_session_service-device-menu-mgr.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_session_service_CFLAGS) $(CFLAGS) -c -o indicator_session_service-device-menu-mgr.o `test -f 'device-menu-mgr.c' || echo '$(srcdir)/'`device-menu-mgr.c + +indicator_session_service-device-menu-mgr.obj: device-menu-mgr.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_session_service_CFLAGS) $(CFLAGS) -MT indicator_session_service-device-menu-mgr.obj -MD -MP -MF $(DEPDIR)/indicator_session_service-device-menu-mgr.Tpo -c -o indicator_session_service-device-menu-mgr.obj `if test -f 'device-menu-mgr.c'; then $(CYGPATH_W) 'device-menu-mgr.c'; else $(CYGPATH_W) '$(srcdir)/device-menu-mgr.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_session_service-device-menu-mgr.Tpo $(DEPDIR)/indicator_session_service-device-menu-mgr.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='device-menu-mgr.c' object='indicator_session_service-device-menu-mgr.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_session_service_CFLAGS) $(CFLAGS) -c -o indicator_session_service-device-menu-mgr.obj `if test -f 'device-menu-mgr.c'; then $(CYGPATH_W) 'device-menu-mgr.c'; else $(CYGPATH_W) '$(srcdir)/device-menu-mgr.c'; fi` + +indicator_session_service-apt-watcher.o: apt-watcher.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_session_service_CFLAGS) $(CFLAGS) -MT indicator_session_service-apt-watcher.o -MD -MP -MF $(DEPDIR)/indicator_session_service-apt-watcher.Tpo -c -o indicator_session_service-apt-watcher.o `test -f 'apt-watcher.c' || echo '$(srcdir)/'`apt-watcher.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_session_service-apt-watcher.Tpo $(DEPDIR)/indicator_session_service-apt-watcher.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='apt-watcher.c' object='indicator_session_service-apt-watcher.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_session_service_CFLAGS) $(CFLAGS) -c -o indicator_session_service-apt-watcher.o `test -f 'apt-watcher.c' || echo '$(srcdir)/'`apt-watcher.c + +indicator_session_service-apt-watcher.obj: apt-watcher.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_session_service_CFLAGS) $(CFLAGS) -MT indicator_session_service-apt-watcher.obj -MD -MP -MF $(DEPDIR)/indicator_session_service-apt-watcher.Tpo -c -o indicator_session_service-apt-watcher.obj `if test -f 'apt-watcher.c'; then $(CYGPATH_W) 'apt-watcher.c'; else $(CYGPATH_W) '$(srcdir)/apt-watcher.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_session_service-apt-watcher.Tpo $(DEPDIR)/indicator_session_service-apt-watcher.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='apt-watcher.c' object='indicator_session_service-apt-watcher.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_session_service_CFLAGS) $(CFLAGS) -c -o indicator_session_service-apt-watcher.obj `if test -f 'apt-watcher.c'; then $(CYGPATH_W) 'apt-watcher.c'; else $(CYGPATH_W) '$(srcdir)/apt-watcher.c'; fi` + +indicator_session_service-apt-transaction.o: apt-transaction.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_session_service_CFLAGS) $(CFLAGS) -MT indicator_session_service-apt-transaction.o -MD -MP -MF $(DEPDIR)/indicator_session_service-apt-transaction.Tpo -c -o indicator_session_service-apt-transaction.o `test -f 'apt-transaction.c' || echo '$(srcdir)/'`apt-transaction.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_session_service-apt-transaction.Tpo $(DEPDIR)/indicator_session_service-apt-transaction.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='apt-transaction.c' object='indicator_session_service-apt-transaction.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_session_service_CFLAGS) $(CFLAGS) -c -o indicator_session_service-apt-transaction.o `test -f 'apt-transaction.c' || echo '$(srcdir)/'`apt-transaction.c + +indicator_session_service-apt-transaction.obj: apt-transaction.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_session_service_CFLAGS) $(CFLAGS) -MT indicator_session_service-apt-transaction.obj -MD -MP -MF $(DEPDIR)/indicator_session_service-apt-transaction.Tpo -c -o indicator_session_service-apt-transaction.obj `if test -f 'apt-transaction.c'; then $(CYGPATH_W) 'apt-transaction.c'; else $(CYGPATH_W) '$(srcdir)/apt-transaction.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_session_service-apt-transaction.Tpo $(DEPDIR)/indicator_session_service-apt-transaction.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='apt-transaction.c' object='indicator_session_service-apt-transaction.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_session_service_CFLAGS) $(CFLAGS) -c -o indicator_session_service-apt-transaction.obj `if test -f 'apt-transaction.c'; then $(CYGPATH_W) 'apt-transaction.c'; else $(CYGPATH_W) '$(srcdir)/apt-transaction.c'; fi` + +indicator_session_service-udev-mgr.o: udev-mgr.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_session_service_CFLAGS) $(CFLAGS) -MT indicator_session_service-udev-mgr.o -MD -MP -MF $(DEPDIR)/indicator_session_service-udev-mgr.Tpo -c -o indicator_session_service-udev-mgr.o `test -f 'udev-mgr.c' || echo '$(srcdir)/'`udev-mgr.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_session_service-udev-mgr.Tpo $(DEPDIR)/indicator_session_service-udev-mgr.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='udev-mgr.c' object='indicator_session_service-udev-mgr.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_session_service_CFLAGS) $(CFLAGS) -c -o indicator_session_service-udev-mgr.o `test -f 'udev-mgr.c' || echo '$(srcdir)/'`udev-mgr.c + +indicator_session_service-udev-mgr.obj: udev-mgr.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_session_service_CFLAGS) $(CFLAGS) -MT indicator_session_service-udev-mgr.obj -MD -MP -MF $(DEPDIR)/indicator_session_service-udev-mgr.Tpo -c -o indicator_session_service-udev-mgr.obj `if test -f 'udev-mgr.c'; then $(CYGPATH_W) 'udev-mgr.c'; else $(CYGPATH_W) '$(srcdir)/udev-mgr.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_session_service-udev-mgr.Tpo $(DEPDIR)/indicator_session_service-udev-mgr.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='udev-mgr.c' object='indicator_session_service-udev-mgr.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_session_service_CFLAGS) $(CFLAGS) -c -o indicator_session_service-udev-mgr.obj `if test -f 'udev-mgr.c'; then $(CYGPATH_W) 'udev-mgr.c'; else $(CYGPATH_W) '$(srcdir)/udev-mgr.c'; fi` + mostlyclean-libtool: -rm -f *.lo @@ -922,19 +1037,26 @@ uninstall-am: uninstall-libexecPROGRAMS \ uninstall-sessionlibLTLIBRARIES -consolekit-manager-client.h: $(srcdir)/consolekit-manager.xml +consolekit-manager-client.h: $(srcdir)/org.freedesktop.ConsoleKit.Manager.xml dbus-binding-tool \ --prefix=_consolekit_manager_client \ --mode=glib-client \ --output=consolekit-manager-client.h \ - $(srcdir)/consolekit-manager.xml + $(srcdir)/org.freedesktop.ConsoleKit.Manager.xml + +consolekit-seat-client.h: $(srcdir)/org.freedesktop.ConsoleKit.Seat.xml + dbus-binding-tool \ + --prefix=_consolekit_seat_client \ + --mode=glib-client \ + --output=consolekit-seat-client.h \ + $(srcdir)/org.freedesktop.ConsoleKit.Seat.xml -consolekit-session-client.h: $(srcdir)/consolekit-session.xml +consolekit-session-client.h: $(srcdir)/org.freedesktop.ConsoleKit.Session.xml dbus-binding-tool \ --prefix=_consolekit_session_client \ --mode=glib-client \ --output=consolekit-session-client.h \ - $(srcdir)/consolekit-session.xml + $(srcdir)/org.freedesktop.ConsoleKit.Session.xml display-manager-client.h: $(srcdir)/display-manager.xml dbus-binding-tool \ diff --git a/src/apt-transaction.c b/src/apt-transaction.c new file mode 100644 index 0000000..be1c57b --- /dev/null +++ b/src/apt-transaction.c @@ -0,0 +1,265 @@ +/* +Copyright 2011 Canonical Ltd. + +Authors: + Conor Curran <conor.curran@canonical.com> + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <gio/gio.h> + +#include "apt-transaction.h" +#include "dbus-shared-names.h" + +static void apt_transaction_investigate (AptTransaction* self); +static void apt_transaction_simulate_transaction_cb (GObject * obj, + GAsyncResult * res, + gpointer user_data); +static void apt_transaction_receive_signal (GDBusProxy * proxy, + gchar * sender_name, + gchar * signal_name, + GVariant * parameters, + gpointer user_data); +static void apt_transaction_finish_proxy_setup (GObject *source_object, + GAsyncResult *res, + gpointer user_data); + +struct _AptTransaction +{ + GObject parent_instance; + GDBusProxy * proxy; + GCancellable * proxy_cancel; + gchar* id; + TransactionType type; +}; + +enum { + UPDATE, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + +G_DEFINE_TYPE (AptTransaction, apt_transaction, G_TYPE_OBJECT); + +static void +apt_transaction_init (AptTransaction *self) +{ + self->proxy = NULL; + self->id = NULL; + self->proxy_cancel = g_cancellable_new(); +} + +static void +apt_transaction_finalize (GObject *object) +{ + AptTransaction* self = APT_TRANSACTION(object); + g_signal_handlers_disconnect_by_func (G_OBJECT (self->proxy), + G_CALLBACK (apt_transaction_receive_signal), + self); + if (self->proxy != NULL){ + g_object_unref (self->proxy); + self->proxy = NULL; + } + g_free (self->id); + G_OBJECT_CLASS (apt_transaction_parent_class)->finalize (object); +} + +static void +apt_transaction_class_init (AptTransactionClass *klass) +{ + GObjectClass* object_class = G_OBJECT_CLASS (klass); + object_class->finalize = apt_transaction_finalize; + + signals[UPDATE] = g_signal_new("state-update", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__INT, + G_TYPE_NONE, 1, G_TYPE_INT); +} + +// TODO: you don't need this additional helper +// Just GObject properties properly +static void +apt_transaction_investigate (AptTransaction* self) +{ + g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM, + G_DBUS_PROXY_FLAGS_NONE, + NULL, + "org.debian.apt", + self->id, + "org.debian.apt.transaction", + self->proxy_cancel, + apt_transaction_finish_proxy_setup, + self); +} + +static void +apt_transaction_finish_proxy_setup (GObject *source_object, + GAsyncResult *res, + gpointer user_data) +{ + g_return_if_fail (APT_IS_TRANSACTION (user_data)); + AptTransaction* self = APT_TRANSACTION(user_data); + GError * error = NULL; + + GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error); + + if (self->proxy_cancel != NULL) { + g_object_unref(self->proxy_cancel); + self->proxy_cancel = NULL; + } + + if (error != NULL) { + g_warning("Could not grab DBus proxy for %s: %s", + "org.debian.apt", error->message); + g_error_free(error); + return; + } + + self->proxy = proxy; + + g_signal_connect (G_OBJECT(self->proxy), + "g-signal", + G_CALLBACK (apt_transaction_receive_signal), + self); + + if (self->type == SIMULATION){ + g_dbus_proxy_call (self->proxy, + "Simulate", + NULL, + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + apt_transaction_simulate_transaction_cb, + self); + } +} + +static void +apt_transaction_receive_signal (GDBusProxy * proxy, + gchar * sender_name, + gchar * signal_name, + GVariant * parameters, + gpointer user_data) +{ + g_return_if_fail (APT_IS_TRANSACTION (user_data)); + AptTransaction* self = APT_TRANSACTION(user_data); + AptState current_state = DONT_KNOW; + + if (g_strcmp0(signal_name, "PropertyChanged") == 0 && self->type == SIMULATION) + { + gchar* prop_name= NULL; + GVariant* value = NULL; + g_variant_get (parameters, "(sv)", &prop_name, &value); + g_debug ("transaction prop update - prop = %s", prop_name); + + if (g_variant_is_of_type (value, G_VARIANT_TYPE_STRING) == TRUE){ + gchar* key = NULL; + g_variant_get (value, "s", &key); + g_debug ("transaction prop update - value = %s", key); + } + + if (g_strcmp0 (prop_name, "Dependencies") == 0){ + + gchar** install = NULL; + gchar** reinstall = NULL; + gchar** remove = NULL; + gchar** purge = NULL; + gchar** upgrade = NULL; + gchar** downgrade = NULL; + gchar** keep = NULL; + g_variant_get (value, "(asasasasasasas)", &install, + &reinstall, &remove, &purge, &upgrade, &downgrade, + &keep); + /* + g_debug ("upgrade package length %i", g_strv_length(upgrade)); + g_debug ("install package length %i", g_strv_length(install)); + g_debug ("reinstall package length %i", g_strv_length(reinstall)); + g_debug ("remove package length %i", g_strv_length(remove)); + g_debug ("purge package length %i", g_strv_length(purge)); + */ + gboolean upgrade_needed = (g_strv_length(upgrade) > 1) || + (g_strv_length(install) > 1) || + (g_strv_length(reinstall) > 1) || + (g_strv_length(remove) > 1) || + (g_strv_length(purge) > 1); + if (upgrade_needed == TRUE){ + current_state = UPDATES_AVAILABLE; + } + else{ + current_state = UP_TO_DATE; + } + } + } + else if (g_strcmp0(signal_name, "PropertyChanged") == 0 && + self->type == REAL) + { + GVariant* role = g_dbus_proxy_get_cached_property (self->proxy, + "Role"); + if (g_variant_is_of_type (role, G_VARIANT_TYPE_STRING) == TRUE){ + gchar* current_role = NULL; + g_variant_get (role, "s", ¤t_role); + g_debug ("Current transaction role = %s", current_role); + if (g_strcmp0 (current_role, "role-commit-packages") == 0 || + g_strcmp0 (current_role, "role-upgrade-system") == 0){ + g_debug ("UPGRADE IN PROGRESS"); + current_state = UPGRADE_IN_PROGRESS; + } + } + } + else if (g_strcmp0(signal_name, "Finished") == 0) + { + g_debug ("TRANSACTION Finished"); + current_state = FINISHED; + } + // Finally send out the state update + if (current_state != DONT_KNOW){ + g_signal_emit (self, + signals[UPDATE], + 0, + current_state); + } + g_variant_unref (parameters); +} + +static void +apt_transaction_simulate_transaction_cb (GObject * obj, + GAsyncResult * res, + gpointer user_data) +{ + GError * error = NULL; + if (error != NULL) { + g_warning ("unable to complete the simulate call"); + g_error_free (error); + return; + } +} +TransactionType +apt_transaction_get_transaction_type (AptTransaction* self) +{ + return self->type; +} + +AptTransaction* apt_transaction_new (gchar* transaction_id, TransactionType t) +{ + AptTransaction* tr = g_object_new (APT_TYPE_TRANSACTION, NULL); + tr->id = transaction_id; + tr->type = t; + g_debug ("Apt transaction new id = %s", tr->id); + apt_transaction_investigate (tr); + return tr; +} diff --git a/src/apt-transaction.h b/src/apt-transaction.h new file mode 100644 index 0000000..9e4370d --- /dev/null +++ b/src/apt-transaction.h @@ -0,0 +1,49 @@ +/* +Copyright 2011 Canonical Ltd. + +Authors: + Conor Curran <conor.curran@canonical.com> + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef _APT_TRANSACTION_H_ +#define _APT_TRANSACTION_H_ + +#include <glib-object.h> +#include "dbus-shared-names.h" + +G_BEGIN_DECLS + +#define APT_TYPE_TRANSACTION (apt_transaction_get_type ()) +#define APT_TRANSACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), APT_TYPE_TRANSACTION, AptTransaction)) +#define APT_TRANSACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), APT_TYPE_TRANSACTION, AptTransactionClass)) +#define APT_IS_TRANSACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), APT_TYPE_TRANSACTION)) +#define APT_IS_TRANSACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), APT_TYPE_TRANSACTION)) +#define APT_TRANSACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), APT_TYPE_TRANSACTION, AptTransactionClass)) + +typedef struct _AptTransactionClass AptTransactionClass; +typedef struct _AptTransaction AptTransaction; + +struct _AptTransactionClass +{ + GObjectClass parent_class; +}; + +AptTransaction* apt_transaction_new (gchar* transaction_id, TransactionType t); +TransactionType apt_transaction_get_transaction_type (AptTransaction* self); +GType apt_transaction_get_type (void) G_GNUC_CONST; + +G_END_DECLS + +#endif /* _APT_TRANSACTION_H_ */ diff --git a/src/apt-watcher.c b/src/apt-watcher.c new file mode 100644 index 0000000..7d706a0 --- /dev/null +++ b/src/apt-watcher.c @@ -0,0 +1,348 @@ +/* +Copyright 2011 Canonical Ltd. + +Authors: + Conor Curran <conor.curran@canonical.com> + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <gio/gio.h> +#include <glib/gi18n.h> +#include "apt-watcher.h" +#include "apt-transaction.h" + +static guint watcher_id; + +struct _AptWatcher +{ + GObject parent_instance; + GCancellable * proxy_cancel; + GDBusProxy * proxy; + SessionDbus* session_dbus_interface; + DbusmenuMenuitem* apt_item; + AptState current_state; + AptTransaction* current_transaction; +}; + +static void +apt_watcher_on_name_appeared (GDBusConnection *connection, + const gchar *name, + const gchar *name_owner, + gpointer user_data); +static void +apt_watcher_on_name_vanished (GDBusConnection *connection, + const gchar *name, + gpointer user_data); +static void fetch_proxy_cb (GObject * object, + GAsyncResult * res, + gpointer user_data); + +static void apt_watcher_upgrade_system_cb (GObject * obj, + GAsyncResult * res, + gpointer user_data); + + +static void apt_watcher_show_apt_dialog (DbusmenuMenuitem* mi, + guint timestamp, + gchar * type); + +static void apt_watcher_signal_cb (GDBusProxy* proxy, + gchar* sender_name, + gchar* signal_name, + GVariant* parameters, + gpointer user_data); +static void apt_watcher_manage_transactions (AptWatcher* self, + gchar* transaction_id); + + + +G_DEFINE_TYPE (AptWatcher, apt_watcher, G_TYPE_OBJECT); + +static void +apt_watcher_init (AptWatcher *self) +{ + self->current_state = UP_TO_DATE; + self->proxy_cancel = g_cancellable_new(); + self->proxy = NULL; + self->current_transaction = NULL; + g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM, + G_DBUS_PROXY_FLAGS_NONE, + NULL, + "org.debian.apt", + "/org/debian/apt", + "org.debian.apt", + self->proxy_cancel, + fetch_proxy_cb, + self); +} + +static void +apt_watcher_finalize (GObject *object) +{ + g_bus_unwatch_name (watcher_id); + AptWatcher* self = APT_WATCHER (object); + + if (self->proxy != NULL) + g_object_unref (self->proxy); + + G_OBJECT_CLASS (apt_watcher_parent_class)->finalize (object); +} + +static void +apt_watcher_class_init (AptWatcherClass *klass) +{ + GObjectClass* object_class = G_OBJECT_CLASS (klass); + object_class->finalize = apt_watcher_finalize; +} + +static void +fetch_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data) +{ + GError * error = NULL; + + AptWatcher* self = APT_WATCHER(user_data); + g_return_if_fail(self != NULL); + + GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error); + + if (self->proxy_cancel != NULL) { + g_object_unref(self->proxy_cancel); + self->proxy_cancel = NULL; + } + + if (error != NULL) { + g_warning("Could not grab DBus proxy for %s: %s", + "org.debian.apt", error->message); + g_error_free(error); + return; + } + + self->proxy = proxy; + // Set up the watch. + watcher_id = g_bus_watch_name (G_BUS_TYPE_SYSTEM, + "org.debian.apt", + G_BUS_NAME_WATCHER_FLAGS_NONE, + apt_watcher_on_name_appeared, + apt_watcher_on_name_vanished, + self, + NULL); + + g_signal_connect (self->proxy, + "g-signal", + G_CALLBACK(apt_watcher_signal_cb), + self); +} + + +static void +apt_watcher_on_name_appeared (GDBusConnection *connection, + const gchar *name, + const gchar *name_owner, + gpointer user_data) +{ + g_return_if_fail (APT_IS_WATCHER (user_data)); + AptWatcher* watcher = APT_WATCHER (user_data); + + g_print ("Name %s on %s is owned by %s\n", + name, + "the system bus", + name_owner); + + g_dbus_proxy_call (watcher->proxy, + "UpgradeSystem", + g_variant_new("(b)", TRUE), + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + apt_watcher_upgrade_system_cb, + user_data); +} + +static void +apt_watcher_on_name_vanished (GDBusConnection *connection, + const gchar *name, + gpointer user_data) +{ + g_debug ("Name %s does not exist or has just vanished", + name); + g_return_if_fail (APT_IS_WATCHER (user_data)); +} + +static void +apt_watcher_upgrade_system_cb (GObject * obj, + GAsyncResult * res, + gpointer user_data) +{ + g_return_if_fail (APT_IS_WATCHER (user_data)); + AptWatcher* self = APT_WATCHER (user_data); + + GError * error = NULL; + GVariant * result; + + result = g_dbus_proxy_call_finish(self->proxy, res, &error); + + if (error != NULL) { + g_warning ("unable to complete the UpgradeSystem apt call"); + g_error_free (error); + return; + } + + gchar* transaction_id = NULL; + g_variant_get (result, "(s)", &transaction_id); + + if (transaction_id == NULL){ + g_warning ("apt_watcher_upgrade_system_cb - transaction id is null"); + return; + } + + apt_watcher_manage_transactions (self, transaction_id); + +} + +static void +apt_watcher_show_apt_dialog (DbusmenuMenuitem * mi, + guint timestamp, + gchar * type) +{ + GError * error = NULL; + if (!g_spawn_command_line_async("update-manager", &error)) + { + g_warning("Unable to show update-manager: %s", error->message); + g_error_free(error); + } +} + +static void +apt_watcher_transaction_state_update_cb (AptTransaction* trans, + gint update, + gpointer user_data) +{ + g_debug ("apt-watcher -transaction update %i", update); + g_return_if_fail (APT_IS_WATCHER (user_data)); + AptWatcher* self = APT_WATCHER (user_data); + + AptState state = (AptState)update; + + if (state == UP_TO_DATE){ + dbusmenu_menuitem_property_set (self->apt_item, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Software Up to Date")); + // Simulations don't send a finished signal for some reason + // Anyway from a simulation we just need one state update + // (updates available or not) + if (apt_transaction_get_transaction_type (self->current_transaction) + == SIMULATION){ + g_object_unref (G_OBJECT(self->current_transaction)); + self->current_transaction = NULL; + } + } + else if (state == UPDATES_AVAILABLE){ + dbusmenu_menuitem_property_set (self->apt_item, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Updates Available…")); + // Simulations don't send a finished signal for some reason + // Anyway from a simulation we just need one state update + // (updates available or not) + if (apt_transaction_get_transaction_type (self->current_transaction) + == SIMULATION){ + g_object_unref (G_OBJECT(self->current_transaction)); + self->current_transaction = NULL; + } + } + else if (state == UPGRADE_IN_PROGRESS){ + dbusmenu_menuitem_property_set (self->apt_item, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Updates Installing…")); + } + else if (state == FINISHED){ + GVariant* reboot_result = g_dbus_proxy_get_cached_property (self->proxy, + "RebootRequired"); + gboolean reboot; + g_variant_get (reboot_result, "b", &reboot); + if (reboot == FALSE){ + dbusmenu_menuitem_property_set (self->apt_item, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Software Up to Date")); + } + else{ + dbusmenu_menuitem_property_set (self->apt_item, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Reboot Required")); + session_dbus_restart_required (self->session_dbus_interface); + } + g_debug ("Finished with a reboot value of %i", reboot); + g_object_unref (G_OBJECT(self->current_transaction)); + self->current_transaction = NULL; + } + self->current_state = state; +} + +static void +apt_watcher_manage_transactions (AptWatcher* self, gchar* transaction_id) +{ + if (self->current_transaction == NULL){ + self->current_transaction = apt_transaction_new (transaction_id, SIMULATION); + g_signal_connect (G_OBJECT(self->current_transaction), + "state-update", + G_CALLBACK(apt_watcher_transaction_state_update_cb), self); + } +} + +// TODO - Ask MVO about this. +// Signal is of type s not sas which is on d-feet !!! +static void apt_watcher_signal_cb ( GDBusProxy* proxy, + gchar* sender_name, + gchar* signal_name, + GVariant* parameters, + gpointer user_data) +{ + g_return_if_fail (APT_IS_WATCHER (user_data)); + AptWatcher* self = APT_WATCHER (user_data); + + g_variant_ref (parameters); + GVariant *value = g_variant_get_child_value (parameters, 0); + + if (g_strcmp0(signal_name, "ActiveTransactionsChanged") == 0){ + gchar* input = NULL; + g_variant_get(value, "s", & input); + if (g_str_has_prefix (input, "/org/debian/apt/transaction/") == TRUE){ + g_debug ("Active Transactions signal - input is null = %i", input == NULL); + + if (self->current_transaction != NULL) + { + g_object_unref (G_OBJECT(self->current_transaction)); + self->current_transaction = NULL; + } + + self->current_transaction = apt_transaction_new (input, REAL); + g_signal_connect (G_OBJECT(self->current_transaction), + "state-update", + G_CALLBACK(apt_watcher_transaction_state_update_cb), self); + } + } + g_variant_unref (parameters); +} + +AptWatcher* apt_watcher_new (SessionDbus* session_dbus, + DbusmenuMenuitem* item) +{ + AptWatcher* watcher = g_object_new (APT_TYPE_WATCHER, NULL); + watcher->session_dbus_interface = session_dbus; + watcher->apt_item = item; + g_signal_connect (G_OBJECT(watcher->apt_item), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(apt_watcher_show_apt_dialog), watcher); + return watcher; +} + diff --git a/src/apt-watcher.h b/src/apt-watcher.h new file mode 100644 index 0000000..7b98a44 --- /dev/null +++ b/src/apt-watcher.h @@ -0,0 +1,60 @@ +/* +Copyright 2011 Canonical Ltd. + +Authors: + Conor Curran <conor.curran@canonical.com> + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef _APT_WATCHER_H_ +#define _APT_WATCHER_H_ + +#include <glib-object.h> + +#include <libdbusmenu-glib/client.h> + +#include <gtk/gtk.h> +#if GTK_CHECK_VERSION(3, 0, 0) +#include <libdbusmenu-gtk3/menuitem.h> +#else +#include <libdbusmenu-gtk/menuitem.h> +#endif + +#include "session-dbus.h" + +G_BEGIN_DECLS + +#define APT_TYPE_WATCHER (apt_watcher_get_type ()) +#define APT_WATCHER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), APT_TYPE_WATCHER, AptWatcher)) +#define APT_WATCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), APT_TYPE_WATCHER, AptWatcherClass)) +#define APT_IS_WATCHER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), APT_TYPE_WATCHER)) +#define APT_IS_WATCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), APT_TYPE_WATCHER)) +#define APT_WATCHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), APT_TYPE_WATCHER, AptWatcherClass)) + +typedef struct _AptWatcherClass AptWatcherClass; +typedef struct _AptWatcher AptWatcher; + +struct _AptWatcherClass +{ + GObjectClass parent_class; +}; + +GType apt_watcher_get_type (void) G_GNUC_CONST; + +AptWatcher* apt_watcher_new (SessionDbus* session_dbus, + DbusmenuMenuitem* apt_item); + +G_END_DECLS + +#endif /* _APT_WATCHER_H_ */ diff --git a/src/dbus-shared-names.h b/src/dbus-shared-names.h index f97dddc..d9dfff1 100644 --- a/src/dbus-shared-names.h +++ b/src/dbus-shared-names.h @@ -20,16 +20,25 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #ifndef __DBUS_SHARED_NAMES_H__ -#define __DBUS_SHARED_NAMES_H__ 1 +#define __DBUS_SHARED_NAMES_H__ + +typedef enum { + UP_TO_DATE, + CHECKING_FOR_UPDATES, + UPDATES_AVAILABLE, + UPGRADE_IN_PROGRESS, + FINISHED, + RESTART_NEEDED, + DONT_KNOW +}AptState; -#define INDICATOR_STATUS_DBUS_NAME "com.canonical.indicator.status" -#define INDICATOR_STATUS_DBUS_OBJECT "/com/canonical/indicator/status/menu" -#define INDICATOR_STATUS_SERVICE_DBUS_OBJECT "/com/canonical/indicator/status/service" -#define INDICATOR_STATUS_SERVICE_DBUS_INTERFACE "com.canonical.indicator.status.service" +typedef enum { + SIMULATION, + REAL +}TransactionType; -#define INDICATOR_USERS_DBUS_NAME "com.canonical.indicator.users" +#define INDICATOR_USERS_DBUS_NAME INDICATOR_SESSION_DBUS_NAME #define INDICATOR_USERS_DBUS_OBJECT "/com/canonical/indicator/users/menu" #define INDICATOR_USERS_SERVICE_DBUS_OBJECT "/org/gnome/DisplayManager/UserManager" #define INDICATOR_USERS_SERVICE_DBUS_INTERFACE "org.gnome.DisplayManager.UserManager" @@ -44,8 +53,9 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #define USER_ITEM_TYPE "x-canonical-user-item" #define USER_ITEM_PROP_NAME "user-item-name" #define USER_ITEM_PROP_LOGGED_IN "user-item-logged-in" +#define USER_ITEM_PROP_IS_CURRENT_USER "user-item-is-current-user" #define USER_ITEM_PROP_ICON "user-item-icon-path" -#define USER_ITEM_ICON_DEFAULT "default-icon" +#define USER_ITEM_ICON_DEFAULT "user-offline" #define RESTART_ITEM_TYPE "x-canonical-restart-item" #define RESTART_ITEM_LABEL "restart-label" diff --git a/src/device-menu-mgr.c b/src/device-menu-mgr.c new file mode 100644 index 0000000..cbddaa3 --- /dev/null +++ b/src/device-menu-mgr.c @@ -0,0 +1,874 @@ +/* +Copyright 2011 Canonical Ltd. + +Authors: + Conor Curran <conor.curran@canonical.com> + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <libdbusmenu-glib/client.h> +#include <libdbusmenu-gtk3/menuitem.h> + +#include "device-menu-mgr.h" +#include "gconf-helper.h" +#include "dbus-shared-names.h" +#include "dbusmenu-shared.h" +#include "lock-helper.h" +#include "upower-client.h" +#include "apt-watcher.h" +#include "udev-mgr.h" + +#define UP_ADDRESS "org.freedesktop.UPower" +#define UP_OBJECT "/org/freedesktop/UPower" +#define UP_INTERFACE "org.freedesktop.UPower" + +#define EXTRA_LAUNCHER_DIR "/usr/share/indicators/session/applications" + +struct _DeviceMenuMgr +{ + GObject parent_instance; + DbusmenuMenuitem* root_item; + SessionDbus* session_dbus_interface; + AptWatcher* apt_watcher; + UdevMgr* udev_mgr; +}; + +static GConfClient *gconf_client = NULL; +static DbusmenuMenuitem *lock_menuitem = NULL; +static DbusmenuMenuitem *system_settings_menuitem = NULL; +static DbusmenuMenuitem *display_settings_menuitem = NULL; +static DbusmenuMenuitem *bluetooth_settings_menuitem = NULL; +static DbusmenuMenuitem *login_settings_menuitem = NULL; +static DbusmenuMenuitem *software_updates_menuitem = NULL; +static DbusmenuMenuitem *printers_menuitem = NULL; +static DbusmenuMenuitem *scanners_menuitem = NULL; +static DbusmenuMenuitem *webcam_menuitem = NULL; + +static DBusGProxyCall * suspend_call = NULL; +static DBusGProxyCall * hibernate_call = NULL; + +static DbusmenuMenuitem * hibernate_mi = NULL; +static DbusmenuMenuitem * suspend_mi = NULL; +static DbusmenuMenuitem * logout_mi = NULL; +static DbusmenuMenuitem * restart_mi = NULL; +static DbusmenuMenuitem * shutdown_mi = NULL; + +static gboolean can_hibernate = TRUE; +static gboolean can_suspend = TRUE; +static gboolean allow_hibernate = TRUE; +static gboolean allow_suspend = TRUE; + +static DBusGProxy * up_main_proxy = NULL; +static DBusGProxy * up_prop_proxy = NULL; + +static void device_menu_mgr_ensure_gconf_client (DeviceMenuMgr* self); +static void setup_restart_watch (DeviceMenuMgr* self); +static void setup_up (DeviceMenuMgr* self); +static void device_menu_mgr_rebuild_items (DeviceMenuMgr *self); +static void lock_if_possible (DeviceMenuMgr* self); +static void machine_sleep_with_context (DeviceMenuMgr* self, + gchar* type); +static void show_system_settings_with_context (DbusmenuMenuitem * mi, + guint timestamp, + gchar * type); + +static void device_menu_mgr_show_simple_scan (DbusmenuMenuitem * mi, + guint timestamp, + gchar * type); +static void device_menu_mgr_show_cheese (DbusmenuMenuitem * mi, + guint timestamp, + gchar * type); + +static void +machine_sleep_from_hibernate (DbusmenuMenuitem * mi, + guint timestamp, + gpointer userdata); +static void +machine_sleep_from_suspend (DbusmenuMenuitem * mi, + guint timestamp, + gpointer userdata); + +G_DEFINE_TYPE (DeviceMenuMgr, device_menu_mgr, G_TYPE_OBJECT); + +static void +device_menu_mgr_init (DeviceMenuMgr *self) +{ + self->apt_watcher = NULL; + self->root_item = dbusmenu_menuitem_new (); + setup_restart_watch(self); + setup_up(self); + g_idle_add(lock_screen_setup, NULL); +} + +static void +device_menu_mgr_finalize (GObject *object) +{ + G_OBJECT_CLASS (device_menu_mgr_parent_class)->finalize (object); +} + +// TODO refactor into one helper method for both menu mgrs. +static void +device_menu_mgr_class_init (DeviceMenuMgrClass *klass) +{ + GObjectClass* object_class = G_OBJECT_CLASS (klass); + object_class->finalize = device_menu_mgr_finalize; +} + +// TODO +// Is this needed anymore +static void +lockdown_changed (GConfClient *client, + guint cnxd_id, + GConfEntry *entry, + gpointer user_data) +{ + DeviceMenuMgr* self = DEVICE_MENU_MGR (user_data); + GConfValue *value = gconf_entry_get_value (entry); + const gchar *key = gconf_entry_get_key (entry); + + if (value == NULL || key == NULL) { + return; + } + + if (g_strcmp0 (key, LOCKDOWN_KEY_USER) == 0 || + g_strcmp0 (key, LOCKDOWN_KEY_SCREENSAVER) == 0) { + device_menu_mgr_rebuild_items(self); + } + + return; +} + +static void +keybinding_changed (GConfClient *client, + guint cnxd_id, + GConfEntry *entry, + gpointer user_data) +{ + GConfValue *value = gconf_entry_get_value (entry); + const gchar *key = gconf_entry_get_key (entry); + + if (value == NULL || key == NULL) { + return; + } + + if (g_strcmp0 (key, KEY_LOCK_SCREEN) == 0) { + g_debug("Keybinding changed to: %s", gconf_value_get_string(value)); + if (lock_menuitem != NULL) { + dbusmenu_menuitem_property_set_shortcut_string (lock_menuitem, + gconf_value_get_string(value)); + } + } + return; +} + +/* Check to see if the lockdown key is protecting from + locking the screen. If not, lock it. */ +static void +lock_if_possible (DeviceMenuMgr* self) { + device_menu_mgr_ensure_gconf_client (self); + + if (!gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_SCREENSAVER, NULL)) { + lock_screen (NULL, 0, NULL); + } + return; +} + +/* A return from the command to sleep the system. Make sure + that we unthrottle the screensaver. */ +static void +sleep_response (DBusGProxy * proxy, DBusGProxyCall * call, gpointer data) +{ + screensaver_unthrottle(); + return; +} + +static void +machine_sleep_from_suspend (DbusmenuMenuitem * mi, + guint timestamp, + gpointer userdata) +{ + DeviceMenuMgr* self = DEVICE_MENU_MGR (userdata); + machine_sleep_with_context (self, "Suspend"); +} + +static void +machine_sleep_from_hibernate (DbusmenuMenuitem * mi, + guint timestamp, + gpointer userdata) +{ + DeviceMenuMgr* self = DEVICE_MENU_MGR (userdata); + machine_sleep_with_context (self, "Hibernate"); +} + +/* Let's put this machine to sleep, with some info on how + it should sleep. */ +static void +machine_sleep_with_context (DeviceMenuMgr* self, gchar* type) +{ + if (up_main_proxy == NULL) { + g_warning("Can not %s as no upower proxy", type); + } + + screensaver_throttle(type); + lock_if_possible (self); + dbus_g_proxy_begin_call(up_main_proxy, + type, + sleep_response, + NULL, + NULL, + G_TYPE_INVALID); + + return; +} + +/* A response to getting the suspend property */ +static void +suspend_prop_cb (DBusGProxy * proxy, DBusGProxyCall * call, gpointer userdata) +{ + suspend_call = NULL; + DeviceMenuMgr* self = DEVICE_MENU_MGR (userdata); + + GValue candoit = {0}; + GError * error = NULL; + dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_VALUE, &candoit, G_TYPE_INVALID); + if (error != NULL) { + g_warning("Unable to check suspend: %s", error->message); + g_error_free(error); + return; + } + g_debug("Got Suspend: %s", g_value_get_boolean(&candoit) ? "true" : "false"); + + gboolean local_can_suspend = g_value_get_boolean(&candoit); + if (local_can_suspend != can_suspend) { + can_suspend = local_can_suspend; + // TODO figure out what needs updating on the menu + // And add or remove it but just don't rebuild the whole menu + // a waste + device_menu_mgr_rebuild_items(self); + } + return; +} + +/* Response to getting the hibernate property */ +static void +hibernate_prop_cb (DBusGProxy * proxy, DBusGProxyCall * call, gpointer userdata) +{ + hibernate_call = NULL; + DeviceMenuMgr* self = DEVICE_MENU_MGR (userdata); + + GValue candoit = {0}; + GError * error = NULL; + dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_VALUE, &candoit, G_TYPE_INVALID); + if (error != NULL) { + g_warning("Unable to check hibernate: %s", error->message); + g_error_free(error); + return; + } + g_debug("Got Hibernate: %s", g_value_get_boolean(&candoit) ? "true" : "false"); + + gboolean local_can_hibernate = g_value_get_boolean(&candoit); + if (local_can_hibernate != can_hibernate) { + can_hibernate = local_can_hibernate; + device_menu_mgr_rebuild_items(self); + } +} + +/* A signal that we need to recheck to ensure we can still + hibernate and/or suspend */ +static void +up_changed_cb (DBusGProxy * proxy, gpointer user_data) +{ + /* Start Async call to see if we can hibernate */ + if (suspend_call == NULL) { + suspend_call = dbus_g_proxy_begin_call(up_prop_proxy, + "Get", + suspend_prop_cb, + user_data, + NULL, + G_TYPE_STRING, + UP_INTERFACE, + G_TYPE_STRING, + "CanSuspend", + G_TYPE_INVALID, + G_TYPE_VALUE, + G_TYPE_INVALID); + } + + /* Start Async call to see if we can suspend */ + if (hibernate_call == NULL) { + hibernate_call = dbus_g_proxy_begin_call(up_prop_proxy, + "Get", + hibernate_prop_cb, + user_data, + NULL, + G_TYPE_STRING, + UP_INTERFACE, + G_TYPE_STRING, + "CanHibernate", + G_TYPE_INVALID, + G_TYPE_VALUE, + G_TYPE_INVALID); + } +} +/* Handle the callback from the allow functions to check and + see if we're changing the value, and if so, rebuilding the + menus based on that info. */ +static void +allowed_suspend_cb (DBusGProxy *proxy, + gboolean OUT_allowed, + GError *error, + gpointer userdata) +{ + if (error != NULL) { + g_warning("Unable to get information on what is allowed from UPower: %s", + error->message); + return; + } + + if (OUT_allowed != allow_suspend) { + allow_suspend = OUT_allowed; + device_menu_mgr_rebuild_items(DEVICE_MENU_MGR (userdata)); + } +} + +/* Handle the callback from the allow functions to check and + see if we're changing the value, and if so, rebuilding the + menus based on that info. */ +static void +allowed_hibernate_cb (DBusGProxy *proxy, + gboolean OUT_allowed, + GError *error, + gpointer userdata) +{ + if (error != NULL) { + g_warning("Unable to get information on what is allowed from UPower: %s", + error->message); + return; + } + + if (OUT_allowed != allow_hibernate) { + allow_hibernate = OUT_allowed; + device_menu_mgr_rebuild_items(DEVICE_MENU_MGR (userdata)); + } +} + +/* This function goes through and sets up what we need for + DKp checking. We're even setting up the calls for the props + we need */ +static void +setup_up (DeviceMenuMgr* self) { + DBusGConnection * bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL); + g_return_if_fail(bus != NULL); + + if (up_main_proxy == NULL) { + up_main_proxy = dbus_g_proxy_new_for_name(bus, + UP_ADDRESS, + UP_OBJECT, + UP_INTERFACE); + } + g_return_if_fail(up_main_proxy != NULL); + + if (up_prop_proxy == NULL) { + up_prop_proxy = dbus_g_proxy_new_for_name(bus, + UP_ADDRESS, + UP_OBJECT, + DBUS_INTERFACE_PROPERTIES); + /* Connect to changed signal */ + dbus_g_proxy_add_signal(up_main_proxy, + "Changed", + G_TYPE_INVALID); + + dbus_g_proxy_connect_signal(up_main_proxy, + "Changed", + G_CALLBACK(up_changed_cb), + self, + NULL); + } + g_return_if_fail(up_prop_proxy != NULL); + + + /* Force an original "changed" event */ + up_changed_cb(up_main_proxy, self); + + /* Check to see if these are getting blocked by PolicyKit */ + org_freedesktop_UPower_suspend_allowed_async(up_main_proxy, + allowed_suspend_cb, + self); + org_freedesktop_UPower_hibernate_allowed_async(up_main_proxy, + allowed_hibernate_cb, + self); + + return; +} + +/* This is the function to show a dialog on actions that + can destroy data. Currently it just calls the GTK version + but it seems that in the future it should figure out + what's going on and something better. */ +static void +show_dialog (DbusmenuMenuitem * mi, guint timestamp, gchar * type) +{ + + gchar * helper = g_build_filename(LIBEXECDIR, "gtk-logout-helper", NULL); + gchar * dialog_line = g_strdup_printf("%s --%s", helper, type); + g_free(helper); + + g_debug("Showing dialog '%s'", dialog_line); + + GError * error = NULL; + if (!g_spawn_command_line_async(dialog_line, &error)) { + g_warning("Unable to show dialog: %s", error->message); + g_error_free(error); + } + g_free(dialog_line); +} + +static void +show_session_properties (DbusmenuMenuitem * mi, + guint timestamp, + gchar * type) +{ + GError * error = NULL; + if (!g_spawn_command_line_async("gnome-session-properties", &error)) + { + g_warning("Unable to show dialog: %s", error->message); + g_error_free(error); + } +} + +static void +show_printer_properties (DbusmenuMenuitem * mi, + guint timestamp, + gchar * type) +{ + GError * error = NULL; + if (!g_spawn_command_line_async("system-config-printer", &error)) + { + g_warning("Unable to show dialog: %s", error->message); + g_error_free(error); + } +} + +static void +show_system_settings_with_context (DbusmenuMenuitem * mi, + guint timestamp, + gchar * type) +{ + gchar * control_centre_command = g_strdup_printf("%s %s", + "gnome-control-center", + type); + + g_debug("Command centre exec call '%s'", control_centre_command); + + GError * error = NULL; + if (!g_spawn_command_line_async(control_centre_command, &error)) + { + g_warning("Unable to show dialog: %s", error->message); + g_error_free(error); + } + g_free(control_centre_command); +} + +// TODO: refactor both of these down to the one method. +static void device_menu_mgr_show_simple_scan (DbusmenuMenuitem * mi, + guint timestamp, + gchar * type) +{ + GError * error = NULL; + if (!g_spawn_command_line_async("simple-scan", &error)) + { + g_warning("Unable to launch simple-scan: %s", error->message); + g_error_free(error); + if (!g_spawn_command_line_async("software-center simple-scan", &error)) + { + g_warning ("Unable to launch software-centre simple-scan: %s", + error->message); + g_error_free(error); + } + } +} + +static void device_menu_mgr_show_cheese (DbusmenuMenuitem * mi, + guint timestamp, + gchar * type) +{ + GError * error = NULL; + if (!g_spawn_command_line_async("cheese", &error)) + { + g_warning("Unable to launch cheese: %s", error->message); + g_error_free(error); + if (!g_spawn_command_line_async("software-center cheese", &error)) + { + g_warning ("Unable to launch software-centre cheese: %s", + error->message); + g_error_free(error); + } + } +} + +static void +device_menu_mgr_build_settings_items (DeviceMenuMgr* self) +{ + system_settings_menuitem = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (system_settings_menuitem, + DBUSMENU_MENUITEM_PROP_LABEL, + _("System Settings…")); + g_signal_connect (G_OBJECT(system_settings_menuitem), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(show_system_settings_with_context), ""); + dbusmenu_menuitem_child_add_position(self->root_item, + system_settings_menuitem, + 0); + + display_settings_menuitem = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (display_settings_menuitem, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Displays…")); + g_signal_connect (G_OBJECT(display_settings_menuitem), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(show_system_settings_with_context), "display"); + dbusmenu_menuitem_child_add_position(self->root_item, + display_settings_menuitem, + 1); + bluetooth_settings_menuitem = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (bluetooth_settings_menuitem, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Bluetooth…")); + g_signal_connect (G_OBJECT(bluetooth_settings_menuitem), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(show_system_settings_with_context), "bluetooth"); + dbusmenu_menuitem_child_add_position(self->root_item, + bluetooth_settings_menuitem, + 2); + + login_settings_menuitem = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (login_settings_menuitem, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Startup Applications…")); + g_signal_connect (G_OBJECT(login_settings_menuitem), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(show_session_properties), + "login"); + dbusmenu_menuitem_child_add_position(self->root_item, + login_settings_menuitem, + 3); + software_updates_menuitem = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (software_updates_menuitem, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Software Up to Date")); + dbusmenu_menuitem_child_add_position(self->root_item, + software_updates_menuitem, + 4); + + DbusmenuMenuitem * separator1 = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (separator1, + DBUSMENU_MENUITEM_PROP_TYPE, + DBUSMENU_CLIENT_TYPES_SEPARATOR); + dbusmenu_menuitem_child_add_position (self->root_item, separator1, 5); +} + +static void +device_menu_mgr_build_devices_items (DeviceMenuMgr* self) +{ + DbusmenuMenuitem * device_heading = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (device_heading, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Attached Devices")); + dbusmenu_menuitem_property_set_bool (device_heading, + DBUSMENU_MENUITEM_PROP_ENABLED, + FALSE); + dbusmenu_menuitem_child_add_position (self->root_item, + device_heading, + 6); + + printers_menuitem = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (printers_menuitem, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Printers")); + g_signal_connect (G_OBJECT(printers_menuitem), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(show_printer_properties), + "printers"); + dbusmenu_menuitem_child_add_position(self->root_item, + printers_menuitem, + 7); + scanners_menuitem = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (scanners_menuitem, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Scanners")); + g_signal_connect (G_OBJECT(scanners_menuitem), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(device_menu_mgr_show_simple_scan), + NULL); + dbusmenu_menuitem_child_add_position (self->root_item, + scanners_menuitem, + 8); + dbusmenu_menuitem_property_set_bool (scanners_menuitem, + DBUSMENU_MENUITEM_PROP_VISIBLE, + FALSE); + + webcam_menuitem = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (webcam_menuitem, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Webcam")); + g_signal_connect (G_OBJECT(webcam_menuitem), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(device_menu_mgr_show_cheese), + NULL); + dbusmenu_menuitem_child_add_position (self->root_item, + webcam_menuitem, + 10); + dbusmenu_menuitem_property_set_bool (webcam_menuitem, + DBUSMENU_MENUITEM_PROP_VISIBLE, + FALSE); + + DbusmenuMenuitem * separator3 = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (separator3, + DBUSMENU_MENUITEM_PROP_TYPE, + DBUSMENU_CLIENT_TYPES_SEPARATOR); + dbusmenu_menuitem_child_add_position (self->root_item, separator3, 11); +} + +static void +device_menu_mgr_build_static_items (DeviceMenuMgr* self, gboolean greeter_mode) +{ + // Static Setting items + if (!greeter_mode) { + device_menu_mgr_build_settings_items (self); + } + + // Devices control + if (!greeter_mode) { + device_menu_mgr_build_devices_items (self); + } + + // Session control + if (!greeter_mode) { + gboolean can_lockscreen; + + /* Make sure we have a valid GConf client, and build one + if needed */ + device_menu_mgr_ensure_gconf_client (self); + can_lockscreen = !gconf_client_get_bool ( gconf_client, + LOCKDOWN_KEY_SCREENSAVER, + NULL); + /* Lock screen item */ + if (can_lockscreen) { + lock_menuitem = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (lock_menuitem, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Lock Screen")); + + gchar * shortcut = gconf_client_get_string(gconf_client, KEY_LOCK_SCREEN, NULL); + if (shortcut != NULL) { + g_debug("Lock screen shortcut: %s", shortcut); + dbusmenu_menuitem_property_set_shortcut_string(lock_menuitem, shortcut); + g_free(shortcut); + } + else { + g_debug("Unable to get lock screen shortcut."); + } + + g_signal_connect (G_OBJECT(lock_menuitem), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(lock_screen), NULL); + dbusmenu_menuitem_child_append(self->root_item, lock_menuitem); + } + + logout_mi = dbusmenu_menuitem_new(); + + if (supress_confirmations()) { + dbusmenu_menuitem_property_set (logout_mi, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Log Out")); + } + else { + dbusmenu_menuitem_property_set (logout_mi, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Log Out\342\200\246")); + } + dbusmenu_menuitem_property_set_bool (logout_mi, + DBUSMENU_MENUITEM_PROP_VISIBLE, + show_logout()); + dbusmenu_menuitem_child_append(self->root_item, logout_mi); + g_signal_connect( G_OBJECT(logout_mi), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(show_dialog), "logout"); + } + + if (can_suspend && allow_suspend) { + suspend_mi = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (suspend_mi, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Suspend")); + dbusmenu_menuitem_child_append (self->root_item, suspend_mi); + g_signal_connect( G_OBJECT(suspend_mi), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(machine_sleep_from_suspend), + self); + } + + if (can_hibernate && allow_hibernate) { + hibernate_mi = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (hibernate_mi, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Hibernate")); + dbusmenu_menuitem_child_append(self->root_item, hibernate_mi); + g_signal_connect (G_OBJECT(hibernate_mi), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(machine_sleep_from_hibernate), self); + } + + shutdown_mi = dbusmenu_menuitem_new(); + + if (supress_confirmations()) { + dbusmenu_menuitem_property_set (shutdown_mi, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Shut Down")); + } + else { + dbusmenu_menuitem_property_set (shutdown_mi, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Shut Down\342\200\246")); + } + dbusmenu_menuitem_property_set_bool (shutdown_mi, + DBUSMENU_MENUITEM_PROP_VISIBLE, + show_shutdown()); + dbusmenu_menuitem_child_append (self->root_item, shutdown_mi); + g_signal_connect (G_OBJECT(shutdown_mi), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(show_dialog), "shutdown"); + + RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi = g_new0 (RestartShutdownLogoutMenuItems, 1); + restart_shutdown_logout_mi->logout_mi = logout_mi; + restart_shutdown_logout_mi->shutdown_mi = shutdown_mi; + + update_menu_entries(restart_shutdown_logout_mi); + // Time to create the udev mgr and hand it the static relevant items. + self->udev_mgr = udev_mgr_new (scanners_menuitem, webcam_menuitem); +} + + +static void +device_menu_mgr_rebuild_items (DeviceMenuMgr* self) +{ + dbusmenu_menuitem_property_set_bool (hibernate_mi, + DBUSMENU_MENUITEM_PROP_VISIBLE, + can_hibernate && allow_hibernate); + dbusmenu_menuitem_property_set_bool (suspend_mi, + DBUSMENU_MENUITEM_PROP_VISIBLE, + can_suspend && allow_suspend); +} + +/* When the directory changes we need to figure out how our menu + item should look. */ +static void +restart_dir_changed (gpointer userdata) +{ + DeviceMenuMgr* self = DEVICE_MENU_MGR (userdata); + gboolean restart_required = g_file_test("/var/run/reboot-required", G_FILE_TEST_EXISTS); + + if (restart_required) { + if (supress_confirmations()) { + dbusmenu_menuitem_property_set (restart_mi, + RESTART_ITEM_LABEL, + _("Restart to Complete Update")); + } else { + dbusmenu_menuitem_property_set (restart_mi, + RESTART_ITEM_LABEL, + _("Restart to Complete Update\342\200\246")); + } + dbusmenu_menuitem_property_set (restart_mi, + RESTART_ITEM_ICON, + "system-restart-panel"); + if (self->session_dbus_interface != NULL) { + session_dbus_set_name (self->session_dbus_interface, ICON_RESTART); + } + } else { + if (supress_confirmations()) { + dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart")); + } else { + dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart\342\200\246")); + } + dbusmenu_menuitem_property_remove(restart_mi, RESTART_ITEM_ICON); + if (self->session_dbus_interface != NULL) { + session_dbus_set_name(self->session_dbus_interface, ICON_DEFAULT); + } + } + return; +} + +/* Buids a file watcher for the directory so that when it + changes we can check to see if our reboot-required is + there. */ +static void +setup_restart_watch (DeviceMenuMgr* self) +{ + GFile * filedir = g_file_new_for_path("/var/run"); + GFileMonitor * filemon = g_file_monitor_directory(filedir, G_FILE_MONITOR_NONE, NULL, NULL); + if (filemon != NULL) { + g_signal_connect (G_OBJECT(filemon), + "changed", + G_CALLBACK(restart_dir_changed), + self); + } + restart_dir_changed(self); + return; +} + +/* Ensures that we have a GConf client and if we build one + set up the signal handler. */ +static void +device_menu_mgr_ensure_gconf_client (DeviceMenuMgr* self) +{ + if (!gconf_client) { + gconf_client = gconf_client_get_default (); + gconf_client_add_dir(gconf_client, LOCKDOWN_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + gconf_client_notify_add (gconf_client, + LOCKDOWN_DIR, + lockdown_changed, + self, + NULL, + NULL); + + gconf_client_add_dir(gconf_client, KEYBINDING_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + gconf_client_notify_add (gconf_client, + KEYBINDING_DIR, + keybinding_changed, + self, + NULL, + NULL); + } +} + +DbusmenuMenuitem* +device_mgr_get_root_item (DeviceMenuMgr* self) +{ + return self->root_item; +} + +/* + * Clean Entry Point + */ +DeviceMenuMgr* device_menu_mgr_new (SessionDbus* session_dbus, gboolean greeter_mode) +{ + DeviceMenuMgr* device_mgr = g_object_new (DEVICE_TYPE_MENU_MGR, NULL); + device_mgr->session_dbus_interface = session_dbus; + device_menu_mgr_build_static_items (device_mgr, greeter_mode); + if (software_updates_menuitem != NULL) { + device_mgr->apt_watcher = apt_watcher_new (session_dbus, + software_updates_menuitem); + } + return device_mgr; +} diff --git a/src/device-menu-mgr.h b/src/device-menu-mgr.h new file mode 100644 index 0000000..d3c3a5a --- /dev/null +++ b/src/device-menu-mgr.h @@ -0,0 +1,53 @@ +/* +Copyright 2011 Canonical Ltd. + +Authors: + Conor Curran <conor.curran@canonical.com> + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + + +#ifndef _DEVICE_MENU_MGR_H_ +#define _DEVICE_MENU_MGR_H_ + +#include <glib-object.h> + +#include "session-dbus.h" + +G_BEGIN_DECLS + +#define DEVICE_TYPE_MENU_MGR (device_menu_mgr_get_type ()) +#define DEVICE_MENU_MGR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DEVICE_TYPE_MENU_MGR, DeviceMenuMgr)) +#define DEVICE_MENU_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DEVICE_TYPE_MENU_MGR, DeviceMenuMgrClass)) +#define DEVICE_IS_MENU_MGR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DEVICE_TYPE_MENU_MGR)) +#define DEVICE_IS_MENU_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DEVICE_TYPE_MENU_MGR)) +#define DEVICE_MENU_MGR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DEVICE_TYPE_MENU_MGR, DeviceMenuMgrClass)) + +typedef struct _DeviceMenuMgrClass DeviceMenuMgrClass; +typedef struct _DeviceMenuMgr DeviceMenuMgr; + +struct _DeviceMenuMgrClass +{ + GObjectClass parent_class; +}; + +GType device_menu_mgr_get_type (void) G_GNUC_CONST; + +DeviceMenuMgr* device_menu_mgr_new (SessionDbus* session_dbus, gboolean greeter_mode); + +DbusmenuMenuitem* device_mgr_get_root_item (DeviceMenuMgr* self); + +G_END_DECLS + +#endif /* _DEVICE_MENU_MGR_H_ */ diff --git a/src/dialog.c b/src/dialog.c index 9633224..299f954 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -183,6 +183,8 @@ logout_dialog_new (LogoutDialogType type) "text", _(body_strings[type]), NULL)); + gtk_window_set_keep_above(GTK_WINDOW(dialog), TRUE); + gboolean allowed = FALSE; if (type == LOGOUT_DIALOG_TYPE_LOG_OUT) { allowed = ck_check_allowed(LOGOUT_DIALOG_TYPE_RESTART); @@ -223,6 +225,12 @@ logout_dialog_new (LogoutDialogType type) button_text, GTK_RESPONSE_OK, NULL); } + + if (type == LOGOUT_DIALOG_TYPE_SHUTDOWN){ + const gchar * restart_text; + restart_text = g_dpgettext2 (NULL, "button", button_strings[LOGOUT_DIALOG_TYPE_RESTART]); + gtk_dialog_add_button (GTK_DIALOG(dialog), restart_text, GTK_RESPONSE_HELP); + } gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK); diff --git a/src/display-manager.xml b/src/display-manager.xml index 004eca1..92f5e05 100644 --- a/src/display-manager.xml +++ b/src/display-manager.xml @@ -1,17 +1,20 @@ <!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> <node> - <interface name="org.freedesktop.DisplayManager"> + <interface name="org.freedesktop.DisplayManager.Seat"> <!-- Show greeter to allow new login / switch users --> - <method name="ShowGreeter"/> + <method name="SwitchToGreeter"/> <!-- Switch to a user, starting a new display if required --> <method name="SwitchToUser"> <arg name="username" direction="in" type="s"/> + <arg name="session" direction="in" type="s"/> </method> <!-- Switch to the guest user --> - <method name="SwitchToGuest"/> + <method name="SwitchToGuest"> + <arg name="session" direction="in" type="s"/> + </method> </interface> </node> diff --git a/src/gconf-helper.c b/src/gconf-helper.c index 4911dcb..93ae96f 100644 --- a/src/gconf-helper.c +++ b/src/gconf-helper.c @@ -82,9 +82,9 @@ static void update_menu_entries_callback (GConfClient *client, guint cnxn_id, GC dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->restart_mi, RESTART_ITEM_LABEL, _("Restart")); dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Shut Down")); } else { - dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->logout_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Log Out...")); - dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->restart_mi, RESTART_ITEM_LABEL, _("Restart...")); - dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Shut Down...")); + dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->logout_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Log Out…")); + dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->restart_mi, RESTART_ITEM_LABEL, _("Restart…")); + dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Shut Down…")); } } } diff --git a/src/gconf-helper.h b/src/gconf-helper.h index 505c24f..039b309 100644 --- a/src/gconf-helper.h +++ b/src/gconf-helper.h @@ -39,6 +39,12 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #define RESTART_KEY GLOBAL_DIR "/suppress_restart_menuitem" #define SHUTDOWN_KEY GLOBAL_DIR "/suppress_shutdown_menuitem" +#define LOCKDOWN_DIR "/desktop/gnome/lockdown" +#define LOCKDOWN_KEY_USER LOCKDOWN_DIR "/disable_user_switching" +#define LOCKDOWN_KEY_SCREENSAVER LOCKDOWN_DIR "/disable_lock_screen" +#define KEYBINDING_DIR "/apps/gnome_settings_daemon/keybindings" +#define KEY_LOCK_SCREEN KEYBINDING_DIR "/screensaver" + typedef struct _RestartShutdownLogoutMenuItems { DbusmenuMenuitem * logout_mi; diff --git a/src/gen-session-dbus.xml.c b/src/gen-session-dbus.xml.c index 493d18d..319f203 100644 --- a/src/gen-session-dbus.xml.c +++ b/src/gen-session-dbus.xml.c @@ -3,15 +3,23 @@ const char * _session_dbus = "<node name=\"/com/canonical/indicator/session/service\">\n" " <interface name=\"com.canonical.indicator.session.service\">\n" "\n" -" <!-- Icon -->\n" -" <method name=\"GetIcon\">\n" +" <method name=\"GetUserRealName\">\n" " <arg name=\"name\" direction=\"out\" type=\"s\"/>\n" " </method>\n" -"\n" -" <signal name=\"IconUpdated\">\n" +" <method name=\"GetUserMenuVisibility\">\n" +" <arg name=\"update\" direction=\"out\" type=\"b\"/>\n" +" </method>\n" +" <method name=\"IsUpdateNeeded\">\n" +" <arg name=\"update\" direction=\"out\" type=\"b\"/>\n" +" </method>\n" +" <signal name=\"UserRealNameUpdated\">\n" " <arg name=\"name\" type=\"s\"/>\n" " </signal>\n" -"\n" +" <signal name=\"UserMenuIsVisible\">\n" +" <arg name=\"update\" type=\"b\"/>\n" +" </signal>\n" +" <signal name=\"RestartRequired\">\n" +" </signal>\n" " </interface>\n" "</node>\n" ; diff --git a/src/indicator-session.c b/src/indicator-session.c index c9617c4..f6727d9 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -6,7 +6,8 @@ Copyright 2009 Canonical Ltd. Authors: Ted Gould <ted@canonical.com> - + Conor Curran <conor.curran@canonical.com> + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3, as published by the Free Software Foundation. @@ -43,6 +44,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include "dbus-shared-names.h" #include "dbusmenu-shared.h" +#include "user-widget.h" #define INDICATOR_SESSION_TYPE (indicator_session_get_type ()) #define INDICATOR_SESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INDICATOR_SESSION_TYPE, IndicatorSession)) @@ -61,8 +63,9 @@ struct _IndicatorSessionClass { struct _IndicatorSession { IndicatorObject parent; IndicatorServiceManager * service; - GtkImage * status_image; - DbusmenuGtkMenu * menu; + IndicatorObjectEntry users; + IndicatorObjectEntry devices; + gboolean show_users_entry; GCancellable * service_proxy_cancel; GDBusProxy * service_proxy; }; @@ -74,26 +77,37 @@ INDICATOR_SET_VERSION INDICATOR_SET_TYPE(INDICATOR_SESSION_TYPE) /* Prototypes */ -static GtkLabel * get_label (IndicatorObject * io); -static GtkImage * get_icon (IndicatorObject * io); -static GtkMenu * get_menu (IndicatorObject * io); -static const gchar * get_accessible_desc (IndicatorObject * io); -static gboolean build_menu_switch (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data); -static gboolean new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data); -static void icon_changed (IndicatorSession * session, const gchar * icon_name); +static gboolean build_menu_switch (DbusmenuMenuitem * newitem, + DbusmenuMenuitem * parent, + DbusmenuClient * client, + gpointer user_data); +static gboolean new_user_item (DbusmenuMenuitem * newitem, + DbusmenuMenuitem * parent, + DbusmenuClient * client, + gpointer user_data); +static gboolean build_restart_item (DbusmenuMenuitem * newitem, + DbusmenuMenuitem * parent, + DbusmenuClient * client, + gpointer user_data); +static void indicator_session_update_users_label (IndicatorSession* self, + const gchar* name); static void service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointer user_data); -static gboolean build_restart_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data); static void receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, GVariant * parameters, gpointer user_data); static void service_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data); +static void user_real_name_get_cb (GObject * obj, GAsyncResult * res, gpointer user_data); +static void user_menu_visibility_get_cb (GObject* obj, GAsyncResult* res, gpointer user_data); static void indicator_session_class_init (IndicatorSessionClass *klass); static void indicator_session_init (IndicatorSession *self); static void indicator_session_dispose (GObject *object); static void indicator_session_finalize (GObject *object); - +static GList* indicator_session_get_entries (IndicatorObject* obj); +static guint indicator_session_get_location (IndicatorObject * io, + IndicatorObjectEntry * entry); + G_DEFINE_TYPE (IndicatorSession, indicator_session, INDICATOR_OBJECT_TYPE); -static void +static void indicator_session_class_init (IndicatorSessionClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); @@ -102,82 +116,87 @@ indicator_session_class_init (IndicatorSessionClass *klass) object_class->finalize = indicator_session_finalize; IndicatorObjectClass * io_class = INDICATOR_OBJECT_CLASS(klass); - io_class->get_label = get_label; - io_class->get_image = get_icon; - io_class->get_menu = get_menu; - io_class->get_accessible_desc = get_accessible_desc; - + io_class->get_entries = indicator_session_get_entries; + io_class->get_location = indicator_session_get_location; return; } static void indicator_session_init (IndicatorSession *self) { - /* Set good defaults */ self->service = NULL; self->service_proxy_cancel = NULL; self->service_proxy = NULL; - + self->show_users_entry = FALSE; + /* Now let's fire these guys up. */ - self->service = indicator_service_manager_new_version(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_VERSION); - g_signal_connect(G_OBJECT(self->service), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(service_connection_cb), self); - - self->status_image = indicator_image_helper(ICON_DEFAULT); - self->menu = dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_OBJECT); - - DbusmenuClient * client = DBUSMENU_CLIENT(dbusmenu_gtkmenu_get_client(self->menu)); - dbusmenu_client_add_type_handler(client, MENU_SWITCH_TYPE, build_menu_switch); - dbusmenu_client_add_type_handler(client, USER_ITEM_TYPE, new_user_item); - dbusmenu_client_add_type_handler(client, RESTART_ITEM_TYPE, build_restart_item); - + self->service = indicator_service_manager_new_version(INDICATOR_SESSION_DBUS_NAME, + INDICATOR_SESSION_DBUS_VERSION); + g_signal_connect(G_OBJECT(self->service), + INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, + G_CALLBACK(service_connection_cb), self); + + GtkWidget* avatar_icon = NULL; + // users + self->users.menu = GTK_MENU (dbusmenu_gtkmenu_new (INDICATOR_USERS_DBUS_NAME, + INDICATOR_USERS_DBUS_OBJECT)); + // Set the image to the default avator image + GdkPixbuf* pixbuf = NULL; + GError* error = NULL; + pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), + "avatar-default", + 17, + GTK_ICON_LOOKUP_FORCE_SIZE, + &error); + + // I think the avatar image is available always but just in case have a fallback + if (error != NULL) { + g_warning ("Could not load the default avatar image for some reason"); + self->users.image = indicator_image_helper (USER_ITEM_ICON_DEFAULT); + } + else{ + avatar_icon = gtk_image_new (); + gtk_image_set_from_pixbuf (GTK_IMAGE (avatar_icon), pixbuf); + self->users.image = GTK_IMAGE (avatar_icon); + g_object_unref (pixbuf); + g_error_free (error); + } + + self->users.label = GTK_LABEL (gtk_label_new (NULL)); + + // devices + self->devices.menu = GTK_MENU (dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, + INDICATOR_SESSION_DBUS_OBJECT)); + self->devices.image = indicator_image_helper ("system-devices-panel"); + + gtk_widget_show (GTK_WIDGET(self->devices.menu)); + gtk_widget_show (GTK_WIDGET(self->devices.image)); + gtk_widget_show (GTK_WIDGET(self->users.image)); + gtk_widget_show (GTK_WIDGET(self->users.menu)); + + g_object_ref_sink (self->users.menu); + g_object_ref_sink (self->users.image); + g_object_ref_sink (self->devices.menu); + g_object_ref_sink (self->devices.image); + + // Setup the handlers for users + DbusmenuClient * users_client = DBUSMENU_CLIENT(dbusmenu_gtkmenu_get_client(DBUSMENU_GTKMENU(self->users.menu))); + dbusmenu_client_add_type_handler (users_client, + USER_ITEM_TYPE, + new_user_item); + dbusmenu_client_add_type_handler_full (users_client, + MENU_SWITCH_TYPE, + build_menu_switch, + self, NULL); + + // Setup the handlers for devices + DbusmenuClient * devices_client = DBUSMENU_CLIENT(dbusmenu_gtkmenu_get_client(DBUSMENU_GTKMENU(self->devices.menu))); + dbusmenu_client_add_type_handler (devices_client, + RESTART_ITEM_TYPE, + build_restart_item); + GtkAccelGroup * agroup = gtk_accel_group_new(); - dbusmenu_gtkclient_set_accel_group(DBUSMENU_GTKCLIENT(client), agroup); - - self->service_proxy_cancel = g_cancellable_new(); - - g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION, - G_DBUS_PROXY_FLAGS_NONE, - NULL, - INDICATOR_SESSION_DBUS_NAME, - INDICATOR_SESSION_SERVICE_DBUS_OBJECT, - INDICATOR_SESSION_SERVICE_DBUS_IFACE, - self->service_proxy_cancel, - service_proxy_cb, - self); - - return; -} - -/* Callback from trying to create the proxy for the serivce, this - could include starting the service. Sometime it'll fail and - we'll try to start that dang service again! */ -static void -service_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data) -{ - GError * error = NULL; - - IndicatorSession * self = INDICATOR_SESSION(user_data); - g_return_if_fail(self != NULL); - - GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error); - - if (self->service_proxy_cancel != NULL) { - g_object_unref(self->service_proxy_cancel); - self->service_proxy_cancel = NULL; - } - - if (error != NULL) { - g_warning("Could not grab DBus proxy for %s: %s", INDICATOR_SESSION_DBUS_NAME, error->message); - g_error_free(error); - return; - } - - /* Okay, we're good to grab the proxy at this point, we're - sure that it's ours. */ - self->service_proxy = proxy; - - g_signal_connect(proxy, "g-signal", G_CALLBACK(receive_signal), self); - + dbusmenu_gtkclient_set_accel_group(DBUSMENU_GTKCLIENT(devices_client), agroup); return; } @@ -201,6 +220,14 @@ indicator_session_dispose (GObject *object) g_object_unref(self->service_proxy_cancel); self->service_proxy_cancel = NULL; } + + if (self->users.menu != NULL) { + g_object_unref (self->users.menu); + } + + if (self->devices.menu != NULL) { + g_object_unref (self->devices.menu); + } G_OBJECT_CLASS (indicator_session_parent_class)->dispose (object); return; @@ -214,256 +241,348 @@ indicator_session_finalize (GObject *object) return; } -static void -icon_name_get_cb (GObject * obj, GAsyncResult * res, gpointer user_data) +static GList* +indicator_session_get_entries (IndicatorObject* obj) { - IndicatorSession * self = INDICATOR_SESSION(user_data); - GError * error = NULL; - gchar * name; - GVariant * result; - - result = g_dbus_proxy_call_finish(self->service_proxy, res, &error); - - if (error != NULL) { - return; - } - - g_variant_get(result, "(&s)", &name); - - if (name == NULL || name[0] == '\0') { - return; + g_return_val_if_fail(IS_INDICATOR_SESSION(obj), NULL); + IndicatorSession* self = INDICATOR_SESSION (obj); + + g_debug ("get entries"); + GList * retval = NULL; + // Only show the users menu if we have more than one + if (self->show_users_entry == TRUE){ + retval = g_list_prepend (retval, &self->users); + } + retval = g_list_prepend (retval, &self->devices); + + if (retval != NULL) { + retval = g_list_reverse(retval); } + return retval; +} - indicator_image_helper_update(self->status_image, name); - return; +static guint +indicator_session_get_location (IndicatorObject * io, + IndicatorObjectEntry * entry) +{ + IndicatorSession * self = INDICATOR_SESSION (io); + if (entry == &self->users){ + return 1; + } + else if (entry == &self->devices){ + return 0; + } + g_warning ("IOEntry handed to us to position but we don't own it!"); + return 0; } +/* callback for the service manager state of being */ static void service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointer user_data) { - IndicatorSession * self = INDICATOR_SESSION(user_data); + IndicatorSession * self = INDICATOR_SESSION (user_data); if (connected) { - g_dbus_proxy_call(self->service_proxy, "GetIcon", NULL, - G_DBUS_CALL_FLAGS_NONE, -1, NULL, - icon_name_get_cb, user_data); - } else { - indicator_image_helper_update(self->status_image, ICON_DEFAULT); - } - + if (self->service_proxy != NULL){ + // Its a reconnect ! + // Fetch synchronisation data and return (proxy is still legit) + g_dbus_proxy_call (self->service_proxy, + "GetUserMenuVisibility", + NULL, + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + user_menu_visibility_get_cb, + user_data); + g_dbus_proxy_call (self->service_proxy, + "GetUserRealName", + NULL, + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + user_real_name_get_cb, + user_data); + return; + } + + self->service_proxy_cancel = g_cancellable_new(); + g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION, + G_DBUS_PROXY_FLAGS_NONE, + NULL, + INDICATOR_SESSION_DBUS_NAME, + INDICATOR_SESSION_SERVICE_DBUS_OBJECT, + INDICATOR_SESSION_SERVICE_DBUS_IFACE, + self->service_proxy_cancel, + service_proxy_cb, + self); + } return; } -static GtkLabel * -get_label (IndicatorObject * io) -{ - return NULL; -} - -static const gchar * -get_accessible_desc (IndicatorObject * io) -{ - return _("Session"); -} static void -icon_changed (IndicatorSession * session, const gchar * icon_name) +service_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data) { - indicator_image_helper_update(session->status_image, icon_name); - return; -} + GError * error = NULL; -/* Receives all signals from the service, routed to the appropriate functions */ -static void -receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, - GVariant * parameters, gpointer user_data) -{ IndicatorSession * self = INDICATOR_SESSION(user_data); + g_return_if_fail(self != NULL); + + GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error); - if (g_strcmp0(signal_name, "IconUpdated") == 0) { - const gchar *name; - g_variant_get (parameters, "(&s)", &name); - icon_changed(self, name); + if (self->service_proxy_cancel != NULL) { + g_object_unref(self->service_proxy_cancel); + self->service_proxy_cancel = NULL; } - return; -} + if (error != NULL) { + g_warning("Could not grab DBus proxy for %s: %s", INDICATOR_SESSION_DBUS_NAME, error->message); + g_error_free(error); + return; + } -static GtkImage * -get_icon (IndicatorObject * io) -{ - gtk_widget_show(GTK_WIDGET(INDICATOR_SESSION(io)->status_image)); - return INDICATOR_SESSION(io)->status_image; -} + /* Okay, we're good to grab the proxy at this point, we're + sure that it's ours. */ + self->service_proxy = proxy; -static void -user_property_change (DbusmenuMenuitem * item, const gchar * property, GVariant * variant, gpointer user_data) -{ - if (g_strcmp0(property, USER_ITEM_PROP_LOGGED_IN) == 0) { - if (g_variant_get_boolean(variant)) { - gtk_widget_show(GTK_WIDGET(user_data)); - } else { - gtk_widget_hide(GTK_WIDGET(user_data)); - } - } + g_signal_connect(proxy, "g-signal", G_CALLBACK(receive_signal), self); + + // Figure out whether we should show the user menu at all. + g_dbus_proxy_call (self->service_proxy, + "GetUserMenuVisibility", + NULL, + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + user_menu_visibility_get_cb, + user_data); + + // Fetch the user's real name for the user entry label + g_dbus_proxy_call (self->service_proxy, + "GetUserRealName", + NULL, + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + user_real_name_get_cb, + user_data); return; } -/* Builds an item with a hip little logged in icon. */ + static gboolean -new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data) +new_user_item (DbusmenuMenuitem * newitem, + DbusmenuMenuitem * parent, + DbusmenuClient * client, + gpointer user_data) { - GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_menu_item_new()); - gint padding = 0; - gtk_widget_style_get(GTK_WIDGET(gmi), "horizontal-padding", &padding, NULL); - GtkWidget * hbox = gtk_hbox_new(FALSE, padding); - - GtkWidget * usericon = NULL; - const gchar * icon_name = dbusmenu_menuitem_property_get(newitem, USER_ITEM_PROP_ICON); - g_debug("Using user icon for '%s' from file: %s", dbusmenu_menuitem_property_get(newitem, USER_ITEM_PROP_NAME), icon_name); - if (icon_name != NULL && icon_name[0] != '\0') { - if (g_strcmp0(icon_name, USER_ITEM_ICON_DEFAULT) != 0 && g_file_test(icon_name, G_FILE_TEST_EXISTS)) { - gint width, height; - gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); - - GError * error = NULL; - GdkPixbuf * pixbuf = gdk_pixbuf_new_from_file_at_size(icon_name, width, height, &error); - - if (error == NULL) { - usericon = gtk_image_new_from_pixbuf(pixbuf); - g_object_unref(pixbuf); - } else { - g_warning("Unable to load user icon '%s': %s", icon_name, error->message); - g_error_free(error); - } - } + - if (usericon == NULL) { - GIcon * gicon = g_themed_icon_new_with_default_fallbacks("stock_person-panel"); - usericon = gtk_image_new_from_gicon(gicon, GTK_ICON_SIZE_MENU); - g_object_unref(gicon); - } - } - if (usericon != NULL) { - gtk_misc_set_alignment(GTK_MISC(usericon), 0.0, 0.5); - gtk_box_pack_start(GTK_BOX(hbox), usericon, FALSE, FALSE, 0); - gtk_widget_show(usericon); - } + GtkWidget* user_item = NULL; - GtkWidget * label = gtk_label_new(dbusmenu_menuitem_property_get(newitem, USER_ITEM_PROP_NAME)); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); - gtk_widget_show(label); - - GtkWidget * icon = gtk_image_new_from_icon_name("account-logged-in", GTK_ICON_SIZE_MENU); - gtk_misc_set_alignment(GTK_MISC(icon), 1.0, 0.5); - gtk_box_pack_start(GTK_BOX(hbox), icon, FALSE, FALSE, 0); - if (dbusmenu_menuitem_property_get_bool(newitem, USER_ITEM_PROP_LOGGED_IN)) { - gtk_widget_show(icon); - } else { - gtk_widget_hide(icon); - } + g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); + g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE); - gtk_container_add(GTK_CONTAINER(gmi), hbox); - gtk_widget_show(hbox); + user_item = user_widget_new(newitem); - dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent); + GtkMenuItem *user_widget = GTK_MENU_ITEM(user_item); - g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(user_property_change), icon); + dbusmenu_gtkclient_newitem_base (DBUSMENU_GTKCLIENT(client), + newitem, + user_widget, + parent); - return TRUE; -} + g_debug ("%s (\"%s\")", __func__, + dbusmenu_menuitem_property_get (newitem, + USER_ITEM_PROP_NAME)); + gtk_widget_show_all (user_item); -/* Indicator based function to get the menu for the whole - applet. This starts up asking for the parts of the menu - from the various services. */ -static GtkMenu * -get_menu (IndicatorObject * io) -{ - return GTK_MENU(INDICATOR_SESSION(io)->menu); + return TRUE; } + static void -switch_property_change (DbusmenuMenuitem * item, const gchar * property, GVariant * variant, gpointer user_data) +user_real_name_get_cb (GObject * obj, GAsyncResult * res, gpointer user_data) { - if (g_strcmp0(property, MENU_SWITCH_USER) != 0) { - return; - } - - GtkMenuItem * gmi = dbusmenu_gtkclient_menuitem_get(DBUSMENU_GTKCLIENT(user_data), item); - gchar * finalstring = NULL; - gboolean set_ellipsize = FALSE; - gboolean no_name_in_lang = FALSE; - - /* TRANSLATORS: Translate the '1' below into anything other than - '1' if "Switch From %s..." doesn't make sense in your language. - Instead, the string "Switch User..." will be used. */ - const gchar * translate = C_("session_menu:switchfrom", "1"); - if (g_strcmp0(translate, "1") != 0) { - no_name_in_lang = TRUE; - } + IndicatorSession * self = INDICATOR_SESSION(user_data); + GError * error = NULL; + GVariant * result; - /* If there's a NULL string of some type, then we want to - go back to our old 'Switch User' which isn't great but - eh, this error condition should never happen. */ - if (variant == NULL || g_variant_get_string(variant, NULL) == NULL || g_variant_get_string(variant, NULL)[0] == '\0' || no_name_in_lang) { - finalstring = _("Switch User..."); - set_ellipsize = FALSE; - } + result = g_dbus_proxy_call_finish(self->service_proxy, res, &error); - if (finalstring == NULL) { - const gchar * username = g_variant_get_string(variant, NULL); - GtkStyle * style = gtk_widget_get_style(GTK_WIDGET(gmi)); + if (error != NULL) { + g_warning ("unable to complete real name dbus query"); + g_error_free (error); + return; + } + + const gchar* username = NULL; + g_variant_get (result, "(s)", &username); + indicator_session_update_users_label (self, username); + return; +} - PangoLayout * layout = pango_layout_new(gtk_widget_get_pango_context(GTK_WIDGET(gmi))); - pango_layout_set_text(layout, username, -1); - pango_layout_set_font_description(layout, style->font_desc); +static void +user_menu_visibility_get_cb (GObject* obj, GAsyncResult* res, gpointer user_data) +{ + IndicatorSession * self = INDICATOR_SESSION(user_data); + GError * error = NULL; + GVariant * result; - gint width; - pango_layout_get_pixel_size(layout, &width, NULL); - g_object_unref(layout); - g_debug("Username width %dpx", width); + result = g_dbus_proxy_call_finish(self->service_proxy, res, &error); - gint point = pango_font_description_get_size(style->font_desc); - g_debug("Font size %f pt", (gfloat)point / PANGO_SCALE); + if (error != NULL) { + g_warning ("unable to complete real name dbus query"); + g_error_free (error); + return; + } + gboolean update; + g_variant_get (result, "(b)", &update); + + // If it is what we had before no need to do anything... + if (self->show_users_entry == update){ + return; + } + //Otherwise + self->show_users_entry = update; + + if (self->show_users_entry == TRUE){ + g_signal_emit_by_name ((gpointer)self, + "entry-added", + &self->users); + } + else{ + g_signal_emit_by_name ((gpointer)self, + "entry-removed", + &self->users); + } +} - gdouble dpi = gdk_screen_get_resolution(gdk_screen_get_default()); - g_debug("Screen DPI %f", dpi); +/* Receives all signals from the service, routed to the appropriate functions */ +static void +receive_signal (GDBusProxy * proxy, + gchar * sender_name, + gchar * signal_name, + GVariant * parameters, + gpointer user_data) +{ + IndicatorSession * self = INDICATOR_SESSION(user_data); - gdouble pixels_per_em = ((point * dpi) / 72.0f) / PANGO_SCALE; - gdouble ems = width / pixels_per_em; - g_debug("Username width %fem", ems); + if (g_strcmp0(signal_name, "UserRealNameUpdated") == 0) { + const gchar* username = NULL; + g_variant_get (parameters, "(s)", &username); + indicator_session_update_users_label (self, username); + } + else if (g_strcmp0(signal_name, "UserMenuIsVisible") == 0) { + gboolean update; + g_variant_get (parameters, "(b)", &update); + + // If it is what we had before no need to do anything... + if (self->show_users_entry == update){ + return; + } + + //Otherwise + self->show_users_entry = update; + + if (self->show_users_entry == TRUE){ + g_signal_emit_by_name ((gpointer)self, + "entry-added", + &self->users); + + } + else{ + g_signal_emit_by_name ((gpointer)self, + "entry-removed", + &self->users); + } + } + else if (g_strcmp0(signal_name, "RebootRequired") == 0) { + // TODO waiting on design to give me a name. + self->devices.image = indicator_image_helper ("system-devices-alert-panel"); + } +} - /* TODO: We need some way to remove the elipsis from appearing - twice in the label. Not sure how to do that yet. */ - finalstring = g_strdup_printf(_("Switch From %s..."), username); - if (ems >= 20.0f) { - set_ellipsize = TRUE; - } else { - set_ellipsize = FALSE; - } - } - gtk_menu_item_set_label(gmi, finalstring); - GtkLabel * label = GTK_LABEL(gtk_bin_get_child(GTK_BIN(gmi))); - if (label != NULL) { - if (set_ellipsize) { - gtk_label_set_ellipsize(label, PANGO_ELLIPSIZE_END); - } else { - gtk_label_set_ellipsize(label, PANGO_ELLIPSIZE_NONE); - } - } +static void +switch_property_change (DbusmenuMenuitem * item, + const gchar * property, + GVariant * variant, + gpointer user_data) +{ + if (g_strcmp0 (property, MENU_SWITCH_USER) != 0) { + return; + } + + GtkMenuItem * gmi = dbusmenu_gtkclient_menuitem_get(DBUSMENU_GTKCLIENT(user_data), item); + gchar * finalstring = NULL; + gboolean set_ellipsize = FALSE; + gboolean no_name_in_lang = FALSE; + + const gchar * translate = C_("session_menu:switchfrom", "1"); + if (g_strcmp0(translate, "1") != 0) { + no_name_in_lang = TRUE; + } + + if (variant == NULL || g_variant_get_string(variant, NULL) == NULL || + g_variant_get_string(variant, NULL)[0] == '\0' || no_name_in_lang) { + finalstring = _("Switch User..."); + set_ellipsize = FALSE; + } + + if (finalstring == NULL) { + const gchar * username = g_variant_get_string(variant, NULL); + GtkStyle * style = gtk_widget_get_style(GTK_WIDGET(gmi)); + + PangoLayout * layout = pango_layout_new(gtk_widget_get_pango_context(GTK_WIDGET(gmi))); + pango_layout_set_text (layout, username, -1); + pango_layout_set_font_description(layout, style->font_desc); + + gint width; + pango_layout_get_pixel_size(layout, &width, NULL); + g_object_unref(layout); + g_debug("Username width %dpx", width); + + gint point = pango_font_description_get_size(style->font_desc); + g_debug("Font size %f pt", (gfloat)point / PANGO_SCALE); + + gdouble dpi = gdk_screen_get_resolution(gdk_screen_get_default()); + g_debug("Screen DPI %f", dpi); + + gdouble pixels_per_em = ((point * dpi) / 72.0f) / PANGO_SCALE; + gdouble ems = width / pixels_per_em; + g_debug("Username width %fem", ems); + + finalstring = g_strdup_printf(_("Switch From %s..."), username); + if (ems >= 20.0f) { + set_ellipsize = TRUE; + } else { + set_ellipsize = FALSE; + } + + } + gtk_menu_item_set_label(gmi, finalstring); + + GtkLabel * label = GTK_LABEL(gtk_bin_get_child(GTK_BIN(gmi))); + if (label != NULL) { + if (set_ellipsize) { + gtk_label_set_ellipsize(label, PANGO_ELLIPSIZE_END); + } else { + gtk_label_set_ellipsize(label, PANGO_ELLIPSIZE_NONE); + } + } return; } static const gchar * dbusmenu_item_data = "dbusmenu-item"; -/* IF the label or icon changes we need to grab that and update - the menu item */ static void -restart_property_change (DbusmenuMenuitem * item, const gchar * property, GVariant * variant, gpointer user_data) +restart_property_change (DbusmenuMenuitem * item, + const gchar * property, + GVariant * variant, + gpointer user_data) { DbusmenuGtkClient * client = DBUSMENU_GTKCLIENT(user_data); GtkMenuItem * gmi = dbusmenu_gtkclient_menuitem_get(client, item); @@ -482,14 +601,14 @@ restart_property_change (DbusmenuMenuitem * item, const gchar * property, GVaria } g_object_unref(G_OBJECT(gicon)); } - return; } -/* Builds the restart item which is a more traditional GTK image - menu item that puts the graphic into the gutter. */ static gboolean -build_restart_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data) +build_restart_item (DbusmenuMenuitem * newitem, + DbusmenuMenuitem * parent, + DbusmenuClient * client, + gpointer user_data) { GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_image_menu_item_new()); if (gmi == NULL) { @@ -500,7 +619,6 @@ build_restart_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(restart_property_change), client); - /* Grab the inital variants and put them into the item */ GVariant * variant; variant = dbusmenu_menuitem_property_get_variant(newitem, RESTART_ITEM_LABEL); if (variant != NULL) { @@ -515,36 +633,63 @@ build_restart_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm return TRUE; } - -/* Callback for when the style changes so we can reevaluate the - size of the user name with the potentially new font. */ static void -switch_style_set (GtkWidget * widget, GtkStyle * prev_style, gpointer user_data) +switch_style_set (GtkWidget * widget, + GtkStyle * prev_style, + gpointer user_data) { DbusmenuGtkClient * client = DBUSMENU_GTKCLIENT(user_data); - DbusmenuMenuitem * mi = DBUSMENU_MENUITEM(g_object_get_data(G_OBJECT(widget), dbusmenu_item_data)); + DbusmenuMenuitem * mi = DBUSMENU_MENUITEM(g_object_get_data(G_OBJECT(widget), + dbusmenu_item_data)); - switch_property_change(mi, MENU_SWITCH_USER, dbusmenu_menuitem_property_get_variant(mi, MENU_SWITCH_USER), client); + switch_property_change (mi, + MENU_SWITCH_USER, + dbusmenu_menuitem_property_get_variant(mi, MENU_SWITCH_USER), + client); return; } -/* This function checks to see if the user name is short enough - to not need ellipsing itself, or if, it will get ellipsed by - the standard label processor. */ static gboolean -build_menu_switch (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data) +build_menu_switch (DbusmenuMenuitem * newitem, + DbusmenuMenuitem * parent, + DbusmenuClient * client, + gpointer user_data) { GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_menu_item_new()); if (gmi == NULL) { return FALSE; } - g_object_set_data(G_OBJECT(gmi), dbusmenu_item_data, newitem); + + g_object_set_data(G_OBJECT(gmi), dbusmenu_item_data, newitem); dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent); - g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(switch_property_change), client); - g_signal_connect(G_OBJECT(gmi), "style-set", G_CALLBACK(switch_style_set), client); - switch_property_change(newitem, MENU_SWITCH_USER, dbusmenu_menuitem_property_get_variant(newitem, MENU_SWITCH_USER), client); + g_signal_connect (G_OBJECT(newitem), + DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, + G_CALLBACK(switch_property_change), + client); + g_signal_connect (G_OBJECT(gmi), + "style-set", + G_CALLBACK(switch_style_set), + client); + + switch_property_change (newitem, + MENU_SWITCH_USER, + dbusmenu_menuitem_property_get_variant(newitem, MENU_SWITCH_USER), client); + + return TRUE; +} - return TRUE; +static void +indicator_session_update_users_label (IndicatorSession* self, + const gchar* name) +{ + g_debug ("update users label"); + + if (name == NULL){ + gtk_widget_hide(GTK_WIDGET(self->users.label)); + return; + } + gtk_label_set_text (self->users.label, g_strdup(name)); + gtk_widget_show(GTK_WIDGET(self->users.label)); } diff --git a/src/lock-helper.c b/src/lock-helper.c index 9b15070..4c91aa5 100644 --- a/src/lock-helper.c +++ b/src/lock-helper.c @@ -20,12 +20,12 @@ with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <glib/gi18n.h> -#include <gconf/gconf-client.h> +#include <gio/gio.h> #include <dbus/dbus-glib.h> #include "lock-helper.h" -#define GCONF_DIR "/apps/gnome-screensaver" -#define GCONF_KEY GCONF_DIR "/lock_enabled" +#define SCREENSAVER_SCHEMA "org.gnome.desktop.screensaver" +#define SCREENSAVER_LOCK_ENABLED_KEY "lock-enabled" static DBusGProxy * gss_proxy = NULL; static GMainLoop * gss_mainloop = NULL; @@ -34,7 +34,7 @@ static DBusGProxyCall * cookie_call = NULL; static gboolean is_guest = FALSE; -static GConfClient * gconf_client = NULL; +static GSettings * settings = NULL; void build_gss_proxy (void); @@ -131,11 +131,11 @@ will_lock_screen (void) return FALSE; } - if (gconf_client == NULL) { - gconf_client = gconf_client_get_default(); + if (settings == NULL) { + settings = g_settings_new (SCREENSAVER_SCHEMA); } - return gconf_client_get_bool (gconf_client, GCONF_KEY, NULL); + return g_settings_get_boolean (settings, SCREENSAVER_LOCK_ENABLED_KEY); } /* When the screensave go active, if we've got a mainloop @@ -150,11 +150,22 @@ gss_active_changed (DBusGProxy * proxy, gboolean active, gpointer data) return; } +static gboolean +get_greeter_mode (void) +{ + const gchar *var; + var = g_getenv("INDICATOR_GREETER_MODE"); + return (g_strcmp0(var, "1") == 0); +} + /* Build the gss proxy and set up it's signals */ void build_gss_proxy (void) { if (gss_proxy == NULL) { + if (get_greeter_mode ()) + return; /* Don't start/lock the screensaver from the login screen */ + DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); g_return_if_fail(session_bus != NULL); diff --git a/src/consolekit-manager.xml b/src/org.freedesktop.ConsoleKit.Manager.xml index f903b55..f903b55 100644 --- a/src/consolekit-manager.xml +++ b/src/org.freedesktop.ConsoleKit.Manager.xml diff --git a/src/org.freedesktop.ConsoleKit.Seat.xml b/src/org.freedesktop.ConsoleKit.Seat.xml new file mode 100644 index 0000000..d95990b --- /dev/null +++ b/src/org.freedesktop.ConsoleKit.Seat.xml @@ -0,0 +1,164 @@ +<?xml version="1.0" encoding="UTF-8"?> +<node xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd"> + + <interface name="org.freedesktop.ConsoleKit.Seat"> + <doc:doc> + <doc:description> + <doc:para>A seat is a collection of sessions and a set of hardware (usually at +least a keyboard and mouse). Only one session may be active on a +seat at a time.</doc:para> + </doc:description> + </doc:doc> + + <method name="GetId"> + <arg name="sid" direction="out" type="o"> + <doc:doc> + <doc:summary>Seat ID</doc:summary> + </doc:doc> + </arg> + <doc:doc> + <doc:description> + <doc:para>Returns the ID for Seat.</doc:para> + </doc:description> + </doc:doc> + </method> + + <method name="GetSessions"> + <arg name="sessions" direction="out" type="ao"> + <doc:doc> + <doc:summary>an array of Session IDs</doc:summary> + </doc:doc> + </arg> + <doc:doc> + <doc:description> + <doc:para>This gets a list of all the <doc:ref type="interface" to="Session">Sessions</doc:ref> + that are currently attached to this seat.</doc:para> + <doc:para>Each Session ID is an D-Bus object path for the object that implements the + <doc:ref type="interface" to="Session">Session</doc:ref> interface.</doc:para> + </doc:description> + </doc:doc> + </method> + + <method name="GetDevices"> + <arg name="devices" direction="out" type="a(ss)"> + <doc:doc> + <doc:summary>an array of devices</doc:summary> + </doc:doc> + </arg> + <doc:doc> + <doc:description> + <doc:para>This gets a list of all the devices + that are currently associated with this seat.</doc:para> + <doc:para>Each device is an D-Bus structure that represents + the device type and the device id. + </doc:para> + </doc:description> + </doc:doc> + </method> + + <method name="GetActiveSession"> + <arg name="ssid" direction="out" type="o"> + <doc:doc> + <doc:summary>Session ID</doc:summary> + </doc:doc> + </arg> + <doc:doc> + <doc:description> + <doc:para>Gets the Session ID that is currently active on this Seat.</doc:para> + <doc:para>Returns NULL if there is no active session.</doc:para> + </doc:description> + </doc:doc> + </method> + + <method name="CanActivateSessions"> + <arg name="can_activate" direction="out" type="b"> + <doc:doc> + <doc:summary>TRUE if seat supports session activation</doc:summary> + </doc:doc> + </arg> + <doc:doc> + <doc:description><doc:para>Used to determine whether the seat supports session activation.</doc:para> + </doc:description> + </doc:doc> + </method> + + <method name="ActivateSession"> + <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> + <arg name="ssid" direction="in" type="o"> + <doc:doc> + <doc:summary>Session ID</doc:summary> + </doc:doc> + </arg> + <doc:doc> + <doc:description> + <doc:para>Attempt to activate the specified session. In most + cases, if successful, this will cause the session to + become visible and take control of the hardware that is + associated with this seat.</doc:para> + </doc:description> + <doc:seealso><doc:ref type="method" to="Session.Activate">Activate()</doc:ref></doc:seealso> + </doc:doc> + </method> + + <signal name="ActiveSessionChanged"> + <arg name="ssid" type="o"> + <doc:doc> + <doc:summary>Session ID</doc:summary> + </doc:doc> + </arg> + <doc:doc> + <doc:description> + <doc:para>Emitted when the active session has changed.</doc:para> + </doc:description> + </doc:doc> + </signal> + <signal name="SessionAdded"> + <arg name="ssid" type="o"> + <doc:doc> + <doc:summary>Session ID</doc:summary> + </doc:doc> + </arg> + <doc:doc> + <doc:description> + <doc:para>Emitted when a session has been added to the seat.</doc:para> + </doc:description> + </doc:doc> + </signal> + <signal name="SessionRemoved"> + <arg name="ssid" type="o"> + <doc:doc> + <doc:summary>Session ID</doc:summary> + </doc:doc> + </arg> + <doc:doc> + <doc:description> + <doc:para>Emitted when a session has been removed from the seat.</doc:para> + </doc:description> + </doc:doc> + </signal> + <signal name="DeviceAdded"> + <arg name="device" type="(ss)"> + <doc:doc> + <doc:summary>Device structure</doc:summary> + </doc:doc> + </arg> + <doc:doc> + <doc:description> + <doc:para>Emitted when a device has been associated with the seat.</doc:para> + </doc:description> + </doc:doc> + </signal> + <signal name="DeviceRemoved"> + <arg name="device" type="(ss)"> + <doc:doc> + <doc:summary>Device structure</doc:summary> + </doc:doc> + </arg> + <doc:doc> + <doc:description> + <doc:para>Emitted when a device has been dissociated from the seat.</doc:para> + </doc:description> + </doc:doc> + </signal> + </interface> +</node> diff --git a/src/consolekit-session.xml b/src/org.freedesktop.ConsoleKit.Session.xml index b6e1cdb..b6e1cdb 100644 --- a/src/consolekit-session.xml +++ b/src/org.freedesktop.ConsoleKit.Session.xml diff --git a/src/sane-rules.h b/src/sane-rules.h new file mode 100644 index 0000000..0b72e52 --- /dev/null +++ b/src/sane-rules.h @@ -0,0 +1,778 @@ +void populate_scsi_scanners (GHashTable* scanners) +{ + GList* epson = NULL; + epson = g_list_append (epson, g_strdup ("GT-9700")); + epson = g_list_append (epson, g_strdup ("GT-9800")); + epson = g_list_append (epson, g_strdup ("Perfection1200")); + epson = g_list_append (epson, g_strdup ("Perfection636")); + epson = g_list_append (epson, g_strdup ("SCANNER GT-7000")); + g_hash_table_insert (scanners, + g_strdup("EPSON"), + epson); + + + GList* hp = NULL; + hp = g_list_append (hp, g_strdup ("C1130A")); + hp = g_list_append (hp, g_strdup ("C1750A")); + hp = g_list_append (hp, g_strdup ("C1790A")); + hp = g_list_append (hp, g_strdup ("C2500A")); + hp = g_list_append (hp, g_strdup ("C2520A")); + hp = g_list_append (hp, g_strdup ("C5110A")); + hp = g_list_append (hp, g_strdup ("C6270A")); + hp = g_list_append (hp, g_strdup ("C7670A")); + g_hash_table_insert (scanners, + g_strdup("HP"), + hp); +} + + + +void populate_usb_scanners (GHashTable* scanners) +{ + GList* hp = NULL; + + hp = g_list_append (hp, g_strdup ("0101")); + hp = g_list_append (hp, g_strdup ("0105")); + hp = g_list_append (hp, g_strdup ("0201")); + hp = g_list_append (hp, g_strdup ("0205")); + hp = g_list_append (hp, g_strdup ("0305")); + hp = g_list_append (hp, g_strdup ("0401")); + hp = g_list_append (hp, g_strdup ("0405")); + hp = g_list_append (hp, g_strdup ("0505")); + hp = g_list_append (hp, g_strdup ("0601")); + hp = g_list_append (hp, g_strdup ("0605")); + hp = g_list_append (hp, g_strdup ("0701")); + hp = g_list_append (hp, g_strdup ("0705")); + hp = g_list_append (hp, g_strdup ("0801")); + hp = g_list_append (hp, g_strdup ("0805")); + hp = g_list_append (hp, g_strdup ("0901")); + hp = g_list_append (hp, g_strdup ("0a01")); + hp = g_list_append (hp, g_strdup ("0b01")); + hp = g_list_append (hp, g_strdup ("1005")); + hp = g_list_append (hp, g_strdup ("1105")); + hp = g_list_append (hp, g_strdup ("1205")); + hp = g_list_append (hp, g_strdup ("1305")); + hp = g_list_append (hp, g_strdup ("1405")); + hp = g_list_append (hp, g_strdup ("1705")); + hp = g_list_append (hp, g_strdup ("1805")); + hp = g_list_append (hp, g_strdup ("2005")); + hp = g_list_append (hp, g_strdup ("2205")); + hp = g_list_append (hp, g_strdup ("2305")); + hp = g_list_append (hp, g_strdup ("2405")); + hp = g_list_append (hp, g_strdup ("2605")); + hp = g_list_append (hp, g_strdup ("2805")); + hp = g_list_append (hp, g_strdup ("3805")); + hp = g_list_append (hp, g_strdup ("3905")); + hp = g_list_append (hp, g_strdup ("3B17")); + hp = g_list_append (hp, g_strdup ("4105")); + hp = g_list_append (hp, g_strdup ("4205")); + hp = g_list_append (hp, g_strdup ("4305")); + hp = g_list_append (hp, g_strdup ("4505")); + hp = g_list_append (hp, g_strdup ("4605")); + hp = g_list_append (hp, g_strdup ("5617")); + hp = g_list_append (hp, g_strdup ("5717")); + + g_hash_table_insert (scanners, + g_strdup("03f0"), + hp); + + GList* mustek_2 = NULL; + mustek_2 = g_list_append (mustek_2, g_strdup ("1000")); + mustek_2 = g_list_append (mustek_2, g_strdup ("1001")); + g_hash_table_insert (scanners, + g_strdup("0400"), + mustek_2); + + GList* kodak = NULL; + kodak = g_list_append (kodak, g_strdup ("6001")); + kodak = g_list_append (kodak, g_strdup ("6002")); + kodak = g_list_append (kodak, g_strdup ("6003")); + kodak = g_list_append (kodak, g_strdup ("6004")); + kodak = g_list_append (kodak, g_strdup ("6005")); + g_hash_table_insert (scanners, + g_strdup("040a"), + kodak); + + GList* creative = NULL; + + creative = g_list_append (creative, g_strdup ("4007")); + + g_hash_table_insert (scanners, + g_strdup("041e"), + creative); + + GList* lexmark = NULL; + + lexmark = g_list_append (lexmark, g_strdup("002d")); + lexmark = g_list_append (lexmark, g_strdup("0060")); + lexmark = g_list_append (lexmark, g_strdup("007c")); + lexmark = g_list_append (lexmark, g_strdup("007d")); + + g_hash_table_insert (scanners, + g_strdup("043d"), + lexmark); + + + GList* genius = NULL; + genius = g_list_append (genius, g_strdup("2004")); + genius = g_list_append (genius, g_strdup("2007")); + genius = g_list_append (genius, g_strdup("2008")); + genius = g_list_append (genius, g_strdup("2009")); + genius = g_list_append (genius, g_strdup("2011")); + genius = g_list_append (genius, g_strdup("2013")); + genius = g_list_append (genius, g_strdup("2014")); + genius = g_list_append (genius, g_strdup("2015")); + genius = g_list_append (genius, g_strdup("2016")); + genius = g_list_append (genius, g_strdup("2017")); + genius = g_list_append (genius, g_strdup("201a")); + genius = g_list_append (genius, g_strdup("201b")); + genius = g_list_append (genius, g_strdup("201d")); + genius = g_list_append (genius, g_strdup("201e")); + genius = g_list_append (genius, g_strdup("201f")); + genius = g_list_append (genius, g_strdup("20c1")); + g_hash_table_insert (scanners, + g_strdup("0458"), + genius); + + GList* medion = NULL; + medion = g_list_append (medion, g_strdup("0377")); + g_hash_table_insert (scanners, + g_strdup("0461"), + medion); + + GList* trust = NULL; + trust = g_list_append (trust, g_strdup("1000")); + trust = g_list_append (trust, g_strdup("1002")); + g_hash_table_insert (scanners, + g_strdup("047b"), + trust); + + GList* kyocera = NULL; + kyocera = g_list_append (kyocera, g_strdup("0335")); + g_hash_table_insert (scanners, + g_strdup("0482"), + kyocera); + + GList* compaq = NULL; + compaq = g_list_append (compaq, g_strdup("001a")); + g_hash_table_insert (scanners, + g_strdup("049f"), + compaq); + GList* benq = NULL; + benq = g_list_append (benq, g_strdup("1a20")); + benq = g_list_append (benq, g_strdup("1a2a")); + benq = g_list_append (benq, g_strdup("2022")); + benq = g_list_append (benq, g_strdup("2040")); + benq = g_list_append (benq, g_strdup("2060")); + benq = g_list_append (benq, g_strdup("207e")); + benq = g_list_append (benq, g_strdup("20b0")); + benq = g_list_append (benq, g_strdup("20be")); + benq = g_list_append (benq, g_strdup("20c0")); + benq = g_list_append (benq, g_strdup("20de")); + benq = g_list_append (benq, g_strdup("20f8")); + benq = g_list_append (benq, g_strdup("20fc")); + benq = g_list_append (benq, g_strdup("20fe")); + benq = g_list_append (benq, g_strdup("2137")); + benq = g_list_append (benq, g_strdup("2211")); + g_hash_table_insert (scanners, + g_strdup("04a5"), + benq); + + GList* visioneer = NULL; + visioneer = g_list_append (visioneer, g_strdup("0229")); + visioneer = g_list_append (visioneer, g_strdup("0390")); + visioneer = g_list_append (visioneer, g_strdup("0420")); + visioneer = g_list_append (visioneer, g_strdup("0421")); + visioneer = g_list_append (visioneer, g_strdup("0422")); + visioneer = g_list_append (visioneer, g_strdup("0423")); + visioneer = g_list_append (visioneer, g_strdup("0424")); + visioneer = g_list_append (visioneer, g_strdup("0426")); + visioneer = g_list_append (visioneer, g_strdup("0427")); + visioneer = g_list_append (visioneer, g_strdup("0444")); + visioneer = g_list_append (visioneer, g_strdup("0446")); + visioneer = g_list_append (visioneer, g_strdup("0447")); + visioneer = g_list_append (visioneer, g_strdup("0448")); + visioneer = g_list_append (visioneer, g_strdup("0449")); + visioneer = g_list_append (visioneer, g_strdup("044c")); + visioneer = g_list_append (visioneer, g_strdup("0474")); + visioneer = g_list_append (visioneer, g_strdup("0475")); + visioneer = g_list_append (visioneer, g_strdup("0477")); + visioneer = g_list_append (visioneer, g_strdup("0478")); + visioneer = g_list_append (visioneer, g_strdup("0479")); + visioneer = g_list_append (visioneer, g_strdup("047a")); + visioneer = g_list_append (visioneer, g_strdup("047b")); + visioneer = g_list_append (visioneer, g_strdup("047c")); + visioneer = g_list_append (visioneer, g_strdup("048c")); + visioneer = g_list_append (visioneer, g_strdup("048d")); + visioneer = g_list_append (visioneer, g_strdup("048e")); + visioneer = g_list_append (visioneer, g_strdup("048f")); + visioneer = g_list_append (visioneer, g_strdup("0490")); + visioneer = g_list_append (visioneer, g_strdup("0491")); + visioneer = g_list_append (visioneer, g_strdup("0492")); + visioneer = g_list_append (visioneer, g_strdup("0493")); + visioneer = g_list_append (visioneer, g_strdup("0494")); + visioneer = g_list_append (visioneer, g_strdup("0495")); + visioneer = g_list_append (visioneer, g_strdup("0497")); + visioneer = g_list_append (visioneer, g_strdup("0498")); + visioneer = g_list_append (visioneer, g_strdup("0499")); + visioneer = g_list_append (visioneer, g_strdup("049a")); + visioneer = g_list_append (visioneer, g_strdup("049b")); + visioneer = g_list_append (visioneer, g_strdup("049c")); + visioneer = g_list_append (visioneer, g_strdup("049d")); + visioneer = g_list_append (visioneer, g_strdup("04a7")); + visioneer = g_list_append (visioneer, g_strdup("04ac")); + g_hash_table_insert (scanners, + g_strdup("04a7"), + visioneer); + GList* canon = NULL; + canon = g_list_append (canon, g_strdup("1601")); + canon = g_list_append (canon, g_strdup("1602")); + canon = g_list_append (canon, g_strdup("1603")); + canon = g_list_append (canon, g_strdup("1604")); + canon = g_list_append (canon, g_strdup("1606")); + canon = g_list_append (canon, g_strdup("1607")); + canon = g_list_append (canon, g_strdup("1608")); + canon = g_list_append (canon, g_strdup("1609")); + canon = g_list_append (canon, g_strdup("160a")); + canon = g_list_append (canon, g_strdup("160b")); + canon = g_list_append (canon, g_strdup("1706")); + canon = g_list_append (canon, g_strdup("1707")); + canon = g_list_append (canon, g_strdup("1708")); + canon = g_list_append (canon, g_strdup("1709")); + canon = g_list_append (canon, g_strdup("170a")); + canon = g_list_append (canon, g_strdup("170b")); + canon = g_list_append (canon, g_strdup("170c")); + canon = g_list_append (canon, g_strdup("170d")); + canon = g_list_append (canon, g_strdup("170e")); + canon = g_list_append (canon, g_strdup("1712")); + canon = g_list_append (canon, g_strdup("1713")); + canon = g_list_append (canon, g_strdup("1714")); + canon = g_list_append (canon, g_strdup("1715")); + canon = g_list_append (canon, g_strdup("1716")); + canon = g_list_append (canon, g_strdup("1717")); + canon = g_list_append (canon, g_strdup("1718")); + canon = g_list_append (canon, g_strdup("1719")); + canon = g_list_append (canon, g_strdup("171a")); + canon = g_list_append (canon, g_strdup("171b")); + canon = g_list_append (canon, g_strdup("171c")); + canon = g_list_append (canon, g_strdup("1721")); + canon = g_list_append (canon, g_strdup("1722")); + canon = g_list_append (canon, g_strdup("1723")); + canon = g_list_append (canon, g_strdup("1724")); + canon = g_list_append (canon, g_strdup("1725")); + canon = g_list_append (canon, g_strdup("1726")); + canon = g_list_append (canon, g_strdup("1727")); + canon = g_list_append (canon, g_strdup("1728")); + canon = g_list_append (canon, g_strdup("1729")); + canon = g_list_append (canon, g_strdup("172b")); + canon = g_list_append (canon, g_strdup("172c")); + canon = g_list_append (canon, g_strdup("172d")); + canon = g_list_append (canon, g_strdup("172e")); + canon = g_list_append (canon, g_strdup("172f")); + canon = g_list_append (canon, g_strdup("1730")); + canon = g_list_append (canon, g_strdup("1731")); + canon = g_list_append (canon, g_strdup("1732")); + canon = g_list_append (canon, g_strdup("1733")); + canon = g_list_append (canon, g_strdup("1734")); + canon = g_list_append (canon, g_strdup("1735")); + canon = g_list_append (canon, g_strdup("1736")); + canon = g_list_append (canon, g_strdup("173a")); + canon = g_list_append (canon, g_strdup("173b")); + canon = g_list_append (canon, g_strdup("173c")); + canon = g_list_append (canon, g_strdup("173d")); + canon = g_list_append (canon, g_strdup("173e")); + canon = g_list_append (canon, g_strdup("173f")); + canon = g_list_append (canon, g_strdup("1740")); + canon = g_list_append (canon, g_strdup("1741")); + canon = g_list_append (canon, g_strdup("1742")); + canon = g_list_append (canon, g_strdup("1901")); + canon = g_list_append (canon, g_strdup("1904")); + canon = g_list_append (canon, g_strdup("1905")); + canon = g_list_append (canon, g_strdup("1909")); + canon = g_list_append (canon, g_strdup("190a")); + canon = g_list_append (canon, g_strdup("2204")); + canon = g_list_append (canon, g_strdup("2206")); + canon = g_list_append (canon, g_strdup("2207")); + canon = g_list_append (canon, g_strdup("2208")); + canon = g_list_append (canon, g_strdup("220d")); + canon = g_list_append (canon, g_strdup("220e")); + canon = g_list_append (canon, g_strdup("2213")); + canon = g_list_append (canon, g_strdup("221c")); + canon = g_list_append (canon, g_strdup("2220")); + canon = g_list_append (canon, g_strdup("2222")); + canon = g_list_append (canon, g_strdup("262f")); + canon = g_list_append (canon, g_strdup("2630")); + canon = g_list_append (canon, g_strdup("263c")); + canon = g_list_append (canon, g_strdup("263d")); + canon = g_list_append (canon, g_strdup("263e")); + canon = g_list_append (canon, g_strdup("263f")); + canon = g_list_append (canon, g_strdup("264c")); + canon = g_list_append (canon, g_strdup("264d")); + canon = g_list_append (canon, g_strdup("264e")); + canon = g_list_append (canon, g_strdup("264f")); + canon = g_list_append (canon, g_strdup("2659")); + canon = g_list_append (canon, g_strdup("265d")); + canon = g_list_append (canon, g_strdup("265e")); + canon = g_list_append (canon, g_strdup("265f")); + canon = g_list_append (canon, g_strdup("2660")); + canon = g_list_append (canon, g_strdup("2684")); + canon = g_list_append (canon, g_strdup("2686")); + canon = g_list_append (canon, g_strdup("26a3")); + canon = g_list_append (canon, g_strdup("26b0")); + canon = g_list_append (canon, g_strdup("26b4")); + canon = g_list_append (canon, g_strdup("26b5")); + canon = g_list_append (canon, g_strdup("26ec")); + canon = g_list_append (canon, g_strdup("26ed")); + canon = g_list_append (canon, g_strdup("26ee")); + g_hash_table_insert (scanners, + g_strdup("04a9"), + canon); + + GList* nikon = NULL; + nikon = g_list_append (nikon, g_strdup ("4000")); + nikon = g_list_append (nikon, g_strdup ("4001")); + nikon = g_list_append (nikon, g_strdup ("4002")); + g_hash_table_insert (scanners, + g_strdup("04b0"), + nikon); + + GList* epson = NULL; + + // for testing (its a printer not a scanner!) + //epson = g_list_append (epson, g_strdup ("0001")); + + epson = g_list_append (epson, g_strdup("0101")); + epson = g_list_append (epson, g_strdup("0103")); + epson = g_list_append (epson, g_strdup("0104")); + epson = g_list_append (epson, g_strdup("0105")); + epson = g_list_append (epson, g_strdup("0106")); + epson = g_list_append (epson, g_strdup("0107")); + epson = g_list_append (epson, g_strdup("0109")); + epson = g_list_append (epson, g_strdup("010a")); + epson = g_list_append (epson, g_strdup("010b")); + epson = g_list_append (epson, g_strdup("010c")); + epson = g_list_append (epson, g_strdup("010e")); + epson = g_list_append (epson, g_strdup("010f")); + epson = g_list_append (epson, g_strdup("0110")); + epson = g_list_append (epson, g_strdup("0112")); + epson = g_list_append (epson, g_strdup("0114")); + epson = g_list_append (epson, g_strdup("011b")); + epson = g_list_append (epson, g_strdup("011c")); + epson = g_list_append (epson, g_strdup("011d")); + epson = g_list_append (epson, g_strdup("011e")); + epson = g_list_append (epson, g_strdup("011f")); + epson = g_list_append (epson, g_strdup("0120")); + epson = g_list_append (epson, g_strdup("0121")); + epson = g_list_append (epson, g_strdup("0122")); + epson = g_list_append (epson, g_strdup("0126")); + epson = g_list_append (epson, g_strdup("0128")); + epson = g_list_append (epson, g_strdup("0129")); + epson = g_list_append (epson, g_strdup("012a")); + epson = g_list_append (epson, g_strdup("012b")); + epson = g_list_append (epson, g_strdup("012c")); + epson = g_list_append (epson, g_strdup("0135")); + epson = g_list_append (epson, g_strdup("0801")); + epson = g_list_append (epson, g_strdup("0802")); + epson = g_list_append (epson, g_strdup("0805")); + epson = g_list_append (epson, g_strdup("0806")); + epson = g_list_append (epson, g_strdup("0807")); + epson = g_list_append (epson, g_strdup("0808")); + epson = g_list_append (epson, g_strdup("080c")); + epson = g_list_append (epson, g_strdup("080d")); + epson = g_list_append (epson, g_strdup("080e")); + epson = g_list_append (epson, g_strdup("080f")); + epson = g_list_append (epson, g_strdup("0810")); + epson = g_list_append (epson, g_strdup("0811")); + epson = g_list_append (epson, g_strdup("0813")); + epson = g_list_append (epson, g_strdup("0814")); + epson = g_list_append (epson, g_strdup("0815")); + epson = g_list_append (epson, g_strdup("0817")); + epson = g_list_append (epson, g_strdup("0818")); + epson = g_list_append (epson, g_strdup("0819")); + epson = g_list_append (epson, g_strdup("081a")); + epson = g_list_append (epson, g_strdup("081c")); + epson = g_list_append (epson, g_strdup("081d")); + epson = g_list_append (epson, g_strdup("081f")); + epson = g_list_append (epson, g_strdup("0820")); + epson = g_list_append (epson, g_strdup("0827")); + epson = g_list_append (epson, g_strdup("0828")); + epson = g_list_append (epson, g_strdup("0829")); + epson = g_list_append (epson, g_strdup("082a")); + epson = g_list_append (epson, g_strdup("082b")); + epson = g_list_append (epson, g_strdup("082e")); + epson = g_list_append (epson, g_strdup("082f")); + epson = g_list_append (epson, g_strdup("0830")); + epson = g_list_append (epson, g_strdup("0833")); + epson = g_list_append (epson, g_strdup("0834")); + epson = g_list_append (epson, g_strdup("0835")); + epson = g_list_append (epson, g_strdup("0836")); + epson = g_list_append (epson, g_strdup("0837")); + epson = g_list_append (epson, g_strdup("0838")); + epson = g_list_append (epson, g_strdup("0839")); + epson = g_list_append (epson, g_strdup("083a")); + epson = g_list_append (epson, g_strdup("083c")); + epson = g_list_append (epson, g_strdup("0841")); + epson = g_list_append (epson, g_strdup("0843")); + epson = g_list_append (epson, g_strdup("0844")); + epson = g_list_append (epson, g_strdup("0846")); + epson = g_list_append (epson, g_strdup("0847")); + epson = g_list_append (epson, g_strdup("0848")); + epson = g_list_append (epson, g_strdup("0849")); + epson = g_list_append (epson, g_strdup("084a")); + epson = g_list_append (epson, g_strdup("084c")); + epson = g_list_append (epson, g_strdup("084d")); + epson = g_list_append (epson, g_strdup("084f")); + epson = g_list_append (epson, g_strdup("0851")); + epson = g_list_append (epson, g_strdup("0854")); + epson = g_list_append (epson, g_strdup("0856")); + g_hash_table_insert (scanners, + g_strdup("04b8"), + epson); + + GList* fujitsu = NULL; + fujitsu = g_list_append (fujitsu, g_strdup ("1029")); + fujitsu = g_list_append (fujitsu, g_strdup ("1041")); + fujitsu = g_list_append (fujitsu, g_strdup ("1042")); + fujitsu = g_list_append (fujitsu, g_strdup ("1078")); + fujitsu = g_list_append (fujitsu, g_strdup ("1095")); + fujitsu = g_list_append (fujitsu, g_strdup ("1096")); + fujitsu = g_list_append (fujitsu, g_strdup ("1097")); + fujitsu = g_list_append (fujitsu, g_strdup ("10ad")); + fujitsu = g_list_append (fujitsu, g_strdup ("10ae")); + fujitsu = g_list_append (fujitsu, g_strdup ("10af")); + fujitsu = g_list_append (fujitsu, g_strdup ("10c7")); + fujitsu = g_list_append (fujitsu, g_strdup ("10cf")); + fujitsu = g_list_append (fujitsu, g_strdup ("10e0")); + fujitsu = g_list_append (fujitsu, g_strdup ("10e1")); + fujitsu = g_list_append (fujitsu, g_strdup ("10e2")); + fujitsu = g_list_append (fujitsu, g_strdup ("10e6")); + fujitsu = g_list_append (fujitsu, g_strdup ("10e7")); + fujitsu = g_list_append (fujitsu, g_strdup ("10ef")); + fujitsu = g_list_append (fujitsu, g_strdup ("10f2")); + fujitsu = g_list_append (fujitsu, g_strdup ("10fe")); + fujitsu = g_list_append (fujitsu, g_strdup ("1135")); + fujitsu = g_list_append (fujitsu, g_strdup ("114a")); + fujitsu = g_list_append (fujitsu, g_strdup ("114d")); + fujitsu = g_list_append (fujitsu, g_strdup ("114e")); + fujitsu = g_list_append (fujitsu, g_strdup ("114f")); + fujitsu = g_list_append (fujitsu, g_strdup ("1150")); + fujitsu = g_list_append (fujitsu, g_strdup ("1155")); + fujitsu = g_list_append (fujitsu, g_strdup ("1156")); + fujitsu = g_list_append (fujitsu, g_strdup ("116f")); + fujitsu = g_list_append (fujitsu, g_strdup ("1174")); + fujitsu = g_list_append (fujitsu, g_strdup ("1175")); + fujitsu = g_list_append (fujitsu, g_strdup ("1176")); + fujitsu = g_list_append (fujitsu, g_strdup ("1177")); + fujitsu = g_list_append (fujitsu, g_strdup ("1178")); + fujitsu = g_list_append (fujitsu, g_strdup ("117f")); + fujitsu = g_list_append (fujitsu, g_strdup ("119d")); + fujitsu = g_list_append (fujitsu, g_strdup ("119e")); + fujitsu = g_list_append (fujitsu, g_strdup ("119f")); + fujitsu = g_list_append (fujitsu, g_strdup ("11a0")); + fujitsu = g_list_append (fujitsu, g_strdup ("11a2")); + fujitsu = g_list_append (fujitsu, g_strdup ("11ed")); + fujitsu = g_list_append (fujitsu, g_strdup ("11ee")); + fujitsu = g_list_append (fujitsu, g_strdup ("11ef")); + fujitsu = g_list_append (fujitsu, g_strdup ("11f1")); + fujitsu = g_list_append (fujitsu, g_strdup ("11f2")); + fujitsu = g_list_append (fujitsu, g_strdup ("11f3")); + fujitsu = g_list_append (fujitsu, g_strdup ("11f4")); + fujitsu = g_list_append (fujitsu, g_strdup ("11fc")); + g_hash_table_insert (scanners, + g_strdup("04c5"), + fujitsu); + GList* konica = NULL; + konica = g_list_append (konica, g_strdup ("0722")); + g_hash_table_insert (scanners, + g_strdup("04c8"), + konica); + GList* panasonic = NULL; + panasonic = g_list_append (panasonic, g_strdup ("1000")); + panasonic = g_list_append (panasonic, g_strdup ("1001")); + panasonic = g_list_append (panasonic, g_strdup ("1006")); + panasonic = g_list_append (panasonic, g_strdup ("1007")); + panasonic = g_list_append (panasonic, g_strdup ("1009")); + panasonic = g_list_append (panasonic, g_strdup ("100a")); + panasonic = g_list_append (panasonic, g_strdup ("100f")); + panasonic = g_list_append (panasonic, g_strdup ("1010")); + g_hash_table_insert (scanners, + g_strdup("04da"), + panasonic); + + GList* samsung = NULL; + + samsung = g_list_append (samsung, g_strdup ("341b")); + samsung = g_list_append (samsung, g_strdup ("341f")); + samsung = g_list_append (samsung, g_strdup ("3426")); + samsung = g_list_append (samsung, g_strdup ("342a")); + samsung = g_list_append (samsung, g_strdup ("342b")); + samsung = g_list_append (samsung, g_strdup ("342c")); + samsung = g_list_append (samsung, g_strdup ("3433")); + samsung = g_list_append (samsung, g_strdup ("3434")); + samsung = g_list_append (samsung, g_strdup ("343c")); + samsung = g_list_append (samsung, g_strdup ("3434")); + g_hash_table_insert (scanners, + g_strdup("04e8"), + samsung); + + GList* pentax = NULL; + pentax = g_list_append (pentax, g_strdup ("2038")); + g_hash_table_insert (scanners, + g_strdup("04f9"), + pentax); + + GList* apitek = NULL; + apitek = g_list_append (apitek, g_strdup ("0202")); + g_hash_table_insert (scanners, + g_strdup("0553"), + apitek); + + GList* mustek = NULL; + mustek = g_list_append (mustek, g_strdup ("0001")); + mustek = g_list_append (mustek, g_strdup ("0002")); + mustek = g_list_append (mustek, g_strdup ("0006")); + mustek = g_list_append (mustek, g_strdup ("0008")); + mustek = g_list_append (mustek, g_strdup ("0010")); + mustek = g_list_append (mustek, g_strdup ("0210")); + mustek = g_list_append (mustek, g_strdup ("0218")); + mustek = g_list_append (mustek, g_strdup ("0219")); + mustek = g_list_append (mustek, g_strdup ("021a")); + mustek = g_list_append (mustek, g_strdup ("021b")); + mustek = g_list_append (mustek, g_strdup ("021c")); + mustek = g_list_append (mustek, g_strdup ("021d")); + mustek = g_list_append (mustek, g_strdup ("021e")); + mustek = g_list_append (mustek, g_strdup ("021f")); + mustek = g_list_append (mustek, g_strdup ("0409")); + g_hash_table_insert (scanners, + g_strdup("055f"), + mustek); + GList* artec = NULL; + artec = g_list_append (artec, g_strdup ("4002")); + artec = g_list_append (artec, g_strdup ("4003")); + artec = g_list_append (artec, g_strdup ("4004")); + artec = g_list_append (artec, g_strdup ("4005")); + artec = g_list_append (artec, g_strdup ("4006")); + artec = g_list_append (artec, g_strdup ("4007")); + artec = g_list_append (artec, g_strdup ("4009")); + artec = g_list_append (artec, g_strdup ("4010")); + artec = g_list_append (artec, g_strdup ("4011")); + g_hash_table_insert (scanners, + g_strdup("05d8"), + artec); + + GList* microtek = NULL; + microtek = g_list_append (microtek, g_strdup ("0099")); + microtek = g_list_append (microtek, g_strdup ("009a")); + microtek = g_list_append (microtek, g_strdup ("00a3")); + microtek = g_list_append (microtek, g_strdup ("00b6")); + microtek = g_list_append (microtek, g_strdup ("30cf")); + microtek = g_list_append (microtek, g_strdup ("30d4")); + microtek = g_list_append (microtek, g_strdup ("40b3")); + microtek = g_list_append (microtek, g_strdup ("40b8")); + microtek = g_list_append (microtek, g_strdup ("40ca")); + microtek = g_list_append (microtek, g_strdup ("40cb")); + microtek = g_list_append (microtek, g_strdup ("40dd")); + microtek = g_list_append (microtek, g_strdup ("40ff")); + microtek = g_list_append (microtek, g_strdup ("80a3")); + g_hash_table_insert (scanners, + g_strdup("05da"), + microtek); + + GList* avision = NULL; + avision = g_list_append (avision, g_strdup ("0268")); + avision = g_list_append (avision, g_strdup ("026a")); + avision = g_list_append (avision, g_strdup ("0a13")); + avision = g_list_append (avision, g_strdup ("0a15")); + avision = g_list_append (avision, g_strdup ("0a16")); + avision = g_list_append (avision, g_strdup ("0a18")); + avision = g_list_append (avision, g_strdup ("0a19")); + avision = g_list_append (avision, g_strdup ("0a23")); + avision = g_list_append (avision, g_strdup ("0a24")); + avision = g_list_append (avision, g_strdup ("0a25")); + avision = g_list_append (avision, g_strdup ("0a27")); + avision = g_list_append (avision, g_strdup ("0a2a")); + avision = g_list_append (avision, g_strdup ("0a2b")); + avision = g_list_append (avision, g_strdup ("0a2c")); + avision = g_list_append (avision, g_strdup ("0a2d")); + avision = g_list_append (avision, g_strdup ("0a2e")); + avision = g_list_append (avision, g_strdup ("0a2f")); + avision = g_list_append (avision, g_strdup ("0a33")); + avision = g_list_append (avision, g_strdup ("0a3a")); + avision = g_list_append (avision, g_strdup ("0a3c")); + avision = g_list_append (avision, g_strdup ("0a40")); + avision = g_list_append (avision, g_strdup ("0a41")); + avision = g_list_append (avision, g_strdup ("0a45")); + avision = g_list_append (avision, g_strdup ("0a4d")); + avision = g_list_append (avision, g_strdup ("0a4e")); + avision = g_list_append (avision, g_strdup ("0a4f")); + avision = g_list_append (avision, g_strdup ("0a5e")); + avision = g_list_append (avision, g_strdup ("0a61")); + avision = g_list_append (avision, g_strdup ("0a65")); + avision = g_list_append (avision, g_strdup ("0a66")); + avision = g_list_append (avision, g_strdup ("0a68")); + avision = g_list_append (avision, g_strdup ("0a82")); + avision = g_list_append (avision, g_strdup ("0a84")); + avision = g_list_append (avision, g_strdup ("0a93")); + avision = g_list_append (avision, g_strdup ("0a94")); + avision = g_list_append (avision, g_strdup ("0aa1")); + avision = g_list_append (avision, g_strdup ("1a35")); + g_hash_table_insert (scanners, + g_strdup("0638"), + avision); + GList* minolta = NULL; + minolta = g_list_append (minolta, g_strdup ("4004")); + minolta = g_list_append (minolta, g_strdup ("400d")); + minolta = g_list_append (minolta, g_strdup ("400e")); + g_hash_table_insert (scanners, + g_strdup("0686"), + minolta); + + GList* agfa = NULL; + agfa = g_list_append (agfa, g_strdup ("0001")); + agfa = g_list_append (agfa, g_strdup ("0002")); + agfa = g_list_append (agfa, g_strdup ("0100")); + agfa = g_list_append (agfa, g_strdup ("2061")); + agfa = g_list_append (agfa, g_strdup ("208d")); + agfa = g_list_append (agfa, g_strdup ("208f")); + agfa = g_list_append (agfa, g_strdup ("2091")); + agfa = g_list_append (agfa, g_strdup ("2093")); + agfa = g_list_append (agfa, g_strdup ("2095")); + agfa = g_list_append (agfa, g_strdup ("2097")); + agfa = g_list_append (agfa, g_strdup ("20fd")); + agfa = g_list_append (agfa, g_strdup ("20ff")); + g_hash_table_insert (scanners, + g_strdup("06bd"), + minolta); + + GList* umax_2 = NULL; + umax_2 = g_list_append (umax_2, g_strdup ("0020")); + g_hash_table_insert (scanners, + g_strdup("06dc"), + umax_2); + + GList* plustek = NULL; + + plustek = g_list_append (plustek, g_strdup ("0001")); + plustek = g_list_append (plustek, g_strdup ("0010")); + plustek = g_list_append (plustek, g_strdup ("0011")); + plustek = g_list_append (plustek, g_strdup ("0013")); + plustek = g_list_append (plustek, g_strdup ("0015")); + plustek = g_list_append (plustek, g_strdup ("0017")); + plustek = g_list_append (plustek, g_strdup ("0400")); + plustek = g_list_append (plustek, g_strdup ("0401")); + plustek = g_list_append (plustek, g_strdup ("0402")); + plustek = g_list_append (plustek, g_strdup ("0403")); + plustek = g_list_append (plustek, g_strdup ("040b")); + plustek = g_list_append (plustek, g_strdup ("040e")); + plustek = g_list_append (plustek, g_strdup ("0412")); + plustek = g_list_append (plustek, g_strdup ("0413")); + plustek = g_list_append (plustek, g_strdup ("0422")); + plustek = g_list_append (plustek, g_strdup ("0454")); + plustek = g_list_append (plustek, g_strdup ("045f")); + plustek = g_list_append (plustek, g_strdup ("0462")); + plustek = g_list_append (plustek, g_strdup ("0900")); + g_hash_table_insert (scanners, + g_strdup("07b3"), + plustek); + + GList* corex = NULL; + corex = g_list_append (corex, g_strdup ("0002")); + corex = g_list_append (corex, g_strdup ("0005")); + g_hash_table_insert (scanners, + g_strdup("08f0"), + corex); + + GList* xerox = NULL; + xerox = g_list_append (xerox, g_strdup ("3d5d")); + xerox = g_list_append (xerox, g_strdup ("3da4")); + xerox = g_list_append (xerox, g_strdup ("420c")); + xerox = g_list_append (xerox, g_strdup ("4265")); + xerox = g_list_append (xerox, g_strdup ("4293")); + xerox = g_list_append (xerox, g_strdup ("4294")); + g_hash_table_insert (scanners, + g_strdup("0924"), + xerox); + + GList* pentax_2 = NULL; + pentax_2 = g_list_append (pentax_2, g_strdup ("3210")); + g_hash_table_insert (scanners, + g_strdup("0a17"), + pentax_2); + + GList* portable = NULL; + portable = g_list_append (portable, g_strdup ("1000")); + g_hash_table_insert (scanners, + g_strdup("0a53"), + portable); + + GList* syscan = NULL; + syscan = g_list_append (syscan, g_strdup ("4600")); + syscan = g_list_append (syscan, g_strdup ("4802")); + syscan = g_list_append (syscan, g_strdup ("4803")); + syscan = g_list_append (syscan, g_strdup ("480c")); + syscan = g_list_append (syscan, g_strdup ("4810")); + syscan = g_list_append (syscan, g_strdup ("6620")); + g_hash_table_insert (scanners, + g_strdup("0a82"), + syscan); + + GList* canon_2 = NULL; + canon_2 = g_list_append (canon_2, g_strdup ("160c")); + canon_2 = g_list_append (canon_2, g_strdup ("160f")); + canon_2 = g_list_append (canon_2, g_strdup ("1614")); + canon_2 = g_list_append (canon_2, g_strdup ("1617")); + canon_2 = g_list_append (canon_2, g_strdup ("1618")); + canon_2 = g_list_append (canon_2, g_strdup ("161a")); + canon_2 = g_list_append (canon_2, g_strdup ("161b")); + canon_2 = g_list_append (canon_2, g_strdup ("161d")); + canon_2 = g_list_append (canon_2, g_strdup ("1620")); + canon_2 = g_list_append (canon_2, g_strdup ("1622")); + canon_2 = g_list_append (canon_2, g_strdup ("1623")); + canon_2 = g_list_append (canon_2, g_strdup ("1624")); + canon_2 = g_list_append (canon_2, g_strdup ("1626")); + canon_2 = g_list_append (canon_2, g_strdup ("162b")); + canon_2 = g_list_append (canon_2, g_strdup ("1638")); + canon_2 = g_list_append (canon_2, g_strdup ("1639")); + g_hash_table_insert (scanners, + g_strdup("1083"), + canon_2); + + GList* digital = NULL; + digital = g_list_append (digital, g_strdup ("0001")); + g_hash_table_insert (scanners, + g_strdup("1183"), + digital); + + GList* konica_2 = NULL; + konica_2 = g_list_append (konica_2, g_strdup ("2089")); + g_hash_table_insert (scanners, + g_strdup("132b"), + konica_2); + + GList* umax = NULL; + umax = g_list_append (umax, g_strdup ("0010")); + umax = g_list_append (umax, g_strdup ("0030")); + umax = g_list_append (umax, g_strdup ("0050")); + umax = g_list_append (umax, g_strdup ("0060")); + umax = g_list_append (umax, g_strdup ("0070")); + umax = g_list_append (umax, g_strdup ("0130")); + umax = g_list_append (umax, g_strdup ("0160")); + umax = g_list_append (umax, g_strdup ("0230")); + g_hash_table_insert (scanners, + g_strdup("1606"), + umax); + + GList* docketport = NULL; + docketport = g_list_append (docketport, g_strdup ("4810")); + g_hash_table_insert (scanners, + g_strdup("1dcc"), + docketport); + + GList* dell = NULL; + dell = g_list_append (dell, g_strdup ("5105")); + dell = g_list_append (dell, g_strdup ("5124")); + dell = g_list_append (dell, g_strdup ("5250")); + g_hash_table_insert (scanners, + g_strdup("413c"), + dell); +} diff --git a/src/session-dbus.c b/src/session-dbus.c index fa9ea54..1cf73ac 100644 --- a/src/session-dbus.c +++ b/src/session-dbus.c @@ -5,6 +5,7 @@ Copyright 2010 Canonical Ltd. Authors: Ted Gould <ted@canonical.com> + Conor Curran <conor.curran@canonical.com> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3, as published @@ -28,7 +29,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include "session-dbus.h" #include "dbus-shared-names.h" -static GVariant * get_icon (SessionDbus * service); +static GVariant * get_users_real_name (SessionDbus * service); static void bus_get_cb (GObject * object, GAsyncResult * res, gpointer user_data); static void bus_method_call (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * method, GVariant * params, GDBusMethodInvocation * invocation, gpointer user_data); @@ -37,6 +38,7 @@ static void bus_method_call (GDBusConnection * connection, const gchar * sender, typedef struct _SessionDbusPrivate SessionDbusPrivate; struct _SessionDbusPrivate { gchar * name; + gboolean user_menu_is_visible; GDBusConnection * bus; GCancellable * bus_cancel; guint dbus_registration; @@ -98,10 +100,11 @@ session_dbus_init (SessionDbus *self) { SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(self); - priv->name = g_strdup(ICON_DEFAULT); + priv->name = NULL; priv->bus = NULL; priv->bus_cancel = NULL; priv->dbus_registration = 0; + priv->user_menu_is_visible = FALSE; priv->bus_cancel = g_cancellable_new(); g_bus_get(G_BUS_TYPE_SESSION, @@ -160,15 +163,20 @@ bus_method_call (GDBusConnection * connection, const gchar * sender, const gchar * method, GVariant * params, GDBusMethodInvocation * invocation, gpointer user_data) { - SessionDbus * service = SESSION_DBUS(user_data); + SessionDbus * service = SESSION_DBUS (user_data); + SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE (service); + GVariant * retval = NULL; - if (g_strcmp0(method, "GetIcon") == 0) { - retval = get_icon(service); - } else { - g_warning("Calling method '%s' on the indicator service and it's unknown", method); + if (g_strcmp0(method, "GetUserRealName") == 0) { + retval = get_users_real_name (service); + } + else if (g_strcmp0 (method, "GetUserMenuVisibility") == 0){ + retval = g_variant_new ("(b)", priv->user_menu_is_visible); + } + else { + g_warning("Calling method '%s' on the indicator service and it's unknown", method); } - g_dbus_method_invocation_return_value(invocation, retval); return; } @@ -214,10 +222,10 @@ session_dbus_finalize (GObject *object) } static GVariant * -get_icon (SessionDbus * service) +get_users_real_name (SessionDbus * service) { SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(service); - return g_variant_new("(s)", priv->name); + return g_variant_new ("(s)", priv->name); } SessionDbus * @@ -229,29 +237,81 @@ session_dbus_new (void) void session_dbus_set_name (SessionDbus * session, const gchar * name) { +} + +void +session_dbus_set_users_real_name (SessionDbus * session, const gchar * name) +{ SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(session); GError * error = NULL; if (priv->name != NULL) { g_free(priv->name); priv->name = NULL; } + priv->name = g_strdup(name); if (priv->bus != NULL) { g_dbus_connection_emit_signal (priv->bus, - NULL, - INDICATOR_SESSION_SERVICE_DBUS_OBJECT, - INDICATOR_SESSION_SERVICE_DBUS_IFACE, - "IconUpdated", - g_variant_new ("(s)", priv->name, NULL), - &error); + NULL, + INDICATOR_SESSION_SERVICE_DBUS_OBJECT, + INDICATOR_SESSION_SERVICE_DBUS_IFACE, + "UserRealNameUpdated", + g_variant_new ("(s)", priv->name, NULL), + &error); if (error != NULL) { - g_warning("Unable to send IconUpdated signal: %s", error->message); + g_warning("Unable to send UserRealNameUpdated signal: %s", error->message); g_error_free(error); return; } } - return; } + +void +session_dbus_set_user_menu_visibility (SessionDbus* session, + gboolean visible) +{ + SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(session); + GError * error = NULL; + + priv->user_menu_is_visible = visible; + + if (priv->bus != NULL) { + g_dbus_connection_emit_signal (priv->bus, + NULL, + INDICATOR_SESSION_SERVICE_DBUS_OBJECT, + INDICATOR_SESSION_SERVICE_DBUS_IFACE, + "UserMenuIsVisible", + g_variant_new ("(b)", priv->user_menu_is_visible), + &error); + + if (error != NULL) { + g_warning("Unable to send UserMenuIsVisible signal: %s", error->message); + g_error_free(error); + } + } +} + +void session_dbus_restart_required (SessionDbus* session) +{ + SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(session); + GError * error = NULL; + + if (priv->bus != NULL) { + g_dbus_connection_emit_signal (priv->bus, + NULL, + INDICATOR_SESSION_SERVICE_DBUS_OBJECT, + INDICATOR_SESSION_SERVICE_DBUS_IFACE, + "RebootRequired", + NULL, + &error); + + if (error != NULL) { + g_warning("Unable to send reboot-required signal: %s", error->message); + g_error_free(error); + } + } + +} diff --git a/src/session-dbus.h b/src/session-dbus.h index 792917b..4dc340a 100644 --- a/src/session-dbus.h +++ b/src/session-dbus.h @@ -48,8 +48,10 @@ struct _SessionDbus { GType session_dbus_get_type (void); SessionDbus * session_dbus_new (void); -void session_dbus_set_name (SessionDbus * session, const gchar * name); - +void session_dbus_set_name (SessionDbus * session, const gchar * name); +void session_dbus_set_users_real_name (SessionDbus * session, const gchar * name); +void session_dbus_set_user_menu_visibility (SessionDbus* session, gboolean visible); +void session_dbus_restart_required (SessionDbus* session); G_END_DECLS #endif diff --git a/src/session-dbus.xml b/src/session-dbus.xml index ee724f5..fd1859f 100644 --- a/src/session-dbus.xml +++ b/src/session-dbus.xml @@ -2,14 +2,22 @@ <node name="/com/canonical/indicator/session/service"> <interface name="com.canonical.indicator.session.service"> - <!-- Icon --> - <method name="GetIcon"> + <method name="GetUserRealName"> <arg name="name" direction="out" type="s"/> </method> - - <signal name="IconUpdated"> + <method name="GetUserMenuVisibility"> + <arg name="update" direction="out" type="b"/> + </method> + <method name="IsUpdateNeeded"> + <arg name="update" direction="out" type="b"/> + </method> + <signal name="UserRealNameUpdated"> <arg name="name" type="s"/> </signal> - + <signal name="UserMenuIsVisible"> + <arg name="update" type="b"/> + </signal> + <signal name="RestartRequired"> + </signal> </interface> </node> diff --git a/src/session-service.c b/src/session-service.c index dfc3805..753e304 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -8,6 +8,7 @@ Authors: Ted Gould <ted@canonical.com> Christoph Korn <c_korn@gmx.de> Cody Russell <crussell@canonical.com> + Conor Curran <conor.curran@canonical.com> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3, as published @@ -36,32 +37,22 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <libdbusmenu-glib/server.h> #include <libdbusmenu-glib/menuitem.h> #include <libdbusmenu-glib/client.h> + +#include <gtk/gtk.h> +#if GTK_CHECK_VERSION(3, 0, 0) #include <libdbusmenu-gtk3/menuitem.h> +#else +#include <libdbusmenu-gtk/menuitem.h> +#endif #include <libindicator/indicator-service.h> #include "dbus-shared-names.h" #include "dbusmenu-shared.h" - -#include "gconf-helper.h" - -#include "session-dbus.h" #include "users-service-dbus.h" -#include "lock-helper.h" -#include "upower-client.h" - -#define UP_ADDRESS "org.freedesktop.UPower" -#define UP_OBJECT "/org/freedesktop/UPower" -#define UP_INTERFACE "org.freedesktop.UPower" - -#define EXTRA_LAUNCHER_DIR "/usr/share/indicators/session/applications" - -#define LOCKDOWN_DIR "/desktop/gnome/lockdown" -#define LOCKDOWN_KEY_USER LOCKDOWN_DIR "/disable_user_switching" -#define LOCKDOWN_KEY_SCREENSAVER LOCKDOWN_DIR "/disable_lock_screen" - -#define KEYBINDING_DIR "/apps/gnome_settings_daemon/keybindings" -#define KEY_LOCK_SCREEN KEYBINDING_DIR "/screensaver" +#include "user-menu-mgr.h" +#include "device-menu-mgr.h" +#include "session-dbus.h" typedef struct _ActivateData ActivateData; struct _ActivateData @@ -70,697 +61,10 @@ struct _ActivateData UserData *user; }; -static UsersServiceDbus *dbus_interface = NULL; +//static UsersServiceDbus *dbus_interface = NULL; static SessionDbus *session_dbus = NULL; - -static DbusmenuMenuitem *lock_menuitem = NULL; -static DbusmenuMenuitem *switch_menuitem = NULL; - -static DbusmenuMenuitem * root_menuitem = NULL; static GMainLoop * mainloop = NULL; -static DBusGProxy * up_main_proxy = NULL; -static DBusGProxy * up_prop_proxy = NULL; - -static DBusGProxyCall * suspend_call = NULL; -static DBusGProxyCall * hibernate_call = NULL; - -static DbusmenuMenuitem * hibernate_mi = NULL; -static DbusmenuMenuitem * suspend_mi = NULL; -static DbusmenuMenuitem * logout_mi = NULL; -static DbusmenuMenuitem * restart_mi = NULL; -static DbusmenuMenuitem * shutdown_mi = NULL; - -static gboolean can_hibernate = TRUE; -static gboolean can_suspend = TRUE; -static gboolean allow_hibernate = TRUE; -static gboolean allow_suspend = TRUE; - -static GConfClient * gconf_client = NULL; - -static void rebuild_items (DbusmenuMenuitem *root, UsersServiceDbus *service); - -static void -lockdown_changed (GConfClient *client, - guint cnxd_id, - GConfEntry *entry, - gpointer user_data) -{ - GConfValue *value = gconf_entry_get_value (entry); - const gchar *key = gconf_entry_get_key (entry); - - if (value == NULL || key == NULL) { - return; - } - - if (g_strcmp0 (key, LOCKDOWN_KEY_USER) == 0 || g_strcmp0 (key, LOCKDOWN_KEY_SCREENSAVER) == 0) { - rebuild_items(root_menuitem, dbus_interface); - } - - return; -} - -static void -keybinding_changed (GConfClient *client, - guint cnxd_id, - GConfEntry *entry, - gpointer user_data) -{ - GConfValue *value = gconf_entry_get_value (entry); - const gchar *key = gconf_entry_get_key (entry); - - if (value == NULL || key == NULL) { - return; - } - - if (g_strcmp0 (key, KEY_LOCK_SCREEN) == 0) { - g_debug("Keybinding changed to: %s", gconf_value_get_string(value)); - if (lock_menuitem != NULL) { - dbusmenu_menuitem_property_set_shortcut_string(lock_menuitem, gconf_value_get_string(value)); - } - } - - return; -} - -/* Ensures that we have a GConf client and if we build one - set up the signal handler. */ -static void -ensure_gconf_client (void) -{ - if (!gconf_client) { - gconf_client = gconf_client_get_default (); - - gconf_client_add_dir(gconf_client, LOCKDOWN_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); - gconf_client_notify_add(gconf_client, LOCKDOWN_DIR, lockdown_changed, NULL, NULL, NULL); - - gconf_client_add_dir(gconf_client, KEYBINDING_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); - gconf_client_notify_add(gconf_client, KEYBINDING_DIR, keybinding_changed, NULL, NULL, NULL); - } - return; -} - -/* Check to see if the lockdown key is protecting from - locking the screen. If not, lock it. */ -static void -lock_if_possible (void) { - ensure_gconf_client (); - - if (!gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_SCREENSAVER, NULL)) { - lock_screen(NULL, 0, NULL); - } - - return; -} - -/* A return from the command to sleep the system. Make sure - that we unthrottle the screensaver. */ -static void -sleep_response (DBusGProxy * proxy, DBusGProxyCall * call, gpointer data) -{ - screensaver_unthrottle(); - return; -} - -/* Let's put this machine to sleep, with some info on how - it should sleep. */ -static void -machine_sleep (DbusmenuMenuitem * mi, guint timestamp, gpointer userdata) -{ - gchar * type = (gchar *)userdata; - - if (up_main_proxy == NULL) { - g_warning("Can not %s as no upower proxy", type); - } - - screensaver_throttle(type); - lock_if_possible(); - - dbus_g_proxy_begin_call(up_main_proxy, - type, - sleep_response, - NULL, - NULL, - G_TYPE_INVALID); - - return; -} - -/* A response to getting the suspend property */ -static void -suspend_prop_cb (DBusGProxy * proxy, DBusGProxyCall * call, gpointer userdata) -{ - suspend_call = NULL; - - GValue candoit = {0}; - GError * error = NULL; - dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_VALUE, &candoit, G_TYPE_INVALID); - if (error != NULL) { - g_warning("Unable to check suspend: %s", error->message); - g_error_free(error); - return; - } - g_debug("Got Suspend: %s", g_value_get_boolean(&candoit) ? "true" : "false"); - - gboolean local_can_suspend = g_value_get_boolean(&candoit); - if (local_can_suspend != can_suspend) { - can_suspend = local_can_suspend; - rebuild_items(root_menuitem, dbus_interface); - } - - return; -} - -/* Response to getting the hibernate property */ -static void -hibernate_prop_cb (DBusGProxy * proxy, DBusGProxyCall * call, gpointer userdata) -{ - hibernate_call = NULL; - - GValue candoit = {0}; - GError * error = NULL; - dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_VALUE, &candoit, G_TYPE_INVALID); - if (error != NULL) { - g_warning("Unable to check hibernate: %s", error->message); - g_error_free(error); - return; - } - g_debug("Got Hibernate: %s", g_value_get_boolean(&candoit) ? "true" : "false"); - - gboolean local_can_hibernate = g_value_get_boolean(&candoit); - if (local_can_hibernate != can_hibernate) { - can_hibernate = local_can_hibernate; - rebuild_items(root_menuitem, dbus_interface); - } - - return; -} - -/* A signal that we need to recheck to ensure we can still - hibernate and/or suspend */ -static void -up_changed_cb (DBusGProxy * proxy, gpointer user_data) -{ - /* Start Async call to see if we can hibernate */ - if (suspend_call == NULL) { - suspend_call = dbus_g_proxy_begin_call(up_prop_proxy, - "Get", - suspend_prop_cb, - NULL, - NULL, - G_TYPE_STRING, - UP_INTERFACE, - G_TYPE_STRING, - "CanSuspend", - G_TYPE_INVALID, - G_TYPE_VALUE, - G_TYPE_INVALID); - } - - /* Start Async call to see if we can suspend */ - if (hibernate_call == NULL) { - hibernate_call = dbus_g_proxy_begin_call(up_prop_proxy, - "Get", - hibernate_prop_cb, - NULL, - NULL, - G_TYPE_STRING, - UP_INTERFACE, - G_TYPE_STRING, - "CanHibernate", - G_TYPE_INVALID, - G_TYPE_VALUE, - G_TYPE_INVALID); - } - - return; -} - -/* Handle the callback from the allow functions to check and - see if we're changing the value, and if so, rebuilding the - menus based on that info. */ -static void -allowed_cb (DBusGProxy *proxy, gboolean OUT_allowed, GError *error, gpointer userdata) -{ - if (error != NULL) { - g_warning("Unable to get information on what is allowed from UPower: %s", error->message); - return; - } - - gboolean * can_do = (gboolean *)userdata; - - if (OUT_allowed != *can_do) { - *can_do = OUT_allowed; - rebuild_items (root_menuitem, dbus_interface); - } -} - -/* This function goes through and sets up what we need for - DKp checking. We're even setting up the calls for the props - we need */ -static void -setup_up (void) { - DBusGConnection * bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL); - g_return_if_fail(bus != NULL); - - if (up_main_proxy == NULL) { - up_main_proxy = dbus_g_proxy_new_for_name(bus, - UP_ADDRESS, - UP_OBJECT, - UP_INTERFACE); - } - g_return_if_fail(up_main_proxy != NULL); - - if (up_prop_proxy == NULL) { - up_prop_proxy = dbus_g_proxy_new_for_name(bus, - UP_ADDRESS, - UP_OBJECT, - DBUS_INTERFACE_PROPERTIES); - /* Connect to changed signal */ - dbus_g_proxy_add_signal(up_main_proxy, - "Changed", - G_TYPE_INVALID); - - dbus_g_proxy_connect_signal(up_main_proxy, - "Changed", - G_CALLBACK(up_changed_cb), - NULL, - NULL); - } - g_return_if_fail(up_prop_proxy != NULL); - - - /* Force an original "changed" event */ - up_changed_cb(up_main_proxy, NULL); - - /* Check to see if these are getting blocked by PolicyKit */ - org_freedesktop_UPower_suspend_allowed_async(up_main_proxy, - allowed_cb, - &allow_suspend); - org_freedesktop_UPower_hibernate_allowed_async(up_main_proxy, - allowed_cb, - &allow_hibernate); - - return; -} - -/* This is the function to show a dialog on actions that - can destroy data. Currently it just calls the GTK version - but it seems that in the future it should figure out - what's going on and something better. */ -static void -show_dialog (DbusmenuMenuitem * mi, guint timestamp, gchar * type) -{ - gchar * helper = g_build_filename(LIBEXECDIR, "gtk-logout-helper", NULL); - gchar * dialog_line = g_strdup_printf("%s --%s", helper, type); - g_free(helper); - - g_debug("Showing dialog '%s'", dialog_line); - - GError * error = NULL; - if (!g_spawn_command_line_async(dialog_line, &error)) { - g_warning("Unable to show dialog: %s", error->message); - g_error_free(error); - } - - g_free(dialog_line); - - return; -} - -/* Checks to see if we should show the guest session item */ -static gboolean -check_guest_session (void) -{ - if (geteuid() < 500) { - /* System users shouldn't have guest account shown. Mosly - this would be the case of the guest user itself. */ - return FALSE; - } - // FIXME: Ask DisplayManager - - return TRUE; -} - -/* Called when someone clicks on the guest session item. */ -static void -activate_guest_session (DbusmenuMenuitem * mi, guint timestamp, gpointer user_data) -{ - lock_if_possible(); - - if (!users_service_dbus_activate_guest_session(USERS_SERVICE_DBUS(user_data))) - g_warning("Unable to activate guest session"); - - return; -} - -/* Checks to see if we can create sessions */ -static gboolean -check_new_session (void) -{ - return TRUE; -} - -/* Starts a new generic session */ -static void -activate_new_session (DbusmenuMenuitem * mi, guint timestamp, gpointer user_data) -{ - lock_if_possible(); - - users_service_dbus_show_greeter (USERS_SERVICE_DBUS(user_data)); - - return; -} - -/* Activates a session for a particular user. */ -static void -activate_user_session (DbusmenuMenuitem *mi, guint timestamp, gpointer user_data) -{ - UserData *user = (UserData *)user_data; - UsersServiceDbus *service = user->service; - - lock_if_possible(); - - users_service_dbus_activate_user_session (service, user); -} - -/* Comparison function to look into the UserData struct - to compare by using the username value */ -static gint -compare_users_by_username (const gchar *a, - const gchar *b) -{ - UserData *user1 = (UserData *)a; - UserData *user2 = (UserData *)b; - - gint retval = g_strcmp0 (user1->real_name, user2->real_name); - - /* If they're the same, they're both in conflict. */ - if (retval == 0) { - user1->real_name_conflict = TRUE; - user2->real_name_conflict = TRUE; - } - - return retval; -} - -/* Take a desktop file and execute it */ -static void -desktop_activate_cb (DbusmenuMenuitem * mi, guint timestamp, gpointer data) -{ - GAppInfo * appinfo = G_APP_INFO(data); - g_return_if_fail(appinfo != NULL); - g_app_info_launch(appinfo, NULL, NULL, NULL); - return; -} - -/* Look at the GAppInfo structures and sort based on - the application names */ -static gint -sort_app_infos (gconstpointer a, gconstpointer b) -{ - GAppInfo * appa = G_APP_INFO(a); - GAppInfo * appb = G_APP_INFO(b); - - const gchar * namea = NULL; - const gchar * nameb = NULL; - - if (appa != NULL) { - namea = g_app_info_get_name(appa); - } - - if (appb != NULL) { - nameb = g_app_info_get_name(appb); - } - - return g_strcmp0(namea, nameb); -} - -/* Builds up the menu for us */ -static void -rebuild_items (DbusmenuMenuitem *root, - UsersServiceDbus *service) -{ - DbusmenuMenuitem *mi = NULL; - DbusmenuMenuitem * guest_mi = NULL; - GList *u; - UserData *user; - gboolean can_activate; - gboolean can_lockscreen; - GList *children; - - /* Make sure we have a valid GConf client, and build one - if needed */ - ensure_gconf_client (); - - /* Check to see which menu items we're allowed to have */ - can_activate = users_service_dbus_can_activate_session (service) && - !gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_USER, NULL); - can_lockscreen = !gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_SCREENSAVER, NULL); - - /* Remove the old menu items if that makes sense */ - children = dbusmenu_menuitem_take_children (root); - g_list_foreach (children, (GFunc)g_object_unref, NULL); - g_list_free (children); - - /* Lock screen item */ - if (can_lockscreen) { - lock_menuitem = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(lock_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _("Lock Screen")); - - gchar * shortcut = gconf_client_get_string(gconf_client, KEY_LOCK_SCREEN, NULL); - if (shortcut != NULL) { - g_debug("Lock screen shortcut: %s", shortcut); - dbusmenu_menuitem_property_set_shortcut_string(lock_menuitem, shortcut); - g_free(shortcut); - } else { - g_debug("Unable to get lock screen shortcut."); - } - - g_signal_connect(G_OBJECT(lock_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(lock_screen), NULL); - dbusmenu_menuitem_child_append(root, lock_menuitem); - } - - /* Set to NULL just incase we don't end up building one */ - users_service_dbus_set_guest_item(service, NULL); - - /* Build all of the user switching items */ - if (can_activate == TRUE) - { - if (can_lockscreen) { - DbusmenuMenuitem * separator1 = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(separator1, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); - dbusmenu_menuitem_child_append(root, separator1); - } - - if (check_guest_session ()) - { - guest_mi = dbusmenu_menuitem_new (); - dbusmenu_menuitem_property_set (guest_mi, DBUSMENU_MENUITEM_PROP_TYPE, USER_ITEM_TYPE); - dbusmenu_menuitem_property_set (guest_mi, USER_ITEM_PROP_NAME, _("Guest Session")); - dbusmenu_menuitem_property_set_bool (guest_mi, USER_ITEM_PROP_LOGGED_IN, FALSE); - dbusmenu_menuitem_child_append (root, guest_mi); - g_signal_connect (G_OBJECT (guest_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_guest_session), service); - users_service_dbus_set_guest_item(service, guest_mi); - } - - if (check_new_session ()) - { - - switch_menuitem = dbusmenu_menuitem_new (); - dbusmenu_menuitem_property_set (switch_menuitem, DBUSMENU_MENUITEM_PROP_TYPE, MENU_SWITCH_TYPE); - dbusmenu_menuitem_property_set (switch_menuitem, MENU_SWITCH_USER, g_get_user_name()); - dbusmenu_menuitem_child_append (root, switch_menuitem); - g_signal_connect (G_OBJECT (switch_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_new_session), service); - } - - GList * users = NULL; - users = users_service_dbus_get_user_list (service); - guint user_count = g_list_length(users); - - if (user_count > MINIMUM_USERS && user_count < MAXIMUM_USERS) { - users = g_list_sort (users, (GCompareFunc)compare_users_by_username); - } - for (u = users; u != NULL; u = g_list_next (u)) { - user = u->data; - user->service = service; - - if (user->uid == getuid()) { - /* Hide me from the list */ - continue; - } - g_debug ("%li %s", user->uid, user->user_name); - - if (g_strcmp0(user->user_name, "guest") == 0) { - /* Check to see if the guest has sessions and so therefore should - get a check mark. */ - if (user->sessions != NULL) { - dbusmenu_menuitem_property_set_bool (guest_mi, USER_ITEM_PROP_LOGGED_IN, TRUE); - } - /* If we're showing user accounts, keep going through the list */ - if (user_count > MINIMUM_USERS && user_count < MAXIMUM_USERS) { - continue; - } - /* If not, we can stop here */ - break; - } - - if (user_count > MINIMUM_USERS && user_count < MAXIMUM_USERS) { - mi = dbusmenu_menuitem_new (); - dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_TYPE, USER_ITEM_TYPE); - if (user->real_name_conflict) { - gchar * conflictedname = g_strdup_printf("%s (%s)", user->real_name, user->user_name); - dbusmenu_menuitem_property_set (mi, USER_ITEM_PROP_NAME, conflictedname); - g_free(conflictedname); - } else { - dbusmenu_menuitem_property_set (mi, USER_ITEM_PROP_NAME, user->real_name); - } - dbusmenu_menuitem_property_set_bool (mi, USER_ITEM_PROP_LOGGED_IN, user->sessions != NULL); - if (user->icon_file != NULL && user->icon_file[0] != '\0') { - dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, user->icon_file); - } else { - dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, USER_ITEM_ICON_DEFAULT); - } - dbusmenu_menuitem_child_append (root, mi); - g_signal_connect (G_OBJECT (mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_user_session), user); - user->menuitem = mi; - } - } - - g_list_free(users); - } - - /* If there were a bunch of items before us, we need a - separator. */ - if (can_lockscreen || can_activate) { - DbusmenuMenuitem * separator = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); - dbusmenu_menuitem_child_append(root, separator); - } - - /* Start going through the session based items. */ - - logout_mi = dbusmenu_menuitem_new(); - if (supress_confirmations()) { - dbusmenu_menuitem_property_set(logout_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Log Out")); - } else { - dbusmenu_menuitem_property_set(logout_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Log Out\342\200\246")); - } - dbusmenu_menuitem_property_set_bool(logout_mi, DBUSMENU_MENUITEM_PROP_VISIBLE, show_logout()); - dbusmenu_menuitem_child_append(root, logout_mi); - g_signal_connect(G_OBJECT(logout_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_dialog), "logout"); - - if (can_suspend && allow_suspend) { - suspend_mi = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(suspend_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Suspend")); - dbusmenu_menuitem_child_append(root, suspend_mi); - g_signal_connect(G_OBJECT(suspend_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(machine_sleep), "Suspend"); - } - - if (can_hibernate && allow_hibernate) { - hibernate_mi = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(hibernate_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Hibernate")); - dbusmenu_menuitem_child_append(root, hibernate_mi); - g_signal_connect(G_OBJECT(hibernate_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(machine_sleep), "Hibernate"); - } - - restart_mi = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(restart_mi, DBUSMENU_MENUITEM_PROP_TYPE, RESTART_ITEM_TYPE); - if (supress_confirmations()) { - dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart")); - } else { - dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart\342\200\246")); - } - dbusmenu_menuitem_property_set_bool(restart_mi, DBUSMENU_MENUITEM_PROP_VISIBLE, show_restart()); - dbusmenu_menuitem_child_append(root, restart_mi); - g_signal_connect(G_OBJECT(restart_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_dialog), "restart"); - - shutdown_mi = dbusmenu_menuitem_new(); - if (supress_confirmations()) { - dbusmenu_menuitem_property_set(shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Shut Down")); - } else { - dbusmenu_menuitem_property_set(shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Shut Down\342\200\246")); - } - dbusmenu_menuitem_property_set_bool(shutdown_mi, DBUSMENU_MENUITEM_PROP_VISIBLE, show_shutdown()); - dbusmenu_menuitem_child_append(root, shutdown_mi); - g_signal_connect(G_OBJECT(shutdown_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_dialog), "shutdown"); - - RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi = g_new0 (RestartShutdownLogoutMenuItems, 1); - restart_shutdown_logout_mi->logout_mi = logout_mi; - restart_shutdown_logout_mi->restart_mi = restart_mi; - restart_shutdown_logout_mi->shutdown_mi = shutdown_mi; - - update_menu_entries(restart_shutdown_logout_mi); - - /* now add extra launchers */ - GDir *extra_launchers_dir; - extra_launchers_dir = g_dir_open (EXTRA_LAUNCHER_DIR, 0, NULL); - if (extra_launchers_dir != NULL) { - GList * launchers = NULL; - - /* Find all the desktop files we want to use */ - for (;;) { - const gchar *extra_launcher_file; - - extra_launcher_file = g_dir_read_name (extra_launchers_dir); - if (extra_launcher_file == NULL) - break; - if (!g_str_has_suffix (extra_launcher_file, ".desktop")) - continue; - - gchar *full_path = g_build_filename (EXTRA_LAUNCHER_DIR, extra_launcher_file, NULL); - GAppInfo * appinfo = G_APP_INFO(g_desktop_app_info_new_from_filename (full_path)); - g_free (full_path); - - launchers = g_list_prepend(launchers, appinfo); - } - g_dir_close(extra_launchers_dir); - - /* Sort the desktop files based on their names */ - launchers = g_list_sort(launchers, sort_app_infos); - - /* Turn each one into a separate menu item */ - GList * launcher = NULL; - gboolean sepadded = FALSE; - for (launcher = launchers; launcher != NULL; launcher = g_list_next(launcher)) { - GAppInfo * appinfo = G_APP_INFO(launcher->data); - - /* Make sure we have a separator */ - if (!sepadded) { - DbusmenuMenuitem * separator = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); - dbusmenu_menuitem_child_append(root, separator); - g_object_unref(separator); - sepadded = TRUE; - } - - /* Build the item */ - DbusmenuMenuitem * desktop_mi = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(desktop_mi, DBUSMENU_MENUITEM_PROP_LABEL, g_app_info_get_name(appinfo)); - g_signal_connect(G_OBJECT(desktop_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(desktop_activate_cb), appinfo); - g_object_weak_ref(G_OBJECT(desktop_mi), (GWeakNotify)g_object_unref, appinfo); - - /* Put into the menu */ - dbusmenu_menuitem_child_append(root, desktop_mi); - } - - g_list_free(launchers); - } - - return; -} - -/* Signal called when a user is added. It updates the count and - rebuilds the menu */ -static void -user_change (UsersServiceDbus *service, - const gchar *user_id, - gpointer user_data) -{ - DbusmenuMenuitem *root = (DbusmenuMenuitem *)user_data; - rebuild_items (root, service); - return; -} /* When the service interface starts to shutdown, we should follow it. */ @@ -774,51 +78,12 @@ service_shutdown (IndicatorService * service, gpointer user_data) return; } -/* When the directory changes we need to figure out how our menu - item should look. */ -static void -restart_dir_changed (void) -{ - gboolean restart_required = g_file_test("/var/run/reboot-required", G_FILE_TEST_EXISTS); - - if (restart_required) { - if (supress_confirmations()) { - dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart to Complete Update")); - } else { - dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart to Complete Update\342\200\246")); - } - dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_ICON, "system-restart-panel"); - if (session_dbus != NULL) { - session_dbus_set_name(session_dbus, ICON_RESTART); - } - } else { - if (supress_confirmations()) { - dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart")); - } else { - dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart\342\200\246")); - } - dbusmenu_menuitem_property_remove(restart_mi, RESTART_ITEM_ICON); - if (session_dbus != NULL) { - session_dbus_set_name(session_dbus, ICON_DEFAULT); - } - } - - return; -} - -/* Buids a file watcher for the directory so that when it - changes we can check to see if our reboot-required is - there. */ -static void -setup_restart_watch (void) +static gboolean +get_greeter_mode (void) { - GFile * filedir = g_file_new_for_path("/var/run"); - GFileMonitor * filemon = g_file_monitor_directory(filedir, G_FILE_MONITOR_NONE, NULL, NULL); - if (filemon != NULL) { - g_signal_connect(G_OBJECT(filemon), "changed", G_CALLBACK(restart_dir_changed), NULL); - } - restart_dir_changed(); - return; + const gchar *var; + var = g_getenv("INDICATOR_GREETER_MODE"); + return (g_strcmp0(var, "1") == 0); } /* Main, is well, main. It brings everything up and throws @@ -826,7 +91,9 @@ setup_restart_watch (void) int main (int argc, char ** argv) { - g_type_init(); + gboolean greeter_mode; + + g_type_init(); /* Setting up i18n and gettext. Apparently, we need all of these. */ @@ -834,42 +101,31 @@ main (int argc, char ** argv) bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); textdomain (GETTEXT_PACKAGE); - IndicatorService * service = indicator_service_new_version(INDICATOR_SESSION_DBUS_NAME, - INDICATOR_SESSION_DBUS_VERSION); - g_signal_connect(G_OBJECT(service), - INDICATOR_SERVICE_SIGNAL_SHUTDOWN, - G_CALLBACK(service_shutdown), NULL); + IndicatorService * service = indicator_service_new_version (INDICATOR_SESSION_DBUS_NAME, + INDICATOR_SESSION_DBUS_VERSION); + g_signal_connect (G_OBJECT(service), + INDICATOR_SERVICE_SIGNAL_SHUTDOWN, + G_CALLBACK(service_shutdown), NULL); session_dbus = session_dbus_new(); - g_idle_add(lock_screen_setup, NULL); - - root_menuitem = dbusmenu_menuitem_new(); - g_debug("Root ID: %d", dbusmenu_menuitem_get_id(root_menuitem)); - - dbus_interface = g_object_new (USERS_SERVICE_DBUS_TYPE, NULL); - - rebuild_items (root_menuitem, dbus_interface); - - g_signal_connect (G_OBJECT (dbus_interface), - "user-added", - G_CALLBACK (user_change), - root_menuitem); - g_signal_connect (G_OBJECT (dbus_interface), - "user-deleted", - G_CALLBACK (user_change), - root_menuitem); - - setup_restart_watch(); - - setup_up(); - - DbusmenuServer * server = dbusmenu_server_new(INDICATOR_SESSION_DBUS_OBJECT); - dbusmenu_server_set_root(server, root_menuitem); - - mainloop = g_main_loop_new(NULL, FALSE); - g_main_loop_run(mainloop); + greeter_mode = get_greeter_mode(); + + // Devices + DeviceMenuMgr* device_mgr = device_menu_mgr_new (session_dbus, greeter_mode); + DbusmenuServer * server = dbusmenu_server_new(INDICATOR_SESSION_DBUS_OBJECT); + dbusmenu_server_set_root(server, device_mgr_get_root_item (device_mgr)); + + if (!greeter_mode) { + // Users + UserMenuMgr* user_mgr = user_menu_mgr_new (session_dbus, greeter_mode); + DbusmenuServer* users_server = dbusmenu_server_new (INDICATOR_USERS_DBUS_OBJECT); + dbusmenu_server_set_root (users_server, user_mgr_get_root_item (user_mgr)); + } - return 0; + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + return 0; } diff --git a/src/udev-mgr.c b/src/udev-mgr.c new file mode 100644 index 0000000..f66d862 --- /dev/null +++ b/src/udev-mgr.c @@ -0,0 +1,456 @@ +/* +Copyright 2011 Canonical Ltd. + +Authors: + Conor Curran <conor.curran@canonical.com> + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <gudev/gudev.h> + +// TEMP +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <stdarg.h> + +#include "udev-mgr.h" +#include "sane-rules.h" + +static void udevice_mgr_device_list_iterator (gpointer data, + gpointer userdata); +static void udev_mgr_uevent_cb (GUdevClient *client, + gchar *action, + GUdevDevice *device, + gpointer user_data); +static void udev_mgr_update_menuitems (UdevMgr* self); +static void udev_mgr_check_if_usb_device_is_supported (UdevMgr* self, + GUdevDevice *device, + UdevMgrDeviceAction action); +static void udev_mgr_handle_webcam (UdevMgr* self, + GUdevDevice* device, + UdevMgrDeviceAction action); +static void udev_mgr_handle_scsi_device (UdevMgr* self, + GUdevDevice* device, + UdevMgrDeviceAction action); + +static void udev_mgr_cleanup_lists(gpointer data, gpointer self); +static void udev_mgr_cleanup_entries(gpointer data, gpointer self); + + +static void debug_device (UdevMgr* self, + GUdevDevice* device, + UdevMgrDeviceAction action); + + +struct _UdevMgr +{ + GObject parent_instance; + DbusmenuMenuitem* scanner_item; + DbusmenuMenuitem* webcam_item; + GUdevClient* client; + GHashTable* supported_usb_scanners; + GHashTable* supported_scsi_scanners; + GHashTable* scanners_present; + GHashTable* webcams_present; +}; + +const char *subsystems[3] = {"usb", "scsi", "video4linux"}; +const gchar* usb_subsystem = "usb"; +const gchar* scsi_subsystem = "scsi"; +const gchar* video4linux_subsystem = "video4linux"; + + +G_DEFINE_TYPE (UdevMgr, udev_mgr, G_TYPE_OBJECT); + +static void +udev_mgr_init (UdevMgr* self) +{ + self->client = NULL; + self->supported_usb_scanners = NULL; + self->scanners_present = NULL; + self->webcams_present = NULL; + self->client = g_udev_client_new (subsystems); + self->supported_usb_scanners = g_hash_table_new_full (g_str_hash, + g_str_equal, + g_free, + (GDestroyNotify)udev_mgr_cleanup_lists); + self->supported_scsi_scanners = g_hash_table_new_full (g_str_hash, + g_str_equal, + g_free, + (GDestroyNotify)udev_mgr_cleanup_lists); + self->scanners_present = g_hash_table_new_full (g_str_hash, + g_str_equal, + g_free, + g_free); + self->webcams_present = g_hash_table_new_full (g_str_hash, + g_str_equal, + g_free, + g_free); + + // load into memory all supported scanners ... + populate_usb_scanners (self->supported_usb_scanners); + populate_scsi_scanners (self->supported_scsi_scanners); + g_signal_connect (G_OBJECT (self->client), + "uevent", + G_CALLBACK (udev_mgr_uevent_cb), + self); +} + +static void +udev_mgr_cleanup_lists(gpointer data, gpointer self) +{ + GList* scanners = (GList*)data; + g_list_foreach (scanners, udev_mgr_cleanup_entries, NULL); + g_list_free(scanners); +} + +static void +udev_mgr_cleanup_entries(gpointer data, gpointer self) +{ + gchar* entry = (gchar*)data; + g_free(entry); +} + +static void +udev_mgr_finalize (GObject *object) +{ + UdevMgr* self = UDEV_MGR (object); + g_hash_table_destroy (self->supported_scsi_scanners); + g_hash_table_destroy (self->supported_usb_scanners); + g_hash_table_destroy (self->scanners_present); + g_hash_table_destroy (self->webcams_present); + G_OBJECT_CLASS (udev_mgr_parent_class)->finalize (object); +} + +static void +udev_mgr_class_init (UdevMgrClass *klass) +{ + GObjectClass* object_class = G_OBJECT_CLASS (klass); + object_class->finalize = udev_mgr_finalize; +} + +static void +udevice_mgr_device_list_iterator (gpointer data, gpointer userdata) +{ + g_return_if_fail (G_UDEV_IS_DEVICE (data)); + g_return_if_fail (UDEV_IS_MGR (userdata)); + + UdevMgr* self = UDEV_MGR (userdata); + + GUdevDevice* device = G_UDEV_DEVICE (data); + + const gchar* subsystem = NULL; + subsystem = g_udev_device_get_subsystem (device); + + if (g_strcmp0 (subsystem, "usb") == 0){ + udev_mgr_check_if_usb_device_is_supported (self, device, ADD); + } + else if (g_strcmp0 (subsystem, "video4linux") == 0){ + udev_mgr_handle_webcam (self, device, ADD); + } + else if (g_strcmp0 (subsystem, "scsi") == 0){ + udev_mgr_handle_scsi_device (self, device, ADD); + } + + g_object_unref (device); +} + + +static void udev_mgr_update_menuitems (UdevMgr* self) +{ + dbusmenu_menuitem_property_set_bool (self->scanner_item, + DBUSMENU_MENUITEM_PROP_VISIBLE, + g_hash_table_size (self->scanners_present) > 0); + + dbusmenu_menuitem_property_set_bool (self->webcam_item, + DBUSMENU_MENUITEM_PROP_VISIBLE, + g_hash_table_size (self->webcams_present) > 0); + +} + +static void udev_mgr_uevent_cb (GUdevClient *client, + gchar *action, + GUdevDevice *device, + gpointer user_data) +{ + g_return_if_fail (UDEV_IS_MGR (user_data)); + UdevMgr* self = UDEV_MGR (user_data); + g_return_if_fail (device != NULL); + + g_debug ("just received a UEVENT with an action : %s", action); + + UdevMgrDeviceAction udev_mgr_action = ADD; + + if (g_strcmp0 (action, "remove") == 0){ + udev_mgr_action = REMOVE; + } + + const gchar* subsystem = NULL; + subsystem = g_udev_device_get_subsystem (device); + + if (g_strcmp0 (subsystem, "usb") == 0){ + udev_mgr_check_if_usb_device_is_supported (self, + device, + udev_mgr_action); + } + else if (g_strcmp0 (subsystem, "video4linux") == 0){ + udev_mgr_handle_webcam (self, device, udev_mgr_action); + } + else if (g_strcmp0 (subsystem, "scsi") == 0){ + udev_mgr_handle_scsi_device (self, device, udev_mgr_action); + } +} + + +static void +udev_mgr_handle_webcam (UdevMgr* self, + GUdevDevice* device, + UdevMgrDeviceAction action) +{ + if (FALSE) + debug_device (self, device, action); + + const gchar* vendor; + const gchar* product; + + vendor = g_udev_device_get_property (device, "ID_VENDOR_ID"); + product = g_udev_device_get_property (device, "ID_MODEL_ID"); + + if (action == REMOVE){ + if (g_hash_table_lookup (self->webcams_present, product) == NULL){ + g_warning ("Got a remove event on a webcam device but we don't have that device in our webcam cache"); + return; + } + g_hash_table_remove (self->webcams_present, + product); + + } + else { + if (g_hash_table_lookup (self->webcams_present, product) != NULL){ + g_warning ("Got an ADD event on a webcam device but we already have that device in our webcam cache"); + return; + } + g_hash_table_insert (self->webcams_present, + g_strdup (product), + g_strdup (vendor)); + } + udev_mgr_update_menuitems (self); +} + +static void +debug_device (UdevMgr* self, + GUdevDevice* device, + UdevMgrDeviceAction action) +{ + /*const gchar* vendor; + const gchar* product; + const gchar* number; + const gchar* name; + + vendor = g_udev_device_get_property (device, "ID_VENDOR_ID"); + product = g_udev_device_get_property (device, "ID_MODEL_ID"); + number = g_udev_device_get_number (device); + name = g_udev_device_get_name (device); + + g_debug ("device vendor id %s , product id of %s , number of %s and name of %s", + g_strdup(vendor), + g_strdup(product), + g_strdup(number), + g_strdup(name)); + + const gchar *const *list; + const gchar *const *iter; + char propstr[500]; + guint32 namelen = 0, i; + + list = g_udev_device_get_property_keys(device); + + for (iter = list; iter && *iter; iter++) { + if (strlen(*iter) > namelen) + namelen = strlen(*iter); + } + namelen++; + + for (iter = list; iter && *iter; iter++) { + strcpy(propstr, *iter); + strcat(propstr, ":"); + for (i = 0; i < namelen - strlen(*iter); i++) + strcat(propstr, " "); + strcat(propstr, g_udev_device_get_property(device, *iter)); + g_debug("%s", propstr); + }*/ +} + +static void udev_mgr_handle_scsi_device (UdevMgr* self, + GUdevDevice* device, + UdevMgrDeviceAction action) +{ + const gchar* type = NULL; + type = g_udev_device_get_property (device, "TYPE"); + // apparently anything thats type 3 and SCSI is a Scanner + if (g_strcmp0 (type, "6") == 0){ + gchar* random_scanner_name = g_strdup_printf("%p--scanner", self); + g_hash_table_insert (self->scanners_present, + random_scanner_name, + g_strdup("Scanner")); + udev_mgr_update_menuitems (self); + return; + } + + // We only care about type 3 for the special cases below + if (g_strcmp0 (type, "3") != 0){ + return; + } + + const gchar* vendor = NULL; + vendor = g_udev_device_get_property (device, "VENDOR"); + + if (vendor == NULL) + return; + + GList* vendor_list = NULL; + vendor_list = g_hash_table_lookup (self->supported_scsi_scanners, + (gpointer)vendor); + if (vendor_list == NULL) + return; + + const gchar* model_id = NULL; + model_id = g_udev_device_get_property (device, "MODEL"); + + if (model_id == NULL) + return; + + GList* model_entry = NULL; + model_entry = g_list_find_custom (vendor_list, + model_id, + (GCompareFunc)g_strcmp0); + + if (model_entry != NULL){ + if (action == REMOVE){ + if (g_hash_table_lookup (self->scanners_present, g_strdup(vendor)) == NULL){ + g_warning ("Got an REMOVE event on a scanner device but we dont have that device in our scanners cache"); + } + else{ + g_hash_table_remove (self->scanners_present, vendor); + } + } + else{ + if (g_hash_table_lookup (self->scanners_present, g_strdup(vendor)) != NULL){ + g_warning ("Got an ADD event on a scanner device but we already have that device in our scanners cache"); + } + else{ + g_hash_table_insert (self->scanners_present, + g_strdup(vendor), + g_strdup(model_id)); + } + } + udev_mgr_update_menuitems (self); + } +} + +static void +udev_mgr_check_if_usb_device_is_supported (UdevMgr* self, + GUdevDevice *device, + UdevMgrDeviceAction action) +{ + const gchar* vendor = NULL; + debug_device (self, device, action); + + vendor = g_udev_device_get_property (device, "ID_VENDOR_ID"); + + if (vendor == NULL) + return; + + //g_debug ("vendor = %s", vendor); + + GList* vendor_list = NULL; + vendor_list = g_hash_table_lookup (self->supported_usb_scanners, + (gpointer)vendor); + if (vendor_list == NULL) + return; + + const gchar* model_id = NULL; + model_id = g_udev_device_get_property (device, "ID_MODEL_ID"); + + if (model_id == NULL) + return; + + GList* model_entry = NULL; + model_entry = g_list_find_custom(vendor_list, model_id, (GCompareFunc)g_strcmp0); + + if (model_entry != NULL){ + if (action == REMOVE){ + if (g_hash_table_lookup (self->scanners_present, g_strdup(vendor)) == NULL){ + g_warning ("Got an REMOVE event on a scanner device but we dont have that device in our scanners cache"); + } + else{ + g_hash_table_remove (self->scanners_present, vendor); + } + } + else{ + if (g_hash_table_lookup (self->scanners_present, g_strdup(vendor)) != NULL){ + g_warning ("Got an ADD event on a scanner device but we already have that device in our scanners cache"); + } + else{ + g_hash_table_insert (self->scanners_present, + g_strdup(vendor), + g_strdup(model_id)); + } + } + udev_mgr_update_menuitems (self); + } +} + +UdevMgr* udev_mgr_new (DbusmenuMenuitem* scanner, + DbusmenuMenuitem* webcam) +{ + UdevMgr* mgr = g_object_new (UDEV_TYPE_MGR, NULL); + mgr->scanner_item = scanner; + mgr->webcam_item = webcam; + + // Check for USB devices + GList* usb_devices_available = NULL; + usb_devices_available = g_udev_client_query_by_subsystem (mgr->client, + usb_subsystem); + if (usb_devices_available != NULL){ + g_list_foreach (usb_devices_available, + udevice_mgr_device_list_iterator, + mgr); + + g_list_free (usb_devices_available); + } + // Check for webcams + GList* video_devices_available = NULL; + video_devices_available = g_udev_client_query_by_subsystem (mgr->client, + video4linux_subsystem); + if (video_devices_available != NULL){ + g_list_foreach (video_devices_available, + udevice_mgr_device_list_iterator, + mgr); + + g_list_free (video_devices_available); + } + // Check for SCSI devices + GList* scsi_devices_available = NULL; + scsi_devices_available = g_udev_client_query_by_subsystem (mgr->client, + scsi_subsystem); + if (scsi_devices_available != NULL){ + g_list_foreach (scsi_devices_available, + udevice_mgr_device_list_iterator, + mgr); + g_list_free (scsi_devices_available); + } + return mgr; +} diff --git a/src/udev-mgr.h b/src/udev-mgr.h new file mode 100644 index 0000000..5119803 --- /dev/null +++ b/src/udev-mgr.h @@ -0,0 +1,62 @@ +/* +Copyright 2011 Canonical Ltd. + +Authors: + Conor Curran <conor.curran@canonical.com> + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef _UDEV_MGR_H_ +#define _UDEV_MGR_H_ + +#include <glib-object.h> +#include <libdbusmenu-glib/client.h> + +#include <gtk/gtk.h> +#if GTK_CHECK_VERSION(3, 0, 0) +#include <libdbusmenu-gtk3/menuitem.h> +#else +#include <libdbusmenu-gtk/menuitem.h> +#endif + +G_BEGIN_DECLS + +#define UDEV_TYPE_MGR (udev_mgr_get_type ()) +#define UDEV_MGR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UDEV_TYPE_MGR, UdevMgr)) +#define UDEV_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UDEV_TYPE_MGR, UdevMgrClass)) +#define UDEV_IS_MGR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UDEV_TYPE_MGR)) +#define UDEV_IS_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UDEV_TYPE_MGR)) +#define UDEV_MGR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UDEV_TYPE_MGR, UdevMgrClass)) + +typedef struct _UdevMgrClass UdevMgrClass; +typedef struct _UdevMgr UdevMgr; + +struct _UdevMgrClass +{ + GObjectClass parent_class; +}; + + +GType udev_mgr_get_type (void) G_GNUC_CONST; +UdevMgr* udev_mgr_new (DbusmenuMenuitem* scanner_item, + DbusmenuMenuitem* webcam_item); + +typedef enum { + ADD, + REMOVE +}UdevMgrDeviceAction; + +G_END_DECLS + +#endif /* _UDEV_MGR_H_ */ diff --git a/src/user-menu-mgr.c b/src/user-menu-mgr.c new file mode 100644 index 0000000..44c1960 --- /dev/null +++ b/src/user-menu-mgr.c @@ -0,0 +1,431 @@ +/* +Copyright 2011 Canonical Ltd. + +Authors: + Conor Curran <conor.curran@canonical.com> + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <libdbusmenu-glib/client.h> + +#include "user-menu-mgr.h" +#include "gconf-helper.h" +#include "dbus-shared-names.h" +#include "dbusmenu-shared.h" +#include "lock-helper.h" +#include "users-service-dbus.h" + +static GConfClient * gconf_client = NULL; +static DbusmenuMenuitem *switch_menuitem = NULL; + +struct _UserMenuMgr +{ + GObject parent_instance; + UsersServiceDbus* users_dbus_interface; + DbusmenuMenuitem* root_item; + gint user_count; + SessionDbus* session_dbus_interface; +}; + +static void activate_new_session (DbusmenuMenuitem * mi, + guint timestamp, + gpointer user_data); +static void activate_user_session (DbusmenuMenuitem *mi, + guint timestamp, + gpointer user_data); +static gint compare_users_by_username (const gchar *a, + const gchar *b); +static void activate_online_accounts (DbusmenuMenuitem *mi, + guint timestamp, + gpointer user_data); +static void user_menu_mgr_rebuild_items (UserMenuMgr *self, + gboolean greeter_mode); +static gboolean check_new_session (); +static void user_change (UsersServiceDbus *service, + const gchar *user_id, + gpointer user_data); + +static void ensure_gconf_client (); +static gboolean check_guest_session (void); +static void activate_guest_session (DbusmenuMenuitem * mi, + guint timestamp, + gpointer user_data); + + +G_DEFINE_TYPE (UserMenuMgr, user_menu_mgr, G_TYPE_OBJECT); + + +static void +user_menu_mgr_init (UserMenuMgr *self) +{ + self->users_dbus_interface = g_object_new (USERS_SERVICE_DBUS_TYPE, NULL); + self->root_item = dbusmenu_menuitem_new (); + g_signal_connect (G_OBJECT (self->users_dbus_interface), + "user-added", + G_CALLBACK (user_change), + self); + g_signal_connect (G_OBJECT (self->users_dbus_interface), + "user-removed", + G_CALLBACK (user_change), + self); +} + +static void +user_menu_mgr_finalize (GObject *object) +{ + /* TODO: Add deinitalization code here */ + G_OBJECT_CLASS (user_menu_mgr_parent_class)->finalize (object); +} + +static void +user_menu_mgr_class_init (UserMenuMgrClass *klass) +{ + GObjectClass* object_class = G_OBJECT_CLASS (klass); + //GObjectClass* parent_class = G_OBJECT_CLASS (klass); + + object_class->finalize = user_menu_mgr_finalize; +} + +/* Builds up the menu for us */ +static void +user_menu_mgr_rebuild_items (UserMenuMgr *self, gboolean greeter_mode) +{ + DbusmenuMenuitem *mi = NULL; + DbusmenuMenuitem *guest_mi = NULL; + GList *u; + UserData *user; + gboolean can_activate; + GList *children; + + /* Make sure we have a valid GConf client, and build one + if needed */ + ensure_gconf_client (); + + /* Check to see which menu items we're allowed to have */ + can_activate = users_service_dbus_can_activate_session (self->users_dbus_interface) && + !gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_USER, NULL); + + /* Remove the old menu items if that makes sense */ + children = dbusmenu_menuitem_take_children (self->root_item); + g_list_foreach (children, (GFunc)g_object_unref, NULL); + g_list_free (children); + + /* Set to NULL just incase we don't end up building one */ + users_service_dbus_set_guest_item(self->users_dbus_interface, NULL); + + /* Build all of the user switching items */ + if (can_activate == TRUE) + { + + if (check_new_session ()){ + switch_menuitem = dbusmenu_menuitem_new (); + dbusmenu_menuitem_property_set (switch_menuitem, + DBUSMENU_MENUITEM_PROP_TYPE, + MENU_SWITCH_TYPE); + dbusmenu_menuitem_property_set (switch_menuitem, + MENU_SWITCH_USER, + g_get_user_name()); + dbusmenu_menuitem_child_append (self->root_item, switch_menuitem); + g_signal_connect (G_OBJECT (switch_menuitem), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK (activate_new_session), + self->users_dbus_interface); + } + + if (check_guest_session ()) + { + guest_mi = dbusmenu_menuitem_new (); + dbusmenu_menuitem_property_set (guest_mi, + DBUSMENU_MENUITEM_PROP_TYPE, + USER_ITEM_TYPE); + dbusmenu_menuitem_property_set (guest_mi, + USER_ITEM_PROP_NAME, + _("Guest Session")); + dbusmenu_menuitem_property_set_bool (guest_mi, + USER_ITEM_PROP_LOGGED_IN, + FALSE); + dbusmenu_menuitem_child_append (self->root_item, guest_mi); + g_signal_connect (G_OBJECT (guest_mi), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK (activate_guest_session), + self); + users_service_dbus_set_guest_item (self->users_dbus_interface, + guest_mi); + } + + GList * users = NULL; + users = users_service_dbus_get_user_list (self->users_dbus_interface); + self->user_count = g_list_length(users); + + gboolean user_menu_is_visible = FALSE; + + if (!greeter_mode){ + user_menu_is_visible = self->user_count > 1; + } + + session_dbus_set_user_menu_visibility (self->session_dbus_interface, + user_menu_is_visible); + + if (self->user_count > MINIMUM_USERS && self->user_count < MAXIMUM_USERS) { + users = g_list_sort (users, (GCompareFunc)compare_users_by_username); + } + + for (u = users; u != NULL; u = g_list_next (u)) { + user = u->data; + g_debug ("%p: %s", user, user->real_name); + user->service = self->users_dbus_interface; + + if (g_strcmp0(user->user_name, "guest") == 0) { + /* Check to see if the guest has sessions and so therefore should + get a check mark. */ + if (user->sessions != NULL) { + dbusmenu_menuitem_property_set_bool (guest_mi, + USER_ITEM_PROP_LOGGED_IN, + TRUE); + } + /* If we're showing user accounts, keep going through the list */ + if (self->user_count > MINIMUM_USERS && self->user_count < MAXIMUM_USERS) { + continue; + } + /* If not, we can stop here */ + break; + } + + if (self->user_count > MINIMUM_USERS && self->user_count < MAXIMUM_USERS) { + mi = dbusmenu_menuitem_new (); + dbusmenu_menuitem_property_set (mi, + DBUSMENU_MENUITEM_PROP_TYPE, + USER_ITEM_TYPE); + if (user->real_name_conflict) { + gchar * conflictedname = g_strdup_printf("%s (%s)", user->real_name, user->user_name); + dbusmenu_menuitem_property_set (mi, USER_ITEM_PROP_NAME, conflictedname); + g_free(conflictedname); + } else { + //g_debug ("%i %s", (gint)user->uid, user->real_name); + //g_debug ("users uid = %i", (gint)user->uid); + //g_debug ("users real name = %s", user->real_name); + if (user == NULL){ + g_debug ("USER pointer is NULL"); + return; + } + g_debug ("%p: %s", user, user->real_name); + + dbusmenu_menuitem_property_set (mi, + USER_ITEM_PROP_NAME, + user->real_name); + } + dbusmenu_menuitem_property_set_bool (mi, + USER_ITEM_PROP_LOGGED_IN, + user->sessions != NULL); + if (user->icon_file != NULL && user->icon_file[0] != '\0') { + dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, user->icon_file); + } else { + dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, USER_ITEM_ICON_DEFAULT); + } + + gboolean logged_in = g_strcmp0 (user->user_name, g_get_user_name()) == 0; + dbusmenu_menuitem_property_set_bool (mi, + USER_ITEM_PROP_IS_CURRENT_USER, + logged_in); + if (logged_in == TRUE){ + g_debug ("about to set the users real name to %s for user %s", + user->real_name, user->user_name); + session_dbus_set_users_real_name (self->session_dbus_interface, user->real_name); + } + + dbusmenu_menuitem_child_append (self->root_item, mi); + g_signal_connect (G_OBJECT (mi), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK (activate_user_session), + user); + user->menuitem = mi; + } + } + g_list_free(users); + } + // Add the online accounts and separator + DbusmenuMenuitem * separator1 = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (separator1, + DBUSMENU_MENUITEM_PROP_TYPE, + DBUSMENU_CLIENT_TYPES_SEPARATOR); + dbusmenu_menuitem_child_append (self->root_item, separator1); + DbusmenuMenuitem * online_accounts_item = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (online_accounts_item, + DBUSMENU_MENUITEM_PROP_TYPE, + DBUSMENU_CLIENT_TYPES_DEFAULT); + dbusmenu_menuitem_property_set (online_accounts_item, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Online Accounts…")); + + g_signal_connect (G_OBJECT (online_accounts_item), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK (activate_online_accounts), + NULL); + + dbusmenu_menuitem_child_append (self->root_item, online_accounts_item); +} + +/* Checks to see if we can create sessions */ +// TODO what is this ? +static gboolean +check_new_session () +{ + return TRUE; +} + +/* Check to see if the lockdown key is protecting from + locking the screen. If not, lock it. */ +static void +lock_if_possible (void) { + ensure_gconf_client (); + + if (!gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_SCREENSAVER, NULL)) { + lock_screen(NULL, 0, NULL); + } + + return; +} + + +/* Starts a new generic session */ +static void +activate_new_session (DbusmenuMenuitem * mi, guint timestamp, gpointer user_data) +{ + lock_if_possible(); + + users_service_dbus_show_greeter (USERS_SERVICE_DBUS(user_data)); + + return; +} + +/* Activates a session for a particular user. */ +static void +activate_user_session (DbusmenuMenuitem *mi, guint timestamp, gpointer user_data) +{ + UserData *user = (UserData *)user_data; + UsersServiceDbus *service = user->service; + + lock_if_possible(); + + users_service_dbus_activate_user_session (service, user); +} + +/* Comparison function to look into the UserData struct + to compare by using the username value */ +static gint +compare_users_by_username (const gchar *a, + const gchar *b) +{ + UserData *user1 = (UserData *)a; + UserData *user2 = (UserData *)b; + + gint retval = g_strcmp0 (user1->real_name, user2->real_name); + + /* If they're the same, they're both in conflict. */ + if (retval == 0) { + user1->real_name_conflict = TRUE; + user2->real_name_conflict = TRUE; + } + + return retval; +} + +// TODO +// Wait until dialog is complete to find out name to pass +// to the control centre. +static void +activate_online_accounts (DbusmenuMenuitem *mi, + guint timestamp, + gpointer user_data) +{ + GError * error = NULL; + if (!g_spawn_command_line_async("gnome-control-center online-accounts", &error)) + { + g_warning("Unable to show control centre: %s", error->message); + g_error_free(error); + } +} + +/* Signal called when a user is added. It updates the count and + rebuilds the menu */ +static void +user_change (UsersServiceDbus *service, + const gchar *user_id, + gpointer user_data) +{ + //DbusmenuMenuitem *root = (DbusmenuMenuitem *)user_data; + // TODO sort this out. + //rebuild_user_items (root, service); + return; +} + +/* Ensures that we have a GConf client and if we build one + set up the signal handler. */ +static void +ensure_gconf_client () +{ + if (!gconf_client) { + gconf_client = gconf_client_get_default (); + gconf_client_add_dir (gconf_client, LOCKDOWN_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + gconf_client_add_dir (gconf_client, KEYBINDING_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + } +} + +DbusmenuMenuitem* +user_mgr_get_root_item (UserMenuMgr* self) +{ + return self->root_item; +} + +/* Checks to see if we should show the guest suession item */ +static gboolean +check_guest_session (void) +{ + if (geteuid() < 500) { + /* System users shouldn't have guest account shown. Mosly + this would be the case of the guest user itself. */ + return FALSE; + } + + return TRUE; +} + +/* Called when someone clicks on the guest session item. */ +static void +activate_guest_session (DbusmenuMenuitem * mi, guint timestamp, gpointer user_data) +{ + g_return_if_fail (USER_IS_MENU_MGR (user_data)); + UserMenuMgr* user_mgr = USER_MENU_MGR(user_data); + UsersServiceDbus *service = user_mgr->users_dbus_interface; + + lock_if_possible(); + + if (users_service_dbus_activate_guest_session(service)) { + return; + } +} + + +/* + * Clean Entry Point + */ +UserMenuMgr* user_menu_mgr_new (SessionDbus* session_dbus, gboolean greeter_mode) +{ + UserMenuMgr* user_mgr = g_object_new (USER_TYPE_MENU_MGR, NULL); + user_mgr->session_dbus_interface = session_dbus; + user_menu_mgr_rebuild_items (user_mgr, greeter_mode); + return user_mgr; +} + + diff --git a/src/user-menu-mgr.h b/src/user-menu-mgr.h new file mode 100644 index 0000000..01823e7 --- /dev/null +++ b/src/user-menu-mgr.h @@ -0,0 +1,54 @@ +/* +Copyright 2011 Canonical Ltd. + +Authors: + Conor Curran <conor.curran@canonical.com> + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + + +#ifndef _USER_MENU_MGR_H_ +#define _USER_MENU_MGR_H_ + + +#include <glib-object.h> +#include <libdbusmenu-gtk3/menuitem.h> + +#include "session-dbus.h" + +G_BEGIN_DECLS + +#define USER_TYPE_MENU_MGR (user_menu_mgr_get_type ()) +#define USER_MENU_MGR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), USER_TYPE_MENU_MGR, UserMenuMgr)) +#define USER_MENU_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), USER_TYPE_MENU_MGR, UserMenuMgrClass)) +#define USER_IS_MENU_MGR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), USER_TYPE_MENU_MGR)) +#define USER_IS_MENU_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), USER_TYPE_MENU_MGR)) +#define USER_MENU_MGR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), USER_TYPE_MENU_MGR, UserMenuMgrClass)) + +typedef struct _UserMenuMgrClass UserMenuMgrClass; +typedef struct _UserMenuMgr UserMenuMgr; + +struct _UserMenuMgrClass +{ + GObjectClass parent_class; +}; + +GType user_menu_mgr_get_type (void) G_GNUC_CONST; +UserMenuMgr* user_menu_mgr_new (SessionDbus* session_dbus, + gboolean greeter_mode); + +DbusmenuMenuitem* user_mgr_get_root_item (UserMenuMgr* self); +G_END_DECLS + +#endif /* _USER_MENU_MGR_H_ */ diff --git a/src/user-widget.c b/src/user-widget.c new file mode 100644 index 0000000..6495e80 --- /dev/null +++ b/src/user-widget.c @@ -0,0 +1,343 @@ +/* +Copyright 2011 Canonical Ltd. + +Authors: + Conor Curran <conor.curran@canonical.com> + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <glib/gi18n.h> +#include <gtk/gtk.h> +#include <glib.h> +#include <libindicator/indicator-image-helper.h> +#include "user-widget.h" +#include "dbus-shared-names.h" + + +typedef struct _UserWidgetPrivate UserWidgetPrivate; + +struct _UserWidgetPrivate +{ + DbusmenuMenuitem* twin_item; + GtkWidget* user_image; + GtkWidget* user_name; + GtkWidget* container; + GtkWidget* tick_icon; + gboolean logged_in; + gboolean sessions_active; +}; + +#define USER_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), USER_WIDGET_TYPE, UserWidgetPrivate)) + +/* Prototypes */ +static void user_widget_class_init (UserWidgetClass *klass); +static void user_widget_init (UserWidget *self); +static void user_widget_dispose (GObject *object); +static void user_widget_finalize (GObject *object); + +static void user_widget_set_twin_item (UserWidget* self, + DbusmenuMenuitem* twin_item); +// keyevent consumers +static gboolean user_widget_button_release_event (GtkWidget *menuitem, + GdkEventButton *event); +// Dbusmenuitem properties update callback +static void user_widget_property_update (DbusmenuMenuitem* item, + gchar* property, + GVariant* value, + gpointer userdata); +#if GTK_CHECK_VERSION(3, 0, 0) +static gboolean user_widget_primitive_draw_cb_gtk_3 (GtkWidget *image, + cairo_t* cr, + gpointer user_data); +#else +static gboolean user_widget_primitive_draw_cb (GtkWidget *image, + GdkEventExpose *event, + gpointer user_data); +#endif + +G_DEFINE_TYPE (UserWidget, user_widget, GTK_TYPE_MENU_ITEM); + +static void +user_widget_class_init (UserWidgetClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + widget_class->button_release_event = user_widget_button_release_event; + + g_type_class_add_private (klass, sizeof (UserWidgetPrivate)); + + gobject_class->dispose = user_widget_dispose; + gobject_class->finalize = user_widget_finalize; +} + +static void +user_widget_init (UserWidget *self) +{ + UserWidgetPrivate * priv = USER_WIDGET_GET_PRIVATE(self); + + gint padding = 0; + gtk_widget_style_get (GTK_WIDGET(self), + "horizontal-padding", + &padding, + NULL); + + priv->user_image = NULL; + priv->user_name = NULL; + priv->logged_in = FALSE; + priv->sessions_active = FALSE; + priv->container = NULL; + priv->tick_icon = NULL; + + // Create the UI elements. + priv->user_image = gtk_image_new (); + + // Just for now set the image to the default avator image + GdkPixbuf* pixbuf = NULL; + GError* error = NULL; + pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), + "avatar-default", + 32, + GTK_ICON_LOOKUP_FORCE_SIZE, + &error); + + if (pixbuf == NULL || error != NULL) { + g_warning ("Could not load the default avatar image for some reason"); + } + else{ + gtk_image_set_from_pixbuf (GTK_IMAGE(priv->user_image), pixbuf); + g_object_unref (pixbuf); + } + + priv->user_name = gtk_label_new (""); + priv->container = gtk_hbox_new (FALSE, 0); + priv->tick_icon = gtk_image_new_from_icon_name ("account-logged-in", + GTK_ICON_SIZE_MENU); + gtk_misc_set_alignment(GTK_MISC(priv->tick_icon), 1.0, 0.5); + + // Pack it together + gtk_box_pack_start (GTK_BOX (priv->container), + priv->user_image, + FALSE, + FALSE, + 0); + gtk_box_pack_start (GTK_BOX (priv->container), + priv->user_name, + FALSE, + FALSE, + 3); + gtk_box_pack_start (GTK_BOX(priv->container), + priv->tick_icon, + FALSE, + FALSE, 5); + + gtk_widget_show_all (priv->container); + gtk_container_add (GTK_CONTAINER (self), priv->container); + + gtk_widget_show_all (priv->tick_icon); + gtk_widget_set_no_show_all (priv->tick_icon, TRUE); + gtk_widget_hide (priv->tick_icon); + + // Fetch the drawing context. + #if GTK_CHECK_VERSION(3, 0, 0) + g_signal_connect_after (GTK_WIDGET(self), "draw", + G_CALLBACK(user_widget_primitive_draw_cb_gtk_3), + GTK_WIDGET(self)); + #else + g_signal_connect_after (GTK_WIDGET(self), "expose-event", + G_CALLBACK(user_widget_primitive_draw_cb), + GTK_WIDGET(self)); + #endif +} + +static void +user_widget_dispose (GObject *object) +{ + //UserWidgetPrivate * priv = USER_WIDGET_GET_PRIVATE(USER_WIDGET(object)); + + G_OBJECT_CLASS (user_widget_parent_class)->dispose (object); +} + +// TODO tidy up image and name +static void +user_widget_finalize (GObject *object) +{ + G_OBJECT_CLASS (user_widget_parent_class)->finalize (object); +} + +#if GTK_CHECK_VERSION(3, 0, 0) + +// Draw the radio dot and/or green check mark +// TODO handle drawing of green check mark +static gboolean +user_widget_primitive_draw_cb_gtk_3 (GtkWidget *widget, + cairo_t* cr, + gpointer user_data) +{ + + g_return_val_if_fail(IS_USER_WIDGET(user_data), FALSE); + UserWidget* meta = USER_WIDGET(user_data); + UserWidgetPrivate * priv = USER_WIDGET_GET_PRIVATE(meta); + + // Draw dot only when user is the current user. + if (!dbusmenu_menuitem_property_get_bool (priv->twin_item, + USER_ITEM_PROP_IS_CURRENT_USER)){ + return FALSE; + } + + GtkStyle *style; + gdouble x, y; + gdouble offset = 15.0; + + style = gtk_widget_get_style (widget); + + GtkAllocation allocation; + gtk_widget_get_allocation (widget, &allocation); + x = allocation.x + 13; + y = offset; + + cairo_arc (cr, x, y, 3.0, 0.0, 2 * G_PI);; + + cairo_set_source_rgb (cr, style->fg[gtk_widget_get_state(widget)].red/65535.0, + style->fg[gtk_widget_get_state(widget)].green/65535.0, + style->fg[gtk_widget_get_state(widget)].blue/65535.0); + cairo_fill (cr); + + return FALSE; +} + +// GTK 2 Expose handler +#else + +// Draw the triangle if the player is running ... +static gboolean +user_widget_primitive_draw_cb (GtkWidget *widget, + GdkEventExpose *event, + gpointer user_data) +{ + /* + g_return_val_if_fail(IS_USER_WIDGET(user_data), FALSE); + UserWidget* meta = USER_WIDGET(user_data); + UserWidgetPrivate * priv = USER_WIDGET_GET_PRIVATE(meta); + + GtkStyle *style; + cairo_t *cr; + int x, y, arrow_width, arrow_height; + + gint offset = 3; + arrow_width = 5; + arrow_height = 9; + + style = gtk_widget_get_style (widget); + + cr = (cairo_t*) gdk_cairo_create (gtk_widget_get_window (widget)); + + GtkAllocation allocation; + gtk_widget_get_allocation (widget, &allocation); + x = allocation.x; + y = allocation.y; + + // Draw player icon + if (priv->icon_buf != NULL){ + gdk_cairo_set_source_pixbuf (cr, + priv->icon_buf, + x + arrow_width + 1, + y + offset); + cairo_paint (cr); + } + + // Draw triangle but only if the player is running. + if (dbusmenu_menuitem_property_get_bool (priv->twin_item, + DBUSMENU_METADATA_MENUITEM_PLAYER_RUNNING)){ + y += (double)arrow_height/2.0 + offset; + cairo_set_line_width (cr, 1.0); + + cairo_move_to (cr, x, y); + cairo_line_to (cr, x, y + arrow_height); + cairo_line_to (cr, x + arrow_width, y + (double)arrow_height/2.0); + cairo_close_path (cr); + cairo_set_source_rgb (cr, style->fg[gtk_widget_get_state(widget)].red/65535.0, + style->fg[gtk_widget_get_state(widget)].green/65535.0, + style->fg[gtk_widget_get_state(widget)].blue/65535.0); + cairo_fill (cr); + } + + cairo_destroy (cr);*/ + return FALSE; +} +#endif + + +/* Suppress/consume keyevents */ +static gboolean +user_widget_button_release_event (GtkWidget *menuitem, + GdkEventButton *event) +{ + return FALSE; +} + +static void +user_widget_property_update (DbusmenuMenuitem* item, gchar* property, + GVariant* value, gpointer userdata) +{ + g_return_if_fail (IS_USER_WIDGET (userdata)); + //gtk_widget_queue_redraw (GTK_WIDGET(userdata)); +} + + +static void +user_widget_set_twin_item (UserWidget* self, + DbusmenuMenuitem* twin_item) +{ + UserWidgetPrivate* priv = USER_WIDGET_GET_PRIVATE(self); + priv->twin_item = twin_item; + g_signal_connect( G_OBJECT(priv->twin_item), "property-changed", + G_CALLBACK(user_widget_property_update), self); + + const gchar * icon_name = dbusmenu_menuitem_property_get (twin_item, + USER_ITEM_PROP_ICON); + gtk_label_set_label (GTK_LABEL (priv->user_name), + dbusmenu_menuitem_property_get (twin_item, USER_ITEM_PROP_NAME)); + + if (dbusmenu_menuitem_property_get_bool (twin_item, USER_ITEM_PROP_LOGGED_IN)) { + g_debug ("%s USER HAS ACTIVE SESSIONS", + dbusmenu_menuitem_property_get (twin_item, USER_ITEM_PROP_NAME)); + gtk_widget_show(priv->tick_icon); + } + else { + g_debug ("%s USER DOESN'T HAVE ACTIVE SESSIONS", + dbusmenu_menuitem_property_get (twin_item, USER_ITEM_PROP_NAME)); + gtk_widget_hide(priv->tick_icon); + } + + g_debug("Using user icon for '%s' from file: %s", + dbusmenu_menuitem_property_get(twin_item, USER_ITEM_PROP_NAME), icon_name); + +} + + /** + * transport_new: + * @returns: a new #UserWidget. + **/ +GtkWidget* +user_widget_new(DbusmenuMenuitem *item) +{ + GtkWidget* widget = g_object_new(USER_WIDGET_TYPE, NULL); + user_widget_set_twin_item ( USER_WIDGET(widget), item ); + return widget; +} diff --git a/src/user-widget.h b/src/user-widget.h new file mode 100644 index 0000000..e1f6d1a --- /dev/null +++ b/src/user-widget.h @@ -0,0 +1,54 @@ +/* +Copyright 2011 Canonical Ltd. + +Authors: + Conor Curran <conor.curran@canonical.com> + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see <http://www.gnu.org/licenses/>. +*/ +#ifndef __USER_WIDGET_H__ +#define __USER_WIDGET_H__ + +#include <gtk/gtk.h> +#if GTK_CHECK_VERSION(3, 0, 0) +#include <libdbusmenu-gtk3/menuitem.h> +#else +#include <libdbusmenu-gtk/menuitem.h> +#endif + +G_BEGIN_DECLS + +#define USER_WIDGET_TYPE (user_widget_get_type ()) +#define USER_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), USER_WIDGET_TYPE, UserWidget)) +#define USER_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), USER_WIDGET_TYPE, UserWidgetClass)) +#define IS_USER_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), USER_WIDGET_TYPE)) +#define IS_USER_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), USER_WIDGET_TYPE)) +#define USER_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), USER_WIDGET_TYPE, UserWidgetClass)) + +typedef struct _UserWidget UserWidget; +typedef struct _UserWidgetClass UserWidgetClass; + +struct _UserWidgetClass { + GtkMenuItemClass parent_class; +}; + +struct _UserWidget { + GtkMenuItem parent; +}; + +GType user_widget_get_type (void); +GtkWidget* user_widget_new(DbusmenuMenuitem *twin_item); + +G_END_DECLS + +#endif diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index 087378c..e7507a4 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -36,6 +36,7 @@ #include "accounts-service-client.h" #include "consolekit-manager-client.h" #include "consolekit-session-client.h" +#include "consolekit-seat-client.h" #define CK_ADDR "org.freedesktop.ConsoleKit" #define CK_SESSION_IFACE "org.freedesktop.ConsoleKit.Session" @@ -195,15 +196,50 @@ static void create_display_manager_proxy (UsersServiceDbus *self) { UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (self); + DBusGProxy *dm_proxy = NULL; + GError *error = NULL; + const gchar *cookie = NULL; + gchar *seat = NULL; + + cookie = g_getenv ("XDG_SESSION_COOKIE"); + if (cookie == NULL || cookie[0] == 0) + { + g_warning ("Failed to get DisplayManager proxy: XDG_SESSION_COOKIE undefined."); + return; + } + + dm_proxy = dbus_g_proxy_new_for_name (priv->system_bus, + "org.freedesktop.DisplayManager", + "/org/freedesktop/DisplayManager", + "org.freedesktop.DisplayManager"); + + if (!dm_proxy) + { + g_warning ("Failed to get DisplayManager proxy."); + return; + } + + /* Now request the proper seat */ + if (!dbus_g_proxy_call (dm_proxy, "GetSeatForCookie", &error, + G_TYPE_STRING, cookie, G_TYPE_INVALID, + DBUS_TYPE_G_OBJECT_PATH, &seat, G_TYPE_INVALID)) + { + g_warning ("Failed to get DisplayManager seat proxy: %s", error->message); + g_object_unref (dm_proxy); + g_error_free (error); + return; + } + g_object_unref (dm_proxy); priv->display_manager_proxy = dbus_g_proxy_new_for_name (priv->system_bus, "org.freedesktop.DisplayManager", - "/org/freedesktop/DisplayManager", - "org.freedesktop.DisplayManager"); + seat, + "org.freedesktop.DisplayManager.Seat"); + g_free (seat); if (!priv->display_manager_proxy) { - g_warning ("Failed to get DisplayManager proxy."); + g_warning ("Failed to get DisplayManager seat proxy."); return; } } @@ -280,6 +316,28 @@ create_ck_proxy (UsersServiceDbus *self) } } +/* Get the initial sessions when starting up */ +static void +get_cksessions_cb (DBusGProxy *proxy, GPtrArray * sessions, GError * error, gpointer userdata) +{ + if (error != NULL) { + g_warning("Unable to get initial sessions: %s", error->message); + return; + } + + /* If there's no error we should at least get an + array of zero entries */ + g_return_if_fail(sessions != NULL); + g_debug("Got %d initial sessions", sessions->len); + + int i; + for (i = 0; i < sessions->len; i++) { + seat_proxy_session_added(proxy, g_ptr_array_index(sessions, i), USERS_SERVICE_DBUS(userdata)); + } + + return; +} + static void create_seat_proxy (UsersServiceDbus *self) { @@ -328,6 +386,10 @@ create_seat_proxy (UsersServiceDbus *self) G_CALLBACK (seat_proxy_session_removed), self, NULL); + + org_freedesktop_ConsoleKit_Seat_get_sessions_async (priv->seat_proxy, get_cksessions_cb, self); + + return; } static void @@ -521,7 +583,11 @@ static void add_sessions_for_user (UsersServiceDbus *self, UserData *user) { - g_return_if_fail(IS_USERS_SERVICE_DBUS(self)); + g_return_if_fail (IS_USERS_SERVICE_DBUS(self)); + + g_debug ("!!!!!!!!!! - add_sessions_for_user %i %s", + (int)user->uid, user->user_name); + UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (self); GError *error; GPtrArray *sessions; @@ -780,7 +846,7 @@ users_service_dbus_show_greeter (UsersServiceDbus *self) { g_return_val_if_fail(IS_USERS_SERVICE_DBUS(self), FALSE); UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (self); - return org_freedesktop_DisplayManager_show_greeter(priv->display_manager_proxy, NULL); + return org_freedesktop_DisplayManager_Seat_switch_to_greeter(priv->display_manager_proxy, NULL); } /* Activates the guest account if it can. */ @@ -789,7 +855,7 @@ users_service_dbus_activate_guest_session (UsersServiceDbus *self) { g_return_val_if_fail(IS_USERS_SERVICE_DBUS(self), FALSE); UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (self); - return org_freedesktop_DisplayManager_switch_to_guest(priv->display_manager_proxy, NULL); + return org_freedesktop_DisplayManager_Seat_switch_to_guest(priv->display_manager_proxy, "", NULL); } /* Activates a specific user */ @@ -799,7 +865,7 @@ users_service_dbus_activate_user_session (UsersServiceDbus *self, { g_return_val_if_fail(IS_USERS_SERVICE_DBUS(self), FALSE); UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (self); - return org_freedesktop_DisplayManager_switch_to_user(priv->display_manager_proxy, user->user_name, NULL); + return org_freedesktop_DisplayManager_Seat_switch_to_user(priv->display_manager_proxy, user->user_name, "", NULL); } gboolean |