Skip to content

Commit

Permalink
chore: Merge branch 'master' into develop/snipe
Browse files Browse the repository at this point in the history
From 725e5ea
to 00abfeb

Log: Merge 'master' branch
  • Loading branch information
rb-union committed Jun 17, 2024
2 parents 0f16994 + 00abfeb commit b90acd6
Show file tree
Hide file tree
Showing 78 changed files with 2,593 additions and 1,527 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/call-debian-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: debianCheck
on:
pull_request_target:
types: [opened, synchronize, reopened]

permissions:
pull-requests: write
contents: read
checks: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
debian-check:
uses: linuxdeepin/.github/.github/workflows/debian-check.yml@master
with:
job_name: "debian-check"

Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,16 @@
<arg type="a{sv}" direction="out"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
</method>
<method name="SaveRedoOperations">
<arg name="values" type="a{sv}" direction="in"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QVariantMap"/>
</method>
<method name="RevocationRedoOperations">
<arg type="a{sv}" direction="out"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
</method>
<method name="CleanOperationsByUrl">
<arg name="urls" type="as" direction="in"/>
</method>
</interface>
</node>
3 changes: 3 additions & 0 deletions assets/dbus/org.freedesktop.FileManager1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@
<method name="Trash">
<arg name="URIs" type="as" direction="in"/>
</method>
<method name="Open">
<arg name="Args" type="as" direction="in"/>
</method>
</interface>
</node>
21 changes: 11 additions & 10 deletions assets/scripts/dde-file-manager
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later

f="${1#file://}"
args=""
for arg in "$@"; do
args+="$arg,"
done

# dde-file-manager --show-item xxx
if [[ "$1" == "--show-item" ]]; then
dbus-send --print-reply --dest=org.freedesktop.FileManager1 /org/freedesktop/FileManager1 org.freedesktop.FileManager1.ShowItems "array:string:${@:2}" "string:"
# dde-file-manager /path/to/xxx or file:///path/to/xxx
elif [ -e "$f" ]; then
dbus-send --print-reply --dest=org.freedesktop.FileManager1 /org/freedesktop/FileManager1 org.freedesktop.FileManager1.ShowItems "array:string:$f" "string:"
else
exec /usr/libexec/dde-file-manager "$@"
fi
args=${args%,}

dbus-send --print-reply --dest=org.freedesktop.FileManager1 /org/freedesktop/FileManager1 org.freedesktop.FileManager1.Open array:string:"$args"

if [ $? -ne 0 ]; then
echo "dbus call failed"
exec file-manager.sh "$@"
fi
3 changes: 3 additions & 0 deletions include/dfm-base/dfm_event_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ enum GlobalEventType {
kLoadPlugins,
kHeadlessStarted,
kShowSettingDialog,
kSaveRedoOperator, // save Ctrl+Z operator
kCleanSaveOperatorByUrls, // if file delete,clear all ops which contains url
kRedo, // Ctrl+Y

// request file operations
kOpenFiles = 200,
Expand Down
4 changes: 4 additions & 0 deletions include/dfm-base/interfaces/abstractjobhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class AbstractJobHandler : public QObject
kDontFormatFileName = 0x100, // 拷贝时不处理文件名称
kRevocation = 0x200, // 拷贝时不处理文件名称
kCopyRemote = 0x400, // 深信服远程拷贝
kRedo = 0x800, // 重新执行(ctrl + Y)
kCountProgressCustomize = 0x800, // 强制使用自己统计进度
};
Q_ENUM(JobFlag)
Expand Down Expand Up @@ -89,6 +90,8 @@ class AbstractJobHandler : public QObject
kFailedParseUrlOfTrash = 34, // 解析trash的url失败 Failed to parse the url of trash
kFailedObtainTrashOriginalFile = 35, // 获取trash中原文件失败 Failed to obtain the trash original file
kFileMoveToTrashError = 36, // 文件移动到回收站错误
kRetryReadOrWriteFailed = 37, // 重试失败
kCanNotAccessFile = 38, // 无法访问远程文件
kUnknowError = 255, // 未知错误
};
Q_ENUM(JobErrorType)
Expand Down Expand Up @@ -244,6 +247,7 @@ class AbstractJobHandler : public QObject
void requestShowTipsDialog(DFMBASE_NAMESPACE::AbstractJobHandler::ShowDialogType type, const QList<QUrl> list);
void workerFinish();
void requestRemoveTaskWidget();
void requestSaveRedoOperation(const QString &token, const qint64 deleteFirstFileSize);
Q_SIGNALS: // 发送给任务使用的信号
/*!
* \brief userAction 用户当前动作
Expand Down
7 changes: 6 additions & 1 deletion src/dfm-base/base/application/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ Settings *Application::dataPersistence()
void Application::appAttributeTrigger(TriggerAttribute ta)
{
switch (ta) {
case kRestoreViewMode:
case kRestoreViewMode: {
auto defaultViewMode = appAttribute(Application::kViewMode).toInt();
auto settings = appObtuselySetting();

Expand All @@ -304,6 +304,11 @@ void Application::appAttributeTrigger(TriggerAttribute ta)

if (instance())
Q_EMIT instance()->viewModeChanged(defaultViewMode);
break;
}
case kClearSearchHistory:
Q_EMIT instance()->clearSearchHistory();
break;
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/dfm-base/base/application/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ class Application : public QObject
Q_ENUM(GenericAttribute)

enum TriggerAttribute {
kRestoreViewMode // restore defualt view mode to all dir
kRestoreViewMode, // restore defualt view mode to all dir
kClearSearchHistory // clear search history
};

Q_ENUM(TriggerAttribute)
Expand Down Expand Up @@ -110,6 +111,7 @@ class Application : public QObject

void genericSettingCreated(Settings *settings);
void appSettingCreated(Settings *settings);
void clearSearchHistory();

protected:
Application(ApplicationPrivate *dd, QObject *parent = nullptr);
Expand Down
68 changes: 68 additions & 0 deletions src/dfm-base/base/device/deviceproxymanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
#include "devicemanager.h"
#include "deviceutils.h"
#include "private/deviceproxymanager_p.h"
#include <dfm-base/utils/finallyutil.h>

#include <QDBusServiceWatcher>
#include <QtConcurrent>

using namespace dfmbase;
static constexpr char kDeviceService[] { "org.deepin.filemanager.server" };
Expand Down Expand Up @@ -47,6 +49,20 @@ QStringList DeviceProxyManager::getAllBlockIdsByUUID(const QStringList &uuids, G
return devs;
}

QStringList DeviceProxyManager::asyncGetAllBlockIdsByUUID(const QStringList &uuids, GlobalServerDefines::DeviceQueryOptions opts)
{
const auto &&devices = getAllBlockIds(opts);
QStringList devs;
for (const auto &id : devices) {
const auto &&info = asyncQueryBlockInfo(id);
if (info.value("error", QVariant(false)).toBool())
return devs;
if (uuids.contains(info.value(GlobalServerDefines::DeviceProperty::kUUID).toString()))
devs << id;
}
return devs;
}

QStringList DeviceProxyManager::getAllProtocolIds()
{
if (d->isDBusRuning() && d->devMngDBus) {
Expand Down Expand Up @@ -80,6 +96,32 @@ QVariantMap DeviceProxyManager::queryProtocolInfo(const QString &id, bool reload
}
}

QVariantMap DeviceProxyManager::asyncQueryBlockInfo(const QString &id, bool reload)
{
if (d->isDBusRuning() && d->devMngDBus) {
auto fun = [=](const QString &id, bool reload) -> QDBusPendingReply<QVariantMap> {
DeviceManagerInterface devMngDBus(kDeviceService, kDevMngPath, QDBusConnection::sessionBus());
return devMngDBus.QueryBlockDeviceInfo(id, reload);
};
return d->asyncQueryInfo(id, reload, fun);
} else {
return queryBlockInfo(id, reload);
}
}

QVariantMap DeviceProxyManager::asyncQueryProtocolInfo(const QString &id, bool reload)

Check warning on line 112 in src/dfm-base/base/device/deviceproxymanager.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'asyncQueryProtocolInfo' is never used.
{
if (d->isDBusRuning() && d->devMngDBus) {
auto fun = [=](const QString &id, bool reload) -> QDBusPendingReply<QVariantMap> {
DeviceManagerInterface devMngDBus(kDeviceService, kDevMngPath, QDBusConnection::sessionBus());
return devMngDBus.QueryProtocolDeviceInfo(id, reload);
};
return d->asyncQueryInfo(id, reload, fun);
} else {
return queryProtocolInfo(id, reload);
}
}

void DeviceProxyManager::reloadOpticalInfo(const QString &id)
{
if (d->isDBusRuning() && d->devMngDBus)
Expand Down Expand Up @@ -345,6 +387,32 @@ void DeviceProxyManagerPrivate::disconnCurrentConnections()
currentConnectionType = kNoneConnection;
}

QVariantMap DeviceProxyManagerPrivate::asyncQueryInfo(const QString &id, bool reload, std::function<QDBusPendingReply<QVariantMap>(const QString&, bool)> func)
{
QEventLoop loop;
QFutureWatcher<QDBusPendingReply<QVariantMap>>* fw = new QFutureWatcher<QDBusPendingReply<QVariantMap>>;
FinallyUtil release([&] {
if (fw) {
delete fw;
fw = nullptr;
}
});
connect(fw, &QFutureWatcher<QDBusPendingReply<QVariantMap>>::finished, [&loop](){
loop.quit();
});
QFuture<QDBusPendingReply<QVariantMap>> ft =
QtConcurrent::run([id, reload, func](){
QDBusPendingReply<QVariantMap> reply = func(id, reload);
reply.waitForFinished();
return reply;
});
fw->setFuture(ft);
if (loop.exec()) {
return QVariantMap({{"error", true}});
}
return fw->result();
}

void DeviceProxyManagerPrivate::addMounts(const QString &id, const QString &mpt)
{
QString p = mpt.endsWith("/") ? mpt : mpt + "/";
Expand Down
3 changes: 3 additions & 0 deletions src/dfm-base/base/device/deviceproxymanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ class DeviceProxyManager : public QObject
// device info getter
QStringList getAllBlockIds(GlobalServerDefines::DeviceQueryOptions opts = GlobalServerDefines::DeviceQueryOption::kNoCondition);
QStringList getAllBlockIdsByUUID(const QStringList &uuids, GlobalServerDefines::DeviceQueryOptions opts = GlobalServerDefines::DeviceQueryOption::kNoCondition);
QStringList asyncGetAllBlockIdsByUUID(const QStringList &uuids, GlobalServerDefines::DeviceQueryOptions opts = GlobalServerDefines::DeviceQueryOption::kNoCondition);
QStringList getAllProtocolIds();
QVariantMap queryBlockInfo(const QString &id, bool reload = false);
QVariantMap queryProtocolInfo(const QString &id, bool reload = false);
QVariantMap asyncQueryBlockInfo(const QString &id, bool reload = false);
QVariantMap asyncQueryProtocolInfo(const QString &id, bool reload = false);

// device operation
void reloadOpticalInfo(const QString &id);
Expand Down
2 changes: 2 additions & 0 deletions src/dfm-base/base/device/private/deviceproxymanager_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class DeviceProxyManagerPrivate : public QObject
void connectToAPI();
void disconnCurrentConnections();

QVariantMap asyncQueryInfo(const QString &id, bool reload, std::function<QDBusPendingReply<QVariantMap>(const QString &, bool)> func);

private Q_SLOTS:
void addMounts(const QString &id, const QString &mpt);
void removeMounts(const QString &id);
Expand Down
2 changes: 2 additions & 0 deletions src/dfm-base/dialogs/taskdialog/taskwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ void TaskWidget::onButtonClicked()
AbstractJobHandler::SupportActions actions = obj->property(kBtnPropertyActionName).value<AbstractJobHandler::SupportAction>();
showConflictButtons(actions.testFlag(AbstractJobHandler::SupportAction::kPauseAction));
actions = chkboxNotAskAgain && chkboxNotAskAgain->isChecked() ? actions | AbstractJobHandler::SupportAction::kRememberAction : actions;
lbErrorMsg->setText("");
lbErrorMsg->hide();
emit buttonClicked(actions);
}
void TaskWidget::parentClose()
Expand Down
48 changes: 29 additions & 19 deletions src/dfm-base/file/local/localfilehandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ LocalFileHandler::~LocalFileHandler()
* \param url 新文件的url
* \return bool 创建文件是否成功
*/
bool LocalFileHandler::touchFile(const QUrl &url, const QUrl &tempUrl /*= QUrl()*/)
QUrl LocalFileHandler::touchFile(const QUrl &url, const QUrl &tempUrl /*= QUrl()*/)
{
QSharedPointer<DFMIO::DOperator> oper { new DFMIO::DOperator(url) };
if (!oper) {
qCWarning(logDFMBase) << "create operator failed, url: " << url;
return false;
return QUrl();
}

bool success = oper->touchFile();
Expand All @@ -82,21 +82,21 @@ bool LocalFileHandler::touchFile(const QUrl &url, const QUrl &tempUrl /*= QUrl()

d->setError(oper->lastError());

return false;
return QUrl();
} else { // fix bug 189699 When the iPhone creates a file, the gio is created successfully, but there is no file
auto info = InfoFactory::create<FileInfo>(url, Global::CreateFileInfoType::kCreateFileInfoSync);
if (!info || !info->exists()) {
d->lastError.setCode(DFMIOErrorCode::DFM_IO_ERROR_NOT_SUPPORTED);
return false;
return QUrl();
}
}

d->loadTemplateInfo(url, tempUrl);
auto templateUrl = d->loadTemplateInfo(url, tempUrl);
qCInfo(logDFMBase, "touchFile source file : %s, Template file %s, successed by dfmio function touchFile!",
url.path().toStdString().c_str(), tempUrl.path().toStdString().c_str());
FileUtils::notifyFileChangeManual(DFMGLOBAL_NAMESPACE::FileNotifyType::kFileAdded, url);

return true;
return templateUrl;
}
/*!
* \brief LocalFileHandler::mkdir 创建目录
Expand Down Expand Up @@ -970,24 +970,14 @@ QString LocalFileHandlerPrivate::getInternetShortcutUrl(const QString &path)
return url;
}

void LocalFileHandlerPrivate::loadTemplateInfo(const QUrl &url, const QUrl &templateUrl /*= QUrl()*/)
QUrl LocalFileHandlerPrivate::loadTemplateInfo(const QUrl &url, const QUrl &templateUrl /*= QUrl()*/)
{
QUrl templateFile = templateUrl;
if (!templateFile.isValid()) {

FileInfoPointer targetFileInfo { InfoFactory::create<FileInfo>(url, Global::CreateFileInfoType::kCreateFileInfoSync) };
const QString &suffix = targetFileInfo->suffix();

const QUrl &trashUrl { QUrl::fromLocalFile(StandardPaths::location(StandardPaths::kTemplatesPath)) };
DFMIO::DEnumerator enumerator(trashUrl,
{},
static_cast<DFMIO::DEnumerator::DirFilter>(static_cast<int32_t>(QDir::Files)),
DFMIO::DEnumerator::IteratorFlag::kNoIteratorFlags);
while (enumerator.hasNext()) {
if (enumerator.fileInfo()->attribute(DFMIO::DFileInfo::AttributeID::kStandardSuffix) == suffix) {
templateFile = enumerator.next();
break;
}
}
templateFile = loadTemplateUrl(suffix);
}

if (templateFile.isValid()) {
Expand All @@ -1001,7 +991,10 @@ void LocalFileHandlerPrivate::loadTemplateInfo(const QUrl &url, const QUrl &temp

FileInfoPointer fileInfo = InfoFactory::create<FileInfo>(url);
fileInfo->refresh();
} else {
templateFile = url;
}
return templateFile;
}

bool LocalFileHandlerPrivate::doOpenFile(const QUrl &url, const QString &desktopFile /*= QString()*/)
Expand Down Expand Up @@ -1226,6 +1219,23 @@ void LocalFileHandlerPrivate::setError(DFMIOError error)
lastError = error;
}

QUrl LocalFileHandlerPrivate::loadTemplateUrl(const QString &suffix)
{
QUrl templateFile;
const QUrl &tempdir { QUrl::fromLocalFile(StandardPaths::location(StandardPaths::kTemplatesPath)) };
DFMIO::DEnumerator enumerator(tempdir,
{},
static_cast<DFMIO::DEnumerator::DirFilter>(static_cast<int32_t>(QDir::Files)),
DFMIO::DEnumerator::IteratorFlag::kNoIteratorFlags);
while (enumerator.hasNext()) {
if (enumerator.fileInfo()->attribute(DFMIO::DFileInfo::AttributeID::kStandardSuffix) == suffix) {
templateFile = enumerator.next();
break;
}
}
return templateFile;
}

void LocalFileHandlerPrivate::asyncAddRecentFile(const QString &desktop, const QList<QString> urls, const QMap<QString, QString> &mimeTypes)

Check warning on line 1239 in src/dfm-base/file/local/localfilehandler.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Parameter 'urls' is passed by value. It could be passed as a const reference which is usually faster and recommended in C++.
{
QMutexLocker lk(&lock);
Expand Down
2 changes: 1 addition & 1 deletion src/dfm-base/file/local/localfilehandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class LocalFileHandler
LocalFileHandler();
~LocalFileHandler();

bool touchFile(const QUrl &url, const QUrl &tempUrl = QUrl());
QUrl touchFile(const QUrl &url, const QUrl &tempUrl = QUrl());
bool mkdir(const QUrl &dir);
bool rmdir(const QUrl &url);
bool renameFile(const QUrl &url, const QUrl &newUrl, const bool needCheck = true);
Expand Down
Loading

0 comments on commit b90acd6

Please sign in to comment.