/soc/2013/ashmew2/filetransferY: 331d25ab4fc0: Shifted code from...
Ashish Gupta
ashmew2 at gmail.com
Sat Feb 1 07:55:20 EST 2014
Changeset: 331d25ab4fc0d25df47b0468fbc8528e6b19ad3a
Author: Ashish Gupta <ashmew2 at gmail.com>
Date: 2014-02-01 16:49 +0530
Branch: filetransferX
URL: https://hg.pidgin.im/soc/2013/ashmew2/filetransferY/rev/331d25ab4fc0
Description:
Shifted code from session to share
diffstat:
libpurple/protocols/jabber/google/google_session.c | 109 +-
libpurple/protocols/jabber/google/google_session.h | 84 +-
libpurple/protocols/jabber/google/google_share.c | 1708 ++++++++++---------
libpurple/protocols/jabber/google/google_share.h | 2 +
4 files changed, 952 insertions(+), 951 deletions(-)
diffs (truncated from 2061 to 300 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
@@ -149,7 +149,7 @@ google_session_destroy(GoogleSession *se
purple_debug_info("google_session", "Phase END of function\n");
}
-static xmlnode *
+xmlnode *
google_session_create_xmlnode(GoogleSession *session, const char *type)
{
xmlnode *node = xmlnode_new("session");
@@ -433,7 +433,7 @@ jabber_google_session_get_params(JabberS
return new_params;
}
-static void
+void
jabber_google_relay_response_session_initiate_cb(GoogleSession *session,
const gchar *relay_ip, guint relay_udp, guint relay_tcp, guint relay_ssltcp,
const gchar *relay_username, const gchar *relay_password)
@@ -768,108 +768,9 @@ google_session_handle_initiate(JabberStr
0, 0, 0, NULL, NULL);
}
}
- else {
-
- GoogleXferSessionData *share_session = (GoogleXferSessionData *)session->session_data;
- xmlnode *description = xmlnode_get_child(sess, "description");
- xmlnode *manifest,*file,*filename = NULL,*protocol,*http,*url_source_path,*url_preview_path,*transport;
- guint filesize = 0;
- JabberIq *result;
-
- share_session = g_new0(GoogleXferSessionData, 1);
-
- purple_debug_info("google_session", "Indeed a SHARE Session\n");
- if( description ) {
- purple_debug_info("google_session", "description is not NULL");
- manifest = xmlnode_get_child(description, "manifest");
- if( manifest ) {
- purple_debug_info("google_session", "manifest not NULL");
- file = xmlnode_get_child(manifest, "file");
- if( file ) {
- purple_debug_info("google_session", "file is not NULL\n");
- filename = xmlnode_get_child(file, "name");
-
- filesize = atoi(xmlnode_get_attrib(file, "size"));
-
- purple_debug_info("google_session", "File size : %d",filesize);
- share_session->filesize = g_ascii_strtoull((gchar *)xmlnode_get_attrib(file, "size"),NULL,10);
- if( filename ) {
- purple_debug_info("google_session", "Filename : %s",xmlnode_get_data_unescaped(filename));
- share_session->filename = xmlnode_get_data_unescaped(filename);
- }
- else
- purple_debug_info("google_session", "Filename is NULL");
- }
- }
- protocol = xmlnode_get_child(description, "protocol");
- if( protocol ) {
- purple_debug_info("google_session", "protocol is not NULL");
- http = xmlnode_get_child(protocol, "http");
- if( http ) {
- purple_debug_info("google_session", "http is not NULL");
- url_source_path = xmlnode_get_child(http, "url");
- if( url_source_path ) {
- purple_debug_info("google_session", "url_source_path is not NULL. Name : %s",xmlnode_get_data_unescaped(url_source_path));
- share_session->source_url = xmlnode_get_data_unescaped(url_source_path);
- }
- url_preview_path = xmlnode_get_next_twin(url_source_path);
- if(url_preview_path) {
- purple_debug_info("google_session", "url_source_preview is not NULL. Data : %s",xmlnode_get_data_unescaped(url_preview_path));
- share_session->preview_url = xmlnode_get_data_unescaped(url_preview_path);
- }
- }
- }
-
- transport = xmlnode_get_child(sess, "transport");
- if( transport )
- purple_debug_info("google_session", "Transport is not null : %s",xmlnode_get_attrib(transport, "xmlns"));
- else
- purple_debug_info("google_session", "Transport is NULL");
- }
- /*Add the GoogleSession *session to the GList*/
-
- purple_debug_info("google_session", "We have received a file request : XFER_RECEIVE.\n");
-
- share_session->xfer = purple_xfer_new(purple_connection_get_account(js->gc), PURPLE_XFER_RECEIVE,
- session->remote_jid);
-
- js->gtalk_xfer_list = g_list_prepend(js->gtalk_xfer_list, share_session->xfer);
-
- if(filename)
- purple_xfer_set_filename(share_session->xfer, xmlnode_get_data_unescaped(filename));
-
- purple_xfer_set_size(share_session->xfer, filesize);
- /*Setting up stuff for XFER_RECEIVE*/
- 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_cancel_recv_fnc(share_session->xfer,
- gtalk_xfer_cancel_xfer);
- 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);
-
- session->session_data = share_session;
-
- 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);
- } else {
- jabber_google_relay_response_session_initiate_cb(session, NULL, 0, 0, 0,
- NULL, NULL);
- }
- /*Ask the user to accept the file transfer*/
- purple_xfer_request(share_session->xfer);
- session->state = RECEIVED_INITIATE;
- return TRUE;
- }
+ else
+ gtalk_xfer_handle_initiate(js, session, sess, iq_id);
+
return TRUE;
}
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
@@ -22,6 +22,48 @@
#define PURPLE_JABBER_GOOGLE_SESSION_H_
#include "jabber.h"
+#include <nice/agent.h>
+
+typedef enum {
+ GTALK_XFER_CHANNEL_INITIALIZED = 0,
+ GTALK_XFER_CHANNEL_HTTP_GET_NOT_SENT,
+ GTALK_XFER_CHANNEL_SENT_HTTP_GET,
+ GTALK_XFER_CHANNEL_HTTP_GET_RECEIVED,
+ GTALK_XFER_CHANNEL_HTTP_OK_SENT,
+ GTALK_XFER_CHANNEL_HTTP_SENDING,
+ GTALK_XFER_CHANNEL_HTTP_RECEIVING,
+ GTALK_XFER_CHANNEL_HTTP_TRANSFERRING,
+ GTALK_XFER_CHANNEL_HTTP_SENDING_COMPLETE,
+ GTALK_XFER_CHANNEL_HTTP_RECEIVING_COMPLETE,
+ GTALK_XFER_CHANNEL_PARSED_HTTP_RESPONSE_HEADER
+} GoogleXferChannelState;
+
+typedef struct {
+ gchar *filename; /*File Details*/
+ guint64 filesize;
+ gchar *preview_url;
+ gchar *source_url;
+ PurpleXfer *xfer;
+ NiceAgent *share_agent; /*Needs to have a manifest
+ Entry for Folder Sharing: TODO*/
+ gchar *channel_name;
+ NiceComponentState agent_state;
+ PurpleCircBuffer *buffer;
+ GoogleXferChannelState channel_state;
+ gint stream_id;
+ gboolean candidates_gathered;
+ gboolean file_opened; /* Stuff for using file buffer
+ for sending Gtalk Files.. */
+ FILE *file_to_send;
+ char *file_buf;
+ int file_buf_current_size;
+ int file_buf_sent;
+
+ GSList *remote_share_candidates; /* lists of
+ NiceCandidates */
+ GSList *local_share_candidates;
+
+} GoogleXferSessionData;
typedef struct {
char *id;
@@ -51,6 +93,36 @@ typedef struct {
gpointer session_data;
} GoogleSession;
+void cb_new_selected_pair(NiceAgent *agent, guint stream_id, guint component_id,
+ gchar *lfoundation, gchar *rfoundation, 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_component_writable(NiceAgent *agent, guint stream_id, guint component_id,
+ gpointer user_data);
+/*--------------------*/
+/*correct*/
+void gtalk_xfer_handle_initiate(JabberStream *js,
+ GoogleSession *session,
+ xmlnode *sess,
+ const char *iq_id);
+
+void gtalk_xfer_handle_candidates(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id);
+void gtalk_xfer_handle_info(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id);
+void gtalk_xfer_handle_accept(JabberStream *js, GoogleSession *session, const char *iq_id);
+void gtalk_xfer_handle_reject(JabberStream *js, GoogleSession *session, const char *iq_id);
+gint gtalk_xfer_init_agent(GoogleSession *session);
+
+void jabber_google_relay_response_session_initiate_cb(GoogleSession *session,
+ const gchar *relay_ip, guint relay_udp, guint relay_tcp, guint relay_ssltcp,
+ const gchar *relay_username, const gchar *relay_password);
+xmlnode *
+google_session_create_xmlnode(GoogleSession *session, const char *type);
+void
+gtalk_xfer_send(PurpleConnection *gc, const char *who, const char *file);
+/*--------------------*/
+
+void cb_candidate_gathering_done(NiceAgent *agent, guint stream_id, gpointer user_data);
+
gboolean jabber_google_session_initiate(JabberStream *js, const gchar *who,
PurpleMediaSessionType type);
@@ -59,16 +131,4 @@ void jabber_google_session_parse(JabberS
void google_session_destroy(GoogleSession *session);
-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);
-gssize gtalk_xfer_read(guchar **out_buffer, PurpleXfer *xfer);
-gssize gtalk_xfer_write(const guchar *buffer, size_t size, 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);
-void gtalk_xfer_send_candidates(GoogleSession *session);
-void gtalk_xfer_send_session_initiate(PurpleXfer *xfer);
#endif /* PURPLE_JABBER_GOOGLE_SESSION_H_ */
diff --git a/libpurple/protocols/jabber/google/google_share.c b/libpurple/protocols/jabber/google/google_share.c
--- a/libpurple/protocols/jabber/google/google_share.c
+++ b/libpurple/protocols/jabber/google/google_share.c
@@ -1,5 +1,5 @@
/**
- * Purple is the legal property of its developers, whose names are too numerous
+ * Purple is the legal property of its developers, wohse names are too numerous
* to list here. Please refer to the COPYRIGHT file distributed with this
* source distribution.
*
@@ -18,6 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
+#include "google_share.h"
#include <stdlib.h>
#include "internal.h"
#include "debug.h"
@@ -31,513 +32,42 @@
#include "relay.h"
#include <nice/agent.h>
-typedef enum {
- GTALK_XFER_CHANNEL_INITIALIZED = 0,
- GTALK_XFER_CHANNEL_HTTP_GET_NOT_SENT,
- GTALK_XFER_CHANNEL_SENT_HTTP_GET,
- GTALK_XFER_CHANNEL_HTTP_GET_RECEIVED,
- GTALK_XFER_CHANNEL_HTTP_OK_SENT,
- GTALK_XFER_CHANNEL_HTTP_SENDING,
- GTALK_XFER_CHANNEL_HTTP_RECEIVING,
- GTALK_XFER_CHANNEL_HTTP_TRANSFERRING,
- GTALK_XFER_CHANNEL_HTTP_SENDING_COMPLETE,
- GTALK_XFER_CHANNEL_HTTP_RECEIVING_COMPLETE,
- GTALK_XFER_CHANNEL_PARSED_HTTP_RESPONSE_HEADER
-} GoogleXferChannelState;
+static char*
+gtalk_get_temporary_url(void)
+{
+ /*According to GTalk data, the length of temporary URL must be 44.*/
+ static int z = - 1;
+ char *temporary_url = g_malloc(45);
+ int i = 11;
+ char *alpha = "abcdefghijklmnopqrstuvwxyz";
+ char *num = "0123456789";
+ srandom(time(NULL));
-typedef struct {
- gchar *filename; /*File Details*/
- guint64 filesize;
- gchar *preview_url;
- gchar *source_url;
- PurpleXfer *xfer;
- NiceAgent *share_agent; /*Needs to have a manifest
- Entry for Folder Sharing: TODO*/
- gchar *channel_name;
- NiceComponentState agent_state;
- PurpleCircBuffer *buffer;
- GoogleXferChannelState channel_state;
- gint stream_id;
- gboolean candidates_gathered;
- gboolean file_opened; /* Stuff for using file buffer
More information about the Commits
mailing list