*/
#include "stc-manager-gdbus.h"
+#include "stc-manager.h"
#include "stc-statistics.h"
#include "stc-restriction.h"
#include "stc-default-connection.h"
return ret;
}
+static gboolean __stc_manager_gdbus_manager_init(stc_s *stc)
+{
+ __STC_LOG_FUNC_ENTER__;
+ gboolean ret = TRUE;
+ gchar *s = NULL;
+
+ StcObjectSkeleton *object = NULL;
+ StcManager *manager = NULL;
+ s = g_strdup_printf(STC_DBUS_SERVICE_MANAGER_PATH);
+
+ object = stc_object_skeleton_new(s);
+ g_free(s);
+
+ manager = stc_manager_skeleton_new();
+ stc_object_skeleton_set_manager(object, manager);
+ g_object_unref(manager);
+
+ g_signal_connect(manager, "handle-stop",
+ G_CALLBACK(handle_manager_stop), stc);
+
+ g_dbus_object_manager_server_export(stc->obj_mgr,
+ G_DBUS_OBJECT_SKELETON(object));
+ g_object_unref(object);
+
+ stc->manager_obj = (gpointer)manager;
+
+ __STC_LOG_FUNC_EXIT__;
+ return ret;
+}
+
+
static void __stc_manager_gdbus_on_bus_acquired(GDBusConnection *connection,
const gchar *name,
gpointer user_data)
stc->connection = connection;
if (__stc_manager_gdbus_statistics_init(stc) == FALSE) {
- STC_LOGE("Can not signal connect to statistics");
+ STC_LOGE("Can not signal connect to statistics"); //LCOV_EXCL_LINE
/* Deinitialize and quit manager */
}
if (__stc_manager_gdbus_restriction_init(stc) == FALSE) {
- STC_LOGE("Cannot signal connect to restriction");
+ STC_LOGE("Cannot signal connect to restriction"); //LCOV_EXCL_LINE
+ /* Deinitialize and quit manager */
+ }
+
+ if (__stc_manager_gdbus_manager_init(stc) == FALSE) {
+ STC_LOGE("Cannot signal connect to manager"); //LCOV_EXCL_LINE
/* Deinitialize and quit manager */
}
STC_LOGD("name : %s", name);
}
+//LCOV_EXCL_START
static void __stc_manager_gdbus_on_name_lost(GDBusConnection *connection,
const gchar *name,
gpointer user_data)
{
STC_LOGD("name : %s", name);
}
+//LCOV_EXCL_STOP
void stc_manager_gdbus_init(gpointer stc_data)
{
stc->statistics_obj = NULL;
stc->restriction_obj = NULL;
+ stc->manager_obj = NULL;
__STC_LOG_FUNC_EXIT__;
}
GVariant *reply = NULL;
if (connection == NULL) {
- STC_LOGE("Failed to get GDBusconnection");
- return reply;
+ STC_LOGE("Failed to get GDBusconnection"); //LCOV_EXCL_LINE
+ return reply; //LCOV_EXCL_LINE
}
reply = g_dbus_connection_call_sync(connection,
if (reply == NULL) {
if (error != NULL) {
- STC_LOGE("g_dbus_connection_call_sync() failed"
+ STC_LOGE("g_dbus_connection_call_sync() failed" //LCOV_EXCL_LINE
"error [%d: %s]", error->code, error->message);
- g_error_free(error);
+ g_error_free(error); //LCOV_EXCL_LINE
} else {
- STC_LOGE("g_dbus_connection_call_sync() failed");
+ STC_LOGE("g_dbus_connection_call_sync() failed"); //LCOV_EXCL_LINE
}
return NULL;
GDestroyNotify user_data_free_func)
{
if (connection == NULL) {
- STC_LOGE("Failed to get GDBusconnection");
- return 0;
+ STC_LOGE("Failed to get GDBusconnection"); //LCOV_EXCL_LINE
+ return 0; //LCOV_EXCL_LINE
}
return g_dbus_connection_signal_subscribe(connection,
guint subscription_id)
{
if (connection == NULL) {
- STC_LOGE("Failed to get GDBusconnection");
- return;
+ STC_LOGE("Failed to get GDBusconnection"); //LCOV_EXCL_LINE
+ return; //LCOV_EXCL_LINE
}
g_dbus_connection_signal_unsubscribe(connection, subscription_id);
GVariant *value = NULL;
if (!cb) {
- __STC_LOG_FUNC_EXIT__;
- return;
+ __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return; //LCOV_EXCL_LINE
}
while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
GError *error = NULL;
if (connection == NULL) {
- STC_LOGE("GDBusconnection is NULL");
+ STC_LOGE("GDBusconnection is NULL"); //LCOV_EXCL_LINE
return 0;
}
parameters,
&error);
if (rv != TRUE) {
- STC_LOGE("Failed to emit signal [%s] interface [%s] Error [%s]",
+ STC_LOGE("Failed to emit signal [%s] interface [%s] Error [%s]", //LCOV_EXCL_LINE
signal_name, interface_name, error->message);
- g_error_free(error);
+ g_error_free(error); //LCOV_EXCL_LINE
} else {
STC_LOGD("[%s] signal sent on [%s] interface", signal_name,
interface_name);
return rv;
}
+
+gboolean handle_manager_stop(StcManager *object,
+ GDBusMethodInvocation *invocation)
+{
+ __STC_LOG_FUNC_ENTER__;
+ GVariant *return_parameters = NULL;
+
+ STC_LOGI("stc manager stop");
+
+ return_parameters = g_variant_new("(i)", STC_ERROR_NONE);
+
+ DEBUG_GDBUS_VARIANT("Return parameters: ", return_parameters);
+ STC_DBUS_REPLY(invocation, return_parameters);
+
+ stc_stop_manager();
+
+ __STC_LOG_FUNC_EXIT__;
+ return TRUE;
+}