/soc/2013/ashmew2/filetransferX: c45927ddfa19: Added gtalk_xfer_...
Ashish Gupta
ashmew2 at gmail.com
Mon Aug 19 19:25:51 EDT 2013
Changeset: c45927ddfa198f820230db66e90bf29d13fbb5fe
Author: Ashish Gupta <ashmew2 at gmail.com>
Date: 2013-08-20 02:59 +0530
Branch: filetransferX
URL: https://hg.pidgin.im/soc/2013/ashmew2/filetransferX/rev/c45927ddfa19
Description:
Added gtalk_xfer_ functions
diffstat:
libpurple/protocols/jabber/google/google_session.c | 56 ++++++++++++++-------
libpurple/protocols/jabber/google/google_session.h | 4 +-
2 files changed, 40 insertions(+), 20 deletions(-)
diffs (150 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
@@ -443,7 +443,9 @@ jabber_google_relay_response_session_ini
GoogleXferSessionData *share_session = session_data->share_session;
agent = share_session->share_agent;
- if(!share_session->share_agent) {/*TODO: Should probably have an agent_init function..Later..*/
+ if(!share_session->share_agent) {/*TODO: Should probably have an agent_init function for this..Later..*/
+ purple_xfer_request(share_session->xfer);
+
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;
@@ -755,7 +757,9 @@ google_session_handle_initiate(JabberStr
const gchar *xmlns;
GoogleAVSessionData *session_data =
(GoogleAVSessionData *) session->session_data;
-
+ GoogleXferSessionData *share_session =
+ session_data->share_session;
+
purple_debug_info("google_session", "Inside google_session_handle_initiate");
if (session->state != UNINIT) {
@@ -891,16 +895,16 @@ FT XML:
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,
+ share_session->xfer = purple_xfer_new(purple_connection_get_account(js->gc), 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_xfer_set_filename(share_session->xfer, 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);
+ share_session->xfer->data = session;
+ share_session->buffer = purple_circ_buffer_new(65536);
/*
purple_debug_info("google_session", "Sending a file request in return\n");
@@ -1952,6 +1956,17 @@ void gtalk_xfer_send_initiate(PurpleXfer
jabber_iq_send(iq);
}
+void
+gtalk_xfer_request_denied(PurpleXfer *xfer)
+{
+ purple_debug_info("google_session", "Request denied by user..\n");
+}
+
+void
+gtalk_xfer_read(PurpleXfer *xfer)
+{
+ purple_debug_info("google_session", "Inside gtalk_xfer_read()..\n");
+}
void
gtalk_xfer_init(PurpleXfer *xfer)
@@ -1959,10 +1974,12 @@ gtalk_xfer_init(PurpleXfer *xfer)
GoogleSession *session = (GoogleSession *)(xfer->data);
GoogleAVSessionData *session_data = (GoogleAVSessionData *)session->session_data;
GoogleXferSessionData *share_session = session_data->share_session;
- GList *iter;
+ JabberStream *js = session->js;
+
+/* GList *iter;
PurpleNetworkListenData *portdata = purple_network_listen_range_family
(27015, 64000, AF_INET, SOCK_STREAM, gtalk_port_cb, xfer);
- JabberStream *js = session->js;
+
purple_debug_info("google_session", "Inside gtalk_xfer_init() \n");
purple_debug_info("google_session", "We have a file now. Details of Xfer :\nwho : %s\nfilename:%s\nlocal_filename:%s\nsize:%d\nlocal_port : %d\nremote_port:%d\nremote_ip:%s\nBytes Sent:%d\nBytes Remaining:%d\n",xfer->who,xfer->filename,xfer->local_filename,xfer->size,xfer->local_port,xfer->remote_port,xfer->remote_ip,xfer->bytes_sent,xfer->bytes_remaining);
@@ -1988,7 +2005,8 @@ gtalk_xfer_init(PurpleXfer *xfer)
NULL, NULL);
}
*/
- gtalk_xfer_send_initiate(xfer);
+/* TODO:Uncomment above and below?*/
+/* gtalk_xfer_send_initiate(xfer);*/
/**TODO: IP.PORT etc should all be in the GoogleSession thing? I guess so.*/
/*TODO: xfer->local_port set in the gtalk_port_cb() */
@@ -2007,7 +2025,7 @@ gtalk_xfer_init(PurpleXfer *xfer)
gtalk_xfer_start(xfer);
*/
// purple_xfer_start( xfer, -1, xfer->remote_ip, xfer->remote_port );
-
+ gtalk_xfer_send_transport_accept(js, session);
}
void gtalk_xfer_send_info(JabberStream *js, GoogleSession *session, xmlnode *sess)
@@ -2075,11 +2093,11 @@ TODO: CLEAN UP
}
void
-gtalk_xfer_send_transport_accept(JabberStream *js, GoogleSession *session, xmlnode *sess)
+gtalk_xfer_send_transport_accept(JabberStream *js, GoogleSession *session)
{
JabberIq *iq;
xmlnode *session_node, *transport_node;
-
+
purple_debug_info("google_session", "Inside google_xfer_send_transport_accept()\n");
iq = jabber_iq_new(js, JABBER_IQ_SET);
xmlnode_set_attrib(iq->node, "to", session->remote_jid);
@@ -2088,7 +2106,7 @@ gtalk_xfer_send_transport_accept(JabberS
transport_node = xmlnode_new_child(session_node, "transport");
xmlnode_set_attrib(session_node, "type", "transport-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);
@@ -2096,7 +2114,7 @@ gtalk_xfer_send_transport_accept(JabberS
jabber_iq_send(iq);
-/*TODO : Remove these temporary lines and put at their appropriate location : */
+/*TODO : Remove these temporary lines and put at their appropriate location :
gtalk_xfer_send_accept(js, session, sess);
gtalk_xfer_send_info(js, session, sess);
/*************************************************************/
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
@@ -55,8 +55,10 @@ void jabber_google_session_parse(JabberS
void gtalk_xfer_send(PurpleConnection *gc, const char *who, const char*file);
void gtalk_xfer_init(PurpleXfer *xfer);
+void gtalk_xfer_request_denied(PurpleXfer *xfer);
+void gtalk_xfer_read(PurpleXfer *xfer);
void gtalk_xfer_start(PurpleXfer *xfer);
-void gtalk_xfer_send_transport_accept(JabberStream *js, GoogleSession *session, xmlnode *sess);
+void gtalk_xfer_send_transport_accept(JabberStream *js, GoogleSession *session);
void gtalk_xfer_send_accept(JabberStream *js, GoogleSession *session, xmlnode *sess);
void gtalk_xfer_prepare_candidates(GoogleSession *session);
void gtalk_xfer_send_candidates(GoogleSession *session);
More information about the Commits
mailing list