mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Added message when bookmark updated
This commit is contained in:
parent
a8ecbccc9c
commit
92b85bb7f1
@ -1763,19 +1763,23 @@ cmd_bookmark(gchar **args, struct cmd_help_t help)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(cmd, "add") == 0) {
|
if (strcmp(cmd, "add") == 0) {
|
||||||
bookmark_add(jid, nick, autojoin);
|
gboolean added = bookmark_add(jid, nick, autojoin);
|
||||||
GString *msg = g_string_new("Bookmark added for ");
|
if (added) {
|
||||||
g_string_append(msg, jid);
|
GString *msg = g_string_new("Bookmark added for ");
|
||||||
if (nick != NULL) {
|
g_string_append(msg, jid);
|
||||||
g_string_append(msg, ", nickname: ");
|
if (nick != NULL) {
|
||||||
g_string_append(msg, nick);
|
g_string_append(msg, ", nickname: ");
|
||||||
|
g_string_append(msg, nick);
|
||||||
|
}
|
||||||
|
if (autojoin) {
|
||||||
|
g_string_append(msg, ", autojoin enabled");
|
||||||
|
}
|
||||||
|
g_string_append(msg, ".");
|
||||||
|
cons_show(msg->str);
|
||||||
|
g_string_free(msg, TRUE);
|
||||||
|
} else {
|
||||||
|
cons_show("Bookmark updated for %s.", jid);
|
||||||
}
|
}
|
||||||
if (autojoin) {
|
|
||||||
g_string_append(msg, ", autojoin enabled");
|
|
||||||
}
|
|
||||||
g_string_append(msg, ".");
|
|
||||||
cons_show(msg->str);
|
|
||||||
g_string_free(msg, TRUE);
|
|
||||||
} else if (strcmp(cmd, "remove") == 0) {
|
} else if (strcmp(cmd, "remove") == 0) {
|
||||||
bookmark_remove(jid, autojoin);
|
bookmark_remove(jid, autojoin);
|
||||||
if (autojoin) {
|
if (autojoin) {
|
||||||
|
@ -58,7 +58,7 @@ bookmark_request(void)
|
|||||||
xmpp_stanza_release(iq);
|
xmpp_stanza_release(iq);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static gboolean
|
||||||
_bookmark_add(const char *jid, const char *nick, gboolean autojoin)
|
_bookmark_add(const char *jid, const char *nick, gboolean autojoin)
|
||||||
{
|
{
|
||||||
/* TODO: send request */
|
/* TODO: send request */
|
||||||
@ -67,6 +67,8 @@ _bookmark_add(const char *jid, const char *nick, gboolean autojoin)
|
|||||||
/* this may be command for modifying */
|
/* this may be command for modifying */
|
||||||
autocomplete_remove(bookmark_ac, jid);
|
autocomplete_remove(bookmark_ac, jid);
|
||||||
autocomplete_add(bookmark_ac, jid);
|
autocomplete_add(bookmark_ac, jid);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -132,7 +132,7 @@ void (*iq_set_autoping)(int seconds);
|
|||||||
Capabilities* (*caps_get)(const char * const caps_str);
|
Capabilities* (*caps_get)(const char * const caps_str);
|
||||||
void (*caps_close)(void);
|
void (*caps_close)(void);
|
||||||
|
|
||||||
void (*bookmark_add)(const char *jid, const char *nick, gboolean autojoin);
|
gboolean (*bookmark_add)(const char *jid, const char *nick, gboolean autojoin);
|
||||||
void (*bookmark_remove)(const char *jid, gboolean autojoin);
|
void (*bookmark_remove)(const char *jid, gboolean autojoin);
|
||||||
const GList * (*bookmark_get_list)(void);
|
const GList * (*bookmark_get_list)(void);
|
||||||
char * (*bookmark_find)(char *search_str);
|
char * (*bookmark_find)(char *search_str);
|
||||||
|
@ -169,7 +169,7 @@ void cmd_bookmark_add_adds_bookmark_with_jid(void **state)
|
|||||||
|
|
||||||
mock_connection_status(JABBER_CONNECTED);
|
mock_connection_status(JABBER_CONNECTED);
|
||||||
|
|
||||||
expect_bookmark_add(jid, NULL, FALSE);
|
expect_and_return_bookmark_add(jid, NULL, FALSE, TRUE);
|
||||||
expect_cons_show("Bookmark added for room@conf.server.");
|
expect_cons_show("Bookmark added for room@conf.server.");
|
||||||
|
|
||||||
gboolean result = cmd_bookmark(args, *help);
|
gboolean result = cmd_bookmark(args, *help);
|
||||||
@ -189,7 +189,7 @@ void cmd_bookmark_add_adds_bookmark_with_jid_nick(void **state)
|
|||||||
|
|
||||||
mock_connection_status(JABBER_CONNECTED);
|
mock_connection_status(JABBER_CONNECTED);
|
||||||
|
|
||||||
expect_bookmark_add(jid, nick, FALSE);
|
expect_and_return_bookmark_add(jid, nick, FALSE, TRUE);
|
||||||
expect_cons_show("Bookmark added for room@conf.server, nickname: bob.");
|
expect_cons_show("Bookmark added for room@conf.server, nickname: bob.");
|
||||||
|
|
||||||
gboolean result = cmd_bookmark(args, *help);
|
gboolean result = cmd_bookmark(args, *help);
|
||||||
@ -208,7 +208,7 @@ void cmd_bookmark_add_adds_bookmark_with_jid_autojoin(void **state)
|
|||||||
|
|
||||||
mock_connection_status(JABBER_CONNECTED);
|
mock_connection_status(JABBER_CONNECTED);
|
||||||
|
|
||||||
expect_bookmark_add(jid, NULL, TRUE);
|
expect_and_return_bookmark_add(jid, NULL, TRUE, TRUE);
|
||||||
expect_cons_show("Bookmark added for room@conf.server, autojoin enabled.");
|
expect_cons_show("Bookmark added for room@conf.server, autojoin enabled.");
|
||||||
|
|
||||||
gboolean result = cmd_bookmark(args, *help);
|
gboolean result = cmd_bookmark(args, *help);
|
||||||
@ -228,7 +228,7 @@ void cmd_bookmark_add_adds_bookmark_with_jid_nick_autojoin(void **state)
|
|||||||
|
|
||||||
mock_connection_status(JABBER_CONNECTED);
|
mock_connection_status(JABBER_CONNECTED);
|
||||||
|
|
||||||
expect_bookmark_add(jid, nick, TRUE);
|
expect_and_return_bookmark_add(jid, nick, TRUE, TRUE);
|
||||||
expect_cons_show("Bookmark added for room@conf.server, nickname: bob, autojoin enabled.");
|
expect_cons_show("Bookmark added for room@conf.server, nickname: bob, autojoin enabled.");
|
||||||
|
|
||||||
gboolean result = cmd_bookmark(args, *help);
|
gboolean result = cmd_bookmark(args, *help);
|
||||||
@ -254,7 +254,7 @@ void cmd_bookmark_add_adds_bookmark_with_room_details(void **state)
|
|||||||
mock_current_win_type(WIN_MUC);
|
mock_current_win_type(WIN_MUC);
|
||||||
ui_current_recipient_returns(jid);
|
ui_current_recipient_returns(jid);
|
||||||
|
|
||||||
expect_bookmark_add(jid, nick, FALSE);
|
expect_and_return_bookmark_add(jid, nick, FALSE, TRUE);
|
||||||
expect_cons_show("Bookmark added for room@conf.server, nickname: bob.");
|
expect_cons_show("Bookmark added for room@conf.server, nickname: bob.");
|
||||||
|
|
||||||
gboolean result = cmd_bookmark(args, *help);
|
gboolean result = cmd_bookmark(args, *help);
|
||||||
@ -281,7 +281,7 @@ void cmd_bookmark_add_adds_bookmark_with_room_details_autojoin(void **state)
|
|||||||
mock_current_win_type(WIN_MUC);
|
mock_current_win_type(WIN_MUC);
|
||||||
ui_current_recipient_returns(jid);
|
ui_current_recipient_returns(jid);
|
||||||
|
|
||||||
expect_bookmark_add(jid, nick, TRUE);
|
expect_and_return_bookmark_add(jid, nick, TRUE, TRUE);
|
||||||
expect_cons_show("Bookmark added for room@conf.server, nickname: bob, autojoin enabled.");
|
expect_cons_show("Bookmark added for room@conf.server, nickname: bob, autojoin enabled.");
|
||||||
|
|
||||||
gboolean result = cmd_bookmark(args, *help);
|
gboolean result = cmd_bookmark(args, *help);
|
||||||
@ -328,3 +328,22 @@ void cmd_bookmark_remove_removes_autojoin(void **state)
|
|||||||
|
|
||||||
free(help);
|
free(help);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmd_bookmark_add_shows_message_when_upated(void **state)
|
||||||
|
{
|
||||||
|
mock_bookmark_add();
|
||||||
|
mock_cons_show();
|
||||||
|
char *jid = "room@conf.server";
|
||||||
|
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||||
|
gchar *args[] = { "add", jid, NULL };
|
||||||
|
|
||||||
|
mock_connection_status(JABBER_CONNECTED);
|
||||||
|
|
||||||
|
expect_and_return_bookmark_add(jid, NULL, FALSE, FALSE);
|
||||||
|
expect_cons_show("Bookmark updated for room@conf.server.");
|
||||||
|
|
||||||
|
gboolean result = cmd_bookmark(args, *help);
|
||||||
|
assert_true(result);
|
||||||
|
|
||||||
|
free(help);
|
||||||
|
}
|
||||||
|
@ -15,3 +15,4 @@ void cmd_bookmark_add_adds_bookmark_with_room_details(void **state);
|
|||||||
void cmd_bookmark_add_adds_bookmark_with_room_details_autojoin(void **state);
|
void cmd_bookmark_add_adds_bookmark_with_room_details_autojoin(void **state);
|
||||||
void cmd_bookmark_remove_removes_bookmark(void **state);
|
void cmd_bookmark_remove_removes_bookmark(void **state);
|
||||||
void cmd_bookmark_remove_removes_autojoin(void **state);
|
void cmd_bookmark_remove_removes_autojoin(void **state);
|
||||||
|
void cmd_bookmark_add_shows_message_when_upated(void **state);
|
||||||
|
@ -456,6 +456,7 @@ int main(int argc, char* argv[]) {
|
|||||||
unit_test(cmd_bookmark_add_adds_bookmark_with_room_details_autojoin),
|
unit_test(cmd_bookmark_add_adds_bookmark_with_room_details_autojoin),
|
||||||
unit_test(cmd_bookmark_remove_removes_bookmark),
|
unit_test(cmd_bookmark_remove_removes_bookmark),
|
||||||
unit_test(cmd_bookmark_remove_removes_autojoin),
|
unit_test(cmd_bookmark_remove_removes_autojoin),
|
||||||
|
unit_test(cmd_bookmark_add_shows_message_when_upated),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,12 +64,13 @@ _mock_bookmark_get_list(void)
|
|||||||
return (GList *)mock();
|
return (GList *)mock();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static gboolean
|
||||||
_mock_bookmark_add(const char *jid, const char *nick, gboolean autojoin)
|
_mock_bookmark_add(const char *jid, const char *nick, gboolean autojoin)
|
||||||
{
|
{
|
||||||
check_expected(jid);
|
check_expected(jid);
|
||||||
check_expected(nick);
|
check_expected(nick);
|
||||||
check_expected(autojoin);
|
check_expected(autojoin);
|
||||||
|
return (gboolean)mock();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -194,7 +195,8 @@ presence_update_expect(resource_presence_t presence, char *msg, int idle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
expect_bookmark_add(char *expected_jid, char *expected_nick, gboolean expected_autojoin)
|
expect_and_return_bookmark_add(char *expected_jid, char *expected_nick,
|
||||||
|
gboolean expected_autojoin, gboolean added)
|
||||||
{
|
{
|
||||||
expect_string(_mock_bookmark_add, jid, expected_jid);
|
expect_string(_mock_bookmark_add, jid, expected_jid);
|
||||||
if (expected_nick != NULL) {
|
if (expected_nick != NULL) {
|
||||||
@ -203,6 +205,8 @@ expect_bookmark_add(char *expected_jid, char *expected_nick, gboolean expected_a
|
|||||||
expect_any(_mock_bookmark_add, nick);
|
expect_any(_mock_bookmark_add, nick);
|
||||||
}
|
}
|
||||||
expect_value(_mock_bookmark_add, autojoin, expected_autojoin);
|
expect_value(_mock_bookmark_add, autojoin, expected_autojoin);
|
||||||
|
|
||||||
|
will_return(_mock_bookmark_add, added);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -24,7 +24,8 @@ void presence_update_expect(resource_presence_t presence, char *msg, int idle);
|
|||||||
void bookmark_get_list_returns(GList *bookmarks);
|
void bookmark_get_list_returns(GList *bookmarks);
|
||||||
|
|
||||||
void mock_bookmark_add(void);
|
void mock_bookmark_add(void);
|
||||||
void expect_bookmark_add(char *expected_jid, char *expected_nick, gboolean expected_autojoin);
|
void expect_and_return_bookmark_add(char *expected_jid, char *expected_nick,
|
||||||
|
gboolean expected_autojoin, gboolean added);
|
||||||
|
|
||||||
void mock_bookmark_remove(void);
|
void mock_bookmark_remove(void);
|
||||||
void expect_bookmark_remove(char *expected_jid, gboolean expected_autojoin);
|
void expect_bookmark_remove(char *expected_jid, gboolean expected_autojoin);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user