peony-extensions/ 0000775 0001750 0001750 00000000000 15257160277 013043 5 ustar feng feng peony-extensions/NEWS 0000664 0001750 0001750 00000000401 15257160264 013531 0 ustar feng feng ### peony-extensions 2.0.0
* Rewrite the plugins according to the peony-2.0.0.
### peony-extensions 1.1.0
* Initial release.
* Add archive extension.
### peony-extensions 1.1.4
* Drop peony-admin since python-gi and python-caja depends python2.
peony-extensions/test-computer-view/ 0000775 0001750 0001750 00000000000 15257160264 016622 5 ustar feng feng peony-extensions/test-computer-view/main.cpp 0000664 0001750 0001750 00000001623 15257160264 020254 0 ustar feng feng /*
* Peony-Qt's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
*/
#include "mainwindow.h"
#include
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
peony-extensions/test-computer-view/mainwindow.h 0000664 0001750 0001750 00000002052 15257160264 021146 0 ustar feng feng /*
* Peony-Qt's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
*/
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
peony-extensions/test-computer-view/test-computer-view.pro 0000664 0001750 0001750 00000002016 15257160264 023126 0 ustar feng feng QT += core gui dbus network
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += debug c++11 no_keywords link_pkgconfig plugin
PKGCONFIG +=gio-2.0 glib-2.0 gio-unix-2.0 peony udisks2 libnotify
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
include(../common.pri)
include(../peony-extension-computer-view/computer-view/computer-view.pri)
# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp \
mainwindow.cpp
HEADERS += \
mainwindow.h
FORMS += \
mainwindow.ui
peony-extensions/test-computer-view/mainwindow.ui 0000664 0001750 0001750 00000001030 15257160264 021327 0 ustar feng feng
MainWindow
0
0
800
600
MainWindow
peony-extensions/test-computer-view/mainwindow.cpp 0000664 0001750 0001750 00000002007 15257160264 021501 0 ustar feng feng /*
* Peony-Qt's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
*/
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "computer-view.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
setCentralWidget(new ComputerView);
}
MainWindow::~MainWindow()
{
delete ui;
}
peony-extensions/peony-send-to-device/ 0000775 0001750 0001750 00000000000 15257160277 017001 5 ustar feng feng peony-extensions/peony-send-to-device/send-to-device-plugin.cpp 0000664 0001750 0001750 00000024563 15257160277 023621 0 ustar feng feng /*
* Peony-Qt's Library
*
* Copyright (C) 2019, Tianjin KYLIN Information Technology Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Ding Jing
*
*/
#include "send-to-device-plugin.h"
#include "file-info.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#ifdef KYLIN_COMMON
#include
#endif
#define V10_SP1_EDU "V10SP1-edu"
static QString getIconName (GIcon* icons);
static void mounted_func (gpointer data, gpointer udata);
static void handle_mount_added (GVolumeMonitor* monitor, GMount* mount, gpointer data);
static void handle_mount_removed(GVolumeMonitor* monitor, GMount* mount, gpointer data);
using namespace Peony;
SendToPlugin::SendToPlugin(QObject *parent) : QObject(parent), mEnable(true)
{
// translator
QTranslator *t = new QTranslator(this);
t->load(":/translations/peony-send-to-device_"+QLocale::system().name());
QFile file(":/translations/peony-send-to-device_"+QLocale::system().name()+".ts");
QApplication::installTranslator(t);
}
QList SendToPlugin::menuActions(Types types, const QString &uri, const QStringList &selectionUris)
{
#ifdef KYLIN_COMMON
if (QString::fromStdString(KDKGetPrjCodeName()) == V10_SP1_EDU) {
return QList();
}
#endif
QList l;
if (selectionUris.count() <= 0) {
return l;
}
auto info = FileInfo::fromUri(selectionUris.first());
if (selectionUris.first().startsWith("computer:///")
|| selectionUris.first().startsWith("trash:///")
|| selectionUris.first().startsWith("filesafe:///")
|| info->isVirtual()) {
return l;
}
QStringList selectionTargerUris = selectionUris;
if (selectionUris.first().startsWith("recent:///")) {
selectionTargerUris.clear();
for (auto u : selectionUris){
selectionTargerUris << FileUtils::getTargetUri(u);
}
}
QAction* action = new DriverAction(selectionTargerUris);
if (action) {
l << action;
}
Q_UNUSED(uri)
Q_UNUSED(types)
return l;
}
DriverItem::DriverItem(QString uri, QIcon icon, QString name, QObject* parent) : QAction(parent), mName(name), mIcon(icon), mUri(uri)
{
setIcon(mIcon);
setText(name);
}
const QIcon DriverItem::icon()
{
return mIcon;
}
const QString DriverItem::name()
{
return mName;
}
const QString DriverItem::uri()
{
return mUri;
}
static void handle_mount_added(GVolumeMonitor* monitor, GMount* mount, gpointer data)
{
DriverAction* drivers = (DriverAction*)data;
mounted_func (mount, drivers);
Q_UNUSED(monitor)
}
static void handle_mount_removed(GVolumeMonitor* monitor, GMount* mount, gpointer data)
{
char* path = nullptr;
GFile* location = nullptr;
if (!mount || !data) return;
location = g_mount_get_default_location(mount);
if (location) {
path = g_file_get_uri(location);
}
if (nullptr != path) {
((DriverAction*)data)->driverRemove(path);
}
qDebug() << "remove uri:" << path;
if (!path) g_free(path);
if (!location) g_object_unref(location);
Q_UNUSED(monitor)
}
static void mounted_func (gpointer data, gpointer udata)
{
GMount* mount = (GMount*)data;
GFile* location = nullptr;
char* uri = nullptr;
DriverAction* act = (static_cast(udata));
if (!data || !udata || !act) return;
if (mount) {
location = g_mount_get_default_location(mount);
if (location) {
uri = g_file_get_uri(location);
auto path = g_file_peek_path(location);
if (path) {
g_autoptr (GUnixMountEntry) entry = g_unix_mount_at(path, NULL);
if (entry) {
auto fsType = g_unix_mount_get_fs_type(entry);
if (QString(fsType).contains("fuse.kyfs")) {
return;
}
}
}
}
}
// check permission
FileInfoJob* fileInfo = new FileInfoJob(uri);
fileInfo->setAutoDelete ();
fileInfo->queryAsync ();
act->connect(fileInfo, &FileInfoJob::queryAsyncFinished, act, [=] (bool success) {
if (success) {
GMount* mount = (GMount*)data;
if (G_IS_MOUNT (mount)) {
g_autofree char* name = g_mount_get_name(mount);
GIcon* icons = g_mount_get_icon(mount);
QString icon = getIconName (icons);
if (icon.isEmpty()) {
g_autoptr(GVolume) volume = g_mount_get_volume(mount);
g_autoptr(GIcon) g_icon = g_volume_get_icon(volume);
icon = FileUtils::getIconStringFromGIcon(g_icon);
}
if (icon == "drive-harddisk-usb") {
double size = FileUtils::getDeviceSize(fileInfo->getInfo()->unixDeviceFile().toUtf8().constData());
if (size > 128) {
icon = "drive-harddisk-usb";
} else {
icon = "drive-removable-media-usb";
}
}
std::shared_ptr info = fileInfo->getInfo();
if (uri && name && info.get()->canExecute() && info.get()->canWrite()) {
Q_EMIT (static_cast(udata))->driverAdded(uri, name, icon);
}
qDebug() << "name:" << name << " uri:" << uri << " icons:" << icons << " icon:" << icon;
}
}
});
if (!uri) g_free(uri);
if (!location) g_object_unref(location);
}
static QString getIconName (GIcon* icons)
{
if (nullptr == icons) {
return "";
}
QString icon = nullptr;
if (G_IS_ICON(icons)) {
const gchar* const* iconNames = g_themed_icon_get_names(G_THEMED_ICON (icons));
if (iconNames) {
auto p = iconNames;
while (*p) {
QIcon icont = QIcon::fromTheme(*p);
if (!icont.isNull()) {
icon = QString (*p);
break;
} else {
p++;
}
}
}
g_object_unref(icons);
}
return icon;
}
DriverAction::DriverAction(const QStringList& uris, QObject *parent) : QAction(parent)
{
mMenu = new QMenu();
mVolumeMonitor = g_volume_monitor_get();
mDeviceAdd = g_signal_connect(G_OBJECT(mVolumeMonitor), "mount-added", G_CALLBACK(handle_mount_added), (gpointer)this);
mDeviceRemove = g_signal_connect(G_OBJECT(mVolumeMonitor), "mount-removed", G_CALLBACK(handle_mount_removed), (gpointer)this);
connect(this, &DriverAction::driverAdded, this, [=] (QString uri, QString name, QString icon) {
if (!mDrivers.contains(uri)) {
QString curUri = uri;
if (curUri.endsWith("/")) {
curUri.chop(1);
}
QString usrName = QStandardPaths::writableLocation(QStandardPaths::HomeLocation).section("/", -1, -1);
if ("file:///data" == curUri
|| "file:///backup" == curUri
|| "file:///boot" == curUri
|| "file:///tmp" == curUri
|| "file:///var" == curUri
|| "file:///media/" + usrName + "/SYSBOOT" == curUri
|| "file:///media/" + usrName + "/sysboot" == curUri
|| "file:///media/" + usrName + "/data" == curUri
|| "file:///media/" + usrName + "/DATA" == curUri
|| curUri.startsWith("burn://")
|| curUri.startsWith("ftp://")
|| curUri.startsWith("smb://")
|| curUri.startsWith("file:///media/" + usrName + "/KYLIN-")
|| curUri.startsWith("file:///media/" + usrName + "/kylin-")
) {
return ;
}
auto it = new DriverItem (uri, QIcon::fromTheme(icon), name);
it->connect(it, &QAction::triggered, it, [=] () {
qDebug() << "======" << __func__ << "uris:" << uris << "it->uri" << it->uri();
FileCopyOperation* op = new FileCopyOperation(uris, it->uri(), nullptr);
op->setAutoDelete(true);
FileOperationManager::getInstance()->startOperation(op);
});
mMenu->addAction(it);
mDrivers[uri] = it;
}
showAction();
});
connect(this, &DriverAction::driverRemove, this, [=] (QString uri) {
if (mDrivers.contains(uri)) {
auto it = mDrivers[uri];
mMenu->removeAction(it);
it->deleteLater();
mDrivers.remove(uri);
}
showAction();
});
GList* mounts = g_volume_monitor_get_mounts (mVolumeMonitor);
if (mounts) {
g_list_foreach (mounts, mounted_func, this);
g_list_free_full(mounts, g_object_unref);
}
setMenu(mMenu);
setText(tr("Send to a removable device"));
showAction();
}
DriverAction::~DriverAction()
{
//if (mMenu) delete mMenu;
if (mVolumeMonitor) {
g_signal_handler_disconnect(G_OBJECT(mVolumeMonitor), mDeviceAdd);
g_signal_handler_disconnect(G_OBJECT(mVolumeMonitor), mDeviceRemove);
g_object_unref(mVolumeMonitor);
}
for (auto it = mDrivers.begin(); it != mDrivers.end(); ++it) {
it.value()->deleteLater();
}
if (!mDrivers.isEmpty()) {
mDrivers.clear();
}
}
void DriverAction::showAction()
{
setVisible(mDrivers.size() > 0 ? true : false);
}
peony-extensions/peony-send-to-device/translations/ 0000775 0001750 0001750 00000000000 15257160277 021522 5 ustar feng feng peony-extensions/peony-send-to-device/translations/peony-send-to-device_tr.ts 0000664 0001750 0001750 00000001151 15257160264 026527 0 ustar feng feng
Peony::DriverAction
Send to a removable device
Peony::SendToPlugin
Send to a removable device
peony-extensions/peony-send-to-device/translations/peony-send-to-device_es.ts 0000664 0001750 0001750 00000001211 15257160264 026506 0 ustar feng feng
Peony::DriverAction
Send to a removable device
Enviar a un dispositivo extraÃble
Peony::SendToPlugin
Send to a removable device
Enviar a un dispositivo extraÃble
peony-extensions/peony-send-to-device/translations/peony-send-to-device_zh_CN.ts 0000664 0001750 0001750 00000001162 15257160264 027105 0 ustar feng feng
Peony::DriverAction
Send to a removable device
��到移动设备
Peony::SendToPlugin
Send to a removable device
��到移动设备
peony-extensions/peony-send-to-device/translations/peony-send-to-device_mn.ts 0000664 0001750 0001750 00000001377 15257160264 026526 0 ustar feng feng
Peony::DriverAction
Send to a removable device
á °á ¢á ¯á µá ¢á ®á ¡á ¯ á ³á ¦á ¬á ¦á ¬á ¡á ·á ¦á ®á µá ¢ á ³á ‹á ¤á Œ á ¢á ¯á ¡á ¬á ¡á ¬á ¦
Peony::SendToPlugin
Send to a removable device
á °á ¢á ¯á µá ¢á ®á ¡á ¯ á ³á ¦á ¬á ¦á ¬á ¡á ·á ¦á ®á µá ¢ á ³á ‹á ¤á Œ á ¢á ¯á ¡á ¬á ¡á ¬á ¦
peony-extensions/peony-send-to-device/translations/peony-send-to-device_kk_KZ.ts 0000664 0001750 0001750 00000001331 15257160264 027113 0 ustar feng feng
Peony::DriverAction
Send to a removable device
شىعارىپ جىبەرۋگە بولاتٸن اسپاپقا جولداۋ
Peony::SendToPlugin
Send to a removable device
شىعارىپ جىبەرۋگە بولاتٸن اسپاپقا جولداۋ
peony-extensions/peony-send-to-device/translations/peony-send-to-device_zh_HK.ts 0000664 0001750 0001750 00000001165 15257160264 027112 0 ustar feng feng
Peony::DriverAction
Send to a removable device
發�到�行動�置
Peony::SendToPlugin
Send to a removable device
發�到�行動�置
peony-extensions/peony-send-to-device/translations/peony-send-to-device_fr.ts 0000664 0001750 0001750 00000001223 15257160264 026511 0 ustar feng feng
Peony::DriverAction
Send to a removable device
Envoyer vers un périphérique amovible
Peony::SendToPlugin
Send to a removable device
Envoyer vers un périphérique amovible
peony-extensions/peony-send-to-device/translations/peony-send-to-device_ky_KG.ts 0000664 0001750 0001750 00000001351 15257160264 027110 0 ustar feng feng
Peony::DriverAction
Send to a removable device
چىعارىپ جىبەرۉۉگۅ بولوتۇرعان اسباپقا جولدوو
Peony::SendToPlugin
Send to a removable device
چىعارىپ جىبەرۉۉگۅ بولوتۇرعان اسباپقا جولدوو
peony-extensions/peony-send-to-device/translations/peony-send-to-device_de.ts 0000664 0001750 0001750 00000001213 15257160264 026471 0 ustar feng feng
Peony::DriverAction
Send to a removable device
An einen Wechseldatenträger senden
Peony::SendToPlugin
Send to a removable device
An einen Wechseldatenträger senden
peony-extensions/peony-send-to-device/translations/peony-send-to-device_bo_CN.ts 0000664 0001750 0001750 00000001360 15257160264 027064 0 ustar feng feng
Peony::DriverAction
Send to a removable device
སྤོ་སྒུལ་སྒྲིག་ཆས་ལ་ས�ྱེལ་བ�
Peony::SendToPlugin
Send to a removable device
སྤོ་སྒུལ་སྒྲིག་ཆས་ལ་ས�ྱེལ་བ�
peony-extensions/peony-send-to-device/translations/peony-send-to-device_cs.ts 0000664 0001750 0001750 00000001151 15257160264 026507 0 ustar feng feng
Peony::DriverAction
Send to a removable device
Peony::SendToPlugin
Send to a removable device
peony-extensions/peony-send-to-device/translations/peony-send-to-device_ug_CN.ts 0000664 0001750 0001750 00000001337 15257160264 027103 0 ustar feng feng
Peony::DriverAction
Send to a removable device
چىقىرىۋ�تىشكە بولىدىغان ئۈسكۈنىگە يوللاش
Peony::SendToPlugin
Send to a removable device
چىقىرىۋ�تىشكە بولىدىغان ئۈسكۈنىگە يوللاش
peony-extensions/peony-send-to-device/peony-send-to-device.pro 0000664 0001750 0001750 00000002366 15257160277 023470 0 ustar feng feng QT += core gui widgets concurrent
include(../common.pri)
TARGET = peony-send-to-device
TEMPLATE = lib
DEFINES += PEONYADMIN_LIBRARY
PKGCONFIG += peony
CONFIG += link_pkgconfig no_keywords c++11 plugin debug
SOURCES += \
send-to-device-plugin.cpp
HEADERS += \
send-to-device-plugin.h
TRANSLATIONS += \
translations/peony-send-to-device_cs.ts \
translations/peony-send-to-device_de.ts \
translations/peony-send-to-device_es.ts \
translations/peony-send-to-device_fr.ts \
translations/peony-send-to-device_kk_KZ.ts \
translations/peony-send-to-device_ug_CN.ts \
translations/peony-send-to-device_ky_KG.ts \
translations/peony-send-to-device_tr.ts \
translations/peony-send-to-device_zh_CN.ts \
translations/peony-send-to-device_bo_CN.ts \
translations/peony-send-to-device_mn.ts \
translations/peony-send-to-device_zh_HK.ts
#RESOURCES += \
# resources.qrc
CONFIG += lrelease embed_translations
QM_FILES_RESOURCE_PREFIX = /translations/
target.path = $$[QT_INSTALL_LIBS]/peony-extensions
INSTALLS += target
SKIP_TEST = $$(EXTENSIONS_SKIP_TEST)
isEmpty(SKIP_TEST) {
message("build with tests")
QMAKE_LFLAGS += -fprofile-arcs -ftest-coverage
QMAKE_CXXFLAGS += --coverage
LIBS += -lgcov
}
peony-extensions/peony-send-to-device/send-to-device-plugin.h 0000664 0001750 0001750 00000005730 15257160277 023261 0 ustar feng feng /*
* Peony-Qt's Library
*
* Copyright (C) 2019, Tianjin KYLIN Information Technology Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Ding Jing
*
*/
#ifndef ADMINMENUPLUGIN_H
#define ADMINMENUPLUGIN_H
#include
#include
#include
#undef signals
namespace Peony {
class DriverItem;
class RemoveableDriver;
class SendToPlugin : public QObject, public MenuPluginInterface
{
Q_OBJECT
Q_PLUGIN_METADATA(IID MenuPluginInterface_iid FILE "common.json")
Q_INTERFACES(Peony::MenuPluginInterface)
public:
explicit SendToPlugin(QObject *parent = nullptr);
QString testPlugin() override {return "";}
bool isEnable() override {return mEnable;}
void setEnable(bool enable) override {mEnable = enable;}
const QString description() override {return tr("Send to a removable device");}
const QString name() override {return "Peony Qt Send to a removable device";}
const QIcon icon() override {return QIcon::fromTheme("document-send-symbolic");}
PluginInterface::PluginType pluginType() override {return PluginInterface::MenuPlugin;}
QList menuActions(Types types, const QString &uri, const QStringList &selectionUris) override;
private:
bool mEnable;
};
class DriverAction : public QAction
{
Q_OBJECT
public:
explicit DriverAction (const QStringList& uris, QObject* parent = nullptr);
~DriverAction ();
Q_SIGNALS:
void driverRemove (QString uri);
void driverAdded (QString uri, QString name, QString icon);
private:
void showAction ();
private:
gulong mDeviceAdd;
gulong mDeviceRemove;
QMenu* mMenu = nullptr;
GVolumeMonitor* mVolumeMonitor = nullptr;
QMap mDrivers;
};
class DriverItem : public QAction
{
friend class RemoveableDriverModel;
Q_OBJECT
public:
explicit DriverItem (QString uri, QIcon icon, QString name, QObject* parent = nullptr);
const QIcon icon ();
const QString uri ();
const QString name ();
private:
bool mConnect;
QString mName;
QIcon mIcon;
QString mUri;
};
}
#endif
peony-extensions/peony-intelligent-data-management-service/ 0000775 0001750 0001750 00000000000 15257160277 023170 5 ustar feng feng ././@LongLink 0000644 0000000 0000000 00000000153 00000000000 011602 L ustar root root peony-extensions/peony-intelligent-data-management-service/peony-intelligent-data-management-service_mn.ts peony-extensions/peony-intelligent-data-management-service/peony-intelligent-data-management-service0000664 0001750 0001750 00000027755 15257160277 033260 0 ustar feng feng
AISearchTask
Failed to create ai search session.
á ¡á ·á ¢á ¬á ¦ á ¬á ¤á ·á á ¯ á ¢ á ¡á á ¦á ³á ¦á ¨ á ªá á ¶á ¢á á ¤á ¯á ¬á ¤ á ¶á ¢á ¨ á á ·á á Žá á ¦á á ¡á ¶ á ƒ
Search task cancelled.
á ¡á ·á ¢á ¬á ¦ á ¡á á ¦á ·á á ¡ á ¨á ¢á á ¡á ¨á ²á ¡ á ¬á ¦á ´á ¦á ¨ á ¦á á ¡á ¢ á ªá £á ¯á µá á ¢ á ƒ
Condition
File name contains "%1"
á ªá ¢á ´á ¢á á ®á á ²á ‹á ¸á ·á ¢á ¶á á ¯ á ¤á ¨ á ¨á ¡á ·á Žá ¡ á ³á ¤  ã‚¢  á ªá á á ²á á ¨á Žá
File name without "%1"
《1》 á ªá ¢á ´á ¢á á ®á á ²á ‹á §á ·á ¢á ¶á á ¯ á ¤á ¨ á ¨á ¡á ·á Žá ¡ á á ªá ´á ¤ á ªá £á ¯á ¬á ¤ á ¦á á ¡á ¶á ƒ
File type contains "%1"
á ªá ¢á ´á ¢á á ®á á ²á ‹á ¸á ·á ¢á ¶á á ¯ á ¤á ¨ á ³á ¦á ·á ¦á ¯ á ¬á ¡á ¯á ªá ¡á ·á ¢ á ³á ¤  ã‚¢  á ªá á á ²á á ¨á Žá
By suffix
á á ·á ¤ á ²á á ¯á Žá á ªá á · á ³á á ·á ¤ á ƒ
Folder
á ªá ¢á ´á ¢á á Œ á ®á á ²á ‹á §á ·á ¢á ¶á á ¯ á ¬á á ªá ¤á ³á á ·
Plain Text
á ´á ¤á ¯ á ³á á ¢á �á ¢á °á ºá ¸á ²
WPS Document
WPS á ªá ¢á ´á ¢á á Œ á ®á á ²á ‹á §á ·á ¢á ¶á á ¯ á ƒ
PDF
PDF á ¬á ¡á ¯á ªá ¡á ·á ¢ á ƒ
Image
á µá ¢á ·á ¤á
Video
á ¸á ¢á ³á ¢á ¤á ‹
Audio
á ³á á á ¤á ¨ á ¤ á ³á á ªá ²á á ®á µá ¢ á ƒ
File type contains %1
á ªá ¢á ´á ¢á á Œ á ®á á ²á ‹á §á ·á ¢á ¶á á ¯ á ¤á ¨ á ²á ¦á ·á ¦á ¯ á ¬á ¡á ¯á ªá ¡á ·á ¢ á ³á ¦ 1 á ªá á á ²á á ¨á Žá á ƒ
All
á ªá ¦á ¬á ¦á ¢á ¯á ¡
Empty(0K)
á ¬á ¤á á ¤á °á ¤á ¨(0K)
Tiny(0-16K)
á µá ¢á µá ¢á á ¬á ¡á ¯á ªá ¡á ·á ¢ (0-16K)
Small(16K-1M)
á µá ¢á µá ¢á á ¨á £á ®á §á · (16K-1M)
Medium(1M-128M)
á ³á ¤á ®á ³á á µá ¡á ·á á ¡(1M-128M)
Big(128M-1G)
á ¶á ¡á ¬á ¡(128M-1G)
Large(1-4G)
á ®á ¤á ¨á ³á á á ¶á ¡á ¬á ¡(1-4G)
Great(>4G)
á ®á á °á ¢ á ¶á ¡á á ¡(>4G)
File size contains %1
á ªá ¢á ´á ¢á á Œ á ®á á ²á ‹á §á ·á ¢á ¶á á ¯ á ¤á ¨ á ¶á ¡á ¬á ¡ á ªá á á Žá á ³á ¤ 1 á ªá á á ²á á ¨á Žá á ƒ
File size without %1
á ªá ¢á ´á ¢á á ®á á ²á ‹á §á ·á ¢á ¶á á ¯ á ¤á ¨ á ¶á ¡á ¬á ¡ á ªá á á Žá (〈 1 á ªá á á ²á á ¬á ¤ á ¦á á ¡á ¢ )
File content match %1
á ªá ¢á ´á ¢á á Œ á ®á á ²á ‹á §á ·á ¢á ¶á á ¯ á ¤á ¨ á á á ¤á ¯á á Žá á ¨á ¢ 1 á ƒ
File location contains "%1"
á ªá ¢á ´á ¢á á ®á á ²á ‹á ¸á ·á ¢á ¶á á ¯ á ¤á ¨ á ªá á ¶á ¢á ·á ¢ á ³á ¤  ã‚¢  á ªá á á ²á á ¨á Žá
File location without "%1"
《1》 á ªá ¢á ´á ¢á á ®á á ²á ‹á §á ·á ¢á ¶á á ¯ á ¤á ¨ á ªá á ¶á ¢á ·á ¢ á ªá á ¶á ¢á ¬á ¤ á ¦á á ¡á ¶á ƒ
Later than "%1"
《1》 á ¡á ´á ¡ á ¬á £á µá ¢á ®á ³á á á °á á ¨ á ¨á ¢ 《1》 á ¡á ´á ¡ á ¬á £á µá ¢á ® á £á ·á £á ¶á ¢á ²á
Earlier than "%1"
《 1 》 á ¡á ´á ¡ á ¡á ·á ²á ¡ 《 1 》 á ¡á ´á ¡ á ¡á ·á ²á ¡ 《 1 》 á ¡á ´á ¡ á ¡á ·
DatabaseManager
New Space %1
á °á ¢á ¨á Žá ¡ á £á ·á £á ¨ á µá á ¶ á ¨á ¢ 1 á ƒ
File %1 has areally been added to %2
á ªá ¢á ´á ¢á á Œ á ®á á ²á ‹á §á ·á ¢á ¶á á ¯ á ¤á ¨ 1 á ¶á ¢ á ¨á ¢á á ¡á ¨á ²á ¡ á µá ¢á ©á ¬á ¢á ¨á ¢ á ªá ¡á · á ¨á ¡á ®á ¡á á ¡á ³ 2 á ªá £á ¯á ²á á ¯á Žá á ¨á ¡á ®á ¡á µá ¡á ¢ á ƒ
File %1 doesn't exsit in any space.
á ªá ¢á ´á ¢á á Œ á ®á á ²á ‹á §á ·á ¢á ¶á á ¯ á ¢ á � 1 á ¶á á ®á á · á ´á ¤ á £á ·á £á ¨ á µá á ¶ á ³á ¤ á á ·á ¢á ¯á ¬á ¤ á ¦á á ¡á ¢ á ƒ
Failed to get space %1's id from query
á á °á á á ¤á ¨ á ¯á á ªá ¯á á ¬á ¤ á ³á ¤á ®á ³á á á ´á á £á ·á £á ¨ á µá á ¶ á ¶á ¢á ¨ 1 á ¶á ¢á ¨ ID á £á ¯á µá ¤ á ³á ¡á ¶á ¢á ¯á ¬á ¦ á ¦á á ¡á ¶ á ƒ
Failed to get %1's id from query
á ªá á ¶á ¢á ´á á á á ¨ á ¯á á ªá ¯á á ¬á ¤ á ³á ¤á ®á ³á á á ´á 1 á ¶á ¢á ¨ ID á £á ¯á µá ¤ á ³á ¡á ¶á ¢á ¯á ¬á ¦ á ¦á á ¡á ¶ á ƒ
ModelController
Failed to rename space %1 to %2, %2 is existed.
á £á ·á £á ¨ á µá á ¶ á ¶á ¢á ¨ ã‚¢ á ¶á ¢ ã‚¢ á ¬á ¦á ¨á ³á ¦ á ¶á ¢ イ á á ¡á µá ¦ á ¨á ¡á ·á ¡á ¯á ¡á µá ¦ á ‚ á £á ·á £á °á ¢á µá ¤ イ á £á ·á £á °á ¢á µá ¤ á ªá á ¶á ¢á ¨á Žá á ƒ
Failed to remove space %1, error message: %2
á £á ·á £á ¨ á µá á ¶ á ¨á ¢ ã‚¢ á ¶á ¢ á ¬á á °á ¤á µá ¤ á ³á ¡á ¶á ¢á ¯á ¬á ¦ á ¦á á ¡á ¶ á ‚ á ªá ¤á ·á ¤á á ¤ á ®á ¡á ³á ¡á á ¡ á „ イ á ƒ
New Space %1
á °á ¢á ¨á Žá ¡ á £á ·á £á ¨ á µá á ¶ á ¨á ¢ 1 á ƒ
Failed to updatestatus space %1, error message: %2
á ªá á ¶á ¢á ³á á ¯ á ¤á ¨ á £á ·á £á ¨ á µá á ¶ á ¶á ¢ á °á ¢á ¨á ¡á ³á ¬á ¡á ¬á ¦ á ¶á ¢á ¨ á á ·á á Žá á ¦á á ¡á ¶ á ‚ á ªá ¤á ·á ¤á á ¤ á ®á ¡á ³á ¡á á ¡ á „ 2 á ƒ
QObject
%1 %2
%1 %2
Intelligent Data Manager Introduction
á ¤á ¶á ¤á ¨á ²á ¤ á ²á £á á Žá á ªá á ·á ¢á ®á ²á á ¶á ¢á ¨ á ¬á á ®á ¢á ¶á á ·á ¤á ¯á ²á á ¶á ¢á ¨ á ªá á á á µá ¢ á ¶á ¢á ¨ á ²á á ¨á ¢á ¯á ´á á á ¤á ¯á á Žá á ƒ
peony-intelligent-data-management-service
á ®á ¦ á ³á ‹á á ¨ á ¤ á ¤á ¶á ¤á ¨á ²á ¤ á ²á £á á Žá á ªá á ·á ¢á ®á ²á á ¶á ¢á ¨ á ¬á á ®á ¢á ¶á á ·á ¤á ¯á ²á á ¶á ¢á ¨ á ¦á ¢á ¯á ¡á ´á ¢á ¯á ¡á á ¡ á ƒ
exit
á ²á ¦á · á ³á á ¬á ¢á ¨ á ¡á ¬á ¢á ¯á ¡á á ¦á ¯á ¬á ¦ á ¦á á ¡á ¢
UKUI::IDM::FileInfoJob
Create Date: %1
á ¡á á ¦á ³á ¦á ¨ á ªá á ¶á ¢á á ¤á ¯á ¬á ¤ á ¡á ³á ¦á · á ¬á ¤á á ¤á ´á á á Žá á „ 1 á ƒ
Open Date: %1
á ´á ¢á ¯á ¥á á ¡á ²á ¡á ¶ á ²á á ¯á ªá ¢á ¬á ¤ á ¡á ³á ¦á · á ¬á ¤á á ¤á ´á á á Žá á „ 1 á ƒ
peony-extensions/peony-intelligent-data-management-service/main.cpp 0000664 0001750 0001750 00000006066 15257160264 024624 0 ustar feng feng /*
* Peony Intelligent Spaces Service
*
* Copyright (C) 2025, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: He JinQin
*
*/
#include
#include
#include
#include
#include "model/modelcontroller.h"
#include
#include
#include
#include "model/searchresultmodel.h"
#include "3rd-parties/qtsinglecoreapplication.h"
#include
#include
#ifdef KY_SDK_KABASE
#include
#endif
int main(int argc, char *argv[])
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
#endif
#ifdef KY_SDK_KABASE
qInstallMessageHandler(kdk::kabase::Log::logOutput);
#else
initUkuiLog4qt("peony-intelligent-data-management-service");
#endif
QCoreApplication::setApplicationName("peony-intelligent-data-management-service");
QtSingleCoreApplication app("peony-intelligent-data-management-service", argc, argv);
if (app.isRunning()) {
QString message = app.arguments().join(' ');
qDebug() << "send message" << message;
if (app.sendMessage(message)) {
return 0;
} else {
qWarning() << "failed to send massage to running program";
}
}
QTranslator idm;
if (idm.load("/usr/share/peony-intelligent-data-management-service/peony-intelligent-data-management-service_"+QLocale::system().name()))
app.installTranslator(&idm);
QCommandLineParser parser;
parser.addHelpOption();
QCommandLineOption quitOption(QStringList() << "q" << "quit", QObject::tr("exit"));
parser.addOption(quitOption);
parser.process(app);
if (parser.isSet(quitOption)) {
app.quit();
return 0;
}
auto mc = ModelController::globalInstance();
mc->setParent(&app);
QObject::connect(&app, &QtSingleCoreApplication::messageReceived, &app, [&](const QString & message) {
QStringList arguments = message.split(" ");
qDebug() << "message recived" << message << "arguments" << arguments;
parser.process(arguments);
if (parser.isSet(quitOption)) {
app.quit();
}});
return app.exec();
}
././@LongLink 0000644 0000000 0000000 00000000153 00000000000 011602 L ustar root root peony-extensions/peony-intelligent-data-management-service/peony-intelligent-data-management-service_kk.ts peony-extensions/peony-intelligent-data-management-service/peony-intelligent-data-management-service0000664 0001750 0001750 00000023710 15257160264 033237 0 ustar feng feng
AISearchTask
Failed to create ai search session.
ai ٸزدەۋ جوبالاۋدى قۇرۋ جەÚىلىس قالدى.
Search task cancelled.
ٸزدەۋ مىندەتى كۇشىنەن قالدىرىلدى.
Condition
File name contains "%1"
ØÛ‡Ø¬Ø§Øª مى «٪1» نى ٶز ىشىنە الادٸ
File name without "%1"
«٪1» بولماعان ØÛ‡Ø¬Ø§Øª مى
File type contains "%1"
ØÛ‡Ø¬Ø§Øª تيپى «٪1» نى ٶز ىشىنە الادٸ
By suffix
قوسىمشاسى
Folder
ØÛ‡Ø¬Ø§Øª قىسقىش
Plain Text
تۇنىق تەكىسىت
WPS Document
WPS ØÛ‡Ø¬Ø§ØªÙ‰
PDF
Image
راسىم
Video
سىن
Audio
Û‡Ù†
File type contains %1
ØÛ‡Ø¬Ø§Øª تيپى Ùª1 نى ٶز ىشىنە الادٸ
All
جالپىسى
Empty(0K)
قۇرعاق(0K)
Tiny(0-16K)
كىشكەنەسىنە (0-16K)
Small(16K-1M)
كشكەنە (16K-1M)
Medium(1M-128M)
ورتاشا (1M-128M)
Big(128M-1G)
ۇلكەن(128M-1G)
Large(1-4G)
ۇلكەن(1-4G)
Great(>4G)
كەرەمەت(>4G)
File size contains %1
ØÛ‡Ø¬Ø§Øª ۇلكەندىگى Ùª1 نى ٶز ىشىنە الادٸ
File size without %1
ØÛ‡Ø¬Ø§Øª ۇلكەندىگى Ùª1 جوق
File content match %1
ØÛ‡Ø¬Ø§Øª مازمۇنى Ùª1 بۇرشاق كەلەدى
File location contains "%1"
ØÛ‡Ø¬Ø§Øª ورنى «٪1» نى ٶز ىشىنە الادٸ
File location without "%1"
ØÛ‡Ø¬Ø§Øª ورنى «٪1» جوق
Later than "%1"
«٪1» دان كەيىن
Earlier than "%1"
«٪1» دان بۇرٸنعٸ
DatabaseManager
New Space %1
Ø¬Ø§ÚØ§ بوستٸق Ùª1
File %1 has areally been added to %2
ØÛ‡Ø¬Ø§Øª Ùª1 راسىندا Ùª2 Ú¯Û• قوسىلدى
File %1 doesn't exsit in any space.
ØÛ‡Ø¬Ø§Øª Ùª1 ەشقانداي بوستققا شىقپايدى.
Failed to get space %1's id from query
سۈرۈشتۈرۈشتىن بوستٸق Ùª1 Ù†Ù‰Ú ID عا ÙŠÛ• بولعالٸ بولمادى
Failed to get %1's id from query
سۈرۈشتۈرۈشتىن Ùª1 Ù†Ù‰Ú Ø§Ø²Ø§Ù…Ø§ØªØªÙ‰Ù‚ كۋالىك الۋ جەÚىلىپ قالدى
ModelController
Failed to rename space %1 to %2, %2 is existed.
Ø¨ÙˆØ³ØªÙ‚ØªÙ¸Ú Ø§ØªØ§Ø¹Ù‰Ù† Ùª1 Ú¯Û• Ùª2 ورىنداپ وزگەرتۋ جەÚىلىس قالدى، Ùª2 ساقتالعان.
Failed to remove space %1, error message: %2
Ùª1 بوستقتٸ شىعارىپ وتۋ جەÚىلىس قالدى، قاتەلىك ØØ§Ø¨Ø§Ø±Ù‰: Ùª2
New Space %1
Ø¬Ø§ÚØ§ بوستٸق Ùª1
Failed to updatestatus space %1, error message: %2
Ùª1 بەينە بوستٸقتٸ Ø¬Ø§ÚØ§Ù„اۋ جەÚىلىس قالدى، قاتەلىك ØØ§Ø¨Ø§Ø±Ù‰: Ùª2
QObject
%1 %2
Intelligent Data Manager Introduction
وي قابٸلەتتٸ ساندىق مالىمەت Ø¨Ø§Ø³Ù‚Ø§Ø±Û‹Ø´Ù†Ù‰Ú ØªÙˆÙ†Û‡Ø´ØªÛ‡Ø±Û‡Ø´Ù‰
peony-intelligent-data-management-service
پيون وي قابٸلەتتٸ ساندىق مالىمەت باسقارۋ قىزىمەت وتەۋى
exit
شەگىنۋ
UKUI::IDM::FileInfoJob
Create Date: %1
چيسىلا قۇرۋ: ٪1
Open Date: %1
اشىلعان ۋاقىتى: ٪1
././@LongLink 0000644 0000000 0000000 00000000153 00000000000 011602 L ustar root root peony-extensions/peony-intelligent-data-management-service/peony-intelligent-data-management-service_ug.ts peony-extensions/peony-intelligent-data-management-service/peony-intelligent-data-management-service0000664 0001750 0001750 00000023766 15257160264 033252 0 ustar feng feng
AISearchTask
Failed to create ai search session.
ai ئىزدەش مەشغۇلاتىنى قۇرۇش مەغلۇب بولدى.
Search task cancelled.
ئىزدەش ۋەزىپىسى ئەمەلدىن قالدۇرۇلدى.
Condition
File name contains "%1"
ھۆججەت نامى «٪1» نى ئۆز ئىچىگە ئالىدۇ
File name without "%1"
«٪1» بولمىغان ھۆججەت نامى
File type contains "%1"
ھۆججەت تىپى «٪1» نى ئۆز ئىچىگە ئالىدۇ
By suffix
قوشۇمچىسى
Folder
ھۆججەت قىسقۇچ
Plain Text
ساپ ت�كىست
WPS Document
WPS ھۆججىتى
PDF
PDF
Image
رەسىم
Video
سىن
Audio
ئۈن
File type contains %1
ھۆججەت تىپى ٪1 نى ئۆز ئىچىگە ئالىدۇ
All
بارلىق
Empty(0K)
قۇرۇق(0K)
Tiny(0-16K)
كىچىككىنە (0-16K)
Small(16K-1M)
كىچىك (16K-1M)
Medium(1M-128M)
ئوتتۇراھال (1M-128M)
Big(128M-1G)
Ú†ÙˆÚ(128M-1G)
Large(1-4G)
Ú†ÙˆÚ(1-4G)
Great(>4G)
قالتىس(>4G)
File size contains %1
ھۆججەت Ú†ÙˆÚلۇقى Ùª1 نى ئۆز ئىچىگە ئالىدۇ
File size without %1
ھۆججەت Ú†ÙˆÚلۇقى Ùª1 يوق
File content match %1
ھۆججەت مەزمۇنى ٪1 ماس ك�لىدۇ
File location contains "%1"
ھۆججەت ئورنى «٪1» نى ئۆز ئىچىگە ئالىدۇ
File location without "%1"
ھۆججەت ئورنى «٪1» يوق
Later than "%1"
«٪1» دىن ك�يىن
Earlier than "%1"
«٪1» دىن بۇرۇنقى
DatabaseManager
New Space %1
ÙŠÛ�ÚÙ‰ بوشلۇق Ùª1
File %1 has areally been added to %2
ھۆججەت ٪1 ھەقىقەتەن ٪2 گە قوشۇلدى
File %1 doesn't exsit in any space.
ھۆججەت ٪1 ھىچقانداق بوشلۇقتا چىقمايدۇ.
Failed to get space %1's id from query
سۈرۈشتۈرۈشتىن بوشلۇق Ùª1 Ù†Ù‰Ú ID غا ئÛ�رىشكىلى بولمىدى
Failed to get %1's id from query
سۈرۈشتۈرۈشتىن Ùª1 Ù†Ù‰Ú ÙƒÙ‰Ù…Ù„Ù‰ÙƒÙ‰Ù†Ù‰ ئÛ�لىش مەغلۇپ بولدى
ModelController
Failed to rename space %1 to %2, %2 is existed.
Ø¨ÙˆØ´Ù„Û‡Ù‚Ù†Ù‰Ú Ù†Ø§Ù…Ù‰Ù†Ù‰ Ùª1 Ú¯Û• Ùª2 قىلىپ ئۆزگەرتىش مەغلۇب بولدى، Ùª2 مەۋجۇت.
Failed to remove space %1, error message: %2
٪1 بوشلۇقنى چىقىرىۋ�تىش مەغلۇب بولدى، خاتالىق ئۇچۇرى: ٪2
New Space %1
ÙŠÛ�ÚÙ‰ بوشلۇق Ùª1
Failed to updatestatus space %1, error message: %2
Ùª1 ھالەت بوشلۇقىنى ÙŠÛ�Úىلاش مەغلۇب بولدى، خاتالىق ئۇچۇرى: Ùª2
QObject
%1 %2
%1 %2
Intelligent Data Manager Introduction
ئەقلىي ئىقتىدارلىق سانلىق مەلۇمات Ø¨Ø§Ø´Ù‚Û‡Ø±ØºÛ‡Ú†Ù†Ù‰Ú ØªÙˆÙ†Û‡Ø´ØªÛ‡Ø±Û‡Ø´Ù‰
peony-intelligent-data-management-service
مودەنگۈل ئەقلىي ئىقتىدارلىق سانلىق مەلۇمات باشقۇرۇش مۇلازىمىتى
exit
چ�كىنىش
UKUI::IDM::FileInfoJob
Create Date: %1
چ�سلا قۇرۇش: ٪1
Open Date: %1
ئ�چىلغان ۋاقتى: ٪1
././@LongLink 0000644 0000000 0000000 00000000156 00000000000 011605 L ustar root root peony-extensions/peony-intelligent-data-management-service/peony-intelligent-data-management-service_bo_CN.ts peony-extensions/peony-intelligent-data-management-service/peony-intelligent-data-management-service0000664 0001750 0001750 00000027163 15257160277 033251 0 ustar feng feng
AISearchTask
Failed to create ai search session.
འཚོལ་ཞིབ་ཚོགས་འདུ་གསར་འཛུགས་བྱེད་�བས་མེད�
Search task cancelled.
འཚོལ་ཞིབ་ཀྱི་ལས་འགན་མེད་པར་བཟོས་ཟིན�
Condition
File name contains "%1"
ཡིག་ཆའི་མིང་ལ་"1%"འདུས་ཡོད�
File name without "%1"
"1%"ཡི་ཡིག་ཆའི་མིང་འ�ྱེར་མི་དགོས�
File type contains "%1"
ཡིག་ཆའི་རིགས་ལ་"བརྒྱ་ཆ་1"འདུས་ཡོད�
By suffix
རྗེས་སུ་缀དགོས�
Folder
ཡིག་སྣོད་
Plain Text
ཡིག་དེབ་དངོས་
WPS Document
WPSགྱི་ཡིག་ཚགས�
PDF
PDFཡི་རྣམ་གཞག
Image
བརྙན་རིས
Video
བརྙན་ཕབ�
Audio
སྒྲ་ཕབ�
File type contains %1
ཡིག་ཆའི་རིགས་སུ་བརྒྱ་ཆ་1ཚད་ཡོད�
All
ཚང་མ�
Empty(0K)
སྟོང་�(0K)
Tiny(0-16K)
ཆུང་གྲས� (0-16K)
Small(16K-1M)
ཨང་གྲངས་ཆུང་བ� (16K-1M)�
Medium(1M-128M)
འབྲིང་རིམ་(1M—128M)
Big(128M-1G)
ཆེ�(128M—1G)
Large(1-4G)
ཤིན་�ུ་ཆེ་བ�(1-4G)
Great(>4G)
ཆེ�4G
File size contains %1
ཡིག་ཆའི་ཆེ་ཆུང་ནང་བརྒྱ་ཆ་1ཚད་ཡོད�
File size without %1
ཡིག་ཆའི་ཆེ་ཆུང་(བརྒྱ་ཆ་1མི་འདུས� )
File content match %1
ཡིག་ཆའི་ནང་དོན་ཆ་མ�ུན་ཡིན་པ�
File location contains "%1"
ཡིག་ཆའི་གོ་གནས་སུ་"1%ཚུད་ཡོད�
File location without "%1"
"1"ཡི་ཡིག་ཆའི་གོ་གནས་མེད�
Later than "%1"
"བརྒྱ་ཆ་1"ལས་འཕྱི་བ་རེད�
Earlier than "%1"
"བརྒྱ་ཆ་1"ལས་སྔ་བ་ཡོད�
DatabaseManager
New Space %1
བར་སྟོང་གསར་པ� བརྒྱ་ཆ་1ཡོད�
File %1 has areally been added to %2
ཡིག་ཆའི་1%བརྒྱ་ཆ་2ལ་དངོས་འབྲེལ་�་སྣོན་བྱས་ཡོད�
File %1 doesn't exsit in any space.
ཡིག་ཆའི་བརྒྱ་ཆ་1ནི་བར་སྣང་གང་རུང་དུ་མེད་པར་འགྱུར་མི་སྲིད�
Failed to get space %1's id from query
འདྲི་རྩད་�ྲོད་ནས་བར་སྟོང་བརྒྱ་ཆ་1ཟིན་པའི་ID�ོབ་�བས་མེད�
Failed to get %1's id from query
འདྲི་རྩད་�ྲོད་ནས་1%ཡི་ID�ོབ་�བས་མེད�
ModelController
Failed to rename space %1 to %2, %2 is existed.
བར་སྟོང་བརྒྱ་ཆ་1གི་མིང་ལ་མིང་བ�གས་ནས་བརྒྱ་ཆ་2ཡོད་པ་དང་བརྒྱ་ཆ་2ཡོད་མི་�ུབ�
Failed to remove space %1, error message: %2
བར་སྟོང་གི་བརྒྱ་ཆ་1མེད་པར་བཟོས་པ་དང་� ནོར་འ�ྲུལ་གྱི་གནས་ཚུལ� བརྒྱ་ཆ་2ཡིན�
New Space %1
བར་སྟོང་གསར་པ� བརྒྱ་ཆ་1ཡོད�
Failed to updatestatus space %1, error message: %2
རྣམ་པ་གསར་སྒྱུར་བྱེད་�བས་བྲལ་བའི་བར་སྟོང་བརྒྱ་ཆ་1དང་� ནོར་འ�ྲུལ་གྱི་གནས་ཚུལ� 2%བཅས་ཡིན�
QObject
%1 %2
%1 %2
Intelligent Data Manager Introduction
རིག་ནུས་གཞི་གྲངས་དོ་དམ་ཡོ་བྱད་ངོ་སྤྲོད་བྱས་པ་རེད
peony-intelligent-data-management-service
牡་�ན་རིག་ནུས་ཀྱི་གཞི་གྲངས་དོ་དམ་ཞབས་ཞུ་བྱེད་དགོས�
exit
འབུད་པ�
UKUI::IDM::FileInfoJob
Create Date: %1
གསར་འཛུགས་བྱས་པའི་ཚེས་གྲངས�བརྒྱ་ཆ་1ཡིན�
Open Date: %1
སྒོ་འབྱེད་པའི་དུས་ཚོད� བརྒྱ་ཆ་1ཡིན�
peony-extensions/peony-intelligent-data-management-service/conf/ 0000775 0001750 0001750 00000000000 15257160264 024111 5 ustar feng feng peony-extensions/peony-intelligent-data-management-service/conf/com.peony.idm.service 0000664 0001750 0001750 00000000244 15257160264 030152 0 ustar feng feng [D-BUS Service]
Name=com.peony.idm.service
Exec=/usr/bin/peony-intelligent-data-management-service
SystemdService=peony-intelligent-data-management-service.service
././@LongLink 0000644 0000000 0000000 00000000162 00000000000 011602 L ustar root root peony-extensions/peony-intelligent-data-management-service/conf/peony-intelligent-data-management-service.service peony-extensions/peony-intelligent-data-management-service/conf/peony-intelligent-data-management-se0000664 0001750 0001750 00000000500 15257160264 033123 0 ustar feng feng [Unit]
Description=Peony Intelligent Space Management Service
PartOf=xdg-desktop-autostart.target
After=xdg-desktop-autostart.target
[Service]
ExecStart=/usr/bin/peony-intelligent-data-management-service
Restart=on-failure
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=xdg-desktop-autostart.target
peony-extensions/peony-intelligent-data-management-service/file/ 0000775 0001750 0001750 00000000000 15257160277 024107 5 ustar feng feng peony-extensions/peony-intelligent-data-management-service/file/qtremoteobject/ 0000775 0001750 0001750 00000000000 15257160264 027132 5 ustar feng feng ././@LongLink 0000644 0000000 0000000 00000000150 00000000000 011577 L ustar root root peony-extensions/peony-intelligent-data-management-service/file/qtremoteobject/fileeventhandlerimpl.cpp peony-extensions/peony-intelligent-data-management-service/file/qtremoteobject/fileeventhandlerimpl.0000664 0001750 0001750 00000002202 15257160264 033330 0 ustar feng feng /*
* UKUI Intelligent Data Manager
*
* Copyright (C) 2024, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: Yue Lan
*
*/
#include "fileeventhandlerimpl.h"
#include
FileEventHandlerImpl::FileEventHandlerImpl(QObject *parent) : FileEventHandlerSource(parent)
{
}
void FileEventHandlerImpl::handleFileEvent(int eventType, QString arg1, QString arg2)
{
qDebug() << "server handle file event" << eventType << arg1 << arg2;
Q_EMIT reciveClientFileEvent(eventType,arg1,arg2);
}
././@LongLink 0000644 0000000 0000000 00000000146 00000000000 011604 L ustar root root peony-extensions/peony-intelligent-data-management-service/file/qtremoteobject/fileeventhandlerimpl.h peony-extensions/peony-intelligent-data-management-service/file/qtremoteobject/fileeventhandlerimpl.0000664 0001750 0001750 00000002403 15257160264 033333 0 ustar feng feng /*
* UKUI Intelligent Data Manager
*
* Copyright (C) 2024, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: Yue Lan
*
*/
#ifndef FILEEVENTHANDLERIMPL_H
#define FILEEVENTHANDLERIMPL_H
#include
#include "rep_fileeventhandler_source.h"
class FileEventHandlerImpl : public FileEventHandlerSource
{
Q_OBJECT
public:
explicit FileEventHandlerImpl(QObject *parent = nullptr);
Q_SIGNALS:
void reciveClientFileEvent(int eventType, const QString &arg1, const QString &arg2);
public Q_SLOTS:
virtual void handleFileEvent(int eventType, QString arg1, QString arg2);
};
#endif // FILEEVENTHANDLERIMPL_H
peony-extensions/peony-intelligent-data-management-service/file/fileinfojob.h 0000664 0001750 0001750 00000006343 15257160264 026550 0 ustar feng feng /*
* UKUI Intelligent Data Manager
*
* Copyright (C) 2024, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: Yue Lan
*
*/
#ifndef FILEINFOJOB_H
#define FILEINFOJOB_H
#include
#include
#include "file/fileinfo.h"
#include
class Condition;
class QFileInfo;
typedef struct _GFile GFile; /* Dummy typedef */
typedef struct _GFileInfo GFileInfo;
namespace UKUI {
namespace IDM {
class FileInfo;
class FileInfoJobPrivate;
class FileInfoJob : public QObject, public QRunnable
{
Q_OBJECT
public:
static FileInfoJob *fromUris(const QStringList &uris, bool addWatchByDefault = true);
static FileInfoJob *fromPaths(const QStringList &paths, bool addWatchByDefault = true);
static FileInfoJob *fromInfos(const QList> &infos, bool addWatchByDefault = true);
static bool infoMatchCondtions(const QFileInfo &fileinfo, const QList > &andConditions, const QList > &orConditions);
static bool queryInfoSyncWithConditions(QSharedPointer &info, const QList> &andConditions, const QList> &orConditions);
~FileInfoJob();
void start();
void cancel();
/*!
* \brief setConditions
* 设置�索过滤�件
* \param conditions
*/
void setConditions(const QList> &conditions);
void setSpaceId(int spaceId);
void setLabels(const QStringList &labels);
void setHandleContentCondition(bool handleContentCondition);
void run() override;
QList> getInfos();
void updateFileInfoDataformat(QSharedPointer &info);
Q_SIGNALS:
void started();
void finished();
void cancelled();
void errored(const QString &errorMessage);
void infoUpdated(const QSharedPointer &info);
public Q_SLOTS:
void handleCancelWithSpaceId(int spaceId);
private:
static void updateInfoWithGFileInfo(QSharedPointer &info, GFile *gfile, GFileInfo *gfileinfo);
static bool infoMatchCondtions(QSharedPointer &info, const QList > &andConditions, const QList > &orConditions, bool handleContentCondition);
bool infoMatchLabels(QSharedPointer &info, const QStringList &labels);
explicit FileInfoJob(const QStringList &args, bool isUriFormat, bool addWatchByDefault = true, QObject *parent = nullptr);
FileInfoJob();
FileInfoJobPrivate *priv;
};
#endif // FILEINFOJOB_H
}
}
peony-extensions/peony-intelligent-data-management-service/file/fileinfomanager.h 0000664 0001750 0001750 00000004310 15257160264 027400 0 ustar feng feng /*
* UKUI Intelligent Data Manager
*
* Copyright (C) 2024, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: Yue Lan
*
*/
#ifndef FILEINFOMANAGER_H
#define FILEINFOMANAGER_H
#include
#include
namespace UKUI {
namespace IDM {
class FileInfoManagerPrivate;
class FileInfoManager : public QObject
{
Q_OBJECT
public:
enum FileEventType {
Unknown,
FileCreated,
FileModified,
FileDeleted,
FileMoveOut,
FileMoveIn,
FileMoved,
FileAccessed,
FileOpened,
FileClosed,
FileAttrChanged,
FileIgnoredAutomatic,
FileUnmount,
UserAddFile,
UserRemoveFile,
Other
};
Q_ENUM(FileEventType)
static FileInfoManager *globalInstance();
void addFileToWatcher(const QString &url, bool *ok = nullptr);
QStringList addFilesToWatcher(const QStringList &urls);
void removeFileFromWatcher(const QString &url, bool *ok = nullptr);
QStringList removeFilesFromWatcher(const QStringList &urls);
Q_SIGNALS:
void fileChanged(FileEventType type, const QString &arg1, const QString arg2);
void remoteFileEvent(int eventType, const QString &arg1, const QString arg2);
private:
FileInfoManagerPrivate *priv;
explicit FileInfoManager(QObject *parent = nullptr);
~FileInfoManager();
friend class FileInfo;
QSharedPointer getInfoByUri(const QString &uri);
void insertInfo(QSharedPointer info);
void removeInfoPtrByUri(const QString &uri);
};
}
}
#endif // FILEINFOMANAGER_H
peony-extensions/peony-intelligent-data-management-service/file/fileinfo.cpp 0000664 0001750 0001750 00000011617 15257160264 026410 0 ustar feng feng /*
* UKUI Intelligent Data Manager
*
* Copyright (C) 2024, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: Yue Lan
*
*/
#include "fileinfo.h"
#include "fileinfo_p.h"
#include "fileinfomanager.h"
#include
#include
#include
#include
using namespace UKUI::IDM;
QSharedPointer FileInfo::fromPath(const QString &filePath, bool addWatch)
{
QUrl url = QUrl::fromLocalFile(filePath);
return fromUri(url.toEncoded(), addWatch);
}
QSharedPointer FileInfo::fromUri(const QString &uri, bool addWatch)
{
QSharedPointer info = FileInfoManager::globalInstance()->getInfoByUri(uri);
if (info.isNull()) {
info = QSharedPointer(new FileInfo);
info->priv->uri = uri;
FileInfoManager::globalInstance()->insertInfo(info);
if (addWatch)
FileInfoManager::globalInstance()->addFileToWatcher(uri);
}
return info;
}
QSharedPointer FileInfo::fromUrl(const QUrl &url, bool addWatch)
{
return fromUri(url.toEncoded(), addWatch);
}
bool FileInfo::isValid() const
{
QMutexLocker(&priv->mutex);
bool isValid = priv->state == FileInfoPrivate::State::Valid;
return isValid;
}
QString FileInfo::uri() const
{
QMutexLocker(&priv->mutex);
QString uri = priv->uri;
return uri;
}
QString FileInfo::path() const
{
QMutexLocker(&priv->mutex);
QString path = priv->path;
return path;
}
QString FileInfo::parentPath() const
{
QMutexLocker(&priv->mutex);
QString path = priv->parentPath;
return path;
}
QString FileInfo::displayName() const
{
QMutexLocker(&priv->mutex);
QString name = priv->name;
return name;
}
QString FileInfo::iconName() const
{
QMutexLocker(&priv->mutex);
QString iconName = priv->iconName;
return iconName;
}
QString FileInfo::createDateString() const
{
QMutexLocker(&priv->mutex);
QString string = priv->createDateString;
return string;
}
QString FileInfo::modifyDateString() const
{
QMutexLocker(&priv->mutex);
QString string = priv->modifyDateString;
return string;
}
QString FileInfo::openDateString() const
{
QMutexLocker(&priv->mutex);
QString string = priv->openDateString;
return string;
}
QString FileInfo::dateString() const
{
QMutexLocker(&priv->mutex);
QString string = priv->dateString;
return string;
}
QString FileInfo::version() const
{
QMutexLocker(&priv->mutex);
QString version = priv->version;
return version;
}
QString FileInfo::mimeType() const
{
QMutexLocker(&priv->mutex);
QString mimeType = priv->mimeType;
return mimeType;
}
QString FileInfo::fileType() const
{
QMutexLocker(&priv->mutex);
QString fileType = priv->fileType;
return fileType;
}
quint64 FileInfo::timeModifiedMsec() const
{
QMutexLocker(&priv->mutex);
quint64 timeModifiedMsec = priv->timeModifiedMsec;
return timeModifiedMsec;
}
quint64 FileInfo::timeAccessMsec() const
{
QMutexLocker(&priv->mutex);
quint64 timeAccessMsec = priv->timeAccessMsec;
return timeAccessMsec;
}
qint64 FileInfo::timeRecentModified() const
{
QMutexLocker(&priv->mutex);
qint64 timeRecentModified = priv->timeRecentModified;
return timeRecentModified;
}
quint64 FileInfo::size() const
{
QMutexLocker(&priv->mutex);
quint64 size = priv->size;
return size;
}
QString FileInfo::sizeFormat() const
{
QMutexLocker(&priv->mutex);
QString sizeFormat = priv->sizeFormat;
return sizeFormat;
}
quint64 FileInfo::openCount() const
{
QMutexLocker(&priv->mutex);
quint64 count = priv->openCount;
return count;
}
QList FileInfo::labelColors() const
{
QList colors;
QMutexLocker(&priv->mutex);
colors = priv->labelColors;
return colors;
}
void FileInfo::setChecked(bool flag)
{
QMutexLocker(&priv->mutex);
priv->ischecked = flag;
}
bool FileInfo::isChecked() const
{
QMutexLocker(&priv->mutex);
bool ischecked = priv->ischecked;
return ischecked;
}
FileInfo::FileInfo()
{
priv = new FileInfoPrivate;
}
FileInfo::~FileInfo()
{
// TODO: 批é‡�å¼‚æ¥æ›´æ–°æ•°æ�®åº“
FileInfoManager::globalInstance()->removeFileFromWatcher(this->path());
FileInfoManager::globalInstance()->removeInfoPtrByUri(priv->uri);
delete priv;
}
peony-extensions/peony-intelligent-data-management-service/file/fileinfo.h 0000664 0001750 0001750 00000004110 15257160264 026043 0 ustar feng feng /*
* UKUI Intelligent Data Manager
*
* Copyright (C) 2024, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: Yue Lan
*
*/
#ifndef FILEINFO_H
#define FILEINFO_H
#include
#include
namespace UKUI {
namespace IDM {
class FileInfoPrivate;
class FileInfo
{
friend class FileInfoJob;
public:
static QSharedPointer fromPath(const QString &filePath, bool addWatch = false);
static QSharedPointer fromUri(const QString &uri, bool addWatch = false);
static QSharedPointer fromUrl(const QUrl &url, bool addWatch = false);
bool isValid() const;
QString uri() const;
QString path() const;
QString parentPath() const;
QString displayName() const;
QString iconName() const;
QString createDateString() const;
QString modifyDateString() const;
QString openDateString() const;
QString dateString() const;
QString version() const;
QString mimeType() const;
QString fileType() const;
quint64 timeModifiedMsec() const;
quint64 timeAccessMsec() const;
qint64 timeRecentModified() const;
quint64 size() const;
QString sizeFormat() const;
quint64 openCount() const;
QList labelColors() const;
void setChecked(bool flag);
bool isChecked() const;
~FileInfo();
private:
FileInfo();
QSharedPointer getInfoByUri(const QString &uri);
FileInfoPrivate *priv;
};
}
}
#endif // FILEINFO_H
peony-extensions/peony-intelligent-data-management-service/file/fileinfomanager.cpp 0000664 0001750 0001750 00000016637 15257160264 027752 0 ustar feng feng /*
* UKUI Intelligent Data Manager
*
* Copyright (C) 2024, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: Yue Lan
*
*/
#include "fileinfomanager.h"
#include "file/qtremoteobject/fileeventhandlerimpl.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
namespace UKUI {
namespace IDM {
class FileInfoManagerPrivate
{
public:
FileInfoManagerPrivate();
~FileInfoManagerPrivate();
QHash> hash;
KYSDK_FILEWATCHER::FileWatcher *watcher;
QThread *watcherThread;
QEventLoop *watcherLoop;
QRemoteObjectHost *host;
FileEventHandlerImpl *impl;
QMutex mutex;
QMutex watcherMutex;
};
FileInfoManagerPrivate::FileInfoManagerPrivate()
{
watcher = new KYSDK_FILEWATCHER::FileWatcher;
watcherThread = new QThread;
watcherLoop = new QEventLoop;
host = new QRemoteObjectHost;
impl = new FileEventHandlerImpl;
}
FileInfoManagerPrivate::~FileInfoManagerPrivate()
{
watcherThread->quit();
watcherThread->wait();
host->disableRemoting(impl);
watcherLoop->quit();
watcher->clearWatchList();
watcher->disconnect();
delete watcher;
delete watcherLoop;
delete watcherThread;
delete impl;
delete host;
}
}
}
using namespace UKUI::IDM;
static FileInfoManager *instance = nullptr;
FileInfoManager *FileInfoManager::globalInstance()
{
if (!instance) {
instance = new FileInfoManager;
}
return instance;
}
FileInfoManager::FileInfoManager(QObject *parent) : QObject(parent)
{
// 在主线程ä¸åˆ�å§‹åŒ–æ ‡è®°model
FileLabelModel::getGlobalModel();
priv = new FileInfoManagerPrivate;
priv->watcher->moveToThread(priv->watcherThread);
priv->watcherLoop->moveToThread(priv->watcherThread);
priv->host->moveToThread(priv->watcherThread);
priv->impl->moveToThread(priv->watcherThread);
connect(priv->watcherThread, &QThread::started, priv->watcherLoop, [=]{
QString displayEnv = (qgetenv("XDG_SESSION_TYPE") == "wayland") ? QLatin1String("WAYLAND_DISPLAY") : QLatin1String("DISPLAY");
QString display(qgetenv(displayEnv.toUtf8().data()));
QUrl nodeUrl(QStringLiteral("local:ukui-idm-") + QString(qgetenv("USER")) + display);
priv->host->setHostUrl(nodeUrl);
priv->host->enableRemoting(priv->impl);
priv->watcherLoop->exec();
});
connect(priv->impl, &FileEventHandlerImpl::reciveClientFileEvent, this, &FileInfoManager::remoteFileEvent);
qRegisterMetaType("FileEventType");
// connect(priv->watcher, &KYSDK_FILEWATCHER::FileWatcher::fileAccessed, this, [=](QString name, QString parent){
// Q_EMIT fileChanged(FileAccessed, name, parent);
// });
connect(priv->watcher, &KYSDK_FILEWATCHER::FileWatcher::fileAttrChanged, this, [=](QString name, QString parent){
Q_EMIT fileChanged(FileAttrChanged, name, parent);
});
// connect(priv->watcher, &KYSDK_FILEWATCHER::FileWatcher::fileClosed, this, [=](QString name, QString parent){
// Q_EMIT fileChanged(FileClosed, name, parent);
// });
// connect(priv->watcher, &KYSDK_FILEWATCHER::FileWatcher::fileCreated, this, [=](QString name, QString parent){
// Q_EMIT fileChanged(FileCreated, name, parent);
// });
connect(priv->watcher, &KYSDK_FILEWATCHER::FileWatcher::fileDeleted, this, [=](QString name, QString parent){
Q_EMIT fileChanged(FileDeleted, name, parent);
});
connect(priv->watcher, &KYSDK_FILEWATCHER::FileWatcher::fileIgnoredAutomatic, this, [=](QString name, QString parent){
Q_EMIT fileChanged(FileIgnoredAutomatic, name, parent);
});
connect(priv->watcher, &KYSDK_FILEWATCHER::FileWatcher::fileModified, this, [=](QString name, QString parent){
Q_EMIT fileChanged(FileModified, name, parent);
});
connect(priv->watcher, &KYSDK_FILEWATCHER::FileWatcher::fileMoveIn, this, [=](QString name, QString parent){
Q_EMIT fileChanged(FileMoveIn, name, parent);
});
connect(priv->watcher, &KYSDK_FILEWATCHER::FileWatcher::fileMoveOut, this, [=](QString name, QString parent){
Q_EMIT fileChanged(FileMoveOut, name, parent);
});
// connect(priv->watcher, &KYSDK_FILEWATCHER::FileWatcher::fileOpened, this, [=](QString name, QString parent){
// Q_EMIT fileChanged(FileOpened, name, parent);
// });
priv->watcherThread->start();
}
FileInfoManager::~FileInfoManager()
{
delete priv;
}
QSharedPointer FileInfoManager::getInfoByUri(const QString &uri)
{
QMutexLocker l(&priv->mutex);
auto info = priv->hash.value(uri);
return info;
}
void FileInfoManager::insertInfo(QSharedPointer info)
{
QMutexLocker l(&priv->mutex);
priv->hash.insert(info->uri(), info);
}
void FileInfoManager::removeInfoPtrByUri(const QString &uri)
{
QMutexLocker l(&priv->mutex);
priv->hash.remove(uri);
}
void FileInfoManager::addFileToWatcher(const QString &url, bool *ok)
{
if (url.isEmpty()) {
if (ok) {
*ok = false;
}
return;
}
QUrl tmp(url);
QString path = tmp.toLocalFile();
if (!path.startsWith("/")) {
if (ok) {
*ok = false;
return;
}
}
QMutexLocker l(&priv->watcherMutex);
int ret = priv->watcher->addWatchTarget(path,
KYSDK_FILEWATCHER::FileWatcherType::PERIODIC,
KYSDK_FILEWATCHER::FileWatcherAttribute::MODIFY|KYSDK_FILEWATCHER::FileWatcherAttribute::DELETE|KYSDK_FILEWATCHER::FileWatcherAttribute::ATTRIB);
if (ok) {
*ok = !ret; // 为0时�功
}
}
QStringList FileInfoManager::addFilesToWatcher(const QStringList &urls)
{
QStringList failedFiles;
for (auto url : urls) {
bool ok = false;
addFileToWatcher(url, &ok);
if (!ok && !url.isEmpty()) {
failedFiles << url;
}
}
return failedFiles;
}
void FileInfoManager::removeFileFromWatcher(const QString &url, bool *ok)
{
if (url.isEmpty()) {
if (ok) {
*ok = false;
}
return;
}
QUrl tmp(url);
QString path = tmp.toLocalFile();
QMutexLocker l(&priv->watcherMutex);
int ret = priv->watcher->removeWatchTarget(path);
if (ok) {
*ok = !ret; // 为0时�功
}
}
QStringList FileInfoManager::removeFilesFromWatcher(const QStringList &urls)
{
QStringList failedFiles;
for (auto url : urls) {
bool ok = false;
removeFileFromWatcher(url, &ok);
if (!ok && !url.isEmpty()) {
failedFiles << url;
}
}
return failedFiles;
}
peony-extensions/peony-intelligent-data-management-service/file/fileinfojob.cpp 0000664 0001750 0001750 00000053074 15257160277 027112 0 ustar feng feng /*
* UKUI Intelligent Data Manager
*
* Copyright (C) 2024, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: Yue Lan
*
*/
#include "fileinfojob.h"
#include "fileinfo_p.h"
#include "fileinfomanager.h"
#include "condition/condition.h"
#include "ai/aiconditionshelper.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#undef signals
#include
#define PEONY_FILE_TIME_OPENED "metadata::peony-time-opened"
#define PEONY_FILE_OPENED_COUNT "metadata::peony-opened-count"
namespace UKUI {
namespace IDM {
class FileInfoJobPrivate{
public:
FileInfoJobPrivate() {
cancelled = false;
canFetchInfos = false;
hasCondition = false;
}
~FileInfoJobPrivate() {
if (conditionsHelper) {
delete conditionsHelper;
}
}
QList> infos;
QSet> resultInfos;
std::atomic_bool cancelled;
std::atomic_bool canFetchInfos;
bool hasCondition;
bool addWatchByDefault;
bool handleContentCondition = false;
QList> andConditions;
QList> orConditions;
QStringList labels;
AIConditionsHelper *conditionsHelper = nullptr;
int spaceId = -1;
};
}
}
using namespace UKUI::IDM;
FileInfoJob *FileInfoJob::fromUris(const QStringList &uris, bool addWatchByDefault)
{
return new FileInfoJob(uris, true, addWatchByDefault);
}
FileInfoJob *FileInfoJob::fromPaths(const QStringList &paths, bool addWatchByDefault)
{
return new FileInfoJob(paths, false, addWatchByDefault);
}
FileInfoJob *FileInfoJob::fromInfos(const QList > &infos, bool addWatchByDefault)
{
auto job = new FileInfoJob;
job->priv->addWatchByDefault = addWatchByDefault;
job->priv->infos = infos;
return job;
}
bool FileInfoJob::queryInfoSyncWithConditions(QSharedPointer &info, const QList> &andConditions, const QList> &orConditions)
{
g_autoptr (GFile) gfile = g_file_new_for_uri(info->priv->uri.toUtf8().constData());
g_autoptr (GFileInfo) gfileinfo = g_file_query_info(gfile,
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME","
G_FILE_ATTRIBUTE_STANDARD_ICON","
G_FILE_ATTRIBUTE_STANDARD_TARGET_URI","
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE","
G_FILE_ATTRIBUTE_STANDARD_SIZE","
G_FILE_ATTRIBUTE_TIME_ACCESS","
G_FILE_ATTRIBUTE_TIME_MODIFIED","
G_FILE_ATTRIBUTE_TIME_CREATED,
G_FILE_QUERY_INFO_NONE, nullptr, nullptr);
if (!gfileinfo) {
return false;
} else {
updateInfoWithGFileInfo(info, gfile, gfileinfo);
if (orConditions.isEmpty() && andConditions.isEmpty())
return true;
else
return infoMatchCondtions(info, andConditions, orConditions, false);
}
}
FileInfoJob::~FileInfoJob()
{
delete priv;
}
void FileInfoJob::start()
{
// fixme: not use QThreadPool::globalInstance()
QThreadPool::globalInstance()->start(this);
}
void FileInfoJob::cancel()
{
priv->cancelled = true;
}
void FileInfoJob::setConditions(const QList > &conditions)
{
priv->andConditions.clear();
priv->orConditions.clear();
if (conditions.isEmpty()) {
priv->hasCondition = false;
return;
}
for (auto condition : conditions) {
if (condition->isAndCondition()) {
priv->andConditions << condition;
} else {
priv->orConditions << condition;
}
}
priv->hasCondition = true;
if (!priv->conditionsHelper) {
priv->conditionsHelper = new AIConditionsHelper;
}
}
void FileInfoJob::setSpaceId(int spaceId)
{
priv->spaceId = spaceId;
}
void FileInfoJob::setLabels(const QStringList &labels)
{
if (labels.isEmpty()) {
priv->labels.clear();
return;
}
priv->labels = labels;
if (!priv->conditionsHelper) {
priv->conditionsHelper = new AIConditionsHelper;
}
}
void FileInfoJob::setHandleContentCondition(bool handleContentCondition)
{
priv->handleContentCondition = handleContentCondition;
}
void FileInfoJob::run()
{
priv->canFetchInfos = false;
Q_EMIT started();
while (!priv->infos.isEmpty()) {
auto info = priv->infos.takeFirst();
GError *error = nullptr;
g_autoptr (GFile) gfile = g_file_new_for_uri(info->priv->uri.toUtf8().constData());
g_autoptr (GFileInfo) gfileinfo = g_file_query_info(gfile,
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME","
G_FILE_ATTRIBUTE_STANDARD_ICON","
G_FILE_ATTRIBUTE_STANDARD_TARGET_URI","
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE","
G_FILE_ATTRIBUTE_STANDARD_SIZE","
G_FILE_ATTRIBUTE_TIME_ACCESS","
G_FILE_ATTRIBUTE_TIME_MODIFIED","
G_FILE_ATTRIBUTE_TIME_CREATED","
G_FILE_ATTRIBUTE_RECENT_MODIFIED","
PEONY_FILE_OPENED_COUNT","
PEONY_FILE_TIME_OPENED","
"metadata::peony-file-label-ids",
G_FILE_QUERY_INFO_NONE, nullptr, &error);
if (error) {
QString msg = error->message;
g_error_free (error);
{
QMutexLocker l(&info->priv->mutex);
info->priv->state = FileInfoPrivate::Invalid;
}
Q_EMIT errored(msg);
continue;
}
if (priv->cancelled) {
priv->infos.clear();
priv->resultInfos.clear();
Q_EMIT cancelled();
return;
}
updateInfoWithGFileInfo(info, gfile, gfileinfo);
bool match = true;
if (priv->hasCondition) {
match = infoMatchCondtions(info, priv->andConditions, priv->orConditions, priv->handleContentCondition);
}
if (!priv->labels.isEmpty()) {
if (match) {
// 如果基本æ�¡ä»¶ä¸�匹é…�则ä¸�å�šæ ‡ç¾åŒ¹é…�
match = infoMatchLabels(info, priv->labels);
}
}
if (match) {
if (priv->addWatchByDefault) {
FileInfoManager::globalInstance()->addFileToWatcher(info->uri());
}
priv->resultInfos << info;
Q_EMIT infoUpdated(info);
}
}
priv->canFetchInfos = true;
Q_EMIT finished();
}
QList > FileInfoJob::getInfos()
{
if (priv->canFetchInfos) {
return priv->resultInfos.values();
}
return QList>();
}
void FileInfoJob::handleCancelWithSpaceId(int spaceId)
{
if (spaceId == priv->spaceId) {
cancel();
}
}
void FileInfoJob::updateInfoWithGFileInfo(QSharedPointer &info, GFile *gfile, GFileInfo *gfileinfo)
{
g_autofree gchar *path = g_file_get_path(gfile);
QString displayName = g_file_info_get_attribute_string(gfileinfo, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME);
GIcon *gicon = g_file_info_get_icon(gfileinfo);
QString iconName = Peony::FileUtils::getIconStringFromGIconThreadSafety(gicon);
guint64 timeAcessSec = g_file_info_get_attribute_uint64(gfileinfo, G_FILE_ATTRIBUTE_TIME_ACCESS);
guint64 timeModifiedSec = g_file_info_get_attribute_uint64(gfileinfo, G_FILE_ATTRIBUTE_TIME_MODIFIED);
guint64 timeCreatedSec = g_file_info_get_attribute_uint64(gfileinfo, G_FILE_ATTRIBUTE_TIME_CREATED);
if (g_file_info_has_attribute(gfileinfo, PEONY_FILE_TIME_OPENED)) {
QString peonyTimeOpenedString = g_file_info_get_attribute_string(gfileinfo, PEONY_FILE_TIME_OPENED);
timeAcessSec = peonyTimeOpenedString.toULongLong();
}
int openCount = 0;
if (g_file_info_has_attribute(gfileinfo, PEONY_FILE_OPENED_COUNT)) {
QString openCountString = g_file_info_get_attribute_string(gfileinfo, PEONY_FILE_OPENED_COUNT);
openCount = openCountString.toULongLong();
}
guint64 timeAcessMsec = timeAcessSec * 1000;
guint64 timeModifiedMsec = timeModifiedSec * 1000;
guint64 timeCreatedMsec = timeCreatedSec * 1000;
gint64 timeRecentModified = g_file_info_get_attribute_int64(gfileinfo, G_FILE_ATTRIBUTE_RECENT_MODIFIED);
const gchar *ctype = g_file_info_get_content_type(gfileinfo);
QString contentType = ctype;
g_autofree gchar *ftype = g_content_type_get_description(ctype);
QString fileType = ftype;
g_autofree gchar *formatsize = nullptr;
guint64 size = g_file_info_get_size(gfileinfo);
if (contentType != "inode/directory") {
formatsize = g_format_size(size);
}
if (!path) {
if (g_file_info_has_attribute(gfileinfo, G_FILE_ATTRIBUTE_STANDARD_TARGET_URI)) {
QUrl url(g_file_info_get_attribute_as_string(gfileinfo, G_FILE_ATTRIBUTE_STANDARD_TARGET_URI));
path = g_strdup(url.toLocalFile().toUtf8().constData());
}
}
QString dateString;
QString createString = Peony::GlobalSettings::getInstance()->transToSystemTimeFormat(timeCreatedSec);
createString = tr("Create Date: %1").arg(createString);
QString accessString = Peony::GlobalSettings::getInstance()->transToSystemTimeFormat(timeAcessSec);
accessString = tr("Open Date: %1").arg(accessString);
QString modifiyString = Peony::GlobalSettings::getInstance()->transToSystemTimeFormat(timeModifiedSec);
//modifiyString = tr("Modify Date: %1").arg(modifiyString);
if (timeAcessSec > timeModifiedSec) {
// 显示打开时间
dateString = accessString;
} else if (timeModifiedSec > timeCreatedSec) {
// fixme: 由于WPSç‰æ–‡ä»¶ä¿®æ”¹æ—¶æ˜¯ä»¥ä¸´æ—¶æ–‡ä»¶ç§»åŠ¨æ–¹å¼�进行原文件覆盖,所以创建时间和修改时间在ä¿�å˜å�Žæ˜¯ä¸€è‡´çš„,这里先显示修改时间,å�Žç»éœ€è¦�结å�ˆç‰ˆæœ¬åˆ¤æ–的信æ�¯æ�¥å¤„ç�†æ¤å¤„显示的内容
// 显示修改时间
dateString = modifiyString;
} else {
// 显示创建时间
dateString = createString;
}
QString parentPath = path;
parentPath.truncate(parentPath.lastIndexOf('/'));
// æ ‡è®°ä¿¡æ�¯
auto metaInfo = Peony::FileMetaInfo::fromGFileInfo(info->priv->uri, gfileinfo);
auto labelStrings = metaInfo->getMetaInfoStringList("peony-file-label-ids");
QList labelIds;
QList labelColors;
// fixme: 线程安全问题
auto labelModel = FileLabelModel::getGlobalModel();
for (QString labelString : labelStrings) {
int labelId = labelString.toInt();
auto item = labelModel->itemFromId(labelId);
if (item) {
labelColors << item->color();
labelIds << labelId;
}
}
QString version = "test";
// thread safety
{
QMutexLocker l(&info->priv->mutex);
info->priv->path = path;
info->priv->parentPath = parentPath;
info->priv->name = displayName;
info->priv->iconName = iconName;
info->priv->timeAccessMsec = timeAcessMsec;
info->priv->timeModifiedMsec = timeModifiedMsec;
info->priv->timeCreatedMsec = timeCreatedMsec;
info->priv->openDateString = accessString;
info->priv->modifyDateString = modifiyString;
info->priv->createDateString = createString;
info->priv->dateString = modifiyString;
info->priv->version = version;
info->priv->mimeType = contentType;
info->priv->fileType = fileType;
info->priv->size = size;
info->priv->sizeFormat = formatsize;
info->priv->labelIds = labelIds;
info->priv->labelColors = labelColors;
info->priv->timeRecentModified = timeRecentModified;
info->priv->openCount = openCount;
info->priv->state = FileInfoPrivate::State::Valid;
//info->priv->ischecked = false;
}
}
bool FileInfoJob::infoMatchCondtions(QSharedPointer &info, const QList > &andConditions, const QList > &orConditions, bool handleContentCondition)
{
QString displayName = info->displayName();
quint64 size = info->size();
QString contentType = info->mimeType();
quint64 timeModifiedMsec = info->timeModifiedMsec();
QString path = info->path();
bool match = true;
// 如果符�所有�件, 则match最终会为true, 如果没有或�件则match�始值为true, �则为false
match = orConditions.count() == 0;
// 或æ�¡ä»¶, å�ªéœ€è¦�满足其ä¸ä¹‹ä¸€å�³å�¯é€šè¿‡
for (auto condition : orConditions) {
// 如果å˜åœ¨æ�¡ä»¶åŒ¹é…�则跳过, 并且设置match为true
switch (condition->type()) {
case Condition::FileName: {
match = condition->isFileNameMatchedWithKeywords(displayName);
break;
}
case Condition::FileContent: {
// 或�件的文件内容匹�目�仅用于普通�索,这里�以跳过
// if (handleContentCondition) {
QString contentDecription = condition->getFileContentContent();
AIConditionsHelper helper;
match = helper.isFileMatchedWithDescriptionCondition(info->path(), contentDecription);
//}
break;
}
case Condition::FileSize: {
match = condition->isFileSizeMatchedWithSize(size);
break;
}
case Condition::FileType: {
int subType = condition->getFileTypeSelectionType();
if (subType < 0) {
match = condition->isFileTypeMatchedWithSuffixes(displayName);
} else {
match = condition->isFileTypeMatchedWithSubType(subType, displayName, contentType);
}
break;
}
case Condition::DateRange: {
match = condition->isFileMatchedWithDate(0, timeModifiedMsec);
break;
}
case Condition::SearchLocation: {
match = condition->isFileMatchedWithSearchLocation(path);
break;
}
default: {
match = false;
break;
}
}
// 如果有一个�件匹�, 则跳出循环
if (match) {
break;
}
}
if (!match) {
return match;
} else {
// 如果å˜åœ¨ä¸�匹é…�的且æ�¡ä»¶, åˆ™è·³è¿‡æ¤æ¬¡æµ�程
for (auto condition : andConditions) {
// 如果å˜åœ¨æ�¡ä»¶ä¸�匹é…�则跳过, 并且设置match为false
switch (condition->type()) {
case Condition::FileName: {
match = condition->isFileNameMatchedWithKeywords(displayName);
break;
}
case Condition::FileContent: {
// 与æ�¡ä»¶çš„æ–‡ä»¶å†…容æ�œç´¢ç›®å‰�结å�ˆè¯ä¹‰æ�œç´¢ä½¿ç”¨ï¼Œè¿™é‡Œéœ€è¦�区分是è¯ä¹‰æ�œç´¢è¿˜æ˜¯åЍæ€�æ·»åŠ åœºæ™¯
//if (handleContentCondition) {
QString contentDecription = condition->getFileContentContent();
AIConditionsHelper helper;
match = helper.isFileMatchedWithDescriptionCondition(info->path(), contentDecription);
//}
break;
}
case Condition::FileType: {
int subType = condition->getFileTypeSelectionType();
if (subType < 0) {
match = condition->isFileTypeMatchedWithSuffixes(displayName);
} else {
match = condition->isFileTypeMatchedWithSubType(subType, displayName, contentType);
}
break;
}
case Condition::FileSize: {
match = condition->isFileSizeMatchedWithSize(size);
break;
}
case Condition::SearchLocation: {
match = condition->isFileMatchedWithSearchLocation(path);
break;
}
case Condition::DateRange: {
match = condition->isFileMatchedWithDate(0, timeModifiedMsec);
break;
}
default:
match = true;
break;
}
// å˜åœ¨ä¸�匹é…�, 则跳出循环
if (!match) {
break;
}
}
}
return match;
}
bool FileInfoJob::infoMatchLabels(QSharedPointer &info, const QStringList &labels)
{
QUrl url = info->uri();
QString filePath = url.toLocalFile();
return priv->conditionsHelper->isFileMatchedWithLables(filePath, labels);
}
bool FileInfoJob::infoMatchCondtions(const QFileInfo &fileinfo, const QList> &andConditions, const QList > &orConditions)
{
QString displayName = fileinfo.fileName();
QString path = fileinfo.absoluteFilePath();
quint64 size = fileinfo.size();
QString contentType;
if (fileinfo.isDir()) {
contentType = "inode/directory";
} else {
//QMimeDatabase db;
//QMimeType mimeType = db.mimeTypeForFile(fileinfo.absoluteFilePath(), QMimeDatabase::MatchExtension); // fixme: æ�œç´¢æ ¹ç›®å½•匹é…�æ—¶è°ƒç”¨æ¤æ–¹æ³•内å˜ä¼šé£™å�‡
g_autofree gchar *contenttype = g_content_type_guess(path.toUtf8().constData(), nullptr, size, nullptr);
contentType = contenttype;
}
quint64 timeModifiedMsec = fileinfo.fileTime(QFile::FileModificationTime).toMSecsSinceEpoch();
QSharedPointer info = QSharedPointer(new FileInfo);
info->priv->name = displayName;
info->priv->size = size;
info->priv->mimeType = contentType;
info->priv->timeModifiedMsec = timeModifiedMsec;
info->priv->path = path;
return infoMatchCondtions(info, andConditions, orConditions, false);
}
FileInfoJob::FileInfoJob(const QStringList &args, bool isUriFormat, bool addWatchByDefault, QObject *parent) : QObject(parent), QRunnable()
{
setAutoDelete(false);
priv = new FileInfoJobPrivate;
priv->addWatchByDefault = addWatchByDefault;
if (isUriFormat) {
for (auto arg : args) {
priv->infos.append(FileInfo::fromUri(arg));
}
} else {
for (auto arg : args) {
priv->infos.append(FileInfo::fromPath(arg));
}
}
}
void FileInfoJob::updateFileInfoDataformat(QSharedPointer &info)
{
GError *error = nullptr;
g_autoptr (GFile) gfile = g_file_new_for_uri(info->priv->uri.toUtf8().constData());
g_autoptr (GFileInfo) gfileinfo = g_file_query_info(gfile,
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME","
G_FILE_ATTRIBUTE_STANDARD_ICON","
G_FILE_ATTRIBUTE_STANDARD_TARGET_URI","
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE","
G_FILE_ATTRIBUTE_STANDARD_SIZE","
G_FILE_ATTRIBUTE_TIME_ACCESS","
G_FILE_ATTRIBUTE_TIME_MODIFIED","
G_FILE_ATTRIBUTE_TIME_CREATED","
G_FILE_ATTRIBUTE_RECENT_MODIFIED","
PEONY_FILE_OPENED_COUNT","
PEONY_FILE_TIME_OPENED","
"metadata::peony-file-label-ids",
G_FILE_QUERY_INFO_NONE, nullptr, &error);
if (error) {
QString msg = error->message;
g_error_free (error);
{
QMutexLocker l(&info->priv->mutex);
info->priv->state = FileInfoPrivate::Invalid;
}
return;
}
updateInfoWithGFileInfo(info, gfile, gfileinfo);
}
FileInfoJob::FileInfoJob()
{
setAutoDelete(false);
priv = new FileInfoJobPrivate;
priv->addWatchByDefault = true;
}
peony-extensions/peony-intelligent-data-management-service/file/fileinfo_p.h 0000664 0001750 0001750 00000003203 15257160264 026364 0 ustar feng feng /*
* UKUI Intelligent Data Manager
*
* Copyright (C) 2024, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: Yue Lan
*
*/
#ifndef FILEINFO_P_H
#define FILEINFO_P_H
#include
#include
namespace UKUI {
namespace IDM {
class FileInfoPrivate
{
public:
enum State
{
Invalid,
Valid
};
FileInfoPrivate() {}
State state = Invalid;
QString uri;
QString path;
QString parentPath;
QString name;
QString iconName;
QString createDateString;
QString modifyDateString;
QString openDateString;
QString dateString;
quint64 timeAccessMsec = -1;
quint64 timeModifiedMsec = -1;
quint64 timeCreatedMsec = -1;
qint64 timeRecentModified = -1;
QString version;
QString mimeType;
QString fileType;
quint64 size;
QString sizeFormat;
QList labelIds;
QList labelColors;
quint64 openCount = 0;
bool ischecked = false;
QMutex mutex;
};
}
}
#endif // FILEINFO_P_H
peony-extensions/peony-intelligent-data-management-service/ai/ 0000775 0001750 0001750 00000000000 15257160277 023561 5 ustar feng feng peony-extensions/peony-intelligent-data-management-service/ai/aiconditionshelper.cpp 0000664 0001750 0001750 00000006727 15257160264 030160 0 ustar feng feng /*
* UKUI Intelligent Data Manager
*
* Copyright (C) 2024, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: Yue Lan
*
*/
#include "aiconditionshelper.h"
#include
#include
#include
#include
AIConditionsHelper::AIConditionsHelper(QObject *parent)
: QObject{parent}
{
#ifdef USE_AI
session = data_management_create_session();
if (session) {
inited = true;
}
#endif
}
bool AIConditionsHelper::isValid()
{
return inited;
}
AIConditionsHelper::~AIConditionsHelper()
{
#ifdef USE_AI
data_management_destroy_session(session);
#endif
}
QJsonDocument AIConditionsHelper::pharseConditions(const QString &description, bool *ok)
{
QJsonDocument doc;
#ifdef USE_AI
if (!inited) {
setOkResult(ok, false);
return doc;
}
char *results = nullptr;
QJsonObject obj;
obj["description"] = description;
QJsonDocument descriptionDoc(obj);
DataManagementStatus ret = data_management_extract_search_conditions(session, descriptionDoc.toJson().constData(), &results);
if (!ret.success) {
setOkResult(ok, false);
return doc;
}
doc = QJsonDocument::fromJson(results);
setOkResult(ok, true);
return doc;
#else
setOkResult(ok, false);
return doc;
#endif
}
bool AIConditionsHelper::isFileMatchedWithDescriptionCondition(const QString &filePath, const QString &descriptionCondition, bool *ok)
{
#ifdef USE_AI
bool matched = false;
if (!inited) {
setOkResult(ok, false);
return matched;
}
QJsonObject obj;
obj["file"] = filePath;
obj["description"] = descriptionCondition;
QJsonDocument doc(obj);
bool result = false;
auto ret = data_management_is_file_relevant_to_description(session, doc.toJson().constData(), &result);
if (!ret.success) {
return matched;
}
if (result == 1) {
matched = true;
}
setOkResult(ok, true);
return matched;
#else
setOkResult(ok, false);
return false;
#endif
}
bool AIConditionsHelper::isFileMatchedWithLables(const QString &filePath, const QStringList &labels, bool *ok)
{
#ifdef USE_AI
bool matched = false;
if (!inited) {
setOkResult(ok, false);
return matched;
}
QJsonObject obj;
obj["file"] = filePath;
obj["tags"] = QJsonArray::fromStringList(labels);
QJsonDocument doc(obj);
bool result = false;
DataManagementStatus ret = data_management_is_file_relevant_to_tags(session, doc.toJson().constData(), &result);
if (!ret.success) {
return matched;
}
if (result == 1) {
matched = true;
}
setOkResult(ok, true);
return matched;
#else
setOkResult(ok, false);
return false;
#endif
}
void AIConditionsHelper::setOkResult(bool *ok, bool result)
{
if (ok) {
*ok = result;
}
}
peony-extensions/peony-intelligent-data-management-service/ai/ailabelhelper.cpp 0000664 0001750 0001750 00000014440 15257160264 027055 0 ustar feng feng /*
* UKUI Intelligent Data Manager
*
* Copyright (C) 2024, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: Yue Lan
*
*/
#include "ailabelhelper.h"
#include
#include
#include
#include
#include
#include
#include
AILabelHelper::AILabelHelper(QObject *parent)
: QObject{parent}
{
#ifdef USE_AI
session = data_management_create_session();
if (session) {
inited = true;
}
#endif
}
AILabelHelper::~AILabelHelper()
{
#ifdef USE_AI
data_management_destroy_session(session);
#endif
}
bool AILabelHelper::isValid()
{
return inited;
}
QStringList AILabelHelper::getTopLabels(int maxCount, bool *ok)
{
QStringList list;
#ifdef USE_AI
if (!inited) {
setOkResult(ok, false);
return list;
}
char *results = nullptr;
auto ret = data_management_get_all_tags(session, &results);
if (!ret.success) {
setOkResult(ok, false);
return list;
}
QJsonDocument doc = QJsonDocument::fromJson(results);
if (doc.isObject()) {
QJsonObject obj = doc.object();
QJsonValue tagsValue = obj.value("tags");
if (tagsValue.isArray()) {
QJsonArray tagsArray = tagsValue.toArray();
for (auto tag : tagsArray) {
list << tag.toString();
if (maxCount > 0 && list.count() == maxCount)
break;
}
}
} else if (doc.isArray()) {
QJsonArray tagsArray = doc.array();
for (auto tag : tagsArray) {
list << tag.toString();
if (maxCount > 0 && list.count() == maxCount)
break;
}
}
data_management_destroy_result(results);
setOkResult(ok, true);
return list;
#else
setOkResult(ok, false);
return list;
#endif
}
QStringList AILabelHelper::getSimilarLabels(const QString &label, bool *ok)
{
QStringList list;
#ifdef USE_AI
if (!inited) {
setOkResult(ok, false);
return list;
}
QJsonObject obj;
QStringList labels;
labels << label;
obj["tags"] = QJsonArray::fromStringList(labels);
QJsonDocument tagsDoc(obj);
char *results = nullptr;
auto ret = data_management_search_similar_tags(session, tagsDoc.toJson().constData(), &results);
if (!ret.success) {
setOkResult(ok, false);
return list;
}
QJsonDocument doc = QJsonDocument::fromJson(results);
if (doc.isObject()) {
QJsonObject obj = doc.object();
QJsonValue tagsValue = obj.value("tags");
if (tagsValue.isArray()) {
QJsonArray tagsArray = tagsValue.toArray();
for (auto tag : tagsArray) {
list << tag.toString();
}
}
} else if (doc.isArray()) {
QJsonArray tagsArray = doc.array();
for (auto tag : tagsArray) {
list << tag.toString();
}
}
data_management_destroy_result(results);
setOkResult(ok, true);
return list;
#else
setOkResult(ok, false);
return list;
#endif
}
QStringList AILabelHelper::getFileLabels(const QString &filePath, bool *ok)
{
QStringList list;
#ifdef USE_AI
if (!inited) {
setOkResult(ok, false);
return list;
}
QJsonObject obj;
QStringList files;
files << filePath;
obj["files"] = QJsonArray::fromStringList(files);
QJsonDocument doc(obj);
char *results = nullptr;
auto ret = data_management_get_tags_of_files(session, doc.toJson().constData(), &results);
if (!ret.success) {
setOkResult(ok, false);
return list;
}
doc = QJsonDocument::fromJson(results);
if (doc.isArray()) {
QJsonArray resultsArray = doc.array();
for (auto result : resultsArray) {
if (result.isObject()) {
QJsonObject obj = result.toObject();
QJsonValue tagsValue = obj.value("tags");
if (tagsValue.isArray()) {
QJsonArray tagsArray = tagsValue.toArray();
for (auto tag : tagsArray) {
list << tag.toString();
}
}
break;
}
}
}
data_management_destroy_result(results);
setOkResult(ok, true);
return list;
#else
setOkResult(ok, false);
return list;
#endif
}
QStringList AILabelHelper::getFilesByLabels(const QStringList &labels, bool *ok)
{
QStringList list;
#ifdef USE_AI
if (!inited) {
setOkResult(ok, false);
return list;
}
qDebug() << labels;
QJsonArray tagsArray = QJsonArray::fromStringList(labels);
QJsonObject obj;
obj["tags"] = tagsArray;
QJsonDocument doc(obj);
char *results = nullptr;
qDebug() << doc;
auto ret = data_management_search_files_about_tags(session, doc.toJson().constData(), &results);
if (!ret.success) {
setOkResult(ok, false);
return list;
}
doc = QJsonDocument::fromJson(results);
if (doc.isObject()) {
obj = doc.object();
QJsonValue value = obj["files"];
if (value.isArray()) {
QJsonArray filesArray = value.toArray();
for (auto file : filesArray) {
list << file.toString();
}
}
} else if (doc.isArray()) {
QJsonArray filesArray = doc.array();
for (auto file : filesArray) {
list << file.toString();
}
}
data_management_destroy_result(results);
setOkResult(ok, true);
return list;
#else
setOkResult(ok, false);
return list;
#endif
}
void AILabelHelper::setOkResult(bool *ok, bool result)
{
if (ok) {
*ok = result;
}
}
peony-extensions/peony-intelligent-data-management-service/ai/aiconditionshelper.h 0000664 0001750 0001750 00000003117 15257160264 027613 0 ustar feng feng /*
* UKUI Intelligent Data Manager
*
* Copyright (C) 2024, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: Yue Lan
*
*/
#ifndef AICONDITIONSHELPER_H
#define AICONDITIONSHELPER_H
#include
#ifdef USE_AI
#include
#endif
class AIConditionsHelper : public QObject
{
Q_OBJECT
public:
explicit AIConditionsHelper(QObject *parent = nullptr);
~AIConditionsHelper();
QJsonDocument pharseConditions(const QString &description, bool *ok = nullptr);
bool isFileMatchedWithDescriptionCondition(const QString &filePath, const QString &descriptionCondition, bool *ok = nullptr);
bool isFileMatchedWithLables(const QString &filePath, const QStringList &labels, bool *ok = nullptr);
bool isValid();
private:
void setOkResult(bool *ok, bool result);
#ifdef USE_AI
DataManagementSession *session = nullptr;
#endif
bool inited = false;
};
#endif // AICONDITIONSHELPER_H
peony-extensions/peony-intelligent-data-management-service/ai/aisearchtask.cpp 0000664 0001750 0001750 00000023535 15257160277 026737 0 ustar feng feng /*
* UKUI Intelligent Data Manager
*
* Copyright (C) 2024, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: Yue Lan
*
*/
#include "aisearchtask.h"
#include "file/fileinfo.h"
#include "file/fileinfojob.h"
#include "ai/aiconditionshelper.h"
#include "ai/ailabelhelper.h"
#include "condition/condition.h"
#include
#include
#include
#include
#include
#include "model/modelcontroller.h"
#include
AISearchTask::AISearchTask(const QString &description, QObject *parent)
: QObject{parent}, m_description{description}
{
cancelled = false;
}
void AISearchTask::cancel()
{
cancelled = true;
}
void AISearchTask::doQuery()
{
// connect(this, &AISearchTask::finished, this, [=](bool successed, const QList> &results, const QJsonDocument &conditions, const QString &errorMsg){
// cancel();
// });
QList infos;
DataManagementSession *session = data_management_create_session();
if (!session) {
Q_EMIT finished(false, infos, QJsonDocument(), tr("Failed to create ai search session."));
return;
}
if (cancelled) {
data_management_destroy_session(session);
Q_EMIT finished(false, infos, QJsonDocument(), tr("Search task cancelled."));
return;
}
QJsonDocument conditionsDoc;
if (pharseConditions) {
AIConditionsHelper helper;
conditionsDoc = helper.pharseConditions(m_description);
qDebug() << conditionsDoc;
QJsonObject conditionsObj = conditionsDoc.object();
auto conditions = Condition::generateContitionsFromDescription(conditionsObj);
//将�件进行转��AI文件内容返回的type为3对应文管文件内容类型type为7
if(conditions.size()==1 && conditions[0]->type() == Condition::DateRange){
auto fileContentObj = conditionsObj[QString::number(0)].toObject();
fileContentObj["condition type"] = int(Condition::FileContent);
fileContentObj["content"] = m_description;
fileContentObj["orCondition"] = false;
conditionsObj[QString::number(0)] = fileContentObj;
}
conditions = Condition::generateContitionsFromDescription(conditionsObj);
auto labels = Condition::getLabelsFromDescription(conditionsObj);
bool hasConditions = false;
bool hasLabels = false;
bool hasContentConditions = false;
QString contentDescription;
hasConditions = !conditions.isEmpty();
// 获�文件内容�述�件
for (auto condition : conditions) {
if (condition->type() == Condition::FileContent) {
hasContentConditions = true;
contentDescription = condition->getFileContentContent();
break;
}
}
hasLabels = !labels.isEmpty();
QSet labelsMatchedInfos;
QSet contentMatchedInfos;
QSet basicMatchedInfos;
QSet resultInfos;
if (cancelled) {
goto out;
}
if (hasLabels) {
// 获å�–æ ‡ç¾åŒ¹é…�结果
AILabelHelper labelHelper;
QStringList files = labelHelper.getFilesByLabels(labels);
for (auto path : files) {
//auto info = UKUI::IDM::FileInfo::fromPath(path);
labelsMatchedInfos << path;
}
}
if (hasContentConditions) {
// 获å�–文件内容匹é…�结果,注æ„�这里使用的ä¸�是普通æ�œç´¢æŒ‰å…³é”®å—的匹é…�æ–¹å¼�
QJsonObject obj;
obj["text"] = contentDescription;
QJsonDocument doc(obj);
char* searchresults = nullptr;
data_management_similarity_search(session, doc.toJson().constData(), &searchresults);
QJsonDocument resultDoc = QJsonDocument::fromJson(searchresults);
data_management_destroy_result(searchresults);
QJsonArray resultArray = resultDoc.array();
if (cancelled) {
goto out;
}
// 使用è¯ä¹‰è§£æž�获å�–çš„æ�¡ä»¶è¿›è¡Œè¿‡æ»¤
QList> orConditions;
QList> andConditions;
for (auto condition : conditions) {
if (condition->isAndCondition()) {
andConditions << condition;
} else {
orConditions << condition;
}
}
for (auto item : resultArray) {
if (cancelled) {
goto out;
}
if (item.isObject()) {
auto result = item.toObject();
auto value = result.value("filepath");
QString path = value.toString();
auto info = UKUI::IDM::FileInfo::fromPath(path);
if (UKUI::IDM::FileInfoJob::infoMatchCondtions(QFileInfo(path), andConditions, orConditions))
{
contentMatchedInfos << path;
}
}
}
} else if (!hasContentConditions && hasConditions) {
// fixme: ä¸�包å�«å†…容æ��è¿°çš„è¯ä¹‰æ�œç´¢ï¼ŒèŽ·å�–符å�ˆåŸºæœ¬æ�¡ä»¶çš„æ–‡ä»¶ç»“果,这里应该退化æˆ�普通æ�œç´¢çš„æµ�程
}
if (!hasConditions) {
// 如果å�ªæœ‰æ ‡ç¾æ�¡ä»¶åˆ™ç›´æŽ¥è¿”å›žæ ‡ç¾ç»“æžœ
infos = labelsMatchedInfos.values();
} else {
// 如果å�Œæ—¶æœ‰æ ‡ç¾æ�¡ä»¶å’ŒåŸºç¡€æ�¡ä»¶ï¼Œåˆ™éœ€è¦�å�–å�„自结果的交集
if (hasContentConditions) {
resultInfos = contentMatchedInfos;
if (hasLabels)
resultInfos = resultInfos.intersect(labelsMatchedInfos);
infos = resultInfos.values();
} else if (hasConditions) {
resultInfos = basicMatchedInfos;
if (hasLabels)
resultInfos = resultInfos.intersect(labelsMatchedInfos);
infos = resultInfos.values();
}
}
} else {
// 将整段description作为token进行�索
QJsonObject obj;
obj["text"] = m_description;
QJsonDocument doc(obj);
char* searchresults = nullptr;
data_management_similarity_search(session, doc.toJson().constData(), &searchresults);
QJsonDocument resultDoc = QJsonDocument::fromJson(searchresults);
data_management_destroy_result(searchresults);
QJsonArray resultArray = resultDoc.array();
if (cancelled) {
goto out;
}
QSet labelsMatchedFiles;
QSet conditionsMatchedFiles;
bool hasLabels = false;
auto labels = Condition::getLabelsFromDescription(m_conditionDescription);
if (!labels.isEmpty()) {
hasLabels = true;
AILabelHelper helper;
QStringList filesMatchedLabels = helper.getFilesByLabels(labels);
for (auto filePath : filesMatchedLabels) {
labelsMatchedFiles << filePath;//UKUI::IDM::FileInfo::fromPath(filePath);
}
if (cancelled) {
goto out;
}
}
// 使用手动设置的�件进行过滤
auto conditions = Condition::generateContitionsFromDescription(m_conditionDescription);
QList> orConditions;
QList> andConditions;
for (auto condition : conditions) {
if (condition->isAndCondition()) {
andConditions << condition;
} else {
orConditions << condition;
}
}
for (auto item : resultArray) {
if (cancelled) {
goto out;
}
if (item.isObject()) {
auto result = item.toObject();
auto value = result.value("filepath");
QString path = value.toString();
//auto info = UKUI::IDM::FileInfo::fromPath(path);
if (UKUI::IDM::FileInfoJob::infoMatchCondtions(QFileInfo(path), andConditions, orConditions)) {
conditionsMatchedFiles << path;
}
}
}
if (hasLabels) {
auto set = conditionsMatchedFiles;
set = set.intersect(labelsMatchedFiles);
infos = set.values();
} else {
infos = conditionsMatchedFiles.values();
}
}
out:
data_management_destroy_session(session);
if (cancelled) {
infos.clear();
//Q_EMIT finished(false, infos, QJsonDocument(), tr("Search task cancelled."));
} else {
Q_EMIT finished(true,infos, conditionsDoc, nullptr);
//resultInfos = infos;
}
}
void AISearchTask::cancelWithSpaceId(int spaceId)
{
if (this->spaceId == spaceId) {
cancel();
}
}
void AISearchTask::setPharseConditions(bool newPharseConditions)
{
pharseConditions = newPharseConditions;
}
void AISearchTask::setFilterConditionDescription(const QVariant &conditionDescription)
{
m_conditionDescription = conditionDescription;
}
void AISearchTask::setSpaceId(int spaceId)
{
this->spaceId = spaceId;
}
peony-extensions/peony-intelligent-data-management-service/ai/aisearchtask.h 0000664 0001750 0001750 00000004612 15257160264 026373 0 ustar feng feng /*
* UKUI Intelligent Data Manager
*
* Copyright (C) 2024, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: Yue Lan
*
*/
#ifndef AISEARCHTASK_H
#define AISEARCHTASK_H
#include
#include
#include
#include
#include
#include
#include
namespace UKUI {
namespace IDM {
class FileInfo;
}
}
class AISearchTask : public QObject
{
Q_OBJECT
public:
explicit AISearchTask(const QString &description, QObject *parent = nullptr);
/*!
* \brief setPharseConditions
* 是å�¦å¯¹è¾“入的description进行è¯ä¹‰è§£æž�转为æ�¡ä»¶ä¹‹å�Žå†�进行æ�œç´¢
* \param newPharseConditions
*/
void setPharseConditions(bool newPharseConditions);
/*!
* \brief setFilterConditionDescription
* 设置用于过滤结果的�件�置,�有在pharseConditions为false时�有效果
* \param conditionDescription
*/
void setFilterConditionDescription(const QVariant &conditionDescription);
void setSpaceId(int spaceId);
Q_SIGNALS:
void finisheds(bool successed, const QList &results, const QJsonDocument &conditions, const QString &errorMsg);
void finished(bool successed, const QList &results, const QJsonDocument &conditions, const QString &errorMsg);
void searchcontentload(QString uri, QString modified, QString filetype,QString size);
public Q_SLOTS:
void cancel();
void doQuery();
void cancelWithSpaceId(int spaceId);
private:
std::atomic_bool cancelled;
bool pharseConditions = false;
QString m_description;
QVariant m_conditionDescription;
QList> resultInfos;
int spaceId = -1;
};
#endif // AISEARCHTASK_H
peony-extensions/peony-intelligent-data-management-service/ai/ailabelhelper.h 0000664 0001750 0001750 00000003031 15257160264 026514 0 ustar feng feng /*
* UKUI Intelligent Data Manager
*
* Copyright (C) 2024, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: Yue Lan
*
*/
#ifndef AILABELHELPER_H
#define AILABELHELPER_H
#include
#ifdef USE_AI
#include
#endif
class AILabelHelper : public QObject
{
Q_OBJECT
public:
explicit AILabelHelper(QObject *parent = nullptr);
~AILabelHelper();
bool isValid();
QStringList getTopLabels(int maxCount, bool *ok = nullptr);
QStringList getSimilarLabels(const QString &label, bool *ok = nullptr);
QStringList getFileLabels(const QString &filePath, bool *ok = nullptr);
QStringList getFilesByLabels(const QStringList &labels, bool *ok = nullptr);
private:
void setOkResult(bool *ok, bool result);
#ifdef USE_AI
DataManagementSession *session = nullptr;
#endif
bool inited = false;
};
#endif // AILABELHELPER_H
peony-extensions/peony-intelligent-data-management-service/ai/aipreviewhelper.h 0000664 0001750 0001750 00000002617 15257160264 027127 0 ustar feng feng /*
* UKUI Intelligent Data Manager
*
* Copyright (C) 2024, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: Yue Lan
*
*/
#ifndef AIPREVIEWHELPER_H
#define AIPREVIEWHELPER_H
#include
#ifdef USE_AI
#include
#endif
class AIPreviewHelper : public QObject
{
Q_OBJECT
public:
explicit AIPreviewHelper(QObject *parent = nullptr);
~AIPreviewHelper();
bool isValid();
QStringList getFileLabels(const QString &filePath, bool *ok = nullptr);
QString getFileSummary(const QString &filePath, bool *ok = nullptr);
private:
void setOkResult(bool *ok, bool result);
#ifdef USE_AI
DataManagementSession *session = nullptr;
#endif
bool inited = false;
};
#endif // AIPREVIEWHELPER_H
peony-extensions/peony-intelligent-data-management-service/ai/aipreviewhelper.cpp 0000664 0001750 0001750 00000007356 15257160264 027467 0 ustar feng feng /*
* UKUI Intelligent Data Manager
*
* Copyright (C) 2024, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: Yue Lan
*
*/
#include "aipreviewhelper.h"
#include
#include
#include
#include
#include
#include
#include "model/modelcontroller.h"
AIPreviewHelper::AIPreviewHelper(QObject *parent)
: QObject{parent}
{
#ifdef USE_AI
session = data_management_create_session();
if (session) {
inited = true;
}
#endif
}
AIPreviewHelper::~AIPreviewHelper()
{
#ifdef USE_AI
data_management_destroy_session(session);
#endif
}
bool AIPreviewHelper::isValid()
{
return inited;
}
QStringList AIPreviewHelper::getFileLabels(const QString &filePath, bool *ok)
{
QStringList list;
#ifdef USE_AI
if (!inited) {
setOkResult(ok, false);
return list;
}
QJsonObject obj;
QStringList files;
files << filePath;
obj["files"] = QJsonArray::fromStringList(files);
QJsonDocument doc(obj);
char *results = nullptr;
auto ret = data_management_get_tags_of_files(session, doc.toJson().constData(), &results);
if (!ret.success) {
setOkResult(ok, false);
return list;
}
doc = QJsonDocument::fromJson(results);
if (doc.isArray()) {
QJsonArray resultsArray = doc.array();
for (auto result : resultsArray) {
if (result.isObject()) {
QJsonObject obj = result.toObject();
QJsonValue tagsValue = obj.value("tags");
if (tagsValue.isArray()) {
QJsonArray tagsArray = tagsValue.toArray();
for (auto tag : tagsArray) {
list << tag.toString();
}
}
break;
}
}
}
data_management_destroy_result(results);
setOkResult(ok, true);
return list;
#else
setOkResult(ok, false);
return list;
#endif
}
QString AIPreviewHelper::getFileSummary(const QString &filePath, bool *ok)
{
QString summary;
#ifdef USE_AI
if (!inited) {
setOkResult(ok, false);
return summary;
}
QJsonObject obj;
QStringList files;
files << filePath;
obj["files"] = QJsonArray::fromStringList(files);
QJsonDocument doc(obj);
char *results = nullptr;
auto ret = data_management_get_summarys_of_files(session, doc.toJson().constData(), &results);
if (!ret.success) {
setOkResult(ok, false);
return summary;
}
doc = QJsonDocument::fromJson(results);
if (doc.isArray()) {
QJsonArray resultsArray = doc.array();
for (auto result : resultsArray) {
if (result.isObject()) {
QJsonObject obj = result.toObject();
summary = obj["summary"].toString();
break;
}
}
}
data_management_destroy_result(results);
setOkResult(ok, true);
return summary;
#else
setOkResult(ok, false);
return summary;
#endif
}
void AIPreviewHelper::setOkResult(bool *ok, bool result)
{
if (ok) {
*ok = result;
}
}
././@LongLink 0000644 0000000 0000000 00000000153 00000000000 011602 L ustar root root peony-extensions/peony-intelligent-data-management-service/peony-intelligent-data-management-service_ky.ts peony-extensions/peony-intelligent-data-management-service/peony-intelligent-data-management-service0000664 0001750 0001750 00000023724 15257160264 033244 0 ustar feng feng
AISearchTask
Failed to create ai search session.
ai ىزدۅۅ ماشعۇلاتىنى قۇرۇۇ جەÚىلۉۉ بولدۇ .
Search task cancelled.
ىزدۅۅ مىلدەتى ارعادان قالتىرىلدى.
Condition
File name contains "%1"
ۅجۅت ناامى «٪1» نى ۅز ىچىنە الات
File name without "%1"
«٪1» بولبوعون ۅجۅت ناامى
File type contains "%1"
ۅجۅت تۉرۉ «٪1» نى ۅز ىچىنە الات
By suffix
قوشۇمچاسى
Folder
تىزىمدىك
Plain Text
تازا تەكىست
WPS Document
WPS ۅجۅتۉۉ
PDF
Image
سۉرۅت
Video
ايىپ
Audio
دووش
File type contains %1
ۅجۅت تۉرۉ ٪1 نى ۅز ىچىنە الات
All
باردىعى
Empty(0K)
ÙƒÛ…ÚØ¯Û…ÙŠ(0K)
Tiny(0-16K)
كىچىككىنە (0-16K)
Small(16K-1M)
كىچىك (16K-1M)
Medium(1M-128M)
ورتوچو (1M-128M)
Big(128M-1G)
Ú†ÙˆÚ(128M-1G)
Large(1-4G)
Ú†ÙˆÚ(1-4G)
Great(>4G)
قالتىس(>4G)
File size contains %1
ۅجۅت Ú†ÙˆÚØ¯Û‡Ø¹Û‡ Ùª1 نى ۅز ىچىنە الات
File size without %1
ۅجۅت Ú†ÙˆÚØ¯Û‡Ø¹Û‡ Ùª1 جوق
File content match %1
ۅجۅت مازمۇنۇ ٪1 شاي گەلەت
File location contains "%1"
ۅجۅت وردۇ «٪1» نى ۅز ىچىنە الات
File location without "%1"
ۅجۅت وردۇ «٪1» جوق
Later than "%1"
«٪1» نان كىيىن
Earlier than "%1"
«٪1» نان مۇرۇنقۇ
DatabaseManager
New Space %1
جاÚÙ‰ بوشتۇق Ùª1
File %1 has areally been added to %2
ۅجۅت ٪1 چىنعى ٪2 گە قوشۇلدۇ
File %1 doesn't exsit in any space.
ۅجۅت ٪1 ارقانداي بوشتۇقتا چىقبايت.
Failed to get space %1's id from query
سۈرۈشتۈرۈشتىن بوشتۇق Ùª1 Ù†Ù‰Ú ID عا Û•Û• بولعولۇ بولبودۇ
Failed to get %1's id from query
سۈرۈشتۈرۈشتىن Ùª1 Ù†Ù‰Ú ÙƒÛ‰Ø¨Û…Ù„Û‰Ú¯Û‰Ù†Û‰ الۇۇ جەÚىلۉۉ بولدۇ
ModelController
Failed to rename space %1 to %2, %2 is existed.
بوشتۇقتۇن اتاعىن Ùª1 Ú¯Û• Ùª2 جاساپ ۅزگۅرتۉش جەÚىلۉۉ بولدۇ ØŒ Ùª2 باربولۇۇسۇ .
Failed to remove space %1, error message: %2
Ùª1 بوشتۇقتۇ چىعارۇۇ جەÚىلۉۉ بولدۇ ØŒ قاتاالىق ۇچۇرۇ : Ùª2
New Space %1
جاÚÙ‰ بوشتۇق Ùª1
Failed to updatestatus space %1, error message: %2
Ùª1 ابالى بوشتۇعۇن جاÚىلوو جەÚىلۉۉ بولدۇ ØŒ قاتاالىق ۇچۇرۇ : Ùª2
QObject
%1 %2
Intelligent Data Manager Introduction
روØÙ‰ÙŠ Ø¬Û…Ù†Ø¯Û…Ù…Ø¯Û‰Ù„Û‰Ùƒ ساندۇۇ بايانداما باشقارۇۇچۇنۇن تونۇشتۇرۇشى
peony-intelligent-data-management-service
پئون روØÙ‰ÙŠ Ø¬Û…Ù†Ø¯Û…Ù…Ø¯Û‰Ù„Û‰Ùƒ ساندۇۇ بايانداما باشقارىش سان قاينارى
exit
جانىش ، قايتىش
UKUI::IDM::FileInfoJob
Create Date: %1
چىسلا قۇرۇۇ: ٪1
Open Date: %1
اچىلعان ۇباقتى: ٪1
././@LongLink 0000644 0000000 0000000 00000000156 00000000000 011605 L ustar root root peony-extensions/peony-intelligent-data-management-service/peony-intelligent-data-management-service_zh_HK.ts peony-extensions/peony-intelligent-data-management-service/peony-intelligent-data-management-service0000664 0001750 0001750 00000021723 15257160277 033245 0 ustar feng feng
AISearchTask
Failed to create ai search session.
無法創建 ai �索工作階段。
Search task cancelled.
�索任務已�消。
Condition
File name contains "%1"
檔�包�「%1�
File name without "%1"
�帶「%1�的檔�
File type contains "%1"
檔案類型包�「%1�
By suffix
按後綴
Folder
資料夾
Plain Text
純文本
WPS Document
WPS文件
PDF
PDFæ ¼å¼�
Image
圖�
Video
è¦–é »
Audio
音訊
File type contains %1
檔案類型包� %1
All
都
Empty(0K)
空(0K)
Tiny(0-16K)
�型(0-16K)
Small(16K-1M)
�號(16K-1M)
Medium(1M-128M)
ä¸åž‹ï¼ˆ1M-128M)
Big(128M-1G)
大(128M-1G)
Large(1-4G)
大號(1-4G)
Great(>4G)
很棒(>4G)
File size contains %1
檔案大�包� %1
File size without %1
檔案大�(�� %1)
File content match %1
檔案內容匹� %1
File location contains "%1"
檔案�置包�「%1�
File location without "%1"
沒有%1 的檔案�置
Later than "%1"
晚於“%1�
Earlier than "%1"
早於“%1�
DatabaseManager
New Space %1
新空間 %1
File %1 has areally been added to %2
檔案 %1 å·²çœŸæ£æ·»åŠ åˆ° %2
File %1 doesn't exsit in any space.
檔案 %1 ä¸�æœƒåœ¨ä»»ä½•ç©ºé–“ä¸æ¶ˆå¤±ã€‚
Failed to get space %1's id from query
無法從查詢ä¸ç�²å�–空間 %1 çš„ ID
Failed to get %1's id from query
無法從查詢ä¸ç�²å�– %1 çš„ ID
ModelController
Failed to rename space %1 to %2, %2 is existed.
無法將空間 %1 é‡�新命å��為 %2,å˜åœ¨ %2。
Failed to remove space %1, error message: %2
無法刪除空間 %1,錯誤訊�:%2
New Space %1
新空間 %1
Failed to updatestatus space %1, error message: %2
無法更新狀態空間 %1,錯誤訊�:%2
QObject
%1 %2
%1 %2
Intelligent Data Manager Introduction
智能數據管�員介紹
peony-intelligent-data-management-service
牡丹智能數據管��務
exit
退出
UKUI::IDM::FileInfoJob
Create Date: %1
創建日期:%1
Open Date: %1
開放日期:%1
././@LongLink 0000644 0000000 0000000 00000000156 00000000000 011605 L ustar root root peony-extensions/peony-intelligent-data-management-service/peony-intelligent-data-management-service_zh_CN.ts peony-extensions/peony-intelligent-data-management-service/peony-intelligent-data-management-service0000664 0001750 0001750 00000021305 15257160277 033241 0 ustar feng feng
AISearchTask
Failed to create ai search session.
Search task cancelled.
Condition
File name contains "%1"
File name without "%1"
File type contains "%1"
By suffix
Folder
Plain Text
WPS Document
PDF
Image
Video
Audio
File type contains %1
All
Empty(0K)
Tiny(0-16K)
Small(16K-1M)
Medium(1M-128M)
Big(128M-1G)
Large(1-4G)
Great(>4G)
File size contains %1
File size without %1
File content match %1
File location contains "%1"
File location without "%1"
Later than "%1"
Earlier than "%1"
DatabaseManager
New Space %1
新建空间 %1
File %1 has areally been added to %2
File %1 doesn't exsit in any space.
Failed to get space %1's id from query
Failed to get %1's id from query
ModelController
Failed to rename space %1 to %2, %2 is existed.
Failed to remove space %1, error message: %2
New Space %1
新建空间 %1
Failed to updatestatus space %1, error message: %2
QObject
%1 %2
Intelligent Data Manager Introduction
智能空间介�
exit
UKUI::IDM::FileInfoJob
Create Date: %1
Open Date: %1
peony-extensions/peony-intelligent-data-management-service/search/ 0000775 0001750 0001750 00000000000 15257160277 024435 5 ustar feng feng peony-extensions/peony-intelligent-data-management-service/search/searchtask.h 0000664 0001750 0001750 00000006327 15257160277 026746 0 ustar feng feng /*
* UKUI Intelligent Data Manager
*
* Copyright (C) 2024, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: Yue Lan
*
*/
#ifndef SEARCHTASK_H
#define SEARCHTASK_H
#include
#include
#include
#include
#include "condition/condition.h"
#include "file/fileinfo.h"
#include
#include
#define SEARCH_LOAD_BATCH 100
class QReadWriteLock;
namespace UKUI {
namespace IDM {
class FileInfo;
}
}
class SearchTask : public QObject
{
friend class SearchResultModel;
friend class ModelController;
Q_OBJECT
public:
explicit SearchTask(QObject *parent = nullptr);
void setSpaceId(int spaceId);
~SearchTask();
const QVariant &getConditionsDescription() const;
void setConditionsDescription(const QVariant &newConditionsDescription);
QStringList getLabels();
void updateSearchDirs();
void setSearchPath(const QString path);
void setNeedSearchFile(bool flag);
Q_SIGNALS:
void conditionsDescriptionChanged();
void searchFinished(bool successed);
void searchContentFinished(bool successed);
void searchWithLabelsFinished(bool successed);
void finished();
void fileReload(QString uri, QString modified, QString filetype,QString size);
void searchLoadBatch(bool finish);
public Q_SLOTS:
void start();
void cancel();
void handleCancelWithSpaceId(int spaceId);
protected:
void handleSearchResult();
private:
UkuiSearch::UkuiSearchTask *ukuiSearchTask;
UkuiSearch::DataQueue *queue;
UkuiSearch::UkuiSearchTask *ukuiSearchContentTask;
UkuiSearch::DataQueue *contentQueue;
QList> resultInfos;
QList> contentResultInfos;
QDBusInterface* m_interface;
bool needSearchFile = false;
bool needSearchFileContent = false;
bool hasContentSearchAndCondition = false;
bool searchDone = false;
bool searchContentDone = false;
bool cancelled = false;
int spaceId = -1;
QReadWriteLock rwlock;
QVariant conditionsDescription;
QList> conditions;
QList> andConditions;
QList> orConditions;
QStringList labels;
QStringList indexDirs;
QSet filesMatchedWithLabels;
QString currentSearchpath;
QString m_searchKeyword;
Q_PROPERTY(QVariant conditionsDescription READ getConditionsDescription WRITE setConditionsDescription NOTIFY conditionsDescriptionChanged)
};
#endif // SEARCHTASK_H
peony-extensions/peony-intelligent-data-management-service/search/searchtask.cpp 0000664 0001750 0001750 00000036037 15257160277 027302 0 ustar feng feng /*
* UKUI Intelligent Data Manager
*
* Copyright (C) 2025, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: JinQin He
*
*/
#include "searchtask.h"
#include "condition/condition.h"
#include "file/fileinfojob.h"
#include "model/modelcontroller.h"
#include "ai/ailabelhelper.h"
#include
#include
#include
#include
#include
#include
SearchTask::SearchTask(QObject *parent)
: QObject{parent}
{
m_interface = new QDBusInterface("com.ukui.search.fileindex.service",
"/org/ukui/search/privateDirWatcher",
"org.ukui.search.fileindex",
QDBusConnection::sessionBus(),
this);
// 检查�务是��用
if (!m_interface->isValid()) {
qWarning() << "DBus interface not valid:" << QDBusConnection::sessionBus().lastError().message();
}
ukuiSearchTask = new UkuiSearch::UkuiSearchTask;
ukuiSearchTask->setInformNum(100);
ukuiSearchTask->setMaxResultNum();
ukuiSearchTask->initSearchPlugin(UkuiSearch::SearchProperty::SearchType::File);
queue = ukuiSearchTask->init();
connect(ukuiSearchTask, &UkuiSearch::UkuiSearchTask::searchError, this, [=](){
Q_EMIT searchFinished(false);
});
connect(ukuiSearchTask, &UkuiSearch::UkuiSearchTask::reachInformNum, this, &SearchTask::handleSearchResult);
connect(ukuiSearchTask, &UkuiSearch::UkuiSearchTask::searchFinished, this, [=](){
qInfo() <<"finish search keyword:=="<setInformNum(100);
ukuiSearchContentTask->setMaxResultNum();
ukuiSearchContentTask->initSearchPlugin(UkuiSearch::SearchProperty::SearchType::FileContent);
contentQueue = ukuiSearchContentTask->init();
connect(ukuiSearchContentTask, &UkuiSearch::UkuiSearchTask::searchError, this, [=](size_t searchId, QString msg){
qCritical() << "search content failed," << searchId << msg;
Q_EMIT searchContentFinished(false);
searchContentDone = true;
if (searchDone || !needSearchFile) {
if (!cancelled)
Q_EMIT finished();
}
});
connect(ukuiSearchContentTask, &UkuiSearch::UkuiSearchTask::reachInformNum, this, &SearchTask::handleSearchResult);
connect(ukuiSearchContentTask, &UkuiSearch::UkuiSearchTask::searchFinished, this, [=](){
handleSearchResult();
searchContentDone = true;
Q_EMIT searchContentFinished(true);
if (searchDone || !needSearchFile) {
if (!cancelled)
Q_EMIT finished();
}
});
}
void SearchTask::setSpaceId(int spaceId)
{
this->spaceId = spaceId;
}
SearchTask::~SearchTask()
{
ukuiSearchTask->stop();
queue->clear();
delete ukuiSearchTask;
ukuiSearchContentTask->stop();
contentQueue->clear();
delete ukuiSearchContentTask;
resultInfos.clear();
contentResultInfos.clear();
}
const QVariant &SearchTask::getConditionsDescription() const
{
return conditionsDescription;
}
void SearchTask::setConditionsDescription(const QVariant &newConditionsDescription)
{
if (conditionsDescription == newConditionsDescription)
return;
needSearchFile = false;
needSearchFileContent = true;
hasContentSearchAndCondition = false;
conditionsDescription = newConditionsDescription;
auto newConditions = Condition::generateContitionsFromDescription(newConditionsDescription);
auto newLabels = Condition::getLabelsFromDescription(newConditionsDescription);
rwlock.lockForWrite();
andConditions.clear();
orConditions.clear();
conditions = newConditions;
labels = newLabels;
if (ukuiSearchTask->isSearching(UkuiSearch::SearchProperty::SearchType::File)) {
ukuiSearchTask->stop();
}
ukuiSearchTask->clearAllConditions();
if (ukuiSearchContentTask->isSearching(UkuiSearch::SearchProperty::SearchType::FileContent)) {
ukuiSearchContentTask->stop();
}
ukuiSearchContentTask->clearAllConditions();
UkuiSearch::SearchResultProperties properties = {UkuiSearch::SearchProperty::FilePath};
bool hasDateRangeCondition = false;
bool hasSearchLocationCondition = false;
updateSearchDirs();
int FileNameIndex = -1;
int i = 0;
for (auto condition : conditions) {
bool shouldAddCondition = true;
switch (condition->type()) {
case Condition::FileName: {
auto keywords = condition->getFileNameKeywords();
FileNameIndex = i;
if (keywords.isEmpty()) {
shouldAddCondition = false;
break;
}else{
m_searchKeyword = keywords.at(0);
}
if (condition->getFileNameIsContains()) {
needSearchFile = true;
for (auto keyword : keywords) {
ukuiSearchTask->addKeyword(keyword);
}
}
else{
needSearchFile = true;
#ifdef UKUI_SEARCH_HAS_MATCH_ALL
ukuiSearchTask->setMatchAllIfNoKeyword(true);
#endif
}
break;
}
case Condition::FileSize:
case Condition::FileType: {
needSearchFile = true;
#ifdef UKUI_SEARCH_HAS_MATCH_ALL
ukuiSearchTask->setMatchAllIfNoKeyword(true);
#endif
break;
}
case Condition::FileContent: {
auto contentKeyword = condition->getFileContentContent();
if (contentKeyword.isEmpty()) {
shouldAddCondition = false;
break;
}
if (condition->isAndCondition()) {
hasContentSearchAndCondition = true;
}
needSearchFileContent = true;
ukuiSearchContentTask->addKeyword(condition->getFileContentContent());
break;
}
case Condition::SearchLocation: {
auto path = condition->getSearchLocationPath();
if (path.isEmpty()) {
shouldAddCondition = false;
break;
}
needSearchFile = true;
//ukuiSearchTask->setMatchAllIfNoKeyword(true);
if (condition->getSearchLocationIsContains()) {
ukuiSearchTask->addSearchDir(path);
ukuiSearchContentTask->addSearchDir(path);
}
break;
}
case Condition::DateRange: {
// åœ¨çº¿ç¨‹ä¸æŸ¥è¯¢æ—¶é—´ä¿¡æ�¯
needSearchFile = true;
#ifdef UKUI_SEARCH_HAS_MATCH_ALL
ukuiSearchTask->setMatchAllIfNoKeyword(true);
#endif
hasDateRangeCondition = true;
break;
}
case Condition::ConditionMatchRule: {
needSearchFile = true;
needSearchFileContent = condition->getConditionMatchRule()==0?true:false;
break;
}
default:
break;
}
if (condition->isAndCondition()) {
andConditions << condition;
} else {
orConditions << condition;
}
i++;
}
if(needSearchFileContent && FileNameIndex !=-1){
auto nameCondition = conditions[FileNameIndex];
auto keywords = nameCondition->getFileNameKeywords();
ukuiSearchContentTask->addKeyword(keywords.first());
}
if (hasContentSearchAndCondition) {
// 如果包å�«äº†ä¸Žé€»è¾‘çš„æ–‡ä»¶å†…å®¹å…³é”®å—æ�¡ä»¶ï¼Œåˆ™ä¸�进行文件å��æ�œç´¢
needSearchFile = false;
}
rwlock.unlock();
// æ ¹æ�®æ�¡ä»¶å¯¹æ�œç´¢task进行设置
if (hasDateRangeCondition)
properties.append(UkuiSearch::SearchProperty::ModifiedTime);
ukuiSearchTask->setResultProperties(UkuiSearch::SearchProperty::SearchType::File, properties);
ukuiSearchContentTask->setResultProperties(UkuiSearch::SearchProperty::SearchType::FileContent, properties);
ukuiSearchTask->setRecurse(true);
ukuiSearchContentTask->setRecurse(true);
// 清空旧�件的结果
queue->clear();
contentQueue->clear();
resultInfos.clear();
contentResultInfos.clear();
Q_EMIT conditionsDescriptionChanged();
}
QStringList SearchTask::getLabels()
{
return labels;
}
void SearchTask::start()
{
cancelled = false;
filesMatchedWithLabels.clear();
// 如果�件�完全,比如文件��件未设置文件�,�索路径未设置路径,则�需�执行�索
if (!needSearchFile && !needSearchFileContent && labels.isEmpty()) {
if (!cancelled)
Q_EMIT finished();
return;
}
if (!labels.isEmpty()) {
bool basicConditionsOnlyHasSearchLocation = true;
for (auto condition : andConditions) {
if (condition->type() != Condition::SearchLocation) {
basicConditionsOnlyHasSearchLocation = false;
}
}
for (auto condition : orConditions) {
if (condition->type() != Condition::SearchLocation) {
basicConditionsOnlyHasSearchLocation = false;
}
}
// fixmeæ ‡ç¾æ�œç´¢å¼‚æ¥å®žçŽ°ï¼Œå¹¶ä¸”å’Œæ–‡ä»¶ä»¥å�Šå†…容æ�œç´¢å�–交集
AILabelHelper helper;
QStringList files = helper.getFilesByLabels(labels);
filesMatchedWithLabels = QSet(files.begin(), files.end());
if (!needSearchFile && !needSearchFileContent || basicConditionsOnlyHasSearchLocation) {
for (auto path : filesMatchedWithLabels) {
auto info = UKUI::IDM::FileInfo::fromPath(path);
contentResultInfos << info;
}
Q_EMIT finished();
}
}
qInfo() <<"start search keyword:=="<startSearch(UkuiSearch::SearchProperty::SearchType::File);
if (needSearchFileContent)
ukuiSearchContentTask->startSearch(UkuiSearch::SearchProperty::SearchType::FileContent);
}
void SearchTask::cancel()
{
cancelled = true;
if (needSearchFile)
ukuiSearchTask->stop();
if (needSearchFileContent)
ukuiSearchContentTask->stop();
resultInfos.clear();
contentResultInfos.clear();
}
void SearchTask::handleCancelWithSpaceId(int spaceId)
{
if (spaceId == this->spaceId) {
cancel();
deleteLater();
}
}
void SearchTask::handleSearchResult()
{
while (!queue->isEmpty()) {
if(cancelled){
return;
}
auto item = queue->dequeue();
QString path = item.getValue(UkuiSearch::SearchProperty::FilePath).toString();
if (!labels.isEmpty()) {
if (!filesMatchedWithLabels.contains(path))
continue;
}
QVariant timeVar = item.getValue(UkuiSearch::SearchProperty::ModifiedTime);
if (timeVar.isValid()) {
QDateTime modificationTimeDate = timeVar.toDateTime();
// fixme: åˆ¤æ–æ—¥æœŸç›¸å…³æ�¡ä»¶
}
// fixme: 判æ–大å°�相关æ�¡ä»¶
// fixme: 判æ–类型相关æ�¡ä»¶
if (spaceId >= 0) {
QFileInfo fileinfo(path);
if (UKUI::IDM::FileInfoJob::infoMatchCondtions(fileinfo, andConditions, orConditions)) {
auto info = UKUI::IDM::FileInfo::fromPath(path);
//ModelController::globalInstance()->fileReload(info->uri(),info->modifyDateString(),info->fileType(),info->sizeFormat());
resultInfos << info;
}
} else {
auto info = UKUI::IDM::FileInfo::fromPath(path);
resultInfos << info;
if(resultInfos.size() % SEARCH_LOAD_BATCH == 0){
Q_EMIT searchLoadBatch(false);
}
}
}
while (!contentQueue->isEmpty()) {
if(cancelled){
return;
}
auto item = contentQueue->dequeue();
QString path = item.getValue(UkuiSearch::SearchProperty::FilePath).toString();
if (!labels.isEmpty()) {
if (!filesMatchedWithLabels.contains(path))
continue;
}
QVariant timeVar = item.getValue(UkuiSearch::SearchProperty::ModifiedTime);
if (timeVar.isValid()) {
QDateTime modificationTimeDate = timeVar.toDateTime();
// fixme: åˆ¤æ–æ—¥æœŸç›¸å…³æ�¡ä»¶
}
// fixme: 判æ–大å°�相关æ�¡ä»¶
// fixme: 判æ–类型相关æ�¡ä»¶
if (spaceId >= 0) {
QFileInfo fileinfo(path);
//file content result don't need check filename condition
QList> realandConditions;
QList> realOrConditions;
for (auto condition:andConditions) {
if(condition->type()!= Condition::FileName){
realandConditions<type()!= Condition::FileName){
realOrConditions<clearSearchDir();
//ukuiSearchContentTask->clearSearchDir();
QDBusReply indexDirsRpl = m_interface->call("currentSearchDirs");
if (indexDirsRpl.isValid()) {
indexDirs = indexDirsRpl.value();
}
if(currentSearchpath.isEmpty()){
ukuiSearchTask->addSearchDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
ukuiSearchContentTask->addSearchDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
}
else{
ukuiSearchTask->addSearchDir(currentSearchpath);
ukuiSearchContentTask->addSearchDir(currentSearchpath);
}
// for (auto dir:indexDirs) {
// ukuiSearchTask->addSearchDir(dir);
// }
}
void SearchTask::setSearchPath(const QString path)
{
currentSearchpath = path;
}
void SearchTask::setNeedSearchFile(bool flag)
{
needSearchFile = flag;
}
peony-extensions/peony-intelligent-data-management-service/3rd-parties/ 0000775 0001750 0001750 00000000000 15257160264 025321 5 ustar feng feng peony-extensions/peony-intelligent-data-management-service/3rd-parties/qtlockedfile_unix.cpp 0000664 0001750 0001750 00000003054 15257160264 031540 0 ustar feng feng // Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
// SPDX-License-Identifier: BSD-3-Clause
#include
#include
#include
#include
#include "qtlockedfile.h"
bool QtLockedFile::lock(LockMode mode, bool block)
{
if (!isOpen()) {
qWarning("QtLockedFile::lock(): file is not opened");
return false;
}
if (mode == NoLock)
return unlock();
if (mode == m_lock_mode)
return true;
if (m_lock_mode != NoLock)
unlock();
struct flock fl;
fl.l_whence = SEEK_SET;
fl.l_start = 0;
fl.l_len = 0;
fl.l_type = (mode == ReadLock) ? F_RDLCK : F_WRLCK;
int cmd = block ? F_SETLKW : F_SETLK;
int ret = fcntl(handle(), cmd, &fl);
if (ret == -1) {
if (errno != EINTR && errno != EAGAIN)
qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno));
return false;
}
m_lock_mode = mode;
return true;
}
bool QtLockedFile::unlock()
{
if (!isOpen()) {
qWarning("QtLockedFile::unlock(): file is not opened");
return false;
}
if (!isLocked())
return true;
struct flock fl;
fl.l_whence = SEEK_SET;
fl.l_start = 0;
fl.l_len = 0;
fl.l_type = F_UNLCK;
int ret = fcntl(handle(), F_SETLKW, &fl);
if (ret == -1) {
qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno));
return false;
}
m_lock_mode = NoLock;
return true;
}
QtLockedFile::~QtLockedFile()
{
if (isOpen())
unlock();
}
peony-extensions/peony-intelligent-data-management-service/3rd-parties/qtlocalpeer.h 0000664 0001750 0001750 00000001445 15257160264 030011 0 ustar feng feng // Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
// SPDX-License-Identifier: BSD-3-Clause
#ifndef QTLOCALPEER_H
#define QTLOCALPEER_H
#include
#include
#include
#include "qtlockedfile.h"
class QtLocalPeer : public QObject
{
Q_OBJECT
public:
QtLocalPeer(QObject *parent = 0, const QString &appId = QString());
bool isClient();
bool sendMessage(const QString &message, int timeout);
QString applicationId() const
{ return id; }
Q_SIGNALS:
void messageReceived(const QString &message);
protected Q_SLOTS:
void receiveConnection();
protected:
QString id;
QString socketName;
QLocalServer* server;
QtLP_Private::QtLockedFile lockFile;
private:
static const char* ack;
};
#endif // QTLOCALPEER_H
peony-extensions/peony-intelligent-data-management-service/3rd-parties/qtlocalpeer.cpp 0000664 0001750 0001750 00000011747 15257160264 030352 0 ustar feng feng // Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
// SPDX-License-Identifier: BSD-3-Clause
#include "qtlocalpeer.h"
#include
#include
#include
#include
#if defined(Q_OS_WIN)
#include
#include
typedef BOOL(WINAPI*PProcessIdToSessionId)(DWORD,DWORD*);
static PProcessIdToSessionId pProcessIdToSessionId = 0;
#endif
#if defined(Q_OS_UNIX)
#include
#include
#include
#endif
namespace QtLP_Private {
#include "qtlockedfile.cpp"
#if defined(Q_OS_WIN)
#include "qtlockedfile_win.cpp"
#else
#include "qtlockedfile_unix.cpp"
#endif
}
const char* QtLocalPeer::ack = "ack";
QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId)
: QObject(parent), id(appId)
{
QString prefix = id;
if (id.isEmpty()) {
id = QCoreApplication::applicationFilePath();
#if defined(Q_OS_WIN)
id = id.toLower();
#endif
prefix = id.section(QLatin1Char('/'), -1);
}
prefix.remove(QRegularExpression("[^a-zA-Z]"));
prefix.truncate(6);
QByteArray idc = id.toUtf8();
quint16 idNum = qChecksum(idc.constData(), idc.size());
socketName = QLatin1String("qtsingleapp-") + prefix
+ QLatin1Char('-') + QString::number(idNum, 16);
#if defined(Q_OS_WIN)
if (!pProcessIdToSessionId) {
QLibrary lib("kernel32");
pProcessIdToSessionId = (PProcessIdToSessionId)lib.resolve("ProcessIdToSessionId");
}
if (pProcessIdToSessionId) {
DWORD sessionId = 0;
pProcessIdToSessionId(GetCurrentProcessId(), &sessionId);
socketName += QLatin1Char('-') + QString::number(sessionId, 16);
}
#else
socketName += QLatin1Char('-') + QString::number(::getuid(), 16);
#endif
server = new QLocalServer(this);
QString lockName = QDir(QDir::tempPath()).absolutePath()
+ QLatin1Char('/') + socketName
+ QLatin1String("-lockfile");
lockFile.setFileName(lockName);
lockFile.open(QIODevice::ReadWrite);
}
bool QtLocalPeer::isClient()
{
if (lockFile.isLocked())
return false;
if (!lockFile.lock(QtLP_Private::QtLockedFile::WriteLock, false))
return true;
bool res = server->listen(socketName);
#if defined(Q_OS_UNIX) && (QT_VERSION >= QT_VERSION_CHECK(4,5,0))
// ### Workaround
if (!res && server->serverError() == QAbstractSocket::AddressInUseError) {
QFile::remove(QDir::cleanPath(QDir::tempPath())+QLatin1Char('/')+socketName);
res = server->listen(socketName);
}
#endif
if (!res)
qWarning("QtSingleCoreApplication: listen on local socket failed, %s", qPrintable(server->errorString()));
QObject::connect(server, SIGNAL(newConnection()), SLOT(receiveConnection()));
return false;
}
bool QtLocalPeer::sendMessage(const QString &message, int timeout)
{
if (!isClient())
return false;
QLocalSocket socket;
bool connOk = false;
for(int i = 0; i < 2; i++) {
// Try twice, in case the other instance is just starting up
socket.connectToServer(socketName);
connOk = socket.waitForConnected(timeout/2);
if (connOk || i)
break;
int ms = 250;
#if defined(Q_OS_WIN)
Sleep(DWORD(ms));
#else
struct timespec ts = { ms / 1000, (ms % 1000) * 1000 * 1000 };
nanosleep(&ts, NULL);
#endif
}
if (!connOk)
return false;
QByteArray uMsg(message.toUtf8());
QDataStream ds(&socket);
ds.writeBytes(uMsg.constData(), uMsg.size());
bool res = socket.waitForBytesWritten(timeout);
if (res) {
res &= socket.waitForReadyRead(timeout); // wait for ack
if (res)
res &= (socket.read(qstrlen(ack)) == ack);
}
return res;
}
void QtLocalPeer::receiveConnection()
{
QLocalSocket* socket = server->nextPendingConnection();
if (!socket)
return;
while (true) {
if (socket->state() == QLocalSocket::UnconnectedState) {
qWarning("QtLocalPeer: Peer disconnected");
delete socket;
return;
}
if (socket->bytesAvailable() >= qint64(sizeof(quint32)))
break;
socket->waitForReadyRead();
}
QDataStream ds(socket);
QByteArray uMsg;
quint32 remaining;
ds >> remaining;
uMsg.resize(remaining);
int got = 0;
char* uMsgBuf = uMsg.data();
do {
got = ds.readRawData(uMsgBuf, remaining);
remaining -= got;
uMsgBuf += got;
} while (remaining && got >= 0 && socket->waitForReadyRead(2000));
if (got < 0) {
qWarning("QtLocalPeer: Message reception failed %s", socket->errorString().toLatin1().constData());
delete socket;
return;
}
QString message(QString::fromUtf8(uMsg));
socket->write(ack, qstrlen(ack));
socket->waitForBytesWritten(1000);
socket->waitForDisconnected(1000); // make sure client reads ack
delete socket;
Q_EMIT messageReceived(message); //### (might take a long time to return)
}
peony-extensions/peony-intelligent-data-management-service/3rd-parties/qtsinglecoreapplication.h 0000664 0001750 0001750 00000001265 15257160264 032421 0 ustar feng feng // Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
// SPDX-License-Identifier: BSD-3-Clause
#ifndef QTSINGLECOREAPPLICATION_H
#define QTSINGLECOREAPPLICATION_H
#include
class QtLocalPeer;
class QtSingleCoreApplication : public QCoreApplication
{
Q_OBJECT
public:
QtSingleCoreApplication(int &argc, char **argv);
QtSingleCoreApplication(const QString &id, int &argc, char **argv);
bool isRunning();
QString id() const;
public Q_SLOTS:
bool sendMessage(const QString &message, int timeout = 5000);
Q_SIGNALS:
void messageReceived(const QString &message);
private:
QtLocalPeer* peer;
};
#endif // QTSINGLECOREAPPLICATION_H
peony-extensions/peony-intelligent-data-management-service/3rd-parties/qtlockedfile.cpp 0000664 0001750 0001750 00000010202 15257160264 030466 0 ustar feng feng // Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
// SPDX-License-Identifier: BSD-3-Clause
#include "qtlockedfile.h"
/*!
\class QtLockedFile
\brief The QtLockedFile class extends QFile with advisory locking
functions.
A file may be locked in read or write mode. Multiple instances of
\e QtLockedFile, created in multiple processes running on the same
machine, may have a file locked in read mode. Exactly one instance
may have it locked in write mode. A read and a write lock cannot
exist simultaneously on the same file.
The file locks are advisory. This means that nothing prevents
another process from manipulating a locked file using QFile or
file system functions offered by the OS. Serialization is only
guaranteed if all processes that access the file use
QLockedFile. Also, while holding a lock on a file, a process
must not open the same file again (through any API), or locks
can be unexpectedly lost.
The lock provided by an instance of \e QtLockedFile is released
whenever the program terminates. This is true even when the
program crashes and no destructors are called.
*/
/*! \enum QtLockedFile::LockMode
This enum describes the available lock modes.
\value ReadLock A read lock.
\value WriteLock A write lock.
\value NoLock Neither a read lock nor a write lock.
*/
/*!
Constructs an unlocked \e QtLockedFile object. This constructor
behaves in the same way as \e QFile::QFile().
\sa QFile::QFile()
*/
QtLockedFile::QtLockedFile()
: QFile()
{
#ifdef Q_OS_WIN
wmutex = 0;
rmutex = 0;
#endif
m_lock_mode = NoLock;
}
/*!
Constructs an unlocked QtLockedFile object with file \a name. This
constructor behaves in the same way as \e QFile::QFile(const
QString&).
\sa QFile::QFile()
*/
QtLockedFile::QtLockedFile(const QString &name)
: QFile(name)
{
#ifdef Q_OS_WIN
wmutex = 0;
rmutex = 0;
#endif
m_lock_mode = NoLock;
}
/*!
Opens the file in OpenMode \a mode.
This is identical to QFile::open(), with the one exception that the
Truncate mode flag is disallowed. Truncation would conflict with the
advisory file locking, since the file would be modified before the
write lock is obtained. If truncation is required, use resize(0)
after obtaining the write lock.
Returns true if successful; otherwise false.
\sa QFile::open(), QFile::resize()
*/
bool QtLockedFile::open(OpenMode mode)
{
if (mode & QIODevice::Truncate) {
qWarning("QtLockedFile::open(): Truncate mode not allowed.");
return false;
}
return QFile::open(mode);
}
/*!
Returns \e true if this object has a in read or write lock;
otherwise returns \e false.
\sa lockMode()
*/
bool QtLockedFile::isLocked() const
{
return m_lock_mode != NoLock;
}
/*!
Returns the type of lock currently held by this object, or \e
QtLockedFile::NoLock.
\sa isLocked()
*/
QtLockedFile::LockMode QtLockedFile::lockMode() const
{
return m_lock_mode;
}
/*!
\fn bool QtLockedFile::lock(LockMode mode, bool block = true)
Obtains a lock of type \a mode. The file must be opened before it
can be locked.
If \a block is true, this function will block until the lock is
aquired. If \a block is false, this function returns \e false
immediately if the lock cannot be aquired.
If this object already has a lock of type \a mode, this function
returns \e true immediately. If this object has a lock of a
different type than \a mode, the lock is first released and then a
new lock is obtained.
This function returns \e true if, after it executes, the file is
locked by this object, and \e false otherwise.
\sa unlock(), isLocked(), lockMode()
*/
/*!
\fn bool QtLockedFile::unlock()
Releases a lock.
If the object has no lock, this function returns immediately.
This function returns \e true if, after it executes, the file is
not locked by this object, and \e false otherwise.
\sa lock(), isLocked(), lockMode()
*/
/*!
\fn QtLockedFile::~QtLockedFile()
Destroys the \e QtLockedFile object. If any locks were held, they
are released.
*/
peony-extensions/peony-intelligent-data-management-service/3rd-parties/qtlockedfile_win.cpp 0000664 0001750 0001750 00000011121 15257160264 031344 0 ustar feng feng // Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
// SPDX-License-Identifier: BSD-3-Clause
#include "qtlockedfile.h"
#include