Fri, 10 Mar 2023 01:24:33 -0600
Make PurpleRequestFieldBool into a GObject
This also does an `hg cp`, though with all the renaming of the parameter names, maybe that wasn't as useful for tracking the diff.
Note, I didn't bother re-indenting some of the blocks, because they'll all eventually be moved when everything is subclassed.
Testing Done:
Compiled and opened Request Fields from Demo protocol.
Reviewed at https://reviews.imfreedom.org/r/2332/
| 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 | */ | |
|
40441
f23c7e772667
Make sure we're not including the gettext macros in header files and deal with the repercussions of that.
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
23 | |
|
f23c7e772667
Make sure we're not including the gettext macros in header files and deal with the repercussions of that.
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
24 | #include <glib/gi18n-lib.h> |
|
f23c7e772667
Make sure we're not including the gettext macros in header files and deal with the repercussions of that.
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
25 | |
|
40358
e6fe6fc1f516
move all protocols, purple plugins, and purple tests to use purple.h instead of including files individually
Gary Kramlich <grim@reaperworld.com>
parents:
40062
diff
changeset
|
26 | #include <purple.h> |
| 7923 | 27 | |
| 28 | #include "xdata.h" | |
| 29 | ||
| 30 | typedef enum { | |
| 31 | JABBER_X_DATA_IGNORE = 0, | |
| 32 | JABBER_X_DATA_TEXT_SINGLE, | |
| 33 | JABBER_X_DATA_TEXT_MULTI, | |
| 34 | JABBER_X_DATA_LIST_SINGLE, | |
| 35 | JABBER_X_DATA_LIST_MULTI, | |
| 8295 | 36 | JABBER_X_DATA_BOOLEAN, |
| 37 | JABBER_X_DATA_JID_SINGLE | |
| 7923 | 38 | } jabber_x_data_field_type; |
| 39 | ||
| 40 | struct jabber_x_data_data { | |
| 41 | GHashTable *fields; | |
| 42 | GSList *values; | |
|
41967
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40817
diff
changeset
|
43 | GCallback cb; |
| 7923 | 44 | gpointer user_data; |
| 45 | 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
|
46 | GList *actions; |
|
42127
18acb99a0fa6
Convert PurpleRequestGroup into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41967
diff
changeset
|
47 | PurpleRequestGroup *actiongroup; |
| 7923 | 48 | }; |
| 49 | ||
|
42128
118067ca0367
Convert PurpleRequestPage into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42127
diff
changeset
|
50 | static void |
|
118067ca0367
Convert PurpleRequestPage into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42127
diff
changeset
|
51 | jabber_x_data_ok_cb(struct jabber_x_data_data *data, PurpleRequestPage *page) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
52 | PurpleXmlNode *result = purple_xmlnode_new("x"); |
|
41967
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40817
diff
changeset
|
53 | GCallback cb = data->cb; |
| 7923 | 54 | gpointer user_data = data->user_data; |
| 55 | JabberStream *js = data->js; | |
| 56 | 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
|
57 | 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
|
58 | gboolean hasActions = (data->actions != NULL); |
| 7923 | 59 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
60 | 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
|
61 | purple_xmlnode_set_attrib(result, "type", "submit"); |
| 7923 | 62 | |
|
42128
118067ca0367
Convert PurpleRequestPage into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42127
diff
changeset
|
63 | for(groups = purple_request_page_get_groups(page); 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
|
64 | if(groups->data == data->actiongroup) { |
|
42127
18acb99a0fa6
Convert PurpleRequestGroup into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41967
diff
changeset
|
65 | for(flds = purple_request_group_get_fields(groups->data); flds; flds = flds->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
|
66 | 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
|
67 | 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
|
68 | int handleindex; |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
69 | 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
|
70 | continue; |
|
34338
c652670afac5
Request API refactoring: custom PURPLE_REQUEST_CHOICE values, instead of indexes
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34332
diff
changeset
|
71 | 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
|
72 | 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
|
73 | 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
|
74 | } |
|
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
|
75 | 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
|
76 | } |
|
42127
18acb99a0fa6
Convert PurpleRequestGroup into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41967
diff
changeset
|
77 | for(flds = purple_request_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
|
78 | PurpleXmlNode *fieldnode, *valuenode; |
| 15884 | 79 | PurpleRequestField *field = flds->data; |
| 80 | const char *id = purple_request_field_get_id(field); | |
| 7923 | 81 | jabber_x_data_field_type type = GPOINTER_TO_INT(g_hash_table_lookup(data->fields, id)); |
| 82 | ||
| 83 | switch(type) { | |
| 84 | case JABBER_X_DATA_TEXT_SINGLE: | |
| 8295 | 85 | case JABBER_X_DATA_JID_SINGLE: |
| 7923 | 86 | { |
|
42135
1a89a067a0d5
Add a PurpleRequestFieldString subclass
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42128
diff
changeset
|
87 | PurpleRequestFieldString *sfield = PURPLE_REQUEST_FIELD_STRING(field); |
|
1a89a067a0d5
Add a PurpleRequestFieldString subclass
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42128
diff
changeset
|
88 | const char *value = purple_request_field_string_get_value(sfield); |
|
16398
a895aca0a7ce
Ok I couldn't resist. For iChat and Adium buddies who are advertising
Mark Doliner <markdoliner@pidgin.im>
parents:
16136
diff
changeset
|
89 | 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
|
90 | break; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
91 | 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
|
92 | 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
|
93 | valuenode = purple_xmlnode_new_child(fieldnode, "value"); |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38358
diff
changeset
|
94 | purple_xmlnode_insert_data(valuenode, value, -1); |
| 7923 | 95 | break; |
| 96 | } | |
| 97 | case JABBER_X_DATA_TEXT_MULTI: | |
| 98 | { | |
|
42135
1a89a067a0d5
Add a PurpleRequestFieldString subclass
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42128
diff
changeset
|
99 | PurpleRequestFieldString *sfield = PURPLE_REQUEST_FIELD_STRING(field); |
|
1a89a067a0d5
Add a PurpleRequestFieldString subclass
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42128
diff
changeset
|
100 | const char *value = purple_request_field_string_get_value(sfield); |
| 7923 | 101 | char **pieces, **p; |
|
16398
a895aca0a7ce
Ok I couldn't resist. For iChat and Adium buddies who are advertising
Mark Doliner <markdoliner@pidgin.im>
parents:
16136
diff
changeset
|
102 | 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
|
103 | break; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
104 | 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
|
105 | purple_xmlnode_set_attrib(fieldnode, "var", id); |
| 7923 | 106 | |
| 107 | pieces = g_strsplit(value, "\n", -1); | |
| 108 | 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
|
109 | 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
|
110 | purple_xmlnode_insert_data(valuenode, *p, -1); |
| 7923 | 111 | } |
| 112 | g_strfreev(pieces); | |
| 113 | } | |
| 114 | break; | |
| 115 | case JABBER_X_DATA_LIST_SINGLE: | |
| 116 | case JABBER_X_DATA_LIST_MULTI: | |
| 117 | { | |
|
18190
bcf28ef7e8ff
Re-fix the DBus list handling code by killing const GList* / const GSList*
Richard Laager <rlaager@pidgin.im>
parents:
16490
diff
changeset
|
118 | GList *selected = purple_request_field_list_get_selected(field); |
| 7923 | 119 | char *value; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
120 | 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
|
121 | purple_xmlnode_set_attrib(fieldnode, "var", id); |
| 7923 | 122 | |
| 123 | while(selected) { | |
| 15884 | 124 | 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
|
125 | valuenode = purple_xmlnode_new_child(fieldnode, "value"); |
| 7923 | 126 | if(value) |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
127 | purple_xmlnode_insert_data(valuenode, value, -1); |
| 7923 | 128 | selected = selected->next; |
| 129 | } | |
| 130 | } | |
| 131 | break; | |
| 132 | case JABBER_X_DATA_BOOLEAN: | |
|
42136
cfa707dcda7d
Make PurpleRequestFieldBool into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42135
diff
changeset
|
133 | { |
|
cfa707dcda7d
Make PurpleRequestFieldBool into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42135
diff
changeset
|
134 | PurpleRequestFieldBool *bfield = PURPLE_REQUEST_FIELD_BOOL(field); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
135 | 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
|
136 | 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
|
137 | valuenode = purple_xmlnode_new_child(fieldnode, "value"); |
|
42136
cfa707dcda7d
Make PurpleRequestFieldBool into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42135
diff
changeset
|
138 | if(purple_request_field_bool_get_value(bfield)) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
139 | purple_xmlnode_insert_data(valuenode, "1", -1); |
|
42136
cfa707dcda7d
Make PurpleRequestFieldBool into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42135
diff
changeset
|
140 | } else { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
141 | purple_xmlnode_insert_data(valuenode, "0", -1); |
|
42136
cfa707dcda7d
Make PurpleRequestFieldBool into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42135
diff
changeset
|
142 | } |
|
cfa707dcda7d
Make PurpleRequestFieldBool into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42135
diff
changeset
|
143 | } |
| 7923 | 144 | break; |
| 145 | case JABBER_X_DATA_IGNORE: | |
| 146 | break; | |
| 147 | } | |
| 148 | } | |
| 149 | } | |
| 150 | ||
| 151 | g_hash_table_destroy(data->fields); | |
|
40052
cc03b5af25ea
Use GSList functions instead of manual iterations
qarkai <qarkai@gmail.com>
parents:
40049
diff
changeset
|
152 | g_slist_free_full(data->values, g_free); |
| 40047 | 153 | g_list_free_full(data->actions, g_free); |
| 7923 | 154 | g_free(data); |
| 155 | ||
|
41967
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40817
diff
changeset
|
156 | if(hasActions) { |
|
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40817
diff
changeset
|
157 | ((jabber_x_data_action_cb)cb)(js, result, actionhandle, user_data); |
|
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40817
diff
changeset
|
158 | } 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
|
159 | ((jabber_x_data_cb)cb)(js, result, user_data); |
|
41967
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40817
diff
changeset
|
160 | } |
|
26565
94071f2569f2
Fix a potential memleak by freeing this regardless of whether hasActions
Mark Doliner <markdoliner@pidgin.im>
parents:
26042
diff
changeset
|
161 | |
|
94071f2569f2
Fix a potential memleak by freeing this regardless of whether hasActions
Mark Doliner <markdoliner@pidgin.im>
parents:
26042
diff
changeset
|
162 | g_free(actionhandle); |
| 7923 | 163 | } |
| 164 | ||
|
41967
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40817
diff
changeset
|
165 | static void |
|
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40817
diff
changeset
|
166 | jabber_x_data_cancel_cb(struct jabber_x_data_data *data, |
|
42128
118067ca0367
Convert PurpleRequestPage into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42127
diff
changeset
|
167 | G_GNUC_UNUSED PurpleRequestPage *page) |
|
41967
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40817
diff
changeset
|
168 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
169 | PurpleXmlNode *result = purple_xmlnode_new("x"); |
|
41967
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40817
diff
changeset
|
170 | GCallback cb = data->cb; |
| 7923 | 171 | gpointer user_data = data->user_data; |
| 172 | JabberStream *js = data->js; | |
| 40049 | 173 | gboolean hasActions = (data->actions != NULL); |
| 7923 | 174 | g_hash_table_destroy(data->fields); |
|
40052
cc03b5af25ea
Use GSList functions instead of manual iterations
qarkai <qarkai@gmail.com>
parents:
40049
diff
changeset
|
175 | g_slist_free_full(data->values, g_free); |
| 40049 | 176 | g_list_free_full(data->actions, g_free); |
| 7923 | 177 | g_free(data); |
| 178 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
179 | 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
|
180 | purple_xmlnode_set_attrib(result, "type", "cancel"); |
| 7923 | 181 | |
|
41967
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40817
diff
changeset
|
182 | if(hasActions) { |
|
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40817
diff
changeset
|
183 | ((jabber_x_data_action_cb)cb)(js, result, NULL, user_data); |
|
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40817
diff
changeset
|
184 | } 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
|
185 | ((jabber_x_data_cb)cb)(js, result, user_data); |
|
41967
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40817
diff
changeset
|
186 | } |
| 7923 | 187 | } |
| 188 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
189 | void *jabber_x_data_request(JabberStream *js, PurpleXmlNode *packet, jabber_x_data_cb cb, gpointer user_data) |
| 7923 | 190 | { |
|
41967
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40817
diff
changeset
|
191 | return jabber_x_data_request_with_actions(js, packet, NULL, 0, |
|
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40817
diff
changeset
|
192 | (jabber_x_data_action_cb)(GCallback)cb, |
|
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40817
diff
changeset
|
193 | 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
|
194 | } |
|
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
|
195 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
196 | 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
|
197 | { |
| 8396 | 198 | void *handle; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
199 | PurpleXmlNode *fn, *x; |
|
42128
118067ca0367
Convert PurpleRequestPage into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42127
diff
changeset
|
200 | PurpleRequestPage *page; |
|
42127
18acb99a0fa6
Convert PurpleRequestGroup into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41967
diff
changeset
|
201 | PurpleRequestGroup *group; |
|
23493
e04778a3d29a
Kill the warning 'field' may be used uninitialized in this function
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
23176
diff
changeset
|
202 | PurpleRequestField *field = NULL; |
| 7923 | 203 | |
| 204 | char *title = NULL; | |
| 205 | char *instructions = NULL; | |
| 206 | ||
| 207 | struct jabber_x_data_data *data = g_new0(struct jabber_x_data_data, 1); | |
| 208 | ||
| 209 | data->fields = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); | |
| 210 | data->user_data = user_data; | |
|
41967
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40817
diff
changeset
|
211 | data->cb = G_CALLBACK(cb); |
| 7923 | 212 | data->js = js; |
| 213 | ||
|
42128
118067ca0367
Convert PurpleRequestPage into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42127
diff
changeset
|
214 | page = purple_request_page_new(); |
|
42127
18acb99a0fa6
Convert PurpleRequestGroup into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41967
diff
changeset
|
215 | group = purple_request_group_new(NULL); |
|
42128
118067ca0367
Convert PurpleRequestPage into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42127
diff
changeset
|
216 | purple_request_page_add_group(page, group); |
| 7923 | 217 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
218 | 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
|
219 | PurpleXmlNode *valuenode; |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
220 | 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
|
221 | 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
|
222 | const char *var = purple_xmlnode_get_attrib(fn, "var"); |
| 8135 | 223 | char *value = NULL; |
| 224 | ||
| 225 | 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
|
226 | type = "text-single"; |
| 8135 | 227 | |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
228 | if(!var && !purple_strequal(type, "fixed")) |
| 8135 | 229 | continue; |
| 230 | if(!label) | |
| 231 | label = var; | |
| 232 | ||
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
30511
diff
changeset
|
233 | 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
|
234 | 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
|
235 | value = purple_xmlnode_get_data(valuenode); |
| 8135 | 236 | |
| 15884 | 237 | field = purple_request_field_string_new(var, label, |
| 8135 | 238 | value ? value : "", FALSE); |
|
42135
1a89a067a0d5
Add a PurpleRequestFieldString subclass
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42128
diff
changeset
|
239 | purple_request_field_string_set_masked(PURPLE_REQUEST_FIELD_STRING(field), |
|
1a89a067a0d5
Add a PurpleRequestFieldString subclass
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42128
diff
changeset
|
240 | TRUE); |
|
42127
18acb99a0fa6
Convert PurpleRequestGroup into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41967
diff
changeset
|
241 | purple_request_group_add_field(group, field); |
| 8135 | 242 | |
| 243 | g_hash_table_replace(data->fields, g_strdup(var), GINT_TO_POINTER(JABBER_X_DATA_TEXT_SINGLE)); | |
| 244 | ||
|
16136
49ddb8f06d96
I noticed some places where we were doing the whole
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
245 | g_free(value); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
30511
diff
changeset
|
246 | } else if(purple_strequal(type, "text-multi") || purple_strequal(type, "jid-multi")) { |
| 8135 | 247 | GString *str = g_string_new(""); |
| 248 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
249 | 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
|
250 | valuenode = purple_xmlnode_get_next_twin(valuenode)) { |
| 8135 | 251 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
252 | if(!(value = purple_xmlnode_get_data(valuenode))) |
| 8135 | 253 | continue; |
| 254 | ||
| 255 | g_string_append_printf(str, "%s\n", value); | |
| 256 | g_free(value); | |
| 257 | } | |
| 258 | ||
| 15884 | 259 | field = purple_request_field_string_new(var, label, |
| 8135 | 260 | str->str, TRUE); |
|
42127
18acb99a0fa6
Convert PurpleRequestGroup into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41967
diff
changeset
|
261 | purple_request_group_add_field(group, field); |
| 7923 | 262 | |
| 8135 | 263 | g_hash_table_replace(data->fields, g_strdup(var), GINT_TO_POINTER(JABBER_X_DATA_TEXT_MULTI)); |
| 264 | ||
| 265 | g_string_free(str, TRUE); | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
30511
diff
changeset
|
266 | } 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
|
267 | PurpleXmlNode *optnode; |
| 8135 | 268 | GList *selected = NULL; |
| 269 | ||
| 15884 | 270 | field = purple_request_field_list_new(var, label); |
| 8135 | 271 | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
30511
diff
changeset
|
272 | if(purple_strequal(type, "list-multi")) { |
| 15884 | 273 | purple_request_field_list_set_multi_select(field, TRUE); |
| 8135 | 274 | g_hash_table_replace(data->fields, g_strdup(var), |
| 275 | GINT_TO_POINTER(JABBER_X_DATA_LIST_MULTI)); | |
| 276 | } else { | |
| 277 | g_hash_table_replace(data->fields, g_strdup(var), | |
| 278 | GINT_TO_POINTER(JABBER_X_DATA_LIST_SINGLE)); | |
| 279 | } | |
| 280 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
281 | 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
|
282 | 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
|
283 | 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
|
284 | 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
|
285 | 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
|
286 | } |
| 8135 | 287 | } |
| 7923 | 288 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
289 | 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
|
290 | optnode = purple_xmlnode_get_next_twin(optnode)) { |
| 8135 | 291 | const char *lbl; |
| 292 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
293 | if(!(valuenode = purple_xmlnode_get_child(optnode, "value"))) |
| 8135 | 294 | continue; |
| 295 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
296 | if(!(value = purple_xmlnode_get_data(valuenode))) |
| 8135 | 297 | continue; |
| 298 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
299 | 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
|
300 | lbl = value; |
| 8135 | 301 | |
| 302 | data->values = g_slist_prepend(data->values, value); | |
| 303 | ||
|
24900
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
23493
diff
changeset
|
304 | purple_request_field_list_add_icon(field, lbl, NULL, value); |
| 8135 | 305 | if(g_list_find_custom(selected, value, (GCompareFunc)strcmp)) |
| 15884 | 306 | purple_request_field_list_add_selected(field, lbl); |
| 8135 | 307 | } |
|
42127
18acb99a0fa6
Convert PurpleRequestGroup into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41967
diff
changeset
|
308 | purple_request_group_add_field(group, field); |
| 8135 | 309 | |
|
40062
d25228fc7b8e
Use g_list_free_full instead of manual iterations
qarkai <qarkai@gmail.com>
parents:
40052
diff
changeset
|
310 | g_list_free_full(selected, g_free); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
30511
diff
changeset
|
311 | } else if(purple_strequal(type, "boolean")) { |
| 8135 | 312 | gboolean def = FALSE; |
| 7923 | 313 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
314 | 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
|
315 | value = purple_xmlnode_get_data(valuenode); |
| 7923 | 316 | |
|
8390
13e1ff9b2850
[gaim-migrate @ 9119]
Mark Doliner <markdoliner@pidgin.im>
parents:
8385
diff
changeset
|
317 | if(value && (!g_ascii_strcasecmp(value, "yes") || |
|
13e1ff9b2850
[gaim-migrate @ 9119]
Mark Doliner <markdoliner@pidgin.im>
parents:
8385
diff
changeset
|
318 | !g_ascii_strcasecmp(value, "true") || !g_ascii_strcasecmp(value, "1"))) |
| 8135 | 319 | def = TRUE; |
| 7923 | 320 | |
| 15884 | 321 | field = purple_request_field_bool_new(var, label, def); |
|
42127
18acb99a0fa6
Convert PurpleRequestGroup into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41967
diff
changeset
|
322 | purple_request_group_add_field(group, field); |
| 7923 | 323 | |
| 8135 | 324 | g_hash_table_replace(data->fields, g_strdup(var), GINT_TO_POINTER(JABBER_X_DATA_BOOLEAN)); |
| 7923 | 325 | |
|
16136
49ddb8f06d96
I noticed some places where we were doing the whole
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
326 | g_free(value); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
30511
diff
changeset
|
327 | } 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
|
328 | 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
|
329 | value = purple_xmlnode_get_data(valuenode); |
| 7923 | 330 | |
|
23176
90f6226370cb
applied changes from 069f197178d158cdd308687095c14d49d8eee0ed
Daniel Atallah <datallah@pidgin.im>
parents:
22664
diff
changeset
|
331 | if(value != NULL) { |
|
90f6226370cb
applied changes from 069f197178d158cdd308687095c14d49d8eee0ed
Daniel Atallah <datallah@pidgin.im>
parents:
22664
diff
changeset
|
332 | field = purple_request_field_label_new("", value); |
|
42127
18acb99a0fa6
Convert PurpleRequestGroup into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41967
diff
changeset
|
333 | purple_request_group_add_field(group, field); |
| 7923 | 334 | |
|
23176
90f6226370cb
applied changes from 069f197178d158cdd308687095c14d49d8eee0ed
Daniel Atallah <datallah@pidgin.im>
parents:
22664
diff
changeset
|
335 | g_free(value); |
|
90f6226370cb
applied changes from 069f197178d158cdd308687095c14d49d8eee0ed
Daniel Atallah <datallah@pidgin.im>
parents:
22664
diff
changeset
|
336 | } |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
30511
diff
changeset
|
337 | } 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
|
338 | 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
|
339 | value = purple_xmlnode_get_data(valuenode); |
| 7923 | 340 | |
| 15884 | 341 | field = purple_request_field_string_new(var, "", value ? value : "", |
| 8135 | 342 | FALSE); |
| 15884 | 343 | purple_request_field_set_visible(field, FALSE); |
|
42127
18acb99a0fa6
Convert PurpleRequestGroup into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41967
diff
changeset
|
344 | purple_request_group_add_field(group, field); |
| 7923 | 345 | |
| 8135 | 346 | g_hash_table_replace(data->fields, g_strdup(var), GINT_TO_POINTER(JABBER_X_DATA_TEXT_SINGLE)); |
| 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); |
| 8135 | 349 | } 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
|
350 | 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
|
351 | value = purple_xmlnode_get_data(valuenode); |
| 7923 | 352 | |
| 15884 | 353 | field = purple_request_field_string_new(var, label, |
| 8135 | 354 | value ? value : "", FALSE); |
|
42127
18acb99a0fa6
Convert PurpleRequestGroup into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41967
diff
changeset
|
355 | purple_request_group_add_field(group, field); |
| 7923 | 356 | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
30511
diff
changeset
|
357 | if(purple_strequal(type, "jid-single")) { |
| 15884 | 358 | purple_request_field_set_type_hint(field, "screenname"); |
| 8295 | 359 | g_hash_table_replace(data->fields, g_strdup(var), GINT_TO_POINTER(JABBER_X_DATA_JID_SINGLE)); |
| 360 | } else { | |
| 361 | g_hash_table_replace(data->fields, g_strdup(var), GINT_TO_POINTER(JABBER_X_DATA_TEXT_SINGLE)); | |
| 362 | } | |
| 7923 | 363 | |
|
16136
49ddb8f06d96
I noticed some places where we were doing the whole
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
364 | g_free(value); |
| 7923 | 365 | } |
|
19894
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
19203
diff
changeset
|
366 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
367 | 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
|
368 | purple_request_field_set_required(field,TRUE); |
| 7923 | 369 | } |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23493
diff
changeset
|
370 | |
|
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
|
371 | 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
|
372 | 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
|
373 | GList *action; |
|
34338
c652670afac5
Request API refactoring: custom PURPLE_REQUEST_CHOICE values, instead of indexes
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34332
diff
changeset
|
374 | int i; |
|
c652670afac5
Request API refactoring: custom PURPLE_REQUEST_CHOICE values, instead of indexes
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34332
diff
changeset
|
375 | |
|
42127
18acb99a0fa6
Convert PurpleRequestGroup into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41967
diff
changeset
|
376 | data->actiongroup = group = purple_request_group_new(_("Actions")); |
|
42128
118067ca0367
Convert PurpleRequestPage into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42127
diff
changeset
|
377 | purple_request_page_add_group(page, group); |
|
34338
c652670afac5
Request API refactoring: custom PURPLE_REQUEST_CHOICE values, instead of indexes
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34332
diff
changeset
|
378 | actionfield = purple_request_field_choice_new("libpurple:jabber:xdata:actions", _("Select an action"), GINT_TO_POINTER(defaultaction)); |
|
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
|
379 | |
|
34338
c652670afac5
Request API refactoring: custom PURPLE_REQUEST_CHOICE values, instead of indexes
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34332
diff
changeset
|
380 | 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
|
381 | 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
|
382 | |
|
34338
c652670afac5
Request API refactoring: custom PURPLE_REQUEST_CHOICE values, instead of indexes
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34332
diff
changeset
|
383 | 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
|
384 | 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
|
385 | } |
|
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
|
386 | purple_request_field_set_required(actionfield,TRUE); |
|
42127
18acb99a0fa6
Convert PurpleRequestGroup into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41967
diff
changeset
|
387 | purple_request_group_add_field(group, actionfield); |
| 7923 | 388 | } |
| 389 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
390 | 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
|
391 | title = purple_xmlnode_get_data(x); |
| 7923 | 392 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
393 | 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
|
394 | instructions = purple_xmlnode_get_data(x); |
| 7923 | 395 | |
|
42128
118067ca0367
Convert PurpleRequestPage into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42127
diff
changeset
|
396 | handle = purple_request_fields(js->gc, title, title, instructions, page, |
| 8396 | 397 | _("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
|
398 | _("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
|
399 | purple_request_cpar_from_connection(js->gc), |
|
21653
621c47778132
merge of '73ae9aeda3c58fbf8437421da68d19d06f93e686'
Evan Schoenberg <evands@pidgin.im>
parents:
21233
diff
changeset
|
400 | data); |
| 7923 | 401 | |
|
16136
49ddb8f06d96
I noticed some places where we were doing the whole
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
402 | g_free(title); |
|
49ddb8f06d96
I noticed some places where we were doing the whole
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
403 | g_free(instructions); |
| 7923 | 404 | |
| 8396 | 405 | return handle; |
| 7923 | 406 | } |
| 407 | ||
|
30511
3e43438dbd72
jabber: Move (and harden) a function to xdata.c
Paul Aurich <darkrain42@pidgin.im>
parents:
29304
diff
changeset
|
408 | gchar * |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
409 | 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
|
410 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
411 | PurpleXmlNode *field; |
| 7923 | 412 | |
|
30511
3e43438dbd72
jabber: Move (and harden) a function to xdata.c
Paul Aurich <darkrain42@pidgin.im>
parents:
29304
diff
changeset
|
413 | 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
|
414 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
415 | 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
|
416 | 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
|
417 | 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
|
418 | 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
|
419 | 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
|
420 | if (value) |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
30511
diff
changeset
|
421 | 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
|
422 | else |
|
3e43438dbd72
jabber: Move (and harden) a function to xdata.c
Paul Aurich <darkrain42@pidgin.im>
parents:
29304
diff
changeset
|
423 | /* 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
|
424 | * 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
|
425 | * of not helping broken clients. |
|
3e43438dbd72
jabber: Move (and harden) a function to xdata.c
Paul Aurich <darkrain42@pidgin.im>
parents:
29304
diff
changeset
|
426 | */ |
|
3e43438dbd72
jabber: Move (and harden) a function to xdata.c
Paul Aurich <darkrain42@pidgin.im>
parents:
29304
diff
changeset
|
427 | return NULL; |
|
3e43438dbd72
jabber: Move (and harden) a function to xdata.c
Paul Aurich <darkrain42@pidgin.im>
parents:
29304
diff
changeset
|
428 | } |
|
3e43438dbd72
jabber: Move (and harden) a function to xdata.c
Paul Aurich <darkrain42@pidgin.im>
parents:
29304
diff
changeset
|
429 | } |
|
3e43438dbd72
jabber: Move (and harden) a function to xdata.c
Paul Aurich <darkrain42@pidgin.im>
parents:
29304
diff
changeset
|
430 | |
|
3e43438dbd72
jabber: Move (and harden) a function to xdata.c
Paul Aurich <darkrain42@pidgin.im>
parents:
29304
diff
changeset
|
431 | /* Erm, none found :( */ |
|
3e43438dbd72
jabber: Move (and harden) a function to xdata.c
Paul Aurich <darkrain42@pidgin.im>
parents:
29304
diff
changeset
|
432 | return NULL; |
|
3e43438dbd72
jabber: Move (and harden) a function to xdata.c
Paul Aurich <darkrain42@pidgin.im>
parents:
29304
diff
changeset
|
433 | } |
|
3e43438dbd72
jabber: Move (and harden) a function to xdata.c
Paul Aurich <darkrain42@pidgin.im>
parents:
29304
diff
changeset
|
434 |