-static void add_reference(GcIfaceGeoclue * gc, DBusGMethodInvocation * context)
-{
- GeoclueGpsManager *gpsmanager = (GEOCLUE_GPSMANAGER(gc));
- char *sender;
- int *pcount;
-
- sender = dbus_g_method_get_sender(context);
- if (g_hash_table_size(gpsmanager->connections) == 0) {
- start_tracking(gpsmanager);
- }
- pcount = g_hash_table_lookup(gpsmanager->connections, sender);
- if (!pcount) {
- pcount = g_malloc0(sizeof(int));
- g_hash_table_insert(gpsmanager->connections, sender, pcount);
- }
- (*pcount)++;
-
- g_debug("add_reference (%s) (%d)", sender, (*pcount));
-
- dbus_g_method_return(context);
-}
-
-static gboolean remove_client(GeoclueGpsManager * gpsmanager, const char *client)
-{
- int *pcount;
-
- pcount = g_hash_table_lookup(gpsmanager->connections, client);
- if (!pcount) {
- return FALSE;
- }
- (*pcount)--;
- if (*pcount == 0) {
- g_hash_table_remove(gpsmanager->connections, client);
- }
- if (g_hash_table_size(gpsmanager->connections) == 0) {
- g_debug("There is no connections!");
- stop_tracking(gpsmanager);
- }
- return TRUE;
-}
-
-static gboolean remove_all_clients(GeoclueGpsManager * gpsmanager, const char *client)
-{
- int *pcount;
-
- pcount = g_hash_table_lookup(gpsmanager->connections, client);
- if (!pcount) {
- return FALSE;
- }
- g_hash_table_remove(gpsmanager->connections, client);
- if (g_hash_table_size(gpsmanager->connections) == 0) {
- g_debug("There is no connections!");
- stop_tracking(gpsmanager);
- }
- return TRUE;
-}
-
-static void remove_reference(GcIfaceGeoclue * gc, DBusGMethodInvocation * context)
-{
- GeoclueGpsManager *gpsmanager = (GEOCLUE_GPSMANAGER(gc));
- char *sender;
-
- sender = dbus_g_method_get_sender(context);
- if (!remove_client(gpsmanager, sender)) {
- g_warning("Unreffed by client taht has not been referenced");
- }
-
- g_free(sender);
-
- dbus_g_method_return(context);
-}
-
-static void name_owner_changed(DBusGProxy * proxy, const char *name, const char *prev_owner, const char *new_owner, void *gc)
-{
- GeoclueGpsManager *gpsmanager = (GEOCLUE_GPSMANAGER(gc));
- g_debug("name_owner_changed, name:%s, prev_owner:%s, new_owner:%s", name, prev_owner, new_owner);
- if (strcmp(new_owner, "") == 0 && strcmp(name, prev_owner) == 0) {
- if (remove_all_clients(gpsmanager, prev_owner)) {
- g_warning("Impolite client %s disconnected without unreferencing\n", prev_owner);
- }
- }
-}
-