diff --git a/src/event/server_events.c b/src/event/server_events.c index 56d5b11f..0e07e170 100644 --- a/src/event/server_events.c +++ b/src/event/server_events.c @@ -50,51 +50,6 @@ #include "ui/ui.h" -void -sv_ev_room_join_error(const char * const room, const char * const err) -{ - if (muc_active(room)) { - muc_leave(room); - } - ui_handle_room_join_error(room, err); -} - -// handle presence stanza errors -void -sv_ev_presence_error(const char *from, const char * const type, - const char *err_msg) -{ - // handle error from recipient - if (from != NULL) { - ui_handle_recipient_error(from, err_msg); - - // handle errors from no recipient - } else { - ui_handle_error(err_msg); - } -} - -// handle message stanza errors -void -sv_ev_message_error(const char * const jid, const char * const type, - const char * const err_msg) -{ - // handle errors from no recipient - if (jid == NULL) { - ui_handle_error(err_msg); - - // handle recipient not found ('from' contains a value and type is 'cancel') - } else if (type != NULL && (strcmp(type, "cancel") == 0)) { - log_info("Recipient %s not found: %s", jid, err_msg); - Jid *jidp = jid_create(jid); - chat_session_remove(jidp->barejid); - - // handle any other error from recipient - } else { - ui_handle_recipient_error(jid, err_msg); - } -} - void sv_ev_login_account_success(char *account_name) { @@ -147,112 +102,6 @@ sv_ev_failed_login(void) log_info("Login failed"); } -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) -{ - cons_show_software_version(jid, presence, name, version, os); -} - -void -sv_ev_disco_info(const char *from, GSList *identities, GSList *features) -{ - cons_show_disco_info(from, identities, features); -} - -void -sv_ev_room_disco_info(const char * const room, GSList *identities, GSList *features, gboolean display) -{ - muc_set_features(room, features); - if (display) { - ui_show_room_disco_info(room, identities, features); - } -} - -void -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); - } else { - cons_show_error("Service discovery failed: %s", error); - } -} - -void -sv_ev_enable_carbons_error(const char * const error) -{ - cons_show_error("Server error enabling message carbons: %s", error); -} - -void -sv_ev_disable_carbons_error(const char * const error) -{ - cons_show_error("Server error disabling message carbons: %s", error); -} - -void -sv_ev_room_info_error(const char * const room, const char * const error) -{ - ui_handle_room_info_error(room, error); -} - -void -sv_ev_room_list(GSList *rooms, const char *conference_node) -{ - cons_show_room_list(rooms, conference_node); -} - -void -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); - ui_handle_room_affiliation_list_error(room, affiliation, error); -} - -void -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 -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); - ui_handle_room_role_set_error(room, nick, role, error); -} - -void -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 -sv_ev_room_role_list(const char * const room, const char * const role, GSList *nicks) -{ - ui_handle_room_role_list(room, role, nicks); -} - -void -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); - ui_handle_room_affiliation_set_error(room, jid, affiliation, error); -} - -void -sv_ev_disco_items(GSList *items, const char *jid) -{ - cons_show_disco_items(items, jid); -} - void sv_ev_room_invite(jabber_invite_t invite_type, const char * const invitor, const char * const room, @@ -509,36 +358,6 @@ sv_ev_room_banned(const char * const room, const char * const actor, const char ui_room_banned(room, actor, reason); } -void -sv_ev_room_configure(const char * const room, DataForm *form) -{ - ui_handle_room_configuration(room, form); -} - -void -sv_ev_room_configuration_form_error(const char * const room, const char * const message) -{ - ui_handle_room_configuration_form_error(room, message); -} - -void -sv_ev_room_config_submit_result(const char * const room) -{ - ui_handle_room_config_submit_result(room); -} - -void -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 -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 sv_ev_room_occupant_offline(const char * const room, const char * const nick, const char * const show, const char * const status) @@ -571,32 +390,6 @@ sv_ev_room_occupent_banned(const char * const room, const char * const nick, con occupantswin_occupants(room); } -void -sv_ev_group_add(const char * const contact, - const char * const group) -{ - ui_group_added(contact, group); -} - -void -sv_ev_group_remove(const char * const contact, - const char * const group) -{ - ui_group_removed(contact, group); -} - -void -sv_ev_roster_remove(const char * const barejid) -{ - ui_roster_remove(barejid); -} - -void -sv_ev_roster_add(const char * const barejid, const char * const name) -{ - ui_roster_add(barejid, name); -} - void sv_ev_roster_update(const char * const barejid, const char * const name, GSList *groups, const char * const subscription, gboolean pending_out) @@ -605,39 +398,12 @@ sv_ev_roster_update(const char * const barejid, const char * const name, rosterwin_roster(); } -void -sv_ev_autoping_cancel(void) -{ - prefs_set_autoping(0); - cons_show_error("Server ping not supported, autoping disabled."); -} - void sv_ev_xmpp_stanza(const char * const msg) { ui_handle_stanza(msg); } -void -sv_ev_ping_result(const char * const from, int millis) -{ - if (from == NULL) { - cons_show("Ping response from server: %dms.", millis); - } else { - cons_show("Ping response from %s: %dms.", from, millis); - } -} - -void -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); - } else { - cons_show_error("Error returned from pinging %s: %s.", from, error); - } -} - 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, diff --git a/src/event/server_events.h b/src/event/server_events.h index daf885b3..c7cc9697 100644 --- a/src/event/server_events.h +++ b/src/event/server_events.h @@ -40,12 +40,6 @@ 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 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); @@ -56,19 +50,6 @@ void sv_ev_room_history(const char * const room_jid, const char * const nick, GTimeVal tv_stamp, const char * const message); void sv_ev_room_message(const char * const room_jid, const char * const nick, const char * const message); -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 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 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 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); @@ -95,25 +76,8 @@ void sv_ev_room_occupent_kicked(const char * const room, const char * const nick 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 sv_ev_group_add(const char * const contact, - const char * const group); -void sv_ev_group_remove(const char * const contact, - const char * const group); -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 sv_ev_presence_error(const char *from, const char * const type, - const char *err_msg); 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); @@ -123,7 +87,5 @@ void sv_ev_muc_occupant_online(const char * const room, const char * const nick, void sv_ev_roster_update(const char * const barejid, const char * const name, GSList *groups, const char * const subscription, gboolean pending_out); 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/xmpp/iq.c b/src/xmpp/iq.c index 75286bf8..1a0f64a9 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -47,6 +47,7 @@ #include "log.h" #include "muc.h" #include "profanity.h" +#include "ui/ui.h" #include "config/preferences.h" #include "event/server_events.h" #include "xmpp/capabilities.h" @@ -515,7 +516,8 @@ _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); - sv_ev_autoping_cancel(); + prefs_set_autoping(0); + cons_show_error("Server ping not supported, autoping disabled."); xmpp_timed_handler_delete(conn, _ping_timed_handler); } } @@ -739,7 +741,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); - sv_ev_enable_carbons_error(error_message); + cons_show_error("Server error enabling message carbons: %s", error_message); log_debug("Error enabling carbons: %s", error_message); } else { log_debug("Message carbons enabled."); @@ -754,7 +756,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); - sv_ev_disable_carbons_error(error_message); + cons_show_error("Server error disabling message carbons: %s", error_message); log_debug("Error disabling carbons: %s", error_message); } else { log_debug("Message carbons disabled."); @@ -774,7 +776,12 @@ _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); - sv_ev_ping_error_result(from, error_message); + if (!error_message) { + cons_show_error("Error returned from pinging %s.", from); + } else { + cons_show_error("Error returned from pinging %s: %s.", from, error_message); + } + free(error_message); g_date_time_unref(sent); return 0; @@ -788,7 +795,11 @@ _manual_pong_handler(xmpp_conn_t *const conn, xmpp_stanza_t * const stanza, g_date_time_unref(sent); g_date_time_unref(now); - sv_ev_ping_result(from, elapsed_millis); + if (from == NULL) { + cons_show("Ping response from server: %dms.", elapsed_millis); + } else { + cons_show("Ping response from %s: %dms.", from, elapsed_millis); + } return 0; } @@ -865,7 +876,7 @@ _version_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, presence = string_from_resource_presence(resource->presence); } - sv_ev_software_version_result(jid, presence, name_str, version_str, os_str); + cons_show_software_version(jid, presence, name_str, version_str, os_str); jid_destroy(jidp); @@ -1085,40 +1096,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); - sv_ev_room_configuration_form_error(from, error_message); + ui_handle_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"); - sv_ev_room_configuration_form_error(from, "No from attribute for room cofig response."); + ui_handle_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"); - sv_ev_room_configuration_form_error(from, "No query element found parsing room config response"); + ui_handle_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); - sv_ev_room_configuration_form_error(from, "No form configuration options available"); + ui_handle_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"); - sv_ev_room_configuration_form_error(from, "Form not of type 'form' parsing room config response."); + ui_handle_room_configuration_form_error(from, "Form not of type 'form' parsing room config response."); return 0; } DataForm *form = form_create(x); - sv_ev_room_configure(from, form); + ui_handle_room_configuration(from, form); return 0; } @@ -1140,7 +1151,8 @@ 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); - sv_ev_room_affiliation_set_error(from, affiliation_set->item, affiliation_set->privilege, error_message); + log_debug("Error setting affiliation %s list for room %s, user %s: %s", affiliation_set->privilege, from, affiliation_set->item, error_message); + ui_handle_room_affiliation_set_error(from, affiliation_set->item, affiliation_set->privilege, error_message); free(error_message); } @@ -1168,7 +1180,8 @@ 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); - sv_ev_room_role_set_error(from, role_set->item, role_set->privilege, error_message); + log_debug("Error setting role %s list for room %s, user %s: %s", role_set->privilege, from, role_set->item, error_message); + ui_handle_room_role_set_error(from, role_set->item, role_set->privilege, error_message); free(error_message); } @@ -1196,7 +1209,8 @@ _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); - sv_ev_room_affiliation_list_result_error(from, affiliation, error_message); + log_debug("Error retrieving %s list for room %s: %s", affiliation, from, error_message); + ui_handle_room_affiliation_list_error(from, affiliation, error_message); free(error_message); free(affiliation); return 0; @@ -1218,7 +1232,8 @@ _room_affiliation_list_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * } } - sv_ev_room_affiliation_list(from, affiliation, jids); + muc_jid_autocomplete_add_all(from, jids); + ui_handle_room_affiliation_list(from, affiliation, jids); free(affiliation); g_slist_free(jids); @@ -1242,7 +1257,8 @@ _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); - sv_ev_room_role_list_result_error(from, role, error_message); + log_debug("Error retrieving %s list for room %s: %s", role, from, error_message); + ui_handle_room_role_list_error(from, role, error_message); free(error_message); free(role); return 0; @@ -1264,7 +1280,7 @@ _room_role_list_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const s } } - sv_ev_room_role_list(from, role, nicks); + ui_handle_room_role_list(from, role, nicks); free(role); g_slist_free(nicks); @@ -1288,12 +1304,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); - sv_ev_room_config_submit_result_error(from, error_message); + ui_handle_room_config_submit_result_error(from, error_message); free(error_message); return 0; } - sv_ev_room_config_submit_result(from); + ui_handle_room_config_submit_result(from); return 0; } @@ -1315,7 +1331,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); - sv_ev_room_kick_result_error(from, nick, error_message); + ui_handle_room_kick_error(from, nick, error_message); free(error_message); free(nick); return 0; @@ -1359,7 +1375,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); - sv_ev_room_info_error(cb_data->room, error_message); + ui_handle_room_info_error(cb_data->room, error_message); free(error_message); } free(cb_data->room); @@ -1411,7 +1427,10 @@ _room_info_response_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stan child = xmpp_stanza_get_next(child); } - sv_ev_room_disco_info(cb_data->room, identities, features, cb_data->display); + muc_set_features(cb_data->room, features); + if (cb_data->display) { + ui_show_room_disco_info(cb_data->room, identities, features); + } g_slist_free_full(features, free); g_slist_free_full(identities, (GDestroyNotify)_identity_destroy); @@ -1439,7 +1458,11 @@ _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); - sv_ev_disco_info_error(from, error_message); + if (from) { + cons_show_error("Service discovery failed for %s: %s", from, error_message); + } else { + cons_show_error("Service discovery failed: %s", error_message); + } free(error_message); return 0; } @@ -1488,7 +1511,7 @@ _disco_info_response_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const sta child = xmpp_stanza_get_next(child); } - sv_ev_disco_info(from, identities, features); + cons_show_disco_info(from, identities, features); g_slist_free_full(features, free); g_slist_free_full(identities, (GDestroyNotify)_identity_destroy); @@ -1536,9 +1559,9 @@ _disco_items_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stan } if (g_strcmp0(id, "confreq") == 0) { - sv_ev_room_list(items, from); + cons_show_room_list(items, from); } else if (g_strcmp0(id, "discoitemsreq") == 0) { - sv_ev_disco_items(items, from); + cons_show_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 3acb9f4a..6c7a62ed 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -42,6 +42,7 @@ #include "log.h" #include "muc.h" #include "profanity.h" +#include "ui/ui.h" #include "event/server_events.h" #include "xmpp/connection.h" #include "xmpp/message.h" @@ -329,7 +330,16 @@ _message_error_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, g_string_free(log_msg, TRUE); - sv_ev_message_error(jid, type, err_msg); + if (!jid) { + ui_handle_error(err_msg); + } else if (type && (strcmp(type, "cancel") == 0)) { + log_info("Recipient %s not found: %s", jid, err_msg); + Jid *jidp = jid_create(jid); + chat_session_remove(jidp->barejid); + jid_destroy(jidp); + } else { + ui_handle_recipient_error(jid, err_msg); + } free(err_msg); diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c index b4d2d098..6d9ba14e 100644 --- a/src/xmpp/presence.c +++ b/src/xmpp/presence.c @@ -44,6 +44,7 @@ #include "log.h" #include "muc.h" #include "profanity.h" +#include "ui/ui.h" #include "event/server_events.h" #include "xmpp/capabilities.h" #include "xmpp/connection.h" @@ -399,7 +400,10 @@ _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); - sv_ev_room_join_error(fulljid->barejid, error_cond); + if (muc_active(fulljid->barejid)) { + muc_leave(fulljid->barejid); + } + ui_handle_room_join_error(fulljid->barejid, error_cond); jid_destroy(fulljid); return 1; } @@ -427,7 +431,11 @@ _presence_error_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, g_string_free(log_msg, TRUE); - sv_ev_presence_error(from, type, err_msg); + if (from != NULL) { + ui_handle_recipient_error(from, err_msg); + } else { + ui_handle_error(err_msg); + } free(err_msg); diff --git a/src/xmpp/roster.c b/src/xmpp/roster.c index 91330f1b..84561ecf 100644 --- a/src/xmpp/roster.c +++ b/src/xmpp/roster.c @@ -41,6 +41,7 @@ #include "log.h" #include "profanity.h" +#include "ui/ui.h" #include "event/server_events.h" #include "tools/autocomplete.h" #include "xmpp/connection.h" @@ -163,7 +164,7 @@ _group_add_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, { if (userdata != NULL) { GroupData *data = userdata; - sv_ev_group_add(data->name, data->group); + ui_group_added(data->name, data->group); free(data->name); free(data->group); free(userdata); @@ -210,7 +211,7 @@ _group_remove_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, { if (userdata != NULL) { GroupData *data = userdata; - sv_ev_group_remove(data->name, data->group); + ui_group_removed(data->name, data->group); free(data->name); free(data->group); free(userdata); @@ -257,10 +258,8 @@ _roster_set_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, if (name == NULL) { name = barejid_lower; } - roster_remove(name, barejid_lower); - - sv_ev_roster_remove(barejid_lower); + ui_roster_remove(barejid_lower); // otherwise update local roster } else { @@ -278,7 +277,7 @@ _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) { - sv_ev_roster_add(barejid_lower, name); + ui_roster_add(barejid_lower, name); } } else { sv_ev_roster_update(barejid_lower, name, groups, sub, pending_out); diff --git a/tests/test_server_events.c b/tests/test_server_events.c index ffff74f9..d87dc217 100644 --- a/tests/test_server_events.c +++ b/tests/test_server_events.c @@ -101,82 +101,6 @@ void console_shows_dnd_presence_when_set_all(void **state) roster_clear(); } -void handle_message_error_when_no_recipient(void **state) -{ - char *err_msg = "Some error."; - char *from = NULL; - char *type = "cancel"; - - expect_string(ui_handle_error, err_msg, err_msg); - - sv_ev_message_error(from, type, err_msg); -} - -void handle_message_error_when_recipient_cancel(void **state) -{ - char *err_msg = "Some error."; - char *from = "bob@server.com"; - char *type = "cancel"; - - prefs_set_boolean(PREF_STATES, FALSE); - chat_sessions_init(); - - sv_ev_message_error(from, type, err_msg); -} - -void handle_message_error_when_recipient_cancel_disables_chat_session(void **state) -{ - char *err_msg = "Some error."; - char *barejid = "bob@server.com"; - char *resource = "resource"; - char *type = "cancel"; - - prefs_set_boolean(PREF_STATES, TRUE); - chat_sessions_init(); - chat_session_recipient_active(barejid, resource, FALSE); - - sv_ev_message_error(barejid, type, err_msg); - ChatSession *session = chat_session_get(barejid); - - assert_null(session); - chat_sessions_clear(); -} - -void handle_message_error_when_recipient_and_no_type(void **state) -{ - char *err_msg = "Some error."; - char *from = "bob@server.com"; - char *type = NULL; - - expect_string(ui_handle_recipient_error, recipient, from); - expect_string(ui_handle_recipient_error, err_msg, err_msg); - - sv_ev_message_error(from, type, err_msg); -} - -void handle_presence_error_when_no_recipient(void **state) -{ - char *err_msg = "Some error."; - char *from = NULL; - char *type = NULL; - - expect_string(ui_handle_error, err_msg, err_msg); - - sv_ev_presence_error(from, type, err_msg); -} - -void handle_presence_error_when_from_recipient(void **state) -{ - char *err_msg = "Some error."; - char *from = "bob@server.com"; - char *type = NULL; - - expect_string(ui_handle_recipient_error, recipient, from); - expect_string(ui_handle_recipient_error, err_msg, err_msg); - - sv_ev_presence_error(from, type, err_msg); -} - void handle_offline_removes_chat_session(void **state) { chat_sessions_init(); diff --git a/tests/testsuite.c b/tests/testsuite.c index b4ce1c0a..91fd54e3 100644 --- a/tests/testsuite.c +++ b/tests/testsuite.c @@ -443,16 +443,6 @@ int main(int argc, char* argv[]) { unit_test_setup_teardown(console_shows_dnd_presence_when_set_all, load_preferences, close_preferences), - unit_test(handle_message_error_when_no_recipient), - unit_test_setup_teardown(handle_message_error_when_recipient_cancel, - load_preferences, - close_preferences), - unit_test_setup_teardown(handle_message_error_when_recipient_cancel_disables_chat_session, - load_preferences, - close_preferences), - unit_test(handle_message_error_when_recipient_and_no_type), - unit_test(handle_presence_error_when_no_recipient), - unit_test(handle_presence_error_when_from_recipient), unit_test(handle_offline_removes_chat_session), unit_test(lost_connection_clears_chat_sessions),