src/monitor/monitor-thread.c
src/monitor/monitor-command.c
src/monitor/request-handler.c
+ #Generated by a custom command 'gdbus-codegen' below
+ src/monitor/monitor-dbus-stub.c
)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
--output-directory src/thermal/
scripts/thermal-dbus.xml
COMMENT "Generating GDBus stub for thermal interface")
+ADD_CUSTOM_COMMAND(
+ OUTPUT src/monitor/monitor-dbus-stub.c
+ COMMAND gdbus-codegen --interface-prefix org.tizen.
+ --generate-c-code monitor-dbus-stub
+ --output-directory src/monitor/
+ scripts/monitor-dbus.xml
+ COMMENT "Generating GDBus stub for monitor interface")
ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} -ldl -lm)
#define DBUS_PMQOS_I_ULTRAPOWERSAVING_HANDLER "handle_ultra_power_saving"
#define DBUS_PMQOS_I_SET_SCENARIO_HANDLER "handle_set_scenario"
+#define DBUS_MONITOR_INTERFACE "org.tizen.system.pass.monitor"
+#define DBUS_MONITOR_PATH "/Org/Tizen/System/Pass/Monitor"
+#define DBUS_MONITOR_I_SET_DEBUG_HANDLER "handle_set_debug"
+
#define DBUS_THERMAL_BUS_NAME "org.tizen.system.thermal"
#define DBUS_THERMAL_INTERFACE "org.tizen.system.thermal"
#define DBUS_THERMAL_PATH "/Org/Tizen/System/Thermal"
#include "pass/pass-dbus-stub.h"
#include "pmqos/pmqos-dbus-stub.h"
#include "thermal/thermal-dbus-stub.h"
+#include "monitor/monitor-dbus-stub.h"
#include "gdbus-definition.h"
void gdbus_put_instance_core(SystemPassCore **instance);
SystemPassPmqos *gdbus_get_instance_pmqos(void);
void gdbus_put_instance_pmqos(SystemPassPmqos **instance);
+SystemPassMonitor *gdbus_get_instance_monitor(void);
+void gdbus_put_instance_monitor(SystemPassMonitor **instance);
SystemThermal *gdbus_get_instance_thermal(void);
void gdbus_put_instance_thermal(SystemThermal **instance);
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<node name="/Org/Tizen/System/Pass/Monitor">
+ <interface name="org.tizen.system.pass.monitor">
+ <method name="SetDebug">
+ <arg type="b" name="on" direction="in" />
+ <arg type="i" name="return_code" direction="out" />
+ </method>
+ </interface>
+</node>
send_interface="org.tizen.system.pass.core"/>
<allow send_destination="org.tizen.system.pass"
send_interface="org.tizen.system.pass.pmqos"/>
+ <allow send_destination="org.tizen.system.pass"
+ send_interface="org.tizen.system.pass.monitor"/>
<allow send_destination="org.tizen.system.thermal"
send_interface="org.tizen.system.thermal"/>
</policy>
#include <util/device-notifier.h>
#include <util/log.h>
#include <util/devices.h>
+#include <util/gdbus-util.h>
#include <monitor/monitor.h>
static struct monitor g_monitor;
static gboolean g_debug_mode;
+static SystemPassMonitor *g_gdbus_instance;
+
struct monitor *monitor_get(void)
{
return &g_monitor;
g_debug_mode = on;
}
+static gboolean dbus_cb_monitor_set_debug(SystemPassMonitor *obj,
+ GDBusMethodInvocation *invoc,
+ gboolean on,
+ gpointer user_data)
+{
+ if (monitor_get_debug_mode() != on) {
+ monitor_set_debug_mode(on);
+ _I("PASS Resource Monitor debug mode is set to %s", on ? "on" : "off");
+ }
+
+ g_dbus_method_invocation_return_value(invoc, g_variant_new("(i)", 0));
+
+ return TRUE;
+}
+
+static struct gdbus_signal_info g_gdbus_signal_infos[] = {
+ {
+ .handler = DBUS_MONITOR_I_SET_DEBUG_HANDLER,
+ .cb = G_CALLBACK(dbus_cb_monitor_set_debug),
+ .cb_data = NULL,
+ .ret_id = 0,
+ },
+};
+
static int monitor_setup(void *data, void *user_data)
{
int ret;
{
int ret = 0;
+ g_gdbus_instance = gdbus_get_instance_monitor();
+ if (g_gdbus_instance == NULL) {
+ _E("failed to get instance for the %s interface\n",
+ DBUS_MONITOR_INTERFACE);
+ return -EINVAL;
+ }
+
+ ret = gdbus_connect_signal(g_gdbus_instance,
+ ARRAY_SIZE(g_gdbus_signal_infos), g_gdbus_signal_infos);
+ if (ret < 0) {
+ _E("failed to register dbus methods\n");
+ ret = -EINVAL;
+ goto out;
+ }
+
+ ret = gdbus_export_interface(PASS_DBUS_CORE,
+ g_gdbus_instance, DBUS_MONITOR_PATH);
+ if (ret < 0) {
+ _E("cannot export the dbus interface '%s' at the object path '%s'\n",
+ DBUS_MONITOR_INTERFACE,
+ DBUS_MONITOR_PATH);
+ ret = -EINVAL;
+ goto out_disconnect;
+ }
+
/*
* Register a notifier for the booting-done event. The actual
* initialization of the daemon is performed by this notifier after
if (ret < 0) {
_E("cannot register a callback function \
for the booting-done event (%d)\n", ret);
- return ret;
+ goto out_disconnect;
}
return 0;
+
+out_disconnect:
+ gdbus_disconnect_signal(g_gdbus_instance,
+ ARRAY_SIZE(g_gdbus_signal_infos), g_gdbus_signal_infos);
+out:
+ gdbus_put_instance_monitor(&g_gdbus_instance);
+
+ return ret;
+
}
static const struct device_ops monitor_device_ops = {
put_instance((gpointer *)instance);
}
+SystemPassMonitor *gdbus_get_instance_monitor(void)
+{
+ return system_pass_monitor_skeleton_new();
+}
+
+void gdbus_put_instance_monitor(SystemPassMonitor **instance)
+{
+ put_instance((gpointer *)instance);
+}
+
SystemThermal *gdbus_get_instance_thermal(void)
{
return system_thermal_skeleton_new();