Commit 12b95631 authored by Evangelos Ribeiro Tzaras's avatar Evangelos Ribeiro Tzaras
Browse files

Update upstream source from tag 'upstream/0.4.0_beta2'

Update to upstream version '0.4.0~beta2'
with Debian dir a116f249e904d6f7579a3010e4137fedff78a2b3
parents d9adeaab 5f82fe5b
......@@ -62,6 +62,12 @@
<description>Whether pressing Enter key sends the message</description>
</key>
<key name="request-sms-delivery-reports" type="b">
<default>true</default>
<summary>Request SMS delivery reports</summary>
<description>Whether to request delivery reports for outgoing SMS</description>
</key>
<key name="experimental-features" type="b">
<default>false</default>
<summary>Enable experimental features</summary>
......
project(
'chatty', 'c', 'cpp',
version: '0.3.4',
version: '0.4.0.beta2',
meson_version: '>= 0.46.0',
)
......
This diff is collapsed.
This diff is collapsed.
......@@ -9,7 +9,12 @@
"--share=ipc",
"--socket=fallback-x11",
"--socket=wayland",
"--talk-name=org.sigxcpu.Feedback"
"--talk-name=org.sigxcpu.Feedback",
"--system-talk-name=org.freedesktop.ModemManager1",
"--talk-name=org.gnome.evolution.dataserver.AddressBook10",
"--talk-name=org.gnome.evolution.dataserver.Sources5",
"--talk-name=im.pidgin.purple.PurpleService",
"--talk-name=org.gnome.evolution.dataserver.Subprocess.Backend.*"
],
"cleanup-commands": [ "rm -rf /app/lib/debug/ /app/include/boost" ],
"cleanup": [
......@@ -169,9 +174,9 @@
"-DENABLE_UOA=OFF",
"-DENABLE_GOOGLE_AUTH=OFF",
"-DENABLE_GOOGLE=OFF",
"-DENABLE_WITH_PHONENUMBER=ON",
"-DENABLE_VALA_BINDINGS=ON",
"-DENABLE_WEATHER=OFF",
"-DWITH_PHONENUMBER=ON",
"-DWITH_OPENLDAP=OFF",
"-DWITH_LIBDB=OFF",
"-DENABLE_INTROSPECTION=ON",
......@@ -207,10 +212,64 @@
"sources": [
{
"type": "git",
"tag" : "3.2.4",
"url": "https://gitlab.matrix.org/matrix-org/olm.git"
}
]
},
{
"name" : "gspell",
"config-opts" : [
"--disable-gtk-doc",
"--disable-gtk-doc-html"
],
"cleanup" : [
"/bin",
"/include",
"/lib/pkgconfig",
"*.la",
"/share"
],
"sources" : [
{
"type" : "archive",
"url" : "https://download.gnome.org/sources/gspell/1.8/gspell-1.8.1.tar.xz",
"sha256" : "819a1d23c7603000e73f5e738bdd284342e0cd345fb0c7650999c31ec741bbe5"
}
]
},
{
"name" : "gudev",
"buildsystem" : "meson",
"config-opts" : [
"-Dtests=disabled",
"-Dintrospection=disabled"
],
"sources" : [
{
"type" : "git",
"url" : "https://gitlab.gnome.org/GNOME/libgudev.git"
}
]
},
{
"name" : "ModemManager",
"buildsystem" : "autotools",
"config-opts" : [
"--disable-introspection",
"--disable-vala",
"--with-udev-base-dir=/app/lib",
"--with-systemdsystemunitdir=/app/lib/systemd/system",
"--without-mbim",
"--without-qmi"
],
"sources" : [
{
"type" : "git",
"url" : "git://anongit.freedesktop.org/ModemManager/ModemManager"
}
]
},
{
"name": "purism-chatty",
"buildsystem": "meson",
......
......@@ -193,7 +193,7 @@ application_show_connection_error (ChattyApplication *self,
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG(dialog),
"%s: %s\n\n%s",
message,
chatty_account_get_username (CHATTY_ACCOUNT (account)),
chatty_item_get_username (CHATTY_ITEM (account)),
_("Please check ID and password"));
run_dialog_and_destroy (GTK_DIALOG (dialog));
......@@ -206,13 +206,8 @@ application_open_chat (ChattyApplication *self,
g_assert (CHATTY_IS_APPLICATION (self));
g_assert (CHATTY_IS_CHAT (chat));
if (!self->main_window) {
self->main_window = chatty_window_new (GTK_APPLICATION (self));
g_object_add_weak_pointer (G_OBJECT (self->main_window), (gpointer *)&self->main_window);
}
g_application_activate (G_APPLICATION (self));
chatty_window_open_chat (CHATTY_WINDOW (self->main_window), chat);
gtk_window_present (GTK_WINDOW (self->main_window));
}
static gboolean
......@@ -237,8 +232,8 @@ chatty_application_show_window (GSimpleAction *action,
g_assert (CHATTY_IS_APPLICATION (self));
self->show_window = TRUE;
g_application_activate (G_APPLICATION (self));
gtk_window_present (GTK_WINDOW (self->main_window));
}
static void
......@@ -260,6 +255,8 @@ chatty_application_open_chat (GSimpleAction *action,
CHATTY_DEBUG_MSG ("Opening chat %s, account: %s", room_id, account_id);
self->show_window = TRUE;
g_application_activate (G_APPLICATION (self));
chatty_window_open_chat (CHATTY_WINDOW (self->main_window), chat);
}
......
......@@ -10,6 +10,7 @@
*/
#include <glib/gi18n.h>
#include <gspell/gspell.h>
#include "chatty-avatar.h"
#include "chatty-chat.h"
......@@ -55,8 +56,6 @@ struct _ChattyChatView
gboolean first_scroll_to_bottom;
};
static GHashTable *ht_sms_id = NULL;
#define INDICATOR_WIDTH 60
#define INDICATOR_HEIGHT 40
#define INDICATOR_MARGIN 2
......@@ -90,14 +89,6 @@ enum {
static guint signals[N_SIGNALS];
static gboolean
chat_view_hash_table_match_item (gpointer key,
gpointer value,
gpointer user_data)
{
return value == user_data;
}
static void
chatty_draw_typing_indicator (cairo_t *cr)
{
......@@ -206,7 +197,7 @@ chatty_chat_view_update (ChattyChatView *self)
gtk_widget_set_visible (self->send_file_button, chatty_chat_has_file_upload (self->chat));
if (protocol == CHATTY_PROTOCOL_SMS) {
if (protocol == CHATTY_PROTOCOL_MMS_SMS) {
gtk_label_set_label (GTK_LABEL (self->empty_label0),
_("This is an SMS conversation"));
gtk_label_set_label (GTK_LABEL (self->empty_label1),
......@@ -225,7 +216,7 @@ chatty_chat_view_update (ChattyChatView *self)
context = gtk_widget_get_style_context (self->send_message_button);
if (protocol == CHATTY_PROTOCOL_SMS)
if (protocol == CHATTY_PROTOCOL_MMS_SMS)
gtk_style_context_add_class (context, "button_send_green");
else if (chatty_chat_is_im (self->chat))
gtk_style_context_add_class (context, "suggested-action");
......@@ -267,6 +258,21 @@ chat_view_edge_overshot_cb (ChattyChatView *self,
}
static void
chat_account_status_changed_cb (ChattyChatView *self)
{
ChattyAccount *account;
gboolean enabled;
account = chatty_chat_get_account (self->chat);
g_return_if_fail (account);
enabled = chatty_account_get_status (account) == CHATTY_CONNECTED;
gtk_widget_set_sensitive (self->message_input, enabled);
gtk_widget_set_sensitive (self->send_file_button, enabled);
gtk_widget_set_sensitive (self->send_message_button, enabled);
}
static GtkWidget *
chat_view_message_row_new (ChattyMessage *message,
ChattyChatView *self)
......@@ -371,6 +377,16 @@ chat_view_send_file_button_clicked_cb (ChattyChatView *self,
}
}
static void
view_send_message_async_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
g_autoptr(ChattyChatView) self = user_data;
chatty_chat_set_unread_count (self->chat, 0);
}
static void
chat_view_send_message_button_clicked_cb (ChattyChatView *self)
{
......@@ -379,8 +395,6 @@ chat_view_send_message_button_clicked_cb (ChattyChatView *self)
g_autoptr(ChattyMessage) msg = NULL;
g_autofree char *message = NULL;
GtkTextIter start, end;
gchar *sms_id_str;
guint sms_id;
g_assert (CHATTY_IS_CHAT_VIEW (self));
......@@ -413,24 +427,6 @@ chat_view_send_message_button_clicked_cb (ChattyChatView *self)
protocol = chatty_item_get_protocols (CHATTY_ITEM (self->chat));
/* provide a msg-id to the sms-plugin for send-receipts */
if (conv && chatty_item_get_protocols (CHATTY_ITEM (self->chat)) == CHATTY_PROTOCOL_SMS) {
sms_id = g_random_int ();
sms_id_str = g_strdup_printf ("%i", sms_id);
g_hash_table_insert (ht_sms_id, sms_id_str, g_object_ref (self->chat));
g_debug ("hash table insert sms_id_str: %s ht_size: %i",
sms_id_str, g_hash_table_size (ht_sms_id));
purple_conv_im_send_with_flags (PURPLE_CONV_IM (conv),
sms_id_str,
PURPLE_MESSAGE_NO_LOG |
PURPLE_MESSAGE_NOTIFY |
PURPLE_MESSAGE_INVISIBLE);
}
if (protocol == CHATTY_PROTOCOL_MATRIX ||
protocol == CHATTY_PROTOCOL_XMPP ||
protocol == CHATTY_PROTOCOL_TELEGRAM)
......@@ -440,7 +436,9 @@ chat_view_send_message_button_clicked_cb (ChattyChatView *self)
NULL, time (NULL),
escaped ? CHATTY_MESSAGE_HTML_ESCAPED : CHATTY_MESSAGE_TEXT,
CHATTY_DIRECTION_OUT, 0);
chatty_chat_send_message_async (self->chat, msg, NULL, NULL);
chatty_chat_send_message_async (self->chat, msg,
view_send_message_async_cb,
g_object_ref (self));
gtk_widget_hide (self->send_message_button);
}
......@@ -482,7 +480,7 @@ chat_view_message_input_changed_cb (ChattyChatView *self)
chatty_update_typing_status (self);
if (chatty_settings_get_convert_emoticons (chatty_settings_get_default ()) &&
chatty_item_get_protocols (CHATTY_ITEM (self->chat)) != CHATTY_PROTOCOL_SMS)
chatty_item_get_protocols (CHATTY_ITEM (self->chat)) != CHATTY_PROTOCOL_MMS_SMS)
chatty_check_for_emoticon (self);
}
......@@ -595,56 +593,6 @@ chat_view_file_requested_cb (ChattyChatView *self,
g_object_ref (self));
}
static void
chat_view_sms_sent_cb (const char *sms_id,
int status)
{
ChattyChat *chat;
ChattyMessage *message;
GListModel *message_list;
const gchar *message_id;
ChattyMsgStatus sent_status;
time_t time_now;
guint n_items;
if (sms_id == NULL)
return;
if (status == CHATTY_SMS_RECEIPT_NONE)
sent_status = CHATTY_STATUS_SENDING_FAILED;
else if (status == CHATTY_SMS_RECEIPT_MM_ACKN)
sent_status = CHATTY_STATUS_SENT;
else if (status == CHATTY_SMS_RECEIPT_SMSC_ACKN)
sent_status = CHATTY_STATUS_DELIVERED;
else
return;
chat = g_hash_table_lookup (ht_sms_id, sms_id);
if (!chat)
return;
message_list = chatty_chat_get_messages (chat);
n_items = g_list_model_get_n_items (message_list);
message = g_list_model_get_item (message_list, n_items - 1);
message_id = chatty_message_get_id (message);
time_now = time (NULL);
if (message_id == NULL)
chatty_message_set_id (message, sms_id);
if (g_strcmp0 (message_id, sms_id) == 0) {
chatty_message_set_status (message, sent_status, time_now);
g_object_unref (message);
return;
}
message = chatty_pp_chat_find_message_with_id (CHATTY_PP_CHAT (chat), sms_id);
if (message)
chatty_message_set_status (message, sent_status, time_now);
}
static void
chatty_chat_view_map (GtkWidget *widget)
{
......@@ -660,9 +608,6 @@ chatty_chat_view_finalize (GObject *object)
{
ChattyChatView *self = (ChattyChatView *)object;
g_hash_table_foreach_remove (ht_sms_id,
chat_view_hash_table_match_item,
self);
g_clear_object (&self->chat);
G_OBJECT_CLASS (chatty_chat_view_parent_class)->finalize (object);
......@@ -722,6 +667,7 @@ chatty_chat_view_class_init (ChattyChatViewClass *klass)
static void
chatty_chat_view_init (ChattyChatView *self)
{
GspellTextView *gspell_view;
GtkAdjustment *vadjustment;
gtk_widget_init_template (GTK_WIDGET (self));
......@@ -736,6 +682,9 @@ chatty_chat_view_init (ChattyChatView *self)
gtk_list_box_set_header_func (GTK_LIST_BOX (self->message_list),
(GtkListBoxUpdateHeaderFunc)chat_view_update_header_func,
NULL, NULL);
gspell_view = gspell_text_view_get_from_gtk_text_view (GTK_TEXT_VIEW (self->message_input));
gspell_text_view_basic_setup (gspell_view);
}
GtkWidget *
......@@ -744,29 +693,11 @@ chatty_chat_view_new (void)
return g_object_new (CHATTY_TYPE_CHAT_VIEW, NULL);
}
void
chatty_chat_view_purple_init (void)
{
ht_sms_id = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
purple_signal_connect (purple_conversations_get_handle (),
"sms-sent", ht_sms_id,
PURPLE_CALLBACK (chat_view_sms_sent_cb), NULL);
}
void
chatty_chat_view_purple_uninit (void)
{
purple_signals_disconnect_by_handle (ht_sms_id);
g_hash_table_destroy (ht_sms_id);
}
void
chatty_chat_view_set_chat (ChattyChatView *self,
ChattyChat *chat)
{
ChattyAccount *account;
GListModel *messages;
g_return_if_fail (CHATTY_IS_CHAT_VIEW (self));
......@@ -790,9 +721,20 @@ chatty_chat_view_set_chat (ChattyChatView *self,
return;
messages = chatty_chat_get_messages (chat);
account = chatty_chat_get_account (chat);
if (g_list_model_get_n_items (messages) <= 3)
chatty_chat_load_past_messages (chat, -1);
if (account)
g_signal_connect_object (account, "notify::status",
G_CALLBACK (chat_account_status_changed_cb),
self,
G_CONNECT_SWAPPED);
chat_account_status_changed_cb (self);
gtk_list_box_bind_model (GTK_LIST_BOX (self->message_list),
chatty_chat_get_messages (self->chat),
(GtkListBoxCreateWidgetFunc)chat_view_message_row_new,
......@@ -811,6 +753,8 @@ chatty_chat_view_set_chat (ChattyChatView *self,
chat_buddy_typing_changed_cb (self);
chatty_chat_view_update (self);
chat_view_adjustment_value_changed_cb (self);
gtk_widget_grab_focus (self->message_input);
}
ChattyChat *
......
......@@ -22,8 +22,6 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (ChattyChatView, chatty_chat_view, CHATTY, CHAT_VIEW, GtkBox)
GtkWidget *chatty_chat_view_new (void);
void chatty_chat_view_purple_init (void);
void chatty_chat_view_purple_uninit (void);
void chatty_chat_view_set_chat (ChattyChatView *self,
ChattyChat *chat);
ChattyChat *chatty_chat_view_get_chat (ChattyChatView *self);
......
......@@ -101,19 +101,6 @@ chatty_chat_real_get_chat_name (ChattyChat *self)
return "";
}
static const char *
chatty_chat_real_get_username (ChattyChat *self)
{
ChattyChatPrivate *priv = chatty_chat_get_instance_private (self);
g_assert (CHATTY_IS_CHAT (self));
if (priv->user_name)
return priv->user_name;
return "";
}
static ChattyAccount *
chatty_chat_real_get_account (ChattyChat *self)
{
......@@ -303,6 +290,20 @@ chatty_chat_real_get_name (ChattyItem *item)
return "";
}
static const char *
chatty_chat_real_get_username (ChattyItem *item)
{
ChattyChat *self = (ChattyChat *)item;
ChattyChatPrivate *priv = chatty_chat_get_instance_private (self);
g_assert (CHATTY_IS_CHAT (self));
if (priv->user_name)
return priv->user_name;
return "";
}
static void
chatty_chat_get_property (GObject *object,
guint prop_id,
......@@ -376,12 +377,12 @@ chatty_chat_class_init (ChattyChatClass *klass)
object_class->finalize = chatty_chat_finalize;
item_class->get_name = chatty_chat_real_get_name;
item_class->get_username = chatty_chat_real_get_username;
klass->set_data = chatty_chat_real_set_data;
klass->is_im = chatty_chat_real_is_im;
klass->has_file_upload = chatty_chat_real_has_file_upload;
klass->get_chat_name = chatty_chat_real_get_chat_name;
klass->get_username = chatty_chat_real_get_username;
klass->get_account = chatty_chat_real_get_account;
klass->load_past_messages = chatty_chat_real_load_past_messages;
klass->is_loading_history = chatty_chat_real_is_loading_history;
......@@ -520,14 +521,6 @@ chatty_chat_get_chat_name (ChattyChat *self)
return CHATTY_CHAT_GET_CLASS (self)->get_chat_name (self);
}
const char *
chatty_chat_get_username (ChattyChat *self)
{
g_return_val_if_fail (CHATTY_IS_CHAT (self), "");
return CHATTY_CHAT_GET_CLASS (self)->get_username (self);
}
ChattyAccount *
chatty_chat_get_account (ChattyChat *self)
{
......
......@@ -34,7 +34,6 @@ struct _ChattyChatClass
gboolean (*is_im) (ChattyChat *self);
gboolean (*has_file_upload) (ChattyChat *self);
const char *(*get_chat_name) (ChattyChat *self);
const char *(*get_username) (ChattyChat *self);
ChattyAccount *(*get_account) (ChattyChat *self);
GListModel *(*get_messages) (ChattyChat *self);
GListModel *(*get_users) (ChattyChat *self);
......@@ -89,7 +88,6 @@ void chatty_chat_set_data (ChattyChat *self,
gboolean chatty_chat_is_im (ChattyChat *self);
gboolean chatty_chat_has_file_upload (ChattyChat *self);
const char *chatty_chat_get_chat_name (ChattyChat *self);
const char *chatty_chat_get_username (ChattyChat *self);
ChattyAccount *chatty_chat_get_account (ChattyChat *self);
GListModel *chatty_chat_get_messages (ChattyChat *self);
void chatty_chat_load_past_messages (ChattyChat *self,
......
......@@ -115,10 +115,9 @@ chatty_eds_bus_got (GObject *object,
}
static ChattyContact *
chatty_contact_provider_matches (ChattyEds *self,
const char *needle,
ChattyProtocol protocols,
gboolean match_name)
chatty_contact_provider_get_match (ChattyEds *self,
const char *value,
ChattyProtocol protocols)
{
GListModel *model;
guint n_items;
......@@ -129,13 +128,13 @@ chatty_contact_provider_matches (ChattyEds *self,
for (guint i = 0; i < n_items; i++)
{
g_autoptr(ChattyItem) item = NULL;
g_autoptr(ChattyContact) contact = NULL;
item = g_list_model_get_item (model, i);
match = chatty_item_matches (item, needle, protocols, match_name);
contact = g_list_model_get_item (model, i);
match = chatty_contact_is_exact_match (contact, value, protocols);
if (match)
return CHATTY_CONTACT (item);
return contact;
}
return NULL;
......@@ -191,7 +190,7 @@ chatty_eds_load_contact (ChattyEds *self,
if (self->protocols & CHATTY_PROTOCOL_CALL)
protocol = CHATTY_PROTOCOL_CALL;
else
protocol = CHATTY_PROTOCOL_SMS;
protocol = CHATTY_PROTOCOL_MMS_SMS;
} else if (field_id == E_CONTACT_IM_JABBER) {
protocol = CHATTY_PROTOCOL_XMPP;
} else {
......@@ -240,7 +239,7 @@ chatty_eds_objects_added_cb (ChattyEds *self,
for (GSList *l = (GSList *)objects; l != NULL; l = l->next)
{
if (self->protocols & CHATTY_PROTOCOL_SMS ||
if (self->protocols & CHATTY_PROTOCOL_MMS_SMS ||
self->protocols & CHATTY_PROTOCOL_CALL)
chatty_eds_load_contact (self, l->data, E_CONTACT_TEL);
......@@ -641,7 +640,7 @@ chatty_eds_find_by_number (ChattyEds *self,
{
g_return_val_if_fail (CHATTY_IS_EDS (self), NULL);
return chatty_contact_provider_matches (self, phone_number, CHATTY_PROTOCOL_ANY, FALSE);
return chatty_contact_provider_get_match (self, phone_number, CHATTY_PROTOCOL_ANY);
}
......
......@@ -48,7 +48,7 @@ typedef enum
typedef enum
{
CHATTY_PROTOCOL_NONE = 0,
CHATTY_PROTOCOL_SMS = 1 << 0,
CHATTY_PROTOCOL_MMS_SMS = 1 << 0,
CHATTY_PROTOCOL_MMS = 1 << 1,
CHATTY_PROTOCOL_CALL = 1 << 2,
CHATTY_PROTOCOL_XMPP = 1 << 3,
......@@ -148,10 +148,3 @@ typedef enum
CHATTY_ITEM_ARCHIVED,
CHATTY_ITEM_BLOCKED,
} ChattyItemState;
typedef enum
{
CHATTY_SMS_RECEIPT_NONE = -1,
CHATTY_SMS_RECEIPT_MM_ACKN = 0,
CHATTY_SMS_RECEIPT_SMSC_ACKN,
} e_sms_receipt_states;
......@@ -22,6 +22,9 @@
#include "chatty-utils.h"
#include "chatty-settings.h"
#include "users/chatty-mm-account.h"
#include "users/chatty-mm-buddy.h"
#include "chatty-mm-chat.h"
#include "chatty-history.h"
#define STRING(arg) STRING_VALUE(arg)
......@@ -30,6 +33,11 @@
/* increment when DB changes */
#define HISTORY_VERSION 3
/* Shouldn't be modified, new values should be appended */
#define MESSAGE_DIRECTION_OUT -1
#define MESSAGE_DIRECTION_SYSTEM 0