e272ea8
From 44686bc81055c7bee7f41f9e219c35115ce8119f Mon Sep 17 00:00:00 2001
a6bffad
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
a6bffad
Date: Wed, 20 Dec 2017 15:29:39 +0000
a6bffad
Subject: [PATCH] request installation of langpack via packagekit
a6bffad
MIME-Version: 1.0
a6bffad
Content-Type: text/plain; charset=UTF-8
a6bffad
Content-Transfer-Encoding: 8bit
a6bffad
a6bffad
if ui is set to track the locale automatically and the current locale
a6bffad
has no match in installed resources but has a match in the list of
a6bffad
languages that libreoffice was compiled to contain
a6bffad
a6bffad
so e.g. de_AT locale shouldn't trigger the installation of anything if
a6bffad
langpack-de is already installed and yue_HK shouldn't trigger install
a6bffad
of anything cause that not supported (at time of writing) for libreoffice
a6bffad
a6bffad
put Fedora/RHEL/Ubuntu naming schemes in here.
a6bffad
a6bffad
I moved the lang code from svl to svtools so I could use the restart dialog
a6bffad
to prompt to restart after the langpack is installed, but packagekit's blocking
a6bffad
mode seems to be no longer blocking and control returns immediately which is a
a6bffad
change since the last time I played with this stuff, so drop the restart thing
a6bffad
for now. The lack of a blocking modal also makes the "run this on idle when there's
a6bffad
a toplevel window up and running" a bit futile, but lets keep that for now anyway.
a6bffad
a6bffad
also...
a6bffad
a6bffad
set dbus id for existing DbusSessionHelper users
a6bffad
a6bffad
Change-Id: I64329e21ae79b6607856de9781bee0274b9cb136
a6bffad
Reviewed-on: https://gerrit.libreoffice.org/46854
a6bffad
Tested-by: Jenkins <ci@libreoffice.org>
a6bffad
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
a6bffad
Tested-by: Caolán McNamara <caolanm@redhat.com>
a6bffad
(cherry picked from commit 7cf4eeed81fd333c87dedffa792f5d547b7981f0)
a6bffad
a6bffad
Change-Id: Ice731be539850338ccdd8af87839e0b4d83f01e7
a6bffad
---
a6bffad
 config_host/config_langs.h.in                      |  10 ++
a6bffad
 config_host/config_vendor.h.in                     |  10 ++
a6bffad
 configure.ac                                       |   4 +
a6bffad
 cui/source/options/optgdlg.cxx                     |   3 +-
a6bffad
 desktop/source/app/langselect.cxx                  |   3 +-
a6bffad
 include/svl/languageoptions.hxx                    |   3 -
a6bffad
 include/svtools/langhelp.hxx                       |   3 +
e272ea8
 offapi/org/freedesktop/PackageKit/XModify.idl      |  22 ++--
a6bffad
 .../registry/data/org/openoffice/Office/Common.xcu |   3 +
a6bffad
 .../schema/org/openoffice/Office/Common.xcs        |   6 +
e272ea8
 sfx2/source/appl/appserv.cxx                       |   3 +-
e272ea8
 .../sessioninstall/SyncDbusSessionHelper.cxx       |  57 +++++----
e272ea8
 .../sessioninstall/SyncDbusSessionHelper.hxx       |  20 ++--
a6bffad
 svl/source/config/languageoptions.cxx              |  33 ------
e272ea8
 svtools/source/misc/langhelp.cxx                   | 130 ++++++++++++++++++++-
e272ea8
 sw/source/uibase/app/apphdl.cxx                    |   3 +-
e272ea8
 vcl/inc/unx/fontmanager.hxx                        |   6 +-
e272ea8
 vcl/unx/generic/fontmanager/fontconfig.cxx         |  93 ++-------------
e272ea8
 vcl/unx/generic/fontmanager/fontmanager.cxx        |   2 -
e272ea8
 19 files changed, 235 insertions(+), 179 deletions(-)
a6bffad
 create mode 100644 config_host/config_langs.h.in
a6bffad
 create mode 100644 config_host/config_vendor.h.in
a6bffad
a6bffad
diff --git a/config_host/config_langs.h.in b/config_host/config_langs.h.in
a6bffad
new file mode 100644
a6bffad
index 0000000..d60a5c1
a6bffad
--- /dev/null
a6bffad
+++ b/config_host/config_langs.h.in
a6bffad
@@ -0,0 +1,10 @@
a6bffad
+/* Configuration of restriction on supported ui languages, by the
a6bffad
+ * --with-lang option.
a6bffad
+ */
a6bffad
+
a6bffad
+#ifndef CONFIG_LANGS_H
a6bffad
+#define CONFIG_LANGS_H
a6bffad
+
a6bffad
+#define WITH_LANG ""
a6bffad
+
a6bffad
+#endif
a6bffad
diff --git a/config_host/config_vendor.h.in b/config_host/config_vendor.h.in
a6bffad
new file mode 100644
a6bffad
index 0000000..3260221
a6bffad
--- /dev/null
a6bffad
+++ b/config_host/config_vendor.h.in
a6bffad
@@ -0,0 +1,10 @@
a6bffad
+/* Configuration of restriction on supported ui languages, by the
a6bffad
+ * --with-lang option.
a6bffad
+ */
a6bffad
+
a6bffad
+#ifndef CONFIG_VENDOR_H
a6bffad
+#define CONFIG_VENDOR_H
a6bffad
+
a6bffad
+#define OOO_VENDOR ""
a6bffad
+
a6bffad
+#endif
a6bffad
diff --git a/configure.ac b/configure.ac
e272ea8
index bbb47e6..55e2aa0 100644
a6bffad
--- a/configure.ac
a6bffad
+++ b/configure.ac
e272ea8
@@ -11777,6 +11777,7 @@ if test "$enable_release_build" = "" -o "$enable_release_build" = "no"; then
a6bffad
     ALL_LANGS=`echo $ALL_LANGS qtz`
a6bffad
 fi
a6bffad
 AC_SUBST(ALL_LANGS)
a6bffad
+AC_DEFINE_UNQUOTED(WITH_LANG,"$WITH_LANG")
a6bffad
 AC_SUBST(WITH_LANG)
a6bffad
 AC_SUBST(WITH_LANG_LIST)
a6bffad
 AC_SUBST(GIT_NEEDED_SUBMODULES)
e272ea8
@@ -11925,6 +11926,7 @@ else
a6bffad
     OOO_VENDOR="$with_vendor"
a6bffad
     AC_MSG_RESULT([$OOO_VENDOR])
a6bffad
 fi
a6bffad
+AC_DEFINE_UNQUOTED(OOO_VENDOR,"$OOO_VENDOR")
a6bffad
 AC_SUBST(OOO_VENDOR)
a6bffad
 
a6bffad
 if test "$_os" = "Android" ; then
e272ea8
@@ -12538,6 +12540,7 @@ AC_CONFIG_HEADERS([config_host/config_gio.h])
a6bffad
 AC_CONFIG_HEADERS([config_host/config_global.h])
a6bffad
 AC_CONFIG_HEADERS([config_host/config_gpgme.h])
a6bffad
 AC_CONFIG_HEADERS([config_host/config_java.h])
a6bffad
+AC_CONFIG_HEADERS([config_host/config_langs.h])
a6bffad
 AC_CONFIG_HEADERS([config_host/config_lgpl.h])
a6bffad
 AC_CONFIG_HEADERS([config_host/config_liblangtag.h])
a6bffad
 AC_CONFIG_HEADERS([config_host/config_locales.h])
e272ea8
@@ -12549,6 +12552,7 @@ AC_CONFIG_HEADERS([config_host/config_options.h])
a6bffad
 AC_CONFIG_HEADERS([config_host/config_options_calc.h])
a6bffad
 AC_CONFIG_HEADERS([config_host/config_test.h])
a6bffad
 AC_CONFIG_HEADERS([config_host/config_typesizes.h])
a6bffad
+AC_CONFIG_HEADERS([config_host/config_vendor.h])
a6bffad
 AC_CONFIG_HEADERS([config_host/config_vcl.h])
a6bffad
 AC_CONFIG_HEADERS([config_host/config_vclplug.h])
a6bffad
 AC_CONFIG_HEADERS([config_host/config_version.h])
a6bffad
diff --git a/cui/source/options/optgdlg.cxx b/cui/source/options/optgdlg.cxx
a6bffad
index 1c90931..7965179 100644
a6bffad
--- a/cui/source/options/optgdlg.cxx
a6bffad
+++ b/cui/source/options/optgdlg.cxx
a6bffad
@@ -21,6 +21,7 @@
a6bffad
 #include <svl/zforlist.hxx>
a6bffad
 #include <svl/currencytable.hxx>
a6bffad
 #include <svtools/grfmgr.hxx>
a6bffad
+#include <svtools/langhelp.hxx>
a6bffad
 #include <svl/flagitem.hxx>
a6bffad
 #include <sfx2/dispatch.hxx>
a6bffad
 #include <unotools/lingucfg.hxx>
a6bffad
@@ -1122,7 +1123,7 @@ namespace
a6bffad
     LanguageTag GetInstalledLocaleForSystemUILanguage()
a6bffad
     {
a6bffad
         css::uno::Sequence<OUString> inst(officecfg::Setup::Office::InstalledLocales::get()->getElementNames());
a6bffad
-        return LanguageTag(getInstalledLocaleForSystemUILanguage(inst)).makeFallback();
a6bffad
+        return LanguageTag(getInstalledLocaleForSystemUILanguage(inst, false)).makeFallback();
a6bffad
     }
a6bffad
 }
a6bffad
 
a6bffad
diff --git a/desktop/source/app/langselect.cxx b/desktop/source/app/langselect.cxx
a6bffad
index 4ce877a..86ce743 100644
a6bffad
--- a/desktop/source/app/langselect.cxx
a6bffad
+++ b/desktop/source/app/langselect.cxx
a6bffad
@@ -37,6 +37,7 @@
a6bffad
 #include <sal/log.hxx>
a6bffad
 #include <sal/types.h>
a6bffad
 #include <svl/languageoptions.hxx>
a6bffad
+#include <svtools/langhelp.hxx>
a6bffad
 
a6bffad
 #include <app.hxx>
a6bffad
 
a6bffad
@@ -103,7 +104,7 @@ bool prepareLocale() {
a6bffad
         }
a6bffad
     }
a6bffad
     if (locale.isEmpty()) {
a6bffad
-        locale = getInstalledLocaleForSystemUILanguage(inst);
a6bffad
+        locale = getInstalledLocaleForSystemUILanguage(inst, true);
a6bffad
     }
a6bffad
     if (locale.isEmpty()) {
a6bffad
         return false;
a6bffad
diff --git a/include/svl/languageoptions.hxx b/include/svl/languageoptions.hxx
a6bffad
index f386cb6..6de8eb5 100644
a6bffad
--- a/include/svl/languageoptions.hxx
a6bffad
+++ b/include/svl/languageoptions.hxx
a6bffad
@@ -131,9 +131,6 @@ public:
a6bffad
     bool            isCJKKeyboardLayoutInstalled() const;
a6bffad
 };
a6bffad
 
a6bffad
-OUString SVL_DLLPUBLIC getInstalledLocaleForLanguage(css::uno::Sequence<OUString> const & installed, OUString const & locale);
a6bffad
-OUString SVL_DLLPUBLIC getInstalledLocaleForSystemUILanguage(css::uno::Sequence<OUString> const & installed);
a6bffad
-
a6bffad
 #endif // INCLUDED_SVL_LANGUAGEOPTIONS_HXX
a6bffad
 
a6bffad
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
a6bffad
diff --git a/include/svtools/langhelp.hxx b/include/svtools/langhelp.hxx
a6bffad
index a3a84df..db22bb3 100644
a6bffad
--- a/include/svtools/langhelp.hxx
a6bffad
+++ b/include/svtools/langhelp.hxx
a6bffad
@@ -22,6 +22,9 @@
a6bffad
  */
a6bffad
 SVT_DLLPUBLIC void localizeWebserviceURI( OUString& io_rURI );
a6bffad
 
a6bffad
+OUString SVT_DLLPUBLIC getInstalledLocaleForLanguage(css::uno::Sequence<OUString> const & installed, OUString const & locale);
a6bffad
+OUString SVT_DLLPUBLIC getInstalledLocaleForSystemUILanguage(css::uno::Sequence<OUString> const & installed, bool bRequestInstallIfMissing);
a6bffad
+
a6bffad
 #endif
a6bffad
 
a6bffad
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
e272ea8
diff --git a/offapi/org/freedesktop/PackageKit/XModify.idl b/offapi/org/freedesktop/PackageKit/XModify.idl
e272ea8
index a712bb5..69544e9 100644
e272ea8
--- a/offapi/org/freedesktop/PackageKit/XModify.idl
e272ea8
+++ b/offapi/org/freedesktop/PackageKit/XModify.idl
e272ea8
@@ -22,7 +22,7 @@ module PackageKit
e272ea8
  *  The interface used for modifying the package database.
e272ea8
  *
e272ea8
  * @sa
e272ea8
- * https://git.gnome.org/browse/gnome-software/tree/src/org.freedesktop.PackageKit.xml
e272ea8
+ * https://git.gnome.org/browse/gnome-software/tree/src/org.freedesktop.PackageKit.Modify2.xml
e272ea8
  * for documentation of the corresponding D-Bus interface
e272ea8
  */
e272ea8
 interface XModify : com::sun::star::uno::XInterface
e272ea8
@@ -32,70 +32,70 @@ interface XModify : com::sun::star::uno::XInterface
e272ea8
      * @since LibreOffice 4.0
e272ea8
      */
e272ea8
 
e272ea8
-    void InstallPackageFiles( [in] unsigned long xid, [in] sequence< string > files, [in] string interaction);
e272ea8
+    void InstallPackageFiles([in] sequence< string > files, [in] string interaction);
e272ea8
 
e272ea8
     /**
e272ea8
      * Installs sequence< string > packages to provide sequence< string > files.
e272ea8
      * @since LibreOffice 4.0
e272ea8
      */
e272ea8
 
e272ea8
-    void InstallProvideFiles( [in] unsigned long xid, [in] sequence< string > files, [in] string interaction);
e272ea8
+    void InstallProvideFiles([in] sequence< string > files, [in] string interaction);
e272ea8
 
e272ea8
     /**
e272ea8
      * Installs sequence< string > packages to provide sequence< string > files.
e272ea8
      * @since LibreOffice 4.0
e272ea8
      */
e272ea8
 
e272ea8
-    void InstallCatalogs( [in] unsigned long xid, [in] sequence< string > files, [in] string interaction);
e272ea8
+    void InstallCatalogs([in] sequence< string > files, [in] string interaction);
e272ea8
 
e272ea8
     /**
e272ea8
      * Installs sequence< string > packages from a configured software source.
e272ea8
      * @since LibreOffice 4.0
e272ea8
      */
e272ea8
 
e272ea8
-    void InstallPackageNames( [in] unsigned long xid, [in] sequence< string > packages, [in] string interaction);
e272ea8
+    void InstallPackageNames([in] sequence< string > packages, [in] string interaction);
e272ea8
 
e272ea8
     /**
e272ea8
      * Installs mimetype handlers from a configured software source.
e272ea8
      * @since LibreOffice 4.0
e272ea8
      */
e272ea8
 
e272ea8
-    void InstallMimeTypes( [in] unsigned long xid, [in] sequence< string > mimeTypes, [in] string interaction);
e272ea8
+    void InstallMimeTypes([in] sequence< string > mimeTypes, [in] string interaction);
e272ea8
 
e272ea8
     /**
e272ea8
      * Installs fontconfig resources ( [in] usually fonts) from a configured software source.
e272ea8
      * @since LibreOffice 4.0
e272ea8
      */
e272ea8
 
e272ea8
-    void InstallFontconfigResources( [in] unsigned long xid, [in] sequence< string > resources, [in] string interaction);
e272ea8
+    void InstallFontconfigResources([in] sequence< string > resources, [in] string interaction);
e272ea8
 
e272ea8
     /**
e272ea8
      * Installs GStreamer resources ( [in] usually codecs) from a configured software source.
e272ea8
      * @since LibreOffice 4.0
e272ea8
      */
e272ea8
 
e272ea8
-    void InstallGStreamerResources( [in] unsigned long xid, [in] sequence< string > resources, [in] string interaction);
e272ea8
+    void InstallGStreamerResources([in] sequence< string > resources, [in] string interaction);
e272ea8
 
e272ea8
     /**
e272ea8
      * Installs resources of a given type from a configured software source.
e272ea8
      * @since LibreOffice 4.0
e272ea8
      */
e272ea8
 
e272ea8
-    void InstallResources( [in] unsigned long xid, [in] sequence< string > types, [in] sequence< string > resources, [in] string interaction);
e272ea8
+    void InstallResources([in] sequence< string > types, [in] sequence< string > resources, [in] string interaction);
e272ea8
 
e272ea8
     /**
e272ea8
      * Removes sequence< string > packages that provide the given local sequence< string > files.
e272ea8
      * @since LibreOffice 4.0
e272ea8
      */
e272ea8
 
e272ea8
-    void RemovePackageByFiles( [in] unsigned long xid, [in] sequence< string > files, [in] string interaction);
e272ea8
+    void RemovePackageByFiles([in] sequence< string > files, [in] string interaction);
e272ea8
 
e272ea8
     /**
e272ea8
      * Installs printer drivers from a configured software source.
e272ea8
      * @since LibreOffice 4.0
e272ea8
      */
e272ea8
 
e272ea8
-    void InstallPrinterDrivers( [in] unsigned long xid, [in] sequence< string > files, [in] string interaction);
e272ea8
+    void InstallPrinterDrivers([in] sequence< string > files, [in] string interaction);
a6bffad
 };
a6bffad
 
e272ea8
 } ; // PackageKit
a6bffad
diff --git a/officecfg/registry/data/org/openoffice/Office/Common.xcu b/officecfg/registry/data/org/openoffice/Office/Common.xcu
a6bffad
index 6b94ff9..26d1ba0 100644
a6bffad
--- a/officecfg/registry/data/org/openoffice/Office/Common.xcu
a6bffad
+++ b/officecfg/registry/data/org/openoffice/Office/Common.xcu
a6bffad
@@ -535,6 +535,9 @@
a6bffad
       <prop oor:name="EnableFontInstallation" oor:type="xs:boolean">
a6bffad
         <value install:module="unx">true</value>
a6bffad
       </prop>
a6bffad
+      <prop oor:name="EnableLangpackInstallation" oor:type="xs:boolean">
a6bffad
+        <value install:module="unx">true</value>
a6bffad
+      </prop>
a6bffad
   </node>
a6bffad
   <node oor:name="Classification">
a6bffad
       <prop oor:name="Policy" oor:type="xs:short">
a6bffad
diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
a6bffad
index f9816fc..2884179 100644
a6bffad
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
a6bffad
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
a6bffad
@@ -6382,6 +6382,12 @@
a6bffad
         </info>
a6bffad
         <value>true</value>
a6bffad
       </prop>
a6bffad
+      <prop oor:name="EnableLangpackInstallation" oor:type="xs:boolean" oor:nillable="false">
a6bffad
+        <info>
a6bffad
+           <desc>Specifies if missing langpack installation should be triggered.</desc>
a6bffad
+        </info>
a6bffad
+        <value>true</value>
a6bffad
+      </prop>
a6bffad
     </group>
a6bffad
     <group oor:name="Classification">
a6bffad
       <info>
a6bffad
diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx
e272ea8
index 1e2a2ec..e48e5aa 100644
a6bffad
--- a/sfx2/source/appl/appserv.cxx
a6bffad
+++ b/sfx2/source/appl/appserv.cxx
a6bffad
@@ -59,6 +59,7 @@
a6bffad
 #include <unotools/configmgr.hxx>
a6bffad
 #include <tools/diagnose_ex.h>
a6bffad
 #include <vcl/layout.hxx>
a6bffad
+#include <vcl/sysdata.hxx>
a6bffad
 #include <svl/intitem.hxx>
a6bffad
 #include <svl/eitem.hxx>
a6bffad
 #include <svl/stritem.hxx>
e272ea8
@@ -196,7 +197,7 @@ namespace
a6bffad
                 using namespace svtools;
a6bffad
                 Reference< XSyncDbusSessionHelper > xSyncDbusSessionHelper(SyncDbusSessionHelper::create(comphelper::getProcessComponentContext()));
a6bffad
                 Sequence< OUString > vPackages { "libreoffice-base" };
a6bffad
-                xSyncDbusSessionHelper->InstallPackageNames(0, vPackages, OUString());
e272ea8
+                xSyncDbusSessionHelper->InstallPackageNames(vPackages, OUString());
a6bffad
                 // Ill be back (hopefully)!
a6bffad
                 SolarMutexGuard aGuard;
a6bffad
                 executeRestartDialog(comphelper::getProcessComponentContext(), nullptr, RESTART_REASON_BIBLIOGRAPHY_INSTALL);
e272ea8
diff --git a/shell/source/sessioninstall/SyncDbusSessionHelper.cxx b/shell/source/sessioninstall/SyncDbusSessionHelper.cxx
e272ea8
index a1211f7..1938077 100644
e272ea8
--- a/shell/source/sessioninstall/SyncDbusSessionHelper.cxx
e272ea8
+++ b/shell/source/sessioninstall/SyncDbusSessionHelper.cxx
e272ea8
@@ -18,7 +18,7 @@ using namespace ::com::sun::star::uno;
a6bffad
 
e272ea8
 namespace
e272ea8
 {
e272ea8
-    struct GVariantDeleter { void operator()(GVariant* pV) { g_variant_unref(pV); } };
e272ea8
+    struct GVariantDeleter { void operator()(GVariant* pV) { if (pV) g_variant_unref(pV); } };
e272ea8
     struct GVariantBuilderDeleter { void operator()(GVariantBuilder* pVB) { g_variant_builder_unref(pVB); } };
e272ea8
     template <typename T> struct GObjectDeleter { void operator()(T* pO) { g_object_unref(pO); } };
e272ea8
     class GErrorWrapper
e272ea8
@@ -55,8 +55,15 @@ namespace
e272ea8
         return proxy;
e272ea8
     }
e272ea8
 
e272ea8
+    static GVariant* pk_make_platform_data()
e272ea8
+    {
e272ea8
+        GVariantBuilder builder;
e272ea8
+        g_variant_builder_init(&builder, G_VARIANT_TYPE("a{sv}"));
e272ea8
+        return g_variant_builder_end(&builder);
e272ea8
+    }
e272ea8
+
e272ea8
 void request(
e272ea8
-    char const * method, sal_uInt32 xid,
e272ea8
+    char const * method,
e272ea8
     css::uno::Sequence<OUString> const & resources,
e272ea8
     OUString const & interaction)
e272ea8
 {
e272ea8
@@ -70,14 +77,14 @@ void request(
e272ea8
     }
e272ea8
     auto iactUtf8(OUStringToOString(interaction, RTL_TEXTENCODING_UTF8));
e272ea8
     std::shared_ptr<GDBusProxy> proxy(
e272ea8
-        lcl_GetPackageKitProxy("Modify"), GObjectDeleter<GDBusProxy>());
e272ea8
+        lcl_GetPackageKitProxy("Modify2"), GObjectDeleter<GDBusProxy>());
e272ea8
     GErrorWrapper error;
e272ea8
-    g_dbus_proxy_call_sync(
e272ea8
+    std::shared_ptr<GVariant> result(g_dbus_proxy_call_sync(
e272ea8
         proxy.get(), method,
e272ea8
         g_variant_new(
e272ea8
-            "(uass)", static_cast<guint32>(xid), builder.get(),
e272ea8
-            iactUtf8.getStr()),
e272ea8
-        G_DBUS_CALL_FLAGS_NONE, -1, nullptr, &error.getRef());
e272ea8
+            "(asss@a{sv})", builder.get(), iactUtf8.getStr(),
e272ea8
+            "libreoffice-startcenter.desktop", pk_make_platform_data()),
e272ea8
+        G_DBUS_CALL_FLAGS_NONE, -1, nullptr, &error.getRef()), GVariantDeleter());
e272ea8
 }
e272ea8
 
e272ea8
 }
e272ea8
@@ -92,66 +99,66 @@ namespace shell { namespace sessioninstall
a6bffad
     }
e272ea8
 
e272ea8
 void SyncDbusSessionHelper::InstallPackageFiles(
e272ea8
-    sal_uInt32 xid, css::uno::Sequence<OUString> const & files,
e272ea8
+    css::uno::Sequence<OUString> const & files,
e272ea8
     OUString const & interaction)
e272ea8
 {
e272ea8
-    request("InstallPackageFiles", xid, files, interaction);
e272ea8
+    request("InstallPackageFiles", files, interaction);
e272ea8
 }
e272ea8
 
e272ea8
 void SyncDbusSessionHelper::InstallProvideFiles(
e272ea8
-    sal_uInt32 xid, css::uno::Sequence<OUString> const & files,
e272ea8
+    css::uno::Sequence<OUString> const & files,
e272ea8
     OUString const & interaction)
e272ea8
 {
e272ea8
-    request("InstallProvideFiles", xid, files, interaction);
e272ea8
+    request("InstallProvideFiles", files, interaction);
e272ea8
 }
e272ea8
 
e272ea8
 void SyncDbusSessionHelper::InstallCatalogs(
e272ea8
-    sal_uInt32 xid, css::uno::Sequence<OUString> const & files,
e272ea8
+    css::uno::Sequence<OUString> const & files,
e272ea8
     OUString const & interaction)
e272ea8
 {
e272ea8
-    request("InstallCatalogs", xid, files, interaction);
e272ea8
+    request("InstallCatalogs", files, interaction);
e272ea8
 }
e272ea8
 
e272ea8
 void SyncDbusSessionHelper::InstallPackageNames(
e272ea8
-    sal_uInt32 xid, css::uno::Sequence<OUString> const & packages,
e272ea8
+    css::uno::Sequence<OUString> const & packages,
e272ea8
     OUString const & interaction)
e272ea8
 {
e272ea8
-    request("InstallPackageNames", xid, packages, interaction);
e272ea8
+    request("InstallPackageNames", packages, interaction);
e272ea8
 }
e272ea8
 
e272ea8
 void SyncDbusSessionHelper::InstallMimeTypes(
e272ea8
-    sal_uInt32 xid, css::uno::Sequence<OUString> const & mimeTypes,
e272ea8
+    css::uno::Sequence<OUString> const & mimeTypes,
e272ea8
     OUString const & interaction)
e272ea8
 {
e272ea8
-    request("InstallMimeTypes", xid, mimeTypes, interaction);
e272ea8
+    request("InstallMimeTypes", mimeTypes, interaction);
e272ea8
 }
e272ea8
 
e272ea8
 void SyncDbusSessionHelper::InstallFontconfigResources(
e272ea8
-    sal_uInt32 xid, css::uno::Sequence<OUString> const & resources,
e272ea8
+    css::uno::Sequence<OUString> const & resources,
e272ea8
     OUString const & interaction)
e272ea8
 {
e272ea8
-    request("InstallFontconfigResources", xid, resources, interaction);
e272ea8
+    request("InstallFontconfigResources", resources, interaction);
e272ea8
 }
e272ea8
 
e272ea8
 void SyncDbusSessionHelper::InstallGStreamerResources(
e272ea8
-    sal_uInt32 xid, css::uno::Sequence<OUString> const & resources,
e272ea8
+    css::uno::Sequence<OUString> const & resources,
e272ea8
     OUString const & interaction)
e272ea8
 {
e272ea8
-    request("InstallGStreamerResources", xid, resources, interaction);
e272ea8
+    request("InstallGStreamerResources", resources, interaction);
a6bffad
 }
e272ea8
 
e272ea8
 void SyncDbusSessionHelper::RemovePackageByFiles(
e272ea8
-    sal_uInt32 xid, css::uno::Sequence<OUString> const & files,
e272ea8
+    css::uno::Sequence<OUString> const & files,
e272ea8
     OUString const & interaction)
e272ea8
 {
e272ea8
-    request("RemovePackageByFiles", xid, files, interaction);
e272ea8
+    request("RemovePackageByFiles", files, interaction);
e272ea8
 }
e272ea8
 
e272ea8
 void SyncDbusSessionHelper::InstallPrinterDrivers(
e272ea8
-    sal_uInt32 xid, css::uno::Sequence<OUString> const & files,
e272ea8
+    css::uno::Sequence<OUString> const & files,
e272ea8
     OUString const & interaction)
e272ea8
 {
e272ea8
-    request("InstallPrinteDrivers", xid, files, interaction);
e272ea8
+    request("InstallPrinteDrivers", files, interaction);
e272ea8
 }
e272ea8
 
e272ea8
     void SAL_CALL SyncDbusSessionHelper::IsInstalled( const OUString& sPackagename, const OUString& sInteraction, sal_Bool& o_isInstalled )
e272ea8
diff --git a/shell/source/sessioninstall/SyncDbusSessionHelper.hxx b/shell/source/sessioninstall/SyncDbusSessionHelper.hxx
e272ea8
index 731b649..72b17ba 100644
e272ea8
--- a/shell/source/sessioninstall/SyncDbusSessionHelper.hxx
e272ea8
+++ b/shell/source/sessioninstall/SyncDbusSessionHelper.hxx
e272ea8
@@ -23,26 +23,26 @@ namespace shell { namespace sessioninstall
e272ea8
             SyncDbusSessionHelper(css::uno::Reference< css::uno::XComponentContext> const&);
e272ea8
 
e272ea8
             // XModify Methods
e272ea8
-            virtual void SAL_CALL InstallPackageFiles( ::sal_uInt32 xid, const css::uno::Sequence< OUString >& files, const OUString& interaction ) override;
e272ea8
+            virtual void SAL_CALL InstallPackageFiles( const css::uno::Sequence< OUString >& files, const OUString& interaction ) override;
e272ea8
 
e272ea8
-            virtual void SAL_CALL InstallProvideFiles( ::sal_uInt32 xid, const css::uno::Sequence< OUString >& files, const OUString& interaction ) override;
e272ea8
+            virtual void SAL_CALL InstallProvideFiles( const css::uno::Sequence< OUString >& files, const OUString& interaction ) override;
e272ea8
 
e272ea8
-            virtual void SAL_CALL InstallCatalogs( ::sal_uInt32 xid, const css::uno::Sequence< OUString >& files, const OUString& interaction ) override;
e272ea8
+            virtual void SAL_CALL InstallCatalogs( const css::uno::Sequence< OUString >& files, const OUString& interaction ) override;
e272ea8
 
e272ea8
-            virtual void SAL_CALL InstallPackageNames( ::sal_uInt32 xid, const css::uno::Sequence< OUString >& packages, const OUString& interaction ) override;
e272ea8
+            virtual void SAL_CALL InstallPackageNames( const css::uno::Sequence< OUString >& packages, const OUString& interaction ) override;
e272ea8
 
e272ea8
-            virtual void SAL_CALL InstallMimeTypes( ::sal_uInt32 xid, const css::uno::Sequence< OUString >& mimeTypes, const OUString& interaction ) override;
e272ea8
+            virtual void SAL_CALL InstallMimeTypes( const css::uno::Sequence< OUString >& mimeTypes, const OUString& interaction ) override;
e272ea8
 
e272ea8
-            virtual void SAL_CALL InstallFontconfigResources( ::sal_uInt32 xid, const css::uno::Sequence< OUString >& resources, const OUString& interaction ) override;
e272ea8
+            virtual void SAL_CALL InstallFontconfigResources( const css::uno::Sequence< OUString >& resources, const OUString& interaction ) override;
e272ea8
 
e272ea8
-            virtual void SAL_CALL InstallGStreamerResources( ::sal_uInt32 xid, const css::uno::Sequence< OUString >& resources, const OUString& interaction ) override;
e272ea8
+            virtual void SAL_CALL InstallGStreamerResources( const css::uno::Sequence< OUString >& resources, const OUString& interaction ) override;
e272ea8
 
e272ea8
-            virtual void SAL_CALL InstallResources( ::sal_uInt32 /* xid */, const css::uno::Sequence< OUString >& /* types */, const css::uno::Sequence< OUString >& /* resources */, const OUString& /* interaction */ ) override
e272ea8
+            virtual void SAL_CALL InstallResources( const css::uno::Sequence< OUString >& /* types */, const css::uno::Sequence< OUString >& /* resources */, const OUString& /* interaction */ ) override
e272ea8
                 { throw css::uno::RuntimeException(); } // not implemented
e272ea8
 
e272ea8
-            virtual void SAL_CALL RemovePackageByFiles( ::sal_uInt32 xid, const css::uno::Sequence< OUString >& files, const OUString& interaction ) override;
e272ea8
+            virtual void SAL_CALL RemovePackageByFiles( const css::uno::Sequence< OUString >& files, const OUString& interaction ) override;
e272ea8
 
e272ea8
-            virtual void SAL_CALL InstallPrinterDrivers( ::sal_uInt32 xid, const css::uno::Sequence< OUString >& files, const OUString& interaction ) override;
e272ea8
+            virtual void SAL_CALL InstallPrinterDrivers( const css::uno::Sequence< OUString >& files, const OUString& interaction ) override;
e272ea8
 
e272ea8
             // XQuery Methods
e272ea8
             virtual void SAL_CALL IsInstalled( const OUString& /* package_name */, const OUString& /* interaction */, sal_Bool& /* installed */ ) override;
a6bffad
diff --git a/svl/source/config/languageoptions.cxx b/svl/source/config/languageoptions.cxx
a6bffad
index 9f9fe45..74af031 100644
a6bffad
--- a/svl/source/config/languageoptions.cxx
a6bffad
+++ b/svl/source/config/languageoptions.cxx
a6bffad
@@ -27,7 +27,6 @@
a6bffad
 #include <rtl/instance.hxx>
a6bffad
 #include <com/sun/star/i18n/ScriptType.hpp>
a6bffad
 #include <unotools/syslocale.hxx>
a6bffad
-#include <officecfg/System.hxx>
a6bffad
 
a6bffad
 #ifdef _WIN32
a6bffad
 #if !defined WIN32_LEAN_AND_MEAN
a6bffad
@@ -256,41 +255,9 @@ bool SvtSystemLanguageOptions::isKeyboardLayoutTypeInstalled(sal_Int16 scriptTyp
a6bffad
     return isInstalled;
a6bffad
 }
a6bffad
 
a6bffad
-
a6bffad
 bool SvtSystemLanguageOptions::isCJKKeyboardLayoutInstalled() const
a6bffad
 {
a6bffad
     return isKeyboardLayoutTypeInstalled(css::i18n::ScriptType::ASIAN);
a6bffad
 }
a6bffad
 
a6bffad
-OUString getInstalledLocaleForLanguage(css::uno::Sequence<OUString> const & installed, OUString const & locale)
a6bffad
-{
a6bffad
-    if (locale.isEmpty())
a6bffad
-        return OUString();  // do not attempt to resolve anything
a6bffad
-
a6bffad
-    for (sal_Int32 i = 0; i != installed.getLength(); ++i) {
a6bffad
-        if (installed[i] == locale) {
a6bffad
-            return installed[i];
a6bffad
-        }
a6bffad
-    }
a6bffad
-    std::vector<OUString> fallbacks(LanguageTag(locale).getFallbackStrings(false));
a6bffad
-    for (OUString & rf : fallbacks) {
a6bffad
-        for (sal_Int32 i = 0; i != installed.getLength(); ++i) {
a6bffad
-            if (installed[i] == rf) {
a6bffad
-                return installed[i];
a6bffad
-            }
a6bffad
-        }
a6bffad
-    }
a6bffad
-    return OUString();
a6bffad
-}
a6bffad
-
a6bffad
-OUString getInstalledLocaleForSystemUILanguage(const css::uno::Sequence<OUString>& rLocaleElementNames)
a6bffad
-{
a6bffad
-    OUString locale = getInstalledLocaleForLanguage(rLocaleElementNames, officecfg::System::L10N::UILocale::get());
a6bffad
-    if (locale.isEmpty())
a6bffad
-        locale = getInstalledLocaleForLanguage(rLocaleElementNames, "en-US");
a6bffad
-    if (locale.isEmpty() && rLocaleElementNames.hasElements())
a6bffad
-        locale = rLocaleElementNames[0];
a6bffad
-    return locale;
a6bffad
-}
a6bffad
-
a6bffad
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
a6bffad
diff --git a/svtools/source/misc/langhelp.cxx b/svtools/source/misc/langhelp.cxx
e272ea8
index 16a3a1d..1e4c5c5 100644
a6bffad
--- a/svtools/source/misc/langhelp.cxx
a6bffad
+++ b/svtools/source/misc/langhelp.cxx
a6bffad
@@ -7,12 +7,20 @@
a6bffad
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
a6bffad
  */
a6bffad
 
a6bffad
-
a6bffad
+#include <comphelper/sequence.hxx>
a6bffad
+#include <i18nlangtag/mslangid.hxx>
a6bffad
+#include <officecfg/Office/Common.hxx>
a6bffad
+#include <officecfg/System.hxx>
a6bffad
+#include <org/freedesktop/PackageKit/SyncDbusSessionHelper.hpp>
a6bffad
+#include <rtl/ustring.hxx>
a6bffad
 #include <svtools/langhelp.hxx>
a6bffad
-
a6bffad
+#include <vcl/idle.hxx>
a6bffad
 #include <vcl/svapp.hxx>
a6bffad
+#include <vcl/sysdata.hxx>
a6bffad
 #include <vcl/settings.hxx>
a6bffad
-#include <rtl/ustring.hxx>
a6bffad
+#include <vcl/window.hxx>
a6bffad
+#include <config_langs.h>
a6bffad
+#include <config_vendor.h>
a6bffad
 
a6bffad
 void localizeWebserviceURI( OUString& rURI )
a6bffad
 {
e272ea8
@@ -33,4 +41,120 @@ void localizeWebserviceURI( OUString& rURI )
a6bffad
     rURI += aLang;
a6bffad
 }
a6bffad
 
a6bffad
+OUString getInstalledLocaleForLanguage(css::uno::Sequence<OUString> const & installed, OUString const & locale)
a6bffad
+{
a6bffad
+    if (locale.isEmpty())
a6bffad
+        return OUString();  // do not attempt to resolve anything
a6bffad
+
a6bffad
+    for (sal_Int32 i = 0; i != installed.getLength(); ++i) {
a6bffad
+        if (installed[i] == locale) {
a6bffad
+            return installed[i];
a6bffad
+        }
a6bffad
+    }
a6bffad
+    std::vector<OUString> fallbacks(LanguageTag(locale).getFallbackStrings(false));
a6bffad
+    for (OUString & rf : fallbacks) {
a6bffad
+        for (sal_Int32 i = 0; i != installed.getLength(); ++i) {
a6bffad
+            if (installed[i] == rf) {
a6bffad
+                return installed[i];
a6bffad
+            }
a6bffad
+        }
a6bffad
+    }
a6bffad
+    return OUString();
a6bffad
+}
a6bffad
+
a6bffad
+static std::unique_ptr<Idle> xLangpackInstaller;
a6bffad
+
a6bffad
+class InstallLangpack : public Idle
a6bffad
+{
a6bffad
+    std::vector<OUString> m_aPackages;
a6bffad
+public:
a6bffad
+    explicit InstallLangpack(const std::vector<OUString>& rPackages)
a6bffad
+        : Idle("install langpack")
a6bffad
+        , m_aPackages(rPackages)
a6bffad
+    {
a6bffad
+        SetPriority(TaskPriority::LOWEST);
a6bffad
+    }
a6bffad
+
a6bffad
+    virtual void Invoke() override
a6bffad
+    {
a6bffad
+        vcl::Window* pTopWindow = Application::GetActiveTopWindow();
a6bffad
+        if (!pTopWindow)
a6bffad
+            pTopWindow = Application::GetFirstTopLevelWindow();
a6bffad
+        if (!pTopWindow)
a6bffad
+        {
a6bffad
+            Start();
a6bffad
+            return;
a6bffad
+        }
a6bffad
+        try
a6bffad
+        {
a6bffad
+            using namespace org::freedesktop::PackageKit;
a6bffad
+            css::uno::Reference<XSyncDbusSessionHelper> xSyncDbusSessionHelper(SyncDbusSessionHelper::create(comphelper::getProcessComponentContext()));
e272ea8
+            xSyncDbusSessionHelper->InstallPackageNames(comphelper::containerToSequence(m_aPackages), OUString());
a6bffad
+        }
a6bffad
+        catch (const css::uno::Exception& e)
a6bffad
+        {
a6bffad
+            SAL_INFO("svl", "trying to install a LibreOffice langpack, caught " << e);
a6bffad
+        }
a6bffad
+        xLangpackInstaller.reset();
a6bffad
+    }
a6bffad
+};
a6bffad
+
a6bffad
+OUString getInstalledLocaleForSystemUILanguage(const css::uno::Sequence<OUString>& rLocaleElementNames, bool bRequestInstallIfMissing)
a6bffad
+{
a6bffad
+    OUString wantedLocale = officecfg::System::L10N::UILocale::get();
a6bffad
+    OUString locale = getInstalledLocaleForLanguage(rLocaleElementNames, wantedLocale);
a6bffad
+    if (bRequestInstallIfMissing && locale.isEmpty() && !wantedLocale.isEmpty() && !Application::IsHeadlessModeEnabled() &&
a6bffad
+        officecfg::Office::Common::PackageKit::EnableLangpackInstallation::get())
a6bffad
+    {
a6bffad
+        LanguageTag aWantedTag(wantedLocale);
a6bffad
+        if (aWantedTag.getLanguage() != "en")
a6bffad
+        {
a6bffad
+            // We try these bases + the exact locale + fallback locale.
a6bffad
+            //
a6bffad
+            // The theory is that we can request a bunch of packages
a6bffad
+            // and it's a success if one of them is available
a6bffad
+            std::vector<OUString> aPackages;
a6bffad
+            OUString sAvailableLocales(WITH_LANG);
a6bffad
+            std::vector<OUString> aAvailable;
a6bffad
+            sal_Int32 nIndex = 0;
a6bffad
+            do
a6bffad
+            {
a6bffad
+                aAvailable.emplace_back(sAvailableLocales.getToken(0, ' ', nIndex));
a6bffad
+            }
a6bffad
+            while (nIndex >= 0);
a6bffad
+            OUString install = getInstalledLocaleForLanguage(comphelper::containerToSequence(aAvailable), wantedLocale);
a6bffad
+            if (!install.isEmpty() && install != "en-US")
a6bffad
+            {
a6bffad
+                if (strcmp(OOO_VENDOR, "Red Hat, Inc.") == 0 || strcmp(OOO_VENDOR, "The Fedora Project") == 0)
a6bffad
+                {
a6bffad
+                    // langpack is the typical Fedora/RHEL naming convention
a6bffad
+                    LanguageType eType = aWantedTag.getLanguageType();
a6bffad
+                    if (MsLangId::isSimplifiedChinese(eType))
a6bffad
+                        aPackages.emplace_back("libreoffice-langpack-zh-Hans");
a6bffad
+                    else if (MsLangId::isTraditionalChinese(eType))
a6bffad
+                        aPackages.emplace_back("libreoffice-langpack-zh-Hant");
a6bffad
+                    else
a6bffad
+                        aPackages.emplace_back("libreoffice-langpack-" + install);
a6bffad
+                }
a6bffad
+                //Debian would be: "The Document Foundation/Debian"
a6bffad
+                else if (strcmp(OOO_VENDOR, "The Document Foundation, Debian and Ubuntu") == 0)
a6bffad
+                {
a6bffad
+                    // l10n is the typical Debian/Ubuntu naming convention
a6bffad
+                    aPackages.emplace_back("libreoffice-l10n-" + install);
a6bffad
+                }
a6bffad
+            }
a6bffad
+            if (!aPackages.empty())
a6bffad
+            {
a6bffad
+                xLangpackInstaller.reset(new InstallLangpack(aPackages));
a6bffad
+                xLangpackInstaller->Start();
a6bffad
+            }
a6bffad
+        }
a6bffad
+    }
a6bffad
+    if (locale.isEmpty())
a6bffad
+        locale = getInstalledLocaleForLanguage(rLocaleElementNames, "en-US");
a6bffad
+    if (locale.isEmpty() && rLocaleElementNames.hasElements())
a6bffad
+        locale = rLocaleElementNames[0];
a6bffad
+    return locale;
a6bffad
+}
a6bffad
+
a6bffad
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
a6bffad
diff --git a/sw/source/uibase/app/apphdl.cxx b/sw/source/uibase/app/apphdl.cxx
e272ea8
index 467112e..6986807 100644
a6bffad
--- a/sw/source/uibase/app/apphdl.cxx
a6bffad
+++ b/sw/source/uibase/app/apphdl.cxx
a6bffad
@@ -44,6 +44,7 @@
a6bffad
 #include <svl/ctloptions.hxx>
a6bffad
 #include <unotools/useroptions.hxx>
a6bffad
 #include <vcl/msgbox.hxx>
a6bffad
+#include <vcl/sysdata.hxx>
a6bffad
 #include <vcl/wrkwin.hxx>
a6bffad
 #include <svx/insctrl.hxx>
a6bffad
 #include <svx/selctrl.hxx>
e272ea8
@@ -420,7 +421,7 @@ void SwMailMergeWizardExecutor::ExecuteMailMergeWizard( const SfxItemSet * pArgs
a6bffad
             using namespace svtools;
a6bffad
             css::uno::Reference< XSyncDbusSessionHelper > xSyncDbusSessionHelper(SyncDbusSessionHelper::create(comphelper::getProcessComponentContext()));
a6bffad
             const css::uno::Sequence< OUString > vPackages{ "libreoffice-base" };
a6bffad
-            xSyncDbusSessionHelper->InstallPackageNames(0, vPackages, OUString());
e272ea8
+            xSyncDbusSessionHelper->InstallPackageNames(vPackages, OUString());
a6bffad
             SolarMutexGuard aGuard;
a6bffad
             executeRestartDialog(comphelper::getProcessComponentContext(), nullptr, RESTART_REASON_MAILMERGE_INSTALL);
a6bffad
         }
e272ea8
diff --git a/vcl/inc/unx/fontmanager.hxx b/vcl/inc/unx/fontmanager.hxx
e272ea8
index 03d033e..14aebde 100644
e272ea8
--- a/vcl/inc/unx/fontmanager.hxx
e272ea8
+++ b/vcl/inc/unx/fontmanager.hxx
e272ea8
@@ -192,14 +192,10 @@ class VCL_PLUGIN_PUBLIC PrintFontManager
e272ea8
     static void addFontconfigDir(const OString& rDirectory);
e272ea8
 
e272ea8
     std::set<OString> m_aPreviousLangSupportRequests;
e272ea8
-#if ENABLE_GIO
e272ea8
-    std::vector<OString> m_aCurrentRequests;
e272ea8
-#endif
e272ea8
+    std::vector<OUString> m_aCurrentRequests;
e272ea8
     Timer m_aFontInstallerTimer;
e272ea8
 
e272ea8
-#if ENABLE_GIO
e272ea8
     DECL_LINK( autoInstallFontLangSupport, Timer*, void );
e272ea8
-#endif
e272ea8
     PrintFontManager();
e272ea8
 public:
e272ea8
     ~PrintFontManager();
a6bffad
diff --git a/vcl/unx/generic/fontmanager/fontconfig.cxx b/vcl/unx/generic/fontmanager/fontconfig.cxx
e272ea8
index 2c16e04..59acfa5 100644
a6bffad
--- a/vcl/unx/generic/fontmanager/fontconfig.cxx
a6bffad
+++ b/vcl/unx/generic/fontmanager/fontconfig.cxx
e272ea8
@@ -20,6 +20,7 @@
e272ea8
 #include <memory>
e272ea8
 #include <unx/fontmanager.hxx>
e272ea8
 #include <impfont.hxx>
e272ea8
+#include <comphelper/sequence.hxx>
e272ea8
 #include <vcl/svapp.hxx>
e272ea8
 #include <vcl/sysdata.hxx>
e272ea8
 #include <vcl/vclenum.hxx>
e272ea8
@@ -31,8 +32,8 @@
e272ea8
 #include <rtl/strbuf.hxx>
e272ea8
 #include <unicode/uchar.h>
e272ea8
 #include <unicode/uscript.h>
e272ea8
-#include <config_gio.h>
e272ea8
 #include <officecfg/Office/Common.hxx>
e272ea8
+#include <org/freedesktop/PackageKit/SyncDbusSessionHelper.hpp>
e272ea8
 
e272ea8
 using namespace psp;
e272ea8
 
e272ea8
@@ -40,10 +41,6 @@ using namespace psp;
e272ea8
 #include <ft2build.h>
e272ea8
 #include <fontconfig/fcfreetype.h>
e272ea8
 
e272ea8
-#if ENABLE_GIO
e272ea8
-#include <gio/gio.h>
e272ea8
-#endif
e272ea8
-
e272ea8
 #include <cstdio>
e272ea8
 #include <cstdarg>
e272ea8
 
e272ea8
@@ -862,96 +859,28 @@ namespace
e272ea8
             aBuf.append('-').append(pScriptCode);
e272ea8
         return OStringToOUString(aBuf.makeStringAndClear(), RTL_TEXTENCODING_UTF8);
e272ea8
     }
e272ea8
-
e272ea8
-#if ENABLE_GIO
e272ea8
-    guint get_xid_for_dbus()
e272ea8
-    {
a6bffad
-        // FIXME: Application::GetActiveTopWindow only returns something sensible if LO currently has the focus
a6bffad
-        // (which is not the case when you are trying to debug this...). It should instead return the last active window.
a6bffad
-        const vcl::Window *pTopWindow = Application::IsHeadlessModeEnabled() ? nullptr : Application::GetActiveTopWindow();
e272ea8
-        const SystemEnvData* pEnvData = pTopWindow ? pTopWindow->GetSystemData() : nullptr;
a6bffad
-        return pEnvData ? pEnvData->aWindow : 0;
e272ea8
-    }
e272ea8
-#endif
e272ea8
 }
e272ea8
 
e272ea8
-#if ENABLE_GIO
e272ea8
 IMPL_LINK_NOARG(PrintFontManager, autoInstallFontLangSupport, Timer *, void)
e272ea8
 {
e272ea8
-    if (!officecfg::Office::Common::PackageKit::EnableFontInstallation::get())
e272ea8
-        return;
e272ea8
-
e272ea8
-    guint xid = get_xid_for_dbus();
e272ea8
-
e272ea8
-    if (!xid)
e272ea8
+    try
e272ea8
     {
e272ea8
-        SAL_WARN("vcl", "Could not retrieve X Window ID for DBUS");
e272ea8
-        return;
e272ea8
+        using namespace org::freedesktop::PackageKit;
e272ea8
+        css::uno::Reference<XSyncDbusSessionHelper> xSyncDbusSessionHelper(SyncDbusSessionHelper::create(comphelper::getProcessComponentContext()));
e272ea8
+        xSyncDbusSessionHelper->InstallFontconfigResources(comphelper::containerToSequence(m_aCurrentRequests), "hide-finished");
a6bffad
     }
e272ea8
-
e272ea8
-
e272ea8
-    GError *error = nullptr;
e272ea8
-    /* get the DBUS session connection */
e272ea8
-    GDBusConnection *session_connection = g_bus_get_sync(G_BUS_TYPE_SESSION, nullptr, &error);
e272ea8
-    if (error != nullptr)
e272ea8
-    {
e272ea8
-        g_debug ("DBUS cannot connect : %s", error->message);
e272ea8
-        g_error_free (error);
e272ea8
-        return;
e272ea8
-    }
e272ea8
-
e272ea8
-    /* get the proxy with gnome-session-manager */
e272ea8
-    GDBusProxy *proxy = g_dbus_proxy_new_sync(session_connection,
e272ea8
-                                              G_DBUS_PROXY_FLAGS_NONE,
e272ea8
-                                              nullptr, // GDBusInterfaceInfo
e272ea8
-                                              "org.freedesktop.PackageKit",
e272ea8
-                                              "/org/freedesktop/PackageKit",
e272ea8
-                                              "org.freedesktop.PackageKit.Modify",
e272ea8
-                                              nullptr, // GCancellable
e272ea8
-                                              &error);
e272ea8
-    if (proxy == nullptr && error != nullptr)
e272ea8
-    {
e272ea8
-        g_debug("Could not get DBUS proxy: org.freedesktop.PackageKit: %s", error->message);
e272ea8
-        g_error_free(error);
e272ea8
-        return;
e272ea8
-    }
e272ea8
-
e272ea8
-    GVariantBuilder *builder = g_variant_builder_new (G_VARIANT_TYPE("as")); // 'as'=array of strings
e272ea8
-    for (std::vector<OString>::const_iterator aI = m_aCurrentRequests.begin(); aI != m_aCurrentRequests.end(); ++aI)
e272ea8
-        g_variant_builder_add (builder, "s", aI->getStr());
e272ea8
-
e272ea8
-    GVariant *res = g_dbus_proxy_call_sync(proxy,
e272ea8
-                                     "InstallFontconfigResources",
e272ea8
-                                     // Create a new variant with the following types:
e272ea8
-                                     //   'u'=guint32 (xid); 'as'=array of strings (builder); 's'=string ("hide-finished")
e272ea8
-                                     // See also https://people.gnome.org/~ryanl/glib-docs/gvariant-format-strings.html
e272ea8
-                                     g_variant_new("(uass)", xid, builder, "hide-finished"),
e272ea8
-                                     G_DBUS_CALL_FLAGS_NONE,
e272ea8
-                                     -1, // Timeout
e272ea8
-                                     nullptr, // GCancellable
e272ea8
-                                     &error);
e272ea8
-
e272ea8
-    if (res == nullptr && error != nullptr)
e272ea8
+    catch (const css::uno::Exception& e)
e272ea8
     {
e272ea8
+        SAL_INFO("vcl", "InstallFontconfigResources problem, caught " << e);
e272ea8
         // Disable this method from now on. It's simply not available on some systems
e272ea8
         // and leads to an error dialog being shown each time this is called tdf#104883
e272ea8
         std::shared_ptr<comphelper::ConfigurationChanges> batch( comphelper::ConfigurationChanges::create() );
e272ea8
         officecfg::Office::Common::PackageKit::EnableFontInstallation::set(false, batch);
e272ea8
         batch->commit();
e272ea8
-        g_debug("InstallFontconfigResources problem : %s", error->message);
e272ea8
-        g_error_free(error);
e272ea8
-    }
e272ea8
-    else
e272ea8
-    {
e272ea8
-        g_variant_unref(res);
e272ea8
     }
e272ea8
 
e272ea8
-    g_variant_builder_unref(builder);
e272ea8
-    g_object_unref(G_OBJECT (proxy));
e272ea8
-
e272ea8
     m_aCurrentRequests.clear();
a6bffad
 }
e272ea8
-#endif
e272ea8
 
e272ea8
 void PrintFontManager::Substitute( FontSelectPattern &rPattern, OUString& rMissingCodes )
e272ea8
 {
e272ea8
@@ -1107,8 +1036,7 @@ void PrintFontManager::Substitute( FontSelectPattern &rPattern, OUString& rMissi
e272ea8
                     }
e272ea8
                 }
e272ea8
                 OUString sStillMissing(pRemainingCodes.get(), nRemainingLen);
e272ea8
-#if ENABLE_GIO
e272ea8
-                if (get_xid_for_dbus())
e272ea8
+                if (!Application::IsHeadlessModeEnabled() && officecfg::Office::Common::PackageKit::EnableFontInstallation::get())
e272ea8
                 {
e272ea8
                     if (sStillMissing == rMissingCodes) //replaced nothing
e272ea8
                     {
e272ea8
@@ -1127,7 +1055,7 @@ void PrintFontManager::Substitute( FontSelectPattern &rPattern, OUString& rMissi
e272ea8
                             if (!sTag.isEmpty() && m_aPreviousLangSupportRequests.find(sTag) == m_aPreviousLangSupportRequests.end())
e272ea8
                             {
e272ea8
                                 OString sReq = OString(":lang=") + sTag;
e272ea8
-                                m_aCurrentRequests.push_back(sReq);
e272ea8
+                                m_aCurrentRequests.push_back(OUString::fromUtf8(sReq));
e272ea8
                                 m_aPreviousLangSupportRequests.insert(sTag);
e272ea8
                             }
e272ea8
                         }
e272ea8
@@ -1138,7 +1066,6 @@ void PrintFontManager::Substitute( FontSelectPattern &rPattern, OUString& rMissi
e272ea8
                         m_aFontInstallerTimer.Start();
e272ea8
                     }
e272ea8
                 }
e272ea8
-#endif
e272ea8
                 rMissingCodes = sStillMissing;
e272ea8
             }
e272ea8
         }
e272ea8
diff --git a/vcl/unx/generic/fontmanager/fontmanager.cxx b/vcl/unx/generic/fontmanager/fontmanager.cxx
e272ea8
index c956345..d1743dd 100644
e272ea8
--- a/vcl/unx/generic/fontmanager/fontmanager.cxx
e272ea8
+++ b/vcl/unx/generic/fontmanager/fontmanager.cxx
e272ea8
@@ -146,10 +146,8 @@ PrintFontManager::PrintFontManager()
e272ea8
     : m_nNextFontID( 1 )
e272ea8
     , m_nNextDirAtom( 1 )
e272ea8
 {
e272ea8
-#if ENABLE_GIO
e272ea8
     m_aFontInstallerTimer.SetInvokeHandler(LINK(this, PrintFontManager, autoInstallFontLangSupport));
e272ea8
     m_aFontInstallerTimer.SetTimeout(5000);
e272ea8
-#endif
e272ea8
 }
e272ea8
 
e272ea8
 PrintFontManager::~PrintFontManager()
a6bffad
-- 
a6bffad
2.9.5
a6bffad