Mercurial > pidgin
comparison libpurple/protocols/oscar/oscar_data.c @ 15373:5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Sat, 20 Jan 2007 02:32:10 +0000 |
parents | |
children | 32c366eeeb99 |
comparison
equal
deleted
inserted
replaced
15372:f79e0f4df793 | 15373:5fe8042783c1 |
---|---|
1 /* | |
2 * Gaim's oscar protocol plugin | |
3 * This file is the legal property of its developers. | |
4 * Please see the AUTHORS file distributed alongside this file. | |
5 * | |
6 * This library is free software; you can redistribute it and/or | |
7 * modify it under the terms of the GNU Lesser General Public | |
8 * License as published by the Free Software Foundation; either | |
9 * version 2 of the License, or (at your option) any later version. | |
10 * | |
11 * This library is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 * Lesser General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU Lesser General Public | |
17 * License along with this library; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 */ | |
20 | |
21 #include "oscar.h" | |
22 | |
23 typedef struct _SnacHandler SnacHandler; | |
24 | |
25 struct _SnacHandler | |
26 { | |
27 guint16 family; | |
28 guint16 subtype; | |
29 aim_rxcallback_t handler; | |
30 guint16 flags; | |
31 }; | |
32 | |
33 /** | |
34 * Allocates a new OscarData and initializes it with default values. | |
35 */ | |
36 OscarData * | |
37 oscar_data_new(void) | |
38 { | |
39 OscarData *od; | |
40 | |
41 od = g_new0(OscarData, 1); | |
42 | |
43 aim_initsnachash(od); | |
44 od->snacid_next = 0x00000001; | |
45 od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | |
46 od->handlerlist = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_free); | |
47 | |
48 /* | |
49 * Register all the modules for this session... | |
50 */ | |
51 aim__registermodule(od, misc_modfirst); /* load the catch-all first */ | |
52 aim__registermodule(od, service_modfirst); | |
53 aim__registermodule(od, locate_modfirst); | |
54 aim__registermodule(od, buddylist_modfirst); | |
55 aim__registermodule(od, msg_modfirst); | |
56 aim__registermodule(od, adverts_modfirst); | |
57 aim__registermodule(od, invite_modfirst); | |
58 aim__registermodule(od, admin_modfirst); | |
59 aim__registermodule(od, popups_modfirst); | |
60 aim__registermodule(od, bos_modfirst); | |
61 aim__registermodule(od, search_modfirst); | |
62 aim__registermodule(od, stats_modfirst); | |
63 aim__registermodule(od, translate_modfirst); | |
64 aim__registermodule(od, chatnav_modfirst); | |
65 aim__registermodule(od, chat_modfirst); | |
66 aim__registermodule(od, odir_modfirst); | |
67 aim__registermodule(od, bart_modfirst); | |
68 /* missing 0x11 - 0x12 */ | |
69 aim__registermodule(od, ssi_modfirst); | |
70 /* missing 0x14 */ | |
71 aim__registermodule(od, icq_modfirst); | |
72 /* missing 0x16 */ | |
73 aim__registermodule(od, auth_modfirst); | |
74 aim__registermodule(od, email_modfirst); | |
75 | |
76 return od; | |
77 } | |
78 | |
79 /** | |
80 * Logoff and deallocate a session. | |
81 * | |
82 * @param od Session to kill | |
83 */ | |
84 void | |
85 oscar_data_destroy(OscarData *od) | |
86 { | |
87 aim_cleansnacs(od, -1); | |
88 | |
89 while (od->requesticon) | |
90 { | |
91 gchar *sn = od->requesticon->data; | |
92 od->requesticon = g_slist_remove(od->requesticon, sn); | |
93 g_free(sn); | |
94 } | |
95 g_free(od->email); | |
96 g_free(od->newp); | |
97 g_free(od->oldp); | |
98 if (od->icontimer > 0) | |
99 gaim_timeout_remove(od->icontimer); | |
100 if (od->getblisttimer > 0) | |
101 gaim_timeout_remove(od->getblisttimer); | |
102 if (od->getinfotimer > 0) | |
103 gaim_timeout_remove(od->getinfotimer); | |
104 while (od->oscar_connections != NULL) | |
105 flap_connection_destroy(od->oscar_connections->data, | |
106 OSCAR_DISCONNECT_DONE, NULL); | |
107 | |
108 while (od->peer_connections != NULL) | |
109 peer_connection_destroy(od->peer_connections->data, | |
110 OSCAR_DISCONNECT_LOCAL_CLOSED, NULL); | |
111 | |
112 aim__shutdownmodules(od); | |
113 | |
114 g_hash_table_destroy(od->buddyinfo); | |
115 g_hash_table_destroy(od->handlerlist); | |
116 | |
117 g_free(od); | |
118 } | |
119 | |
120 void | |
121 oscar_data_addhandler(OscarData *od, guint16 family, guint16 subtype, aim_rxcallback_t newhandler, guint16 flags) | |
122 { | |
123 SnacHandler *snac_handler; | |
124 | |
125 gaim_debug_misc("oscar", "Adding handler for %04x/%04x\n", family, subtype); | |
126 | |
127 snac_handler = g_new0(SnacHandler, 1); | |
128 | |
129 snac_handler->family = family; | |
130 snac_handler->subtype = subtype; | |
131 snac_handler->flags = flags; | |
132 snac_handler->handler = newhandler; | |
133 | |
134 g_hash_table_insert(od->handlerlist, | |
135 GUINT_TO_POINTER((family << 16) + subtype), | |
136 snac_handler); | |
137 } | |
138 | |
139 aim_rxcallback_t | |
140 aim_callhandler(OscarData *od, guint16 family, guint16 subtype) | |
141 { | |
142 SnacHandler *snac_handler; | |
143 | |
144 snac_handler = g_hash_table_lookup(od->handlerlist, GUINT_TO_POINTER((family << 16) + subtype)); | |
145 | |
146 return snac_handler ? snac_handler->handler : NULL; | |
147 } |