From f84be4fd25f04e122f8a68f9ce4f9dc4daead118 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Sat, 19 Sep 2015 12:40:42 +0200 Subject: fork unity-greeter as arctica-greeter --- src/Makefile.am | 26 +- src/arctica-greeter.vala | 660 +++++++++++++++++++++++++++++++++++++++++++++++ src/dash-box.vala | 2 +- src/dash-entry.vala | 6 +- src/flat-button.vala | 2 +- src/greeter-list.vala | 34 +-- src/main-window.vala | 18 +- src/menubar.vala | 6 +- src/prompt-box.vala | 2 +- src/session-list.vala | 2 +- src/settings-daemon.vala | 2 +- src/settings.vala | 2 +- src/shutdown-dialog.vala | 2 +- src/unity-greeter.vala | 660 ----------------------------------------------- src/user-list.vala | 80 +++--- 15 files changed, 752 insertions(+), 752 deletions(-) create mode 100644 src/arctica-greeter.vala delete mode 100644 src/unity-greeter.vala (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index b890ee0..4e11310 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,9 +1,9 @@ # -*- Mode: Automake; indent-tabs-mode: t; tab-width: 4 -*- -sbin_PROGRAMS = unity-greeter +sbin_PROGRAMS = arctica-greeter noinst_PROGRAMS = logo-generator -unity_greeter_SOURCES = \ +arctica_greeter_SOURCES = \ config.vapi \ fixes.vapi \ indicator.vapi \ @@ -31,26 +31,26 @@ unity_greeter_SOURCES = \ settings-daemon.vala \ shutdown-dialog.vala \ toggle-box.vala \ - unity-greeter.vala \ + arctica-greeter.vala \ user-list.vala \ user-prompt-box.vala logo_generator_SOURCES = logo-generator.vala -unity_greeter_CFLAGS = \ - $(UNITY_GREETER_CFLAGS) \ +arctica_greeter_CFLAGS = \ + $(ARCTICA_GREETER_CFLAGS) \ -w \ -DGNOME_DESKTOP_USE_UNSTABLE_API \ -DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" \ -DLOCALEDIR=\""$(localedir)"\" \ -DVERSION=\"$(VERSION)\" \ - -DCONFIG_FILE=\""$(sysconfdir)/lightdm/unity-greeter.conf"\" \ + -DCONFIG_FILE=\""$(sysconfdir)/lightdm/arctica-greeter.conf"\" \ -DPKGDATADIR=\""$(pkgdatadir)"\" \ -DINDICATORDIR=\""$(INDICATORDIR)"\" -logo_generator_CFLAGS = $(unity_greeter_CFLAGS) +logo_generator_CFLAGS = $(arctica_greeter_CFLAGS) -unity_greeter_VALAFLAGS = \ +arctica_greeter_VALAFLAGS = \ --pkg posix \ --pkg gtk+-3.0 \ --pkg gdk-x11-3.0 \ @@ -62,15 +62,15 @@ unity_greeter_VALAFLAGS = \ --pkg pixman-1 \ --target-glib 2.32 -logo_generator_VALAFLAGS = $(unity_greeter_VALAFLAGS) +logo_generator_VALAFLAGS = $(arctica_greeter_VALAFLAGS) -unity_greeter_LDADD = \ - $(UNITY_GREETER_LIBS) \ +arctica_greeter_LDADD = \ + $(ARCTICA_GREETER_LIBS) \ -lm -logo_generator_LDADD = $(unity_greeter_LDADD) +logo_generator_LDADD = $(arctica_greeter_LDADD) -unity_greeter_vala.stamp: $(top_srcdir)/config.h +arctica_greeter_vala.stamp: $(top_srcdir)/config.h DISTCLEANFILES = \ Makefile.in diff --git a/src/arctica-greeter.vala b/src/arctica-greeter.vala new file mode 100644 index 0000000..217e23c --- /dev/null +++ b/src/arctica-greeter.vala @@ -0,0 +1,660 @@ +/* -*- Mode: Vala; indent-tabs-mode: nil; tab-width: 4 -*- + * + * Copyright (C) 2011 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Authored by: Robert Ancell + */ + +public const int grid_size = 40; + +public class ArcticaGreeter +{ + public static ArcticaGreeter singleton; + + public signal void show_message (string text, LightDM.MessageType type); + public signal void show_prompt (string text, LightDM.PromptType type); + public signal void authentication_complete (); + public signal void starting_session (); + + public bool test_mode = false; + + private string state_file; + private KeyFile state; + + private Cairo.XlibSurface background_surface; + + private SettingsDaemon settings_daemon; + + public bool orca_needs_kick; + private MainWindow main_window; + + private LightDM.Greeter greeter; + + private Canberra.Context canberra_context; + + private static Timer log_timer; + + private DialogDBusInterface dbus_object; + + private ArcticaGreeter (bool test_mode_) + { + singleton = this; + test_mode = test_mode_; + + /* Prepare to set the background */ + debug ("Creating background surface"); + background_surface = create_root_surface (Gdk.Screen.get_default ()); + + greeter = new LightDM.Greeter (); + greeter.show_message.connect ((text, type) => { show_message (text, type); }); + greeter.show_prompt.connect ((text, type) => { show_prompt (text, type); }); + greeter.autologin_timer_expired.connect (() => { greeter.authenticate_autologin (); }); + greeter.authentication_complete.connect (() => { authentication_complete (); }); + var connected = false; + try + { + connected = greeter.connect_sync (); + } + catch (Error e) + { + warning ("Failed to connect to LightDM daemon"); + } + if (!connected && !test_mode) + Posix.exit (Posix.EXIT_FAILURE); + + if (!test_mode) + { + settings_daemon = new SettingsDaemon (); + settings_daemon.start (); + } + + var state_dir = Path.build_filename (Environment.get_user_cache_dir (), "arctica-greeter"); + DirUtils.create_with_parents (state_dir, 0775); + + var xdg_seat = GLib.Environment.get_variable("XDG_SEAT"); + var state_file_name = xdg_seat != null && xdg_seat != "seat0" ? xdg_seat + "-state" : "state"; + + state_file = Path.build_filename (state_dir, state_file_name); + state = new KeyFile (); + try + { + state.load_from_file (state_file, KeyFileFlags.NONE); + } + catch (Error e) + { + if (!(e is FileError.NOENT)) + warning ("Failed to load state from %s: %s\n", state_file, e.message); + } + + main_window = new MainWindow (); + + Bus.own_name (BusType.SESSION, "com.canonical.ArcticaGreeter", BusNameOwnerFlags.NONE); + + dbus_object = new DialogDBusInterface (); + dbus_object.open_dialog.connect ((type) => + { + ShutdownDialogType dialog_type; + switch (type) + { + default: + case 1: + dialog_type = ShutdownDialogType.LOGOUT; + break; + case 2: + dialog_type = ShutdownDialogType.RESTART; + break; + } + main_window.show_shutdown_dialog (dialog_type); + }); + dbus_object.close_dialog.connect ((type) => { main_window.close_shutdown_dialog (); }); + Bus.own_name (BusType.SESSION, "com.canonical.Unity", BusNameOwnerFlags.NONE, + (c) => + { + try + { + c.register_object ("/org/gnome/SessionManager/EndSessionDialog", dbus_object); + } + catch (Error e) + { + warning ("Failed to register /org/gnome/SessionManager/EndSessionDialog: %s", e.message); + } + }, + null, + () => debug ("Failed to acquire name com.canonical.Unity")); + + start_fake_wm (); + Gdk.threads_add_idle (ready_cb); + } + + public string? get_state (string key) + { + try + { + return state.get_value ("greeter", key); + } + catch (Error e) + { + return null; + } + } + + public void set_state (string key, string value) + { + state.set_value ("greeter", key, value); + var data = state.to_data (); + try + { + FileUtils.set_contents (state_file, data); + } + catch (Error e) + { + debug ("Failed to write state: %s", e.message); + } + } + + public void push_list (GreeterList widget) + { + main_window.push_list (widget); + } + + public void pop_list () + { + main_window.pop_list (); + } + + public static void add_style_class (Gtk.Widget widget) + { + /* Add style context class lightdm-user-list */ + var ctx = widget.get_style_context (); + ctx.add_class ("lightdm"); + } + + public bool start_session (string? session, Background bg) + { + /* Paint our background onto the root window before we close our own window */ + var c = new Cairo.Context (background_surface); + bg.draw_full (c, Background.DrawFlags.NONE); + c = null; + refresh_background (Gdk.Screen.get_default (), background_surface); + + if (test_mode) + { + debug ("Successfully logged in! Quitting..."); + Gtk.main_quit (); + return true; + } + + if (!session_is_valid (session)) + { + debug ("Session %s is not available, using system default %s instead", session, greeter.default_session_hint); + session = greeter.default_session_hint; + } + + var result = false; + try + { + result = LightDM.greeter_start_session_sync (greeter, session); + } + catch (Error e) + { + warning ("Failed to start session: %s", e.message); + } + + if (result) + starting_session (); + + return result; + } + + private bool session_is_valid (string? session) + { + if (session == null) + return true; + + foreach (var s in LightDM.get_sessions ()) + if (s.key == session) + return true; + + return false; + } + + private bool ready_cb () + { + debug ("starting system-ready sound"); + + /* Launch canberra */ + Canberra.Context.create (out canberra_context); + + if (UGSettings.get_boolean (UGSettings.KEY_PLAY_READY_SOUND)) + canberra_context.play (0, + Canberra.PROP_CANBERRA_XDG_THEME_NAME, + "ubuntu", + Canberra.PROP_EVENT_ID, + "system-ready"); + + return false; + } + + public void show () + { + debug ("Showing main window"); + main_window.show (); + main_window.get_window ().focus (Gdk.CURRENT_TIME); + main_window.set_keyboard_state (); + } + + public bool is_authenticated () + { + return greeter.is_authenticated; + } + + public void authenticate (string? userid = null) + { + greeter.authenticate (userid); + } + + public void authenticate_as_guest () + { + greeter.authenticate_as_guest (); + } + + public void authenticate_remote (string? session, string? userid) + { + ArcticaGreeter.singleton.greeter.authenticate_remote (session, userid); + } + + public void cancel_authentication () + { + greeter.cancel_authentication (); + } + + public void respond (string response) + { + greeter.respond (response); + } + + public string authentication_user () + { + return greeter.authentication_user; + } + + public string default_session_hint () + { + return greeter.default_session_hint; + } + + public string select_user_hint () + { + return greeter.select_user_hint; + } + + public bool show_manual_login_hint () + { + return greeter.show_manual_login_hint; + } + + public bool show_remote_login_hint () + { + return greeter.show_remote_login_hint; + } + + public bool hide_users_hint () + { + return greeter.hide_users_hint; + } + + public bool has_guest_account_hint () + { + return greeter.has_guest_account_hint; + } + + private Gdk.FilterReturn focus_upon_map (Gdk.XEvent gxevent, Gdk.Event event) + { + var xevent = (X.Event*)gxevent; + if (xevent.type == X.EventType.MapNotify) + { + var display = Gdk.x11_lookup_xdisplay (xevent.xmap.display); + var xwin = xevent.xmap.window; + var win = Gdk.X11Window.foreign_new_for_display (display, xwin); + if (win != null && !xevent.xmap.override_redirect) + { + /* Check to see if this window is our onboard window, since we don't want to focus it. */ + X.Window keyboard_xid = 0; + if (main_window.menubar.keyboard_window != null) + keyboard_xid = Gdk.X11Window.get_xid (main_window.menubar.keyboard_window.get_window ()); + + if (xwin != keyboard_xid && win.get_type_hint() != Gdk.WindowTypeHint.NOTIFICATION) + { + win.focus (Gdk.CURRENT_TIME); + + /* Make sure to keep keyboard above */ + if (main_window.menubar.keyboard_window != null) + main_window.menubar.keyboard_window.get_window ().raise (); + } + } + } + else if (xevent.type == X.EventType.UnmapNotify) + { + // Since we aren't keeping track of focus (for example, we don't + // track the Z stack of windows) like a normal WM would, when we + // decide here where to return focus after another window unmaps, + // we don't have much to go on. X will tell us if we should take + // focus back. (I could not find an obvious way to determine this, + // but checking if the X input focus is RevertTo.None seems + // reliable.) + + X.Window xwin; + int revert_to; + xevent.xunmap.display.get_input_focus (out xwin, out revert_to); + + if (revert_to == X.RevertTo.None) + { + main_window.get_window ().focus (Gdk.CURRENT_TIME); + + /* Make sure to keep keyboard above */ + if (main_window.menubar.keyboard_window != null) + main_window.menubar.keyboard_window.get_window ().raise (); + } + } + return Gdk.FilterReturn.CONTINUE; + } + + private void start_fake_wm () + { + /* We want new windows (e.g. the shutdown dialog) to gain focus. + We don't really need anything more than that (don't need alt-tab + since any dialog should be "modal" or at least dealt with before + continuing even if not actually marked as modal) */ + var root = Gdk.get_default_root_window (); + root.set_events (root.get_events () | Gdk.EventMask.SUBSTRUCTURE_MASK); + root.add_filter (focus_upon_map); + } + + private static Cairo.XlibSurface? create_root_surface (Gdk.Screen screen) + { + var visual = screen.get_system_visual (); + + unowned X.Display display = Gdk.X11Display.get_xdisplay (screen.get_display ()); + + var pixmap = X.CreatePixmap (display, + Gdk.X11Window.get_xid (screen.get_root_window ()), + screen.get_width (), + screen.get_height (), + visual.get_depth ()); + + /* Convert into a Cairo surface */ + var surface = new Cairo.XlibSurface (display, + pixmap, + Gdk.X11Visual.get_xvisual (visual), + screen.get_width (), screen.get_height ()); + + return surface; + } + + private static void refresh_background (Gdk.Screen screen, Cairo.XlibSurface surface) + { + Gdk.flush (); + + unowned X.Display display = Gdk.X11Display.get_xdisplay (screen.get_display ()); + + /* Ensure Cairo has actually finished its drawing */ + surface.flush (); + /* Use this pixmap for the background */ + X.SetWindowBackgroundPixmap (display, + Gdk.X11Window.get_xid (screen.get_root_window ()), + surface.get_drawable ()); + + X.ClearWindow (display, Gdk.X11Window.get_xid (screen.get_root_window ())); + } + + private static void log_cb (string? log_domain, LogLevelFlags log_level, string message) + { + string prefix; + switch (log_level & LogLevelFlags.LEVEL_MASK) + { + case LogLevelFlags.LEVEL_ERROR: + prefix = "ERROR:"; + break; + case LogLevelFlags.LEVEL_CRITICAL: + prefix = "CRITICAL:"; + break; + case LogLevelFlags.LEVEL_WARNING: + prefix = "WARNING:"; + break; + case LogLevelFlags.LEVEL_MESSAGE: + prefix = "MESSAGE:"; + break; + case LogLevelFlags.LEVEL_INFO: + prefix = "INFO:"; + break; + case LogLevelFlags.LEVEL_DEBUG: + prefix = "DEBUG:"; + break; + default: + prefix = "LOG:"; + break; + } + + stderr.printf ("[%+.2fs] %s %s\n", log_timer.elapsed (), prefix, message); + } + + public static int main (string[] args) + { + /* Protect memory from being paged to disk, as we deal with passwords */ + Posix.mlockall (Posix.MCL_CURRENT | Posix.MCL_FUTURE); + + /* Disable the stupid global menubar */ + Environment.unset_variable ("UBUNTU_MENUPROXY"); + + /* Initialize i18n */ + Intl.setlocale (LocaleCategory.ALL, ""); + Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.LOCALEDIR); + Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8"); + Intl.textdomain (Config.GETTEXT_PACKAGE); + + /* Set up the accessibility stack, in case the user needs it for screen reading etc. */ + Environment.set_variable ("GTK_MODULES", "atk-bridge", false); + + Pid atspi_pid = 0; + Pid upstart_pid = 0; + + try + { + string[] argv; + + Shell.parse_argv ("/usr/lib/at-spi2-core/at-spi-bus-launcher --launch-immediately", out argv); + Process.spawn_async (null, + argv, + null, + SpawnFlags.SEARCH_PATH, + null, + out atspi_pid); + } + catch (Error e) + { + warning ("Error starting the at-spi registry: %s", e.message); + } + + Gtk.init (ref args); + Ido.init (); + + log_timer = new Timer (); + Log.set_default_handler (log_cb); + + debug ("Starting arctica-greeter %s UID=%d LANG=%s", Config.VERSION, (int) Posix.getuid (), Environment.get_variable ("LANG")); + + /* Set the cursor to not be the crap default */ + debug ("Setting cursor"); + Gdk.get_default_root_window ().set_cursor (new Gdk.Cursor (Gdk.CursorType.LEFT_PTR)); + + bool do_show_version = false; + bool do_test_mode = false; + OptionEntry versionOption = { "version", 'v', 0, OptionArg.NONE, ref do_show_version, + /* Help string for command line --version flag */ + N_("Show release version"), null }; + OptionEntry testOption = { "test-mode", 0, 0, OptionArg.NONE, ref do_test_mode, + /* Help string for command line --test-mode flag */ + N_("Run in test mode"), null }; + OptionEntry nullOption = { null }; + OptionEntry[] options = { versionOption, testOption, nullOption }; + + debug ("Loading command line options"); + var c = new OptionContext (/* Arguments and description for --help text */ + _("- Arctica Greeter")); + c.add_main_entries (options, Config.GETTEXT_PACKAGE); + c.add_group (Gtk.get_option_group (true)); + try + { + c.parse (ref args); + } + catch (Error e) + { + stderr.printf ("%s\n", e.message); + stderr.printf (/* Text printed out when an unknown command-line argument provided */ + _("Run '%s --help' to see a full list of available command line options."), args[0]); + stderr.printf ("\n"); + return Posix.EXIT_FAILURE; + } + if (do_show_version) + { + /* Note, not translated so can be easily parsed */ + stderr.printf ("arctica-greeter %s\n", Config.VERSION); + return Posix.EXIT_SUCCESS; + } + + if (do_test_mode) + debug ("Running in test mode"); + + /* Set GTK+ settings */ + debug ("Setting GTK+ settings"); + var settings = Gtk.Settings.get_default (); + var value = UGSettings.get_string (UGSettings.KEY_THEME_NAME); + if (value != "") + settings.set ("gtk-theme-name", value, null); + value = UGSettings.get_string (UGSettings.KEY_ICON_THEME_NAME); + if (value != "") + settings.set ("gtk-icon-theme-name", value, null); + value = UGSettings.get_string (UGSettings.KEY_FONT_NAME); + if (value != "") + settings.set ("gtk-font-name", value, null); + var double_value = UGSettings.get_double (UGSettings.KEY_XFT_DPI); + if (double_value != 0.0) + settings.set ("gtk-xft-dpi", (int) (1024 * double_value), null); + var boolean_value = UGSettings.get_boolean (UGSettings.KEY_XFT_ANTIALIAS); + settings.set ("gtk-xft-antialias", boolean_value, null); + value = UGSettings.get_string (UGSettings.KEY_XFT_HINTSTYLE); + if (value != "") + settings.set ("gtk-xft-hintstyle", value, null); + value = UGSettings.get_string (UGSettings.KEY_XFT_RGBA); + if (value != "") + settings.set ("gtk-xft-rgba", value, null); + + debug ("Creating Arctica Greeter"); + var greeter = new ArcticaGreeter (do_test_mode); + + debug ("Showing greeter"); + greeter.show (); + + if (!do_test_mode) + { + /* Start the indicator services */ + try + { + string[] argv; + + Shell.parse_argv ("init --user --startup-event indicator-services-start", out argv); + Process.spawn_async (null, + argv, + null, + SpawnFlags.SEARCH_PATH, + null, + out upstart_pid); + } + catch (Error e) + { + warning ("Error starting Upstart for indicators: %s", e.message); + } + + /* Make nm-applet hide items the user does not have permissions to interact with */ + Environment.set_variable ("NM_APPLET_HIDE_POLICY_ITEMS", "1", true); + + try + { + Process.spawn_command_line_async ("nm-applet"); + } + catch (Error e) + { + warning ("Error starting nm-applet: %s", e.message); + } + } + + /* Setup a handler for TERM so we quit cleanly */ + GLib.Unix.signal_add(GLib.ProcessSignal.TERM, () => { + debug("Got a SIGTERM"); + Gtk.main_quit(); + return true; + }); + + debug ("Starting main loop"); + Gtk.main (); + + debug ("Cleaning up"); + + if (upstart_pid != 0) + { + Posix.kill (upstart_pid, Posix.SIGTERM); + int status; + Posix.waitpid (upstart_pid, out status, 0); + if (Process.if_exited (status)) + debug ("Upstart exited with return value %d", Process.exit_status (status)); + else + debug ("Upstart terminated with signal %d", Process.term_sig (status)); + upstart_pid = 0; + } + + if (atspi_pid != 0) + { + Posix.kill (atspi_pid, Posix.SIGKILL); + int status; + Posix.waitpid (atspi_pid, out status, 0); + if (Process.if_exited (status)) + debug ("AT-SPI exited with return value %d", Process.exit_status (status)); + else + debug ("AT-SPI terminated with signal %d", Process.term_sig (status)); + atspi_pid = 0; + } + + debug ("Exiting"); + + return Posix.EXIT_SUCCESS; + } +} + +[DBus (name="org.gnome.SessionManager.EndSessionDialog")] +public class DialogDBusInterface : Object +{ + public signal void open_dialog (uint32 type); + public signal void close_dialog (); + + public void open (uint32 type, uint32 timestamp, uint32 seconds_to_stay_open, ObjectPath[] inhibitor_object_paths) + { + open_dialog (type); + } + + public void close () + { + close_dialog (); + } +} diff --git a/src/dash-box.vala b/src/dash-box.vala index 40ecf34..e5a64c6 100644 --- a/src/dash-box.vala +++ b/src/dash-box.vala @@ -52,7 +52,7 @@ public class DashBox : Gtk.Box /* Does not actually add w to this widget, as doing so would potentially mess with w's placement. */ public void set_base (Gtk.Widget? w) { - if (!UnityGreeter.singleton.test_mode) { + if (!ArcticaGreeter.singleton.test_mode) { return_if_fail (pushed == null); return_if_fail (mode == Mode.NORMAL); } diff --git a/src/dash-entry.vala b/src/dash-entry.vala index 9528705..634dd16 100644 --- a/src/dash-entry.vala +++ b/src/dash-entry.vala @@ -47,7 +47,7 @@ public class DashEntry : Gtk.Entry, Fadable } } - private static const string NO_BORDER_CLASS = "unity-greeter-no-border"; + private static const string NO_BORDER_CLASS = "arctica-greeter-no-border"; protected FadeTracker fade_tracker { get; protected set; } private Gdk.Window arrow_win; @@ -308,10 +308,10 @@ public class DashEntry : Gtk.Entry, Fadable // This is a workaroud for bug https://launchpad.net/bugs/944159 // The problem is that orca seems to not notice that it's in a password // field on startup. We just need to kick orca in the pants. - if (UnityGreeter.singleton.orca_needs_kick) + if (ArcticaGreeter.singleton.orca_needs_kick) { Signal.emit_by_name (get_accessible (), "focus-event", true); - UnityGreeter.singleton.orca_needs_kick = false; + ArcticaGreeter.singleton.orca_needs_kick = false; } return base.key_press_event (event); diff --git a/src/flat-button.vala b/src/flat-button.vala index 3a718d2..1ce23a7 100644 --- a/src/flat-button.vala +++ b/src/flat-button.vala @@ -23,7 +23,7 @@ public class FlatButton : Gtk.Button construct { - UnityGreeter.add_style_class (this); + ArcticaGreeter.add_style_class (this); try { var style = new Gtk.CssProvider (); diff --git a/src/greeter-list.vala b/src/greeter-list.vala index 2433a10..965da26 100644 --- a/src/greeter-list.vala +++ b/src/greeter-list.vala @@ -24,7 +24,7 @@ private int get_grid_offset (int size) return (int) (size % grid_size) / 2; } -[DBus (name="com.canonical.UnityGreeter.List")] +[DBus (name="com.canonical.ArcticaGreeter.List")] public class ListDBusInterface : Object { private GreeterList list; @@ -231,7 +231,7 @@ public abstract class GreeterList : FadableBox public void cancel_authentication () { - UnityGreeter.singleton.cancel_authentication (); + ArcticaGreeter.singleton.cancel_authentication (); entry_selected (selected_entry.id); } @@ -266,7 +266,7 @@ public abstract class GreeterList : FadableBox protected void add_with_class (Gtk.Widget widget) { fixed.add (widget); - UnityGreeter.add_style_class (widget); + ArcticaGreeter.add_style_class (widget); } protected void redraw_greeter_box () @@ -475,7 +475,7 @@ public abstract class GreeterList : FadableBox entry.destroy (); /* Show a manual login if no users and no remote login entry */ - if (!have_entries () && !UnityGreeter.singleton.show_remote_login_hint ()) + if (!have_entries () && !ArcticaGreeter.singleton.show_remote_login_hint ()) add_manual_entry (); queue_draw (); @@ -781,9 +781,9 @@ public abstract class GreeterList : FadableBox protected void connect_to_lightdm () { - UnityGreeter.singleton.show_message.connect (show_message_cb); - UnityGreeter.singleton.show_prompt.connect (show_prompt_cb); - UnityGreeter.singleton.authentication_complete.connect (authentication_complete_cb); + ArcticaGreeter.singleton.show_message.connect (show_message_cb); + ArcticaGreeter.singleton.show_prompt.connect (show_prompt_cb); + ArcticaGreeter.singleton.authentication_complete.connect (authentication_complete_cb); } protected void show_message_cb (string text, LightDM.MessageType type) @@ -797,10 +797,10 @@ public abstract class GreeterList : FadableBox /* Notify the greeter on what user has been logged */ if (get_selected_id () == "*other" && manual_name == null) { - if (UnityGreeter.singleton.test_mode) + if (ArcticaGreeter.singleton.test_mode) manual_name = test_username; else - manual_name = UnityGreeter.singleton.authentication_user(); + manual_name = ArcticaGreeter.singleton.authentication_user(); } prompted = true; @@ -826,10 +826,10 @@ public abstract class GreeterList : FadableBox return; bool is_authenticated; - if (UnityGreeter.singleton.test_mode) + if (ArcticaGreeter.singleton.test_mode) is_authenticated = test_is_authenticated; else - is_authenticated = UnityGreeter.singleton.is_authenticated(); + is_authenticated = ArcticaGreeter.singleton.is_authenticated(); if (is_authenticated) { @@ -837,7 +837,7 @@ public abstract class GreeterList : FadableBox if (prompted && !unacknowledged_messages) { login_complete (); - if (UnityGreeter.singleton.test_mode) + if (ArcticaGreeter.singleton.test_mode) start_session (); else { @@ -890,16 +890,16 @@ public abstract class GreeterList : FadableBox greeter_authenticating_user = get_selected_id (); - if (UnityGreeter.singleton.test_mode) + if (ArcticaGreeter.singleton.test_mode) test_start_authentication (); else { if (get_selected_id () == "*other") - UnityGreeter.singleton.authenticate (); + ArcticaGreeter.singleton.authenticate (); else if (get_selected_id () == "*guest") - UnityGreeter.singleton.authenticate_as_guest (); + ArcticaGreeter.singleton.authenticate_as_guest (); else - UnityGreeter.singleton.authenticate (get_selected_id ()); + ArcticaGreeter.singleton.authenticate (get_selected_id ()); } } @@ -914,7 +914,7 @@ public abstract class GreeterList : FadableBox private void start_session () { - if (!UnityGreeter.singleton.start_session (get_lightdm_session (), background)) + if (!ArcticaGreeter.singleton.start_session (get_lightdm_session (), background)) { show_message (_("Failed to start session"), true); start_authentication (); diff --git a/src/main-window.vala b/src/main-window.vala index 7574719..4026cff 100644 --- a/src/main-window.vala +++ b/src/main-window.vala @@ -48,7 +48,7 @@ public class MainWindow : Gtk.Window override_background_color (Gtk.StateFlags.NORMAL, bg_color); get_accessible ().set_name (_("Login Screen")); has_resize_grip = false; - UnityGreeter.add_style_class (this); + ArcticaGreeter.add_style_class (this); realize (); background = new Background (Gdk.cairo_create (get_window ()).get_target ()); @@ -57,7 +57,7 @@ public class MainWindow : Gtk.Window background.set_logo (UGSettings.get_string (UGSettings.KEY_LOGO), UGSettings.get_string (UGSettings.KEY_BACKGROUND_LOGO)); background.show (); add (background); - UnityGreeter.add_style_class (background); + ArcticaGreeter.add_style_class (background); login_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); login_box.show (); @@ -93,13 +93,13 @@ public class MainWindow : Gtk.Window menualign.show (); menubox.add (menualign); login_box.add (menubox); - UnityGreeter.add_style_class (menualign); - UnityGreeter.add_style_class (menubox); + ArcticaGreeter.add_style_class (menualign); + ArcticaGreeter.add_style_class (menubox); menubar = new MenuBar (background, accel_group); menubar.show (); menualign.add (menubar); - UnityGreeter.add_style_class (menubar); + ArcticaGreeter.add_style_class (menubar); hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); hbox.expand = true; @@ -132,7 +132,7 @@ public class MainWindow : Gtk.Window add_user_list (); - if (UnityGreeter.singleton.test_mode) + if (ArcticaGreeter.singleton.test_mode) { /* Simulate an 800x600 monitor to the left of a 640x480 monitor */ monitors = new List (); @@ -274,7 +274,7 @@ public class MainWindow : Gtk.Window GreeterList greeter_list; greeter_list = new UserList (background, menubar); greeter_list.show (); - UnityGreeter.add_style_class (greeter_list); + ArcticaGreeter.add_style_class (greeter_list); push_list (greeter_list); } @@ -347,14 +347,14 @@ public class MainWindow : Gtk.Window show_shutdown_dialog (ShutdownDialogType.SHUTDOWN); return true; case Gdk.Key.z: - if (UnityGreeter.singleton.test_mode && (event.state & Gdk.ModifierType.MOD1_MASK) != 0) + if (ArcticaGreeter.singleton.test_mode && (event.state & Gdk.ModifierType.MOD1_MASK) != 0) { show_shutdown_dialog (ShutdownDialogType.SHUTDOWN); return true; } break; case Gdk.Key.Z: - if (UnityGreeter.singleton.test_mode && (event.state & Gdk.ModifierType.MOD1_MASK) != 0) + if (ArcticaGreeter.singleton.test_mode && (event.state & Gdk.ModifierType.MOD1_MASK) != 0) { show_shutdown_dialog (ShutdownDialogType.RESTART); return true; diff --git a/src/menubar.vala b/src/menubar.vala index 79783da..799cb18 100644 --- a/src/menubar.vala +++ b/src/menubar.vala @@ -153,7 +153,7 @@ public class MenuBar : Gtk.MenuBar setup_indicators (); - UnityGreeter.singleton.starting_session.connect (cleanup); + ArcticaGreeter.singleton.starting_session.connect (cleanup); } private void close_pid (ref Pid pid) @@ -325,7 +325,7 @@ public class MenuBar : Gtk.MenuBar try { var conn = Bus.get_sync (BusType.SESSION); - greeter_set_env ("UNITY_GREETER_DBUS_NAME", conn.get_unique_name ()); + greeter_set_env ("ARCTICA_GREETER_DBUS_NAME", conn.get_unique_name ()); } catch (IOError e) { @@ -474,7 +474,7 @@ public class MenuBar : Gtk.MenuBar // this is not racy with orca startup, it is racy with whether // orca will read the first character or not out loud. Hence // why we do both. Ideally this would be fixed in orca itself. - UnityGreeter.singleton.orca_needs_kick = true; + ArcticaGreeter.singleton.orca_needs_kick = true; Timeout.add_seconds (1, () => { Signal.emit_by_name ((get_toplevel () as Gtk.Window).get_focus ().get_accessible (), "focus-event", true); return false; diff --git a/src/prompt-box.vala b/src/prompt-box.vala index 894870d..50c46d1 100644 --- a/src/prompt-box.vala +++ b/src/prompt-box.vala @@ -423,7 +423,7 @@ public class PromptBox : FadableBox { w.set_data ("prompt-box-widget", this); if (add_style_class) - UnityGreeter.add_style_class (w); + ArcticaGreeter.add_style_class (w); last_row += 1; box_grid.attach (w, COL_ENTRIES_START, last_row, COL_ENTRIES_WIDTH, 1); diff --git a/src/session-list.vala b/src/session-list.vala index 7127023..bfbab9c 100644 --- a/src/session-list.vala +++ b/src/session-list.vala @@ -36,7 +36,7 @@ public class SessionPrompt : PromptBox box = new ToggleBox (default_session, session); - if (UnityGreeter.singleton.test_mode) + if (ArcticaGreeter.singleton.test_mode) { box.add_item ("gnome", "GNOME", SessionList.get_badge ("gnome")); box.add_item ("kde", "KDE", SessionList.get_badge ("kde")); diff --git a/src/settings-daemon.vala b/src/settings-daemon.vala index 9cf3908..65440e8 100644 --- a/src/settings-daemon.vala +++ b/src/settings-daemon.vala @@ -122,7 +122,7 @@ public class SettingsDaemon : Object new Variant ("(ssss)", "handle-power-key", Environment.get_user_name (), - "Unity Greeter handling keypresses", + "Arctica Greeter handling keypresses", "block"), new VariantType ("(h)"), DBusCallFlags.NONE, diff --git a/src/settings.vala b/src/settings.vala index ebdc9e7..12722c5 100644 --- a/src/settings.vala +++ b/src/settings.vala @@ -97,5 +97,5 @@ public class UGSettings return gsettings.set_strv (key, value); } - private static const string SCHEMA = "com.canonical.unity-greeter"; + private static const string SCHEMA = "org.ArcticaProject.arctica-greeter"; } diff --git a/src/shutdown-dialog.vala b/src/shutdown-dialog.vala index 73e1bf4..cccd534 100644 --- a/src/shutdown-dialog.vala +++ b/src/shutdown-dialog.vala @@ -565,7 +565,7 @@ private class DialogButton : Gtk.Button this.get_accessible ().set_name (l.get_text ()); } - UnityGreeter.add_style_class (this); + ArcticaGreeter.add_style_class (this); try { // Remove the default GtkButton paddings and border diff --git a/src/unity-greeter.vala b/src/unity-greeter.vala deleted file mode 100644 index cf501af..0000000 --- a/src/unity-greeter.vala +++ /dev/null @@ -1,660 +0,0 @@ -/* -*- Mode: Vala; indent-tabs-mode: nil; tab-width: 4 -*- - * - * Copyright (C) 2011 Canonical Ltd - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 3 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Authored by: Robert Ancell - */ - -public const int grid_size = 40; - -public class UnityGreeter -{ - public static UnityGreeter singleton; - - public signal void show_message (string text, LightDM.MessageType type); - public signal void show_prompt (string text, LightDM.PromptType type); - public signal void authentication_complete (); - public signal void starting_session (); - - public bool test_mode = false; - - private string state_file; - private KeyFile state; - - private Cairo.XlibSurface background_surface; - - private SettingsDaemon settings_daemon; - - public bool orca_needs_kick; - private MainWindow main_window; - - private LightDM.Greeter greeter; - - private Canberra.Context canberra_context; - - private static Timer log_timer; - - private DialogDBusInterface dbus_object; - - private UnityGreeter (bool test_mode_) - { - singleton = this; - test_mode = test_mode_; - - /* Prepare to set the background */ - debug ("Creating background surface"); - background_surface = create_root_surface (Gdk.Screen.get_default ()); - - greeter = new LightDM.Greeter (); - greeter.show_message.connect ((text, type) => { show_message (text, type); }); - greeter.show_prompt.connect ((text, type) => { show_prompt (text, type); }); - greeter.autologin_timer_expired.connect (() => { greeter.authenticate_autologin (); }); - greeter.authentication_complete.connect (() => { authentication_complete (); }); - var connected = false; - try - { - connected = greeter.connect_sync (); - } - catch (Error e) - { - warning ("Failed to connect to LightDM daemon"); - } - if (!connected && !test_mode) - Posix.exit (Posix.EXIT_FAILURE); - - if (!test_mode) - { - settings_daemon = new SettingsDaemon (); - settings_daemon.start (); - } - - var state_dir = Path.build_filename (Environment.get_user_cache_dir (), "unity-greeter"); - DirUtils.create_with_parents (state_dir, 0775); - - var xdg_seat = GLib.Environment.get_variable("XDG_SEAT"); - var state_file_name = xdg_seat != null && xdg_seat != "seat0" ? xdg_seat + "-state" : "state"; - - state_file = Path.build_filename (state_dir, state_file_name); - state = new KeyFile (); - try - { - state.load_from_file (state_file, KeyFileFlags.NONE); - } - catch (Error e) - { - if (!(e is FileError.NOENT)) - warning ("Failed to load state from %s: %s\n", state_file, e.message); - } - - main_window = new MainWindow (); - - Bus.own_name (BusType.SESSION, "com.canonical.UnityGreeter", BusNameOwnerFlags.NONE); - - dbus_object = new DialogDBusInterface (); - dbus_object.open_dialog.connect ((type) => - { - ShutdownDialogType dialog_type; - switch (type) - { - default: - case 1: - dialog_type = ShutdownDialogType.LOGOUT; - break; - case 2: - dialog_type = ShutdownDialogType.RESTART; - break; - } - main_window.show_shutdown_dialog (dialog_type); - }); - dbus_object.close_dialog.connect ((type) => { main_window.close_shutdown_dialog (); }); - Bus.own_name (BusType.SESSION, "com.canonical.Unity", BusNameOwnerFlags.NONE, - (c) => - { - try - { - c.register_object ("/org/gnome/SessionManager/EndSessionDialog", dbus_object); - } - catch (Error e) - { - warning ("Failed to register /org/gnome/SessionManager/EndSessionDialog: %s", e.message); - } - }, - null, - () => debug ("Failed to acquire name com.canonical.Unity")); - - start_fake_wm (); - Gdk.threads_add_idle (ready_cb); - } - - public string? get_state (string key) - { - try - { - return state.get_value ("greeter", key); - } - catch (Error e) - { - return null; - } - } - - public void set_state (string key, string value) - { - state.set_value ("greeter", key, value); - var data = state.to_data (); - try - { - FileUtils.set_contents (state_file, data); - } - catch (Error e) - { - debug ("Failed to write state: %s", e.message); - } - } - - public void push_list (GreeterList widget) - { - main_window.push_list (widget); - } - - public void pop_list () - { - main_window.pop_list (); - } - - public static void add_style_class (Gtk.Widget widget) - { - /* Add style context class lightdm-user-list */ - var ctx = widget.get_style_context (); - ctx.add_class ("lightdm"); - } - - public bool start_session (string? session, Background bg) - { - /* Paint our background onto the root window before we close our own window */ - var c = new Cairo.Context (background_surface); - bg.draw_full (c, Background.DrawFlags.NONE); - c = null; - refresh_background (Gdk.Screen.get_default (), background_surface); - - if (test_mode) - { - debug ("Successfully logged in! Quitting..."); - Gtk.main_quit (); - return true; - } - - if (!session_is_valid (session)) - { - debug ("Session %s is not available, using system default %s instead", session, greeter.default_session_hint); - session = greeter.default_session_hint; - } - - var result = false; - try - { - result = LightDM.greeter_start_session_sync (greeter, session); - } - catch (Error e) - { - warning ("Failed to start session: %s", e.message); - } - - if (result) - starting_session (); - - return result; - } - - private bool session_is_valid (string? session) - { - if (session == null) - return true; - - foreach (var s in LightDM.get_sessions ()) - if (s.key == session) - return true; - - return false; - } - - private bool ready_cb () - { - debug ("starting system-ready sound"); - - /* Launch canberra */ - Canberra.Context.create (out canberra_context); - - if (UGSettings.get_boolean (UGSettings.KEY_PLAY_READY_SOUND)) - canberra_context.play (0, - Canberra.PROP_CANBERRA_XDG_THEME_NAME, - "ubuntu", - Canberra.PROP_EVENT_ID, - "system-ready"); - - return false; - } - - public void show () - { - debug ("Showing main window"); - main_window.show (); - main_window.get_window ().focus (Gdk.CURRENT_TIME); - main_window.set_keyboard_state (); - } - - public bool is_authenticated () - { - return greeter.is_authenticated; - } - - public void authenticate (string? userid = null) - { - greeter.authenticate (userid); - } - - public void authenticate_as_guest () - { - greeter.authenticate_as_guest (); - } - - public void authenticate_remote (string? session, string? userid) - { - UnityGreeter.singleton.greeter.authenticate_remote (session, userid); - } - - public void cancel_authentication () - { - greeter.cancel_authentication (); - } - - public void respond (string response) - { - greeter.respond (response); - } - - public string authentication_user () - { - return greeter.authentication_user; - } - - public string default_session_hint () - { - return greeter.default_session_hint; - } - - public string select_user_hint () - { - return greeter.select_user_hint; - } - - public bool show_manual_login_hint () - { - return greeter.show_manual_login_hint; - } - - public bool show_remote_login_hint () - { - return greeter.show_remote_login_hint; - } - - public bool hide_users_hint () - { - return greeter.hide_users_hint; - } - - public bool has_guest_account_hint () - { - return greeter.has_guest_account_hint; - } - - private Gdk.FilterReturn focus_upon_map (Gdk.XEvent gxevent, Gdk.Event event) - { - var xevent = (X.Event*)gxevent; - if (xevent.type == X.EventType.MapNotify) - { - var display = Gdk.x11_lookup_xdisplay (xevent.xmap.display); - var xwin = xevent.xmap.window; - var win = Gdk.X11Window.foreign_new_for_display (display, xwin); - if (win != null && !xevent.xmap.override_redirect) - { - /* Check to see if this window is our onboard window, since we don't want to focus it. */ - X.Window keyboard_xid = 0; - if (main_window.menubar.keyboard_window != null) - keyboard_xid = Gdk.X11Window.get_xid (main_window.menubar.keyboard_window.get_window ()); - - if (xwin != keyboard_xid && win.get_type_hint() != Gdk.WindowTypeHint.NOTIFICATION) - { - win.focus (Gdk.CURRENT_TIME); - - /* Make sure to keep keyboard above */ - if (main_window.menubar.keyboard_window != null) - main_window.menubar.keyboard_window.get_window ().raise (); - } - } - } - else if (xevent.type == X.EventType.UnmapNotify) - { - // Since we aren't keeping track of focus (for example, we don't - // track the Z stack of windows) like a normal WM would, when we - // decide here where to return focus after another window unmaps, - // we don't have much to go on. X will tell us if we should take - // focus back. (I could not find an obvious way to determine this, - // but checking if the X input focus is RevertTo.None seems - // reliable.) - - X.Window xwin; - int revert_to; - xevent.xunmap.display.get_input_focus (out xwin, out revert_to); - - if (revert_to == X.RevertTo.None) - { - main_window.get_window ().focus (Gdk.CURRENT_TIME); - - /* Make sure to keep keyboard above */ - if (main_window.menubar.keyboard_window != null) - main_window.menubar.keyboard_window.get_window ().raise (); - } - } - return Gdk.FilterReturn.CONTINUE; - } - - private void start_fake_wm () - { - /* We want new windows (e.g. the shutdown dialog) to gain focus. - We don't really need anything more than that (don't need alt-tab - since any dialog should be "modal" or at least dealt with before - continuing even if not actually marked as modal) */ - var root = Gdk.get_default_root_window (); - root.set_events (root.get_events () | Gdk.EventMask.SUBSTRUCTURE_MASK); - root.add_filter (focus_upon_map); - } - - private static Cairo.XlibSurface? create_root_surface (Gdk.Screen screen) - { - var visual = screen.get_system_visual (); - - unowned X.Display display = Gdk.X11Display.get_xdisplay (screen.get_display ()); - - var pixmap = X.CreatePixmap (display, - Gdk.X11Window.get_xid (screen.get_root_window ()), - screen.get_width (), - screen.get_height (), - visual.get_depth ()); - - /* Convert into a Cairo surface */ - var surface = new Cairo.XlibSurface (display, - pixmap, - Gdk.X11Visual.get_xvisual (visual), - screen.get_width (), screen.get_height ()); - - return surface; - } - - private static void refresh_background (Gdk.Screen screen, Cairo.XlibSurface surface) - { - Gdk.flush (); - - unowned X.Display display = Gdk.X11Display.get_xdisplay (screen.get_display ()); - - /* Ensure Cairo has actually finished its drawing */ - surface.flush (); - /* Use this pixmap for the background */ - X.SetWindowBackgroundPixmap (display, - Gdk.X11Window.get_xid (screen.get_root_window ()), - surface.get_drawable ()); - - X.ClearWindow (display, Gdk.X11Window.get_xid (screen.get_root_window ())); - } - - private static void log_cb (string? log_domain, LogLevelFlags log_level, string message) - { - string prefix; - switch (log_level & LogLevelFlags.LEVEL_MASK) - { - case LogLevelFlags.LEVEL_ERROR: - prefix = "ERROR:"; - break; - case LogLevelFlags.LEVEL_CRITICAL: - prefix = "CRITICAL:"; - break; - case LogLevelFlags.LEVEL_WARNING: - prefix = "WARNING:"; - break; - case LogLevelFlags.LEVEL_MESSAGE: - prefix = "MESSAGE:"; - break; - case LogLevelFlags.LEVEL_INFO: - prefix = "INFO:"; - break; - case LogLevelFlags.LEVEL_DEBUG: - prefix = "DEBUG:"; - break; - default: - prefix = "LOG:"; - break; - } - - stderr.printf ("[%+.2fs] %s %s\n", log_timer.elapsed (), prefix, message); - } - - public static int main (string[] args) - { - /* Protect memory from being paged to disk, as we deal with passwords */ - Posix.mlockall (Posix.MCL_CURRENT | Posix.MCL_FUTURE); - - /* Disable the stupid global menubar */ - Environment.unset_variable ("UBUNTU_MENUPROXY"); - - /* Initialize i18n */ - Intl.setlocale (LocaleCategory.ALL, ""); - Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.LOCALEDIR); - Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8"); - Intl.textdomain (Config.GETTEXT_PACKAGE); - - /* Set up the accessibility stack, in case the user needs it for screen reading etc. */ - Environment.set_variable ("GTK_MODULES", "atk-bridge", false); - - Pid atspi_pid = 0; - Pid upstart_pid = 0; - - try - { - string[] argv; - - Shell.parse_argv ("/usr/lib/at-spi2-core/at-spi-bus-launcher --launch-immediately", out argv); - Process.spawn_async (null, - argv, - null, - SpawnFlags.SEARCH_PATH, - null, - out atspi_pid); - } - catch (Error e) - { - warning ("Error starting the at-spi registry: %s", e.message); - } - - Gtk.init (ref args); - Ido.init (); - - log_timer = new Timer (); - Log.set_default_handler (log_cb); - - debug ("Starting unity-greeter %s UID=%d LANG=%s", Config.VERSION, (int) Posix.getuid (), Environment.get_variable ("LANG")); - - /* Set the cursor to not be the crap default */ - debug ("Setting cursor"); - Gdk.get_default_root_window ().set_cursor (new Gdk.Cursor (Gdk.CursorType.LEFT_PTR)); - - bool do_show_version = false; - bool do_test_mode = false; - OptionEntry versionOption = { "version", 'v', 0, OptionArg.NONE, ref do_show_version, - /* Help string for command line --version flag */ - N_("Show release version"), null }; - OptionEntry testOption = { "test-mode", 0, 0, OptionArg.NONE, ref do_test_mode, - /* Help string for command line --test-mode flag */ - N_("Run in test mode"), null }; - OptionEntry nullOption = { null }; - OptionEntry[] options = { versionOption, testOption, nullOption }; - - debug ("Loading command line options"); - var c = new OptionContext (/* Arguments and description for --help text */ - _("- Unity Greeter")); - c.add_main_entries (options, Config.GETTEXT_PACKAGE); - c.add_group (Gtk.get_option_group (true)); - try - { - c.parse (ref args); - } - catch (Error e) - { - stderr.printf ("%s\n", e.message); - stderr.printf (/* Text printed out when an unknown command-line argument provided */ - _("Run '%s --help' to see a full list of available command line options."), args[0]); - stderr.printf ("\n"); - return Posix.EXIT_FAILURE; - } - if (do_show_version) - { - /* Note, not translated so can be easily parsed */ - stderr.printf ("unity-greeter %s\n", Config.VERSION); - return Posix.EXIT_SUCCESS; - } - - if (do_test_mode) - debug ("Running in test mode"); - - /* Set GTK+ settings */ - debug ("Setting GTK+ settings"); - var settings = Gtk.Settings.get_default (); - var value = UGSettings.get_string (UGSettings.KEY_THEME_NAME); - if (value != "") - settings.set ("gtk-theme-name", value, null); - value = UGSettings.get_string (UGSettings.KEY_ICON_THEME_NAME); - if (value != "") - settings.set ("gtk-icon-theme-name", value, null); - value = UGSettings.get_string (UGSettings.KEY_FONT_NAME); - if (value != "") - settings.set ("gtk-font-name", value, null); - var double_value = UGSettings.get_double (UGSettings.KEY_XFT_DPI); - if (double_value != 0.0) - settings.set ("gtk-xft-dpi", (int) (1024 * double_value), null); - var boolean_value = UGSettings.get_boolean (UGSettings.KEY_XFT_ANTIALIAS); - settings.set ("gtk-xft-antialias", boolean_value, null); - value = UGSettings.get_string (UGSettings.KEY_XFT_HINTSTYLE); - if (value != "") - settings.set ("gtk-xft-hintstyle", value, null); - value = UGSettings.get_string (UGSettings.KEY_XFT_RGBA); - if (value != "") - settings.set ("gtk-xft-rgba", value, null); - - debug ("Creating Unity Greeter"); - var greeter = new UnityGreeter (do_test_mode); - - debug ("Showing greeter"); - greeter.show (); - - if (!do_test_mode) - { - /* Start the indicator services */ - try - { - string[] argv; - - Shell.parse_argv ("init --user --startup-event indicator-services-start", out argv); - Process.spawn_async (null, - argv, - null, - SpawnFlags.SEARCH_PATH, - null, - out upstart_pid); - } - catch (Error e) - { - warning ("Error starting Upstart for indicators: %s", e.message); - } - - /* Make nm-applet hide items the user does not have permissions to interact with */ - Environment.set_variable ("NM_APPLET_HIDE_POLICY_ITEMS", "1", true); - - try - { - Process.spawn_command_line_async ("nm-applet"); - } - catch (Error e) - { - warning ("Error starting nm-applet: %s", e.message); - } - } - - /* Setup a handler for TERM so we quit cleanly */ - GLib.Unix.signal_add(GLib.ProcessSignal.TERM, () => { - debug("Got a SIGTERM"); - Gtk.main_quit(); - return true; - }); - - debug ("Starting main loop"); - Gtk.main (); - - debug ("Cleaning up"); - - if (upstart_pid != 0) - { - Posix.kill (upstart_pid, Posix.SIGTERM); - int status; - Posix.waitpid (upstart_pid, out status, 0); - if (Process.if_exited (status)) - debug ("Upstart exited with return value %d", Process.exit_status (status)); - else - debug ("Upstart terminated with signal %d", Process.term_sig (status)); - upstart_pid = 0; - } - - if (atspi_pid != 0) - { - Posix.kill (atspi_pid, Posix.SIGKILL); - int status; - Posix.waitpid (atspi_pid, out status, 0); - if (Process.if_exited (status)) - debug ("AT-SPI exited with return value %d", Process.exit_status (status)); - else - debug ("AT-SPI terminated with signal %d", Process.term_sig (status)); - atspi_pid = 0; - } - - debug ("Exiting"); - - return Posix.EXIT_SUCCESS; - } -} - -[DBus (name="org.gnome.SessionManager.EndSessionDialog")] -public class DialogDBusInterface : Object -{ - public signal void open_dialog (uint32 type); - public signal void close_dialog (); - - public void open (uint32 type, uint32 timestamp, uint32 seconds_to_stay_open, ObjectPath[] inhibitor_object_paths) - { - open_dialog (type); - } - - public void close () - { - close_dialog (); - } -} diff --git a/src/user-list.vala b/src/user-list.vala index 2bfbd64..2b1a0da 100644 --- a/src/user-list.vala +++ b/src/user-list.vala @@ -71,7 +71,7 @@ public class UserList : GreeterList { show_hidden_users_ = value; - if (UnityGreeter.singleton.test_mode) + if (ArcticaGreeter.singleton.test_mode) { if (value) add_user ("hidden", "Hidden User", null, false, false, null); @@ -164,8 +164,8 @@ public class UserList : GreeterList connect_to_lightdm (); - if (!UnityGreeter.singleton.test_mode && - UnityGreeter.singleton.show_remote_login_hint ()) + if (!ArcticaGreeter.singleton.test_mode && + ArcticaGreeter.singleton.show_remote_login_hint ()) remote_login_service_watch = Bus.watch_name (BusType.SESSION, "com.canonical.RemoteLogin", BusNameWatcherFlags.AUTO_START, @@ -388,7 +388,7 @@ public class UserList : GreeterList remote_login_service = null; /* provide a fallback manual login option */ - if (UnityGreeter.singleton.hide_users_hint ()) { + if (ArcticaGreeter.singleton.hide_users_hint ()) { add_manual_entry(); set_active_entry ("*other"); } @@ -444,7 +444,7 @@ public class UserList : GreeterList try { var url = url_from_remote_loding_server_list_name (selected_entry.id); - if (UnityGreeter.singleton.test_mode) + if (ArcticaGreeter.singleton.test_mode) { if (password_field.text == "password") { @@ -526,7 +526,7 @@ public class UserList : GreeterList sensitive = false; will_clear = true; greeter_authenticating_user = selected_entry.id; - if (UnityGreeter.singleton.test_mode) + if (ArcticaGreeter.singleton.test_mode) { Gtk.Entry field = current_remote_fields.get ("password") as Gtk.Entry; test_is_authenticated = field.text == "password"; @@ -537,7 +537,7 @@ public class UserList : GreeterList } else { - UnityGreeter.singleton.authenticate_remote (get_lightdm_session (), null); + ArcticaGreeter.singleton.authenticate_remote (get_lightdm_session (), null); remote_login_service.set_last_used_server.begin (currently_browsing_server_url, url_from_remote_loding_server_list_name (selected_entry.id)); } } @@ -571,7 +571,7 @@ public class UserList : GreeterList if (is_supported_remote_session (config_session)) { greeter_authenticating_user = selected_entry.id; - UnityGreeter.singleton.authenticate_remote (config_session, null); + ArcticaGreeter.singleton.authenticate_remote (config_session, null); } } dialog.destroy (); @@ -630,7 +630,7 @@ public class UserList : GreeterList private void entry_selected_cb (string? username) { - UnityGreeter.singleton.set_state ("last-user", username); + ArcticaGreeter.singleton.set_state ("last-user", username); if (selected_entry is UserPromptBox) session = (selected_entry as UserPromptBox).session; else @@ -774,7 +774,7 @@ public class UserList : GreeterList string[] email_domains; try { - if (UnityGreeter.singleton.test_mode) + if (ArcticaGreeter.singleton.test_mode) email_domains = { "canonical.com", "ubuntu.org", "candy.com", "urban.net" }; else yield remote_login_service.get_cached_domains_for_server (url, out email_domains); @@ -885,10 +885,10 @@ public class UserList : GreeterList foreach (var response in responses) { - if (UnityGreeter.singleton.test_mode) + if (ArcticaGreeter.singleton.test_mode) test_respond (response); else - UnityGreeter.singleton.respond (response); + ArcticaGreeter.singleton.respond (response); } } @@ -898,10 +898,10 @@ public class UserList : GreeterList unacknowledged_messages = false; var is_authenticated = false; - if (UnityGreeter.singleton.test_mode) + if (ArcticaGreeter.singleton.test_mode) is_authenticated = test_is_authenticated; else - is_authenticated = UnityGreeter.singleton.is_authenticated(); + is_authenticated = ArcticaGreeter.singleton.is_authenticated(); /* Finish authentication (again) or restart it */ if (is_authenticated) @@ -917,18 +917,18 @@ public class UserList : GreeterList { var session_chooser = new SessionList (background, menubar, session, default_session); session_chooser.session_clicked.connect (session_clicked_cb); - UnityGreeter.singleton.push_list (session_chooser); + ArcticaGreeter.singleton.push_list (session_chooser); } private void session_clicked_cb (string session) { this.session = session; - UnityGreeter.singleton.pop_list (); + ArcticaGreeter.singleton.pop_list (); } private bool should_show_session_badge () { - if (UnityGreeter.singleton.test_mode) + if (ArcticaGreeter.singleton.test_mode) return get_selected_id () != "no-badge"; else return LightDM.get_sessions ().length () > 1; @@ -956,7 +956,7 @@ public class UserList : GreeterList private bool is_supported_remote_session (string session_internal_name) { - if (UnityGreeter.singleton.test_mode) + if (ArcticaGreeter.singleton.test_mode) return session_internal_name == "rdp"; var found = false; @@ -998,13 +998,13 @@ public class UserList : GreeterList private void fill_list () { - if (UnityGreeter.singleton.test_mode) + if (ArcticaGreeter.singleton.test_mode) test_fill_list (); else { - default_session = UnityGreeter.singleton.default_session_hint (); - always_show_manual = UnityGreeter.singleton.show_manual_login_hint (); - if (!UnityGreeter.singleton.hide_users_hint ()) + default_session = ArcticaGreeter.singleton.default_session_hint (); + always_show_manual = ArcticaGreeter.singleton.show_manual_login_hint (); + if (!ArcticaGreeter.singleton.hide_users_hint ()) { var users = LightDM.UserList.get_instance (); users.user_added.connect (user_added_cb); @@ -1014,7 +1014,7 @@ public class UserList : GreeterList user_added_cb (user); } - if (UnityGreeter.singleton.has_guest_account_hint ()) + if (ArcticaGreeter.singleton.has_guest_account_hint ()) { debug ("Adding guest account entry"); offer_guest = true; @@ -1024,9 +1024,9 @@ public class UserList : GreeterList if (!have_entries ()) add_manual_entry (); - var last_user = UnityGreeter.singleton.get_state ("last-user"); - if (UnityGreeter.singleton.select_user_hint () != null) - set_active_entry (UnityGreeter.singleton.select_user_hint ()); + var last_user = ArcticaGreeter.singleton.get_state ("last-user"); + if (ArcticaGreeter.singleton.select_user_hint () != null) + set_active_entry (ArcticaGreeter.singleton.select_user_hint ()); else if (last_user != null) set_active_entry (last_user); } @@ -1065,30 +1065,30 @@ public class UserList : GreeterList { Gtk.Entry field = current_remote_fields.get ("username") as Gtk.Entry; var answer = field != null ? field.text : ""; - UnityGreeter.singleton.respond (answer); + ArcticaGreeter.singleton.respond (answer); } else if (text == "password:") { Gtk.Entry field = current_remote_fields.get ("password") as Gtk.Entry; var answer = field != null ? field.text : ""; - UnityGreeter.singleton.respond (answer); + ArcticaGreeter.singleton.respond (answer); } else if (text == "remote host:") { var answer = url_from_remote_loding_server_list_name (selected_entry.id); - UnityGreeter.singleton.respond (answer); + ArcticaGreeter.singleton.respond (answer); } else if (text == "domain:") { Gtk.Entry field = current_remote_fields.get ("domain") as Gtk.Entry; var answer = field != null ? field.text : ""; - UnityGreeter.singleton.respond (answer); + ArcticaGreeter.singleton.respond (answer); } else if (text == "x2gosession:") { Gtk.Entry field = current_remote_fields.get ("x2gosession") as Gtk.Entry; var answer = field != null ? field.text : ""; - UnityGreeter.singleton.respond (answer); + ArcticaGreeter.singleton.respond (answer); } } else @@ -1161,7 +1161,7 @@ public class UserList : GreeterList { } - if (!UnityGreeter.singleton.hide_users_hint()) + if (!ArcticaGreeter.singleton.hide_users_hint()) while (add_test_entry ()); /* add a manual entry if the list of entries is empty initially */ @@ -1172,12 +1172,12 @@ public class UserList : GreeterList n_test_entries++; } - offer_guest = UnityGreeter.singleton.has_guest_account_hint(); - always_show_manual = UnityGreeter.singleton.show_manual_login_hint(); + offer_guest = ArcticaGreeter.singleton.has_guest_account_hint(); + always_show_manual = ArcticaGreeter.singleton.show_manual_login_hint(); key_press_event.connect (test_key_press_cb); - if (UnityGreeter.singleton.show_remote_login_hint()) + if (ArcticaGreeter.singleton.show_remote_login_hint()) Timeout.add (1000, () => { RemoteServer[] test_server_list = {}; @@ -1199,7 +1199,7 @@ public class UserList : GreeterList return false; }); - var last_user = UnityGreeter.singleton.get_state ("last-user"); + var last_user = ArcticaGreeter.singleton.get_state ("last-user"); if (last_user != null) set_active_entry (last_user); @@ -1587,19 +1587,19 @@ public class UserList : GreeterList authentication_complete_cb (); break; case "info-prompt": - show_message_cb ("Welcome to Unity Greeter", LightDM.MessageType.INFO); + show_message_cb ("Welcome to Arctica Greeter", LightDM.MessageType.INFO); show_prompt_cb ("Password:", LightDM.PromptType.SECRET); break; case "long-info-prompt": - show_message_cb ("Welcome to Unity Greeter\n\nWe like to annoy you with long messages.\nLike this one\n\nThis is the last line of a multiple line message.", LightDM.MessageType.INFO); + show_message_cb ("Welcome to Arctica Greeter\n\nWe like to annoy you with long messages.\nLike this one\n\nThis is the last line of a multiple line message.", LightDM.MessageType.INFO); show_prompt_cb ("Password:", LightDM.PromptType.SECRET); break; case "wide-info-prompt": - show_message_cb ("Welcome to Unity Greeter, the greeteriest greeter that ever did appear in these fine lands", LightDM.MessageType.INFO); + show_message_cb ("Welcome to Arctica Greeter, the greeteriest greeter that ever did appear in these fine lands", LightDM.MessageType.INFO); show_prompt_cb ("Password:", LightDM.PromptType.SECRET); break; case "multi-info-prompt": - show_message_cb ("Welcome to Unity Greeter", LightDM.MessageType.INFO); + show_message_cb ("Welcome to Arctica Greeter", LightDM.MessageType.INFO); show_message_cb ("This is an error", LightDM.MessageType.ERROR); show_message_cb ("You should have seen three messages", LightDM.MessageType.INFO); show_prompt_cb ("Password:", LightDM.PromptType.SECRET); -- cgit v1.2.3