Commit 759faeae authored by Nicolas Jager's avatar Nicolas Jager Committed by Guillaume Roguez
Browse files

ChatView : add button to send basic invitation.

- an "invite" button is added to the chatview, click on it, will request
the daemon to send a contact request to the uri of the contact shown.

Change-Id: I3959eb5d4ac153d54762ee80ea2f68a766e730a7
Reviewed-by: Guillaume Roguez's avatarGuillaume Roguez <>
parent 40916b48
......@@ -19,6 +19,7 @@
#include "chatview.h"
#include "utils/accounts.h"
#include <gtk/gtk.h>
#include <call.h>
......@@ -35,6 +36,10 @@
#include "utils/calling.h"
#include "webkitchatcontainer.h"
// LRC
#include <account.h>
static constexpr GdkRGBA RING_BLUE = {0.0508, 0.594, 0.676, 1.0}; // outgoing msg color: (13, 152, 173)
struct _ChatView
......@@ -61,6 +66,7 @@ struct _ChatViewPrivate
GtkWidget *combobox_cm;
GtkWidget *button_close_chatview;
GtkWidget *button_placecall;
GtkWidget *button_send_invitation;
/* only one of the three following pointers should be non void;
* either this is an in-call chat (and so the in-call chat APIs will be used)
......@@ -184,6 +190,42 @@ placecall_clicked(ChatView *self)
static void
button_send_invitation_clicked(ChatView *self)
auto priv = CHAT_VIEW_GET_PRIVATE(self);
// get the account associated to the selected cm
auto active = gtk_combo_box_get_active(GTK_COMBO_BOX(priv->combobox_cm));
if (priv->person)
priv->cm = priv->person->phoneNumbers().at(active);
if (!priv->cm) {
g_warning("invalid contact, cannot send invitation!");
// try first to use the account associated to the contact method
auto account = priv->cm->account();
if (not account) {
// get the choosen account
account = get_active_ring_account();
if (not account) {
g_warning("invalid account, cannot send invitation!");
// perform the request
if (not account->sendContactRequest(priv->cm))
g_warning("contact request not forwarded, cannot send invitation!");
// TODO : add an entry in the conversation to tell the user an invitation was sent.
static void
chat_view_init(ChatView *view)
......@@ -195,6 +237,7 @@ chat_view_init(ChatView *view)
g_signal_connect(priv->entry_chat_input, "activate", G_CALLBACK(send_chat), view);
g_signal_connect(priv->button_close_chatview, "clicked", G_CALLBACK(hide_chat_view), view);
g_signal_connect_swapped(priv->button_placecall, "clicked", G_CALLBACK(placecall_clicked), view);
g_signal_connect_swapped(priv->button_send_invitation, "clicked", G_CALLBACK(button_send_invitation_clicked), view);
static void
......@@ -214,6 +257,7 @@ chat_view_class_init(ChatViewClass *klass)
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), ChatView, combobox_cm);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), ChatView, button_close_chatview);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), ChatView, button_placecall);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), ChatView, button_send_invitation);
chat_view_signals[NEW_MESSAGES_DISPLAYED] = g_signal_new (
......@@ -53,6 +53,16 @@
<property name="pack-type">end</property>
<object class="GtkButton" id="button_send_invitation">
<property name="visible">True</property>
<property name="label">Invite</property>
<property name="tooltip-text" translatable="yes">Send invitation</property>
<property name="pack-type">end</property>
<object class="GtkComboBox" id="combobox_cm">
<property name="visible">True</property>
Supports Markdown
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