* Copyright 2001, 2002 Ximian, Inc.
*
* This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
+ * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
*
* This library 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
- * Library General Public License for more details.
+ * Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Library General Public
+ * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
#include <stdlib.h>
{NULL}
};
-static GDBusConnection *bus_connection = NULL;
static GDBusProxy *sm_proxy = NULL;
static char *client_id = NULL;
static GDBusProxy *client_proxy = NULL;
#define SM_CLIENT_DBUS_INTERFACE "org.gnome.SessionManager.ClientPrivate"
-static void registry_session_init (const char *previous_client_id, const char *exe);
+static gboolean register_client (void);
static void
-on_session_over (GDBusProxy *proxy,
- gchar *sender_name,
- gchar *signal_name,
- GVariant *parameters,
- gpointer user_data)
+on_session_signal (GDBusProxy *proxy,
+ gchar *sender_name,
+ gchar *signal_name,
+ GVariant *parameters,
+ gpointer user_data)
{
if (g_strcmp0 (signal_name, "SessionOver") == 0) {
g_main_loop_quit (mainloop);
+ } else if (g_strcmp0 (signal_name, "SessionRunning") == 0) {
+ if (!register_client ())
+ g_warning ("Unable to register client with session manager");
}
}
static gboolean
session_manager_connect (void)
{
+ GVariant *res;
+ gboolean is_running;
sm_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, 0, NULL,
SM_DBUS_NAME,
SM_DBUS_PATH,
SM_DBUS_INTERFACE, NULL, NULL);
+ res = g_dbus_proxy_call_sync (sm_proxy,
+ "IsSessionRunning", NULL,
+ 0, 1000, NULL, NULL);
+
+ if (res) {
+ g_variant_get (res, "(b)", &is_running);
+ g_variant_unref (res);
+ if (is_running) {
+ if (!register_client ())
+ g_warning ("Unable to register client with session manager");
+ }
+ }
+
g_signal_connect (G_OBJECT (sm_proxy), "g-signal",
- G_CALLBACK (on_session_over), NULL);
+ G_CALLBACK (on_session_signal), NULL);
return (sm_proxy != NULL);
}
-static void
-stop_cb (gpointer data)
-{
- g_main_loop_quit (mainloop);
-}
-
static gboolean
end_session_response (gboolean is_okay, const gchar *reason)
{
- GVariant *ret;
+ GVariant *ret;
GError *error = NULL;
if (!reason)
register_client (void)
{
GError *error;
- GVariant *res;
+ GVariant *res;
const char *startup_id;
const char *app_id;
+ if (client_proxy)
+ return TRUE;
+
startup_id = g_getenv ("DESKTOP_AUTOSTART_ID");
if (!startup_id)
startup_id = "";
{
if (!session_manager_connect ())
g_warning ("Unable to connect to session manager");
-
- if (!register_client ())
- g_warning ("Unable to register client with session manager");
}
g_main_loop_run (mainloop);