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 | |
parent | 875b3b63624308f4e50f82e17db27edeb9609d6c (diff) | |
download | opie-8aaae9e3eca7853e9c693d2401f721d75209acf7.zip opie-8aaae9e3eca7853e9c693d2401f721d75209acf7.tar.gz opie-8aaae9e3eca7853e9c693d2401f721d75209acf7.tar.bz2 |
Added DCC receive support
-rw-r--r-- | noncore/net/opieirc/dccprogress.cpp | 75 | ||||
-rw-r--r-- | noncore/net/opieirc/dccprogress.h | 35 | ||||
-rw-r--r-- | noncore/net/opieirc/dcctransfer.cpp | 41 | ||||
-rw-r--r-- | noncore/net/opieirc/dcctransfer.h | 44 | ||||
-rw-r--r-- | noncore/net/opieirc/dcctransferrecv.cpp | 53 | ||||
-rw-r--r-- | noncore/net/opieirc/dcctransferrecv.h | 21 | ||||
-rw-r--r-- | noncore/net/opieirc/dcctransfertab.cpp | 81 | ||||
-rw-r--r-- | noncore/net/opieirc/dcctransfertab.h | 41 | ||||
-rw-r--r-- | noncore/net/opieirc/ircmessageparser.cpp | 30 | ||||
-rw-r--r-- | noncore/net/opieirc/ircservertab.cpp | 4 | ||||
-rw-r--r-- | noncore/net/opieirc/ircservertab.h | 1 | ||||
-rw-r--r-- | noncore/net/opieirc/ircsession.cpp | 5 | ||||
-rw-r--r-- | noncore/net/opieirc/ircsession.h | 4 | ||||
-rw-r--r-- | noncore/net/opieirc/mainwindow.cpp | 20 | ||||
-rw-r--r-- | noncore/net/opieirc/mainwindow.h | 8 | ||||
-rw-r--r-- | noncore/net/opieirc/opieirc.pro | 9 |
16 files changed, 459 insertions, 13 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 | |||
diff --git a/noncore/net/opieirc/dccprogress.h b/noncore/net/opieirc/dccprogress.h new file mode 100644 index 0000000..81b922e --- a/dev/null +++ b/noncore/net/opieirc/dccprogress.h | |||
@@ -0,0 +1,35 @@ | |||
1 | #ifndef DCCPROGRESS_H | ||
2 | #define DCCPROGRESS_H | ||
3 | |||
4 | |||
5 | #include <qwidget.h> | ||
6 | |||
7 | #include "dcctransfer.h" | ||
8 | |||
9 | class QProgressBar; | ||
10 | class QLabel; | ||
11 | class QVBox; | ||
12 | |||
13 | class DCCProgress: public QWidget { | ||
14 | |||
15 | Q_OBJECT | ||
16 | public: | ||
17 | DCCProgress(DCCTransfer::Type type, Q_UINT32 ip4Addr, Q_UINT16 port, | ||
18 | const QString &filename, const QString &nickname, unsigned int size, | ||
19 | QWidget *parent = 0, char *name = 0, WFlags f = 0); | ||
20 | |||
21 | bool finished(); | ||
22 | void cancel(); | ||
23 | |||
24 | public slots: | ||
25 | void slotSetProgress(int progress); | ||
26 | void slotFinished(DCCTransfer *transfer, DCCTransfer::EndCode code); | ||
27 | |||
28 | private: | ||
29 | QVBox *m_vbox; | ||
30 | QLabel *m_label; | ||
31 | QProgressBar *m_bar; | ||
32 | DCCTransfer *m_transfer; | ||
33 | }; | ||
34 | |||
35 | #endif | ||
diff --git a/noncore/net/opieirc/dcctransfer.cpp b/noncore/net/opieirc/dcctransfer.cpp new file mode 100644 index 0000000..cfa9f74 --- a/dev/null +++ b/noncore/net/opieirc/dcctransfer.cpp | |||
@@ -0,0 +1,41 @@ | |||
1 | #include <qsocket.h> | ||
2 | #include <qfile.h> | ||
3 | |||
4 | #include "dcctransfer.h" | ||
5 | |||
6 | |||
7 | DCCTransfer::DCCTransfer(Q_UINT32 ip4Addr, Q_UINT16 port, const QString &filename, unsigned int size) | ||
8 | : m_socket(new QSocket), m_file(new QFile), m_bufSize(4096), m_buffer(new char[m_bufSize]), | ||
9 | m_ip4Addr(ip4Addr), m_port(port), m_totalSize(size), m_processedSize(0) | ||
10 | { | ||
11 | m_file->setName(filename); | ||
12 | } | ||
13 | |||
14 | DCCTransfer::~DCCTransfer() | ||
15 | { | ||
16 | if(m_socket) | ||
17 | delete m_socket; | ||
18 | if(m_file) { | ||
19 | m_file->close(); | ||
20 | delete m_file; | ||
21 | } | ||
22 | if(m_buffer) | ||
23 | delete []m_buffer; | ||
24 | } | ||
25 | |||
26 | |||
27 | void DCCTransfer::cancel() | ||
28 | { | ||
29 | if(m_socket) | ||
30 | m_socket->close(); | ||
31 | |||
32 | emit(finished(DCCTransfer::SelfAborted)); | ||
33 | } | ||
34 | |||
35 | QString DCCTransfer::filename() | ||
36 | { | ||
37 | if(!m_file) | ||
38 | return QString::null; | ||
39 | |||
40 | return m_file->name().mid(m_file->name().findRev('/') + 1); | ||
41 | } | ||
diff --git a/noncore/net/opieirc/dcctransfer.h b/noncore/net/opieirc/dcctransfer.h new file mode 100644 index 0000000..775ed24 --- a/dev/null +++ b/noncore/net/opieirc/dcctransfer.h | |||
@@ -0,0 +1,44 @@ | |||
1 | #ifndef DCCTRANSFER_H | ||
2 | #define DCCTRANSFER_H | ||
3 | |||
4 | #include <qobject.h> | ||
5 | |||
6 | class QSocket; | ||
7 | class QFile; | ||
8 | class QString; | ||
9 | |||
10 | class DCCTransfer: public QObject { | ||
11 | Q_OBJECT | ||
12 | public: | ||
13 | enum Type { Send, Recv }; | ||
14 | enum EndCode { Successfull, SelfAborted, PeerAborted, Timeout }; | ||
15 | |||
16 | DCCTransfer(Q_UINT32 ip4Addr, Q_UINT16 port, const QString &filename, unsigned int size); | ||
17 | virtual ~DCCTransfer(); | ||
18 | |||
19 | void cancel(); | ||
20 | |||
21 | QString filename(); | ||
22 | |||
23 | signals: | ||
24 | virtual void finished(DCCTransfer *transfer, EndCode code); | ||
25 | virtual void progress(int progress); | ||
26 | |||
27 | protected slots: | ||
28 | virtual void slotProcess() = 0; | ||
29 | virtual void slotFinished() = 0; | ||
30 | |||
31 | protected: | ||
32 | QSocket *m_socket; | ||
33 | QFile *m_file; | ||
34 | unsigned int m_bufSize; | ||
35 | char *m_buffer; | ||
36 | Q_UINT32 m_ip4Addr; | ||
37 | Q_UINT16 m_port; | ||
38 | unsigned int m_totalSize; | ||
39 | unsigned int m_processedSize; | ||
40 | bool m_cancel; | ||
41 | bool m_timeout; | ||
42 | }; | ||
43 | |||
44 | #endif | ||
diff --git a/noncore/net/opieirc/dcctransferrecv.cpp b/noncore/net/opieirc/dcctransferrecv.cpp new file mode 100644 index 0000000..58e8d09 --- a/dev/null +++ b/noncore/net/opieirc/dcctransferrecv.cpp | |||
@@ -0,0 +1,53 @@ | |||
1 | #include <netinet/in.h> | ||
2 | |||
3 | #include <qfile.h> | ||
4 | #include <qsocket.h> | ||
5 | #include <qhostaddress.h> | ||
6 | |||
7 | #include <opie2/odebug.h> | ||
8 | |||
9 | |||
10 | #include "dcctransferrecv.h" | ||
11 | |||
12 | |||
13 | DCCTransferRecv::DCCTransferRecv(Q_UINT32 ip4Addr, Q_UINT16 port, const QString &filename, unsigned int size) | ||
14 | : DCCTransfer(ip4Addr, port, filename, size) | ||
15 | { | ||
16 | QHostAddress ip(ip4Addr); | ||
17 | m_socket->connectToHost(ip.toString(), m_port); | ||
18 | connect(m_socket, SIGNAL(readyRead()), this, SLOT(slotProcess())); | ||
19 | connect(m_socket, SIGNAL(connectionClosed()), this, SLOT(slotFinished())); | ||
20 | |||
21 | m_file->open(IO_WriteOnly); | ||
22 | } | ||
23 | |||
24 | |||
25 | void DCCTransferRecv::slotProcess() | ||
26 | { | ||
27 | int availableBytes = m_socket->bytesAvailable(); | ||
28 | int receivedBytes = 0; | ||
29 | |||
30 | while(receivedBytes < availableBytes) { | ||
31 | int bytes = m_socket->readBlock(m_buffer, m_bufSize); | ||
32 | receivedBytes += bytes; | ||
33 | m_file->writeBlock(m_buffer, bytes); | ||
34 | } | ||
35 | |||
36 | m_file->flush(); | ||
37 | m_processedSize += availableBytes; | ||
38 | unsigned long value = htonl(m_processedSize); | ||
39 | m_socket->writeBlock((char*)&value, sizeof(unsigned long)); | ||
40 | |||
41 | emit (progress((m_processedSize * 100) / m_totalSize)); | ||
42 | } | ||
43 | |||
44 | void DCCTransferRecv::slotFinished() | ||
45 | { | ||
46 | m_file->close(); | ||
47 | |||
48 | if(m_processedSize == m_totalSize) | ||
49 | emit(finished(this, DCCTransfer::Successfull)); | ||
50 | else | ||
51 | emit(finished(this, DCCTransfer::PeerAborted)); | ||
52 | } | ||
53 | |||
diff --git a/noncore/net/opieirc/dcctransferrecv.h b/noncore/net/opieirc/dcctransferrecv.h new file mode 100644 index 0000000..bfc55ef --- a/dev/null +++ b/noncore/net/opieirc/dcctransferrecv.h | |||
@@ -0,0 +1,21 @@ | |||
1 | #ifndef DCCTRANSFERRECV_H | ||
2 | #define DCCTRANSFERRECV_H | ||
3 | |||
4 | #include "dcctransfer.h" | ||
5 | |||
6 | |||
7 | class DCCTransferRecv: public DCCTransfer { | ||
8 | Q_OBJECT | ||
9 | public: | ||
10 | DCCTransferRecv(Q_UINT32 ip4Addr, Q_UINT16 port, const QString &filename, unsigned int size); | ||
11 | |||
12 | signals: | ||
13 | void finished(DCCTransfer *transfer, DCCTransfer::EndCode code); | ||
14 | |||
15 | public slots: | ||
16 | void slotProcess(); | ||
17 | void slotFinished(); | ||
18 | }; | ||
19 | |||
20 | #endif | ||
21 | |||
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 | |||
14 | DCCTransferTab::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 | |||
22 | DCCTransferTab::~DCCTransferTab() | ||
23 | { | ||
24 | if(m_hbox) | ||
25 | delete m_hbox; | ||
26 | } | ||
27 | |||
28 | QString DCCTransferTab::title() | ||
29 | { | ||
30 | return "DCC"; | ||
31 | } | ||
32 | |||
33 | void 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 | |||
67 | bool 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 | |||
77 | void 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 | } | ||
diff --git a/noncore/net/opieirc/dcctransfertab.h b/noncore/net/opieirc/dcctransfertab.h new file mode 100644 index 0000000..a21323d --- a/dev/null +++ b/noncore/net/opieirc/dcctransfertab.h | |||
@@ -0,0 +1,41 @@ | |||
1 | #ifndef DCCTRANSFERTAB_H | ||
2 | #define DCCTRANSFERTAB_H | ||
3 | |||
4 | #include "dcctransfer.h" | ||
5 | #include "irctab.h" | ||
6 | |||
7 | template <class T> class QList; | ||
8 | |||
9 | class DCCProgress; | ||
10 | class IRCSession; | ||
11 | class QString; | ||
12 | class QHBox; | ||
13 | class MainWindow; | ||
14 | |||
15 | class DCCTransferTab: public IRCTab { | ||
16 | Q_OBJECT | ||
17 | public: | ||
18 | |||
19 | DCCTransferTab(QWidget *parent = 0, const char *name = 0, WFlags f = 0); | ||
20 | ~DCCTransferTab(); | ||
21 | virtual QString DCCTransferTab::title(); | ||
22 | virtual IRCSession* DCCTransferTab::session(){return 0;}; | ||
23 | virtual void DCCTransferTab::appendText(QString){}; | ||
24 | virtual void DCCTransferTab::remove(); | ||
25 | virtual void DCCTransferTab::settingsChanged() {}; | ||
26 | void addTransfer(DCCTransfer::Type type, Q_UINT32 ip4Addr, | ||
27 | Q_UINT16 port, const QString &filename, | ||
28 | const QString &nickname, unsigned int size); | ||
29 | static bool confirm(QWidget *parent = 0, | ||
30 | const QString &nickname = QString::null, | ||
31 | const QString &filename = QString::null, | ||
32 | unsigned int size = 0); | ||
33 | private: | ||
34 | QHBox *m_hbox; | ||
35 | QList <DCCProgress> m_progressList; | ||
36 | MainWindow *m_parent; | ||
37 | |||
38 | }; | ||
39 | |||
40 | #endif | ||
41 | |||
diff --git a/noncore/net/opieirc/ircmessageparser.cpp b/noncore/net/opieirc/ircmessageparser.cpp index ad9de2b..939cdae 100644 --- a/noncore/net/opieirc/ircmessageparser.cpp +++ b/noncore/net/opieirc/ircmessageparser.cpp | |||
@@ -1,23 +1,28 @@ | |||
1 | #include <qtextstream.h> | 1 | #include <qtextstream.h> |
2 | #include <qdatetime.h> | 2 | #include <qdatetime.h> |
3 | 3 | ||
4 | #include <opie2/ofiledialog.h> | ||
5 | #include <opie2/ofileselector.h> | ||
6 | #include <opie2/odebug.h> | ||
7 | |||
4 | #include "ircmessageparser.h" | 8 | #include "ircmessageparser.h" |
5 | #include "ircversion.h" | 9 | #include "ircversion.h" |
6 | #include "ircchannelperson.h" | 10 | #include "ircchannelperson.h" |
7 | //#include "transferreceiver.h" | 11 | #include "dcctransfertab.h" |
12 | #include "ircservertab.h" | ||
8 | 13 | ||
9 | /* Lookup table for literal commands */ | 14 | /* Lookup table for literal commands */ |
10 | IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = { | 15 | IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = { |
11 | { "PING", FUNC(parseLiteralPing) }, | 16 | { "PING", FUNC(parseLiteralPing) }, |
12 | { "NOTICE", FUNC(parseLiteralNotice) }, | 17 | { "NOTICE", FUNC(parseLiteralNotice) }, |
13 | { "JOIN", FUNC(parseLiteralJoin) }, | 18 | { "JOIN", FUNC(parseLiteralJoin) }, |
14 | { "PRIVMSG", FUNC(parseLiteralPrivMsg) }, | 19 | { "PRIVMSG", FUNC(parseLiteralPrivMsg) }, |
15 | { "NICK", FUNC(parseLiteralNick) }, | 20 | { "NICK", FUNC(parseLiteralNick) }, |
16 | { "PART", FUNC(parseLiteralPart) }, | 21 | { "PART", FUNC(parseLiteralPart) }, |
17 | { "QUIT", FUNC(parseLiteralQuit) }, | 22 | { "QUIT", FUNC(parseLiteralQuit) }, |
18 | { "ERROR", FUNC(parseLiteralError) }, | 23 | { "ERROR", FUNC(parseLiteralError) }, |
19 | { "ERROR:", FUNC(parseLiteralError) }, | 24 | { "ERROR:", FUNC(parseLiteralError) }, |
20 | { "MODE", FUNC(parseLiteralMode) }, | 25 | { "MODE", FUNC(parseLiteralMode) }, |
21 | { "KICK", FUNC(parseLiteralKick) }, | 26 | { "KICK", FUNC(parseLiteralKick) }, |
22 | { "TOPIC", FUNC(parseLiteralTopic) }, | 27 | { "TOPIC", FUNC(parseLiteralTopic) }, |
23 | { 0 , 0 } | 28 | { 0 , 0 } |
@@ -448,38 +453,51 @@ void IRCMessageParser::parseCTCPAction(IRCMessage *message) { | |||
448 | if (!person) { | 453 | if (!person) { |
449 | /* Person not yet known, create and add to the current session */ | 454 | /* Person not yet known, create and add to the current session */ |
450 | person = new IRCPerson(message->prefix()); | 455 | person = new IRCPerson(message->prefix()); |
451 | m_session->addPerson(person); | 456 | m_session->addPerson(person); |
452 | } | 457 | } |
453 | IRCOutput output(OUTPUT_QUERYACTION, "*" + mask.nick() + message->param(0)); | 458 | IRCOutput output(OUTPUT_QUERYACTION, "*" + mask.nick() + message->param(0)); |
454 | output.addParam(person); | 459 | output.addParam(person); |
455 | emit outputReady(output); | 460 | emit outputReady(output); |
456 | } else { | 461 | } else { |
457 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with bad recipient"))); | 462 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with bad recipient"))); |
458 | } | 463 | } |
459 | } | 464 | } |
460 | } | 465 | } |
461 | 466 | ||
462 | void IRCMessageParser::parseCTCPDCC(IRCMessage *message) { | 467 | void IRCMessageParser::parseCTCPDCC(IRCMessage *message) { |
463 | QStringList params = QStringList::split(' ', message->param(0).stripWhiteSpace()); | 468 | QStringList params = QStringList::split(' ', message->param(0).stripWhiteSpace()); |
464 | if( params.count() != 5) { | 469 | |
465 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Malformed DCC request from ") + IRCPerson(message->prefix()).nick())); | 470 | if(params[0] == "SEND") { |
466 | return; | 471 | QString nickname = IRCPerson(message->prefix()).nick(); |
472 | if( params.count() != 5) { | ||
473 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Malformed DCC request from %1").arg(nickname))); | ||
474 | return; | ||
475 | } | ||
476 | bool accepted = DCCTransferTab::confirm(static_cast<QWidget*>(m_session->parent()), nickname, params[1], params[4].toUInt()); | ||
477 | if(!accepted) | ||
478 | return; | ||
479 | QString filename = Opie::Ui::OFileDialog::getSaveFileName(Opie::Ui::OFileSelector::EXTENDED_ALL, | ||
480 | QString::null, params[1], MimeTypes(), 0, tr("Save As")); | ||
481 | if(filename.isEmpty()) | ||
482 | return; | ||
483 | |||
484 | odebug << "Receiving file " << filename << " from " << nickname << oendl; | ||
485 | static_cast<IRCServerTab*>(m_session->parent())->mainwindow()->addDCC(DCCTransfer::Recv, params[2].toUInt(), params[3].toUInt(), | ||
486 | filename, nickname, params[4].toUInt()); | ||
467 | } | 487 | } |
468 | |||
469 | //TransferReceiver *foo = new TransferReceiver(params[2].toUInt(), params[3].toUInt(), params[1], params[4].toUInt()); | ||
470 | } | 488 | } |
471 | 489 | ||
472 | void IRCMessageParser::parseLiteralMode(IRCMessage *message) { | 490 | void IRCMessageParser::parseLiteralMode(IRCMessage *message) { |
473 | IRCPerson mask(message->prefix()); | 491 | IRCPerson mask(message->prefix()); |
474 | 492 | ||
475 | if (message->param(0).startsWith("#")) { | 493 | if (message->param(0).startsWith("#")) { |
476 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); | 494 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); |
477 | if (channel) { | 495 | if (channel) { |
478 | QString temp, parameters = message->allParameters().right(message->allParameters().length() - channel->channelname().length() - 1); | 496 | QString temp, parameters = message->allParameters().right(message->allParameters().length() - channel->channelname().length() - 1); |
479 | QTextIStream stream(¶meters); | 497 | QTextIStream stream(¶meters); |
480 | bool set = FALSE; | 498 | bool set = FALSE; |
481 | while (!stream.atEnd()) { | 499 | while (!stream.atEnd()) { |
482 | stream >> temp; | 500 | stream >> temp; |
483 | if (temp.startsWith("+")) { | 501 | if (temp.startsWith("+")) { |
484 | set = TRUE; | 502 | set = TRUE; |
485 | temp = temp.right(1); | 503 | temp = temp.right(1); |
diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp index 62a06e8..d3c0448 100644 --- a/noncore/net/opieirc/ircservertab.cpp +++ b/noncore/net/opieirc/ircservertab.cpp | |||
@@ -399,17 +399,21 @@ void IRCServerTab::display(IRCOutput output) { | |||
399 | break; | 399 | break; |
400 | case OUTPUT_TITLE: | 400 | case OUTPUT_TITLE: |
401 | m_description->setText(output.message()); | 401 | m_description->setText(output.message()); |
402 | break; | 402 | break; |
403 | default: | 403 | default: |
404 | appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() + "</font><br>"); | 404 | appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() + "</font><br>"); |
405 | break; | 405 | break; |
406 | } | 406 | } |
407 | } | 407 | } |
408 | 408 | ||
409 | void IRCServerTab::slotUpdateChannels() { | 409 | void IRCServerTab::slotUpdateChannels() { |
410 | QListIterator<IRCChannelTab> it(m_channelTabs); | 410 | QListIterator<IRCChannelTab> it(m_channelTabs); |
411 | for (; it.current(); ++it) { | 411 | for (; it.current(); ++it) { |
412 | it.current()->list()->update(); | 412 | it.current()->list()->update(); |
413 | } | 413 | } |
414 | } | 414 | } |
415 | |||
416 | MainWindow *IRCServerTab::mainwindow() { | ||
417 | return m_mainWindow; | ||
418 | } | ||
415 | 419 | ||
diff --git a/noncore/net/opieirc/ircservertab.h b/noncore/net/opieirc/ircservertab.h index 42f6f57..fe48a3b 100644 --- a/noncore/net/opieirc/ircservertab.h +++ b/noncore/net/opieirc/ircservertab.h | |||
@@ -28,32 +28,33 @@ | |||
28 | #include "ircchanneltab.h" | 28 | #include "ircchanneltab.h" |
29 | #include "ircquerytab.h" | 29 | #include "ircquerytab.h" |
30 | #include "ircmisc.h" | 30 | #include "ircmisc.h" |
31 | 31 | ||
32 | 32 | ||
33 | class IRCServerTab : public IRCTab { | 33 | class IRCServerTab : public IRCTab { |
34 | Q_OBJECT | 34 | Q_OBJECT |
35 | public: | 35 | public: |
36 | static bool containsPing(const QString& text, IRCServerTab *tab); | 36 | static bool containsPing(const QString& text, IRCServerTab *tab); |
37 | 37 | ||
38 | /* IRCTab implementation */ | 38 | /* IRCTab implementation */ |
39 | IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0); | 39 | IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0); |
40 | ~IRCServerTab(); | 40 | ~IRCServerTab(); |
41 | QString title(); | 41 | QString title(); |
42 | IRCSession *session(); | 42 | IRCSession *session(); |
43 | IRCServer *server(); | 43 | IRCServer *server(); |
44 | MainWindow *mainwindow(); | ||
44 | 45 | ||
45 | /* Start the server session */ | 46 | /* Start the server session */ |
46 | void doConnect(); | 47 | void doConnect(); |
47 | // QString *mynick(); | 48 | // QString *mynick(); |
48 | /* Remove tabs from the internal tab lists */ | 49 | /* Remove tabs from the internal tab lists */ |
49 | void removeChannelTab(IRCChannelTab *tab); | 50 | void removeChannelTab(IRCChannelTab *tab); |
50 | void removeQueryTab(IRCQueryTab *tab); | 51 | void removeQueryTab(IRCQueryTab *tab); |
51 | /* Return tabs from the internal tab lists */ | 52 | /* Return tabs from the internal tab lists */ |
52 | IRCChannelTab *getTabForChannel(IRCChannel *channel); | 53 | IRCChannelTab *getTabForChannel(IRCChannel *channel); |
53 | IRCQueryTab *getTabForQuery(IRCPerson *person); | 54 | IRCQueryTab *getTabForQuery(IRCPerson *person); |
54 | /* Add tabs to the internal tab lists */ | 55 | /* Add tabs to the internal tab lists */ |
55 | void addQueryTab(IRCQueryTab *tab); | 56 | void addQueryTab(IRCQueryTab *tab); |
56 | /* Execute a user command such as /join, /msg etc */ | 57 | /* Execute a user command such as /join, /msg etc */ |
57 | void executeCommand(IRCTab *tab, QString line); | 58 | void executeCommand(IRCTab *tab, QString line); |
58 | protected: | 59 | protected: |
59 | void appendText(QString text); | 60 | void appendText(QString text); |
diff --git a/noncore/net/opieirc/ircsession.cpp b/noncore/net/opieirc/ircsession.cpp index fd8ba72..c8d7869 100644 --- a/noncore/net/opieirc/ircsession.cpp +++ b/noncore/net/opieirc/ircsession.cpp | |||
@@ -1,27 +1,28 @@ | |||
1 | 1 | ||
2 | #include "ircsession.h" | 2 | #include "ircsession.h" |
3 | #include "ircmessageparser.h" | 3 | #include "ircmessageparser.h" |
4 | #include "ircchannelperson.h" | 4 | #include "ircchannelperson.h" |
5 | #include "ircversion.h" | 5 | #include "ircversion.h" |
6 | 6 | ||
7 | IRCSession::IRCSession(QWidget *parent, IRCServer *server) { | 7 | IRCSession::IRCSession(QObject *parent, IRCServer *server) |
8 | : QObject(parent) | ||
9 | { | ||
8 | m_server = server; | 10 | m_server = server; |
9 | m_connection = new IRCConnection(m_server); | 11 | m_connection = new IRCConnection(m_server); |
10 | m_parser = new IRCMessageParser(this); | 12 | m_parser = new IRCMessageParser(this); |
11 | m_parent = parent; | ||
12 | connect(m_connection, SIGNAL(messageArrived(IRCMessage*)), this, SLOT(handleMessage(IRCMessage*))); | 13 | connect(m_connection, SIGNAL(messageArrived(IRCMessage*)), this, SLOT(handleMessage(IRCMessage*))); |
13 | connect(m_parser, SIGNAL(outputReady(IRCOutput)), this, SIGNAL(outputReady(IRCOutput))); | 14 | connect(m_parser, SIGNAL(outputReady(IRCOutput)), this, SIGNAL(outputReady(IRCOutput))); |
14 | connect(m_connection, SIGNAL(outputReady(IRCOutput)), this, SIGNAL(outputReady(IRCOutput))); | 15 | connect(m_connection, SIGNAL(outputReady(IRCOutput)), this, SIGNAL(outputReady(IRCOutput))); |
15 | } | 16 | } |
16 | 17 | ||
17 | IRCSession::~IRCSession() { | 18 | IRCSession::~IRCSession() { |
18 | /* We want this to get deleted automatically */ | 19 | /* We want this to get deleted automatically */ |
19 | m_channels.setAutoDelete(TRUE); | 20 | m_channels.setAutoDelete(TRUE); |
20 | m_people.setAutoDelete(TRUE); | 21 | m_people.setAutoDelete(TRUE); |
21 | 22 | ||
22 | delete m_parser; | 23 | delete m_parser; |
23 | delete m_connection; | 24 | delete m_connection; |
24 | } | 25 | } |
25 | 26 | ||
26 | void IRCSession::beginSession() { | 27 | void IRCSession::beginSession() { |
27 | m_connection->doConnect(); | 28 | m_connection->doConnect(); |
diff --git a/noncore/net/opieirc/ircsession.h b/noncore/net/opieirc/ircsession.h index 7c91893..23a2540 100644 --- a/noncore/net/opieirc/ircsession.h +++ b/noncore/net/opieirc/ircsession.h | |||
@@ -17,42 +17,43 @@ | |||
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | 18 | ||
19 | */ | 19 | */ |
20 | 20 | ||
21 | #ifndef __IRCSESSION_H | 21 | #ifndef __IRCSESSION_H |
22 | #define __IRCSESSION_H | 22 | #define __IRCSESSION_H |
23 | 23 | ||
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qlist.h> | 25 | #include <qlist.h> |
26 | #include "ircserver.h" | 26 | #include "ircserver.h" |
27 | #include "ircconnection.h" | 27 | #include "ircconnection.h" |
28 | #include "ircmessage.h" | 28 | #include "ircmessage.h" |
29 | #include "ircchannel.h" | 29 | #include "ircchannel.h" |
30 | #include "ircoutput.h" | 30 | #include "ircoutput.h" |
31 | 31 | ||
32 | class IRCMessageParser; | 32 | class IRCMessageParser; |
33 | class IRCServerTab; | ||
33 | 34 | ||
34 | /* The IRCSession stores all information relating to the connection | 35 | /* The IRCSession stores all information relating to the connection |
35 | to one IRC server. IRCSession makes it possible to run multiple | 36 | to one IRC server. IRCSession makes it possible to run multiple |
36 | IRC server connections from within the same program */ | 37 | IRC server connections from within the same program */ |
37 | 38 | ||
38 | class IRCSession : public QObject { | 39 | class IRCSession : public QObject { |
39 | friend class IRCMessageParser; | 40 | friend class IRCMessageParser; |
40 | Q_OBJECT | 41 | Q_OBJECT |
41 | public: | 42 | public: |
42 | IRCSession(QWidget *parent, IRCServer *server); | 43 | IRCSession(QObject *parent, IRCServer *server); |
43 | ~IRCSession(); | 44 | ~IRCSession(); |
44 | 45 | ||
45 | void join(QString channel); | 46 | void join(QString channel); |
46 | void quit(QString message); | 47 | void quit(QString message); |
47 | void quit(); | 48 | void quit(); |
48 | void raw(QString message); | 49 | void raw(QString message); |
49 | void topic(IRCChannel *channel, QString message); | 50 | void topic(IRCChannel *channel, QString message); |
50 | void mode(IRCChannel *channel, QString message); | 51 | void mode(IRCChannel *channel, QString message); |
51 | void mode(IRCPerson *person, QString message); | 52 | void mode(IRCPerson *person, QString message); |
52 | void mode(QString message); | 53 | void mode(QString message); |
53 | void part(IRCChannel *channel); | 54 | void part(IRCChannel *channel); |
54 | void op(IRCChannel *channel, IRCPerson *person); | 55 | void op(IRCChannel *channel, IRCPerson *person); |
55 | void kick(IRCChannel *channel, IRCPerson *person); | 56 | void kick(IRCChannel *channel, IRCPerson *person); |
56 | void kick(IRCChannel *channel, IRCPerson *person, QString message); | 57 | void kick(IRCChannel *channel, IRCPerson *person, QString message); |
57 | void beginSession(); | 58 | void beginSession(); |
58 | bool isSessionActive(); | 59 | bool isSessionActive(); |
@@ -77,20 +78,19 @@ protected: | |||
77 | void removeChannel(IRCChannel *channel); | 78 | void removeChannel(IRCChannel *channel); |
78 | void removePerson(IRCPerson *person); | 79 | void removePerson(IRCPerson *person); |
79 | void getChannelsByPerson(IRCPerson *person, QList<IRCChannel> &channels); | 80 | void getChannelsByPerson(IRCPerson *person, QList<IRCChannel> &channels); |
80 | protected slots: | 81 | protected slots: |
81 | void handleMessage(IRCMessage *message); | 82 | void handleMessage(IRCMessage *message); |
82 | signals: | 83 | signals: |
83 | void outputReady(IRCOutput output); | 84 | void outputReady(IRCOutput output); |
84 | void updateChannels(); | 85 | void updateChannels(); |
85 | protected: | 86 | protected: |
86 | IRCServer *m_server; | 87 | IRCServer *m_server; |
87 | IRCConnection *m_connection; | 88 | IRCConnection *m_connection; |
88 | IRCMessageParser *m_parser; | 89 | IRCMessageParser *m_parser; |
89 | QList<IRCChannel> m_channels; | 90 | QList<IRCChannel> m_channels; |
90 | QList<IRCPerson> m_people; | 91 | QList<IRCPerson> m_people; |
91 | QString m_validUsermodes; | 92 | QString m_validUsermodes; |
92 | QString m_validChannelmodes; | 93 | QString m_validChannelmodes; |
93 | QWidget *m_parent; | ||
94 | }; | 94 | }; |
95 | 95 | ||
96 | #endif /* __IRCSESSION_H */ | 96 | #endif /* __IRCSESSION_H */ |
diff --git a/noncore/net/opieirc/mainwindow.cpp b/noncore/net/opieirc/mainwindow.cpp index 1811a0c..3d60107 100644 --- a/noncore/net/opieirc/mainwindow.cpp +++ b/noncore/net/opieirc/mainwindow.cpp | |||
@@ -1,51 +1,56 @@ | |||
1 | #include <qmenubar.h> | 1 | #include <qmenubar.h> |
2 | #include <qpe/resource.h> | 2 | #include <qpe/resource.h> |
3 | 3 | ||
4 | #include <opie2/odebug.h> | 4 | #include <opie2/odebug.h> |
5 | 5 | ||
6 | #include <qwhatsthis.h> | 6 | #include <qwhatsthis.h> |
7 | 7 | ||
8 | #include "mainwindow.h" | 8 | #include "mainwindow.h" |
9 | #include "ircservertab.h" | 9 | #include "ircservertab.h" |
10 | #include "dcctransfertab.h" | ||
10 | #include "ircserverlist.h" | 11 | #include "ircserverlist.h" |
11 | #include "ircsettings.h" | 12 | #include "ircsettings.h" |
12 | 13 | ||
14 | #include <stdio.h> | ||
15 | |||
16 | |||
13 | QString MainWindow::appCaption() { | 17 | QString MainWindow::appCaption() { |
14 | return QObject::tr("Opie IRC"); | 18 | return QObject::tr("Opie IRC"); |
15 | } | 19 | } |
16 | 20 | ||
17 | 21 | ||
18 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { | 22 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { |
19 | setCaption(tr("IRC Client")); | 23 | setCaption(tr("IRC Client")); |
20 | m_tabWidget = new IRCTabWidget(this); | 24 | m_tabWidget = new IRCTabWidget(this); |
21 | QWhatsThis::add(m_tabWidget, tr("Server connections, channels, queries and other things will be placed here")); | 25 | QWhatsThis::add(m_tabWidget, tr("Server connections, channels, queries and other things will be placed here")); |
22 | connect(m_tabWidget, SIGNAL(currentChanged(QWidget*)), this, SLOT(selected(QWidget*))); | 26 | connect(m_tabWidget, SIGNAL(currentChanged(QWidget*)), this, SLOT(selected(QWidget*))); |
23 | setCentralWidget(m_tabWidget); | 27 | setCentralWidget(m_tabWidget); |
24 | setToolBarsMovable(FALSE); | 28 | setToolBarsMovable(FALSE); |
25 | QMenuBar *menuBar = new QMenuBar(this); | 29 | QMenuBar *menuBar = new QMenuBar(this); |
26 | QPopupMenu *irc = new QPopupMenu(this); | 30 | QPopupMenu *irc = new QPopupMenu(this); |
27 | menuBar->insertItem(tr("IRC"), irc); | 31 | menuBar->insertItem(tr("IRC"), irc); |
28 | QAction *a = new QAction(tr("New connection"), Resource::loadPixmap("pass"), QString::null, 0, this, 0); | 32 | QAction *a = new QAction(tr("New connection"), Resource::loadPixmap("pass"), QString::null, 0, this, 0); |
29 | connect(a, SIGNAL(activated()), this, SLOT(newConnection())); | 33 | connect(a, SIGNAL(activated()), this, SLOT(newConnection())); |
30 | a->setWhatsThis(tr("Create a new connection to an IRC server")); | 34 | a->setWhatsThis(tr("Create a new connection to an IRC server")); |
31 | a->addTo(irc); | 35 | a->addTo(irc); |
32 | a = new QAction(tr("Settings"), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0); | 36 | a = new QAction(tr("Settings"), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0); |
33 | a->setWhatsThis(tr("Configure OpieIRC's behavior and appearance")); | 37 | a->setWhatsThis(tr("Configure OpieIRC's behavior and appearance")); |
34 | connect(a, SIGNAL(activated()), this, SLOT(settings())); | 38 | connect(a, SIGNAL(activated()), this, SLOT(settings())); |
35 | a->addTo(irc); | 39 | a->addTo(irc); |
40 | m_dccTab = 0; | ||
36 | loadSettings(); | 41 | loadSettings(); |
37 | } | 42 | } |
38 | 43 | ||
39 | /*IRCTabWidget MainWindow::getTabWidget(){ | 44 | /*IRCTabWidget MainWindow::getTabWidget(){ |
40 | return m_tabWidget; | 45 | return m_tabWidget; |
41 | } */ | 46 | } */ |
42 | 47 | ||
43 | void MainWindow::loadSettings() { | 48 | void MainWindow::loadSettings() { |
44 | Config config("OpieIRC"); | 49 | Config config("OpieIRC"); |
45 | config.setGroup("OpieIRC"); | 50 | config.setGroup("OpieIRC"); |
46 | IRCTab::m_backgroundColor = config.readEntry("BackgroundColor", "#FFFFFF"); | 51 | IRCTab::m_backgroundColor = config.readEntry("BackgroundColor", "#FFFFFF"); |
47 | IRCTab::m_textColor = config.readEntry("TextColor", "#000000"); | 52 | IRCTab::m_textColor = config.readEntry("TextColor", "#000000"); |
48 | IRCTab::m_errorColor = config.readEntry("ErrorColor", "#FF0000"); | 53 | IRCTab::m_errorColor = config.readEntry("ErrorColor", "#FF0000"); |
49 | IRCTab::m_selfColor = config.readEntry("SelfColor", "#CC0000"); | 54 | IRCTab::m_selfColor = config.readEntry("SelfColor", "#CC0000"); |
50 | IRCTab::m_otherColor = config.readEntry("OtherColor", "#0000BB"); | 55 | IRCTab::m_otherColor = config.readEntry("OtherColor", "#0000BB"); |
51 | IRCTab::m_serverColor = config.readEntry("ServerColor", "#0000FF"); | 56 | IRCTab::m_serverColor = config.readEntry("ServerColor", "#0000FF"); |
@@ -64,32 +69,35 @@ void MainWindow::addTab(IRCTab *tab) { | |||
64 | connect(tab, SIGNAL(ping (const QString&)), this, SLOT(slotPing(const QString&))); | 69 | connect(tab, SIGNAL(ping (const QString&)), this, SLOT(slotPing(const QString&))); |
65 | connect(tab, SIGNAL(nextTab()), this, SLOT(slotNextTab())); | 70 | connect(tab, SIGNAL(nextTab()), this, SLOT(slotNextTab())); |
66 | connect(tab, SIGNAL(prevTab()), this, SLOT(slotPrevTab())); | 71 | connect(tab, SIGNAL(prevTab()), this, SLOT(slotPrevTab())); |
67 | 72 | ||
68 | m_tabWidget->addTab(tab, tab->title()); | 73 | m_tabWidget->addTab(tab, tab->title()); |
69 | m_tabWidget->showPage(tab); | 74 | m_tabWidget->showPage(tab); |
70 | tab->setID(m_tabWidget->currentPageIndex()); | 75 | tab->setID(m_tabWidget->currentPageIndex()); |
71 | m_tabs.append(tab); | 76 | m_tabs.append(tab); |
72 | } | 77 | } |
73 | 78 | ||
74 | void MainWindow::changeEvent(IRCTab *tab) { | 79 | void MainWindow::changeEvent(IRCTab *tab) { |
75 | if (tab->id() != m_tabWidget->currentPageIndex()) | 80 | if (tab->id() != m_tabWidget->currentPageIndex()) |
76 | m_tabWidget->setTabColor(tab->id(), blue); | 81 | m_tabWidget->setTabColor(tab->id(), blue); |
77 | } | 82 | } |
78 | 83 | ||
79 | void MainWindow::killTab(IRCTab *tab, bool imediate) { | 84 | void MainWindow::killTab(IRCTab *tab, bool imediate) { |
85 | if (tab == m_dccTab) | ||
86 | m_dccTab = 0; | ||
87 | |||
80 | m_toDelete.append( tab ); | 88 | m_toDelete.append( tab ); |
81 | 89 | ||
82 | if ( imediate ) | 90 | if ( imediate ) |
83 | slotKillTabsLater(); | 91 | slotKillTabsLater(); |
84 | else | 92 | else |
85 | QTimer::singleShot(0, this, SLOT(slotKillTabsLater()) ); | 93 | QTimer::singleShot(0, this, SLOT(slotKillTabsLater()) ); |
86 | } | 94 | } |
87 | 95 | ||
88 | void MainWindow::slotKillTabsLater() { | 96 | void MainWindow::slotKillTabsLater() { |
89 | for ( QListIterator<IRCTab> it(m_toDelete); it.current(); ++it ) { | 97 | for ( QListIterator<IRCTab> it(m_toDelete); it.current(); ++it ) { |
90 | m_tabWidget->removePage( it.current() ); | 98 | m_tabWidget->removePage( it.current() ); |
91 | odebug << it.current() << oendl; | 99 | odebug << it.current() << oendl; |
92 | m_tabs.remove( it.current() ); | 100 | m_tabs.remove( it.current() ); |
93 | } | 101 | } |
94 | 102 | ||
95 | m_toDelete.setAutoDelete( true ); | 103 | m_toDelete.setAutoDelete( true ); |
@@ -124,16 +132,28 @@ void MainWindow::slotNextTab() { | |||
124 | 132 | ||
125 | int j = m_tabWidget->currentPageIndex (); | 133 | int j = m_tabWidget->currentPageIndex (); |
126 | if ( i == j ) | 134 | if ( i == j ) |
127 | m_tabWidget->setCurrentPage ( 1 ); | 135 | m_tabWidget->setCurrentPage ( 1 ); |
128 | } | 136 | } |
129 | 137 | ||
130 | void MainWindow::slotPrevTab() { | 138 | void MainWindow::slotPrevTab() { |
131 | int i = m_tabWidget->currentPageIndex (); | 139 | int i = m_tabWidget->currentPageIndex (); |
132 | if ( i > 1 ) | 140 | if ( i > 1 ) |
133 | m_tabWidget->setCurrentPage ( i-1 ); | 141 | m_tabWidget->setCurrentPage ( i-1 ); |
134 | } | 142 | } |
135 | 143 | ||
136 | void MainWindow::slotPing( const QString& /*channel*/ ) { | 144 | void MainWindow::slotPing( const QString& /*channel*/ ) { |
137 | raise(); | 145 | raise(); |
138 | } | 146 | } |
139 | 147 | ||
148 | void MainWindow::addDCC(DCCTransfer::Type type, Q_UINT32 ip4Addr, Q_UINT16 port, | ||
149 | const QString &filename, const QString &nickname, unsigned int size) { | ||
150 | |||
151 | if (!m_dccTab) { | ||
152 | m_dccTab = new DCCTransferTab(this); | ||
153 | addTab(m_dccTab); | ||
154 | m_dccTab->show(); | ||
155 | } | ||
156 | |||
157 | m_dccTab->addTransfer(type, ip4Addr, port, filename, nickname, size); | ||
158 | } | ||
159 | |||
diff --git a/noncore/net/opieirc/mainwindow.h b/noncore/net/opieirc/mainwindow.h index abf205d..873a685 100644 --- a/noncore/net/opieirc/mainwindow.h +++ b/noncore/net/opieirc/mainwindow.h | |||
@@ -11,51 +11,57 @@ | |||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | 18 | ||
19 | */ | 19 | */ |
20 | 20 | ||
21 | #ifndef __MAINWINDOW_H | 21 | #ifndef __MAINWINDOW_H |
22 | #define __MAINWINDOW_H | 22 | #define __MAINWINDOW_H |
23 | 23 | ||
24 | #include <qmainwindow.h> | 24 | #include <qmainwindow.h> |
25 | #include <qaction.h> | 25 | #include <qaction.h> |
26 | #include <qlist.h> | 26 | #include <qlist.h> |
27 | #include "mainwindow.h" | 27 | |
28 | #include "dcctransfer.h" | ||
28 | #include "ircmisc.h" | 29 | #include "ircmisc.h" |
29 | #include "irctab.h" | 30 | #include "irctab.h" |
30 | 31 | ||
32 | class DCCTransferTab; | ||
33 | |||
31 | class MainWindow : public QMainWindow { | 34 | class MainWindow : public QMainWindow { |
32 | Q_OBJECT | 35 | Q_OBJECT |
33 | public: | 36 | public: |
34 | MainWindow(QWidget *parent = 0, const char *name = 0, WFlags f = 0); | 37 | MainWindow(QWidget *parent = 0, const char *name = 0, WFlags f = 0); |
35 | // IRCTabWidget getTabWidget(); | 38 | // IRCTabWidget getTabWidget(); |
36 | void addTab(IRCTab *tab); | 39 | void addTab(IRCTab *tab); |
37 | void killTab(IRCTab *tab, bool now = false); | 40 | void killTab(IRCTab *tab, bool now = false); |
38 | static QString appName() { return QString::fromLatin1("opieirc"); } | 41 | static QString appName() { return QString::fromLatin1("opieirc"); } |
39 | static QString appCaption(); | 42 | static QString appCaption(); |
43 | void addDCC(DCCTransfer::Type type, Q_UINT32 ip4Addr, Q_UINT16 port, | ||
44 | const QString &filename, const QString &nickname, unsigned int size); | ||
40 | signals: | 45 | signals: |
41 | void updateScroll(); | 46 | void updateScroll(); |
42 | protected slots: | 47 | protected slots: |
43 | void newConnection(); | 48 | void newConnection(); |
44 | void settings(); | 49 | void settings(); |
45 | void selected(QWidget *); | 50 | void selected(QWidget *); |
46 | void changeEvent(IRCTab *); | 51 | void changeEvent(IRCTab *); |
47 | 52 | ||
48 | void slotNextTab(); | 53 | void slotNextTab(); |
49 | void slotPrevTab(); | 54 | void slotPrevTab(); |
50 | void slotPing(const QString&); | 55 | void slotPing(const QString&); |
51 | void slotKillTabsLater(); | 56 | void slotKillTabsLater(); |
52 | 57 | ||
53 | protected: | 58 | protected: |
54 | void loadSettings(); | 59 | void loadSettings(); |
55 | protected: | 60 | protected: |
56 | IRCTabWidget *m_tabWidget; | 61 | IRCTabWidget *m_tabWidget; |
57 | QList<IRCTab> m_tabs; | 62 | QList<IRCTab> m_tabs; |
58 | QList<IRCTab> m_toDelete; | 63 | QList<IRCTab> m_toDelete; |
64 | DCCTransferTab *m_dccTab; | ||
59 | }; | 65 | }; |
60 | 66 | ||
61 | #endif /* __MAINWINDOW_H */ | 67 | #endif /* __MAINWINDOW_H */ |
diff --git a/noncore/net/opieirc/opieirc.pro b/noncore/net/opieirc/opieirc.pro index 1ef9be2..5e91450 100644 --- a/noncore/net/opieirc/opieirc.pro +++ b/noncore/net/opieirc/opieirc.pro | |||
@@ -1,30 +1,35 @@ | |||
1 | CONFIG = qt warn_on quick-app | 1 | CONFIG = qt warn_on quick-app |
2 | HEADERS = ircchannel.h ircconnection.h \ | 2 | HEADERS = ircchannel.h ircconnection.h \ |
3 | ircmessage.h \ | 3 | ircmessage.h \ |
4 | ircmessageparser.h ircoutput.h \ | 4 | ircmessageparser.h ircoutput.h \ |
5 | ircperson.h ircserver.h ircsession.h \ | 5 | ircperson.h ircserver.h ircsession.h \ |
6 | mainwindow.h irctab.h ircservertab.h \ | 6 | mainwindow.h irctab.h ircservertab.h \ |
7 | ircchanneltab.h ircchannellist.h \ | 7 | ircchanneltab.h ircchannellist.h \ |
8 | ircserverlist.h ircservereditor.h \ | 8 | ircserverlist.h ircservereditor.h \ |
9 | ircquerytab.h ircsettings.h ircmisc.h \ | 9 | ircquerytab.h ircsettings.h ircmisc.h \ |
10 | ircchannelperson.h | 10 | ircchannelperson.h dcctransfertab.h \ |
11 | dccprogress.h dcctransfer.h \ | ||
12 | dcctransferrecv.h | ||
11 | SOURCES = ircchannel.cpp ircconnection.cpp \ | 13 | SOURCES = ircchannel.cpp ircconnection.cpp \ |
12 | ircmessage.cpp \ | 14 | ircmessage.cpp \ |
13 | ircmessageparser.cpp ircoutput.cpp \ | 15 | ircmessageparser.cpp ircoutput.cpp \ |
14 | ircperson.cpp ircserver.cpp \ | 16 | ircperson.cpp ircserver.cpp \ |
15 | ircsession.cpp main.cpp mainwindow.cpp \ | 17 | ircsession.cpp main.cpp mainwindow.cpp \ |
16 | irctab.cpp ircservertab.cpp \ | 18 | irctab.cpp ircservertab.cpp \ |
17 | ircchanneltab.cpp ircchannellist.cpp \ | 19 | ircchanneltab.cpp ircchannellist.cpp \ |
18 | ircserverlist.cpp ircservereditor.cpp \ | 20 | ircserverlist.cpp ircservereditor.cpp \ |
19 | ircquerytab.cpp ircsettings.cpp ircmisc.cpp \ | 21 | ircquerytab.cpp ircsettings.cpp ircmisc.cpp \ |
20 | ircchannelperson.cpp | 22 | ircchannelperson.cpp dcctransfertab.cpp \ |
23 | dccprogress.cpp dcctransfer.cpp \ | ||
24 | dcctransferrecv.cpp | ||
25 | |||
21 | INCLUDEPATH += $(OPIEDIR)/include | 26 | INCLUDEPATH += $(OPIEDIR)/include |
22 | DEPENDPATH += $(OPIEDIR)/include | 27 | DEPENDPATH += $(OPIEDIR)/include |
23 | 28 | ||
24 | PRECOMPILED_HEADER = stable.h | 29 | PRECOMPILED_HEADER = stable.h |
25 | 30 | ||
26 | LIBS += -lqpe -lopiecore2 -lopieui2 -lqtaux2 | 31 | LIBS += -lqpe -lopiecore2 -lopieui2 -lqtaux2 |
27 | TARGET = opieirc | 32 | TARGET = opieirc |
28 | 33 | ||
29 | 34 | ||
30 | include( $(OPIEDIR)/include.pro ) | 35 | include( $(OPIEDIR)/include.pro ) |