WIP: add ProcExclude as a method sandbox/lstelmach/proc-exclude-method
authorŁukasz Stelmach <l.stelmach@samsung.com>
Fri, 4 May 2018 13:23:34 +0000 (15:23 +0200)
committerŁukasz Stelmach <l.stelmach@samsung.com>
Fri, 4 May 2018 14:02:59 +0000 (16:02 +0200)
Change-Id: I1fa8be9305d50d8c27924e6e94785cb888731b74

src/proc-stat/proc-monitor.c

index 0236bc57bc0df12d59e622339d834153238e13c8..3c4573e7e8987141b21bd32e01f62badcf9b7f56 100755 (executable)
@@ -413,7 +413,7 @@ static void dbus_get_cpu_lists(GDBusMethodInvocation *invocation, GVariant *para
 
 static void proc_dbus_exclude_signal_handler(GVariant *params)
 {
-       char *str = NULL;
+       const char *str = NULL;
        pid_t pid = 0;
        struct proc_exclude pe;
        int len;
@@ -452,6 +452,24 @@ static void proc_dbus_exclude_signal_handler(GVariant *params)
                return;
 }
 
+static void proc_dbus_exclude_method_handler(GDBusMethodInvocation *invocation, GVariant *params)
+{
+       const char *str = NULL;
+       pid_t pid = 0;
+
+       g_variant_get(params, "(&si)", &str, &pid);
+       if (!str || pid == 0) {
+               _E("invalid parameters");
+               g_dbus_method_invocation_return_error(invocation,
+                                                     G_DBUS_ERROR,
+                                                     G_DBUS_ERROR_INVALID_ARGS,
+                                                     "invalid arguments");
+               return;
+       }
+       proc_dbus_exclude_signal_handler(params);
+       D_BUS_REPLY_NULL(invocation);
+}
+
 static void proc_dbus_exclude_appid_signal_handler(GVariant *params)
 {
        char *str = NULL;
@@ -1008,6 +1026,10 @@ static const char dbus_methods_xml[] =
 "              </method>"
 "              <method name='PrePoweroff'>"
 "                      <arg type='i' name='MinusOne' direction='out'/>"
+"              </method name='ProcExclude'>"
+"                      <arg type='s' name='Action' direction='in'>"
+"                      <arg type='u' name='PID' direction='in'>"
+"              <method>"
 "              </method>"
 /* Following functions are defined in proc-usage-stats.c */
 "              <method name='ProcMemoryUsage'>"
@@ -1035,6 +1057,7 @@ static struct d_bus_method dbus_methods[] = {
 /* Following functions are defined in proc-usage-stats.c */
        { "ProcMemoryUsage", dbus_proc_memory_usage },
        { "ProcCpuUsage", dbus_proc_cpu_usage },
+       { "ProcExclude", proc_dbus_exclude_method_handler},
        /* Add methods here */
 };