Revision d4433f6f

b/pithos-macos/PithosAccount.m
370 370
    if (!accountNode) {
371 371
        accountNode = [[PithosAccountNode alloc] initWithPithos:self.pithos];
372 372
        accountNode.childrenUpdatedNotificationName = nil;
373
        accountNode.inheritChildrenUpdatedNotificationName = YES;
373 374
    }
374 375
    return accountNode;
375 376
}
b/pithos-macos/PithosAccountNode.m
61 61
- (id)initWithPithos:(ASIPithos *)aPithos {
62 62
    if ((self = [super init])) {
63 63
        self.pithos = aPithos;
64
        self.childrenUpdatedNotificationName = [NSString stringWithString:@"PithosAccountNodeChildrenUpdated"];
65 64
    }
66 65
    return self;
67 66
}
......
215 214
                    node.parent = self;
216 215
                    node.shared = shared;
217 216
                    node.sharingAccount = sharingAccount;
217
                    node.inheritChildrenUpdatedNotificationName = inheritChildrenUpdatedNotificationName;
218 218
                    if (children) {
219 219
                        NSUInteger oldIndex = [children indexOfObject:node];
220 220
                        if (oldIndex != NSNotFound) {
......
243 243
            @synchronized(self) {
244 244
                freshness = PithosNodeStateRefreshFinished;
245 245
            }
246
            if (childrenUpdatedNotificationName) {
247
                // Notify observers that children are updated
248
                [[NSNotificationCenter defaultCenter] postNotificationName:childrenUpdatedNotificationName object:self];
249
            }
246
            [self postChildrenUpdatedNotificationName];
250 247
        } else {
251 248
            [accountRequest release];
252 249
            // Do an additional request to fetch more objects
......
280 277
        @synchronized(self) {
281 278
            freshness = PithosNodeStateRefreshFinished;
282 279
        }
283
        if (childrenUpdatedNotificationName) {
284
            // Notify observers that children are updated
285
            [[NSNotificationCenter defaultCenter] postNotificationName:childrenUpdatedNotificationName object:self];
286
        }
280
        [self postChildrenUpdatedNotificationName];
287 281
    } else {
288 282
        [self accountRequestFailed:accountRequest];
289 283
    }
b/pithos-macos/PithosBrowserController.m
223 223
    [[[outlineView tableColumns] objectAtIndex:0] setDataCell:[[[PithosOutlineViewCell alloc] init] autorelease]];
224 224
    
225 225
    // Register for updates
226
    // PithosContainerNode updates browser nodes
227
    [[NSNotificationCenter defaultCenter] addObserver:self 
228
                                             selector:@selector(pithosNodeChildrenUpdated:) 
229
                                                 name:@"PithosContainerNodeChildrenUpdated" 
230
                                               object:nil];
231
    // PithosSubdirNode updates browser nodes
232
    [[NSNotificationCenter defaultCenter] addObserver:self 
233
                                             selector:@selector(pithosNodeChildrenUpdated:) 
234
                                                 name:@"PithosSubdirNodeChildrenUpdated" 
235
                                               object:nil];
236 226
    // PithosAccountNode accountNode updates outlineView container nodes 
237 227
    [[NSNotificationCenter defaultCenter] addObserver:self 
238 228
                                             selector:@selector(pithosAccountNodeChildrenUpdated:) 
239
                                                 name:@"PithosAccountNodeChildrenUpdated" 
229
                                                 name:@"PithosNodeChildrenUpdated" 
240 230
                                               object:accountNode];
241
    // PithosAccountNode other than accountNode updates nodes 
231
    // PithosNode updates browser nodes
242 232
    [[NSNotificationCenter defaultCenter] addObserver:self 
243 233
                                             selector:@selector(pithosNodeChildrenUpdated:) 
244
                                                 name:@"PithosAccountNodeChildrenUpdated" 
234
                                                 name:@"PithosNodeChildrenUpdated" 
245 235
                                               object:nil];
246
    // PithosSharingAccountsNode othersSharedNode updates browser nodes 
247
    [[NSNotificationCenter defaultCenter] addObserver:self 
248
                                             selector:@selector(pithosNodeChildrenUpdated:) 
249
                                                 name:@"PithosSharingAccountsNodeChildrenUpdated" 
250
                                               object:othersSharedNode];
251 236
    // Request for browser refresh 
252 237
    [[NSNotificationCenter defaultCenter] addObserver:self 
253 238
                                             selector:@selector(pithosBrowserRefreshNeeded:) 
......
437 422

  
438 423
- (void)pithosNodeChildrenUpdated:(NSNotification *)notification {
439 424
    PithosNode *node = (PithosNode *)[notification object];
440
    if (node == accountNode)
425
    if ((node == accountNode) || ![node.pithos isEqualTo:pithos])
441 426
        return;
442 427
    NSLog(@"pithosNodeChildrenUpdated:%@", node.url);
443 428
    NSInteger lastColumn = [browser lastColumn];
b/pithos-macos/PithosContainerNode.m
67 67
        self.pithosContainer = aPithosContainer;
68 68
        prefix = nil;
69 69
        self.icon = anIcon;
70
        self.childrenUpdatedNotificationName = [NSString stringWithString:@"PithosContainerNodeChildrenUpdated"];
71 70
    }
72 71
    return self;
73 72
}
......
294 293
                                node.parent = self;
295 294
                                node.shared = shared;
296 295
                                node.sharingAccount = sharingAccount;
296
                                node.inheritChildrenUpdatedNotificationName = inheritChildrenUpdatedNotificationName;
297 297
                                if (children) {
298 298
                                    NSUInteger oldIndex = [children indexOfObject:node];
299 299
                                    if (oldIndex != NSNotFound) {
......
316 316
                            node.parent = self;
317 317
                            node.shared = shared;
318 318
                            node.sharingAccount = sharingAccount;
319
                            node.inheritChildrenUpdatedNotificationName = inheritChildrenUpdatedNotificationName;
319 320
                            if (children) {
320 321
                                NSUInteger oldIndex = [children indexOfObject:node];
321 322
                                if (oldIndex != NSNotFound) {
......
335 336
                            node.parent = self;
336 337
                            node.shared = shared;
337 338
                            node.sharingAccount = sharingAccount;
339
                            node.inheritChildrenUpdatedNotificationName = inheritChildrenUpdatedNotificationName;
338 340
                            if (children) {
339 341
                                NSUInteger oldIndex = [children indexOfObject:node];
340 342
                                if (oldIndex != NSNotFound) {
......
366 368
            @synchronized(self) {
367 369
                freshness = PithosNodeStateRefreshFinished;
368 370
            }
369
            if (childrenUpdatedNotificationName) {
370
                // Notify observers that children are updated
371
                [[NSNotificationCenter defaultCenter] postNotificationName:childrenUpdatedNotificationName object:self];
372
            }
371
            [self postChildrenUpdatedNotificationName];
373 372
        } else {
374 373
            [containerRequest release];
375 374
            // Do an additional request to fetch more objects
......
408 407
        @synchronized(self) {
409 408
            freshness = PithosNodeStateRefreshFinished;
410 409
        }
411
        if (childrenUpdatedNotificationName) {
412
            // Notify observers that children are updated
413
            [[NSNotificationCenter defaultCenter] postNotificationName:childrenUpdatedNotificationName object:self];
414
        }
410
        [self postChildrenUpdatedNotificationName];
415 411
    } else {
416 412
        [self containerRequestFailed:containerRequest];
417 413
    }
b/pithos-macos/PithosNode.h
59 59
    NSMutableArray *children;
60 60
    NSMutableArray *newChildren;
61 61
    NSString *childrenUpdatedNotificationName;
62
    BOOL inheritChildrenUpdatedNotificationName;
62 63
    
63 64
    NSString *displayName;
64 65
    BOOL isLeafItem;
......
77 78
@property(nonatomic, retain) NSString *sharingAccount;
78 79
@property(nonatomic, readonly) NSArray *children;
79 80
@property(nonatomic, retain) NSString *childrenUpdatedNotificationName;
81
@property(nonatomic, assign) BOOL inheritChildrenUpdatedNotificationName;
80 82

  
81 83
@property(nonatomic, retain) NSString *displayName;
82 84
@property(nonatomic, readonly) BOOL isLeafItem;
......
93 95
- (void)refresh;
94 96
- (void)forceRefresh;
95 97

  
98
- (void) postChildrenUpdatedNotificationName;
99

  
96 100
- (void)showPithosNodeInfo:(id)sender;
97 101
- (void)pithosNodeInfoWillClose:(id)sender;
98 102

  
b/pithos-macos/PithosNode.m
41 41
#import "ASIPithosRequest.h"
42 42

  
43 43
@implementation PithosNode
44
@synthesize forcedRefresh, parent, shared, sharingAccount, childrenUpdatedNotificationName, displayName, isLeafItem, icon;
44
@synthesize forcedRefresh, parent, shared, sharingAccount, childrenUpdatedNotificationName, 
45
            inheritChildrenUpdatedNotificationName, displayName, isLeafItem, icon;
45 46
@dynamic url, children, pithos, pithosAccount, pithosContainer, pithosObject;
46 47

  
47 48
#pragma mark -
......
53 54
        forcedRefresh = NO;
54 55
        shared = NO;
55 56
        isLeafItem = NO;
57
        self.childrenUpdatedNotificationName = @"PithosNodeChildrenUpdated";
58
        inheritChildrenUpdatedNotificationName = NO;
56 59
    }
57 60
    return self;
58 61
}
......
124 127
    [self refresh];
125 128
}
126 129

  
130
- (void)postChildrenUpdatedNotificationName {
131
    // Notify observers that children are updated
132
    if (inheritChildrenUpdatedNotificationName) {
133
        PithosNode *ancestor = self;
134
        while (ancestor && ancestor.parent) {
135
            ancestor = ancestor.parent;
136
        }
137
        if (ancestor && ancestor.childrenUpdatedNotificationName) {
138
            [[NSNotificationCenter defaultCenter] postNotificationName:ancestor.childrenUpdatedNotificationName object:self];
139
        }
140
    } else if (childrenUpdatedNotificationName) {
141
        [[NSNotificationCenter defaultCenter] postNotificationName:childrenUpdatedNotificationName object:self];
142
    }
143
}
144

  
127 145
- (void)showPithosNodeInfo:(id)sender {
128 146
    // Abstract method
129 147
}
b/pithos-macos/PithosSharingAccountsNode.m
54 54
    if ((self = [super init])) {
55 55
        self.pithos = aPithos;
56 56
        self.sharingAccount = @"";
57
        self.childrenUpdatedNotificationName = [NSString stringWithString:@"PithosSharingAccountsNodeChildrenUpdated"];
58 57
    }
59 58
    return self;
60 59
}
......
188 187
                        node.parent = self;
189 188
                        node.shared = shared;
190 189
                        node.sharingAccount = account.name;
190
                        node.inheritChildrenUpdatedNotificationName = inheritChildrenUpdatedNotificationName;
191 191
                        if (children) {
192 192
                            NSUInteger oldIndex = [children indexOfObject:node];
193 193
                            if (oldIndex != NSNotFound) {
......
215 215
            @synchronized(self) {
216 216
                freshness = PithosNodeStateRefreshFinished;
217 217
            }
218
            if (childrenUpdatedNotificationName) {
219
                // Notify observers that children are updated
220
                [[NSNotificationCenter defaultCenter] postNotificationName:childrenUpdatedNotificationName object:self];
221
            }
218
            [self postChildrenUpdatedNotificationName];
222 219
        } else {
223 220
            [sharingAccountsRequest release];
224 221
            // Do an additional request to fetch more objects
b/pithos-macos/PithosSubdirNode.m
67 67
        self.pithos = aPithos;
68 68
        self.pithosContainer = aPithosContainer;
69 69
        self.pithosObject = aPithosObject;
70
        self.childrenUpdatedNotificationName = [NSString stringWithString:@"PithosSubdirNodeChildrenUpdated"];
71 70
        refreshParent = NO;
72 71
    }
73 72
    return self;

Also available in: Unified diff