changeset 23171:ff8ec3d58367

Modified patch from Stefan 'cockroach' Ott to add blocked-im-msg and chat-invite-blocked signals for blocked im messages and blocked chat invites. Closes #1062.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Fri, 23 May 2008 02:23:07 +0000
parents d7e66b6137f9
children 388e96b79206
files ChangeLog.API doc/conversation-signals.dox libpurple/conversation.c libpurple/server.c
diffstat 4 files changed, 62 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog.API	Thu May 22 21:44:53 2008 +0000
+++ b/ChangeLog.API	Fri May 23 02:23:07 2008 +0000
@@ -8,6 +8,8 @@
 		* PurpleSmiley and the Smiley API.
 		* purple_serv_got_join_chat_failed
 		* chat-join-failed signal (see conversation-signals.dox)
+		* chat-invite-blocked and blocked-im-msg signals (see
+		  converation-signals.dox) (Thanks to Stefan Ott)
 		* purple_blist_update_node_icon
 		* purple_buddy_icons_node_has_custom_icon
 		* purple_buddy_icons_node_find_custom_icon
--- a/doc/conversation-signals.dox	Thu May 22 21:44:53 2008 +0000
+++ b/doc/conversation-signals.dox	Fri May 23 02:23:07 2008 +0000
@@ -7,6 +7,7 @@
   @signal sent-im-msg
   @signal receiving-im-msg
   @signal received-im-msg
+  @signal blocked-im-msg
   @signal writing-chat-msg
   @signal wrote-chat-msg
   @signal sending-chat-msg
@@ -26,6 +27,7 @@
   @signal chat-inviting-user
   @signal chat-invited-user
   @signal chat-invited
+  @signal chat-invite-blocked
   @signal chat-joined
   @signal chat-join-failed
   @signal chat-left
@@ -132,6 +134,21 @@
   @param flags   The IM message flags.
  @endsignaldef
 
+ @signaldef blocked-im-msg
+  @signalproto
+void (*blocked_im_msg)(PurpleAccount *account, const char *sender,
+        const char *message, PurpleMessageFlags flags, time_t when);
+  @endsignalproto
+  @signaldesc
+   Emitted after an IM is blocked due to privacy settings.
+  @param account The account the message was received on.
+  @param sender  The username of the sender.
+  @param message The message that was blocked.
+  @param flags   The IM message flags.
+  @param when    The time the message was sent.
+  @since 2.5.0
+ @endsignaldef
+
  @signaldef writing-chat-msg
   @signalproto
 gboolean (*writing_chat_msg)(PurpleAccount *account, const char *who,
@@ -404,6 +421,21 @@
           default behavior will be maintained: the user will be prompted.
  @endsignaldef
 
+ @signaldef chat-invite-blocked
+  @signalproto
+void (*chat_invite_blocked)(PurpleAccount *account, const char *inviter,
+                   const char *name, const char *message, GHashTable *data);
+  @endsignalproto
+  @signaldesc
+   Emitted when an invitation to join a chat is blocked.
+  @param account  The account the invitation was sent to.
+  @param inviter  The name of the person sending the invitation.
+  @param name     The name of the chat invited to.
+  @param message  The invitation message sent.
+  @param data     Hashtable containing data about the invited chat.
+  @since 2.5.0
+ @endsignaldef
+
  @signaldef chat-joined
   @signalproto
 void (*chat_joined)(PurpleConversation *conv);
--- a/libpurple/conversation.c	Thu May 22 21:44:53 2008 +0000
+++ b/libpurple/conversation.c	Fri May 23 02:23:07 2008 +0000
@@ -2221,6 +2221,16 @@
 										PURPLE_SUBTYPE_CONVERSATION),
 						 purple_value_new(PURPLE_TYPE_UINT));
 
+	purple_signal_register(handle, "blocked-im-msg",
+						 purple_marshal_VOID__POINTER_POINTER_POINTER_UINT_UINT,
+						 NULL, 5,
+						 purple_value_new(PURPLE_TYPE_SUBTYPE,
+							 PURPLE_SUBTYPE_ACCOUNT),
+						 purple_value_new(PURPLE_TYPE_STRING),
+						 purple_value_new(PURPLE_TYPE_STRING),
+						 purple_value_new(PURPLE_TYPE_UINT),
+						 purple_value_new(PURPLE_TYPE_UINT));
+
 	purple_signal_register(handle, "writing-chat-msg",
 						 purple_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER_UINT,
 						 purple_value_new(PURPLE_TYPE_BOOLEAN), 5,
@@ -2376,6 +2386,16 @@
 						 purple_value_new(PURPLE_TYPE_STRING),
 						 purple_value_new(PURPLE_TYPE_POINTER));
 
+	purple_signal_register(handle, "chat-invite-blocked",
+						 purple_marshal_VOID__POINTER_POINTER_POINTER_POINTER_POINTER,
+						 NULL, 5,
+						 purple_value_new(PURPLE_TYPE_SUBTYPE,
+							 PURPLE_SUBTYPE_ACCOUNT),
+						 purple_value_new(PURPLE_TYPE_STRING),
+						 purple_value_new(PURPLE_TYPE_STRING),
+						 purple_value_new(PURPLE_TYPE_STRING),
+						 purple_value_new(PURPLE_TYPE_BOXED, "GHashTable *"));
+
 	purple_signal_register(handle, "chat-joined",
 						 purple_marshal_VOID__POINTER, NULL, 1,
 						 purple_value_new(PURPLE_TYPE_SUBTYPE,
--- a/libpurple/server.c	Thu May 22 21:44:53 2008 +0000
+++ b/libpurple/server.c	Fri May 23 02:23:07 2008 +0000
@@ -659,8 +659,11 @@
 
 	if (PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc))->set_permit_deny == NULL) {
 		/* protocol does not support privacy, handle it ourselves */
-		if (!purple_privacy_check(account, who))
+		if (!purple_privacy_check(account, who)) {
+			purple_signal_emit(purple_conversations_get_handle(), "blocked-im-msg",
+					account, who, msg, flags, (unsigned int)mtime);
 			return;
+		}
 	}
 
 	/*
@@ -879,8 +882,11 @@
 	account = purple_connection_get_account(gc);
 	if (PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc))->set_permit_deny == NULL) {
 		/* protocol does not support privacy, handle it ourselves */
-		if (!purple_privacy_check(account, who))
+		if (!purple_privacy_check(account, who)) {
+			purple_signal_emit(purple_conversations_get_handle(), "chat-invite-blocked",
+					account, who, name, message, data);
 			return;
+		}
 	}
 
 	plugin_return = GPOINTER_TO_INT(purple_signal_emit_return_1(