summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Lundblad <malu@pidgin.im>2009-11-12 23:24:43 +0000
committerMarcus Lundblad <malu@pidgin.im>2009-11-12 23:24:43 +0000
commitb850f3d6eccc630ce7af5fc965a1e93187a1694d (patch)
tree289e39d42652e71276a80281e928adfbc6b08445
parent8d9903756e935e3fb11193a9b2446dbeb3a28491 (diff)
downloadpidgin-b850f3d6eccc630ce7af5fc965a1e93187a1694d.tar.gz
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
-rw-r--r--ChangeLog2
-rw-r--r--libpurple/protocols/jabber/buddy.c6
-rw-r--r--libpurple/protocols/jabber/buddy.h1
-rw-r--r--libpurple/protocols/jabber/jabber.c45
-rw-r--r--libpurple/protocols/jabber/jabber.h1
-rw-r--r--libpurple/protocols/jabber/libxmpp.c2
6 files changed, 56 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index d016626518..fa0876e70f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/libpurple/protocols/jabber/buddy.c b/libpurple/protocols/jabber/buddy.c
index 92683231fd..c361f76934 100644
--- a/libpurple/protocols/jabber/buddy.c
+++ b/libpurple/protocols/jabber/buddy.c
@@ -2341,6 +2341,12 @@ void jabber_user_search_begin(PurplePluginAction *action)
}
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;
diff --git a/libpurple/protocols/jabber/buddy.h b/libpurple/protocols/jabber/buddy.h
index ebe033c637..c09a402f59 100644
--- a/libpurple/protocols/jabber/buddy.h
+++ b/libpurple/protocols/jabber/buddy.h
@@ -123,6 +123,7 @@ void jabber_buddy_remove_all_pending_buddy_info_requests(JabberStream *js);
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);
diff --git a/libpurple/protocols/jabber/jabber.c b/libpurple/protocols/jabber/jabber.c
index 57f94a771e..33be24f4d7 100644
--- a/libpurple/protocols/jabber/jabber.c
+++ b/libpurple/protocols/jabber/jabber.c
@@ -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(PurpleAccount *account, const char *who)
#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;
diff --git a/libpurple/protocols/jabber/jabber.h b/libpurple/protocols/jabber/jabber.h
index d25fa67fd9..c7f858aaac 100644
--- a/libpurple/protocols/jabber/jabber.h
+++ b/libpurple/protocols/jabber/jabber.h
@@ -368,6 +368,7 @@ gboolean jabber_video_enabled(JabberStream *js, const char *unused);
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);
diff --git a/libpurple/protocols/jabber/libxmpp.c b/libpurple/protocols/jabber/libxmpp.c
index bf945363a4..f52880357b 100644
--- a/libpurple/protocols/jabber/libxmpp.c
+++ b/libpurple/protocols/jabber/libxmpp.c
@@ -111,7 +111,7 @@ static PurplePluginProtocolInfo prpl_info =
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 */