Debian Codegraph @

src/lomiriappmenu/menuregistrar.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 2016 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 "menuregistrar.h"cxx . . $ `<file>/src/lomiriappmenu/menuregistrar.h`/
18 #include "registry.h"cxx . . $ `<file>/src/lomiriappmenu/registry.h`/
19 #include "logging.h"cxx . . $ `<file>/src/lomiriappmenu/logging.h`/
20
21 #include <QDebug>
22 #include <QDBusObjectPath>
23 #include <QGuiApplication>
24 #include <qpa/qplatformnativeinterface.h>
25 #include <qpa/qplatformwindow.h>
26
27 namespacecxx . . $ `$anonymous_namespace_src/lomiriappmenu/menuregistrar.cpp`/ {
28
29 bool isMirClientcxx . . $ `$anonymous_namespace_src/lomiriappmenu/menuregistrar.cpp`/isMirClient(c9857a73d68e59ba).() {
30 return qGuiAppcxx . . $ `<external>/9746514399953054211/qguiapplication.h:70:9`!->platformNamecxx . . $ QGuiApplication#platformName(4365c3963150523e).() ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "ubuntumirclient";
31 }
32
33 }
34
35 LomiriMenuRegistrarcxx . . $ LomiriMenuRegistrar#::LomiriMenuRegistrarcxx . . $ LomiriMenuRegistrar#LomiriMenuRegistrar(49f6e7a06ebc5aa8).()
36 : m_connectioncxx . . $ LomiriMenuRegistrar#m_connection.(nullptr)
37 , m_registeredProcessIdcxx . . $ LomiriMenuRegistrar#m_registeredProcessId.(~0)
38 {
39 GError *error = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
40 m_connectioncxx . . $ LomiriMenuRegistrar#m_connection. = g_bus_get_sync (G_BUS_TYPE_SESSION, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, &error);
41 if (!m_connectioncxx . . $ LomiriMenuRegistrar#m_connection.) {
42 qCWarningcxx . . $ `<external>/13903568758641964362/qloggingcategory.h:138:11`!(lomiriappmenuRegistrar, "Failed to retrieve session bus - %s", error ? error->message : "unknown error");
43 g_error_free (error);
44 return;
45 }
46 m_servicecxx . . $ LomiriMenuRegistrar#m_service. =cxx . . $ QString#`operator=`(d02845eef0c33901). g_dbus_connection_get_unique_name(m_connectioncxx . . $ LomiriMenuRegistrar#m_connection.);
47 connectcxx . . $ QObject#connect(835f87066c895669).(LomiriMenuRegistrycxx . . $ LomiriMenuRegistry#::instancecxx . . $ LomiriMenuRegistry#instance(b0a1ce46fb707340).(), &LomiriMenuRegistrycxx . . $ LomiriMenuRegistry#::serviceChangedcxx . . $ LomiriMenuRegistry#serviceChanged(49f6e7a06ebc5aa8)., this, &LomiriMenuRegistrarcxx . . $ LomiriMenuRegistrar#::onRegistrarServiceChangedcxx . . $ LomiriMenuRegistrar#onRegistrarServiceChanged(49f6e7a06ebc5aa8).);
48
49 if (isMirClientcxx . . $ `$anonymous_namespace_src/lomiriappmenu/menuregistrar.cpp`/isMirClient(c9857a73d68e59ba).()) {
50 auto nativeInterface = qGuiAppcxx . . $ `<external>/9746514399953054211/qguiapplication.h:70:9`!->platformNativeInterfacecxx . . $ QGuiApplication#platformNativeInterface(a344dd76f4c6724a).();
51 connectcxx . . $ QObject#connect(d9dbe0c0ad4eecec).(nativeInterface, &QPlatformNativeInterfacecxx . . $ QPlatformNativeInterface#::windowPropertyChangedcxx . . $ QPlatformNativeInterface#windowPropertyChanged(3a4f3fd801b1c1d2)., this, [this](QPlatformWindowcxx . . $ QPlatformWindow#* window, const QStringcxx . . $ QString# &property) {
52 if (property !=cxx . . $ `operator!=`(edf9e4f73813982f). QStringLiteralcxx . . $ `<external>/2817157206922689722/qstringliteral.h:65:9`!("persistentSurfaceId")) {
53 return;
54 }
55 if (window->windowcxx . . $ QPlatformWindow#window(d520c9a5ccf200dd).() ==cxx . . $ `operator==`(4a5b7cdf3c1bd30d). m_windowcxx . . $ LomiriMenuRegistrar#m_window.) {
56 registerMenuForWindowcxx . . $ LomiriMenuRegistrar#registerMenuForWindow(ec3123c1967ea00e).(m_windowcxx . . $ LomiriMenuRegistrar#m_window., m_pathcxx . . $ LomiriMenuRegistrar#m_path.);
57 }
58 });
59 }
60 }
61
62 LomiriMenuRegistrarcxx . . $ LomiriMenuRegistrar#::~cxx . . $ LomiriMenuRegistrar#`~LomiriMenuRegistrar`(49f6e7a06ebc5aa8).LomiriMenuRegistrarcxx . . $ LomiriMenuRegistrar#()
63 {
64 if (m_connectioncxx . . $ LomiriMenuRegistrar#m_connection.) {
65 g_object_unref(m_connectioncxx . . $ LomiriMenuRegistrar#m_connection.);
66 }
67 unregisterMenucxx . . $ LomiriMenuRegistrar#unregisterMenu(49f6e7a06ebc5aa8).();
68 }
69
70 void LomiriMenuRegistrarcxx . . $ LomiriMenuRegistrar#::registerMenuForWindowcxx . . $ LomiriMenuRegistrar#registerMenuForWindow(ec3123c1967ea00e).(QWindowcxx . . $ QWindow#* window, const QDBusObjectPathcxx . . $ QDBusObjectPath#& path)
71 {
72 unregisterMenucxx . . $ LomiriMenuRegistrar#unregisterMenu(49f6e7a06ebc5aa8).();
73
74 m_windowcxx . . $ LomiriMenuRegistrar#m_window. =cxx . . $ QPointer#`operator=`(500fb76d9e491ab0). window;
75 m_pathcxx . . $ LomiriMenuRegistrar#m_path. =cxx . . $ QDBusObjectPath#`operator=`(18fc4ad97faace4f). path;
76
77 registerMenucxx . . $ LomiriMenuRegistrar#registerMenu(49f6e7a06ebc5aa8).();
78 }
79
80 void LomiriMenuRegistrarcxx . . $ LomiriMenuRegistrar#::registerMenucxx . . $ LomiriMenuRegistrar#registerMenu(49f6e7a06ebc5aa8).()
81 {
82 if (LomiriMenuRegistrycxx . . $ LomiriMenuRegistry#::instancecxx . . $ LomiriMenuRegistry#instance(b0a1ce46fb707340).()->isConnectedcxx . . $ LomiriMenuRegistry#isConnected(50ce9a9e25b4a850).() && m_windowcxx . . $ LomiriMenuRegistrar#m_window.) {
83 if (isMirClientcxx . . $ `$anonymous_namespace_src/lomiriappmenu/menuregistrar.cpp`/isMirClient(c9857a73d68e59ba).()) {
84 registerSurfaceMenucxx . . $ LomiriMenuRegistrar#registerSurfaceMenu(49f6e7a06ebc5aa8).();
85 } else {
86 registerApplicationMenucxx . . $ LomiriMenuRegistrar#registerApplicationMenu(49f6e7a06ebc5aa8).();
87 }
88 }
89 }
90
91 void LomiriMenuRegistrarcxx . . $ LomiriMenuRegistrar#::unregisterMenucxx . . $ LomiriMenuRegistrar#unregisterMenu(49f6e7a06ebc5aa8).()
92 {
93 if (!m_registeredSurfaceIdcxx . . $ LomiriMenuRegistrar#m_registeredSurfaceId..isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) {
94 unregisterSurfaceMenucxx . . $ LomiriMenuRegistrar#unregisterSurfaceMenu(49f6e7a06ebc5aa8).();
95 } else if (m_registeredProcessIdcxx . . $ LomiriMenuRegistrar#m_registeredProcessId. != ~0) {
96 unregisterApplicationMenucxx . . $ LomiriMenuRegistrar#unregisterApplicationMenu(49f6e7a06ebc5aa8).();
97 }
98 }
99
100 void LomiriMenuRegistrarcxx . . $ LomiriMenuRegistrar#::registerSurfaceMenucxx . . $ LomiriMenuRegistrar#registerSurfaceMenu(49f6e7a06ebc5aa8).()
101 {
102 auto nativeInterface = qGuiAppcxx . . $ `<external>/9746514399953054211/qguiapplication.h:70:9`!->platformNativeInterfacecxx . . $ QGuiApplication#platformNativeInterface(a344dd76f4c6724a).();
103 QByteArraycxx . . $ QByteArray# persistentSurfaceId = nativeInterfacecxx . . $ QByteArray#QByteArray(3203d9f8f38841a4).->windowPropertycxx . . $ QPlatformNativeInterface#windowProperty(76959004c729e3a7).(m_windowcxx . . $ LomiriMenuRegistrar#m_window.->cxx . . $ QPointer#`operator->`(5a2a78a048fb49a8).handlecxx . . $ QWindow#handle(23d05d3b936522f1).(), "persistentSurfaceId"cxx . . $ QString#QString(85c52e162fed56f9)., QByteArraycxx . . $ QVariant#QVariant(45672f3c6961a244).()).toByteArraycxx . . $ QVariant#toByteArray(a96750bfbcb1fbe9).();
104 if (persistentSurfaceId.isEmptycxx . . $ QByteArray#isEmpty(50ce9a9e25b4a850).()) return;
105
106 LomiriMenuRegistrycxx . . $ LomiriMenuRegistry#::instancecxx . . $ LomiriMenuRegistry#instance(b0a1ce46fb707340).()->registerSurfaceMenucxx . . $ LomiriMenuRegistry#registerSurfaceMenu(ea9db58ee935b3e8).(persistentSurfaceIdcxx . . $ QString#QString(45672f3c6961a244)., m_pathcxx . . $ LomiriMenuRegistrar#m_path., m_servicecxx . . $ LomiriMenuRegistrar#m_service.);
107 m_registeredSurfaceIdcxx . . $ LomiriMenuRegistrar#m_registeredSurfaceId. =cxx . . $ QString#`operator=`(49ea8750b4987a17). persistentSurfaceId;
108 }
109
110 void LomiriMenuRegistrarcxx . . $ LomiriMenuRegistrar#::unregisterSurfaceMenucxx . . $ LomiriMenuRegistrar#unregisterSurfaceMenu(49f6e7a06ebc5aa8).()
111 {
112 if (LomiriMenuRegistrycxx . . $ LomiriMenuRegistry#::instancecxx . . $ LomiriMenuRegistry#instance(b0a1ce46fb707340).()->isConnectedcxx . . $ LomiriMenuRegistry#isConnected(50ce9a9e25b4a850).()) {
113 LomiriMenuRegistrycxx . . $ LomiriMenuRegistry#::instancecxx . . $ LomiriMenuRegistry#instance(b0a1ce46fb707340).()->unregisterSurfaceMenucxx . . $ LomiriMenuRegistry#unregisterSurfaceMenu(88b147b41fa0c21e).(m_registeredSurfaceIdcxx . . $ LomiriMenuRegistrar#m_registeredSurfaceId., m_pathcxx . . $ LomiriMenuRegistrar#m_path.);
114 }
115 m_registeredSurfaceIdcxx . . $ LomiriMenuRegistrar#m_registeredSurfaceId..clearcxx . . $ QString#clear(49f6e7a06ebc5aa8).();
116 }
117
118 void LomiriMenuRegistrarcxx . . $ LomiriMenuRegistrar#::registerApplicationMenucxx . . $ LomiriMenuRegistrar#registerApplicationMenu(49f6e7a06ebc5aa8).()
119 {
120 pid_t pid = getpid();
121 LomiriMenuRegistrycxx . . $ LomiriMenuRegistry#::instancecxx . . $ LomiriMenuRegistry#instance(b0a1ce46fb707340).()->registerApplicationMenucxx . . $ LomiriMenuRegistry#registerApplicationMenu(d940720556290bb7).(pid, m_pathcxx . . $ LomiriMenuRegistrar#m_path., m_servicecxx . . $ LomiriMenuRegistrar#m_service.);
122 m_registeredProcessIdcxx . . $ LomiriMenuRegistrar#m_registeredProcessId. = pid;
123 }
124
125 void LomiriMenuRegistrarcxx . . $ LomiriMenuRegistrar#::unregisterApplicationMenucxx . . $ LomiriMenuRegistrar#unregisterApplicationMenu(49f6e7a06ebc5aa8).()
126 {
127 if (LomiriMenuRegistrycxx . . $ LomiriMenuRegistry#::instancecxx . . $ LomiriMenuRegistry#instance(b0a1ce46fb707340).()->isConnectedcxx . . $ LomiriMenuRegistry#isConnected(50ce9a9e25b4a850).()) {
128 LomiriMenuRegistrycxx . . $ LomiriMenuRegistry#::instancecxx . . $ LomiriMenuRegistry#instance(b0a1ce46fb707340).()->unregisterApplicationMenucxx . . $ LomiriMenuRegistry#unregisterApplicationMenu(ed291af23ed92a62).(m_registeredProcessIdcxx . . $ LomiriMenuRegistrar#m_registeredProcessId., m_pathcxx . . $ LomiriMenuRegistrar#m_path.);
129 }
130 m_registeredProcessIdcxx . . $ LomiriMenuRegistrar#m_registeredProcessId. = ~0;
131 }
132
133 void LomiriMenuRegistrarcxx . . $ LomiriMenuRegistrar#::onRegistrarServiceChangedcxx . . $ LomiriMenuRegistrar#onRegistrarServiceChanged(49f6e7a06ebc5aa8).()
134 {
135 unregisterMenucxx . . $ LomiriMenuRegistrar#unregisterMenu(49f6e7a06ebc5aa8).();
136 registerMenucxx . . $ LomiriMenuRegistrar#registerMenu(49f6e7a06ebc5aa8).();
137 }