soc.2009.transport: 1c6ca4ca: First part of straight filetransfer supp...
hanzz at soc.pidgin.im
hanzz at soc.pidgin.im
Sun Aug 2 14:55:33 EDT 2009
-----------------------------------------------------------------
Revision: 1c6ca4ca22b62be96ffd6fdf58c641abd0cfbea2
Ancestor: 013cb823a9c5af21d70e4a99ed2cf52408adc708
Author: hanzz at soc.pidgin.im
Date: 2009-08-02T18:53:10
Branch: im.pidgin.soc.2009.transport
URL: http://d.pidgin.im/viewmtn/revision/info/1c6ca4ca22b62be96ffd6fdf58c641abd0cfbea2
Added files:
filetransferrepeater.cpp filetransferrepeater.h
Modified files:
CMakeLists.txt filetransfermanager.cpp main.cpp user.cpp
user.h
ChangeLog:
First part of straight filetransfer support
-------------- next part --------------
============================================================
--- filetransferrepeater.cpp afc5cb1f5ffab85652107c99717c9c3a697d341a
+++ filetransferrepeater.cpp afc5cb1f5ffab85652107c99717c9c3a697d341a
@@ -0,0 +1,37 @@
+/**
+ * XMPP - libpurple transport
+ *
+ * Copyright (C) 2009, Jan Kaluza <hanzz at soc.pidgin.im>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
+ */
+
+#include "filetransferrepeater.h"
+#include "main.h"
+
+FiletransferRepeater::FiletransferRepeater(GlooxMessageHandler *main, const JID& to, const std::string& sid, SIProfileFT::StreamType type, const JID& from) {
+ m_main = main;
+ m_to = to;
+ m_sid = sid;
+ m_type = type;
+ m_from = from;
+}
+
+void FiletransferRepeater::registerXfer(PurpleXfer *xfer) {
+ m_xfer = xfer;
+
+}
+
+
============================================================
--- filetransferrepeater.h efd6b9522c2248dd249a57d249e48b782f9e35ca
+++ filetransferrepeater.h efd6b9522c2248dd249a57d249e48b782f9e35ca
@@ -0,0 +1,56 @@
+/**
+ * XMPP - libpurple transport
+ *
+ * Copyright (C) 2009, Jan Kaluza <hanzz at soc.pidgin.im>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
+ */
+
+#ifndef _SPECTRUM_FILETRANSFER_REPEATER_H
+#define _SPECTRUM_FILETRANSFER_REPEATER_H
+
+#include "localization.h"
+#include "gloox/tag.h"
+#include "gloox/presence.h"
+#include "gloox/siprofileft.h"
+#include "conversation.h"
+#include "ft.h"
+
+class User;
+extern Localization localization;
+
+class GlooxMessageHandler;
+
+using namespace gloox;
+
+class FiletransferRepeater {
+
+ public:
+ FiletransferRepeater(GlooxMessageHandler *main, const JID& to, const std::string& sid, SIProfileFT::StreamType type, const JID& from);
+ ~FiletransferRepeater() {}
+
+ void registerXfer(PurpleXfer *xfer);
+
+ private:
+ GlooxMessageHandler *m_main;
+ JID m_to;
+ std::string m_sid;
+ SIProfileFT::StreamType m_type;
+ JID m_from;
+ PurpleXfer *m_xfer;
+
+};
+
+#endif
============================================================
--- CMakeLists.txt 16f081ef58c6ed340051c5212bd21e78c6d65806
+++ CMakeLists.txt 9060def2830375f6df77a8c1e1fcb5875cf87333
@@ -60,6 +60,7 @@
caps.cpp
discoinfohandler.cpp
filetransfermanager.cpp
+ filetransferrepeater.cpp
sendfile.cpp
thread.cpp
gatewayhandler.cpp
@@ -103,6 +104,7 @@
caps.h
discoinfohandler.h
filetransfermanager.h
+ filetransferrepeater.h
sendfile.h
thread.h
gatewayhandler.h
============================================================
--- filetransfermanager.cpp 00108c3ba1f04299f8c8e062c34450aed8d77f54
+++ filetransfermanager.cpp 896a81de7b5782a842f40bdcfcbd0d6201a38ad3
@@ -19,6 +19,7 @@
*/
#include "filetransfermanager.h"
+#include "usermanager.h"
void FileTransferManager::setSIProfileFT(gloox::SIProfileFT *sipft,GlooxMessageHandler *parent) {
m_sip = sipft;
@@ -30,7 +31,6 @@ void FileTransferManager::handleFTReques
std::cout << "Received file transfer request from " << from.full() << " " << to.full() << " " << sid << ".\n";
m_info[sid].filename = name;
m_info[sid].size = size;
- void serv_send_file(PurpleConnection *gc, const char *who, const char *file)
User *user = p->userManager()->getUserByJID(from.username());
if (user) {
@@ -38,6 +38,8 @@ void FileTransferManager::handleFTReques
if (user->isConnected()){
Log().Get(user->jid()) << "sending file";
serv_send_file(purple_account_get_connection(user->account()),to.username().c_str(), name.c_str());
+ // GlooxMessageHandler::instance()->ft->acceptFT(from, sid, SIProfileFT::FTTypeS5B, to);
+ user->addFiletransfer(from, sid, SIProfileFT::FTTypeS5B, to);
}
}
}
============================================================
--- main.cpp 1e7500d8b7ca002b844e75e708c23e8e1d536ef8
+++ main.cpp ee4ace89731f72fdf6531146fbace07adfd8c42f
@@ -28,6 +28,7 @@
#include "adhocrepeater.h"
#include "searchhandler.h"
#include "searchrepeater.h"
+#include "filetransferrepeater.h"
#include "parser.h"
#include "commands.h"
#include "protocols/abstractprotocol.h"
@@ -387,7 +388,18 @@ static void XferCreated(PurpleXfer *xfer
}
static void XferCreated(PurpleXfer *xfer) {
- purple_xfer_set_ui_read_fnc(xfer, ui_read_fnc);
+ std::string remote_user(purple_xfer_get_remote_user(xfer));
+
+ User *user = GlooxMessageHandler::instance()->userManager()->getUserByAccount(purple_xfer_get_account(xfer));
+ if (!user) return;
+
+ FiletransferRepeater *repeater = user->removeFiletransfer(remote_user);
+ if (!repeater) return;
+
+ repeater->registerXfer(xfer);
+
+// purple_xfer_set_ui_read_fnc(xfer, ui_read_fnc);
+
// xfer->ui_data = new
}
============================================================
--- user.cpp 0acd479c34f57ddbbdb0df315100a699a168f106
+++ user.cpp ead4ec48a2097693d94d865ca624cb569b6bc462
@@ -28,6 +28,7 @@
#include "cmds.h"
#include "parser.h"
#include "proxy.h"
+#include "filetransferrepeater.h"
/*
* Called when contact list has been received from legacy network.
@@ -72,6 +73,7 @@ User::User(GlooxMessageHandler *parent,
m_lang = NULL;
m_features = 0;
m_mucs = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
+ m_filetransfers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
PurpleValue *value;
// check default settings
@@ -1247,6 +1249,11 @@ void User::receivedPresence(const Presen
delete stanzaTag;
}
+void User::addFiletransfer( const JID& to, const std::string& sid, SIProfileFT::StreamType type, const JID& from ) {
+ FiletransferRepeater *ft = new FiletransferRepeater(p, to, sid, type, from);
+ g_hash_table_replace(m_filetransfers, g_strdup(to.bare() == m_jid ? from.username().c_str() : to.username().c_str()), ft);
+}
+
User::~User(){
purple_account_set_enabled(m_account, HIICQ_UI, TRUE);
@@ -1296,6 +1303,7 @@ User::~User(){
m_authRequests.clear();
g_hash_table_destroy(m_mucs);
g_hash_table_destroy(m_settings);
+ g_hash_table_destroy(m_filetransfers);
p->protocol()->onDestroy(this);
}
============================================================
--- user.h ab6f84621e91ec8e3d2e9b6135ab2c39c10b36a6
+++ user.h c34ca15761e1a38e0802bb6c5f77ccb6009734f5
@@ -24,8 +24,10 @@
#include <time.h>
#include <gloox/clientbase.h>
#include <gloox/messagesession.h>
+#include <gloox/siprofileft.h>
#include <glib.h>
class GlooxMessageHandler;
+class FiletransferRepeater;
#include "main.h"
#include "sql.h"
@@ -117,6 +119,9 @@ class User {
void connected();
void disconnected();
+ // Filetransfers
+ void addFiletransfer( const JID& to, const std::string& sid, SIProfileFT::StreamType type, const JID& from );
+ FiletransferRepeater* removeFiletransfer(std::string &from) { FiletransferRepeater *repeater = (FiletransferRepeater *) g_hash_table_lookup(m_filetransfers, from.c_str()); if (repeater) g_hash_table_remove(m_filetransfers, from.c_str()); return repeater; }
std::string actionData;
@@ -192,6 +197,7 @@ class User {
int m_features;
time_t m_connectionStart; // connection start timestamp
GHashTable *m_mucs; // MUCs
+ GHashTable *m_filetransfers;
std::map<std::string,RosterRow> m_roster; // jabber roster of this user
std::map<std::string,Resource> m_resources; // list of all resources which are connected to the transport
std::map<std::string,authRequest> m_authRequests; // list of authorization requests (holds callbacks and user data)
More information about the Commits
mailing list