Diff for /chimera/ProgressDlgController.mm between versions 1.4 and 1.8

version 1.4, 2002/02/03 19:40:10 version 1.8, 2002/02/04 02:55:17
Line 8 Line 8
 #import "ProgressDlgController.h"  #import "ProgressDlgController.h"
   #include "nsCOMPtr.h"
   #include "nsString.h"
 #include "nsIWebBrowserPersist.h"  #include "nsIWebBrowserPersist.h"
 #include "nsIInputStream.h"  #include "nsIInputStream.h"
 #include "nsIURL.h"  #include "nsIURL.h"
   #include "nsILocalFile.h"
 #include "nsIDOMDocument.h"  #include "nsIDOMDocument.h"
   #include "nsIWebProgressListener.h"
   #include "nsIComponentManager.h"
   class nsDownloadListener : public nsIWebProgressListener
       nsDownloadListener(ProgressDlgController* aController,
                          nsIWebBrowserPersist* aPersist,
                          nsISupports* aSource,
                          NSString* aDestination,
                          const char* aContentType,
                          nsIInputStream* aPostData,
                          BOOL aBypassCache)
           mController = aController;
           mWebPersist = aPersist;
           // The source is either a simple URL or a complete document.
           mURL = do_QueryInterface(aSource);
           if (!mURL)
               mDocument = do_QueryInterface(aSource);
           nsCAutoString dstStr = [aDestination cString];
           NS_NewLocalFile(dstStr.get(), PR_FALSE, getter_AddRefs(mDestination));
           mContentType = aContentType;
           mPostData = aPostData;
           mBypassCache = aBypassCache;
       virtual ~nsDownloadListener() {};
       void BeginDownload();
   private: // Member variables
       ProgressDlgController* mController; // Controller for our UI.
       nsCOMPtr<nsIWebBrowserPersist> mWebPersist; // Our web persist object.
       nsCOMPtr<nsIURL> mURL; // The URL of our source file. Null if we're saving a complete document.
       nsCOMPtr<nsILocalFile> mDestination; // Our destination URL.
       nsCString mContentType; // Our content type string.
       nsCOMPtr<nsIDOMDocument> mDocument; // A DOM document.  Null if we're only saving a simple URL.
       nsCOMPtr<nsIInputStream> mPostData;  // For complete documents, this is our post data from session history.
       PRBool mBypassCache; // Whether we should bypass the cache or not.
   NS_IMPL_ISUPPORTS1(nsDownloadListener, nsIWebProgressListener)
   /* void onProgressChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in long aCurSelfProgress, in long aMaxSelfProgress, in long aCurTotalProgress, in long aMaxTotalProgress); */
   nsDownloadListener::OnProgressChange(nsIWebProgress *aWebProgress, 
                                            nsIRequest *aRequest, 
                                            PRInt32 aCurSelfProgress, 
                                            PRInt32 aMaxSelfProgress, 
                                            PRInt32 aCurTotalProgress, 
                                            PRInt32 aMaxTotalProgress)
     return NS_OK;
   /* void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI location); */
   nsDownloadListener::OnLocationChange(nsIWebProgress *aWebProgress, 
                                            nsIRequest *aRequest, 
                                            nsIURI *location)
     return NS_OK;
   /* void onStatusChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsresult aStatus, in wstring aMessage); */
   nsDownloadListener::OnStatusChange(nsIWebProgress *aWebProgress, 
                                          nsIRequest *aRequest, 
                                          nsresult aStatus, 
                                          const PRUnichar *aMessage)
     return NS_OK;
   /* void onSecurityChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in long state); */
   nsDownloadListener::OnSecurityChange(nsIWebProgress *aWebProgress, 
                                                         nsIRequest *aRequest, 
                                     PRInt32 state)
     return NS_OK;
   // Implementation of nsIWebProgressListener
   /* void onStateChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in long aStateFlags, in unsigned long aStatus); */
   nsDownloadListener::OnStateChange(nsIWebProgress *aWebProgress, 
                                         nsIRequest *aRequest, 
                                         PRInt32 aStateFlags, 
                                         PRUint32 aStatus)
       return NS_OK;
       if (mWebPersist) {
           PRInt32 flags = nsIWebBrowserPersist::PERSIST_FLAGS_NO_CONVERSION | 
           if (mBypassCache)
               flags |= nsIWebBrowserPersist::PERSIST_FLAGS_BYPASS_CACHE;
               flags |= nsIWebBrowserPersist::PERSIST_FLAGS_FROM_CACHE;
           if (mURL)
               mWebPersist->SaveURI(mURL, mPostData, mDestination);
           else {
 static NSString *SaveFileToolbarIdentifier                      = @"Save File Dialog Toolbar";  static NSString *SaveFileToolbarIdentifier                      = @"Save File Dialog Toolbar";
 static NSString *CancelToolbarItemIdentifier            = @"Cancel Toolbar Item";  static NSString *CancelToolbarItemIdentifier            = @"Cancel Toolbar Item";
Line 32  static NSString *LeaveOpenToolbarItemIde Line 154  static NSString *LeaveOpenToolbarItemIde
         mDownloadIsPaused = NO;  //Get this value from preferences instead of hardcoding NO.          mDownloadIsPaused = NO;  //Get this value from preferences instead of hardcoding NO.
         mSaveFileDialogShouldStayOpen = NO;          mSaveFileDialogShouldStayOpen = NO;
     }      }
       mDownloadListener = nsnull;
     return self;      return self;
 }  }
Line 42  static NSString *LeaveOpenToolbarItemIde Line 167  static NSString *LeaveOpenToolbarItemIde
             postData:(nsIInputStream*)aInputStream              postData:(nsIInputStream*)aInputStream
          bypassCache:(BOOL)aBypassCache           bypassCache:(BOOL)aBypassCache
 {  {
    mDownloadListener = new nsDownloadListener(self, aPersist, aSource,
                                                aDestination, aContentType,
                                                aInputStream, aBypassCache);
 }  }
 - (void)windowDidLoad  - (void)windowDidLoad
 {  {
     [self setupToolbar];      [self setupToolbar];
       if (mDownloadListener)
 }  }
 - (void)setupToolbar  - (void)setupToolbar
Line 153  static NSString *LeaveOpenToolbarItemIde Line 282  static NSString *LeaveOpenToolbarItemIde
 -(void)pauseAndResumeDownload  -(void)pauseAndResumeDownload
 {  {
     if ( ! mDownloadIsPaused ) {      if ( ! mDownloadIsPaused ) {
         //Do logic to pause download          //Do logic to pause download
         mDownloadIsPaused = YES;          mDownloadIsPaused = YES;
Line 169  static NSString *LeaveOpenToolbarItemIde Line 297  static NSString *LeaveOpenToolbarItemIde
         [pauseResumeToggleToolbarItem setToolTip:@"Pause this FTP file download"];          [pauseResumeToggleToolbarItem setToolTip:@"Pause this FTP file download"];
         [pauseResumeToggleToolbarItem setImage:[NSImage imageNamed:@"savePause"]];          [pauseResumeToggleToolbarItem setImage:[NSImage imageNamed:@"savePause"]];
     }      }
 }  }
 -(void)showFile  -(void)showFile
Line 201  static NSString *LeaveOpenToolbarItemIde Line 328  static NSString *LeaveOpenToolbarItemIde
     }      }
 }  }
   - (void)windowWillClose:(NSNotification *)notification
       [self release];
   - (void)dealloc
       delete mDownloadListener;
       mDownloadListener = nsnull;
       [pauseResumeToggleToolbarItem release];
       [leaveOpenToggleToolbarItem release];
       [super dealloc];
 @end  @end

Removed from v.1.4  
changed lines
  Added in v.1.8

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>