--- a/jingle-filetransfer/filetransfer.c Fri Jul 23 15:28:14 2010 +0200
+++ b/jingle-filetransfer/filetransfer.c Sat Jul 24 00:03:33 2010 +0200
@@ -208,7 +208,7 @@
return;
}
- if (!g_file_test (args[1], G_FILE_TEST_EXISTS)) {
+ if (!g_file_test (args[1], G_FILE_TEST_IS_REGULAR | G_FILE_TEST_EXISTS)) {
scr_LogPrint(LPRINT_LOGNORM, "File doesn't exist!");
return;
}
@@ -233,11 +233,15 @@
jft->size = 0;
jft->outfile = g_io_channel_new_file (args[1], "r", NULL);
g_io_channel_set_encoding(jft->outfile, NULL, NULL);
- while (g_io_channel_read_chars(jft->outfile, (gchar*)data, 1024, &bytes_read, NULL) != G_IO_STATUS_EOF) {
+ // For the md5 and the size
+ while (g_io_channel_read_chars(jft->outfile,
+ (gchar*)data, 1024, &bytes_read, NULL)
+ != G_IO_STATUS_EOF) {
jft->size+=bytes_read;
g_checksum_update(md5, data, bytes_read);
}
jft->hash = g_strdup(g_checksum_get_string(md5));
+ g_io_channel_seek_position (jft->outfile, 0, G_SEEK_SET, NULL);
session_add_app(sess, "file", NS_JINGLE_APP_FT, jft);
g_checksum_free(md5);
g_free(sid);
--- a/jingle/jingle.c Fri Jul 23 15:28:14 2010 +0200
+++ b/jingle/jingle.c Sat Jul 24 00:03:33 2010 +0200
@@ -378,6 +378,54 @@
return m;
}
+LmMessage *lm_message_from_jinglesession(const JingleSession *js,
+ const gchar *to,
+ JingleAction action)
+{
+ LmMessage* m;
+ LmMessageNode *jnode;
+ const gchar *actionstr;
+
+ m = lm_message_new_with_sub_type(to, LM_MESSAGE_TYPE_IQ,
+ LM_MESSAGE_SUB_TYPE_SET);
+ jnode = lm_message_node_add_child(m->node, "jingle", NULL);
+
+ if (actionstr = jingle_action_list[action].name)
+ lm_message_node_set_attribute(jnode, "action", actionstr);
+ else
+ return NULL;
+
+ if (js->initiator)
+ lm_message_node_set_attribute(jnode, "initiator", js->initiator);
+
+ if (js->sid)
+ lm_message_node_set_attribute(jnode, "sid", js->sid);
+ else
+ return NULL;
+
+ g_slist_foreach(js->content, lm_insert_sessioncontent, jnode);
+ return m;
+}
+
+static void lm_insert_sessioncontent(gpointer data, gpointer userdata)
+{
+ const gchar *xmlns;
+ JingleTransportFuncs *tfunc;
+ JingleAppFuncs *afunc;
+ SessionContent* content = (SessionContent*) data;
+ LmMessageNode* dad = (LmMessageNode*) userdata;
+ LmMessageNode* node = (LmMessageNode*) lm_message_node_add_child(dad,
+ "content", NULL);
+
+ if (content->name)
+ lm_message_node_set_attribute(node, "name", content->name);
+
+ //tfunc->handle(tfunc->check(content, NULL), node);
+
+ //afunc->handle(afunc->check(content, NULL), node);
+
+}
+
static void lm_insert_jinglecontent(gpointer data, gpointer userdata)
{
const gchar *xmlns;
--- a/jingle/jingle.h Fri Jul 23 15:28:14 2010 +0200
+++ b/jingle/jingle.h Sat Jul 24 00:03:33 2010 +0200
@@ -138,4 +138,10 @@
void handle_trans_data(const gchar *xmlns, gconstpointer data, const gchar *data2, guint len);
gchar *new_sid(void);
+
+LmMessage *lm_message_from_jinglesession(const JingleSession *js,
+ const gchar *to,
+ JingleAction action);
+
+static void lm_insert_sessioncontent(gpointer data, gpointer userdata);
#endif
--- a/jingle/register.h Fri Jul 23 15:28:14 2010 +0200
+++ b/jingle/register.h Sat Jul 24 00:03:33 2010 +0200
@@ -75,5 +75,6 @@
JingleTransportFuncs *jingle_get_transportfuncs(const gchar *xmlns);
void jingle_unregister_app(const gchar *xmlns);
void jingle_unregister_transport(const gchar *xmlns);
+JingleTransportFuncs *jingle_transport_for_app(const gchar *appxmlns, GSList **forbid);
#endif