Added hexchat_emit_print_attrs() to plugin interface.
This commit is contained in:
parent
5e240eb259
commit
e0fb3d537d
|
@ -180,6 +180,8 @@ struct _hexchat_plugin
|
|||
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, ...);
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -330,6 +332,10 @@ int
|
|||
hexchat_emit_print (hexchat_plugin *ph,
|
||||
const char *event_name, ...);
|
||||
|
||||
int
|
||||
hexchat_emit_print_attrs (hexchat_plugin *ph, hexchat_event_attrs *attrs,
|
||||
const char *event_name, ...);
|
||||
|
||||
char *
|
||||
hexchat_gettext (hexchat_plugin *ph,
|
||||
const char *msgid);
|
||||
|
|
|
@ -295,9 +295,9 @@ plugin_add (session *sess, char *filename, void *handle, void *init_func,
|
|||
pl->hexchat_pluginpref_list = hexchat_pluginpref_list;
|
||||
pl->hexchat_hook_server_attrs = hexchat_hook_server_attrs;
|
||||
pl->hexchat_hook_print_attrs = hexchat_hook_print_attrs;
|
||||
pl->hexchat_emit_print_attrs = hexchat_emit_print_attrs;
|
||||
|
||||
/* incase new plugins are loaded on older HexChat */
|
||||
pl->hexchat_dummy2 = hexchat_dummy;
|
||||
pl->hexchat_dummy1 = hexchat_dummy;
|
||||
|
||||
/* run hexchat_plugin_init, if it returns 0, close the plugin */
|
||||
|
@ -1646,8 +1646,36 @@ hexchat_emit_print (hexchat_plugin *ph, const char *event_name, ...)
|
|||
break;
|
||||
}
|
||||
|
||||
i = text_emit_by_name ((char *)event_name, ph->context, argv[0], argv[1],
|
||||
argv[2], argv[3]);
|
||||
i = text_emit_by_name ((char *)event_name, ph->context, (time_t) 0,
|
||||
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);
|
||||
|
||||
return i;
|
||||
|
|
|
@ -144,10 +144,10 @@ struct _hexchat_plugin
|
|||
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, ...);
|
||||
|
||||
/* If you add new functions here you should remove the corresponding number
|
||||
* of dummy functions bellow. */
|
||||
void *(*hexchat_dummy2) (hexchat_plugin *ph);
|
||||
/* If you add a new function here you should remove the dummy function bellow. */
|
||||
void *(*hexchat_dummy1) (hexchat_plugin *ph);
|
||||
|
||||
/* PRIVATE FIELDS! */
|
||||
|
|
|
@ -2164,14 +2164,15 @@ text_find_format_string (char *name)
|
|||
}
|
||||
|
||||
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;
|
||||
|
||||
i = pevent_find (name, &i);
|
||||
if (i >= 0)
|
||||
{
|
||||
text_emit (i, sess, a, b, c, d, 0);
|
||||
text_emit (i, sess, a, b, c, d, timestamp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,8 @@ void pevent_make_pntevts (void);
|
|||
int text_color_of (char *name);
|
||||
void text_emit (int index, session *sess, char *a, char *b, char *c, char *d,
|
||||
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);
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue