2 * Purple's oscar protocol plugin
3 * This file is the legal property of its developers.
4 * Please see the AUTHORS file distributed alongside this file.
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
23 typedef struct _SnacHandler SnacHandler
;
29 aim_rxcallback_t handler
;
34 * Allocates a new OscarData and initializes it with default values.
43 od
= g_new0(OscarData
, 1);
46 od
->snacid_next
= 0x00000001;
47 od
->buddyinfo
= g_hash_table_new_full(g_str_hash
, g_str_equal
, g_free
, g_free
);
48 od
->handlerlist
= g_hash_table_new_full(g_direct_hash
, g_direct_equal
, NULL
, g_free
);
51 * Register all the modules for this session...
53 aim__registermodule(od
, misc_modfirst
); /* load the catch-all first */
54 aim__registermodule(od
, service_modfirst
);
55 aim__registermodule(od
, locate_modfirst
);
56 aim__registermodule(od
, buddylist_modfirst
);
57 aim__registermodule(od
, msg_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
, chatnav_modfirst
);
64 aim__registermodule(od
, chat_modfirst
);
65 aim__registermodule(od
, bart_modfirst
);
66 /* missing 0x11 - 0x12 */
67 aim__registermodule(od
, ssi_modfirst
);
69 aim__registermodule(od
, icq_modfirst
);
71 /* auth_modfirst is only needed if we're connecting with the old-style BUCP login */
72 aim__registermodule(od
, auth_modfirst
);
73 aim__registermodule(od
, email_modfirst
);
75 msg
= g_string_new("Registered modules: ");
76 for (cur
= od
->modlistv
; cur
; cur
= cur
->next
) {
77 g_string_append_printf(
79 "%s (family=0x%04x, version=0x%04x, toolid=0x%04x, toolversion=0x%04x), ",
86 purple_debug_misc("oscar", "%s\n", msg
->str
);
87 g_string_free(msg
, TRUE
);
93 * Logoff and deallocate a session.
95 * @param od Session to kill
98 oscar_data_destroy(OscarData
*od
)
100 aim_cleansnacs(od
, -1);
102 /* Only used when connecting with clientLogin */
103 if (od
->url_data
!= NULL
)
104 purple_util_fetch_url_cancel(od
->url_data
);
106 while (od
->requesticon
)
108 g_free(od
->requesticon
->data
);
109 od
->requesticon
= g_slist_delete_link(od
->requesticon
, od
->requesticon
);
114 if (od
->getblisttimer
> 0)
115 purple_timeout_remove(od
->getblisttimer
);
116 while (od
->oscar_connections
!= NULL
)
117 flap_connection_destroy(od
->oscar_connections
->data
,
118 OSCAR_DISCONNECT_DONE
, NULL
);
120 while (od
->peer_connections
!= NULL
)
121 peer_connection_destroy(od
->peer_connections
->data
,
122 OSCAR_DISCONNECT_LOCAL_CLOSED
, NULL
);
124 aim__shutdownmodules(od
);
126 g_hash_table_destroy(od
->buddyinfo
);
127 g_hash_table_destroy(od
->handlerlist
);
133 oscar_data_addhandler(OscarData
*od
, guint16 family
, guint16 subtype
, aim_rxcallback_t newhandler
, guint16 flags
)
135 SnacHandler
*snac_handler
;
137 snac_handler
= g_new0(SnacHandler
, 1);
139 snac_handler
->family
= family
;
140 snac_handler
->subtype
= subtype
;
141 snac_handler
->flags
= flags
;
142 snac_handler
->handler
= newhandler
;
144 g_hash_table_insert(od
->handlerlist
,
145 GUINT_TO_POINTER((family
<< 16) + subtype
),
150 aim_callhandler(OscarData
*od
, guint16 family
, guint16 subtype
)
152 SnacHandler
*snac_handler
;
154 snac_handler
= g_hash_table_lookup(od
->handlerlist
, GUINT_TO_POINTER((family
<< 16) + subtype
));
156 return snac_handler
? snac_handler
->handler
: NULL
;