aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/chat_session.c100
-rw-r--r--src/chat_session.h9
-rw-r--r--src/command/command.c30
-rw-r--r--src/command/commands.c110
-rw-r--r--src/otr/otr.c10
-rw-r--r--src/server_events.c20
-rw-r--r--src/ui/core.c8
-rw-r--r--src/ui/inputwin.c16
-rw-r--r--src/xmpp/message.c30
-rw-r--r--src/xmpp/xmpp.h11
-rw-r--r--tests/test_cmd_otr.c2
-rw-r--r--tests/test_server_events.c5
-rw-r--r--tests/xmpp/stub_xmpp.c7
13 files changed, 125 insertions, 233 deletions
diff --git a/src/chat_session.c b/src/chat_session.c
index 8185ee8e..dcd6e0ac 100644
--- a/src/chat_session.c
+++ b/src/chat_session.c
@@ -34,6 +34,7 @@
#include <stdlib.h>
#include <string.h>
+#include <assert.h>
#include <glib.h>
@@ -57,7 +58,7 @@ typedef enum {
typedef struct chat_session_t {
char *barejid;
char *resource;
- gboolean supported;
+ gboolean send_states;
chat_state_t state;
GTimer *active_timer;
gboolean sent;
@@ -66,12 +67,12 @@ typedef struct chat_session_t {
static GHashTable *sessions;
static ChatSession*
-_chat_session_new(const char * const barejid, const char * const resource, gboolean supported)
+_chat_session_new(const char * const barejid, const char * const resource, gboolean send_states)
{
ChatSession *new_session = malloc(sizeof(struct chat_session_t));
new_session->barejid = strdup(barejid);
new_session->resource = strdup(resource);
- new_session->supported = supported;
+ new_session->send_states = send_states;
new_session->state = CHAT_STATE_STARTED;
new_session->active_timer = g_timer_new();
new_session->sent = FALSE;
@@ -111,6 +112,7 @@ gboolean
chat_session_exists(const char * const barejid)
{
ChatSession *session = g_hash_table_lookup(sessions, barejid);
+
return (session != NULL);
}
@@ -118,33 +120,22 @@ char*
chat_session_get_resource(const char * const barejid)
{
ChatSession *session = g_hash_table_lookup(sessions, barejid);
- if (session) {
- return session->resource;
- } else {
- return NULL;
- }
+ assert(session != NULL);
+
+ return session->resource;
}
gboolean
-chat_session_on_message_send(const char * const barejid)
+chat_session_send_states(const char * const barejid)
{
- gboolean send_state = FALSE;
-
- if (prefs_get_boolean(PREF_STATES)) {
- ChatSession *session = g_hash_table_lookup(sessions, barejid);
- if (session && session->supported) {
- session->state = CHAT_STATE_ACTIVE;
- g_timer_start(session->active_timer);
- session->sent = TRUE;
- send_state = TRUE;
- }
- }
+ ChatSession *session = g_hash_table_lookup(sessions, barejid);
+ assert(session != NULL);
- return send_state;
+ return session->send_states;
}
void
-chat_session_on_incoming_message(const char * const barejid, const char * const resource, gboolean supported)
+chat_session_on_incoming_message(const char * const barejid, const char * const resource, gboolean send_states)
{
ChatSession *session = g_hash_table_lookup(sessions, barejid);
@@ -153,14 +144,14 @@ chat_session_on_incoming_message(const char * const barejid, const char * const
if (g_strcmp0(session->resource, resource) != 0) {
log_info("Replacing chat session %s/%s, with new session %s/%s", session->barejid, session->resource, barejid, resource);
g_hash_table_remove(sessions, session);
- session = _chat_session_new(barejid, resource, supported);
+ session = _chat_session_new(barejid, resource, send_states);
g_hash_table_insert(sessions, strdup(barejid), session);
} else {
- session->supported = supported;
+ session->send_states = send_states;
}
} else {
log_info("Starting chat session with %s/%s", barejid, resource);
- session = _chat_session_new(barejid, resource, supported);
+ session = _chat_session_new(barejid, resource, send_states);
g_hash_table_insert(sessions, strdup(barejid), session);
}
} else if (session) {
@@ -170,28 +161,33 @@ chat_session_on_incoming_message(const char * const barejid, const char * const
}
void
+chat_session_on_message_send(const char * const barejid)
+{
+ ChatSession *session = g_hash_table_lookup(sessions, barejid);
+ assert(session != NULL);
+
+ session->state = CHAT_STATE_ACTIVE;
+ g_timer_start(session->active_timer);
+ session->sent = TRUE;
+}
+
+void
chat_session_on_window_close(const char * const barejid)
{
- if (prefs_get_boolean(PREF_STATES)) {
- ChatSession *session = g_hash_table_lookup(sessions, barejid);
- // send <gone/> chat state before closing
- if (session && session->supported) {
- session->state = CHAT_STATE_GONE;
- message_send_gone(barejid);
- session->sent = TRUE;
- g_hash_table_remove(sessions, barejid);
- }
+ ChatSession *session = g_hash_table_lookup(sessions, barejid);
+ assert(session != NULL);
+
+ if (prefs_get_boolean(PREF_STATES) && session->send_states) {
+ message_send_gone(barejid);
}
}
void
chat_session_on_cancel(const char * const jid)
{
- if (prefs_get_boolean(PREF_STATES)) {
- ChatSession *session = g_hash_table_lookup(sessions, jid);
- if (session) {
- session->supported = FALSE;
- }
+ ChatSession *session = g_hash_table_lookup(sessions, jid);
+ if (session) {
+ session->send_states = FALSE;
}
}
@@ -199,7 +195,7 @@ void
chat_session_on_activity(const char * const barejid)
{
ChatSession *session = g_hash_table_lookup(sessions, barejid);
- if (session && session->supported) {
+ if (session) {
if (session->state != CHAT_STATE_COMPOSING) {
session->sent = FALSE;
}
@@ -208,11 +204,15 @@ chat_session_on_activity(const char * const barejid)
g_timer_start(session->active_timer);
if (!session->sent || session->state == CHAT_STATE_PAUSED) {
- Jid *jidp = jid_create_from_bare_and_resource(session->barejid, session->resource);
- message_send_composing(jidp->fulljid);
+ if (prefs_get_boolean(PREF_STATES) && prefs_get_boolean(PREF_OUTTYPE) && session->send_states) {
+ Jid *jidp = jid_create_from_bare_and_resource(session->barejid, session->resource);
+ message_send_composing(jidp->fulljid);
+ jid_destroy(jidp);
+ }
session->sent = TRUE;
- jid_destroy(jidp);
}
+ } else if (prefs_get_boolean(PREF_STATES) && prefs_get_boolean(PREF_OUTTYPE)) {
+ message_send_composing(barejid);
}
}
@@ -220,7 +220,7 @@ void
chat_session_on_inactivity(const char * const barejid)
{
ChatSession *session = g_hash_table_lookup(sessions, barejid);
- if (session && session->supported) {
+ if (session) {
if (session->active_timer != NULL) {
gdouble elapsed = g_timer_elapsed(session->active_timer, NULL);
@@ -247,13 +247,19 @@ chat_session_on_inactivity(const char * const barejid)
if (session->sent == FALSE) {
Jid *jidp = jid_create_from_bare_and_resource(session->barejid, session->resource);
if (session->state == CHAT_STATE_GONE) {
- message_send_gone(jidp->fulljid);
+ if (prefs_get_boolean(PREF_STATES) && session->send_states) {
+ message_send_gone(jidp->fulljid);
+ }
session->sent = TRUE;
} else if (session->state == CHAT_STATE_INACTIVE) {
- message_send_inactive(jidp->fulljid);
+ if (prefs_get_boolean(PREF_STATES) && session->send_states) {
+ message_send_inactive(jidp->fulljid);
+ }
session->sent = TRUE;
} else if (session->state == CHAT_STATE_PAUSED && prefs_get_boolean(PREF_OUTTYPE)) {
- message_send_paused(jidp->fulljid);
+ if (prefs_get_boolean(PREF_STATES) && session->send_states) {
+ message_send_paused(jidp->fulljid);
+ }
session->sent = TRUE;
}
jid_destroy(jidp);
diff --git a/src/chat_session.h b/src/chat_session.h
index f9f47586..441f9096 100644
--- a/src/chat_session.h
+++ b/src/chat_session.h
@@ -42,11 +42,14 @@ void chat_sessions_clear(void);
gboolean chat_session_exists(const char * const barejid);
char* chat_session_get_resource(const char * const barejid);
-gboolean chat_session_on_message_send(const char * const barejid);
+gboolean chat_session_send_states(const char * const barejid);
+
+void chat_session_on_message_send(const char * const barejid);
void chat_session_on_window_close(const char * const barejid);
-void chat_session_on_incoming_message(const char * const barejid, const char * const resource, gboolean supported);
+void chat_session_on_incoming_message(const char * const barejid, const char * const resource, gboolean send_states);
void chat_session_on_cancel(const char * const jid);
+
void chat_session_on_activity(const char * const barejid);
-void chat_session_on_inactivity(const char * const recipient);
+void chat_session_on_inactivity(const char * const barejid);
#endif
diff --git a/src/command/command.c b/src/command/command.c
index 470bb886..7fd1616e 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -1814,15 +1814,7 @@ cmd_execute_default(const char * inp)
if (otr_is_secure(chatwin->barejid)) {
char *encrypted = otr_encrypt_message(chatwin->barejid, inp);
if (encrypted != NULL) {
- char *resource = NULL;
- gboolean send_state = FALSE;
- if (chat_session_exists(chatwin->barejid)) {
- resource = chat_session_get_resource(chatwin->barejid);
- send_state = chat_session_on_message_send(chatwin->barejid);
- } else {
- send_state = TRUE;
- }
- message_send_chat(chatwin->barejid, resource, encrypted, send_state);
+ message_send_chat(chatwin->barejid, encrypted);
otr_free_message(encrypted);
if (prefs_get_boolean(PREF_CHLOG)) {
const char *jid = jabber_get_fulljid();
@@ -1842,15 +1834,7 @@ cmd_execute_default(const char * inp)
cons_show_error("Failed to send message.");
}
} else {
- char *resource = NULL;
- gboolean send_state = FALSE;
- if (chat_session_exists(chatwin->barejid)) {
- resource = chat_session_get_resource(chatwin->barejid);
- send_state = chat_session_on_message_send(chatwin->barejid);
- } else {
- send_state = TRUE;
- }
- message_send_chat(chatwin->barejid, resource, inp, send_state);
+ message_send_chat(chatwin->barejid, inp);
if (prefs_get_boolean(PREF_CHLOG)) {
const char *jid = jabber_get_fulljid();
Jid *jidp = jid_create(jid);
@@ -1861,15 +1845,7 @@ cmd_execute_default(const char * inp)
ui_outgoing_chat_msg("me", chatwin->barejid, inp);
}
#else
- char *resource = NULL;
- gboolean send_state = FALSE;
- if (chat_session_exists(chatwin->barejid)) {
- resource = chat_session_get_resource(chatwin->barejid);
- send_state = chat_session_on_message_send(chatwin->barejid);
- } else {
- send_state = TRUE;
- }
- message_send_chat(chatwin->barejid, resource, inp, send_state);
+ message_send_chat(chatwin->barejid, inp);
if (prefs_get_boolean(PREF_CHLOG)) {
const char *jid = jabber_get_fulljid();
Jid *jidp = jid_create(jid);
diff --git a/src/command/commands.c b/src/command/commands.c
index 89fe9557..049582c0 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -1203,31 +1203,23 @@ cmd_msg(gchar **args, struct cmd_help_t help)
barejid = usr;
}
- // if msg to current recipient, and resource specified, set resource
- char *resource = NULL;
- ProfWin *current = wins_get_current();
- if (current->type == WIN_CHAT) {
- ProfChatWin *chatwin = (ProfChatWin*)current;
- assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
- if ((g_strcmp0(chatwin->barejid, barejid) == 0) && (chatwin->resource)) {
- resource = chatwin->resource;
- }
- }
+ // TODO if msg to current recipient, and resource specified, set resource
+// char *resource = NULL;
+// ProfWin *current = wins_get_current();
+// if (current->type == WIN_CHAT) {
+// ProfChatWin *chatwin = (ProfChatWin*)current;
+// assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
+// if ((g_strcmp0(chatwin->barejid, barejid) == 0) && (chatwin->resource)) {
+// resource = chatwin->resource;
+// }
+// }
if (msg != NULL) {
#ifdef HAVE_LIBOTR
if (otr_is_secure(barejid)) {
char *encrypted = otr_encrypt_message(barejid, msg);
if (encrypted != NULL) {
- resource = NULL;
- gboolean send_state = FALSE;
- if (chat_session_exists(barejid)) {
- resource = chat_session_get_resource(barejid);
- send_state = chat_session_on_message_send(barejid);
- } else {
- send_state = TRUE;
- }
- message_send_chat(barejid, resource, encrypted, send_state);
+ message_send_chat(barejid, encrypted);
otr_free_message(encrypted);
ui_outgoing_chat_msg("me", barejid, msg);
@@ -1256,27 +1248,11 @@ cmd_msg(gchar **args, struct cmd_help_t help)
GString *otr_message = g_string_new(msg);
g_string_append(otr_message, OTRL_MESSAGE_TAG_BASE);
g_string_append(otr_message, OTRL_MESSAGE_TAG_V2);
- resource = NULL;
- gboolean send_state = FALSE;
- if (chat_session_exists(barejid)) {
- resource = chat_session_get_resource(barejid);
- send_state = chat_session_on_message_send(barejid);
- } else {
- send_state = TRUE;
- }
- message_send_chat(barejid, resource, otr_message->str, send_state);
+ message_send_chat(barejid, otr_message->str);
g_string_free(otr_message, TRUE);
} else {
- resource = NULL;
- gboolean send_state = FALSE;
- if (chat_session_exists(barejid)) {
- resource = chat_session_get_resource(barejid);
- send_state = chat_session_on_message_send(barejid);
- } else {
- send_state = TRUE;
- }
- message_send_chat(barejid, resource, msg, send_state);
+ message_send_chat(barejid, msg);
}
ui_outgoing_chat_msg("me", barejid, msg);
@@ -1289,15 +1265,7 @@ cmd_msg(gchar **args, struct cmd_help_t help)
}
return TRUE;
#else
- resource = NULL;
- gboolean send_state = FALSE;
- if (chat_session_exists(barejid)) {
- resource = chat_session_get_resource(barejid);
- send_state = chat_session_on_message_send(barejid);
- } else {
- send_state = TRUE;
- }
- message_send_chat(barejid, resource, msg, send_state);
+ message_send_chat(barejid, msg);
ui_outgoing_chat_msg("me", barejid, msg);
if (((win_type == WIN_CHAT) || (win_type == WIN_CONSOLE)) && prefs_get_boolean(PREF_CHLOG)) {
@@ -3036,15 +3004,7 @@ cmd_tiny(gchar **args, struct cmd_help_t help)
if (otr_is_secure(chatwin->barejid)) {
char *encrypted = otr_encrypt_message(chatwin->barejid, tiny);
if (encrypted != NULL) {
- char *resource = NULL;
- gboolean send_state = FALSE;
- if (chat_session_exists(chatwin->barejid)) {
- resource = chat_session_get_resource(chatwin->barejid);
- send_state = chat_session_on_message_send(chatwin->barejid);
- } else {
- send_state = TRUE;
- }
- message_send_chat(chatwin->barejid, resource, encrypted, send_state);
+ message_send_chat(chatwin->barejid, encrypted);
otr_free_message(encrypted);
if (prefs_get_boolean(PREF_CHLOG)) {
const char *jid = jabber_get_fulljid();
@@ -3064,15 +3024,7 @@ cmd_tiny(gchar **args, struct cmd_help_t help)
cons_show_error("Failed to send message.");
}
} else {
- char *resource = NULL;
- gboolean send_state = FALSE;
- if (chat_session_exists(chatwin->barejid)) {
- resource = chat_session_get_resource(chatwin->barejid);
- send_state = chat_session_on_message_send(chatwin->barejid);
- } else {
- send_state = TRUE;
- }
- message_send_chat(chatwin->barejid, resource, tiny, send_state);
+ message_send_chat(chatwin->barejid, tiny);
if (prefs_get_boolean(PREF_CHLOG)) {
const char *jid = jabber_get_fulljid();
Jid *jidp = jid_create(jid);
@@ -3083,15 +3035,7 @@ cmd_tiny(gchar **args, struct cmd_help_t help)
ui_outgoing_chat_msg("me", chatwin->barejid, tiny);
}
#else
- char *resource = NULL;
- gboolean send_state = FALSE;
- if (chat_session_exists(chatwin->barejid)) {
- resource = chat_session_get_resource(chatwin->barejid);
- send_state = chat_session_on_message_send(chatwin->barejid);
- } else {
- send_state = TRUE;
- }
- message_send_chat(chatwin->barejid, resource, tiny, send_state);
+ message_send_chat(chatwin->barejid, tiny);
if (prefs_get_boolean(PREF_CHLOG)) {
const char *jid = jabber_get_fulljid();
Jid *jidp = jid_create(jid);
@@ -4008,15 +3952,7 @@ cmd_otr(gchar **args, struct cmd_help_t help)
ui_current_print_formatted_line('!', 0, "You have not generated or loaded a private key, use '/otr gen'");
} else if (!otr_is_secure(barejid)) {
char *otr_query_message = otr_start_query();
- char *resource = NULL;
- gboolean send_state = FALSE;
- if (chat_session_exists(barejid)) {
- resource = chat_session_get_resource(barejid);
- send_state = chat_session_on_message_send(barejid);
- } else {
- send_state = TRUE;
- }
- message_send_chat(barejid, resource, otr_query_message, send_state);
+ message_send_chat(barejid, otr_query_message);
} else {
ui_gone_secure(barejid, otr_is_trusted(barejid));
}
@@ -4034,15 +3970,7 @@ cmd_otr(gchar **args, struct cmd_help_t help)
} else {
ProfChatWin *chatwin = ui_get_current_chat();
char *otr_query_message = otr_start_query();
- char *resource = NULL;
- gboolean send_state = FALSE;
- if (chat_session_exists(chatwin->barejid)) {
- resource = chat_session_get_resource(chatwin->barejid);
- send_state = chat_session_on_message_send(chatwin->barejid);
- } else {
- send_state = TRUE;
- }
- message_send_chat(chatwin->barejid, resource, otr_query_message, send_state);
+ message_send_chat(chatwin->barejid, otr_query_message);
}
}
}
diff --git a/src/otr/otr.c b/src/otr/otr.c
index 8e579b87..bd1c2ce3 100644
--- a/src/otr/otr.c
+++ b/src/otr/otr.c
@@ -110,15 +110,7 @@ static void
cb_inject_message(void *opdata, const char *accountname,
const char *protocol, const char *recipient, const char *message)
{
- char *resource = NULL;
- gboolean send_state = FALSE;
- if (chat_session_exists(recipient)) {
- resource = chat_session_get_resource(recipient);
- send_state = chat_session_on_message_send(recipient);
- } else {
- send_state = TRUE;
- }
- message_send_chat(recipient, resource, message, send_state);
+ message_send_chat(recipient, message);
}
static void
diff --git a/src/server_events.c b/src/server_events.c
index f6874222..02522f98 100644
--- a/src/server_events.c
+++ b/src/server_events.c
@@ -318,15 +318,7 @@ handle_incoming_message(char *barejid, char *message)
memmove(whitespace_base, whitespace_base+tag_length, tag_length);
char *otr_query_message = otr_start_query();
cons_show("OTR Whitespace pattern detected. Attempting to start OTR session...");
- char *resource = NULL;
- gboolean send_state = FALSE;
- if (chat_session_exists(barejid)) {
- resource = chat_session_get_resource(barejid);
- send_state = chat_session_on_message_send(barejid);
- } else {
- send_state = TRUE;
- }
- message_send_chat(barejid, resource, otr_query_message, send_state);
+ message_send_chat(barejid, otr_query_message);
}
}
}
@@ -340,15 +332,7 @@ handle_incoming_message(char *barejid, char *message)
if (policy == PROF_OTRPOLICY_ALWAYS && !was_decrypted && !whitespace_base) {
char *otr_query_message = otr_start_query();
cons_show("Attempting to start OTR session...");
- char *resource = NULL;
- gboolean send_state = FALSE;
- if (chat_session_exists(barejid)) {
- resource = chat_session_get_resource(barejid);
- send_state = chat_session_on_message_send(barejid);
- } else {
- send_state = TRUE;
- }
- message_send_chat(barejid, resource, otr_query_message, send_state);
+ message_send_chat(barejid, otr_query_message);
}
ui_incoming_msg(barejid, newmessage, NULL);
diff --git a/src/ui/core.c b/src/ui/core.c
index 2e8ae9ff..d5e01d94 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -705,7 +705,9 @@ ui_close_connected_win(int index)
otr_end_session(chatwin->barejid);
}
#endif
- chat_session_on_window_close(chatwin->barejid);
+ if (chat_session_exists(chatwin->barejid)) {
+ chat_session_on_window_close(chatwin->barejid);
+ }
}
}
}
@@ -1162,7 +1164,9 @@ ui_prune_wins(void)
if (window->type == WIN_CHAT) {
if (conn_status == JABBER_CONNECTED) {
ProfChatWin *chatwin = (ProfChatWin*)window;
- chat_session_on_window_close(chatwin->barejid);
+ if (chat_session_exists(chatwin->barejid)) {
+ chat_session_on_window_close(chatwin->barejid);
+ }
}
}
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 4165bd3f..19318745 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -151,17 +151,11 @@ inp_get_char(char *input, int *size, int *result)
in_command = TRUE;
}
- if (prefs_get_boolean(PREF_STATES)) {
- if (*result == ERR) {
- prof_handle_idle();
- }
- if (prefs_get_boolean(PREF_OUTTYPE)
- && (*result != ERR)
- && (*result != KEY_CODE_YES)
- && !in_command
- && _printable(ch)) {
- prof_handle_activity();
- }
+ if (*result == ERR) {
+ prof_handle_idle();
+ }
+ if ((*result != ERR) && (*result != KEY_CODE_YES) && !in_command && _printable(ch)) {
+ prof_handle_activity();
}
// if it wasn't an arrow key etc
diff --git a/src/xmpp/message.c b/src/xmpp/message.c
index 4b2a517f..6d1eda43 100644
--- a/src/xmpp/message.c
+++ b/src/xmpp/message.c
@@ -80,19 +80,29 @@ message_add_handlers(void)
}
void
-message_send_chat(const char * const barejid, const char * const resource, const char * const msg, gboolean send_state)
+message_send_chat(const char * const barejid, const char * const msg)
{
xmpp_stanza_t *message;
xmpp_conn_t * const conn = connection_get_conn();
xmpp_ctx_t * const ctx = connection_get_ctx();
+ char *resource = NULL;
+ gboolean send_state = FALSE;
+ if (chat_session_exists(barejid)) {
+ chat_session_on_message_send(barejid);
+ resource = chat_session_get_resource(barejid);
+ send_state = chat_session_send_states(barejid);
+ } else {
+ send_state = TRUE;
+ }
+
GString *jid = g_string_new(barejid);
if (resource) {
g_string_append(jid, "/");
g_string_append(jid, resource);
}
- if (send_state) {
+ if (prefs_get_boolean(PREF_STATES) && send_state) {
message = stanza_create_message(ctx, jid->str, STANZA_TYPE_CHAT, msg, STANZA_NAME_ACTIVE);
} else {
message = stanza_create_message(ctx, jid->str, STANZA_TYPE_CHAT, msg, NULL);
@@ -149,22 +159,22 @@ message_send_invite(const char * const roomjid, const char * const contact,
}
void
-message_send_composing(const char * const fulljid)
+message_send_composing(const char * const jid)
{
xmpp_conn_t * const conn = connection_get_conn();
xmpp_ctx_t * const ctx = connection_get_ctx();
- xmpp_stanza_t *stanza = stanza_create_chat_state(ctx, fulljid, STANZA_NAME_COMPOSING);
+ xmpp_stanza_t *stanza = stanza_create_chat_state(ctx, jid, STANZA_NAME_COMPOSING);
xmpp_send(conn, stanza);
xmpp_stanza_release(stanza);
}
void
-message_send_paused(const char * const fulljid)
+message_send_paused(const char * const jid)
{
xmpp_conn_t * const conn = connection_get_conn();
xmpp_ctx_t * const ctx = connection_get_ctx();
- xmpp_stanza_t *stanza = stanza_create_chat_state(ctx, fulljid,
+ xmpp_stanza_t *stanza = stanza_create_chat_state(ctx, jid,
STANZA_NAME_PAUSED);
xmpp_send(conn, stanza);
@@ -172,11 +182,11 @@ message_send_paused(const char * const fulljid)
}
void
-message_send_inactive(const char * const fulljid)
+message_send_inactive(const char * const jid)
{
xmpp_conn_t * const conn = connection_get_conn();
xmpp_ctx_t * const ctx = connection_get_ctx();
- xmpp_stanza_t *stanza = stanza_create_chat_state(ctx, fulljid,
+ xmpp_stanza_t *stanza = stanza_create_chat_state(ctx, jid,
STANZA_NAME_INACTIVE);
xmpp_send(conn, stanza);
@@ -184,11 +194,11 @@ message_send_inactive(const char * const fulljid)
}
void
-message_send_gone(const char * const fulljid)
+message_send_gone(const char * const jid)
{
xmpp_conn_t * const conn = connection_get_conn();
xmpp_ctx_t * const ctx = connection_get_ctx();
- xmpp_stanza_t *stanza = stanza_create_chat_state(ctx, fulljid,
+ xmpp_stanza_t *stanza = stanza_create_chat_state(ctx, jid,
STANZA_NAME_GONE);
xmpp_send(conn, stanza);
diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h
index d4d35c6b..161eebdf 100644
--- a/src/xmpp/xmpp.h
+++ b/src/xmpp/xmpp.h
@@ -145,16 +145,15 @@ char* jabber_get_account_name(void);
GList * jabber_get_available_resources(void);
// message functions
-void message_send_chat(const char * const barejid, const char * const resource, const char * const msg,
- gboolean send_state);
+void message_send_chat(const char * const barejid, const char * const msg);
void message_send_private(const char * const fulljid, const char * const msg);
void message_send_groupchat(const char * const roomjid, const char * const msg);
void message_send_groupchat_subject(const char * const roomjid, const char * const subject);
-void message_send_inactive(const char * const fulljid);
-void message_send_composing(const char * const fulljid);
-void message_send_paused(const char * const fulljid);
-void message_send_gone(const char * const fulljid);
+void message_send_inactive(const char * const jid);
+void message_send_composing(const char * const jid);
+void message_send_paused(const char * const jid);
+void message_send_gone(const char * const jid);
void message_send_invite(const char * const room, const char * const contact,
const char * const reason);
diff --git a/tests/test_cmd_otr.c b/tests/test_cmd_otr.c
index 3cd9dd59..7d0adc1a 100644
--- a/tests/test_cmd_otr.c
+++ b/tests/test_cmd_otr.c
@@ -552,9 +552,7 @@ cmd_otr_start_sends_otr_query_message_to_current_recipeint(void **state)
will_return(otr_start_query, query_message);
expect_string(message_send_chat, barejid, chatwin->barejid);
- expect_value(message_send_chat, resource, NULL);
expect_string(message_send_chat, msg, query_message);
- expect_any(message_send_chat, send_state);
gboolean result = cmd_otr(args, *help);
assert_true(result);
diff --git a/tests/test_server_events.c b/tests/test_server_events.c
index 67d4ecb2..db74e8f3 100644
--- a/tests/test_server_events.c
+++ b/tests/test_server_events.c
@@ -141,9 +141,10 @@ void handle_message_error_when_recipient_cancel_disables_chat_session(void **sta
expect_any(ui_handle_recipient_not_found, err_msg);
handle_message_error(from, type, err_msg);
- gboolean chat_session_supported = chat_session_on_message_send(from);
+ chat_session_on_message_send(from);
+ gboolean send_states = chat_session_send_states(from);
- assert_false(chat_session_supported);
+ assert_false(send_states);
chat_sessions_clear();
}
diff --git a/tests/xmpp/stub_xmpp.c b/tests/xmpp/stub_xmpp.c
index 580a6c61..a6058058 100644
--- a/tests/xmpp/stub_xmpp.c
+++ b/tests/xmpp/stub_xmpp.c
@@ -58,13 +58,10 @@ GList * jabber_get_available_resources(void)
}
// message functions
-void message_send_chat(const char * const barejid, const char * const resource, const char * const msg,
- gboolean send_state)
+void message_send_chat(const char * const barejid, const char * const msg)
{
check_expected(barejid);
- check_expected(resource);
check_expected(msg);
- check_expected(send_state);
}
void message_send_private(const char * const fulljid, const char * const msg) {}
@@ -218,4 +215,4 @@ void roster_send_add_new(const char * const barejid, const char * const name)
void roster_send_remove(const char * const barejid)
{
check_expected(barejid);
-} \ No newline at end of file
+}