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 option to automatically mark new messages as read #131

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
purple: add defer_joins, use_matrix_alias and name_with_tag options
(Most of these changes are aimed at making matrix not a pain to use)
- The `defer_joins` option on prpl accounts waits for users to be added
  to a prpl conversation before adding the bitlbee user, in the hope
  of being able to get some chat name/alias metadata before doing so.
- (To that end, the name hint for rooms is now updated when users are
  added.)
- The `name_with_tag` options prefixes the account tag to the name hint
  for prpl accounts, in order to namespace prpl channels somewhat.
- The `use_matrix_alias` option is specialized for the purple-matrix
  plugin, and makes the name hint use the `matrix_alias` data item
  of the prpl conversation, instead of the title.
  • Loading branch information
eeeeeta committed Apr 4, 2019
commit fc75fb4eae441db5582b63b6bc00aecbe75f2c24
2 changes: 1 addition & 1 deletion bitlbee.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ extern "C" {
#define CONTROL_TOPIC "Welcome to the control channel. Type \2help\2 for help information."
#define IRCD_INFO PACKAGE " <http://www.bitlbee.org/>"

#define MAX_NICK_LENGTH 24
#define MAX_NICK_LENGTH 80

#define HELP_FILE VARDIR "help.txt"
#define CONF_FILE_DEF ETCDIR "bitlbee.conf"
Expand Down
44 changes: 39 additions & 5 deletions protocols/purple/purple.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,15 @@ 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->flags |= ACC_SET_OFFLINE_ONLY;

s = set_add(&acc->set, "use_matrix_alias", "false", set_eval_bool, acc);
s->flags |= ACC_SET_OFFLINE_ONLY;

s = set_add(&acc->set, "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 +1116,24 @@ 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")) {
char tagged_name[128];
char *tag = set_getstr(&(gc->ic->acc->set), "tag");
g_snprintf(tagged_name, sizeof(tagged_name), "%s-%s", tag, hint);
imcb_chat_name_hint(gc, tagged_name);
}
else {
imcb_chat_name_hint(gc, conv->title);
}
}
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,12 @@ 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);
}
else {
imcb_log(gc->ic, "Deferring join to %s", conv->name);
}
}
}

Expand All @@ -1154,6 +1184,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)
Expand All @@ -1171,7 +1205,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);
Expand Down