From: Manuel Nickschas Date: Sat, 3 May 2008 18:08:02 +0000 (+0000) Subject: Merging -r804:811 from trunk to branches/0.3. X-Git-Tag: 0.3.0~425^2~8 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=6fe30667a4a4747e8fad048dad499f7d2390b044 Merging -r804:811 from trunk to branches/0.3. --- diff --git a/build/buildconf.pri b/build/buildconf.pri index 25d9928f..a5aa5558 100644 --- a/build/buildconf.pri +++ b/build/buildconf.pri @@ -1,10 +1,14 @@ +# This file contains global build settings. Note that you can add stuff to CONFIG +# by using qmake -config stuff +# Notable examples: +# +# -config debug (or release or debug_and_release) +# -config verbose (to enable verbose compiling) + CONFIG += warn_on uic resources qt silent -# CONFIG += incremental link_prl nostrip qt_no_framework -release { - CONFIG *= release strip -} else { - CONFIG *= debug +verbose { + CONFIG -= silent } win32 { diff --git a/src/core/ircserverhandler.cpp b/src/core/ircserverhandler.cpp index 138b7534..c2264ace 100644 --- a/src/core/ircserverhandler.cpp +++ b/src/core/ircserverhandler.cpp @@ -162,7 +162,9 @@ void IrcServerHandler::defaultHandler(QString cmd, const QString &prefix, const // IRC SERVER HANDLER //******************************/ void IrcServerHandler::handleJoin(const QString &prefix, const QList ¶ms) { - if(params.count() < 1) return; + if(!checkParamCount("IrcServerHandler::handleJoin()", params, 1)) + return; + QString channel = serverDecode(params[0]); IrcUser *ircuser = network()->updateNickFromMask(prefix); emit displayMsg(Message::Join, BufferInfo::ChannelBuffer, channel, channel, prefix); @@ -172,11 +174,15 @@ void IrcServerHandler::handleJoin(const QString &prefix, const QList } void IrcServerHandler::handleKick(const QString &prefix, const QList ¶ms) { + if(!checkParamCount("IrcServerHandler::handleKick()", params, 2)) + return; + network()->updateNickFromMask(prefix); IrcUser *victim = network()->ircUser(params[1]); - if(!victim) return; + if(!victim) + return; + QString channel = serverDecode(params[0]); - victim->partChannel(channel); QString msg; @@ -190,10 +196,8 @@ void IrcServerHandler::handleKick(const QString &prefix, const QList } void IrcServerHandler::handleMode(const QString &prefix, const QList ¶ms) { - if(params.count() < 2) { - emit displayMsg(Message::Error, BufferInfo::StatusBuffer, "", tr("Received invalid MODE from %s: %s").arg(prefix).arg(serverDecode(params).join(" "))); + if(!checkParamCount("IrcServerHandler::handleMode()", params, 2)) return; - } if(network()->isChannelName(serverDecode(params[0]))) { // Channel Modes @@ -258,6 +262,9 @@ void IrcServerHandler::handleMode(const QString &prefix, const QList } void IrcServerHandler::handleNick(const QString &prefix, const QList ¶ms) { + if(!checkParamCount("IrcServerHandler::handleNick()", params, 1)) + return; + IrcUser *ircuser = network()->updateNickFromMask(prefix); if(!ircuser) { qWarning() << "IrcServerHandler::handleNick(): Unknown IrcUser!"; @@ -270,7 +277,6 @@ void IrcServerHandler::handleNick(const QString &prefix, const QList ? newnick : prefix; - emit nickChanged(newnick, oldnick); foreach(QString channel, ircuser->channels()) emit displayMsg(Message::Nick, BufferInfo::ChannelBuffer, channel, newnick, sender); @@ -279,10 +285,8 @@ void IrcServerHandler::handleNick(const QString &prefix, const QList } void IrcServerHandler::handleNotice(const QString &prefix, const QList ¶ms) { - if(params.count() < 2) { - qWarning() << "IrcServerHandler::handleNotice(): not enough Parameters:" << prefix << serverDecode(params); + if(!checkParamCount("IrcServerHandler::handleNotice()", params, 2)) return; - } QString target = serverDecode(params[0]); if(prefix.isEmpty() || target == "AUTH") @@ -294,6 +298,9 @@ void IrcServerHandler::handleNotice(const QString &prefix, const QList ¶ms) { + if(!checkParamCount("IrcServerHandler::handlePart()", params, 1)) + return; + IrcUser *ircuser = network()->updateNickFromMask(prefix); QString channel = serverDecode(params[0]); if(!ircuser) { @@ -317,6 +324,9 @@ void IrcServerHandler::handlePing(const QString &prefix, const QList } void IrcServerHandler::handlePrivmsg(const QString &prefix, const QList ¶ms) { + if(!checkParamCount("IrcServerHandler::handlePrivmsg()", params, 1)) + return; + IrcUser *ircuser = network()->updateNickFromMask(prefix); if(!ircuser) { qWarning() << "IrcServerHandler::handlePrivmsg(): Unknown IrcUser!"; @@ -348,7 +358,7 @@ void IrcServerHandler::handleQuit(const QString &prefix, const QList if(!ircuser) return; QString msg; - if(params.count()) + if(params.count() > 0) msg = userDecode(ircuser->nick(), params[0]); foreach(QString channel, ircuser->channels()) @@ -358,23 +368,37 @@ void IrcServerHandler::handleQuit(const QString &prefix, const QList } void IrcServerHandler::handleTopic(const QString &prefix, const QList ¶ms) { + if(!checkParamCount("IrcServerHandler::handleTopic()", params, 1)) + return; + IrcUser *ircuser = network()->updateNickFromMask(prefix); - if(!ircuser) return; - QString channel = serverDecode(params[0]); + if(!ircuser) + return; + + IrcChannel *channel = network()->ircChannel(serverDecode(params[0])); + if(!channel) + return; + QString topic; - if(params.count() >= 2) topic = channelDecode(channel, params[1]); + if(params.count() > 1) + topic = channelDecode(channel->name(), params[1]); - network()->ircChannel(channel)->setTopic(topic); + channel->setTopic(topic); - emit displayMsg(Message::Server, BufferInfo::ChannelBuffer, channel, tr("%1 has changed topic for %2 to: \"%3\"").arg(ircuser->nick()).arg(channel).arg(topic)); + emit displayMsg(Message::Server, BufferInfo::ChannelBuffer, channel->name(), tr("%1 has changed topic for %2 to: \"%3\"").arg(ircuser->nick()).arg(channel->name()).arg(topic)); } /* RPL_WELCOME */ void IrcServerHandler::handle001(const QString &prefix, const QList ¶ms) { + network()->setCurrentServer(prefix); + + if(params.isEmpty()) { + emit displayMsg(Message::Error, BufferInfo::StatusBuffer, "", QString("%1 didn't supply a valid welcome message... expect some serious issues...")); + } // there should be only one param: "Welcome to the Internet Relay Network !@" QString param = serverDecode(params[0]); QString myhostmask = param.section(' ', -1, -1); - network()->setCurrentServer(prefix); + network()->setMyNick(nickFromMask(myhostmask)); emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", param, prefix); @@ -451,8 +475,12 @@ WHOWAS-Message: /* RPL_AWAY - " :" */ void IrcServerHandler::handle301(const QString &prefix, const QList ¶ms) { Q_UNUSED(prefix); + if(!checkParamCount("IrcServerHandler::handle301()", params, 2)) + return; + + QString nickName = serverDecode(params[0]); - QString awayMessage = userDecode(nickName, params.last()); + QString awayMessage = userDecode(nickName, params[1]); IrcUser *ircuser = network()->ircUser(nickName); if(ircuser) { @@ -481,6 +509,9 @@ void IrcServerHandler::handle301(const QString &prefix, const QList /* RPL_WHOISSERVICE - " is registered nick" */ void IrcServerHandler::handle307(const QString &prefix, const QList ¶ms) { Q_UNUSED(prefix) + if(!checkParamCount("IrcServerHandler::handle307()", params, 1)) + return; + QString whoisServiceReply = serverDecode(params).join(" "); IrcUser *ircuser = network()->ircUser(serverDecode(params[0])); if(ircuser) { @@ -492,6 +523,9 @@ void IrcServerHandler::handle307(const QString &prefix, const QList /* RPL_SUSERHOST - " is available for help." */ void IrcServerHandler::handle310(const QString &prefix, const QList ¶ms) { Q_UNUSED(prefix) + if(!checkParamCount("IrcServerHandler::handle310()", params, 1)) + return; + QString suserHost = serverDecode(params).join(" "); IrcUser *ircuser = network()->ircUser(serverDecode(params[0])); if(ircuser) { @@ -503,6 +537,9 @@ void IrcServerHandler::handle310(const QString &prefix, const QList /* RPL_WHOISUSER - " * :" */ void IrcServerHandler::handle311(const QString &prefix, const QList ¶ms) { Q_UNUSED(prefix) + if(!checkParamCount("IrcServerHandler::handle311()", params, 3)) + return; + _whois = true; IrcUser *ircuser = network()->ircUser(serverDecode(params[0])); if(ircuser) { @@ -518,6 +555,9 @@ void IrcServerHandler::handle311(const QString &prefix, const QList /* RPL_WHOISSERVER - " :" */ void IrcServerHandler::handle312(const QString &prefix, const QList ¶ms) { Q_UNUSED(prefix) + if(!checkParamCount("IrcServerHandler::handle312()", params, 2)) + return; + IrcUser *ircuser = network()->ircUser(serverDecode(params[0])); if(ircuser) { ircuser->setServer(serverDecode(params[1])); @@ -534,6 +574,9 @@ void IrcServerHandler::handle312(const QString &prefix, const QList /* RPL_WHOISOPERATOR - " :is an IRC operator" */ void IrcServerHandler::handle313(const QString &prefix, const QList ¶ms) { Q_UNUSED(prefix) + if(!checkParamCount("IrcServerHandler::handle313()", params, 1)) + return; + IrcUser *ircuser = network()->ircUser(serverDecode(params[0])); if(ircuser) { ircuser->setIrcOperator(params.last()); @@ -544,6 +587,9 @@ void IrcServerHandler::handle313(const QString &prefix, const QList /* RPL_WHOWASUSER - " * :" */ void IrcServerHandler::handle314(const QString &prefix, const QList ¶ms) { Q_UNUSED(prefix) + if(!checkParamCount("IrcServerHandler::handle314()", params, 3)) + return; + QString nick = serverDecode(params[0]); QString hostmask = QString("%1@%2").arg(serverDecode(params[1])).arg(serverDecode(params[2])); QString realName = serverDecode(params.last()); @@ -553,20 +599,24 @@ void IrcServerHandler::handle314(const QString &prefix, const QList /* RPL_ENDOFWHO: " :End of WHO list" */ void IrcServerHandler::handle315(const QString &prefix, const QList ¶ms) { Q_UNUSED(prefix); + if(!checkParamCount("IrcServerHandler::handle315()", params, 1)) + return; + QStringList p = serverDecode(params); - if(p.count()) { - if(networkConnection()->setAutoWhoDone(p[0])) { - return; // stay silent - } - p.takeLast(); // should be "End of WHO list" - emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("[Who] End of /WHO list for %1").arg(p.join(" "))); + if(networkConnection()->setAutoWhoDone(p[0])) { + return; // stay silent } + p.takeLast(); // should be "End of WHO list" + emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("[Who] End of /WHO list for %1").arg(p.join(" "))); } /* RPL_WHOISIDLE - " :seconds idle" (real life: " :seconds idle, signon time) */ void IrcServerHandler::handle317(const QString &prefix, const QList ¶ms) { Q_UNUSED(prefix); + if(!checkParamCount("IrcServerHandler::handle317()", params, 2)) + return; + QString nick = serverDecode(params[0]); IrcUser *ircuser = network()->ircUser(nick); if(ircuser) { @@ -574,7 +624,7 @@ void IrcServerHandler::handle317(const QString &prefix, const QList int idleSecs = serverDecode(params[1]).toInt(); idleSecs *= -1; ircuser->setIdleTime(now.addSecs(idleSecs)); - if(params.size()>3) { + if(params.size() > 3) { // if we have more then 3 params we have the obove mentioned "real life" situation int loginTime = serverDecode(params[2]).toInt(); ircuser->setLoginTime(QDateTime::fromTime_t(loginTime)); emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("[Whois] %1 is logged in since %2").arg(ircuser->nick()).arg(ircuser->loginTime().toString())); @@ -598,6 +648,9 @@ void IrcServerHandler::handle318(const QString &prefix, const QList /* RPL_WHOISCHANNELS - " :*( ( "@" / "+" ) " " )" */ void IrcServerHandler::handle319(const QString &prefix, const QList ¶ms) { Q_UNUSED(prefix) + if(!checkParamCount("IrcServerHandler::handle319()", params, 2)) + return; + QString nick = serverDecode(params.first()); QStringList op; QStringList voice; @@ -627,6 +680,9 @@ void IrcServerHandler::handle320(const QString &prefix, const QList /* RPL_NOTOPIC */ void IrcServerHandler::handle331(const QString &prefix, const QList ¶ms) { Q_UNUSED(prefix); + if(!checkParamCount("IrcServerHandler::handle331()", params, 1)) + return; + QString channel = serverDecode(params[0]); network()->ircChannel(channel)->setTopic(QString()); emit displayMsg(Message::Server, BufferInfo::ChannelBuffer, channel, tr("No topic is set for %1.").arg(channel)); @@ -635,6 +691,9 @@ void IrcServerHandler::handle331(const QString &prefix, const QList /* RPL_TOPIC */ void IrcServerHandler::handle332(const QString &prefix, const QList ¶ms) { Q_UNUSED(prefix); + if(!checkParamCount("IrcServerHandler::handle332()", params, 2)) + return; + QString channel = serverDecode(params[0]); QString topic = channelDecode(channel, params[1]); network()->ircChannel(channel)->setTopic(topic); @@ -644,6 +703,9 @@ void IrcServerHandler::handle332(const QString &prefix, const QList /* Topic set by... */ void IrcServerHandler::handle333(const QString &prefix, const QList ¶ms) { Q_UNUSED(prefix); + if(!checkParamCount("IrcServerHandler::handle333()", params, 3)) + return; + QString channel = serverDecode(params[0]); emit displayMsg(Message::Server, BufferInfo::ChannelBuffer, channel, tr("Topic set by %1 on %2") .arg(serverDecode(params[1]), QDateTime::fromTime_t(channelDecode(channel, params[2]).toUInt()).toString())); @@ -653,6 +715,9 @@ void IrcServerHandler::handle333(const QString &prefix, const QList ( "H" / "G" > ["*"] [ ( "@" / "+" ) ] : " */ void IrcServerHandler::handle352(const QString &prefix, const QList ¶ms) { Q_UNUSED(prefix) + if(!checkParamCount("IrcServerHandler::handle352()", params, 6)) + return; + QString channel = serverDecode(params[0]); IrcUser *ircuser = network()->ircUser(serverDecode(params[4])); if(ircuser) { @@ -673,11 +738,8 @@ void IrcServerHandler::handle352(const QString &prefix, const QList /* RPL_NAMREPLY */ void IrcServerHandler::handle353(const QString &prefix, const QList ¶ms) { Q_UNUSED(prefix); - const int numParams = params.count(); - if(numParams < 2) { - qWarning() << "IrcServerHandler::handler353() received not enough params:" << serverDecode(params); + if(!checkParamCount("IrcServerHandler::handle353()", params, 2)) return; - } // param[0] is either "=", "*" or "@" indicating a public, private or secret channel // we don't use this information at the time beeing @@ -736,7 +798,9 @@ void IrcServerHandler::handle432(const QString &prefix, const QList /* ERR_NICKNAMEINUSE */ void IrcServerHandler::handle433(const QString &prefix, const QList ¶ms) { Q_UNUSED(prefix); - + if(!checkParamCount("IrcServerHandler::handle433()", params, 1)) + return; + QString errnick = serverDecode(params[0]); emit displayMsg(Message::Error, BufferInfo::StatusBuffer, "", tr("Nick already in use: %1").arg(errnick)); @@ -765,6 +829,15 @@ void IrcServerHandler::tryNextNick(const QString &errnick) { } } +bool IrcServerHandler::checkParamCount(const QString &methodName, const QList ¶ms, int minParams) { + if(params.count() < minParams) { + qWarning() << qPrintable(methodName) << "requieres" << minParams << "parameters but received only" << params.count() << serverDecode(params); + return false; + } else { + return true; + } +} + /***********************************************************************************/ diff --git a/src/core/ircserverhandler.h b/src/core/ircserverhandler.h index fe629041..a4005e32 100644 --- a/src/core/ircserverhandler.h +++ b/src/core/ircserverhandler.h @@ -78,6 +78,7 @@ signals: private: void tryNextNick(const QString &errnick); + bool checkParamCount(const QString &methodName, const QList ¶ms, int minParams); bool _whois; }; diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 1d2aeb96..55b99f43 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -83,6 +83,7 @@ MainWin::MainWin(QtUi *_gui, QWidget *parent) ui.setupUi(this); setWindowTitle("Quassel IRC"); setWindowIcon(offlineTrayIcon); + qApp->setWindowIcon(offlineTrayIcon); systray->setIcon(offlineTrayIcon); setWindowIconText("Quassel IRC"); @@ -424,6 +425,7 @@ void MainWin::setConnectedState() { ui.bufferWidget->show(); statusBar()->showMessage(tr("Connected to core.")); setWindowIcon(onlineTrayIcon); + qApp->setWindowIcon(onlineTrayIcon); systray->setIcon(onlineTrayIcon); if(sslLabel->width() == 0) sslLabel->setPixmap(QPixmap::fromImage(QImage(":/16x16/status/no-ssl"))); @@ -482,6 +484,7 @@ void MainWin::setDisconnectedState() { // nickListWidget->reset(); statusBar()->showMessage(tr("Not connected to core.")); setWindowIcon(offlineTrayIcon); + qApp->setWindowIcon(offlineTrayIcon); systray->setIcon(offlineTrayIcon); sslLabel->setPixmap(QPixmap()); } diff --git a/src/uisupport/bufferview.cpp b/src/uisupport/bufferview.cpp index 78d8bae0..ffa5ca8d 100644 --- a/src/uisupport/bufferview.cpp +++ b/src/uisupport/bufferview.cpp @@ -129,11 +129,25 @@ void BufferView::setFilteredModel(QAbstractItemModel *model_, BufferViewConfig * } else { BufferViewFilter *filter = new BufferViewFilter(model_, config); setModel(filter); - connect(this, SIGNAL(removeBuffer(const QModelIndex &)), filter, SLOT(removeBuffer(const QModelIndex &))); + connect(this, SIGNAL(removeBuffer(const QModelIndex &)), + filter, SLOT(removeBuffer(const QModelIndex &))); } setConfig(config); } +void BufferView::setSelectionModel(QItemSelectionModel *selectionModel) { + if(QTreeView::selectionModel()) + disconnect(selectionModel, SIGNAL(currentChanged(QModelIndex, QModelIndex)), + model(), SIGNAL(checkPreviousCurrentForRemoval(QModelIndex, QModelIndex))); + + QTreeView::setSelectionModel(selectionModel); + BufferViewFilter *filter = qobject_cast(model()); + if(filter) { + connect(selectionModel, SIGNAL(currentChanged(QModelIndex, QModelIndex)), + filter, SLOT(checkPreviousCurrentForRemoval(QModelIndex, QModelIndex))); + } +} + void BufferView::setConfig(BufferViewConfig *config) { if(_config == config) return; diff --git a/src/uisupport/bufferview.h b/src/uisupport/bufferview.h index b42c6c1a..66ee467b 100644 --- a/src/uisupport/bufferview.h +++ b/src/uisupport/bufferview.h @@ -42,6 +42,7 @@ public: void setModel(QAbstractItemModel *model); void setFilteredModel(QAbstractItemModel *model, BufferViewConfig *config); + virtual void setSelectionModel(QItemSelectionModel *selectionModel); void setConfig(BufferViewConfig *config); inline BufferViewConfig *config() { return _config; } diff --git a/src/uisupport/bufferviewfilter.cpp b/src/uisupport/bufferviewfilter.cpp index 50387363..d3ec1998 100644 --- a/src/uisupport/bufferviewfilter.cpp +++ b/src/uisupport/bufferviewfilter.cpp @@ -26,6 +26,12 @@ #include "uisettings.h" +class CheckRemovalEvent : public QEvent { +public: + CheckRemovalEvent(const QModelIndex &source_index) : QEvent(QEvent::User), index(source_index) {}; + QPersistentModelIndex index; +}; + /***************************************** * The Filter for the Tree View *****************************************/ @@ -40,6 +46,9 @@ BufferViewFilter::BufferViewFilter(QAbstractItemModel *model, BufferViewConfig * setDynamicSortFilter(true); loadColors(); + + connect(this, SIGNAL(_dataChanged(const QModelIndex &, const QModelIndex &)), + this, SLOT(_q_sourceDataChanged(QModelIndex,QModelIndex))); } void BufferViewFilter::loadColors() { @@ -268,6 +277,28 @@ void BufferViewFilter::source_rowsInserted(const QModelIndex &parent, int start, } } +void BufferViewFilter::checkPreviousCurrentForRemoval(const QModelIndex ¤t, const QModelIndex &previous) { + Q_UNUSED(current); + if(previous.isValid()) + qApp->postEvent(this, new CheckRemovalEvent(previous)); +} + +void BufferViewFilter::customEvent(QEvent *event) { + if(event->type() != QEvent::User) + return; + + CheckRemovalEvent *removalEvent = static_cast(event); + checkItemForRemoval(removalEvent->index); + + event->accept(); +} + +void BufferViewFilter::checkItemsForRemoval(const QModelIndex &topLeft, const QModelIndex &bottomRight) { + QModelIndex source_topLeft = mapToSource(topLeft); + QModelIndex source_bottomRight = mapToSource(bottomRight); + emit _dataChanged(source_topLeft, source_bottomRight); +} + // ****************************** // Helper // ****************************** diff --git a/src/uisupport/bufferviewfilter.h b/src/uisupport/bufferviewfilter.h index 4715f11a..4a80f7ec 100644 --- a/src/uisupport/bufferviewfilter.h +++ b/src/uisupport/bufferviewfilter.h @@ -63,6 +63,9 @@ public: public slots: void removeBuffer(const QModelIndex &); + void checkPreviousCurrentForRemoval(const QModelIndex ¤t, const QModelIndex &previous); + void checkItemForRemoval(const QModelIndex &index) { checkItemsForRemoval(index, index); } + void checkItemsForRemoval(const QModelIndex &topLeft, const QModelIndex &bottomRight); void source_rowsInserted(const QModelIndex &parent, int start, int end); protected: @@ -70,17 +73,21 @@ protected: bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const; bool bufferLessThan(const QModelIndex &source_left, const QModelIndex &source_right) const; bool networkLessThan(const QModelIndex &source_left, const QModelIndex &source_right) const; + virtual void customEvent(QEvent *event); +signals: + void _dataChanged(const QModelIndex &source_topLeft, const QModelIndex &source_bottomRight); + private: QPointer _config; - + QColor _FgColorInactiveActivity; QColor _FgColorNoActivity; QColor _FgColorHighlightActivity; QColor _FgColorNewMessageActivity; QColor _FgColorOtherActivity; void loadColors(); - + bool filterAcceptBuffer(const QModelIndex &) const; bool filterAcceptNetwork(const QModelIndex &) const; void addBuffer(const BufferId &); diff --git a/version.inc b/version.inc index 56d80eec..44ca5afa 100644 --- a/version.inc +++ b/version.inc @@ -4,8 +4,8 @@ { using namespace Global; quasselVersion = "0.2.0-beta1-pre"; - quasselDate = "2008-05-01"; - quasselBuild = 803; + quasselDate = "2008-05-03"; + quasselBuild = 810; //! Minimum client build number the core needs clientBuildNeeded = 731;