summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Komarov <ivan.komarov@pidgin.im>2010-06-28 20:02:12 +0000
committerIvan Komarov <ivan.komarov@pidgin.im>2010-06-28 20:02:12 +0000
commit6bb50fcebe9052b94bc8f327fe4c95f977d1bcfd (patch)
treed39d0ca1e1ae227a419dd61868e4d1bfdc34e6a0
parent18bc330198fcf63e977f6f7daff2a79024accc95 (diff)
downloadpidgin-6bb50fcebe9052b94bc8f327fe4c95f977d1bcfd.tar.gz
Added a way to add a user to the (In)Visible list via the context menu.
-rw-r--r--libpurple/protocols/oscar/Makefile.am3
-rw-r--r--libpurple/protocols/oscar/family_feedbag.c101
-rw-r--r--libpurple/protocols/oscar/oscar.c28
-rw-r--r--libpurple/protocols/oscar/oscar.h6
-rw-r--r--libpurple/protocols/oscar/visibility.c64
-rw-r--r--libpurple/protocols/oscar/visibility.h29
6 files changed, 123 insertions, 108 deletions
diff --git a/libpurple/protocols/oscar/Makefile.am b/libpurple/protocols/oscar/Makefile.am
index ee121ba5bc..7402ac8554 100644
--- a/libpurple/protocols/oscar/Makefile.am
+++ b/libpurple/protocols/oscar/Makefile.am
@@ -46,7 +46,8 @@ OSCARSOURCES = \
snactypes.h \
tlv.c \
userinfo.c \
- util.c
+ util.c \
+ visibility.c
AM_CFLAGS = $(st)
diff --git a/libpurple/protocols/oscar/family_feedbag.c b/libpurple/protocols/oscar/family_feedbag.c
index 22392e2fff..6b3ebea2c9 100644
--- a/libpurple/protocols/oscar/family_feedbag.c
+++ b/libpurple/protocols/oscar/family_feedbag.c
@@ -660,10 +660,8 @@ int aim_ssi_cleanlist(OscarData *od)
if (!cur->name) {
if (cur->type == AIM_SSI_TYPE_BUDDY)
aim_ssi_delbuddy(od, NULL, NULL);
- else if (cur->type == AIM_SSI_TYPE_PERMIT)
- aim_ssi_delpermit(od, NULL);
- else if (cur->type == AIM_SSI_TYPE_DENY)
- aim_ssi_deldeny(od, NULL);
+ else if (cur->type == AIM_SSI_TYPE_PERMIT || cur->type == AIM_SSI_TYPE_DENY || cur->type == AIM_SSI_TYPE_ICQDENY)
+ aim_ssi_del_from_private_list(od, NULL, cur->type);
} else if ((cur->type == AIM_SSI_TYPE_BUDDY) && ((cur->gid == 0x0000) || (!aim_ssi_itemlist_find(od->ssi.local, cur->gid, 0x0000)))) {
char *alias = aim_ssi_getalias(od->ssi.local, NULL, cur->name);
aim_ssi_addbuddy(od, cur->name, "orphans", NULL, alias, NULL, NULL, FALSE);
@@ -748,51 +746,31 @@ int aim_ssi_addbuddy(OscarData *od, const char *name, const char *group, GSList
return aim_ssi_sync(od);
}
-/**
- * Add a permit buddy to the list.
- *
- * @param od The oscar odion.
- * @param name The name of the item..
- * @return Return 0 if no errors, otherwise return the error number.
- */
-int aim_ssi_addpermit(OscarData *od, const char *name)
+int
+aim_ssi_add_to_private_list(OscarData *od, const char* name, guint16 list_type)
{
-
if (!od || !name || !od->ssi.received_data)
return -EINVAL;
- /* Make sure the master group exists */
if (aim_ssi_itemlist_find(od->ssi.local, 0x0000, 0x0000) == NULL)
- aim_ssi_itemlist_add(&od->ssi.local, NULL, 0x0000, 0x0000, AIM_SSI_TYPE_GROUP, NULL);
-
- /* Add that bad boy */
- aim_ssi_itemlist_add(&od->ssi.local, name, 0x0000, 0xFFFF, AIM_SSI_TYPE_PERMIT, NULL);
+ aim_ssi_itemlist_add(&od->ssi.local, NULL, 0x0000, 0x0000, list_type, NULL);
- /* Sync our local list with the server list */
+ aim_ssi_itemlist_add(&od->ssi.local, name, 0x0000, 0xFFFF, list_type, NULL);
return aim_ssi_sync(od);
}
-/**
- * Add a deny buddy to the list.
- *
- * @param od The oscar odion.
- * @param name The name of the item..
- * @return Return 0 if no errors, otherwise return the error number.
- */
-int aim_ssi_adddeny(OscarData *od, const char *name)
+int
+aim_ssi_del_from_private_list(OscarData* od, const char* name, guint16 list_type)
{
- guint16 deny_entry_type = aim_ssi_getdenyentrytype(od);
- if (!od || !name || !od->ssi.received_data)
- return -EINVAL;
+ struct aim_ssi_item *del;
- /* Make sure the master group exists */
- if (aim_ssi_itemlist_find(od->ssi.local, 0x0000, 0x0000) == NULL)
- aim_ssi_itemlist_add(&od->ssi.local, NULL, 0x0000, 0x0000, deny_entry_type, NULL);
+ if (!od)
+ return -EINVAL;
- /* Add that bad boy */
- aim_ssi_itemlist_add(&od->ssi.local, name, 0x0000, 0xFFFF, deny_entry_type, NULL);
+ if (!(del = aim_ssi_itemlist_finditem(od->ssi.local, NULL, name, list_type)))
+ return -EINVAL;
- /* Sync our local list with the server list */
+ aim_ssi_itemlist_del(&od->ssi.local, del);
return aim_ssi_sync(od);
}
@@ -860,57 +838,6 @@ int aim_ssi_delgroup(OscarData *od, const char *group)
}
/**
- * Deletes a permit buddy from the list.
- *
- * @param od The oscar odion.
- * @param name The name of the item, or NULL.
- * @return Return 0 if no errors, otherwise return the error number.
- */
-int aim_ssi_delpermit(OscarData *od, const char *name)
-{
- struct aim_ssi_item *del;
-
- if (!od)
- return -EINVAL;
-
- /* Find the item */
- if (!(del = aim_ssi_itemlist_finditem(od->ssi.local, NULL, name, AIM_SSI_TYPE_PERMIT)))
- return -EINVAL;
-
- /* Remove the item from the list */
- aim_ssi_itemlist_del(&od->ssi.local, del);
-
- /* Sync our local list with the server list */
- return aim_ssi_sync(od);
-}
-
-/**
- * Deletes a deny buddy from the list.
- *
- * @param od The oscar odion.
- * @param name The name of the item, or NULL.
- * @return Return 0 if no errors, otherwise return the error number.
- */
-int aim_ssi_deldeny(OscarData *od, const char *name)
-{
- guint16 deny_entry_type = aim_ssi_getdenyentrytype(od);
- struct aim_ssi_item *del;
-
- if (!od)
- return -EINVAL;
-
- /* Find the item */
- if (!(del = aim_ssi_itemlist_finditem(od->ssi.local, NULL, name, deny_entry_type)))
- return -EINVAL;
-
- /* Remove the item from the list */
- aim_ssi_itemlist_del(&od->ssi.local, del);
-
- /* Sync our local list with the server list */
- return aim_ssi_sync(od);
-}
-
-/**
* Move a buddy from one group to another group. This basically just deletes the
* buddy and re-adds it.
*
diff --git a/libpurple/protocols/oscar/oscar.c b/libpurple/protocols/oscar/oscar.c
index 74660283af..01601b8d97 100644
--- a/libpurple/protocols/oscar/oscar.c
+++ b/libpurple/protocols/oscar/oscar.c
@@ -46,6 +46,7 @@
#include "request.h"
#include "util.h"
#include "version.h"
+#include "visibility.h"
#include "oscarcommon.h"
#include "oscar.h"
@@ -5175,41 +5176,36 @@ void oscar_set_permit_deny(PurpleConnection *gc) {
PurpleAccount *account = purple_connection_get_account(gc);
OscarData *od = purple_connection_get_protocol_data(gc);
- if (od->ssi.received_data)
- /*
- * Conveniently there is a one-to-one mapping between the
- * values of libpurple's PurplePrivacyType and the values used
- * by the oscar protocol.
- */
- aim_ssi_setpermdeny(od, account->perm_deny);
+ /*
+ * Conveniently there is a one-to-one mapping between the
+ * values of libpurple's PurplePrivacyType and the values used
+ * by the oscar protocol.
+ */
+ aim_ssi_setpermdeny(od, account->perm_deny);
}
void oscar_add_permit(PurpleConnection *gc, const char *who) {
OscarData *od = purple_connection_get_protocol_data(gc);
purple_debug_info("oscar", "ssi: About to add a permit\n");
- if (od->ssi.received_data)
- aim_ssi_addpermit(od, who);
+ aim_ssi_add_to_private_list(od, who, AIM_SSI_TYPE_PERMIT);
}
void oscar_add_deny(PurpleConnection *gc, const char *who) {
OscarData *od = purple_connection_get_protocol_data(gc);
purple_debug_info("oscar", "ssi: About to add a deny\n");
- if (od->ssi.received_data)
- aim_ssi_adddeny(od, who);
+ aim_ssi_add_to_private_list(od, who, aim_ssi_getdenyentrytype(od));
}
void oscar_rem_permit(PurpleConnection *gc, const char *who) {
OscarData *od = purple_connection_get_protocol_data(gc);
purple_debug_info("oscar", "ssi: About to delete a permit\n");
- if (od->ssi.received_data)
- aim_ssi_delpermit(od, who);
+ aim_ssi_del_from_private_list(od, who, AIM_SSI_TYPE_PERMIT);
}
void oscar_rem_deny(PurpleConnection *gc, const char *who) {
OscarData *od = purple_connection_get_protocol_data(gc);
purple_debug_info("oscar", "ssi: About to delete a deny\n");
- if (od->ssi.received_data)
- aim_ssi_deldeny(od, who);
+ aim_ssi_del_from_private_list(od, who, aim_ssi_getdenyentrytype(od));
}
GList *
@@ -5541,7 +5537,6 @@ oscar_get_aim_info_cb(PurpleBlistNode *node, gpointer ignore)
static GList *
oscar_buddy_menu(PurpleBuddy *buddy) {
-
PurpleConnection *gc;
OscarData *od;
GList *menu;
@@ -5579,6 +5574,7 @@ oscar_buddy_menu(PurpleBuddy *buddy) {
PURPLE_CALLBACK(oscar_get_icqxstatusmsg),
NULL, NULL);
menu = g_list_prepend(menu, act);
+ menu = g_list_prepend(menu, create_visibility_menu_item(od, bname));
}
if (userinfo &&
diff --git a/libpurple/protocols/oscar/oscar.h b/libpurple/protocols/oscar/oscar.h
index 6fa90b7c85..adaec87dfb 100644
--- a/libpurple/protocols/oscar/oscar.h
+++ b/libpurple/protocols/oscar/oscar.h
@@ -1329,12 +1329,8 @@ gboolean aim_ssi_waitingforauth(struct aim_ssi_item *list, const char *gn, const
/* Client functions for changing SSI data */
int aim_ssi_addbuddy(OscarData *od, const char *name, const char *group, GSList *tlvlist, const char *alias, const char *comment, const char *smsnum, gboolean needauth);
-int aim_ssi_addpermit(OscarData *od, const char *name);
-int aim_ssi_adddeny(OscarData *od, const char *name);
int aim_ssi_delbuddy(OscarData *od, const char *name, const char *group);
int aim_ssi_delgroup(OscarData *od, const char *group);
-int aim_ssi_delpermit(OscarData *od, const char *name);
-int aim_ssi_deldeny(OscarData *od, const char *name);
int aim_ssi_movebuddy(OscarData *od, const char *oldgn, const char *newgn, const char *bn);
int aim_ssi_aliasbuddy(OscarData *od, const char *gn, const char *bn, const char *alias);
int aim_ssi_editcomment(OscarData *od, const char *gn, const char *bn, const char *alias);
@@ -1345,6 +1341,8 @@ int aim_ssi_setpermdeny(OscarData *od, guint8 permdeny);
int aim_ssi_setpresence(OscarData *od, guint32 presence);
int aim_ssi_seticon(OscarData *od, const guint8 *iconsum, guint8 iconsumlen);
int aim_ssi_delicon(OscarData *od);
+int aim_ssi_add_to_private_list(OscarData *od, const char* name, guint16 list_type);
+int aim_ssi_del_from_private_list(OscarData* od, const char* name, guint16 list_type);
guint16 aim_ssi_getdenyentrytype(OscarData* od);
diff --git a/libpurple/protocols/oscar/visibility.c b/libpurple/protocols/oscar/visibility.c
new file mode 100644
index 0000000000..64265ad8e9
--- /dev/null
+++ b/libpurple/protocols/oscar/visibility.c
@@ -0,0 +1,64 @@
+/*
+ * Purple's oscar protocol plugin
+ * This file is the legal property of its developers.
+ * Please see the AUTHORS file distributed alongside this file.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
+*/
+
+#include "visibility.h"
+
+struct visibility_cb_data
+{
+ guint16 list_type;
+ gboolean add_to_list;
+};
+
+static void
+visibility_cb(PurpleBlistNode *node, struct visibility_cb_data *data)
+{
+ PurpleBuddy *buddy = PURPLE_BUDDY(node);
+ const char* bname = purple_buddy_get_name(buddy);
+ OscarData *od = purple_account_get_connection(purple_buddy_get_account(buddy))->proto_data;
+
+ if (data->add_to_list) {
+ aim_ssi_add_to_private_list(od, bname, data->list_type);
+ } else {
+ aim_ssi_del_from_private_list(od, bname, data->list_type);
+ }
+
+ g_free(data);
+}
+
+PurpleMenuAction *
+create_visibility_menu_item(OscarData *od, const char *bname)
+{
+ PurpleAccount *account = purple_connection_get_account(od->gc);
+ gboolean invisible = purple_account_is_status_active(account, OSCAR_STATUS_ID_INVISIBLE);
+ guint16 list_type = invisible ? AIM_SSI_TYPE_PERMIT : AIM_SSI_TYPE_DENY;
+ gboolean on_list = aim_ssi_itemlist_finditem(od->ssi.local, NULL, bname, list_type) != NULL;
+ gchar *label;
+ struct visibility_cb_data *data;
+ PurpleMenuAction *result;
+
+ data = g_new0(struct visibility_cb_data, 1);
+ data->list_type = list_type;
+ data->add_to_list = !on_list;
+
+ label = g_strdup_printf("%s %s", on_list ? "Don't appear" : "Appear", invisible ? "online" : "offline");
+ result = purple_menu_action_new(label, PURPLE_CALLBACK(visibility_cb), data, NULL);
+ g_free(label);
+ return result;
+}
diff --git a/libpurple/protocols/oscar/visibility.h b/libpurple/protocols/oscar/visibility.h
new file mode 100644
index 0000000000..c3849ea2ae
--- /dev/null
+++ b/libpurple/protocols/oscar/visibility.h
@@ -0,0 +1,29 @@
+/*
+ * Purple's oscar protocol plugin
+ * This file is the legal property of its developers.
+ * Please see the AUTHORS file distributed alongside this file.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
+*/
+
+#ifndef _VISIBILITY_H_
+#define _VISIBILITY_H_
+
+#include "oscar.h"
+#include "util.h"
+
+PurpleMenuAction * create_visibility_menu_item(OscarData *od, const char *bname);
+
+#endif \ No newline at end of file