libpurple/protocols/jabber/xdata.c

Wed, 13 May 2009 20:29:03 +0000

author
Marcus Lundblad <malu@pidgin.im>
date
Wed, 13 May 2009 20:29:03 +0000
changeset 27110
05ca719b901b
parent 26565
94071f2569f2
child 26657
1067482b6de1
child 28322
ac8fec1d2234
permissions
-rw-r--r--

Support custom smileys in MUCs (when all participants support BoB and a maximum
of 10 participants are in the chat).
Always announce support for BoB, since disable custom smileys will still turn
off fetching them, and BoB can be used for other purposes further on.

7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1 /*
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
2 * purple - Jabber Protocol Plugin
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
3 *
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
4 * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com>
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
5 *
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
9 * (at your option) any later version.
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
10 *
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
14 * GNU General Public License for more details.
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
15 *
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
17 * 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
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
19 *
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
20 */
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
21 #include "internal.h"
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
22 #include "request.h"
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
23 #include "server.h"
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
24
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
25 #include "xdata.h"
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
26
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
27 typedef enum {
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
28 JABBER_X_DATA_IGNORE = 0,
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
29 JABBER_X_DATA_TEXT_SINGLE,
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
30 JABBER_X_DATA_TEXT_MULTI,
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
31 JABBER_X_DATA_LIST_SINGLE,
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
32 JABBER_X_DATA_LIST_MULTI,
8295
440ef02f6858 [gaim-migrate @ 9019]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
33 JABBER_X_DATA_BOOLEAN,
440ef02f6858 [gaim-migrate @ 9019]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
34 JABBER_X_DATA_JID_SINGLE
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
35 } jabber_x_data_field_type;
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
36
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
37 struct jabber_x_data_data {
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
38 GHashTable *fields;
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
39 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
40 jabber_x_data_action_cb cb;
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
41 gpointer user_data;
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
42 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
43 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
44 PurpleRequestFieldGroup *actiongroup;
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
45 };
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
46
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
47 static void jabber_x_data_ok_cb(struct jabber_x_data_data *data, PurpleRequestFields *fields) {
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
48 xmlnode *result = 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
49 jabber_x_data_action_cb cb = data->cb;
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
50 gpointer user_data = data->user_data;
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
51 JabberStream *js = data->js;
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
52 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
53 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
54 gboolean hasActions = (data->actions != NULL);
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
55
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8396
diff changeset
56 xmlnode_set_namespace(result, "jabber:x:data");
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
57 xmlnode_set_attrib(result, "type", "submit");
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
58
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
59 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
60 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
61 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
62 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
63 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
64 int 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
65 if(strcmp(id, "libpurple:jabber:xdata: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
66 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
67 handleindex = purple_request_field_choice_get_value(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 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
69 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
70 }
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 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
72 }
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
73 for(flds = purple_request_field_group_get_fields(groups->data); flds; flds = flds->next) {
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
74 xmlnode *fieldnode, *valuenode;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
75 PurpleRequestField *field = flds->data;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
76 const char *id = purple_request_field_get_id(field);
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
77 jabber_x_data_field_type type = GPOINTER_TO_INT(g_hash_table_lookup(data->fields, id));
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
78
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
79 switch(type) {
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
80 case JABBER_X_DATA_TEXT_SINGLE:
8295
440ef02f6858 [gaim-migrate @ 9019]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
81 case JABBER_X_DATA_JID_SINGLE:
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
82 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
83 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
84 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
85 break;
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
86 fieldnode = xmlnode_new_child(result, "field");
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
87 xmlnode_set_attrib(fieldnode, "var", id);
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
88 valuenode = xmlnode_new_child(fieldnode, "value");
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
89 if(value)
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
90 xmlnode_insert_data(valuenode, value, -1);
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
91 break;
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
92 }
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
93 case JABBER_X_DATA_TEXT_MULTI:
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
94 {
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
95 char **pieces, **p;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
96 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
97 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
98 break;
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
99 fieldnode = xmlnode_new_child(result, "field");
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
100 xmlnode_set_attrib(fieldnode, "var", id);
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
101
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
102 pieces = g_strsplit(value, "\n", -1);
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
103 for(p = pieces; *p != NULL; p++) {
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
104 valuenode = xmlnode_new_child(fieldnode, "value");
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
105 xmlnode_insert_data(valuenode, *p, -1);
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
106 }
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
107 g_strfreev(pieces);
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
108 }
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
109 break;
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
110 case JABBER_X_DATA_LIST_SINGLE:
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
111 case JABBER_X_DATA_LIST_MULTI:
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
112 {
18190
bcf28ef7e8ff Re-fix the DBus list handling code by killing const GList* / const GSList*
Richard Laager <rlaager@pidgin.im>
parents: 16490
diff changeset
113 GList *selected = purple_request_field_list_get_selected(field);
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
114 char *value;
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
115 fieldnode = xmlnode_new_child(result, "field");
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
116 xmlnode_set_attrib(fieldnode, "var", id);
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
117
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
118 while(selected) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
119 value = purple_request_field_list_get_data(field, selected->data);
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
120 valuenode = xmlnode_new_child(fieldnode, "value");
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
121 if(value)
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
122 xmlnode_insert_data(valuenode, value, -1);
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
123 selected = selected->next;
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
124 }
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
125 }
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
126 break;
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
127 case JABBER_X_DATA_BOOLEAN:
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
128 fieldnode = xmlnode_new_child(result, "field");
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
129 xmlnode_set_attrib(fieldnode, "var", id);
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
130 valuenode = xmlnode_new_child(fieldnode, "value");
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
131 if(purple_request_field_bool_get_value(field))
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
132 xmlnode_insert_data(valuenode, "1", -1);
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
133 else
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
134 xmlnode_insert_data(valuenode, "0", -1);
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
135 break;
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
136 case JABBER_X_DATA_IGNORE:
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
137 break;
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
138 }
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
139 }
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
140 }
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
141
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
142 g_hash_table_destroy(data->fields);
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
143 while(data->values) {
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
144 g_free(data->values->data);
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
145 data->values = g_slist_delete_link(data->values, data->values);
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
146 }
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
147 if (data->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
148 GList *action;
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 for(action = data->actions; action; action = g_list_next(action)) {
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
150 g_free(action->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
151 }
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
152 g_list_free(data->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
153 }
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
154 g_free(data);
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
155
26565
94071f2569f2 Fix a potential memleak by freeing this regardless of whether hasActions
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
156 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
157 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
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);
26565
94071f2569f2 Fix a potential memleak by freeing this regardless of whether hasActions
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
160
94071f2569f2 Fix a potential memleak by freeing this regardless of whether hasActions
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
161 g_free(actionhandle);
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
162 }
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
163
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
164 static void jabber_x_data_cancel_cb(struct jabber_x_data_data *data, PurpleRequestFields *fields) {
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
165 xmlnode *result = 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
166 jabber_x_data_action_cb cb = data->cb;
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
167 gpointer user_data = data->user_data;
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
168 JabberStream *js = data->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
169 gboolean hasActions = FALSE;
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
170 g_hash_table_destroy(data->fields);
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
171 while(data->values) {
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
172 g_free(data->values->data);
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
173 data->values = g_slist_delete_link(data->values, data->values);
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
174 }
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
175 if (data->actions) {
19899
483c4f495a6c Various warning fixes for the xmpp prpl.
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
176 GList *action;
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
177 hasActions = 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
178 for(action = data->actions; action; action = g_list_next(action)) {
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 g_free(action->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
180 }
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
181 g_list_free(data->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
182 }
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
183 g_free(data);
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
184
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 8396
diff changeset
185 xmlnode_set_namespace(result, "jabber:x:data");
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
186 xmlnode_set_attrib(result, "type", "cancel");
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
187
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
188 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
189 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
190 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
191 ((jabber_x_data_cb)cb)(js, result, user_data);
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
192 }
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
193
8396
8681756b4769 [gaim-migrate @ 9125]
Nathan Walp <nwalp@pidgin.im>
parents: 8390
diff changeset
194 void *jabber_x_data_request(JabberStream *js, xmlnode *packet, jabber_x_data_cb cb, gpointer user_data)
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
195 {
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
196 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
197 }
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
198
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
199 void *jabber_x_data_request_with_actions(JabberStream *js, xmlnode *packet, GList *actions, int defaultaction, jabber_x_data_action_cb cb, gpointer 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
200 {
8396
8681756b4769 [gaim-migrate @ 9125]
Nathan Walp <nwalp@pidgin.im>
parents: 8390
diff changeset
201 void *handle;
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
202 xmlnode *fn, *x;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
203 PurpleRequestFields *fields;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
204 PurpleRequestFieldGroup *group;
23493
e04778a3d29a Kill the warning 'field' may be used uninitialized in this function
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 23176
diff changeset
205 PurpleRequestField *field = NULL;
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
206
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
207 char *title = NULL;
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
208 char *instructions = NULL;
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
209
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
210 struct jabber_x_data_data *data = g_new0(struct jabber_x_data_data, 1);
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
211
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
212 data->fields = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
213 data->user_data = user_data;
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
214 data->cb = cb;
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
215 data->js = js;
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
216
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
217 fields = purple_request_fields_new();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
218 group = purple_request_field_group_new(NULL);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
219 purple_request_fields_add_group(fields, group);
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
220
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
221 for(fn = xmlnode_get_child(packet, "field"); fn; fn = xmlnode_get_next_twin(fn)) {
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
222 xmlnode *valuenode;
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
223 const char *type = xmlnode_get_attrib(fn, "type");
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
224 const char *label = xmlnode_get_attrib(fn, "label");
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
225 const char *var = xmlnode_get_attrib(fn, "var");
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
226 char *value = NULL;
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
227
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
228 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
229 type = "text-single";
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
230
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
231 if(!var && strcmp(type, "fixed"))
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
232 continue;
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
233 if(!label)
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
234 label = var;
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
235
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
236 if(!strcmp(type, "text-private")) {
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
237 if((valuenode = xmlnode_get_child(fn, "value")))
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
238 value = xmlnode_get_data(valuenode);
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
239
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
240 field = purple_request_field_string_new(var, label,
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
241 value ? value : "", FALSE);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
242 purple_request_field_string_set_masked(field, TRUE);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
243 purple_request_field_group_add_field(group, field);
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
244
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
245 g_hash_table_replace(data->fields, g_strdup(var), GINT_TO_POINTER(JABBER_X_DATA_TEXT_SINGLE));
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
246
16136
49ddb8f06d96 I noticed some places where we were doing the whole
Mark Doliner <markdoliner@pidgin.im>
parents: 15884
diff changeset
247 g_free(value);
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
248 } else if(!strcmp(type, "text-multi") || !strcmp(type, "jid-multi")) {
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
249 GString *str = g_string_new("");
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
250
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
251 for(valuenode = xmlnode_get_child(fn, "value"); valuenode;
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
252 valuenode = xmlnode_get_next_twin(valuenode)) {
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
253
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
254 if(!(value = xmlnode_get_data(valuenode)))
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
255 continue;
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
256
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
257 g_string_append_printf(str, "%s\n", value);
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
258 g_free(value);
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
259 }
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
260
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
261 field = purple_request_field_string_new(var, label,
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
262 str->str, TRUE);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
263 purple_request_field_group_add_field(group, field);
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
264
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
265 g_hash_table_replace(data->fields, g_strdup(var), GINT_TO_POINTER(JABBER_X_DATA_TEXT_MULTI));
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
266
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
267 g_string_free(str, TRUE);
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
268 } else if(!strcmp(type, "list-single") || !strcmp(type, "list-multi")) {
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
269 xmlnode *optnode;
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
270 GList *selected = NULL;
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
271
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
272 field = purple_request_field_list_new(var, label);
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
273
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
274 if(!strcmp(type, "list-multi")) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
275 purple_request_field_list_set_multi_select(field, TRUE);
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
276 g_hash_table_replace(data->fields, g_strdup(var),
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
277 GINT_TO_POINTER(JABBER_X_DATA_LIST_MULTI));
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
278 } else {
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
279 g_hash_table_replace(data->fields, g_strdup(var),
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
280 GINT_TO_POINTER(JABBER_X_DATA_LIST_SINGLE));
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
281 }
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
282
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
283 for(valuenode = xmlnode_get_child(fn, "value"); valuenode;
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
284 valuenode = xmlnode_get_next_twin(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
285 char *data = xmlnode_get_data(valuenode);
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 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
287 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
288 }
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
289 }
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
290
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
291 for(optnode = xmlnode_get_child(fn, "option"); optnode;
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
292 optnode = xmlnode_get_next_twin(optnode)) {
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
293 const char *lbl;
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
294
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
295 if(!(valuenode = xmlnode_get_child(optnode, "value")))
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
296 continue;
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
297
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
298 if(!(value = xmlnode_get_data(valuenode)))
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
299 continue;
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
300
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
301 if(!(lbl = 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
302 lbl = value;
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
303
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
304 data->values = g_slist_prepend(data->values, value);
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
305
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
306 purple_request_field_list_add(field, lbl, value);
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
307 if(g_list_find_custom(selected, value, (GCompareFunc)strcmp))
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
308 purple_request_field_list_add_selected(field, lbl);
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
309 }
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
310 purple_request_field_group_add_field(group, field);
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
311
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
312 while(selected) {
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
313 g_free(selected->data);
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
314 selected = g_list_delete_link(selected, selected);
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
315 }
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
316
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
317 } else if(!strcmp(type, "boolean")) {
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
318 gboolean def = FALSE;
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
319
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
320 if((valuenode = xmlnode_get_child(fn, "value")))
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
321 value = xmlnode_get_data(valuenode);
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
322
8390
13e1ff9b2850 [gaim-migrate @ 9119]
Mark Doliner <markdoliner@pidgin.im>
parents: 8385
diff changeset
323 if(value && (!g_ascii_strcasecmp(value, "yes") ||
13e1ff9b2850 [gaim-migrate @ 9119]
Mark Doliner <markdoliner@pidgin.im>
parents: 8385
diff changeset
324 !g_ascii_strcasecmp(value, "true") || !g_ascii_strcasecmp(value, "1")))
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
325 def = TRUE;
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
326
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
327 field = purple_request_field_bool_new(var, label, def);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
328 purple_request_field_group_add_field(group, field);
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
329
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
330 g_hash_table_replace(data->fields, g_strdup(var), GINT_TO_POINTER(JABBER_X_DATA_BOOLEAN));
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
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);
23176
90f6226370cb applied changes from 069f197178d158cdd308687095c14d49d8eee0ed
Daniel Atallah <datallah@pidgin.im>
parents: 22664
diff changeset
333 } else if(!strcmp(type, "fixed")) {
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
334 if((valuenode = xmlnode_get_child(fn, "value")))
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
335 value = xmlnode_get_data(valuenode);
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
336
23176
90f6226370cb applied changes from 069f197178d158cdd308687095c14d49d8eee0ed
Daniel Atallah <datallah@pidgin.im>
parents: 22664
diff changeset
337 if(value != NULL) {
90f6226370cb applied changes from 069f197178d158cdd308687095c14d49d8eee0ed
Daniel Atallah <datallah@pidgin.im>
parents: 22664
diff changeset
338 field = purple_request_field_label_new("", value);
90f6226370cb applied changes from 069f197178d158cdd308687095c14d49d8eee0ed
Daniel Atallah <datallah@pidgin.im>
parents: 22664
diff changeset
339 purple_request_field_group_add_field(group, field);
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
340
23176
90f6226370cb applied changes from 069f197178d158cdd308687095c14d49d8eee0ed
Daniel Atallah <datallah@pidgin.im>
parents: 22664
diff changeset
341 g_free(value);
90f6226370cb applied changes from 069f197178d158cdd308687095c14d49d8eee0ed
Daniel Atallah <datallah@pidgin.im>
parents: 22664
diff changeset
342 }
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
343 } else if(!strcmp(type, "hidden")) {
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
344 if((valuenode = xmlnode_get_child(fn, "value")))
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
345 value = xmlnode_get_data(valuenode);
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
346
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
347 field = purple_request_field_string_new(var, "", value ? value : "",
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
348 FALSE);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
349 purple_request_field_set_visible(field, FALSE);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
350 purple_request_field_group_add_field(group, field);
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
351
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
352 g_hash_table_replace(data->fields, g_strdup(var), GINT_TO_POINTER(JABBER_X_DATA_TEXT_SINGLE));
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
353
16136
49ddb8f06d96 I noticed some places where we were doing the whole
Mark Doliner <markdoliner@pidgin.im>
parents: 15884
diff changeset
354 g_free(value);
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
355 } else { /* text-single, jid-single, and the default */
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
356 if((valuenode = xmlnode_get_child(fn, "value")))
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
357 value = xmlnode_get_data(valuenode);
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
358
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
359 field = purple_request_field_string_new(var, label,
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
360 value ? value : "", FALSE);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
361 purple_request_field_group_add_field(group, field);
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
362
8295
440ef02f6858 [gaim-migrate @ 9019]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
363 if(!strcmp(type, "jid-single")) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
364 purple_request_field_set_type_hint(field, "screenname");
8295
440ef02f6858 [gaim-migrate @ 9019]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
365 g_hash_table_replace(data->fields, g_strdup(var), GINT_TO_POINTER(JABBER_X_DATA_JID_SINGLE));
440ef02f6858 [gaim-migrate @ 9019]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
366 } else {
440ef02f6858 [gaim-migrate @ 9019]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
367 g_hash_table_replace(data->fields, g_strdup(var), GINT_TO_POINTER(JABBER_X_DATA_TEXT_SINGLE));
440ef02f6858 [gaim-migrate @ 9019]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
368 }
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
369
16136
49ddb8f06d96 I noticed some places where we were doing the whole
Mark Doliner <markdoliner@pidgin.im>
parents: 15884
diff changeset
370 g_free(value);
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
371 }
19894
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 19203
diff changeset
372
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 19203
diff changeset
373 if(field && xmlnode_get_child(fn, "required"))
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 19203
diff changeset
374 purple_request_field_set_required(field,TRUE);
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
375 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23493
diff changeset
376
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
377 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
378 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
379 GList *action;
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
380 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
381 purple_request_fields_add_group(fields, group);
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
382 actionfield = purple_request_field_choice_new("libpurple:jabber:xdata:actions", _("Select an action"), defaultaction);
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
383
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 for(action = actions; action; action = g_list_next(action)) {
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 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
386
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
387 purple_request_field_choice_add(actionfield, a->name);
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
388 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
389 }
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
390 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
391 purple_request_field_group_add_field(group, actionfield);
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
392 }
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
393
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
394 if((x = xmlnode_get_child(packet, "title")))
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
395 title = xmlnode_get_data(x);
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
396
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
397 if((x = xmlnode_get_child(packet, "instructions")))
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
398 instructions = xmlnode_get_data(x);
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
399
21653
621c47778132 merge of '73ae9aeda3c58fbf8437421da68d19d06f93e686'
Evan Schoenberg <evands@pidgin.im>
parents: 21233
diff changeset
400 handle = purple_request_fields(js->gc, title, title, instructions, fields,
8396
8681756b4769 [gaim-migrate @ 9125]
Nathan Walp <nwalp@pidgin.im>
parents: 8390
diff changeset
401 _("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
402 _("Cancel"), G_CALLBACK(jabber_x_data_cancel_cb),
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
403 purple_connection_get_account(js->gc), /* XXX Do we have a who here? */ NULL, NULL,
21653
621c47778132 merge of '73ae9aeda3c58fbf8437421da68d19d06f93e686'
Evan Schoenberg <evands@pidgin.im>
parents: 21233
diff changeset
404 data);
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
405
16136
49ddb8f06d96 I noticed some places where we were doing the whole
Mark Doliner <markdoliner@pidgin.im>
parents: 15884
diff changeset
406 g_free(title);
49ddb8f06d96 I noticed some places where we were doing the whole
Mark Doliner <markdoliner@pidgin.im>
parents: 15884
diff changeset
407 g_free(instructions);
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
408
8396
8681756b4769 [gaim-migrate @ 9125]
Nathan Walp <nwalp@pidgin.im>
parents: 8390
diff changeset
409 return handle;
7923
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
410 }
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
411
fd43ed3cda18 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
412

mercurial