Skip to content

Commit

Permalink
Merge branch 'placeholder-prototype'
Browse files Browse the repository at this point in the history
  • Loading branch information
ckamm committed Apr 18, 2018
2 parents 57044c1 + a9561f4 commit 9e8464e
Show file tree
Hide file tree
Showing 44 changed files with 1,282 additions and 108 deletions.
1 change: 1 addition & 0 deletions OWNCLOUD.cmake
Expand Up @@ -5,6 +5,7 @@ set( APPLICATION_DOMAIN "owncloud.com" )
set( APPLICATION_VENDOR "ownCloud" )
set( APPLICATION_UPDATE_URL "https://updates.owncloud.com/client/" CACHE string "URL for updater" )
set( APPLICATION_ICON_NAME "owncloud" )
set( APPLICATION_PLACEHOLDER_SUFFIX "owncloud" CACHE STRING "Placeholder suffix (not including the .)")

set( LINUX_PACKAGE_SHORTNAME "owncloud" )

Expand Down
120 changes: 120 additions & 0 deletions admin/win/nsi/lib/fileassoc.nsh
@@ -0,0 +1,120 @@
; fileassoc.nsh
; File association helper macros
; Written by Saivert
; See http://nsis.sourceforge.net/FileAssoc
;
; Features automatic backup system and UPDATEFILEASSOC macro for
; shell change notification.
;
; |> How to use <|
; To associate a file with an application so you can double-click it in explorer, use
; the APP_ASSOCIATE macro like this:
;
; Example:
; !insertmacro APP_ASSOCIATE "txt" "myapp.textfile" "Description of txt files" \
; "$INSTDIR\myapp.exe,0" "Open with myapp" "$INSTDIR\myapp.exe $\"%1$\""
;
; Never insert the APP_ASSOCIATE macro multiple times, it is only ment
; to associate an application with a single file and using the
; the "open" verb as default. To add more verbs (actions) to a file
; use the APP_ASSOCIATE_ADDVERB macro.
;
; Example:
; !insertmacro APP_ASSOCIATE_ADDVERB "myapp.textfile" "edit" "Edit with myapp" \
; "$INSTDIR\myapp.exe /edit $\"%1$\""
;
; To have access to more options when registering the file association use the
; APP_ASSOCIATE_EX macro. Here you can specify the verb and what verb is to be the
; standard action (default verb).
;
; And finally: To remove the association from the registry use the APP_UNASSOCIATE
; macro. Here is another example just to wrap it up:
; !insertmacro APP_UNASSOCIATE "txt" "myapp.textfile"
;
; |> Note <|
; When defining your file class string always use the short form of your application title
; then a period (dot) and the type of file. This keeps the file class sort of unique.
; Examples:
; Winamp.Playlist
; NSIS.Script
; Photoshop.JPEGFile
;
; |> Tech info <|
; The registry key layout for a file association is:
; HKEY_CLASSES_ROOT
; <applicationID> = <"description">
; shell
; <verb> = <"menu-item text">
; command = <"command string">
;

!macro APP_ASSOCIATE EXT FILECLASS DESCRIPTION ICON COMMANDTEXT COMMAND
; Backup the previously associated file class
ReadRegStr $R0 HKCR ".${EXT}" ""
WriteRegStr HKCR ".${EXT}" "${FILECLASS}_backup" "$R0"

WriteRegStr HKCR ".${EXT}" "" "${FILECLASS}"

WriteRegStr HKCR "${FILECLASS}" "" `${DESCRIPTION}`
WriteRegStr HKCR "${FILECLASS}\DefaultIcon" "" `${ICON}`
WriteRegStr HKCR "${FILECLASS}\shell" "" "open"
WriteRegStr HKCR "${FILECLASS}\shell\open" "" `${COMMANDTEXT}`
WriteRegStr HKCR "${FILECLASS}\shell\open\command" "" `${COMMAND}`
!macroend

!macro APP_ASSOCIATE_EX EXT FILECLASS DESCRIPTION ICON VERB DEFAULTVERB SHELLNEW COMMANDTEXT COMMAND
; Backup the previously associated file class
ReadRegStr $R0 HKCR ".${EXT}" ""
WriteRegStr HKCR ".${EXT}" "${FILECLASS}_backup" "$R0"

WriteRegStr HKCR ".${EXT}" "" "${FILECLASS}"
StrCmp "${SHELLNEW}" "0" +2
WriteRegStr HKCR ".${EXT}\ShellNew" "NullFile" ""

WriteRegStr HKCR "${FILECLASS}" "" `${DESCRIPTION}`
WriteRegStr HKCR "${FILECLASS}\DefaultIcon" "" `${ICON}`
WriteRegStr HKCR "${FILECLASS}\shell" "" `${DEFAULTVERB}`
WriteRegStr HKCR "${FILECLASS}\shell\${VERB}" "" `${COMMANDTEXT}`
WriteRegStr HKCR "${FILECLASS}\shell\${VERB}\command" "" `${COMMAND}`
!macroend

!macro APP_ASSOCIATE_ADDVERB FILECLASS VERB COMMANDTEXT COMMAND
WriteRegStr HKCR "${FILECLASS}\shell\${VERB}" "" `${COMMANDTEXT}`
WriteRegStr HKCR "${FILECLASS}\shell\${VERB}\command" "" `${COMMAND}`
!macroend

!macro APP_ASSOCIATE_REMOVEVERB FILECLASS VERB
DeleteRegKey HKCR `${FILECLASS}\shell\${VERB}`
!macroend


!macro APP_UNASSOCIATE EXT FILECLASS
; Backup the previously associated file class
ReadRegStr $R0 HKCR ".${EXT}" `${FILECLASS}_backup`
WriteRegStr HKCR ".${EXT}" "" "$R0"

DeleteRegKey HKCR `${FILECLASS}`
!macroend

!macro APP_ASSOCIATE_GETFILECLASS OUTPUT EXT
ReadRegStr ${OUTPUT} HKCR ".${EXT}" ""
!macroend


; !defines for use with SHChangeNotify
!ifdef SHCNE_ASSOCCHANGED
!undef SHCNE_ASSOCCHANGED
!endif
!define SHCNE_ASSOCCHANGED 0x08000000
!ifdef SHCNF_FLUSH
!undef SHCNF_FLUSH
!endif
!define SHCNF_FLUSH 0x1000

!macro UPDATEFILEASSOC
; Using the system.dll plugin to call the SHChangeNotify Win32 API function so we
; can update the shell.
System::Call "shell32::SHChangeNotify(i,i,i,i) (${SHCNE_ASSOCCHANGED}, ${SHCNF_FLUSH}, 0, 0)"
!macroend

;EOF
10 changes: 10 additions & 0 deletions cmake/modules/NSIS.template.in
Expand Up @@ -7,6 +7,8 @@
!define APPLICATION_CMD_EXECUTABLE "@APPLICATION_EXECUTABLE@cmd.exe"
!define APPLICATION_DOMAIN "@APPLICATION_DOMAIN@"
!define APPLICATION_LICENSE "@APPLICATION_LICENSE@"
!define APPLICATION_PLACEHOLDER_SUFFIX "@APPLICATION_PLACEHOLDER_SUFFIX@"
!define APPLICATION_PLACEHOLDER_FILECLASS "@APPLICATION_EXECUTABLE@.@APPLICATION_PLACEHOLDER_SUFFIX@"
!define WIN_SETUP_BITMAP_PATH "@WIN_SETUP_BITMAP_PATH@"

!define CRASHREPORTER_EXECUTABLE "@CRASHREPORTER_EXECUTABLE@"
Expand Down Expand Up @@ -100,6 +102,8 @@ ReserveFile "${NSISDIR}\Plugins\InstallOptions.dll"
!include Library.nsh ;Used by the COM registration for shell extensions
!include x64.nsh ;Used to determine the right arch for the shell extensions

!include ${source_path}/admin/win/nsi/lib/fileassoc.nsh

;-----------------------------------------------------------------------------
; Memento selections stored in registry.
;-----------------------------------------------------------------------------
Expand Down Expand Up @@ -466,6 +470,9 @@ Section "${APPLICATION_NAME}" SEC_APPLICATION
;CSync configs
File "${SOURCE_PATH}/sync-exclude.lst"

;Add file association
!insertmacro APP_ASSOCIATE "${APPLICATION_PLACEHOLDER_SUFFIX}" "${APPLICATION_PLACEHOLDER_FILECLASS}" "Placeholder for Remote File" "$INSTDIR\${APPLICATION_EXECUTABLE},0" "Download" "$INSTDIR\${APPLICATION_EXECUTABLE} $\"%1$\""

SectionEnd

!ifdef OPTION_SECTION_SC_SHELL_EXT
Expand Down Expand Up @@ -643,6 +650,9 @@ Section Uninstall

DeleteRegKey HKCR "${APPLICATION_NAME}"

;Remove file association
!insertmacro APP_UNASSOCIATE "${APPLICATION_PLACEHOLDER_SUFFIX}" "${APPLICATION_PLACEHOLDER_FILECLASS}"

;Shell extension
!ifdef OPTION_SECTION_SC_SHELL_EXT
!define LIBRARY_COM
Expand Down
2 changes: 2 additions & 0 deletions config.h.in
Expand Up @@ -18,6 +18,8 @@
#cmakedefine APPLICATION_EXECUTABLE "@APPLICATION_EXECUTABLE@"
#cmakedefine APPLICATION_UPDATE_URL "@APPLICATION_UPDATE_URL@"
#cmakedefine APPLICATION_ICON_NAME "@APPLICATION_ICON_NAME@"
#cmakedefine APPLICATION_PLACEHOLDER_SUFFIX "@APPLICATION_PLACEHOLDER_SUFFIX@"
#define APPLICATION_DOTPLACEHOLDER_SUFFIX "." APPLICATION_PLACEHOLDER_SUFFIX

#cmakedefine ZLIB_FOUND @ZLIB_FOUND@

Expand Down
3 changes: 3 additions & 0 deletions doc/conffile.rst
Expand Up @@ -49,6 +49,9 @@ Some interesting values that can be set on the configuration file are:
| ``moveToTrash`` | ``false`` | If non-locally deleted files should be moved to trash instead of deleting them completely. |
| | | This option only works on linux |
+---------------------------------+---------------+--------------------------------------------------------------------------------------------------------+
| ``showExperimentalOptions`` | ``false`` | Whether to show experimental options that are still undergoing testing in the user interface. |
| | | Turning this on does not enable experimental behavior on its own. It does enable user inferface options that can be used to opt in to experimental features. |
+---------------------------------+---------------+--------------------------------------------------------------------------------------------------------+


+----------------------------------------------------------------------------------------------------------------------------------------------------------+
Expand Down
72 changes: 1 addition & 71 deletions mirall.desktop.in
Expand Up @@ -8,77 +8,7 @@ GenericName=Folder Sync
Icon=@APPLICATION_EXECUTABLE@
Keywords=@APPLICATION_NAME@;syncing;file;sharing;
X-GNOME-Autostart-Delay=3



# Translations


# Translations


# Translations


# Translations


# Translations


# Translations


# Translations


# Translations


# Translations


# Translations


# Translations


# Translations


# Translations


# Translations


# Translations


# Translations


# Translations


# Translations


# Translations


# Translations


# Translations


# Translations


# Translations

MimeType=application/x-@APPLICATION_EXECUTABLE@

# Translations
Comment[oc]=@APPLICATION_NAME@ sincronizacion del client
Expand Down
4 changes: 3 additions & 1 deletion src/csync/csync.h
Expand Up @@ -137,7 +137,9 @@ enum ItemType {
ItemTypeFile = 0,
ItemTypeSoftLink = 1,
ItemTypeDirectory = 2,
ItemTypeSkip = 3
ItemTypeSkip = 3,
ItemTypePlaceholder = 4,
ItemTypePlaceholderDownload = 5
};


Expand Down
62 changes: 62 additions & 0 deletions src/csync/csync_exclude.cpp
Expand Up @@ -33,9 +33,12 @@
#include "csync_misc.h"

#include "common/utility.h"
#include "../version.h"

#include <QString>
#include <QFileInfo>
#include <QFile>
#include <QDir>


/** Expands C-like escape sequences (in place)
Expand Down Expand Up @@ -240,6 +243,7 @@ static CSYNC_EXCLUDE_TYPE _csync_excluded_common(const char *path, bool excludeC
using namespace OCC;

ExcludedFiles::ExcludedFiles()
: _clientVersion(MIRALL_VERSION_MAJOR, MIRALL_VERSION_MINOR, MIRALL_VERSION_PATCH)
{
// Windows used to use PathMatchSpec which allows *foo to match abc/deffoo.
_wildcardsMatchSlash = Utility::isWindows();
Expand Down Expand Up @@ -278,6 +282,34 @@ void ExcludedFiles::setWildcardsMatchSlash(bool onoff)
prepare();
}

void ExcludedFiles::setClientVersion(ExcludedFiles::Version version)
{
_clientVersion = version;
}

void ExcludedFiles::setupPlaceholderExclude(
const QString &excludeFile, const QByteArray &placeholderExtension)
{
if (!QFile::exists(excludeFile)) {
// Ensure the parent paths exist
QDir().mkpath(QFileInfo(excludeFile).dir().absolutePath());
} else {
// Does the exclude file contain the exclude already?
QFile file(excludeFile);
file.open(QIODevice::ReadOnly | QIODevice::Text);
auto data = file.readAll();
file.close();
if (data.contains("\n*" + placeholderExtension + "\n"))
return;
}

// Add it to the file
QFile file(excludeFile);
file.open(QIODevice::ReadWrite | QIODevice::Append);
file.write("\n#!version < 2.5.0\n*" + placeholderExtension + "\n");
file.close();
}

bool ExcludedFiles::reloadExcludeFiles()
{
_allExcludes.clear();
Expand All @@ -290,6 +322,10 @@ bool ExcludedFiles::reloadExcludeFiles()
}
while (!f.atEnd()) {
QByteArray line = f.readLine().trimmed();
if (line.startsWith("#!version")) {
if (!versionDirectiveKeepNextLine(line))
f.readLine();
}
if (line.isEmpty() || line.startsWith('#'))
continue;
csync_exclude_expand_escapes(line);
Expand All @@ -301,6 +337,32 @@ bool ExcludedFiles::reloadExcludeFiles()
return success;
}

bool ExcludedFiles::versionDirectiveKeepNextLine(const QByteArray &directive) const
{
if (!directive.startsWith("#!version"))
return true;
QByteArrayList args = directive.split(' ');
if (args.size() != 3)
return true;
QByteArray op = args[1];
QByteArrayList argVersions = args[2].split('.');
if (argVersions.size() != 3)
return true;

auto argVersion = std::make_tuple(argVersions[0].toInt(), argVersions[1].toInt(), argVersions[2].toInt());
if (op == "<=")
return _clientVersion <= argVersion;
if (op == "<")
return _clientVersion < argVersion;
if (op == ">")
return _clientVersion > argVersion;
if (op == ">=")
return _clientVersion >= argVersion;
if (op == "==")
return _clientVersion == argVersion;
return true;
}

bool ExcludedFiles::isExcluded(
const QString &filePath,
const QString &basePath,
Expand Down

0 comments on commit 9e8464e

Please sign in to comment.