Bug 273524 - "Helper applications with parameters don't work ( GTK2/Gnome )" [p=mh+mozilla@glandium.org (Mike Hommey) r=biesi a1.9=beltzner]

This commit is contained in:
reed@reedloden.com 2008-02-26 16:58:15 -08:00
Родитель b9470f6ddf
Коммит 35982d200f
3 изменённых файлов: 41 добавлений и 32 удалений

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

@ -149,38 +149,10 @@ nsGNOMERegistry::GetFromType(const nsACString& aMIMEType)
vfs->GetDescriptionForMimeType(aMIMEType, description);
mimeInfo->SetDescription(NS_ConvertUTF8toUTF16(description));
// Convert UTF-8 registry value to filesystem encoding, which
// g_find_program_in_path() uses.
nsCAutoString command;
handlerApp->GetCommand(command);
gchar *nativeCommand = g_filename_from_utf8(command.get(),
-1, NULL, NULL, NULL);
if (!nativeCommand) {
NS_ERROR("Could not convert helper app command to filesystem encoding");
return nsnull;
}
gchar *commandPath = g_find_program_in_path(nativeCommand);
g_free(nativeCommand);
if (!commandPath) {
return nsnull;
}
nsCOMPtr<nsILocalFile> appFile;
NS_NewNativeLocalFile(nsDependentCString(commandPath), PR_TRUE,
getter_AddRefs(appFile));
if (appFile) {
mimeInfo->SetDefaultApplication(appFile);
nsCAutoString name;
handlerApp->GetName(name);
mimeInfo->SetDefaultDescription(NS_ConvertUTF8toUTF16(name));
mimeInfo->SetPreferredAction(nsIMIMEInfo::useSystemDefault);
}
g_free(commandPath);
nsCAutoString name;
handlerApp->GetName(name);
mimeInfo->SetDefaultDescription(NS_ConvertUTF8toUTF16(name));
mimeInfo->SetPreferredAction(nsIMIMEInfo::useSystemDefault);
nsMIMEInfoBase* retval;
NS_ADDREF((retval = mimeInfo));

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

@ -39,6 +39,7 @@
#include "nsMIMEInfoUnix.h"
#include "nsGNOMERegistry.h"
#include "nsIGnomeVFSService.h"
nsresult
nsMIMEInfoUnix::LoadUriInternal(nsIURI * aURI)
@ -46,3 +47,35 @@ nsMIMEInfoUnix::LoadUriInternal(nsIURI * aURI)
return nsGNOMERegistry::LoadURL(aURI);
}
NS_IMETHODIMP
nsMIMEInfoUnix::GetHasDefaultHandler(PRBool *_retval)
{
*_retval = PR_FALSE;
nsCOMPtr<nsIGnomeVFSService> vfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
if (vfs) {
nsCOMPtr<nsIGnomeVFSMimeApp> app;
if (NS_SUCCEEDED(vfs->GetAppForMimeType(mType, getter_AddRefs(app))) && app)
*_retval = PR_TRUE;
}
return NS_OK;
}
nsresult
nsMIMEInfoUnix::LaunchDefaultWithFile(nsIFile *aFile)
{
nsCAutoString nativePath;
aFile->GetNativePath(nativePath);
nsCOMPtr<nsIGnomeVFSService> vfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
if (vfs) {
nsCOMPtr<nsIGnomeVFSMimeApp> app;
if (NS_SUCCEEDED(vfs->GetAppForMimeType(mType, getter_AddRefs(app))) && app)
return vfs->ShowURIForInput(nativePath);
}
if (!mDefaultApplication)
return NS_ERROR_FILE_NOT_FOUND;
return LaunchWithIProcess(mDefaultApplication, nativePath);
}

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

@ -51,7 +51,11 @@ public:
nsMIMEInfoImpl(aType, aClass) {}
protected:
NS_IMETHOD GetHasDefaultHandler(PRBool *_retval);
virtual NS_HIDDEN_(nsresult) LoadUriInternal(nsIURI *aURI);
virtual NS_HIDDEN_(nsresult) LaunchDefaultWithFile(nsIFile *aFile);
};
#endif // nsMIMEInfoUnix_h_