summaryrefslogtreecommitdiff
path: root/src/gypsy-server.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gypsy-server.c')
-rw-r--r--src/gypsy-server.c61
1 files changed, 35 insertions, 26 deletions
diff --git a/src/gypsy-server.c b/src/gypsy-server.c
index b843114..7b99eef 100644
--- a/src/gypsy-server.c
+++ b/src/gypsy-server.c
@@ -8,6 +8,21 @@
* Author: Iain Holmes <iain@gnome.org>
* Copyright (C) 2007 Iain Holmes
* Copyright (C) 2007 Openedhand, Ltd
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * 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, write to the Free Software Foundation, Inc., 59 Temple
+ * Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
*/
/*
@@ -42,7 +57,7 @@ static guint32 signals[LAST_SIGNAL] = {0, };
G_DEFINE_TYPE (GypsyServer, gypsy_server, G_TYPE_OBJECT);
#define GYPSY_GPS_PATH "/org/freedesktop/Gypsy/"
-#define TERMINATE_TIMEOUT 30000 /* 30 second timeout */
+#define TERMINATE_TIMEOUT 10000 /* 10 second timeout */
static void gypsy_server_create (GypsyServer *gps,
const char *IN_device_path,
@@ -66,7 +81,6 @@ gypsy_server_error_quark (void)
/* We don't want to terminate at the moment, as there is no way to be
restarted until D-Bus 1.2 which has the System bus activation stuff
*/
-#if 0
static gboolean
gypsy_terminate (gpointer data)
{
@@ -76,7 +90,6 @@ gypsy_terminate (gpointer data)
return FALSE;
}
-#endif
/* IN_args contains that path to the GPS device we wish to open */
static void
@@ -151,7 +164,6 @@ gypsy_server_shutdown (GypsyServer *gps,
device_name = g_path_get_basename (IN_device_path);
g_debug ("Device name: %s", device_name);
path = g_strdup_printf ("%s%s", GYPSY_GPS_PATH, device_name);
- g_free (device_name);
client = (GypsyClient *) dbus_g_connection_lookup_g_object (priv->connection, path);
g_free (path);
@@ -162,31 +174,30 @@ gypsy_server_shutdown (GypsyServer *gps,
GYPSY_SERVER_ERROR_NO_CLIENT,
"No such client: %s",
device_name));
- }
-
- g_object_unref (client);
+ } else {
+ if (--priv->client_count == 0) {
+ if (priv->terminate_id == 0) {
+ priv->terminate_id = g_timeout_add (TERMINATE_TIMEOUT,
+ gypsy_terminate,
+ gps);
+ }
+ }
- if (--priv->client_count == 0) {
-#if 0
- if (priv->terminate_id == 0) {
- priv->terminate_id = g_timeout_add (TERMINATE_TIMEOUT,
- gypsy_terminate,
- gps);
+ /* Update the hash of open connnctions */
+ sender = dbus_g_method_get_sender (context);
+ list = g_hash_table_lookup (priv->connections, sender);
+ owner = g_list_find (list, client);
+ if (owner) {
+ g_object_unref (owner->data);
}
-#endif
- }
+ list = g_list_remove (list, client);
+ g_hash_table_insert (priv->connections, sender, list);
+
+ dbus_g_method_return (context);
- /* Update the hash of open connnctions */
- sender = dbus_g_method_get_sender (context);
- list = g_hash_table_lookup (priv->connections, sender);
- owner = g_list_find (list, client);
- if (owner) {
- g_object_unref (owner->data);
}
- list = g_list_remove (list, client);
- g_hash_table_insert (priv->connections, sender, list);
- dbus_g_method_return (context);
+ g_free (device_name);
}
static void
@@ -271,14 +282,12 @@ gypsy_server_remove_clients (GypsyServer *gps,
for (l = list; l; l = l->next) {
g_object_unref (l->data);
if (--priv->client_count == 0) {
-#if 0
if (priv->terminate_id == 0) {
priv->terminate_id =
g_timeout_add (TERMINATE_TIMEOUT,
gypsy_terminate,
gps);
}
-#endif
}
}
g_list_free (list);