Revision 919cb043 pithos-macos/PithosAccountNode.m
b/pithos-macos/PithosAccountNode.m | ||
---|---|---|
2 | 2 |
// PithosAccountNode.m |
3 | 3 |
// pithos-macos |
4 | 4 |
// |
5 |
// Copyright 2011 GRNET S.A. All rights reserved. |
|
5 |
// Copyright 2011-2012 GRNET S.A. All rights reserved.
|
|
6 | 6 |
// |
7 | 7 |
// Redistribution and use in source and binary forms, with or |
8 | 8 |
// without modification, are permitted provided that the following |
... | ... | |
37 | 37 |
|
38 | 38 |
#import "PithosAccountNode.h" |
39 | 39 |
#import "PithosContainerNode.h" |
40 |
#import "ASIPithos.h" |
|
40 | 41 |
#import "ASIPithosAccountRequest.h" |
41 | 42 |
#import "ASIPithosAccount.h" |
42 | 43 |
#import "ASIPithosContainer.h" |
... | ... | |
47 | 48 |
static NSImage *sharedIcon = nil; |
48 | 49 |
|
49 | 50 |
@implementation PithosAccountNode |
50 |
@synthesize pithosAccount; |
|
51 |
@synthesize pithos, pithosAccount;
|
|
51 | 52 |
|
52 | 53 |
+ (void)initialize { |
53 | 54 |
if (self == [PithosAccountNode class]) |
... | ... | |
57 | 58 |
#pragma mark - |
58 | 59 |
#pragma mark Object Lifecycle |
59 | 60 |
|
61 |
- (id)initWithPithos:(ASIPithos *)aPithos { |
|
62 |
if ((self = [super init])) { |
|
63 |
self.pithos = aPithos; |
|
64 |
} |
|
65 |
return self; |
|
66 |
} |
|
67 |
|
|
60 | 68 |
- (void)dealloc { |
61 | 69 |
[accountRequest clearDelegatesAndCancel]; |
62 | 70 |
[accountRequest release]; |
... | ... | |
66 | 74 |
[applyMetadataAccountRequest release]; |
67 | 75 |
[containers release]; |
68 | 76 |
[pithosAccount release]; |
77 |
[pithos release]; |
|
69 | 78 |
[super dealloc]; |
70 | 79 |
} |
71 | 80 |
|
... | ... | |
75 | 84 |
- (NSString *)url { |
76 | 85 |
if (url == nil) |
77 | 86 |
url = [[NSString alloc] initWithFormat:@"%@%@", |
78 |
(sharingAccount ? [ASIPithosRequest storageURLWithAuthUser:sharingAccount] : [ASIPithosRequest storageURL]),
|
|
87 |
(sharingAccount ? [pithos storageURLWithAuthUser:sharingAccount] : pithos.storageURL),
|
|
79 | 88 |
(shared ? @"?shared" : @"")]; |
80 | 89 |
return url; |
81 | 90 |
} |
... | ... | |
87 | 96 |
break; |
88 | 97 |
case PithosNodeStateRefreshNeeded: |
89 | 98 |
freshness = PithosNodeStateRefreshing; |
90 |
accountRequest = [[ASIPithosAccountRequest listContainersRequestWithLimit:0 |
|
91 |
marker:nil |
|
92 |
shared:shared |
|
93 |
until:nil] retain]; |
|
99 |
accountRequest = [[ASIPithosAccountRequest listContainersRequestWithPithos:pithos |
|
100 |
limit:0 |
|
101 |
marker:nil |
|
102 |
shared:shared |
|
103 |
until:nil] retain]; |
|
94 | 104 |
if (sharingAccount) |
95 |
[accountRequest setRequestUserFromDefaultTo:sharingAccount]; |
|
105 |
[accountRequest setRequestUserFromDefaultTo:sharingAccount withPithos:pithos];
|
|
96 | 106 |
accountRequest.delegate = self; |
97 | 107 |
accountRequest.didFinishSelector = @selector(performRequestFinishedDelegateInBackground:); |
98 | 108 |
accountRequest.didFailSelector = @selector(performRequestFailedDelegateInBackground:); |
... | ... | |
191 | 201 |
newChildren = [[NSMutableArray alloc] init]; |
192 | 202 |
NSMutableIndexSet *keptNodes = [NSMutableIndexSet indexSet]; |
193 | 203 |
for (ASIPithosContainer *container in containers) { |
194 |
PithosContainerNode *node = [[[PithosContainerNode alloc] initWithPithosContainer:container] autorelease]; |
|
204 |
PithosContainerNode *node = [[[PithosContainerNode alloc] initWithPithos:pithos pithosContainer:container] autorelease];
|
|
195 | 205 |
node.parent = self; |
196 | 206 |
node.shared = shared; |
197 | 207 |
node.sharingAccount = sharingAccount; |
... | ... | |
227 | 237 |
} else { |
228 | 238 |
[accountRequest release]; |
229 | 239 |
// Do an additional request to fetch more objects |
230 |
accountRequest = [[ASIPithosAccountRequest listContainersRequestWithLimit:0 |
|
231 |
marker:[[someContainers lastObject] name] |
|
232 |
shared:shared |
|
233 |
until:nil] retain]; |
|
240 |
accountRequest = [[ASIPithosAccountRequest listContainersRequestWithPithos:pithos |
|
241 |
limit:0 |
|
242 |
marker:[[someContainers lastObject] name] |
|
243 |
shared:shared |
|
244 |
until:nil] retain]; |
|
234 | 245 |
if (sharingAccount) |
235 |
[accountRequest setRequestUserFromDefaultTo:sharingAccount]; |
|
246 |
[accountRequest setRequestUserFromDefaultTo:sharingAccount withPithos:pithos];
|
|
236 | 247 |
accountRequest.delegate = self; |
237 | 248 |
accountRequest.didFinishSelector = @selector(performRequestFinishedDelegateInBackground:); |
238 | 249 |
accountRequest.didFailSelector = @selector(performRequestFailedDelegateInBackground:); |
... | ... | |
312 | 323 |
NSMutableDictionary *groups = pithosAccount.groups; |
313 | 324 |
if ([groups count] == 0) |
314 | 325 |
groups = [NSMutableDictionary dictionaryWithObject:@"" forKey:@"group"]; |
315 |
applyMetadataAccountRequest = [[ASIPithosAccountRequest updateAccountMetadataRequestWithGroups:groups |
|
326 |
applyMetadataAccountRequest = [[ASIPithosAccountRequest updateAccountMetadataRequestWithPithos:pithos |
|
327 |
groups:groups |
|
316 | 328 |
metadata:pithosAccount.metadata |
317 | 329 |
update:NO] retain]; |
318 | 330 |
applyMetadataAccountRequest.delegate = self; |
... | ... | |
332 | 344 |
- (void)refreshInfo { |
333 | 345 |
@synchronized(self) { |
334 | 346 |
if (refreshMetadataAccountRequest == nil) { |
335 |
refreshMetadataAccountRequest = [[ASIPithosAccountRequest accountMetadataRequest] retain]; |
|
347 |
refreshMetadataAccountRequest = [[ASIPithosAccountRequest accountMetadataRequestWithPithos:pithos] retain];
|
|
336 | 348 |
refreshMetadataAccountRequest.delegate = self; |
337 | 349 |
refreshMetadataAccountRequest.didFinishSelector = @selector(performRequestFinishedDelegateInBackground:); |
338 | 350 |
refreshMetadataAccountRequest.didFailSelector = @selector(performRequestFailedDelegateInBackground:); |
Also available in: Unified diff