/soc/2013/ashmew2/filetransferX: 5b7397d874f2: Added details to ...
Ashish Gupta
ashmew2 at gmail.com
Mon Aug 19 19:25:51 EDT 2013
Changeset: 5b7397d874f2264b82ccafb0e0970ecf300ba6fe
Author: Ashish Gupta <ashmew2 at gmail.com>
Date: 2013-08-20 02:35 +0530
Branch: filetransferX
URL: https://hg.pidgin.im/soc/2013/ashmew2/filetransferX/rev/5b7397d874f2
Description:
Added details to xfer
diffstat:
libpurple/protocols/jabber/google/google_session.c | 52 +++++++++++++++------
1 files changed, 36 insertions(+), 16 deletions(-)
diffs (125 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
@@ -91,6 +91,14 @@ typedef struct {
*/
+void cb_candidate_gathering_done(NiceAgent *agent, guint stream_id, gpointer user_data);
+void cb_nice_component_state_changed(NiceAgent *agent,guint stream_id, guint component_id,
+ guint state, gpointer user_data);
+void cb_nice_recv(NiceAgent *agent, guint stream_id, guint component_id,
+ guint len, gchar *buf, gpointer data);
+void cb_nice_component_writable(NiceAgent *agent, guint stream_id, guint component_id,
+ gpointer user_data);
+
static gboolean
google_session_id_equal(gconstpointer a, gconstpointer b)
{
@@ -435,7 +443,7 @@ jabber_google_relay_response_session_ini
GoogleXferSessionData *share_session = session_data->share_session;
agent = share_session->share_agent;
- if(!share_session->share_agent) {
+ if(!share_session->share_agent) {/*TODO: Should probably have an agent_init function..Later..*/
agent = nice_agent_new_reliable (NULL, NICE_COMPATIBILITY_RFC5245);
share_session->stream_id = nice_agent_add_stream(agent, 1);
stream_id = share_session->stream_id;
@@ -463,7 +471,7 @@ jabber_google_relay_response_session_ini
}
nice_agent_attach_recv(agent, stream_id, 1, g_main_context_default(),
- google_share_data_received_cb, session);
+ cb_nice_recv, session);
g_signal_connect(G_OBJECT(agent), "candidate-gathering-done",
G_CALLBACK(cb_candidate_gathering_done), session);
g_signal_connect(G_OBJECT(agent), "reliable-transport-writable",
@@ -476,6 +484,8 @@ jabber_google_relay_response_session_ini
purple_debug_info("google_session", "share_agent is NULL in relab_cb! Returning..\n");
/*Set up other stuff for NiceAgent TODO*/
/*TODO : Return for now, trying to receive a file from GTalk, otherwise we went on with the relay_candidate_* set up..*/
+/*TODO: The point here is that the share_agent will ALWAYS BE NULL when receiving a file because we are not changing it in
+ handle_initiate() */
return;
}
else {
@@ -535,7 +545,7 @@ jabber_google_relay_response_session_ini
}
session_data->media = purple_media_manager_create_media(
- purple_media_manager_get(),v
+ purple_media_manager_get(),
purple_connection_get_account(js->gc),
"fsrtpconference", session->remote_jid, TRUE);
@@ -801,8 +811,8 @@ google_session_handle_initiate(JabberStr
else {
xmlnode *description = xmlnode_get_child(sess, "description");
xmlnode *manifest,*file,*filename,*protocol,*http,*url_source_path,*url_preview_path,*transport;
- char *filesize;
- JabberIq *result_iq, *set_iq,*ResponseIq;
+ guint filesize;
+ JabberIq *result_iq, *set_iq,*result;
char *responsetxt;
int responsetxtlen;
xmlnode *tmp;
@@ -821,7 +831,7 @@ google_session_handle_initiate(JabberStr
if( file ) {
purple_debug_info("google_session", "file is not NULL");
filename = xmlnode_get_child(file, "name");
- filesize = xmlnode_get_attrib(file, "size");
+ filesize = atoi(xmlnode_get_attrib(file, "size"));
purple_debug_info("google_session", "File size : %s",filesize);
session_data->share_session->filesize = g_ascii_strtoull((gchar *)xmlnode_get_attrib(file, "size"),NULL,10);
if( filename ) {
@@ -880,7 +890,18 @@ FT XML:
/*Add the GoogleSession *session to the GList*/
js->google_share_sessions = g_list_prepend(js->google_share_sessions, session);
purple_debug_info("google_session", "We have received a file request.\n");
-
+
+ session_data->xfer = purple_xfer_new(account, PURPLE_XFER_RECEIVE,
+ session->remote_jid);
+ purple_xfer_set_filename(session_data->xfer, filename);
+ purple_xfer_set_size(session_data->xfer, filesize);
+ purple_xfer_set_init_fnc(session_data->xfer, google_share_init);
+ purple_xfer_set_request_denied_fnc(session_data->xfer,
+ google_share_request_denied);
+ purple_xfer_set_read_fnc(session_data->xfer, google_share_read);
+ session_data->xfer->data = session;
+ session_data->buffer = purple_circ_buffer_new(65536);
+
/*
purple_debug_info("google_session", "Sending a file request in return\n");
jabber_send_raw(js,temp,strlen(temp));
@@ -916,6 +937,11 @@ FT XML:
*/
/*TODO : Fix name for ResponseIq */
+ result = jabber_iq_new(js,JABBER_IQ_RESULT);
+ xmlnode_set_attrib(result->node, "to", session->remote_jid);
+ jabber_iq_set_id(result, iq_id);
+ jabber_iq_send(result);
+
if (js->google_relay_host && js->google_relay_token) {
jabber_google_do_relay_request(js, session,
jabber_google_relay_response_session_initiate_cb);
@@ -923,15 +949,9 @@ FT XML:
jabber_google_relay_response_session_initiate_cb(session, NULL, 0, 0, 0,
NULL, NULL);
}
-
- ResponseIq = jabber_iq_new(js,JABBER_IQ_RESULT);
- xmlnode_set_attrib(ResponseIq->node, "to", session->remote_jid);
- jabber_iq_set_id(ResponseIq, iq_id);
- purple_debug_info("google_session", "handle_initiate() : ResponseIq->id : %s\n",ResponseIq->id);
- jabber_iq_send(ResponseIq);
-
- gtalk_xfer_send_transport_accept(js, session, sess);
- /*
+ /*TODO: Uncomment the following?*/
+// gtalk_xfer_send_transport_accept(js, session, sess);
+ /**//*
ResponseIq2 = jabber_iq_new(js,JABBER_IQ_SET);
xmlnode_set_attrib(ResponseIq2->node, "to", session->remote_jid);
More information about the Commits
mailing list