1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
|
/*
* Copyright © 2004-2009 Jens Oknelid, paskharen@gmail.com
*
* 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 02110-1301 USA.
*
* In addition, as a special exception, compiling, linking, and/or
* using OpenSSL with this program is allowed.
*/
#ifndef WULFOR_TRANSFERS_HH
#define WULFOR_TRANSFERS_HH
#include "IntlUtil.hh"
#include <dcpp/stdinc.h>
#include <dcpp/DCPlusPlus.h>
#include <dcpp/ConnectionManager.h>
#include <dcpp/DownloadManager.h>
#include <dcpp/LogManager.h>
#include <dcpp/QueueManager.h>
#include <dcpp/UploadManager.h>
#include "treeview.hh"
#include "entry.hh"
#include "UserCommandMenu.hh"
class Transfers:
public dcpp::ConnectionManagerListener,
public dcpp::DownloadManagerListener,
public dcpp::QueueManagerListener,
public dcpp::UploadManagerListener,
public Entry
{
public:
Transfers();
~Transfers();
GtkWidget *getContainer() { return getWidget("mainBox"); }
virtual void show();
private:
// GUI functions
void addConnection_gui(dcpp::StringMap params, bool download);
void removeConnection_gui(const std::string cid, bool download);
void initTransfer_gui(dcpp::StringMap params);
void updateTransfer_gui(dcpp::StringMap params, bool download);
void updateFilePosition_gui(const std::string cid, int64_t filePosition);
void updateParent_gui(GtkTreeIter* iter);
void finishParent_gui(const std::string target, const std::string status);
bool findParent_gui(const std::string& target, GtkTreeIter* iter);
bool findTransfer_gui(const std::string& cid, bool download, GtkTreeIter* iter);
void popupTransferMenu_gui();
// GUI callbacks
static gboolean onTransferButtonPressed_gui(GtkWidget *widget, GdkEventButton *event, gpointer data);
static gboolean onTransferButtonReleased_gui(GtkWidget *widget, GdkEventButton *event, gpointer data);
static void onGetFileListClicked_gui(GtkMenuItem *item, gpointer data);
static void onMatchQueueClicked_gui(GtkMenuItem *item, gpointer data);
static void onPrivateMessageClicked_gui(GtkMenuItem *item, gpointer data);
static void onAddFavoriteUserClicked_gui(GtkMenuItem *item, gpointer data);
static void onGrantExtraSlotClicked_gui(GtkMenuItem *item, gpointer data);
static void onRemoveUserFromQueueClicked_gui(GtkMenuItem *item, gpointer data);
static void onForceAttemptClicked_gui(GtkMenuItem *item, gpointer data);
static void onCloseConnectionClicked_gui(GtkMenuItem *item, gpointer data);
// Client functions
void getParams_client(dcpp::StringMap& params, dcpp::ConnectionQueueItem* cqi);
void getParams_client(dcpp::StringMap& params, dcpp::Transfer* transfer);
std::string getFileName_client(dcpp::Transfer *t);
void getFileList_client(std::string cid, std::string hubUrl);
void matchQueue_client(std::string cid, std::string hubUrl);
void addFavoriteUser_client(std::string cid);
void grantExtraSlot_client(std::string cid, std::string hubUrl);
void removeUserFromQueue_client(std::string cid);
void forceAttempt_client(std::string cid);
void closeConnection_client(std::string cid, bool download);
// DownloadManager
virtual void on(dcpp::DownloadManagerListener::Requesting, dcpp::Download* dl) throw();
virtual void on(dcpp::DownloadManagerListener::Starting, dcpp::Download* dl) throw();
virtual void on(dcpp::DownloadManagerListener::Tick, const dcpp::DownloadList& dls) throw();
virtual void on(dcpp::DownloadManagerListener::Complete, dcpp::Download* dl) throw();
virtual void on(dcpp::DownloadManagerListener::Failed, dcpp::Download* dl, const std::string& reason) throw();
// ConnectionManager
virtual void on(dcpp::ConnectionManagerListener::Added, dcpp::ConnectionQueueItem* cqi) throw();
virtual void on(dcpp::ConnectionManagerListener::Connected, dcpp::ConnectionQueueItem* cqi) throw();
virtual void on(dcpp::ConnectionManagerListener::Removed, dcpp::ConnectionQueueItem* cqi) throw();
virtual void on(dcpp::ConnectionManagerListener::Failed, dcpp::ConnectionQueueItem* cqi, const std::string&) throw();
virtual void on(dcpp::ConnectionManagerListener::StatusChanged, dcpp::ConnectionQueueItem* cqi) throw();
// QueueManager
virtual void on(dcpp::QueueManagerListener::Finished, dcpp::QueueItem* qi, const std::string&, int64_t size) throw();
virtual void on(dcpp::QueueManagerListener::Removed, dcpp::QueueItem* qi) throw();
// UploadManager
virtual void on(dcpp::UploadManagerListener::Starting, dcpp::Upload* ul) throw();
virtual void on(dcpp::UploadManagerListener::Tick, const dcpp::UploadList& uls) throw();
virtual void on(dcpp::UploadManagerListener::Complete, dcpp::Upload* ul) throw();
virtual void on(dcpp::UploadManagerListener::Failed, dcpp::Upload* ul, const std::string& reason) throw();
TreeView transferView;
GtkTreeStore *transferStore;
GtkTreeSelection *transferSelection;
UserCommandMenu* userCommandMenu;
};
#endif // WULFOR_TRANSFERS_HH
|