annotate src/protocols/jabber/iq.c @ 12116:e75ef7aa913e

[gaim-migrate @ 14416] " This patch implements a replacement for the queuing system from 1.x. It also obsoletes a previous patch [#1338873] I submitted to prioritize the unseen states in gtk conversations. The attached envelope.png is ripped from the msgunread.png already included in gaim. It should be dropped in the pixmaps directory (Makefile.am is updated accordingly in this patch). The two separate queuing preferences from 1.x, queuing messages while away and queuing all new messages (from docklet), are replaced with a single 3-way preference for conversations. The new preference is "Hide new IM conversations". This preference can be set to never, away and always. When a gtk conversation is created, it may be placed in a hidden conversation window instead of being placed normally. This decision is based upon the preference and possibly the away state of the account the conversation is being created for. This *will* effect conversations the user explicitly requests to be created, so in these cases the caller must be sure to present the conversation to the user, using gaim_gtkconv_present_conversation(). This is done already in gtkdialogs.c which handles creating conversations requested by the user from gaim proper (menus, double-clicking on budy in blist, etc.). The main advantage to not queuing messages is that the conversations exist, the message is written to the conversation (and logged if appropriate) and the unseen state is set on the conversation. This means no additional features are needed to track whether there are queued messages or not, just use the unseen state on conversations. Since conversations may not be visible (messages "queued"), gaim proper needs some notification that there are messages waiting. I opted for a menutray icon that shows up when an im conversation has an unseen message. Clicking this icon will focus (and show if hidden) the first conversation with an unseen message. This is essentially the same behavior of the docklet in cvs right now, except that the icon is only visible when there is a conversation with an unread message. The api that is added is flexible enough to allow either the docklet or the new blist menutray icon to be visible for conversations of any/all types and for unseen messages >= any state. Currently they are set to only IM conversations and only unseen states >= TEXT (system messages and no log messages will not trigger blinking the docklet or showing the blist tray icon), but these could be made preferences relatively easily in the future. Other plugins could probably benefit as well: gaim_gtk_conversations_get_first_unseen(). There is probably some limit to comment size, so I'll stop rambling now. If anyone has more questions/comments, catch me in #gaim, here or on gaim-devel." committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Wed, 16 Nov 2005 18:17:01 +0000
parents 9e14f1850369
children ecd471d1eeec
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1 /*
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
2 * gaim - Jabber Protocol Plugin
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
3 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
4 * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
5 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
9 * (at your option) any later version.
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
10 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
14 * GNU General Public License for more details.
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
15 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
19 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
20 */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
21 #include "internal.h"
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
22 #include "debug.h"
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
23 #include "prefs.h"
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10487
diff changeset
24 #include "util.h"
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
25
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
26 #include "buddy.h"
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
27 #include "disco.h"
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
28 #include "iq.h"
7170
1cf80749f2f0 [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
29 #include "oob.h"
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
30 #include "roster.h"
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
31 #include "si.h"
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
32
7058
06e7697f3fae [gaim-migrate @ 7621]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7014
diff changeset
33 #ifdef _WIN32
06e7697f3fae [gaim-migrate @ 7621]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7014
diff changeset
34 #include "utsname.h"
06e7697f3fae [gaim-migrate @ 7621]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7014
diff changeset
35 #endif
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
36
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
37 JabberIq *jabber_iq_new(JabberStream *js, JabberIqType type)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
38 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
39 JabberIq *iq;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
40
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
41 iq = g_new0(JabberIq, 1);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
42
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
43 iq->type = type;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
44
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
45 iq->node = xmlnode_new("iq");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
46 switch(iq->type) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
47 case JABBER_IQ_SET:
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
48 xmlnode_set_attrib(iq->node, "type", "set");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
49 break;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
50 case JABBER_IQ_GET:
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
51 xmlnode_set_attrib(iq->node, "type", "get");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
52 break;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
53 case JABBER_IQ_ERROR:
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
54 xmlnode_set_attrib(iq->node, "type", "error");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
55 break;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
56 case JABBER_IQ_RESULT:
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
57 xmlnode_set_attrib(iq->node, "type", "result");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
58 break;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
59 case JABBER_IQ_NONE:
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
60 /* this shouldn't ever happen */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
61 break;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
62 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
63
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
64 iq->js = js;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
65
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
66 if(type == JABBER_IQ_GET || type == JABBER_IQ_SET) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
67 iq->id = jabber_get_next_id(js);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
68 xmlnode_set_attrib(iq->node, "id", iq->id);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
69 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
70
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
71 return iq;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
72 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
73
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
74 JabberIq *jabber_iq_new_query(JabberStream *js, JabberIqType type,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
75 const char *xmlns)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
76 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
77 JabberIq *iq = jabber_iq_new(js, type);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
78 xmlnode *query;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
79
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
80 query = xmlnode_new_child(iq->node, "query");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
81 xmlnode_set_attrib(query, "xmlns", xmlns);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
82
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
83 return iq;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
84 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
85
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
86 typedef struct _JabberCallbackData {
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
87 JabberIqCallback *callback;
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
88 gpointer data;
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
89 } JabberCallbackData;
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
90
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
91 void
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
92 jabber_iq_set_callback(JabberIq *iq, JabberIqCallback *callback, gpointer data)
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
93 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
94 iq->callback = callback;
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
95 iq->callback_data = data;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
96 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
97
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
98 void jabber_iq_set_id(JabberIq *iq, const char *id)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
99 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
100 if(iq->id)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
101 g_free(iq->id);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
102
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
103 if(id) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
104 xmlnode_set_attrib(iq->node, "id", id);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
105 iq->id = g_strdup(id);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
106 } else {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
107 xmlnode_remove_attrib(iq->node, "id");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
108 iq->id = NULL;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
109 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
110 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
111
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
112 void jabber_iq_send(JabberIq *iq)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
113 {
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
114 JabberCallbackData *jcd;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
115 g_return_if_fail(iq != NULL);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
116
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
117 jabber_send(iq->js, iq->node);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
118
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
119 if(iq->id && iq->callback) {
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
120 jcd = g_new0(JabberCallbackData, 1);
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
121 jcd->callback = iq->callback;
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
122 jcd->data = iq->callback_data;
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
123 g_hash_table_insert(iq->js->iq_callbacks, g_strdup(iq->id), jcd);
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
124 }
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
125
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
126 jabber_iq_free(iq);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
127 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
128
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
129 void jabber_iq_free(JabberIq *iq)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
130 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
131 g_return_if_fail(iq != NULL);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
132
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
133 g_free(iq->id);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
134 xmlnode_free(iq->node);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
135 g_free(iq);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
136 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
137
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
138 static void jabber_iq_last_parse(JabberStream *js, xmlnode *packet)
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
139 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
140 JabberIq *iq;
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
141 const char *type;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
142 const char *from;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
143 const char *id;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
144 xmlnode *query;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
145 char *idle_time;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
146
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
147 type = xmlnode_get_attrib(packet, "type");
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
148 from = xmlnode_get_attrib(packet, "from");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
149 id = xmlnode_get_attrib(packet, "id");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
150
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
151 if(type && !strcmp(type, "get")) {
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
152 iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, "jabber:iq:last");
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
153 jabber_iq_set_id(iq, id);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
154 xmlnode_set_attrib(iq->node, "to", from);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
155
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
156 query = xmlnode_get_child(iq->node, "query");
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
157
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
158 idle_time = g_strdup_printf("%ld", js->idle ? time(NULL) - js->idle : 0);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
159 xmlnode_set_attrib(query, "seconds", idle_time);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
160 g_free(idle_time);
7401
aaf91a891cd9 [gaim-migrate @ 7997]
Nathan Walp <nwalp@pidgin.im>
parents: 7395
diff changeset
161
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
162 jabber_iq_send(iq);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
163 }
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
164 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
165
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
166 static void jabber_iq_time_parse(JabberStream *js, xmlnode *packet)
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
167 {
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
168 const char *type, *from, *id;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
169 JabberIq *iq;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
170 char buf[1024];
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
171 xmlnode *query;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
172 time_t now_t;
9709
4d05b6e9e9cd [gaim-migrate @ 10570]
Mark Doliner <mark@kingant.net>
parents: 8315
diff changeset
173 struct tm *now;
9722
25866d09063d [gaim-migrate @ 10583]
Mark Doliner <mark@kingant.net>
parents: 9709
diff changeset
174
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
175 time(&now_t);
9709
4d05b6e9e9cd [gaim-migrate @ 10570]
Mark Doliner <mark@kingant.net>
parents: 8315
diff changeset
176 now = localtime(&now_t);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
177
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
178 type = xmlnode_get_attrib(packet, "type");
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
179 from = xmlnode_get_attrib(packet, "from");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
180 id = xmlnode_get_attrib(packet, "id");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
181
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
182 if(type && !strcmp(type, "get")) {
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10487
diff changeset
183 char *utf8;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
184
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
185 iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, "jabber:iq:time");
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
186 jabber_iq_set_id(iq, id);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
187 xmlnode_set_attrib(iq->node, "to", from);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
188
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
189 query = xmlnode_get_child(iq->node, "query");
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
190
9709
4d05b6e9e9cd [gaim-migrate @ 10570]
Mark Doliner <mark@kingant.net>
parents: 8315
diff changeset
191 strftime(buf, sizeof(buf), "%Y%m%dT%T", now);
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
192 xmlnode_insert_data(xmlnode_new_child(query, "utc"), buf, -1);
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10487
diff changeset
193
9709
4d05b6e9e9cd [gaim-migrate @ 10570]
Mark Doliner <mark@kingant.net>
parents: 8315
diff changeset
194 strftime(buf, sizeof(buf), "%Z", now);
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10487
diff changeset
195 if((utf8 = gaim_utf8_try_convert(buf))) {
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10487
diff changeset
196 xmlnode_insert_data(xmlnode_new_child(query, "tz"), utf8, -1);
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10487
diff changeset
197 g_free(utf8);
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10487
diff changeset
198 }
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10487
diff changeset
199
9709
4d05b6e9e9cd [gaim-migrate @ 10570]
Mark Doliner <mark@kingant.net>
parents: 8315
diff changeset
200 strftime(buf, sizeof(buf), "%d %b %Y %T", now);
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10487
diff changeset
201 if((utf8 = gaim_utf8_try_convert(buf))) {
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10487
diff changeset
202 xmlnode_insert_data(xmlnode_new_child(query, "display"), utf8, -1);
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10487
diff changeset
203 g_free(utf8);
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10487
diff changeset
204 }
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
205
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
206 jabber_iq_send(iq);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
207 }
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
208 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
209
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
210 static void jabber_iq_version_parse(JabberStream *js, xmlnode *packet)
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
211 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
212 JabberIq *iq;
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
213 const char *type, *from, *id;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
214 xmlnode *query;
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10487
diff changeset
215 char *os = NULL;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
216
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
217 type = xmlnode_get_attrib(packet, "type");
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
218
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
219 if(type && !strcmp(type, "get")) {
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10487
diff changeset
220
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
221 if(!gaim_prefs_get_bool("/plugins/prpl/jabber/hide_os")) {
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
222 struct utsname osinfo;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
223
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
224 uname(&osinfo);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
225 os = g_strdup_printf("%s %s %s", osinfo.sysname, osinfo.release,
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
226 osinfo.machine);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
227 }
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10487
diff changeset
228
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
229 from = xmlnode_get_attrib(packet, "from");
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
230 id = xmlnode_get_attrib(packet, "id");
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
231
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
232 iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, "jabber:iq:version");
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
233 xmlnode_set_attrib(iq->node, "to", from);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
234 jabber_iq_set_id(iq, id);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
235
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
236 query = xmlnode_get_child(iq->node, "query");
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
237
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
238 xmlnode_insert_data(xmlnode_new_child(query, "name"), PACKAGE, -1);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
239 xmlnode_insert_data(xmlnode_new_child(query, "version"), VERSION, -1);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
240 if(os) {
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
241 xmlnode_insert_data(xmlnode_new_child(query, "os"), os, -1);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
242 g_free(os);
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
243 }
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10487
diff changeset
244
8006
45f37d7a20dc [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
245 jabber_iq_send(iq);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
246 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
247 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
248
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
249 void jabber_iq_parse(JabberStream *js, xmlnode *packet)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
250 {
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
251 JabberCallbackData *jcd;
8169
a64774143a42 [gaim-migrate @ 8882]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
252 xmlnode *query, *error, *x;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
253 const char *xmlns;
8135
8f4ce853e685 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
254 const char *type, *id, *from;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
255
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
256 query = xmlnode_get_child(packet, "query");
8043
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
257 type = xmlnode_get_attrib(packet, "type");
8135
8f4ce853e685 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
258 from = xmlnode_get_attrib(packet, "from");
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
259 id = xmlnode_get_attrib(packet, "id");
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
260
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
261 /* First, lets see if a special callback got registered */
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
262
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
263 if(type && (!strcmp(type, "result") || !strcmp(type, "error"))) {
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
264 if(id && *id && (jcd = g_hash_table_lookup(js->iq_callbacks, id))) {
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
265 jcd->callback(js, packet, jcd->data);
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
266 g_hash_table_remove(js->iq_callbacks, id);
8314
db1123eb56b0 [gaim-migrate @ 9038]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
267 return;
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
268 }
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
269 }
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
270
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
271 /* Apparently not, so lets see if we have a pre-defined handler */
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
272
8043
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
273 if(type && query && (xmlns = xmlnode_get_attrib(query, "xmlns"))) {
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
274 if(!strcmp(type, "set")) {
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
275 if(!strcmp(xmlns, "jabber:iq:roster")) {
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
276 jabber_roster_parse(js, packet);
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
277 return;
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
278 } else if(!strcmp(xmlns, "jabber:iq:oob")) {
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
279 jabber_oob_parse(js, packet);
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
280 return;
8262
b5dbd1839716 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8169
diff changeset
281 } else if(!strcmp(xmlns, "http://jabber.org/protocol/bytestreams")) {
b5dbd1839716 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8169
diff changeset
282 jabber_bytestreams_parse(js, packet);
b5dbd1839716 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8169
diff changeset
283 return;
8043
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
284 }
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
285 } else if(!strcmp(type, "get")) {
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
286 if(!strcmp(xmlns, "jabber:iq:last")) {
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
287 jabber_iq_last_parse(js, packet);
8043
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
288 return;
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
289 } else if(!strcmp(xmlns, "jabber:iq:time")) {
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
290 jabber_iq_time_parse(js, packet);
8043
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
291 return;
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
292 } else if(!strcmp(xmlns, "jabber:iq:version")) {
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
293 jabber_iq_version_parse(js, packet);
8043
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
294 return;
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
295 } else if(!strcmp(xmlns, "http://jabber.org/protocol/disco#info")) {
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
296 jabber_disco_info_parse(js, packet);
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
297 return;
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
298 } else if(!strcmp(xmlns, "http://jabber.org/protocol/disco#items")) {
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
299 jabber_disco_items_parse(js, packet);
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
300 return;
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
301 }
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
302 } else if(!strcmp(type, "result")) {
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
303 if(!strcmp(xmlns, "jabber:iq:roster")) {
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
304 jabber_roster_parse(js, packet);
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
305 return;
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
306 } else if(!strcmp(xmlns, "jabber:iq:register")) {
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
307 jabber_register_parse(js, packet);
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
308 return;
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
309 } else if(!strcmp(xmlns, "http://jabber.org/protocol/disco#info")) {
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
310 jabber_disco_info_parse(js, packet);
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
311 return;
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8006
diff changeset
312 }
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
313 }
8262
b5dbd1839716 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8169
diff changeset
314 } else {
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
315 if(xmlnode_get_child_with_namespace(packet, "si", "http://jabber.org/protocol/si")) {
8262
b5dbd1839716 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8169
diff changeset
316 jabber_si_parse(js, packet);
b5dbd1839716 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8169
diff changeset
317 return;
b5dbd1839716 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8169
diff changeset
318 }
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
319 }
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
320
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
321
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
322 /* If we get here, send the default error reply mandated by XMPP-CORE */
8135
8f4ce853e685 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
323
8315
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
324 if(type && (!strcmp(type, "set") || !strcmp(type, "get"))) {
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
325 JabberIq *iq = jabber_iq_new(js, JABBER_IQ_ERROR);
8135
8f4ce853e685 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
326
8315
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
327 xmlnode_free(iq->node);
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
328 iq->node = xmlnode_copy(packet);
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
329 xmlnode_set_attrib(iq->node, "to", from);
11825
9e14f1850369 [gaim-migrate @ 14116]
Mark Doliner <mark@kingant.net>
parents: 11822
diff changeset
330 xmlnode_remove_attrib(iq->node, "from");
8315
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
331 xmlnode_set_attrib(iq->node, "type", "error");
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
332 error = xmlnode_new_child(iq->node, "error");
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
333 xmlnode_set_attrib(error, "type", "cancel");
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
334 xmlnode_set_attrib(error, "code", "501");
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
335 x = xmlnode_new_child(error, "feature-not-implemented");
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
336 xmlnode_set_attrib(x, "xmlns", "urn:ietf:params:xml:ns:xmpp-stanzas");
8169
a64774143a42 [gaim-migrate @ 8882]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
337
8315
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
338 jabber_iq_send(iq);
52ea0ab31caa [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
339 }
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
340 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
341