summaryrefslogtreecommitdiff
authorfliplap <fliplap>2003-07-22 05:36:18 (UTC)
committer fliplap <fliplap>2003-07-22 05:36:18 (UTC)
commitd672a787dd122410063ac6cb721be8b5f8cd418e (patch) (side-by-side diff)
treed29b21fc979c41a48b2d201c9b37647e729c521c
parent2fdb15d45c336bbe1540bd9de6b5bfaea13df163 (diff)
downloadopie-d672a787dd122410063ac6cb721be8b5f8cd418e.zip
opie-d672a787dd122410063ac6cb721be8b5f8cd418e.tar.gz
opie-d672a787dd122410063ac6cb721be8b5f8cd418e.tar.bz2
fixed scroll issue, added many commands
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/ircchanneltab.cpp8
-rw-r--r--noncore/net/opieirc/ircchanneltab.h1
-rw-r--r--noncore/net/opieirc/ircquerytab.cpp6
-rw-r--r--noncore/net/opieirc/ircquerytab.h1
-rw-r--r--noncore/net/opieirc/ircservertab.cpp111
-rw-r--r--noncore/net/opieirc/ircservertab.h6
-rw-r--r--noncore/net/opieirc/ircsession.cpp37
-rw-r--r--noncore/net/opieirc/ircsession.h10
-rw-r--r--noncore/net/opieirc/mainwindow.cpp5
-rw-r--r--noncore/net/opieirc/mainwindow.h4
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
@@ -28,29 +28,32 @@ IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainW
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) {
@@ -126,12 +129,13 @@ void IRCChannelTab::popupQuery() {
}
}
}
}
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
@@ -44,12 +44,13 @@ public:
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();
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
@@ -19,15 +19,21 @@ IRCQueryTab::IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow
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) {
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
@@ -34,12 +34,13 @@ public:
~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;
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
@@ -19,15 +19,21 @@ IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *pa
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) {
@@ -61,12 +67,16 @@ 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() {
@@ -76,48 +86,127 @@ void IRCServerTab::settingsChanged() {
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 + "\">&gt;</font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(nickname)+"</font><font color=\"" + m_textColor + "\">&lt; "+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("//")) {
@@ -150,23 +239,23 @@ void IRCServerTab::remove() {
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;
}
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
@@ -17,32 +17,35 @@
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);
@@ -50,12 +53,13 @@ public:
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:
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
@@ -25,12 +25,48 @@ void IRCSession::beginSession() {
}
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);
@@ -105,7 +141,6 @@ 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
@@ -40,17 +40,25 @@ 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);
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
@@ -27,12 +27,16 @@ MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(
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");
@@ -42,12 +46,13 @@ void MainWindow::loadSettings() {
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);
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
@@ -29,15 +29,17 @@
#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: