Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions panels/notification/common/dbaccessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <QDir>
#include <QElapsedTimer>
#include <QLoggingCategory>
#include <QMutexLocker>
#include <QSqlDatabase>
#include <QSqlError>
#include <QSqlQuery>
Expand Down Expand Up @@ -173,6 +174,7 @@
{
BENCHMARK();

QMutexLocker locker(&m_mutex);
QSqlQuery query(m_connection);

QString columns = QStringList{
Expand Down Expand Up @@ -224,6 +226,7 @@
{
BENCHMARK();

QMutexLocker locker(&m_mutex);
QSqlQuery query(m_connection);

QString cmd = QString("UPDATE %1 SET ProcessedType = :processed WHERE ID = :id").arg(TableName_v2);
Expand All @@ -240,9 +243,10 @@
{
BENCHMARK();

QMutexLocker locker(&m_mutex);
QSqlQuery query(m_connection);
QString cmd = QString("SELECT %1 FROM notifications2 WHERE ID = :id").arg(EntityFields.join(","));
query.prepare(cmd);

Check warning on line 249 in panels/notification/common/dbaccessor.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Error code from the return value of function query.prepare() is not used.
query.bindValue(":id", id);

if (!query.exec()) {
Expand All @@ -260,6 +264,7 @@
{
BENCHMARK();

QMutexLocker locker(&m_mutex);
QSqlQuery query(m_connection);
if (appName == DataAccessor::AllApp()) {
QString cmd = QString("SELECT COUNT(*) FROM notifications2 WHERE (ProcessedType = :processedType OR ProcessedType IS NULL)");
Expand Down Expand Up @@ -287,6 +292,7 @@
{
BENCHMARK();

QMutexLocker locker(&m_mutex);
QSqlQuery query(m_connection);
QString cmd =
QString(
Expand Down Expand Up @@ -314,6 +320,7 @@
{
BENCHMARK();

QMutexLocker locker(&m_mutex);
QSqlQuery query(m_connection);
if (appName == DataAccessor::AllApp()) {
if (maxCount >= 0) {
Expand Down Expand Up @@ -360,9 +367,10 @@
{
BENCHMARK();

QMutexLocker locker(&m_mutex);
QSqlQuery query(m_connection);
QString cmd = QString("SELECT %1 FROM notifications2 WHERE notifyId = :notifyId ORDER BY CTime DESC LIMIT 1").arg(EntityFields.join(","));
query.prepare(cmd);

Check warning on line 373 in panels/notification/common/dbaccessor.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Error code from the return value of function query.prepare() is not used.
query.bindValue(":notifyId", notifyId);

if (!query.exec()) {
Expand All @@ -383,6 +391,7 @@
{
BENCHMARK();

QMutexLocker locker(&m_mutex);
QSqlQuery query(m_connection);
if (maxCount >= 0) {
QString cmd("SELECT DISTINCT AppName FROM notifications2 ORDER BY CTime DESC LIMIT :limit");
Expand Down Expand Up @@ -413,6 +422,7 @@
{
BENCHMARK();

QMutexLocker locker(&m_mutex);
QSqlQuery query(m_connection);

QString cmd("DELETE FROM notifications2 WHERE ID = :id");
Expand All @@ -431,6 +441,7 @@
{
BENCHMARK();

QMutexLocker locker(&m_mutex);
QSqlQuery query(m_connection);

QString cmd("DELETE FROM notifications2 WHERE AppName = :appName");
Expand All @@ -449,6 +460,7 @@
{
BENCHMARK();

QMutexLocker locker(&m_mutex);
QSqlQuery query(m_connection);

QString cmd("DELETE FROM notifications2");
Expand Down
2 changes: 2 additions & 0 deletions panels/notification/common/dbaccessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#pragma once

#include <QMutex>
#include <QObject>
#include <QSqlDatabase>

Expand Down Expand Up @@ -50,6 +51,7 @@ class DBAccessor : public DataAccessor
NotifyEntity parseEntity(const QSqlQuery &query);

private:
mutable QMutex m_mutex;
QSqlDatabase m_connection;
QString m_key;
};
Expand Down
6 changes: 3 additions & 3 deletions panels/notification/server/notificationmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ class NotificationManager : public QObject, public QDBusContext
bool registerDbusService();

uint recordCount() const;
void actionInvoked(qint64 id, uint bubbleId, const QString &actionKey);
void notificationClosed(qint64 id, uint bubbleId, uint reason);
void notificationReplaced(qint64 id);
Q_INVOKABLE void actionInvoked(qint64 id, uint bubbleId, const QString &actionKey);
Q_INVOKABLE void notificationClosed(qint64 id, uint bubbleId, uint reason);
Q_INVOKABLE void notificationReplaced(qint64 id);

void removeNotification(qint64 id);
void removeNotifications(const QString &appName);
Expand Down
6 changes: 3 additions & 3 deletions panels/notification/server/notifyserverapplet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,17 @@ bool NotifyServerApplet::init()

void NotifyServerApplet::actionInvoked(qint64 id, uint bubbleId, const QString &actionKey)
{
m_manager->actionInvoked(id, bubbleId, actionKey);
QMetaObject::invokeMethod(m_manager, "actionInvoked", Qt::AutoConnection, Q_ARG(qint64, id), Q_ARG(uint, bubbleId), Q_ARG(QString, actionKey));
}

void NotifyServerApplet::notificationClosed(qint64 id, uint bubbleId, uint reason)
{
m_manager->notificationClosed(id, bubbleId, reason);
QMetaObject::invokeMethod(m_manager, "notificationClosed", Qt::AutoConnection, Q_ARG(qint64, id), Q_ARG(uint, bubbleId), Q_ARG(uint, reason));
}

void NotifyServerApplet::notificationReplaced(qint64 id)
{
m_manager->notificationReplaced(id);
QMetaObject::invokeMethod(m_manager, "notificationReplaced", Qt::AutoConnection, Q_ARG(qint64, id));
}

QVariant NotifyServerApplet::appValue(const QString &appId, int configItem)
Expand Down
Loading