soc.2009.privacy_rewrite: 0c94a9d9: Now that we are handling more than allow...
sulabh at soc.pidgin.im
sulabh at soc.pidgin.im
Thu Jul 23 10:40:42 EDT 2009
-----------------------------------------------------------------
Revision: 0c94a9d9bfbd40f66730d454316439bd63e0c755
Ancestor: fe959a66c3384eecf2a7cb3904cdba7033b23ab4
Author: sulabh at soc.pidgin.im
Date: 2009-07-23T12:23:39
Branch: im.pidgin.soc.2009.privacy_rewrite
URL: http://d.pidgin.im/viewmtn/revision/info/0c94a9d9bfbd40f66730d454316439bd63e0c755
Modified files:
libpurple/privacy.c libpurple/protocols/yahoo/libyahoo.c
libpurple/protocols/yahoo/libyahoojp.c
libpurple/protocols/yahoo/libymsg.c
libpurple/protocols/yahoo/libymsg.h libpurple/prpl.h
libpurple/server.c libpurple/server.h
ChangeLog:
Now that we are handling more than allow and deny list, simplify/change the API to be able to manage server side functions for all the lists.
Also change yahoo! prpl accordingly
-------------- next part --------------
============================================================
--- libpurple/privacy.c 3bb73baddcf70694875bd611f6a1dc43c00daa15
+++ libpurple/privacy.c b902a489ac9b9aeda01b07b2897f0b57a4124b36
@@ -47,7 +47,7 @@ purple_privacy_permit_add(PurpleAccount
purple_privacy_update_contact(account, name, local_only, TRUE, TRUE);
if (!local_only && purple_account_is_connected(account))
- serv_add_permit(purple_account_get_connection(account), name);
+ serv_privacy_list_add(purple_account_get_connection(account), PURPLE_PRIVACY_ALLOW_LIST, name);
if (privacy_ops != NULL && privacy_ops->permit_added != NULL)
privacy_ops->permit_added(account, name);
@@ -100,7 +100,7 @@ purple_privacy_permit_remove(PurpleAccou
/* privacy laters: we have freed the buddy, check if some function in following statements don't require any data that we freed */
if (!local_only && purple_account_is_connected(account))
- serv_rem_permit(purple_account_get_connection(account), name);
+ serv_privacy_list_remove(purple_account_get_connection(account), PURPLE_PRIVACY_ALLOW_LIST, name);
if (privacy_ops != NULL && privacy_ops->permit_removed != NULL)
privacy_ops->permit_removed(account, name);
@@ -130,7 +130,7 @@ purple_privacy_deny_add(PurpleAccount *a
purple_privacy_update_contact(account, name, local_only, TRUE, TRUE);
if (!local_only && purple_account_is_connected(account))
- serv_add_deny(purple_account_get_connection(account), name);
+ serv_privacy_list_add(purple_account_get_connection(account), PURPLE_PRIVACY_BLOCK_BOTH_LIST, name);
if (privacy_ops != NULL && privacy_ops->deny_added != NULL)
privacy_ops->deny_added(account, name);
@@ -184,7 +184,7 @@ purple_privacy_deny_remove(PurpleAccount
/* privacy laters: we have freed the buddy, check if some function in following statements don't require any data that we freed */
if (!local_only && purple_account_is_connected(account))
- serv_rem_deny(purple_account_get_connection(account), name);
+ serv_privacy_list_remove(purple_account_get_connection(account), PURPLE_PRIVACY_BLOCK_BOTH_LIST, name);
if (privacy_ops != NULL && privacy_ops->deny_removed != NULL)
privacy_ops->deny_removed(account, name);
============================================================
--- libpurple/protocols/yahoo/libyahoo.c 7fd6f0efe49d91771c7018051a9445a35cdcfc8b
+++ libpurple/protocols/yahoo/libyahoo.c 7d5eb47090b8ab6796f627e19547962f2037b2d7
@@ -219,10 +219,8 @@ static PurplePluginProtocolInfo prpl_inf
NULL, /* add_buddies */
yahoo_remove_buddy,
NULL, /* remove_buddies */
- NULL, /* add_permit */
- yahoo_add_deny,
- NULL, /* rem_permit */
- yahoo_rem_deny,
+ yahoo_privacy_list_add, /* add to privacy lists */
+ yahoo_privacy_list_remove, /* remove from privacy lists */
yahoo_set_permit_deny,
yahoo_c_join,
NULL, /* reject chat invite */
============================================================
--- libpurple/protocols/yahoo/libyahoojp.c 1f179cfb524cb18e66273aca1fdd80fd636ba2c3
+++ libpurple/protocols/yahoo/libyahoojp.c ca2c2228364334d3af86160259d18f6d600c06a0
@@ -115,10 +115,8 @@ static PurplePluginProtocolInfo prpl_inf
NULL, /* add_buddies */
yahoo_remove_buddy,
NULL, /* remove_buddies */
- NULL, /* add_permit */
- yahoo_add_deny,
- NULL, /* rem_permit */
- yahoo_rem_deny,
+ yahoo_privacy_list_add, /* add to privacy lists */
+ yahoo_privacy_list_remove, /* remove from privacy lists */
yahoo_set_permit_deny,
yahoo_c_join,
NULL, /* reject chat invite */
============================================================
--- libpurple/protocols/yahoo/libymsg.c 2c4ebd8f9d237b79aa50e7093ff2d02f1195cd1c
+++ libpurple/protocols/yahoo/libymsg.c b6d144f84bb2f6fde934b087c0acb3342e056150
@@ -1963,7 +1963,7 @@ static void ignore_buddy(PurpleBuddy *bu
purple_account_remove_buddy(account, buddy, group);
purple_blist_remove_buddy(buddy);
- serv_add_deny(purple_account_get_connection(account), name);
+ serv_privacy_list_add(purple_account_get_connection(account), PURPLE_PRIVACY_BLOCK_BOTH_LIST, name);
g_free(name);
}
@@ -4725,7 +4725,7 @@ void yahoo_remove_buddy(PurpleConnection
g_free(cg);
}
-void yahoo_add_deny(PurpleConnection *gc, const char *who) {
+static void yahoo_add_deny(PurpleConnection *gc, const char *who) {
struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data;
struct yahoo_packet *pkt;
@@ -4741,7 +4741,7 @@ void yahoo_add_deny(PurpleConnection *gc
yahoo_packet_send_and_free(pkt, yd);
}
-void yahoo_rem_deny(PurpleConnection *gc, const char *who) {
+static void yahoo_rem_deny(PurpleConnection *gc, const char *who) {
struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data;
struct yahoo_packet *pkt;
@@ -4756,6 +4756,62 @@ void yahoo_rem_deny(PurpleConnection *gc
yahoo_packet_send_and_free(pkt, yd);
}
+void yahoo_privacy_list_add(PurpleConnection *gc, PurplePrivacyListType list_type, const char *who)
+{
+ struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data;
+
+ if (!yd->logged_in)
+ return;
+
+ if (!who || who[0] == '\0')
+ return;
+
+ switch(list_type)
+ {
+ case PURPLE_PRIVACY_ALLOW_LIST:
+ case PURPLE_PRIVACY_BLOCK_MESSAGE_LIST:
+ case PURPLE_PRIVACY_BUDDY_LIST:
+ /* either not supported or not the right place to edit the list */
+ break;
+ case PURPLE_PRIVACY_BLOCK_BOTH_LIST:
+ yahoo_add_deny(gc, who);
+ break;
+ case PURPLE_PRIVACY_VISIBLE_LIST:
+ case PURPLE_PRIVACY_INVISIBLE_LIST:
+ /* Privacy laters */
+ break;
+ }
+ return;
+}
+
+void yahoo_privacy_list_remove(PurpleConnection *gc, PurplePrivacyListType list_type, const char *who)
+{
+ struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data;
+
+ if (!yd->logged_in)
+ return;
+
+ if (!who || who[0] == '\0')
+ return;
+
+ switch(list_type)
+ {
+ case PURPLE_PRIVACY_ALLOW_LIST:
+ case PURPLE_PRIVACY_BLOCK_MESSAGE_LIST:
+ case PURPLE_PRIVACY_BUDDY_LIST:
+ /* either not supported or not the right place to edit the list */
+ break;
+ case PURPLE_PRIVACY_BLOCK_BOTH_LIST:
+ yahoo_rem_deny(gc, who);
+ break;
+ case PURPLE_PRIVACY_VISIBLE_LIST:
+ case PURPLE_PRIVACY_INVISIBLE_LIST:
+ /* Privacy laters */
+ break;
+ }
+ return;
+}
+
void yahoo_set_permit_deny(PurpleConnection *gc)
{
PurpleAccount *account;
============================================================
--- libpurple/protocols/yahoo/libymsg.h 571540c0f32899c58e33bb64bf6bbc0ce1872f64
+++ libpurple/protocols/yahoo/libymsg.h 92bfed9fe4c186b0d0dfaf728b3f499545764424
@@ -27,6 +27,7 @@
#include "circbuffer.h"
#include "cmds.h"
+#include "privacy.h"
#include "prpl.h"
#define YAHOO_PAGER_HOST "scsa.msg.yahoo.com"
@@ -310,8 +311,8 @@ void yahoo_remove_buddy(PurpleConnection
void yahoo_set_idle(PurpleConnection *gc, int idle);
void yahoo_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *g);
void yahoo_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group);
-void yahoo_add_deny(PurpleConnection *gc, const char *who);
-void yahoo_rem_deny(PurpleConnection *gc, const char *who);
+void yahoo_privacy_list_add(PurpleConnection *gc, PurplePrivacyListType list_type, const char *who);
+void yahoo_privacy_list_remove(PurpleConnection *gc, PurplePrivacyListType list_type, const char *who);
void yahoo_set_permit_deny(PurpleConnection *gc);
void yahoo_keepalive(PurpleConnection *gc);
void yahoo_change_buddys_group(PurpleConnection *gc, const char *who, const char *old_group, const char *new_group);
============================================================
--- libpurple/prpl.h 0a8c668f8cec8a3963e25a19f6ffadc3eabcfd83
+++ libpurple/prpl.h 3a11c5a9da26c3c23f56353dd0f6d6cbcf62d1f8
@@ -67,6 +67,7 @@ typedef struct _PurpleBuddyIconSpec Purp
#include "imgstore.h"
#include "media.h"
#include "notify.h"
+#include "privacy.h"
#include "proxy.h"
#include "plugin.h"
#include "roomlist.h"
@@ -309,10 +310,8 @@ struct _PurplePluginProtocolInfo
void (*add_buddies)(PurpleConnection *, GList *buddies, GList *groups);
void (*remove_buddy)(PurpleConnection *, PurpleBuddy *buddy, PurpleGroup *group);
void (*remove_buddies)(PurpleConnection *, GList *buddies, GList *groups);
- void (*add_permit)(PurpleConnection *, const char *name);
- void (*add_deny)(PurpleConnection *, const char *name);
- void (*rem_permit)(PurpleConnection *, const char *name);
- void (*rem_deny)(PurpleConnection *, const char *name);
+ void (*privacy_list_add)(PurpleConnection *, PurplePrivacyListType list_type, const char *name);
+ void (*privacy_list_remove)(PurpleConnection *, PurplePrivacyListType list_type, const char *name);
void (*set_permit_deny)(PurpleConnection *);
void (*join_chat)(PurpleConnection *, GHashTable *components);
void (*reject_chat)(PurpleConnection *, GHashTable *components);
============================================================
--- libpurple/server.c 8730c7801e191207259746e59cbe9f4618e20f6b
+++ libpurple/server.c c7a028a6f930d1a92a6f714fcf41c30cfb7ce73f
@@ -376,7 +376,7 @@ void serv_move_buddy(PurpleBuddy *b, Pur
}
}
-void serv_add_permit(PurpleConnection *gc, const char *name)
+void serv_privacy_list_add(PurpleConnection *gc, PurplePrivacyListType list_type, const char *name)
{
PurplePlugin *prpl = NULL;
PurplePluginProtocolInfo *prpl_info = NULL;
@@ -387,11 +387,11 @@ void serv_add_permit(PurpleConnection *g
if(prpl)
prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
- if(prpl_info && prpl_info->add_permit)
- prpl_info->add_permit(gc, name);
+ if(prpl_info && prpl_info->privacy_list_add)
+ prpl_info->privacy_list_add(gc, list_type, name);
}
-void serv_add_deny(PurpleConnection *gc, const char *name)
+void serv_privacy_list_remove(PurpleConnection *gc, PurplePrivacyListType list_type, const char *name)
{
PurplePlugin *prpl = NULL;
PurplePluginProtocolInfo *prpl_info = NULL;
@@ -402,40 +402,10 @@ void serv_add_deny(PurpleConnection *gc,
if(prpl)
prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
- if(prpl_info && prpl_info->add_deny)
- prpl_info->add_deny(gc, name);
+ if(prpl_info && prpl_info->privacy_list_remove)
+ prpl_info->privacy_list_remove(gc, list_type, name);
}
-void serv_rem_permit(PurpleConnection *gc, const char *name)
-{
- PurplePlugin *prpl = NULL;
- PurplePluginProtocolInfo *prpl_info = NULL;
-
- if(gc)
- prpl = purple_connection_get_prpl(gc);
-
- if(prpl)
- prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
-
- if(prpl_info && prpl_info->rem_permit)
- prpl_info->rem_permit(gc, name);
-}
-
-void serv_rem_deny(PurpleConnection *gc, const char *name)
-{
- PurplePlugin *prpl = NULL;
- PurplePluginProtocolInfo *prpl_info = NULL;
-
- if(gc)
- prpl = purple_connection_get_prpl(gc);
-
- if(prpl)
- prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
-
- if(prpl_info && prpl_info->rem_deny)
- prpl_info->rem_deny(gc, name);
-}
-
void serv_set_permit_deny(PurpleConnection *gc)
{
PurplePlugin *prpl = NULL;
============================================================
--- libpurple/server.h e60a052326d73dab6400ee495790e7a09f155494
+++ libpurple/server.h fa39833fc949b4c69cfc1a448577d9de6ebf9e65
@@ -28,6 +28,7 @@
#include "account.h"
#include "conversation.h"
+#include "privacy.h"
#include "prpl.h"
#ifdef __cplusplus
@@ -90,10 +91,8 @@ void serv_set_info(PurpleConnection *, c
void serv_get_info(PurpleConnection *, const char *);
void serv_set_info(PurpleConnection *, const char *);
-void serv_add_permit(PurpleConnection *, const char *);
-void serv_add_deny(PurpleConnection *, const char *);
-void serv_rem_permit(PurpleConnection *, const char *);
-void serv_rem_deny(PurpleConnection *, const char *);
+void serv_privacy_list_add(PurpleConnection *, PurplePrivacyListType list_type, const char *name);
+void serv_privacy_list_remove(PurpleConnection *, PurplePrivacyListType list_type, const char *name);
void serv_set_permit_deny(PurpleConnection *);
void serv_chat_invite(PurpleConnection *, int, const char *, const char *);
void serv_chat_leave(PurpleConnection *, int);
More information about the Commits
mailing list