soc.2010.msn-tlc: d09b6f5a: Move file request up in the stack.
masca at cpw.pidgin.im
masca at cpw.pidgin.im
Thu Jun 24 02:17:01 EDT 2010
-----------------------------------------------------------------
Revision: d09b6f5aaa0c654d0b38b8c06cdc6ffff1285e2a
Ancestor: 50866b18d43f2d75de77e9541e28af56c97d7e4b
Author: masca at cpw.pidgin.im
Date: 2010-06-24T00:41:07
Branch: im.pidgin.soc.2010.msn-tlc
URL: http://d.pidgin.im/viewmtn/revision/info/d09b6f5aaa0c654d0b38b8c06cdc6ffff1285e2a
Modified files:
libpurple/protocols/msn/msn.c libpurple/protocols/msn/slp.c
libpurple/protocols/msn/slp.h
libpurple/protocols/msn/slplink.c
libpurple/protocols/msn/slplink.h
ChangeLog:
Move file request up in the stack.
-------------- next part --------------
============================================================
--- libpurple/protocols/msn/msn.c 3a0b79ebd0451c59af3beac1e7f1153fd6a84320
+++ libpurple/protocols/msn/msn.c 7c9aafe74ee46591cfb527568c3a509bf72a7bd2
@@ -803,9 +803,7 @@ t_msn_xfer_init(PurpleXfer *xfer)
static void
t_msn_xfer_init(PurpleXfer *xfer)
{
- MsnSlpLink *slplink = xfer->data;
- msn_slplink_request_ft(slplink, xfer);
- msn_slplink_unref(slplink);
+ msn_request_ft(xfer);
}
static void
============================================================
--- libpurple/protocols/msn/slp.c ff0c1058a825d329ca457b6f889878679b87021a
+++ libpurple/protocols/msn/slp.c f4959c1fd50f80034ae9ff7a851471c11552b06b
@@ -1318,3 +1318,132 @@ request_user_display(MsnUser *user)
msn_release_buddy_icon_request(session->userlist);
}
}
+
+static void
+send_file_cb(MsnSlpCall *slpcall)
+{
+ MsnSlpMessage *slpmsg;
+ PurpleXfer *xfer;
+
+ xfer = (PurpleXfer *)slpcall->xfer;
+ if (purple_xfer_get_status(xfer) >= PURPLE_XFER_STATUS_STARTED)
+ return;
+
+ purple_xfer_ref(xfer);
+ purple_xfer_start(xfer, -1, NULL, 0);
+ if (purple_xfer_get_status(xfer) != PURPLE_XFER_STATUS_STARTED) {
+ purple_xfer_unref(xfer);
+ return;
+ }
+ purple_xfer_unref(xfer);
+
+ slpmsg = msn_slpmsg_file_new(slpcall, purple_xfer_get_size(xfer));
+ msn_slpmsg_set_slplink(slpmsg, slpcall->slplink);
+
+ msn_slplink_send_slpmsg(slpcall->slplink, slpmsg);
+}
+
+static gchar *
+gen_context(PurpleXfer *xfer, const char *file_name, const char *file_path)
+{
+ gsize size = 0;
+ MsnFileContext *header;
+ gchar *u8 = NULL;
+ gchar *ret;
+ gunichar2 *uni = NULL;
+ glong currentChar = 0;
+ glong len = 0;
+ const char *preview;
+ gsize preview_len;
+
+ size = purple_xfer_get_size(xfer);
+
+ purple_xfer_prepare_thumbnail(xfer, "png");
+
+ if (!file_name) {
+ gchar *basename = g_path_get_basename(file_path);
+ u8 = purple_utf8_try_convert(basename);
+ g_free(basename);
+ file_name = u8;
+ }
+
+ uni = g_utf8_to_utf16(file_name, -1, NULL, &len, NULL);
+
+ if (u8) {
+ g_free(u8);
+ file_name = NULL;
+ u8 = NULL;
+ }
+
+ preview = purple_xfer_get_thumbnail(xfer, &preview_len);
+ header = g_malloc(sizeof(MsnFileContext) + preview_len);
+
+ header->length = GUINT32_TO_LE(sizeof(MsnFileContext) - 1);
+ header->version = GUINT32_TO_LE(2); /* V.3 contains additional unnecessary data */
+ header->file_size = GUINT64_TO_LE(size);
+ if (preview)
+ header->type = GUINT32_TO_LE(0);
+ else
+ header->type = GUINT32_TO_LE(1);
+
+ len = MIN(len, MAX_FILE_NAME_LEN);
+ for (currentChar = 0; currentChar < len; currentChar++) {
+ header->file_name[currentChar] = GUINT16_TO_LE(uni[currentChar]);
+ }
+ memset(&header->file_name[currentChar], 0x00, (MAX_FILE_NAME_LEN - currentChar) * 2);
+
+ memset(&header->unknown1, 0, sizeof(header->unknown1));
+ header->unknown2 = GUINT32_TO_LE(0xffffffff);
+ if (preview) {
+ memcpy(&header->preview, preview, preview_len);
+ }
+ header->preview[preview_len] = '\0';
+
+ g_free(uni);
+ ret = purple_base64_encode((const guchar *)header, sizeof(MsnFileContext) + preview_len);
+ g_free(header);
+ return ret;
+}
+
+void
+msn_request_ft(PurpleXfer *xfer)
+{
+ MsnSlpCall *slpcall;
+ MsnSlpLink *slplink;
+ char *context;
+ const char *fn;
+ const char *fp;
+
+ fn = purple_xfer_get_filename(xfer);
+ fp = purple_xfer_get_local_filename(xfer);
+
+ slplink = xfer->data;
+
+ g_return_if_fail(slplink != NULL);
+ g_return_if_fail(fp != NULL);
+
+ slpcall = msn_slpcall_new(slplink);
+ msn_slpcall_init(slpcall, MSN_SLPCALL_DC);
+
+ slpcall->session_init_cb = send_file_cb;
+ slpcall->end_cb = msn_xfer_end_cb;
+ slpcall->cb = msn_xfer_completed_cb;
+ slpcall->xfer = xfer;
+ purple_xfer_ref(slpcall->xfer);
+
+ slpcall->pending = TRUE;
+
+ purple_xfer_set_cancel_send_fnc(xfer, msn_xfer_cancel);
+ purple_xfer_set_read_fnc(xfer, msn_xfer_read);
+ purple_xfer_set_write_fnc(xfer, msn_xfer_write);
+
+ xfer->data = slpcall;
+
+ context = gen_context(xfer, fn, fp);
+
+ msn_slpcall_invite(slpcall, MSN_FT_GUID, 2, context);
+ msn_slplink_unref(slplink);
+
+ g_free(context);
+}
+
============================================================
--- libpurple/protocols/msn/slp.h 0610af1662b6a1c1b68f9f4b7e7b48563c0cf319
+++ libpurple/protocols/msn/slp.h 3c8d33936619e6b541bcfc2406d51ce8c54bee11
@@ -75,4 +75,6 @@ void msn_queue_buddy_icon_request(MsnUse
void msn_queue_buddy_icon_request(MsnUser *user);
+void msn_request_ft(PurpleXfer *xfer);
+
#endif /* MSN_SLP_H */
============================================================
--- libpurple/protocols/msn/slplink.c f6d607ab52c91a2420f37b40120f2ee860a471d3
+++ libpurple/protocols/msn/slplink.c 34414d86ee47b66c206ec419080b7db2f50c4319
@@ -441,30 +441,6 @@ msn_slplink_send_ack(MsnSlpLink *slplink
msn_slpmsg_destroy(slpmsg);
}
-static void
-send_file_cb(MsnSlpCall *slpcall)
-{
- MsnSlpMessage *slpmsg;
- PurpleXfer *xfer;
-
- xfer = (PurpleXfer *)slpcall->xfer;
- if (purple_xfer_get_status(xfer) >= PURPLE_XFER_STATUS_STARTED)
- return;
-
- purple_xfer_ref(xfer);
- purple_xfer_start(xfer, -1, NULL, 0);
- if (purple_xfer_get_status(xfer) != PURPLE_XFER_STATUS_STARTED) {
- purple_xfer_unref(xfer);
- return;
- }
- purple_xfer_unref(xfer);
-
- slpmsg = msn_slpmsg_file_new(slpcall, purple_xfer_get_size(xfer));
- msn_slpmsg_set_slplink(slpmsg, slpcall->slplink);
-
- msn_slplink_send_slpmsg(slpcall->slplink, slpmsg);
-}
-
static MsnSlpMessage *
msn_slplink_message_find(MsnSlpLink *slplink, long session_id, long id)
{
@@ -652,107 +628,7 @@ msn_slplink_process_msg(MsnSlpLink *slpl
}
}
-static gchar *
-gen_context(PurpleXfer *xfer, const char *file_name, const char *file_path)
-{
- gsize size = 0;
- MsnFileContext *header;
- gchar *u8 = NULL;
- gchar *ret;
- gunichar2 *uni = NULL;
- glong currentChar = 0;
- glong len = 0;
- const char *preview;
- gsize preview_len;
-
- size = purple_xfer_get_size(xfer);
-
- purple_xfer_prepare_thumbnail(xfer, "png");
-
- if (!file_name) {
- gchar *basename = g_path_get_basename(file_path);
- u8 = purple_utf8_try_convert(basename);
- g_free(basename);
- file_name = u8;
- }
-
- uni = g_utf8_to_utf16(file_name, -1, NULL, &len, NULL);
-
- if (u8) {
- g_free(u8);
- file_name = NULL;
- u8 = NULL;
- }
-
- preview = purple_xfer_get_thumbnail(xfer, &preview_len);
- header = g_malloc(sizeof(MsnFileContext) + preview_len);
-
- header->length = GUINT32_TO_LE(sizeof(MsnFileContext) - 1);
- header->version = GUINT32_TO_LE(2); /* V.3 contains additional unnecessary data */
- header->file_size = GUINT64_TO_LE(size);
- if (preview)
- header->type = GUINT32_TO_LE(0);
- else
- header->type = GUINT32_TO_LE(1);
-
- len = MIN(len, MAX_FILE_NAME_LEN);
- for (currentChar = 0; currentChar < len; currentChar++) {
- header->file_name[currentChar] = GUINT16_TO_LE(uni[currentChar]);
- }
- memset(&header->file_name[currentChar], 0x00, (MAX_FILE_NAME_LEN - currentChar) * 2);
-
- memset(&header->unknown1, 0, sizeof(header->unknown1));
- header->unknown2 = GUINT32_TO_LE(0xffffffff);
- if (preview) {
- memcpy(&header->preview, preview, preview_len);
- }
- header->preview[preview_len] = '\0';
-
- g_free(uni);
- ret = purple_base64_encode((const guchar *)header, sizeof(MsnFileContext) + preview_len);
- g_free(header);
- return ret;
-}
-
void
-msn_slplink_request_ft(MsnSlpLink *slplink, PurpleXfer *xfer)
-{
- MsnSlpCall *slpcall;
- char *context;
- const char *fn;
- const char *fp;
-
- fn = purple_xfer_get_filename(xfer);
- fp = purple_xfer_get_local_filename(xfer);
-
- g_return_if_fail(slplink != NULL);
- g_return_if_fail(fp != NULL);
-
- slpcall = msn_slpcall_new(slplink);
- msn_slpcall_init(slpcall, MSN_SLPCALL_DC);
-
- slpcall->session_init_cb = send_file_cb;
- slpcall->end_cb = msn_xfer_end_cb;
- slpcall->cb = msn_xfer_completed_cb;
- slpcall->xfer = xfer;
- purple_xfer_ref(slpcall->xfer);
-
- slpcall->pending = TRUE;
-
- purple_xfer_set_cancel_send_fnc(xfer, msn_xfer_cancel);
- purple_xfer_set_read_fnc(xfer, msn_xfer_read);
- purple_xfer_set_write_fnc(xfer, msn_xfer_write);
-
- xfer->data = slpcall;
-
- context = gen_context(xfer, fn, fp);
-
- msn_slpcall_invite(slpcall, MSN_FT_GUID, 2, context);
-
- g_free(context);
-}
-
-void
msn_slplink_request_object(MsnSlpLink *slplink,
const char *info,
MsnSlpCb cb,
============================================================
--- libpurple/protocols/msn/slplink.h 2a1c1b8d016b867bec868b5df839d4a2d3011a17
+++ libpurple/protocols/msn/slplink.h 7d07dc4e5819bb8b26dc7449eb92deb67f67a442
@@ -80,7 +80,6 @@ void msn_slplink_process_msg(MsnSlpLink
MsnSlpMessage *slpmsg);
void msn_slplink_send_queued_slpmsgs(MsnSlpLink *slplink);
void msn_slplink_process_msg(MsnSlpLink *slplink, MsnP2PHeader *header, const char *data, gsize len);
-void msn_slplink_request_ft(MsnSlpLink *slplink, PurpleXfer *xfer);
/* Only exported for msn_xfer_write */
void msn_slplink_send_msgpart(MsnSlpLink *slplink, MsnSlpMessage *slpmsg);
More information about the Commits
mailing list