changeset 6564:800ef4a51096

[gaim-migrate @ 7086] gaim_signal_register now takes a GaimValue return value and param types. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Thu, 21 Aug 2003 21:54:36 +0000
parents 122cb375be2d
children cb00e9647033
files src/account.c src/blist.c src/connection.c src/conversation.c src/core.c src/signals.c src/signals.h
diffstat 7 files changed, 283 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- a/src/account.c	Thu Aug 21 21:21:21 2003 +0000
+++ b/src/account.c	Thu Aug 21 21:54:36 2003 +0000
@@ -1429,18 +1429,35 @@
 	void *handle = gaim_accounts_get_handle();
 
 	gaim_signal_register(handle, "account-connecting",
-						 gaim_marshal_VOID__POINTER);
+						 gaim_marshal_VOID__POINTER, NULL, 1,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_ACCOUNT));
 
 	gaim_signal_register(handle, "account-away",
-						 gaim_marshal_VOID__POINTER_POINTER_POINTER);
+						 gaim_marshal_VOID__POINTER_POINTER_POINTER, NULL, 3,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_ACCOUNT),
+						 gaim_value_new(GAIM_TYPE_STRING),
+						 gaim_value_new(GAIM_TYPE_STRING));
 
 	gaim_signal_register(handle, "account-setting-info",
-						 gaim_marshal_VOID__POINTER_POINTER);
+						 gaim_marshal_VOID__POINTER_POINTER, NULL, 2,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_ACCOUNT),
+						 gaim_value_new(GAIM_TYPE_STRING));
+
 	gaim_signal_register(handle, "account-set-info",
-						 gaim_marshal_VOID__POINTER_POINTER);
+						 gaim_marshal_VOID__POINTER_POINTER, NULL, 2,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_ACCOUNT),
+						 gaim_value_new(GAIM_TYPE_STRING));
 
 	gaim_signal_register(handle, "account-warned",
-						 gaim_marshal_VOID__POINTER_POINTER_UINT);
+						 gaim_marshal_VOID__POINTER_POINTER_UINT, NULL, 3,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_ACCOUNT),
+						 gaim_value_new(GAIM_TYPE_STRING),
+						 gaim_value_new(GAIM_TYPE_UINT));
 }
 
 void
--- a/src/blist.c	Thu Aug 21 21:21:21 2003 +0000
+++ b/src/blist.c	Thu Aug 21 21:54:36 2003 +0000
@@ -2103,20 +2103,36 @@
 {
 	void *handle = gaim_blist_get_handle();
 
-	gaim_signal_register(handle, "buddy-away", gaim_marshal_VOID__POINTER);
-	gaim_signal_register(handle, "buddy-back", gaim_marshal_VOID__POINTER);
+	gaim_signal_register(handle, "buddy-away",
+						 gaim_marshal_VOID__POINTER, NULL, 1,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_BLIST_BUDDY));
+
+	gaim_signal_register(handle, "buddy-back",
+						 gaim_marshal_VOID__POINTER, NULL, 1,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_BLIST_BUDDY));
 
 	gaim_signal_register(handle, "buddy-idle",
-						 gaim_marshal_VOID__POINTER);
+						 gaim_marshal_VOID__POINTER, NULL, 1,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_BLIST_BUDDY));
 	gaim_signal_register(handle, "buddy-unidle",
-						 gaim_marshal_VOID__POINTER);
+						 gaim_marshal_VOID__POINTER, NULL, 1,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_BLIST_BUDDY));
 
 	gaim_signal_register(handle, "buddy-signed-on",
-						 gaim_marshal_VOID__POINTER);
+						 gaim_marshal_VOID__POINTER, NULL, 1,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_BLIST_BUDDY));
+
 	gaim_signal_register(handle, "buddy-signed-off",
-						 gaim_marshal_VOID__POINTER);
+						 gaim_marshal_VOID__POINTER, NULL, 1,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_BLIST_BUDDY));
 
-	gaim_signal_register(handle, "update-idle", gaim_marshal_VOID);
+	gaim_signal_register(handle, "update-idle", gaim_marshal_VOID, NULL, 0);
 }
 
 void
--- a/src/connection.c	Thu Aug 21 21:21:21 2003 +0000
+++ b/src/connection.c	Thu Aug 21 21:54:36 2003 +0000
@@ -459,10 +459,25 @@
 {
 	void *handle = gaim_connections_get_handle();
 
-	gaim_signal_register(handle, "signing-on",  gaim_marshal_VOID__POINTER);
-	gaim_signal_register(handle, "signed-on",   gaim_marshal_VOID__POINTER);
-	gaim_signal_register(handle, "signing-off", gaim_marshal_VOID__POINTER);
-	gaim_signal_register(handle, "signed-off",  gaim_marshal_VOID__POINTER);
+	gaim_signal_register(handle, "signing-on",
+						 gaim_marshal_VOID__POINTER, NULL, 1,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_ACCOUNT));
+
+	gaim_signal_register(handle, "signed-on",
+						 gaim_marshal_VOID__POINTER, NULL, 1,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_ACCOUNT));
+
+	gaim_signal_register(handle, "signing-off",
+						 gaim_marshal_VOID__POINTER, NULL, 1,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_ACCOUNT));
+
+	gaim_signal_register(handle, "signed-off",
+						 gaim_marshal_VOID__POINTER, NULL, 1,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_ACCOUNT));
 }
 
 void
--- a/src/conversation.c	Thu Aug 21 21:21:21 2003 +0000
+++ b/src/conversation.c	Thu Aug 21 21:54:36 2003 +0000
@@ -2621,61 +2621,166 @@
 
 	/* Register signals */
 	gaim_signal_register(handle, "displaying-im-msg",
-						 gaim_marshal_BOOLEAN__POINTER_POINTER);
+						 gaim_marshal_BOOLEAN__POINTER_POINTER,
+						 gaim_value_new(GAIM_TYPE_BOOLEAN), 2,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_ACCOUNT),
+						 gaim_value_new_outgoing(GAIM_TYPE_STRING));
+
 	gaim_signal_register(handle, "displayed-im-msg",
-						 gaim_marshal_VOID__POINTER_POINTER);
+						 gaim_marshal_VOID__POINTER_POINTER, NULL, 2,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_ACCOUNT),
+						 gaim_value_new(GAIM_TYPE_STRING));
+
 	gaim_signal_register(handle, "sending-im-msg",
-						 gaim_marshal_VOID__POINTER_POINTER_POINTER);
+						 gaim_marshal_VOID__POINTER_POINTER_POINTER,
+						 NULL, 3,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_ACCOUNT),
+						 gaim_value_new(GAIM_TYPE_STRING),
+						 gaim_value_new_outgoing(GAIM_TYPE_STRING));
+
 	gaim_signal_register(handle, "sent-im-msg",
-						 gaim_marshal_VOID__POINTER_POINTER_POINTER);
+						 gaim_marshal_VOID__POINTER_POINTER_POINTER,
+						 NULL, 3,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_ACCOUNT),
+						 gaim_value_new(GAIM_TYPE_STRING),
+						 gaim_value_new(GAIM_TYPE_STRING));
+
 	gaim_signal_register(handle, "received-im-msg",
-						 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER);
+						 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER,
+						 gaim_value_new(GAIM_TYPE_BOOLEAN), 4,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_ACCOUNT),
+						 gaim_value_new_outgoing(GAIM_TYPE_STRING),
+						 gaim_value_new_outgoing(GAIM_TYPE_STRING),
+						 gaim_value_new_outgoing(GAIM_TYPE_UINT));
 
 	gaim_signal_register(handle, "displaying-chat-msg",
-						 gaim_marshal_BOOLEAN__POINTER_POINTER_UINT);
+						 gaim_marshal_BOOLEAN__POINTER_POINTER,
+						 gaim_value_new(GAIM_TYPE_BOOLEAN), 2,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_ACCOUNT),
+						 gaim_value_new_outgoing(GAIM_TYPE_STRING));
+
 	gaim_signal_register(handle, "displayed-chat-msg",
-						 gaim_marshal_VOID__POINTER_POINTER_UINT);
+						 gaim_marshal_VOID__POINTER_POINTER, NULL, 2,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_ACCOUNT),
+						 gaim_value_new(GAIM_TYPE_STRING));
+
 	gaim_signal_register(handle, "sending-chat-msg",
-						 gaim_marshal_VOID__POINTER_POINTER_UINT);
+						 gaim_marshal_VOID__POINTER_POINTER_UINT, NULL, 3,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_ACCOUNT),
+						 gaim_value_new_outgoing(GAIM_TYPE_STRING),
+						 gaim_value_new(GAIM_TYPE_UINT));
+
 	gaim_signal_register(handle, "sent-chat-msg",
-						 gaim_marshal_VOID__POINTER_POINTER_UINT);
+						 gaim_marshal_VOID__POINTER_POINTER_UINT, NULL, 3,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_ACCOUNT),
+						 gaim_value_new_outgoing(GAIM_TYPE_STRING),
+						 gaim_value_new(GAIM_TYPE_UINT));
+
 	gaim_signal_register(handle, "received-chat-msg",
-				gaim_marshal_VOID__POINTER_POINTER_POINTER_UINT);
+						 gaim_marshal_VOID__POINTER_POINTER_POINTER_UINT,
+						 NULL, 4,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_ACCOUNT),
+						 gaim_value_new_outgoing(GAIM_TYPE_STRING),
+						 gaim_value_new_outgoing(GAIM_TYPE_STRING),
+						 gaim_value_new(GAIM_TYPE_UINT));
 
 	gaim_signal_register(handle, "conversation-switching",
-						 gaim_marshal_VOID__POINTER_POINTER);
+						 gaim_marshal_VOID__POINTER_POINTER, NULL, 2,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_CONVERSATION),
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_CONVERSATION));
+
 	gaim_signal_register(handle, "conversation-switched",
-						 gaim_marshal_VOID__POINTER_POINTER);
+						 gaim_marshal_VOID__POINTER_POINTER, NULL, 2,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_CONVERSATION),
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_CONVERSATION));
 
 	gaim_signal_register(handle, "conversation-created",
-						 gaim_marshal_VOID__POINTER);
+						 gaim_marshal_VOID__POINTER, NULL, 1,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_CONVERSATION));
+
 	gaim_signal_register(handle, "deleting-conversation",
-						 gaim_marshal_VOID__POINTER);
+						 gaim_marshal_VOID__POINTER, NULL, 1,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_CONVERSATION));
 
 	gaim_signal_register(handle, "buddy-typing",
-						 gaim_marshal_VOID__POINTER);
+						 gaim_marshal_VOID__POINTER, NULL, 1,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_CONVERSATION));
 
 	gaim_signal_register(handle, "chat-buddy-joining",
-						 gaim_marshal_VOID__POINTER_POINTER);
+						 gaim_marshal_VOID__POINTER_POINTER, NULL, 2,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_CONVERSATION),
+						 gaim_value_new(GAIM_TYPE_STRING));
+
 	gaim_signal_register(handle, "chat-buddy-joined",
-						 gaim_marshal_VOID__POINTER_POINTER);
+						 gaim_marshal_VOID__POINTER_POINTER, NULL, 2,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_CONVERSATION),
+						 gaim_value_new(GAIM_TYPE_STRING));
 
 	gaim_signal_register(handle, "chat-buddy-leaving",
-						 gaim_marshal_VOID__POINTER_POINTER_POINTER);
+						 gaim_marshal_VOID__POINTER_POINTER_POINTER, NULL, 3,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_CONVERSATION),
+						 gaim_value_new(GAIM_TYPE_STRING),
+						 gaim_value_new(GAIM_TYPE_STRING));
+
 	gaim_signal_register(handle, "chat-buddy-left",
-						 gaim_marshal_VOID__POINTER_POINTER_POINTER);
+						 gaim_marshal_VOID__POINTER_POINTER_POINTER, NULL, 3,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_CONVERSATION),
+						 gaim_value_new(GAIM_TYPE_STRING),
+						 gaim_value_new(GAIM_TYPE_STRING));
 
 	gaim_signal_register(handle, "chat-inviting-user",
-						 gaim_marshal_VOID__POINTER_POINTER_POINTER);
+						 gaim_marshal_VOID__POINTER_POINTER_POINTER, NULL, 3,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_CONVERSATION),
+						 gaim_value_new(GAIM_TYPE_STRING),
+						 gaim_value_new_outgoing(GAIM_TYPE_STRING));
+
 	gaim_signal_register(handle, "chat-invited-user",
-						 gaim_marshal_VOID__POINTER_POINTER_POINTER);
+						 gaim_marshal_VOID__POINTER_POINTER_POINTER, NULL, 3,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_CONVERSATION),
+						 gaim_value_new(GAIM_TYPE_STRING),
+						 gaim_value_new(GAIM_TYPE_STRING));
 
 	gaim_signal_register(handle, "chat-invited",
-						 gaim_marshal_VOID__POINTER_POINTER_POINTER_POINTER);
+						 gaim_marshal_VOID__POINTER_POINTER_POINTER_POINTER,
+						 NULL, 4,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_ACCOUNT),
+						 gaim_value_new(GAIM_TYPE_STRING),
+						 gaim_value_new(GAIM_TYPE_STRING),
+						 gaim_value_new(GAIM_TYPE_STRING));
+
 	gaim_signal_register(handle, "chat-joined",
-						 gaim_marshal_VOID__POINTER);
+						 gaim_marshal_VOID__POINTER, NULL, 1,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_CONVERSATION));
+
 	gaim_signal_register(handle, "chat-left",
-						 gaim_marshal_VOID__POINTER);
+						 gaim_marshal_VOID__POINTER, NULL, 1,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_CONVERSATION));
 }
 
 void
--- a/src/core.c	Thu Aug 21 21:21:21 2003 +0000
+++ b/src/core.c	Thu Aug 21 21:54:36 2003 +0000
@@ -64,7 +64,7 @@
 	/* The signals subsystem is important and should be first. */
 	gaim_signals_init();
 
-	gaim_signal_register(core, "quitting", gaim_marshal_VOID);
+	gaim_signal_register(core, "quitting", gaim_marshal_VOID, NULL, 0);
 
 	/* Initialize all static protocols. */
 	static_proto_init();
--- a/src/signals.c	Thu Aug 21 21:21:21 2003 +0000
+++ b/src/signals.c	Thu Aug 21 21:54:36 2003 +0000
@@ -24,6 +24,7 @@
 
 #include "debug.h"
 #include "signals.h"
+#include "value.h"
 
 typedef struct
 {
@@ -42,6 +43,10 @@
 
 	GaimSignalMarshalFunc marshal;
 
+	int num_values;
+	GaimValue **values;
+	GaimValue *ret_value;
+
 	GList *handlers;
 	size_t handler_count;
 
@@ -84,15 +89,27 @@
 
 	g_list_free(signal_data->handlers);
 
+	if (signal_data->values != NULL)
+	{
+		int i;
+
+		for (i = 0; i < signal_data->num_values; i++)
+			gaim_value_destroy((GaimValue *)signal_data->values[i]);
+
+		g_free(signal_data->values);
+	}
+
 	g_free(signal_data);
 }
 
 gulong
 gaim_signal_register(void *instance, const char *signal,
-					 GaimSignalMarshalFunc marshal)
+					 GaimSignalMarshalFunc marshal,
+					 GaimValue *ret_value, int num_values, ...)
 {
 	GaimInstanceData *instance_data;
 	GaimSignalData *signal_data;
+	va_list args;
 
 	g_return_val_if_fail(instance != NULL, 0);
 	g_return_val_if_fail(signal   != NULL, 0);
@@ -119,6 +136,22 @@
 	signal_data->id              = instance_data->next_signal_id;
 	signal_data->marshal         = marshal;
 	signal_data->next_handler_id = 1;
+	signal_data->ret_value       = ret_value;
+	signal_data->num_values      = num_values;
+
+	if (num_values > 0)
+	{
+		int i;
+
+		signal_data->values = g_new0(GaimValue *, num_values);
+
+		va_start(args, num_values);
+
+		for (i = 0; i < num_values; i++)
+			signal_data->values[i] = va_arg(args, GaimValue *);
+
+		va_end(args);
+	}
 
 	g_hash_table_insert(instance_data->signals,
 						g_strdup(signal), signal_data);
@@ -169,6 +202,38 @@
 	g_return_if_fail(found);
 }
 
+void
+gaim_signal_get_values(void *instance, const char *signal,
+					   GaimValue **ret_value,
+					   int *num_values, GaimValue ***values)
+{
+	GaimInstanceData *instance_data;
+	GaimSignalData *signal_data;
+
+	g_return_if_fail(instance   != NULL);
+	g_return_if_fail(signal     != NULL);
+	g_return_if_fail(num_values != NULL);
+	g_return_if_fail(values     != NULL);
+
+	/* Get the instance data */
+	instance_data =
+		(GaimInstanceData *)g_hash_table_lookup(instance_table, instance);
+
+	g_return_if_fail(instance_data != NULL);
+
+	/* Get the signal data */
+	signal_data =
+		(GaimSignalData *)g_hash_table_lookup(instance_data->signals, signal);
+
+	g_return_if_fail(signal_data != NULL);
+
+	*num_values = signal_data->num_values;
+	*values     = signal_data->values;
+
+	if (ret_value != NULL)
+		*ret_value = signal_data->ret_value;
+}
+
 static gulong
 signal_connect_common(void *instance, const char *signal, void *handle,
 					  GaimCallback func, void *data, gboolean use_vargs)
--- a/src/signals.h	Thu Aug 21 21:21:21 2003 +0000
+++ b/src/signals.h	Thu Aug 21 21:54:36 2003 +0000
@@ -24,6 +24,7 @@
 #define _GAIM_SIGNAL_H_
 
 #include <glib.h>
+#include "value.h"
 
 #define GAIM_CALLBACK(func) ((GaimCallback)func)
 
@@ -43,15 +44,21 @@
 /**
  * Registers a signal in an instance.
  *
- * @param instance The instance to register the signal for.
- * @param signal   The signal name.
- * @param marshal  The marshal function.
+ * @param instance  The instance to register the signal for.
+ * @param signal    The signal name.
+ * @param marshal   The marshal function.
+ * @param ret_value The return value type, or NULL for no return value.
+ * @param num_types The number of values to be passed to the callbacks.
+ * @param ...       The values to pass to the callbacks.
  *
  * @return The signal ID local to that instance, or 0 if the signal
  *         couldn't be registered.
+ *
+ * @see GaimValue
  */
 gulong gaim_signal_register(void *instance, const char *signal,
-							GaimSignalMarshalFunc marshal);
+							GaimSignalMarshalFunc marshal,
+							GaimValue *ret_value, int num_values, ...);
 
 /**
  * Unregisters a signal in an instance.
@@ -69,6 +76,18 @@
 void gaim_signals_unregister_by_instance(void *instance);
 
 /**
+ * Returns a list of value types used for a signal.
+ *
+ * @param instance   The instance the signal is registered to.
+ * @param signal     The signal.
+ * @param num_values The returned number of values.
+ * @param values     The returned list of values.
+ */
+void gaim_signal_get_values(void *instance, const char *signal,
+							GaimValue **ret_value,
+							int *num_values, GaimValue ***values);
+
+/**
  * Connects a signal handler to a signal for a particular object.
  *
  * Take care not to register a handler function twice. Gaim will