$(MKDIR_P) $(DESTDIR)$(sysconfdir)/actd/available-modules
$(MKDIR_P) $(DESTDIR)$(sysconfdir)/actd/enabled-modules
+lib_LTLIBRARIES = libactd.la
+libactd_la_SOURCES = src/libactd/unit_control.c
+libactd_la_LDFLAGS = -pie -shared
+libactd_la_LIBADD = $(SYSCOMMON_LIBS)
+libactd_la_CFLAGS = $(AM_CFLAGS) $(SYSCOMMON_CFLAGS)
+libactd_includedir = $(includedir)/actd
+libactd_include_HEADERS = include/unit_control.h
bin_PROGRAMS = activationd_acceptance_checker
--- /dev/null
+#ifndef UNIT_CONTROL_H
+#define UNIT_CONTROL_H
+
+#include <glib.h>
+#include <glib/gi18n.h>
+
+typedef void (*actd_unit_cb)(GVariant *var, void *user_data, GError *err);
+
+int actd_start_unit(const char *unit);
+int actd_stop_unit(const char *unit);
+int actd_restart_unit(const char *unit);
+
+int actd_start_unit_async(const char *unit, actd_unit_cb cb, void *user_data);
+int actd_stop_unit_async(const char *unit, actd_unit_cb cb, void *user_data);
+int actd_restart_unit_async(const char *unit, actd_unit_cb cb, void *user_data);
+
+#endif /* UNIT_CONTROL_H */
%description -n event-processing-devel
Files used in external modules development
+%package -n libactd
+Summary: Activationd API
+Group: Development/Libraries
+BuildRequires: pkgconfig(libsyscommon)
+BuildRequires: pkgconfig(dlog)
+
+%description -n libactd
+This library provides API for interaction with modules
+
%prep
%setup -q
cp %{SOURCE1001} .
%files
+%files -n libactd
+%{_prefix}/lib/libactd.so*
+
%files -n event-processing-devel
%license COPYING
%{_includedir}/*
%{_libdir}/pkgconfig/*
+%{_prefix}/include/actd/*
%files -n event-processing-activation-dm -f activation-dm-files
%license COPYING
--- /dev/null
+/*
+ * This file is part of epc.
+ *
+ * Copyright © 2019 Samsung Electronics
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <libsyscommon/dbus-system.h>
+#include <errno.h>
+
+#include "unit_control.h"
+
+#define UNIT_CONTROL_NAME "org.tizen.Activationd"
+#define UNIT_CONTROL_INTERFACE "org.tizen.Activationd"
+#define UNIT_CONTROL_OBJ_PATH "/org/tizen/activationd"
+
+static int call_uc(const char *method, const char *unit)
+{
+ int ret;
+ GVariant *msg = NULL;
+ const char *result;
+
+ msg = dbus_handle_method_sync_with_reply_var(UNIT_CONTROL_NAME,
+ UNIT_CONTROL_OBJ_PATH,
+ UNIT_CONTROL_INTERFACE,
+ method,
+ g_variant_new("(s)", unit));
+
+ if (!msg)
+ return -EBADMSG;
+
+ g_variant_get(msg, "(s)", &result);
+ if (g_strcmp0(result, "ok") == 0)
+ ret = 0;
+ else
+ ret = -1;
+
+ g_free(result);
+ return ret;
+}
+
+static int call_uc_async(const char *method, const char *unit, actd_unit_cb cb, void *user_data)
+{
+ return dbus_handle_method_async_with_reply_var(UNIT_CONTROL_NAME,
+ UNIT_CONTROL_OBJ_PATH,
+ UNIT_CONTROL_INTERFACE,
+ method,
+ g_variant_new("(s)", unit),
+ cb,
+ -1,
+ user_data);
+}
+
+int actd_start_unit(const char *unit)
+{
+ return call_uc("Start", unit);
+}
+
+int actd_stop_unit(const char *unit)
+{
+ return call_uc("Stop", unit);
+}
+
+int actd_restart_unit(const char *unit)
+{
+ return call_uc("Restart", unit);
+}
+
+int actd_start_unit_async(const char *unit, actd_unit_cb cb, void *user_data)
+{
+ return call_uc_async("Start", unit, cb, user_data);
+}
+
+int actd_stop_unit_async(const char *unit, actd_unit_cb cb, void *user_data)
+{
+ return call_uc_async("Stop", unit, cb, user_data);
+}
+
+int actd_restart_unit_async(const char *unit, actd_unit_cb cb, void *user_data)
+{
+ return call_uc_async("Restart", unit, cb, user_data);
+}