1
0
mirror of https://github.com/moparisthebest/hexchat synced 2024-12-01 13:42:16 -05:00

Merge pull request #675 from orium/server-time-plugins

Server time plugins
This commit is contained in:
Diogo Sousa 2013-07-14 11:29:24 -07:00
commit 6c8d9c2194
8 changed files with 221 additions and 32 deletions

View File

@ -548,7 +548,8 @@ dcc_chat_line (struct DCC *dcc, char *line)
for (i = 5; i < PDIWORDS; i++) for (i = 5; i < PDIWORDS; i++)
word[i] = "\000"; word[i] = "\000";
ret = plugin_emit_print (sess, word); ret = plugin_emit_print (sess, word)
+ plugin_emit_print_attrs (sess, word, 0);
/* did the plugin close it? */ /* did the plugin close it? */
if (!g_slist_find (dcc_list, dcc)) if (!g_slist_find (dcc_list, dcc))

View File

@ -49,6 +49,10 @@ typedef struct _hexchat_hook hexchat_hook;
#ifndef PLUGIN_C #ifndef PLUGIN_C
typedef struct _hexchat_context hexchat_context; typedef struct _hexchat_context hexchat_context;
#endif #endif
typedef struct
{
time_t server_time_utc; /* 0 if not used */
} hexchat_event_attrs;
#ifndef PLUGIN_C #ifndef PLUGIN_C
struct _hexchat_plugin struct _hexchat_plugin
@ -164,6 +168,23 @@ struct _hexchat_plugin
const char *var); const char *var);
int (*hexchat_pluginpref_list) (hexchat_plugin *ph, int (*hexchat_pluginpref_list) (hexchat_plugin *ph,
char *dest); char *dest);
hexchat_hook *(*hexchat_hook_server_attrs) (hexchat_plugin *ph,
const char *name,
int pri,
int (*callback) (char *word[], char *word_eol[],
hexchat_event_attrs *attrs, void *user_data),
void *userdata);
hexchat_hook *(*hexchat_hook_print_attrs) (hexchat_plugin *ph,
const char *name,
int pri,
int (*callback) (char *word[], hexchat_event_attrs *attrs,
void *user_data),
void *userdata);
int (*hexchat_emit_print_attrs) (hexchat_plugin *ph, hexchat_event_attrs *attrs,
const char *event_name, ...);
hexchat_event_attrs *(*hexchat_event_attrs_create) (hexchat_plugin *ph);
void (*hexchat_event_attrs_free) (hexchat_plugin *ph,
hexchat_event_attrs *attrs);
}; };
#endif #endif
@ -176,6 +197,10 @@ hexchat_hook_command (hexchat_plugin *ph,
const char *help_text, const char *help_text,
void *userdata); void *userdata);
hexchat_event_attrs *hexchat_event_attrs_create (hexchat_plugin *ph);
void hexchat_event_attrs_free (hexchat_plugin *ph, hexchat_event_attrs *attrs);
hexchat_hook * hexchat_hook *
hexchat_hook_server (hexchat_plugin *ph, hexchat_hook_server (hexchat_plugin *ph,
const char *name, const char *name,
@ -183,6 +208,14 @@ hexchat_hook_server (hexchat_plugin *ph,
int (*callback) (char *word[], char *word_eol[], void *user_data), int (*callback) (char *word[], char *word_eol[], void *user_data),
void *userdata); void *userdata);
hexchat_hook *
hexchat_hook_server_attrs (hexchat_plugin *ph,
const char *name,
int pri,
int (*callback) (char *word[], char *word_eol[],
hexchat_event_attrs *attrs, void *user_data),
void *userdata);
hexchat_hook * hexchat_hook *
hexchat_hook_print (hexchat_plugin *ph, hexchat_hook_print (hexchat_plugin *ph,
const char *name, const char *name,
@ -190,6 +223,14 @@ hexchat_hook_print (hexchat_plugin *ph,
int (*callback) (char *word[], void *user_data), int (*callback) (char *word[], void *user_data),
void *userdata); void *userdata);
hexchat_hook *
hexchat_hook_print_attrs (hexchat_plugin *ph,
const char *name,
int pri,
int (*callback) (char *word[], hexchat_event_attrs *attrs,
void *user_data),
void *userdata);
hexchat_hook * hexchat_hook *
hexchat_hook_timer (hexchat_plugin *ph, hexchat_hook_timer (hexchat_plugin *ph,
int timeout, int timeout,
@ -297,6 +338,10 @@ int
hexchat_emit_print (hexchat_plugin *ph, hexchat_emit_print (hexchat_plugin *ph,
const char *event_name, ...); const char *event_name, ...);
int
hexchat_emit_print_attrs (hexchat_plugin *ph, hexchat_event_attrs *attrs,
const char *event_name, ...);
char * char *
hexchat_gettext (hexchat_plugin *ph, hexchat_gettext (hexchat_plugin *ph,
const char *msgid); const char *msgid);
@ -350,8 +395,12 @@ hexchat_pluginpref_list (hexchat_plugin *ph,
#define HEXCHAT_PLUGIN_HANDLE (ph) #define HEXCHAT_PLUGIN_HANDLE (ph)
#endif #endif
#define hexchat_hook_command ((HEXCHAT_PLUGIN_HANDLE)->hexchat_hook_command) #define hexchat_hook_command ((HEXCHAT_PLUGIN_HANDLE)->hexchat_hook_command)
#define hexchat_event_attrs_create ((HEXCHAT_PLUGIN_HANDLE)->hexchat_event_attrs_create)
#define hexchat_event_attrs_free ((HEXCHAT_PLUGIN_HANDLE)->hexchat_event_attrs_free)
#define hexchat_hook_server ((HEXCHAT_PLUGIN_HANDLE)->hexchat_hook_server) #define hexchat_hook_server ((HEXCHAT_PLUGIN_HANDLE)->hexchat_hook_server)
#define hexchat_hook_server_attrs ((HEXCHAT_PLUGIN_HANDLE)->hexchat_hook_server_attrs)
#define hexchat_hook_print ((HEXCHAT_PLUGIN_HANDLE)->hexchat_hook_print) #define hexchat_hook_print ((HEXCHAT_PLUGIN_HANDLE)->hexchat_hook_print)
#define hexchat_hook_print_attrs ((HEXCHAT_PLUGIN_HANDLE)->hexchat_hook_print_attrs)
#define hexchat_hook_timer ((HEXCHAT_PLUGIN_HANDLE)->hexchat_hook_timer) #define hexchat_hook_timer ((HEXCHAT_PLUGIN_HANDLE)->hexchat_hook_timer)
#define hexchat_hook_fd ((HEXCHAT_PLUGIN_HANDLE)->hexchat_hook_fd) #define hexchat_hook_fd ((HEXCHAT_PLUGIN_HANDLE)->hexchat_hook_fd)
#define hexchat_unhook ((HEXCHAT_PLUGIN_HANDLE)->hexchat_unhook) #define hexchat_unhook ((HEXCHAT_PLUGIN_HANDLE)->hexchat_unhook)
@ -374,6 +423,7 @@ hexchat_pluginpref_list (hexchat_plugin *ph,
#define hexchat_plugingui_add ((HEXCHAT_PLUGIN_HANDLE)->hexchat_plugingui_add) #define hexchat_plugingui_add ((HEXCHAT_PLUGIN_HANDLE)->hexchat_plugingui_add)
#define hexchat_plugingui_remove ((HEXCHAT_PLUGIN_HANDLE)->hexchat_plugingui_remove) #define hexchat_plugingui_remove ((HEXCHAT_PLUGIN_HANDLE)->hexchat_plugingui_remove)
#define hexchat_emit_print ((HEXCHAT_PLUGIN_HANDLE)->hexchat_emit_print) #define hexchat_emit_print ((HEXCHAT_PLUGIN_HANDLE)->hexchat_emit_print)
#define hexchat_emit_print_attrs ((HEXCHAT_PLUGIN_HANDLE)->hexchat_emit_print_attrs)
#define hexchat_list_time ((HEXCHAT_PLUGIN_HANDLE)->hexchat_list_time) #define hexchat_list_time ((HEXCHAT_PLUGIN_HANDLE)->hexchat_list_time)
#define hexchat_gettext ((HEXCHAT_PLUGIN_HANDLE)->hexchat_gettext) #define hexchat_gettext ((HEXCHAT_PLUGIN_HANDLE)->hexchat_gettext)
#define hexchat_send_modes ((HEXCHAT_PLUGIN_HANDLE)->hexchat_send_modes) #define hexchat_send_modes ((HEXCHAT_PLUGIN_HANDLE)->hexchat_send_modes)

View File

@ -86,6 +86,8 @@ struct _hexchat_list
typedef int (hexchat_cmd_cb) (char *word[], char *word_eol[], void *user_data); typedef int (hexchat_cmd_cb) (char *word[], char *word_eol[], void *user_data);
typedef int (hexchat_serv_cb) (char *word[], char *word_eol[], void *user_data); typedef int (hexchat_serv_cb) (char *word[], char *word_eol[], void *user_data);
typedef int (hexchat_print_cb) (char *word[], void *user_data); typedef int (hexchat_print_cb) (char *word[], void *user_data);
typedef int (hexchat_serv_attrs_cb) (char *word[], char *word_eol[], hexchat_event_attrs *attrs, void *user_data);
typedef int (hexchat_print_attrs_cb) (char *word[], hexchat_event_attrs *attrs, void *user_data);
typedef int (hexchat_fd_cb) (int fd, int flags, void *user_data); typedef int (hexchat_fd_cb) (int fd, int flags, void *user_data);
typedef int (hexchat_timer_cb) (void *user_data); typedef int (hexchat_timer_cb) (void *user_data);
typedef int (hexchat_init_func) (hexchat_plugin *, char **, char **, char **, char *); typedef int (hexchat_init_func) (hexchat_plugin *, char **, char **, char **, char *);
@ -104,7 +106,9 @@ enum
{ {
HOOK_COMMAND, /* /command */ HOOK_COMMAND, /* /command */
HOOK_SERVER, /* PRIVMSG, NOTICE, numerics */ HOOK_SERVER, /* PRIVMSG, NOTICE, numerics */
HOOK_SERVER_ATTRS, /* same as above, with attributes */
HOOK_PRINT, /* All print events */ HOOK_PRINT, /* All print events */
HOOK_PRINT_ATTRS, /* same as above, with attributes */
HOOK_TIMER, /* timeouts */ HOOK_TIMER, /* timeouts */
HOOK_FD, /* sockets & fds */ HOOK_FD, /* sockets & fds */
HOOK_DELETED /* marked for deletion */ HOOK_DELETED /* marked for deletion */
@ -289,12 +293,11 @@ plugin_add (session *sess, char *filename, void *handle, void *init_func,
pl->hexchat_pluginpref_get_int = hexchat_pluginpref_get_int; pl->hexchat_pluginpref_get_int = hexchat_pluginpref_get_int;
pl->hexchat_pluginpref_delete = hexchat_pluginpref_delete; pl->hexchat_pluginpref_delete = hexchat_pluginpref_delete;
pl->hexchat_pluginpref_list = hexchat_pluginpref_list; pl->hexchat_pluginpref_list = hexchat_pluginpref_list;
pl->hexchat_hook_server_attrs = hexchat_hook_server_attrs;
/* incase new plugins are loaded on older HexChat */ pl->hexchat_hook_print_attrs = hexchat_hook_print_attrs;
pl->hexchat_dummy4 = hexchat_dummy; pl->hexchat_emit_print_attrs = hexchat_emit_print_attrs;
pl->hexchat_dummy3 = hexchat_dummy; pl->hexchat_event_attrs_create = hexchat_event_attrs_create;
pl->hexchat_dummy2 = hexchat_dummy; pl->hexchat_event_attrs_free = hexchat_event_attrs_free;
pl->hexchat_dummy1 = hexchat_dummy;
/* run hexchat_plugin_init, if it returns 0, close the plugin */ /* run hexchat_plugin_init, if it returns 0, close the plugin */
if (((hexchat_init_func *)init_func) (pl, &pl->name, &pl->desc, &pl->version, arg) == 0) if (((hexchat_init_func *)init_func) (pl, &pl->name, &pl->desc, &pl->version, arg) == 0)
@ -539,7 +542,8 @@ plugin_hook_find (GSList *list, int type, char *name)
/* check for plugin hooks and run them */ /* check for plugin hooks and run them */
static int static int
plugin_hook_run (session *sess, char *name, char *word[], char *word_eol[], int type) plugin_hook_run (session *sess, char *name, char *word[], char *word_eol[],
hexchat_event_attrs *attrs, int type)
{ {
GSList *list, *next; GSList *list, *next;
hexchat_hook *hook; hexchat_hook *hook;
@ -562,9 +566,15 @@ plugin_hook_run (session *sess, char *name, char *word[], char *word_eol[], int
case HOOK_COMMAND: case HOOK_COMMAND:
ret = ((hexchat_cmd_cb *)hook->callback) (word, word_eol, hook->userdata); ret = ((hexchat_cmd_cb *)hook->callback) (word, word_eol, hook->userdata);
break; break;
case HOOK_PRINT_ATTRS:
ret = ((hexchat_print_attrs_cb *)hook->callback) (word, attrs, hook->userdata);
break;
case HOOK_SERVER: case HOOK_SERVER:
ret = ((hexchat_serv_cb *)hook->callback) (word, word_eol, hook->userdata); ret = ((hexchat_serv_cb *)hook->callback) (word, word_eol, hook->userdata);
break; break;
case HOOK_SERVER_ATTRS:
ret = ((hexchat_serv_attrs_cb *)hook->callback) (word, word_eol, attrs, hook->userdata);
break;
default: /*case HOOK_PRINT:*/ default: /*case HOOK_PRINT:*/
ret = ((hexchat_print_cb *)hook->callback) (word, hook->userdata); ret = ((hexchat_print_cb *)hook->callback) (word, hook->userdata);
break; break;
@ -606,15 +616,43 @@ xit:
int int
plugin_emit_command (session *sess, char *name, char *word[], char *word_eol[]) plugin_emit_command (session *sess, char *name, char *word[], char *word_eol[])
{ {
return plugin_hook_run (sess, name, word, word_eol, HOOK_COMMAND); return plugin_hook_run (sess, name, word, word_eol, NULL, HOOK_COMMAND);
}
hexchat_event_attrs *
hexchat_event_attrs_create (hexchat_plugin *ph)
{
hexchat_event_attrs *attrs;
attrs = g_malloc (sizeof (*attrs));
attrs->server_time_utc = (time_t) 0;
return attrs;
}
void
hexchat_event_attrs_free (hexchat_plugin *ph, hexchat_event_attrs *attrs)
{
g_free (attrs);
} }
/* got a server PRIVMSG, NOTICE, numeric etc... */ /* got a server PRIVMSG, NOTICE, numeric etc... */
int int
plugin_emit_server (session *sess, char *name, char *word[], char *word_eol[]) plugin_emit_server (session *sess, char *name, char *word[], char *word_eol[])
{ {
return plugin_hook_run (sess, name, word, word_eol, HOOK_SERVER); return plugin_hook_run (sess, name, word, word_eol, NULL, HOOK_SERVER);
}
int
plugin_emit_server_attrs (session *sess, char *name, char *word[], char *word_eol[],
time_t server_time)
{
hexchat_event_attrs attrs;
attrs.server_time_utc = server_time;
return plugin_hook_run (sess, name, word, word_eol, &attrs, HOOK_SERVER_ATTRS);
} }
/* see if any plugins are interested in this print event */ /* see if any plugins are interested in this print event */
@ -622,7 +660,17 @@ plugin_emit_server (session *sess, char *name, char *word[], char *word_eol[])
int int
plugin_emit_print (session *sess, char *word[]) plugin_emit_print (session *sess, char *word[])
{ {
return plugin_hook_run (sess, word[0], word, NULL, HOOK_PRINT); return plugin_hook_run (sess, word[0], word, NULL, NULL, HOOK_PRINT);
}
int
plugin_emit_print_attrs (session *sess, char *word[], time_t server_time)
{
hexchat_event_attrs attrs;
attrs.server_time_utc = server_time;
return plugin_hook_run (sess, word[0], word, NULL, &attrs, HOOK_PRINT_ATTRS);
} }
int int
@ -635,7 +683,7 @@ plugin_emit_dummy_print (session *sess, char *name)
for (i = 1; i < 32; i++) for (i = 1; i < 32; i++)
word[i] = "\000"; word[i] = "\000";
return plugin_hook_run (sess, name, word, NULL, HOOK_PRINT); return plugin_hook_run (sess, name, word, NULL, NULL, HOOK_PRINT);
} }
int int
@ -663,7 +711,7 @@ plugin_emit_keypress (session *sess, unsigned int state, unsigned int keyval,
for (i = 5; i < PDIWORDS; i++) for (i = 5; i < PDIWORDS; i++)
word[i] = "\000"; word[i] = "\000";
return plugin_hook_run (sess, word[0], word, NULL, HOOK_PRINT); return plugin_hook_run (sess, word[0], word, NULL, NULL, HOOK_PRINT);
} }
static int static int
@ -868,6 +916,14 @@ hexchat_hook_server (hexchat_plugin *ph, const char *name, int pri,
return plugin_add_hook (ph, HOOK_SERVER, pri, name, 0, callb, 0, userdata); return plugin_add_hook (ph, HOOK_SERVER, pri, name, 0, callb, 0, userdata);
} }
hexchat_hook *
hexchat_hook_server_attrs (hexchat_plugin *ph, const char *name, int pri,
hexchat_serv_attrs_cb *callb, void *userdata)
{
return plugin_add_hook (ph, HOOK_SERVER_ATTRS, pri, name, 0, callb, 0,
userdata);
}
hexchat_hook * hexchat_hook *
hexchat_hook_print (hexchat_plugin *ph, const char *name, int pri, hexchat_hook_print (hexchat_plugin *ph, const char *name, int pri,
hexchat_print_cb *callb, void *userdata) hexchat_print_cb *callb, void *userdata)
@ -875,6 +931,14 @@ hexchat_hook_print (hexchat_plugin *ph, const char *name, int pri,
return plugin_add_hook (ph, HOOK_PRINT, pri, name, 0, callb, 0, userdata); return plugin_add_hook (ph, HOOK_PRINT, pri, name, 0, callb, 0, userdata);
} }
hexchat_hook *
hexchat_hook_print_attrs (hexchat_plugin *ph, const char *name, int pri,
hexchat_print_attrs_cb *callb, void *userdata)
{
return plugin_add_hook (ph, HOOK_PRINT_ATTRS, pri, name, 0, callb, 0,
userdata);
}
hexchat_hook * hexchat_hook *
hexchat_hook_timer (hexchat_plugin *ph, int timeout, hexchat_timer_cb *callb, hexchat_hook_timer (hexchat_plugin *ph, int timeout, hexchat_timer_cb *callb,
void *userdata) void *userdata)
@ -1598,8 +1662,36 @@ hexchat_emit_print (hexchat_plugin *ph, const char *event_name, ...)
break; break;
} }
i = text_emit_by_name ((char *)event_name, ph->context, argv[0], argv[1], i = text_emit_by_name ((char *)event_name, ph->context, (time_t) 0,
argv[2], argv[3]); argv[0], argv[1], argv[2], argv[3]);
va_end (args);
return i;
}
int
hexchat_emit_print_attrs (hexchat_plugin *ph, hexchat_event_attrs *attrs,
const char *event_name, ...)
{
va_list args;
/* currently only 4 because no events use more than 4.
This can be easily expanded without breaking the API. */
char *argv[4] = {NULL, NULL, NULL, NULL};
int i = 0;
va_start (args, event_name);
while (1)
{
argv[i] = va_arg (args, char *);
if (!argv[i])
break;
i++;
if (i >= 4)
break;
}
i = text_emit_by_name ((char *)event_name, ph->context, attrs->server_time_utc,
argv[0], argv[1], argv[2], argv[3]);
va_end (args); va_end (args);
return i; return i;

View File

@ -132,10 +132,24 @@ struct _hexchat_plugin
const char *var); const char *var);
int (*hexchat_pluginpref_list) (hexchat_plugin *ph, int (*hexchat_pluginpref_list) (hexchat_plugin *ph,
char *dest); char *dest);
void *(*hexchat_dummy4) (hexchat_plugin *ph); hexchat_hook *(*hexchat_hook_server_attrs) (hexchat_plugin *ph,
void *(*hexchat_dummy3) (hexchat_plugin *ph); const char *name,
void *(*hexchat_dummy2) (hexchat_plugin *ph); int pri,
void *(*hexchat_dummy1) (hexchat_plugin *ph); int (*callback) (char *word[], char *word_eol[],
hexchat_event_attrs *attrs, void *user_data),
void *userdata);
hexchat_hook *(*hexchat_hook_print_attrs) (hexchat_plugin *ph,
const char *name,
int pri,
int (*callback) (char *word[], hexchat_event_attrs *attrs,
void *user_data),
void *userdata);
int (*hexchat_emit_print_attrs) (hexchat_plugin *ph, hexchat_event_attrs *attrs,
const char *event_name, ...);
hexchat_event_attrs *(*hexchat_event_attrs_create) (hexchat_plugin *ph);
void (*hexchat_event_attrs_free) (hexchat_plugin *ph,
hexchat_event_attrs *attrs);
/* PRIVATE FIELDS! */ /* PRIVATE FIELDS! */
void *handle; /* from dlopen */ void *handle; /* from dlopen */
char *filename; /* loaded from */ char *filename; /* loaded from */
@ -156,7 +170,10 @@ void plugin_kill_all (void);
void plugin_auto_load (session *sess); void plugin_auto_load (session *sess);
int plugin_emit_command (session *sess, char *name, char *word[], char *word_eol[]); int plugin_emit_command (session *sess, char *name, char *word[], char *word_eol[]);
int plugin_emit_server (session *sess, char *name, char *word[], char *word_eol[]); int plugin_emit_server (session *sess, char *name, char *word[], char *word_eol[]);
int plugin_emit_server_attrs (session *sess, char *name, char *word[],
char *word_eol[], time_t server_time);
int plugin_emit_print (session *sess, char *word[]); int plugin_emit_print (session *sess, char *word[]);
int plugin_emit_print_attrs (session *sess, char *word[], time_t server_time);
int plugin_emit_dummy_print (session *sess, char *name); int plugin_emit_dummy_print (session *sess, char *name);
int plugin_emit_keypress (session *sess, unsigned int state, unsigned int keyval, int len, char *string); int plugin_emit_keypress (session *sess, unsigned int state, unsigned int keyval, int len, char *string);
GList* plugin_command_list(GList *tmp_list); GList* plugin_command_list(GList *tmp_list);

View File

@ -1493,6 +1493,9 @@ irc_inline (server *serv, char *buf, int len)
if (buf[0] == ':') if (buf[0] == ':')
{ {
int eat1;
int eat2;
/* find a context for this message */ /* find a context for this message */
if (is_channel (serv, word[3])) if (is_channel (serv, word[3]))
{ {
@ -1506,15 +1509,29 @@ irc_inline (server *serv, char *buf, int len)
word[0] = type; word[0] = type;
word_eol[1] = buf; /* keep the ":" for plugins */ word_eol[1] = buf; /* keep the ":" for plugins */
if (plugin_emit_server (sess, type, word, word_eol))
eat1 = plugin_emit_server (sess, type, word, word_eol);
eat2 = plugin_emit_server_attrs (sess, type, word, word_eol,
tags_data.timestamp);
if (eat1 || eat2)
goto xit; goto xit;
word[1]++; word[1]++;
word_eol[1] = buf + 1; /* but not for HexChat internally */ word_eol[1] = buf + 1; /* but not for HexChat internally */
} else } else
{ {
int eat1;
int eat2;
word[0] = type = word[1]; word[0] = type = word[1];
if (plugin_emit_server (sess, type, word, word_eol))
eat1 = plugin_emit_server (sess, type, word, word_eol);
eat2 = plugin_emit_server_attrs (sess, type, word, word_eol,
tags_data.timestamp);
if (eat1 || eat2)
goto xit; goto xit;
} }

View File

@ -2070,6 +2070,8 @@ text_emit (int index, session *sess, char *a, char *b, char *c, char *d,
int i; int i;
unsigned int stripcolor_args = (chanopt_is_set (prefs.hex_text_stripcolor_msg, sess->text_strip) ? 0xFFFFFFFF : 0); unsigned int stripcolor_args = (chanopt_is_set (prefs.hex_text_stripcolor_msg, sess->text_strip) ? 0xFFFFFFFF : 0);
char tbuf[NICKLEN + 4]; char tbuf[NICKLEN + 4];
int eat1;
int eat2;
if (prefs.hex_text_color_nicks && (index == XP_TE_CHANACTION || index == XP_TE_CHANMSG)) if (prefs.hex_text_color_nicks && (index == XP_TE_CHANACTION || index == XP_TE_CHANMSG))
{ {
@ -2086,7 +2088,10 @@ text_emit (int index, session *sess, char *a, char *b, char *c, char *d,
for (i = 5; i < PDIWORDS; i++) for (i = 5; i < PDIWORDS; i++)
word[i] = "\000"; word[i] = "\000";
if (plugin_emit_print (sess, word)) eat1 = plugin_emit_print (sess, word);
eat2 = plugin_emit_print_attrs (sess, word, timestamp);
if (eat1 || eat2)
return; return;
/* If a plugin's callback executes "/close", 'sess' may be invalid */ /* If a plugin's callback executes "/close", 'sess' may be invalid */
@ -2158,14 +2163,15 @@ text_find_format_string (char *name)
} }
int int
text_emit_by_name (char *name, session *sess, char *a, char *b, char *c, char *d) text_emit_by_name (char *name, session *sess, time_t timestamp,
char *a, char *b, char *c, char *d)
{ {
int i = 0; int i = 0;
i = pevent_find (name, &i); i = pevent_find (name, &i);
if (i >= 0) if (i >= 0)
{ {
text_emit (i, sess, a, b, c, d, 0); text_emit (i, sess, a, b, c, d, timestamp);
return 1; return 1;
} }

View File

@ -55,7 +55,8 @@ void pevent_make_pntevts (void);
int text_color_of (char *name); int text_color_of (char *name);
void text_emit (int index, session *sess, char *a, char *b, char *c, char *d, void text_emit (int index, session *sess, char *a, char *b, char *c, char *d,
time_t timestamp); time_t timestamp);
int text_emit_by_name (char *name, session *sess, char *a, char *b, char *c, char *d); int text_emit_by_name (char *name, session *sess, time_t timestamp,
char *a, char *b, char *c, char *d);
char *text_validate (char **text, int *len); char *text_validate (char **text, int *len);
int get_stamp_str (char *fmt, time_t tim, char **ret); int get_stamp_str (char *fmt, time_t tim, char **ret);
void format_event (session *sess, int index, char **args, char *o, int sizeofo, unsigned int stripcolor_args); void format_event (session *sess, int index, char **args, char *o, int sizeofo, unsigned int stripcolor_args);

View File

@ -1,8 +1,12 @@
EXPORTED { EXPORTED {
global: global:
hexchat_hook_command; hexchat_hook_command;
hexchat_event_attrs_create;
hexchat_event_attrs_free;
hexchat_hook_server; hexchat_hook_server;
hexchat_hook_server_attrs;
hexchat_hook_print; hexchat_hook_print;
hexchat_hook_print_attrs;
hexchat_hook_timer; hexchat_hook_timer;
hexchat_hook_fd; hexchat_hook_fd;
hexchat_unhook; hexchat_unhook;
@ -25,6 +29,7 @@ EXPORTED {
hexchat_plugingui_add; hexchat_plugingui_add;
hexchat_plugingui_remove; hexchat_plugingui_remove;
hexchat_emit_print; hexchat_emit_print;
hexchat_emit_print_attrs;
hexchat_list_time; hexchat_list_time;
hexchat_gettext; hexchat_gettext;
hexchat_send_modes; hexchat_send_modes;