Mercurial > pidgin
annotate libpurple/protocols/oscar/flap_connection.c @ 28940:4d50162d809e
Put all our rateclass members in a single hash table instead of in one
hash table per rateclass. Should reduce memory usage by using 1 hash
table instead of 5ish for each flap connection
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 03 Feb 2010 01:03:09 +0000 |
parents | 0616027add19 |
children | 6d2ba42595fe |
rev | line source |
---|---|
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1 /* |
15822 | 2 * Purple's oscar protocol plugin |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3 * This file is the legal property of its developers. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4 * Please see the AUTHORS file distributed alongside this file. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
6 * This library is free software; you can redistribute it and/or |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
7 * modify it under the terms of the GNU Lesser General Public |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
8 * License as published by the Free Software Foundation; either |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
9 * version 2 of the License, or (at your option) any later version. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
10 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
11 * This library is distributed in the hope that it will be useful, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
14 * Lesser General Public License for more details. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
15 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
16 * You should have received a copy of the GNU Lesser General Public |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
17 * License along with this library; if not, write to the Free Software |
19681
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18815
diff
changeset
|
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
19 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
20 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
21 #include "oscar.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
22 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
23 #include "eventloop.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
24 #include "proxy.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
25 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
26 #ifndef _WIN32 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
27 #include <netdb.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
28 #include <sys/socket.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
29 #include <netinet/in.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
30 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
31 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
32 #ifdef _WIN32 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
33 #include "win32dep.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
34 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
35 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
36 /** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
37 * This sends a channel 1 SNAC containing the FLAP version. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
38 * The FLAP version is sent by itself at the beginning of every |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
39 * connection to a FLAP server. It is always the very first |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
40 * packet sent by both the server and the client after the SYN, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
41 * SYN/ACK, ACK handshake. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
42 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
43 void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
44 flap_connection_send_version(OscarData *od, FlapConnection *conn) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
45 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
46 FlapFrame *frame; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
47 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
48 frame = flap_frame_new(od, 0x01, 4); |
27143
454d46e9cbb7
Make a function static and add two comments
Mark Doliner <mark@kingant.net>
parents:
25381
diff
changeset
|
49 byte_stream_put32(&frame->data, 0x00000001); /* FLAP Version */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
50 flap_connection_send(conn, frame); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
51 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
52 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
53 /** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
54 * This sends a channel 1 FLAP containing the FLAP version and |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
55 * the authentication cookie. This is sent when connecting to |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
56 * any FLAP server after the initial connection to the auth |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
57 * server. It is always the very first packet sent by both the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
58 * server and the client after the SYN, SYN/ACK, ACK handshake. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
59 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
60 void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
61 flap_connection_send_version_with_cookie(OscarData *od, FlapConnection *conn, guint16 length, const guint8 *chipsahoy) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
62 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
63 FlapFrame *frame; |
17369
f80f7e1047be
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <mark@kingant.net>
parents:
17191
diff
changeset
|
64 GSList *tlvlist = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
65 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
66 frame = flap_frame_new(od, 0x01, 4 + 2 + 2 + length); |
27143
454d46e9cbb7
Make a function static and add two comments
Mark Doliner <mark@kingant.net>
parents:
25381
diff
changeset
|
67 byte_stream_put32(&frame->data, 0x00000001); /* FLAP Version */ |
17369
f80f7e1047be
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <mark@kingant.net>
parents:
17191
diff
changeset
|
68 aim_tlvlist_add_raw(&tlvlist, 0x0006, length, chipsahoy); |
f80f7e1047be
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <mark@kingant.net>
parents:
17191
diff
changeset
|
69 aim_tlvlist_write(&frame->data, &tlvlist); |
f80f7e1047be
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <mark@kingant.net>
parents:
17191
diff
changeset
|
70 aim_tlvlist_free(tlvlist); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
71 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
72 flap_connection_send(conn, frame); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
73 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
74 |
27161
7054f810b0f9
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <mark@kingant.net>
parents:
27158
diff
changeset
|
75 void |
28499
4575d8daba12
oscar: Fix 'Allow multiple simultaenous logins' with clientLogin.
Paul Aurich <paul@darkrain42.org>
parents:
28490
diff
changeset
|
76 flap_connection_send_version_with_cookie_and_clientinfo(OscarData *od, FlapConnection *conn, guint16 length, const guint8 *chipsahoy, ClientInfo *ci, gboolean allow_multiple_logins) |
27161
7054f810b0f9
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <mark@kingant.net>
parents:
27158
diff
changeset
|
77 { |
7054f810b0f9
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <mark@kingant.net>
parents:
27158
diff
changeset
|
78 FlapFrame *frame; |
7054f810b0f9
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <mark@kingant.net>
parents:
27158
diff
changeset
|
79 GSList *tlvlist = NULL; |
7054f810b0f9
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <mark@kingant.net>
parents:
27158
diff
changeset
|
80 |
7054f810b0f9
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <mark@kingant.net>
parents:
27158
diff
changeset
|
81 frame = flap_frame_new(od, 0x01, 1152 + length); |
7054f810b0f9
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <mark@kingant.net>
parents:
27158
diff
changeset
|
82 |
7054f810b0f9
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <mark@kingant.net>
parents:
27158
diff
changeset
|
83 byte_stream_put32(&frame->data, 0x00000001); /* FLAP Version */ |
7054f810b0f9
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <mark@kingant.net>
parents:
27158
diff
changeset
|
84 aim_tlvlist_add_raw(&tlvlist, 0x0006, length, chipsahoy); |
7054f810b0f9
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <mark@kingant.net>
parents:
27158
diff
changeset
|
85 |
27429
74e487f82f39
Oh, we don't need a special ui_info field for the AIM clientstring
Mark Doliner <mark@kingant.net>
parents:
27428
diff
changeset
|
86 if (ci->clientstring != NULL) |
74e487f82f39
Oh, we don't need a special ui_info field for the AIM clientstring
Mark Doliner <mark@kingant.net>
parents:
27428
diff
changeset
|
87 aim_tlvlist_add_str(&tlvlist, 0x0003, ci->clientstring); |
74e487f82f39
Oh, we don't need a special ui_info field for the AIM clientstring
Mark Doliner <mark@kingant.net>
parents:
27428
diff
changeset
|
88 else { |
74e487f82f39
Oh, we don't need a special ui_info field for the AIM clientstring
Mark Doliner <mark@kingant.net>
parents:
27428
diff
changeset
|
89 gchar *clientstring = oscar_get_clientstring(); |
27428
5048054d319a
Use the ui_info hash table instead of prefs when passing the clientstring
Mark Doliner <mark@kingant.net>
parents:
27381
diff
changeset
|
90 aim_tlvlist_add_str(&tlvlist, 0x0003, clientstring); |
27429
74e487f82f39
Oh, we don't need a special ui_info field for the AIM clientstring
Mark Doliner <mark@kingant.net>
parents:
27428
diff
changeset
|
91 g_free(clientstring); |
74e487f82f39
Oh, we don't need a special ui_info field for the AIM clientstring
Mark Doliner <mark@kingant.net>
parents:
27428
diff
changeset
|
92 } |
27161
7054f810b0f9
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <mark@kingant.net>
parents:
27158
diff
changeset
|
93 aim_tlvlist_add_16(&tlvlist, 0x0017, (guint16)ci->major); |
7054f810b0f9
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <mark@kingant.net>
parents:
27158
diff
changeset
|
94 aim_tlvlist_add_16(&tlvlist, 0x0018, (guint16)ci->minor); |
7054f810b0f9
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <mark@kingant.net>
parents:
27158
diff
changeset
|
95 aim_tlvlist_add_16(&tlvlist, 0x0019, (guint16)ci->point); |
7054f810b0f9
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <mark@kingant.net>
parents:
27158
diff
changeset
|
96 aim_tlvlist_add_16(&tlvlist, 0x001a, (guint16)ci->build); |
28499
4575d8daba12
oscar: Fix 'Allow multiple simultaenous logins' with clientLogin.
Paul Aurich <paul@darkrain42.org>
parents:
28490
diff
changeset
|
97 aim_tlvlist_add_8(&tlvlist, 0x004a, (allow_multiple_logins ? 0x01 : 0x03)); |
27161
7054f810b0f9
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <mark@kingant.net>
parents:
27158
diff
changeset
|
98 |
7054f810b0f9
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <mark@kingant.net>
parents:
27158
diff
changeset
|
99 aim_tlvlist_write(&frame->data, &tlvlist); |
7054f810b0f9
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <mark@kingant.net>
parents:
27158
diff
changeset
|
100 |
7054f810b0f9
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <mark@kingant.net>
parents:
27158
diff
changeset
|
101 aim_tlvlist_free(tlvlist); |
7054f810b0f9
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <mark@kingant.net>
parents:
27158
diff
changeset
|
102 |
7054f810b0f9
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <mark@kingant.net>
parents:
27158
diff
changeset
|
103 flap_connection_send(conn, frame); |
7054f810b0f9
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <mark@kingant.net>
parents:
27158
diff
changeset
|
104 } |
7054f810b0f9
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <mark@kingant.net>
parents:
27158
diff
changeset
|
105 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
106 static struct rateclass * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
107 flap_connection_get_rateclass(FlapConnection *conn, guint16 family, guint16 subtype) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
108 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
109 gconstpointer key; |
28940
4d50162d809e
Put all our rateclass members in a single hash table instead of in one
Mark Doliner <mark@kingant.net>
parents:
28939
diff
changeset
|
110 gpointer rateclass; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
111 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
112 key = GUINT_TO_POINTER((family << 16) + subtype); |
28940
4d50162d809e
Put all our rateclass members in a single hash table instead of in one
Mark Doliner <mark@kingant.net>
parents:
28939
diff
changeset
|
113 rateclass = g_hash_table_lookup(conn->rateclass_members, key); |
4d50162d809e
Put all our rateclass members in a single hash table instead of in one
Mark Doliner <mark@kingant.net>
parents:
28939
diff
changeset
|
114 if (rateclass != NULL) |
4d50162d809e
Put all our rateclass members in a single hash table instead of in one
Mark Doliner <mark@kingant.net>
parents:
28939
diff
changeset
|
115 return rateclass; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
116 |
28938
2e3e0801de29
optimization to the oscar prpl to use less memory, care of Shaun Lindsay
Mark Doliner <mark@kingant.net>
parents:
28937
diff
changeset
|
117 return conn->default_rateclass; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
118 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
119 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
120 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
121 * Attempt to calculate what our new current average would be if we |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
122 * were to send a SNAC in this rateclass at the given time. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
123 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
124 static guint32 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
125 rateclass_get_new_current(FlapConnection *conn, struct rateclass *rateclass, struct timeval *now) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
126 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
127 unsigned long timediff; /* In milliseconds */ |
28490
45583f271c02
oscar: Update the rate calculations based on OSCAR docs.
aman@tmm1.net
parents:
27555
diff
changeset
|
128 guint32 current; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
129 |
28937
89bece95a522
We were using this formula from before the documentation was public, and
Mark Doliner <mark@kingant.net>
parents:
28499
diff
changeset
|
130 /* This formula is documented at http://dev.aol.com/aim/oscar/#RATELIMIT */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
131 timediff = (now->tv_sec - rateclass->last.tv_sec) * 1000 + (now->tv_usec - rateclass->last.tv_usec) / 1000; |
28490
45583f271c02
oscar: Update the rate calculations based on OSCAR docs.
aman@tmm1.net
parents:
27555
diff
changeset
|
132 current = ((rateclass->current * (rateclass->windowsize - 1)) + timediff) / rateclass->windowsize; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
133 |
28490
45583f271c02
oscar: Update the rate calculations based on OSCAR docs.
aman@tmm1.net
parents:
27555
diff
changeset
|
134 return MIN(current, rateclass->max); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
135 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
136 |
23568
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
137 /* |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
138 * Attempt to send the contents of a given queue |
23578
38a30596ff49
This looks good to me. I'm thinking we probably don't want to get
Mark Doliner <mark@kingant.net>
parents:
23568
diff
changeset
|
139 * |
38a30596ff49
This looks good to me. I'm thinking we probably don't want to get
Mark Doliner <mark@kingant.net>
parents:
23568
diff
changeset
|
140 * @return TRUE if the queue was completely emptied or was initially |
38a30596ff49
This looks good to me. I'm thinking we probably don't want to get
Mark Doliner <mark@kingant.net>
parents:
23568
diff
changeset
|
141 * empty; FALSE if rate limiting prevented it from being |
38a30596ff49
This looks good to me. I'm thinking we probably don't want to get
Mark Doliner <mark@kingant.net>
parents:
23568
diff
changeset
|
142 * emptied. |
23568
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
143 */ |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
144 static gboolean flap_connection_send_snac_queue(FlapConnection *conn, struct timeval now, GQueue *queue) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
145 { |
23568
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
146 while (!g_queue_is_empty(queue)) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
147 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
148 QueuedSnac *queued_snac; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
149 struct rateclass *rateclass; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
150 |
23568
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
151 queued_snac = g_queue_peek_head(queue); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
152 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
153 rateclass = flap_connection_get_rateclass(conn, queued_snac->family, queued_snac->subtype); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
154 if (rateclass != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
155 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
156 guint32 new_current; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
157 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
158 new_current = rateclass_get_new_current(conn, rateclass, &now); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
159 |
28490
45583f271c02
oscar: Update the rate calculations based on OSCAR docs.
aman@tmm1.net
parents:
27555
diff
changeset
|
160 if (rateclass->dropping_snacs || new_current <= rateclass->alert) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
161 /* Not ready to send this SNAC yet--keep waiting. */ |
23568
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
162 return FALSE; |
23578
38a30596ff49
This looks good to me. I'm thinking we probably don't want to get
Mark Doliner <mark@kingant.net>
parents:
23568
diff
changeset
|
163 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
164 rateclass->current = new_current; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
165 rateclass->last.tv_sec = now.tv_sec; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
166 rateclass->last.tv_usec = now.tv_usec; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
167 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
168 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
169 flap_connection_send(conn, queued_snac->frame); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
170 g_free(queued_snac); |
23568
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
171 g_queue_pop_head(queue); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
172 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
173 |
23568
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
174 /* We emptied the queue */ |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
175 return TRUE; |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
176 } |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
177 |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
178 static gboolean flap_connection_send_queued(gpointer data) |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
179 { |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
180 FlapConnection *conn; |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
181 struct timeval now; |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
182 |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
183 conn = data; |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
184 gettimeofday(&now, NULL); |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
185 |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
186 purple_debug_info("oscar", "Attempting to send %u queued SNACs and %u queued low-priority SNACs for %p\n", |
24120
3b968076a5dc
Don't use g_queue_get_length because it requires glib 2.4
Mark Doliner <mark@kingant.net>
parents:
23579
diff
changeset
|
187 (conn->queued_snacs ? conn->queued_snacs->length : 0), |
3b968076a5dc
Don't use g_queue_get_length because it requires glib 2.4
Mark Doliner <mark@kingant.net>
parents:
23579
diff
changeset
|
188 (conn->queued_lowpriority_snacs ? conn->queued_lowpriority_snacs->length : 0), |
23568
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
189 conn); |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
190 if (!conn->queued_snacs || flap_connection_send_snac_queue(conn, now, conn->queued_snacs)) { |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
191 if (!conn->queued_lowpriority_snacs || flap_connection_send_snac_queue(conn, now, conn->queued_lowpriority_snacs)) { |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
192 /* Both queues emptied. */ |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
193 conn->queued_timeout = 0; |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
194 return FALSE; |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
195 } |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
196 } |
23578
38a30596ff49
This looks good to me. I'm thinking we probably don't want to get
Mark Doliner <mark@kingant.net>
parents:
23568
diff
changeset
|
197 |
23568
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
198 /* We couldn't send all our SNACs. Keep trying */ |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
199 return TRUE; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
200 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
201 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
202 /** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
203 * This sends a channel 2 FLAP containing a SNAC. The SNAC family and |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
204 * subtype are looked up in the rate info for this connection, and if |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
205 * sending this SNAC will induce rate limiting then we delay sending |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
206 * of the SNAC by putting it into an outgoing holding queue. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
207 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
208 * @param data The optional bytestream that makes up the data portion |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
209 * of this SNAC. For empty SNACs this should be NULL. |
23578
38a30596ff49
This looks good to me. I'm thinking we probably don't want to get
Mark Doliner <mark@kingant.net>
parents:
23568
diff
changeset
|
210 * @param high_priority If TRUE, the SNAC will be queued normally if |
38a30596ff49
This looks good to me. I'm thinking we probably don't want to get
Mark Doliner <mark@kingant.net>
parents:
23568
diff
changeset
|
211 * needed. If FALSE, it wil be queued separately, to be sent |
38a30596ff49
This looks good to me. I'm thinking we probably don't want to get
Mark Doliner <mark@kingant.net>
parents:
23568
diff
changeset
|
212 * only if all high priority SNACs have been sent. |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
213 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
214 void |
23568
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
215 flap_connection_send_snac_with_priority(OscarData *od, FlapConnection *conn, guint16 family, const guint16 subtype, guint16 flags, aim_snacid_t snacid, ByteStream *data, gboolean high_priority) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
216 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
217 FlapFrame *frame; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
218 guint32 length; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
219 gboolean enqueue = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
220 struct rateclass *rateclass; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
221 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
222 length = data != NULL ? data->offset : 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
223 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
224 frame = flap_frame_new(od, 0x02, 10 + length); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
225 aim_putsnac(&frame->data, family, subtype, flags, snacid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
226 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
227 if (length > 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
228 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
229 byte_stream_rewind(data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
230 byte_stream_putbs(&frame->data, data, length); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
231 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
232 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
233 if (conn->queued_timeout != 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
234 enqueue = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
235 else if ((rateclass = flap_connection_get_rateclass(conn, family, subtype)) != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
236 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
237 struct timeval now; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
238 guint32 new_current; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
239 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
240 gettimeofday(&now, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
241 new_current = rateclass_get_new_current(conn, rateclass, &now); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
242 |
28490
45583f271c02
oscar: Update the rate calculations based on OSCAR docs.
aman@tmm1.net
parents:
27555
diff
changeset
|
243 if (rateclass->dropping_snacs || new_current <= rateclass->alert) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
244 { |
28490
45583f271c02
oscar: Update the rate calculations based on OSCAR docs.
aman@tmm1.net
parents:
27555
diff
changeset
|
245 purple_debug_info("oscar", "Current rate for conn %p would be %u, but we alert at %u; enqueueing\n", conn, new_current, rateclass->alert); |
22717
979a81468e19
All SNACs on FLAP channel 2 except in the auth family are now sent through
Evan Schoenberg <evan.s@dreskin.net>
parents:
22486
diff
changeset
|
246 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
247 enqueue = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
248 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
249 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
250 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
251 rateclass->current = new_current; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
252 rateclass->last.tv_sec = now.tv_sec; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
253 rateclass->last.tv_usec = now.tv_usec; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
254 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
255 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
256 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
257 if (enqueue) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
258 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
259 /* We've been sending too fast, so delay this message */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
260 QueuedSnac *queued_snac; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
261 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
262 queued_snac = g_new(QueuedSnac, 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
263 queued_snac->family = family; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
264 queued_snac->subtype = subtype; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
265 queued_snac->frame = frame; |
23568
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
266 |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
267 if (high_priority) { |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
268 if (!conn->queued_snacs) |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
269 conn->queued_snacs = g_queue_new(); |
23578
38a30596ff49
This looks good to me. I'm thinking we probably don't want to get
Mark Doliner <mark@kingant.net>
parents:
23568
diff
changeset
|
270 g_queue_push_tail(conn->queued_snacs, queued_snac); |
23568
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
271 } else { |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
272 if (!conn->queued_lowpriority_snacs) |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
273 conn->queued_lowpriority_snacs = g_queue_new(); |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
274 g_queue_push_tail(conn->queued_lowpriority_snacs, queued_snac); |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
275 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
276 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
277 if (conn->queued_timeout == 0) |
15822 | 278 conn->queued_timeout = purple_timeout_add(500, flap_connection_send_queued, conn); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
279 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
280 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
281 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
282 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
283 flap_connection_send(conn, frame); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
284 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
285 |
23568
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
286 void |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
287 flap_connection_send_snac(OscarData *od, FlapConnection *conn, guint16 family, const guint16 subtype, guint16 flags, aim_snacid_t snacid, ByteStream *data) |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
288 { |
23579 | 289 flap_connection_send_snac_with_priority(od, conn, family, subtype, flags, snacid, data, TRUE); |
23568
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
290 } |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
291 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
292 /** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
293 * This sends an empty channel 4 FLAP. This is sent to signify |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
294 * that we're logging off. This shouldn't really be necessary-- |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
295 * usually the AIM server will detect that the TCP connection has |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
296 * been destroyed--but it's good practice. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
297 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
298 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
299 flap_connection_send_close(OscarData *od, FlapConnection *conn) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
300 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
301 FlapFrame *frame; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
302 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
303 frame = flap_frame_new(od, 0x04, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
304 flap_connection_send(conn, frame); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
305 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
306 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
307 /** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
308 * This sends an empty channel 5 FLAP. This is used as a keepalive |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
309 * packet in FLAP connections. WinAIM 4.x and higher send these |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
310 * _every minute_ to keep the connection alive. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
311 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
312 void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
313 flap_connection_send_keepalive(OscarData *od, FlapConnection *conn) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
314 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
315 FlapFrame *frame; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
316 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
317 frame = flap_frame_new(od, 0x05, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
318 flap_connection_send(conn, frame); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
319 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
320 /* clean out SNACs over 60sec old */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
321 aim_cleansnacs(od, 60); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
322 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
323 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
324 /** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
325 * Allocate a new empty connection structure. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
326 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
327 * @param od The oscar session associated with this connection. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
328 * @param type Type of connection to create |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
329 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
330 * @return Returns the new connection structure. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
331 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
332 FlapConnection * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
333 flap_connection_new(OscarData *od, int type) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
334 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
335 FlapConnection *conn; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
336 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
337 conn = g_new0(FlapConnection, 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
338 conn->od = od; |
15822 | 339 conn->buffer_outgoing = purple_circ_buffer_new(0); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
340 conn->fd = -1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
341 conn->subtype = -1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
342 conn->type = type; |
28940
4d50162d809e
Put all our rateclass members in a single hash table instead of in one
Mark Doliner <mark@kingant.net>
parents:
28939
diff
changeset
|
343 conn->rateclass_members = g_hash_table_new(g_direct_hash, g_direct_equal); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
344 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
345 od->oscar_connections = g_slist_prepend(od->oscar_connections, conn); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
346 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
347 return conn; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
348 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
349 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
350 /** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
351 * Close (but not free) a connection. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
352 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
353 * This cancels any currently pending connection attempt, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
354 * closes any open fd and frees the auth cookie. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
355 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
356 * @param conn The connection to close. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
357 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
358 void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
359 flap_connection_close(OscarData *od, FlapConnection *conn) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
360 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
361 if (conn->connect_data != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
362 { |
15822 | 363 purple_proxy_connect_cancel(conn->connect_data); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
364 conn->connect_data = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
365 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
366 |
23562
3b3d7039bc8e
Daniel Atallah pointed out that this was obviously wrong. So we would
Mark Doliner <mark@kingant.net>
parents:
22917
diff
changeset
|
367 if (conn->new_conn_data != NULL) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
368 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
369 if (conn->type == SNAC_FAMILY_CHAT) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
370 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
371 oscar_chat_destroy(conn->new_conn_data); |
23563
de24d89313b0
I swear I did this! I must have gotten a little overzealous with the
Mark Doliner <mark@kingant.net>
parents:
23562
diff
changeset
|
372 conn->new_conn_data = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
373 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
374 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
375 |
27158
75aaadd295ed
Stop the watchers before closing the fds
Mark Doliner <mark@kingant.net>
parents:
27143
diff
changeset
|
376 if ((conn->fd >= 0 || conn->gsc != NULL) |
75aaadd295ed
Stop the watchers before closing the fds
Mark Doliner <mark@kingant.net>
parents:
27143
diff
changeset
|
377 && conn->type == SNAC_FAMILY_LOCATE) |
75aaadd295ed
Stop the watchers before closing the fds
Mark Doliner <mark@kingant.net>
parents:
27143
diff
changeset
|
378 flap_connection_send_close(od, conn); |
25211
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
379 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
380 if (conn->watcher_incoming != 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
381 { |
15822 | 382 purple_input_remove(conn->watcher_incoming); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
383 conn->watcher_incoming = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
384 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
385 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
386 if (conn->watcher_outgoing != 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
387 { |
15822 | 388 purple_input_remove(conn->watcher_outgoing); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
389 conn->watcher_outgoing = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
390 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
391 |
27158
75aaadd295ed
Stop the watchers before closing the fds
Mark Doliner <mark@kingant.net>
parents:
27143
diff
changeset
|
392 if (conn->fd >= 0) |
75aaadd295ed
Stop the watchers before closing the fds
Mark Doliner <mark@kingant.net>
parents:
27143
diff
changeset
|
393 { |
75aaadd295ed
Stop the watchers before closing the fds
Mark Doliner <mark@kingant.net>
parents:
27143
diff
changeset
|
394 close(conn->fd); |
75aaadd295ed
Stop the watchers before closing the fds
Mark Doliner <mark@kingant.net>
parents:
27143
diff
changeset
|
395 conn->fd = -1; |
75aaadd295ed
Stop the watchers before closing the fds
Mark Doliner <mark@kingant.net>
parents:
27143
diff
changeset
|
396 } |
75aaadd295ed
Stop the watchers before closing the fds
Mark Doliner <mark@kingant.net>
parents:
27143
diff
changeset
|
397 |
75aaadd295ed
Stop the watchers before closing the fds
Mark Doliner <mark@kingant.net>
parents:
27143
diff
changeset
|
398 if (conn->gsc != NULL) |
75aaadd295ed
Stop the watchers before closing the fds
Mark Doliner <mark@kingant.net>
parents:
27143
diff
changeset
|
399 { |
75aaadd295ed
Stop the watchers before closing the fds
Mark Doliner <mark@kingant.net>
parents:
27143
diff
changeset
|
400 purple_ssl_close(conn->gsc); |
75aaadd295ed
Stop the watchers before closing the fds
Mark Doliner <mark@kingant.net>
parents:
27143
diff
changeset
|
401 conn->gsc = NULL; |
75aaadd295ed
Stop the watchers before closing the fds
Mark Doliner <mark@kingant.net>
parents:
27143
diff
changeset
|
402 } |
75aaadd295ed
Stop the watchers before closing the fds
Mark Doliner <mark@kingant.net>
parents:
27143
diff
changeset
|
403 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
404 g_free(conn->buffer_incoming.data.data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
405 conn->buffer_incoming.data.data = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
406 |
15822 | 407 purple_circ_buffer_destroy(conn->buffer_outgoing); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
408 conn->buffer_outgoing = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
409 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
410 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
411 /** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
412 * Free a FlapFrame |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
413 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
414 * @param frame The frame to free. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
415 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
416 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
417 flap_frame_destroy(FlapFrame *frame) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
418 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
419 g_free(frame->data.data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
420 g_free(frame); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
421 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
422 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
423 static gboolean |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
424 flap_connection_destroy_cb(gpointer data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
425 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
426 FlapConnection *conn; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
427 OscarData *od; |
15822 | 428 PurpleAccount *account; |
18608
a244c34ce59c
Call the AIM_CB_SPECIAL_CONNERR callback from
Mark Doliner <mark@kingant.net>
parents:
17476
diff
changeset
|
429 aim_rxcallback_t userfunc; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
430 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
431 conn = data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
432 od = conn->od; |
22167
ce5ced43cd93
Undo revision accb4afcd6bbf17cf99d9aac0b4b448293190647. This should
Mark Doliner <mark@kingant.net>
parents:
22166
diff
changeset
|
433 account = purple_connection_get_account(od->gc); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
434 |
15822 | 435 purple_debug_info("oscar", "Destroying oscar connection of " |
18608
a244c34ce59c
Call the AIM_CB_SPECIAL_CONNERR callback from
Mark Doliner <mark@kingant.net>
parents:
17476
diff
changeset
|
436 "type 0x%04hx. Disconnect reason is %d\n", |
a244c34ce59c
Call the AIM_CB_SPECIAL_CONNERR callback from
Mark Doliner <mark@kingant.net>
parents:
17476
diff
changeset
|
437 conn->type, conn->disconnect_reason); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
438 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
439 od->oscar_connections = g_slist_remove(od->oscar_connections, conn); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
440 |
18608
a244c34ce59c
Call the AIM_CB_SPECIAL_CONNERR callback from
Mark Doliner <mark@kingant.net>
parents:
17476
diff
changeset
|
441 if ((userfunc = aim_callhandler(od, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR))) |
a244c34ce59c
Call the AIM_CB_SPECIAL_CONNERR callback from
Mark Doliner <mark@kingant.net>
parents:
17476
diff
changeset
|
442 userfunc(od, conn, NULL, conn->disconnect_code, conn->error_message); |
a244c34ce59c
Call the AIM_CB_SPECIAL_CONNERR callback from
Mark Doliner <mark@kingant.net>
parents:
17476
diff
changeset
|
443 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
444 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
445 * TODO: If we don't have a SNAC_FAMILY_LOCATE connection then |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
446 * we should try to request one instead of disconnecting. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
447 */ |
22167
ce5ced43cd93
Undo revision accb4afcd6bbf17cf99d9aac0b4b448293190647. This should
Mark Doliner <mark@kingant.net>
parents:
22166
diff
changeset
|
448 if (!account->disconnecting && ((od->oscar_connections == NULL) |
ce5ced43cd93
Undo revision accb4afcd6bbf17cf99d9aac0b4b448293190647. This should
Mark Doliner <mark@kingant.net>
parents:
22166
diff
changeset
|
449 || (!flap_connection_getbytype(od, SNAC_FAMILY_LOCATE)))) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
450 { |
15822 | 451 /* No more FLAP connections! Sign off this PurpleConnection! */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
452 gchar *tmp; |
21358 | 453 PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR; |
20124
05726ea2dd89
Add disconnection reasons to oscar.
Will Thompson <will.thompson@collabora.co.uk>
parents:
19681
diff
changeset
|
454 |
18609
2774acdb1cff
Move a call to purple_connection_error() from oscar.c to
Mark Doliner <mark@kingant.net>
parents:
18608
diff
changeset
|
455 if (conn->disconnect_code == 0x0001) { |
21358 | 456 reason = PURPLE_CONNECTION_ERROR_NAME_IN_USE; |
27374
fe912af02ff6
Remove trailing periods from short disconnection error messags and remove
Mark Doliner <mark@kingant.net>
parents:
27161
diff
changeset
|
457 tmp = g_strdup(_("You have signed on from another location")); |
20589
5723dbc6212d
Clear the password consistently when we get a "Signed-On elsewhere" or a "Invalid Password" disconnection. Disconnection reason codes will take care of this in the core, but until then, this is ok. Fixes #3204.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19681
diff
changeset
|
458 if (!purple_account_get_remember_password(account)) |
5723dbc6212d
Clear the password consistently when we get a "Signed-On elsewhere" or a "Invalid Password" disconnection. Disconnection reason codes will take care of this in the core, but until then, this is ok. Fixes #3204.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19681
diff
changeset
|
459 purple_account_set_password(account, NULL); |
18609
2774acdb1cff
Move a call to purple_connection_error() from oscar.c to
Mark Doliner <mark@kingant.net>
parents:
18608
diff
changeset
|
460 } else if (conn->disconnect_reason == OSCAR_DISCONNECT_REMOTE_CLOSED) |
27374
fe912af02ff6
Remove trailing periods from short disconnection error messags and remove
Mark Doliner <mark@kingant.net>
parents:
27161
diff
changeset
|
461 tmp = g_strdup(_("Server closed the connection")); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
462 else if (conn->disconnect_reason == OSCAR_DISCONNECT_LOST_CONNECTION) |
27374
fe912af02ff6
Remove trailing periods from short disconnection error messags and remove
Mark Doliner <mark@kingant.net>
parents:
27161
diff
changeset
|
463 tmp = g_strdup_printf(_("Lost connection with server: %s"), |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
464 conn->error_message); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
465 else if (conn->disconnect_reason == OSCAR_DISCONNECT_INVALID_DATA) |
27374
fe912af02ff6
Remove trailing periods from short disconnection error messags and remove
Mark Doliner <mark@kingant.net>
parents:
27161
diff
changeset
|
466 tmp = g_strdup(_("Received invalid data on connection with server")); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
467 else if (conn->disconnect_reason == OSCAR_DISCONNECT_COULD_NOT_CONNECT) |
27381
f541583e31bd
More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents:
27374
diff
changeset
|
468 tmp = g_strdup_printf(_("Unable to connect: %s"), |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
469 conn->error_message); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
470 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
471 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
472 * We shouldn't print a message for some disconnect_reasons. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
473 * Like OSCAR_DISCONNECT_LOCAL_CLOSED. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
474 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
475 tmp = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
476 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
477 if (tmp != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
478 { |
20124
05726ea2dd89
Add disconnection reasons to oscar.
Will Thompson <will.thompson@collabora.co.uk>
parents:
19681
diff
changeset
|
479 purple_connection_error_reason(od->gc, reason, tmp); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
480 g_free(tmp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
481 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
482 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
483 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
484 flap_connection_close(od, conn); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
485 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
486 g_free(conn->error_message); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
487 g_free(conn->cookie); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
488 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
489 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
490 * Free conn->internal, if necessary |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
491 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
492 if (conn->type == SNAC_FAMILY_CHAT) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
493 flap_connection_destroy_chat(od, conn); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
494 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
495 g_slist_free(conn->groups); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
496 while (conn->rateclasses != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
497 { |
28940
4d50162d809e
Put all our rateclass members in a single hash table instead of in one
Mark Doliner <mark@kingant.net>
parents:
28939
diff
changeset
|
498 g_free(conn->rateclasses->data); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
499 conn->rateclasses = g_slist_delete_link(conn->rateclasses, conn->rateclasses); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
500 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
501 |
28940
4d50162d809e
Put all our rateclass members in a single hash table instead of in one
Mark Doliner <mark@kingant.net>
parents:
28939
diff
changeset
|
502 g_hash_table_destroy(conn->rateclass_members); |
4d50162d809e
Put all our rateclass members in a single hash table instead of in one
Mark Doliner <mark@kingant.net>
parents:
28939
diff
changeset
|
503 |
23568
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
504 if (conn->queued_snacs) { |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
505 while (!g_queue_is_empty(conn->queued_snacs)) |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
506 { |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
507 QueuedSnac *queued_snac; |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
508 queued_snac = g_queue_pop_head(conn->queued_snacs); |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
509 flap_frame_destroy(queued_snac->frame); |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
510 g_free(queued_snac); |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
511 } |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
512 g_queue_free(conn->queued_snacs); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
513 } |
23568
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
514 |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
515 if (conn->queued_lowpriority_snacs) { |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
516 while (!g_queue_is_empty(conn->queued_lowpriority_snacs)) |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
517 { |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
518 QueuedSnac *queued_snac; |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
519 queued_snac = g_queue_pop_head(conn->queued_lowpriority_snacs); |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
520 flap_frame_destroy(queued_snac->frame); |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
521 g_free(queued_snac); |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
522 } |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
523 g_queue_free(conn->queued_lowpriority_snacs); |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
524 } |
0a674616953c
Added `flap_connection_send_snac_with_priority()`, which allows specifying
Evan Schoenberg <evan.s@dreskin.net>
parents:
23563
diff
changeset
|
525 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
526 if (conn->queued_timeout > 0) |
15822 | 527 purple_timeout_remove(conn->queued_timeout); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
528 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
529 g_free(conn); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
530 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
531 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
532 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
533 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
534 /** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
535 * See the comments for the parameters of |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
536 * flap_connection_schedule_destroy(). |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
537 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
538 void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
539 flap_connection_destroy(FlapConnection *conn, OscarDisconnectReason reason, const gchar *error_message) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
540 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
541 if (conn->destroy_timeout != 0) |
15822 | 542 purple_timeout_remove(conn->destroy_timeout); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
543 conn->disconnect_reason = reason; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
544 g_free(conn->error_message); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
545 conn->error_message = g_strdup(error_message); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
546 flap_connection_destroy_cb(conn); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
547 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
548 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
549 /** |
15822 | 550 * Schedule Purple to destroy the given FlapConnection as soon as we |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
551 * return control back to the program's main loop. We must do this |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
552 * if we want to destroy the connection but we are still using it |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
553 * for some reason. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
554 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
555 * @param reason The reason for the disconnection. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
556 * @param error_message A brief error message that gives more detail |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
557 * regarding the reason for the disconnecting. This should |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
558 * be NULL for everything except OSCAR_DISCONNECT_LOST_CONNECTION, |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20589
diff
changeset
|
559 * in which case it should contain the value of g_strerror(errno), |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
560 * and OSCAR_DISCONNECT_COULD_NOT_CONNECT, in which case it |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
561 * should contain the error_message passed back from the call |
15822 | 562 * to purple_proxy_connect(). |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
563 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
564 void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
565 flap_connection_schedule_destroy(FlapConnection *conn, OscarDisconnectReason reason, const gchar *error_message) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
566 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
567 if (conn->destroy_timeout != 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
568 /* Already taken care of */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
569 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
570 |
15822 | 571 purple_debug_info("oscar", "Scheduling destruction of FLAP " |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
572 "connection of type 0x%04hx\n", conn->type); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
573 conn->disconnect_reason = reason; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
574 g_free(conn->error_message); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
575 conn->error_message = g_strdup(error_message); |
15822 | 576 conn->destroy_timeout = purple_timeout_add(0, flap_connection_destroy_cb, conn); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
577 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
578 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
579 /** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
580 * In OSCAR, every connection has a set of SNAC groups associated |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
581 * with it. These are the groups that you can send over this connection |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
582 * without being guaranteed a "Not supported" SNAC error. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
583 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
584 * The grand theory of things says that these associations transcend |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
585 * what libfaim calls "connection types" (conn->type). You can probably |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
586 * see the elegance here, but since I want to revel in it for a bit, you |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
587 * get to hear it all spelled out. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
588 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
589 * So let us say that you have your core BOS connection running. One |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
590 * of your modules has just given you a SNAC of the group 0x0004 to send |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
591 * you. Maybe an IM destined for some twit in Greenland. So you start |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
592 * at the top of your connection list, looking for a connection that |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
593 * claims to support group 0x0004. You find one. Why, that neat BOS |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
594 * connection of yours can do that. So you send it on its way. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
595 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
596 * Now, say, that fellow from Greenland has friends and they all want to |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
597 * meet up with you in a lame chat room. This has landed you a SNAC |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
598 * in the family 0x000e and you have to admit you're a bit lost. You've |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
599 * searched your connection list for someone who wants to make your life |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
600 * easy and deliver this SNAC for you, but there isn't one there. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
601 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
602 * Here comes the good bit. Without even letting anyone know, particularly |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
603 * the module that decided to send this SNAC, and definitely not that twit |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
604 * in Greenland, you send out a service request. In this request, you have |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
605 * marked the need for a connection supporting group 0x000e. A few seconds |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
606 * later, you receive a service redirect with an IP address and a cookie in |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
607 * it. Great, you say. Now I have something to do. Off you go, making |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
608 * that connection. One of the first things you get from this new server |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
609 * is a message saying that indeed it does support the group you were looking |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
610 * for. So you continue and send rate confirmation and all that. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
611 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
612 * Then you remember you had that SNAC to send, and now you have a means to |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
613 * do it, and you do, and everyone is happy. Except the Greenlander, who is |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
614 * still stuck in the bitter cold. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
615 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
616 * Oh, and this is useful for building the Migration SNACs, too. In the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
617 * future, this may help convince me to implement rate limit mitigation |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
618 * for real. We'll see. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
619 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
620 * Just to make me look better, I'll say that I've known about this great |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
621 * scheme for quite some time now. But I still haven't convinced myself |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
622 * to make libfaim work that way. It would take a fair amount of effort, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
623 * and probably some client API changes as well. (Whenever I don't want |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
624 * to do something, I just say it would change the client API. Then I |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
625 * instantly have a couple of supporters of not doing it.) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
626 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
627 * Generally, addgroup is only called by the internal handling of the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
628 * server ready SNAC. So if you want to do something before that, you'll |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
629 * have to be more creative. That is done rather early, though, so I don't |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
630 * think you have to worry about it. Unless you're me. I care deeply |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
631 * about such inane things. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
632 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
633 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
634 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
635 /** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
636 * Find a FlapConnection that supports the given oscar |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
637 * family. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
638 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
639 FlapConnection * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
640 flap_connection_findbygroup(OscarData *od, guint16 group) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
641 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
642 GSList *cur; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
643 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
644 for (cur = od->oscar_connections; cur != NULL; cur = cur->next) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
645 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
646 FlapConnection *conn; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
647 GSList *l; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
648 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
649 conn = cur->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
650 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
651 for (l = conn->groups; l != NULL; l = l->next) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
652 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
653 if (GPOINTER_TO_UINT(l->data) == group) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
654 return conn; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
655 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
656 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
657 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
658 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
659 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
660 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
661 /** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
662 * Locates a connection of the specified type in the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
663 * specified session. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
664 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
665 * TODO: Use flap_connection_findbygroup everywhere and get rid of this. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
666 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
667 * @param od The session to search. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
668 * @param type The type of connection to look for. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
669 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
670 * @return Returns the first connection found of the given target type, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
671 * or NULL if none could be found. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
672 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
673 FlapConnection * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
674 flap_connection_getbytype(OscarData *od, int type) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
675 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
676 GSList *cur; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
677 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
678 for (cur = od->oscar_connections; cur != NULL; cur = cur->next) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
679 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
680 FlapConnection *conn; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
681 conn = cur->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
682 if ((conn->type == type) && (conn->connected)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
683 return conn; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
684 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
685 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
686 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
687 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
688 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
689 FlapConnection * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
690 flap_connection_getbytype_all(OscarData *od, int type) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
691 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
692 GSList *cur; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
693 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
694 for (cur = od->oscar_connections; cur; cur = cur->next) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
695 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
696 FlapConnection *conn; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
697 conn = cur->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
698 if (conn->type == type) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
699 return conn; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
700 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
701 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
702 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
703 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
704 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
705 /** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
706 * Allocate a new FLAP frame. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
707 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
708 * @param channel The FLAP channel. This is almost always 2. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
709 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
710 FlapFrame * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
711 flap_frame_new(OscarData *od, guint16 channel, int datalen) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
712 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
713 FlapFrame *frame; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
714 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
715 frame = g_new0(FlapFrame, 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
716 frame->channel = channel; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
717 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
718 if (datalen > 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
719 byte_stream_new(&frame->data, datalen); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
720 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
721 return frame; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
722 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
723 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
724 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
725 parse_snac(OscarData *od, FlapConnection *conn, FlapFrame *frame) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
726 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
727 aim_module_t *cur; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
728 aim_modsnac_t snac; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
729 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
730 if (byte_stream_empty(&frame->data) < 10) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
731 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
732 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
733 snac.family = byte_stream_get16(&frame->data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
734 snac.subtype = byte_stream_get16(&frame->data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
735 snac.flags = byte_stream_get16(&frame->data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
736 snac.id = byte_stream_get32(&frame->data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
737 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
738 /* SNAC flags are apparently uniform across all SNACs, so we handle them here */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
739 if (snac.flags & 0x0001) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
740 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
741 * This means the SNAC will be followed by another SNAC with |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
742 * related information. We don't need to do anything about |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
743 * this here. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
744 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
745 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
746 if (snac.flags & 0x8000) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
747 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
748 * This packet contains the version of the family that this SNAC is |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
749 * in. You get this when your SSI module is version 2 or higher. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
750 * For now we have no need for this, but you could always save |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
751 * it as a part of aim_modnsac_t, or something. The format is... |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
752 * 2 byte length of total mini-header (which is 6 bytes), then TLV |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
753 * of type 0x0001, length 0x0002, value is the 2 byte version |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
754 * number |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
755 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
756 byte_stream_advance(&frame->data, byte_stream_get16(&frame->data)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
757 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
758 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
759 for (cur = (aim_module_t *)od->modlistv; cur; cur = cur->next) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
760 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
761 if (!(cur->flags & AIM_MODFLAG_MULTIFAMILY) && |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
762 (cur->family != snac.family)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
763 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
764 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
765 if (cur->snachandler(od, conn, cur, frame, &snac, &frame->data)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
766 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
767 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
768 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
769 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
770 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
771 parse_fakesnac(OscarData *od, FlapConnection *conn, FlapFrame *frame, guint16 family, guint16 subtype) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
772 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
773 aim_module_t *cur; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
774 aim_modsnac_t snac; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
775 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
776 snac.family = family; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
777 snac.subtype = subtype; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
778 snac.flags = snac.id = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
779 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
780 for (cur = (aim_module_t *)od->modlistv; cur; cur = cur->next) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
781 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
782 if (!(cur->flags & AIM_MODFLAG_MULTIFAMILY) && |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
783 (cur->family != snac.family)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
784 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
785 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
786 if (cur->snachandler(od, conn, cur, frame, &snac, &frame->data)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
787 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
788 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
789 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
790 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
791 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
792 parse_flap_ch4(OscarData *od, FlapConnection *conn, FlapFrame *frame) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
793 { |
17369
f80f7e1047be
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <mark@kingant.net>
parents:
17191
diff
changeset
|
794 GSList *tlvlist; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
795 char *msg = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
796 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
797 if (byte_stream_empty(&frame->data) == 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
798 /* XXX should do something with this */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
799 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
800 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
801 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
802 /* An ICQ account is logging in */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
803 if (conn->type == SNAC_FAMILY_AUTH) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
804 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
805 parse_fakesnac(od, conn, frame, 0x0017, 0x0003); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
806 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
807 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
808 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
809 tlvlist = aim_tlvlist_read(&frame->data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
810 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
811 if (aim_tlv_gettlv(tlvlist, 0x0009, 1)) |
18608
a244c34ce59c
Call the AIM_CB_SPECIAL_CONNERR callback from
Mark Doliner <mark@kingant.net>
parents:
17476
diff
changeset
|
812 conn->disconnect_code = aim_tlv_get16(tlvlist, 0x0009, 1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
813 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
814 if (aim_tlv_gettlv(tlvlist, 0x000b, 1)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
815 msg = aim_tlv_getstr(tlvlist, 0x000b, 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
816 |
18608
a244c34ce59c
Call the AIM_CB_SPECIAL_CONNERR callback from
Mark Doliner <mark@kingant.net>
parents:
17476
diff
changeset
|
817 /* |
a244c34ce59c
Call the AIM_CB_SPECIAL_CONNERR callback from
Mark Doliner <mark@kingant.net>
parents:
17476
diff
changeset
|
818 * The server ended this FLAP connnection, so let's be nice and |
a244c34ce59c
Call the AIM_CB_SPECIAL_CONNERR callback from
Mark Doliner <mark@kingant.net>
parents:
17476
diff
changeset
|
819 * close the physical TCP connection |
a244c34ce59c
Call the AIM_CB_SPECIAL_CONNERR callback from
Mark Doliner <mark@kingant.net>
parents:
17476
diff
changeset
|
820 */ |
a244c34ce59c
Call the AIM_CB_SPECIAL_CONNERR callback from
Mark Doliner <mark@kingant.net>
parents:
17476
diff
changeset
|
821 flap_connection_schedule_destroy(conn, |
a244c34ce59c
Call the AIM_CB_SPECIAL_CONNERR callback from
Mark Doliner <mark@kingant.net>
parents:
17476
diff
changeset
|
822 OSCAR_DISCONNECT_REMOTE_CLOSED, msg); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
823 |
17369
f80f7e1047be
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <mark@kingant.net>
parents:
17191
diff
changeset
|
824 aim_tlvlist_free(tlvlist); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
825 |
17191
1927f4ead3ca
Make all the oscar memory allocations and frees use the glib functions to avoid problems when mixing C runtimes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
15822
diff
changeset
|
826 g_free(msg); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
827 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
828 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
829 /** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
830 * Takes a new incoming FLAP frame and sends it to the appropriate |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
831 * handler function to be parsed. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
832 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
833 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
834 parse_flap(OscarData *od, FlapConnection *conn, FlapFrame *frame) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
835 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
836 if (frame->channel == 0x01) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
837 guint32 flap_version = byte_stream_get32(&frame->data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
838 if (flap_version != 0x00000001) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
839 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
840 /* Error! */ |
15822 | 841 purple_debug_warning("oscar", "Expecting FLAP version " |
22486
3225c99785b8
Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <mark@kingant.net>
parents:
22195
diff
changeset
|
842 "0x00000001 but received FLAP version %08x. Closing connection.\n", |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
843 flap_version); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
844 flap_connection_schedule_destroy(conn, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
845 OSCAR_DISCONNECT_INVALID_DATA, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
846 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
847 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
848 conn->connected = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
849 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
850 } else if (frame->channel == 0x02) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
851 parse_snac(od, conn, frame); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
852 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
853 } else if (frame->channel == 0x04) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
854 parse_flap_ch4(od, conn, frame); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
855 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
856 } else if (frame->channel == 0x05) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
857 /* TODO: Reset our keepalive watchdog? */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
858 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
859 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
860 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
861 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
862 /** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
863 * Read in all available data on the socket for a given connection. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
864 * All complete FLAPs handled immedate after they're received. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
865 * Incomplete FLAP data is stored locally and appended to the next |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
866 * time this callback is triggered. |
25211
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
867 * |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
868 * This is called by flap_connection_recv_cb and |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
869 * flap_connection_recv_cb_ssl for unencrypted/encrypted connections. |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
870 */ |
25211
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
871 static void |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
872 flap_connection_recv(FlapConnection *conn) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
873 { |
25211
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
874 gpointer buf; |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
875 gsize buflen; |
22914
8f353a311895
More s/ssize_t/gssize/
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22856
diff
changeset
|
876 gssize read; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
877 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
878 /* Read data until we run out of data and break out of the loop */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
879 while (TRUE) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
880 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
881 /* Start reading a new FLAP */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
882 if (conn->buffer_incoming.data.data == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
883 { |
25211
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
884 buf = conn->header + conn->header_received; |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
885 buflen = 6 - conn->header_received; |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
886 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
887 /* Read the first 6 bytes (the FLAP header) */ |
25211
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
888 if (conn->gsc) |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
889 read = purple_ssl_read(conn->gsc, buf, buflen); |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
890 else |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
891 read = recv(conn->fd, buf, buflen, 0); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
892 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
893 /* Check if the FLAP server closed the connection */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
894 if (read == 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
895 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
896 flap_connection_schedule_destroy(conn, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
897 OSCAR_DISCONNECT_REMOTE_CLOSED, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
898 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
899 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
900 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
901 /* If there was an error then close the connection */ |
17448
648551e3243a
Only check for EAGAIN if send returns -1, not when it returns 0
Mark Doliner <mark@kingant.net>
parents:
17369
diff
changeset
|
902 if (read < 0) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
903 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
904 if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
905 /* No worries */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
906 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
907 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
908 /* Error! */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
909 flap_connection_schedule_destroy(conn, |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20589
diff
changeset
|
910 OSCAR_DISCONNECT_LOST_CONNECTION, g_strerror(errno)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
911 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
912 } |
22149
252b96b6a32c
Don't send keep-alives if we've received data since in the last KEEPALIVE_INTERVAL seconds
Sean Egan <seanegan@gmail.com>
parents:
21418
diff
changeset
|
913 conn->od->gc->last_received = time(NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
914 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
915 /* If we don't even have a complete FLAP header then do nothing */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
916 conn->header_received += read; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
917 if (conn->header_received < 6) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
918 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
919 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
920 /* All FLAP frames must start with the byte 0x2a */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
921 if (aimutil_get8(&conn->header[0]) != 0x2a) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
922 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
923 flap_connection_schedule_destroy(conn, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
924 OSCAR_DISCONNECT_INVALID_DATA, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
925 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
926 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
927 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
928 /* Verify the sequence number sent by the server. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
929 #if 0 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
930 /* TODO: Need to initialize conn->seqnum_in somewhere before we can use this. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
931 if (aimutil_get16(&conn->header[1]) != conn->seqnum_in++) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
932 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
933 /* Received an out-of-order FLAP! */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
934 flap_connection_schedule_destroy(conn, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
935 OSCAR_DISCONNECT_INVALID_DATA, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
936 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
937 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
938 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
939 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
940 /* Initialize a new temporary FlapFrame for incoming data */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
941 conn->buffer_incoming.channel = aimutil_get8(&conn->header[1]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
942 conn->buffer_incoming.seqnum = aimutil_get16(&conn->header[2]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
943 conn->buffer_incoming.data.len = aimutil_get16(&conn->header[4]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
944 conn->buffer_incoming.data.data = g_new(guint8, conn->buffer_incoming.data.len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
945 conn->buffer_incoming.data.offset = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
946 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
947 |
25211
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
948 buflen = conn->buffer_incoming.data.len - conn->buffer_incoming.data.offset; |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
949 if (buflen) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
950 { |
25211
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
951 buf = &conn->buffer_incoming.data.data[conn->buffer_incoming.data.offset]; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
952 /* Read data into the temporary FlapFrame until it is complete */ |
25211
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
953 if (conn->gsc) |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
954 read = purple_ssl_read(conn->gsc, buf, buflen); |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
955 else |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
956 read = recv(conn->fd, buf, buflen, 0); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
957 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
958 /* Check if the FLAP server closed the connection */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
959 if (read == 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
960 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
961 flap_connection_schedule_destroy(conn, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
962 OSCAR_DISCONNECT_REMOTE_CLOSED, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
963 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
964 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
965 |
17448
648551e3243a
Only check for EAGAIN if send returns -1, not when it returns 0
Mark Doliner <mark@kingant.net>
parents:
17369
diff
changeset
|
966 if (read < 0) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
967 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
968 if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
969 /* No worries */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
970 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
971 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
972 /* Error! */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
973 flap_connection_schedule_destroy(conn, |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20589
diff
changeset
|
974 OSCAR_DISCONNECT_LOST_CONNECTION, g_strerror(errno)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
975 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
976 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
977 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
978 conn->buffer_incoming.data.offset += read; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
979 if (conn->buffer_incoming.data.offset < conn->buffer_incoming.data.len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
980 /* Waiting for more data to arrive */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
981 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
982 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
983 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
984 /* We have a complete FLAP! Handle it and continue reading */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
985 byte_stream_rewind(&conn->buffer_incoming.data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
986 parse_flap(conn->od, conn, &conn->buffer_incoming); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
987 conn->lastactivity = time(NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
988 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
989 g_free(conn->buffer_incoming.data.data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
990 conn->buffer_incoming.data.data = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
991 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
992 conn->header_received = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
993 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
994 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
995 |
25211
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
996 void |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
997 flap_connection_recv_cb(gpointer data, gint source, PurpleInputCondition cond) |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
998 { |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
999 FlapConnection *conn = data; |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
1000 |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
1001 flap_connection_recv(conn); |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
1002 } |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
1003 |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
1004 void |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
1005 flap_connection_recv_cb_ssl(gpointer data, PurpleSslConnection *gsc, PurpleInputCondition cond) |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
1006 { |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
1007 FlapConnection *conn = data; |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
1008 |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
1009 flap_connection_recv(conn); |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
1010 } |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
1011 |
25381
f6ef3a9534db
Shuffle a few comments around to make it look like I did something
Mark Doliner <mark@kingant.net>
parents:
25213
diff
changeset
|
1012 /** |
f6ef3a9534db
Shuffle a few comments around to make it look like I did something
Mark Doliner <mark@kingant.net>
parents:
25213
diff
changeset
|
1013 * @param source When this function is called as a callback source is |
f6ef3a9534db
Shuffle a few comments around to make it look like I did something
Mark Doliner <mark@kingant.net>
parents:
25213
diff
changeset
|
1014 * set to the fd that triggered the callback. But this function |
f6ef3a9534db
Shuffle a few comments around to make it look like I did something
Mark Doliner <mark@kingant.net>
parents:
25213
diff
changeset
|
1015 * is also called directly from flap_connection_send_byte_stream(), |
f6ef3a9534db
Shuffle a few comments around to make it look like I did something
Mark Doliner <mark@kingant.net>
parents:
25213
diff
changeset
|
1016 * in which case source will be -1. So don't use source--use |
f6ef3a9534db
Shuffle a few comments around to make it look like I did something
Mark Doliner <mark@kingant.net>
parents:
25213
diff
changeset
|
1017 * conn->gsc or conn->fd instead. |
f6ef3a9534db
Shuffle a few comments around to make it look like I did something
Mark Doliner <mark@kingant.net>
parents:
25213
diff
changeset
|
1018 */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1019 static void |
15822 | 1020 send_cb(gpointer data, gint source, PurpleInputCondition cond) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1021 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1022 FlapConnection *conn; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1023 int writelen, ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1024 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1025 conn = data; |
15822 | 1026 writelen = purple_circ_buffer_get_max_read(conn->buffer_outgoing); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1027 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1028 if (writelen == 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1029 { |
15822 | 1030 purple_input_remove(conn->watcher_outgoing); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1031 conn->watcher_outgoing = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1032 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1033 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1034 |
25211
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
1035 if (conn->gsc) |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
1036 ret = purple_ssl_write(conn->gsc, conn->buffer_outgoing->outptr, |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
1037 writelen); |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
1038 else |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
1039 ret = send(conn->fd, conn->buffer_outgoing->outptr, writelen, 0); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1040 if (ret <= 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1041 { |
27374
fe912af02ff6
Remove trailing periods from short disconnection error messags and remove
Mark Doliner <mark@kingant.net>
parents:
27161
diff
changeset
|
1042 if (ret < 0 && (errno == EAGAIN || errno == EWOULDBLOCK)) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1043 /* No worries */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1044 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1045 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1046 /* Error! */ |
15822 | 1047 purple_input_remove(conn->watcher_outgoing); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1048 conn->watcher_outgoing = 0; |
25211
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
1049 if (conn->gsc) { |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
1050 purple_ssl_close(conn->gsc); |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
1051 conn->gsc = NULL; |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
1052 } else { |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
1053 close(conn->fd); |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
1054 conn->fd = -1; |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
1055 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1056 flap_connection_schedule_destroy(conn, |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20589
diff
changeset
|
1057 OSCAR_DISCONNECT_LOST_CONNECTION, g_strerror(errno)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1058 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1059 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1060 |
15822 | 1061 purple_circ_buffer_mark_read(conn->buffer_outgoing, ret); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1062 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1063 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1064 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1065 flap_connection_send_byte_stream(ByteStream *bs, FlapConnection *conn, size_t count) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1066 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1067 if (conn == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1068 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1069 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1070 /* Make sure we don't send past the end of the bs */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1071 if (count > byte_stream_empty(bs)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1072 count = byte_stream_empty(bs); /* truncate to remaining space */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1073 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1074 if (count == 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1075 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1076 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1077 /* Add everything to our outgoing buffer */ |
15822 | 1078 purple_circ_buffer_append(conn->buffer_outgoing, bs->data, count); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1079 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1080 /* If we haven't already started writing stuff, then start the cycle */ |
25211
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
1081 if (conn->watcher_outgoing == 0) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1082 { |
25211
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
1083 if (conn->gsc) { |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
1084 conn->watcher_outgoing = purple_input_add(conn->gsc->fd, |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
1085 PURPLE_INPUT_WRITE, send_cb, conn); |
25381
f6ef3a9534db
Shuffle a few comments around to make it look like I did something
Mark Doliner <mark@kingant.net>
parents:
25213
diff
changeset
|
1086 send_cb(conn, -1, 0); |
25211
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
1087 } else if (conn->fd >= 0) { |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
1088 conn->watcher_outgoing = purple_input_add(conn->fd, |
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
1089 PURPLE_INPUT_WRITE, send_cb, conn); |
25381
f6ef3a9534db
Shuffle a few comments around to make it look like I did something
Mark Doliner <mark@kingant.net>
parents:
25213
diff
changeset
|
1090 send_cb(conn, -1, 0); |
25211
ea70a446dde4
First pass at adding SSL connections to OSCAR.
Paul Aurich <paul@darkrain42.org>
parents:
24438
diff
changeset
|
1091 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1092 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1093 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1094 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1095 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1096 sendframe_flap(FlapConnection *conn, FlapFrame *frame) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1097 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1098 ByteStream bs; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1099 int payloadlen, bslen; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1100 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1101 payloadlen = byte_stream_curpos(&frame->data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1102 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1103 byte_stream_new(&bs, 6 + payloadlen); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1104 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1105 /* FLAP header */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1106 byte_stream_put8(&bs, 0x2a); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1107 byte_stream_put8(&bs, frame->channel); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1108 byte_stream_put16(&bs, frame->seqnum); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1109 byte_stream_put16(&bs, payloadlen); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1110 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1111 /* Payload */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1112 byte_stream_rewind(&frame->data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1113 byte_stream_putbs(&bs, &frame->data, payloadlen); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1114 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1115 bslen = byte_stream_curpos(&bs); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1116 byte_stream_rewind(&bs); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1117 flap_connection_send_byte_stream(&bs, conn, bslen); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1118 |
22718
da3de0190be2
Used byte_stream_destroy(), added in 2e791da1fb1cfd6b751a0cef01aa83dc89692051,
Evan Schoenberg <evan.s@dreskin.net>
parents:
22717
diff
changeset
|
1119 byte_stream_destroy(&bs); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1120 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1121 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1122 void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1123 flap_connection_send(FlapConnection *conn, FlapFrame *frame) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1124 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1125 frame->seqnum = ++(conn->seqnum_out); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1126 sendframe_flap(conn, frame); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1127 flap_frame_destroy(frame); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1128 } |