Skip to content

Commit

Permalink
Merge pull request #3347 from jturcotte/shell_integration_findersync
Browse files Browse the repository at this point in the history
shell_i: Add a FinderSync-based implementation #2340
  • Loading branch information
danimo committed Jul 2, 2015
2 parents ba613a1 + 360a0ee commit 0610d3e
Show file tree
Hide file tree
Showing 92 changed files with 1,873 additions and 9,446 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ if(OWNCLOUD_5XX_NO_BLACKLIST)
add_definitions(-DOWNCLOUD_5XX_NO_BLACKLIST=1)
endif()

if(APPLE)
set( SOCKETAPI_TEAM_IDENTIFIER_PREFIX "" CACHE STRING "SocketApi prefix (including a following dot) that must match the codesigh key's TeamIdentifier/Organizational Unit" )
endif()

#### find libs
#find_package(Qt4 4.7.0 COMPONENTS QtCore QtGui QtXml QtNetwork QtTest QtWebkit REQUIRED )
#if( UNIX AND NOT APPLE ) # Fdo notifications
Expand Down
10 changes: 8 additions & 2 deletions admin/osx/sign_app.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
#!/bin/sh -xe

[ "$#" -lt 2 ] && echo "Usage: sign_app.sh <app> <identity>" && exit
[ "$#" -lt 2 ] && echo "Usage: sign_app.sh <app> <identity> <team_identifier>" && exit

src_app="$1"
identity="$2"
team_identifier="$3"

codesign -s "$identity" --force --verbose=4 --deep "$src_app"
codesign -s "$identity" --force --preserve-metadata=entitlements --verbose=4 --deep "$src_app"

# Verify the signature
spctl -a -t exec -vv $src_app
codesign -dv $src_app

# Validate that the key used for signing the binary matches the expected TeamIdentifier
# needed to pass the SocketApi through the sandbox
codesign -dv $src_app 2>&1 | grep "TeamIdentifier=$team_identifier"
exit $?
3 changes: 1 addition & 2 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
#cmakedefine WITH_QTKEYCHAIN 1
#cmakedefine WITH_CRASHREPORTER
#cmakedefine CRASHREPORTER_EXECUTABLE "@CRASHREPORTER_EXECUTABLE@"
#define SOCKETAPI_TEAM_IDENTIFIER_PREFIX "@SOCKETAPI_TEAM_IDENTIFIER_PREFIX@"


#cmakedefine GIT_SHA1 "@GIT_SHA1@"
#cmakedefine APPLICATION_DOMAIN @APPLICATION_DOMAIN@
#cmakedefine THEME_CLASS @THEME_CLASS@
#cmakedefine THEME_INCLUDE @THEME_INCLUDE@
Expand Down
25 changes: 21 additions & 4 deletions shell_integration/MacOSX/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@

if(APPLE)
add_custom_target( mac_overlayplugin ALL
xcodebuild -workspace ${CMAKE_SOURCE_DIR}/shell_integration/MacOSX/OwnCloud.xcworkspace
-scheme SyncStateFinder.osax SYMROOT=${CMAKE_CURRENT_BINARY_DIR} archive
COMMENT building Mac Overlay icons)
add_custom_target( legacy_mac_overlayplugin ALL
xcodebuild -workspace ${CMAKE_SOURCE_DIR}/shell_integration/MacOSX/OwnCloud.xcworkspace
-scheme SyncStateFinder.osax -configuration Release SYMROOT=${CMAKE_CURRENT_BINARY_DIR}
OC_APPLICATION_REV_DOMAIN=${APPLICATION_REV_DOMAIN}
OC_SOCKETAPI_TEAM_IDENTIFIER_PREFIX=${SOCKETAPI_TEAM_IDENTIFIER_PREFIX}
COMMENT building Legacy Mac Overlay icons)

# The bundle identifier and application group need to have compatible values with the client
# to be able to open a Mach port across the extension's sandbox boundary.
# Pass the info through the xcodebuild command line and make sure that the project uses
# those user-defined settings to build the plist.
add_custom_target( mac_overlayplugin ALL
xcodebuild -project ${CMAKE_SOURCE_DIR}/shell_integration/MacOSX/OwnCloudFinderSync/OwnCloudFinderSync.xcodeproj
-target FinderSyncExt -configuration Release SYMROOT=${CMAKE_CURRENT_BINARY_DIR}
OC_APPLICATION_NAME=${APPLICATION_NAME}
OC_APPLICATION_REV_DOMAIN=${APPLICATION_REV_DOMAIN}
OC_SOCKETAPI_TEAM_IDENTIFIER_PREFIX=${SOCKETAPI_TEAM_IDENTIFIER_PREFIX}
COMMENT building Mac Overlay icons)

INSTALL( DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Release/SyncStateFinder.osax/Contents
DESTINATION ${CMAKE_INSTALL_PREFIX}/Library/ScriptingAdditions/SyncStateFinder.osax/ )
INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Release/FinderSyncExt.appex
DESTINATION ${OWNCLOUD_OSX_BUNDLE}/Contents/Plugins
USE_SOURCE_PERMISSIONS)
endif(APPLE)

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@
<string>OwnCloud</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>09EE94AA-F410-4594-AB26-5A0220DEAEC7</key>
<key>D67321A19EF879CA55BF889202BA8C23AC9AA2B5</key>
<string>ssh://github.com/owncloud/client.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>shell_integration/MacOSX/OwnCloud.xcworkspace</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>09EE94AA-F410-4594-AB26-5A0220DEAEC7</key>
<key>D67321A19EF879CA55BF889202BA8C23AC9AA2B5</key>
<string>../../..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>ssh://github.com/owncloud/client.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>110</integer>
<integer>111</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>09EE94AA-F410-4594-AB26-5A0220DEAEC7</string>
<string>D67321A19EF879CA55BF889202BA8C23AC9AA2B5</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>09EE94AA-F410-4594-AB26-5A0220DEAEC7</string>
<string>D67321A19EF879CA55BF889202BA8C23AC9AA2B5</string>
<key>IDESourceControlWCCName</key>
<string>client</string>
</dict>
Expand Down
6 changes: 3 additions & 3 deletions shell_integration/MacOSX/OwnCloudFinder/ContentManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#import <Foundation/Foundation.h>

@interface ContentManager : NSObject
@interface OwnCloudFinderContentManager : NSObject
{
NSMutableDictionary* _fileNamesCache;
NSMutableDictionary* _oldFileNamesCache;
Expand All @@ -31,7 +31,7 @@
NSNumber *_icnErrSwm;
}

+ (ContentManager*)sharedInstance;
+ (OwnCloudFinderContentManager*)sharedInstance;

- (void)enableFileIcons:(BOOL)enable;
- (NSNumber*)iconByPath:(NSString*)path isDirectory:(BOOL)isDir;
Expand All @@ -42,6 +42,6 @@
- (void)reFetchFileNameCacheForPath:(NSString*)path;
- (void)repaintAllWindows;

- (void)loadIconResourcePath:(NSString*)path;
- (void)loadIconResources;

@end
41 changes: 21 additions & 20 deletions shell_integration/MacOSX/OwnCloudFinder/ContentManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
#import "RequestManager.h"
#import "IconCache.h"

static ContentManager* sharedInstance = nil;
static OwnCloudFinderContentManager* sharedInstance = nil;

@implementation ContentManager
@implementation OwnCloudFinderContentManager
- init
{
self = [super init];
Expand All @@ -33,6 +33,7 @@ @implementation ContentManager
_oldFileNamesCache = [[NSMutableDictionary alloc] init];
_fileIconsEnabled = TRUE;
_hasChangedContent = TRUE;
[self loadIconResources];
}

return self;
Expand All @@ -48,7 +49,7 @@ - (void)dealloc
[super dealloc];
}

+ (ContentManager*)sharedInstance
+ (OwnCloudFinderContentManager*)sharedInstance
{
@synchronized(self)
{
Expand All @@ -61,20 +62,20 @@ + (ContentManager*)sharedInstance
return sharedInstance;
}

- (void)loadIconResourcePath:(NSString*)path
- (void)loadIconResources
{
NSString *base = path;

_icnOk = [[IconCache sharedInstance] registerIcon:[base stringByAppendingPathComponent:@"ok.icns"]];
_icnSync = [[IconCache sharedInstance] registerIcon:[base stringByAppendingPathComponent:@"sync.icns"]];
_icnWarn = [[IconCache sharedInstance] registerIcon:[base stringByAppendingPathComponent:@"warning.icns"]];
_icnErr = [[IconCache sharedInstance] registerIcon:[base stringByAppendingPathComponent:@"error.icns"]];
_icnOkSwm = [[IconCache sharedInstance] registerIcon:[base stringByAppendingPathComponent:@"ok_swm.icns"]];
_icnSyncSwm = [[IconCache sharedInstance] registerIcon:[base stringByAppendingPathComponent:@"sync_swm.icns"]];
_icnWarnSwm = [[IconCache sharedInstance] registerIcon:[base stringByAppendingPathComponent:@"warning_swm.icns"]];
_icnErrSwm = [[IconCache sharedInstance] registerIcon:[base stringByAppendingPathComponent:@"error_swm.icns"]];

// NSLog(@"Icon ok identifier: %d from %@", [_icnOk intValue], [base stringByAppendingString:@"ok.icns"]);
NSBundle *extBundle = [NSBundle bundleForClass:[self class]];

_icnOk = [[IconCache sharedInstance] registerIcon:[extBundle imageForResource:@"ok.icns"]];
_icnSync = [[IconCache sharedInstance] registerIcon:[extBundle imageForResource:@"sync.icns"]];
_icnWarn = [[IconCache sharedInstance] registerIcon:[extBundle imageForResource:@"warning.icns"]];
_icnErr = [[IconCache sharedInstance] registerIcon:[extBundle imageForResource:@"error.icns"]];
_icnOkSwm = [[IconCache sharedInstance] registerIcon:[extBundle imageForResource:@"ok_swm.icns"]];
_icnSyncSwm = [[IconCache sharedInstance] registerIcon:[extBundle imageForResource:@"sync_swm.icns"]];
_icnWarnSwm = [[IconCache sharedInstance] registerIcon:[extBundle imageForResource:@"warning_swm.icns"]];
_icnErrSwm = [[IconCache sharedInstance] registerIcon:[extBundle imageForResource:@"error_swm.icns"]];

// NSLog(@"Icon ok: %@ identifier: %d from bundle %@", [extBundle imageForResource:@"ok.icns"], [_icnOk intValue], extBundle);
}

- (void)enableFileIcons:(BOOL)enable
Expand Down Expand Up @@ -141,19 +142,19 @@ - (NSNumber*)iconByPath:(NSString*)path isDirectory:(BOOL)isDir
}
NSString* normalizedPath = [path decomposedStringWithCanonicalMapping];

if (![[RequestManager sharedInstance] isRegisteredPath:normalizedPath isDirectory:isDir]) {
if (![[OwnCloudFinderRequestManager sharedInstance] isRegisteredPath:normalizedPath isDirectory:isDir]) {
return [NSNumber numberWithInt:0];
}

NSNumber* result = [_fileNamesCache objectForKey:normalizedPath];
// NSLog(@"XXXXXXX Asking for icon for path %@ = %d",normalizedPath, [result intValue]);

if( result == nil ) {
// start the async call
[[RequestManager sharedInstance] askForIcon:normalizedPath isDirectory:isDir];
result = [NSNumber numberWithInt:0];
// Set 0 into the cache, meaning "don't have an icon, but already requested it"
[_fileNamesCache setObject:result forKey:normalizedPath];
// start the async call
[[OwnCloudFinderRequestManager sharedInstance] askForIcon:normalizedPath isDirectory:isDir];
}
if ([result intValue] == 0) {
// Show the old state while we wait for the new one
Expand Down Expand Up @@ -222,7 +223,7 @@ - (void)repaintAllWindows
}

MenuManager* menuManager = [MenuManager sharedInstance];
RequestManager* requestManager = [RequestManager sharedInstance];
OwnCloudFinderRequestManager* requestManager = [OwnCloudFinderRequestManager sharedInstance];

if ([[window className] isEqualToString:@"TBrowserWindow"])
{
Expand Down
6 changes: 3 additions & 3 deletions shell_integration/MacOSX/OwnCloudFinder/FinderHook.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ + (void)install

// NSLog(@"SyncStateFinder: installing SyncState Shell extension");

[RequestManager sharedInstance];
[OwnCloudFinderRequestManager sharedInstance];

// Icons
[self hookMethod:@selector(drawImage:) inClass:@"IKImageBrowserCell" toCallToTheNewMethod:@selector(OCIconOverlayHandlers_IKImageBrowserCell_drawImage:)]; // 10.7 & 10.8 & 10.9 (Icon View arrange by name)
Expand Down Expand Up @@ -95,11 +95,11 @@ + (void)uninstall

// NSLog(@"SyncStateFinder: uninstalling");

[[ContentManager sharedInstance] dealloc];
[[OwnCloudFinderContentManager sharedInstance] dealloc];

[[IconCache sharedInstance] dealloc];

[[RequestManager sharedInstance] dealloc];
[[OwnCloudFinderRequestManager sharedInstance] dealloc];

// Icons
[self hookMethod:@selector(OCIconOverlayHandlers_drawImage:) inClass:@"TIconViewCell" toCallToTheNewMethod:@selector(drawImage:)]; // 10.7 & 10.8 & 10.9
Expand Down
Loading

0 comments on commit 0610d3e

Please sign in to comment.