Use user catalog displayname when displaying an account node
authorMiltiadis Vasilakis <mvasilak@gmail.com>
Tue, 19 Feb 2013 11:12:51 +0000 (13:12 +0200)
committerMiltiadis Vasilakis <mvasilak@gmail.com>
Tue, 19 Feb 2013 16:17:19 +0000 (18:17 +0200)
pithos-macos/PithosAccount.m
pithos-macos/PithosAccountNode.m
pithos-macos/PithosBrowserController.h
pithos-macos/PithosBrowserController.m
pithos-macos/PithosContainerNode.m
pithos-macos/PithosSharingAccountsNode.m
pithos-macos/pithos_macosAppDelegate.m

index 5329bcd..1edfbc3 100644 (file)
         sharingAccountsNode = [[PithosSharingAccountsNode alloc] initWithPithos:self.pithos];
         sharingAccountsNode.childrenUpdatedNotificationName = nil;
         sharingAccountsNode.inheritChildrenUpdatedNotificationName = YES;
+        sharingAccountsNode.pithosAccountManager = self;
     }
     return sharingAccountsNode;
 }
index 51b5c61..ee1ded1 100644 (file)
@@ -185,8 +185,15 @@ static NSImage *sharedIcon = nil;
 }
 
 - (NSString *)displayName {
-    if (displayName == nil)
-        return [NSString stringWithString:(sharingAccount ? sharingAccount : @"account")];
+    if (displayName == nil) {
+        if (!sharingAccount) {
+            return @"account";
+        } else if (pithosAccountManager) {
+            return [pithosAccountManager displaynameForUUID:sharingAccount safe:YES];
+        } else {
+            return [sharingAccount copy];
+        }
+    }
     return [displayName copy];
 }
 
@@ -254,6 +261,7 @@ static NSImage *sharedIcon = nil;
                         node.shared = shared;
                         node.sharingAccount = sharingAccount;
                         node.inheritChildrenUpdatedNotificationName = inheritChildrenUpdatedNotificationName;
+                        node.pithosAccountManager = pithosAccountManager;
                         if (children) {
                             NSUInteger oldIndex = [children indexOfObject:node];
                             if (oldIndex != NSNotFound) {
index 6a307f8..4473c55 100644 (file)
@@ -38,6 +38,7 @@
 #import <Cocoa/Cocoa.h>
 #import "PithosActivityFacility.h"
 @class ASIPithos;
+@class PithosAccount;
 @class PithosNode;
 @class PithosAccountNode;
 @class PithosSharingAccountsNode;
@@ -51,6 +52,7 @@
     
     ASIPithos *pithos;
     
+    PithosAccount *__unsafe_unretained pithosAccountManager;
     PithosNode *rootNode;
     PithosAccountNode *accountNode;
     PithosEmptyNode *containersNode;
 
 @property (nonatomic, strong) ASIPithos *pithos;
 
+@property (nonatomic, unsafe_unretained) PithosAccount *pithosAccountManager;
 @property (nonatomic, strong) PithosAccountNode *accountNode;
 
 @property (nonatomic, unsafe_unretained) IBOutlet NSSplitView *verticalSplitView;
index d753e9f..205bfb8 100644 (file)
 
 @implementation PithosBrowserController
 @synthesize pithos;
-@synthesize accountNode;
+@synthesize pithosAccountManager, accountNode;
 @synthesize verticalSplitView, horizontalSplitView, leftTopView, leftBottomView, outlineView, browser, outlineViewMenu, browserMenu;
 @synthesize draggedNodes, draggedParentNode;
 @synthesize clipboardNodes, clipboardParentNode, clipboardCopy;
     activityFacility = [PithosActivityFacility defaultPithosActivityFacility];
     
     self.accountNode = [[PithosAccountNode alloc] initWithPithos:pithos];
+    accountNode.pithosAccountManager = pithosAccountManager;
     containersNode = [[PithosEmptyNode alloc] initWithDisplayName:@"CONTAINERS" icon:nil];
     containersNodeChildren = [[NSMutableArray alloc] init];
     sharedNode = [[PithosEmptyNode alloc] initWithDisplayName:@"SHARED" icon:nil];
     mySharedNode = [[PithosAccountNode alloc] initWithPithos:pithos];
+    mySharedNode.pithosAccountManager = pithosAccountManager;
     mySharedNode.displayName = @"shared by me";
     mySharedNode.shared = YES;
     mySharedNode.icon = [[NSWorkspace sharedWorkspace] iconForFileType:NSFileTypeForHFSTypeCode(kUserIcon)];
     othersSharedNode = [[PithosSharingAccountsNode alloc] initWithPithos:pithos];
+    othersSharedNode.pithosAccountManager = pithosAccountManager;
     othersSharedNode.displayName = @"shared with me";
     othersSharedNode.icon = [[NSWorkspace sharedWorkspace] iconForFileType:NSFileTypeForHFSTypeCode(kGroupIcon)];
     
     [downloadCallbackQueue setSuspended:NO];
 
     accountNode.pithos = pithos;
+    accountNode.pithosAccountManager = pithosAccountManager;
     [accountNode forceRefresh];
     mySharedNode.pithos = pithos;
+    mySharedNode.pithosAccountManager = pithosAccountManager;
     [mySharedNode forceRefresh];
     othersSharedNode.pithos = pithos;
+    othersSharedNode.pithosAccountManager = pithosAccountManager;
     [othersSharedNode forceRefresh];
             
 //    [activityFacility reset];
index c144fd5..8336b31 100644 (file)
@@ -276,6 +276,7 @@ static NSImage *sharedIcon = nil;
                                     node.shared = shared;
                                     node.sharingAccount = sharingAccount;
                                     node.inheritChildrenUpdatedNotificationName = inheritChildrenUpdatedNotificationName;
+                                    node.pithosAccountManager = pithosAccountManager;
                                     if (children) {
                                         NSUInteger oldIndex = [children indexOfObject:node];
                                         if (oldIndex != NSNotFound) {
@@ -299,6 +300,7 @@ static NSImage *sharedIcon = nil;
                                 node.shared = shared;
                                 node.sharingAccount = sharingAccount;
                                 node.inheritChildrenUpdatedNotificationName = inheritChildrenUpdatedNotificationName;
+                                node.pithosAccountManager = pithosAccountManager;
                                 if (children) {
                                     NSUInteger oldIndex = [children indexOfObject:node];
                                     if (oldIndex != NSNotFound) {
@@ -319,6 +321,7 @@ static NSImage *sharedIcon = nil;
                                 node.shared = shared;
                                 node.sharingAccount = sharingAccount;
                                 node.inheritChildrenUpdatedNotificationName = inheritChildrenUpdatedNotificationName;
+                                node.pithosAccountManager = pithosAccountManager;
                                 if (children) {
                                     NSUInteger oldIndex = [children indexOfObject:node];
                                     if (oldIndex != NSNotFound) {
index a04650d..b03192d 100644 (file)
@@ -41,6 +41,7 @@
 #import "ASIPithos.h"
 #import "ASIPithosAccount.h"
 #import "ASIDownloadCache.h"
+#import "PithosAccount.h"
 #import "PithosUtilities.h"
 #import "PithosActivityFacility.h"
 
                     DLog(@"using newChildren");
                     newChildren = [[NSMutableArray alloc] init];
                     NSMutableIndexSet *keptNodes = [NSMutableIndexSet indexSet];
+                    NSMutableArray *sharingAccountsNames = [NSMutableArray arrayWithCapacity:sharingAccounts.count];
                     for (ASIPithosAccount *account in sharingAccounts) {
+                        [sharingAccountsNames addObject:account.name];
                         if (![account.name isEqualToString:pithos.authUser]) {
                             PithosAccountNode *node = [[PithosAccountNode alloc] initWithPithos:pithos];
                             node.parent = self;
                             node.shared = shared;
                             node.sharingAccount = account.name;
                             node.inheritChildrenUpdatedNotificationName = inheritChildrenUpdatedNotificationName;
+                            node.pithosAccountManager = pithosAccountManager;
                             if (children) {
                                 NSUInteger oldIndex = [children indexOfObject:node];
                                 if (oldIndex != NSNotFound) {
                             [newChildren addObject:node];
                         }
                     }
+                    [pithosAccountManager updateUserCatalogForForDisplaynames:nil UUIDs:sharingAccountsNames];
                     [[children objectsAtIndexes:
                       [[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [children count])] indexesPassingTest:^(NSUInteger idx, BOOL *stop){
                         if ([keptNodes containsIndex:idx])
index 72b75da..3c78a73 100644 (file)
@@ -104,6 +104,7 @@ currentPithosAccount, pithosAccounts, pithosAccountsDictionary, syncPithosAccoun
     
     if (currentPithosAccount.active) {
         [self savePithosAccounts:self];
+        self.pithosBrowserController.pithosAccountManager = currentPithosAccount;
         [self showPithosBrowser:self];
         self.pithosBrowserController.pithos = currentPithosAccount.pithos;
     } else {
@@ -448,6 +449,7 @@ void LSSharedFileListChanged(LSSharedFileListRef inList, void *context) {
         for (PithosAccount *pithosAccount in pithosAccounts) {
             if (pithosAccount.active) {
                 self.currentPithosAccount = pithosAccount;
+                self.pithosBrowserController.pithosAccountManager = currentPithosAccount;
                 self.pithosBrowserController.pithos = currentPithosAccount.pithos;
                 break;
             }
@@ -555,6 +557,7 @@ void LSSharedFileListChanged(LSSharedFileListRef inList, void *context) {
                 return;
         }
         self.currentPithosAccount = pithosAccount;
+        self.pithosBrowserController.pithosAccountManager = currentPithosAccount;
         [self showPithosBrowser:self];
         self.pithosBrowserController.pithos = currentPithosAccount.pithos;
     }