cpw.malu.xmpp.jingle_ft: 14fcd8db: "back-port" the resource selection fix f...
malu at pidgin.im
malu at pidgin.im
Wed Jun 30 18:05:41 EDT 2010
----------------------------------------------------------------------
Revision: 14fcd8db027bf0876869572cb7c2ef29aac06440
Parent: 16448198be138531743791081bb5bfa573aaff87
Author: malu at pidgin.im
Date: 06/30/10 18:01:03
Branch: im.pidgin.cpw.malu.xmpp.jingle_ft
URL: http://d.pidgin.im/viewmtn/revision/info/14fcd8db027bf0876869572cb7c2ef29aac06440
Changelog:
"back-port" the resource selection fix for Jingle FT
Changed an occurance of the SI FT namespace to use the #define
Changes against parent 16448198be138531743791081bb5bfa573aaff87
patched libpurple/protocols/jabber/jabber.c
patched libpurple/protocols/jabber/xfer.c
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jabber.c 422d566324f5224f4883b16b568b37013a580a4c
+++ libpurple/protocols/jabber/jabber.c 00bedee2725ccc695af7b1471bb8f60690659169
@@ -3441,10 +3441,9 @@ gboolean jabber_can_receive_file(PurpleC
for (iter = jb->resources; iter ; iter = g_list_next(iter)) {
JabberBuddyResource *jbr = (JabberBuddyResource *) iter->data;
- if (jabber_resource_has_capability(jbr, NS_SI_FILE_TRANSFER)
- && (jabber_resource_has_capability(jbr,
- NS_BYTESTREAMS)
- || jabber_resource_has_capability(jbr, NS_IBB))))
+ if ((jabber_resource_has_capability(jbr, NS_SI_FILE_TRANSFER)
+ && (jabber_resource_has_capability(jbr, NS_BYTESTREAMS)
+ || jabber_resource_has_capability(jbr, NS_IBB)))
|| ((jabber_resource_has_capability(jbr, JINGLE_APP_FT)
&& (jabber_resource_has_capability(jbr,
JINGLE_TRANSPORT_S5B)
============================================================
--- libpurple/protocols/jabber/xfer.c 6358c383093ea205076faa9afbd79cdb0df7c4ee
+++ libpurple/protocols/jabber/xfer.c 7aed9b906399e57618e1dee945060319deee8497
@@ -116,15 +116,35 @@ jabber_xfer_send(PurpleConnection *gc, c
JabberStream *js = (JabberStream *) purple_connection_get_protocol_data(gc);
JabberBuddy *jb = jabber_buddy_find(js, who, TRUE);
JabberBuddyResource *jbr = NULL;
+ GList *resources = NULL;
gchar *resource = jabber_get_resource(who);
+ if (jb) {
+ GList *l;
+
+ for (l = jb->resources ; l ; l = g_list_next(l)) {
+ jbr = l->data;
+
+ if ((jabber_resource_has_capability(jbr, NS_SI_FILE_TRANSFER)
+ && (jabber_resource_has_capability(jbr, NS_BYTESTREAMS)
+ || jabber_resource_has_capability(jbr, NS_IBB)))
+ || ((jabber_resource_has_capability(jbr, JINGLE_APP_FT)
+ && (jabber_resource_has_capability(jbr,
+ JINGLE_TRANSPORT_S5B)
+ || jabber_resource_has_capability(jbr,
+ JINGLE_TRANSPORT_IBB))))) {
+ resources = g_list_append(resources, jbr);
+ }
+ }
+ }
+
/* Let the user select a resource, unless "who" already contains one */
/* or there's only one resource online */
if (resource) {
/* who already contains a resource */
jabber_xfer_send_to_resource(gc, who, file);
g_free(resource);
- } else if(!jb || !jb->resources) {
+ } else if(!resources) {
/* no resources online, we're trying to send to someone
* whose presence we're not subscribed to, or
* someone who is offline. Let's inform the user */
@@ -143,12 +163,12 @@ jabber_xfer_send(PurpleConnection *gc, c
purple_notify_error(js->gc, _("File Send Failed"), _("File Send Failed"), msg);
g_free(msg);
- } else if(!jb->resources->next) {
+ } else if (g_list_length(resources) == 1) {
/* only 1 resource online (probably our most common case)
* so no need to ask who to send to */
gchar *jid = NULL;
- jbr = jb->resources->data;
+ jbr = resources->data;
jid = g_strdup_printf("%s/%s", who, jbr->name);
jabber_xfer_send_to_resource(gc, jid, file);
g_free(jid);
@@ -167,7 +187,7 @@ jabber_xfer_send(PurpleConnection *gc, c
data->who = who;
data->file = g_strdup(file);
- for(l = jb->resources; l; l = l->next) {
+ for(l = resources; l; l = l->next) {
jbr = l->data;
purple_request_field_choice_add(field, jbr->name);
@@ -184,6 +204,8 @@ jabber_xfer_send(PurpleConnection *gc, c
g_free(msg);
}
+
+ g_list_free(resources);
}
xmlnode *
@@ -192,8 +214,7 @@ jabber_xfer_create_file_element(const Pu
xmlnode *file = xmlnode_new("file");
gchar buf[32];
- xmlnode_set_namespace(file,
- "http://jabber.org/protocol/si/profile/file-transfer");
+ xmlnode_set_namespace(file, NS_SI_FILE_TRANSFER);
xmlnode_set_attrib(file, "name", xfer->filename);
g_snprintf(buf, sizeof(buf), "%" G_GSIZE_FORMAT, xfer->size);
xmlnode_set_attrib(file, "size", buf);
More information about the Commits
mailing list