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