Expose ProcExclude as a method call 79/178579/4
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>
Tue, 29 May 2018 15:56:04 +0000 (17:56 +0200)
Change-Id: I1fa8be9305d50d8c27924e6e94785cb888731b74
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
src/proc-stat/proc-monitor.c

index 0236bc57bc0df12d59e622339d834153238e13c8..ed34303a66896e174bfbb83c07a1dfce89f6847d 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;
@@ -1009,6 +1027,10 @@ static const char dbus_methods_xml[] =
 "              <method name='PrePoweroff'>"
 "                      <arg type='i' name='MinusOne' direction='out'/>"
 "              </method>"
+"              <method name='ProcExclude'>"
+"                      <arg type='s' name='Action' direction='in'/>"
+"                      <arg type='i' name='PID' direction='in'/>"
+"              </method>"
 /* Following functions are defined in proc-usage-stats.c */
 "              <method name='ProcMemoryUsage'>"
 "                      <arg type='ai' name='ProcList' direction='in'/>"
@@ -1032,6 +1054,7 @@ static struct d_bus_method dbus_methods[] = {
        { "GetMemInfo", dbus_get_meminfo },
        { "ReclaimMemory", dbus_reclaim_memory },
        { "PrePoweroff", dbus_pre_poweroff },
+       { "ProcExclude", proc_dbus_exclude_method_handler},
 /* Following functions are defined in proc-usage-stats.c */
        { "ProcMemoryUsage", dbus_proc_memory_usage },
        { "ProcCpuUsage", dbus_proc_cpu_usage },