1
0
mirror of https://github.com/chylex/Nextcloud-Desktop.git synced 2025-04-09 19:15:43 +02:00

shell_i: Remove the ICON_PATH socket API message

It was only used on OS X and couldn't be used by the FinderSync
extension since that one runs in a sandbox. So use the same system
to load images in the legacy extension by shipping them in the
extension bundle instead of the owncloud.app bundle.

This is also given that the legacy extension needs padded icons
while the FinderSync one needs unpadded icons.
This commit is contained in:
Jocelyn Turcotte 2015-06-17 16:08:57 +02:00
parent e111e11dab
commit 85938ab1f1
10 changed files with 53 additions and 102 deletions
shell_integration
MacOSX
OwnCloudFinder
OwnCloudFinderSync/FinderSyncExt
common
icons
src/gui

View File

@ -42,6 +42,6 @@
- (void)reFetchFileNameCacheForPath:(NSString*)path;
- (void)repaintAllWindows;
- (void)loadIconResourcePath:(NSString*)path;
- (void)loadIconResources;
@end

View File

@ -33,6 +33,7 @@ static ContentManager* sharedInstance = nil;
_oldFileNamesCache = [[NSMutableDictionary alloc] init];
_fileIconsEnabled = TRUE;
_hasChangedContent = TRUE;
[self loadIconResources];
}
return self;
@ -61,20 +62,20 @@ static ContentManager* sharedInstance = nil;
return sharedInstance;
}
- (void)loadIconResourcePath:(NSString*)path
- (void)loadIconResources
{
NSString *base = path;
NSBundle *extBundle = [NSBundle bundleForClass:[self class]];
_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"]];
_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 %@", [_icnOk intValue], [base stringByAppendingString:@"ok.icns"]);
// NSLog(@"Icon ok: %@ identifier: %d from bundle %@", [extBundle imageForResource:@"ok.icns"], [_icnOk intValue], extBundle);
}
- (void)enableFileIcons:(BOOL)enable

View File

@ -17,13 +17,11 @@
@interface IconCache : NSObject {
int _currentIconId;
NSMutableDictionary* _iconIdDictionary;
NSMutableDictionary* _iconPathDictionary;
}
+ (IconCache*)sharedInstance;
- (NSImage*)getIcon:(NSNumber*)iconId;
- (NSNumber*)registerIcon:(NSString*)path;
- (void)unregisterIcon:(NSNumber*)iconId;
- (NSNumber*)registerIcon:(NSImage*)image;
@end

View File

@ -25,7 +25,6 @@ static IconCache* sharedInstance = nil;
if (self)
{
_iconIdDictionary = [[NSMutableDictionary alloc] init];
_iconPathDictionary = [[NSMutableDictionary alloc] init];
_currentIconId = 0;
}
@ -35,7 +34,6 @@ static IconCache* sharedInstance = nil;
- (void)dealloc
{
[_iconIdDictionary release];
[_iconPathDictionary release];
sharedInstance = nil;
[super dealloc];
@ -60,57 +58,15 @@ static IconCache* sharedInstance = nil;
return image;
}
- (NSNumber*)registerIcon:(NSString*)path
- (NSNumber*)registerIcon:(NSImage*)image
{
if (path == nil)
{
return [NSNumber numberWithInt:-1];
}
_currentIconId++;
NSImage* image = [[NSImage alloc]initWithContentsOfFile:path];
if (image == nil)
{
NSLog(@"%@ Could not load %@", NSStringFromSelector(_cmd), path);
return [NSNumber numberWithInt:-1];
}
NSNumber* iconId = [_iconPathDictionary objectForKey:path];
if (iconId == nil)
{
_currentIconId++;
iconId = [NSNumber numberWithInt:_currentIconId];
[_iconPathDictionary setObject:iconId forKey:path];
}
NSNumber* iconId = [NSNumber numberWithInt:_currentIconId];
[_iconIdDictionary setObject:image forKey:iconId];
[image release];
return iconId;
}
- (void)unregisterIcon:(NSNumber*)iconId
{
NSString* path = @"";
for (NSString* key in _iconPathDictionary)
{
NSNumber* value = [_iconPathDictionary objectForKey:key];
if ([value isEqualToNumber:iconId])
{
path = key;
break;
}
}
[_iconPathDictionary removeObjectForKey:path];
[_iconIdDictionary removeObjectForKey:iconId];
}
@end

View File

@ -20,6 +20,14 @@
8C99F6941622D145002D2135 /* IconCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C99F6931622D145002D2135 /* IconCache.m */; };
8D576314048677EA00EA77CD /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0AA1909FFE8422F4C02AAC07 /* CoreFoundation.framework */; };
8D5B49A804867FD3000E48DA /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8D5B49A704867FD3000E48DA /* InfoPlist.strings */; };
C220057B1B31B04C00A4FB37 /* error_swm.icns in Resources */ = {isa = PBXBuildFile; fileRef = C22005731B31B04C00A4FB37 /* error_swm.icns */; };
C220057C1B31B04C00A4FB37 /* error.icns in Resources */ = {isa = PBXBuildFile; fileRef = C22005741B31B04C00A4FB37 /* error.icns */; };
C220057D1B31B04C00A4FB37 /* ok_swm.icns in Resources */ = {isa = PBXBuildFile; fileRef = C22005751B31B04C00A4FB37 /* ok_swm.icns */; };
C220057E1B31B04C00A4FB37 /* ok.icns in Resources */ = {isa = PBXBuildFile; fileRef = C22005761B31B04C00A4FB37 /* ok.icns */; };
C220057F1B31B04C00A4FB37 /* sync_swm.icns in Resources */ = {isa = PBXBuildFile; fileRef = C22005771B31B04C00A4FB37 /* sync_swm.icns */; };
C22005801B31B04C00A4FB37 /* sync.icns in Resources */ = {isa = PBXBuildFile; fileRef = C22005781B31B04C00A4FB37 /* sync.icns */; };
C22005811B31B04C00A4FB37 /* warning_swm.icns in Resources */ = {isa = PBXBuildFile; fileRef = C22005791B31B04C00A4FB37 /* warning_swm.icns */; };
C22005821B31B04C00A4FB37 /* warning.icns in Resources */ = {isa = PBXBuildFile; fileRef = C220057A1B31B04C00A4FB37 /* warning.icns */; };
C2B573831B1CD5AE00303B36 /* SyncClientProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B573821B1CD5AE00303B36 /* SyncClientProxy.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; };
/* End PBXBuildFile section */
@ -48,6 +56,14 @@
8C99F6931622D145002D2135 /* IconCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IconCache.m; sourceTree = "<group>"; };
8D576316048677EA00EA77CD /* SyncStateFinder.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SyncStateFinder.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
8D576317048677EA00EA77CD /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
C22005731B31B04C00A4FB37 /* error_swm.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = error_swm.icns; path = ../../icons/icns/error_swm.icns; sourceTree = "<group>"; };
C22005741B31B04C00A4FB37 /* error.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = error.icns; path = ../../icons/icns/error.icns; sourceTree = "<group>"; };
C22005751B31B04C00A4FB37 /* ok_swm.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = ok_swm.icns; path = ../../icons/icns/ok_swm.icns; sourceTree = "<group>"; };
C22005761B31B04C00A4FB37 /* ok.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = ok.icns; path = ../../icons/icns/ok.icns; sourceTree = "<group>"; };
C22005771B31B04C00A4FB37 /* sync_swm.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = sync_swm.icns; path = ../../icons/icns/sync_swm.icns; sourceTree = "<group>"; };
C22005781B31B04C00A4FB37 /* sync.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = sync.icns; path = ../../icons/icns/sync.icns; sourceTree = "<group>"; };
C22005791B31B04C00A4FB37 /* warning_swm.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = warning_swm.icns; path = ../../icons/icns/warning_swm.icns; sourceTree = "<group>"; };
C220057A1B31B04C00A4FB37 /* warning.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = warning.icns; path = ../../icons/icns/warning.icns; sourceTree = "<group>"; };
C2B573811B1CD5AE00303B36 /* SyncClientProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SyncClientProxy.h; sourceTree = "<group>"; };
C2B573821B1CD5AE00303B36 /* SyncClientProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SyncClientProxy.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
@ -94,6 +110,14 @@
089C167CFE841241C02AAC07 /* Resources */ = {
isa = PBXGroup;
children = (
C22005731B31B04C00A4FB37 /* error_swm.icns */,
C22005741B31B04C00A4FB37 /* error.icns */,
C22005751B31B04C00A4FB37 /* ok_swm.icns */,
C22005761B31B04C00A4FB37 /* ok.icns */,
C22005771B31B04C00A4FB37 /* sync_swm.icns */,
C22005781B31B04C00A4FB37 /* sync.icns */,
C22005791B31B04C00A4FB37 /* warning_swm.icns */,
C220057A1B31B04C00A4FB37 /* warning.icns */,
8D576317048677EA00EA77CD /* Info.plist */,
8D5B49A704867FD3000E48DA /* InfoPlist.strings */,
);
@ -179,7 +203,7 @@
attributes = {
LastUpgradeCheck = 0460;
};
buildConfigurationList = 1DEB911E08733D790010E9CD /* Build configuration list for PBXProject "SyncStateFinder" */;
buildConfigurationList = 1DEB911E08733D790010E9CD /* Build configuration list for PBXProject "OwnCloudFinder" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 1;
@ -189,7 +213,7 @@
French,
German,
);
mainGroup = 089C166AFE841209C02AAC07 /* SyncStateFinder` */;
mainGroup = 089C166AFE841209C02AAC07 /* SyncStateFinder */;
projectDirPath = "";
projectRoot = "";
targets = (
@ -203,7 +227,15 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C220057E1B31B04C00A4FB37 /* ok.icns in Resources */,
C22005821B31B04C00A4FB37 /* warning.icns in Resources */,
C220057F1B31B04C00A4FB37 /* sync_swm.icns in Resources */,
C220057C1B31B04C00A4FB37 /* error.icns in Resources */,
8D5B49A804867FD3000E48DA /* InfoPlist.strings in Resources */,
C22005801B31B04C00A4FB37 /* sync.icns in Resources */,
C220057D1B31B04C00A4FB37 /* ok_swm.icns in Resources */,
C220057B1B31B04C00A4FB37 /* error_swm.icns in Resources */,
C22005811B31B04C00A4FB37 /* warning_swm.icns in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -318,7 +350,7 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
1DEB911E08733D790010E9CD /* Build configuration list for PBXProject "SyncStateFinder" */ = {
1DEB911E08733D790010E9CD /* Build configuration list for PBXProject "OwnCloudFinder" */ = {
isa = XCConfigurationList;
buildConfigurations = (
1DEB911F08733D790010E9CD /* Debug */,

View File

@ -129,11 +129,6 @@ static RequestManager* sharedInstance = nil;
_shareMenuTitle = title;
}
- (void)loadIconResourcePath:(NSString*)path
{
[[ContentManager sharedInstance] loadIconResourcePath:path];
}
- (void)connectionDidDie
{
// NSLog(@"Socket DISconnected! %@", [err localizedDescription]);

View File

@ -44,7 +44,7 @@
[syncController setBadgeImage:warning label:@"Ignored" forBadgeIdentifier:@"IGNORE+SWM"];
[syncController setBadgeImage:error label:@"Error" forBadgeIdentifier:@"ERROR+SWM"];
// The Mach post name needs to be prefixed with the code signing Team ID
// The Mach port name needs to be prefixed with the code signing Team ID
// https://developer.apple.com/library/mac/documentation/Security/Conceptual/AppSandboxDesignGuide/AppSandboxInDepth/AppSandboxInDepth.html#//apple_ref/doc/uid/TP40011183-CH3-SW24
NSString *serverName = [[teamIdentifierPrefix stringByAppendingString:[extBundle bundleIdentifier]]
stringByReplacingOccurrencesOfString:@".FinderSyncExt" withString:@".socketApi"];
@ -148,11 +148,6 @@
_shareMenuTitle = title;
}
- (void)loadIconResourcePath:(NSString*)path
{
#pragma unused(path)
}
- (void)connectionDidDie
{
_shareMenuTitle = nil;

View File

@ -119,10 +119,6 @@
} else if( [[chunks objectAtIndex:0 ] isEqualToString:@"UNREGISTER_PATH"] ) {
NSString *path = [chunks objectAtIndex:1];
[_delegate unregisterPath:path];
} else if( [[chunks objectAtIndex:0 ] isEqualToString:@"ICON_PATH"] ) {
// FIXME: Should also go away once we move icons into the bundle
NSString *path = [chunks objectAtIndex:1];
[_delegate loadIconResourcePath:path];
} else if( [[chunks objectAtIndex:0 ] isEqualToString:@"SHARE_MENU_TITLE"] ) {
[_delegate setShareMenuTitle:[chunks objectAtIndex:1]];
} else {

View File

@ -1,12 +1,3 @@
# Install the Mac icon container into the Mac Bundle.
if( BUILD_OWNCLOUD_OSX_BUNDLE AND NOT BUILD_LIBRARIES_ONLY )
set (ICON_DIR ${OWNCLOUD_OSX_BUNDLE}/Contents/Resources/icons)
file(GLOB mac_icons "icns/*icns")
install(FILES ${mac_icons} DESTINATION ${ICON_DIR})
endif()
if( UNIX AND NOT APPLE )
SET(ICON_DIR ${DATADIR}/icons/hicolor)
@ -22,6 +13,3 @@ if( UNIX AND NOT APPLE )
ENDFOREACH(size)
endif()

View File

@ -177,16 +177,6 @@ void SocketApi::slotNewConnection()
_listeners.append(socket);
#ifdef Q_OS_MAC
// We want to tell our location so it can load the icons
// e.g. "/Users/guruz/woboq/owncloud/client/buildmirall/owncloud.app/Contents/MacOS/"
QString iconPath = qApp->applicationDirPath() + "/../Resources/icons/";
if (!QDir(iconPath).exists()) {
DEBUG << "Icon path " << iconPath << " does not exist, did you forget make install?";
}
broadcastMessage(QLatin1String("ICON_PATH"), iconPath );
#endif
foreach( Folder *f, FolderMan::instance()->map() ) {
QString message = buildRegisterPathMessage(f->path());
sendMessage(socket, message);