pidgin: 8b6b0e83: jabber: Determine if a buddy can receive...
malu at pidgin.im
malu at pidgin.im
Thu Nov 12 18:25:42 EST 2009
-----------------------------------------------------------------
Revision: 8b6b0e8385b470c8181ddd6b6fd6d8e708c08f9e
Ancestor: 21e0c593084b90bf269f264a4f54e3ac8ea291d9
Author: malu at pidgin.im
Date: 2009-11-12T23:24:43
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/8b6b0e8385b470c8181ddd6b6fd6d8e708c08f9e
Modified files:
ChangeLog libpurple/protocols/jabber/buddy.c
libpurple/protocols/jabber/buddy.h
libpurple/protocols/jabber/jabber.c
libpurple/protocols/jabber/jabber.h
libpurple/protocols/jabber/libxmpp.c
ChangeLog:
jabber: Determine if a buddy can receive a file transfer (when we have
received caps for all online caps).
This will still allow file transfer to clients that don't advertise caps.
Disables the file transfer option for gmail buddies
Refs #1507
-------------- next part --------------
============================================================
--- ChangeLog fdef734d3515a840eaaaf90cdaaa9fc462f06644
+++ ChangeLog b1f96e57cc0938a10e386feb51867aad2e123248
@@ -42,6 +42,8 @@ version 2.6.4 (??/??/20??):
account's domain, and use that for voice and video if found and the user
didn't set one manually in prefs.
* Fix a crash when adding a buddy without an '@'.
+ * Don't show the option to send a file to a buddy if we know for certain
+ they don't support any file transfer method supported by libpurple.
Yahoo:
* Fix sending /buzz.
============================================================
--- libpurple/protocols/jabber/buddy.c 51ae69fb1a591ca8a38b7fb828970c4b86d13ec0
+++ libpurple/protocols/jabber/buddy.c 9a47cd9c950377ee7b1ccc6395d9343e88d48a3a
@@ -2341,6 +2341,12 @@ gboolean
}
gboolean
+jabber_resource_know_capabilities(const JabberBuddyResource *jbr)
+{
+ return jbr->caps.info != NULL;
+}
+
+gboolean
jabber_resource_has_capability(const JabberBuddyResource *jbr, const gchar *cap)
{
const GList *node = NULL;
============================================================
--- libpurple/protocols/jabber/buddy.h f786328f96fb8982745e3052f6c9ad2080cf67e8
+++ libpurple/protocols/jabber/buddy.h 509699775bb00c543db2320f5098bc63aa66d78d
@@ -123,6 +123,7 @@ void jabber_vcard_fetch_mine(JabberStrea
void jabber_vcard_fetch_mine(JabberStream *js);
+gboolean jabber_resource_know_capabilities(const JabberBuddyResource *jbr);
gboolean jabber_resource_has_capability(const JabberBuddyResource *jbr,
const gchar *cap);
gboolean jabber_buddy_has_capability(const JabberBuddy *jb, const gchar *cap);
============================================================
--- libpurple/protocols/jabber/jabber.c 9861db333983ecf98713755a830bd9aa5e004514
+++ libpurple/protocols/jabber/jabber.c 41d392fd2ac5e1947015c8dc021862b98e910f1d
@@ -52,6 +52,7 @@
#include "data.h"
#include "disco.h"
#include "google.h"
+#include "ibb.h"
#include "iq.h"
#include "jutil.h"
#include "message.h"
@@ -3224,6 +3225,50 @@ PurpleMediaCaps jabber_get_media_caps(Pu
#endif
}
+gboolean jabber_can_receive_file(PurpleConnection *gc, const char *who)
+{
+ JabberStream *js = gc->proto_data;
+
+ if (js) {
+ JabberBuddy *jb = jabber_buddy_find(js, who, FALSE);
+ GList *iter;
+ gboolean has_resources_without_caps = FALSE;
+
+ /* find out if there is any resources without caps */
+ for (iter = jb->resources; iter ; iter = g_list_next(iter)) {
+ JabberBuddyResource *jbr = (JabberBuddyResource *) iter->data;
+
+ if (!jabber_resource_know_capabilities(jbr)) {
+ has_resources_without_caps = TRUE;
+ }
+ }
+
+ if (has_resources_without_caps) {
+ /* there is at least one resource which we don't have caps for,
+ let's assume they can receive files... */
+ return TRUE;
+ } else {
+ /* we have caps for all the resources, see if at least one has
+ right caps */
+ for (iter = jb->resources; iter ; iter = g_list_next(iter)) {
+ JabberBuddyResource *jbr = (JabberBuddyResource *) iter->data;
+
+ if (jabber_resource_has_capability(jbr,
+ "http://jabber.org/protocol/si/profile/file-transfer")
+ && (jabber_resource_has_capability(jbr,
+ "http://jabber.org/protocol/bytestreams")
+ || jabber_resource_has_capability(jbr,
+ XEP_0047_NAMESPACE))) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+ }
+ } else {
+ return TRUE;
+ }
+}
+
void jabber_register_commands(void)
{
PurpleCmdId id;
============================================================
--- libpurple/protocols/jabber/jabber.h ac103a30f7f417d8d67656982049ecde5f6cf545
+++ libpurple/protocols/jabber/jabber.h db11a9cb219a167f5864ef85c915ff2b9c7ab70f
@@ -368,6 +368,7 @@ PurpleMediaCaps jabber_get_media_caps(Pu
gboolean jabber_initiate_media(PurpleAccount *account, const char *who,
PurpleMediaSessionType type);
PurpleMediaCaps jabber_get_media_caps(PurpleAccount *account, const char *who);
+gboolean jabber_can_receive_file(PurpleConnection *gc, const gchar *who);
void jabber_register_commands(void);
void jabber_unregister_commands(void);
============================================================
--- libpurple/protocols/jabber/libxmpp.c e4ce89ddf64f9bdc73ad047f91e3b3443dae13d7
+++ libpurple/protocols/jabber/libxmpp.c fa1b2b78022e4068984bcf64896101cd9874c5b2
@@ -111,7 +111,7 @@ static PurplePluginProtocolInfo prpl_inf
jabber_roomlist_get_list, /* roomlist_get_list */
jabber_roomlist_cancel, /* roomlist_cancel */
NULL, /* roomlist_expand_category */
- NULL, /* can_receive_file */
+ jabber_can_receive_file, /* can_receive_file */
jabber_si_xfer_send, /* send_file */
jabber_si_new_xfer, /* new_xfer */
jabber_offline_message, /* offline_message */
More information about the Commits
mailing list