From: Manuel Nickschas Date: Thu, 8 Oct 2015 22:12:37 +0000 (+0200) Subject: Merge pull request #151 from Tucos/ws-hist X-Git-Tag: travis-deploy-test~547 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=b49c64970b6237fc95f8ca88c8bb6bcf04c251d7;hp=402c30b7a4db362f14e0920988a0967970ccd2da Merge pull request #151 from Tucos/ws-hist Preserve white-space in the input history. --- diff --git a/3rdparty/miniz/miniz.c b/3rdparty/miniz/miniz.c index ee0ac995..4805823d 100644 --- a/3rdparty/miniz/miniz.c +++ b/3rdparty/miniz/miniz.c @@ -750,11 +750,11 @@ typedef struct mz_int16 m_look_up[TINFL_FAST_LOOKUP_SIZE], m_tree[TINFL_MAX_HUFF_SYMBOLS_0 * 2]; } tinfl_huff_table; -#if MINIZ_HAS_64BIT_REGISTERS +#if defined MINIZ_HAS_64BIT_REGISTERS && MINIZ_HAS_64BIT_REGISTERS #define TINFL_USE_64BIT_BITBUF 1 #endif -#if TINFL_USE_64BIT_BITBUF +#if defined TINFL_USE_64BIT_BITBUF && TINFL_USE_64BIT_BITBUF typedef mz_uint64 tinfl_bit_buf_t; #define TINFL_BITBUF_SIZE (64) #else diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a22fac9..a35fa8f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -217,9 +217,9 @@ if (USE_QT5) PURPOSE "Required for audio notifications" ) - find_package(LibsnoreQt5 QUIET) + find_package(LibsnoreQt5 0.5.70 QUIET) set_package_properties(LibsnoreQt5 PROPERTIES TYPE OPTIONAL - URL "https://github.com/TheOneRing/Snorenotify" + URL "https://projects.kde.org/projects/playground/libs/snorenotify" DESCRIPTION "a cross-platform notification framework" PURPOSE "Enable support for the snorenotify framework" ) @@ -361,13 +361,6 @@ else(USE_QT5) DESCRIPTION "a multimedia abstraction library" PURPOSE "Required for audio notifications" ) - - find_package(Libsnore QUIET) - set_package_properties(Libsnore PROPERTIES TYPE OPTIONAL - URL "https://github.com/TheOneRing/Snorenotify" - DESCRIPTION "a cross-platform notification framework" - PURPOSE "Enable support for the snorenotify framework" - ) endif(WITH_KDE) find_package(IndicateQt QUIET) diff --git a/src/client/bufferviewoverlay.cpp b/src/client/bufferviewoverlay.cpp index f04b4531..91cad716 100644 --- a/src/client/bufferviewoverlay.cpp +++ b/src/client/bufferviewoverlay.cpp @@ -70,7 +70,7 @@ void BufferViewOverlay::restore() currentIds += CoreAccountSettings().bufferViewOverlay(); QSet::const_iterator iter; - for (iter = currentIds.constBegin(); iter != currentIds.constEnd(); iter++) { + for (iter = currentIds.constBegin(); iter != currentIds.constEnd(); ++iter) { addView(*iter); } } @@ -144,7 +144,7 @@ void BufferViewOverlay::removeView(int viewId) else { if (!config->isInitialized()) _uninitializedViewCount++; - viewIter++; + ++viewIter; } } @@ -211,7 +211,7 @@ void BufferViewOverlay::updateHelper() if (Client::bufferViewManager()) { BufferViewConfig *config = 0; QSet::const_iterator viewIter; - for (viewIter = _bufferViewIds.constBegin(); viewIter != _bufferViewIds.constEnd(); viewIter++) { + for (viewIter = _bufferViewIds.constBegin(); viewIter != _bufferViewIds.constEnd(); ++viewIter) { config = Client::bufferViewManager()->bufferViewConfig(*viewIter); if (!config) continue; diff --git a/src/client/client.cpp b/src/client/client.cpp index 54a93fb3..0c6ad25c 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -535,7 +535,7 @@ void Client::networkDestroyed() break; } else { - netIter++; + ++netIter; } } } diff --git a/src/client/clientauthhandler.cpp b/src/client/clientauthhandler.cpp index 7ed231c2..eeca2cff 100644 --- a/src/client/clientauthhandler.cpp +++ b/src/client/clientauthhandler.cpp @@ -34,6 +34,10 @@ #include "clientsettings.h" #include "peerfactory.h" +#if QT_VERSION < 0x050000 +# include "../../3rdparty/sha512/sha512.h" +#endif + using namespace Protocol; ClientAuthHandler::ClientAuthHandler(CoreAccount account, QObject *parent) @@ -423,6 +427,7 @@ void ClientAuthHandler::checkAndEnableSsl(bool coreSupportsSsl) } s.setAccountValue("ShowNoCoreSslWarning", false); s.setAccountValue("SslCert", QString()); + s.setAccountValue("SslCertDigestVersion", QVariant(QVariant::Int)); } if (_legacy) onConnectionReady(); @@ -444,6 +449,7 @@ void ClientAuthHandler::onSslSocketEncrypted() // That way, a warning will appear in case it becomes invalid at some point CoreAccountSettings s; s.setAccountValue("SSLCert", QString()); + s.setAccountValue("SslCertDigestVersion", QVariant(QVariant::Int)); } emit encrypted(true); @@ -462,8 +468,27 @@ void ClientAuthHandler::onSslErrors() CoreAccountSettings s; QByteArray knownDigest = s.accountValue("SslCert").toByteArray(); + ClientAuthHandler::DigestVersion knownDigestVersion = static_cast(s.accountValue("SslCertDigestVersion").toInt()); + + QByteArray calculatedDigest; + switch (knownDigestVersion) { + case ClientAuthHandler::DigestVersion::Md5: + calculatedDigest = socket->peerCertificate().digest(QCryptographicHash::Md5); + break; - if (knownDigest != socket->peerCertificate().digest()) { + case ClientAuthHandler::DigestVersion::Sha2_512: +#if QT_VERSION >= 0x050000 + calculatedDigest = socket->peerCertificate().digest(QCryptographicHash::Sha512); +#else + calculatedDigest = sha2_512(socket->peerCertificate().toDer()); +#endif + break; + + default: + qWarning() << "Certificate digest version" << QString(knownDigestVersion) << "is not supported"; + } + + if (knownDigest != calculatedDigest) { bool accepted = false; bool permanently = false; emit handleSslErrors(socket, &accepted, &permanently); @@ -473,13 +498,42 @@ void ClientAuthHandler::onSslErrors() return; } - if (permanently) - s.setAccountValue("SslCert", socket->peerCertificate().digest()); - else + if (permanently) { +#if QT_VERSION >= 0x050000 + s.setAccountValue("SslCert", socket->peerCertificate().digest(QCryptographicHash::Sha512)); +#else + s.setAccountValue("SslCert", sha2_512(socket->peerCertificate().toDer())); +#endif + s.setAccountValue("SslCertDigestVersion", ClientAuthHandler::DigestVersion::Latest); + } + else { s.setAccountValue("SslCert", QString()); + s.setAccountValue("SslCertDigestVersion", QVariant(QVariant::Int)); + } + } + else if (knownDigestVersion != ClientAuthHandler::DigestVersion::Latest) { +#if QT_VERSION >= 0x050000 + s.setAccountValue("SslCert", socket->peerCertificate().digest(QCryptographicHash::Sha512)); +#else + s.setAccountValue("SslCert", sha2_512(socket->peerCertificate().toDer())); +#endif + s.setAccountValue("SslCertDigestVersion", ClientAuthHandler::DigestVersion::Latest); } socket->ignoreSslErrors(); } +#if QT_VERSION < 0x050000 +QByteArray ClientAuthHandler::sha2_512(const QByteArray &input) { + unsigned char output[64]; + sha512((unsigned char*) input.constData(), input.size(), output, false); + // QByteArray::fromRawData() cannot be used here because that constructor + // does not copy "output" and the data is clobbered when the variable goes + // out of scope. + QByteArray result; + result.append((char*) output, 64); + return result; +} +#endif + #endif /* HAVE_SSL */ diff --git a/src/client/clientauthhandler.h b/src/client/clientauthhandler.h index 7d6c9357..00c2986e 100644 --- a/src/client/clientauthhandler.h +++ b/src/client/clientauthhandler.h @@ -36,6 +36,12 @@ class ClientAuthHandler : public AuthHandler public: ClientAuthHandler(CoreAccount account, QObject *parent = 0); + enum DigestVersion { + Md5, + Sha2_512, + Latest=Sha2_512 + }; + public slots: void connectToCore(); @@ -83,6 +89,10 @@ private: void checkAndEnableSsl(bool coreSupportsSsl); void startRegistration(); +#if QT_VERSION < 0x050000 + QByteArray sha2_512(const QByteArray &input); +#endif + private slots: void onSocketConnected(); void onSocketStateChanged(QAbstractSocket::SocketState state); diff --git a/src/client/clientirclisthelper.cpp b/src/client/clientirclisthelper.cpp index 229e1576..1af7bc59 100644 --- a/src/client/clientirclisthelper.cpp +++ b/src/client/clientirclisthelper.cpp @@ -43,7 +43,7 @@ void ClientIrcListHelper::receiveChannelList(const NetworkId &netId, const QStri QVariantList channelVar = iter->toList(); ChannelDescription channelDescription(channelVar[0].toString(), channelVar[1].toUInt(), channelVar[2].toString()); channelList << channelDescription; - iter++; + ++iter; } emit channelListReceived(netId, channelFilters, channelList); diff --git a/src/client/clientsettings.cpp b/src/client/clientsettings.cpp index dc8e5c18..812e5328 100644 --- a/src/client/clientsettings.cpp +++ b/src/client/clientsettings.cpp @@ -216,7 +216,7 @@ QSet CoreAccountSettings::bufferViewOverlay() { QSet viewIds; QVariantList variants = accountValue("BufferViewOverlay").toList(); - for (QVariantList::const_iterator iter = variants.constBegin(); iter != variants.constEnd(); iter++) { + for (QVariantList::const_iterator iter = variants.constBegin(); iter != variants.constEnd(); ++iter) { viewIds << iter->toInt(); } return viewIds; diff --git a/src/client/coreconnection.cpp b/src/client/coreconnection.cpp index 0e4b4f94..9f876f91 100644 --- a/src/client/coreconnection.cpp +++ b/src/client/coreconnection.cpp @@ -216,6 +216,8 @@ void CoreConnection::setState(ConnectionState state) if (state != _state) { _state = state; emit stateChanged(state); + if (state == Connected) + _wantReconnect = true; if (state == Disconnected) emit disconnected(); } diff --git a/src/client/messagefilter.cpp b/src/client/messagefilter.cpp index 5efed2c1..1001ea32 100644 --- a/src/client/messagefilter.cpp +++ b/src/client/messagefilter.cpp @@ -201,7 +201,7 @@ bool MessageFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourcePar while (idIter != _validBuffers.constEnd()) { if (Client::networkModel()->bufferType(*idIter) == BufferInfo::StatusBuffer) return true; - idIter++; + ++idIter; } } @@ -241,6 +241,6 @@ void MessageFilter::requestBacklog() QSet::const_iterator bufferIdIter = _validBuffers.constBegin(); while (bufferIdIter != _validBuffers.constEnd()) { Client::messageModel()->requestBacklog(*bufferIdIter); - bufferIdIter++; + ++bufferIdIter; } } diff --git a/src/client/messagemodel.cpp b/src/client/messagemodel.cpp index cbcfceb2..97d8f0ac 100644 --- a/src/client/messagemodel.cpp +++ b/src/client/messagemodel.cpp @@ -206,7 +206,7 @@ int MessageModel::insertMessagesGracefully(const QList &msglist) QList::const_iterator iter; if (inOrder) { iter = msglist.constEnd(); - iter--; // this op is safe as we've allready passed an empty check + --iter; // this op is safe as we've allready passed an empty check } else { iter = msglist.constBegin(); @@ -229,11 +229,11 @@ int MessageModel::insertMessagesGracefully(const QList &msglist) } if (!inOrder) - iter++; + ++iter; if (inOrder) { while (iter != msglist.constBegin()) { - iter--; + --iter; if (!fastForward && (*iter).msgId() <= minId) break; @@ -295,7 +295,7 @@ int MessageModel::insertMessagesGracefully(const QList &msglist) dupeId = (*iter).msgId(); grouplist.prepend(*iter); } - iter++; + ++iter; } } diff --git a/src/client/networkmodel.cpp b/src/client/networkmodel.cpp index 6da58323..2adbe08a 100644 --- a/src/client/networkmodel.cpp +++ b/src/client/networkmodel.cpp @@ -723,7 +723,7 @@ void ChannelBufferItem::addUsersToCategory(const QList &ircUsers) QHash >::const_iterator catIter = categories.constBegin(); while (catIter != categories.constEnd()) { catIter.key()->addUsers(catIter.value()); - catIter++; + ++catIter; } } @@ -947,33 +947,54 @@ QVariant IrcUserItem::data(int column, int role) const QString IrcUserItem::toolTip(int column) const { Q_UNUSED(column); - QStringList toolTip(QString("%1").arg(nickName())); - if (_ircUser->userModes() != "") toolTip[0].append(QString(" (%1)").arg(_ircUser->userModes())); - if (_ircUser->isAway()) { - toolTip[0].append(tr(" is away")); - if (!_ircUser->awayMessage().isEmpty()) - toolTip[0].append(QString(" (%1)").arg(_ircUser->awayMessage())); + QString strTooltip; + QTextStream tooltip( &strTooltip, QIODevice::WriteOnly ); + tooltip << ""; + + tooltip << "

" << nickName(); + if (_ircUser->userModes() != "") { + //TODO: Translate user Modes and add them to the table below + tooltip << " (" << _ircUser->userModes() << ")"; } - if (!_ircUser->realName().isEmpty()) toolTip.append(_ircUser->realName()); - if (!_ircUser->ircOperator().isEmpty()) toolTip.append(QString("%1 %2").arg(nickName()).arg(_ircUser->ircOperator())); - if (!_ircUser->suserHost().isEmpty()) toolTip.append(_ircUser->suserHost()); - if (!_ircUser->whoisServiceReply().isEmpty()) toolTip.append(_ircUser->whoisServiceReply()); + tooltip << "

"; - toolTip.append(_ircUser->hostmask().remove(0, _ircUser->hostmask().indexOf("!")+1)); + auto addRow = [&](const QString& key, const QString& value, bool condition = true) { + if (condition) + { + tooltip << "" << key << "" << value << ""; + } + }; + + tooltip << ""; + if (_ircUser->isAway()) { + QString awayMessage(tr("(unknown)")); + if(!_ircUser->awayMessage().isEmpty()) { + awayMessage = _ircUser->awayMessage(); + } + addRow(tr("Away Message"), awayMessage); + } + addRow(tr("Realname"), _ircUser->realName(), !_ircUser->realName().isEmpty()); + addRow(tr("Operator"), _ircUser->ircOperator(), !_ircUser->ircOperator().isEmpty()); + addRow(tr("Suser Host"), _ircUser->suserHost(),!_ircUser->suserHost().isEmpty()); + addRow(tr("Whois Service Reply"), _ircUser->whoisServiceReply(), !_ircUser->whoisServiceReply().isEmpty()); + addRow(tr("Hostmask"), _ircUser->hostmask().remove(0, _ircUser->hostmask().indexOf("!")+1)); + addRow(tr("Operator"), _ircUser->ircOperator(), !_ircUser->ircOperator().isEmpty()); if (_ircUser->idleTime().isValid()) { QDateTime now = QDateTime::currentDateTime(); QDateTime idle = _ircUser->idleTime(); int idleTime = idle.secsTo(now); - toolTip.append(tr("idling since %1").arg(secondsToString(idleTime))); + addRow(tr("Idling since"), secondsToString(idleTime)); } + if (_ircUser->loginTime().isValid()) { - toolTip.append(tr("login time: %1").arg(_ircUser->loginTime().toString())); + addRow(tr("Login time"), _ircUser->loginTime().toString()); } - if (!_ircUser->server().isEmpty()) toolTip.append(tr("server: %1").arg(_ircUser->server())); + addRow(tr("Server"), _ircUser->server(), !_ircUser->server().isEmpty()); - return QString("

%1

").arg(toolTip.join("
")); + tooltip << "
"; + return strTooltip; } diff --git a/src/client/selectionmodelsynchronizer.cpp b/src/client/selectionmodelsynchronizer.cpp index 4d2ed232..0dcf7f8e 100644 --- a/src/client/selectionmodelsynchronizer.cpp +++ b/src/client/selectionmodelsynchronizer.cpp @@ -96,7 +96,7 @@ void SelectionModelSynchronizer::selectionModelDestroyed(QObject *object) iter = _selectionModels.erase(iter); } else { - iter++; + ++iter; } } } @@ -252,7 +252,7 @@ void SelectionModelSynchronizer::currentChanged(const QModelIndex ¤t, cons QSet::iterator iter = _selectionModels.begin(); while (iter != _selectionModels.end()) { (*iter)->setCurrentIndex(mapFromSource(current, (*iter)), QItemSelectionModel::Current); - iter++; + ++iter; } _changeCurrentEnabled = true; } @@ -267,7 +267,7 @@ void SelectionModelSynchronizer::selectionChanged(const QItemSelection &selected QSet::iterator iter = _selectionModels.begin(); while (iter != _selectionModels.end()) { (*iter)->select(mapSelectionFromSource(currentSelection(), (*iter)), QItemSelectionModel::ClearAndSelect); - iter++; + ++iter; } _changeSelectionEnabled = true; } diff --git a/src/client/treemodel.cpp b/src/client/treemodel.cpp index fd47bc04..220c843f 100644 --- a/src/client/treemodel.cpp +++ b/src/client/treemodel.cpp @@ -105,7 +105,7 @@ void AbstractTreeItem::removeAllChilds() child = *childIter; child->setTreeItemFlags(0); // disable self deletion, as this would only fuck up consitency and the child gets deleted anyways child->removeAllChilds(); - childIter++; + ++childIter; } emit beginRemoveChilds(0, numChilds - 1); @@ -220,7 +220,7 @@ void AbstractTreeItem::dumpChildList() while (childIter != _childItems.constEnd()) { child = *childIter; qDebug() << "Row:" << child->row() << child << child->data(0, Qt::DisplayRole); - childIter++; + ++childIter; } } qDebug() << "==== End Of Childlist ===="; diff --git a/src/common/abstractcliparser.h b/src/common/abstractcliparser.h index 293ccd92..9ef194be 100644 --- a/src/common/abstractcliparser.h +++ b/src/common/abstractcliparser.h @@ -54,7 +54,7 @@ protected: CliArgOption }; - CliParserArg(const CliArgType type = CliArgInvalid, const char shortName = 0, const QString &help = QString(), const QString &valueName = QString(), const QString def = QString()) + CliParserArg(const CliArgType type = CliArgInvalid, const char shortName = 0, const QString &help = QString(), const QString &valueName = QString(), const QString &def = QString()) : type(type) , shortName(shortName) , help(help) diff --git a/src/common/bufferviewmanager.cpp b/src/common/bufferviewmanager.cpp index 33ba5288..580b4ad2 100644 --- a/src/common/bufferviewmanager.cpp +++ b/src/common/bufferviewmanager.cpp @@ -88,7 +88,7 @@ QVariantList BufferViewManager::initBufferViewIds() const BufferViewConfigHash::const_iterator iterEnd = _bufferViewConfigs.constEnd(); while (iter != iterEnd) { bufferViewIds << (*iter)->bufferViewId(); - iter++; + ++iter; } return bufferViewIds; } @@ -100,6 +100,6 @@ void BufferViewManager::initSetBufferViewIds(const QVariantList bufferViewIds) QVariantList::const_iterator iterEnd = bufferViewIds.constEnd(); while (iter != iterEnd) { newBufferViewConfig((*iter).value()); - iter++; + ++iter; } } diff --git a/src/common/cliparser.cpp b/src/common/cliparser.cpp index 2e94e559..ba653df4 100644 --- a/src/common/cliparser.cpp +++ b/src/common/cliparser.cpp @@ -146,7 +146,7 @@ bool CliParser::init(const QStringList &args) else value = currentArg->toLocal8Bit(); name = currentArg->mid(1).toLatin1().at(0); // we took one argument as argument to an option so skip it next time - if (skipNext) currentArg++; + if (skipNext) ++currentArg; if (!addShortArg(CliParserArg::CliArgOption, name, value)) return false; } } diff --git a/src/common/ircchannel.cpp b/src/common/ircchannel.cpp index 89b3b330..c111b9fa 100644 --- a/src/common/ircchannel.cpp +++ b/src/common/ircchannel.cpp @@ -73,7 +73,7 @@ bool IrcChannel::isValidChannelUserMode(const QString &mode) const { bool isvalid = true; if (mode.size() > 1) { - qWarning() << "Channel" << name() << "received Channel User Mode which is longer then 1 Char:" << mode; + qWarning() << "Channel" << name() << "received Channel User Mode which is longer than 1 Char:" << mode; isvalid = false; } return isvalid; @@ -183,12 +183,12 @@ void IrcChannel::joinIrcUsers(const QList &users, const QStringList & } _userModes[ircuser] = modes[i]; - ircuser->joinChannel(this); + ircuser->joinChannel(this, true); connect(ircuser, SIGNAL(nickSet(QString)), this, SLOT(ircUserNickSet(QString))); // connect(ircuser, SIGNAL(destroyed()), this, SLOT(ircUserDestroyed())); - // if you wonder why there is no counterpart to ircUserJoined: - // the joines are propagted by the ircuser. the signal ircUserJoined is only for convenience + // If you wonder why there is no counterpart to ircUserJoined: + // the joins are propagated by the ircuser. The signal ircUserJoined is only for convenience newNicks << ircuser->nick(); newModes << modes[i]; @@ -227,8 +227,8 @@ void IrcChannel::part(IrcUser *ircuser) if (isKnownUser(ircuser)) { _userModes.remove(ircuser); ircuser->partChannel(this); - // if you wonder why there is no counterpart to ircUserParted: - // the joines are propagted by the ircuser. the signal ircUserParted is only for convenience + // If you wonder why there is no counterpart to ircUserParted: + // the joins are propagted by the ircuser. The signal ircUserParted is only for convenience disconnect(ircuser, 0, this, 0); emit ircUserParted(ircuser); @@ -321,7 +321,7 @@ QVariantMap IrcChannel::initUserModes() const QHash::const_iterator iter = _userModes.constBegin(); while (iter != _userModes.constEnd()) { usermodes[iter.key()->nick()] = iter.value(); - iter++; + ++iter; } return usermodes; } @@ -335,7 +335,7 @@ void IrcChannel::initSetUserModes(const QVariantMap &usermodes) while (iter != usermodes.constEnd()) { users << network()->newIrcUser(iter.key()); modes << iter.value().toString(); - iter++; + ++iter; } joinIrcUsers(users, modes); } @@ -349,7 +349,7 @@ QVariantMap IrcChannel::initChanModes() const QHash::const_iterator A_iter = _A_channelModes.constBegin(); while (A_iter != _A_channelModes.constEnd()) { A_modes[A_iter.key()] = A_iter.value(); - A_iter++; + ++A_iter; } channelModes["A"] = A_modes; @@ -357,7 +357,7 @@ QVariantMap IrcChannel::initChanModes() const QHash::const_iterator B_iter = _B_channelModes.constBegin(); while (B_iter != _B_channelModes.constEnd()) { B_modes[B_iter.key()] = B_iter.value(); - B_iter++; + ++B_iter; } channelModes["B"] = B_modes; @@ -365,7 +365,7 @@ QVariantMap IrcChannel::initChanModes() const QHash::const_iterator C_iter = _C_channelModes.constBegin(); while (C_iter != _C_channelModes.constEnd()) { C_modes[C_iter.key()] = C_iter.value(); - C_iter++; + ++C_iter; } channelModes["C"] = C_modes; @@ -373,7 +373,7 @@ QVariantMap IrcChannel::initChanModes() const QSet::const_iterator D_iter = _D_channelModes.constBegin(); while (D_iter != _D_channelModes.constEnd()) { D_modes += *D_iter; - D_iter++; + ++D_iter; } channelModes["D"] = D_modes; @@ -387,21 +387,21 @@ void IrcChannel::initSetChanModes(const QVariantMap &channelModes) QVariantMap::const_iterator iterEnd = channelModes["A"].toMap().constEnd(); while (iter != iterEnd) { _A_channelModes[iter.key()[0]] = iter.value().toStringList(); - iter++; + ++iter; } iter = channelModes["B"].toMap().constBegin(); iterEnd = channelModes["B"].toMap().constEnd(); while (iter != iterEnd) { _B_channelModes[iter.key()[0]] = iter.value().toString(); - iter++; + ++iter; } iter = channelModes["C"].toMap().constBegin(); iterEnd = channelModes["C"].toMap().constEnd(); while (iter != iterEnd) { _C_channelModes[iter.key()[0]] = iter.value().toString(); - iter++; + ++iter; } QString D_modes = channelModes["D"].toString(); @@ -468,7 +468,7 @@ void IrcChannel::ircUserNickSet(QString nick) * C --> set value or remove * D --> on/off * - * B and C behave very similar... we store the data in different datastructes + * B and C behave very similar... we store the data in different datastructures * for future compatibility ******************************************************************************/ @@ -596,21 +596,21 @@ QString IrcChannel::channelModeString() const QSet::const_iterator D_iter = _D_channelModes.constBegin(); while (D_iter != _D_channelModes.constEnd()) { modeString += *D_iter; - D_iter++; + ++D_iter; } QHash::const_iterator BC_iter = _C_channelModes.constBegin(); while (BC_iter != _C_channelModes.constEnd()) { modeString += BC_iter.key(); params << BC_iter.value(); - BC_iter++; + ++BC_iter; } BC_iter = _B_channelModes.constBegin(); while (BC_iter != _B_channelModes.constEnd()) { modeString += BC_iter.key(); params << BC_iter.value(); - BC_iter++; + ++BC_iter; } if (modeString.isEmpty()) return modeString; diff --git a/src/common/ircuser.cpp b/src/common/ircuser.cpp index 543f2b71..32ff7944 100644 --- a/src/common/ircuser.cpp +++ b/src/common/ircuser.cpp @@ -275,12 +275,13 @@ void IrcUser::updateHostmask(const QString &mask) } -void IrcUser::joinChannel(IrcChannel *channel) +void IrcUser::joinChannel(IrcChannel *channel, bool skip_channel_join) { Q_ASSERT(channel); if (!_channels.contains(channel)) { _channels.insert(channel); - channel->joinIrcUser(this); + if (!skip_channel_join) + channel->joinIrcUser(this); } } diff --git a/src/common/ircuser.h b/src/common/ircuser.h index c8840ed8..c33a3b2d 100644 --- a/src/common/ircuser.h +++ b/src/common/ircuser.h @@ -118,7 +118,12 @@ public slots: void setUserModes(const QString &modes); - void joinChannel(IrcChannel *channel); + /*! + * \brief joinChannel Called when user joins some channel, this function inserts the channel to internal list of channels this user is in. + * \param channel Pointer to a channel this user just joined + * \param skip_channel_join If this is false, this function will also call IrcChannel::joinIrcUser, can be set to true as a performance tweak. + */ + void joinChannel(IrcChannel *channel, bool skip_channel_join = false); void joinChannel(const QString &channelname); void partChannel(IrcChannel *channel); void partChannel(const QString &channelname); diff --git a/src/common/signalproxy.cpp b/src/common/signalproxy.cpp index d9102fd3..754e9dbb 100644 --- a/src/common/signalproxy.cpp +++ b/src/common/signalproxy.cpp @@ -119,7 +119,7 @@ void SignalProxy::SignalRelay::detachSignal(QObject *sender, int signalId) break; } else { - slotIter++; + ++slotIter; } } } @@ -197,7 +197,7 @@ SignalProxy::~SignalProxy() objIter = classIter->erase(objIter); obj->stopSynchronize(this); } - classIter++; + ++classIter; } _syncSlave.clear(); @@ -482,7 +482,7 @@ void SignalProxy::detachSlots(QObject *receiver) slotIter = _attachedSlots.erase(slotIter); } else - slotIter++; + ++slotIter; } } @@ -497,7 +497,7 @@ void SignalProxy::stopSynchronize(SyncableObject *obj) classIter->remove(obj->objectName()); break; } - classIter++; + ++classIter; } obj->stopSynchronize(this); } diff --git a/src/common/syncableobject.cpp b/src/common/syncableobject.cpp index b4f395fe..3a1799e2 100644 --- a/src/common/syncableobject.cpp +++ b/src/common/syncableobject.cpp @@ -141,7 +141,7 @@ void SyncableObject::fromVariantMap(const QVariantMap &properties) while (iterator != properties.constEnd()) { propName = iterator.key(); if (propName == "objectName") { - iterator++; + ++iterator; continue; } @@ -152,7 +152,7 @@ void SyncableObject::fromVariantMap(const QVariantMap &properties) else setProperty(propName.toLatin1(), iterator.value()); // qDebug() << "<<< SYNC:" << name << iterator.value(); - iterator++; + ++iterator; } } diff --git a/src/common/syncableobject.h b/src/common/syncableobject.h index 08bd2e30..1275cc32 100644 --- a/src/common/syncableobject.h +++ b/src/common/syncableobject.h @@ -76,7 +76,7 @@ public: virtual bool isInitialized() const; - virtual const QMetaObject *syncMetaObject() const { return metaObject(); }; + virtual const QMetaObject *syncMetaObject() const { return metaObject(); } inline void setAllowClientUpdates(bool allow) { _allowClientUpdates = allow; } inline bool allowClientUpdates() const { return _allowClientUpdates; } diff --git a/src/core/abstractsqlstorage.cpp b/src/core/abstractsqlstorage.cpp index dce39cb2..fb4409a0 100644 --- a/src/core/abstractsqlstorage.cpp +++ b/src/core/abstractsqlstorage.cpp @@ -41,7 +41,7 @@ AbstractSqlStorage::~AbstractSqlStorage() { // disconnect the connections, so their deletion is no longer interessting for us QHash::iterator conIter; - for (conIter = _connectionPool.begin(); conIter != _connectionPool.end(); conIter++) { + for (conIter = _connectionPool.begin(); conIter != _connectionPool.end(); ++conIter) { QSqlDatabase::removeDatabase(conIter.value()->name()); disconnect(conIter.value(), 0, this, 0); } @@ -275,7 +275,7 @@ bool AbstractSqlStorage::watchQuery(QSqlQuery &query) QVariantMap boundValues = query.boundValues(); QStringList valueStrings; QVariantMap::const_iterator iter; - for (iter = boundValues.constBegin(); iter != boundValues.constEnd(); iter++) { + for (iter = boundValues.constBegin(); iter != boundValues.constEnd(); ++iter) { QString value; QSqlField field; if (query.driver()) { diff --git a/src/core/coreauthhandler.cpp b/src/core/coreauthhandler.cpp index 92b32c5c..e3809246 100644 --- a/src/core/coreauthhandler.cpp +++ b/src/core/coreauthhandler.cpp @@ -159,6 +159,7 @@ void CoreAuthHandler::handle(const RegisterClient &msg) useSsl = _connectionFeatures & Protocol::Encryption; if (Quassel::isOptionSet("require-ssl") && !useSsl && !_peer->isLocal()) { + quInfo() << qPrintable(tr("SSL required but non-SSL connection attempt from %1").arg(socket()->peerAddress().toString())); _peer->dispatch(ClientDenied(tr("SSL is required!
You need to use SSL in order to connect to this core."))); _peer->close(); return; @@ -209,6 +210,7 @@ void CoreAuthHandler::handle(const Login &msg) UserId uid = Core::validateUser(msg.user, msg.password); if (uid == 0) { + quInfo() << qPrintable(tr("Invalid login attempt from %1 as \"%2\"").arg(socket()->peerAddress().toString(), msg.user)); _peer->dispatch(LoginFailed(tr("Invalid username or password!
The username/password combination you supplied could not be found in the database."))); return; } diff --git a/src/core/corebacklogmanager.cpp b/src/core/corebacklogmanager.cpp index bb1d93f5..90004caf 100644 --- a/src/core/corebacklogmanager.cpp +++ b/src/core/corebacklogmanager.cpp @@ -42,7 +42,7 @@ QVariantList CoreBacklogManager::requestBacklog(BufferId bufferId, MsgId first, QList::const_iterator msgListEnd = msgList.constEnd(); while (msgIter != msgListEnd) { backlog << qVariantFromValue(*msgIter); - msgIter++; + ++msgIter; } if (additional && limit != 0) { @@ -69,7 +69,7 @@ QVariantList CoreBacklogManager::requestBacklog(BufferId bufferId, MsgId first, msgListEnd = msgList.constEnd(); while (msgIter != msgListEnd) { backlog << qVariantFromValue(*msgIter); - msgIter++; + ++msgIter; } } } @@ -88,7 +88,7 @@ QVariantList CoreBacklogManager::requestBacklogAll(MsgId first, MsgId last, int QList::const_iterator msgListEnd = msgList.constEnd(); while (msgIter != msgListEnd) { backlog << qVariantFromValue(*msgIter); - msgIter++; + ++msgIter; } if (additional) { @@ -109,7 +109,7 @@ QVariantList CoreBacklogManager::requestBacklogAll(MsgId first, MsgId last, int msgListEnd = msgList.constEnd(); while (msgIter != msgListEnd) { backlog << qVariantFromValue(*msgIter); - msgIter++; + ++msgIter; } } diff --git a/src/core/corebufferviewmanager.cpp b/src/core/corebufferviewmanager.cpp index 2c63d921..23417c3b 100644 --- a/src/core/corebufferviewmanager.cpp +++ b/src/core/corebufferviewmanager.cpp @@ -37,7 +37,7 @@ CoreBufferViewManager::CoreBufferViewManager(SignalProxy *proxy, CoreSession *pa while (iter != iterEnd) { config = new CoreBufferViewConfig(iter.key().toInt(), iter.value().toMap(), this); addBufferViewConfig(config); - iter++; + ++iter; } } @@ -50,7 +50,7 @@ void CoreBufferViewManager::saveBufferViews() BufferViewConfigHash::const_iterator iterEnd = bufferViewConfigHash().constEnd(); while (iter != iterEnd) { views[QString::number((*iter)->bufferViewId())] = (*iter)->toVariantMap(); - iter++; + ++iter; } Core::setUserSetting(_coreSession->user(), "BufferViews", views); @@ -70,7 +70,7 @@ void CoreBufferViewManager::requestCreateBufferView(const QVariantMap &propertie if ((*iter)->bufferViewId() > maxId) maxId = (*iter)->bufferViewId(); - iter++; + ++iter; } maxId++; @@ -85,7 +85,7 @@ void CoreBufferViewManager::requestCreateBufferViews(const QVariantList &propert QVariantList::const_iterator iterEnd = properties.constEnd(); while (iter != iterEnd) { requestCreateBufferView((*iter).toMap()); - iter++; + ++iter; } } diff --git a/src/core/coreircchannel.cpp b/src/core/coreircchannel.cpp index ccb82a50..c2745a8e 100644 --- a/src/core/coreircchannel.cpp +++ b/src/core/coreircchannel.cpp @@ -28,6 +28,15 @@ CoreIrcChannel::CoreIrcChannel(const QString &channelname, Network *network) { #ifdef HAVE_QCA2 _cipher = 0; + + // Get the cipher key from CoreNetwork if present + CoreNetwork *coreNetwork = qobject_cast(network); + if (coreNetwork) { + QByteArray key = coreNetwork->readChannelCipherKey(channelname); + if (!key.isEmpty()) { + setEncrypted(cipher()->setKey(key)); + } + } #endif } @@ -35,6 +44,15 @@ CoreIrcChannel::CoreIrcChannel(const QString &channelname, Network *network) CoreIrcChannel::~CoreIrcChannel() { #ifdef HAVE_QCA2 + // Store the cipher key in CoreNetwork, including empty keys if a cipher + // exists. There is no need to store the empty key if no cipher exists; no + // key was present when instantiating and no key was set during the + // channel's lifetime. + CoreNetwork *coreNetwork = qobject_cast(network()); + if (coreNetwork && _cipher) { + coreNetwork->storeChannelCipherKey(name(), _cipher->key()); + } + delete _cipher; #endif } diff --git a/src/core/corenetwork.cpp b/src/core/corenetwork.cpp index 932af6fc..942e32f6 100644 --- a/src/core/corenetwork.cpp +++ b/src/core/corenetwork.cpp @@ -71,7 +71,6 @@ CoreNetwork::CoreNetwork(const NetworkId &networkid, CoreSession *session) connect(&_tokenBucketTimer, SIGNAL(timeout()), this, SLOT(fillBucketAndProcessQueue())); connect(&socket, SIGNAL(connected()), this, SLOT(socketInitialized())); - connect(&socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected())); connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError(QAbstractSocket::SocketError))); connect(&socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(socketStateChanged(QAbstractSocket::SocketState))); connect(&socket, SIGNAL(readyRead()), this, SLOT(socketHasData())); @@ -538,6 +537,7 @@ void CoreNetwork::socketStateChanged(QAbstractSocket::SocketState socketState) switch (socketState) { case QAbstractSocket::UnconnectedState: state = Network::Disconnected; + socketDisconnected(); break; case QAbstractSocket::HostLookupState: case QAbstractSocket::ConnectingState: diff --git a/src/core/corenetwork.h b/src/core/corenetwork.h index 05565a47..8073d410 100644 --- a/src/core/corenetwork.h +++ b/src/core/corenetwork.h @@ -84,6 +84,9 @@ public: inline QString channelKey(const QString &channel) const { return _channelKeys.value(channel.toLower(), QString()); } + inline QByteArray readChannelCipherKey(const QString &channel) const { return _cipherKeys.value(channel.toLower()); } + inline void storeChannelCipherKey(const QString &channel, const QByteArray &key) { _cipherKeys[channel.toLower()] = key; } + inline bool isAutoWhoInProgress(const QString &channel) const { return _autoWhoPending.value(channel.toLower(), 0); } inline UserId userId() const { return _coreSession->user(); } @@ -245,6 +248,9 @@ private: QList _msgQueue; QString _requestedUserModes; // 2 strings separated by a '-' character. first part are requested modes to add, the second to remove + + // List of blowfish keys for channels + QHash _cipherKeys; }; diff --git a/src/core/coresession.cpp b/src/core/coresession.cpp index 5fd5bdcf..1d0d5c5f 100644 --- a/src/core/coresession.cpp +++ b/src/core/coresession.cpp @@ -175,7 +175,7 @@ void CoreSession::loadSettings() networkIter = networkInfos.erase(networkIter); } else { - networkIter++; + ++networkIter; } } s.removeIdentity(id); @@ -548,7 +548,7 @@ void CoreSession::destroyNetwork(NetworkId id) messageIter = _messageQueue.erase(messageIter); } else { - messageIter++; + ++messageIter; } } // remove buffers from syncer @@ -578,7 +578,7 @@ void CoreSession::clientsConnected() IrcUser *me = 0; while (netIter != _networks.end()) { net = *netIter; - netIter++; + ++netIter; if (!net->isConnected()) continue; @@ -605,7 +605,7 @@ void CoreSession::clientsDisconnected() QString awayReason; while (netIter != _networks.end()) { net = *netIter; - netIter++; + ++netIter; if (!net->isConnected()) continue; @@ -633,7 +633,7 @@ void CoreSession::globalAway(const QString &msg) CoreNetwork *net = 0; while (netIter != _networks.end()) { net = *netIter; - netIter++; + ++netIter; if (!net->isConnected()) continue; diff --git a/src/core/ctcpparser.cpp b/src/core/ctcpparser.cpp index 37b0af3e..d2da8413 100644 --- a/src/core/ctcpparser.cpp +++ b/src/core/ctcpparser.cpp @@ -81,7 +81,7 @@ QByteArray CtcpParser::lowLevelQuote(const QByteArray &message) QHash::const_iterator quoteIter = quoteHash.constBegin(); while (quoteIter != quoteHash.constEnd()) { quotedMessage.replace(quoteIter.value(), quoteIter.key()); - quoteIter++; + ++quoteIter; } return quotedMessage; } @@ -117,7 +117,7 @@ QByteArray CtcpParser::xdelimQuote(const QByteArray &message) QHash::const_iterator quoteIter = _ctcpXDelimDequoteHash.constBegin(); while (quoteIter != _ctcpXDelimDequoteHash.constEnd()) { quotedMessage.replace(quoteIter.value(), quoteIter.key()); - quoteIter++; + ++quoteIter; } return quotedMessage; } @@ -185,7 +185,7 @@ void CtcpParser::parseSimple(IrcEventRawMessage *e, Message::Type messagetype, Q if (dequotedMessage.count(XDELIM) != 2 || dequotedMessage[0] != '\001' || dequotedMessage[dequotedMessage.count() -1] != '\001') { displayMsg(e, messagetype, targetDecode(e, dequotedMessage), e->prefix(), e->target(), flags); } else { - int spacePos = -1; + int spacePos; QString ctcpcmd, ctcpparam; QByteArray ctcp = xdelimDequote(dequotedMessage.mid(1, dequotedMessage.count() - 2)); diff --git a/src/core/postgresqlstorage.cpp b/src/core/postgresqlstorage.cpp index e7a71e7b..b16f4b0a 100644 --- a/src/core/postgresqlstorage.cpp +++ b/src/core/postgresqlstorage.cpp @@ -2004,7 +2004,7 @@ bool PostgreSqlMigrationWriter::postProcess() << Sequence("quasseluser", "userid") << Sequence("sender", "senderid"); QList::const_iterator iter; - for (iter = sequences.constBegin(); iter != sequences.constEnd(); iter++) { + for (iter = sequences.constBegin(); iter != sequences.constEnd(); ++iter) { resetQuery(); newQuery(QString("SELECT setval('%1_%2_seq', max(%2)) FROM %1").arg(iter->table, iter->field), db); if (!exec()) diff --git a/src/qtui/CMakeLists.txt b/src/qtui/CMakeLists.txt index 13279baa..6987ec60 100644 --- a/src/qtui/CMakeLists.txt +++ b/src/qtui/CMakeLists.txt @@ -95,12 +95,11 @@ if (WITH_KF5) list(APPEND LIBS KF5::ConfigWidgets KF5::Notifications KF5::NotifyConfig KF5::WidgetsAddons KF5::XmlGui) endif() -if (LIBSNORE_FOUND) +if (LibsnoreQt5_FOUND) add_definitions(-DHAVE_LIBSNORE) - include_directories(${LIBSNORE_INCLUDE_DIRS}) list(APPEND SOURCES snorenotificationbackend.cpp) list(APPEND FORMS snorentificationconfigwidget.ui) - list(APPEND LIBS ${LIBSNORE_LIBRARIES}) + list(APPEND LIBS Snore::Libsnore) endif() if (PHONON_FOUND OR Phonon4Qt5_FOUND) diff --git a/src/qtui/chatscene.cpp b/src/qtui/chatscene.cpp index e03d7cad..3d5534dd 100644 --- a/src/qtui/chatscene.cpp +++ b/src/qtui/chatscene.cpp @@ -651,7 +651,7 @@ void ChatScene::firstHandlePositionChanged(qreal xpos) QPointF senderPos(firstColumnHandle()->sceneRight(), 0); while (lineIter != lineIterBegin) { - lineIter--; + --lineIter; (*lineIter)->setFirstColumn(timestampWidth, senderWidth, senderPos); } //setItemIndexMethod(QGraphicsScene::BspTreeIndex); @@ -687,7 +687,7 @@ void ChatScene::secondHandlePositionChanged(qreal xpos) qreal contentsWidth = _sceneRect.width() - secondColumnHandle()->sceneRight(); QPointF contentsPos(secondColumnHandle()->sceneRight(), 0); while (lineIter != lineIterBegin) { - lineIter--; + --lineIter; (*lineIter)->setSecondColumn(senderWidth, contentsWidth, contentsPos, linePos); } //setItemIndexMethod(QGraphicsScene::BspTreeIndex); diff --git a/src/qtui/dockmanagernotificationbackend.cpp b/src/qtui/dockmanagernotificationbackend.cpp index c9fdc0de..56547763 100644 --- a/src/qtui/dockmanagernotificationbackend.cpp +++ b/src/qtui/dockmanagernotificationbackend.cpp @@ -46,11 +46,11 @@ DockManagerNotificationBackend::DockManagerNotificationBackend(QObject *parent) if (_dock->isValid()) { _bus.connect("org.freedesktop.DockManager", "/org/freedesktop/DockManager", "org.freedesktop.DockManager", "ItemAdded", this, SLOT(itemAdded(QDBusObjectPath))); } else { - qDebug() << "No DockManager available"; - _enabled = false; + _available = _enabled = false; return; } } + _available = true; itemAdded(QDBusObjectPath()); @@ -171,18 +171,18 @@ void DockManagerNotificationBackend::enabledChanged(const QVariant &v) SettingsPage *DockManagerNotificationBackend::createConfigWidget() const { - return new ConfigWidget(); + return new ConfigWidget(_available); } /***************************************************************************/ -DockManagerNotificationBackend::ConfigWidget::ConfigWidget(QWidget *parent) +DockManagerNotificationBackend::ConfigWidget::ConfigWidget(bool enabled, QWidget *parent) : SettingsPage("Internal", "DockManagerNotification", parent) { QHBoxLayout *layout = new QHBoxLayout(this); layout->addWidget(enabledBox = new QCheckBox(tr("Mark dockmanager entry"), this)); - enabledBox->setEnabled(true); + enabledBox->setEnabled(enabled); connect(enabledBox, SIGNAL(toggled(bool)), SLOT(widgetChanged())); } diff --git a/src/qtui/dockmanagernotificationbackend.h b/src/qtui/dockmanagernotificationbackend.h index 70efb006..bbae76c4 100644 --- a/src/qtui/dockmanagernotificationbackend.h +++ b/src/qtui/dockmanagernotificationbackend.h @@ -50,6 +50,7 @@ private slots: private: class ConfigWidget; bool _enabled; + bool _available; QDBusConnection _bus; QDBusInterface *_dock; QDBusInterface *_item; @@ -62,7 +63,7 @@ class DockManagerNotificationBackend::ConfigWidget : public SettingsPage Q_OBJECT public: - ConfigWidget(QWidget *parent = 0); + ConfigWidget(bool enabled, QWidget *parent = 0); void save(); void load(); diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 8f022cac..bd8727ac 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -104,15 +104,17 @@ # ifdef HAVE_PHONON # include "phononnotificationbackend.h" # endif -# ifdef HAVE_LIBSNORE -# include "snorenotificationbackend.h" -# endif # include "systraynotificationbackend.h" # include "taskbarnotificationbackend.h" #else /* HAVE_KDE */ # include "knotificationbackend.h" #endif /* HAVE_KDE */ + +#ifdef HAVE_LIBSNORE +# include "snorenotificationbackend.h" +#endif + #ifdef HAVE_SSL # include "sslinfodlg.h" #endif @@ -224,18 +226,18 @@ void MainWin::init() # ifdef HAVE_PHONON QtUi::registerNotificationBackend(new PhononNotificationBackend(this)); # endif -# ifdef HAVE_LIBSNORE - QtUi::registerNotificationBackend(new SnoreNotificationBackend(this)); -# elif !defined(QT_NO_SYSTEMTRAYICON) - QtUi::registerNotificationBackend(new SystrayNotificationBackend(this)); -# endif - QtUi::registerNotificationBackend(new TaskbarNotificationBackend(this)); - #else /* HAVE_KDE */ QtUi::registerNotificationBackend(new KNotificationBackend(this)); #endif /* HAVE_KDE */ + +#ifdef HAVE_LIBSNORE + QtUi::registerNotificationBackend(new SnoreNotificationBackend(this)); +#elif !defined(QT_NO_SYSTEMTRAYICON) && !defined(HAVE_KDE) + QtUi::registerNotificationBackend(new SystrayNotificationBackend(this)); +#endif + #ifdef HAVE_INDICATEQT QtUi::registerNotificationBackend(new IndicatorNotificationBackend(this)); #endif diff --git a/src/qtui/qtuimessageprocessor.cpp b/src/qtui/qtuimessageprocessor.cpp index 68690f84..84deebee 100644 --- a/src/qtui/qtuimessageprocessor.cpp +++ b/src/qtui/qtuimessageprocessor.cpp @@ -70,7 +70,7 @@ void QtUiMessageProcessor::process(QList &msgs) while (msgIter != msgIterEnd) { checkForHighlight(*msgIter); preProcess(*msgIter); - msgIter++; + ++msgIter; } Client::messageModel()->insertMessages(msgs); return; @@ -190,7 +190,7 @@ void QtUiMessageProcessor::highlightListChanged(const QVariant &variant) rule["CS"].toBool() ? Qt::CaseSensitive : Qt::CaseInsensitive, rule["RegEx"].toBool(), rule["Channel"].toString()); - iter++; + ++iter; } } diff --git a/src/qtui/settingspages/bufferviewsettingspage.cpp b/src/qtui/settingspages/bufferviewsettingspage.cpp index a3308f9b..a438af97 100644 --- a/src/qtui/settingspages/bufferviewsettingspage.cpp +++ b/src/qtui/settingspages/bufferviewsettingspage.cpp @@ -400,7 +400,7 @@ void BufferViewSettingsPage::on_deleteBufferView_clicked() break; } else { - iter++; + ++iter; } } delete config; @@ -524,7 +524,7 @@ bool BufferViewSettingsPage::testHasChanged() } else { changed = true; - iter++; + ++iter; } } return changed; diff --git a/src/qtui/settingspages/identitiessettingspage.cpp b/src/qtui/settingspages/identitiessettingspage.cpp index d75a1c0b..72267fca 100644 --- a/src/qtui/settingspages/identitiessettingspage.cpp +++ b/src/qtui/settingspages/identitiessettingspage.cpp @@ -84,7 +84,7 @@ void IdentitiesSettingsPage::continueUnsecured() _editSsl = true; QHash::iterator idIter; - for (idIter = identities.begin(); idIter != identities.end(); idIter++) { + for (idIter = identities.begin(); idIter != identities.end(); ++idIter) { idIter.value()->enableEditSsl(); } diff --git a/src/qtui/snorenotificationbackend.cpp b/src/qtui/snorenotificationbackend.cpp index 6732c549..72873c1e 100644 --- a/src/qtui/snorenotificationbackend.cpp +++ b/src/qtui/snorenotificationbackend.cpp @@ -22,6 +22,7 @@ #include #include +#include #include "client.h" #include "networkmodel.h" @@ -31,83 +32,66 @@ #include -#include -#include +#include +#include SnoreNotificationBackend::SnoreNotificationBackend (QObject *parent) : AbstractNotificationBackend(parent), - m_systrayBackend(NULL) + m_icon(QIcon::fromTheme("quassel", QIcon(":/icons/quassel.png"))) { - NotificationSettings notificationSettings; - QString backend = notificationSettings.value("Snore/Backend", "Default").toString(); - m_timeout = notificationSettings.value("Snore/Timeout", 10).toInt(); - - notificationSettings.notify("Snore/Backend", this, SLOT(backendChanged(const QVariant &))); - notificationSettings.notify("Snore/Timeout", this, SLOT(timeoutChanged(const QVariant &))); - //TODO: try to get an instance of the tray icon to be able to show popups - m_snore = new Snore::SnoreCore(); - m_snore->loadPlugins(Snore::SnorePlugin::BACKEND); - m_icon = Snore::Icon(QIcon::fromTheme("quassel", QIcon(":/icons/quassel.png")).pixmap(48).toImage()); + Snore::SnoreCore::instance().loadPlugins( +#ifndef HAVE_KDE + Snore::SnorePlugin::BACKEND | +#endif + Snore::SnorePlugin::SECONDARY_BACKEND); m_application = Snore::Application("Quassel", m_icon); - m_application.hints().setValue("WINDOWS_APP_ID","QuasselProject.QuasselIRC"); + m_application.hints().setValue("windows-app-id","QuasselProject.QuasselIRC"); + m_application.hints().setValue("pushover-token", "arNtsi983QSZUqU3KAZrFLKHGFPkdL"); - connect(m_snore, SIGNAL(actionInvoked(Snore::Notification)), this, SLOT(actionInvoked(Snore::Notification))); + connect(&Snore::SnoreCore::instance(), SIGNAL(actionInvoked(Snore::Notification)), this, SLOT(actionInvoked(Snore::Notification))); m_alert = Snore::Alert(tr("Private Message"), m_icon); m_application.addAlert(m_alert); + Snore::SnoreCore::instance().setDefaultApplication(m_application); - m_snore->registerApplication(m_application); - - backendChanged(QVariant::fromValue(backend)); - - + NotificationSettings notificationSettings; + bool enabled = notificationSettings.value("Snore/Enabled", false).toBool(); + setTraybackend(enabled); + notificationSettings.notify("Snore/Enabled", this, SLOT(setTraybackend(const QVariant &))); } SnoreNotificationBackend::~SnoreNotificationBackend() { - m_snore->deregisterApplication(m_application); - m_snore->deleteLater(); -} - -void SnoreNotificationBackend::backendChanged(const QVariant &v) -{ - QString backend = v.toString(); - if (backend != "Default") { - if (setSnoreBackend(backend)) { - return; - } - } - setTraybackend(); -} - -void SnoreNotificationBackend::timeoutChanged(const QVariant &v) -{ - m_timeout = v.toInt(); + Snore::SnoreCore::instance().deregisterApplication(m_application); } void SnoreNotificationBackend::notify(const Notification &n) { - if (m_systrayBackend != NULL) { +#ifndef HAVE_KDE + if (m_systrayBackend != nullptr) { return; } - QString title = Client::networkModel()->networkName(n.bufferId) + " - " + Client::networkModel()->bufferName(n.bufferId); +#endif + QString title = QString("%1 - %2").arg(Client::networkModel()->networkName(n.bufferId), Client::networkModel()->bufferName(n.bufferId)); QString message = QString("<%1> %2").arg(n.sender, n.message); - Snore::Notification noti(m_application, m_alert, title, message, m_icon, m_timeout); + Snore::Notification noti(m_application, m_alert, title, message, m_icon); noti.hints().setValue("QUASSEL_ID", n.notificationId); m_notificationIds.insert(n.notificationId, noti.id()); - m_snore->broadcastNotification(noti); + Snore::SnoreCore::instance().broadcastNotification(noti); } void SnoreNotificationBackend::close(uint notificationId) { - if (m_systrayBackend != NULL) { +#ifndef HAVE_KDE + if (m_systrayBackend != nullptr) { return; } - Snore::Notification n = m_snore->getActiveNotificationByID(m_notificationIds.take(notificationId)); - m_snore->requestCloseNotification(n, Snore::Notification::CLOSED); +#endif + Snore::Notification n = Snore::SnoreCore::instance().getActiveNotificationByID(m_notificationIds.take(notificationId)); + Snore::SnoreCore::instance().requestCloseNotification(n, Snore::Notification::CLOSED); } void SnoreNotificationBackend::actionInvoked(Snore::Notification n) @@ -117,57 +101,40 @@ void SnoreNotificationBackend::actionInvoked(Snore::Notification n) SettingsPage *SnoreNotificationBackend::createConfigWidget()const { - return new ConfigWidget(m_snore); + return new ConfigWidget(); } -void SnoreNotificationBackend::setTraybackend() -{ - if (m_systrayBackend == NULL) { - m_systrayBackend = new SystrayNotificationBackend(this); - QtUi::registerNotificationBackend(m_systrayBackend); - } -} -bool SnoreNotificationBackend::setSnoreBackend(const QString &backend) +void SnoreNotificationBackend::setTraybackend(const QVariant &b) { - if (m_systrayBackend != NULL) { - QtUi::unregisterNotificationBackend(m_systrayBackend); - delete m_systrayBackend; - m_systrayBackend = NULL; +#ifndef HAVE_KDE + if (!b.toBool()) { + if (m_systrayBackend == nullptr) { + m_systrayBackend = new SystrayNotificationBackend(this); + QtUi::registerNotificationBackend(m_systrayBackend); + } + } else { + if (m_systrayBackend != nullptr) { + QtUi::unregisterNotificationBackend(m_systrayBackend); + m_systrayBackend->deleteLater(); + m_systrayBackend = nullptr; + } + } +#endif + if (b.toBool()) { + Snore::SnoreCore::instance().registerApplication(m_application); + } else { + Snore::SnoreCore::instance().deregisterApplication(m_application); } - return m_snore->setPrimaryNotificationBackend(backend); } - - - /***************************************************************************/ -SnoreNotificationBackend::ConfigWidget::ConfigWidget(Snore::SnoreCore *snore, QWidget *parent) - :SettingsPage("Internal", "SnoreNotification", parent), - m_snore(snore) +SnoreNotificationBackend::ConfigWidget::ConfigWidget(QWidget *parent) + :SettingsPage("Internal", "SnoreNotification", parent) { ui.setupUi(this); - QStringList backends = m_snore->notificationBackends(); - backends.append("Default"); - qSort(backends); - ui.backends->insertItems(0, backends); - - connect(ui.backends, SIGNAL(currentIndexChanged(QString)), SLOT(backendChanged(QString))); - connect(ui.timeout, SIGNAL(valueChanged(int)), this, SLOT(timeoutChanged(int))); -} - -void SnoreNotificationBackend::ConfigWidget::backendChanged(const QString &b) -{ - ui.backends->setCurrentIndex(ui.backends->findText(b)); - setChangedState(true); -} - -void SnoreNotificationBackend::ConfigWidget::timeoutChanged(int i) -{ - ui.timeout->setValue(i); - setChangedState(true); - + connect(ui.useSnoreCheckBox, SIGNAL(toggled(bool)), this, SLOT(useSnnoreChanged(bool))); } bool SnoreNotificationBackend::ConfigWidget::hasDefaults() const @@ -177,24 +144,33 @@ bool SnoreNotificationBackend::ConfigWidget::hasDefaults() const void SnoreNotificationBackend::ConfigWidget::defaults() { - backendChanged("Default"); - timeoutChanged(10); + useSnnoreChanged(false); + ui.widget->reset(); } void SnoreNotificationBackend::ConfigWidget::load() { NotificationSettings s; - QString backend = s.value("Snore/Backend", "Default").toString(); - int timeout = s.value("Snore/Timeout", 10).toInt(); - ui.backends->setCurrentIndex(ui.backends->findText(backend)); - ui.timeout->setValue(timeout); + bool enabled = s.value("Snore/Enabled", false).toBool(); + ui.useSnoreCheckBox->setChecked(enabled); + ui.widget->setEnabled(enabled); setChangedState(false); + QMetaObject::invokeMethod(this, "changed", Qt::QueuedConnection);//hack to make apply and accept button work for snore settings widget } void SnoreNotificationBackend::ConfigWidget::save() { NotificationSettings s; - s.setValue("Snore/Backend", ui.backends->currentText()); - s.setValue("Snore/Timeout", ui.timeout->value()); + s.setValue("Snore/Enabled", ui.useSnoreCheckBox->isChecked()); + ui.widget->accept(); load(); } + +void SnoreNotificationBackend::ConfigWidget::useSnnoreChanged(bool b) +{ + ui.useSnoreCheckBox->setChecked(b); + ui.widget->setEnabled(b); + setChangedState(true); +} + + diff --git a/src/qtui/snorenotificationbackend.h b/src/qtui/snorenotificationbackend.h index fa57adc2..e0abdf7f 100644 --- a/src/qtui/snorenotificationbackend.h +++ b/src/qtui/snorenotificationbackend.h @@ -27,8 +27,8 @@ #include "ui_snorentificationconfigwidget.h" -#include -#include +#include +#include class SystrayNotificationBackend; @@ -41,53 +41,44 @@ public: void notify(const Notification &); void close(uint notificationId); - virtual SettingsPage *createConfigWidget()const; + virtual SettingsPage *createConfigWidget() const; signals: void activated(uint notificationId = 0); public slots: void actionInvoked(Snore::Notification); + private slots: - void backendChanged(const QVariant &); - void timeoutChanged(const QVariant &); + void setTraybackend(const QVariant &b); private: - void setTraybackend(); - bool setSnoreBackend(const QString &backend); class ConfigWidget; - SystrayNotificationBackend * m_systrayBackend; - Snore::SnoreCore *m_snore; +#ifndef HAVE_KDE + SystrayNotificationBackend * m_systrayBackend = nullptr; +#endif QHash m_notificationIds; Snore::Icon m_icon; Snore::Application m_application; Snore::Alert m_alert; - int m_timeout; }; class SnoreNotificationBackend::ConfigWidget : public SettingsPage { Q_OBJECT public: - ConfigWidget(Snore::SnoreCore *snore, QWidget *parent = 0); - void save(); - void load(); + ConfigWidget(QWidget *parent = 0); + bool hasDefaults() const; void defaults(); - + void load(); + void save(); private slots: - void backendChanged(const QString&); - void timeoutChanged(int); + void useSnnoreChanged(bool); private: Ui::SnoreNotificationConfigWidget ui; - Snore::SnoreCore *m_snore; - - // QSpinBox *timeoutBox; - - // bool enabled; - // int timeout; }; #endif diff --git a/src/qtui/ui/snorentificationconfigwidget.ui b/src/qtui/ui/snorentificationconfigwidget.ui index 0e33248b..991e37b6 100644 --- a/src/qtui/ui/snorentificationconfigwidget.ui +++ b/src/qtui/ui/snorentificationconfigwidget.ui @@ -28,78 +28,37 @@ Snore - - - - 10 - 25 - 46 - 13 - - - - Backend: - - - - - - 70 - 20 - 331 - 22 - - - - - - - 10 - 65 - 46 - 13 - - - - Timeout: - - - - - - 70 - 60 - 81 - 22 - - - - - - - s - - - 0 - - - - - - 170 - 65 - 101 - 16 - - - - 0 means infinite - - + + + + + + + + + + Enable Snore + + + + + + + + + + + + Snore::SettingsDialog + QWidget +
libsnore/settingsdialog.h
+ 1 +
+
diff --git a/src/uisupport/bufferviewfilter.cpp b/src/uisupport/bufferviewfilter.cpp index 970f037a..c829267a 100644 --- a/src/uisupport/bufferviewfilter.cpp +++ b/src/uisupport/bufferviewfilter.cpp @@ -161,12 +161,12 @@ void BufferViewFilter::enableEditMode(bool enable) if (enable == false) { addBuffers(QList::fromSet(_toAdd)); QSet::const_iterator iter; - for (iter = _toTempRemove.constBegin(); iter != _toTempRemove.constEnd(); iter++) { + for (iter = _toTempRemove.constBegin(); iter != _toTempRemove.constEnd(); ++iter) { if (config()->temporarilyRemovedBuffers().contains(*iter)) continue; config()->requestRemoveBuffer(*iter); } - for (iter = _toRemove.constBegin(); iter != _toRemove.constEnd(); iter++) { + for (iter = _toRemove.constBegin(); iter != _toRemove.constEnd(); ++iter) { if (config()->removedBuffers().contains(*iter)) continue; config()->requestRemoveBufferPermanently(*iter); diff --git a/src/uisupport/contextmenuactionprovider.cpp b/src/uisupport/contextmenuactionprovider.cpp index 87d104fd..62d7aac1 100644 --- a/src/uisupport/contextmenuactionprovider.cpp +++ b/src/uisupport/contextmenuactionprovider.cpp @@ -514,7 +514,7 @@ void ContextMenuActionProvider::addIgnoreMenu(QMenu *menu, const QString &hostma ignoreMenu->addAction(act); } counter++; - ruleIter++; + ++ruleIter; } if (counter) ignoreMenu->addSeparator(); diff --git a/src/uisupport/multilineedit.cpp b/src/uisupport/multilineedit.cpp index 0651abf1..37f1f62a 100644 --- a/src/uisupport/multilineedit.cpp +++ b/src/uisupport/multilineedit.cpp @@ -41,6 +41,7 @@ MultiLineEdit::MultiLineEdit(QWidget *parent) _scrollBarsEnabled(true), _pasteProtectionEnabled(true), _emacsMode(false), + _completionSpace(0), _lastDocumentHeight(-1) { document()->setDocumentMargin(0); @@ -670,8 +671,12 @@ void MultiLineEdit::on_returnPressed() } -void MultiLineEdit::on_returnPressed(const QString &text) +void MultiLineEdit::on_returnPressed(QString text) { + if (_completionSpace && text.endsWith(" ")) { + text.chop(1); + } + if (!text.isEmpty()) { foreach(const QString &line, text.split('\n', QString::SkipEmptyParts)) { if (line.isEmpty()) @@ -690,6 +695,8 @@ void MultiLineEdit::on_returnPressed(const QString &text) void MultiLineEdit::on_textChanged() { + _completionSpace = qMax(_completionSpace - 1, 0); + QString newText = text(); newText.replace("\r\n", "\n"); newText.replace('\r', '\n'); @@ -772,3 +779,12 @@ void MultiLineEdit::showHistoryEntry() setTextCursor(cursor); updateScrollBars(); } + + +void MultiLineEdit::addCompletionSpace() +{ + // Inserting the space emits textChanged, which should not disable removal + _completionSpace = 2; + insertPlainText(" "); +} + diff --git a/src/uisupport/multilineedit.h b/src/uisupport/multilineedit.h index 7591a510..f83c4de4 100644 --- a/src/uisupport/multilineedit.h +++ b/src/uisupport/multilineedit.h @@ -35,9 +35,6 @@ # define MultiLineEditParent QTextEdit #endif -class QKeyEvent; -class TabCompleter; - class MultiLineEdit : public MultiLineEditParent { Q_OBJECT @@ -76,6 +73,8 @@ public: inline qint32 idx() const { return _idx; } inline bool emacsMode() const { return _emacsMode; } + void addCompletionSpace(); + public slots: void setMode(Mode mode); void setMinHeight(int numLines); @@ -101,7 +100,7 @@ protected: private slots: void on_returnPressed(); - void on_returnPressed(const QString &text); + void on_returnPressed(QString text); void on_textChanged(); void on_documentHeightChanged(qreal height); @@ -124,6 +123,7 @@ private: bool _scrollBarsEnabled; bool _pasteProtectionEnabled; bool _emacsMode; + int _completionSpace; QSize _sizeHint; qreal _lastDocumentHeight; diff --git a/src/uisupport/tabcompleter.cpp b/src/uisupport/tabcompleter.cpp index 130095d5..b0e61fd7 100644 --- a/src/uisupport/tabcompleter.cpp +++ b/src/uisupport/tabcompleter.cpp @@ -152,7 +152,7 @@ void TabCompleter::complete() _lastCompletionLength += _nickSuffix.length(); } else if (s.addSpaceMidSentence()) { - _lineEdit->insert(" "); + _lineEdit->addCompletionSpace(); _lastCompletionLength++; }