soc.2009.transport: 06fe7b50: Updated FT to be in sync with current li...
hanzz at soc.pidgin.im
hanzz at soc.pidgin.im
Thu Aug 6 01:55:22 EDT 2009
-----------------------------------------------------------------
Revision: 06fe7b50a358be4f132f30f26f1a4fc3460daf92
Ancestor: a93cd788e8444de0ef3b9656ff9ae3727fd61a66
Author: hanzz at soc.pidgin.im
Date: 2009-08-06T05:50:47
Branch: im.pidgin.soc.2009.transport
URL: http://d.pidgin.im/viewmtn/revision/info/06fe7b50a358be4f132f30f26f1a4fc3460daf92
Modified files:
filetransferrepeater.cpp main.cpp
ChangeLog:
Updated FT to be in sync with current libpurple patch
-------------- next part --------------
============================================================
--- filetransferrepeater.cpp f66ae76f9f0726e84be2cf720d3b54c55b810b63
+++ filetransferrepeater.cpp 17e8a7c9af253799eaa140767a01227d90d03373
@@ -161,52 +161,6 @@ static gboolean ui_got_data(gpointer dat
return FALSE;
}
-static size_t ui_write_fnc(const guchar *buffer, size_t size, PurpleXfer *xfer) {
- FiletransferRepeater *repeater = (FiletransferRepeater *) xfer->ui_data;
- std::string d((char *)buffer, size);
- if (repeater->getResender())
- repeater->getResender()->getMutex()->lock();
- repeater->gotData(d);
- if (repeater->getResender())
- repeater->getResender()->getMutex()->unlock();
- return size;
-}
-
-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("");
- repeater->getResender()->getMutex()->unlock();
- return 0;
- }
- else {
- 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_strndup(data.c_str(), data.size());
- memcpy((*buffer), data.c_str(), data.size());
- size_t s = repeater->getBuffer().size();
- Log().Get("REPEATER") << "GOT BUFFER, BUFFER SIZE=" << s;
- repeater->getResender()->getMutex()->unlock();
- return data.size();
- }
-}
-
FiletransferRepeater::FiletransferRepeater(GlooxMessageHandler *main, const JID& to, const std::string& sid, SIProfileFT::StreamType type, const JID& from, long size) {
m_main = main;
m_size = size;
@@ -235,8 +189,6 @@ void FiletransferRepeater::registerXfer(
void FiletransferRepeater::registerXfer(PurpleXfer *xfer) {
m_xfer = xfer;
- purple_xfer_set_ui_read_fnc(m_xfer, ui_read_fnc);
- purple_xfer_set_ui_write_fnc(m_xfer, ui_write_fnc);
// purple_xfer_set_local_filename(xfer, filename);
if (m_size != -1)
purple_xfer_set_size(xfer, m_size);
============================================================
--- main.cpp 806f5410044f9c7a3c9eb6cbf530ebfc21d5d03b
+++ main.cpp 727338f5ad13eed53967f3bb3822f20aaf8b37ba
@@ -437,6 +437,53 @@ static void buddyListAddBuddy(PurpleAcco
std::cout << "BUDDY LIST ADD BUDDY REQUEST\n";
}
+static size_t XferWrite(PurpleXfer *xfer, const guchar *buffer, size_t size) {
+ FiletransferRepeater *repeater = (FiletransferRepeater *) xfer->ui_data;
+ std::string d((char *)buffer, size);
+ if (repeater->getResender())
+ repeater->getResender()->getMutex()->lock();
+ repeater->gotData(d);
+ if (repeater->getResender())
+ repeater->getResender()->getMutex()->unlock();
+ return size;
+}
+
+static size_t XferRead(PurpleXfer *xfer, guchar **buffer, size_t size) {
+// 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("");
+ repeater->getResender()->getMutex()->unlock();
+ return 0;
+ }
+ else {
+ 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_strndup(data.c_str(), data.size());
+ memcpy((*buffer), data.c_str(), data.size());
+ size_t s = repeater->getBuffer().size();
+ Log().Get("REPEATER") << "GOT BUFFER, BUFFER SIZE=" << s;
+ repeater->getResender()->getMutex()->unlock();
+ return data.size();
+ }
+}
+
+
/*
* Ops....
*/
@@ -511,6 +558,9 @@ static PurpleXferUiOps xferUiOps =
NULL,
NULL,
NULL,
+ NULL,
+ XferWrite,
+ XferRead,
NULL
};
More information about the Commits
mailing list