1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2024-11-04 15:41:19 +00:00

manager: Propagate messages from account

Not all portions from the user interface are listening directly to messages from
accounts, so the manager should propagate them to allow the UI to pick them up.

Closes #340
This commit is contained in:
Evangelos Ribeiro Tzaras 2021-12-28 15:32:22 +01:00
parent cc8da717b1
commit 339093876c

View file

@ -27,6 +27,7 @@
#include "config.h" #include "config.h"
#include "calls-account.h"
#include "calls-application.h" #include "calls-application.h"
#include "calls-contacts-provider.h" #include "calls-contacts-provider.h"
#include "calls-manager.h" #include "calls-manager.h"
@ -199,6 +200,36 @@ update_protocols (CallsManager *self)
update_state (self); update_state (self);
} }
/* propagate any message from origins, providers, calls, etc */
static void
on_message (CallsMessageSource *source,
const char *message,
GtkMessageType message_type,
CallsManager *self)
{
g_autofree char *notification = NULL;
g_assert (CALLS_IS_MESSAGE_SOURCE (source));
g_assert (CALLS_IS_MANAGER (self));
/* Prefix the message with the name of the source, if known */
if (CALLS_IS_ACCOUNT (source)) {
notification = g_strdup_printf ("%s: %s",
calls_account_get_address (CALLS_ACCOUNT (source)),
message);
}
if (notification) {
calls_message_source_emit_message (CALLS_MESSAGE_SOURCE (self),
notification,
message_type);
} else {
calls_message_source_emit_message (CALLS_MESSAGE_SOURCE (self),
message,
message_type);
}
}
static void static void
add_call (CallsManager *self, CallsCall *call, CallsOrigin *origin) add_call (CallsManager *self, CallsCall *call, CallsOrigin *origin)
@ -288,6 +319,11 @@ add_origin (CallsManager *self, CallsOrigin *origin)
g_list_store_append (self->origins, origin); g_list_store_append (self->origins, origin);
g_signal_connect (origin,
"message",
G_CALLBACK (on_message),
self);
g_signal_connect_object (origin, g_signal_connect_object (origin,
"notify::country-code", "notify::country-code",
G_CALLBACK (update_country_code_cb), G_CALLBACK (update_country_code_cb),