Thu, 13 Feb 2020 20:57:31 -0600
Move the libidn check to jabber/meson.build as it needs specific functions of the library
| 7923 | 1 | /* |
| 15884 | 2 | * purple - Jabber Protocol Plugin |
| 7923 | 3 | * |
|
28322
ac8fec1d2234
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents:
26565
diff
changeset
|
4 | * Purple is the legal property of its developers, whose names are too numerous |
|
ac8fec1d2234
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents:
26565
diff
changeset
|
5 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
ac8fec1d2234
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents:
26565
diff
changeset
|
6 | * source distribution. |
| 7923 | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify | |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 19 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19051
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 7923 | 21 | * |
| 22 | */ | |
| 23 | #include "internal.h" | |
| 24 | #include "request.h" | |
| 25 | #include "server.h" | |
| 26 | ||
| 27 | #include "xdata.h" | |
| 28 | ||
| 29 | typedef enum { | |
| 30 | JABBER_X_DATA_IGNORE = 0, | |
| 31 | JABBER_X_DATA_TEXT_SINGLE, | |
| 32 | JABBER_X_DATA_TEXT_MULTI, | |
| 33 | JABBER_X_DATA_LIST_SINGLE, | |
| 34 | JABBER_X_DATA_LIST_MULTI, | |
| 8295 | 35 | JABBER_X_DATA_BOOLEAN, |
| 36 | JABBER_X_DATA_JID_SINGLE | |
| 7923 | 37 | } jabber_x_data_field_type; |
| 38 | ||
| 39 | struct jabber_x_data_data { | |
| 40 | GHashTable *fields; | |
| 41 | GSList *values; | |
|
17805
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
42 | jabber_x_data_action_cb cb; |
| 7923 | 43 | gpointer user_data; |
| 44 | JabberStream *js; | |
|
17805
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
45 | GList *actions; |
|
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
46 | PurpleRequestFieldGroup *actiongroup; |
| 7923 | 47 | }; |
| 48 | ||
| 15884 | 49 | static void jabber_x_data_ok_cb(struct jabber_x_data_data *data, PurpleRequestFields *fields) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
50 | PurpleXmlNode *result = purple_xmlnode_new("x"); |
|
17805
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
51 | jabber_x_data_action_cb cb = data->cb; |
| 7923 | 52 | gpointer user_data = data->user_data; |
| 53 | JabberStream *js = data->js; | |
| 54 | GList *groups, *flds; | |
|
17805
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
55 | char *actionhandle = NULL; |
|
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
56 | gboolean hasActions = (data->actions != NULL); |
| 7923 | 57 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
58 | purple_xmlnode_set_namespace(result, "jabber:x:data"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
59 | purple_xmlnode_set_attrib(result, "type", "submit"); |
| 7923 | 60 | |
| 15884 | 61 | for(groups = purple_request_fields_get_groups(fields); groups; groups = groups->next) { |
|
17805
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
62 | if(groups->data == data->actiongroup) { |
|
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
63 | for(flds = purple_request_field_group_get_fields(groups->data); flds; flds = flds->next) { |
|
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
64 | PurpleRequestField *field = flds->data; |
|
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
65 | const char *id = purple_request_field_get_id(field); |
|
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
66 | int handleindex; |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
67 | if(!purple_strequal(id, "libpurple:jabber:xdata:actions")) |
|
17805
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
68 | continue; |
|
34338
c652670afac5
Request API refactoring: custom PURPLE_REQUEST_CHOICE values, instead of indexes
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34332
diff
changeset
|
69 | handleindex = GPOINTER_TO_INT(purple_request_field_choice_get_value(field)); |
|
17805
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
70 | actionhandle = g_strdup(g_list_nth_data(data->actions, handleindex)); |
|
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
71 | break; |
|
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
72 | } |
|
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
73 | continue; |
|
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
74 | } |
| 15884 | 75 | for(flds = purple_request_field_group_get_fields(groups->data); flds; flds = flds->next) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
76 | PurpleXmlNode *fieldnode, *valuenode; |
| 15884 | 77 | PurpleRequestField *field = flds->data; |
| 78 | const char *id = purple_request_field_get_id(field); | |
| 7923 | 79 | jabber_x_data_field_type type = GPOINTER_TO_INT(g_hash_table_lookup(data->fields, id)); |
| 80 | ||
| 81 | switch(type) { | |
| 82 | case JABBER_X_DATA_TEXT_SINGLE: | |
| 8295 | 83 | case JABBER_X_DATA_JID_SINGLE: |
| 7923 | 84 | { |
| 15884 | 85 | const char *value = purple_request_field_string_get_value(field); |
|
16398
a895aca0a7ce
Ok I couldn't resist. For iChat and Adium buddies who are advertising
Mark Doliner <markdoliner@pidgin.im>
parents:
16136
diff
changeset
|
86 | if (value == NULL) |
|
a895aca0a7ce
Ok I couldn't resist. For iChat and Adium buddies who are advertising
Mark Doliner <markdoliner@pidgin.im>
parents:
16136
diff
changeset
|
87 | break; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
88 | fieldnode = purple_xmlnode_new_child(result, "field"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
89 | purple_xmlnode_set_attrib(fieldnode, "var", id); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
90 | valuenode = purple_xmlnode_new_child(fieldnode, "value"); |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38358
diff
changeset
|
91 | purple_xmlnode_insert_data(valuenode, value, -1); |
| 7923 | 92 | break; |
| 93 | } | |
| 94 | case JABBER_X_DATA_TEXT_MULTI: | |
| 95 | { | |
| 96 | char **pieces, **p; | |
| 15884 | 97 | const char *value = purple_request_field_string_get_value(field); |
|
16398
a895aca0a7ce
Ok I couldn't resist. For iChat and Adium buddies who are advertising
Mark Doliner <markdoliner@pidgin.im>
parents:
16136
diff
changeset
|
98 | if (value == NULL) |
|
a895aca0a7ce
Ok I couldn't resist. For iChat and Adium buddies who are advertising
Mark Doliner <markdoliner@pidgin.im>
parents:
16136
diff
changeset
|
99 | break; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
100 | fieldnode = purple_xmlnode_new_child(result, "field"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
101 | purple_xmlnode_set_attrib(fieldnode, "var", id); |
| 7923 | 102 | |
| 103 | pieces = g_strsplit(value, "\n", -1); | |
| 104 | for(p = pieces; *p != NULL; p++) { | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
105 | valuenode = purple_xmlnode_new_child(fieldnode, "value"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
106 | purple_xmlnode_insert_data(valuenode, *p, -1); |
| 7923 | 107 | } |
| 108 | g_strfreev(pieces); | |
| 109 | } | |
| 110 | break; | |
| 111 | case JABBER_X_DATA_LIST_SINGLE: | |
| 112 | case JABBER_X_DATA_LIST_MULTI: | |
| 113 | { | |
|
18190
bcf28ef7e8ff
Re-fix the DBus list handling code by killing const GList* / const GSList*
Richard Laager <rlaager@pidgin.im>
parents:
16490
diff
changeset
|
114 | GList *selected = purple_request_field_list_get_selected(field); |
| 7923 | 115 | char *value; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
116 | fieldnode = purple_xmlnode_new_child(result, "field"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
117 | purple_xmlnode_set_attrib(fieldnode, "var", id); |
| 7923 | 118 | |
| 119 | while(selected) { | |
| 15884 | 120 | value = purple_request_field_list_get_data(field, selected->data); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
121 | valuenode = purple_xmlnode_new_child(fieldnode, "value"); |
| 7923 | 122 | if(value) |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
123 | purple_xmlnode_insert_data(valuenode, value, -1); |
| 7923 | 124 | selected = selected->next; |
| 125 | } | |
| 126 | } | |
| 127 | break; | |
| 128 | case JABBER_X_DATA_BOOLEAN: | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
129 | fieldnode = purple_xmlnode_new_child(result, "field"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
130 | purple_xmlnode_set_attrib(fieldnode, "var", id); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
131 | valuenode = purple_xmlnode_new_child(fieldnode, "value"); |
| 15884 | 132 | if(purple_request_field_bool_get_value(field)) |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
133 | purple_xmlnode_insert_data(valuenode, "1", -1); |
| 7923 | 134 | else |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
135 | purple_xmlnode_insert_data(valuenode, "0", -1); |
| 7923 | 136 | break; |
| 137 | case JABBER_X_DATA_IGNORE: | |
| 138 | break; | |
| 139 | } | |
| 140 | } | |
| 141 | } | |
| 142 | ||
| 143 | g_hash_table_destroy(data->fields); | |
|
40052
cc03b5af25ea
Use GSList functions instead of manual iterations
qarkai <qarkai@gmail.com>
parents:
40049
diff
changeset
|
144 | g_slist_free_full(data->values, g_free); |
| 40047 | 145 | g_list_free_full(data->actions, g_free); |
| 7923 | 146 | g_free(data); |
| 147 | ||
|
26565
94071f2569f2
Fix a potential memleak by freeing this regardless of whether hasActions
Mark Doliner <markdoliner@pidgin.im>
parents:
26042
diff
changeset
|
148 | if (hasActions) |
|
17805
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
149 | cb(js, result, actionhandle, user_data); |
|
26565
94071f2569f2
Fix a potential memleak by freeing this regardless of whether hasActions
Mark Doliner <markdoliner@pidgin.im>
parents:
26042
diff
changeset
|
150 | else |
|
17805
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
151 | ((jabber_x_data_cb)cb)(js, result, user_data); |
|
26565
94071f2569f2
Fix a potential memleak by freeing this regardless of whether hasActions
Mark Doliner <markdoliner@pidgin.im>
parents:
26042
diff
changeset
|
152 | |
|
94071f2569f2
Fix a potential memleak by freeing this regardless of whether hasActions
Mark Doliner <markdoliner@pidgin.im>
parents:
26042
diff
changeset
|
153 | g_free(actionhandle); |
| 7923 | 154 | } |
| 155 | ||
| 15884 | 156 | static void jabber_x_data_cancel_cb(struct jabber_x_data_data *data, PurpleRequestFields *fields) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
157 | PurpleXmlNode *result = purple_xmlnode_new("x"); |
|
17805
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
158 | jabber_x_data_action_cb cb = data->cb; |
| 7923 | 159 | gpointer user_data = data->user_data; |
| 160 | JabberStream *js = data->js; | |
| 40049 | 161 | gboolean hasActions = (data->actions != NULL); |
| 7923 | 162 | g_hash_table_destroy(data->fields); |
|
40052
cc03b5af25ea
Use GSList functions instead of manual iterations
qarkai <qarkai@gmail.com>
parents:
40049
diff
changeset
|
163 | g_slist_free_full(data->values, g_free); |
| 40049 | 164 | g_list_free_full(data->actions, g_free); |
| 7923 | 165 | g_free(data); |
| 166 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
167 | purple_xmlnode_set_namespace(result, "jabber:x:data"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
168 | purple_xmlnode_set_attrib(result, "type", "cancel"); |
| 7923 | 169 | |
|
17805
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
170 | if (hasActions) |
|
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
171 | cb(js, result, NULL, user_data); |
|
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
172 | else |
|
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
173 | ((jabber_x_data_cb)cb)(js, result, user_data); |
| 7923 | 174 | } |
| 175 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
176 | void *jabber_x_data_request(JabberStream *js, PurpleXmlNode *packet, jabber_x_data_cb cb, gpointer user_data) |
| 7923 | 177 | { |
|
17805
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
178 | return jabber_x_data_request_with_actions(js, packet, NULL, 0, (jabber_x_data_action_cb)cb, user_data); |
|
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
179 | } |
|
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
180 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
181 | void *jabber_x_data_request_with_actions(JabberStream *js, PurpleXmlNode *packet, GList *actions, int defaultaction, jabber_x_data_action_cb cb, gpointer user_data) |
|
17805
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
182 | { |
| 8396 | 183 | void *handle; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
184 | PurpleXmlNode *fn, *x; |
| 15884 | 185 | PurpleRequestFields *fields; |
| 186 | PurpleRequestFieldGroup *group; | |
|
23493
e04778a3d29a
Kill the warning 'field' may be used uninitialized in this function
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23176
diff
changeset
|
187 | PurpleRequestField *field = NULL; |
| 7923 | 188 | |
| 189 | char *title = NULL; | |
| 190 | char *instructions = NULL; | |
| 191 | ||
| 192 | struct jabber_x_data_data *data = g_new0(struct jabber_x_data_data, 1); | |
| 193 | ||
| 194 | data->fields = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); | |
| 195 | data->user_data = user_data; | |
| 196 | data->cb = cb; | |
| 197 | data->js = js; | |
| 198 | ||
| 15884 | 199 | fields = purple_request_fields_new(); |
| 200 | group = purple_request_field_group_new(NULL); | |
| 201 | purple_request_fields_add_group(fields, group); | |
| 7923 | 202 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
203 | for(fn = purple_xmlnode_get_child(packet, "field"); fn; fn = purple_xmlnode_get_next_twin(fn)) { |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
204 | PurpleXmlNode *valuenode; |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
205 | const char *type = purple_xmlnode_get_attrib(fn, "type"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
206 | const char *label = purple_xmlnode_get_attrib(fn, "label"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
207 | const char *var = purple_xmlnode_get_attrib(fn, "var"); |
| 8135 | 208 | char *value = NULL; |
| 209 | ||
| 210 | if(!type) | |
|
17837
a9c447447c06
XEP-0004 says that if no field type is specified, text-single should be assumed.
Andreas Monitzer <am@adiumx.com>
parents:
17805
diff
changeset
|
211 | type = "text-single"; |
| 8135 | 212 | |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
213 | if(!var && !purple_strequal(type, "fixed")) |
| 8135 | 214 | continue; |
| 215 | if(!label) | |
| 216 | label = var; | |
| 217 | ||
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
30511
diff
changeset
|
218 | if(purple_strequal(type, "text-private")) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
219 | if((valuenode = purple_xmlnode_get_child(fn, "value"))) |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
220 | value = purple_xmlnode_get_data(valuenode); |
| 8135 | 221 | |
| 15884 | 222 | field = purple_request_field_string_new(var, label, |
| 8135 | 223 | value ? value : "", FALSE); |
| 15884 | 224 | purple_request_field_string_set_masked(field, TRUE); |
| 225 | purple_request_field_group_add_field(group, field); | |
| 8135 | 226 | |
| 227 | g_hash_table_replace(data->fields, g_strdup(var), GINT_TO_POINTER(JABBER_X_DATA_TEXT_SINGLE)); | |
| 228 | ||
|
16136
49ddb8f06d96
I noticed some places where we were doing the whole
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
229 | g_free(value); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
30511
diff
changeset
|
230 | } else if(purple_strequal(type, "text-multi") || purple_strequal(type, "jid-multi")) { |
| 8135 | 231 | GString *str = g_string_new(""); |
| 232 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
233 | for(valuenode = purple_xmlnode_get_child(fn, "value"); valuenode; |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
234 | valuenode = purple_xmlnode_get_next_twin(valuenode)) { |
| 8135 | 235 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
236 | if(!(value = purple_xmlnode_get_data(valuenode))) |
| 8135 | 237 | continue; |
| 238 | ||
| 239 | g_string_append_printf(str, "%s\n", value); | |
| 240 | g_free(value); | |
| 241 | } | |
| 242 | ||
| 15884 | 243 | field = purple_request_field_string_new(var, label, |
| 8135 | 244 | str->str, TRUE); |
| 15884 | 245 | purple_request_field_group_add_field(group, field); |
| 7923 | 246 | |
| 8135 | 247 | g_hash_table_replace(data->fields, g_strdup(var), GINT_TO_POINTER(JABBER_X_DATA_TEXT_MULTI)); |
| 248 | ||
| 249 | g_string_free(str, TRUE); | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
30511
diff
changeset
|
250 | } else if(purple_strequal(type, "list-single") || purple_strequal(type, "list-multi")) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
251 | PurpleXmlNode *optnode; |
| 8135 | 252 | GList *selected = NULL; |
| 253 | ||
| 15884 | 254 | field = purple_request_field_list_new(var, label); |
| 8135 | 255 | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
30511
diff
changeset
|
256 | if(purple_strequal(type, "list-multi")) { |
| 15884 | 257 | purple_request_field_list_set_multi_select(field, TRUE); |
| 8135 | 258 | g_hash_table_replace(data->fields, g_strdup(var), |
| 259 | GINT_TO_POINTER(JABBER_X_DATA_LIST_MULTI)); | |
| 260 | } else { | |
| 261 | g_hash_table_replace(data->fields, g_strdup(var), | |
| 262 | GINT_TO_POINTER(JABBER_X_DATA_LIST_SINGLE)); | |
| 263 | } | |
| 264 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
265 | for(valuenode = purple_xmlnode_get_child(fn, "value"); valuenode; |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
266 | valuenode = purple_xmlnode_get_next_twin(valuenode)) { |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
267 | char *data = purple_xmlnode_get_data(valuenode); |
|
22664
d2e81c1408ae
If the default value of a list-single or list-multi data forms field is NULL
Etan Reisner <deryni@pidgin.im>
parents:
21653
diff
changeset
|
268 | if (data != NULL) { |
|
d2e81c1408ae
If the default value of a list-single or list-multi data forms field is NULL
Etan Reisner <deryni@pidgin.im>
parents:
21653
diff
changeset
|
269 | selected = g_list_prepend(selected, data); |
|
d2e81c1408ae
If the default value of a list-single or list-multi data forms field is NULL
Etan Reisner <deryni@pidgin.im>
parents:
21653
diff
changeset
|
270 | } |
| 8135 | 271 | } |
| 7923 | 272 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
273 | for(optnode = purple_xmlnode_get_child(fn, "option"); optnode; |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
274 | optnode = purple_xmlnode_get_next_twin(optnode)) { |
| 8135 | 275 | const char *lbl; |
| 276 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
277 | if(!(valuenode = purple_xmlnode_get_child(optnode, "value"))) |
| 8135 | 278 | continue; |
| 279 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
280 | if(!(value = purple_xmlnode_get_data(valuenode))) |
| 8135 | 281 | continue; |
| 282 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
283 | if(!(lbl = purple_xmlnode_get_attrib(optnode, "label"))) |
|
19051
b932fc2e28cd
For XMPP multi-selection lists in generic data forms, the intent here
Mark Doliner <markdoliner@pidgin.im>
parents:
18190
diff
changeset
|
284 | lbl = value; |
| 8135 | 285 | |
| 286 | data->values = g_slist_prepend(data->values, value); | |
| 287 | ||
|
24900
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
23493
diff
changeset
|
288 | purple_request_field_list_add_icon(field, lbl, NULL, value); |
| 8135 | 289 | if(g_list_find_custom(selected, value, (GCompareFunc)strcmp)) |
| 15884 | 290 | purple_request_field_list_add_selected(field, lbl); |
| 8135 | 291 | } |
| 15884 | 292 | purple_request_field_group_add_field(group, field); |
| 8135 | 293 | |
|
40062
d25228fc7b8e
Use g_list_free_full instead of manual iterations
qarkai <qarkai@gmail.com>
parents:
40052
diff
changeset
|
294 | g_list_free_full(selected, g_free); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
30511
diff
changeset
|
295 | } else if(purple_strequal(type, "boolean")) { |
| 8135 | 296 | gboolean def = FALSE; |
| 7923 | 297 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
298 | if((valuenode = purple_xmlnode_get_child(fn, "value"))) |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
299 | value = purple_xmlnode_get_data(valuenode); |
| 7923 | 300 | |
|
8390
13e1ff9b2850
[gaim-migrate @ 9119]
Mark Doliner <markdoliner@pidgin.im>
parents:
8385
diff
changeset
|
301 | if(value && (!g_ascii_strcasecmp(value, "yes") || |
|
13e1ff9b2850
[gaim-migrate @ 9119]
Mark Doliner <markdoliner@pidgin.im>
parents:
8385
diff
changeset
|
302 | !g_ascii_strcasecmp(value, "true") || !g_ascii_strcasecmp(value, "1"))) |
| 8135 | 303 | def = TRUE; |
| 7923 | 304 | |
| 15884 | 305 | field = purple_request_field_bool_new(var, label, def); |
| 306 | purple_request_field_group_add_field(group, field); | |
| 7923 | 307 | |
| 8135 | 308 | g_hash_table_replace(data->fields, g_strdup(var), GINT_TO_POINTER(JABBER_X_DATA_BOOLEAN)); |
| 7923 | 309 | |
|
16136
49ddb8f06d96
I noticed some places where we were doing the whole
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
310 | g_free(value); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
30511
diff
changeset
|
311 | } else if(purple_strequal(type, "fixed")) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
312 | if((valuenode = purple_xmlnode_get_child(fn, "value"))) |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
313 | value = purple_xmlnode_get_data(valuenode); |
| 7923 | 314 | |
|
23176
90f6226370cb
applied changes from 069f197178d158cdd308687095c14d49d8eee0ed
Daniel Atallah <datallah@pidgin.im>
parents:
22664
diff
changeset
|
315 | if(value != NULL) { |
|
90f6226370cb
applied changes from 069f197178d158cdd308687095c14d49d8eee0ed
Daniel Atallah <datallah@pidgin.im>
parents:
22664
diff
changeset
|
316 | field = purple_request_field_label_new("", value); |
|
90f6226370cb
applied changes from 069f197178d158cdd308687095c14d49d8eee0ed
Daniel Atallah <datallah@pidgin.im>
parents:
22664
diff
changeset
|
317 | purple_request_field_group_add_field(group, field); |
| 7923 | 318 | |
|
23176
90f6226370cb
applied changes from 069f197178d158cdd308687095c14d49d8eee0ed
Daniel Atallah <datallah@pidgin.im>
parents:
22664
diff
changeset
|
319 | g_free(value); |
|
90f6226370cb
applied changes from 069f197178d158cdd308687095c14d49d8eee0ed
Daniel Atallah <datallah@pidgin.im>
parents:
22664
diff
changeset
|
320 | } |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
30511
diff
changeset
|
321 | } else if(purple_strequal(type, "hidden")) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
322 | if((valuenode = purple_xmlnode_get_child(fn, "value"))) |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
323 | value = purple_xmlnode_get_data(valuenode); |
| 7923 | 324 | |
| 15884 | 325 | field = purple_request_field_string_new(var, "", value ? value : "", |
| 8135 | 326 | FALSE); |
| 15884 | 327 | purple_request_field_set_visible(field, FALSE); |
| 328 | purple_request_field_group_add_field(group, field); | |
| 7923 | 329 | |
| 8135 | 330 | g_hash_table_replace(data->fields, g_strdup(var), GINT_TO_POINTER(JABBER_X_DATA_TEXT_SINGLE)); |
| 7923 | 331 | |
|
16136
49ddb8f06d96
I noticed some places where we were doing the whole
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
332 | g_free(value); |
| 8135 | 333 | } else { /* text-single, jid-single, and the default */ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
334 | if((valuenode = purple_xmlnode_get_child(fn, "value"))) |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
335 | value = purple_xmlnode_get_data(valuenode); |
| 7923 | 336 | |
| 15884 | 337 | field = purple_request_field_string_new(var, label, |
| 8135 | 338 | value ? value : "", FALSE); |
| 15884 | 339 | purple_request_field_group_add_field(group, field); |
| 7923 | 340 | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
30511
diff
changeset
|
341 | if(purple_strequal(type, "jid-single")) { |
| 15884 | 342 | purple_request_field_set_type_hint(field, "screenname"); |
| 8295 | 343 | g_hash_table_replace(data->fields, g_strdup(var), GINT_TO_POINTER(JABBER_X_DATA_JID_SINGLE)); |
| 344 | } else { | |
| 345 | g_hash_table_replace(data->fields, g_strdup(var), GINT_TO_POINTER(JABBER_X_DATA_TEXT_SINGLE)); | |
| 346 | } | |
| 7923 | 347 | |
|
16136
49ddb8f06d96
I noticed some places where we were doing the whole
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
348 | g_free(value); |
| 7923 | 349 | } |
|
19894
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
19203
diff
changeset
|
350 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
351 | if(field && purple_xmlnode_get_child(fn, "required")) |
|
19894
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
19203
diff
changeset
|
352 | purple_request_field_set_required(field,TRUE); |
| 7923 | 353 | } |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23493
diff
changeset
|
354 | |
|
17805
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
355 | if(actions != NULL) { |
|
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
356 | PurpleRequestField *actionfield; |
|
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
357 | GList *action; |
|
34338
c652670afac5
Request API refactoring: custom PURPLE_REQUEST_CHOICE values, instead of indexes
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34332
diff
changeset
|
358 | int i; |
|
c652670afac5
Request API refactoring: custom PURPLE_REQUEST_CHOICE values, instead of indexes
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34332
diff
changeset
|
359 | |
|
17805
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
360 | data->actiongroup = group = purple_request_field_group_new(_("Actions")); |
|
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
361 | purple_request_fields_add_group(fields, group); |
|
34338
c652670afac5
Request API refactoring: custom PURPLE_REQUEST_CHOICE values, instead of indexes
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34332
diff
changeset
|
362 | actionfield = purple_request_field_choice_new("libpurple:jabber:xdata:actions", _("Select an action"), GINT_TO_POINTER(defaultaction)); |
|
c652670afac5
Request API refactoring: custom PURPLE_REQUEST_CHOICE values, instead of indexes
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34332
diff
changeset
|
363 | purple_request_field_choice_set_data_destructor(actionfield, g_free); |
|
17805
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
364 | |
|
34338
c652670afac5
Request API refactoring: custom PURPLE_REQUEST_CHOICE values, instead of indexes
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34332
diff
changeset
|
365 | for(i = 0, action = actions; action; action = g_list_next(action), i++) { |
|
17805
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
366 | JabberXDataAction *a = action->data; |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23493
diff
changeset
|
367 | |
|
34338
c652670afac5
Request API refactoring: custom PURPLE_REQUEST_CHOICE values, instead of indexes
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34332
diff
changeset
|
368 | purple_request_field_choice_add(actionfield, a->name, GINT_TO_POINTER(i)); |
|
17805
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
369 | data->actions = g_list_append(data->actions, g_strdup(a->handle)); |
|
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
370 | } |
|
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
371 | purple_request_field_set_required(actionfield,TRUE); |
|
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17774
diff
changeset
|
372 | purple_request_field_group_add_field(group, actionfield); |
| 7923 | 373 | } |
| 374 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
375 | if((x = purple_xmlnode_get_child(packet, "title"))) |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
376 | title = purple_xmlnode_get_data(x); |
| 7923 | 377 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
378 | if((x = purple_xmlnode_get_child(packet, "instructions"))) |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
379 | instructions = purple_xmlnode_get_data(x); |
| 7923 | 380 | |
|
21653
621c47778132
merge of '73ae9aeda3c58fbf8437421da68d19d06f93e686'
Evan Schoenberg <evands@pidgin.im>
parents:
21233
diff
changeset
|
381 | handle = purple_request_fields(js->gc, title, title, instructions, fields, |
| 8396 | 382 | _("OK"), G_CALLBACK(jabber_x_data_ok_cb), |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16398
diff
changeset
|
383 | _("Cancel"), G_CALLBACK(jabber_x_data_cancel_cb), |
|
34332
876483829700
Request API refactoring: switch purple_request_fields to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
30511
diff
changeset
|
384 | purple_request_cpar_from_connection(js->gc), |
|
21653
621c47778132
merge of '73ae9aeda3c58fbf8437421da68d19d06f93e686'
Evan Schoenberg <evands@pidgin.im>
parents:
21233
diff
changeset
|
385 | data); |
| 7923 | 386 | |
|
16136
49ddb8f06d96
I noticed some places where we were doing the whole
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
387 | g_free(title); |
|
49ddb8f06d96
I noticed some places where we were doing the whole
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
388 | g_free(instructions); |
| 7923 | 389 | |
| 8396 | 390 | return handle; |
| 7923 | 391 | } |
| 392 | ||
|
30511
3e43438dbd72
jabber: Move (and harden) a function to xdata.c
Paul Aurich <darkrain42@pidgin.im>
parents:
29304
diff
changeset
|
393 | gchar * |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
394 | jabber_x_data_get_formtype(const PurpleXmlNode *form) |
|
30511
3e43438dbd72
jabber: Move (and harden) a function to xdata.c
Paul Aurich <darkrain42@pidgin.im>
parents:
29304
diff
changeset
|
395 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
396 | PurpleXmlNode *field; |
| 7923 | 397 | |
|
30511
3e43438dbd72
jabber: Move (and harden) a function to xdata.c
Paul Aurich <darkrain42@pidgin.im>
parents:
29304
diff
changeset
|
398 | g_return_val_if_fail(form != NULL, NULL); |
|
3e43438dbd72
jabber: Move (and harden) a function to xdata.c
Paul Aurich <darkrain42@pidgin.im>
parents:
29304
diff
changeset
|
399 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
400 | for (field = purple_xmlnode_get_child((PurpleXmlNode *)form, "field"); field; |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
401 | field = purple_xmlnode_get_next_twin(field)) { |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
402 | const char *var = purple_xmlnode_get_attrib(field, "var"); |
|
30511
3e43438dbd72
jabber: Move (and harden) a function to xdata.c
Paul Aurich <darkrain42@pidgin.im>
parents:
29304
diff
changeset
|
403 | if (purple_strequal(var, "FORM_TYPE")) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
404 | PurpleXmlNode *value = purple_xmlnode_get_child(field, "value"); |
|
30511
3e43438dbd72
jabber: Move (and harden) a function to xdata.c
Paul Aurich <darkrain42@pidgin.im>
parents:
29304
diff
changeset
|
405 | if (value) |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
406 | return purple_xmlnode_get_data(value); |
|
30511
3e43438dbd72
jabber: Move (and harden) a function to xdata.c
Paul Aurich <darkrain42@pidgin.im>
parents:
29304
diff
changeset
|
407 | else |
|
3e43438dbd72
jabber: Move (and harden) a function to xdata.c
Paul Aurich <darkrain42@pidgin.im>
parents:
29304
diff
changeset
|
408 | /* An interesting corner case... Looking for a second |
|
3e43438dbd72
jabber: Move (and harden) a function to xdata.c
Paul Aurich <darkrain42@pidgin.im>
parents:
29304
diff
changeset
|
409 | * FORM_TYPE would be more considerate, but I'm in favor |
|
3e43438dbd72
jabber: Move (and harden) a function to xdata.c
Paul Aurich <darkrain42@pidgin.im>
parents:
29304
diff
changeset
|
410 | * of not helping broken clients. |
|
3e43438dbd72
jabber: Move (and harden) a function to xdata.c
Paul Aurich <darkrain42@pidgin.im>
parents:
29304
diff
changeset
|
411 | */ |
|
3e43438dbd72
jabber: Move (and harden) a function to xdata.c
Paul Aurich <darkrain42@pidgin.im>
parents:
29304
diff
changeset
|
412 | return NULL; |
|
3e43438dbd72
jabber: Move (and harden) a function to xdata.c
Paul Aurich <darkrain42@pidgin.im>
parents:
29304
diff
changeset
|
413 | } |
|
3e43438dbd72
jabber: Move (and harden) a function to xdata.c
Paul Aurich <darkrain42@pidgin.im>
parents:
29304
diff
changeset
|
414 | } |
|
3e43438dbd72
jabber: Move (and harden) a function to xdata.c
Paul Aurich <darkrain42@pidgin.im>
parents:
29304
diff
changeset
|
415 | |
|
3e43438dbd72
jabber: Move (and harden) a function to xdata.c
Paul Aurich <darkrain42@pidgin.im>
parents:
29304
diff
changeset
|
416 | /* Erm, none found :( */ |
|
3e43438dbd72
jabber: Move (and harden) a function to xdata.c
Paul Aurich <darkrain42@pidgin.im>
parents:
29304
diff
changeset
|
417 | return NULL; |
|
3e43438dbd72
jabber: Move (and harden) a function to xdata.c
Paul Aurich <darkrain42@pidgin.im>
parents:
29304
diff
changeset
|
418 | } |
|
3e43438dbd72
jabber: Move (and harden) a function to xdata.c
Paul Aurich <darkrain42@pidgin.im>
parents:
29304
diff
changeset
|
419 |