Tue, 18 Oct 2011 20:25:41 +0000
Add a purple_connection_update_last_received() function to update the
PurpleConnection->last_received value.
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1 | /** |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2 | * @file simple.c |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
3 | * |
| 15884 | 4 | * purple |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
5 | * |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
6 | * Copyright (C) 2005 Thomas Butter <butter@uni-mannheim.de> |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
7 | * |
|
11345
48a2f93e47b6
[gaim-migrate @ 13562]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11341
diff
changeset
|
8 | * *** |
|
48a2f93e47b6
[gaim-migrate @ 13562]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11341
diff
changeset
|
9 | * Thanks to Google's Summer of Code Program and the helpful mentors |
|
48a2f93e47b6
[gaim-migrate @ 13562]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11341
diff
changeset
|
10 | * *** |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
11 | * |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
12 | * This program is free software; you can redistribute it and/or modify |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
13 | * it under the terms of the GNU General Public License as published by |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
14 | * the Free Software Foundation; either version 2 of the License, or |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
15 | * (at your option) any later version. |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
16 | * |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
17 | * This program is distributed in the hope that it will be useful, |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
20 | * GNU General Public License for more details. |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
21 | * |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
22 | * You should have received a copy of the GNU General Public License |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
23 | * along with this program; if not, write to the Free Software |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19848
diff
changeset
|
24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
25 | */ |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
26 | |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
27 | #include "internal.h" |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
28 | |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
29 | #include "accountopt.h" |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
30 | #include "blist.h" |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
31 | #include "conversation.h" |
|
14243
0bda01972ff2
[gaim-migrate @ 16833]
Mark Doliner <markdoliner@pidgin.im>
parents:
14226
diff
changeset
|
32 | #include "dnsquery.h" |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
33 | #include "debug.h" |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
34 | #include "notify.h" |
|
11345
48a2f93e47b6
[gaim-migrate @ 13562]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11341
diff
changeset
|
35 | #include "privacy.h" |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
36 | #include "prpl.h" |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
37 | #include "plugin.h" |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
38 | #include "util.h" |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
39 | #include "version.h" |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
40 | #include "network.h" |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
41 | #include "xmlnode.h" |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
42 | |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
43 | #include "simple.h" |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
44 | #include "sipmsg.h" |
|
11383
2c5a70e62389
[gaim-migrate @ 13610]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11346
diff
changeset
|
45 | #include "dnssrv.h" |
|
11409
2a3466f4a32c
[gaim-migrate @ 13646]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11396
diff
changeset
|
46 | #include "ntlm.h" |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
47 | |
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
21503
diff
changeset
|
48 | static char *gentag(void) { |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
49 | return g_strdup_printf("%04d%04d", rand() & 0xFFFF, rand() & 0xFFFF); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
50 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
51 | |
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
21503
diff
changeset
|
52 | static char *genbranch(void) { |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
53 | return g_strdup_printf("z9hG4bK%04X%04X%04X%04X%04X", |
|
12767
4870d7755883
[gaim-migrate @ 15114]
Daniel Atallah <datallah@pidgin.im>
parents:
12760
diff
changeset
|
54 | rand() & 0xFFFF, rand() & 0xFFFF, rand() & 0xFFFF, |
|
4870d7755883
[gaim-migrate @ 15114]
Daniel Atallah <datallah@pidgin.im>
parents:
12760
diff
changeset
|
55 | rand() & 0xFFFF, rand() & 0xFFFF); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
56 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
57 | |
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
21503
diff
changeset
|
58 | static char *gencallid(void) { |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
59 | return g_strdup_printf("%04Xg%04Xa%04Xi%04Xm%04Xt%04Xb%04Xx%04Xx", |
|
12767
4870d7755883
[gaim-migrate @ 15114]
Daniel Atallah <datallah@pidgin.im>
parents:
12760
diff
changeset
|
60 | rand() & 0xFFFF, rand() & 0xFFFF, rand() & 0xFFFF, |
|
4870d7755883
[gaim-migrate @ 15114]
Daniel Atallah <datallah@pidgin.im>
parents:
12760
diff
changeset
|
61 | rand() & 0xFFFF, rand() & 0xFFFF, rand() & 0xFFFF, |
|
4870d7755883
[gaim-migrate @ 15114]
Daniel Atallah <datallah@pidgin.im>
parents:
12760
diff
changeset
|
62 | rand() & 0xFFFF, rand() & 0xFFFF); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
63 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
64 | |
| 15884 | 65 | static const char *simple_list_icon(PurpleAccount *a, PurpleBuddy *b) { |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
66 | return "simple"; |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
67 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
68 | |
| 15884 | 69 | static void simple_keep_alive(PurpleConnection *gc) { |
|
32266
af94a3153685
Convert simple prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
70 | struct simple_account_data *sip = purple_connection_get_protocol_data(gc); |
|
11341
5511bbeeb3b4
[gaim-migrate @ 13555]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11327
diff
changeset
|
71 | if(sip->udp) { /* in case of UDP send a packet only with a 0 byte to |
|
5511bbeeb3b4
[gaim-migrate @ 13555]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11327
diff
changeset
|
72 | remain in the NAT table */ |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
73 | gchar buf[2] = {0, 0}; |
| 15884 | 74 | purple_debug_info("simple", "sending keep alive\n"); |
|
11194
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
75 | sendto(sip->fd, buf, 1, 0, (struct sockaddr*)&sip->serveraddr, sizeof(struct sockaddr_in)); |
|
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
76 | } |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
77 | return; |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
78 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
79 | |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
80 | static gboolean process_register_response(struct simple_account_data *sip, struct sipmsg *msg, struct transaction *tc); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
81 | static void send_notify(struct simple_account_data *sip, struct simple_watcher *); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
82 | |
|
20988
75eab0f2aa19
Patch from Will Hawkins to publish a status of closed when signing out of a SIMPLE account. Fixes #1914.
Daniel Atallah <datallah@pidgin.im>
parents:
20658
diff
changeset
|
83 | static void send_open_publish(struct simple_account_data *sip); |
|
75eab0f2aa19
Patch from Will Hawkins to publish a status of closed when signing out of a SIMPLE account. Fixes #1914.
Daniel Atallah <datallah@pidgin.im>
parents:
20658
diff
changeset
|
84 | static void send_closed_publish(struct simple_account_data *sip); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
85 | |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
86 | static void do_notifies(struct simple_account_data *sip) { |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
87 | GSList *tmp = sip->watcher; |
| 15884 | 88 | purple_debug_info("simple", "do_notifies()\n"); |
|
11345
48a2f93e47b6
[gaim-migrate @ 13562]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11341
diff
changeset
|
89 | if((sip->republish != -1) || sip->republish < time(NULL)) { |
| 15884 | 90 | if(purple_account_get_bool(sip->account, "dopublish", TRUE)) { |
|
20988
75eab0f2aa19
Patch from Will Hawkins to publish a status of closed when signing out of a SIMPLE account. Fixes #1914.
Daniel Atallah <datallah@pidgin.im>
parents:
20658
diff
changeset
|
91 | send_open_publish(sip); |
|
11345
48a2f93e47b6
[gaim-migrate @ 13562]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11341
diff
changeset
|
92 | } |
|
48a2f93e47b6
[gaim-migrate @ 13562]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11341
diff
changeset
|
93 | } |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
94 | |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
95 | while(tmp) { |
| 15884 | 96 | purple_debug_info("simple", "notifying %s\n", ((struct simple_watcher*)tmp->data)->name); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
97 | send_notify(sip, tmp->data); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
98 | tmp = tmp->next; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
99 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
100 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
101 | |
| 15884 | 102 | static void simple_set_status(PurpleAccount *account, PurpleStatus *status) { |
|
32266
af94a3153685
Convert simple prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
103 | PurpleConnection *gc = purple_account_get_connection(account); |
| 15884 | 104 | PurpleStatusPrimitive primitive = purple_status_type_get_primitive(purple_status_get_type(status)); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
105 | struct simple_account_data *sip = NULL; |
|
11718
90804d019837
[gaim-migrate @ 14009]
Mark Doliner <markdoliner@pidgin.im>
parents:
11658
diff
changeset
|
106 | |
| 15884 | 107 | if (!purple_status_is_active(status)) |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
108 | return; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
109 | |
|
32266
af94a3153685
Convert simple prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
110 | if (gc) |
|
af94a3153685
Convert simple prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
111 | sip = purple_connection_get_protocol_data(gc); |
|
11718
90804d019837
[gaim-migrate @ 14009]
Mark Doliner <markdoliner@pidgin.im>
parents:
11658
diff
changeset
|
112 | |
|
90804d019837
[gaim-migrate @ 14009]
Mark Doliner <markdoliner@pidgin.im>
parents:
11658
diff
changeset
|
113 | if (sip) |
|
90804d019837
[gaim-migrate @ 14009]
Mark Doliner <markdoliner@pidgin.im>
parents:
11658
diff
changeset
|
114 | { |
|
11650
757d7fbd4ca9
[gaim-migrate @ 13931]
Mark Doliner <markdoliner@pidgin.im>
parents:
11522
diff
changeset
|
115 | g_free(sip->status); |
| 15884 | 116 | if (primitive == PURPLE_STATUS_AVAILABLE) |
|
11718
90804d019837
[gaim-migrate @ 14009]
Mark Doliner <markdoliner@pidgin.im>
parents:
11658
diff
changeset
|
117 | sip->status = g_strdup("available"); |
|
90804d019837
[gaim-migrate @ 14009]
Mark Doliner <markdoliner@pidgin.im>
parents:
11658
diff
changeset
|
118 | else |
|
90804d019837
[gaim-migrate @ 14009]
Mark Doliner <markdoliner@pidgin.im>
parents:
11658
diff
changeset
|
119 | sip->status = g_strdup("busy"); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
120 | |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
121 | do_notifies(sip); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
122 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
123 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
124 | |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
125 | static struct sip_connection *connection_find(struct simple_account_data *sip, int fd) { |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
126 | struct sip_connection *ret = NULL; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
127 | GSList *entry = sip->openconns; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
128 | while(entry) { |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
129 | ret = entry->data; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
130 | if(ret->fd == fd) return ret; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
131 | entry = entry->next; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
132 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
133 | return NULL; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
134 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
135 | |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
136 | static struct simple_watcher *watcher_find(struct simple_account_data *sip, |
|
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
137 | const gchar *name) { |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
138 | struct simple_watcher *watcher; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
139 | GSList *entry = sip->watcher; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
140 | while(entry) { |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
141 | watcher = entry->data; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
142 | if(!strcmp(name, watcher->name)) return watcher; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
143 | entry = entry->next; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
144 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
145 | return NULL; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
146 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
147 | |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
148 | static struct simple_watcher *watcher_create(struct simple_account_data *sip, |
|
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
149 | const gchar *name, const gchar *callid, const gchar *ourtag, |
|
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
150 | const gchar *theirtag, gboolean needsxpidf) { |
|
13093
e27434c31f00
[gaim-migrate @ 15454]
Daniel Atallah <datallah@pidgin.im>
parents:
13089
diff
changeset
|
151 | struct simple_watcher *watcher = g_new0(struct simple_watcher, 1); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
152 | watcher->name = g_strdup(name); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
153 | watcher->dialog.callid = g_strdup(callid); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
154 | watcher->dialog.ourtag = g_strdup(ourtag); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
155 | watcher->dialog.theirtag = g_strdup(theirtag); |
|
13178
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
156 | watcher->needsxpidf = needsxpidf; |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
157 | sip->watcher = g_slist_append(sip->watcher, watcher); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
158 | return watcher; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
159 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
160 | |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
161 | static void watcher_remove(struct simple_account_data *sip, const gchar *name) { |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
162 | struct simple_watcher *watcher = watcher_find(sip, name); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
163 | sip->watcher = g_slist_remove(sip->watcher, watcher); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
164 | g_free(watcher->name); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
165 | g_free(watcher->dialog.callid); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
166 | g_free(watcher->dialog.ourtag); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
167 | g_free(watcher->dialog.theirtag); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
168 | g_free(watcher); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
169 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
170 | |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
171 | static struct sip_connection *connection_create(struct simple_account_data *sip, int fd) { |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
172 | struct sip_connection *ret = g_new0(struct sip_connection, 1); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
173 | ret->fd = fd; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
174 | sip->openconns = g_slist_append(sip->openconns, ret); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
175 | return ret; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
176 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
177 | |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
178 | static void connection_remove(struct simple_account_data *sip, int fd) { |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
179 | struct sip_connection *conn = connection_find(sip, fd); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
180 | sip->openconns = g_slist_remove(sip->openconns, conn); |
| 15884 | 181 | if(conn->inputhandler) purple_input_remove(conn->inputhandler); |
|
11650
757d7fbd4ca9
[gaim-migrate @ 13931]
Mark Doliner <markdoliner@pidgin.im>
parents:
11522
diff
changeset
|
182 | g_free(conn->inbuf); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
183 | g_free(conn); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
184 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
185 | |
|
11346
4af1dc4b2c44
[gaim-migrate @ 13563]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11345
diff
changeset
|
186 | static void connection_free_all(struct simple_account_data *sip) { |
|
4af1dc4b2c44
[gaim-migrate @ 13563]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11345
diff
changeset
|
187 | struct sip_connection *ret = NULL; |
|
4af1dc4b2c44
[gaim-migrate @ 13563]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11345
diff
changeset
|
188 | GSList *entry = sip->openconns; |
|
4af1dc4b2c44
[gaim-migrate @ 13563]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11345
diff
changeset
|
189 | while(entry) { |
|
4af1dc4b2c44
[gaim-migrate @ 13563]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11345
diff
changeset
|
190 | ret = entry->data; |
|
4af1dc4b2c44
[gaim-migrate @ 13563]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11345
diff
changeset
|
191 | connection_remove(sip, ret->fd); |
|
4af1dc4b2c44
[gaim-migrate @ 13563]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11345
diff
changeset
|
192 | entry = sip->openconns; |
|
4af1dc4b2c44
[gaim-migrate @ 13563]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11345
diff
changeset
|
193 | } |
|
4af1dc4b2c44
[gaim-migrate @ 13563]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11345
diff
changeset
|
194 | } |
|
4af1dc4b2c44
[gaim-migrate @ 13563]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11345
diff
changeset
|
195 | |
|
32315
2550a39e0285
Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32300
diff
changeset
|
196 | static void simple_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group, const char *message) |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
197 | { |
|
32266
af94a3153685
Convert simple prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
198 | struct simple_account_data *sip = purple_connection_get_protocol_data(gc); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
199 | struct simple_buddy *b; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24040
diff
changeset
|
200 | const char *name = purple_buddy_get_name(buddy); |
|
25911
f22097dc8413
propagate from branch 'im.pidgin.pidgin.next.minor' (head d24c4a9d28f21eaa47bd76e50ed31053733edcb1)
Elliott Sales de Andrade <qulogic@pidgin.im>
diff
changeset
|
201 | if(strncmp(name, "sip:", 4)) { |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24040
diff
changeset
|
202 | gchar *buf = g_strdup_printf("sip:%s", name); |
| 15884 | 203 | purple_blist_rename_buddy(buddy, buf); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
204 | g_free(buf); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
205 | } |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24040
diff
changeset
|
206 | if(!g_hash_table_lookup(sip->buddies, name)) { |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
207 | b = g_new0(struct simple_buddy, 1); |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24040
diff
changeset
|
208 | purple_debug_info("simple", "simple_add_buddy %s\n", name); |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24040
diff
changeset
|
209 | b->name = g_strdup(name); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
210 | g_hash_table_insert(sip->buddies, b->name, b); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
211 | } else { |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24040
diff
changeset
|
212 | purple_debug_info("simple", "buddy %s already in internal list\n", name); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
213 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
214 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
215 | |
| 15884 | 216 | static void simple_get_buddies(PurpleConnection *gc) { |
|
27199
ab2af9d15cba
Use purple_find_buddies() instead of iterating the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
26482
diff
changeset
|
217 | GSList *buddies; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24040
diff
changeset
|
218 | PurpleAccount *account; |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
219 | |
| 15884 | 220 | purple_debug_info("simple", "simple_get_buddies\n"); |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
221 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24040
diff
changeset
|
222 | account = purple_connection_get_account(gc); |
|
27199
ab2af9d15cba
Use purple_find_buddies() instead of iterating the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
26482
diff
changeset
|
223 | buddies = purple_find_buddies(account, NULL); |
|
ab2af9d15cba
Use purple_find_buddies() instead of iterating the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
26482
diff
changeset
|
224 | while (buddies) { |
|
ab2af9d15cba
Use purple_find_buddies() instead of iterating the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
26482
diff
changeset
|
225 | PurpleBuddy *buddy = buddies->data; |
|
32315
2550a39e0285
Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32300
diff
changeset
|
226 | simple_add_buddy(gc, buddy, purple_buddy_get_group(buddy), NULL); |
|
27199
ab2af9d15cba
Use purple_find_buddies() instead of iterating the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
26482
diff
changeset
|
227 | |
|
ab2af9d15cba
Use purple_find_buddies() instead of iterating the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
26482
diff
changeset
|
228 | buddies = g_slist_delete_link(buddies, buddies); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
229 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
230 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
231 | |
| 15884 | 232 | static void simple_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
233 | { |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24040
diff
changeset
|
234 | const char *name = purple_buddy_get_name(buddy); |
|
32266
af94a3153685
Convert simple prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
235 | struct simple_account_data *sip = purple_connection_get_protocol_data(gc); |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24040
diff
changeset
|
236 | struct simple_buddy *b = g_hash_table_lookup(sip->buddies, name); |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24040
diff
changeset
|
237 | g_hash_table_remove(sip->buddies, name); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
238 | g_free(b->name); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
239 | g_free(b); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
240 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
241 | |
| 15884 | 242 | static GList *simple_status_types(PurpleAccount *acc) { |
| 243 | PurpleStatusType *type; | |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
244 | GList *types = NULL; |
|
12456
94b229fc8203
[gaim-migrate @ 14765]
Mark Doliner <markdoliner@pidgin.im>
parents:
12389
diff
changeset
|
245 | |
| 15884 | 246 | type = purple_status_type_new_with_attrs( |
| 247 | PURPLE_STATUS_AVAILABLE, NULL, NULL, TRUE, TRUE, FALSE, | |
| 248 | "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), | |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12571
diff
changeset
|
249 | NULL); |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
250 | types = g_list_append(types, type); |
|
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
251 | |
| 15884 | 252 | type = purple_status_type_new_full( |
| 253 | PURPLE_STATUS_OFFLINE, NULL, NULL, TRUE, TRUE, FALSE); | |
|
12657
fd16423a0383
[gaim-migrate @ 15000]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
254 | types = g_list_append(types, type); |
|
fd16423a0383
[gaim-migrate @ 15000]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
255 | |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
256 | return types; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
257 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
258 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
259 | static gchar *auth_header(struct simple_account_data *sip, |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
260 | struct sip_auth *auth, const gchar *method, const gchar *target) { |
|
11346
4af1dc4b2c44
[gaim-migrate @ 13563]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11345
diff
changeset
|
261 | gchar noncecount[9]; |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
262 | gchar *response; |
|
11346
4af1dc4b2c44
[gaim-migrate @ 13563]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11345
diff
changeset
|
263 | gchar *ret; |
|
11409
2a3466f4a32c
[gaim-migrate @ 13646]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11396
diff
changeset
|
264 | gchar *tmp; |
|
13089
e1ab8bfba211
[gaim-migrate @ 15450]
Mark Doliner <markdoliner@pidgin.im>
parents:
13086
diff
changeset
|
265 | const char *authdomain; |
|
e1ab8bfba211
[gaim-migrate @ 15450]
Mark Doliner <markdoliner@pidgin.im>
parents:
13086
diff
changeset
|
266 | const char *authuser; |
|
e1ab8bfba211
[gaim-migrate @ 15450]
Mark Doliner <markdoliner@pidgin.im>
parents:
13086
diff
changeset
|
267 | |
| 15884 | 268 | authdomain = purple_account_get_string(sip->account, "authdomain", ""); |
| 269 | authuser = purple_account_get_string(sip->account, "authuser", sip->username); | |
|
13089
e1ab8bfba211
[gaim-migrate @ 15450]
Mark Doliner <markdoliner@pidgin.im>
parents:
13086
diff
changeset
|
270 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
271 | if(!authuser || strlen(authuser) < 1) { |
|
13085
c80913901342
[gaim-migrate @ 15446]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13084
diff
changeset
|
272 | authuser = sip->username; |
|
c80913901342
[gaim-migrate @ 15446]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13084
diff
changeset
|
273 | } |
|
11409
2a3466f4a32c
[gaim-migrate @ 13646]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11396
diff
changeset
|
274 | |
|
2a3466f4a32c
[gaim-migrate @ 13646]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11396
diff
changeset
|
275 | if(auth->type == 1) { /* Digest */ |
|
2a3466f4a32c
[gaim-migrate @ 13646]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11396
diff
changeset
|
276 | sprintf(noncecount, "%08d", auth->nc++); |
| 15884 | 277 | response = purple_cipher_http_digest_calculate_response( |
|
12389
7196ba664097
[gaim-migrate @ 14695]
Richard Laager <rlaager@pidgin.im>
parents:
12382
diff
changeset
|
278 | "md5", method, target, NULL, NULL, |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
279 | auth->nonce, noncecount, NULL, auth->digest_session_key); |
| 15884 | 280 | purple_debug(PURPLE_DEBUG_MISC, "simple", "response %s\n", response); |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
281 | |
|
17187
78b7ae95ad45
Fix an extra \r\n in the Authorization header. Fixes #965.
Daniel Atallah <datallah@pidgin.im>
parents:
17185
diff
changeset
|
282 | ret = g_strdup_printf("Digest username=\"%s\", realm=\"%s\", nonce=\"%s\", uri=\"%s\", nc=\"%s\", response=\"%s\"", authuser, auth->realm, auth->nonce, target, noncecount, response); |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
283 | g_free(response); |
|
11409
2a3466f4a32c
[gaim-migrate @ 13646]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11396
diff
changeset
|
284 | return ret; |
|
2a3466f4a32c
[gaim-migrate @ 13646]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11396
diff
changeset
|
285 | } else if(auth->type == 2) { /* NTLM */ |
|
13085
c80913901342
[gaim-migrate @ 15446]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13084
diff
changeset
|
286 | if(auth->nc == 3 && auth->nonce) { |
| 15884 | 287 | /* TODO: Don't hardcode "purple" as the hostname */ |
| 288 | ret = purple_ntlm_gen_type3(authuser, sip->password, "purple", authdomain, (const guint8 *)auth->nonce, &auth->flags); | |
|
17187
78b7ae95ad45
Fix an extra \r\n in the Authorization header. Fixes #965.
Daniel Atallah <datallah@pidgin.im>
parents:
17185
diff
changeset
|
289 | tmp = g_strdup_printf("NTLM qop=\"auth\", opaque=\"%s\", realm=\"%s\", targetname=\"%s\", gssapi-data=\"%s\"", auth->opaque, auth->realm, auth->target, ret); |
|
11409
2a3466f4a32c
[gaim-migrate @ 13646]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11396
diff
changeset
|
290 | g_free(ret); |
|
2a3466f4a32c
[gaim-migrate @ 13646]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11396
diff
changeset
|
291 | return tmp; |
|
2a3466f4a32c
[gaim-migrate @ 13646]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11396
diff
changeset
|
292 | } |
|
17187
78b7ae95ad45
Fix an extra \r\n in the Authorization header. Fixes #965.
Daniel Atallah <datallah@pidgin.im>
parents:
17185
diff
changeset
|
293 | tmp = g_strdup_printf("NTLM qop=\"auth\", realm=\"%s\", targetname=\"%s\", gssapi-data=\"\"", auth->realm, auth->target); |
|
11409
2a3466f4a32c
[gaim-migrate @ 13646]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11396
diff
changeset
|
294 | return tmp; |
|
2a3466f4a32c
[gaim-migrate @ 13646]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11396
diff
changeset
|
295 | } |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
296 | |
|
11346
4af1dc4b2c44
[gaim-migrate @ 13563]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11345
diff
changeset
|
297 | sprintf(noncecount, "%08d", auth->nc++); |
| 15884 | 298 | response = purple_cipher_http_digest_calculate_response( |
|
12389
7196ba664097
[gaim-migrate @ 14695]
Richard Laager <rlaager@pidgin.im>
parents:
12382
diff
changeset
|
299 | "md5", method, target, NULL, NULL, |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
300 | auth->nonce, noncecount, NULL, auth->digest_session_key); |
| 15884 | 301 | purple_debug(PURPLE_DEBUG_MISC, "simple", "response %s\n", response); |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
302 | |
|
17187
78b7ae95ad45
Fix an extra \r\n in the Authorization header. Fixes #965.
Daniel Atallah <datallah@pidgin.im>
parents:
17185
diff
changeset
|
303 | ret = g_strdup_printf("Digest username=\"%s\", realm=\"%s\", nonce=\"%s\", uri=\"%s\", nc=\"%s\", response=\"%s\"", authuser, auth->realm, auth->nonce, target, noncecount, response); |
|
12382
5ef67596b420
[gaim-migrate @ 14688]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
304 | g_free(response); |
|
11346
4af1dc4b2c44
[gaim-migrate @ 13563]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11345
diff
changeset
|
305 | return ret; |
|
4af1dc4b2c44
[gaim-migrate @ 13563]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11345
diff
changeset
|
306 | } |
|
4af1dc4b2c44
[gaim-migrate @ 13563]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11345
diff
changeset
|
307 | |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
308 | static char *parse_attribute(const char *attrname, const char *source) { |
|
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
309 | const char *tmp, *tmp2; |
|
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
310 | char *retval = NULL; |
|
12746
7ee4a8a55435
[gaim-migrate @ 15093]
Daniel Atallah <datallah@pidgin.im>
parents:
12745
diff
changeset
|
311 | int len = strlen(attrname); |
|
7ee4a8a55435
[gaim-migrate @ 15093]
Daniel Atallah <datallah@pidgin.im>
parents:
12745
diff
changeset
|
312 | |
|
23086
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
313 | /* we know that source is NULL-terminated. |
|
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
314 | * Therefore this loop won't be infinite. |
|
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
315 | */ |
|
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
316 | while (source[0] == ' ') |
|
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
317 | source++; |
|
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
318 | |
|
12746
7ee4a8a55435
[gaim-migrate @ 15093]
Daniel Atallah <datallah@pidgin.im>
parents:
12745
diff
changeset
|
319 | if(!strncmp(source, attrname, len)) { |
|
7ee4a8a55435
[gaim-migrate @ 15093]
Daniel Atallah <datallah@pidgin.im>
parents:
12745
diff
changeset
|
320 | tmp = source + len; |
|
7ee4a8a55435
[gaim-migrate @ 15093]
Daniel Atallah <datallah@pidgin.im>
parents:
12745
diff
changeset
|
321 | tmp2 = g_strstr_len(tmp, strlen(tmp), "\""); |
|
7ee4a8a55435
[gaim-migrate @ 15093]
Daniel Atallah <datallah@pidgin.im>
parents:
12745
diff
changeset
|
322 | if(tmp2) |
|
7ee4a8a55435
[gaim-migrate @ 15093]
Daniel Atallah <datallah@pidgin.im>
parents:
12745
diff
changeset
|
323 | retval = g_strndup(tmp, tmp2 - tmp); |
|
13086
0e5a0a33475b
[gaim-migrate @ 15447]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13085
diff
changeset
|
324 | else |
|
0e5a0a33475b
[gaim-migrate @ 15447]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13085
diff
changeset
|
325 | retval = g_strdup(tmp); |
|
12746
7ee4a8a55435
[gaim-migrate @ 15093]
Daniel Atallah <datallah@pidgin.im>
parents:
12745
diff
changeset
|
326 | } |
|
7ee4a8a55435
[gaim-migrate @ 15093]
Daniel Atallah <datallah@pidgin.im>
parents:
12745
diff
changeset
|
327 | |
|
7ee4a8a55435
[gaim-migrate @ 15093]
Daniel Atallah <datallah@pidgin.im>
parents:
12745
diff
changeset
|
328 | return retval; |
|
7ee4a8a55435
[gaim-migrate @ 15093]
Daniel Atallah <datallah@pidgin.im>
parents:
12745
diff
changeset
|
329 | } |
|
7ee4a8a55435
[gaim-migrate @ 15093]
Daniel Atallah <datallah@pidgin.im>
parents:
12745
diff
changeset
|
330 | |
|
21100
814637ced463
Some constification, which also found and fixed some potential double-free
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21076
diff
changeset
|
331 | static void fill_auth(struct simple_account_data *sip, const gchar *hdr, struct sip_auth *auth) { |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
332 | int i = 0; |
|
13089
e1ab8bfba211
[gaim-migrate @ 15450]
Mark Doliner <markdoliner@pidgin.im>
parents:
13086
diff
changeset
|
333 | const char *authuser; |
|
11424
b0f8535daa74
[gaim-migrate @ 13661]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11409
diff
changeset
|
334 | char *tmp; |
|
11439
e76bc2f9deb0
[gaim-migrate @ 13676]
Daniel Atallah <datallah@pidgin.im>
parents:
11424
diff
changeset
|
335 | gchar **parts; |
|
13085
c80913901342
[gaim-migrate @ 15446]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13084
diff
changeset
|
336 | |
| 15884 | 337 | authuser = purple_account_get_string(sip->account, "authuser", sip->username); |
|
13089
e1ab8bfba211
[gaim-migrate @ 15450]
Mark Doliner <markdoliner@pidgin.im>
parents:
13086
diff
changeset
|
338 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
339 | if(!authuser || strlen(authuser) < 1) { |
|
13085
c80913901342
[gaim-migrate @ 15446]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13084
diff
changeset
|
340 | authuser = sip->username; |
|
c80913901342
[gaim-migrate @ 15446]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13084
diff
changeset
|
341 | } |
|
13089
e1ab8bfba211
[gaim-migrate @ 15450]
Mark Doliner <markdoliner@pidgin.im>
parents:
13086
diff
changeset
|
342 | |
|
11346
4af1dc4b2c44
[gaim-migrate @ 13563]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11345
diff
changeset
|
343 | if(!hdr) { |
| 15884 | 344 | purple_debug_error("simple", "fill_auth: hdr==NULL\n"); |
|
11346
4af1dc4b2c44
[gaim-migrate @ 13563]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11345
diff
changeset
|
345 | return; |
|
4af1dc4b2c44
[gaim-migrate @ 13563]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11345
diff
changeset
|
346 | } |
|
11409
2a3466f4a32c
[gaim-migrate @ 13646]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11396
diff
changeset
|
347 | |
|
18552
810a338ef085
Use the glib strcasecmp functions everywhere, as we've had reports of
Richard Laager <rlaager@pidgin.im>
parents:
17653
diff
changeset
|
348 | if(!g_ascii_strncasecmp(hdr, "NTLM", 4)) { |
| 15884 | 349 | purple_debug_info("simple", "found NTLM\n"); |
|
11409
2a3466f4a32c
[gaim-migrate @ 13646]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11396
diff
changeset
|
350 | auth->type = 2; |
|
23086
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
351 | parts = g_strsplit(hdr+5, "\",", 0); |
|
13348
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
352 | i = 0; |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
353 | while(parts[i]) { |
| 15884 | 354 | purple_debug_info("simple", "parts[i] %s\n", parts[i]); |
|
13348
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
355 | if((tmp = parse_attribute("gssapi-data=\"", parts[i]))) { |
| 15884 | 356 | auth->nonce = g_memdup(purple_ntlm_parse_type2(tmp, &auth->flags), 8); |
|
13348
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
357 | g_free(tmp); |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
358 | } |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
359 | if((tmp = parse_attribute("targetname=\"", |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
360 | parts[i]))) { |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
361 | auth->target = tmp; |
|
11424
b0f8535daa74
[gaim-migrate @ 13661]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11409
diff
changeset
|
362 | } |
|
13348
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
363 | else if((tmp = parse_attribute("realm=\"", |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
364 | parts[i]))) { |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
365 | auth->realm = tmp; |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
366 | } |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
367 | else if((tmp = parse_attribute("opaque=\"", parts[i]))) { |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
368 | auth->opaque = tmp; |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
369 | } |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
370 | i++; |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
371 | } |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
372 | g_strfreev(parts); |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
373 | auth->nc = 1; |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
374 | if(!strstr(hdr, "gssapi-data")) { |
|
11409
2a3466f4a32c
[gaim-migrate @ 13646]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11396
diff
changeset
|
375 | auth->nc = 1; |
|
13085
c80913901342
[gaim-migrate @ 15446]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13084
diff
changeset
|
376 | } else { |
|
11409
2a3466f4a32c
[gaim-migrate @ 13646]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11396
diff
changeset
|
377 | auth->nc = 3; |
|
23086
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
378 | } |
|
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
379 | |
|
11409
2a3466f4a32c
[gaim-migrate @ 13646]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11396
diff
changeset
|
380 | return; |
|
23086
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
381 | } else if(!g_ascii_strncasecmp(hdr, "DIGEST", 6)) { |
|
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
382 | |
|
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
383 | purple_debug_info("simple", "found DIGEST\n"); |
|
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
384 | |
|
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
385 | auth->type = 1; |
|
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
386 | parts = g_strsplit(hdr+7, ",", 0); |
|
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
387 | while(parts[i]) { |
|
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
388 | if((tmp = parse_attribute("nonce=\"", parts[i]))) { |
|
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
389 | auth->nonce = tmp; |
|
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
390 | } |
|
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
391 | else if((tmp = parse_attribute("realm=\"", parts[i]))) { |
|
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
392 | auth->realm = tmp; |
|
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
393 | } |
|
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
394 | i++; |
|
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
395 | } |
|
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
396 | g_strfreev(parts); |
|
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
397 | purple_debug(PURPLE_DEBUG_MISC, "simple", "nonce: %s realm: %s\n", |
|
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
398 | auth->nonce ? auth->nonce : "(null)", |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
399 | auth->realm ? auth->realm : "(null)"); |
|
23086
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
400 | |
|
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
401 | if(auth->realm) { |
|
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
402 | auth->digest_session_key = purple_cipher_http_digest_calculate_session_key( |
|
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
403 | "md5", authuser, auth->realm, sip->password, auth->nonce, NULL); |
|
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
404 | |
|
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
405 | auth->nc = 1; |
|
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
406 | } |
|
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
407 | |
|
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
408 | } else { |
|
413ccc075f8b
Patch from Will Hawkins to fix SIMPLE authentication on some servers.
Daniel Atallah <datallah@pidgin.im>
parents:
22942
diff
changeset
|
409 | purple_debug_error("simple", "Unsupported or bad WWW-Authenticate header (%s).\n", hdr); |
|
11409
2a3466f4a32c
[gaim-migrate @ 13646]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11396
diff
changeset
|
410 | } |
|
2a3466f4a32c
[gaim-migrate @ 13646]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11396
diff
changeset
|
411 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
412 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
413 | |
| 15884 | 414 | static void simple_canwrite_cb(gpointer data, gint source, PurpleInputCondition cond) { |
| 415 | PurpleConnection *gc = data; | |
|
32266
af94a3153685
Convert simple prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
416 | struct simple_account_data *sip = purple_connection_get_protocol_data(gc); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
417 | gsize max_write; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
418 | gssize written; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
419 | |
| 15884 | 420 | max_write = purple_circ_buffer_get_max_read(sip->txbuf); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
421 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
422 | if(max_write == 0) { |
| 15884 | 423 | purple_input_remove(sip->tx_handler); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
424 | sip->tx_handler = 0; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
425 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
426 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
427 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
428 | written = write(sip->fd, sip->txbuf->outptr, max_write); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
429 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
430 | if(written < 0 && errno == EAGAIN) |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
431 | written = 0; |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27350
diff
changeset
|
432 | else if (written <= 0) { |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
433 | /*TODO: do we really want to disconnect on a failure to write?*/ |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27350
diff
changeset
|
434 | gchar *tmp = g_strdup_printf(_("Lost connection with server: %s"), |
|
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27350
diff
changeset
|
435 | g_strerror(errno)); |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31949
diff
changeset
|
436 | purple_connection_error(gc, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27350
diff
changeset
|
437 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); |
|
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27350
diff
changeset
|
438 | g_free(tmp); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
439 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
440 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
441 | |
| 15884 | 442 | purple_circ_buffer_mark_read(sip->txbuf, written); |
|
11346
4af1dc4b2c44
[gaim-migrate @ 13563]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11345
diff
changeset
|
443 | } |
|
4af1dc4b2c44
[gaim-migrate @ 13563]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11345
diff
changeset
|
444 | |
| 15884 | 445 | static void simple_input_cb(gpointer data, gint source, PurpleInputCondition cond); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
446 | |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27350
diff
changeset
|
447 | static void send_later_cb(gpointer data, gint source, const gchar *error_message) { |
| 15884 | 448 | PurpleConnection *gc = data; |
|
14180
77010795da2c
[gaim-migrate @ 16752]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
449 | struct simple_account_data *sip; |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
450 | struct sip_connection *conn; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
451 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
452 | if(source < 0) { |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27350
diff
changeset
|
453 | gchar *tmp = g_strdup_printf(_("Unable to connect: %s"), |
|
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27350
diff
changeset
|
454 | error_message); |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31949
diff
changeset
|
455 | purple_connection_error(gc, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27350
diff
changeset
|
456 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); |
|
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27350
diff
changeset
|
457 | g_free(tmp); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
458 | return; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
459 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
460 | |
|
32266
af94a3153685
Convert simple prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
461 | sip = purple_connection_get_protocol_data(gc); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
462 | sip->fd = source; |
|
13058
2bf79aa07199
[gaim-migrate @ 15420]
Daniel Atallah <datallah@pidgin.im>
parents:
12909
diff
changeset
|
463 | sip->connecting = FALSE; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
464 | |
| 15884 | 465 | simple_canwrite_cb(gc, sip->fd, PURPLE_INPUT_WRITE); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
466 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
467 | /* If there is more to write now, we need to register a handler */ |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
468 | if(sip->txbuf->bufused > 0) |
| 15884 | 469 | sip->tx_handler = purple_input_add(sip->fd, PURPLE_INPUT_WRITE, |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
470 | simple_canwrite_cb, gc); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
471 | |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
472 | conn = connection_create(sip, source); |
| 15884 | 473 | conn->inputhandler = purple_input_add(sip->fd, PURPLE_INPUT_READ, simple_input_cb, gc); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
474 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
475 | |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
476 | |
| 15884 | 477 | static void sendlater(PurpleConnection *gc, const char *buf) { |
|
32266
af94a3153685
Convert simple prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
478 | struct simple_account_data *sip = purple_connection_get_protocol_data(gc); |
|
14151
34427f138b1f
[gaim-migrate @ 16712]
Mark Doliner <markdoliner@pidgin.im>
parents:
14132
diff
changeset
|
479 | |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
480 | if(!sip->connecting) { |
| 15884 | 481 | purple_debug_info("simple", "connecting to %s port %d\n", sip->realhostname ? sip->realhostname : "{NULL}", sip->realport); |
| 482 | if (purple_proxy_connect(gc, sip->account, sip->realhostname, sip->realport, send_later_cb, gc) == NULL) { | |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31949
diff
changeset
|
483 | purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _("Unable to connect")); |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
484 | } |
|
13058
2bf79aa07199
[gaim-migrate @ 15420]
Daniel Atallah <datallah@pidgin.im>
parents:
12909
diff
changeset
|
485 | sip->connecting = TRUE; |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
486 | } |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
487 | |
| 15884 | 488 | if(purple_circ_buffer_get_max_read(sip->txbuf) > 0) |
| 489 | purple_circ_buffer_append(sip->txbuf, "\r\n", 2); | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
490 | |
| 15884 | 491 | purple_circ_buffer_append(sip->txbuf, buf, strlen(buf)); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
492 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
493 | |
| 15884 | 494 | static void sendout_pkt(PurpleConnection *gc, const char *buf) { |
|
32266
af94a3153685
Convert simple prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
495 | struct simple_account_data *sip = purple_connection_get_protocol_data(gc); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
496 | time_t currtime = time(NULL); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
497 | int writelen = strlen(buf); |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
498 | |
| 15884 | 499 | purple_debug(PURPLE_DEBUG_MISC, "simple", "\n\nsending - %s\n######\n%s\n######\n\n", ctime(&currtime), buf); |
|
11189
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
500 | if(sip->udp) { |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
501 | if(sendto(sip->fd, buf, writelen, 0, (struct sockaddr*)&sip->serveraddr, sizeof(struct sockaddr_in)) < writelen) { |
| 15884 | 502 | purple_debug_info("simple", "could not send packet\n"); |
|
11189
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
503 | } |
|
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
504 | } else { |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
505 | int ret; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
506 | if(sip->fd < 0) { |
|
11189
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
507 | sendlater(gc, buf); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
508 | return; |
|
11189
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
509 | } |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
510 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
511 | if(sip->tx_handler) { |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
512 | ret = -1; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
513 | errno = EAGAIN; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
514 | } else |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
515 | ret = write(sip->fd, buf, writelen); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
516 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
517 | if (ret < 0 && errno == EAGAIN) |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
518 | ret = 0; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
519 | else if(ret <= 0) { /* XXX: When does this happen legitimately? */ |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
520 | sendlater(gc, buf); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
521 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
522 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
523 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
524 | if (ret < writelen) { |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
525 | if(!sip->tx_handler) |
| 15884 | 526 | sip->tx_handler = purple_input_add(sip->fd, |
| 527 | PURPLE_INPUT_WRITE, simple_canwrite_cb, | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
528 | gc); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
529 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
530 | /* XXX: is it OK to do this? You might get part of a request sent |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
531 | with part of another. */ |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
532 | if(sip->txbuf->bufused > 0) |
| 15884 | 533 | purple_circ_buffer_append(sip->txbuf, "\r\n", 2); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
534 | |
| 15884 | 535 | purple_circ_buffer_append(sip->txbuf, buf + ret, |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
536 | writelen - ret); |
|
11189
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
537 | } |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
538 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
539 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
540 | |
| 15884 | 541 | static int simple_send_raw(PurpleConnection *gc, const char *buf, int len) |
| 14604 | 542 | { |
| 543 | sendout_pkt(gc, buf); | |
| 544 | return len; | |
| 545 | } | |
| 546 | ||
|
11194
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
547 | static void sendout_sipmsg(struct simple_account_data *sip, struct sipmsg *msg) { |
|
12741
14cd04e157b1
[gaim-migrate @ 15088]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
548 | GSList *tmp = msg->headers; |
|
11194
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
549 | gchar *name; |
|
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
550 | gchar *value; |
|
12741
14cd04e157b1
[gaim-migrate @ 15088]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
551 | GString *outstr = g_string_new(""); |
|
14cd04e157b1
[gaim-migrate @ 15088]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
552 | g_string_append_printf(outstr, "%s %s SIP/2.0\r\n", msg->method, msg->target); |
|
11194
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
553 | while(tmp) { |
|
12741
14cd04e157b1
[gaim-migrate @ 15088]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
554 | name = ((struct siphdrelement*) (tmp->data))->name; |
|
14cd04e157b1
[gaim-migrate @ 15088]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
555 | value = ((struct siphdrelement*) (tmp->data))->value; |
|
14cd04e157b1
[gaim-migrate @ 15088]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
556 | g_string_append_printf(outstr, "%s: %s\r\n", name, value); |
|
11194
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
557 | tmp = g_slist_next(tmp); |
|
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
558 | } |
|
12741
14cd04e157b1
[gaim-migrate @ 15088]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
559 | g_string_append_printf(outstr, "\r\n%s", msg->body ? msg->body : ""); |
|
14cd04e157b1
[gaim-migrate @ 15088]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
560 | sendout_pkt(sip->gc, outstr->str); |
|
14cd04e157b1
[gaim-migrate @ 15088]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
561 | g_string_free(outstr, TRUE); |
|
11194
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
562 | } |
|
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
563 | |
| 15884 | 564 | static void send_sip_response(PurpleConnection *gc, struct sipmsg *msg, int code, |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
565 | const char *text, const char *body) { |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
566 | GSList *tmp = msg->headers; |
|
12741
14cd04e157b1
[gaim-migrate @ 15088]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
567 | gchar *name; |
|
14cd04e157b1
[gaim-migrate @ 15088]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
568 | gchar *value; |
|
14cd04e157b1
[gaim-migrate @ 15088]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
569 | GString *outstr = g_string_new(""); |
|
13093
e27434c31f00
[gaim-migrate @ 15454]
Daniel Atallah <datallah@pidgin.im>
parents:
13089
diff
changeset
|
570 | |
|
12754
539bcb15199f
[gaim-migrate @ 15101]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
12753
diff
changeset
|
571 | /* When sending the acknowlegements and errors, the content length from the original |
|
539bcb15199f
[gaim-migrate @ 15101]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
12753
diff
changeset
|
572 | message is still here, but there is no body; we need to make sure we're sending the |
|
539bcb15199f
[gaim-migrate @ 15101]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
12753
diff
changeset
|
573 | correct content length */ |
|
539bcb15199f
[gaim-migrate @ 15101]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
12753
diff
changeset
|
574 | sipmsg_remove_header(msg, "Content-Length"); |
|
539bcb15199f
[gaim-migrate @ 15101]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
12753
diff
changeset
|
575 | if(body) { |
|
539bcb15199f
[gaim-migrate @ 15101]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
12753
diff
changeset
|
576 | gchar len[12]; |
|
539bcb15199f
[gaim-migrate @ 15101]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
12753
diff
changeset
|
577 | sprintf(len, "%" G_GSIZE_FORMAT , strlen(body)); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
578 | sipmsg_add_header(msg, "Content-Length", len); |
|
12754
539bcb15199f
[gaim-migrate @ 15101]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
12753
diff
changeset
|
579 | } |
|
539bcb15199f
[gaim-migrate @ 15101]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
12753
diff
changeset
|
580 | else |
|
539bcb15199f
[gaim-migrate @ 15101]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
12753
diff
changeset
|
581 | sipmsg_add_header(msg, "Content-Length", "0"); |
|
12741
14cd04e157b1
[gaim-migrate @ 15088]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
582 | g_string_append_printf(outstr, "SIP/2.0 %d %s\r\n", code, text); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
583 | while(tmp) { |
|
12741
14cd04e157b1
[gaim-migrate @ 15088]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
584 | name = ((struct siphdrelement*) (tmp->data))->name; |
|
14cd04e157b1
[gaim-migrate @ 15088]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
585 | value = ((struct siphdrelement*) (tmp->data))->value; |
|
12745
1dc3525647c2
[gaim-migrate @ 15092]
Daniel Atallah <datallah@pidgin.im>
parents:
12741
diff
changeset
|
586 | |
|
12741
14cd04e157b1
[gaim-migrate @ 15088]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
587 | g_string_append_printf(outstr, "%s: %s\r\n", name, value); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
588 | tmp = g_slist_next(tmp); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
589 | } |
|
12741
14cd04e157b1
[gaim-migrate @ 15088]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
590 | g_string_append_printf(outstr, "\r\n%s", body ? body : ""); |
|
14cd04e157b1
[gaim-migrate @ 15088]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
591 | sendout_pkt(gc, outstr->str); |
|
14cd04e157b1
[gaim-migrate @ 15088]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
592 | g_string_free(outstr, TRUE); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
593 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
594 | |
|
11194
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
595 | static void transactions_remove(struct simple_account_data *sip, struct transaction *trans) { |
|
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
596 | if(trans->msg) sipmsg_free(trans->msg); |
|
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
597 | sip->transactions = g_slist_remove(sip->transactions, trans); |
|
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
598 | g_free(trans); |
|
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
599 | } |
|
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
600 | |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
601 | static void transactions_add_buf(struct simple_account_data *sip, const gchar *buf, void *callback) { |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
602 | struct transaction *trans = g_new0(struct transaction, 1); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
603 | trans->time = time(NULL); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
604 | trans->msg = sipmsg_parse_msg(buf); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
605 | trans->cseq = sipmsg_find_header(trans->msg, "CSeq"); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
606 | trans->callback = callback; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
607 | sip->transactions = g_slist_append(sip->transactions, trans); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
608 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
609 | |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
610 | static struct transaction *transactions_find(struct simple_account_data *sip, struct sipmsg *msg) { |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
611 | struct transaction *trans; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
612 | GSList *transactions = sip->transactions; |
|
21100
814637ced463
Some constification, which also found and fixed some potential double-free
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21076
diff
changeset
|
613 | const gchar *cseq = sipmsg_find_header(msg, "CSeq"); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
614 | |
|
16232
b5838c6cb3ed
simple-crashfix.diff from achris in ticket #98. This is a fix for the crasher,
Richard Laager <rlaager@pidgin.im>
parents:
16209
diff
changeset
|
615 | if (cseq) { |
|
b5838c6cb3ed
simple-crashfix.diff from achris in ticket #98. This is a fix for the crasher,
Richard Laager <rlaager@pidgin.im>
parents:
16209
diff
changeset
|
616 | while(transactions) { |
|
b5838c6cb3ed
simple-crashfix.diff from achris in ticket #98. This is a fix for the crasher,
Richard Laager <rlaager@pidgin.im>
parents:
16209
diff
changeset
|
617 | trans = transactions->data; |
|
b5838c6cb3ed
simple-crashfix.diff from achris in ticket #98. This is a fix for the crasher,
Richard Laager <rlaager@pidgin.im>
parents:
16209
diff
changeset
|
618 | if(!strcmp(trans->cseq, cseq)) { |
|
b5838c6cb3ed
simple-crashfix.diff from achris in ticket #98. This is a fix for the crasher,
Richard Laager <rlaager@pidgin.im>
parents:
16209
diff
changeset
|
619 | return trans; |
|
b5838c6cb3ed
simple-crashfix.diff from achris in ticket #98. This is a fix for the crasher,
Richard Laager <rlaager@pidgin.im>
parents:
16209
diff
changeset
|
620 | } |
|
b5838c6cb3ed
simple-crashfix.diff from achris in ticket #98. This is a fix for the crasher,
Richard Laager <rlaager@pidgin.im>
parents:
16209
diff
changeset
|
621 | transactions = transactions->next; |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
622 | } |
|
16232
b5838c6cb3ed
simple-crashfix.diff from achris in ticket #98. This is a fix for the crasher,
Richard Laager <rlaager@pidgin.im>
parents:
16209
diff
changeset
|
623 | } else { |
|
b5838c6cb3ed
simple-crashfix.diff from achris in ticket #98. This is a fix for the crasher,
Richard Laager <rlaager@pidgin.im>
parents:
16209
diff
changeset
|
624 | purple_debug(PURPLE_DEBUG_MISC, "simple", "Received message contains no CSeq header.\n"); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
625 | } |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
626 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
627 | return NULL; |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
628 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
629 | |
| 15884 | 630 | static void send_sip_request(PurpleConnection *gc, const gchar *method, |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
631 | const gchar *url, const gchar *to, const gchar *addheaders, |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
632 | const gchar *body, struct sip_dialog *dialog, TransCallback tc) { |
|
32266
af94a3153685
Convert simple prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
633 | struct simple_account_data *sip = purple_connection_get_protocol_data(gc); |
|
13093
e27434c31f00
[gaim-migrate @ 15454]
Daniel Atallah <datallah@pidgin.im>
parents:
13089
diff
changeset
|
634 | char *callid = dialog ? g_strdup(dialog->callid) : gencallid(); |
|
14213
1d35fd2c5713
[gaim-migrate @ 16796]
Daniel Atallah <datallah@pidgin.im>
parents:
14180
diff
changeset
|
635 | char *auth = NULL; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
636 | const char *addh = ""; |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12196
diff
changeset
|
637 | gchar *branch = genbranch(); |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
638 | gchar *tag = NULL; |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12196
diff
changeset
|
639 | char *buf; |
|
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12196
diff
changeset
|
640 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
641 | if(!strcmp(method, "REGISTER")) { |
|
13093
e27434c31f00
[gaim-migrate @ 15454]
Daniel Atallah <datallah@pidgin.im>
parents:
13089
diff
changeset
|
642 | if(sip->regcallid) { |
|
e27434c31f00
[gaim-migrate @ 15454]
Daniel Atallah <datallah@pidgin.im>
parents:
13089
diff
changeset
|
643 | g_free(callid); |
|
e27434c31f00
[gaim-migrate @ 15454]
Daniel Atallah <datallah@pidgin.im>
parents:
13089
diff
changeset
|
644 | callid = g_strdup(sip->regcallid); |
|
e27434c31f00
[gaim-migrate @ 15454]
Daniel Atallah <datallah@pidgin.im>
parents:
13089
diff
changeset
|
645 | } |
|
12196
92a07bdbe0df
[gaim-migrate @ 14498]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
12143
diff
changeset
|
646 | else sip->regcallid = g_strdup(callid); |
|
92a07bdbe0df
[gaim-migrate @ 14498]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
12143
diff
changeset
|
647 | } |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
648 | |
|
13093
e27434c31f00
[gaim-migrate @ 15454]
Daniel Atallah <datallah@pidgin.im>
parents:
13089
diff
changeset
|
649 | if(addheaders) addh = addheaders; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
650 | if(sip->registrar.type && !strcmp(method, "REGISTER")) { |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
651 | buf = auth_header(sip, &sip->registrar, method, url); |
|
17187
78b7ae95ad45
Fix an extra \r\n in the Authorization header. Fixes #965.
Daniel Atallah <datallah@pidgin.im>
parents:
17185
diff
changeset
|
652 | auth = g_strdup_printf("Authorization: %s\r\n", buf); |
|
11346
4af1dc4b2c44
[gaim-migrate @ 13563]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11345
diff
changeset
|
653 | g_free(buf); |
| 15884 | 654 | purple_debug(PURPLE_DEBUG_MISC, "simple", "header %s", auth); |
|
17187
78b7ae95ad45
Fix an extra \r\n in the Authorization header. Fixes #965.
Daniel Atallah <datallah@pidgin.im>
parents:
17185
diff
changeset
|
655 | } else if(sip->proxy.type && strcmp(method, "REGISTER")) { |
|
11346
4af1dc4b2c44
[gaim-migrate @ 13563]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11345
diff
changeset
|
656 | buf = auth_header(sip, &sip->proxy, method, url); |
|
17187
78b7ae95ad45
Fix an extra \r\n in the Authorization header. Fixes #965.
Daniel Atallah <datallah@pidgin.im>
parents:
17185
diff
changeset
|
657 | auth = g_strdup_printf("Proxy-Authorization: %s\r\n", buf); |
|
11346
4af1dc4b2c44
[gaim-migrate @ 13563]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11345
diff
changeset
|
658 | g_free(buf); |
| 15884 | 659 | purple_debug(PURPLE_DEBUG_MISC, "simple", "header %s", auth); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
660 | } |
|
12767
4870d7755883
[gaim-migrate @ 15114]
Daniel Atallah <datallah@pidgin.im>
parents:
12760
diff
changeset
|
661 | |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
662 | if (!dialog) |
|
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
663 | tag = gentag(); |
|
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
664 | |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
665 | buf = g_strdup_printf("%s %s SIP/2.0\r\n" |
|
11190
16f02ac58a38
[gaim-migrate @ 13308]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11189
diff
changeset
|
666 | "Via: SIP/2.0/%s %s:%d;branch=%s\r\n" |
|
13085
c80913901342
[gaim-migrate @ 15446]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13084
diff
changeset
|
667 | /* Don't know what epid is, but LCS wants it */ |
|
c80913901342
[gaim-migrate @ 15446]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13084
diff
changeset
|
668 | "From: <sip:%s@%s>;tag=%s;epid=1234567890\r\n" |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
669 | "To: <%s>%s%s\r\n" |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
670 | "Max-Forwards: 10\r\n" |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
671 | "CSeq: %d %s\r\n" |
| 15884 | 672 | "User-Agent: Purple/" VERSION "\r\n" |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
673 | "Call-ID: %s\r\n" |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
674 | "%s%s" |
| 11658 | 675 | "Content-Length: %" G_GSIZE_FORMAT "\r\n\r\n%s", |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
676 | method, |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
677 | url, |
|
11190
16f02ac58a38
[gaim-migrate @ 13308]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11189
diff
changeset
|
678 | sip->udp ? "UDP" : "TCP", |
| 15884 | 679 | purple_network_get_my_ip(-1), |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
680 | sip->listenport, |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
681 | branch, |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
682 | sip->username, |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
683 | sip->servername, |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
684 | dialog ? dialog->ourtag : tag, |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
685 | to, |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
686 | dialog ? ";tag=" : "", |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
687 | dialog ? dialog->theirtag : "", |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
688 | ++sip->cseq, |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
689 | method, |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
690 | callid, |
|
14213
1d35fd2c5713
[gaim-migrate @ 16796]
Daniel Atallah <datallah@pidgin.im>
parents:
14180
diff
changeset
|
691 | auth ? auth : "", |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
692 | addh, |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
693 | strlen(body), |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
694 | body); |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
695 | |
|
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
696 | g_free(tag); |
|
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
697 | g_free(auth); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
698 | g_free(branch); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
699 | g_free(callid); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
700 | |
|
11341
5511bbeeb3b4
[gaim-migrate @ 13555]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11327
diff
changeset
|
701 | /* add to ongoing transactions */ |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
702 | |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
703 | transactions_add_buf(sip, buf, tc); |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
704 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
705 | sendout_pkt(gc, buf); |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
706 | |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
707 | g_free(buf); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
708 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
709 | |
|
13178
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
710 | static char *get_contact(struct simple_account_data *sip) { |
|
21417
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
711 | return g_strdup_printf("<sip:%s@%s:%d;transport=%s>;methods=\"MESSAGE, SUBSCRIBE, NOTIFY\"", |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
712 | sip->username, purple_network_get_my_ip(-1), |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
713 | sip->listenport, |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
714 | sip->udp ? "udp" : "tcp"); |
|
13178
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
715 | } |
|
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
716 | |
|
11194
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
717 | static void do_register_exp(struct simple_account_data *sip, int expire) { |
|
19991
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
718 | char *uri, *to, *contact, *hdr; |
|
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
719 | |
|
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
720 | sip->reregister = time(NULL) + expire - 50; |
|
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
721 | |
|
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
722 | uri = g_strdup_printf("sip:%s", sip->servername); |
|
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
723 | to = g_strdup_printf("sip:%s@%s", sip->username, sip->servername); |
|
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
724 | contact = get_contact(sip); |
|
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
725 | hdr = g_strdup_printf("Contact: %s\r\nExpires: %d\r\n", contact, expire); |
|
13178
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
726 | g_free(contact); |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
727 | |
|
19991
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
728 | sip->registerstatus = SIMPLE_REGISTER_SENT; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
729 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
730 | send_sip_request(sip->gc, "REGISTER", uri, to, hdr, "", NULL, |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
731 | process_register_response); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
732 | |
|
13178
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
733 | g_free(hdr); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
734 | g_free(uri); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
735 | g_free(to); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
736 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
737 | |
|
11194
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
738 | static void do_register(struct simple_account_data *sip) { |
|
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
739 | do_register_exp(sip, sip->registerexpire); |
|
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
740 | } |
|
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
741 | |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
742 | static gchar *parse_from(const gchar *hdr) { |
|
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
743 | gchar *from; |
|
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
744 | const gchar *tmp, *tmp2 = hdr; |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
745 | |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
746 | if(!hdr) return NULL; |
| 15884 | 747 | purple_debug_info("simple", "parsing address out of %s\n", hdr); |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
748 | tmp = strchr(hdr, '<'); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
749 | |
|
11341
5511bbeeb3b4
[gaim-migrate @ 13555]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11327
diff
changeset
|
750 | /* i hate the different SIP UA behaviours... */ |
|
5511bbeeb3b4
[gaim-migrate @ 13555]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11327
diff
changeset
|
751 | if(tmp) { /* sip address in <...> */ |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
752 | tmp2 = tmp + 1; |
|
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
753 | tmp = strchr(tmp2, '>'); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
754 | if(tmp) { |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
755 | from = g_strndup(tmp2, tmp - tmp2); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
756 | } else { |
| 15884 | 757 | purple_debug_info("simple", "found < without > in From\n"); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
758 | return NULL; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
759 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
760 | } else { |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
761 | tmp = strchr(tmp2, ';'); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
762 | if(tmp) { |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
763 | from = g_strndup(tmp2, tmp - tmp2); |
|
11483
098043515257
[gaim-migrate @ 13725]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11439
diff
changeset
|
764 | } else { |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
765 | from = g_strdup(tmp2); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
766 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
767 | } |
| 15884 | 768 | purple_debug_info("simple", "got %s\n", from); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
769 | return from; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
770 | } |
|
21417
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
771 | static gchar *find_tag(const gchar *); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
772 | |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
773 | static gboolean process_subscribe_response(struct simple_account_data *sip, struct sipmsg *msg, struct transaction *tc) { |
|
21417
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
774 | gchar *to = NULL; |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
775 | struct simple_buddy *b = NULL; |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
776 | gchar *theirtag = NULL, *ourtag = NULL; |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
777 | const gchar *callid = NULL; |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
778 | |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
779 | purple_debug_info("simple", "process subscribe response\n"); |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
780 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
781 | if(msg->response == 200 || msg->response == 202) { |
|
21417
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
782 | if ( (to = parse_from(sipmsg_find_header(msg, "To"))) && |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
783 | (b = g_hash_table_lookup(sip->buddies, to)) && |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
784 | !(b->dialog)) |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
785 | { |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
786 | purple_debug_info("simple", "creating dialog" |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
787 | " information for a subscription.\n"); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
788 | |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
789 | theirtag = find_tag(sipmsg_find_header(msg, "To")); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
790 | ourtag = find_tag(sipmsg_find_header(msg, "From")); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
791 | callid = sipmsg_find_header(msg, "Call-ID"); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
792 | |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
793 | if (theirtag && ourtag && callid) |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
794 | { |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
795 | b->dialog = g_new0(struct sip_dialog, 1); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
796 | b->dialog->ourtag = g_strdup(ourtag); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
797 | b->dialog->theirtag = g_strdup(theirtag); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
798 | b->dialog->callid = g_strdup(callid); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
799 | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
800 | purple_debug_info("simple", "ourtag: %s\n", |
|
21417
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
801 | ourtag); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
802 | purple_debug_info("simple", "theirtag: %s\n", |
|
21417
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
803 | theirtag); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
804 | purple_debug_info("simple", "callid: %s\n", |
|
21417
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
805 | callid); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
806 | g_free(theirtag); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
807 | g_free(ourtag); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
808 | } |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
809 | } |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
810 | else |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
811 | { |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
812 | purple_debug_info("simple", "cannot create dialog!\n"); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
813 | } |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
814 | return TRUE; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
815 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
816 | |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
817 | to = parse_from(sipmsg_find_header(tc->msg, "To")); /* cant be NULL since it is our own msg */ |
|
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
818 | |
|
11341
5511bbeeb3b4
[gaim-migrate @ 13555]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11327
diff
changeset
|
819 | /* we can not subscribe -> user is offline (TODO unknown status?) */ |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
820 | |
| 15884 | 821 | purple_prpl_got_user_status(sip->account, to, "offline", NULL); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
822 | g_free(to); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
823 | return TRUE; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
824 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
825 | |
|
21417
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
826 | static void simple_subscribe_exp(struct simple_account_data *sip, struct simple_buddy *buddy, int expiration) { |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
827 | gchar *contact, *to, *tmp, *tmp2; |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
828 | |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
829 | tmp2 = g_strdup_printf( |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
830 | "Expires: %d\r\n" |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
831 | "Accept: application/pidf+xml, application/xpidf+xml\r\n" |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
832 | "Event: presence\r\n", |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
833 | expiration); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
834 | |
|
25603
d9748fa08309
This is a combination of patches from darkrain42 and Marcus Sundberg to fix
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
25206
diff
changeset
|
835 | if(strncmp(buddy->name, "sip:", 4)) |
|
d9748fa08309
This is a combination of patches from darkrain42 and Marcus Sundberg to fix
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
25206
diff
changeset
|
836 | to = g_strdup_printf("sip:%s", buddy->name); |
|
d9748fa08309
This is a combination of patches from darkrain42 and Marcus Sundberg to fix
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
25206
diff
changeset
|
837 | else |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
838 | to = g_strdup(buddy->name); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
839 | |
|
13178
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
840 | tmp = get_contact(sip); |
|
21417
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
841 | contact = g_strdup_printf("%sContact: %s\r\n", tmp2, tmp); |
|
13178
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
842 | g_free(tmp); |
|
21417
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
843 | g_free(tmp2); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
844 | |
|
21417
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
845 | send_sip_request(sip->gc, "SUBSCRIBE", to, to, contact,"",buddy->dialog, |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
846 | (expiration > 0) ? process_subscribe_response : NULL); |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
847 | |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
848 | g_free(to); |
|
11341
5511bbeeb3b4
[gaim-migrate @ 13555]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11327
diff
changeset
|
849 | g_free(contact); |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
850 | |
|
11341
5511bbeeb3b4
[gaim-migrate @ 13555]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11327
diff
changeset
|
851 | /* resubscribe before subscription expires */ |
|
5511bbeeb3b4
[gaim-migrate @ 13555]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11327
diff
changeset
|
852 | /* add some jitter */ |
|
21417
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
853 | if (expiration > 60) |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
854 | buddy->resubscribe = time(NULL) + (expiration - 60) + (rand() % 50); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
855 | else if (expiration > 0) |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
856 | buddy->resubscribe = time(NULL) + ((int) (expiration / 2)); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
857 | } |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
858 | |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
859 | static void simple_subscribe(struct simple_account_data *sip, struct simple_buddy *buddy) { |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
860 | simple_subscribe_exp(sip, buddy, SUBSCRIBE_EXPIRATION); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
861 | } |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
862 | |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
863 | static void simple_unsubscribe(char *name, struct simple_buddy *buddy, struct simple_account_data *sip) { |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
864 | if (buddy->dialog) |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
865 | { |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
866 | purple_debug_info("simple", "Unsubscribing from %s\n", name); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
867 | simple_subscribe_exp(sip, buddy, 0); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
868 | } |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
869 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
870 | |
|
13348
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
871 | static gboolean simple_add_lcs_contacts(struct simple_account_data *sip, struct sipmsg *msg, struct transaction *tc) { |
|
21100
814637ced463
Some constification, which also found and fixed some potential double-free
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21076
diff
changeset
|
872 | const gchar *tmp; |
|
13348
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
873 | xmlnode *item, *group, *isc; |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
874 | const char *name_group; |
| 15884 | 875 | PurpleBuddy *b; |
| 876 | PurpleGroup *g = NULL; | |
|
13348
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
877 | struct simple_buddy *bs; |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
878 | int len = msg->bodylen; |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
879 | |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
880 | |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
881 | tmp = sipmsg_find_header(msg, "Event"); |
|
25603
d9748fa08309
This is a combination of patches from darkrain42 and Marcus Sundberg to fix
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
25206
diff
changeset
|
882 | if(tmp && !strncmp(tmp, "vnd-microsoft-roaming-contacts", 30)){ |
|
13348
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
883 | |
| 15884 | 884 | purple_debug_info("simple", "simple_add_lcs_contacts->%s-%d\n", msg->body, len); |
| 885 | /*Convert the contact from XML to Purple Buddies*/ | |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
886 | isc = xmlnode_from_str(msg->body, len); |
|
13348
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
887 | |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
888 | /* ToDo. Find for all groups */ |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
889 | if ((group = xmlnode_get_child(isc, "group"))) { |
|
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
890 | name_group = xmlnode_get_attrib(group, "name"); |
| 15884 | 891 | purple_debug_info("simple", "name_group->%s\n", name_group); |
| 892 | g = purple_find_group(name_group); | |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
893 | if(!g) |
| 15884 | 894 | g = purple_group_new(name_group); |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
895 | } |
|
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
896 | |
|
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
897 | if (!g) { |
| 15884 | 898 | g = purple_find_group("Buddies"); |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
899 | if(!g) |
| 15884 | 900 | g = purple_group_new("Buddies"); |
|
13348
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
901 | } |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
902 | |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
903 | for(item = xmlnode_get_child(isc, "contact"); item; item = xmlnode_get_next_twin(item)) |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
904 | { |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
905 | const char *uri, *name, *groups; |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
906 | char *buddy_name; |
|
13348
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
907 | uri = xmlnode_get_attrib(item, "uri"); |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
908 | name = xmlnode_get_attrib(item, "name"); |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
909 | groups = xmlnode_get_attrib(item, "groups"); |
| 15884 | 910 | purple_debug_info("simple", "URI->%s\n", uri); |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
911 | |
|
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
912 | buddy_name = g_strdup_printf("sip:%s", uri); |
|
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
913 | |
| 15884 | 914 | b = purple_find_buddy(sip->account, buddy_name); |
|
13348
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
915 | if(!b){ |
| 15884 | 916 | b = purple_buddy_new(sip->account, buddy_name, uri); |
|
13348
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
917 | } |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
918 | g_free(buddy_name); |
|
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
919 | |
| 15884 | 920 | purple_blist_add_buddy(b, NULL, g, NULL); |
| 921 | purple_blist_alias_buddy(b, uri); | |
|
13348
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
922 | bs = g_new0(struct simple_buddy, 1); |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24040
diff
changeset
|
923 | bs->name = g_strdup(purple_buddy_get_name(b)); |
|
13348
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
924 | g_hash_table_insert(sip->buddies, bs->name, bs); |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
925 | } |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
926 | xmlnode_free(isc); |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
927 | } |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
928 | return 0; |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
929 | } |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
930 | |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
931 | static void simple_subscribe_buddylist(struct simple_account_data *sip) { |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
932 | gchar *contact = "Event: vnd-microsoft-roaming-contacts\r\nAccept: application/vnd-microsoft-roaming-contacts+xml\r\nSupported: com.microsoft.autoextend\r\nSupported: ms-benotify\r\nProxy-Require: ms-benotify\r\nSupported: ms-piggyback-first-notify\r\n"; |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
933 | gchar *to; |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
934 | gchar *tmp; |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
935 | to = g_strdup_printf("sip:%s@%s", sip->username, sip->servername); |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
936 | |
|
13348
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
937 | tmp = get_contact(sip); |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
938 | |
|
13348
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
939 | contact = g_strdup_printf("%sContact: %s\r\n", contact, tmp); |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
940 | g_free(tmp); |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
941 | |
|
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
942 | send_sip_request(sip->gc, "SUBSCRIBE", to, to, contact, "", NULL, simple_add_lcs_contacts); |
|
13348
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
943 | |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
944 | g_free(to); |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
945 | g_free(contact); |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
946 | } |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
947 | |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
948 | |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
949 | static void simple_buddy_resub(char *name, struct simple_buddy *buddy, struct simple_account_data *sip) { |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
950 | time_t curtime = time(NULL); |
| 15884 | 951 | purple_debug_info("simple", "buddy resub\n"); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
952 | if(buddy->resubscribe < curtime) { |
| 15884 | 953 | purple_debug(PURPLE_DEBUG_MISC, "simple", "simple_buddy_resub %s\n", name); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
954 | simple_subscribe(sip, buddy); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
955 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
956 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
957 | |
|
11194
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
958 | static gboolean resend_timeout(struct simple_account_data *sip) { |
|
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
959 | GSList *tmp = sip->transactions; |
|
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
960 | time_t currtime = time(NULL); |
|
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
961 | while(tmp) { |
|
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
962 | struct transaction *trans = tmp->data; |
|
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
963 | tmp = tmp->next; |
|
22709
6bd336964410
Printf warning fixes.
Daniel Atallah <datallah@pidgin.im>
parents:
22634
diff
changeset
|
964 | purple_debug_info("simple", "have open transaction age: %lu\n", currtime- trans->time); |
|
11194
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
965 | if((currtime - trans->time > 5) && trans->retries >= 1) { |
|
11341
5511bbeeb3b4
[gaim-migrate @ 13555]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11327
diff
changeset
|
966 | /* TODO 408 */ |
|
11194
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
967 | } else { |
|
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
968 | if((currtime - trans->time > 2) && trans->retries == 0) { |
|
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
969 | trans->retries++; |
|
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
970 | sendout_sipmsg(sip, trans->msg); |
|
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
971 | } |
|
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
972 | } |
|
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
973 | } |
|
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
974 | return TRUE; |
|
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
975 | } |
|
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
976 | |
|
12768
0783fffbd552
[gaim-migrate @ 15115]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
12767
diff
changeset
|
977 | static gboolean subscribe_timeout(struct simple_account_data *sip) { |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
978 | GSList *tmp; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
979 | time_t curtime = time(NULL); |
|
11341
5511bbeeb3b4
[gaim-migrate @ 13555]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11327
diff
changeset
|
980 | /* register again if first registration expires */ |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
981 | if(sip->reregister < curtime) { |
|
11194
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
982 | do_register(sip); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
983 | } |
|
21417
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
984 | |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
985 | /* publish status again if our last update is about to expire. */ |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
986 | if (sip->republish != -1 && |
|
21417
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
987 | sip->republish < curtime && |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
988 | purple_account_get_bool(sip->account, "dopublish", TRUE)) |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
989 | { |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
990 | purple_debug_info("simple", "subscribe_timeout: republishing status.\n"); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
991 | send_open_publish(sip); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
992 | } |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
993 | |
|
11341
5511bbeeb3b4
[gaim-migrate @ 13555]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11327
diff
changeset
|
994 | /* check for every subscription if we need to resubscribe */ |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
995 | g_hash_table_foreach(sip->buddies, (GHFunc)simple_buddy_resub, (gpointer)sip); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
996 | |
|
11341
5511bbeeb3b4
[gaim-migrate @ 13555]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11327
diff
changeset
|
997 | /* remove a timed out suscriber */ |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
998 | tmp = sip->watcher; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
999 | while(tmp) { |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1000 | struct simple_watcher *watcher = tmp->data; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1001 | if(watcher->expire < curtime) { |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1002 | watcher_remove(sip, watcher->name); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1003 | tmp = sip->watcher; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1004 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1005 | if(tmp) tmp = tmp->next; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1006 | } |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
1007 | |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1008 | return TRUE; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1009 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1010 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
1011 | static void simple_send_message(struct simple_account_data *sip, const char *to, const char *msg, const char *type) { |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1012 | gchar *hdr; |
|
13185
ee7ac8a41ec4
[gaim-migrate @ 15547]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13178
diff
changeset
|
1013 | gchar *fullto; |
|
25603
d9748fa08309
This is a combination of patches from darkrain42 and Marcus Sundberg to fix
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
25206
diff
changeset
|
1014 | if(strncmp(to, "sip:", 4)) |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
1015 | fullto = g_strdup_printf("sip:%s", to); |
|
25603
d9748fa08309
This is a combination of patches from darkrain42 and Marcus Sundberg to fix
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
25206
diff
changeset
|
1016 | else |
|
13185
ee7ac8a41ec4
[gaim-migrate @ 15547]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13178
diff
changeset
|
1017 | fullto = g_strdup(to); |
|
25603
d9748fa08309
This is a combination of patches from darkrain42 and Marcus Sundberg to fix
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
25206
diff
changeset
|
1018 | |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
1019 | if(type) { |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
1020 | hdr = g_strdup_printf("Content-Type: %s\r\n", type); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1021 | } else { |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1022 | hdr = g_strdup("Content-Type: text/plain\r\n"); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1023 | } |
|
13185
ee7ac8a41ec4
[gaim-migrate @ 15547]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13178
diff
changeset
|
1024 | send_sip_request(sip->gc, "MESSAGE", fullto, fullto, hdr, msg, NULL, NULL); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1025 | g_free(hdr); |
|
13185
ee7ac8a41ec4
[gaim-migrate @ 15547]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13178
diff
changeset
|
1026 | g_free(fullto); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1027 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1028 | |
| 15884 | 1029 | static int simple_im_send(PurpleConnection *gc, const char *who, const char *what, PurpleMessageFlags flags) { |
|
32266
af94a3153685
Convert simple prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
1030 | struct simple_account_data *sip = purple_connection_get_protocol_data(gc); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1031 | char *to = g_strdup(who); |
| 15884 | 1032 | char *text = purple_unescape_html(what); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1033 | simple_send_message(sip, to, text, NULL); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1034 | g_free(to); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1035 | g_free(text); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1036 | return 1; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1037 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1038 | |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1039 | static void process_incoming_message(struct simple_account_data *sip, struct sipmsg *msg) { |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1040 | gchar *from; |
|
21100
814637ced463
Some constification, which also found and fixed some potential double-free
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21076
diff
changeset
|
1041 | const gchar *contenttype; |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1042 | gboolean found = FALSE; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1043 | |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1044 | from = parse_from(sipmsg_find_header(msg, "From")); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1045 | |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1046 | if(!from) return; |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
1047 | |
| 15884 | 1048 | purple_debug(PURPLE_DEBUG_MISC, "simple", "got message from %s: %s\n", from, msg->body); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1049 | |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1050 | contenttype = sipmsg_find_header(msg, "Content-Type"); |
|
25603
d9748fa08309
This is a combination of patches from darkrain42 and Marcus Sundberg to fix
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
25206
diff
changeset
|
1051 | if(!contenttype || !strncmp(contenttype, "text/plain", 10) || !strncmp(contenttype, "text/html", 9)) { |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1052 | serv_got_im(sip->gc, from, msg->body, 0, time(NULL)); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1053 | send_sip_response(sip->gc, msg, 200, "OK", NULL); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1054 | found = TRUE; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1055 | } |
|
25603
d9748fa08309
This is a combination of patches from darkrain42 and Marcus Sundberg to fix
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
25206
diff
changeset
|
1056 | else if(!strncmp(contenttype, "application/im-iscomposing+xml", 30)) { |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
1057 | xmlnode *isc = xmlnode_from_str(msg->body, msg->bodylen); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1058 | xmlnode *state; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1059 | gchar *statedata; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1060 | |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1061 | if(!isc) { |
| 15884 | 1062 | purple_debug_info("simple", "process_incoming_message: can not parse iscomposing\n"); |
|
18840
05aeff1821c4
Fix from Will Hawkins to plug some leaks in error cases for the SIMPLE prpl. References #2181.
Daniel Atallah <datallah@pidgin.im>
parents:
18552
diff
changeset
|
1063 | g_free(from); |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
1064 | return; |
|
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
1065 | } |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1066 | |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
1067 | state = xmlnode_get_child(isc, "state"); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1068 | |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
1069 | if(!state) { |
|
18840
05aeff1821c4
Fix from Will Hawkins to plug some leaks in error cases for the SIMPLE prpl. References #2181.
Daniel Atallah <datallah@pidgin.im>
parents:
18552
diff
changeset
|
1070 | purple_debug_info("simple", "process_incoming_message: no state found\n"); |
|
05aeff1821c4
Fix from Will Hawkins to plug some leaks in error cases for the SIMPLE prpl. References #2181.
Daniel Atallah <datallah@pidgin.im>
parents:
18552
diff
changeset
|
1071 | xmlnode_free(isc); |
|
05aeff1821c4
Fix from Will Hawkins to plug some leaks in error cases for the SIMPLE prpl. References #2181.
Daniel Atallah <datallah@pidgin.im>
parents:
18552
diff
changeset
|
1072 | g_free(from); |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
1073 | return; |
|
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
1074 | } |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1075 | |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
1076 | statedata = xmlnode_get_data(state); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1077 | if(statedata) { |
|
24845
6418fb8799b8
Some cleanup. The headers are all NUL delimited, so we don't need to mess with
Daniel Atallah <datallah@pidgin.im>
parents:
24844
diff
changeset
|
1078 | if(strstr(statedata, "active")) |
|
6418fb8799b8
Some cleanup. The headers are all NUL delimited, so we don't need to mess with
Daniel Atallah <datallah@pidgin.im>
parents:
24844
diff
changeset
|
1079 | serv_got_typing(sip->gc, from, 0, PURPLE_TYPING); |
|
6418fb8799b8
Some cleanup. The headers are all NUL delimited, so we don't need to mess with
Daniel Atallah <datallah@pidgin.im>
parents:
24844
diff
changeset
|
1080 | else |
|
6418fb8799b8
Some cleanup. The headers are all NUL delimited, so we don't need to mess with
Daniel Atallah <datallah@pidgin.im>
parents:
24844
diff
changeset
|
1081 | serv_got_typing_stopped(sip->gc, from); |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
1082 | |
|
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
1083 | g_free(statedata); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1084 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1085 | xmlnode_free(isc); |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
1086 | send_sip_response(sip->gc, msg, 200, "OK", NULL); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1087 | found = TRUE; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1088 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1089 | if(!found) { |
|
19832
84b69b21672b
Patch from QuLogic. Fixes #2903 ('Missing newlines in debug messages.')
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18840
diff
changeset
|
1090 | purple_debug_info("simple", "got unknown mime-type\n"); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1091 | send_sip_response(sip->gc, msg, 415, "Unsupported media type", NULL); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1092 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1093 | g_free(from); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1094 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1095 | |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1096 | |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1097 | gboolean process_register_response(struct simple_account_data *sip, struct sipmsg *msg, struct transaction *tc) { |
|
21100
814637ced463
Some constification, which also found and fixed some potential double-free
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21076
diff
changeset
|
1098 | const gchar *tmp; |
| 15884 | 1099 | purple_debug(PURPLE_DEBUG_MISC, "simple", "in process register response response: %d\n", msg->response); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1100 | switch (msg->response) { |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1101 | case 200: |
|
19991
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1102 | if(sip->registerstatus < SIMPLE_REGISTER_COMPLETE) { /* registered */ |
| 15884 | 1103 | if(purple_account_get_bool(sip->account, "dopublish", TRUE)) { |
|
20988
75eab0f2aa19
Patch from Will Hawkins to publish a status of closed when signing out of a SIMPLE account. Fixes #1914.
Daniel Atallah <datallah@pidgin.im>
parents:
20658
diff
changeset
|
1104 | send_open_publish(sip); |
|
11345
48a2f93e47b6
[gaim-migrate @ 13562]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11341
diff
changeset
|
1105 | } |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1106 | } |
|
19991
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1107 | sip->registerstatus = SIMPLE_REGISTER_COMPLETE; |
| 15884 | 1108 | purple_connection_set_state(sip->gc, PURPLE_CONNECTED); |
|
11341
5511bbeeb3b4
[gaim-migrate @ 13555]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11327
diff
changeset
|
1109 | |
|
5511bbeeb3b4
[gaim-migrate @ 13555]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11327
diff
changeset
|
1110 | /* get buddies from blist */ |
|
5511bbeeb3b4
[gaim-migrate @ 13555]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11327
diff
changeset
|
1111 | simple_get_buddies(sip->gc); |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
1112 | |
|
12768
0783fffbd552
[gaim-migrate @ 15115]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
12767
diff
changeset
|
1113 | subscribe_timeout(sip); |
|
13348
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
1114 | tmp = sipmsg_find_header(msg, "Allow-Events"); |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
1115 | if(tmp && strstr(tmp, "vnd-microsoft-provisioning")){ |
|
13348
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
1116 | simple_subscribe_buddylist(sip); |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
1117 | } |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
1118 | |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1119 | break; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1120 | case 401: |
|
19991
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1121 | if(sip->registerstatus != SIMPLE_REGISTER_RETRY) { |
| 15884 | 1122 | purple_debug_info("simple", "REGISTER retries %d\n", sip->registrar.retries); |
|
19991
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1123 | if(sip->registrar.retries > SIMPLE_REGISTER_RETRY_MAX) { |
|
32678
01f6312a4a7b
On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents:
32594
diff
changeset
|
1124 | if (!purple_account_get_remember_password(purple_connection_get_account(sip->gc))) |
|
01f6312a4a7b
On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents:
32594
diff
changeset
|
1125 | purple_account_set_password(purple_connection_get_account(sip->gc), NULL); |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31949
diff
changeset
|
1126 | purple_connection_error(sip->gc, |
| 21279 | 1127 | PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27350
diff
changeset
|
1128 | _("Incorrect password")); |
|
11346
4af1dc4b2c44
[gaim-migrate @ 13563]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11345
diff
changeset
|
1129 | return TRUE; |
|
4af1dc4b2c44
[gaim-migrate @ 13563]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11345
diff
changeset
|
1130 | } |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1131 | tmp = sipmsg_find_header(msg, "WWW-Authenticate"); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1132 | fill_auth(sip, tmp, &sip->registrar); |
|
19991
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1133 | sip->registerstatus = SIMPLE_REGISTER_RETRY; |
|
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1134 | do_register(sip); |
|
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1135 | } |
|
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1136 | break; |
|
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1137 | default: |
|
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1138 | if (sip->registerstatus != SIMPLE_REGISTER_RETRY) { |
|
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1139 | purple_debug_info("simple", "Unrecognized return code for REGISTER.\n"); |
|
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1140 | if (sip->registrar.retries > SIMPLE_REGISTER_RETRY_MAX) { |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31949
diff
changeset
|
1141 | purple_connection_error(sip->gc, |
| 21279 | 1142 | PURPLE_CONNECTION_ERROR_OTHER_ERROR, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27350
diff
changeset
|
1143 | _("Unknown server response")); |
|
19991
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1144 | return TRUE; |
|
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1145 | } |
|
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1146 | sip->registerstatus = SIMPLE_REGISTER_RETRY; |
|
11194
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
1147 | do_register(sip); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1148 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1149 | break; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1150 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1151 | return TRUE; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1152 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1153 | |
|
21417
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1154 | static gboolean dialog_match(struct sip_dialog *dialog, struct sipmsg *msg) |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1155 | { |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1156 | const gchar *fromhdr; |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1157 | const gchar *tohdr; |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1158 | const gchar *callid; |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1159 | gchar *ourtag, *theirtag; |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1160 | gboolean match = FALSE; |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1161 | |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1162 | fromhdr = sipmsg_find_header(msg, "From"); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1163 | tohdr = sipmsg_find_header(msg, "To"); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1164 | callid = sipmsg_find_header(msg, "Call-ID"); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1165 | |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1166 | if (!fromhdr || !tohdr || !callid) |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1167 | return FALSE; |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1168 | |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1169 | ourtag = find_tag(tohdr); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1170 | theirtag = find_tag(fromhdr); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1171 | |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1172 | if (ourtag && theirtag && |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1173 | !strcmp(dialog->callid, callid) && |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1174 | !strcmp(dialog->ourtag, ourtag) && |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1175 | !strcmp(dialog->theirtag, theirtag)) |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1176 | match = TRUE; |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1177 | |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1178 | g_free(ourtag); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1179 | g_free(theirtag); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1180 | |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1181 | return match; |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1182 | } |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1183 | |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1184 | static void process_incoming_notify(struct simple_account_data *sip, struct sipmsg *msg) { |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1185 | gchar *from; |
|
21100
814637ced463
Some constification, which also found and fixed some potential double-free
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21076
diff
changeset
|
1186 | const gchar *fromhdr; |
|
20989
5707d9d29718
Patch from Will Hawkins for some cleanup of the SIMPLE notify message processing. This should hopefully fix some cases when a user signs off but we don't notice. Fixes #3507.
Daniel Atallah <datallah@pidgin.im>
parents:
20988
diff
changeset
|
1187 | gchar *basicstatus_data; |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1188 | xmlnode *pidf; |
|
14132
2325b60d8b77
[gaim-migrate @ 16691]
Daniel Atallah <datallah@pidgin.im>
parents:
14131
diff
changeset
|
1189 | xmlnode *basicstatus = NULL, *tuple, *status; |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1190 | gboolean isonline = FALSE; |
|
21417
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1191 | struct simple_buddy *b = NULL; |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1192 | const gchar *sshdr = NULL; |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1193 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
1194 | fromhdr = sipmsg_find_header(msg, "From"); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1195 | from = parse_from(fromhdr); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1196 | if(!from) return; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1197 | |
|
21417
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1198 | b = g_hash_table_lookup(sip->buddies, from); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1199 | if (!b) |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1200 | { |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1201 | g_free(from); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1202 | purple_debug_info("simple", "Could not find the buddy.\n"); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1203 | return; |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1204 | } |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1205 | |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1206 | if (b->dialog && !dialog_match(b->dialog, msg)) |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1207 | { |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1208 | /* We only accept notifies from people that |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1209 | * we already have a dialog with. |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1210 | */ |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1211 | purple_debug_info("simple","No corresponding dialog for notify--discard\n"); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1212 | g_free(from); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1213 | return; |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1214 | } |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1215 | |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1216 | pidf = xmlnode_from_str(msg->body, msg->bodylen); |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
1217 | |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1218 | if(!pidf) { |
| 15884 | 1219 | purple_debug_info("simple", "process_incoming_notify: no parseable pidf\n"); |
|
21417
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1220 | sshdr = sipmsg_find_header(msg, "Subscription-State"); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1221 | if (sshdr) |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1222 | { |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1223 | int i = 0; |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1224 | gchar **ssparts = g_strsplit(sshdr, ":", 0); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1225 | while (ssparts[i]) |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1226 | { |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1227 | g_strchug(ssparts[i]); |
|
22634
faaadc2d74bb
Use purple_str_has_prefix which provides backwards compatibility with older
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22388
diff
changeset
|
1228 | if (purple_str_has_prefix(ssparts[i], "terminated")) |
|
21417
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1229 | { |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1230 | purple_debug_info("simple", "Subscription expired!"); |
| 24638 | 1231 | if (b->dialog) |
| 1232 | { | |
| 1233 | g_free(b->dialog->ourtag); | |
| 1234 | g_free(b->dialog->theirtag); | |
| 1235 | g_free(b->dialog->callid); | |
| 1236 | g_free(b->dialog); | |
| 1237 | b->dialog = NULL; | |
| 1238 | } | |
|
21417
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1239 | |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1240 | purple_prpl_got_user_status(sip->account, from, "offline", NULL); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1241 | break; |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1242 | } |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1243 | i++; |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1244 | } |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1245 | g_strfreev(ssparts); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1246 | } |
|
20989
5707d9d29718
Patch from Will Hawkins for some cleanup of the SIMPLE notify message processing. This should hopefully fix some cases when a user signs off but we don't notice. Fixes #3507.
Daniel Atallah <datallah@pidgin.im>
parents:
20988
diff
changeset
|
1247 | send_sip_response(sip->gc, msg, 200, "OK", NULL); |
|
18840
05aeff1821c4
Fix from Will Hawkins to plug some leaks in error cases for the SIMPLE prpl. References #2181.
Daniel Atallah <datallah@pidgin.im>
parents:
18552
diff
changeset
|
1248 | g_free(from); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1249 | return; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1250 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1251 | |
|
14132
2325b60d8b77
[gaim-migrate @ 16691]
Daniel Atallah <datallah@pidgin.im>
parents:
14131
diff
changeset
|
1252 | if ((tuple = xmlnode_get_child(pidf, "tuple"))) |
|
2325b60d8b77
[gaim-migrate @ 16691]
Daniel Atallah <datallah@pidgin.im>
parents:
14131
diff
changeset
|
1253 | if ((status = xmlnode_get_child(tuple, "status"))) |
|
2325b60d8b77
[gaim-migrate @ 16691]
Daniel Atallah <datallah@pidgin.im>
parents:
14131
diff
changeset
|
1254 | basicstatus = xmlnode_get_child(status, "basic"); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1255 | |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1256 | if(!basicstatus) { |
| 15884 | 1257 | purple_debug_info("simple", "process_incoming_notify: no basic found\n"); |
|
14132
2325b60d8b77
[gaim-migrate @ 16691]
Daniel Atallah <datallah@pidgin.im>
parents:
14131
diff
changeset
|
1258 | xmlnode_free(pidf); |
|
18840
05aeff1821c4
Fix from Will Hawkins to plug some leaks in error cases for the SIMPLE prpl. References #2181.
Daniel Atallah <datallah@pidgin.im>
parents:
18552
diff
changeset
|
1259 | g_free(from); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1260 | return; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1261 | } |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
1262 | |
|
20989
5707d9d29718
Patch from Will Hawkins for some cleanup of the SIMPLE notify message processing. This should hopefully fix some cases when a user signs off but we don't notice. Fixes #3507.
Daniel Atallah <datallah@pidgin.im>
parents:
20988
diff
changeset
|
1263 | basicstatus_data = xmlnode_get_data(basicstatus); |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
1264 | |
|
20989
5707d9d29718
Patch from Will Hawkins for some cleanup of the SIMPLE notify message processing. This should hopefully fix some cases when a user signs off but we don't notice. Fixes #3507.
Daniel Atallah <datallah@pidgin.im>
parents:
20988
diff
changeset
|
1265 | if(!basicstatus_data) { |
| 15884 | 1266 | purple_debug_info("simple", "process_incoming_notify: no basic data found\n"); |
|
14132
2325b60d8b77
[gaim-migrate @ 16691]
Daniel Atallah <datallah@pidgin.im>
parents:
14131
diff
changeset
|
1267 | xmlnode_free(pidf); |
|
18840
05aeff1821c4
Fix from Will Hawkins to plug some leaks in error cases for the SIMPLE prpl. References #2181.
Daniel Atallah <datallah@pidgin.im>
parents:
18552
diff
changeset
|
1268 | g_free(from); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1269 | return; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1270 | } |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
1271 | |
|
20989
5707d9d29718
Patch from Will Hawkins for some cleanup of the SIMPLE notify message processing. This should hopefully fix some cases when a user signs off but we don't notice. Fixes #3507.
Daniel Atallah <datallah@pidgin.im>
parents:
20988
diff
changeset
|
1272 | if(strstr(basicstatus_data, "open")) |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1273 | isonline = TRUE; |
|
20989
5707d9d29718
Patch from Will Hawkins for some cleanup of the SIMPLE notify message processing. This should hopefully fix some cases when a user signs off but we don't notice. Fixes #3507.
Daniel Atallah <datallah@pidgin.im>
parents:
20988
diff
changeset
|
1274 | |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1275 | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
1276 | if(isonline) |
|
20989
5707d9d29718
Patch from Will Hawkins for some cleanup of the SIMPLE notify message processing. This should hopefully fix some cases when a user signs off but we don't notice. Fixes #3507.
Daniel Atallah <datallah@pidgin.im>
parents:
20988
diff
changeset
|
1277 | purple_prpl_got_user_status(sip->account, from, "available", NULL); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
1278 | else |
|
20989
5707d9d29718
Patch from Will Hawkins for some cleanup of the SIMPLE notify message processing. This should hopefully fix some cases when a user signs off but we don't notice. Fixes #3507.
Daniel Atallah <datallah@pidgin.im>
parents:
20988
diff
changeset
|
1279 | purple_prpl_got_user_status(sip->account, from, "offline", NULL); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1280 | |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1281 | xmlnode_free(pidf); |
|
20989
5707d9d29718
Patch from Will Hawkins for some cleanup of the SIMPLE notify message processing. This should hopefully fix some cases when a user signs off but we don't notice. Fixes #3507.
Daniel Atallah <datallah@pidgin.im>
parents:
20988
diff
changeset
|
1282 | g_free(from); |
|
5707d9d29718
Patch from Will Hawkins for some cleanup of the SIMPLE notify message processing. This should hopefully fix some cases when a user signs off but we don't notice. Fixes #3507.
Daniel Atallah <datallah@pidgin.im>
parents:
20988
diff
changeset
|
1283 | g_free(basicstatus_data); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1284 | |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1285 | send_sip_response(sip->gc, msg, 200, "OK", NULL); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1286 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1287 | |
| 15884 | 1288 | static unsigned int simple_typing(PurpleConnection *gc, const char *name, PurpleTypingState state) { |
|
32266
af94a3153685
Convert simple prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
1289 | struct simple_account_data *sip = purple_connection_get_protocol_data(gc); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1290 | |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1291 | gchar *xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1292 | "<isComposing xmlns=\"urn:ietf:params:xml:ns:im-iscomposing\"\n" |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1293 | "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1294 | "xsi:schemaLocation=\"urn:ietf:params:xml:ns:im-composing iscomposing.xsd\">\n" |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1295 | "<state>%s</state>\n" |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1296 | "<contenttype>text/plain</contenttype>\n" |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1297 | "<refresh>60</refresh>\n" |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1298 | "</isComposing>"; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1299 | gchar *recv = g_strdup(name); |
| 15884 | 1300 | if(state == PURPLE_TYPING) { |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1301 | gchar *msg = g_strdup_printf(xml, "active"); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1302 | simple_send_message(sip, recv, msg, "application/im-iscomposing+xml"); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1303 | g_free(msg); |
| 15884 | 1304 | } else /* TODO: Only if (state == PURPLE_TYPED) ? */ { |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1305 | gchar *msg = g_strdup_printf(xml, "idle"); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1306 | simple_send_message(sip, recv, msg, "application/im-iscomposing+xml"); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1307 | g_free(msg); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1308 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1309 | g_free(recv); |
|
13844
835b8f7b3d1d
[gaim-migrate @ 16295]
Mark Doliner <markdoliner@pidgin.im>
parents:
13751
diff
changeset
|
1310 | /* |
|
835b8f7b3d1d
[gaim-migrate @ 16295]
Mark Doliner <markdoliner@pidgin.im>
parents:
13751
diff
changeset
|
1311 | * TODO: Is this right? It will cause the core to call |
| 15884 | 1312 | * serv_send_typing(gc, who, PURPLE_TYPING) once every second |
|
13844
835b8f7b3d1d
[gaim-migrate @ 16295]
Mark Doliner <markdoliner@pidgin.im>
parents:
13751
diff
changeset
|
1313 | * until the user stops typing. If that's not desired, |
|
835b8f7b3d1d
[gaim-migrate @ 16295]
Mark Doliner <markdoliner@pidgin.im>
parents:
13751
diff
changeset
|
1314 | * then return 0 instead. |
|
835b8f7b3d1d
[gaim-migrate @ 16295]
Mark Doliner <markdoliner@pidgin.im>
parents:
13751
diff
changeset
|
1315 | */ |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1316 | return 1; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1317 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1318 | |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
1319 | static gchar *find_tag(const gchar *hdr) { |
|
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
1320 | const gchar *tmp = strstr(hdr, ";tag="), *tmp2; |
|
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
1321 | |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1322 | if(!tmp) return NULL; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1323 | tmp += 5; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1324 | if((tmp2 = strchr(tmp, ';'))) { |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
1325 | return g_strndup(tmp, tmp2 - tmp); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1326 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1327 | return g_strdup(tmp); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1328 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1329 | |
|
13178
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1330 | static gchar* gen_xpidf(struct simple_account_data *sip) { |
|
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1331 | gchar *doc = g_strdup_printf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" |
|
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1332 | "<presence>\n" |
|
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1333 | "<presentity uri=\"sip:%s@%s;method=SUBSCRIBE\"/>\n" |
|
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1334 | "<display name=\"sip:%s@%s\"/>\n" |
|
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1335 | "<atom id=\"1234\">\n" |
|
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1336 | "<address uri=\"sip:%s@%s\">\n" |
|
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1337 | "<status status=\"%s\"/>\n" |
|
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1338 | "</address>\n" |
|
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1339 | "</atom>\n" |
|
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1340 | "</presence>\n", |
|
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1341 | sip->username, |
|
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1342 | sip->servername, |
|
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1343 | sip->username, |
|
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1344 | sip->servername, |
|
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1345 | sip->username, |
|
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1346 | sip->servername, |
|
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1347 | sip->status); |
|
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1348 | return doc; |
|
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1349 | } |
|
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1350 | |
|
20988
75eab0f2aa19
Patch from Will Hawkins to publish a status of closed when signing out of a SIMPLE account. Fixes #1914.
Daniel Atallah <datallah@pidgin.im>
parents:
20658
diff
changeset
|
1351 | static gchar* gen_pidf(struct simple_account_data *sip, gboolean open) { |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1352 | gchar *doc = g_strdup_printf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
1353 | "<presence xmlns=\"urn:ietf:params:xml:ns:pidf\"\n" |
|
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
1354 | "xmlns:im=\"urn:ietf:params:xml:ns:pidf:im\"\n" |
|
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
1355 | "entity=\"sip:%s@%s\">\n" |
|
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
1356 | "<tuple id=\"bs35r9f\">\n" |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1357 | "<status>\n" |
|
20988
75eab0f2aa19
Patch from Will Hawkins to publish a status of closed when signing out of a SIMPLE account. Fixes #1914.
Daniel Atallah <datallah@pidgin.im>
parents:
20658
diff
changeset
|
1358 | "<basic>%s</basic>\n" |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1359 | "</status>\n" |
|
13656
32db312f1b9c
[gaim-migrate @ 16057]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13581
diff
changeset
|
1360 | "<note>%s</note>\n" |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1361 | "</tuple>\n" |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1362 | "</presence>", |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1363 | sip->username, |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1364 | sip->servername, |
|
20988
75eab0f2aa19
Patch from Will Hawkins to publish a status of closed when signing out of a SIMPLE account. Fixes #1914.
Daniel Atallah <datallah@pidgin.im>
parents:
20658
diff
changeset
|
1365 | (open == TRUE) ? "open" : "closed", |
|
75eab0f2aa19
Patch from Will Hawkins to publish a status of closed when signing out of a SIMPLE account. Fixes #1914.
Daniel Atallah <datallah@pidgin.im>
parents:
20658
diff
changeset
|
1366 | (open == TRUE) ? sip->status : ""); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1367 | return doc; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1368 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1369 | |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1370 | static void send_notify(struct simple_account_data *sip, struct simple_watcher *watcher) { |
|
20988
75eab0f2aa19
Patch from Will Hawkins to publish a status of closed when signing out of a SIMPLE account. Fixes #1914.
Daniel Atallah <datallah@pidgin.im>
parents:
20658
diff
changeset
|
1371 | gchar *doc = watcher->needsxpidf ? gen_xpidf(sip) : gen_pidf(sip, TRUE); |
|
13178
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1372 | gchar *hdr = watcher->needsxpidf ? "Event: presence\r\nContent-Type: application/xpidf+xml\r\n" : "Event: presence\r\nContent-Type: application/pidf+xml\r\n"; |
|
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1373 | send_sip_request(sip->gc, "NOTIFY", watcher->name, watcher->name, hdr, doc, &watcher->dialog, NULL); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1374 | g_free(doc); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1375 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1376 | |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1377 | static gboolean process_publish_response(struct simple_account_data *sip, struct sipmsg *msg, struct transaction *tc) { |
|
22182
0a0d7e312397
Patch from Will Hawkins to implement sending a SIP-If-Match header on subsequent PUBLISHes after receiving a SIP-Etag header. I made some minor tweaks to this, hopefully I didn't break anything. Fixes #4422.
Daniel Atallah <datallah@pidgin.im>
parents:
22104
diff
changeset
|
1378 | |
|
0a0d7e312397
Patch from Will Hawkins to implement sending a SIP-If-Match header on subsequent PUBLISHes after receiving a SIP-Etag header. I made some minor tweaks to this, hopefully I didn't break anything. Fixes #4422.
Daniel Atallah <datallah@pidgin.im>
parents:
22104
diff
changeset
|
1379 | const gchar *etag = NULL; |
|
0a0d7e312397
Patch from Will Hawkins to implement sending a SIP-If-Match header on subsequent PUBLISHes after receiving a SIP-Etag header. I made some minor tweaks to this, hopefully I didn't break anything. Fixes #4422.
Daniel Atallah <datallah@pidgin.im>
parents:
22104
diff
changeset
|
1380 | |
|
11345
48a2f93e47b6
[gaim-migrate @ 13562]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11341
diff
changeset
|
1381 | if(msg->response != 200 && msg->response != 408) { |
|
11341
5511bbeeb3b4
[gaim-migrate @ 13555]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11327
diff
changeset
|
1382 | /* never send again */ |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1383 | sip->republish = -1; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1384 | } |
|
22182
0a0d7e312397
Patch from Will Hawkins to implement sending a SIP-If-Match header on subsequent PUBLISHes after receiving a SIP-Etag header. I made some minor tweaks to this, hopefully I didn't break anything. Fixes #4422.
Daniel Atallah <datallah@pidgin.im>
parents:
22104
diff
changeset
|
1385 | |
|
0a0d7e312397
Patch from Will Hawkins to implement sending a SIP-If-Match header on subsequent PUBLISHes after receiving a SIP-Etag header. I made some minor tweaks to this, hopefully I didn't break anything. Fixes #4422.
Daniel Atallah <datallah@pidgin.im>
parents:
22104
diff
changeset
|
1386 | etag = sipmsg_find_header(msg, "SIP-Etag"); |
|
0a0d7e312397
Patch from Will Hawkins to implement sending a SIP-If-Match header on subsequent PUBLISHes after receiving a SIP-Etag header. I made some minor tweaks to this, hopefully I didn't break anything. Fixes #4422.
Daniel Atallah <datallah@pidgin.im>
parents:
22104
diff
changeset
|
1387 | if (etag) { |
|
0a0d7e312397
Patch from Will Hawkins to implement sending a SIP-If-Match header on subsequent PUBLISHes after receiving a SIP-Etag header. I made some minor tweaks to this, hopefully I didn't break anything. Fixes #4422.
Daniel Atallah <datallah@pidgin.im>
parents:
22104
diff
changeset
|
1388 | /* we must store the etag somewhere. */ |
|
0a0d7e312397
Patch from Will Hawkins to implement sending a SIP-If-Match header on subsequent PUBLISHes after receiving a SIP-Etag header. I made some minor tweaks to this, hopefully I didn't break anything. Fixes #4422.
Daniel Atallah <datallah@pidgin.im>
parents:
22104
diff
changeset
|
1389 | g_free(sip->publish_etag); |
|
0a0d7e312397
Patch from Will Hawkins to implement sending a SIP-If-Match header on subsequent PUBLISHes after receiving a SIP-Etag header. I made some minor tweaks to this, hopefully I didn't break anything. Fixes #4422.
Daniel Atallah <datallah@pidgin.im>
parents:
22104
diff
changeset
|
1390 | sip->publish_etag = g_strdup(etag); |
|
0a0d7e312397
Patch from Will Hawkins to implement sending a SIP-If-Match header on subsequent PUBLISHes after receiving a SIP-Etag header. I made some minor tweaks to this, hopefully I didn't break anything. Fixes #4422.
Daniel Atallah <datallah@pidgin.im>
parents:
22104
diff
changeset
|
1391 | } |
|
0a0d7e312397
Patch from Will Hawkins to implement sending a SIP-If-Match header on subsequent PUBLISHes after receiving a SIP-Etag header. I made some minor tweaks to this, hopefully I didn't break anything. Fixes #4422.
Daniel Atallah <datallah@pidgin.im>
parents:
22104
diff
changeset
|
1392 | |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1393 | return TRUE; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1394 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1395 | |
|
20988
75eab0f2aa19
Patch from Will Hawkins to publish a status of closed when signing out of a SIMPLE account. Fixes #1914.
Daniel Atallah <datallah@pidgin.im>
parents:
20658
diff
changeset
|
1396 | static void send_open_publish(struct simple_account_data *sip) { |
|
21417
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1397 | gchar *add_headers = NULL; |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1398 | gchar *uri = g_strdup_printf("sip:%s@%s", sip->username, sip->servername); |
|
20988
75eab0f2aa19
Patch from Will Hawkins to publish a status of closed when signing out of a SIMPLE account. Fixes #1914.
Daniel Atallah <datallah@pidgin.im>
parents:
20658
diff
changeset
|
1399 | gchar *doc = gen_pidf(sip, TRUE); |
|
21417
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1400 | |
|
22182
0a0d7e312397
Patch from Will Hawkins to implement sending a SIP-If-Match header on subsequent PUBLISHes after receiving a SIP-Etag header. I made some minor tweaks to this, hopefully I didn't break anything. Fixes #4422.
Daniel Atallah <datallah@pidgin.im>
parents:
22104
diff
changeset
|
1401 | add_headers = g_strdup_printf("%s%s%s%s%d\r\n%s", |
|
0a0d7e312397
Patch from Will Hawkins to implement sending a SIP-If-Match header on subsequent PUBLISHes after receiving a SIP-Etag header. I made some minor tweaks to this, hopefully I didn't break anything. Fixes #4422.
Daniel Atallah <datallah@pidgin.im>
parents:
22104
diff
changeset
|
1402 | sip->publish_etag ? "SIP-If-Match: " : "", |
|
0a0d7e312397
Patch from Will Hawkins to implement sending a SIP-If-Match header on subsequent PUBLISHes after receiving a SIP-Etag header. I made some minor tweaks to this, hopefully I didn't break anything. Fixes #4422.
Daniel Atallah <datallah@pidgin.im>
parents:
22104
diff
changeset
|
1403 | sip->publish_etag ? sip->publish_etag : "", |
|
0a0d7e312397
Patch from Will Hawkins to implement sending a SIP-If-Match header on subsequent PUBLISHes after receiving a SIP-Etag header. I made some minor tweaks to this, hopefully I didn't break anything. Fixes #4422.
Daniel Atallah <datallah@pidgin.im>
parents:
22104
diff
changeset
|
1404 | sip->publish_etag ? "\r\n" : "", |
|
0a0d7e312397
Patch from Will Hawkins to implement sending a SIP-If-Match header on subsequent PUBLISHes after receiving a SIP-Etag header. I made some minor tweaks to this, hopefully I didn't break anything. Fixes #4422.
Daniel Atallah <datallah@pidgin.im>
parents:
22104
diff
changeset
|
1405 | "Expires: ", PUBLISH_EXPIRATION, |
|
0a0d7e312397
Patch from Will Hawkins to implement sending a SIP-If-Match header on subsequent PUBLISHes after receiving a SIP-Etag header. I made some minor tweaks to this, hopefully I didn't break anything. Fixes #4422.
Daniel Atallah <datallah@pidgin.im>
parents:
22104
diff
changeset
|
1406 | "Event: presence\r\n" |
|
21417
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1407 | "Content-Type: application/pidf+xml\r\n"); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1408 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
1409 | send_sip_request(sip->gc, "PUBLISH", uri, uri, |
|
21417
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1410 | add_headers, doc, NULL, process_publish_response); |
|
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1411 | sip->republish = time(NULL) + PUBLISH_EXPIRATION - 50; |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
1412 | g_free(uri); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1413 | g_free(doc); |
|
21417
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1414 | g_free(add_headers); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1415 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1416 | |
|
20988
75eab0f2aa19
Patch from Will Hawkins to publish a status of closed when signing out of a SIMPLE account. Fixes #1914.
Daniel Atallah <datallah@pidgin.im>
parents:
20658
diff
changeset
|
1417 | static void send_closed_publish(struct simple_account_data *sip) { |
|
75eab0f2aa19
Patch from Will Hawkins to publish a status of closed when signing out of a SIMPLE account. Fixes #1914.
Daniel Atallah <datallah@pidgin.im>
parents:
20658
diff
changeset
|
1418 | gchar *uri = g_strdup_printf("sip:%s@%s", sip->username, sip->servername); |
|
22182
0a0d7e312397
Patch from Will Hawkins to implement sending a SIP-If-Match header on subsequent PUBLISHes after receiving a SIP-Etag header. I made some minor tweaks to this, hopefully I didn't break anything. Fixes #4422.
Daniel Atallah <datallah@pidgin.im>
parents:
22104
diff
changeset
|
1419 | gchar *add_headers, *doc; |
|
0a0d7e312397
Patch from Will Hawkins to implement sending a SIP-If-Match header on subsequent PUBLISHes after receiving a SIP-Etag header. I made some minor tweaks to this, hopefully I didn't break anything. Fixes #4422.
Daniel Atallah <datallah@pidgin.im>
parents:
22104
diff
changeset
|
1420 | |
|
0a0d7e312397
Patch from Will Hawkins to implement sending a SIP-If-Match header on subsequent PUBLISHes after receiving a SIP-Etag header. I made some minor tweaks to this, hopefully I didn't break anything. Fixes #4422.
Daniel Atallah <datallah@pidgin.im>
parents:
22104
diff
changeset
|
1421 | add_headers = g_strdup_printf("%s%s%s%s", |
|
0a0d7e312397
Patch from Will Hawkins to implement sending a SIP-If-Match header on subsequent PUBLISHes after receiving a SIP-Etag header. I made some minor tweaks to this, hopefully I didn't break anything. Fixes #4422.
Daniel Atallah <datallah@pidgin.im>
parents:
22104
diff
changeset
|
1422 | sip->publish_etag ? "SIP-If-Match: " : "", |
|
0a0d7e312397
Patch from Will Hawkins to implement sending a SIP-If-Match header on subsequent PUBLISHes after receiving a SIP-Etag header. I made some minor tweaks to this, hopefully I didn't break anything. Fixes #4422.
Daniel Atallah <datallah@pidgin.im>
parents:
22104
diff
changeset
|
1423 | sip->publish_etag ? sip->publish_etag : "", |
|
0a0d7e312397
Patch from Will Hawkins to implement sending a SIP-If-Match header on subsequent PUBLISHes after receiving a SIP-Etag header. I made some minor tweaks to this, hopefully I didn't break anything. Fixes #4422.
Daniel Atallah <datallah@pidgin.im>
parents:
22104
diff
changeset
|
1424 | sip->publish_etag ? "\r\n" : "", |
|
0a0d7e312397
Patch from Will Hawkins to implement sending a SIP-If-Match header on subsequent PUBLISHes after receiving a SIP-Etag header. I made some minor tweaks to this, hopefully I didn't break anything. Fixes #4422.
Daniel Atallah <datallah@pidgin.im>
parents:
22104
diff
changeset
|
1425 | "Expires: 600\r\n" |
|
0a0d7e312397
Patch from Will Hawkins to implement sending a SIP-If-Match header on subsequent PUBLISHes after receiving a SIP-Etag header. I made some minor tweaks to this, hopefully I didn't break anything. Fixes #4422.
Daniel Atallah <datallah@pidgin.im>
parents:
22104
diff
changeset
|
1426 | "Event: presence\r\n" |
|
0a0d7e312397
Patch from Will Hawkins to implement sending a SIP-If-Match header on subsequent PUBLISHes after receiving a SIP-Etag header. I made some minor tweaks to this, hopefully I didn't break anything. Fixes #4422.
Daniel Atallah <datallah@pidgin.im>
parents:
22104
diff
changeset
|
1427 | "Content-Type: application/pidf+xml\r\n"); |
|
0a0d7e312397
Patch from Will Hawkins to implement sending a SIP-If-Match header on subsequent PUBLISHes after receiving a SIP-Etag header. I made some minor tweaks to this, hopefully I didn't break anything. Fixes #4422.
Daniel Atallah <datallah@pidgin.im>
parents:
22104
diff
changeset
|
1428 | |
|
0a0d7e312397
Patch from Will Hawkins to implement sending a SIP-If-Match header on subsequent PUBLISHes after receiving a SIP-Etag header. I made some minor tweaks to this, hopefully I didn't break anything. Fixes #4422.
Daniel Atallah <datallah@pidgin.im>
parents:
22104
diff
changeset
|
1429 | doc = gen_pidf(sip, FALSE); |
|
0a0d7e312397
Patch from Will Hawkins to implement sending a SIP-If-Match header on subsequent PUBLISHes after receiving a SIP-Etag header. I made some minor tweaks to this, hopefully I didn't break anything. Fixes #4422.
Daniel Atallah <datallah@pidgin.im>
parents:
22104
diff
changeset
|
1430 | send_sip_request(sip->gc, "PUBLISH", uri, uri, add_headers, |
|
20988
75eab0f2aa19
Patch from Will Hawkins to publish a status of closed when signing out of a SIMPLE account. Fixes #1914.
Daniel Atallah <datallah@pidgin.im>
parents:
20658
diff
changeset
|
1431 | doc, NULL, process_publish_response); |
|
75eab0f2aa19
Patch from Will Hawkins to publish a status of closed when signing out of a SIMPLE account. Fixes #1914.
Daniel Atallah <datallah@pidgin.im>
parents:
20658
diff
changeset
|
1432 | /*sip->republish = time(NULL) + 500;*/ |
|
75eab0f2aa19
Patch from Will Hawkins to publish a status of closed when signing out of a SIMPLE account. Fixes #1914.
Daniel Atallah <datallah@pidgin.im>
parents:
20658
diff
changeset
|
1433 | g_free(uri); |
|
75eab0f2aa19
Patch from Will Hawkins to publish a status of closed when signing out of a SIMPLE account. Fixes #1914.
Daniel Atallah <datallah@pidgin.im>
parents:
20658
diff
changeset
|
1434 | g_free(doc); |
|
22182
0a0d7e312397
Patch from Will Hawkins to implement sending a SIP-If-Match header on subsequent PUBLISHes after receiving a SIP-Etag header. I made some minor tweaks to this, hopefully I didn't break anything. Fixes #4422.
Daniel Atallah <datallah@pidgin.im>
parents:
22104
diff
changeset
|
1435 | g_free(add_headers); |
|
20988
75eab0f2aa19
Patch from Will Hawkins to publish a status of closed when signing out of a SIMPLE account. Fixes #1914.
Daniel Atallah <datallah@pidgin.im>
parents:
20658
diff
changeset
|
1436 | } |
|
75eab0f2aa19
Patch from Will Hawkins to publish a status of closed when signing out of a SIMPLE account. Fixes #1914.
Daniel Atallah <datallah@pidgin.im>
parents:
20658
diff
changeset
|
1437 | |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1438 | static void process_incoming_subscribe(struct simple_account_data *sip, struct sipmsg *msg) { |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
1439 | const char *from_hdr = sipmsg_find_header(msg, "From"); |
|
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
1440 | gchar *from = parse_from(from_hdr); |
|
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
1441 | gchar *theirtag = find_tag(from_hdr); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1442 | gchar *ourtag = find_tag(sipmsg_find_header(msg, "To")); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1443 | gboolean tagadded = FALSE; |
|
21100
814637ced463
Some constification, which also found and fixed some potential double-free
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21076
diff
changeset
|
1444 | const gchar *callid = sipmsg_find_header(msg, "Call-ID"); |
|
814637ced463
Some constification, which also found and fixed some potential double-free
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21076
diff
changeset
|
1445 | const gchar *expire = sipmsg_find_header(msg, "Expire"); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1446 | gchar *tmp; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1447 | struct simple_watcher *watcher = watcher_find(sip, from); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1448 | if(!ourtag) { |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1449 | tagadded = TRUE; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1450 | ourtag = gentag(); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1451 | } |
|
11341
5511bbeeb3b4
[gaim-migrate @ 13555]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11327
diff
changeset
|
1452 | if(!watcher) { /* new subscription */ |
|
21100
814637ced463
Some constification, which also found and fixed some potential double-free
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21076
diff
changeset
|
1453 | const gchar *acceptheader = sipmsg_find_header(msg, "Accept"); |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
1454 | gboolean needsxpidf = FALSE; |
| 15884 | 1455 | if(!purple_privacy_check(sip->account, from)) { |
|
11345
48a2f93e47b6
[gaim-migrate @ 13562]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11341
diff
changeset
|
1456 | send_sip_response(sip->gc, msg, 202, "Ok", NULL); |
|
48a2f93e47b6
[gaim-migrate @ 13562]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11341
diff
changeset
|
1457 | goto privend; |
|
48a2f93e47b6
[gaim-migrate @ 13562]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11341
diff
changeset
|
1458 | } |
|
13178
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1459 | if(acceptheader) { |
|
21100
814637ced463
Some constification, which also found and fixed some potential double-free
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21076
diff
changeset
|
1460 | const gchar *tmp = acceptheader; |
|
14132
2325b60d8b77
[gaim-migrate @ 16691]
Daniel Atallah <datallah@pidgin.im>
parents:
14131
diff
changeset
|
1461 | gboolean foundpidf = FALSE; |
|
2325b60d8b77
[gaim-migrate @ 16691]
Daniel Atallah <datallah@pidgin.im>
parents:
14131
diff
changeset
|
1462 | gboolean foundxpidf = FALSE; |
|
13178
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1463 | while(tmp && tmp < acceptheader + strlen(acceptheader)) { |
|
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1464 | gchar *tmp2 = strchr(tmp, ','); |
|
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1465 | if(tmp2) *tmp2 = '\0'; |
|
17155
143ff2796376
Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@pidgin.im>
parents:
16746
diff
changeset
|
1466 | if(!g_ascii_strcasecmp("application/pidf+xml", tmp)) |
|
14132
2325b60d8b77
[gaim-migrate @ 16691]
Daniel Atallah <datallah@pidgin.im>
parents:
14131
diff
changeset
|
1467 | foundpidf = TRUE; |
|
17155
143ff2796376
Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@pidgin.im>
parents:
16746
diff
changeset
|
1468 | if(!g_ascii_strcasecmp("application/xpidf+xml", tmp)) |
|
14132
2325b60d8b77
[gaim-migrate @ 16691]
Daniel Atallah <datallah@pidgin.im>
parents:
14131
diff
changeset
|
1469 | foundxpidf = TRUE; |
|
13178
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1470 | if(tmp2) { |
|
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1471 | *tmp2 = ','; |
|
17653
a71ca6b486a0
Fix a freeze caused by improper SIMPLE message parsing. Thanks, Michal Matyska! Fixes #1037
Sean Egan <seanegan@pidgin.im>
parents:
17226
diff
changeset
|
1472 | tmp = tmp2 + 1; |
|
13178
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1473 | while(*tmp == ' ') tmp++; |
|
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1474 | } else |
|
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1475 | tmp = 0; |
|
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1476 | } |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
1477 | if(!foundpidf && foundxpidf) needsxpidf = TRUE; |
|
13178
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1478 | } |
|
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1479 | watcher = watcher_create(sip, from, callid, ourtag, theirtag, needsxpidf); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1480 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1481 | if(tagadded) { |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1482 | gchar *to = g_strdup_printf("%s;tag=%s", sipmsg_find_header(msg, "To"), ourtag); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1483 | sipmsg_remove_header(msg, "To"); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1484 | sipmsg_add_header(msg, "To", to); |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
1485 | g_free(to); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1486 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1487 | if(expire) |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1488 | watcher->expire = time(NULL) + strtol(expire, NULL, 10); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1489 | else |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1490 | watcher->expire = time(NULL) + 600; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1491 | sipmsg_remove_header(msg, "Contact"); |
|
13178
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1492 | tmp = get_contact(sip); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1493 | sipmsg_add_header(msg, "Contact", tmp); |
|
13178
824d50326672
[gaim-migrate @ 15540]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13130
diff
changeset
|
1494 | g_free(tmp); |
| 15884 | 1495 | purple_debug_info("simple", "got subscribe: name %s ourtag %s theirtag %s callid %s\n", watcher->name, watcher->dialog.ourtag, watcher->dialog.theirtag, watcher->dialog.callid); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1496 | send_sip_response(sip->gc, msg, 200, "Ok", NULL); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1497 | send_notify(sip, watcher); |
|
11345
48a2f93e47b6
[gaim-migrate @ 13562]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11341
diff
changeset
|
1498 | privend: |
|
48a2f93e47b6
[gaim-migrate @ 13562]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11341
diff
changeset
|
1499 | g_free(from); |
|
48a2f93e47b6
[gaim-migrate @ 13562]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11341
diff
changeset
|
1500 | g_free(theirtag); |
|
48a2f93e47b6
[gaim-migrate @ 13562]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11341
diff
changeset
|
1501 | g_free(ourtag); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1502 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1503 | |
|
11189
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
1504 | static void process_input_message(struct simple_account_data *sip, struct sipmsg *msg) { |
|
12745
1dc3525647c2
[gaim-migrate @ 15092]
Daniel Atallah <datallah@pidgin.im>
parents:
12741
diff
changeset
|
1505 | gboolean found = FALSE; |
|
1dc3525647c2
[gaim-migrate @ 15092]
Daniel Atallah <datallah@pidgin.im>
parents:
12741
diff
changeset
|
1506 | if(msg->response == 0) { /* request */ |
|
11189
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
1507 | if(!strcmp(msg->method, "MESSAGE")) { |
|
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
1508 | process_incoming_message(sip, msg); |
|
12745
1dc3525647c2
[gaim-migrate @ 15092]
Daniel Atallah <datallah@pidgin.im>
parents:
12741
diff
changeset
|
1509 | found = TRUE; |
|
1dc3525647c2
[gaim-migrate @ 15092]
Daniel Atallah <datallah@pidgin.im>
parents:
12741
diff
changeset
|
1510 | } else if(!strcmp(msg->method, "NOTIFY")) { |
|
11189
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
1511 | process_incoming_notify(sip, msg); |
|
12745
1dc3525647c2
[gaim-migrate @ 15092]
Daniel Atallah <datallah@pidgin.im>
parents:
12741
diff
changeset
|
1512 | found = TRUE; |
|
1dc3525647c2
[gaim-migrate @ 15092]
Daniel Atallah <datallah@pidgin.im>
parents:
12741
diff
changeset
|
1513 | } else if(!strcmp(msg->method, "SUBSCRIBE")) { |
|
11189
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
1514 | process_incoming_subscribe(sip, msg); |
|
12745
1dc3525647c2
[gaim-migrate @ 15092]
Daniel Atallah <datallah@pidgin.im>
parents:
12741
diff
changeset
|
1515 | found = TRUE; |
|
1dc3525647c2
[gaim-migrate @ 15092]
Daniel Atallah <datallah@pidgin.im>
parents:
12741
diff
changeset
|
1516 | } else { |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
1517 | send_sip_response(sip->gc, msg, 501, "Not implemented", NULL); |
|
11190
16f02ac58a38
[gaim-migrate @ 13308]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11189
diff
changeset
|
1518 | } |
|
11341
5511bbeeb3b4
[gaim-migrate @ 13555]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11327
diff
changeset
|
1519 | } else { /* response */ |
|
11189
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
1520 | struct transaction *trans = transactions_find(sip, msg); |
|
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
1521 | if(trans) { |
|
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
1522 | if(msg->response == 407) { |
|
21100
814637ced463
Some constification, which also found and fixed some potential double-free
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21076
diff
changeset
|
1523 | gchar *resend, *auth; |
|
814637ced463
Some constification, which also found and fixed some potential double-free
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21076
diff
changeset
|
1524 | const gchar *ptmp; |
|
11439
e76bc2f9deb0
[gaim-migrate @ 13676]
Daniel Atallah <datallah@pidgin.im>
parents:
11424
diff
changeset
|
1525 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
1526 | if(sip->proxy.retries > 3) return; |
|
11346
4af1dc4b2c44
[gaim-migrate @ 13563]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11345
diff
changeset
|
1527 | sip->proxy.retries++; |
|
11341
5511bbeeb3b4
[gaim-migrate @ 13555]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11327
diff
changeset
|
1528 | /* do proxy authentication */ |
|
11189
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
1529 | |
|
11439
e76bc2f9deb0
[gaim-migrate @ 13676]
Daniel Atallah <datallah@pidgin.im>
parents:
11424
diff
changeset
|
1530 | ptmp = sipmsg_find_header(msg, "Proxy-Authenticate"); |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
1531 | |
|
11189
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
1532 | fill_auth(sip, ptmp, &sip->proxy); |
|
11346
4af1dc4b2c44
[gaim-migrate @ 13563]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11345
diff
changeset
|
1533 | auth = auth_header(sip, &sip->proxy, trans->msg->method, trans->msg->target); |
|
13273
68a4ff81c348
[gaim-migrate @ 15638]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13201
diff
changeset
|
1534 | sipmsg_remove_header(trans->msg, "Proxy-Authorization"); |
|
11189
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
1535 | sipmsg_add_header(trans->msg, "Proxy-Authorization", auth); |
|
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
1536 | g_free(auth); |
|
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
1537 | resend = sipmsg_to_string(trans->msg); |
|
11341
5511bbeeb3b4
[gaim-migrate @ 13555]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11327
diff
changeset
|
1538 | /* resend request */ |
|
11189
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
1539 | sendout_pkt(sip->gc, resend); |
|
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
1540 | g_free(resend); |
|
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
1541 | } else { |
|
11517
a3d6d136b7dd
[gaim-migrate @ 13762]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11483
diff
changeset
|
1542 | if(msg->response == 100) { |
|
a3d6d136b7dd
[gaim-migrate @ 13762]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11483
diff
changeset
|
1543 | /* ignore provisional response */ |
| 15884 | 1544 | purple_debug_info("simple", "got trying response\n"); |
|
11517
a3d6d136b7dd
[gaim-migrate @ 13762]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11483
diff
changeset
|
1545 | } else { |
|
a3d6d136b7dd
[gaim-migrate @ 13762]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11483
diff
changeset
|
1546 | sip->proxy.retries = 0; |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
1547 | if(!strcmp(trans->msg->method, "REGISTER")) { |
|
19991
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1548 | |
|
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1549 | /* This is encountered when a REGISTER request was ... |
|
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1550 | */ |
|
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1551 | if(msg->response == 401) { |
|
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1552 | /* denied until further authentication was provided. */ |
|
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1553 | sip->registrar.retries++; |
|
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1554 | } |
|
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1555 | else if (msg->response != 200) { |
|
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1556 | /* denied for some other reason! */ |
|
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1557 | sip->registrar.retries++; |
|
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1558 | } |
|
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1559 | else { |
|
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1560 | /* accepted! */ |
|
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1561 | sip->registrar.retries = 0; |
|
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1562 | } |
|
13348
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
1563 | } else { |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
1564 | if(msg->response == 401) { |
|
19991
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1565 | /* This is encountered when a generic (MESSAGE, NOTIFY, etc) |
|
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1566 | * was denied until further authorization is provided. |
|
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1567 | */ |
|
21100
814637ced463
Some constification, which also found and fixed some potential double-free
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21076
diff
changeset
|
1568 | gchar *resend, *auth; |
|
814637ced463
Some constification, which also found and fixed some potential double-free
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21076
diff
changeset
|
1569 | const gchar *ptmp; |
|
13348
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
1570 | |
|
19991
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1571 | if(sip->registrar.retries > SIMPLE_REGISTER_RETRY_MAX) return; |
|
13348
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
1572 | sip->registrar.retries++; |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
1573 | |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
1574 | ptmp = sipmsg_find_header(msg, "WWW-Authenticate"); |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
1575 | |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
1576 | fill_auth(sip, ptmp, &sip->registrar); |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
1577 | auth = auth_header(sip, &sip->registrar, trans->msg->method, trans->msg->target); |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
1578 | sipmsg_remove_header(trans->msg, "Authorization"); |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
1579 | sipmsg_add_header(trans->msg, "Authorization", auth); |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
1580 | g_free(auth); |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
1581 | resend = sipmsg_to_string(trans->msg); |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
1582 | /* resend request */ |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
1583 | sendout_pkt(sip->gc, resend); |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
1584 | g_free(resend); |
|
19991
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1585 | } else { |
|
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1586 | /* Reset any count of retries that may have |
|
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1587 | * accumulated in the above branch. |
|
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1588 | */ |
|
603d11d2afa7
Fixes #3051 Patch from Will Hawkins to clean up SIMPLE login and registration
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
1589 | sip->registrar.retries = 0; |
|
13348
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
1590 | } |
|
1fe9d587d705
[gaim-migrate @ 15717]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13297
diff
changeset
|
1591 | } |
|
11517
a3d6d136b7dd
[gaim-migrate @ 13762]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11483
diff
changeset
|
1592 | if(trans->callback) { |
|
a3d6d136b7dd
[gaim-migrate @ 13762]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11483
diff
changeset
|
1593 | /* call the callback to process response*/ |
|
a3d6d136b7dd
[gaim-migrate @ 13762]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11483
diff
changeset
|
1594 | (trans->callback)(sip, msg, trans); |
|
a3d6d136b7dd
[gaim-migrate @ 13762]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11483
diff
changeset
|
1595 | } |
|
a3d6d136b7dd
[gaim-migrate @ 13762]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11483
diff
changeset
|
1596 | transactions_remove(sip, trans); |
|
11189
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
1597 | } |
|
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
1598 | } |
|
12745
1dc3525647c2
[gaim-migrate @ 15092]
Daniel Atallah <datallah@pidgin.im>
parents:
12741
diff
changeset
|
1599 | found = TRUE; |
|
11189
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
1600 | } else { |
| 15884 | 1601 | purple_debug(PURPLE_DEBUG_MISC, "simple", "received response to unknown transaction"); |
|
11189
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
1602 | } |
|
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
1603 | } |
|
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
1604 | if(!found) { |
| 15884 | 1605 | purple_debug(PURPLE_DEBUG_MISC, "simple", "received a unknown sip message with method %s and response %d\n", msg->method, msg->response); |
|
11189
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
1606 | } |
|
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
1607 | } |
|
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
1608 | |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1609 | static void process_input(struct simple_account_data *sip, struct sip_connection *conn) |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1610 | { |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1611 | char *cur; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1612 | char *dummy; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1613 | struct sipmsg *msg; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1614 | int restlen; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1615 | cur = conn->inbuf; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1616 | |
|
11341
5511bbeeb3b4
[gaim-migrate @ 13555]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11327
diff
changeset
|
1617 | /* according to the RFC remove CRLF at the beginning */ |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1618 | while(*cur == '\r' || *cur == '\n') { |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1619 | cur++; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1620 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1621 | if(cur != conn->inbuf) { |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
1622 | memmove(conn->inbuf, cur, conn->inbufused - (cur - conn->inbuf)); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
1623 | conn->inbufused = strlen(conn->inbuf); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1624 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1625 | |
|
11341
5511bbeeb3b4
[gaim-migrate @ 13555]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11327
diff
changeset
|
1626 | /* Received a full Header? */ |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
1627 | if((cur = strstr(conn->inbuf, "\r\n\r\n")) != NULL) { |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1628 | time_t currtime = time(NULL); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1629 | cur += 2; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1630 | cur[0] = '\0'; |
| 15884 | 1631 | purple_debug_info("simple", "\n\nreceived - %s\n######\n%s\n#######\n\n", ctime(&currtime), conn->inbuf); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1632 | msg = sipmsg_parse_header(conn->inbuf); |
|
24758
26c1c4bc47c0
Add a NULL check to fix a crash. Fixes #4516.
Richard Laager <rlaager@pidgin.im>
parents:
24638
diff
changeset
|
1633 | |
|
26c1c4bc47c0
Add a NULL check to fix a crash. Fixes #4516.
Richard Laager <rlaager@pidgin.im>
parents:
24638
diff
changeset
|
1634 | if(!msg) { |
|
26c1c4bc47c0
Add a NULL check to fix a crash. Fixes #4516.
Richard Laager <rlaager@pidgin.im>
parents:
24638
diff
changeset
|
1635 | /* Should we re-use this error message (from lower in the function)? */ |
|
26c1c4bc47c0
Add a NULL check to fix a crash. Fixes #4516.
Richard Laager <rlaager@pidgin.im>
parents:
24638
diff
changeset
|
1636 | purple_debug_misc("simple", "received a incomplete sip msg: %s\n", conn->inbuf); |
|
26c1c4bc47c0
Add a NULL check to fix a crash. Fixes #4516.
Richard Laager <rlaager@pidgin.im>
parents:
24638
diff
changeset
|
1637 | return; |
|
26c1c4bc47c0
Add a NULL check to fix a crash. Fixes #4516.
Richard Laager <rlaager@pidgin.im>
parents:
24638
diff
changeset
|
1638 | } |
|
26c1c4bc47c0
Add a NULL check to fix a crash. Fixes #4516.
Richard Laager <rlaager@pidgin.im>
parents:
24638
diff
changeset
|
1639 | |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1640 | cur[0] = '\r'; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1641 | cur += 2; |
|
14131
2cd4ddea2f52
[gaim-migrate @ 16690]
Daniel Atallah <datallah@pidgin.im>
parents:
14043
diff
changeset
|
1642 | restlen = conn->inbufused - (cur - conn->inbuf); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
1643 | if(restlen >= msg->bodylen) { |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
1644 | dummy = g_malloc(msg->bodylen + 1); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1645 | memcpy(dummy, cur, msg->bodylen); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
1646 | dummy[msg->bodylen] = '\0'; |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1647 | msg->body = dummy; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
1648 | cur += msg->bodylen; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
1649 | memmove(conn->inbuf, cur, conn->inbuflen - (cur - conn->inbuf)); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
1650 | conn->inbufused = strlen(conn->inbuf); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1651 | } else { |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1652 | sipmsg_free(msg); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1653 | return; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1654 | } |
| 15884 | 1655 | purple_debug(PURPLE_DEBUG_MISC, "simple", "in process response response: %d\n", msg->response); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
1656 | process_input_message(sip, msg); |
|
29997
9a9b586ac254
Lots of little memleak fixes
Mark Doliner <markdoliner@pidgin.im>
parents:
29996
diff
changeset
|
1657 | sipmsg_free(msg); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1658 | } else { |
| 15884 | 1659 | purple_debug(PURPLE_DEBUG_MISC, "simple", "received a incomplete sip msg: %s\n", conn->inbuf); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1660 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1661 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1662 | |
| 15884 | 1663 | static void simple_udp_process(gpointer data, gint source, PurpleInputCondition con) { |
| 1664 | PurpleConnection *gc = data; | |
|
32266
af94a3153685
Convert simple prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
1665 | struct simple_account_data *sip = purple_connection_get_protocol_data(gc); |
|
11189
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
1666 | struct sipmsg *msg; |
|
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
1667 | int len; |
| 29996 | 1668 | time_t currtime = time(NULL); |
|
11189
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
1669 | |
|
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
1670 | static char buffer[65536]; |
|
12770
f9bbe68a0c88
[gaim-migrate @ 15117]
Daniel Atallah <datallah@pidgin.im>
parents:
12769
diff
changeset
|
1671 | if((len = recv(source, buffer, sizeof(buffer) - 1, 0)) > 0) { |
|
12748
f2cbf850b529
[gaim-migrate @ 15095]
Daniel Atallah <datallah@pidgin.im>
parents:
12746
diff
changeset
|
1672 | buffer[len] = '\0'; |
| 15884 | 1673 | purple_debug_info("simple", "\n\nreceived - %s\n######\n%s\n#######\n\n", ctime(&currtime), buffer); |
|
12748
f2cbf850b529
[gaim-migrate @ 15095]
Daniel Atallah <datallah@pidgin.im>
parents:
12746
diff
changeset
|
1674 | msg = sipmsg_parse_msg(buffer); |
|
30007
09362ce17f6f
simple: sipmsg_free() can't handle NULL. Reported by Jochen
Paul Aurich <darkrain42@pidgin.im>
parents:
29998
diff
changeset
|
1675 | if (msg) { |
|
09362ce17f6f
simple: sipmsg_free() can't handle NULL. Reported by Jochen
Paul Aurich <darkrain42@pidgin.im>
parents:
29998
diff
changeset
|
1676 | process_input_message(sip, msg); |
|
09362ce17f6f
simple: sipmsg_free() can't handle NULL. Reported by Jochen
Paul Aurich <darkrain42@pidgin.im>
parents:
29998
diff
changeset
|
1677 | sipmsg_free(msg); |
|
09362ce17f6f
simple: sipmsg_free() can't handle NULL. Reported by Jochen
Paul Aurich <darkrain42@pidgin.im>
parents:
29998
diff
changeset
|
1678 | } |
|
12748
f2cbf850b529
[gaim-migrate @ 15095]
Daniel Atallah <datallah@pidgin.im>
parents:
12746
diff
changeset
|
1679 | } |
|
11189
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
1680 | } |
|
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
1681 | |
| 15884 | 1682 | static void simple_input_cb(gpointer data, gint source, PurpleInputCondition cond) |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1683 | { |
| 15884 | 1684 | PurpleConnection *gc = data; |
|
32266
af94a3153685
Convert simple prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
1685 | struct simple_account_data *sip = purple_connection_get_protocol_data(gc); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1686 | int len; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1687 | struct sip_connection *conn = connection_find(sip, source); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1688 | if(!conn) { |
| 15884 | 1689 | purple_debug_error("simple", "Connection not found!\n"); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1690 | return; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1691 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1692 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
1693 | if(conn->inbuflen < conn->inbufused + SIMPLE_BUF_INC) { |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1694 | conn->inbuflen += SIMPLE_BUF_INC; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1695 | conn->inbuf = g_realloc(conn->inbuf, conn->inbuflen); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1696 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1697 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
1698 | len = read(source, conn->inbuf + conn->inbufused, SIMPLE_BUF_INC - 1); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
1699 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
1700 | if(len < 0 && errno == EAGAIN) |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
1701 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
1702 | else if(len <= 0) { |
| 15884 | 1703 | purple_debug_info("simple", "simple_input_cb: read error\n"); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1704 | connection_remove(sip, source); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1705 | if(sip->fd == source) sip->fd = -1; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1706 | return; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1707 | } |
|
32679
fd936a0b84f7
Add a purple_connection_update_last_received() function to update the
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
1708 | purple_connection_update_last_received(gc); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1709 | conn->inbufused += len; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
1710 | conn->inbuf[conn->inbufused] = '\0'; |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
1711 | |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1712 | process_input(sip, conn); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1713 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1714 | |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1715 | /* Callback for new connections on incoming TCP port */ |
| 15884 | 1716 | static void simple_newconn_cb(gpointer data, gint source, PurpleInputCondition cond) { |
| 1717 | PurpleConnection *gc = data; | |
|
32266
af94a3153685
Convert simple prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
1718 | struct simple_account_data *sip = purple_connection_get_protocol_data(gc); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1719 | struct sip_connection *conn; |
|
24040
24ff94bfd09d
Use non-blocking io for inbound TCP connections for SIMPLE.
Daniel Atallah <datallah@pidgin.im>
parents:
23495
diff
changeset
|
1720 | int newfd, flags; |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1721 | |
|
24040
24ff94bfd09d
Use non-blocking io for inbound TCP connections for SIMPLE.
Daniel Atallah <datallah@pidgin.im>
parents:
23495
diff
changeset
|
1722 | newfd = accept(source, NULL, NULL); |
|
24ff94bfd09d
Use non-blocking io for inbound TCP connections for SIMPLE.
Daniel Atallah <datallah@pidgin.im>
parents:
23495
diff
changeset
|
1723 | |
|
24ff94bfd09d
Use non-blocking io for inbound TCP connections for SIMPLE.
Daniel Atallah <datallah@pidgin.im>
parents:
23495
diff
changeset
|
1724 | flags = fcntl(newfd, F_GETFL); |
|
24ff94bfd09d
Use non-blocking io for inbound TCP connections for SIMPLE.
Daniel Atallah <datallah@pidgin.im>
parents:
23495
diff
changeset
|
1725 | fcntl(newfd, F_SETFL, flags | O_NONBLOCK); |
|
24ff94bfd09d
Use non-blocking io for inbound TCP connections for SIMPLE.
Daniel Atallah <datallah@pidgin.im>
parents:
23495
diff
changeset
|
1726 | #ifndef _WIN32 |
|
24ff94bfd09d
Use non-blocking io for inbound TCP connections for SIMPLE.
Daniel Atallah <datallah@pidgin.im>
parents:
23495
diff
changeset
|
1727 | fcntl(newfd, F_SETFD, FD_CLOEXEC); |
|
24ff94bfd09d
Use non-blocking io for inbound TCP connections for SIMPLE.
Daniel Atallah <datallah@pidgin.im>
parents:
23495
diff
changeset
|
1728 | #endif |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1729 | |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1730 | conn = connection_create(sip, newfd); |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
1731 | |
| 15884 | 1732 | conn->inputhandler = purple_input_add(newfd, PURPLE_INPUT_READ, simple_input_cb, gc); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1733 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1734 | |
|
14180
77010795da2c
[gaim-migrate @ 16752]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
1735 | static void login_cb(gpointer data, gint source, const gchar *error_message) { |
| 15884 | 1736 | PurpleConnection *gc = data; |
|
14180
77010795da2c
[gaim-migrate @ 16752]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
1737 | struct simple_account_data *sip; |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1738 | struct sip_connection *conn; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1739 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
1740 | if(source < 0) { |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27350
diff
changeset
|
1741 | gchar *tmp = g_strdup_printf(_("Unable to connect: %s"), |
|
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27350
diff
changeset
|
1742 | error_message); |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31949
diff
changeset
|
1743 | purple_connection_error(gc, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27350
diff
changeset
|
1744 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); |
|
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27350
diff
changeset
|
1745 | g_free(tmp); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1746 | return; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1747 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1748 | |
|
32266
af94a3153685
Convert simple prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
1749 | sip = purple_connection_get_protocol_data(gc); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1750 | sip->fd = source; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1751 | |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
1752 | conn = connection_create(sip, source); |
|
13093
e27434c31f00
[gaim-migrate @ 15454]
Daniel Atallah <datallah@pidgin.im>
parents:
13089
diff
changeset
|
1753 | |
| 15884 | 1754 | sip->registertimeout = purple_timeout_add((rand()%100)+10*1000, (GSourceFunc)subscribe_timeout, sip); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1755 | |
|
11194
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
1756 | do_register(sip); |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
1757 | |
| 15884 | 1758 | conn->inputhandler = purple_input_add(sip->fd, PURPLE_INPUT_READ, simple_input_cb, gc); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1759 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1760 | |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1761 | static guint simple_ht_hash_nick(const char *nick) { |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1762 | char *lc = g_utf8_strdown(nick, -1); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1763 | guint bucket = g_str_hash(lc); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1764 | g_free(lc); |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
1765 | |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1766 | return bucket; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1767 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1768 | |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1769 | static gboolean simple_ht_equals_nick(const char *nick1, const char *nick2) { |
| 15884 | 1770 | return (purple_utf8_strcasecmp(nick1, nick2) == 0); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1771 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1772 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12770
diff
changeset
|
1773 | static void simple_udp_host_resolved_listen_cb(int listenfd, gpointer data) { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12770
diff
changeset
|
1774 | struct simple_account_data *sip = (struct simple_account_data*) data; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12770
diff
changeset
|
1775 | |
|
14329
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14324
diff
changeset
|
1776 | sip->listen_data = NULL; |
|
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14324
diff
changeset
|
1777 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12770
diff
changeset
|
1778 | if(listenfd == -1) { |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31949
diff
changeset
|
1779 | purple_connection_error(sip->gc, |
| 21279 | 1780 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27350
diff
changeset
|
1781 | _("Unable to create listen socket")); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12770
diff
changeset
|
1782 | return; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12770
diff
changeset
|
1783 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12770
diff
changeset
|
1784 | |
| 29996 | 1785 | /* |
| 1786 | * TODO: Is it correct to set sip->fd to the listenfd? For the TCP | |
| 1787 | * listener we set sip->listenfd, but maybe UDP is different? | |
| 1788 | * Maybe we use the same fd for outgoing data or something? | |
| 1789 | */ | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12770
diff
changeset
|
1790 | sip->fd = listenfd; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12770
diff
changeset
|
1791 | |
| 15884 | 1792 | sip->listenport = purple_network_get_port_from_fd(sip->fd); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12770
diff
changeset
|
1793 | |
| 15884 | 1794 | sip->listenpa = purple_input_add(sip->fd, PURPLE_INPUT_READ, simple_udp_process, sip->gc); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12770
diff
changeset
|
1795 | |
| 15884 | 1796 | sip->resendtimeout = purple_timeout_add(2500, (GSourceFunc) resend_timeout, sip); |
| 1797 | sip->registertimeout = purple_timeout_add((rand()%100)+10*1000, (GSourceFunc)subscribe_timeout, sip); | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12770
diff
changeset
|
1798 | do_register(sip); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12770
diff
changeset
|
1799 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12770
diff
changeset
|
1800 | |
|
12767
4870d7755883
[gaim-migrate @ 15114]
Daniel Atallah <datallah@pidgin.im>
parents:
12760
diff
changeset
|
1801 | static void simple_udp_host_resolved(GSList *hosts, gpointer data, const char *error_message) { |
|
4870d7755883
[gaim-migrate @ 15114]
Daniel Atallah <datallah@pidgin.im>
parents:
12760
diff
changeset
|
1802 | struct simple_account_data *sip = (struct simple_account_data*) data; |
|
4870d7755883
[gaim-migrate @ 15114]
Daniel Atallah <datallah@pidgin.im>
parents:
12760
diff
changeset
|
1803 | int addr_size; |
|
4870d7755883
[gaim-migrate @ 15114]
Daniel Atallah <datallah@pidgin.im>
parents:
12760
diff
changeset
|
1804 | |
|
14300
68a0aa63f3b8
[gaim-migrate @ 16920]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
1805 | sip->query_data = NULL; |
|
68a0aa63f3b8
[gaim-migrate @ 16920]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
1806 | |
|
12767
4870d7755883
[gaim-migrate @ 15114]
Daniel Atallah <datallah@pidgin.im>
parents:
12760
diff
changeset
|
1807 | if (!hosts || !hosts->data) { |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31949
diff
changeset
|
1808 | purple_connection_error(sip->gc, |
| 21279 | 1809 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27350
diff
changeset
|
1810 | _("Unable to resolve hostname")); |
|
12767
4870d7755883
[gaim-migrate @ 15114]
Daniel Atallah <datallah@pidgin.im>
parents:
12760
diff
changeset
|
1811 | return; |
|
4870d7755883
[gaim-migrate @ 15114]
Daniel Atallah <datallah@pidgin.im>
parents:
12760
diff
changeset
|
1812 | } |
|
4870d7755883
[gaim-migrate @ 15114]
Daniel Atallah <datallah@pidgin.im>
parents:
12760
diff
changeset
|
1813 | |
|
4870d7755883
[gaim-migrate @ 15114]
Daniel Atallah <datallah@pidgin.im>
parents:
12760
diff
changeset
|
1814 | addr_size = GPOINTER_TO_INT(hosts->data); |
|
4870d7755883
[gaim-migrate @ 15114]
Daniel Atallah <datallah@pidgin.im>
parents:
12760
diff
changeset
|
1815 | hosts = g_slist_remove(hosts, hosts->data); |
|
4870d7755883
[gaim-migrate @ 15114]
Daniel Atallah <datallah@pidgin.im>
parents:
12760
diff
changeset
|
1816 | memcpy(&(sip->serveraddr), hosts->data, addr_size); |
|
4870d7755883
[gaim-migrate @ 15114]
Daniel Atallah <datallah@pidgin.im>
parents:
12760
diff
changeset
|
1817 | g_free(hosts->data); |
|
4870d7755883
[gaim-migrate @ 15114]
Daniel Atallah <datallah@pidgin.im>
parents:
12760
diff
changeset
|
1818 | hosts = g_slist_remove(hosts, hosts->data); |
|
4870d7755883
[gaim-migrate @ 15114]
Daniel Atallah <datallah@pidgin.im>
parents:
12760
diff
changeset
|
1819 | while(hosts) { |
|
4870d7755883
[gaim-migrate @ 15114]
Daniel Atallah <datallah@pidgin.im>
parents:
12760
diff
changeset
|
1820 | hosts = g_slist_remove(hosts, hosts->data); |
|
4870d7755883
[gaim-migrate @ 15114]
Daniel Atallah <datallah@pidgin.im>
parents:
12760
diff
changeset
|
1821 | g_free(hosts->data); |
|
4870d7755883
[gaim-migrate @ 15114]
Daniel Atallah <datallah@pidgin.im>
parents:
12760
diff
changeset
|
1822 | hosts = g_slist_remove(hosts, hosts->data); |
|
4870d7755883
[gaim-migrate @ 15114]
Daniel Atallah <datallah@pidgin.im>
parents:
12760
diff
changeset
|
1823 | } |
|
4870d7755883
[gaim-migrate @ 15114]
Daniel Atallah <datallah@pidgin.im>
parents:
12760
diff
changeset
|
1824 | |
|
4870d7755883
[gaim-migrate @ 15114]
Daniel Atallah <datallah@pidgin.im>
parents:
12760
diff
changeset
|
1825 | /* create socket for incoming connections */ |
|
32594
f2feea134fdb
Remove deprecated purple_network_listen_map_external().
Andrew Victor <andrew.victor@mxit.com>
parents:
32593
diff
changeset
|
1826 | sip->listen_data = purple_network_listen_range(5060, 5160, AF_UNSPEC, SOCK_DGRAM, TRUE, |
|
14329
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14324
diff
changeset
|
1827 | simple_udp_host_resolved_listen_cb, sip); |
|
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14324
diff
changeset
|
1828 | if (sip->listen_data == NULL) { |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31949
diff
changeset
|
1829 | purple_connection_error(sip->gc, |
| 21279 | 1830 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27350
diff
changeset
|
1831 | _("Unable to create listen socket")); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12770
diff
changeset
|
1832 | return; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12770
diff
changeset
|
1833 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12770
diff
changeset
|
1834 | } |
|
12767
4870d7755883
[gaim-migrate @ 15114]
Daniel Atallah <datallah@pidgin.im>
parents:
12760
diff
changeset
|
1835 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12770
diff
changeset
|
1836 | static void |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12770
diff
changeset
|
1837 | simple_tcp_connect_listen_cb(int listenfd, gpointer data) { |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12770
diff
changeset
|
1838 | struct simple_account_data *sip = (struct simple_account_data*) data; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12770
diff
changeset
|
1839 | |
|
14329
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14324
diff
changeset
|
1840 | sip->listen_data = NULL; |
|
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14324
diff
changeset
|
1841 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12770
diff
changeset
|
1842 | sip->listenfd = listenfd; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12770
diff
changeset
|
1843 | if(sip->listenfd == -1) { |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31949
diff
changeset
|
1844 | purple_connection_error(sip->gc, |
| 21279 | 1845 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27350
diff
changeset
|
1846 | _("Unable to create listen socket")); |
|
12767
4870d7755883
[gaim-migrate @ 15114]
Daniel Atallah <datallah@pidgin.im>
parents:
12760
diff
changeset
|
1847 | return; |
|
4870d7755883
[gaim-migrate @ 15114]
Daniel Atallah <datallah@pidgin.im>
parents:
12760
diff
changeset
|
1848 | } |
|
4870d7755883
[gaim-migrate @ 15114]
Daniel Atallah <datallah@pidgin.im>
parents:
12760
diff
changeset
|
1849 | |
| 15884 | 1850 | purple_debug_info("simple", "listenfd: %d\n", sip->listenfd); |
| 1851 | sip->listenport = purple_network_get_port_from_fd(sip->listenfd); | |
| 1852 | sip->listenpa = purple_input_add(sip->listenfd, PURPLE_INPUT_READ, | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12770
diff
changeset
|
1853 | simple_newconn_cb, sip->gc); |
| 15884 | 1854 | purple_debug_info("simple", "connecting to %s port %d\n", |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12770
diff
changeset
|
1855 | sip->realhostname, sip->realport); |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12770
diff
changeset
|
1856 | /* open tcp connection to the server */ |
| 15884 | 1857 | if (purple_proxy_connect(sip->gc, sip->account, sip->realhostname, |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14696
diff
changeset
|
1858 | sip->realport, login_cb, sip->gc) == NULL) { |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31949
diff
changeset
|
1859 | purple_connection_error(sip->gc, |
| 21279 | 1860 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27350
diff
changeset
|
1861 | _("Unable to connect")); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12770
diff
changeset
|
1862 | } |
|
12767
4870d7755883
[gaim-migrate @ 15114]
Daniel Atallah <datallah@pidgin.im>
parents:
12760
diff
changeset
|
1863 | } |
|
4870d7755883
[gaim-migrate @ 15114]
Daniel Atallah <datallah@pidgin.im>
parents:
12760
diff
changeset
|
1864 | |
| 15884 | 1865 | static void srvresolved(PurpleSrvResponse *resp, int results, gpointer data) { |
|
13581
d0f0e28aa864
[gaim-migrate @ 15962]
Mark Doliner <markdoliner@pidgin.im>
parents:
13399
diff
changeset
|
1866 | struct simple_account_data *sip; |
|
d0f0e28aa864
[gaim-migrate @ 15962]
Mark Doliner <markdoliner@pidgin.im>
parents:
13399
diff
changeset
|
1867 | gchar *hostname; |
|
d0f0e28aa864
[gaim-migrate @ 15962]
Mark Doliner <markdoliner@pidgin.im>
parents:
13399
diff
changeset
|
1868 | int port; |
|
11383
2c5a70e62389
[gaim-migrate @ 13610]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11346
diff
changeset
|
1869 | |
|
14370
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14329
diff
changeset
|
1870 | sip = data; |
|
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14329
diff
changeset
|
1871 | sip->srv_query_data = NULL; |
|
13581
d0f0e28aa864
[gaim-migrate @ 15962]
Mark Doliner <markdoliner@pidgin.im>
parents:
13399
diff
changeset
|
1872 | |
| 15884 | 1873 | port = purple_account_get_int(sip->account, "port", 0); |
|
11383
2c5a70e62389
[gaim-migrate @ 13610]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11346
diff
changeset
|
1874 | |
|
2c5a70e62389
[gaim-migrate @ 13610]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11346
diff
changeset
|
1875 | /* find the host to connect to */ |
|
2c5a70e62389
[gaim-migrate @ 13610]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11346
diff
changeset
|
1876 | if(results) { |
|
2c5a70e62389
[gaim-migrate @ 13610]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11346
diff
changeset
|
1877 | hostname = g_strdup(resp->hostname); |
|
12769
21ce86fd6ffa
[gaim-migrate @ 15116]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
12768
diff
changeset
|
1878 | if(!port) |
|
21ce86fd6ffa
[gaim-migrate @ 15116]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
12768
diff
changeset
|
1879 | port = resp->port; |
|
11383
2c5a70e62389
[gaim-migrate @ 13610]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11346
diff
changeset
|
1880 | g_free(resp); |
|
2c5a70e62389
[gaim-migrate @ 13610]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11346
diff
changeset
|
1881 | } else { |
| 15884 | 1882 | if(!purple_account_get_bool(sip->account, "useproxy", FALSE)) { |
|
11383
2c5a70e62389
[gaim-migrate @ 13610]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11346
diff
changeset
|
1883 | hostname = g_strdup(sip->servername); |
|
2c5a70e62389
[gaim-migrate @ 13610]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11346
diff
changeset
|
1884 | } else { |
| 15884 | 1885 | hostname = g_strdup(purple_account_get_string(sip->account, "proxy", sip->servername)); |
|
11383
2c5a70e62389
[gaim-migrate @ 13610]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11346
diff
changeset
|
1886 | } |
|
2c5a70e62389
[gaim-migrate @ 13610]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11346
diff
changeset
|
1887 | } |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
1888 | |
|
11383
2c5a70e62389
[gaim-migrate @ 13610]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11346
diff
changeset
|
1889 | sip->realhostname = hostname; |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
1890 | sip->realport = port; |
|
12769
21ce86fd6ffa
[gaim-migrate @ 15116]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
12768
diff
changeset
|
1891 | if(!sip->realport) sip->realport = 5060; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
1892 | |
|
11383
2c5a70e62389
[gaim-migrate @ 13610]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11346
diff
changeset
|
1893 | /* TCP case */ |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
1894 | if(!sip->udp) { |
|
11409
2a3466f4a32c
[gaim-migrate @ 13646]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11396
diff
changeset
|
1895 | /* create socket for incoming connections */ |
|
32594
f2feea134fdb
Remove deprecated purple_network_listen_map_external().
Andrew Victor <andrew.victor@mxit.com>
parents:
32593
diff
changeset
|
1896 | sip->listen_data = purple_network_listen_range(5060, 5160, AF_UNSPEC, SOCK_STREAM, TRUE, |
|
14329
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14324
diff
changeset
|
1897 | simple_tcp_connect_listen_cb, sip); |
|
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14324
diff
changeset
|
1898 | if (sip->listen_data == NULL) { |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31949
diff
changeset
|
1899 | purple_connection_error(sip->gc, |
| 21279 | 1900 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27350
diff
changeset
|
1901 | _("Unable to create listen socket")); |
|
11409
2a3466f4a32c
[gaim-migrate @ 13646]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11396
diff
changeset
|
1902 | return; |
|
2a3466f4a32c
[gaim-migrate @ 13646]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11396
diff
changeset
|
1903 | } |
|
11383
2c5a70e62389
[gaim-migrate @ 13610]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11346
diff
changeset
|
1904 | } else { /* UDP */ |
| 15884 | 1905 | purple_debug_info("simple", "using udp with server %s and port %d\n", hostname, port); |
|
12565
8601c9c26f93
[gaim-migrate @ 14884]
Daniel Atallah <datallah@pidgin.im>
parents:
12563
diff
changeset
|
1906 | |
|
32297
100ef65e9664
Replace purple_dnsquery_a_account with purple_dnsquery_a.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32266
diff
changeset
|
1907 | sip->query_data = purple_dnsquery_a(sip->account, hostname, |
|
31680
d3902c687705
Use the new account-contextual DNS API everywhere. Refs #11110
Daniel Atallah <datallah@pidgin.im>
parents:
31595
diff
changeset
|
1908 | port, simple_udp_host_resolved, sip); |
|
14300
68a0aa63f3b8
[gaim-migrate @ 16920]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
1909 | if (sip->query_data == NULL) { |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31949
diff
changeset
|
1910 | purple_connection_error(sip->gc, |
| 21279 | 1911 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27350
diff
changeset
|
1912 | _("Unable to resolve hostname")); |
|
14300
68a0aa63f3b8
[gaim-migrate @ 16920]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
1913 | } |
|
11383
2c5a70e62389
[gaim-migrate @ 13610]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11346
diff
changeset
|
1914 | } |
|
2c5a70e62389
[gaim-migrate @ 13610]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11346
diff
changeset
|
1915 | } |
|
2c5a70e62389
[gaim-migrate @ 13610]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11346
diff
changeset
|
1916 | |
| 15884 | 1917 | static void simple_login(PurpleAccount *account) |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1918 | { |
| 15884 | 1919 | PurpleConnection *gc; |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1920 | struct simple_account_data *sip; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1921 | gchar **userserver; |
|
23495
cc9ee7e6a09f
There's no need to dup this
Mark Doliner <markdoliner@pidgin.im>
parents:
23302
diff
changeset
|
1922 | const gchar *hosttoconnect; |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
1923 | |
| 15884 | 1924 | const char *username = purple_account_get_username(account); |
| 1925 | gc = purple_account_get_connection(account); | |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1926 | |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
1927 | if (strpbrk(username, " \t\v\r\n") != NULL) { |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31949
diff
changeset
|
1928 | purple_connection_error(gc, |
| 21279 | 1929 | PURPLE_CONNECTION_ERROR_INVALID_SETTINGS, |
|
22942
2bf494f8e2a4
Change the string "screen name" to "username" everywhere. I think most
Mark Doliner <markdoliner@pidgin.im>
parents:
22709
diff
changeset
|
1930 | _("SIP usernames may not contain whitespaces or @ symbols")); |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
1931 | return; |
|
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
1932 | } |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1933 | |
|
32266
af94a3153685
Convert simple prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
1934 | sip = g_new0(struct simple_account_data, 1); |
|
af94a3153685
Convert simple prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
1935 | purple_connection_set_protocol_data(gc, sip); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
1936 | sip->gc = gc; |
|
31949
f141aee90086
Fix some closes on invalid fds, which can crash on Windows.
Florian Quèze <florian@instantbird.org>
parents:
31680
diff
changeset
|
1937 | sip->fd = -1; |
|
f141aee90086
Fix some closes on invalid fds, which can crash on Windows.
Florian Quèze <florian@instantbird.org>
parents:
31680
diff
changeset
|
1938 | sip->listenfd = -1; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
1939 | sip->account = account; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
1940 | sip->registerexpire = 900; |
| 15884 | 1941 | sip->udp = purple_account_get_bool(account, "udp", FALSE); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
1942 | /* TODO: is there a good default grow size? */ |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
1943 | if(!sip->udp) |
| 15884 | 1944 | sip->txbuf = purple_circ_buffer_new(0); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13185
diff
changeset
|
1945 | |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1946 | userserver = g_strsplit(username, "@", 2); |
|
25179
0dbf2eb5f168
Don't allow connecting a SIMPLE account if no server is configured. Fixes #7767.
Florian Quèze <florian@instantbird.org>
parents:
24845
diff
changeset
|
1947 | if (userserver[1] == NULL || userserver[1][0] == '\0') { |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31949
diff
changeset
|
1948 | purple_connection_error(gc, |
|
25179
0dbf2eb5f168
Don't allow connecting a SIMPLE account if no server is configured. Fixes #7767.
Florian Quèze <florian@instantbird.org>
parents:
24845
diff
changeset
|
1949 | PURPLE_CONNECTION_ERROR_INVALID_SETTINGS, |
|
25206
4758bccd444c
disapproval of revision '99fcf96872a999874e2f1e5f46bd44f4a487119c'
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
25201
diff
changeset
|
1950 | _("SIP connect server not specified")); |
|
25179
0dbf2eb5f168
Don't allow connecting a SIMPLE account if no server is configured. Fixes #7767.
Florian Quèze <florian@instantbird.org>
parents:
24845
diff
changeset
|
1951 | return; |
|
0dbf2eb5f168
Don't allow connecting a SIMPLE account if no server is configured. Fixes #7767.
Florian Quèze <florian@instantbird.org>
parents:
24845
diff
changeset
|
1952 | } |
|
0dbf2eb5f168
Don't allow connecting a SIMPLE account if no server is configured. Fixes #7767.
Florian Quèze <florian@instantbird.org>
parents:
24845
diff
changeset
|
1953 | |
| 15884 | 1954 | purple_connection_set_display_name(gc, userserver[0]); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1955 | sip->username = g_strdup(userserver[0]); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1956 | sip->servername = g_strdup(userserver[1]); |
| 15884 | 1957 | sip->password = g_strdup(purple_connection_get_password(gc)); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1958 | g_strfreev(userserver); |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1959 | |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1960 | sip->buddies = g_hash_table_new((GHashFunc)simple_ht_hash_nick, (GEqualFunc)simple_ht_equals_nick); |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
1961 | |
| 15884 | 1962 | purple_connection_update_progress(gc, _("Connecting"), 1, 2); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1963 | |
|
11837
2f1206084fef
[gaim-migrate @ 14128]
Mark Doliner <markdoliner@pidgin.im>
parents:
11718
diff
changeset
|
1964 | /* TODO: Set the status correctly. */ |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1965 | sip->status = g_strdup("available"); |
|
11189
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
1966 | |
| 15884 | 1967 | if(!purple_account_get_bool(account, "useproxy", FALSE)) { |
|
23495
cc9ee7e6a09f
There's no need to dup this
Mark Doliner <markdoliner@pidgin.im>
parents:
23302
diff
changeset
|
1968 | hosttoconnect = sip->servername; |
|
11210
95ba2527d7d1
[gaim-migrate @ 13341]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11194
diff
changeset
|
1969 | } else { |
|
23495
cc9ee7e6a09f
There's no need to dup this
Mark Doliner <markdoliner@pidgin.im>
parents:
23302
diff
changeset
|
1970 | hosttoconnect = purple_account_get_string(account, "proxy", sip->servername); |
|
11210
95ba2527d7d1
[gaim-migrate @ 13341]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11194
diff
changeset
|
1971 | } |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
1972 | |
|
32300
59a31f9f67fc
Clean up SRV/TXT query functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32297
diff
changeset
|
1973 | sip->srv_query_data = purple_srv_resolve(account, "sip", |
|
14370
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14329
diff
changeset
|
1974 | sip->udp ? "udp" : "tcp", hosttoconnect, srvresolved, sip); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1975 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1976 | |
| 15884 | 1977 | static void simple_close(PurpleConnection *gc) |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
1978 | { |
|
32266
af94a3153685
Convert simple prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
1979 | struct simple_account_data *sip = purple_connection_get_protocol_data(gc); |
|
11194
47dc0e9a757a
[gaim-migrate @ 13317]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11192
diff
changeset
|
1980 | |
|
29989
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
1981 | if (!sip) |
|
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
1982 | return; |
|
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
1983 | |
|
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
1984 | /* unregister */ |
|
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
1985 | if (sip->registerstatus == SIMPLE_REGISTER_COMPLETE) |
|
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
1986 | { |
|
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
1987 | g_hash_table_foreach(sip->buddies, |
|
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
1988 | (GHFunc)simple_unsubscribe, |
|
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
1989 | (gpointer)sip); |
|
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
1990 | |
|
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
1991 | if (purple_account_get_bool(sip->account, "dopublish", TRUE)) |
|
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
1992 | send_closed_publish(sip); |
|
21417
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1993 | |
|
29989
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
1994 | do_register_exp(sip, 0); |
|
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
1995 | } |
|
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
1996 | connection_free_all(sip); |
|
21417
48f4f6c2fe47
Patch from Will Hawkins to make the SIMPLE prpl more standards compliant by keeping all subscribe/notify messaging within a dialog. This didn't apply cleanly, so I had to manually apply it - hopefully I didn't break anything during the process. Fixes #3778.
Daniel Atallah <datallah@pidgin.im>
parents:
21106
diff
changeset
|
1997 | |
| 29996 | 1998 | if (sip->listenpa) |
| 1999 | purple_input_remove(sip->listenpa); | |
| 2000 | if (sip->tx_handler) | |
| 2001 | purple_input_remove(sip->tx_handler); | |
| 2002 | if (sip->resendtimeout) | |
| 2003 | purple_timeout_remove(sip->resendtimeout); | |
| 2004 | if (sip->registertimeout) | |
| 2005 | purple_timeout_remove(sip->registertimeout); | |
|
29989
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
2006 | if (sip->query_data != NULL) |
|
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
2007 | purple_dnsquery_destroy(sip->query_data); |
|
13399
e877a5672fe8
[gaim-migrate @ 15772]
Richard Laager <rlaager@pidgin.im>
parents:
13348
diff
changeset
|
2008 | |
|
29989
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
2009 | if (sip->srv_query_data != NULL) |
|
32300
59a31f9f67fc
Clean up SRV/TXT query functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32297
diff
changeset
|
2010 | purple_srv_txt_query_destroy(sip->srv_query_data); |
|
14300
68a0aa63f3b8
[gaim-migrate @ 16920]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
2011 | |
|
29989
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
2012 | if (sip->listen_data != NULL) |
|
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
2013 | purple_network_listen_cancel(sip->listen_data); |
|
14370
12ef3d4096ee
[gaim-migrate @ 16998]
Mark Doliner <markdoliner@pidgin.im>
parents:
14329
diff
changeset
|
2014 | |
| 29996 | 2015 | if (sip->fd >= 0) |
| 2016 | close(sip->fd); | |
| 2017 | if (sip->listenfd >= 0) | |
| 2018 | close(sip->listenfd); | |
| 2019 | ||
|
29989
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
2020 | g_free(sip->servername); |
|
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
2021 | g_free(sip->username); |
|
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
2022 | g_free(sip->password); |
|
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
2023 | g_free(sip->registrar.nonce); |
|
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
2024 | g_free(sip->registrar.opaque); |
|
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
2025 | g_free(sip->registrar.target); |
|
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
2026 | g_free(sip->registrar.realm); |
|
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
2027 | g_free(sip->registrar.digest_session_key); |
|
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
2028 | g_free(sip->proxy.nonce); |
|
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
2029 | g_free(sip->proxy.opaque); |
|
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
2030 | g_free(sip->proxy.target); |
|
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
2031 | g_free(sip->proxy.realm); |
|
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
2032 | g_free(sip->proxy.digest_session_key); |
|
29997
9a9b586ac254
Lots of little memleak fixes
Mark Doliner <markdoliner@pidgin.im>
parents:
29996
diff
changeset
|
2033 | g_free(sip->status); |
|
9a9b586ac254
Lots of little memleak fixes
Mark Doliner <markdoliner@pidgin.im>
parents:
29996
diff
changeset
|
2034 | g_hash_table_destroy(sip->buddies); |
|
9a9b586ac254
Lots of little memleak fixes
Mark Doliner <markdoliner@pidgin.im>
parents:
29996
diff
changeset
|
2035 | g_free(sip->regcallid); |
|
29998
fcacdafd0f2d
Fix one more small memleak by freeing any lingering transactions at shutdown
Mark Doliner <markdoliner@pidgin.im>
parents:
29997
diff
changeset
|
2036 | while (sip->transactions) |
|
fcacdafd0f2d
Fix one more small memleak by freeing any lingering transactions at shutdown
Mark Doliner <markdoliner@pidgin.im>
parents:
29997
diff
changeset
|
2037 | transactions_remove(sip, sip->transactions->data); |
|
29989
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
2038 | g_free(sip->publish_etag); |
|
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
2039 | if (sip->txbuf) |
|
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
2040 | purple_circ_buffer_destroy(sip->txbuf); |
|
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
2041 | g_free(sip->realhostname); |
|
14329
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14324
diff
changeset
|
2042 | |
|
29989
18bc65ced65a
Exit early if sip is null, instead of putting the whole body of this
Mark Doliner <markdoliner@pidgin.im>
parents:
29757
diff
changeset
|
2043 | g_free(sip); |
|
32266
af94a3153685
Convert simple prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
2044 | purple_connection_set_protocol_data(gc, NULL); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2045 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2046 | |
| 15884 | 2047 | static PurplePluginProtocolInfo prpl_info = |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2048 | { |
|
32316
21dab55b4699
Move struct_size to the beginning of the struct. Even if we don't
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32315
diff
changeset
|
2049 | sizeof(PurplePluginProtocolInfo), /* struct_size */ |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2050 | 0, |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2051 | NULL, /* user_splits */ |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2052 | NULL, /* protocol_options */ |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11837
diff
changeset
|
2053 | NO_BUDDY_ICONS, /* icon_spec */ |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2054 | simple_list_icon, /* list_icon */ |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11837
diff
changeset
|
2055 | NULL, /* list_emblems */ |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2056 | NULL, /* status_text */ |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2057 | NULL, /* tooltip_text */ |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2058 | simple_status_types, /* away_states */ |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2059 | NULL, /* blist_node_menu */ |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11837
diff
changeset
|
2060 | NULL, /* chat_info */ |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11837
diff
changeset
|
2061 | NULL, /* chat_info_defaults */ |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11837
diff
changeset
|
2062 | simple_login, /* login */ |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11837
diff
changeset
|
2063 | simple_close, /* close */ |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11837
diff
changeset
|
2064 | simple_im_send, /* send_im */ |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2065 | NULL, /* set_info */ |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11837
diff
changeset
|
2066 | simple_typing, /* send_typing */ |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11837
diff
changeset
|
2067 | NULL, /* get_info */ |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2068 | simple_set_status, /* set_status */ |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2069 | NULL, /* set_idle */ |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2070 | NULL, /* change_passwd */ |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2071 | simple_add_buddy, /* add_buddy */ |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2072 | NULL, /* add_buddies */ |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2073 | simple_remove_buddy, /* remove_buddy */ |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2074 | NULL, /* remove_buddies */ |
|
22388
9f418ec14552
Remove some empty PRPL callbacks
Mark Doliner <markdoliner@pidgin.im>
parents:
22277
diff
changeset
|
2075 | NULL, /* add_permit */ |
|
9f418ec14552
Remove some empty PRPL callbacks
Mark Doliner <markdoliner@pidgin.im>
parents:
22277
diff
changeset
|
2076 | NULL, /* add_deny */ |
|
9f418ec14552
Remove some empty PRPL callbacks
Mark Doliner <markdoliner@pidgin.im>
parents:
22277
diff
changeset
|
2077 | NULL, /* rem_permit */ |
|
9f418ec14552
Remove some empty PRPL callbacks
Mark Doliner <markdoliner@pidgin.im>
parents:
22277
diff
changeset
|
2078 | NULL, /* rem_deny */ |
|
9f418ec14552
Remove some empty PRPL callbacks
Mark Doliner <markdoliner@pidgin.im>
parents:
22277
diff
changeset
|
2079 | NULL, /* set_permit_deny */ |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11837
diff
changeset
|
2080 | NULL, /* join_chat */ |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2081 | NULL, /* reject_chat */ |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11837
diff
changeset
|
2082 | NULL, /* get_chat_name */ |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11837
diff
changeset
|
2083 | NULL, /* chat_invite */ |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11837
diff
changeset
|
2084 | NULL, /* chat_leave */ |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2085 | NULL, /* chat_whisper */ |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11837
diff
changeset
|
2086 | NULL, /* chat_send */ |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11837
diff
changeset
|
2087 | simple_keep_alive, /* keepalive */ |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2088 | NULL, /* register_user */ |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2089 | NULL, /* get_cb_info */ |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2090 | NULL, /* alias_buddy */ |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2091 | NULL, /* group_buddy */ |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2092 | NULL, /* rename_group */ |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2093 | NULL, /* buddy_free */ |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2094 | NULL, /* convo_closed */ |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2095 | NULL, /* normalize */ |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2096 | NULL, /* set_buddy_icon */ |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2097 | NULL, /* remove_group */ |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2098 | NULL, /* get_cb_real_name */ |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11837
diff
changeset
|
2099 | NULL, /* set_chat_topic */ |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2100 | NULL, /* find_blist_chat */ |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11837
diff
changeset
|
2101 | NULL, /* roomlist_get_list */ |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11837
diff
changeset
|
2102 | NULL, /* roomlist_cancel */ |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2103 | NULL, /* roomlist_expand_category */ |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2104 | NULL, /* can_receive_file */ |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11837
diff
changeset
|
2105 | NULL, /* send_file */ |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12595
diff
changeset
|
2106 | NULL, /* new_xfer */ |
|
12645
a907ba243930
[gaim-migrate @ 14983]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12600
diff
changeset
|
2107 | NULL, /* offline_message */ |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12595
diff
changeset
|
2108 | NULL, /* whiteboard_prpl_ops */ |
| 15185 | 2109 | simple_send_raw, /* send_raw */ |
| 2110 | NULL, /* roomlist_room_serialize */ | |
|
22071
4c47e360e467
Fix the prplinfo structs and get rid of some compile warnings.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22069
diff
changeset
|
2111 | NULL, /* unregister_user */ |
|
4c47e360e467
Fix the prplinfo structs and get rid of some compile warnings.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22069
diff
changeset
|
2112 | NULL, /* send_attention */ |
|
4c47e360e467
Fix the prplinfo structs and get rid of some compile warnings.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22069
diff
changeset
|
2113 | NULL, /* get_attention_types */ |
|
23707
480f94157418
propagate from branch 'im.pidgin.pidgin' (head bd5f7f61d9349053ee4738efc0d17453f0574057)
Sadrul Habib Chowdhury <sadrul@pidgin.im>
diff
changeset
|
2114 | NULL, /* get_account_text_table */ |
|
22648
e286d795c5f9
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22647
diff
changeset
|
2115 | NULL, /* initiate_media */ |
|
29757
f137c1386384
Add a NULL for PurplePluginProtocolInfo::get_moods to all the plugins I build
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
2116 | NULL, /* get_media_caps */ |
|
30138
cca9685df785
Add purple_account_[gs]et_public_alias functions, per discussion in d@cpi
Paul Aurich <darkrain42@pidgin.im>
parents:
30007
diff
changeset
|
2117 | NULL, /* get_moods */ |
|
cca9685df785
Add purple_account_[gs]et_public_alias functions, per discussion in d@cpi
Paul Aurich <darkrain42@pidgin.im>
parents:
30007
diff
changeset
|
2118 | NULL, /* set_public_alias */ |
|
32315
2550a39e0285
Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32300
diff
changeset
|
2119 | NULL /* get_public_alias */ |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2120 | }; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2121 | |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2122 | |
| 15884 | 2123 | static PurplePluginInfo info = |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2124 | { |
| 15884 | 2125 | PURPLE_PLUGIN_MAGIC, |
| 2126 | PURPLE_MAJOR_VERSION, | |
| 2127 | PURPLE_MINOR_VERSION, | |
| 2128 | PURPLE_PLUGIN_PROTOCOL, /**< type */ | |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2129 | NULL, /**< ui_requirement */ |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2130 | 0, /**< flags */ |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2131 | NULL, /**< dependencies */ |
| 15884 | 2132 | PURPLE_PRIORITY_DEFAULT, /**< priority */ |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2133 | |
|
12489
14274d68d499
[gaim-migrate @ 14801]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
12456
diff
changeset
|
2134 | "prpl-simple", /**< id */ |
|
14274d68d499
[gaim-migrate @ 14801]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
12456
diff
changeset
|
2135 | "SIMPLE", /**< name */ |
|
21106
b85fbef13eed
Add a --with-extraversion option to ./configure so packagers can fine tune
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21100
diff
changeset
|
2136 | DISPLAY_VERSION, /**< version */ |
|
12489
14274d68d499
[gaim-migrate @ 14801]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
12456
diff
changeset
|
2137 | N_("SIP/SIMPLE Protocol Plugin"), /** summary */ |
|
14274d68d499
[gaim-migrate @ 14801]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
12456
diff
changeset
|
2138 | N_("The SIP/SIMPLE Protocol Plugin"), /** description */ |
|
14274d68d499
[gaim-migrate @ 14801]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
12456
diff
changeset
|
2139 | "Thomas Butter <butter@uni-mannheim.de>", /**< author */ |
| 15884 | 2140 | PURPLE_WEBSITE, /**< homepage */ |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2141 | |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2142 | NULL, /**< load */ |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2143 | NULL, /**< unload */ |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2144 | NULL, /**< destroy */ |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2145 | |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2146 | NULL, /**< ui_info */ |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2147 | &prpl_info, /**< extra_info */ |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2148 | NULL, |
|
16746
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16238
diff
changeset
|
2149 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16238
diff
changeset
|
2150 | |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16238
diff
changeset
|
2151 | /* padding */ |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16238
diff
changeset
|
2152 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16238
diff
changeset
|
2153 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16238
diff
changeset
|
2154 | NULL, |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2155 | NULL |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2156 | }; |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2157 | |
| 15884 | 2158 | static void _init_plugin(PurplePlugin *plugin) |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2159 | { |
| 15884 | 2160 | PurpleAccountUserSplit *split; |
| 2161 | PurpleAccountOption *option; | |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2162 | |
| 15884 | 2163 | split = purple_account_user_split_new(_("Server"), "", '@'); |
|
11396
468e60b682cd
[gaim-migrate @ 13627]
Daniel Atallah <datallah@pidgin.im>
parents:
11383
diff
changeset
|
2164 | prpl_info.user_splits = g_list_append(prpl_info.user_splits, split); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2165 | |
| 15884 | 2166 | option = purple_account_option_bool_new(_("Publish status (note: everyone may watch you)"), "dopublish", TRUE); |
|
11345
48a2f93e47b6
[gaim-migrate @ 13562]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11341
diff
changeset
|
2167 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
48a2f93e47b6
[gaim-migrate @ 13562]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11341
diff
changeset
|
2168 | |
| 15884 | 2169 | option = purple_account_option_int_new(_("Connect port"), "port", 0); |
|
12730
f64fdbc34677
[gaim-migrate @ 15074]
Daniel Atallah <datallah@pidgin.im>
parents:
12689
diff
changeset
|
2170 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
f64fdbc34677
[gaim-migrate @ 15074]
Daniel Atallah <datallah@pidgin.im>
parents:
12689
diff
changeset
|
2171 | |
| 15884 | 2172 | option = purple_account_option_bool_new(_("Use UDP"), "udp", FALSE); |
|
11189
5ac07336091e
[gaim-migrate @ 13307]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11181
diff
changeset
|
2173 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
| 15884 | 2174 | option = purple_account_option_bool_new(_("Use proxy"), "useproxy", FALSE); |
|
11210
95ba2527d7d1
[gaim-migrate @ 13341]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11194
diff
changeset
|
2175 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
| 15884 | 2176 | option = purple_account_option_string_new(_("Proxy"), "proxy", ""); |
|
11210
95ba2527d7d1
[gaim-migrate @ 13341]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11194
diff
changeset
|
2177 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
| 15884 | 2178 | option = purple_account_option_string_new(_("Auth User"), "authuser", ""); |
|
13085
c80913901342
[gaim-migrate @ 15446]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13084
diff
changeset
|
2179 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
| 15884 | 2180 | option = purple_account_option_string_new(_("Auth Domain"), "authdomain", ""); |
|
13085
c80913901342
[gaim-migrate @ 15446]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13084
diff
changeset
|
2181 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
11181
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2182 | } |
|
e872a55b9524
[gaim-migrate @ 13292]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
diff
changeset
|
2183 | |
| 15884 | 2184 | PURPLE_INIT_PLUGIN(simple, _init_plugin, info); |