1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2024-12-14 00:17:35 +00:00

notifier: Switch to CallsUiCallData

This commit is contained in:
Evangelos Ribeiro Tzaras 2022-02-01 06:10:38 +01:00
parent 98b8155fc6
commit 3fa290f5a7

View file

@ -28,6 +28,9 @@
#include "calls-manager.h"
#include "calls-notifier.h"
#include "calls-ui-call-data.h"
#include <cui-call.h>
#include <glib/gi18n.h>
#include <glib-object.h>
@ -42,32 +45,32 @@ struct _CallsNotifier
G_DEFINE_TYPE (CallsNotifier, calls_notifier, G_TYPE_OBJECT);
static void
notify (CallsNotifier *self, CallsCall *call)
notify (CallsNotifier *self, CuiCall *call)
{
GApplication *app = g_application_get_default ();
g_autoptr (GNotification) notification = g_notification_new (_("Missed call"));
g_autoptr (CallsBestMatch) contact = NULL;
g_autofree gchar *msg = NULL;
g_autofree gchar *ref = NULL;
g_autofree gchar *label_callback = NULL;
const char *name;
const char *id;
gboolean got_id;
gboolean got_contact;
#if GLIB_CHECK_VERSION(2,70,0)
g_notification_set_category (notification, "x-gnome.call.unanswered");
#endif
contact = calls_call_get_contact (call);
/* TODO: We need to update the notification when the contact name changes
We would need to resend the notification in this case, as changing the properties
after having called g_application_send_notification() will have no effect.
*/
name = calls_best_match_get_name (contact);
id = calls_call_get_id (call);
name = cui_call_get_display_name (call);
id = cui_call_get_id (call);
got_id = !!id && (g_strcmp0 (id, "") != 0);
got_contact = got_id && (g_strcmp0 (id, name) != 0);
if (calls_best_match_has_individual (contact))
if (got_contact)
/* %s is a name here */
msg = g_strdup_printf (_("Missed call from <b>%s</b>"), name);
else if (got_id)
@ -90,27 +93,25 @@ notify (CallsNotifier *self, CallsCall *call)
static void
state_changed_cb (CallsNotifier *self,
CallsCallState new_state,
CallsCallState old_state,
CallsCall *call)
CuiCallState new_state,
CuiCallState old_state,
CuiCall *call)
{
guint n;
g_return_if_fail (CALLS_IS_NOTIFIER (self));
g_return_if_fail (CALLS_IS_CALL (call));
g_return_if_fail (CUI_IS_CALL (call));
g_return_if_fail (old_state != new_state);
if (old_state == CALLS_CALL_STATE_INCOMING &&
new_state == CALLS_CALL_STATE_DISCONNECTED)
{
if (old_state == CUI_CALL_STATE_INCOMING &&
new_state == CUI_CALL_STATE_DISCONNECTED)
notify (self, call);
}
/* Can use g_list_store_find with newer glib */
n = g_list_model_get_n_items (G_LIST_MODEL (self->unanswered));
for (int i = 0; i < n; i++)
{
g_autoptr (CallsCall) item = g_list_model_get_item (G_LIST_MODEL (self->unanswered), i);
g_autoptr (CuiCall) item = g_list_model_get_item (G_LIST_MODEL (self->unanswered), i);
if (item == call)
{
g_list_store_remove (self->unanswered, i);
@ -120,7 +121,7 @@ state_changed_cb (CallsNotifier *self,
}
static void
call_added_cb (CallsNotifier *self, CallsCall *call)
call_added_cb (CallsNotifier *self, CuiCall *call)
{
g_list_store_append(self->unanswered, call);
@ -134,7 +135,7 @@ call_added_cb (CallsNotifier *self, CallsCall *call)
static void
calls_notifier_init (CallsNotifier *self)
{
self->unanswered = g_list_store_new (CALLS_TYPE_CALL);
self->unanswered = g_list_store_new (CUI_TYPE_CALL);
}
@ -146,7 +147,7 @@ calls_notifier_constructed (GObject *object)
CallsNotifier *self = CALLS_NOTIFIER (object);
g_signal_connect_swapped (calls_manager_get_default (),
"call-add",
"ui-call-added",
G_CALLBACK (call_added_cb),
self);