Exemplo n.º 1
0
static PurpleXmlNode *
pounce_to_xmlnode(PurplePounce *pounce)
{
	PurpleXmlNode *node, *child;
	PurpleAccount *pouncer;
	PurplePounceEvent events;
	PurplePounceOption options;

	pouncer = purple_pounce_get_pouncer(pounce);
	events  = purple_pounce_get_events(pounce);
	options = purple_pounce_get_options(pounce);

	node = purple_xmlnode_new("pounce");
	purple_xmlnode_set_attrib(node, "ui", pounce->ui_type);

	child = purple_xmlnode_new_child(node, "account");
	purple_xmlnode_set_attrib(child, "protocol", purple_account_get_protocol_id(pouncer));
	purple_xmlnode_insert_data(child,
			purple_normalize(pouncer, purple_account_get_username(pouncer)), -1);

	child = purple_xmlnode_new_child(node, "pouncee");
	purple_xmlnode_insert_data(child, purple_pounce_get_pouncee(pounce), -1);

	/* Write pounce options */
	child = purple_xmlnode_new_child(node, "options");
	if (options & PURPLE_POUNCE_OPTION_AWAY)
		add_option_to_xmlnode(child, "on-away");

	/* Write pounce events */
	child = purple_xmlnode_new_child(node, "events");
	if (events & PURPLE_POUNCE_SIGNON)
		add_event_to_xmlnode(child, "sign-on");
	if (events & PURPLE_POUNCE_SIGNOFF)
		add_event_to_xmlnode(child, "sign-off");
	if (events & PURPLE_POUNCE_AWAY)
		add_event_to_xmlnode(child, "away");
	if (events & PURPLE_POUNCE_AWAY_RETURN)
		add_event_to_xmlnode(child, "return-from-away");
	if (events & PURPLE_POUNCE_IDLE)
		add_event_to_xmlnode(child, "idle");
	if (events & PURPLE_POUNCE_IDLE_RETURN)
		add_event_to_xmlnode(child, "return-from-idle");
	if (events & PURPLE_POUNCE_TYPING)
		add_event_to_xmlnode(child, "start-typing");
	if (events & PURPLE_POUNCE_TYPED)
		add_event_to_xmlnode(child, "typed");
	if (events & PURPLE_POUNCE_TYPING_STOPPED)
		add_event_to_xmlnode(child, "stop-typing");
	if (events & PURPLE_POUNCE_MESSAGE_RECEIVED)
		add_event_to_xmlnode(child, "message-received");

	/* Write pounce actions */
	child = purple_xmlnode_new_child(node, "actions");
	g_hash_table_foreach(pounce->actions, action_parameter_list_to_xmlnode, child);

	if (purple_pounce_get_save(pounce))
		purple_xmlnode_new_child(node, "save");

	return node;
}
Exemplo n.º 2
0
PurplePounce *
purple_find_pounce(const PurpleAccount *pouncer, const char *pouncee,
				 PurplePounceEvent events)
{
	PurplePounce *pounce = NULL;
	GList *l;
	char *norm_pouncee;

	g_return_val_if_fail(pouncer != NULL, NULL);
	g_return_val_if_fail(pouncee != NULL, NULL);
	g_return_val_if_fail(events  != PURPLE_POUNCE_NONE, NULL);

	norm_pouncee = g_strdup(purple_normalize(pouncer, pouncee));

	for (l = purple_pounces_get_all(); l != NULL; l = l->next)
	{
		pounce = (PurplePounce *)l->data;

		if ((purple_pounce_get_events(pounce) & events) &&
			(purple_pounce_get_pouncer(pounce) == pouncer) &&
			!purple_utf8_strcasecmp(purple_normalize(pouncer, purple_pounce_get_pouncee(pounce)),
								  norm_pouncee))
		{
			break;
		}

		pounce = NULL;
	}

	g_free(norm_pouncee);

	return pounce;
}
Exemplo n.º 3
0
static void
add_pounce_to_treeview(GntTree *tree, PurplePounce *pounce)
{
	PurpleAccount *account;
	const char *pouncer;
	const char *pouncee;

	account = purple_pounce_get_pouncer(pounce);
	pouncer = purple_account_get_username(account);
	pouncee = purple_pounce_get_pouncee(pounce);
	gnt_tree_add_row_last(tree, pounce,
		gnt_tree_create_row(tree, pouncer, pouncee), NULL);
}
Exemplo n.º 4
0
void
purple_pounce_execute(const PurpleAccount *pouncer, const char *pouncee,
					PurplePounceEvent events)
{
	PurplePounce *pounce;
	PurplePounceHandler *handler;
	PurplePresence *presence;
	GList *l, *l_next;
	char *norm_pouncee;

	g_return_if_fail(pouncer != NULL);
	g_return_if_fail(pouncee != NULL);
	g_return_if_fail(events  != PURPLE_POUNCE_NONE);

	norm_pouncee = g_strdup(purple_normalize(pouncer, pouncee));

	for (l = purple_pounces_get_all(); l != NULL; l = l_next)
	{
		pounce = (PurplePounce *)l->data;
		l_next = l->next;

		presence = purple_account_get_presence(pouncer);

		if ((purple_pounce_get_events(pounce) & events) &&
			(purple_pounce_get_pouncer(pounce) == pouncer) &&
			!purple_utf8_strcasecmp(purple_normalize(pouncer, purple_pounce_get_pouncee(pounce)),
								  norm_pouncee) &&
			(pounce->options == PURPLE_POUNCE_OPTION_NONE ||
			 (pounce->options & PURPLE_POUNCE_OPTION_AWAY &&
			  !purple_presence_is_available(presence))))
		{
			handler = g_hash_table_lookup(pounce_handlers, pounce->ui_type);

			if (handler != NULL && handler->cb != NULL)
			{
				handler->cb(pounce, events, purple_pounce_get_data(pounce));

				if (!purple_pounce_get_save(pounce))
					purple_pounce_destroy(pounce);
			}
		}
	}

	g_free(norm_pouncee);
}
Exemplo n.º 5
0
void
purple_pounce_destroy_all_by_account(PurpleAccount *account)
{
	PurpleAccount *pouncer;
	PurplePounce *pounce;
	GList *l, *l_next;

	g_return_if_fail(account != NULL);

	for (l = purple_pounces_get_all(); l != NULL; l = l_next)
	{
		pounce = (PurplePounce *)l->data;
		l_next = l->next;

		pouncer = purple_pounce_get_pouncer(pounce);
		if (pouncer == account)
			purple_pounce_destroy(pounce);
	}
}
Exemplo n.º 6
0
void
purple_pounce_destroy_all_by_buddy(PurpleBuddy *buddy)
{
	const char *pouncee, *bname;
	PurpleAccount *pouncer, *bacct;
	PurplePounce *pounce;
	GList *l, *l_next;

	g_return_if_fail(buddy != NULL);

	bacct = purple_buddy_get_account(buddy);
	bname = purple_buddy_get_name(buddy);

	for (l = purple_pounces_get_all(); l != NULL; l = l_next) {
		pounce = (PurplePounce *)l->data;
		l_next = l->next;

		pouncer = purple_pounce_get_pouncer(pounce);
		pouncee = purple_pounce_get_pouncee(pounce);

		if ( (pouncer == bacct) && (strcmp(pouncee, bname) == 0) )
			purple_pounce_destroy(pounce);
	}
}
Exemplo n.º 7
0
static void
pounces_manager_delete_cb(GntButton *button, gpointer user_data)
{
	PouncesManager *dialog = user_data;
	PurplePounce *pounce;
	PurpleAccount *account;
	const char *pouncer, *pouncee;
	char *buf;

	pounce = (PurplePounce *)gnt_tree_get_selection_data(GNT_TREE(dialog->tree));
	if (pounce == NULL)
		return;

	account = purple_pounce_get_pouncer(pounce);
	pouncer = purple_account_get_username(account);
	pouncee = purple_pounce_get_pouncee(pounce);
	buf = g_strdup_printf(_("Are you sure you want to delete the pounce on %s for %s?"), pouncee, pouncer);
	purple_request_action(pounce, NULL, buf, NULL, 0,
						account, pouncee, NULL,
						pounce, 2,
						_("Delete"), pounces_manager_delete_confirm_cb,
						_("Cancel"), NULL);
	g_free(buf);
}
Exemplo n.º 8
0
static void
pounce_cb(PurplePounce *pounce, PurplePounceEvent events, void *data)
{
	PurpleConversation *conv;
	PurpleAccount *account;
	PurpleBuddy *buddy;
	const char *pouncee;
	const char *alias;

	pouncee = purple_pounce_get_pouncee(pounce);
	account = purple_pounce_get_pouncer(pounce);

	buddy = purple_find_buddy(account, pouncee);
	if (buddy != NULL)
	{
		alias = purple_buddy_get_alias(buddy);
		if (alias == NULL)
			alias = pouncee;
	}
	else
		alias = pouncee;

	if (purple_pounce_action_is_enabled(pounce, "open-window"))
	{
		if (!purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, pouncee, account))
			purple_conversation_new(PURPLE_CONV_TYPE_IM, account, pouncee);
	}

	if (purple_pounce_action_is_enabled(pounce, "popup-notify"))
	{
		char *tmp = NULL;
		const char *name_shown;
		const char *reason;
		struct {
			PurplePounceEvent event;
			const char *format;
		} messages[] = {
			{PURPLE_POUNCE_TYPING, _("%s has started typing to you (%s)")},
			{PURPLE_POUNCE_TYPED, _("%s has paused while typing to you (%s)")},
			{PURPLE_POUNCE_SIGNON, _("%s has signed on (%s)")},
			{PURPLE_POUNCE_IDLE_RETURN, _("%s has returned from being idle (%s)")},
			{PURPLE_POUNCE_AWAY_RETURN, _("%s has returned from being away (%s)")},
			{PURPLE_POUNCE_TYPING_STOPPED, _("%s has stopped typing to you (%s)")},
			{PURPLE_POUNCE_SIGNOFF, _("%s has signed off (%s)")},
			{PURPLE_POUNCE_IDLE, _("%s has become idle (%s)")},
			{PURPLE_POUNCE_AWAY, _("%s has gone away. (%s)")},
			{PURPLE_POUNCE_MESSAGE_RECEIVED, _("%s has sent you a message. (%s)")},
			{0, NULL}
		};
		int i;
		reason = purple_pounce_action_get_attribute(pounce, "popup-notify",
				"reason");

		/*
		 * Here we place the protocol name in the pounce dialog to lessen
		 * confusion about what protocol a pounce is for.
		 */
		for (i = 0; messages[i].format != NULL; i++) {
			if (messages[i].event & events) {
				tmp = g_strdup_printf(messages[i].format, alias,
						purple_account_get_protocol_name(account));
				break;
			}
		}
		if (tmp == NULL)
			tmp = g_strdup(_("Unknown pounce event. Please report this!"));

		/*
		 * Ok here is where I change the second argument, title, from
		 * NULL to the account alias if we have it or the account
		 * name if that's all we have
		 */
		if ((name_shown = purple_account_get_alias(account)) == NULL)
			name_shown = purple_account_get_username(account);

		if (reason == NULL)
		{
			purple_notify_info(NULL, name_shown, tmp, purple_date_format_full(NULL));
		}
		else
		{
			char *tmp2 = g_strdup_printf("%s\n\n%s", reason, purple_date_format_full(NULL));
			purple_notify_info(NULL, name_shown, tmp, tmp2);
			g_free(tmp2);
		}
		g_free(tmp);
	}

	if (purple_pounce_action_is_enabled(pounce, "send-message"))
	{
		const char *message;

		message = purple_pounce_action_get_attribute(pounce, "send-message",
												   "message");

		if (message != NULL)
		{
			conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, pouncee, account);

			if (conv == NULL)
				conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, pouncee);

			purple_conversation_write(conv, NULL, message,
									PURPLE_MESSAGE_SEND, time(NULL));

			serv_send_im(purple_account_get_connection(account), (char *)pouncee, (char *)message, 0);
		}
	}

	if (purple_pounce_action_is_enabled(pounce, "execute-command"))
	{
		const char *command;

		command = purple_pounce_action_get_attribute(pounce,
				"execute-command", "command");

		if (command != NULL)
		{
			char *localecmd = g_locale_from_utf8(command, -1, NULL,
					NULL, NULL);

			if (localecmd != NULL)
			{
				int pid = fork();

				if (pid == 0) {
					char *args[4];

					args[0] = "sh";
					args[1] = "-c";
					args[2] = (char *)localecmd;
					args[3] = NULL;

					execvp(args[0], args);

					_exit(0);
				}
				g_free(localecmd);
			}
		}
	}

	if (purple_pounce_action_is_enabled(pounce, "play-beep"))
	{
		beep();
	}
}
Exemplo n.º 9
0
void
finch_pounce_editor_show(PurpleAccount *account, const char *name,
							PurplePounce *cur_pounce)
{
	PurpleGntPounceDialog *dialog;
	GntWidget *window;
	GntWidget *bbox;
	GntWidget *hbox, *vbox;
	GntWidget *button;
	GntWidget *combo;
	GList *list;

	g_return_if_fail((cur_pounce != NULL) ||
	                 (account != NULL) ||
	                 (purple_accounts_get_all() != NULL));

	dialog = g_new0(PurpleGntPounceDialog, 1);

	if (cur_pounce != NULL) {
		dialog->pounce  = cur_pounce;
		dialog->account = purple_pounce_get_pouncer(cur_pounce);
	} else if (account != NULL) {
		dialog->pounce  = NULL;
		dialog->account = account;
	} else {
		GList *connections = purple_connections_get_all();
		PurpleConnection *gc;

		if (connections != NULL) {
			gc = (PurpleConnection *)connections->data;
			dialog->account = purple_connection_get_account(gc);
		} else
			dialog->account = purple_accounts_get_all()->data;

		dialog->pounce  = NULL;
	}

	/* Create the window. */
	dialog->window = window = gnt_vbox_new(FALSE);
	gnt_box_set_pad(GNT_BOX(window), 0);
	gnt_box_set_toplevel(GNT_BOX(window), TRUE);
	gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_LEFT);
	gnt_box_set_title(GNT_BOX(window),
						 (cur_pounce == NULL
						  ? _("New Buddy Pounce") : _("Edit Buddy Pounce")));

	g_signal_connect(G_OBJECT(window), "destroy",
					 G_CALLBACK(delete_win_cb), dialog);

	gnt_box_add_widget(GNT_BOX(window), gnt_label_new_with_format(_("Pounce on Whom"), GNT_TEXT_FLAG_BOLD));

	/* Account: */
	gnt_box_add_widget(GNT_BOX(window), gnt_label_new(_("Account:")));
	dialog->account_menu = combo = gnt_combo_box_new();
	list = purple_accounts_get_all();
	for (; list; list = list->next)
	{
		PurpleAccount *account;
		char *text;

		account = list->data;
		text = g_strdup_printf("%s (%s)",
				purple_account_get_username(account),
				purple_account_get_protocol_name(account));
		gnt_combo_box_add_data(GNT_COMBO_BOX(combo), account, text);
		g_free(text);
	}
	if (dialog->account)
		gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), dialog->account);

	gnt_box_add_widget(GNT_BOX(window), combo);

	/* Buddy: */
	hbox = gnt_hbox_new(FALSE);
	gnt_box_add_widget(GNT_BOX(hbox), gnt_label_new(_("Buddy name:")));

	dialog->buddy_entry = gnt_entry_new(NULL);
	gnt_box_add_widget(GNT_BOX(hbox), dialog->buddy_entry);

	setup_buddy_list_suggestion(GNT_ENTRY(dialog->buddy_entry), TRUE);

	gnt_box_add_widget(GNT_BOX(window), hbox);

	if (cur_pounce != NULL) {
		gnt_entry_set_text(GNT_ENTRY(dialog->buddy_entry),
						   purple_pounce_get_pouncee(cur_pounce));
	} else if (name != NULL) {
		gnt_entry_set_text(GNT_ENTRY(dialog->buddy_entry), name);
	}

	/* Create the event frame */
	gnt_box_add_widget(GNT_BOX(window), gnt_line_new(FALSE));
	gnt_box_add_widget(GNT_BOX(window), gnt_label_new_with_format(_("Pounce When Buddy..."), GNT_TEXT_FLAG_BOLD));

	dialog->signon = gnt_check_box_new(_("Signs on"));
	dialog->signoff = gnt_check_box_new(_("Signs off"));
	dialog->away = gnt_check_box_new(_("Goes away"));
	dialog->away_return = gnt_check_box_new(_("Returns from away"));
	dialog->idle = gnt_check_box_new(_("Becomes idle"));
	dialog->idle_return = gnt_check_box_new(_("Is no longer idle"));
	dialog->typing = gnt_check_box_new(_("Starts typing"));
	dialog->typed = gnt_check_box_new(_("Pauses while typing"));
	dialog->stop_typing = gnt_check_box_new(_("Stops typing"));
	dialog->message_recv = gnt_check_box_new(_("Sends a message"));

	hbox = gnt_hbox_new(TRUE);
	gnt_box_set_pad(GNT_BOX(hbox), 2);

	vbox = gnt_vbox_new(FALSE);
	gnt_box_set_pad(GNT_BOX(vbox), 0);
	gnt_box_add_widget(GNT_BOX(hbox), vbox);

	gnt_box_add_widget(GNT_BOX(vbox), dialog->signon);
	gnt_box_add_widget(GNT_BOX(vbox), dialog->away);
	gnt_box_add_widget(GNT_BOX(vbox), dialog->idle);
	gnt_box_add_widget(GNT_BOX(vbox), dialog->typing);
	gnt_box_add_widget(GNT_BOX(vbox), dialog->stop_typing);

	vbox = gnt_vbox_new(FALSE);
	gnt_box_set_pad(GNT_BOX(vbox), 0);
	gnt_box_add_widget(GNT_BOX(hbox), vbox);

	gnt_box_add_widget(GNT_BOX(vbox), dialog->signoff);
	gnt_box_add_widget(GNT_BOX(vbox), dialog->away_return);
	gnt_box_add_widget(GNT_BOX(vbox), dialog->idle_return);
	gnt_box_add_widget(GNT_BOX(vbox), dialog->typed);
	gnt_box_add_widget(GNT_BOX(vbox), dialog->message_recv);

	gnt_box_add_widget(GNT_BOX(window), hbox);

	/* Create the "Action" frame. */
	gnt_box_add_widget(GNT_BOX(window), gnt_line_new(FALSE));
	gnt_box_add_widget(GNT_BOX(window), gnt_label_new_with_format(_("Action"), GNT_TEXT_FLAG_BOLD));

	dialog->open_win = gnt_check_box_new(_("Open an IM window"));
	dialog->popup = gnt_check_box_new(_("Pop up a notification"));
	dialog->send_msg = gnt_check_box_new(_("Send a message"));
	dialog->exec_cmd = gnt_check_box_new(_("Execute a command"));
	dialog->play_sound = gnt_check_box_new(_("Play a sound"));

	dialog->send_msg_entry    = gnt_entry_new(NULL);
	dialog->exec_cmd_entry    = gnt_entry_new(NULL);
	dialog->popup_entry       = gnt_entry_new(NULL);
	dialog->exec_cmd_entry   = gnt_entry_new(NULL);

	hbox = gnt_hbox_new(FALSE);
	gnt_box_add_widget(GNT_BOX(hbox), dialog->open_win);
	gnt_box_add_widget(GNT_BOX(window), hbox);
	hbox = gnt_hbox_new(FALSE);
	gnt_box_add_widget(GNT_BOX(hbox), dialog->popup);
	gnt_box_add_widget(GNT_BOX(hbox), dialog->popup_entry);
	gnt_box_add_widget(GNT_BOX(window), hbox);
	hbox = gnt_hbox_new(FALSE);
	gnt_box_add_widget(GNT_BOX(hbox), dialog->send_msg);
	gnt_box_add_widget(GNT_BOX(hbox), dialog->send_msg_entry);
	gnt_box_add_widget(GNT_BOX(window), hbox);
	hbox = gnt_hbox_new(FALSE);
	gnt_box_add_widget(GNT_BOX(hbox), dialog->exec_cmd);
	gnt_box_add_widget(GNT_BOX(hbox), dialog->exec_cmd_entry);
	gnt_box_add_widget(GNT_BOX(window), hbox);
	hbox = gnt_hbox_new(FALSE);
	gnt_box_add_widget(GNT_BOX(hbox), dialog->play_sound);
	gnt_box_add_widget(GNT_BOX(window), hbox);

	gnt_box_add_widget(GNT_BOX(window), gnt_line_new(FALSE));
	gnt_box_add_widget(GNT_BOX(window), gnt_label_new_with_format(_("Options"), GNT_TEXT_FLAG_BOLD));
	dialog->on_away = gnt_check_box_new(_("Pounce only when my status is not Available"));
	gnt_box_add_widget(GNT_BOX(window), dialog->on_away);
	dialog->save_pounce = gnt_check_box_new(_("Recurring"));
	gnt_box_add_widget(GNT_BOX(window), dialog->save_pounce);


	gnt_box_add_widget(GNT_BOX(window), gnt_line_new(FALSE));
	/* Now the button box! */
	bbox = gnt_hbox_new(FALSE);

	/* Cancel button */
	button = gnt_button_new(_("Cancel"));
	gnt_box_add_widget(GNT_BOX(bbox), button);
	g_signal_connect(G_OBJECT(button), "activate",
					 G_CALLBACK(cancel_cb), dialog);

	/* Save button */
	dialog->save_button = button = gnt_button_new(_("Save"));
	gnt_box_add_widget(GNT_BOX(bbox), button);
	g_signal_connect(G_OBJECT(button), "activate",
					 G_CALLBACK(save_pounce_cb), dialog);

	gnt_box_add_widget(GNT_BOX(window), bbox);


	/* Set the values of stuff. */
	if (cur_pounce != NULL)
	{
		PurplePounceEvent events   = purple_pounce_get_events(cur_pounce);
		PurplePounceOption options = purple_pounce_get_options(cur_pounce);
		const char *value;

		/* Options */
		gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->on_away),
									(options & PURPLE_POUNCE_OPTION_AWAY));

		/* Events */
		gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->signon),
									(events & PURPLE_POUNCE_SIGNON));
		gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->signoff),
									(events & PURPLE_POUNCE_SIGNOFF));
		gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->away),
									(events & PURPLE_POUNCE_AWAY));
		gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->away_return),
									(events & PURPLE_POUNCE_AWAY_RETURN));
		gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->idle),
									(events & PURPLE_POUNCE_IDLE));
		gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->idle_return),
									(events & PURPLE_POUNCE_IDLE_RETURN));
		gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->typing),
									(events & PURPLE_POUNCE_TYPING));
		gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->typed),
									(events & PURPLE_POUNCE_TYPED));
		gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->stop_typing),
									(events & PURPLE_POUNCE_TYPING_STOPPED));
		gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->message_recv),
									(events & PURPLE_POUNCE_MESSAGE_RECEIVED));

		/* Actions */
		gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->open_win),
			purple_pounce_action_is_enabled(cur_pounce, "open-window"));
		gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->popup),
			purple_pounce_action_is_enabled(cur_pounce, "popup-notify"));
		gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->send_msg),
			purple_pounce_action_is_enabled(cur_pounce, "send-message"));
		gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->exec_cmd),
			purple_pounce_action_is_enabled(cur_pounce, "execute-command"));
		gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->play_sound),
			purple_pounce_action_is_enabled(cur_pounce, "play-beep"));

		gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->save_pounce),
			purple_pounce_get_save(cur_pounce));

		if ((value = purple_pounce_action_get_attribute(cur_pounce,
		                                              "send-message",
		                                              "message")) != NULL)
		{
			gnt_entry_set_text(GNT_ENTRY(dialog->send_msg_entry), value);
		}

		if ((value = purple_pounce_action_get_attribute(cur_pounce,
		                                              "popup-notify",
		                                              "reason")) != NULL)
		{
			gnt_entry_set_text(GNT_ENTRY(dialog->popup_entry), value);
		}

		if ((value = purple_pounce_action_get_attribute(cur_pounce,
		                                              "execute-command",
		                                              "command")) != NULL)
		{
			gnt_entry_set_text(GNT_ENTRY(dialog->exec_cmd_entry), value);
		}
	}
	else
	{
		PurpleBuddy *buddy = NULL;

		if (name != NULL)
			buddy = purple_find_buddy(account, name);

		/* Set some defaults */
		if (buddy == NULL) {
			gnt_check_box_set_checked(
				GNT_CHECK_BOX(dialog->signon), TRUE);
		} else {
			if (!PURPLE_BUDDY_IS_ONLINE(buddy)) {
				gnt_check_box_set_checked(
					GNT_CHECK_BOX(dialog->signon), TRUE);
			} else {
				gboolean default_set = FALSE;
				PurplePresence *presence = purple_buddy_get_presence(buddy);

				if (purple_presence_is_idle(presence))
				{
					gnt_check_box_set_checked(
						GNT_CHECK_BOX(dialog->idle_return), TRUE);

					default_set = TRUE;
				}

				if (!purple_presence_is_available(presence))
				{
					gnt_check_box_set_checked(
						GNT_CHECK_BOX(dialog->away_return), TRUE);

					default_set = TRUE;
				}

				if (!default_set)
				{
					gnt_check_box_set_checked(
						GNT_CHECK_BOX(dialog->signon), TRUE);
				}
			}
		}

		gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->open_win),
			purple_prefs_get_bool("/finch/pounces/default_actions/open-window"));
		gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->popup),
			purple_prefs_get_bool("/finch/pounces/default_actions/popup-notify"));
		gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->send_msg),
			purple_prefs_get_bool("/finch/pounces/default_actions/send-message"));
		gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->exec_cmd),
			purple_prefs_get_bool("/finch/pounces/default_actions/execute-command"));
		gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->play_sound),
			purple_prefs_get_bool("/finch/pounces/default_actions/play-beep"));
	}

	gnt_widget_show(window);
}