summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/common/hexchat-plugin.h6
-rw-r--r--src/common/plugin.c34
-rw-r--r--src/common/plugin.h6
-rw-r--r--src/common/text.c5
-rw-r--r--src/common/text.h3
5 files changed, 45 insertions, 9 deletions
diff --git a/src/common/hexchat-plugin.h b/src/common/hexchat-plugin.h
index f5583e2a..db2630f7 100644
--- a/src/common/hexchat-plugin.h
+++ b/src/common/hexchat-plugin.h
@@ -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);
diff --git a/src/common/plugin.c b/src/common/plugin.c
index 8e39f653..8fd6805b 100644
--- a/src/common/plugin.c
+++ b/src/common/plugin.c
@@ -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;
diff --git a/src/common/plugin.h b/src/common/plugin.h
index 9af54426..3cb97866 100644
--- a/src/common/plugin.h
+++ b/src/common/plugin.h
@@ -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! */
diff --git a/src/common/text.c b/src/common/text.c
index 94744e86..2f4323a2 100644
--- a/src/common/text.c
+++ b/src/common/text.c
@@ -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;
 	}
 
diff --git a/src/common/text.h b/src/common/text.h
index 5a51c894..a9fd9d4e 100644
--- a/src/common/text.h
+++ b/src/common/text.h
@@ -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);