diff options
author | James Booth <boothj5@gmail.com> | 2014-09-03 22:00:08 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2014-09-03 22:00:08 +0100 |
commit | 64521eb135229c8c6905b6c74668142eaf441a32 (patch) | |
tree | e28c6cbad26ec962a8362b4d0622782ea2398d11 /src | |
parent | aa9f1dfa06038ba095c5410805a26d957fda1cf9 (diff) | |
download | profani-tty-64521eb135229c8c6905b6c74668142eaf441a32.tar.gz |
Handle /room config cancel
Diffstat (limited to 'src')
-rw-r--r-- | src/server_events.c | 6 | ||||
-rw-r--r-- | src/server_events.h | 1 | ||||
-rw-r--r-- | src/ui/core.c | 20 | ||||
-rw-r--r-- | src/ui/ui.h | 1 | ||||
-rw-r--r-- | src/xmpp/iq.c | 73 |
5 files changed, 101 insertions, 0 deletions
diff --git a/src/server_events.c b/src/server_events.c index 4c14d079..47fc2153 100644 --- a/src/server_events.c +++ b/src/server_events.c @@ -456,6 +456,12 @@ handle_room_requires_config(const char * const room) } void +handle_room_destroy(const char * const room) +{ + ui_room_destroyed(room); +} + +void handle_room_roster_complete(const char * const room) { if (muc_room_is_autojoin(room)) { diff --git a/src/server_events.h b/src/server_events.h index e9946ee6..82c0d58d 100644 --- a/src/server_events.h +++ b/src/server_events.h @@ -70,6 +70,7 @@ void handle_leave_room(const char * const room); void handle_room_nick_change(const char * const room, const char * const nick); void handle_room_requires_config(const char * const room); +void handle_room_destroy(const char * const room); void handle_room_roster_complete(const char * const room); void handle_room_member_presence(const char * const room, const char * const nick, const char * const show, diff --git a/src/ui/core.c b/src/ui/core.c index a447031b..4a7bb365 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -1596,6 +1596,10 @@ _ui_room_requires_config(const char * const room_jid) log_error("Received room config request, but no window open for %s.", room_jid); } else { int num = wins_get_num(window); + int ui_index = num; + if (ui_index == 10) { + ui_index = 0; + } win_save_vprint(window, '!', NULL, 0, COLOUR_ROOMINFO, "", "Room requires configuration, use '/room config accept' or '/room config cancel'"); @@ -1607,6 +1611,21 @@ _ui_room_requires_config(const char * const room_jid) } else { status_bar_new(num); } + + cons_show("Room created, locked: %s (%d)", room_jid, ui_index); + } +} + +static void +_ui_room_destroyed(const char * const room_jid) +{ + ProfWin *window = wins_get_by_recipient(room_jid); + if (window == NULL) { + log_error("Received room destroy result, but no window open for %s.", room_jid); + } else { + int num = wins_get_num(window); + ui_close_win(num); + cons_show("Room destroyed: %s", room_jid); } } @@ -2086,4 +2105,5 @@ ui_init_module(void) ui_swap_wins = _ui_swap_wins; ui_update = _ui_update; ui_room_requires_config = _ui_room_requires_config; + ui_room_destroyed = _ui_room_destroyed; } diff --git a/src/ui/ui.h b/src/ui/ui.h index 350561e5..7e8967c0 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -136,6 +136,7 @@ void (*ui_room_message)(const char * const room_jid, const char * const nick, void (*ui_room_subject)(const char * const room_jid, const char * const subject); void (*ui_room_requires_config)(const char * const room_jid); +void (*ui_room_destroyed)(const char * const room_jid); void (*ui_room_broadcast)(const char * const room_jid, const char * const message); void (*ui_room_member_offline)(const char * const room, const char * const nick); diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index bcadbdce..dc7e6de7 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -73,6 +73,8 @@ static int _disco_items_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * const userdata); static int _disco_items_get_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * const userdata); +static int _destroy_room_result_handler(xmpp_conn_t * const conn, + xmpp_stanza_t * const stanza, void * const userdata); static int _ping_timed_handler(xmpp_conn_t * const conn, void * const userdata); @@ -95,6 +97,8 @@ iq_add_handlers(void) HANDLE(STANZA_NS_PING, STANZA_TYPE_GET, _ping_get_handler); + HANDLE(NULL, STANZA_TYPE_RESULT, _destroy_room_result_handler); + if (prefs_get_autoping() != 0) { int millis = prefs_get_autoping() * 1000; xmpp_timed_handler_add(conn, _ping_timed_handler, millis, ctx); @@ -174,6 +178,10 @@ _iq_destroy_instant_room(const char * const room_jid) xmpp_conn_t * const conn = connection_get_conn(); xmpp_ctx_t * const ctx = connection_get_ctx(); xmpp_stanza_t *iq = stanza_create_instant_room_destroy_iq(ctx, room_jid); + + char *id = xmpp_stanza_get_id(iq); + xmpp_id_handler_add(conn, _destroy_room_result_handler, id, NULL); + xmpp_send(conn, iq); xmpp_stanza_release(iq); } @@ -185,8 +193,10 @@ _error_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID); if (id != NULL) { + log_debug("IQ error handler fired, id: %s.", id); log_error("IQ error received, id: %s.", id); } else { + log_debug("IQ error handler fired."); log_error("IQ error received."); } @@ -200,6 +210,12 @@ _pong_handler(xmpp_conn_t *const conn, xmpp_stanza_t * const stanza, char *id = xmpp_stanza_get_id(stanza); char *type = xmpp_stanza_get_type(stanza); + if (id != NULL) { + log_debug("IQ pong handler fired, id: %s.", id); + } else { + log_debug("IQ pong handler fired."); + } + if (id != NULL && type != NULL) { // show warning if error if (strcmp(type, STANZA_TYPE_ERROR) == 0) { @@ -248,6 +264,14 @@ static int _version_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * const userdata) { + char *id = xmpp_stanza_get_id(stanza); + + if (id != NULL) { + log_debug("IQ version result handler fired, id: %s.", id); + } else { + log_debug("IQ version result handler fired."); + } + const char *jid = xmpp_stanza_get_attribute(stanza, "from"); xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); @@ -303,6 +327,12 @@ _ping_get_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, const char *to = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_TO); const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); + if (id != NULL) { + log_debug("IQ ping get handler fired, id: %s.", id); + } else { + log_debug("IQ ping get handler fired."); + } + if ((from == NULL) || (to == NULL)) { return 1; } @@ -331,6 +361,12 @@ _version_get_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID); const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); + if (id != NULL) { + log_debug("IQ version get handler fired, id: %s.", id); + } else { + log_debug("IQ version get handler fired."); + } + if (from != NULL) { xmpp_stanza_t *response = xmpp_stanza_new(ctx); xmpp_stanza_set_name(response, STANZA_NAME_IQ); @@ -390,8 +426,15 @@ _disco_items_get_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * const userdata) { xmpp_ctx_t *ctx = (xmpp_ctx_t *)userdata; + const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID); const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); + if (id != NULL) { + log_debug("IQ disco items get handler fired, id: %s.", id); + } else { + log_debug("IQ disco items get handler fired."); + } + if (from != NULL) { xmpp_stanza_t *response = xmpp_stanza_new(ctx); xmpp_stanza_set_name(response, STANZA_NAME_IQ); @@ -421,6 +464,14 @@ _disco_info_get_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, xmpp_stanza_t *incoming_query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY); const char *node_str = xmpp_stanza_get_attribute(incoming_query, STANZA_ATTR_NODE); + const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID); + + if (id != NULL) { + log_debug("IQ disco info get handler fired, id: %s.", id); + } else { + log_debug("IQ disco info get handler fired."); + } + if (from != NULL) { xmpp_stanza_t *response = xmpp_stanza_new(ctx); xmpp_stanza_set_name(response, STANZA_NAME_IQ); @@ -441,6 +492,28 @@ _disco_info_get_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, return 1; } +static int +_destroy_room_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, + void * const userdata) +{ + const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID); + + if (id != NULL) { + log_debug("IQ destroy room result handler fired, id: %s.", id); + } else { + log_debug("IQ destroy room result handler fired."); + } + + const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); + if (from == NULL) { + log_error("No from attribute for IQ destroy room result"); + } else { + handle_room_destroy(from); + } + + return 0; +} + static void _identity_destroy(DiscoIdentity *identity) { |