about summary refs log tree commit diff stats
path: root/src/xmpp
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-09-03 13:55:06 +0100
committerJames Booth <boothj5@gmail.com>2014-09-03 13:55:06 +0100
commit09c10f62f20bafc599c12038170383853e4dc52e (patch)
treed3cd6c85c2aa329973146d65dc1b3a5845999c04 /src/xmpp
parentd7b3e99a27f232dc5f0c38dfc8712c11ae7b4c30 (diff)
downloadprofani-tty-09c10f62f20bafc599c12038170383853e4dc52e.tar.gz
Send instant room request
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/iq.c11
-rw-r--r--src/xmpp/stanza.c29
-rw-r--r--src/xmpp/stanza.h3
-rw-r--r--src/xmpp/xmpp.h1
4 files changed, 44 insertions, 0 deletions
diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c
index 96c94cd3..d03e635c 100644
--- a/src/xmpp/iq.c
+++ b/src/xmpp/iq.c
@@ -158,6 +158,16 @@ _iq_send_software_version(const char * const fulljid)
     xmpp_stanza_release(iq);
 }
 
+static void
+_iq_create_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_request_iq(ctx, room_jid);
+    xmpp_send(conn, iq);
+    xmpp_stanza_release(iq);
+}
+
 static int
 _error_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
     void * const userdata)
@@ -667,4 +677,5 @@ iq_init_module(void)
     iq_disco_items_request = _iq_disco_items_request;
     iq_send_software_version = _iq_send_software_version;
     iq_set_autoping = _iq_set_autoping;
+    iq_create_instant_room = _iq_create_instant_room;
 }
diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c
index 6d3dcc54..ac8f0dc1 100644
--- a/src/xmpp/stanza.c
+++ b/src/xmpp/stanza.c
@@ -424,6 +424,35 @@ stanza_create_room_leave_presence(xmpp_ctx_t *ctx, const char * const room,
 }
 
 xmpp_stanza_t *
+stanza_create_instant_room_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_SET);
+    xmpp_stanza_set_attribute(iq, STANZA_ATTR_TO, room_jid);
+    char *id = create_unique_id("leave");
+    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, "submit");
+    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 93b584f5..7afea8e5 100644
--- a/src/xmpp/stanza.h
+++ b/src/xmpp/stanza.h
@@ -141,6 +141,7 @@
 #define STANZA_NS_CHATSTATES "http://jabber.org/protocol/chatstates"
 #define STANZA_NS_MUC "http://jabber.org/protocol/muc"
 #define STANZA_NS_MUC_USER "http://jabber.org/protocol/muc#user"
+#define STANZA_NS_MUC_OWNER "http://jabber.org/protocol/muc#owner"
 #define STANZA_NS_CAPS "http://jabber.org/protocol/caps"
 #define STANZA_NS_PING "urn:xmpp:ping"
 #define STANZA_NS_LASTACTIVITY "jabber:iq:last"
@@ -201,6 +202,8 @@ gboolean stanza_is_room_nick_change(xmpp_stanza_t * const stanza);
 gboolean stanza_muc_requires_config(xmpp_stanza_t * const stanza);
 
 char * stanza_get_new_nick(xmpp_stanza_t * const stanza);
+xmpp_stanza_t* stanza_create_instant_room_request_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 22f550e3..cd28ddd2 100644
--- a/src/xmpp/xmpp.h
+++ b/src/xmpp/xmpp.h
@@ -139,6 +139,7 @@ void (*iq_room_list_request)(gchar *conferencejid);
 void (*iq_disco_info_request)(gchar *jid);
 void (*iq_disco_items_request)(gchar *jid);
 void (*iq_set_autoping)(int seconds);
+void (*iq_create_instant_room)(const char * const room_jid);
 
 // caps functions
 Capabilities* (*caps_get)(const char * const caps_str);
e4adee718fbff87cbcb5a82fcb9496d701211'>a84e4ade ^
a2726b6a ^
a84e4ade ^



























dd11334b ^
a2726b6a ^
da5104f8 ^
59788752 ^
0346fda0 ^

0346fda0 ^

da5104f8 ^
37742d71 ^

a2726b6a ^
37742d71 ^

a2726b6a ^
37742d71 ^








a2726b6a ^










37742d71 ^



a2726b6a ^
37742d71 ^




















a2726b6a ^










37742d71 ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165