-rw-r--r-- | noncore/net/opieirc/ircchanneltab.cpp | 8 | ||||
-rw-r--r-- | noncore/net/opieirc/ircchanneltab.h | 1 | ||||
-rw-r--r-- | noncore/net/opieirc/ircquerytab.cpp | 6 | ||||
-rw-r--r-- | noncore/net/opieirc/ircquerytab.h | 1 | ||||
-rw-r--r-- | noncore/net/opieirc/ircservertab.cpp | 111 | ||||
-rw-r--r-- | noncore/net/opieirc/ircservertab.h | 6 | ||||
-rw-r--r-- | noncore/net/opieirc/ircsession.cpp | 37 | ||||
-rw-r--r-- | noncore/net/opieirc/ircsession.h | 10 | ||||
-rw-r--r-- | noncore/net/opieirc/mainwindow.cpp | 5 | ||||
-rw-r--r-- | noncore/net/opieirc/mainwindow.h | 4 |
10 files changed, 172 insertions, 17 deletions
diff --git a/noncore/net/opieirc/ircchanneltab.cpp b/noncore/net/opieirc/ircchanneltab.cpp index c1964c8..beb8bce 100644 --- a/noncore/net/opieirc/ircchanneltab.cpp +++ b/noncore/net/opieirc/ircchanneltab.cpp @@ -26,33 +26,36 @@ IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainW m_list->setMaximumWidth(LISTWIDTH); m_field = new IRCHistoryLineEdit(this); QWhatsThis::add(m_field, tr("Type your message here to participate in the channel discussion")); m_popup = new QPopupMenu(m_list); m_lines = 0; /* Required so that embedded-style "right" clicks work */ QPEApplication::setStylusOperation(m_list->viewport(), QPEApplication::RightOnHold); connect(m_list, SIGNAL(mouseButtonPressed(int, QListBoxItem *, const QPoint&)), this, SLOT(mouseButtonPressed(int, QListBoxItem *, const QPoint &))); - /* Construct the popup menu */ QPopupMenu *ctcpMenu = new QPopupMenu(m_list); m_popup->insertItem(Resource::loadPixmap("opieirc/ctcp"), tr("CTCP"), ctcpMenu); m_popup->insertItem(Resource::loadPixmap("opieirc/query"), tr("Query"), this, SLOT(popupQuery())); ctcpMenu->insertItem(Resource::loadPixmap("opieirc/ping"), tr("Ping"), this, SLOT(popupPing())); ctcpMenu->insertItem(Resource::loadPixmap("opieirc/version"), tr("Version"), this, SLOT(popupVersion())); ctcpMenu->insertItem(Resource::loadPixmap("opieirc/whois"), tr("Whois"), this, SLOT(popupWhois())); - + connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); m_layout->add(hbox); hbox->show(); m_layout->add(m_field); m_field->setFocus(); connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); settingsChanged(); } +void IRCChannelTab::scrolling(){ + m_textview->ensureVisible(0, m_textview->contentsHeight()); +} + void IRCChannelTab::appendText(QString text) { /* not using append because it creates layout problems */ QString txt = m_textview->text() + text + "\n"; if (m_maxLines > 0 && m_lines >= m_maxLines) { int firstBreak = txt.find('\n'); if (firstBreak != -1) { txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); } @@ -124,16 +127,17 @@ void IRCChannelTab::popupQuery() { m_parentTab->addQueryTab(tab); m_mainWindow->addTab(tab); } } } } void IRCChannelTab::popupPing() { + //HAHA, no wonder these don't work } void IRCChannelTab::popupVersion() { } void IRCChannelTab::popupWhois() { } diff --git a/noncore/net/opieirc/ircchanneltab.h b/noncore/net/opieirc/ircchanneltab.h index a03ee3e..001c96d 100644 --- a/noncore/net/opieirc/ircchanneltab.h +++ b/noncore/net/opieirc/ircchanneltab.h @@ -42,16 +42,17 @@ public: IRCSession *session(); IRCChannel *channel(); IRCChannelList *list(); public: void appendText(QString text); public slots: void remove(); void settingsChanged(); + void scrolling(); protected slots: void processCommand(); void toggleList(); void mouseButtonPressed(int mouse, QListBoxItem *item, const QPoint &point); /* Popup slots */ void popupQuery(); void popupPing(); void popupVersion(); diff --git a/noncore/net/opieirc/ircquerytab.cpp b/noncore/net/opieirc/ircquerytab.cpp index 21a53dc..a113b04 100644 --- a/noncore/net/opieirc/ircquerytab.cpp +++ b/noncore/net/opieirc/ircquerytab.cpp @@ -17,19 +17,25 @@ IRCQueryTab::IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow QWhatsThis::add(m_textview, tr("Private discussion")); m_field = new IRCHistoryLineEdit(this); QWhatsThis::add(m_field, tr("Type your text here in order to send a message to the other person")); m_layout->add(hbox); hbox->show(); m_layout->add(m_field); m_field->setFocus(); connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); + connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); settingsChanged(); } +void IRCQueryTab::scrolling(){ + m_textview->ensureVisible(0, m_textview->contentsHeight()); +} + + void IRCQueryTab::appendText(QString text) { /* not using append because it creates layout problems */ QString txt = m_textview->text() + text + "\n"; if (m_maxLines > 0 && m_lines >= m_maxLines) { int firstBreak = txt.find('\n'); if (firstBreak != -1) { txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); } diff --git a/noncore/net/opieirc/ircquerytab.h b/noncore/net/opieirc/ircquerytab.h index f9cc8e1..b3b04fb 100644 --- a/noncore/net/opieirc/ircquerytab.h +++ b/noncore/net/opieirc/ircquerytab.h @@ -32,16 +32,17 @@ public: /* IRCTab implementation */ IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0); ~IRCQueryTab(); QString title(); IRCSession *session(); IRCPerson *person(); void appendText(QString text); public slots: + void scrolling(); void remove(); void processCommand(); void display(IRCOutput output); void settingsChanged(); protected: bool m_close; MainWindow *m_mainWindow; IRCServerTab *m_parentTab; diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp index 5aa447f..1d9520a 100644 --- a/noncore/net/opieirc/ircservertab.cpp +++ b/noncore/net/opieirc/ircservertab.cpp @@ -17,19 +17,25 @@ IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *pa QWhatsThis::add(m_textview, tr("Server messages")); m_layout->add(m_textview); m_field = new IRCHistoryLineEdit(this); QWhatsThis::add(m_field, tr("Type commands here. A list of available commands can be found inside the OpieIRC help")); m_layout->add(m_field); connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); m_field->setFocus(); connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput))); + connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); settingsChanged(); } +void IRCServerTab::scrolling(){ + m_textview->ensureVisible(0, m_textview->contentsHeight()); +} + + void IRCServerTab::appendText(QString text) { /* not using append because it creates layout problems */ QString txt = m_textview->text() + text + "\n"; if (m_maxLines > 0 && m_lines >= m_maxLines) { int firstBreak = txt.find('\n'); if (firstBreak != -1) { txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); } @@ -59,67 +65,150 @@ void IRCServerTab::addQueryTab(IRCQueryTab *tab) { QString IRCServerTab::title() { return "Server"; } IRCSession *IRCServerTab::session() { return m_session; } +/* +QString *IRCServerTab::mynick() { + return (*m_server->nick()); +} */ IRCServer *IRCServerTab::server() { return &m_server; } void IRCServerTab::settingsChanged() { m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); m_lines = 0; } void IRCServerTab::executeCommand(IRCTab *tab, QString line) { QTextIStream stream(&line); QString command; stream >> command; command = command.upper().right(command.length()-1); - - if (command == "JOIN") { + + //JOIN + if (command == "JOIN" || command == "J") { QString channel; stream >> channel; if (channel.length() > 0 && (channel.startsWith("#") || channel.startsWith("+"))) { m_session->join(channel); } else { - tab->appendText("<font color=\"" + m_errorColor + "\">Unknown channel format!</font><br>"); + tab->appendText("<font color=\"" + m_errorColor + "\">Unknown channel format!</font><br>"); } - } else if (command == "ME") { + } + + //KICK + else if (command == "KICK"){ + QString nickname; + stream >> nickname; + if (nickname.length() > 0) { + if (line.length() > 7 + nickname.length()) { + QString text = line.right(line.length()-nickname.length()-7); + IRCPerson person; + person.setNick(nickname); + m_session->kick(((IRCChannelTab *)tab)->channel(), &person, text); + } else { + IRCPerson person; + person.setNick(nickname); + m_session->kick(((IRCChannelTab *)tab)->channel(), &person); + } + } + } + + else if (command == "OP"){ + QString nickname; + stream >> nickname; + if (nickname.length() > 0) { + if (line.length() > 7 + nickname.length()) { + QString text = line.right(line.length()-nickname.length()-7); + IRCPerson person; + person.setNick(nickname); + m_session->kick(((IRCChannelTab *)tab)->channel(), &person, text); + } else { + IRCPerson person; + person.setNick(nickname); + m_session->kick(((IRCChannelTab *)tab)->channel(), &person); + } + } + } + + //SEND MODES + else if (command == "MODE"){ + QString text = line.right(line.length()-6); + if (text.length() > 0) { + m_session->mode(text); + } else { + tab->appendText("<font color=\"" + m_errorColor + "\">/mode channel {[+|-]|o|p|s|i|t|n|b|v} [limit] [user] [ban mask]<br>/mode nickname {[+|-]|i|w|s|o}</font><br>"); + } + } + //SEND RAW MESSAGE TO SERVER, COMPLETELY UNCHECKED - anything in the RFC...or really anything you want + else if (command == "RAW"){ + QString text = line.right(line.length()-5); + if (text.length() > 0) { + m_session->raw(text); + } + } + else if (command == "SUSPEND"){ + QString text = line.right(line.length()-9); + if (text.upper() == "ON") { + QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; + } + else if (text.upper() == "OFF"){ + QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; + } else { + tab->appendText("<font color=\"" + m_errorColor + "\">Line: "+ line +"</font><br>Text: "+text); + } + } + + else if (command == "QUIT"){ + QString text = line.right(line.length()-6); + if (text.length() > 0) { + m_session->quit(text); + } else { + m_session->quit(); + } + } + + //SEND ACTION + else if (command == "ME") { QString text = line.right(line.length()-4); if (text.length() > 0) { if (tab->isA("IRCChannelTab")) { tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); m_session->sendAction(((IRCChannelTab *)tab)->channel(), text); } else if (tab->isA("IRCQueryTab")) { tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); m_session->sendAction(((IRCQueryTab *)tab)->person(), text); } else { - tab->appendText("<font color=\"" + m_errorColor + "\">Invalid tab for this command</font><br>"); + tab->appendText("<font color=\"" + m_errorColor + "\">Invalid tab for this command</font><br>"); } } - } else if (command == "MSG") { + } + //SEND PRIVMSG + else if (command == "MSG") { QString nickname; stream >> nickname; if (nickname.length() > 0) { if (line.length() > 6 + nickname.length()) { QString text = line.right(line.length()-nickname.length()-6); IRCPerson person; person.setNick(nickname); tab->appendText("<font color=\"" + m_textColor + "\">></font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(nickname)+"</font><font color=\"" + m_textColor + "\">< "+IRCOutput::toHTML(text)+"</font><br>"); m_session->sendMessage(&person, text); } - } - } else { - tab->appendText("<font color=\"" + m_errorColor + "\">Unknown command</font><br>"); + } + } + else { + tab->appendText("<font color=\"" + m_errorColor + "\">Unknown command</font><br>"); } } void IRCServerTab::processCommand() { QString text = m_field->text(); if (text.startsWith("/") && !text.startsWith("//")) { /* Command mode */ executeCommand(this, text); @@ -148,27 +237,27 @@ void IRCServerTab::remove() { m_mainWindow->killTab(m_queryTabs.current()); } m_mainWindow->killTab(this); } } IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) { QListIterator<IRCChannelTab> it(m_channelTabs); - + for (; it.current(); ++it) { if (it.current()->channel() == channel) return it.current(); } return 0; } IRCQueryTab *IRCServerTab::getTabForQuery(IRCPerson *person) { QListIterator<IRCQueryTab> it(m_queryTabs); - + for (; it.current(); ++it) { if (it.current()->person()->nick() == person->nick()) return it.current(); } return 0; } void IRCServerTab::display(IRCOutput output) { diff --git a/noncore/net/opieirc/ircservertab.h b/noncore/net/opieirc/ircservertab.h index 8d24cba..48200d7 100644 --- a/noncore/net/opieirc/ircservertab.h +++ b/noncore/net/opieirc/ircservertab.h @@ -15,49 +15,53 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef __IRCSERVERTAB_H #define __IRCSERVERTAB_H - +#include <qpe/qpeapplication.h> +#include <qpe/qcopenvelope_qws.h> #include "irctab.h" #include "ircsession.h" #include "mainwindow.h" #include "ircchanneltab.h" #include "ircquerytab.h" #include "ircmisc.h" + class IRCServerTab : public IRCTab { Q_OBJECT public: /* IRCTab implementation */ IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0); ~IRCServerTab(); QString title(); IRCSession *session(); IRCServer *server(); /* Start the server session */ void doConnect(); +// QString *mynick(); /* Remove tabs from the internal tab lists */ void removeChannelTab(IRCChannelTab *tab); void removeQueryTab(IRCQueryTab *tab); /* Return tabs from the internal tab lists */ IRCChannelTab *getTabForChannel(IRCChannel *channel); IRCQueryTab *getTabForQuery(IRCPerson *person); /* Add tabs to the internal tab lists */ void addQueryTab(IRCQueryTab *tab); /* Execute a user command such as /join, /msg etc */ void executeCommand(IRCTab *tab, QString line); protected: void appendText(QString text); public slots: + void scrolling(); void remove(); void processCommand(); void settingsChanged(); protected slots: void display(IRCOutput output); protected: int m_lines; bool m_close; diff --git a/noncore/net/opieirc/ircsession.cpp b/noncore/net/opieirc/ircsession.cpp index 122a943..1cc1ee2 100644 --- a/noncore/net/opieirc/ircsession.cpp +++ b/noncore/net/opieirc/ircsession.cpp @@ -23,16 +23,52 @@ IRCSession::~IRCSession() { void IRCSession::beginSession() { m_connection->doConnect(); } void IRCSession::join(QString channelname) { m_connection->sendLine("JOIN "+channelname); } +void IRCSession::quit(){ + m_connection->sendLine("QUIT :[OI] I'm too good to need a reason"); +} + +void IRCSession::quit(QString message){ + m_connection->sendLine("QUIT :" + message); +} + +void IRCSession::topic(IRCChannel *channel, QString message){ + m_connection->sendLine("TOPIC :" + channel->channelname() + " " + message); +} + +void IRCSession::mode(IRCChannel *channel, QString message){ + m_connection->sendLine("MODE " + channel->channelname() + " " + message); +} + +void IRCSession::mode(IRCPerson *person, QString message){ + m_connection->sendLine("MODE " + person->nick() + " " + message); +} + +void IRCSession::mode(QString message){ + m_connection->sendLine("MODE " + message); +} + +void IRCSession::raw(QString message){ + m_connection->sendLine(message); +} + +void IRCSession::kick(IRCChannel *channel, IRCPerson *person) { + m_connection->sendLine("KICK "+ channel->channelname() + " " + person->nick() +" :0wn3d - no reason"); +} + +void IRCSession::kick(IRCChannel *channel, IRCPerson *person, QString message) { + m_connection->sendLine("KICK "+ channel->channelname() + " " + person->nick() +" :" + message); +} + void IRCSession::sendMessage(IRCPerson *person, QString message) { m_connection->sendLine("PRIVMSG " + person->nick() + " :" + message); } void IRCSession::sendMessage(IRCChannel *channel, QString message) { m_connection->sendLine("PRIVMSG " + channel->channelname() + " :" + message); } @@ -103,9 +139,8 @@ void IRCSession::removeChannel(IRCChannel *channel) { void IRCSession::removePerson(IRCPerson *person) { m_people.remove(person); } void IRCSession::handleMessage(IRCMessage *message) { m_parser->parse(message); } - diff --git a/noncore/net/opieirc/ircsession.h b/noncore/net/opieirc/ircsession.h index aa4bed3..a6a3e50 100644 --- a/noncore/net/opieirc/ircsession.h +++ b/noncore/net/opieirc/ircsession.h @@ -38,21 +38,29 @@ class IRCMessageParser; class IRCSession : public QObject { friend class IRCMessageParser; Q_OBJECT public: IRCSession(IRCServer *server); ~IRCSession(); void join(QString channel); + void quit(QString message); + void quit(); + void raw(QString message); + void topic(IRCChannel *channel, QString message); + void mode(IRCChannel *channel, QString message); + void mode(IRCPerson *person, QString message); + void mode(QString message); void part(IRCChannel *channel); + void kick(IRCChannel *channel, IRCPerson *person); + void kick(IRCChannel *channel, IRCPerson *person, QString message); void beginSession(); bool isSessionActive(); void endSession(); - void sendMessage(IRCPerson *person, QString message); void sendMessage(IRCChannel *channel, QString message); void sendAction(IRCPerson *person, QString message); void sendAction(IRCChannel *channel, QString message); IRCChannel *getChannel(QString channelname); IRCPerson *getPerson(QString nickname); protected: void addPerson(IRCPerson *person); diff --git a/noncore/net/opieirc/mainwindow.cpp b/noncore/net/opieirc/mainwindow.cpp index 3ed29e3..8f76cdd 100644 --- a/noncore/net/opieirc/mainwindow.cpp +++ b/noncore/net/opieirc/mainwindow.cpp @@ -25,31 +25,36 @@ MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow( a->addTo(irc); a = new QAction(tr("Settings"), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0); a->setWhatsThis(tr("Configure OpieIRC's behavior and appearance")); connect(a, SIGNAL(activated()), this, SLOT(settings())); a->addTo(irc); loadSettings(); } +/*IRCTabWidget MainWindow::getTabWidget(){ + return m_tabWidget; +} */ + void MainWindow::loadSettings() { Config config("OpieIRC"); config.setGroup("OpieIRC"); IRCTab::m_backgroundColor = config.readEntry("BackgroundColor", "#FFFFFF"); IRCTab::m_textColor = config.readEntry("TextColor", "#000000"); IRCTab::m_errorColor = config.readEntry("ErrorColor", "#FF0000"); IRCTab::m_selfColor = config.readEntry("SelfColor", "#CC0000"); IRCTab::m_otherColor = config.readEntry("OtherColor", "#0000BB"); IRCTab::m_serverColor = config.readEntry("ServerColor", "#0000FF"); IRCTab::m_notificationColor = config.readEntry("NotificationColor", "#AA3300"); IRCTab::m_maxLines = config.readNumEntry("Lines", 100); } void MainWindow::selected(QWidget *) { m_tabWidget->setTabColor(m_tabWidget->currentPageIndex(), black); + emit updateScroll(); } void MainWindow::addTab(IRCTab *tab) { connect(tab, SIGNAL(changed(IRCTab *)), this, SLOT(changeEvent(IRCTab *))); m_tabWidget->addTab(tab, tab->title()); m_tabWidget->showPage(tab); tab->setID(m_tabWidget->currentPageIndex()); m_tabs.append(tab); diff --git a/noncore/net/opieirc/mainwindow.h b/noncore/net/opieirc/mainwindow.h index 9946f10..bd1a9ce 100644 --- a/noncore/net/opieirc/mainwindow.h +++ b/noncore/net/opieirc/mainwindow.h @@ -27,19 +27,21 @@ #include "mainwindow.h" #include "ircmisc.h" #include "irctab.h" class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow(QWidget *parent = 0, const char *name = 0, WFlags f = 0); - +// IRCTabWidget getTabWidget(); void addTab(IRCTab *tab); void killTab(IRCTab *tab); +signals: + void updateScroll(); protected slots: void newConnection(); void settings(); void selected(QWidget *); void changeEvent(IRCTab *); protected: void loadSettings(); protected: |