mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Handle /room config cancel
This commit is contained in:
parent
aa9f1dfa06
commit
64521eb135
@ -455,6 +455,12 @@ handle_room_requires_config(const char * const room)
|
||||
ui_room_requires_config(room);
|
||||
}
|
||||
|
||||
void
|
||||
handle_room_destroy(const char * const room)
|
||||
{
|
||||
ui_room_destroyed(room);
|
||||
}
|
||||
|
||||
void
|
||||
handle_room_roster_complete(const char * const room)
|
||||
{
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user