2
* $Id: xmpp-session.c,v 1.2 2008/03/01 17:57:21 errtu Exp $
4
* Copyright (C) 2007 Colin DIDIER
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License version 2 as
8
* published by the Free Software Foundation.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License along
16
* with this program; if not, write to the Free Software Foundation, Inc.,
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27
#include "lib-config/iconfig.h"
29
#include "xmpp-channels.h"
30
#include "xmpp-protocol.h"
31
#include "xmpp-rosters.h"
32
#include "xmpp-servers.h"
33
#include "xmpp-tools.h"
36
sig_session_save_server(XMPP_SERVER_REC *server, CONFIG_REC *config,
39
if (!IS_XMPP_SERVER(server))
42
config_node_set_bool(config, node, "usermode_away", server->usermode_away);
43
config_node_set_str(config, node, "away_reason", server->away_reason);
45
config_node_set_int(config, node, "show", server->show);
46
config_node_set_bool(config, node, "default_priority",
47
server->default_priority);
48
config_node_set_int(config, node, "priority", server->priority);
52
sig_session_restore_server(XMPP_SERVER_REC *server, CONFIG_NODE *node)
54
if (!IS_XMPP_SERVER(server))
57
server->usermode_away = config_node_get_bool(node, "usermode_away",
60
signal_emit("xmpp own_presence", 4, server,
61
config_node_get_int(node, "show", XMPP_PRESENCE_AVAILABLE),
62
config_node_get_str(node, "away_reason", NULL),
63
config_node_get_bool(node, "priority", TRUE) ?
64
config_node_get_int(node, "priority", 0) : server->priority);
68
sig_session_restore_nick(XMPP_CHANNEL_REC *channel, CONFIG_NODE *node)
73
session_restore_channel(XMPP_CHANNEL_REC *channel)
75
g_return_if_fail(IS_XMPP_CHANNEL(channel));
79
sig_connected(XMPP_SERVER_REC *server)
83
if (!IS_XMPP_SERVER(server) || !server->session_reconnect)
86
for (tmp = server->channels; tmp != NULL; tmp = tmp->next) {
87
XMPP_CHANNEL_REC *channel = XMPP_CHANNEL(tmp->data);
89
if (channel != NULL && channel->session_rejoin)
90
session_restore_channel(channel);
95
xmpp_session_init(void)
97
signal_add("session save server",
98
(SIGNAL_FUNC)sig_session_save_server);
99
signal_add("session restore server",
100
(SIGNAL_FUNC)sig_session_restore_server);
101
signal_add("session restore nick",
102
(SIGNAL_FUNC)sig_session_restore_nick);
103
signal_add("event connected", (SIGNAL_FUNC)sig_connected);
107
xmpp_session_deinit(void)
109
signal_remove("session save server",
110
(SIGNAL_FUNC)sig_session_save_server);
111
signal_remove("session restore server",
112
(SIGNAL_FUNC)sig_session_restore_server);
113
signal_remove("session restore nick",
114
(SIGNAL_FUNC)sig_session_restore_nick);
115
signal_remove("event connected", (SIGNAL_FUNC)sig_connected);