diff options
-rw-r--r-- | src/command/command.c | 48 | ||||
-rw-r--r-- | src/command/commands.c | 12 | ||||
-rw-r--r-- | src/config/preferences.c | 9 | ||||
-rw-r--r-- | src/config/preferences.h | 3 | ||||
-rw-r--r-- | src/ui/buffer.c | 2 | ||||
-rw-r--r-- | src/ui/console.c | 12 | ||||
-rw-r--r-- | src/ui/core.c | 2 | ||||
-rw-r--r-- | src/xmpp/message.c | 6 |
8 files changed, 73 insertions, 21 deletions
diff --git a/src/command/command.c b/src/command/command.c index 0a4be511..e165254e 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -101,6 +101,7 @@ static char * _resource_autocomplete(const char * const input); static char * _titlebar_autocomplete(const char * const input); static char * _inpblock_autocomplete(const char * const input); static char * _time_autocomplete(const char * const input); +static char * _receipts_autocomplete(const char * const input); GHashTable *commands = NULL; @@ -920,12 +921,14 @@ static struct cmd_t command_defs[] = NULL } } }, { "/receipts", - cmd_receipts, parse_args, 1, 1, &cons_receipts_setting, - { "/receipts on|off", "Message delivery receipts.", - { "/receipts on|off", - "----------------", - "Enable or disable message delivery receipts.", - "The user interface will indicate when a message has been received.", + cmd_receipts, parse_args, 2, 2, &cons_receipts_setting, + { "/receipts send|request on|off", "Message delivery receipts.", + { "/receipts send|request on|off", + "-----------------------------", + "Enable or disable message delivery receipts. The interface will indicate when a message has been received.", + "", + "send on|off : Enable or disable sending of delivery receipts.", + "request on|off : Enable or disable sending of delivery receipt requests.", NULL } } }, { "/reconnect", @@ -1198,6 +1201,7 @@ static Autocomplete time_ac; static Autocomplete time_statusbar_ac; static Autocomplete resource_ac; static Autocomplete inpblock_ac; +static Autocomplete receipts_ac; /* * Initialise command autocompleter and history @@ -1555,6 +1559,10 @@ cmd_init(void) inpblock_ac = autocomplete_new(); autocomplete_add(inpblock_ac, "timeout"); autocomplete_add(inpblock_ac, "dynamic"); + + receipts_ac = autocomplete_new(); + autocomplete_add(receipts_ac, "send"); + autocomplete_add(receipts_ac, "request"); } void @@ -1612,6 +1620,7 @@ cmd_uninit(void) autocomplete_free(time_statusbar_ac); autocomplete_free(resource_ac); autocomplete_free(inpblock_ac); + autocomplete_free(receipts_ac); } gboolean @@ -1778,6 +1787,7 @@ cmd_reset_autocomplete() autocomplete_reset(time_statusbar_ac); autocomplete_reset(resource_ac); autocomplete_reset(inpblock_ac); + autocomplete_reset(receipts_ac); if (ui_current_win_type() == WIN_CHAT) { ProfChatWin *chatwin = wins_get_current_chat(); @@ -1897,7 +1907,7 @@ _cmd_complete_parameters(const char * const input) // autocomplete boolean settings gchar *boolean_choices[] = { "/beep", "/intype", "/states", "/outtype", "/flash", "/splash", "/chlog", "/grlog", "/mouse", "/history", - "/vercheck", "/privileges", "/presence", "/wrap", "/carbons", "/receipts" }; + "/vercheck", "/privileges", "/presence", "/wrap", "/carbons" }; for (i = 0; i < ARRAY_SIZE(boolean_choices); i++) { result = autocomplete_param_with_func(input, boolean_choices[i], prefs_autocomplete_boolean_choice); @@ -1998,6 +2008,7 @@ _cmd_complete_parameters(const char * const input) g_hash_table_insert(ac_funcs, "/titlebar", _titlebar_autocomplete); g_hash_table_insert(ac_funcs, "/inpblock", _inpblock_autocomplete); g_hash_table_insert(ac_funcs, "/time", _time_autocomplete); + g_hash_table_insert(ac_funcs, "/receipts", _receipts_autocomplete); int len = strlen(input); char parsed[len+1]; @@ -2815,6 +2826,29 @@ _statuses_autocomplete(const char * const input) } static char * +_receipts_autocomplete(const char * const input) +{ + char *result = NULL; + + result = autocomplete_param_with_func(input, "/receipts send", prefs_autocomplete_boolean_choice); + if (result != NULL) { + return result; + } + + result = autocomplete_param_with_func(input, "/receipts request", prefs_autocomplete_boolean_choice); + if (result != NULL) { + return result; + } + + result = autocomplete_param_with_ac(input, "/receipts", receipts_ac, TRUE); + if (result != NULL) { + return result; + } + + return NULL; +} + +static char * _alias_autocomplete(const char * const input) { char *result = NULL; diff --git a/src/command/commands.c b/src/command/commands.c index 1a55765e..86285a46 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -4016,8 +4016,16 @@ cmd_carbons(gchar **args, struct cmd_help_t help) gboolean cmd_receipts(gchar **args, struct cmd_help_t help) { - return _cmd_set_boolean_preference(args[0], help, - "Message delivery receipts", PREF_RECEIPTS); + if (g_strcmp0(args[0], "send") == 0) { + return _cmd_set_boolean_preference(args[1], help, + "Send delivery receipts", PREF_RECEIPTS_SEND); + } else if (g_strcmp0(args[0], "request") == 0) { + return _cmd_set_boolean_preference(args[1], help, + "Request delivery receipets", PREF_RECEIPTS_REQUEST); + } else { + cons_show("Usage: %s", help.usage); + return TRUE; + } } gboolean diff --git a/src/config/preferences.c b/src/config/preferences.c index ce25ff9e..fdaae11f 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -543,7 +543,8 @@ _get_group(preference_t pref) case PREF_CONNECT_ACCOUNT: case PREF_DEFAULT_ACCOUNT: case PREF_CARBONS: - case PREF_RECEIPTS: + case PREF_RECEIPTS_SEND: + case PREF_RECEIPTS_REQUEST: return PREF_GROUP_CONNECTION; case PREF_OTR_LOG: case PREF_OTR_POLICY: @@ -580,8 +581,10 @@ _get_key(preference_t pref) return "history"; case PREF_CARBONS: return "carbons"; - case PREF_RECEIPTS: - return "receipts"; + case PREF_RECEIPTS_SEND: + return "receipts.send"; + case PREF_RECEIPTS_REQUEST: + return "receipts.request"; case PREF_MOUSE: return "mouse"; case PREF_OCCUPANTS: diff --git a/src/config/preferences.h b/src/config/preferences.h index b031e857..a9413886 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -60,7 +60,8 @@ typedef enum { PREF_INTYPE, PREF_HISTORY, PREF_CARBONS, - PREF_RECEIPTS, + PREF_RECEIPTS_SEND, + PREF_RECEIPTS_REQUEST, PREF_MOUSE, PREF_OCCUPANTS, PREF_OCCUPANTS_SIZE, diff --git a/src/ui/buffer.c b/src/ui/buffer.c index 40a994f1..0848b60f 100644 --- a/src/ui/buffer.c +++ b/src/ui/buffer.c @@ -106,7 +106,7 @@ buffer_mark_received(ProfBuff buffer, const char * const id) GSList *entries = buffer->entries; while (entries) { ProfBuffEntry *entry = entries->data; - if (entry->receipt) { + if (entry->receipt && g_strcmp0(entry->receipt->id, id) == 0) { if (!entry->receipt->received) { entry->receipt->received = TRUE; return TRUE; diff --git a/src/ui/console.c b/src/ui/console.c index cd74f455..328f59aa 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -1199,10 +1199,16 @@ cons_carbons_setting(void) void cons_receipts_setting(void) { - if (prefs_get_boolean(PREF_RECEIPTS)) - cons_show("Message receipts (/receipts) : ON"); + if (prefs_get_boolean(PREF_RECEIPTS_REQUEST)) + cons_show("Request receipts (/receipts) : ON"); else - cons_show("Message receipts (/receipts) : OFF"); + cons_show("Request receipts (/receipts) : OFF"); + + if (prefs_get_boolean(PREF_RECEIPTS_SEND)) + cons_show("Send receipts (/receipts) : ON"); + else + cons_show("Send receipts (/receipts) : OFF"); + } void diff --git a/src/ui/core.c b/src/ui/core.c index c00c7838..acb9e550 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -1467,7 +1467,7 @@ ui_outgoing_chat_msg(const char * const barejid, const char * const message, cha ProfChatWin *chatwin = (ProfChatWin*)window; chat_state_active(chatwin->state); - if (prefs_get_boolean(PREF_RECEIPTS) && id) { + if (prefs_get_boolean(PREF_RECEIPTS_REQUEST) && id) { win_print_with_receipt(window, '-', NULL, 0, THEME_TEXT_ME, "me", message, id); } else { win_print(window, '-', NULL, 0, THEME_TEXT_ME, "me", message); diff --git a/src/xmpp/message.c b/src/xmpp/message.c index 7986c668..e6927f76 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -110,7 +110,7 @@ message_send_chat(const char * const barejid, const char * const msg) if (state) { stanza_attach_state(ctx, message, state); } - if (prefs_get_boolean(PREF_RECEIPTS)) { + if (prefs_get_boolean(PREF_RECEIPTS_REQUEST)) { stanza_attach_receipt_request(ctx, message); } @@ -151,7 +151,7 @@ message_send_chat_encrypted(const char * const barejid, const char * const msg) stanza_attach_state(ctx, message, state); } stanza_attach_carbons_private(ctx, message); - if (prefs_get_boolean(PREF_RECEIPTS)) { + if (prefs_get_boolean(PREF_RECEIPTS_REQUEST)) { stanza_attach_receipt_request(ctx, message); } @@ -621,7 +621,7 @@ _chat_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, } else { handle_incoming_message(jid->barejid, jid->resourcepart, message); } - if (id) { + if (id && prefs_get_boolean(PREF_RECEIPTS_SEND)) { xmpp_stanza_t *receipts = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_RECEIPTS); if (receipts) { char *receipts_name = xmpp_stanza_get_name(receipts); |