summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPekka Vuorela <pvuorela@iki.fi>2025-11-10 12:26:29 +0200
committerPekka Vuorela <pvuorela@iki.fi>2025-11-12 13:09:58 +0200
commitcc3f1651da37aceb333dcd10817da06b3994cbda (patch)
tree99703337eb0dec36feb8989a355785c504e0095c
parent83372ffcf8526b4a0a405be8fef1e3d102c26155 (diff)
Remove non-functional NewCountNotifier
This doesn't nor has done anything meaningful. For handling new messages it should be better to just create a plugin, e.g. what SailfishOS has done for making notifications on new emails. Change-Id: I962339b406dd305c38fa11992d1576d6aa668084 Reviewed-by: Pekka Vuorela <pvuorela@iki.fi> Reviewed-by: <matti.viljanen@kapsi.fi> Reviewed-by: Damien Caliste <dcaliste@free.fr>
-rw-r--r--benchmarks/tst_messageserver/tst_messageserver.pro6
-rw-r--r--src/tools/messageserver/CMakeLists.txt4
-rw-r--r--src/tools/messageserver/messageserver.cpp165
-rw-r--r--src/tools/messageserver/messageserver.h16
-rw-r--r--src/tools/messageserver/messageserver.pro4
-rw-r--r--src/tools/messageserver/newcountnotifier.cpp56
-rw-r--r--src/tools/messageserver/newcountnotifier.h64
-rw-r--r--src/tools/messageserver/servicehandler.h1
8 files changed, 8 insertions, 308 deletions
diff --git a/benchmarks/tst_messageserver/tst_messageserver.pro b/benchmarks/tst_messageserver/tst_messageserver.pro
index c64f40f9..6b79f069 100644
--- a/benchmarks/tst_messageserver/tst_messageserver.pro
+++ b/benchmarks/tst_messageserver/tst_messageserver.pro
@@ -24,8 +24,7 @@ HEADERS += benchmarkcontext.h \
$$IMAP_PLUGIN/imaplog.h \
$$MESSAGE_SERVER/mailmessageclient.h \
$$MESSAGE_SERVER/messageserver.h \
- $$MESSAGE_SERVER/servicehandler.h \
- $$MESSAGE_SERVER/newcountnotifier.h
+ $$MESSAGE_SERVER/servicehandler.h
SOURCES += benchmarkcontext.cpp \
qscopedconnection.cpp \
@@ -36,8 +35,7 @@ SOURCES += benchmarkcontext.cpp \
$$MESSAGE_SERVER/mailmessageclient.cpp \
$$MESSAGE_SERVER/messageserver.cpp \
$$MESSAGE_SERVER/prepareaccounts.cpp \
- $$MESSAGE_SERVER/servicehandler.cpp \
- $$MESSAGE_SERVER/newcountnotifier.cpp
+ $$MESSAGE_SERVER/servicehandler.cpp
linux {
HEADERS += testmalloc.h 3rdparty/cycle_p.h
diff --git a/src/tools/messageserver/CMakeLists.txt b/src/tools/messageserver/CMakeLists.txt
index dc5c669c..7cb8b5b0 100644
--- a/src/tools/messageserver/CMakeLists.txt
+++ b/src/tools/messageserver/CMakeLists.txt
@@ -1,12 +1,10 @@
set(SRC
messageserver.cpp
- newcountnotifier.cpp
servicehandler.cpp)
set(HEADERS
messageserver.h
- servicehandler.h
- newcountnotifier.h)
+ servicehandler.h)
qt_add_dbus_adaptor(GENERATED_SOURCES ../../libraries/qmfclient/qmailservice.xml servicehandler.h ServiceHandler qmailservice_adaptor)
diff --git a/src/tools/messageserver/messageserver.cpp b/src/tools/messageserver/messageserver.cpp
index 26dc9ace..86710dd9 100644
--- a/src/tools/messageserver/messageserver.cpp
+++ b/src/tools/messageserver/messageserver.cpp
@@ -46,7 +46,6 @@
#include <qmaillog.h>
#include <qmailipc.h>
-#include <newcountnotifier.h>
#include <qmailmessageserverplugin.h>
#define LC_MESSAGING "org.qt.messageserver"
@@ -70,8 +69,7 @@ int MessageServer::sigintFd[2];
MessageServer::MessageServer(QObject *parent)
: QObject(parent),
- handler(0),
- newMessageTotal(0),
+ handler(nullptr),
completionAttempted(false)
{
readLogSettings();
@@ -166,13 +164,7 @@ bool MessageServer::init()
connect(handler, &ServiceHandler::retrievalReady,
this, &MessageServer::retrievalCompleted);
- connect(handler, SIGNAL(newMessagesAvailable()),
- this, SLOT(reportNewCounts()));
-
- connect(this, &MessageServer::messageCountUpdated,
- handler, &ServiceHandler::messageCountUpdated);
-
- //clean up any temporary messages that were not cleaned up by clients
+ // clean up any temporary messages that were not cleaned up by clients
QTimer::singleShot(0, this, SLOT(cleanupTemporaryMessages()));
emit handler->actionsListed(QMailActionDataList());
@@ -209,132 +201,6 @@ void MessageServer::retrievalCompleted(quint64 action)
emit handler->retrievalCompleted(action);
}
-QMap<QMailMessage::MessageType, QString> typeSignatureInit()
-{
- QMap<QMailMessage::MessageType, QString> map;
-
- map.insert(QMailMessage::Sms, "newSmsCount(int)");
- map.insert(QMailMessage::Mms, "newMmsCount(int)");
- map.insert(QMailMessage::Email, "newEmailCount(int)");
- map.insert(QMailMessage::Instant, "newInstantCount(int)");
- map.insert(QMailMessage::System, "newSystemCount(int)");
-
- return map;
-}
-
-static QMap<QMailMessage::MessageType, QString> typeServiceInit()
-{
- QMap<QMailMessage::MessageType, QString> map;
-
- map.insert(QMailMessage::Sms, "NewSmsArrival");
- map.insert(QMailMessage::Mms, "NewMmsArrival");
- map.insert(QMailMessage::Email, "NewEmailArrival");
- map.insert(QMailMessage::Instant, "NewInstantMessageArrival");
- map.insert(QMailMessage::System, "NewSystemMessageArrival");
-
- return map;
-}
-
-QString serviceForType(QMailMessage::MessageType type)
-{
- static QMap<QMailMessage::MessageType, QString> typeService(typeServiceInit());
- return typeService[type];
-}
-
-int MessageServer::newMessageCount(QMailMessage::MessageType type) const
-{
- QMailMessageKey newMessageKey(QMailMessageKey::status(QMailMessage::New, QMailDataComparator::Includes));
- if (type != QMailMessage::AnyType) {
- newMessageKey &= QMailMessageKey::messageType(type);
- }
-
- return QMailStore::instance()->countMessages(newMessageKey);
-}
-
-void MessageServer::reportNewCounts()
-{
- static QMap<QMailMessage::MessageType, QString> typeSignature(typeSignatureInit());
-
- MessageCountMap newCounts;
- foreach (const QMailMessage::MessageType &type, typeSignature.keys()) {
- newCounts[type] = newMessageCount(type);
- }
-
- newMessageTotal = newMessageCount(QMailMessage::AnyType);
-
- if (newMessageTotal) {
- // Inform QPE of changes to the new message counts
- foreach (const QMailMessage::MessageType &type, typeSignature.keys()) {
- if ((newCounts[type] > 0) && (newCounts[type] != messageCounts[type]))
- NewCountNotifier::notify(type, newCounts[type]);
- }
-
- // Request handling of the new message events
- MessageCountMap::const_iterator it = newCounts.begin(), end = newCounts.end();
-
- for ( ; it != end; ++it) {
- QMailMessage::MessageType type(it.key());
- if (it.value() != messageCounts[type]) {
- // This type's count has changed since last reported
-
- if ( NewCountNotifier* action = new NewCountNotifier(type, it.value())) {
- actionType[action] = type;
-
- connect(action, SIGNAL(response(bool)), this, SLOT(response(bool)));
- connect(action, SIGNAL(error(QString)), this, SLOT(error(QString)));
-
- // Ensure the client receives any generated events before the arrival notification
- QMailStore::instance()->flushIpcNotifications();
- if (!action->notify())
- qCWarning(lcMessaging) << "Unable to invoke service:" << serviceForType(type);
- }
- }
- }
- }
-
- messageCounts = newCounts;
-}
-
-void MessageServer::response(bool handled)
-{
- if (NewCountNotifier* action = static_cast<NewCountNotifier*>(sender())) {
- if (handled) {
- QMailMessage::MessageType type(actionType[action]);
- // No messages of this type are new any longer
- QMailMessageKey newMessages(QMailMessageKey::messageType(type));
- newMessages &= QMailMessageKey(QMailMessageKey::status(QMailMessage::New, QMailDataComparator::Includes));
- QMailStore::instance()->updateMessagesMetaData(newMessages, QMailMessage::New, false);
-
- if (messageCounts[type] != 0) {
- newMessageTotal -= messageCounts[type];
-
- messageCounts[type] = 0;
- NewCountNotifier::notify(type, 0);
- }
- }
- actionType.remove(action);
- action->deleteLater();
- if (actionType.isEmpty()) {
- // All outstanding handler events have been processed
- emit messageCountUpdated();
- }
- }
-}
-
-void MessageServer::error(const QString &message)
-{
- if (NewCountNotifier* action = static_cast<NewCountNotifier*>(sender())) {
- qCWarning(lcMessaging) << "Unable to complete service:" << serviceForType(actionType[action]) << "-" << message;
- actionType.remove(action);
- action->deleteLater();
- }
-
- if (actionType.isEmpty()) {
- // No outstanding handler events remain
- emit messageCountUpdated();
- }
-}
-
void MessageServer::transmissionCompleted(quint64 action)
{
// Ensure the client receives any resulting events before the completion notification
@@ -367,10 +233,7 @@ void MessageServer::messagesAdded(const QMailMessageIdList &ids)
void MessageServer::messagesUpdated(const QMailMessageIdList &ids)
{
- if (QMailStore::instance()->asynchronousEmission()) {
- // Only need to check message counts if the update occurred in another process
- updateNewMessageCounts();
- } else {
+ if (!QMailStore::instance()->asynchronousEmission()) {
// If we're updating, check whether the messages have been marked as Removed
foreach (const QMailMessageId &id, ids) {
if (completionList.contains(id)) {
@@ -390,28 +253,6 @@ void MessageServer::messagesRemoved(const QMailMessageIdList &ids)
// No need to complete deleted messages
completionList.remove(id);
}
-
- updateNewMessageCounts();
-}
-
-void MessageServer::updateNewMessageCounts()
-{
- int newTotal = newMessageCount(QMailMessage::AnyType);
- if (newTotal != newMessageTotal) {
- // The number of messages marked as new has changed, but not via a message arrival event
- static QMap<QMailMessage::MessageType, QString> typeSignature(typeSignatureInit());
-
- // Update the individual counts
- foreach (const QMailMessage::MessageType &type, typeSignature.keys()) {
- int count(newMessageCount(type));
- if (count != messageCounts[type]) {
- messageCounts[type] = count;
- NewCountNotifier::notify(type, count);
- }
- }
-
- emit messageCountUpdated();
- }
}
void MessageServer::cleanupTemporaryMessages()
diff --git a/src/tools/messageserver/messageserver.h b/src/tools/messageserver/messageserver.h
index 25f4b7f3..8308973c 100644
--- a/src/tools/messageserver/messageserver.h
+++ b/src/tools/messageserver/messageserver.h
@@ -35,14 +35,13 @@
#define MESSAGESERVER_H
#include <qmailmessageserver.h>
+
#include <QObject>
#include <QSet>
#include <QSocketNotifier>
#include <QList>
class ServiceHandler;
-class StoreHandler;
-class NewCountNotifier;
class QMailMessageServerService;
typedef QMap<QMailMessage::MessageType, int> MessageCountMap;
@@ -77,29 +76,16 @@ private slots:
void transmissionCompleted(quint64 action);
- void response(bool handled);
- void error(const QString &message);
-
void messagesAdded(const QMailMessageIdList &ids);
void messagesUpdated(const QMailMessageIdList &ids);
void messagesRemoved(const QMailMessageIdList &ids);
- void reportNewCounts();
void cleanupTemporaryMessages();
private:
- int newMessageCount(QMailMessage::MessageType type) const;
-
- void updateNewMessageCounts();
-
void readLogSettings() const;
ServiceHandler *handler;
- StoreHandler *storeHandler;
- MessageCountMap messageCounts;
-
- QMap<NewCountNotifier*, QMailMessage::MessageType> actionType;
- int newMessageTotal;
QSet<QMailMessageId> completionList;
bool completionAttempted;
diff --git a/src/tools/messageserver/messageserver.pro b/src/tools/messageserver/messageserver.pro
index c0773f31..95defd28 100644
--- a/src/tools/messageserver/messageserver.pro
+++ b/src/tools/messageserver/messageserver.pro
@@ -15,11 +15,9 @@ CONFIG -= app_bundle
target.path += $$QMF_INSTALL_ROOT/bin
HEADERS += messageserver.h \
- servicehandler.h \
- newcountnotifier.h
+ servicehandler.h
SOURCES += messageserver.cpp \
- newcountnotifier.cpp \
servicehandler.cpp
mailservice.files = ../../libraries/qmfclient/qmailservice.xml
diff --git a/src/tools/messageserver/newcountnotifier.cpp b/src/tools/messageserver/newcountnotifier.cpp
deleted file mode 100644
index f89f7270..00000000
--- a/src/tools/messageserver/newcountnotifier.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the Qt Messaging Framework.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <newcountnotifier.h>
-
-//stub for alternate handling, currently does nothing
-
-NewCountNotifier::NewCountNotifier(QMailMessage::MessageType, int)
- : QObject()
-{
-}
-
-NewCountNotifier::~NewCountNotifier()
-{
-}
-
-bool NewCountNotifier::notify()
-{
- // Emitting response(true) will cause the QMailMessage::New flag to be unset for all messages
- emit response(false);
- return true;
-}
-
-void NewCountNotifier::notify(QMailMessage::MessageType, int)
-{
-}
diff --git a/src/tools/messageserver/newcountnotifier.h b/src/tools/messageserver/newcountnotifier.h
deleted file mode 100644
index ed9f44d7..00000000
--- a/src/tools/messageserver/newcountnotifier.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the Qt Messaging Framework.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef NEWCOUNTNOTIFIER_H
-#define NEWCOUNTNOTIFIER_H
-
-#include <QString>
-#include <QObject>
-#include <qmailmessage.h>
-
-class NewCountNotifierPrivate;
-
-class NewCountNotifier : public QObject
-{
- Q_OBJECT
-
-public:
- NewCountNotifier(QMailMessage::MessageType type, int count);
- ~NewCountNotifier();
-
- bool notify();
-
-signals:
- void response(bool handled);
- void error(const QString& msg);
-
-public:
- static void notify(QMailMessage::MessageType type, int count);
-
-private:
- NewCountNotifierPrivate* d;
-};
-
-#endif
diff --git a/src/tools/messageserver/servicehandler.h b/src/tools/messageserver/servicehandler.h
index 1569151c..e873e801 100644
--- a/src/tools/messageserver/servicehandler.h
+++ b/src/tools/messageserver/servicehandler.h
@@ -155,7 +155,6 @@ signals:
void protocolRequestCompleted(quint64 action);
void newMessagesAvailable();
- void messageCountUpdated();
void transmissionReady(quint64 action);
void retrievalReady(quint64 action);