Revision fb27f368
b/pithos-macos/PithosAccount.h | ||
---|---|---|
2 | 2 |
// PithosAccount.h |
3 | 3 |
// pithos-macos |
4 | 4 |
// |
5 |
// Copyright 2012 GRNET S.A. All rights reserved. |
|
5 |
// Copyright 2012-2013 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 |
b/pithos-macos/PithosAccount.m | ||
---|---|---|
2 | 2 |
// PithosAccount.m |
3 | 3 |
// pithos-macos |
4 | 4 |
// |
5 |
// Copyright 2012 GRNET S.A. All rights reserved. |
|
5 |
// Copyright 2012-2013 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 |
... | ... | |
59 | 59 |
} |
60 | 60 |
|
61 | 61 |
- (NSString *)stringByRemovingTrailingSlashes { |
62 |
NSString *stringWithRemovedTrailingSlashes = [self copy]; |
|
63 |
while ([stringWithRemovedTrailingSlashes hasSuffix:@"/"]) { |
|
64 |
stringWithRemovedTrailingSlashes = [stringWithRemovedTrailingSlashes substringToIndex:(stringWithRemovedTrailingSlashes.length - 1)]; |
|
65 |
} |
|
66 |
return stringWithRemovedTrailingSlashes; |
|
62 |
return [self stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"/"]]; |
|
67 | 63 |
} |
68 | 64 |
@end |
69 | 65 |
|
... | ... | |
312 | 308 |
|
313 | 309 |
- (PithosAccountNode *)accountNode { |
314 | 310 |
if (!accountNode) { |
315 |
accountNode = [[PithosAccountNode alloc] initWithPithosAccountManager:self andPithos:self.pithos];
|
|
311 |
accountNode = [[PithosAccountNode alloc] initWithPithosAccountManager:self]; |
|
316 | 312 |
accountNode.childrenUpdatedNotificationName = nil; |
317 | 313 |
accountNode.inheritChildrenUpdatedNotificationName = YES; |
318 | 314 |
} |
... | ... | |
321 | 317 |
|
322 | 318 |
- (PithosSharingAccountsNode *)sharingAccountsNode { |
323 | 319 |
if (!sharingAccountsNode) { |
324 |
sharingAccountsNode = [[PithosSharingAccountsNode alloc] initWithPithosAccountManager:self andPithos:self.pithos];
|
|
320 |
sharingAccountsNode = [[PithosSharingAccountsNode alloc] initWithPithosAccountManager:self]; |
|
325 | 321 |
sharingAccountsNode.childrenUpdatedNotificationName = nil; |
326 | 322 |
sharingAccountsNode.inheritChildrenUpdatedNotificationName = YES; |
327 | 323 |
} |
... | ... | |
358 | 354 |
manual:(BOOL)aManual |
359 | 355 |
authToken:(NSString *)anAuthToken |
360 | 356 |
authUser:(NSString *)anAuthUser |
361 |
ignoreSSLErrors:(BOOL)anIgnoreSSLErrors { |
|
357 |
ignoreSSLErrors:(BOOL)anIgnoreSSLErrors |
|
358 |
resetNodes:(BOOL)resetNodes { |
|
359 |
BOOL pithosUpdated = (![authURLString isEqualToString:[anAuthURLString stringByRemovingTrailingSlashes]] || |
|
360 |
![pithosObjectStoreURLString isEqualToString:[aPithosObjectStoreURLString stringByRemovingTrailingSlashes]] || |
|
361 |
![astakosAccountURLString isEqualToString:[anAstakosAccountURLString stringByRemovingTrailingSlashes]] || |
|
362 |
![authToken isEqualToString:anAuthToken] || ![authUser isEqualToString:anAuthUser] || |
|
363 |
(ignoreSSLErrors != anIgnoreSSLErrors)); |
|
362 | 364 |
self.authURLString = anAuthURLString; |
363 | 365 |
self.pithosObjectStoreURLString = aPithosObjectStoreURLString; |
364 | 366 |
self.astakosAccountURLString = anAstakosAccountURLString; |
... | ... | |
375 | 377 |
[self updateUserCatalogForDisplaynames:nil UUIDs:[NSArray arrayWithObject:authUser]]; |
376 | 378 |
|
377 | 379 |
self.active = YES; |
378 |
if (syncDaemon) { |
|
379 |
self.syncDaemon.pithos = self.pithos; |
|
380 |
if (self.syncActive) |
|
381 |
[self.syncDaemon startDaemon]; |
|
382 |
} |
|
383 |
if (accountNode) |
|
384 |
self.accountNode.pithos = self.pithos; |
|
385 |
if (sharingAccountsNode) |
|
386 |
self.sharingAccountsNode.pithos = self.pithos; |
|
387 |
if (accountNode) { |
|
388 |
if (self.accountNode.children) { |
|
380 |
if (pithosUpdated) { |
|
381 |
if (syncDaemon) { |
|
382 |
// For the sync daemon we keep using a separate pithos object. |
|
383 |
self.syncDaemon.pithos = self.pithos; |
|
384 |
if (self.syncActive) |
|
385 |
[self.syncDaemon startDaemon]; |
|
386 |
} |
|
387 |
if (resetNodes) { |
|
388 |
[accountNode reset]; |
|
389 |
[accountNode refreshInfo]; |
|
390 |
[sharingAccountsNode reset]; |
|
391 |
|
|
392 |
[[NSNotificationCenter defaultCenter] postNotificationName:@"PithosAccountPithosChanged" object:self]; |
|
389 | 393 |
} |
390 |
[self.accountNode refreshInfo]; |
|
391 |
} |
|
392 |
if (sharingAccountsNode && self.sharingAccountsNode.children) { |
|
393 | 394 |
} |
394 | 395 |
} |
395 | 396 |
} |
396 | 397 |
|
397 |
- (void)updateSyncWithSyncActive:(BOOL)aSyncActive |
|
398 |
- (void)updateWithAuthURLString:(NSString *)anAuthURLString |
|
399 |
pithosObjectStoreURLString:(NSString *)aPithosObjectStoreURLString |
|
400 |
astakosAccountURLString:(NSString *)anAstakosAccountURLString |
|
401 |
astakosWebloginURLString:(NSString *)anAstakosWebloginURLString |
|
402 |
manual:(BOOL)aManual |
|
403 |
authToken:(NSString *)anAuthToken |
|
404 |
authUser:(NSString *)anAuthUser |
|
405 |
ignoreSSLErrors:(BOOL)anIgnoreSSLErrors { |
|
406 |
[self updateWithAuthURLString:anAuthURLString |
|
407 |
pithosObjectStoreURLString:aPithosObjectStoreURLString |
|
408 |
astakosAccountURLString:anAstakosAccountURLString |
|
409 |
astakosWebloginURLString:anAstakosWebloginURLString |
|
410 |
manual:aManual |
|
411 |
authToken:anAuthToken |
|
412 |
authUser:anAuthUser |
|
413 |
ignoreSSLErrors:anIgnoreSSLErrors |
|
414 |
resetNodes:YES]; |
|
415 |
} |
|
416 |
|
|
417 |
- (void)updateSyncWithSyncActive:(BOOL)aSyncActive |
|
398 | 418 |
syncDirectoryPath:(NSString *)aSyncDirectoryPath |
399 | 419 |
syncAccountsDictionary:(NSMutableDictionary *)aSyncAccountsDictionary |
400 | 420 |
syncSkipHidden:(BOOL)aSyncSkipHidden { |
... | ... | |
443 | 463 |
- (void)updateServicesFromServiceCatalogRequest:(ASIPithosRequest *)serviceCatalogRequest { |
444 | 464 |
if (serviceCatalogRequest.responseStatusCode == 200) { |
445 | 465 |
NSMutableDictionary *services = [self servicesFromServiceCatalogRequest:serviceCatalogRequest]; |
446 |
self.pithosObjectStoreURLString = [services objectForKey:@"PithosObjectStoreURLString"]; |
|
447 |
self.astakosAccountURLString = [services objectForKey:@"AstakosAccountURLString"]; |
|
448 |
self.astakosWebloginURLString = [services objectForKey:@"AstakosWebloginURLString"]; |
|
449 |
self.manual = NO; |
|
450 |
|
|
466 |
NSString *newAuthToken = nil; |
|
467 |
NSString *newAuthUser = nil; |
|
451 | 468 |
if (authToken.length) { |
452 | 469 |
NSDictionary *token = [serviceCatalogRequest token]; |
453 |
self.authToken = [token objectForKey:@"id"];
|
|
454 |
self.authUser = [[token objectForKey:@"tenant"] objectForKey:@"id"];
|
|
470 |
newAuthToken = [token objectForKey:@"id"];
|
|
471 |
newAuthUser = [[token objectForKey:@"tenant"] objectForKey:@"id"];
|
|
455 | 472 |
} |
473 |
[self updateWithAuthURLString:authURLString |
|
474 |
pithosObjectStoreURLString:[services objectForKey:@"PithosObjectStoreURLString"] |
|
475 |
astakosAccountURLString:[services objectForKey:@"AstakosAccountURLString"] |
|
476 |
astakosWebloginURLString:[services objectForKey:@"AstakosWebloginURLString"] |
|
477 |
manual:NO |
|
478 |
authToken:(newAuthToken ? newAuthToken : authToken) |
|
479 |
authUser:(newAuthUser ? newAuthUser : authUser) |
|
480 |
ignoreSSLErrors:ignoreSSLErrors |
|
481 |
resetNodes:NO]; |
|
456 | 482 |
} else if (serviceCatalogRequest.responseStatusCode == 404) { |
457 |
self.pithosObjectStoreURLString = [[[NSURL URLWithString:authURLString] URLByAppendingPathComponent:@"v1"] description]; |
|
458 |
self.astakosAccountURLString = [self.authURLString copy]; |
|
459 |
self.astakosWebloginURLString = [self.authURLString copy]; |
|
460 |
self.manual = YES; |
|
483 |
[self updateWithAuthURLString:authURLString |
|
484 |
pithosObjectStoreURLString:[[[NSURL URLWithString:authURLString] URLByAppendingPathComponent:@"v1"] description] |
|
485 |
astakosAccountURLString:[authURLString copy] |
|
486 |
astakosWebloginURLString:[authURLString copy] |
|
487 |
manual:YES |
|
488 |
authToken:authToken |
|
489 |
authUser:authUser |
|
490 |
ignoreSSLErrors:ignoreSSLErrors |
|
491 |
resetNodes:NO]; |
|
461 | 492 |
} |
462 | 493 |
} |
463 | 494 |
|
... | ... | |
525 | 556 |
self.astakosWebloginURLString = [decoder decodeObjectForKey:@"astakosWebloginURLString"]; |
526 | 557 |
self.manual = [decoder decodeBoolForKey:@"manual"]; |
527 | 558 |
|
559 |
self.ignoreSSLErrors = [decoder decodeBoolForKey:@"ignoreSSLErrors"]; |
|
560 |
|
|
528 | 561 |
// Support for older versions. |
529 | 562 |
if (!authURLString && !pithosObjectStoreURLString && !astakosAccountURLString && !astakosWebloginURLString) { |
530 | 563 |
NSString *tmpURLString = [decoder decodeObjectForKey:@"serverURL"]; |
... | ... | |
579 | 612 |
[encoder encodeObject:authToken forKey:@"authToken"]; |
580 | 613 |
[encoder encodeObject:authUser forKey:@"authUser"]; |
581 | 614 |
[encoder encodeObject:userCatalog forKey:@"userCatalog"]; |
615 |
|
|
616 |
[encoder encodeBool:ignoreSSLErrors forKey:@"ignoreSSLErrors"]; |
|
582 | 617 |
} |
583 | 618 |
|
584 | 619 |
@end |
b/pithos-macos/PithosAccountNode.h | ||
---|---|---|
2 | 2 |
// PithosAccountNode.h |
3 | 3 |
// pithos-macos |
4 | 4 |
// |
5 |
// Copyright 2011-2012 GRNET S.A. All rights reserved.
|
|
5 |
// Copyright 2011-2013 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 |
... | ... | |
36 | 36 |
// or implied, of GRNET S.A. |
37 | 37 |
|
38 | 38 |
#import "PithosNode.h" |
39 |
@class ASIPithos; |
|
40 | 39 |
@class ASIPithosAccountRequest; |
41 | 40 |
@class ASIPithosAccount; |
42 | 41 |
|
43 | 42 |
@interface PithosAccountNode : PithosNode { |
44 |
ASIPithos *pithos; |
|
45 | 43 |
ASIPithosAccount *pithosAccount; |
46 | 44 |
|
47 | 45 |
ASIPithosAccountRequest *accountRequest; |
48 | 46 |
|
49 | 47 |
ASIPithosAccountRequest *applyMetadataAccountRequest; |
50 | 48 |
ASIPithosAccountRequest *refreshMetadataAccountRequest; |
51 |
|
|
52 |
BOOL reset; |
|
53 |
|
|
49 |
|
|
54 | 50 |
NSMutableDictionary *translatedGroups; |
55 | 51 |
} |
56 | 52 |
|
57 |
@property(nonatomic, strong) ASIPithos *pithos; |
|
58 | 53 |
@property(nonatomic, strong) ASIPithosAccount *pithosAccount; |
59 | 54 |
@property(nonatomic, strong) ASIPithosAccountRequest *accountRequest; |
60 | 55 |
@property(nonatomic, strong) ASIPithosAccountRequest *applyMetadataAccountRequest; |
61 | 56 |
@property(nonatomic, strong) ASIPithosAccountRequest *refreshMetadataAccountRequest; |
62 | 57 |
@property(nonatomic, strong) NSMutableDictionary *translatedGroups; |
63 | 58 |
|
64 |
- (id)initWithPithosAccountManager:(PithosAccount *)aPithosAccountManager andPithos:(ASIPithos *)aPithos; |
|
65 |
|
|
66 | 59 |
- (void)applyInfo; |
67 | 60 |
- (void)refreshInfo; |
61 |
- (void)reset; |
|
68 | 62 |
|
69 | 63 |
@end |
b/pithos-macos/PithosAccountNode.m | ||
---|---|---|
2 | 2 |
// PithosAccountNode.m |
3 | 3 |
// pithos-macos |
4 | 4 |
// |
5 |
// Copyright 2011-2012 GRNET S.A. All rights reserved.
|
|
5 |
// Copyright 2011-2013 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 |
... | ... | |
49 | 49 |
static NSImage *sharedIcon = nil; |
50 | 50 |
|
51 | 51 |
@implementation PithosAccountNode |
52 |
@synthesize pithos, pithosAccount, accountRequest, applyMetadataAccountRequest, refreshMetadataAccountRequest, translatedGroups;
|
|
52 |
@synthesize pithosAccount, accountRequest, applyMetadataAccountRequest, refreshMetadataAccountRequest, translatedGroups; |
|
53 | 53 |
|
54 | 54 |
+ (void)initialize { |
55 | 55 |
if (self == [PithosAccountNode class]) |
... | ... | |
59 | 59 |
#pragma mark - |
60 | 60 |
#pragma mark Object Lifecycle |
61 | 61 |
|
62 |
- (id)initWithPithosAccountManager:(PithosAccount *)aPithosAccountManager andPithos:(ASIPithos *)aPithos { |
|
63 |
if ((self = [super initWithPithosAccountManager:aPithosAccountManager])) { |
|
64 |
pithos = aPithos; |
|
65 |
} |
|
66 |
return self; |
|
67 |
} |
|
68 |
|
|
69 | 62 |
- (void)dealloc { |
70 | 63 |
[accountRequest clearDelegatesAndCancel]; |
71 | 64 |
[refreshMetadataAccountRequest clearDelegatesAndCancel]; |
... | ... | |
104 | 97 |
} |
105 | 98 |
|
106 | 99 |
#pragma mark - |
107 |
#pragma mark Properties
|
|
100 |
#pragma mark Actions
|
|
108 | 101 |
|
109 |
- (void)setPithos:(ASIPithos *)aPithos { |
|
110 |
if (aPithos && ![aPithos isEqualTo:pithos]) { |
|
111 |
pithos = aPithos; |
|
112 |
url = nil; |
|
113 |
[accountRequest clearDelegatesAndCancel]; |
|
114 |
self.accountRequest = nil; |
|
115 |
[refreshMetadataAccountRequest clearDelegatesAndCancel]; |
|
116 |
self.refreshMetadataAccountRequest = nil; |
|
117 |
[applyMetadataAccountRequest clearDelegatesAndCancel]; |
|
118 |
self.applyMetadataAccountRequest = nil; |
|
119 |
reset = YES; |
|
120 |
} |
|
102 |
- (void)reset { |
|
103 |
[accountRequest clearDelegatesAndCancel]; |
|
104 |
self.accountRequest = nil; |
|
105 |
[refreshMetadataAccountRequest clearDelegatesAndCancel]; |
|
106 |
self.refreshMetadataAccountRequest = nil; |
|
107 |
[applyMetadataAccountRequest clearDelegatesAndCancel]; |
|
108 |
self.applyMetadataAccountRequest = nil; |
|
109 |
children = nil; |
|
110 |
newChildren = nil; |
|
111 |
self.pithosAccount = nil; |
|
112 |
freshness = PithosNodeStateRefreshNeeded; |
|
113 |
forcedRefresh = YES; |
|
114 |
[self postChildrenUpdatedNotificationName]; |
|
115 |
[self children]; |
|
121 | 116 |
} |
122 | 117 |
|
118 |
#pragma mark - |
|
119 |
#pragma mark Properties |
|
120 |
|
|
123 | 121 |
- (void)setPithosAccount:(ASIPithosAccount *)aPithosAccount { |
124 | 122 |
if (![pithosAccount isEqualTo:aPithosAccount]) { |
125 | 123 |
pithosAccount = aPithosAccount; |
... | ... | |
128 | 126 |
} |
129 | 127 |
|
130 | 128 |
- (NSString *)url { |
131 |
if (url == nil) |
|
132 |
url = [[NSString alloc] initWithFormat:@"%@%@", |
|
133 |
(sharingAccount ? [pithos storageURLWithAuthUser:sharingAccount] : pithos.storageURL), |
|
134 |
(shared ? @"?shared" : @"")]; |
|
135 |
return url; |
|
129 |
return [NSString stringWithFormat:@"@account@%@%@", |
|
130 |
(sharingAccount ? sharingAccount : pithosAccountManager.pithos.authUser), |
|
131 |
(shared ? @"?shared" : @"")]; |
|
136 | 132 |
} |
137 | 133 |
|
138 | 134 |
- (NSArray *)children { |
139 | 135 |
@synchronized(self) { |
140 |
if (reset) { |
|
141 |
[accountRequest clearDelegatesAndCancel]; |
|
142 |
self.accountRequest = nil; |
|
143 |
[refreshMetadataAccountRequest clearDelegatesAndCancel]; |
|
144 |
self.refreshMetadataAccountRequest = nil; |
|
145 |
[applyMetadataAccountRequest clearDelegatesAndCancel]; |
|
146 |
self.applyMetadataAccountRequest = nil; |
|
147 |
children = nil; |
|
148 |
newChildren = nil; |
|
149 |
self.pithosAccount = nil; |
|
150 |
freshness = PithosNodeStateRefreshNeeded; |
|
151 |
forcedRefresh = YES; |
|
152 |
reset = NO; |
|
153 |
[self postChildrenUpdatedNotificationName]; |
|
154 |
} |
|
155 | 136 |
switch (freshness) { |
156 | 137 |
case PithosNodeStateFresh: |
157 | 138 |
break; |
158 | 139 |
case PithosNodeStateRefreshNeeded: |
159 | 140 |
freshness = PithosNodeStateRefreshing; |
160 |
self.accountRequest = [ASIPithosAccountRequest listContainersRequestWithPithos:pithos |
|
141 |
self.accountRequest = [ASIPithosAccountRequest listContainersRequestWithPithos:pithosAccountManager.pithos
|
|
161 | 142 |
limit:0 |
162 | 143 |
marker:nil |
163 | 144 |
shared:shared |
164 | 145 |
until:nil]; |
165 | 146 |
if (sharingAccount) |
166 |
[accountRequest setRequestUserFromDefaultTo:sharingAccount withPithos:pithos]; |
|
147 |
[accountRequest setRequestUserFromDefaultTo:sharingAccount withPithos:pithosAccountManager.pithos];
|
|
167 | 148 |
else if (!forcedRefresh) |
168 | 149 |
accountRequest.downloadCache = [ASIDownloadCache sharedCache]; |
169 | 150 |
accountRequest.delegate = self; |
... | ... | |
265 | 246 |
NSMutableIndexSet *keptNodes = [NSMutableIndexSet indexSet]; |
266 | 247 |
for (ASIPithosContainer *container in containers) { |
267 | 248 |
PithosContainerNode *node = [[PithosContainerNode alloc] initWithPithosAccountManager:pithosAccountManager |
268 |
andPithos:pithos |
|
269 | 249 |
pithosContainer:container]; |
270 | 250 |
node.parent = self; |
271 | 251 |
node.shared = shared; |
... | ... | |
299 | 279 |
[self postChildrenUpdatedNotificationName]; |
300 | 280 |
} else { |
301 | 281 |
// Do an additional request to fetch more objects |
302 |
self.accountRequest = [ASIPithosAccountRequest listContainersRequestWithPithos:pithos |
|
282 |
self.accountRequest = [ASIPithosAccountRequest listContainersRequestWithPithos:pithosAccountManager.pithos
|
|
303 | 283 |
limit:0 |
304 | 284 |
marker:[[someContainers lastObject] name] |
305 | 285 |
shared:shared |
306 | 286 |
until:nil]; |
307 | 287 |
if (sharingAccount) |
308 |
[accountRequest setRequestUserFromDefaultTo:sharingAccount withPithos:pithos]; |
|
288 |
[accountRequest setRequestUserFromDefaultTo:sharingAccount withPithos:pithosAccountManager.pithos];
|
|
309 | 289 |
else if (!forcedRefresh) |
310 | 290 |
accountRequest.downloadCache = [ASIDownloadCache sharedCache]; |
311 | 291 |
accountRequest.delegate = self; |
... | ... | |
485 | 465 |
[groups setObject:[NSArray arrayWithObject:@""] forKey:@"group"]; |
486 | 466 |
} |
487 | 467 |
|
488 |
self.applyMetadataAccountRequest = [ASIPithosAccountRequest updateAccountMetadataRequestWithPithos:pithos |
|
468 |
self.applyMetadataAccountRequest = [ASIPithosAccountRequest updateAccountMetadataRequestWithPithos:pithosAccountManager.pithos
|
|
489 | 469 |
groups:groups |
490 | 470 |
metadata:pithosAccount.metadata |
491 | 471 |
update:NO]; |
... | ... | |
506 | 486 |
- (void)refreshInfo { |
507 | 487 |
@synchronized(self) { |
508 | 488 |
if (refreshMetadataAccountRequest == nil) { |
509 |
self.refreshMetadataAccountRequest = [ASIPithosAccountRequest accountMetadataRequestWithPithos:pithos]; |
|
489 |
self.refreshMetadataAccountRequest = [ASIPithosAccountRequest accountMetadataRequestWithPithos:pithosAccountManager.pithos];
|
|
510 | 490 |
refreshMetadataAccountRequest.delegate = self; |
511 | 491 |
refreshMetadataAccountRequest.didFinishSelector = @selector(performRequestFinishedDelegateInBackground:); |
512 | 492 |
refreshMetadataAccountRequest.didFailSelector = @selector(performRequestFailedDelegateInBackground:); |
b/pithos-macos/PithosBrowserController.h | ||
---|---|---|
2 | 2 |
// PithosBrowserController.h |
3 | 3 |
// pithos-macos |
4 | 4 |
// |
5 |
// Copyright 2011-2012 GRNET S.A. All rights reserved.
|
|
5 |
// Copyright 2011-2013 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 <Cocoa/Cocoa.h> |
39 | 39 |
#import "PithosActivityFacility.h" |
40 |
@class ASIPithos; |
|
41 | 40 |
@class PithosAccount; |
42 | 41 |
@class PithosNode; |
43 | 42 |
@class PithosAccountNode; |
... | ... | |
50 | 49 |
BOOL browserInitialized; |
51 | 50 |
BOOL browserActive; |
52 | 51 |
|
53 |
ASIPithos *pithos; |
|
54 |
|
|
55 |
PithosAccount *__unsafe_unretained pithosAccountManager; |
|
52 |
PithosAccount *pithosAccountManager; |
|
56 | 53 |
PithosNode *rootNode; |
57 | 54 |
PithosAccountNode *accountNode; |
58 | 55 |
PithosEmptyNode *containersNode; |
... | ... | |
106 | 103 |
NSOperationQueue *downloadCallbackQueue; |
107 | 104 |
} |
108 | 105 |
|
109 |
@property (nonatomic, strong) ASIPithos *pithos; |
|
110 |
|
|
111 |
@property (nonatomic, unsafe_unretained) PithosAccount *pithosAccountManager; |
|
106 |
@property (nonatomic, strong) PithosAccount *pithosAccountManager; |
|
112 | 107 |
@property (nonatomic, strong) PithosAccountNode *accountNode; |
113 | 108 |
|
114 | 109 |
@property (nonatomic, strong) NSArray *draggedNodes; |
b/pithos-macos/PithosBrowserController.m | ||
---|---|---|
2 | 2 |
// PithosBrowserController.m |
3 | 3 |
// pithos-macos |
4 | 4 |
// |
5 |
// Copyright 2011-2012 GRNET S.A. All rights reserved.
|
|
5 |
// Copyright 2011-2013 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 |
... | ... | |
54 | 54 |
#import "ASIPithosContainer.h" |
55 | 55 |
#import "ASIPithosObject.h" |
56 | 56 |
#import "PithosUtilities.h" |
57 |
#import "PithosAccount.h" |
|
57 | 58 |
#import "UsingSizeTransformer.h" |
58 | 59 |
|
59 | 60 |
#define REFRESH_TIMER_INTERVAL 5 |
... | ... | |
108 | 109 |
@end |
109 | 110 |
|
110 | 111 |
@implementation PithosBrowserController |
111 |
@synthesize pithos; |
|
112 | 112 |
@synthesize pithosAccountManager, accountNode; |
113 | 113 |
@synthesize draggedNodes, draggedParentNode; |
114 | 114 |
@synthesize clipboardNodes, clipboardParentNode, clipboardCopy; |
... | ... | |
209 | 209 |
[activityProgressIndicator setMaxValue:1.0]; |
210 | 210 |
activityFacility = [PithosActivityFacility defaultPithosActivityFacility]; |
211 | 211 |
|
212 |
self.accountNode = [[PithosAccountNode alloc] initWithPithosAccountManager:pithosAccountManager andPithos:pithos];
|
|
212 |
self.accountNode = [[PithosAccountNode alloc] initWithPithosAccountManager:pithosAccountManager]; |
|
213 | 213 |
containersNode = [[PithosEmptyNode alloc] initWithDisplayName:@"CONTAINERS" icon:nil]; |
214 | 214 |
containersNodeChildren = [[NSMutableArray alloc] init]; |
215 | 215 |
sharedNode = [[PithosEmptyNode alloc] initWithDisplayName:@"SHARED" icon:nil]; |
216 |
mySharedNode = [[PithosAccountNode alloc] initWithPithosAccountManager:pithosAccountManager andPithos:pithos];
|
|
216 |
mySharedNode = [[PithosAccountNode alloc] initWithPithosAccountManager:pithosAccountManager]; |
|
217 | 217 |
mySharedNode.displayName = @"shared by me"; |
218 | 218 |
mySharedNode.shared = YES; |
219 | 219 |
mySharedNode.icon = [[NSWorkspace sharedWorkspace] iconForFileType:NSFileTypeForHFSTypeCode(kUserIcon)]; |
220 |
othersSharedNode = [[PithosSharingAccountsNode alloc] initWithPithosAccountManager:pithosAccountManager andPithos:pithos];
|
|
220 |
othersSharedNode = [[PithosSharingAccountsNode alloc] initWithPithosAccountManager:pithosAccountManager]; |
|
221 | 221 |
othersSharedNode.displayName = @"shared with me"; |
222 | 222 |
othersSharedNode.icon = [[NSWorkspace sharedWorkspace] iconForFileType:NSFileTypeForHFSTypeCode(kGroupIcon)]; |
223 | 223 |
|
... | ... | |
337 | 337 |
[uploadCallbackQueue setSuspended:NO]; |
338 | 338 |
[downloadCallbackQueue setSuspended:NO]; |
339 | 339 |
|
340 |
accountNode.pithos = pithos; |
|
341 | 340 |
accountNode.pithosAccountManager = pithosAccountManager; |
342 |
[accountNode forceRefresh]; |
|
343 |
mySharedNode.pithos = pithos; |
|
341 |
[accountNode reset]; |
|
344 | 342 |
mySharedNode.pithosAccountManager = pithosAccountManager; |
345 |
[mySharedNode forceRefresh]; |
|
346 |
othersSharedNode.pithos = pithos; |
|
343 |
[mySharedNode reset]; |
|
347 | 344 |
othersSharedNode.pithosAccountManager = pithosAccountManager; |
348 |
[othersSharedNode forceRefresh];
|
|
349 |
|
|
345 |
[othersSharedNode reset];
|
|
346 |
|
|
350 | 347 |
// [activityFacility reset]; |
351 | 348 |
activityFacility.delegate = self; |
352 | 349 |
|
... | ... | |
383 | 380 |
[self resetBrowser]; |
384 | 381 |
} |
385 | 382 |
|
386 |
- (void)setPithos:(ASIPithos *)aPithos { |
|
387 |
if (aPithos) { |
|
388 |
if (![aPithos.authUser isEqualToString:pithos.authUser] || |
|
389 |
![aPithos.authToken isEqualToString:pithos.authToken] || |
|
390 |
(aPithos.ignoreSSLErrors != pithos.ignoreSSLErrors) || |
|
391 |
![aPithos.storageURLPrefix isEqual:pithos.storageURLPrefix] || |
|
392 |
![aPithos.publicURLPrefix isEqual:pithos.publicURLPrefix]) { |
|
393 |
[self resetBrowser]; |
|
394 |
pithos = aPithos; |
|
395 |
[self startBrowser]; |
|
396 |
} else { |
|
397 |
[self startBrowser]; |
|
398 |
} |
|
383 |
- (void)setPithosAccountManager:(PithosAccount *)aPithosAccountManager { |
|
384 |
if (aPithosAccountManager && (aPithosAccountManager != pithosAccountManager)) { |
|
385 |
[self resetBrowser]; |
|
386 |
if (pithosAccountManager) |
|
387 |
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"PithosAccountPithosChanged" object:pithosAccountManager]; |
|
388 |
pithosAccountManager = aPithosAccountManager; |
|
389 |
[[NSNotificationCenter defaultCenter] addObserver:self |
|
390 |
selector:@selector(pithosAccountManagerPithosChanged:) |
|
391 |
name:@"PithosAccountPithosChanged" |
|
392 |
object:pithosAccountManager]; |
|
393 |
[self startBrowser]; |
|
399 | 394 |
} |
400 | 395 |
} |
401 | 396 |
|
402 |
|
|
403 | 397 |
#pragma mark - |
404 | 398 |
#pragma mark Observers |
405 | 399 |
|
400 |
-(void)pithosAccountManagerPithosChanged:(NSNotification *)notification { |
|
401 |
if (![NSThread isMainThread]) { |
|
402 |
[self performSelectorOnMainThread:@selector(pithosAccountManagerPithosChanged:) withObject:notification waitUntilDone:NO]; |
|
403 |
return; |
|
404 |
} |
|
405 |
[self resetBrowser]; |
|
406 |
[self startBrowser]; |
|
407 |
} |
|
408 |
|
|
406 | 409 |
- (void)pithosNodeChildrenUpdated:(NSNotification *)notification { |
407 | 410 |
if (![NSThread isMainThread]) { |
408 | 411 |
[self performSelectorOnMainThread:@selector(pithosNodeChildrenUpdated:) withObject:notification waitUntilDone:NO]; |
409 | 412 |
return; |
410 | 413 |
} |
411 | 414 |
PithosNode *node = (PithosNode *)[notification object]; |
412 |
if ((node == accountNode) || ![node.pithos isEqualTo:pithos])
|
|
415 |
if ((node == accountNode) || (node.pithosAccountManager != pithosAccountManager))
|
|
413 | 416 |
return; |
414 | 417 |
DLog(@"pithosNodeChildrenUpdated:%@", node.url); |
415 | 418 |
NSInteger lastColumn = [browser lastColumn]; |
... | ... | |
453 | 456 |
BOOL refreshAccountNode = NO; |
454 | 457 |
if (!containerPithosFound) { |
455 | 458 |
// Create pithos node |
456 |
ASIPithosContainerRequest *containerRequest = [ASIPithosContainerRequest createOrUpdateContainerRequestWithPithos:pithos
|
|
459 |
ASIPithosContainerRequest *containerRequest = [ASIPithosContainerRequest createOrUpdateContainerRequestWithPithos:pithosAccountManager.pithos
|
|
457 | 460 |
containerName:@"pithos"]; |
458 | 461 |
[PithosUtilities startAndWaitForRequest:containerRequest]; |
459 | 462 |
if ([containerRequest error]) { |
... | ... | |
464 | 467 |
} |
465 | 468 |
if (!containerTrashFound) { |
466 | 469 |
// Create trash node |
467 |
ASIPithosContainerRequest *containerRequest = [ASIPithosContainerRequest createOrUpdateContainerRequestWithPithos:pithos |
|
470 |
ASIPithosContainerRequest *containerRequest = [ASIPithosContainerRequest createOrUpdateContainerRequestWithPithos:pithosAccountManager.pithos
|
|
468 | 471 |
containerName:@"trash"]; |
469 | 472 |
[PithosUtilities startAndWaitForRequest:containerRequest]; |
470 | 473 |
if ([containerRequest error]) { |
... | ... | |
615 | 618 |
destinationObjectName = [destinationObjectName stringByAppendingString:@"/"]; |
616 | 619 |
NSError *error = nil; |
617 | 620 |
BOOL isDirectory; |
618 |
if ([PithosUtilities objectExistsAtPithos:pithos
|
|
621 |
if ([PithosUtilities objectExistsAtPithos:pithosAccountManager.pithos
|
|
619 | 622 |
containerName:node.pithosContainer.name |
620 | 623 |
objectName:destinationObjectName |
621 | 624 |
error:&error |
... | ... | |
634 | 637 |
} |
635 | 638 |
if (operation.isCancelled) |
636 | 639 |
return; |
637 |
ASIPithosObjectRequest *objectRequest = [PithosUtilities moveObjectRequestWithPithos:pithos |
|
640 |
ASIPithosObjectRequest *objectRequest = [PithosUtilities moveObjectRequestWithPithos:pithosAccountManager.pithos
|
|
638 | 641 |
containerName:node.pithosContainer.name |
639 | 642 |
objectName:node.pithosObject.name |
640 | 643 |
destinationContainerName:node.pithosContainer.name |
... | ... | |
683 | 686 |
NSString *destinationObjectName = [[node.pithosObject.name stringByDeletingLastPathComponent] stringByAppendingPathComponent:newName]; |
684 | 687 |
NSError *error = nil; |
685 | 688 |
BOOL isDirectory; |
686 |
if ([PithosUtilities objectExistsAtPithos:pithos
|
|
689 |
if ([PithosUtilities objectExistsAtPithos:pithosAccountManager.pithos
|
|
687 | 690 |
containerName:node.pithosContainer.name |
688 | 691 |
objectName:destinationObjectName |
689 | 692 |
error:&error |
... | ... | |
704 | 707 |
return; |
705 | 708 |
if (node.pithosObject.subdir) |
706 | 709 |
destinationObjectName = [destinationObjectName stringByAppendingString:@"/"]; |
707 |
NSArray *objectRequests = [PithosUtilities moveObjectRequestsForSubdirWithPithos:pithos
|
|
710 |
NSArray *objectRequests = [PithosUtilities moveObjectRequestsForSubdirWithPithos:pithosAccountManager.pithos
|
|
708 | 711 |
containerName:node.pithosContainer.name |
709 | 712 |
objectName:node.pithosObject.name |
710 | 713 |
destinationContainerName:node.pithosContainer.name |
... | ... | |
952 | 955 |
@autoreleasepool { |
953 | 956 |
if (operation.isCancelled) |
954 | 957 |
return; |
955 |
NSArray *objectRequests = [PithosUtilities objectDataRequestsForSubdirWithPithos:pithos
|
|
958 |
NSArray *objectRequests = [PithosUtilities objectDataRequestsForSubdirWithPithos:pithosAccountManager.pithos
|
|
956 | 959 |
containerName:node.pithosContainer.name |
957 | 960 |
objectName:node.pithosObject.name |
958 | 961 |
toDirectory:dirPath |
... | ... | |
1008 | 1011 |
@autoreleasepool { |
1009 | 1012 |
if (operation.isCancelled) |
1010 | 1013 |
return; |
1011 |
__block ASIPithosObjectRequest *objectRequest = [PithosUtilities objectDataRequestWithPithos:pithos |
|
1014 |
__block ASIPithosObjectRequest *objectRequest = [PithosUtilities objectDataRequestWithPithos:pithosAccountManager.pithos
|
|
1012 | 1015 |
containerName:node.pithosContainer.name |
1013 | 1016 |
objectName:node.pithosObject.name |
1014 | 1017 |
version:version |
... | ... | |
1066 | 1069 |
else |
1067 | 1070 |
objectNamePrefix = [NSString string]; |
1068 | 1071 |
if ((destinationNode.pithosContainer.blockHash == nil) || (destinationNode.pithosContainer.blockSize == 0)) { |
1069 |
ASIPithosContainerRequest *containerRequest = [ASIPithosContainerRequest containerMetadataRequestWithPithos:pithos
|
|
1072 |
ASIPithosContainerRequest *containerRequest = [ASIPithosContainerRequest containerMetadataRequestWithPithos:pithosAccountManager.pithos
|
|
1070 | 1073 |
containerName:containerName]; |
1071 | 1074 |
[PithosUtilities startAndWaitForRequest:containerRequest]; |
1072 | 1075 |
if ([containerRequest error]) { |
... | ... | |
1105 | 1108 |
NSArray *hashes = nil; |
1106 | 1109 |
if (operation.isCancelled) |
1107 | 1110 |
return; |
1108 |
ASIPithosObjectRequest *objectRequest = [PithosUtilities writeObjectDataRequestWithPithos:pithos |
|
1111 |
ASIPithosObjectRequest *objectRequest = [PithosUtilities writeObjectDataRequestWithPithos:pithosAccountManager.pithos
|
|
1109 | 1112 |
containerName:containerName |
1110 | 1113 |
objectName:objectName |
1111 | 1114 |
contentType:contentType |
... | ... | |
1176 | 1179 |
NSMutableArray *filePaths = nil; |
1177 | 1180 |
NSMutableArray *hashesArrays = nil; |
1178 | 1181 |
NSMutableArray *directoryObjectRequests = nil; |
1179 |
NSArray *objectRequests = [PithosUtilities writeObjectDataRequestsWithPithos:pithos
|
|
1182 |
NSArray *objectRequests = [PithosUtilities writeObjectDataRequestsWithPithos:pithosAccountManager.pithos
|
|
1180 | 1183 |
containerName:containerName |
1181 | 1184 |
objectName:objectName |
1182 | 1185 |
blockSize:blockSize |
... | ... | |
1295 | 1298 |
NSString *destinationObjectName = [objectNamePrefix stringByAppendingPathComponent:node.displayName]; |
1296 | 1299 |
if ([node.pithosObject.name hasSuffix:@"/"]) |
1297 | 1300 |
destinationObjectName = [destinationObjectName stringByAppendingString:@"/"]; |
1298 |
ASIPithosObjectRequest *objectRequest = [PithosUtilities moveObjectRequestWithPithos:pithos
|
|
1301 |
ASIPithosObjectRequest *objectRequest = [PithosUtilities moveObjectRequestWithPithos:pithosAccountManager.pithos
|
|
1299 | 1302 |
containerName:node.pithosContainer.name |
1300 | 1303 |
objectName:node.pithosObject.name |
1301 | 1304 |
destinationContainerName:containerName |
... | ... | |
1341 | 1344 |
NSString *destinationObjectName = [objectNamePrefix stringByAppendingPathComponent:node.displayName]; |
1342 | 1345 |
if (node.pithosObject.subdir) |
1343 | 1346 |
destinationObjectName = [destinationObjectName stringByAppendingString:@"/"]; |
1344 |
NSArray *objectRequests = [PithosUtilities moveObjectRequestsForSubdirWithPithos:pithos
|
|
1347 |
NSArray *objectRequests = [PithosUtilities moveObjectRequestsForSubdirWithPithos:pithosAccountManager.pithos
|
|
1345 | 1348 |
containerName:node.pithosContainer.name |
1346 | 1349 |
objectName:node.pithosObject.name |
1347 | 1350 |
destinationContainerName:containerName |
... | ... | |
1416 | 1419 |
if ([node.pithosObject.name hasSuffix:@"/"]) |
1417 | 1420 |
destinationObjectName = [destinationObjectName stringByAppendingString:@"/"]; |
1418 | 1421 |
} else { |
1419 |
destinationObjectName = [PithosUtilities safeObjectNameForPithos:pithos
|
|
1422 |
destinationObjectName = [PithosUtilities safeObjectNameForPithos:pithosAccountManager.pithos
|
|
1420 | 1423 |
containerName:containerName |
1421 | 1424 |
objectName:node.pithosObject.name]; |
1422 | 1425 |
} |
1423 | 1426 |
if (operation.isCancelled) |
1424 | 1427 |
return; |
1425 |
ASIPithosObjectRequest *objectRequest = [PithosUtilities cpyObjectRequestWithPithos:pithos |
|
1428 |
ASIPithosObjectRequest *objectRequest = [PithosUtilities cpyObjectRequestWithPithos:pithosAccountManager.pithos
|
|
1426 | 1429 |
containerName:node.pithosContainer.name |
1427 | 1430 |
objectName:node.pithosObject.name |
1428 | 1431 |
destinationContainerName:containerName |
... | ... | |
1472 | 1475 |
if (node.pithosObject.subdir) |
1473 | 1476 |
destinationObjectName = [destinationObjectName stringByAppendingString:@"/"]; |
1474 | 1477 |
} else { |
1475 |
destinationObjectName = [PithosUtilities safeSubdirNameForPithos:pithos |
|
1478 |
destinationObjectName = [PithosUtilities safeSubdirNameForPithos:pithosAccountManager.pithos
|
|
1476 | 1479 |
containerName:containerName |
1477 | 1480 |
subdirName:node.pithosObject.name]; |
1478 | 1481 |
} |
1479 | 1482 |
if (operation.isCancelled) |
1480 | 1483 |
return; |
1481 |
NSArray *objectRequests = [PithosUtilities cpyObjectRequestsForSubdirWithPithos:pithos |
|
1484 |
NSArray *objectRequests = [PithosUtilities cpyObjectRequestsForSubdirWithPithos:pithosAccountManager.pithos
|
|
1482 | 1485 |
containerName:node.pithosContainer.name |
1483 | 1486 |
objectName:node.pithosObject.name |
1484 | 1487 |
destinationContainerName:containerName |
... | ... | |
1782 | 1785 |
currentBytes:currentBytes]; |
1783 | 1786 |
}); |
1784 | 1787 |
NSUInteger missingBlockIndex = [missingBlocks firstIndex]; |
1785 |
__block ASIPithosContainerRequest *newContainerRequest = [PithosUtilities updateContainerDataRequestWithPithos:pithos
|
|
1788 |
__block ASIPithosContainerRequest *newContainerRequest = [PithosUtilities updateContainerDataRequestWithPithos:pithosAccountManager.pithos
|
|
1786 | 1789 |
containerName:[objectRequest.userInfo objectForKey:@"containerName"] |
1787 | 1790 |
blockSize:blockSize |
1788 | 1791 |
forFile:[objectRequest.userInfo objectForKey:@"filePath"] |
... | ... | |
1826 | 1829 |
missingBlockIndex = [missingBlocks indexGreaterThanIndex:missingBlockIndex]; |
1827 | 1830 |
if (missingBlockIndex == NSNotFound) { |
1828 | 1831 |
NSArray *hashes = [containerRequest.userInfo objectForKey:@"hashes"]; |
1829 |
ASIPithosObjectRequest *newObjectRequest = [PithosUtilities writeObjectDataRequestWithPithos:pithos |
|
1832 |
ASIPithosObjectRequest *newObjectRequest = [PithosUtilities writeObjectDataRequestWithPithos:pithosAccountManager.pithos
|
|
1830 | 1833 |
containerName:[containerRequest.userInfo objectForKey:@"containerName"] |
1831 | 1834 |
objectName:[containerRequest.userInfo objectForKey:@"objectName"] |
1832 | 1835 |
contentType:[containerRequest.userInfo objectForKey:@"contentType"] |
... | ... | |
1846 | 1849 |
[(NSMutableDictionary *)(newObjectRequest.userInfo) setObject:NSStringFromSelector(@selector(uploadObjectUsingHashMapFinished:)) forKey:@"didFinishSelector"]; |
1847 | 1850 |
[uploadNetworkQueue addOperation:[PithosUtilities prepareRequest:newObjectRequest priority:[[newObjectRequest.userInfo objectForKey:@"priority"] integerValue]]]; |
1848 | 1851 |
} else { |
1849 |
__block ASIPithosContainerRequest *newContainerRequest = [PithosUtilities updateContainerDataRequestWithPithos:pithos |
|
1852 |
__block ASIPithosContainerRequest *newContainerRequest = [PithosUtilities updateContainerDataRequestWithPithos:pithosAccountManager.pithos
|
|
1850 | 1853 |
containerName:[containerRequest.userInfo objectForKey:@"containerName"] |
1851 | 1854 |
blockSize:[[containerRequest.userInfo objectForKey:@"blockSize"] unsignedIntegerValue] |
1852 | 1855 |
forFile:[containerRequest.userInfo objectForKey:@"filePath"] |
... | ... | |
2355 | 2358 |
@autoreleasepool { |
2356 | 2359 |
if (operation.isCancelled) |
2357 | 2360 |
return; |
2358 |
NSString *safeObjectName = [PithosUtilities safeSubdirNameForPithos:pithos |
|
2361 |
NSString *safeObjectName = [PithosUtilities safeSubdirNameForPithos:pithosAccountManager.pithos
|
|
2359 | 2362 |
containerName:node.pithosContainer.name |
2360 | 2363 |
subdirName:@"untitled folder"]; |
2361 | 2364 |
NSString *fileName = [safeObjectName lastPathComponent]; |
2362 | 2365 |
if (operation.isCancelled) |
2363 | 2366 |
return; |
2364 |
ASIPithosObjectRequest *objectRequest = [ASIPithosObjectRequest writeObjectDataRequestWithPithos:pithos |
|
2367 |
ASIPithosObjectRequest *objectRequest = [ASIPithosObjectRequest writeObjectDataRequestWithPithos:pithosAccountManager.pithos
|
|
2365 | 2368 |
containerName:node.pithosContainer.name |
2366 | 2369 |
objectName:safeObjectName |
2367 | 2370 |
eTag:nil |
... | ... | |
2405 | 2408 |
@autoreleasepool { |
2406 | 2409 |
if (operation.isCancelled) |
2407 | 2410 |
return; |
2408 |
NSString *safeObjectName = [PithosUtilities safeSubdirNameForPithos:pithos |
|
2411 |
NSString *safeObjectName = [PithosUtilities safeSubdirNameForPithos:pithosAccountManager.pithos
|
|
2409 | 2412 |
containerName:node.pithosContainer.name |
2410 | 2413 |
subdirName:[node.pithosObject.name stringByAppendingPathComponent:@"untitled folder"]]; |
2411 | 2414 |
NSString *fileName = [safeObjectName lastPathComponent]; |
2412 | 2415 |
if (operation.isCancelled) |
2413 | 2416 |
return; |
2414 |
ASIPithosObjectRequest *objectRequest = [ASIPithosObjectRequest writeObjectDataRequestWithPithos:pithos
|
|
2417 |
ASIPithosObjectRequest *objectRequest = [ASIPithosObjectRequest writeObjectDataRequestWithPithos:pithosAccountManager.pithos
|
|
2415 | 2418 |
containerName:node.pithosContainer.name |
2416 | 2419 |
objectName:safeObjectName |
2417 | 2420 |
eTag:nil |
... | ... | |
2501 | 2504 |
NSString *fileName = [node.pithosObject.name lastPathComponent]; |
2502 | 2505 |
if ([node.pithosObject.name hasSuffix:@"/"]) |
2503 | 2506 |
fileName = [fileName stringByAppendingString:@"/"]; |
2504 |
ASIPithosObjectRequest *objectRequest = [ASIPithosObjectRequest deleteObjectRequestWithPithos:pithos
|
|
2507 |
ASIPithosObjectRequest *objectRequest = [ASIPithosObjectRequest deleteObjectRequestWithPithos:pithosAccountManager.pithos
|
|
2505 | 2508 |
containerName:node.pithosContainer.name |
2506 | 2509 |
objectName:node.pithosObject.name]; |
2507 | 2510 |
if (operation.isCancelled) |
... | ... | |
2537 | 2540 |
@autoreleasepool { |
2538 | 2541 |
if (operation.isCancelled) |
2539 | 2542 |
return; |
2540 |
NSArray *objectRequests = [PithosUtilities deleteObjectRequestsForSubdirWithPithos:pithos |
|
2543 |
NSArray *objectRequests = [PithosUtilities deleteObjectRequestsForSubdirWithPithos:pithosAccountManager.pithos
|
|
2541 | 2544 |
containerName:node.pithosContainer.name |
2542 | 2545 |
objectName:node.pithosObject.name]; |
2543 | 2546 |
if (!operation.isCancelled && objectRequests) { |
... | ... | |
2589 | 2592 |
@autoreleasepool { |
2590 | 2593 |
if (operation.isCancelled) |
2591 | 2594 |
return; |
2592 |
NSString *safeObjectName = [PithosUtilities safeObjectNameForPithos:pithos |
|
2595 |
NSString *safeObjectName = [PithosUtilities safeObjectNameForPithos:pithosAccountManager.pithos
|
|
2593 | 2596 |
containerName:@"trash" |
2594 | 2597 |
objectName:node.pithosObject.name]; |
2595 | 2598 |
if (!operation.isCancelled && safeObjectName) { |
2596 |
ASIPithosObjectRequest *objectRequest = [PithosUtilities moveObjectRequestWithPithos:pithos
|
|
2599 |
ASIPithosObjectRequest *objectRequest = [PithosUtilities moveObjectRequestWithPithos:pithosAccountManager.pithos
|
|
2597 | 2600 |
containerName:node.pithosContainer.name |
2598 | 2601 |
objectName:node.pithosObject.name |
2599 | 2602 |
destinationContainerName:@"trash" |
... | ... | |
2637 | 2640 |
@autoreleasepool { |
2638 | 2641 |
if (operation.isCancelled) |
2639 | 2642 |
return; |
2640 |
NSString *safeObjectName = [PithosUtilities safeSubdirNameForPithos:pithos
|
|
2643 |
NSString *safeObjectName = [PithosUtilities safeSubdirNameForPithos:pithosAccountManager.pithos
|
|
2641 | 2644 |
containerName:@"trash" |
2642 | 2645 |
subdirName:node.pithosObject.name]; |
2643 | 2646 |
if (!operation.isCancelled && safeObjectName) { |
2644 |
NSArray *objectRequests = [PithosUtilities moveObjectRequestsForSubdirWithPithos:pithos
|
|
2647 |
NSArray *objectRequests = [PithosUtilities moveObjectRequestsForSubdirWithPithos:pithosAccountManager.pithos
|
|
2645 | 2648 |
containerName:node.pithosContainer.name |
2646 | 2649 |
objectName:node.pithosObject.name |
2647 | 2650 |
destinationContainerName:@"trash" |
b/pithos-macos/PithosContainerNode.h | ||
---|---|---|
2 | 2 |
// PithosContainerNode.h |
3 | 3 |
// pithos-macos |
4 | 4 |
// |
5 |
// Copyright 2011-2012 GRNET S.A. All rights reserved.
|
|
5 |
// Copyright 2011-2013 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 |
... | ... | |
36 | 36 |
// or implied, of GRNET S.A. |
37 | 37 |
|
38 | 38 |
#import "PithosNode.h" |
39 |
@class ASIPithos; |
|
40 | 39 |
@class ASIPithosContainer; |
41 | 40 |
@class ASIPithosContainerRequest; |
42 | 41 |
|
43 | 42 |
@interface PithosContainerNode : PithosNode { |
44 |
ASIPithos *pithos; |
|
45 | 43 |
ASIPithosContainer *pithosContainer; |
46 | 44 |
|
47 | 45 |
ASIPithosContainerRequest *containerRequest; |
... | ... | |
54 | 52 |
NSNumber *policyQuota; |
55 | 53 |
} |
56 | 54 |
|
57 |
- (id)initWithPithosAccountManager:(PithosAccount *)aPithosAccountManager |
|
58 |
andPithos:(ASIPithos *)aPithos pithosContainer:(ASIPithosContainer *)aPithosContainer; |
|
59 |
- (id)initWithPithosAccountManager:(PithosAccount *)aPithosAccountManager |
|
60 |
andPithos:(ASIPithos *)aPithos pithosContainer:(ASIPithosContainer *)aPithosContainer icon:(NSImage *)anIcon; |
|
61 |
- (id)initWithPithosAccountManager:(PithosAccount *)aPithosAccountManager |
|
62 |
andPithos:(ASIPithos *)aPithos containerName:(NSString *)aContainerName; |
|
63 |
- (id)initWithPithosAccountManager:(PithosAccount *)aPithosAccountManager |
|
64 |
andPithos:(ASIPithos *)aPithos containerName:(NSString *)aContainerName icon:(NSImage *)anIcon; |
|
55 |
- (id)initWithPithosAccountManager:(PithosAccount *)aPithosAccountManager pithosContainer:(ASIPithosContainer *)aPithosContainer; |
|
56 |
- (id)initWithPithosAccountManager:(PithosAccount *)aPithosAccountManager pithosContainer:(ASIPithosContainer *)aPithosContainer icon:(NSImage *)anIcon; |
|
57 |
- (id)initWithPithosAccountManager:(PithosAccount *)aPithosAccountManager containerName:(NSString *)aContainerName; |
|
58 |
- (id)initWithPithosAccountManager:(PithosAccount *)aPithosAccountManager containerName:(NSString *)aContainerName icon:(NSImage *)anIcon; |
|
65 | 59 |
|
66 |
@property(nonatomic, strong) ASIPithos *pithos; |
|
67 | 60 |
@property(nonatomic, strong) ASIPithosContainer *pithosContainer; |
68 | 61 |
@property(nonatomic, strong) ASIPithosContainerRequest *containerRequest; |
69 | 62 |
@property(nonatomic, strong) NSString *prefix; |
b/pithos-macos/PithosContainerNode.m | ||
---|---|---|
2 | 2 |
// PithosContainerNode.m |
3 | 3 |
// pithos-macos |
4 | 4 |
// |
5 |
// Copyright 2011-2012 GRNET S.A. All rights reserved.
|
|
5 |
// Copyright 2011-2013 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 |
... | ... | |
44 | 44 |
#import "ASIPithosObject.h" |
45 | 45 |
#import "ASIDownloadCache.h" |
46 | 46 |
#import "PithosUtilities.h" |
47 |
#import "PithosAccount.h" |
|
47 | 48 |
#import "PithosContainerNodeInfoController.h" |
48 | 49 |
#import "PithosActivityFacility.h" |
49 | 50 |
|
50 | 51 |
static NSImage *sharedIcon = nil; |
51 | 52 |
|
52 | 53 |
@implementation PithosContainerNode |
53 |
@synthesize pithos, pithosContainer, containerRequest, prefix, applyMetadataContainerRequest, refreshMetadataContainerRequest;
|
|
54 |
@synthesize pithosContainer, containerRequest, prefix, applyMetadataContainerRequest, refreshMetadataContainerRequest; |
|
54 | 55 |
@synthesize policyVersioning, policyQuota; |
55 | 56 |
|
56 | 57 |
+ (void)initialize { |
... | ... | |
61 | 62 |
#pragma mark - |
62 | 63 |
#pragma mark Object Lifecycle |
63 | 64 |
|
64 |
- (id)initWithPithosAccountManager:(PithosAccount *)aPithosAccountManager |
|
65 |
andPithos:(ASIPithos *)aPithos pithosContainer:(ASIPithosContainer *)aPithosContainer icon:(NSImage *)anIcon { |
|
65 |
- (id)initWithPithosAccountManager:(PithosAccount *)aPithosAccountManager pithosContainer:(ASIPithosContainer *)aPithosContainer icon:(NSImage *)anIcon { |
|
66 | 66 |
if ((self = [super initWithPithosAccountManager:aPithosAccountManager])) { |
67 |
pithos = aPithos; |
|
68 | 67 |
self.pithosContainer = aPithosContainer; |
69 | 68 |
self.icon = anIcon; |
70 | 69 |
} |
71 | 70 |
return self; |
72 | 71 |
} |
73 | 72 |
|
74 |
- (id)initWithPithosAccountManager:(PithosAccount *)aPithosAccountManager |
|
75 |
andPithos:(ASIPithos *)aPithos pithosContainer:(ASIPithosContainer *)aPithosContainer { |
|
76 |
return [self initWithPithosAccountManager:aPithosAccountManager andPithos:aPithos pithosContainer:aPithosContainer icon:nil]; |
|
73 |
- (id)initWithPithosAccountManager:(PithosAccount *)aPithosAccountManager pithosContainer:(ASIPithosContainer *)aPithosContainer { |
|
74 |
return [self initWithPithosAccountManager:aPithosAccountManager pithosContainer:aPithosContainer icon:nil]; |
|
77 | 75 |
} |
78 | 76 |
|
79 |
- (id)initWithPithosAccountManager:(PithosAccount *)aPithosAccountManager |
|
80 |
andPithos:(ASIPithos *)aPithos containerName:(NSString *)aContainerName icon:(NSImage *)anIcon { |
|
77 |
- (id)initWithPithosAccountManager:(PithosAccount *)aPithosAccountManager containerName:(NSString *)aContainerName icon:(NSImage *)anIcon { |
|
81 | 78 |
ASIPithosContainer *container = [ASIPithosContainer container]; |
82 | 79 |
container.name = aContainerName; |
83 |
return [self initWithPithosAccountManager:aPithosAccountManager andPithos:aPithos pithosContainer:container icon:anIcon];
|
|
80 |
return [self initWithPithosAccountManager:aPithosAccountManager pithosContainer:container icon:anIcon]; |
|
84 | 81 |
} |
85 | 82 |
|
86 |
- (id)initWithPithosAccountManager:(PithosAccount *)aPithosAccountManager |
|
87 |
andPithos:(ASIPithos *)aPithos containerName:(NSString *)aContainerName { |
|
88 |
return [self initWithPithosAccountManager:aPithosAccountManager andPithos:aPithos containerName:aContainerName icon:nil]; |
|
83 |
- (id)initWithPithosAccountManager:(PithosAccount *)aPithosAccountManager containerName:(NSString *)aContainerName { |
|
84 |
return [self initWithPithosAccountManager:aPithosAccountManager containerName:aContainerName icon:nil]; |
|
89 | 85 |
} |
90 | 86 |
|
91 | 87 |
- (void)dealloc { |
... | ... | |
97 | 93 |
#pragma mark - |
98 | 94 |
#pragma mark Properties |
99 | 95 |
|
100 |
- (void)setPithos:(ASIPithos *)aPithos { |
|
101 |
if (aPithos && ![aPithos isEqualTo:pithos]) { |
|
102 |
pithos = aPithos; |
|
103 |
url = nil; |
|
104 |
} |
|
105 |
} |
|
106 |
|
|
107 | 96 |
- (NSString *)url { |
108 |
if (url == nil) |
|
109 |
url = [[NSString alloc] initWithFormat:@"%@/%@%@", |
|
110 |
(sharingAccount ? [pithos storageURLWithAuthUser:sharingAccount] : pithos.storageURL), |
|
111 |
pithosContainer.name, |
|
112 |
(shared ? @"?shared" : @"")]; |
|
113 |
return url; |
|
97 |
return [NSString stringWithFormat:@"@container@%@/%@%@", |
|
98 |
(sharingAccount ? sharingAccount : pithosAccountManager.pithos.authUser), |
|
99 |
pithosContainer.name, |
|
100 |
(shared ? @"?shared" : @"")]; |
|
114 | 101 |
} |
115 | 102 |
|
116 | 103 |
- (NSArray *)children { |
... | ... | |
120 | 107 |
break; |
121 | 108 |
case PithosNodeStateRefreshNeeded: |
122 | 109 |
freshness = PithosNodeStateRefreshing; |
123 |
self.containerRequest = [ASIPithosContainerRequest listObjectsRequestWithPithos:pithos |
|
110 |
self.containerRequest = [ASIPithosContainerRequest listObjectsRequestWithPithos:pithosAccountManager.pithos
|
|
124 | 111 |
containerName:pithosContainer.name |
125 | 112 |
limit:0 |
126 | 113 |
marker:nil |
... | ... | |
131 | 118 |
shared:shared |
132 | 119 |
until:nil]; |
133 | 120 |
if (sharingAccount) |
134 |
[containerRequest setRequestUserFromDefaultTo:sharingAccount withPithos:pithos]; |
|
121 |
[containerRequest setRequestUserFromDefaultTo:sharingAccount withPithos:pithosAccountManager.pithos];
|
|
135 | 122 |
else if (!forcedRefresh) |
136 | 123 |
containerRequest.downloadCache = [ASIDownloadCache sharedCache]; |
137 | 124 |
containerRequest.delegate = self; |
... | ... | |
273 | 260 |
if ((sameNameObjectIndex == NSNotFound) || |
274 | 261 |
![PithosUtilities isContentTypeDirectory:[[objects objectAtIndex:sameNameObjectIndex] contentType]]) { |
275 | 262 |
PithosSubdirNode *node = [[PithosSubdirNode alloc] initWithPithosAccountManager:pithosAccountManager |
276 |
andPithos:pithos |
|
277 | 263 |
pithosContainer:pithosContainer |
278 | 264 |
pithosObject:object]; |
279 | 265 |
node.parent = self; |
... | ... | |
297 | 283 |
} |
298 | 284 |
} else if ([PithosUtilities isContentTypeDirectory:object.contentType]) { |
299 | 285 |
PithosSubdirNode *node = [[PithosSubdirNode alloc] initWithPithosAccountManager:pithosAccountManager |
300 |
andPithos:pithos |
|
301 | 286 |
pithosContainer:pithosContainer |
302 | 287 |
pithosObject:object]; |
303 | 288 |
node.parent = self; |
... | ... | |
318 | 303 |
[newChildren addObject:node]; |
319 | 304 |
} else { |
320 | 305 |
PithosObjectNode *node = [[PithosObjectNode alloc] initWithPithosAccountManager:pithosAccountManager |
321 |
andPithos:pithos |
|
322 | 306 |
pithosContainer:pithosContainer |
323 | 307 |
pithosObject:object]; |
324 | 308 |
node.parent = self; |
... | ... | |
356 | 340 |
[self postChildrenUpdatedNotificationName]; |
357 | 341 |
} else { |
358 | 342 |
// Do an additional request to fetch more objects |
359 |
self.containerRequest = [ASIPithosContainerRequest listObjectsRequestWithPithos:pithos |
|
343 |
self.containerRequest = [ASIPithosContainerRequest listObjectsRequestWithPithos:pithosAccountManager.pithos
|
|
360 | 344 |
containerName:pithosContainer.name |
361 | 345 |
limit:0 |
362 | 346 |
marker:[[someObjects lastObject] name] |
... | ... | |
367 | 351 |
shared:shared |
368 | 352 |
until:nil]; |
369 | 353 |
if (sharingAccount) |
370 |
[containerRequest setRequestUserFromDefaultTo:sharingAccount withPithos:pithos]; |
|
354 |
[containerRequest setRequestUserFromDefaultTo:sharingAccount withPithos:pithosAccountManager.pithos];
|
|
371 | 355 |
else if (!forcedRefresh) |
372 | 356 |
containerRequest.downloadCache = [ASIDownloadCache sharedCache]; |
373 | 357 |
containerRequest.delegate = self; |
... | ... | |
455 | 439 |
@synchronized(self) { |
456 | 440 |
if (applyMetadataContainerRequest == nil) { |
457 | 441 |
[[pithosNodeInfoController window] makeFirstResponder:nil]; |
458 |
self.applyMetadataContainerRequest = [ASIPithosContainerRequest updateContainerMetadataRequestWithPithos:pithos |
|
442 |
self.applyMetadataContainerRequest = [ASIPithosContainerRequest updateContainerMetadataRequestWithPithos:pithosAccountManager.pithos
|
|
459 | 443 |
containerName:pithosContainer.name |
460 | 444 |
policy:[NSDictionary dictionaryWithObjectsAndKeys: |
461 | 445 |
policyVersioning, @"versioning", |
... | ... | |
480 | 464 |
- (void)refreshInfo { |
481 | 465 |
@synchronized(self) { |
482 | 466 |
if (refreshMetadataContainerRequest == nil) { |
483 |
self.refreshMetadataContainerRequest = [ASIPithosContainerRequest containerMetadataRequestWithPithos:pithos |
|
467 |
self.refreshMetadataContainerRequest = [ASIPithosContainerRequest containerMetadataRequestWithPithos:pithosAccountManager.pithos
|
|
484 | 468 |
containerName:pithosContainer.name]; |
485 | 469 |
refreshMetadataContainerRequest.delegate = self; |
486 | 470 |
refreshMetadataContainerRequest.didFinishSelector = @selector(performRequestFinishedDelegateInBackground:); |
b/pithos-macos/PithosNode.m | ||
---|---|---|
2 | 2 |
// PithosNode.m |
3 | 3 |
// pithos-macos |
4 | 4 |
// |
5 |
// Copyright 2011 GRNET S.A. All rights reserved. |
|
5 |
// Copyright 2011-2013 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 |
... | ... | |
73 | 73 |
} |
74 | 74 |
|
75 | 75 |
#pragma mark - |
76 |
#pragma mark Properties |
|
77 |
|
|
78 |
- (void)setShared:(BOOL)aShared { |
|
79 |
if (shared != aShared) { |
|
80 |
shared = aShared; |
|
81 |
url = nil; |
|
82 |
} |
|
83 |
} |
|
84 |
|
|
85 |
- (void)setSharingAccount:(NSString *)aSharingAccount { |
|
86 |
if (![sharingAccount isEqualToString:aSharingAccount]) { |
|
87 |
sharingAccount = aSharingAccount; |
|
88 |
url = nil; |
|
89 |
} |
|
90 |
} |
|
91 |
|
|
92 |
#pragma mark - |
|
93 | 76 |
#pragma mark Actions |
94 | 77 |
|
95 | 78 |
- (void)invalidateChildren { |
b/pithos-macos/PithosObjectNode.h | ||
---|---|---|
2 | 2 |
// PithosObjectNode.h |
3 | 3 |
// pithos-macos |
4 | 4 |
// |
5 |
// Copyright 2011-2012 GRNET S.A. All rights reserved.
|
|
5 |
// Copyright 2011-2013 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 |
... | ... | |
36 | 36 |
// or implied, of GRNET S.A. |
37 | 37 |
|
38 | 38 |
#import "PithosNode.h" |
39 |
@class ASIPithos; |
|
40 | 39 |
@class ASIPithosContainer; |
41 | 40 |
@class ASIPithosObject; |
42 | 41 |
@class ASIPithosObjectRequest; |
43 | 42 |
|
44 | 43 |
@interface PithosObjectNode : PithosNode { |
45 |
ASIPithos *pithos; |
|
46 | 44 |
ASIPithosContainer *pithosContainer; |
47 | 45 |
ASIPithosObject *pithosObject; |
48 | 46 |
NSArray *versions; |
... | ... | |
57 | 55 |
} |
58 | 56 |
|
59 | 57 |
- (id)initWithPithosAccountManager:(PithosAccount *)aPithosAccountManager |
60 |
andPithos:(ASIPithos *)aPithos |
|
61 | 58 |
pithosContainer:(ASIPithosContainer *)aPithosContainer |
62 | 59 |
pithosObject:(ASIPithosObject *)aPithosObject; |
63 | 60 |
|
64 |
@property (nonatomic, strong) ASIPithos *pithos; |
|
65 | 61 |
@property (nonatomic, strong) ASIPithosContainer *pithosContainer; |
66 | 62 |
@property (nonatomic, strong) ASIPithosObject *pithosObject; |
67 | 63 |
@property (nonatomic, strong) NSArray *versions; |
b/pithos-macos/PithosObjectNode.m | ||
---|---|---|
2 | 2 |
// PithosObjectNode.m |
3 | 3 |
// pithos-macos |
4 | 4 |
// |
5 |
// Copyright 2011-2012 GRNET S.A. All rights reserved.
|
|
5 |
// Copyright 2011-2013 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 |
... | ... | |
48 | 48 |
#import "PithosObjectNodeInfoController.h" |
49 | 49 |
|
50 | 50 |
@implementation PithosObjectNode |
51 |
@synthesize pithos, pithosContainer, pithosObject, versions, applyMetadataObjectRequest, refreshMetadataObjectRequest, refreshVersionsObjectRequest;
|
|
51 |
@synthesize pithosContainer, pithosObject, versions, applyMetadataObjectRequest, refreshMetadataObjectRequest, refreshVersionsObjectRequest; |
|
52 | 52 |
@synthesize isPublic, translatedModifiedBy, translatedPermissions; |
53 | 53 |
|
54 | 54 |
#pragma mark - |
55 | 55 |
#pragma mark Object Lifecycle |
56 | 56 |
|
57 | 57 |
- (id)initWithPithosAccountManager:(PithosAccount *)aPithosAccountManager |
58 |
andPithos:(ASIPithos *)aPithos |
|
59 | 58 |
pithosContainer:(ASIPithosContainer *)aPithosContainer |
60 | 59 |
pithosObject:(ASIPithosObject *)aPithosObject { |
61 | 60 |
if ((self = [super initWithPithosAccountManager:aPithosAccountManager])) { |
62 |
pithos = aPithos; |
|
63 | 61 |
isLeafItem = YES; |
64 | 62 |
self.pithosContainer = aPithosContainer; |
65 | 63 |
self.pithosObject = aPithosObject; |
... | ... | |
121 | 119 |
#pragma mark - |
122 | 120 |
#pragma mark Properties |
123 | 121 |
|
124 |
- (void)setPithos:(ASIPithos *)aPithos { |
|
125 |
if (aPithos && ![aPithos isEqualTo:pithos]) { |
|
126 |
pithos = aPithos; |
|
127 |
url = nil; |
|
128 |
} |
|
129 |
} |
|
130 |
|
|
131 | 122 |
- (NSString *)url { |
132 |
if (url == nil) |
|
133 |
url = [[NSString alloc] initWithFormat:@"object %@/%@/%@%@", |
|
134 |
(sharingAccount ? [pithos storageURLWithAuthUser:sharingAccount] : pithos.storageURL), |
|
135 |
pithosContainer.name, |
|
136 |
pithosObject.name, |
|
137 |
(shared ? @"?shared" : @"")]; |
|
138 |
return url; |
|
123 |
return [NSString stringWithFormat:@"@object@%@/%@/%@%@", |
|
124 |
(sharingAccount ? sharingAccount : pithosAccountManager.pithos.authUser), |
|
125 |
pithosContainer.name, |
|
126 |
pithosObject.name, |
|
127 |
(shared ? @"?shared" : @"")]; |
|
139 | 128 |
} |
140 | 129 |
|
141 | 130 |
- (NSArray *)children { |
... | ... | |
280 | 269 |
if (applyMetadataObjectRequest == nil) { |
281 | 270 |
[[pithosNodeInfoController window] makeFirstResponder:nil]; |
282 | 271 |
if (sharingAccount) { |
283 |
self.applyMetadataObjectRequest = [ASIPithosObjectRequest updateObjectMetadataRequestWithPithos:pithos |
|
272 |
self.applyMetadataObjectRequest = [ASIPithosObjectRequest updateObjectMetadataRequestWithPithos:pithosAccountManager.pithos
|
|
284 | 273 |
containerName:pithosContainer.name |
285 | 274 |
objectName:pithosObject.name |
286 | 275 |
contentEncoding:nil |
... | ... | |
290 | 279 |
isPublic:(isPublic ? ASIPithosObjectRequestPublicTrue : ASIPithosObjectRequestPublicFalse) |
291 | 280 |
metadata:pithosObject.metadata |
292 | 281 |
update:NO]; |
293 |
[applyMetadataObjectRequest setRequestUserFromDefaultTo:sharingAccount withPithos:pithos]; |
|
282 |
[applyMetadataObjectRequest setRequestUserFromDefaultTo:sharingAccount withPithos:pithosAccountManager.pithos];
|
|
294 | 283 |
} else { |
295 | 284 |
NSMutableArray *permissions = [NSMutableArray array]; |
296 | 285 |
if (translatedPermissions.count) { |
... | ... | |
410 | 399 |
} |
411 | 400 |
pithosObject.permissions = permissions; |
412 | 401 |
|
413 |
self.applyMetadataObjectRequest = [ASIPithosObjectRequest updateObjectMetadataRequestWithPithos:pithos |
|
402 |
self.applyMetadataObjectRequest = [ASIPithosObjectRequest updateObjectMetadataRequestWithPithos:pithosAccountManager.pithos
|
|
414 | 403 |
containerName:pithosContainer.name |
415 | 404 |
objectName:pithosObject.name |
416 | 405 |
contentEncoding:pithosObject.contentEncoding |
... | ... | |
438 | 427 |
- (void)refreshInfo { |
439 | 428 |
@synchronized(self) { |
440 | 429 |
if (refreshMetadataObjectRequest == nil) { |
441 |
self.refreshMetadataObjectRequest = [ASIPithosObjectRequest objectMetadataRequestWithPithos:pithos |
|
430 |
self.refreshMetadataObjectRequest = [ASIPithosObjectRequest objectMetadataRequestWithPithos:pithosAccountManager.pithos
|
|
442 | 431 |
containerName:pithosContainer.name |
443 | 432 |
objectName:pithosObject.name]; |
444 | 433 |
if (sharingAccount) |
445 |
[refreshMetadataObjectRequest setRequestUserFromDefaultTo:sharingAccount withPithos:pithos]; |
|
434 |
[refreshMetadataObjectRequest setRequestUserFromDefaultTo:sharingAccount withPithos:pithosAccountManager.pithos];
|
|
446 | 435 |
refreshMetadataObjectRequest.delegate = self; |
447 | 436 |
refreshMetadataObjectRequest.didFinishSelector = @selector(performRequestFinishedDelegateInBackground:); |
448 | 437 |
refreshMetadataObjectRequest.didFailSelector = @selector(performRequestFailedDelegateInBackground:); |
... | ... | |
466 | 455 |
- (void)refreshVersions { |
467 | 456 |
@synchronized(self) { |
468 | 457 |
if (refreshVersionsObjectRequest == nil) { |
469 |
self.refreshVersionsObjectRequest = [ASIPithosObjectRequest objectVersionsRequestWithPithos:pithos |
|
458 |
self.refreshVersionsObjectRequest = [ASIPithosObjectRequest objectVersionsRequestWithPithos:pithosAccountManager.pithos
|
|
470 | 459 |
containerName:pithosContainer.name |
471 | 460 |
objectName:pithosObject.name]; |
472 | 461 |
if (sharingAccount) |
473 |
[refreshVersionsObjectRequest setRequestUserFromDefaultTo:sharingAccount withPithos:pithos]; |
|
462 |
[refreshVersionsObjectRequest setRequestUserFromDefaultTo:sharingAccount withPithos:pithosAccountManager.pithos];
|
|
474 | 463 |
refreshVersionsObjectRequest.delegate = self; |
475 | 464 |
refreshVersionsObjectRequest.didFinishSelector = @selector(performRequestFinishedDelegateInBackground:); |
476 | 465 |
refreshVersionsObjectRequest.didFailSelector = @selector(performRequestFailedDelegateInBackground:); |
b/pithos-macos/PithosPreferencesController.h | ||
---|---|---|
2 | 2 |
// PithosPreferencesController.h |
3 | 3 |
// pithos-macos |
4 | 4 |
// |
5 |
// Copyright 2011-2012 GRNET S.A. All rights reserved.
|
|
5 |
// Copyright 2011-2013 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 |
b/pithos-macos/PithosPreferencesController.m | ||
---|---|---|
2 | 2 |
// PithosPreferencesController.m |
3 | 3 |
// pithos-macos |
4 | 4 |
// |
5 |
// Copyright 2011-2012 GRNET S.A. All rights reserved.
|
|
5 |
// Copyright 2011-2013 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 |
... | ... | |
332 | 332 |
return; |
333 | 333 |
} else { |
334 | 334 |
[tmpPithosAccount updateServicesFromServiceCatalogRequest:serviceCatalogRequest]; |
335 |
self.authURLString = tmpPithosAccount.authURLString; |
|
335 | 336 |
self.manual = tmpPithosAccount.manual; |
336 | 337 |
self.pithosObjectStoreURLString = tmpPithosAccount.pithosObjectStoreURLString; |
337 | 338 |
self.astakosAccountURLString = tmpPithosAccount.astakosAccountURLString; |
... | ... | |
366 | 367 |
return; |
367 | 368 |
} else { |
368 | 369 |
[tmpPithosAccount updateServicesFromServiceCatalogRequest:serviceCatalogRequest]; |
370 |
self.authURLString = tmpPithosAccount.authURLString; |
|
369 | 371 |
self.manual = tmpPithosAccount.manual; |
370 | 372 |
self.pithosObjectStoreURLString = tmpPithosAccount.pithosObjectStoreURLString; |
371 | 373 |
self.astakosAccountURLString = tmpPithosAccount.astakosAccountURLString; |
... | ... | |
407 | 409 |
authToken:authToken |
408 | 410 |
authUser:authUser |
409 | 411 |
ignoreSSLErrors:ignoreSSLErrors]; |
412 |
self.pithosObjectStoreURLString = selectedPithosAccount.pithosObjectStoreURLString; |
|
413 |
self.astakosAccountURLString = selectedPithosAccount.astakosAccountURLString; |
|
414 |
self.astakosWebloginURLString = selectedPithosAccount.astakosWebloginURLString; |
|
410 | 415 |
self.displayname = [selectedPithosAccount displaynameForUUID:authUser safe:NO]; |
411 | 416 |
[self updateAuthorization]; |
412 | 417 |
} |
... | ... | |
418 | 423 |
[delegate showPithosBrowser:self]; |
419 | 424 |
} |
420 | 425 |
if ([selectedPithosAccount isEqualTo:delegate.currentPithosAccount]) |
421 |
delegate.pithosBrowserController.pithos = selectedPithosAccount.pithos;
|
|
426 |
delegate.pithosBrowserController.pithosAccountManager = selectedPithosAccount;
|
|
422 | 427 |
} |
423 | 428 |
|
424 | 429 |
- (IBAction)authorizationCancel:(id)server { |
b/pithos-macos/PithosSharingAccountsNode.h | ||
---|---|---|
2 | 2 |
// PithosSharingAccountsNode.h |
3 | 3 |
// pithos-macos |
4 | 4 |
// |
5 |
// Copyright 2011-2012 GRNET S.A. All rights reserved.
|
|
5 |
// Copyright 2011-2013 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 "PithosNode.h" |
39 | 39 |
@class ASIPithosRequest; |
40 |
@class ASIPithos; |
|
41 | 40 |
|
42 | 41 |
@interface PithosSharingAccountsNode : PithosNode { |
43 |
ASIPithos *pithos; |
|
44 |
|
|
45 | 42 |
ASIPithosRequest *sharingAccountsRequest; |
46 |
|
|
47 |
BOOL reset; |
|
48 | 43 |
} |
49 | 44 |
|
50 |
@property(nonatomic, strong) ASIPithos *pithos; |
|
51 | 45 |
@property(nonatomic, strong) ASIPithosRequest *sharingAccountsRequest; |
52 | 46 |
|
53 |
- (id)initWithPithosAccountManager:(PithosAccount *)aPithosAccountManager andPithos:(ASIPithos *)aPithos;
|
|
47 |
- (void)reset;
|
|
54 | 48 |
|
55 | 49 |
@end |
b/pithos-macos/PithosSharingAccountsNode.m | ||
---|---|---|
2 | 2 |
// PithosAccountNode.m |
3 | 3 |
// pithos-macos |
4 | 4 |
// |
5 |
// Copyright 2011-2012 GRNET S.A. All rights reserved.
|
|
5 |
// Copyright 2011-2013 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 |
... | ... | |
46 | 46 |
#import "PithosActivityFacility.h" |
47 | 47 |
|
48 | 48 |
@implementation PithosSharingAccountsNode |
49 |
@synthesize pithos, sharingAccountsRequest;
|
|
49 |
@synthesize sharingAccountsRequest; |
|
50 | 50 |
|
51 | 51 |
#pragma mark - |
52 | 52 |
#pragma mark Object Lifecycle |
53 | 53 |
|
54 |
- (id)initWithPithosAccountManager:(PithosAccount *)aPithosAccountManager andPithos:(ASIPithos *)aPithos {
|
|
54 |
- (id)initWithPithosAccountManager:(PithosAccount *)aPithosAccountManager { |
|
55 | 55 |
if ((self = [super initWithPithosAccountManager:aPithosAccountManager])) { |
56 |
pithos = aPithos; |
|
57 | 56 |
self.sharingAccount = @""; |
58 | 57 |
} |
59 | 58 |
return self; |
... | ... | |
64 | 63 |
} |
65 | 64 |
|
66 | 65 |
#pragma mark - |
67 |
#pragma mark Properties
|
|
66 |
#pragma mark Actions
|
|
68 | 67 |
|
69 |
- (void)setPithos:(ASIPithos *)aPithos { |
|
70 |
if (aPithos && ![aPithos isEqualTo:pithos]) { |
|
71 |
pithos = aPithos; |
|
72 |
url = nil; |
|
73 |
[sharingAccountsRequest clearDelegatesAndCancel]; |
|
74 |
self.sharingAccountsRequest = nil; |
|
75 |
reset = YES; |
|
76 |
} |
|
68 |
- (void)reset { |
|
69 |
[sharingAccountsRequest clearDelegatesAndCancel]; |
|
70 |
self.sharingAccountsRequest = nil; |
|
71 |
children = nil; |
|
72 |
newChildren = nil; |
|
73 |
freshness = PithosNodeStateRefreshNeeded; |
|
74 |
forcedRefresh = YES; |
|
75 |
[self postChildrenUpdatedNotificationName]; |
|
76 |
[self children]; |
|
77 | 77 |
} |
78 | 78 |
|
79 |
#pragma mark - |
|
80 |
#pragma mark Properties |
|
81 |
|
|
79 | 82 |
- (NSString *)url { |
80 |
if (url == nil) |
|
81 |
url = [[pithos.storageURLPrefix description] copy]; |
|
82 |
return url; |
|
83 |
return @"@sharing accounts@"; |
|
83 | 84 |
} |
84 | 85 |
|
85 | 86 |
- (NSArray *)children { |
86 | 87 |
@synchronized(self) { |
87 |
if (reset) { |
|
88 |
[sharingAccountsRequest clearDelegatesAndCancel]; |
|
89 |
self.sharingAccountsRequest = nil; |
|
90 |
children = nil; |
|
91 |
newChildren = nil; |
|
92 |
freshness = PithosNodeStateRefreshNeeded; |
|
93 |
forcedRefresh = YES; |
|
94 |
reset = NO; |
|
95 |
[self postChildrenUpdatedNotificationName]; |
|
96 |
} |
|
97 | 88 |
switch (freshness) { |
98 | 89 |
case PithosNodeStateFresh: |
99 | 90 |
break; |
100 | 91 |
case PithosNodeStateRefreshNeeded: |
101 | 92 |
freshness = PithosNodeStateRefreshing; |
102 |
self.sharingAccountsRequest = [ASIPithosRequest listSharingAccountsRequestWithPithos:pithos limit:0 marker:nil]; |
|
93 |
self.sharingAccountsRequest = [ASIPithosRequest listSharingAccountsRequestWithPithos:pithosAccountManager.pithos limit:0 marker:nil];
|
|
103 | 94 |
sharingAccountsRequest.delegate = self; |
104 | 95 |
sharingAccountsRequest.didFinishSelector = @selector(performRequestFinishedDelegateInBackground:); |
105 | 96 |
sharingAccountsRequest.didFailSelector = @selector(performRequestFailedDelegateInBackground:); |
... | ... | |
186 | 177 |
newChildren = [[NSMutableArray alloc] init]; |
187 | 178 |
NSMutableIndexSet *keptNodes = [NSMutableIndexSet indexSet]; |
188 | 179 |
for (ASIPithosAccount *account in sharingAccounts) { |
189 |
if (![account.name isEqualToString:pithos.authUser]) { |
|
190 |
PithosAccountNode *node = [[PithosAccountNode alloc] initWithPithosAccountManager:pithosAccountManager |
|
191 |
andPithos:pithos]; |
|
180 |
if (![account.name isEqualToString:pithosAccountManager.pithos.authUser]) { |
|
181 |
PithosAccountNode *node = [[PithosAccountNode alloc] initWithPithosAccountManager:pithosAccountManager]; |
|
192 | 182 |
node.parent = self; |
193 | 183 |
node.shared = shared; |
194 | 184 |
node.sharingAccount = account.name; |
... | ... | |
226 | 216 |
[self postChildrenUpdatedNotificationName]; |
227 | 217 |
} else { |
228 | 218 |
// Do an additional request to fetch more objects |
229 |
self.sharingAccountsRequest = [ASIPithosRequest listSharingAccountsRequestWithPithos:pithos |
|
219 |
self.sharingAccountsRequest = [ASIPithosRequest listSharingAccountsRequestWithPithos:pithosAccountManager.pithos
|
|
230 | 220 |
limit:0 |
231 | 221 |
marker:[[someSharingAccounts lastObject] name]]; |
232 | 222 |
sharingAccountsRequest.delegate = self; |
b/pithos-macos/PithosSubdirNode.h | ||
---|---|---|
2 | 2 |
// PithosSubdirNode.h |
3 | 3 |
// pithos-macos |
4 | 4 |
// |
5 |
// Copyright 2011-2012 GRNET S.A. All rights reserved.
|
|
5 |
// Copyright 2011-2013 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 |
... | ... | |
55 | 55 |
} |
56 | 56 |
|
57 | 57 |
- (id)initWithPithosAccountManager:(PithosAccount *)aPithosAccountManager |
58 |
andPithos:(ASIPithos *)aPithos |
|
59 | 58 |
pithosContainer:(ASIPithosContainer *)aPithosContainer |
60 | 59 |
pithosObject:(ASIPithosObject *)aPithosObject; |
61 | 60 |
|
b/pithos-macos/PithosSubdirNode.m | ||
---|---|---|
2 | 2 |
// PithosSubdirNode.m |
3 | 3 |
// pithos-macos |
4 | 4 |
// |
5 |
// Copyright 2011-2012 GRNET S.A. All rights reserved.
|
|
5 |
// Copyright 2011-2013 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 |
... | ... | |
63 | 63 |
#pragma mark Object Lifecycle |
64 | 64 |
|
65 | 65 |
- (id)initWithPithosAccountManager:(PithosAccount *)aPithosAccountManager |
66 |
andPithos:(ASIPithos *)aPithos |
|
67 | 66 |
pithosContainer:(ASIPithosContainer *)aPithosContainer |
68 | 67 |
pithosObject:(ASIPithosObject *)aPithosObject { |
69 | 68 |
if ((self = [super initWithPithosAccountManager:aPithosAccountManager])) { |
70 |
pithos = aPithos; |
|
71 | 69 |
refreshParent = NO; |
Also available in: Unified diff