[Pkg-owncloud-commits] [owncloud-client] 253/332: Mac overlays: Fix allocations, use icns, correct query type.
Sandro Knauß
hefee-guest at moszumanska.debian.org
Thu Aug 14 21:07:08 UTC 2014
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit a6987ad703a0ad5da9eb4212a15bf4aab44d10e3
Author: Klaas Freitag <freitag at owncloud.com>
Date: Wed Jul 9 18:00:26 2014 +0200
Mac overlays: Fix allocations, use icns, correct query type.
---
.../MacOSX/LiferayNativityFinder/ContentManager.h | 2 +-
.../MacOSX/LiferayNativityFinder/ContentManager.m | 33 ++++++++------
.../LiferayNativityFinder/IconOverlayHandlers.m | 35 ++++++++++++---
.../MacOSX/LiferayNativityFinder/RequestManager.h | 4 +-
.../MacOSX/LiferayNativityFinder/RequestManager.m | 50 ++++++++++++----------
shell_integration/MacOSX/deploy.sh | 2 +-
6 files changed, 78 insertions(+), 48 deletions(-)
diff --git a/shell_integration/MacOSX/LiferayNativityFinder/ContentManager.h b/shell_integration/MacOSX/LiferayNativityFinder/ContentManager.h
index 2e167f7..454672d 100644
--- a/shell_integration/MacOSX/LiferayNativityFinder/ContentManager.h
+++ b/shell_integration/MacOSX/LiferayNativityFinder/ContentManager.h
@@ -23,7 +23,7 @@
+ (ContentManager*)sharedInstance;
- (void)enableFileIcons:(BOOL)enable;
-- (NSNumber*)iconByPath:(NSString*)path;
+- (NSNumber*)iconByPath:(NSString*)path isDirectory:(NSNumber*)isDir;
- (void)removeAllIcons;
- (void)removeIcons:(NSArray*)paths;
- (void)setIcons:(NSDictionary*)iconDictionary filterByFolder:(NSString*)filterFolder;
diff --git a/shell_integration/MacOSX/LiferayNativityFinder/ContentManager.m b/shell_integration/MacOSX/LiferayNativityFinder/ContentManager.m
index 6427f2b..3a4ae1a 100644
--- a/shell_integration/MacOSX/LiferayNativityFinder/ContentManager.m
+++ b/shell_integration/MacOSX/LiferayNativityFinder/ContentManager.m
@@ -32,11 +32,11 @@ static ContentManager* sharedInstance = nil;
_fileNamesCache = [[NSMutableDictionary alloc] init];
_fileIconsEnabled = TRUE;
- [[IconCache sharedInstance] registerIcon:@"/Users/mackie/owncloud.com/mirall/shell_integration/icons/128x128/OK_128.png"];
- [[IconCache sharedInstance] registerIcon:@"/Users/mackie/owncloud.com/mirall/shell_integration/icons/128x128/Sync_128.png"];
- [[IconCache sharedInstance] registerIcon:@"/Users/mackie/owncloud.com/mirall/shell_integration/icons/128x128/Warning_128.png"];
- [[IconCache sharedInstance] registerIcon:@"/Users/mackie/owncloud.com/mirall/shell_integration/icons/128x128/Error_128.png"];
- [[IconCache sharedInstance] registerIcon:@"/Users/mackie/owncloud.com/mirall/shell_integration/icons/128x128/OK_Shared_128.png"];
+ [[IconCache sharedInstance] registerIcon:@"/Users/mackie/owncloud.com/mirall/shell_integration/icons/icns/ok.icns"];
+ [[IconCache sharedInstance] registerIcon:@"/Users/mackie/owncloud.com/mirall/shell_integration/icons/icns/sync.icns"];
+ [[IconCache sharedInstance] registerIcon:@"/Users/mackie/owncloud.com/mirall/shell_integration/icons/icns/sync.icns"];
+ [[IconCache sharedInstance] registerIcon:@"/Users/mackie/owncloud.com/mirall/shell_integration/icons/icns/sync.icns"];
+ [[IconCache sharedInstance] registerIcon:@"/Users/mackie/owncloud.com/mirall/shell_integration/icons/icns/sync.icns"];
}
@@ -97,7 +97,7 @@ static ContentManager* sharedInstance = nil;
[self repaintAllWindows];
}
-- (NSNumber*)iconByPath:(NSString*)path
+- (NSNumber*)iconByPath:(NSString*)path isDirectory:(NSNumber*)isDir
{
if (!_fileIconsEnabled)
{
@@ -105,21 +105,26 @@ static ContentManager* sharedInstance = nil;
// return nil;
}
+ if( path == nil ) {
+ NSNumber *res = [NSNumber numberWithInt:0];
+ return res;
+ }
NSString* normalizedPath = [path decomposedStringWithCanonicalMapping];
-
+
NSNumber* result = [_fileNamesCache objectForKey:normalizedPath];
NSLog(@"XXXXXXX Asking for icon for path %@ = %d",path, [result intValue]);
- if( result != nil ) {
- NSLog(@"Found icon index %d", [result intValue]);
- // there is a proper icon index
- } else {
- NSLog(@"Need to query for icon");
+ if( result == nil ) {
// start the async call
- NSNumber *minusOne = -1;
+ NSNumber* minusOne = [[NSNumber alloc] initWithInt:-1];
[_fileNamesCache setObject:minusOne forKey:normalizedPath];
- [[RequestManager sharedInstance] askForIcon:normalizedPath];
+ [[RequestManager sharedInstance] askForIcon:normalizedPath isDirectory:isDir];
+ result = [NSNumber numberWithInt:0];
+ } else if( [result intValue] == -1 ) {
+ // the socket call is underways.
result = [NSNumber numberWithInt:0];
+ } else {
+ // there is a proper icon index
}
NSLog(@"iconByPath return value %d", [result intValue]);
diff --git a/shell_integration/MacOSX/LiferayNativityFinder/IconOverlayHandlers.m b/shell_integration/MacOSX/LiferayNativityFinder/IconOverlayHandlers.m
index 6ff08a9..7f39eab 100644
--- a/shell_integration/MacOSX/LiferayNativityFinder/IconOverlayHandlers.m
+++ b/shell_integration/MacOSX/LiferayNativityFinder/IconOverlayHandlers.m
@@ -26,9 +26,16 @@
NSURL* url = [[NSClassFromString(@"FINode") nodeFromNodeRef:[(TIconAndTextCell*)self node]->fNodeRef] previewItemURL];
- NSNumber* imageIndex = [[ContentManager sharedInstance] iconByPath:[url path]];
-
- NSLog(@"The icon index is %d", [imageIndex intValue]);
+ NSError *error;
+ NSNumber *isDir = nil;
+ if (! [url getResourceValue:&isDir forKey:NSURLIsDirectoryKey error:&error]) {
+ // handle error
+ [isDir initWithBool:NO]; // lets assume its a file.
+ }
+
+ NSNumber* imageIndex = [[ContentManager sharedInstance] iconByPath:[url path] isDirectory:isDir];
+
+ NSLog(@"1 The icon index is %d", [imageIndex intValue]);
if ([imageIndex intValue] > 0)
{
NSImage* image = [[IconCache sharedInstance] getIcon:imageIndex];
@@ -63,8 +70,15 @@
NSURL* url = [node previewItemURL];
- NSNumber* imageIndex = [[ContentManager sharedInstance] iconByPath:[url path]];
- NSLog(@"The icon index is %d", [imageIndex intValue]);
+ NSError *error;
+ NSNumber *isDir = nil;
+ if (! [url getResourceValue:&isDir forKey:NSURLIsDirectoryKey error:&error]) {
+ // handle error
+ [isDir initWithBool:NO]; // lets assume its a file.
+ }
+
+ NSNumber* imageIndex = [[ContentManager sharedInstance] iconByPath:[url path] isDirectory:isDir];
+ NSLog(@"2 The icon index is %d", [imageIndex intValue]);
if ([imageIndex intValue] > 0)
{
@@ -113,6 +127,13 @@
NSURL *url;
+ NSError *error;
+ NSNumber *isDir = nil;
+ if (! [url getResourceValue:&isDir forKey:NSURLIsDirectoryKey error:&error]) {
+ // handle error
+ [isDir initWithBool:NO]; // lets assume its a file.
+ }
+
if ([fiNode respondsToSelector:@selector(previewItemURL)])
{
url = [fiNode previewItemURL];
@@ -121,8 +142,8 @@
return;
}
- NSNumber* imageIndex = [[ContentManager sharedInstance] iconByPath:[url path]];
- NSLog(@"The icon index is %d", [imageIndex intValue]);
+ NSNumber* imageIndex = [[ContentManager sharedInstance] iconByPath:[url path] isDirectory:isDir];
+ NSLog(@"3 The icon index is %d", [imageIndex intValue]);
if ([imageIndex intValue] > 0)
{
diff --git a/shell_integration/MacOSX/LiferayNativityFinder/RequestManager.h b/shell_integration/MacOSX/LiferayNativityFinder/RequestManager.h
index 6db388b..6f1f992 100644
--- a/shell_integration/MacOSX/LiferayNativityFinder/RequestManager.h
+++ b/shell_integration/MacOSX/LiferayNativityFinder/RequestManager.h
@@ -39,8 +39,8 @@
+ (RequestManager*)sharedInstance;
-- (void)askOnSocket:(NSString*)path;
-- (void)askForIcon:(NSString*)path;
+- (void)askOnSocket:(NSString*)path query:(NSString*)verb;
+- (void)askForIcon:(NSString*)path isDirectory:(NSNumber*)isDir;
- (void)menuItemClicked:(NSDictionary*)actionDictionary;
- (NSArray*)menuItemsForFiles:(NSArray*)files;
- (void)start;
diff --git a/shell_integration/MacOSX/LiferayNativityFinder/RequestManager.m b/shell_integration/MacOSX/LiferayNativityFinder/RequestManager.m
index e99ecb5..05afb68 100644
--- a/shell_integration/MacOSX/LiferayNativityFinder/RequestManager.m
+++ b/shell_integration/MacOSX/LiferayNativityFinder/RequestManager.m
@@ -14,7 +14,6 @@
#import "ContentManager.h"
#import "IconCache.h"
-#import "JSONKit.h"
#import "RequestManager.h"
#define READ_TAG 2422
@@ -46,12 +45,6 @@ static RequestManager* sharedInstance = nil;
[_socket disconnect];
[_socket release];
- // dispatch_release(_listenQueue);
-
- // [_callbackMsgs release];
-
- // [_filterFolder release];
-
sharedInstance = nil;
[super dealloc];
@@ -71,10 +64,12 @@ static RequestManager* sharedInstance = nil;
}
-- (void)askOnSocket:(NSString*)path
+- (void)askOnSocket:(NSString*)path query:(NSString*)verb
{
- NSLog(@"XX on Socket for %@", path);
- NSData* data = [[NSString stringWithFormat:@"RETRIEVE_FILE_STATUS:%@\n", path] dataUsingEncoding:NSUTF8StringEncoding];
+ NSString *query = [NSString stringWithFormat:@"%@:%@\n", verb,path];
+ NSLog(@"Query: %@", query);
+
+ NSData* data = [query dataUsingEncoding:NSUTF8StringEncoding];
[_socket writeData:data withTimeout:5 tag:4711];
NSData* stop = [@"\n" dataUsingEncoding:NSUTF8StringEncoding];
@@ -82,10 +77,15 @@ static RequestManager* sharedInstance = nil;
}
-- (void)askForIcon:(NSString*)path
+- (void)askForIcon:(NSString*)path isDirectory:(NSNumber*)isDir
{
+ NSString *verb = @"RETRIEVE_FILE_STATUS";
if( _isConnected ) {
- [self askOnSocket:path];
+ if( [isDir boolValue] ) {
+ verb = @"RETRIEVE_FOLDER_STATUS";
+ }
+
+ [self askOnSocket:path query:verb];
} else {
[_requestQueue addObject:path];
}
@@ -112,20 +112,24 @@ static RequestManager* sharedInstance = nil;
{
if( tag == READ_TAG) {
- NSString* a1 = [NSString stringWithUTF8String:[data bytes]];
-
- NSString *answer = [a1 stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]];
- NSLog(@"READ from socket (%ld): AA%@OO", tag, answer);
+ NSString *answer = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
+
+ // Cut the trailing newline.
+ if ([answer length] > 0) {
+ answer = [answer substringToIndex:[answer length] - 1];
+ }
+
+ NSLog(@"READ from socket (%ld): <%@>", tag, answer);
- if( answer != nil ) {
- NSArray *chunks = [answer componentsSeparatedByString: @":"];
- // FIXME: Check if chunks[0] equals "STATUS"
- if( [chunks count] > 0 && [[chunks objectAtIndex:0] isEqualToString:@"STATUS"] ) {
- ContentManager *contentman = [ContentManager sharedInstance];
- [contentman setResultForPath:[chunks objectAtIndex:2] result:[chunks objectAtIndex:1]];
+ if( answer != nil ) {
+ NSArray *chunks = [answer componentsSeparatedByString: @":"];
+
+ if( [chunks count] > 0 && [[chunks objectAtIndex:0] isEqualToString:@"STATUS"] ) {
+ ContentManager *contentman = [ContentManager sharedInstance];
+ [contentman setResultForPath:[chunks objectAtIndex:2] result:[chunks objectAtIndex:1]];
+ }
}
}
- }
}
- (NSTimeInterval)socket:(GCDAsyncSocket*)socket shouldTimeoutReadWithTag:(long)tag elapsed:(NSTimeInterval)elapsed bytesDone:(NSUInteger)length
diff --git a/shell_integration/MacOSX/deploy.sh b/shell_integration/MacOSX/deploy.sh
index 3476901..13bbbce 100644
--- a/shell_integration/MacOSX/deploy.sh
+++ b/shell_integration/MacOSX/deploy.sh
@@ -2,7 +2,7 @@
# osascript $HOME/owncloud.com/mirall/shell_integration/MacOSX/unload.scpt
sudo rm -rf /Library/ScriptingAdditions/LiferayNativity.osax
-sudo cp -r $HOME/Library/Developer/Xcode/DerivedData/LiferayNativity-flulyntyemvwtcgiriaddqfewwvc/Build/Products/Debug/LiferayNativity.osax /Library/ScriptingAdditions/
+sudo cp -r $HOME/Library/Developer/Xcode/DerivedData/LiferayNativity-gvtginoclfyisuagangtxsfbuztw/Build/Products/Debug/LiferayNativity.osax /Library/ScriptingAdditions/
sudo killall Finder
sleep 1
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list