| 1 | /* |
| 2 | * Copyright (C) 2017 Canonical, Ltd. |
| 3 | * |
| 4 | * This program is free software: you can redistribute it and/or modify it under |
| 5 | * the terms of the GNU Lesser General Public License version 3, as published by |
| 6 | * the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 9 | * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
| 10 | * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 | * Lesser General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU Lesser General Public License |
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ |
| 16 | |
| 17 | #include "lomiriappmenuextraactionhandler.h"cxx . . $ `<file>/src/lomiriappmenu/lomiriappmenuextraactionhandler.h`/ |
| 18 | |
| 19 | #include "gmenumodelexporter.h"cxx . . $ `<file>/src/lomiriappmenu/gmenumodelexporter.h`/ |
| 20 | #include "logging.h"cxx . . $ `<file>/src/lomiriappmenu/logging.h`/ |
| 21 | |
| 22 | static const gchar introspection_xmlcxx . . $ introspection_xml.[] = |
| 23 | "<node>" |
| 24 | " <interface name='qtubuntu.actions.extra'>" |
| 25 | " <method name='aboutToShow'>" |
| 26 | " <arg type='t' name='tag' direction='in'/>" |
| 27 | " </method>" |
| 28 | " </interface>" |
| 29 | "</node>"; |
| 30 | |
| 31 | static void handle_method_callcxx . . $ handle_method_call(bc21dc0d4aa296df). (GDBusConnection *, |
| 32 | const gchar *, |
| 33 | const gchar *, |
| 34 | const gchar *, |
| 35 | const gchar *method_name, |
| 36 | GVariant *parameters, |
| 37 | GDBusMethodInvocation *invocation, |
| 38 | gpointer user_data) |
| 39 | { |
| 40 | |
| 41 | if (g_strcmp0 (method_name, "aboutToShow") == 0) |
| 42 | { |
| 43 | if (g_variant_check_format_string(parameters, "(t)", false)) { |
| 44 | auto obj = static_cast<LomiriGMenuModelExportercxx . . $ LomiriGMenuModelExporter#*>(user_data); |
| 45 | guint64 tag; |
| 46 | |
| 47 | g_variant_get (parameters, "(t)", &tag); |
| 48 | obj->aboutToShowcxx . . $ LomiriGMenuModelExporter#aboutToShow(891dc3055356b409).(tag); |
| 49 | } |
| 50 | |
| 51 | g_dbus_method_invocation_return_value (invocation, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 52 | } else { |
| 53 | g_dbus_method_invocation_return_error(invocation, |
| 54 | G_DBUS_ERRORcxx . . $ `<external>/517763016858796244/gdbuserror.h:49:9`!, |
| 55 | G_DBUS_ERROR_UNKNOWN_METHOD, |
| 56 | "Unknown method"); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | |
| 61 | static const GDBusInterfaceVTable interface_vtablecxx . . $ interface_vtable. = |
| 62 | { |
| 63 | handle_method_callcxx . . $ handle_method_call(bc21dc0d4aa296df)., |
| 64 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, |
| 65 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, |
| 66 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! |
| 67 | }; |
| 68 | |
| 69 | LomiriAppMenuExtraActionHandlercxx . . $ LomiriAppMenuExtraActionHandler#::LomiriAppMenuExtraActionHandlercxx . . $ LomiriAppMenuExtraActionHandler#LomiriAppMenuExtraActionHandler(49f6e7a06ebc5aa8).() |
| 70 | : m_registration_idcxx . . $ LomiriAppMenuExtraActionHandler#m_registration_id.(0) |
| 71 | { |
| 72 | m_introspection_datacxx . . $ LomiriAppMenuExtraActionHandler#m_introspection_data. = g_dbus_node_info_new_for_xml (introspection_xmlcxx . . $ introspection_xml., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 73 | } |
| 74 | |
| 75 | LomiriAppMenuExtraActionHandlercxx . . $ LomiriAppMenuExtraActionHandler#::~cxx . . $ LomiriAppMenuExtraActionHandler#`~LomiriAppMenuExtraActionHandler`(49f6e7a06ebc5aa8).LomiriAppMenuExtraActionHandlercxx . . $ LomiriAppMenuExtraActionHandler#() |
| 76 | { |
| 77 | g_clear_pointercxx . . $ `<external>/1123956534522462559/gmem.h:135:9`!(&m_introspection_data, g_dbus_node_info_unref); |
| 78 | } |
| 79 | |
| 80 | bool LomiriAppMenuExtraActionHandlercxx . . $ LomiriAppMenuExtraActionHandler#::connectcxx . . $ LomiriAppMenuExtraActionHandler#connect(41d31289457d7a6e).(GDBusConnection *connection, const QByteArraycxx . . $ QByteArray# &menuPath, LomiriGMenuModelExportercxx . . $ LomiriGMenuModelExporter# *gmenuexporter) |
| 81 | { |
| 82 | if (m_registration_idcxx . . $ LomiriAppMenuExtraActionHandler#m_registration_id. != 0) { |
| 83 | qCWarningcxx . . $ `<external>/13903568758641964362/qloggingcategory.h:138:11`!(lomiriappmenu, "Called connect in an already connected LomiriAppMenuExtraActionHandler"); |
| 84 | return false; |
| 85 | } |
| 86 | |
| 87 | GError *error = nullptr; |
| 88 | m_registration_idcxx . . $ LomiriAppMenuExtraActionHandler#m_registration_id. = g_dbus_connection_register_object (connection, menuPath.constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).(), |
| 89 | m_introspection_datacxx . . $ LomiriAppMenuExtraActionHandler#m_introspection_data.->interfacescxx . . $ _GDBusNodeInfo#interfaces.[0], |
| 90 | &interface_vtablecxx . . $ interface_vtable., |
| 91 | gmenuexporter, |
| 92 | nullptr, |
| 93 | &error); |
| 94 | |
| 95 | if (!m_registration_idcxx . . $ LomiriAppMenuExtraActionHandler#m_registration_id.) { |
| 96 | qCWarningcxx . . $ `<external>/13903568758641964362/qloggingcategory.h:138:11`!(lomiriappmenu, "Failed to extra actions - %s", error ? error->message : "unknown error"); |
| 97 | g_clear_error(&error); |
| 98 | } |
| 99 | |
| 100 | return m_registration_idcxx . . $ LomiriAppMenuExtraActionHandler#m_registration_id. != 0; |
| 101 | } |
| 102 | |
| 103 | void LomiriAppMenuExtraActionHandlercxx . . $ LomiriAppMenuExtraActionHandler#::disconnectcxx . . $ LomiriAppMenuExtraActionHandler#disconnect(8f9d48b3906dd9bd).(GDBusConnection *connection) { |
| 104 | if (m_registration_idcxx . . $ LomiriAppMenuExtraActionHandler#m_registration_id.) { |
| 105 | g_dbus_connection_unregister_object (connection, m_registration_idcxx . . $ LomiriAppMenuExtraActionHandler#m_registration_id.); |
| 106 | } |
| 107 | } |