Bug 294375 - Remove support for libgnomevfs's handling of user modifications to the MIME database, as it has been deprecated for years [r=karlt sr=roc]

This commit is contained in:
Reed Loden 2009-09-08 15:08:02 -05:00
Родитель e2a289f840
Коммит 6aae290bff
5 изменённых файлов: 4 добавлений и 219 удалений

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

@ -46,7 +46,6 @@
#include "nsStringAPI.h"
#include "nsIGConfService.h"
#include "nsIGIOService.h"
#include "nsIGnomeVFSService.h"
#include "nsIStringBundle.h"
#include "nsIOutputStream.h"
#include "nsIProcess.h"
@ -107,16 +106,14 @@ nsGNOMEShellService::Init()
{
nsresult rv;
// GConf and GnomeVFS _must_ be available, or we do not allow
// GConf _must_ be available, or we do not allow
// CreateInstance to succeed.
nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
nsCOMPtr<nsIGIOService> giovfs =
do_GetService(NS_GIOSERVICE_CONTRACTID);
nsCOMPtr<nsIGnomeVFSService> gnomevfs =
do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
if (!gconf || (!giovfs && !gnomevfs))
if (!gconf)
return NS_ERROR_NOT_AVAILABLE;
// Check G_BROKEN_FILENAMES. If it's set, then filenames in glib use
@ -218,16 +215,11 @@ nsGNOMEShellService::SetDefaultBrowser(PRBool aClaimAllTypes,
nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
nsCAutoString schemeList; /* For GnomeVFS fallback */
nsCAutoString appKeyValue(mAppPath);
appKeyValue.Append(" \"%s\"");
unsigned int i;
for (i = 0; i < NS_ARRAY_LENGTH(appProtocols); ++i) {
/* For GnomeVFS fallback */
schemeList.Append(nsDependentCString(appProtocols[i].name));
schemeList.Append(',');
if (appProtocols[i].essential || aClaimAllTypes) {
gconf->SetAppForProtocol(nsDependentCString(appProtocols[i].name),
appKeyValue);
@ -238,8 +230,6 @@ nsGNOMEShellService::SetDefaultBrowser(PRBool aClaimAllTypes,
if (aClaimAllTypes) {
nsCOMPtr<nsIGIOService> giovfs =
do_GetService(NS_GIOSERVICE_CONTRACTID);
nsCOMPtr<nsIGnomeVFSService> gnomevfs =
do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
nsCOMPtr<nsIStringBundleService> bundleService =
do_GetService(NS_STRINGBUNDLE_CONTRACTID);
@ -268,64 +258,6 @@ nsGNOMEShellService::SetDefaultBrowser(PRBool aClaimAllTypes,
appInfo->SetAsDefaultForMimeType(nsDependentCString(appTypes[i].mimeType));
appInfo->SetAsDefaultForFileExtensions(nsDependentCString(appTypes[i].extensions));
}
} else {
/* Fallback GnomeVFS */
gnomevfs->SetAppStringKey(id, nsIGnomeVFSService::APP_KEY_COMMAND, mAppPath);
gnomevfs->SetAppStringKey(id, nsIGnomeVFSService::APP_KEY_NAME,
NS_ConvertUTF16toUTF8(brandFullName));
// We don't want to be the default handler for "file:", but we do
// want Nautilus to know that we support file: if the MIME type is
// one that we can handle.
schemeList.Append("file");
gnomevfs->SetAppStringKey(id, nsIGnomeVFSService::APP_KEY_SUPPORTED_URI_SCHEMES,
schemeList);
gnomevfs->SetAppStringKey(id, nsIGnomeVFSService::APP_KEY_EXPECTS_URIS,
NS_LITERAL_CSTRING("true"));
gnomevfs->SetAppBoolKey(id, nsIGnomeVFSService::APP_KEY_CAN_OPEN_MULTIPLE,
PR_FALSE);
gnomevfs->SetAppBoolKey(id, nsIGnomeVFSService::APP_KEY_REQUIRES_TERMINAL,
PR_FALSE);
// Copy icons/document.png to ~/.icons/firefox-document.png
nsCAutoString iconFilePath(mAppPath);
PRInt32 lastSlash = iconFilePath.RFindChar(PRUnichar('/'));
if (lastSlash == -1) {
NS_ERROR("no slash in executable path?");
} else {
iconFilePath.SetLength(lastSlash);
nsCOMPtr<nsILocalFile> iconFile;
NS_NewNativeLocalFile(iconFilePath, PR_FALSE, getter_AddRefs(iconFile));
if (iconFile) {
iconFile->AppendRelativeNativePath(NS_LITERAL_CSTRING("icons/document.png"));
nsCOMPtr<nsILocalFile> userIconPath;
NS_NewNativeLocalFile(nsDependentCString(PR_GetEnv("HOME")), PR_FALSE,
getter_AddRefs(userIconPath));
if (userIconPath) {
userIconPath->AppendNative(NS_LITERAL_CSTRING(".icons"));
iconFile->CopyToNative(userIconPath,
nsDependentCString(kDocumentIconPath));
}
}
}
for (i = 0; i < NS_ARRAY_LENGTH(appTypes); ++i) {
gnomevfs->AddMimeType(id, nsDependentCString(appTypes[i].mimeType));
gnomevfs->SetMimeExtensions(nsDependentCString(appTypes[i].mimeType),
nsDependentCString(appTypes[i].extensions));
gnomevfs->SetAppForMimeType(nsDependentCString(appTypes[i].mimeType), id);
gnomevfs->SetIconForMimeType(nsDependentCString(appTypes[i].mimeType),
NS_LITERAL_CSTRING(kDocumentIconPath));
}
gnomevfs->SyncAppRegistry();
}
}

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

@ -393,13 +393,11 @@ libgnome/libgnome.h
libgnomeui/gnome-icon-lookup.h
libgnomeui/gnome-icon-theme.h
libgnomeui/gnome-ui-init.h
libgnomevfs/gnome-vfs-application-registry.h
libgnomevfs/gnome-vfs-file-info.h
libgnomevfs/gnome-vfs.h
libgnomevfs/gnome-vfs-init.h
libgnomevfs/gnome-vfs-mime.h
libgnomevfs/gnome-vfs-mime-handlers.h
libgnomevfs/gnome-vfs-mime-info.h
libgnomevfs/gnome-vfs-mime-utils.h
libgnomevfs/gnome-vfs-ops.h
libgnomevfs/gnome-vfs-standard-callbacks.h

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

@ -393,13 +393,11 @@ libgnome/libgnome.h
libgnomeui/gnome-icon-lookup.h
libgnomeui/gnome-icon-theme.h
libgnomeui/gnome-ui-init.h
libgnomevfs/gnome-vfs-application-registry.h
libgnomevfs/gnome-vfs-file-info.h
libgnomevfs/gnome-vfs.h
libgnomevfs/gnome-vfs-init.h
libgnomevfs/gnome-vfs-mime.h
libgnomevfs/gnome-vfs-mime-handlers.h
libgnomevfs/gnome-vfs-mime-info.h
libgnomevfs/gnome-vfs-mime-utils.h
libgnomevfs/gnome-vfs-ops.h
libgnomevfs/gnome-vfs-standard-callbacks.h

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

@ -45,10 +45,8 @@
extern "C" {
#include <libgnomevfs/gnome-vfs.h>
#include <libgnomevfs/gnome-vfs-application-registry.h>
#include <libgnomevfs/gnome-vfs-mime.h>
#include <libgnomevfs/gnome-vfs-mime-handlers.h>
#include <libgnomevfs/gnome-vfs-mime-info.h>
}
class nsGnomeVFSMimeApp : public nsIGnomeVFSMimeApp
@ -226,24 +224,6 @@ nsGnomeVFSService::GetAppForMimeType(const nsACString &aMimeType,
return NS_OK;
}
NS_IMETHODIMP
nsGnomeVFSService::SetAppForMimeType(const nsACString &aMimeType,
const nsACString &aId)
{
gnome_vfs_mime_set_default_application(PromiseFlatCString(aMimeType).get(),
PromiseFlatCString(aId).get());
return NS_OK;
}
NS_IMETHODIMP
nsGnomeVFSService::SetIconForMimeType(const nsACString &aMimeType,
const nsACString &aIconName)
{
gnome_vfs_mime_set_icon(PromiseFlatCString(aMimeType).get(),
PromiseFlatCString(aIconName).get());
return NS_OK;
}
NS_IMETHODIMP
nsGnomeVFSService::GetDescriptionForMimeType(const nsACString &aMimeType,
nsACString& aDescription)
@ -282,70 +262,3 @@ nsGnomeVFSService::ShowURIForInput(const nsACString &aUri)
g_free(spec);
return rv;
}
NS_IMETHODIMP
nsGnomeVFSService::SetAppStringKey(const nsACString &aID,
PRInt32 aKey,
const nsACString &aValue)
{
const char *key;
if (aKey == APP_KEY_COMMAND)
key = GNOME_VFS_APPLICATION_REGISTRY_COMMAND;
else if (aKey == APP_KEY_NAME)
key = GNOME_VFS_APPLICATION_REGISTRY_NAME;
else if (aKey == APP_KEY_SUPPORTED_URI_SCHEMES)
key = "supported_uri_schemes";
else if (aKey == APP_KEY_EXPECTS_URIS)
key = "expects_uris";
else
return NS_ERROR_NOT_AVAILABLE;
gnome_vfs_application_registry_set_value(PromiseFlatCString(aID).get(), key,
PromiseFlatCString(aValue).get());
return NS_OK;
}
NS_IMETHODIMP
nsGnomeVFSService::SetAppBoolKey(const nsACString &aID,
PRInt32 aKey,
PRBool aValue)
{
const char *key;
if (aKey == APP_KEY_CAN_OPEN_MULTIPLE)
key = GNOME_VFS_APPLICATION_REGISTRY_CAN_OPEN_MULTIPLE_FILES;
else if (aKey == APP_KEY_REQUIRES_TERMINAL)
key = GNOME_VFS_APPLICATION_REGISTRY_REQUIRES_TERMINAL;
else
return NS_ERROR_NOT_AVAILABLE;
gnome_vfs_application_registry_set_bool_value(PromiseFlatCString(aID).get(),
key, aValue);
return NS_OK;
}
NS_IMETHODIMP
nsGnomeVFSService::AddMimeType(const nsACString &aID, const nsACString &aType)
{
gnome_vfs_application_registry_add_mime_type(PromiseFlatCString(aID).get(),
PromiseFlatCString(aType).get());
return NS_OK;
}
NS_IMETHODIMP
nsGnomeVFSService::SyncAppRegistry()
{
gnome_vfs_application_registry_sync();
return NS_OK;
}
NS_IMETHODIMP
nsGnomeVFSService::SetMimeExtensions(const nsACString &aMimeType,
const nsACString &aExtensionsList)
{
GnomeVFSResult res =
gnome_vfs_mime_set_extensions_list(PromiseFlatCString(aMimeType).get(),
PromiseFlatCString(aExtensionsList).get());
return (res == GNOME_VFS_OK) ? NS_OK : NS_ERROR_FAILURE;
}

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

@ -63,54 +63,16 @@ interface nsIGnomeVFSMimeApp : nsISupports
};
/*
* The VFS service makes use of two distinct registries.
*
* The application registry holds information about applications (uniquely
* identified by id), such as which MIME types and URI schemes they are
* capable of handling, whether they run in a terminal, etc.
* The VFS service makes use of a registry for information.
*
* The MIME registry holds information about MIME types, such as which
* extensions map to a given MIME type. The MIME registry also stores the
* id of the application selected to handle each MIME type.
*/
[scriptable, uuid(dea20bf0-4e4d-48c5-b932-dc3e116dc64b)]
[scriptable, uuid(d1ac73a6-2ceb-4164-8142-215afe7fe8a6)]
interface nsIGnomeVFSService : nsISupports
{
/*** Application registry methods ***/
/* string keys */
const long APP_KEY_COMMAND = 0;
const long APP_KEY_NAME = 1;
const long APP_KEY_SUPPORTED_URI_SCHEMES = 2; /* comma-separated list */
const long APP_KEY_EXPECTS_URIS = 3; /* "true", "false", or "non-file" */
/* Set one of the above string keys for the given application id.
'id' can be an arbitrary, unique string to identify the application. */
void setAppStringKey(in AUTF8String id,
in long key, /* see enums above */
in AUTF8String value);
/* boolean keys */
const long APP_KEY_CAN_OPEN_MULTIPLE = 4;
const long APP_KEY_REQUIRES_TERMINAL = 5;
/* Set one of the above boolean keys for the given application id.
'id' can be an arbitrary, unique string to identify the application. */
void setAppBoolKey(in AUTF8String id,
in long key,
in boolean value);
/* Add a MIME type to the list of types that the application can handle */
void addMimeType(in AUTF8String id,
in AUTF8String mimeType);
/* Commit application registry changes to disk. This must be called
to save changes. */
void syncAppRegistry();
/*** MIME registry methods ***/
/* Obtain the MIME type registered for an extension. The extension
@ -120,27 +82,9 @@ interface nsIGnomeVFSService : nsISupports
/* Obtain the preferred application for opening a given MIME type */
nsIGnomeVFSMimeApp getAppForMimeType(in AUTF8String mimeType);
/* Set the preferred application for opening a given MIME type */
void setAppForMimeType(in AUTF8String mimeType,
in AUTF8String id);
/* Obtain a description for the given MIME type */
AUTF8String getDescriptionForMimeType(in AUTF8String mimeType);
/* Set the icon for a MIME type, which will be searched for by the shell
using the icon theme search path. */
void setIconForMimeType(in AUTF8String mimeType,
in AUTF8String iconPath);
/*
* Set the list of extensions for a given MIME type.
* Should be passed a space separated list of extensions with no
* dot, i.e. "gif jpg png".
*/
void setMimeExtensions(in AUTF8String mimeType,
in AUTF8String extensionsList);
/*** Misc. methods ***/
/* Open the given URI in the default application */