Merge pull request #148 from Tucos/DMdebug
authorManuel Nickschas <sputnick@quassel-irc.org>
Thu, 8 Oct 2015 22:04:54 +0000 (00:04 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Thu, 8 Oct 2015 22:04:54 +0000 (00:04 +0200)
Disable checkbox if no DockManager is present

42 files changed:
3rdparty/miniz/miniz.c
CMakeLists.txt
src/client/bufferviewoverlay.cpp
src/client/client.cpp
src/client/clientauthhandler.cpp
src/client/clientauthhandler.h
src/client/clientirclisthelper.cpp
src/client/clientsettings.cpp
src/client/coreconnection.cpp
src/client/messagefilter.cpp
src/client/messagemodel.cpp
src/client/networkmodel.cpp
src/client/selectionmodelsynchronizer.cpp
src/client/treemodel.cpp
src/common/abstractcliparser.h
src/common/bufferviewmanager.cpp
src/common/cliparser.cpp
src/common/ircchannel.cpp
src/common/ircuser.cpp
src/common/ircuser.h
src/common/signalproxy.cpp
src/common/syncableobject.cpp
src/common/syncableobject.h
src/core/abstractsqlstorage.cpp
src/core/coreauthhandler.cpp
src/core/corebacklogmanager.cpp
src/core/corebufferviewmanager.cpp
src/core/corenetwork.cpp
src/core/coresession.cpp
src/core/ctcpparser.cpp
src/core/postgresqlstorage.cpp
src/qtui/CMakeLists.txt
src/qtui/chatscene.cpp
src/qtui/mainwin.cpp
src/qtui/qtuimessageprocessor.cpp
src/qtui/settingspages/bufferviewsettingspage.cpp
src/qtui/settingspages/identitiessettingspage.cpp
src/qtui/snorenotificationbackend.cpp
src/qtui/snorenotificationbackend.h
src/qtui/ui/snorentificationconfigwidget.ui
src/uisupport/bufferviewfilter.cpp
src/uisupport/contextmenuactionprovider.cpp

index ee0ac99..4805823 100644 (file)
@@ -750,11 +750,11 @@ typedef struct
   mz_int16 m_look_up[TINFL_FAST_LOOKUP_SIZE], m_tree[TINFL_MAX_HUFF_SYMBOLS_0 * 2];\r
 } tinfl_huff_table;\r
 \r
-#if MINIZ_HAS_64BIT_REGISTERS\r
+#if defined MINIZ_HAS_64BIT_REGISTERS && MINIZ_HAS_64BIT_REGISTERS\r
   #define TINFL_USE_64BIT_BITBUF 1\r
 #endif\r
 \r
-#if TINFL_USE_64BIT_BITBUF\r
+#if defined TINFL_USE_64BIT_BITBUF && TINFL_USE_64BIT_BITBUF\r
   typedef mz_uint64 tinfl_bit_buf_t;\r
   #define TINFL_BITBUF_SIZE (64)\r
 #else\r
index 1a22fac..a35fa8f 100644 (file)
@@ -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)
index f04b453..91cad71 100644 (file)
@@ -70,7 +70,7 @@ void BufferViewOverlay::restore()
     currentIds += CoreAccountSettings().bufferViewOverlay();
 
     QSet<int>::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<int>::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;
index 54a93fb..0c6ad25 100644 (file)
@@ -535,7 +535,7 @@ void Client::networkDestroyed()
             break;
         }
         else {
-            netIter++;
+            ++netIter;
         }
     }
 }
index 7ed231c..eeca2cf 100644 (file)
 #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<ClientAuthHandler::DigestVersion>(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 */
index 7d6c935..00c2986 100644 (file)
@@ -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);
index 229e157..1af7bc5 100644 (file)
@@ -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);
index dc8e5c1..812e532 100644 (file)
@@ -216,7 +216,7 @@ QSet<int> CoreAccountSettings::bufferViewOverlay()
 {
     QSet<int> 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;
index 0e4b4f9..9f876f9 100644 (file)
@@ -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();
     }
index 5efed2c..1001ea3 100644 (file)
@@ -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<BufferId>::const_iterator bufferIdIter = _validBuffers.constBegin();
     while (bufferIdIter != _validBuffers.constEnd()) {
         Client::messageModel()->requestBacklog(*bufferIdIter);
-        bufferIdIter++;
+        ++bufferIdIter;
     }
 }
index cbcfceb..97d8f0a 100644 (file)
@@ -206,7 +206,7 @@ int MessageModel::insertMessagesGracefully(const QList<Message> &msglist)
     QList<Message>::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<Message> &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<Message> &msglist)
                 dupeId = (*iter).msgId();
                 grouplist.prepend(*iter);
             }
-            iter++;
+            ++iter;
         }
     }
 
index 6da5832..2adbe08 100644 (file)
@@ -723,7 +723,7 @@ void ChannelBufferItem::addUsersToCategory(const QList<IrcUser *> &ircUsers)
     QHash<UserCategoryItem *, QList<IrcUser *> >::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("<b>%1</b>").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 << "<qt><style>.bold { font-weight: bold; }</style>";
+
+    tooltip << "<p class='bold' align='center'>" << 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 << "</p>";
 
-    toolTip.append(_ircUser->hostmask().remove(0, _ircUser->hostmask().indexOf("!")+1));
+    auto addRow = [&](const QString& key, const QString& value, bool condition = true) {
+        if (condition)
+        {
+            tooltip << "<tr><td class='bold' align='right'>" << key << "</td><td>" << value << "</td></tr>";
+        }
+    };
+
+    tooltip << "<table cellspacing='5' cellpadding='0'>";
+    if (_ircUser->isAway()) {
+        QString awayMessage(tr("(unknown)"));
+        if(!_ircUser->awayMessage().isEmpty()) {
+            awayMessage = _ircUser->awayMessage();
+        }
+        addRow(tr("Away&nbsp;Message"), awayMessage);
+    }
+    addRow(tr("Realname"), _ircUser->realName(), !_ircUser->realName().isEmpty());
+    addRow(tr("Operator"), _ircUser->ircOperator(), !_ircUser->ircOperator().isEmpty());
+    addRow(tr("Suser&nbsp;Host"), _ircUser->suserHost(),!_ircUser->suserHost().isEmpty());
+    addRow(tr("Whois&nbsp;Service&nbsp;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&nbsp;since"), secondsToString(idleTime));
     }
+
     if (_ircUser->loginTime().isValid()) {
-        toolTip.append(tr("login time: %1").arg(_ircUser->loginTime().toString()));
+        addRow(tr("Login&nbsp;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("<p> %1 </p>").arg(toolTip.join("<br />"));
+    tooltip << "</table></qt>";
+    return strTooltip;
 }
 
 
index 4d2ed23..0dcf7f8 100644 (file)
@@ -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 &current, cons
     QSet<QItemSelectionModel *>::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<QItemSelectionModel *>::iterator iter = _selectionModels.begin();
     while (iter != _selectionModels.end()) {
         (*iter)->select(mapSelectionFromSource(currentSelection(), (*iter)), QItemSelectionModel::ClearAndSelect);
-        iter++;
+        ++iter;
     }
     _changeSelectionEnabled = true;
 }
index fd47bc0..220c843 100644 (file)
@@ -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 ====";
index 293ccd9..9ef194b 100644 (file)
@@ -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)
index 33ba528..580b4ad 100644 (file)
@@ -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<int>());
-        iter++;
+        ++iter;
     }
 }
index 2e94e55..ba653df 100644 (file)
@@ -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;
             }
         }
index 89b3b33..c111b9f 100644 (file)
@@ -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<IrcUser *> &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<IrcUser *, QString>::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<QChar, QStringList>::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<QChar, QString>::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<QChar, QString>::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<QChar>::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<QChar>::const_iterator D_iter = _D_channelModes.constBegin();
     while (D_iter != _D_channelModes.constEnd()) {
         modeString += *D_iter;
-        D_iter++;
+        ++D_iter;
     }
 
     QHash<QChar, QString>::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;
index 543f2b7..32ff794 100644 (file)
@@ -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);
     }
 }
 
index c8840ed..c33a3b2 100644 (file)
@@ -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);
index d9102fd..754e9db 100644 (file)
@@ -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);
 }
index b4f395f..3a1799e 100644 (file)
@@ -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;
     }
 }
 
index 08bd2e3..1275cc3 100644 (file)
@@ -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; }
index dce39cb..fb4409a 100644 (file)
@@ -41,7 +41,7 @@ AbstractSqlStorage::~AbstractSqlStorage()
 {
     // disconnect the connections, so their deletion is no longer interessting for us
     QHash<QThread *, Connection *>::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()) {
index 92b32c5..e380924 100644 (file)
@@ -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("<b>SSL is required!</b><br>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("<b>Invalid username or password!</b><br>The username/password combination you supplied could not be found in the database.")));
         return;
     }
index bb1d93f..90004ca 100644 (file)
@@ -42,7 +42,7 @@ QVariantList CoreBacklogManager::requestBacklog(BufferId bufferId, MsgId first,
     QList<Message>::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<Message>::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;
         }
     }
 
index 2c63d92..23417c3 100644 (file)
@@ -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;
     }
 }
 
index 932af6f..942e32f 100644 (file)
@@ -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:
index 5fd5bdc..1d0d5c5 100644 (file)
@@ -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;
index 37b0af3..d2da841 100644 (file)
@@ -81,7 +81,7 @@ QByteArray CtcpParser::lowLevelQuote(const QByteArray &message)
     QHash<QByteArray, QByteArray>::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<QByteArray, QByteArray>::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));
index e7a71e7..b16f4b0 100644 (file)
@@ -2004,7 +2004,7 @@ bool PostgreSqlMigrationWriter::postProcess()
               << Sequence("quasseluser", "userid")
               << Sequence("sender", "senderid");
     QList<Sequence>::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())
index 13279ba..6987ec6 100644 (file)
@@ -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)
index e03d7ca..3d5534d 100644 (file)
@@ -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);
index 8f022ca..bd8727a 100644 (file)
 #  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
index 68690f8..84deebe 100644 (file)
@@ -70,7 +70,7 @@ void QtUiMessageProcessor::process(QList<Message> &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;
     }
 }
 
index a3308f9..a438af9 100644 (file)
@@ -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;
index d75a1c0..72267fc 100644 (file)
@@ -84,7 +84,7 @@ void IdentitiesSettingsPage::continueUnsecured()
     _editSsl = true;
 
     QHash<IdentityId, CertIdentity *>::iterator idIter;
-    for (idIter = identities.begin(); idIter != identities.end(); idIter++) {
+    for (idIter = identities.begin(); idIter != identities.end(); ++idIter) {
         idIter.value()->enableEditSsl();
     }
 
index 6732c54..72873c1 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <QtGui>
 #include <QtGlobal>
+#include <QMetaObject>
 
 #include "client.h"
 #include "networkmodel.h"
 #include <iostream>
 
 
-#include <snore/core/snore.h>
-#include <snore/core/notification/notification.h>
+#include <libsnore/snore.h>
+#include <libsnore/notification/notification.h>
 
 
 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);
+}
+
+
index fa57adc..e0abdf7 100644 (file)
@@ -27,8 +27,8 @@
 
 #include "ui_snorentificationconfigwidget.h"
 
-#include <snore/core/snore.h>
-#include <snore/core/notification/notification.h>
+#include <libsnore/snore.h>
+#include <libsnore/notification/notification.h>
 
 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<uint, uint> 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
index 0e33248..991e37b 100644 (file)
      <property name="title">
       <string>Snore</string>
      </property>
-     <widget class="QLabel" name="label">
-      <property name="geometry">
-       <rect>
-        <x>10</x>
-        <y>25</y>
-        <width>46</width>
-        <height>13</height>
-       </rect>
-      </property>
-      <property name="text">
-       <string>Backend:</string>
-      </property>
-     </widget>
-     <widget class="QComboBox" name="backends">
-      <property name="geometry">
-       <rect>
-        <x>70</x>
-        <y>20</y>
-        <width>331</width>
-        <height>22</height>
-       </rect>
-      </property>
-     </widget>
-     <widget class="QLabel" name="label_2">
-      <property name="geometry">
-       <rect>
-        <x>10</x>
-        <y>65</y>
-        <width>46</width>
-        <height>13</height>
-       </rect>
-      </property>
-      <property name="text">
-       <string>Timeout:</string>
-      </property>
-     </widget>
-     <widget class="QSpinBox" name="timeout">
-      <property name="geometry">
-       <rect>
-        <x>70</x>
-        <y>60</y>
-        <width>81</width>
-        <height>22</height>
-       </rect>
-      </property>
-      <property name="specialValueText">
-       <string/>
-      </property>
-      <property name="suffix">
-       <string> s</string>
-      </property>
-      <property name="minimum">
-       <number>0</number>
-      </property>
-     </widget>
-     <widget class="QLabel" name="label_3">
-      <property name="geometry">
-       <rect>
-        <x>170</x>
-        <y>65</y>
-        <width>101</width>
-        <height>16</height>
-       </rect>
-      </property>
-      <property name="text">
-       <string>0 means infinite</string>
-      </property>
-     </widget>
+     <layout class="QVBoxLayout" name="verticalLayout">
+      <item>
+       <widget class="Snore::SettingsDialog" name="widget" native="true"/>
+      </item>
+      <item>
+       <layout class="QFormLayout" name="formLayout">
+        <item row="0" column="0">
+         <widget class="QLabel" name="useSnoreLabel">
+          <property name="text">
+           <string>Enable Snore</string>
+          </property>
+         </widget>
+        </item>
+        <item row="0" column="1">
+         <widget class="QCheckBox" name="useSnoreCheckBox"/>
+        </item>
+       </layout>
+      </item>
+     </layout>
     </widget>
    </item>
   </layout>
  </widget>
+ <customwidgets>
+  <customwidget>
+   <class>Snore::SettingsDialog</class>
+   <extends>QWidget</extends>
+   <header location="global">libsnore/settingsdialog.h</header>
+   <container>1</container>
+  </customwidget>
+ </customwidgets>
  <resources/>
  <connections/>
 </ui>
index 970f037..c829267 100644 (file)
@@ -161,12 +161,12 @@ void BufferViewFilter::enableEditMode(bool enable)
     if (enable == false) {
         addBuffers(QList<BufferId>::fromSet(_toAdd));
         QSet<BufferId>::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);
index 87d104f..62d7aac 100644 (file)
@@ -514,7 +514,7 @@ void ContextMenuActionProvider::addIgnoreMenu(QMenu *menu, const QString &hostma
                 ignoreMenu->addAction(act);
             }
             counter++;
-            ruleIter++;
+            ++ruleIter;
         }
         if (counter)
             ignoreMenu->addSeparator();