1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

List ignored bookmarks

`/bookmarl ignore` lists the ignored bookmarks.

Regards https://github.com/profanity-im/profanity/issues/1115
This commit is contained in:
Michael Vetter 2020-05-24 17:17:20 +02:00
parent ca3972b3ca
commit f121554088
7 changed files with 54 additions and 2 deletions

View File

@ -795,7 +795,9 @@ static struct cmd_t command_defs[] =
{ "/bookmark",
parse_args, 0, 8, NULL,
CMD_NOSUBFUNCS
CMD_SUBFUNCS(
{ "ignore", cmd_bookmark_ignore }
)
CMD_MAINFUNC(cmd_bookmark)
CMD_TAGS(
CMD_TAG_GROUPCHAT)
@ -806,7 +808,8 @@ static struct cmd_t command_defs[] =
"/bookmark update <room> [nick <nick>] [password <password>] [name <roomname>] autojoin on|off]",
"/bookmark remove [<room>]",
"/bookmark join <room>",
"/bookmark invites on|off")
"/bookmark invites on|off",
"/bookmark ignore")
CMD_DESC(
"Manage bookmarks and join bookmarked rooms. "
"In a chat room, no arguments will bookmark the current room, setting autojoin to \"on\".")

View File

@ -68,6 +68,7 @@
#include "tools/autocomplete.h"
#include "tools/parser.h"
#include "tools/tinyurl.h"
#include "tools/bookmark_ignore.h"
#include "plugins/plugins.h"
#include "ui/ui.h"
#include "ui/window_list.h"
@ -4766,6 +4767,30 @@ cmd_bookmark(ProfWin *window, const char *const command, gchar **args)
return TRUE;
}
gboolean
cmd_bookmark_ignore(ProfWin *window, const char *const command, gchar **args)
{
jabber_conn_status_t conn_status = connection_get_status();
if (conn_status != JABBER_CONNECTED) {
cons_show("You are not currently connected.");
cons_alert();
return TRUE;
}
// `/bookmark ignore` lists them
if (args[1] == NULL) {
gsize len;
gchar **list = bookmark_ignore_list(&len);
cons_show_bookmarks_ignore(list, len);
g_strfreev(list);
return TRUE;
}
cons_bad_cmd_usage(command);
return TRUE;
}
gboolean
cmd_disco(ProfWin *window, const char *const command, gchar **args)
{

View File

@ -115,6 +115,7 @@ gboolean cmd_reconnect(ProfWin *window, const char *const command, gchar **args)
gboolean cmd_room(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_rooms(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_bookmark(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_bookmark_ignore(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_roster(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_software(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_splash(ProfWin *window, const char *const command, gchar **args);

View File

@ -85,3 +85,9 @@ bookmark_ignored(Bookmark *bookmark)
{
return g_key_file_get_boolean(bookmark_ignore_keyfile, account_jid, bookmark->barejid, NULL);
}
gchar **
bookmark_ignore_list(gsize *len)
{
return g_key_file_get_keys(bookmark_ignore_keyfile, account_jid, len, NULL);
}

View File

@ -39,5 +39,6 @@
void bookmark_ignore_on_connect();
void bookmark_ignore_on_disconnect();
gboolean bookmark_ignored(Bookmark *bookmark);
gchar ** bookmark_ignore_list(gsize *len);
#endif

View File

@ -2683,3 +2683,18 @@ _show_roster_contacts(GSList *list, gboolean show_groups)
curr = g_slist_next(curr);
}
}
void
cons_show_bookmarks_ignore(gchar **list, gsize len)
{
int i;
ProfWin *console = wins_get_console();
cons_show("");
cons_show("Ignored bookmarks:");
for(i=0; i<len; i++) {
win_print(console, THEME_DEFAULT, "-", " %s", list[i]);
win_newline(console);
}
}

View File

@ -268,6 +268,7 @@ void cons_show_login_success(ProfAccount *account, gboolean secured);
void cons_show_account_list(gchar **accounts);
void cons_show_room_list(GSList *room, const char *const conference_node);
void cons_show_bookmarks(const GList *list);
void cons_show_bookmarks_ignore(gchar **list, gsize len);
void cons_show_disco_items(GSList *items, const char *const jid);
void cons_show_disco_info(const char *from, GSList *identities, GSList *features);
void cons_show_room_invite(const char *const invitor, const char *const room, const char *const reason);