1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-10 11:43:13 +02:00

Remove notify plugin (moved to core)

This commit is contained in:
Sebastien Helleu
2009-04-24 16:26:13 +02:00
parent 671087e26a
commit 163c5d6dfb
35 changed files with 646 additions and 962 deletions
-4
View File
@@ -70,10 +70,6 @@ IF(NOT DISABLE_LOGGER)
ADD_SUBDIRECTORY( logger )
ENDIF(NOT DISABLE_LOGGER)
IF(NOT DISABLE_NOTIFY)
ADD_SUBDIRECTORY( notify )
ENDIF(NOT DISABLE_NOTIFY)
IF(NOT DISABLE_RELAY)
ADD_SUBDIRECTORY( relay )
ENDIF(NOT DISABLE_RELAY)
+2 -6
View File
@@ -58,10 +58,6 @@ if PLUGIN_LOGGER
logger_dir = logger
endif
if PLUGIN_NOTIFY
notify_dir = notify
endif
if PLUGIN_RELAY
relay_dir = relay
endif
@@ -95,7 +91,7 @@ xfer_dir = xfer
endif
SUBDIRS = . $(alias_dir) $(aspell_dir) $(charset_dir) $(demo_dir) $(fifo_dir) \
$(irc_dir) $(jabber_dir) $(logger_dir) $(notify_dir) $(relay_dir) \
$(script_dir) $(trigger_dir) $(xfer_dir)
$(irc_dir) $(jabber_dir) $(logger_dir) $(relay_dir) $(script_dir) \
$(trigger_dir) $(xfer_dir)
EXTRA_DIST = CMakeLists.txt
+16 -16
View File
@@ -142,14 +142,14 @@ irc_display_server (struct t_irc_server *server, int with_detail)
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_ADDRESSES));
else
weechat_printf (NULL, " addresses. . . . . . : %s'%s'",
IRC_COLOR_CHAT_HOST,
IRC_COLOR_CHAT_VALUE,
weechat_config_string (server->options[IRC_SERVER_OPTION_ADDRESSES]));
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_PROXY]))
weechat_printf (NULL, " proxy. . . . . . . . : ('%s')",
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_PROXY));
else
weechat_printf (NULL, " proxy. . . . . . . . : %s'%s'",
IRC_COLOR_CHAT_HOST,
IRC_COLOR_CHAT_VALUE,
weechat_config_string (server->options[IRC_SERVER_OPTION_PROXY]));
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_IPV6]))
weechat_printf (NULL, " ipv6 . . . . . . . . : (%s)",
@@ -157,7 +157,7 @@ irc_display_server (struct t_irc_server *server, int with_detail)
_("on") : _("off"));
else
weechat_printf (NULL, " ipv6 . . . . . . . . : %s%s",
IRC_COLOR_CHAT_HOST,
IRC_COLOR_CHAT_VALUE,
weechat_config_boolean (server->options[IRC_SERVER_OPTION_IPV6]) ?
_("on") : _("off"));
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_SSL]))
@@ -166,7 +166,7 @@ irc_display_server (struct t_irc_server *server, int with_detail)
_("on") : _("off"));
else
weechat_printf (NULL, " ssl. . . . . . . . . : %s%s",
IRC_COLOR_CHAT_HOST,
IRC_COLOR_CHAT_VALUE,
weechat_config_boolean (server->options[IRC_SERVER_OPTION_SSL]) ?
_("on") : _("off"));
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_PASSWORD]))
@@ -174,7 +174,7 @@ irc_display_server (struct t_irc_server *server, int with_detail)
_("(hidden)"));
else
weechat_printf (NULL, " password . . . . . . : %s%s",
IRC_COLOR_CHAT_HOST,
IRC_COLOR_CHAT_VALUE,
_("(hidden)"));
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTOCONNECT]))
weechat_printf (NULL, " autoconnect. . . . . : (%s)",
@@ -182,7 +182,7 @@ irc_display_server (struct t_irc_server *server, int with_detail)
_("on") : _("off"));
else
weechat_printf (NULL, " autoconnect. . . . . : %s%s",
IRC_COLOR_CHAT_HOST,
IRC_COLOR_CHAT_VALUE,
weechat_config_boolean (server->options[IRC_SERVER_OPTION_AUTOCONNECT]) ?
_("on") : _("off"));
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTORECONNECT]))
@@ -191,7 +191,7 @@ irc_display_server (struct t_irc_server *server, int with_detail)
_("on") : _("off"));
else
weechat_printf (NULL, " autoreconnect. . . . : %s%s",
IRC_COLOR_CHAT_HOST,
IRC_COLOR_CHAT_VALUE,
weechat_config_boolean (server->options[IRC_SERVER_OPTION_AUTORECONNECT]) ?
_("on") : _("off"));
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTORECONNECT_DELAY]))
@@ -200,7 +200,7 @@ irc_display_server (struct t_irc_server *server, int with_detail)
NG_("second", "seconds", IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AUTORECONNECT_DELAY)));
else
weechat_printf (NULL, " autoreconnect_delay. : %s%d %s",
IRC_COLOR_CHAT_HOST,
IRC_COLOR_CHAT_VALUE,
weechat_config_integer (server->options[IRC_SERVER_OPTION_AUTORECONNECT_DELAY]),
NG_("second", "seconds", weechat_config_integer (server->options[IRC_SERVER_OPTION_AUTORECONNECT_DELAY])));
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_NICKS]))
@@ -208,28 +208,28 @@ irc_display_server (struct t_irc_server *server, int with_detail)
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_NICKS));
else
weechat_printf (NULL, " nicks. . . . . . . . : %s'%s'",
IRC_COLOR_CHAT_HOST,
IRC_COLOR_CHAT_VALUE,
weechat_config_string (server->options[IRC_SERVER_OPTION_NICKS]));
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_USERNAME]))
weechat_printf (NULL, " username . . . . . . : ('%s')",
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_USERNAME));
else
weechat_printf (NULL, " username . . . . . . : %s'%s'",
IRC_COLOR_CHAT_HOST,
IRC_COLOR_CHAT_VALUE,
weechat_config_string (server->options[IRC_SERVER_OPTION_USERNAME]));
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_REALNAME]))
weechat_printf (NULL, " realname . . . . . . : ('%s')",
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_REALNAME));
else
weechat_printf (NULL, " realname . . . . . . : %s'%s'",
IRC_COLOR_CHAT_HOST,
IRC_COLOR_CHAT_VALUE,
weechat_config_string (server->options[IRC_SERVER_OPTION_REALNAME]));
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_LOCAL_HOSTNAME]))
weechat_printf (NULL, " local_hostname . . . : ('%s')",
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_LOCAL_HOSTNAME));
else
weechat_printf (NULL, " local_hostname . . . : %s'%s'",
IRC_COLOR_CHAT_HOST,
IRC_COLOR_CHAT_VALUE,
weechat_config_string (server->options[IRC_SERVER_OPTION_LOCAL_HOSTNAME]));
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_COMMAND]))
{
@@ -247,7 +247,7 @@ irc_display_server (struct t_irc_server *server, int with_detail)
if (string && weechat_config_boolean (irc_config_look_hide_nickserv_pwd))
irc_display_hide_password (string, 1);
weechat_printf (NULL, " command. . . . . . . : %s'%s'",
IRC_COLOR_CHAT_HOST,
IRC_COLOR_CHAT_VALUE,
(string) ? string : weechat_config_string (server->options[IRC_SERVER_OPTION_COMMAND]));
if (string)
free (string);
@@ -258,7 +258,7 @@ irc_display_server (struct t_irc_server *server, int with_detail)
NG_("second", "seconds", IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_COMMAND_DELAY)));
else
weechat_printf (NULL, " command_delay. . . . : %s%d %s",
IRC_COLOR_CHAT_HOST,
IRC_COLOR_CHAT_VALUE,
weechat_config_integer (server->options[IRC_SERVER_OPTION_COMMAND_DELAY]),
NG_("second", "seconds", weechat_config_integer (server->options[IRC_SERVER_OPTION_COMMAND_DELAY])));
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTOJOIN]))
@@ -266,7 +266,7 @@ irc_display_server (struct t_irc_server *server, int with_detail)
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_AUTOJOIN));
else
weechat_printf (NULL, " autojoin . . . . . . : %s'%s'",
IRC_COLOR_CHAT_HOST,
IRC_COLOR_CHAT_VALUE,
weechat_config_string (server->options[IRC_SERVER_OPTION_AUTOJOIN]));
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_AUTOREJOIN]))
weechat_printf (NULL, " autorejoin . . . . . : (%s)",
@@ -274,7 +274,7 @@ irc_display_server (struct t_irc_server *server, int with_detail)
_("on") : _("off"));
else
weechat_printf (NULL, " autorejoin . . . . . : %s%s",
IRC_COLOR_CHAT_HOST,
IRC_COLOR_CHAT_VALUE,
weechat_config_boolean (server->options[IRC_SERVER_OPTION_AUTOREJOIN]) ?
_("on") : _("off"));
}
+1
View File
@@ -49,6 +49,7 @@
#define IRC_COLOR_CHAT_NICK_SELF weechat_color("chat_nick_self")
#define IRC_COLOR_CHAT_NICK_OTHER weechat_color("chat_nick_other")
#define IRC_COLOR_CHAT_SERVER weechat_color("chat_server")
#define IRC_COLOR_CHAT_VALUE weechat_color("chat_value")
#define IRC_COLOR_NICKLIST_PREFIX1 weechat_color("nicklist_prefix1")
#define IRC_COLOR_NICKLIST_PREFIX2 weechat_color("nicklist_prefix2")
#define IRC_COLOR_NICKLIST_PREFIX3 weechat_color("nicklist_prefix3")
+17 -17
View File
@@ -60,21 +60,21 @@ jabber_display_server (struct t_jabber_server *server, int with_detail)
JABBER_SERVER_OPTION_STRING(server, JABBER_SERVER_OPTION_USERNAME));
else
weechat_printf (NULL, " username . . . . . . : %s'%s'",
JABBER_COLOR_CHAT_HOST,
JABBER_COLOR_CHAT_VALUE,
weechat_config_string (server->options[JABBER_SERVER_OPTION_USERNAME]));
if (weechat_config_option_is_null (server->options[JABBER_SERVER_OPTION_SERVER]))
weechat_printf (NULL, " server . . . . . . . : ('%s')",
JABBER_SERVER_OPTION_STRING(server, JABBER_SERVER_OPTION_SERVER));
else
weechat_printf (NULL, " server . . . . . . . : %s'%s'",
JABBER_COLOR_CHAT_HOST,
JABBER_COLOR_CHAT_VALUE,
weechat_config_string (server->options[JABBER_SERVER_OPTION_SERVER]));
if (weechat_config_option_is_null (server->options[JABBER_SERVER_OPTION_PROXY]))
weechat_printf (NULL, " proxy. . . . . . . . : ('%s')",
JABBER_SERVER_OPTION_STRING(server, JABBER_SERVER_OPTION_PROXY));
else
weechat_printf (NULL, " proxy. . . . . . . . : %s'%s'",
JABBER_COLOR_CHAT_HOST,
JABBER_COLOR_CHAT_VALUE,
weechat_config_string (server->options[JABBER_SERVER_OPTION_PROXY]));
if (weechat_config_option_is_null (server->options[JABBER_SERVER_OPTION_IPV6]))
weechat_printf (NULL, " ipv6 . . . . . . . . : (%s)",
@@ -82,7 +82,7 @@ jabber_display_server (struct t_jabber_server *server, int with_detail)
_("on") : _("off"));
else
weechat_printf (NULL, " ipv6 . . . . . . . . : %s%s",
JABBER_COLOR_CHAT_HOST,
JABBER_COLOR_CHAT_VALUE,
weechat_config_boolean (server->options[JABBER_SERVER_OPTION_IPV6]) ?
_("on") : _("off"));
if (weechat_config_option_is_null (server->options[JABBER_SERVER_OPTION_TLS]))
@@ -91,7 +91,7 @@ jabber_display_server (struct t_jabber_server *server, int with_detail)
_("on") : _("off"));
else
weechat_printf (NULL, " tls. . . . . . . . . : %s%s",
JABBER_COLOR_CHAT_HOST,
JABBER_COLOR_CHAT_VALUE,
weechat_config_boolean (server->options[JABBER_SERVER_OPTION_TLS]) ?
_("on") : _("off"));
if (weechat_config_option_is_null (server->options[JABBER_SERVER_OPTION_SASL]))
@@ -100,7 +100,7 @@ jabber_display_server (struct t_jabber_server *server, int with_detail)
_("on") : _("off"));
else
weechat_printf (NULL, " sasl . . . . . . . . : %s%s",
JABBER_COLOR_CHAT_HOST,
JABBER_COLOR_CHAT_VALUE,
weechat_config_boolean (server->options[JABBER_SERVER_OPTION_SASL]) ?
_("on") : _("off"));
if (weechat_config_option_is_null (server->options[JABBER_SERVER_OPTION_RESOURCE]))
@@ -108,21 +108,21 @@ jabber_display_server (struct t_jabber_server *server, int with_detail)
JABBER_SERVER_OPTION_STRING(server, JABBER_SERVER_OPTION_RESOURCE));
else
weechat_printf (NULL, " resource . . . . . . : %s'%s'",
JABBER_COLOR_CHAT_HOST,
JABBER_COLOR_CHAT_VALUE,
weechat_config_string (server->options[JABBER_SERVER_OPTION_RESOURCE]));
if (weechat_config_option_is_null (server->options[JABBER_SERVER_OPTION_PASSWORD]))
weechat_printf (NULL, " password . . . . . . : %s",
_("(hidden)"));
else
weechat_printf (NULL, " password . . . . . . : %s%s",
JABBER_COLOR_CHAT_HOST,
JABBER_COLOR_CHAT_VALUE,
_("(hidden)"));
if (weechat_config_option_is_null (server->options[JABBER_SERVER_OPTION_LOCAL_ALIAS]))
weechat_printf (NULL, " local_alias. . . . . : ('%s')",
JABBER_SERVER_OPTION_STRING(server, JABBER_SERVER_OPTION_LOCAL_ALIAS));
else
weechat_printf (NULL, " local_alias. . . . . : %s'%s'",
JABBER_COLOR_CHAT_HOST,
JABBER_COLOR_CHAT_VALUE,
weechat_config_string (server->options[JABBER_SERVER_OPTION_LOCAL_ALIAS]));
if (weechat_config_option_is_null (server->options[JABBER_SERVER_OPTION_AUTOCONNECT]))
weechat_printf (NULL, " autoconnect. . . . . : (%s)",
@@ -130,7 +130,7 @@ jabber_display_server (struct t_jabber_server *server, int with_detail)
_("on") : _("off"));
else
weechat_printf (NULL, " autoconnect. . . . . : %s%s",
JABBER_COLOR_CHAT_HOST,
JABBER_COLOR_CHAT_VALUE,
weechat_config_boolean (server->options[JABBER_SERVER_OPTION_AUTOCONNECT]) ?
_("on") : _("off"));
if (weechat_config_option_is_null (server->options[JABBER_SERVER_OPTION_AUTORECONNECT]))
@@ -139,7 +139,7 @@ jabber_display_server (struct t_jabber_server *server, int with_detail)
_("on") : _("off"));
else
weechat_printf (NULL, " autoreconnect. . . . : %s%s",
JABBER_COLOR_CHAT_HOST,
JABBER_COLOR_CHAT_VALUE,
weechat_config_boolean (server->options[JABBER_SERVER_OPTION_AUTORECONNECT]) ?
_("on") : _("off"));
if (weechat_config_option_is_null (server->options[JABBER_SERVER_OPTION_AUTORECONNECT_DELAY]))
@@ -148,7 +148,7 @@ jabber_display_server (struct t_jabber_server *server, int with_detail)
NG_("second", "seconds", JABBER_SERVER_OPTION_INTEGER(server, JABBER_SERVER_OPTION_AUTORECONNECT_DELAY)));
else
weechat_printf (NULL, " autoreconnect_delay. : %s%d %s",
JABBER_COLOR_CHAT_HOST,
JABBER_COLOR_CHAT_VALUE,
weechat_config_integer (server->options[JABBER_SERVER_OPTION_AUTORECONNECT_DELAY]),
NG_("second", "seconds", weechat_config_integer (server->options[JABBER_SERVER_OPTION_AUTORECONNECT_DELAY])));
if (weechat_config_option_is_null (server->options[JABBER_SERVER_OPTION_LOCAL_HOSTNAME]))
@@ -156,14 +156,14 @@ jabber_display_server (struct t_jabber_server *server, int with_detail)
JABBER_SERVER_OPTION_STRING(server, JABBER_SERVER_OPTION_LOCAL_HOSTNAME));
else
weechat_printf (NULL, " local_hostname . . . : %s'%s'",
JABBER_COLOR_CHAT_HOST,
JABBER_COLOR_CHAT_VALUE,
weechat_config_string (server->options[JABBER_SERVER_OPTION_LOCAL_HOSTNAME]));
if (weechat_config_option_is_null (server->options[JABBER_SERVER_OPTION_COMMAND]))
weechat_printf (NULL, " command. . . . . . . : ('%s')",
JABBER_SERVER_OPTION_STRING(server, JABBER_SERVER_OPTION_COMMAND));
else
weechat_printf (NULL, " command. . . . . . . : %s'%s'",
JABBER_COLOR_CHAT_HOST,
JABBER_COLOR_CHAT_VALUE,
weechat_config_string (server->options[JABBER_SERVER_OPTION_COMMAND]));
if (weechat_config_option_is_null (server->options[JABBER_SERVER_OPTION_COMMAND_DELAY]))
weechat_printf (NULL, " command_delay. . . . : (%d %s)",
@@ -171,7 +171,7 @@ jabber_display_server (struct t_jabber_server *server, int with_detail)
NG_("second", "seconds", JABBER_SERVER_OPTION_INTEGER(server, JABBER_SERVER_OPTION_COMMAND_DELAY)));
else
weechat_printf (NULL, " command_delay. . . . : %s%d %s",
JABBER_COLOR_CHAT_HOST,
JABBER_COLOR_CHAT_VALUE,
weechat_config_integer (server->options[JABBER_SERVER_OPTION_COMMAND_DELAY]),
NG_("second", "seconds", weechat_config_integer (server->options[JABBER_SERVER_OPTION_COMMAND_DELAY])));
if (weechat_config_option_is_null (server->options[JABBER_SERVER_OPTION_AUTOJOIN]))
@@ -179,7 +179,7 @@ jabber_display_server (struct t_jabber_server *server, int with_detail)
JABBER_SERVER_OPTION_STRING(server, JABBER_SERVER_OPTION_AUTOJOIN));
else
weechat_printf (NULL, " autojoin . . . . . . : %s'%s'",
JABBER_COLOR_CHAT_HOST,
JABBER_COLOR_CHAT_VALUE,
weechat_config_string (server->options[JABBER_SERVER_OPTION_AUTOJOIN]));
if (weechat_config_option_is_null (server->options[JABBER_SERVER_OPTION_AUTOREJOIN]))
weechat_printf (NULL, " autorejoin . . . . . : (%s)",
@@ -187,7 +187,7 @@ jabber_display_server (struct t_jabber_server *server, int with_detail)
_("on") : _("off"));
else
weechat_printf (NULL, " autorejoin . . . . . : %s%s",
JABBER_COLOR_CHAT_HOST,
JABBER_COLOR_CHAT_VALUE,
weechat_config_boolean (server->options[JABBER_SERVER_OPTION_AUTOREJOIN]) ?
_("on") : _("off"));
}
+1
View File
@@ -48,6 +48,7 @@
#define JABBER_COLOR_CHAT_NICK_SELF weechat_color("chat_nick_self")
#define JABBER_COLOR_CHAT_NICK_OTHER weechat_color("chat_nick_other")
#define JABBER_COLOR_CHAT_SERVER weechat_color("chat_server")
#define JABBER_COLOR_CHAT_VALUE weechat_color("chat_value")
#define JABBER_COLOR_NICKLIST_PREFIX1 weechat_color("nicklist_prefix1")
#define JABBER_COLOR_NICKLIST_PREFIX2 weechat_color("nicklist_prefix2")
#define JABBER_COLOR_NICKLIST_PREFIX3 weechat_color("nicklist_prefix3")
-22
View File
@@ -1,22 +0,0 @@
# Copyright (c) 2003-2009 FlashCode <flashcode@flashtux.org>
#
# 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 3 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, see <http://www.gnu.org/licenses/>.
#
ADD_LIBRARY(notify MODULE notify.c)
SET_TARGET_PROPERTIES(notify PROPERTIES PREFIX "")
TARGET_LINK_LIBRARIES(notify)
INSTALL(TARGETS notify LIBRARY DESTINATION lib/${PROJECT_NAME}/plugins)
-27
View File
@@ -1,27 +0,0 @@
# Copyright (c) 2003-2009 FlashCode <flashcode@flashtux.org>
#
# 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 3 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, see <http://www.gnu.org/licenses/>.
#
INCLUDES = -DLOCALEDIR=\"$(datadir)/locale\" $(NOTIFY_CFLAGS)
libdir = ${weechat_libdir}/plugins
lib_LTLIBRARIES = notify.la
notify_la_SOURCES = notify.c
notify_la_LDFLAGS = -module
notify_la_LIBADD = $(NOTIFY_LFLAGS)
EXTRA_DIST = CMakeLists.txt
-505
View File
@@ -1,505 +0,0 @@
/*
* Copyright (c) 2003-2009 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
/* notify.c: Notify plugin for WeeChat: set/save buffer notify levels */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iconv.h>
#include "../weechat-plugin.h"
#define NOTIFY_PLUGIN_NAME "notify"
WEECHAT_PLUGIN_NAME(NOTIFY_PLUGIN_NAME);
WEECHAT_PLUGIN_DESCRIPTION("Notify plugin for WeeChat (set/save buffer notify levels)");
WEECHAT_PLUGIN_AUTHOR("FlashCode <flashcode@flashtux.org>");
WEECHAT_PLUGIN_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_WEECHAT_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_LICENSE("GPL3");
#define NOTIFY_CONFIG_NAME "notify"
struct t_weechat_plugin *weechat_notify_plugin = NULL;
#define weechat_plugin weechat_notify_plugin
struct t_config_file *notify_config_file = NULL;
struct t_config_section *notify_config_section_buffer = NULL;
#define NOTIFY_NUM_LEVELS 4
char *notify_string[NOTIFY_NUM_LEVELS] =
{ "none", "highlight", "message", "all" };
/*
* notify_search: search a notify level by name
*/
int
notify_search (const char *notify_name)
{
int i;
for (i = 0; i < NOTIFY_NUM_LEVELS; i++)
{
if (weechat_strcasecmp (notify_name, notify_string[i]) == 0)
return i;
}
/* notify level not found */
return -1;
}
/*
* notify_build_option_name: build option name for a buffer
*/
char *
notify_build_option_name (struct t_gui_buffer *buffer)
{
const char *plugin_name, *name;
char *option_name;
int length;
plugin_name = weechat_buffer_get_string (buffer, "plugin");
name = weechat_buffer_get_string (buffer, "name");
length = strlen (plugin_name) + 1 + strlen (name) + 1;
option_name = malloc (length);
if (!option_name)
return NULL;
snprintf (option_name, length, "%s.%s", plugin_name, name);
return option_name;
}
/*
* notify_get: read a notify level in config file
* we first try with all arguments, then remove one by one
* to find notify level (from specific to general notify)
*/
int
notify_get (const char *name)
{
char *option_name, *ptr_end;
struct t_config_option *ptr_option;
option_name = strdup (name);
if (option_name)
{
ptr_end = option_name + strlen (option_name);
while (ptr_end >= option_name)
{
ptr_option = weechat_config_search_option (notify_config_file,
notify_config_section_buffer,
option_name);
if (ptr_option)
{
free (option_name);
return weechat_config_integer (ptr_option);
}
ptr_end--;
while ((ptr_end >= option_name) && (ptr_end[0] != '.'))
{
ptr_end--;
}
if ((ptr_end >= option_name) && (ptr_end[0] == '.'))
ptr_end[0] = '\0';
}
ptr_option = weechat_config_search_option (notify_config_file,
notify_config_section_buffer,
option_name);
free (option_name);
if (ptr_option)
return weechat_config_integer (ptr_option);
}
/* notify level not found */
return -1;
}
/*
* notify_set_buffer: set notify for a buffer
*/
void
notify_set_buffer (struct t_gui_buffer *buffer)
{
char *option_name, notify_str[16];
int notify;
option_name = notify_build_option_name (buffer);
if (option_name)
{
notify = notify_get (option_name);
if (weechat_notify_plugin->debug)
{
weechat_printf (NULL,
_("notify: debug: set notify for buffer %s to "
"%d (%s)"),
option_name, notify,
(notify < 0) ? "reset" : notify_string[notify]);
}
/* set notify for buffer */
snprintf (notify_str, sizeof (notify_str), "%d", notify);
weechat_buffer_set (buffer, "notify", notify_str);
free (option_name);
}
}
/*
* notify_set_buffer_all: set notify for all opened buffers
*/
void
notify_set_buffer_all ()
{
struct t_infolist *ptr_infolist;
ptr_infolist = weechat_infolist_get ("buffer", NULL, NULL);
if (ptr_infolist)
{
while (weechat_infolist_next (ptr_infolist))
{
notify_set_buffer (weechat_infolist_pointer (ptr_infolist,
"pointer"));
}
weechat_infolist_free (ptr_infolist);
}
}
/*
* notify_config_cb: callback for config hook
*/
int
notify_config_cb (void *data, const char *option, const char *value)
{
/* make C compiler happy */
(void) data;
(void) option;
(void) value;
notify_set_buffer_all ();
return WEECHAT_RC_OK;
}
/*
* notify_config_reaload: reload notify configuration file
*/
int
notify_config_reload (void *data, struct t_config_file *config_file)
{
/* make C compiler happy */
(void) data;
/* free all notify levels */
weechat_config_section_free_options (notify_config_section_buffer);
return weechat_config_reload (config_file);
}
/*
* notify_config_create_option: set a notify level
*/
int
notify_config_create_option (void *data, struct t_config_file *config_file,
struct t_config_section *section,
const char *option_name, const char *value)
{
struct t_config_option *ptr_option;
int rc;
/* make C compiler happy */
(void) data;
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
if (option_name)
{
ptr_option = weechat_config_search_option (config_file, section,
option_name);
if (ptr_option)
{
if (value && value[0])
rc = weechat_config_option_set (ptr_option, value, 1);
else
{
weechat_config_option_free (ptr_option);
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
}
}
else
{
if (value && value[0])
{
ptr_option = weechat_config_new_option (
config_file, section,
option_name, "integer", NULL,
"none|highlight|message|all",
0, 0, "", value, 0, NULL, NULL, NULL, NULL, NULL, NULL);
rc = (ptr_option) ?
WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
}
else
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
}
}
if (rc == WEECHAT_CONFIG_OPTION_SET_ERROR)
{
weechat_printf (NULL,
_("%s%s: unable to set notify level \"%s\" => \"%s\""),
weechat_prefix ("error"), NOTIFY_PLUGIN_NAME,
option_name, value);
}
return rc;
}
/*
* notify_config_init: init notify configuration file
* return: 1 if ok, 0 if error
*/
int
notify_config_init ()
{
struct t_config_section *ptr_section;
notify_config_file = weechat_config_new (NOTIFY_CONFIG_NAME,
&notify_config_reload, NULL);
if (!notify_config_file)
return 0;
ptr_section = weechat_config_new_section (notify_config_file, "buffer",
1, 1,
NULL, NULL,
NULL, NULL,
NULL, NULL,
&notify_config_create_option, NULL,
NULL, NULL);
if (!ptr_section)
{
weechat_config_free (notify_config_file);
return 0;
}
notify_config_section_buffer = ptr_section;
return 1;
}
/*
* notify_config_read: read notify configuration file
*/
int
notify_config_read ()
{
return weechat_config_read (notify_config_file);
}
/*
* notify_config_write: write notify configuration file
*/
int
notify_config_write ()
{
return weechat_config_write (notify_config_file);
}
/*
* notify_buffer_opened_signal_cb: callback for "buffer_opened" signal
*/
int
notify_buffer_opened_signal_cb (void *data, const char *signal,
const char *type_data, void *signal_data)
{
/* make C compiler happy */
(void) data;
(void) signal;
(void) type_data;
notify_set_buffer (signal_data);
return WEECHAT_RC_OK;
}
/*
* notify_set: set a notify level for a buffer
*/
void
notify_set (struct t_gui_buffer *buffer, const char *name, int value)
{
char notify_str[16];
/* create/update option */
if (notify_config_create_option (NULL,
notify_config_file,
notify_config_section_buffer,
name,
(value < 0) ?
NULL : notify_string[value]) > 0)
{
/* set notify for buffer */
snprintf (notify_str, sizeof (notify_str), "%d", value);
weechat_buffer_set (buffer, "notify", notify_str);
/* display message */
if (value >= 0)
weechat_printf (NULL, "%s: \"%s\" => %s",
NOTIFY_PLUGIN_NAME, name, notify_string[value]);
else
weechat_printf (NULL, _("%s: \"%s\" removed"),
NOTIFY_PLUGIN_NAME, name);
}
}
/*
* notify_command_cb: callback for /notify command
*/
int
notify_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
char **argv, char **argv_eol)
{
int notify_level;
char *option_name;
/* make C compiler happy */
(void) data;
/* check arguments */
if (argc < 2)
{
weechat_printf (NULL,
_("%s%s: missing parameters"),
weechat_prefix ("error"), NOTIFY_PLUGIN_NAME);
return WEECHAT_RC_ERROR;
}
/* check if notify level exists */
if (weechat_strcasecmp (argv[1], "reset") == 0)
notify_level = -1;
else
{
notify_level = notify_search (argv_eol[1]);
if (notify_level < 0)
{
weechat_printf (NULL,
_("%s%s: unknown notify level \"%s\""),
weechat_prefix ("error"), NOTIFY_PLUGIN_NAME,
argv_eol[1]);
return WEECHAT_RC_ERROR;
}
}
/* set buffer notify level */
option_name = notify_build_option_name (buffer);
if (option_name)
{
notify_set (buffer, option_name, notify_level);
free (option_name);
}
else
return WEECHAT_RC_ERROR;
return WEECHAT_RC_OK;
}
/*
* weechat_plugin_init: init notify plugin
*/
int
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
{
/* make C compiler happy */
(void) argc;
(void) argv;
weechat_plugin = plugin;
if (!notify_config_init ())
{
weechat_printf (NULL,
_("%s%s: error creating configuration file"),
weechat_prefix("error"), NOTIFY_PLUGIN_NAME);
return WEECHAT_RC_ERROR;
}
notify_config_read ();
/* /notify command */
weechat_hook_command ("notify",
N_("change notify level for current buffer"),
N_("reset | none | highlight | message | all"),
N_(" reset: reset notify level to default value\n"
" none: buffer will never be in hotlist\n"
"highlight: buffer will be in hotlist for "
"highlights only\n"
" message: buffer will be in hotlist for "
"highlights and user messages only\n"
" all: buffer will be in hotlist for "
"any text printed"),
"reset|none|highlight|message|all",
&notify_command_cb, NULL);
/* callback when a buffer is opened */
weechat_hook_signal ("buffer_opened", &notify_buffer_opened_signal_cb, NULL);
/* callback when a config option is changed */
weechat_hook_config ("notify.buffer.*", &notify_config_cb, NULL);
/* set notify for opened buffers */
notify_set_buffer_all ();
return WEECHAT_RC_OK;
}
/*
* weechat_plugin_end: end notify plugin
*/
int
weechat_plugin_end (struct t_weechat_plugin *plugin)
{
/* make C compiler happy */
(void) plugin;
notify_config_write ();
weechat_config_free (notify_config_file);
return WEECHAT_RC_OK;
}