source: protocols/bee.c @ adec749

Last change on this file since adec749 was 5ebff60, checked in by dequis <dx@…>, at 2015-02-20T22:50:54Z

Reindent everything to K&R style with tabs

Used uncrustify, with the configuration file in ./doc/uncrustify.cfg

Commit author set to "Indent <please@…>" so that it's easier to
skip while doing git blame.

  • Property mode set to 100644
File size: 2.9 KB
RevLine 
[5ebff60]1/********************************************************************\
[81186cab]2  * BitlBee -- An IRC to other IM-networks gateway                     *
3  *                                                                    *
4  * Copyright 2002-2010 Wilmer van der Gaast and others                *
5  \********************************************************************/
6
7/* Some IM-core stuff                                                   */
8
9/*
10  This program is free software; you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation; either version 2 of the License, or
13  (at your option) any later version.
14
15  This program is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  GNU General Public License for more details.
19
20  You should have received a copy of the GNU General Public License with
21  the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL;
[6f10697]22  if not, write to the Free Software Foundation, Inc., 51 Franklin St.,
23  Fifth Floor, Boston, MA  02110-1301  USA
[81186cab]24*/
25
26#define BITLBEE_CORE
[ebaebfe]27#include "bitlbee.h"
28
[5ebff60]29static char *set_eval_away_status(set_t *set, char *value);
[81186cab]30
[ebaebfe]31bee_t *bee_new()
32{
[5ebff60]33        bee_t *b = g_new0(bee_t, 1);
[ebaebfe]34        set_t *s;
[5ebff60]35
36        s = set_add(&b->set, "auto_connect", "true", set_eval_bool, b);
37        s = set_add(&b->set, "auto_reconnect", "true", set_eval_bool, b);
38        s = set_add(&b->set, "auto_reconnect_delay", "5*3<900", set_eval_account_reconnect_delay, b);
39        s = set_add(&b->set, "away", NULL, set_eval_away_status, b);
[5df65bd]40        s->flags |= SET_NULL_OK | SET_HIDDEN;
[5ebff60]41        s = set_add(&b->set, "debug", "false", set_eval_bool, b);
42        s = set_add(&b->set, "mobile_is_away", "false", set_eval_bool, b);
43        s = set_add(&b->set, "save_on_quit", "true", set_eval_bool, b);
44        s = set_add(&b->set, "status", NULL, set_eval_away_status, b);
[ebaebfe]45        s->flags |= SET_NULL_OK;
[5ebff60]46        s = set_add(&b->set, "strip_html", "true", NULL, b);
47
48        b->user = g_malloc(1);
49
[ebaebfe]50        return b;
51}
52
[5ebff60]53void bee_free(bee_t *b)
[ebaebfe]54{
[5ebff60]55        while (b->accounts) {
56                if (b->accounts->ic) {
57                        imc_logout(b->accounts->ic, FALSE);
58                } else if (b->accounts->reconnect) {
59                        cancel_auto_reconnect(b->accounts);
60                }
61
62                if (b->accounts->ic == NULL) {
63                        account_del(b, b->accounts);
64                } else {
[ebaebfe]65                        /* Nasty hack, but account_del() doesn't work in this
66                           case and we don't want infinite loops, do we? ;-) */
[d33679e]67                        b->accounts = b->accounts->next;
[5ebff60]68                }
69        }
70
71        while (b->set) {
72                set_del(&b->set, b->set->key);
[ebaebfe]73        }
[5ebff60]74
75        bee_group_free(b);
76
77        g_free(b->user);
78        g_free(b);
[ebaebfe]79}
[81186cab]80
[5ebff60]81static char *set_eval_away_status(set_t *set, char *value)
[81186cab]82{
83        bee_t *bee = set->data;
84        account_t *a;
[5ebff60]85
86        g_free(set->value);
87        set->value = g_strdup(value);
88
89        for (a = bee->accounts; a; a = a->next) {
[81186cab]90                struct im_connection *ic = a->ic;
[5ebff60]91
92                if (ic && ic->flags & OPT_LOGGED_IN) {
93                        imc_away_send_update(ic);
94                }
[81186cab]95        }
[5ebff60]96
[81186cab]97        return value;
98}
Note: See TracBrowser for help on using the repository browser.