Placeholder: The extension is now a branding option
authorOlivier Goffart <ogoffart@woboq.com>
Thu, 25 Jan 2018 15:20:35 +0000 (16:20 +0100)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 15 Dec 2020 09:57:49 +0000 (10:57 +0100)
14 files changed:
CMakeLists.txt
config.h.in
mirall.desktop.in
src/csync/csync_private.h
src/gui/CMakeLists.txt
src/gui/application.cpp
src/gui/folder.cpp
src/gui/owncloud.xml [deleted file]
src/gui/owncloud.xml.in [new file with mode: 0644]
src/libsync/owncloudpropagator.cpp
src/libsync/owncloudpropagator.h
src/libsync/propagatedownload.cpp
src/libsync/syncengine.cpp
src/libsync/syncoptions.h

index 5df23883895d25f5427d686ed877882986f7845e..0062e0beb467215c53e935ac16968851d0341034 100644 (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)
index 0581afbd90e25357b6a30487db4362b2dfa4e462..0983b6ba1af70e4f5e4cb116f297bd89a96ec832 100644 (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@
 
index bde42a49fd240f8e531073963f97485c7fe4e027..970ad1da0d729703527bcff311bced1e7ec63d92 100644 (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
 
 
index 780dfb66d7edcabe73f99234135a79d700532d37..bba72237f345a3ec06c49cf85ea17bac8d1c0e33 100644 (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();
index 215945c2e593bdd67142c0c25c501957bb973d0a..d16b77097728ca21075feb9b86c7d8c1ce0c8102 100644 (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")
index f6d67a4bde5b80e3654c0b0ed9f39d9d0fe64e8c..c4fb2009a304fc9e8409100ec3002188bd94f88e 100644 (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;
index d408a9d32d4ec4236555427f663449a87d5b80b3..f724a85c3d80b1bef42394e02c1f3e18657beaad 100644 (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()) {
diff --git a/src/gui/owncloud.xml b/src/gui/owncloud.xml
deleted file mode 100644 (file)
index 7198b76..0000000
+++ /dev/null
@@ -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>
diff --git a/src/gui/owncloud.xml.in b/src/gui/owncloud.xml.in
new file mode 100644 (file)
index 0000000..5d1d062
--- /dev/null
@@ -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>
index 5d815aa43aec39ccd282fcce8af9e931de75f190..5584c8652eeee86bdd0762d2134baa4952b6b5e4 100644 (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()
index c6a52db131cbe6e95183c480ff37c2cd53cf3d02..4b34913e51b5125112759ece5a72a7a4b674ea01 100644 (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.
      */
index a674e7365373b2e0c7f133f582e121ce0b3ba262..6134f1e2a7d8e10bb424e1f06a622256fd5fe25a 100644 (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;
     }
 
index d4e2b090ff487c60927e8bf87b25ac0f0074ae87..5770a5d3a379d5bd5df86869fada3d4917749981 100644 (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
index f442c380bb1cdbc09004b1be5c2762a00cb507cb..2e302bda94e82c6e22eb13b27699cbf54aa48c46 100644 (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