diff options
author | James Booth <boothj5@gmail.com> | 2015-04-28 23:57:28 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2015-04-28 23:57:28 +0100 |
commit | 5d827cafec736050f101a407aa281ddc2bb2c60d (patch) | |
tree | 12834644d17aebb7342d377a0eb7e0d8b5bbc2e6 | |
parent | 43189b1ab428444ba5a0bca088cd7b55293b9540 (diff) | |
parent | d3698e6bee7985cd1707ec7b50fe61a5bf0c2829 (diff) | |
download | profani-tty-5d827cafec736050f101a407aa281ddc2bb2c60d.tar.gz |
Merge branch 'master' into pgp
Conflicts: src/xmpp/message.c
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | src/command/commands.c | 33 | ||||
-rw-r--r-- | src/event/client_events.c | 23 | ||||
-rw-r--r-- | src/event/client_events.h | 13 | ||||
-rw-r--r-- | src/event/server_events.c | 130 | ||||
-rw-r--r-- | src/event/server_events.h | 130 | ||||
-rw-r--r-- | src/event/ui_events.c | 48 | ||||
-rw-r--r-- | src/event/ui_events.h | 41 | ||||
-rw-r--r-- | src/ui/core.c | 26 | ||||
-rw-r--r-- | src/xmpp/connection.c | 10 | ||||
-rw-r--r-- | src/xmpp/iq.c | 56 | ||||
-rw-r--r-- | src/xmpp/message.c | 46 | ||||
-rw-r--r-- | src/xmpp/presence.c | 34 | ||||
-rw-r--r-- | src/xmpp/roster.c | 12 | ||||
-rw-r--r-- | tests/test_server_events.c | 28 |
15 files changed, 341 insertions, 291 deletions
diff --git a/Makefile.am b/Makefile.am index 0963e3a5..4f7f2c3d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -15,6 +15,7 @@ core_sources = \ src/xmpp/form.c src/xmpp/form.h \ src/event/server_events.c src/event/server_events.h \ src/event/client_events.c src/event/client_events.h \ + src/event/ui_events.c src/event/ui_events.h \ src/ui/ui.h src/ui/window.c src/ui/window.h src/ui/core.c \ src/ui/titlebar.c src/ui/statusbar.c src/ui/inputwin.c \ src/ui/titlebar.h src/ui/statusbar.h src/ui/inputwin.h \ @@ -64,6 +65,7 @@ tests_sources = \ src/ui/titlebar.h src/ui/statusbar.h src/ui/inputwin.h \ src/event/server_events.c src/event/server_events.h \ src/event/client_events.c src/event/client_events.h \ + src/event/ui_events.c src/event/ui_events.h \ tests/xmpp/stub_xmpp.c \ tests/ui/stub_ui.c \ tests/pgp/stub_gpg.c \ diff --git a/src/command/commands.c b/src/command/commands.c index 677d1b5b..e054577b 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -69,6 +69,7 @@ #include "ui/ui.h" #include "ui/windows.h" #include "event/client_events.h" +#include "event/ui_events.h" static void _update_presence(const resource_presence_t presence, const char * const show, gchar **args); @@ -112,19 +113,19 @@ cmd_execute_default(const char * inp) case WIN_CHAT: { ProfChatWin *chatwin = wins_get_current_chat(); - client_send_msg(chatwin->barejid, inp); + cl_ev_send_msg(chatwin->barejid, inp); break; } case WIN_PRIVATE: { ProfPrivateWin *privatewin = wins_get_current_private(); - client_send_priv_msg(privatewin->fulljid, inp); + cl_ev_send_priv_msg(privatewin->fulljid, inp); break; } case WIN_MUC: { ProfMucWin *mucwin = wins_get_current_muc(); - client_send_muc_msg(mucwin->roomjid, inp); + cl_ev_send_muc_msg(mucwin->roomjid, inp); break; } default: @@ -211,13 +212,13 @@ cmd_connect(gchar **args, struct cmd_help_t help) if (account) { // use password if set if (account->password) { - conn_status = client_connect_account(account); + conn_status = cl_ev_connect_account(account); // use eval_password if set } else if (account->eval_password) { gboolean res = account_eval_password(account); if (res) { - conn_status = client_connect_account(account); + conn_status = cl_ev_connect_account(account); free(account->password); account->password = NULL; } else { @@ -229,7 +230,7 @@ cmd_connect(gchar **args, struct cmd_help_t help) // no account password setting, prompt } else { account->password = ui_ask_password(); - conn_status = client_connect_account(account); + conn_status = cl_ev_connect_account(account); free(account->password); account->password = NULL; } @@ -240,7 +241,7 @@ cmd_connect(gchar **args, struct cmd_help_t help) } else { jid = strdup(lower); char *passwd = ui_ask_password(); - conn_status = client_connect_jid(jid, passwd, altdomain, port); + conn_status = cl_ev_connect_jid(jid, passwd, altdomain, port); free(passwd); } @@ -1317,7 +1318,7 @@ cmd_msg(gchar **args, struct cmd_help_t help) g_string_append(full_jid, usr); if (msg) { - client_send_priv_msg(full_jid->str, msg); + cl_ev_send_priv_msg(full_jid->str, msg); } else { ui_new_private_win(full_jid->str); } @@ -1338,14 +1339,14 @@ cmd_msg(gchar **args, struct cmd_help_t help) } if (msg) { - client_send_msg(barejid, msg); + cl_ev_send_msg(barejid, msg); return TRUE; } else { ProfWin *window = (ProfWin*)wins_get_chat(barejid); if (window) { - client_focus_win(window); + ui_ev_focus_win(window); } else { - client_new_chat_win(barejid); + ui_ev_new_chat_win(barejid); } #ifdef HAVE_LIBOTR @@ -3152,19 +3153,19 @@ cmd_tiny(gchar **args, struct cmd_help_t help) case WIN_CHAT: { ProfChatWin *chatwin = wins_get_current_chat(); - client_send_msg(chatwin->barejid, tiny); + cl_ev_send_msg(chatwin->barejid, tiny); break; } case WIN_PRIVATE: { ProfPrivateWin *privatewin = wins_get_current_private(); - client_send_priv_msg(privatewin->fulljid, tiny); + cl_ev_send_priv_msg(privatewin->fulljid, tiny); break; } case WIN_MUC: { ProfMucWin *mucwin = wins_get_current_muc(); - client_send_muc_msg(mucwin->roomjid, tiny); + cl_ev_send_muc_msg(mucwin->roomjid, tiny); break; } default: @@ -4237,9 +4238,9 @@ cmd_otr(gchar **args, struct cmd_help_t help) ProfWin *window = (ProfWin*)wins_get_chat(barejid); if (window) { - client_focus_win(window); + ui_ev_focus_win(window); } else { - client_new_chat_win(barejid); + ui_ev_new_chat_win(barejid); } if (ui_current_win_is_otr()) { diff --git a/src/event/client_events.c b/src/event/client_events.c index 2aa66d08..70de5f6c 100644 --- a/src/event/client_events.c +++ b/src/event/client_events.c @@ -43,14 +43,14 @@ #endif jabber_conn_status_t -client_connect_jid(const char * const jid, const char * const passwd, const char * const altdomain, const int port) +cl_ev_connect_jid(const char * const jid, const char * const passwd, const char * const altdomain, const int port) { cons_show("Connecting as %s", jid); return jabber_connect_with_details(jid, passwd, altdomain, port); } jabber_conn_status_t -client_connect_account(ProfAccount *account) +cl_ev_connect_account(ProfAccount *account) { char *jid = account_create_full_jid(account); cons_show("Connecting with account %s as %s", account->name, jid); @@ -60,7 +60,7 @@ client_connect_account(ProfAccount *account) } void -client_send_msg(const char * const barejid, const char * const msg) +cl_ev_send_msg(const char * const barejid, const char * const msg) { #ifdef HAVE_LIBOTR otr_on_message_send(barejid, msg); @@ -73,27 +73,14 @@ client_send_msg(const char * const barejid, const char * const msg) } void -client_send_muc_msg(const char * const roomjid, const char * const msg) +cl_ev_send_muc_msg(const char * const roomjid, const char * const msg) { message_send_groupchat(roomjid, msg); } void -client_send_priv_msg(const char * const fulljid, const char * const msg) +cl_ev_send_priv_msg(const char * const fulljid, const char * const msg) { message_send_private(fulljid, msg); ui_outgoing_private_msg(fulljid, msg); -} - -void -client_focus_win(ProfWin *win) -{ - ui_switch_win(win); -} - -void -client_new_chat_win(const char * const barejid) -{ - ProfWin *win = ui_new_chat_win(barejid); - ui_switch_win(win); } \ No newline at end of file diff --git a/src/event/client_events.h b/src/event/client_events.h index efa535c9..fcf26523 100644 --- a/src/event/client_events.h +++ b/src/event/client_events.h @@ -35,14 +35,11 @@ #ifndef CLIENT_EVENTS_H #define CLIENT_EVENTS_H -jabber_conn_status_t client_connect_jid(const char * const jid, const char * const passwd, const char * const altdomain, const int port); -jabber_conn_status_t client_connect_account(ProfAccount *account); +jabber_conn_status_t cl_ev_connect_jid(const char * const jid, const char * const passwd, const char * const altdomain, const int port); +jabber_conn_status_t cl_ev_connect_account(ProfAccount *account); -void client_send_msg(const char * const barejid, const char * const msg); -void client_send_muc_msg(const char * const roomjid, const char * const msg); -void client_send_priv_msg(const char * const fulljid, const char * const msg); - -void client_focus_win(ProfWin *win); -void client_new_chat_win(const char * const barejid); +void cl_ev_send_msg(const char * const barejid, const char * const msg); +void cl_ev_send_muc_msg(const char * const roomjid, const char * const msg); +void cl_ev_send_priv_msg(const char * const fulljid, const char * const msg); #endif \ No newline at end of file diff --git a/src/event/server_events.c b/src/event/server_events.c index 514835ba..56d5b11f 100644 --- a/src/event/server_events.c +++ b/src/event/server_events.c @@ -51,7 +51,7 @@ #include "ui/ui.h" void -srv_room_join_error(const char * const room, const char * const err) +sv_ev_room_join_error(const char * const room, const char * const err) { if (muc_active(room)) { muc_leave(room); @@ -61,7 +61,7 @@ srv_room_join_error(const char * const room, const char * const err) // handle presence stanza errors void -srv_presence_error(const char *from, const char * const type, +sv_ev_presence_error(const char *from, const char * const type, const char *err_msg) { // handle error from recipient @@ -76,7 +76,7 @@ srv_presence_error(const char *from, const char * const type, // handle message stanza errors void -srv_message_error(const char * const jid, const char * const type, +sv_ev_message_error(const char * const jid, const char * const type, const char * const err_msg) { // handle errors from no recipient @@ -96,7 +96,7 @@ srv_message_error(const char * const jid, const char * const type, } void -srv_login_account_success(char *account_name) +sv_ev_login_account_success(char *account_name) { ProfAccount *account = accounts_get_account(account_name); @@ -123,7 +123,7 @@ srv_login_account_success(char *account_name) } void -srv_roster_received(void) +sv_ev_roster_received(void) { if (prefs_get_boolean(PREF_ROSTER)) { ui_show_roster(); @@ -131,7 +131,7 @@ srv_roster_received(void) } void -srv_lost_connection(void) +sv_ev_lost_connection(void) { cons_show_error("Lost connection."); roster_clear(); @@ -141,27 +141,27 @@ srv_lost_connection(void) } void -srv_failed_login(void) +sv_ev_failed_login(void) { cons_show_error("Login failed."); log_info("Login failed"); } void -srv_software_version_result(const char * const jid, const char * const presence, +sv_ev_software_version_result(const char * const jid, const char * const presence, const char * const name, const char * const version, const char * const os) { cons_show_software_version(jid, presence, name, version, os); } void -srv_disco_info(const char *from, GSList *identities, GSList *features) +sv_ev_disco_info(const char *from, GSList *identities, GSList *features) { cons_show_disco_info(from, identities, features); } void -srv_room_disco_info(const char * const room, GSList *identities, GSList *features, gboolean display) +sv_ev_room_disco_info(const char * const room, GSList *identities, GSList *features, gboolean display) { muc_set_features(room, features); if (display) { @@ -170,7 +170,7 @@ srv_room_disco_info(const char * const room, GSList *identities, GSList *feature } void -srv_disco_info_error(const char * const from, const char * const error) +sv_ev_disco_info_error(const char * const from, const char * const error) { if (from) { cons_show_error("Service discovery failed for %s: %s", from, error); @@ -180,31 +180,31 @@ srv_disco_info_error(const char * const from, const char * const error) } void -srv_enable_carbons_error(const char * const error) +sv_ev_enable_carbons_error(const char * const error) { cons_show_error("Server error enabling message carbons: %s", error); } void -srv_disable_carbons_error(const char * const error) +sv_ev_disable_carbons_error(const char * const error) { cons_show_error("Server error disabling message carbons: %s", error); } void -srv_room_info_error(const char * const room, const char * const error) +sv_ev_room_info_error(const char * const room, const char * const error) { ui_handle_room_info_error(room, error); } void -srv_room_list(GSList *rooms, const char *conference_node) +sv_ev_room_list(GSList *rooms, const char *conference_node) { cons_show_room_list(rooms, conference_node); } void -srv_room_affiliation_list_result_error(const char * const room, const char * const affiliation, +sv_ev_room_affiliation_list_result_error(const char * const room, const char * const affiliation, const char * const error) { log_debug("Error retrieving %s list for room %s: %s", affiliation, room, error); @@ -212,14 +212,14 @@ srv_room_affiliation_list_result_error(const char * const room, const char * con } void -srv_room_affiliation_list(const char * const room, const char * const affiliation, GSList *jids) +sv_ev_room_affiliation_list(const char * const room, const char * const affiliation, GSList *jids) { muc_jid_autocomplete_add_all(room, jids); ui_handle_room_affiliation_list(room, affiliation, jids); } void -srv_room_role_set_error(const char * const room, const char * const nick, const char * const role, +sv_ev_room_role_set_error(const char * const room, const char * const nick, const char * const role, const char * const error) { log_debug("Error setting role %s list for room %s, user %s: %s", role, room, nick, error); @@ -227,20 +227,20 @@ srv_room_role_set_error(const char * const room, const char * const nick, const } void -srv_room_role_list_result_error(const char * const room, const char * const role, const char * const error) +sv_ev_room_role_list_result_error(const char * const room, const char * const role, const char * const error) { log_debug("Error retrieving %s list for room %s: %s", role, room, error); ui_handle_room_role_list_error(room, role, error); } void -srv_room_role_list(const char * const room, const char * const role, GSList *nicks) +sv_ev_room_role_list(const char * const room, const char * const role, GSList *nicks) { ui_handle_room_role_list(room, role, nicks); } void -srv_room_affiliation_set_error(const char * const room, const char * const jid, const char * const affiliation, +sv_ev_room_affiliation_set_error(const char * const room, const char * const jid, const char * const affiliation, const char * const error) { log_debug("Error setting affiliation %s list for room %s, user %s: %s", affiliation, room, jid, error); @@ -248,13 +248,13 @@ srv_room_affiliation_set_error(const char * const room, const char * const jid, } void -srv_disco_items(GSList *items, const char *jid) +sv_ev_disco_items(GSList *items, const char *jid) { cons_show_disco_items(items, jid); } void -srv_room_invite(jabber_invite_t invite_type, +sv_ev_room_invite(jabber_invite_t invite_type, const char * const invitor, const char * const room, const char * const reason, const char * const password) { @@ -265,7 +265,7 @@ srv_room_invite(jabber_invite_t invite_type, } void -srv_room_broadcast(const char *const room_jid, +sv_ev_room_broadcast(const char *const room_jid, const char * const message) { if (muc_roster_complete(room_jid)) { @@ -276,7 +276,7 @@ srv_room_broadcast(const char *const room_jid, } void -srv_room_subject(const char * const room, const char * const nick, const char * const subject) +sv_ev_room_subject(const char * const room, const char * const nick, const char * const subject) { muc_set_subject(room, subject); if (muc_roster_complete(room)) { @@ -285,14 +285,14 @@ srv_room_subject(const char * const room, const char * const nick, const char * } void -srv_room_history(const char * const room_jid, const char * const nick, +sv_ev_room_history(const char * const room_jid, const char * const nick, GTimeVal tv_stamp, const char * const message) { ui_room_history(room_jid, nick, tv_stamp, message); } void -srv_room_message(const char * const room_jid, const char * const nick, +sv_ev_room_message(const char * const room_jid, const char * const nick, const char * const message) { ui_room_message(room_jid, nick, message); @@ -305,19 +305,19 @@ srv_room_message(const char * const room_jid, const char * const nick, } void -srv_incoming_private_message(char *fulljid, char *message) +sv_ev_incoming_private_message(char *fulljid, char *message) { ui_incoming_private_msg(fulljid, message, NULL); } void -srv_carbon(char *barejid, char *message) +sv_ev_carbon(char *barejid, char *message) { ui_outgoing_chat_msg_carbon(barejid, message); } void -srv_incoming_message(char *barejid, char *resource, char *message) +sv_ev_incoming_message(char *barejid, char *resource, char *message) { #ifdef HAVE_LIBOTR otr_on_message_recv(barejid, resource, message); @@ -328,26 +328,26 @@ srv_incoming_message(char *barejid, char *resource, char *message) } void -srv_delayed_private_message(char *fulljid, char *message, GTimeVal tv_stamp) +sv_ev_delayed_private_message(char *fulljid, char *message, GTimeVal tv_stamp) { ui_incoming_private_msg(fulljid, message, &tv_stamp); } void -srv_delayed_message(char *barejid, char *message, GTimeVal tv_stamp) +sv_ev_delayed_message(char *barejid, char *message, GTimeVal tv_stamp) { ui_incoming_msg(barejid, NULL, message, &tv_stamp); chat_log_msg_in_delayed(barejid, message, &tv_stamp); } void -srv_message_receipt(char *barejid, char *id) +sv_ev_message_receipt(char *barejid, char *id) { ui_message_receipt(barejid, id); } void -srv_typing(char *barejid, char *resource) +sv_ev_typing(char *barejid, char *resource) { ui_contact_typing(barejid, resource); if (ui_chat_win_exists(barejid)) { @@ -356,7 +356,7 @@ srv_typing(char *barejid, char *resource) } void -srv_paused(char *barejid, char *resource) +sv_ev_paused(char *barejid, char *resource) { if (ui_chat_win_exists(barejid)) { chat_session_recipient_paused(barejid, resource); @@ -364,7 +364,7 @@ srv_paused(char *barejid, char *resource) } void -srv_inactive(char *barejid, char *resource) +sv_ev_inactive(char *barejid, char *resource) { if (ui_chat_win_exists(barejid)) { chat_session_recipient_inactive(barejid, resource); @@ -372,7 +372,7 @@ srv_inactive(char *barejid, char *resource) } void -srv_gone(const char * const barejid, const char * const resource) +sv_ev_gone(const char * const barejid, const char * const resource) { ui_recipient_gone(barejid, resource); if (ui_chat_win_exists(barejid)) { @@ -381,7 +381,7 @@ srv_gone(const char * const barejid, const char * const resource) } void -srv_activity(const char * const barejid, const char * const resource, gboolean send_states) +sv_ev_activity(const char * const barejid, const char * const resource, gboolean send_states) { if (ui_chat_win_exists(barejid)) { chat_session_recipient_active(barejid, resource, send_states); @@ -389,7 +389,7 @@ srv_activity(const char * const barejid, const char * const resource, gboolean s } void -srv_subscription(const char *barejid, jabber_subscr_t type) +sv_ev_subscription(const char *barejid, jabber_subscr_t type) { switch (type) { case PRESENCE_SUBSCRIBE: @@ -418,7 +418,7 @@ srv_subscription(const char *barejid, jabber_subscr_t type) } void -srv_contact_offline(char *barejid, char *resource, char *status) +sv_ev_contact_offline(char *barejid, char *resource, char *status) { gboolean updated = roster_contact_offline(barejid, resource, status); @@ -431,7 +431,7 @@ srv_contact_offline(char *barejid, char *resource, char *status) } void -srv_contact_online(char *barejid, Resource *resource, +sv_ev_contact_online(char *barejid, Resource *resource, GDateTime *last_activity) { gboolean updated = roster_update_presence(barejid, resource, last_activity); @@ -474,21 +474,21 @@ srv_contact_online(char *barejid, Resource *resource, } void -srv_leave_room(const char * const room) +sv_ev_leave_room(const char * const room) { muc_leave(room); ui_leave_room(room); } void -srv_room_destroy(const char * const room) +sv_ev_room_destroy(const char * const room) { muc_leave(room); ui_room_destroy(room); } void -srv_room_destroyed(const char * const room, const char * const new_jid, const char * const password, +sv_ev_room_destroyed(const char * const room, const char * const new_jid, const char * const password, const char * const reason) { muc_leave(room); @@ -496,51 +496,51 @@ srv_room_destroyed(const char * const room, const char * const new_jid, const ch } void -srv_room_kicked(const char * const room, const char * const actor, const char * const reason) +sv_ev_room_kicked(const char * const room, const char * const actor, const char * const reason) { muc_leave(room); ui_room_kicked(room, actor, reason); } void -srv_room_banned(const char * const room, const char * const actor, const char * const reason) +sv_ev_room_banned(const char * const room, const char * const actor, const char * const reason) { muc_leave(room); ui_room_banned(room, actor, reason); } void -srv_room_configure(const char * const room, DataForm *form) +sv_ev_room_configure(const char * const room, DataForm *form) { ui_handle_room_configuration(room, form); } void -srv_room_configuration_form_error(const char * const room, const char * const message) +sv_ev_room_configuration_form_error(const char * const room, const char * const message) { ui_handle_room_configuration_form_error(room, message); } void -srv_room_config_submit_result(const char * const room) +sv_ev_room_config_submit_result(const char * const room) { ui_handle_room_config_submit_result(room); } void -srv_room_config_submit_result_error(const char * const room, const char * const message) +sv_ev_room_config_submit_result_error(const char * const room, const char * const message) { ui_handle_room_config_submit_result_error(room, message); } void -srv_room_kick_result_error(const char * const room, const char * const nick, const char * const error) +sv_ev_room_kick_result_error(const char * const room, const char * const nick, const char * const error) { ui_handle_room_kick_error(room, nick, error); } void -srv_room_occupant_offline(const char * const room, const char * const nick, +sv_ev_room_occupant_offline(const char * const room, const char * const nick, const char * const show, const char * const status) { muc_roster_remove(room, nick); @@ -554,7 +554,7 @@ srv_room_occupant_offline(const char * const room, const char * const nick, } void -srv_room_occupent_kicked(const char * const room, const char * const nick, const char * const actor, +sv_ev_room_occupent_kicked(const char * const room, const char * const nick, const char * const actor, const char * const reason) { muc_roster_remove(room, nick); @@ -563,7 +563,7 @@ srv_room_occupent_kicked(const char * const room, const char * const nick, const } void -srv_room_occupent_banned(const char * const room, const char * const nick, const char * const actor, +sv_ev_room_occupent_banned(const char * const room, const char * const nick, const char * const actor, const char * const reason) { muc_roster_remove(room, nick); @@ -572,33 +572,33 @@ srv_room_occupent_banned(const char * const room, const char * const nick, const } void -srv_group_add(const char * const contact, +sv_ev_group_add(const char * const contact, const char * const group) { ui_group_added(contact, group); } void -srv_group_remove(const char * const contact, +sv_ev_group_remove(const char * const contact, const char * const group) { ui_group_removed(contact, group); } void -srv_roster_remove(const char * const barejid) +sv_ev_roster_remove(const char * const barejid) { ui_roster_remove(barejid); } void -srv_roster_add(const char * const barejid, const char * const name) +sv_ev_roster_add(const char * const barejid, const char * const name) { ui_roster_add(barejid, name); } void -srv_roster_update(const char * const barejid, const char * const name, +sv_ev_roster_update(const char * const barejid, const char * const name, GSList *groups, const char * const subscription, gboolean pending_out) { roster_update(barejid, name, groups, subscription, pending_out); @@ -606,20 +606,20 @@ srv_roster_update(const char * const barejid, const char * const name, } void -srv_autoping_cancel(void) +sv_ev_autoping_cancel(void) { prefs_set_autoping(0); cons_show_error("Server ping not supported, autoping disabled."); } void -srv_xmpp_stanza(const char * const msg) +sv_ev_xmpp_stanza(const char * const msg) { ui_handle_stanza(msg); } void -srv_ping_result(const char * const from, int millis) +sv_ev_ping_result(const char * const from, int millis) { if (from == NULL) { cons_show("Ping response from server: %dms.", millis); @@ -629,7 +629,7 @@ srv_ping_result(const char * const from, int millis) } void -srv_ping_error_result(const char * const from, const char * const error) +sv_ev_ping_error_result(const char * const from, const char * const error) { if (error == NULL) { cons_show_error("Error returned from pinging %s.", from); @@ -639,7 +639,7 @@ srv_ping_error_result(const char * const from, const char * const error) } void -srv_muc_self_online(const char * const room, const char * const nick, gboolean config_required, +sv_ev_muc_self_online(const char * const room, const char * const nick, gboolean config_required, const char * const role, const char * const affiliation, const char * const actor, const char * const reason, const char * const jid, const char * const show, const char * const status) { @@ -716,7 +716,7 @@ srv_muc_self_online(const char * const room, const char * const nick, gboolean c } void -srv_muc_occupant_online(const char * const room, const char * const nick, const char * const jid, +sv_ev_muc_occupant_online(const char * const room, const char * const nick, const char * const jid, const char * const role, const char * const affiliation, const char * const actor, const char * const reason, const char * const show, const char * const status) { diff --git a/src/event/server_events.h b/src/event/server_events.h index acba1391..daf885b3 100644 --- a/src/event/server_events.h +++ b/src/event/server_events.h @@ -37,93 +37,93 @@ #include "xmpp/xmpp.h" -void srv_login_account_success(char *account_name); -void srv_lost_connection(void); -void srv_failed_login(void); -void srv_software_version_result(const char * const jid, const char * const presence, +void sv_ev_login_account_success(char *account_name); +void sv_ev_lost_connection(void); +void sv_ev_failed_login(void); +void sv_ev_software_version_result(const char * const jid, const char * const presence, const char * const name, const char * const version, const char * const os); -void srv_disco_info(const char *from, GSList *identities, GSList *features); -void srv_disco_info_error(const char * const from, const char * const error); -void srv_room_list(GSList *rooms, const char *conference_node); -void srv_disco_items(GSList *items, const char *jid); -void srv_room_invite(jabber_invite_t invite_type, +void sv_ev_disco_info(const char *from, GSList *identities, GSList *features); +void sv_ev_disco_info_error(const char * const from, const char * const error); +void sv_ev_room_list(GSList *rooms, const char *conference_node); +void sv_ev_disco_items(GSList *items, const char *jid); +void sv_ev_room_invite(jabber_invite_t invite_type, const char * const invitor, const char * const room, const char * const reason, const char * const password); -void srv_room_broadcast(const char *const room_jid, +void sv_ev_room_broadcast(const char *const room_jid, const char * const message); -void srv_room_subject(const char * const room, const char * const nick, const char * const subject); -void srv_room_history(const char * const room_jid, const char * const nick, +void sv_ev_room_subject(const char * const room, const char * const nick, const char * const subject); +void sv_ev_room_history(const char * const room_jid, const char * const nick, GTimeVal tv_stamp, const char * const message); -void srv_room_message(const char * const room_jid, const char * const nick, +void sv_ev_room_message(const char * const room_jid, const char * const nick, const char * const message); -void srv_room_join_error(const char * const room, const char * const err); -void srv_room_info_error(const char * const room, const char * const error); -void srv_room_disco_info(const char * const room, GSList *identities, GSList *features, gboolean display); -void srv_room_affiliation_list_result_error(const char * const room, const char * const affiliation, +void sv_ev_room_join_error(const char * const room, const char * const err); +void sv_ev_room_info_error(const char * const room, const char * const error); +void sv_ev_room_disco_info(const char * const room, GSList *identities, GSList *features, gboolean display); +void sv_ev_room_affiliation_list_result_error(const char * const room, const char * const affiliation, const char * const error); -void srv_room_affiliation_list(const char * const room, const char * const affiliation, GSList *jids); -void srv_room_affiliation_set_error(const char * const room, const char * const jid, const char * const affiliation, +void sv_ev_room_affiliation_list(const char * const room, const char * const affiliation, GSList *jids); +void sv_ev_room_affiliation_set_error(const char * const room, const char * const jid, const char * const affiliation, const char * const error); -void srv_room_role_list_result_error(const char * const from, const char * const role, const char * const error); -void srv_room_role_list(const char * const from, const char * const role, GSList *nicks); -void srv_room_role_set_error(const char * const room, const char * const nick, const char * const role, +void sv_ev_room_role_list_result_error(const char * const from, const char * const role, const char * const error); +void sv_ev_room_role_list(const char * const from, const char * const role, GSList *nicks); +void sv_ev_room_role_set_error(const char * const room, const char * const nick, const char * const role, const char * const error); -void srv_room_kick_result_error(const char * const room, const char * const nick, const char * const error); -void srv_incoming_message(char *barejid, char *resource, char *message); -void srv_incoming_private_message(char *fulljid, char *message); -void srv_delayed_message(char *fulljid, char *message, GTimeVal tv_stamp); -void srv_delayed_private_message(char *fulljid, char *message, GTimeVal tv_stamp); -void srv_typing(char *barejid, char *resource); -void srv_paused(char *barejid, char *resource); -void srv_inactive(char *barejid, char *resource); -void srv_activity(char *barejid, char *resource, gboolean send_states); -void srv_gone(const char * const barejid, const char * const resource); -void srv_subscription(const char *from, jabber_subscr_t type); -void srv_message_receipt(char *barejid, char *id); -void srv_contact_offline(char *contact, char *resource, char *status); -void srv_contact_online(char *contact, Resource *resource, +void sv_ev_room_kick_result_error(const char * const room, const char * const nick, const char * const error); +void sv_ev_incoming_message(char *barejid, char *resource, char *message); +void sv_ev_incoming_private_message(char *fulljid, char *message); +void sv_ev_delayed_message(char *fulljid, char *message, GTimeVal tv_stamp); +void sv_ev_delayed_private_message(char *fulljid, char *message, GTimeVal tv_stamp); +void sv_ev_typing(char *barejid, char *resource); +void sv_ev_paused(char *barejid, char *resource); +void sv_ev_inactive(char *barejid, char *resource); +void sv_ev_activity(char *barejid, char *resource, gboolean send_states); +void sv_ev_gone(const char * const barejid, const char * const resource); +void sv_ev_subscription(const char *from, jabber_subscr_t type); +void sv_ev_message_receipt(char *barejid, char *id); +void sv_ev_contact_offline(char *contact, char *resource, char *status); +void sv_ev_contact_online(char *contact, Resource *resource, GDateTime *last_activity); -void srv_leave_room(const char * const room); -void srv_room_destroy(const char * const room); -void srv_room_occupant_offline(const char * const room, const char * const nick, +void sv_ev_leave_room(const char * const room); +void sv_ev_room_destroy(const char * const room); +void sv_ev_room_occupant_offline(const char * const room, const char * const nick, const char * const show, const char * const status); -void srv_room_destroyed(const char * const room, const char * const new_jid, const char * const password, +void sv_ev_room_destroyed(const char * const room, const char * const new_jid, const char * const password, const char * const reason); -void srv_room_kicked(const char * const room, const char * const actor, const char * const reason); -void srv_room_occupent_kicked(const char * const room, const char * const nick, const char * const actor, +void sv_ev_room_kicked(const char * const room, const char * const actor, const char * const reason); +void sv_ev_room_occupent_kicked(const char * const room, const char * const nick, const char * const actor, const char * const reason); -void srv_room_banned(const char * const room, const char * const actor, const char * const reason); -void srv_room_occupent_banned(const char * const room, const char * const nick, const char * const actor, +void sv_ev_room_banned(const char * const room, const char * const actor, const char * const reason); +void sv_ev_room_occupent_banned(const char * const room, const char * const nick, const char * const actor, const char * const reason); -void srv_group_add(const char * const contact, +void sv_ev_group_add(const char * const contact, const char * const group); -void srv_group_remove(const char * const contact, +void sv_ev_group_remove(const char * const contact, const char * const group); -void srv_roster_remove(const char * const barejid); -void srv_roster_add(const char * const barejid, const char * const name); -void srv_autoping_cancel(void); -void srv_carbon(char *barejid, char *message); -void srv_message_error(const char * const from, const char * const type, +void sv_ev_roster_remove(const char * const barejid); +void sv_ev_roster_add(const char * const barejid, const char * const name); +void sv_ev_autoping_cancel(void); +void sv_ev_carbon(char *barejid, char *message); +void sv_ev_message_error(const char * const from, const char * const type, const char * const err_msg); -void srv_presence_error(const char *from, const char * const type, +void sv_ev_presence_error(const char *from, const char * const type, const char *err_msg); -void srv_xmpp_stanza(const char * const msg); -void srv_ping_result(const char * const from, int millis); -void srv_ping_error_result(const char * const from, const char * const error); -void srv_room_configure(const char * const room, DataForm *form); -void srv_room_configuration_form_error(const char * const from, const char * const message); -void srv_room_config_submit_result(const char * const room); -void srv_room_config_submit_result_error(const char * const room, const char * const message); -void srv_muc_self_online(const char * const room, const char * const nick, gboolean config_required, +void sv_ev_xmpp_stanza(const char * const msg); +void sv_ev_ping_result(const char * const from, int millis); +void sv_ev_ping_error_result(const char * const from, const char * const error); +void sv_ev_room_configure(const char * const room, DataForm *form); +void sv_ev_room_configuration_form_error(const char * const from, const char * const message); +void sv_ev_room_config_submit_result(const char * const room); +void sv_ev_room_config_submit_result_error(const char * const room, const char * const message); +void sv_ev_muc_self_online(const char * const room, const char * const nick, gboolean config_required, const char * const role, const char * const affiliation, const char * const actor, const char * const reason, const char * const jid, const char * const show, const char * const status); -void srv_muc_occupant_online(const char * const room, const char * const nick, const char * const jid, +void sv_ev_muc_occupant_online(const char * const room, const char * const nick, const char * const jid, const char * const role, const char * const affiliation, const char * const actor, const char * const reason, const char * const show_str, const char * const status_str); -void srv_roster_update(const char * const barejid, const char * const name, +void sv_ev_roster_update(const char * const barejid, const char * const name, GSList *groups, const char * const subscription, gboolean pending_out); -void srv_roster_received(void); -void srv_enable_carbons_error(const char * const error); -void srv_disable_carbons_error(const char * const error); +void sv_ev_roster_received(void); +void sv_ev_enable_carbons_error(const char * const error); +void sv_ev_disable_carbons_error(const char * const error); #endif diff --git a/src/event/ui_events.c b/src/event/ui_events.c new file mode 100644 index 00000000..c079c0e6 --- /dev/null +++ b/src/event/ui_events.c @@ -0,0 +1,48 @@ +/* + * ui_events.c + * + * Copyright (C) 2012 - 2015 James Booth <boothj5@gmail.com> + * + * This file is part of Profanity. + * + * Profanity is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Profanity is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Profanity. If not, see <http://www.gnu.org/licenses/>. + * + * In addition, as a special exception, the copyright holders give permission to + * link the code of portions of this program with the OpenSSL library under + * certain conditions as described in each individual source file, and + * distribute linked combinations including the two. + * + * You must obey the GNU General Public License in all respects for all of the + * code used other than OpenSSL. If you modify file(s) with this exception, you + * may extend this exception to your version of the file(s), but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. If you delete this exception statement from all + * source files in the program, then also delete it here. + * + */ + +#include "ui/ui.h" + +void +ui_ev_focus_win(ProfWin *win) +{ + ui_switch_win(win); +} + +void +ui_ev_new_chat_win(const char * const barejid) +{ + ProfWin *win = ui_new_chat_win(barejid); + ui_switch_win(win); +} \ No newline at end of file diff --git a/src/event/ui_events.h b/src/event/ui_events.h new file mode 100644 index 00000000..77017d2c --- /dev/null +++ b/src/event/ui_events.h @@ -0,0 +1,41 @@ +/* + * ui_events.h + * + * Copyright (C) 2012 - 2015 James Booth <boothj5@gmail.com> + * + * This file is part of Profanity. + * + * Profanity is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Profanity is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Profanity. If not, see <http://www.gnu.org/licenses/>. + * + * In addition, as a special exception, the copyright holders give permission to + * link the code of portions of this program with the OpenSSL library under + * certain conditions as described in each individual source file, and + * distribute linked combinations including the two. + * + * You must obey the GNU General Public License in all respects for all of the + * code used other than OpenSSL. If you modify file(s) with this exception, you + * may extend this exception to your version of the file(s), but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. If you delete this exception statement from all + * source files in the program, then also delete it here. + * + */ + +#ifndef UI_EVENTS_H +#define UI_EVENTS_H + +void ui_ev_focus_win(ProfWin *win); +void ui_ev_new_chat_win(const char * const barejid); + +#endif \ No newline at end of file diff --git a/src/ui/core.c b/src/ui/core.c index 78faff18..698b4e98 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -3002,32 +3002,6 @@ ui_hide_roster(void) } } -//static void -//_win_handle_switch(const wint_t ch) -//{ -// if (ch == KEY_F(1)) { -// ui_switch_win(1); -// } else if (ch == KEY_F(2)) { -// ui_switch_win(2); -// } else if (ch == KEY_F(3)) { -// ui_switch_win(3); -// } else if (ch == KEY_F(4)) { -// ui_switch_win(4); -// } else if (ch == KEY_F(5)) { -// ui_switch_win(5); -// } else if (ch == KEY_F(6)) { -// ui_switch_win(6); -// } else if (ch == KEY_F(7)) { -// ui_switch_win(7); -// } else if (ch == KEY_F(8)) { -// ui_switch_win(8); -// } else if (ch == KEY_F(9)) { -// ui_switch_win(9); -// } else if (ch == KEY_F(10)) { -// ui_switch_win(0); -// } -//} -// static void _win_show_history(int win_index, const char * const contact) { diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c index 295c8f2f..f2596f14 100644 --- a/src/xmpp/connection.c +++ b/src/xmpp/connection.c @@ -438,7 +438,7 @@ _connection_handler(xmpp_conn_t * const conn, // logged in with account if (saved_account.name != NULL) { log_debug("Connection handler: logged in with account name: %s", saved_account.name); - srv_login_account_success(saved_account.name); + sv_ev_login_account_success(saved_account.name); // logged in without account, use details to create new account } else { @@ -446,7 +446,7 @@ _connection_handler(xmpp_conn_t * const conn, accounts_add(saved_details.name, saved_details.altdomain, saved_details.port); accounts_set_jid(saved_details.name, saved_details.jid); - srv_login_account_success(saved_details.name); + sv_ev_login_account_success(saved_details.name); saved_account.name = strdup(saved_details.name); saved_account.passwd = strdup(saved_details.passwd); @@ -486,7 +486,7 @@ _connection_handler(xmpp_conn_t * const conn, // lost connection for unknown reason if (jabber_conn.conn_status == JABBER_CONNECTED) { log_debug("Connection handler: Lost connection for unknown reason"); - srv_lost_connection(); + sv_ev_lost_connection(); if (prefs_get_reconnect() != 0) { assert(reconnect_timer == NULL); reconnect_timer = g_timer_new(); @@ -503,7 +503,7 @@ _connection_handler(xmpp_conn_t * const conn, log_debug("Connection handler: Login failed"); if (reconnect_timer == NULL) { log_debug("Connection handler: No reconnect timer"); - srv_failed_login(); + sv_ev_failed_login(); _connection_free_saved_account(); _connection_free_saved_details(); _connection_free_session_data(); @@ -563,7 +563,7 @@ _xmpp_file_logger(void * const userdata, const xmpp_log_level_t level, log_level_t prof_level = _get_log_level(level); log_msg(prof_level, area, msg); if ((g_strcmp0(area, "xmpp") == 0) || (g_strcmp0(area, "conn")) == 0) { - srv_xmpp_stanza(msg); + sv_ev_xmpp_stanza(msg); } } diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index 71876cdc..75286bf8 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -515,7 +515,7 @@ _pong_handler(xmpp_conn_t *const conn, xmpp_stanza_t * const stanza, if (errtype != NULL) { if (strcmp(errtype, "cancel") == 0) { log_warning("Server ping (id=%s) error type 'cancel', disabling autoping.", id); - srv_autoping_cancel(); + sv_ev_autoping_cancel(); xmpp_timed_handler_delete(conn, _ping_timed_handler); } } @@ -739,7 +739,7 @@ _enable_carbons_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, char *type = xmpp_stanza_get_type(stanza); if (g_strcmp0(type, "error") == 0) { char *error_message = stanza_get_error_message(stanza); - srv_enable_carbons_error(error_message); + sv_ev_enable_carbons_error(error_message); log_debug("Error enabling carbons: %s", error_message); } else { log_debug("Message carbons enabled."); @@ -754,7 +754,7 @@ _disable_carbons_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, char *type = xmpp_stanza_get_type(stanza); if (g_strcmp0(type, "error") == 0) { char *error_message = stanza_get_error_message(stanza); - srv_disable_carbons_error(error_message); + sv_ev_disable_carbons_error(error_message); log_debug("Error disabling carbons: %s", error_message); } else { log_debug("Message carbons disabled."); @@ -774,7 +774,7 @@ _manual_pong_handler(xmpp_conn_t *const conn, xmpp_stanza_t * const stanza, // handle error responses if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { char *error_message = stanza_get_error_message(stanza); - srv_ping_error_result(from, error_message); + sv_ev_ping_error_result(from, error_message); free(error_message); g_date_time_unref(sent); return 0; @@ -788,7 +788,7 @@ _manual_pong_handler(xmpp_conn_t *const conn, xmpp_stanza_t * const stanza, g_date_time_unref(sent); g_date_time_unref(now); - srv_ping_result(from, elapsed_millis); + sv_ev_ping_result(from, elapsed_millis); return 0; } @@ -865,7 +865,7 @@ _version_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, presence = string_from_resource_presence(resource->presence); } - srv_software_version_result(jid, presence, name_str, version_str, os_str); + sv_ev_software_version_result(jid, presence, name_str, version_str, os_str); jid_destroy(jidp); @@ -1062,7 +1062,7 @@ _destroy_room_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const sta if (from == NULL) { log_error("No from attribute for IQ destroy room result"); } else { - srv_room_destroy(from); + sv_ev_room_destroy(from); } return 0; @@ -1085,40 +1085,40 @@ _room_config_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, // handle error responses if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { char *error_message = stanza_get_error_message(stanza); - srv_room_configuration_form_error(from, error_message); + sv_ev_room_configuration_form_error(from, error_message); free(error_message); return 0; } if (from == NULL) { log_warning("No from attribute for IQ config request result"); - srv_room_configuration_form_error(from, "No from attribute for room cofig response."); + sv_ev_room_configuration_form_error(from, "No from attribute for room cofig response."); return 0; } xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); if (query == NULL) { log_warning("No query element found parsing room config response"); - srv_room_configuration_form_error(from, "No query element found parsing room config response"); + sv_ev_room_configuration_form_error(from, "No query element found parsing room config response"); return 0; } xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(query, STANZA_NS_DATA); if (x == NULL) { log_warning("No x element found with %s namespace parsing room config response", STANZA_NS_DATA); - srv_room_configuration_form_error(from, "No form configuration options available"); + sv_ev_room_configuration_form_error(from, "No form configuration options available"); return 0; } char *form_type = xmpp_stanza_get_attribute(x, STANZA_ATTR_TYPE); if (g_strcmp0(form_type, "form") != 0) { log_warning("x element not of type 'form' parsing room config response"); - srv_room_configuration_form_error(from, "Form not of type 'form' parsing room config response."); + sv_ev_room_configuration_form_error(from, "Form not of type 'form' parsing room config response."); return 0; } DataForm *form = form_create(x); - srv_room_configure(from, form); + sv_ev_room_configure(from, form); return 0; } @@ -1140,7 +1140,7 @@ static int _room_affiliation_set_result_handler(xmpp_conn_t * const conn, xmpp_s // handle error responses if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { char *error_message = stanza_get_error_message(stanza); - srv_room_affiliation_set_error(from, affiliation_set->item, affiliation_set->privilege, error_message); + sv_ev_room_affiliation_set_error(from, affiliation_set->item, affiliation_set->privilege, error_message); free(error_message); } @@ -1168,7 +1168,7 @@ static int _room_role_set_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t // handle error responses if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { char *error_message = stanza_get_error_message(stanza); - srv_room_role_set_error(from, role_set->item, role_set->privilege, error_message); + sv_ev_room_role_set_error(from, role_set->item, role_set->privilege, error_message); free(error_message); } @@ -1196,7 +1196,7 @@ _room_affiliation_list_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * // handle error responses if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { char *error_message = stanza_get_error_message(stanza); - srv_room_affiliation_list_result_error(from, affiliation, error_message); + sv_ev_room_affiliation_list_result_error(from, affiliation, error_message); free(error_message); free(affiliation); return 0; @@ -1218,7 +1218,7 @@ _room_affiliation_list_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * } } - srv_room_affiliation_list(from, affiliation, jids); + sv_ev_room_affiliation_list(from, affiliation, jids); free(affiliation); g_slist_free(jids); @@ -1242,7 +1242,7 @@ _room_role_list_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const s // handle error responses if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { char *error_message = stanza_get_error_message(stanza); - srv_room_role_list_result_error(from, role, error_message); + sv_ev_room_role_list_result_error(from, role, error_message); free(error_message); free(role); return 0; @@ -1264,7 +1264,7 @@ _room_role_list_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const s } } - srv_room_role_list(from, role, nicks); + sv_ev_room_role_list(from, role, nicks); free(role); g_slist_free(nicks); @@ -1288,12 +1288,12 @@ _room_config_submit_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stan // handle error responses if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { char *error_message = stanza_get_error_message(stanza); - srv_room_config_submit_result_error(from, error_message); + sv_ev_room_config_submit_result_error(from, error_message); free(error_message); return 0; } - srv_room_config_submit_result(from); + sv_ev_room_config_submit_result(from); return 0; } @@ -1315,7 +1315,7 @@ _room_kick_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza // handle error responses if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { char *error_message = stanza_get_error_message(stanza); - srv_room_kick_result_error(from, nick, error_message); + sv_ev_room_kick_result_error(from, nick, error_message); free(error_message); free(nick); return 0; @@ -1359,7 +1359,7 @@ _room_info_response_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stan if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { if (cb_data->display) { char *error_message = stanza_get_error_message(stanza); - srv_room_info_error(cb_data->room, error_message); + sv_ev_room_info_error(cb_data->room, error_message); free(error_message); } free(cb_data->room); @@ -1411,7 +1411,7 @@ _room_info_response_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stan child = xmpp_stanza_get_next(child); } - srv_room_disco_info(cb_data->room, identities, features, cb_data->display); + sv_ev_room_disco_info(cb_data->room, identities, features, cb_data->display); g_slist_free_full(features, free); g_slist_free_full(identities, (GDestroyNotify)_identity_destroy); @@ -1439,7 +1439,7 @@ _disco_info_response_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const sta // handle error responses if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { char *error_message = stanza_get_error_message(stanza); - srv_disco_info_error(from, error_message); + sv_ev_disco_info_error(from, error_message); free(error_message); return 0; } @@ -1488,7 +1488,7 @@ _disco_info_response_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const sta child = xmpp_stanza_get_next(child); } - srv_disco_info(from, identities, features); + sv_ev_disco_info(from, identities, features); g_slist_free_full(features, free); g_slist_free_full(identities, (GDestroyNotify)_identity_destroy); @@ -1536,9 +1536,9 @@ _disco_items_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stan } if (g_strcmp0(id, "confreq") == 0) { - srv_room_list(items, from); + sv_ev_room_list(items, from); } else if (g_strcmp0(id, "discoitemsreq") == 0) { - srv_disco_items(items, from); + sv_ev_disco_items(items, from); } g_slist_free_full(items, (GDestroyNotify)_item_destroy); diff --git a/src/xmpp/message.c b/src/xmpp/message.c index aa5e55d9..3acb9f4a 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -329,7 +329,7 @@ _message_error_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, g_string_free(log_msg, TRUE); - srv_message_error(jid, type, err_msg); + sv_ev_message_error(jid, type, err_msg); free(err_msg); @@ -376,7 +376,7 @@ _muc_user_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, password = xmpp_stanza_get_text(password_st); } - srv_room_invite(INVITE_MEDIATED, invitor, room, reason, password); + sv_ev_room_invite(INVITE_MEDIATED, invitor, room, reason, password); jid_destroy(jidp); if (reason) { xmpp_free(ctx, reason); @@ -420,7 +420,7 @@ _conference_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, reason = xmpp_stanza_get_attribute(xns_conference, STANZA_ATTR_REASON); password = xmpp_stanza_get_attribute(xns_conference, STANZA_ATTR_PASSWORD); - srv_room_invite(INVITE_DIRECT, invitor, room, reason, password); + sv_ev_room_invite(INVITE_DIRECT, invitor, room, reason, password); jid_destroy(jidp); @@ -444,7 +444,7 @@ _captcha_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, if (body != NULL) { char *message = xmpp_stanza_get_text(body); if (message != NULL) { - srv_room_broadcast(from, message); + sv_ev_room_broadcast(from, message); xmpp_free(ctx, message); } } @@ -465,7 +465,7 @@ _groupchat_handler(xmpp_conn_t * const conn, xmpp_stanza_t *subject = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_SUBJECT); if (subject != NULL) { message = xmpp_stanza_get_text(subject); - srv_room_subject(jid->barejid, jid->resourcepart, message); + sv_ev_room_subject(jid->barejid, jid->resourcepart, message); xmpp_free(ctx, message); jid_destroy(jid); @@ -478,7 +478,7 @@ _groupchat_handler(xmpp_conn_t * const conn, if (body != NULL) { message = xmpp_stanza_get_text(body); if (message != NULL) { - srv_room_broadcast(room_jid, message); + sv_ev_room_broadcast(room_jid, message); xmpp_free(ctx, message); } } @@ -510,9 +510,9 @@ _groupchat_handler(xmpp_conn_t * const conn, message = xmpp_stanza_get_text(body); if (message != NULL) { if (delayed) { - srv_room_history(jid->barejid, jid->resourcepart, tv_stamp, message); + sv_ev_room_history(jid->barejid, jid->resourcepart, tv_stamp, message); } else { - srv_room_message(jid->barejid, jid->resourcepart, message); + sv_ev_room_message(jid->barejid, jid->resourcepart, message); } xmpp_free(ctx, message); } @@ -566,7 +566,7 @@ _chat_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, char *fulljid = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); if (fulljid) { Jid *jidp = jid_create(fulljid); - srv_message_receipt(jidp->barejid, id); + sv_ev_message_receipt(jidp->barejid, id); jid_destroy(jidp); return 1; } @@ -603,11 +603,11 @@ _chat_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, if (message != NULL) { // if we are the recipient, treat as standard incoming message if(g_strcmp0(my_jid->barejid, jid_to->barejid) == 0){ - srv_incoming_message(jid_from->barejid, jid_from->resourcepart, message); + sv_ev_incoming_message(jid_from->barejid, jid_from->resourcepart, message); } // else treat as a sent message else{ - srv_carbon(jid_to->barejid, message); + sv_ev_carbon(jid_to->barejid, message); } xmpp_free(ctx, message); } @@ -645,9 +645,9 @@ _chat_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, char *message = xmpp_stanza_get_text(body); if (message != NULL) { if (delayed) { - srv_delayed_private_message(jid->str, message, tv_stamp); + sv_ev_delayed_private_message(jid->str, message, tv_stamp); } else { - srv_incoming_private_message(jid->str, message); + sv_ev_incoming_private_message(jid->str, message); } xmpp_free(ctx, message); } @@ -669,7 +669,7 @@ _chat_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, char *message = xmpp_stanza_get_text(body); if (message != NULL) { if (delayed) { - srv_delayed_message(jid->barejid, message, tv_stamp); + sv_ev_delayed_message(jid->barejid, message, tv_stamp); } else { #ifdef HAVE_LIBGPGME gboolean handled = FALSE; @@ -678,15 +678,15 @@ _chat_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, char *enc_message = xmpp_stanza_get_text(x); char *decrypted = p_gpg_decrypt(jid->barejid, enc_message); if (decrypted) { - srv_incoming_message(jid->barejid, jid->resourcepart, decrypted); + sv_ev_incoming_message(jid->barejid, jid->resourcepart, decrypted); handled = TRUE; } } if (!handled) { - srv_incoming_message(jid->barejid, jid->resourcepart, message); + sv_ev_incoming_message(jid->barejid, jid->resourcepart, message); } #else - srv_incoming_message(jid->barejid, jid->resourcepart, message); + sv_ev_incoming_message(jid->barejid, jid->resourcepart, message); #endif } if (id && prefs_get_boolean(PREF_RECEIPTS_SEND)) { @@ -709,17 +709,17 @@ _chat_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, gboolean paused = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_PAUSED) != NULL; gboolean inactive = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_INACTIVE) != NULL; if (gone) { - srv_gone(jid->barejid, jid->resourcepart); + sv_ev_gone(jid->barejid, jid->resourcepart); } else if (typing) { - srv_typing(jid->barejid, jid->resourcepart); + sv_ev_typing(jid->barejid, jid->resourcepart); } else if (paused) { - srv_paused(jid->barejid, jid->resourcepart); + sv_ev_paused(jid->barejid, jid->resourcepart); } else if (inactive) { - srv_inactive(jid->barejid, jid->resourcepart); + sv_ev_inactive(jid->barejid, jid->resourcepart); } else if (stanza_contains_chat_state(stanza)) { - srv_activity(jid->barejid, jid->resourcepart, TRUE); + sv_ev_activity(jid->barejid, jid->resourcepart, TRUE); } else { - srv_activity(jid->barejid, jid->resourcepart, FALSE); + sv_ev_activity(jid->barejid, jid->resourcepart, FALSE); } } diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c index b704b49c..b4d2d098 100644 --- a/src/xmpp/presence.c +++ b/src/xmpp/presence.c @@ -399,7 +399,7 @@ _presence_error_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, } log_info("Error joining room: %s, reason: %s", fulljid->barejid, error_cond); - srv_room_join_error(fulljid->barejid, error_cond); + sv_ev_room_join_error(fulljid->barejid, error_cond); jid_destroy(fulljid); return 1; } @@ -427,7 +427,7 @@ _presence_error_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, g_string_free(log_msg, TRUE); - srv_presence_error(from, type, err_msg); + sv_ev_presence_error(from, type, err_msg); free(err_msg); @@ -443,7 +443,7 @@ _unsubscribed_handler(xmpp_conn_t * const conn, Jid *from_jid = jid_create(from); log_debug("Unsubscribed presence handler fired for %s", from); - srv_subscription(from_jid->barejid, PRESENCE_UNSUBSCRIBED); + sv_ev_subscription(from_jid->barejid, PRESENCE_UNSUBSCRIBED); autocomplete_remove(sub_requests_ac, from_jid->barejid); jid_destroy(from_jid); @@ -459,7 +459,7 @@ _subscribed_handler(xmpp_conn_t * const conn, Jid *from_jid = jid_create(from); log_debug("Subscribed presence handler fired for %s", from); - srv_subscription(from_jid->barejid, PRESENCE_SUBSCRIBED); + sv_ev_subscription(from_jid->barejid, PRESENCE_SUBSCRIBED); autocomplete_remove(sub_requests_ac, from_jid->barejid); jid_destroy(from_jid); @@ -479,7 +479,7 @@ _subscribe_handler(xmpp_conn_t * const conn, return 1; } - srv_subscription(from_jid->barejid, PRESENCE_SUBSCRIBE); + sv_ev_subscription(from_jid->barejid, PRESENCE_SUBSCRIBE); autocomplete_add(sub_requests_ac, from_jid->barejid); jid_destroy(from_jid); @@ -507,11 +507,11 @@ _unavailable_handler(xmpp_conn_t * const conn, if (strcmp(my_jid->barejid, from_jid->barejid) !=0) { if (from_jid->resourcepart != NULL) { - srv_contact_offline(from_jid->barejid, from_jid->resourcepart, status_str); + sv_ev_contact_offline(from_jid->barejid, from_jid->resourcepart, status_str); // hack for servers that do not send full jid with unavailable presence } else { - srv_contact_offline(from_jid->barejid, "__prof_default", status_str); + sv_ev_contact_offline(from_jid->barejid, "__prof_default", status_str); } } else { if (from_jid->resourcepart != NULL) { @@ -633,7 +633,7 @@ _available_handler(xmpp_conn_t * const conn, if (g_strcmp0(xmpp_presence->jid->barejid, my_jid->barejid) == 0) { connection_add_available_resource(resource); } else { - srv_contact_online(xmpp_presence->jid->barejid, resource, xmpp_presence->last_activity); + sv_ev_contact_online(xmpp_presence->jid->barejid, resource, xmpp_presence->last_activity); } jid_destroy(my_jid); @@ -719,7 +719,7 @@ _muc_user_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * char *new_jid = stanza_get_muc_destroy_alternative_room(stanza); char *password = stanza_get_muc_destroy_alternative_password(stanza); char *reason = stanza_get_muc_destroy_reason(stanza); - srv_room_destroyed(room, new_jid, password, reason); + sv_ev_room_destroyed(room, new_jid, password, reason); free(password); free(reason); @@ -727,19 +727,19 @@ _muc_user_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * } else if (g_slist_find_custom(status_codes, "307", (GCompareFunc)g_strcmp0) != NULL) { char *actor = stanza_get_actor(stanza); char *reason = stanza_get_reason(stanza); - srv_room_kicked(room, actor, reason); + sv_ev_room_kicked(room, actor, reason); free(reason); // banned from room } else if (g_slist_find_custom(status_codes, "301", (GCompareFunc)g_strcmp0) != NULL) { char *actor = stanza_get_actor(stanza); char *reason = stanza_get_reason(stanza); - srv_room_banned(room, actor, reason); + sv_ev_room_banned(room, actor, reason); free(reason); // normal exit } else { - srv_leave_room(room); + sv_ev_leave_room(room); } g_slist_free_full(status_codes, free); @@ -750,7 +750,7 @@ _muc_user_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * gboolean config_required = stanza_muc_requires_config(stanza); char *actor = stanza_get_actor(stanza); char *reason = stanza_get_reason(stanza); - srv_muc_self_online(room, nick, config_required, role, affiliation, actor, reason, jid, show_str, status_str); + sv_ev_muc_self_online(room, nick, config_required, role, affiliation, actor, reason, jid, show_str, status_str); } // handle presence from room members @@ -772,19 +772,19 @@ _muc_user_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * if (g_slist_find_custom(status_codes, "307", (GCompareFunc)g_strcmp0) != NULL) { char *actor = stanza_get_actor(stanza); char *reason = stanza_get_reason(stanza); - srv_room_occupent_kicked(room, nick, actor, reason); + sv_ev_room_occupent_kicked(room, nick, actor, reason); free(reason); // banned from room } else if (g_slist_find_custom(status_codes, "301", (GCompareFunc)g_strcmp0) != NULL) { char *actor = stanza_get_actor(stanza); char *reason = stanza_get_reason(stanza); - srv_room_occupent_banned(room, nick, actor, reason); + sv_ev_room_occupent_banned(room, nick, actor, reason); free(reason); // normal exit } else { - srv_room_occupant_offline(room, nick, "offline", status_str); + sv_ev_room_occupant_offline(room, nick, "offline", status_str); } g_slist_free_full(status_codes, free); @@ -802,7 +802,7 @@ _muc_user_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * char *actor = stanza_get_actor(stanza); char *reason = stanza_get_reason(stanza); - srv_muc_occupant_online(room, nick, jid, role, affiliation, actor, reason, show_str, status_str); + sv_ev_muc_occupant_online(room, nick, jid, role, affiliation, actor, reason, show_str, status_str); } } diff --git a/src/xmpp/roster.c b/src/xmpp/roster.c index 51880d77..91330f1b 100644 --- a/src/xmpp/roster.c +++ b/src/xmpp/roster.c @@ -163,7 +163,7 @@ _group_add_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, { if (userdata != NULL) { GroupData *data = userdata; - srv_group_add(data->name, data->group); + sv_ev_group_add(data->name, data->group); free(data->name); free(data->group); free(userdata); @@ -210,7 +210,7 @@ _group_remove_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, { if (userdata != NULL) { GroupData *data = userdata; - srv_group_remove(data->name, data->group); + sv_ev_group_remove(data->name, data->group); free(data->name); free(data->group); free(userdata); @@ -260,7 +260,7 @@ _roster_set_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, roster_remove(name, barejid_lower); - srv_roster_remove(barejid_lower); + sv_ev_roster_remove(barejid_lower); // otherwise update local roster } else { @@ -278,10 +278,10 @@ _roster_set_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, if (contact == NULL) { gboolean added = roster_add(barejid_lower, name, groups, sub, pending_out); if (added) { - srv_roster_add(barejid_lower, name); + sv_ev_roster_add(barejid_lower, name); } } else { - srv_roster_update(barejid_lower, name, groups, sub, pending_out); + sv_ev_roster_update(barejid_lower, name, groups, sub, pending_out); } } @@ -330,7 +330,7 @@ _roster_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, item = xmpp_stanza_get_next(item); } - srv_roster_received(); + sv_ev_roster_received(); resource_presence_t conn_presence = accounts_get_login_presence(jabber_get_account_name()); presence_update(conn_presence, NULL, 0); diff --git a/tests/test_server_events.c b/tests/test_server_events.c index 29290203..ffff74f9 100644 --- a/tests/test_server_events.c +++ b/tests/test_server_events.c @@ -21,7 +21,7 @@ void console_doesnt_show_online_presence_when_set_none(void **state) roster_add("test1@server", "bob", NULL, "both", FALSE); Resource *resource = resource_new("resource", RESOURCE_ONLINE, NULL, 10); - srv_contact_online("test1@server", resource, NULL); + sv_ev_contact_online("test1@server", resource, NULL); roster_clear(); } @@ -38,7 +38,7 @@ void console_shows_online_presence_when_set_online(void **state) expect_memory(cons_show_contact_online, resource, resource, sizeof(resource)); expect_value(cons_show_contact_online, last_activity, NULL); - srv_contact_online("test1@server", resource, NULL); + sv_ev_contact_online("test1@server", resource, NULL); roster_clear(); } @@ -55,7 +55,7 @@ void console_shows_online_presence_when_set_all(void **state) expect_memory(cons_show_contact_online, resource, resource, sizeof(resource)); expect_value(cons_show_contact_online, last_activity, NULL); - srv_contact_online("test1@server", resource, NULL); + sv_ev_contact_online("test1@server", resource, NULL); roster_clear(); } @@ -67,7 +67,7 @@ void console_doesnt_show_dnd_presence_when_set_none(void **state) roster_add("test1@server", "bob", NULL, "both", FALSE); Resource *resource = resource_new("resource", RESOURCE_DND, NULL, 10); - srv_contact_online("test1@server", resource, NULL); + sv_ev_contact_online("test1@server", resource, NULL); roster_clear(); } @@ -79,7 +79,7 @@ void console_doesnt_show_dnd_presence_when_set_online(void **state) roster_add("test1@server", "bob", NULL, "both", FALSE); Resource *resource = resource_new("resource", RESOURCE_DND, NULL, 10); - srv_contact_online("test1@server", resource, NULL); + sv_ev_contact_online("test1@server", resource, NULL); roster_clear(); } @@ -96,7 +96,7 @@ void console_shows_dnd_presence_when_set_all(void **state) expect_memory(cons_show_contact_online, resource, resource, sizeof(resource)); expect_value(cons_show_contact_online, last_activity, NULL); - srv_contact_online("test1@server", resource, NULL); + sv_ev_contact_online("test1@server", resource, NULL); roster_clear(); } @@ -109,7 +109,7 @@ void handle_message_error_when_no_recipient(void **state) expect_string(ui_handle_error, err_msg, err_msg); - srv_message_error(from, type, err_msg); + sv_ev_message_error(from, type, err_msg); } void handle_message_error_when_recipient_cancel(void **state) @@ -121,7 +121,7 @@ void handle_message_error_when_recipient_cancel(void **state) prefs_set_boolean(PREF_STATES, FALSE); chat_sessions_init(); - srv_message_error(from, type, err_msg); + sv_ev_message_error(from, type, err_msg); } void handle_message_error_when_recipient_cancel_disables_chat_session(void **state) @@ -135,7 +135,7 @@ void handle_message_error_when_recipient_cancel_disables_chat_session(void **sta chat_sessions_init(); chat_session_recipient_active(barejid, resource, FALSE); - srv_message_error(barejid, type, err_msg); + sv_ev_message_error(barejid, type, err_msg); ChatSession *session = chat_session_get(barejid); assert_null(session); @@ -151,7 +151,7 @@ void handle_message_error_when_recipient_and_no_type(void **state) expect_string(ui_handle_recipient_error, recipient, from); expect_string(ui_handle_recipient_error, err_msg, err_msg); - srv_message_error(from, type, err_msg); + sv_ev_message_error(from, type, err_msg); } void handle_presence_error_when_no_recipient(void **state) @@ -162,7 +162,7 @@ void handle_presence_error_when_no_recipient(void **state) expect_string(ui_handle_error, err_msg, err_msg); - srv_presence_error(from, type, err_msg); + sv_ev_presence_error(from, type, err_msg); } void handle_presence_error_when_from_recipient(void **state) @@ -174,7 +174,7 @@ void handle_presence_error_when_from_recipient(void **state) expect_string(ui_handle_recipient_error, recipient, from); expect_string(ui_handle_recipient_error, err_msg, err_msg); - srv_presence_error(from, type, err_msg); + sv_ev_presence_error(from, type, err_msg); } void handle_offline_removes_chat_session(void **state) @@ -187,7 +187,7 @@ void handle_offline_removes_chat_session(void **state) Resource *resourcep = resource_new(resource, RESOURCE_ONLINE, NULL, 10); roster_update_presence(barejid, resourcep, NULL); chat_session_recipient_active(barejid, resource, FALSE); - srv_contact_offline(barejid, resource, NULL); + sv_ev_contact_offline(barejid, resource, NULL); ChatSession *session = chat_session_get(barejid); assert_null(session); @@ -203,7 +203,7 @@ void lost_connection_clears_chat_sessions(void **state) chat_session_recipient_active("steve@server.org", "mobile", FALSE); expect_any_cons_show_error(); - srv_lost_connection(); + sv_ev_lost_connection(); ChatSession *session1 = chat_session_get("bob@server.org"); ChatSession *session2 = chat_session_get("steve@server.org"); |