/soc/2013/ashmew2/filetransferX: 90b7f5e0a506: Added gtalk_xfer_...
Ashish Gupta
ashmew2 at gmail.com
Mon Aug 19 19:25:51 EDT 2013
Changeset: 90b7f5e0a5065185c60dfce934b23577c9415760
Author: Ashish Gupta <ashmew2 at gmail.com>
Date: 2013-08-20 03:30 +0530
Branch: filetransferX
URL: https://hg.pidgin.im/soc/2013/ashmew2/filetransferX/rev/90b7f5e0a506
Description:
Added gtalk_xfer_cb() functions
diffstat:
libpurple/protocols/jabber/google/google_session.c | 65 ++++++++++++++++++---
libpurple/protocols/jabber/google/google_session.h | 2 +-
2 files changed, 56 insertions(+), 11 deletions(-)
diffs (130 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
@@ -59,6 +59,7 @@ typedef struct {
/*Needs to have a manifest Entry for Folder Sharing*/
NiceAgent *share_agent; /*TODO : Assess the usefulness of share_agent and stream_id*/
ShareChannel *share_channel;
+ gchar *channel_name;
NiceComponentState agent_state;
PurpleCircBuffer *buffer; /*Need to add something for HTTP_STATUS too */
guint stream_id;
@@ -833,10 +834,12 @@ google_session_handle_initiate(JabberStr
purple_debug_info("google_session", "manifest not NULL");
file = xmlnode_get_child(manifest, "file");
if( file ) {
- purple_debug_info("google_session", "file is not NULL");
+ purple_debug_info("google_session", "file is not NULL\n");
filename = xmlnode_get_child(file, "name");
+
filesize = atoi(xmlnode_get_attrib(file, "size"));
- purple_debug_info("google_session", "File size : %s",filesize);
+
+ purple_debug_info("google_session", "File size : %d",filesize);
session_data->share_session->filesize = g_ascii_strtoull((gchar *)xmlnode_get_attrib(file, "size"),NULL,10);
if( filename ) {
purple_debug_info("google_session", "Filename : %s",xmlnode_get_data_unescaped(filename));
@@ -897,7 +900,7 @@ FT XML:
share_session->xfer = purple_xfer_new(purple_connection_get_account(js->gc), PURPLE_XFER_RECEIVE,
session->remote_jid);
- purple_xfer_set_filename(share_session->xfer, filename);
+ purple_xfer_set_filename(share_session->xfer, xmlnode_get_data_unescaped(filename));
purple_xfer_set_size(share_session->xfer, filesize);
purple_xfer_set_init_fnc(share_session->xfer, gtalk_xfer_init);
purple_xfer_set_request_denied_fnc(share_session->xfer,
@@ -2054,7 +2057,42 @@ void gtalk_xfer_send_info(JabberStream *
jabber_iq_send(iq);
}
-void gtalk_xfer_send_accept(JabberStream *js, GoogleSession *session, xmlnode *sess)
+void
+gtalk_xfer_accept_cb(JabberStream *js, const gchar *from, JabberIqType type,
+ const gchar *id, xmlnode *sess, gpointer data)
+{
+ if (type != JABBER_IQ_RESULT) {
+ purple_debug_info("google_session", "Our Accept Request was REJECTED by Gtalk?. Should Abort.\n");
+ /*TODO: Make the session terminate gracefully here*/
+ }
+ else {
+ /*Send a channel*/
+ GoogleSession *session = (GoogleSession *) data;
+ GoogleAVSessionData *session_data = (GoogleAVSessionData *)session->session_data;
+ GoogleXferSessionData *share_session = session_data->share_session;
+
+ gchar *me = g_strdup_printf("%s@%s/%s",
+ session->js->user->node,
+ session->js->user->domain,
+ session->js->user->resource);
+
+ JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET);
+ xmlnode *sess = google_session_create_xmlnode(session, "info");
+ xmlnode *channel = xmlnode_new_child(sess, "channel");
+
+ share_session->channel_name = jabber_get_next_id(session->js); /*TODO: name can be private-1 ? :) */
+
+ xmlnode_set_namespace(channel, NS_GOOGLE_SESSION_SHARE);
+ xmlnode_set_attrib(channel, "name", share_session->channel_name);
+ xmlnode_set_attrib(iq->node, "to", session->remote_jid);
+ xmlnode_set_attrib(iq->node, "from", me);
+ xmlnode_insert_child(iq->node, sess);
+ jabber_iq_set_callback(iq, gtalk_xfer_channel_cb, session);
+ jabber_iq_send(iq);
+ }
+}
+
+void gtalk_xfer_send_accept(JabberStream *js, GoogleSession *session)
{
/*
TODO: CLEAN UP
@@ -2079,17 +2117,24 @@ TODO: CLEAN UP
description_node = xmlnode_new_child(session_node, "description");
xmlnode_set_attrib(session_node, "type", "accept");
- xmlnode_set_attrib(session_node, "id", xmlnode_get_attrib(sess, "id"));
+ xmlnode_set_attrib(session_node, "id", session->id.id);
xmlnode_set_attrib(session_node, "initiator", session->remote_jid);
xmlnode_set_namespace(session_node, NS_GOOGLE_SESSION);
-
+
xmlnode_new_child(description_node, "manifest");
protocol_node = xmlnode_new_child(description_node, "protocol");
xmlnode_new_child(protocol_node, "http");
+
+ xmlnode_set_namespace(description_node, NS_GOOGLE_SESSION_SHARE);
+ jabber_iq_set_callback(iq, gtalk_xfer_accept_cb, session);
+ jabber_iq_send(iq);
+}
- xmlnode_set_namespace(description_node, NS_GOOGLE_SESSION_SHARE);
-
- jabber_iq_send(iq);
+void
+gtalk_xfer_transport_accept_cb(JabberStream *js, const gchar *from,
+ JabberIqType type, const gchar *id, xmlnode *packet, gpointer data)
+{
+ gtalk_xfer_send_accept(js, (GoogleSession *)data);
}
void
@@ -2111,7 +2156,7 @@ gtalk_xfer_send_transport_accept(JabberS
xmlnode_set_namespace(session_node, NS_GOOGLE_SESSION);
xmlnode_set_namespace(transport_node, NS_GOOGLE_TRANSPORT_P2P);
-
+ jabber_iq_set_callback(iq, gtalk_xfer_transport_accept_cb, session);
jabber_iq_send(iq);
/*TODO : Remove these temporary lines and put at their appropriate location :
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
@@ -59,7 +59,7 @@ void gtalk_xfer_request_denied(PurpleXfe
void gtalk_xfer_read(PurpleXfer *xfer);
void gtalk_xfer_start(PurpleXfer *xfer);
void gtalk_xfer_send_transport_accept(JabberStream *js, GoogleSession *session);
-void gtalk_xfer_send_accept(JabberStream *js, GoogleSession *session, xmlnode *sess);
+void gtalk_xfer_send_accept(JabberStream *js, GoogleSession *session);
void gtalk_xfer_prepare_candidates(GoogleSession *session);
void gtalk_xfer_send_candidates(GoogleSession *session);
More information about the Commits
mailing list