/soc/2013/ashmew2/filetransferX: f14e6f37c3ff: Relocating functi...
Ashish Gupta
ashmew2 at gmail.com
Sun Aug 18 07:53:45 EDT 2013
Changeset: f14e6f37c3ff8c3b36d74c83dc00957772035697
Author: Ashish Gupta <ashmew2 at gmail.com>
Date: 2013-08-17 16:55 +0530
Branch: filetransferX
URL: https://hg.pidgin.im/soc/2013/ashmew2/filetransferX/rev/f14e6f37c3ff
Description:
Relocating function calls
diffstat:
libpurple/protocols/jabber/google/google_session.c | 92 ++++++++++++++-------
libpurple/protocols/jabber/google/google_session.h | 3 +
2 files changed, 63 insertions(+), 32 deletions(-)
diffs (252 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
@@ -417,6 +417,8 @@ jabber_google_relay_response_session_ini
session_data->share_session;
NiceCandidate *relay_candidate_udp, *relay_candidate_tcp;
NiceCandidate *relay_candidate_ssltcp;
+ guint stream_id;
+ NiceAgent *agent;
if(session_data->share) {
/*TODO: Relocate? Define a new function? Only time will tell :P
@@ -425,19 +427,24 @@ jabber_google_relay_response_session_ini
return;
*/
GoogleXferSessionData *share_session = session_data->share_session;
- NiceAgent *agent = nice_agent_new_reliable (NULL, NICE_COMPATIBILITY_RFC5245);
- guint stream_id;
-
- /*Add relay candidates to our candidate list?*/
+
+ if(!share_session->share_agent) {
+ agent = nice_agent_new_reliable (NULL, NICE_COMPATIBILITY_RFC5245);
+ /*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'
*/
-
- share_session->share_agent = agent;
- stream_id = nice_agent_add_stream (agent, 1);
- share_session->stream_id = stream_id;
-
+ purple_debug_info("google_session", "share_agent is NULL in relab_cb!\n");
+ share_session->share_agent = agent;
+ stream_id = nice_agent_add_stream (agent, 1);
+ share_session->stream_id = stream_id;
+/*Set up other stuff for NiceAgent TODO*/
+
+ }
+ else {
+ purple_debug_info("google_session", "share_agent is NOT NULL\n");
+ }
/*TODO: Add candidates here to the local_candidates GList in GoogleXferSessionData;*/
-
+
relay_candidate_udp = nice_candidate_new(NICE_CANDIDATE_TYPE_RELAYED);
relay_candidate_udp->transport = NICE_CANDIDATE_TRANSPORT_UDP;
relay_candidate_udp->priority = 0;
@@ -453,9 +460,9 @@ jabber_google_relay_response_session_ini
relay_candidate_ssltcp = nice_candidate_copy(relay_candidate_udp);
nice_address_set_port(&relay_candidate_ssltcp->addr, relay_ssltcp);
- share_session->local_share_candidates = g_list_prepend(share_session->local_share_candidates, relay_candidate_udp);
- share_session->local_share_candidates = g_list_prepend(share_session->local_share_candidates, relay_candidate_tcp);
- share_session->local_share_candidates = g_list_prepend(share_session->local_share_candidates, relay_candidate_ssltcp);
+ 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");
@@ -465,7 +472,7 @@ jabber_google_relay_response_session_ini
purple_debug_info("google_session","Setting Relay on Niceagent Failed..\n");
else
purple_debug_info("google_session","Setting Relay on Niceagent Succeeded..\n");
-
+ gtalk_xfer_send_candidates(session);
return;
}
@@ -905,7 +912,8 @@ google_session_handle_info(JabberStream
share_session->share_channel->stream_id = share_session->stream_id;
share_session->share_channel->agent = share_session->share_agent;
share_session->share_channel->name = g_strdup(xmlnode_get_attrib(channel, "name"));
-
+ share_session->share_channel->component_id = 1; /*TODO: Check if this will be 1 or NOT or something else*/
+
if(share_session->share_agent)
purple_debug_info("google_session", "Added a channel !\n");
else
@@ -916,6 +924,8 @@ google_session_handle_info(JabberStream
jabber_iq_set_id(iq, iq_id);
xmlnode_set_attrib(iq->node, "to", session->remote_jid);
jabber_iq_send(iq);
+ /*TODO: Finding a good place for calling prepare candidates*/
+ gtalk_xfer_prepare_candidates(session);
}
static void
@@ -1085,53 +1095,60 @@ static void
gtalk_xfer_handle_candidates(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id)
{/*<iq to="doondoon1234 at gmail.com/F0529E73" type="set" id="249" from="ashmew2 at gmail.com/Talk.v1040217A105"><session type="transport-info" id="1195983148" initiator="ashmew2 at gmail.com/Talk.v1040217A105" xmlns="http://www.google.com/session"><transport xmlns="http://www.google.com/transport/p2p"><candidate name="private-1" address="10.0.2.15" port="58919" preference="1" username="j8xIQAN/LvaC/dxb" protocol="udp" generation="0" password="eEy12J+BFBmZO0jj" type="local" network="0"/></transport></session></iq>*/
- NiceCandidate *candid;
+ NiceCandidate *candid = nice_candidate_new(NICE_CANDIDATE_TYPE_HOST);
GSList *candidate_list = NULL;
xmlnode *candidate_node;
- GoogleAVSession *session_data = (GoogleAVSessionData*)session->session_data;
+ GoogleAVSessionData *session_data = (GoogleAVSessionData*)session->session_data;
GoogleXferSessionData *share_session = session_data->share_session;
+ purple_debug_info("google_session", "Inside gtalk_xfer_handle_candidates..\n");
+
if(sess)
candidate_node = xmlnode_get_child(xmlnode_get_child(sess, "transport"), "candidate");
- if(candidate) {
+ if(candidate_node) {
gchar *type = xmlnode_get_attrib(candidate_node, "type");
+ purple_debug_info("google_session", "Reached Here..0\n");
candid->type = (!strcmp(type, "local") ? NICE_CANDIDATE_TYPE_HOST :
!strcmp(type, "stun") ? NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE :
!strcmp(type, "relay") ? NICE_CANDIDATE_TYPE_RELAYED :
NICE_CANDIDATE_TYPE_HOST);
+
if(!strcmp(xmlnode_get_attrib(candidate_node, "protocol"), "udp"))
candid->transport = NICE_CANDIDATE_TRANSPORT_UDP;
else {
purple_debug_info("google_session", "Remote Candidate is not UDP...Returning..\n");
return;
}
+ purple_debug_info("google_session", "Reached Here..1\n");
nice_address_init(&candid->addr);
nice_address_set_from_string(&candid->addr, xmlnode_get_attrib(candidate_node, "address"));
nice_address_set_port(&candid->addr, atoi(xmlnode_get_attrib(candidate_node, "port")));
candid->stream_id = share_session->stream_id;
- candid->username = g_strdup(xmlnode_get_attrib("username"));
+ purple_debug_info("google_session", "Reached Here..2\n");
+ candid->username = g_strdup(xmlnode_get_attrib(candidate_node, "username"));
if(!candid->username)
candid->username = g_strdup("");
- candid->password = g_strdup(xmlnode_get_attrib("password"));
+ candid->password = g_strdup(xmlnode_get_attrib(candidate_node, "password"));
if(!candid->password)
candid->password = g_strdup("");
-
+ purple_debug_info("google_session", "Reached Here..3\n");
candidate_list = g_slist_append(candidate_list, candid);
nice_agent_set_remote_candidates(share_session->share_agent,
- share_session->stream_id, share_session->share_chanel->component_id,
+ share_session->stream_id, share_session->share_channel->component_id,
candidate_list);
g_slist_free(candidate_list);
}
purple_debug_info("google_session", "Added remote candidate to Nice Agent.\n");
-
}
static void
google_session_handle_transport_info(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id)
{
GoogleAVSessionData *session_data = (GoogleAVSessionData *)session->session_data;
+ purple_debug_info("google_session", "Inside handle_transport_info..\n");
+
if(session_data->share)
gtalk_xfer_handle_candidates(js, session, sess, iq_id);
else
@@ -1239,7 +1256,7 @@ gtalk_port_cb(int listenfd, gpointer dat
}
-static void
+void
gtalk_xfer_send_candidates(GoogleSession *session)
{
@@ -1372,7 +1389,7 @@ cb_candidate_gathering_done(NiceAgent *a
candid->password = g_strdup(local_password);
/*Insert it into our GoogleXferSession's local_share_candidates*/
- share_session->local_share_candidates = g_list_append(share_session->local_share_candidates, candid);
+ share_session->local_share_candidates = g_list_prepend(share_session->local_share_candidates, candid);
/*TODO: local_share_candidates are being added to the list here itself. What about the part that follows?
Shouldn't relay candidates and these candidates be togeter?*/
}
@@ -1391,15 +1408,15 @@ cb_candidate_gathering_done(NiceAgent *a
/*TODO: Once the candidates have beeng gthered, we must send out our GList of NiceCandidates.
Call gtalk_xfer_send_candidates() Here .
-*/
- gtalk_xfer_send_candidates(session);
+
+gtalk_xfer_send_candidates(session);*/
}
void
cb_nice_recv(NiceAgent *agent, guint stream_id, guint component_id,
guint len, gchar *buf, gpointer data)
{
-//dummy function
+ purple_debug_info("google_session", "Inside cb_nice_recv\n");
}
char *nice_component_state_to_str(guint state)
@@ -1482,7 +1499,18 @@ This will most probably end in successfu
purple_debug_info("google_session", "Agent's stun was not NULL.");
gloop = g_main_loop_new(NULL, FALSE);
-
+
+/*Sending relay request to Google's Relay Server..*/
+ if (js->google_relay_host && js->google_relay_token) {
+ purple_debug_info("google_session", "Calling do_relay_request()..\n");
+ jabber_google_do_relay_request(js, session,
+ jabber_google_relay_response_session_initiate_cb);
+ } else {
+ purple_debug_info("google_session", "FAILED TO Call do_relay_request()..Just the cb\n");
+ jabber_google_relay_response_session_initiate_cb(session, NULL, 0, 0, 0,
+ NULL, NULL);
+ }
+
purple_debug_info("google_session", "Inside send candids\n");
temp_struct->agent = agent;
// Connect the signals
@@ -1524,7 +1552,9 @@ This will most probably end in successfu
g_main_loop_run (gloop);
g_main_loop_unref(gloop); /*TODO: Check if gloop is causing a CRASH when Destroying pidgin instance*/
g_object_unref(agent); /*Something here is causing a CRASH on destroying pidgin..Find out what! TODO*/
-
+
+ /*relay information gathering : */
+
return;
}
@@ -1731,7 +1761,6 @@ void gtalk_xfer_send_initiate(PurpleXfer
transport_node = xmlnode_new_child(session_node, "transport");
xmlnode_set_namespace(transport_node, NS_GOOGLE_TRANSPORT_P2P);
- purple_debug_info("google_session", "We send this init thing : \n%s\n",xmlnode_to_str(session_node, &size));
js->google_share_sessions = g_list_prepend(js->google_share_sessions, session);
jabber_iq_send(iq);
@@ -1932,7 +1961,6 @@ google_session_parse_iq(JabberStream *js
purple_debug_info("google_session", "Inside transport-accept handle block..Calling it now..\n");
google_session_handle_transport_accept(js, session, sess, iq_id);
} else if (!strcmp(type, "transport-info")) {
- gtalk_xfer_prepare_candidates(session);
google_session_handle_transport_info(js, session, sess, iq_id);
// google_xfer_send(js,session); TODO: Clean up a bit.
// purple_debug_info("google_session", "Back in parse_iq\n");
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,4 +58,7 @@ void gtalk_xfer_init(PurpleXfer *xfer);
void gtalk_xfer_start(PurpleXfer *xfer);
void gtalk_xfer_send_transport_accept(JabberStream *js, GoogleSession *session, xmlnode *sess);
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);
+
#endif /* PURPLE_JABBER_GOOGLE_SESSION_H_ */
More information about the Commits
mailing list