зеркало из https://github.com/mozilla/pjs.git
Bug 327323 - Can't "Open with" files that are send as application/octet-stream (Linux). r=bzbarsky
This commit is contained in:
Родитель
be5a90cb12
Коммит
6169919759
|
@ -48,6 +48,7 @@
|
||||||
#include "nsGNOMERegistry.h"
|
#include "nsGNOMERegistry.h"
|
||||||
#include "nsIGIOService.h"
|
#include "nsIGIOService.h"
|
||||||
#include "nsIGnomeVFSService.h"
|
#include "nsIGnomeVFSService.h"
|
||||||
|
#include "nsAutoPtr.h"
|
||||||
#ifdef MOZ_ENABLE_DBUS
|
#ifdef MOZ_ENABLE_DBUS
|
||||||
#include "nsDBusHandlerApp.h"
|
#include "nsDBusHandlerApp.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -75,18 +76,14 @@ NS_IMETHODIMP
|
||||||
nsMIMEInfoUnix::GetHasDefaultHandler(PRBool *_retval)
|
nsMIMEInfoUnix::GetHasDefaultHandler(PRBool *_retval)
|
||||||
{
|
{
|
||||||
*_retval = PR_FALSE;
|
*_retval = PR_FALSE;
|
||||||
nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
|
nsRefPtr<nsMIMEInfoBase> mimeInfo = nsGNOMERegistry::GetFromType(mType);
|
||||||
nsCOMPtr<nsIGnomeVFSService> gnomevfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
|
if (!mimeInfo) {
|
||||||
if (giovfs) {
|
nsCAutoString ext;
|
||||||
nsCOMPtr<nsIGIOMimeApp> app;
|
GetPrimaryExtension(ext);
|
||||||
if (NS_SUCCEEDED(giovfs->GetAppForMimeType(mType, getter_AddRefs(app))) && app)
|
mimeInfo = nsGNOMERegistry::GetFromExtension(ext);
|
||||||
*_retval = PR_TRUE;
|
|
||||||
} else if (gnomevfs) {
|
|
||||||
/* Fallback to GnomeVFS*/
|
|
||||||
nsCOMPtr<nsIGnomeVFSMimeApp> app;
|
|
||||||
if (NS_SUCCEEDED(gnomevfs->GetAppForMimeType(mType, getter_AddRefs(app))) && app)
|
|
||||||
*_retval = PR_TRUE;
|
|
||||||
}
|
}
|
||||||
|
if (mimeInfo)
|
||||||
|
*_retval = PR_TRUE;
|
||||||
|
|
||||||
if (*_retval)
|
if (*_retval)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -128,6 +125,23 @@ nsMIMEInfoUnix::LaunchDefaultWithFile(nsIFile *aFile)
|
||||||
return app->Launch(nativePath);
|
return app->Launch(nativePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we haven't got an app we try to get a valid one by searching for the
|
||||||
|
// extension mapped type
|
||||||
|
nsRefPtr<nsMIMEInfoBase> mimeInfo = nsGNOMERegistry::GetFromExtension(nativePath);
|
||||||
|
if (mimeInfo) {
|
||||||
|
nsCAutoString type;
|
||||||
|
mimeInfo->GetType(type);
|
||||||
|
if (giovfs) {
|
||||||
|
nsCOMPtr<nsIGIOMimeApp> app;
|
||||||
|
if (NS_SUCCEEDED(giovfs->GetAppForMimeType(type, getter_AddRefs(app))) && app)
|
||||||
|
return app->Launch(nativePath);
|
||||||
|
} else if (gnomevfs) {
|
||||||
|
nsCOMPtr<nsIGnomeVFSMimeApp> app;
|
||||||
|
if (NS_SUCCEEDED(gnomevfs->GetAppForMimeType(type, getter_AddRefs(app))) && app)
|
||||||
|
return app->Launch(nativePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!mDefaultApplication)
|
if (!mDefaultApplication)
|
||||||
return NS_ERROR_FILE_NOT_FOUND;
|
return NS_ERROR_FILE_NOT_FOUND;
|
||||||
|
|
||||||
|
|
|
@ -1580,7 +1580,12 @@ nsOSHelperAppService::GetMIMEInfoFromOS(const nsACString& aType,
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy the attributes of retval onto miByExt, to return it
|
// Copy the attributes of retval (mimeinfo from type) onto miByExt, to
|
||||||
|
// return it
|
||||||
|
// but reset to just collected mDefaultAppDescription (from ext)
|
||||||
|
nsAutoString byExtDefault;
|
||||||
|
miByExt->GetDefaultDescription(byExtDefault);
|
||||||
|
retval->SetDefaultDescription(byExtDefault);
|
||||||
retval->CopyBasicDataTo(miByExt);
|
retval->CopyBasicDataTo(miByExt);
|
||||||
|
|
||||||
miByExt.swap(retval);
|
miByExt.swap(retval);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче