- (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;
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
[self repaintAllWindows];
}
-- (void)removeIcons:(NSArray*)paths
-{
- for (NSString* path in paths)
- {
- NSString* normalizedPath = [path decomposedStringWithCanonicalMapping];
-
- [_fileNamesCache removeObjectForKey:normalizedPath];
- }
-
- [self repaintAllWindows];
-}
-
- (void)repaintAllWindowsIfNeeded
{
if (!_hasChangedContent) {
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 ) {
}
[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;
}
}
ContentManager *contentman = [ContentManager sharedInstance];
- [contentman clearFileNameCacheForPath:nil];
+ [contentman clearFileNameCache];
[contentman repaintAllWindows];
// Read for the UPDATE_VIEW requests
// clear the caches in conent manager
ContentManager *contentman = [ContentManager sharedInstance];
- [contentman clearFileNameCacheForPath:nil];
+ [contentman clearFileNameCache];
[contentman repaintAllWindows];
}