From 8aaae9e3eca7853e9c693d2401f721d75209acf7 Mon Sep 17 00:00:00 2001 From: skyhusker Date: Thu, 03 Feb 2005 21:47:50 +0000 Subject: Added DCC receive support --- (limited to 'noncore/net/opieirc/dcctransfertab.cpp') 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 +#include +#include +#include +#include + +#include "dcctransfer.h" +#include "dccprogress.h" +#include "mainwindow.h" +#include "dcctransfertab.h" + +#include + +DCCTransferTab::DCCTransferTab(QWidget *parent, const char *name, WFlags f) + :IRCTab(parent, name, f), m_hbox(new QHBox(this)), m_parent(static_cast(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 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.
If you close this tab, they will be canceled." + "
Do you want to close it anyway?"), + tr("&Close"), tr("&Don't Close")); + if ( retval != 0 ) { + return; + } + //Cancel active transfers (user accepted) + for(QListIterator 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)); +} -- cgit v0.9.0.2