about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/command/command.c13
-rw-r--r--src/command/commands.c33
-rw-r--r--src/ui/core.c3
-rw-r--r--src/xmpp/iq.c22
-rw-r--r--src/xmpp/stanza.c54
-rw-r--r--src/xmpp/stanza.h4
-rw-r--r--src/xmpp/xmpp.h2
7 files changed, 114 insertions, 17 deletions
diff --git a/src/command/command.c b/src/command/command.c
index ecfbca3a..73902ad3 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -306,10 +306,13 @@ static struct cmd_t command_defs[] =
 
     { "/room",
         cmd_room, parse_args, 2, 2, NULL,
-        { "/room config accept|cancel", "Room configuration.",
-        { "/room config accept|cncel",
-          "-------------------------",
-          "Accept or cancel default room configuration.",
+        { "/room config accept|destroy|edit|cancel", "Room configuration.",
+        { "/room config accept|destroy|edit|cancel",
+          "---------------------------------------",
+          "config accept  - Accept default room configuration.",
+          "config destroy - Cancel default room configuration.",
+          "config edit    - Edit room configuration.",
+          "config cancel  - Cancel room configuration.",
           NULL } } },
 
     { "/rooms",
@@ -1210,6 +1213,8 @@ cmd_init(void)
 
     room_config_ac = autocomplete_new();
     autocomplete_add(room_config_ac, "accept");
+    autocomplete_add(room_config_ac, "destroy");
+    autocomplete_add(room_config_ac, "edit");
     autocomplete_add(room_config_ac, "cancel");
 
     cmd_history_init();
diff --git a/src/command/commands.c b/src/command/commands.c
index 7b49ad61..e6ec9e2d 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -1809,7 +1809,9 @@ cmd_room(gchar **args, struct cmd_help_t help)
     }
 
     if ((g_strcmp0(args[1], "accept") != 0) &&
-            (g_strcmp0(args[1], "cancel") != 0)) {
+            (g_strcmp0(args[1], "cancel") != 0) &&
+            (g_strcmp0(args[1], "destroy") != 0) &&
+            (g_strcmp0(args[1], "edit") != 0)) {
         cons_show("Usage: %s", help.usage);
         return TRUE;
     }
@@ -1821,22 +1823,33 @@ cmd_room(gchar **args, struct cmd_help_t help)
     if (ui_index == 10) {
         ui_index = 0;
     }
-    gboolean requires_config = muc_requires_config(room);
-    if (!requires_config) {
-        win_save_vprint(window, '!', NULL, 0, COLOUR_ROOMINFO, "", "Current room does not require configuration.");
+
+    if (g_strcmp0(args[1], "accept") == 0) {
+        gboolean requires_config = muc_requires_config(room);
+        if (!requires_config) {
+            win_save_vprint(window, '!', NULL, 0, COLOUR_ROOMINFO, "", "Current room does not require configuration.");
+            return TRUE;
+        } else {
+            iq_confirm_instant_room(room);
+            muc_set_requires_config(room, FALSE);
+            win_save_vprint(window, '!', NULL, 0, COLOUR_ROOMINFO, "", "Room unlocked.");
+            cons_show("Room unlocked: %s (%d)", room, ui_index);
+            return TRUE;
+        }
+    }
+
+    if (g_strcmp0(args[1], "destroy") == 0) {
+        iq_destroy_instant_room(room);
         return TRUE;
     }
 
-    if (g_strcmp0(args[1], "accept") == 0) {
-        iq_confirm_instant_room(room);
-        muc_set_requires_config(room, FALSE);
-        win_save_vprint(window, '!', NULL, 0, COLOUR_ROOMINFO, "", "Room unlocked.");
-        cons_show("Room unlocked: %s (%d)", room, ui_index);
+    if (g_strcmp0(args[1], "edit") == 0) {
+        iq_request_room_config_form(room);
         return TRUE;
     }
 
     if (g_strcmp0(args[1], "cancel") == 0) {
-        iq_destroy_instant_room(room);
+        iq_room_config_cancel(room);
         return TRUE;
     }
 
diff --git a/src/ui/core.c b/src/ui/core.c
index 4a7bb365..8495cd23 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -1601,7 +1601,8 @@ _ui_room_requires_config(const char * const room_jid)
             ui_index = 0;
         }
 
-        win_save_vprint(window, '!', NULL, 0, COLOUR_ROOMINFO, "", "Room requires configuration, use '/room config accept' or '/room config cancel'");
+        win_save_vprint(window, '!', NULL, 0, COLOUR_ROOMINFO, "",
+            "Room requires configuration, use '/room config accept' or '/room config destroy'");
 
         // currently in groupchat window
         if (wins_is_current(window)) {
diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c
index 17269fe2..9e1bf759 100644
--- a/src/xmpp/iq.c
+++ b/src/xmpp/iq.c
@@ -189,6 +189,26 @@ _iq_destroy_instant_room(const char * const room_jid)
 }
 
 static void
+_iq_request_room_config_form(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_room_config_request_iq(ctx, room_jid);
+    xmpp_send(conn, iq);
+    xmpp_stanza_release(iq);
+}
+
+static void
+_iq_room_config_cancel(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_room_config_cancel_iq(ctx, room_jid);
+    xmpp_send(conn, iq);
+    xmpp_stanza_release(iq);
+}
+
+static void
 _iq_send_ping(const char * const target)
 {
     xmpp_conn_t * const conn = connection_get_conn();
@@ -800,4 +820,6 @@ iq_init_module(void)
     iq_confirm_instant_room = _iq_confirm_instant_room;
     iq_destroy_instant_room = _iq_destroy_instant_room;
     iq_send_ping = _iq_send_ping;
+    iq_request_room_config_form = _iq_request_room_config_form;
+    iq_room_config_cancel = _iq_room_config_cancel;
 }
diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c
index e068eeed..b37d3fbd 100644
--- a/src/xmpp/stanza.c
+++ b/src/xmpp/stanza.c
@@ -430,7 +430,7 @@ stanza_create_instant_room_request_iq(xmpp_ctx_t *ctx, const char * const room_j
     xmpp_stanza_set_name(iq, STANZA_NAME_IQ);
     xmpp_stanza_set_type(iq, STANZA_TYPE_SET);
     xmpp_stanza_set_attribute(iq, STANZA_ATTR_TO, room_jid);
-    char *id = create_unique_id("leave");
+    char *id = create_unique_id("room");
     xmpp_stanza_set_id(iq, id);
     free(id);
 
@@ -459,7 +459,7 @@ stanza_create_instant_room_destroy_iq(xmpp_ctx_t *ctx, const char * const room_j
     xmpp_stanza_set_name(iq, STANZA_NAME_IQ);
     xmpp_stanza_set_type(iq, STANZA_TYPE_SET);
     xmpp_stanza_set_attribute(iq, STANZA_ATTR_TO, room_jid);
-    char *id = create_unique_id("leave");
+    char *id = create_unique_id("room");
     xmpp_stanza_set_id(iq, id);
     free(id);
 
@@ -480,6 +480,56 @@ stanza_create_instant_room_destroy_iq(xmpp_ctx_t *ctx, const char * const room_j
 }
 
 xmpp_stanza_t *
+stanza_create_room_config_request_iq(xmpp_ctx_t *ctx, const char * const room_jid)
+{
+    xmpp_stanza_t *iq = xmpp_stanza_new(ctx);
+    xmpp_stanza_set_name(iq, STANZA_NAME_IQ);
+    xmpp_stanza_set_type(iq, STANZA_TYPE_GET);
+    xmpp_stanza_set_attribute(iq, STANZA_ATTR_TO, room_jid);
+    char *id = create_unique_id("room");
+    xmpp_stanza_set_id(iq, id);
+    free(id);
+
+    xmpp_stanza_t *query = xmpp_stanza_new(ctx);
+    xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
+    xmpp_stanza_set_ns(query, STANZA_NS_MUC_OWNER);
+
+    xmpp_stanza_add_child(iq, query);
+    xmpp_stanza_release(query);
+
+    return iq;
+}
+
+xmpp_stanza_t *
+stanza_create_room_config_cancel_iq(xmpp_ctx_t *ctx, const char * const room_jid)
+{
+    xmpp_stanza_t *iq = xmpp_stanza_new(ctx);
+    xmpp_stanza_set_name(iq, STANZA_NAME_IQ);
+    xmpp_stanza_set_type(iq, STANZA_TYPE_SET);
+    xmpp_stanza_set_attribute(iq, STANZA_ATTR_TO, room_jid);
+    char *id = create_unique_id("room");
+    xmpp_stanza_set_id(iq, id);
+    free(id);
+
+    xmpp_stanza_t *query = xmpp_stanza_new(ctx);
+    xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
+    xmpp_stanza_set_ns(query, STANZA_NS_MUC_OWNER);
+
+    xmpp_stanza_t *x = xmpp_stanza_new(ctx);
+    xmpp_stanza_set_name(x, STANZA_NAME_X);
+    xmpp_stanza_set_type(x, "cancel");
+    xmpp_stanza_set_ns(x, STANZA_NS_DATA);
+
+    xmpp_stanza_add_child(query, x);
+    xmpp_stanza_release(x);
+
+    xmpp_stanza_add_child(iq, query);
+    xmpp_stanza_release(query);
+
+    return iq;
+}
+
+xmpp_stanza_t *
 stanza_create_presence(xmpp_ctx_t * const ctx)
 {
     xmpp_stanza_t *presence = xmpp_stanza_new(ctx);
diff --git a/src/xmpp/stanza.h b/src/xmpp/stanza.h
index 3d925787..ea8e0cdb 100644
--- a/src/xmpp/stanza.h
+++ b/src/xmpp/stanza.h
@@ -207,6 +207,10 @@ xmpp_stanza_t* stanza_create_instant_room_request_iq(xmpp_ctx_t *ctx,
     const char * const room_jid);
 xmpp_stanza_t* stanza_create_instant_room_destroy_iq(xmpp_ctx_t *ctx,
     const char * const room_jid);
+xmpp_stanza_t* stanza_create_room_config_request_iq(xmpp_ctx_t *ctx,
+    const char * const room_jid);
+xmpp_stanza_t* stanza_create_room_config_cancel_iq(xmpp_ctx_t *ctx,
+    const char * const room_jid);
 
 int stanza_get_idle_time(xmpp_stanza_t * const stanza);
 char * stanza_get_caps_str(xmpp_stanza_t * const stanza);
diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h
index 78703230..c1060c69 100644
--- a/src/xmpp/xmpp.h
+++ b/src/xmpp/xmpp.h
@@ -141,6 +141,8 @@ void (*iq_disco_items_request)(gchar *jid);
 void (*iq_set_autoping)(int seconds);
 void (*iq_confirm_instant_room)(const char * const room_jid);
 void (*iq_destroy_instant_room)(const char * const room_jid);
+void (*iq_request_room_config_form)(const char * const room_jid);
+void (*iq_room_config_cancel)(const char * const room_jid);
 void (*iq_send_ping)(const char * const target);
 
 // caps functions