Skip to content

Commit

Permalink
chore: add DBus adaptor for anything service
Browse files Browse the repository at this point in the history
Add AnythingAdaptor class generated from qdbusxml2cpp to provide DBus interface
for the anything service.

Log: add DBus adaptor for anything service
  • Loading branch information
wyu71 authored and deepin-bot[bot] committed Jan 14, 2025
1 parent f4d44c6 commit 8df7984
Show file tree
Hide file tree
Showing 2 changed files with 379 additions and 0 deletions.
211 changes: 211 additions & 0 deletions src/configs/dbus/AnythingAdaptor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
// SPDX-FileCopyrightText: 2024 - 2025 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include "AnythingAdaptor.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 AnythingAdaptor
*/

AnythingAdaptor::AnythingAdaptor(QObject *parent)
: QDBusAbstractAdaptor(parent)
{
// constructor
setAutoRelaySignals(true);
}

AnythingAdaptor::~AnythingAdaptor()
{
// destructor
}

bool AnythingAdaptor::autoIndexExternal() const
{
// get the value of property autoIndexExternal
return qvariant_cast< bool >(parent()->property("autoIndexExternal"));
}

void AnythingAdaptor::setAutoIndexExternal(bool value)
{
// set the value of property autoIndexExternal
parent()->setProperty("autoIndexExternal", QVariant::fromValue(value));
}

bool AnythingAdaptor::autoIndexInternal() const
{
// get the value of property autoIndexInternal
return qvariant_cast< bool >(parent()->property("autoIndexInternal"));
}

void AnythingAdaptor::setAutoIndexInternal(bool value)
{
// set the value of property autoIndexInternal
parent()->setProperty("autoIndexInternal", QVariant::fromValue(value));
}

int AnythingAdaptor::logLevel() const
{
// get the value of property logLevel
return qvariant_cast< int >(parent()->property("logLevel"));
}

void AnythingAdaptor::setLogLevel(int value)
{
// set the value of property logLevel
parent()->setProperty("logLevel", QVariant::fromValue(value));
}

bool AnythingAdaptor::addPath(const QString &path)
{
// handle method call com.deepin.anything.addPath
bool success;
QMetaObject::invokeMethod(parent(), "addPath", Q_RETURN_ARG(bool, success), Q_ARG(QString, path));
return success;
}

QStringList AnythingAdaptor::allPath()
{
// handle method call com.deepin.anything.allPath
QStringList pathList;
QMetaObject::invokeMethod(parent(), "allPath", Q_RETURN_ARG(QStringList, pathList));
return pathList;
}

QString AnythingAdaptor::cacheDir()
{
// handle method call com.deepin.anything.cacheDir
QString path;
QMetaObject::invokeMethod(parent(), "cacheDir", Q_RETURN_ARG(QString, path));
return path;
}

bool AnythingAdaptor::cancelBuild(const QString &path)
{
// handle method call com.deepin.anything.cancelBuild
bool success;
QMetaObject::invokeMethod(parent(), "cancelBuild", Q_RETURN_ARG(bool, success), Q_ARG(QString, path));
return success;
}

bool AnythingAdaptor::hasLFT(const QString &path)
{
// handle method call com.deepin.anything.hasLFT
bool success;
QMetaObject::invokeMethod(parent(), "hasLFT", Q_RETURN_ARG(bool, success), Q_ARG(QString, path));
return success;
}

QStringList AnythingAdaptor::hasLFTSubdirectories(const QString &path)
{
// handle method call com.deepin.anything.hasLFTSubdirectories
QStringList directories;
QMetaObject::invokeMethod(parent(), "hasLFTSubdirectories", Q_RETURN_ARG(QStringList, directories), Q_ARG(QString, path));
return directories;
}

QStringList AnythingAdaptor::insertFileToLFTBuf(const QByteArray &filePath)
{
// handle method call com.deepin.anything.insertFileToLFTBuf
QStringList bufRootPathList;
QMetaObject::invokeMethod(parent(), "insertFileToLFTBuf", Q_RETURN_ARG(QStringList, bufRootPathList), Q_ARG(QByteArray, filePath));
return bufRootPathList;
}

bool AnythingAdaptor::lftBuinding(const QString &path)
{
// handle method call com.deepin.anything.lftBuinding
bool success;
QMetaObject::invokeMethod(parent(), "lftBuinding", Q_RETURN_ARG(bool, success), Q_ARG(QString, path));
return success;
}

QStringList AnythingAdaptor::parallelsearch(const QString &path, uint startOffset, uint endOffset, const QString &keyword, const QStringList &rules, uint &startOffset_, uint &endOffset_)
{
// handle method call com.deepin.anything.parallelsearch
//return static_cast<YourObjectType *>(parent())->parallelsearch(path, startOffset, endOffset, keyword, rules, startOffset_, endOffset_);
}

QStringList AnythingAdaptor::parallelsearch(const QString &path, const QString &keyword, const QStringList &rules)
{
// handle method call com.deepin.anything.parallelsearch
QStringList results;
QMetaObject::invokeMethod(parent(), "parallelsearch", Q_RETURN_ARG(QStringList, results), Q_ARG(QString, path), Q_ARG(QString, keyword), Q_ARG(QStringList, rules));
return results;
}

void AnythingAdaptor::quit()
{
// handle method call com.deepin.anything.quit
QMetaObject::invokeMethod(parent(), "quit");
}

QStringList AnythingAdaptor::refresh(const QByteArray &serialUriFilter)
{
// handle method call com.deepin.anything.refresh
QStringList rootPathList;
QMetaObject::invokeMethod(parent(), "refresh", Q_RETURN_ARG(QStringList, rootPathList), Q_ARG(QByteArray, serialUriFilter));
return rootPathList;
}

QStringList AnythingAdaptor::removeFileFromLFTBuf(const QByteArray &filePath)
{
// handle method call com.deepin.anything.removeFileFromLFTBuf
QStringList bufRootPathList;
QMetaObject::invokeMethod(parent(), "removeFileFromLFTBuf", Q_RETURN_ARG(QStringList, bufRootPathList), Q_ARG(QByteArray, filePath));
return bufRootPathList;
}

bool AnythingAdaptor::removePath(const QString &path)
{
// handle method call com.deepin.anything.removePath
bool success;
QMetaObject::invokeMethod(parent(), "removePath", Q_RETURN_ARG(bool, success), Q_ARG(QString, path));
return success;
}

QStringList AnythingAdaptor::renameFileOfLFTBuf(const QByteArray &fromFilePath, const QByteArray &toFilePath)
{
// handle method call com.deepin.anything.renameFileOfLFTBuf
QStringList bufRootPathList;
QMetaObject::invokeMethod(parent(), "renameFileOfLFTBuf", Q_RETURN_ARG(QStringList, bufRootPathList), Q_ARG(QByteArray, fromFilePath), Q_ARG(QByteArray, toFilePath));
return bufRootPathList;
}

QStringList AnythingAdaptor::search(int maxCount, qlonglong icase, uint startOffset, uint endOffset, const QString &path, const QString &keyword, bool useRegExp, uint &startOffset_, uint &endOffset_)
{
// handle method call com.deepin.anything.search
//return static_cast<YourObjectType *>(parent())->search(maxCount, icase, startOffset, endOffset, path, keyword, useRegExp, startOffset_, endOffset_);
}

QStringList AnythingAdaptor::search(const QString &path, const QString &keyword, bool useRegExp)
{
// handle method call com.deepin.anything.search
QStringList results;
QMetaObject::invokeMethod(parent(), "search", Q_RETURN_ARG(QStringList, results), Q_ARG(QString, path), Q_ARG(QString, keyword), Q_ARG(bool, useRegExp));
return results;
}

QByteArray AnythingAdaptor::setCodecNameForLocale(const QByteArray &name)
{
// handle method call com.deepin.anything.setCodecNameForLocale
QByteArray oldCodecName;
QMetaObject::invokeMethod(parent(), "setCodecNameForLocale", Q_RETURN_ARG(QByteArray, oldCodecName), Q_ARG(QByteArray, name));
return oldCodecName;
}

QStringList AnythingAdaptor::sync(const QString &mountPoint)
{
// handle method call com.deepin.anything.sync
QStringList rootPathList;
QMetaObject::invokeMethod(parent(), "sync", Q_RETURN_ARG(QStringList, rootPathList), Q_ARG(QString, mountPoint));
return rootPathList;
}

168 changes: 168 additions & 0 deletions src/configs/dbus/AnythingAdaptor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
// SPDX-FileCopyrightText: 2024 - 2025 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#ifndef ANYTHINGADAPTOR_H
#define ANYTHINGADAPTOR_H

#include <QtCore/QObject>
#include <QtDBus/QtDBus>
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 com.deepin.anything
*/
class AnythingAdaptor: public QDBusAbstractAdaptor
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "com.deepin.anything")
Q_CLASSINFO("D-Bus Introspection", ""
" <interface name=\"com.deepin.anything\">\n"
" <property access=\"readwrite\" type=\"b\" name=\"autoIndexInternal\"/>\n"
" <property access=\"readwrite\" type=\"b\" name=\"autoIndexExternal\"/>\n"
" <property access=\"readwrite\" type=\"i\" name=\"logLevel\"/>\n"
" <method name=\"cacheDir\">\n"
" <arg direction=\"out\" type=\"s\" name=\"path\"/>\n"
" </method>\n"
" <method name=\"setCodecNameForLocale\">\n"
" <arg direction=\"in\" type=\"ay\" name=\"name\"/>\n"
" <arg direction=\"out\" type=\"ay\" name=\"oldCodecName\"/>\n"
" </method>\n"
" <method name=\"allPath\">\n"
" <arg direction=\"out\" type=\"as\" name=\"pathList\"/>\n"
" </method>\n"
" <method name=\"addPath\">\n"
" <arg direction=\"in\" type=\"s\" name=\"path\"/>\n"
" <arg direction=\"out\" type=\"b\" name=\"success\"/>\n"
" </method>\n"
" <method name=\"removePath\">\n"
" <arg direction=\"in\" type=\"s\" name=\"path\"/>\n"
" <arg direction=\"out\" type=\"b\" name=\"success\"/>\n"
" </method>\n"
" <method name=\"hasLFT\">\n"
" <arg direction=\"in\" type=\"s\" name=\"path\"/>\n"
" <arg direction=\"out\" type=\"b\" name=\"success\"/>\n"
" </method>\n"
" <method name=\"hasLFTSubdirectories\">\n"
" <arg direction=\"in\" type=\"s\" name=\"path\"/>\n"
" <arg direction=\"out\" type=\"as\" name=\"directories\"/>\n"
" </method>\n"
" <method name=\"lftBuinding\">\n"
" <arg direction=\"in\" type=\"s\" name=\"path\"/>\n"
" <arg direction=\"out\" type=\"b\" name=\"success\"/>\n"
" </method>\n"
" <method name=\"cancelBuild\">\n"
" <arg direction=\"in\" type=\"s\" name=\"path\"/>\n"
" <arg direction=\"out\" type=\"b\" name=\"success\"/>\n"
" </method>\n"
" <method name=\"refresh\">\n"
" <arg direction=\"in\" type=\"ay\" name=\"serialUriFilter\"/>\n"
" <arg direction=\"out\" type=\"as\" name=\"rootPathList\"/>\n"
" </method>\n"
" <method name=\"sync\">\n"
" <arg direction=\"in\" type=\"s\" name=\"mountPoint\"/>\n"
" <arg direction=\"out\" type=\"as\" name=\"rootPathList\"/>\n"
" </method>\n"
" <method name=\"search\">\n"
" <arg direction=\"in\" type=\"s\" name=\"path\"/>\n"
" <arg direction=\"in\" type=\"s\" name=\"keyword\"/>\n"
" <arg direction=\"in\" type=\"b\" name=\"useRegExp\"/>\n"
" <arg direction=\"out\" type=\"as\" name=\"results\"/>\n"
" </method>\n"
" <method name=\"search\">\n"
" <arg direction=\"in\" type=\"i\" name=\"maxCount\"/>\n"
" <arg direction=\"in\" type=\"x\" name=\"icase\"/>\n"
" <arg direction=\"in\" type=\"u\" name=\"startOffset\"/>\n"
" <arg direction=\"in\" type=\"u\" name=\"endOffset\"/>\n"
" <arg direction=\"in\" type=\"s\" name=\"path\"/>\n"
" <arg direction=\"in\" type=\"s\" name=\"keyword\"/>\n"
" <arg direction=\"in\" type=\"b\" name=\"useRegExp\"/>\n"
" <arg direction=\"out\" type=\"as\" name=\"results\"/>\n"
" <arg direction=\"out\" type=\"u\" name=\"startOffset\"/>\n"
" <arg direction=\"out\" type=\"u\" name=\"endOffset\"/>\n"
" </method>\n"
" <method name=\"parallelsearch\">\n"
" <arg direction=\"in\" type=\"s\" name=\"path\"/>\n"
" <arg direction=\"in\" type=\"s\" name=\"keyword\"/>\n"
" <arg direction=\"in\" type=\"as\" name=\"rules\"/>\n"
" <arg direction=\"out\" type=\"as\" name=\"results\"/>\n"
" </method>\n"
" <method name=\"parallelsearch\">\n"
" <arg direction=\"in\" type=\"s\" name=\"path\"/>\n"
" <arg direction=\"in\" type=\"u\" name=\"startOffset\"/>\n"
" <arg direction=\"in\" type=\"u\" name=\"endOffset\"/>\n"
" <arg direction=\"in\" type=\"s\" name=\"keyword\"/>\n"
" <arg direction=\"in\" type=\"as\" name=\"rules\"/>\n"
" <arg direction=\"out\" type=\"as\" name=\"results\"/>\n"
" <arg direction=\"out\" type=\"u\" name=\"startOffset\"/>\n"
" <arg direction=\"out\" type=\"u\" name=\"endOffset\"/>\n"
" </method>\n"
" <method name=\"insertFileToLFTBuf\">\n"
" <arg direction=\"in\" type=\"ay\" name=\"filePath\"/>\n"
" <arg direction=\"out\" type=\"as\" name=\"bufRootPathList\"/>\n"
" </method>\n"
" <method name=\"removeFileFromLFTBuf\">\n"
" <arg direction=\"in\" type=\"ay\" name=\"filePath\"/>\n"
" <arg direction=\"out\" type=\"as\" name=\"bufRootPathList\"/>\n"
" </method>\n"
" <method name=\"renameFileOfLFTBuf\">\n"
" <arg direction=\"in\" type=\"ay\" name=\"fromFilePath\"/>\n"
" <arg direction=\"in\" type=\"ay\" name=\"toFilePath\"/>\n"
" <arg direction=\"out\" type=\"as\" name=\"bufRootPathList\"/>\n"
" </method>\n"
" <method name=\"quit\"/>\n"
" <signal name=\"addPathFinished\">\n"
" <arg type=\"s\" name=\"path\"/>\n"
" <arg type=\"b\" name=\"success\"/>\n"
" </signal>\n"
" </interface>\n"
"")
public:
AnythingAdaptor(QObject *parent);
virtual ~AnythingAdaptor();

public: // PROPERTIES
Q_PROPERTY(bool autoIndexExternal READ autoIndexExternal WRITE setAutoIndexExternal)
bool autoIndexExternal() const;
void setAutoIndexExternal(bool value);

Q_PROPERTY(bool autoIndexInternal READ autoIndexInternal WRITE setAutoIndexInternal)
bool autoIndexInternal() const;
void setAutoIndexInternal(bool value);

Q_PROPERTY(int logLevel READ logLevel WRITE setLogLevel)
int logLevel() const;
void setLogLevel(int value);

public Q_SLOTS: // METHODS
bool addPath(const QString &path);
QStringList allPath();
QString cacheDir();
bool cancelBuild(const QString &path);
bool hasLFT(const QString &path);
QStringList hasLFTSubdirectories(const QString &path);
QStringList insertFileToLFTBuf(const QByteArray &filePath);
bool lftBuinding(const QString &path);
QStringList parallelsearch(const QString &path, uint startOffset, uint endOffset, const QString &keyword, const QStringList &rules, uint &startOffset_, uint &endOffset_);
QStringList parallelsearch(const QString &path, const QString &keyword, const QStringList &rules);
void quit();
QStringList refresh(const QByteArray &serialUriFilter);
QStringList removeFileFromLFTBuf(const QByteArray &filePath);
bool removePath(const QString &path);
QStringList renameFileOfLFTBuf(const QByteArray &fromFilePath, const QByteArray &toFilePath);
QStringList search(int maxCount, qlonglong icase, uint startOffset, uint endOffset, const QString &path, const QString &keyword, bool useRegExp, uint &startOffset_, uint &endOffset_);
QStringList search(const QString &path, const QString &keyword, bool useRegExp);
QByteArray setCodecNameForLocale(const QByteArray &name);
QStringList sync(const QString &mountPoint);
Q_SIGNALS: // SIGNALS
void addPathFinished(const QString &path, bool success);
};

#endif

0 comments on commit 8df7984

Please sign in to comment.