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

« back to all changes in this revision

Viewing changes to gnome-session/gsm-consolekit.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:
31
31
#include <dbus/dbus-glib.h>
32
32
#include <dbus/dbus-glib-lowlevel.h>
33
33
 
34
 
#include "gsm-marshal.h"
 
34
#include "gsm-system.h"
35
35
#include "gsm-consolekit.h"
36
36
 
37
37
#define CK_NAME      "org.freedesktop.ConsoleKit"
43
43
#define CK_SEAT_INTERFACE    "org.freedesktop.ConsoleKit.Seat"
44
44
#define CK_SESSION_INTERFACE "org.freedesktop.ConsoleKit.Session"
45
45
 
 
46
#define GSM_CONSOLEKIT_SESSION_TYPE_LOGIN_WINDOW "LoginWindow"
 
47
 
46
48
#define GSM_CONSOLEKIT_GET_PRIVATE(o)                                   \
47
49
        (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSM_TYPE_CONSOLEKIT, GsmConsolekitPrivate))
48
50
 
51
53
        DBusGConnection *dbus_connection;
52
54
        DBusGProxy      *bus_proxy;
53
55
        DBusGProxy      *ck_proxy;
54
 
        guint32          is_connected : 1;
55
 
};
56
 
 
57
 
enum {
58
 
        PROP_0,
59
 
        PROP_IS_CONNECTED
60
 
};
61
 
 
62
 
enum {
63
 
        REQUEST_COMPLETED = 0,
64
 
        LAST_SIGNAL
65
 
};
66
 
 
67
 
static guint signals[LAST_SIGNAL] = { 0 };
 
56
};
68
57
 
69
58
static void     gsm_consolekit_class_init   (GsmConsolekitClass *klass);
70
59
static void     gsm_consolekit_init         (GsmConsolekit      *ck);
82
71
                                                      const char        *new_owner,
83
72
                                                      GsmConsolekit   *manager);
84
73
 
85
 
G_DEFINE_TYPE (GsmConsolekit, gsm_consolekit, G_TYPE_OBJECT);
86
 
 
87
 
static void
88
 
gsm_consolekit_get_property (GObject    *object,
89
 
                             guint       prop_id,
90
 
                             GValue     *value,
91
 
                             GParamSpec *pspec)
92
 
{
93
 
        GsmConsolekit *manager = GSM_CONSOLEKIT (object);
94
 
 
95
 
        switch (prop_id) {
96
 
        case PROP_IS_CONNECTED:
97
 
                g_value_set_boolean (value,
98
 
                                     manager->priv->is_connected);
99
 
                break;
100
 
 
101
 
        default:
102
 
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
103
 
                                                   prop_id,
104
 
                                                   pspec);
105
 
        }
106
 
}
 
74
static void gsm_consolekit_system_init (GsmSystemInterface *iface);
 
75
 
 
76
G_DEFINE_TYPE_WITH_CODE (GsmConsolekit, gsm_consolekit, G_TYPE_OBJECT,
 
77
                         G_IMPLEMENT_INTERFACE (GSM_TYPE_SYSTEM,
 
78
                                                gsm_consolekit_system_init))
107
79
 
108
80
static void
109
81
gsm_consolekit_class_init (GsmConsolekitClass *manager_class)
110
82
{
111
83
        GObjectClass *object_class;
112
 
        GParamSpec   *param_spec;
113
84
 
114
85
        object_class = G_OBJECT_CLASS (manager_class);
115
86
 
116
87
        object_class->finalize = gsm_consolekit_finalize;
117
 
        object_class->get_property = gsm_consolekit_get_property;
118
 
 
119
 
        param_spec = g_param_spec_boolean ("is-connected",
120
 
                                           "Is connected",
121
 
                                           "Whether the session is connected to ConsoleKit",
122
 
                                           FALSE,
123
 
                                           G_PARAM_READABLE);
124
 
 
125
 
        g_object_class_install_property (object_class, PROP_IS_CONNECTED,
126
 
                                         param_spec);
127
 
 
128
 
        signals [REQUEST_COMPLETED] =
129
 
                g_signal_new ("request-completed",
130
 
                              G_OBJECT_CLASS_TYPE (object_class),
131
 
                              G_SIGNAL_RUN_LAST,
132
 
                              G_STRUCT_OFFSET (GsmConsolekitClass, request_completed),
133
 
                              NULL,
134
 
                              NULL,
135
 
                              g_cclosure_marshal_VOID__POINTER,
136
 
                              G_TYPE_NONE,
137
 
                              1, G_TYPE_POINTER);
138
88
 
139
89
        g_type_class_add_private (manager_class, sizeof (GsmConsolekitPrivate));
140
90
}
232
182
        is_connected = TRUE;
233
183
 
234
184
 out:
235
 
        if (manager->priv->is_connected != is_connected) {
236
 
                manager->priv->is_connected = is_connected;
237
 
                g_object_notify (G_OBJECT (manager), "is-connected");
238
 
        }
239
 
 
240
185
        if (!is_connected) {
241
186
                if (manager->priv->dbus_connection == NULL) {
242
187
                        if (manager->priv->bus_proxy != NULL) {
336
281
        }
337
282
}
338
283
 
339
 
GQuark
340
 
gsm_consolekit_error_quark (void)
341
 
{
342
 
        static GQuark error_quark = 0;
343
 
 
344
 
        if (error_quark == 0) {
345
 
                error_quark = g_quark_from_static_string ("gsm-consolekit-error");
346
 
        }
347
 
 
348
 
        return error_quark;
349
 
}
350
 
 
351
 
GsmConsolekit *
352
 
gsm_consolekit_new (void)
353
 
{
354
 
        GsmConsolekit *manager;
355
 
 
356
 
        manager = g_object_new (GSM_TYPE_CONSOLEKIT, NULL);
357
 
 
358
 
        return manager;
359
 
}
360
 
 
361
284
static void
362
285
emit_restart_complete (GsmConsolekit *manager,
363
286
                       GError        *error)
367
290
        call_error = NULL;
368
291
 
369
292
        if (error != NULL) {
370
 
                call_error = g_error_new_literal (GSM_CONSOLEKIT_ERROR,
371
 
                                                  GSM_CONSOLEKIT_ERROR_RESTARTING,
 
293
                call_error = g_error_new_literal (GSM_SYSTEM_ERROR,
 
294
                                                  GSM_SYSTEM_ERROR_RESTARTING,
372
295
                                                  error->message);
373
296
        }
374
297
 
375
 
        g_signal_emit (G_OBJECT (manager),
376
 
                       signals [REQUEST_COMPLETED],
377
 
                       0, call_error);
 
298
        g_signal_emit_by_name (G_OBJECT (manager),
 
299
                               "request_completed", call_error);
378
300
 
379
301
        if (call_error != NULL) {
380
302
                g_error_free (call_error);
390
312
        call_error = NULL;
391
313
 
392
314
        if (error != NULL) {
393
 
                call_error = g_error_new_literal (GSM_CONSOLEKIT_ERROR,
394
 
                                                  GSM_CONSOLEKIT_ERROR_STOPPING,
 
315
                call_error = g_error_new_literal (GSM_SYSTEM_ERROR,
 
316
                                                  GSM_SYSTEM_ERROR_STOPPING,
395
317
                                                  error->message);
396
318
        }
397
319
 
398
 
        g_signal_emit (G_OBJECT (manager),
399
 
                       signals [REQUEST_COMPLETED],
400
 
                       0, call_error);
 
320
        g_signal_emit_by_name (G_OBJECT (manager),
 
321
                               "request_completed", call_error);
401
322
 
402
323
        if (call_error != NULL) {
403
324
                g_error_free (call_error);
404
325
        }
405
326
}
406
327
 
407
 
void
408
 
gsm_consolekit_attempt_restart (GsmConsolekit *manager)
 
328
static void
 
329
gsm_consolekit_attempt_restart (GsmSystem *system)
409
330
{
 
331
        GsmConsolekit *manager = GSM_CONSOLEKIT (system);
410
332
        gboolean res;
411
333
        GError  *error;
412
334
 
436
358
        }
437
359
}
438
360
 
439
 
void
440
 
gsm_consolekit_attempt_stop (GsmConsolekit *manager)
 
361
static void
 
362
gsm_consolekit_attempt_stop (GsmSystem *system)
441
363
{
 
364
        GsmConsolekit *manager = GSM_CONSOLEKIT (system);
442
365
        gboolean res;
443
366
        GError  *error;
444
367
 
596
519
        return seat_id;
597
520
}
598
521
 
599
 
void
600
 
gsm_consolekit_set_session_idle (GsmConsolekit *manager,
601
 
                                 gboolean       is_idle)
 
522
static void
 
523
gsm_consolekit_set_session_idle (GsmSystem *system,
 
524
                                 gboolean   is_idle)
602
525
{
 
526
        GsmConsolekit *manager = GSM_CONSOLEKIT (system);
603
527
        gboolean        res;
604
528
        GError         *error;
605
529
        char           *session_id;
708
632
        return can_activate;
709
633
}
710
634
 
711
 
gboolean
712
 
gsm_consolekit_can_switch_user (GsmConsolekit *manager)
 
635
static gboolean
 
636
gsm_consolekit_can_switch_user (GsmSystem *system)
713
637
{
 
638
        GsmConsolekit *manager = GSM_CONSOLEKIT (system);
714
639
        GError  *error;
715
640
        char    *seat_id;
716
641
        gboolean ret;
737
662
        return ret;
738
663
}
739
664
 
740
 
gboolean
741
 
gsm_consolekit_can_restart (GsmConsolekit *manager)
 
665
static gboolean
 
666
gsm_consolekit_can_restart (GsmSystem *system)
742
667
{
 
668
        GsmConsolekit *manager = GSM_CONSOLEKIT (system);
743
669
        gboolean res;
744
670
        gboolean can_restart;
745
671
        GError  *error;
771
697
        return can_restart;
772
698
}
773
699
 
774
 
gboolean
775
 
gsm_consolekit_can_stop (GsmConsolekit *manager)
 
700
static gboolean
 
701
gsm_consolekit_can_stop (GsmSystem *system)
776
702
{
 
703
        GsmConsolekit *manager = GSM_CONSOLEKIT (system);
777
704
        gboolean res;
778
705
        gboolean can_stop;
779
706
        GError  *error;
804
731
        return can_stop;
805
732
}
806
733
 
807
 
gchar *
 
734
static gchar *
808
735
gsm_consolekit_get_current_session_type (GsmConsolekit *manager)
809
736
{
810
737
        GError *gerror;
871
798
        return ret;
872
799
}
873
800
 
874
 
 
875
 
GsmConsolekit *
876
 
gsm_get_consolekit (void)
877
 
{
878
 
        static GsmConsolekit *manager = NULL;
879
 
 
880
 
        if (manager == NULL) {
881
 
                manager = gsm_consolekit_new ();
882
 
        }
883
 
 
884
 
        return g_object_ref (manager);
885
 
}
886
 
 
887
 
gboolean
888
 
gsm_consolekit_is_current_session_login (void)
889
 
{
890
 
        GsmConsolekit *consolekit;
 
801
static gboolean
 
802
gsm_consolekit_is_login_session (GsmSystem *system)
 
803
{
 
804
        GsmConsolekit *consolekit = GSM_CONSOLEKIT (system);
891
805
        char *session_type;
892
806
        gboolean ret;
893
807
 
894
 
        consolekit = gsm_get_consolekit ();
895
808
        session_type = gsm_consolekit_get_current_session_type (consolekit);
896
809
 
897
810
        ret = (g_strcmp0 (session_type, GSM_CONSOLEKIT_SESSION_TYPE_LOGIN_WINDOW) == 0);
898
811
 
899
 
        g_object_unref (consolekit);
900
812
        g_free (session_type);
901
813
 
902
814
        return ret;
903
815
}
 
816
 
 
817
static void
 
818
gsm_consolekit_system_init (GsmSystemInterface *iface)
 
819
{
 
820
        iface->can_switch_user = gsm_consolekit_can_switch_user;
 
821
        iface->can_stop = gsm_consolekit_can_stop;
 
822
        iface->can_restart = gsm_consolekit_can_restart;
 
823
        iface->attempt_stop = gsm_consolekit_attempt_stop;
 
824
        iface->attempt_restart = gsm_consolekit_attempt_restart;
 
825
        iface->set_session_idle = gsm_consolekit_set_session_idle;
 
826
        iface->is_login_session = gsm_consolekit_is_login_session;
 
827
}
 
828
 
 
829
GsmConsolekit *
 
830
gsm_consolekit_new (void)
 
831
{
 
832
        GsmConsolekit *manager;
 
833
 
 
834
        manager = g_object_new (GSM_TYPE_CONSOLEKIT, NULL);
 
835
 
 
836
        return manager;
 
837
}