author | skyhusker <skyhusker> | 2005-02-03 21:47:50 (UTC) |
---|---|---|
committer | skyhusker <skyhusker> | 2005-02-03 21:47:50 (UTC) |
commit | 8aaae9e3eca7853e9c693d2401f721d75209acf7 (patch) (unidiff) | |
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) (show 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 @@ | |||
1 | #include <qprogressbar.h> | ||
2 | #include <qlabel.h> | ||
3 | #include <qvbox.h> | ||
4 | |||
5 | #include "dcctransfer.h" | ||
6 | #include "dcctransferrecv.h" | ||
7 | #include "dccprogress.h" | ||
8 | |||
9 | DCCProgress::DCCProgress(DCCTransfer::Type type, Q_UINT32 ip4Addr, Q_UINT16 port, | ||
10 | const QString &filename, const QString &nickname, unsigned int size, QWidget *parent, char *name, WFlags f) | ||
11 | : QWidget(parent, name, f), m_vbox(new QVBox(this)), | ||
12 | m_label(new QLabel(m_vbox)), | ||
13 | m_bar(new QProgressBar(m_vbox)) | ||
14 | { | ||
15 | |||
16 | if (DCCTransfer::Recv == type) | ||
17 | m_transfer = new DCCTransferRecv(ip4Addr, port, filename, size); | ||
18 | |||
19 | |||
20 | connect(m_transfer, SIGNAL(progress(int)), this, SLOT(slotSetProgress(int))); | ||
21 | connect(m_transfer, SIGNAL(finished(DCCTransfer *, DCCTransfer::EndCode)), | ||
22 | this, SLOT(slotFinished(DCCTransfer *, DCCTransfer::EndCode))); | ||
23 | |||
24 | m_label->setText(tr("Receiving file %1 from %2...").arg(m_transfer->filename()).arg(nickname)); | ||
25 | |||
26 | m_label->show(); | ||
27 | m_bar->show(); | ||
28 | show(); | ||
29 | |||
30 | } | ||
31 | |||
32 | bool DCCProgress::finished() | ||
33 | { | ||
34 | return ( m_transfer == 0); | ||
35 | } | ||
36 | |||
37 | void DCCProgress::cancel() | ||
38 | { | ||
39 | if (m_transfer) | ||
40 | m_transfer->cancel(); | ||
41 | } | ||
42 | |||
43 | void DCCProgress::slotSetProgress(int progress) | ||
44 | { | ||
45 | m_bar->setProgress(progress); | ||
46 | } | ||
47 | |||
48 | void DCCProgress::slotFinished(DCCTransfer *transfer, DCCTransfer::EndCode code) | ||
49 | { | ||
50 | if(transfer != m_transfer) | ||
51 | // WTF!! | ||
52 | return; | ||
53 | |||
54 | QString msg; | ||
55 | |||
56 | switch(code) { | ||
57 | case DCCTransfer::Successfull: | ||
58 | msg = tr("Successfully received %1").arg(m_transfer->filename()); | ||
59 | break; | ||
60 | case DCCTransfer::SelfAborted: | ||
61 | msg = tr("Aborted"); | ||
62 | break; | ||
63 | case DCCTransfer::PeerAborted: | ||
64 | msg = tr("Peer Aborted"); | ||
65 | break; | ||
66 | case DCCTransfer::Timeout: | ||
67 | msg = tr("Timeout"); | ||
68 | break; | ||
69 | } | ||
70 | |||
71 | m_label->setText(msg); | ||
72 | delete m_transfer; | ||
73 | m_transfer = 0; | ||
74 | } | ||
75 | |||