/soc/2013/ashmew2/filetransferX: aa080c4d9a98: Successfully rece...
Ashish Gupta
ashmew2 at gmail.com
Mon Sep 9 05:39:06 EDT 2013
Changeset: aa080c4d9a989ec878232e20cc831c25812dec45
Author: Ashish Gupta <ashmew2 at gmail.com>
Date: 2013-09-09 15:08 +0530
Branch: filetransferX
URL: https://hg.pidgin.im/soc/2013/ashmew2/filetransferX/rev/aa080c4d9a98
Description:
Successfully receive BIG files from GTalk and send End Of Transfer to Gtalk
diffstat:
libpurple/protocols/jabber/google/google_session.c | 81 +++++++++++++++------
1 files changed, 56 insertions(+), 25 deletions(-)
diffs (173 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
@@ -523,12 +523,12 @@ jabber_google_relay_response_session_ini
/*Add relay candidates to our candidate list?*/
/* * candidate address='49.248.181.68' port='46448' username='HKmLfAkZB81f7r8x' password='' preference='0.000000' protocol='udp' type='stun' component='1' network='0' generation='0' name='private-1'
*/
- purple_debug_info("google_session", "share_agent is NULL in relab_cb! Adding relay candids manually ..\n");
+ purple_debug_info("google_session", "share_agent is NULL in relab_cb! Not adding manually the candidates. ..\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() */
-
+/*
relay_candidate_udp = nice_candidate_new(NICE_CANDIDATE_TYPE_RELAYED);
relay_candidate_udp->transport = NICE_CANDIDATE_TRANSPORT_UDP;
relay_candidate_udp->priority = 0;
@@ -552,8 +552,8 @@ jabber_google_relay_response_session_ini
share_session->local_share_candidates = g_list_append(share_session->local_share_candidates, relay_candidate_udp);
// share_session->local_share_candidates = g_list_append(share_session->local_share_candidates, relay_candidate_tcp);
// share_session->local_share_candidates = g_list_append(share_session->local_share_candidates, relay_candidate_ssltcp);
-
- purple_debug_info("google_session", "Added relay candidates without a crash.\n");
+*/
+ purple_debug_info("google_session", "Did not add candidates manually.\n");
return;
}
else {
@@ -1048,6 +1048,7 @@ gtalk_xfer_handle_info(JabberStream *js
/*TODO: Finding a good place for calling prepare candidates*/
/*TODO: Uncomment prepare_candidates*/
/*TODO: Judge the utility of gtalk_xfer_prepare_candidates(session)*/
+ purple_debug_info("google_session", "Calling gather candidates..\n");
nice_agent_gather_candidates(share_session->share_agent, share_session->stream_id);
/* gtalk_xfer_prepare_candidates(session);*/
@@ -1772,6 +1773,34 @@ http_read_line(gchar *buffer, guint len)
void
gtalk_xfer_end(PurpleXfer *xfer)
{
+
+/*TODO: Send this XML stanza in order to say that the transfer is finished. We must send this, otherwise GTalk will keep
+ thinking that the xfer is still ongoing
+ <iq to="doondoon1234 at gmail.com/24E670D3" type="set" id="102" from="ashmew2 at gmail.com/Talk.v1048DA41A6C"><session type="info" id="purple4bbd2553" initiator="doondoon1234 at gmail.com/24E670D3" xmlns="http://www.google.com/session"><complete xmlns="http://www.google.com/session/share"/></session></iq>
+
+*/
+/*The following is only for PURPLE_XFER_RECEIVE...Should add something for PURPLE_XFER_SEND asap..TODO*/
+ GoogleSession *session = (GoogleSession *) xfer->data;
+ GoogleAVSessionData *session_data =
+ (GoogleAVSessionData *) session->session_data;
+ GoogleXferSessionData *share_session = session_data->share_session;
+ JabberStream *js = session->js;
+ JabberIq *iq = jabber_iq_new(js, JABBER_IQ_SET);
+ xmlnode *complete_node, *session_node;
+
+ xmlnode_set_attrib(iq->node, "to", session->remote_jid);
+
+ session_node = xmlnode_new_child(iq->node, "session");
+ xmlnode_set_attrib(session_node, "type", "info");
+ 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);
+
+ complete_node = xmlnode_new_child(session_node, "complete");
+ xmlnode_set_namespace(complete_node, NS_GOOGLE_SESSION_SHARE);
+
+ jabber_iq_send(iq);
+
purple_debug_info("google_session", "Gtalk Xfer Ended.\n");
}
@@ -1810,7 +1839,7 @@ cb_nice_recv(NiceAgent *agent, guint str
PurpleXfer *xfer = share_session->xfer;
gchar *curr = buf;
- purple_debug_info("google_session", "Inside cb_nice_recv. Received : %s", buf);
+/* purple_debug_info("google_session", "Inside cb_nice_recv. Received : %s", buf);*/
if(purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) {
purple_debug_info("google_session", "Inside cb_nice_recv for XFER_SEND.Received : %s\n", buf);
@@ -1838,19 +1867,19 @@ cb_nice_recv(NiceAgent *agent, guint str
purple_debug_info("google_session", "Filesize is : %llu", xfer->size);
/*Share_session->fileize should probably have xfer->size's value*/
share_session->channel_state = GTALK_XFER_CHANNEL_HTTP_OK_SENT;
- share_session->channel_state = GTALK_XFER_CHANNEL_HTTP_SENDING;
- purple_debug_info("google_session", "\nChanged to _SENDING, Bytes remaining: %llu",
- purple_xfer_get_bytes_remaining(xfer));
+
share_session->file_to_send = fopen(share_session->xfer->local_filename, "rb");
+
+ if(share_session->agent_state == NICE_COMPONENT_STATE_READY) {
+ share_session->channel_state = GTALK_XFER_CHANNEL_HTTP_SENDING;
+ purple_debug_info("google_session", "Calling component_writable for initiating transfer..");
+ cb_nice_component_writable(share_session->share_agent, share_session->stream_id,
+ 1, share_session);
+ }
/*TODO: The file_to_send pointer remains open as long as the file hasn't been sent..there seems to be some issue with
fseeking the file from the SEEK_SET always, Trying to acheive desired results with SEEK_CUR"
*/
- purple_debug_info("google_session", "Calling component_writable..\n");
-/*TODO: Remove the call to writable..*/
- cb_nice_component_writable(share_session->share_agent, share_session->stream_id,
- 1, share_session);
-
/* fread_ret = fread(file_buf, 1, 65530, file_ptr);
send_ret = nice_agent_send(share_session->share_agent, share_session->stream_id, 1,
@@ -2020,7 +2049,7 @@ void cb_nice_component_state_changed(Nic
return;
}
- if(state == NICE_COMPONENT_STATE_READY) {
+ if(purple_xfer_get_type(share_session->xfer) == PURPLE_XFER_SEND) {
GSList *remote_candids = nice_agent_get_remote_candidates(agent, stream_id, component_id);
GSList *local_candids = nice_agent_get_local_candidates(agent, stream_id, component_id);
@@ -2046,14 +2075,15 @@ void cb_nice_component_state_changed(Nic
local_candids = local_candids->next;
}
purple_debug_info("google_session", "***********\n");
- g_signal_stop_emission_by_name(G_OBJECT(share_session->share_agent),"component-state-changed");
+/* g_signal_stop_emission_by_name(G_OBJECT(share_session->share_agent),"component-state-changed");*/
/*TODO: Check if another way can be worked out without disconnecting the component-state-changed signal..*/
-
- purple_debug_info("google_session", "Disconnected the component-state-changed signal..");
- cb_nice_component_writable(share_session->share_agent, share_session->stream_id,
- 1, share_session);
-
+ if(share_session->channel_state == GTALK_XFER_CHANNEL_HTTP_OK_SENT) {
+ share_session->channel_state = GTALK_XFER_CHANNEL_HTTP_SENDING;
+ purple_debug_info("google_session", "Disconnected the component-state-changed signal..");
+ cb_nice_component_writable(share_session->share_agent, share_session->stream_id,
+ 1, share_session);
+ }
}
if(state == NICE_COMPONENT_STATE_READY &&
@@ -2082,6 +2112,8 @@ void cb_nice_component_state_changed(Nic
FILE *file_ptr = share_session->file_to_send;
purple_debug_info("google_session", "STATE_READY for XFER_SEND! in cb_component_state_changed.");
+
+
// purple_debug_info("google_session", "xfer->local_filename = %s\n",share_session->xfer->local_filename);
/* if(share_session->channel_state == GTALK_XFER_CHANNEL_HTTP_OK_SENT) {
cb_nice_component_writable(share_session->share_agent, share_session->stream_id, 1,
@@ -2227,11 +2259,10 @@ void cb_nice_component_writable(NiceAgen
purple_debug_info("google_session", "_WRITABLE NOW ! (Inside cb_nice_component_writable\n");
- if(share_session->agent_state!=NICE_COMPONENT_STATE_READY) {
- purple_debug_info("google_session", "returning from _writable as state!=READY..\n");
- return;
+ if(share_session->agent_state != NICE_COMPONENT_STATE_READY) {
+ purple_debug_info("google_session", "Inside _writable state!=READY..\n");
}
-
+
if(share_session->channel_state == GTALK_XFER_CHANNEL_HTTP_SENDING) {
purple_debug_info("google_session", "Checking for file_buf is NULL or not..");
@@ -2384,7 +2415,7 @@ void cb_nice_component_writable(NiceAgen
void cb_new_selected_pair(NiceAgent *agent, guint stream_id, guint component_id,
gchar *lfoundation, gchar *rfoundation, gpointer user_data)
{
- purple_debug_info("google_session", "__GOT NEW SELECTED PAIR! with %s:%s", lfoundation, rfoundation);
+ purple_debug_info("google_session", "__GOT NEW SELECTED PAIR! with %s:%s\n", lfoundation, rfoundation);
}
void cb_new_candidate(NiceAgent *agent, guint stream_id, guint component_id,
More information about the Commits
mailing list