changeset 31851:0cf50b0f7af4

Add invite message support to Oscar.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sun, 20 Mar 2011 22:03:48 +0000
parents 0c981f2c169a
children c0a122c22475
files libpurple/protocols/oscar/authorization.c libpurple/protocols/oscar/family_feedbag.c libpurple/protocols/oscar/libaim.c libpurple/protocols/oscar/libicq.c libpurple/protocols/oscar/oscar.c libpurple/protocols/oscar/oscar.h libpurple/protocols/oscar/oscarcommon.h
diffstat 7 files changed, 24 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/oscar/authorization.c	Sun Mar 20 21:47:54 2011 +0000
+++ b/libpurple/protocols/oscar/authorization.c	Sun Mar 20 22:03:48 2011 +0000
@@ -25,20 +25,19 @@
 #include "oscar.h"
 #include "request.h"
 
-static void
-oscar_auth_request(struct name_data *data, char *msg)
+/* When you ask other people for authorization */
+void
+oscar_auth_sendrequest(PurpleConnection *gc, const char *bname, const char *msg)
 {
-	PurpleConnection *gc;
 	OscarData *od;
 	PurpleAccount *account;
 	PurpleBuddy *buddy;
 	PurpleGroup *group;
-	const char *bname, *gname;
+	const char *gname;
 
-	gc = data->gc;
 	od = purple_connection_get_protocol_data(gc);
 	account = purple_connection_get_account(gc);
-	buddy = purple_find_buddy(account, data->name);
+	buddy = purple_find_buddy(account, bname);
 	if (buddy != NULL)
 		group = purple_buddy_get_group(buddy);
 	else
@@ -46,11 +45,10 @@
 
 	if (group != NULL)
 	{
-		bname = purple_buddy_get_name(buddy);
 		gname = purple_group_get_name(group);
 		purple_debug_info("oscar", "ssi: adding buddy %s to group %s\n",
 				   bname, gname);
-		aim_ssi_sendauthrequest(od, data->name, msg ? msg : _("Please authorize me so I can add you to my buddy list."));
+		aim_ssi_sendauthrequest(od, bname, msg ? msg : _("Please authorize me so I can add you to my buddy list."));
 		if (!aim_ssi_itemlist_finditem(od->ssi.local, gname, bname, AIM_SSI_TYPE_BUDDY))
 		{
 			aim_ssi_addbuddy(od, bname, gname, NULL, purple_buddy_get_alias_only(buddy), NULL, NULL, TRUE);
@@ -66,8 +64,6 @@
 			}
 		}
 	}
-
-	oscar_free_name_data(data);
 }
 
 static void
@@ -105,24 +101,6 @@
 					   data);
 }
 
-/* When you ask other people for authorization */
-void
-oscar_auth_sendrequest(PurpleConnection *gc, const char *name)
-{
-	struct name_data *data;
-
-	data = g_new0(struct name_data, 1);
-	data->gc = gc;
-	data->name = g_strdup(name);
-
-	purple_request_input(data->gc, NULL, _("Authorization Request Message:"),
-					   NULL, _("Please authorize me!"), TRUE, FALSE, NULL,
-					   _("_OK"), G_CALLBACK(oscar_auth_request),
-					   _("_Cancel"), G_CALLBACK(oscar_free_name_data),
-					   purple_connection_get_account(gc), name, NULL,
-					   data);
-}
-
 void
 oscar_auth_sendrequest_menu(PurpleBlistNode *node, gpointer ignored)
 {
@@ -133,7 +111,7 @@
 
 	buddy = (PurpleBuddy *) node;
 	gc = purple_account_get_connection(purple_buddy_get_account(buddy));
-	oscar_auth_sendrequest(gc, purple_buddy_get_name(buddy));
+	oscar_auth_sendrequest(gc, purple_buddy_get_name(buddy), NULL);
 }
 
 /* When other people ask you for authorization */
@@ -150,4 +128,4 @@
 	purple_account_request_authorization(account, data->name, NULL, data->nick,
 		reason, purple_find_buddy(account, data->name) != NULL,
 		oscar_auth_grant, oscar_auth_dontgrant_msgprompt, data);
-}
\ No newline at end of file
+}
--- a/libpurple/protocols/oscar/family_feedbag.c	Sun Mar 20 21:47:54 2011 +0000
+++ b/libpurple/protocols/oscar/family_feedbag.c	Sun Mar 20 22:03:48 2011 +0000
@@ -1682,7 +1682,7 @@
  * granted, denied, or dropped.
  *
  */
-int aim_ssi_sendauthrequest(OscarData *od, char *bn, const char *msg)
+int aim_ssi_sendauthrequest(OscarData *od, const char *bn, const char *msg)
 {
 	FlapConnection *conn;
 	ByteStream bs;
@@ -1759,7 +1759,7 @@
  * if reply=0x01 then grant
  *
  */
-int aim_ssi_sendauthreply(OscarData *od, char *bn, guint8 reply, const char *msg)
+int aim_ssi_sendauthreply(OscarData *od, const char *bn, guint8 reply, const char *msg)
 {
 	FlapConnection *conn;
 	ByteStream bs;
--- a/libpurple/protocols/oscar/libaim.c	Sun Mar 20 21:47:54 2011 +0000
+++ b/libpurple/protocols/oscar/libaim.c	Sun Mar 20 22:03:48 2011 +0000
@@ -29,7 +29,7 @@
 
 static PurplePluginProtocolInfo prpl_info =
 {
-	OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE,
+	OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE | OPT_PROTO_INVITE_MESSAGE,
 	NULL,					/* user_splits */
 	NULL,					/* protocol_options */
 	{"gif,jpeg,bmp,ico", 0, 0, 100, 100, 7168, PURPLE_ICON_SCALE_DISPLAY}, /* icon_spec */
@@ -50,7 +50,7 @@
 	oscar_set_status,		/* set_status */
 	oscar_set_idle,			/* set_idle */
 	oscar_change_passwd,	/* change_passwd */
-	oscar_add_buddy,		/* add_buddy */
+	NULL,					/* add_buddy */
 	NULL,					/* add_buddies */
 	oscar_remove_buddy,		/* remove_buddy */
 	NULL,					/* remove_buddies */
@@ -101,7 +101,7 @@
 	NULL,					/* get_moods */
 	NULL,					/* set_public_alias */
 	NULL,					/* get_public_alias */
-	NULL,					/* add_buddy_with_invite */
+	oscar_add_buddy,		/* add_buddy_with_invite */
 	NULL					/* add_buddies_with_invite */
 };
 
--- a/libpurple/protocols/oscar/libicq.c	Sun Mar 20 21:47:54 2011 +0000
+++ b/libpurple/protocols/oscar/libicq.c	Sun Mar 20 22:03:48 2011 +0000
@@ -38,7 +38,7 @@
 
 static PurplePluginProtocolInfo prpl_info =
 {
-	OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE,
+	OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE | OPT_PROTO_INVITE_MESSAGE,
 	NULL,					/* user_splits */
 	NULL,					/* protocol_options */
 	{"gif,jpeg,bmp,ico", 0, 0, 100, 100, 7168, PURPLE_ICON_SCALE_DISPLAY}, /* icon_spec */
@@ -59,7 +59,7 @@
 	oscar_set_status,		/* set_status */
 	oscar_set_idle,			/* set_idle */
 	oscar_change_passwd,	/* change_passwd */
-	oscar_add_buddy,		/* add_buddy */
+	NULL,					/* add_buddy */
 	NULL,					/* add_buddies */
 	oscar_remove_buddy,		/* remove_buddy */
 	NULL,					/* remove_buddies */
@@ -111,7 +111,7 @@
 	oscar_get_purple_moods, /* get_moods */
 	NULL,					/* set_public_alias */
 	NULL,					/* get_public_alias */
-	NULL,					/* add_buddy_with_invite */
+	oscar_add_buddy,		/* add_buddy_with_invite */
 	NULL					/* add_buddies_with_invite */
 };
 
--- a/libpurple/protocols/oscar/oscar.c	Sun Mar 20 21:47:54 2011 +0000
+++ b/libpurple/protocols/oscar/oscar.c	Sun Mar 20 22:03:48 2011 +0000
@@ -3685,7 +3685,8 @@
 }
 
 void
-oscar_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) {
+oscar_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group, const char *msg)
+{
 	OscarData *od;
 	PurpleAccount *account;
 	const char *bname, *gname;
@@ -3725,7 +3726,7 @@
 		                                  aim_ssi_itemlist_findparentname(od->ssi.local, bname),
 		                                  bname)) {
 			/* Not authorized -- Re-request authorization */
-			oscar_auth_sendrequest(gc, bname);
+			oscar_auth_sendrequest(gc, bname, msg);
 		}
 	}
 
@@ -4175,7 +4176,7 @@
 
 			case 0x000e: { /* buddy requires authorization */
 				if ((retval->action == SNAC_SUBTYPE_FEEDBAG_ADD) && (retval->name))
-					oscar_auth_sendrequest(gc, retval->name);
+					oscar_auth_sendrequest(gc, retval->name, NULL);
 			} break;
 
 			default: { /* La la la */
--- a/libpurple/protocols/oscar/oscar.h	Sun Mar 20 21:47:54 2011 +0000
+++ b/libpurple/protocols/oscar/oscar.h	Sun Mar 20 22:03:48 2011 +0000
@@ -912,8 +912,8 @@
 /* 0x0007 */ int aim_ssi_enable(OscarData *od);
 /* 0x0011 */ int aim_ssi_modbegin(OscarData *od);
 /* 0x0012 */ int aim_ssi_modend(OscarData *od);
-/* 0x0018 */ int aim_ssi_sendauthrequest(OscarData *od, char *bn, const char *msg);
-/* 0x001a */ int aim_ssi_sendauthreply(OscarData *od, char *bn, guint8 reply, const char *msg);
+/* 0x0018 */ int aim_ssi_sendauthrequest(OscarData *od, const char *bn, const char *msg);
+/* 0x001a */ int aim_ssi_sendauthreply(OscarData *od, const char *bn, guint8 reply, const char *msg);
 
 /* Client functions for retrieving SSI data */
 struct aim_ssi_item *aim_ssi_itemlist_find(struct aim_ssi_item *list, guint16 gid, guint16 bid);
@@ -1311,7 +1311,7 @@
 void oscar_user_info_display_aim(OscarData *od, aim_userinfo_t *userinfo);
 
 /* authorization.c - OSCAR authorization requests */
-void oscar_auth_sendrequest(PurpleConnection *gc, const char *name);
+void oscar_auth_sendrequest(PurpleConnection *gc, const char *name, const char *msg);
 void oscar_auth_sendrequest_menu(PurpleBlistNode *node, gpointer ignored);
 void oscar_auth_recvrequest(PurpleConnection *gc, gchar *name, gchar *nick, gchar *reason);
 
--- a/libpurple/protocols/oscar/oscarcommon.h	Sun Mar 20 21:47:54 2011 +0000
+++ b/libpurple/protocols/oscar/oscarcommon.h	Sun Mar 20 22:03:48 2011 +0000
@@ -79,7 +79,7 @@
 void oscar_set_status(PurpleAccount *account, PurpleStatus *status);
 void oscar_set_idle(PurpleConnection *gc, int time);
 void oscar_change_passwd(PurpleConnection *gc, const char *old, const char *new);
-void oscar_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group);
+void oscar_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group, const char *msg);
 void oscar_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group);
 void oscar_add_permit(PurpleConnection *gc, const char *who);
 void oscar_add_deny(PurpleConnection *gc, const char *who);