/soc/2013/ashmew2/filetransferX: 1b59b1ad1fc4: Getting GET Reque...
Ashish Gupta
ashmew2 at gmail.com
Fri Aug 23 03:21:22 EDT 2013
Changeset: 1b59b1ad1fc401ed21f9ace20cd91a0e0bc5603a
Author: Ashish Gupta <ashmew2 at gmail.com>
Date: 2013-08-22 17:29 +0530
Branch: filetransferX
URL: https://hg.pidgin.im/soc/2013/ashmew2/filetransferX/rev/1b59b1ad1fc4
Description:
Getting GET Request from GTalk
diffstat:
libpurple/protocols/jabber/google/google_session.c | 54 +++++++++++++++------
libpurple/protocols/jabber/google/google_session.h | 1 +
2 files changed, 40 insertions(+), 15 deletions(-)
diffs (155 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
@@ -418,6 +418,7 @@ gint gtalk_xfer_init_agent(GoogleSession
(GoogleAVSessionData *)session->session_data;
GoogleXferSessionData *share_session = session_data->share_session;
+ purple_debug_info("google_session", "Inside gtalk_xfer_init_agent\n");
if(!share_session)
return -1;
@@ -428,20 +429,21 @@ gint gtalk_xfer_init_agent(GoogleSession
agent = nice_agent_new_reliable (g_main_context_default(), NICE_COMPATIBILITY_GOOGLE);
stream_id = nice_agent_add_stream(agent, 1);
+ share_session->share_agent = agent;
- nice_agent_attach_recv (agent, stream_id, 1, g_main_context_default(),
+ nice_agent_attach_recv (share_session->share_agent, stream_id, 1, g_main_context_default(),
cb_nice_recv, share_session);
- g_signal_connect (G_OBJECT (agent), "candidate-gathering-done",
+ g_signal_connect (G_OBJECT (share_session->share_agent), "candidate-gathering-done",
G_CALLBACK (cb_candidate_gathering_done), session);
- g_signal_connect (G_OBJECT (agent), "new-selected-pair",
+ g_signal_connect (G_OBJECT (share_session->share_agent), "new-selected-pair",
G_CALLBACK (cb_new_selected_pair), NULL);
- g_signal_connect (G_OBJECT (agent), "component-state-changed",
+ g_signal_connect (G_OBJECT (share_session->share_agent), "component-state-changed",
G_CALLBACK (cb_nice_component_state_changed), session);
- g_signal_connect (G_OBJECT (agent), "reliable-transport-writable",
+ g_signal_connect (G_OBJECT (share_session->share_agent), "reliable-transport-writable",
G_CALLBACK (cb_nice_component_writable), NULL);
share_session->share_agent = agent;
@@ -927,10 +929,13 @@ FT XML:
session->remote_jid);
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,
gtalk_xfer_request_denied);
purple_xfer_set_read_fnc(share_session->xfer, gtalk_xfer_read);
+ purple_xfer_set_end_fnc(share_session->xfer, gtalk_xfer_end);
+
share_session->xfer->data = session;
share_session->buffer = purple_circ_buffer_new(65536);
@@ -982,7 +987,7 @@ FT XML:
NULL, NULL);
}
/*TODO: Uncomment the following?*/
-// gtalk_xfer_send_transport_accept(js, session, sess);
+ gtalk_xfer_send_transport_accept(js, session);
/**//*
ResponseIq2 = jabber_iq_new(js,JABBER_IQ_SET);
@@ -1394,8 +1399,17 @@ google_session_handle_terminate(JabberSt
{
GoogleAVSessionData *session_data =
(GoogleAVSessionData *) session->session_data;
-
- purple_media_end(session_data->media, NULL, NULL);
+ /* if(session_data->share)
+ {
+ TODO: Add destroy_session_stuff. Make sure to remove all the callbacks as well.
+
+ js->google_share_sessions = g_list_remove(js->google_share_sessions,session);
+ google_session_destroy(session);
+ purple_debug_info("google_session", "Destroyed gtalk_xfer session.\n");
+
+ }
+ else*/
+ purple_media_end(session_data->media, NULL, NULL);
}
static void
@@ -1742,6 +1756,13 @@ http_read_line(gchar *buffer, guint len)
return p;
}
+void
+gtalk_xfer_end(PurpleXfer *xfer)
+{
+ purple_debug_info("google_session", "Gtalk Xfer Ended.\n");
+}
+
+
gssize
gtalk_xfer_read(guchar **out_buffer, PurpleXfer *xfer)
{
@@ -1762,7 +1783,7 @@ gtalk_xfer_read(guchar **out_buffer, Pur
buffer += tmp;
purple_circ_buffer_mark_read(share_session->buffer, tmp);
}
-
+ purple_debug_info("google_session", "gtalk_xfer_read returning : %ld\n",size);
return size;
}
@@ -1775,8 +1796,8 @@ cb_nice_recv(NiceAgent *agent, guint str
GoogleXferSessionData *share_session = (GoogleXferSessionData *)data;
PurpleXfer *xfer = share_session->xfer;
gchar *curr = buf;
-
- purple_debug_info("google_session", "Received : \n%s\n", buf);
+
+/* purple_debug_info("google_session", "Received : \n%s\n", buf);*/
if (purple_xfer_get_type(xfer) == PURPLE_XFER_RECEIVE) {
if (share_session->channel_state ==
@@ -1813,13 +1834,15 @@ cb_nice_recv(NiceAgent *agent, guint str
purple_xfer_start(xfer, -1, NULL, 0);
}
/* otherwise the remaining headers would come in the next package
- not sure if this will ever happen */
-
+ not sure if this will ever happen */
} else if (share_session->channel_state ==
GTALK_XFER_CHANNEL_PARSED_HTTP_RESPONSE_HEADER) {
+ static int curlen = 0;
/* write data to transfer */
+ curlen+=len;
+
purple_debug_info("google-share",
- "got %d bytes to write to transfer\n", len);
+ "got %d bytes to write to transfer, CURLEN: %d\n", len, curlen);
if (len <= purple_xfer_get_bytes_remaining(xfer)) {
purple_circ_buffer_append(share_session->buffer, curr, len);
@@ -1831,7 +1854,8 @@ cb_nice_recv(NiceAgent *agent, guint str
}
}
} else if(purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) {
- purple_debug_info("google_session", "Inside cb_nice_recv for XFER_SEND..\n");
+ purple_debug_info("google_session", "Inside cb_nice_recv for XFER_SEND.Received : %s\n", buf);
+
/*TODO: Something to do*/
}
}
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
@@ -58,6 +58,7 @@ void gtalk_xfer_init(PurpleXfer *xfer);
void gtalk_xfer_request_denied(PurpleXfer *xfer);
gssize gtalk_xfer_read(guchar **out_buffer, PurpleXfer *xfer);
void gtalk_xfer_start(PurpleXfer *xfer);
+void gtalk_xfer_end(PurpleXfer *xfer);
void gtalk_xfer_send_transport_accept(JabberStream *js, GoogleSession *session);
void gtalk_xfer_send_accept(JabberStream *js, GoogleSession *session);
void gtalk_xfer_prepare_candidates(GoogleSession *session);
More information about the Commits
mailing list