refactor(app-database-service):remove the redundant slots inherited from QThread.

This commit is contained in:
JunjieBai 2023-08-04 09:54:53 +08:00 committed by iaom
parent c9c3003061
commit d6b622a7a2
8 changed files with 269 additions and 1 deletions

View File

@ -179,6 +179,7 @@ AppDBManager::AppDBManager(QObject *parent) : QThread(parent), m_database(QSqlDa
}
}
});
m_adaptor = new AppDBManagerAdaptor(this);
} else {
qDebug() << "App-db-manager does nothing.";
}

View File

@ -33,6 +33,7 @@
#include "pending-app-info-queue.h"
#include "file-system-watcher.h"
#include "application-property.h"
#include "app-database-adaptor.h"
#define APP_DATABASE_PATH QDir::homePath()+"/.config/org.ukui/ukui-search/appdata/"
#define APP_DATABASE_NAME "app-info.db"
@ -223,6 +224,7 @@ private:
//原本额外排除的目录,不知道额外的原因,有可能之后有问题--bjj20220621
"/usr/share/applications/screensavers"
};
AppDBManagerAdaptor *m_adaptor = nullptr;
Q_SIGNALS:
//操作数据库

View File

@ -0,0 +1,111 @@
/*
* This file was generated by qdbusxml2cpp version 0.8
* Command line was: qdbusxml2cpp org.ukui.appdatabase.xml -a app-database-adaptor -i ../../libsearch/appdata/application-property.h
*
* qdbusxml2cpp is Copyright (C) 2020 The Qt Company Ltd.
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
*/
#include "app-database-adaptor.h"
#include <QtCore/QMetaObject>
#include <QtCore/QByteArray>
#include <QtCore/QList>
#include <QtCore/QMap>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QVariant>
/*
* Implementation of adaptor class AppDBManagerAdaptor
*/
AppDBManagerAdaptor::AppDBManagerAdaptor(QObject *parent)
: QDBusAbstractAdaptor(parent)
{
// constructor
setAutoRelaySignals(true);
}
AppDBManagerAdaptor::~AppDBManagerAdaptor()
{
// destructor
}
void AppDBManagerAdaptor::deleteDBItem(const QString &desktopfd)
{
// handle method call org.ukui.search.appDBManager.deleteDBItem
QMetaObject::invokeMethod(parent(), "deleteDBItem", Q_ARG(QString, desktopfd));
}
QString AppDBManagerAdaptor::desktopFilePathFromName(const QString &desktopFileName)
{
// handle method call org.ukui.search.appDBManager.desktopFilePathFromName
QString out0;
QMetaObject::invokeMethod(parent(), "desktopFilePathFromName", Q_RETURN_ARG(QString, out0), Q_ARG(QString, desktopFileName));
return out0;
}
void AppDBManagerAdaptor::insertDBItem(const QString &desktopfd)
{
// handle method call org.ukui.search.appDBManager.insertDBItem
QMetaObject::invokeMethod(parent(), "insertDBItem", Q_ARG(QString, desktopfd));
}
void AppDBManagerAdaptor::setValue(UkuiSearch::ApplicationInfoMap infos2BSet)
{
// handle method call org.ukui.search.appDBManager.setValue
QMetaObject::invokeMethod(parent(), "setValue", Q_ARG(UkuiSearch::ApplicationInfoMap, infos2BSet));
}
QString AppDBManagerAdaptor::tranPidToDesktopFp(uint pid)
{
// handle method call org.ukui.search.appDBManager.tranPidToDesktopFp
QString out0;
QMetaObject::invokeMethod(parent(), "tranPidToDesktopFp", Q_RETURN_ARG(QString, out0), Q_ARG(uint, pid));
return out0;
}
void AppDBManagerAdaptor::updateDBItem(const QString &desktopfd)
{
// handle method call org.ukui.search.appDBManager.updateDBItem
QMetaObject::invokeMethod(parent(), "updateDBItem", Q_ARG(QString, desktopfd));
}
void AppDBManagerAdaptor::updateFavoritesState(const QString &desktopFilePath)
{
// handle method call org.ukui.search.appDBManager.updateFavoritesState
QMetaObject::invokeMethod(parent(), "updateFavoritesState", Q_ARG(QString, desktopFilePath));
}
void AppDBManagerAdaptor::updateFavoritesState(const QString &desktopFilePath, uint num)
{
// handle method call org.ukui.search.appDBManager.updateFavoritesState
QMetaObject::invokeMethod(parent(), "updateFavoritesState", Q_ARG(QString, desktopFilePath), Q_ARG(uint, num));
}
void AppDBManagerAdaptor::updateLaunchTimes(const QString &desktopFilePath)
{
// handle method call org.ukui.search.appDBManager.updateLaunchTimes
QMetaObject::invokeMethod(parent(), "updateLaunchTimes", Q_ARG(QString, desktopFilePath));
}
void AppDBManagerAdaptor::updateLocaleData(const QString &desktopFilePath)
{
// handle method call org.ukui.search.appDBManager.updateLocaleData
QMetaObject::invokeMethod(parent(), "updateLocaleData", Q_ARG(QString, desktopFilePath));
}
void AppDBManagerAdaptor::updateTopState(const QString &desktopFilePath)
{
// handle method call org.ukui.search.appDBManager.updateTopState
QMetaObject::invokeMethod(parent(), "updateTopState", Q_ARG(QString, desktopFilePath));
}
void AppDBManagerAdaptor::updateTopState(const QString &desktopFilePath, uint num)
{
// handle method call org.ukui.search.appDBManager.updateTopState
QMetaObject::invokeMethod(parent(), "updateTopState", Q_ARG(QString, desktopFilePath), Q_ARG(uint, num));
}

View File

@ -0,0 +1,100 @@
/*
* This file was generated by qdbusxml2cpp version 0.8
* Command line was: qdbusxml2cpp org.ukui.appdatabase.xml -a app-database-adaptor -i ../../libsearch/appdata/application-property.h
*
* qdbusxml2cpp is Copyright (C) 2020 The Qt Company Ltd.
*
* This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments
* before re-generating it.
*/
#ifndef APPDATABASEADAPTOR_H
#define APPDATABASEADAPTOR_H
#include <QtCore/QObject>
#include <QtDBus/QtDBus>
#include "../../libsearch/appdata/application-property.h"
QT_BEGIN_NAMESPACE
class QByteArray;
template<class T> class QList;
template<class Key, class Value> class QMap;
class QString;
class QStringList;
class QVariant;
QT_END_NAMESPACE
/*
* Adaptor class for interface org.ukui.search.appDBManager
*/
class AppDBManagerAdaptor: public QDBusAbstractAdaptor
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.ukui.search.appDBManager")
Q_CLASSINFO("D-Bus Introspection", ""
" <interface name=\"org.ukui.search.appDBManager\">\n"
" <method name=\"tranPidToDesktopFp\">\n"
" <arg direction=\"out\" type=\"s\"/>\n"
" <arg direction=\"in\" type=\"u\" name=\"pid\"/>\n"
" </method>\n"
" <method name=\"desktopFilePathFromName\">\n"
" <arg direction=\"out\" type=\"s\"/>\n"
" <arg direction=\"in\" type=\"s\" name=\"desktopFileName\"/>\n"
" </method>\n"
" <method name=\"insertDBItem\">\n"
" <arg direction=\"in\" type=\"s\" name=\"desktopfd\"/>\n"
" </method>\n"
" <method name=\"updateDBItem\">\n"
" <arg direction=\"in\" type=\"s\" name=\"desktopfd\"/>\n"
" </method>\n"
" <method name=\"deleteDBItem\">\n"
" <arg direction=\"in\" type=\"s\" name=\"desktopfd\"/>\n"
" </method>\n"
" <method name=\"updateLocaleData\">\n"
" <arg direction=\"in\" type=\"s\" name=\"desktopFilePath\"/>\n"
" </method>\n"
" <method name=\"updateLaunchTimes\">\n"
" <arg direction=\"in\" type=\"s\" name=\"desktopFilePath\"/>\n"
" </method>\n"
" <method name=\"updateFavoritesState\">\n"
" <arg direction=\"in\" type=\"s\" name=\"desktopFilePath\"/>\n"
" <arg direction=\"in\" type=\"u\" name=\"num\"/>\n"
" </method>\n"
" <method name=\"updateFavoritesState\">\n"
" <arg direction=\"in\" type=\"s\" name=\"desktopFilePath\"/>\n"
" </method>\n"
" <method name=\"updateTopState\">\n"
" <arg direction=\"in\" type=\"s\" name=\"desktopFilePath\"/>\n"
" <arg direction=\"in\" type=\"u\" name=\"num\"/>\n"
" </method>\n"
" <method name=\"updateTopState\">\n"
" <arg direction=\"in\" type=\"s\" name=\"desktopFilePath\"/>\n"
" </method>\n"
" <method name=\"setValue\">\n"
" <arg direction=\"in\" type=\"a{sa{iv}}\" name=\"infos2BSet\"/>\n"
" <annotation value=\"UkuiSearch::ApplicationInfoMap\" name=\"org.qtproject.QtDBus.QtTypeName.In0\"/>\n"
" </method>\n"
" </interface>\n"
"")
public:
AppDBManagerAdaptor(QObject *parent);
virtual ~AppDBManagerAdaptor();
public: // PROPERTIES
public Q_SLOTS: // METHODS
void deleteDBItem(const QString &desktopfd);
QString desktopFilePathFromName(const QString &desktopFileName);
void insertDBItem(const QString &desktopfd);
void setValue(UkuiSearch::ApplicationInfoMap infos2BSet);
QString tranPidToDesktopFp(uint pid);
void updateDBItem(const QString &desktopfd);
void updateFavoritesState(const QString &desktopFilePath);
void updateFavoritesState(const QString &desktopFilePath, uint num);
void updateLaunchTimes(const QString &desktopFilePath);
void updateLocaleData(const QString &desktopFilePath);
void updateTopState(const QString &desktopFilePath);
void updateTopState(const QString &desktopFilePath, uint num);
Q_SIGNALS: // SIGNALS
};
#endif

View File

@ -0,0 +1,7 @@
INCLUDEPATH += $$PWD
HEADERS += \
$$PWD/app-database-adaptor.h
SOURCES += \
$$PWD/app-database-adaptor.cpp

View File

@ -0,0 +1,46 @@
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.ukui.search.appDBManager">
<method name="tranPidToDesktopFp">
<arg type="s" direction="out"/>
<arg name="pid" type="u" direction="in"/>
</method>
<method name="desktopFilePathFromName">
<arg type="s" direction="out"/>
<arg name="desktopFileName" type="s" direction="in"/>
</method>
<method name="insertDBItem">
<arg name="desktopfd" type="s" direction="in"/>
</method>
<method name="updateDBItem">
<arg name="desktopfd" type="s" direction="in"/>
</method>
<method name="deleteDBItem">
<arg name="desktopfd" type="s" direction="in"/>
</method>
<method name="updateLocaleData">
<arg name="desktopFilePath" type="s" direction="in"/>
</method>
<method name="updateLaunchTimes">
<arg name="desktopFilePath" type="s" direction="in"/>
</method>
<method name="updateFavoritesState">
<arg name="desktopFilePath" type="s" direction="in"/>
<arg name="num" type="u" direction="in"/>
</method>
<method name="updateFavoritesState">
<arg name="desktopFilePath" type="s" direction="in"/>
</method>
<method name="updateTopState">
<arg name="desktopFilePath" type="s" direction="in"/>
<arg name="num" type="u" direction="in"/>
</method>
<method name="updateTopState">
<arg name="desktopFilePath" type="s" direction="in"/>
</method>
<method name="setValue">
<arg name="infos2BSet" type="a{sa{iv}}" direction="in"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="UkuiSearch::ApplicationInfoMap"/>
</method>
</interface>
</node>

View File

@ -51,7 +51,7 @@ UkuiSearchAppDataService::UkuiSearchAppDataService(int &argc, char *argv[], cons
qCritical() << "QDbus register service failed reason:" << sessionBus.lastError();
}
if(!sessionBus.registerObject("/org/ukui/search/appDataBase/dbManager", AppDBManager::getInstance(), QDBusConnection::ExportAllSlots)) {
if(!sessionBus.registerObject("/org/ukui/search/appDataBase/dbManager", AppDBManager::getInstance(), QDBusConnection::ExportAdaptors)) {
qCritical() << "ukui-search-app-db-manager dbus register object failed reason:" << sessionBus.lastError();
}

View File

@ -22,6 +22,7 @@ QMAKE_CXXFLAGS += -Werror=return-type -Werror=return-local-addr -Werror=uninitia
#include(../libsearch/appdata/appdata.pri)
include(../3rd-parties/qtsingleapplication/qtsingleapplication.pri)
include(./dbus/app-database-dbus.pri)
LIBS += -lQt5Xdg