a8a561
diff -up thunderbird-45.0/mozilla/toolkit/system/gnome/moz.build.moz-1134537-delete-nsgnomevfsservice thunderbird-45.0/mozilla/toolkit/system/gnome/moz.build
a8a561
--- thunderbird-45.0/mozilla/toolkit/system/gnome/moz.build.moz-1134537-delete-nsgnomevfsservice	2016-04-07 23:33:34.000000000 +0200
a8a561
+++ thunderbird-45.0/mozilla/toolkit/system/gnome/moz.build	2016-05-11 13:56:15.863034987 +0200
a8a561
@@ -15,6 +15,12 @@ if CONFIG['MOZ_ENABLE_GCONF']:
a8a561
         'nsGConfService.cpp',
a8a561
     ]
a8a561
 
a8a561
+if CONFIG['MOZ_ENABLE_GNOMEVFS']:
a8a561
+    SOURCES += [
a8a561
+        'nsGnomeVFSService.cpp',
a8a561
+    ]
a8a561
+
a8a561
+
a8a561
 if CONFIG['MOZ_ENABLE_GIO']:
a8a561
     SOURCES += [
a8a561
         'nsGIOService.cpp',
a8a561
@@ -29,6 +35,7 @@ LOCAL_INCLUDES += [
a8a561
 ]
a8a561
 
a8a561
 CXXFLAGS += CONFIG['MOZ_GCONF_CFLAGS']
a8a561
+CXXFLAGS += CONFIG['MOZ_GNOMEVFS_CFLAGS']
a8a561
 CXXFLAGS += CONFIG['MOZ_GIO_CFLAGS']
a8a561
 CXXFLAGS += CONFIG['GLIB_CFLAGS']
a8a561
 CXXFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS']
a8a561
@@ -38,3 +45,5 @@ if CONFIG['MOZ_ENABLE_GTK']:
a8a561
 
a8a561
 if CONFIG['GNU_CXX']:
a8a561
     CXXFLAGS += ['-Wshadow']
a8a561
+    
a8a561
+OS_LIBS += CONFIG['MOZ_GNOMEVFS_LIBS']
a8a561
\ No newline at end of file
a8a561
diff -up thunderbird-45.0/mozilla/toolkit/system/gnome/nsGnomeModule.cpp.moz-1134537-delete-nsgnomevfsservice thunderbird-45.0/mozilla/toolkit/system/gnome/nsGnomeModule.cpp
a8a561
--- thunderbird-45.0/mozilla/toolkit/system/gnome/nsGnomeModule.cpp.moz-1134537-delete-nsgnomevfsservice	2016-04-07 23:33:34.000000000 +0200
a8a561
+++ thunderbird-45.0/mozilla/toolkit/system/gnome/nsGnomeModule.cpp	2016-05-11 13:54:01.306097859 +0200
a8a561
@@ -12,6 +12,10 @@
a8a561
 #include "nsGConfService.h"
a8a561
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsGConfService, Init)
a8a561
 #endif
a8a561
+#ifdef MOZ_ENABLE_GNOMEVFS
a8a561
+#include "nsGnomeVFSService.h"
a8a561
+NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsGnomeVFSService, Init)
a8a561
+#endif
a8a561
 #ifdef MOZ_ENABLE_GIO
a8a561
 #include "nsGIOService.h"
a8a561
 #include "nsGSettingsService.h"
a8a561
@@ -26,6 +30,9 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsSy
a8a561
 #ifdef MOZ_ENABLE_GCONF
a8a561
 NS_DEFINE_NAMED_CID(NS_GCONFSERVICE_CID);
a8a561
 #endif
a8a561
+#ifdef MOZ_ENABLE_GNOMEVFS
a8a561
+NS_DEFINE_NAMED_CID(NS_GNOMEVFSSERVICE_CID);
a8a561
+#endif
a8a561
 #ifdef MOZ_ENABLE_GIO
a8a561
 NS_DEFINE_NAMED_CID(NS_GIOSERVICE_CID);
a8a561
 NS_DEFINE_NAMED_CID(NS_GSETTINGSSERVICE_CID);
a8a561
@@ -37,6 +44,9 @@ static const mozilla::Module::CIDEntry k
a8a561
 #ifdef MOZ_ENABLE_GCONF
a8a561
   { &kNS_GCONFSERVICE_CID, false, nullptr, nsGConfServiceConstructor },
a8a561
 #endif
a8a561
+#ifdef MOZ_ENABLE_GNOMEVFS
a8a561
+  { &kNS_GNOMEVFSSERVICE_CID, false, nullptr, nsGnomeVFSServiceConstructor },
a8a561
+#endif
a8a561
 #ifdef MOZ_ENABLE_GIO
a8a561
   { &kNS_GIOSERVICE_CID, false, nullptr, nsGIOServiceConstructor },
a8a561
   { &kNS_GSETTINGSSERVICE_CID, false, nullptr, nsGSettingsServiceConstructor },
a8a561
@@ -50,6 +60,9 @@ static const mozilla::Module::ContractID
a8a561
 #ifdef MOZ_ENABLE_GCONF
a8a561
   { NS_GCONFSERVICE_CONTRACTID, &kNS_GCONFSERVICE_CID },
a8a561
 #endif
a8a561
+#ifdef MOZ_ENABLE_GNOMEVFS
a8a561
+  { NS_GNOMEVFSSERVICE_CONTRACTID, &kNS_GNOMEVFSSERVICE_CID },
a8a561
+#endif
a8a561
 #ifdef MOZ_ENABLE_GIO
a8a561
   { NS_GIOSERVICE_CONTRACTID, &kNS_GIOSERVICE_CID },
a8a561
   { NS_GSETTINGSSERVICE_CONTRACTID, &kNS_GSETTINGSSERVICE_CID },
a8a561
diff -up thunderbird-45.0/mozilla/toolkit/system/gnome/nsGnomeVFSService.cpp.moz-1134537-delete-nsgnomevfsservice thunderbird-45.0/mozilla/toolkit/system/gnome/nsGnomeVFSService.cpp
a8a561
--- thunderbird-45.0/mozilla/toolkit/system/gnome/nsGnomeVFSService.cpp.moz-1134537-delete-nsgnomevfsservice	2016-05-11 13:54:01.306097859 +0200
a8a561
+++ thunderbird-45.0/mozilla/toolkit/system/gnome/nsGnomeVFSService.cpp	2016-05-11 13:54:01.306097859 +0200
a8a561
@@ -0,0 +1,225 @@
a8a561
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
a8a561
+/* This Source Code Form is subject to the terms of the Mozilla Public
a8a561
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
a8a561
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
a8a561
+
a8a561
+#include "nsGnomeVFSService.h"
a8a561
+#include "nsStringGlue.h"
a8a561
+#include "nsIURI.h"
a8a561
+#include "nsTArray.h"
a8a561
+#include "nsIStringEnumerator.h"
a8a561
+#include "nsAutoPtr.h"
a8a561
+
a8a561
+extern "C" {
a8a561
+#include <libgnomevfs/gnome-vfs.h>
a8a561
+#include <libgnomevfs/gnome-vfs-mime.h>
a8a561
+#include <libgnomevfs/gnome-vfs-mime-handlers.h>
a8a561
+}
a8a561
+
a8a561
+class nsGnomeVFSMimeApp : public nsIGnomeVFSMimeApp
a8a561
+{
a8a561
+public:
a8a561
+  NS_DECL_ISUPPORTS
a8a561
+  NS_DECL_NSIGNOMEVFSMIMEAPP
a8a561
+
a8a561
+  nsGnomeVFSMimeApp(GnomeVFSMimeApplication* aApp) : mApp(aApp) {}
a8a561
+
a8a561
+private:
a8a561
+  ~nsGnomeVFSMimeApp() { gnome_vfs_mime_application_free(mApp); }
a8a561
+  GnomeVFSMimeApplication *mApp;
a8a561
+};
a8a561
+
a8a561
+NS_IMPL_ISUPPORTS(nsGnomeVFSMimeApp, nsIGnomeVFSMimeApp)
a8a561
+
a8a561
+NS_IMETHODIMP
a8a561
+nsGnomeVFSMimeApp::GetId(nsACString& aId)
a8a561
+{
a8a561
+  aId.Assign(mApp->id);
a8a561
+  return NS_OK;
a8a561
+}
a8a561
+
a8a561
+NS_IMETHODIMP
a8a561
+nsGnomeVFSMimeApp::GetName(nsACString& aName)
a8a561
+{
a8a561
+  aName.Assign(mApp->name);
a8a561
+  return NS_OK;
a8a561
+}
a8a561
+
a8a561
+NS_IMETHODIMP
a8a561
+nsGnomeVFSMimeApp::GetCommand(nsACString& aCommand)
a8a561
+{
a8a561
+  aCommand.Assign(mApp->command);
a8a561
+  return NS_OK;
a8a561
+}
a8a561
+
a8a561
+NS_IMETHODIMP
a8a561
+nsGnomeVFSMimeApp::GetCanOpenMultipleFiles(bool* aCanOpen)
a8a561
+{
a8a561
+  *aCanOpen = mApp->can_open_multiple_files;
a8a561
+  return NS_OK;
a8a561
+}
a8a561
+
a8a561
+NS_IMETHODIMP
a8a561
+nsGnomeVFSMimeApp::GetExpectsURIs(int32_t* aExpects)
a8a561
+{
a8a561
+  *aExpects = mApp->expects_uris;
a8a561
+  return NS_OK;
a8a561
+}
a8a561
+
a8a561
+NS_IMETHODIMP
a8a561
+nsGnomeVFSMimeApp::Launch(const nsACString &aUri)
a8a561
+{
a8a561
+  char *uri = gnome_vfs_make_uri_from_input(PromiseFlatCString(aUri).get());
a8a561
+
a8a561
+  if (! uri)
a8a561
+    return NS_ERROR_FAILURE;
a8a561
+
a8a561
+  GList uris = { 0 };
a8a561
+  uris.data = uri;
a8a561
+
a8a561
+  GnomeVFSResult result = gnome_vfs_mime_application_launch(mApp, &uris;;
a8a561
+  g_free(uri);
a8a561
+
a8a561
+  if (result != GNOME_VFS_OK)
a8a561
+    return NS_ERROR_FAILURE;
a8a561
+
a8a561
+  return NS_OK;
a8a561
+}
a8a561
+
a8a561
+class UTF8StringEnumerator : public nsIUTF8StringEnumerator
a8a561
+{
a8a561
+public:
a8a561
+  UTF8StringEnumerator() : mIndex(0) { }
a8a561
+private:
a8a561
+  ~UTF8StringEnumerator() { }
a8a561
+
a8a561
+  NS_DECL_ISUPPORTS
a8a561
+  NS_DECL_NSIUTF8STRINGENUMERATOR
a8a561
+public:
a8a561
+  nsTArray<nsCString> mStrings;
a8a561
+  uint32_t            mIndex;
a8a561
+};
a8a561
+
a8a561
+NS_IMPL_ISUPPORTS(UTF8StringEnumerator, nsIUTF8StringEnumerator)
a8a561
+
a8a561
+NS_IMETHODIMP
a8a561
+UTF8StringEnumerator::HasMore(bool *aResult)
a8a561
+{
a8a561
+  *aResult = mIndex < mStrings.Length();
a8a561
+  return NS_OK;
a8a561
+}
a8a561
+
a8a561
+NS_IMETHODIMP
a8a561
+UTF8StringEnumerator::GetNext(nsACString& aResult)
a8a561
+{
a8a561
+  if (mIndex >= mStrings.Length())
a8a561
+    return NS_ERROR_UNEXPECTED;
a8a561
+
a8a561
+  aResult.Assign(mStrings[mIndex]);
a8a561
+  ++mIndex;
a8a561
+  return NS_OK;
a8a561
+}
a8a561
+
a8a561
+NS_IMETHODIMP
a8a561
+nsGnomeVFSMimeApp::GetSupportedURISchemes(nsIUTF8StringEnumerator** aSchemes)
a8a561
+{
a8a561
+  *aSchemes = nullptr;
a8a561
+
a8a561
+  RefPtr<UTF8StringEnumerator> array = new UTF8StringEnumerator();
a8a561
+  NS_ENSURE_TRUE(array, NS_ERROR_OUT_OF_MEMORY);
a8a561
+
a8a561
+  for (GList *list = mApp->supported_uri_schemes; list; list = list->next) {
a8a561
+    if (!array->mStrings.AppendElement((char*) list->data)) {
a8a561
+      return NS_ERROR_OUT_OF_MEMORY;
a8a561
+    }
a8a561
+  }
a8a561
+
a8a561
+  NS_ADDREF(*aSchemes = array);
a8a561
+  return NS_OK;
a8a561
+}
a8a561
+
a8a561
+NS_IMETHODIMP
a8a561
+nsGnomeVFSMimeApp::GetRequiresTerminal(bool* aRequires)
a8a561
+{
a8a561
+  *aRequires = mApp->requires_terminal;
a8a561
+  return NS_OK;
a8a561
+}
a8a561
+
a8a561
+nsresult
a8a561
+nsGnomeVFSService::Init()
a8a561
+{
a8a561
+  return gnome_vfs_init() ? NS_OK : NS_ERROR_FAILURE;
a8a561
+}
a8a561
+
a8a561
+NS_IMPL_ISUPPORTS(nsGnomeVFSService, nsIGnomeVFSService)
a8a561
+
a8a561
+NS_IMETHODIMP
a8a561
+nsGnomeVFSService::GetMimeTypeFromExtension(const nsACString &aExtension,
a8a561
+                                            nsACString& aMimeType)
a8a561
+{
a8a561
+  nsAutoCString fileExtToUse(".");
a8a561
+  fileExtToUse.Append(aExtension);
a8a561
+
a8a561
+  const char *mimeType = gnome_vfs_mime_type_from_name(fileExtToUse.get());
a8a561
+  aMimeType.Assign(mimeType);
a8a561
+
a8a561
+  // |mimeType| points to internal gnome-vfs data, so don't free it.
a8a561
+
a8a561
+  return NS_OK;
a8a561
+}
a8a561
+
a8a561
+NS_IMETHODIMP
a8a561
+nsGnomeVFSService::GetAppForMimeType(const nsACString &aMimeType,
a8a561
+                                     nsIGnomeVFSMimeApp** aApp)
a8a561
+{
a8a561
+  *aApp = nullptr;
a8a561
+  GnomeVFSMimeApplication *app =
a8a561
+   gnome_vfs_mime_get_default_application(PromiseFlatCString(aMimeType).get());
a8a561
+
a8a561
+  if (app) {
a8a561
+    nsGnomeVFSMimeApp *mozApp = new nsGnomeVFSMimeApp(app);
a8a561
+    NS_ENSURE_TRUE(mozApp, NS_ERROR_OUT_OF_MEMORY);
a8a561
+
a8a561
+    NS_ADDREF(*aApp = mozApp);
a8a561
+  }
a8a561
+
a8a561
+  return NS_OK;
a8a561
+}
a8a561
+
a8a561
+NS_IMETHODIMP
a8a561
+nsGnomeVFSService::GetDescriptionForMimeType(const nsACString &aMimeType,
a8a561
+                                             nsACString& aDescription)
a8a561
+{
a8a561
+  const char *desc =
a8a561
+    gnome_vfs_mime_get_description(PromiseFlatCString(aMimeType).get());
a8a561
+  aDescription.Assign(desc);
a8a561
+
a8a561
+  // |desc| points to internal gnome-vfs data, so don't free it.
a8a561
+
a8a561
+  return NS_OK;
a8a561
+}
a8a561
+
a8a561
+NS_IMETHODIMP
a8a561
+nsGnomeVFSService::ShowURI(nsIURI *aURI)
a8a561
+{
a8a561
+  nsAutoCString spec;
a8a561
+  aURI->GetSpec(spec);
a8a561
+
a8a561
+  if (gnome_vfs_url_show_with_env(spec.get(), nullptr) == GNOME_VFS_OK)
a8a561
+    return NS_OK;
a8a561
+
a8a561
+  return NS_ERROR_FAILURE;
a8a561
+}
a8a561
+
a8a561
+NS_IMETHODIMP
a8a561
+nsGnomeVFSService::ShowURIForInput(const nsACString &aUri)
a8a561
+{
a8a561
+  char* spec = gnome_vfs_make_uri_from_input(PromiseFlatCString(aUri).get());
a8a561
+  nsresult rv = NS_ERROR_FAILURE;
a8a561
+
a8a561
+  if (gnome_vfs_url_show_with_env(spec, nullptr) == GNOME_VFS_OK)
a8a561
+    rv = NS_OK;
a8a561
+
a8a561
+  g_free(spec);
a8a561
+  return rv;
a8a561
+}
a8a561
diff -up thunderbird-45.0/mozilla/toolkit/system/gnome/nsGnomeVFSService.h.moz-1134537-delete-nsgnomevfsservice thunderbird-45.0/mozilla/toolkit/system/gnome/nsGnomeVFSService.h
a8a561
--- thunderbird-45.0/mozilla/toolkit/system/gnome/nsGnomeVFSService.h.moz-1134537-delete-nsgnomevfsservice	2016-05-11 13:54:01.307097859 +0200
a8a561
+++ thunderbird-45.0/mozilla/toolkit/system/gnome/nsGnomeVFSService.h	2016-05-11 13:54:01.307097859 +0200
a8a561
@@ -0,0 +1,26 @@
a8a561
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
a8a561
+/* This Source Code Form is subject to the terms of the Mozilla Public
a8a561
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
a8a561
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
a8a561
+
a8a561
+#ifndef nsGnomeVFSService_h_
a8a561
+#define nsGnomeVFSService_h_
a8a561
+
a8a561
+#include "nsIGnomeVFSService.h"
a8a561
+#include "mozilla/Attributes.h"
a8a561
+
a8a561
+#define NS_GNOMEVFSSERVICE_CID \
a8a561
+{0x5f43022c, 0x6194, 0x4b37, {0xb2, 0x6d, 0xe4, 0x10, 0x24, 0x62, 0x52, 0x64}}
a8a561
+
a8a561
+class nsGnomeVFSService : public nsIGnomeVFSService
a8a561
+{
a8a561
+public:
a8a561
+  NS_DECL_ISUPPORTS
a8a561
+  NS_DECL_NSIGNOMEVFSSERVICE
a8a561
+
a8a561
+  nsresult Init();
a8a561
+private:
a8a561
+  ~nsGnomeVFSService() { };
a8a561
+};
a8a561
+
a8a561
+#endif
a8a561
diff -up thunderbird-45.0/mozilla/xpcom/system/moz.build.moz-1134537-delete-nsgnomevfsservice thunderbird-45.0/mozilla/xpcom/system/moz.build
a8a561
--- thunderbird-45.0/mozilla/xpcom/system/moz.build.moz-1134537-delete-nsgnomevfsservice	2016-04-07 23:33:35.000000000 +0200
a8a561
+++ thunderbird-45.0/mozilla/xpcom/system/moz.build	2016-05-11 13:54:01.307097859 +0200
a8a561
@@ -11,6 +11,7 @@ XPIDL_SOURCES += [
a8a561
     'nsIGConfService.idl',
a8a561
     'nsIGeolocationProvider.idl',
a8a561
     'nsIGIOService.idl',
a8a561
+    'nsIGnomeVFSService.idl',
a8a561
     'nsIGSettingsService.idl',
a8a561
     'nsIHapticFeedback.idl',
a8a561
     'nsIPackageKitService.idl',
a8a561
diff -up thunderbird-45.0/mozilla/xpcom/system/nsIGnomeVFSService.idl.moz-1134537-delete-nsgnomevfsservice thunderbird-45.0/mozilla/xpcom/system/nsIGnomeVFSService.idl
a8a561
--- thunderbird-45.0/mozilla/xpcom/system/nsIGnomeVFSService.idl.moz-1134537-delete-nsgnomevfsservice	2016-05-11 13:54:01.307097859 +0200
a8a561
+++ thunderbird-45.0/mozilla/xpcom/system/nsIGnomeVFSService.idl	2016-05-11 13:54:01.307097859 +0200
a8a561
@@ -0,0 +1,64 @@
a8a561
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
a8a561
+/* This Source Code Form is subject to the terms of the Mozilla Public
a8a561
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
a8a561
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
a8a561
+
a8a561
+#include "nsISupports.idl"
a8a561
+
a8a561
+interface nsIUTF8StringEnumerator;
a8a561
+interface nsIURI;
a8a561
+
a8a561
+/* nsIGnomeVFSMimeApp holds information about an application that is looked up
a8a561
+   with nsIGnomeVFSService::GetAppForMimeType. */
a8a561
+
a8a561
+[scriptable, uuid(66009894-9877-405b-9321-bf30420e34e6)]
a8a561
+interface nsIGnomeVFSMimeApp : nsISupports
a8a561
+{
a8a561
+  const long EXPECTS_URIS  = 0;
a8a561
+  const long EXPECTS_PATHS = 1;
a8a561
+  const long EXPECTS_URIS_FOR_NON_FILES = 2;
a8a561
+
a8a561
+  readonly attribute AUTF8String         id;
a8a561
+  readonly attribute AUTF8String         name;
a8a561
+  readonly attribute AUTF8String         command;
a8a561
+  readonly attribute boolean             canOpenMultipleFiles;
a8a561
+  readonly attribute long                expectsURIs;  // see constants above
a8a561
+  readonly attribute nsIUTF8StringEnumerator supportedURISchemes;
a8a561
+  readonly attribute boolean             requiresTerminal;
a8a561
+
a8a561
+  void launch(in AUTF8String uri);
a8a561
+};
a8a561
+
a8a561
+/*
a8a561
+ * The VFS service makes use of a registry for information.
a8a561
+ *
a8a561
+ * The MIME registry holds information about MIME types, such as which
a8a561
+ * extensions map to a given MIME type.  The MIME registry also stores the
a8a561
+ * id of the application selected to handle each MIME type.
a8a561
+ */
a8a561
+
a8a561
+[scriptable, uuid(d1ac73a6-2ceb-4164-8142-215afe7fe8a6)]
a8a561
+interface nsIGnomeVFSService : nsISupports
a8a561
+{
a8a561
+  /*** MIME registry methods ***/
a8a561
+
a8a561
+  /* Obtain the MIME type registered for an extension.  The extension
a8a561
+     should not include a leading dot. */
a8a561
+  AUTF8String        getMimeTypeFromExtension(in AUTF8String extension);
a8a561
+
a8a561
+  /* Obtain the preferred application for opening a given MIME type */
a8a561
+  nsIGnomeVFSMimeApp getAppForMimeType(in AUTF8String mimeType);
a8a561
+
a8a561
+  /* Obtain a description for the given MIME type */
a8a561
+  AUTF8String        getDescriptionForMimeType(in AUTF8String mimeType);
a8a561
+
a8a561
+  /*** Misc. methods ***/
a8a561
+
a8a561
+  /* Open the given URI in the default application */
a8a561
+  void               showURI(in nsIURI uri);
a8a561
+  [noscript] void    showURIForInput(in ACString uri);
a8a561
+};
a8a561
+
a8a561
+%{C++
a8a561
+#define NS_GNOMEVFSSERVICE_CONTRACTID "@mozilla.org/gnome-vfs-service;1"
a8a561
+%}