shell_integration on OSX: Remove dead code
authorJocelyn Turcotte <jturcotte@woboq.com>
Wed, 6 May 2015 10:49:04 +0000 (12:49 +0200)
committerJocelyn Turcotte <jturcotte@woboq.com>
Wed, 6 May 2015 14:56:50 +0000 (16:56 +0200)
removeIcons isn't called and clearFileNameCacheForPath was always
called with a "nil" path.

Remove the return value of askForIcon which was always 0, and use
that value explicitly at the only call site.

Remove the "-1" code path in iconByPath since setIcons prevents
-1 from getting into _fileNamesCache in all cases.

shell_integration/MacOSX/OwnCloudFinder/ContentManager.h
shell_integration/MacOSX/OwnCloudFinder/ContentManager.m
shell_integration/MacOSX/OwnCloudFinder/RequestManager.h
shell_integration/MacOSX/OwnCloudFinder/RequestManager.m

index 2de92bc16cbd594f6a3c253f36cbebd0a4875df7..31d26dbf2a5ad507240dfd5e8e88f4c53da1f319 100644 (file)
 - (void)enableFileIcons:(BOOL)enable;
 - (NSNumber*)iconByPath:(NSString*)path isDirectory:(BOOL)isDir;
 - (void)removeAllIcons;
-- (void)removeIcons:(NSArray*)paths;
 - (void)setIcons:(NSDictionary*)iconDictionary filterByFolder:(NSString*)filterFolder;
 - (void)setResultForPath:(NSString*)path result:(NSString*)result;
-- (void)clearFileNameCacheForPath:(NSString*)path;
+- (void)clearFileNameCache;
 - (void)reFetchFileNameCacheForPath:(NSString*)path;
 - (void)repaintAllWindows;
 
index 5ef4efee19859d80fe5a534b12da4ccbb52a064f..941390ded0ade0897158695a8645aab692010df8 100644 (file)
@@ -148,46 +148,21 @@ static ContentManager* sharedInstance = nil;
        
        if( result == nil ) {
                // start the async call
-               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.
+               [[RequestManager sharedInstance] askForIcon:normalizedPath isDirectory:isDir];
                result = [NSNumber numberWithInt:0];
-       } else {
-               // there is a proper icon index
+               // Set 0 into the cache, meaning "don't have an icon, but already requested it"
+               [_fileNamesCache setObject:result forKey:normalizedPath];
        }
-    // NSLog(@"iconByPath return value %d", [result intValue]);
+       // NSLog(@"iconByPath return value %d", [result intValue]);
 
        return result;
 }
 
-// called as a result of an UPDATE_VIEW message.
-// it clears the entries from the hash to make it call again home to the desktop client.
-- (void)clearFileNameCacheForPath:(NSString*)path
+// Clears the entries from the hash to make it call again home to the desktop client.
+- (void)clearFileNameCache
 {
-       //NSLog(@"%@", NSStringFromSelector(_cmd));
-       NSMutableArray *keysToDelete = [NSMutableArray array];
-       
-       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 ) {
-               NSLog( @"Entries to delete: %lu", (unsigned long)[keysToDelete count]);
-               [_fileNamesCache removeObjectsForKeys:keysToDelete];
-       }
+       [_fileNamesCache release];
+       _fileNamesCache = [[NSMutableDictionary alloc] init];
 }
 
 - (void)reFetchFileNameCacheForPath:(NSString*)path
@@ -218,18 +193,6 @@ static ContentManager* sharedInstance = nil;
        [self repaintAllWindows];
 }
 
-- (void)removeIcons:(NSArray*)paths
-{
-       for (NSString* path in paths)
-       {
-               NSString* normalizedPath = [path decomposedStringWithCanonicalMapping];
-
-               [_fileNamesCache removeObjectForKey:normalizedPath];
-       }
-
-       [self repaintAllWindows];
-}
-
 - (void)repaintAllWindowsIfNeeded
 {
        if (!_hasChangedContent) {
index 99436dcb5a9beb721b456ababf77cafca8e03ee4..130c885c6c157e0c6c792e8a2fe312029a41f8a1 100644 (file)
@@ -34,7 +34,7 @@
 
 - (BOOL)isRegisteredPath:(NSString*)path isDirectory:(BOOL)isDir;
 - (void)askOnSocket:(NSString*)path query:(NSString*)verb;
-- (NSNumber*)askForIcon:(NSString*)path isDirectory:(BOOL)isDir;
+- (void)askForIcon:(NSString*)path isDirectory:(BOOL)isDir;
 - (void)menuItemClicked:(NSDictionary*)actionDictionary;
 - (void)start;
 
index 888b4d5d771e5bc48be4f2fa38b1c9338d97aa9b..52f5d9f54ca23704e5a8829afd410d8939f5ad94 100644 (file)
@@ -101,10 +101,9 @@ static RequestManager* sharedInstance = nil;
        return registered;
 }
 
-- (NSNumber*)askForIcon:(NSString*)path isDirectory:(BOOL)isDir
+- (void)askForIcon:(NSString*)path isDirectory:(BOOL)isDir
 {
        NSString *verb = @"RETRIEVE_FILE_STATUS";
-       NSNumber *res = [NSNumber numberWithInt:0];
 
        if( [self isRegisteredPath:path isDirectory:isDir] ) {
                if( _isConnected ) {
@@ -113,16 +112,11 @@ static RequestManager* sharedInstance = nil;
                        }
 
                        [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
                }
        }
-       return res;
 }
 
 
@@ -201,7 +195,7 @@ static RequestManager* sharedInstance = nil;
        }
 
        ContentManager *contentman = [ContentManager sharedInstance];
-       [contentman clearFileNameCacheForPath:nil];
+       [contentman clearFileNameCache];
        [contentman repaintAllWindows];
 
        // Read for the UPDATE_VIEW requests
@@ -221,7 +215,7 @@ static RequestManager* sharedInstance = nil;
 
     // clear the caches in conent manager
        ContentManager *contentman = [ContentManager sharedInstance];
-       [contentman clearFileNameCacheForPath:nil];
+       [contentman clearFileNameCache];
        [contentman repaintAllWindows];
 }