mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2024-11-15 12:55:36 +00:00
MMPlugin: emit *-removed after removing object
This makes sure that when we use calls_provider_get_origins/calls () in the signal handler it doesn't include the removed origin/call.
This commit is contained in:
parent
389e772069
commit
ed0da2a3ab
2 changed files with 41 additions and 54 deletions
|
@ -112,44 +112,23 @@ dial (CallsOrigin *origin, const gchar *number)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
remove_call (CallsMMOrigin *self,
|
|
||||||
CallsMMCall *call,
|
|
||||||
const gchar *path,
|
|
||||||
const gchar *reason)
|
|
||||||
{
|
|
||||||
g_signal_emit_by_name (CALLS_ORIGIN(self), "call-removed",
|
|
||||||
CALLS_CALL(call), reason);
|
|
||||||
g_hash_table_remove (self->calls, path);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
struct CallsMMRemoveCallsData
|
|
||||||
{
|
|
||||||
CallsOrigin *origin;
|
|
||||||
const gchar *reason;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
remove_calls_cb (const gchar *path,
|
|
||||||
CallsMMCall *call,
|
|
||||||
struct CallsMMRemoveCallsData *data)
|
|
||||||
{
|
|
||||||
g_signal_emit_by_name (data->origin, "call-removed",
|
|
||||||
CALLS_CALL(call), data->reason);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
remove_calls (CallsMMOrigin *self, const gchar *reason)
|
remove_calls (CallsMMOrigin *self, const gchar *reason)
|
||||||
{
|
{
|
||||||
struct CallsMMRemoveCallsData data = { CALLS_ORIGIN (self), reason };
|
GList *paths, *node;
|
||||||
|
gpointer call;
|
||||||
|
|
||||||
g_hash_table_foreach_remove (self->calls,
|
paths = g_hash_table_get_keys (self->calls);
|
||||||
(GHRFunc) remove_calls_cb,
|
|
||||||
&data);
|
for (node = paths; node != NULL; node = node->next)
|
||||||
|
{
|
||||||
|
g_hash_table_steal_extended (self->calls, node->data, NULL, &call);
|
||||||
|
g_signal_emit_by_name (self, "call-removed",
|
||||||
|
CALLS_CALL(call), reason);
|
||||||
|
g_object_unref (call);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_list_free_full (paths, g_free);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -341,13 +320,17 @@ call_deleted_cb (MMModemVoice *voice,
|
||||||
const gchar *path,
|
const gchar *path,
|
||||||
CallsMMOrigin *self)
|
CallsMMOrigin *self)
|
||||||
{
|
{
|
||||||
CallsMMCall *call;
|
gpointer call;
|
||||||
|
gpointer key;
|
||||||
GString *reason;
|
GString *reason;
|
||||||
const gchar *mm_reason;
|
const gchar *mm_reason;
|
||||||
|
|
||||||
g_debug ("Removing call `%s'", path);
|
g_debug ("Removing call `%s'", path);
|
||||||
|
|
||||||
call = g_hash_table_lookup (self->calls, path);
|
g_hash_table_steal_extended (self->calls, path, &key, &call);
|
||||||
|
|
||||||
|
g_free (key);
|
||||||
|
|
||||||
if (!call)
|
if (!call)
|
||||||
{
|
{
|
||||||
g_warning ("Could not find removed call `%s'", path);
|
g_warning ("Could not find removed call `%s'", path);
|
||||||
|
@ -356,14 +339,15 @@ call_deleted_cb (MMModemVoice *voice,
|
||||||
|
|
||||||
reason = g_string_new ("Call removed");
|
reason = g_string_new ("Call removed");
|
||||||
|
|
||||||
mm_reason = calls_mm_call_get_disconnect_reason (call);
|
mm_reason = calls_mm_call_get_disconnect_reason (CALLS_MM_CALL (call));
|
||||||
if (mm_reason)
|
if (mm_reason)
|
||||||
{
|
{
|
||||||
g_string_assign (reason, mm_reason);
|
g_string_assign (reason, mm_reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
remove_call (self, call, path, reason->str);
|
g_signal_emit_by_name (self, "call-removed", call, reason);
|
||||||
|
|
||||||
|
g_object_unref (call);
|
||||||
g_string_free (reason, TRUE);
|
g_string_free (reason, TRUE);
|
||||||
|
|
||||||
g_debug ("Removed call `%s'", path);
|
g_debug ("Removed call `%s'", path);
|
||||||
|
|
|
@ -186,10 +186,12 @@ remove_modem_object (CallsMMProvider *self,
|
||||||
|
|
||||||
g_assert (CALLS_IS_ORIGIN (origin));
|
g_assert (CALLS_IS_ORIGIN (origin));
|
||||||
|
|
||||||
|
g_object_ref (origin);
|
||||||
|
g_hash_table_remove (self->origins, path);
|
||||||
|
|
||||||
g_signal_emit_by_name (CALLS_PROVIDER (self),
|
g_signal_emit_by_name (CALLS_PROVIDER (self),
|
||||||
"origin-removed", CALLS_ORIGIN (origin));
|
"origin-removed", CALLS_ORIGIN (origin));
|
||||||
|
g_object_unref (origin);
|
||||||
g_hash_table_remove (self->origins, path);
|
|
||||||
|
|
||||||
update_status (self);
|
update_status (self);
|
||||||
}
|
}
|
||||||
|
@ -322,23 +324,24 @@ mm_appeared_cb (GDBusConnection *connection,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
remove_origins_cb (const gchar *path,
|
|
||||||
CallsMMOrigin *origin,
|
|
||||||
CallsMMProvider *self)
|
|
||||||
{
|
|
||||||
g_signal_emit_by_name (CALLS_PROVIDER (self),
|
|
||||||
"origin-removed", CALLS_ORIGIN (origin));
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clear_dbus (CallsMMProvider *self)
|
clear_dbus (CallsMMProvider *self)
|
||||||
{
|
{
|
||||||
g_hash_table_foreach_remove (self->origins,
|
GList *paths, *node;
|
||||||
(GHRFunc)remove_origins_cb,
|
gpointer origin;
|
||||||
self);
|
|
||||||
|
paths = g_hash_table_get_keys (self->origins);
|
||||||
|
|
||||||
|
for (node = paths; node != NULL; node = node->next)
|
||||||
|
{
|
||||||
|
g_hash_table_steal_extended (self->origins, node->data, NULL, &origin);
|
||||||
|
g_signal_emit_by_name (CALLS_PROVIDER (self),
|
||||||
|
"origin-removed", CALLS_ORIGIN (origin));
|
||||||
|
g_object_unref (origin);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_list_free_full (paths, g_free);
|
||||||
|
|
||||||
g_clear_object (&self->mm);
|
g_clear_object (&self->mm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue