Author: fejj
Date: 2007-12-14 13:10:35 -0500 (Fri, 14 Dec 2007)
New Revision: 91307

Modified:
   trunk/moon/src/ChangeLog
   trunk/moon/src/downloader.cpp
   trunk/moon/src/downloader.h
Log:
2007-12-14  Jeffrey Stedfast  <[EMAIL PROTECTED]>

        * downloader.cpp (Downloader::Abort): Don't abort if we've already
        been aborted or been notified that we've failed (needed protection
        for the Plugin downloader).
        (Downloader::Send): Set aborted = false.
        (Downloader::NotifyFailed): Don't do anything if we've already
        been notified of failure for this download request.

        * downloader.h (class Downloader): Keep track of aborted state as
        well.



Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog    2007-12-14 18:09:06 UTC (rev 91306)
+++ trunk/moon/src/ChangeLog    2007-12-14 18:10:35 UTC (rev 91307)
@@ -1,3 +1,15 @@
+2007-12-14  Jeffrey Stedfast  <[EMAIL PROTECTED]>
+
+       * downloader.cpp (Downloader::Abort): Don't abort if we've already
+       been aborted or been notified that we've failed (needed protection
+       for the Plugin downloader).
+       (Downloader::Send): Set aborted = false.
+       (Downloader::NotifyFailed): Don't do anything if we've already
+       been notified of failure for this download request.
+
+       * downloader.h (class Downloader): Keep track of aborted state as
+       well.
+
 2007-12-14  Stephane Delcroix  <[EMAIL PROTECTED]>
 
        * brush.cpp: Fix for bnc 346204: Set both Width and Height for Image if

Modified: trunk/moon/src/downloader.cpp
===================================================================
--- trunk/moon/src/downloader.cpp       2007-12-14 18:09:06 UTC (rev 91306)
+++ trunk/moon/src/downloader.cpp       2007-12-14 18:10:35 UTC (rev 91307)
@@ -68,6 +68,7 @@
        filename = NULL;
        failed_msg = NULL;
        started = false;
+       aborted = false;
        this->write = NULL;
        file_size = -2;
        total = 0;
@@ -98,7 +99,10 @@
 void
 Downloader::Abort ()
 {
-       abort_func (downloader_state);
+       if (!aborted && !failed_msg) {
+               abort_func (downloader_state);
+               aborted = true;
+       }
 }
 
 void *
@@ -244,16 +248,21 @@
 void
 Downloader::Send ()
 {
-       if (filename != NULL){
+       if (filename != NULL) {
+               // Consumer is re-sending a request which finished successfully.
                NotifyFinished (filename);
                return;
        }
-       if (failed_msg != NULL){
+       
+       if (failed_msg != NULL) {
+               // Consumer is re-sending a request which failed.
                Emit (DownloadFailedEvent, failed_msg);
                return;
        }
-
+       
        started = true;
+       aborted = false;
+       
        send_func (downloader_state);
 }
 
@@ -297,10 +306,18 @@
 void
 Downloader::NotifyFailed (const char *msg)
 {
+       /* if we've already been notified of failure, no-op */
+       if (failed_msg)
+               return;
+       
        // dl->SetValue (Downloader::StatusProperty, Value (400))
        // For some reason the status is 0, not updated on errors?
+       
+       Emit (DownloadFailedEvent, (gpointer) msg);
+       
+       // save the error in case someone else calls ::Send() on this
+       // downloader for the same uri.
        failed_msg = g_strdup (msg);
-       Emit (DownloadFailedEvent, (gpointer) msg);
 }
 
 void
@@ -398,7 +415,7 @@
 {
        if (!dl->Completed () && dl->Started ())
                downloader_abort (dl);
-
+       
        dl->Send ();
 }
 
@@ -408,14 +425,14 @@
        return new Downloader ();
 }
 
-void downloader_set_functions (downloader_create_state_func create_state,
-                              downloader_destroy_state_func destroy_state,
-                              downloader_open_func open,
-                              downloader_send_func send,
-                              downloader_abort_func abort)
+void
+downloader_set_functions (downloader_create_state_func create_state,
+                         downloader_destroy_state_func destroy_state,
+                         downloader_open_func open,
+                         downloader_send_func send,
+                         downloader_abort_func abort)
 {
-       Downloader::SetFunctions (create_state,
-                                 destroy_state,
+       Downloader::SetFunctions (create_state, destroy_state,
                                  open, send, abort, false);
 }
 

Modified: trunk/moon/src/downloader.h
===================================================================
--- trunk/moon/src/downloader.h 2007-12-14 18:09:06 UTC (rev 91306)
+++ trunk/moon/src/downloader.h 2007-12-14 18:10:35 UTC (rev 91307)
@@ -108,7 +108,8 @@
 
        char *filename;
        char *failed_msg;
-       bool  started;
+       bool started;
+       bool aborted;
        
        // Set by the consumer
        downloader_write_func       write;

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to