changeset 15136:31603a03cc02

[gaim-migrate @ 17921] Etan had changed the account notify stuff so that the prpl decides if the person is a buddy or not; I totally wiped that out with my authorization stuff. This brings it back. Additionally, I added a googletalk flag to JabberStream which can determine at runtime if you're connected to Google Talk. All of the Google Talk extensions can be detected individually with disco, but this might be used for working with perfectly standard XMPP that's implemented in what might be considered a quirky way in Google Talk. For instance, Google Talk automatically adds buddies to your roster when you authorize them to add you. I was going to use this flag so that the Jabber prpl would never ask me to add a Google Talk buddy who's just been automatically added anyway. I decided to keep it, though, since I may still want to specify what group he's in. This opens the door for more Google Talk customization though >:) committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Fri, 08 Dec 2006 02:51:47 +0000
parents 9e1d9c9229ce
children af9fde10e4e2
files gtk/gtkaccount.c gtk/gtkutils.c libgaim/account.c libgaim/account.h libgaim/protocols/jabber/disco.c libgaim/protocols/jabber/jabber.h libgaim/protocols/jabber/presence.c libgaim/protocols/msn/userlist.c libgaim/protocols/oscar/oscar.c libgaim/protocols/yahoo/yahoo.c
diffstat 10 files changed, 75 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/gtk/gtkaccount.c	Thu Dec 07 23:16:04 2006 +0000
+++ b/gtk/gtkaccount.c	Fri Dec 08 02:51:47 2006 +0000
@@ -2420,7 +2420,7 @@
 
 static void
 gaim_gtk_accounts_request_authorization(GaimAccount *account, const char *remote_user,
-					const char *id, const char *alias, const char *message,
+					const char *id, const char *alias, const char *message, gboolean on_list,
 					GCallback auth_cb, GCallback deny_cb, void *user_data)
 {
 	char *buffer;
@@ -2445,7 +2445,7 @@
 		                (message != NULL ? message  : ""));
 
 
-	if (!gaim_find_buddy(account, remote_user)) {
+	if (!on_list) {
 		struct auth_and_add *aa = g_new0(struct auth_and_add, 1);
 		aa->auth_cb = (GaimAccountRequestAuthorizationCb)auth_cb;
 		aa->deny_cb = (GaimAccountRequestAuthorizationCb)deny_cb;
--- a/gtk/gtkutils.c	Thu Dec 07 23:16:04 2006 +0000
+++ b/gtk/gtkutils.c	Fri Dec 08 02:51:47 2006 +0000
@@ -2927,15 +2927,12 @@
 		   primary_esc, secondary ? "\n" : "", secondary?secondary_esc:"");
 	g_free(primary_esc);
 	label = gtk_label_new(NULL);
-	gtk_widget_set_size_request(label, gaim_prefs_get_int("/gaim/gtk/blist/width")-16,-1);
+	gtk_widget_set_size_request(label, gaim_prefs_get_int("/gaim/gtk/blist/width")-25,-1);
         gtk_widget_modify_text(vbox, GTK_STATE_NORMAL, &(label->style->white));
         gtk_label_set_markup(GTK_LABEL(label), label_text);
         gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
         gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
         gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
-#if GTK_CHECK_VERSION(2,6,0)
-	//	g_object_set(label, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
-#endif
 	
 	hbox2 = gtk_hbox_new(FALSE, 6);
 	gtk_box_pack_start(GTK_BOX(vbox), hbox2, FALSE, FALSE, 0);
--- a/libgaim/account.c	Thu Dec 07 23:16:04 2006 +0000
+++ b/libgaim/account.c	Fri Dec 08 02:51:47 2006 +0000
@@ -1055,7 +1055,7 @@
 
 void
 gaim_account_request_authorization(GaimAccount *account, const char *remote_user,
-			           const char *id, const char *alias, const char *message,
+			           const char *id, const char *alias, const char *message, gboolean on_list,
 				   GCallback auth_cb, GCallback deny_cb, void *user_data)
 {
         GaimAccountUiOps *ui_ops;
@@ -1066,7 +1066,7 @@
         ui_ops = gaim_accounts_get_ui_ops();
 
         if (ui_ops != NULL && ui_ops->request_authorize != NULL)
-               ui_ops->request_authorize(account, remote_user, id, alias, message, auth_cb, deny_cb, user_data);
+               ui_ops->request_authorize(account, remote_user, id, alias, message, on_list, auth_cb, deny_cb, user_data);
 						
 }
 
--- a/libgaim/account.h	Thu Dec 07 23:16:04 2006 +0000
+++ b/libgaim/account.h	Fri Dec 08 02:51:47 2006 +0000
@@ -54,7 +54,7 @@
 	                    const char *id, const char *alias,
 	                    const char *message);
 	void (*request_authorize)(GaimAccount *account, const char *remote_user, const char *id,
-				 const char *alias, const char *message, 
+				 const char *alias, const char *message, gboolean on_list, 
 				 GCallback authorize_cb, GCallback deny_cb, void *user_data);
 };
 
@@ -194,7 +194,7 @@
  * @param user_data    Data to be passed back to the above callbacks
  */
 void gaim_account_request_authorization(GaimAccount *account, const char *remote_user,
-					const char *id, const char *alias, const char *message,
+					const char *id, const char *alias, const char *message, gboolean on_list,
 					GCallback auth_cb, GCallback deny_cb, void *user_data);
 
 /**
--- a/libgaim/protocols/jabber/disco.c	Thu Dec 07 23:16:04 2006 +0000
+++ b/libgaim/protocols/jabber/disco.c	Fri Dec 08 02:51:47 2006 +0000
@@ -212,7 +212,48 @@
 }
 
 static void
-jabber_disco_server_result_cb(JabberStream *js, xmlnode *packet, gpointer data)
+jabber_disco_server_info_result_cb(JabberStream *js, xmlnode *packet, gpointer data)
+{
+  	xmlnode *query, *child;
+	const char *from = xmlnode_get_attrib(packet, "from");
+	const char *type = xmlnode_get_attrib(packet, "type");
+
+	if(!from || !type)
+		return;
+
+	if(strcmp(from, js->user->domain))
+		return;
+
+	if(strcmp(type, "result"))
+		return;
+
+	query = xmlnode_get_child(packet, "query");
+	
+	if (!query) return;
+	
+	for (child = xmlnode_get_child(query, "category"); child; 
+	     child = xmlnode_get_next_twin(child)) {
+		const char *category, *type, *name;
+		category = xmlnode_get_attrib(child, "category");
+		if (!category || strcmp(category, "server"))
+			continue;
+		type = xmlnode_get_attrib(child, "type");
+		if (!type || strcmp(type, "im"))
+			continue;
+		
+		name = xmlnode_get_attrib(child, "name");
+		if (!name)
+			continue;
+
+		g_free(js->server_name);
+		js->server_name = g_strdup(name);
+		if (!strcmp(name, "Google Talk"))
+			js->googletalk = TRUE;
+	}
+}
+
+static void
+jabber_disco_server_items_result_cb(JabberStream *js, xmlnode *packet, gpointer data)
 {
 	xmlnode *query, *child;
 	const char *from = xmlnode_get_attrib(packet, "from");
@@ -255,7 +296,13 @@
 
 	xmlnode_set_attrib(iq->node, "to", js->user->domain);
 
-	jabber_iq_set_callback(iq, jabber_disco_server_result_cb, NULL);
+	jabber_iq_set_callback(iq, jabber_disco_server_items_result_cb, NULL);
+	jabber_iq_send(iq);
+
+	iq = jabber_iq_new_query(js, JABBER_IQ_GET,
+		                 "http://jabber.org/protocol/disco#info");
+	xmlnode_set_attrib(iq->node, "to", js->user->domain);
+	jabber_iq_set_callback(iq, jabber_disco_server_info_result_cb, NULL);
 	jabber_iq_send(iq);
 }
 
--- a/libgaim/protocols/jabber/jabber.h	Thu Dec 07 23:16:04 2006 +0000
+++ b/libgaim/protocols/jabber/jabber.h	Fri Dec 08 02:51:47 2006 +0000
@@ -120,6 +120,9 @@
 
 	gboolean reinit;
 
+	gboolean googletalk;
+	char *server_name;
+
 	/* OK, this stays at the end of the struct, so plugins can depend
 	 * on the rest of the stuff being in the right place
 	 */
--- a/libgaim/protocols/jabber/presence.c	Thu Dec 07 23:16:04 2006 +0000
+++ b/libgaim/protocols/jabber/presence.c	Fri Dec 08 02:51:47 2006 +0000
@@ -280,13 +280,22 @@
 		jb->error_msg = msg ? msg : g_strdup(_("Unknown Error in presence"));
 	} else if(type && !strcmp(type, "subscribe")) {
 		struct _jabber_add_permit *jap = g_new0(struct _jabber_add_permit, 1);
+		gboolean onlist = FALSE;
+		GaimBuddy *buddy = gaim_find_buddy(gaim_connection_get_account(js->gc), from);
+		JabberBuddy *jb = NULL;
 
+		if (buddy) {
+			jb = jabber_buddy_find(js, from, TRUE);
+			if ((jb->subscription & JABBER_SUB_TO) == 0)
+				onlist = TRUE;
+		}
+		
 		jap->gc = js->gc;
 		jap->who = g_strdup(from);
 		jap->js = js;
 
-		gaim_account_request_authorization(gaim_connection_get_account(js->gc), from, NULL, NULL, NULL,
-				G_CALLBACK(authorize_add_cb), G_CALLBACK(deny_add_cb), jap);
+		gaim_account_request_authorization(gaim_connection_get_account(js->gc), from, NULL, NULL, NULL, onlist,
+					   	   G_CALLBACK(authorize_add_cb), G_CALLBACK(deny_add_cb), jap);
 		jabber_id_free(jid);
 		return;
 	} else if(type && !strcmp(type, "subscribed")) {
--- a/libgaim/protocols/msn/userlist.c	Thu Dec 07 23:16:04 2006 +0000
+++ b/libgaim/protocols/msn/userlist.c	Fri Dec 08 02:51:47 2006 +0000
@@ -74,6 +74,7 @@
 	pa->gc = gc;
 	
 	gaim_account_request_authorization(gaim_connection_get_account(gc), passport, NULL, friendly, NULL,
+					   gaim_find_buddy(gaim_connection_get_account(gc), passport),
 					   G_CALLBACK(msn_accept_add_cb), G_CALLBACK(msn_cancel_add_cb), pa);
 }
 
--- a/libgaim/protocols/oscar/oscar.c	Thu Dec 07 23:16:04 2006 +0000
+++ b/libgaim/protocols/oscar/oscar.c	Fri Dec 08 02:51:47 2006 +0000
@@ -2331,7 +2331,7 @@
 				data->nick = NULL;
 
 				gaim_account_request_authorization(account, sn,
-						NULL, NULL, reason,	G_CALLBACK(gaim_auth_grant),
+						NULL, NULL, reason, gaim_find_buddy(account, sn), G_CALLBACK(gaim_auth_grant),
 						G_CALLBACK(gaim_auth_dontgrant_msgprompt), data);
 				g_free(reason);
 			}
@@ -5043,7 +5043,7 @@
 	data->nick = NULL;
 
 	gaim_account_request_authorization(account, nombre,
-			NULL, NULL, reason, G_CALLBACK(gaim_auth_grant),
+			NULL, NULL, reason, buddy, G_CALLBACK(gaim_auth_grant),
 			G_CALLBACK(gaim_auth_dontgrant_msgprompt), data);
 	g_free(nombre);
 	g_free(reason);
--- a/libgaim/protocols/yahoo/yahoo.c	Thu Dec 07 23:16:04 2006 +0000
+++ b/libgaim/protocols/yahoo/yahoo.c	Fri Dec 08 02:51:47 2006 +0000
@@ -996,7 +996,8 @@
 		 * this should probably be moved to the core.
 		 */
 		 gaim_account_request_authorization(gaim_connection_get_account(gc), add_req->who, add_req->id,
-                                                    NULL, add_req->msg, G_CALLBACK(yahoo_buddy_add_authorize_cb), 
+                                                    NULL, add_req->msg, gaim_find_buddy(gaim_connection_get_account(gc),add_req->who),
+						    G_CALLBACK(yahoo_buddy_add_authorize_cb), 
 						    G_CALLBACK(yahoo_buddy_add_deny_reason_cb),
                                                     add_req);
 	} else {