changeset 5864:417b1001d2b1

[gaim-migrate @ 6295] Rewrote the pounce API again. Now it's even MORE core/UI-split, and will allow for loading/saving. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sat, 14 Jun 2003 11:14:49 +0000
parents 98ec3e394f59
children 412c5a0f9ef1
files src/gaimrc.c src/gtkpounce.c src/gtkpounce.h src/pounce.c src/pounce.h
diffstat 5 files changed, 391 insertions(+), 195 deletions(-) [+]
line wrap: on
line diff
--- a/src/gaimrc.c	Sat Jun 14 11:14:26 2003 +0000
+++ b/src/gaimrc.c	Sat Jun 14 11:14:49 2003 +0000
@@ -383,6 +383,17 @@
  *
  *   -- ChipX86
  */
+typedef enum
+{
+	GAIM_GTKPOUNCE_NONE       = 0x00, /**< No action.          */
+	GAIM_GTKPOUNCE_OPEN_WIN   = 0x01, /**< Open an IM window.  */
+	GAIM_GTKPOUNCE_POPUP      = 0x02, /**< Popup notification. */
+	GAIM_GTKPOUNCE_SEND_MSG   = 0x04, /**< Send a message.     */
+	GAIM_GTKPOUNCE_EXEC_CMD   = 0x08, /**< Execute a command.  */
+	GAIM_GTKPOUNCE_PLAY_SOUND = 0x10  /**< Play a sound.       */
+
+} GaimGtkPounceAction;
+
 static int pounce_evt_trans_table[] =
 {
 	0x010, GAIM_POUNCE_SIGNON,
@@ -1646,11 +1657,27 @@
 
 		old_pounce_opts_to_new(ph->options, &events, &actions);
 
-		pounce = gaim_gtkpounce_new(account, ph->name, events, actions,
-			(*ph->message == '\0' ? NULL : ph->message),
-			(*ph->command == '\0' ? NULL : ph->command),
-			(*ph->sound   == '\0' ? NULL : ph->sound),
-			(ph->options & 0x100));
+		pounce = gaim_gtkpounce_new(account, ph->name, events);
+
+		gaim_pounce_action_set_enabled(pounce, "open-window",
+			(actions & GAIM_GTKPOUNCE_OPEN_WIN));
+		gaim_pounce_action_set_enabled(pounce, "popup-notify",
+			(actions & GAIM_GTKPOUNCE_POPUP));
+		gaim_pounce_action_set_enabled(pounce, "send-message",
+			(actions & GAIM_GTKPOUNCE_SEND_MSG));
+		gaim_pounce_action_set_enabled(pounce, "execute-command",
+			(actions & GAIM_GTKPOUNCE_EXEC_CMD));
+		gaim_pounce_action_set_enabled(pounce, "play-sound",
+			(actions & GAIM_GTKPOUNCE_PLAY_SOUND));
+
+		gaim_pounce_action_set_attribute(pounce, "send-message", "message",
+			(*ph->message == '\0' ? NULL : ph->message));
+		gaim_pounce_action_set_attribute(pounce, "execute-command", "command",
+			(*ph->sound == '\0' ? NULL : ph->message));
+		gaim_pounce_action_set_attribute(pounce, "play-sound", "filename",
+			(*ph->sound == '\0' ? NULL : ph->message));
+
+		gaim_pounce_set_save(pounce, (ph->options & 0x100));
 
 		g_free(ph);
 	}
--- a/src/gtkpounce.c	Sat Jun 14 11:14:26 2003 +0000
+++ b/src/gtkpounce.c	Sat Jun 14 11:14:49 2003 +0000
@@ -1,9 +1,9 @@
 /**
- * @file gtkpounce.h GTK+ buddy pounce API
+ * @file gtkpounce.c GTK+ Buddy Pounce API
  *
  * gaim
  *
- * Copyright (C) 2003, Christian Hammond <chipx86@gnupdate.org>
+ * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.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
@@ -168,8 +168,6 @@
 	struct gaim_buddy_list *blist;
 	struct gaim_gtk_buddy_list *gtkblist;
 	GaimPounceEvent events = GAIM_POUNCE_NONE;
-	GaimGtkPounceAction actions = GAIM_GTKPOUNCE_NONE;
-	gboolean save;
 
 	name = gtk_entry_get_text(GTK_ENTRY(dialog->buddy_entry));
 
@@ -204,25 +202,6 @@
 	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->stop_typing)))
 		events |= GAIM_POUNCE_TYPING_STOPPED;
 
-
-	/* Actions */
-	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->open_win)))
-		actions |= GAIM_GTKPOUNCE_OPEN_WIN;
-
-	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->popup)))
-		actions |= GAIM_GTKPOUNCE_POPUP;
-
-	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->send_msg)))
-		actions |= GAIM_GTKPOUNCE_SEND_MSG;
-
-	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->exec_cmd)))
-		actions |= GAIM_GTKPOUNCE_EXEC_CMD;
-
-	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->play_sound)))
-		actions |= GAIM_GTKPOUNCE_PLAY_SOUND;
-
-	save = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->save_pounce));
-
 	/* Data fields */
 	message = gtk_entry_get_text(GTK_ENTRY(dialog->send_msg_entry));
 	command = gtk_entry_get_text(GTK_ENTRY(dialog->exec_cmd_entry));
@@ -232,34 +211,39 @@
 	if (*command == '\0') command = NULL;
 	if (*sound   == '\0') sound   = NULL;
 
-	if (dialog->pounce == NULL)
-	{
-		gaim_gtkpounce_new(dialog->account, name, events, actions,
-						   message, command, sound, save);
+	if (dialog->pounce == NULL) {
+		dialog->pounce = gaim_gtkpounce_new(dialog->account, name, events);
 	}
-	else
-	{
-		GaimGtkPounceData *pounce_data;
-
+	else {
 		gaim_pounce_set_events(dialog->pounce, events);
 		gaim_pounce_set_pouncer(dialog->pounce, dialog->account);
 		gaim_pounce_set_pouncee(dialog->pounce, name);
-
-		pounce_data = GAIM_GTKPOUNCE(dialog->pounce);
-
-		if (pounce_data->message != NULL) g_free(pounce_data->message);
-		if (pounce_data->command != NULL) g_free(pounce_data->command);
-		if (pounce_data->sound   != NULL) g_free(pounce_data->sound);
-
-		pounce_data->message = (message == NULL ? NULL : g_strdup(message));
-		pounce_data->command = (command == NULL ? NULL : g_strdup(command));
-		pounce_data->sound   = (sound   == NULL ? NULL : g_strdup(sound));
-
-		pounce_data->actions = actions;
-		pounce_data->save    = save;
 	}
 
+	/* Actions*/
+	gaim_pounce_action_set_enabled(dialog->pounce, "open-window",
+		gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->open_win)));
+	gaim_pounce_action_set_enabled(dialog->pounce, "popup-notify",
+		gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->popup)));
+	gaim_pounce_action_set_enabled(dialog->pounce, "send-message",
+		gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->send_msg)));
+	gaim_pounce_action_set_enabled(dialog->pounce, "execute-command",
+		gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->exec_cmd)));
+	gaim_pounce_action_set_enabled(dialog->pounce, "play-sound",
+		gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->play_sound)));
+
+	gaim_pounce_action_set_attribute(dialog->pounce, "send-message",
+									 "message", message);
+	gaim_pounce_action_set_attribute(dialog->pounce, "execute-command",
+									 "command", command);
+	gaim_pounce_action_set_attribute(dialog->pounce, "play-sound",
+									 "filename", sound);
+
+	gaim_pounce_set_save(dialog->pounce,
+		gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->save_pounce)));
+
 	delete_win_cb(NULL, NULL, dialog);
+
 	/* Rebuild the pounce menu */
 	blist = gaim_get_blist();
 
@@ -330,21 +314,19 @@
 {
 	GaimConversation *conv;
 	GaimAccount *account;
-	GaimGtkPounceData *pounce_data;
 	const char *pouncee;
 
-	pounce_data = (GaimGtkPounceData *)data;
-	pouncee     = gaim_pounce_get_pouncee(pounce);
-	account     = gaim_pounce_get_pouncer(pounce);
+	pouncee = gaim_pounce_get_pouncee(pounce);
+	account = gaim_pounce_get_pouncer(pounce);
 
-	if (pounce_data->actions & GAIM_GTKPOUNCE_OPEN_WIN) {
+	if (gaim_pounce_action_is_enabled(pounce, "open-window")) {
 		conv = gaim_find_conversation(pouncee);
 
 		if (conv == NULL)
 			conv = gaim_conversation_new(GAIM_CONV_IM, account, pouncee);
 	}
 
-	if (pounce_data->actions & GAIM_GTKPOUNCE_POPUP) {
+	if (gaim_pounce_action_is_enabled(pounce, "popup-notify")) {
 		char tmp[1024];
 
 		g_snprintf(tmp, sizeof(tmp),
@@ -362,66 +344,70 @@
 		gaim_notify_info(NULL, NULL, tmp, NULL);
 	}
 
-	if (pounce_data->actions & GAIM_GTKPOUNCE_SEND_MSG &&
-		pounce_data->message != NULL) {
+	if (gaim_pounce_action_is_enabled(pounce, "send-message")) {
+		const char *message;
 
-		conv = gaim_find_conversation(pouncee);
+		message = gaim_pounce_action_get_attribute(pounce, "send-message",
+												   "message");
+
+		if (message != NULL) {
+			conv = gaim_find_conversation(pouncee);
 
-		if (conv == NULL)
-			conv = gaim_conversation_new(GAIM_CONV_IM, account, pouncee);
+			if (conv == NULL)
+				conv = gaim_conversation_new(GAIM_CONV_IM, account, pouncee);
 
-		gaim_conversation_write(conv, NULL, pounce_data->message, -1,
-								WFLAG_SEND, time(NULL));
+			gaim_conversation_write(conv, NULL, message, -1,
+									WFLAG_SEND, time(NULL));
 
-		serv_send_im(account->gc, (char *)pouncee, pounce_data->message, -1, 0);
+			serv_send_im(account->gc, (char *)pouncee, (char *)message, -1, 0);
+		}
 	}
 
-	if (pounce_data->actions & GAIM_GTKPOUNCE_EXEC_CMD &&
-		pounce_data->command != NULL) {
 #ifndef _WIN32
-		int pid = fork();
+	if (gaim_pounce_action_is_enabled(pounce, "execute-command")) {
+		const char *command;
+
+		command = gaim_pounce_action_get_attribute(pounce, "execute-command",
+												   "command");
 
-		if (pid == 0) {
-			char *args[4];
+		if (command != NULL) {
+			int pid = fork();
+
+			if (pid == 0) {
+				char *args[4];
 
-			args[0] = "sh";
-			args[1] = "-c";
-			args[2] = pounce_data->command;
-			args[3] = NULL;
+				args[0] = "sh";
+				args[1] = "-c";
+				args[2] = (char *)command;
+				args[3] = NULL;
 
-			execvp(args[0], args);
+				execvp(args[0], args);
 
-			_exit(0);
+				_exit(0);
+			}
 		}
-#endif /* _WIN32 */
 	}
+#endif /* _WIN32 */
 
-	if (pounce_data->actions & GAIM_GTKPOUNCE_PLAY_SOUND) {
-		if (pounce_data->sound != NULL)
-			gaim_sound_play_file(pounce_data->sound);
+	if (gaim_pounce_action_is_enabled(pounce, "play-sound")) {
+		const char *sound;
+
+		sound = gaim_pounce_action_get_attribute(pounce, "play-sound",
+												 "sound");
+
+		if (sound != NULL)
+			gaim_sound_play_file(sound);
 		else
 			gaim_sound_play_event(GAIM_SOUND_POUNCE_DEFAULT);
 	}
-
-	if (!pounce_data->save)
-		gaim_pounce_destroy(pounce);
 }
 
 static void
 free_pounce(void *data)
 {
-	GaimGtkPounceData *pounce_data;
 	struct gaim_buddy_list *blist;
 	struct gaim_gtk_buddy_list *gtkblist;
 
-	pounce_data = (GaimGtkPounceData *)data;
-
-	if (pounce_data->message != NULL) g_free(pounce_data->message);
-	if (pounce_data->command != NULL) g_free(pounce_data->command);
-	if (pounce_data->sound   != NULL) g_free(pounce_data->sound);
-
-	g_free(data);
-
 	/* Rebuild the pounce menu */
 	blist = gaim_get_blist();
 
@@ -435,24 +421,20 @@
 
 GaimPounce *
 gaim_gtkpounce_new(GaimAccount *pouncer, const char *pouncee,
-				   GaimPounceEvent events, GaimGtkPounceAction actions,
-				   const char *message, const char *command,
-				   const char *sound, gboolean save)
+				   GaimPounceEvent events)
 {
-	GaimGtkPounceData *data;
+	GaimPounce *pounce;
 
-	data = g_new0(GaimGtkPounceData, 1);
+	pounce = gaim_pounce_new(GAIM_GTK_UI, pouncer, pouncee, events,
+							 pounce_cb, NULL, free_pounce);
 
-	data->actions = actions;
+	gaim_pounce_action_register(pounce, "open-window");
+	gaim_pounce_action_register(pounce, "popup-notify");
+	gaim_pounce_action_register(pounce, "send-message");
+	gaim_pounce_action_register(pounce, "execute-command");
+	gaim_pounce_action_register(pounce, "play-sound");
 
-	if (message != NULL) data->message = g_strdup(message);
-	if (command != NULL) data->command = g_strdup(command);
-	if (sound   != NULL) data->sound   = g_strdup(sound);
-
-	data->save = save;
-
-	return gaim_pounce_new(pouncer, pouncee, events, pounce_cb, data,
-						   free_pounce);
+	return pounce;
 }
 
 void
@@ -750,14 +732,10 @@
 
 	/* Set the values of stuff. */
 	if (cur_pounce != NULL) {
-		GaimPounceEvent events;
-		GaimGtkPounceAction actions;
-		GaimGtkPounceData *pounce_data;
+		GaimPounceEvent events = gaim_pounce_get_events(cur_pounce);
+		const char *value;
 
-		pounce_data = GAIM_GTKPOUNCE(cur_pounce);
-		events      = gaim_pounce_get_events(cur_pounce);
-		actions     = pounce_data->actions;
-
+		/* Events */
 		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->signon),
 									(events & GAIM_POUNCE_SIGNON));
 		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->signoff),
@@ -775,29 +753,40 @@
 		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->stop_typing),
 									(events & GAIM_POUNCE_TYPING_STOPPED));
 
+		/* Actions */
 		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->open_win),
-									(actions & GAIM_GTKPOUNCE_OPEN_WIN));
+			gaim_pounce_action_is_enabled(cur_pounce, "open-window"));
 		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->popup),
-									(actions & GAIM_GTKPOUNCE_POPUP));
+			gaim_pounce_action_is_enabled(cur_pounce, "popup-notify"));
 		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->send_msg),
-									(actions & GAIM_GTKPOUNCE_SEND_MSG));
+			gaim_pounce_action_is_enabled(cur_pounce, "send-message"));
 		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->exec_cmd),
-									(actions & GAIM_GTKPOUNCE_EXEC_CMD));
+			gaim_pounce_action_is_enabled(cur_pounce, "execute-command"));
 		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->play_sound),
-									(actions & GAIM_GTKPOUNCE_PLAY_SOUND));
+			gaim_pounce_action_is_enabled(cur_pounce, "play-sound"));
 
 		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->save_pounce),
-									 pounce_data->save);
+			gaim_pounce_get_save(cur_pounce));
+
+		if ((value = gaim_pounce_action_get_attribute(cur_pounce,
+													  "send-message",
+													  "message")) != NULL) {
+
+			gtk_entry_set_text(GTK_ENTRY(dialog->send_msg_entry), value);
+		}
 
-		if (pounce_data->message != NULL)
-			gtk_entry_set_text(GTK_ENTRY(dialog->send_msg_entry),
-							   pounce_data->message);
-		if (pounce_data->command != NULL)
-			gtk_entry_set_text(GTK_ENTRY(dialog->exec_cmd_entry),
-							   pounce_data->command);
-		if (pounce_data->sound != NULL)
-			gtk_entry_set_text(GTK_ENTRY(dialog->play_sound_entry),
-							   pounce_data->sound);
+		if ((value = gaim_pounce_action_get_attribute(cur_pounce,
+													  "execute-command",
+													  "command")) != NULL) {
+
+			gtk_entry_set_text(GTK_ENTRY(dialog->exec_cmd_entry), value);
+		}
+
+		if ((value = gaim_pounce_action_get_attribute(cur_pounce,
+													  "play-sound",
+													  "filename")) != NULL) {
+			gtk_entry_set_text(GTK_ENTRY(dialog->play_sound_entry), value);
+		}
 	}
 	else {
 		/* Set some defaults */
--- a/src/gtkpounce.h	Sat Jun 14 11:14:26 2003 +0000
+++ b/src/gtkpounce.h	Sat Jun 14 11:14:49 2003 +0000
@@ -1,10 +1,10 @@
 /**
- * @file gtkpounce.h GTK+ buddy pounce API
+ * @file gtkpounce.h GTK+ Buddy Pounce API
  * @ingroup gtkui
  *
  * gaim
  *
- * Copyright (C) 2003, Christian Hammond <chipx86@gnupdate.org>
+ * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.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
@@ -26,60 +26,16 @@
 #include "pounce.h"
 
 /**
- * Types of actions that gaim's GTK+ interface supports.
- */
-typedef enum
-{
-	GAIM_GTKPOUNCE_NONE       = 0x00, /**< No action.          */
-	GAIM_GTKPOUNCE_OPEN_WIN   = 0x01, /**< Open an IM window.  */
-	GAIM_GTKPOUNCE_POPUP      = 0x02, /**< Popup notification. */
-	GAIM_GTKPOUNCE_SEND_MSG   = 0x04, /**< Send a message.     */
-	GAIM_GTKPOUNCE_EXEC_CMD   = 0x08, /**< Execute a command.  */
-	GAIM_GTKPOUNCE_PLAY_SOUND = 0x10  /**< Play a sound.       */
-
-} GaimGtkPounceAction;
-
-/**
- * GTK+ pounce-specific data.
- */
-typedef struct
-{
-	GaimGtkPounceAction actions;  /**< The action(s) for this pounce.      */
-
-	char *message;          /**< The message to send, if
-	                             GAIM_GTKPOUNCE_SEND_MSG is in actions.    */
-	char *command;          /**< The command to execute, if
-	                             GAIM_GTKPOUNCE_EXEC_CMD is in actions.    */
-	char *sound;            /**< The sound file to play, if
-	                             GAIM_GTKPOUNCE_PLAY_SOUND is in actions.  */
-
-	gboolean save;          /**< If TRUE, the pounce should be saved after
-	                             activation.                               */
-
-} GaimGtkPounceData;
-
-#define GAIM_GTKPOUNCE(pounce) \
-	((GaimGtkPounceData *)gaim_pounce_get_data(pounce))
-
-/**
  * Creates a GTK-specific pounce.
  *
  * @param pouncer The account that will pounce.
  * @param pouncee The buddy to pounce on.
  * @param events  The event(s) to pounce on.
- * @param actions The actions.
- * @param message The optional message to send.
- * @param command The optional command to execute.
- * @param sound   The optional sound to play.
- * @param save    Whether or not to save the data.
  *
  * @return The new buddy pounce.
  */
 GaimPounce *gaim_gtkpounce_new(GaimAccount *pouncer, const char *pouncee,
-							   GaimPounceEvent events,
-							   GaimGtkPounceAction actions,
-							   const char *message, const char *command,
-							   const char *sound, gboolean save);
+							   GaimPounceEvent events);
 
 /**
  * Displays a New Buddy Pounce or Edit Buddy Pounce dialog.
--- a/src/pounce.c	Sat Jun 14 11:14:26 2003 +0000
+++ b/src/pounce.c	Sat Jun 14 11:14:49 2003 +0000
@@ -1,9 +1,9 @@
 /**
- * @file pounce.h Buddy pounce API
+ * @file pounce.c Buddy Pounce API
  *
  * gaim
  *
- * Copyright (C) 2003, Christian Hammond <chipx86@gnupdate.org>
+ * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.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
@@ -23,15 +23,52 @@
 #include <string.h>
 #include "gaim.h"
 
+typedef struct
+{
+	char *name;
+
+	gboolean enabled;
+
+	GHashTable *atts;
+
+} GaimPounceActionData;
+
+
 static GList *pounces = NULL;
 
+static GaimPounceActionData *
+find_action_data(const GaimPounce *pounce, const char *name)
+{
+	GaimPounceActionData *action;
+
+	g_return_val_if_fail(pounce != NULL, NULL);
+	g_return_val_if_fail(name   != NULL, NULL);
+
+	action = g_hash_table_lookup(pounce->actions, name);
+
+	return action;
+}
+
+static void
+free_action_data(gpointer data)
+{
+	GaimPounceActionData *action_data = data;
+
+	g_free(action_data->name);
+
+	g_hash_table_destroy(action_data->atts);
+
+	g_free(action_data);
+}
+
 GaimPounce *
-gaim_pounce_new(GaimAccount *pouncer, const char *pouncee,
-				GaimPounceEvent event, GaimPounceCb cb,
-				void *data, void (*free)(void *))
+gaim_pounce_new(const char *ui_type, GaimAccount *pouncer,
+				const char *pouncee, GaimPounceEvent event,
+				GaimPounceCb cb, void *data, void (*free)(void *))
 {
 	GaimPounce *pounce;
 
+	g_return_val_if_fail(ui_type != NULL, NULL);
 	g_return_val_if_fail(pouncer != NULL, NULL);
 	g_return_val_if_fail(pouncee != NULL, NULL);
 	g_return_val_if_fail(event   != 0,    NULL);
@@ -39,6 +76,7 @@
 
 	pounce = g_new0(GaimPounce, 1);
 
+	pounce->ui_type  = g_strdup(ui_type);
 	pounce->pouncer  = pouncer;
 	pounce->pouncee  = g_strdup(pouncee);
 	pounce->events   = event;
@@ -46,6 +84,9 @@
 	pounce->data     = data;
 	pounce->free     = free;
 
+	pounce->actions  = g_hash_table_new_full(g_str_hash, g_str_equal,
+											 g_free, free_action_data);
+
 	pounces = g_list_append(pounces, pounce);
 
 	return pounce;
@@ -56,10 +97,12 @@
 {
 	g_return_if_fail(pounce != NULL);
 
-	if (pounce->pouncee != NULL)
-		g_free(pounce->pouncee);
+	pounces = g_list_remove(pounces, pounce);
 
-	pounces = g_list_remove(pounces, pounce);
+	if (pounce->ui_type != NULL) g_free(pounce->ui_type);
+	if (pounce->pouncee != NULL) g_free(pounce->pouncee);
+
+	g_hash_table_destroy(pounce->actions);
 
 	if (pounce->free != NULL && pounce->data != NULL)
 		pounce->free(pounce->data);
@@ -98,6 +141,69 @@
 }
 
 void
+gaim_pounce_set_save(GaimPounce *pounce, gboolean save)
+{
+	g_return_if_fail(pounce != NULL);
+
+	pounce->save = save;
+}
+
+void
+gaim_pounce_action_register(GaimPounce *pounce, const char *name)
+{
+	GaimPounceActionData *action_data;
+
+	g_return_if_fail(pounce != NULL);
+	g_return_if_fail(name   != NULL);
+
+	action_data = g_new0(GaimPounceActionData, 1);
+
+	action_data->name    = g_strdup(name);
+	action_data->enabled = FALSE;
+	action_data->atts    = g_hash_table_new_full(g_str_hash, g_str_equal,
+												 g_free, g_free);
+
+	g_hash_table_insert(pounce->actions, g_strdup(name), action_data);
+}
+
+void
+gaim_pounce_action_set_enabled(GaimPounce *pounce, const char *action,
+							   gboolean enabled)
+{
+	GaimPounceActionData *action_data;
+
+	g_return_if_fail(pounce != NULL);
+	g_return_if_fail(action != NULL);
+
+	action_data = find_action_data(pounce, action);
+
+	g_return_if_fail(action_data != NULL);
+
+	action_data->enabled = enabled;
+}
+
+void
+gaim_pounce_action_set_attribute(GaimPounce *pounce, const char *action,
+								 const char *attr, const char *value)
+{
+	GaimPounceActionData *action_data;
+
+	g_return_if_fail(pounce != NULL);
+	g_return_if_fail(action != NULL);
+	g_return_if_fail(attr   != NULL);
+
+	action_data = find_action_data(pounce, action);
+
+	g_return_if_fail(action_data != NULL);
+
+	if (value == NULL)
+		g_hash_table_remove(action_data->atts, attr);
+	else
+		g_hash_table_insert(action_data->atts, g_strdup(attr),
+							g_strdup(value));
+}
+
+void
 gaim_pounce_set_data(GaimPounce *pounce, void *data)
 {
 	g_return_if_fail(pounce != NULL);
@@ -129,6 +235,46 @@
 	return pounce->pouncee;
 }
 
+gboolean
+gaim_pounce_get_save(const GaimPounce *pounce)
+{
+	g_return_val_if_fail(pounce != NULL, FALSE);
+
+	return pounce->save;
+}
+
+gboolean
+gaim_pounce_action_is_enabled(const GaimPounce *pounce, const char *action)
+{
+	GaimPounceActionData *action_data;
+
+	g_return_val_if_fail(pounce != NULL, FALSE);
+	g_return_val_if_fail(action != NULL, FALSE);
+
+	action_data = find_action_data(pounce, action);
+
+	g_return_val_if_fail(action_data != NULL, FALSE);
+
+	return action_data->enabled;
+}
+
+const char *
+gaim_pounce_action_get_attribute(const GaimPounce *pounce,
+								 const char *action, const char *attr)
+{
+	GaimPounceActionData *action_data;
+
+	g_return_val_if_fail(pounce != NULL, NULL);
+	g_return_val_if_fail(action != NULL, NULL);
+	g_return_val_if_fail(attr   != NULL, NULL);
+
+	action_data = find_action_data(pounce, action);
+
+	g_return_val_if_fail(action_data != NULL, NULL);
+
+	return g_hash_table_lookup(action_data->atts, attr);
+}
+
 void *
 gaim_pounce_get_data(const GaimPounce *pounce)
 {
@@ -142,21 +288,26 @@
 					GaimPounceEvent events)
 {
 	GaimPounce *pounce;
-	GList *l;
+	GList *l, *l_next;
 
 	g_return_if_fail(pouncer != NULL);
 	g_return_if_fail(pouncee != NULL);
 	g_return_if_fail(events  != GAIM_POUNCE_NONE);
 
-	for (l = gaim_get_pounces(); l != NULL; l = l->next) {
+	for (l = gaim_get_pounces(); l != NULL; l = l_next) {
 		pounce = (GaimPounce *)l->data;
+		l_next = l->next;
 
 		if ((gaim_pounce_get_events(pounce) & events) &&
 			(gaim_pounce_get_pouncer(pounce) == pouncer) &&
 			!strcmp(gaim_pounce_get_pouncee(pounce), pouncee)) {
 
-			if (pounce->callback != NULL)
+			if (pounce->callback != NULL) {
 				pounce->callback(pounce, events, gaim_pounce_get_data(pounce));
+
+				if (!gaim_pounce_get_save(pounce))
+					gaim_pounce_destroy(pounce);
+			}
 		}
 	}
 }
--- a/src/pounce.h	Sat Jun 14 11:14:26 2003 +0000
+++ b/src/pounce.h	Sat Jun 14 11:14:49 2003 +0000
@@ -1,10 +1,10 @@
 /**
- * @file pounce.h Buddy pounce API
+ * @file pounce.h Buddy Pounce API
  * @ingroup core
  *
  * gaim
  *
- * Copyright (C) 2003, Christian Hammond <chipx86@gnupdate.org>
+ * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.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
@@ -55,20 +55,27 @@
  */
 struct _GaimPounce
 {
+	char *ui_type;                /**< The type of UI.            */
+
 	GaimPounceEvent events;       /**< The event(s) to pounce on. */
-	GaimAccount *pouncer; /**< The user who is pouncing.  */
+	GaimAccount *pouncer;         /**< The user who is pouncing.  */
 
 	char *pouncee;                /**< The buddy to pounce on.    */
 
-	GaimPounceCb callback;      /**< The callback function to call when the
-	                                   event is triggered. */
-	void (*free)(void *data);     /**< The data free function. */
-	void *data;                   /**< Pounce-specific data. */
+	GHashTable *actions;          /**< The registered actions.    */
+
+	gboolean save;                /**< Whether or not the pounce should
+	                                   be saved after activation. */
+	GaimPounceCb callback;        /**< The callback function to call when the
+	                                   event is triggered.        */
+	void (*free)(void *data);     /**< The data free function.    */
+	void *data;                   /**< Pounce-specific data.      */
 };
 
 /**
  * Creates a new buddy pounce.
  *
+ * @param ui_type The type of UI the pounce is for.
  * @param pouncer The account that will pounce.
  * @param pouncee The buddy to pounce on.
  * @param event   The event(s) to pounce on.
@@ -78,7 +85,8 @@
  *
  * @return The new buddy pounce structure.
  */
-GaimPounce *gaim_pounce_new(GaimAccount *pouncer, const char *pouncee,
+GaimPounce *gaim_pounce_new(const char *ui_type,
+							GaimAccount *pouncer, const char *pouncee,
 							GaimPounceEvent event, GaimPounceCb cb,
 							void *data, void (*free)(void *));
 
@@ -114,12 +122,43 @@
 void gaim_pounce_set_pouncee(GaimPounce *pounce, const char *buddy);
 
 /**
- * Sets the callback function to call when the pounce event is triggered.
+ * Sets whether or not the pounce should be saved after execution.
+ *
+ * @param pounce The buddy pounce.
+ * @param save   @c TRUE if the pounce should be saved, or @c FALSE otherwise.
+ */
+void gaim_pounce_set_save(GaimPounce *pounce, gboolean save);
+
+/**
+ * Registers an action type for the pounce.
  *
  * @param pounce The buddy pounce.
- * @param cb     The callback function.
+ * @param name   The action name.
+ */
+void gaim_pounce_action_register(GaimPounce *pounce, const char *name);
+
+/**
+ * Enables or disables an action for a pounce.
+ *
+ * @param pounce  The buddy pounce.
+ * @param action  The name of the action.
+ * @param enabled The enabled state.
  */
-void gaim_pounce_set_callback(GaimPounce *pounce, GaimPounceCb cb);
+void gaim_pounce_action_set_enabled(GaimPounce *pounce, const char *action,
+									gboolean enabled);
+
+/**
+ * Sets a value for an attribute in an action.
+ *
+ * If @a value is @c NULL, the value will be unset.
+ *
+ * @param pounce The buddy pounce.
+ * @param action The action name.
+ * @param attr   The attribute name.
+ * @param value  The value.
+ */
+void gaim_pounce_action_set_attribute(GaimPounce *pounce, const char *action,
+									  const char *attr, const char *value);
 
 /**
  * Sets the pounce-specific data.
@@ -157,6 +196,40 @@
 const char *gaim_pounce_get_pouncee(const GaimPounce *pounce);
 
 /**
+ * Returns whether or not the pounce should save after execution.
+ *
+ * @param pounce The buddy pounce.
+ *
+ * @return @c TRUE if the pounce should be saved after execution, or
+ *         @c FALSE otherwise.
+ */
+gboolean gaim_pounce_get_save(const GaimPounce *pounce);
+
+/**
+ * Returns whether or not an action is enabled.
+ *
+ * @param pounce The buddy pounce.
+ * @param action The action name.
+ *
+ * @return @c TRUE if the action is enabled, or @c FALSE otherwise.
+ */
+gboolean gaim_pounce_action_is_enabled(const GaimPounce *pounce,
+									   const char *action);
+
+/**
+ * Returns the value for an attribute in an action.
+ *
+ * @param pounce The buddy pounce.
+ * @param action The action name.
+ * @param attr   The attribute name.
+ *
+ * @return The attribute value, if it exists, or @c NULL.
+ */
+const char *gaim_pounce_action_get_attribute(const GaimPounce *pounce,
+											 const char *action,
+											 const char *attr);
+
+/**
  * Returns the pounce-specific data.
  *
  * @param pounce The buddy pounce.