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) (side-by-side diff)
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 @@
+#include <qlist.h>
+#include <qlabel.h>
+#include <qstring.h>
+#include <qvbox.h>
+#include <qmessagebox.h>
+
+#include "dcctransfer.h"
+#include "dccprogress.h"
+#include "mainwindow.h"
+#include "dcctransfertab.h"
+
+#include <stdio.h>
+
+DCCTransferTab::DCCTransferTab(QWidget *parent, const char *name, WFlags f)
+ :IRCTab(parent, name, f), m_hbox(new QHBox(this)), m_parent(static_cast<MainWindow*>(parent))
+{
+ m_description->setText("");
+ m_layout->add(m_hbox);
+ m_hbox->show();
+}
+
+DCCTransferTab::~DCCTransferTab()
+{
+ if(m_hbox)
+ delete m_hbox;
+}
+
+QString DCCTransferTab::title()
+{
+ return "DCC";
+}
+
+void DCCTransferTab::remove()
+{
+ //Clean finished transfers
+ for(QListIterator <DCCProgress> it(m_progressList); it.current(); ++it) {
+ DCCProgress *current = it.current();
+ if (current->finished()) {
+ m_progressList.remove(current);
+ current->hide();
+ delete current;
+ }
+ }
+
+ if (m_progressList.count() > 0) {
+ int retval = QMessageBox::information( parentWidget() , tr("DCC Transfers in Progress"),
+ tr( "There are transfers in progress. <br>If you close this tab, they will be canceled."
+ "<br>Do you want to close it anyway?"),
+ tr("&Close"), tr("&Don't Close"));
+ if ( retval != 0 ) {
+ return;
+ }
+ //Cancel active transfers (user accepted)
+ for(QListIterator <DCCProgress> itr(m_progressList); itr.current(); ++itr) {
+ DCCProgress *current = itr.current();
+ m_progressList.remove(current);
+ current->hide();
+ current->cancel();
+ delete current;
+ }
+ }
+
+ //Remove
+ m_parent->killTab(this);
+}
+
+bool DCCTransferTab::confirm(QWidget *parent, const QString &nickname, const QString &filename, unsigned int size)
+{
+ int retval = QMessageBox::information(parent, tr("DCC Transfer from %1").arg(nickname),
+ tr( "%1 is trying to send you the file %2\n(%3 bytes)").arg(nickname).arg(filename).arg(size),
+ tr("&Accept"), tr("&Reject"));
+
+ return ( 0 == retval);
+
+}
+
+void DCCTransferTab::addTransfer(DCCTransfer::Type type, Q_UINT32 ip4Addr, Q_UINT16 port,
+ const QString &filename, const QString &nickname, unsigned int size)
+{
+ m_progressList.append(new DCCProgress(type, ip4Addr, port, filename, nickname, size, this));
+}