feat: watch systemd unit new and remove to sync state
add default values to XDG_DATA_DIRS if it dosen't set Signed-off-by: ComixHe <heyuming@deepin.org> Signed-off-by: black-desk <me@black-desk.cn>
This commit is contained in:
		@ -21,17 +21,19 @@ int main(int argc, char *argv[])
 | 
			
		||||
{
 | 
			
		||||
    QCoreApplication app{argc, argv};
 | 
			
		||||
    auto &bus = ApplicationManager1DBus::instance();
 | 
			
		||||
    bus.init(DBusType::Session);
 | 
			
		||||
    auto &AMBus = bus.globalBus();
 | 
			
		||||
    bus.initGlobalServerBus(DBusType::Session);
 | 
			
		||||
    bus.setDestBus("");
 | 
			
		||||
    auto &AMBus = bus.globalServerBus();
 | 
			
		||||
 | 
			
		||||
    registerComplexDbusType();
 | 
			
		||||
    ApplicationManager1Service AMService{std::make_unique<CGroupsIdentifier>(), AMBus};
 | 
			
		||||
    QList<DesktopFile> fileList{};
 | 
			
		||||
    auto pathEnv = qgetenv("XDG_DATA_DIRS");
 | 
			
		||||
    if (pathEnv.isEmpty()) {
 | 
			
		||||
        qFatal() << "environment variable $XDG_DATA_DIRS is empty.";
 | 
			
		||||
    QByteArray XDGDataDirs;
 | 
			
		||||
    XDGDataDirs = qgetenv("XDG_DATA_DIRS");
 | 
			
		||||
    if (XDGDataDirs.isEmpty()) {
 | 
			
		||||
        XDGDataDirs.append("/usr/local/share/:/usr/share/");
 | 
			
		||||
    }
 | 
			
		||||
    auto desktopFileDirs = pathEnv.split(':');
 | 
			
		||||
    auto desktopFileDirs = XDGDataDirs.split(':');
 | 
			
		||||
 | 
			
		||||
    for (const auto &dir : desktopFileDirs) {
 | 
			
		||||
        auto dirPath = QDir{QDir::cleanPath(dir) + "/applications"};
 | 
			
		||||
 | 
			
		||||
@ -6,7 +6,7 @@
 | 
			
		||||
 | 
			
		||||
bool registerObjectToDBus(QObject *o, const QString &path, const QString &interface)
 | 
			
		||||
{
 | 
			
		||||
    auto &con = ApplicationManager1DBus::instance().globalBus();
 | 
			
		||||
    auto &con = ApplicationManager1DBus::instance().globalServerBus();
 | 
			
		||||
    if (!con.registerObject(path, interface, o, QDBusConnection::RegisterOption::ExportAllContents)) {
 | 
			
		||||
        qFatal() << "register object failed:" << path << interface << con.lastError();
 | 
			
		||||
    } else {
 | 
			
		||||
@ -17,6 +17,7 @@ bool registerObjectToDBus(QObject *o, const QString &path, const QString &interf
 | 
			
		||||
 | 
			
		||||
void unregisterObjectFromDBus(const QString &path)
 | 
			
		||||
{
 | 
			
		||||
    auto &con = ApplicationManager1DBus::instance().globalBus();
 | 
			
		||||
    auto &con = ApplicationManager1DBus::instance().globalServerBus();
 | 
			
		||||
    con.unregisterObject(path);
 | 
			
		||||
    qInfo() << "unregister object:" << path;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user