File: downloadqueue.hh

package info (click to toggle)
linuxdcpp 1.0.2-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 2,392 kB
  • ctags: 5,102
  • sloc: cpp: 33,213; ansic: 472; makefile: 15
file content (120 lines) | stat: -rw-r--r-- 5,277 bytes parent folder | download | duplicates (2)
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
/*
 * Copyright © 2004-2008 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_DOWNLOAD_QUEUE_HH
#define WULFOR_DOWNLOAD_QUEUE_HH

#include <client/stdinc.h>
#include <client/DCPlusPlus.h>
#include <client/QueueManager.h>

#include "bookentry.hh"
#include "treeview.hh"

class DownloadQueue:
	public BookEntry,
	public QueueManagerListener
{
	public:
		DownloadQueue();
		virtual ~DownloadQueue();
		virtual void show();

	private:
		// GUI functions
		void buildDynamicMenu_gui();
		void setStatus_gui(std::string text, std::string statusItem);
		void updateStatus_gui();
		void addFiles_gui(vector<StringMap> files, bool firstUpdate);
		void addFile_gui(StringMap params, bool updateDirs);
		void addDir_gui(const std::string &path, GtkTreeIter *parent);
		void updateFile_gui(StringMap params);
		void removeFile_gui(std::string path, int64_t size);
		void removeDir_gui(const std::string &path, GtkTreeIter *parent);
		void updateFileView_gui();
		void sendMessage_gui(std::string cid);

		// GUI callbacks
		static gboolean onDirButtonPressed_gui(GtkWidget *widget, GdkEventButton *event, gpointer data);
		static gboolean onDirButtonReleased_gui(GtkWidget *widget, GdkEventButton *event, gpointer data);
		static gboolean onDirKeyReleased_gui(GtkWidget *widget, GdkEventKey *event, gpointer data);
		static gboolean onFileButtonPressed_gui(GtkWidget *widget, GdkEventButton *event, gpointer data);
		static gboolean onFileButtonReleased_gui(GtkWidget *widget, GdkEventButton *event, gpointer data);
		static gboolean onFileKeyReleased_gui(GtkWidget *widget, GdkEventKey *event, gpointer data);
		static void onDirPriorityClicked_gui(GtkMenuItem *item, gpointer data);
		static void onDirMoveClicked_gui(GtkMenuItem *item, gpointer data);
		static void onDirRemoveClicked_gui(GtkMenuItem *menuitem, gpointer data);
		static void onFileSearchAlternatesClicked_gui(GtkMenuItem *item, gpointer data);
		static void onCopyMagnetClicked_gui(GtkMenuItem* item, gpointer data);
		static void onFileMoveClicked_gui(GtkMenuItem *item, gpointer data);
		static void onFilePriorityClicked_gui(GtkMenuItem *item, gpointer data);
		static void onFileGetListClicked_gui(GtkMenuItem *item, gpointer data);
		static void onFileSendPMClicked_gui(GtkMenuItem *item, gpointer data);
		static void onFileReAddSourceClicked_gui(GtkMenuItem *item, gpointer data);
		static void onFileRemoveSourceClicked_gui(GtkMenuItem *item, gpointer data);
		static void onFileRemoveUserFromQueueClicked_gui(GtkMenuItem *item, gpointer data);
		static void onFileRemoveClicked_gui(GtkMenuItem *menuitem, gpointer data);

		// Client functions
		void buildList_client();
		void move_client(std::string source, std::string target);
		void moveDir_client(std::string source, std::string target);
		void setPriority_client(std::string target, QueueItem::Priority p);
		void setPriorityDir_client(std::string path, QueueItem::Priority p);
		void addList_client(std::string target, std::string nick);
		void sendMessage_client(std::string target, std::string nick);
		void reAddSource_client(std::string target, std::string nick);
		void removeSource_client(std::string target, std::string nick);
		void removeSources_client(std::string target, std::string nick);
		void remove_client(std::string target);
		void removeDir_client(std::string path);
		void updateFileView_client(std::string path);
		void getQueueParams_client(QueueItem *item, StringMap &params);

		// Client callbacks
		virtual void on(QueueManagerListener::Added, QueueItem *item) throw();
		virtual void on(QueueManagerListener::Moved, QueueItem *item, const std::string &oldTarget) throw();
		virtual void on(QueueManagerListener::Removed, QueueItem *item) throw();
		virtual void on(QueueManagerListener::SourcesUpdated, QueueItem *item) throw();
		virtual void on(QueueManagerListener::StatusUpdated, QueueItem *item) throw();

		// Private variables
		TreeView dirView;
		TreeView fileView;
		GtkTreeStore *dirStore;
		GtkListStore *fileStore;
		GtkTreeSelection *dirSelection;
		GtkTreeSelection *fileSelection;
		GdkEventType dirPrevious;
		std::string currentDir;
		hash_map<std::string, std::map<std::string, std::string> > sources;
		hash_map<std::string, std::map<std::string, std::string> > badSources;
		int currentItems;
		int totalItems;
		int64_t currentSize;
		int64_t totalSize;

		typedef map<std::string, std::string>::const_iterator SourceIter;
};

#else
class DownloadQueue;
#endif