2
* $Id: text-xmpp-nick.c,v 1.6 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.
22
#include "window-items.h"
24
/* in include/irssi/src/fe-text */
25
#include "statusbar.h"
27
#include "xmpp-servers.h"
28
#include "xmpp-channels.h"
31
update_nick_statusbar(XMPP_SERVER_REC *server, XMPP_CHANNEL_REC *channel,
34
g_return_if_fail(server != NULL);
36
if (!IS_XMPP_SERVER(server))
40
server->nick = g_strdup(IS_XMPP_CHANNEL(channel) ?
41
channel->nick : server->nickname);
44
statusbar_redraw(NULL, TRUE);
48
sig_window_changed(WINDOW_REC *window, WINDOW_REC *oldwindow)
50
XMPP_SERVER_REC *server;
51
XMPP_CHANNEL_REC *channel;
53
g_return_if_fail(window != NULL);
55
server = XMPP_SERVER(window->active_server);
59
channel = XMPP_CHANNEL(window->active);
60
if (channel != NULL ||
61
(oldwindow != NULL && IS_XMPP_CHANNEL(oldwindow->active)))
62
update_nick_statusbar(server, channel, FALSE);
66
sig_window_destroyed(WINDOW_REC *window)
68
XMPP_SERVER_REC *server;
69
XMPP_CHANNEL_REC *channel;
71
g_return_if_fail(window != NULL);
73
server = XMPP_SERVER(window->active_server);
77
channel = XMPP_CHANNEL(window->active);
78
if (channel != NULL || !IS_XMPP_CHANNEL(active_win->active))
79
update_nick_statusbar(server, NULL, TRUE);
83
sig_nick_changed(XMPP_SERVER_REC *server, XMPP_CHANNEL_REC *channel)
85
if (!IS_XMPP_SERVER(server) || !IS_XMPP_CHANNEL(channel))
88
if (XMPP_CHANNEL(active_win->active) == channel)
89
update_nick_statusbar(server, channel, TRUE);
93
sig_channel_joined(XMPP_CHANNEL_REC *channel)
95
g_return_if_fail(channel != NULL);
97
if (!IS_XMPP_CHANNEL(channel))
100
if (XMPP_CHANNEL(active_win->active) == channel)
101
update_nick_statusbar(channel->server, channel, TRUE);
105
sig_channel_destroyed(XMPP_CHANNEL_REC *channel)
107
g_return_if_fail(channel != NULL);
109
if (!IS_XMPP_CHANNEL(channel))
112
if (XMPP_CHANNEL(active_win->active) == channel)
113
update_nick_statusbar(channel->server, NULL, TRUE);
117
text_xmpp_nick_init(void)
119
signal_add("window changed", (SIGNAL_FUNC)sig_window_changed);
120
signal_add("window destroyed", (SIGNAL_FUNC)sig_window_destroyed);
121
signal_add("message xmpp channel own_nick",
122
(SIGNAL_FUNC)sig_nick_changed);
123
signal_add("channel joined",(SIGNAL_FUNC)sig_channel_joined);
124
signal_add("channel destroyed",(SIGNAL_FUNC)sig_channel_destroyed);
128
text_xmpp_nick_deinit(void)
130
signal_remove("window changed", (SIGNAL_FUNC)sig_window_changed);
131
signal_remove("window destroyed", (SIGNAL_FUNC)sig_window_destroyed);
132
signal_remove("message xmpp channel own_nick",
133
(SIGNAL_FUNC)sig_nick_changed);
134
signal_remove("channel joined",(SIGNAL_FUNC)sig_channel_joined);
135
signal_remove("channel destroyed",(SIGNAL_FUNC)sig_channel_destroyed);