diff src/server.c @ 11064:e4459e8ccfb5

[gaim-migrate @ 13035] Patch #1208082 from Levi Bard (tak_tak) This patch modifies the chat-invited signal so plugins can programmatically accept or reject chat invitations. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Thu, 07 Jul 2005 02:47:49 +0000
parents 2b772e7094ef
children 90be432e8385
line wrap: on
line diff
--- a/src/server.c	Thu Jul 07 02:35:23 2005 +0000
+++ b/src/server.c	Thu Jul 07 02:47:49 2005 +0000
@@ -999,30 +999,40 @@
 	GaimAccount *account;
 	char buf2[BUF_LONG];
 	struct chat_invite_data *cid = g_new0(struct chat_invite_data, 1);
+	int plugin_return;
 
 	account = gaim_connection_get_account(gc);
 
-	gaim_signal_emit(gaim_conversations_get_handle(),
-					 "chat-invited", account, who, name, message, data);
-
-	if (message != NULL)
-	{
-		g_snprintf(buf2, sizeof(buf2),
-				   _("%s has invited %s to the chat room %s:\n%s"),
-				   who, gaim_account_get_username(account), name, message);
-	}
-	else
-		g_snprintf(buf2, sizeof(buf2),
-				   _("%s has invited %s to the chat room %s\n"),
-				   who, gaim_account_get_username(account), name);
+	plugin_return = GPOINTER_TO_INT(gaim_signal_emit_return_1(
+					gaim_conversations_get_handle(),
+					"chat-invited", account, who, name, message, data));
 
 	cid->gc = gc;
 	cid->components = data;
 
-	gaim_request_accept_cancel(gc, NULL, _("Accept chat invitation?"), buf2,
+	if (plugin_return == 0)
+	{
+		if (message != NULL)
+		{
+			g_snprintf(buf2, sizeof(buf2),
+				   _("%s has invited %s to the chat room %s:\n%s"),
+				   who, gaim_account_get_username(account), name, message);
+		}
+		else
+			g_snprintf(buf2, sizeof(buf2),
+				   _("%s has invited %s to the chat room %s\n"),
+				   who, gaim_account_get_username(account), name);
+
+
+		gaim_request_accept_cancel(gc, NULL, _("Accept chat invitation?"), buf2,
 							   GAIM_DEFAULT_ACTION_NONE, cid,
 							   G_CALLBACK(chat_invite_accept),
 							   G_CALLBACK(chat_invite_reject));
+	}
+	else if (plugin_return > 0)
+		chat_invite_accept(cid);
+	else
+		chat_invite_reject(cid);
 }
 
 GaimConversation *serv_got_joined_chat(GaimConnection *gc,