/soc/2013/ashmew2/filetransferX: 28a94cdfc015: New gtalk xfer fu...
Ashish Gupta
ashmew2 at gmail.com
Mon Aug 5 17:55:13 EDT 2013
Changeset: 28a94cdfc015e2061e95e6efdbec04d571a93e9e
Author: Ashish Gupta <ashmew2 at gmail.com>
Date: 2013-08-06 03:24 +0530
Branch: filetransferX
URL: https://hg.pidgin.im/soc/2013/ashmew2/filetransferX/rev/28a94cdfc015
Description:
New gtalk xfer functions
diffstat:
libpurple/protocols/jabber/google/google_session.c | 63 ++++++++++++++++++++++
libpurple/protocols/jabber/google/google_session.h | 3 +-
libpurple/protocols/jabber/si.c | 1 +
3 files changed, 66 insertions(+), 1 deletions(-)
diffs (95 lines):
diff --git a/libpurple/protocols/jabber/google/google_session.c b/libpurple/protocols/jabber/google/google_session.c
--- a/libpurple/protocols/jabber/google/google_session.c
+++ b/libpurple/protocols/jabber/google/google_session.c
@@ -1021,6 +1021,69 @@ gtalk_xfer_start(PurpleXfer *xfer)
}
}
+PurpleXfer *gtalk_xfer_new(PurpleConnection *gc, const char *who)
+{
+ PurpleXfer *xfer;
+
+ xfer = purple_xfer_new(gc->account, PURPLE_XFER_SEND, who);
+
+ if (xfer) {
+ xfer->data = g_new0(GoogleSession, 1);
+/*TODO: GoogleXferSessionData should probably have JabberStream in it*/
+ purple_xfer_set_init_fnc(xfer, gtalk_xfer_init);
+ purple_xfer_set_start_fnc(xfer, gtalk_xfer_start);
+ }
+}
+
+void
+gtalk_xfer_send(PurpleConnection *gc, const char *who, const char *file)
+{
+ PurpleXfer *xfer;
+ xfer = gtalk_new_xfer(gc, who);
+
+ xfer = purple_xfer_new(purple_connection_get_account(gc), PURPLE_XFER_SEND, who);
+
+ if(!xfer) {
+ purple_debug_info("google_session", "Failed to Create an Xfer for Sending a File..");
+ return;
+ }
+
+ if (file) {
+ purple_xfer_request_accepted(xfer, file);
+ purple_debug_info("google_session", "file is non NULL.File : %s\n");
+ }
+ else {
+ purple_xfer_request(xfer);
+ purple_debug_info("google_session", "file is NULL. File : %s\n",file);
+ }
+ purple_debug_info("google_session", "We have a file now. Details of Xfer :\nwho : %s\nfilename:%s\nlocal_filename:%s\nsize:%d\n",xfer->who,xfer->filename,xfer->local_filename,xfer->size);
+
+ /*
+
+ JabberStream *js = purple_connection_get_protocol_data(gc);
+ JabberIq *iq = jabber_iq_new(js, JABBER_IQ_SET);
+ xmlnode *session_node, *description_node;
+ gchar *me = g_strdup_printf("%s@%s/%s",
+ session->js->user->node,
+ session->js->user->domain,
+ session->js->user->resource);
+
+ xmlnode_set_attrib(iq->node, "to", session->remote_jid);
+
+ session_node = xmlnode_new_child(iq->node, "session");
+ xmlnode_set_attrib(session_node, "type", "initiate");
+ xmlnode_set_attrib(session_node, "id", jabber_get_next_id(js));
+ xmlnode_set_attrib(session_node, "initiator", me);
+ xmlnode_set_namespace(session_node, NS_GOOGLE_SESSION);
+
+ description_node = xmlnode_new_child(session_node, "description");
+ xmlnode_set_namespace(description_node, NS_GOOGLE_SESSION_SHARE);
+
+ manifest_node = xmlnode_new_child(description_node, "manifest");
+ file_node = xmlnode_new_child(manifest_node, "file");
+ /* xmlnode_set_attrib(file_node, "size", FILE_SIZE); */
+}
+
static void
gtalk_xfer_init(PurpleXfer *xfer)
{
diff --git a/libpurple/protocols/jabber/google/google_session.h b/libpurple/protocols/jabber/google/google_session.h
--- a/libpurple/protocols/jabber/google/google_session.h
+++ b/libpurple/protocols/jabber/google/google_session.h
@@ -53,4 +53,5 @@ gboolean jabber_google_session_initiate(
void jabber_google_session_parse(JabberStream *js, const char *from,
JabberIqType type, const char *iq, xmlnode *session);
-#endif /* PURPLE_JABBER_GOOGLE_SESSION_H_ */
\ No newline at end of file
+void gtalk_xfer_send(PurpleConnection *gc, const char *who, const char*file);
+#endif /* PURPLE_JABBER_GOOGLE_SESSION_H_ */
diff --git a/libpurple/protocols/jabber/si.c b/libpurple/protocols/jabber/si.c
--- a/libpurple/protocols/jabber/si.c
+++ b/libpurple/protocols/jabber/si.c
@@ -38,6 +38,7 @@
#include "ibb.h"
#include "iq.h"
#include "si.h"
+#include "google/google_session.h"
#define STREAMHOST_CONNECT_TIMEOUT 15
#define ENABLE_FT_THUMBNAILS 0
More information about the Commits
mailing list