soc.2009.transport: 49505314: fixed filetransfer from xmpp to legacy n...
hanzz at soc.pidgin.im
hanzz at soc.pidgin.im
Tue Aug 4 07:41:19 EDT 2009
-----------------------------------------------------------------
Revision: 49505314eb2ad201a906df379cf83e1e2e8d34b2
Ancestor: cecedf582b6865f650e7dbd0217ef6f9c99352c1
Author: hanzz at soc.pidgin.im
Date: 2009-08-04T08:17:18
Branch: im.pidgin.soc.2009.transport
URL: http://d.pidgin.im/viewmtn/revision/info/49505314eb2ad201a906df379cf83e1e2e8d34b2
Modified files:
filetransferrepeater.cpp main.cpp
ChangeLog:
fixed filetransfer from xmpp to legacy network
-------------- next part --------------
============================================================
--- filetransferrepeater.cpp 059ab4f8d05ee12cf866684d3075bd8082738e2f
+++ filetransferrepeater.cpp 72b8d29f87c1d9b24276347410fb271e0b12d08a
@@ -74,24 +74,45 @@ void ReceiveFileStraight::handleBytestre
}
}
+static gboolean ui_got_data(gpointer data){
+ PurpleXfer *xfer = (PurpleXfer*) data;
+ purple_xfer_ui_got_data(xfer);
+ return FALSE;
+}
-
-static size_t ui_read_fnc(guchar *buffer, size_t size, PurpleXfer *xfer) {
+static size_t ui_read_fnc(guchar **buffer, size_t size, PurpleXfer *xfer) {
+ Log().Get("REPEATER") << "ui_read";
FiletransferRepeater *repeater = (FiletransferRepeater *) xfer->ui_data;
+ if (!repeater->getResender()) {
+ repeater->wantsData();
+ (*buffer) = (guchar*) g_strdup("");
+ return 0;
+ }
repeater->getResender()->getMutex()->lock();
if (repeater->getBuffer().empty()) {
+ Log().Get("REPEATER") << "buffer is empty, setting wantsData = true";
repeater->wantsData();
- buffer = (guchar*) g_strdup("");
+ (*buffer) = (guchar*) g_strdup("");
repeater->getResender()->getMutex()->unlock();
return 0;
}
else {
- buffer = (guchar*) g_strdup(repeater->getBuffer().c_str());
+ std::string data;
+ if (repeater->getBuffer().size() > size) {
+ data = repeater->getBuffer().substr(0, size);
+ repeater->getBuffer().erase(0, size);
+ }
+ else {
+ data = repeater->getBuffer();
+ repeater->getBuffer().erase();
+ }
+ (*buffer) = (guchar*) g_strdup(data.c_str());
size_t s = repeater->getBuffer().size();
+ Log().Get("REPEATER") << "GOT BUFFER, SIZE=" << s;
repeater->getResender()->getMutex()->unlock();
- return s;
+ return size;
}
}
@@ -102,6 +123,9 @@ FiletransferRepeater::FiletransferRepeat
m_sid = sid;
m_type = type;
m_from = from;
+ m_buffer = "";
+ m_wantsData = false;
+ m_resender = NULL;
}
void FiletransferRepeater::registerXfer(PurpleXfer *xfer) {
@@ -124,10 +148,11 @@ void FiletransferRepeater::gotData(const
}
void FiletransferRepeater::gotData(const std::string &data) {
- m_buffer = data;
+ m_buffer.append(data);
+ Log().Get("ReceiveFileStraight") << "Got DATA! " << m_wantsData;
if (m_wantsData) {
m_wantsData = false;
- purple_xfer_ui_got_data(m_xfer);
+ purple_timeout_add(0,&ui_got_data,m_xfer);
}
}
============================================================
--- main.cpp 225d98b60346f83245b9ce9775ab93ee623c8024
+++ main.cpp 93417917c506bde7ee0ee3590b15a3f743ee4b42
@@ -385,7 +385,7 @@ static void XferCreated(PurpleXfer *xfer
static void XferCreated(PurpleXfer *xfer) {
std::string remote_user(purple_xfer_get_remote_user(xfer));
-
+ Log().Get("xfercreated") << "get user " << remote_user;
User *user = GlooxMessageHandler::instance()->userManager()->getUserByAccount(purple_xfer_get_account(xfer));
if (!user) return;
More information about the Commits
mailing list