Revision fb27f368 pithos-macos/PithosSubdirNode.m
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; |
72 | 70 |
self.pithosContainer = aPithosContainer; |
73 | 71 |
self.pithosObject = aPithosObject; |
... | ... | |
129 | 127 |
#pragma mark - |
130 | 128 |
#pragma mark Properties |
131 | 129 |
|
132 |
- (void)setPithos:(ASIPithos *)aPithos { |
|
133 |
if (aPithos && ![aPithos isEqualTo:pithos]) { |
|
134 |
pithos = aPithos; |
|
135 |
url = nil; |
|
136 |
} |
|
137 |
} |
|
138 | 130 |
|
139 | 131 |
- (NSString *)url { |
140 |
if (url == nil) |
|
141 |
url = [[NSString alloc] initWithFormat:@"subdir %@/%@/%@%@", |
|
142 |
(sharingAccount ? [pithos storageURLWithAuthUser:sharingAccount] : pithos.storageURL), |
|
143 |
pithosContainer.name, |
|
144 |
prefix, |
|
145 |
(shared ? @"?shared" : @"")]; |
|
146 |
return url; |
|
132 |
return [NSString stringWithFormat:@"@subdir@%@/%@/%@%@", |
|
133 |
(sharingAccount ? sharingAccount : pithosAccountManager.pithos.authUser), |
|
134 |
pithosContainer.name, |
|
135 |
prefix, |
|
136 |
(shared ? @"?shared" : @"")]; |
|
147 | 137 |
} |
148 | 138 |
|
149 | 139 |
- (NSString *)displayName { |
... | ... | |
297 | 287 |
if (pithosObject.subdir) { |
298 | 288 |
BOOL createObject = NO; |
299 | 289 |
NSAlert *alert; |
300 |
ASIPithosObjectRequest *request = [ASIPithosObjectRequest objectMetadataRequestWithPithos:pithos |
|
290 |
ASIPithosObjectRequest *request = [ASIPithosObjectRequest objectMetadataRequestWithPithos:pithosAccountManager.pithos
|
|
301 | 291 |
containerName:pithosContainer.name |
302 | 292 |
objectName:prefix]; |
303 | 293 |
[PithosUtilities startAndWaitForRequest:request]; |
... | ... | |
312 | 302 |
[alert addButtonWithTitle:@"Cancel"]; |
313 | 303 |
NSInteger choice = [alert runModal]; |
314 | 304 |
if (choice == NSAlertFirstButtonReturn) { |
315 |
request = [ASIPithosObjectRequest deleteObjectRequestWithPithos:pithos |
|
305 |
request = [ASIPithosObjectRequest deleteObjectRequestWithPithos:pithosAccountManager.pithos
|
|
316 | 306 |
containerName:pithosContainer.name |
317 | 307 |
objectName:prefix]; |
318 | 308 |
[PithosUtilities startAndWaitForRequest:request]; |
... | ... | |
454 | 444 |
} |
455 | 445 |
pithosObject.permissions = permissions; |
456 | 446 |
|
457 |
self.applyMetadataObjectRequest = [ASIPithosObjectRequest writeObjectDataRequestWithPithos:pithos |
|
447 |
self.applyMetadataObjectRequest = [ASIPithosObjectRequest writeObjectDataRequestWithPithos:pithosAccountManager.pithos
|
|
458 | 448 |
containerName:pithosContainer.name |
459 | 449 |
objectName:prefix |
460 | 450 |
eTag:nil |
... | ... | |
481 | 471 |
} else { |
482 | 472 |
[[pithosNodeInfoController window] makeFirstResponder:nil]; |
483 | 473 |
if (sharingAccount) { |
484 |
self.applyMetadataObjectRequest = [ASIPithosObjectRequest updateObjectMetadataRequestWithPithos:pithos |
|
474 |
self.applyMetadataObjectRequest = [ASIPithosObjectRequest updateObjectMetadataRequestWithPithos:pithosAccountManager.pithos
|
|
485 | 475 |
containerName:pithosContainer.name |
486 | 476 |
objectName:pithosObject.name |
487 | 477 |
contentEncoding:nil |
... | ... | |
491 | 481 |
isPublic:(isPublic ? ASIPithosObjectRequestPublicTrue : ASIPithosObjectRequestPublicFalse) |
492 | 482 |
metadata:pithosObject.metadata |
493 | 483 |
update:NO]; |
494 |
[applyMetadataObjectRequest setRequestUserFromDefaultTo:sharingAccount withPithos:pithos]; |
|
484 |
[applyMetadataObjectRequest setRequestUserFromDefaultTo:sharingAccount withPithos:pithosAccountManager.pithos];
|
|
495 | 485 |
} else { |
496 | 486 |
NSMutableArray *permissions = [NSMutableArray array]; |
497 | 487 |
if (translatedPermissions.count) { |
... | ... | |
611 | 601 |
} |
612 | 602 |
pithosObject.permissions = permissions; |
613 | 603 |
|
614 |
self.applyMetadataObjectRequest = [ASIPithosObjectRequest updateObjectMetadataRequestWithPithos:pithos |
|
604 |
self.applyMetadataObjectRequest = [ASIPithosObjectRequest updateObjectMetadataRequestWithPithos:pithosAccountManager.pithos
|
|
615 | 605 |
containerName:pithosContainer.name |
616 | 606 |
objectName:pithosObject.name |
617 | 607 |
contentEncoding:pithosObject.contentEncoding |
... | ... | |
643 | 633 |
self.pithosObject = [ASIPithosObject subdirWithName:pithosObject.name]; |
644 | 634 |
return; |
645 | 635 |
} else if (refreshMetadataObjectRequest == nil) { |
646 |
self.refreshMetadataObjectRequest = [ASIPithosObjectRequest objectMetadataRequestWithPithos:pithos |
|
636 |
self.refreshMetadataObjectRequest = [ASIPithosObjectRequest objectMetadataRequestWithPithos:pithosAccountManager.pithos
|
|
647 | 637 |
containerName:pithosContainer.name |
648 | 638 |
objectName:prefix]; |
649 | 639 |
if (sharingAccount) |
650 |
[refreshMetadataObjectRequest setRequestUserFromDefaultTo:sharingAccount withPithos:pithos]; |
|
640 |
[refreshMetadataObjectRequest setRequestUserFromDefaultTo:sharingAccount withPithos:pithosAccountManager.pithos];
|
|
651 | 641 |
refreshMetadataObjectRequest.delegate = self; |
652 | 642 |
refreshMetadataObjectRequest.didFinishSelector = @selector(performRequestFinishedDelegateInBackground:); |
653 | 643 |
refreshMetadataObjectRequest.didFailSelector = @selector(performRequestFailedDelegateInBackground:); |
... | ... | |
673 | 663 |
if (pithosObject.subdir) { |
674 | 664 |
return; |
675 | 665 |
} else if (refreshVersionsObjectRequest == nil) { |
676 |
self.refreshVersionsObjectRequest = [ASIPithosObjectRequest objectVersionsRequestWithPithos:pithos |
|
666 |
self.refreshVersionsObjectRequest = [ASIPithosObjectRequest objectVersionsRequestWithPithos:pithosAccountManager.pithos
|
|
677 | 667 |
containerName:pithosContainer.name |
678 | 668 |
objectName:pithosObject.name]; |
679 | 669 |
if (sharingAccount) |
680 |
[refreshVersionsObjectRequest setRequestUserFromDefaultTo:sharingAccount withPithos:pithos]; |
|
670 |
[refreshVersionsObjectRequest setRequestUserFromDefaultTo:sharingAccount withPithos:pithosAccountManager.pithos];
|
|
681 | 671 |
refreshVersionsObjectRequest.delegate = self; |
682 | 672 |
refreshVersionsObjectRequest.didFinishSelector = @selector(performRequestFinishedDelegateInBackground:); |
683 | 673 |
refreshVersionsObjectRequest.didFailSelector = @selector(performRequestFailedDelegateInBackground:); |
Also available in: Unified diff