source: protocols/nogaim.c @ 808825e

Last change on this file since 808825e was 808825e, checked in by jgeboski <jgeboski@…>, at 2016-05-26T02:48:08Z

Show the enabled/disabled protocols in the 'plugins' command output

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