[Pkg-owncloud-commits] [owncloud-client] 265/332: MacOverlays: Registered pathes support.

Sandro Knauß hefee-guest at moszumanska.debian.org
Thu Aug 14 21:07:10 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 5a5c03a82660366f453c6847f748138c2823bed5
Author: Klaas Freitag <freitag at owncloud.com>
Date:   Thu Jul 17 19:29:02 2014 +0200

    MacOverlays: Registered pathes support.
    
    Remember the pathes that come with the first UPDATE_VIEW msg. That
    reduces the number of socket communications.
---
 .../UserInterfaceState.xcuserstate                 | Bin 33056 -> 33964 bytes
 .../MacOSX/LiferayNativityFinder/ContentManager.m  |  25 ++++++---
 .../MacOSX/LiferayNativityFinder/RequestManager.h  |   4 +-
 .../MacOSX/LiferayNativityFinder/RequestManager.m  |  62 +++++++++++++++++----
 4 files changed, 70 insertions(+), 21 deletions(-)

diff --git a/shell_integration/MacOSX/LiferayNativity.xcworkspace/xcuserdata/mackie.xcuserdatad/UserInterfaceState.xcuserstate b/shell_integration/MacOSX/LiferayNativity.xcworkspace/xcuserdata/mackie.xcuserdatad/UserInterfaceState.xcuserstate
index 0d18ea8..142c955 100644
Binary files a/shell_integration/MacOSX/LiferayNativity.xcworkspace/xcuserdata/mackie.xcuserdatad/UserInterfaceState.xcuserstate and b/shell_integration/MacOSX/LiferayNativity.xcworkspace/xcuserdata/mackie.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/shell_integration/MacOSX/LiferayNativityFinder/ContentManager.m b/shell_integration/MacOSX/LiferayNativityFinder/ContentManager.m
index 6e34b5f..bc38730 100644
--- a/shell_integration/MacOSX/LiferayNativityFinder/ContentManager.m
+++ b/shell_integration/MacOSX/LiferayNativityFinder/ContentManager.m
@@ -31,7 +31,7 @@ static ContentManager* sharedInstance = nil;
 	{
 		_fileNamesCache = [[NSMutableDictionary alloc] init];
 		_fileIconsEnabled = TRUE;
-		
+
 		// FIXME: Proper path here!
 		NSString *base = @"/Users/mackie/owncloud.com/mirall/shell_integration/icons/icns/";
 		
@@ -133,9 +133,9 @@ static ContentManager* sharedInstance = nil;
 	
 	if( result == nil ) {
 		// start the async call
-		NSNumber* minusOne = [[NSNumber alloc] initWithInt:-1];
-		[_fileNamesCache setObject:minusOne forKey:normalizedPath];
-		[[RequestManager sharedInstance] askForIcon:normalizedPath isDirectory:isDir];
+		NSNumber *askState = [[RequestManager sharedInstance] askForIcon:normalizedPath isDirectory:isDir];
+		[_fileNamesCache setObject:askState forKey:normalizedPath];
+
 		result = [NSNumber numberWithInt:0];
 	} else if( [result intValue] == -1 ) {
 		// the socket call is underways.
@@ -144,7 +144,7 @@ static ContentManager* sharedInstance = nil;
 		// there is a proper icon index
 	}
     // NSLog(@"iconByPath return value %d", [result intValue]);
-	
+
 	return result;
 }
 
@@ -155,11 +155,18 @@ static ContentManager* sharedInstance = nil;
 	NSMutableArray *keysToDelete = [NSMutableArray array];
 	NSLog(@"Clearing the cache for %@", path);
 	
-	for (id p in [_fileNamesCache keyEnumerator]) {
-		//do stuff with obj
-		if ( [p hasPrefix:path] ) {
-			[keysToDelete addObject:p];
+	if( path != nil ) {
+		for (id p in [_fileNamesCache keyEnumerator]) {
+			//do stuff with obj
+			if ( [p hasPrefix:path] ) {
+				[keysToDelete addObject:p];
+			}
 		}
+	} else {
+		// clear the entire fileNameCache
+		[_fileNamesCache release];
+		_fileNamesCache = [[NSMutableDictionary alloc] init];
+		return;
 	}
 	
 	if( [keysToDelete count] > 0 ) {
diff --git a/shell_integration/MacOSX/LiferayNativityFinder/RequestManager.h b/shell_integration/MacOSX/LiferayNativityFinder/RequestManager.h
index 9f6e443..d88edf3 100644
--- a/shell_integration/MacOSX/LiferayNativityFinder/RequestManager.h
+++ b/shell_integration/MacOSX/LiferayNativityFinder/RequestManager.h
@@ -21,6 +21,7 @@
 	GCDAsyncSocket* _socket;
 
 	NSMutableArray* _requestQueue;
+	NSMutableDictionary* _registeredPathes;
 	
 	BOOL _isRunning;
 	BOOL _isConnected;
@@ -30,8 +31,9 @@
 
 + (RequestManager*)sharedInstance;
 
+- (BOOL)isRegisteredPath:(NSString*)path;
 - (void)askOnSocket:(NSString*)path query:(NSString*)verb;
-- (void)askForIcon:(NSString*)path isDirectory:(NSNumber*)isDir;
+- (NSNumber*)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 b3c9e38..7bb9553 100644
--- a/shell_integration/MacOSX/LiferayNativityFinder/RequestManager.m
+++ b/shell_integration/MacOSX/LiferayNativityFinder/RequestManager.m
@@ -31,6 +31,8 @@ static RequestManager* sharedInstance = nil;
 		_isRunning = NO;
 		_isConnected = NO;
 
+		_registeredPathes = [[NSMutableDictionary alloc] init];
+
 		[self start];
 	}
 
@@ -75,19 +77,45 @@ static RequestManager* sharedInstance = nil;
 }
 
 
-- (void)askForIcon:(NSString*)path isDirectory:(NSNumber*)isDir
+- (BOOL)isRegisteredPath:(NSString*)path
+{
+	// check if the file in question is underneath a registered directory
+	NSArray *regPathes = [_registeredPathes allKeys];
+	BOOL registered = NO;
+
+	for( NSString *regPath in regPathes ) {
+		if( [path hasPrefix:regPath]) {
+			// the path was registered
+			registered = YES;
+			break;
+		}
+	}
+
+	return registered;
+}
+
+- (NSNumber*)askForIcon:(NSString*)path isDirectory:(NSNumber*)isDir
 {
 	NSString *verb = @"RETRIEVE_FILE_STATUS";
-	if( _isConnected ) {
-		if( [isDir boolValue] ) {
-			verb = @"RETRIEVE_FOLDER_STATUS";
+	NSNumber *res = [NSNumber numberWithInt:0];
+
+	if( [self isRegisteredPath:path] ) {
+		if( _isConnected ) {
+			if( [isDir boolValue] ) {
+				verb = @"RETRIEVE_FOLDER_STATUS";
+			}
+
+			[self askOnSocket:path query:verb];
+
+			NSNumber *res_minus_one = [NSNumber numberWithInt:0];
+
+			return res_minus_one;
+		} else {
+			[_requestQueue addObject:path];
+			[self start]; // try again to connect
 		}
-		
-		[self askOnSocket:path query:verb];
-	} else {
-		[_requestQueue addObject:path];
-		[self start]; // try again to connect
 	}
+	return res;
 }
 
 
@@ -107,7 +135,11 @@ static RequestManager* sharedInstance = nil;
 		if( [[chunks objectAtIndex:0] isEqualToString:@"STATUS"] ) {
 			[contentman setResultForPath:[chunks objectAtIndex:2] result:[chunks objectAtIndex:1]];
 		} else if( [[chunks objectAtIndex:0] isEqualToString:@"UPDATE_VIEW"] ) {
-			[contentman clearFileNameCacheForPath:[chunks objectAtIndex:1]]; // Fixme: index1 can be empty
+			NSString *path = [chunks objectAtIndex:1];
+			NSNumber *one = [NSNumber numberWithInt:1];
+			[_registeredPathes setObject:one forKey:path];
+
+			[contentman clearFileNameCacheForPath:path]; // Fixme: index1 can be empty
 		} else {
 			NSLog(@"Unknown command %@", [chunks objectAtIndex:0]);
 		}
@@ -131,7 +163,7 @@ static RequestManager* sharedInstance = nil;
 	NSLog( @"Connected to host successfully!");
 	_isConnected = YES;
 	_isRunning = NO;
-	
+
 	if( [_requestQueue count] > 0 ) {
 		NSLog( @"We have to empty the queue");
 		for( NSString *path in _requestQueue ) {
@@ -154,6 +186,14 @@ static RequestManager* sharedInstance = nil;
 	if( err ) {
 		NSLog(@"ERROR: %@", [err localizedDescription]);
 	}
+
+	// clear the registered pathes.
+	[_registeredPathes release];
+	_registeredPathes = [[NSMutableDictionary alloc] init];
+
+    // clear the caches in conent manager
+	ContentManager *contentman = [ContentManager sharedInstance];
+	[contentman clearFileNameCacheForPath:nil];
 }
 
 

-- 
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