Remmina - The GTK+ Remote Desktop Client  v1.4.33
Remmina is a remote desktop client written in GTK+, aiming to be useful for system administrators and travellers, who need to work with lots of remote computers in front of either large monitors or tiny netbooks. Remmina supports multiple network protocols in an integrated and consistent user interface. Currently RDP, VNC, NX, XDMCP and SSH are supported.
remmina_sysinfo.c
Go to the documentation of this file.
1 /*
2  * Remmina - The GTK+ Remote Desktop Client
3  * Copyright (C) 2010 Vic Lee
4  * Copyright (C) 2014-2015 Antenore Gatta, Fabio Castelli, Giovanni Panozzo
5  * Copyright (C) 2016-2023 Antenore Gatta, Giovanni Panozzo
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  *
22  * In addition, as a special exception, the copyright holders give
23  * permission to link the code of portions of this program with the
24  * OpenSSL library under certain conditions as described in each
25  * individual source file, and distribute linked combinations
26  * including the two.
27  * You must obey the GNU General Public License in all respects
28  * for all of the code used other than OpenSSL. * If you modify
29  * file(s) with this exception, you may extend this exception to your
30  * version of the file(s), but you are not obligated to do so. * If you
31  * do not wish to do so, delete this exception statement from your
32  * version. * If you delete this exception statement from all source
33  * files in the program, then also delete it here.
34  *
35  */
36 
37 #include "config.h"
38 #include <glib/gi18n.h>
39 #include <sys/stat.h>
40 #include <sys/types.h>
41 #include <fcntl.h>
43 #include "remmina_sysinfo.h"
44 
46 {
47  /* Check if we have an appindicator available (which uses
48  * DBUS KDE StatusNotifier)
49  */
50 
51  TRACE_CALL(__func__);
52  GDBusConnection *con;
53  GVariant *v;
54  GError *error;
55  gboolean available;
56 
57  available = FALSE;
58  con = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL);
59  if (con) {
60  error = NULL;
61  v = g_dbus_connection_call_sync(con,
62  "org.kde.StatusNotifierWatcher",
63  "/StatusNotifierWatcher",
64  "org.freedesktop.DBus.Introspectable",
65  "Introspect",
66  NULL,
67  NULL,
68  G_DBUS_CALL_FLAGS_NONE,
69  -1,
70  NULL,
71  &error);
72  if (v) {
73  available = TRUE;
74  g_variant_unref(v);
75  }
76  g_object_unref(con);
77  }
78  return available;
79 }
80 
87 {
88  TRACE_CALL(__func__);
89  GDBusConnection *con;
90  GDBusProxy *p;
91  GVariant *v;
92  GError *error;
93  gsize sz;
94  gchar *ret;
95 
96  ret = NULL;
97 
98  con = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL);
99  if (con) {
100  error = NULL;
101  p = g_dbus_proxy_new_sync(con,
102  G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS | G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
103  NULL,
104  "org.gnome.Shell",
105  "/org/gnome/Shell",
106  "org.gnome.Shell",
107  NULL,
108  &error);
109  if (p) {
110  v = g_dbus_proxy_get_cached_property(p, "ShellVersion");
111  if (v) {
112  if (g_variant_is_of_type(v, G_VARIANT_TYPE_STRING)) {
113  ret = g_strdup(g_variant_get_string(v, &sz));
114  }
115  g_variant_unref(v);
116  }
117  g_object_unref(p);
118  }
119  g_object_unref(con);
120  }
121  return ret;
122 }
123 
131 {
132  TRACE_CALL(__func__);
133  const gchar *xdg_current_desktop;
134  const gchar *gdmsession;
135  gchar *ret;
136 
137  xdg_current_desktop = g_environ_getenv(g_get_environ(), "XDG_CURRENT_DESKTOP");
138  gdmsession = g_environ_getenv(g_get_environ(), "GDMSESSION");
139 
140  if (!xdg_current_desktop || xdg_current_desktop[0] == '\0') {
141  if (!gdmsession || gdmsession[0] == '\0') {
142  ret = NULL;
143  }else {
144  ret = g_strdup_printf("%s", gdmsession);
145  }
146  }else if (!gdmsession || gdmsession[0] == '\0') {
147  ret = g_strdup_printf("%s", xdg_current_desktop);
148  return ret;
149  }else if (g_strcmp0(xdg_current_desktop,gdmsession) == 0) {
150  ret = g_strdup_printf("%s", xdg_current_desktop);
151  }else {
152  ret = g_strdup_printf("%s %s", xdg_current_desktop, gdmsession);
153  }
154  return ret;
155 }
gchar * remmina_sysinfo_get_gnome_shell_version()
Query DBUS to get GNOME Shell version.
gchar * remmina_sysinfo_get_wm_name()
Query environment variables to get the Window manager name.
gboolean remmina_sysinfo_is_appindicator_available()