Wed, 05 Sep 2007 22:32:14 +0000
propagate from branch 'im.pidgin.pidgin' (head 0853a065e5c3fcb5a6bb13fc23bec44ecf510ecd)
to branch 'im.pidgin.soc.2007.xmpp' (head b273d0db2bdd4a80d0fb22d32fe186e1f496933f)
| 2086 | 1 | /* |
| 15884 | 2 | * purple - Jabber Protocol Plugin |
| 2086 | 3 | * |
| 7014 | 4 | * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com> |
| 2086 | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify | |
| 7 | * it under the terms of the GNU General Public License as published by | |
| 8 | * the Free Software Foundation; either version 2 of the License, or | |
| 9 | * (at your option) any later version. | |
| 7014 | 10 | * |
| 2086 | 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 2086 | 14 | * GNU General Public License for more details. |
| 15 | * | |
| 16 | * You should have received a copy of the GNU General Public License | |
| 17 | * along with this program; if not, write to the Free Software | |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 2086 | 19 | * |
| 20 | */ | |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
21 | #include "internal.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
22 | |
| 7014 | 23 | #include "account.h" |
| 24 | #include "accountopt.h" | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
25 | #include "blist.h" |
| 9130 | 26 | #include "cmds.h" |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10504
diff
changeset
|
27 | #include "connection.h" |
|
15952
c087855dc551
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
28 | #include "conversation.h" |
| 7014 | 29 | #include "debug.h" |
| 11387 | 30 | #include "dnssrv.h" |
| 7014 | 31 | #include "message.h" |
| 7072 | 32 | #include "notify.h" |
| 8713 | 33 | #include "pluginpref.h" |
|
14175
2bc5a80c5071
[gaim-migrate @ 16747]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
34 | #include "proxy.h" |
| 7014 | 35 | #include "prpl.h" |
| 7072 | 36 | #include "request.h" |
| 7014 | 37 | #include "server.h" |
|
7095
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
38 | #include "util.h" |
| 9943 | 39 | #include "version.h" |
|
15952
c087855dc551
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
40 | #include "xmlnode.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
41 | |
| 7014 | 42 | #include "auth.h" |
| 43 | #include "buddy.h" | |
| 44 | #include "chat.h" | |
| 8312 | 45 | #include "disco.h" |
| 15265 | 46 | #include "google.h" |
| 7014 | 47 | #include "iq.h" |
| 48 | #include "jutil.h" | |
| 49 | #include "message.h" | |
| 50 | #include "parser.h" | |
| 51 | #include "presence.h" | |
| 52 | #include "jabber.h" | |
| 53 | #include "roster.h" | |
|
17769
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
17768
diff
changeset
|
54 | #include "ping.h" |
|
9466
b6425eab60ca
[gaim-migrate @ 10291]
Daniel Atallah <datallah@pidgin.im>
parents:
9414
diff
changeset
|
55 | #include "si.h" |
| 7923 | 56 | #include "xdata.h" |
|
17768
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
17767
diff
changeset
|
57 | #include "pep.h" |
|
17817
8e0f271aab78
The server's ad-hoc commands are now listed in the account's action menu. Note that this requires an additional field in the _PurplePluginAction struct. There's no other way, since there was no way to supply user_data, and dynamically created functions are not supported by C. This should be fine, since that struct is only malloced in purple_plugin_action_new, which is part of the core. Applications have to either pass the struct unmodified, or restore the user_data pointer if the action is recreated when necessary (as is the case in Adium).
Andreas Monitzer <am@adiumx.com>
parents:
17815
diff
changeset
|
58 | #include "adhoccommands.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
59 | |
|
17783
2687df1ca202
PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents:
17782
diff
changeset
|
60 | #include <assert.h> |
|
2687df1ca202
PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents:
17782
diff
changeset
|
61 | |
|
17813
c5cc8ebf62c0
Introduced an additional connection stage to the jabber connection progress in order to be able to tell in the application, whether SSL/TLS is enabled, so it can display a lock icon next to the connection.
Andreas Monitzer <am@adiumx.com>
parents:
17810
diff
changeset
|
62 | #define JABBER_CONNECT_STEPS (js->gsc ? 9 : 5) |
| 2086 | 63 | |
| 15884 | 64 | static PurplePlugin *my_protocol = NULL; |
|
17773
6956b763b3d1
Implemented adding callbacks for PEP events. Moved the feature list to be application-global instead of per-connection (makes more sense).
Andreas Monitzer <am@adiumx.com>
parents:
17770
diff
changeset
|
65 | GList *jabber_features; |
|
4249
62583b5d3663
[gaim-migrate @ 4499]
Robert McQueen <robot101@debian.org>
parents:
4245
diff
changeset
|
66 | |
|
18912
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
67 | static void jabber_unregister_account_cb(JabberStream *js); |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
68 | |
| 7014 | 69 | static void jabber_stream_init(JabberStream *js) |
| 70 | { | |
| 71 | char *open_stream; | |
|
3340
7e59a209931d
[gaim-migrate @ 3359]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3337
diff
changeset
|
72 | |
| 7014 | 73 | open_stream = g_strdup_printf("<stream:stream to='%s' " |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
74 | "xmlns='jabber:client' " |
| 7395 | 75 | "xmlns:stream='http://etherx.jabber.org/streams' " |
| 76 | "version='1.0'>", | |
| 7291 | 77 | js->user->domain); |
| 13808 | 78 | /* setup the parser fresh for each stream */ |
| 79 | jabber_parser_setup(js); | |
| 7642 | 80 | jabber_send_raw(js, open_stream, -1); |
| 14062 | 81 | js->reinit = FALSE; |
| 7014 | 82 | g_free(open_stream); |
| 2086 | 83 | } |
| 84 | ||
| 7395 | 85 | static void |
| 86 | jabber_session_initialized_cb(JabberStream *js, xmlnode *packet, gpointer data) | |
| 3311 | 87 | { |
| 7014 | 88 | const char *type = xmlnode_get_attrib(packet, "type"); |
| 89 | if(type && !strcmp(type, "result")) { | |
| 90 | jabber_stream_set_state(js, JABBER_STREAM_CONNECTED); | |
|
18912
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
91 | if(js->unregistration) |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
92 | jabber_unregister_account_cb(js); |
| 7014 | 93 | } else { |
| 15884 | 94 | purple_connection_error(js->gc, _("Error initializing session")); |
| 3311 | 95 | } |
| 96 | } | |
| 97 | ||
| 7014 | 98 | static void jabber_session_init(JabberStream *js) |
| 3311 | 99 | { |
| 7014 | 100 | JabberIq *iq = jabber_iq_new(js, JABBER_IQ_SET); |
| 101 | xmlnode *session; | |
| 3311 | 102 | |
| 7395 | 103 | jabber_iq_set_callback(iq, jabber_session_initialized_cb, NULL); |
| 3311 | 104 | |
| 7014 | 105 | session = xmlnode_new_child(iq->node, "session"); |
| 13808 | 106 | xmlnode_set_namespace(session, "urn:ietf:params:xml:ns:xmpp-session"); |
| 3311 | 107 | |
| 7014 | 108 | jabber_iq_send(iq); |
| 3311 | 109 | } |
| 110 | ||
| 7395 | 111 | static void jabber_bind_result_cb(JabberStream *js, xmlnode *packet, |
| 112 | gpointer data) | |
| 113 | { | |
| 8401 | 114 | const char *type = xmlnode_get_attrib(packet, "type"); |
| 115 | xmlnode *bind; | |
| 116 | ||
| 117 | if(type && !strcmp(type, "result") && | |
| 118 | (bind = xmlnode_get_child_with_namespace(packet, "bind", "urn:ietf:params:xml:ns:xmpp-bind"))) { | |
| 119 | xmlnode *jid; | |
| 120 | char *full_jid; | |
| 121 | if((jid = xmlnode_get_child(bind, "jid")) && (full_jid = xmlnode_get_data(jid))) { | |
| 10289 | 122 | JabberBuddy *my_jb = NULL; |
| 8401 | 123 | jabber_id_free(js->user); |
| 124 | if(!(js->user = jabber_id_new(full_jid))) { | |
| 15884 | 125 | purple_connection_error(js->gc, _("Invalid response from server.")); |
| 8401 | 126 | } |
| 10289 | 127 | if((my_jb = jabber_buddy_find(js, full_jid, TRUE))) |
| 128 | my_jb->subscription |= JABBER_SUB_BOTH; | |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10490
diff
changeset
|
129 | g_free(full_jid); |
| 8401 | 130 | } |
| 131 | } else { | |
| 132 | char *msg = jabber_parse_error(js, packet); | |
| 15884 | 133 | purple_connection_error(js->gc, msg); |
| 8401 | 134 | g_free(msg); |
| 135 | } | |
| 7395 | 136 | |
| 137 | jabber_session_init(js); | |
| 138 | } | |
| 139 | ||
| 140 | static void jabber_stream_features_parse(JabberStream *js, xmlnode *packet) | |
| 141 | { | |
| 8296 | 142 | if(xmlnode_get_child(packet, "starttls")) { |
| 143 | if(jabber_process_starttls(js, packet)) | |
| 144 | return; | |
|
17830
ae563ca41109
Added an option to require SSL or TLS when connecting to an XMPP server.
Andreas Monitzer <am@adiumx.com>
parents:
17828
diff
changeset
|
145 | } else if(purple_account_get_bool(js->gc->account, "require_tls", FALSE) && !js->gsc) { |
|
ae563ca41109
Added an option to require SSL or TLS when connecting to an XMPP server.
Andreas Monitzer <am@adiumx.com>
parents:
17828
diff
changeset
|
146 | purple_connection_error(js->gc, _("You require encryption, but it is not available on this server.")); |
|
ae563ca41109
Added an option to require SSL or TLS when connecting to an XMPP server.
Andreas Monitzer <am@adiumx.com>
parents:
17828
diff
changeset
|
147 | return; |
| 8296 | 148 | } |
| 149 | ||
| 10988 | 150 | if(js->registration) { |
| 151 | jabber_register_start(js); | |
| 152 | } else if(xmlnode_get_child(packet, "mechanisms")) { | |
| 7395 | 153 | jabber_auth_start(js, packet); |
| 154 | } else if(xmlnode_get_child(packet, "bind")) { | |
| 155 | xmlnode *bind, *resource; | |
| 156 | JabberIq *iq = jabber_iq_new(js, JABBER_IQ_SET); | |
| 157 | bind = xmlnode_new_child(iq->node, "bind"); | |
| 13808 | 158 | xmlnode_set_namespace(bind, "urn:ietf:params:xml:ns:xmpp-bind"); |
| 7395 | 159 | resource = xmlnode_new_child(bind, "resource"); |
| 160 | xmlnode_insert_data(resource, js->user->resource, -1); | |
| 161 | ||
| 162 | jabber_iq_set_callback(iq, jabber_bind_result_cb, NULL); | |
| 163 | ||
| 164 | jabber_iq_send(iq); | |
| 8296 | 165 | } else /* if(xmlnode_get_child_with_namespace(packet, "auth")) */ { |
| 166 | /* If we get an empty stream:features packet, or we explicitly get | |
| 167 | * an auth feature with namespace http://jabber.org/features/iq-auth | |
| 168 | * we should revert back to iq:auth authentication, even though we're | |
| 169 | * connecting to an XMPP server. */ | |
| 170 | js->auth_type = JABBER_AUTH_IQ_AUTH; | |
| 171 | jabber_stream_set_state(js, JABBER_STREAM_AUTHENTICATING); | |
| 7395 | 172 | } |
| 173 | } | |
| 174 | ||
| 7014 | 175 | static void jabber_stream_handle_error(JabberStream *js, xmlnode *packet) |
| 3311 | 176 | { |
| 8401 | 177 | char *msg = jabber_parse_error(js, packet); |
| 3311 | 178 | |
| 15884 | 179 | purple_connection_error(js->gc, msg); |
| 8401 | 180 | g_free(msg); |
| 2086 | 181 | } |
| 182 | ||
| 7014 | 183 | static void tls_init(JabberStream *js); |
| 2086 | 184 | |
|
17828
6957bf9d7330
Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents:
17827
diff
changeset
|
185 | void jabber_process_packet(JabberStream *js, xmlnode **packet) |
| 2086 | 186 | { |
| 15980 | 187 | const char *xmlns; |
| 188 | ||
|
17828
6957bf9d7330
Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents:
17827
diff
changeset
|
189 | purple_signal_emit(my_protocol, "jabber-receiving-xmlnode", js->gc, packet); |
| 14358 | 190 | |
| 191 | /* if the signal leaves us with a null packet, we're done */ | |
|
17828
6957bf9d7330
Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents:
17827
diff
changeset
|
192 | if(NULL == *packet) |
| 14358 | 193 | return; |
| 194 | ||
|
17828
6957bf9d7330
Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents:
17827
diff
changeset
|
195 | xmlns = xmlnode_get_namespace(*packet); |
| 15980 | 196 | |
|
17828
6957bf9d7330
Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents:
17827
diff
changeset
|
197 | if(!strcmp((*packet)->name, "iq")) { |
|
6957bf9d7330
Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents:
17827
diff
changeset
|
198 | jabber_iq_parse(js, *packet); |
|
6957bf9d7330
Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents:
17827
diff
changeset
|
199 | } else if(!strcmp((*packet)->name, "presence")) { |
|
6957bf9d7330
Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents:
17827
diff
changeset
|
200 | jabber_presence_parse(js, *packet); |
|
6957bf9d7330
Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents:
17827
diff
changeset
|
201 | } else if(!strcmp((*packet)->name, "message")) { |
|
6957bf9d7330
Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents:
17827
diff
changeset
|
202 | jabber_message_parse(js, *packet); |
|
6957bf9d7330
Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents:
17827
diff
changeset
|
203 | } else if(!strcmp((*packet)->name, "stream:features")) { |
|
6957bf9d7330
Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents:
17827
diff
changeset
|
204 | jabber_stream_features_parse(js, *packet); |
|
6957bf9d7330
Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents:
17827
diff
changeset
|
205 | } else if (!strcmp((*packet)->name, "features") && |
| 15980 | 206 | !strcmp(xmlns, "http://etherx.jabber.org/streams")) { |
|
17828
6957bf9d7330
Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents:
17827
diff
changeset
|
207 | jabber_stream_features_parse(js, *packet); |
|
6957bf9d7330
Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents:
17827
diff
changeset
|
208 | } else if(!strcmp((*packet)->name, "stream:error") || |
|
6957bf9d7330
Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents:
17827
diff
changeset
|
209 | (!strcmp((*packet)->name, "error") && |
| 15980 | 210 | !strcmp(xmlns, "http://etherx.jabber.org/streams"))) |
| 211 | { | |
|
17828
6957bf9d7330
Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents:
17827
diff
changeset
|
212 | jabber_stream_handle_error(js, *packet); |
|
6957bf9d7330
Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents:
17827
diff
changeset
|
213 | } else if(!strcmp((*packet)->name, "challenge")) { |
| 7014 | 214 | if(js->state == JABBER_STREAM_AUTHENTICATING) |
|
17828
6957bf9d7330
Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents:
17827
diff
changeset
|
215 | jabber_auth_handle_challenge(js, *packet); |
|
6957bf9d7330
Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents:
17827
diff
changeset
|
216 | } else if(!strcmp((*packet)->name, "success")) { |
| 7014 | 217 | if(js->state == JABBER_STREAM_AUTHENTICATING) |
|
17828
6957bf9d7330
Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents:
17827
diff
changeset
|
218 | jabber_auth_handle_success(js, *packet); |
|
6957bf9d7330
Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents:
17827
diff
changeset
|
219 | } else if(!strcmp((*packet)->name, "failure")) { |
| 7014 | 220 | if(js->state == JABBER_STREAM_AUTHENTICATING) |
|
17828
6957bf9d7330
Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents:
17827
diff
changeset
|
221 | jabber_auth_handle_failure(js, *packet); |
|
6957bf9d7330
Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents:
17827
diff
changeset
|
222 | } else if(!strcmp((*packet)->name, "proceed")) { |
| 7014 | 223 | if(js->state == JABBER_STREAM_AUTHENTICATING && !js->gsc) |
| 224 | tls_init(js); | |
| 225 | } else { | |
| 15884 | 226 | purple_debug(PURPLE_DEBUG_WARNING, "jabber", "Unknown packet: %s\n", |
|
17828
6957bf9d7330
Fixed a bug in the XMPP parser involving event handlers that replace the xmlnode packet. This caused double frees in this situation. The replacing function must free the xmlnode, since multiple event handlers could do this, and the intermediate xml trees would leak otherwise.
Andreas Monitzer <am@adiumx.com>
parents:
17827
diff
changeset
|
227 | (*packet)->name); |
| 2086 | 228 | } |
| 229 | } | |
| 230 | ||
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
231 | static int jabber_do_send(JabberStream *js, const char *data, int len) |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
232 | { |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
233 | int ret; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
234 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
235 | if (js->gsc) |
| 15884 | 236 | ret = purple_ssl_write(js->gsc, data, len); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
237 | else |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
238 | ret = write(js->fd, data, len); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
239 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
240 | return ret; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
241 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
242 | |
| 15884 | 243 | static void jabber_send_cb(gpointer data, gint source, PurpleInputCondition cond) |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
244 | { |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
245 | JabberStream *js = data; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
246 | int ret, writelen; |
| 15884 | 247 | writelen = purple_circ_buffer_get_max_read(js->write_buffer); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
248 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
249 | if (writelen == 0) { |
| 15884 | 250 | purple_input_remove(js->writeh); |
|
13746
790924f38349
[gaim-migrate @ 16155]
Mark Doliner <markdoliner@pidgin.im>
parents:
13546
diff
changeset
|
251 | js->writeh = 0; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
252 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
253 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
254 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
255 | ret = jabber_do_send(js, js->write_buffer->outptr, writelen); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
256 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
257 | if (ret < 0 && errno == EAGAIN) |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
258 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
259 | else if (ret <= 0) { |
| 15884 | 260 | purple_connection_error(js->gc, _("Write error")); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
261 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
262 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
263 | |
| 15884 | 264 | purple_circ_buffer_mark_read(js->write_buffer, ret); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
265 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
266 | |
| 7642 | 267 | void jabber_send_raw(JabberStream *js, const char *data, int len) |
| 2086 | 268 | { |
| 7014 | 269 | int ret; |
| 2086 | 270 | |
| 7014 | 271 | /* because printing a tab to debug every minute gets old */ |
| 272 | if(strcmp(data, "\t")) | |
| 15884 | 273 | purple_debug(PURPLE_DEBUG_MISC, "jabber", "Sending%s: %s\n", |
| 7014 | 274 | js->gsc ? " (ssl)" : "", data); |
| 2086 | 275 | |
| 12508 | 276 | /* If we've got a security layer, we need to encode the data, |
| 277 | * splitting it on the maximum buffer length negotiated */ | |
| 14668 | 278 | |
| 15884 | 279 | purple_signal_emit(my_protocol, "jabber-sending-text", js->gc, &data); |
| 15412 | 280 | if (data == NULL) |
| 281 | return; | |
| 14668 | 282 | |
| 12508 | 283 | #ifdef HAVE_CYRUS_SASL |
| 284 | if (js->sasl_maxbuf>0) { | |
| 285 | int pos; | |
| 286 | ||
| 287 | if (!js->gsc && js->fd<0) | |
| 288 | return; | |
| 289 | pos = 0; | |
| 290 | if (len == -1) | |
| 291 | len = strlen(data); | |
| 292 | while (pos < len) { | |
| 293 | int towrite; | |
| 294 | const char *out; | |
| 295 | unsigned olen; | |
| 296 | ||
| 297 | if ((len - pos) < js->sasl_maxbuf) | |
| 298 | towrite = len - pos; | |
| 299 | else | |
| 300 | towrite = js->sasl_maxbuf; | |
| 301 | ||
| 302 | sasl_encode(js->sasl, &data[pos], towrite, &out, &olen); | |
| 303 | pos += towrite; | |
| 304 | ||
|
15783
e2f6e431f5a6
Simon Wilkinson noticed that this check was invalid and caused authentications to hang.
Daniel Atallah <datallah@pidgin.im>
parents:
15709
diff
changeset
|
305 | if (js->writeh == 0) |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
306 | ret = jabber_do_send(js, out, olen); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
307 | else { |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
308 | ret = -1; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
309 | errno = EAGAIN; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
310 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
311 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
312 | if (ret < 0 && errno != EAGAIN) |
| 15884 | 313 | purple_connection_error(js->gc, _("Write error")); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
314 | else if (ret < olen) { |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
315 | if (ret < 0) |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
316 | ret = 0; |
|
13746
790924f38349
[gaim-migrate @ 16155]
Mark Doliner <markdoliner@pidgin.im>
parents:
13546
diff
changeset
|
317 | if (js->writeh == 0) |
| 15884 | 318 | js->writeh = purple_input_add( |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
319 | js->gsc ? js->gsc->fd : js->fd, |
| 15884 | 320 | PURPLE_INPUT_WRITE, |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
321 | jabber_send_cb, js); |
| 15884 | 322 | purple_circ_buffer_append(js->write_buffer, |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
323 | out + ret, olen - ret); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
324 | } |
| 12508 | 325 | } |
| 326 | return; | |
| 327 | } | |
| 328 | #endif | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
329 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
330 | if (len == -1) |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
331 | len = strlen(data); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
332 | |
|
13746
790924f38349
[gaim-migrate @ 16155]
Mark Doliner <markdoliner@pidgin.im>
parents:
13546
diff
changeset
|
333 | if (js->writeh == 0) |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
334 | ret = jabber_do_send(js, data, len); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
335 | else { |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
336 | ret = -1; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
337 | errno = EAGAIN; |
|
2814
91cc1a0cdee0
[gaim-migrate @ 2827]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2800
diff
changeset
|
338 | } |
|
91cc1a0cdee0
[gaim-migrate @ 2827]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2800
diff
changeset
|
339 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
340 | if (ret < 0 && errno != EAGAIN) |
| 15884 | 341 | purple_connection_error(js->gc, _("Write error")); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
342 | else if (ret < len) { |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
343 | if (ret < 0) |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
344 | ret = 0; |
|
13746
790924f38349
[gaim-migrate @ 16155]
Mark Doliner <markdoliner@pidgin.im>
parents:
13546
diff
changeset
|
345 | if (js->writeh == 0) |
| 15884 | 346 | js->writeh = purple_input_add( |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
347 | js->gsc ? js->gsc->fd : js->fd, |
| 15884 | 348 | PURPLE_INPUT_WRITE, jabber_send_cb, js); |
| 349 | purple_circ_buffer_append(js->write_buffer, | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
350 | data + ret, len - ret); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
351 | } |
| 14604 | 352 | return; |
| 353 | } | |
| 7014 | 354 | |
|
16302
eb633ebf84f2
This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
Sean Egan <seanegan@pidgin.im>
parents:
16180
diff
changeset
|
355 | int jabber_prpl_send_raw(PurpleConnection *gc, const char *buf, int len) |
| 14604 | 356 | { |
| 357 | JabberStream *js = (JabberStream*)gc->proto_data; | |
| 358 | jabber_send_raw(js, buf, len); | |
| 359 | return len; | |
|
2814
91cc1a0cdee0
[gaim-migrate @ 2827]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2800
diff
changeset
|
360 | } |
|
91cc1a0cdee0
[gaim-migrate @ 2827]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2800
diff
changeset
|
361 | |
| 7014 | 362 | void jabber_send(JabberStream *js, xmlnode *packet) |
| 2086 | 363 | { |
| 7014 | 364 | char *txt; |
| 7642 | 365 | int len; |
| 2086 | 366 | |
| 15884 | 367 | purple_signal_emit(my_protocol, "jabber-sending-xmlnode", js->gc, &packet); |
| 14358 | 368 | |
| 369 | /* if we get NULL back, we're done processing */ | |
| 370 | if(NULL == packet) | |
| 371 | return; | |
| 372 | ||
| 7642 | 373 | txt = xmlnode_to_str(packet, &len); |
| 374 | jabber_send_raw(js, txt, len); | |
| 7014 | 375 | g_free(txt); |
| 2086 | 376 | } |
| 377 | ||
|
16302
eb633ebf84f2
This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
Sean Egan <seanegan@pidgin.im>
parents:
16180
diff
changeset
|
378 | void jabber_keepalive(PurpleConnection *gc) |
| 2086 | 379 | { |
| 7642 | 380 | jabber_send_raw(gc->proto_data, "\t", -1); |
| 2086 | 381 | } |
| 382 | ||
| 7014 | 383 | static void |
| 15884 | 384 | jabber_recv_cb_ssl(gpointer data, PurpleSslConnection *gsc, |
| 385 | PurpleInputCondition cond) | |
| 6764 | 386 | { |
| 15884 | 387 | PurpleConnection *gc = data; |
| 7014 | 388 | JabberStream *js = gc->proto_data; |
| 6764 | 389 | int len; |
| 7014 | 390 | static char buf[4096]; |
| 6768 | 391 | |
|
14030
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
14004
diff
changeset
|
392 | /* TODO: It should be possible to make this check unnecessary */ |
| 15884 | 393 | if(!PURPLE_CONNECTION_IS_VALID(gc)) { |
| 394 | purple_ssl_close(gsc); | |
| 6768 | 395 | return; |
| 396 | } | |
| 397 | ||
| 15884 | 398 | while((len = purple_ssl_read(gsc, buf, sizeof(buf) - 1)) > 0) { |
| 6764 | 399 | buf[len] = '\0'; |
| 15884 | 400 | purple_debug(PURPLE_DEBUG_INFO, "jabber", "Recv (ssl)(%d): %s\n", len, buf); |
| 7014 | 401 | jabber_parser_process(js, buf, len); |
| 14062 | 402 | if(js->reinit) |
| 403 | jabber_stream_init(js); | |
| 13280 | 404 | } |
| 405 | ||
| 406 | if(errno == EAGAIN) | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
407 | return; |
| 13280 | 408 | else |
| 15884 | 409 | purple_connection_error(gc, _("Read Error")); |
| 2086 | 410 | } |
| 411 | ||
| 7014 | 412 | static void |
| 15884 | 413 | jabber_recv_cb(gpointer data, gint source, PurpleInputCondition condition) |
| 2086 | 414 | { |
| 15884 | 415 | PurpleConnection *gc = data; |
| 7014 | 416 | JabberStream *js = gc->proto_data; |
| 417 | int len; | |
| 418 | static char buf[4096]; | |
| 2086 | 419 | |
| 15884 | 420 | if(!PURPLE_CONNECTION_IS_VALID(gc)) |
| 7014 | 421 | return; |
| 2956 | 422 | |
| 7014 | 423 | if((len = read(js->fd, buf, sizeof(buf) - 1)) > 0) { |
| 12508 | 424 | #ifdef HAVE_CYRUS_SASL |
| 425 | if (js->sasl_maxbuf>0) { | |
| 426 | const char *out; | |
|
14697
518c0fae208e
[gaim-migrate @ 17381]
Daniel Atallah <datallah@pidgin.im>
parents:
14668
diff
changeset
|
427 | unsigned int olen; |
| 12508 | 428 | sasl_decode(js->sasl, buf, len, &out, &olen); |
| 429 | if (olen>0) { | |
| 15884 | 430 | purple_debug(PURPLE_DEBUG_INFO, "jabber", "RecvSASL (%u): %s\n", olen, out); |
| 12508 | 431 | jabber_parser_process(js,out,olen); |
| 14700 | 432 | if(js->reinit) |
| 433 | jabber_stream_init(js); | |
| 12508 | 434 | } |
| 435 | return; | |
| 436 | } | |
| 437 | #endif | |
| 7014 | 438 | buf[len] = '\0'; |
| 15884 | 439 | purple_debug(PURPLE_DEBUG_INFO, "jabber", "Recv (%d): %s\n", len, buf); |
| 7014 | 440 | jabber_parser_process(js, buf, len); |
| 14700 | 441 | if(js->reinit) |
| 442 | jabber_stream_init(js); | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
443 | } else if(errno == EAGAIN) { |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
444 | return; |
| 7177 | 445 | } else { |
| 15884 | 446 | purple_connection_error(gc, _("Read Error")); |
| 7014 | 447 | } |
| 2086 | 448 | } |
| 449 | ||
| 7014 | 450 | static void |
| 15884 | 451 | jabber_login_callback_ssl(gpointer data, PurpleSslConnection *gsc, |
| 452 | PurpleInputCondition cond) | |
| 6764 | 453 | { |
| 15884 | 454 | PurpleConnection *gc = data; |
|
15023
c38f385a128a
[gaim-migrate @ 17740]
Evan Schoenberg <evands@pidgin.im>
parents:
14899
diff
changeset
|
455 | JabberStream *js; |
|
c38f385a128a
[gaim-migrate @ 17740]
Evan Schoenberg <evands@pidgin.im>
parents:
14899
diff
changeset
|
456 | |
|
c38f385a128a
[gaim-migrate @ 17740]
Evan Schoenberg <evands@pidgin.im>
parents:
14899
diff
changeset
|
457 | /* TODO: It should be possible to make this check unnecessary */ |
| 15884 | 458 | if(!PURPLE_CONNECTION_IS_VALID(gc)) { |
| 459 | purple_ssl_close(gsc); | |
|
15023
c38f385a128a
[gaim-migrate @ 17740]
Evan Schoenberg <evands@pidgin.im>
parents:
14899
diff
changeset
|
460 | return; |
|
c38f385a128a
[gaim-migrate @ 17740]
Evan Schoenberg <evands@pidgin.im>
parents:
14899
diff
changeset
|
461 | } |
|
c38f385a128a
[gaim-migrate @ 17740]
Evan Schoenberg <evands@pidgin.im>
parents:
14899
diff
changeset
|
462 | |
|
c38f385a128a
[gaim-migrate @ 17740]
Evan Schoenberg <evands@pidgin.im>
parents:
14899
diff
changeset
|
463 | js = gc->proto_data; |
|
17813
c5cc8ebf62c0
Introduced an additional connection stage to the jabber connection progress in order to be able to tell in the application, whether SSL/TLS is enabled, so it can display a lock icon next to the connection.
Andreas Monitzer <am@adiumx.com>
parents:
17810
diff
changeset
|
464 | |
| 7014 | 465 | if(js->state == JABBER_STREAM_CONNECTING) |
| 7642 | 466 | jabber_send_raw(js, "<?xml version='1.0' ?>", -1); |
| 7014 | 467 | jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING); |
| 15884 | 468 | purple_ssl_input_add(gsc, jabber_recv_cb_ssl, gc); |
|
17813
c5cc8ebf62c0
Introduced an additional connection stage to the jabber connection progress in order to be able to tell in the application, whether SSL/TLS is enabled, so it can display a lock icon next to the connection.
Andreas Monitzer <am@adiumx.com>
parents:
17810
diff
changeset
|
469 | |
|
c5cc8ebf62c0
Introduced an additional connection stage to the jabber connection progress in order to be able to tell in the application, whether SSL/TLS is enabled, so it can display a lock icon next to the connection.
Andreas Monitzer <am@adiumx.com>
parents:
17810
diff
changeset
|
470 | /* Tell the app that we're doing encryption */ |
|
c5cc8ebf62c0
Introduced an additional connection stage to the jabber connection progress in order to be able to tell in the application, whether SSL/TLS is enabled, so it can display a lock icon next to the connection.
Andreas Monitzer <am@adiumx.com>
parents:
17810
diff
changeset
|
471 | jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING_ENCRYPTION); |
| 6764 | 472 | } |
| 473 | ||
| 7014 | 474 | |
| 475 | static void | |
|
14175
2bc5a80c5071
[gaim-migrate @ 16747]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
476 | jabber_login_callback(gpointer data, gint source, const gchar *error) |
| 6764 | 477 | { |
| 15884 | 478 | PurpleConnection *gc = data; |
| 7014 | 479 | JabberStream *js = gc->proto_data; |
| 2086 | 480 | |
|
8783
7be6da5bc279
[gaim-migrate @ 9545]
Mark Doliner <markdoliner@pidgin.im>
parents:
8778
diff
changeset
|
481 | if (source < 0) { |
|
17643
870d08f93965
Better error message for when a Jabber connection fails
Mark Doliner <markdoliner@pidgin.im>
parents:
17052
diff
changeset
|
482 | gchar *tmp; |
|
870d08f93965
Better error message for when a Jabber connection fails
Mark Doliner <markdoliner@pidgin.im>
parents:
17052
diff
changeset
|
483 | tmp = g_strdup_printf(_("Could not establish a connection with the server:\n%s"), |
|
870d08f93965
Better error message for when a Jabber connection fails
Mark Doliner <markdoliner@pidgin.im>
parents:
17052
diff
changeset
|
484 | error); |
|
870d08f93965
Better error message for when a Jabber connection fails
Mark Doliner <markdoliner@pidgin.im>
parents:
17052
diff
changeset
|
485 | purple_connection_error(gc, tmp); |
|
870d08f93965
Better error message for when a Jabber connection fails
Mark Doliner <markdoliner@pidgin.im>
parents:
17052
diff
changeset
|
486 | g_free(tmp); |
|
8783
7be6da5bc279
[gaim-migrate @ 9545]
Mark Doliner <markdoliner@pidgin.im>
parents:
8778
diff
changeset
|
487 | return; |
|
7be6da5bc279
[gaim-migrate @ 9545]
Mark Doliner <markdoliner@pidgin.im>
parents:
8778
diff
changeset
|
488 | } |
|
7be6da5bc279
[gaim-migrate @ 9545]
Mark Doliner <markdoliner@pidgin.im>
parents:
8778
diff
changeset
|
489 | |
| 7014 | 490 | js->fd = source; |
| 2956 | 491 | |
| 7014 | 492 | if(js->state == JABBER_STREAM_CONNECTING) |
| 7642 | 493 | jabber_send_raw(js, "<?xml version='1.0' ?>", -1); |
|
2300
06a3c10f4918
[gaim-migrate @ 2310]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2289
diff
changeset
|
494 | |
| 7014 | 495 | jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING); |
| 15884 | 496 | gc->inpa = purple_input_add(js->fd, PURPLE_INPUT_READ, jabber_recv_cb, gc); |
| 7014 | 497 | } |
| 2086 | 498 | |
| 7014 | 499 | static void |
| 15884 | 500 | jabber_ssl_connect_failure(PurpleSslConnection *gsc, PurpleSslErrorType error, |
| 7426 | 501 | gpointer data) |
| 502 | { | |
| 15884 | 503 | PurpleConnection *gc = data; |
|
15668
c8831ae23d4c
If jabber_ssl_connect_failure() is called because a connect attempt fails, but the user has already canceled the attempt by signing the account offline, this would previously crash. It now does not.
Evan Schoenberg <evands@pidgin.im>
parents:
15558
diff
changeset
|
504 | JabberStream *js; |
| 7426 | 505 | |
|
15668
c8831ae23d4c
If jabber_ssl_connect_failure() is called because a connect attempt fails, but the user has already canceled the attempt by signing the account offline, this would previously crash. It now does not.
Evan Schoenberg <evands@pidgin.im>
parents:
15558
diff
changeset
|
506 | /* If the connection is already disconnected, we don't need to do anything else */ |
| 15884 | 507 | if(!PURPLE_CONNECTION_IS_VALID(gc)) |
|
15668
c8831ae23d4c
If jabber_ssl_connect_failure() is called because a connect attempt fails, but the user has already canceled the attempt by signing the account offline, this would previously crash. It now does not.
Evan Schoenberg <evands@pidgin.im>
parents:
15558
diff
changeset
|
508 | return; |
|
c8831ae23d4c
If jabber_ssl_connect_failure() is called because a connect attempt fails, but the user has already canceled the attempt by signing the account offline, this would previously crash. It now does not.
Evan Schoenberg <evands@pidgin.im>
parents:
15558
diff
changeset
|
509 | |
|
c8831ae23d4c
If jabber_ssl_connect_failure() is called because a connect attempt fails, but the user has already canceled the attempt by signing the account offline, this would previously crash. It now does not.
Evan Schoenberg <evands@pidgin.im>
parents:
15558
diff
changeset
|
510 | js = gc->proto_data; |
|
14312
6ce4512aa9a8
[gaim-migrate @ 16932]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
511 | js->gsc = NULL; |
|
6ce4512aa9a8
[gaim-migrate @ 16932]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
512 | |
|
18488
662f2635497f
- Replace switch statements in irc and jabber prpls with purple_ssl_strerror calls
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18486
diff
changeset
|
513 | purple_connection_error(gc, purple_ssl_strerror(error)); |
| 7426 | 514 | } |
| 515 | ||
| 7427 | 516 | static void tls_init(JabberStream *js) |
| 517 | { | |
| 15884 | 518 | purple_input_remove(js->gc->inpa); |
| 7427 | 519 | js->gc->inpa = 0; |
|
18449
2d2df64f4303
applied changes from f9186fabb483b56a9d7e8fb7241b2520e9930413
William Ehlhardt <williamehlhardt@gmail.com>
parents:
18235
diff
changeset
|
520 | js->gsc = purple_ssl_connect_with_host_fd(js->gc->account, js->fd, |
|
17765
04aaa6965b10
Fixed one of the issues in the ssl stuff, allowing CN cert checks for starttls-connections in XMPP.
Andreas Monitzer <am@adiumx.com>
parents:
17052
diff
changeset
|
521 | jabber_login_callback_ssl, jabber_ssl_connect_failure, js->serverFQDN, js->gc); |
| 7427 | 522 | } |
| 523 | ||
| 17052 | 524 | static void jabber_login_connect(JabberStream *js, const char *fqdn, const char *host, int port) |
| 11387 | 525 | { |
| 17052 | 526 | js->serverFQDN = g_strdup(fqdn); |
|
15800
2d0ec4fe2681
pass the correct domain to cyrus sasl (sf patch 1663064)
Nathan Walp <nwalp@pidgin.im>
parents:
15783
diff
changeset
|
527 | |
| 17052 | 528 | if (purple_proxy_connect(js->gc, js->gc->account, host, |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14700
diff
changeset
|
529 | port, jabber_login_callback, js->gc) == NULL) |
| 15884 | 530 | purple_connection_error(js->gc, _("Unable to create socket")); |
| 11387 | 531 | } |
| 532 | ||
| 15884 | 533 | static void srv_resolved_cb(PurpleSrvResponse *resp, int results, gpointer data) |
| 11387 | 534 | { |
|
13956
c3001d55c88f
[gaim-migrate @ 16377]
Mark Doliner <markdoliner@pidgin.im>
parents:
13808
diff
changeset
|
535 | JabberStream *js; |
|
c3001d55c88f
[gaim-migrate @ 16377]
Mark Doliner <markdoliner@pidgin.im>
parents:
13808
diff
changeset
|
536 | |
|
14370
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14358
diff
changeset
|
537 | js = data; |
|
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14358
diff
changeset
|
538 | js->srv_query_data = NULL; |
| 11387 | 539 | |
| 540 | if(results) { | |
| 17052 | 541 | jabber_login_connect(js, resp->hostname, resp->hostname, resp->port); |
| 11387 | 542 | g_free(resp); |
| 543 | } else { | |
| 17052 | 544 | jabber_login_connect(js, js->user->domain, js->user->domain, |
| 15884 | 545 | purple_account_get_int(js->gc->account, "port", 5222)); |
| 11387 | 546 | } |
| 547 | } | |
| 548 | ||
|
16302
eb633ebf84f2
This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
Sean Egan <seanegan@pidgin.im>
parents:
16180
diff
changeset
|
549 | void |
| 15884 | 550 | jabber_login(PurpleAccount *account) |
| 2086 | 551 | { |
| 15884 | 552 | PurpleConnection *gc = purple_account_get_connection(account); |
| 553 | const char *connect_server = purple_account_get_string(account, | |
| 7014 | 554 | "connect_server", ""); |
| 555 | JabberStream *js; | |
| 10289 | 556 | JabberBuddy *my_jb = NULL; |
| 2086 | 557 | |
| 15884 | 558 | gc->flags |= PURPLE_CONNECTION_HTML; |
| 7014 | 559 | js = gc->proto_data = g_new0(JabberStream, 1); |
| 560 | js->gc = gc; | |
|
8013
03f5b77cdaf0
[gaim-migrate @ 8693]
Olivier Blin <blino@users.sourceforge.net>
parents:
8011
diff
changeset
|
561 | js->fd = -1; |
| 8312 | 562 | js->iq_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 563 | g_free, g_free); | |
| 564 | js->disco_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, | |
| 7395 | 565 | g_free, g_free); |
| 7014 | 566 | js->buddies = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 7116 | 567 | g_free, (GDestroyNotify)jabber_buddy_free); |
| 7014 | 568 | js->chats = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 8396 | 569 | g_free, (GDestroyNotify)jabber_chat_free); |
| 15884 | 570 | js->user = jabber_id_new(purple_account_get_username(account)); |
| 7322 | 571 | js->next_id = g_random_int(); |
| 15884 | 572 | js->write_buffer = purple_circ_buffer_new(512); |
|
17800
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17791
diff
changeset
|
573 | js->old_length = -1; |
| 5613 | 574 | |
| 7310 | 575 | if(!js->user) { |
|
16961
b6955f946f8f
s/Jabber/XMPP in user-visible places.
Richard Laager <rlaager@pidgin.im>
parents:
16847
diff
changeset
|
576 | purple_connection_error(gc, _("Invalid XMPP ID")); |
| 7310 | 577 | return; |
| 578 | } | |
|
17008
502623177086
Handle people forgetting to enter a domain. Also, change 'server,' in the account options to 'domain,' which is its proper name, and hopefully less confusion
Sean Egan <seanegan@pidgin.im>
parents:
17007
diff
changeset
|
579 | |
|
502623177086
Handle people forgetting to enter a domain. Also, change 'server,' in the account options to 'domain,' which is its proper name, and hopefully less confusion
Sean Egan <seanegan@pidgin.im>
parents:
17007
diff
changeset
|
580 | if (!js->user->domain || *(js->user->domain) == '\0') { |
|
502623177086
Handle people forgetting to enter a domain. Also, change 'server,' in the account options to 'domain,' which is its proper name, and hopefully less confusion
Sean Egan <seanegan@pidgin.im>
parents:
17007
diff
changeset
|
581 | purple_connection_error(gc, _("Invalid XMPP ID. Domain must be set.")); |
|
502623177086
Handle people forgetting to enter a domain. Also, change 'server,' in the account options to 'domain,' which is its proper name, and hopefully less confusion
Sean Egan <seanegan@pidgin.im>
parents:
17007
diff
changeset
|
582 | return; |
|
502623177086
Handle people forgetting to enter a domain. Also, change 'server,' in the account options to 'domain,' which is its proper name, and hopefully less confusion
Sean Egan <seanegan@pidgin.im>
parents:
17007
diff
changeset
|
583 | } |
|
502623177086
Handle people forgetting to enter a domain. Also, change 'server,' in the account options to 'domain,' which is its proper name, and hopefully less confusion
Sean Egan <seanegan@pidgin.im>
parents:
17007
diff
changeset
|
584 | |
| 7147 | 585 | if(!js->user->resource) { |
| 586 | char *me; | |
| 11939 | 587 | js->user->resource = g_strdup("Home"); |
| 7147 | 588 | if(!js->user->node) { |
| 589 | js->user->node = js->user->domain; | |
| 590 | js->user->domain = g_strdup("jabber.org"); | |
| 591 | } | |
| 592 | me = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, | |
| 593 | js->user->resource); | |
| 15884 | 594 | purple_account_set_username(account, me); |
| 7147 | 595 | g_free(me); |
| 7145 | 596 | } |
| 597 | ||
| 15884 | 598 | if((my_jb = jabber_buddy_find(js, purple_account_get_username(account), TRUE))) |
| 10289 | 599 | my_jb->subscription |= JABBER_SUB_BOTH; |
| 600 | ||
| 7014 | 601 | jabber_stream_set_state(js, JABBER_STREAM_CONNECTING); |
| 2956 | 602 | |
| 11387 | 603 | /* if they've got old-ssl mode going, we probably want to ignore SRV lookups */ |
| 15884 | 604 | if(purple_account_get_bool(js->gc->account, "old_ssl", FALSE)) { |
| 605 | if(purple_ssl_is_supported()) { | |
| 606 | js->gsc = purple_ssl_connect(js->gc->account, | |
| 11387 | 607 | connect_server[0] ? connect_server : js->user->domain, |
| 15884 | 608 | purple_account_get_int(account, "port", 5223), jabber_login_callback_ssl, |
| 11387 | 609 | jabber_ssl_connect_failure, js->gc); |
| 7630 | 610 | } else { |
| 15884 | 611 | purple_connection_error(js->gc, _("SSL support unavailable")); |
| 7630 | 612 | } |
| 3311 | 613 | } |
| 3770 | 614 | |
| 11387 | 615 | /* no old-ssl, so if they've specified a connect server, we'll use that, otherwise we'll |
| 616 | * invoke the magic of SRV lookups, to figure out host and port */ | |
| 7014 | 617 | if(!js->gsc) { |
| 11387 | 618 | if(connect_server[0]) { |
| 17052 | 619 | jabber_login_connect(js, js->user->domain, connect_server, purple_account_get_int(account, "port", 5222)); |
| 11387 | 620 | } else { |
| 15884 | 621 | js->srv_query_data = purple_srv_resolve("xmpp-client", |
|
14370
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14358
diff
changeset
|
622 | "tcp", js->user->domain, srv_resolved_cb, js); |
| 11387 | 623 | } |
| 2956 | 624 | } |
| 2086 | 625 | } |
| 626 | ||
| 11387 | 627 | |
| 7072 | 628 | static gboolean |
| 629 | conn_close_cb(gpointer data) | |
| 630 | { | |
| 631 | JabberStream *js = data; | |
| 15884 | 632 | PurpleAccount *account = purple_connection_get_account(js->gc); |
|
17810
c8d4297080cb
Fixed a leak: The XML parser was never cleaned up on disconnect.
Andreas Monitzer <am@adiumx.com>
parents:
17806
diff
changeset
|
633 | |
|
c8d4297080cb
Fixed a leak: The XML parser was never cleaned up on disconnect.
Andreas Monitzer <am@adiumx.com>
parents:
17806
diff
changeset
|
634 | jabber_parser_free(js); |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10504
diff
changeset
|
635 | |
| 15884 | 636 | purple_account_disconnect(account); |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10504
diff
changeset
|
637 | |
| 7072 | 638 | return FALSE; |
| 639 | } | |
| 640 | ||
| 641 | static void | |
| 642 | jabber_connection_schedule_close(JabberStream *js) | |
| 643 | { | |
| 15884 | 644 | purple_timeout_add(0, conn_close_cb, js); |
| 7072 | 645 | } |
| 646 | ||
| 647 | static void | |
| 7395 | 648 | jabber_registration_result_cb(JabberStream *js, xmlnode *packet, gpointer data) |
| 7072 | 649 | { |
|
17814
c47c22006b0d
Implemented a callback for a successful registration, supplying the username and password to the application when available, in the way explained by Sean.
Andreas Monitzer <am@adiumx.com>
parents:
17813
diff
changeset
|
650 | PurpleAccount *account = purple_connection_get_account(js->gc); |
| 7072 | 651 | const char *type = xmlnode_get_attrib(packet, "type"); |
| 652 | char *buf; | |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
653 | char *to = data; |
| 7072 | 654 | |
| 655 | if(!strcmp(type, "result")) { | |
|
17814
c47c22006b0d
Implemented a callback for a successful registration, supplying the username and password to the application when available, in the way explained by Sean.
Andreas Monitzer <am@adiumx.com>
parents:
17813
diff
changeset
|
656 | if(js->registration) { |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
657 | buf = g_strdup_printf(_("Registration of %s@%s successful"), |
| 7072 | 658 | js->user->node, js->user->domain); |
|
17815
232d57a6b6df
Simplified registration callback per request of Sean.
Andreas Monitzer <am@adiumx.com>
parents:
17814
diff
changeset
|
659 | if(account->registration_cb) |
|
232d57a6b6df
Simplified registration callback per request of Sean.
Andreas Monitzer <am@adiumx.com>
parents:
17814
diff
changeset
|
660 | (account->registration_cb)(account, TRUE, account->registration_cb_user_data); |
|
17814
c47c22006b0d
Implemented a callback for a successful registration, supplying the username and password to the application when available, in the way explained by Sean.
Andreas Monitzer <am@adiumx.com>
parents:
17813
diff
changeset
|
661 | } |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
662 | else |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
663 | buf = g_strdup_printf(_("Registration to %s successful"), |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
664 | to); |
| 15884 | 665 | purple_notify_info(NULL, _("Registration Successful"), |
| 7072 | 666 | _("Registration Successful"), buf); |
| 667 | g_free(buf); | |
| 668 | } else { | |
| 8401 | 669 | char *msg = jabber_parse_error(js, packet); |
| 7072 | 670 | |
| 8401 | 671 | if(!msg) |
| 672 | msg = g_strdup(_("Unknown Error")); | |
| 7072 | 673 | |
| 15884 | 674 | purple_notify_error(NULL, _("Registration Failed"), |
| 8401 | 675 | _("Registration Failed"), msg); |
| 676 | g_free(msg); | |
|
17815
232d57a6b6df
Simplified registration callback per request of Sean.
Andreas Monitzer <am@adiumx.com>
parents:
17814
diff
changeset
|
677 | if(account->registration_cb) |
|
232d57a6b6df
Simplified registration callback per request of Sean.
Andreas Monitzer <am@adiumx.com>
parents:
17814
diff
changeset
|
678 | (account->registration_cb)(account, FALSE, account->registration_cb_user_data); |
| 7072 | 679 | } |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
680 | g_free(to); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
681 | if(js->registration) |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
682 | jabber_connection_schedule_close(js); |
| 7072 | 683 | } |
| 684 | ||
|
18755
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
685 | static void |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
686 | jabber_unregistration_result_cb(JabberStream *js, xmlnode *packet, gpointer data) |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
687 | { |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
688 | const char *type = xmlnode_get_attrib(packet, "type"); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
689 | char *buf; |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
690 | char *to = data; |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
691 | |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
692 | if(!strcmp(type, "result")) { |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
693 | buf = g_strdup_printf(_("Registration from %s successfully removed"), |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
694 | to); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
695 | purple_notify_info(NULL, _("Unregistration Successful"), |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
696 | _("Unregistration Successful"), buf); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
697 | g_free(buf); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
698 | } else { |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
699 | char *msg = jabber_parse_error(js, packet); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
700 | |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
701 | if(!msg) |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
702 | msg = g_strdup(_("Unknown Error")); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
703 | |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
704 | purple_notify_error(NULL, _("Unregistration Failed"), |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
705 | _("Unregistration Failed"), msg); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
706 | g_free(msg); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
707 | } |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
708 | g_free(to); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
709 | } |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
710 | |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
711 | typedef struct _JabberRegisterCBData { |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
712 | JabberStream *js; |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
713 | char *who; |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
714 | } JabberRegisterCBData; |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
715 | |
| 7072 | 716 | static void |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
717 | jabber_register_cb(JabberRegisterCBData *cbdata, PurpleRequestFields *fields) |
| 7072 | 718 | { |
| 719 | GList *groups, *flds; | |
| 720 | xmlnode *query, *y; | |
| 721 | JabberIq *iq; | |
| 7264 | 722 | char *username; |
| 7072 | 723 | |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
724 | iq = jabber_iq_new_query(cbdata->js, JABBER_IQ_SET, "jabber:iq:register"); |
| 7072 | 725 | query = xmlnode_get_child(iq->node, "query"); |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
726 | xmlnode_set_attrib(iq->node,"to",cbdata->who); |
| 7072 | 727 | |
| 15884 | 728 | for(groups = purple_request_fields_get_groups(fields); groups; |
| 7072 | 729 | groups = groups->next) { |
| 15884 | 730 | for(flds = purple_request_field_group_get_fields(groups->data); |
| 7072 | 731 | flds; flds = flds->next) { |
| 15884 | 732 | PurpleRequestField *field = flds->data; |
| 733 | const char *id = purple_request_field_get_id(field); | |
|
18755
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
734 | if(!strcmp(id,"unregister")) { |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
735 | gboolean value = purple_request_field_bool_get_value(field); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
736 | if(value) { |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
737 | /* unregister from service. this doesn't include any of the fields, so remove them from the stanza by recreating it |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
738 | (there's no "remove child" function for xmlnode) */ |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
739 | jabber_iq_free(iq); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
740 | iq = jabber_iq_new_query(cbdata->js, JABBER_IQ_SET, "jabber:iq:register"); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
741 | query = xmlnode_get_child(iq->node, "query"); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
742 | xmlnode_set_attrib(iq->node,"to",cbdata->who); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
743 | xmlnode_new_child(query, "remove"); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
744 | |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
745 | jabber_iq_set_callback(iq, jabber_unregistration_result_cb, cbdata->who); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
746 | |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
747 | jabber_iq_send(iq); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
748 | g_free(cbdata); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
749 | return; |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
750 | } |
| 7072 | 751 | } else { |
|
18755
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
752 | const char *value = purple_request_field_string_get_value(field); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
753 | |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
754 | if(!strcmp(id, "username")) { |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
755 | y = xmlnode_new_child(query, "username"); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
756 | } else if(!strcmp(id, "password")) { |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
757 | y = xmlnode_new_child(query, "password"); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
758 | } else if(!strcmp(id, "name")) { |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
759 | y = xmlnode_new_child(query, "name"); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
760 | } else if(!strcmp(id, "email")) { |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
761 | y = xmlnode_new_child(query, "email"); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
762 | } else if(!strcmp(id, "nick")) { |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
763 | y = xmlnode_new_child(query, "nick"); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
764 | } else if(!strcmp(id, "first")) { |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
765 | y = xmlnode_new_child(query, "first"); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
766 | } else if(!strcmp(id, "last")) { |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
767 | y = xmlnode_new_child(query, "last"); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
768 | } else if(!strcmp(id, "address")) { |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
769 | y = xmlnode_new_child(query, "address"); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
770 | } else if(!strcmp(id, "city")) { |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
771 | y = xmlnode_new_child(query, "city"); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
772 | } else if(!strcmp(id, "state")) { |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
773 | y = xmlnode_new_child(query, "state"); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
774 | } else if(!strcmp(id, "zip")) { |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
775 | y = xmlnode_new_child(query, "zip"); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
776 | } else if(!strcmp(id, "phone")) { |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
777 | y = xmlnode_new_child(query, "phone"); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
778 | } else if(!strcmp(id, "url")) { |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
779 | y = xmlnode_new_child(query, "url"); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
780 | } else if(!strcmp(id, "date")) { |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
781 | y = xmlnode_new_child(query, "date"); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
782 | } else { |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
783 | continue; |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
784 | } |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
785 | xmlnode_insert_data(y, value, -1); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
786 | if(cbdata->js->registration && !strcmp(id, "username")) { |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
787 | if(cbdata->js->user->node) |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
788 | g_free(cbdata->js->user->node); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
789 | cbdata->js->user->node = g_strdup(value); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
790 | } |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
791 | if(cbdata->js->registration && !strcmp(id, "password")) |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
792 | purple_account_set_password(cbdata->js->gc->account, value); |
| 7072 | 793 | } |
| 794 | } | |
| 795 | } | |
| 796 | ||
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
797 | if(cbdata->js->registration) { |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
798 | username = g_strdup_printf("%s@%s/%s", cbdata->js->user->node, cbdata->js->user->domain, |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
799 | cbdata->js->user->resource); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
800 | purple_account_set_username(cbdata->js->gc->account, username); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
801 | g_free(username); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
802 | } |
| 7264 | 803 | |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
804 | jabber_iq_set_callback(iq, jabber_registration_result_cb, cbdata->who); |
| 7072 | 805 | |
| 806 | jabber_iq_send(iq); | |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
807 | g_free(cbdata); |
| 7072 | 808 | } |
| 809 | ||
| 810 | static void | |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
811 | jabber_register_cancel_cb(JabberRegisterCBData *cbdata, PurpleRequestFields *fields) |
| 7072 | 812 | { |
|
17814
c47c22006b0d
Implemented a callback for a successful registration, supplying the username and password to the application when available, in the way explained by Sean.
Andreas Monitzer <am@adiumx.com>
parents:
17813
diff
changeset
|
813 | PurpleAccount *account = purple_connection_get_account(cbdata->js->gc); |
|
19894
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
19389
diff
changeset
|
814 | if(account && cbdata->js->registration) { |
|
17814
c47c22006b0d
Implemented a callback for a successful registration, supplying the username and password to the application when available, in the way explained by Sean.
Andreas Monitzer <am@adiumx.com>
parents:
17813
diff
changeset
|
815 | if(account->registration_cb) |
|
17815
232d57a6b6df
Simplified registration callback per request of Sean.
Andreas Monitzer <am@adiumx.com>
parents:
17814
diff
changeset
|
816 | (account->registration_cb)(account, FALSE, account->registration_cb_user_data); |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
817 | jabber_connection_schedule_close(cbdata->js); |
|
17814
c47c22006b0d
Implemented a callback for a successful registration, supplying the username and password to the application when available, in the way explained by Sean.
Andreas Monitzer <am@adiumx.com>
parents:
17813
diff
changeset
|
818 | } |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
819 | g_free(cbdata->who); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
820 | g_free(cbdata); |
| 7072 | 821 | } |
| 822 | ||
| 7923 | 823 | static void jabber_register_x_data_cb(JabberStream *js, xmlnode *result, gpointer data) |
| 824 | { | |
| 825 | xmlnode *query; | |
| 826 | JabberIq *iq; | |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
827 | char *to = data; |
| 7923 | 828 | |
| 829 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register"); | |
| 830 | query = xmlnode_get_child(iq->node, "query"); | |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
831 | xmlnode_set_attrib(iq->node,"to",to); |
| 7923 | 832 | |
| 833 | xmlnode_insert_child(query, result); | |
| 834 | ||
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
835 | jabber_iq_set_callback(iq, jabber_registration_result_cb, to); |
| 7923 | 836 | jabber_iq_send(iq); |
| 837 | } | |
| 838 | ||
| 7072 | 839 | void jabber_register_parse(JabberStream *js, xmlnode *packet) |
| 840 | { | |
|
17814
c47c22006b0d
Implemented a callback for a successful registration, supplying the username and password to the application when available, in the way explained by Sean.
Andreas Monitzer <am@adiumx.com>
parents:
17813
diff
changeset
|
841 | PurpleAccount *account = purple_connection_get_account(js->gc); |
| 14356 | 842 | const char *type; |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
843 | const char *from = xmlnode_get_attrib(packet, "from"); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
844 | PurpleRequestFields *fields; |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
845 | PurpleRequestFieldGroup *group; |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
846 | PurpleRequestField *field; |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
847 | xmlnode *query, *x, *y; |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
848 | char *instructions; |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
849 | JabberRegisterCBData *cbdata; |
|
18755
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
850 | gboolean registered = FALSE; |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
851 | |
| 14356 | 852 | if(!(type = xmlnode_get_attrib(packet, "type")) || strcmp(type, "result")) |
| 853 | return; | |
| 854 | ||
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
855 | if(js->registration) |
| 7072 | 856 | /* get rid of the login thingy */ |
| 15884 | 857 | purple_connection_set_state(js->gc, PURPLE_CONNECTED); |
| 7072 | 858 | |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
859 | query = xmlnode_get_child(packet, "query"); |
| 7072 | 860 | |
|
18755
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
861 | if(xmlnode_get_child(query, "registered")) { |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
862 | registered = TRUE; |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
863 | |
|
17814
c47c22006b0d
Implemented a callback for a successful registration, supplying the username and password to the application when available, in the way explained by Sean.
Andreas Monitzer <am@adiumx.com>
parents:
17813
diff
changeset
|
864 | if(js->registration) { |
|
18755
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
865 | purple_notify_error(NULL, _("Already Registered"), |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
866 | _("Already Registered"), NULL); |
|
17814
c47c22006b0d
Implemented a callback for a successful registration, supplying the username and password to the application when available, in the way explained by Sean.
Andreas Monitzer <am@adiumx.com>
parents:
17813
diff
changeset
|
867 | if(account->registration_cb) |
|
17815
232d57a6b6df
Simplified registration callback per request of Sean.
Andreas Monitzer <am@adiumx.com>
parents:
17814
diff
changeset
|
868 | (account->registration_cb)(account, FALSE, account->registration_cb_user_data); |
| 7072 | 869 | jabber_connection_schedule_close(js); |
|
18755
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
870 | return; |
| 7072 | 871 | } |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
872 | } |
| 7072 | 873 | |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
874 | if((x = xmlnode_get_child_with_namespace(packet, "x", |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
875 | "jabber:x:data"))) { |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
876 | jabber_x_data_request(js, x, jabber_register_x_data_cb, g_strdup(from)); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
877 | return; |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
878 | } else if((x = xmlnode_get_child_with_namespace(packet, "x", |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
879 | "jabber:x:oob"))) { |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
880 | xmlnode *url; |
| 7923 | 881 | |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
882 | if((url = xmlnode_get_child(x, "url"))) { |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
883 | char *href; |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
884 | if((href = xmlnode_get_data(url))) { |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
885 | purple_notify_uri(NULL, href); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
886 | g_free(href); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
887 | if(js->registration) { |
| 8398 | 888 | js->gc->wants_to_die = TRUE; |
|
17814
c47c22006b0d
Implemented a callback for a successful registration, supplying the username and password to the application when available, in the way explained by Sean.
Andreas Monitzer <am@adiumx.com>
parents:
17813
diff
changeset
|
889 | if(account->registration_cb) /* succeeded, but we have no login info */ |
|
17815
232d57a6b6df
Simplified registration callback per request of Sean.
Andreas Monitzer <am@adiumx.com>
parents:
17814
diff
changeset
|
890 | (account->registration_cb)(account, TRUE, account->registration_cb_user_data); |
| 8398 | 891 | jabber_connection_schedule_close(js); |
| 892 | } | |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
893 | return; |
| 7923 | 894 | } |
| 895 | } | |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
896 | } |
| 7923 | 897 | |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
898 | /* as a last resort, use the old jabber:iq:register syntax */ |
| 7923 | 899 | |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
900 | fields = purple_request_fields_new(); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
901 | group = purple_request_field_group_new(NULL); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
902 | purple_request_fields_add_group(fields, group); |
| 7072 | 903 | |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
904 | if(js->registration) |
| 15884 | 905 | field = purple_request_field_string_new("username", _("Username"), |
| 7072 | 906 | js->user->node, FALSE); |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
907 | else |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
908 | field = purple_request_field_string_new("username", _("Username"), |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
909 | NULL, FALSE); |
| 7072 | 910 | |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
911 | purple_request_field_group_add_field(group, field); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
912 | |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
913 | if(js->registration) |
| 15884 | 914 | field = purple_request_field_string_new("password", _("Password"), |
| 915 | purple_connection_get_password(js->gc), FALSE); | |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
916 | else |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
917 | field = purple_request_field_string_new("password", _("Password"), |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
918 | NULL, FALSE); |
| 7072 | 919 | |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
920 | purple_request_field_string_set_masked(field, TRUE); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
921 | purple_request_field_group_add_field(group, field); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
922 | |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
923 | if(xmlnode_get_child(query, "name")) { |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
924 | if(js->registration) |
| 15884 | 925 | field = purple_request_field_string_new("name", _("Name"), |
| 926 | purple_account_get_alias(js->gc->account), FALSE); | |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
927 | else |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
928 | field = purple_request_field_string_new("name", _("Name"), |
| 7072 | 929 | NULL, FALSE); |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
930 | purple_request_field_group_add_field(group, field); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
931 | } |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
932 | if(xmlnode_get_child(query, "email")) { |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
933 | field = purple_request_field_string_new("email", _("E-mail"), |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
934 | NULL, FALSE); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
935 | purple_request_field_group_add_field(group, field); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
936 | } |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
937 | if(xmlnode_get_child(query, "nick")) { |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
938 | field = purple_request_field_string_new("nick", _("Nickname"), |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
939 | NULL, FALSE); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
940 | purple_request_field_group_add_field(group, field); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
941 | } |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
942 | if(xmlnode_get_child(query, "first")) { |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
943 | field = purple_request_field_string_new("first", _("First name"), |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
944 | NULL, FALSE); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
945 | purple_request_field_group_add_field(group, field); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
946 | } |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
947 | if(xmlnode_get_child(query, "last")) { |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
948 | field = purple_request_field_string_new("last", _("Last name"), |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
949 | NULL, FALSE); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
950 | purple_request_field_group_add_field(group, field); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
951 | } |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
952 | if(xmlnode_get_child(query, "address")) { |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
953 | field = purple_request_field_string_new("address", _("Address"), |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
954 | NULL, FALSE); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
955 | purple_request_field_group_add_field(group, field); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
956 | } |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
957 | if(xmlnode_get_child(query, "city")) { |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
958 | field = purple_request_field_string_new("city", _("City"), |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
959 | NULL, FALSE); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
960 | purple_request_field_group_add_field(group, field); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
961 | } |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
962 | if(xmlnode_get_child(query, "state")) { |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
963 | field = purple_request_field_string_new("state", _("State"), |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
964 | NULL, FALSE); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
965 | purple_request_field_group_add_field(group, field); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
966 | } |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
967 | if(xmlnode_get_child(query, "zip")) { |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
968 | field = purple_request_field_string_new("zip", _("Postal code"), |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
969 | NULL, FALSE); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
970 | purple_request_field_group_add_field(group, field); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
971 | } |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
972 | if(xmlnode_get_child(query, "phone")) { |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
973 | field = purple_request_field_string_new("phone", _("Phone"), |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
974 | NULL, FALSE); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
975 | purple_request_field_group_add_field(group, field); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
976 | } |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
977 | if(xmlnode_get_child(query, "url")) { |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
978 | field = purple_request_field_string_new("url", _("URL"), |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
979 | NULL, FALSE); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
980 | purple_request_field_group_add_field(group, field); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
981 | } |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
982 | if(xmlnode_get_child(query, "date")) { |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
983 | field = purple_request_field_string_new("date", _("Date"), |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
984 | NULL, FALSE); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
985 | purple_request_field_group_add_field(group, field); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
986 | } |
|
18755
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
987 | if(registered) { |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
988 | field = purple_request_field_bool_new("unregister", _("Unregister"), FALSE); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
989 | purple_request_field_group_add_field(group, field); |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
990 | } |
| 7072 | 991 | |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
992 | if((y = xmlnode_get_child(query, "instructions"))) |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
993 | instructions = xmlnode_get_data(y); |
|
18755
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
994 | else if(registered) |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
995 | instructions = g_strdup(_("Please fill out the information below " |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
996 | "to change your account registration.")); |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
997 | else |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
998 | instructions = g_strdup(_("Please fill out the information below " |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
999 | "to register your new account.")); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
1000 | |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
1001 | cbdata = g_new0(JabberRegisterCBData, 1); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
1002 | cbdata->js = js; |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
1003 | cbdata->who = g_strdup(from); |
| 7072 | 1004 | |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
1005 | if(js->registration) |
|
16961
b6955f946f8f
s/Jabber/XMPP in user-visible places.
Richard Laager <rlaager@pidgin.im>
parents:
16847
diff
changeset
|
1006 | purple_request_fields(js->gc, _("Register New XMPP Account"), |
|
b6955f946f8f
s/Jabber/XMPP in user-visible places.
Richard Laager <rlaager@pidgin.im>
parents:
16847
diff
changeset
|
1007 | _("Register New XMPP Account"), instructions, fields, |
| 7072 | 1008 | _("Register"), G_CALLBACK(jabber_register_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:
16302
diff
changeset
|
1009 | _("Cancel"), G_CALLBACK(jabber_register_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:
16302
diff
changeset
|
1010 | purple_connection_get_account(js->gc), NULL, NULL, |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
1011 | cbdata); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
1012 | else { |
|
18755
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
1013 | char *title = registered?g_strdup_printf(_("Change Account Registration at %s"), from) |
|
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
1014 | :g_strdup_printf(_("Register New Account at %s"), from); |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
1015 | purple_request_fields(js->gc, title, |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
1016 | title, instructions, fields, |
|
18755
8c4ddce1fb46
Added the ability to unregister from a gateway.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
1017 | registered?_("Change Registration"):_("Register"), G_CALLBACK(jabber_register_cb), |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
1018 | _("Cancel"), G_CALLBACK(jabber_register_cancel_cb), |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
1019 | purple_connection_get_account(js->gc), NULL, NULL, |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
1020 | cbdata); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
1021 | g_free(title); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
1022 | } |
|
14140
fcb570e0b2db
[gaim-migrate @ 16699]
Daniel Atallah <datallah@pidgin.im>
parents:
14115
diff
changeset
|
1023 | |
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
1024 | g_free(instructions); |
| 7072 | 1025 | } |
| 1026 | ||
| 8016 | 1027 | void jabber_register_start(JabberStream *js) |
| 7072 | 1028 | { |
| 1029 | JabberIq *iq; | |
| 1030 | ||
| 1031 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:register"); | |
| 1032 | jabber_iq_send(iq); | |
| 1033 | } | |
| 1034 | ||
|
17806
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
1035 | void jabber_register_gateway(JabberStream *js, const char *gateway) { |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
1036 | JabberIq *iq; |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
1037 | |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
1038 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:register"); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
1039 | xmlnode_set_attrib(iq->node, "to", gateway); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
1040 | jabber_iq_send(iq); |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
1041 | } |
|
ed4647f0915d
Added the ability to register gateways, re-using most of the account registration code for this.
Andreas Monitzer <am@adiumx.com>
parents:
17803
diff
changeset
|
1042 | |
|
16302
eb633ebf84f2
This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
Sean Egan <seanegan@pidgin.im>
parents:
16180
diff
changeset
|
1043 | void jabber_register_account(PurpleAccount *account) |
| 7072 | 1044 | { |
| 15884 | 1045 | PurpleConnection *gc = purple_account_get_connection(account); |
| 7072 | 1046 | JabberStream *js; |
| 10289 | 1047 | JabberBuddy *my_jb = NULL; |
| 15884 | 1048 | const char *connect_server = purple_account_get_string(account, |
| 7072 | 1049 | "connect_server", ""); |
| 1050 | const char *server; | |
| 1051 | ||
| 1052 | js = gc->proto_data = g_new0(JabberStream, 1); | |
| 1053 | js->gc = gc; | |
| 1054 | js->registration = TRUE; | |
| 8312 | 1055 | js->iq_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 1056 | g_free, g_free); | |
| 1057 | js->disco_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, | |
| 7395 | 1058 | g_free, g_free); |
| 15884 | 1059 | js->user = jabber_id_new(purple_account_get_username(account)); |
| 7322 | 1060 | js->next_id = g_random_int(); |
|
17800
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17791
diff
changeset
|
1061 | js->old_length = -1; |
| 7072 | 1062 | |
| 7310 | 1063 | if(!js->user) { |
|
16961
b6955f946f8f
s/Jabber/XMPP in user-visible places.
Richard Laager <rlaager@pidgin.im>
parents:
16847
diff
changeset
|
1064 | purple_connection_error(gc, _("Invalid XMPP ID")); |
| 7310 | 1065 | return; |
| 1066 | } | |
| 1067 | ||
| 15884 | 1068 | js->write_buffer = purple_circ_buffer_new(512); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
1069 | |
| 7147 | 1070 | if(!js->user->resource) { |
| 1071 | char *me; | |
| 11939 | 1072 | js->user->resource = g_strdup("Home"); |
| 7147 | 1073 | if(!js->user->node) { |
| 1074 | js->user->node = js->user->domain; | |
| 1075 | js->user->domain = g_strdup("jabber.org"); | |
| 1076 | } | |
| 1077 | me = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, | |
| 1078 | js->user->resource); | |
| 15884 | 1079 | purple_account_set_username(account, me); |
| 7147 | 1080 | g_free(me); |
| 1081 | } | |
| 1082 | ||
| 15884 | 1083 | if((my_jb = jabber_buddy_find(js, purple_account_get_username(account), TRUE))) |
| 10289 | 1084 | my_jb->subscription |= JABBER_SUB_BOTH; |
| 1085 | ||
| 7072 | 1086 | server = connect_server[0] ? connect_server : js->user->domain; |
| 1087 | ||
| 1088 | jabber_stream_set_state(js, JABBER_STREAM_CONNECTING); | |
| 1089 | ||
| 15884 | 1090 | if(purple_account_get_bool(account, "old_ssl", FALSE)) { |
| 1091 | if(purple_ssl_is_supported()) { | |
| 1092 | js->gsc = purple_ssl_connect(account, server, | |
| 1093 | purple_account_get_int(account, "port", 5222), | |
| 7630 | 1094 | jabber_login_callback_ssl, jabber_ssl_connect_failure, gc); |
| 1095 | } else { | |
| 15884 | 1096 | purple_connection_error(gc, _("SSL support unavailable")); |
| 7630 | 1097 | } |
| 7072 | 1098 | } |
| 1099 | ||
| 1100 | if(!js->gsc) { | |
| 15069 | 1101 | if (connect_server[0]) { |
| 17052 | 1102 | jabber_login_connect(js, js->user->domain, server, |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1103 | purple_account_get_int(account, |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1104 | "port", 5222)); |
| 15069 | 1105 | } else { |
| 15884 | 1106 | js->srv_query_data = purple_srv_resolve("xmpp-client", |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1107 | "tcp", |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1108 | js->user->domain, |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1109 | srv_resolved_cb, |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1110 | js); |
| 15069 | 1111 | } |
| 7072 | 1112 | } |
| 1113 | } | |
| 1114 | ||
|
18912
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1115 | static void jabber_unregister_account_iq_cb(JabberStream *js, xmlnode *packet, gpointer data) { |
|
18994
310e9d853e2b
Implemented a callback for unregistering, mirroring the registration callback. Since this is a new API, I can do it properly by passing it right in the unregister function call, instead of having a separate function for setting it.
Andreas Monitzer <am@adiumx.com>
parents:
18993
diff
changeset
|
1116 | PurpleAccount *account = purple_connection_get_account(js->gc); |
|
18912
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1117 | const char *type = xmlnode_get_attrib(packet,"type"); |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1118 | if(!strcmp(type,"error")) { |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1119 | char *msg = jabber_parse_error(js, packet); |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1120 | |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1121 | purple_notify_error(js->gc, _("Error unregistering account"), |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1122 | _("Error unregistering account"), msg); |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1123 | g_free(msg); |
|
18994
310e9d853e2b
Implemented a callback for unregistering, mirroring the registration callback. Since this is a new API, I can do it properly by passing it right in the unregister function call, instead of having a separate function for setting it.
Andreas Monitzer <am@adiumx.com>
parents:
18993
diff
changeset
|
1124 | if(js->unregistration_cb) |
|
18995
6ba7743720cb
Mixed up TRUE and FALSE.
Andreas Monitzer <am@adiumx.com>
parents:
18994
diff
changeset
|
1125 | js->unregistration_cb(account, FALSE, js->unregistration_user_data); |
|
18912
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1126 | } else if(!strcmp(type,"result")) { |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1127 | purple_notify_info(js->gc, _("Account successfully unregistered"), |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1128 | _("Account successfully unregistered"), NULL); |
|
18994
310e9d853e2b
Implemented a callback for unregistering, mirroring the registration callback. Since this is a new API, I can do it properly by passing it right in the unregister function call, instead of having a separate function for setting it.
Andreas Monitzer <am@adiumx.com>
parents:
18993
diff
changeset
|
1129 | if(js->unregistration_cb) |
|
18995
6ba7743720cb
Mixed up TRUE and FALSE.
Andreas Monitzer <am@adiumx.com>
parents:
18994
diff
changeset
|
1130 | js->unregistration_cb(account, TRUE, js->unregistration_user_data); |
|
18912
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1131 | } |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1132 | } |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1133 | |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1134 | static void jabber_unregister_account_cb(JabberStream *js) { |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1135 | JabberIq *iq; |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1136 | xmlnode *query; |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1137 | assert(js->unregistration); |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1138 | |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1139 | iq = jabber_iq_new_query(js,JABBER_IQ_SET,"jabber:iq:register"); |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1140 | assert(iq); |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1141 | query = xmlnode_get_child_with_namespace(iq->node,"query","jabber:iq:register"); |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1142 | assert(query); |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1143 | xmlnode_new_child(query,"remove"); |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1144 | |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1145 | xmlnode_set_attrib(iq->node,"to",js->user->domain); |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1146 | jabber_iq_set_callback(iq,jabber_unregister_account_iq_cb,NULL); |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1147 | |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1148 | jabber_iq_send(iq); |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1149 | } |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1150 | |
|
18994
310e9d853e2b
Implemented a callback for unregistering, mirroring the registration callback. Since this is a new API, I can do it properly by passing it right in the unregister function call, instead of having a separate function for setting it.
Andreas Monitzer <am@adiumx.com>
parents:
18993
diff
changeset
|
1151 | void jabber_unregister_account(PurpleAccount *account, PurpleAccountUnregistrationCb cb, void *user_data) { |
|
18912
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1152 | PurpleConnection *gc = purple_account_get_connection(account); |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1153 | JabberStream *js; |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1154 | |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1155 | if(gc->state != PURPLE_CONNECTED) { |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1156 | if(gc->state != PURPLE_CONNECTING) |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1157 | jabber_login(account); |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1158 | js = gc->proto_data; |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1159 | js->unregistration = TRUE; |
|
18994
310e9d853e2b
Implemented a callback for unregistering, mirroring the registration callback. Since this is a new API, I can do it properly by passing it right in the unregister function call, instead of having a separate function for setting it.
Andreas Monitzer <am@adiumx.com>
parents:
18993
diff
changeset
|
1160 | js->unregistration_cb = cb; |
|
310e9d853e2b
Implemented a callback for unregistering, mirroring the registration callback. Since this is a new API, I can do it properly by passing it right in the unregister function call, instead of having a separate function for setting it.
Andreas Monitzer <am@adiumx.com>
parents:
18993
diff
changeset
|
1161 | js->unregistration_user_data = user_data; |
|
18912
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1162 | return; |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1163 | } |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1164 | |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1165 | js = gc->proto_data; |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1166 | assert(!js->unregistration); /* don't allow multiple calls */ |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1167 | js->unregistration = TRUE; |
|
18994
310e9d853e2b
Implemented a callback for unregistering, mirroring the registration callback. Since this is a new API, I can do it properly by passing it right in the unregister function call, instead of having a separate function for setting it.
Andreas Monitzer <am@adiumx.com>
parents:
18993
diff
changeset
|
1168 | js->unregistration_cb = cb; |
|
310e9d853e2b
Implemented a callback for unregistering, mirroring the registration callback. Since this is a new API, I can do it properly by passing it right in the unregister function call, instead of having a separate function for setting it.
Andreas Monitzer <am@adiumx.com>
parents:
18993
diff
changeset
|
1169 | js->unregistration_user_data = user_data; |
|
18912
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1170 | |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1171 | jabber_unregister_account_cb(js); |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1172 | } |
|
606597744812
Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
Andreas Monitzer <am@adiumx.com>
parents:
18755
diff
changeset
|
1173 | |
|
16302
eb633ebf84f2
This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
Sean Egan <seanegan@pidgin.im>
parents:
16180
diff
changeset
|
1174 | void jabber_close(PurpleConnection *gc) |
| 2086 | 1175 | { |
| 7014 | 1176 | JabberStream *js = gc->proto_data; |
| 2956 | 1177 | |
| 14004 | 1178 | /* Don't perform any actions on the ssl connection |
| 1179 | * if we were forcibly disconnected because it will crash | |
| 1180 | * on some SSL backends. | |
|
13154
1a93fddf2a9a
[gaim-migrate @ 15516]
Evan Schoenberg <evands@pidgin.im>
parents:
13051
diff
changeset
|
1181 | */ |
|
1a93fddf2a9a
[gaim-migrate @ 15516]
Evan Schoenberg <evands@pidgin.im>
parents:
13051
diff
changeset
|
1182 | if (!gc->disconnect_timeout) |
| 14003 | 1183 | jabber_send_raw(js, "</stream:stream>", -1); |
| 3311 | 1184 | |
|
14370
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14358
diff
changeset
|
1185 | if (js->srv_query_data) |
| 15884 | 1186 | purple_srv_cancel(js->srv_query_data); |
|
14370
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14358
diff
changeset
|
1187 | |
| 7014 | 1188 | if(js->gsc) { |
|
13243
5a127fc7db90
[gaim-migrate @ 15608]
Evan Schoenberg <evands@pidgin.im>
parents:
13238
diff
changeset
|
1189 | #ifdef HAVE_OPENSSL |
|
5a127fc7db90
[gaim-migrate @ 15608]
Evan Schoenberg <evands@pidgin.im>
parents:
13238
diff
changeset
|
1190 | if (!gc->disconnect_timeout) |
| 13385 | 1191 | #endif |
| 15884 | 1192 | purple_ssl_close(js->gsc); |
| 8360 | 1193 | } else if (js->fd > 0) { |
| 7072 | 1194 | if(js->gc->inpa) |
| 15884 | 1195 | purple_input_remove(js->gc->inpa); |
| 7014 | 1196 | close(js->fd); |
| 1197 | } | |
|
15363
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
1198 | |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
1199 | jabber_buddy_remove_all_pending_buddy_info_requests(js); |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
1200 | |
|
17810
c8d4297080cb
Fixed a leak: The XML parser was never cleaned up on disconnect.
Andreas Monitzer <am@adiumx.com>
parents:
17806
diff
changeset
|
1201 | jabber_parser_free(js); |
|
c8d4297080cb
Fixed a leak: The XML parser was never cleaned up on disconnect.
Andreas Monitzer <am@adiumx.com>
parents:
17806
diff
changeset
|
1202 | |
| 8312 | 1203 | if(js->iq_callbacks) |
| 1204 | g_hash_table_destroy(js->iq_callbacks); | |
| 1205 | if(js->disco_callbacks) | |
| 1206 | g_hash_table_destroy(js->disco_callbacks); | |
| 7072 | 1207 | if(js->buddies) |
| 1208 | g_hash_table_destroy(js->buddies); | |
| 1209 | if(js->chats) | |
| 1210 | g_hash_table_destroy(js->chats); | |
| 8043 | 1211 | while(js->chat_servers) { |
| 1212 | g_free(js->chat_servers->data); | |
| 1213 | js->chat_servers = g_list_delete_link(js->chat_servers, js->chat_servers); | |
| 1214 | } | |
| 11675 | 1215 | while(js->user_directories) { |
| 1216 | g_free(js->user_directories->data); | |
| 1217 | js->user_directories = g_list_delete_link(js->user_directories, js->user_directories); | |
| 1218 | } | |
| 7014 | 1219 | if(js->stream_id) |
| 1220 | g_free(js->stream_id); | |
| 7587 | 1221 | if(js->user) |
| 1222 | jabber_id_free(js->user); | |
| 10189 | 1223 | if(js->avatar_hash) |
| 1224 | g_free(js->avatar_hash); | |
| 15884 | 1225 | purple_circ_buffer_destroy(js->write_buffer); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13154
diff
changeset
|
1226 | if(js->writeh) |
| 15884 | 1227 | purple_input_remove(js->writeh); |
| 12508 | 1228 | #ifdef HAVE_CYRUS_SASL |
| 1229 | if(js->sasl) | |
| 1230 | sasl_dispose(&js->sasl); | |
| 1231 | if(js->sasl_mechs) | |
| 1232 | g_string_free(js->sasl_mechs, TRUE); | |
| 1233 | if(js->sasl_cb) | |
| 1234 | g_free(js->sasl_cb); | |
|
17765
04aaa6965b10
Fixed one of the issues in the ssl stuff, allowing CN cert checks for starttls-connections in XMPP.
Andreas Monitzer <am@adiumx.com>
parents:
17052
diff
changeset
|
1235 | #endif |
|
15800
2d0ec4fe2681
pass the correct domain to cyrus sasl (sf patch 1663064)
Nathan Walp <nwalp@pidgin.im>
parents:
15783
diff
changeset
|
1236 | if(js->serverFQDN) |
|
2d0ec4fe2681
pass the correct domain to cyrus sasl (sf patch 1663064)
Nathan Walp <nwalp@pidgin.im>
parents:
15783
diff
changeset
|
1237 | g_free(js->serverFQDN); |
|
17817
8e0f271aab78
The server's ad-hoc commands are now listed in the account's action menu. Note that this requires an additional field in the _PurplePluginAction struct. There's no other way, since there was no way to supply user_data, and dynamically created functions are not supported by C. This should be fine, since that struct is only malloced in purple_plugin_action_new, which is part of the core. Applications have to either pass the struct unmodified, or restore the user_data pointer if the action is recreated when necessary (as is the case in Adium).
Andreas Monitzer <am@adiumx.com>
parents:
17815
diff
changeset
|
1238 | while(js->commands) { |
|
8e0f271aab78
The server's ad-hoc commands are now listed in the account's action menu. Note that this requires an additional field in the _PurplePluginAction struct. There's no other way, since there was no way to supply user_data, and dynamically created functions are not supported by C. This should be fine, since that struct is only malloced in purple_plugin_action_new, which is part of the core. Applications have to either pass the struct unmodified, or restore the user_data pointer if the action is recreated when necessary (as is the case in Adium).
Andreas Monitzer <am@adiumx.com>
parents:
17815
diff
changeset
|
1239 | JabberAdHocCommands *cmd = js->commands->data; |
|
8e0f271aab78
The server's ad-hoc commands are now listed in the account's action menu. Note that this requires an additional field in the _PurplePluginAction struct. There's no other way, since there was no way to supply user_data, and dynamically created functions are not supported by C. This should be fine, since that struct is only malloced in purple_plugin_action_new, which is part of the core. Applications have to either pass the struct unmodified, or restore the user_data pointer if the action is recreated when necessary (as is the case in Adium).
Andreas Monitzer <am@adiumx.com>
parents:
17815
diff
changeset
|
1240 | g_free(cmd->jid); |
|
8e0f271aab78
The server's ad-hoc commands are now listed in the account's action menu. Note that this requires an additional field in the _PurplePluginAction struct. There's no other way, since there was no way to supply user_data, and dynamically created functions are not supported by C. This should be fine, since that struct is only malloced in purple_plugin_action_new, which is part of the core. Applications have to either pass the struct unmodified, or restore the user_data pointer if the action is recreated when necessary (as is the case in Adium).
Andreas Monitzer <am@adiumx.com>
parents:
17815
diff
changeset
|
1241 | g_free(cmd->node); |
| 17827 | 1242 | g_free(cmd->name); |
|
17817
8e0f271aab78
The server's ad-hoc commands are now listed in the account's action menu. Note that this requires an additional field in the _PurplePluginAction struct. There's no other way, since there was no way to supply user_data, and dynamically created functions are not supported by C. This should be fine, since that struct is only malloced in purple_plugin_action_new, which is part of the core. Applications have to either pass the struct unmodified, or restore the user_data pointer if the action is recreated when necessary (as is the case in Adium).
Andreas Monitzer <am@adiumx.com>
parents:
17815
diff
changeset
|
1243 | g_free(cmd); |
|
8e0f271aab78
The server's ad-hoc commands are now listed in the account's action menu. Note that this requires an additional field in the _PurplePluginAction struct. There's no other way, since there was no way to supply user_data, and dynamically created functions are not supported by C. This should be fine, since that struct is only malloced in purple_plugin_action_new, which is part of the core. Applications have to either pass the struct unmodified, or restore the user_data pointer if the action is recreated when necessary (as is the case in Adium).
Andreas Monitzer <am@adiumx.com>
parents:
17815
diff
changeset
|
1244 | js->commands = g_list_delete_link(js->commands, js->commands); |
|
8e0f271aab78
The server's ad-hoc commands are now listed in the account's action menu. Note that this requires an additional field in the _PurplePluginAction struct. There's no other way, since there was no way to supply user_data, and dynamically created functions are not supported by C. This should be fine, since that struct is only malloced in purple_plugin_action_new, which is part of the core. Applications have to either pass the struct unmodified, or restore the user_data pointer if the action is recreated when necessary (as is the case in Adium).
Andreas Monitzer <am@adiumx.com>
parents:
17815
diff
changeset
|
1245 | } |
| 15198 | 1246 | g_free(js->server_name); |
| 15225 | 1247 | g_free(js->gmail_last_time); |
| 1248 | g_free(js->gmail_last_tid); | |
|
17800
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17791
diff
changeset
|
1249 | if(js->old_msg) |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17791
diff
changeset
|
1250 | g_free(js->old_msg); |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17791
diff
changeset
|
1251 | if(js->old_avatarhash) |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17791
diff
changeset
|
1252 | g_free(js->old_avatarhash); |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17791
diff
changeset
|
1253 | if(js->old_artist) |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17791
diff
changeset
|
1254 | g_free(js->old_artist); |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17791
diff
changeset
|
1255 | if(js->old_title) |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17791
diff
changeset
|
1256 | g_free(js->old_title); |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17791
diff
changeset
|
1257 | if(js->old_source) |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17791
diff
changeset
|
1258 | g_free(js->old_source); |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17791
diff
changeset
|
1259 | if(js->old_uri) |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17791
diff
changeset
|
1260 | g_free(js->old_uri); |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17791
diff
changeset
|
1261 | if(js->old_track) |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17791
diff
changeset
|
1262 | g_free(js->old_track); |
|
39a0f9ed0e26
Replaced a clean and simple API with a very weird hack due to vivid request on #pidgin by multiple devs. This avoids the change in PurplePluginProtocolInfo, but requires complicated change tracking in every prpl. The others prpl should add this change tracking, too (since otherwise the status gets changed even though nothing they care about changed), but that's not up to me.
Andreas Monitzer <am@adiumx.com>
parents:
17791
diff
changeset
|
1263 | |
| 7014 | 1264 | g_free(js); |
|
11389
c1e05b75b0b0
[gaim-migrate @ 13617]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11387
diff
changeset
|
1265 | |
|
c1e05b75b0b0
[gaim-migrate @ 13617]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11387
diff
changeset
|
1266 | gc->proto_data = NULL; |
| 5093 | 1267 | } |
| 1268 | ||
| 7014 | 1269 | void jabber_stream_set_state(JabberStream *js, JabberStreamState state) |
|
3105
8c23b0ec1036
[gaim-migrate @ 3119]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3074
diff
changeset
|
1270 | { |
| 7014 | 1271 | js->state = state; |
| 1272 | switch(state) { | |
| 1273 | case JABBER_STREAM_OFFLINE: | |
| 1274 | break; | |
| 1275 | case JABBER_STREAM_CONNECTING: | |
| 15884 | 1276 | purple_connection_update_progress(js->gc, _("Connecting"), 1, |
| 7014 | 1277 | JABBER_CONNECT_STEPS); |
| 1278 | break; | |
| 1279 | case JABBER_STREAM_INITIALIZING: | |
| 15884 | 1280 | purple_connection_update_progress(js->gc, _("Initializing Stream"), |
| 7014 | 1281 | js->gsc ? 5 : 2, JABBER_CONNECT_STEPS); |
| 1282 | jabber_stream_init(js); | |
| 1283 | break; | |
|
17813
c5cc8ebf62c0
Introduced an additional connection stage to the jabber connection progress in order to be able to tell in the application, whether SSL/TLS is enabled, so it can display a lock icon next to the connection.
Andreas Monitzer <am@adiumx.com>
parents:
17810
diff
changeset
|
1284 | case JABBER_STREAM_INITIALIZING_ENCRYPTION: |
|
c5cc8ebf62c0
Introduced an additional connection stage to the jabber connection progress in order to be able to tell in the application, whether SSL/TLS is enabled, so it can display a lock icon next to the connection.
Andreas Monitzer <am@adiumx.com>
parents:
17810
diff
changeset
|
1285 | purple_connection_update_progress(js->gc, _("Initializing SSL/TLS"), |
|
c5cc8ebf62c0
Introduced an additional connection stage to the jabber connection progress in order to be able to tell in the application, whether SSL/TLS is enabled, so it can display a lock icon next to the connection.
Andreas Monitzer <am@adiumx.com>
parents:
17810
diff
changeset
|
1286 | 6, JABBER_CONNECT_STEPS); |
|
c5cc8ebf62c0
Introduced an additional connection stage to the jabber connection progress in order to be able to tell in the application, whether SSL/TLS is enabled, so it can display a lock icon next to the connection.
Andreas Monitzer <am@adiumx.com>
parents:
17810
diff
changeset
|
1287 | break; |
| 7014 | 1288 | case JABBER_STREAM_AUTHENTICATING: |
| 15884 | 1289 | purple_connection_update_progress(js->gc, _("Authenticating"), |
|
17813
c5cc8ebf62c0
Introduced an additional connection stage to the jabber connection progress in order to be able to tell in the application, whether SSL/TLS is enabled, so it can display a lock icon next to the connection.
Andreas Monitzer <am@adiumx.com>
parents:
17810
diff
changeset
|
1290 | js->gsc ? 7 : 3, JABBER_CONNECT_STEPS); |
| 8296 | 1291 | if(js->protocol_version == JABBER_PROTO_0_9 && js->registration) { |
| 1292 | jabber_register_start(js); | |
| 1293 | } else if(js->auth_type == JABBER_AUTH_IQ_AUTH) { | |
| 1294 | jabber_auth_start_old(js); | |
| 8016 | 1295 | } |
| 7014 | 1296 | break; |
| 1297 | case JABBER_STREAM_REINITIALIZING: | |
| 15884 | 1298 | purple_connection_update_progress(js->gc, _("Re-initializing Stream"), |
|
17813
c5cc8ebf62c0
Introduced an additional connection stage to the jabber connection progress in order to be able to tell in the application, whether SSL/TLS is enabled, so it can display a lock icon next to the connection.
Andreas Monitzer <am@adiumx.com>
parents:
17810
diff
changeset
|
1299 | (js->gsc ? 8 : 4), JABBER_CONNECT_STEPS); |
|
16847
cd87fc9c6856
this should fix jabber buddy icons (but it will re-introduce the behavior of overwriting your vCard whenever you sign in).
Nathan Walp <nwalp@pidgin.im>
parents:
16799
diff
changeset
|
1300 | |
| 14700 | 1301 | /* The stream will be reinitialized later, in jabber_recv_cb_ssl() */ |
| 1302 | js->reinit = TRUE; | |
|
16847
cd87fc9c6856
this should fix jabber buddy icons (but it will re-introduce the behavior of overwriting your vCard whenever you sign in).
Nathan Walp <nwalp@pidgin.im>
parents:
16799
diff
changeset
|
1303 | |
| 7014 | 1304 | break; |
| 1305 | case JABBER_STREAM_CONNECTED: | |
|
16847
cd87fc9c6856
this should fix jabber buddy icons (but it will re-introduce the behavior of overwriting your vCard whenever you sign in).
Nathan Walp <nwalp@pidgin.im>
parents:
16799
diff
changeset
|
1306 | /* now we can alert the core that we're ready to send status */ |
| 15884 | 1307 | purple_connection_set_state(js->gc, PURPLE_CONNECTED); |
| 8312 | 1308 | jabber_disco_items_server(js); |
| 7014 | 1309 | break; |
|
3105
8c23b0ec1036
[gaim-migrate @ 3119]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3074
diff
changeset
|
1310 | } |
|
8c23b0ec1036
[gaim-migrate @ 3119]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3074
diff
changeset
|
1311 | } |
|
8c23b0ec1036
[gaim-migrate @ 3119]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3074
diff
changeset
|
1312 | |
| 7014 | 1313 | char *jabber_get_next_id(JabberStream *js) |
| 2086 | 1314 | { |
| 15884 | 1315 | return g_strdup_printf("purple%x", js->next_id++); |
| 2086 | 1316 | } |
| 1317 | ||
|
14453
1cc75906700c
[gaim-migrate @ 17098]
Mark Doliner <markdoliner@pidgin.im>
parents:
14375
diff
changeset
|
1318 | |
|
16302
eb633ebf84f2
This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
Sean Egan <seanegan@pidgin.im>
parents:
16180
diff
changeset
|
1319 | void jabber_idle_set(PurpleConnection *gc, int idle) |
|
3340
7e59a209931d
[gaim-migrate @ 3359]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3337
diff
changeset
|
1320 | { |
| 7014 | 1321 | JabberStream *js = gc->proto_data; |
|
3340
7e59a209931d
[gaim-migrate @ 3359]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3337
diff
changeset
|
1322 | |
| 7014 | 1323 | js->idle = idle ? time(NULL) - idle : idle; |
|
3314
12fa45677717
[gaim-migrate @ 3332]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3311
diff
changeset
|
1324 | } |
|
12fa45677717
[gaim-migrate @ 3332]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3311
diff
changeset
|
1325 | |
|
17783
2687df1ca202
PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents:
17782
diff
changeset
|
1326 | void jabber_add_feature(const char *shortname, const char *namespace, JabberFeatureEnabled cb) { |
|
2687df1ca202
PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents:
17782
diff
changeset
|
1327 | JabberFeature *feat; |
|
2687df1ca202
PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents:
17782
diff
changeset
|
1328 | |
|
2687df1ca202
PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents:
17782
diff
changeset
|
1329 | assert(shortname != NULL); |
|
2687df1ca202
PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents:
17782
diff
changeset
|
1330 | assert(namespace != NULL); |
|
2687df1ca202
PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents:
17782
diff
changeset
|
1331 | |
|
2687df1ca202
PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents:
17782
diff
changeset
|
1332 | feat = g_new0(JabberFeature,1); |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1333 | feat->shortname = g_strdup(shortname); |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1334 | feat->namespace = g_strdup(namespace); |
|
17783
2687df1ca202
PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents:
17782
diff
changeset
|
1335 | feat->is_enabled = cb; |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1336 | |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1337 | /* try to remove just in case it already exists in the list */ |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1338 | jabber_remove_feature(shortname); |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1339 | |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1340 | jabber_features = g_list_append(jabber_features, feat); |
|
17770
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17769
diff
changeset
|
1341 | } |
|
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17769
diff
changeset
|
1342 | |
|
17773
6956b763b3d1
Implemented adding callbacks for PEP events. Moved the feature list to be application-global instead of per-connection (makes more sense).
Andreas Monitzer <am@adiumx.com>
parents:
17770
diff
changeset
|
1343 | void jabber_remove_feature(const char *shortname) { |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1344 | GList *feature; |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1345 | for(feature = jabber_features; feature; feature = feature->next) { |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1346 | JabberFeature *feat = (JabberFeature*)feature->data; |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1347 | if(!strcmp(feat->shortname, shortname)) { |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1348 | g_free(feat->shortname); |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1349 | g_free(feat->namespace); |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1350 | |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1351 | g_free(feature->data); |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1352 | feature = g_list_delete_link(feature, feature); |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1353 | break; |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1354 | } |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1355 | } |
|
17770
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17769
diff
changeset
|
1356 | } |
|
e67998927a3c
Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents:
17769
diff
changeset
|
1357 | |
|
16302
eb633ebf84f2
This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
Sean Egan <seanegan@pidgin.im>
parents:
16180
diff
changeset
|
1358 | const char *jabber_list_icon(PurpleAccount *a, PurpleBuddy *b) |
| 2086 | 1359 | { |
| 4687 | 1360 | return "jabber"; |
| 1361 | } | |
| 4916 | 1362 | |
|
16302
eb633ebf84f2
This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
Sean Egan <seanegan@pidgin.im>
parents:
16180
diff
changeset
|
1363 | const char* jabber_list_emblem(PurpleBuddy *b) |
| 4916 | 1364 | { |
| 7014 | 1365 | JabberStream *js; |
|
13486
4ea1a712aaa3
[gaim-migrate @ 15861]
Daniel Atallah <datallah@pidgin.im>
parents:
13385
diff
changeset
|
1366 | JabberBuddy *jb = NULL; |
| 7014 | 1367 | |
| 1368 | if(!b->account->gc) | |
|
15558
6fb7a0ad8a0b
clean up some compile warnings
Nathan Walp <nwalp@pidgin.im>
parents:
15524
diff
changeset
|
1369 | return NULL; |
|
6fb7a0ad8a0b
clean up some compile warnings
Nathan Walp <nwalp@pidgin.im>
parents:
15524
diff
changeset
|
1370 | |
| 7014 | 1371 | js = b->account->gc->proto_data; |
|
13486
4ea1a712aaa3
[gaim-migrate @ 15861]
Daniel Atallah <datallah@pidgin.im>
parents:
13385
diff
changeset
|
1372 | if(js) |
|
4ea1a712aaa3
[gaim-migrate @ 15861]
Daniel Atallah <datallah@pidgin.im>
parents:
13385
diff
changeset
|
1373 | jb = jabber_buddy_find(js, b->name, FALSE); |
| 5135 | 1374 | |
| 15884 | 1375 | if(!PURPLE_BUDDY_IS_ONLINE(b)) { |
| 7014 | 1376 | if(jb && (jb->subscription & JABBER_SUB_PENDING || |
| 1377 | !(jb->subscription & JABBER_SUB_TO))) | |
| 15524 | 1378 | return "not-authorized"; |
| 2086 | 1379 | } |
| 15524 | 1380 | return NULL; |
| 4916 | 1381 | } |
| 2086 | 1382 | |
|
16302
eb633ebf84f2
This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
Sean Egan <seanegan@pidgin.im>
parents:
16180
diff
changeset
|
1383 | char *jabber_status_text(PurpleBuddy *b) |
|
2205
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2170
diff
changeset
|
1384 | { |
| 7014 | 1385 | char *ret = NULL; |
|
18310
dbc5240f6bf5
Fix a crash when you have an IM window open on a jabber account and the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18235
diff
changeset
|
1386 | JabberBuddy *jb = NULL; |
|
dbc5240f6bf5
Fix a crash when you have an IM window open on a jabber account and the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18235
diff
changeset
|
1387 | |
|
dbc5240f6bf5
Fix a crash when you have an IM window open on a jabber account and the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18235
diff
changeset
|
1388 | if (b->account->gc && b->account->gc->proto_data) |
|
dbc5240f6bf5
Fix a crash when you have an IM window open on a jabber account and the
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18235
diff
changeset
|
1389 | jb = jabber_buddy_find(b->account->gc->proto_data, b->name, FALSE); |
| 5234 | 1390 | |
| 15884 | 1391 | if(jb && !PURPLE_BUDDY_IS_ONLINE(b) && (jb->subscription & JABBER_SUB_PENDING || !(jb->subscription & JABBER_SUB_TO))) { |
| 7014 | 1392 | ret = g_strdup(_("Not Authorized")); |
| 15884 | 1393 | } else if(jb && !PURPLE_BUDDY_IS_ONLINE(b) && jb->error_msg) { |
| 7014 | 1394 | ret = g_strdup(jb->error_msg); |
| 2956 | 1395 | } else { |
|
7095
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
1396 | char *stripped; |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
1397 | |
| 15884 | 1398 | if(!(stripped = purple_markup_strip_html(jabber_buddy_get_status_msg(jb)))) { |
| 1399 | PurpleStatus *status = purple_presence_get_active_status(purple_buddy_get_presence(b)); | |
| 2956 | 1400 | |
| 15884 | 1401 | if(!purple_status_is_available(status)) |
| 1402 | stripped = g_strdup(purple_status_get_name(status)); | |
| 9954 | 1403 | } |
| 2086 | 1404 | |
| 7014 | 1405 | if(stripped) { |
| 1406 | ret = g_markup_escape_text(stripped, -1); | |
| 1407 | g_free(stripped); | |
| 1408 | } | |
| 2086 | 1409 | } |
| 1410 | ||
| 7014 | 1411 | return ret; |
| 2956 | 1412 | } |
| 1413 | ||
|
16302
eb633ebf84f2
This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
Sean Egan <seanegan@pidgin.im>
parents:
16180
diff
changeset
|
1414 | void jabber_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) |
| 4744 | 1415 | { |
| 11609 | 1416 | JabberBuddy *jb; |
| 1417 | ||
|
12970
c2f3b4dcf711
[gaim-migrate @ 15323]
Richard Laager <rlaager@pidgin.im>
parents:
12948
diff
changeset
|
1418 | g_return_if_fail(b != NULL); |
|
c2f3b4dcf711
[gaim-migrate @ 15323]
Richard Laager <rlaager@pidgin.im>
parents:
12948
diff
changeset
|
1419 | g_return_if_fail(b->account != NULL); |
|
c2f3b4dcf711
[gaim-migrate @ 15323]
Richard Laager <rlaager@pidgin.im>
parents:
12948
diff
changeset
|
1420 | g_return_if_fail(b->account->gc != NULL); |
|
c2f3b4dcf711
[gaim-migrate @ 15323]
Richard Laager <rlaager@pidgin.im>
parents:
12948
diff
changeset
|
1421 | g_return_if_fail(b->account->gc->proto_data != NULL); |
| 11609 | 1422 | |
| 1423 | jb = jabber_buddy_find(b->account->gc->proto_data, b->name, | |
| 7014 | 1424 | FALSE); |
| 1425 | ||
| 8194 | 1426 | if(jb) { |
| 11609 | 1427 | JabberBuddyResource *jbr = NULL; |
| 8194 | 1428 | const char *sub; |
| 11609 | 1429 | GList *l; |
| 1430 | ||
|
12948
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12944
diff
changeset
|
1431 | if (full) { |
|
17780
749862fd4a87
Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <am@adiumx.com>
parents:
17779
diff
changeset
|
1432 | PurpleStatus *status; |
|
749862fd4a87
Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <am@adiumx.com>
parents:
17779
diff
changeset
|
1433 | PurpleValue *value; |
|
749862fd4a87
Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <am@adiumx.com>
parents:
17779
diff
changeset
|
1434 | |
|
12948
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12944
diff
changeset
|
1435 | if(jb->subscription & JABBER_SUB_FROM) { |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12944
diff
changeset
|
1436 | if(jb->subscription & JABBER_SUB_TO) |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12944
diff
changeset
|
1437 | sub = _("Both"); |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12944
diff
changeset
|
1438 | else if(jb->subscription & JABBER_SUB_PENDING) |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12944
diff
changeset
|
1439 | sub = _("From (To pending)"); |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12944
diff
changeset
|
1440 | else |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12944
diff
changeset
|
1441 | sub = _("From"); |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12944
diff
changeset
|
1442 | } else { |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12944
diff
changeset
|
1443 | if(jb->subscription & JABBER_SUB_TO) |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12944
diff
changeset
|
1444 | sub = _("To"); |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12944
diff
changeset
|
1445 | else if(jb->subscription & JABBER_SUB_PENDING) |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12944
diff
changeset
|
1446 | sub = _("None (To pending)"); |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12944
diff
changeset
|
1447 | else |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12944
diff
changeset
|
1448 | sub = _("None"); |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12944
diff
changeset
|
1449 | } |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
15198
diff
changeset
|
1450 | |
| 15884 | 1451 | purple_notify_user_info_add_pair(user_info, _("Subscription"), sub); |
|
17780
749862fd4a87
Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <am@adiumx.com>
parents:
17779
diff
changeset
|
1452 | |
|
749862fd4a87
Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <am@adiumx.com>
parents:
17779
diff
changeset
|
1453 | status = purple_presence_get_active_status(purple_buddy_get_presence(b)); |
|
749862fd4a87
Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <am@adiumx.com>
parents:
17779
diff
changeset
|
1454 | value = purple_status_get_attr_value(status, "mood"); |
|
749862fd4a87
Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <am@adiumx.com>
parents:
17779
diff
changeset
|
1455 | if(value && purple_value_get_type(value) == PURPLE_TYPE_STRING) { |
|
749862fd4a87
Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <am@adiumx.com>
parents:
17779
diff
changeset
|
1456 | const char *mood = purple_value_get_string(value); |
|
749862fd4a87
Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <am@adiumx.com>
parents:
17779
diff
changeset
|
1457 | |
|
749862fd4a87
Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <am@adiumx.com>
parents:
17779
diff
changeset
|
1458 | value = purple_status_get_attr_value(status, "moodtext"); |
|
749862fd4a87
Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <am@adiumx.com>
parents:
17779
diff
changeset
|
1459 | if(value && purple_value_get_type(value) == PURPLE_TYPE_STRING) { |
|
749862fd4a87
Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <am@adiumx.com>
parents:
17779
diff
changeset
|
1460 | char *moodplustext = g_strdup_printf("%s (%s)",mood,purple_value_get_string(value)); |
|
749862fd4a87
Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <am@adiumx.com>
parents:
17779
diff
changeset
|
1461 | |
|
749862fd4a87
Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <am@adiumx.com>
parents:
17779
diff
changeset
|
1462 | purple_notify_user_info_add_pair(user_info, _("Mood"), moodplustext); |
|
749862fd4a87
Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <am@adiumx.com>
parents:
17779
diff
changeset
|
1463 | g_free(moodplustext); |
|
749862fd4a87
Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <am@adiumx.com>
parents:
17779
diff
changeset
|
1464 | } else |
|
749862fd4a87
Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <am@adiumx.com>
parents:
17779
diff
changeset
|
1465 | purple_notify_user_info_add_pair(user_info, _("Mood"), mood); |
|
749862fd4a87
Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <am@adiumx.com>
parents:
17779
diff
changeset
|
1466 | } |
| 8194 | 1467 | } |
| 1468 | ||
| 11609 | 1469 | for(l=jb->resources; l; l = l->next) { |
| 8194 | 1470 | char *text = NULL; |
| 11609 | 1471 | char *res = NULL; |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
15198
diff
changeset
|
1472 | char *label, *value; |
|
12944
da8f60d43d88
[gaim-migrate @ 15297]
Richard Laager <rlaager@pidgin.im>
parents:
12943
diff
changeset
|
1473 | const char *state; |
| 11609 | 1474 | |
| 1475 | jbr = l->data; | |
| 1476 | ||
| 8194 | 1477 | if(jbr->status) { |
| 11646 | 1478 | char *tmp; |
| 15884 | 1479 | text = purple_strreplace(jbr->status, "\n", "<br />\n"); |
| 1480 | tmp = purple_markup_strip_html(text); | |
| 11646 | 1481 | g_free(text); |
| 1482 | text = g_markup_escape_text(tmp, -1); | |
| 1483 | g_free(tmp); | |
| 8194 | 1484 | } |
| 1485 | ||
| 11609 | 1486 | if(jbr->name) |
| 11610 | 1487 | res = g_strdup_printf(" (%s)", jbr->name); |
| 11609 | 1488 | |
|
12944
da8f60d43d88
[gaim-migrate @ 15297]
Richard Laager <rlaager@pidgin.im>
parents:
12943
diff
changeset
|
1489 | state = jabber_buddy_state_get_name(jbr->state); |
| 15884 | 1490 | if (text != NULL && !purple_utf8_strcasecmp(state, text)) { |
|
12944
da8f60d43d88
[gaim-migrate @ 15297]
Richard Laager <rlaager@pidgin.im>
parents:
12943
diff
changeset
|
1491 | g_free(text); |
|
da8f60d43d88
[gaim-migrate @ 15297]
Richard Laager <rlaager@pidgin.im>
parents:
12943
diff
changeset
|
1492 | text = NULL; |
|
da8f60d43d88
[gaim-migrate @ 15297]
Richard Laager <rlaager@pidgin.im>
parents:
12943
diff
changeset
|
1493 | } |
|
da8f60d43d88
[gaim-migrate @ 15297]
Richard Laager <rlaager@pidgin.im>
parents:
12943
diff
changeset
|
1494 | |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
15198
diff
changeset
|
1495 | label = g_strdup_printf("%s%s", |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
15198
diff
changeset
|
1496 | _("Status"), (res ? res : "")); |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
15198
diff
changeset
|
1497 | value = g_strdup_printf("%s%s%s", |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
15198
diff
changeset
|
1498 | state, |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
15198
diff
changeset
|
1499 | (text ? ": " : ""), |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
15198
diff
changeset
|
1500 | (text ? text : "")); |
|
12944
da8f60d43d88
[gaim-migrate @ 15297]
Richard Laager <rlaager@pidgin.im>
parents:
12943
diff
changeset
|
1501 | |
| 15884 | 1502 | purple_notify_user_info_add_pair(user_info, label, value); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
15198
diff
changeset
|
1503 | |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
15198
diff
changeset
|
1504 | g_free(label); |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
15198
diff
changeset
|
1505 | g_free(value); |
|
12944
da8f60d43d88
[gaim-migrate @ 15297]
Richard Laager <rlaager@pidgin.im>
parents:
12943
diff
changeset
|
1506 | g_free(text); |
|
da8f60d43d88
[gaim-migrate @ 15297]
Richard Laager <rlaager@pidgin.im>
parents:
12943
diff
changeset
|
1507 | g_free(res); |
| 11609 | 1508 | } |
| 1509 | ||
| 15884 | 1510 | if(!PURPLE_BUDDY_IS_ONLINE(b) && jb->error_msg) { |
| 1511 | purple_notify_user_info_add_pair(user_info, _("Error"), jb->error_msg); | |
| 8194 | 1512 | } |
| 4745 | 1513 | } |
| 4732 | 1514 | } |
| 1515 | ||
|
16302
eb633ebf84f2
This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
Sean Egan <seanegan@pidgin.im>
parents:
16180
diff
changeset
|
1516 | GList *jabber_status_types(PurpleAccount *account) |
| 7014 | 1517 | { |
| 15884 | 1518 | PurpleStatusType *type; |
| 9954 | 1519 | GList *types = NULL; |
| 15884 | 1520 | PurpleValue *priority_value; |
| 9954 | 1521 | |
| 15884 | 1522 | priority_value = purple_value_new(PURPLE_TYPE_INT); |
| 1523 | purple_value_set_int(priority_value, 1); | |
| 1524 | type = purple_status_type_new_with_attrs(PURPLE_STATUS_AVAILABLE, | |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1525 | jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_ONLINE), |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1526 | NULL, TRUE, TRUE, FALSE, |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1527 | "priority", _("Priority"), priority_value, |
| 15884 | 1528 | "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1529 | "mood", _("Mood"), purple_value_new(PURPLE_TYPE_STRING), |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1530 | "moodtext", _("Mood Text"), purple_value_new(PURPLE_TYPE_STRING), |
|
17791
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1531 | "tune_artist", _("Tune Artist"), purple_value_new(PURPLE_TYPE_STRING), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1532 | "tune_title", _("Tune Title"), purple_value_new(PURPLE_TYPE_STRING), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1533 | "tune_album", _("Tune Album"), purple_value_new(PURPLE_TYPE_STRING), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1534 | "tune_genre", _("Tune Genre"), purple_value_new(PURPLE_TYPE_STRING), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1535 | "tune_comment", _("Tune Comment"), purple_value_new(PURPLE_TYPE_STRING), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1536 | "tune_track", _("Tune Track"), purple_value_new(PURPLE_TYPE_STRING), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1537 | "tune_time", _("Tune Time"), purple_value_new(PURPLE_TYPE_INT), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1538 | "tune_year", _("Tune Year"), purple_value_new(PURPLE_TYPE_INT), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1539 | "tune_url", _("Tune URL"), purple_value_new(PURPLE_TYPE_STRING), |
|
17803
882abe4d932e
Implemented XEP-0172: User Nickname, fixed some potential crashers in the other PEP callbacks.
Andreas Monitzer <am@adiumx.com>
parents:
17800
diff
changeset
|
1540 | "nick", _("Nickname"), purple_value_new(PURPLE_TYPE_STRING), |
|
17824
52683dfc1f7d
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <am@adiumx.com>
parents:
17823
diff
changeset
|
1541 | "buzz", _("Allow Buzz"), purple_value_new(PURPLE_TYPE_BOOLEAN), |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1542 | NULL); |
| 9980 | 1543 | types = g_list_append(types, type); |
| 1544 | ||
| 15884 | 1545 | priority_value = purple_value_new(PURPLE_TYPE_INT); |
| 1546 | purple_value_set_int(priority_value, 1); | |
| 1547 | type = purple_status_type_new_with_attrs(PURPLE_STATUS_AVAILABLE, | |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1548 | jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_CHAT), |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1549 | _("Chatty"), TRUE, TRUE, FALSE, |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1550 | "priority", _("Priority"), priority_value, |
| 15884 | 1551 | "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1552 | "mood", _("Mood"), purple_value_new(PURPLE_TYPE_STRING), |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1553 | "moodtext", _("Mood Text"), purple_value_new(PURPLE_TYPE_STRING), |
|
17791
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1554 | "tune_artist", _("Tune Artist"), purple_value_new(PURPLE_TYPE_STRING), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1555 | "tune_title", _("Tune Title"), purple_value_new(PURPLE_TYPE_STRING), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1556 | "tune_album", _("Tune Album"), purple_value_new(PURPLE_TYPE_STRING), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1557 | "tune_genre", _("Tune Genre"), purple_value_new(PURPLE_TYPE_STRING), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1558 | "tune_comment", _("Tune Comment"), purple_value_new(PURPLE_TYPE_STRING), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1559 | "tune_track", _("Tune Track"), purple_value_new(PURPLE_TYPE_STRING), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1560 | "tune_time", _("Tune Time"), purple_value_new(PURPLE_TYPE_INT), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1561 | "tune_year", _("Tune Year"), purple_value_new(PURPLE_TYPE_INT), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1562 | "tune_url", _("Tune URL"), purple_value_new(PURPLE_TYPE_STRING), |
|
17803
882abe4d932e
Implemented XEP-0172: User Nickname, fixed some potential crashers in the other PEP callbacks.
Andreas Monitzer <am@adiumx.com>
parents:
17800
diff
changeset
|
1563 | "nick", _("Nickname"), purple_value_new(PURPLE_TYPE_STRING), |
|
17824
52683dfc1f7d
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <am@adiumx.com>
parents:
17823
diff
changeset
|
1564 | "buzz", _("Allow Buzz"), purple_value_new(PURPLE_TYPE_BOOLEAN), |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1565 | NULL); |
| 9954 | 1566 | types = g_list_append(types, type); |
| 2086 | 1567 | |
| 15884 | 1568 | priority_value = purple_value_new(PURPLE_TYPE_INT); |
| 1569 | purple_value_set_int(priority_value, 0); | |
| 1570 | type = purple_status_type_new_with_attrs(PURPLE_STATUS_AWAY, | |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1571 | jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_AWAY), |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1572 | NULL, TRUE, TRUE, FALSE, |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1573 | "priority", _("Priority"), priority_value, |
| 15884 | 1574 | "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1575 | "mood", _("Mood"), purple_value_new(PURPLE_TYPE_STRING), |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1576 | "moodtext", _("Mood Text"), purple_value_new(PURPLE_TYPE_STRING), |
|
17791
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1577 | "tune_artist", _("Tune Artist"), purple_value_new(PURPLE_TYPE_STRING), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1578 | "tune_title", _("Tune Title"), purple_value_new(PURPLE_TYPE_STRING), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1579 | "tune_album", _("Tune Album"), purple_value_new(PURPLE_TYPE_STRING), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1580 | "tune_genre", _("Tune Genre"), purple_value_new(PURPLE_TYPE_STRING), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1581 | "tune_comment", _("Tune Comment"), purple_value_new(PURPLE_TYPE_STRING), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1582 | "tune_track", _("Tune Track"), purple_value_new(PURPLE_TYPE_STRING), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1583 | "tune_time", _("Tune Time"), purple_value_new(PURPLE_TYPE_INT), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1584 | "tune_year", _("Tune Year"), purple_value_new(PURPLE_TYPE_INT), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1585 | "tune_url", _("Tune URL"), purple_value_new(PURPLE_TYPE_STRING), |
|
17803
882abe4d932e
Implemented XEP-0172: User Nickname, fixed some potential crashers in the other PEP callbacks.
Andreas Monitzer <am@adiumx.com>
parents:
17800
diff
changeset
|
1586 | "nick", _("Nickname"), purple_value_new(PURPLE_TYPE_STRING), |
|
17824
52683dfc1f7d
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <am@adiumx.com>
parents:
17823
diff
changeset
|
1587 | "buzz", _("Allow Buzz"), purple_value_new(PURPLE_TYPE_BOOLEAN), |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1588 | NULL); |
| 9954 | 1589 | types = g_list_append(types, type); |
| 1590 | ||
| 15884 | 1591 | priority_value = purple_value_new(PURPLE_TYPE_INT); |
| 1592 | purple_value_set_int(priority_value, 0); | |
| 1593 | type = purple_status_type_new_with_attrs(PURPLE_STATUS_EXTENDED_AWAY, | |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1594 | jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_XA), |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1595 | NULL, TRUE, TRUE, FALSE, |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1596 | "priority", _("Priority"), priority_value, |
| 15884 | 1597 | "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1598 | "mood", _("Mood"), purple_value_new(PURPLE_TYPE_STRING), |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1599 | "moodtext", _("Mood Text"), purple_value_new(PURPLE_TYPE_STRING), |
|
17791
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1600 | "tune_artist", _("Tune Artist"), purple_value_new(PURPLE_TYPE_STRING), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1601 | "tune_title", _("Tune Title"), purple_value_new(PURPLE_TYPE_STRING), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1602 | "tune_album", _("Tune Album"), purple_value_new(PURPLE_TYPE_STRING), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1603 | "tune_genre", _("Tune Genre"), purple_value_new(PURPLE_TYPE_STRING), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1604 | "tune_comment", _("Tune Comment"), purple_value_new(PURPLE_TYPE_STRING), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1605 | "tune_track", _("Tune Track"), purple_value_new(PURPLE_TYPE_STRING), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1606 | "tune_time", _("Tune Time"), purple_value_new(PURPLE_TYPE_INT), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1607 | "tune_year", _("Tune Year"), purple_value_new(PURPLE_TYPE_INT), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1608 | "tune_url", _("Tune URL"), purple_value_new(PURPLE_TYPE_STRING), |
|
17803
882abe4d932e
Implemented XEP-0172: User Nickname, fixed some potential crashers in the other PEP callbacks.
Andreas Monitzer <am@adiumx.com>
parents:
17800
diff
changeset
|
1609 | "nick", _("Nickname"), purple_value_new(PURPLE_TYPE_STRING), |
|
17824
52683dfc1f7d
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <am@adiumx.com>
parents:
17823
diff
changeset
|
1610 | "buzz", _("Allow Buzz"), purple_value_new(PURPLE_TYPE_BOOLEAN), |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1611 | NULL); |
| 9954 | 1612 | types = g_list_append(types, type); |
| 1613 | ||
| 15884 | 1614 | priority_value = purple_value_new(PURPLE_TYPE_INT); |
| 1615 | purple_value_set_int(priority_value, 0); | |
| 1616 | type = purple_status_type_new_with_attrs(PURPLE_STATUS_UNAVAILABLE, | |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1617 | jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_DND), |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1618 | _("Do Not Disturb"), TRUE, TRUE, FALSE, |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1619 | "priority", _("Priority"), priority_value, |
| 15884 | 1620 | "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1621 | "mood", _("Mood"), purple_value_new(PURPLE_TYPE_STRING), |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1622 | "moodtext", _("Mood Text"), purple_value_new(PURPLE_TYPE_STRING), |
|
17791
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1623 | "tune_artist", _("Tune Artist"), purple_value_new(PURPLE_TYPE_STRING), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1624 | "tune_title", _("Tune Title"), purple_value_new(PURPLE_TYPE_STRING), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1625 | "tune_album", _("Tune Album"), purple_value_new(PURPLE_TYPE_STRING), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1626 | "tune_genre", _("Tune Genre"), purple_value_new(PURPLE_TYPE_STRING), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1627 | "tune_comment", _("Tune Comment"), purple_value_new(PURPLE_TYPE_STRING), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1628 | "tune_track", _("Tune Track"), purple_value_new(PURPLE_TYPE_STRING), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1629 | "tune_time", _("Tune Time"), purple_value_new(PURPLE_TYPE_INT), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1630 | "tune_year", _("Tune Year"), purple_value_new(PURPLE_TYPE_INT), |
|
b947d72db9db
Implemented user tune, currently untested.
Andreas Monitzer <am@adiumx.com>
parents:
17788
diff
changeset
|
1631 | "tune_url", _("Tune URL"), purple_value_new(PURPLE_TYPE_STRING), |
|
17803
882abe4d932e
Implemented XEP-0172: User Nickname, fixed some potential crashers in the other PEP callbacks.
Andreas Monitzer <am@adiumx.com>
parents:
17800
diff
changeset
|
1632 | "nick", _("Nickname"), purple_value_new(PURPLE_TYPE_STRING), |
|
17824
52683dfc1f7d
Added the option to enable/disable buzz via a status setting. It's default off for the pidgin folks.
Andreas Monitzer <am@adiumx.com>
parents:
17823
diff
changeset
|
1633 | "buzz", _("Allow Buzz"), purple_value_new(PURPLE_TYPE_BOOLEAN), |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1634 | NULL); |
| 9954 | 1635 | types = g_list_append(types, type); |
| 1636 | ||
| 1637 | /* | |
| 8166 | 1638 | if(js->protocol_version == JABBER_PROTO_0_9) |
| 1639 | m = g_list_append(m, _("Invisible")); | |
|
10009
8a4fcc043f47
[gaim-migrate @ 10926]
Mark Doliner <markdoliner@pidgin.im>
parents:
9980
diff
changeset
|
1640 | */ |
| 2086 | 1641 | |
| 15884 | 1642 | type = purple_status_type_new_with_attrs(PURPLE_STATUS_OFFLINE, |
|
12658
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12646
diff
changeset
|
1643 | jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_UNAVAILABLE), |
|
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12646
diff
changeset
|
1644 | NULL, FALSE, TRUE, FALSE, |
| 15884 | 1645 | "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), |
|
12658
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12646
diff
changeset
|
1646 | NULL); |
|
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12646
diff
changeset
|
1647 | types = g_list_append(types, type); |
|
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12646
diff
changeset
|
1648 | |
| 9954 | 1649 | return types; |
| 2086 | 1650 | } |
| 1651 | ||
| 7395 | 1652 | static void |
| 1653 | jabber_password_change_result_cb(JabberStream *js, xmlnode *packet, | |
| 1654 | gpointer data) | |
| 7124 | 1655 | { |
| 1656 | const char *type; | |
| 1657 | ||
| 1658 | type = xmlnode_get_attrib(packet, "type"); | |
| 1659 | ||
| 9414 | 1660 | if(type && !strcmp(type, "result")) { |
| 15884 | 1661 | purple_notify_info(js->gc, _("Password Changed"), _("Password Changed"), |
| 7124 | 1662 | _("Your password has been changed.")); |
| 1663 | } else { | |
| 8401 | 1664 | char *msg = jabber_parse_error(js, packet); |
| 7124 | 1665 | |
| 15884 | 1666 | purple_notify_error(js->gc, _("Error changing password"), |
| 8401 | 1667 | _("Error changing password"), msg); |
| 1668 | g_free(msg); | |
| 7124 | 1669 | } |
| 1670 | } | |
| 1671 | ||
| 1672 | static void jabber_password_change_cb(JabberStream *js, | |
| 15884 | 1673 | PurpleRequestFields *fields) |
| 7124 | 1674 | { |
| 1675 | const char *p1, *p2; | |
| 1676 | JabberIq *iq; | |
| 1677 | xmlnode *query, *y; | |
| 1678 | ||
| 15884 | 1679 | p1 = purple_request_fields_get_string(fields, "password1"); |
| 1680 | p2 = purple_request_fields_get_string(fields, "password2"); | |
| 7124 | 1681 | |
| 1682 | if(strcmp(p1, p2)) { | |
| 15884 | 1683 | purple_notify_error(js->gc, NULL, _("New passwords do not match."), NULL); |
| 7124 | 1684 | return; |
| 1685 | } | |
| 1686 | ||
| 1687 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register"); | |
| 1688 | ||
| 1689 | xmlnode_set_attrib(iq->node, "to", js->user->domain); | |
| 1690 | ||
| 1691 | query = xmlnode_get_child(iq->node, "query"); | |
| 1692 | ||
| 1693 | y = xmlnode_new_child(query, "username"); | |
| 1694 | xmlnode_insert_data(y, js->user->node, -1); | |
| 1695 | y = xmlnode_new_child(query, "password"); | |
| 1696 | xmlnode_insert_data(y, p1, -1); | |
| 1697 | ||
| 7395 | 1698 | jabber_iq_set_callback(iq, jabber_password_change_result_cb, NULL); |
| 7124 | 1699 | |
| 1700 | jabber_iq_send(iq); | |
| 1701 | ||
| 15884 | 1702 | purple_account_set_password(js->gc->account, p1); |
| 7124 | 1703 | } |
| 1704 | ||
| 15884 | 1705 | static void jabber_password_change(PurplePluginAction *action) |
| 7124 | 1706 | { |
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
1707 | |
| 15884 | 1708 | PurpleConnection *gc = (PurpleConnection *) action->context; |
| 7124 | 1709 | JabberStream *js = gc->proto_data; |
| 15884 | 1710 | PurpleRequestFields *fields; |
| 1711 | PurpleRequestFieldGroup *group; | |
| 1712 | PurpleRequestField *field; | |
| 7124 | 1713 | |
| 15884 | 1714 | fields = purple_request_fields_new(); |
| 1715 | group = purple_request_field_group_new(NULL); | |
| 1716 | purple_request_fields_add_group(fields, group); | |
| 7124 | 1717 | |
| 15884 | 1718 | field = purple_request_field_string_new("password1", _("Password"), |
| 7124 | 1719 | "", FALSE); |
| 15884 | 1720 | purple_request_field_string_set_masked(field, TRUE); |
|
18381
8192b072afa6
Make password fileds in Jabber's Change Password dialog required. Fixes #1907
Sean Egan <seanegan@pidgin.im>
parents:
18310
diff
changeset
|
1721 | purple_request_field_set_required(field, TRUE); |
| 15884 | 1722 | purple_request_field_group_add_field(group, field); |
| 7124 | 1723 | |
| 15884 | 1724 | field = purple_request_field_string_new("password2", _("Password (again)"), |
| 7124 | 1725 | "", FALSE); |
| 15884 | 1726 | purple_request_field_string_set_masked(field, TRUE); |
|
18381
8192b072afa6
Make password fileds in Jabber's Change Password dialog required. Fixes #1907
Sean Egan <seanegan@pidgin.im>
parents:
18310
diff
changeset
|
1727 | purple_request_field_set_required(field, TRUE); |
| 15884 | 1728 | purple_request_field_group_add_field(group, field); |
| 7124 | 1729 | |
|
16961
b6955f946f8f
s/Jabber/XMPP in user-visible places.
Richard Laager <rlaager@pidgin.im>
parents:
16847
diff
changeset
|
1730 | purple_request_fields(js->gc, _("Change XMPP Password"), |
|
b6955f946f8f
s/Jabber/XMPP in user-visible places.
Richard Laager <rlaager@pidgin.im>
parents:
16847
diff
changeset
|
1731 | _("Change XMPP Password"), _("Please enter your new password"), |
| 7124 | 1732 | fields, _("OK"), G_CALLBACK(jabber_password_change_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:
16302
diff
changeset
|
1733 | _("Cancel"), NULL, |
|
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:
16302
diff
changeset
|
1734 | purple_connection_get_account(gc), NULL, NULL, |
|
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:
16302
diff
changeset
|
1735 | js); |
| 7124 | 1736 | } |
| 1737 | ||
|
16302
eb633ebf84f2
This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
Sean Egan <seanegan@pidgin.im>
parents:
16180
diff
changeset
|
1738 | GList *jabber_actions(PurplePlugin *plugin, gpointer context) |
| 2956 | 1739 | { |
|
17782
83af68644d0a
Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <am@adiumx.com>
parents:
17780
diff
changeset
|
1740 | PurpleConnection *gc = (PurpleConnection *) context; |
|
83af68644d0a
Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <am@adiumx.com>
parents:
17780
diff
changeset
|
1741 | JabberStream *js = gc->proto_data; |
| 2956 | 1742 | GList *m = NULL; |
| 15884 | 1743 | PurplePluginAction *act; |
|
4333
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4316
diff
changeset
|
1744 | |
| 15884 | 1745 | act = purple_plugin_action_new(_("Set User Info..."), |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1746 | jabber_setup_set_info); |
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
1747 | m = g_list_append(m, act); |
|
4333
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4316
diff
changeset
|
1748 | |
| 8296 | 1749 | /* if (js->protocol_options & CHANGE_PASSWORD) { */ |
| 15884 | 1750 | act = purple_plugin_action_new(_("Change Password..."), |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1751 | jabber_password_change); |
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
1752 | m = g_list_append(m, act); |
| 8296 | 1753 | /* } */ |
| 2956 | 1754 | |
| 15884 | 1755 | act = purple_plugin_action_new(_("Search for Users..."), |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
1756 | jabber_user_search_begin); |
| 11675 | 1757 | m = g_list_append(m, act); |
| 1758 | ||
|
17783
2687df1ca202
PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents:
17782
diff
changeset
|
1759 | purple_debug_info("jabber", "jabber_actions: have pep: %s\n", js->pep?"YES":"NO"); |
|
2687df1ca202
PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents:
17782
diff
changeset
|
1760 | |
|
17782
83af68644d0a
Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <am@adiumx.com>
parents:
17780
diff
changeset
|
1761 | if(js->pep) |
|
83af68644d0a
Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <am@adiumx.com>
parents:
17780
diff
changeset
|
1762 | jabber_pep_init_actions(&m); |
|
17817
8e0f271aab78
The server's ad-hoc commands are now listed in the account's action menu. Note that this requires an additional field in the _PurplePluginAction struct. There's no other way, since there was no way to supply user_data, and dynamically created functions are not supported by C. This should be fine, since that struct is only malloced in purple_plugin_action_new, which is part of the core. Applications have to either pass the struct unmodified, or restore the user_data pointer if the action is recreated when necessary (as is the case in Adium).
Andreas Monitzer <am@adiumx.com>
parents:
17815
diff
changeset
|
1763 | |
|
8e0f271aab78
The server's ad-hoc commands are now listed in the account's action menu. Note that this requires an additional field in the _PurplePluginAction struct. There's no other way, since there was no way to supply user_data, and dynamically created functions are not supported by C. This should be fine, since that struct is only malloced in purple_plugin_action_new, which is part of the core. Applications have to either pass the struct unmodified, or restore the user_data pointer if the action is recreated when necessary (as is the case in Adium).
Andreas Monitzer <am@adiumx.com>
parents:
17815
diff
changeset
|
1764 | if(js->commands) |
|
8e0f271aab78
The server's ad-hoc commands are now listed in the account's action menu. Note that this requires an additional field in the _PurplePluginAction struct. There's no other way, since there was no way to supply user_data, and dynamically created functions are not supported by C. This should be fine, since that struct is only malloced in purple_plugin_action_new, which is part of the core. Applications have to either pass the struct unmodified, or restore the user_data pointer if the action is recreated when necessary (as is the case in Adium).
Andreas Monitzer <am@adiumx.com>
parents:
17815
diff
changeset
|
1765 | jabber_adhoc_init_server_commands(js, &m); |
| 11675 | 1766 | |
| 2956 | 1767 | return m; |
| 1768 | } | |
| 1769 | ||
|
16302
eb633ebf84f2
This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
Sean Egan <seanegan@pidgin.im>
parents:
16180
diff
changeset
|
1770 | PurpleChat *jabber_find_blist_chat(PurpleAccount *account, const char *name) |
| 7999 | 1771 | { |
| 15884 | 1772 | PurpleBlistNode *gnode, *cnode; |
| 7999 | 1773 | JabberID *jid; |
| 1774 | ||
| 1775 | if(!(jid = jabber_id_new(name))) | |
| 1776 | return NULL; | |
| 1777 | ||
| 15884 | 1778 | for(gnode = purple_get_blist()->root; gnode; gnode = gnode->next) { |
| 7999 | 1779 | for(cnode = gnode->child; cnode; cnode = cnode->next) { |
| 15884 | 1780 | PurpleChat *chat = (PurpleChat*)cnode; |
| 7999 | 1781 | const char *room, *server; |
| 15884 | 1782 | if(!PURPLE_BLIST_NODE_IS_CHAT(cnode)) |
| 7999 | 1783 | continue; |
| 1784 | ||
| 1785 | if(chat->account != account) | |
| 8011 | 1786 | continue; |
| 7999 | 1787 | |
| 1788 | if(!(room = g_hash_table_lookup(chat->components, "room"))) | |
| 1789 | continue; | |
| 1790 | if(!(server = g_hash_table_lookup(chat->components, "server"))) | |
| 1791 | continue; | |
| 1792 | ||
| 8158 | 1793 | if(jid->node && jid->domain && |
| 1794 | !g_utf8_collate(room, jid->node) && !g_utf8_collate(server, jid->domain)) { | |
| 7999 | 1795 | jabber_id_free(jid); |
| 1796 | return chat; | |
| 1797 | } | |
| 1798 | } | |
| 1799 | } | |
| 1800 | jabber_id_free(jid); | |
| 1801 | return NULL; | |
| 1802 | } | |
| 1803 | ||
|
16302
eb633ebf84f2
This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
Sean Egan <seanegan@pidgin.im>
parents:
16180
diff
changeset
|
1804 | void jabber_convo_closed(PurpleConnection *gc, const char *who) |
| 8400 | 1805 | { |
| 1806 | JabberStream *js = gc->proto_data; | |
| 1807 | JabberID *jid; | |
| 1808 | JabberBuddy *jb; | |
| 1809 | JabberBuddyResource *jbr; | |
| 1810 | ||
| 1811 | if(!(jid = jabber_id_new(who))) | |
| 1812 | return; | |
| 1813 | ||
| 1814 | if((jb = jabber_buddy_find(js, who, TRUE)) && | |
| 1815 | (jbr = jabber_buddy_find_resource(jb, jid->resource))) { | |
| 1816 | if(jbr->thread_id) { | |
| 1817 | g_free(jbr->thread_id); | |
| 1818 | jbr->thread_id = NULL; | |
| 1819 | } | |
|
15709
b58646e3ce63
Sending XEP 85 'gone' messages
Sean Egan <seanegan@pidgin.im>
parents:
15668
diff
changeset
|
1820 | if(jbr->chat_states == JABBER_CHAT_STATES_SUPPORTED) |
|
b58646e3ce63
Sending XEP 85 'gone' messages
Sean Egan <seanegan@pidgin.im>
parents:
15668
diff
changeset
|
1821 | jabber_message_conv_closed(js, who); |
| 8400 | 1822 | } |
| 1823 | ||
| 1824 | jabber_id_free(jid); | |
| 1825 | } | |
| 1826 | ||
| 8401 | 1827 | |
| 1828 | char *jabber_parse_error(JabberStream *js, xmlnode *packet) | |
| 1829 | { | |
| 1830 | xmlnode *error; | |
| 1831 | const char *code = NULL, *text = NULL; | |
| 13808 | 1832 | const char *xmlns = xmlnode_get_namespace(packet); |
| 8401 | 1833 | char *cdata = NULL; |
| 1834 | ||
| 1835 | if((error = xmlnode_get_child(packet, "error"))) { | |
| 1836 | cdata = xmlnode_get_data(error); | |
| 1837 | code = xmlnode_get_attrib(error, "code"); | |
| 1838 | ||
| 1839 | /* Stanza errors */ | |
| 1840 | if(xmlnode_get_child(error, "bad-request")) { | |
| 1841 | text = _("Bad Request"); | |
| 1842 | } else if(xmlnode_get_child(error, "conflict")) { | |
| 1843 | text = _("Conflict"); | |
| 1844 | } else if(xmlnode_get_child(error, "feature-not-implemented")) { | |
| 1845 | text = _("Feature Not Implemented"); | |
| 1846 | } else if(xmlnode_get_child(error, "forbidden")) { | |
| 1847 | text = _("Forbidden"); | |
| 1848 | } else if(xmlnode_get_child(error, "gone")) { | |
| 1849 | text = _("Gone"); | |
| 1850 | } else if(xmlnode_get_child(error, "internal-server-error")) { | |
| 1851 | text = _("Internal Server Error"); | |
| 1852 | } else if(xmlnode_get_child(error, "item-not-found")) { | |
| 1853 | text = _("Item Not Found"); | |
| 1854 | } else if(xmlnode_get_child(error, "jid-malformed")) { | |
|
16961
b6955f946f8f
s/Jabber/XMPP in user-visible places.
Richard Laager <rlaager@pidgin.im>
parents:
16847
diff
changeset
|
1855 | text = _("Malformed XMPP ID"); |
| 8401 | 1856 | } else if(xmlnode_get_child(error, "not-acceptable")) { |
| 1857 | text = _("Not Acceptable"); | |
| 1858 | } else if(xmlnode_get_child(error, "not-allowed")) { | |
| 1859 | text = _("Not Allowed"); | |
| 1860 | } else if(xmlnode_get_child(error, "not-authorized")) { | |
| 1861 | text = _("Not Authorized"); | |
| 1862 | } else if(xmlnode_get_child(error, "payment-required")) { | |
| 1863 | text = _("Payment Required"); | |
| 1864 | } else if(xmlnode_get_child(error, "recipient-unavailable")) { | |
| 1865 | text = _("Recipient Unavailable"); | |
| 1866 | } else if(xmlnode_get_child(error, "redirect")) { | |
| 1867 | /* XXX */ | |
| 1868 | } else if(xmlnode_get_child(error, "registration-required")) { | |
| 1869 | text = _("Registration Required"); | |
| 1870 | } else if(xmlnode_get_child(error, "remote-server-not-found")) { | |
| 1871 | text = _("Remote Server Not Found"); | |
| 1872 | } else if(xmlnode_get_child(error, "remote-server-timeout")) { | |
| 1873 | text = _("Remote Server Timeout"); | |
| 1874 | } else if(xmlnode_get_child(error, "resource-constraint")) { | |
| 1875 | text = _("Server Overloaded"); | |
| 1876 | } else if(xmlnode_get_child(error, "service-unavailable")) { | |
| 1877 | text = _("Service Unavailable"); | |
| 1878 | } else if(xmlnode_get_child(error, "subscription-required")) { | |
| 1879 | text = _("Subscription Required"); | |
| 1880 | } else if(xmlnode_get_child(error, "unexpected-request")) { | |
| 1881 | text = _("Unexpected Request"); | |
| 1882 | } else if(xmlnode_get_child(error, "undefined-condition")) { | |
| 1883 | text = _("Unknown Error"); | |
| 1884 | } | |
| 1885 | } else if(xmlns && !strcmp(xmlns, "urn:ietf:params:xml:ns:xmpp-sasl")) { | |
| 1886 | if(xmlnode_get_child(packet, "aborted")) { | |
| 1887 | js->gc->wants_to_die = TRUE; | |
| 1888 | text = _("Authorization Aborted"); | |
| 13806 | 1889 | } else if(xmlnode_get_child(packet, "incorrect-encoding")) { |
| 8401 | 1890 | text = _("Incorrect encoding in authorization"); |
| 13806 | 1891 | } else if(xmlnode_get_child(packet, "invalid-authzid")) { |
| 8401 | 1892 | js->gc->wants_to_die = TRUE; |
| 1893 | text = _("Invalid authzid"); | |
| 13806 | 1894 | } else if(xmlnode_get_child(packet, "invalid-mechanism")) { |
| 8401 | 1895 | js->gc->wants_to_die = TRUE; |
| 1896 | text = _("Invalid Authorization Mechanism"); | |
| 13806 | 1897 | } else if(xmlnode_get_child(packet, "mechanism-too-weak")) { |
| 8401 | 1898 | js->gc->wants_to_die = TRUE; |
| 1899 | text = _("Authorization mechanism too weak"); | |
| 13806 | 1900 | } else if(xmlnode_get_child(packet, "not-authorized")) { |
| 8401 | 1901 | js->gc->wants_to_die = TRUE; |
| 1902 | text = _("Not Authorized"); | |
| 13806 | 1903 | } else if(xmlnode_get_child(packet, "temporary-auth-failure")) { |
| 8401 | 1904 | text = _("Temporary Authentication Failure"); |
| 1905 | } else { | |
| 13051 | 1906 | js->gc->wants_to_die = TRUE; |
| 8401 | 1907 | text = _("Authentication Failure"); |
| 1908 | } | |
|
15979
acfbd09bc217
Correctly handle the Jabber disconnection error for signing onto the
Mark Doliner <markdoliner@pidgin.im>
parents:
15977
diff
changeset
|
1909 | } else if(!strcmp(packet->name, "stream:error") || |
|
acfbd09bc217
Correctly handle the Jabber disconnection error for signing onto the
Mark Doliner <markdoliner@pidgin.im>
parents:
15977
diff
changeset
|
1910 | (!strcmp(packet->name, "error") && |
| 15980 | 1911 | !strcmp(xmlns, "http://etherx.jabber.org/streams"))) { |
| 8402 | 1912 | if(xmlnode_get_child(packet, "bad-format")) { |
| 1913 | text = _("Bad Format"); | |
| 1914 | } else if(xmlnode_get_child(packet, "bad-namespace-prefix")) { | |
| 1915 | text = _("Bad Namespace Prefix"); | |
| 1916 | } else if(xmlnode_get_child(packet, "conflict")) { | |
| 1917 | js->gc->wants_to_die = TRUE; | |
| 1918 | text = _("Resource Conflict"); | |
| 1919 | } else if(xmlnode_get_child(packet, "connection-timeout")) { | |
| 1920 | text = _("Connection Timeout"); | |
| 1921 | } else if(xmlnode_get_child(packet, "host-gone")) { | |
| 1922 | text = _("Host Gone"); | |
| 1923 | } else if(xmlnode_get_child(packet, "host-unknown")) { | |
| 1924 | text = _("Host Unknown"); | |
| 1925 | } else if(xmlnode_get_child(packet, "improper-addressing")) { | |
| 1926 | text = _("Improper Addressing"); | |
| 1927 | } else if(xmlnode_get_child(packet, "internal-server-error")) { | |
| 1928 | text = _("Internal Server Error"); | |
| 1929 | } else if(xmlnode_get_child(packet, "invalid-id")) { | |
| 1930 | text = _("Invalid ID"); | |
| 1931 | } else if(xmlnode_get_child(packet, "invalid-namespace")) { | |
| 1932 | text = _("Invalid Namespace"); | |
| 1933 | } else if(xmlnode_get_child(packet, "invalid-xml")) { | |
| 1934 | text = _("Invalid XML"); | |
| 1935 | } else if(xmlnode_get_child(packet, "nonmatching-hosts")) { | |
| 1936 | text = _("Non-matching Hosts"); | |
| 1937 | } else if(xmlnode_get_child(packet, "not-authorized")) { | |
| 1938 | text = _("Not Authorized"); | |
| 1939 | } else if(xmlnode_get_child(packet, "policy-violation")) { | |
| 1940 | text = _("Policy Violation"); | |
| 1941 | } else if(xmlnode_get_child(packet, "remote-connection-failed")) { | |
| 1942 | text = _("Remote Connection Failed"); | |
| 1943 | } else if(xmlnode_get_child(packet, "resource-constraint")) { | |
| 1944 | text = _("Resource Constraint"); | |
| 1945 | } else if(xmlnode_get_child(packet, "restricted-xml")) { | |
| 1946 | text = _("Restricted XML"); | |
| 1947 | } else if(xmlnode_get_child(packet, "see-other-host")) { | |
| 1948 | text = _("See Other Host"); | |
| 1949 | } else if(xmlnode_get_child(packet, "system-shutdown")) { | |
| 1950 | text = _("System Shutdown"); | |
| 1951 | } else if(xmlnode_get_child(packet, "undefined-condition")) { | |
| 1952 | text = _("Undefined Condition"); | |
| 1953 | } else if(xmlnode_get_child(packet, "unsupported-encoding")) { | |
| 1954 | text = _("Unsupported Encoding"); | |
| 1955 | } else if(xmlnode_get_child(packet, "unsupported-stanza-type")) { | |
| 1956 | text = _("Unsupported Stanza Type"); | |
| 1957 | } else if(xmlnode_get_child(packet, "unsupported-version")) { | |
| 1958 | text = _("Unsupported Version"); | |
| 1959 | } else if(xmlnode_get_child(packet, "xml-not-well-formed")) { | |
| 1960 | text = _("XML Not Well Formed"); | |
| 1961 | } else { | |
| 1962 | text = _("Stream Error"); | |
| 1963 | } | |
| 8401 | 1964 | } |
| 1965 | ||
| 1966 | if(text || cdata) { | |
| 1967 | char *ret = g_strdup_printf("%s%s%s", code ? code : "", | |
| 1968 | code ? ": " : "", text ? text : cdata); | |
| 1969 | g_free(cdata); | |
| 1970 | return ret; | |
| 1971 | } else { | |
| 1972 | return NULL; | |
| 1973 | } | |
| 1974 | } | |
| 1975 | ||
| 15884 | 1976 | static PurpleCmdRet jabber_cmd_chat_config(PurpleConversation *conv, |
| 9597 | 1977 | const char *cmd, char **args, char **error, void *data) |
| 9130 | 1978 | { |
| 1979 | JabberChat *chat = jabber_chat_find_by_conv(conv); | |
|
18986
5542a465de12
Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents:
18381
diff
changeset
|
1980 | |
|
5542a465de12
Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents:
18381
diff
changeset
|
1981 | if (!chat) |
|
5542a465de12
Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents:
18381
diff
changeset
|
1982 | return PURPLE_CMD_RET_FAILED; |
|
5542a465de12
Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents:
18381
diff
changeset
|
1983 | |
| 9130 | 1984 | jabber_chat_request_room_configure(chat); |
| 15884 | 1985 | return PURPLE_CMD_RET_OK; |
| 9130 | 1986 | } |
| 1987 | ||
| 15884 | 1988 | static PurpleCmdRet jabber_cmd_chat_register(PurpleConversation *conv, |
| 9597 | 1989 | const char *cmd, char **args, char **error, void *data) |
| 9130 | 1990 | { |
| 1991 | JabberChat *chat = jabber_chat_find_by_conv(conv); | |
|
18986
5542a465de12
Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents:
18381
diff
changeset
|
1992 | |
|
5542a465de12
Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents:
18381
diff
changeset
|
1993 | if (!chat) |
|
5542a465de12
Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents:
18381
diff
changeset
|
1994 | return PURPLE_CMD_RET_FAILED; |
|
5542a465de12
Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents:
18381
diff
changeset
|
1995 | |
| 9130 | 1996 | jabber_chat_register(chat); |
| 15884 | 1997 | return PURPLE_CMD_RET_OK; |
| 9130 | 1998 | } |
| 1999 | ||
| 15884 | 2000 | static PurpleCmdRet jabber_cmd_chat_topic(PurpleConversation *conv, |
| 9597 | 2001 | const char *cmd, char **args, char **error, void *data) |
| 9130 | 2002 | { |
| 2003 | JabberChat *chat = jabber_chat_find_by_conv(conv); | |
|
18986
5542a465de12
Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents:
18381
diff
changeset
|
2004 | |
|
5542a465de12
Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents:
18381
diff
changeset
|
2005 | if (!chat) |
|
5542a465de12
Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents:
18381
diff
changeset
|
2006 | return PURPLE_CMD_RET_FAILED; |
|
5542a465de12
Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents:
18381
diff
changeset
|
2007 | |
| 9130 | 2008 | jabber_chat_change_topic(chat, args ? args[0] : NULL); |
| 15884 | 2009 | return PURPLE_CMD_RET_OK; |
| 9130 | 2010 | } |
| 2011 | ||
| 15884 | 2012 | static PurpleCmdRet jabber_cmd_chat_nick(PurpleConversation *conv, |
| 9597 | 2013 | const char *cmd, char **args, char **error, void *data) |
| 9130 | 2014 | { |
| 2015 | JabberChat *chat = jabber_chat_find_by_conv(conv); | |
| 2016 | ||
|
18986
5542a465de12
Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents:
18381
diff
changeset
|
2017 | if(!chat || !args || !args[0]) |
| 15884 | 2018 | return PURPLE_CMD_RET_FAILED; |
| 9130 | 2019 | |
| 2020 | jabber_chat_change_nick(chat, args[0]); | |
| 15884 | 2021 | return PURPLE_CMD_RET_OK; |
| 9130 | 2022 | } |
| 2023 | ||
| 15884 | 2024 | static PurpleCmdRet jabber_cmd_chat_part(PurpleConversation *conv, |
| 9597 | 2025 | const char *cmd, char **args, char **error, void *data) |
| 9130 | 2026 | { |
| 2027 | JabberChat *chat = jabber_chat_find_by_conv(conv); | |
|
18986
5542a465de12
Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents:
18381
diff
changeset
|
2028 | |
|
5542a465de12
Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents:
18381
diff
changeset
|
2029 | if (!chat) |
|
5542a465de12
Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents:
18381
diff
changeset
|
2030 | return PURPLE_CMD_RET_FAILED; |
|
5542a465de12
Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents:
18381
diff
changeset
|
2031 | |
| 9130 | 2032 | jabber_chat_part(chat, args ? args[0] : NULL); |
| 15884 | 2033 | return PURPLE_CMD_RET_OK; |
| 9130 | 2034 | } |
| 2035 | ||
| 15884 | 2036 | static PurpleCmdRet jabber_cmd_chat_ban(PurpleConversation *conv, |
| 9597 | 2037 | const char *cmd, char **args, char **error, void *data) |
| 9152 | 2038 | { |
| 2039 | JabberChat *chat = jabber_chat_find_by_conv(conv); | |
| 2040 | ||
|
18986
5542a465de12
Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents:
18381
diff
changeset
|
2041 | if(!chat || !args || !args[0]) |
| 15884 | 2042 | return PURPLE_CMD_RET_FAILED; |
| 9152 | 2043 | |
| 2044 | if(!jabber_chat_ban_user(chat, args[0], args[1])) { | |
| 2045 | *error = g_strdup_printf(_("Unable to ban user %s"), args[0]); | |
| 15884 | 2046 | return PURPLE_CMD_RET_FAILED; |
| 9152 | 2047 | } |
| 2048 | ||
| 15884 | 2049 | return PURPLE_CMD_RET_OK; |
| 9152 | 2050 | } |
| 2051 | ||
| 15884 | 2052 | static PurpleCmdRet jabber_cmd_chat_affiliate(PurpleConversation *conv, |
| 11393 | 2053 | const char *cmd, char **args, char **error, void *data) |
| 2054 | { | |
| 2055 | JabberChat *chat = jabber_chat_find_by_conv(conv); | |
| 2056 | ||
|
18986
5542a465de12
Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents:
18381
diff
changeset
|
2057 | if (!chat || !args || !args[0] || !args[1]) |
| 15884 | 2058 | return PURPLE_CMD_RET_FAILED; |
| 11393 | 2059 | |
|
13238
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
13201
diff
changeset
|
2060 | if (strcmp(args[1], "owner") != 0 && |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2061 | strcmp(args[1], "admin") != 0 && |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2062 | strcmp(args[1], "member") != 0 && |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2063 | strcmp(args[1], "outcast") != 0 && |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2064 | strcmp(args[1], "none") != 0) { |
| 11393 | 2065 | *error = g_strdup_printf(_("Unknown affiliation: \"%s\""), args[1]); |
| 15884 | 2066 | return PURPLE_CMD_RET_FAILED; |
| 11393 | 2067 | } |
| 2068 | ||
| 2069 | if (!jabber_chat_affiliate_user(chat, args[0], args[1])) { | |
| 2070 | *error = g_strdup_printf(_("Unable to affiliate user %s as \"%s\""), args[0], args[1]); | |
| 15884 | 2071 | return PURPLE_CMD_RET_FAILED; |
| 11393 | 2072 | } |
| 2073 | ||
| 15884 | 2074 | return PURPLE_CMD_RET_OK; |
| 11393 | 2075 | } |
| 2076 | ||
| 15884 | 2077 | static PurpleCmdRet jabber_cmd_chat_role(PurpleConversation *conv, |
|
13238
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
13201
diff
changeset
|
2078 | const char *cmd, char **args, char **error, void *data) |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
13201
diff
changeset
|
2079 | { |
|
19217
ee1aa7e4c462
Fix uninitialized variable access.
Daniel Atallah <datallah@pidgin.im>
parents:
18986
diff
changeset
|
2080 | JabberChat *chat = jabber_chat_find_by_conv(conv); |
|
13238
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
13201
diff
changeset
|
2081 | |
|
18986
5542a465de12
Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents:
18381
diff
changeset
|
2082 | if (!chat || !args || !args[0] || !args[1]) |
| 15884 | 2083 | return PURPLE_CMD_RET_FAILED; |
|
13238
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
13201
diff
changeset
|
2084 | |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
13201
diff
changeset
|
2085 | if (strcmp(args[1], "moderator") != 0 && |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2086 | strcmp(args[1], "participant") != 0 && |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2087 | strcmp(args[1], "visitor") != 0 && |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2088 | strcmp(args[1], "none") != 0) { |
|
13238
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
13201
diff
changeset
|
2089 | *error = g_strdup_printf(_("Unknown role: \"%s\""), args[1]); |
| 15884 | 2090 | return PURPLE_CMD_RET_FAILED; |
|
13238
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
13201
diff
changeset
|
2091 | } |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
13201
diff
changeset
|
2092 | |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
13201
diff
changeset
|
2093 | if (!jabber_chat_role_user(chat, args[0], args[1])) { |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
13201
diff
changeset
|
2094 | *error = g_strdup_printf(_("Unable to set role \"%s\" for user: %s"), |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2095 | args[1], args[0]); |
| 15884 | 2096 | return PURPLE_CMD_RET_FAILED; |
|
13238
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
13201
diff
changeset
|
2097 | } |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
13201
diff
changeset
|
2098 | |
| 15884 | 2099 | return PURPLE_CMD_RET_OK; |
|
13238
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
13201
diff
changeset
|
2100 | } |
|
b98439d90903
[gaim-migrate @ 15603]
Andrej Krivulčík <thefox692@users.sourceforge.net>
parents:
13201
diff
changeset
|
2101 | |
| 15884 | 2102 | static PurpleCmdRet jabber_cmd_chat_invite(PurpleConversation *conv, |
| 9597 | 2103 | const char *cmd, char **args, char **error, void *data) |
| 9152 | 2104 | { |
| 2105 | if(!args || !args[0]) | |
| 15884 | 2106 | return PURPLE_CMD_RET_FAILED; |
| 9152 | 2107 | |
| 15884 | 2108 | jabber_chat_invite(purple_conversation_get_gc(conv), |
| 2109 | purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)), args[1] ? args[1] : "", | |
| 9152 | 2110 | args[0]); |
| 2111 | ||
| 15884 | 2112 | return PURPLE_CMD_RET_OK; |
| 9152 | 2113 | } |
| 2114 | ||
| 15884 | 2115 | static PurpleCmdRet jabber_cmd_chat_join(PurpleConversation *conv, |
| 9597 | 2116 | const char *cmd, char **args, char **error, void *data) |
| 9152 | 2117 | { |
| 2118 | JabberChat *chat = jabber_chat_find_by_conv(conv); | |
| 2119 | GHashTable *components; | |
| 2120 | ||
|
18986
5542a465de12
Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents:
18381
diff
changeset
|
2121 | if(!chat || !args || !args[0]) |
| 15884 | 2122 | return PURPLE_CMD_RET_FAILED; |
| 9152 | 2123 | |
| 2124 | components = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL); | |
| 2125 | ||
| 2126 | g_hash_table_replace(components, "room", args[0]); | |
| 2127 | g_hash_table_replace(components, "server", chat->server); | |
| 2128 | g_hash_table_replace(components, "handle", chat->handle); | |
| 2129 | if(args[1]) | |
| 2130 | g_hash_table_replace(components, "password", args[1]); | |
| 2131 | ||
| 15884 | 2132 | jabber_chat_join(purple_conversation_get_gc(conv), components); |
| 9152 | 2133 | |
| 2134 | g_hash_table_destroy(components); | |
| 15884 | 2135 | return PURPLE_CMD_RET_OK; |
| 9152 | 2136 | } |
| 2137 | ||
| 15884 | 2138 | static PurpleCmdRet jabber_cmd_chat_kick(PurpleConversation *conv, |
| 9597 | 2139 | const char *cmd, char **args, char **error, void *data) |
| 9152 | 2140 | { |
| 2141 | JabberChat *chat = jabber_chat_find_by_conv(conv); | |
| 2142 | ||
|
18986
5542a465de12
Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents:
18381
diff
changeset
|
2143 | if(!chat || !args || !args[0]) |
| 15884 | 2144 | return PURPLE_CMD_RET_FAILED; |
| 9152 | 2145 | |
| 2146 | if(!jabber_chat_kick_user(chat, args[0], args[1])) { | |
| 2147 | *error = g_strdup_printf(_("Unable to kick user %s"), args[0]); | |
| 15884 | 2148 | return PURPLE_CMD_RET_FAILED; |
| 9152 | 2149 | } |
| 2150 | ||
| 15884 | 2151 | return PURPLE_CMD_RET_OK; |
| 9152 | 2152 | } |
| 2153 | ||
| 15884 | 2154 | static PurpleCmdRet jabber_cmd_chat_msg(PurpleConversation *conv, |
| 9597 | 2155 | const char *cmd, char **args, char **error, void *data) |
| 9152 | 2156 | { |
| 2157 | JabberChat *chat = jabber_chat_find_by_conv(conv); | |
| 2158 | char *who; | |
| 2159 | ||
|
18986
5542a465de12
Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents:
18381
diff
changeset
|
2160 | if (!chat) |
|
5542a465de12
Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents:
18381
diff
changeset
|
2161 | return PURPLE_CMD_RET_FAILED; |
|
5542a465de12
Fix a bunch of possible crashes in jabber when using slash commands in
Mark Doliner <markdoliner@pidgin.im>
parents:
18381
diff
changeset
|
2162 | |
| 9152 | 2163 | who = g_strdup_printf("%s@%s/%s", chat->room, chat->server, args[0]); |
| 2164 | ||
| 15884 | 2165 | jabber_message_send_im(purple_conversation_get_gc(conv), who, args[1], 0); |
| 9152 | 2166 | |
| 2167 | g_free(who); | |
| 15884 | 2168 | return PURPLE_CMD_RET_OK; |
| 9152 | 2169 | } |
| 2170 | ||
|
17769
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
17768
diff
changeset
|
2171 | static PurpleCmdRet jabber_cmd_ping(PurpleConversation *conv, |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
17768
diff
changeset
|
2172 | const char *cmd, char **args, char **error, void *data) |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
17768
diff
changeset
|
2173 | { |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
17768
diff
changeset
|
2174 | if(!args || !args[0]) |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
17768
diff
changeset
|
2175 | return PURPLE_CMD_RET_FAILED; |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
17768
diff
changeset
|
2176 | |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
17768
diff
changeset
|
2177 | if(!jabber_ping_jid(conv, args[0])) { |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
17768
diff
changeset
|
2178 | *error = g_strdup_printf(_("Unable to ping user %s"), args[0]); |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
17768
diff
changeset
|
2179 | return PURPLE_CMD_RET_FAILED; |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
17768
diff
changeset
|
2180 | } |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
17768
diff
changeset
|
2181 | |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
17768
diff
changeset
|
2182 | return PURPLE_CMD_RET_OK; |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
17768
diff
changeset
|
2183 | } |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
17768
diff
changeset
|
2184 | |
|
17822
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2185 | static PurpleCmdRet jabber_cmd_buzz(PurpleConversation *conv, |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2186 | const char *cmd, char **args, char **error, void *data) |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2187 | { |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2188 | JabberStream *js = conv->account->gc->proto_data; |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2189 | xmlnode *msg, *buzz; |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2190 | JabberBuddy *jb; |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2191 | JabberBuddyResource *jbr; |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2192 | char *to; |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2193 | GList *iter; |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2194 | |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2195 | if(!args || !args[0]) |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2196 | return PURPLE_CMD_RET_FAILED; |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2197 | |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2198 | jb = jabber_buddy_find(js, args[0], FALSE); |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2199 | if(!jb) { |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2200 | *error = g_strdup_printf(_("Unable to buzz, because there is nothing known about user %s."), args[0]); |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2201 | return PURPLE_CMD_RET_FAILED; |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2202 | } |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2203 | |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2204 | jbr = jabber_buddy_find_resource(jb, NULL); |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2205 | if(!jbr) { |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2206 | *error = g_strdup_printf(_("Unable to buzz, because user %s might be offline."), args[0]); |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2207 | return PURPLE_CMD_RET_FAILED; |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2208 | } |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2209 | if(!jbr->caps) { |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2210 | *error = g_strdup_printf(_("Unable to buzz, because there is nothing known about user %s."), args[0]); |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2211 | return PURPLE_CMD_RET_FAILED; |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2212 | } |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2213 | for(iter = jbr->caps->features; iter; iter = g_list_next(iter)) { |
|
18996
9c15c80fec2a
Updated attention namespace to adhere to my new XEP-0224: Attention
Andreas Monitzer <am@adiumx.com>
parents:
18995
diff
changeset
|
2214 | if(!strcmp(iter->data, "http://www.xmpp.org/extensions/xep-0224.html#ns")) { |
|
17822
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2215 | msg = xmlnode_new("message"); |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2216 | to = g_strdup_printf("%s/%s", args[0], jbr->name); |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2217 | xmlnode_set_attrib(msg,"to",to); |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2218 | g_free(to); |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2219 | |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2220 | /* avoid offline storage */ |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2221 | xmlnode_set_attrib(msg,"type","headline"); |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2222 | |
|
17823
2ca25e7e65dd
Switched buzz namespace and tag name to be libpurple-specific and use a more professionally-sounding name ('attention' instead of 'buzz').
Andreas Monitzer <am@adiumx.com>
parents:
17822
diff
changeset
|
2223 | buzz = xmlnode_new_child(msg,"attention"); |
|
18996
9c15c80fec2a
Updated attention namespace to adhere to my new XEP-0224: Attention
Andreas Monitzer <am@adiumx.com>
parents:
18995
diff
changeset
|
2224 | xmlnode_set_namespace(buzz,"http://www.xmpp.org/extensions/xep-0224.html#ns"); |
|
17822
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2225 | |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2226 | jabber_send(js,msg); |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2227 | xmlnode_free(msg); |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2228 | |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2229 | return PURPLE_CMD_RET_OK; |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2230 | } |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2231 | } |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2232 | *error = g_strdup_printf(_("Unable to buzz, because the user %s does not support it."), args[0]); |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2233 | return PURPLE_CMD_RET_FAILED; |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2234 | } |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2235 | |
|
16302
eb633ebf84f2
This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
Sean Egan <seanegan@pidgin.im>
parents:
16180
diff
changeset
|
2236 | gboolean jabber_offline_message(const PurpleBuddy *buddy) |
|
12645
a907ba243930
[gaim-migrate @ 14983]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12600
diff
changeset
|
2237 | { |
|
a907ba243930
[gaim-migrate @ 14983]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12600
diff
changeset
|
2238 | return TRUE; |
|
a907ba243930
[gaim-migrate @ 14983]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12600
diff
changeset
|
2239 | } |
|
a907ba243930
[gaim-migrate @ 14983]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12600
diff
changeset
|
2240 | |
|
16302
eb633ebf84f2
This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
Sean Egan <seanegan@pidgin.im>
parents:
16180
diff
changeset
|
2241 | void jabber_register_commands(void) |
| 9130 | 2242 | { |
| 15884 | 2243 | purple_cmd_register("config", "", PURPLE_CMD_P_PRPL, |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2244 | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY, |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2245 | "prpl-jabber", jabber_cmd_chat_config, |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2246 | _("config: Configure a chat room."), NULL); |
| 15884 | 2247 | purple_cmd_register("configure", "", PURPLE_CMD_P_PRPL, |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2248 | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY, |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2249 | "prpl-jabber", jabber_cmd_chat_config, |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2250 | _("configure: Configure a chat room."), NULL); |
| 15884 | 2251 | purple_cmd_register("nick", "s", PURPLE_CMD_P_PRPL, |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2252 | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY, |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2253 | "prpl-jabber", jabber_cmd_chat_nick, |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2254 | _("nick <new nickname>: Change your nickname."), |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2255 | NULL); |
| 15884 | 2256 | purple_cmd_register("part", "s", PURPLE_CMD_P_PRPL, |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2257 | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY | |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2258 | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2259 | jabber_cmd_chat_part, _("part [room]: Leave the room."), |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2260 | NULL); |
| 15884 | 2261 | purple_cmd_register("register", "", PURPLE_CMD_P_PRPL, |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2262 | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY, |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2263 | "prpl-jabber", jabber_cmd_chat_register, |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2264 | _("register: Register with a chat room."), NULL); |
| 9130 | 2265 | /* XXX: there needs to be a core /topic cmd, methinks */ |
| 15884 | 2266 | purple_cmd_register("topic", "s", PURPLE_CMD_P_PRPL, |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2267 | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY | |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2268 | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2269 | jabber_cmd_chat_topic, |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2270 | _("topic [new topic]: View or change the topic."), |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2271 | NULL); |
| 15884 | 2272 | purple_cmd_register("ban", "ws", PURPLE_CMD_P_PRPL, |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2273 | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY | |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2274 | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2275 | jabber_cmd_chat_ban, |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2276 | _("ban <user> [room]: Ban a user from the room."), |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2277 | NULL); |
| 15884 | 2278 | purple_cmd_register("affiliate", "ws", PURPLE_CMD_P_PRPL, |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2279 | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY | |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2280 | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2281 | jabber_cmd_chat_affiliate, |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2282 | _("affiliate <user> <owner|admin|member|outcast|none>: Set a user's affiliation with the room."), |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2283 | NULL); |
| 15884 | 2284 | purple_cmd_register("role", "ws", PURPLE_CMD_P_PRPL, |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2285 | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY | |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2286 | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2287 | jabber_cmd_chat_role, |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2288 | _("role <user> <moderator|participant|visitor|none>: Set a user's role in the room."), |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2289 | NULL); |
| 15884 | 2290 | purple_cmd_register("invite", "ws", PURPLE_CMD_P_PRPL, |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2291 | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY | |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2292 | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2293 | jabber_cmd_chat_invite, |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2294 | _("invite <user> [message]: Invite a user to the room."), |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2295 | NULL); |
| 15884 | 2296 | purple_cmd_register("join", "ws", PURPLE_CMD_P_PRPL, |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2297 | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY | |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2298 | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2299 | jabber_cmd_chat_join, |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2300 | _("join: <room> [server]: Join a chat on this server."), |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2301 | NULL); |
| 15884 | 2302 | purple_cmd_register("kick", "ws", PURPLE_CMD_P_PRPL, |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2303 | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY | |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2304 | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2305 | jabber_cmd_chat_kick, |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2306 | _("kick <user> [room]: Kick a user from the room."), |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2307 | NULL); |
| 15884 | 2308 | purple_cmd_register("msg", "ws", PURPLE_CMD_P_PRPL, |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2309 | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY, |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2310 | "prpl-jabber", jabber_cmd_chat_msg, |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2311 | _("msg <user> <message>: Send a private message to another user."), |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2312 | NULL); |
|
17769
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
17768
diff
changeset
|
2313 | purple_cmd_register("ping", "w", PURPLE_CMD_P_PRPL, |
|
17779
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2314 | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM | |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2315 | PURPLE_CMD_FLAG_PRPL_ONLY, |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2316 | "prpl-jabber", jabber_cmd_ping, |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2317 | _("ping <jid>: Ping a user/component/server."), |
|
773326802e26
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents:
17775
diff
changeset
|
2318 | NULL); |
|
17822
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2319 | purple_cmd_register("buzz", "s", PURPLE_CMD_P_PRPL, |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2320 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_PRPL_ONLY, |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2321 | "prpl-jabber", jabber_cmd_buzz, |
|
1a183f3fa9d7
disapproval of revision 'd52c12703a8e67c41c7f95a2cae7f16ab426ad76'
Andreas Monitzer <am@adiumx.com>
parents:
17821
diff
changeset
|
2322 | _("buzz: Buzz a user to get their attention"), NULL); |
| 9130 | 2323 | } |
| 2324 | ||
|
16302
eb633ebf84f2
This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
Sean Egan <seanegan@pidgin.im>
parents:
16180
diff
changeset
|
2325 | void |
|
eb633ebf84f2
This does the ol' AIM/ICQ split trick on Jabber, creating an XMPP prpl. This can be used, later, to create a Bonjour plugin that reuses libjabber
Sean Egan <seanegan@pidgin.im>
parents:
16180
diff
changeset
|
2326 | jabber_init_plugin(PurplePlugin *plugin) |
| 14358 | 2327 | { |
|
17787
439329d20337
Added support for setting the avatar via XEP-0084. Receiving other people's avatar is up next.
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
2328 | my_protocol = plugin; |
| 14358 | 2329 | } |