From 39fb05577aae81450946aa6fa28c9973e36f3e1a Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 2 May 2016 21:50:39 +0100 Subject: [PATCH 1/3] Rename id_handler_add -> iq_id_handler_add --- src/xmpp/blocking.c | 6 +++--- src/xmpp/bookmark.c | 2 +- src/xmpp/connection.h | 2 +- src/xmpp/iq.c | 44 +++++++++++++++++++++---------------------- src/xmpp/roster.c | 4 ++-- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/xmpp/blocking.c b/src/xmpp/blocking.c index 06bbadf6..735b9140 100644 --- a/src/xmpp/blocking.c +++ b/src/xmpp/blocking.c @@ -73,7 +73,7 @@ blocking_request(void) } blocked_ac = autocomplete_new(); - id_handler_add(id, _blocklist_result_handler, id); + iq_id_handler_add(id, _blocklist_result_handler, id); iq = stanza_create_blocked_list_request(ctx); xmpp_stanza_set_id(iq, id); @@ -132,7 +132,7 @@ blocked_add(char *jid) xmpp_stanza_add_child(iq, block); xmpp_stanza_release(block); - id_handler_add(id, _block_add_result_handler, strdup(jid)); + iq_id_handler_add(id, _block_add_result_handler, strdup(jid)); send_iq_stanza(iq); xmpp_stanza_release(iq); @@ -171,7 +171,7 @@ blocked_remove(char *jid) xmpp_stanza_add_child(iq, block); xmpp_stanza_release(block); - id_handler_add(id, _block_remove_result_handler, strdup(jid)); + iq_id_handler_add(id, _block_remove_result_handler, strdup(jid)); send_iq_stanza(iq); xmpp_stanza_release(iq); diff --git a/src/xmpp/bookmark.c b/src/xmpp/bookmark.c index de922cf5..f76685e9 100644 --- a/src/xmpp/bookmark.c +++ b/src/xmpp/bookmark.c @@ -86,7 +86,7 @@ bookmark_request(void) bookmark_list = NULL; } - id_handler_add(id, _bookmark_result_id_handler, id); + iq_id_handler_add(id, _bookmark_result_id_handler, id); iq = stanza_create_bookmarks_storage_request(ctx); xmpp_stanza_set_id(iq, id); diff --git a/src/xmpp/connection.h b/src/xmpp/connection.h index 9d15bc96..8a66a56b 100644 --- a/src/xmpp/connection.h +++ b/src/xmpp/connection.h @@ -59,6 +59,6 @@ void send_iq_stanza(xmpp_stanza_t *const stanza); void roster_set_handler(xmpp_stanza_t *const stanza); void roster_result_handler(xmpp_stanza_t *const stanza); -void id_handler_add(const char *const id, ProfIdCallback func, void *userdata); +void iq_id_handler_add(const char *const id, ProfIdCallback func, void *userdata); #endif diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index 092d9392..f01f1c15 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -211,7 +211,7 @@ iq_add_handlers(void) } void -id_handler_add(const char *const id, ProfIdCallback func, void *userdata) +iq_id_handler_add(const char *const id, ProfIdCallback func, void *userdata) { ProfIdHandler *handler = malloc(sizeof(ProfIdHandler)); handler->func = func; @@ -283,7 +283,7 @@ iq_enable_carbons(void) xmpp_stanza_t *iq = stanza_enable_carbons(ctx); const char *id = xmpp_stanza_get_id(iq); - id_handler_add(id, _enable_carbons_id_handler, NULL); + iq_id_handler_add(id, _enable_carbons_id_handler, NULL); send_iq_stanza(iq); xmpp_stanza_release(iq); @@ -296,7 +296,7 @@ iq_disable_carbons(void) xmpp_stanza_t *iq = stanza_disable_carbons(ctx); const char *id = xmpp_stanza_get_id(iq); - id_handler_add(id, _disable_carbons_id_handler, NULL); + iq_id_handler_add(id, _disable_carbons_id_handler, NULL); send_iq_stanza(iq); xmpp_stanza_release(iq); @@ -329,7 +329,7 @@ iq_http_upload_request(HTTPUpload *upload) xmpp_stanza_t *iq = stanza_create_http_upload_request(ctx, id, disco_info->item, upload); - id_handler_add(id, _http_upload_response_id_handler, upload); + iq_id_handler_add(id, _http_upload_response_id_handler, upload); free(id); @@ -345,7 +345,7 @@ iq_disco_info_request(gchar *jid) char *id = create_unique_id("disco_info"); xmpp_stanza_t *iq = stanza_create_disco_info_iq(ctx, id, jid, NULL); - id_handler_add(id, _disco_info_response_id_handler, NULL); + iq_id_handler_add(id, _disco_info_response_id_handler, NULL); free(id); @@ -360,7 +360,7 @@ iq_disco_info_request_onconnect(gchar *jid) char *id = create_unique_id("disco_info_onconnect"); xmpp_stanza_t *iq = stanza_create_disco_info_iq(ctx, id, jid, NULL); - id_handler_add(id, _disco_info_response_id_handler_onconnect, NULL); + iq_id_handler_add(id, _disco_info_response_id_handler_onconnect, NULL); free(id); @@ -375,7 +375,7 @@ iq_last_activity_request(gchar *jid) char *id = create_unique_id("lastactivity"); xmpp_stanza_t *iq = stanza_create_last_activity_iq(ctx, id, jid); - id_handler_add(id, _last_activity_response_id_handler, NULL); + iq_id_handler_add(id, _last_activity_response_id_handler, NULL); free(id); @@ -394,7 +394,7 @@ iq_room_info_request(const char *const room, gboolean display_result) cb_data->room = strdup(room); cb_data->display = display_result; - id_handler_add(id, _room_info_response_id_handler, cb_data); + iq_id_handler_add(id, _room_info_response_id_handler, cb_data); free(id); @@ -422,7 +422,7 @@ iq_send_caps_request_for_jid(const char *const to, const char *const id, xmpp_stanza_t *iq = stanza_create_disco_info_iq(ctx, id, to, node_str->str); g_string_free(node_str, TRUE); - id_handler_add(id, _caps_response_for_jid_id_handler, strdup(to)); + iq_id_handler_add(id, _caps_response_for_jid_id_handler, strdup(to)); send_iq_stanza(iq); xmpp_stanza_release(iq); @@ -448,7 +448,7 @@ iq_send_caps_request(const char *const to, const char *const id, xmpp_stanza_t *iq = stanza_create_disco_info_iq(ctx, id, to, node_str->str); g_string_free(node_str, TRUE); - id_handler_add(id, _caps_response_id_handler, NULL); + iq_id_handler_add(id, _caps_response_id_handler, NULL); send_iq_stanza(iq); xmpp_stanza_release(iq); @@ -473,7 +473,7 @@ iq_send_caps_request_legacy(const char *const to, const char *const id, g_string_printf(node_str, "%s#%s", node, ver); xmpp_stanza_t *iq = stanza_create_disco_info_iq(ctx, id, to, node_str->str); - id_handler_add(id, _caps_response_legacy_id_handler, node_str->str); + iq_id_handler_add(id, _caps_response_legacy_id_handler, node_str->str); g_string_free(node_str, FALSE); send_iq_stanza(iq); @@ -505,7 +505,7 @@ iq_send_software_version(const char *const fulljid) xmpp_stanza_t *iq = stanza_create_software_version_iq(ctx, fulljid); const char *id = xmpp_stanza_get_id(iq); - id_handler_add(id, _version_result_id_handler, strdup(fulljid)); + iq_id_handler_add(id, _version_result_id_handler, strdup(fulljid)); send_iq_stanza(iq); xmpp_stanza_release(iq); @@ -527,7 +527,7 @@ iq_destroy_room(const char *const room_jid) xmpp_stanza_t *iq = stanza_create_instant_room_destroy_iq(ctx, room_jid); const char *id = xmpp_stanza_get_id(iq); - id_handler_add(id, _destroy_room_result_id_handler, NULL); + iq_id_handler_add(id, _destroy_room_result_id_handler, NULL); send_iq_stanza(iq); xmpp_stanza_release(iq); @@ -540,7 +540,7 @@ iq_request_room_config_form(const char *const room_jid) xmpp_stanza_t *iq = stanza_create_room_config_request_iq(ctx, room_jid); const char *id = xmpp_stanza_get_id(iq); - id_handler_add(id, _room_config_id_handler, NULL); + iq_id_handler_add(id, _room_config_id_handler, NULL); send_iq_stanza(iq); xmpp_stanza_release(iq); @@ -553,7 +553,7 @@ iq_submit_room_config(const char *const room, DataForm *form) xmpp_stanza_t *iq = stanza_create_room_config_submit_iq(ctx, room, form); const char *id = xmpp_stanza_get_id(iq); - id_handler_add(id, _room_config_submit_id_handler, NULL); + iq_id_handler_add(id, _room_config_submit_id_handler, NULL); send_iq_stanza(iq); xmpp_stanza_release(iq); @@ -575,7 +575,7 @@ iq_room_affiliation_list(const char *const room, char *affiliation) xmpp_stanza_t *iq = stanza_create_room_affiliation_list_iq(ctx, room, affiliation); const char *id = xmpp_stanza_get_id(iq); - id_handler_add(id, _room_affiliation_list_result_id_handler, strdup(affiliation)); + iq_id_handler_add(id, _room_affiliation_list_result_id_handler, strdup(affiliation)); send_iq_stanza(iq); xmpp_stanza_release(iq); @@ -588,7 +588,7 @@ iq_room_kick_occupant(const char *const room, const char *const nick, const char xmpp_stanza_t *iq = stanza_create_room_kick_iq(ctx, room, nick, reason); const char *id = xmpp_stanza_get_id(iq); - id_handler_add(id, _room_kick_result_id_handler, strdup(nick)); + iq_id_handler_add(id, _room_kick_result_id_handler, strdup(nick)); send_iq_stanza(iq); xmpp_stanza_release(iq); @@ -612,7 +612,7 @@ iq_room_affiliation_set(const char *const room, const char *const jid, char *aff affiliation_set->item = strdup(jid); affiliation_set->privilege = strdup(affiliation); - id_handler_add(id, _room_affiliation_set_result_id_handler, affiliation_set); + iq_id_handler_add(id, _room_affiliation_set_result_id_handler, affiliation_set); send_iq_stanza(iq); xmpp_stanza_release(iq); @@ -631,7 +631,7 @@ iq_room_role_set(const char *const room, const char *const nick, char *role, role_set->item = strdup(nick); role_set->privilege = strdup(role); - id_handler_add(id, _room_role_set_result_id_handler, role_set); + iq_id_handler_add(id, _room_role_set_result_id_handler, role_set); send_iq_stanza(iq); xmpp_stanza_release(iq); @@ -644,7 +644,7 @@ iq_room_role_list(const char *const room, char *role) xmpp_stanza_t *iq = stanza_create_room_role_list_iq(ctx, room, role); const char *id = xmpp_stanza_get_id(iq); - id_handler_add(id, _room_role_list_result_id_handler, strdup(role)); + iq_id_handler_add(id, _room_role_list_result_id_handler, strdup(role)); send_iq_stanza(iq); xmpp_stanza_release(iq); @@ -658,7 +658,7 @@ iq_send_ping(const char *const target) const char *id = xmpp_stanza_get_id(iq); GDateTime *now = g_date_time_new_now_local(); - id_handler_add(id, _manual_pong_id_handler, now); + iq_id_handler_add(id, _manual_pong_id_handler, now); send_iq_stanza(iq); xmpp_stanza_release(iq); @@ -972,7 +972,7 @@ _autoping_timed_send(xmpp_conn_t *const conn, void *const userdata) log_debug("Autoping: Sending ping request: %s", id); // add pong handler - id_handler_add(id, _auto_pong_id_handler, ctx); + iq_id_handler_add(id, _auto_pong_id_handler, ctx); send_iq_stanza(iq); xmpp_stanza_release(iq); diff --git a/src/xmpp/roster.c b/src/xmpp/roster.c index 05afdcd8..b409380a 100644 --- a/src/xmpp/roster.c +++ b/src/xmpp/roster.c @@ -137,7 +137,7 @@ roster_send_add_to_group(const char *const group, PContact contact) } xmpp_ctx_t * const ctx = connection_get_ctx(); - id_handler_add(unique_id, _group_add_id_handler, data); + iq_id_handler_add(unique_id, _group_add_id_handler, data); xmpp_stanza_t *iq = stanza_create_roster_set(ctx, unique_id, p_contact_barejid(contact), p_contact_name(contact), new_groups); send_iq_stanza(iq); @@ -182,7 +182,7 @@ roster_send_remove_from_group(const char *const group, PContact contact) data->name = strdup(p_contact_barejid(contact)); } - id_handler_add(unique_id, _group_remove_id_handler, data); + iq_id_handler_add(unique_id, _group_remove_id_handler, data); xmpp_stanza_t *iq = stanza_create_roster_set(ctx, unique_id, p_contact_barejid(contact), p_contact_name(contact), new_groups); send_iq_stanza(iq); From aabe3afff88a71c295386a22315c183aba894ac9 Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 2 May 2016 22:34:26 +0100 Subject: [PATCH 2/3] Rename stanza handler init functions --- src/xmpp/connection.c | 6 +++--- src/xmpp/iq.c | 2 +- src/xmpp/iq.h | 2 +- src/xmpp/message.c | 2 +- src/xmpp/message.h | 2 +- src/xmpp/presence.c | 2 +- src/xmpp/presence.h | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c index f730c99c..45c0b318 100644 --- a/src/xmpp/connection.c +++ b/src/xmpp/connection.c @@ -688,9 +688,9 @@ _connection_handler(xmpp_conn_t *const conn, const xmpp_conn_event_t status, con chat_sessions_init(); - message_add_handlers(); - presence_add_handlers(); - iq_add_handlers(); + message_handlers_init(); + presence_handlers_init(); + iq_handlers_init(); roster_request(); bookmark_request(); diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index f01f1c15..fa3d90c4 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -193,7 +193,7 @@ _iq_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const us } void -iq_add_handlers(void) +iq_handlers_init(void) { xmpp_conn_t * const conn = connection_get_conn(); xmpp_ctx_t * const ctx = connection_get_ctx(); diff --git a/src/xmpp/iq.h b/src/xmpp/iq.h index 36583a28..5f72eac8 100644 --- a/src/xmpp/iq.h +++ b/src/xmpp/iq.h @@ -35,7 +35,7 @@ #ifndef XMPP_IQ_H #define XMPP_IQ_H -void iq_add_handlers(void); +void iq_handlers_init(void); void iq_roster_request(void); #endif diff --git a/src/xmpp/message.c b/src/xmpp/message.c index 93e78893..6d999d61 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -122,7 +122,7 @@ _message_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *con } void -message_add_handlers(void) +message_handlers_init(void) { xmpp_conn_t * const conn = connection_get_conn(); xmpp_ctx_t * const ctx = connection_get_ctx(); diff --git a/src/xmpp/message.h b/src/xmpp/message.h index 01938572..b886144f 100644 --- a/src/xmpp/message.h +++ b/src/xmpp/message.h @@ -35,6 +35,6 @@ #ifndef XMPP_MESSAGE_H #define XMPP_MESSAGE_H -void message_add_handlers(void); +void message_handlers_init(void); #endif diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c index 0a9b3ce0..d817965a 100644 --- a/src/xmpp/presence.c +++ b/src/xmpp/presence.c @@ -131,7 +131,7 @@ _presence_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *co } void -presence_add_handlers(void) +presence_handlers_init(void) { xmpp_conn_t * const conn = connection_get_conn(); xmpp_ctx_t * const ctx = connection_get_ctx(); diff --git a/src/xmpp/presence.h b/src/xmpp/presence.h index e77a6550..501bf058 100644 --- a/src/xmpp/presence.h +++ b/src/xmpp/presence.h @@ -35,8 +35,8 @@ #ifndef XMPP_PRESENCE_H #define XMPP_PRESENCE_H +void presence_handlers_init(void); void presence_sub_requests_init(void); -void presence_add_handlers(void); void presence_clear_sub_requests(void); #endif From 2e1eb9210a2ed1d543a63dae442d4bd52f547841 Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 2 May 2016 22:49:30 +0100 Subject: [PATCH 3/3] Remove userdata from _blocklist_result_handler --- src/xmpp/blocking.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xmpp/blocking.c b/src/xmpp/blocking.c index 735b9140..206e188d 100644 --- a/src/xmpp/blocking.c +++ b/src/xmpp/blocking.c @@ -73,7 +73,7 @@ blocking_request(void) } blocked_ac = autocomplete_new(); - iq_id_handler_add(id, _blocklist_result_handler, id); + iq_id_handler_add(id, _blocklist_result_handler, NULL); iq = stanza_create_blocked_list_request(ctx); xmpp_stanza_set_id(iq, id);