diff --git a/doc/user-guide/commands.xml b/doc/user-guide/commands.xml
index f4fb2eb04..5d6779028 100644
--- a/doc/user-guide/commands.xml
+++ b/doc/user-guide/commands.xml
@@ -999,6 +999,50 @@
+
+
+ false
+
+
+
+ Only relevant for purple-matrix. If enabled, uses the Matrix canonical alias (or one of the room aliases, if not present) as the name of Matrix groupchats, instead of the room's title. This can help for Matrix rooms with frequently-changed titles.
+
+
+
+
+
+
+ false
+
+
+
+ If this setting is enabled, the names of groupchats generated for this account will have "TAG-" prepended to them, where TAG is the tag of the account. This can help keep groupchats separated when using libpurple.
+
+
+
+
+
+
+ false
+
+
+
+ If enabled, automatically marks every message received as read. Useful to avoid duplicate messages when the connection drops, but may annoy your friends.
+
+
+
+
+
+ false
+
+
+
+ This setting controls whether to wait for users to be added to groupchats before joining them. This can help make the channel names generated by some libpurple protocols nicer (e.g. when using purple-matrix).
+
+
+
+
+
false
diff --git a/protocols/purple/purple.c b/protocols/purple/purple.c
index d07892d3d..5e66e1ac3 100644
--- a/protocols/purple/purple.c
+++ b/protocols/purple/purple.c
@@ -284,6 +284,17 @@ static void purple_init(account_t *acc)
s = set_add(&acc->set, "display_name", NULL, set_eval_display_name, acc);
s->flags |= ACC_SET_ONLINE_ONLY;
+ s = set_add(&acc->set, "defer_joins", "false", set_eval_bool, acc);
+ s = set_add(&acc->set, "mark_read", "false", set_eval_bool, acc);
+
+ if (strcmp(prpl->info->name, "Matrix") == 0) {
+ s = set_add(&acc->set, "use_matrix_alias", "false", set_eval_bool, acc);
+ s->flags |= ACC_SET_OFFLINE_ONLY;
+ }
+
+ s = set_add(&acc->set, "chat_name_with_tag", "false", set_eval_bool, acc);
+ s->flags |= ACC_SET_OFFLINE_ONLY;
+
if (pi->options & OPT_PROTO_MAIL_CHECK) {
s = set_add(&acc->set, "mail_notifications", "false", set_eval_bool, acc);
s->flags |= ACC_SET_OFFLINE_ONLY;
@@ -1107,6 +1118,23 @@ static PurpleBlistUiOps bee_blist_uiops =
prplcb_blist_remove, /* remove */
};
+void purple_hint_chat_names(struct groupchat *gc, PurpleConversation *conv) {
+ char *hint = NULL;
+ if (conv->title != NULL) {
+ hint = conv->title;
+ }
+ if (set_getbool(&(gc->ic->acc->set), "use_matrix_alias") && purple_conversation_get_data(conv, "matrix_alias") != NULL) {
+ hint = (char *) purple_conversation_get_data(conv, "matrix_alias");
+ }
+ if (set_getbool(&(gc->ic->acc->set), "chat_name_with_tag")) {
+ char *tag = set_getstr(&(gc->ic->acc->set), "tag");
+ char *tagged_name = g_strdup_printf("%s-%s", tag, hint);
+ imcb_chat_name_hint(gc, tagged_name);
+ g_free(tagged_name);
+ } else {
+ imcb_chat_name_hint(gc, hint);
+ }
+}
void prplcb_conv_new(PurpleConversation *conv)
{
if (conv->type == PURPLE_CONV_TYPE_CHAT) {
@@ -1117,9 +1145,7 @@ void prplcb_conv_new(PurpleConversation *conv)
if (!gc) {
gc = imcb_chat_new(ic, conv->name);
- if (conv->title != NULL) {
- imcb_chat_name_hint(gc, conv->title);
- }
+ purple_hint_chat_names(gc, conv);
}
/* don't set the topic if it's just the name */
@@ -1133,7 +1159,9 @@ void prplcb_conv_new(PurpleConversation *conv)
/* libpurple brokenness: Whatever. Show that we join right away,
there's no clear "This is you!" signaling in _add_users so
don't even try. */
- imcb_chat_add_buddy(gc, gc->ic->acc->user);
+ if (!set_getbool(&(ic->acc->set), "defer_joins")) {
+ imcb_chat_add_buddy(gc, gc->ic->acc->user);
+ }
}
}
@@ -1154,6 +1182,10 @@ void prplcb_conv_add_users(PurpleConversation *conv, GList *cbuddies, gboolean n
imcb_chat_add_buddy(gc, pcb->name);
}
+ purple_hint_chat_names(gc, conv);
+ if (!gc->joined) {
+ imcb_chat_add_buddy(gc, gc->ic->acc->user);
+ }
}
void prplcb_conv_del_users(PurpleConversation *conv, GList *cbuddies)
@@ -1171,7 +1203,7 @@ static void handle_conv_msg(PurpleConversation *conv, const char *who, const cha
{
struct im_connection *ic = purple_ic_by_pa(conv->account);
struct groupchat *gc = conv->ui_data;
- char *message = g_strdup(message_);
+ char *message = purple_unescape_html(message_);
PurpleBuddy *buddy;
buddy = purple_find_buddy(conv->account, who);
@@ -1185,9 +1217,18 @@ static void handle_conv_msg(PurpleConversation *conv, const char *who, const cha
imcb_chat_msg(gc, who, message, bee_flags, mtime);
}
+ if (set_getbool(&(ic->acc->set), "mark_read")) {
+ purple_conversation_update(conv, PURPLE_CONV_UPDATE_UNSEEN);
+ }
+
g_free(message);
}
+/* Handles has_focus - this needs to return TRUE if we want marking things as read to work for some prpls */
+static gboolean prplcb_conv_has_focus(PurpleConversation *conv) {
+ struct im_connection *ic = purple_ic_by_pa(conv->account);
+ return set_getbool(&(ic->acc->set), "mark_read");
+}
/* Handles write_im and write_chat. Removes echoes of locally sent messages.
*
* PURPLE_MESSAGE_DELAYED is used for chat backlogs - if a message has both
@@ -1253,7 +1294,7 @@ static PurpleConversationUiOps bee_conv_uiops =
prplcb_conv_del_users, /* chat_remove_users */
NULL, /* chat_update_user */
NULL, /* present */
- NULL, /* has_focus */
+ prplcb_conv_has_focus, /* has_focus */
NULL, /* custom_smiley_add */
NULL, /* custom_smiley_write */
NULL, /* custom_smiley_close */