Revision 2943d6d4

b/pithos-macos.xcodeproj/project.pbxproj
51 51
		6152D095143334E000803874 /* SharingAccountBoolTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = 6152D094143334E000803874 /* SharingAccountBoolTransformer.m */; };
52 52
		6154BF4B145554D600EE353A /* pithos-logo-small.png in Resources */ = {isa = PBXBuildFile; fileRef = 6154BF4A145554D600EE353A /* pithos-logo-small.png */; };
53 53
		6154BF4D145558E300EE353A /* pithos.icns in Resources */ = {isa = PBXBuildFile; fileRef = 6154BF4C145558E300EE353A /* pithos.icns */; };
54
		6154BF501456A83200EE353A /* UsingSizeTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = 6154BF4F1456A83100EE353A /* UsingSizeTransformer.m */; };
54 55
		615615DD140CECDB00017BD4 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 615615DC140CECDB00017BD4 /* libz.dylib */; };
55 56
		615A444E140F8A5700308614 /* MetadataKeyTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = 615A444D140F8A5700308614 /* MetadataKeyTransformer.m */; };
56 57
		615A4451140F8A7F00308614 /* MetadataKeyFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = 615A4450140F8A7F00308614 /* MetadataKeyFormatter.m */; };
......
164 165
		6152D094143334E000803874 /* SharingAccountBoolTransformer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SharingAccountBoolTransformer.m; path = "pithos-macos/SharingAccountBoolTransformer.m"; sourceTree = "<group>"; };
165 166
		6154BF4A145554D600EE353A /* pithos-logo-small.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "pithos-logo-small.png"; sourceTree = "<group>"; };
166 167
		6154BF4C145558E300EE353A /* pithos.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = pithos.icns; path = ../pithos.icns; sourceTree = "<group>"; };
168
		6154BF4E1456A83100EE353A /* UsingSizeTransformer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UsingSizeTransformer.h; path = "pithos-macos/UsingSizeTransformer.h"; sourceTree = "<group>"; };
169
		6154BF4F1456A83100EE353A /* UsingSizeTransformer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = UsingSizeTransformer.m; path = "pithos-macos/UsingSizeTransformer.m"; sourceTree = "<group>"; };
167 170
		615615DC140CECDB00017BD4 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
168 171
		615A444C140F8A5700308614 /* MetadataKeyTransformer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MetadataKeyTransformer.h; path = "pithos-macos/MetadataKeyTransformer.h"; sourceTree = "<group>"; };
169 172
		615A444D140F8A5700308614 /* MetadataKeyTransformer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MetadataKeyTransformer.m; path = "pithos-macos/MetadataKeyTransformer.m"; sourceTree = "<group>"; };
......
419 422
				613629B4143E0F8B00363787 /* GroupMembersDictionaryTransformer.m */,
420 423
				6164B2DB1450E55C00D4C1AB /* LastCompletedSyncTransformer.h */,
421 424
				6164B2DC1450E55C00D4C1AB /* LastCompletedSyncTransformer.m */,
425
				6154BF4E1456A83100EE353A /* UsingSizeTransformer.h */,
426
				6154BF4F1456A83100EE353A /* UsingSizeTransformer.m */,
422 427
			);
423 428
			name = "Value Transformers";
424 429
			sourceTree = "<group>";
......
630 635
				61F04132144DB97200A0C788 /* PithosLocalObjectState.m in Sources */,
631 636
				61F04133144DB97600A0C788 /* PithosSyncDaemon.m in Sources */,
632 637
				6164B2DD1450E55C00D4C1AB /* LastCompletedSyncTransformer.m in Sources */,
638
				6154BF501456A83200EE353A /* UsingSizeTransformer.m in Sources */,
633 639
			);
634 640
			runOnlyForDeploymentPostprocessing = 0;
635 641
		};
b/pithos-macos/PithosBrowserController.h
73 73
    NSTextField *activityTextField;
74 74
    NSProgressIndicator *activityProgressIndicator;
75 75
    PithosActivityFacility *activityFacility;
76
    
77
    NSTimer *refreshTimer;
76 78
}
77 79

  
78
@property (nonatomic, readonly) PithosAccountNode *accountNode;
80
@property (nonatomic, retain) PithosAccountNode *accountNode;
79 81

  
80 82
@property (nonatomic, assign) IBOutlet NSSplitView *verticalSplitView;
81 83
@property (nonatomic, assign) IBOutlet NSSplitView *horizontalSplitView;
b/pithos-macos/PithosBrowserController.m
52 52
#import "ASIPithosContainer.h"
53 53
#import "ASIPithosObject.h"
54 54
#import "PithosUtilities.h"
55
#import "BytesSizeTransformer.h"
55
#import "UsingSizeTransformer.h"
56 56

  
57 57
@interface PithosBrowserCell : FileSystemBrowserCell {}
58 58
@end
......
120 120

  
121 121
- (void)dealloc {
122 122
    [[NSNotificationCenter defaultCenter] removeObserver:self];
123
    [refreshTimer invalidate];
124
    [refreshTimer release];
123 125
    [clipboardParentNode release];
124 126
    [clipboardNodes release];
125 127
    [draggedParentNode release];
......
150 152
}
151 153

  
152 154
- (void)resetContainers:(NSNotification *)notification {
155
    [refreshTimer invalidate];
156
    [refreshTimer release];
157
    
153 158
    rootNode = nil;
154 159
    [browser loadColumnZero];
155 160
    [containersNodeChildren removeAllObjects];
......
164 169
    [othersSharedNode refresh];
165 170
    
166 171
    [activityFacility reset];
172
    
173
    refreshTimer = [[NSTimer scheduledTimerWithTimeInterval:30 target:self selector:@selector(forceRefresh:) userInfo:self repeats:YES] retain];
167 174
}
168 175

  
169 176
- (void)windowDidLoad {
......
175 182
    activityFacility = [PithosActivityFacility defaultPithosActivityFacility];
176 183
    activityFacility.delegate = self;
177 184
    
178
    accountNode = [[PithosAccountNode alloc] init];
185
    self.accountNode = [[[PithosAccountNode alloc] init] autorelease];
179 186
    containersNode = [[PithosEmptyNode alloc] initWithDisplayName:@"CONTAINERS" icon:nil];
180 187
    containersNodeChildren = [[NSMutableArray alloc] init];
181 188
    sharedNode = [[PithosEmptyNode alloc] initWithDisplayName:@"SHARED" icon:nil];
......
2064 2071
    }
2065 2072
    
2066 2073
    if (!message)
2067
        message = [NSString stringWithFormat:@"%@ used", 
2068
                   [[[[BytesSizeTransformer alloc] init] autorelease] transformedValue: 
2069
                    [NSNumber numberWithUnsignedInteger:accountNode.pithosAccount.bytesUsed]]];
2074
        message = [[[[UsingSizeTransformer alloc] init] autorelease] transformedValue:accountNode.pithosAccount];
2070 2075
    [activityTextField setStringValue:message];
2071 2076
}
2072 2077

  
b/pithos-macos/PithosSyncDaemon.m
576 576
                                      nil];
577 577
            [objectRequest setBytesReceivedBlock:^(unsigned long long size, unsigned long long total){
578 578
                [activityFacility updateActivity:activity 
579
                                     withMessage:[NSString stringWithFormat:@"Downloading '%@' (%.0f%%)", 
579
                                     withMessage:[NSString stringWithFormat:@"Sync: Downloading '%@' (%.0f%%)", 
580 580
                                                  [[objectRequest.userInfo valueForKey:@"pithosObject"] name], 
581 581
                                                  (100*(activity.currentBytes + size + 0.0)/(activity.totalBytes + 0.0))] 
582 582
                                      totalBytes:activity.totalBytes 
......
1130 1130
                [(NSMutableDictionary *)(newObjectRequest.userInfo) setObject:[NSNumber numberWithUnsignedInteger:10] forKey:@"retries"];
1131 1131
                [newObjectRequest setBytesReceivedBlock:^(unsigned long long size, unsigned long long total){
1132 1132
                    [activityFacility updateActivity:activity 
1133
                                         withMessage:[NSString stringWithFormat:@"Downloading '%@' (%.0f%%)", 
1133
                                         withMessage:[NSString stringWithFormat:@"Sync: Downloading '%@' (%.0f%%)", 
1134 1134
                                                      object.name, 
1135 1135
                                                      (100*(activity.currentBytes + size + 0.0)/(activity.totalBytes + 0.0))] 
1136 1136
                                          totalBytes:activity.totalBytes 
......
1198 1198
            [(NSMutableDictionary *)(newObjectRequest.userInfo) setObject:[NSNumber numberWithUnsignedInteger:10] forKey:@"retries"];
1199 1199
            [newObjectRequest setBytesReceivedBlock:^(unsigned long long size, unsigned long long total){
1200 1200
                [activityFacility updateActivity:activity 
1201
                                     withMessage:[NSString stringWithFormat:@"Downloading '%@' (%.0f%%)", 
1201
                                     withMessage:[NSString stringWithFormat:@"Sync: Downloading '%@' (%.0f%%)", 
1202 1202
                                                  object.name, 
1203 1203
                                                  (100*(activity.currentBytes + size + 0.0)/(activity.totalBytes + 0.0))] 
1204 1204
                                      totalBytes:activity.totalBytes 
......
1293 1293
            if (totalBytes >= [missingBlocks count]*blockSize)
1294 1294
                currentBytes = totalBytes - [missingBlocks count]*blockSize;
1295 1295
            [activityFacility updateActivity:activity 
1296
                                 withMessage:[NSString stringWithFormat:@"Uploading '%@' (%.0f%%)", object.name, (100*(currentBytes + 0.0)/(totalBytes + 0.0))] 
1296
                                 withMessage:[NSString stringWithFormat:@"Sync: Uploading '%@' (%.0f%%)", object.name, (100*(currentBytes + 0.0)/(totalBytes + 0.0))] 
1297 1297
                                  totalBytes:totalBytes 
1298 1298
                                currentBytes:currentBytes];
1299 1299
            NSUInteger missingBlockIndex = [missingBlocks firstIndex];
......
1312 1312
            [(NSMutableDictionary *)(newContainerRequest.userInfo) setObject:[NSNumber numberWithUnsignedInteger:missingBlockIndex] forKey:@"missingBlockIndex"];
1313 1313
            [newContainerRequest setBytesSentBlock:^(unsigned long long size, unsigned long long total){
1314 1314
                [activityFacility updateActivity:activity 
1315
                                     withMessage:[NSString stringWithFormat:@"Uploading '%@' (%.0f%%)", object.name, (100*(activity.currentBytes + size + 0.0)/(activity.totalBytes + 0.0))] 
1315
                                     withMessage:[NSString stringWithFormat:@"Sync: Uploading '%@' (%.0f%%)", object.name, (100*(activity.currentBytes + size + 0.0)/(activity.totalBytes + 0.0))] 
1316 1316
                                      totalBytes:activity.totalBytes 
1317 1317
                                    currentBytes:(activity.currentBytes + size)];
1318 1318
            }];
......
1333 1333
        if (currentBytes > totalBytes)
1334 1334
            currentBytes = totalBytes;
1335 1335
        [activityFacility updateActivity:activity 
1336
                             withMessage:[NSString stringWithFormat:@"Uploading '%@' (%.0f%%)", object.name, (100*(currentBytes + 0.0)/(totalBytes + 0.0))] 
1336
                             withMessage:[NSString stringWithFormat:@"Sync: Uploading '%@' (%.0f%%)", object.name, (100*(currentBytes + 0.0)/(totalBytes + 0.0))] 
1337 1337
                              totalBytes:totalBytes 
1338 1338
                            currentBytes:currentBytes];
1339 1339
        NSIndexSet *missingBlocks = [containerRequest.userInfo objectForKey:@"missingBlocks"];
......
1383 1383
                [(NSMutableDictionary *)(newContainerRequest.userInfo) setObject:[NSNumber numberWithUnsignedInteger:missingBlockIndex] forKey:@"missingBlockIndex"];
1384 1384
                [newContainerRequest setBytesSentBlock:^(unsigned long long size, unsigned long long total){
1385 1385
                    [activityFacility updateActivity:activity 
1386
                                         withMessage:[NSString stringWithFormat:@"Uploading '%@' (%.0f%%)", object.name, (100*(activity.currentBytes + size + 0.0)/(activity.totalBytes + 0.0))] 
1386
                                         withMessage:[NSString stringWithFormat:@"Sync: Uploading '%@' (%.0f%%)", object.name, (100*(activity.currentBytes + size + 0.0)/(activity.totalBytes + 0.0))] 
1387 1387
                                          totalBytes:activity.totalBytes 
1388 1388
                                        currentBytes:(activity.currentBytes + size)];
1389 1389
                }];
b/pithos-macos/UsingSizeTransformer.h
1
//
2
//  UsingSizeTransformer.h
3
//  pithos-macos
4
//
5
// Copyright 2011 GRNET S.A. All rights reserved.
6
//
7
// Redistribution and use in source and binary forms, with or
8
// without modification, are permitted provided that the following
9
// conditions are met:
10
// 
11
//   1. Redistributions of source code must retain the above
12
//      copyright notice, this list of conditions and the following
13
//      disclaimer.
14
// 
15
//   2. Redistributions in binary form must reproduce the above
16
//      copyright notice, this list of conditions and the following
17
//      disclaimer in the documentation and/or other materials
18
//      provided with the distribution.
19
// 
20
// THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
21
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
24
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
27
// USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28
// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
// POSSIBILITY OF SUCH DAMAGE.
32
// 
33
// The views and conclusions contained in the software and
34
// documentation are those of the authors and should not be
35
// interpreted as representing official policies, either expressed
36
// or implied, of GRNET S.A.
37

  
38
@interface UsingSizeTransformer : NSValueTransformer
39
@end
b/pithos-macos/UsingSizeTransformer.m
1
//
2
//  UsingSizeTransformer.m
3
//  pithos-macos
4
//
5
// Copyright 2011 GRNET S.A. All rights reserved.
6
//
7
// Redistribution and use in source and binary forms, with or
8
// without modification, are permitted provided that the following
9
// conditions are met:
10
// 
11
//   1. Redistributions of source code must retain the above
12
//      copyright notice, this list of conditions and the following
13
//      disclaimer.
14
// 
15
//   2. Redistributions in binary form must reproduce the above
16
//      copyright notice, this list of conditions and the following
17
//      disclaimer in the documentation and/or other materials
18
//      provided with the distribution.
19
// 
20
// THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
21
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
24
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
27
// USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28
// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
// POSSIBILITY OF SUCH DAMAGE.
32
// 
33
// The views and conclusions contained in the software and
34
// documentation are those of the authors and should not be
35
// interpreted as representing official policies, either expressed
36
// or implied, of GRNET S.A.
37

  
38
#import "UsingSizeTransformer.h"
39
#import "ASIPithosAccount.h"
40
#import "BytesSizeTransformer.h"
41

  
42
@implementation UsingSizeTransformer
43

  
44
+ (Class)transformedValueClass {
45
	return [NSString class];
46
}
47

  
48
+ (BOOL)allowsReverseTransformation {
49
	return NO;
50
}
51

  
52
- (id)transformedValue:(id)value {
53
    if (value == nil)
54
		return @"Using -";
55
    ASIPithosAccount *account = (ASIPithosAccount *)value;
56
    long long policyQuota = (account.policy ? [[account.policy objectForKey:@"quota"] longLongValue] : 0);
57
    BytesSizeTransformer *bytesSizeTransformer = [[[BytesSizeTransformer alloc] init] autorelease];
58
    if (policyQuota > 0)
59
        return [NSString stringWithFormat:@"Using %@ of %@", 
60
                [bytesSizeTransformer transformedValue:[NSNumber numberWithUnsignedInteger:account.bytesUsed]], 
61
                [bytesSizeTransformer transformedValue:[NSNumber numberWithLongLong:policyQuota]]];
62
    else
63
        return [NSString stringWithFormat:@"Using %@", 
64
                [bytesSizeTransformer transformedValue:[NSNumber numberWithUnsignedInteger:account.bytesUsed]]];        
65
}
66

  
67
+ (void)initialize {
68
    [[NSValueTransformer class] setValueTransformer:[self new] forName:@"UsingSizeTransformer"];
69
}
70

  
71
@end
b/pithos-macos/en.lproj/MainMenu.xib
2216 2216
					</object>
2217 2217
					<int key="connectionID">569</int>
2218 2218
				</object>
2219
				<object class="IBConnectionRecord">
2220
					<object class="IBBindingConnection" key="connection">
2221
						<string key="label">enabled: delegate.alwaysNo</string>
2222
						<reference key="source" ref="629835270"/>
2223
						<reference key="destination" ref="1050"/>
2224
						<object class="NSNibBindingConnector" key="connector">
2225
							<reference key="NSSource" ref="629835270"/>
2226
							<reference key="NSDestination" ref="1050"/>
2227
							<string key="NSLabel">enabled: delegate.alwaysNo</string>
2228
							<string key="NSBinding">enabled</string>
2229
							<string key="NSKeyPath">delegate.alwaysNo</string>
2230
							<int key="NSNibBindingConnectorVersion">2</int>
2231
						</object>
2232
					</object>
2233
					<int key="connectionID">570</int>
2234
				</object>
2235
				<object class="IBConnectionRecord">
2236
					<object class="IBBindingConnection" key="connection">
2237
						<string key="label">title: delegate.pithosBrowserController.accountNode.pithosAccount</string>
2238
						<reference key="source" ref="629835270"/>
2239
						<reference key="destination" ref="1050"/>
2240
						<object class="NSNibBindingConnector" key="connector">
2241
							<reference key="NSSource" ref="629835270"/>
2242
							<reference key="NSDestination" ref="1050"/>
2243
							<string key="NSLabel">title: delegate.pithosBrowserController.accountNode.pithosAccount</string>
2244
							<string key="NSBinding">title</string>
2245
							<string key="NSKeyPath">delegate.pithosBrowserController.accountNode.pithosAccount</string>
2246
							<object class="NSDictionary" key="NSOptions">
2247
								<string key="NS.key.0">NSValueTransformerName</string>
2248
								<string key="NS.object.0">UsingSizeTransformer</string>
2249
							</object>
2250
							<int key="NSNibBindingConnectorVersion">2</int>
2251
						</object>
2252
					</object>
2253
					<int key="connectionID">575</int>
2254
				</object>
2219 2255
			</object>
2220 2256
			<object class="IBMutableOrderedSet" key="objectRecords">
2221 2257
				<object class="NSArray" key="orderedObjects">
......
3679 3715
				<reference key="dict.values" ref="0"/>
3680 3716
			</object>
3681 3717
			<nil key="sourceID"/>
3682
			<int key="maxID">569</int>
3718
			<int key="maxID">575</int>
3683 3719
		</object>
3684 3720
		<object class="IBClassDescriber" key="IBDocument.Classes"/>
3685 3721
		<int key="IBDocument.localizationMode">0</int>
b/pithos-macos/pithos_macosAppDelegate.h
79 79
@property (nonatomic, readonly) NSString *syncContainerName;
80 80
@property (nonatomic, assign) NSTimeInterval syncTimeInterval;
81 81

  
82
@property (nonatomic, retain) PithosBrowserController *pithosBrowserController;
82 83
@property (nonatomic, retain) PithosSyncDaemon *pithosSyncDaemon;
83 84
@property (nonatomic, assign) BOOL alwaysNo;
84 85

  
b/pithos-macos/pithos_macosAppDelegate.m
44 44

  
45 45
@implementation pithos_macosAppDelegate
46 46
@synthesize storageURLPrefix, publicURLPrefix, loginURLPrefix, aboutURL;
47
@synthesize syncDirectoryPath, syncContainerName, syncTimeInterval, pithosSyncDaemon, alwaysNo;
47
@synthesize syncDirectoryPath, syncContainerName, syncTimeInterval, pithosBrowserController, pithosSyncDaemon, alwaysNo;
48 48

  
49 49
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
50 50
    NSURL *testURL;
......
237 237
}
238 238

  
239 239
- (void)startSyncWithDirectoryPath:(NSString *)directoryPath containerName:(NSString *)containerName {
240
    self.pithosSyncDaemon = [[PithosSyncDaemon alloc] initWithDirectoryPath:syncDirectoryPath 
241
                                                         containerName:syncContainerName 
242
                                                          timeInterval:syncTimeInterval];
240
    self.pithosSyncDaemon = [[[PithosSyncDaemon alloc] initWithDirectoryPath:syncDirectoryPath 
241
                                                               containerName:syncContainerName 
242
                                                                timeInterval:syncTimeInterval] autorelease];
243 243
}
244 244

  
245 245
@end

Also available in: Unified diff