author | skyhusker <skyhusker> | 2005-02-03 21:47:50 (UTC) |
---|---|---|
committer | skyhusker <skyhusker> | 2005-02-03 21:47:50 (UTC) |
commit | 8aaae9e3eca7853e9c693d2401f721d75209acf7 (patch) (side-by-side diff) | |
tree | 6f700d154fac8510b322242496604d0ad7589377 /noncore/net/opieirc/dccprogress.cpp | |
parent | 875b3b63624308f4e50f82e17db27edeb9609d6c (diff) | |
download | opie-8aaae9e3eca7853e9c693d2401f721d75209acf7.zip opie-8aaae9e3eca7853e9c693d2401f721d75209acf7.tar.gz opie-8aaae9e3eca7853e9c693d2401f721d75209acf7.tar.bz2 |
Added DCC receive support
Diffstat (limited to 'noncore/net/opieirc/dccprogress.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opieirc/dccprogress.cpp | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/noncore/net/opieirc/dccprogress.cpp b/noncore/net/opieirc/dccprogress.cpp new file mode 100644 index 0000000..28277f7 --- a/dev/null +++ b/noncore/net/opieirc/dccprogress.cpp @@ -0,0 +1,75 @@ +#include <qprogressbar.h> +#include <qlabel.h> +#include <qvbox.h> + +#include "dcctransfer.h" +#include "dcctransferrecv.h" +#include "dccprogress.h" + +DCCProgress::DCCProgress(DCCTransfer::Type type, Q_UINT32 ip4Addr, Q_UINT16 port, + const QString &filename, const QString &nickname, unsigned int size, QWidget *parent, char *name, WFlags f) + : QWidget(parent, name, f), m_vbox(new QVBox(this)), + m_label(new QLabel(m_vbox)), + m_bar(new QProgressBar(m_vbox)) +{ + + if (DCCTransfer::Recv == type) + m_transfer = new DCCTransferRecv(ip4Addr, port, filename, size); + + + connect(m_transfer, SIGNAL(progress(int)), this, SLOT(slotSetProgress(int))); + connect(m_transfer, SIGNAL(finished(DCCTransfer *, DCCTransfer::EndCode)), + this, SLOT(slotFinished(DCCTransfer *, DCCTransfer::EndCode))); + + m_label->setText(tr("Receiving file %1 from %2...").arg(m_transfer->filename()).arg(nickname)); + + m_label->show(); + m_bar->show(); + show(); + +} + +bool DCCProgress::finished() +{ + return ( m_transfer == 0); +} + +void DCCProgress::cancel() +{ + if (m_transfer) + m_transfer->cancel(); +} + +void DCCProgress::slotSetProgress(int progress) +{ + m_bar->setProgress(progress); +} + +void DCCProgress::slotFinished(DCCTransfer *transfer, DCCTransfer::EndCode code) +{ + if(transfer != m_transfer) + // WTF!! + return; + + QString msg; + + switch(code) { + case DCCTransfer::Successfull: + msg = tr("Successfully received %1").arg(m_transfer->filename()); + break; + case DCCTransfer::SelfAborted: + msg = tr("Aborted"); + break; + case DCCTransfer::PeerAborted: + msg = tr("Peer Aborted"); + break; + case DCCTransfer::Timeout: + msg = tr("Timeout"); + break; + } + + m_label->setText(msg); + delete m_transfer; + m_transfer = 0; +} + |