1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Merge branch 'master' into osx-functional

This commit is contained in:
James Booth 2016-05-23 23:59:31 +01:00
commit 08a8d2f50c
10 changed files with 68 additions and 4 deletions

View File

@ -517,6 +517,7 @@ cmd_ac_init(void)
autocomplete_add(bookmark_ac, "update");
autocomplete_add(bookmark_ac, "remove");
autocomplete_add(bookmark_ac, "join");
autocomplete_add(bookmark_ac, "invites");
bookmark_property_ac = autocomplete_new();
autocomplete_add(bookmark_property_ac, "nick");
@ -1599,6 +1600,10 @@ _bookmark_autocomplete(ProfWin *window, const char *const input)
if (found) {
return found;
}
found = autocomplete_param_with_func(input, "/bookmark invites", prefs_autocomplete_boolean_choice);
if (found) {
return found;
}
found = autocomplete_param_with_ac(input, "/bookmark", bookmark_ac, TRUE);
return found;

View File

@ -807,7 +807,8 @@ static struct cmd_t command_defs[] =
"/bookmark add <room> [nick <nick>] [password <password>] [autojoin on|off]",
"/bookmark update <room> [nick <nick>] [password <password>] [autojoin on|off]",
"/bookmark remove <room>",
"/bookmark join <room>")
"/bookmark join <room>",
"/bookmark invites on|off")
CMD_DESC(
"Manage bookmarks and join bookmarked rooms. "
"In a chat room, no arguments will bookmark the current room, setting autojoin to \"on\".")
@ -819,7 +820,8 @@ static struct cmd_t command_defs[] =
{ "nick <nick>", "Nickname used in the chat room." },
{ "password <password>", "Password if required, may be stored in plaintext on your server." },
{ "autojoin on|off", "Whether to join the room automatically on login." },
{ "join <room>", "Join room using the properties associated with the bookmark." })
{ "join <room>", "Join room using the properties associated with the bookmark." },
{ "invites on|off", "Whether or not to bookmark accepted room invites, defaults to 'on'."})
CMD_NOEXAMPLES
},

View File

@ -4337,7 +4337,19 @@ cmd_bookmark(ProfWin *window, const char *const command, gchar **args)
return TRUE;
}
if (strcmp(cmd, "list") == 0) {
if (strcmp(cmd, "invites") == 0) {
if (g_strcmp0(args[1], "on") == 0) {
prefs_set_boolean(PREF_BOOKMARK_INVITE, TRUE);
cons_show("Auto bookmarking accepted invites enabled.");
} else if (g_strcmp0(args[1], "off") == 0) {
prefs_set_boolean(PREF_BOOKMARK_INVITE, FALSE);
cons_show("Auto bookmarking accepted invites disabled.");
} else {
cons_bad_cmd_usage(command);
cons_show("");
}
return TRUE;
} else if (strcmp(cmd, "list") == 0) {
const GList *bookmarks = bookmark_get_list();
cons_show_bookmarks(bookmarks);
} else {

View File

@ -57,6 +57,7 @@
#define PREF_GROUP_ALIAS "alias"
#define PREF_GROUP_OTR "otr"
#define PREF_GROUP_PGP "pgp"
#define PREF_GROUP_MUC "muc"
#define INPBLOCK_DEFAULT 1000
@ -1286,6 +1287,8 @@ _get_group(preference_t pref)
return PREF_GROUP_OTR;
case PREF_PGP_LOG:
return PREF_GROUP_PGP;
case PREF_BOOKMARK_INVITE:
return PREF_GROUP_MUC;
default:
return NULL;
}
@ -1484,6 +1487,8 @@ _get_key(preference_t pref)
return "console.private";
case PREF_CONSOLE_CHAT:
return "console.chat";
case PREF_BOOKMARK_INVITE:
return "bookmark.invite";
default:
return NULL;
}
@ -1530,6 +1535,7 @@ _get_default_boolean(preference_t pref)
case PREF_LASTACTIVITY:
case PREF_NOTIFY_MENTION_WHOLE_WORD:
case PREF_TRAY_READ:
case PREF_BOOKMARK_INVITE:
return TRUE;
default:
return FALSE;

View File

@ -140,6 +140,7 @@ typedef enum {
PREF_CONSOLE_MUC,
PREF_CONSOLE_PRIVATE,
PREF_CONSOLE_CHAT,
PREF_BOOKMARK_INVITE,
} preference_t;
typedef struct prof_alias_t {

View File

@ -793,7 +793,13 @@ sv_ev_muc_self_online(const char *const room, const char *const nick, gboolean c
iq_room_info_request(room, FALSE);
muc_invites_remove(room);
if (muc_invites_contain(room)) {
if (prefs_get_boolean(PREF_BOOKMARK_INVITE) && !bookmark_exists(room)) {
bookmark_add(room, nick, muc_invite_password(room), "on");
}
muc_invites_remove(room);
}
muc_roster_set_complete(room);
// show roster if occupants list disabled by default

View File

@ -717,6 +717,14 @@ cons_show_bookmarks(const GList *list)
list = g_list_next(list);
}
}
cons_show("");
if (prefs_get_boolean(PREF_BOOKMARK_INVITE)) {
cons_show("Automatic invite bookmarking (/bookmark invites): ON");
} else {
cons_show("Automatic invite bookmarking (/bookmark invites): OFF");
}
cons_alert();
}

View File

@ -240,6 +240,24 @@ bookmark_autocomplete_reset(void)
}
}
gboolean
bookmark_exists(const char *const room)
{
GSList *bookmarks = autocomplete_create_list(bookmark_ac);
GSList *curr = bookmarks;
while (curr) {
if (strcmp(curr->data, room) == 0) {
g_slist_free_full(bookmarks, g_free);
return TRUE;
} else {
curr = g_slist_next(curr);
}
}
g_slist_free_full(bookmarks, g_free);
return FALSE;
}
static int
_bookmark_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
{

View File

@ -184,6 +184,7 @@ gboolean bookmark_join(const char *jid);
const GList* bookmark_get_list(void);
char* bookmark_find(const char *const search_str);
void bookmark_autocomplete_reset(void);
gboolean bookmark_exists(const char *const room);
void roster_send_name_change(const char *const barejid, const char *const new_name, GSList *groups);
void roster_send_add_to_group(const char *const group, PContact contact);

View File

@ -254,6 +254,11 @@ void roster_send_name_change(const char * const barejid, const char * const new_
check_expected(groups);
}
gboolean bookmark_exists(const char *const room)
{
return FALSE;
}
void roster_send_add_to_group(const char * const group, PContact contact) {}
void roster_send_remove_from_group(const char * const group, PContact contact) {}