cpw.malu.xmpp.jingle_ft: a58aa4f5: Transfer using socks5 using the first of...
malu at pidgin.im
malu at pidgin.im
Mon Apr 13 10:45:55 EDT 2009
-----------------------------------------------------------------
Revision: a58aa4f530ba389aa0cc006e3ca741c3a4e928ea
Ancestor: 6c6d261d95804de9dfc66cd3ca8689fb4b170c68
Author: malu at pidgin.im
Date: 2009-04-13T14:41:58
Branch: im.pidgin.cpw.malu.xmpp.jingle_ft
URL: http://d.pidgin.im/viewmtn/revision/info/a58aa4f530ba389aa0cc006e3ca741c3a4e928ea
Modified files:
libpurple/protocols/jabber/jingle/file-transfer.c
libpurple/protocols/jabber/jingle/s5b.c
libpurple/protocols/jabber/jingle/s5b.h
ChangeLog:
Transfer using socks5 using the first offered streamhost candidate works now.
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jingle/file-transfer.c f86a046475db3f5ecc0e97d6f17e577ba3d8c33c
+++ libpurple/protocols/jabber/jingle/file-transfer.c c797409198f914de2cd6ba543348e765975ea125
@@ -271,6 +271,25 @@ jingle_file_transfer_ibb_send_data(Jingl
g_object_unref(transport);
}
+/* callback functions for S5B */
+static void
+jingle_file_transfer_s5b_connect_callback(JingleContent *content)
+{
+ PurpleXfer *xfer = JINGLE_FT_GET_PRIVATE(JINGLE_FT(content))->xfer;
+ JingleTransport *transport = jingle_content_get_transport(content);
+ JingleS5B *s5b = JINGLE_S5B(transport);
+
+ purple_debug_info("jingle-ft",
+ "in jingle_file_transfer_s5b_connect_callback\n");
+ purple_xfer_start(xfer, jingle_s5b_get_fd(s5b), NULL, 0);
+}
+
+static void
+jingle_file_transfer_s5b_error_callback(JingleContent *content)
+{
+
+}
+
/* callback functions for IBB */
static void
jingle_file_transfer_ibb_data_sent_callback(JingleContent *content)
@@ -330,7 +349,8 @@ jingle_file_transfer_ibb_error_callback(
PurpleAccount *account = purple_connection_get_account(gc);
gchar *who = jingle_session_get_remote_jid(session);
- purple_debug_error("jabber", "an error occured during IBB file transfer\n");
+ purple_debug_error("jingle-ft",
+ "an error occured during IBB file transfer\n");
purple_xfer_error(purple_xfer_get_type(xfer), account, who,
_("An error occured on the in-band bytestream transfer\n"));
purple_xfer_cancel_remote(xfer);
@@ -487,6 +507,10 @@ jingle_file_transfer_xfer_init(PurpleXfe
/* start the transfer */
purple_xfer_start(xfer, 0, NULL, 0);
} else if (JINGLE_IS_S5B(transport)) {
+ jingle_s5b_set_connect_callback(JINGLE_S5B(transport),
+ jingle_file_transfer_s5b_connect_callback, content);
+ jingle_s5b_set_error_callback(JINGLE_S5B(transport),
+ jingle_file_transfer_s5b_error_callback, content);
jingle_s5b_gather_streamhosts(session, JINGLE_S5B(transport));
}
g_object_unref(session);
@@ -642,6 +666,12 @@ jingle_file_transfer_handle_action_inter
const gchar *filename =
purple_xfer_get_local_filename(xfer);
jingle_ibb_create_session(ibb, content, sid, who);
+ } else if (JINGLE_IS_S5B(transport)) {
+ /* set S5B callbacks */
+ jingle_s5b_set_connect_callback(JINGLE_S5B(transport),
+ jingle_file_transfer_s5b_connect_callback, content);
+ jingle_s5b_set_error_callback(JINGLE_S5B(transport),
+ jingle_file_transfer_s5b_error_callback, content);
}
g_object_unref(transport);
@@ -709,11 +739,14 @@ jingle_file_transfer_handle_action_inter
} else {
/* we are now the "owner" of the bytestream */
jingle_s5b_take_command(s5b);
+
+ /* also when receiving a <streamhost-used/> we need to
+ check if that is not one of our local streamhosts,
+ in which case it is a proxy, and we should connect to that */
+
+ /* start transfer */
+ jingle_file_transfer_s5b_connect_callback(content);
}
-
- /* also when receiving a <streamhost-used/> we need to check if
- that is not one of our local streamhosts, in which case it is
- a proxy, and we should connect to that */
}
}
============================================================
--- libpurple/protocols/jabber/jingle/s5b.c e26176b1275c5acf54323f7878f608638f931368
+++ libpurple/protocols/jabber/jingle/s5b.c 9356bf11a2d5c553476ce8a7fd4f1cb34430ceec
@@ -144,6 +144,10 @@ struct _JingleS5BPrivate {
GList *local_streamhosts;
GList *remaining_streamhosts; /* pointer to untested remote SHs */
JabberBytestreamsStreamhost *successfull_remote_streamhost;
+ JingleS5BConnectCallback *connect_cb;
+ JingleS5BErrorCallback *error_cb;
+ JingleContent *connect_content; /* used for the connect callback */
+ JingleContent *error_content; /* used for the error callback */
};
#define JINGLE_S5B_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), JINGLE_TYPE_S5B, JingleS5BPrivate))
@@ -160,7 +164,10 @@ enum {
enum {
PROP_0,
- PROP_SID
+ PROP_SID,
+ PROP_FD,
+ PROP_CONNECT_CB,
+ PROP_ERROR_CB
};
GType
@@ -206,6 +213,16 @@ jingle_s5b_class_init (JingleS5BClass *k
NULL,
G_PARAM_READWRITE));
+ purple_debug_info("jingle-s5b", "install_property\n");
+ g_object_class_install_property(gobject_class, PROP_FD,
+ g_param_spec_int("fd",
+ "File descriptor",
+ "The file descriptor for reading/writing data on the stream",
+ G_MININT,
+ G_MAXINT,
+ 0,
+ G_PARAM_READABLE));
+
g_type_class_add_private(klass, sizeof(JingleS5BPrivate));
}
@@ -280,6 +297,9 @@ jingle_s5b_get_property (GObject *object
case PROP_SID:
g_value_set_string(value, s5b->priv->sid);
break;
+ case PROP_FD:
+ g_value_set_int(value, s5b->priv->fd);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -300,6 +320,28 @@ jingle_s5b_set_sid(JingleS5B *s5b, const
g_object_set(s5b, "sid", sid, NULL);
}
+int
+jingle_s5b_get_fd(const JingleS5B *s5b)
+{
+ int fd;
+ g_object_get((gpointer) s5b, "fd", &fd, NULL);
+ return fd;
+}
+
+void jingle_s5b_set_connect_callback(JingleS5B *s5b,
+ JingleS5BConnectCallback *cb, JingleContent *content)
+{
+ s5b->priv->connect_cb = cb;
+ s5b->priv->connect_content = content;
+}
+
+void jingle_s5b_set_error_callback(JingleS5B *s5b,
+ JingleS5BErrorCallback *cb, JingleContent *content)
+{
+ s5b->priv->error_cb = cb;
+ s5b->priv->error_content = content;
+}
+
void
jingle_s5b_add_streamhosts(JingleS5B *s5b, const xmlnode *transport)
{
@@ -822,6 +864,12 @@ jingle_s5b_transport_accept_cb(JabberStr
now we shall "surrender" to other side and signal the content
to start */
jingle_s5b_surrender(s5b);
+ /* start transfer */
+ if (s5b->priv->connect_cb && s5b->priv->connect_content) {
+ s5b->priv->connect_cb(s5b->priv->connect_content);
+ } else {
+ /* some error? */
+ }
}
}
============================================================
--- libpurple/protocols/jabber/jingle/s5b.h 22626223759284ce98076d8b1427b974ca3a89a1
+++ libpurple/protocols/jabber/jingle/s5b.h 0c9668e6784fb2d27c245e26bd8faa6a19d334c8
@@ -54,6 +54,10 @@ struct _JingleS5B
JingleS5BPrivate *priv; /**< The private data of this object. */
};
+/* Callbacks used for S5B */
+typedef void (JingleS5BConnectCallback)(JingleContent *) ;
+typedef void (JingleS5BErrorCallback)(JingleContent *);
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -68,6 +72,14 @@ void jingle_s5b_set_sid(JingleS5B *s5b,
const gchar *jingle_s5b_get_sid(const JingleS5B *s5b);
void jingle_s5b_set_sid(JingleS5B *s5b, const gchar *sid);
+int jingle_s5b_get_fd(const JingleS5B *s5b);
+
+void jingle_s5b_set_connect_callback(JingleS5B *s5b,
+ JingleS5BConnectCallback *cb, JingleContent *content);
+void jingle_s5b_set_error_callback(JingleS5B *s5b,
+ JingleS5BErrorCallback *cb, JingleContent *content);
+
+
void jingle_s5b_add_streamhosts(JingleS5B *s5b, const xmlnode *transport);
/* start discovering streamhosts, initiator will send session-initiate when
More information about the Commits
mailing list