Changeset 855
- Timestamp:
- Mar 14, 2016, 12:01:47 PM (5 years ago)
- Location:
- ldm/trunk
- Files:
-
- 66 added
- 16 deleted
- 42 edited
Legend:
- Unmodified
- Added
- Removed
-
ldm/trunk/fuentes/.pc/applied-patches
r517 r855 1 1 remove-hackish-gettext-function 2 lliurex-patches 3 ldm_verbose_ ssh.patch4 ldm_background .patch5 profiled_thinclients 6 other_languages 2 lliurex-patches_ported_from_2_2_13 3 ldm_verbose_patch_integrated_from_2_2_13 4 ldm_background_ported_from_2_2_13 5 profiled_thinclients_ported_from_2_2_13 6 other_languages_ported_from_2_2_13 -
ldm/trunk/fuentes/.pc/remove-hackish-gettext-function/share/ldm-script.in
r516 r855 60 60 61 61 for SCRIPT in $(find -L $RCDIRS -type f -name "$SCRIPTS" -printf '%f\n' | 62 tr ' ' '\n' | egrep ^[ 0-9a-zA-Z_\-]*$ | sort -u)62 tr ' ' '\n' | egrep ^[[:alnum:]_\-]*$ | sort -u) 63 63 do 64 64 # only source the first instance of the script found -
ldm/trunk/fuentes/ChangeLog
r516 r855 1 1588 Vagrant Cascadian 2016-02-07 {ldm-2.2.18} 2 Version 2.2.18 3 4 1587 Alkis Georgopoulos 2016-01-18 5 Display LDM only in the first monitor (LP: #693151). 6 7 1586 Alkis Georgopoulos 2015-12-08 8 DesktopNames replaced X-LightDM-DesktopName in xsession files 9 (GNOME: #727546). 10 11 1585 Alkis Georgopoulos 2015-12-05 12 "break" is not valid inside "case". 13 14 1584 Vagrant Cascadian 2015-10-08 {ldm-2.2.17} 15 Version 2.2.17 16 17 1583 Vagrant Cascadian 2015-10-08 18 screen.d/ldm: Rewrite test for LDM_DIRECTX to avoid using a negated 19 boolean_is_true check. 20 21 1582 Alkis Georgopoulos 2015-10-08 22 Xorg after 1.17 (not 1.16) needs `-listen tcp`. 23 24 1581 Alkis Georgopoulos 2015-10-03 25 Xorg after 1.16 needs `-listen tcp`. 26 27 1580 Alkis Georgopoulos 2015-09-22 28 ldm-script: fix regression from r1579, it needs [:alnum:], not 29 [:alpha:]. 30 31 1579 Alkis Georgopoulos 2015-09-02 32 Replace [A-Za-z] with [:alpha:] to avoid locale issues (LP: 33 #1491066). 34 35 1578 Vagrant Cascadian 2015-08-19 {ldm-2.2.16} 36 Version 2.2.16 37 38 1577 Alkis Georgopoulos 2015-05-22 39 Export DESKTOP_SESSION and XDG_CURRENT_DESKTOP to the client 40 environment and try to avoid an empty LDM_SESSION. These, along 41 with r2646 from ltsp-client, make Unity work for both thin and fat 42 clients in Ubuntu 14.04, and possibly fix other DE issues as well. 43 The /etc/X11/Xsession.d/40-ltsp-{client|server} workarounds were 44 not effective and can now be completely dropped from the Ubuntu 45 packaging. 46 47 1576 Alkis Georgopoulos 2015-05-18 48 Generalize LDM_12HOURCLOCK to LDM_CLOCK_FORMAT. 49 50 1575 Vagrant Cascadian 2015-02-01 51 Remove rc.d hook to set LIBGL_ALWAYS_INDIRECT=true, as it causes 52 problems with several common desktops, and can be enabled 53 on a per-client basis by setting CLIENT_ENV in lts.conf. 54 https://bugs.debian.org/767764 55 56 1574 Vagrant Cascadian 2014-10-21 {ldm-2.2.15} 57 Version 2.2.15 58 59 1573 Vagrant Cascadian 2014-09-23 60 dmrc-processing: Use do_ssh function rather than duplicating the 61 ssh call. 62 63 1572 Vagrant Cascadian 2014-09-23 64 dmrc-processing hook: Compare desktop session against local 65 /usr/share/xsessions/*.desktop when running as a fat client. 66 https://bugs.launchpad.net/ltsp/+bug/1272889 67 68 1571 Vagrant Cascadian 2014-09-23 69 Remove further traces of halt-check hook. 70 71 1570 Vagrant Cascadian 2014-09-23 72 Remove check for halting when SHUTDOWN_TIME is set, implemented 73 in LTSP instead. https://bugs.launchpad.net/ltsp/+bug/604908 74 75 1569 Jakob Unterwurzacher 2014-09-22 76 ssh: Set ConnectTimeout=10 77 78 ConnectTimeout should be less than the timeout ssh_chat passes to 79 expect, so we get the error message from ssh before expect gives up 80 (30 seconds). 81 82 Also slightly increase the log level for spawning ssh to INFO. 83 84 1568 Jakob Unterwurzacher 2014-09-22 85 ssh: Make sure expect() notices if ssh dies after finding a match 86 87 Before this patch, the error message "ssh: connect to host server 88 port 22: Connection refused" was sometime mistaken as a prompt 89 because it contains a colon. This caused a 30 second delay. 90 91 1567 Jakob Unterwurzacher 2014-09-22 92 ssh: expect() must handle EINTR 93 94 Otherwise, we do not capture the error message from ssh reliably as 95 select() may be interrupted by SIGCHLD before we read the message. 96 97 1566 Jakob Unterwurzacher 2014-09-22 98 ssh: Also log the error message from ssh 99 100 1565 Jakob Unterwurzacher 2014-09-22 101 ssh: De-duplicate message handling code 102 103 Clean-up step for the previous patch. 104 105 1564 Jakob Unterwurzacher 2014-09-22 106 ssh: Display specific error message if available 107 108 This way, we get a proper "Permission denied" for a wrong password. 109 Horrible code duplication is fixed in the next patch. 110 111 1563 Jakob Unterwurzacher 2014-09-22 112 ssh: Make expect() read all available data even if the child 113 has exited 114 115 Implemented by checking if the child has exited *after* reading 116 all data. That way, we capture the error message. 117 118 1562 Jakob Unterwurzacher 2014-09-22 119 ssh: Remove superfluous timeout.tv_sec check in expect() 120 121 Timeout is already handled earlier. Checking for timeout.tv_sec == 122 0 is a bug as it may be zero under normal circumstances. 123 124 1561 Vagrant Cascadian 2014-09-20 125 rc.d/I01-halt-check: Use poweroff instead of halt. 126 127 1560 Vagrant Cascadian 2014-09-20 128 rc.d/I01-halt-check: Return if SHUTDOWN_TIME is not set. 129 130 1559 Vagrant Cascadian 2014-09-20 131 rc.d/I01-halt-check: Explicitly return 0. 132 133 1558 Vagrant Cascadian 2014-09-11 134 Fix typo: conditionally enable "-nolisten tcp" based on LDM_DIRECTX. 135 136 1557 Vagrant Cascadian 2014-09-10 137 Disable listening on tcp, unless using LDM_DIRECTX. Thanks to 138 Denis Croombs for reporting the issue! 139 140 1556 Vagrant Cascadian 2014-09-10 141 Remove support for running without xinitrc. 142 143 1555 Vagrant Cascadian 2014-08-05 {ldm-2.2.14} 144 version 2.2.14 145 146 1554 ben-Nabiy Derush 2014-07-31 147 Updated according to vagrantc suggestions. Moved tests outside of 148 function, reduced variables, so on... 149 150 1553 ben-Nabiy Derush 2014-07-31 151 Added opt-in ssh_hashpass function 152 153 1552 ben-Nabiy Derush 2014-07-31 154 Added ldm_getenv_bool_default 155 156 1551 ben-Nabiy Derush 2014-07-28 157 Revised README-DEVELOPMENT-POLICY to clarify whitespace changes 158 in existing code needing a separate merge request. 159 160 1550 ben-Nabiy Derush 2014-07-28 161 indent -kr -i4 -nut -c50 -psl 162 163 1549 ben-Nabiy Derush 2014-07-28 164 indent -kr -i4 -nut -c50 -psl 165 166 1548 ben-Nabiy Derush 2014-07-28 167 indent -kr -i4 -nut -c50 -psl 168 169 1547 ben-Nabiy Derush 2014-07-28 170 indent -kr -i4 -nut -c50 -psl 171 172 1546 ben-Nabiy Derush 2014-07-28 173 indent -kr -i4 -nut -c50 -psl 174 175 1545 ben-Nabiy Derush 2014-07-28 176 indent -kr -i4 -nut -c50 -psl 177 1 178 1544 Vagrant Cascadian 2014-02-22 {ldm-2.2.13} 2 179 version 2.2.13 -
ldm/trunk/fuentes/README-DEVELOPMENT-POLICY
r516 r855 22 22 - Align inline comments on column 50 23 23 - A newline after function definitions 24 - If you change whitespace or formatting of existing code, please do this in a 25 separate merge proposal. This includes running the above indent command on 26 existing code. 24 27 - All if() else blocks will have {}'s, even if only 1 line long, or Ollie will break your thumbs. 25 28 - Comments will be /* */ or Scott will break the rest of your fingers. -
ldm/trunk/fuentes/configure.ac
r516 r855 4 4 5 5 PACKAGE=ldm 6 VERSION=2.2.1 36 VERSION=2.2.18 7 7 AUTHOR=sbalneav@ltsp.org 8 8 -
ldm/trunk/fuentes/debian/changelog
r518 r855 1 ldm (2:2.2.13-1+lliurex6) xenial; urgency=medium 2 3 * Release into xenial 4 5 -- M.Angel Juan <m.angel.juan@gmail.com> Tue, 09 Feb 2016 17:37:06 +0100 6 7 ldm (2:2.2.13-1+lliurex3) trusty; urgency=high 8 9 * Adding profile.d to thin-clients 10 11 -- Hector Garcia Huerta <hectorgh@gmail.com> Mon, 03 Aug 2015 12:06:35 +0200 12 13 ldm (2:2.2.13-1+lliurex2) trusty; urgency=medium 14 15 * Adding more descriptive messages when login fails 16 17 -- Hector Garcia Huerta <hectorgh@gmail.com> Thu, 06 Nov 2014 12:51:54 +0100 18 19 ldm (2:2.2.13-1+lliurex1) trusty; urgency=medium 20 21 * LliureX changes 22 23 -- Hector Garcia Huerta <hectorgh@gmail.com> Tue, 07 Oct 2014 14:22:50 +0200 1 ldm (2:2.2.18-1) unstable; urgency=medium 2 3 * New upstream version. 4 - Display LDM only in the first monitor (LP: #693151). 5 - DesktopNames replaced X-LightDM-DesktopName in xsession files 6 (GNOME: #727546). 7 - Fix invalid syntax in .dmrc parsing the default session. 8 9 * debian/control: Update Vcs-Browser to use https URL. 10 11 -- Vagrant Cascadian <vagrant@debian.org> Sun, 07 Feb 2016 11:51:40 -0800 12 13 ldm (2:2.2.17-1) unstable; urgency=medium 14 15 * New upstream version: 16 - ldm-script: Fix locale issues by matching against alphanumeric 17 characters (LP: #1491066). 18 - screen.d/ldm: Fix LDM_DIRECTX with Xorg 1.17+, which no longer opens 19 a listening TCP socket by default (LP: #1449282). 20 21 -- Vagrant Cascadian <vagrant@debian.org> Thu, 08 Oct 2015 13:59:43 -0700 22 23 ldm (2:2.2.16-1) experimental; urgency=medium 24 25 * New upstream version: 26 - Generalize LDM_12HOURCLOCK to LDM_CLOCK_FORMAT. 27 - Export DESKTOP_SESSION and XDG_CURRENT_DESKTOP to the client. 28 * Drop Remove-rc.d-hook-to-set-LIBGL_ALWAYS_INDIRECT-true-a.patch, 29 applied upstream. 30 * Use X-Vendor-Recommends to allow for variation between packages built 31 on Ubuntu and Debian. 32 * debian/copyright: 33 - Reorder to fix lintian warnings and better follow copyright-format 34 1.0. 35 - Updated with newer copyright holders. 36 37 -- Vagrant Cascadian <vagrant@debian.org> Wed, 19 Aug 2015 12:01:03 +0200 38 39 ldm (2:2.2.15-2) unstable; urgency=medium 40 41 * Add patch to remove hook to set LIBGL_ALWAYS_INDIRECT=true, as it 42 causes several common desktops to fail (Closes: #767764). 43 44 -- Vagrant Cascadian <vagrant@debian.org> Sun, 08 Feb 2015 23:19:42 -0800 45 46 ldm (2:2.2.15-1) unstable; urgency=medium 47 48 * New upstream version: 49 - Display error message on failed login (LP: #1325388). 50 Thanks to Jakob Unterwurzacher! 51 52 - Remove check for halting when SHUTDOWN_TIME is set, implemented in 53 LTSP instead (LP: #604908). 54 55 - Compare desktop session against available local sessions when 56 running as a fat client (LP: #1272889). 57 58 * debian/control: Update Standards-Version to 3.9.6, no changes needed. 59 * Remove patch to disable listening on tcp, applied upstream. 60 * Update debian/copyright. 61 62 -- Vagrant Cascadian <vagrant@debian.org> Wed, 22 Oct 2014 00:45:45 -0700 63 64 ldm (2:2.2.14-2) unstable; urgency=medium 65 66 * Add patch from upstream to disable listening on tcp when not using 67 LDM_DIRECTX. 68 69 -- Vagrant Cascadian <vagrant@debian.org> Mon, 15 Sep 2014 14:09:56 -0500 70 71 ldm (2:2.2.14-1) unstable; urgency=medium 72 73 * New upstream version: 74 - Add feature to hash passwords for use with localapps and fat clients. 75 Thanks to ben-Nabiy Derush. 76 77 * debian/rules: 78 - Use dpkg-vendor --derives-from Ubuntu to set VENDOR, 79 to better handle Debian/Ubuntu derivatives. 80 - Allow architecture independent builds to succeed even if some files 81 built by arch specific targets are missing. 82 83 * ldm-server: Recommend mate-desktop-environment in preference to other 84 sessions. 85 86 -- Vagrant Cascadian <vagrant@debian.org> Tue, 05 Aug 2014 22:38:48 -0700 24 87 25 88 ldm (2:2.2.13-1) unstable; urgency=low -
ldm/trunk/fuentes/debian/control
r516 r855 6 6 Build-Depends: debhelper (>= 9), flex, bison, libpopt-dev, libgtk2.0-dev, 7 7 intltool, iso-codes, locales, python, dh-autoreconf, dctrl-tools 8 Standards-Version: 3.9. 58 Standards-Version: 3.9.6 9 9 Vcs-Bzr: nosmart+http://anonscm.debian.org/bzr/pkg-ltsp/ldm/ldm-debian-packaging/ 10 Vcs-Browser: http ://anonscm.debian.org/loggerhead/pkg-ltsp/ldm/ldm-debian-packaging/files10 Vcs-Browser: https://anonscm.debian.org/loggerhead/pkg-ltsp/ldm/ldm-debian-packaging/files 11 11 Homepage: http://ltsp.org/ 12 12 … … 38 38 openssh-server, 39 39 update-inetd, openbsd-inetd | inet-superserver 40 Recommends: ltspfs,41 gnome-session | x-session-manager | x-window-manager,40 Recommends: ${vendor:Recommends}, 41 ltspfs, 42 42 libasound2-plugins, 43 43 xauth 44 X-Debian-Recommends: mate-desktop-environment | gnome-session | x-session-manager | x-window-manager 45 X-Ubuntu-Recommends: gnome-session | mate-desktop-environment | x-session-manager | x-window-manager 44 46 Breaks: ltsp-server (<= 5.1.62) 45 47 Replaces: ltsp-server (<= 5.1.62) -
ldm/trunk/fuentes/debian/copyright
r516 r855 4 4 Upstream-Source: http://bazaar.launchpad.net/~ltsp-upstream/ltsp/ldm-trunk/ 5 5 6 Files: * 7 Copyright: 8 2005-2015 Scott Balneaves and LTSP developers 9 License: GPL-2+ 10 6 11 Files: debian/* 7 Copyright: 2007-201 2Vagrant Cascadian <vagrant@freegeek.org>12 Copyright: 2007-2014 Vagrant Cascadian <vagrant@freegeek.org> 8 13 2009 Ryan Niebur <ryanryan52@gmail.com> 14 License: GPL-2+ 15 16 Files: src/plugins/ssh/* 17 Copyright: 2014 Jakob Unterwurzacher <jakobunt@gmail.com> 18 2014 ben-Nabiy Derush <bennabiy@parchmentpress.net> 19 2012-2013 Alkis Georgopoulos <alkisg@gmail.com> 20 2013 Scott Balneaves <sbalneav@phobos.legalaid.mb.ca> 21 2010-2012 Stéphane Graber <stgraber@ubuntu.com> 22 2012 Floris Bos / Maxnet <bos@je-eigen-domein.nl> 23 2012 Vagrant Cascadian <vagrant@debian.org> 24 2011 Warren Togami <warren@togami.com> 25 2010 Simon Poirier <spoirier@revolutionlinux.com> 26 2010 Vincent Vinet <vvinet@revolutionlinux.com> 9 27 License: GPL-2+ 10 28 … … 25 43 2008 Wolfgang Schweer <schweer@cityweb.de> 26 44 2008 Toshio Kuratomi 45 2015 Alkis Georgopoulos <alkisg@gmail.com> 27 46 License: GPL-2 28 47 … … 66 85 License: GPL-2+ 67 86 68 Files: src/sshutils.c69 Copyright: 2007-2008 Scott Balneaves <sbalneav@ltsp.org>70 2008 Ryan Niebur <RyanRyan52@gmail.com>71 2008 Warren Togami <wtogami@redhat.com>72 2008 Vagrant Cascadian <vagrant@freegeek.org>73 2008 Toshio Kuratomi74 License: GPL-2+75 76 Files: src/get_ip.c77 Copyright: 2007 Oliver Grawert <ogra@canonical.com>78 2008 Scott Balneaves <sbalneav@ltsp.org>79 2008 Warren Togami <wtogami@redhat.com>80 2008 Toshio Kuratomi81 2008-2009 Ryan Niebur <RyanRyan52@gmail.com>82 License: GPL-283 84 Files: src/greeter_iface.c85 Copyright: 2007 Oliver Grawert <ogra@canonical.com>86 2007-2008 Scott Balneaves <sbalneav@ltsp.org>87 2007-2008 Vagrant Cascadian <vagrant@freegeek.org>88 2008 Ryan Niebur <RyanRyan52@gmail.com>89 2008 John Ellson <john.ellson@comcast.net>90 2008 Gideon Romm <gadi@ltsp.org>91 2008 Warren Togami <wtogami@redhat.com>92 2008 Francis Giraldeau <francis.giraldeau@revolutionlinux.com>93 2008 Toshio Kuratomi94 License: GPL-2+95 96 87 Files: src/ldminfo.c 97 88 Copyright: 2007 Francis Giraldeau, <francis.giraldeau@revolutionlinux.com> 98 89 2007-2008 Scott Balneaves <sbalneav@ltsp.org> 99 90 2008-2009 Ryan Niebur <ryanryan52@gmail.com> 100 License: GPL-2+ 101 102 Files: src/ldm-getenv-bool.c 103 Copyright: 2007-2008 Scott Balneaves <sbalneav@ltsp.org> 104 2008 Ryan Niebur <RyanRyan52@gmail.com> 105 2008 Vagrant Cascadian <vagrant@freegeek.org> 91 2014 ben-Nabiy Derush <bennabiy@parchmentpress.net> 92 2015 Alkis Georgopoulos <alkisg@gmail.com> 106 93 License: GPL-2+ 107 94 -
ldm/trunk/fuentes/debian/patches/series
r517 r855 1 1 remove-hackish-gettext-function 2 lliurex-patches 3 ldm_verbose_ ssh.patch4 ldm_background .patch5 profiled_thinclients 6 other_languages 2 lliurex-patches_ported_from_2_2_13 3 ldm_verbose_patch_integrated_from_2_2_13 4 ldm_background_ported_from_2_2_13 5 profiled_thinclients_ported_from_2_2_13 6 other_languages_ported_from_2_2_13 -
ldm/trunk/fuentes/debian/rules
r516 r855 3 3 export ENABLE_NLS=1 4 4 5 VENDOR ?= $(shell dpkg-vendor -- query Vendor)5 VENDOR ?= $(shell dpkg-vendor --derives-from Ubuntu && echo Ubuntu || echo Debian) 6 6 7 7 %: … … 10 10 override_dh_install: 11 11 dh_install 12 rm debian/ldm/usr/lib/*/ldm/*.la12 rm -f debian/ldm/usr/lib/*/ldm/*.la 13 13 14 14 override_dh_fixperms: 15 15 dh_fixperms 16 16 # ensure ldm-script is executable to avoid lintian warning 17 chmod +x debian/ldm/usr/share/ldm/ldm-script17 test ! -f debian/ldm/usr/share/ldm/ldm-script || chmod +x debian/ldm/usr/share/ldm/ldm-script 18 18 19 19 override_dh_autoreconf: -
ldm/trunk/fuentes/gtkgreet/greeter.c
r516 r855 80 80 GList *host_list = NULL; 81 81 GIOChannel *g_stdout; /* stdout io channel */ 82 gchar * 82 gchar *ldm_theme_dir; 83 83 84 84 int allowguest; … … 87 87 88 88 gchar * 89 ldm_theme_file(char * 90 { 91 gchar * 92 gchar * 89 ldm_theme_file(char *file) 90 { 91 gchar *filename; 92 gchar *filename_default; 93 93 filename = g_strconcat("/", ldm_theme_dir, "/", file, NULL); 94 filename_default = g_strconcat("/", LDM_THEME_DIR, "ltsp", "/", file, NULL);95 if (access(g_strconcat(filename, ".png", NULL), F_OK ) != -1)96 {94 filename_default = 95 g_strconcat("/", LDM_THEME_DIR, "ltsp", "/", file, NULL); 96 if (access(g_strconcat(filename, ".png", NULL), F_OK) != -1) { 97 97 filename = g_strconcat(filename, ".png", NULL); 98 } 99 else if (access(g_strconcat(filename, ".jpg", NULL), F_OK ) != -1) 100 { 98 } else if (access(g_strconcat(filename, ".jpg", NULL), F_OK) != -1) { 101 99 filename = g_strconcat(filename, ".jpg", NULL); 102 } 103 else if (access(g_strconcat(filename_default, ".png", NULL), F_OK ) != -1) 104 { 100 } else if (access(g_strconcat(filename_default, ".png", NULL), F_OK) != 101 -1) { 105 102 filename = g_strconcat(filename_default, ".png", NULL); 106 } 107 else if (access(g_strconcat(filename_default, ".jpg", NULL), F_OK ) != -1) 108 { 103 } else if (access(g_strconcat(filename_default, ".jpg", NULL), F_OK) != 104 -1) { 109 105 filename = g_strconcat(filename_default, ".jpg", NULL); 110 106 } 111 107 return filename; 112 108 } 113 GdkPixmap* root_bg = 0; 114 void load_root_background(const gchar* filename, gboolean scale, gboolean reload) { 115 if (root_bg != 0){ 109 110 void 111 get_default_display_size(gint * width, gint * height) 112 { 113 GdkDisplay *display = NULL; 114 GdkScreen *screen = NULL; 115 GdkRectangle my_rect; 116 117 display = gdk_display_get_default(); 118 screen = gdk_display_get_default_screen(display); 119 gdk_screen_get_monitor_geometry(screen, 0, &my_rect); 120 *width = my_rect.width; 121 *height = my_rect.height; 122 } 123 124 GdkPixmap *root_bg = 0; 125 void 126 load_root_background(const gchar * filename, gboolean scale, 127 gboolean reload) 128 { 129 if (root_bg != 0) { 116 130 if (reload) { 117 g_object_unref(G_OBJECT 131 g_object_unref(G_OBJECT(root_bg)); 118 132 root_bg = 0; 119 133 } else { … … 122 136 } 123 137 124 GtkWidget *image = gtk_image_new_from_file(filename);125 g_object_ref(G_OBJECT 126 GdkPixbuf * pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(image));127 double img_width = (double) gdk_pixbuf_get_width(pixbuf);128 double img_height = (double) gdk_pixbuf_get_height(pixbuf);129 130 GdkWindow *root = gdk_get_default_root_window();138 GtkWidget *image = gtk_image_new_from_file(filename); 139 g_object_ref(G_OBJECT(image)); 140 GdkPixbuf *pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(image)); 141 double img_width = (double) gdk_pixbuf_get_width(pixbuf); 142 double img_height = (double) gdk_pixbuf_get_height(pixbuf); 143 144 GdkWindow *root = gdk_get_default_root_window(); 131 145 gint width, height; 132 g dk_drawable_get_size(GDK_DRAWABLE (root),&width, &height);146 get_default_display_size(&width, &height); 133 147 134 148 // create pixmap 135 gdk_drawable_get_size(GDK_DRAWABLE (root), &width, &height); 136 root_bg = gdk_pixmap_new(GDK_DRAWABLE (root), width, height, -1); 137 g_object_ref(G_OBJECT (root_bg)); 149 root_bg = gdk_pixmap_new(GDK_DRAWABLE(root), width, height, -1); 150 g_object_ref(G_OBJECT(root_bg)); 138 151 139 152 // paint pixmap onto bg 140 cairo_t * ctx = gdk_cairo_create(GDK_DRAWABLE(root_bg));153 cairo_t *ctx = gdk_cairo_create(GDK_DRAWABLE(root_bg)); 141 154 if (scale) { 142 cairo_scale(ctx, width /img_width, height/img_height);155 cairo_scale(ctx, width / img_width, height / img_height); 143 156 } 144 157 gdk_cairo_set_source_pixbuf(ctx, pixbuf, 0, 0); … … 148 161 //g_object_unref(G_OBJECT (bg)); 149 162 150 g_object_unref(G_OBJECT 163 g_object_unref(G_OBJECT(image)); 151 164 } 152 165 153 166 void 154 set_root_background() { 155 GdkWindow* root = gdk_get_default_root_window(); 156 157 158 // bg needs to be set and painted, so it refreshes now and in the future 159 gdk_window_set_back_pixmap(GDK_WINDOW (root), GDK_PIXMAP (root_bg), 0); 160 gdk_draw_drawable(GDK_DRAWABLE (root), 161 gdk_gc_new(GDK_DRAWABLE (root)), 162 GDK_DRAWABLE (root_bg), 163 0, 0, 164 0, 0, 165 -1, -1); 166 } 167 168 void 169 draw_background(GtkWidget* widget, gpointer data) { 170 GdkWindow* window; 167 draw_background(GtkWidget * widget, gpointer data) 168 { 169 GdkWindow *window; 171 170 gint width, height, x, y; 172 171 … … 175 174 return; 176 175 } 177 gdk_drawable_get_size(GDK_DRAWABLE (window), &width, &height); 178 gdk_window_get_origin(GDK_WINDOW (window), &x, &y); 179 GdkPixmap* new_bg = gdk_pixmap_new(root_bg, width, height, -1); 180 g_object_ref(G_OBJECT (new_bg)); 181 gdk_draw_drawable(GDK_DRAWABLE (new_bg), 182 gdk_gc_new(GDK_DRAWABLE (new_bg)), 183 GDK_DRAWABLE (root_bg), 184 x, y, 185 0, 0, 186 width, height); 187 gdk_window_set_back_pixmap(GDK_WINDOW (window), new_bg, 0); 188 189 gtk_widget_queue_draw(GTK_WIDGET (widget)); 176 gdk_drawable_get_size(GDK_DRAWABLE(window), &width, &height); 177 gdk_window_get_origin(GDK_WINDOW(window), &x, &y); 178 GdkPixmap *new_bg = gdk_pixmap_new(root_bg, width, height, -1); 179 g_object_ref(G_OBJECT(new_bg)); 180 gdk_draw_drawable(GDK_DRAWABLE(new_bg), 181 gdk_gc_new(GDK_DRAWABLE(new_bg)), 182 GDK_DRAWABLE(root_bg), x, y, 0, 0, width, height); 183 gdk_window_set_back_pixmap(GDK_WINDOW(window), new_bg, 0); 184 185 gtk_widget_queue_draw(GTK_WIDGET(widget)); 190 186 } 191 187 … … 197 193 198 194 static void 199 spawn_command(GtkWidget * widget, const gchar * command)195 spawn_command(GtkWidget * widget, const gchar * command) 200 196 { 201 197 GError **error = NULL; … … 206 202 update_time(GtkWidget * label) 207 203 { 208 gchar *timestring = 0;209 204 time_t timet; 210 205 struct tm *timePtr; 206 gchar *clock_format; 207 gchar label_markup[100]; 211 208 212 209 timet = time(NULL); 213 210 timePtr = localtime(&timet); 214 211 215 // use 12 hour clock format if LDM_12HOURCLOCK is set to true 216 if (ldm_getenv_bool("LDM_12HOURCLOCK")) { 217 timestring = g_strdup_printf("<b>%.2d:%.2d</b>", 218 (timePtr->tm_hour % 12) ? (timePtr->tm_hour % 12) : 12, 219 timePtr->tm_min); 220 } 221 else { 222 timestring = g_strdup_printf("<b>%.2d:%.2d</b>", 223 timePtr->tm_hour, timePtr->tm_min); 224 } 225 226 gtk_label_set_markup((GtkLabel *) label, timestring); 227 228 g_free(timestring); 212 // Allow the users to customize the clock format including the GTK markup, 213 // for example in case they want the date non-bold and the time in bold. 214 clock_format=ldm_getenv_str_default("LDM_CLOCK_FORMAT", "%x, <b>%H:%M</b>"); 215 if (strftime(label_markup, sizeof(label_markup), clock_format, timePtr)) 216 gtk_label_set_markup((GtkLabel *) label, label_markup); 229 217 230 218 return TRUE; … … 236 224 gchar *string; 237 225 int entry_length; 238 entry_length = strlen(gtk_entry_get_text((GtkEntry *) entry));239 if (entry_length == 0 && timeout_enabled) {240 if (timeout_left > 1) {226 entry_length = strlen(gtk_entry_get_text((GtkEntry *) entry)); 227 if (entry_length == 0 && timeout_enabled) { 228 if (timeout_left > 1) { 241 229 timeout_left--; 242 230 } else if (timeout_left == 1) { 243 g_io_channel_write_chars(g_stdout, "@GUEST@\n", -1, NULL, NULL); 231 g_io_channel_write_chars(g_stdout, "@GUEST@\n", -1, NULL, 232 NULL); 244 233 g_io_channel_flush(g_stdout, NULL); 245 234 timeout_left = 0; 246 235 timeout_enabled = FALSE; 247 } else if (timeout_left == 0) {236 } else if (timeout_left == 0) { 248 237 timeout_left = login_timeout; 249 238 } 250 string = g_strdup_printf(_("Automatic login in %d seconds"), timeout_left); 239 string = 240 g_strdup_printf(_("Automatic login in %d seconds"), 241 timeout_left); 251 242 gtk_label_set_markup((GtkLabel *) label, string); 252 243 g_free(string); … … 275 266 gboolean result; 276 267 277 result=gdk_property_get( 278 gdk_get_default_root_window(), 279 gdk_atom_intern(property,TRUE), 280 GDK_NONE, 281 0, 282 512, 283 FALSE, 284 actual_property_type, 285 actual_format, 286 actual_length, 287 data); 268 result = gdk_property_get(gdk_get_default_root_window(), 269 gdk_atom_intern(property, TRUE), 270 GDK_NONE, 271 0, 272 512, 273 FALSE, 274 actual_property_type, 275 actual_format, actual_length, data); 288 276 return result; 289 277 } … … 299 287 g_strstrip(buf->str); 300 288 301 log_entry("gtkgreet", 7,"Got command: %s",buf->str);289 log_entry("gtkgreet", 7, "Got command: %s", buf->str); 302 290 303 291 if (!g_ascii_strncasecmp(buf->str, "msg", 3)) { … … 320 308 } else if (!g_ascii_strncasecmp(buf->str, "userid", 6)) { 321 309 timeout_enabled = login_timeout > 0; 322 if (timeout_enabled) {310 if (timeout_enabled) { 323 311 gtk_widget_show(timeoutbox); 324 312 } … … 369 357 370 358 // choice;choice 1|choice 2|choice 3 371 gchar ** choices = g_strsplit(buf->str+7, "|", -1);359 gchar **choices = g_strsplit(buf->str + 7, "|", -1); 372 360 373 361 // drop combo box to drop model 374 362 gtk_list_store_clear(choiceList); 375 363 376 for (i =0; i<g_strv_length(choices); ++i) {364 for (i = 0; i < g_strv_length(choices); ++i) { 377 365 gtk_list_store_append(GTK_LIST_STORE(choiceList), &iter); 378 366 gtk_list_store_set(GTK_LIST_STORE(choiceList), &iter, 0, … … 392 380 393 381 // pref choice;key;title;menu;icon;choice 1|choice 2|choice 3 394 gchar **args = g_strsplit(buf->str, ";", 6);395 gchar **choices = g_strsplit(args[5], "|", -1);382 gchar **args = g_strsplit(buf->str, ";", 6); 383 gchar **choices = g_strsplit(args[5], "|", -1); 396 384 397 385 GreeterPref *pref = greeter_pref_new(g_strdup(args[1])); … … 401 389 pref->icon = g_strdup(args[4]); 402 390 403 for (i=0; i<g_strv_length(choices); ++i) { 404 pref->choices = g_list_append(pref->choices, g_strdup(choices[i])); 391 for (i = 0; i < g_strv_length(choices); ++i) { 392 pref->choices = 393 g_list_append(pref->choices, g_strdup(choices[i])); 405 394 } 406 395 … … 415 404 buf->str[buf->len] = '\0'; 416 405 417 valstr = g_strdup_printf("%s\n", greeter_pref_get_value(name).str_val); 406 valstr = 407 g_strdup_printf("%s\n", greeter_pref_get_value(name).str_val); 418 408 g_io_channel_write_chars(g_stdout, valstr, -1, NULL, NULL); 419 409 g_io_channel_flush(g_stdout, NULL); 420 410 g_free(valstr); 421 411 } else if (!g_ascii_strncasecmp(buf->str, "allowguest", 10)) { 422 gchar *valstr = buf->str + 11;412 gchar *valstr = buf->str + 11; 423 413 allowguest = g_ascii_strncasecmp(valstr, "false", 2); 424 414 if (!allowguest) … … 455 445 handle_choice(GtkComboBox * combo, GdkWindow * window) 456 446 { 457 gchar *selection;458 gchar *entrystr;447 gchar *selection; 448 gchar *entrystr; 459 449 460 450 selection = gtk_combo_box_get_active_text(GTK_COMBO_BOX(choiceCombo)); … … 474 464 g_io_channel_flush(g_stdout, NULL); 475 465 g_free(entrystr); 476 if (gtk_entry_get_visibility(GTK_ENTRY(entry)))466 if (gtk_entry_get_visibility(GTK_ENTRY(entry))) 477 467 gtk_entry_set_text(entry, ""); 478 468 } 479 469 480 470 static gboolean 481 menu_append_pref(gpointer akey, gpointer avalue, gpointer adata) { 482 char* key = (char*)akey; 483 GreeterPref* pref = (GreeterPref*)avalue; 484 GtkWidget* menu = (GtkWidget*)adata; 471 menu_append_pref(gpointer akey, gpointer avalue, gpointer adata) 472 { 473 char *key = (char *) akey; 474 GreeterPref *pref = (GreeterPref *) avalue; 475 GtkWidget *menu = (GtkWidget *) adata; 485 476 GtkWidget *pref_item, *prefico; 486 477 487 pref_item = 488 gtk_image_menu_item_new_with_mnemonic(_(pref->menu)); 478 pref_item = gtk_image_menu_item_new_with_mnemonic(_(pref->menu)); 489 479 prefico = gtk_image_new_from_file(ldm_theme_file(pref->icon)); 490 480 gtk_image_menu_item_set_image((GtkImageMenuItem *) pref_item, prefico); … … 511 501 if (getenv("LDM_FORCE_LANGUAGE") == NULL) { 512 502 lang_item = 513 gtk_image_menu_item_new_with_mnemonic(_("Select _Language ...")); 503 gtk_image_menu_item_new_with_mnemonic(_ 504 ("Select _Language ...")); 514 505 langico = gtk_image_new_from_file(ldm_theme_file("language")); 515 gtk_image_menu_item_set_image((GtkImageMenuItem *) lang_item, langico); 506 gtk_image_menu_item_set_image((GtkImageMenuItem *) lang_item, 507 langico); 516 508 g_signal_connect_swapped(G_OBJECT(lang_item), "activate", 517 509 G_CALLBACK(langwin), window); … … 521 513 if (getenv("LDM_FORCE_SESSION") == NULL) { 522 514 sess_item = 523 gtk_image_menu_item_new_with_mnemonic(_("Select _Session ...")); 515 gtk_image_menu_item_new_with_mnemonic(_ 516 ("Select _Session ...")); 524 517 sessico = gtk_image_new_from_file(ldm_theme_file("session")); 525 gtk_image_menu_item_set_image((GtkImageMenuItem *) sess_item, sessico); 518 gtk_image_menu_item_set_image((GtkImageMenuItem *) sess_item, 519 sessico); 526 520 g_signal_connect_swapped(G_OBJECT(sess_item), "activate", 527 521 G_CALLBACK(sesswin), window); … … 533 527 gtk_image_menu_item_new_with_mnemonic(_("Select _Host ...")); 534 528 hostico = gtk_image_new_from_file(ldm_theme_file("host")); 535 gtk_image_menu_item_set_image((GtkImageMenuItem *) host_item, hostico); 529 gtk_image_menu_item_set_image((GtkImageMenuItem *) host_item, 530 hostico); 536 531 g_signal_connect_swapped(G_OBJECT(host_item), "activate", 537 532 G_CALLBACK(hostwin), window); … … 539 534 } 540 535 541 for (i =0; i<=9; i++) {536 for (i = 0; i <= 9; i++) { 542 537 g_sprintf(custom_env_var, "LDM_MENU_ITEM_%d", i); 543 custom_mnemonic =getenv(custom_env_var);538 custom_mnemonic = getenv(custom_env_var); 544 539 if (custom_mnemonic == NULL) 545 540 continue; … … 547 542 gtk_image_menu_item_new_with_mnemonic(custom_mnemonic); 548 543 g_sprintf(custom_env_var, "LDM_MENU_COMMAND_%d", i); 549 custom_command =getenv(custom_env_var);544 custom_command = getenv(custom_env_var); 550 545 if (custom_command == NULL) { 551 546 gtk_widget_destroy(custom_item); … … 554 549 customico = gtk_image_new_from_file(ldm_theme_file("backend")); 555 550 gtk_image_menu_item_set_image((GtkImageMenuItem *) custom_item, 556 customico);551 customico); 557 552 g_signal_connect(G_OBJECT(custom_item), "activate", 558 G_CALLBACK(spawn_command), g_strdup(custom_command)); 553 G_CALLBACK(spawn_command), 554 g_strdup(custom_command)); 559 555 gtk_menu_shell_append(GTK_MENU_SHELL(menu), custom_item); 560 556 } … … 603 599 else { 604 600 strncpy(dest, source, MAXSTRSZ - 1); 605 *(dest + MAXSTRSZ - 1) = '\0'; /* ensure null termination */601 *(dest + MAXSTRSZ - 1) = '\0'; /* ensure null termination */ 606 602 } 607 603 … … 614 610 */ 615 611 static gboolean 616 key_press_event(GtkWidget * widget, GdkEventKey *event, gpointer window)612 key_press_event(GtkWidget * widget, GdkEventKey * event, gpointer window) 617 613 { 618 614 if ((event->keyval == GDK_Tab || 619 615 event->keyval == GDK_KP_Tab) && 620 (event->state & (GDK_CONTROL_MASK|GDK_MOD1_MASK|GDK_SHIFT_MASK)) == 0) { 621 handle_entry(GTK_ENTRY(entry), window); 622 return TRUE; 616 (event-> 617 state & (GDK_CONTROL_MASK | GDK_MOD1_MASK | GDK_SHIFT_MASK)) == 618 0) { 619 handle_entry(GTK_ENTRY(entry), window); 620 return TRUE; 623 621 } 624 622 … … 629 627 main(int argc, char *argv[]) 630 628 { 631 gint lw ;629 gint lw, lh; 632 630 633 631 GtkWidget *loginWindow, *prefBar; … … 643 641 gint width, height; 644 642 GIOChannel *g_stdin; 645 char * 643 char *ldm_theme; 646 644 647 645 #ifdef ENABLE_NLS 648 setlocale 649 bindtextdomain 650 bind_textdomain_codeset 651 textdomain 646 setlocale(LC_ALL, ""); 647 bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR); 648 bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); 649 textdomain(GETTEXT_PACKAGE); 652 650 #endif 653 651 654 652 /* Init log settings */ 655 log_init(ldm_getenv_bool("LDM_SYSLOG"),ldm_getenv_int("LDM_LOGLEVEL",-1)); 653 log_init(ldm_getenv_bool("LDM_SYSLOG"), 654 ldm_getenv_int("LDM_LOGLEVEL", -1)); 656 655 657 656 gtk_init(&argc, &argv); 658 657 ldm_theme = getenv("LDM_THEME"); 659 658 660 if (ldm_theme) 661 { 662 if(*ldm_theme == '/') 659 if (ldm_theme) { 660 if (*ldm_theme == '/') 663 661 ldm_theme_dir = g_strdup(ldm_theme); 664 662 else 665 663 ldm_theme_dir = g_strconcat(LDM_THEME_DIR, ldm_theme, NULL); 666 } 667 else 668 { 664 } else { 669 665 ldm_theme_dir = g_strconcat(LDM_THEME_DIR, "default", NULL); 670 666 } … … 687 683 /* Set the background */ 688 684 load_root_background(ldm_theme_file("bg"), TRUE, FALSE); 689 set_root_background(); 690 691 gdk_drawable_get_size(root, &width, &height); 685 686 get_default_display_size(&width, &height); 692 687 693 688 /* Setup the time and system labels */ … … 698 693 #ifdef K12LINUX 699 694 hoststring = 700 g_strdup_printf("<b>%s</b> (%s)", get_sysname(), getenv("LDMINFO_IPADDR")); 695 g_strdup_printf("<b>%s</b> (%s)", get_sysname(), 696 getenv("LDMINFO_IPADDR")); 701 697 #else 702 698 hoststring = 703 g_strdup_printf("<b>%s</b> (%s) //", get_sysname(), getenv("LDMINFO_IPADDR")); 699 g_strdup_printf("<b>%s</b> (%s) -", get_sysname(), 700 getenv("LDMINFO_IPADDR")); 704 701 #endif 705 702 gtk_label_set_markup((GtkLabel *) syslabel, hoststring); … … 728 725 729 726 /**** Create the login window ****/ 730 gtk_window_set_position(GTK_WINDOW(loginWindow), GTK_WIN_POS_CENTER_ALWAYS);731 727 { 732 GtkWidget *guestbox, *guestspacer1, *guestspacer2, *vbox, *vbox2, *hbox; 728 GtkWidget *guestbox, *guestspacer1, *guestspacer2, *vbox, *vbox2, 729 *vbox2spacer, *hbox; 733 730 GtkCellRenderer *renderer; 734 731 735 g_signal_connect(G_OBJECT(loginWindow), "destroy", G_CALLBACK(destroy),736 NULL);732 g_signal_connect(G_OBJECT(loginWindow), "destroy", 733 G_CALLBACK(destroy), NULL); 737 734 738 735 gtk_widget_set_app_paintable(loginWindow, TRUE); 739 736 g_signal_connect(loginWindow, "configure-event", 740 G_CALLBACK(draw_background), NULL);741 //gtk_widget_set_size_request(loginWindow, width/2, height/2);742 //gtk_widget_realize(loginWindow);743 gtk_window_set_decorated(GTK_WINDOW 737 G_CALLBACK(draw_background), NULL); 738 gtk_widget_set_size_request(loginWindow, width, height); 739 gtk_widget_realize(loginWindow); 740 gtk_window_set_decorated(GTK_WINDOW(loginWindow), FALSE); 744 741 745 742 logo = gtk_image_new_from_file(ldm_theme_file("logo")); 746 743 #ifdef K12LINUX 747 if (access(ldm_theme_file("bottom_right"), R_OK) == 0) {748 bottom_right = gtk_image_new_from_file(ldm_theme_file("bottom_right"));749 has_bottom_right_image=TRUE;750 }751 else752 has_bottom_right_image =FALSE;744 if (access(ldm_theme_file("bottom_right"), R_OK) == 0) { 745 bottom_right = 746 gtk_image_new_from_file(ldm_theme_file("bottom_right")); 747 has_bottom_right_image = TRUE; 748 } else 749 has_bottom_right_image = FALSE; 753 750 #endif 754 751 755 752 pix = gtk_image_get_pixbuf((GtkImage *) logo); 756 753 lw = gdk_pixbuf_get_width(pix); 754 lh = gdk_pixbuf_get_height(pix); 757 755 758 756 759 757 vbox = gtk_vbox_new(FALSE, 5); 760 vbox2 = gtk_vbox_new(FALSE, 0); 758 vbox2 = gtk_vbox_new(FALSE, ((height / 2) - lh)); 759 vbox2spacer = gtk_vbox_new(FALSE, 5); 761 760 EntryBox = gtk_hbox_new(FALSE, 5); 762 761 hbox = gtk_hbox_new(FALSE, 0); … … 772 771 StatusMessages = gtk_label_new(""); 773 772 entry = gtk_entry_new(); 774 gtk_entry_set_width_chars(GTK_ENTRY(entry), 12);773 gtk_entry_set_width_chars(GTK_ENTRY(entry), 20); 775 774 g_signal_connect(G_OBJECT(entry), "activate", 776 775 G_CALLBACK(handle_entry), root); … … 780 779 781 780 choiceList = gtk_list_store_new(1, G_TYPE_STRING); 782 choiceCombo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(choiceList)); 781 choiceCombo = 782 gtk_combo_box_new_with_model(GTK_TREE_MODEL(choiceList)); 783 783 renderer = gtk_cell_renderer_text_new(); 784 784 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(choiceCombo), 785 GTK_CELL_RENDERER(renderer), 786 TRUE); 785 GTK_CELL_RENDERER(renderer), TRUE); 787 786 gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(choiceCombo), 788 787 GTK_CELL_RENDERER(renderer), … … 791 790 G_CALLBACK(handle_choice), root); 792 791 793 if (getenv("LDM_LOGIN_TIMEOUT") != NULL 792 if (getenv("LDM_LOGIN_TIMEOUT") != NULL) { 794 793 login_timeout = atoi(getenv("LDM_LOGIN_TIMEOUT")); 795 794 } else { … … 803 802 timeoutbox = gtk_hbox_new(FALSE, 0); 804 803 gtk_box_pack_start(GTK_BOX(vbox), timeoutbox, FALSE, FALSE, 0); 805 gtk_box_pack_start(GTK_BOX(timeoutbox), timeoutspacer1, TRUE, FALSE, 0); 806 gtk_box_pack_start(GTK_BOX(timeoutbox), timeoutlabel, FALSE, FALSE, 0); 807 gtk_box_pack_start(GTK_BOX(timeoutbox), timeoutspacer2, TRUE, FALSE, 0); 804 gtk_box_pack_start(GTK_BOX(timeoutbox), timeoutspacer1, TRUE, 805 FALSE, 0); 806 gtk_box_pack_start(GTK_BOX(timeoutbox), timeoutlabel, FALSE, FALSE, 807 0); 808 gtk_box_pack_start(GTK_BOX(timeoutbox), timeoutspacer2, TRUE, 809 FALSE, 0); 808 810 g_timeout_add(1000, (GSourceFunc) update_timeout, timeoutlabel); 809 811 810 812 guestspacer1 = gtk_label_new(""); 811 813 guestspacer2 = gtk_label_new(""); 812 GuestButton = gtk_button_new_with_label 814 GuestButton = gtk_button_new_with_label(_("Login as Guest")); 813 815 g_signal_connect(G_OBJECT(GuestButton), "clicked", 814 G_CALLBACK(handle_guestbutton), root);815 gtk_button_set_focus_on_click((GtkButton *) GuestButton, FALSE);816 G_CALLBACK(handle_guestbutton), root); 817 gtk_button_set_focus_on_click((GtkButton *) GuestButton, FALSE); 816 818 guestbox = gtk_hbox_new(FALSE, 0); 817 gtk_box_pack_start(GTK_BOX(guestbox), guestspacer1, TRUE, FALSE, 0); 818 gtk_box_pack_start(GTK_BOX(guestbox), GuestButton, FALSE, FALSE, 0); 819 gtk_box_pack_start(GTK_BOX(guestbox), guestspacer2, TRUE, FALSE, 0); 819 gtk_box_pack_start(GTK_BOX(guestbox), guestspacer1, TRUE, FALSE, 820 0); 821 gtk_box_pack_start(GTK_BOX(guestbox), GuestButton, FALSE, FALSE, 822 0); 823 gtk_box_pack_start(GTK_BOX(guestbox), guestspacer2, TRUE, FALSE, 824 0); 820 825 821 826 entryspacer1 = gtk_label_new(""); 822 827 entryspacer2 = gtk_label_new(""); 823 gtk_box_pack_start(GTK_BOX(EntryBox), entryspacer1, TRUE, FALSE, 0); 828 gtk_box_pack_start(GTK_BOX(EntryBox), entryspacer1, TRUE, FALSE, 829 0); 824 830 gtk_box_pack_start(GTK_BOX(EntryBox), UserPrompt, FALSE, FALSE, 0); 825 831 gtk_box_pack_start(GTK_BOX(EntryBox), entry, FALSE, FALSE, 0); 826 gtk_box_pack_start(GTK_BOX(EntryBox), choiceCombo, FALSE, FALSE, 0); 827 gtk_box_pack_start(GTK_BOX(EntryBox), entryspacer2, TRUE, FALSE, 0); 832 gtk_box_pack_start(GTK_BOX(EntryBox), choiceCombo, FALSE, FALSE, 833 0); 834 gtk_box_pack_start(GTK_BOX(EntryBox), entryspacer2, TRUE, FALSE, 835 0); 828 836 829 837 gtk_box_pack_start(GTK_BOX(vbox), logo, FALSE, FALSE, 5); 830 838 gtk_box_pack_start(GTK_BOX(vbox), EntryBox, TRUE, FALSE, 0); 831 if(allowguest) gtk_box_pack_start(GTK_BOX(vbox), guestbox, FALSE, FALSE, 0); 839 if (allowguest) 840 gtk_box_pack_start(GTK_BOX(vbox), guestbox, FALSE, FALSE, 0); 832 841 gtk_box_pack_start(GTK_BOX(vbox), timeoutbox, FALSE, FALSE, 0); 833 842 gtk_box_pack_start(GTK_BOX(vbox), StatusMessages, TRUE, FALSE, 0); 834 843 gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, FALSE, 0); 844 gtk_box_pack_start(GTK_BOX(vbox2), vbox2spacer, FALSE, FALSE, 0); 835 845 gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0); 836 846 … … 843 853 GtkWidget *BottomBarBox; 844 854 845 gtk_widget_set_app_paintable(GTK_WIDGET 855 gtk_widget_set_app_paintable(GTK_WIDGET(prefBar), TRUE); 846 856 g_signal_connect(prefBar, "configure-event", 847 G_CALLBACK(draw_background), NULL);848 gtk_window_set_decorated(GTK_WINDOW 857 G_CALLBACK(draw_background), NULL); 858 gtk_window_set_decorated(GTK_WINDOW(prefBar), FALSE); 849 859 gtk_widget_set_size_request(prefBar, width, BOTTOM_BAR_HEIGHT); 850 860 … … 862 872 optionbutton_box = gtk_vbox_new(FALSE, 0); 863 873 optionbutton_spacer = gtk_label_new(""); 864 gtk_box_pack_start(GTK_BOX(optionbutton_box), GTK_WIDGET(optionbutton_spacer), TRUE, FALSE, 0); 865 gtk_box_pack_end(GTK_BOX(optionbutton_box), GTK_WIDGET(optionbutton), FALSE, FALSE, 5); 874 gtk_box_pack_start(GTK_BOX(optionbutton_box), 875 GTK_WIDGET(optionbutton_spacer), TRUE, FALSE, 876 0); 877 gtk_box_pack_end(GTK_BOX(optionbutton_box), 878 GTK_WIDGET(optionbutton), FALSE, FALSE, 5); 866 879 gtk_box_pack_start(GTK_BOX(BottomBarBox), 867 880 GTK_WIDGET(optionbutton_box), FALSE, FALSE, 5); 868 881 869 if (has_bottom_right_image == TRUE) {882 if (has_bottom_right_image == TRUE) { 870 883 bottom_right_box = gtk_vbox_new(FALSE, 0); 871 884 bottom_right_spacer = gtk_label_new(""); 872 gtk_box_pack_start(GTK_BOX(bottom_right_box), GTK_WIDGET(bottom_right_spacer), TRUE, FALSE, 0); 873 gtk_box_pack_end(GTK_BOX(bottom_right_box), GTK_WIDGET(bottom_right), FALSE, FALSE, 0); 885 gtk_box_pack_start(GTK_BOX(bottom_right_box), 886 GTK_WIDGET(bottom_right_spacer), TRUE, 887 FALSE, 0); 888 gtk_box_pack_end(GTK_BOX(bottom_right_box), 889 GTK_WIDGET(bottom_right), FALSE, FALSE, 0); 874 890 gtk_box_pack_end(GTK_BOX(BottomBarBox), 875 GTK_WIDGET(bottom_right_box), FALSE, FALSE, 0); 891 GTK_WIDGET(bottom_right_box), FALSE, FALSE, 892 0); 876 893 } 877 894 #endif 878 gtk_container_add(GTK_CONTAINER 895 gtk_container_add(GTK_CONTAINER(prefBar), BottomBarBox); 879 896 } 880 897 … … 885 902 GtkWidget *TopBarBox; 886 903 887 gtk_window_set_decorated(GTK_WINDOW 904 gtk_window_set_decorated(GTK_WINDOW(topBar), FALSE); 888 905 gtk_widget_set_size_request(topBar, width, TOP_BAR_HEIGHT); 889 906 890 907 TopBarBox = gtk_hbox_new(FALSE, 5); 891 908 gtk_box_pack_start(GTK_BOX(TopBarBox), 892 GTK_WIDGET(syslabel), FALSE, FALSE, 5);909 GTK_WIDGET(syslabel), FALSE, FALSE, 5); 893 910 gtk_box_pack_end(GTK_BOX(TopBarBox), 894 911 GTK_WIDGET(timelabel), FALSE, FALSE, 5); … … 899 916 gtk_widget_show_all(loginWindow); 900 917 gtk_widget_show_all(prefBar); 901 gtk_window_move(GTK_WINDOW (prefBar), 0, height - BOTTOM_BAR_HEIGHT); 918 gtk_window_move(GTK_WINDOW(loginWindow), 0, 0); 919 gtk_window_move(GTK_WINDOW(prefBar), 0, height - BOTTOM_BAR_HEIGHT); 902 920 #ifdef K12LINUX 903 921 gtk_widget_show_all(topBar); 904 gtk_window_move(GTK_WINDOW 922 gtk_window_move(GTK_WINDOW(topBar), 0, 0); 905 923 #endif 906 924 925 // Center the mouse pointer on the default display 926 GdkDisplay *display = gdk_display_get_default(); 927 GdkScreen *screen = gdk_display_get_default_screen(display); 928 GdkRectangle bbox; 929 gdk_screen_get_monitor_geometry(screen, 0, &bbox); 930 gdk_display_warp_pointer(display, screen, bbox.width/2, bbox.height/2); 907 931 gdk_window_set_cursor(root, normcursor); 908 932 -
ldm/trunk/fuentes/gtkgreet/langwin.c
r516 r855 70 70 71 71 curr_host = 72 ldminfo_lookup(g_list_nth_data(host_list, 73 selected_host_id)); 72 ldminfo_lookup(g_list_nth_data(host_list, selected_host_id)); 74 73 l = curr_host->languages; 75 74 g_strlcpy(language, g_list_nth_data(l, lang_selected - 1), … … 99 98 */ 100 99 101 curr_host = ldminfo_lookup(g_list_nth_data(host_list, selected_host_id)); 100 curr_host = 101 ldminfo_lookup(g_list_nth_data(host_list, selected_host_id)); 102 102 103 103 gtk_combo_box_append_text(GTK_COMBO_BOX(lang_select), … … 136 136 label = gtk_label_new(""); 137 137 gtk_label_set_markup((GtkLabel *) label, 138 _("Select the language for your session to use:")); 138 _ 139 ("Select the language for your session to use:")); 139 140 140 141 gtk_box_pack_start((GtkBox *) vbox, (GtkWidget *) label, FALSE, FALSE, -
ldm/trunk/fuentes/gtkgreet/prefs.c
r516 r855 26 26 #include <sys/socket.h> 27 27 28 static GTree *greeter_prefs = NULL;28 static GTree *greeter_prefs = NULL; 29 29 30 static int g_strcmp(gconstpointer a, gconstpointer b) { 31 return strcmp((char*)a, (char*)b); 30 static int 31 g_strcmp(gconstpointer a, gconstpointer b) 32 { 33 return strcmp((char *) a, (char *) b); 32 34 } 33 35 34 void greeter_pref_init() { 36 void 37 greeter_pref_init() 38 { 35 39 if (greeter_prefs) { 36 40 g_tree_destroy(greeter_prefs); … … 40 44 } 41 45 42 GreeterPref* greeter_pref_new(const gchar* name) { 43 GreeterPref* pref = g_malloc0(sizeof(GreeterPref)); 46 GreeterPref * 47 greeter_pref_new(const gchar * name) 48 { 49 GreeterPref *pref = g_malloc0(sizeof(GreeterPref)); 44 50 g_tree_replace(greeter_prefs, g_strdup(name), pref); 45 51 pref->choices = g_list_alloc(); … … 48 54 } 49 55 50 void greeter_pref_destroy(const gchar* name) { 56 void 57 greeter_pref_destroy(const gchar * name) 58 { 51 59 gpointer key; 52 60 gpointer valptr; 53 GreeterPref *value;61 GreeterPref *value; 54 62 55 63 g_tree_lookup_extended(greeter_prefs, name, &key, &valptr); 56 value = (GreeterPref *)valptr;64 value = (GreeterPref *) valptr; 57 65 if (value->choices) { 58 g_list_foreach(value->choices, (GFunc) g_free, NULL);66 g_list_foreach(value->choices, (GFunc) g_free, NULL); 59 67 g_list_free(value->choices); 60 68 } … … 74 82 } 75 83 76 void greeter_pref_prompt(const gchar* name) { 84 void 85 greeter_pref_prompt(const gchar * name) 86 { 77 87 } 78 88 79 GreeterPref* greeter_pref_get_pref(const gchar* name) { 80 return (GreeterPref*)g_tree_lookup(greeter_prefs, name); 89 GreeterPref * 90 greeter_pref_get_pref(const gchar * name) 91 { 92 return (GreeterPref *) g_tree_lookup(greeter_prefs, name); 81 93 } 82 94 83 PrefValue greeter_pref_get_value(const gchar* name) { 84 GreeterPref* value = (GreeterPref*) g_tree_lookup(greeter_prefs, name); 95 PrefValue 96 greeter_pref_get_value(const gchar * name) 97 { 98 GreeterPref *value = 99 (GreeterPref *) g_tree_lookup(greeter_prefs, name); 85 100 if (!value) { 86 return (PrefValue)"None"; 87 } if (value->value.int_val == 0) { 88 return (PrefValue)"None"; 101 return (PrefValue) "None"; 102 } 103 if (value->value.int_val == 0) { 104 return (PrefValue) "None"; 89 105 } 90 106 91 return (PrefValue) (char*)g_list_nth_data(value->choices,92 value->value.int_val);107 return (PrefValue) (char *) g_list_nth_data(value->choices, 108 value->value.int_val); 93 109 } 94 110 95 void greeter_pref_foreach(GTraverseFunc func, gpointer user_data) { 111 void 112 greeter_pref_foreach(GTraverseFunc func, gpointer user_data) 113 { 96 114 g_tree_foreach(greeter_prefs, func, user_data); 97 115 } 98 -
ldm/trunk/fuentes/gtkgreet/prefwin.c
r516 r855 28 28 #include "greeter.h" 29 29 30 static GtkWidget *pref_combo = NULL;30 static GtkWidget *pref_combo = NULL; 31 31 static gint choice_total = 0; 32 32 … … 34 34 35 35 typedef struct { 36 GtkWidget *prefwin;37 const gchar *prefname;36 GtkWidget *prefwin; 37 const gchar *prefname; 38 38 } PrefData; 39 39 … … 43 43 44 44 static void 45 prefwin_accept(GtkWidget * widget, PrefData * data)45 prefwin_accept(GtkWidget * widget, PrefData * data) 46 46 { 47 GreeterPref *pref = greeter_pref_get_pref(data->prefname);48 gchar *notif;47 GreeterPref *pref = greeter_pref_get_pref(data->prefname); 48 gchar *notif; 49 49 50 pref->value.int_val = gtk_combo_box_get_active(GTK_COMBO_BOX(pref_combo)); 50 pref->value.int_val = 51 gtk_combo_box_get_active(GTK_COMBO_BOX(pref_combo)); 51 52 gtk_widget_destroy(data->prefwin); 52 53 … … 75 76 { 76 77 77 GreeterPref *pref;78 GreeterPref *pref; 78 79 GtkWidget *prefwin, *label, *vbox, *buttonbox; 79 80 GtkWidget *cancel, *accept, *frame; … … 91 92 (GFunc) populate_pref_combo_box, pref_combo); 92 93 93 gtk_combo_box_set_active(GTK_COMBO_BOX(pref_combo), pref->value.int_val); 94 gtk_combo_box_set_active(GTK_COMBO_BOX(pref_combo), 95 pref->value.int_val); 94 96 95 97 /* … … 111 113 112 114 accept = gtk_button_new_from_stock("gtk-ok"); 113 PrefData *data = g_malloc0(sizeof(PrefData));115 PrefData *data = g_malloc0(sizeof(PrefData)); 114 116 data->prefwin = prefwin; 115 117 data->prefname = pref_name; … … 123 125 124 126 label = gtk_label_new(""); 125 gtk_label_set_markup((GtkLabel *) label, 126 _(pref->title)); 127 gtk_label_set_markup((GtkLabel *) label, _(pref->title)); 127 128 128 129 gtk_box_pack_start((GtkBox *) vbox, (GtkWidget *) label, FALSE, FALSE, … … 144 145 return; 145 146 } 146 -
ldm/trunk/fuentes/gtkgreet/sesswin.c
r516 r855 68 68 GList *s = NULL; 69 69 70 curr_host = ldminfo_lookup(g_list_nth_data(host_list, selected_host_id)); 70 curr_host = 71 ldminfo_lookup(g_list_nth_data(host_list, selected_host_id)); 71 72 s = curr_host->sessions; 72 73 g_strlcpy(session, g_list_nth_data(s, sess_selected - 2), … … 100 101 */ 101 102 102 curr_host = ldminfo_lookup(g_list_nth_data(host_list, current_host_id)); 103 curr_host = 104 ldminfo_lookup(g_list_nth_data(host_list, current_host_id)); 103 105 104 106 gtk_combo_box_append_text(GTK_COMBO_BOX(sess_select), -
ldm/trunk/fuentes/misc/ldm-dialog.c
r516 r855 46 46 int auto_close; 47 47 48 void yes_clicked(GtkWidget * widget, GtkWidget * mywin) 48 void 49 yes_clicked(GtkWidget * widget, GtkWidget * mywin) 49 50 { 50 51 gtk_main_quit(); … … 52 53 } 53 54 54 void no_clicked(GtkWidget * widget, GtkWidget * mywin) 55 void 56 no_clicked(GtkWidget * widget, GtkWidget * mywin) 55 57 { 56 58 gtk_main_quit(); … … 58 60 } 59 61 60 void link_clicked(GtkWidget * widget, GtkLabel * mywin) 61 { 62 printf("url: %s\n",gtk_label_get_current_uri(GTK_LABEL(widget))); 62 void 63 link_clicked(GtkWidget * widget, GtkLabel * mywin) 64 { 65 printf("url: %s\n", gtk_label_get_current_uri(GTK_LABEL(widget))); 63 66 gtk_main_quit(); 64 67 exit(0); 65 68 } 66 69 67 void update_progressbar() 68 { 69 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress), current_number/100.0); 70 if(current_number < 100.0) { 71 if(yes) 70 void 71 update_progressbar() 72 { 73 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress), 74 current_number / 100.0); 75 if (current_number < 100.0) { 76 if (yes) 72 77 gtk_widget_set_sensitive(yes, FALSE); 73 78 } else { 74 if (auto_close == TRUE)79 if (auto_close == TRUE) 75 80 yes_clicked(NULL, NULL); 76 if (yes) {81 if (yes) { 77 82 gtk_widget_set_sensitive(yes, TRUE); 78 83 gtk_widget_grab_focus(yes); … … 81 86 } 82 87 83 void update_progressbar_from_channel(GIOChannel * channel) 88 void 89 update_progressbar_from_channel(GIOChannel * channel) 84 90 { 85 91 GString *buf; … … 92 98 } 93 99 94 void usage(char * progname) { 95 printf("Usage: %s --message|--question|--progress [mode specific options] \"message\"\n", progname); 100 void 101 usage(char *progname) 102 { 103 printf 104 ("Usage: %s --message|--question|--progress [mode specific options] \"message\"\n", 105 progname); 96 106 printf("Progress mode options: --auto-close\n"); 97 107 exit(1); … … 100 110 #define USAGE() usage(argv[0]) 101 111 102 int main(int argc, char ** argv){ 103 GtkWidget *mywin, *vbox, *hbox, *label, *spacer, *big_hbox, *ospacer, *o2spacer; 112 int 113 main(int argc, char **argv) 114 { 115 GtkWidget *mywin, *vbox, *hbox, *label, *spacer, *big_hbox, *ospacer, 116 *o2spacer; 104 117 int mode; 105 118 int retval; 106 char * 119 char *message; 107 120 int has_no_button, has_yes_button; 108 121 mode = NOTHING; … … 111 124 auto_close = FALSE; 112 125 113 setlocale 114 bindtextdomain 115 bind_textdomain_codeset 116 textdomain 126 setlocale(LC_ALL, ""); 127 bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR); 128 bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); 129 textdomain(GETTEXT_PACKAGE); 117 130 118 131 // Option processing … … 122 135 {"progress", 0, 0, PROGRESS}, 123 136 {"auto-close", 0, 0, AUTO_CLOSE_OPTION}, 124 {0, 0,0,0}137 {0, 0, 0, 0} 125 138 }; 126 while (1) {139 while (1) { 127 140 retval = getopt_long(argc, argv, "", longopts, NULL); 128 if (retval == -1)129 break; 130 switch (retval) {141 if (retval == -1) 142 break; 143 switch (retval) { 131 144 case MESSAGE: 132 145 case QUESTION: 133 146 case PROGRESS: 134 if (mode != NOTHING)147 if (mode != NOTHING) 135 148 USAGE(); 136 149 mode = retval; … … 144 157 } 145 158 } 146 if (mode == NOTHING)159 if (mode == NOTHING) 147 160 USAGE(); 148 if ((argc - optind) != 1)161 if ((argc - optind) != 1) 149 162 USAGE(); 150 if (auto_close == TRUE && mode != PROGRESS)163 if (auto_close == TRUE && mode != PROGRESS) 151 164 USAGE(); 152 165 message = argv[optind]; 153 switch (mode) {166 switch (mode) { 154 167 case MESSAGE: 155 168 has_no_button = FALSE; … … 158 171 break; 159 172 case PROGRESS: 160 if (auto_close == TRUE)173 if (auto_close == TRUE) 161 174 has_yes_button = FALSE; 162 175 break; … … 167 180 168 181 // Theme 169 char * 170 gchar * 182 char *ldm_theme; 183 gchar *ldm_gtkrc; 171 184 ldm_theme = getenv("LDM_THEME"); 172 if (ldm_theme) 173 { 174 if(*ldm_theme == '/') 185 if (ldm_theme) { 186 if (*ldm_theme == '/') 175 187 ldm_gtkrc = g_strconcat(ldm_theme, "/greeter-gtkrc", NULL); 176 188 else 177 ldm_gtkrc = g_strconcat(LDM_THEME_DIR, ldm_theme, "/greeter-gtkrc", NULL); 189 ldm_gtkrc = 190 g_strconcat(LDM_THEME_DIR, ldm_theme, "/greeter-gtkrc", 191 NULL); 178 192 } else 179 ldm_gtkrc = g_strconcat(LDM_THEME_DIR, "default", "/greeter-gtkrc", NULL); 193 ldm_gtkrc = 194 g_strconcat(LDM_THEME_DIR, "default", "/greeter-gtkrc", NULL); 180 195 gtk_rc_add_default_file(ldm_gtkrc); 181 196 g_free(ldm_gtkrc); 182 197 // Finish setting up the basic stuff 183 198 mywin = gtk_window_new(GTK_WINDOW_TOPLEVEL); 184 gdk_window_set_cursor(gdk_get_default_root_window(), gdk_cursor_new(GDK_LEFT_PTR)); 185 gtk_window_set_title(GTK_WINDOW(mywin),""); 186 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(mywin),TRUE); 187 gtk_window_set_resizable (GTK_WINDOW(mywin),0); 199 gdk_window_set_cursor(gdk_get_default_root_window(), 200 gdk_cursor_new(GDK_LEFT_PTR)); 201 gtk_window_set_title(GTK_WINDOW(mywin), ""); 202 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(mywin), TRUE); 203 gtk_window_set_resizable(GTK_WINDOW(mywin), 0); 188 204 gtk_window_set_position(GTK_WINDOW(mywin), GTK_WIN_POS_CENTER_ALWAYS); 189 g_signal_connect(GTK_WINDOW(mywin), "destroy", G_CALLBACK(no_clicked), mywin); 205 g_signal_connect(GTK_WINDOW(mywin), "destroy", G_CALLBACK(no_clicked), 206 mywin); 190 207 hbox = gtk_hbox_new(FALSE, 3); 191 208 spacer = gtk_label_new(""); … … 197 214 198 215 // Make the yes button 199 if (has_yes_button == TRUE) {216 if (has_yes_button == TRUE) { 200 217 yes = gtk_button_new_from_stock("gtk-ok"); 201 g_signal_connect(G_OBJECT(yes), "clicked", G_CALLBACK(yes_clicked), mywin); 218 g_signal_connect(G_OBJECT(yes), "clicked", G_CALLBACK(yes_clicked), 219 mywin); 202 220 gtk_box_pack_start(GTK_BOX(hbox), yes, FALSE, FALSE, 0); 203 221 } 204 205 222 // Make the no button 206 if (has_no_button == TRUE) {223 if (has_no_button == TRUE) { 207 224 no = gtk_button_new_from_stock("gtk-cancel"); 208 g_signal_connect(G_OBJECT(no), "clicked", G_CALLBACK(no_clicked), mywin); 225 g_signal_connect(G_OBJECT(no), "clicked", G_CALLBACK(no_clicked), 226 mywin); 209 227 gtk_box_pack_start(GTK_BOX(hbox), no, FALSE, FALSE, 0); 210 228 } 211 212 229 // Create the label 213 230 label = gtk_label_new(message); … … 215 232 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); 216 233 gtk_window_set_default_size(GTK_WINDOW(mywin), 300, -1); 217 g_signal_connect(GTK_LABEL(label), "activate-link", G_CALLBACK(link_clicked), label); 234 g_signal_connect(GTK_LABEL(label), "activate-link", 235 G_CALLBACK(link_clicked), label); 218 236 219 237 vbox = gtk_vbox_new(FALSE, 0); 220 GtkWidget * 238 GtkWidget *blah; 221 239 blah = gtk_alignment_new(0, 0.5, 0, 0); 222 240 gtk_container_add(GTK_CONTAINER(blah), label); 223 241 gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(blah), FALSE, FALSE, 10); 224 242 225 if (mode == PROGRESS) {243 if (mode == PROGRESS) { 226 244 // Make the progress bar 227 245 progress = gtk_progress_bar_new(); … … 235 253 // Set up the hook that listens for input 236 254 g_stdin = g_io_channel_unix_new(0); 237 g_io_add_watch(g_stdin, G_IO_IN, (GIOFunc) update_progressbar_from_channel, g_stdin);238 }239 255 g_io_add_watch(g_stdin, G_IO_IN, 256 (GIOFunc) update_progressbar_from_channel, g_stdin); 257 } 240 258 // More basic GTK stuff 241 259 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); -
ldm/trunk/fuentes/po/POTFILES.in
r516 r855 11 11 gtkgreet/langwin.c 12 12 gtkgreet/prefwin.c 13 rc.d/I01-halt-check14 13 rc.d/I01-nbd-checkupdate 15 14 rc.d/S15-userLoginCheck -
ldm/trunk/fuentes/rc.d/Makefile.am
r516 r855 1 1 EXTRA_DIST = $(rcd_DATA) 2 2 rcddir = $(datadir)/ldm/rc.d 3 rcd_DATA = I01- halt-check I01-nbd-checkupdate K99-ltsp-cluster P00-ltsp-cluster S01-setup-xauth S15-userLoginCheck S20-restrictUser S99-debug-terminal S99-ltsp-cluster X50-generate-env X50-dmrc-processing X50-printers X51-openglX52-xcompmgr X95-run-x-session3 rcd_DATA = I01-nbd-checkupdate K99-ltsp-cluster P00-ltsp-cluster S01-setup-xauth S15-userLoginCheck S20-restrictUser S99-debug-terminal S99-ltsp-cluster X50-generate-env X50-dmrc-processing X50-printers X52-xcompmgr X95-run-x-session -
ldm/trunk/fuentes/rc.d/X50-dmrc-processing
r516 r855 18 18 19 19 # for code readability 20 do_command(){ 21 if boolean_is_true "$LTSP_FATCLIENT" ; then 22 eval "$@" 23 else 24 do_ssh "$@" 25 fi 26 } 27 20 28 do_ssh(){ 21 29 ssh -S "$LDM_SOCKET" "$LDM_SERVER" "$@" 2>/dev/null … … 33 41 34 42 if [ -n "$desktop" ]; then 35 session_exec=$(do_ sshsed -n "s/^Exec=//p" "/usr/share/xsessions/$desktop.desktop")43 session_exec=$(do_command sed -n "s/^Exec=//p" "/usr/share/xsessions/$desktop.desktop") 36 44 if [ -n "$session_exec" ]; then 37 45 LDM_SESSION="$session_exec" … … 63 71 ;; 64 72 default|'') 65 ldm_session_from_desktop_file "$(get_dmrc_key "Session")" && break 66 ldm_session_from_desktop_file "$LDM_SESSION" && break 73 ldm_session_from_desktop_file "$(get_dmrc_key "Session")" || 74 ldm_session_from_desktop_file "$LDM_SESSION" || 75 true 67 76 ;; 68 77 *) 69 78 LDM_SESSION="$LDM_SELECTED_SESSION" 70 79 # If there's a corresponding xsession.desktop file, save its name to .dmrc 71 dmrc_session=$(do_ ssh"grep -lR '^Exec=$LDM_SESSION$' /usr/share/xsessions/ | sed -n '/\/usr\/share\/xsessions\/\(.*\)\.desktop/{s//\1/p;q}'")80 dmrc_session=$(do_command "grep -lR '^Exec=$LDM_SESSION$' /usr/share/xsessions/ | sed -n '/\/usr\/share\/xsessions\/\(.*\)\.desktop/{s//\1/p;q}'") 72 81 if [ -n "$dmrc_session" ]; then 73 82 put_dmrc_key "Session" "$dmrc_session" -
ldm/trunk/fuentes/rc.d/X50-generate-env
r516 r855 1 1 # -*- Shell-Script -*- 2 2 3 # Set up the LTSP_CLIENT and LTSP_CLIENT_HOSTNAME environment variables. 4 # We may not want to force set this: 3 # Set up the LTSP_* environment variables. 4 CLIENT_ENV="$CLIENT_ENV LTSP_CLIENT=$LDMINFO_IPADDR LTSP_CLIENT_HOSTNAME=$(hostname)" 5 test -n "$LTSP_CLIENT_MAC" && CLIENT_ENV="$CLIENT_ENV LTSP_CLIENT_MAC=$LTSP_CLIENT_MAC" 6 if boolean_is_true "$LTSP_FATCLIENT"; then 7 CLIENT_ENV="$CLIENT_ENV LTSP_FATCLIENT=$LTSP_FATCLIENT" 8 fi 5 9 6 CLIENT_ENV="$CLIENT_ENV LTSP_CLIENT=$LDMINFO_IPADDR LTSP_CLIENT_HOSTNAME=$(hostname)" 7 test -n "$LTSP_FATCLIENT" && CLIENT_ENV="$CLIENT_ENV LTSP_FATCLIENT=$LTSP_FATCLIENT" 8 test -n "$LTSP_CLIENT_MAC" && CLIENT_ENV="$CLIENT_ENV LTSP_CLIENT_MAC=$LTSP_CLIENT_MAC" 10 # Some DEs *require* certain environment variables to be set by the DM, 11 # notably DESKTOP_SESSION and XDG_CURRENT_DESKTOP. Let's try to set them here. 12 # At this point, LDM_SESSION is either unset, 13 # or it's set to the Exec= line of an xsession.desktop file, 14 # or it's user-defined, in which case we don't need to set any vars. 15 # do_command() was defined in X50-dmrc-processing. 16 if [ -z "$LDM_SESSION" ]; then 17 default_session=$(basename "$(do_command "readlink -qs /etc/alternatives/x-session-manager")") 18 # If default_session is empty, we select the first one with an Exec= line 19 DESKTOP_SESSION=$(do_command "grep -lR '^Exec=$default_session' /usr/share/xsessions/ | sed -n '/\/usr\/share\/xsessions\/\(.*\)\.desktop/{s//\1/p;q}'") 20 else 21 DESKTOP_SESSION=$(do_command "grep -lR '^Exec=$LDM_SESSION$' /usr/share/xsessions/ | sed -n '/\/usr\/share\/xsessions\/\(.*\)\.desktop/{s//\1/p;q}'") 22 fi 23 if [ -n "$DESKTOP_SESSION" ]; then 24 # We're setting the default LDM_SESSION instead of leaving it empty, 25 # only as a workaround for LP #1457730. 26 LDM_SESSION=$(do_command "sed -n 's/^Exec=//p' '/usr/share/xsessions/$DESKTOP_SESSION.desktop'") 27 # Match the deprecated X-LightDM-DesktopName and the newer DesktopNames. 28 XDG_CURRENT_DESKTOP=$(do_command "sed -n 's/^[^=]*DesktopName[^=]*=//p' '/usr/share/xsessions/$DESKTOP_SESSION.desktop'") 29 if [ -z "$XDG_CURRENT_DESKTOP" ]; then 30 XDG_CURRENT_DESKTOP=$(do_command "sed -n 's/^Name=//p' '/usr/share/xsessions/$DESKTOP_SESSION.desktop'") 31 fi 32 # DesktopNames is separated by ";" while XDG_CURRENT_DESKTOP by ":". 33 XDG_CURRENT_DESKTOP=$(echo "${XDG_CURRENT_DESKTOP%;}" | tr ';' ':') 34 fi 35 test -n "$DESKTOP_SESSION" && CLIENT_ENV="$CLIENT_ENV DESKTOP_SESSION='$DESKTOP_SESSION'" 36 test -n "$XDG_CURRENT_DESKTOP" && CLIENT_ENV="$CLIENT_ENV XDG_CURRENT_DESKTOP='$XDG_CURRENT_DESKTOP'" 37 9 38 export CLIENT_ENV 39 10 40 # Set our language, if a different one is picked. 11 12 if [ -z "$LDM_LANGUAGE" ]; then 13 LDM_LANGUAGE=$LANG41 if [ -n "$LDM_LANGUAGE" ]; then 42 MY_LANG="LANG=$LDM_LANGUAGE" 43 export MY_LANG 14 44 fi 15 45 … … 19 49 20 50 # Set the DISPLAY env, if not running over encrypted ssh 21 22 51 if boolean_is_true "$LDM_DIRECTX"; then 23 52 MY_DISP="DISPLAY=${LDMINFO_IPADDR}${DISPLAY}" … … 36 65 37 66 # Handle sound 38 39 67 if boolean_is_true "$SOUND"; then 40 68 if [ -z "$SOUND_DAEMON" ]; then -
ldm/trunk/fuentes/screen.d/ldm
r516 r855 128 128 fi 129 129 130 if [ -x /usr/share/ltsp/xinitrc ]; then 131 xinitrc=/usr/share/ltsp/xinitrc 130 if boolean_is_true "$LDM_DIRECTX" ; then 131 if [ $({ echo "1.17"; X -version 2>&1 | sed -n 's/X.Org X Server //p';} | sort -V | head -n 1) = "1.17" ]; then 132 # Xorg after 1.17 needs `-listen tcp`, see 133 # http://cgit.freedesktop.org/xorg/xserver/commit/?id=cc59be38b7eff52a1d003b390f2994c73ee0b3e9 134 X_ARGS="-listen tcp $X_ARGS" 135 fi 136 else 137 X_ARGS="-nolisten tcp $X_ARGS" 132 138 fi 139 140 xinitrc=/usr/share/ltsp/xinitrc 133 141 134 142 -
ldm/trunk/fuentes/share/ldm-script.in
r516 r855 50 50 51 51 for SCRIPT in $(find -L $RCDIRS -type f -name "$SCRIPTS" -printf '%f\n' | 52 tr ' ' '\n' | egrep ^[ 0-9a-zA-Z_\-]*$ | sort -u)52 tr ' ' '\n' | egrep ^[[:alnum:]_\-]*$ | sort -u) 53 53 do 54 54 # only source the first instance of the script found -
ldm/trunk/fuentes/src/ldm.c
r516 r855 47 47 * Setting up LDM env. variables 48 48 */ 49 void get_ldm_env() { 49 void 50 get_ldm_env() 51 { 50 52 gchar *greeter_path, *wm_path; 51 53 … … 67 69 greeter_path = g_strdup("ldmgtkgreet"); 68 70 69 if(greeter_path[0] != '/') { 70 ldm.greeter_prog = g_strjoin("/", LDM_EXEC_DIR, greeter_path, NULL); 71 if (greeter_path[0] != '/') { 72 ldm.greeter_prog = 73 g_strjoin("/", LDM_EXEC_DIR, greeter_path, NULL); 71 74 g_free(greeter_path); 72 75 } else { … … 75 78 76 79 wm_path = g_strdup(getenv("LDM_WINMANAGER")); 77 if (!wm_path)80 if (!wm_path) 78 81 wm_path = g_strdup("wwm"); 79 82 80 if (wm_path[0] != '/') {83 if (wm_path[0] != '/') { 81 84 ldm.wm_prog = g_strjoin("/", LDM_EXEC_DIR, wm_path, NULL); 82 85 g_free(wm_path); … … 90 93 * main entry point 91 94 */ 92 int main(int argc, char *argv[]) { 95 int 96 main(int argc, char *argv[]) 97 { 93 98 /* decls */ 94 99 gchar *auth_plugin = NULL; … … 96 101 97 102 /* Init log settings */ 98 log_init(ldm_getenv_bool("LDM_SYSLOG"),ldm_getenv_int("LDM_LOGLEVEL",-1)); 103 log_init(ldm_getenv_bool("LDM_SYSLOG"), 104 ldm_getenv_int("LDM_LOGLEVEL", -1)); 99 105 100 106 #ifdef ENABLE_NLS 101 setlocale 102 bindtextdomain 103 bind_textdomain_codeset 104 textdomain 107 setlocale(LC_ALL, ""); 108 bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR); 109 bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); 110 textdomain(GETTEXT_PACKAGE); 105 111 #endif 106 112 … … 111 117 sigemptyset(&action.sa_mask); 112 118 action.sa_flags = SA_SIGINFO; 113 sigaction 119 sigaction(SIGCHLD, &action, NULL); 114 120 115 121 /* … … 118 124 bzero(&ldm, sizeof ldm); 119 125 120 ldm.pid = getpid(); /* Get our pid, to use in the command_socket */126 ldm.pid = getpid(); /* Get our pid, to use in the command_socket */ 121 127 ldm.display = g_strdup(getenv("DISPLAY")); 122 128 … … 125 131 */ 126 132 get_ipaddr(); 127 log_entry("ldm",6,"started on client with IP address: %s", ldm.ipaddr); 133 log_entry("ldm", 6, "started on client with IP address: %s", 134 ldm.ipaddr); 128 135 129 136 /* … … 140 147 * Load plugins 141 148 */ 142 if (ldm_load_plugins())143 log_entry("ldm", 3,"unable to load plugins");149 if (ldm_load_plugins()) 150 log_entry("ldm", 3, "unable to load plugins"); 144 151 145 152 /* 146 153 * Begin running display manager 147 154 */ 148 log_entry("ldm", 6,"calling rc.d init scripts");149 rc_files("init"); /* Execute any rc files */155 log_entry("ldm", 6, "calling rc.d init scripts"); 156 rc_files("init"); /* Execute any rc files */ 150 157 151 158 if (!ldm.autologin) { … … 153 160 gint rfd, wfd, rfd2, wfd2; 154 161 155 log_entry("ldm", 7,"spawning window manager: %s", ldm.wm_prog);162 log_entry("ldm", 7, "spawning window manager: %s", ldm.wm_prog); 156 163 ldm.wmpid = ldm_spawn(ldm.wm_prog, &rfd2, &wfd2, NULL); 157 log_entry("ldm", 7,"spawning greeter: %s", ldm.greeter_prog);164 log_entry("ldm", 7, "spawning greeter: %s", ldm.greeter_prog); 158 165 ldm.greeterpid = ldm_spawn(ldm.greeter_prog, &rfd, &wfd, NULL); 159 166 set_greeter_pid(ldm.greeterpid); … … 171 178 /* allow choosing backend */ 172 179 backends = g_strjoinv("|", ldm_get_plugins()); 173 cmd = g_strconcat("pref choice;backend;Authentication Backend;Select _Backend ...;session;", 174 backends, "\n", NULL); 175 if(ask_greeter(cmd)) 180 cmd = 181 g_strconcat 182 ("pref choice;backend;Authentication Backend;Select _Backend ...;session;", 183 backends, "\n", NULL); 184 if (ask_greeter(cmd)) 176 185 die("ldm", "%s from greeter failed", cmd); 177 186 g_free(backends); … … 196 205 /* Init plugin */ 197 206 set_current_plugin(auth_plugin); 198 log_entry("ldm",6,"authenticating with backend: %s", auth_plugin); 207 log_entry("ldm", 6, "authenticating with backend: %s", 208 auth_plugin); 199 209 ldm_setup_plugin(); 200 210 } while (ldm_auth_plugin()); … … 205 215 206 216 set_current_plugin(auth_plugin); 207 log_entry("ldm",6,"guest authenticating with backend: %s", auth_plugin); 217 log_entry("ldm", 6, "guest authenticating with backend: %s", 218 auth_plugin); 208 219 ldm_setup_plugin(); 209 220 … … 222 233 */ 223 234 224 log_entry("ldm", 6,"X session ended");225 226 log_entry("ldm", 6,"calling rc.d stop scripts");227 rc_files("stop"); /* Execute any rc files */235 log_entry("ldm", 6, "X session ended"); 236 237 log_entry("ldm", 6, "calling rc.d stop scripts"); 238 rc_files("stop"); /* Execute any rc files */ 228 239 229 240 /* Closing plugin */ … … 245 256 g_free(ldm.control_socket); 246 257 g_free(ldm.ipaddr); 247 g_list_foreach(host_list, (GFunc) g_free, NULL);258 g_list_foreach(host_list, (GFunc) g_free, NULL); 248 259 g_list_free(host_list); 249 260 -
ldm/trunk/fuentes/src/ldmgreetercomm.c
r516 r855 20 20 * set_greeter_pid 21 21 */ 22 void set_greeter_pid(GPid p) { 22 void 23 set_greeter_pid(GPid p) 24 { 23 25 greeterpid = p; 24 26 } … … 27 29 * set_greeter_read_channel 28 30 */ 29 void set_greeter_read_channel(GIOChannel *gr) { 31 void 32 set_greeter_read_channel(GIOChannel * gr) 33 { 30 34 greeterr = gr; 31 35 } … … 34 38 * set_greeter_read_channel 35 39 */ 36 void set_greeter_write_channel(GIOChannel *gw) { 40 void 41 set_greeter_write_channel(GIOChannel * gw) 42 { 37 43 greeterw = gw; 38 44 } … … 45 51 * Return 1 if fails, else 0 46 52 */ 47 int ask_greeter(gchar *cmd) { 53 int 54 ask_greeter(gchar * cmd) 55 { 48 56 /* Write command to io channel of the greeter */ 49 57 GError *ge = NULL; 50 if(g_io_channel_write_chars(greeterw, cmd, -1, NULL, &ge) != G_IO_STATUS_NORMAL) { 51 log_entry("ldm",4,"%s", ge->message); 58 if (g_io_channel_write_chars(greeterw, cmd, -1, NULL, &ge) != 59 G_IO_STATUS_NORMAL) { 60 log_entry("ldm", 4, "%s", ge->message); 52 61 return 1; 53 62 } 54 63 55 64 /* Flush buffer */ 56 if (g_io_channel_flush(greeterw, &ge) != G_IO_STATUS_NORMAL) {57 log_entry("ldm", 4,"%s", ge->message);65 if (g_io_channel_flush(greeterw, &ge) != G_IO_STATUS_NORMAL) { 66 log_entry("ldm", 4, "%s", ge->message); 58 67 return 1; 59 68 } … … 67 76 * s_ldm -- struct ldm_info 68 77 */ 69 void close_greeter() { 78 void 79 close_greeter() 80 { 70 81 gboolean failed = 0; 71 82 gchar *cmd = "quit\n"; … … 74 85 return; 75 86 76 if (ask_greeter(cmd))87 if (ask_greeter(cmd)) 77 88 failed = 1; 78 89 79 if (failed) {80 log_entry("ldm", 3,"quit command failed. SIGTERM to greeter");81 if (kill(greeterpid, SIGTERM) < 0) {82 log_entry("ldm", 3,"SIGTERM failed. SIGKILL to greeter");90 if (failed) { 91 log_entry("ldm", 3, "quit command failed. SIGTERM to greeter"); 92 if (kill(greeterpid, SIGTERM) < 0) { 93 log_entry("ldm", 3, "SIGTERM failed. SIGKILL to greeter"); 83 94 kill(greeterpid, SIGKILL); 84 95 } … … 97 108 * Ask greeter to print a message to UI 98 109 */ 99 int set_message(gchar *msg) { 110 int 111 set_message(gchar * msg) 112 { 100 113 gchar *cmd; 101 114 … … 104 117 105 118 cmd = g_strconcat("msg ", msg, "\n", NULL); 106 if (ask_greeter(cmd))119 if (ask_greeter(cmd)) 107 120 return 1; 108 121 g_free(cmd); … … 120 133 * Return 1 if fails, else 0 and buffer with data in 121 134 */ 122 int listen_greeter(gchar **buffer, gsize *buflen, gsize *end) { 135 int 136 listen_greeter(gchar ** buffer, gsize * buflen, gsize * end) 137 { 123 138 while (1) { 124 139 /* Reads data from I/O channel of the greeter */ 125 140 GError *ge = NULL; 126 if(g_io_channel_read_line(greeterr, buffer, buflen, end, &ge) != G_IO_STATUS_NORMAL) { 127 log_entry("ldm",3,"%s", ge->message); 141 if (g_io_channel_read_line(greeterr, buffer, buflen, end, &ge) != 142 G_IO_STATUS_NORMAL) { 143 log_entry("ldm", 3, "%s", ge->message); 128 144 return 1; 129 145 } 130 146 131 147 g_strstrip(*buffer); 132 log_entry("ldm", 7,"Got command: %s",*buffer);148 log_entry("ldm", 7, "Got command: %s", *buffer); 133 149 134 150 /* handle callbacks */ … … 154 170 * buffer -- buffer to write to answer 155 171 */ 156 gchar *ask_value_greeter(gchar *cmd) { 172 gchar * 173 ask_value_greeter(gchar * cmd) 174 { 157 175 gsize len, end; 158 176 gchar *buffer; 159 if (ask_greeter(cmd))177 if (ask_greeter(cmd)) 160 178 die("ldm", "%s from greeter failed", cmd); 161 179 162 if (listen_greeter(&buffer, &len, &end))180 if (listen_greeter(&buffer, &len, &end)) 163 181 die("ldm", "%s from greeter failed", cmd); 164 182 -
ldm/trunk/fuentes/src/ldminfo.c
r516 r855 40 40 static GHashTable *ldminfo_hash = NULL; 41 41 42 static void generate_hash_table(void) { 42 static void 43 generate_hash_table(void) 44 { 43 45 char buffer[1024]; 44 FILE * file; 45 char ** ret; 46 display_names = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); 46 FILE *file; 47 char **ret; 48 display_names = 49 g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); 47 50 file = fopen(RC_DIR "/locales", "r"); 48 if (file == NULL) {51 if (file == NULL) { 49 52 return; 50 53 } 51 while (fgets(buffer, sizeof(buffer), file) != NULL) {54 while (fgets(buffer, sizeof(buffer), file) != NULL) { 52 55 ret = g_strsplit(buffer, " ", 2); 53 g_hash_table_insert(display_names, g_strdup(ret[0]), g_strdup(g_strchomp(ret[1]))); 56 g_hash_table_insert(display_names, g_strdup(ret[0]), 57 g_strdup(g_strchomp(ret[1]))); 54 58 g_strfreev(ret); 55 59 } … … 57 61 } 58 62 59 static gchar * get_display_name(gchar * locale) { 60 gchar * compare_to; 61 char ** ret; 62 gchar * result; 63 static gchar * 64 get_display_name(gchar * locale) 65 { 66 gchar *compare_to; 67 char **ret; 68 gchar *result; 63 69 ret = g_strsplit(locale, ".", 2); 64 70 compare_to = g_strdup(ret[0]); 65 71 g_strfreev(ret); 66 if (compare_to == NULL) {72 if (compare_to == NULL) { 67 73 return g_strdup(locale); 68 74 } 69 75 result = g_hash_table_lookup(display_names, compare_to); 70 if (result == NULL) {76 if (result == NULL) { 71 77 result = g_strdup(locale); 72 78 } … … 78 84 * ldminfo struct freed 79 85 */ 80 void ldminfo_free() { 86 void 87 ldminfo_free() 88 { 81 89 g_hash_table_destroy(ldminfo_hash); 82 90 } … … 85 93 * ldminfo_lookup 86 94 */ 87 ldminfo *ldminfo_lookup(gconstpointer key) { 95 ldminfo * 96 ldminfo_lookup(gconstpointer key) 97 { 88 98 return g_hash_table_lookup(ldminfo_hash, key); 89 99 } … … 92 102 * ldminfo_size 93 103 */ 94 int ldminfo_size() { 104 int 105 ldminfo_size() 106 { 95 107 return g_hash_table_size(ldminfo_hash); 96 108 } … … 99 111 * ldminfo_init 100 112 */ 101 void ldminfo_init(GList **host_list, const char *ldm_server) { 113 void 114 ldminfo_init(GList ** host_list, const char *ldm_server) 115 { 102 116 char **hosts_char = NULL; 103 117 ldminfo *ldm_host_info = NULL; … … 108 122 /* Static hash table */ 109 123 ldminfo_hash = g_hash_table_new_full(g_str_hash, g_str_equal, 110 124 g_free, g_free); 111 125 hosts_char = g_strsplit(ldm_server, " ", -1); 112 126 … … 152 166 * etc. Things like nc -z hostname ssh, etc. 153 167 */ 154 void _ldminfo_query_one(const char *hostname, ldminfo * ldm_host_info) { 168 void 169 _ldminfo_query_one(const char *hostname, ldminfo * ldm_host_info) 170 { 155 171 int filedes, numbytes; 156 172 char buf[MAXBUFSIZE]; … … 181 197 * split string by line and then construct the ldm_host_info 182 198 */ 183 void _ldminfo_parse_string(const char *s, ldminfo * ldm_host_info) { 199 void 200 _ldminfo_parse_string(const char *s, ldminfo * ldm_host_info) 201 { 184 202 char **lines = NULL; 185 203 int i; … … 194 212 g_list_append(ldm_host_info->languages, g_strdup(val[1])); 195 213 ldm_host_info->language_names = 196 g_list_append(ldm_host_info->language_names, get_display_name(val[1])); 197 g_strfreev(val); 198 } else if (!g_ascii_strncasecmp(lines[i], "session:", 8) && !g_strstr_len(s, -1, "session-with-name")) { 214 g_list_append(ldm_host_info->language_names, 215 get_display_name(val[1])); 216 g_strfreev(val); 217 } else if (!g_ascii_strncasecmp(lines[i], "session:", 8) 218 && !g_strstr_len(s, -1, "session-with-name")) { 199 219 gchar **val; 200 220 gchar *name; 201 221 val = g_strsplit(lines[i], ":", 2); 202 222 name = g_strrstr(val[1], "/"); 203 if (name) {223 if (name) { 204 224 name++; 205 225 } else { 206 226 name = val[1]; 207 227 } 208 ldm_host_info->sessions = g_list_append(ldm_host_info->sessions, g_strdup(val[1])); 209 ldm_host_info->session_names = g_list_append(ldm_host_info->session_names, g_strdup(name)); 228 ldm_host_info->sessions = 229 g_list_append(ldm_host_info->sessions, g_strdup(val[1])); 230 ldm_host_info->session_names = 231 g_list_append(ldm_host_info->session_names, 232 g_strdup(name)); 210 233 g_strfreev(val); 211 234 } else if (!g_ascii_strncasecmp(lines[i], "session-with-name:", 8)) { 212 235 gchar **val; 213 236 val = g_strsplit(lines[i], ":", 3); 214 ldm_host_info->sessions = g_list_append(ldm_host_info->sessions, g_strdup(val[2])); 215 ldm_host_info->session_names = g_list_append(ldm_host_info->session_names, g_strdup(val[1])); 237 ldm_host_info->sessions = 238 g_list_append(ldm_host_info->sessions, g_strdup(val[2])); 239 ldm_host_info->session_names = 240 g_list_append(ldm_host_info->session_names, 241 g_strdup(val[1])); 216 242 g_strfreev(val); 217 243 } else if (!g_ascii_strncasecmp(lines[i], "rating:", 7)) { … … 238 264 * name -- env. variable name 239 265 */ 240 int ldm_getenv_bool(const char *name) { 266 int 267 ldm_getenv_bool(const char *name) 268 { 241 269 char *env = getenv(name); 242 270 243 if (env) {271 if (env) { 244 272 if (*env == 'y' || *env == 't' || *env == 'T' || *env == 'Y') 245 273 return 1; … … 249 277 250 278 /* 279 * ldm_getenv_bool_default 280 * Return if env variable is set to true or false 281 * name -- env. variable name 282 * default_value -- int to return as default [0,1] 283 */ 284 int 285 ldm_getenv_bool_default(const char *name, const int default_value) 286 { 287 char *env = getenv(name); 288 289 if (env != NULL) { 290 if (*env == 'y' || *env == 't' || *env == 'T' || *env == 'Y') { 291 return 1; 292 } else { 293 return 0; 294 } 295 } 296 return default_value; 297 } 298 299 /* 251 300 * ldm_getenv_int 252 301 * Return an int, will return default_value if not set 253 302 */ 254 int ldm_getenv_int(const char *name,int default_value) { 303 int 304 ldm_getenv_int(const char *name, int default_value) 305 { 255 306 char *env = getenv(name); 256 307 257 if (env) {308 if (env) { 258 309 return atoi(env); 259 310 } 260 311 return default_value; 261 312 } 313 314 /* 315 * ldm_getenv_str_default 316 * Return a string, will return default_value if not set 317 * No malloc()s, caller should strdup the result if needed. 318 */ 319 const char * 320 ldm_getenv_str_default(const char *name, const char *default_value) 321 { 322 char *env = getenv(name); 323 324 if (env) { 325 return env; 326 } 327 return default_value; 328 } -
ldm/trunk/fuentes/src/ldminfo.h
r516 r855 46 46 47 47 int ldm_getenv_bool(const char *name); 48 int ldm_getenv_bool_default(const char *name, const int default_value); 48 49 int ldm_getenv_int(const char *name, int default_value); 50 const char *ldm_getenv_str_default(const char *name, const char *default_value); 49 51 50 52 ldminfo *ldminfo_lookup(gconstpointer key); -
ldm/trunk/fuentes/src/ldmplugin.c
r516 r855 13 13 #include "logging.h" 14 14 15 GTree *plugin_list = NULL;16 gchar **plugin_names = NULL;15 GTree *plugin_list = NULL; 16 gchar **plugin_names = NULL; 17 17 static jmp_buf auth_jmp_buf; 18 static gchar* current_plugin = NULL; 19 20 static int g_strcmp(gconstpointer a, gconstpointer b) { 21 return strcmp((char*)a, (char*)b); 18 static gchar *current_plugin = NULL; 19 20 static int 21 g_strcmp(gconstpointer a, gconstpointer b) 22 { 23 return strcmp((char *) a, (char *) b); 22 24 } 23 25 … … 26 28 * Set current plugin name 27 29 */ 28 void set_current_plugin(char *plug_name) { 30 void 31 set_current_plugin(char *plug_name) 32 { 29 33 current_plugin = plug_name; 30 34 } … … 34 38 * Iterate over plugin_list and start plugin 35 39 */ 36 void ldm_start_plugin() { 37 LdmBackend *desc = (LdmBackend*) g_tree_lookup(plugin_list, current_plugin); 38 if(desc->start_cb) 40 void 41 ldm_start_plugin() 42 { 43 LdmBackend *desc = 44 (LdmBackend *) g_tree_lookup(plugin_list, current_plugin); 45 if (desc->start_cb) 39 46 desc->start_cb(); 40 47 } … … 44 51 * Iterate over plugin_list and close plugin 45 52 */ 46 void ldm_close_plugin() { 47 LdmBackend *desc = (LdmBackend*) g_tree_lookup(plugin_list, current_plugin); 48 if(desc->clean_cb) 53 void 54 ldm_close_plugin() 55 { 56 LdmBackend *desc = 57 (LdmBackend *) g_tree_lookup(plugin_list, current_plugin); 58 if (desc->clean_cb) 49 59 desc->clean_cb(); 50 60 } … … 54 64 * Call setup callback function of plugin 55 65 */ 56 void ldm_setup_plugin() { 57 log_entry("ldm",7,"setting up plugin: %s", current_plugin); 58 LdmBackend *desc = (LdmBackend*) g_tree_lookup(plugin_list, current_plugin); 59 if(desc->init_cb) 66 void 67 ldm_setup_plugin() 68 { 69 log_entry("ldm", 7, "setting up plugin: %s", current_plugin); 70 LdmBackend *desc = 71 (LdmBackend *) g_tree_lookup(plugin_list, current_plugin); 72 if (desc->init_cb) 60 73 desc->init_cb(); 61 74 } … … 65 78 * Call setup guest authentication values of plugin 66 79 */ 67 void ldm_guest_auth_plugin() { 68 log_entry("ldm",7,"guest auth plugin: %s", current_plugin); 69 LdmBackend *desc = (LdmBackend*) g_tree_lookup(plugin_list, current_plugin); 70 if(desc->guest_cb) 80 void 81 ldm_guest_auth_plugin() 82 { 83 log_entry("ldm", 7, "guest auth plugin: %s", current_plugin); 84 LdmBackend *desc = 85 (LdmBackend *) g_tree_lookup(plugin_list, current_plugin); 86 if (desc->guest_cb) 71 87 desc->guest_cb(); 72 88 } … … 77 93 * Returns 0 on success, 1 otherwise 78 94 */ 79 int ldm_auth_plugin() { 80 LdmBackend *desc = (LdmBackend*) g_tree_lookup(plugin_list, current_plugin); 95 int 96 ldm_auth_plugin() 97 { 98 LdmBackend *desc = 99 (LdmBackend *) g_tree_lookup(plugin_list, current_plugin); 81 100 82 101 if (desc->guest_cb) … … 86 105 87 106 switch (setjmp(auth_jmp_buf)) { 88 89 if(desc->auth_cb)90 91 92 93 94 95 log_entry("ldm",7,"reloading backend");96 97 98 if(desc->guest_cb)99 100 107 case AUTH_EXC_NONE: 108 if (desc->auth_cb) 109 desc->auth_cb(); 110 return 0; 111 case AUTH_EXC_RELOAD_BACKEND: 112 ldm_close_plugin(); 113 114 log_entry("ldm", 7, "reloading backend"); 115 return 1; 116 case AUTH_EXC_GUEST: 117 if (desc->guest_cb) 118 desc->guest_cb(); 119 return 0; 101 120 } 102 121 return 1; … … 108 127 */ 109 128 void __attribute__ ((visibility("default"))) 110 ldm_init_plugin(LdmBackend* descriptor) { 111 gchar** new_plugin_names; 129 ldm_init_plugin(LdmBackend * descriptor) 130 { 131 gchar **new_plugin_names; 112 132 int plugin_names_len; 113 133 114 134 plugin_names_len = g_strv_length(plugin_names); 115 135 new_plugin_names = g_realloc(plugin_names, 116 (plugin_names_len +1)*sizeof(gchar*));136 (plugin_names_len + 1) * sizeof(gchar *)); 117 137 if (new_plugin_names != plugin_names) { 118 138 g_free(plugin_names); … … 120 140 } 121 141 plugin_names[plugin_names_len] = g_strdup(descriptor->name); 122 plugin_names[plugin_names_len +1] = NULL;142 plugin_names[plugin_names_len + 1] = NULL; 123 143 124 144 g_tree_replace(plugin_list, descriptor->name, descriptor); 125 log_entry("ldm", 7,"%s initialized", descriptor->name);145 log_entry("ldm", 7, "%s initialized", descriptor->name); 126 146 } 127 147 … … 131 151 * path -- plugin path 132 152 */ 133 void _load_plugin(const char *path) { 153 void 154 _load_plugin(const char *path) 155 { 134 156 void *handle = dlopen(path, RTLD_LAZY); 135 157 if (handle) { 136 log_entry("ldm", 7,"loaded %s", path);158 log_entry("ldm", 7, "loaded %s", path); 137 159 return; 138 160 } 139 161 140 log_entry("ldm", 4,"%s: Invalid LDM plugin %s", dlerror(), path);162 log_entry("ldm", 4, "%s: Invalid LDM plugin %s", dlerror(), path); 141 163 } 142 164 … … 145 167 * Load all plugins at LDM_PLUG_DIR 146 168 */ 147 int ldm_load_plugins() { 169 int 170 ldm_load_plugins() 171 { 148 172 plugin_list = g_tree_new(g_strcmp); 149 173 g_tree_ref(plugin_list); 150 plugin_names = g_malloc0(sizeof(gchar *));151 152 DIR *plugin_dir = opendir(LDM_PLUG_DIR);174 plugin_names = g_malloc0(sizeof(gchar *)); 175 176 DIR *plugin_dir = opendir(LDM_PLUG_DIR); 153 177 154 178 if (!plugin_dir) { 155 log_entry("ldm", 3,"unable to open plugin dir: %s", LDM_PLUG_DIR);179 log_entry("ldm", 3, "unable to open plugin dir: %s", LDM_PLUG_DIR); 156 180 return 1; 157 181 } 158 struct dirent* entry; 159 while ( (entry = readdir(plugin_dir)) ) { 160 if ((entry->d_type == DT_REG || entry->d_type == DT_UNKNOWN) && (strstr(entry->d_name, ".so") != NULL)) { 161 int name_len = strlen(entry->d_name)+strlen(LDM_PLUG_DIR)+2; 162 char* plug_name = (char *) malloc(name_len); 163 snprintf(plug_name, name_len, "%s/%s", LDM_PLUG_DIR, entry->d_name); 164 log_entry("ldm",7,"loading: %s", plug_name); 182 struct dirent *entry; 183 while ((entry = readdir(plugin_dir))) { 184 if ((entry->d_type == DT_REG || entry->d_type == DT_UNKNOWN) 185 && (strstr(entry->d_name, ".so") != NULL)) { 186 int name_len = 187 strlen(entry->d_name) + strlen(LDM_PLUG_DIR) + 2; 188 char *plug_name = (char *) malloc(name_len); 189 snprintf(plug_name, name_len, "%s/%s", LDM_PLUG_DIR, 190 entry->d_name); 191 log_entry("ldm", 7, "loading: %s", plug_name); 165 192 166 193 _load_plugin(plug_name); … … 169 196 } 170 197 171 if (errno) perror(strerror(errno)); 198 if (errno) 199 perror(strerror(errno)); 172 200 closedir(plugin_dir); 173 201 return 0; … … 179 207 * error before retrying. 180 208 */ 181 void ldm_raise_auth_except(LdmAuthException n) { 209 void 210 ldm_raise_auth_except(LdmAuthException n) 211 { 182 212 longjmp(auth_jmp_buf, n); 183 213 } 184 214 185 gchar** ldm_get_plugins() { 215 gchar ** 216 ldm_get_plugins() 217 { 186 218 return plugin_names; 187 219 } 188 -
ldm/trunk/fuentes/src/ldmutils.c
r516 r855 22 22 * Run startup commands. 23 23 */ 24 void rc_files(char *action) { 24 void 25 rc_files(char *action) 26 { 25 27 GPid rcpid; 26 28 gchar *command; 27 29 28 command = g_strjoin(" ", "/bin/sh", RC_DIR "/ldm-script", action, NULL); 30 command = 31 g_strjoin(" ", "/bin/sh", RC_DIR "/ldm-script", action, NULL); 29 32 30 33 rcpid = ldm_spawn(command, NULL, NULL, NULL); … … 38 41 * Get ip address of host 39 42 */ 40 void get_ipaddr() { 43 void 44 get_ipaddr() 45 { 41 46 int numreqs = 10; 42 47 struct ifconf ifc; 43 struct ifreq *ifr; /* netdevice(7) */48 struct ifreq *ifr; /* netdevice(7) */ 44 49 struct ifreq info; 45 50 struct sockaddr_in *sa; … … 49 54 skfd = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP); 50 55 if (skfd < 0) 51 die("ldm", "socket");56 die("ldm", "socket"); 52 57 53 58 /* … … 59 64 while (TRUE) { 60 65 ifc.ifc_len = sizeof(struct ifreq) * numreqs; 61 ifc.ifc_buf = (char *) realloc(ifc.ifc_buf, ifc.ifc_len);66 ifc.ifc_buf = (char *) realloc(ifc.ifc_buf, ifc.ifc_len); 62 67 if (ifc.ifc_buf == NULL) 63 die("ldm", "out of memory");68 die("ldm", "out of memory"); 64 69 65 70 if (ioctl(skfd, SIOCGIFCONF, &ifc) < 0) { 66 log_entry("ldm", 4,"SIOCGIFCONF");71 log_entry("ldm", 4, "SIOCGIFCONF"); 67 72 goto out; 68 73 } 69 74 70 if (ifc.ifc_len == (int) sizeof(struct ifreq) * numreqs){75 if (ifc.ifc_len == (int) sizeof(struct ifreq) * numreqs) { 71 76 /* assume it overflowed and try again */ 72 77 numreqs += 10; … … 89 94 strcpy(info.ifr_name, ifr->ifr_name); 90 95 if (ioctl(skfd, SIOCGIFFLAGS, &info) < 0) { 91 log_entry("ldm", 4,"SIOCGIFFLAGS");96 log_entry("ldm", 4, "SIOCGIFFLAGS"); 92 97 goto out; 93 98 } … … 102 107 } 103 108 104 out:109 out: 105 110 if (ifc.ifc_buf) 106 111 free(ifc.ifc_buf); 107 112 108 113 if (n == ifc.ifc_len) 109 die("ldm", "no configured interface found");114 die("ldm", "no configured interface found"); 110 115 } 111 116 … … 115 120 * Execute commands. Prints nice error message if failure. 116 121 */ 117 GPid ldm_spawn(gchar *command, gint *rfd, gint *wfd, GSpawnChildSetupFunc setup) { 122 GPid 123 ldm_spawn(gchar * command, gint * rfd, gint * wfd, 124 GSpawnChildSetupFunc setup) 125 { 118 126 GPid pid; 119 127 GError *error = NULL; … … 122 130 gchar **argv = NULL; 123 131 124 g_shell_parse_argv 132 g_shell_parse_argv(command, &argc, &argv, NULL); 125 133 126 134 if (!wfd) 127 135 flags |= G_SPAWN_STDOUT_TO_DEV_NULL; 128 136 129 g_spawn_async_with_pipes ( 130 NULL, /* Working directory: inherit */ 131 argv, /* Arguments, null term */ 132 NULL, /* Environment, inherit from parent */ 133 flags, /* Flags, set above */ 134 setup, /* Child setup function: passed to us */ 135 NULL, /* No user data */ 136 &pid, /* child pid */ 137 wfd, /* Pointer to in file descriptor */ 138 rfd, /* Pointer to out file descriptor */ 139 NULL, /* No stderr */ 140 &error); /* GError handler */ 137 g_spawn_async_with_pipes(NULL, /* Working directory: inherit */ 138 argv, /* Arguments, null term */ 139 NULL, /* Environment, inherit from parent */ 140 flags, /* Flags, set above */ 141 setup, /* Child setup function: passed to us */ 142 NULL, /* No user data */ 143 &pid, /* child pid */ 144 wfd, /* Pointer to in file descriptor */ 145 rfd, /* Pointer to out file descriptor */ 146 NULL, /* No stderr */ 147 &error); /* GError handler */ 141 148 142 149 g_strfreev(argv); 143 150 144 151 if (error) { 145 log_entry("ldm",3,"ldm_spawn failed to execute: %s", error->message); 152 log_entry("ldm", 3, "ldm_spawn failed to execute: %s", 153 error->message); 146 154 } else { 147 log_entry("ldm", 7,"ldm_spawn: pid = %d", pid);155 log_entry("ldm", 7, "ldm_spawn: pid = %d", pid); 148 156 } 149 157 … … 158 166 * ldm_wait 159 167 */ 160 void handle_sigchld(int signo) { 168 void 169 handle_sigchld(int signo) 170 { 161 171 /* do nothing */ 162 172 child_exited = TRUE; … … 168 178 * wait for child process 169 179 */ 170 void ldm_wait(GPid pid) { 180 void 181 ldm_wait(GPid pid) 182 { 171 183 siginfo_t info; 172 log_entry("ldm", 7,"waiting for process: %d", pid);184 log_entry("ldm", 7, "waiting for process: %d", pid); 173 185 do { 174 186 int res; 175 res = waitid 187 res = waitid(P_PID, pid, &info, WEXITED | WSTOPPED); 176 188 if (res == -1) { 177 189 int temp; 178 190 temp = errno; 179 log_entry("ldm",4,"waitid returned an error: %s", strerror(errno)); 180 if(temp == ECHILD) { 191 log_entry("ldm", 4, "waitid returned an error: %s", 192 strerror(errno)); 193 if (temp == ECHILD) { 181 194 break; 182 195 } … … 189 202 break; 190 203 } else { 191 log_entry("ldm",4,"unexpected terminated process, pid: %d", 192 info.si_pid); 204 log_entry("ldm", 4, 205 "unexpected terminated process, pid: %d", 206 info.si_pid); 193 207 unexpected_child = TRUE; 194 208 } … … 197 211 198 212 if (info.si_code == CLD_EXITED) { 199 log_entry("ldm", 7,"process %d exited with status %d", info.si_pid,200 WEXITSTATUS(info.si_status));213 log_entry("ldm", 7, "process %d exited with status %d", 214 info.si_pid, WEXITSTATUS(info.si_status)); 201 215 } else if (info.si_code == CLD_KILLED) { 202 log_entry("ldm", 7,"process %d killed by signal %d", info.si_pid,203 info.si_status);216 log_entry("ldm", 7, "process %d killed by signal %d", info.si_pid, 217 info.si_status); 204 218 } 205 219 } … … 209 223 * Close window manager by SIGKILL 210 224 */ 211 void close_wm() { 225 void 226 close_wm() 227 { 212 228 if (!(ldm.wmpid)) { 213 229 return; 214 230 } 215 231 216 log_entry("ldm", 7,"closing window manager");232 log_entry("ldm", 7, "closing window manager"); 217 233 if (kill(ldm.wmpid, SIGKILL) < 0) { 218 log_entry("ldm", 3,"sending SIGKILL to window manager failed");234 log_entry("ldm", 3, "sending SIGKILL to window manager failed"); 219 235 } 220 236 ldm_wait(ldm.wmpid); 221 237 ldm.wmpid = 0; 222 238 } 223 -
ldm/trunk/fuentes/src/logging.c
r516 r855 46 46 * the boolean LDM_SYSLOG. 47 47 */ 48 void log_init(int syslog, int level) { 48 void 49 log_init(int syslog, int level) 50 { 49 51 if (level < 0 || level > 7) { 50 52 loglevel = LOGLEVEL; 51 } 52 else { 53 } else { 53 54 loglevel = level; 54 55 } … … 56 57 if (syslog) { 57 58 openlog("ldm", LOG_PID | LOG_NOWAIT, LOG_DAEMON); 58 } 59 else { 59 } else { 60 60 logfile = fopen(LOGFILE, "a"); 61 61 if (!logfile) { … … 63 63 exit(1); 64 64 } 65 setbuf(logfile, NULL); /* unbuffered writes to the log file */65 setbuf(logfile, NULL); /* unbuffered writes to the log file */ 66 66 } 67 67 } … … 71 71 * Close logging and clean exit 72 72 */ 73 void log_close() { 73 void 74 log_close() 75 { 74 76 if (logfile) 75 77 fclose(logfile); … … 82 84 * log_entry: log messages to file or syslog 83 85 */ 84 void log_entry(char *component, int level, const char *format, ...) { 86 void 87 log_entry(char *component, int level, const char *format, ...) 88 { 85 89 if (level < 0 || level > 7 || level > loglevel) 86 90 return; … … 98 102 strftime(timestr, sizeof(timestr), "%b %e %H:%M:%S", ptr); 99 103 100 fprintf(logfile, "%s: [%s] %s: ", timestr, component, LOG_LEVEL_NAMES[level]); 104 fprintf(logfile, "%s: [%s] %s: ", timestr, component, 105 LOG_LEVEL_NAMES[level]); 101 106 vfprintf(logfile, format, ap); 102 107 fprintf(logfile, "\n"); … … 114 119 * msg -- log message 115 120 */ 116 void die(char *component, const char *format, ...) { 121 void 122 die(char *component, const char *format, ...) 123 { 117 124 va_list ap; 118 125 va_start(ap, format); -
ldm/trunk/fuentes/src/plugin.c
r516 r855 15 15 * Ask the greeter to check autologin or get username 16 16 */ 17 void get_userid(gchar **username) { 17 void 18 get_userid(gchar ** username) 19 { 18 20 gchar *cmd; 19 21 … … 27 29 * get_passwd 28 30 */ 29 void get_passwd(gchar **password) { 31 void 32 get_passwd(gchar ** password) 33 { 30 34 gchar *cmd; 31 35 32 cmd = g_strconcat("prompts <b>", _("Password"), "</b>\npasswd\n", NULL); 33 *password = (gchar*) ask_value_greeter(cmd); 36 cmd = 37 g_strconcat("prompts <b>", _("Password"), "</b>\npasswd\n", NULL); 38 *password = (gchar *) ask_value_greeter(cmd); 34 39 35 set_message(g_strconcat("<b>", _("Verifying password. Please wait."), "</b>", NULL)); 40 set_message(g_strconcat 41 ("<b>", _("Verifying password. Please wait."), "</b>", 42 NULL)); 36 43 g_free(cmd); 37 44 } … … 40 47 * get_host 41 48 */ 42 void get_host(gchar **server) { 49 void 50 get_host(gchar ** server) 51 { 43 52 gchar *cmd = "hostname\n"; 44 53 gchar *host; 45 54 46 host = (gchar *) ask_value_greeter(cmd);47 if (g_ascii_strncasecmp(host, "None", 4)) {48 if (*server)55 host = (gchar *) ask_value_greeter(cmd); 56 if (g_ascii_strncasecmp(host, "None", 4)) { 57 if (*server) 49 58 g_free(*server); 50 59 *server = host; … … 55 64 * get_language 56 65 */ 57 void get_language(gchar **language) { 66 void 67 get_language(gchar ** language) 68 { 58 69 gchar *cmd = "language\n"; 59 70 gchar *lang; 60 71 61 lang = (gchar *) ask_value_greeter(cmd);72 lang = (gchar *) ask_value_greeter(cmd); 62 73 63 if (g_ascii_strncasecmp(lang, "None", 4)) {64 if (*language)74 if (g_ascii_strncasecmp(lang, "None", 4)) { 75 if (*language) 65 76 g_free(*language); 66 77 *language = lang; … … 72 83 * get_session 73 84 */ 74 void get_session(gchar **session) { 85 void 86 get_session(gchar ** session) 87 { 75 88 gchar *cmd = "session\n"; 76 89 gchar *sess; 77 90 78 sess = (gchar *) ask_value_greeter(cmd);91 sess = (gchar *) ask_value_greeter(cmd); 79 92 80 93 if (g_ascii_strncasecmp(sess, "None", 4)) { … … 90 103 * Return to variable xsession the LDM_XSESSION info 91 104 */ 92 void __attribute__ ((visibility("default"))) get_Xsession(gchar **xsession, gconstpointer server) { 105 void __attribute__ ((visibility("default"))) get_Xsession(gchar ** 106 xsession, 107 gconstpointer 108 server) 109 { 93 110 ldminfo *curr_host = NULL; 94 111 gchar *tmp_xsess = NULL; … … 97 114 if (!tmp_xsess || strlen(tmp_xsess) == 0) { 98 115 curr_host = ldminfo_lookup(server); 99 if (curr_host) {116 if (curr_host) { 100 117 tmp_xsess = curr_host->xsession; 101 118 if (!tmp_xsess || strlen(tmp_xsess) == 0) { 102 119 tmp_xsess = g_strdup(getenv("LDM_DEFAULT_XSESSION")); 103 120 if (!tmp_xsess || strlen(tmp_xsess) == 0) 104 die("ldm", "no Xsession");121 die("ldm", "no Xsession"); 105 122 } 106 123 } … … 116 133 * Then run xsession script 117 134 */ 118 void __attribute__ ((visibility("default"))) set_session_env(gchar *xsession, gchar *session) { 119 if (g_strcmp0(session,"default") != 0 || getenv("LDM_SESSION") == NULL) { 120 log_entry("ldm",7,"Export LDM_SELECTED_SESSION to environment: \"%s\"", session); 135 void __attribute__ ((visibility("default"))) set_session_env(gchar * 136 xsession, 137 gchar * 138 session) 139 { 140 if (g_strcmp0(session, "default") != 0 141 || getenv("LDM_SESSION") == NULL) { 142 log_entry("ldm", 7, 143 "Export LDM_SELECTED_SESSION to environment: \"%s\"", 144 session); 121 145 setenv("LDM_SELECTED_SESSION", session, 1); 122 } 123 else { 124 log_entry("ldm",7,"Using existing LDM_SESSION from environment: \"%s\"", getenv("LDM_SESSION")); 146 } else { 147 log_entry("ldm", 7, 148 "Using existing LDM_SESSION from environment: \"%s\"", 149 getenv("LDM_SESSION")); 125 150 } 126 151 … … 135 160 * Check for LTSP-Cluster. If true, contact loadbalancer for an IP 136 161 */ 137 void __attribute__ ((visibility("default"))) get_ltsp_cfg(gchar **server) { 162 void __attribute__ ((visibility("default"))) get_ltsp_cfg(gchar ** server) 163 { 138 164 /* Check for LTSP-Cluster, if true, contact the loadbalancer for an IP */ 139 165 if (access(LTSP_CLUSTER_CONFILE, F_OK) == 0) { … … 141 167 fp = popen("getltscfg-cluster -l ldm", "r"); 142 168 if (fp != NULL) { 143 log_entry("ltsp-cluster",6,"IP before load-balancing: %s", *server); 169 log_entry("ltsp-cluster", 6, "IP before load-balancing: %s", 170 *server); 144 171 if (fgets(*server, PATH_MAX, fp) == NULL) 145 log_entry("ltsp-cluster",4,"failed to get an IP from the load-balancer"); 172 log_entry("ltsp-cluster", 4, 173 "failed to get an IP from the load-balancer"); 146 174 147 log_entry("ltsp-cluster",6,"IP after loadbalancing: %s", *server); 175 log_entry("ltsp-cluster", 6, "IP after loadbalancing: %s", 176 *server); 148 177 } 149 178 if (pclose(fp) == -1) 150 log_entry("ltsp-cluster", 3,"load-balancing failed");179 log_entry("ltsp-cluster", 3, "load-balancing failed"); 151 180 } 152 181 } -
ldm/trunk/fuentes/src/plugins/rdesktop/rdesktop.c
r516 r855 23 23 RdpInfo *rdpinfo; 24 24 25 void __attribute__((constructor)) initialize() { 26 descriptor = (LdmBackend*) malloc(sizeof(LdmBackend)); 25 void __attribute__ ((constructor)) initialize() 26 { 27 descriptor = (LdmBackend *) malloc(sizeof(LdmBackend)); 27 28 bzero(descriptor, sizeof(LdmBackend)); 28 29 … … 40 41 * Callback function for initialization 41 42 */ 42 void init_rdesktop() { 43 rdpinfo = (RdpInfo*) malloc(sizeof(RdpInfo)); 43 void 44 init_rdesktop() 45 { 46 rdpinfo = (RdpInfo *) malloc(sizeof(RdpInfo)); 44 47 bzero(rdpinfo, sizeof(RdpInfo)); 45 48 … … 53 56 * Callback function for starting rdesktop session 54 57 */ 55 void start_rdesktop() { 58 void 59 start_rdesktop() 60 { 56 61 gboolean error = FALSE; 57 62 58 63 /* Variable validation */ 59 if (!rdpinfo->username) {60 log_entry("rdesktop", 3,"no username");64 if (!rdpinfo->username) { 65 log_entry("rdesktop", 3, "no username"); 61 66 error = TRUE; 62 67 } 63 68 64 if (!rdpinfo->password) {65 log_entry("rdesktop", 3,"no password");69 if (!rdpinfo->password) { 70 log_entry("rdesktop", 3, "no password"); 66 71 error = TRUE; 67 72 } 68 73 69 if (!rdpinfo->server) {70 log_entry("rdesktop", 3,"no server");74 if (!rdpinfo->server) { 75 log_entry("rdesktop", 3, "no server"); 71 76 error = TRUE; 72 77 } 73 78 74 if (!rdpinfo->domain) {75 log_entry("rdesktop", 3,"no domain");79 if (!rdpinfo->domain) { 80 log_entry("rdesktop", 3, "no domain"); 76 81 error = TRUE; 77 82 } 78 83 79 if (error) {80 die("rdesktop", "missing mandatory information");84 if (error) { 85 die("rdesktop", "missing mandatory information"); 81 86 } 82 87 … … 84 89 close_greeter(); 85 90 86 log_entry("rdesktop",6,"starting rdesktop session to '%s' as '%s'", rdpinfo->server, rdpinfo->username); 91 log_entry("rdesktop", 6, "starting rdesktop session to '%s' as '%s'", 92 rdpinfo->server, rdpinfo->username); 87 93 rdesktop_session(); 88 log_entry("rdesktop", 6,"closing rdesktop session");94 log_entry("rdesktop", 6, "closing rdesktop session"); 89 95 } 90 96 … … 92 98 * _get_domain 93 99 */ 94 void _get_domain() { 100 void 101 _get_domain() 102 { 95 103 gchar *cmd = "value domain\n"; 96 104 … … 102 110 * Callback function for authentication 103 111 */ 104 void auth_rdesktop() { 112 void 113 auth_rdesktop() 114 { 105 115 gchar *cmd; 106 116 107 117 /* Separator for domains : '|' */ 108 118 gchar *domains = getenv("RDP_DOMAIN"); 109 cmd = g_strconcat("pref choice;domain;Domain;Select Domai_n ...;session;", domains, "\n", NULL); 119 cmd = 120 g_strconcat 121 ("pref choice;domain;Domain;Select Domai_n ...;session;", domains, 122 "\n", NULL); 110 123 if (domains) { 111 if (ask_greeter(cmd))124 if (ask_greeter(cmd)) 112 125 die("rdesktop", "%s from greeter failed", cmd); 113 126 } else { 114 log_entry("rdesktop",7,"RDP_DOMAIN isn't defined, rdesktop will connect on default domain"); 127 log_entry("rdesktop", 7, 128 "RDP_DOMAIN isn't defined, rdesktop will connect on default domain"); 115 129 } 116 130 … … 122 136 123 137 /* Get hostname */ 124 if (!rdpinfo->server)138 if (!rdpinfo->server) 125 139 get_host(&(rdpinfo->server)); 126 140 … … 138 152 * Callback function for closing the plugins 139 153 */ 140 void close_rdesktop() { 141 log_entry("rdesktop",7,"closing rdesktop session"); 154 void 155 close_rdesktop() 156 { 157 log_entry("rdesktop", 7, "closing rdesktop session"); 142 158 free(rdpinfo); 143 159 } … … 147 163 * Start a rdesktop session to server 148 164 */ 149 void rdesktop_session() { 165 void 166 rdesktop_session() 167 { 150 168 gchar *cmd; 151 169 152 170 cmd = g_strjoin(" ", "rdesktop", "-f", 153 "-u", rdpinfo->username,154 "-p", rdpinfo->password, NULL);171 "-u", rdpinfo->username, 172 "-p", rdpinfo->password, NULL); 155 173 156 174 /* Only append the domain if it's set */ 157 if (g_strcmp0(rdpinfo->domain,"None") != 0) { 158 cmd = g_strjoin(" ", cmd, 159 "-d", rdpinfo->domain, NULL); 175 if (g_strcmp0(rdpinfo->domain, "None") != 0) { 176 cmd = g_strjoin(" ", cmd, "-d", rdpinfo->domain, NULL); 160 177 } 161 178 -
ldm/trunk/fuentes/src/plugins/ssh/Makefile.am
r516 r855 4 4 libssh_la_CFLAGS = $(GLIB_CFLAGS) $(GOBJECT_CFLAGS) 5 5 6 libssh_la_LDFLAGS = $(GLIB_LIBS) $(GOBJECT_LIBS)6 libssh_la_LDFLAGS = -lcrypt $(GLIB_LIBS) $(GOBJECT_LIBS) 7 7 libssh_la_SOURCES = ssh.c -
ldm/trunk/fuentes/src/plugins/ssh/ssh.c
r516 r855 17 17 #include <sys/stat.h> 18 18 #include <utmp.h> 19 #include <crypt.h> 19 20 #include <errno.h> 20 21 … … 34 35 SSHInfo *sshinfo; 35 36 36 void __attribute__((constructor)) initialize() { 37 descriptor = (LdmBackend*) malloc(sizeof(LdmBackend)); 37 void __attribute__ ((constructor)) initialize() 38 { 39 descriptor = (LdmBackend *) malloc(sizeof(LdmBackend)); 38 40 bzero(descriptor, sizeof(LdmBackend)); 39 41 … … 52 54 * Callback function for initialization 53 55 */ 54 void init_ssh() { 55 sshinfo = (SSHInfo*) malloc(sizeof(SSHInfo)); 56 void 57 init_ssh() 58 { 59 sshinfo = (SSHInfo *) malloc(sizeof(SSHInfo)); 56 60 bzero(sshinfo, sizeof(SSHInfo)); 57 61 … … 65 69 * Start ssh session 66 70 */ 67 void start_ssh() { 71 void 72 start_ssh() 73 { 68 74 gboolean error = FALSE; 69 75 70 76 /* Variable validation */ 71 77 if (!(sshinfo->username)) { 72 log_entry("ssh", 3,"no username");78 log_entry("ssh", 3, "no username"); 73 79 error = TRUE; 74 80 } 75 81 76 82 if (!(sshinfo->password)) { 77 log_entry("ssh", 3,"no password");83 log_entry("ssh", 3, "no password"); 78 84 error = TRUE; 79 85 } 80 86 81 87 if (!(sshinfo->server)) { 82 log_entry("ssh", 3,"no server");88 log_entry("ssh", 3, "no server"); 83 89 error = TRUE; 84 90 } … … 88 94 89 95 if (error) { 90 die("ssh", "missing mandatory information");96 die("ssh", "missing mandatory information"); 91 97 } 92 98 … … 101 107 * control sockets. 102 108 */ 103 sshinfo->ctl_socket = g_strdup_printf("/var/run/ldm_socket_%d_%s", ldm.pid, sshinfo->server); 109 sshinfo->ctl_socket = 110 g_strdup_printf("/var/run/ldm_socket_%d_%s", ldm.pid, 111 sshinfo->server); 104 112 105 113 /* Setting ENV variables for plugin */ … … 107 115 108 116 /* Execute any rc files */ 109 log_entry("ssh", 6,"calling rc.d pressh scripts");117 log_entry("ssh", 6, "calling rc.d pressh scripts"); 110 118 rc_files("pressh"); 111 119 112 120 ssh_session(); 113 log_entry("ssh",6,"established ssh session on '%s' as '%s'",sshinfo->server,sshinfo->username); 121 log_entry("ssh", 6, "established ssh session on '%s' as '%s'", 122 sshinfo->server, sshinfo->username); 114 123 115 124 /* Greeter not needed anymore */ 116 125 close_greeter(); 117 126 118 log_entry("ssh",6,"calling rc.d start scripts"); 119 rc_files("start"); /* Execute any rc files */ 120 121 log_entry("ssh",6,"starting X session"); 127 log_entry("ssh", 6, "calling rc.d start scripts"); 128 rc_files("start"); /* Execute any rc files */ 129 130 /* ssh_hashpass - Defaults to opt-in (Must set LDM_PASSWORD_HASH to true) */ 131 if (ldm_getenv_bool_default("LDM_PASSWORD_HASH", FALSE)) 132 { 133 ssh_hashpass(); 134 } 135 else 136 { 137 log_entry("hashpass", 6, "LDM_PASSWORD_HASH set to FALSE or unset, skipping hash function"); 138 } 139 log_entry("hashpass", 6, "Freeing password as promised."); 140 g_free(sshinfo->password); 141 sshinfo->password = NULL; 142 143 log_entry("ssh", 6, "starting X session"); 122 144 set_session_env(sshinfo->xsession, sshinfo->session); 123 145 } … … 127 149 * Callback function for setting guest login 128 150 */ 129 void get_guest() { 130 log_entry("ssh",6,"setting guest login"); 151 void 152 get_guest() 153 { 154 log_entry("ssh", 6, "setting guest login"); 131 155 132 156 /* Get credentials */ … … 180 204 if (sshinfo->server) { 181 205 i = 0; 182 while (1) {183 if (hosts_char[i] == NULL) {206 while (1) { 207 if (hosts_char[i] == NULL) { 184 208 break; 185 209 } 186 if (!g_strcmp0(hosts_char[i], sshinfo->server)) {210 if (!g_strcmp0(hosts_char[i], sshinfo->server)) { 187 211 good = TRUE; 188 212 break; … … 205 229 * Set environment variables used by LDM and Greeter 206 230 */ 207 void _set_env() { 231 void 232 _set_env() 233 { 208 234 setenv("LDM_SERVER", sshinfo->server, 1); 209 235 setenv("LDM_USERNAME", sshinfo->username, 1); … … 215 241 * Callback function for authentication 216 242 */ 217 void get_auth() { 243 void 244 get_auth() 245 { 218 246 /* Get UserID */ 219 247 get_userid(&(sshinfo->username)); … … 236 264 * Callback function for closing the plugins 237 265 */ 238 void close_ssh() { 239 log_entry("ssh",7,"closing ssh session"); 266 void 267 close_ssh() 268 { 269 log_entry("ssh", 7, "closing ssh session"); 240 270 ssh_endsession(); 241 271 … … 249 279 } 250 280 251 int expect(int fd, char *p, int seconds, ...) { 281 int 282 expect(int fd, char *p, int seconds, ...) 283 { 252 284 fd_set set; 253 285 struct timeval timeout; … … 282 314 * Main loop. 283 315 */ 284 285 316 log_entry("ssh",7,"expect: entering main loop"); 286 287 while(1) { 317 while (1) { 318 // timeout.tv_sec = (long) 1; /* one second timeout */ 319 // timeout.tv_usec = 0; 288 320 timeout.tv_sec = 0; 289 321 timeout.tv_usec = 200000; /* 200ms timeout */ … … 293 325 st = select(FD_SETSIZE, &set, NULL, NULL, &timeout); 294 326 295 log_entry("ssh", 7, "expect: select returned %d", st); 327 log_entry("ssh", 7, "expect: select returned %d", st); 328 329 // if (st == -1 && errno == EINTR) 330 // { 331 // continue; /* interrupted by signal -> retry */ 332 // } 333 334 // if (st < 0) { /* bad thing */ 335 // break; 336 // } 337 338 // if (loopcount == 0) { 339 // break; 340 // } 341 342 // if (!st) { /* timeout */ 343 // loopcount--; /* We've not seen the data we want */ 344 // continue; 345 // } 296 346 297 347 /* There is data available - we want to read it in even if … … 299 349 * message 300 350 */ 301 if (st > 0) 302 { 303 size = read(fd, buffer, sizeof buffer); 304 if (size == -1) { 305 log_entry("ssh", 3, "expect: read returned error %d (%s)", errno, strerror(errno)); 306 break; 307 } 308 if (size == 0) { 309 log_entry("ssh", 3, "expect: read returned 0 (EOF))"); 310 break; 311 } 312 313 if ((total + size) < MAXEXP) { 314 strncpy(p + total, buffer, size); 315 total += size; 316 log_entry("ssh", 7, "expect: got %d bytes so far", total); 317 } 318 else 319 { 320 log_entry("ssh", 3, "expect: buffer full"); 321 return ERROR; 322 } 323 } 324 else /* No data available */ 351 if (st > 0) 352 { 353 size = read(fd, buffer, sizeof buffer); 354 355 if (size < 0) { 356 log_entry("ssh", 3, "expect: read returned error %d (%s)", errno, strerror(errno)); 357 break; 358 } 359 if (size == 0) { 360 log_entry("ssh", 3, "expect: read returned 0 (EOF))"); 361 break; 362 } 363 364 if ((total + size) < MAXEXP) { 365 strncpy(p + total, buffer, size); 366 total += size; 367 log_entry("ssh", 7, "expect: got %d bytes so far", total); 368 } 369 else 370 { 371 log_entry("ssh", 3, "expect: buffer full"); 372 return ERROR; 373 } 374 } 375 else /* No data available */ 325 376 { 326 377 /* select() was interrupted by a signal, … … 346 397 break; 347 398 } 399 348 400 349 401 for (i = 0; i < expects->len; i++) { 350 if (strstr(p, g_ptr_array_index(expects, i))) { 351 log_entry("ssh", 7, "expect: found string %d \"%s\"", i, g_ptr_array_index(expects, i)); 352 loopend = TRUE; 353 break; 354 } 355 } 356 357 loopcount--; /* We've not seen the data we want */ 358 } 402 if (strstr(p, g_ptr_array_index(expects, i))) { 403 log_entry("ssh", 7, "expect: found string %d \"%s\"", i, g_ptr_array_index(expects, i)); 404 loopend = TRUE; 405 break; 406 } 407 } 408 loopcount--; /* We've not seen the data we want */ 409 } 359 410 360 411 if (loopend) { … … 365 416 log_entry("ssh",7,"expect: saw: %s", p); 366 417 367 if (size < 0 || st < 0 || child_exited) {368 return ERROR; /* error occured */418 if (size < 0 || st < 0) { 419 return ERROR; /* error occured */ 369 420 } 370 421 if (loopcount == 0) { 371 return TIMED_OUT; /* timed out */ 372 } else { 373 return i; /* which expect did we see? */ 374 } 375 } 376 377 void ssh_chat(gint fd) { 422 return TIMED_OUT; /* timed out */ 423 } 424 /* Sleep a bit to make sure we notice if ssh died in the meantime */ 425 usleep(100000); 426 if (child_exited) 427 { 428 return ERROR; 429 } 430 431 return i; /* which expect did we see? */ 432 } 433 434 void 435 ssh_chat(gint fd) 436 { 378 437 int seen; 379 438 size_t len; … … 396 455 end of the line */ 397 456 if (seen == 0) { 398 g_free(sshinfo->password);399 sshinfo->password = NULL;400 457 return; 401 } else if (seen == 1) { 402 int i; 403 g_strdelimit(lastseen, "\r\n\t", ' '); 404 g_strchomp(lastseen); 405 i = strlen(lastseen); 458 } 459 460 int i; 461 g_strdelimit(lastseen, "\r\n\t", ' '); 462 g_strchomp(lastseen); 463 i = strlen(lastseen); 464 465 if (seen == 1) { 406 466 /* If it's not the first time through, or the :'s not at the 407 467 * end of a line (password expiry or error), set the message */ … … 439 499 } 440 500 441 void ssh_tty_init(void) { 501 void 502 ssh_tty_init(void) 503 { 442 504 (void) setsid(); 443 if (login_tty(sshinfo->sshslavefd) < 0 444 die("ssh", "login_tty failed");505 if (login_tty(sshinfo->sshslavefd) < 0) { 506 die("ssh", "login_tty failed"); 445 507 } 446 508 } … … 450 512 * Start an ssh login to the server. 451 513 */ 452 void ssh_session(void) { 514 void 515 ssh_session(void) 516 { 453 517 gchar *command; 454 518 gchar *port = NULL; … … 456 520 457 521 /* Check for port Override */ 458 if (sshinfo->override_port)459 port = g_strconcat(" -p ", sshinfo->override_port, " ", 522 if (sshinfo->override_port) 523 port = g_strconcat(" -p ", sshinfo->override_port, " ", NULL); 460 524 461 525 openpty(&(sshinfo->sshfd), &(sshinfo->sshslavefd), NULL, NULL, NULL); 462 526 463 527 command = g_strjoin(" ", "ssh", "-Y", "-t", "-M", 464 "-S", sshinfo->ctl_socket, 465 "-o", "NumberOfPasswordPrompts=1", 466 /* ConnectTimeout should be less than the timeout ssh_chat 467 * passes to expect, so we get the error message from ssh 468 * before expect gives up 469 */ 470 "-o", "ConnectTimeout=10", 471 "-l", sshinfo->username, 472 port ? port : "", 473 sshinfo->sshoptions ? sshinfo->sshoptions : "", 474 sshinfo->server, "echo " SENTINEL "; exec /bin/sh -", NULL); 528 "-S", sshinfo->ctl_socket, 529 "-o", "NumberOfPasswordPrompts=1", 530 /* ConnectTimeout should be less than the timeout ssh_chat 531 * passes to expect, so we get the error message from ssh 532 * before expect gives up 533 */ 534 "-o", "ConnectTimeout=10", 535 "-l", sshinfo->username, 536 port ? port : "", 537 sshinfo->sshoptions ? sshinfo->sshoptions : "", 538 sshinfo->server, 539 "echo " SENTINEL "; exec /bin/sh -", NULL); 475 540 log_entry("ssh", 6, "ssh_session: %s", command); 476 541 … … 488 553 } 489 554 490 void ssh_endsession(void) { 555 void 556 ssh_endsession(void) 557 { 491 558 GPid pid; 492 559 gchar *command; … … 496 563 /* socket still exists, so we need to shut down the ssh link */ 497 564 498 command = g_strjoin(" ", "ssh", "-S", sshinfo->ctl_socket, "-O", "exit", sshinfo->server, NULL); 499 log_entry("ssh", 6, "closing ssh session: %s", command); 565 command = 566 g_strjoin(" ", "ssh", "-S", sshinfo->ctl_socket, "-O", "exit", 567 sshinfo->server, NULL); 568 log_entry("ssh", 6, "closing ssh session: %s"), command; 500 569 pid = ldm_spawn(command, NULL, NULL, NULL); 501 570 ldm_wait(pid); … … 507 576 } 508 577 509 void *eater() { 578 /* 579 * ssh_hashpass() 580 * Set up password hash for client /etc/shadow using /dev/urandom 581 * rather than g_rand() due to developer recommendations at: 582 * https://developer.gnome.org/glib/stable/glib-Random-Numbers.html 583 */ 584 void 585 ssh_hashpass(void) 586 { 587 FILE *rand_fp; 588 FILE *shad_fp; 589 gchar salt[] = "$6$...............$"; 590 gchar buf[16]; 591 const gchar seedchars[] = 592 "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; 593 gchar *shadowentry; 594 const gchar hashloc[] = "/var/cache/ltsp/shadow.sed"; 595 size_t i = 0; 596 log_entry("hashpass", 6, "LDM_PASSWORD_HASH set to true, setting hash"); 597 rand_fp = fopen("/dev/urandom", "r"); 598 if (rand_fp == NULL) 599 { 600 log_entry("hashpass", 7, "Unable to read from /dev/urandom - Skipping HASH function"); 601 } 602 else 603 { 604 fread(buf, sizeof buf, 1, rand_fp); 605 fclose(rand_fp); 606 for (; i < sizeof buf; i++) 607 { 608 salt[3 + i] = seedchars[buf[i] % (sizeof seedchars - 1)]; 609 } 610 shadowentry = crypt(sshinfo->password, salt); 611 log_entry("hashpass", 6, "hash created"); 612 /* generate dynamic file for writing hash to. 613 * Will remove anything in its way. 614 * This will be removed during rc.d script run. 615 */ 616 shad_fp = fopen(hashloc, "w"); 617 if (shad_fp == NULL) 618 { 619 log_entry("hashpass", 7, "Unable to open %s for hash entry.", 620 hashloc); 621 } 622 else 623 { 624 fprintf(shad_fp, 625 "# Generated by LTSP, for LDM rc.d script manipulation\n$s:!:%s:", 626 shadowentry); 627 fclose(shad_fp); 628 } 629 } 630 } 631 632 void * 633 eater() 634 { 510 635 fd_set set; 511 636 struct timeval timeout; … … 519 644 } 520 645 521 timeout.tv_sec = (long) 1;/* one second timeout */646 timeout.tv_sec = (long) 1; /* one second timeout */ 522 647 timeout.tv_usec = 0; 523 648 FD_ZERO(&set); -
ldm/trunk/fuentes/src/plugins/ssh/ssh.h
r516 r855 30 30 void ssh_session(void); 31 31 void ssh_tty_init(); 32 void ssh_hashpass(void); 32 33 33 34 int expect(int, char*,int,...); -
ldm/trunk/fuentes/wwm/client.c
r516 r855 21 21 for (c = head_client; c; c = c->next) 22 22 if (w == c->parent || w == c->window) 23 return (c);24 return (NULL);23 return (c); 24 return (NULL); 25 25 } 26 26 27 27 Client * 28 next_client_on_vdesk(Client * c)28 next_client_on_vdesk(Client * c) 29 29 { 30 30 Client *newc = c, *marker = c; … … 38 38 while (newc != marker && newc->vdesk != v); 39 39 40 return ((newc == marker) ? NULL : newc);41 } 42 43 void 44 set_wm_state(Client * c, int state)40 return ((newc == marker) ? NULL : newc); 41 } 42 43 void 44 set_wm_state(Client * c, int state) 45 45 { 46 46 long data[2]; 47 47 48 48 data[0] = (long) state; 49 data[1] = None; /* icon window */49 data[1] = None; /* icon window */ 50 50 51 51 XChangeProperty(display, c->window, xa_wm_state, xa_wm_state, … … 55 55 56 56 void 57 send_config(Client * c)57 send_config(Client * c) 58 58 { 59 59 XConfigureEvent ce; 60 60 61 ce.type 62 ce.event 63 ce.window 64 ce.x 65 ce.y 66 ce.width 67 ce.height 68 ce.border_width 69 ce.above 61 ce.type = ConfigureNotify; 62 ce.event = c->window; 63 ce.window = c->window; 64 ce.x = c->x; 65 ce.y = c->y; 66 ce.width = c->width; 67 ce.height = c->height; 68 ce.border_width = c->border; 69 ce.above = None; 70 70 ce.override_redirect = False; 71 71 72 XSendEvent(display, c->window, False, StructureNotifyMask, (XEvent *) &ce); 72 XSendEvent(display, c->window, False, StructureNotifyMask, 73 (XEvent *) & ce); 73 74 XSync(display, False); 74 75 } 75 76 76 77 void 77 remove_client(Client * c, int from_cleanup)78 remove_client(Client * c, int from_cleanup) 78 79 { 79 80 Window root = ROOTWINDOW; … … 105 106 XFree(c->size); 106 107 if (current == c) 107 current = NULL; /* an enter event should set this up again */108 current = NULL; /* an enter event should set this up again */ 108 109 free(c); 109 110 … … 114 115 115 116 void 116 change_gravity(Client * c, int invert)117 change_gravity(Client * c, int invert) 117 118 { 118 119 int dx = 0, dy = 0; 119 120 int gravity = (c->size->flags & PWinGravity) ? 120 121 c->size->win_gravity : NorthWestGravity; 121 122 122 123 switch (gravity) { 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 124 case CenterGravity: 125 case StaticGravity: 126 case NorthWestGravity: 127 case NorthGravity: 128 case WestGravity: 129 dx = c->border; 130 dy = c->border; 131 break; 132 case NorthEastGravity: 133 case EastGravity: 134 dx = -(c->border); 135 dy = c->border; 136 break; 137 case SouthEastGravity: 138 dx = -(c->border); 139 dy = -(c->border); 140 break; 141 case SouthGravity: 142 case SouthWestGravity: 143 dx = c->border; 144 dy = -(c->border); 145 break; 145 146 } 146 147 … … 155 156 156 157 void 157 send_wm_delete(Client * c)158 send_wm_delete(Client * c) 158 159 { 159 160 int i, n, found = 0; … … 181 182 XEvent ev; 182 183 183 ev.type 184 ev.xclient.window 184 ev.type = ClientMessage; 185 ev.xclient.window = w; 185 186 ev.xclient.message_type = a; 186 ev.xclient.format = 32; 187 ev.xclient.data.l[0] = x; 188 ev.xclient.data.l[1] = CurrentTime; 189 190 return(XSendEvent(display, w, False, NoEventMask, &ev)); 191 } 192 193 void 194 set_shape(Client *c) { 195 int i, b; unsigned int u; /* dummies */ 187 ev.xclient.format = 32; 188 ev.xclient.data.l[0] = x; 189 ev.xclient.data.l[1] = CurrentTime; 190 191 return (XSendEvent(display, w, False, NoEventMask, &ev)); 192 } 193 194 void 195 set_shape(Client * c) 196 { 197 int i, b; 198 unsigned int u; /* dummies */ 196 199 int bounding_shaped; 197 200 Status retval; … … 209 212 */ 210 213 211 retval = XShapeQueryExtents(display, c->window, &bounding_shaped, &i, &i, 212 &u, &u, &b, &i, &i, &u, &u); 214 retval = 215 XShapeQueryExtents(display, c->window, &bounding_shaped, &i, &i, 216 &u, &u, &b, &i, &i, &u, &u); 213 217 if (retval && bounding_shaped) 214 218 XShapeCombineShape(display, c->parent, ShapeBounding, 215 c->border, c->border, c->window, ShapeBounding, ShapeSet); 216 } 219 c->border, c->border, c->window, ShapeBounding, 220 ShapeSet); 221 } -
ldm/trunk/fuentes/wwm/events.c
r516 r855 10 10 11 11 void 12 handle_key_event(XKeyEvent * e)12 handle_key_event(XKeyEvent * e) 13 13 { 14 14 int i; … … 35 35 for (i = 0; keytab[i].key != 0; i++) 36 36 if (keytab[i].key == key) { 37 keytab[i].f(c); /* dispatch the function */37 keytab[i].f(c); /* dispatch the function */ 38 38 break; 39 39 } … … 41 41 42 42 void 43 handle_button_event(XButtonEvent * e)43 handle_button_event(XButtonEvent * e) 44 44 { 45 45 // We want a minimal WM, so no mouse actions … … 52 52 return; 53 53 switch (e->button) { 54 case Button4:/* Scrolly wheel up in root */55 56 57 case Button5:/* Scrolly wheel down in root */58 59 54 case Button4: /* Scrolly wheel up in root */ 55 prev_vdesk((Client *) NULL); 56 return; 57 case Button5: /* Scrolly wheel down in root */ 58 next_vdesk((Client *) NULL); 59 return; 60 60 } 61 61 } else if (c) { 62 62 switch (e->button) { 63 case Button1:/* Left mouse = move */64 65 66 case Button3:/* Right mouse = resize */67 63 case Button1: /* Left mouse = move */ 64 move(c, 0); 65 return; 66 case Button3: /* Right mouse = resize */ 67 resize(c, 0); 68 68 return; 69 69 } … … 72 72 73 73 void 74 handle_shape_event(XShapeEvent *e) { 74 handle_shape_event(XShapeEvent * e) 75 { 75 76 Client *c = find_client(e->window); 76 77 … … 80 81 81 82 void 82 handle_configure_request(XConfigureRequestEvent * e)83 handle_configure_request(XConfigureRequestEvent * e) 83 84 { 84 85 Client *c = find_client(e->window); … … 122 123 123 124 void 124 handle_map_request(XMapRequestEvent * e)125 handle_map_request(XMapRequestEvent * e) 125 126 { 126 127 Client *c = find_client(e->window); … … 135 136 136 137 void 137 handle_unmap_event(XUnmapEvent * e)138 handle_unmap_event(XUnmapEvent * e) 138 139 { 139 140 Client *c = find_client(e->window); … … 157 158 158 159 void 159 handle_client_message(XClientMessageEvent * e)160 handle_client_message(XClientMessageEvent * e) 160 161 { 161 162 Client *c = find_client(e->window); 162 163 163 if (c && 164 e->message_type == xa_wm_change_state && 165 e->format == sz_xInternAtomReply && 166 e->data.l[0] == IconicState) 164 if (c && /* Client exists */ 165 e->message_type == xa_wm_change_state && /* Changing state */ 166 e->format == sz_xInternAtomReply && /* Data is long */ 167 e->data.l[0] == IconicState) /* We're now iconic */ 167 168 hide(c); 168 169 } 169 170 170 171 void 171 handle_property_change(XPropertyEvent * e)172 handle_property_change(XPropertyEvent * e) 172 173 { 173 174 Client *c = find_client(e->window); … … 180 181 181 182 void 182 handle_enter_event(XCrossingEvent * e)183 handle_enter_event(XCrossingEvent * e) 183 184 { 184 185 Client *c = find_client(e->window); 185 186 186 if (nomousefocus || !c) /* Ignore focus follows mouse */187 if (nomousefocus || !c) /* Ignore focus follows mouse */ 187 188 return; 188 189 -
ldm/trunk/fuentes/wwm/main.c
r516 r855 14 14 #include "wwm.h" 15 15 16 void handle_shape_event(XShapeEvent * e);16 void handle_shape_event(XShapeEvent * e); 17 17 18 18 /* … … 20 20 */ 21 21 22 Client *head_client = NULL; /* First client */23 Client *current = NULL; /* "current" client */24 Display *display; /* Our display */25 Atom xa_wm_state; /* atoms for window manager functions */22 Client *head_client = NULL; /* First client */ 23 Client *current = NULL; /* "current" client */ 24 Display *display; /* Our display */ 25 Atom xa_wm_state; /* atoms for window manager functions */ 26 26 Atom xa_wm_change_state; 27 27 Atom xa_wm_protos; 28 28 Atom xa_wm_delete; 29 XColor fg, bg, fc; /* Forground, Background, and locked colours */30 int nomousefocus = 0; /* focus follows mouse status */31 int passthrough = 0; /* current passthrough state */32 char *term = NULL; /* terminal to launch */33 int have_shape = 0; /* Do we support shaped windows? */34 int ignore_xerror = 0; /* Ignore X errors */29 XColor fg, bg, fc; /* Forground, Background, and locked colours */ 30 int nomousefocus = 0; /* focus follows mouse status */ 31 int passthrough = 0; /* current passthrough state */ 32 char *term = NULL; /* terminal to launch */ 33 int have_shape = 0; /* Do we support shaped windows? */ 34 int ignore_xerror = 0; /* Ignore X errors */ 35 35 36 36 struct wmkeys keytab[] = { … … 46 46 int shape_event; 47 47 48 dpy = getenv("DISPLAY"); /* manage the display in $DISPLAY */48 dpy = getenv("DISPLAY"); /* manage the display in $DISPLAY */ 49 49 50 50 if (!dpy) … … 54 54 sigemptyset(&act.sa_mask); 55 55 #ifdef SA_NOCLDSTOP 56 act.sa_flags = SA_NOCLDSTOP; /* don't care about STOP, CONT */56 act.sa_flags = SA_NOCLDSTOP; /* don't care about STOP, CONT */ 57 57 #else 58 58 act.sa_flags = 0; 59 59 #endif 60 60 sigaction(SIGTERM, &act, NULL); 61 sigaction(SIGINT, 62 sigaction(SIGHUP, 61 sigaction(SIGINT, &act, NULL); 62 sigaction(SIGHUP, &act, NULL); 63 63 sigaction(SIGCHLD, &act, NULL); 64 64 … … 90 90 XNextEvent(display, &ev); 91 91 switch (ev.type) { 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 handle_shape_event((XShapeEvent *)&ev);119 92 case KeyPress: 93 handle_key_event(&ev.xkey); 94 break; 95 case ButtonPress: 96 handle_button_event(&ev.xbutton); 97 break; 98 case ConfigureRequest: 99 handle_configure_request(&ev.xconfigurerequest); 100 break; 101 case MapRequest: 102 handle_map_request(&ev.xmaprequest); 103 break; 104 case ClientMessage: 105 handle_client_message(&ev.xclient); 106 break; 107 case EnterNotify: 108 handle_enter_event(&ev.xcrossing); 109 break; 110 case PropertyNotify: 111 handle_property_change(&ev.xproperty); 112 break; 113 case UnmapNotify: 114 handle_unmap_event(&ev.xunmap); 115 break; 116 default: 117 if (have_shape && ev.type == shape_event) { 118 handle_shape_event((XShapeEvent *) & ev); 119 } 120 120 } 121 121 } 122 122 123 return (1);/* ?!? shouldn't get here */123 return (1); /* ?!? shouldn't get here */ 124 124 } 125 125 … … 145 145 146 146 display = XOpenDisplay(dpy); 147 if (!display) /* couldn't open display */147 if (!display) /* couldn't open display */ 148 148 exit(1); 149 149 … … 159 159 */ 160 160 161 xa_wm_state = XInternAtom(display, "WM_STATE",False);162 xa_wm_change_state = XInternAtom(display, "WM_CHANGE_STATE", 163 xa_wm_protos = XInternAtom(display, "WM_PROTOCOLS",False);164 xa_wm_delete 161 xa_wm_state = XInternAtom(display, "WM_STATE", False); 162 xa_wm_change_state = XInternAtom(display, "WM_CHANGE_STATE", False); 163 xa_wm_protos = XInternAtom(display, "WM_PROTOCOLS", False); 164 xa_wm_delete = XInternAtom(display, "WM_DELETE_WINDOW", False); 165 165 166 166 XAllocNamedColor(display, colormap, DEF_FG, &fg, &dummy); … … 184 184 185 185 attr.event_mask = KeyPressMask | ChildMask | PropertyChangeMask | 186 186 EnterWindowMask | ButtonMask; 187 187 XChangeWindowAttributes(display, root, CWEventMask, &attr); 188 188 … … 202 202 Window root = RootWindow(display, DefaultScreen(display)); 203 203 XGrabKey(display, XKeysymToKeycode(display, keycode), 204 modifiers, root, True, GrabModeAsync, GrabModeAsync);204 modifiers, root, True, GrabModeAsync, GrabModeAsync); 205 205 } 206 206 -
ldm/trunk/fuentes/wwm/mapfunctions.c
r516 r855 15 15 16 16 void 17 move_win_up(Client * c)17 move_win_up(Client * c) 18 18 { 19 19 if (!c) … … 28 28 29 29 void 30 move_win_down(Client * c)30 move_win_down(Client * c) 31 31 { 32 32 if (!c) … … 41 41 42 42 void 43 move_win_left(Client * c)43 move_win_left(Client * c) 44 44 { 45 45 if (!c) … … 54 54 55 55 void 56 move_win_right(Client * c)56 move_win_right(Client * c) 57 57 { 58 58 if (!c) … … 67 67 68 68 void 69 expand_win_y(Client * c)69 expand_win_y(Client * c) 70 70 { 71 71 if (!c) … … 80 80 81 81 void 82 contract_win_y(Client * c)82 contract_win_y(Client * c) 83 83 { 84 84 if (!c || c->height <= WMDELTA) … … 89 89 90 90 void 91 expand_win_x(Client * c)91 expand_win_x(Client * c) 92 92 { 93 93 if (!c) … … 98 98 99 99 void 100 contract_win_x(Client * c)100 contract_win_x(Client * c) 101 101 { 102 102 if (!c || c->width <= WMDELTA) … … 107 107 108 108 void 109 kill_client(Client * c)109 kill_client(Client * c) 110 110 { 111 111 if (!c) … … 115 115 116 116 void 117 raise_client(Client * c)117 raise_client(Client * c) 118 118 { 119 119 if (!c) … … 123 123 124 124 void 125 lower_client(Client * c)125 lower_client(Client * c) 126 126 { 127 127 if (!c) … … 131 131 132 132 void 133 horizontal_toggle(Client * c)133 horizontal_toggle(Client * c) 134 134 { 135 135 if (!c) … … 140 140 141 141 void 142 vertical_toggle(Client * c)142 vertical_toggle(Client * c) 143 143 { 144 144 if (!c) … … 149 149 150 150 void 151 maximize_toggle(Client * c)151 maximize_toggle(Client * c) 152 152 { 153 153 if (!c) … … 159 159 160 160 void 161 lock_window(Client * c)161 lock_window(Client * c) 162 162 { 163 163 if (!c) 164 164 return; 165 165 XSetWindowBackground(display, c->parent, 166 c->vdesk == LOCKED ? fg.pixel : fc.pixel);166 c->vdesk == LOCKED ? fg.pixel : fc.pixel); 167 167 XClearWindow(display, c->parent); 168 168 c->vdesk = c->vdesk == LOCKED ? vdesk_get() : LOCKED; … … 170 170 171 171 void 172 new_term(Client * c)172 new_term(Client * c) 173 173 { 174 174 spawn(term); … … 176 176 177 177 void 178 next_client(Client * c)178 next_client(Client * c) 179 179 { 180 180 next(current); … … 182 182 183 183 void 184 quit_wm(Client * c)184 quit_wm(Client * c) 185 185 { 186 186 handle_signal(SIGHUP); … … 188 188 189 189 void 190 start_passthrough(Client * c)190 start_passthrough(Client * c) 191 191 { 192 192 passthrough++; … … 194 194 195 195 void 196 goto_vdesk_0(Client * c)196 goto_vdesk_0(Client * c) 197 197 { 198 198 switch_vdesk(0); … … 200 200 201 201 void 202 goto_vdesk_1(Client * c)202 goto_vdesk_1(Client * c) 203 203 { 204 204 switch_vdesk(1); … … 206 206 207 207 void 208 goto_vdesk_2(Client * c)208 goto_vdesk_2(Client * c) 209 209 { 210 210 switch_vdesk(2); … … 212 212 213 213 void 214 goto_vdesk_3(Client * c)214 goto_vdesk_3(Client * c) 215 215 { 216 216 switch_vdesk(3); … … 218 218 219 219 void 220 goto_vdesk_4(Client * c)220 goto_vdesk_4(Client * c) 221 221 { 222 222 switch_vdesk(4); … … 224 224 225 225 void 226 goto_vdesk_5(Client * c)226 goto_vdesk_5(Client * c) 227 227 { 228 228 switch_vdesk(5); … … 230 230 231 231 void 232 goto_vdesk_6(Client * c)232 goto_vdesk_6(Client * c) 233 233 { 234 234 switch_vdesk(6); … … 236 236 237 237 void 238 goto_vdesk_7(Client * c)238 goto_vdesk_7(Client * c) 239 239 { 240 240 switch_vdesk(7); … … 242 242 243 243 void 244 prev_vdesk(Client * c)244 prev_vdesk(Client * c) 245 245 { 246 246 int v = vdesk(VDESK_PREV, VDESK_NULL); … … 250 250 251 251 void 252 next_vdesk(Client * c)252 next_vdesk(Client * c) 253 253 { 254 254 int v = vdesk(VDESK_NEXT, VDESK_NULL); … … 258 258 259 259 void 260 top_left(Client * c)260 top_left(Client * c) 261 261 { 262 262 if (!c) … … 269 269 270 270 void 271 top_right(Client * c)271 top_right(Client * c) 272 272 { 273 273 if (!c) … … 280 280 281 281 void 282 bottom_left(Client * c)282 bottom_left(Client * c) 283 283 { 284 284 if (!c) … … 291 291 292 292 void 293 bottom_right(Client * c)293 bottom_right(Client * c) 294 294 { 295 295 if (!c) … … 302 302 303 303 void 304 toggle_focus(Client * c)304 toggle_focus(Client * c) 305 305 { 306 306 nomousefocus = (nomousefocus + 1) % 2; … … 308 308 309 309 void 310 dummy_func(Client * c)310 dummy_func(Client * c) 311 311 { 312 312 return; -
ldm/trunk/fuentes/wwm/misc.c
r516 r855 53 53 54 54 int 55 handle_xerror(Display * dpy, XErrorEvent *e)55 handle_xerror(Display * dpy, XErrorEvent * e) 56 56 { 57 57 Client *c = find_client(e->resourceid); 58 58 59 59 if (ignore_xerror) 60 return (0);60 return (0); 61 61 62 62 if (e->error_code == BadAccess && … … 67 67 remove_client(c, NOT_QUITTING); 68 68 69 return (0);69 return (0); 70 70 } 71 71 72 72 int 73 handle_xexit(Display * dpy)73 handle_xexit(Display * dpy) 74 74 { 75 75 exit(0); … … 82 82 83 83 switch (vdesk_command) { 84 85 return(my_vdesk);86 87 88 return(my_vdesk);89 90 return((my_vdesk + 1) % VDESK_MAX);91 92 return((my_vdesk ? my_vdesk - 1 : (VDESK_MAX - 1)) % VDESK_MAX);93 94 return(my_vdesk);84 case VDESK_GET: 85 return (my_vdesk); 86 case VDESK_SET: 87 my_vdesk = vdesk_option; 88 return (my_vdesk); 89 case VDESK_NEXT: 90 return ((my_vdesk + 1) % VDESK_MAX); 91 case VDESK_PREV: 92 return ((my_vdesk ? my_vdesk - 1 : (VDESK_MAX - 1)) % VDESK_MAX); 93 default: 94 return (my_vdesk); 95 95 } 96 96 } -
ldm/trunk/fuentes/wwm/new.c
r516 r855 86 86 XGetWindowAttributes(display, c->window, &attr); 87 87 88 c->x 89 c->y 90 c->width 88 c->x = attr.x; 89 c->y = attr.y; 90 c->width = attr.width; 91 91 c->height = attr.height; 92 92 c->border = DEF_BW; 93 c->oldw 94 c->vdesk 93 c->oldw = c->oldh = 0; 94 c->vdesk = vdesk_get(); 95 95 96 96 /* … … 131 131 } 132 132 133 focus_client(c, RAISE); /* new windows get focus */133 focus_client(c, RAISE); /* new windows get focus */ 134 134 } 135 135 136 136 void 137 init_position(Client * c)137 init_position(Client * c) 138 138 { 139 139 int x, y; … … 171 171 172 172 void 173 reparent(Client * c)173 reparent(Client * c) 174 174 { 175 175 XSetWindowAttributes p_attr; … … 182 182 p_attr.background_pixel = bg.pixel; 183 183 p_attr.event_mask = 184 ChildMask | ButtonPressMask | ExposureMask | EnterWindowMask;184 ChildMask | ButtonPressMask | ExposureMask | EnterWindowMask; 185 185 c->parent = 186 186 XCreateWindow(display, root, c->x - c->border, 187 c->y - c->border, c->width + (2 * c->border),188 c->height + (2 * c->border), 0, DefaultDepth(display,189 screen),190 CopyFromParent, DefaultVisual(display, screen),191 CWOverrideRedirect | CWBackPixel | CWEventMask,192 &p_attr);187 c->y - c->border, c->width + (2 * c->border), 188 c->height + (2 * c->border), 0, DefaultDepth(display, 189 screen), 190 CopyFromParent, DefaultVisual(display, screen), 191 CWOverrideRedirect | CWBackPixel | CWEventMask, 192 &p_attr); 193 193 194 194 XAddToSaveSet(display, c->window); -
ldm/trunk/fuentes/wwm/screen.c
r516 r855 8 8 9 9 void 10 draw_outline(Client * c)10 draw_outline(Client * c) 11 11 { 12 12 Window root = ROOTWINDOW; … … 20 20 gv.function = GXinvert; 21 21 gv.subwindow_mode = IncludeInferiors; 22 gv.line_width = DEF_BW; /* opt_bw */22 gv.line_width = DEF_BW; /* opt_bw */ 23 23 24 24 invert_gc = XCreateGC(display, root, 25 GCFunction | GCSubwindowMode | GCLineWidth, &gv); 25 GCFunction | GCSubwindowMode | GCLineWidth, 26 &gv); 26 27 } 27 28 … … 43 44 44 45 void 45 recalculate_sweep(Client * c, int x1, int y1, int x2, int y2)46 recalculate_sweep(Client * c, int x1, int y1, int x2, int y2) 46 47 { 47 48 int basex, basey; … … 52 53 if (c->size->flags & PResizeInc) { 53 54 basex = (c->size->flags & PBaseSize) ? c->size->base_width : 54 55 (c->size->flags & PMinSize) ? c->size->min_width : 0; 55 56 basey = (c->size->flags & PBaseSize) ? c->size->base_height : 56 57 (c->size->flags & PMinSize) ? c->size->min_height : 0; 57 58 c->width -= (c->width - basex) % c->size->width_inc; 58 59 c->height -= (c->height - basey) % c->size->height_inc; … … 78 79 79 80 void 80 sweep(Client * c)81 sweep(Client * c) 81 82 { 82 83 Window root = ROOTWINDOW; … … 99 100 draw_outline(c); 100 101 101 XWarpPointer(display, None, c->window, 0, 0, 0, 0, c->width, c->height); 102 XWarpPointer(display, None, c->window, 0, 0, 0, 0, c->width, 103 c->height); 102 104 103 105 for (;;) { 104 106 XMaskEvent(display, MouseMask, &ev); 105 107 switch (ev.type) { 106 107 draw_outline(c);/* clear */108 109 110 111 112 113 114 115 116 draw_outline(c);/* clear */117 118 119 108 case MotionNotify: 109 draw_outline(c); /* clear */ 110 XUngrabServer(display); 111 recalculate_sweep(c, old_cx, old_cy, 112 ev.xmotion.x, ev.xmotion.y); 113 XSync(display, False); 114 XGrabServer(display); 115 draw_outline(c); 116 break; 117 case ButtonRelease: 118 draw_outline(c); /* clear */ 119 XUngrabServer(display); 120 XUngrabPointer(display, CurrentTime); 121 return; 120 122 } 121 123 } … … 123 125 124 126 void 125 drag(Client * c)127 drag(Client * c) 126 128 { 127 129 Window root = ROOTWINDOW; … … 146 148 XMaskEvent(display, MouseMask, &ev); 147 149 switch (ev.type) { 148 149 draw_outline(c);/* clear */150 151 152 153 154 155 156 157 158 draw_outline(c);/* clear */159 160 161 162 163 150 case MotionNotify: 151 draw_outline(c); /* clear */ 152 XUngrabServer(display); 153 c->x = old_cx + (ev.xmotion.x - x1); 154 c->y = old_cy + (ev.xmotion.y - y1); 155 XSync(display, False); 156 XGrabServer(display); 157 draw_outline(c); 158 break; 159 case ButtonRelease: 160 draw_outline(c); /* clear */ 161 XUngrabServer(display); 162 XUngrabPointer(display, CurrentTime); 163 return; 164 default: 165 break; 164 166 } 165 167 } … … 167 169 168 170 void 169 move(Client * c, int set)171 move(Client * c, int set) 170 172 { 171 173 if (!set) … … 178 180 179 181 void 180 resize(Client * c, int set)182 resize(Client * c, int set) 181 183 { 182 184 if (!set) … … 193 195 194 196 void 195 maximise_horiz(Client * c)197 maximise_horiz(Client * c) 196 198 { 197 199 if (c->oldw) { … … 208 210 209 211 void 210 maximise_vert(Client * c)212 maximise_vert(Client * c) 211 213 { 212 214 if (c->oldh) { … … 223 225 224 226 void 225 hide(Client * c)227 hide(Client * c) 226 228 { 227 229 c->ignore_unmap = 2; … … 232 234 233 235 void 234 unhide(Client * c, int raiseit)236 unhide(Client * c, int raiseit) 235 237 { 236 238 c->ignore_unmap = 0; 237 239 XMapWindow(display, c->window); 238 raiseit ? XMapRaised(display, c->parent) : XMapWindow(display, c->parent); 240 raiseit ? XMapRaised(display, c->parent) : XMapWindow(display, 241 c->parent); 239 242 set_wm_state(c, NormalState); 240 243 } … … 245 248 246 249 void 247 next(Client * c)250 next(Client * c) 248 251 { 249 252 Client *newc; 250 253 251 newc = next_client_on_vdesk(( 254 newc = next_client_on_vdesk((c ? c : head_client)); 252 255 253 256 if (!newc) 254 return; /* couldn't find a next on this screen */257 return; /* couldn't find a next on this screen */ 255 258 256 259 focus_client(newc, RAISE); … … 285 288 286 289 void 287 focus_client(Client * c, int raiseit)290 focus_client(Client * c, int raiseit) 288 291 { 289 292 Client *cp; … … 305 308 306 309 void 307 unfocus_client(Client * c)310 unfocus_client(Client * c) 308 311 { 309 312 XSetInputFocus(display, PointerRoot, RevertToPointerRoot, CurrentTime); -
ldm/trunk/fuentes/wwm/sendkey.c
r516 r855 13 13 14 14 void 15 key_to_event(KeySym key, XEvent * event, Window w, int type)15 key_to_event(KeySym key, XEvent * event, Window w, int type) 16 16 { 17 event->xkey.type 17 event->xkey.type = type; 18 18 event->xkey.display = display; 19 event->xkey.root 20 event->xkey.time 21 event->xkey.x 22 event->xkey.x_root 23 event->xkey.state 24 event->xkey.window 19 event->xkey.root = RootWindow(display, DefaultScreen(display)); 20 event->xkey.time = CurrentTime; 21 event->xkey.x = event->xkey.y = 0; 22 event->xkey.x_root = event->xkey.y_root = 0; 23 event->xkey.state = WMMODMASK; 24 event->xkey.window = w; 25 25 event->xkey.keycode = XKeysymToKeycode(display, key); 26 26 }
Note: See TracChangeset
for help on using the changeset viewer.