From c6f07a3c5b6392b40227630170e1496e2832d95f Mon Sep 17 00:00:00 2001 From: Miltiadis Vasilakis Date: Fri, 2 Sep 2011 12:49:43 +0300 Subject: [PATCH] PublicURL in the object info window can be updated. --- pithos-apple-common | 2 +- pithos-macos.xcodeproj/project.pbxproj | 6 ++ pithos-macos/PithosNodeInfoController.xib | 142 ++++++++++------------------- pithos-macos/PithosObjectNode.h | 3 + pithos-macos/PithosObjectNode.m | 12 ++- pithos-macos/PublicURLTransformer.h | 39 ++++++++ pithos-macos/PublicURLTransformer.m | 62 +++++++++++++ pithos-macos/pithos_macosAppDelegate.h | 6 ++ pithos-macos/pithos_macosAppDelegate.m | 8 +- 9 files changed, 181 insertions(+), 99 deletions(-) create mode 100644 pithos-macos/PublicURLTransformer.h create mode 100644 pithos-macos/PublicURLTransformer.m diff --git a/pithos-apple-common b/pithos-apple-common index be116d2..662d5d9 160000 --- a/pithos-apple-common +++ b/pithos-apple-common @@ -1 +1 @@ -Subproject commit be116d22b7ea1bfe5694dd4edbc3c3538ffcbe1e +Subproject commit 662d5d9ab7db48d7c987589b89194f7ae4807e4d diff --git a/pithos-macos.xcodeproj/project.pbxproj b/pithos-macos.xcodeproj/project.pbxproj index 424d7b8..6c90d2c 100644 --- a/pithos-macos.xcodeproj/project.pbxproj +++ b/pithos-macos.xcodeproj/project.pbxproj @@ -51,6 +51,7 @@ 6180C22E13FBF1FD00BCA40B /* LastModifiedDateTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = 6180C22D13FBF1FD00BCA40B /* LastModifiedDateTransformer.m */; }; 619B85D513F8077800C9371F /* PithosPreferencesController.m in Sources */ = {isa = PBXBuildFile; fileRef = 619B85D313F8077100C9371F /* PithosPreferencesController.m */; }; 619B85D613F8077800C9371F /* PithosPreferencesController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 619B85D413F8077300C9371F /* PithosPreferencesController.xib */; }; + 61C24BBB1410D350007004DC /* PublicURLTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = 61C24BBA1410D350007004DC /* PublicURLTransformer.m */; }; 61E99D9413EC348500E48DA5 /* 145-persondot.png in Resources */ = {isa = PBXBuildFile; fileRef = 61E99D9313EC348500E48DA5 /* 145-persondot.png */; }; /* End PBXBuildFile section */ @@ -140,6 +141,8 @@ 619B85D213F8076F00C9371F /* PithosPreferencesController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PithosPreferencesController.h; sourceTree = ""; }; 619B85D313F8077100C9371F /* PithosPreferencesController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PithosPreferencesController.m; sourceTree = ""; }; 619B85D413F8077300C9371F /* PithosPreferencesController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PithosPreferencesController.xib; sourceTree = ""; }; + 61C24BB91410D350007004DC /* PublicURLTransformer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PublicURLTransformer.h; path = "pithos-macos/PublicURLTransformer.h"; sourceTree = ""; }; + 61C24BBA1410D350007004DC /* PublicURLTransformer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PublicURLTransformer.m; path = "pithos-macos/PublicURLTransformer.m"; sourceTree = ""; }; 61E99D9313EC348500E48DA5 /* 145-persondot.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "145-persondot.png"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -343,6 +346,8 @@ 6180C22D13FBF1FD00BCA40B /* LastModifiedDateTransformer.m */, 615A444C140F8A5700308614 /* MetadataKeyTransformer.h */, 615A444D140F8A5700308614 /* MetadataKeyTransformer.m */, + 61C24BB91410D350007004DC /* PublicURLTransformer.h */, + 61C24BBA1410D350007004DC /* PublicURLTransformer.m */, ); name = "Value Transformers"; sourceTree = ""; @@ -448,6 +453,7 @@ 617460F1140BE45C00D333A1 /* BytesExtendedSizeTransformer.m in Sources */, 615A444E140F8A5700308614 /* MetadataKeyTransformer.m in Sources */, 615A4451140F8A7F00308614 /* MetadataKeyFormatter.m in Sources */, + 61C24BBB1410D350007004DC /* PublicURLTransformer.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/pithos-macos/PithosNodeInfoController.xib b/pithos-macos/PithosNodeInfoController.xib index 85445b3..8933ef8 100644 --- a/pithos-macos/PithosNodeInfoController.xib +++ b/pithos-macos/PithosNodeInfoController.xib @@ -84,7 +84,6 @@ {{10, 473}, {32, 32}} - YES @@ -106,7 +105,6 @@ 270 {{47, 490}, {135, 17}} - YES @@ -144,7 +142,6 @@ 268 {{47, 470}, {60, 17}} - YES @@ -166,7 +163,6 @@ 265 {{178, 490}, {80, 17}} - YES @@ -188,7 +184,6 @@ 268 {{109, 473}, {149, 14}} - YES @@ -206,7 +201,6 @@ 14 {{0, 459}, {265, 5}} - {0, 0} @@ -238,7 +232,6 @@ 268 {{7, 444}, {72, 14}} - YES @@ -257,7 +250,6 @@ 270 {{84, 392}, {174, 14}} - YES @@ -279,7 +271,6 @@ 270 {{84, 422}, {174, 14}} - YES @@ -297,7 +288,6 @@ 270 {{84, 407}, {174, 14}} - YES @@ -315,7 +305,6 @@ 270 {{84, 377}, {174, 14}} - YES @@ -333,7 +322,6 @@ 270 {{84, 362}, {174, 14}} - YES @@ -351,7 +339,6 @@ 270 {{84, 347}, {174, 14}} - YES @@ -369,7 +356,6 @@ 268 {{12, 392}, {72, 14}} - YES @@ -388,7 +374,6 @@ 268 {{12, 422}, {72, 14}} - YES @@ -407,7 +392,6 @@ 268 {{12, 407}, {72, 14}} - YES @@ -426,7 +410,6 @@ 268 {{12, 377}, {72, 14}} - YES @@ -445,7 +428,6 @@ 268 {{12, 362}, {72, 14}} - YES @@ -464,7 +446,6 @@ 268 {{12, 347}, {72, 14}} - YES @@ -483,7 +464,6 @@ 14 {{0, 334}, {265, 5}} - {0, 0} @@ -507,7 +487,6 @@ 268 {{7, 319}, {72, 14}} - YES @@ -536,7 +515,6 @@ 256 {243, 78} - YES @@ -544,7 +522,6 @@ 256 {243, 17} - @@ -553,7 +530,6 @@ -2147483392 {{224, 0}, {16, 17}} - @@ -650,7 +626,6 @@ {{1, 17}, {243, 78}} - @@ -661,7 +636,6 @@ -2147483392 {{224, 17}, {15, 102}} - _doScroller: @@ -673,7 +647,6 @@ -2147483392 {{1, 119}, {223, 15}} - 1 @@ -689,7 +662,6 @@ {{1, 0}, {243, 17}} - @@ -699,7 +671,6 @@ {{10, 215}, {245, 96}} - 562 @@ -714,7 +685,6 @@ 268 {{10, 195}, {18, 18}} - YES @@ -740,7 +710,6 @@ 268 {{27, 195}, {18, 18}} - YES @@ -766,7 +735,6 @@ 14 {{0, 185}, {265, 5}} - {0, 0} @@ -790,7 +758,6 @@ 268 {{7, 170}, {126, 14}} - YES @@ -819,7 +786,6 @@ 256 {243, 78} - YES @@ -827,7 +793,6 @@ 256 {243, 17} - @@ -836,7 +801,6 @@ -2147483392 {{224, 0}, {16, 17}} - @@ -915,7 +879,6 @@ {{1, 17}, {243, 78}} - @@ -926,7 +889,6 @@ -2147483392 {{224, 17}, {15, 102}} - _doScroller: @@ -937,7 +899,6 @@ -2147483392 {{1, 80}, {243, 15}} - 1 @@ -953,7 +914,6 @@ {{1, 0}, {243, 17}} - @@ -963,7 +923,6 @@ {{10, 27}, {245, 96}} - 562 @@ -978,7 +937,6 @@ 268 {{10, 7}, {18, 18}} - YES @@ -1001,7 +959,6 @@ 268 {{27, 7}, {18, 18}} - YES @@ -1024,7 +981,6 @@ 268 {{83, 129}, {61, 18}} - YES @@ -1053,12 +1009,11 @@ 270 {{84, 148}, {174, 14}} - YES - 67239488 - 4196352 + 70385217 + 4195328 Public URL @@ -1071,7 +1026,6 @@ 268 {{12, 148}, {72, 14}} - YES @@ -1090,7 +1044,6 @@ 265 {{193, 5}, {62, 19}} - YES @@ -1116,7 +1069,6 @@ 265 {{123, 5}, {62, 19}} - YES @@ -1136,7 +1088,6 @@ {{7, 11}, {265, 515}} - {{0, 0}, {1280, 778}} @@ -1538,26 +1489,6 @@ - value: node.pithosObject.publicURI - - - - - - value: node.pithosObject.publicURI - value - node.pithosObject.publicURI - - NSNullPlaceholder - - - - 2 - - - 288 - - - value: arrangedObjects.key @@ -1585,6 +1516,51 @@ 289 + + + value: node.isPublic + + + + + + value: node.isPublic + value + node.isPublic + 2 + + + 293 + + + + value: node.pithosObject.publicURI + + + + + + value: node.pithosObject.publicURI + value + node.pithosObject.publicURI + + YES + + YES + NSNullPlaceholder + NSValueTransformerName + + + YES + - + PublicURLTransformer + + + 2 + + + 294 + @@ -2451,29 +2427,9 @@ - 289 - - - - YES - - MetadataKeyFormatter - NSFormatter - - IBProjectSource - ./Classes/MetadataKeyFormatter.h - - - - PithosNodeInfoController - NSWindowController - - IBProjectSource - ./Classes/PithosNodeInfoController.h - - - + 294 + 0 IBCocoaFramework diff --git a/pithos-macos/PithosObjectNode.h b/pithos-macos/PithosObjectNode.h index 7f51202..f90522f 100644 --- a/pithos-macos/PithosObjectNode.h +++ b/pithos-macos/PithosObjectNode.h @@ -46,12 +46,15 @@ ASIPithosObjectRequest *applyMetadataObjectRequest; ASIPithosObjectRequest *refreshMetadataObjectRequest; + + BOOL isPublic; } - (id)initWithPithosContainer:(ASIPithosContainer *)aPithosContainer pithosObject:(ASIPithosObject *)aPithosObject; @property (nonatomic, retain) ASIPithosContainer *pithosContainer; @property (nonatomic, retain) ASIPithosObject *pithosObject; +@property (nonatomic, assign) BOOL isPublic; - (void)applyInfo; - (void)refreshInfo; diff --git a/pithos-macos/PithosObjectNode.m b/pithos-macos/PithosObjectNode.m index f0acf27..aa5481a 100644 --- a/pithos-macos/PithosObjectNode.m +++ b/pithos-macos/PithosObjectNode.m @@ -45,6 +45,7 @@ @implementation PithosObjectNode @synthesize pithosContainer, pithosObject; +@synthesize isPublic; #pragma mark - #pragma mark Object Lifecycle @@ -98,6 +99,14 @@ return icon; } +- (void)setPithosObject:(ASIPithosObject *)aPithosObject { + if (![pithosObject isEqualTo:aPithosObject]) { + [pithosObject release]; + pithosObject = [aPithosObject retain]; + } + self.isPublic = (pithosObject.publicURI != nil); +} + #pragma mark - #pragma mark Info @@ -110,7 +119,7 @@ contentDisposition:nil manifest:nil sharing:nil - isPublic:ASIPithosObjectRequestPublicIgnore + isPublic:(isPublic ? ASIPithosObjectRequestPublicTrue : ASIPithosObjectRequestPublicFalse) metadata:pithosObject.metadata update:NO] retain]; applyMetadataObjectRequest.delegate = self; @@ -131,7 +140,6 @@ } } - #pragma mark - #pragma mark ASIHTTPRequestDelegate diff --git a/pithos-macos/PublicURLTransformer.h b/pithos-macos/PublicURLTransformer.h new file mode 100644 index 0000000..638b777 --- /dev/null +++ b/pithos-macos/PublicURLTransformer.h @@ -0,0 +1,39 @@ +// +// PublicURLTransformer.h +// pithos-macos +// +// Copyright 2011 GRNET S.A. All rights reserved. +// +// Redistribution and use in source and binary forms, with or +// without modification, are permitted provided that the following +// conditions are met: +// +// 1. Redistributions of source code must retain the above +// copyright notice, this list of conditions and the following +// disclaimer. +// +// 2. Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials +// provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS +// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +// USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +// The views and conclusions contained in the software and +// documentation are those of the authors and should not be +// interpreted as representing official policies, either expressed +// or implied, of GRNET S.A. + +@interface PublicURLTransformer : NSValueTransformer +@end diff --git a/pithos-macos/PublicURLTransformer.m b/pithos-macos/PublicURLTransformer.m new file mode 100644 index 0000000..03823a6 --- /dev/null +++ b/pithos-macos/PublicURLTransformer.m @@ -0,0 +1,62 @@ +// +// PublicURLTransformer.m +// pithos-macos +// +// Copyright 2011 GRNET S.A. All rights reserved. +// +// Redistribution and use in source and binary forms, with or +// without modification, are permitted provided that the following +// conditions are met: +// +// 1. Redistributions of source code must retain the above +// copyright notice, this list of conditions and the following +// disclaimer. +// +// 2. Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials +// provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS +// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +// USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +// The views and conclusions contained in the software and +// documentation are those of the authors and should not be +// interpreted as representing official policies, either expressed +// or implied, of GRNET S.A. + +#import "PublicURLTransformer.h" +#import "pithos_macosAppDelegate.h" + +@implementation PublicURLTransformer + ++ (Class)transformedValueClass { + return [NSString class]; +} + ++ (BOOL)allowsReverseTransformation { + return NO; +} + +- (id)transformedValue:(id)value { + if (value == nil) + return nil; + return [[(pithos_macosAppDelegate *)[[NSApplication sharedApplication] delegate] publicURLPrefix] + stringByAppendingString:(NSString *)value]; +} + ++ (void)initialize { + [[NSValueTransformer class] setValueTransformer:[self new] forName:@"PublicURLTransformer"]; +} + +@end diff --git a/pithos-macos/pithos_macosAppDelegate.h b/pithos-macos/pithos_macosAppDelegate.h index 01c26af..cfeb2e2 100644 --- a/pithos-macos/pithos_macosAppDelegate.h +++ b/pithos-macos/pithos_macosAppDelegate.h @@ -47,6 +47,9 @@ NSStatusItem *statusItem; IBOutlet NSUserDefaultsController *userDefaultsController; + + NSString *storageURLPrefix; + NSString *publicURLPrefix; } - (void)handleAppleEvent:(NSAppleEventDescriptor *)event withReplyEvent: (NSAppleEventDescriptor *)replyEvent; @@ -56,4 +59,7 @@ - (void)authenticateWithAuthUser:(NSString *)authUser authToken:(NSString *)authToken; +@property (nonatomic, readonly) NSString *storageURLPrefix; +@property (nonatomic, readonly) NSString *publicURLPrefix; + @end diff --git a/pithos-macos/pithos_macosAppDelegate.m b/pithos-macos/pithos_macosAppDelegate.m index e7e1881..20f065c 100644 --- a/pithos-macos/pithos_macosAppDelegate.m +++ b/pithos-macos/pithos_macosAppDelegate.m @@ -41,8 +41,13 @@ #import "ASIPithosRequest.h" @implementation pithos_macosAppDelegate +@synthesize storageURLPrefix, publicURLPrefix; - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { + // XXX hardcoded for now + storageURLPrefix = @"https://pithos.dev.grnet.gr/v1/"; + publicURLPrefix = @"https://pithos.dev.grnet.gr"; + [[NSAppleEventManager sharedAppleEventManager] setEventHandler:self andSelector:@selector(handleAppleEvent:withReplyEvent:) forEventClass:kInternetEventClass @@ -147,9 +152,6 @@ #pragma Authentication - (void)authenticateWithAuthUser:(NSString *)authUser authToken:(NSString *)authToken { - // XXX hardcoded for now - NSString *storageURLPrefix = @"https://pithos.dev.grnet.gr/v1/"; - NSLog(@"Authentication - storageURLPrefix:%@, authUser:%@, authToken:%@", storageURLPrefix, authUser, authToken); if ([authUser length] && [authToken length]) { [ASIPithosRequest setStorageURL:[storageURLPrefix stringByAppendingString:[authUser stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]]; -- 1.7.10.4