annotate src/protocols/oscar/conn.c @ 13259:3128ef5250ad

[gaim-migrate @ 15625] Fix good things thanks Bleeter committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sun, 12 Feb 2006 23:00:33 +0000
parents 7ead7b8aea63
children 2d5a1d2a520e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents: 12414
diff changeset
1 /*
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents: 12414
diff changeset
2 * Gaim's oscar protocol plugin
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents: 12414
diff changeset
3 * This file is the legal property of its developers.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents: 12414
diff changeset
4 * Please see the AUTHORS file distributed alongside this file.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents: 12414
diff changeset
5 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents: 12414
diff changeset
6 * This library is free software; you can redistribute it and/or
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents: 12414
diff changeset
7 * modify it under the terms of the GNU Lesser General Public
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents: 12414
diff changeset
8 * License as published by the Free Software Foundation; either
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents: 12414
diff changeset
9 * version 2 of the License, or (at your option) any later version.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents: 12414
diff changeset
10 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents: 12414
diff changeset
11 * This library is distributed in the hope that it will be useful,
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents: 12414
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents: 12414
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents: 12414
diff changeset
14 * Lesser General Public License for more details.
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents: 12414
diff changeset
15 *
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents: 12414
diff changeset
16 * You should have received a copy of the GNU Lesser General Public
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents: 12414
diff changeset
17 * License along with this library; if not, write to the Free Software
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents: 12414
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents: 12414
diff changeset
19 */
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents: 12414
diff changeset
20
8888
8592f296db16 [gaim-migrate @ 9657]
Mark Doliner <mark@kingant.net>
parents: 8880
diff changeset
21 /**
8880
ec3e041dc3bd [gaim-migrate @ 9649]
Mark Doliner <mark@kingant.net>
parents: 8866
diff changeset
22 * Low-level connection handling.
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24 * Does all this gloriously nifty connection handling stuff...
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26 */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27
13234
f2431a7e33aa [gaim-migrate @ 15600]
Mark Doliner <mark@kingant.net>
parents: 12414
diff changeset
28 #include "oscar.h"
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 #ifndef _WIN32
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31 #include <netdb.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 #include <sys/socket.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33 #include <netinet/in.h>
3717
988485669631 [gaim-migrate @ 3850]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3694
diff changeset
34 #endif
988485669631 [gaim-migrate @ 3850]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3694
diff changeset
35
988485669631 [gaim-migrate @ 3850]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3694
diff changeset
36 #ifdef _WIN32
988485669631 [gaim-migrate @ 3850]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3694
diff changeset
37 #include "win32dep.h"
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38 #endif
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39
8880
ec3e041dc3bd [gaim-migrate @ 9649]
Mark Doliner <mark@kingant.net>
parents: 8866
diff changeset
40 /**
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
41 * In OSCAR, every connection has a set of SNAC groups associated
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
42 * with it. These are the groups that you can send over this connection
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
43 * without being guaranteed a "Not supported" SNAC error.
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
44 *
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
45 * The grand theory of things says that these associations transcend
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
46 * what libfaim calls "connection types" (conn->type). You can probably
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
47 * see the elegance here, but since I want to revel in it for a bit, you
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
48 * get to hear it all spelled out.
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
49 *
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
50 * So let us say that you have your core BOS connection running. One
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
51 * of your modules has just given you a SNAC of the group 0x0004 to send
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
52 * you. Maybe an IM destined for some twit in Greenland. So you start
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
53 * at the top of your connection list, looking for a connection that
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
54 * claims to support group 0x0004. You find one. Why, that neat BOS
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
55 * connection of yours can do that. So you send it on its way.
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
56 *
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
57 * Now, say, that fellow from Greenland has friends and they all want to
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
58 * meet up with you in a lame chat room. This has landed you a SNAC
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
59 * in the family 0x000e and you have to admit you're a bit lost. You've
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
60 * searched your connection list for someone who wants to make your life
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
61 * easy and deliver this SNAC for you, but there isn't one there.
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
62 *
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
63 * Here comes the good bit. Without even letting anyone know, particularly
8735
92cbf9713795 [gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents: 7474
diff changeset
64 * the module that decided to send this SNAC, and definitely not that twit
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
65 * in Greenland, you send out a service request. In this request, you have
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
66 * marked the need for a connection supporting group 0x000e. A few seconds
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
67 * later, you receive a service redirect with an IP address and a cookie in
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
68 * it. Great, you say. Now I have something to do. Off you go, making
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
69 * that connection. One of the first things you get from this new server
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
70 * is a message saying that indeed it does support the group you were looking
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
71 * for. So you continue and send rate confirmation and all that.
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
72 *
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
73 * Then you remember you had that SNAC to send, and now you have a means to
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
74 * do it, and you do, and everyone is happy. Except the Greenlander, who is
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
75 * still stuck in the bitter cold.
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
76 *
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
77 * Oh, and this is useful for building the Migration SNACs, too. In the
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
78 * future, this may help convince me to implement rate limit mitigation
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
79 * for real. We'll see.
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
80 *
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
81 * Just to make me look better, I'll say that I've known about this great
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
82 * scheme for quite some time now. But I still haven't convinced myself
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
83 * to make libfaim work that way. It would take a fair amount of effort,
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
84 * and probably some client API changes as well. (Whenever I don't want
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
85 * to do something, I just say it would change the client API. Then I
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
86 * instantly have a couple of supporters of not doing it.)
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
87 *
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
88 * Generally, addgroup is only called by the internal handling of the
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
89 * server ready SNAC. So if you want to do something before that, you'll
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
90 * have to be more creative. That is done rather early, though, so I don't
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
91 * think you have to worry about it. Unless you're me. I care deeply
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
92 * about such inane things.
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
93 *
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
94 */
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
95 void
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
96 aim_conn_addgroup(OscarConnection *conn, guint16 group)
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
97 {
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
98 aim_conn_inside_t *ins = (aim_conn_inside_t *)conn->inside;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
99 struct snacgroup *sg;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
100
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
101 sg = malloc(sizeof(struct snacgroup));
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
102
11253
7d31d61e6438 [gaim-migrate @ 13422]
Mark Doliner <mark@kingant.net>
parents: 11162
diff changeset
103 gaim_debug_misc("oscar", "adding group 0x%04x\n", group);
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
104 sg->group = group;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
105
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
106 sg->next = ins->groups;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
107 ins->groups = sg;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
108 }
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
109
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
110 OscarConnection *
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
111 aim_conn_findbygroup(OscarSession *sess, guint16 group)
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
112 {
13254
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
113 GList *cur;;
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
114
13254
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
115 for (cur = sess->oscar_connections; cur; cur = cur->next)
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
116 {
13254
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
117 OscarConnection *conn;
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
118 aim_conn_inside_t *ins;
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
119 struct snacgroup *sg;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
120
13254
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
121 conn = cur->data;
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
122 ins = (aim_conn_inside_t *)conn->inside;
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
123
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
124 for (sg = ins->groups; sg; sg = sg->next)
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
125 {
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
126 if (sg->group == group)
13254
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
127 return conn;
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
128 }
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
129 }
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
130
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
131 return NULL;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
132 }
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
133
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
134 static void
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
135 connkill_snacgroups(struct snacgroup *head)
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
136 {
2675
e759254b29bb [gaim-migrate @ 2688]
Adam Fritzler <mid@auk.cx>
parents: 2672
diff changeset
137 struct snacgroup *sg;
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
138
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
139 for (sg = head; sg; )
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
140 {
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
141 struct snacgroup *tmp;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
142
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
143 tmp = sg->next;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
144 free(sg);
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
145 sg = tmp;
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
146 }
2675
e759254b29bb [gaim-migrate @ 2688]
Adam Fritzler <mid@auk.cx>
parents: 2672
diff changeset
147 }
e759254b29bb [gaim-migrate @ 2688]
Adam Fritzler <mid@auk.cx>
parents: 2672
diff changeset
148
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
149 static void
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
150 connkill_rates(struct rateclass *head)
2675
e759254b29bb [gaim-migrate @ 2688]
Adam Fritzler <mid@auk.cx>
parents: 2672
diff changeset
151 {
e759254b29bb [gaim-migrate @ 2688]
Adam Fritzler <mid@auk.cx>
parents: 2672
diff changeset
152 struct rateclass *rc;
e759254b29bb [gaim-migrate @ 2688]
Adam Fritzler <mid@auk.cx>
parents: 2672
diff changeset
153
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
154 for (rc = head; rc; )
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
155 {
2675
e759254b29bb [gaim-migrate @ 2688]
Adam Fritzler <mid@auk.cx>
parents: 2672
diff changeset
156 struct rateclass *tmp;
2734
9fc65bb80596 [gaim-migrate @ 2747]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
157 struct snacpair *sp;
2675
e759254b29bb [gaim-migrate @ 2688]
Adam Fritzler <mid@auk.cx>
parents: 2672
diff changeset
158
e759254b29bb [gaim-migrate @ 2688]
Adam Fritzler <mid@auk.cx>
parents: 2672
diff changeset
159 tmp = rc->next;
2734
9fc65bb80596 [gaim-migrate @ 2747]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
160
9fc65bb80596 [gaim-migrate @ 2747]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
161 for (sp = rc->members; sp; ) {
9fc65bb80596 [gaim-migrate @ 2747]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
162 struct snacpair *tmpsp;
9fc65bb80596 [gaim-migrate @ 2747]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
163
9fc65bb80596 [gaim-migrate @ 2747]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
164 tmpsp = sp->next;
9fc65bb80596 [gaim-migrate @ 2747]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
165 free(sp);
9fc65bb80596 [gaim-migrate @ 2747]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
166 sp = tmpsp;
9fc65bb80596 [gaim-migrate @ 2747]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
167 }
2675
e759254b29bb [gaim-migrate @ 2688]
Adam Fritzler <mid@auk.cx>
parents: 2672
diff changeset
168 free(rc);
2734
9fc65bb80596 [gaim-migrate @ 2747]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2703
diff changeset
169
2675
e759254b29bb [gaim-migrate @ 2688]
Adam Fritzler <mid@auk.cx>
parents: 2672
diff changeset
170 rc = tmp;
e759254b29bb [gaim-migrate @ 2688]
Adam Fritzler <mid@auk.cx>
parents: 2672
diff changeset
171 }
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
172 }
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
173
13254
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
174 void
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
175 oscar_connection_destroy(OscarSession *sess, OscarConnection *conn)
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
176 {
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
177 aim_rxqueue_cleanbyconn(sess, conn);
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
178 aim_tx_cleanqueue(sess, conn);
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
179
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
180 if (conn->fd != -1)
13254
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
181 aim_conn_close(sess, conn);
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
182
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
183 /*
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
184 * This will free ->internal if it necessary...
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
185 */
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
186 if (conn->type == AIM_CONN_TYPE_CHAT)
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
187 aim_conn_kill_chat(sess, conn);
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
188
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
189 if (conn->inside)
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
190 {
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
191 aim_conn_inside_t *inside = (aim_conn_inside_t *)conn->inside;
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
192
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
193 connkill_snacgroups(inside->groups);
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
194 connkill_rates(inside->rates);
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
195
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
196 free(inside);
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
197 }
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
198
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
199 gaim_circ_buffer_destroy(conn->buffer_outgoing);
13254
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
200 g_free(conn);
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
201 }
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
202
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
203 /**
10271
361c9170d8af [gaim-migrate @ 11420]
Mark Doliner <mark@kingant.net>
parents: 10267
diff changeset
204 * This sends an empty channel 4 SNAC. This is sent to signify
361c9170d8af [gaim-migrate @ 11420]
Mark Doliner <mark@kingant.net>
parents: 10267
diff changeset
205 * that we're logging off. This shouldn't really be necessary--
361c9170d8af [gaim-migrate @ 11420]
Mark Doliner <mark@kingant.net>
parents: 10267
diff changeset
206 * usually the AIM server will detect that the TCP connection has
361c9170d8af [gaim-migrate @ 11420]
Mark Doliner <mark@kingant.net>
parents: 10267
diff changeset
207 * been destroyed.
361c9170d8af [gaim-migrate @ 11420]
Mark Doliner <mark@kingant.net>
parents: 10267
diff changeset
208 */
361c9170d8af [gaim-migrate @ 11420]
Mark Doliner <mark@kingant.net>
parents: 10267
diff changeset
209 static int
13239
f260d319bbbc [gaim-migrate @ 15605]
Mark Doliner <mark@kingant.net>
parents: 13234
diff changeset
210 aim_flap_close(OscarSession *sess, OscarConnection *conn)
10271
361c9170d8af [gaim-migrate @ 11420]
Mark Doliner <mark@kingant.net>
parents: 10267
diff changeset
211 {
13239
f260d319bbbc [gaim-migrate @ 15605]
Mark Doliner <mark@kingant.net>
parents: 13234
diff changeset
212 FlapFrame *fr;
10271
361c9170d8af [gaim-migrate @ 11420]
Mark Doliner <mark@kingant.net>
parents: 10267
diff changeset
213
361c9170d8af [gaim-migrate @ 11420]
Mark Doliner <mark@kingant.net>
parents: 10267
diff changeset
214 if (!sess || !conn)
361c9170d8af [gaim-migrate @ 11420]
Mark Doliner <mark@kingant.net>
parents: 10267
diff changeset
215 return -EINVAL;
361c9170d8af [gaim-migrate @ 11420]
Mark Doliner <mark@kingant.net>
parents: 10267
diff changeset
216
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
217 if (!(fr = flap_frame_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x04, 0)))
10271
361c9170d8af [gaim-migrate @ 11420]
Mark Doliner <mark@kingant.net>
parents: 10267
diff changeset
218 return -ENOMEM;
361c9170d8af [gaim-migrate @ 11420]
Mark Doliner <mark@kingant.net>
parents: 10267
diff changeset
219
361c9170d8af [gaim-migrate @ 11420]
Mark Doliner <mark@kingant.net>
parents: 10267
diff changeset
220 aim_tx_enqueue(sess, fr);
361c9170d8af [gaim-migrate @ 11420]
Mark Doliner <mark@kingant.net>
parents: 10267
diff changeset
221
361c9170d8af [gaim-migrate @ 11420]
Mark Doliner <mark@kingant.net>
parents: 10267
diff changeset
222 return 0;
361c9170d8af [gaim-migrate @ 11420]
Mark Doliner <mark@kingant.net>
parents: 10267
diff changeset
223 }
361c9170d8af [gaim-migrate @ 11420]
Mark Doliner <mark@kingant.net>
parents: 10267
diff changeset
224
361c9170d8af [gaim-migrate @ 11420]
Mark Doliner <mark@kingant.net>
parents: 10267
diff changeset
225 /**
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
226 * Allocate a new empty connection structure.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
227 *
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
228 * @param sess The oscar session associated with this connection.
8880
ec3e041dc3bd [gaim-migrate @ 9649]
Mark Doliner <mark@kingant.net>
parents: 8866
diff changeset
229 * @return Returns the new connection structure.
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
230 */
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
231 static OscarConnection *
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
232 aim_conn_getnext(OscarSession *sess)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
233 {
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
234 OscarConnection *conn;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
235
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
236 conn = g_new0(OscarConnection, 1);
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
237 conn->inside = g_new0(aim_conn_inside_t, 1);
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
238 conn->buffer_outgoing = gaim_circ_buffer_new(-1);
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
239 conn->fd = -1;
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
240 conn->subtype = -1;
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
241 conn->type = -1;
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
242 conn->seqnum = 0;
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
243 conn->lastactivity = 0;
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
244 conn->handlerlist = NULL;
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
245
13254
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
246 sess->oscar_connections = g_list_prepend(sess->oscar_connections, conn);
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
247
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
248 return conn;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
249 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
250
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
251 /**
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
252 * Close, clear, and free a connection structure. Should never be
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
253 * called from within libfaim.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
254 *
8880
ec3e041dc3bd [gaim-migrate @ 9649]
Mark Doliner <mark@kingant.net>
parents: 8866
diff changeset
255 * @param sess Session for the connection.
ec3e041dc3bd [gaim-migrate @ 9649]
Mark Doliner <mark@kingant.net>
parents: 8866
diff changeset
256 * @param deadconn Connection to be freed.
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
257 */
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
258 void
13254
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
259 aim_conn_kill(OscarSession *sess, OscarConnection *conn)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
260 {
13254
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
261 if (!conn)
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
262 return;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
263
13254
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
264 sess->oscar_connections = g_list_remove(sess->oscar_connections, conn);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
265
13254
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
266 oscar_connection_destroy(sess, conn);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
267 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
268
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
269 /**
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
270 * Close (but not free) a connection.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
271 *
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
272 * This leaves everything untouched except for clearing the
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
273 * handler list and setting the fd to -1 (used to recognize
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
274 * dead connections). It will also remove cookies if necessary.
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
275 *
13254
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
276 * @param conn The connection to close.
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
277 */
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
278 void
13254
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
279 aim_conn_close(OscarSession *sess, OscarConnection *conn)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
280 {
13254
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
281 if (conn->type == AIM_CONN_TYPE_BOS)
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
282 aim_flap_close(sess, conn);
5435
a2f26666de42 [gaim-migrate @ 5817]
Mark Doliner <mark@kingant.net>
parents: 5124
diff changeset
283
13254
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
284 if (conn->fd >= 0)
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
285 close(conn->fd);
5435
a2f26666de42 [gaim-migrate @ 5817]
Mark Doliner <mark@kingant.net>
parents: 5124
diff changeset
286
13254
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
287 conn->fd = -1;
5435
a2f26666de42 [gaim-migrate @ 5817]
Mark Doliner <mark@kingant.net>
parents: 5124
diff changeset
288
13254
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
289 if (conn->handlerlist)
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
290 aim_clearhandlers(conn);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
291 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
292
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
293 /**
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
294 * Locates a connection of the specified type in the
8866
c2dff943e240 [gaim-migrate @ 9634]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
295 * specified session.
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
296 *
8880
ec3e041dc3bd [gaim-migrate @ 9649]
Mark Doliner <mark@kingant.net>
parents: 8866
diff changeset
297 * XXX - Except for rendezvous, all uses of this should be removed and
ec3e041dc3bd [gaim-migrate @ 9649]
Mark Doliner <mark@kingant.net>
parents: 8866
diff changeset
298 * aim_conn_findbygroup() should be used instead.
8866
c2dff943e240 [gaim-migrate @ 9634]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
299 *
8880
ec3e041dc3bd [gaim-migrate @ 9649]
Mark Doliner <mark@kingant.net>
parents: 8866
diff changeset
300 * @param sess The session to search.
ec3e041dc3bd [gaim-migrate @ 9649]
Mark Doliner <mark@kingant.net>
parents: 8866
diff changeset
301 * @param type The type of connection to look for.
ec3e041dc3bd [gaim-migrate @ 9649]
Mark Doliner <mark@kingant.net>
parents: 8866
diff changeset
302 * @return Returns the first connection found of the given target type,
ec3e041dc3bd [gaim-migrate @ 9649]
Mark Doliner <mark@kingant.net>
parents: 8866
diff changeset
303 * or NULL if none could be found.
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
304 */
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
305 OscarConnection *
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
306 aim_getconn_type(OscarSession *sess, int type)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
307 {
13254
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
308 GList *cur;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
309
13254
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
310 for (cur = sess->oscar_connections; cur; cur = cur->next)
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
311 {
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
312 OscarConnection *conn;
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
313 conn = cur->data;
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
314 if ((conn->type == type) &&
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
315 !(conn->status & AIM_CONN_STATUS_INPROGRESS))
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
316 return conn;
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
317 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
318
13254
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
319 return NULL;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
320 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
321
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
322 OscarConnection *
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
323 aim_getconn_type_all(OscarSession *sess, int type)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
324 {
13254
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
325 GList *cur;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
326
13254
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
327 for (cur = sess->oscar_connections; cur; cur = cur->next)
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
328 {
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
329 OscarConnection *conn;
13259
3128ef5250ad [gaim-migrate @ 15625]
Mark Doliner <mark@kingant.net>
parents: 13256
diff changeset
330 conn = cur->data;
13254
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
331 if (conn->type == type)
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
332 return conn;
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
333 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
334
13254
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
335 return NULL;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
336 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
337
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
338 /**
13239
f260d319bbbc [gaim-migrate @ 15605]
Mark Doliner <mark@kingant.net>
parents: 13234
diff changeset
339 * Clone an OscarConnection.
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
340 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
341 * A new connection is allocated, and the values are filled in
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
342 * appropriately.
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
343 *
8880
ec3e041dc3bd [gaim-migrate @ 9649]
Mark Doliner <mark@kingant.net>
parents: 8866
diff changeset
344 * @param sess The session containing this connection.
ec3e041dc3bd [gaim-migrate @ 9649]
Mark Doliner <mark@kingant.net>
parents: 8866
diff changeset
345 * @param src The connection to clone.
13239
f260d319bbbc [gaim-migrate @ 15605]
Mark Doliner <mark@kingant.net>
parents: 13234
diff changeset
346 * @return Returns a pointer to the new OscarConnection, or %NULL on error.
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
347 */
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
348 OscarConnection *
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
349 aim_cloneconn(OscarSession *sess, OscarConnection *src)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
350 {
13239
f260d319bbbc [gaim-migrate @ 15605]
Mark Doliner <mark@kingant.net>
parents: 13234
diff changeset
351 OscarConnection *conn;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
352
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
353 if (!(conn = aim_conn_getnext(sess)))
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
354 return NULL;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
355
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
356 conn->fd = src->fd;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
357 conn->type = src->type;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
358 conn->subtype = src->subtype;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
359 conn->seqnum = src->seqnum;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
360 conn->internal = src->internal;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
361 conn->lastactivity = src->lastactivity;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
362 conn->sessv = src->sessv;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
363 aim_clonehandlers(sess, conn, src);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
364
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
365 if (src->inside) {
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
366 /*
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
367 * XXX should clone this section as well, but since currently
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
368 * this function only gets called for some of that rendezvous
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
369 * crap, and not on SNAC connections, its probably okay for
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
370 * now.
2270
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
371 *
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
372 */
d82efea341ef [gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2246
diff changeset
373 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
374
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
375 return conn;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
376 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
377
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
378 /**
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
379 * Opens a new connection to the specified dest host of specified
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
380 * type, using the proxy settings if available. If @host is %NULL,
11162
ccb38cf22483 [gaim-migrate @ 13263]
Mark Doliner <mark@kingant.net>
parents: 11154
diff changeset
381 * the connection is allocated and returned, but no connection
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
382 * is made.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
383 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
384 * FIXME: Return errors in a more sane way.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
385 *
8866
c2dff943e240 [gaim-migrate @ 9634]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
386 * @param sess Session to create connection in
c2dff943e240 [gaim-migrate @ 9634]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
387 * @param type Type of connection to create
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
388 */
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
389 OscarConnection *
13254
e9802db22b06 [gaim-migrate @ 15620]
Mark Doliner <mark@kingant.net>
parents: 13253
diff changeset
390 oscar_connection_new(OscarSession *sess, int type)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
391 {
13239
f260d319bbbc [gaim-migrate @ 15605]
Mark Doliner <mark@kingant.net>
parents: 13234
diff changeset
392 OscarConnection *conn;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
393
11162
ccb38cf22483 [gaim-migrate @ 13263]
Mark Doliner <mark@kingant.net>
parents: 11154
diff changeset
394 if (!(conn = aim_conn_getnext(sess)))
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
395 return NULL;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
396
11162
ccb38cf22483 [gaim-migrate @ 13263]
Mark Doliner <mark@kingant.net>
parents: 11154
diff changeset
397 conn->sessv = (void *)sess;
ccb38cf22483 [gaim-migrate @ 13263]
Mark Doliner <mark@kingant.net>
parents: 11154
diff changeset
398 conn->type = type;
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
399
11162
ccb38cf22483 [gaim-migrate @ 13263]
Mark Doliner <mark@kingant.net>
parents: 11154
diff changeset
400 conn->fd = -1;
ccb38cf22483 [gaim-migrate @ 13263]
Mark Doliner <mark@kingant.net>
parents: 11154
diff changeset
401 conn->status = 0;
ccb38cf22483 [gaim-migrate @ 13263]
Mark Doliner <mark@kingant.net>
parents: 11154
diff changeset
402 return conn;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
403 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
404
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
405 /**
8880
ec3e041dc3bd [gaim-migrate @ 9649]
Mark Doliner <mark@kingant.net>
parents: 8866
diff changeset
406 * Determine if a connection is connecting.
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
407 *
8880
ec3e041dc3bd [gaim-migrate @ 9649]
Mark Doliner <mark@kingant.net>
parents: 8866
diff changeset
408 * @param conn Connection to examine.
8866
c2dff943e240 [gaim-migrate @ 9634]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
409 * @return Returns nonzero if the connection is in the process of
c2dff943e240 [gaim-migrate @ 9634]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
410 * connecting (or if it just completed and
c2dff943e240 [gaim-migrate @ 9634]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
411 * aim_conn_completeconnect() has yet to be called on it).
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
412 */
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
413 int
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
414 aim_conn_isconnecting(OscarConnection *conn)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
415 {
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
416
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
417 if (!conn)
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
418 return 0;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
419
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
420 return !!(conn->status & AIM_CONN_STATUS_INPROGRESS);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
421 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
422
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
423 /*
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
424 * XXX this is nearly as ugly as proxyconnect().
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
425 */
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
426 int
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
427 aim_conn_completeconnect(OscarSession *sess, OscarConnection *conn)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
428 {
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
429 if (!conn || (conn->fd == -1))
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
430 return -1;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
431
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
432 if (!(conn->status & AIM_CONN_STATUS_INPROGRESS))
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
433 return -1;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
434
5124
2e78141ec1b5 [gaim-migrate @ 5487]
Mark Doliner <mark@kingant.net>
parents: 4830
diff changeset
435 fcntl(conn->fd, F_SETFL, 0);
2e78141ec1b5 [gaim-migrate @ 5487]
Mark Doliner <mark@kingant.net>
parents: 4830
diff changeset
436
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
437 conn->status &= ~AIM_CONN_STATUS_INPROGRESS;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
438
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
439 /* Flush out the queues if there was something waiting for this conn */
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
440 aim_tx_flushqueue(sess);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
441
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
442 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
443 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
444
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
445 OscarSession *
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
446 aim_conn_getsess(OscarConnection *conn)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
447 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
448
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
449 if (!conn)
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
450 return NULL;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
451
13239
f260d319bbbc [gaim-migrate @ 15605]
Mark Doliner <mark@kingant.net>
parents: 13234
diff changeset
452 return (OscarSession *)conn->sessv;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
453 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
454
8880
ec3e041dc3bd [gaim-migrate @ 9649]
Mark Doliner <mark@kingant.net>
parents: 8866
diff changeset
455 /**
ec3e041dc3bd [gaim-migrate @ 9649]
Mark Doliner <mark@kingant.net>
parents: 8866
diff changeset
456 * No-op. This sends an empty channel 5 SNAC. WinAIM 4.x and higher
ec3e041dc3bd [gaim-migrate @ 9649]
Mark Doliner <mark@kingant.net>
parents: 8866
diff changeset
457 * sends these _every minute_ to keep the connection alive.
2703
441b84ab7f4e [gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2675
diff changeset
458 */
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
459 int
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
460 aim_flap_nop(OscarSession *sess, OscarConnection *conn)
2703
441b84ab7f4e [gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2675
diff changeset
461 {
13239
f260d319bbbc [gaim-migrate @ 15605]
Mark Doliner <mark@kingant.net>
parents: 13234
diff changeset
462 FlapFrame *fr;
2703
441b84ab7f4e [gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2675
diff changeset
463
13253
87a7c3077c19 [gaim-migrate @ 15619]
Mark Doliner <mark@kingant.net>
parents: 13252
diff changeset
464 if (!(fr = flap_frame_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x05, 0)))
2703
441b84ab7f4e [gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2675
diff changeset
465 return -ENOMEM;
441b84ab7f4e [gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2675
diff changeset
466
441b84ab7f4e [gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2675
diff changeset
467 aim_tx_enqueue(sess, fr);
441b84ab7f4e [gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2675
diff changeset
468
7283
b8fcbff88438 [gaim-migrate @ 7863]
Mark Doliner <mark@kingant.net>
parents: 7282
diff changeset
469 /* clean out SNACs over 60sec old */
b8fcbff88438 [gaim-migrate @ 7863]
Mark Doliner <mark@kingant.net>
parents: 7282
diff changeset
470 aim_cleansnacs(sess, 60);
b8fcbff88438 [gaim-migrate @ 7863]
Mark Doliner <mark@kingant.net>
parents: 7282
diff changeset
471
2703
441b84ab7f4e [gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2675
diff changeset
472 return 0;
441b84ab7f4e [gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2675
diff changeset
473 }