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:
parent
98b8155fc6
commit
3fa290f5a7
1 changed files with 21 additions and 20 deletions
|
@ -28,6 +28,9 @@
|
||||||
|
|
||||||
#include "calls-manager.h"
|
#include "calls-manager.h"
|
||||||
#include "calls-notifier.h"
|
#include "calls-notifier.h"
|
||||||
|
#include "calls-ui-call-data.h"
|
||||||
|
|
||||||
|
#include <cui-call.h>
|
||||||
|
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
|
@ -42,32 +45,32 @@ struct _CallsNotifier
|
||||||
G_DEFINE_TYPE (CallsNotifier, calls_notifier, G_TYPE_OBJECT);
|
G_DEFINE_TYPE (CallsNotifier, calls_notifier, G_TYPE_OBJECT);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
notify (CallsNotifier *self, CallsCall *call)
|
notify (CallsNotifier *self, CuiCall *call)
|
||||||
{
|
{
|
||||||
GApplication *app = g_application_get_default ();
|
GApplication *app = g_application_get_default ();
|
||||||
g_autoptr (GNotification) notification = g_notification_new (_("Missed call"));
|
g_autoptr (GNotification) notification = g_notification_new (_("Missed call"));
|
||||||
g_autoptr (CallsBestMatch) contact = NULL;
|
|
||||||
g_autofree gchar *msg = NULL;
|
g_autofree gchar *msg = NULL;
|
||||||
g_autofree gchar *ref = NULL;
|
g_autofree gchar *ref = NULL;
|
||||||
g_autofree gchar *label_callback = NULL;
|
g_autofree gchar *label_callback = NULL;
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *id;
|
const char *id;
|
||||||
gboolean got_id;
|
gboolean got_id;
|
||||||
|
gboolean got_contact;
|
||||||
|
|
||||||
#if GLIB_CHECK_VERSION(2,70,0)
|
#if GLIB_CHECK_VERSION(2,70,0)
|
||||||
g_notification_set_category (notification, "x-gnome.call.unanswered");
|
g_notification_set_category (notification, "x-gnome.call.unanswered");
|
||||||
#endif
|
#endif
|
||||||
contact = calls_call_get_contact (call);
|
|
||||||
/* TODO: We need to update the notification when the contact name changes
|
/* 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
|
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.
|
after having called g_application_send_notification() will have no effect.
|
||||||
*/
|
*/
|
||||||
name = calls_best_match_get_name (contact);
|
name = cui_call_get_display_name (call);
|
||||||
id = calls_call_get_id (call);
|
id = cui_call_get_id (call);
|
||||||
|
|
||||||
got_id = !!id && (g_strcmp0 (id, "") != 0);
|
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 */
|
/* %s is a name here */
|
||||||
msg = g_strdup_printf (_("Missed call from <b>%s</b>"), name);
|
msg = g_strdup_printf (_("Missed call from <b>%s</b>"), name);
|
||||||
else if (got_id)
|
else if (got_id)
|
||||||
|
@ -90,27 +93,25 @@ notify (CallsNotifier *self, CallsCall *call)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
state_changed_cb (CallsNotifier *self,
|
state_changed_cb (CallsNotifier *self,
|
||||||
CallsCallState new_state,
|
CuiCallState new_state,
|
||||||
CallsCallState old_state,
|
CuiCallState old_state,
|
||||||
CallsCall *call)
|
CuiCall *call)
|
||||||
{
|
{
|
||||||
guint n;
|
guint n;
|
||||||
|
|
||||||
g_return_if_fail (CALLS_IS_NOTIFIER (self));
|
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);
|
g_return_if_fail (old_state != new_state);
|
||||||
|
|
||||||
if (old_state == CALLS_CALL_STATE_INCOMING &&
|
if (old_state == CUI_CALL_STATE_INCOMING &&
|
||||||
new_state == CALLS_CALL_STATE_DISCONNECTED)
|
new_state == CUI_CALL_STATE_DISCONNECTED)
|
||||||
{
|
|
||||||
notify (self, call);
|
notify (self, call);
|
||||||
}
|
|
||||||
|
|
||||||
/* Can use g_list_store_find with newer glib */
|
/* Can use g_list_store_find with newer glib */
|
||||||
n = g_list_model_get_n_items (G_LIST_MODEL (self->unanswered));
|
n = g_list_model_get_n_items (G_LIST_MODEL (self->unanswered));
|
||||||
for (int i = 0; i < n; i++)
|
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)
|
if (item == call)
|
||||||
{
|
{
|
||||||
g_list_store_remove (self->unanswered, i);
|
g_list_store_remove (self->unanswered, i);
|
||||||
|
@ -120,7 +121,7 @@ state_changed_cb (CallsNotifier *self,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
call_added_cb (CallsNotifier *self, CallsCall *call)
|
call_added_cb (CallsNotifier *self, CuiCall *call)
|
||||||
{
|
{
|
||||||
g_list_store_append(self->unanswered, call);
|
g_list_store_append(self->unanswered, call);
|
||||||
|
|
||||||
|
@ -134,7 +135,7 @@ call_added_cb (CallsNotifier *self, CallsCall *call)
|
||||||
static void
|
static void
|
||||||
calls_notifier_init (CallsNotifier *self)
|
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);
|
CallsNotifier *self = CALLS_NOTIFIER (object);
|
||||||
|
|
||||||
g_signal_connect_swapped (calls_manager_get_default (),
|
g_signal_connect_swapped (calls_manager_get_default (),
|
||||||
"call-add",
|
"ui-call-added",
|
||||||
G_CALLBACK (call_added_cb),
|
G_CALLBACK (call_added_cb),
|
||||||
self);
|
self);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue