Bug #38374 --> more updates for external helper application support. (NOT PART OF THE BUILD)

code review will come when this is done and gets turned on.

Pass in the file extension (determined by the content type) that we want to use when generating the name
of the temp file for saving the data for the helper application.
This commit is contained in:
mscott%netscape.com 2000-06-18 01:13:04 +00:00
Родитель cbf35f6dfc
Коммит b1e8d04afd
2 изменённых файлов: 20 добавлений и 7 удалений

Просмотреть файл

@ -66,14 +66,15 @@ NS_IMETHODIMP nsExternalHelperAppService::LaunchAppWithTempFile(nsIFile * aTempF
return NS_ERROR_NOT_IMPLEMENTED;
}
nsExternalAppHandler * nsExternalHelperAppService::CreateNewExternalHandler(nsISupports * aAppCookie)
nsExternalAppHandler * nsExternalHelperAppService::CreateNewExternalHandler(nsISupports * aAppCookie,
const char * aTempFileExtension)
{
nsExternalAppHandler* handler = nsnull;
NS_NEWXPCOM(handler, nsExternalAppHandler);
// add any XP intialization code for an external handler that we may need here...
// right now we don't have any but i bet we will before we are done.
handler->Init(aAppCookie);
handler->Init(aAppCookie, aTempFileExtension);
return handler;
}
@ -114,6 +115,10 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIChannel * aChannel, nsISup
aChannel->GetURI(getter_AddRefs(uri));
nsCOMPtr<nsIURL> url = do_QueryInterface(uri);
nsCAutoString tempLeafName ("test"); // WARNING THIS IS TEMPORARY CODE!!!
tempLeafName.Append(mTempFileExtension);
#if 0
if (url)
{
// try to extract the file name from the url and use that as a first pass as the
@ -122,13 +127,17 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIChannel * aChannel, nsISup
url->GetFileName(getter_Copies(leafName));
if (leafName)
{
nsCAutoString
mTempFile->Append(leafName); // WARNING --> neeed a make Unique routine on nsIFile!!
}
else
mTempFile->Append("test.tmp"); // WARNING THIS IS TEMPORARY CODE!!!
mTempFile->Append("test"); // WARNING THIS IS TEMPORARY CODE!!!
}
else
mTempFile->Append("test.tmp"); // WARNING THIS IS TEMPORARY CODE!!!
mTempFile->Append("test"); // WARNING THIS IS TEMPORARY CODE!!!
#endif
mTempFile->Append(tempLeafName); // make this file unique!!!
nsCOMPtr<nsIFileChannel> mFileChannel = do_CreateInstance(NS_LOCALFILECHANNEL_PROGID);
if (mFileChannel)
@ -185,8 +194,9 @@ NS_IMETHODIMP nsExternalAppHandler::OnStopRequest(nsIChannel * aChannel, nsISupp
return rv;
}
nsresult nsExternalAppHandler::Init(nsISupports * aAppCookie)
nsresult nsExternalAppHandler::Init(nsISupports * aAppCookie, const char * aTempFileExtension)
{
mExternalApplication = aAppCookie;
mTempFileExtension = aTempFileExtension;
return NS_OK;
}

Просмотреть файл

@ -28,6 +28,7 @@
#include "nsIFile.h"
#include "nsIFileStreams.h"
#include "nsIOutputStream.h"
#include "nsString.h"
#include "nsCOMPtr.h"
class nsExternalAppHandler;
@ -44,7 +45,8 @@ public:
// create an external app handler and bind it with a cookie that came from the OS specific
// helper app service subclass.
virtual nsExternalAppHandler * CreateNewExternalHandler(nsISupports * aAppCookie);
// aFileExtension --> the extension we need to append to our temp file INCLUDING the ".". i.e. .mp3
virtual nsExternalAppHandler * CreateNewExternalHandler(nsISupports * aAppCookie, const char * aFileExtension);
protected:
@ -72,10 +74,11 @@ public:
// initialize the handler with a cookie that represents the external
// application associated with this handler.
virtual nsresult Init(nsISupports * aExternalApplicationCookie);
virtual nsresult Init(nsISupports * aExternalApplicationCookie, const char * aFileExtension);
protected:
nsCOMPtr<nsIFile> mTempFile;
nsCString mTempFileExtension;
nsCOMPtr<nsISupports> mExternalApplication;
nsCOMPtr<nsIOutputStream> mOutStream; // output stream to the temp file...