24 struct GVariantDeleter {
void operator()(GVariant* pV) {
if (pV) g_variant_unref(pV); } };
25 struct GVariantBuilderDeleter {
void operator()(GVariantBuilder* pVB) { g_variant_builder_unref(pVB); } };
26 template <
typename T>
struct GObjectDeleter {
void operator()(T* pO) { g_object_unref(pO); } };
31 explicit GErrorWrapper() : m_pError(nullptr) {}
32 ~GErrorWrapper() noexcept(false)
37 m_pError->message, std::strlen(m_pError->message), RTL_TEXTENCODING_UTF8);
38 g_error_free(m_pError);
41 GError*& getRef() {
return m_pError; }
43 GDBusProxy* lcl_GetPackageKitProxy(std::u16string_view sInterface)
45 const OString sFullInterface =
"org.freedesktop.PackageKit." +
OUStringToOString(sInterface, RTL_TEXTENCODING_ASCII_US);
49 proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
50 G_DBUS_PROXY_FLAGS_NONE,
nullptr,
51 "org.freedesktop.PackageKit",
52 "/org/freedesktop/PackageKit",
53 reinterpret_cast<const gchar*
>(sFullInterface.getStr()),
62 GVariant* pk_make_platform_data()
64 GVariantBuilder builder;
65 g_variant_builder_init(&builder, G_VARIANT_TYPE(
"a{sv}"));
66 return g_variant_builder_end(&builder);
71 css::uno::Sequence<OUString>
const & resources,
72 std::u16string_view interaction)
75 std::vector<OString> resUtf8;
76 std::shared_ptr<GVariantBuilder> builder(
77 g_variant_builder_new(G_VARIANT_TYPE (
"as")), GVariantBuilderDeleter());
78 for (
auto & i: resources) {
81 g_variant_builder_add(builder.get(),
"s", s.getStr());
84 std::shared_ptr<GDBusProxy> proxy(
85 lcl_GetPackageKitProxy(u
"Modify2"), GObjectDeleter<GDBusProxy>());
87 std::shared_ptr<GVariant>
result(g_dbus_proxy_call_sync(
90 "(asss@a{sv})", builder.get(), iactUtf8.getStr(),
91 "libreoffice-startcenter.desktop", pk_make_platform_data()),
92 G_DBUS_CALL_FLAGS_NONE, -1,
nullptr, &error.getRef()), GVariantDeleter());
101#if !GLIB_CHECK_VERSION(2,36,0)
108 return {
"org.freedesktop.PackageKit.SyncDbusSessionHelper" };
113 return "org.libreoffice.comp.shell.sessioninstall.SyncDbusSessionHelper";
122 css::uno::Sequence<OUString>
const & files,
123 OUString
const & interaction)
125 request(
"InstallPackageFiles", files, interaction);
129 css::uno::Sequence<OUString>
const & files,
130 OUString
const & interaction)
132 request(
"InstallProvideFiles", files, interaction);
136 css::uno::Sequence<OUString>
const & files,
137 OUString
const & interaction)
139 request(
"InstallCatalogs", files, interaction);
143 css::uno::Sequence<OUString>
const & packages,
144 OUString
const & interaction)
146 request(
"InstallPackageNames", packages, interaction);
150 css::uno::Sequence<OUString>
const & mimeTypes,
151 OUString
const & interaction)
153 request(
"InstallMimeTypes", mimeTypes, interaction);
157 css::uno::Sequence<OUString>
const & resources,
158 OUString
const & interaction)
160 request(
"InstallFontconfigResources", resources, interaction);
164 css::uno::Sequence<OUString>
const & resources,
165 OUString
const & interaction)
167 request(
"InstallGStreamerResources", resources, interaction);
171 css::uno::Sequence<OUString>
const & files,
172 OUString
const & interaction)
174 request(
"RemovePackageByFiles", files, interaction);
178 css::uno::Sequence<OUString>
const & files,
179 OUString
const & interaction)
181 request(
"InstallPrinterDrivers", files, interaction);
186 const OString sPackagenameAscii =
OUStringToOString(sPackagename, RTL_TEXTENCODING_ASCII_US);
187 const OString sInteractionAscii =
OUStringToOString(sInteraction, RTL_TEXTENCODING_ASCII_US);
188 std::shared_ptr<GDBusProxy> proxy(lcl_GetPackageKitProxy(
u"Query"), GObjectDeleter<GDBusProxy>());
190 std::shared_ptr<GVariant>
result(g_dbus_proxy_call_sync (proxy.get(),
192 g_variant_new (
"(ss)",
193 sPackagenameAscii.getStr(),
194 sInteractionAscii.getStr()),
195 G_DBUS_CALL_FLAGS_NONE,
198 &error.getRef()),GVariantDeleter());
200 o_isInstalled = bool(g_variant_get_boolean(g_variant_get_child_value(
result.get(),0)));
203extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
205 css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any>
const&)
virtual void SAL_CALL InstallProvideFiles(const css::uno::Sequence< OUString > &files, const OUString &interaction) override
virtual void SAL_CALL InstallPrinterDrivers(const css::uno::Sequence< OUString > &files, const OUString &interaction) override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual void SAL_CALL InstallCatalogs(const css::uno::Sequence< OUString > &files, const OUString &interaction) override
SyncDbusSessionHelper(css::uno::Reference< css::uno::XComponentContext > const &)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SAL_CALL RemovePackageByFiles(const css::uno::Sequence< OUString > &files, const OUString &interaction) override
virtual void SAL_CALL InstallMimeTypes(const css::uno::Sequence< OUString > &mimeTypes, const OUString &interaction) override
virtual void SAL_CALL InstallFontconfigResources(const css::uno::Sequence< OUString > &resources, const OUString &interaction) override
virtual void SAL_CALL IsInstalled(const OUString &, const OUString &, sal_Bool &) override
virtual void SAL_CALL InstallPackageFiles(const css::uno::Sequence< OUString > &files, const OUString &interaction) override
virtual void SAL_CALL InstallGStreamerResources(const css::uno::Sequence< OUString > &resources, const OUString &interaction) override
virtual OUString SAL_CALL getImplementationName() override
virtual void SAL_CALL InstallPackageNames(const css::uno::Sequence< OUString > &packages, const OUString &interaction) override
struct _GDBusProxy GDBusProxy
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * shell_sessioninstall_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)