Loading xpfe/AppCores/src/nsBrowserAppCore.cpp +27 −31 Original line number Diff line number Diff line Loading @@ -766,6 +766,7 @@ struct nsFileDownloadDialog : public nsIXULWindowCallbacks, ~nsFileDownloadDialog() { delete mOutput; delete [] mBuffer; } void OnOK( nsIContent *aContent ); void OnClose(); void OnStart(); void OnStop(); void SetWindow( nsIWebShellWindow *aWindow ); Loading @@ -779,14 +780,9 @@ private: PRUint32 mBufLen; char * mBuffer; PRBool mStopped; static nsIAtom *kIdAtom, *kCommandAtom, *kFileNameAtom; enum { kPrompt, kProgress } mMode; }; // nsFileDownloadDialog nsIAtom *nsFileDownloadDialog::kIdAtom = 0; nsIAtom *nsFileDownloadDialog::kCommandAtom = 0; nsIAtom *nsFileDownloadDialog::kFileNameAtom = 0; // Standard implementations of addref/release. NS_IMPL_ADDREF( nsFileDownloadDialog ); NS_IMPL_RELEASE( nsFileDownloadDialog ); Loading Loading @@ -828,15 +824,6 @@ nsFileDownloadDialog::nsFileDownloadDialog( nsIURL *aURL, const char *aContentTy mMode( kPrompt ) { // Initialize ref count. NS_INIT_REFCNT(); // Initialize static atoms. static PRBool initialized = 0; if ( !initialized ) { kIdAtom = NS_NewAtom("id"); kCommandAtom = NS_NewAtom("command"); kFileNameAtom = NS_NewAtom("filename"); initialized = 1; } } // Do startup stuff from C++ side. Loading @@ -856,18 +843,6 @@ nsFileDownloadDialog::ConstructBeforeJavaScript(nsIWebShell *aWebShell) { // If showing download progress, make target file name known. if ( mMode == kProgress ) { setAttribute( mWebShell, "data.fileName", "value", nsString((const char*)mFileName) ); // Load source stream into file. nsINetService *inet = 0; rv = nsServiceManager::GetService( kNetServiceCID, kINetServiceIID, (nsISupports**)&inet ); if (NS_OK == rv) { rv = inet->OpenStream(mUrl, this); nsServiceManager::ReleaseService(kNetServiceCID, inet); } else { if ( APP_DEBUG ) { printf( "Error getting Net Service, rv=0x%X\n", (int)rv ); } } } // Add as observer of the xul document. Loading Loading @@ -997,19 +972,23 @@ nsFileDownloadDialog::AttributeChanged( nsIDocument *aDocument, nsresult rv = NS_OK; // Look for data.execute command changing. nsString id; aContent->GetAttribute( kNameSpaceID_None, kIdAtom, id ); nsCOMPtr<nsIAtom> atomId = nsDontQueryInterface<nsIAtom>( NS_NewAtom("id") ); aContent->GetAttribute( kNameSpaceID_None, atomId, id ); if ( id == "data.execute" ) { nsString cmd; aContent->GetAttribute( kNameSpaceID_None, kCommandAtom, cmd ); nsCOMPtr<nsIAtom> atomCommand = nsDontQueryInterface<nsIAtom>( NS_NewAtom("command") ); aContent->GetAttribute( kNameSpaceID_None, atomCommand, cmd ); if ( cmd == "ok" ) { OnOK( aContent ); } else if ( cmd == "start" ) { OnStart(); } else if ( cmd == "stop" ) { OnStop(); } else if ( cmd == "close" ) { OnClose(); } else { } aContent->SetAttribute( kNameSpaceID_None, kCommandAtom, "", PR_FALSE ); aContent->SetAttribute( kNameSpaceID_None, atomCommand, "", PR_FALSE ); } return rv; Loading @@ -1021,7 +1000,8 @@ nsFileDownloadDialog::OnOK( nsIContent *aContent ) { // Show progress. if ( mWebShell ) { nsString fileName; aContent->GetAttribute( kNameSpaceID_None, kFileNameAtom, fileName ); nsCOMPtr<nsIAtom> atomFileName = nsDontQueryInterface<nsIAtom>( NS_NewAtom("filename") ); aContent->GetAttribute( kNameSpaceID_None, atomFileName, fileName ); mFileName = fileName; mMode = kProgress; nsString progressXUL = "resource:/res/samples/downloadProgress.xul"; Loading @@ -1029,7 +1009,6 @@ nsFileDownloadDialog::OnOK( nsIContent *aContent ) { } // Open output file stream. mOutput = new nsOutputFileStream( mFileName ); } void Loading @@ -1038,6 +1017,23 @@ nsFileDownloadDialog::OnClose() { closeWindow( mWindow ); } void nsFileDownloadDialog::OnStart() { if ( mMode == kProgress ) { // Load source stream into file. nsINetService *inet = 0; nsresult rv = nsServiceManager::GetService( kNetServiceCID, kINetServiceIID, (nsISupports**)&inet ); if (NS_OK == rv) { rv = inet->OpenStream(mUrl, this); nsServiceManager::ReleaseService(kNetServiceCID, inet); } else { if ( APP_DEBUG ) { printf( "Error getting Net Service, rv=0x%X\n", (int)rv ); } } } } void nsFileDownloadDialog::OnStop() { // Stop the netlib xfer. Loading xpfe/browser/src/downloadProgress.xul +4 −1 Original line number Diff line number Diff line Loading @@ -52,6 +52,9 @@ // Fill dialog. loadDialog(); // Commence. data.execute.setAttribute("command","start"); } function stop() { Loading Loading @@ -195,7 +198,7 @@ <html:tr> <html:td align="center" colspan="2"> <html:button id="dialog.cancel" onclick="stop()" disabled>Cancel</html:button> <html:button id="dialog.cancel" onclick="stop()" disabled="">Cancel</html:button> </html:td> </html:tr> Loading Loading
xpfe/AppCores/src/nsBrowserAppCore.cpp +27 −31 Original line number Diff line number Diff line Loading @@ -766,6 +766,7 @@ struct nsFileDownloadDialog : public nsIXULWindowCallbacks, ~nsFileDownloadDialog() { delete mOutput; delete [] mBuffer; } void OnOK( nsIContent *aContent ); void OnClose(); void OnStart(); void OnStop(); void SetWindow( nsIWebShellWindow *aWindow ); Loading @@ -779,14 +780,9 @@ private: PRUint32 mBufLen; char * mBuffer; PRBool mStopped; static nsIAtom *kIdAtom, *kCommandAtom, *kFileNameAtom; enum { kPrompt, kProgress } mMode; }; // nsFileDownloadDialog nsIAtom *nsFileDownloadDialog::kIdAtom = 0; nsIAtom *nsFileDownloadDialog::kCommandAtom = 0; nsIAtom *nsFileDownloadDialog::kFileNameAtom = 0; // Standard implementations of addref/release. NS_IMPL_ADDREF( nsFileDownloadDialog ); NS_IMPL_RELEASE( nsFileDownloadDialog ); Loading Loading @@ -828,15 +824,6 @@ nsFileDownloadDialog::nsFileDownloadDialog( nsIURL *aURL, const char *aContentTy mMode( kPrompt ) { // Initialize ref count. NS_INIT_REFCNT(); // Initialize static atoms. static PRBool initialized = 0; if ( !initialized ) { kIdAtom = NS_NewAtom("id"); kCommandAtom = NS_NewAtom("command"); kFileNameAtom = NS_NewAtom("filename"); initialized = 1; } } // Do startup stuff from C++ side. Loading @@ -856,18 +843,6 @@ nsFileDownloadDialog::ConstructBeforeJavaScript(nsIWebShell *aWebShell) { // If showing download progress, make target file name known. if ( mMode == kProgress ) { setAttribute( mWebShell, "data.fileName", "value", nsString((const char*)mFileName) ); // Load source stream into file. nsINetService *inet = 0; rv = nsServiceManager::GetService( kNetServiceCID, kINetServiceIID, (nsISupports**)&inet ); if (NS_OK == rv) { rv = inet->OpenStream(mUrl, this); nsServiceManager::ReleaseService(kNetServiceCID, inet); } else { if ( APP_DEBUG ) { printf( "Error getting Net Service, rv=0x%X\n", (int)rv ); } } } // Add as observer of the xul document. Loading Loading @@ -997,19 +972,23 @@ nsFileDownloadDialog::AttributeChanged( nsIDocument *aDocument, nsresult rv = NS_OK; // Look for data.execute command changing. nsString id; aContent->GetAttribute( kNameSpaceID_None, kIdAtom, id ); nsCOMPtr<nsIAtom> atomId = nsDontQueryInterface<nsIAtom>( NS_NewAtom("id") ); aContent->GetAttribute( kNameSpaceID_None, atomId, id ); if ( id == "data.execute" ) { nsString cmd; aContent->GetAttribute( kNameSpaceID_None, kCommandAtom, cmd ); nsCOMPtr<nsIAtom> atomCommand = nsDontQueryInterface<nsIAtom>( NS_NewAtom("command") ); aContent->GetAttribute( kNameSpaceID_None, atomCommand, cmd ); if ( cmd == "ok" ) { OnOK( aContent ); } else if ( cmd == "start" ) { OnStart(); } else if ( cmd == "stop" ) { OnStop(); } else if ( cmd == "close" ) { OnClose(); } else { } aContent->SetAttribute( kNameSpaceID_None, kCommandAtom, "", PR_FALSE ); aContent->SetAttribute( kNameSpaceID_None, atomCommand, "", PR_FALSE ); } return rv; Loading @@ -1021,7 +1000,8 @@ nsFileDownloadDialog::OnOK( nsIContent *aContent ) { // Show progress. if ( mWebShell ) { nsString fileName; aContent->GetAttribute( kNameSpaceID_None, kFileNameAtom, fileName ); nsCOMPtr<nsIAtom> atomFileName = nsDontQueryInterface<nsIAtom>( NS_NewAtom("filename") ); aContent->GetAttribute( kNameSpaceID_None, atomFileName, fileName ); mFileName = fileName; mMode = kProgress; nsString progressXUL = "resource:/res/samples/downloadProgress.xul"; Loading @@ -1029,7 +1009,6 @@ nsFileDownloadDialog::OnOK( nsIContent *aContent ) { } // Open output file stream. mOutput = new nsOutputFileStream( mFileName ); } void Loading @@ -1038,6 +1017,23 @@ nsFileDownloadDialog::OnClose() { closeWindow( mWindow ); } void nsFileDownloadDialog::OnStart() { if ( mMode == kProgress ) { // Load source stream into file. nsINetService *inet = 0; nsresult rv = nsServiceManager::GetService( kNetServiceCID, kINetServiceIID, (nsISupports**)&inet ); if (NS_OK == rv) { rv = inet->OpenStream(mUrl, this); nsServiceManager::ReleaseService(kNetServiceCID, inet); } else { if ( APP_DEBUG ) { printf( "Error getting Net Service, rv=0x%X\n", (int)rv ); } } } } void nsFileDownloadDialog::OnStop() { // Stop the netlib xfer. Loading
xpfe/browser/src/downloadProgress.xul +4 −1 Original line number Diff line number Diff line Loading @@ -52,6 +52,9 @@ // Fill dialog. loadDialog(); // Commence. data.execute.setAttribute("command","start"); } function stop() { Loading Loading @@ -195,7 +198,7 @@ <html:tr> <html:td align="center" colspan="2"> <html:button id="dialog.cancel" onclick="stop()" disabled>Cancel</html:button> <html:button id="dialog.cancel" onclick="stop()" disabled="">Cancel</html:button> </html:td> </html:tr> Loading