[gnome-shell/T27795: 45/138] shell-app-system: Report an event when an application opens/closes
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/T27795: 45/138] shell-app-system: Report an event when an application opens/closes
- Date: Tue, 1 Oct 2019 23:33:06 +0000 (UTC)
commit 04b20553062563793467b2349f39d9fe5370c147
Author: Mario Sanchez Prada <mario endlessm com>
Date: Mon Jun 5 17:02:49 2017 +0100
shell-app-system: Report an event when an application opens/closes
This uses EOS metrics recorder daemon, so add the dependency too.
meson.build | 3 +++
src/meson.build | 3 ++-
src/shell-app-system.c | 31 ++++++++++++++++++++++++++++++-
3 files changed, 35 insertions(+), 2 deletions(-)
---
diff --git a/meson.build b/meson.build
index b0e577abe3..b2837a6513 100644
--- a/meson.build
+++ b/meson.build
@@ -109,6 +109,9 @@ if enable_recorder
recorder_deps += [gst_dep, gst_base_dep, gtk_dep, x11_dep]
endif
+# Endless-specific: Metrics
+eosmetrics_dep = dependency('eosmetrics-0')
+
nm_deps = []
if get_option('networkmanager')
nm_deps += dependency('libnm', version: nm_req)
diff --git a/src/meson.build b/src/meson.build
index 3523fb16cb..56c26dc845 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -61,7 +61,8 @@ gnome_shell_deps = [
gi_dep,
polkit_dep,
gcr_dep,
- libsystemd_dep
+ libsystemd_dep,
+ eosmetrics_dep,
]
gnome_shell_deps += nm_deps
diff --git a/src/shell-app-system.c b/src/shell-app-system.c
index 127f29ef02..fad1639f91 100644
--- a/src/shell-app-system.c
+++ b/src/shell-app-system.c
@@ -9,6 +9,8 @@
#include <gio/gio.h>
#include <glib/gi18n.h>
+#include <eosmetrics/eosmetrics.h>
+
#include "shell-app-private.h"
#include "shell-window-tracker-private.h"
#include "shell-app-system-private.h"
@@ -23,6 +25,14 @@
#define RESCAN_TIMEOUT_MS 2500
#define MAX_RESCAN_RETRIES 6
+/* Occurs when an application visible to the shell is opened or closed. The
+ * payload varies depending on whether it is given as an opening event or a
+ * closed event. If it is an opening event, the payload is a human-readable
+ * application name. If it is a closing event, the payload is empty. The key
+ * used is a pointer to the corresponding ShellApp.
+ */
+#define SHELL_APP_IS_OPEN_EVENT "b5e11a3d-13f8-4219-84fd-c9ba0bf3d1f0"
+
/* Vendor prefixes are something that can be preprended to a .desktop
* file name. Undo this.
*/
@@ -420,15 +430,34 @@ _shell_app_system_notify_app_state_changed (ShellAppSystem *self,
{
ShellAppState state = shell_app_get_state (app);
+ g_autofree gchar *app_address = g_strdup_printf ("%p", app);
+ GDesktopAppInfo *app_info = shell_app_get_app_info (app);
+ const gchar *app_info_id = NULL;
+ if (app_info != NULL)
+ app_info_id = g_app_info_get_id (G_APP_INFO (app_info));
+
switch (state)
{
case SHELL_APP_STATE_RUNNING:
+ if (app_info_id != NULL)
+ {
+ emtr_event_recorder_record_start (emtr_event_recorder_get_default (),
+ SHELL_APP_IS_OPEN_EVENT,
+ g_variant_new_string (app_address),
+ g_variant_new_string (app_info_id));
+ }
g_hash_table_insert (self->priv->running_apps, g_object_ref (app), NULL);
break;
case SHELL_APP_STATE_STARTING:
break;
case SHELL_APP_STATE_STOPPED:
- g_hash_table_remove (self->priv->running_apps, app);
+ if (g_hash_table_remove (self->priv->running_apps, app) && app_info_id != NULL)
+ {
+ emtr_event_recorder_record_stop (emtr_event_recorder_get_default (),
+ SHELL_APP_IS_OPEN_EVENT,
+ g_variant_new_string (app_address),
+ NULL);
+ }
break;
default:
g_warn_if_reached();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]