#include <QDesktopServices>
#include <QtConcurrent>
-#include "accountmanager.h"
#include "editlocallymanager.h"
#include "folder.h"
#include "folderman.h"
return;
}
+ // Show the loading dialog but don't show the filename until we have
+ // verified the token
+ Systray::instance()->createEditFileLocallyLoadingDialog({});
+
// We check the input data locally first, without modifying any state or
// showing any potentially misleading data to the user
if (!isTokenValid(_token)) {
if (!_tokenVerified) {
showError(tr("Could not validate the request to open a file from server."), tr("Please try again."));
+ return;
}
proceedWithSetup();
_fileName = relPathSplit.last();
+ Systray::instance()->destroyEditFileLocallyLoadingDialog();
Q_EMIT setupFinished();
}
QString EditLocallyHandler::prefixSlashToPath(const QString &path)
{
- auto slashPrefixedPath = path;
- if (!slashPrefixedPath.startsWith('/')) {
- slashPrefixedPath.prepend('/');
- }
-
- return slashPrefixedPath;
+ return path.startsWith('/') ? path : QChar::fromLatin1('/') + path;
}
bool EditLocallyHandler::isTokenValid(const QString &token)
const QRegularExpression tokenRegex("^[a-zA-Z0-9]{128}$");
const auto regexMatch = tokenRegex.match(token);
- // Means invalid token type received, be cautious with bad token
- if(!regexMatch.hasMatch()) {
- return false;
- }
-
- return true;
+ return regexMatch.hasMatch();
}
bool EditLocallyHandler::isRelPathValid(const QString &relPath)
bool EditLocallyHandler::isRelPathExcluded(const QString &relPath)
{
if (relPath.isEmpty()) {
- return true;
+ return false;
}
const auto folderMap = FolderMan::instance()->map();
const auto excludedThroughSelectiveSync = folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, &result);
for (const auto &excludedPath : excludedThroughSelectiveSync) {
if (relPath.startsWith(excludedPath)) {
- return false;
+ return true;
}
}
}
- return true;
+ return false;
}
void EditLocallyHandler::showError(const QString &message, const QString &informativeText)
{
+ Systray::instance()->destroyEditFileLocallyLoadingDialog();
showErrorNotification(message, informativeText);
// to make sure the error is not missed, show a message box in addition
showErrorMessageBox(message, informativeText);
font.pixelSize: root.fontPixelSize
color: Style.ncTextColor
horizontalAlignment: Text.AlignHCenter
+ visible: root.fileName !== ""
}
Label {
id: labelMessage
Layout.alignment: Qt.AlignHCenter
Layout.fillWidth: true
Layout.bottomMargin: Style.standardSpacing
- text: qsTr("Opening for local editing")
+ text: qsTr("Opening file for local editing")
elide: Text.ElideRight
font.pixelSize: root.fontPixelSize
color: Style.ncTextColor