Placeholder: The extension is now a branding option

This commit is contained in:
Olivier Goffart 2018-01-25 16:20:35 +01:00 committed by Kevin Ottens
parent a2bdd5b9a5
commit 91f53521ae
No known key found for this signature in database
GPG key ID: 074BBBCB8DECC9E2
14 changed files with 25 additions and 18 deletions

View file

@ -180,6 +180,8 @@ if(APPLE)
set( SOCKETAPI_TEAM_IDENTIFIER_PREFIX "" CACHE STRING "SocketApi prefix (including a following dot) that must match the codesign key's TeamIdentifier/Organizational Unit" )
endif()
set(OWNCLOUD_PLACEHOLDER_SUFFIX ".owncloud" CACHE STRING "Placeholder suffix (must start with a .)")
if(BUILD_CLIENT)
if(APPLE AND BUILD_UPDATER)
find_package(Sparkle)

View file

@ -26,6 +26,7 @@
#cmakedefine APPLICATION_WIZARD_HEADER_BACKGROUND_COLOR "@APPLICATION_WIZARD_HEADER_BACKGROUND_COLOR@"
#cmakedefine APPLICATION_WIZARD_HEADER_TITLE_COLOR "@APPLICATION_WIZARD_HEADER_TITLE_COLOR@"
#cmakedefine APPLICATION_WIZARD_USE_CUSTOM_LOGO "@APPLICATION_WIZARD_USE_CUSTOM_LOGO@"
#cmakedefine OWNCLOUD_PLACEHOLDER_SUFFIX "@OWNCLOUD_PLACEHOLDER_SUFFIX@"
#cmakedefine ZLIB_FOUND @ZLIB_FOUND@

View file

@ -8,7 +8,7 @@ GenericName=Folder Sync
Icon=@APPLICATION_ICON_NAME@
Keywords=@APPLICATION_NAME@;syncing;file;sharing;
X-GNOME-Autostart-Delay=3
MimeType=application/x-owncloud
MimeType=application/x-@APPLICATION_EXECUTABLE@
# Translations

View file

@ -215,7 +215,7 @@ struct OCSYNC_EXPORT csync_s {
/**
* The suffix to use for placeholder files.
*/
QByteArray placeholder_suffix = ".owncloud";
QByteArray placeholder_suffix;
csync_s(const char *localUri, OCC::SyncJournalDb *statedb);
~csync_s();

View file

@ -431,8 +431,8 @@ if(NOT BUILD_OWNCLOUD_OSX_BUNDLE AND NOT WIN32)
${CMAKE_CURRENT_BINARY_DIR}/${LINUX_APPLICATION_ID}.desktop)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${LINUX_APPLICATION_ID}.desktop DESTINATION ${DATADIR}/applications )
#FIXME! branding
install(FILES owncloud.xml DESTINATION ${DATADIR}/mime/packages )
configure_file(owncloud.xml.in ${APPLICATION_EXECUTABLE}.xml)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${APPLICATION_EXECUTABLE}.xml DESTINATION ${DATADIR}/mime/packages )
find_package(ECM 1.2.0 CONFIG)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

View file

@ -499,7 +499,7 @@ void Application::parseOptions(const QStringList &options)
_backgroundMode = true;
} else if (option == QLatin1String("--version") || option == QLatin1String("-v")) {
_versionOnly = true;
} else if (option.endsWith(".owncloud")) {
} else if (option.endsWith(QStringLiteral(OWNCLOUD_PLACEHOLDER_SUFFIX))) {
// placeholder file, open it after the Folder were created (if the app is not terminated)
QTimer::singleShot(0, this, [this, option] { openPlaceholder(option); });
} else {
@ -679,7 +679,7 @@ void Application::slotGuiIsShowingSettings()
void Application::openPlaceholder(const QString &filename)
{
QLatin1String placeholderExt(".owncloud");
QString placeholderExt = QStringLiteral(OWNCLOUD_PLACEHOLDER_SUFFIX);
if (!filename.endsWith(placeholderExt)) {
qWarning(lcApplication) << "Can only handle file ending in .owncloud. Unable to open" << filename;
return;

View file

@ -715,6 +715,7 @@ void Folder::setSyncOptions()
opt._confirmExternalStorage = cfgFile.confirmExternalStorage();
opt._moveFilesToTrash = cfgFile.moveToTrash();
opt._newFilesArePlaceholders = _definition.usePlaceholders;
opt._placeholderSuffix = QStringLiteral(OWNCLOUD_PLACEHOLDER_SUFFIX);
QByteArray chunkSizeEnv = qgetenv("OWNCLOUD_CHUNK_SIZE");
if (!chunkSizeEnv.isEmpty()) {

View file

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="application/x-owncloud">
<comment>ownCloud placeholder style</comment>
<glob pattern="*.owncloud"/>
</mime-type>
</mime-info>

7
src/gui/owncloud.xml.in Normal file
View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="application/x-@APPLICATION_EXECUTABLE@">
<comment>@APPLICATION_NAME@ placeholders</comment>
<glob pattern="*@OWNCLOUD_PLACEHOLDER_SUFFIX@"/>
</mime-type>
</mime-info>

View file

@ -605,9 +605,9 @@ QString OwncloudPropagator::getFilePath(const QString &tmp_file_name) const
return _localDir + tmp_file_name;
}
QString OwncloudPropagator::placeholderFilePath(const QString &fileName) const
QString OwncloudPropagator::addPlaceholderSuffix(const QString &fileName) const
{
return getFilePath(fileName) + QLatin1String(".owncloud");
return fileName + _syncOptions._placeholderSuffix;
}
void OwncloudPropagator::scheduleNextJob()

View file

@ -453,7 +453,7 @@ public:
/* returns the local file path for the given tmp_file_name */
QString getFilePath(const QString &tmp_file_name) const;
QString placeholderFilePath(const QString &fileName) const;
QString addPlaceholderSuffix(const QString &fileName) const;
/** Creates the job for an item.
*/

View file

@ -402,10 +402,11 @@ void PropagateDownloadFile::startAfterIsEncryptedIsChecked()
// If we want to download something that used to be a placeholder,
// wipe the placeholder and proceed with a normal download
if (_item->_type == ItemTypePlaceholderDownload) {
auto fn = propagator()->placeholderFilePath(_item->_file);
auto placeholder = propagator()->addPlaceholderSuffix(_item->_file);
auto fn = propagator()->getFilePath(placeholder);
qCDebug(lcPropagateDownload) << "Downloading file that used to be a placeholder" << fn;
QFile::remove(fn);
propagator()->_journal->deleteFileRecord(_item->_file + ".owncloud");
propagator()->_journal->deleteFileRecord(placeholder);
_item->_type = ItemTypeFile;
}

View file

@ -859,6 +859,7 @@ void SyncEngine::startSync()
};
_csync_ctx->new_files_are_placeholders = _syncOptions._newFilesArePlaceholders;
_csync_ctx->placeholder_suffix = _syncOptions._placeholderSuffix.toUtf8();
// If needed, make sure we have up to date E2E information before the
// discovery phase, otherwise we start right away

View file

@ -38,6 +38,7 @@ struct SyncOptions
/** Create a placeholder for new files instead of downloading */
bool _newFilesArePlaceholders = false;
QString _placeholderSuffix;
/** The initial un-adjusted chunk size in bytes for chunked uploads, both
* for old and new chunking algorithm, which classifies the item to be chunked