From ed5e9de9f61c7732081ab5ebd8f0d7c72967678c Mon Sep 17 00:00:00 2001 From: Kevin Ottens Date: Thu, 20 Aug 2020 14:53:14 +0200 Subject: [PATCH] Present sharing of E2EE files from the main dialog too The visibility of the share button for the activity list is tied to the path role in the ActivityListModel, so make sure we don't return a path for E2EE files and folders. Signed-off-by: Kevin Ottens --- src/gui/tray/ActivityListModel.cpp | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/gui/tray/ActivityListModel.cpp b/src/gui/tray/ActivityListModel.cpp index f6c9a1778..ddfbd6fcd 100644 --- a/src/gui/tray/ActivityListModel.cpp +++ b/src/gui/tray/ActivityListModel.cpp @@ -90,21 +90,36 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const return QString(); case PathRole: if (!a._file.isEmpty()) { - auto folder = FolderMan::instance()->folder(a._folder); + auto folder = FolderMan::instance()->folderForPath(a._folder); + QString relPath(a._file); if (folder) relPath.prepend(folder->remotePath()); list = FolderMan::instance()->findFileInLocalFolders(relPath, ast->account()); - if (list.count() > 0) { - return QUrl::fromLocalFile(list.at(0)); - } + // File does not exist anymore? Let's try to open its path - if (QFileInfo(relPath).exists()) { + if (list.isEmpty() && QFileInfo(relPath).exists()) { list = FolderMan::instance()->findFileInLocalFolders(QFileInfo(relPath).path(), ast->account()); - if (list.count() > 0) { - return QVariant(list.at(0)); + } + + if (list.isEmpty()) { + return QString(); + } + + const auto path = list.at(0); + folder = FolderMan::instance()->folderForPath(path); + + // If this is an E2EE file or folder, pretend we got no path, this leads to + // hiding the share button which is what we want + if (folder) { + SyncJournalFileRecord rec; + folder->journalDb()->getFileRecord(a._file.mid(1), &rec); + if (rec.isValid() && (rec._isE2eEncrypted || !rec._e2eMangledName.isEmpty())) { + return QString(); } } + + return QUrl::fromLocalFile(path); } return QString(); case AbsolutePathRole: { -- 2.30.2