[5ebff60] | 1 | /********************************************************************\ |
---|
[b7d3cc34] | 2 | * BitlBee -- An IRC to other IM-networks gateway * |
---|
| 3 | * * |
---|
[0e788f5] | 4 | * Copyright 2002-2012 Wilmer van der Gaast and others * |
---|
[b7d3cc34] | 5 | \********************************************************************/ |
---|
| 6 | |
---|
| 7 | /* |
---|
| 8 | * nogaim |
---|
| 9 | * |
---|
| 10 | * Gaim without gaim - for BitlBee |
---|
| 11 | * |
---|
| 12 | * This file contains functions called by the Gaim IM-modules. It's written |
---|
| 13 | * from scratch for BitlBee and doesn't contain any code from Gaim anymore |
---|
| 14 | * (except for the function names). |
---|
| 15 | */ |
---|
| 16 | |
---|
| 17 | /* |
---|
| 18 | This program is free software; you can redistribute it and/or modify |
---|
| 19 | it under the terms of the GNU General Public License as published by |
---|
| 20 | the Free Software Foundation; either version 2 of the License, or |
---|
| 21 | (at your option) any later version. |
---|
| 22 | |
---|
| 23 | This program is distributed in the hope that it will be useful, |
---|
| 24 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 25 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 26 | GNU General Public License for more details. |
---|
| 27 | |
---|
| 28 | You should have received a copy of the GNU General Public License with |
---|
| 29 | the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL; |
---|
[6f10697] | 30 | if not, write to the Free Software Foundation, Inc., 51 Franklin St., |
---|
| 31 | Fifth Floor, Boston, MA 02110-1301 USA |
---|
[b7d3cc34] | 32 | */ |
---|
| 33 | |
---|
| 34 | #define BITLBEE_CORE |
---|
| 35 | #include <ctype.h> |
---|
| 36 | |
---|
[4cf80bb] | 37 | #include "nogaim.h" |
---|
| 38 | |
---|
[b7d3cc34] | 39 | GSList *connections; |
---|
| 40 | |
---|
[65e2ce1] | 41 | #ifdef WITH_PLUGINS |
---|
[d28fe1c4] | 42 | GList *plugins = NULL; |
---|
| 43 | |
---|
| 44 | static gint pluginscmp(gconstpointer a, gconstpointer b, gpointer data) |
---|
| 45 | { |
---|
| 46 | const struct plugin_info *ia = a; |
---|
| 47 | const struct plugin_info *ib = b; |
---|
| 48 | |
---|
| 49 | return g_strcasecmp(ia->name, ib->name); |
---|
| 50 | } |
---|
| 51 | |
---|
[7486853] | 52 | /* semi-private */ |
---|
| 53 | gboolean plugin_info_validate(struct plugin_info *info, const char *path) |
---|
[7b23afd] | 54 | { |
---|
[d28fe1c4] | 55 | GList *l; |
---|
[7486853] | 56 | gboolean loaded = FALSE; |
---|
| 57 | |
---|
| 58 | if (!path) { |
---|
| 59 | path = "(null)"; |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | if (info->abiver != BITLBEE_ABI_VERSION_CODE) { |
---|
| 63 | log_message(LOGLVL_ERROR, |
---|
| 64 | "`%s' uses ABI %u but %u is required\n", |
---|
| 65 | path, info->abiver, |
---|
| 66 | BITLBEE_ABI_VERSION_CODE); |
---|
| 67 | return FALSE; |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | if (!info->name || !info->version) { |
---|
| 71 | log_message(LOGLVL_ERROR, |
---|
| 72 | "Name or version missing from the " |
---|
| 73 | "plugin info in `%s'\n", path); |
---|
| 74 | return FALSE; |
---|
| 75 | } |
---|
| 76 | |
---|
| 77 | for (l = plugins; l; l = l->next) { |
---|
| 78 | struct plugin_info *i = l->data; |
---|
| 79 | |
---|
| 80 | if (g_strcasecmp(i->name, info->name) == 0) { |
---|
| 81 | loaded = TRUE; |
---|
| 82 | break; |
---|
| 83 | } |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | if (loaded) { |
---|
| 87 | log_message(LOGLVL_WARNING, |
---|
| 88 | "%s plugin already loaded\n", |
---|
| 89 | info->name); |
---|
| 90 | return FALSE; |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | return TRUE; |
---|
| 94 | } |
---|
| 95 | |
---|
| 96 | /* semi-private */ |
---|
| 97 | gboolean plugin_info_add(struct plugin_info *info) |
---|
| 98 | { |
---|
| 99 | plugins = g_list_insert_sorted_with_data(plugins, info, pluginscmp, NULL); |
---|
| 100 | return TRUE; |
---|
| 101 | } |
---|
| 102 | |
---|
| 103 | gboolean load_plugin(char *path) |
---|
| 104 | { |
---|
[0483e1e] | 105 | struct plugin_info *info = NULL; |
---|
[d28fe1c4] | 106 | struct plugin_info * (*info_function) (void) = NULL; |
---|
[7b23afd] | 107 | void (*init_function) (void); |
---|
[5ebff60] | 108 | |
---|
[7b23afd] | 109 | GModule *mod = g_module_open(path, G_MODULE_BIND_LAZY); |
---|
| 110 | |
---|
[5ebff60] | 111 | if (!mod) { |
---|
[4fe91a1] | 112 | log_message(LOGLVL_ERROR, "Error loading plugin `%s': %s\n", path, g_module_error()); |
---|
[7b23afd] | 113 | return FALSE; |
---|
| 114 | } |
---|
| 115 | |
---|
[d28fe1c4] | 116 | if (g_module_symbol(mod, "init_plugin_info", (gpointer *) &info_function)) { |
---|
| 117 | info = info_function(); |
---|
| 118 | |
---|
[7486853] | 119 | if (!plugin_info_validate(info, path)) { |
---|
[d28fe1c4] | 120 | g_module_close(mod); |
---|
| 121 | return FALSE; |
---|
| 122 | } |
---|
| 123 | } else { |
---|
| 124 | log_message(LOGLVL_WARNING, "Can't find function `init_plugin_info' in `%s'\n", path); |
---|
| 125 | } |
---|
| 126 | |
---|
[5ebff60] | 127 | if (!g_module_symbol(mod, "init_plugin", (gpointer *) &init_function)) { |
---|
[7b23afd] | 128 | log_message(LOGLVL_WARNING, "Can't find function `init_plugin' in `%s'\n", path); |
---|
[d28fe1c4] | 129 | g_module_close(mod); |
---|
[7b23afd] | 130 | return FALSE; |
---|
| 131 | } |
---|
| 132 | |
---|
[d28fe1c4] | 133 | if (info_function) { |
---|
[7486853] | 134 | plugin_info_add(info); |
---|
[d28fe1c4] | 135 | } |
---|
[7b23afd] | 136 | |
---|
[d28fe1c4] | 137 | init_function(); |
---|
[7b23afd] | 138 | return TRUE; |
---|
| 139 | } |
---|
[b7d3cc34] | 140 | |
---|
[65e2ce1] | 141 | void load_plugins(void) |
---|
| 142 | { |
---|
| 143 | GDir *dir; |
---|
| 144 | GError *error = NULL; |
---|
| 145 | |
---|
[4bfca70] | 146 | dir = g_dir_open(global.conf->plugindir, 0, &error); |
---|
[65e2ce1] | 147 | |
---|
| 148 | if (dir) { |
---|
| 149 | const gchar *entry; |
---|
| 150 | char *path; |
---|
| 151 | |
---|
| 152 | while ((entry = g_dir_read_name(dir))) { |
---|
[35712b7] | 153 | if (!g_str_has_suffix(entry, "." G_MODULE_SUFFIX)) { |
---|
| 154 | continue; |
---|
| 155 | } |
---|
| 156 | |
---|
[4bfca70] | 157 | path = g_build_filename(global.conf->plugindir, entry, NULL); |
---|
[5ebff60] | 158 | if (!path) { |
---|
[65e2ce1] | 159 | log_message(LOGLVL_WARNING, "Can't build path for %s\n", entry); |
---|
| 160 | continue; |
---|
| 161 | } |
---|
| 162 | |
---|
| 163 | load_plugin(path); |
---|
| 164 | |
---|
| 165 | g_free(path); |
---|
| 166 | } |
---|
| 167 | |
---|
| 168 | g_dir_close(dir); |
---|
| 169 | } |
---|
| 170 | } |
---|
[d28fe1c4] | 171 | |
---|
| 172 | GList *get_plugins() |
---|
| 173 | { |
---|
| 174 | return plugins; |
---|
| 175 | } |
---|
[65e2ce1] | 176 | #endif |
---|
[b7d3cc34] | 177 | |
---|
[7b23afd] | 178 | GList *protocols = NULL; |
---|
[ad9ac5d] | 179 | GList *disabled_protocols = NULL; |
---|
[5ebff60] | 180 | |
---|
| 181 | void register_protocol(struct prpl *p) |
---|
[7b23afd] | 182 | { |
---|
[90cd6c4] | 183 | int i; |
---|
| 184 | gboolean refused = global.conf->protocols != NULL; |
---|
[5ebff60] | 185 | |
---|
| 186 | for (i = 0; global.conf->protocols && global.conf->protocols[i]; i++) { |
---|
| 187 | if (g_strcasecmp(p->name, global.conf->protocols[i]) == 0) { |
---|
[90cd6c4] | 188 | refused = FALSE; |
---|
[5ebff60] | 189 | } |
---|
| 190 | } |
---|
[90cd6c4] | 191 | |
---|
[5ebff60] | 192 | if (refused) { |
---|
[ad9ac5d] | 193 | disabled_protocols = g_list_append(disabled_protocols, p); |
---|
[5ebff60] | 194 | } else { |
---|
[90cd6c4] | 195 | protocols = g_list_append(protocols, p); |
---|
[5ebff60] | 196 | } |
---|
[7b23afd] | 197 | } |
---|
| 198 | |
---|
[ad9ac5d] | 199 | static int proto_name_cmp(const void *proto_, const void *name) |
---|
[7b23afd] | 200 | { |
---|
[ad9ac5d] | 201 | const struct prpl *proto = proto_; |
---|
| 202 | return g_strcasecmp(proto->name, name); |
---|
| 203 | } |
---|
[5ebff60] | 204 | |
---|
[ad9ac5d] | 205 | struct prpl *find_protocol(const char *name) |
---|
| 206 | { |
---|
| 207 | GList *gl = g_list_find_custom(protocols, name, proto_name_cmp); |
---|
| 208 | return gl ? gl->data: NULL; |
---|
| 209 | } |
---|
[5ebff60] | 210 | |
---|
[ad9ac5d] | 211 | gboolean is_protocol_disabled(const char *name) |
---|
| 212 | { |
---|
| 213 | return g_list_find_custom(disabled_protocols, name, proto_name_cmp) != NULL; |
---|
[7b23afd] | 214 | } |
---|
| 215 | |
---|
[b4f496e] | 216 | /* Returns heap allocated string with text attempting to explain why a protocol is missing |
---|
| 217 | * Free the return value with g_free() */ |
---|
| 218 | char *explain_unknown_protocol(const char *name) |
---|
| 219 | { |
---|
| 220 | char *extramsg = NULL; |
---|
| 221 | |
---|
| 222 | if (is_protocol_disabled(name)) { |
---|
| 223 | return g_strdup("Protocol disabled in the global config (bitlbee.conf)"); |
---|
| 224 | } |
---|
| 225 | |
---|
| 226 | if (strcmp(name, "yahoo") == 0) { |
---|
| 227 | return g_strdup("The old yahoo protocol is gone, try the funyahoo++ libpurple plugin instead."); |
---|
| 228 | } |
---|
| 229 | |
---|
| 230 | #ifdef WITH_PURPLE |
---|
| 231 | if ((strcmp(name, "msn") == 0) || |
---|
| 232 | (strcmp(name, "loubserp-mxit") == 0) || |
---|
| 233 | (strcmp(name, "myspace") == 0)) { |
---|
| 234 | return g_strdup("This protocol has been removed from your libpurple version."); |
---|
| 235 | } |
---|
| 236 | |
---|
| 237 | if (strcmp(name, "hipchat") == 0) { |
---|
| 238 | return g_strdup("This account type isn't supported by libpurple's jabber."); |
---|
| 239 | } |
---|
| 240 | |
---|
| 241 | #else |
---|
| 242 | if (strcmp(name, "aim") == 0 || strcmp(name, "icq") == 0) { |
---|
| 243 | return g_strdup("This account uses libpurple specific aliases for oscar. " |
---|
| 244 | "Re-add the account with `account add oscar ...'"); |
---|
| 245 | } |
---|
| 246 | |
---|
| 247 | extramsg = "If this is a libpurple plugin, you might need to install bitlbee-libpurple instead."; |
---|
| 248 | #endif |
---|
| 249 | return g_strconcat("The protocol plugin is not installed or could not be loaded. " |
---|
| 250 | "Use the `plugins' command to list available protocols. ", |
---|
| 251 | extramsg, NULL); |
---|
| 252 | } |
---|
| 253 | |
---|
[b7d3cc34] | 254 | void nogaim_init() |
---|
| 255 | { |
---|
[0da65d5] | 256 | extern void oscar_initmodule(); |
---|
| 257 | extern void jabber_initmodule(); |
---|
[1b221e0] | 258 | extern void twitter_initmodule(); |
---|
[796da03] | 259 | extern void purple_initmodule(); |
---|
[7b23afd] | 260 | |
---|
[b7d3cc34] | 261 | #ifdef WITH_OSCAR |
---|
[0da65d5] | 262 | oscar_initmodule(); |
---|
[b7d3cc34] | 263 | #endif |
---|
[5ebff60] | 264 | |
---|
[b7d3cc34] | 265 | #ifdef WITH_JABBER |
---|
[0da65d5] | 266 | jabber_initmodule(); |
---|
[b7d3cc34] | 267 | #endif |
---|
[7b23afd] | 268 | |
---|
[1b221e0] | 269 | #ifdef WITH_TWITTER |
---|
| 270 | twitter_initmodule(); |
---|
| 271 | #endif |
---|
| 272 | |
---|
[796da03] | 273 | #ifdef WITH_PURPLE |
---|
| 274 | purple_initmodule(); |
---|
| 275 | #endif |
---|
[7b23afd] | 276 | |
---|
[65e2ce1] | 277 | #ifdef WITH_PLUGINS |
---|
| 278 | load_plugins(); |
---|
[b7d3cc34] | 279 | #endif |
---|
| 280 | } |
---|
| 281 | |
---|
[808825e] | 282 | GList *get_protocols() |
---|
| 283 | { |
---|
| 284 | return protocols; |
---|
| 285 | } |
---|
| 286 | |
---|
| 287 | GList *get_protocols_disabled() |
---|
| 288 | { |
---|
| 289 | return disabled_protocols; |
---|
| 290 | } |
---|
| 291 | |
---|
[5ebff60] | 292 | GSList *get_connections() |
---|
| 293 | { |
---|
| 294 | return connections; |
---|
| 295 | } |
---|
[b7d3cc34] | 296 | |
---|
[5ebff60] | 297 | struct im_connection *imcb_new(account_t *acc) |
---|
[b7d3cc34] | 298 | { |
---|
[0da65d5] | 299 | struct im_connection *ic; |
---|
[5ebff60] | 300 | |
---|
| 301 | ic = g_new0(struct im_connection, 1); |
---|
| 302 | |
---|
[81e04e1] | 303 | ic->bee = acc->bee; |
---|
[0da65d5] | 304 | ic->acc = acc; |
---|
| 305 | acc->ic = ic; |
---|
[5ebff60] | 306 | |
---|
| 307 | connections = g_slist_append(connections, ic); |
---|
| 308 | |
---|
| 309 | return(ic); |
---|
[b7d3cc34] | 310 | } |
---|
| 311 | |
---|
[5ebff60] | 312 | void imc_free(struct im_connection *ic) |
---|
[b7d3cc34] | 313 | { |
---|
| 314 | account_t *a; |
---|
[5ebff60] | 315 | |
---|
[b7d3cc34] | 316 | /* Destroy the pointer to this connection from the account list */ |
---|
[5ebff60] | 317 | for (a = ic->bee->accounts; a; a = a->next) { |
---|
| 318 | if (a->ic == ic) { |
---|
[0da65d5] | 319 | a->ic = NULL; |
---|
[b7d3cc34] | 320 | break; |
---|
| 321 | } |
---|
[5ebff60] | 322 | } |
---|
| 323 | |
---|
| 324 | connections = g_slist_remove(connections, ic); |
---|
| 325 | g_free(ic); |
---|
[b7d3cc34] | 326 | } |
---|
| 327 | |
---|
[5ebff60] | 328 | static void serv_got_crap(struct im_connection *ic, char *format, ...) |
---|
[b7d3cc34] | 329 | { |
---|
| 330 | va_list params; |
---|
[e27661d] | 331 | char *text; |
---|
[dfde8e0] | 332 | account_t *a; |
---|
[5ebff60] | 333 | |
---|
[03df717] | 334 | if (!ic->bee->ui->log) { |
---|
| 335 | return; |
---|
| 336 | } |
---|
| 337 | |
---|
[5ebff60] | 338 | va_start(params, format); |
---|
| 339 | text = g_strdup_vprintf(format, params); |
---|
| 340 | va_end(params); |
---|
| 341 | |
---|
| 342 | if ((g_strcasecmp(set_getstr(&ic->bee->set, "strip_html"), "always") == 0) || |
---|
| 343 | ((ic->flags & OPT_DOES_HTML) && set_getbool(&ic->bee->set, "strip_html"))) { |
---|
| 344 | strip_html(text); |
---|
| 345 | } |
---|
| 346 | |
---|
[dfde8e0] | 347 | /* Try to find a different connection on the same protocol. */ |
---|
[5ebff60] | 348 | for (a = ic->bee->accounts; a; a = a->next) { |
---|
| 349 | if (a->prpl == ic->acc->prpl && a->ic != ic) { |
---|
[dfde8e0] | 350 | break; |
---|
[5ebff60] | 351 | } |
---|
| 352 | } |
---|
| 353 | |
---|
[e27661d] | 354 | /* If we found one, include the screenname in the message. */ |
---|
[5ebff60] | 355 | if (a) { |
---|
[03df717] | 356 | ic->bee->ui->log(ic->bee, ic->acc->tag, text); |
---|
[5ebff60] | 357 | } else { |
---|
[03df717] | 358 | ic->bee->ui->log(ic->bee, ic->acc->prpl->name, text); |
---|
[5ebff60] | 359 | } |
---|
| 360 | |
---|
| 361 | g_free(text); |
---|
[b7d3cc34] | 362 | } |
---|
| 363 | |
---|
[5ebff60] | 364 | void imcb_log(struct im_connection *ic, char *format, ...) |
---|
[aef4828] | 365 | { |
---|
| 366 | va_list params; |
---|
| 367 | char *text; |
---|
[5ebff60] | 368 | |
---|
| 369 | va_start(params, format); |
---|
| 370 | text = g_strdup_vprintf(format, params); |
---|
| 371 | va_end(params); |
---|
| 372 | |
---|
| 373 | if (ic->flags & OPT_LOGGED_IN) { |
---|
| 374 | serv_got_crap(ic, "%s", text); |
---|
| 375 | } else { |
---|
| 376 | serv_got_crap(ic, "Logging in: %s", text); |
---|
| 377 | } |
---|
| 378 | |
---|
| 379 | g_free(text); |
---|
[aef4828] | 380 | } |
---|
| 381 | |
---|
[5ebff60] | 382 | void imcb_error(struct im_connection *ic, char *format, ...) |
---|
[aef4828] | 383 | { |
---|
| 384 | va_list params; |
---|
| 385 | char *text; |
---|
[5ebff60] | 386 | |
---|
| 387 | va_start(params, format); |
---|
| 388 | text = g_strdup_vprintf(format, params); |
---|
| 389 | va_end(params); |
---|
| 390 | |
---|
| 391 | if (ic->flags & OPT_LOGGED_IN) { |
---|
| 392 | serv_got_crap(ic, "Error: %s", text); |
---|
| 393 | } else { |
---|
| 394 | serv_got_crap(ic, "Login error: %s", text); |
---|
| 395 | } |
---|
| 396 | |
---|
| 397 | g_free(text); |
---|
[aef4828] | 398 | } |
---|
| 399 | |
---|
[5ebff60] | 400 | static gboolean send_keepalive(gpointer d, gint fd, b_input_condition cond) |
---|
[b7d3cc34] | 401 | { |
---|
[0da65d5] | 402 | struct im_connection *ic = d; |
---|
[5ebff60] | 403 | |
---|
| 404 | if ((ic->flags & OPT_PONGS) && !(ic->flags & OPT_PONGED)) { |
---|
[e132b60] | 405 | /* This protocol is expected to ack keepalives and hasn't |
---|
| 406 | since the last time we were here. */ |
---|
[5ebff60] | 407 | imcb_error(ic, "Connection timeout"); |
---|
| 408 | imc_logout(ic, TRUE); |
---|
[e132b60] | 409 | return FALSE; |
---|
| 410 | } |
---|
| 411 | ic->flags &= ~OPT_PONGED; |
---|
[5ebff60] | 412 | |
---|
| 413 | if (ic->acc->prpl->keepalive) { |
---|
| 414 | ic->acc->prpl->keepalive(ic); |
---|
| 415 | } |
---|
| 416 | |
---|
[b7d3cc34] | 417 | return TRUE; |
---|
| 418 | } |
---|
| 419 | |
---|
[5ebff60] | 420 | void start_keepalives(struct im_connection *ic, int interval) |
---|
[e132b60] | 421 | { |
---|
[5ebff60] | 422 | b_event_remove(ic->keepalive); |
---|
| 423 | ic->keepalive = b_timeout_add(interval, send_keepalive, ic); |
---|
| 424 | |
---|
[e132b60] | 425 | /* Connecting successfully counts as a first successful pong. */ |
---|
[5ebff60] | 426 | if (ic->flags & OPT_PONGS) { |
---|
[e132b60] | 427 | ic->flags |= OPT_PONGED; |
---|
[5ebff60] | 428 | } |
---|
[e132b60] | 429 | } |
---|
| 430 | |
---|
[5ebff60] | 431 | void imcb_connected(struct im_connection *ic) |
---|
[b7d3cc34] | 432 | { |
---|
| 433 | /* MSN servers sometimes redirect you to a different server and do |
---|
[84c1a0a] | 434 | the whole login sequence again, so these "late" calls to this |
---|
[b7d3cc34] | 435 | function should be handled correctly. (IOW, ignored) */ |
---|
[5ebff60] | 436 | if (ic->flags & OPT_LOGGED_IN) { |
---|
[b7d3cc34] | 437 | return; |
---|
[5ebff60] | 438 | } |
---|
[11e7828] | 439 | |
---|
[5ebff60] | 440 | if (ic->acc->flags & ACC_FLAG_LOCAL) { |
---|
[11e7828] | 441 | GHashTableIter nicks; |
---|
| 442 | gpointer k, v; |
---|
[5ebff60] | 443 | g_hash_table_iter_init(&nicks, ic->acc->nicks); |
---|
| 444 | while (g_hash_table_iter_next(&nicks, &k, &v)) { |
---|
| 445 | ic->acc->prpl->add_buddy(ic, (char *) k, NULL); |
---|
[11e7828] | 446 | } |
---|
| 447 | } |
---|
[5ebff60] | 448 | |
---|
| 449 | imcb_log(ic, "Logged in"); |
---|
| 450 | |
---|
[0da65d5] | 451 | ic->flags |= OPT_LOGGED_IN; |
---|
[5ebff60] | 452 | start_keepalives(ic, 60000); |
---|
| 453 | |
---|
[58adb7e] | 454 | /* Necessary to send initial presence status, even if we're not away. */ |
---|
[5ebff60] | 455 | imc_away_send_update(ic); |
---|
| 456 | |
---|
[280e655] | 457 | /* Apparently we're connected successfully, so reset the |
---|
| 458 | exponential backoff timer. */ |
---|
| 459 | ic->acc->auto_reconnect_delay = 0; |
---|
[5ebff60] | 460 | |
---|
| 461 | if (ic->bee->ui->imc_connected) { |
---|
| 462 | ic->bee->ui->imc_connected(ic); |
---|
| 463 | } |
---|
[b7d3cc34] | 464 | } |
---|
| 465 | |
---|
[5ebff60] | 466 | gboolean auto_reconnect(gpointer data, gint fd, b_input_condition cond) |
---|
[b7d3cc34] | 467 | { |
---|
| 468 | account_t *a = data; |
---|
[5ebff60] | 469 | |
---|
[b7d3cc34] | 470 | a->reconnect = 0; |
---|
[5ebff60] | 471 | account_on(a->bee, a); |
---|
| 472 | |
---|
| 473 | return(FALSE); /* Only have to run the timeout once */ |
---|
[b7d3cc34] | 474 | } |
---|
| 475 | |
---|
[5ebff60] | 476 | void cancel_auto_reconnect(account_t *a) |
---|
[b7d3cc34] | 477 | { |
---|
[5ebff60] | 478 | b_event_remove(a->reconnect); |
---|
[b7d3cc34] | 479 | a->reconnect = 0; |
---|
| 480 | } |
---|
| 481 | |
---|
[5ebff60] | 482 | void imc_logout(struct im_connection *ic, int allow_reconnect) |
---|
[b7d3cc34] | 483 | { |
---|
[81e04e1] | 484 | bee_t *bee = ic->bee; |
---|
[b7d3cc34] | 485 | account_t *a; |
---|
[81e04e1] | 486 | GSList *l; |
---|
[4230221] | 487 | int delay; |
---|
[5ebff60] | 488 | |
---|
[8d74291] | 489 | /* Nested calls might happen sometimes, this is probably the best |
---|
| 490 | place to catch them. */ |
---|
[5ebff60] | 491 | if (ic->flags & OPT_LOGGING_OUT) { |
---|
[8d74291] | 492 | return; |
---|
[5ebff60] | 493 | } else { |
---|
[0da65d5] | 494 | ic->flags |= OPT_LOGGING_OUT; |
---|
[5ebff60] | 495 | } |
---|
| 496 | |
---|
| 497 | if (ic->bee->ui->imc_disconnected) { |
---|
| 498 | ic->bee->ui->imc_disconnected(ic); |
---|
| 499 | } |
---|
| 500 | |
---|
| 501 | imcb_log(ic, "Signing off.."); |
---|
| 502 | |
---|
[0dd6570] | 503 | /* TBH I don't remember anymore why I didn't just use ic->acc... */ |
---|
[5ebff60] | 504 | for (a = bee->accounts; a; a = a->next) { |
---|
| 505 | if (a->ic == ic) { |
---|
[0dd6570] | 506 | break; |
---|
[5ebff60] | 507 | } |
---|
| 508 | } |
---|
| 509 | |
---|
| 510 | if (a && !allow_reconnect && !(ic->flags & OPT_LOGGED_IN) && |
---|
| 511 | set_getbool(&a->set, "oauth")) { |
---|
[0dd6570] | 512 | /* If this account supports OAuth, we're not logged in yet and |
---|
| 513 | not allowed to retry, assume there were auth issues. Give a |
---|
| 514 | helpful message on what might be necessary to fix this. */ |
---|
[5ebff60] | 515 | imcb_log(ic, "If you're having problems logging in, try re-requesting " |
---|
| 516 | "an OAuth token: account %s set password \"\"", a->tag); |
---|
[0dd6570] | 517 | } |
---|
[5ebff60] | 518 | |
---|
| 519 | for (l = bee->users; l; ) { |
---|
[81e04e1] | 520 | bee_user_t *bu = l->data; |
---|
[eabc9d2] | 521 | GSList *next = l->next; |
---|
[5ebff60] | 522 | |
---|
| 523 | if (bu->ic == ic) { |
---|
| 524 | bee_user_free(bee, bu); |
---|
| 525 | } |
---|
| 526 | |
---|
[eabc9d2] | 527 | l = next; |
---|
[b7d3cc34] | 528 | } |
---|
[5ebff60] | 529 | |
---|
| 530 | b_event_remove(ic->keepalive); |
---|
[be7a180] | 531 | ic->keepalive = 0; |
---|
[5ebff60] | 532 | ic->acc->prpl->logout(ic); |
---|
| 533 | b_event_remove(ic->inpa); |
---|
| 534 | |
---|
| 535 | g_free(ic->away); |
---|
[be7a180] | 536 | ic->away = NULL; |
---|
[5ebff60] | 537 | |
---|
| 538 | query_del_by_conn((irc_t *) ic->bee->ui_data, ic); |
---|
| 539 | |
---|
| 540 | if (!a) { |
---|
[b7d3cc34] | 541 | /* Uhm... This is very sick. */ |
---|
[5ebff60] | 542 | } else if (allow_reconnect && set_getbool(&bee->set, "auto_reconnect") && |
---|
| 543 | set_getbool(&a->set, "auto_reconnect") && |
---|
| 544 | (delay = account_reconnect_delay(a)) > 0) { |
---|
| 545 | imcb_log(ic, "Reconnecting in %d seconds..", delay); |
---|
| 546 | a->reconnect = b_timeout_add(delay * 1000, auto_reconnect, a); |
---|
[b7d3cc34] | 547 | } |
---|
[5ebff60] | 548 | |
---|
| 549 | imc_free(ic); |
---|
[b7d3cc34] | 550 | } |
---|
| 551 | |
---|
[5ebff60] | 552 | void imcb_ask(struct im_connection *ic, char *msg, void *data, |
---|
| 553 | query_callback doit, query_callback dont) |
---|
[b7d3cc34] | 554 | { |
---|
[5ebff60] | 555 | query_add((irc_t *) ic->bee->ui_data, ic, msg, doit, dont, g_free, data); |
---|
[b7d3cc34] | 556 | } |
---|
| 557 | |
---|
[5ebff60] | 558 | void imcb_ask_with_free(struct im_connection *ic, char *msg, void *data, |
---|
| 559 | query_callback doit, query_callback dont, query_callback myfree) |
---|
[d0527c1] | 560 | { |
---|
[5ebff60] | 561 | query_add((irc_t *) ic->bee->ui_data, ic, msg, doit, dont, myfree, data); |
---|
[d0527c1] | 562 | } |
---|
| 563 | |
---|
[5ebff60] | 564 | void imcb_add_buddy(struct im_connection *ic, const char *handle, const char *group) |
---|
[b7d3cc34] | 565 | { |
---|
[81e04e1] | 566 | bee_user_t *bu; |
---|
| 567 | bee_t *bee = ic->bee; |
---|
[8b61469] | 568 | bee_group_t *oldg; |
---|
[5ebff60] | 569 | |
---|
| 570 | if (!(bu = bee_user_by_handle(bee, ic, handle))) { |
---|
| 571 | bu = bee_user_new(bee, ic, handle, 0); |
---|
| 572 | } |
---|
| 573 | |
---|
[8b61469] | 574 | oldg = bu->group; |
---|
[5ebff60] | 575 | bu->group = bee_group_by_name(bee, group, TRUE); |
---|
| 576 | |
---|
| 577 | if (bee->ui->user_group && bu->group != oldg) { |
---|
| 578 | bee->ui->user_group(bee, bu); |
---|
| 579 | } |
---|
[b7d3cc34] | 580 | } |
---|
| 581 | |
---|
[5ebff60] | 582 | void imcb_rename_buddy(struct im_connection *ic, const char *handle, const char *fullname) |
---|
[b7d3cc34] | 583 | { |
---|
[1d39159] | 584 | bee_t *bee = ic->bee; |
---|
[5ebff60] | 585 | bee_user_t *bu = bee_user_by_handle(bee, ic, handle); |
---|
| 586 | |
---|
| 587 | if (!bu || !fullname) { |
---|
| 588 | return; |
---|
| 589 | } |
---|
| 590 | |
---|
| 591 | if (!bu->fullname || strcmp(bu->fullname, fullname) != 0) { |
---|
| 592 | g_free(bu->fullname); |
---|
| 593 | bu->fullname = g_strdup(fullname); |
---|
| 594 | |
---|
| 595 | if (bee->ui->user_fullname) { |
---|
| 596 | bee->ui->user_fullname(bee, bu); |
---|
| 597 | } |
---|
[b7d3cc34] | 598 | } |
---|
| 599 | } |
---|
| 600 | |
---|
[5ebff60] | 601 | void imcb_remove_buddy(struct im_connection *ic, const char *handle, char *group) |
---|
[998b103] | 602 | { |
---|
[5ebff60] | 603 | bee_user_free(ic->bee, bee_user_by_handle(ic->bee, ic, handle)); |
---|
[998b103] | 604 | } |
---|
| 605 | |
---|
[a42fda4] | 606 | /* Implements either imcb_buddy_nick_hint() or imcb_buddy_nick_change() depending on the value of 'change' */ |
---|
| 607 | static void buddy_nick_hint_or_change(struct im_connection *ic, const char *handle, const char *nick, gboolean change) |
---|
[d06eabf] | 608 | { |
---|
[6ef9065] | 609 | bee_t *bee = ic->bee; |
---|
[5ebff60] | 610 | bee_user_t *bu = bee_user_by_handle(bee, ic, handle); |
---|
| 611 | |
---|
| 612 | if (!bu || !nick) { |
---|
| 613 | return; |
---|
| 614 | } |
---|
| 615 | |
---|
| 616 | g_free(bu->nick); |
---|
| 617 | bu->nick = g_strdup(nick); |
---|
| 618 | |
---|
[a42fda4] | 619 | if (change && bee->ui->user_nick_change) { |
---|
| 620 | bee->ui->user_nick_change(bee, bu, nick); |
---|
| 621 | } else if (!change && bee->ui->user_nick_hint) { |
---|
[5ebff60] | 622 | bee->ui->user_nick_hint(bee, bu, nick); |
---|
| 623 | } |
---|
[d06eabf] | 624 | } |
---|
[b7d3cc34] | 625 | |
---|
[a42fda4] | 626 | /* Soft variant, for newly created users. Does nothing if it's already online */ |
---|
| 627 | void imcb_buddy_nick_hint(struct im_connection *ic, const char *handle, const char *nick) |
---|
| 628 | { |
---|
| 629 | buddy_nick_hint_or_change(ic, handle, nick, FALSE); |
---|
| 630 | } |
---|
| 631 | |
---|
| 632 | /* Hard variant, always changes the nick */ |
---|
| 633 | void imcb_buddy_nick_change(struct im_connection *ic, const char *handle, const char *nick) |
---|
| 634 | { |
---|
| 635 | buddy_nick_hint_or_change(ic, handle, nick, TRUE); |
---|
| 636 | } |
---|
[b7d3cc34] | 637 | |
---|
[5ebff60] | 638 | struct imcb_ask_cb_data { |
---|
[0da65d5] | 639 | struct im_connection *ic; |
---|
[7bf0f5f0] | 640 | char *handle; |
---|
| 641 | }; |
---|
| 642 | |
---|
[098a75b] | 643 | static void imcb_ask_cb_free(void *data) |
---|
| 644 | { |
---|
| 645 | struct imcb_ask_cb_data *cbd = data; |
---|
| 646 | |
---|
| 647 | g_free(cbd->handle); |
---|
| 648 | g_free(cbd); |
---|
| 649 | } |
---|
| 650 | |
---|
[5ebff60] | 651 | static void imcb_ask_auth_cb_no(void *data) |
---|
[7bf0f5f0] | 652 | { |
---|
[fa295e36] | 653 | struct imcb_ask_cb_data *cbd = data; |
---|
[5ebff60] | 654 | |
---|
| 655 | cbd->ic->acc->prpl->auth_deny(cbd->ic, cbd->handle); |
---|
| 656 | |
---|
[098a75b] | 657 | imcb_ask_cb_free(cbd); |
---|
[fa295e36] | 658 | } |
---|
| 659 | |
---|
[5ebff60] | 660 | static void imcb_ask_auth_cb_yes(void *data) |
---|
[fa295e36] | 661 | { |
---|
| 662 | struct imcb_ask_cb_data *cbd = data; |
---|
[5ebff60] | 663 | |
---|
| 664 | cbd->ic->acc->prpl->auth_allow(cbd->ic, cbd->handle); |
---|
| 665 | |
---|
[098a75b] | 666 | imcb_ask_cb_free(cbd); |
---|
[fa295e36] | 667 | } |
---|
| 668 | |
---|
[5ebff60] | 669 | void imcb_ask_auth(struct im_connection *ic, const char *handle, const char *realname) |
---|
[fa295e36] | 670 | { |
---|
[5ebff60] | 671 | struct imcb_ask_cb_data *data = g_new0(struct imcb_ask_cb_data, 1); |
---|
[fa295e36] | 672 | char *s, *realname_ = NULL; |
---|
[5ebff60] | 673 | |
---|
| 674 | if (realname != NULL) { |
---|
| 675 | realname_ = g_strdup_printf(" (%s)", realname); |
---|
| 676 | } |
---|
| 677 | |
---|
| 678 | s = g_strdup_printf("The user %s%s wants to add you to his/her buddy list.", |
---|
| 679 | handle, realname_ ? realname_ : ""); |
---|
| 680 | |
---|
| 681 | g_free(realname_); |
---|
| 682 | |
---|
[fa295e36] | 683 | data->ic = ic; |
---|
[5ebff60] | 684 | data->handle = g_strdup(handle); |
---|
| 685 | query_add((irc_t *) ic->bee->ui_data, ic, s, |
---|
[098a75b] | 686 | imcb_ask_auth_cb_yes, imcb_ask_auth_cb_no, imcb_ask_cb_free, data); |
---|
[fa295e36] | 687 | |
---|
[098a75b] | 688 | g_free(s); |
---|
[7bf0f5f0] | 689 | } |
---|
| 690 | |
---|
[5ebff60] | 691 | static void imcb_ask_add_cb_yes(void *data) |
---|
[7bf0f5f0] | 692 | { |
---|
[fa295e36] | 693 | struct imcb_ask_cb_data *cbd = data; |
---|
[5ebff60] | 694 | |
---|
| 695 | cbd->ic->acc->prpl->add_buddy(cbd->ic, cbd->handle, NULL); |
---|
| 696 | |
---|
[098a75b] | 697 | imcb_ask_cb_free(data); |
---|
[7bf0f5f0] | 698 | } |
---|
| 699 | |
---|
[5ebff60] | 700 | void imcb_ask_add(struct im_connection *ic, const char *handle, const char *realname) |
---|
[b7d3cc34] | 701 | { |
---|
[098a75b] | 702 | struct imcb_ask_cb_data *data; |
---|
[7bf0f5f0] | 703 | char *s; |
---|
[5ebff60] | 704 | |
---|
[7bf0f5f0] | 705 | /* TODO: Make a setting for this! */ |
---|
[5ebff60] | 706 | if (bee_user_by_handle(ic->bee, ic, handle) != NULL) { |
---|
[7bf0f5f0] | 707 | return; |
---|
[5ebff60] | 708 | } |
---|
| 709 | |
---|
[098a75b] | 710 | data = g_new0(struct imcb_ask_cb_data, 1); |
---|
| 711 | |
---|
[5ebff60] | 712 | s = g_strdup_printf("The user %s is not in your buddy list yet. Do you want to add him/her now?", handle); |
---|
| 713 | |
---|
[0da65d5] | 714 | data->ic = ic; |
---|
[5ebff60] | 715 | data->handle = g_strdup(handle); |
---|
| 716 | query_add((irc_t *) ic->bee->ui_data, ic, s, |
---|
[098a75b] | 717 | imcb_ask_add_cb_yes, imcb_ask_cb_free, imcb_ask_cb_free, data); |
---|
| 718 | |
---|
| 719 | g_free(s); |
---|
[b7d3cc34] | 720 | } |
---|
| 721 | |
---|
[5ebff60] | 722 | struct bee_user *imcb_buddy_by_handle(struct im_connection *ic, const char *handle) |
---|
[81e04e1] | 723 | { |
---|
[5ebff60] | 724 | return bee_user_by_handle(ic->bee, ic, handle); |
---|
[b7d3cc34] | 725 | } |
---|
| 726 | |
---|
[226fce1] | 727 | /* The plan is to not allow straight calls to prpl functions anymore, but do |
---|
| 728 | them all from some wrappers. We'll start to define some down here: */ |
---|
| 729 | |
---|
[5ebff60] | 730 | int imc_chat_msg(struct groupchat *c, char *msg, int flags) |
---|
[b7d3cc34] | 731 | { |
---|
[e27661d] | 732 | char *buf = NULL; |
---|
[5ebff60] | 733 | |
---|
| 734 | if ((c->ic->flags & OPT_DOES_HTML) && (g_strncasecmp(msg, "<html>", 6) != 0)) { |
---|
| 735 | buf = escape_html(msg); |
---|
[b7d3cc34] | 736 | msg = buf; |
---|
| 737 | } |
---|
[5ebff60] | 738 | |
---|
| 739 | c->ic->acc->prpl->chat_msg(c, msg, flags); |
---|
| 740 | g_free(buf); |
---|
| 741 | |
---|
[0da65d5] | 742 | return 1; |
---|
[b7d3cc34] | 743 | } |
---|
[226fce1] | 744 | |
---|
[5ebff60] | 745 | static char *imc_away_state_find(GList *gcm, char *away, char **message); |
---|
[226fce1] | 746 | |
---|
[5ebff60] | 747 | int imc_away_send_update(struct im_connection *ic) |
---|
[226fce1] | 748 | { |
---|
[3e1ef92c] | 749 | char *away, *msg = NULL; |
---|
[5ebff60] | 750 | |
---|
| 751 | if (ic->acc->prpl->away_states == NULL || |
---|
| 752 | ic->acc->prpl->set_away == NULL) { |
---|
[91cec2f] | 753 | return 0; |
---|
[58adb7e] | 754 | } |
---|
[5ebff60] | 755 | |
---|
| 756 | away = set_getstr(&ic->acc->set, "away") ? |
---|
| 757 | : set_getstr(&ic->bee->set, "away"); |
---|
| 758 | if (away && *away) { |
---|
[977a9d5] | 759 | GList *m = ic->acc->prpl->away_states(ic); |
---|
[ff468a7] | 760 | if (m == NULL) { |
---|
| 761 | return 0; |
---|
| 762 | } |
---|
[5ebff60] | 763 | msg = ic->acc->flags & ACC_FLAG_AWAY_MESSAGE ? away : NULL; |
---|
[ac68733a] | 764 | away = imc_away_state_find(m, away, &msg) ? : |
---|
[eb73d05] | 765 | (imc_away_state_find(m, "away", NULL) ? : m->data); |
---|
[5ebff60] | 766 | } else if (ic->acc->flags & ACC_FLAG_STATUS_MESSAGE) { |
---|
[58adb7e] | 767 | away = NULL; |
---|
[5ebff60] | 768 | msg = set_getstr(&ic->acc->set, "status") ? |
---|
| 769 | : set_getstr(&ic->bee->set, "status"); |
---|
[226fce1] | 770 | } |
---|
[5ebff60] | 771 | |
---|
| 772 | ic->acc->prpl->set_away(ic, away, msg); |
---|
| 773 | |
---|
[34fbbf9] | 774 | return 1; |
---|
[226fce1] | 775 | } |
---|
| 776 | |
---|
[84b045d] | 777 | static char *imc_away_alias_list[8][5] = |
---|
[226fce1] | 778 | { |
---|
| 779 | { "Away from computer", "Away", "Extended away", NULL }, |
---|
| 780 | { "NA", "N/A", "Not available", NULL }, |
---|
| 781 | { "Busy", "Do not disturb", "DND", "Occupied", NULL }, |
---|
| 782 | { "Be right back", "BRB", NULL }, |
---|
| 783 | { "On the phone", "Phone", "On phone", NULL }, |
---|
| 784 | { "Out to lunch", "Lunch", "Food", NULL }, |
---|
| 785 | { "Invisible", "Hidden" }, |
---|
| 786 | { NULL } |
---|
| 787 | }; |
---|
| 788 | |
---|
[5ebff60] | 789 | static char *imc_away_state_find(GList *gcm, char *away, char **message) |
---|
[226fce1] | 790 | { |
---|
| 791 | GList *m; |
---|
| 792 | int i, j; |
---|
[5ebff60] | 793 | |
---|
| 794 | for (m = gcm; m; m = m->next) { |
---|
| 795 | if (g_strncasecmp(m->data, away, strlen(m->data)) == 0) { |
---|
[34fbbf9] | 796 | /* At least the Yahoo! module works better if message |
---|
| 797 | contains no data unless it adds something to what |
---|
| 798 | we have in state already. */ |
---|
[eb73d05] | 799 | if (message && strlen(m->data) == strlen(away)) { |
---|
[34fbbf9] | 800 | *message = NULL; |
---|
[5ebff60] | 801 | } |
---|
| 802 | |
---|
[34fbbf9] | 803 | return m->data; |
---|
| 804 | } |
---|
[5ebff60] | 805 | } |
---|
| 806 | |
---|
| 807 | for (i = 0; *imc_away_alias_list[i]; i++) { |
---|
[34fbbf9] | 808 | int keep_message; |
---|
[5ebff60] | 809 | |
---|
| 810 | for (j = 0; imc_away_alias_list[i][j]; j++) { |
---|
| 811 | if (g_strncasecmp(away, imc_away_alias_list[i][j], strlen(imc_away_alias_list[i][j])) == 0) { |
---|
| 812 | keep_message = strlen(away) != strlen(imc_away_alias_list[i][j]); |
---|
[226fce1] | 813 | break; |
---|
[34fbbf9] | 814 | } |
---|
[5ebff60] | 815 | } |
---|
| 816 | |
---|
| 817 | if (!imc_away_alias_list[i][j]) { /* If we reach the end, this row */ |
---|
| 818 | continue; /* is not what we want. Next! */ |
---|
| 819 | |
---|
| 820 | } |
---|
[226fce1] | 821 | /* Now find an entry in this row which exists in gcm */ |
---|
[5ebff60] | 822 | for (j = 0; imc_away_alias_list[i][j]; j++) { |
---|
| 823 | for (m = gcm; m; m = m->next) { |
---|
| 824 | if (g_strcasecmp(imc_away_alias_list[i][j], m->data) == 0) { |
---|
[eb73d05] | 825 | if (!keep_message && message) { |
---|
[34fbbf9] | 826 | *message = NULL; |
---|
[5ebff60] | 827 | } |
---|
| 828 | |
---|
[34fbbf9] | 829 | return imc_away_alias_list[i][j]; |
---|
| 830 | } |
---|
[5ebff60] | 831 | } |
---|
[226fce1] | 832 | } |
---|
[5ebff60] | 833 | |
---|
[34fbbf9] | 834 | /* No need to look further, apparently this state doesn't |
---|
| 835 | have any good alias for this protocol. */ |
---|
| 836 | break; |
---|
[226fce1] | 837 | } |
---|
[5ebff60] | 838 | |
---|
[34fbbf9] | 839 | return NULL; |
---|
[226fce1] | 840 | } |
---|
[da3b536] | 841 | |
---|
[5ebff60] | 842 | void imc_add_allow(struct im_connection *ic, char *handle) |
---|
[da3b536] | 843 | { |
---|
[5ebff60] | 844 | if (g_slist_find_custom(ic->permit, handle, (GCompareFunc) ic->acc->prpl->handle_cmp) == NULL) { |
---|
| 845 | ic->permit = g_slist_prepend(ic->permit, g_strdup(handle)); |
---|
[da3b536] | 846 | } |
---|
[5ebff60] | 847 | |
---|
| 848 | ic->acc->prpl->add_permit(ic, handle); |
---|
[da3b536] | 849 | } |
---|
| 850 | |
---|
[5ebff60] | 851 | void imc_rem_allow(struct im_connection *ic, char *handle) |
---|
[da3b536] | 852 | { |
---|
| 853 | GSList *l; |
---|
[5ebff60] | 854 | |
---|
| 855 | if ((l = g_slist_find_custom(ic->permit, handle, (GCompareFunc) ic->acc->prpl->handle_cmp))) { |
---|
| 856 | g_free(l->data); |
---|
| 857 | ic->permit = g_slist_delete_link(ic->permit, l); |
---|
[da3b536] | 858 | } |
---|
[5ebff60] | 859 | |
---|
| 860 | ic->acc->prpl->rem_permit(ic, handle); |
---|
[da3b536] | 861 | } |
---|
| 862 | |
---|
[5ebff60] | 863 | void imc_add_block(struct im_connection *ic, char *handle) |
---|
[da3b536] | 864 | { |
---|
[5ebff60] | 865 | if (g_slist_find_custom(ic->deny, handle, (GCompareFunc) ic->acc->prpl->handle_cmp) == NULL) { |
---|
| 866 | ic->deny = g_slist_prepend(ic->deny, g_strdup(handle)); |
---|
[da3b536] | 867 | } |
---|
[5ebff60] | 868 | |
---|
| 869 | ic->acc->prpl->add_deny(ic, handle); |
---|
[da3b536] | 870 | } |
---|
| 871 | |
---|
[5ebff60] | 872 | void imc_rem_block(struct im_connection *ic, char *handle) |
---|
[da3b536] | 873 | { |
---|
| 874 | GSList *l; |
---|
[5ebff60] | 875 | |
---|
| 876 | if ((l = g_slist_find_custom(ic->deny, handle, (GCompareFunc) ic->acc->prpl->handle_cmp))) { |
---|
| 877 | g_free(l->data); |
---|
| 878 | ic->deny = g_slist_delete_link(ic->deny, l); |
---|
[da3b536] | 879 | } |
---|
[5ebff60] | 880 | |
---|
| 881 | ic->acc->prpl->rem_deny(ic, handle); |
---|
[da3b536] | 882 | } |
---|
[85023c6] | 883 | |
---|
[d6e2aa8] | 884 | /* Deprecated: using this function resulted in merging several handles accidentally |
---|
| 885 | * Also the irc layer handles this decently nowadays */ |
---|
[5ebff60] | 886 | void imcb_clean_handle(struct im_connection *ic, char *handle) |
---|
[85023c6] | 887 | { |
---|
| 888 | } |
---|