mirror of
https://github.com/irssi/irssi.git
synced 2025-02-02 15:08:01 -05:00
Lots of moving stuff around - hopefully I didn't break too much :)
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@632 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
3d124da13b
commit
e395e87ded
@ -12,48 +12,57 @@ src/core/net-nonblock.c
|
|||||||
src/core/network.c
|
src/core/network.c
|
||||||
src/core/pidwait.c
|
src/core/pidwait.c
|
||||||
src/core/rawlog.c
|
src/core/rawlog.c
|
||||||
src/core/server-redirect.c
|
src/core/queries.c
|
||||||
src/core/server.c
|
src/core/servers-redirect.c
|
||||||
src/core/settings.c
|
src/core/settings.c
|
||||||
src/core/signals.c
|
src/core/signals.c
|
||||||
src/core/special-vars.c
|
src/core/special-vars.c
|
||||||
|
src/core/net-sendbuffer.c
|
||||||
|
src/core/channels-setup.c
|
||||||
|
src/core/servers-setup.c
|
||||||
|
src/core/chatnets.c
|
||||||
|
src/core/servers-reconnect.c
|
||||||
|
src/core/channels.c
|
||||||
|
src/core/servers.c
|
||||||
|
src/core/nicklist.c
|
||||||
|
src/core/masks.c
|
||||||
|
src/irc/bot/bot-events.c
|
||||||
|
src/irc/bot/bot-irc-commands.c
|
||||||
|
src/irc/bot/bot-users.c
|
||||||
|
src/irc/bot/bot.c
|
||||||
|
src/irc/bot/botnet-connection.c
|
||||||
|
src/irc/bot/botnet-users.c
|
||||||
|
src/irc/bot/botnet.c
|
||||||
src/irc/core/bans.c
|
src/irc/core/bans.c
|
||||||
src/irc/core/channel-events.c
|
src/irc/core/channel-events.c
|
||||||
|
src/irc/core/channel-rejoin.c
|
||||||
src/irc/core/channels-query.c
|
src/irc/core/channels-query.c
|
||||||
src/irc/core/channels-setup.c
|
src/irc/core/irc-channels-setup.c
|
||||||
src/irc/core/channels.c
|
src/irc/core/irc-nicklist.c
|
||||||
src/irc/core/ctcp.c
|
src/irc/core/ctcp.c
|
||||||
src/irc/core/ignore.c
|
src/irc/core/ignore.c
|
||||||
src/irc/core/irc-commands.c
|
|
||||||
src/irc/core/irc-core.c
|
src/irc/core/irc-core.c
|
||||||
src/irc/core/irc-log.c
|
src/irc/core/irc-log.c
|
||||||
src/irc/core/irc-rawlog.c
|
src/irc/core/irc-rawlog.c
|
||||||
src/irc/core/irc-server.c
|
|
||||||
src/irc/core/irc-special-vars.c
|
src/irc/core/irc-special-vars.c
|
||||||
src/irc/core/irc.c
|
src/irc/core/irc.c
|
||||||
src/irc/core/ircnet-setup.c
|
src/irc/core/irc-chatnets.c
|
||||||
src/irc/core/lag.c
|
src/irc/core/lag.c
|
||||||
src/irc/core/masks.c
|
|
||||||
src/irc/core/massjoin.c
|
src/irc/core/massjoin.c
|
||||||
src/irc/core/mode-lists.c
|
src/irc/core/mode-lists.c
|
||||||
src/irc/core/modes.c
|
src/irc/core/modes.c
|
||||||
src/irc/core/netsplit.c
|
src/irc/core/netsplit.c
|
||||||
src/irc/core/nicklist.c
|
src/irc/core/irc-masks.c
|
||||||
src/irc/core/query.c
|
src/irc/core/irc-channels.c
|
||||||
src/irc/core/server-idle.c
|
src/irc/core/server-idle.c
|
||||||
src/irc/core/server-reconnect.c
|
src/irc/core/irc-servers-reconnect.c
|
||||||
src/irc/core/server-setup.c
|
src/irc/core/irc-servers-setup.c
|
||||||
src/irc/core/channel-rejoin.c
|
src/irc/core/irc-commands.c
|
||||||
|
src/irc/core/irc-servers.c
|
||||||
|
src/irc/core/irc-queries.c
|
||||||
src/irc/dcc/dcc-chat.c
|
src/irc/dcc/dcc-chat.c
|
||||||
src/irc/dcc/dcc-files.c
|
src/irc/dcc/dcc-files.c
|
||||||
src/irc/dcc/dcc.c
|
src/irc/dcc/dcc.c
|
||||||
src/irc/bot/bot-events.c
|
|
||||||
src/irc/bot/bot-users.c
|
|
||||||
src/irc/bot/bot.c
|
|
||||||
src/irc/bot/botnet-connection.c
|
|
||||||
src/irc/bot/botnet.c
|
|
||||||
src/irc/bot/botnet-users.c
|
|
||||||
src/irc/bot/bot-irc-commands.c
|
|
||||||
src/irc/flood/autoignore.c
|
src/irc/flood/autoignore.c
|
||||||
src/irc/flood/flood.c
|
src/irc/flood/flood.c
|
||||||
src/irc/notifylist/notify-commands.c
|
src/irc/notifylist/notify-commands.c
|
||||||
@ -64,57 +73,61 @@ src/irc/notifylist/notifylist.c
|
|||||||
src/irc/irc.c
|
src/irc/irc.c
|
||||||
src/fe-common/core/autorun.c
|
src/fe-common/core/autorun.c
|
||||||
src/fe-common/core/command-history.c
|
src/fe-common/core/command-history.c
|
||||||
|
src/fe-common/core/completion.c
|
||||||
src/fe-common/core/fe-common-core.c
|
src/fe-common/core/fe-common-core.c
|
||||||
src/fe-common/core/fe-core-commands.c
|
src/fe-common/core/fe-core-commands.c
|
||||||
src/fe-common/core/fe-log.c
|
src/fe-common/core/fe-log.c
|
||||||
src/fe-common/core/fe-server.c
|
src/fe-common/core/fe-server.c
|
||||||
src/fe-common/core/fe-settings.c
|
src/fe-common/core/fe-settings.c
|
||||||
src/fe-common/core/hilight-text.c
|
|
||||||
src/fe-common/core/keyboard.c
|
src/fe-common/core/keyboard.c
|
||||||
src/fe-common/core/module-formats.c
|
src/fe-common/core/module-formats.c
|
||||||
src/fe-common/core/printtext.c
|
src/fe-common/core/printtext.c
|
||||||
src/fe-common/core/themes.c
|
src/fe-common/core/themes.c
|
||||||
src/fe-common/core/translation.c
|
src/fe-common/core/translation.c
|
||||||
src/fe-common/core/window-items.c
|
|
||||||
src/fe-common/core/windows.c
|
|
||||||
src/fe-common/core/window-activity.c
|
src/fe-common/core/window-activity.c
|
||||||
src/fe-common/core/window-commands.c
|
src/fe-common/core/window-commands.c
|
||||||
src/fe-common/core/completion.c
|
src/fe-common/core/window-items.c
|
||||||
|
src/fe-common/core/windows.c
|
||||||
|
src/fe-common/core/fe-modules.c
|
||||||
|
src/fe-common/core/hilight-text.c
|
||||||
|
src/fe-common/core/window-save.c
|
||||||
src/fe-common/irc/dcc/fe-dcc.c
|
src/fe-common/irc/dcc/fe-dcc.c
|
||||||
src/fe-common/irc/dcc/module-formats.c
|
src/fe-common/irc/dcc/module-formats.c
|
||||||
src/fe-common/irc/fe-channels.c
|
src/fe-common/irc/fe-channels.c
|
||||||
src/fe-common/irc/fe-common-irc.c
|
src/fe-common/irc/fe-common-irc.c
|
||||||
src/fe-common/irc/fe-ctcp.c
|
src/fe-common/irc/fe-ctcp.c
|
||||||
src/fe-common/irc/fe-events-numeric.c
|
|
||||||
src/fe-common/irc/fe-events.c
|
src/fe-common/irc/fe-events.c
|
||||||
src/fe-common/irc/fe-ignore.c
|
src/fe-common/irc/fe-ignore.c
|
||||||
src/fe-common/irc/fe-irc-commands.c
|
src/fe-common/irc/fe-irc-commands.c
|
||||||
src/fe-common/irc/fe-query.c
|
src/fe-common/irc/fe-irc-server.c
|
||||||
|
src/fe-common/irc/fe-ircnet.c
|
||||||
|
src/fe-common/irc/fe-netsplit.c
|
||||||
src/fe-common/irc/irc-hilight-text.c
|
src/fe-common/irc/irc-hilight-text.c
|
||||||
|
src/fe-common/irc/irc-window-activity.c
|
||||||
|
src/fe-common/irc/module-formats.c
|
||||||
src/fe-common/irc/flood/fe-flood.c
|
src/fe-common/irc/flood/fe-flood.c
|
||||||
src/fe-common/irc/flood/module-formats.c
|
src/fe-common/irc/flood/module-formats.c
|
||||||
src/fe-common/irc/notifylist/fe-notifylist.c
|
src/fe-common/irc/notifylist/fe-notifylist.c
|
||||||
src/fe-common/irc/notifylist/module-formats.c
|
src/fe-common/irc/notifylist/module-formats.c
|
||||||
src/fe-common/irc/fe-irc-server.c
|
|
||||||
src/fe-common/irc/fe-netsplit.c
|
|
||||||
src/fe-common/irc/irc-window-activity.c
|
|
||||||
src/fe-common/irc/irc-modules.c
|
src/fe-common/irc/irc-modules.c
|
||||||
|
src/fe-common/irc/fe-netjoin.c
|
||||||
|
src/fe-common/irc/fe-queries.c
|
||||||
|
src/fe-common/irc/fe-events-numeric.c
|
||||||
src/fe-common/irc/irc-completion.c
|
src/fe-common/irc/irc-completion.c
|
||||||
src/fe-common/irc/fe-ircnet.c
|
|
||||||
src/fe-common/irc/module-formats.c
|
|
||||||
src/fe-none/irssi.c
|
src/fe-none/irssi.c
|
||||||
src/fe-text/gui-entry.c
|
src/fe-text/gui-entry.c
|
||||||
src/fe-text/mainwindows.c
|
src/fe-text/gui-printtext.c
|
||||||
src/fe-text/gui-special-vars.c
|
src/fe-text/gui-special-vars.c
|
||||||
src/fe-text/statusbar-items.c
|
|
||||||
src/fe-text/statusbar.c
|
|
||||||
src/fe-text/gui-textwidget.c
|
src/fe-text/gui-textwidget.c
|
||||||
|
src/fe-text/gui-windows.c
|
||||||
src/fe-text/irssi.c
|
src/fe-text/irssi.c
|
||||||
src/fe-text/module-formats.c
|
src/fe-text/module-formats.c
|
||||||
src/fe-text/screen.c
|
src/fe-text/screen.c
|
||||||
src/fe-text/gui-windows.c
|
src/fe-text/statusbar-items.c
|
||||||
|
src/fe-text/statusbar.c
|
||||||
src/fe-text/gui-readline.c
|
src/fe-text/gui-readline.c
|
||||||
src/fe-text/gui-printtext.c
|
src/fe-text/mainwindow-activity.c
|
||||||
|
src/fe-text/mainwindows.c
|
||||||
src/lib-config/get.c
|
src/lib-config/get.c
|
||||||
src/lib-config/parse.c
|
src/lib-config/parse.c
|
||||||
src/lib-config/set.c
|
src/lib-config/set.c
|
||||||
|
4
po/de.po
4
po/de.po
@ -6,7 +6,7 @@
|
|||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: Irssi 0.7.23\n"
|
"Project-Id-Version: Irssi 0.7.23\n"
|
||||||
"POT-Creation-Date: 2000-08-13 03:27+0300\n"
|
"POT-Creation-Date: 2000-09-26 18:28+0300\n"
|
||||||
"PO-Revision-Date: 1999-12-01 10:35-0200\n"
|
"PO-Revision-Date: 1999-12-01 10:35-0200\n"
|
||||||
"Last-Translator: Thomas Heinen <cochi@uni-paderborn.de>\n"
|
"Last-Translator: Thomas Heinen <cochi@uni-paderborn.de>\n"
|
||||||
"Language-Team: Brazilian Portuguese <ldp-br@bazar.conectiva.com.br>\n"
|
"Language-Team: Brazilian Portuguese <ldp-br@bazar.conectiva.com.br>\n"
|
||||||
@ -129,7 +129,7 @@ msgstr "Bitte Nickname angeben"
|
|||||||
msgid "Specify host name to use"
|
msgid "Specify host name to use"
|
||||||
msgstr "Bitte Nickname angeben"
|
msgstr "Bitte Nickname angeben"
|
||||||
|
|
||||||
#: src/fe-text/irssi.c:158
|
#: src/fe-text/irssi.c:164
|
||||||
msgid "Can't initialize screen handling, quitting.\n"
|
msgid "Can't initialize screen handling, quitting.\n"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
4
po/fi.po
4
po/fi.po
@ -6,7 +6,7 @@
|
|||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"POT-Creation-Date: 2000-08-13 03:27+0300\n"
|
"POT-Creation-Date: 2000-09-26 18:28+0300\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
@ -122,7 +122,7 @@ msgstr ""
|
|||||||
msgid "Specify host name to use"
|
msgid "Specify host name to use"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/fe-text/irssi.c:158
|
#: src/fe-text/irssi.c:164
|
||||||
msgid "Can't initialize screen handling, quitting.\n"
|
msgid "Can't initialize screen handling, quitting.\n"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
4
po/fr.po
4
po/fr.po
@ -6,7 +6,7 @@
|
|||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: irssi-0.7.23\n"
|
"Project-Id-Version: irssi-0.7.23\n"
|
||||||
"POT-Creation-Date: 2000-08-13 03:27+0300\n"
|
"POT-Creation-Date: 2000-09-26 18:28+0300\n"
|
||||||
"PO-Revision-Date: 2000-01-26 16:33+0100\n"
|
"PO-Revision-Date: 2000-01-26 16:33+0100\n"
|
||||||
"Last-Translator: Julien Boulnois <jboulnois@free.fr>\n"
|
"Last-Translator: Julien Boulnois <jboulnois@free.fr>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
@ -129,7 +129,7 @@ msgstr "Sp
|
|||||||
msgid "Specify host name to use"
|
msgid "Specify host name to use"
|
||||||
msgstr "Sp<53>écifiez un nick <20>à utiliser"
|
msgstr "Sp<53>écifiez un nick <20>à utiliser"
|
||||||
|
|
||||||
#: src/fe-text/irssi.c:158
|
#: src/fe-text/irssi.c:164
|
||||||
msgid "Can't initialize screen handling, quitting.\n"
|
msgid "Can't initialize screen handling, quitting.\n"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
4
po/pl.po
4
po/pl.po
@ -6,7 +6,7 @@
|
|||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"POT-Creation-Date: 2000-08-13 03:27+0300\n"
|
"POT-Creation-Date: 2000-09-26 18:28+0300\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
@ -122,7 +122,7 @@ msgstr ""
|
|||||||
msgid "Specify host name to use"
|
msgid "Specify host name to use"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/fe-text/irssi.c:158
|
#: src/fe-text/irssi.c:164
|
||||||
msgid "Can't initialize screen handling, quitting.\n"
|
msgid "Can't initialize screen handling, quitting.\n"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: irssi 0.7.23\n"
|
"Project-Id-Version: irssi 0.7.23\n"
|
||||||
"POT-Creation-Date: 2000-08-13 03:27+0300\n"
|
"POT-Creation-Date: 2000-09-26 18:28+0300\n"
|
||||||
"PO-Revision-Date: 2000-02-10 09:50-0200\n"
|
"PO-Revision-Date: 2000-02-10 09:50-0200\n"
|
||||||
"Last-Translator: Frédéric L. W. Meunier <fredlwm@olympiquedemarseille.org>\n"
|
"Last-Translator: Frédéric L. W. Meunier <fredlwm@olympiquedemarseille.org>\n"
|
||||||
"Language-Team: Brazilian Portuguese <ldp-br@bazar.conectiva.com.br>\n"
|
"Language-Team: Brazilian Portuguese <ldp-br@bazar.conectiva.com.br>\n"
|
||||||
@ -130,7 +130,7 @@ msgstr "Espeficar nick para usar"
|
|||||||
msgid "Specify host name to use"
|
msgid "Specify host name to use"
|
||||||
msgstr "Espeficar nick para usar"
|
msgstr "Espeficar nick para usar"
|
||||||
|
|
||||||
#: src/fe-text/irssi.c:158
|
#: src/fe-text/irssi.c:164
|
||||||
msgid "Can't initialize screen handling, quitting.\n"
|
msgid "Can't initialize screen handling, quitting.\n"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
noinst_LTLIBRARIES = libcore.la
|
noinst_LIBRARIES = libcore.a
|
||||||
|
|
||||||
INCLUDES = \
|
INCLUDES = \
|
||||||
$(GLIB_CFLAGS) \
|
$(GLIB_CFLAGS) \
|
||||||
@ -13,13 +13,17 @@ else
|
|||||||
memdebug_src=
|
memdebug_src=
|
||||||
endif
|
endif
|
||||||
|
|
||||||
libcore_la_SOURCES = \
|
libcore_a_SOURCES = \
|
||||||
args.c \
|
args.c \
|
||||||
|
channels.c \
|
||||||
|
channels-setup.c \
|
||||||
commands.c \
|
commands.c \
|
||||||
|
chatnets.c \
|
||||||
core.c \
|
core.c \
|
||||||
levels.c \
|
levels.c \
|
||||||
line-split.c \
|
line-split.c \
|
||||||
log.c \
|
log.c \
|
||||||
|
masks.c \
|
||||||
$(memdebug_src) \
|
$(memdebug_src) \
|
||||||
misc.c \
|
misc.c \
|
||||||
modules.c \
|
modules.c \
|
||||||
@ -27,21 +31,38 @@ libcore_la_SOURCES = \
|
|||||||
net-nonblock.c \
|
net-nonblock.c \
|
||||||
net-sendbuffer.c \
|
net-sendbuffer.c \
|
||||||
network.c \
|
network.c \
|
||||||
|
nicklist.c \
|
||||||
pidwait.c \
|
pidwait.c \
|
||||||
|
queries.c \
|
||||||
rawlog.c \
|
rawlog.c \
|
||||||
server.c \
|
servers.c \
|
||||||
server-redirect.c \
|
servers-reconnect.c \
|
||||||
|
servers-redirect.c \
|
||||||
|
servers-setup.c \
|
||||||
settings.c \
|
settings.c \
|
||||||
signals.c \
|
signals.c \
|
||||||
special-vars.c
|
special-vars.c
|
||||||
|
|
||||||
|
structure_headers = \
|
||||||
|
chatnet-rec.h \
|
||||||
|
channel-rec.h \
|
||||||
|
query-rec.h \
|
||||||
|
server-rec.h \
|
||||||
|
server-setup-rec.h \
|
||||||
|
server-connect-rec.h \
|
||||||
|
window-item-rec.h
|
||||||
|
|
||||||
noinst_HEADERS = \
|
noinst_HEADERS = \
|
||||||
args.h \
|
args.h \
|
||||||
|
channels.h \
|
||||||
|
channels-setup.h \
|
||||||
commands.h \
|
commands.h \
|
||||||
|
chatnets.h \
|
||||||
core.h \
|
core.h \
|
||||||
levels.h \
|
levels.h \
|
||||||
line-split.h \
|
line-split.h \
|
||||||
log.h \
|
log.h \
|
||||||
|
masks.h \
|
||||||
memdebug.h \
|
memdebug.h \
|
||||||
misc.h \
|
misc.h \
|
||||||
module.h \
|
module.h \
|
||||||
@ -51,13 +72,19 @@ noinst_HEADERS = \
|
|||||||
net-nonblock.h \
|
net-nonblock.h \
|
||||||
net-sendbuffer.h \
|
net-sendbuffer.h \
|
||||||
network.h \
|
network.h \
|
||||||
|
nicklist.h \
|
||||||
pidwait.h \
|
pidwait.h \
|
||||||
|
queries.h \
|
||||||
rawlog.h \
|
rawlog.h \
|
||||||
server.h \
|
servers.h \
|
||||||
server-redirect.h \
|
servers-reconnect.h \
|
||||||
|
servers-redirect.h \
|
||||||
|
servers-setup.h \
|
||||||
settings.h \
|
settings.h \
|
||||||
signals.h \
|
signals.h \
|
||||||
special-vars.h
|
special-vars.h \
|
||||||
|
window-item-def.h \
|
||||||
|
$(structure_headers)
|
||||||
|
|
||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
memdebug.c
|
memdebug.c
|
||||||
|
21
src/core/channel-rec.h
Normal file
21
src/core/channel-rec.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
/* CHANNEL_REC definition, used for inheritance */
|
||||||
|
|
||||||
|
#include "window-item-rec.h"
|
||||||
|
|
||||||
|
char *topic;
|
||||||
|
GHashTable *nicks; /* list of nicks */
|
||||||
|
|
||||||
|
int no_modes:1; /* channel doesn't support modes */
|
||||||
|
char *mode;
|
||||||
|
int limit; /* user limit */
|
||||||
|
char *key; /* password key */
|
||||||
|
|
||||||
|
int chanop:1; /* You're a channel operator */
|
||||||
|
int names_got:1; /* Received /NAMES list */
|
||||||
|
int wholist:1; /* WHO list got */
|
||||||
|
int synced:1; /* Channel synced - all queries done */
|
||||||
|
|
||||||
|
int joined:1; /* Have we even received JOIN event for this channel? */
|
||||||
|
int left:1; /* You just left the channel */
|
||||||
|
int kicked:1; /* You just got kicked */
|
||||||
|
int destroying:1;
|
170
src/core/channels-setup.c
Normal file
170
src/core/channels-setup.c
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
/*
|
||||||
|
channels-setup.c : irssi
|
||||||
|
|
||||||
|
Copyright (C) 1999-2000 Timo Sirainen
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "module.h"
|
||||||
|
#include "signals.h"
|
||||||
|
#include "lib-config/iconfig.h"
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
|
#include "channels.h"
|
||||||
|
#include "channels-setup.h"
|
||||||
|
#include "servers-setup.h"
|
||||||
|
|
||||||
|
GSList *setupchannels;
|
||||||
|
|
||||||
|
static CHANNEL_SETUP_REC *channel_setup_read(CONFIG_NODE *node)
|
||||||
|
{
|
||||||
|
CHANNEL_SETUP_REC *rec;
|
||||||
|
char *channel, *password, *botmasks, *autosendcmd;
|
||||||
|
|
||||||
|
g_return_val_if_fail(node != NULL, NULL);
|
||||||
|
|
||||||
|
channel = config_node_get_str(node, "name", NULL);
|
||||||
|
if (channel == NULL) {
|
||||||
|
/* missing information.. */
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
password = config_node_get_str(node, "password", NULL);
|
||||||
|
botmasks = config_node_get_str(node, "botmasks", NULL);
|
||||||
|
autosendcmd = config_node_get_str(node, "autosendcmd", NULL);
|
||||||
|
|
||||||
|
rec = g_new(CHANNEL_SETUP_REC, 1);
|
||||||
|
rec->autojoin = config_node_get_bool(node, "autojoin", FALSE);
|
||||||
|
rec->name = g_strdup(channel);
|
||||||
|
rec->chatnet = g_strdup(config_node_get_str(node, "chatnet", NULL));
|
||||||
|
rec->password = (password == NULL || *password == '\0') ? NULL : g_strdup(password);
|
||||||
|
rec->botmasks = (botmasks == NULL || *botmasks == '\0') ? NULL : g_strdup(botmasks);
|
||||||
|
rec->autosendcmd = (autosendcmd == NULL || *autosendcmd == '\0') ? NULL : g_strdup(autosendcmd);
|
||||||
|
|
||||||
|
setupchannels = g_slist_append(setupchannels, rec);
|
||||||
|
signal_emit("channel setup created", 2, rec, node);
|
||||||
|
return rec;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void channel_setup_save(CHANNEL_SETUP_REC *channel)
|
||||||
|
{
|
||||||
|
CONFIG_NODE *parentnode, *node;
|
||||||
|
int index;
|
||||||
|
|
||||||
|
index = g_slist_index(setupchannels, channel);
|
||||||
|
|
||||||
|
parentnode = iconfig_node_traverse("(channels", TRUE);
|
||||||
|
node = config_node_index(parentnode, index);
|
||||||
|
if (node == NULL)
|
||||||
|
node = config_node_section(parentnode, NULL, NODE_TYPE_BLOCK);
|
||||||
|
|
||||||
|
iconfig_node_clear(node);
|
||||||
|
iconfig_node_set_str(node, "name", channel->name);
|
||||||
|
iconfig_node_set_str(node, "chatnet", channel->chatnet);
|
||||||
|
if (channel->autojoin)
|
||||||
|
config_node_set_bool(node, "autojoin", TRUE);
|
||||||
|
iconfig_node_set_str(node, "password", channel->password);
|
||||||
|
iconfig_node_set_str(node, "botmasks", channel->botmasks);
|
||||||
|
iconfig_node_set_str(node, "autosendcmd", channel->autosendcmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void channel_config_remove(CHANNEL_SETUP_REC *channel)
|
||||||
|
{
|
||||||
|
CONFIG_NODE *node;
|
||||||
|
|
||||||
|
node = iconfig_node_traverse("channels", FALSE);
|
||||||
|
if (node != NULL) iconfig_node_list_remove(node, g_slist_index(setupchannels, channel));
|
||||||
|
}
|
||||||
|
|
||||||
|
void channels_setup_create(CHANNEL_SETUP_REC *channel)
|
||||||
|
{
|
||||||
|
if (g_slist_find(setupchannels, channel) == NULL)
|
||||||
|
setupchannels = g_slist_append(setupchannels, channel);
|
||||||
|
channel_setup_save(channel);
|
||||||
|
|
||||||
|
signal_emit("channel setup created", 1, channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void channels_setup_destroy_rec(CHANNEL_SETUP_REC *channel)
|
||||||
|
{
|
||||||
|
g_return_if_fail(channel != NULL);
|
||||||
|
|
||||||
|
setupchannels = g_slist_remove(setupchannels, channel);
|
||||||
|
signal_emit("channel setup destroyed", 1, channel);
|
||||||
|
|
||||||
|
g_free(channel->name);
|
||||||
|
g_free(channel->chatnet);
|
||||||
|
g_free_not_null(channel->password);
|
||||||
|
g_free_not_null(channel->botmasks);
|
||||||
|
g_free_not_null(channel->autosendcmd);
|
||||||
|
g_free(channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void channels_setup_destroy(CHANNEL_SETUP_REC *channel)
|
||||||
|
{
|
||||||
|
channel_config_remove(channel);
|
||||||
|
channels_setup_destroy_rec(channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
CHANNEL_SETUP_REC *channels_setup_find(const char *channel, const char *chatnet)
|
||||||
|
{
|
||||||
|
GSList *tmp;
|
||||||
|
|
||||||
|
g_return_val_if_fail(channel != NULL, NULL);
|
||||||
|
|
||||||
|
for (tmp = setupchannels; tmp != NULL; tmp = tmp->next) {
|
||||||
|
CHANNEL_SETUP_REC *rec = tmp->data;
|
||||||
|
|
||||||
|
if (g_strcasecmp(rec->name, channel) == 0 &&
|
||||||
|
channel_chatnet_match(rec->chatnet, chatnet))
|
||||||
|
return rec;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void channels_read_config(void)
|
||||||
|
{
|
||||||
|
CONFIG_NODE *node;
|
||||||
|
GSList *tmp;
|
||||||
|
|
||||||
|
while (setupchannels != NULL)
|
||||||
|
channels_setup_destroy_rec(setupchannels->data);
|
||||||
|
|
||||||
|
/* Read channels */
|
||||||
|
node = iconfig_node_traverse("channels", FALSE);
|
||||||
|
if (node != NULL) {
|
||||||
|
for (tmp = node->value; tmp != NULL; tmp = tmp->next)
|
||||||
|
channel_setup_read(tmp->data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void channels_setup_init(void)
|
||||||
|
{
|
||||||
|
source_host_ok = FALSE;
|
||||||
|
|
||||||
|
signal_add("setup reread", (SIGNAL_FUNC) channels_read_config);
|
||||||
|
signal_add("irssi init read settings", (SIGNAL_FUNC) channels_read_config);
|
||||||
|
}
|
||||||
|
|
||||||
|
void channels_setup_deinit(void)
|
||||||
|
{
|
||||||
|
while (setupchannels != NULL)
|
||||||
|
channels_setup_destroy(setupchannels->data);
|
||||||
|
|
||||||
|
signal_remove("setup reread", (SIGNAL_FUNC) channels_read_config);
|
||||||
|
signal_remove("irssi init read settings", (SIGNAL_FUNC) channels_read_config);
|
||||||
|
}
|
33
src/core/channels-setup.h
Normal file
33
src/core/channels-setup.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#ifndef __CHANNELS_SETUP_H
|
||||||
|
#define __CHANNELS_SETUP_H
|
||||||
|
|
||||||
|
#include "modules.h"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char *name;
|
||||||
|
char *chatnet;
|
||||||
|
char *password;
|
||||||
|
|
||||||
|
char *botmasks;
|
||||||
|
char *autosendcmd;
|
||||||
|
|
||||||
|
int autojoin:1;
|
||||||
|
GHashTable *module_data;
|
||||||
|
} CHANNEL_SETUP_REC;
|
||||||
|
|
||||||
|
extern GSList *setupchannels;
|
||||||
|
|
||||||
|
void channels_setup_init(void);
|
||||||
|
void channels_setup_deinit(void);
|
||||||
|
|
||||||
|
void channels_setup_create(CHANNEL_SETUP_REC *channel);
|
||||||
|
void channels_setup_destroy(CHANNEL_SETUP_REC *channel);
|
||||||
|
|
||||||
|
CHANNEL_SETUP_REC *channels_setup_find(const char *channel,
|
||||||
|
const char *chatnet);
|
||||||
|
|
||||||
|
#define channel_chatnet_match(rec, chatnet) \
|
||||||
|
((rec) == NULL || (rec)[0] == '\0' || \
|
||||||
|
((chatnet) != NULL && g_strcasecmp(rec, chatnet) == 0))
|
||||||
|
|
||||||
|
#endif
|
116
src/core/channels.c
Normal file
116
src/core/channels.c
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
/*
|
||||||
|
channel.c : irssi
|
||||||
|
|
||||||
|
Copyright (C) 1999-2000 Timo Sirainen
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "module.h"
|
||||||
|
#include "signals.h"
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
|
#include "channels.h"
|
||||||
|
|
||||||
|
typedef CHANNEL_REC *(*CHANNEL_FIND_FUNC)(SERVER_REC *, const char *);
|
||||||
|
|
||||||
|
GSList *channels; /* List of all channels */
|
||||||
|
|
||||||
|
void channel_init(CHANNEL_REC *channel, int automatic)
|
||||||
|
{
|
||||||
|
g_return_if_fail(channel != NULL);
|
||||||
|
g_return_if_fail(channel->name != NULL);
|
||||||
|
|
||||||
|
channels = g_slist_append(channels, channel);
|
||||||
|
if (channel->server != NULL) {
|
||||||
|
channel->server->channels =
|
||||||
|
g_slist_append(channel->server->channels, channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
MODULE_DATA_INIT(channel);
|
||||||
|
channel->type = module_get_uniq_id("CHANNEL", 0);
|
||||||
|
channel->mode = g_strdup("");
|
||||||
|
channel->createtime = time(NULL);
|
||||||
|
|
||||||
|
signal_emit("channel created", 2, channel, GINT_TO_POINTER(automatic));
|
||||||
|
}
|
||||||
|
|
||||||
|
void channel_destroy(CHANNEL_REC *channel)
|
||||||
|
{
|
||||||
|
g_return_if_fail(IS_CHANNEL(channel));
|
||||||
|
|
||||||
|
if (channel->destroying) return;
|
||||||
|
channel->destroying = TRUE;
|
||||||
|
|
||||||
|
channels = g_slist_remove(channels, channel);
|
||||||
|
if (channel->server != NULL)
|
||||||
|
channel->server->channels = g_slist_remove(channel->server->channels, channel);
|
||||||
|
signal_emit("channel destroyed", 1, channel);
|
||||||
|
|
||||||
|
MODULE_DATA_DEINIT(channel);
|
||||||
|
g_free_not_null(channel->topic);
|
||||||
|
g_free_not_null(channel->key);
|
||||||
|
g_free(channel->name);
|
||||||
|
g_free(channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CHANNEL_REC *channel_find_server(SERVER_REC *server,
|
||||||
|
const char *name)
|
||||||
|
{
|
||||||
|
GSList *tmp;
|
||||||
|
|
||||||
|
g_return_val_if_fail(IS_SERVER(server), NULL);
|
||||||
|
|
||||||
|
if (server->channel_find_func != NULL) {
|
||||||
|
/* use the server specific channel find function */
|
||||||
|
CHANNEL_FIND_FUNC channel_find_func;
|
||||||
|
channel_find_func =
|
||||||
|
(CHANNEL_FIND_FUNC) server->channel_find_func;
|
||||||
|
return channel_find_func(server, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (tmp = server->channels; tmp != NULL; tmp = tmp->next) {
|
||||||
|
CHANNEL_REC *rec = tmp->data;
|
||||||
|
|
||||||
|
if (rec->chat_type == server->channel_type &&
|
||||||
|
g_strcasecmp(name, rec->name) == 0)
|
||||||
|
return rec;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
CHANNEL_REC *channel_find(SERVER_REC *server, const char *name)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail(server == NULL || IS_SERVER(server), NULL);
|
||||||
|
g_return_val_if_fail(name != NULL, NULL);
|
||||||
|
|
||||||
|
if (server != NULL)
|
||||||
|
return channel_find_server(server, name);
|
||||||
|
|
||||||
|
/* find from any server */
|
||||||
|
return gslist_foreach_find(servers,
|
||||||
|
(FOREACH_FIND_FUNC) channel_find_server,
|
||||||
|
(void *) name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void channels_init(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void channels_deinit(void)
|
||||||
|
{
|
||||||
|
module_uniq_destroy("CHANNEL");
|
||||||
|
}
|
31
src/core/channels.h
Normal file
31
src/core/channels.h
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#ifndef __CHANNELS_H
|
||||||
|
#define __CHANNELS_H
|
||||||
|
|
||||||
|
#include "servers.h"
|
||||||
|
|
||||||
|
#define IS_CHANNEL(channel) \
|
||||||
|
((channel) != NULL && \
|
||||||
|
module_find_id("CHANNEL", ((CHANNEL_REC *) (channel))->type) != -1)
|
||||||
|
|
||||||
|
/* Returns CHANNEL_REC if it's channel, NULL if it isn't. */
|
||||||
|
#define CHANNEL(channel) \
|
||||||
|
(IS_CHANNEL(channel) ? (CHANNEL_REC *) (channel) : NULL)
|
||||||
|
|
||||||
|
#define STRUCT_SERVER_REC SERVER_REC
|
||||||
|
typedef struct {
|
||||||
|
#include "channel-rec.h"
|
||||||
|
} CHANNEL_REC;
|
||||||
|
|
||||||
|
extern GSList *channels;
|
||||||
|
|
||||||
|
void channels_init(void);
|
||||||
|
void channels_deinit(void);
|
||||||
|
|
||||||
|
/* Create new channel record */
|
||||||
|
void channel_init(CHANNEL_REC *channel, int automatic);
|
||||||
|
void channel_destroy(CHANNEL_REC *channel);
|
||||||
|
|
||||||
|
/* find channel by name, if `server' is NULL, search from all servers */
|
||||||
|
CHANNEL_REC *channel_find(SERVER_REC *server, const char *name);
|
||||||
|
|
||||||
|
#endif
|
12
src/core/chatnet-rec.h
Normal file
12
src/core/chatnet-rec.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
int type; /* should always be "CHATNET" */
|
||||||
|
int chat_type;
|
||||||
|
|
||||||
|
char *name;
|
||||||
|
|
||||||
|
char *nick;
|
||||||
|
char *username;
|
||||||
|
char *realname;
|
||||||
|
|
||||||
|
char *own_host; /* address to use when connecting this server */
|
||||||
|
char *autosendcmd; /* command to send after connecting to this ircnet */
|
||||||
|
IPADDR *own_ip; /* resolved own_address if not NULL */
|
148
src/core/chatnets.c
Normal file
148
src/core/chatnets.c
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
/*
|
||||||
|
chatnets.c : irssi
|
||||||
|
|
||||||
|
Copyright (C) 1999-2000 Timo Sirainen
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "module.h"
|
||||||
|
#include "network.h"
|
||||||
|
#include "signals.h"
|
||||||
|
#include "special-vars.h"
|
||||||
|
#include "lib-config/iconfig.h"
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
|
#include "chatnets.h"
|
||||||
|
#include "servers.h"
|
||||||
|
|
||||||
|
GSList *chatnets; /* list of available chat networks */
|
||||||
|
|
||||||
|
void chatnet_read(CHATNET_REC *chatnet, void *nodep)
|
||||||
|
{
|
||||||
|
CONFIG_NODE *node = nodep;
|
||||||
|
|
||||||
|
g_return_if_fail(chatnet != NULL);
|
||||||
|
g_return_if_fail(node != NULL);
|
||||||
|
g_return_if_fail(node->key != NULL);
|
||||||
|
|
||||||
|
chatnet->type = module_get_uniq_id("CHATNET", 0);
|
||||||
|
chatnet->name = g_strdup(node->key);
|
||||||
|
chatnet->nick = g_strdup(config_node_get_str(node, "nick", NULL));
|
||||||
|
chatnet->username = g_strdup(config_node_get_str(node, "username", NULL));
|
||||||
|
chatnet->realname = g_strdup(config_node_get_str(node, "realname", NULL));
|
||||||
|
chatnet->own_host = g_strdup(config_node_get_str(node, "host", NULL));
|
||||||
|
chatnet->autosendcmd = g_strdup(config_node_get_str(node, "autosendcmd", NULL));
|
||||||
|
|
||||||
|
chatnets = g_slist_append(chatnets, chatnet);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *chatnet_save(CHATNET_REC *chatnet, void *parentnode)
|
||||||
|
{
|
||||||
|
CONFIG_NODE *node = parentnode;
|
||||||
|
|
||||||
|
g_return_val_if_fail(parentnode != NULL, NULL);
|
||||||
|
g_return_val_if_fail(IS_CHATNET(chatnet), NULL);
|
||||||
|
|
||||||
|
node = config_node_section(node, chatnet->name, NODE_TYPE_BLOCK);
|
||||||
|
iconfig_node_clear(node);
|
||||||
|
|
||||||
|
iconfig_node_set_str(node, "nick", chatnet->nick);
|
||||||
|
iconfig_node_set_str(node, "username", chatnet->username);
|
||||||
|
iconfig_node_set_str(node, "realname", chatnet->realname);
|
||||||
|
iconfig_node_set_str(node, "host", chatnet->own_host);
|
||||||
|
iconfig_node_set_str(node, "autosendcmd", chatnet->autosendcmd);
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
void chatnet_create(CHATNET_REC *chatnet)
|
||||||
|
{
|
||||||
|
g_return_if_fail(chatnet != NULL);
|
||||||
|
|
||||||
|
chatnet->type = module_get_uniq_id("CHATNET", 0);
|
||||||
|
if (g_slist_find(chatnets, chatnet) == NULL)
|
||||||
|
chatnets = g_slist_append(chatnets, chatnet);
|
||||||
|
|
||||||
|
signal_emit("chatnet created", 1, chatnet);
|
||||||
|
}
|
||||||
|
|
||||||
|
void chatnet_remove(CHATNET_REC *chatnet)
|
||||||
|
{
|
||||||
|
g_return_if_fail(IS_CHATNET(chatnet));
|
||||||
|
|
||||||
|
signal_emit("chatnet removed", 1, chatnet);
|
||||||
|
chatnet_destroy(chatnet);
|
||||||
|
}
|
||||||
|
|
||||||
|
void chatnet_destroy(CHATNET_REC *chatnet)
|
||||||
|
{
|
||||||
|
g_return_if_fail(IS_CHATNET(chatnet));
|
||||||
|
|
||||||
|
chatnets = g_slist_remove(chatnets, chatnet);
|
||||||
|
signal_emit("chatnet destroyed", 1, chatnet);
|
||||||
|
|
||||||
|
g_free(chatnet->name);
|
||||||
|
g_free_not_null(chatnet->nick);
|
||||||
|
g_free_not_null(chatnet->username);
|
||||||
|
g_free_not_null(chatnet->realname);
|
||||||
|
g_free_not_null(chatnet->own_host);
|
||||||
|
g_free_not_null(chatnet->autosendcmd);
|
||||||
|
g_free(chatnet);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Find the irc network by name */
|
||||||
|
CHATNET_REC *chatnet_find(const char *name)
|
||||||
|
{
|
||||||
|
GSList *tmp;
|
||||||
|
|
||||||
|
g_return_val_if_fail(name != NULL, NULL);
|
||||||
|
|
||||||
|
for (tmp = chatnets; tmp != NULL; tmp = tmp->next) {
|
||||||
|
CHATNET_REC *rec = tmp->data;
|
||||||
|
|
||||||
|
if (g_strcasecmp(rec->name, name) == 0)
|
||||||
|
return rec;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void sig_connected(SERVER_REC *server)
|
||||||
|
{
|
||||||
|
CHATNET_REC *rec;
|
||||||
|
|
||||||
|
g_return_if_fail(IS_SERVER(server));
|
||||||
|
|
||||||
|
if (server->connrec->chatnet == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
rec = chatnet_find(server->connrec->chatnet);
|
||||||
|
if (rec != NULL && rec->autosendcmd)
|
||||||
|
eval_special_string(rec->autosendcmd, "", server, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void chatnets_init(void)
|
||||||
|
{
|
||||||
|
signal_add("event connected", (SIGNAL_FUNC) sig_connected);
|
||||||
|
}
|
||||||
|
|
||||||
|
void chatnets_deinit(void)
|
||||||
|
{
|
||||||
|
while (chatnets != NULL)
|
||||||
|
chatnet_destroy(chatnets->data);
|
||||||
|
|
||||||
|
signal_remove("event connected", (SIGNAL_FUNC) sig_connected);
|
||||||
|
module_uniq_destroy("CHATNET");
|
||||||
|
}
|
37
src/core/chatnets.h
Normal file
37
src/core/chatnets.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#ifndef __CHATNETS_H
|
||||||
|
#define __CHATNETS_H
|
||||||
|
|
||||||
|
#include "modules.h"
|
||||||
|
|
||||||
|
#define IS_CHATNET(chatnet) \
|
||||||
|
((chatnet) != NULL && \
|
||||||
|
module_find_id("CHATNET", (chatnet)->type) != -1)
|
||||||
|
|
||||||
|
/* Returns CHATNET_REC if it's chatnet, NULL if it isn't. */
|
||||||
|
#define CHATNET(chatnet) \
|
||||||
|
(IS_CHATNET(chatnet) ? (CHATNET_REC *) (chatnet) : NULL)
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
#include "chatnet-rec.h"
|
||||||
|
} CHATNET_REC;
|
||||||
|
|
||||||
|
extern GSList *chatnets; /* list of available chat networks */
|
||||||
|
|
||||||
|
/* read/save to configuration file */
|
||||||
|
void chatnet_read(CHATNET_REC *chatnet, void *node);
|
||||||
|
void *chatnet_save(CHATNET_REC *chatnet, void *parentnode);
|
||||||
|
|
||||||
|
/* add the chatnet to chat networks list */
|
||||||
|
void chatnet_create(CHATNET_REC *chatnet);
|
||||||
|
/* remove the chatnet from chat networks list */
|
||||||
|
void chatnet_remove(CHATNET_REC *chatnet);
|
||||||
|
/* destroy the chatnet structure. doesn't remove from config file */
|
||||||
|
void chatnet_destroy(CHATNET_REC *chatnet);
|
||||||
|
|
||||||
|
/* Find the irc network by name */
|
||||||
|
CHATNET_REC *chatnet_find(const char *name);
|
||||||
|
|
||||||
|
void chatnets_init(void);
|
||||||
|
void chatnets_deinit(void);
|
||||||
|
|
||||||
|
#endif
|
@ -19,12 +19,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include "modules.h"
|
|
||||||
#include "signals.h"
|
#include "signals.h"
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "server.h"
|
#include "servers.h"
|
||||||
#include "server-redirect.h"
|
#include "servers-redirect.h"
|
||||||
#include "special-vars.h"
|
#include "special-vars.h"
|
||||||
|
|
||||||
#include "lib-config/iconfig.h"
|
#include "lib-config/iconfig.h"
|
||||||
@ -617,6 +616,8 @@ static void parse_command(const char *command, int expand_aliases,
|
|||||||
const char *alias, *newcmd;
|
const char *alias, *newcmd;
|
||||||
char *cmd, *orig, *args, *oldcmd;
|
char *cmd, *orig, *args, *oldcmd;
|
||||||
|
|
||||||
|
g_return_if_fail(command != NULL);
|
||||||
|
|
||||||
cmd = orig = g_strconcat("command ", command, NULL);
|
cmd = orig = g_strconcat("command ", command, NULL);
|
||||||
args = strchr(cmd+8, ' ');
|
args = strchr(cmd+8, ' ');
|
||||||
if (args != NULL) *args++ = '\0'; else args = "";
|
if (args != NULL) *args++ = '\0'; else args = "";
|
||||||
@ -643,7 +644,7 @@ static void parse_command(const char *command, int expand_aliases,
|
|||||||
|
|
||||||
cmd = g_strconcat("command ", newcmd, NULL);
|
cmd = g_strconcat("command ", newcmd, NULL);
|
||||||
if (server != NULL)
|
if (server != NULL)
|
||||||
server_redirect_default((SERVER_REC *) server, cmd);
|
server_redirect_default(SERVER(server), cmd);
|
||||||
|
|
||||||
g_strdown(cmd);
|
g_strdown(cmd);
|
||||||
oldcmd = current_command;
|
oldcmd = current_command;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
core.c : irssi
|
core.c : irssi
|
||||||
|
|
||||||
Copyright (C) 1999 Timo Sirainen
|
Copyright (C) 1999-2000 Timo Sirainen
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
|
|
||||||
#include "modules.h"
|
|
||||||
#include "pidwait.h"
|
#include "pidwait.h"
|
||||||
|
|
||||||
#include "net-disconnect.h"
|
#include "net-disconnect.h"
|
||||||
@ -28,12 +27,17 @@
|
|||||||
#include "signals.h"
|
#include "signals.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
#include "server.h"
|
#include "servers.h"
|
||||||
|
#include "chatnets.h"
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "rawlog.h"
|
#include "rawlog.h"
|
||||||
#include "special-vars.h"
|
#include "special-vars.h"
|
||||||
|
|
||||||
|
#include "channels.h"
|
||||||
|
#include "queries.h"
|
||||||
|
#include "nicklist.h"
|
||||||
|
|
||||||
int irssi_gui;
|
int irssi_gui;
|
||||||
|
|
||||||
void core_init(void)
|
void core_init(void)
|
||||||
@ -47,18 +51,28 @@ void core_init(void)
|
|||||||
settings_init();
|
settings_init();
|
||||||
commands_init();
|
commands_init();
|
||||||
|
|
||||||
|
chatnets_init();
|
||||||
servers_init();
|
servers_init();
|
||||||
log_init();
|
log_init();
|
||||||
rawlog_init();
|
rawlog_init();
|
||||||
special_vars_init();
|
special_vars_init();
|
||||||
|
|
||||||
|
channels_init();
|
||||||
|
queries_init();
|
||||||
|
nicklist_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void core_deinit(void)
|
void core_deinit(void)
|
||||||
{
|
{
|
||||||
|
nicklist_deinit();
|
||||||
|
queries_deinit();
|
||||||
|
channels_deinit();
|
||||||
|
|
||||||
special_vars_deinit();
|
special_vars_deinit();
|
||||||
rawlog_deinit();
|
rawlog_deinit();
|
||||||
log_deinit();
|
log_deinit();
|
||||||
servers_deinit();
|
servers_deinit();
|
||||||
|
chatnets_deinit();
|
||||||
|
|
||||||
commands_deinit();
|
commands_deinit();
|
||||||
settings_deinit();
|
settings_deinit();
|
||||||
|
137
src/core/masks.c
Normal file
137
src/core/masks.c
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
/*
|
||||||
|
masks.c : irssi
|
||||||
|
|
||||||
|
Copyright (C) 1999-2000 Timo Sirainen
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "module.h"
|
||||||
|
#include "network.h"
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
|
#include "servers.h"
|
||||||
|
|
||||||
|
typedef int (*MASK_MATCH_FUNC) (const char *, const char *);
|
||||||
|
|
||||||
|
/* Returns TRUE if mask contains '!' ie. address should be checked too.
|
||||||
|
Also checks if mask contained any wildcards. */
|
||||||
|
static int check_address(const char *mask, int *wildcards)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = FALSE;
|
||||||
|
while (*mask != '\0') {
|
||||||
|
if (*mask == '!') {
|
||||||
|
if (*wildcards) return TRUE;
|
||||||
|
ret = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*mask == '?' || *mask == '*') {
|
||||||
|
*wildcards = TRUE;
|
||||||
|
if (ret) return TRUE;
|
||||||
|
}
|
||||||
|
mask++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int check_mask(SERVER_REC *server, const char *mask,
|
||||||
|
const char *str, int wildcards)
|
||||||
|
{
|
||||||
|
MASK_MATCH_FUNC mask_match_func;
|
||||||
|
|
||||||
|
if (server != NULL && server->mask_match_func != NULL) {
|
||||||
|
/* use server specified mask match function */
|
||||||
|
mask_match_func = (MASK_MATCH_FUNC)server->mask_match_func;
|
||||||
|
return mask_match_func(mask, str);
|
||||||
|
}
|
||||||
|
|
||||||
|
return wildcards ? match_wildcards(mask, str) :
|
||||||
|
g_strcasecmp(mask, str) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int mask_match(SERVER_REC *server, const char *mask,
|
||||||
|
const char *nick, const char *user, const char *host)
|
||||||
|
{
|
||||||
|
char *str;
|
||||||
|
int ret, wildcards;
|
||||||
|
|
||||||
|
g_return_val_if_fail(server == NULL || IS_SERVER(server), FALSE);
|
||||||
|
g_return_val_if_fail(mask != NULL && nick != NULL &&
|
||||||
|
nick != NULL && host != NULL, FALSE);
|
||||||
|
|
||||||
|
str = !check_address(mask, &wildcards) ? (char *) nick :
|
||||||
|
g_strdup_printf("%s!%s@%s", nick, user, host);
|
||||||
|
ret = check_mask(server, mask, str, wildcards);
|
||||||
|
if (str != nick) g_free(str);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int mask_match_address(SERVER_REC *server, const char *mask,
|
||||||
|
const char *nick, const char *address)
|
||||||
|
{
|
||||||
|
char *str;
|
||||||
|
int ret, wildcards;
|
||||||
|
|
||||||
|
g_return_val_if_fail(server == NULL || IS_SERVER(server), FALSE);
|
||||||
|
g_return_val_if_fail(mask != NULL && nick != NULL, FALSE);
|
||||||
|
if (address == NULL) address = "";
|
||||||
|
|
||||||
|
str = !check_address(mask, &wildcards) ? (char *) nick :
|
||||||
|
g_strdup_printf("%s!%s", nick, address);
|
||||||
|
ret = check_mask(server, mask, str, wildcards);
|
||||||
|
if (str != nick) g_free(str);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int masks_match(SERVER_REC *server, const char *masks,
|
||||||
|
const char *nick, const char *address)
|
||||||
|
{
|
||||||
|
MASK_MATCH_FUNC mask_match_func;
|
||||||
|
char **list, **tmp, *mask;
|
||||||
|
int found;
|
||||||
|
|
||||||
|
g_return_val_if_fail(server == NULL || IS_SERVER(server), FALSE);
|
||||||
|
g_return_val_if_fail(masks != NULL &&
|
||||||
|
nick != NULL && address != NULL, FALSE);
|
||||||
|
|
||||||
|
mask_match_func = server != NULL && server->mask_match_func != NULL ?
|
||||||
|
(MASK_MATCH_FUNC) server->mask_match_func :
|
||||||
|
(MASK_MATCH_FUNC) match_wildcards;
|
||||||
|
|
||||||
|
found = FALSE;
|
||||||
|
mask = g_strdup_printf("%s!%s", nick, address);
|
||||||
|
list = g_strsplit(masks, " ", -1);
|
||||||
|
for (tmp = list; *tmp != NULL; tmp++) {
|
||||||
|
if (strchr(*tmp, '!') == NULL &&
|
||||||
|
g_strcasecmp(*tmp, nick) == 0) {
|
||||||
|
found = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mask_match_func(*tmp, mask)) {
|
||||||
|
found = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g_strfreev(list);
|
||||||
|
g_free(mask);
|
||||||
|
|
||||||
|
return found;
|
||||||
|
}
|
13
src/core/masks.h
Normal file
13
src/core/masks.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#ifndef __MASKS_H
|
||||||
|
#define __MASKS_H
|
||||||
|
|
||||||
|
#include "servers.h"
|
||||||
|
|
||||||
|
int mask_match(SERVER_REC *server, const char *mask,
|
||||||
|
const char *nick, const char *user, const char *host);
|
||||||
|
int mask_match_address(SERVER_REC *server, const char *mask,
|
||||||
|
const char *nick, const char *address);
|
||||||
|
int masks_match(SERVER_REC *server, const char *masks,
|
||||||
|
const char *nick, const char *address);
|
||||||
|
|
||||||
|
#endif
|
@ -38,7 +38,7 @@ typedef struct {
|
|||||||
static GHashTable *data = NULL, *preallocs = NULL;
|
static GHashTable *data = NULL, *preallocs = NULL;
|
||||||
static const char *comment = "";
|
static const char *comment = "";
|
||||||
|
|
||||||
static void add_flow_checks(guchar *p, unsigned long size)
|
static void add_flow_checks(char *p, unsigned long size)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_BUFFER_CHECKS
|
#ifdef ENABLE_BUFFER_CHECKS
|
||||||
int n;
|
int n;
|
||||||
@ -75,7 +75,7 @@ static void mem_check(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void data_add(void *p, int size, const char *file, int line)
|
static void data_add(char *p, int size, const char *file, int line)
|
||||||
{
|
{
|
||||||
MEM_REC *rec;
|
MEM_REC *rec;
|
||||||
|
|
||||||
@ -106,7 +106,19 @@ static void data_add(void *p, int size, const char *file, int line)
|
|||||||
mem_check();
|
mem_check();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *data_remove(void *p, const char *file, int line)
|
static void data_clear(char *p)
|
||||||
|
{
|
||||||
|
MEM_REC *rec;
|
||||||
|
|
||||||
|
if (g_hash_table_lookup(preallocs, p) != NULL)
|
||||||
|
p += BUFFER_CHECK_SIZE;
|
||||||
|
|
||||||
|
rec = g_hash_table_lookup(data, p);
|
||||||
|
if (rec != NULL && rec->size > 0)
|
||||||
|
memset(p, 'F', rec->size);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *data_remove(char *p, const char *file, int line)
|
||||||
{
|
{
|
||||||
MEM_REC *rec;
|
MEM_REC *rec;
|
||||||
|
|
||||||
@ -132,34 +144,34 @@ static void *data_remove(void *p, const char *file, int line)
|
|||||||
|
|
||||||
void *ig_malloc(int size, const char *file, int line)
|
void *ig_malloc(int size, const char *file, int line)
|
||||||
{
|
{
|
||||||
void *p;
|
char *p;
|
||||||
|
|
||||||
size += BUFFER_CHECK_SIZE*2;
|
size += BUFFER_CHECK_SIZE*2;
|
||||||
p = g_malloc(size);
|
p = g_malloc(size);
|
||||||
data_add(p, size, file, line);
|
data_add(p, size, file, line);
|
||||||
return p+BUFFER_CHECK_SIZE;
|
return (void *) (p+BUFFER_CHECK_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *ig_malloc0(int size, const char *file, int line)
|
void *ig_malloc0(int size, const char *file, int line)
|
||||||
{
|
{
|
||||||
void *p;
|
char *p;
|
||||||
|
|
||||||
size += BUFFER_CHECK_SIZE*2;
|
size += BUFFER_CHECK_SIZE*2;
|
||||||
p = g_malloc0(size);
|
p = g_malloc0(size);
|
||||||
data_add(p, size, file, line);
|
data_add(p, size, file, line);
|
||||||
return p+BUFFER_CHECK_SIZE;
|
return (void *) (p+BUFFER_CHECK_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *ig_realloc(void *mem, unsigned long size, const char *file, int line)
|
void *ig_realloc(void *mem, unsigned long size, const char *file, int line)
|
||||||
{
|
{
|
||||||
void *p;
|
char *p, *oldmem = mem;
|
||||||
|
|
||||||
size += BUFFER_CHECK_SIZE*2;
|
size += BUFFER_CHECK_SIZE*2;
|
||||||
mem -= BUFFER_CHECK_SIZE;
|
oldmem -= BUFFER_CHECK_SIZE;
|
||||||
data_remove(mem, file, line);
|
data_remove(oldmem, file, line);
|
||||||
p = g_realloc(mem, size);
|
p = g_realloc(oldmem, size);
|
||||||
data_add(p, size, file, line);
|
data_add(p, size, file, line);
|
||||||
return p+BUFFER_CHECK_SIZE;
|
return (void *) (p+BUFFER_CHECK_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *ig_strdup(const char *str, const char *file, int line)
|
char *ig_strdup(const char *str, const char *file, int line)
|
||||||
@ -252,11 +264,14 @@ char *ig_strdup_vprintf(const char *file, int line, const char *format, va_list
|
|||||||
|
|
||||||
void ig_free(void *p)
|
void ig_free(void *p)
|
||||||
{
|
{
|
||||||
if (p == NULL) g_error("ig_free() : trying to free NULL");
|
char *cp = p;
|
||||||
|
|
||||||
p -= BUFFER_CHECK_SIZE;
|
if (cp == NULL) g_error("ig_free() : trying to free NULL");
|
||||||
p = data_remove(p, "??", 0);
|
|
||||||
if (p != NULL) g_free(p);
|
cp -= BUFFER_CHECK_SIZE;
|
||||||
|
data_clear(cp);
|
||||||
|
cp = data_remove(cp, "??", 0);
|
||||||
|
if (cp != NULL) g_free(cp);
|
||||||
}
|
}
|
||||||
|
|
||||||
GString *ig_string_new(const char *file, int line, const char *str)
|
GString *ig_string_new(const char *file, int line, const char *str)
|
||||||
@ -264,13 +279,13 @@ GString *ig_string_new(const char *file, int line, const char *str)
|
|||||||
GString *ret;
|
GString *ret;
|
||||||
|
|
||||||
ret = g_string_new(str);
|
ret = g_string_new(str);
|
||||||
data_add(ret, INT_MIN, file, line);
|
data_add((void *) ret, INT_MIN, file, line);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ig_string_free(const char *file, int line, GString *str, gboolean freeit)
|
void ig_string_free(const char *file, int line, GString *str, gboolean freeit)
|
||||||
{
|
{
|
||||||
data_remove(str, file, line);
|
data_remove((void *) str, file, line);
|
||||||
if (!freeit)
|
if (!freeit)
|
||||||
data_add(str->str, INT_MIN, file, line);
|
data_add(str->str, INT_MIN, file, line);
|
||||||
|
|
||||||
@ -304,7 +319,7 @@ void ig_profile_line(void *key, MEM_REC *rec)
|
|||||||
strcmp(rec->file, "ig_strdup_vprintf") == 0 ||
|
strcmp(rec->file, "ig_strdup_vprintf") == 0 ||
|
||||||
strcmp(rec->file, "ig_strconcat") == 0 ||
|
strcmp(rec->file, "ig_strconcat") == 0 ||
|
||||||
strcmp(rec->file, "ig_string_free (free = FALSE)") == 0))
|
strcmp(rec->file, "ig_string_free (free = FALSE)") == 0))
|
||||||
data = rec->p + BUFFER_CHECK_SIZE;
|
data = (char *) rec->p + BUFFER_CHECK_SIZE;
|
||||||
else
|
else
|
||||||
data = rec->comment;
|
data = rec->comment;
|
||||||
fprintf(stderr, "%s:%d %d bytes (%s)\n", rec->file, rec->line, rec->size, data);
|
fprintf(stderr, "%s:%d %d bytes (%s)\n", rec->file, rec->line, rec->size, data);
|
||||||
|
@ -196,12 +196,12 @@ GSList *gslist_find_icase_string(GSList *list, const char *key)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *gslist_foreach_find(GSList *list, FOREACH_FIND_FUNC func, void *data)
|
void *gslist_foreach_find(GSList *list, FOREACH_FIND_FUNC func, const void *data)
|
||||||
{
|
{
|
||||||
void *ret;
|
void *ret;
|
||||||
|
|
||||||
while (list != NULL) {
|
while (list != NULL) {
|
||||||
ret = func(list->data, data);
|
ret = func(list->data, (void *) data);
|
||||||
if (ret != NULL) return ret;
|
if (ret != NULL) return ret;
|
||||||
|
|
||||||
list = list->next;
|
list = list->next;
|
||||||
|
@ -23,7 +23,7 @@ GSList *gslist_find_icase_string(GSList *list, const char *key);
|
|||||||
GList *glist_find_string(GList *list, const char *key);
|
GList *glist_find_string(GList *list, const char *key);
|
||||||
GList *glist_find_icase_string(GList *list, const char *key);
|
GList *glist_find_icase_string(GList *list, const char *key);
|
||||||
|
|
||||||
void *gslist_foreach_find(GSList *list, FOREACH_FIND_FUNC func, void *data);
|
void *gslist_foreach_find(GSList *list, FOREACH_FIND_FUNC func, const void *data);
|
||||||
|
|
||||||
/* `list' contains pointer to structure with a char* to string. */
|
/* `list' contains pointer to structure with a char* to string. */
|
||||||
char *gslistptr_to_string(GSList *list, int offset, const char *delimiter);
|
char *gslistptr_to_string(GSList *list, int offset, const char *delimiter);
|
||||||
|
@ -324,6 +324,11 @@ void module_unload(MODULE_REC *module)
|
|||||||
g_free(module);
|
g_free(module);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void uniq_get_modules(char *key, void *value, GSList **list)
|
||||||
|
{
|
||||||
|
*list = g_slist_append(*list, key);
|
||||||
|
}
|
||||||
|
|
||||||
void modules_init(void)
|
void modules_init(void)
|
||||||
{
|
{
|
||||||
modules = NULL;
|
modules = NULL;
|
||||||
@ -342,11 +347,19 @@ void modules_init(void)
|
|||||||
|
|
||||||
void modules_deinit(void)
|
void modules_deinit(void)
|
||||||
{
|
{
|
||||||
g_hash_table_foreach(idlookup, (GHFunc) module_uniq_destroy, NULL);
|
GSList *list;
|
||||||
g_hash_table_destroy(idlookup);
|
|
||||||
g_hash_table_destroy(uniqids);
|
|
||||||
|
|
||||||
g_hash_table_foreach(stridlookup, (GHFunc) module_uniq_destroy, NULL);
|
list = NULL;
|
||||||
|
g_hash_table_foreach(idlookup, (GHFunc) uniq_get_modules, &list);
|
||||||
|
g_hash_table_foreach(stridlookup, (GHFunc) uniq_get_modules, &list);
|
||||||
|
|
||||||
|
while (list != NULL) {
|
||||||
|
module_uniq_destroy(list->data);
|
||||||
|
list = g_slist_remove(list, list->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_hash_table_destroy(idlookup);
|
||||||
g_hash_table_destroy(stridlookup);
|
g_hash_table_destroy(stridlookup);
|
||||||
|
g_hash_table_destroy(uniqids);
|
||||||
g_hash_table_destroy(uniqstrids);
|
g_hash_table_destroy(uniqstrids);
|
||||||
}
|
}
|
||||||
|
268
src/core/nicklist.c
Normal file
268
src/core/nicklist.c
Normal file
@ -0,0 +1,268 @@
|
|||||||
|
/*
|
||||||
|
nicklist.c : irssi
|
||||||
|
|
||||||
|
Copyright (C) 1999-2000 Timo Sirainen
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "module.h"
|
||||||
|
#include "signals.h"
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
|
#include "nicklist.h"
|
||||||
|
#include "masks.h"
|
||||||
|
|
||||||
|
/* Add new nick to list */
|
||||||
|
NICK_REC *nicklist_insert(CHANNEL_REC *channel, const char *nick,
|
||||||
|
int op, int voice, int send_massjoin)
|
||||||
|
{
|
||||||
|
NICK_REC *rec;
|
||||||
|
|
||||||
|
g_return_val_if_fail(IS_CHANNEL(channel), NULL);
|
||||||
|
g_return_val_if_fail(nick != NULL, NULL);
|
||||||
|
|
||||||
|
rec = g_new0(NICK_REC, 1);
|
||||||
|
|
||||||
|
if (op) rec->op = TRUE;
|
||||||
|
if (voice) rec->voice = TRUE;
|
||||||
|
|
||||||
|
rec->send_massjoin = send_massjoin;
|
||||||
|
rec->nick = g_strdup(nick);
|
||||||
|
rec->host = NULL;
|
||||||
|
|
||||||
|
g_hash_table_insert(channel->nicks, rec->nick, rec);
|
||||||
|
signal_emit("nicklist new", 2, channel, rec);
|
||||||
|
return rec;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void nicklist_destroy(CHANNEL_REC *channel, NICK_REC *nick)
|
||||||
|
{
|
||||||
|
signal_emit("nicklist remove", 2, channel, nick);
|
||||||
|
|
||||||
|
g_free(nick->nick);
|
||||||
|
g_free_not_null(nick->realname);
|
||||||
|
g_free_not_null(nick->host);
|
||||||
|
g_free(nick);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* remove nick from list */
|
||||||
|
void nicklist_remove(CHANNEL_REC *channel, NICK_REC *nick)
|
||||||
|
{
|
||||||
|
g_return_if_fail(IS_CHANNEL(channel));
|
||||||
|
g_return_if_fail(nick != NULL);
|
||||||
|
|
||||||
|
g_hash_table_remove(channel->nicks, nick->nick);
|
||||||
|
nicklist_destroy(channel, nick);
|
||||||
|
}
|
||||||
|
|
||||||
|
static NICK_REC *nicklist_find_wildcards(CHANNEL_REC *channel,
|
||||||
|
const char *mask)
|
||||||
|
{
|
||||||
|
GSList *nicks, *tmp;
|
||||||
|
NICK_REC *nick;
|
||||||
|
|
||||||
|
nicks = nicklist_getnicks(channel);
|
||||||
|
nick = NULL;
|
||||||
|
for (tmp = nicks; tmp != NULL; tmp = tmp->next) {
|
||||||
|
nick = tmp->data;
|
||||||
|
|
||||||
|
if (mask_match_address(channel->server, mask,
|
||||||
|
nick->nick, nick->host))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
g_slist_free(nicks);
|
||||||
|
return tmp == NULL ? NULL : nick;
|
||||||
|
}
|
||||||
|
|
||||||
|
GSList *nicklist_find_multiple(CHANNEL_REC *channel, const char *mask)
|
||||||
|
{
|
||||||
|
GSList *nicks, *tmp, *next;
|
||||||
|
|
||||||
|
g_return_val_if_fail(IS_CHANNEL(channel), NULL);
|
||||||
|
g_return_val_if_fail(mask != NULL, NULL);
|
||||||
|
|
||||||
|
nicks = nicklist_getnicks(channel);
|
||||||
|
for (tmp = nicks; tmp != NULL; tmp = next) {
|
||||||
|
NICK_REC *nick = tmp->data;
|
||||||
|
|
||||||
|
next = tmp->next;
|
||||||
|
if (!mask_match_address(channel->server, mask,
|
||||||
|
nick->nick, nick->host))
|
||||||
|
nicks = g_slist_remove(nicks, tmp->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return nicks;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Find nick record from list */
|
||||||
|
NICK_REC *nicklist_find(CHANNEL_REC *channel, const char *mask)
|
||||||
|
{
|
||||||
|
NICK_REC *nickrec;
|
||||||
|
char *nick, *host;
|
||||||
|
|
||||||
|
g_return_val_if_fail(IS_CHANNEL(channel), NULL);
|
||||||
|
g_return_val_if_fail(mask != NULL, NULL);
|
||||||
|
|
||||||
|
nick = g_strdup(mask);
|
||||||
|
host = strchr(nick, '!');
|
||||||
|
if (host != NULL) *host++ = '\0';
|
||||||
|
|
||||||
|
if (strchr(nick, '*') || strchr(nick, '?')) {
|
||||||
|
g_free(nick);
|
||||||
|
return nicklist_find_wildcards(channel, mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
nickrec = g_hash_table_lookup(channel->nicks, nick);
|
||||||
|
|
||||||
|
if (nickrec != NULL && host != NULL &&
|
||||||
|
(nickrec->host == NULL || !match_wildcards(host, nickrec->host))) {
|
||||||
|
/* hosts didn't match */
|
||||||
|
nickrec = NULL;
|
||||||
|
}
|
||||||
|
g_free(nick);
|
||||||
|
return nickrec;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void get_nicks_hash(gpointer key, NICK_REC *rec, GSList **list)
|
||||||
|
{
|
||||||
|
*list = g_slist_append(*list, rec);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get list of nicks */
|
||||||
|
GSList *nicklist_getnicks(CHANNEL_REC *channel)
|
||||||
|
{
|
||||||
|
GSList *list;
|
||||||
|
|
||||||
|
g_return_val_if_fail(IS_CHANNEL(channel), NULL);
|
||||||
|
|
||||||
|
list = NULL;
|
||||||
|
g_hash_table_foreach(channel->nicks, (GHFunc) get_nicks_hash, &list);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
CHANNEL_REC *channel;
|
||||||
|
const char *nick;
|
||||||
|
GSList *list;
|
||||||
|
} NICKLIST_GET_SAME_REC;
|
||||||
|
|
||||||
|
static void get_nicks_same_hash(gpointer key, NICK_REC *nick,
|
||||||
|
NICKLIST_GET_SAME_REC *rec)
|
||||||
|
{
|
||||||
|
if (g_strcasecmp(nick->nick, rec->nick) == 0) {
|
||||||
|
rec->list = g_slist_append(rec->list, rec->channel);
|
||||||
|
rec->list = g_slist_append(rec->list, nick);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GSList *nicklist_get_same(SERVER_REC *server, const char *nick)
|
||||||
|
{
|
||||||
|
NICKLIST_GET_SAME_REC rec;
|
||||||
|
GSList *tmp;
|
||||||
|
|
||||||
|
g_return_val_if_fail(IS_SERVER(server), NULL);
|
||||||
|
|
||||||
|
rec.nick = nick;
|
||||||
|
rec.list = NULL;
|
||||||
|
for (tmp = server->channels; tmp != NULL; tmp = tmp->next) {
|
||||||
|
rec.channel = tmp->data;
|
||||||
|
g_hash_table_foreach(rec.channel->nicks,
|
||||||
|
(GHFunc) get_nicks_same_hash, &rec);
|
||||||
|
}
|
||||||
|
return rec.list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* nick record comparision for sort functions */
|
||||||
|
int nicklist_compare(NICK_REC *p1, NICK_REC *p2)
|
||||||
|
{
|
||||||
|
if (p1 == NULL) return -1;
|
||||||
|
if (p2 == NULL) return 1;
|
||||||
|
|
||||||
|
if (p1->op && !p2->op) return -1;
|
||||||
|
if (!p1->op && p2->op) return 1;
|
||||||
|
|
||||||
|
if (!p1->op) {
|
||||||
|
if (p1->voice && !p2->voice) return -1;
|
||||||
|
if (!p1->voice && p2->voice) return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_strcasecmp(p1->nick, p2->nick);
|
||||||
|
}
|
||||||
|
|
||||||
|
void nicklist_update_flags(SERVER_REC *server, const char *nick,
|
||||||
|
int gone, int serverop)
|
||||||
|
{
|
||||||
|
GSList *nicks, *tmp;
|
||||||
|
CHANNEL_REC *channel;
|
||||||
|
NICK_REC *rec;
|
||||||
|
|
||||||
|
g_return_if_fail(IS_SERVER(server));
|
||||||
|
g_return_if_fail(nick != NULL);
|
||||||
|
|
||||||
|
nicks = nicklist_get_same(server, nick);
|
||||||
|
for (tmp = nicks; tmp != NULL; tmp = tmp->next->next) {
|
||||||
|
channel = tmp->data;
|
||||||
|
rec = tmp->next->data;
|
||||||
|
|
||||||
|
rec->last_check = time(NULL);
|
||||||
|
|
||||||
|
if (gone != -1 && rec->gone != gone) {
|
||||||
|
rec->gone = gone;
|
||||||
|
signal_emit("nick gone changed", 2, channel, rec);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (serverop != -1 && rec->serverop != serverop) {
|
||||||
|
rec->serverop = serverop;
|
||||||
|
signal_emit("nick serverop changed", 2, channel, rec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g_slist_free(nicks);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void sig_channel_created(CHANNEL_REC *channel)
|
||||||
|
{
|
||||||
|
g_return_if_fail(IS_CHANNEL(channel));
|
||||||
|
|
||||||
|
channel->nicks = g_hash_table_new((GHashFunc) g_istr_hash,
|
||||||
|
(GCompareFunc) g_istr_equal);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void nicklist_remove_hash(gpointer key, NICK_REC *nick,
|
||||||
|
CHANNEL_REC *channel)
|
||||||
|
{
|
||||||
|
nicklist_destroy(channel, nick);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void sig_channel_destroyed(CHANNEL_REC *channel)
|
||||||
|
{
|
||||||
|
g_return_if_fail(IS_CHANNEL(channel));
|
||||||
|
|
||||||
|
g_hash_table_foreach(channel->nicks,
|
||||||
|
(GHFunc) nicklist_remove_hash, channel);
|
||||||
|
g_hash_table_destroy(channel->nicks);
|
||||||
|
}
|
||||||
|
|
||||||
|
void nicklist_init(void)
|
||||||
|
{
|
||||||
|
signal_add_first("channel created", (SIGNAL_FUNC) sig_channel_created);
|
||||||
|
signal_add("channel destroyed", (SIGNAL_FUNC) sig_channel_destroyed);
|
||||||
|
}
|
||||||
|
|
||||||
|
void nicklist_deinit(void)
|
||||||
|
{
|
||||||
|
signal_remove("channel created", (SIGNAL_FUNC) sig_channel_created);
|
||||||
|
signal_remove("channel destroyed", (SIGNAL_FUNC) sig_channel_destroyed);
|
||||||
|
}
|
@ -1,28 +1,31 @@
|
|||||||
#ifndef __NICKLIST_H
|
#ifndef __NICKLIST_H
|
||||||
#define __NICKLIST_H
|
#define __NICKLIST_H
|
||||||
|
|
||||||
#include "irc-server.h"
|
#include "servers.h"
|
||||||
#include "channels.h"
|
#include "channels.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
time_t last_check; /* last time gone was checked */
|
time_t last_check; /* last time gone was checked */
|
||||||
int send_massjoin; /* Waiting to be sent in massjoin signal */
|
|
||||||
|
|
||||||
char *nick;
|
char *nick;
|
||||||
char *host;
|
char *host;
|
||||||
char *realname;
|
char *realname;
|
||||||
|
|
||||||
int hops;
|
int hops;
|
||||||
|
|
||||||
|
/* status in server */
|
||||||
|
int gone:1;
|
||||||
|
int serverop:1;
|
||||||
|
|
||||||
|
/* status in channel */
|
||||||
|
int send_massjoin:1; /* Waiting to be sent in massjoin signal */
|
||||||
int op:1;
|
int op:1;
|
||||||
int halfop:1;
|
int halfop:1;
|
||||||
int voice:1;
|
int voice:1;
|
||||||
int gone:1;
|
|
||||||
int ircop:1;
|
|
||||||
} NICK_REC;
|
} NICK_REC;
|
||||||
|
|
||||||
/* Add new nick to list */
|
/* Add new nick to list */
|
||||||
NICK_REC *nicklist_insert(CHANNEL_REC *channel, const char *nick, int op, int voice, int send_massjoin);
|
NICK_REC *nicklist_insert(CHANNEL_REC *channel, const char *nick,
|
||||||
|
int op, int voice, int send_massjoin);
|
||||||
/* remove nick from list */
|
/* remove nick from list */
|
||||||
void nicklist_remove(CHANNEL_REC *channel, NICK_REC *nick);
|
void nicklist_remove(CHANNEL_REC *channel, NICK_REC *nick);
|
||||||
/* Find nick record from list */
|
/* Find nick record from list */
|
||||||
@ -32,16 +35,15 @@ GSList *nicklist_find_multiple(CHANNEL_REC *channel, const char *mask);
|
|||||||
/* Get list of nicks */
|
/* Get list of nicks */
|
||||||
GSList *nicklist_getnicks(CHANNEL_REC *channel);
|
GSList *nicklist_getnicks(CHANNEL_REC *channel);
|
||||||
/* Get all the nick records of `nick'. Returns channel, nick, channel, ... */
|
/* Get all the nick records of `nick'. Returns channel, nick, channel, ... */
|
||||||
GSList *nicklist_get_same(IRC_SERVER_REC *server, const char *nick);
|
GSList *nicklist_get_same(SERVER_REC *server, const char *nick);
|
||||||
|
|
||||||
|
/* Update specified nick's status in server. */
|
||||||
|
void nicklist_update_flags(SERVER_REC *server, const char *nick,
|
||||||
|
int gone, int ircop);
|
||||||
|
|
||||||
/* Nick record comparision for sort functions */
|
/* Nick record comparision for sort functions */
|
||||||
int nicklist_compare(NICK_REC *p1, NICK_REC *p2);
|
int nicklist_compare(NICK_REC *p1, NICK_REC *p2);
|
||||||
|
|
||||||
/* Remove all "extra" characters from `nick'. Like _nick_ -> nick */
|
|
||||||
char *nick_strip(const char *nick);
|
|
||||||
/* Check is `msg' is meant for `nick'. */
|
|
||||||
int irc_nick_match(const char *nick, const char *msg);
|
|
||||||
|
|
||||||
void nicklist_init(void);
|
void nicklist_init(void);
|
||||||
void nicklist_deinit(void);
|
void nicklist_deinit(void);
|
||||||
|
|
124
src/core/queries.c
Normal file
124
src/core/queries.c
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
/*
|
||||||
|
queries.c : irssi
|
||||||
|
|
||||||
|
Copyright (C) 1999-2000 Timo Sirainen
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "module.h"
|
||||||
|
#include "signals.h"
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
|
#include "queries.h"
|
||||||
|
|
||||||
|
GSList *queries;
|
||||||
|
|
||||||
|
typedef QUERY_REC *(*QUERY_FIND_FUNC)(SERVER_REC *, const char *);
|
||||||
|
|
||||||
|
void query_init(QUERY_REC *query, int automatic)
|
||||||
|
{
|
||||||
|
g_return_if_fail(query != NULL);
|
||||||
|
g_return_if_fail(query->name != NULL);
|
||||||
|
|
||||||
|
queries = g_slist_append(queries, query);
|
||||||
|
if (query->server != NULL) {
|
||||||
|
query->server->queries =
|
||||||
|
g_slist_append(query->server->queries, query);
|
||||||
|
}
|
||||||
|
|
||||||
|
MODULE_DATA_INIT(query);
|
||||||
|
query->type = module_get_uniq_id("QUERY", 0);
|
||||||
|
if (query->server != NULL)
|
||||||
|
query->server_tag = g_strdup(query->server->tag);
|
||||||
|
|
||||||
|
signal_emit("query created", 2, query, GINT_TO_POINTER(automatic));
|
||||||
|
}
|
||||||
|
|
||||||
|
void query_destroy(QUERY_REC *query)
|
||||||
|
{
|
||||||
|
g_return_if_fail(IS_QUERY(query));
|
||||||
|
|
||||||
|
if (query->destroying) return;
|
||||||
|
query->destroying = TRUE;
|
||||||
|
|
||||||
|
queries = g_slist_remove(queries, query);
|
||||||
|
if (query->server != NULL) {
|
||||||
|
query->server->queries =
|
||||||
|
g_slist_remove(query->server->queries, query);
|
||||||
|
}
|
||||||
|
signal_emit("query destroyed", 1, query);
|
||||||
|
|
||||||
|
MODULE_DATA_DEINIT(query);
|
||||||
|
g_free_not_null(query->address);
|
||||||
|
g_free(query->name);
|
||||||
|
g_free(query->server_tag);
|
||||||
|
g_free(query);
|
||||||
|
}
|
||||||
|
|
||||||
|
static QUERY_REC *query_find_server(SERVER_REC *server, const char *nick)
|
||||||
|
{
|
||||||
|
GSList *tmp;
|
||||||
|
|
||||||
|
g_return_val_if_fail(IS_SERVER(server), NULL);
|
||||||
|
|
||||||
|
if (server->query_find_func != NULL) {
|
||||||
|
/* use the server specific query find function */
|
||||||
|
QUERY_FIND_FUNC query_find_func;
|
||||||
|
query_find_func = (QUERY_FIND_FUNC) server->query_find_func;
|
||||||
|
return query_find_func(server, nick);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (tmp = server->queries; tmp != NULL; tmp = tmp->next) {
|
||||||
|
QUERY_REC *rec = tmp->data;
|
||||||
|
|
||||||
|
if (rec->chat_type == server->query_type &&
|
||||||
|
g_strcasecmp(nick, rec->name) == 0)
|
||||||
|
return rec;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
QUERY_REC *query_find(SERVER_REC *server, const char *nick)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail(server == NULL || IS_SERVER(server), NULL);
|
||||||
|
g_return_val_if_fail(nick != NULL, NULL);
|
||||||
|
|
||||||
|
if (server != NULL)
|
||||||
|
return query_find_server(server, nick);
|
||||||
|
|
||||||
|
/* find from any server */
|
||||||
|
return gslist_foreach_find(servers,
|
||||||
|
(FOREACH_FIND_FUNC) query_find_server,
|
||||||
|
(void *) nick);
|
||||||
|
}
|
||||||
|
|
||||||
|
void query_change_server(QUERY_REC *query, SERVER_REC *server)
|
||||||
|
{
|
||||||
|
g_return_if_fail(IS_QUERY(query));
|
||||||
|
|
||||||
|
query->server = server;
|
||||||
|
signal_emit("query server changed", 2, query, server);
|
||||||
|
}
|
||||||
|
|
||||||
|
void queries_init(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void queries_deinit(void)
|
||||||
|
{
|
||||||
|
module_uniq_destroy("QUERY");
|
||||||
|
}
|
32
src/core/queries.h
Normal file
32
src/core/queries.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#ifndef __QUERIES_H
|
||||||
|
#define __QUERIES_H
|
||||||
|
|
||||||
|
#include "servers.h"
|
||||||
|
|
||||||
|
#define IS_QUERY(query) \
|
||||||
|
((query) != NULL && \
|
||||||
|
module_find_id("QUERY", ((QUERY_REC *) (query))->type) != -1)
|
||||||
|
|
||||||
|
/* Returns QUERY_REC if it's query, NULL if it isn't. */
|
||||||
|
#define QUERY(query) \
|
||||||
|
(IS_QUERY(query) ? (QUERY_REC *) (query) : NULL)
|
||||||
|
|
||||||
|
#define STRUCT_SERVER_REC SERVER_REC
|
||||||
|
typedef struct {
|
||||||
|
#include "query-rec.h"
|
||||||
|
} QUERY_REC;
|
||||||
|
|
||||||
|
extern GSList *queries;
|
||||||
|
|
||||||
|
void query_init(QUERY_REC *query, int automatic);
|
||||||
|
void query_destroy(QUERY_REC *query);
|
||||||
|
|
||||||
|
/* Find query by name, if `server' is NULL, search from all servers */
|
||||||
|
QUERY_REC *query_find(SERVER_REC *server, const char *nick);
|
||||||
|
|
||||||
|
void query_change_server(QUERY_REC *query, SERVER_REC *server);
|
||||||
|
|
||||||
|
void queries_init(void);
|
||||||
|
void queries_deinit(void);
|
||||||
|
|
||||||
|
#endif
|
9
src/core/query-rec.h
Normal file
9
src/core/query-rec.h
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
/* QUERY_REC definition, used for inheritance */
|
||||||
|
|
||||||
|
#include "window-item-rec.h"
|
||||||
|
|
||||||
|
char *address;
|
||||||
|
char *server_tag;
|
||||||
|
int unwanted:1; /* TRUE if the other side closed or
|
||||||
|
some error occured (DCC chats!) */
|
||||||
|
int destroying:1;
|
26
src/core/server-connect-rec.h
Normal file
26
src/core/server-connect-rec.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/* SERVER_CONNECT_REC definition, used for inheritance */
|
||||||
|
|
||||||
|
int type;
|
||||||
|
int chat_type;
|
||||||
|
|
||||||
|
/* if we're connecting via proxy, or just NULLs */
|
||||||
|
char *proxy;
|
||||||
|
int proxy_port;
|
||||||
|
char *proxy_string;
|
||||||
|
|
||||||
|
char *address;
|
||||||
|
int port;
|
||||||
|
char *chatnet;
|
||||||
|
|
||||||
|
IPADDR *own_ip;
|
||||||
|
|
||||||
|
char *password;
|
||||||
|
char *nick;
|
||||||
|
char *username;
|
||||||
|
char *realname;
|
||||||
|
|
||||||
|
/* when reconnecting, the old server status */
|
||||||
|
int reconnection:1; /* we're trying to reconnect */
|
||||||
|
char *channels;
|
||||||
|
char *away_reason;
|
||||||
|
char *usermode;
|
50
src/core/server-rec.h
Normal file
50
src/core/server-rec.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/* SERVER_REC definition, used for inheritance */
|
||||||
|
|
||||||
|
int type; /* should always be "SERVER" */
|
||||||
|
int chat_type;
|
||||||
|
|
||||||
|
STRUCT_SERVER_CONNECT_REC *connrec;
|
||||||
|
time_t connect_time; /* connection time */
|
||||||
|
time_t real_connect_time; /* time when server replied that we really are connected */
|
||||||
|
|
||||||
|
char *tag; /* tag name for addressing server */
|
||||||
|
char *nick; /* current nick */
|
||||||
|
|
||||||
|
int connected:1; /* connected to server */
|
||||||
|
int connection_lost:1; /* Connection lost unintentionally */
|
||||||
|
|
||||||
|
void *handle; /* NET_SENDBUF_REC socket */
|
||||||
|
int readtag; /* input tag */
|
||||||
|
|
||||||
|
/* for net_connect_nonblock() */
|
||||||
|
int connect_pipe[2];
|
||||||
|
int connect_tag;
|
||||||
|
int connect_pid;
|
||||||
|
|
||||||
|
/* For deciding if event should be handled internally */
|
||||||
|
GHashTable *eventtable; /* "event xxx" : GSList* of REDIRECT_RECs */
|
||||||
|
GHashTable *eventgrouptable; /* event group : GSList* of REDIRECT_RECs */
|
||||||
|
GHashTable *cmdtable; /* "command xxx" : REDIRECT_CMD_REC* */
|
||||||
|
|
||||||
|
void *rawlog;
|
||||||
|
void *buffer; /* receive buffer */
|
||||||
|
GHashTable *module_data;
|
||||||
|
|
||||||
|
char *version; /* server version */
|
||||||
|
char *away_reason;
|
||||||
|
int server_operator:1;
|
||||||
|
int usermode_away:1;
|
||||||
|
int banned:1; /* not allowed to connect to this server */
|
||||||
|
|
||||||
|
GSList *channels;
|
||||||
|
GSList *queries;
|
||||||
|
|
||||||
|
/* support for multiple server types */
|
||||||
|
void *channel_find_func;
|
||||||
|
void *query_find_func;
|
||||||
|
int channel_type;
|
||||||
|
int query_type;
|
||||||
|
|
||||||
|
void *mask_match_func;
|
||||||
|
|
||||||
|
#undef STRUCT_SERVER_CONNECT_REC
|
19
src/core/server-setup-rec.h
Normal file
19
src/core/server-setup-rec.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
int type;
|
||||||
|
int chat_type;
|
||||||
|
|
||||||
|
char *chatnet;
|
||||||
|
|
||||||
|
char *address;
|
||||||
|
int port;
|
||||||
|
char *password;
|
||||||
|
|
||||||
|
char *own_host; /* address to use when connecting this server */
|
||||||
|
IPADDR *own_ip; /* resolved own_address if not NULL */
|
||||||
|
|
||||||
|
time_t last_connect; /* to avoid reconnecting too fast.. */
|
||||||
|
|
||||||
|
int autoconnect:1;
|
||||||
|
int last_failed:1; /* if last connection attempt failed */
|
||||||
|
int banned:1; /* if we're banned from this server */
|
||||||
|
|
||||||
|
GHashTable *module_data;
|
@ -1,83 +0,0 @@
|
|||||||
#ifndef __SERVER_H
|
|
||||||
#define __SERVER_H
|
|
||||||
|
|
||||||
#ifndef __NETWORK_H
|
|
||||||
typedef struct _ipaddr IPADDR;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* all strings should be either NULL or dynamically allocated */
|
|
||||||
/* address and nick are mandatory, rest are optional */
|
|
||||||
typedef struct {
|
|
||||||
/* if we're connecting via proxy, or just NULLs */
|
|
||||||
char *proxy;
|
|
||||||
int proxy_port;
|
|
||||||
char *proxy_string;
|
|
||||||
|
|
||||||
char *address;
|
|
||||||
int port;
|
|
||||||
char *ircnet;
|
|
||||||
|
|
||||||
IPADDR *own_ip;
|
|
||||||
|
|
||||||
char *password;
|
|
||||||
char *nick;
|
|
||||||
char *username;
|
|
||||||
char *realname;
|
|
||||||
|
|
||||||
/* when reconnecting, the old server status */
|
|
||||||
int reconnection:1; /* we're trying to reconnect */
|
|
||||||
char *channels;
|
|
||||||
char *away_reason;
|
|
||||||
char *usermode;
|
|
||||||
} SERVER_CONNECT_REC;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int type; /* server type */
|
|
||||||
|
|
||||||
SERVER_CONNECT_REC *connrec;
|
|
||||||
time_t connect_time; /* connection time */
|
|
||||||
time_t real_connect_time; /* time when server replied that we really are connected */
|
|
||||||
|
|
||||||
char *tag; /* tag name for addressing server */
|
|
||||||
char *nick; /* current nick */
|
|
||||||
|
|
||||||
int connected:1; /* connected to server */
|
|
||||||
int connection_lost:1; /* Connection lost unintentionally */
|
|
||||||
|
|
||||||
void *handle; /* NET_SENDBUF_REC socket */
|
|
||||||
int readtag; /* input tag */
|
|
||||||
|
|
||||||
/* for net_connect_nonblock() */
|
|
||||||
int connect_pipe[2];
|
|
||||||
int connect_tag;
|
|
||||||
int connect_pid;
|
|
||||||
|
|
||||||
/* For deciding if event should be handled internally */
|
|
||||||
GHashTable *eventtable; /* "event xxx" : GSList* of REDIRECT_RECs */
|
|
||||||
GHashTable *eventgrouptable; /* event group : GSList* of REDIRECT_RECs */
|
|
||||||
GHashTable *cmdtable; /* "command xxx" : REDIRECT_CMD_REC* */
|
|
||||||
|
|
||||||
void *rawlog;
|
|
||||||
void *buffer; /* receive buffer */
|
|
||||||
GHashTable *module_data;
|
|
||||||
|
|
||||||
char *version; /* server version */
|
|
||||||
char *away_reason;
|
|
||||||
int usermode_away:1;
|
|
||||||
int banned:1; /* not allowed to connect to this server */
|
|
||||||
} SERVER_REC;
|
|
||||||
|
|
||||||
extern GSList *servers, *lookup_servers;
|
|
||||||
|
|
||||||
/* Connect to server */
|
|
||||||
int server_connect(SERVER_REC *server);
|
|
||||||
/* Disconnect from server */
|
|
||||||
void server_disconnect(SERVER_REC *server);
|
|
||||||
|
|
||||||
SERVER_REC *server_find_tag(const char *tag);
|
|
||||||
SERVER_REC *server_find_ircnet(const char *ircnet);
|
|
||||||
|
|
||||||
void servers_init(void);
|
|
||||||
void servers_deinit(void);
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
server-reconnect.c : irssi
|
servers-reconnect.c : irssi
|
||||||
|
|
||||||
Copyright (C) 1999 Timo Sirainen
|
Copyright (C) 1999-2000 Timo Sirainen
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -19,16 +19,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include "modules.h"
|
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
#include "network.h"
|
#include "network.h"
|
||||||
#include "signals.h"
|
#include "signals.h"
|
||||||
|
|
||||||
#include "irc.h"
|
#include "servers-setup.h"
|
||||||
#include "modes.h"
|
#include "servers-reconnect.h"
|
||||||
#include "irc-server.h"
|
|
||||||
#include "server-setup.h"
|
|
||||||
#include "server-reconnect.h"
|
|
||||||
|
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
@ -37,10 +33,13 @@ static int last_reconnect_tag;
|
|||||||
static int reconnect_timeout_tag;
|
static int reconnect_timeout_tag;
|
||||||
static int reconnect_time;
|
static int reconnect_time;
|
||||||
|
|
||||||
static void server_reconnect_add(IRC_SERVER_CONNECT_REC *conn, time_t next_connect)
|
static void server_reconnect_add(SERVER_CONNECT_REC *conn,
|
||||||
|
time_t next_connect)
|
||||||
{
|
{
|
||||||
RECONNECT_REC *rec;
|
RECONNECT_REC *rec;
|
||||||
|
|
||||||
|
g_return_if_fail(IS_SERVER_CONNECT(conn));
|
||||||
|
|
||||||
rec = g_new(RECONNECT_REC, 1);
|
rec = g_new(RECONNECT_REC, 1);
|
||||||
rec->tag = ++last_reconnect_tag;
|
rec->tag = ++last_reconnect_tag;
|
||||||
rec->conn = conn;
|
rec->conn = conn;
|
||||||
@ -51,10 +50,12 @@ static void server_reconnect_add(IRC_SERVER_CONNECT_REC *conn, time_t next_conne
|
|||||||
|
|
||||||
static void server_reconnect_destroy(RECONNECT_REC *rec, int free_conn)
|
static void server_reconnect_destroy(RECONNECT_REC *rec, int free_conn)
|
||||||
{
|
{
|
||||||
|
g_return_if_fail(rec != NULL);
|
||||||
|
|
||||||
reconnects = g_slist_remove(reconnects, rec);
|
reconnects = g_slist_remove(reconnects, rec);
|
||||||
|
|
||||||
signal_emit("server reconnect remove", 1, rec);
|
signal_emit("server reconnect remove", 1, rec);
|
||||||
if (free_conn) irc_server_connect_free(rec->conn);
|
if (free_conn) server_connect_free(rec->conn);
|
||||||
g_free(rec);
|
g_free(rec);
|
||||||
|
|
||||||
if (reconnects == NULL)
|
if (reconnects == NULL)
|
||||||
@ -63,11 +64,11 @@ static void server_reconnect_destroy(RECONNECT_REC *rec, int free_conn)
|
|||||||
|
|
||||||
static int server_reconnect_timeout(void)
|
static int server_reconnect_timeout(void)
|
||||||
{
|
{
|
||||||
IRC_SERVER_CONNECT_REC *conn;
|
SERVER_CONNECT_REC *conn;
|
||||||
GSList *list, *tmp;
|
GSList *list, *tmp;
|
||||||
time_t now;
|
time_t now;
|
||||||
|
|
||||||
/* If irc_server_connect() removes the next reconnection in queue,
|
/* If server_connect() removes the next reconnection in queue,
|
||||||
we're screwed. I don't think this should happen anymore, but just
|
we're screwed. I don't think this should happen anymore, but just
|
||||||
to be sure we don't crash, do this safely. */
|
to be sure we don't crash, do this safely. */
|
||||||
list = g_slist_copy(reconnects);
|
list = g_slist_copy(reconnects);
|
||||||
@ -81,7 +82,7 @@ static int server_reconnect_timeout(void)
|
|||||||
if (rec->next_connect <= now) {
|
if (rec->next_connect <= now) {
|
||||||
conn = rec->conn;
|
conn = rec->conn;
|
||||||
server_reconnect_destroy(rec, FALSE);
|
server_reconnect_destroy(rec, FALSE);
|
||||||
irc_server_connect(conn);
|
server_connect(conn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,28 +90,35 @@ static int server_reconnect_timeout(void)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sserver_connect(SETUP_SERVER_REC *rec, IRC_SERVER_CONNECT_REC *conn)
|
static void sserver_connect(SERVER_SETUP_REC *rec, SERVER_CONNECT_REC *conn)
|
||||||
{
|
{
|
||||||
conn->address = g_strdup(rec->address);
|
conn->address = g_strdup(rec->address);
|
||||||
conn->port = rec->port;
|
conn->port = rec->port;
|
||||||
|
|
||||||
server_setup_fill_conn(conn, rec);
|
server_setup_fill_reconn(conn, rec);
|
||||||
if (rec->last_connect > time(NULL)-reconnect_time) {
|
if (rec->last_connect > time(NULL)-reconnect_time) {
|
||||||
/* can't reconnect this fast, wait.. */
|
/* can't reconnect this fast, wait.. */
|
||||||
server_reconnect_add(conn, rec->last_connect+reconnect_time);
|
server_reconnect_add(conn, rec->last_connect+reconnect_time);
|
||||||
} else {
|
} else {
|
||||||
/* connect to server.. */
|
/* connect to server.. */
|
||||||
irc_server_connect(conn);
|
server_connect(conn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void server_connect_copy_skeleton(IRC_SERVER_CONNECT_REC *dest, IRC_SERVER_CONNECT_REC *src)
|
static SERVER_CONNECT_REC *
|
||||||
|
server_connect_copy_skeleton(SERVER_CONNECT_REC *src)
|
||||||
{
|
{
|
||||||
|
SERVER_CONNECT_REC *dest;
|
||||||
|
|
||||||
|
dest = NULL;
|
||||||
|
signal_emit("server connect copy", 2, &dest, src);
|
||||||
|
g_return_val_if_fail(dest != NULL, NULL);
|
||||||
|
|
||||||
dest->proxy = g_strdup(src->proxy);
|
dest->proxy = g_strdup(src->proxy);
|
||||||
dest->proxy_port = src->proxy_port;
|
dest->proxy_port = src->proxy_port;
|
||||||
dest->proxy_string = g_strdup(src->proxy_string);
|
dest->proxy_string = g_strdup(src->proxy_string);
|
||||||
|
|
||||||
dest->ircnet = g_strdup(src->ircnet);
|
dest->chatnet = g_strdup(src->chatnet);
|
||||||
dest->nick = g_strdup(src->nick);
|
dest->nick = g_strdup(src->nick);
|
||||||
dest->username = g_strdup(src->username);
|
dest->username = g_strdup(src->username);
|
||||||
dest->realname = g_strdup(src->realname);
|
dest->realname = g_strdup(src->realname);
|
||||||
@ -120,43 +128,40 @@ static void server_connect_copy_skeleton(IRC_SERVER_CONNECT_REC *dest, IRC_SERVE
|
|||||||
memcpy(dest->own_ip, src->own_ip, sizeof(IPADDR));
|
memcpy(dest->own_ip, src->own_ip, sizeof(IPADDR));
|
||||||
}
|
}
|
||||||
|
|
||||||
dest->cmd_queue_speed = src->cmd_queue_speed;
|
dest->channels = g_strdup(src->channels);
|
||||||
dest->max_kicks = src->max_kicks;
|
dest->away_reason = g_strdup(src->away_reason);
|
||||||
dest->max_modes = src->max_modes;
|
|
||||||
dest->max_msgs = src->max_msgs;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define server_should_reconnect(server) \
|
#define server_should_reconnect(server) \
|
||||||
(irc_server_check(server) && (server)->connection_lost && \
|
((server)->connection_lost && \
|
||||||
((server)->connrec->ircnet != NULL || !(server)->banned))
|
((server)->connrec->chatnet != NULL || !(server)->banned))
|
||||||
|
|
||||||
static void sig_reconnect(IRC_SERVER_REC *server)
|
static void sig_reconnect(SERVER_REC *server)
|
||||||
{
|
{
|
||||||
IRC_SERVER_CONNECT_REC *conn;
|
SERVER_CONNECT_REC *conn;
|
||||||
SETUP_SERVER_REC *sserver;
|
SERVER_SETUP_REC *sserver;
|
||||||
GSList *tmp;
|
GSList *tmp;
|
||||||
int found, through;
|
int found, through;
|
||||||
time_t now;
|
time_t now;
|
||||||
|
|
||||||
g_return_if_fail(server != NULL);
|
g_return_if_fail(IS_SERVER(server));
|
||||||
|
|
||||||
if (reconnect_time == -1 || !server_should_reconnect(server))
|
if (reconnect_time == -1 || !server_should_reconnect(server))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
conn = g_new0(IRC_SERVER_CONNECT_REC, 1);
|
conn = server_connect_copy_skeleton(server->connrec);
|
||||||
server_connect_copy_skeleton(conn, server->connrec);
|
|
||||||
|
|
||||||
/* save the server status */
|
/* save the server status */
|
||||||
if (!server->connected) {
|
if (server->connected) {
|
||||||
conn->channels = g_strdup(server->connrec->channels);
|
|
||||||
conn->away_reason = g_strdup(server->connrec->away_reason);
|
|
||||||
conn->usermode = g_strdup(server->connrec->usermode);
|
|
||||||
} else {
|
|
||||||
conn->reconnection = TRUE;
|
conn->reconnection = TRUE;
|
||||||
conn->channels = irc_server_get_channels(server);
|
|
||||||
|
g_free_not_null(conn->away_reason);
|
||||||
conn->away_reason = !server->usermode_away ? NULL :
|
conn->away_reason = !server->usermode_away ? NULL :
|
||||||
g_strdup(server->away_reason);
|
g_strdup(server->away_reason);
|
||||||
conn->usermode = g_strdup(server->usermode);
|
|
||||||
|
signal_emit("server reconnect save status", 2, conn, server);
|
||||||
}
|
}
|
||||||
|
|
||||||
sserver = server_setup_find(server->connrec->address,
|
sserver = server_setup_find(server->connrec->address,
|
||||||
@ -170,8 +175,8 @@ static void sig_reconnect(IRC_SERVER_REC *server)
|
|||||||
if (server->banned) sserver->banned = TRUE;
|
if (server->banned) sserver->banned = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sserver == NULL || conn->ircnet == NULL) {
|
if (sserver == NULL || conn->chatnet == NULL) {
|
||||||
/* not in any ircnet, just reconnect back to same server */
|
/* not in any chatnet, just reconnect back to same server */
|
||||||
conn->address = g_strdup(server->connrec->address);
|
conn->address = g_strdup(server->connrec->address);
|
||||||
conn->port = server->connrec->port;
|
conn->port = server->connrec->port;
|
||||||
conn->password = server->connrec->password == NULL ? NULL :
|
conn->password = server->connrec->password == NULL ? NULL :
|
||||||
@ -181,7 +186,7 @@ static void sig_reconnect(IRC_SERVER_REC *server)
|
|||||||
time(NULL)-server->connect_time > reconnect_time) {
|
time(NULL)-server->connect_time > reconnect_time) {
|
||||||
/* there's been enough time since last connection,
|
/* there's been enough time since last connection,
|
||||||
reconnect back immediately */
|
reconnect back immediately */
|
||||||
irc_server_connect(conn);
|
server_connect(conn);
|
||||||
} else {
|
} else {
|
||||||
/* reconnect later.. */
|
/* reconnect later.. */
|
||||||
server_reconnect_add(conn, (server->connect_time == 0 ? time(NULL) :
|
server_reconnect_add(conn, (server->connect_time == 0 ? time(NULL) :
|
||||||
@ -196,9 +201,9 @@ static void sig_reconnect(IRC_SERVER_REC *server)
|
|||||||
|
|
||||||
now = time(NULL);
|
now = time(NULL);
|
||||||
for (tmp = setupservers; tmp != NULL; tmp = tmp->next) {
|
for (tmp = setupservers; tmp != NULL; tmp = tmp->next) {
|
||||||
SETUP_SERVER_REC *rec = tmp->data;
|
SERVER_SETUP_REC *rec = tmp->data;
|
||||||
|
|
||||||
if (rec->ircnet != NULL && g_strcasecmp(conn->ircnet, rec->ircnet) == 0 &&
|
if (rec->chatnet != NULL && g_strcasecmp(conn->chatnet, rec->chatnet) == 0 &&
|
||||||
!rec->banned && (!rec->last_connect || !rec->last_failed ||
|
!rec->banned && (!rec->last_connect || !rec->last_failed ||
|
||||||
rec->last_connect < now-FAILED_RECONNECT_WAIT)) {
|
rec->last_connect < now-FAILED_RECONNECT_WAIT)) {
|
||||||
sserver_connect(rec, conn);
|
sserver_connect(rec, conn);
|
||||||
@ -209,13 +214,13 @@ static void sig_reconnect(IRC_SERVER_REC *server)
|
|||||||
/* just try the next server in list */
|
/* just try the next server in list */
|
||||||
found = through = FALSE;
|
found = through = FALSE;
|
||||||
for (tmp = setupservers; tmp != NULL; ) {
|
for (tmp = setupservers; tmp != NULL; ) {
|
||||||
SETUP_SERVER_REC *rec = tmp->data;
|
SERVER_SETUP_REC *rec = tmp->data;
|
||||||
|
|
||||||
if (!found && g_strcasecmp(rec->address, server->connrec->address) == 0 &&
|
if (!found && g_strcasecmp(rec->address, server->connrec->address) == 0 &&
|
||||||
server->connrec->port == rec->port)
|
server->connrec->port == rec->port)
|
||||||
found = TRUE;
|
found = TRUE;
|
||||||
else if (found && !rec->banned && rec->ircnet != NULL &&
|
else if (found && !rec->banned && rec->chatnet != NULL &&
|
||||||
g_strcasecmp(conn->ircnet, rec->ircnet) == 0) {
|
g_strcasecmp(conn->chatnet, rec->chatnet) == 0) {
|
||||||
sserver_connect(rec, conn);
|
sserver_connect(rec, conn);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -227,8 +232,8 @@ static void sig_reconnect(IRC_SERVER_REC *server)
|
|||||||
|
|
||||||
if (through) {
|
if (through) {
|
||||||
/* shouldn't happen unless there's no servers in
|
/* shouldn't happen unless there's no servers in
|
||||||
this ircnet in setup.. */
|
this chatnet in setup.. */
|
||||||
irc_server_connect_free(conn);
|
server_connect_free(conn);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,9 +266,9 @@ static RECONNECT_REC *reconnect_find_tag(int tag)
|
|||||||
|
|
||||||
/* Try to reconnect immediately */
|
/* Try to reconnect immediately */
|
||||||
/* SYNTAX: RECONNECT <tag> */
|
/* SYNTAX: RECONNECT <tag> */
|
||||||
static void cmd_reconnect(const char *data, IRC_SERVER_REC *server)
|
static void cmd_reconnect(const char *data, SERVER_REC *server)
|
||||||
{
|
{
|
||||||
IRC_SERVER_CONNECT_REC *conn;
|
SERVER_CONNECT_REC *conn;
|
||||||
RECONNECT_REC *rec;
|
RECONNECT_REC *rec;
|
||||||
char *str;
|
char *str;
|
||||||
int tag;
|
int tag;
|
||||||
@ -290,7 +295,7 @@ static void cmd_reconnect(const char *data, IRC_SERVER_REC *server)
|
|||||||
else {
|
else {
|
||||||
conn = rec->conn;
|
conn = rec->conn;
|
||||||
server_reconnect_destroy(rec, FALSE);
|
server_reconnect_destroy(rec, FALSE);
|
||||||
irc_server_connect(conn);
|
server_connect(conn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -309,47 +314,7 @@ static void cmd_disconnect(const char *data, SERVER_REC *server)
|
|||||||
signal_emit("server reconnect not found", 1, data);
|
signal_emit("server reconnect not found", 1, data);
|
||||||
else
|
else
|
||||||
server_reconnect_destroy(rec, TRUE);
|
server_reconnect_destroy(rec, TRUE);
|
||||||
}
|
signal_stop();
|
||||||
|
|
||||||
static int sig_set_user_mode(IRC_SERVER_REC *server)
|
|
||||||
{
|
|
||||||
const char *mode;
|
|
||||||
char *newmode;
|
|
||||||
|
|
||||||
if (g_slist_find(servers, server) == NULL)
|
|
||||||
return 0; /* got disconnected */
|
|
||||||
|
|
||||||
mode = server->connrec->usermode;
|
|
||||||
if (mode == NULL) return 0;
|
|
||||||
|
|
||||||
newmode = server->usermode == NULL ? NULL :
|
|
||||||
modes_join(server->usermode, mode);
|
|
||||||
|
|
||||||
if (server->usermode == NULL) {
|
|
||||||
/* server didn't set user mode, just set the new one */
|
|
||||||
irc_send_cmdv(server, "MODE %s %s", server->nick, mode);
|
|
||||||
} else {
|
|
||||||
if (strcmp(newmode, server->usermode) != 0)
|
|
||||||
irc_send_cmdv(server, "MODE %s -%s+%s", server->nick, server->usermode, mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free_not_null(newmode);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void sig_connected(IRC_SERVER_REC *server)
|
|
||||||
{
|
|
||||||
if (!server->connrec->reconnection)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (server->connrec->channels != NULL)
|
|
||||||
channels_join(server, server->connrec->channels, TRUE);
|
|
||||||
if (server->connrec->away_reason != NULL)
|
|
||||||
signal_emit("command away", 2, server->connrec->away_reason, server, NULL);
|
|
||||||
if (server->connrec->usermode != NULL) {
|
|
||||||
/* wait a second and then send the user mode */
|
|
||||||
g_timeout_add(1000, (GSourceFunc) sig_set_user_mode, server);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void read_settings(void)
|
static void read_settings(void)
|
||||||
@ -359,6 +324,8 @@ static void read_settings(void)
|
|||||||
|
|
||||||
void servers_reconnect_init(void)
|
void servers_reconnect_init(void)
|
||||||
{
|
{
|
||||||
|
settings_add_int("server", "server_reconnect_time", 300);
|
||||||
|
|
||||||
reconnects = NULL;
|
reconnects = NULL;
|
||||||
last_reconnect_tag = 0;
|
last_reconnect_tag = 0;
|
||||||
|
|
||||||
@ -367,10 +334,9 @@ void servers_reconnect_init(void)
|
|||||||
|
|
||||||
signal_add("server connect failed", (SIGNAL_FUNC) sig_reconnect);
|
signal_add("server connect failed", (SIGNAL_FUNC) sig_reconnect);
|
||||||
signal_add("server disconnected", (SIGNAL_FUNC) sig_reconnect);
|
signal_add("server disconnected", (SIGNAL_FUNC) sig_reconnect);
|
||||||
signal_add("event connected", (SIGNAL_FUNC) sig_connected);
|
|
||||||
command_bind("rmreconns", NULL, (SIGNAL_FUNC) cmd_rmreconns);
|
command_bind("rmreconns", NULL, (SIGNAL_FUNC) cmd_rmreconns);
|
||||||
command_bind("reconnect", NULL, (SIGNAL_FUNC) cmd_reconnect);
|
command_bind("reconnect", NULL, (SIGNAL_FUNC) cmd_reconnect);
|
||||||
command_bind("disconnect", NULL, (SIGNAL_FUNC) cmd_disconnect);
|
command_bind_first("disconnect", NULL, (SIGNAL_FUNC) cmd_disconnect);
|
||||||
signal_add("setup changed", (SIGNAL_FUNC) read_settings);
|
signal_add("setup changed", (SIGNAL_FUNC) read_settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -383,7 +349,6 @@ void servers_reconnect_deinit(void)
|
|||||||
|
|
||||||
signal_remove("server connect failed", (SIGNAL_FUNC) sig_reconnect);
|
signal_remove("server connect failed", (SIGNAL_FUNC) sig_reconnect);
|
||||||
signal_remove("server disconnected", (SIGNAL_FUNC) sig_reconnect);
|
signal_remove("server disconnected", (SIGNAL_FUNC) sig_reconnect);
|
||||||
signal_remove("event connected", (SIGNAL_FUNC) sig_connected);
|
|
||||||
command_unbind("rmreconns", (SIGNAL_FUNC) cmd_rmreconns);
|
command_unbind("rmreconns", (SIGNAL_FUNC) cmd_rmreconns);
|
||||||
command_unbind("reconnect", (SIGNAL_FUNC) cmd_reconnect);
|
command_unbind("reconnect", (SIGNAL_FUNC) cmd_reconnect);
|
||||||
command_unbind("disconnect", (SIGNAL_FUNC) cmd_disconnect);
|
command_unbind("disconnect", (SIGNAL_FUNC) cmd_disconnect);
|
@ -9,7 +9,7 @@ typedef struct {
|
|||||||
int tag;
|
int tag;
|
||||||
time_t next_connect;
|
time_t next_connect;
|
||||||
|
|
||||||
IRC_SERVER_CONNECT_REC *conn;
|
SERVER_CONNECT_REC *conn;
|
||||||
} RECONNECT_REC;
|
} RECONNECT_REC;
|
||||||
|
|
||||||
extern GSList *reconnects;
|
extern GSList *reconnects;
|
@ -22,8 +22,8 @@
|
|||||||
#include "signals.h"
|
#include "signals.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
#include "server.h"
|
#include "servers.h"
|
||||||
#include "server-redirect.h"
|
#include "servers-redirect.h"
|
||||||
|
|
||||||
static int redirect_group;
|
static int redirect_group;
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ static void server_cmdtable_destroy(char *key, REDIRECT_CMD_REC *value)
|
|||||||
|
|
||||||
static void sig_disconnected(SERVER_REC *server)
|
static void sig_disconnected(SERVER_REC *server)
|
||||||
{
|
{
|
||||||
g_return_if_fail(server != NULL);
|
g_return_if_fail(IS_SERVER(server));
|
||||||
|
|
||||||
if (server->eventtable != NULL) {
|
if (server->eventtable != NULL) {
|
||||||
g_hash_table_foreach(server->eventtable,
|
g_hash_table_foreach(server->eventtable,
|
||||||
@ -84,7 +84,7 @@ void server_redirect_initv(SERVER_REC *server, const char *command,
|
|||||||
{
|
{
|
||||||
REDIRECT_CMD_REC *rec;
|
REDIRECT_CMD_REC *rec;
|
||||||
|
|
||||||
g_return_if_fail(server != NULL);
|
g_return_if_fail(IS_SERVER(server));
|
||||||
g_return_if_fail(command != NULL);
|
g_return_if_fail(command != NULL);
|
||||||
g_return_if_fail(last > 0);
|
g_return_if_fail(last > 0);
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ int server_redirect_single_event(SERVER_REC *server, const char *arg,
|
|||||||
GSList *list, *grouplist;
|
GSList *list, *grouplist;
|
||||||
char *origkey;
|
char *origkey;
|
||||||
|
|
||||||
g_return_val_if_fail(server != NULL, 0);
|
g_return_val_if_fail(IS_SERVER(server), 0);
|
||||||
g_return_val_if_fail(event != NULL, 0);
|
g_return_val_if_fail(event != NULL, 0);
|
||||||
g_return_val_if_fail(signal != NULL, 0);
|
g_return_val_if_fail(signal != NULL, 0);
|
||||||
g_return_val_if_fail(arg != NULL || argpos == -1, 0);
|
g_return_val_if_fail(arg != NULL || argpos == -1, 0);
|
||||||
@ -171,7 +171,7 @@ void server_redirect_event(SERVER_REC *server, const char *arg, int last, ...)
|
|||||||
char *event, *signal;
|
char *event, *signal;
|
||||||
int argpos, group;
|
int argpos, group;
|
||||||
|
|
||||||
g_return_if_fail(server != NULL);
|
g_return_if_fail(IS_SERVER(server));
|
||||||
|
|
||||||
va_start(args, last);
|
va_start(args, last);
|
||||||
|
|
||||||
@ -197,7 +197,7 @@ void server_redirect_default(SERVER_REC *server, const char *command)
|
|||||||
char *event, *origkey;
|
char *event, *origkey;
|
||||||
int last;
|
int last;
|
||||||
|
|
||||||
g_return_if_fail(server != NULL);
|
g_return_if_fail(IS_SERVER(server));
|
||||||
g_return_if_fail(command != NULL);
|
g_return_if_fail(command != NULL);
|
||||||
|
|
||||||
if (server->cmdtable == NULL)
|
if (server->cmdtable == NULL)
|
||||||
@ -245,7 +245,7 @@ void server_redirect_remove_next(SERVER_REC *server, const char *event,
|
|||||||
char *origkey;
|
char *origkey;
|
||||||
int group;
|
int group;
|
||||||
|
|
||||||
g_return_if_fail(server != NULL);
|
g_return_if_fail(IS_SERVER(server));
|
||||||
g_return_if_fail(event != NULL);
|
g_return_if_fail(event != NULL);
|
||||||
|
|
||||||
if (!g_hash_table_lookup_extended(server->eventtable, event,
|
if (!g_hash_table_lookup_extended(server->eventtable, event,
|
||||||
@ -321,6 +321,9 @@ GSList *server_redirect_getqueue(SERVER_REC *server, const char *event,
|
|||||||
char **arglist;
|
char **arglist;
|
||||||
int found;
|
int found;
|
||||||
|
|
||||||
|
g_return_val_if_fail(IS_SERVER(server), NULL);
|
||||||
|
g_return_val_if_fail(event != NULL, NULL);
|
||||||
|
|
||||||
list = g_hash_table_lookup(server->eventtable, event);
|
list = g_hash_table_lookup(server->eventtable, event);
|
||||||
|
|
||||||
for (; list != NULL; list = list->next) {
|
for (; list != NULL; list = list->next) {
|
||||||
@ -328,7 +331,7 @@ GSList *server_redirect_getqueue(SERVER_REC *server, const char *event,
|
|||||||
if (rec->argpos == -1)
|
if (rec->argpos == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (rec->arg == NULL)
|
if (rec->arg == NULL || args == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* we need to check that the argument is right.. */
|
/* we need to check that the argument is right.. */
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef __SERVER_REDIRECT_H
|
#ifndef __SERVERS_REDIRECT_H
|
||||||
#define __SERVER_REDIRECT_H
|
#define __SERVERS_REDIRECT_H
|
||||||
|
|
||||||
#include "server.h"
|
#include "servers.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int last; /* number of "last" events at the start of the events list */
|
int last; /* number of "last" events at the start of the events list */
|
456
src/core/servers-setup.c
Normal file
456
src/core/servers-setup.c
Normal file
@ -0,0 +1,456 @@
|
|||||||
|
/*
|
||||||
|
servers-setup.c : irssi
|
||||||
|
|
||||||
|
Copyright (C) 1999-2000 Timo Sirainen
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "module.h"
|
||||||
|
#include "signals.h"
|
||||||
|
#include "network.h"
|
||||||
|
#include "lib-config/iconfig.h"
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
|
#include "servers.h"
|
||||||
|
#include "servers-setup.h"
|
||||||
|
#include "chatnets.h"
|
||||||
|
|
||||||
|
GSList *setupservers;
|
||||||
|
|
||||||
|
int source_host_ok; /* Use source_host_ip .. */
|
||||||
|
IPADDR *source_host_ip; /* Resolved address */
|
||||||
|
|
||||||
|
static void get_source_host_ip(void)
|
||||||
|
{
|
||||||
|
IPADDR ip;
|
||||||
|
|
||||||
|
if (source_host_ok)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* FIXME: This will block! */
|
||||||
|
source_host_ok = *settings_get_str("hostname") != '\0' &&
|
||||||
|
net_gethostbyname(settings_get_str("hostname"), &ip) == 0;
|
||||||
|
if (source_host_ok) {
|
||||||
|
if (source_host_ip == NULL)
|
||||||
|
source_host_ip = g_new(IPADDR, 1);
|
||||||
|
memcpy(source_host_ip, &ip, sizeof(IPADDR));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void conn_set_ip(SERVER_CONNECT_REC *conn,
|
||||||
|
IPADDR **own_ip, const char *own_host)
|
||||||
|
{
|
||||||
|
IPADDR ip;
|
||||||
|
|
||||||
|
if (*own_ip != NULL) {
|
||||||
|
/* use already resolved IP */
|
||||||
|
if (conn->own_ip == NULL)
|
||||||
|
conn->own_ip = g_new(IPADDR, 1);
|
||||||
|
memcpy(conn->own_ip, *own_ip, sizeof(IPADDR));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* resolve the IP and use it */
|
||||||
|
if (net_gethostbyname(own_host, &ip) == 0) {
|
||||||
|
if (conn->own_ip == NULL)
|
||||||
|
conn->own_ip = g_new(IPADDR, 1);
|
||||||
|
memcpy(conn->own_ip, &ip, sizeof(IPADDR));
|
||||||
|
|
||||||
|
*own_ip = g_new(IPADDR, 1);
|
||||||
|
memcpy(*own_ip, &ip, sizeof(IPADDR));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fill information to connection from server setup record */
|
||||||
|
void server_setup_fill_reconn(SERVER_CONNECT_REC *conn,
|
||||||
|
SERVER_SETUP_REC *sserver)
|
||||||
|
{
|
||||||
|
g_return_if_fail(IS_SERVER_CONNECT(conn));
|
||||||
|
g_return_if_fail(IS_SERVER_SETUP(sserver));
|
||||||
|
|
||||||
|
if (sserver->own_host != NULL)
|
||||||
|
conn_set_ip(conn, &sserver->own_ip, sserver->own_host);
|
||||||
|
|
||||||
|
if (sserver->chatnet != NULL && conn->chatnet == NULL)
|
||||||
|
conn->chatnet = g_strdup(sserver->chatnet);
|
||||||
|
|
||||||
|
if (sserver->password != NULL && conn->password == NULL)
|
||||||
|
conn->password = g_strdup(sserver->password);
|
||||||
|
|
||||||
|
signal_emit("server setup fill reconn", 2, conn, sserver);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void server_setup_fill(SERVER_CONNECT_REC *conn,
|
||||||
|
const char *address, int port)
|
||||||
|
{
|
||||||
|
g_return_if_fail(conn != NULL);
|
||||||
|
g_return_if_fail(address != NULL);
|
||||||
|
|
||||||
|
conn->type = module_get_uniq_id("SERVER CONNECT", 0);
|
||||||
|
|
||||||
|
conn->address = g_strdup(address);
|
||||||
|
conn->port = port > 0 ? port : 6667;
|
||||||
|
|
||||||
|
if (!conn->nick) conn->nick = g_strdup(settings_get_str("default_nick"));
|
||||||
|
conn->username = g_strdup(settings_get_str("user_name"));
|
||||||
|
conn->realname = g_strdup(settings_get_str("real_name"));
|
||||||
|
|
||||||
|
/* proxy settings */
|
||||||
|
if (settings_get_bool("use_proxy")) {
|
||||||
|
conn->proxy = g_strdup(settings_get_str("proxy_address"));
|
||||||
|
conn->proxy_port = settings_get_int("proxy_port");
|
||||||
|
conn->proxy_string = g_strdup(settings_get_str("proxy_string"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* source IP */
|
||||||
|
get_source_host_ip();
|
||||||
|
if (source_host_ok) {
|
||||||
|
conn->own_ip = g_new(IPADDR, 1);
|
||||||
|
memcpy(conn->own_ip, source_host_ip, sizeof(IPADDR));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void server_setup_fill_server(SERVER_CONNECT_REC *conn,
|
||||||
|
SERVER_SETUP_REC *sserver)
|
||||||
|
{
|
||||||
|
g_return_if_fail(IS_SERVER_CONNECT(conn));
|
||||||
|
g_return_if_fail(IS_SERVER_SETUP(sserver));
|
||||||
|
|
||||||
|
sserver->last_connect = time(NULL);
|
||||||
|
|
||||||
|
if (sserver->port > 0) conn->port = sserver->port;
|
||||||
|
server_setup_fill_reconn(conn, sserver);
|
||||||
|
|
||||||
|
signal_emit("server setup fill server", 2, conn, sserver);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void server_setup_fill_chatnet(SERVER_CONNECT_REC *conn,
|
||||||
|
CHATNET_REC *chatnet)
|
||||||
|
{
|
||||||
|
g_return_if_fail(IS_SERVER_CONNECT(conn));
|
||||||
|
g_return_if_fail(IS_CHATNET(chatnet));
|
||||||
|
|
||||||
|
if (chatnet->nick) {
|
||||||
|
g_free(conn->nick);
|
||||||
|
conn->nick = g_strdup(chatnet->nick);;
|
||||||
|
}
|
||||||
|
if (chatnet->username) {
|
||||||
|
g_free(conn->username);
|
||||||
|
conn->username = g_strdup(chatnet->username);;
|
||||||
|
}
|
||||||
|
if (chatnet->realname) {
|
||||||
|
g_free(conn->realname);
|
||||||
|
conn->realname = g_strdup(chatnet->realname);;
|
||||||
|
}
|
||||||
|
if (chatnet->own_host != NULL)
|
||||||
|
conn_set_ip(conn, &chatnet->own_ip, chatnet->own_host);
|
||||||
|
|
||||||
|
signal_emit("server setup fill chatnet", 2, conn, chatnet);
|
||||||
|
}
|
||||||
|
|
||||||
|
static SERVER_CONNECT_REC *
|
||||||
|
create_addr_conn(const char *address, int port,
|
||||||
|
const char *password, const char *nick)
|
||||||
|
{
|
||||||
|
SERVER_CONNECT_REC *conn;
|
||||||
|
SERVER_SETUP_REC *sserver;
|
||||||
|
CHATNET_REC *chatnet;
|
||||||
|
|
||||||
|
g_return_val_if_fail(address != NULL, NULL);
|
||||||
|
|
||||||
|
sserver = server_setup_find(address, port);
|
||||||
|
chatnet = sserver->chatnet == NULL ? NULL :
|
||||||
|
chatnet_find(sserver->chatnet);
|
||||||
|
conn = NULL;
|
||||||
|
signal_emit("server setup connect", 2, &conn, chatnet);
|
||||||
|
if (conn == NULL) {
|
||||||
|
/* no chat protocol wanted this server? */
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* fill in the defaults */
|
||||||
|
server_setup_fill(conn, address, port);
|
||||||
|
|
||||||
|
/* fill the rest from chat network settings */
|
||||||
|
if (chatnet != NULL)
|
||||||
|
server_setup_fill_chatnet(conn, chatnet);
|
||||||
|
|
||||||
|
/* fill the information from setup */
|
||||||
|
if (sserver != NULL)
|
||||||
|
server_setup_fill_server(conn, sserver);
|
||||||
|
|
||||||
|
/* nick / password given in command line overrides all settings */
|
||||||
|
if (password && *password) {
|
||||||
|
g_free_not_null(conn->password);
|
||||||
|
conn->password = g_strdup(password);
|
||||||
|
}
|
||||||
|
if (nick && *nick) {
|
||||||
|
g_free_not_null(conn->nick);
|
||||||
|
conn->nick = g_strdup(nick);
|
||||||
|
}
|
||||||
|
|
||||||
|
return conn;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Connect to server where last connect succeeded (or we haven't tried to
|
||||||
|
connect yet). If there's no such server, connect to server where we
|
||||||
|
haven't connected for the longest time */
|
||||||
|
static SERVER_CONNECT_REC *
|
||||||
|
create_chatnet_conn(const char *dest, int port,
|
||||||
|
const char *password, const char *nick)
|
||||||
|
{
|
||||||
|
SERVER_SETUP_REC *bestrec;
|
||||||
|
GSList *tmp;
|
||||||
|
time_t now, besttime;
|
||||||
|
|
||||||
|
now = time(NULL);
|
||||||
|
bestrec = NULL; besttime = now;
|
||||||
|
for (tmp = setupservers; tmp != NULL; tmp = tmp->next) {
|
||||||
|
SERVER_SETUP_REC *rec = tmp->data;
|
||||||
|
|
||||||
|
if (rec->chatnet == NULL ||
|
||||||
|
g_strcasecmp(rec->chatnet, dest) != 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!rec->last_failed) {
|
||||||
|
bestrec = rec;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bestrec == NULL || besttime > rec->last_connect) {
|
||||||
|
bestrec = rec;
|
||||||
|
besttime = rec->last_connect;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return bestrec == NULL ? NULL :
|
||||||
|
create_addr_conn(bestrec->address, 0, NULL, nick);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create server connection record. `dest' is required, rest can be NULL.
|
||||||
|
`dest' is either a server address or chat network */
|
||||||
|
SERVER_CONNECT_REC *
|
||||||
|
server_create_conn(const char *dest, int port,
|
||||||
|
const char *password, const char *nick)
|
||||||
|
{
|
||||||
|
SERVER_CONNECT_REC *rec;
|
||||||
|
|
||||||
|
g_return_val_if_fail(dest != NULL, NULL);
|
||||||
|
|
||||||
|
if (chatnet_find(dest)) {
|
||||||
|
rec = create_chatnet_conn(dest, port, password, nick);
|
||||||
|
if (rec != NULL)
|
||||||
|
return rec;
|
||||||
|
}
|
||||||
|
|
||||||
|
return create_addr_conn(dest, port, password, nick);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Find matching server from setup. Try to find record with a same port,
|
||||||
|
but fallback to any server with the same address. */
|
||||||
|
SERVER_SETUP_REC *server_setup_find(const char *address, int port)
|
||||||
|
{
|
||||||
|
SERVER_SETUP_REC *server;
|
||||||
|
GSList *tmp;
|
||||||
|
|
||||||
|
g_return_val_if_fail(address != NULL, NULL);
|
||||||
|
|
||||||
|
server = NULL;
|
||||||
|
for (tmp = setupservers; tmp != NULL; tmp = tmp->next) {
|
||||||
|
SERVER_SETUP_REC *rec = tmp->data;
|
||||||
|
|
||||||
|
if (g_strcasecmp(rec->address, address) == 0) {
|
||||||
|
server = rec;
|
||||||
|
if (rec->port == port)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return server;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Find matching server from setup. Ports must match or NULL is returned. */
|
||||||
|
SERVER_SETUP_REC *server_setup_find_port(const char *address, int port)
|
||||||
|
{
|
||||||
|
SERVER_SETUP_REC *rec;
|
||||||
|
|
||||||
|
rec = server_setup_find(address, port);
|
||||||
|
return rec == NULL || rec->port != port ? NULL : rec;
|
||||||
|
}
|
||||||
|
|
||||||
|
static SERVER_SETUP_REC *server_setup_read(CONFIG_NODE *node)
|
||||||
|
{
|
||||||
|
SERVER_SETUP_REC *rec;
|
||||||
|
char *server, *chatnet;
|
||||||
|
int port;
|
||||||
|
|
||||||
|
g_return_val_if_fail(node != NULL, NULL);
|
||||||
|
|
||||||
|
server = config_node_get_str(node, "address", NULL);
|
||||||
|
if (server == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
port = config_node_get_int(node, "port", 6667);
|
||||||
|
if (server_setup_find_port(server, port) != NULL) {
|
||||||
|
/* already exists - don't let it get there twice or
|
||||||
|
server reconnects will screw up! */
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
rec = NULL;
|
||||||
|
chatnet = config_node_get_str(node, "chatnet", NULL);
|
||||||
|
signal_emit("server setup read", 3, &rec, node,
|
||||||
|
chatnet == NULL ? NULL : chatnet_find(chatnet));
|
||||||
|
if (rec == NULL) {
|
||||||
|
/* no chat protocol wanted this server? */
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
rec->type = module_get_uniq_id("SERVER SETUP", 0);
|
||||||
|
rec->chatnet = g_strdup(chatnet);
|
||||||
|
rec->address = g_strdup(server);
|
||||||
|
rec->password = g_strdup(config_node_get_str(node, "password", NULL));
|
||||||
|
rec->port = port;
|
||||||
|
rec->autoconnect = config_node_get_bool(node, "autoconnect", FALSE);
|
||||||
|
rec->own_host = g_strdup(config_node_get_str(node, "own_host", 0));
|
||||||
|
|
||||||
|
setupservers = g_slist_append(setupservers, rec);
|
||||||
|
return rec;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void server_setup_save(SERVER_SETUP_REC *rec)
|
||||||
|
{
|
||||||
|
CONFIG_NODE *parentnode, *node;
|
||||||
|
int index;
|
||||||
|
|
||||||
|
index = g_slist_index(setupservers, rec);
|
||||||
|
|
||||||
|
parentnode = iconfig_node_traverse("(servers", TRUE);
|
||||||
|
node = config_node_index(parentnode, index);
|
||||||
|
if (node == NULL)
|
||||||
|
node = config_node_section(parentnode, NULL, NODE_TYPE_BLOCK);
|
||||||
|
|
||||||
|
iconfig_node_clear(node);
|
||||||
|
iconfig_node_set_str(node, "address", rec->address);
|
||||||
|
iconfig_node_set_str(node, "chatnet", rec->chatnet);
|
||||||
|
|
||||||
|
config_node_set_int(node, "port", rec->port);
|
||||||
|
iconfig_node_set_str(node, "password", rec->password);
|
||||||
|
iconfig_node_set_str(node, "own_host", rec->own_host);
|
||||||
|
|
||||||
|
if (rec->autoconnect)
|
||||||
|
config_node_set_bool(node, "autoconnect", TRUE);
|
||||||
|
|
||||||
|
signal_emit("server setup saved", 2, rec, node);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void server_setup_remove_config(SERVER_SETUP_REC *rec)
|
||||||
|
{
|
||||||
|
CONFIG_NODE *node;
|
||||||
|
int index;
|
||||||
|
|
||||||
|
node = iconfig_node_traverse("servers", FALSE);
|
||||||
|
if (node != NULL) {
|
||||||
|
index = g_slist_index(setupservers, rec);
|
||||||
|
iconfig_node_list_remove(node, index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void server_setup_destroy(SERVER_SETUP_REC *rec)
|
||||||
|
{
|
||||||
|
setupservers = g_slist_remove(setupservers, rec);
|
||||||
|
signal_emit("server setup destroyed", 1, rec);
|
||||||
|
|
||||||
|
g_free_not_null(rec->own_host);
|
||||||
|
g_free_not_null(rec->own_ip);
|
||||||
|
g_free_not_null(rec->chatnet);
|
||||||
|
g_free(rec->address);
|
||||||
|
g_free_not_null(rec->password);
|
||||||
|
g_free(rec);
|
||||||
|
}
|
||||||
|
|
||||||
|
void server_setup_add(SERVER_SETUP_REC *rec)
|
||||||
|
{
|
||||||
|
if (g_slist_find(setupservers, rec) == NULL)
|
||||||
|
setupservers = g_slist_append(setupservers, rec);
|
||||||
|
server_setup_save(rec);
|
||||||
|
}
|
||||||
|
|
||||||
|
void server_setup_remove(SERVER_SETUP_REC *rec)
|
||||||
|
{
|
||||||
|
server_setup_remove_config(rec);
|
||||||
|
server_setup_destroy(rec);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void read_servers(void)
|
||||||
|
{
|
||||||
|
CONFIG_NODE *node;
|
||||||
|
GSList *tmp;
|
||||||
|
|
||||||
|
while (setupservers != NULL)
|
||||||
|
server_setup_destroy(setupservers->data);
|
||||||
|
|
||||||
|
/* Read servers */
|
||||||
|
node = iconfig_node_traverse("servers", FALSE);
|
||||||
|
if (node != NULL) {
|
||||||
|
for (tmp = node->value; tmp != NULL; tmp = tmp->next)
|
||||||
|
server_setup_read(tmp->data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void read_settings(void)
|
||||||
|
{
|
||||||
|
g_free_and_null(source_host_ip);
|
||||||
|
|
||||||
|
source_host_ok = FALSE;
|
||||||
|
get_source_host_ip();
|
||||||
|
}
|
||||||
|
|
||||||
|
void servers_setup_init(void)
|
||||||
|
{
|
||||||
|
settings_add_str("server", "hostname", "");
|
||||||
|
|
||||||
|
settings_add_str("server", "default_nick", NULL);
|
||||||
|
settings_add_str("server", "user_name", NULL);
|
||||||
|
settings_add_str("server", "real_name", NULL);
|
||||||
|
|
||||||
|
settings_add_bool("proxy", "use_proxy", FALSE);
|
||||||
|
settings_add_str("proxy", "proxy_address", "");
|
||||||
|
settings_add_int("proxy", "proxy_port", 6667);
|
||||||
|
settings_add_str("proxy", "proxy_string", "CONNECT %s %d");
|
||||||
|
|
||||||
|
source_host_ip = NULL;
|
||||||
|
read_settings();
|
||||||
|
|
||||||
|
signal_add("setup changed", (SIGNAL_FUNC) read_settings);
|
||||||
|
signal_add("setup reread", (SIGNAL_FUNC) read_servers);
|
||||||
|
signal_add("irssi init read settings", (SIGNAL_FUNC) read_servers);
|
||||||
|
}
|
||||||
|
|
||||||
|
void servers_setup_deinit(void)
|
||||||
|
{
|
||||||
|
g_free_not_null(source_host_ip);
|
||||||
|
|
||||||
|
while (setupservers != NULL)
|
||||||
|
server_setup_destroy(setupservers->data);
|
||||||
|
|
||||||
|
signal_remove("setup changed", (SIGNAL_FUNC) read_settings);
|
||||||
|
signal_remove("setup reread", (SIGNAL_FUNC) read_servers);
|
||||||
|
signal_remove("irssi init read settings", (SIGNAL_FUNC) read_servers);
|
||||||
|
|
||||||
|
module_uniq_destroy("SERVER SETUP");
|
||||||
|
}
|
46
src/core/servers-setup.h
Normal file
46
src/core/servers-setup.h
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
#ifndef __SERVERS_SETUP_H
|
||||||
|
#define __SERVERS_SETUP_H
|
||||||
|
|
||||||
|
#include "servers.h"
|
||||||
|
|
||||||
|
#define IS_SERVER_SETUP(server) \
|
||||||
|
((server) != NULL && \
|
||||||
|
module_find_id("SERVER SETUP", (server)->type) != -1)
|
||||||
|
|
||||||
|
#define SERVER_SETUP(server) \
|
||||||
|
(IS_SERVER_SETUP(server) ? (SERVER_SETUP_REC *) (server) : NULL)
|
||||||
|
|
||||||
|
/* servers */
|
||||||
|
typedef struct {
|
||||||
|
#include "server-setup-rec.h"
|
||||||
|
} SERVER_SETUP_REC;
|
||||||
|
|
||||||
|
extern GSList *setupservers;
|
||||||
|
|
||||||
|
extern IPADDR *source_host_ip; /* Resolved address */
|
||||||
|
extern int source_host_ok; /* Use source_host_ip .. */
|
||||||
|
|
||||||
|
/* Fill reconnection specific information to connection
|
||||||
|
from server setup record */
|
||||||
|
void server_setup_fill_reconn(SERVER_CONNECT_REC *conn,
|
||||||
|
SERVER_SETUP_REC *sserver);
|
||||||
|
|
||||||
|
/* Create server connection record. `dest' is required, rest can be NULL.
|
||||||
|
`dest' is either a server address or chat network */
|
||||||
|
SERVER_CONNECT_REC *
|
||||||
|
server_create_conn(const char *dest, int port,
|
||||||
|
const char *password, const char *nick);
|
||||||
|
|
||||||
|
/* Find matching server from setup. Try to find record with a same port,
|
||||||
|
but fallback to any server with the same address. */
|
||||||
|
SERVER_SETUP_REC *server_setup_find(const char *address, int port);
|
||||||
|
/* Find matching server from setup. Ports must match or NULL is returned. */
|
||||||
|
SERVER_SETUP_REC *server_setup_find_port(const char *address, int port);
|
||||||
|
|
||||||
|
void server_setup_add(SERVER_SETUP_REC *rec);
|
||||||
|
void server_setup_remove(SERVER_SETUP_REC *rec);
|
||||||
|
|
||||||
|
void servers_setup_init(void);
|
||||||
|
void servers_setup_deinit(void);
|
||||||
|
|
||||||
|
#endif
|
@ -19,24 +19,26 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
|
|
||||||
#include "modules.h"
|
|
||||||
#include "signals.h"
|
#include "signals.h"
|
||||||
#include "line-split.h"
|
#include "line-split.h"
|
||||||
#include "net-nonblock.h"
|
#include "net-nonblock.h"
|
||||||
#include "net-sendbuffer.h"
|
#include "net-sendbuffer.h"
|
||||||
#include "rawlog.h"
|
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "server.h"
|
#include "rawlog.h"
|
||||||
#include "server-redirect.h"
|
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
|
#include "servers.h"
|
||||||
|
#include "servers-redirect.h"
|
||||||
|
#include "servers-setup.h"
|
||||||
|
#include "channels.h"
|
||||||
|
#include "queries.h"
|
||||||
|
|
||||||
GSList *servers, *lookup_servers;
|
GSList *servers, *lookup_servers;
|
||||||
|
|
||||||
/* connection to server failed */
|
/* connection to server failed */
|
||||||
static void server_cant_connect(SERVER_REC *server, const char *msg)
|
static void server_cant_connect(SERVER_REC *server, const char *msg)
|
||||||
{
|
{
|
||||||
g_return_if_fail(server != NULL);
|
g_return_if_fail(IS_SERVER(server));
|
||||||
|
|
||||||
lookup_servers = g_slist_remove(lookup_servers, server);
|
lookup_servers = g_slist_remove(lookup_servers, server);
|
||||||
|
|
||||||
@ -52,6 +54,7 @@ static void server_cant_connect(SERVER_REC *server, const char *msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
MODULE_DATA_DEINIT(server);
|
MODULE_DATA_DEINIT(server);
|
||||||
|
server_connect_free(server->connrec);
|
||||||
g_free_not_null(server->nick);
|
g_free_not_null(server->nick);
|
||||||
g_free(server->tag);
|
g_free(server->tag);
|
||||||
g_free(server);
|
g_free(server);
|
||||||
@ -62,6 +65,8 @@ static char *server_create_address_tag(const char *address)
|
|||||||
{
|
{
|
||||||
const char *start, *end;
|
const char *start, *end;
|
||||||
|
|
||||||
|
g_return_val_if_fail(address != NULL, NULL);
|
||||||
|
|
||||||
/* try to generate a reasonable server tag */
|
/* try to generate a reasonable server tag */
|
||||||
if (strchr(address, '.') == NULL) {
|
if (strchr(address, '.') == NULL) {
|
||||||
start = end = NULL;
|
start = end = NULL;
|
||||||
@ -91,7 +96,9 @@ static char *server_create_tag(SERVER_CONNECT_REC *conn)
|
|||||||
char *tag;
|
char *tag;
|
||||||
int num;
|
int num;
|
||||||
|
|
||||||
tag = conn->ircnet != NULL ? g_strdup(conn->ircnet) :
|
g_return_val_if_fail(IS_SERVER_CONNECT(conn), NULL);
|
||||||
|
|
||||||
|
tag = conn->chatnet != NULL ? g_strdup(conn->chatnet) :
|
||||||
server_create_address_tag(conn->address);
|
server_create_address_tag(conn->address);
|
||||||
|
|
||||||
/* then just append numbers after tag until unused is found.. */
|
/* then just append numbers after tag until unused is found.. */
|
||||||
@ -109,6 +116,8 @@ static void server_connect_callback_init(SERVER_REC *server, int handle)
|
|||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
|
g_return_if_fail(IS_SERVER(server));
|
||||||
|
|
||||||
error = net_geterror(handle);
|
error = net_geterror(handle);
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
server->connection_lost = TRUE;
|
server->connection_lost = TRUE;
|
||||||
@ -122,8 +131,12 @@ static void server_connect_callback_init(SERVER_REC *server, int handle)
|
|||||||
server->connect_tag = -1;
|
server->connect_tag = -1;
|
||||||
server->connect_time = time(NULL);
|
server->connect_time = time(NULL);
|
||||||
server->rawlog = rawlog_create();
|
server->rawlog = rawlog_create();
|
||||||
servers = g_slist_append(servers, server);
|
|
||||||
|
|
||||||
|
server->eventtable = g_hash_table_new((GHashFunc) g_istr_hash, (GCompareFunc) g_istr_equal);
|
||||||
|
server->eventgrouptable = g_hash_table_new((GHashFunc) g_direct_hash, (GCompareFunc) g_direct_equal);
|
||||||
|
server->cmdtable = g_hash_table_new((GHashFunc) g_istr_hash, (GCompareFunc) g_istr_equal);
|
||||||
|
|
||||||
|
servers = g_slist_append(servers, server);
|
||||||
signal_emit("server connected", 1, server);
|
signal_emit("server connected", 1, server);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,6 +147,8 @@ static void server_connect_callback_readpipe(SERVER_REC *server)
|
|||||||
const char *errormsg;
|
const char *errormsg;
|
||||||
int handle;
|
int handle;
|
||||||
|
|
||||||
|
g_return_if_fail(IS_SERVER(server));
|
||||||
|
|
||||||
g_source_remove(server->connect_tag);
|
g_source_remove(server->connect_tag);
|
||||||
server->connect_tag = -1;
|
server->connect_tag = -1;
|
||||||
|
|
||||||
@ -182,13 +197,14 @@ static void server_connect_callback_readpipe(SERVER_REC *server)
|
|||||||
signal_emit("server connecting", 2, server, &iprec.ip);
|
signal_emit("server connecting", 2, server, &iprec.ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
int server_connect(SERVER_REC *server)
|
int server_start_connect(SERVER_REC *server)
|
||||||
{
|
{
|
||||||
const char *connect_address;
|
const char *connect_address;
|
||||||
|
|
||||||
g_return_val_if_fail(server != NULL, FALSE);
|
g_return_val_if_fail(server != NULL, FALSE);
|
||||||
|
|
||||||
MODULE_DATA_INIT(server);
|
MODULE_DATA_INIT(server);
|
||||||
|
server->type = module_get_uniq_id("SERVER", 0);
|
||||||
|
|
||||||
if (pipe(server->connect_pipe) != 0) {
|
if (pipe(server->connect_pipe) != 0) {
|
||||||
g_warning("server_connect(): pipe() failed.");
|
g_warning("server_connect(): pipe() failed.");
|
||||||
@ -213,9 +229,48 @@ int server_connect(SERVER_REC *server)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Connect to server */
|
||||||
|
SERVER_REC *server_connect(SERVER_CONNECT_REC *conn)
|
||||||
|
{
|
||||||
|
SERVER_REC *server;
|
||||||
|
|
||||||
|
g_return_val_if_fail(IS_SERVER_CONNECT(conn), NULL);
|
||||||
|
|
||||||
|
server = NULL;
|
||||||
|
signal_emit("server connect", 2, &server, conn);
|
||||||
|
return server;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int server_remove_channels(SERVER_REC *server)
|
||||||
|
{
|
||||||
|
GSList *tmp;
|
||||||
|
int found;
|
||||||
|
|
||||||
|
g_return_val_if_fail(server != NULL, FALSE);
|
||||||
|
|
||||||
|
found = FALSE;
|
||||||
|
for (tmp = server->channels; tmp != NULL; tmp = tmp->next) {
|
||||||
|
CHANNEL_REC *channel = tmp->data;
|
||||||
|
|
||||||
|
channel->server = NULL;
|
||||||
|
channel_destroy(channel);
|
||||||
|
found = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (tmp = server->queries; tmp != NULL; tmp = tmp->next)
|
||||||
|
query_change_server(tmp->data, NULL);
|
||||||
|
|
||||||
|
g_slist_free(server->channels);
|
||||||
|
g_slist_free(server->queries);
|
||||||
|
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
void server_disconnect(SERVER_REC *server)
|
void server_disconnect(SERVER_REC *server)
|
||||||
{
|
{
|
||||||
g_return_if_fail(server != NULL);
|
int chans;
|
||||||
|
|
||||||
|
g_return_if_fail(IS_SERVER(server));
|
||||||
|
|
||||||
if (server->connect_tag != -1) {
|
if (server->connect_tag != -1) {
|
||||||
/* still connecting to server.. */
|
/* still connecting to server.. */
|
||||||
@ -229,12 +284,27 @@ void server_disconnect(SERVER_REC *server)
|
|||||||
|
|
||||||
signal_emit("server disconnected", 1, server);
|
signal_emit("server disconnected", 1, server);
|
||||||
|
|
||||||
if (server->handle != NULL)
|
/* close all channels */
|
||||||
net_sendbuffer_destroy(server->handle, TRUE);
|
chans = server_remove_channels(server);
|
||||||
|
|
||||||
|
if (server->handle != NULL) {
|
||||||
|
if (!chans || server->connection_lost)
|
||||||
|
net_sendbuffer_destroy(server->handle, TRUE);
|
||||||
|
else {
|
||||||
|
/* we were on some channels, try to let the server
|
||||||
|
disconnect so that our quit message is guaranteed
|
||||||
|
to get displayed */
|
||||||
|
net_disconnect_later(net_sendbuffer_handle(server->handle));
|
||||||
|
net_sendbuffer_destroy(server->handle, FALSE);
|
||||||
|
}
|
||||||
|
server->handle = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (server->readtag > 0)
|
if (server->readtag > 0)
|
||||||
g_source_remove(server->readtag);
|
g_source_remove(server->readtag);
|
||||||
|
|
||||||
MODULE_DATA_DEINIT(server);
|
MODULE_DATA_DEINIT(server);
|
||||||
|
server_connect_free(server->connrec);
|
||||||
rawlog_destroy(server->rawlog);
|
rawlog_destroy(server->rawlog);
|
||||||
line_split_free(server->buffer);
|
line_split_free(server->buffer);
|
||||||
g_free_not_null(server->version);
|
g_free_not_null(server->version);
|
||||||
@ -268,29 +338,54 @@ SERVER_REC *server_find_tag(const char *tag)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SERVER_REC *server_find_ircnet(const char *ircnet)
|
SERVER_REC *server_find_chatnet(const char *chatnet)
|
||||||
{
|
{
|
||||||
GSList *tmp;
|
GSList *tmp;
|
||||||
|
|
||||||
g_return_val_if_fail(ircnet != NULL, NULL);
|
g_return_val_if_fail(chatnet != NULL, NULL);
|
||||||
if (*ircnet == '\0') return NULL;
|
if (*chatnet == '\0') return NULL;
|
||||||
|
|
||||||
for (tmp = servers; tmp != NULL; tmp = tmp->next) {
|
for (tmp = servers; tmp != NULL; tmp = tmp->next) {
|
||||||
SERVER_REC *server = tmp->data;
|
SERVER_REC *server = tmp->data;
|
||||||
|
|
||||||
if (server->connrec->ircnet != NULL &&
|
if (server->connrec->chatnet != NULL &&
|
||||||
g_strcasecmp(server->connrec->ircnet, ircnet) == 0)
|
g_strcasecmp(server->connrec->chatnet, chatnet) == 0)
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void server_connect_free(SERVER_CONNECT_REC *conn)
|
||||||
|
{
|
||||||
|
g_return_if_fail(IS_SERVER_CONNECT(conn));
|
||||||
|
|
||||||
|
signal_emit("server connect free", 1, conn);
|
||||||
|
g_free_not_null(conn->proxy);
|
||||||
|
g_free_not_null(conn->proxy_string);
|
||||||
|
|
||||||
|
g_free_not_null(conn->address);
|
||||||
|
g_free_not_null(conn->chatnet);
|
||||||
|
|
||||||
|
g_free_not_null(conn->own_ip);
|
||||||
|
|
||||||
|
g_free_not_null(conn->password);
|
||||||
|
g_free_not_null(conn->nick);
|
||||||
|
g_free_not_null(conn->username);
|
||||||
|
g_free_not_null(conn->realname);
|
||||||
|
|
||||||
|
g_free_not_null(conn->channels);
|
||||||
|
g_free_not_null(conn->away_reason);
|
||||||
|
g_free_not_null(conn->usermode);
|
||||||
|
g_free(conn);
|
||||||
|
}
|
||||||
|
|
||||||
void servers_init(void)
|
void servers_init(void)
|
||||||
{
|
{
|
||||||
lookup_servers = servers = NULL;
|
lookup_servers = servers = NULL;
|
||||||
|
|
||||||
servers_redirect_init();
|
servers_redirect_init();
|
||||||
|
servers_setup_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void servers_deinit(void)
|
void servers_deinit(void)
|
||||||
@ -300,5 +395,9 @@ void servers_deinit(void)
|
|||||||
while (lookup_servers != NULL)
|
while (lookup_servers != NULL)
|
||||||
server_cant_connect(lookup_servers->data, NULL);
|
server_cant_connect(lookup_servers->data, NULL);
|
||||||
|
|
||||||
|
servers_setup_deinit();
|
||||||
servers_redirect_deinit();
|
servers_redirect_deinit();
|
||||||
|
|
||||||
|
module_uniq_destroy("SERVER");
|
||||||
|
module_uniq_destroy("SERVER CONNECT");
|
||||||
}
|
}
|
52
src/core/servers.h
Normal file
52
src/core/servers.h
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
#ifndef __SERVERS_H
|
||||||
|
#define __SERVERS_H
|
||||||
|
|
||||||
|
#include "modules.h"
|
||||||
|
|
||||||
|
#ifndef __NETWORK_H
|
||||||
|
typedef struct _ipaddr IPADDR;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define IS_SERVER(server) \
|
||||||
|
((server) != NULL && module_find_id("SERVER", (server)->type) != -1)
|
||||||
|
|
||||||
|
#define IS_SERVER_CONNECT(conn) \
|
||||||
|
((conn) != NULL && \
|
||||||
|
module_find_id("SERVER CONNECT", (conn)->type) != -1)
|
||||||
|
|
||||||
|
/* Returns SERVER_REC if it's server, NULL if it isn't. */
|
||||||
|
#define SERVER(server) \
|
||||||
|
(IS_SERVER(server) ? (SERVER_REC *) (server) : NULL)
|
||||||
|
|
||||||
|
/* Returns SERVER_CONNECT_REC if it's server connection, NULL if it isn't. */
|
||||||
|
#define SERVER_CONNECT(conn) \
|
||||||
|
(IS_SERVER_CONNECT(conn) ? (SERVER_CONNECT_REC *) (conn) : NULL)
|
||||||
|
|
||||||
|
/* all strings should be either NULL or dynamically allocated */
|
||||||
|
/* address and nick are mandatory, rest are optional */
|
||||||
|
typedef struct {
|
||||||
|
#include "server-connect-rec.h"
|
||||||
|
} SERVER_CONNECT_REC;
|
||||||
|
|
||||||
|
#define STRUCT_SERVER_CONNECT_REC SERVER_CONNECT_REC
|
||||||
|
typedef struct {
|
||||||
|
#include "server-rec.h"
|
||||||
|
} SERVER_REC;
|
||||||
|
|
||||||
|
extern GSList *servers, *lookup_servers;
|
||||||
|
|
||||||
|
void servers_init(void);
|
||||||
|
void servers_deinit(void);
|
||||||
|
|
||||||
|
/* Connect to server */
|
||||||
|
SERVER_REC *server_connect(SERVER_CONNECT_REC *conn);
|
||||||
|
/* Disconnect from server */
|
||||||
|
void server_disconnect(SERVER_REC *server);
|
||||||
|
|
||||||
|
SERVER_REC *server_find_tag(const char *tag);
|
||||||
|
SERVER_REC *server_find_chatnet(const char *chatnet);
|
||||||
|
|
||||||
|
int server_start_connect(SERVER_REC *server);
|
||||||
|
void server_connect_free(SERVER_CONNECT_REC *conn);
|
||||||
|
|
||||||
|
#endif
|
@ -32,6 +32,7 @@ typedef struct {
|
|||||||
#define iconfig_node_set_str(a, b, c) config_node_set_str(mainconfig, a, b, c)
|
#define iconfig_node_set_str(a, b, c) config_node_set_str(mainconfig, a, b, c)
|
||||||
#define iconfig_node_list_remove(a, b) config_node_list_remove(mainconfig, a, b)
|
#define iconfig_node_list_remove(a, b) config_node_list_remove(mainconfig, a, b)
|
||||||
#define iconfig_node_remove(a, b) config_node_remove(mainconfig, a, b)
|
#define iconfig_node_remove(a, b) config_node_remove(mainconfig, a, b)
|
||||||
|
#define iconfig_node_clear(a) config_node_clear(mainconfig, a)
|
||||||
|
|
||||||
extern CONFIG_REC *mainconfig;
|
extern CONFIG_REC *mainconfig;
|
||||||
|
|
||||||
|
@ -310,7 +310,8 @@ void signal_stop_by_name(const char *signal)
|
|||||||
|
|
||||||
static void signal_remove_module(void *signal, SIGNAL_REC *rec, const char *module)
|
static void signal_remove_module(void *signal, SIGNAL_REC *rec, const char *module)
|
||||||
{
|
{
|
||||||
int signal_id, list, index;
|
unsigned int index;
|
||||||
|
int signal_id, list;
|
||||||
|
|
||||||
signal_id = GPOINTER_TO_INT(signal);
|
signal_id = GPOINTER_TO_INT(signal);
|
||||||
|
|
||||||
|
@ -25,6 +25,10 @@
|
|||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "irssi-version.h"
|
#include "irssi-version.h"
|
||||||
|
|
||||||
|
#include "channels.h"
|
||||||
|
#include "queries.h"
|
||||||
|
#include "window-item-def.h"
|
||||||
|
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
|
|
||||||
#define ALIGN_RIGHT 0x01
|
#define ALIGN_RIGHT 0x01
|
||||||
@ -99,7 +103,7 @@ static char *get_internal_setting(const char *key, int type, int *free_ret)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *get_long_variable_value(const char *key, void *server,
|
static char *get_long_variable_value(const char *key, SERVER_REC *server,
|
||||||
void *item, int *free_ret)
|
void *item, int *free_ret)
|
||||||
{
|
{
|
||||||
EXPANDO_FUNC func;
|
EXPANDO_FUNC func;
|
||||||
@ -126,7 +130,7 @@ static char *get_long_variable_value(const char *key, void *server,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *get_long_variable(char **cmd, void *server,
|
static char *get_long_variable(char **cmd, SERVER_REC *server,
|
||||||
void *item, int *free_ret)
|
void *item, int *free_ret)
|
||||||
{
|
{
|
||||||
char *start, *var, *ret;
|
char *start, *var, *ret;
|
||||||
@ -142,7 +146,7 @@ static char *get_long_variable(char **cmd, void *server,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* return the value of the variable found from `cmd' */
|
/* return the value of the variable found from `cmd' */
|
||||||
static char *get_variable(char **cmd, void *server, void *item,
|
static char *get_variable(char **cmd, SERVER_REC *server, void *item,
|
||||||
char **arglist, int *free_ret, int *arg_used)
|
char **arglist, int *free_ret, int *arg_used)
|
||||||
{
|
{
|
||||||
if (isdigit(**cmd) || **cmd == '*' || **cmd == '-' || **cmd == '~') {
|
if (isdigit(**cmd) || **cmd == '*' || **cmd == '-' || **cmd == '~') {
|
||||||
@ -183,7 +187,7 @@ static char *get_history(char **cmd, void *item, int *free_ret)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *get_special_value(char **cmd, void *server, void *item,
|
static char *get_special_value(char **cmd, SERVER_REC *server, void *item,
|
||||||
char **arglist, int *free_ret, int *arg_used)
|
char **arglist, int *free_ret, int *arg_used)
|
||||||
{
|
{
|
||||||
char command, *value, *p;
|
char command, *value, *p;
|
||||||
@ -313,7 +317,7 @@ static char *get_alignment(const char *text, int align, int flags, char pad)
|
|||||||
|
|
||||||
/* Parse and expand text after '$' character. return value has to be
|
/* Parse and expand text after '$' character. return value has to be
|
||||||
g_free()'d if `free_ret' is TRUE. */
|
g_free()'d if `free_ret' is TRUE. */
|
||||||
char *parse_special(char **cmd, void *server, void *item,
|
char *parse_special(char **cmd, SERVER_REC *server, void *item,
|
||||||
char **arglist, int *free_ret, int *arg_used)
|
char **arglist, int *free_ret, int *arg_used)
|
||||||
{
|
{
|
||||||
static char **nested_orig_cmd = NULL; /* FIXME: KLUDGE! */
|
static char **nested_orig_cmd = NULL; /* FIXME: KLUDGE! */
|
||||||
@ -405,7 +409,7 @@ char *parse_special(char **cmd, void *server, void *item,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* parse the whole string. $ and \ chars are replaced */
|
/* parse the whole string. $ and \ chars are replaced */
|
||||||
char *parse_special_string(const char *cmd, void *server, void *item,
|
char *parse_special_string(const char *cmd, SERVER_REC *server, void *item,
|
||||||
const char *data, int *arg_used)
|
const char *data, int *arg_used)
|
||||||
{
|
{
|
||||||
char code, **arglist, *ret;
|
char code, **arglist, *ret;
|
||||||
@ -466,7 +470,7 @@ char *parse_special_string(const char *cmd, void *server, void *item,
|
|||||||
|
|
||||||
/* execute the commands in string - commands can be split with ';' */
|
/* execute the commands in string - commands can be split with ';' */
|
||||||
void eval_special_string(const char *cmd, const char *data,
|
void eval_special_string(const char *cmd, const char *data,
|
||||||
void *server, void *item)
|
SERVER_REC *server, void *item)
|
||||||
{
|
{
|
||||||
const char *cmdchars;
|
const char *cmdchars;
|
||||||
char *orig, *str, *start, *ret;
|
char *orig, *str, *start, *ret;
|
||||||
@ -556,40 +560,101 @@ void special_history_func_set(SPECIAL_HISTORY_FUNC func)
|
|||||||
history_func = func;
|
history_func = func;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* text of your AWAY message, if any */
|
||||||
|
static char *expando_awaymsg(SERVER_REC *server, void *item, int *free_ret)
|
||||||
|
{
|
||||||
|
return server == NULL ? "" : server->away_reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* current channel */
|
||||||
|
static char *expando_channel(SERVER_REC *server, void *item, int *free_ret)
|
||||||
|
{
|
||||||
|
return !IS_CHANNEL(item) ? NULL : CHANNEL(item)->name;
|
||||||
|
}
|
||||||
|
|
||||||
/* time client was started, $time() format */
|
/* time client was started, $time() format */
|
||||||
static char *expando_clientstarted(void *server, void *item, int *free_ret)
|
static char *expando_clientstarted(SERVER_REC *server, void *item, int *free_ret)
|
||||||
{
|
{
|
||||||
*free_ret = TRUE;
|
*free_ret = TRUE;
|
||||||
return g_strdup_printf("%ld", (long) client_start_time);
|
return g_strdup_printf("%ld", (long) client_start_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* client version text string */
|
/* client version text string */
|
||||||
static char *expando_version(void *server, void *item, int *free_ret)
|
static char *expando_version(SERVER_REC *server, void *item, int *free_ret)
|
||||||
{
|
{
|
||||||
return IRSSI_VERSION;
|
return IRSSI_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* current value of CMDCHARS */
|
/* current value of CMDCHARS */
|
||||||
static char *expando_cmdchars(void *server, void *item, int *free_ret)
|
static char *expando_cmdchars(SERVER_REC *server, void *item, int *free_ret)
|
||||||
{
|
{
|
||||||
return (char *) settings_get_str("cmdchars");
|
return (char *) settings_get_str("cmdchars");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* modes of current channel, if any */
|
||||||
|
static char *expando_chanmode(SERVER_REC *server, void *item, int *free_ret)
|
||||||
|
{
|
||||||
|
return !IS_CHANNEL(item) ? NULL : CHANNEL(item)->mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* current nickname */
|
||||||
|
static char *expando_nick(SERVER_REC *server, void *item, int *free_ret)
|
||||||
|
{
|
||||||
|
return server == NULL ? "" : server->nick;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* value of STATUS_OPER if you are an irc operator */
|
||||||
|
static char *expando_statusoper(SERVER_REC *server, void *item, int *free_ret)
|
||||||
|
{
|
||||||
|
return server == NULL || !server->server_operator ? "" :
|
||||||
|
(char *) settings_get_str("STATUS_OPER");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* if you are a channel operator in $C, expands to a '@' */
|
||||||
|
static char *expando_chanop(SERVER_REC *server, void *item, int *free_ret)
|
||||||
|
{
|
||||||
|
return IS_CHANNEL(item) && CHANNEL(item)->chanop ? "@" : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/* nickname of whomever you are QUERYing */
|
||||||
|
static char *expando_query(SERVER_REC *server, void *item, int *free_ret)
|
||||||
|
{
|
||||||
|
return !IS_QUERY(item) ? "" : QUERY(item)->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* version of current server */
|
||||||
|
static char *expando_serverversion(SERVER_REC *server, void *item, int *free_ret)
|
||||||
|
{
|
||||||
|
return server == NULL ? "" : server->version;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* target of current input (channel or QUERY nickname) */
|
||||||
|
static char *expando_target(SERVER_REC *server, void *item, int *free_ret)
|
||||||
|
{
|
||||||
|
return ((WI_ITEM_REC *) item)->name;
|
||||||
|
}
|
||||||
|
|
||||||
/* client release date (numeric version string) */
|
/* client release date (numeric version string) */
|
||||||
static char *expando_releasedate(void *server, void *item, int *free_ret)
|
static char *expando_releasedate(SERVER_REC *server, void *item, int *free_ret)
|
||||||
{
|
{
|
||||||
return IRSSI_VERSION_DATE;
|
return IRSSI_VERSION_DATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* current working directory */
|
/* current working directory */
|
||||||
static char *expando_workdir(void *server, void *item, int *free_ret)
|
static char *expando_workdir(SERVER_REC *server, void *item, int *free_ret)
|
||||||
{
|
{
|
||||||
*free_ret = TRUE;
|
*free_ret = TRUE;
|
||||||
return g_get_current_dir();
|
return g_get_current_dir();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* value of REALNAME */
|
||||||
|
static char *expando_realname(SERVER_REC *server, void *item, int *free_ret)
|
||||||
|
{
|
||||||
|
return server == NULL ? "" : server->connrec->realname;
|
||||||
|
}
|
||||||
|
|
||||||
/* time of day (hh:mm) */
|
/* time of day (hh:mm) */
|
||||||
static char *expando_time(void *server, void *item, int *free_ret)
|
static char *expando_time(SERVER_REC *server, void *item, int *free_ret)
|
||||||
{
|
{
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
struct tm *tm;
|
struct tm *tm;
|
||||||
@ -600,13 +665,13 @@ static char *expando_time(void *server, void *item, int *free_ret)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* a literal '$' */
|
/* a literal '$' */
|
||||||
static char *expando_dollar(void *server, void *item, int *free_ret)
|
static char *expando_dollar(SERVER_REC *server, void *item, int *free_ret)
|
||||||
{
|
{
|
||||||
return "$";
|
return "$";
|
||||||
}
|
}
|
||||||
|
|
||||||
/* system name */
|
/* system name */
|
||||||
static char *expando_sysname(void *server, void *item, int *free_ret)
|
static char *expando_sysname(SERVER_REC *server, void *item, int *free_ret)
|
||||||
{
|
{
|
||||||
struct utsname un;
|
struct utsname un;
|
||||||
|
|
||||||
@ -619,7 +684,7 @@ static char *expando_sysname(void *server, void *item, int *free_ret)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* system release */
|
/* system release */
|
||||||
static char *expando_sysrelease(void *server, void *item, int *free_ret)
|
static char *expando_sysrelease(SERVER_REC *server, void *item, int *free_ret)
|
||||||
{
|
{
|
||||||
struct utsname un;
|
struct utsname un;
|
||||||
|
|
||||||
@ -631,8 +696,22 @@ static char *expando_sysrelease(void *server, void *item, int *free_ret)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Server tag */
|
||||||
|
static char *expando_servertag(SERVER_REC *server, void *item, int *free_ret)
|
||||||
|
{
|
||||||
|
return server == NULL ? "" : server->tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Server chatnet */
|
||||||
|
static char *expando_chatnet(SERVER_REC *server, void *item, int *free_ret)
|
||||||
|
{
|
||||||
|
return server == NULL ? "" : server->connrec->chatnet;
|
||||||
|
}
|
||||||
|
|
||||||
void special_vars_init(void)
|
void special_vars_init(void)
|
||||||
{
|
{
|
||||||
|
settings_add_str("misc", "STATUS_OPER", "*");
|
||||||
|
|
||||||
client_start_time = time(NULL);
|
client_start_time = time(NULL);
|
||||||
|
|
||||||
memset(char_expandos, 0, sizeof(char_expandos));
|
memset(char_expandos, 0, sizeof(char_expandos));
|
||||||
@ -640,22 +719,36 @@ void special_vars_init(void)
|
|||||||
(GCompareFunc) g_str_equal);
|
(GCompareFunc) g_str_equal);
|
||||||
history_func = NULL;
|
history_func = NULL;
|
||||||
|
|
||||||
|
char_expandos['A'] = expando_awaymsg;
|
||||||
|
char_expandos['C'] = expando_channel;
|
||||||
char_expandos['F'] = expando_clientstarted;
|
char_expandos['F'] = expando_clientstarted;
|
||||||
char_expandos['J'] = expando_version;
|
char_expandos['J'] = expando_version;
|
||||||
char_expandos['K'] = expando_cmdchars;
|
char_expandos['K'] = expando_cmdchars;
|
||||||
|
char_expandos['M'] = expando_chanmode;
|
||||||
|
char_expandos['N'] = expando_nick;
|
||||||
|
char_expandos['O'] = expando_statusoper;
|
||||||
|
char_expandos['P'] = expando_chanop;
|
||||||
|
char_expandos['Q'] = expando_query;
|
||||||
|
char_expandos['R'] = expando_serverversion;
|
||||||
|
char_expandos['T'] = expando_target;
|
||||||
char_expandos['V'] = expando_releasedate;
|
char_expandos['V'] = expando_releasedate;
|
||||||
char_expandos['W'] = expando_workdir;
|
char_expandos['W'] = expando_workdir;
|
||||||
|
char_expandos['Y'] = expando_realname;
|
||||||
char_expandos['Z'] = expando_time;
|
char_expandos['Z'] = expando_time;
|
||||||
char_expandos['$'] = expando_dollar;
|
char_expandos['$'] = expando_dollar;
|
||||||
|
|
||||||
expando_create("sysname", expando_sysname);
|
expando_create("sysname", expando_sysname);
|
||||||
expando_create("sysrelease", expando_sysrelease);
|
expando_create("sysrelease", expando_sysrelease);
|
||||||
|
expando_create("tag", expando_servertag);
|
||||||
|
expando_create("chatnet", expando_chatnet);
|
||||||
}
|
}
|
||||||
|
|
||||||
void special_vars_deinit(void)
|
void special_vars_deinit(void)
|
||||||
{
|
{
|
||||||
expando_destroy("sysname", expando_sysname);
|
expando_destroy("sysname", expando_sysname);
|
||||||
expando_destroy("sysrelease", expando_sysrelease);
|
expando_destroy("sysrelease", expando_sysrelease);
|
||||||
|
expando_destroy("tag", expando_servertag);
|
||||||
|
expando_destroy("chatnet", expando_chatnet);
|
||||||
|
|
||||||
g_hash_table_destroy(expandos);
|
g_hash_table_destroy(expandos);
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,25 @@
|
|||||||
#ifndef __SPECIAL_VARS_H
|
#ifndef __SPECIAL_VARS_H
|
||||||
#define __SPECIAL_VARS_H
|
#define __SPECIAL_VARS_H
|
||||||
|
|
||||||
typedef char* (*EXPANDO_FUNC) (void *server, void *item, int *free_ret);
|
#include "servers.h"
|
||||||
typedef char* (*SPECIAL_HISTORY_FUNC) (const char *text, void *item, int *free_ret);
|
|
||||||
|
typedef char* (*EXPANDO_FUNC)
|
||||||
|
(SERVER_REC *server, void *item, int *free_ret);
|
||||||
|
typedef char* (*SPECIAL_HISTORY_FUNC)
|
||||||
|
(const char *text, void *item, int *free_ret);
|
||||||
|
|
||||||
/* Parse and expand text after '$' character. return value has to be
|
/* Parse and expand text after '$' character. return value has to be
|
||||||
g_free()'d if `free_ret' is TRUE. */
|
g_free()'d if `free_ret' is TRUE. */
|
||||||
char *parse_special(char **cmd, void *server, void *item, char **arglist, int *free_ret, int *arg_used);
|
char *parse_special(char **cmd, SERVER_REC *server, void *item,
|
||||||
|
char **arglist, int *free_ret, int *arg_used);
|
||||||
|
|
||||||
/* parse the whole string. $ and \ chars are replaced */
|
/* parse the whole string. $ and \ chars are replaced */
|
||||||
char *parse_special_string(const char *cmd, void *server, void *item, const char *data, int *arg_used);
|
char *parse_special_string(const char *cmd, SERVER_REC *server, void *item,
|
||||||
|
const char *data, int *arg_used);
|
||||||
|
|
||||||
/* execute the commands in string - commands can be split with ';' */
|
/* execute the commands in string - commands can be split with ';' */
|
||||||
void eval_special_string(const char *cmd, const char *data, void *server, void *item);
|
void eval_special_string(const char *cmd, const char *data,
|
||||||
|
SERVER_REC *server, void *item);
|
||||||
|
|
||||||
/* Create expando - overrides any existing ones. */
|
/* Create expando - overrides any existing ones. */
|
||||||
void expando_create(const char *key, EXPANDO_FUNC func);
|
void expando_create(const char *key, EXPANDO_FUNC func);
|
||||||
|
9
src/core/window-item-def.h
Normal file
9
src/core/window-item-def.h
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#ifndef __WINDOW_ITEM_DEF_H
|
||||||
|
#define __WINDOW_ITEM_DEF_H
|
||||||
|
|
||||||
|
#define STRUCT_SERVER_REC SERVER_REC
|
||||||
|
typedef struct {
|
||||||
|
#include "window-item-rec.h"
|
||||||
|
} WI_ITEM_REC;
|
||||||
|
|
||||||
|
#endif
|
14
src/core/window-item-rec.h
Normal file
14
src/core/window-item-rec.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
/* WI_ITEM_REC definition, used for inheritance */
|
||||||
|
|
||||||
|
int type; /* window item type - channel/query/.. */
|
||||||
|
int chat_type; /* chat server type - irc/silc/.. */
|
||||||
|
GHashTable *module_data;
|
||||||
|
|
||||||
|
STRUCT_SERVER_REC *server;
|
||||||
|
char *name;
|
||||||
|
|
||||||
|
time_t createtime;
|
||||||
|
int new_data;
|
||||||
|
int last_color; /* if NEWDATA_HILIGHT is set, color number could be specified here */
|
||||||
|
|
||||||
|
#undef STRUCT_SERVER_REC
|
@ -1,4 +1,4 @@
|
|||||||
noinst_LTLIBRARIES = libfe_common_core.la
|
noinst_LIBRARIES = libfe_common_core.a
|
||||||
|
|
||||||
INCLUDES = \
|
INCLUDES = \
|
||||||
$(GLIB_CFLAGS) \
|
$(GLIB_CFLAGS) \
|
||||||
@ -6,7 +6,7 @@ INCLUDES = \
|
|||||||
-DHELPDIR=\""$(datadir)/irssi/help"\" \
|
-DHELPDIR=\""$(datadir)/irssi/help"\" \
|
||||||
-DSYSCONFDIR=\""$(sysconfdir)"\"
|
-DSYSCONFDIR=\""$(sysconfdir)"\"
|
||||||
|
|
||||||
libfe_common_core_la_SOURCES = \
|
libfe_common_core_a_SOURCES = \
|
||||||
autorun.c \
|
autorun.c \
|
||||||
command-history.c \
|
command-history.c \
|
||||||
completion.c \
|
completion.c \
|
||||||
|
@ -133,6 +133,8 @@ void fe_common_core_finish_init(void)
|
|||||||
{
|
{
|
||||||
WINDOW_REC *window;
|
WINDOW_REC *window;
|
||||||
|
|
||||||
|
signal_emit("irssi init read settings", 0);
|
||||||
|
|
||||||
signal(SIGPIPE, SIG_IGN);
|
signal(SIGPIPE, SIG_IGN);
|
||||||
|
|
||||||
windows_restore();
|
windows_restore();
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#include "module-formats.h"
|
#include "module-formats.h"
|
||||||
#include "signals.h"
|
#include "signals.h"
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
#include "server.h"
|
#include "servers.h"
|
||||||
#include "levels.h"
|
#include "levels.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
@ -19,13 +19,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include "module-formats.h"
|
|
||||||
#include "signals.h"
|
#include "signals.h"
|
||||||
#include "settings.h"
|
|
||||||
#include "network.h"
|
#include "network.h"
|
||||||
|
|
||||||
#include "levels.h"
|
#include "levels.h"
|
||||||
#include "server.h"
|
#include "servers.h"
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
|
#include "module-formats.h"
|
||||||
|
|
||||||
static void sig_server_looking(SERVER_REC *server)
|
static void sig_server_looking(SERVER_REC *server)
|
||||||
{
|
{
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#include "module-formats.h"
|
#include "module-formats.h"
|
||||||
#include "signals.h"
|
#include "signals.h"
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
#include "server.h"
|
#include "servers.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "lib-config/iconfig.h"
|
#include "lib-config/iconfig.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
#include "levels.h"
|
#include "levels.h"
|
||||||
#include "server.h"
|
#include "servers.h"
|
||||||
|
|
||||||
#include "hilight-text.h"
|
#include "hilight-text.h"
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
#include "levels.h"
|
#include "levels.h"
|
||||||
#include "server.h"
|
#include "servers.h"
|
||||||
|
|
||||||
#include "translation.h"
|
#include "translation.h"
|
||||||
#include "themes.h"
|
#include "themes.h"
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include "signals.h"
|
#include "signals.h"
|
||||||
#include "levels.h"
|
#include "levels.h"
|
||||||
#include "server.h"
|
#include "servers.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include "signals.h"
|
#include "signals.h"
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "server.h"
|
#include "servers.h"
|
||||||
|
|
||||||
#include "levels.h"
|
#include "levels.h"
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ static void cmd_window_server(const char *data)
|
|||||||
else if (active_win->active == NULL) {
|
else if (active_win->active == NULL) {
|
||||||
window_change_server(active_win, server);
|
window_change_server(active_win, server);
|
||||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_SERVER_CHANGED, server->tag, server->connrec->address,
|
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_SERVER_CHANGED, server->tag, server->connrec->address,
|
||||||
server->connrec->ircnet == NULL ? "" : server->connrec->ircnet);
|
server->connrec->chatnet == NULL ? "" : server->connrec->chatnet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#include "module-formats.h"
|
#include "module-formats.h"
|
||||||
#include "modules.h"
|
#include "modules.h"
|
||||||
#include "signals.h"
|
#include "signals.h"
|
||||||
#include "server.h"
|
#include "servers.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
#include "levels.h"
|
#include "levels.h"
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include "signals.h"
|
#include "signals.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "server.h"
|
#include "servers.h"
|
||||||
#include "lib-config/iconfig.h"
|
#include "lib-config/iconfig.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include "modules.h"
|
#include "modules.h"
|
||||||
#include "signals.h"
|
#include "signals.h"
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
#include "server.h"
|
#include "servers.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
#ifndef __WINDOWS_H
|
#ifndef __WINDOWS_H
|
||||||
#define __WINDOWS_H
|
#define __WINDOWS_H
|
||||||
|
|
||||||
|
#include "servers.h"
|
||||||
|
|
||||||
|
#define STRUCT_SERVER_REC SERVER_REC
|
||||||
|
#include "window-item-def.h"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
NEWDATA_TEXT = 1,
|
NEWDATA_TEXT = 1,
|
||||||
NEWDATA_MSG,
|
NEWDATA_MSG,
|
||||||
@ -8,30 +13,13 @@ enum {
|
|||||||
NEWDATA_CUSTOM
|
NEWDATA_CUSTOM
|
||||||
};
|
};
|
||||||
|
|
||||||
/* All window items *MUST* have these variables in same order
|
|
||||||
at the start of the structure - the server's type can of course be
|
|
||||||
replaced with the preferred record type.
|
|
||||||
|
|
||||||
!!!! So IF YOU CHANGE THIS: REMEMBER TO UPDATE WI_IRC_REC, CHANNEL_REC
|
|
||||||
and QUERY_REC !!!! (I already forgot this once :) */
|
|
||||||
typedef struct {
|
|
||||||
int type;
|
|
||||||
GHashTable *module_data;
|
|
||||||
|
|
||||||
void *server;
|
|
||||||
char *name;
|
|
||||||
|
|
||||||
int new_data;
|
|
||||||
int last_color; /* if NEWDATA_HILIGHT is set, color number could be specified here */
|
|
||||||
} WI_ITEM_REC;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int refnum;
|
int refnum;
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
GSList *items;
|
GSList *items;
|
||||||
WI_ITEM_REC *active;
|
WI_ITEM_REC *active;
|
||||||
void *active_server;
|
SERVER_REC *active_server;
|
||||||
|
|
||||||
GSList *waiting_channels; /* list of "<server tag> <channel>" */
|
GSList *waiting_channels; /* list of "<server tag> <channel>" */
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
SUBDIRS = dcc flood notifylist
|
SUBDIRS = dcc flood notifylist
|
||||||
|
|
||||||
noinst_LTLIBRARIES = libfe_common_irc.la
|
noinst_LIBRARIES = libfe_common_irc.a
|
||||||
|
|
||||||
INCLUDES = \
|
INCLUDES = \
|
||||||
$(GLIB_CFLAGS) \
|
$(GLIB_CFLAGS) \
|
||||||
@ -11,7 +11,7 @@ INCLUDES = \
|
|||||||
-DHELPDIR=\""$(datadir)/irssi/help"\" \
|
-DHELPDIR=\""$(datadir)/irssi/help"\" \
|
||||||
-DSYSCONFDIR=\""$(sysconfdir)"\"
|
-DSYSCONFDIR=\""$(sysconfdir)"\"
|
||||||
|
|
||||||
libfe_common_irc_la_SOURCES = \
|
libfe_common_irc_a_SOURCES = \
|
||||||
fe-channels.c \
|
fe-channels.c \
|
||||||
fe-irc-commands.c \
|
fe-irc-commands.c \
|
||||||
fe-irc-server.c \
|
fe-irc-server.c \
|
||||||
@ -22,7 +22,7 @@ libfe_common_irc_la_SOURCES = \
|
|||||||
fe-ignore.c \
|
fe-ignore.c \
|
||||||
fe-netjoin.c \
|
fe-netjoin.c \
|
||||||
fe-netsplit.c \
|
fe-netsplit.c \
|
||||||
fe-query.c \
|
fe-queries.c \
|
||||||
fe-common-irc.c \
|
fe-common-irc.c \
|
||||||
irc-completion.c \
|
irc-completion.c \
|
||||||
irc-window-activity.c \
|
irc-window-activity.c \
|
||||||
@ -32,7 +32,7 @@ libfe_common_irc_la_SOURCES = \
|
|||||||
|
|
||||||
noinst_HEADERS = \
|
noinst_HEADERS = \
|
||||||
fe-common-irc.h \
|
fe-common-irc.h \
|
||||||
fe-query.h \
|
fe-queries.h \
|
||||||
irc-hilight-text.h \
|
irc-hilight-text.h \
|
||||||
module.h \
|
module.h \
|
||||||
module-formats.h
|
module-formats.h
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include "./module-formats.h"
|
|
||||||
#include "signals.h"
|
#include "signals.h"
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
#include "network.h"
|
#include "network.h"
|
||||||
@ -27,7 +26,7 @@
|
|||||||
#include "levels.h"
|
#include "levels.h"
|
||||||
#include "irc.h"
|
#include "irc.h"
|
||||||
#include "channels.h"
|
#include "channels.h"
|
||||||
#include "query.h"
|
#include "irc-queries.h"
|
||||||
|
|
||||||
#include "irc/dcc/dcc.h"
|
#include "irc/dcc/dcc.h"
|
||||||
|
|
||||||
@ -35,6 +34,8 @@
|
|||||||
#include "themes.h"
|
#include "themes.h"
|
||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
|
|
||||||
|
#include "module-formats.h"
|
||||||
|
|
||||||
static void dcc_connected(DCC_REC *dcc)
|
static void dcc_connected(DCC_REC *dcc)
|
||||||
{
|
{
|
||||||
char *sender;
|
char *sender;
|
||||||
@ -47,7 +48,7 @@ static void dcc_connected(DCC_REC *dcc)
|
|||||||
printformat(dcc->server, sender, MSGLEVEL_DCC, IRCTXT_DCC_CHAT_CONNECTED,
|
printformat(dcc->server, sender, MSGLEVEL_DCC, IRCTXT_DCC_CHAT_CONNECTED,
|
||||||
dcc->nick, dcc->addrstr, dcc->port);
|
dcc->nick, dcc->addrstr, dcc->port);
|
||||||
if (query_find(NULL, sender) == NULL)
|
if (query_find(NULL, sender) == NULL)
|
||||||
query_create(dcc->server, sender, TRUE);
|
irc_query_create(dcc->server, sender, TRUE);
|
||||||
g_free(sender);
|
g_free(sender);
|
||||||
break;
|
break;
|
||||||
case DCC_TYPE_SEND:
|
case DCC_TYPE_SEND:
|
||||||
@ -278,10 +279,10 @@ static void sig_query_destroyed(QUERY_REC *query)
|
|||||||
{
|
{
|
||||||
DCC_REC *dcc;
|
DCC_REC *dcc;
|
||||||
|
|
||||||
if (*query->nick != '=')
|
if (*query->name != '=')
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dcc = dcc_find_item(DCC_TYPE_CHAT, query->nick+1, NULL);
|
dcc = dcc_find_item(DCC_TYPE_CHAT, query->name+1, NULL);
|
||||||
if (dcc != NULL && !dcc->destroyed) {
|
if (dcc != NULL && !dcc->destroyed) {
|
||||||
/* DCC query window closed, close the dcc chat too. */
|
/* DCC query window closed, close the dcc chat too. */
|
||||||
signal_emit("dcc closed", 1, dcc);
|
signal_emit("dcc closed", 1, dcc);
|
||||||
@ -318,7 +319,7 @@ static void cmd_msg(const char *data)
|
|||||||
cmd_params_free(free_arg);
|
cmd_params_free(free_arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_me(const char *data, SERVER_REC *server, WI_IRC_REC *item)
|
static void cmd_me(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
DCC_REC *dcc;
|
DCC_REC *dcc;
|
||||||
|
|
||||||
@ -331,7 +332,7 @@ static void cmd_me(const char *data, SERVER_REC *server, WI_IRC_REC *item)
|
|||||||
IRCTXT_OWN_DCC_ME, dcc->mynick, data);
|
IRCTXT_OWN_DCC_ME, dcc->mynick, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_action(const char *data, SERVER_REC *server, WI_IRC_REC *item)
|
static void cmd_action(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
DCC_REC *dcc;
|
DCC_REC *dcc;
|
||||||
char *target, *text;
|
char *target, *text;
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
#include "irc.h"
|
#include "irc.h"
|
||||||
#include "channels.h"
|
#include "irc-channels.h"
|
||||||
#include "channels-setup.h"
|
#include "channels-setup.h"
|
||||||
#include "nicklist.h"
|
#include "nicklist.h"
|
||||||
|
|
||||||
@ -70,12 +70,12 @@ static void signal_channel_destroyed(CHANNEL_REC *channel)
|
|||||||
|
|
||||||
static void signal_window_item_removed(WINDOW_REC *window, WI_ITEM_REC *item)
|
static void signal_window_item_removed(WINDOW_REC *window, WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
CHANNEL_REC *channel;
|
IRC_CHANNEL_REC *channel;
|
||||||
|
|
||||||
g_return_if_fail(window != NULL);
|
g_return_if_fail(window != NULL);
|
||||||
|
|
||||||
channel = irc_item_channel(item);
|
channel = IRC_CHANNEL(item);
|
||||||
if (channel != NULL) channel_destroy(channel);
|
if (channel != NULL) channel_destroy(CHANNEL(channel));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sig_disconnected(IRC_SERVER_REC *server)
|
static void sig_disconnected(IRC_SERVER_REC *server)
|
||||||
@ -84,7 +84,7 @@ static void sig_disconnected(IRC_SERVER_REC *server)
|
|||||||
GSList *tmp;
|
GSList *tmp;
|
||||||
|
|
||||||
g_return_if_fail(server != NULL);
|
g_return_if_fail(server != NULL);
|
||||||
if (!irc_server_check(server))
|
if (!IS_IRC_SERVER(server))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (tmp = server->channels; tmp != NULL; tmp = tmp->next) {
|
for (tmp = server->channels; tmp != NULL; tmp = tmp->next) {
|
||||||
@ -101,7 +101,7 @@ static void signal_window_item_changed(WINDOW_REC *window, WI_ITEM_REC *item)
|
|||||||
g_return_if_fail(window != NULL);
|
g_return_if_fail(window != NULL);
|
||||||
if (item == NULL) return;
|
if (item == NULL) return;
|
||||||
|
|
||||||
if (g_slist_length(window->items) > 1 && irc_item_channel(item)) {
|
if (g_slist_length(window->items) > 1 && IS_IRC_CHANNEL(item)) {
|
||||||
printformat(item->server, item->name, MSGLEVEL_CLIENTNOTICE,
|
printformat(item->server, item->name, MSGLEVEL_CLIENTNOTICE,
|
||||||
IRCTXT_TALKING_IN, item->name);
|
IRCTXT_TALKING_IN, item->name);
|
||||||
signal_stop();
|
signal_stop();
|
||||||
@ -146,7 +146,7 @@ static void cmd_wjoin_post(const char *data)
|
|||||||
|
|
||||||
static void cmd_channel_list_joined(void)
|
static void cmd_channel_list_joined(void)
|
||||||
{
|
{
|
||||||
CHANNEL_REC *channel;
|
IRC_CHANNEL_REC *channel;
|
||||||
GString *nicks;
|
GString *nicks;
|
||||||
GSList *nicklist, *tmp, *ntmp;
|
GSList *nicklist, *tmp, *ntmp;
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ static void cmd_channel_list_joined(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* print active channel */
|
/* print active channel */
|
||||||
channel = irc_item_channel(active_win->active);
|
channel = IRC_CHANNEL(active_win->active);
|
||||||
if (channel != NULL)
|
if (channel != NULL)
|
||||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_CURRENT_CHANNEL, channel->name);
|
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_CURRENT_CHANNEL, channel->name);
|
||||||
|
|
||||||
@ -165,7 +165,7 @@ static void cmd_channel_list_joined(void)
|
|||||||
for (tmp = channels; tmp != NULL; tmp = tmp->next) {
|
for (tmp = channels; tmp != NULL; tmp = tmp->next) {
|
||||||
channel = tmp->data;
|
channel = tmp->data;
|
||||||
|
|
||||||
nicklist = nicklist_getnicks(channel);
|
nicklist = nicklist_getnicks(CHANNEL(channel));
|
||||||
nicks = g_string_new(NULL);
|
nicks = g_string_new(NULL);
|
||||||
for (ntmp = nicklist; ntmp != NULL; ntmp = ntmp->next) {
|
for (ntmp = nicklist; ntmp != NULL; ntmp = ntmp->next) {
|
||||||
NICK_REC *rec = ntmp->data;
|
NICK_REC *rec = ntmp->data;
|
||||||
@ -191,7 +191,7 @@ static void cmd_channel_list(void)
|
|||||||
str = g_string_new(NULL);
|
str = g_string_new(NULL);
|
||||||
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_CHANSETUP_HEADER);
|
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_CHANSETUP_HEADER);
|
||||||
for (tmp = setupchannels; tmp != NULL; tmp = tmp->next) {
|
for (tmp = setupchannels; tmp != NULL; tmp = tmp->next) {
|
||||||
SETUP_CHANNEL_REC *rec = tmp->data;
|
CHANNEL_SETUP_REC *rec = tmp->data;
|
||||||
|
|
||||||
g_string_truncate(str, 0);
|
g_string_truncate(str, 0);
|
||||||
if (rec->autojoin)
|
if (rec->autojoin)
|
||||||
@ -203,7 +203,7 @@ static void cmd_channel_list(void)
|
|||||||
|
|
||||||
if (str->len > 2) g_string_truncate(str, str->len-2);
|
if (str->len > 2) g_string_truncate(str, str->len-2);
|
||||||
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_CHANSETUP_LINE,
|
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_CHANSETUP_LINE,
|
||||||
rec->name, rec->ircnet == NULL ? "" : rec->ircnet,
|
rec->name, rec->chatnet == NULL ? "" : rec->chatnet,
|
||||||
rec->password == NULL ? "" : rec->password, str->str);
|
rec->password == NULL ? "" : rec->password, str->str);
|
||||||
}
|
}
|
||||||
g_string_free(str, TRUE);
|
g_string_free(str, TRUE);
|
||||||
@ -225,7 +225,7 @@ static void cmd_channel(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *i
|
|||||||
static void cmd_channel_add(const char *data)
|
static void cmd_channel_add(const char *data)
|
||||||
{
|
{
|
||||||
GHashTable *optlist;
|
GHashTable *optlist;
|
||||||
SETUP_CHANNEL_REC *rec;
|
CHANNEL_SETUP_REC *rec;
|
||||||
char *botarg, *botcmdarg, *ircnet, *channel, *password;
|
char *botarg, *botcmdarg, *ircnet, *channel, *password;
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
|
|
||||||
@ -240,9 +240,9 @@ static void cmd_channel_add(const char *data)
|
|||||||
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
||||||
rec = channels_setup_find(channel, ircnet);
|
rec = channels_setup_find(channel, ircnet);
|
||||||
if (rec == NULL) {
|
if (rec == NULL) {
|
||||||
rec = g_new0(SETUP_CHANNEL_REC, 1);
|
rec = g_new0(CHANNEL_SETUP_REC, 1);
|
||||||
rec->name = g_strdup(channel);
|
rec->name = g_strdup(channel);
|
||||||
rec->ircnet = g_strdup(ircnet);
|
rec->chatnet = g_strdup(ircnet);
|
||||||
} else {
|
} else {
|
||||||
if (g_hash_table_lookup(optlist, "bots")) g_free_and_null(rec->botmasks);
|
if (g_hash_table_lookup(optlist, "bots")) g_free_and_null(rec->botmasks);
|
||||||
if (g_hash_table_lookup(optlist, "botcmd")) g_free_and_null(rec->autosendcmd);
|
if (g_hash_table_lookup(optlist, "botcmd")) g_free_and_null(rec->autosendcmd);
|
||||||
@ -262,7 +262,7 @@ static void cmd_channel_add(const char *data)
|
|||||||
/* SYNTAX: CHANNEL REMOVE <channel> <ircnet> */
|
/* SYNTAX: CHANNEL REMOVE <channel> <ircnet> */
|
||||||
static void cmd_channel_remove(const char *data)
|
static void cmd_channel_remove(const char *data)
|
||||||
{
|
{
|
||||||
SETUP_CHANNEL_REC *rec;
|
CHANNEL_SETUP_REC *rec;
|
||||||
char *ircnet, *channel;
|
char *ircnet, *channel;
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include "lib-config/iconfig.h"
|
#include "lib-config/iconfig.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
#include "server-setup.h"
|
#include "servers-setup.h"
|
||||||
|
|
||||||
#include "themes.h"
|
#include "themes.h"
|
||||||
#include "completion.h"
|
#include "completion.h"
|
||||||
@ -181,12 +181,12 @@ void fe_common_irc_finish_init(void)
|
|||||||
/* connect to autoconnect servers */
|
/* connect to autoconnect servers */
|
||||||
ircnets = NULL;
|
ircnets = NULL;
|
||||||
for (tmp = setupservers; tmp != NULL; tmp = tmp->next) {
|
for (tmp = setupservers; tmp != NULL; tmp = tmp->next) {
|
||||||
SETUP_SERVER_REC *rec = tmp->data;
|
SERVER_SETUP_REC *rec = tmp->data;
|
||||||
|
|
||||||
if (rec->autoconnect && (rec->ircnet == NULL || *rec->ircnet == '\0' ||
|
if (rec->autoconnect && (rec->chatnet == NULL || *rec->chatnet == '\0' ||
|
||||||
gslist_find_icase_string(ircnets, rec->ircnet) == NULL)) {
|
gslist_find_icase_string(ircnets, rec->chatnet) == NULL)) {
|
||||||
if (rec->ircnet != NULL && *rec->ircnet != '\0')
|
if (rec->chatnet != NULL && *rec->chatnet != '\0')
|
||||||
ircnets = g_slist_append(ircnets, rec->ircnet);
|
ircnets = g_slist_append(ircnets, rec->chatnet);
|
||||||
|
|
||||||
str = g_strdup_printf("%s %d", rec->address, rec->port);
|
str = g_strdup_printf("%s %d", rec->address, rec->port);
|
||||||
signal_emit("command connect", 1, str);
|
signal_emit("command connect", 1, str);
|
||||||
|
@ -25,9 +25,9 @@
|
|||||||
|
|
||||||
#include "irc.h"
|
#include "irc.h"
|
||||||
#include "levels.h"
|
#include "levels.h"
|
||||||
#include "server.h"
|
#include "servers.h"
|
||||||
#include "channels.h"
|
#include "channels.h"
|
||||||
#include "query.h"
|
#include "queries.h"
|
||||||
#include "ignore.h"
|
#include "ignore.h"
|
||||||
|
|
||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
|
|
||||||
#include "irc.h"
|
#include "irc.h"
|
||||||
#include "levels.h"
|
#include "levels.h"
|
||||||
#include "server.h"
|
#include "servers.h"
|
||||||
#include "channels.h"
|
#include "irc-channels.h"
|
||||||
#include "nicklist.h"
|
#include "nicklist.h"
|
||||||
|
|
||||||
static char *last_away_nick = NULL;
|
static char *last_away_nick = NULL;
|
||||||
@ -64,7 +64,7 @@ static void event_names_list(const char *data, IRC_SERVER_REC *server)
|
|||||||
g_return_if_fail(data != NULL);
|
g_return_if_fail(data != NULL);
|
||||||
|
|
||||||
params = event_get_params(data, 4, NULL, NULL, &channel, &names);
|
params = event_get_params(data, 4, NULL, NULL, &channel, &names);
|
||||||
if (channel_find(server, channel) == NULL)
|
if (irc_channel_find(server, channel) == NULL)
|
||||||
printformat(server, channel, MSGLEVEL_CRAP, IRCTXT_NAMES, channel, names);
|
printformat(server, channel, MSGLEVEL_CRAP, IRCTXT_NAMES, channel, names);
|
||||||
g_free(params);
|
g_free(params);
|
||||||
}
|
}
|
||||||
@ -160,17 +160,17 @@ static void display_nicks(CHANNEL_REC *channel)
|
|||||||
static void event_end_of_names(const char *data, IRC_SERVER_REC *server)
|
static void event_end_of_names(const char *data, IRC_SERVER_REC *server)
|
||||||
{
|
{
|
||||||
char *params, *channel;
|
char *params, *channel;
|
||||||
CHANNEL_REC *chanrec;
|
IRC_CHANNEL_REC *chanrec;
|
||||||
|
|
||||||
g_return_if_fail(data != NULL);
|
g_return_if_fail(data != NULL);
|
||||||
|
|
||||||
params = event_get_params(data, 2, NULL, &channel);
|
params = event_get_params(data, 2, NULL, &channel);
|
||||||
|
|
||||||
chanrec = channel_find(server, channel);
|
chanrec = irc_channel_find(server, channel);
|
||||||
if (chanrec == NULL)
|
if (chanrec == NULL)
|
||||||
printformat(server, channel, MSGLEVEL_CRAP, IRCTXT_ENDOFNAMES, channel, 0, 0, 0, 0);
|
printformat(server, channel, MSGLEVEL_CRAP, IRCTXT_ENDOFNAMES, channel, 0, 0, 0, 0);
|
||||||
else
|
else
|
||||||
display_nicks(chanrec);
|
display_nicks(CHANNEL(chanrec));
|
||||||
g_free(params);
|
g_free(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,15 +26,15 @@
|
|||||||
|
|
||||||
#include "irc.h"
|
#include "irc.h"
|
||||||
#include "levels.h"
|
#include "levels.h"
|
||||||
#include "server.h"
|
#include "servers.h"
|
||||||
#include "server-redirect.h"
|
#include "servers-redirect.h"
|
||||||
#include "server-reconnect.h"
|
#include "servers-reconnect.h"
|
||||||
#include "channels.h"
|
#include "queries.h"
|
||||||
#include "query.h"
|
|
||||||
#include "nicklist.h"
|
|
||||||
#include "ignore.h"
|
#include "ignore.h"
|
||||||
|
|
||||||
#include "fe-query.h"
|
#include "fe-queries.h"
|
||||||
|
#include "irc-channels.h"
|
||||||
|
#include "irc-nicklist.h"
|
||||||
#include "irc-hilight-text.h"
|
#include "irc-hilight-text.h"
|
||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
|
|
||||||
@ -47,17 +47,18 @@ static void print_channel_msg(IRC_SERVER_REC *server, const char *msg,
|
|||||||
const char *nick, const char *addr,
|
const char *nick, const char *addr,
|
||||||
const char *target)
|
const char *target)
|
||||||
{
|
{
|
||||||
CHANNEL_REC *chanrec;
|
IRC_CHANNEL_REC *chanrec;
|
||||||
NICK_REC *nickrec;
|
NICK_REC *nickrec;
|
||||||
const char *nickmode;
|
const char *nickmode;
|
||||||
int for_me, print_channel;
|
int for_me, print_channel;
|
||||||
char *color;
|
char *color;
|
||||||
|
|
||||||
chanrec = channel_find(server, target);
|
chanrec = irc_channel_find(server, target);
|
||||||
for_me = irc_nick_match(server->nick, msg);
|
for_me = irc_nick_match(server->nick, msg);
|
||||||
color = for_me ? NULL : irc_hilight_find_nick(target, nick, addr, MSGLEVEL_PUBLIC, msg);
|
color = for_me ? NULL : irc_hilight_find_nick(target, nick, addr, MSGLEVEL_PUBLIC, msg);
|
||||||
|
|
||||||
nickrec = chanrec == NULL ? NULL : nicklist_find(chanrec, nick);
|
nickrec = chanrec == NULL ? NULL :
|
||||||
|
nicklist_find(CHANNEL(chanrec), nick);
|
||||||
nickmode = (!settings_get_bool("show_nickmode") || nickrec == NULL) ? "" :
|
nickmode = (!settings_get_bool("show_nickmode") || nickrec == NULL) ? "" :
|
||||||
(nickrec->op ? "@" : nickrec->voice ? "+" : " ");
|
(nickrec->op ? "@" : nickrec->voice ? "+" : " ");
|
||||||
|
|
||||||
@ -139,7 +140,7 @@ static void ctcp_msg_check_action(const char *data, IRC_SERVER_REC *server,
|
|||||||
|
|
||||||
if (ischannel(*target)) {
|
if (ischannel(*target)) {
|
||||||
/* channel action */
|
/* channel action */
|
||||||
item = (WI_ITEM_REC *) channel_find(server, target);
|
item = (WI_ITEM_REC *) irc_channel_find(server, target);
|
||||||
|
|
||||||
if (window_item_is_active(item)) {
|
if (window_item_is_active(item)) {
|
||||||
/* message to active channel in window */
|
/* message to active channel in window */
|
||||||
@ -245,9 +246,10 @@ static void event_quit(const char *data, IRC_SERVER_REC *server, const char *nic
|
|||||||
count = 0; windows = NULL;
|
count = 0; windows = NULL;
|
||||||
chans = !once ? NULL : g_string_new(NULL);
|
chans = !once ? NULL : g_string_new(NULL);
|
||||||
for (tmp = channels; tmp != NULL; tmp = tmp->next) {
|
for (tmp = channels; tmp != NULL; tmp = tmp->next) {
|
||||||
CHANNEL_REC *rec = tmp->data;
|
IRC_CHANNEL_REC *rec = tmp->data;
|
||||||
|
|
||||||
if (rec->server != server || !nicklist_find(rec, nick) ||
|
if (!IS_IRC_CHANNEL(rec) || rec->server != server ||
|
||||||
|
!nicklist_find(CHANNEL(rec), nick) ||
|
||||||
ignore_check(server, nick, addr, rec->name, data, MSGLEVEL_QUITS))
|
ignore_check(server, nick, addr, rec->name, data, MSGLEVEL_QUITS))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -338,10 +340,10 @@ static void event_nick(gchar *data, IRC_SERVER_REC *server, gchar *sender, gchar
|
|||||||
WINDOW_REC *window =
|
WINDOW_REC *window =
|
||||||
window_item_window((WI_ITEM_REC *) query);
|
window_item_window((WI_ITEM_REC *) query);
|
||||||
|
|
||||||
if (g_strcasecmp(query->nick, sender) == 0 &&
|
if (g_strcasecmp(query->name, sender) == 0 &&
|
||||||
g_slist_find(windows, window) == NULL) {
|
g_slist_find(windows, window) == NULL) {
|
||||||
windows = g_slist_append(windows, window);
|
windows = g_slist_append(windows, window);
|
||||||
print_nick_change(server, query->nick, newnick, sender, addr, ownnick);
|
print_nick_change(server, query->name, newnick, sender, addr, ownnick);
|
||||||
msgprint = TRUE;
|
msgprint = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -561,7 +563,7 @@ static void sig_server_reconnect_removed(RECONNECT_REC *reconnect)
|
|||||||
|
|
||||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
|
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
|
||||||
IRCTXT_RECONNECT_REMOVED, reconnect->conn->address, reconnect->conn->port,
|
IRCTXT_RECONNECT_REMOVED, reconnect->conn->address, reconnect->conn->port,
|
||||||
reconnect->conn->ircnet == NULL ? "" : reconnect->conn->ircnet);
|
reconnect->conn->chatnet == NULL ? "" : reconnect->conn->chatnet);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sig_server_reconnect_not_found(const char *tag)
|
static void sig_server_reconnect_not_found(const char *tag)
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
#include "irc.h"
|
#include "irc.h"
|
||||||
#include "irc-server.h"
|
#include "irc-servers.h"
|
||||||
#include "ignore.h"
|
#include "ignore.h"
|
||||||
|
|
||||||
static void fe_unignore(IGNORE_REC *rec);
|
static void fe_unignore(IGNORE_REC *rec);
|
||||||
|
@ -28,13 +28,13 @@
|
|||||||
#include "levels.h"
|
#include "levels.h"
|
||||||
#include "irc.h"
|
#include "irc.h"
|
||||||
#include "irc-commands.h"
|
#include "irc-commands.h"
|
||||||
#include "server.h"
|
#include "servers.h"
|
||||||
#include "mode-lists.h"
|
#include "mode-lists.h"
|
||||||
#include "nicklist.h"
|
#include "nicklist.h"
|
||||||
#include "channels.h"
|
#include "irc-channels.h"
|
||||||
#include "query.h"
|
#include "irc-queries.h"
|
||||||
|
|
||||||
#include "fe-query.h"
|
#include "fe-queries.h"
|
||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
#include "window-items.h"
|
#include "window-items.h"
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ static void cmd_msg(gchar *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
|||||||
{
|
{
|
||||||
GHashTable *optlist;
|
GHashTable *optlist;
|
||||||
WINDOW_REC *window;
|
WINDOW_REC *window;
|
||||||
CHANNEL_REC *channel;
|
IRC_CHANNEL_REC *channel;
|
||||||
NICK_REC *nickrec;
|
NICK_REC *nickrec;
|
||||||
const char *nickmode;
|
const char *nickmode;
|
||||||
char *target, *msg, *freestr, *newtarget;
|
char *target, *msg, *freestr, *newtarget;
|
||||||
@ -67,9 +67,9 @@ static void cmd_msg(gchar *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
|||||||
|
|
||||||
free_ret = FALSE;
|
free_ret = FALSE;
|
||||||
if (strcmp(target, ",") == 0 || strcmp(target, ".") == 0)
|
if (strcmp(target, ",") == 0 || strcmp(target, ".") == 0)
|
||||||
newtarget = parse_special(&target, server, item, NULL, &free_ret, NULL);
|
newtarget = parse_special(&target, SERVER(server), item, NULL, &free_ret, NULL);
|
||||||
else if (strcmp(target, "*") == 0 &&
|
else if (strcmp(target, "*") == 0 &&
|
||||||
(irc_item_channel(item) || irc_item_query(item)))
|
(IS_IRC_CHANNEL(item) || IS_IRC_QUERY(item)))
|
||||||
newtarget = item->name;
|
newtarget = item->name;
|
||||||
else newtarget = target;
|
else newtarget = target;
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ static void cmd_msg(gchar *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
|||||||
target = newtarget;
|
target = newtarget;
|
||||||
|
|
||||||
if (server == NULL || !server->connected) cmd_param_error(CMDERR_NOT_CONNECTED);
|
if (server == NULL || !server->connected) cmd_param_error(CMDERR_NOT_CONNECTED);
|
||||||
channel = channel_find(server, target);
|
channel = irc_channel_find(server, target);
|
||||||
|
|
||||||
freestr = !free_ret ? NULL : target;
|
freestr = !free_ret ? NULL : target;
|
||||||
if (*target == '@' && ischannel(target[1]))
|
if (*target == '@' && ischannel(target[1]))
|
||||||
@ -92,7 +92,8 @@ static void cmd_msg(gchar *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
|||||||
if (ischannel(*target))
|
if (ischannel(*target))
|
||||||
{
|
{
|
||||||
/* msg to channel */
|
/* msg to channel */
|
||||||
nickrec = channel == NULL ? NULL : nicklist_find(channel, server->nick);
|
nickrec = channel == NULL ? NULL :
|
||||||
|
nicklist_find(CHANNEL(channel), server->nick);
|
||||||
nickmode = !settings_get_bool("show_nickmode") || nickrec == NULL ? "" :
|
nickmode = !settings_get_bool("show_nickmode") || nickrec == NULL ? "" :
|
||||||
nickrec->op ? "@" : nickrec->voice ? "+" : " ";
|
nickrec->op ? "@" : nickrec->voice ? "+" : " ";
|
||||||
|
|
||||||
@ -128,11 +129,11 @@ static void cmd_msg(gchar *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* SYNTAX: ME <message> */
|
/* SYNTAX: ME <message> */
|
||||||
static void cmd_me(gchar *data, IRC_SERVER_REC *server, WI_IRC_REC *item)
|
static void cmd_me(gchar *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
g_return_if_fail(data != NULL);
|
g_return_if_fail(data != NULL);
|
||||||
|
|
||||||
if (!irc_item_check(item))
|
if (!IS_IRC_ITEM(item))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (server == NULL || !server->connected)
|
if (server == NULL || !server->connected)
|
||||||
@ -237,21 +238,21 @@ static void cmd_nctcp(const char *data, IRC_SERVER_REC *server)
|
|||||||
cmd_params_free(free_arg);
|
cmd_params_free(free_arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_wall(const char *data, IRC_SERVER_REC *server, WI_IRC_REC *item)
|
static void cmd_wall(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
CHANNEL_REC *chanrec;
|
IRC_CHANNEL_REC *chanrec;
|
||||||
char *channame, *msg;
|
char *channame, *msg;
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
|
|
||||||
g_return_if_fail(data != NULL);
|
g_return_if_fail(data != NULL);
|
||||||
if (server == NULL || !server->connected || !irc_server_check(server))
|
if (server == NULL || !server->connected || !IS_IRC_SERVER(server))
|
||||||
cmd_return_error(CMDERR_NOT_CONNECTED);
|
cmd_return_error(CMDERR_NOT_CONNECTED);
|
||||||
|
|
||||||
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTCHAN | PARAM_FLAG_GETREST, item, &channame, &msg))
|
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTCHAN | PARAM_FLAG_GETREST, item, &channame, &msg))
|
||||||
return;
|
return;
|
||||||
if (*msg == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
if (*msg == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
||||||
|
|
||||||
chanrec = channel_find(server, channame);
|
chanrec = irc_channel_find(server, channame);
|
||||||
if (chanrec == NULL) cmd_param_error(CMDERR_CHAN_NOT_FOUND);
|
if (chanrec == NULL) cmd_param_error(CMDERR_CHAN_NOT_FOUND);
|
||||||
|
|
||||||
printformat(server, chanrec->name, MSGLEVEL_NOTICES, IRCTXT_OWN_WALL, chanrec->name, msg);
|
printformat(server, chanrec->name, MSGLEVEL_NOTICES, IRCTXT_OWN_WALL, chanrec->name, msg);
|
||||||
@ -260,7 +261,7 @@ static void cmd_wall(const char *data, IRC_SERVER_REC *server, WI_IRC_REC *item)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void bans_ask_channel(const char *channel, IRC_SERVER_REC *server,
|
static void bans_ask_channel(const char *channel, IRC_SERVER_REC *server,
|
||||||
WI_IRC_REC *item)
|
WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
GString *str;
|
GString *str;
|
||||||
|
|
||||||
@ -274,7 +275,7 @@ static void bans_ask_channel(const char *channel, IRC_SERVER_REC *server,
|
|||||||
g_string_free(str, TRUE);
|
g_string_free(str, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bans_show_channel(CHANNEL_REC *channel, IRC_SERVER_REC *server)
|
static void bans_show_channel(IRC_CHANNEL_REC *channel, IRC_SERVER_REC *server)
|
||||||
{
|
{
|
||||||
GSList *tmp;
|
GSList *tmp;
|
||||||
|
|
||||||
@ -309,9 +310,9 @@ static void bans_show_channel(CHANNEL_REC *channel, IRC_SERVER_REC *server)
|
|||||||
|
|
||||||
/* SYNTAX: BAN [<channel>] [<nicks>] */
|
/* SYNTAX: BAN [<channel>] [<nicks>] */
|
||||||
static void cmd_ban(const char *data, IRC_SERVER_REC *server,
|
static void cmd_ban(const char *data, IRC_SERVER_REC *server,
|
||||||
WI_IRC_REC *item)
|
WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
CHANNEL_REC *chanrec;
|
IRC_CHANNEL_REC *chanrec;
|
||||||
char *channel, *nicks;
|
char *channel, *nicks;
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
|
|
||||||
@ -331,12 +332,12 @@ static void cmd_ban(const char *data, IRC_SERVER_REC *server,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* display bans */
|
/* display bans */
|
||||||
chanrec = irc_item_channel(item);
|
chanrec = IRC_CHANNEL(item);
|
||||||
if (chanrec == NULL && *channel == '\0')
|
if (chanrec == NULL && *channel == '\0')
|
||||||
cmd_param_error(CMDERR_NOT_JOINED);
|
cmd_param_error(CMDERR_NOT_JOINED);
|
||||||
|
|
||||||
if (*channel != '\0' && strcmp(channel, "*") != 0)
|
if (*channel != '\0' && strcmp(channel, "*") != 0)
|
||||||
chanrec = channel_find(server, channel);
|
chanrec = irc_channel_find(server, channel);
|
||||||
|
|
||||||
if (chanrec == NULL) {
|
if (chanrec == NULL) {
|
||||||
/* not joined to such channel,
|
/* not joined to such channel,
|
||||||
@ -351,21 +352,21 @@ static void cmd_ban(const char *data, IRC_SERVER_REC *server,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* SYNTAX: INVITELIST [<channel>] */
|
/* SYNTAX: INVITELIST [<channel>] */
|
||||||
static void cmd_invitelist(const char *data, IRC_SERVER_REC *server, WI_IRC_REC *item)
|
static void cmd_invitelist(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
CHANNEL_REC *channel, *cur_channel;
|
IRC_CHANNEL_REC *channel, *cur_channel;
|
||||||
GSList *tmp;
|
GSList *tmp;
|
||||||
|
|
||||||
g_return_if_fail(data != NULL);
|
g_return_if_fail(data != NULL);
|
||||||
if (server == NULL || !server->connected) cmd_return_error(CMDERR_NOT_CONNECTED);
|
if (server == NULL || !server->connected) cmd_return_error(CMDERR_NOT_CONNECTED);
|
||||||
|
|
||||||
cur_channel = irc_item_channel(item);
|
cur_channel = IRC_CHANNEL(item);
|
||||||
if (cur_channel == NULL) cmd_return_error(CMDERR_NOT_JOINED);
|
if (cur_channel == NULL) cmd_return_error(CMDERR_NOT_JOINED);
|
||||||
|
|
||||||
if (strcmp(data, "*") == 0 || *data == '\0')
|
if (strcmp(data, "*") == 0 || *data == '\0')
|
||||||
channel = cur_channel;
|
channel = cur_channel;
|
||||||
else
|
else
|
||||||
channel = channel_find(server, data);
|
channel = irc_channel_find(server, data);
|
||||||
if (channel == NULL) cmd_return_error(CMDERR_CHAN_NOT_FOUND);
|
if (channel == NULL) cmd_return_error(CMDERR_CHAN_NOT_FOUND);
|
||||||
|
|
||||||
for (tmp = channel->invitelist; tmp != NULL; tmp = tmp->next)
|
for (tmp = channel->invitelist; tmp != NULL; tmp = tmp->next)
|
||||||
@ -395,15 +396,15 @@ static void cmd_nick(const char *data, IRC_SERVER_REC *server)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* SYNTAX: VER [<target>] */
|
/* SYNTAX: VER [<target>] */
|
||||||
static void cmd_ver(gchar *data, IRC_SERVER_REC *server, WI_IRC_REC *item)
|
static void cmd_ver(gchar *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
g_return_if_fail(data != NULL);
|
g_return_if_fail(data != NULL);
|
||||||
|
|
||||||
if (!irc_server_check(server))
|
if (!IS_IRC_SERVER(server) || !server->connected)
|
||||||
cmd_return_error(CMDERR_NOT_CONNECTED);
|
cmd_return_error(CMDERR_NOT_CONNECTED);
|
||||||
if (*data == '\0' && !irc_item_check(item))
|
if (*data == '\0' && !IS_IRC_ITEM(item))
|
||||||
cmd_return_error(CMDERR_NOT_JOINED);
|
cmd_return_error(CMDERR_NOT_JOINED);
|
||||||
|
|
||||||
str = g_strdup_printf("%s VERSION", *data == '\0' ? item->name : data);
|
str = g_strdup_printf("%s VERSION", *data == '\0' ? item->name : data);
|
||||||
|
@ -24,10 +24,12 @@
|
|||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
|
#include "servers-setup.h"
|
||||||
|
|
||||||
#include "levels.h"
|
#include "levels.h"
|
||||||
#include "irc-server.h"
|
#include "irc-servers.h"
|
||||||
#include "server-reconnect.h"
|
#include "servers-reconnect.h"
|
||||||
#include "server-setup.h"
|
#include "irc-servers-setup.h"
|
||||||
|
|
||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
|
|
||||||
@ -40,7 +42,7 @@ static void print_servers(void)
|
|||||||
|
|
||||||
printformat(NULL, NULL, MSGLEVEL_CRAP, IRCTXT_SERVER_LIST,
|
printformat(NULL, NULL, MSGLEVEL_CRAP, IRCTXT_SERVER_LIST,
|
||||||
rec->tag, rec->connrec->address, rec->connrec->port,
|
rec->tag, rec->connrec->address, rec->connrec->port,
|
||||||
rec->connrec->ircnet == NULL ? "" : rec->connrec->ircnet, rec->connrec->nick);
|
rec->connrec->chatnet == NULL ? "" : rec->connrec->chatnet, rec->connrec->nick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +54,7 @@ static void print_lookup_servers(void)
|
|||||||
|
|
||||||
printformat(NULL, NULL, MSGLEVEL_CRAP, IRCTXT_SERVER_LOOKUP_LIST,
|
printformat(NULL, NULL, MSGLEVEL_CRAP, IRCTXT_SERVER_LOOKUP_LIST,
|
||||||
rec->tag, rec->connrec->address, rec->connrec->port,
|
rec->tag, rec->connrec->address, rec->connrec->port,
|
||||||
rec->connrec->ircnet == NULL ? "" : rec->connrec->ircnet, rec->connrec->nick);
|
rec->connrec->chatnet == NULL ? "" : rec->connrec->chatnet, rec->connrec->nick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,14 +66,14 @@ static void print_reconnects(void)
|
|||||||
|
|
||||||
for (tmp = reconnects; tmp != NULL; tmp = tmp->next) {
|
for (tmp = reconnects; tmp != NULL; tmp = tmp->next) {
|
||||||
RECONNECT_REC *rec = tmp->data;
|
RECONNECT_REC *rec = tmp->data;
|
||||||
IRC_SERVER_CONNECT_REC *conn = rec->conn;
|
SERVER_CONNECT_REC *conn = rec->conn;
|
||||||
|
|
||||||
tag = g_strdup_printf("RECON-%d", rec->tag);
|
tag = g_strdup_printf("RECON-%d", rec->tag);
|
||||||
left = rec->next_connect-time(NULL);
|
left = rec->next_connect-time(NULL);
|
||||||
next_connect = g_strdup_printf("%02d:%02d", left/60, left%60);
|
next_connect = g_strdup_printf("%02d:%02d", left/60, left%60);
|
||||||
printformat(NULL, NULL, MSGLEVEL_CRAP, IRCTXT_SERVER_RECONNECT_LIST,
|
printformat(NULL, NULL, MSGLEVEL_CRAP, IRCTXT_SERVER_RECONNECT_LIST,
|
||||||
tag, conn->address, conn->port,
|
tag, conn->address, conn->port,
|
||||||
conn->ircnet == NULL ? "" : conn->ircnet,
|
conn->chatnet == NULL ? "" : conn->chatnet,
|
||||||
conn->nick, next_connect);
|
conn->nick, next_connect);
|
||||||
g_free(next_connect);
|
g_free(next_connect);
|
||||||
g_free(tag);
|
g_free(tag);
|
||||||
@ -84,7 +86,7 @@ static void print_reconnects(void)
|
|||||||
static void cmd_server_add(const char *data)
|
static void cmd_server_add(const char *data)
|
||||||
{
|
{
|
||||||
GHashTable *optlist;
|
GHashTable *optlist;
|
||||||
SETUP_SERVER_REC *rec;
|
IRC_SERVER_SETUP_REC *rec;
|
||||||
char *addr, *portstr, *password, *value;
|
char *addr, *portstr, *password, *value;
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
int port;
|
int port;
|
||||||
@ -96,16 +98,16 @@ static void cmd_server_add(const char *data)
|
|||||||
if (*addr == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
if (*addr == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
||||||
port = *portstr == '\0' ? 6667 : atoi(portstr);
|
port = *portstr == '\0' ? 6667 : atoi(portstr);
|
||||||
|
|
||||||
rec = server_setup_find_port(addr, port);
|
rec = IRC_SERVER_SETUP(server_setup_find_port(addr, port));
|
||||||
if (rec == NULL) {
|
if (rec == NULL) {
|
||||||
rec = g_new0(SETUP_SERVER_REC, 1);
|
rec = g_new0(IRC_SERVER_SETUP_REC, 1);
|
||||||
rec->address = g_strdup(addr);
|
rec->address = g_strdup(addr);
|
||||||
rec->port = port;
|
rec->port = port;
|
||||||
} else {
|
} else {
|
||||||
value = g_hash_table_lookup(optlist, "port");
|
value = g_hash_table_lookup(optlist, "port");
|
||||||
if (value != NULL && *value != '\0') rec->port = atoi(value);
|
if (value != NULL && *value != '\0') rec->port = atoi(value);
|
||||||
|
|
||||||
if (g_hash_table_lookup(optlist, "ircnet")) g_free_and_null(rec->ircnet);
|
if (g_hash_table_lookup(optlist, "ircnet")) g_free_and_null(rec->chatnet);
|
||||||
if (*password != '\0') g_free_and_null(rec->password);
|
if (*password != '\0') g_free_and_null(rec->password);
|
||||||
if (g_hash_table_lookup(optlist, "host")) {
|
if (g_hash_table_lookup(optlist, "host")) {
|
||||||
g_free_and_null(rec->own_host);
|
g_free_and_null(rec->own_host);
|
||||||
@ -118,7 +120,7 @@ static void cmd_server_add(const char *data)
|
|||||||
|
|
||||||
if (*password != '\0' && strcmp(password, "-") != 0) rec->password = g_strdup(password);
|
if (*password != '\0' && strcmp(password, "-") != 0) rec->password = g_strdup(password);
|
||||||
value = g_hash_table_lookup(optlist, "ircnet");
|
value = g_hash_table_lookup(optlist, "ircnet");
|
||||||
if (value != NULL && *value != '\0') rec->ircnet = g_strdup(value);
|
if (value != NULL && *value != '\0') rec->chatnet = g_strdup(value);
|
||||||
value = g_hash_table_lookup(optlist, "host");
|
value = g_hash_table_lookup(optlist, "host");
|
||||||
if (value != NULL && *value != '\0') {
|
if (value != NULL && *value != '\0') {
|
||||||
rec->own_host = g_strdup(value);
|
rec->own_host = g_strdup(value);
|
||||||
@ -129,7 +131,7 @@ static void cmd_server_add(const char *data)
|
|||||||
value = g_hash_table_lookup(optlist, "cmdmax");
|
value = g_hash_table_lookup(optlist, "cmdmax");
|
||||||
if (value != NULL && *value != '\0') rec->max_cmds_at_once = atoi(value);
|
if (value != NULL && *value != '\0') rec->max_cmds_at_once = atoi(value);
|
||||||
|
|
||||||
server_setup_add(rec);
|
server_setup_add(SERVER_SETUP(rec));
|
||||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_SETUPSERVER_ADDED, addr, port);
|
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_SETUPSERVER_ADDED, addr, port);
|
||||||
|
|
||||||
cmd_params_free(free_arg);
|
cmd_params_free(free_arg);
|
||||||
@ -138,7 +140,7 @@ static void cmd_server_add(const char *data)
|
|||||||
/* SYNTAX: SERVER REMOVE <address> [<port>] */
|
/* SYNTAX: SERVER REMOVE <address> [<port>] */
|
||||||
static void cmd_server_remove(const char *data)
|
static void cmd_server_remove(const char *data)
|
||||||
{
|
{
|
||||||
SETUP_SERVER_REC *rec;
|
SERVER_SETUP_REC *rec;
|
||||||
char *addr, *portstr;
|
char *addr, *portstr;
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
int port;
|
int port;
|
||||||
@ -168,7 +170,7 @@ static void cmd_server_list(const char *data)
|
|||||||
str = g_string_new(NULL);
|
str = g_string_new(NULL);
|
||||||
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_SETUPSERVER_HEADER);
|
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_SETUPSERVER_HEADER);
|
||||||
for (tmp = setupservers; tmp != NULL; tmp = tmp->next) {
|
for (tmp = setupservers; tmp != NULL; tmp = tmp->next) {
|
||||||
SETUP_SERVER_REC *rec = tmp->data;
|
IRC_SERVER_SETUP_REC *rec = tmp->data;
|
||||||
|
|
||||||
g_string_truncate(str, 0);
|
g_string_truncate(str, 0);
|
||||||
if (rec->password != NULL)
|
if (rec->password != NULL)
|
||||||
@ -185,7 +187,7 @@ static void cmd_server_list(const char *data)
|
|||||||
if (str->len > 1) g_string_truncate(str, str->len-2);
|
if (str->len > 1) g_string_truncate(str, str->len-2);
|
||||||
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_SETUPSERVER_LINE,
|
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_SETUPSERVER_LINE,
|
||||||
rec->address, rec->port,
|
rec->address, rec->port,
|
||||||
rec->ircnet == NULL ? "" : rec->ircnet,
|
rec->chatnet == NULL ? "" : rec->chatnet,
|
||||||
str->str);
|
str->str);
|
||||||
}
|
}
|
||||||
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_SETUPSERVER_FOOTER);
|
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_SETUPSERVER_FOOTER);
|
||||||
|
@ -24,9 +24,10 @@
|
|||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
#include "levels.h"
|
#include "levels.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
#include "chatnets.h"
|
||||||
|
|
||||||
#include "irc-server.h"
|
#include "irc-servers.h"
|
||||||
#include "ircnet-setup.h"
|
#include "irc-chatnets.h"
|
||||||
|
|
||||||
static void cmd_ircnet_list(void)
|
static void cmd_ircnet_list(void)
|
||||||
{
|
{
|
||||||
@ -35,8 +36,8 @@ static void cmd_ircnet_list(void)
|
|||||||
|
|
||||||
str = g_string_new(NULL);
|
str = g_string_new(NULL);
|
||||||
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_IRCNET_HEADER);
|
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_IRCNET_HEADER);
|
||||||
for (tmp = ircnets; tmp != NULL; tmp = tmp->next) {
|
for (tmp = chatnets; tmp != NULL; tmp = tmp->next) {
|
||||||
IRCNET_REC *rec = tmp->data;
|
IRC_CHATNET_REC *rec = tmp->data;
|
||||||
|
|
||||||
g_string_truncate(str, 0);
|
g_string_truncate(str, 0);
|
||||||
if (rec->nick != NULL)
|
if (rec->nick != NULL)
|
||||||
@ -81,7 +82,7 @@ static void cmd_ircnet_add(const char *data)
|
|||||||
GHashTable *optlist;
|
GHashTable *optlist;
|
||||||
char *name, *value;
|
char *name, *value;
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
IRCNET_REC *rec;
|
IRC_CHATNET_REC *rec;
|
||||||
|
|
||||||
if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS,
|
if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS,
|
||||||
"ircnet add", &optlist, &name))
|
"ircnet add", &optlist, &name))
|
||||||
@ -90,7 +91,7 @@ static void cmd_ircnet_add(const char *data)
|
|||||||
|
|
||||||
rec = ircnet_find(name);
|
rec = ircnet_find(name);
|
||||||
if (rec == NULL) {
|
if (rec == NULL) {
|
||||||
rec = g_new0(IRCNET_REC, 1);
|
rec = g_new0(IRC_CHATNET_REC, 1);
|
||||||
rec->name = g_strdup(name);
|
rec->name = g_strdup(name);
|
||||||
} else {
|
} else {
|
||||||
if (g_hash_table_lookup(optlist, "nick")) g_free_and_null(rec->nick);
|
if (g_hash_table_lookup(optlist, "nick")) g_free_and_null(rec->nick);
|
||||||
@ -142,7 +143,7 @@ static void cmd_ircnet_add(const char *data)
|
|||||||
/* SYNTAX: IRCNET REMOVE <ircnet> */
|
/* SYNTAX: IRCNET REMOVE <ircnet> */
|
||||||
static void cmd_ircnet_remove(const char *data)
|
static void cmd_ircnet_remove(const char *data)
|
||||||
{
|
{
|
||||||
IRCNET_REC *rec;
|
IRC_CHATNET_REC *rec;
|
||||||
|
|
||||||
if (*data == '\0') cmd_return_error(CMDERR_NOT_ENOUGH_PARAMS);
|
if (*data == '\0') cmd_return_error(CMDERR_NOT_ENOUGH_PARAMS);
|
||||||
|
|
||||||
@ -151,7 +152,7 @@ static void cmd_ircnet_remove(const char *data)
|
|||||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_IRCNET_NOT_FOUND, data);
|
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_IRCNET_NOT_FOUND, data);
|
||||||
else {
|
else {
|
||||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_IRCNET_REMOVED, data);
|
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_IRCNET_REMOVED, data);
|
||||||
ircnet_destroy(rec);
|
chatnet_destroy(CHATNET(rec));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
#include "irc.h"
|
#include "irc.h"
|
||||||
#include "irc-server.h"
|
#include "irc-servers.h"
|
||||||
#include "modes.h"
|
#include "modes.h"
|
||||||
#include "ignore.h"
|
#include "ignore.h"
|
||||||
#include "netsplit.h"
|
#include "netsplit.h"
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
#include "irc.h"
|
#include "irc.h"
|
||||||
#include "irc-server.h"
|
#include "irc-servers.h"
|
||||||
#include "ignore.h"
|
#include "ignore.h"
|
||||||
#include "netsplit.h"
|
#include "netsplit.h"
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
fe-query.c : irssi
|
fe-queries.c : irssi
|
||||||
|
|
||||||
Copyright (C) 1999-2000 Timo Sirainen
|
Copyright (C) 1999-2000 Timo Sirainen
|
||||||
|
|
||||||
@ -28,7 +28,7 @@
|
|||||||
#include "irc.h"
|
#include "irc.h"
|
||||||
#include "irc-commands.h"
|
#include "irc-commands.h"
|
||||||
#include "levels.h"
|
#include "levels.h"
|
||||||
#include "query.h"
|
#include "irc-queries.h"
|
||||||
|
|
||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
#include "window-items.h"
|
#include "window-items.h"
|
||||||
@ -40,22 +40,22 @@ QUERY_REC *privmsg_get_query(IRC_SERVER_REC *server, const char *nick, int own)
|
|||||||
{
|
{
|
||||||
QUERY_REC *query;
|
QUERY_REC *query;
|
||||||
|
|
||||||
query = query_find(server, nick);
|
query = irc_query_find(server, nick);
|
||||||
if (query == NULL && settings_get_bool("autocreate_query") &&
|
if (query == NULL && settings_get_bool("autocreate_query") &&
|
||||||
(!own || settings_get_bool("autocreate_own_query")))
|
(!own || settings_get_bool("autocreate_own_query")))
|
||||||
query = query_create(server, nick, TRUE);
|
query = irc_query_create(server, nick, TRUE);
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void signal_query_created(QUERY_REC *query, gpointer automatic)
|
static void signal_query_created(QUERY_REC *query, gpointer automatic)
|
||||||
{
|
{
|
||||||
if (window_item_find(query->server, query->nick) != NULL)
|
if (window_item_find(query->server, query->name) != NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
window_item_create((WI_ITEM_REC *) query, GPOINTER_TO_INT(automatic));
|
window_item_create((WI_ITEM_REC *) query, GPOINTER_TO_INT(automatic));
|
||||||
printformat(query->server, query->nick, MSGLEVEL_CLIENTNOTICE,
|
printformat(query->server, query->name, MSGLEVEL_CLIENTNOTICE,
|
||||||
IRCTXT_QUERY_STARTED, query->nick);
|
IRCTXT_QUERY_STARTED, query->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void signal_query_created_curwin(QUERY_REC *query)
|
static void signal_query_created_curwin(QUERY_REC *query)
|
||||||
@ -87,7 +87,7 @@ static void signal_window_item_removed(WINDOW_REC *window, WI_ITEM_REC *item)
|
|||||||
|
|
||||||
g_return_if_fail(window != NULL);
|
g_return_if_fail(window != NULL);
|
||||||
|
|
||||||
query = irc_item_query(item);
|
query = IRC_QUERY(item);
|
||||||
if (query != NULL) query_destroy(query);
|
if (query != NULL) query_destroy(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ static void sig_server_connected(IRC_SERVER_REC *server)
|
|||||||
{
|
{
|
||||||
GSList *tmp;
|
GSList *tmp;
|
||||||
|
|
||||||
if (!irc_server_check(server))
|
if (!IS_IRC_SERVER(server))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* check if there's any queries without server */
|
/* check if there's any queries without server */
|
||||||
@ -117,21 +117,20 @@ static void cmd_window_server(const char *data)
|
|||||||
g_return_if_fail(data != NULL);
|
g_return_if_fail(data != NULL);
|
||||||
|
|
||||||
server = server_find_tag(data);
|
server = server_find_tag(data);
|
||||||
if (irc_server_check(server) && irc_item_query(active_win->active)) {
|
if (IS_IRC_SERVER(server) && IS_IRC_QUERY(active_win->active)) {
|
||||||
/* /WINDOW SERVER used in a query window */
|
/* /WINDOW SERVER used in a query window */
|
||||||
query_change_server((QUERY_REC *) active_win->active,
|
query_change_server((QUERY_REC *) active_win->active, server);
|
||||||
(IRC_SERVER_REC *) server);
|
|
||||||
window_change_server(active_win, server);
|
window_change_server(active_win, server);
|
||||||
|
|
||||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_QUERY_SERVER_CHANGED, server->tag, server->connrec->address,
|
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_QUERY_SERVER_CHANGED, server->tag, server->connrec->address,
|
||||||
server->connrec->ircnet == NULL ? "" : server->connrec->ircnet);
|
server->connrec->chatnet == NULL ? "" : server->connrec->chatnet);
|
||||||
|
|
||||||
signal_stop();
|
signal_stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SYNTAX: UNQUERY [<nick>] */
|
/* SYNTAX: UNQUERY [<nick>] */
|
||||||
static void cmd_unquery(const char *data, IRC_SERVER_REC *server, WI_IRC_REC *item)
|
static void cmd_unquery(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
QUERY_REC *query;
|
QUERY_REC *query;
|
||||||
|
|
||||||
@ -139,10 +138,10 @@ static void cmd_unquery(const char *data, IRC_SERVER_REC *server, WI_IRC_REC *it
|
|||||||
|
|
||||||
if (*data == '\0') {
|
if (*data == '\0') {
|
||||||
/* remove current query */
|
/* remove current query */
|
||||||
query = irc_item_query(item);
|
query = IRC_QUERY(item);
|
||||||
if (query == NULL) return;
|
if (query == NULL) return;
|
||||||
} else {
|
} else {
|
||||||
query = query_find(server, data);
|
query = irc_query_find(server, data);
|
||||||
if (query == NULL) {
|
if (query == NULL) {
|
||||||
printformat(server, NULL, MSGLEVEL_CLIENTERROR, IRCTXT_NO_QUERY, data);
|
printformat(server, NULL, MSGLEVEL_CLIENTERROR, IRCTXT_NO_QUERY, data);
|
||||||
return;
|
return;
|
||||||
@ -153,7 +152,7 @@ static void cmd_unquery(const char *data, IRC_SERVER_REC *server, WI_IRC_REC *it
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* SYNTAX: QUERY [-window] <nick> */
|
/* SYNTAX: QUERY [-window] <nick> */
|
||||||
static void cmd_query(const char *data, IRC_SERVER_REC *server, WI_IRC_REC *item)
|
static void cmd_query(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
GHashTable *optlist;
|
GHashTable *optlist;
|
||||||
WINDOW_REC *window;
|
WINDOW_REC *window;
|
||||||
@ -188,9 +187,9 @@ static void cmd_query(const char *data, IRC_SERVER_REC *server, WI_IRC_REC *item
|
|||||||
(SIGNAL_FUNC) signal_query_created_curwin);
|
(SIGNAL_FUNC) signal_query_created_curwin);
|
||||||
}
|
}
|
||||||
|
|
||||||
query = query_find(server, nick);
|
query = irc_query_find(server, nick);
|
||||||
if (query == NULL)
|
if (query == NULL)
|
||||||
query_create(server, nick, FALSE);
|
irc_query_create(server, nick, FALSE);
|
||||||
else {
|
else {
|
||||||
/* query already existed - change to query window */
|
/* query already existed - change to query window */
|
||||||
window = window_item_window((WI_ITEM_REC *) query);
|
window = window_item_window((WI_ITEM_REC *) query);
|
||||||
@ -215,7 +214,7 @@ static int window_has_query(WINDOW_REC *window)
|
|||||||
g_return_val_if_fail(window != NULL, FALSE);
|
g_return_val_if_fail(window != NULL, FALSE);
|
||||||
|
|
||||||
for (tmp = window->items; tmp != NULL; tmp = tmp->next) {
|
for (tmp = window->items; tmp != NULL; tmp = tmp->next) {
|
||||||
if (irc_item_query(tmp->data))
|
if (IS_IRC_QUERY(tmp->data))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,7 +250,7 @@ static void sig_window_restore_item(WINDOW_REC *window, const char *item)
|
|||||||
|
|
||||||
server = (IRC_SERVER_REC *) server_find_tag(tag);
|
server = (IRC_SERVER_REC *) server_find_tag(tag);
|
||||||
|
|
||||||
rec = query_create(server, nick+1, TRUE);
|
rec = irc_query_create(server, nick+1, TRUE);
|
||||||
if (server == NULL)
|
if (server == NULL)
|
||||||
rec->server_tag = g_strdup(tag);
|
rec->server_tag = g_strdup(tag);
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef __FE_QUERY_H
|
#ifndef __FE_QUERIES_H
|
||||||
#define __FE_QUERY_H
|
#define __FE_QUERIES_H
|
||||||
|
|
||||||
/* Return query where to put the private message. */
|
/* Return query where to put the private message. */
|
||||||
QUERY_REC *privmsg_get_query(IRC_SERVER_REC *server, const char *nick, int own);
|
QUERY_REC *privmsg_get_query(IRC_SERVER_REC *server, const char *nick, int own);
|
@ -23,7 +23,7 @@
|
|||||||
#include "signals.h"
|
#include "signals.h"
|
||||||
#include "levels.h"
|
#include "levels.h"
|
||||||
|
|
||||||
#include "irc-server.h"
|
#include "irc-servers.h"
|
||||||
#include "irc/flood/autoignore.h"
|
#include "irc/flood/autoignore.h"
|
||||||
|
|
||||||
#include "themes.h"
|
#include "themes.h"
|
||||||
|
@ -27,10 +27,11 @@
|
|||||||
|
|
||||||
#include "irc.h"
|
#include "irc.h"
|
||||||
#include "irc-commands.h"
|
#include "irc-commands.h"
|
||||||
#include "server.h"
|
#include "servers.h"
|
||||||
#include "channels.h"
|
#include "irc-channels.h"
|
||||||
|
#include "irc-queries.h"
|
||||||
#include "channels-setup.h"
|
#include "channels-setup.h"
|
||||||
#include "nicklist.h"
|
#include "irc-nicklist.h"
|
||||||
|
|
||||||
#include "completion.h"
|
#include "completion.h"
|
||||||
#include "window-items.h"
|
#include "window-items.h"
|
||||||
@ -65,7 +66,7 @@ GList *completion_get_channels(IRC_SERVER_REC *server, const char *word)
|
|||||||
|
|
||||||
/* get channels from setup */
|
/* get channels from setup */
|
||||||
for (tmp = setupchannels; tmp != NULL; tmp = tmp->next) {
|
for (tmp = setupchannels; tmp != NULL; tmp = tmp->next) {
|
||||||
SETUP_CHANNEL_REC *rec = tmp->data;
|
CHANNEL_SETUP_REC *rec = tmp->data;
|
||||||
|
|
||||||
if (g_strncasecmp(rec->name, word, len) == 0)
|
if (g_strncasecmp(rec->name, word, len) == 0)
|
||||||
list = g_list_append(list, g_strdup(rec->name));
|
list = g_list_append(list, g_strdup(rec->name));
|
||||||
@ -146,7 +147,7 @@ static int nick_completion_timeout(void)
|
|||||||
for (tmp = servers; tmp != NULL; tmp = tmp->next) {
|
for (tmp = servers; tmp != NULL; tmp = tmp->next) {
|
||||||
IRC_SERVER_REC *rec = tmp->data;
|
IRC_SERVER_REC *rec = tmp->data;
|
||||||
|
|
||||||
if (!irc_server_check(rec))
|
if (!IS_IRC_SERVER(rec))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
mserver = MODULE_DATA(rec);
|
mserver = MODULE_DATA(rec);
|
||||||
@ -226,9 +227,9 @@ static void event_privmsg(const char *data, IRC_SERVER_REC *server, const char *
|
|||||||
if (ischannel(*target)) {
|
if (ischannel(*target)) {
|
||||||
/* channel message */
|
/* channel message */
|
||||||
MODULE_CHANNEL_REC *mchannel;
|
MODULE_CHANNEL_REC *mchannel;
|
||||||
CHANNEL_REC *channel;
|
IRC_CHANNEL_REC *channel;
|
||||||
|
|
||||||
channel = channel_find(server, target);
|
channel = irc_channel_find(server, target);
|
||||||
if (channel == NULL) {
|
if (channel == NULL) {
|
||||||
g_free(params);
|
g_free(params);
|
||||||
return;
|
return;
|
||||||
@ -405,7 +406,7 @@ static void complete_from_nicklist(GList **outlist, GSList *list,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static GList *completion_channel_nicks(CHANNEL_REC *channel, const char *nick, const char *prefix)
|
static GList *completion_channel_nicks(IRC_CHANNEL_REC *channel, const char *nick, const char *prefix)
|
||||||
{
|
{
|
||||||
MODULE_CHANNEL_REC *mchannel;
|
MODULE_CHANNEL_REC *mchannel;
|
||||||
GSList *nicks, *tmp;
|
GSList *nicks, *tmp;
|
||||||
@ -424,7 +425,7 @@ static GList *completion_channel_nicks(CHANNEL_REC *channel, const char *nick, c
|
|||||||
|
|
||||||
/* and add the rest of the nicks too */
|
/* and add the rest of the nicks too */
|
||||||
len = strlen(nick);
|
len = strlen(nick);
|
||||||
nicks = nicklist_getnicks(channel);
|
nicks = nicklist_getnicks(CHANNEL(channel));
|
||||||
for (tmp = nicks; tmp != NULL; tmp = tmp->next) {
|
for (tmp = nicks; tmp != NULL; tmp = tmp->next) {
|
||||||
NICK_REC *rec = tmp->data;
|
NICK_REC *rec = tmp->data;
|
||||||
|
|
||||||
@ -464,7 +465,7 @@ static void sig_complete_word(GList **list, WINDOW_REC *window,
|
|||||||
const char *word, const char *linestart)
|
const char *word, const char *linestart)
|
||||||
{
|
{
|
||||||
IRC_SERVER_REC *server;
|
IRC_SERVER_REC *server;
|
||||||
CHANNEL_REC *channel;
|
IRC_CHANNEL_REC *channel;
|
||||||
GList *tmplist;
|
GList *tmplist;
|
||||||
const char *cmdchars, *nickprefix;
|
const char *cmdchars, *nickprefix;
|
||||||
char *prefix;
|
char *prefix;
|
||||||
@ -480,7 +481,7 @@ static void sig_complete_word(GList **list, WINDOW_REC *window,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
server = window->active_server;
|
server = IRC_SERVER(window->active_server);
|
||||||
if (server == NULL || !server->connected)
|
if (server == NULL || !server->connected)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -498,7 +499,7 @@ static void sig_complete_word(GList **list, WINDOW_REC *window,
|
|||||||
|
|
||||||
/* nick completion .. we could also be completing a nick after /MSG
|
/* nick completion .. we could also be completing a nick after /MSG
|
||||||
from nicks in channel */
|
from nicks in channel */
|
||||||
channel = irc_item_channel(window->active);
|
channel = IRC_CHANNEL(window->active);
|
||||||
if (channel == NULL)
|
if (channel == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -539,7 +540,7 @@ static void sig_complete_msg(GList **list, WINDOW_REC *window,
|
|||||||
g_return_if_fail(word != NULL);
|
g_return_if_fail(word != NULL);
|
||||||
g_return_if_fail(line != NULL);
|
g_return_if_fail(line != NULL);
|
||||||
|
|
||||||
server = window->active_server;
|
server = IRC_SERVER(window->active_server);
|
||||||
if (server == NULL || !server->connected)
|
if (server == NULL || !server->connected)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -549,7 +550,7 @@ static void sig_complete_msg(GList **list, WINDOW_REC *window,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* expand \n, \t and \\ - FIXME: this doesn't work right */
|
/* expand \n, \t and \\ - FIXME: this doesn't work right */
|
||||||
static char *expand_escapes(const char *line, IRC_SERVER_REC *server, WI_IRC_REC *item)
|
static char *expand_escapes(const char *line, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
char *ptr, *ret;
|
char *ptr, *ret;
|
||||||
|
|
||||||
@ -590,15 +591,15 @@ static char *expand_escapes(const char *line, IRC_SERVER_REC *server, WI_IRC_REC
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void event_text(gchar *line, IRC_SERVER_REC *server, WI_IRC_REC *item)
|
static void event_text(gchar *line, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
CHANNEL_REC *channel;
|
IRC_CHANNEL_REC *channel;
|
||||||
GList *comp;
|
GList *comp;
|
||||||
gchar *str, *ptr;
|
gchar *str, *ptr;
|
||||||
|
|
||||||
g_return_if_fail(line != NULL);
|
g_return_if_fail(line != NULL);
|
||||||
|
|
||||||
if (!irc_item_check(item))
|
if (!IS_IRC_ITEM(item))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* FIXME: this really should go to fe-common/core. */
|
/* FIXME: this really should go to fe-common/core. */
|
||||||
@ -617,10 +618,10 @@ static void event_text(gchar *line, IRC_SERVER_REC *server, WI_IRC_REC *item)
|
|||||||
ptr = strchr(line, *settings_get_str("completion_char"));
|
ptr = strchr(line, *settings_get_str("completion_char"));
|
||||||
if (ptr != NULL) *ptr++ = '\0';
|
if (ptr != NULL) *ptr++ = '\0';
|
||||||
|
|
||||||
channel = irc_item_channel(item);
|
channel = IRC_CHANNEL(item);
|
||||||
|
|
||||||
comp = ptr == NULL || channel == NULL ||
|
comp = ptr == NULL || channel == NULL ||
|
||||||
nicklist_find(channel, line) != NULL ? NULL :
|
nicklist_find(CHANNEL(channel), line) != NULL ? NULL :
|
||||||
completion_channel_nicks(channel, line, NULL);
|
completion_channel_nicks(channel, line, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -653,7 +654,7 @@ static void completion_init_server(IRC_SERVER_REC *server)
|
|||||||
|
|
||||||
g_return_if_fail(server != NULL);
|
g_return_if_fail(server != NULL);
|
||||||
|
|
||||||
if (!irc_server_check(server))
|
if (!IS_IRC_SERVER(server))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
rec = g_new0(MODULE_SERVER_REC, 1);
|
rec = g_new0(MODULE_SERVER_REC, 1);
|
||||||
@ -666,7 +667,7 @@ static void completion_deinit_server(IRC_SERVER_REC *server)
|
|||||||
|
|
||||||
g_return_if_fail(server != NULL);
|
g_return_if_fail(server != NULL);
|
||||||
|
|
||||||
if (!irc_server_check(server))
|
if (!IS_IRC_SERVER(server))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mserver = MODULE_DATA(server);
|
mserver = MODULE_DATA(server);
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
|
|
||||||
#include "irc.h"
|
#include "irc.h"
|
||||||
#include "ignore.h"
|
#include "ignore.h"
|
||||||
#include "irc-server.h"
|
#include "irc-servers.h"
|
||||||
#include "nicklist.h"
|
#include "irc-nicklist.h"
|
||||||
|
|
||||||
#include "completion.h"
|
#include "completion.h"
|
||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
|
@ -23,12 +23,13 @@
|
|||||||
#include "signals.h"
|
#include "signals.h"
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
#include "chatnets.h"
|
||||||
#include "lib-config/iconfig.h"
|
#include "lib-config/iconfig.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
#include "levels.h"
|
#include "levels.h"
|
||||||
#include "irc-server.h"
|
#include "irc-servers.h"
|
||||||
#include "ircnet-setup.h"
|
#include "irc-chatnets.h"
|
||||||
#include "irc/notifylist/notifylist.h"
|
#include "irc/notifylist/notifylist.h"
|
||||||
|
|
||||||
#include "themes.h"
|
#include "themes.h"
|
||||||
@ -100,10 +101,12 @@ static void cmd_notify_show(void)
|
|||||||
offline = g_slist_copy(nicks);
|
offline = g_slist_copy(nicks);
|
||||||
|
|
||||||
/* print the notifies on specific ircnets */
|
/* print the notifies on specific ircnets */
|
||||||
for (tmp = ircnets; tmp != NULL; tmp = tmp->next) {
|
for (tmp = chatnets; tmp != NULL; tmp = tmp->next) {
|
||||||
IRCNET_REC *rec = tmp->data;
|
IRC_CHATNET_REC *rec = tmp->data;
|
||||||
|
|
||||||
server = (IRC_SERVER_REC *) server_find_ircnet(rec->name);
|
if (!IS_IRCNET(rec)) continue;
|
||||||
|
|
||||||
|
server = (IRC_SERVER_REC *) server_find_chatnet(rec->name);
|
||||||
if (server == NULL) continue;
|
if (server == NULL) continue;
|
||||||
|
|
||||||
print_notify_onserver(server, nicks, &offline, rec->name);
|
print_notify_onserver(server, nicks, &offline, rec->name);
|
||||||
@ -113,7 +116,7 @@ static void cmd_notify_show(void)
|
|||||||
for (tmp = servers; tmp != NULL; tmp = tmp->next) {
|
for (tmp = servers; tmp != NULL; tmp = tmp->next) {
|
||||||
server = tmp->data;
|
server = tmp->data;
|
||||||
|
|
||||||
if (server->connrec->ircnet != NULL)
|
if (server->connrec->chatnet != NULL)
|
||||||
continue;
|
continue;
|
||||||
print_notify_onserver(server, nicks, &offline, server->tag);
|
print_notify_onserver(server, nicks, &offline, server->tag);
|
||||||
}
|
}
|
||||||
@ -182,7 +185,7 @@ static void notifylist_joined(IRC_SERVER_REC *server, const char *nick,
|
|||||||
|
|
||||||
printformat(server, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_NOTIFY_JOIN,
|
printformat(server, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_NOTIFY_JOIN,
|
||||||
nick, username, host, realname,
|
nick, username, host, realname,
|
||||||
server->connrec->ircnet == NULL ? "IRC" : server->connrec->ircnet);
|
server->connrec->chatnet == NULL ? "IRC" : server->connrec->chatnet);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void notifylist_left(IRC_SERVER_REC *server, const char *nick,
|
static void notifylist_left(IRC_SERVER_REC *server, const char *nick,
|
||||||
@ -193,7 +196,7 @@ static void notifylist_left(IRC_SERVER_REC *server, const char *nick,
|
|||||||
|
|
||||||
printformat(server, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_NOTIFY_PART,
|
printformat(server, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_NOTIFY_PART,
|
||||||
nick, username, host, realname,
|
nick, username, host, realname,
|
||||||
server->connrec->ircnet == NULL ? "IRC" : server->connrec->ircnet);
|
server->connrec->chatnet == NULL ? "IRC" : server->connrec->chatnet);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void notifylist_away(IRC_SERVER_REC *server, const char *nick,
|
static void notifylist_away(IRC_SERVER_REC *server, const char *nick,
|
||||||
@ -205,11 +208,11 @@ static void notifylist_away(IRC_SERVER_REC *server, const char *nick,
|
|||||||
if (awaymsg != NULL) {
|
if (awaymsg != NULL) {
|
||||||
printformat(server, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_NOTIFY_AWAY,
|
printformat(server, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_NOTIFY_AWAY,
|
||||||
nick, username, host, realname, awaymsg,
|
nick, username, host, realname, awaymsg,
|
||||||
server->connrec->ircnet == NULL ? "IRC" : server->connrec->ircnet);
|
server->connrec->chatnet == NULL ? "IRC" : server->connrec->chatnet);
|
||||||
} else {
|
} else {
|
||||||
printformat(server, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_NOTIFY_UNAWAY,
|
printformat(server, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_NOTIFY_UNAWAY,
|
||||||
nick, username, host, realname,
|
nick, username, host, realname,
|
||||||
server->connrec->ircnet == NULL ? "IRC" : server->connrec->ircnet);
|
server->connrec->chatnet == NULL ? "IRC" : server->connrec->chatnet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,7 +224,7 @@ static void notifylist_unidle(IRC_SERVER_REC *server, const char *nick,
|
|||||||
|
|
||||||
printformat(server, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_NOTIFY_UNIDLE,
|
printformat(server, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_NOTIFY_UNIDLE,
|
||||||
nick, username, host, realname, awaymsg != NULL ? awaymsg : "",
|
nick, username, host, realname, awaymsg != NULL ? awaymsg : "",
|
||||||
server->connrec->ircnet == NULL ? "IRC" : server->connrec->ircnet);
|
server->connrec->chatnet == NULL ? "IRC" : server->connrec->chatnet);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fe_irc_notifylist_init(void)
|
void fe_irc_notifylist_init(void)
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include "signals.h"
|
#include "signals.h"
|
||||||
#include "server.h"
|
#include "servers.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
#include "completion.h"
|
#include "completion.h"
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include "gui-readline.h"
|
#include "gui-readline.h"
|
||||||
|
|
||||||
/* idle time */
|
/* idle time */
|
||||||
static char *expando_idletime(void *server, void *item, int *free_ret)
|
static char *expando_idletime(SERVER_REC *server, void *item, int *free_ret)
|
||||||
{
|
{
|
||||||
int diff;
|
int diff;
|
||||||
|
|
||||||
@ -35,13 +35,13 @@ static char *expando_idletime(void *server, void *item, int *free_ret)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* current contents of the input line */
|
/* current contents of the input line */
|
||||||
static char *expando_inputline(void *server, void *item, int *free_ret)
|
static char *expando_inputline(SERVER_REC *server, void *item, int *free_ret)
|
||||||
{
|
{
|
||||||
return gui_entry_get_text();
|
return gui_entry_get_text();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: value of cutbuffer */
|
/* FIXME: value of cutbuffer */
|
||||||
static char *expando_cutbuffer(void *server, void *item, int *free_ret)
|
static char *expando_cutbuffer(SERVER_REC *server, void *item, int *free_ret)
|
||||||
{
|
{
|
||||||
return cutbuffer;
|
return cutbuffer;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include "levels.h"
|
#include "levels.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
#include "irc-server.h"
|
#include "irc-servers.h"
|
||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
|
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include "signals.h"
|
#include "signals.h"
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
#include "server.h"
|
#include "servers.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
@ -244,9 +244,6 @@ void gui_window_newline(GUI_WINDOW_REC *gui, int visible)
|
|||||||
scrollok(gui->parent->curses_win, TRUE);
|
scrollok(gui->parent->curses_win, TRUE);
|
||||||
wscrl(gui->parent->curses_win, 1);
|
wscrl(gui->parent->curses_win, 1);
|
||||||
scrollok(gui->parent->curses_win, FALSE);
|
scrollok(gui->parent->curses_win, FALSE);
|
||||||
|
|
||||||
wmove(gui->parent->curses_win, gui->parent->lines, 0);
|
|
||||||
wclrtoeol(gui->parent->curses_win);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef __GUI_WINDOWS_H
|
#ifndef __GUI_WINDOWS_H
|
||||||
#define __GUI_WINDOWS_H
|
#define __GUI_WINDOWS_H
|
||||||
|
|
||||||
#include "server.h"
|
#include "servers.h"
|
||||||
#include "mainwindows.h"
|
#include "mainwindows.h"
|
||||||
|
|
||||||
#define WINDOW_GUI(a) ((GUI_WINDOW_REC *) ((a)->gui_data))
|
#define WINDOW_GUI(a) ((GUI_WINDOW_REC *) ((a)->gui_data))
|
||||||
|
@ -88,7 +88,7 @@ static void textui_init(void)
|
|||||||
fe_common_core_init();
|
fe_common_core_init();
|
||||||
fe_common_irc_init();
|
fe_common_irc_init();
|
||||||
|
|
||||||
theme_register(gui_text_formats);
|
theme_register(gui_text_formats);
|
||||||
signal_add("gui exit", (SIGNAL_FUNC) sig_exit);
|
signal_add("gui exit", (SIGNAL_FUNC) sig_exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,14 +20,14 @@
|
|||||||
|
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include "signals.h"
|
#include "signals.h"
|
||||||
#include "server.h"
|
#include "servers.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
#include "irc.h"
|
#include "irc.h"
|
||||||
#include "channels.h"
|
#include "channels.h"
|
||||||
#include "query.h"
|
#include "queries.h"
|
||||||
#include "irc-server.h"
|
#include "irc-servers.h"
|
||||||
#include "nicklist.h"
|
#include "nicklist.h"
|
||||||
|
|
||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
@ -150,7 +150,7 @@ static void statusbar_nick(SBAR_ITEM_REC *item, int ypos)
|
|||||||
strncpy(nick, server->nick, 9);
|
strncpy(nick, server->nick, 9);
|
||||||
nick[9] = '\0';
|
nick[9] = '\0';
|
||||||
|
|
||||||
channel = irc_item_channel(active_win->active);
|
channel = CHANNEL(active_win->active);
|
||||||
nickrec = channel == NULL ? NULL : nicklist_find(channel, server->nick);
|
nickrec = channel == NULL ? NULL : nicklist_find(channel, server->nick);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,7 +224,7 @@ static void statusbar_channel(SBAR_ITEM_REC *item, int ypos)
|
|||||||
|
|
||||||
ltoa(winnum, window == NULL ? 0 : window->refnum);
|
ltoa(winnum, window == NULL ? 0 : window->refnum);
|
||||||
|
|
||||||
witem = window != NULL && irc_item_check(window->active) ?
|
witem = window != NULL && (IS_CHANNEL(window->active) || IS_QUERY(window->active)) ?
|
||||||
window->active : NULL;
|
window->active : NULL;
|
||||||
if (witem == NULL)
|
if (witem == NULL)
|
||||||
{
|
{
|
||||||
@ -242,7 +242,7 @@ static void statusbar_channel(SBAR_ITEM_REC *item, int ypos)
|
|||||||
strncpy(channame, tmpname, 20); channame[20] = '\0';
|
strncpy(channame, tmpname, 20); channame[20] = '\0';
|
||||||
g_free(tmpname);
|
g_free(tmpname);
|
||||||
|
|
||||||
channel = irc_item_channel(witem);
|
channel = CHANNEL(witem);
|
||||||
if (channel == NULL) {
|
if (channel == NULL) {
|
||||||
mode_size = 0;
|
mode_size = 0;
|
||||||
} else {
|
} else {
|
||||||
@ -681,8 +681,8 @@ static void statusbar_topic(SBAR_ITEM_REC *item, int ypos)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
topic = NULL;
|
topic = NULL;
|
||||||
channel = irc_item_channel(active_win->active);
|
channel = CHANNEL(active_win->active);
|
||||||
query = irc_item_query(active_win->active);
|
query = QUERY(active_win->active);
|
||||||
if (channel != NULL && channel->topic != NULL) topic = channel->topic;
|
if (channel != NULL && channel->topic != NULL) topic = channel->topic;
|
||||||
if (query != NULL && query->address != NULL) topic = query->address;
|
if (query != NULL && query->address != NULL) topic = query->address;
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include "signals.h"
|
#include "signals.h"
|
||||||
#include "server.h"
|
#include "servers.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
|
@ -4,6 +4,6 @@ endif
|
|||||||
|
|
||||||
SUBDIRS = core $(BOT) dcc flood notifylist
|
SUBDIRS = core $(BOT) dcc flood notifylist
|
||||||
|
|
||||||
noinst_LTLIBRARIES = libirc.la
|
noinst_LIBRARIES = libirc.a
|
||||||
|
|
||||||
libirc_la_SOURCES = irc.c
|
libirc_a_SOURCES = irc.c
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
|
|
||||||
#include "irc.h"
|
#include "irc.h"
|
||||||
#include "irc-server.h"
|
#include "irc-servers.h"
|
||||||
#include "channels.h"
|
#include "channels.h"
|
||||||
#include "nicklist.h"
|
#include "nicklist.h"
|
||||||
#include "modes.h"
|
#include "modes.h"
|
||||||
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
#include "bot-users.h"
|
#include "bot-users.h"
|
||||||
|
|
||||||
static int get_flags(USER_REC *user, CHANNEL_REC *channel)
|
static int get_flags(USER_REC *user, IRC_CHANNEL_REC *channel)
|
||||||
{
|
{
|
||||||
USER_CHAN_REC *userchan;
|
USER_CHAN_REC *userchan;
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ static int get_flags(USER_REC *user, CHANNEL_REC *channel)
|
|||||||
(~user->not_flags);
|
(~user->not_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void event_massjoin(CHANNEL_REC *channel, GSList *users)
|
static void event_massjoin(IRC_CHANNEL_REC *channel, GSList *users)
|
||||||
{
|
{
|
||||||
USER_REC *user;
|
USER_REC *user;
|
||||||
USER_CHAN_REC *userchan;
|
USER_CHAN_REC *userchan;
|
||||||
@ -86,7 +86,7 @@ static void event_massjoin(CHANNEL_REC *channel, GSList *users)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Parse channel mode string */
|
/* Parse channel mode string */
|
||||||
static void parse_channel_mode(CHANNEL_REC *channel, const char *mode,
|
static void parse_channel_mode(IRC_CHANNEL_REC *channel, const char *mode,
|
||||||
const char *nick, const char *address)
|
const char *nick, const char *address)
|
||||||
{
|
{
|
||||||
NICK_REC *nickrec, *splitnick;
|
NICK_REC *nickrec, *splitnick;
|
||||||
@ -140,7 +140,7 @@ static void parse_channel_mode(CHANNEL_REC *channel, const char *mode,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* check that op is valid */
|
/* check that op is valid */
|
||||||
nickrec = nicklist_find(channel, ptr);
|
nickrec = nicklist_find(CHANNEL(channel), ptr);
|
||||||
if (nickrec == NULL || nickrec->host == NULL)
|
if (nickrec == NULL || nickrec->host == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -169,7 +169,7 @@ static void parse_channel_mode(CHANNEL_REC *channel, const char *mode,
|
|||||||
static void event_mode(const char *data, IRC_SERVER_REC *server,
|
static void event_mode(const char *data, IRC_SERVER_REC *server,
|
||||||
const char *nick, const char *address)
|
const char *nick, const char *address)
|
||||||
{
|
{
|
||||||
CHANNEL_REC *chanrec;
|
IRC_CHANNEL_REC *chanrec;
|
||||||
char *params, *channel, *mode;
|
char *params, *channel, *mode;
|
||||||
|
|
||||||
g_return_if_fail(data != NULL);
|
g_return_if_fail(data != NULL);
|
||||||
@ -178,7 +178,7 @@ static void event_mode(const char *data, IRC_SERVER_REC *server,
|
|||||||
|
|
||||||
if (ischannel(*channel)) {
|
if (ischannel(*channel)) {
|
||||||
/* channel mode change */
|
/* channel mode change */
|
||||||
chanrec = channel_find(server, channel);
|
chanrec = irc_channel_find(server, channel);
|
||||||
if (chanrec != NULL)
|
if (chanrec != NULL)
|
||||||
parse_channel_mode(chanrec, mode, nick, address);
|
parse_channel_mode(chanrec, mode, nick, address);
|
||||||
}
|
}
|
||||||
|
@ -23,10 +23,10 @@
|
|||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
|
|
||||||
#include "irc.h"
|
#include "irc.h"
|
||||||
#include "irc-server.h"
|
#include "irc-servers.h"
|
||||||
#include "channels.h"
|
#include "channels.h"
|
||||||
#include "nicklist.h"
|
#include "nicklist.h"
|
||||||
#include "masks.h"
|
#include "irc-masks.h"
|
||||||
|
|
||||||
#include "bot-users.h"
|
#include "bot-users.h"
|
||||||
#include "botnet-users.h"
|
#include "botnet-users.h"
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#include "lib-config/iconfig.h"
|
#include "lib-config/iconfig.h"
|
||||||
|
|
||||||
#include "channels.h"
|
#include "channels.h"
|
||||||
#include "nicklist.h"
|
#include "irc-nicklist.h"
|
||||||
#include "masks.h"
|
#include "masks.h"
|
||||||
|
|
||||||
#include "bot-users.h"
|
#include "bot-users.h"
|
||||||
@ -154,7 +154,7 @@ static int botuser_find_mask(USER_REC *user, const char *nick, const char *host)
|
|||||||
for (tmp = user->masks; tmp != NULL; tmp = tmp->next) {
|
for (tmp = user->masks; tmp != NULL; tmp = tmp->next) {
|
||||||
USER_MASK_REC *rec = tmp->data;
|
USER_MASK_REC *rec = tmp->data;
|
||||||
|
|
||||||
if (irc_mask_match_address(rec->mask, nick, host)) {
|
if (mask_match_address(NULL, rec->mask, nick, host)) {
|
||||||
user->not_flags = rec->not_flags;
|
user->not_flags = rec->not_flags;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -194,7 +194,7 @@ USER_REC *botuser_find(const char *nick, const char *host)
|
|||||||
g_return_val_if_fail(nick != NULL, NULL);
|
g_return_val_if_fail(nick != NULL, NULL);
|
||||||
|
|
||||||
/* First check for user with same nick */
|
/* First check for user with same nick */
|
||||||
stripnick = nick_strip(nick);
|
stripnick = irc_nick_strip(nick);
|
||||||
user = g_hash_table_lookup(users, stripnick);
|
user = g_hash_table_lookup(users, stripnick);
|
||||||
g_free(stripnick);
|
g_free(stripnick);
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
|
|
||||||
#include "irc.h"
|
#include "irc.h"
|
||||||
#include "irc-server.h"
|
#include "irc-servers.h"
|
||||||
#include "channels.h"
|
#include "channels.h"
|
||||||
#include "nicklist.h"
|
#include "nicklist.h"
|
||||||
#include "masks.h"
|
#include "masks.h"
|
||||||
|
@ -1,56 +1,54 @@
|
|||||||
noinst_LTLIBRARIES = libirc_core.la
|
noinst_LIBRARIES = libirc_core.a
|
||||||
|
|
||||||
INCLUDES = \
|
INCLUDES = \
|
||||||
$(GLIB_CFLAGS) \
|
$(GLIB_CFLAGS) \
|
||||||
-DSYSCONFDIR=\""$(sysconfdir)"\" \
|
-DSYSCONFDIR=\""$(sysconfdir)"\" \
|
||||||
-I$(top_srcdir)/src -I$(top_srcdir)/src/core
|
-I$(top_srcdir)/src -I$(top_srcdir)/src/core
|
||||||
|
|
||||||
libirc_core_la_SOURCES = \
|
libirc_core_a_SOURCES = \
|
||||||
bans.c \
|
bans.c \
|
||||||
ctcp.c \
|
ctcp.c \
|
||||||
channels.c \
|
|
||||||
channels-query.c \
|
channels-query.c \
|
||||||
channels-setup.c \
|
|
||||||
channel-events.c \
|
channel-events.c \
|
||||||
channel-rejoin.c \
|
channel-rejoin.c \
|
||||||
ignore.c \
|
ignore.c \
|
||||||
irc.c \
|
irc.c \
|
||||||
irc-core.c \
|
irc-core.c \
|
||||||
|
irc-channels.c \
|
||||||
|
irc-channels-setup.c \
|
||||||
|
irc-chatnets.c \
|
||||||
irc-commands.c \
|
irc-commands.c \
|
||||||
irc-log.c \
|
irc-log.c \
|
||||||
|
irc-masks.c \
|
||||||
|
irc-nicklist.c \
|
||||||
|
irc-queries.c \
|
||||||
irc-rawlog.c \
|
irc-rawlog.c \
|
||||||
irc-server.c \
|
irc-servers.c \
|
||||||
|
irc-servers-reconnect.c \
|
||||||
|
irc-servers-setup.c \
|
||||||
irc-special-vars.c \
|
irc-special-vars.c \
|
||||||
ircnet-setup.c \
|
|
||||||
lag.c \
|
lag.c \
|
||||||
masks.c \
|
|
||||||
massjoin.c \
|
massjoin.c \
|
||||||
modes.c \
|
modes.c \
|
||||||
mode-lists.c \
|
mode-lists.c \
|
||||||
netsplit.c \
|
netsplit.c \
|
||||||
nicklist.c \
|
server-idle.c
|
||||||
query.c \
|
|
||||||
server-idle.c \
|
|
||||||
server-reconnect.c \
|
|
||||||
server-setup.c
|
|
||||||
|
|
||||||
noinst_HEADERS = \
|
noinst_HEADERS = \
|
||||||
bans.h \
|
bans.h \
|
||||||
ctcp.h \
|
ctcp.h \
|
||||||
channels.h \
|
|
||||||
channels-setup.h \
|
|
||||||
ignore.h \
|
ignore.h \
|
||||||
irc.h \
|
irc.h \
|
||||||
|
irc-channels.h \
|
||||||
|
irc-chatnets.h \
|
||||||
irc-commands.h \
|
irc-commands.h \
|
||||||
irc-server.h \
|
irc-masks.h \
|
||||||
ircnet-setup.h \
|
irc-nicklist.h \
|
||||||
masks.h \
|
irc-queries.h \
|
||||||
|
irc-servers.h \
|
||||||
|
irc-servers-setup.h \
|
||||||
modes.h \
|
modes.h \
|
||||||
mode-lists.h \
|
mode-lists.h \
|
||||||
module.h \
|
module.h \
|
||||||
netsplit.h \
|
netsplit.h \
|
||||||
nicklist.h \
|
server-idle.h
|
||||||
query.h \
|
|
||||||
server-idle.h \
|
|
||||||
server-reconnect.h \
|
|
||||||
server-setup.h
|
|
||||||
|
@ -19,12 +19,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
|
#include "signals.h"
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "signals.h"
|
|
||||||
|
|
||||||
#include "masks.h"
|
#include "irc-masks.h"
|
||||||
#include "modes.h"
|
#include "modes.h"
|
||||||
#include "mode-lists.h"
|
#include "mode-lists.h"
|
||||||
#include "irc.h"
|
#include "irc.h"
|
||||||
@ -33,15 +32,15 @@
|
|||||||
static int bantype;
|
static int bantype;
|
||||||
|
|
||||||
/* Get ban mask */
|
/* Get ban mask */
|
||||||
char *ban_get_mask(CHANNEL_REC *channel, const char *nick)
|
char *ban_get_mask(IRC_CHANNEL_REC *channel, const char *nick)
|
||||||
{
|
{
|
||||||
NICK_REC *rec;
|
NICK_REC *rec;
|
||||||
char *str, *user, *host;
|
char *str, *user, *host;
|
||||||
|
|
||||||
g_return_val_if_fail(channel != NULL, NULL);
|
g_return_val_if_fail(IS_IRC_CHANNEL(channel), NULL);
|
||||||
g_return_val_if_fail(nick != NULL, NULL);
|
g_return_val_if_fail(nick != NULL, NULL);
|
||||||
|
|
||||||
rec = nicklist_find(channel, nick);
|
rec = nicklist_find(CHANNEL(channel), nick);
|
||||||
if (rec == NULL || rec->host == NULL) return NULL;
|
if (rec == NULL || rec->host == NULL) return NULL;
|
||||||
|
|
||||||
str = irc_get_mask(nick, rec->host, bantype);
|
str = irc_get_mask(nick, rec->host, bantype);
|
||||||
@ -109,7 +108,7 @@ void ban_set_type(const char *type)
|
|||||||
signal_emit("ban type changed", 1, bantypestr);
|
signal_emit("ban type changed", 1, bantypestr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ban_set(CHANNEL_REC *channel, const char *bans)
|
void ban_set(IRC_CHANNEL_REC *channel, const char *bans)
|
||||||
{
|
{
|
||||||
GString *str;
|
GString *str;
|
||||||
char **ban, **banlist, *realban;
|
char **ban, **banlist, *realban;
|
||||||
@ -136,12 +135,13 @@ void ban_set(CHANNEL_REC *channel, const char *bans)
|
|||||||
|
|
||||||
if (str->len > 0) {
|
if (str->len > 0) {
|
||||||
g_string_truncate(str, str->len-1);
|
g_string_truncate(str, str->len-1);
|
||||||
channel_set_singlemode(channel->server, channel->name, str->str, "+b");
|
channel_set_singlemode(channel->server, channel->name,
|
||||||
|
str->str, "+b");
|
||||||
}
|
}
|
||||||
g_string_free(str, TRUE);
|
g_string_free(str, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ban_remove(CHANNEL_REC *channel, const char *bans)
|
void ban_remove(IRC_CHANNEL_REC *channel, const char *bans)
|
||||||
{
|
{
|
||||||
GString *str;
|
GString *str;
|
||||||
GSList *tmp;
|
GSList *tmp;
|
||||||
@ -160,18 +160,19 @@ void ban_remove(CHANNEL_REC *channel, const char *bans)
|
|||||||
g_strfreev(banlist);
|
g_strfreev(banlist);
|
||||||
|
|
||||||
if (str->len > 0)
|
if (str->len > 0)
|
||||||
channel_set_singlemode(channel->server, channel->name, str->str, "-b");
|
channel_set_singlemode(channel->server, channel->name,
|
||||||
|
str->str, "-b");
|
||||||
g_string_free(str, TRUE);
|
g_string_free(str, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void command_set_ban(const char *data, IRC_SERVER_REC *server, WI_IRC_REC *item, int set)
|
static void command_set_ban(const char *data, IRC_SERVER_REC *server, void *item, int set)
|
||||||
{
|
{
|
||||||
CHANNEL_REC *chanrec;
|
IRC_CHANNEL_REC *chanrec;
|
||||||
char *channel, *nicks;
|
char *channel, *nicks;
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
|
|
||||||
g_return_if_fail(data != NULL);
|
g_return_if_fail(data != NULL);
|
||||||
if (server == NULL || !server->connected || !irc_server_check(server))
|
if (server == NULL || !server->connected || !IS_IRC_SERVER(server))
|
||||||
cmd_return_error(CMDERR_NOT_CONNECTED);
|
cmd_return_error(CMDERR_NOT_CONNECTED);
|
||||||
|
|
||||||
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTCHAN | PARAM_FLAG_GETREST,
|
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTCHAN | PARAM_FLAG_GETREST,
|
||||||
@ -184,9 +185,11 @@ static void command_set_ban(const char *data, IRC_SERVER_REC *server, WI_IRC_REC
|
|||||||
nicks = (char *) data;
|
nicks = (char *) data;
|
||||||
}
|
}
|
||||||
|
|
||||||
chanrec = channel_find(server, channel);
|
chanrec = irc_channel_find(server, channel);
|
||||||
if (chanrec == NULL) cmd_param_error(CMDERR_CHAN_NOT_FOUND);
|
if (chanrec == NULL)
|
||||||
if (!chanrec->wholist) cmd_param_error(CMDERR_CHAN_NOT_SYNCED);
|
cmd_param_error(CMDERR_CHAN_NOT_FOUND);
|
||||||
|
if (!chanrec->wholist)
|
||||||
|
cmd_param_error(CMDERR_CHAN_NOT_SYNCED);
|
||||||
|
|
||||||
if (set)
|
if (set)
|
||||||
ban_set(chanrec, nicks);
|
ban_set(chanrec, nicks);
|
||||||
@ -204,13 +207,13 @@ static void cmd_bantype(const char *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* SYNTAX: BAN <nicks/masks> */
|
/* SYNTAX: BAN <nicks/masks> */
|
||||||
static void cmd_ban(const char *data, IRC_SERVER_REC *server, WI_IRC_REC *item)
|
static void cmd_ban(const char *data, IRC_SERVER_REC *server, void *item)
|
||||||
{
|
{
|
||||||
command_set_ban(data, server, item, TRUE);
|
command_set_ban(data, server, item, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SYNTAX: UNBAN <masks> */
|
/* SYNTAX: UNBAN <masks> */
|
||||||
static void cmd_unban(const char *data, IRC_SERVER_REC *server, WI_IRC_REC *item)
|
static void cmd_unban(const char *data, IRC_SERVER_REC *server, void *item)
|
||||||
{
|
{
|
||||||
command_set_ban(data, server, item, FALSE);
|
command_set_ban(data, server, item, FALSE);
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
#ifndef __BANS_H
|
#ifndef __BANS_H
|
||||||
#define __BANS_H
|
#define __BANS_H
|
||||||
|
|
||||||
#include "channels.h"
|
#include "irc-channels.h"
|
||||||
|
|
||||||
void bans_init(void);
|
void bans_init(void);
|
||||||
void bans_deinit(void);
|
void bans_deinit(void);
|
||||||
|
|
||||||
char *ban_get_mask(CHANNEL_REC *channel, const char *nick);
|
char *ban_get_mask(IRC_CHANNEL_REC *channel, const char *nick);
|
||||||
|
|
||||||
void ban_set_type(const char *type);
|
void ban_set_type(const char *type);
|
||||||
void ban_set(CHANNEL_REC *channel, const char *bans);
|
void ban_set(IRC_CHANNEL_REC *channel, const char *bans);
|
||||||
void ban_remove(CHANNEL_REC *channel, const char *ban);
|
void ban_remove(IRC_CHANNEL_REC *channel, const char *ban);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -20,10 +20,10 @@
|
|||||||
|
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include "signals.h"
|
#include "signals.h"
|
||||||
|
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "channels.h"
|
|
||||||
#include "irc.h"
|
#include "irc.h"
|
||||||
|
#include "irc-channels.h"
|
||||||
|
|
||||||
static void event_cannot_join(const char *data, IRC_SERVER_REC *server)
|
static void event_cannot_join(const char *data, IRC_SERVER_REC *server)
|
||||||
{
|
{
|
||||||
@ -37,12 +37,12 @@ static void event_cannot_join(const char *data, IRC_SERVER_REC *server)
|
|||||||
if (channel[0] == '!' && channel[1] == '!')
|
if (channel[0] == '!' && channel[1] == '!')
|
||||||
channel++; /* server didn't understand !channels */
|
channel++; /* server didn't understand !channels */
|
||||||
|
|
||||||
chanrec = channel_find(server, channel);
|
chanrec = channel_find(SERVER(server), channel);
|
||||||
if (chanrec == NULL && channel[0] == '!') {
|
if (chanrec == NULL && channel[0] == '!') {
|
||||||
/* it probably replied with the full !channel name,
|
/* it probably replied with the full !channel name,
|
||||||
find the channel with the short name.. */
|
find the channel with the short name.. */
|
||||||
channel = g_strdup_printf("!%s", channel+6);
|
channel = g_strdup_printf("!%s", channel+6);
|
||||||
chanrec = channel_find(server, channel);
|
chanrec = channel_find(SERVER(server), channel);
|
||||||
g_free(channel);
|
g_free(channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ static void channel_change_topic(IRC_SERVER_REC *server, const char *channel, co
|
|||||||
{
|
{
|
||||||
CHANNEL_REC *chanrec;
|
CHANNEL_REC *chanrec;
|
||||||
|
|
||||||
chanrec = channel_find(server, channel);
|
chanrec = channel_find(SERVER(server), channel);
|
||||||
if (chanrec != NULL) {
|
if (chanrec != NULL) {
|
||||||
g_free_not_null(chanrec->topic);
|
g_free_not_null(chanrec->topic);
|
||||||
chanrec->topic = *topic == '\0' ? NULL : g_strdup(topic);
|
chanrec->topic = *topic == '\0' ? NULL : g_strdup(topic);
|
||||||
@ -105,16 +105,18 @@ static void event_topic(const char *data, IRC_SERVER_REC *server)
|
|||||||
|
|
||||||
/* Find any unjoined channel that matches `channel'. Long channel names are
|
/* Find any unjoined channel that matches `channel'. Long channel names are
|
||||||
also a bit problematic, so find a channel where start of the name matches. */
|
also a bit problematic, so find a channel where start of the name matches. */
|
||||||
static CHANNEL_REC *channel_find_unjoined(IRC_SERVER_REC *server, const char *channel)
|
static IRC_CHANNEL_REC *channel_find_unjoined(IRC_SERVER_REC *server,
|
||||||
|
const char *channel)
|
||||||
{
|
{
|
||||||
GSList *tmp;
|
GSList *tmp;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
len = strlen(channel);
|
len = strlen(channel);
|
||||||
for (tmp = server->channels; tmp != NULL; tmp = tmp->next) {
|
for (tmp = server->channels; tmp != NULL; tmp = tmp->next) {
|
||||||
CHANNEL_REC *rec = tmp->data;
|
IRC_CHANNEL_REC *rec = tmp->data;
|
||||||
|
|
||||||
if (rec->joined) continue;
|
if (!IS_IRC_CHANNEL(rec) || rec->joined)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (g_strncasecmp(channel, rec->name, len) == 0 &&
|
if (g_strncasecmp(channel, rec->name, len) == 0 &&
|
||||||
(len > 20 || rec->name[len] == '\0'))
|
(len > 20 || rec->name[len] == '\0'))
|
||||||
@ -127,7 +129,7 @@ static CHANNEL_REC *channel_find_unjoined(IRC_SERVER_REC *server, const char *ch
|
|||||||
static void event_join(const char *data, IRC_SERVER_REC *server, const char *nick, const char *address)
|
static void event_join(const char *data, IRC_SERVER_REC *server, const char *nick, const char *address)
|
||||||
{
|
{
|
||||||
char *params, *channel, *tmp;
|
char *params, *channel, *tmp;
|
||||||
CHANNEL_REC *chanrec;
|
IRC_CHANNEL_REC *chanrec;
|
||||||
|
|
||||||
g_return_if_fail(data != NULL);
|
g_return_if_fail(data != NULL);
|
||||||
|
|
||||||
@ -159,7 +161,7 @@ static void event_join(const char *data, IRC_SERVER_REC *server, const char *nic
|
|||||||
g_free(shortchan);
|
g_free(shortchan);
|
||||||
}
|
}
|
||||||
|
|
||||||
chanrec = channel_find(server, channel);
|
chanrec = irc_channel_find(server, channel);
|
||||||
if (chanrec != NULL && chanrec->joined) {
|
if (chanrec != NULL && chanrec->joined) {
|
||||||
/* already joined this channel - this check was added
|
/* already joined this channel - this check was added
|
||||||
here because of broken irssi proxy :) */
|
here because of broken irssi proxy :) */
|
||||||
@ -170,7 +172,7 @@ static void event_join(const char *data, IRC_SERVER_REC *server, const char *nic
|
|||||||
chanrec = channel_find_unjoined(server, channel);
|
chanrec = channel_find_unjoined(server, channel);
|
||||||
if (chanrec == NULL) {
|
if (chanrec == NULL) {
|
||||||
/* didn't get here with /join command.. */
|
/* didn't get here with /join command.. */
|
||||||
chanrec = channel_create(server, channel, TRUE);
|
chanrec = irc_channel_create(server, channel, TRUE);
|
||||||
}
|
}
|
||||||
chanrec->joined = TRUE;
|
chanrec->joined = TRUE;
|
||||||
if (strcmp(chanrec->name, channel) != 0) {
|
if (strcmp(chanrec->name, channel) != 0) {
|
||||||
@ -195,7 +197,7 @@ static void event_part(const char *data, IRC_SERVER_REC *server, const char *nic
|
|||||||
|
|
||||||
params = event_get_params(data, 2, &channel, &reason);
|
params = event_get_params(data, 2, &channel, &reason);
|
||||||
|
|
||||||
chanrec = channel_find(server, channel);
|
chanrec = channel_find(SERVER(server), channel);
|
||||||
if (chanrec != NULL) {
|
if (chanrec != NULL) {
|
||||||
chanrec->left = TRUE;
|
chanrec->left = TRUE;
|
||||||
channel_destroy(chanrec);
|
channel_destroy(chanrec);
|
||||||
@ -219,7 +221,7 @@ static void event_kick(const char *data, IRC_SERVER_REC *server)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
chanrec = channel_find(server, channel);
|
chanrec = channel_find(SERVER(server), channel);
|
||||||
if (chanrec != NULL) {
|
if (chanrec != NULL) {
|
||||||
chanrec->kicked = TRUE;
|
chanrec->kicked = TRUE;
|
||||||
channel_destroy(chanrec);
|
channel_destroy(chanrec);
|
||||||
|
@ -21,25 +21,29 @@
|
|||||||
|
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include "signals.h"
|
#include "signals.h"
|
||||||
|
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "channels.h"
|
|
||||||
#include "irc.h"
|
#include "irc.h"
|
||||||
|
#include "irc-channels.h"
|
||||||
|
|
||||||
#define REJOIN_TIMEOUT (1000*60*5) /* try to rejoin every 5 minutes */
|
#define REJOIN_TIMEOUT (1000*60*5) /* try to rejoin every 5 minutes */
|
||||||
|
|
||||||
static int rejoin_tag;
|
static int rejoin_tag;
|
||||||
|
|
||||||
|
#define channel_have_key(chan) \
|
||||||
|
((chan) != NULL && (chan)->key != NULL && (chan)->key[0] != '\0')
|
||||||
|
|
||||||
static void channel_rejoin(IRC_SERVER_REC *server, const char *channel)
|
static void channel_rejoin(IRC_SERVER_REC *server, const char *channel)
|
||||||
{
|
{
|
||||||
CHANNEL_REC *chanrec;
|
IRC_CHANNEL_REC *chanrec;
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
chanrec = channel_find(server, channel);
|
chanrec = irc_channel_find(server, channel);
|
||||||
str = chanrec == NULL || chanrec->key == NULL || *chanrec->key == '\0' ?
|
str = channel_have_key(chanrec) ? g_strdup(channel) :
|
||||||
g_strdup(channel) : g_strdup_printf("%s %s", channel, chanrec->key);
|
g_strdup_printf("%s %s", channel, chanrec->key);
|
||||||
|
|
||||||
server->rejoin_channels = g_slist_append(server->rejoin_channels, str);
|
server->rejoin_channels =
|
||||||
|
g_slist_append(server->rejoin_channels, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void event_target_unavailable(const char *data, IRC_SERVER_REC *server)
|
static void event_target_unavailable(const char *data, IRC_SERVER_REC *server)
|
||||||
@ -59,7 +63,7 @@ static void event_target_unavailable(const char *data, IRC_SERVER_REC *server)
|
|||||||
|
|
||||||
static void sig_disconnected(IRC_SERVER_REC *server)
|
static void sig_disconnected(IRC_SERVER_REC *server)
|
||||||
{
|
{
|
||||||
if (!irc_server_check(server))
|
if (!IS_IRC_SERVER(server))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
g_slist_foreach(server->rejoin_channels, (GFunc) g_free, NULL);
|
g_slist_foreach(server->rejoin_channels, (GFunc) g_free, NULL);
|
||||||
@ -71,8 +75,9 @@ static void server_rejoin_channels(IRC_SERVER_REC *server)
|
|||||||
while (server->rejoin_channels != NULL) {
|
while (server->rejoin_channels != NULL) {
|
||||||
char *channel = server->rejoin_channels->data;
|
char *channel = server->rejoin_channels->data;
|
||||||
|
|
||||||
channels_join(server, channel, TRUE);
|
irc_channels_join(server, channel, TRUE);
|
||||||
server->rejoin_channels = g_slist_remove(server->rejoin_channels, channel);
|
server->rejoin_channels =
|
||||||
|
g_slist_remove(server->rejoin_channels, channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +88,7 @@ static int sig_rejoin(void)
|
|||||||
for (tmp = servers; tmp != NULL; tmp = tmp->next) {
|
for (tmp = servers; tmp != NULL; tmp = tmp->next) {
|
||||||
IRC_SERVER_REC *rec = tmp->data;
|
IRC_SERVER_REC *rec = tmp->data;
|
||||||
|
|
||||||
if (irc_server_check(rec))
|
if (IS_IRC_SERVER(rec))
|
||||||
server_rejoin_channels(rec);
|
server_rejoin_channels(rec);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +97,8 @@ static int sig_rejoin(void)
|
|||||||
|
|
||||||
void channel_rejoin_init(void)
|
void channel_rejoin_init(void)
|
||||||
{
|
{
|
||||||
rejoin_tag = g_timeout_add(REJOIN_TIMEOUT, (GSourceFunc) sig_rejoin, NULL);
|
rejoin_tag = g_timeout_add(REJOIN_TIMEOUT,
|
||||||
|
(GSourceFunc) sig_rejoin, NULL);
|
||||||
|
|
||||||
signal_add_first("event 437", (SIGNAL_FUNC) event_target_unavailable);
|
signal_add_first("event 437", (SIGNAL_FUNC) event_target_unavailable);
|
||||||
signal_add("server disconnected", (SIGNAL_FUNC) sig_disconnected);
|
signal_add("server disconnected", (SIGNAL_FUNC) sig_disconnected);
|
||||||
|
@ -39,7 +39,6 @@ loop:
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include "modules.h"
|
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "signals.h"
|
#include "signals.h"
|
||||||
|
|
||||||
@ -48,8 +47,8 @@ loop:
|
|||||||
#include "modes.h"
|
#include "modes.h"
|
||||||
#include "mode-lists.h"
|
#include "mode-lists.h"
|
||||||
#include "nicklist.h"
|
#include "nicklist.h"
|
||||||
#include "irc-server.h"
|
#include "irc-servers.h"
|
||||||
#include "server-redirect.h"
|
#include "servers-redirect.h"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
CHANNEL_QUERY_MODE,
|
CHANNEL_QUERY_MODE,
|
||||||
@ -73,7 +72,7 @@ static void sig_connected(IRC_SERVER_REC *server)
|
|||||||
SERVER_QUERY_REC *rec;
|
SERVER_QUERY_REC *rec;
|
||||||
|
|
||||||
g_return_if_fail(server != NULL);
|
g_return_if_fail(server != NULL);
|
||||||
if (!irc_server_check(server))
|
if (!IS_IRC_SERVER(server))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
rec = g_new0(SERVER_QUERY_REC, 1);
|
rec = g_new0(SERVER_QUERY_REC, 1);
|
||||||
@ -86,7 +85,7 @@ static void sig_disconnected(IRC_SERVER_REC *server)
|
|||||||
int n;
|
int n;
|
||||||
|
|
||||||
g_return_if_fail(server != NULL);
|
g_return_if_fail(server != NULL);
|
||||||
if (!irc_server_check(server))
|
if (!IS_IRC_SERVER(server))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
rec = server->chanqueries;
|
rec = server->chanqueries;
|
||||||
@ -99,7 +98,7 @@ static void sig_disconnected(IRC_SERVER_REC *server)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Add channel to query list */
|
/* Add channel to query list */
|
||||||
static void channel_query_add(CHANNEL_REC *channel, int query)
|
static void channel_query_add(IRC_CHANNEL_REC *channel, int query)
|
||||||
{
|
{
|
||||||
SERVER_QUERY_REC *rec;
|
SERVER_QUERY_REC *rec;
|
||||||
|
|
||||||
@ -111,7 +110,7 @@ static void channel_query_add(CHANNEL_REC *channel, int query)
|
|||||||
rec->queries[query] = g_slist_append(rec->queries[query], channel);
|
rec->queries[query] = g_slist_append(rec->queries[query], channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void channel_query_remove_all(CHANNEL_REC *channel)
|
static void channel_query_remove_all(IRC_CHANNEL_REC *channel)
|
||||||
{
|
{
|
||||||
SERVER_QUERY_REC *rec;
|
SERVER_QUERY_REC *rec;
|
||||||
int n;
|
int n;
|
||||||
@ -125,7 +124,7 @@ static void channel_query_remove_all(CHANNEL_REC *channel)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void sig_channel_destroyed(CHANNEL_REC *channel)
|
static void sig_channel_destroyed(IRC_CHANNEL_REC *channel)
|
||||||
{
|
{
|
||||||
g_return_if_fail(channel != NULL);
|
g_return_if_fail(channel != NULL);
|
||||||
|
|
||||||
@ -138,9 +137,9 @@ static int channels_have_all_names(IRC_SERVER_REC *server)
|
|||||||
GSList *tmp;
|
GSList *tmp;
|
||||||
|
|
||||||
for (tmp = server->channels; tmp != NULL; tmp = tmp->next) {
|
for (tmp = server->channels; tmp != NULL; tmp = tmp->next) {
|
||||||
CHANNEL_REC *rec = tmp->data;
|
IRC_CHANNEL_REC *rec = tmp->data;
|
||||||
|
|
||||||
if (!rec->names_got)
|
if (IS_IRC_CHANNEL(rec) && !rec->names_got)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,7 +161,7 @@ static int find_next_query(SERVER_QUERY_REC *server)
|
|||||||
static void channel_send_query(IRC_SERVER_REC *server, int query)
|
static void channel_send_query(IRC_SERVER_REC *server, int query)
|
||||||
{
|
{
|
||||||
SERVER_QUERY_REC *rec;
|
SERVER_QUERY_REC *rec;
|
||||||
CHANNEL_REC *chanrec;
|
IRC_CHANNEL_REC *chanrec;
|
||||||
GSList *tmp, *chans;
|
GSList *tmp, *chans;
|
||||||
char *cmd, *chanstr_commas, *chanstr;
|
char *cmd, *chanstr_commas, *chanstr;
|
||||||
int onlyone;
|
int onlyone;
|
||||||
@ -183,8 +182,8 @@ static void channel_send_query(IRC_SERVER_REC *server, int query)
|
|||||||
|
|
||||||
chans = rec->queries[query];
|
chans = rec->queries[query];
|
||||||
|
|
||||||
chanstr_commas = gslistptr_to_string(rec->queries[query], G_STRUCT_OFFSET(CHANNEL_REC, name), ",");
|
chanstr_commas = gslistptr_to_string(rec->queries[query], G_STRUCT_OFFSET(IRC_CHANNEL_REC, name), ",");
|
||||||
chanstr_spaces = gslistptr_to_string(rec->queries[query], G_STRUCT_OFFSET(CHANNEL_REC, name), " ");
|
chanstr_spaces = gslistptr_to_string(rec->queries[query], G_STRUCT_OFFSET(IRC_CHANNEL_REC, name), " ");
|
||||||
|
|
||||||
chanstr = g_strconcat(chanstr_commas, " ", chanstr_spaces, NULL);
|
chanstr = g_strconcat(chanstr_commas, " ", chanstr_spaces, NULL);
|
||||||
g_free(chanstr_spaces);
|
g_free(chanstr_spaces);
|
||||||
@ -304,7 +303,7 @@ static void channels_query_check(IRC_SERVER_REC *server)
|
|||||||
channel_send_query(server, query);
|
channel_send_query(server, query);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sig_channel_query(CHANNEL_REC *channel)
|
static void sig_channel_query(IRC_CHANNEL_REC *channel)
|
||||||
{
|
{
|
||||||
SERVER_QUERY_REC *rec;
|
SERVER_QUERY_REC *rec;
|
||||||
|
|
||||||
@ -328,7 +327,7 @@ static void sig_channel_query(CHANNEL_REC *channel)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* if there's no more queries in queries in buffer, send the sync signal */
|
/* if there's no more queries in queries in buffer, send the sync signal */
|
||||||
static void channel_checksync(CHANNEL_REC *channel)
|
static void channel_checksync(IRC_CHANNEL_REC *channel)
|
||||||
{
|
{
|
||||||
SERVER_QUERY_REC *rec;
|
SERVER_QUERY_REC *rec;
|
||||||
int n;
|
int n;
|
||||||
@ -350,7 +349,7 @@ static void channel_checksync(CHANNEL_REC *channel)
|
|||||||
signal_emit("channel sync", 1, channel);
|
signal_emit("channel sync", 1, channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void channel_got_query(IRC_SERVER_REC *server, CHANNEL_REC *chanrec, const char *channel)
|
static void channel_got_query(IRC_SERVER_REC *server, IRC_CHANNEL_REC *chanrec, const char *channel)
|
||||||
{
|
{
|
||||||
SERVER_QUERY_REC *rec;
|
SERVER_QUERY_REC *rec;
|
||||||
|
|
||||||
@ -371,13 +370,13 @@ static void channel_got_query(IRC_SERVER_REC *server, CHANNEL_REC *chanrec, cons
|
|||||||
|
|
||||||
static void event_channel_mode(char *data, IRC_SERVER_REC *server, const char *nick)
|
static void event_channel_mode(char *data, IRC_SERVER_REC *server, const char *nick)
|
||||||
{
|
{
|
||||||
CHANNEL_REC *chanrec;
|
IRC_CHANNEL_REC *chanrec;
|
||||||
char *params, *channel, *mode;
|
char *params, *channel, *mode;
|
||||||
|
|
||||||
g_return_if_fail(data != NULL);
|
g_return_if_fail(data != NULL);
|
||||||
|
|
||||||
params = event_get_params(data, 3 | PARAM_FLAG_GETREST, NULL, &channel, &mode);
|
params = event_get_params(data, 3 | PARAM_FLAG_GETREST, NULL, &channel, &mode);
|
||||||
chanrec = channel_find(server, channel);
|
chanrec = irc_channel_find(server, channel);
|
||||||
if (chanrec != NULL)
|
if (chanrec != NULL)
|
||||||
parse_channel_modes(chanrec, nick, mode);
|
parse_channel_modes(chanrec, nick, mode);
|
||||||
channel_got_query(server, chanrec, channel);
|
channel_got_query(server, chanrec, channel);
|
||||||
@ -395,7 +394,7 @@ static void multi_query_remove(IRC_SERVER_REC *server, const char *event, const
|
|||||||
|
|
||||||
static void event_end_of_who(const char *data, IRC_SERVER_REC *server)
|
static void event_end_of_who(const char *data, IRC_SERVER_REC *server)
|
||||||
{
|
{
|
||||||
CHANNEL_REC *chanrec;
|
IRC_CHANNEL_REC *chanrec;
|
||||||
NICK_REC *nick;
|
NICK_REC *nick;
|
||||||
char *params, *channel, **chans;
|
char *params, *channel, **chans;
|
||||||
int n, onewho;
|
int n, onewho;
|
||||||
@ -414,14 +413,14 @@ static void event_end_of_who(const char *data, IRC_SERVER_REC *server)
|
|||||||
|
|
||||||
/* check that the WHO actually did return something
|
/* check that the WHO actually did return something
|
||||||
(that it understood #chan1,#chan2,..) */
|
(that it understood #chan1,#chan2,..) */
|
||||||
chanrec = channel_find(server, chans[0]);
|
chanrec = irc_channel_find(server, chans[0]);
|
||||||
nick = nicklist_find(chanrec, server->nick);
|
nick = nicklist_find(CHANNEL(chanrec), server->nick);
|
||||||
if (nick->host == NULL)
|
if (nick->host == NULL)
|
||||||
server->no_multi_who = TRUE;
|
server->no_multi_who = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (n = 0; chans[n] != NULL; n++) {
|
for (n = 0; chans[n] != NULL; n++) {
|
||||||
chanrec = channel_find(server, chans[n]);
|
chanrec = irc_channel_find(server, chans[n]);
|
||||||
if (chanrec == NULL)
|
if (chanrec == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -449,13 +448,13 @@ static void event_end_of_who(const char *data, IRC_SERVER_REC *server)
|
|||||||
|
|
||||||
static void event_end_of_banlist(const char *data, IRC_SERVER_REC *server)
|
static void event_end_of_banlist(const char *data, IRC_SERVER_REC *server)
|
||||||
{
|
{
|
||||||
CHANNEL_REC *chanrec;
|
IRC_CHANNEL_REC *chanrec;
|
||||||
char *params, *channel;
|
char *params, *channel;
|
||||||
|
|
||||||
g_return_if_fail(data != NULL);
|
g_return_if_fail(data != NULL);
|
||||||
|
|
||||||
params = event_get_params(data, 2, NULL, &channel);
|
params = event_get_params(data, 2, NULL, &channel);
|
||||||
chanrec = channel_find(server, channel);
|
chanrec = irc_channel_find(server, channel);
|
||||||
|
|
||||||
channel_got_query(server, chanrec, channel);
|
channel_got_query(server, chanrec, channel);
|
||||||
|
|
||||||
@ -464,13 +463,13 @@ static void event_end_of_banlist(const char *data, IRC_SERVER_REC *server)
|
|||||||
|
|
||||||
static void event_end_of_ebanlist(const char *data, IRC_SERVER_REC *server)
|
static void event_end_of_ebanlist(const char *data, IRC_SERVER_REC *server)
|
||||||
{
|
{
|
||||||
CHANNEL_REC *chanrec;
|
IRC_CHANNEL_REC *chanrec;
|
||||||
char *params, *channel;
|
char *params, *channel;
|
||||||
|
|
||||||
g_return_if_fail(data != NULL);
|
g_return_if_fail(data != NULL);
|
||||||
|
|
||||||
params = event_get_params(data, 2, NULL, &channel);
|
params = event_get_params(data, 2, NULL, &channel);
|
||||||
chanrec = channel_find(server, channel);
|
chanrec = irc_channel_find(server, channel);
|
||||||
|
|
||||||
channel_got_query(server, chanrec, channel);
|
channel_got_query(server, chanrec, channel);
|
||||||
|
|
||||||
@ -479,13 +478,13 @@ static void event_end_of_ebanlist(const char *data, IRC_SERVER_REC *server)
|
|||||||
|
|
||||||
static void event_end_of_invitelist(const char *data, IRC_SERVER_REC *server)
|
static void event_end_of_invitelist(const char *data, IRC_SERVER_REC *server)
|
||||||
{
|
{
|
||||||
CHANNEL_REC *chanrec;
|
IRC_CHANNEL_REC *chanrec;
|
||||||
char *params, *channel;
|
char *params, *channel;
|
||||||
|
|
||||||
g_return_if_fail(data != NULL);
|
g_return_if_fail(data != NULL);
|
||||||
|
|
||||||
params = event_get_params(data, 2, NULL, &channel);
|
params = event_get_params(data, 2, NULL, &channel);
|
||||||
chanrec = channel_find(server, channel);
|
chanrec = irc_channel_find(server, channel);
|
||||||
|
|
||||||
channel_got_query(server, chanrec, channel);
|
channel_got_query(server, chanrec, channel);
|
||||||
|
|
||||||
@ -494,9 +493,9 @@ static void event_end_of_invitelist(const char *data, IRC_SERVER_REC *server)
|
|||||||
|
|
||||||
static void channel_lost(IRC_SERVER_REC *server, const char *channel)
|
static void channel_lost(IRC_SERVER_REC *server, const char *channel)
|
||||||
{
|
{
|
||||||
CHANNEL_REC *chanrec;
|
IRC_CHANNEL_REC *chanrec;
|
||||||
|
|
||||||
chanrec = channel_find(server, channel);
|
chanrec = irc_channel_find(server, channel);
|
||||||
if (chanrec != NULL) {
|
if (chanrec != NULL) {
|
||||||
/* channel not found - probably created a new channel
|
/* channel not found - probably created a new channel
|
||||||
and left it immediately. */
|
and left it immediately. */
|
||||||
@ -508,7 +507,7 @@ static void channel_lost(IRC_SERVER_REC *server, const char *channel)
|
|||||||
|
|
||||||
static void multi_command_error(IRC_SERVER_REC *server, const char *data, int query, const char *event)
|
static void multi_command_error(IRC_SERVER_REC *server, const char *data, int query, const char *event)
|
||||||
{
|
{
|
||||||
CHANNEL_REC *chanrec;
|
IRC_CHANNEL_REC *chanrec;
|
||||||
char *params, *channel, **chans;
|
char *params, *channel, **chans;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
@ -519,7 +518,7 @@ static void multi_command_error(IRC_SERVER_REC *server, const char *data, int qu
|
|||||||
chans = g_strsplit(channel, ",", -1);
|
chans = g_strsplit(channel, ",", -1);
|
||||||
for (n = 0; chans[n] != NULL; n++)
|
for (n = 0; chans[n] != NULL; n++)
|
||||||
{
|
{
|
||||||
chanrec = channel_find(server, chans[n]);
|
chanrec = irc_channel_find(server, chans[n]);
|
||||||
if (chanrec != NULL)
|
if (chanrec != NULL)
|
||||||
channel_query_add(chanrec, query);
|
channel_query_add(chanrec, query);
|
||||||
}
|
}
|
||||||
|
@ -1,253 +0,0 @@
|
|||||||
/*
|
|
||||||
channels-setup.c : irssi
|
|
||||||
|
|
||||||
Copyright (C) 1999-2000 Timo Sirainen
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "module.h"
|
|
||||||
#include "signals.h"
|
|
||||||
|
|
||||||
#include "irc.h"
|
|
||||||
#include "channels.h"
|
|
||||||
#include "channels-setup.h"
|
|
||||||
#include "nicklist.h"
|
|
||||||
#include "irc-server.h"
|
|
||||||
#include "server-setup.h"
|
|
||||||
#include "special-vars.h"
|
|
||||||
|
|
||||||
#include "lib-config/iconfig.h"
|
|
||||||
#include "settings.h"
|
|
||||||
|
|
||||||
GSList *setupchannels;
|
|
||||||
|
|
||||||
#define ircnet_match(a, b) \
|
|
||||||
((a) == NULL || (a[0]) == '\0' || (b != NULL && g_strcasecmp(a, b) == 0))
|
|
||||||
|
|
||||||
static void channel_config_add(SETUP_CHANNEL_REC *channel)
|
|
||||||
{
|
|
||||||
CONFIG_NODE *node;
|
|
||||||
|
|
||||||
node = iconfig_node_traverse("(channels", TRUE);
|
|
||||||
node = config_node_section(node, NULL, NODE_TYPE_BLOCK);
|
|
||||||
|
|
||||||
iconfig_node_set_str(node, "name", channel->name);
|
|
||||||
iconfig_node_set_str(node, "ircnet", channel->ircnet);
|
|
||||||
if (channel->autojoin)
|
|
||||||
config_node_set_bool(node, "autojoin", TRUE);
|
|
||||||
iconfig_node_set_str(node, "password", channel->password);
|
|
||||||
iconfig_node_set_str(node, "botmasks", channel->botmasks);
|
|
||||||
iconfig_node_set_str(node, "autosendcmd", channel->autosendcmd);
|
|
||||||
iconfig_node_set_str(node, "background", channel->background);
|
|
||||||
iconfig_node_set_str(node, "font", channel->font);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void channel_config_remove(SETUP_CHANNEL_REC *channel)
|
|
||||||
{
|
|
||||||
CONFIG_NODE *node;
|
|
||||||
|
|
||||||
node = iconfig_node_traverse("channels", FALSE);
|
|
||||||
if (node != NULL) iconfig_node_list_remove(node, g_slist_index(setupchannels, channel));
|
|
||||||
}
|
|
||||||
|
|
||||||
void channels_setup_create(SETUP_CHANNEL_REC *channel)
|
|
||||||
{
|
|
||||||
if (g_slist_find(setupchannels, channel) != NULL) {
|
|
||||||
channel_config_remove(channel);
|
|
||||||
setupchannels = g_slist_remove(setupchannels, channel);
|
|
||||||
}
|
|
||||||
setupchannels = g_slist_append(setupchannels, channel);
|
|
||||||
|
|
||||||
channel_config_add(channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void channels_setup_destroy_rec(SETUP_CHANNEL_REC *channel)
|
|
||||||
{
|
|
||||||
g_return_if_fail(channel != NULL);
|
|
||||||
|
|
||||||
setupchannels = g_slist_remove(setupchannels, channel);
|
|
||||||
|
|
||||||
g_free(channel->name);
|
|
||||||
g_free(channel->ircnet);
|
|
||||||
g_free_not_null(channel->password);
|
|
||||||
g_free_not_null(channel->botmasks);
|
|
||||||
g_free_not_null(channel->autosendcmd);
|
|
||||||
g_free_not_null(channel->background);
|
|
||||||
g_free_not_null(channel->font);
|
|
||||||
g_free(channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
void channels_setup_destroy(SETUP_CHANNEL_REC *channel)
|
|
||||||
{
|
|
||||||
channel_config_remove(channel);
|
|
||||||
channels_setup_destroy_rec(channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
SETUP_CHANNEL_REC *channels_setup_find(const char *channel, const char *ircnet)
|
|
||||||
{
|
|
||||||
GSList *tmp;
|
|
||||||
|
|
||||||
g_return_val_if_fail(channel != NULL, NULL);
|
|
||||||
|
|
||||||
for (tmp = setupchannels; tmp != NULL; tmp = tmp->next) {
|
|
||||||
SETUP_CHANNEL_REC *rec = tmp->data;
|
|
||||||
|
|
||||||
if (g_strcasecmp(rec->name, channel) == 0 &&
|
|
||||||
ircnet_match(rec->ircnet, ircnet))
|
|
||||||
return rec;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* connected to server, autojoin to channels. */
|
|
||||||
static void event_connected(IRC_SERVER_REC *server)
|
|
||||||
{
|
|
||||||
GString *chans;
|
|
||||||
GSList *tmp;
|
|
||||||
|
|
||||||
g_return_if_fail(server != NULL);
|
|
||||||
|
|
||||||
if (server->connrec->reconnection)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* join to the channels marked with autojoin in setup */
|
|
||||||
chans = g_string_new(NULL);
|
|
||||||
for (tmp = setupchannels; tmp != NULL; tmp = tmp->next) {
|
|
||||||
SETUP_CHANNEL_REC *rec = tmp->data;
|
|
||||||
|
|
||||||
if (!rec->autojoin || !ircnet_match(rec->ircnet, server->connrec->ircnet))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
g_string_sprintfa(chans, "%s,", rec->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (chans->len > 0) {
|
|
||||||
g_string_truncate(chans, chans->len-1);
|
|
||||||
channels_join(server, chans->str, TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_string_free(chans, TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* channel wholist received: send the auto send command */
|
|
||||||
static void channel_wholist(CHANNEL_REC *channel)
|
|
||||||
{
|
|
||||||
SETUP_CHANNEL_REC *rec;
|
|
||||||
NICK_REC *nick;
|
|
||||||
char **bots, **bot;
|
|
||||||
|
|
||||||
g_return_if_fail(channel != NULL);
|
|
||||||
|
|
||||||
rec = channels_setup_find(channel->name, channel->server->connrec->ircnet);
|
|
||||||
if (rec == NULL || rec->autosendcmd == NULL || !*rec->autosendcmd)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (rec->botmasks == NULL || !*rec->botmasks) {
|
|
||||||
/* just send the command. */
|
|
||||||
eval_special_string(rec->autosendcmd, "", channel->server, channel);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* find first available bot.. */
|
|
||||||
bots = g_strsplit(rec->botmasks, " ", -1);
|
|
||||||
for (bot = bots; *bot != NULL; bot++) {
|
|
||||||
const char *botnick = *bot;
|
|
||||||
|
|
||||||
nick = nicklist_find(channel, isnickflag(*botnick) ?
|
|
||||||
botnick+1 : botnick);
|
|
||||||
if (nick == NULL)
|
|
||||||
continue;
|
|
||||||
if ((*botnick == '@' && !nick->op) ||
|
|
||||||
(*botnick == '+' && !nick->voice && !nick->op))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* got one! */
|
|
||||||
eval_special_string(rec->autosendcmd, nick->nick, channel->server, channel);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
g_strfreev(bots);
|
|
||||||
}
|
|
||||||
|
|
||||||
static SETUP_CHANNEL_REC *setupchannel_add(CONFIG_NODE *node)
|
|
||||||
{
|
|
||||||
SETUP_CHANNEL_REC *rec;
|
|
||||||
char *channel, *ircnet, *password, *botmasks, *autosendcmd, *background, *font;
|
|
||||||
|
|
||||||
g_return_val_if_fail(node != NULL, NULL);
|
|
||||||
|
|
||||||
channel = config_node_get_str(node, "name", NULL);
|
|
||||||
ircnet = config_node_get_str(node, "ircnet", NULL);
|
|
||||||
if (channel == NULL || ircnet == NULL) {
|
|
||||||
/* missing information.. */
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
password = config_node_get_str(node, "password", NULL);
|
|
||||||
botmasks = config_node_get_str(node, "botmasks", NULL);
|
|
||||||
autosendcmd = config_node_get_str(node, "autosendcmd", NULL);
|
|
||||||
background = config_node_get_str(node, "background", NULL);
|
|
||||||
font = config_node_get_str(node, "font", NULL);
|
|
||||||
|
|
||||||
rec = g_new(SETUP_CHANNEL_REC, 1);
|
|
||||||
rec->autojoin = config_node_get_bool(node, "autojoin", FALSE);
|
|
||||||
rec->name = g_strdup(channel);
|
|
||||||
rec->ircnet = g_strdup(ircnet);
|
|
||||||
rec->password = (password == NULL || *password == '\0') ? NULL : g_strdup(password);
|
|
||||||
rec->botmasks = (botmasks == NULL || *botmasks == '\0') ? NULL : g_strdup(botmasks);
|
|
||||||
rec->autosendcmd = (autosendcmd == NULL || *autosendcmd == '\0') ? NULL : g_strdup(autosendcmd);
|
|
||||||
rec->background = (background == NULL || *background == '\0') ? NULL : g_strdup(background);
|
|
||||||
rec->font = (font == NULL || *font == '\0') ? NULL : g_strdup(font);
|
|
||||||
|
|
||||||
setupchannels = g_slist_append(setupchannels, rec);
|
|
||||||
return rec;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void channels_read_config(void)
|
|
||||||
{
|
|
||||||
CONFIG_NODE *node;
|
|
||||||
GSList *tmp;
|
|
||||||
|
|
||||||
while (setupchannels != NULL)
|
|
||||||
channels_setup_destroy_rec(setupchannels->data);
|
|
||||||
|
|
||||||
/* Read channels */
|
|
||||||
node = iconfig_node_traverse("channels", FALSE);
|
|
||||||
if (node != NULL) {
|
|
||||||
for (tmp = node->value; tmp != NULL; tmp = tmp->next)
|
|
||||||
setupchannel_add(tmp->data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void channels_setup_init(void)
|
|
||||||
{
|
|
||||||
source_host_ok = FALSE;
|
|
||||||
|
|
||||||
channels_read_config();
|
|
||||||
signal_add("event connected", (SIGNAL_FUNC) event_connected);
|
|
||||||
signal_add("channel wholist", (SIGNAL_FUNC) channel_wholist);
|
|
||||||
signal_add("setup reread", (SIGNAL_FUNC) channels_read_config);
|
|
||||||
}
|
|
||||||
|
|
||||||
void channels_setup_deinit(void)
|
|
||||||
{
|
|
||||||
while (setupchannels != NULL)
|
|
||||||
channels_setup_destroy(setupchannels->data);
|
|
||||||
|
|
||||||
signal_remove("event connected", (SIGNAL_FUNC) event_connected);
|
|
||||||
signal_remove("channel wholist", (SIGNAL_FUNC) channel_wholist);
|
|
||||||
signal_remove("setup reread", (SIGNAL_FUNC) channels_read_config);
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
#ifndef __CHANNELS_SETUP_H
|
|
||||||
#define __CHANNELS_SETUP_H
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int autojoin;
|
|
||||||
|
|
||||||
char *name;
|
|
||||||
char *ircnet;
|
|
||||||
char *password;
|
|
||||||
|
|
||||||
char *botmasks;
|
|
||||||
char *autosendcmd;
|
|
||||||
|
|
||||||
char *background;
|
|
||||||
char *font;
|
|
||||||
} SETUP_CHANNEL_REC;
|
|
||||||
|
|
||||||
extern GSList *setupchannels;
|
|
||||||
|
|
||||||
void channels_setup_init(void);
|
|
||||||
void channels_setup_deinit(void);
|
|
||||||
|
|
||||||
void channels_setup_create(SETUP_CHANNEL_REC *channel);
|
|
||||||
void channels_setup_destroy(SETUP_CHANNEL_REC *channel);
|
|
||||||
|
|
||||||
SETUP_CHANNEL_REC *channels_setup_find(const char *channel, const char *ircnet);
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,62 +0,0 @@
|
|||||||
#ifndef __CHANNELS_H
|
|
||||||
#define __CHANNELS_H
|
|
||||||
|
|
||||||
#include "irc-server.h"
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int type;
|
|
||||||
GHashTable *module_data;
|
|
||||||
|
|
||||||
IRC_SERVER_REC *server;
|
|
||||||
char *name;
|
|
||||||
|
|
||||||
int new_data;
|
|
||||||
int last_color;
|
|
||||||
|
|
||||||
time_t createtime;
|
|
||||||
|
|
||||||
GHashTable *nicks; /* list of nicks */
|
|
||||||
GSList *banlist; /* list of bans */
|
|
||||||
GSList *ebanlist; /* list of ban exceptions */
|
|
||||||
GSList *invitelist; /* invite list */
|
|
||||||
|
|
||||||
char *topic;
|
|
||||||
|
|
||||||
/* channel mode */
|
|
||||||
int no_modes:1; /* channel doesn't support modes */
|
|
||||||
char *mode;
|
|
||||||
int limit; /* user limit */
|
|
||||||
char *key; /* password key */
|
|
||||||
|
|
||||||
int chanop:1; /* You're a channel operator */
|
|
||||||
|
|
||||||
int names_got:1; /* Received /NAMES list */
|
|
||||||
int wholist:1; /* WHO list got */
|
|
||||||
int synced:1; /* Channel synced - all queries done */
|
|
||||||
|
|
||||||
int joined:1; /* Have we even received JOIN event for this channel? */
|
|
||||||
int left:1; /* You just left the channel */
|
|
||||||
int kicked:1; /* You just got kicked */
|
|
||||||
int destroying:1;
|
|
||||||
|
|
||||||
time_t massjoin_start; /* Massjoin start time */
|
|
||||||
int massjoins; /* Number of nicks waiting for massjoin signal.. */
|
|
||||||
int last_massjoins; /* Massjoins when last checked in timeout function */
|
|
||||||
} CHANNEL_REC;
|
|
||||||
|
|
||||||
extern GSList *channels;
|
|
||||||
|
|
||||||
void channels_init(void);
|
|
||||||
void channels_deinit(void);
|
|
||||||
|
|
||||||
/* Create new channel record */
|
|
||||||
CHANNEL_REC *channel_create(IRC_SERVER_REC *server, const char *channel, int automatic);
|
|
||||||
void channel_destroy(CHANNEL_REC *channel);
|
|
||||||
|
|
||||||
/* find channel by name, if `server' is NULL, search from all servers */
|
|
||||||
CHANNEL_REC *channel_find(IRC_SERVER_REC *server, const char *channel);
|
|
||||||
|
|
||||||
/* Join to channels. `data' contains channels and channel keys */
|
|
||||||
void channels_join(IRC_SERVER_REC *server, const char *data, int automatic);
|
|
||||||
|
|
||||||
#endif
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user