Commit cc4e824b authored by Sébastien Blin's avatar Sébastien Blin Committed by Andreas Traczyk

ringnotify: rewrite notification system

Ring will now use three types of notifications:

1. Call notifications: opened when an incoming call is here
and closed at the end of the call.
2. Request notifications: opened when a new trust request
arrives and closed when the user accepts/refuse/block or
just open the conversation.
3. Chat notifications: arrives with new interactions and if
the current conversation is different or the client not focused. Closed
by Gnome or when the conversation is opened.

Change-Id: I5e5abf20507bac8bb37c429bc929c671fe66bd6b
Gitlab: #868Reviewed-by: Andreas Traczyk's avatarAndreas Traczyk <andreas.traczyk@savoirfairelinux.com>
parent 5912ad07
......@@ -34,6 +34,10 @@
<default>true</default>
<summary>Enable notifications for incoming calls.</summary>
</key>
<key name="enable-pending-notifications" type="b">
<default>true</default>
<summary>Enable notifications for pending requests.</summary>
</key>
<key name="enable-chat-notifications" type="b">
<default>true</default>
<summary>Enable notifications for new chat messages.</summary>
......
......@@ -59,6 +59,7 @@ struct _GeneralSettingsViewPrivate
GtkWidget *checkbutton_showstatusicon;
GtkWidget *checkbutton_bringtofront;
GtkWidget *checkbutton_callnotifications;
GtkWidget *checkbutton_pendingnotifications;
GtkWidget *checkbutton_chatnotifications;
GtkWidget *checkbutton_chatdisplaylinks;
GtkWidget *checkbutton_searchentryplacescall;
......@@ -223,6 +224,9 @@ general_settings_view_init(GeneralSettingsView *self)
g_settings_bind(priv->settings, "enable-display-links",
priv->checkbutton_chatdisplaylinks, "active",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind(priv->settings, "enable-pending-notifications",
priv->checkbutton_pendingnotifications, "active",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind(priv->settings, "enable-chat-notifications",
priv->checkbutton_chatnotifications, "active",
G_SETTINGS_BIND_DEFAULT);
......@@ -316,6 +320,7 @@ general_settings_view_class_init(GeneralSettingsViewClass *klass)
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), GeneralSettingsView, checkbutton_bringtofront);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), GeneralSettingsView, checkbutton_callnotifications);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), GeneralSettingsView, checkbutton_chatdisplaylinks);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), GeneralSettingsView, checkbutton_pendingnotifications);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), GeneralSettingsView, checkbutton_chatnotifications);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), GeneralSettingsView, checkbutton_searchentryplacescall);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), GeneralSettingsView, radiobutton_chatright);
......
......@@ -119,9 +119,6 @@ struct _RingClientPrivate {
NMClient *nm_client;
NMActiveConnection *primary_connection;
#endif
/* notifications */
QMetaObject::Connection call_notification;
};
/* this union is used to pass ints as pointers and vice versa for GAction parameters*/
......@@ -457,22 +454,6 @@ nm_client_cb(G_GNUC_UNUSED GObject *source_object, GAsyncResult *result, RingCli
#endif /* USE_LIBNM */
static void
call_notifications_toggled(RingClient *self)
{
auto priv = RING_CLIENT_GET_PRIVATE(self);
if (g_settings_get_boolean(priv->settings, "enable-call-notifications")) {
priv->call_notification = QObject::connect(
&CallModel::instance(),
&CallModel::incomingCall,
[] (Call *call) { ring_notify_incoming_call(call); }
);
} else {
QObject::disconnect(priv->call_notification);
}
}
static void
ring_client_startup(GApplication *app)
{
......@@ -590,12 +571,6 @@ ring_client_startup(GApplication *app)
ring_window_show(client);
}
);
/* enable notifications based on settings */
ring_notify_init();
call_notifications_toggled(client);
g_signal_connect_swapped(priv->settings, "changed::enable-call-notifications", G_CALLBACK(call_notifications_toggled), client);
#if USE_LIBNM
/* monitor the network using libnm to notify the daemon about connectivity chagnes */
nm_client_new_async(priv->cancellable, (GAsyncReadyCallback)nm_client_cb, client);
......@@ -617,7 +592,6 @@ ring_client_shutdown(GApplication *app)
g_object_unref(priv->cancellable);
QObject::disconnect(priv->uam_updated);
QObject::disconnect(priv->call_notification);
/* free the QCoreApplication, which will destroy all libRingClient models
* and thus send the Unregister signal over dbus to dring */
......@@ -631,8 +605,6 @@ ring_client_shutdown(GApplication *app)
g_clear_object(&priv->settings);
ring_notify_uninit();
#if USE_LIBNM
/* clear NetworkManager client if it was used */
g_clear_object(&priv->nm_client);
......
This diff is collapsed.
This diff is collapsed.
/*
* Copyright (C) 2015-2018 Savoir-faire Linux Inc.
* Author: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com>
* Author: Sebastien Blin <sebastien.blin@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -21,22 +22,37 @@
#define RING_NOTIFY_H_
#include <gtk/gtk.h>
#include "ringmainwindow.h"
class Call;
class ContactMethod;
namespace Media {
class TextRecording;
}
#include <string>
G_BEGIN_DECLS
#define RING_NOTIFIER_TYPE (ring_notifier_get_type ())
#define RING_NOTIFIER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RING_NOTIFIER_TYPE, RingNotifier))
#define RING_NOTIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), RING_NOTIFIER_TYPE, RingNotifierClass))
#define IS_RING_NOTIFIER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), RING_NOTIFIER_TYPE))
#define IS_RING_NOTIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), RING_NOTIFIER_TYPE))
typedef struct _RingNotifier RingNotifier;
typedef struct _RingNotifierClass RingNotifierClass;
enum class NotificationType
{
CALL,
REQUEST,
CHAT
};
GType ring_notifier_get_type (void) G_GNUC_CONST;
GtkWidget* ring_notifier_new (void);
void ring_notify_init();
void ring_notify_uninit();
gboolean ring_notify_is_initted();
gboolean ring_notify_incoming_call(Call*);
void ring_notify_message(ContactMethod*, Media::TextRecording*);
gboolean ring_notify_close_chat_notification(ContactMethod*);
gboolean ring_show_notification(RingNotifier* view,
const std::string& icon,
const std::string& uri,
const std::string& name,
const std::string& id,
const std::string& title,
const std::string& body,
NotificationType type);
gboolean ring_hide_notification(RingNotifier* view, const std::string& id);
G_END_DECLS
......
......@@ -89,6 +89,14 @@
<property name="draw_indicator">True</property>
</object>
</child>
<child>
<object class="GtkCheckButton" id="checkbutton_pendingnotifications">
<property name="label" translatable="yes">Enable notifications for pending requests.</property>
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
</child>
<child>
<object class="GtkCheckButton" id="checkbutton_chatnotifications">
<property name="label" translatable="yes">Enable notifications for new chat messages.</property>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment