Revision: 2661
          http://skim-app.svn.sourceforge.net/skim-app/?rev=2661&view=rev
Author:   hofman
Date:     2007-08-14 11:22:41 -0700 (Tue, 14 Aug 2007)

Log Message:
-----------
Make some setters for download object private. Cleanup download when app 
terminates in the download object.

Modified Paths:
--------------
    trunk/SKDownload.h
    trunk/SKDownload.m
    trunk/SKDownloadController.h
    trunk/SKDownloadController.m

Modified: trunk/SKDownload.h
===================================================================
--- trunk/SKDownload.h  2007-08-14 17:50:41 UTC (rev 2660)
+++ trunk/SKDownload.h  2007-08-14 18:22:41 UTC (rev 2661)
@@ -64,18 +64,13 @@
 - (id)delegate;
 - (void)setDelegate:(id)newDelegate;
 
-- (int)status;
-- (void)setStatus:(int)newStatus;
-
 - (NSURL *)URL;
 - (void)setURL:(NSURL *)newURL;
 
+- (int)status;
 - (NSString *)filePath;
-- (void)setFilePath:(NSString *)newFilePath;
-
 - (NSString *)fileName;
 - (NSImage *)fileIcon;
-
 - (long long)expectedContentLength;
 - (long long)receivedContentLength;
 

Modified: trunk/SKDownload.m
===================================================================
--- trunk/SKDownload.m  2007-08-14 17:50:41 UTC (rev 2660)
+++ trunk/SKDownload.m  2007-08-14 18:22:41 UTC (rev 2661)
@@ -40,6 +40,15 @@
 #import <ApplicationServices/ApplicationServices.h>
 
 
[EMAIL PROTECTED] SKDownload (Private)
+- (void)setStatus:(int)newStatus;
+- (void)setFilePath:(NSString *)newFilePath;
+- (void)setExpectedContentLength:(long long)newExpectedContentLength;
+- (void)setReceivedContentLength:(long long)newReceivedContentLength;
+- (void)handleApplicationWillTerminateNotification:(NSNotification 
*)notification;
[EMAIL PROTECTED]
+
+
 @implementation SKDownload
 
 - (id)initWithURL:(NSURL *)aURL delegate:(id)aDelegate {
@@ -56,6 +65,9 @@
         
         if (URL)
             [self startDownload];
+        
+        [[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(handleApplicationWillTerminateNotification:) 
+                                                     
name:NSApplicationWillTerminateNotification object:NSApp];
     }
     return self;
 }
@@ -65,6 +77,7 @@
 }
 
 - (void)dealloc {
+    [[NSNotificationCenter defaultCenter] removeObserver:self];
     [self cleanupDownload];
     [URL release];
     [URLDownload release];
@@ -74,6 +87,10 @@
     [super dealloc];
 }
 
+- (void)handleApplicationWillTerminateNotification:(NSNotification 
*)notification {
+    [self cleanupDownload];
+}
+
 #pragma mark Accessors
 
 - (id)delegate {
@@ -150,7 +167,7 @@
         expectedContentLength = newExpectedContentLength;
         if (expectedContentLength > 0) {
             [progressIndicator setIndeterminate:NO];
-            [progressIndicator setMaxValue:expectedContentLength];
+            [progressIndicator setMaxValue:(double)expectedContentLength];
         } else {
             [progressIndicator setIndeterminate:YES];
             [progressIndicator setMaxValue:1.0];
@@ -181,13 +198,13 @@
         [progressIndicator sizeToFit];
         if (expectedContentLength > 0) {
             [progressIndicator setIndeterminate:NO];
-            [progressIndicator setMaxValue:expectedContentLength];
+            [progressIndicator setMaxValue:(double)expectedContentLength];
+            [progressIndicator setDoubleValue:(double)receivedContentLength];
         } else {
             [progressIndicator setIndeterminate:YES];
             [progressIndicator setMaxValue:1.0];
         }
-        if ([self status] == SKDownloadStatusDownloading)
-            [progressIndicator startAnimation:self];
+        [progressIndicator startAnimation:self];
     }
     return progressIndicator;
 }

Modified: trunk/SKDownloadController.h
===================================================================
--- trunk/SKDownloadController.h        2007-08-14 17:50:41 UTC (rev 2660)
+++ trunk/SKDownloadController.h        2007-08-14 18:22:41 UTC (rev 2661)
@@ -53,6 +53,4 @@
 - (IBAction)removeDownload:(id)sender;
 - (IBAction)cancelDownload:(id)sender;
 
-- (void)handleApplicationWillTerminateNotification:(NSNotification 
*)notification;
-
 @end

Modified: trunk/SKDownloadController.m
===================================================================
--- trunk/SKDownloadController.m        2007-08-14 17:50:41 UTC (rev 2660)
+++ trunk/SKDownloadController.m        2007-08-14 18:22:41 UTC (rev 2661)
@@ -55,8 +55,6 @@
 - (id)init {
     if (self = [super init]) {
         downloads = [[NSMutableArray alloc] init];
-        [[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(handleApplicationWillTerminateNotification:) 
-                                                     
name:NSApplicationWillTerminateNotification object:NSApp];
     }
     return self;
 }
@@ -68,10 +66,6 @@
 
 - (NSString *)windowNibName { return @"DownloadsWindow"; }
 
-- (void)handleApplicationWillTerminateNotification:(NSNotification 
*)notification {
-    [downloads makeObjectsPerformSelector:@selector(cleanupDownload)];
-}
-
 - (void)reloadTableView {
     NSView *view;
     while (view = [[tableView subviews] lastObject])


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Skim-app-commit mailing list
Skim-app-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to