if (!accountNode) {
accountNode = [[PithosAccountNode alloc] initWithPithos:self.pithos];
accountNode.childrenUpdatedNotificationName = nil;
+ accountNode.inheritChildrenUpdatedNotificationName = YES;
}
return accountNode;
}
- (id)initWithPithos:(ASIPithos *)aPithos {
if ((self = [super init])) {
self.pithos = aPithos;
- self.childrenUpdatedNotificationName = [NSString stringWithString:@"PithosAccountNodeChildrenUpdated"];
}
return self;
}
node.parent = self;
node.shared = shared;
node.sharingAccount = sharingAccount;
+ node.inheritChildrenUpdatedNotificationName = inheritChildrenUpdatedNotificationName;
if (children) {
NSUInteger oldIndex = [children indexOfObject:node];
if (oldIndex != NSNotFound) {
@synchronized(self) {
freshness = PithosNodeStateRefreshFinished;
}
- if (childrenUpdatedNotificationName) {
- // Notify observers that children are updated
- [[NSNotificationCenter defaultCenter] postNotificationName:childrenUpdatedNotificationName object:self];
- }
+ [self postChildrenUpdatedNotificationName];
} else {
[accountRequest release];
// Do an additional request to fetch more objects
@synchronized(self) {
freshness = PithosNodeStateRefreshFinished;
}
- if (childrenUpdatedNotificationName) {
- // Notify observers that children are updated
- [[NSNotificationCenter defaultCenter] postNotificationName:childrenUpdatedNotificationName object:self];
- }
+ [self postChildrenUpdatedNotificationName];
} else {
[self accountRequestFailed:accountRequest];
}
[[[outlineView tableColumns] objectAtIndex:0] setDataCell:[[[PithosOutlineViewCell alloc] init] autorelease]];
// Register for updates
- // PithosContainerNode updates browser nodes
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(pithosNodeChildrenUpdated:)
- name:@"PithosContainerNodeChildrenUpdated"
- object:nil];
- // PithosSubdirNode updates browser nodes
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(pithosNodeChildrenUpdated:)
- name:@"PithosSubdirNodeChildrenUpdated"
- object:nil];
// PithosAccountNode accountNode updates outlineView container nodes
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(pithosAccountNodeChildrenUpdated:)
- name:@"PithosAccountNodeChildrenUpdated"
+ name:@"PithosNodeChildrenUpdated"
object:accountNode];
- // PithosAccountNode other than accountNode updates nodes
+ // PithosNode updates browser nodes
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(pithosNodeChildrenUpdated:)
- name:@"PithosAccountNodeChildrenUpdated"
+ name:@"PithosNodeChildrenUpdated"
object:nil];
- // PithosSharingAccountsNode othersSharedNode updates browser nodes
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(pithosNodeChildrenUpdated:)
- name:@"PithosSharingAccountsNodeChildrenUpdated"
- object:othersSharedNode];
// Request for browser refresh
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(pithosBrowserRefreshNeeded:)
- (void)pithosNodeChildrenUpdated:(NSNotification *)notification {
PithosNode *node = (PithosNode *)[notification object];
- if (node == accountNode)
+ if ((node == accountNode) || ![node.pithos isEqualTo:pithos])
return;
NSLog(@"pithosNodeChildrenUpdated:%@", node.url);
NSInteger lastColumn = [browser lastColumn];
self.pithosContainer = aPithosContainer;
prefix = nil;
self.icon = anIcon;
- self.childrenUpdatedNotificationName = [NSString stringWithString:@"PithosContainerNodeChildrenUpdated"];
}
return self;
}
node.parent = self;
node.shared = shared;
node.sharingAccount = sharingAccount;
+ node.inheritChildrenUpdatedNotificationName = inheritChildrenUpdatedNotificationName;
if (children) {
NSUInteger oldIndex = [children indexOfObject:node];
if (oldIndex != NSNotFound) {
node.parent = self;
node.shared = shared;
node.sharingAccount = sharingAccount;
+ node.inheritChildrenUpdatedNotificationName = inheritChildrenUpdatedNotificationName;
if (children) {
NSUInteger oldIndex = [children indexOfObject:node];
if (oldIndex != NSNotFound) {
node.parent = self;
node.shared = shared;
node.sharingAccount = sharingAccount;
+ node.inheritChildrenUpdatedNotificationName = inheritChildrenUpdatedNotificationName;
if (children) {
NSUInteger oldIndex = [children indexOfObject:node];
if (oldIndex != NSNotFound) {
@synchronized(self) {
freshness = PithosNodeStateRefreshFinished;
}
- if (childrenUpdatedNotificationName) {
- // Notify observers that children are updated
- [[NSNotificationCenter defaultCenter] postNotificationName:childrenUpdatedNotificationName object:self];
- }
+ [self postChildrenUpdatedNotificationName];
} else {
[containerRequest release];
// Do an additional request to fetch more objects
@synchronized(self) {
freshness = PithosNodeStateRefreshFinished;
}
- if (childrenUpdatedNotificationName) {
- // Notify observers that children are updated
- [[NSNotificationCenter defaultCenter] postNotificationName:childrenUpdatedNotificationName object:self];
- }
+ [self postChildrenUpdatedNotificationName];
} else {
[self containerRequestFailed:containerRequest];
}
NSMutableArray *children;
NSMutableArray *newChildren;
NSString *childrenUpdatedNotificationName;
+ BOOL inheritChildrenUpdatedNotificationName;
NSString *displayName;
BOOL isLeafItem;
@property(nonatomic, retain) NSString *sharingAccount;
@property(nonatomic, readonly) NSArray *children;
@property(nonatomic, retain) NSString *childrenUpdatedNotificationName;
+@property(nonatomic, assign) BOOL inheritChildrenUpdatedNotificationName;
@property(nonatomic, retain) NSString *displayName;
@property(nonatomic, readonly) BOOL isLeafItem;
- (void)refresh;
- (void)forceRefresh;
+- (void) postChildrenUpdatedNotificationName;
+
- (void)showPithosNodeInfo:(id)sender;
- (void)pithosNodeInfoWillClose:(id)sender;
#import "ASIPithosRequest.h"
@implementation PithosNode
-@synthesize forcedRefresh, parent, shared, sharingAccount, childrenUpdatedNotificationName, displayName, isLeafItem, icon;
+@synthesize forcedRefresh, parent, shared, sharingAccount, childrenUpdatedNotificationName,
+ inheritChildrenUpdatedNotificationName, displayName, isLeafItem, icon;
@dynamic url, children, pithos, pithosAccount, pithosContainer, pithosObject;
#pragma mark -
forcedRefresh = NO;
shared = NO;
isLeafItem = NO;
+ self.childrenUpdatedNotificationName = @"PithosNodeChildrenUpdated";
+ inheritChildrenUpdatedNotificationName = NO;
}
return self;
}
[self refresh];
}
+- (void)postChildrenUpdatedNotificationName {
+ // Notify observers that children are updated
+ if (inheritChildrenUpdatedNotificationName) {
+ PithosNode *ancestor = self;
+ while (ancestor && ancestor.parent) {
+ ancestor = ancestor.parent;
+ }
+ if (ancestor && ancestor.childrenUpdatedNotificationName) {
+ [[NSNotificationCenter defaultCenter] postNotificationName:ancestor.childrenUpdatedNotificationName object:self];
+ }
+ } else if (childrenUpdatedNotificationName) {
+ [[NSNotificationCenter defaultCenter] postNotificationName:childrenUpdatedNotificationName object:self];
+ }
+}
+
- (void)showPithosNodeInfo:(id)sender {
// Abstract method
}
if ((self = [super init])) {
self.pithos = aPithos;
self.sharingAccount = @"";
- self.childrenUpdatedNotificationName = [NSString stringWithString:@"PithosSharingAccountsNodeChildrenUpdated"];
}
return self;
}
node.parent = self;
node.shared = shared;
node.sharingAccount = account.name;
+ node.inheritChildrenUpdatedNotificationName = inheritChildrenUpdatedNotificationName;
if (children) {
NSUInteger oldIndex = [children indexOfObject:node];
if (oldIndex != NSNotFound) {
@synchronized(self) {
freshness = PithosNodeStateRefreshFinished;
}
- if (childrenUpdatedNotificationName) {
- // Notify observers that children are updated
- [[NSNotificationCenter defaultCenter] postNotificationName:childrenUpdatedNotificationName object:self];
- }
+ [self postChildrenUpdatedNotificationName];
} else {
[sharingAccountsRequest release];
// Do an additional request to fetch more objects
self.pithos = aPithos;
self.pithosContainer = aPithosContainer;
self.pithosObject = aPithosObject;
- self.childrenUpdatedNotificationName = [NSString stringWithString:@"PithosSubdirNodeChildrenUpdated"];
refreshParent = NO;
}
return self;