diff --git a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp index fe42887bc07..97d03e10781 100644 --- a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -87,8 +87,6 @@ #include "nsObsoleteModuleLoading.h" #include "nsIComponentRegistrar.h" #include "nsPluginLogging.h" -#include "nsDirectoryServiceDefs.h" -#include "nsAppDirectoryServiceDefs.h" // Friggin' X11 has to "#define None". Lame! #ifdef None @@ -142,6 +140,7 @@ #include "nsIDirectoryService.h" #include "nsDirectoryServiceDefs.h" +#include "nsAppDirectoryServiceDefs.h" #include "nsIFile.h" #include "nsPluginDirServiceProvider.h" #include "nsInt64.h" diff --git a/mozilla/modules/plugin/base/src/nsPluginInstancePeer.cpp b/mozilla/modules/plugin/base/src/nsPluginInstancePeer.cpp index 00187521743..1cef84bac55 100644 --- a/mozilla/modules/plugin/base/src/nsPluginInstancePeer.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginInstancePeer.cpp @@ -53,6 +53,10 @@ #include "nsIDocument.h" #include "nsIScriptGlobalObject.h" #include "nsIScriptContext.h" +#include "nsIDirectoryService.h" +#include "nsDirectoryServiceDefs.h" +#include "nsIFileStreams.h" +#include "nsNetUtil.h" #if defined(XP_PC) && !defined(XP_OS2) #include "windows.h" @@ -178,9 +182,9 @@ public: protected: char* mTarget; - nsFileURL mFileURL; - nsFileSpec mFileSpec; - nsCOMPtr mFileThing; + nsCString mFileURL; + nsCOMPtr mTempFile; + nsCOMPtr mOutputStream; nsIPluginInstanceOwner* mOwner; }; @@ -189,58 +193,44 @@ NS_IMPL_RELEASE(nsPluginStreamToFile); nsPluginStreamToFile::nsPluginStreamToFile(const char* target, nsIPluginInstanceOwner* owner) : mTarget(PL_strdup(target)), - mFileURL(nsnull), mOwner(owner) { NS_INIT_REFCNT(); - // open the file and prepare it for writing - char buf[400], tpath[300]; -#ifdef XP_PC -#ifdef XP_OS2 - PL_strcpy(tpath, getenv("TEMP")); -#else - ::GetTempPath(sizeof(tpath), tpath); -#endif - PRInt32 len = PL_strlen(tpath); + nsresult rv; + nsCOMPtr pluginTmp; + rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(pluginTmp)); + if (NS_FAILED(rv)) return; - if ((len > 0) && (tpath[len-1] != '\\')) { - tpath[len] = '\\'; - tpath[len+1] = 0; - } -#elif defined (XP_UNIX) || defined (XP_BEOS) - PL_strcpy(tpath, "/tmp/"); -#else - tpath[0] = 0; -#endif // XP_PC - - PR_snprintf(buf, sizeof(buf), "%s%08X", tpath, this); - - // Create and validate the file spec object. (When we have a constructor for the temp - // directory, we should use this instead of the per-platform hack above). - mFileSpec = PL_strdup(buf); - if (mFileSpec.Error()) - return; + mTempFile = do_QueryInterface(pluginTmp, &rv); + if (NS_FAILED(rv)) return; + + // need to create a file with a unique name - use target as the basis + rv = mTempFile->AppendNative(nsDependentCString(target)); + if (NS_FAILED(rv)) return; + + // Yes, make it unique. + rv = mTempFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0700); + if (NS_FAILED(rv)) return; // create the file - nsISupports* ourStream; - if (NS_FAILED(NS_NewTypicalOutputFileStream(&ourStream, mFileSpec))) + rv = NS_NewLocalFileOutputStream(getter_AddRefs(mOutputStream), mTempFile, -1, 00600); + if (NS_FAILED(rv)) return; - mFileThing = do_QueryInterface(ourStream); - NS_RELEASE(ourStream); - mFileThing->Close(); + mOutputStream->Close(); // construct the URL we'll use later in calls to GetURL() - mFileURL = mFileSpec; + NS_GetURLSpecFromFile(mTempFile, mFileURL); #ifdef NS_DEBUG - printf("File URL = %s\n", mFileURL.GetAsString()); + printf("File URL = %s\n", mFileURL.get()); #endif } nsPluginStreamToFile::~nsPluginStreamToFile() { + // should we be deleting mTempFile here? if (nsnull != mTarget) PL_strfree(mTarget); } @@ -271,14 +261,10 @@ nsPluginStreamToFile::Flush() NS_IMETHODIMP nsPluginStreamToFile::Write(const char* aBuf, PRUint32 aCount, PRUint32 *aWriteCount) { - // write the data to the file and update the target - nsCOMPtr thing; - thing = do_QueryInterface(mFileThing); - thing->Open(mFileSpec, (PR_WRONLY | PR_CREATE_FILE | PR_APPEND), 0700); PRUint32 actualCount; - mFileThing->Write(aBuf, aCount, &actualCount); - mFileThing->Close(); - mOwner->GetURL(mFileURL.GetAsString(), mTarget, nsnull, 0, nsnull, 0); + mOutputStream->Write(aBuf, aCount, &actualCount); + mOutputStream->Flush(); + mOwner->GetURL(mFileURL.get(), mTarget, nsnull, 0, nsnull, 0); return NS_OK; } @@ -307,7 +293,7 @@ nsPluginStreamToFile::IsNonBlocking(PRBool *aNonBlocking) NS_IMETHODIMP nsPluginStreamToFile::Close(void) { - mOwner->GetURL(mFileURL.GetAsString(), mTarget, nsnull, 0, nsnull, 0); + mOwner->GetURL(mFileURL.get(), mTarget, nsnull, 0, nsnull, 0); return NS_OK; } diff --git a/mozilla/xpfe/browser/src/nsBrowserInstance.cpp b/mozilla/xpfe/browser/src/nsBrowserInstance.cpp index 83096aa46ef..63342b99d90 100644 --- a/mozilla/xpfe/browser/src/nsBrowserInstance.cpp +++ b/mozilla/xpfe/browser/src/nsBrowserInstance.cpp @@ -93,7 +93,8 @@ #include "nsIObserverService.h" -#include "nsIFileSpec.h" +#include "nsILocalFile.h" +#include "nsIFileStreams.h" #include "nsCURILoader.h" #include "nsIContentHandler.h" @@ -111,15 +112,14 @@ #define ENABLE_PAGE_CYCLER #endif -#include "nsTimeBomb.h" +#include "nsITimeBomb.h" /* Define Class IDs */ static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID); -static NS_DEFINE_IID(kProxyObjectManagerCID, NS_PROXYEVENT_MANAGER_CID); -static NS_DEFINE_IID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID); -static NS_DEFINE_IID(kCmdLineServiceCID, NS_COMMANDLINE_SERVICE_CID); -static NS_DEFINE_IID(kCGlobalHistoryCID, NS_GLOBALHISTORY_CID); -static NS_DEFINE_CID(kTimeBombCID, NS_TIMEBOMB_CID); +static NS_DEFINE_CID(kProxyObjectManagerCID, NS_PROXYEVENT_MANAGER_CID); +static NS_DEFINE_CID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID); +static NS_DEFINE_CID(kCmdLineServiceCID, NS_COMMANDLINE_SERVICE_CID); +static NS_DEFINE_CID(kCGlobalHistoryCID, NS_GLOBALHISTORY_CID); #ifdef DEBUG static int APP_DEBUG = 0; // Set to 1 in debugger to turn on debugging. @@ -169,15 +169,16 @@ public: nsresult Init(const char* nativePath) { nsresult rv; - mFile = nativePath; - if (!mFile.IsFile()) - return mFile.Error(); + if (!mFile) { + rv = NS_NewNativeLocalFile(nsDependentCString(nativePath), + PR_TRUE, getter_AddRefs(mFile)); + if (NS_FAILED(rv)) return rv; + } - nsCOMPtr in; - rv = NS_NewTypicalInputFileStream(getter_AddRefs(in), mFile); - if (NS_FAILED(rv)) return rv; - nsCOMPtr inStr = do_QueryInterface(in, &rv); + nsCOMPtr inStr; + rv = NS_NewLocalFileInputStream(getter_AddRefs(inStr), mFile); if (NS_FAILED(rv)) return rv; + PRUint32 avail; rv = inStr->Available(&avail); if (NS_FAILED(rv)) return rv; @@ -352,7 +353,7 @@ public: protected: nsBrowserInstance* mAppCore; - nsFileSpec mFile; + nsCOMPtr mFile; char* mBuffer; char* mCursor; nsAutoString mLastRequest; @@ -742,7 +743,7 @@ NS_IMETHODIMP nsBrowserContentHandler::GetDefaultArgs(PRUnichar **aDefaultArgs) timebombChecked = PR_TRUE; PRBool expired; - nsCOMPtr timeBomb(do_GetService(kTimeBombCID, &rv)); + nsCOMPtr timeBomb(do_GetService(NS_TIMEBOMB_CONTRACTID, &rv)); if (NS_FAILED(rv)) return rv; rv = timeBomb->Init(); diff --git a/mozilla/xpfe/components/winhooks/nsWindowsHooks.cpp b/mozilla/xpfe/components/winhooks/nsWindowsHooks.cpp index a4accf82112..5b6eab33399 100644 --- a/mozilla/xpfe/components/winhooks/nsWindowsHooks.cpp +++ b/mozilla/xpfe/components/winhooks/nsWindowsHooks.cpp @@ -54,6 +54,7 @@ #include "nsString.h" #include "nsMemory.h" #include "nsNetCID.h" +#include "nsIFileStreams.h" // The order of these headers is important on Win2K because CreateDirectory // is |#undef|-ed in nsFileSpec.h, so we need to pull in windows.h for the // first time after nsFileSpec.h. @@ -197,23 +198,23 @@ nsWindowsHooks::GetSettings( nsWindowsHooksSettings **result ) { NS_ADDREF( prefs ); // Get each registry value and copy to prefs structure. - prefs->mHandleHTTP = (void*)( BoolRegistryEntry( "isHandlingHTTP" ) ) ? PR_TRUE : PR_FALSE; - prefs->mHandleHTTPS = (void*)( BoolRegistryEntry( "isHandlingHTTPS" ) ) ? PR_TRUE : PR_FALSE; - prefs->mHandleFTP = (void*)( BoolRegistryEntry( "isHandlingFTP" ) ) ? PR_TRUE : PR_FALSE; - prefs->mHandleCHROME = (void*)( BoolRegistryEntry( "isHandlingCHROME" ) ) ? PR_TRUE : PR_FALSE; - prefs->mHandleGOPHER = (void*)( BoolRegistryEntry( "isHandlingGOPHER" ) ) ? PR_TRUE : PR_FALSE; - prefs->mHandleHTML = (void*)( BoolRegistryEntry( "isHandlingHTML" ) ) ? PR_TRUE : PR_FALSE; - prefs->mHandleJPEG = (void*)( BoolRegistryEntry( "isHandlingJPEG" ) ) ? PR_TRUE : PR_FALSE; - prefs->mHandleGIF = (void*)( BoolRegistryEntry( "isHandlingGIF" ) ) ? PR_TRUE : PR_FALSE; - prefs->mHandlePNG = (void*)( BoolRegistryEntry( "isHandlingPNG" ) ) ? PR_TRUE : PR_FALSE; - prefs->mHandleMNG = (void*)( BoolRegistryEntry( "isHandlingMNG" ) ) ? PR_TRUE : PR_FALSE; - prefs->mHandleBMP = (void*)( BoolRegistryEntry( "isHandlingBMP" ) ) ? PR_TRUE : PR_FALSE; - prefs->mHandleICO = (void*)( BoolRegistryEntry( "isHandlingICO" ) ) ? PR_TRUE : PR_FALSE; - prefs->mHandleXML = (void*)( BoolRegistryEntry( "isHandlingXML" ) ) ? PR_TRUE : PR_FALSE; - prefs->mHandleXHTML = (void*)( BoolRegistryEntry( "isHandlingXHTML" ) ) ? PR_TRUE : PR_FALSE; - prefs->mHandleXUL = (void*)( BoolRegistryEntry( "isHandlingXUL" ) ) ? PR_TRUE : PR_FALSE; - prefs->mShowDialog = (void*)( BoolRegistryEntry( "showDialog" ) ) ? PR_TRUE : PR_FALSE; - prefs->mHaveBeenSet = (void*)( BoolRegistryEntry( "haveBeenSet" ) ) ? PR_TRUE : PR_FALSE; + prefs->mHandleHTTP = BoolRegistryEntry( "isHandlingHTTP" ); + prefs->mHandleHTTPS = BoolRegistryEntry( "isHandlingHTTPS" ); + prefs->mHandleFTP = BoolRegistryEntry( "isHandlingFTP" ); + prefs->mHandleCHROME = BoolRegistryEntry( "isHandlingCHROME" ); + prefs->mHandleGOPHER = BoolRegistryEntry( "isHandlingGOPHER" ); + prefs->mHandleHTML = BoolRegistryEntry( "isHandlingHTML" ); + prefs->mHandleJPEG = BoolRegistryEntry( "isHandlingJPEG" ); + prefs->mHandleGIF = BoolRegistryEntry( "isHandlingGIF" ); + prefs->mHandlePNG = BoolRegistryEntry( "isHandlingPNG" ); + prefs->mHandleMNG = BoolRegistryEntry( "isHandlingMNG" ); + prefs->mHandleBMP = BoolRegistryEntry( "isHandlingBMP" ); + prefs->mHandleICO = BoolRegistryEntry( "isHandlingICO" ); + prefs->mHandleXML = BoolRegistryEntry( "isHandlingXML" ); + prefs->mHandleXHTML = BoolRegistryEntry( "isHandlingXHTML" ); + prefs->mHandleXUL = BoolRegistryEntry( "isHandlingXUL" ); + prefs->mShowDialog = BoolRegistryEntry( "showDialog" ); + prefs->mHaveBeenSet = BoolRegistryEntry( "haveBeenSet" ); #ifdef DEBUG_law NS_WARN_IF_FALSE( NS_SUCCEEDED( rv ), "GetPreferences failed" ); @@ -890,13 +891,18 @@ WriteBitmap(nsString& aPath, gfxIImageFrame* aImage) bf.bfSize = bf.bfOffBits + bmi->biSizeImage; // get a file output stream - nsFileSpec path(aPath); - nsCOMPtr streamSupports; - NS_NewTypicalOutputFileStream(getter_AddRefs(streamSupports), path); - nsCOMPtr stream = do_QueryInterface(streamSupports); + nsresult rv; + nsCOMPtr path; + rv = NS_NewLocalFile(aPath, PR_TRUE, getter_AddRefs(path)); + + if (NS_FAILED(rv)) + return rv; + + nsCOMPtr stream; + NS_NewLocalFileOutputStream(getter_AddRefs(stream), path); // write the bitmap headers and rgb pixel data to the file - nsresult rv = NS_ERROR_FAILURE; + rv = NS_ERROR_FAILURE; if (stream) { PRUint32 written; stream->Write((const char*)&bf, sizeof(BITMAPFILEHEADER), &written); diff --git a/mozilla/xpfe/components/winhooks/nsWindowsHooksUtil.cpp b/mozilla/xpfe/components/winhooks/nsWindowsHooksUtil.cpp index b321f05af52..c2b5db94997 100644 --- a/mozilla/xpfe/components/winhooks/nsWindowsHooksUtil.cpp +++ b/mozilla/xpfe/components/winhooks/nsWindowsHooksUtil.cpp @@ -127,7 +127,7 @@ struct BoolRegistryEntry : public RegistryEntry { BoolRegistryEntry( const char *name ) : RegistryEntry( HKEY_LOCAL_MACHINE, mozillaKeyName, name, "1" ) { } - operator void*(); + operator PRBool(); }; // SavedRegistryEntry @@ -722,6 +722,6 @@ nsresult EditableFileTypeRegistryEntry::set() { } // Convert current registry setting to boolean. -BoolRegistryEntry::operator void*() { - return (void*)( currentSetting().Equals( "1" ) ? PR_TRUE : PR_FALSE ); +BoolRegistryEntry::operator PRBool() { + return currentSetting().Equals( "1" ) ? PR_TRUE : PR_FALSE; }