~ubuntu-branches/ubuntu/raring/gnome-session/raring

« back to all changes in this revision

Viewing changes to .pc/12_no_gdm_fallback.patch/gnome-session/gsm-manager.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2012-05-07 11:22:35 UTC
  • mfrom: (1.1.75) (2.2.14 sid)
  • Revision ID: package-import@ubuntu.com-20120507112235-z9pe25ur5d8zt4c6
Tags: 3.4.1-1ubuntu1
* Merge with Debian. Remaining changes:
 - debian/control.in:
   + gnome-session
     - Recommend nautilus and either unity, unity-2d or gnome-shell
     - Only suggest gnome-session-fallback (we don't want it to be installed
       by default)
     - Drop the Recommends on gnome-power-manager, the code gnome-session uses
       has moved to gnome-settings-daemon
   + gnome-session-fallback
     - Recommend cups-pk-helper for gnome-session-fallback so that
       System Settings>Printers works
 - debian/gnome-session-bin.postinst, debian/gnome-session-bin.prerm:
    Moved registering gnome-session binary as a session manager to 
    gnome-session-bin package
 - debian/postinst, postrm:
    set the default lightdm session as ubuntu if none already set
 - don't install defaults.list (installed by desktop-file-utils in ubuntu):
    debian/gnome-session-common.dirs and gnome-session-common.install
 - add debian/gnome-session-common.gsettings-override:
   set ubuntu as the default session if nothing is provided
 - debian/55gnome-session_gnomerc:
    Use POSIX string substitutions (shell internal) instead of external
    basename and cut for startup speed.
 - debian/patches/20_hide_nodisplay.patch:
    Don't show applications in the Sessions properties dialog that have
    NoDisplay=true.
 - debian/patches/21_up_start_on_demand.patch:
    Don't call dkp_client_new() until actually needed. This blocks
    for some time whilst DK-Power is started, if it wasn't running already
    (which is the case during auto-login). This can delay the whole
    session from starting.
 - debian/patches/22_support_autostart_delay.patch:
    Bugzilla patch to support adding a delay to autostart apps, using
    a "X-GNOME-Autostart-Delay" key in the desktop file
 - debian/patches/50_ubuntu_sessions.patch:
    + Add Ubuntu & Ubuntu 2D sessions
    + Add GNOME Classic (Without Effects session). Use notify-osd for
      notifications, but don't add it to RequiredComponents since notify-osd
      doesn't have an autostart .desktop file
    + gnome-shell.desktop adds --session=gnome now that the "ubuntu" session
      is the default. Use TryExec to test if gnome-shell is installed.
 - debian/patches/51_remove_session_saving_from_gui.patch:
    add GNOME_SESSION_SAVE environment variable for people wanting to
    use the save session still, knowing that it can break your system
    if used unwisely (LP: #771896)
 - debian/patches/52_xdg_current_desktop.patch:
    Set XDG_CURRENT_DESKTOP inside gnome-session based on a
    new key 'DesktopName' in gnome-session .desktop files.
 - debian/patches/80_new_upstream_session_dialog.patch:
    Bugzilla patch to change the session dialog. (Deactivated, see bug 807503)
 - debian/patches/95_dbus_request_shutdown.patch:
    Add "RequestShutdown" and "RequestReboot" DBus methods to allow other
    applications to shutdown or reboot the machine via the session manager.
 - debian/patches/96_no_catch_sigsegv.patch:
    Don't register a handler for SIGSEGV. We want Apport to catch these
    crashes so that users can submit useful crash reports.
 - debian/patches/101_screen_lock_on_suspend.patch:
    Use the same logic as gnome-power-manager for deciding the "screen
    lock on suspend" policy. This restores the Jaunty behaviour rather
    than just using the screensaver settings, which is surprising for
    users.
    This patch is deactivated for now, we'll see with the new screensaver and
    screen locking experience what to do (not rebased on gsettings as well)
  - debian/patches/103_kill_the_fail_whale.patch:
    seems that the fail whale try to come back and resist from his removal
    refreshed the patch to ensure it's killed and won't come back ever ever
    again.
  - 104_dont_show_fallback_warning.patch:
    Disable GNOME Fallback warning. It doesn't really explain anything
    and assumes that there aren't people that want to run Fallback.
  - debian/patches/105_hide_session_startup_help.patch:
    Hide Help button on Startup Applications dialog, as it is broken
    and the help documentation hasn't been written for 3.x yet.

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
#include "gsm-fail-whale-dialog.h"
62
62
#include "gsm-icon-names.h"
63
63
#include "gsm-inhibit-dialog.h"
64
 
#include "gsm-consolekit.h"
 
64
#include "gsm-system.h"
65
65
#include "gsm-session-save.h"
 
66
#include "gsm-shell-extensions.h"
66
67
 
67
68
#define GSM_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSM_TYPE_MANAGER, GsmManagerPrivate))
68
69
 
274
275
                         GsmApp      *app)
275
276
{
276
277
        const gchar *app_id;
277
 
        gboolean want_extensions_ui;
278
278
        gboolean allow_logout;
 
279
        GsmSystem *system;
 
280
        GsmShellExtensions *extensions;
279
281
 
280
282
        app_id = gsm_app_peek_app_id (app);
281
 
        want_extensions_ui = g_str_equal (app_id, "gnome-shell.desktop");
282
 
 
283
 
        if (gsm_consolekit_is_current_session_login ()) {
 
283
 
 
284
        if (g_str_equal (app_id, "gnome-shell.desktop")) {
 
285
                extensions = g_object_new (GSM_TYPE_SHELL_EXTENSIONS, NULL);
 
286
                gsm_shell_extensions_disable_all (extensions);
 
287
        } else {
 
288
                extensions = NULL;
 
289
        }
 
290
 
 
291
        system = gsm_get_system ();
 
292
        if (gsm_system_is_login_session (system)) {
284
293
                allow_logout = FALSE;
285
294
        } else {
286
295
                allow_logout = !_log_out_is_locked_down (manager);
287
296
        }
 
297
        g_object_unref (system);
288
298
 
289
299
        gsm_fail_whale_dialog_we_failed (FALSE,
290
300
                                         allow_logout,
291
 
                                         want_extensions_ui);
 
301
                                         extensions);
292
302
}
293
303
 
294
304
static gboolean
342
352
}
343
353
 
344
354
static gboolean
345
 
_find_by_startup_id (const char *id,
346
 
                     GsmClient  *client,
347
 
                     const char *startup_id_a)
 
355
_client_has_startup_id (const char *id,
 
356
                        GsmClient  *client,
 
357
                        const char *startup_id_a)
348
358
{
349
359
        const char *startup_id_b;
350
360
 
368
378
                 condition);
369
379
 
370
380
        client = (GsmClient *)gsm_store_find (manager->priv->clients,
371
 
                                              (GsmStoreFunc)_find_by_startup_id,
 
381
                                              (GsmStoreFunc)_client_has_startup_id,
372
382
                                              (char *)gsm_app_peek_startup_id (app));
373
383
 
374
384
        if (condition) {
459
469
static void start_phase (GsmManager *manager);
460
470
 
461
471
static void
462
 
quit_request_completed (GsmConsolekit *consolekit,
463
 
                        GError        *error,
464
 
                        gpointer       user_data)
 
472
quit_request_completed (GsmSystem *system,
 
473
                        GError    *error,
 
474
                        gpointer   user_data)
465
475
{
466
476
        GdmLogoutAction fallback_action = GPOINTER_TO_INT (user_data);
467
477
 
469
479
                gdm_set_logout_action (fallback_action);
470
480
        }
471
481
 
472
 
        g_object_unref (consolekit);
 
482
        g_object_unref (system);
473
483
 
474
484
        gtk_main_quit ();
475
485
}
477
487
static void
478
488
gsm_manager_quit (GsmManager *manager)
479
489
{
480
 
        GsmConsolekit *consolekit;
 
490
        GsmSystem *system;
481
491
 
482
492
        /* See the comment in request_reboot() for some more details about how
483
493
         * this works. */
490
500
        case GSM_MANAGER_LOGOUT_REBOOT_INTERACT:
491
501
                gdm_set_logout_action (GDM_LOGOUT_ACTION_NONE);
492
502
 
493
 
                consolekit = gsm_get_consolekit ();
494
 
                g_signal_connect (consolekit,
 
503
                system = gsm_get_system ();
 
504
                g_signal_connect (system,
495
505
                                  "request-completed",
496
506
                                  G_CALLBACK (quit_request_completed),
497
507
                                  GINT_TO_POINTER (GDM_LOGOUT_ACTION_REBOOT));
498
 
                gsm_consolekit_attempt_restart (consolekit);
 
508
                gsm_system_attempt_restart (system);
499
509
                break;
500
510
        case GSM_MANAGER_LOGOUT_REBOOT_GDM:
501
511
                gdm_set_logout_action (GDM_LOGOUT_ACTION_REBOOT);
505
515
        case GSM_MANAGER_LOGOUT_SHUTDOWN_INTERACT:
506
516
                gdm_set_logout_action (GDM_LOGOUT_ACTION_NONE);
507
517
 
508
 
                consolekit = gsm_get_consolekit ();
509
 
                g_signal_connect (consolekit,
 
518
                system = gsm_get_system ();
 
519
                g_signal_connect (system,
510
520
                                  "request-completed",
511
521
                                  G_CALLBACK (quit_request_completed),
512
522
                                  GINT_TO_POINTER (GDM_LOGOUT_ACTION_SHUTDOWN));
513
 
                gsm_consolekit_attempt_stop (consolekit);
 
523
                gsm_system_attempt_stop (system);
514
524
                break;
515
525
        case GSM_MANAGER_LOGOUT_SHUTDOWN_GDM:
516
526
                gdm_set_logout_action (GDM_LOGOUT_ACTION_SHUTDOWN);
583
593
}
584
594
 
585
595
static void
 
596
app_event_during_startup (GsmManager *manager,
 
597
                          GsmApp     *app)
 
598
{
 
599
        if (!(manager->priv->phase < GSM_MANAGER_PHASE_APPLICATION))
 
600
                return;
 
601
 
 
602
        manager->priv->pending_apps = g_slist_remove (manager->priv->pending_apps, app);
 
603
 
 
604
        if (manager->priv->pending_apps == NULL) {
 
605
                if (manager->priv->phase_timeout_id > 0) {
 
606
                        g_source_remove (manager->priv->phase_timeout_id);
 
607
                        manager->priv->phase_timeout_id = 0;
 
608
                }
 
609
 
 
610
                end_phase (manager);
 
611
        }
 
612
}
 
613
 
 
614
static void
 
615
_restart_app (GsmManager *manager,
 
616
              GsmApp     *app)
 
617
{
 
618
        GError *error = NULL;
 
619
 
 
620
        if (!gsm_app_restart (app, &error)) {
 
621
                if (is_app_required (manager, app)) {
 
622
                        on_required_app_failure (manager, app);
 
623
                } else {
 
624
                        g_warning ("Error on restarting session managed app: %s", error->message);
 
625
                }
 
626
                g_clear_error (&error);
 
627
 
 
628
                app_event_during_startup (manager, app);
 
629
        }
 
630
}
 
631
 
 
632
static void
586
633
app_died (GsmApp     *app,
 
634
          int         signal,
587
635
          GsmManager *manager)
588
636
{
589
 
        GError *error = NULL;
590
 
 
591
 
        manager->priv->pending_apps = g_slist_remove (manager->priv->pending_apps, app);
592
 
        g_signal_handlers_disconnect_by_func (app, app_registered, manager);
593
 
 
594
 
        g_warning ("Application '%s' killed by signal", gsm_app_peek_app_id (app));
 
637
        g_warning ("Application '%s' killed by signal %d", gsm_app_peek_app_id (app), signal);
595
638
 
596
639
        if (gsm_app_peek_autorestart (app)) {
597
640
                g_debug ("Component '%s' is autorestart, ignoring died signal",
599
642
                return;
600
643
        }
601
644
 
602
 
        if (!gsm_app_restart (app, &error)) {
603
 
                if (is_app_required (manager, app)) {
604
 
                        on_required_app_failure (manager, app);
605
 
                } else {
606
 
                        g_warning ("Error on restarting session managed app: %s", error->message);
607
 
                }
608
 
                g_clear_error (&error);
609
 
        }
 
645
        _restart_app (manager, app);
610
646
 
611
647
        /* For now, we don't do anything with crashes from
612
648
         * non-required apps after they hit the restart limit.
619
655
}
620
656
 
621
657
static void
 
658
app_exited (GsmApp     *app,
 
659
            guchar      exit_code,
 
660
            GsmManager *manager)
 
661
{
 
662
        g_debug ("App %s exited with %d", gsm_app_peek_app_id (app), exit_code);
 
663
 
 
664
        app_event_during_startup (manager, app);
 
665
}
 
666
 
 
667
static void
622
668
app_registered (GsmApp     *app,
623
669
                GsmManager *manager)
624
670
{
625
671
        g_debug ("App %s registered", gsm_app_peek_app_id (app));
626
672
 
627
 
        manager->priv->pending_apps = g_slist_remove (manager->priv->pending_apps, app);
628
 
        g_signal_handlers_disconnect_by_func (app, app_registered, manager);
629
 
 
630
 
        if (manager->priv->pending_apps == NULL) {
631
 
                if (manager->priv->phase_timeout_id > 0) {
632
 
                        g_source_remove (manager->priv->phase_timeout_id);
633
 
                        manager->priv->phase_timeout_id = 0;
634
 
                }
635
 
 
636
 
                end_phase (manager);
637
 
        }
 
673
        app_event_during_startup (manager, app);
638
674
}
639
675
 
640
676
static gboolean
664
700
                        GsmApp *app = a->data;
665
701
                        g_warning ("Application '%s' failed to register before timeout",
666
702
                                   gsm_app_peek_app_id (app));
667
 
                        g_signal_handlers_disconnect_by_func (app, app_registered, manager);
668
703
                        if (is_app_required (manager, app))
669
704
                                on_required_app_failure (manager, app);
670
705
                }
726
761
                 */
727
762
                g_signal_connect (app,
728
763
                                  "exited",
729
 
                                  G_CALLBACK (app_registered),
 
764
                                  G_CALLBACK (app_exited),
730
765
                                  manager);
731
766
                g_signal_connect (app,
732
767
                                  "registered",
1759
1794
{
1760
1795
        gboolean              is_condition_client;
1761
1796
        GsmApp               *app;
1762
 
        GError               *error;
1763
 
        gboolean              res;
1764
1797
        const char           *app_id;
1765
1798
        const char           *startup_id;
1766
1799
        gboolean              app_restart;
1853
1886
 
1854
1887
        g_debug ("GsmManager: restarting app");
1855
1888
 
1856
 
        error = NULL;
1857
 
        res = gsm_app_restart (app, &error);
1858
 
        if (! res) {
1859
 
                if (is_app_required (manager, app)) {
1860
 
                        on_required_app_failure (manager, app);
1861
 
                } else {
1862
 
                        g_warning ("Error on restarting session managed app: %s", error->message);
1863
 
                }
1864
 
                g_clear_error (&error);
1865
 
        }
 
1889
        _restart_app (manager, app);
1866
1890
 
1867
1891
 out:
1868
1892
        g_object_unref (client);
1961
1985
remove_inhibitors_for_connection (GsmManager *manager,
1962
1986
                                  const char *service_name)
1963
1987
{
1964
 
        guint            n_removed;
1965
1988
        RemoveClientData data;
1966
1989
 
1967
1990
        data.service_name = service_name;
1969
1992
 
1970
1993
        debug_inhibitors (manager);
1971
1994
 
1972
 
        n_removed = gsm_store_foreach_remove (manager->priv->inhibitors,
1973
 
                                              (GsmStoreFunc)inhibitor_has_bus_name,
1974
 
                                              &data);
 
1995
        gsm_store_foreach_remove (manager->priv->inhibitors,
 
1996
                                  (GsmStoreFunc)inhibitor_has_bus_name,
 
1997
                                  &data);
1975
1998
}
1976
1999
 
1977
2000
static void
2076
2099
        return manager->priv->failsafe;
2077
2100
}
2078
2101
 
2079
 
static gboolean
2080
 
_client_has_startup_id (const char *id,
2081
 
                        GsmClient  *client,
2082
 
                        const char *startup_id_a)
2083
 
{
2084
 
        const char *startup_id_b;
2085
 
 
2086
 
        startup_id_b = gsm_client_peek_startup_id (client);
2087
 
 
2088
 
        if (IS_STRING_EMPTY (startup_id_b)) {
2089
 
                return FALSE;
2090
 
        }
2091
 
 
2092
 
        return (strcmp (startup_id_a, startup_id_b) == 0);
2093
 
}
2094
 
 
2095
2102
static void
2096
2103
on_client_disconnected (GsmClient  *client,
2097
2104
                        GsmManager *manager)
2178
2185
static void
2179
2186
maybe_save_session (GsmManager *manager)
2180
2187
{
 
2188
        GsmSystem *system;
2181
2189
        GError *error;
 
2190
        gboolean is_login;
2182
2191
 
2183
 
        if (gsm_consolekit_is_current_session_login ())
 
2192
        system = gsm_get_system ();
 
2193
        is_login = gsm_system_is_login_session (system);
 
2194
        g_object_unref (system);
 
2195
        if (is_login)
2184
2196
                return;
2185
2197
 
2186
2198
        /* We only allow session saving when session is running or when
2722
2734
                            guint         status,
2723
2735
                            GsmManager   *manager)
2724
2736
{
2725
 
        GsmConsolekit *consolekit;
 
2737
        GsmSystem *system;
2726
2738
 
2727
 
        consolekit = gsm_get_consolekit ();
2728
 
        gsm_consolekit_set_session_idle (consolekit,
2729
 
                                         (status == GSM_PRESENCE_STATUS_IDLE));
 
2739
        system = gsm_get_system ();
 
2740
        gsm_system_set_session_idle (system,
 
2741
                                     (status == GSM_PRESENCE_STATUS_IDLE));
 
2742
        g_object_unref (system);
2730
2743
}
2731
2744
 
2732
2745
static gboolean
3380
3393
                          gboolean   *shutdown_available,
3381
3394
                          GError    **error)
3382
3395
{
3383
 
        GsmConsolekit *consolekit;
 
3396
        GsmSystem *system;
3384
3397
        gboolean can_suspend;
3385
3398
        gboolean can_hibernate;
3386
3399
 
3393
3406
 
3394
3407
        g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE);
3395
3408
 
3396
 
        consolekit = gsm_get_consolekit ();
 
3409
        system = gsm_get_system ();
3397
3410
        *shutdown_available = !_log_out_is_locked_down (manager) &&
3398
 
                              (gsm_consolekit_can_stop (consolekit)
3399
 
                               || gsm_consolekit_can_restart (consolekit)
 
3411
                              (gsm_system_can_stop (system)
 
3412
                               || gsm_system_can_restart (system)
3400
3413
                               || can_suspend
3401
3414
                               || can_hibernate);
3402
 
        g_object_unref (consolekit);
 
3415
        g_object_unref (system);
3403
3416
 
3404
3417
        return TRUE;
3405
3418
}