Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

purple: add defer_joins, use_matrix_alias and name_with_tag options #125

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 36 additions & 5 deletions protocols/purple/purple.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,16 @@ 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);

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;
Expand Down Expand Up @@ -1107,6 +1117,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), "name_with_tag")) {
eeeeeta marked this conversation as resolved.
Show resolved Hide resolved
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) {
Expand All @@ -1117,9 +1144,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 */
Expand All @@ -1133,7 +1158,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")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: Considering the comment above, I wonder if this should be default behavior, because yeah, this ugly behavior affects quite a few prpls.

It's mostly a question of whether the defer point is always reached reliably - would, say, a newly created channel with no other members skip the add users call? Some weird prpl that just don't do it, and add them with delay?

imcb_chat_add_buddy(gc, gc->ic->acc->user);
}
}
}

Expand All @@ -1154,6 +1181,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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self, recheck the meaning of this one.

imcb_chat_add_buddy(gc, gc->ic->acc->user);
}
}

void prplcb_conv_del_users(PurpleConversation *conv, GList *cbuddies)
Expand All @@ -1171,7 +1202,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_);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: This seems unlikely to be desirable for all prpls. I think there's a prpl flag to mark it as sending html or not?

PurpleBuddy *buddy;

buddy = purple_find_buddy(conv->account, who);
Expand Down