about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-05-24 17:37:27 +0200
committerMichael Vetter <jubalh@iodoru.org>2020-05-24 17:55:15 +0200
commitbe4a6cac78d9f9bd41a55985945446d60fde3a76 (patch)
treec5774305d3b2dc496f567a820705a5d399d7e09d
parentf121554088a6bffd2721b94c46a40d8ec61e0b46 (diff)
downloadprofani-tty-be4a6cac78d9f9bd41a55985945446d60fde3a76.tar.gz
Add bookmark ignore add|remove
Regards https://github.com/profanity-im/profanity/issues/1115
-rw-r--r--src/command/cmd_defs.c11
-rw-r--r--src/command/cmd_funcs.c12
-rw-r--r--src/tools/bookmark_ignore.c12
-rw-r--r--src/tools/bookmark_ignore.h2
4 files changed, 34 insertions, 3 deletions
diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c
index d8a06bf2..70331542 100644
--- a/src/command/cmd_defs.c
+++ b/src/command/cmd_defs.c
@@ -809,10 +809,13 @@ static struct cmd_t command_defs[] =
             "/bookmark remove [<room>]",
             "/bookmark join <room>",
             "/bookmark invites on|off",
-            "/bookmark ignore")
+            "/bookmark ignore",
+            "/bookmark ignore add <jid>",
+            "/bookmark ignore remove <jid>")
         CMD_DESC(
             "Manage bookmarks and join bookmarked rooms. "
-            "In a chat room, no arguments will bookmark the current room, setting autojoin to \"on\".")
+            "In a chat room, no arguments will bookmark the current room, setting autojoin to \"on\"."
+            "There is also an autojoin ignore list in case you want to autojoind in many clients but not on Profanity.")
         CMD_ARGS(
             { "list", "List all bookmarks." },
             { "add [<room>]", "Add a bookmark, passing no room will bookmark the current room, setting autojoin to \"on\"." },
@@ -823,7 +826,9 @@ static struct cmd_t command_defs[] =
             { "name <roomname>", "Optional name for the bookmark. By default localpart of the JID will be used." },
             { "autojoin on|off", "Whether to join the room automatically on login." },
             { "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'."})
+            { "invites on|off", "Whether or not to bookmark accepted room invites, defaults to 'on'."},
+            { "ignore add <barejid>", "Add a bookmark to the autojoin ignore list."},
+            { "ignore remove <barejid>", "Remove a bookmark from the autojoin ignore list."})
         CMD_NOEXAMPLES
     },
 
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index 171a3e52..27416108 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -4787,6 +4787,18 @@ cmd_bookmark_ignore(ProfWin *window, const char *const command, gchar **args)
         return TRUE;
     }
 
+    if (strcmp(args[1], "add") == 0 && args[2] != NULL) {
+        bookmark_ignore_add(args[2]);
+        cons_show("Autojoin for bookmark %s added to ignore list.", args[2]);
+        return TRUE;
+    }
+
+    if (strcmp(args[1], "remove") == 0 && args[2] != NULL) {
+        bookmark_ignore_remove(args[2]);
+        cons_show("Autojoin for bookmark %s removed from ignore list.", args[2]);
+        return TRUE;
+    }
+
     cons_bad_cmd_usage(command);
     return TRUE;
 }
diff --git a/src/tools/bookmark_ignore.c b/src/tools/bookmark_ignore.c
index 018c5b5b..2be65d5f 100644
--- a/src/tools/bookmark_ignore.c
+++ b/src/tools/bookmark_ignore.c
@@ -91,3 +91,15 @@ bookmark_ignore_list(gsize *len)
 {
     return g_key_file_get_keys(bookmark_ignore_keyfile, account_jid, len, NULL);
 }
+
+void
+bookmark_ignore_add(const char *const barejid)
+{
+    g_key_file_set_boolean(bookmark_ignore_keyfile, account_jid, barejid, TRUE);
+}
+
+void
+bookmark_ignore_remove(const char *const barejid)
+{
+    g_key_file_remove_key(bookmark_ignore_keyfile, account_jid, barejid, NULL);
+}
diff --git a/src/tools/bookmark_ignore.h b/src/tools/bookmark_ignore.h
index 3eb0ccff..9b0fda36 100644
--- a/src/tools/bookmark_ignore.h
+++ b/src/tools/bookmark_ignore.h
@@ -40,5 +40,7 @@ void bookmark_ignore_on_connect();
 void bookmark_ignore_on_disconnect();
 gboolean bookmark_ignored(Bookmark *bookmark);
 gchar ** bookmark_ignore_list(gsize *len);
+void bookmark_ignore_add(const char *const barejid);
+void bookmark_ignore_remove(const char *const barejid);
 
 #endif