summaryrefslogtreecommitdiff
path: root/noncore/net/opieirc/dcctransfertab.cpp
authorskyhusker <skyhusker>2005-02-03 21:47:50 (UTC)
committer skyhusker <skyhusker>2005-02-03 21:47:50 (UTC)
commit8aaae9e3eca7853e9c693d2401f721d75209acf7 (patch) (unidiff)
tree6f700d154fac8510b322242496604d0ad7589377 /noncore/net/opieirc/dcctransfertab.cpp
parent875b3b63624308f4e50f82e17db27edeb9609d6c (diff)
downloadopie-8aaae9e3eca7853e9c693d2401f721d75209acf7.zip
opie-8aaae9e3eca7853e9c693d2401f721d75209acf7.tar.gz
opie-8aaae9e3eca7853e9c693d2401f721d75209acf7.tar.bz2
Added DCC receive support
Diffstat (limited to 'noncore/net/opieirc/dcctransfertab.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/dcctransfertab.cpp81
1 files changed, 81 insertions, 0 deletions
diff --git a/noncore/net/opieirc/dcctransfertab.cpp b/noncore/net/opieirc/dcctransfertab.cpp
new file mode 100644
index 0000000..ea0ff1f
--- a/dev/null
+++ b/noncore/net/opieirc/dcctransfertab.cpp
@@ -0,0 +1,81 @@
1#include <qlist.h>
2#include <qlabel.h>
3#include <qstring.h>
4#include <qvbox.h>
5#include <qmessagebox.h>
6
7#include "dcctransfer.h"
8#include "dccprogress.h"
9#include "mainwindow.h"
10#include "dcctransfertab.h"
11
12#include <stdio.h>
13
14DCCTransferTab::DCCTransferTab(QWidget *parent, const char *name, WFlags f)
15 :IRCTab(parent, name, f), m_hbox(new QHBox(this)), m_parent(static_cast<MainWindow*>(parent))
16{
17 m_description->setText("");
18 m_layout->add(m_hbox);
19 m_hbox->show();
20}
21
22DCCTransferTab::~DCCTransferTab()
23{
24 if(m_hbox)
25 delete m_hbox;
26}
27
28QString DCCTransferTab::title()
29{
30 return "DCC";
31}
32
33void DCCTransferTab::remove()
34{
35 //Clean finished transfers
36 for(QListIterator <DCCProgress> it(m_progressList); it.current(); ++it) {
37 DCCProgress *current = it.current();
38 if (current->finished()) {
39 m_progressList.remove(current);
40 current->hide();
41 delete current;
42 }
43 }
44
45 if (m_progressList.count() > 0) {
46 int retval = QMessageBox::information( parentWidget() , tr("DCC Transfers in Progress"),
47 tr( "There are transfers in progress. <br>If you close this tab, they will be canceled."
48 "<br>Do you want to close it anyway?"),
49 tr("&Close"), tr("&Don't Close"));
50 if ( retval != 0 ) {
51 return;
52 }
53 //Cancel active transfers (user accepted)
54 for(QListIterator <DCCProgress> itr(m_progressList); itr.current(); ++itr) {
55 DCCProgress *current = itr.current();
56 m_progressList.remove(current);
57 current->hide();
58 current->cancel();
59 delete current;
60 }
61 }
62
63 //Remove
64 m_parent->killTab(this);
65}
66
67bool DCCTransferTab::confirm(QWidget *parent, const QString &nickname, const QString &filename, unsigned int size)
68{
69 int retval = QMessageBox::information(parent, tr("DCC Transfer from %1").arg(nickname),
70 tr( "%1 is trying to send you the file %2\n(%3 bytes)").arg(nickname).arg(filename).arg(size),
71 tr("&Accept"), tr("&Reject"));
72
73 return ( 0 == retval);
74
75}
76
77void DCCTransferTab::addTransfer(DCCTransfer::Type type, Q_UINT32 ip4Addr, Q_UINT16 port,
78 const QString &filename, const QString &nickname, unsigned int size)
79{
80 m_progressList.append(new DCCProgress(type, ip4Addr, port, filename, nickname, size, this));
81}