This package provices the test code of dbus activation stopping.
+###############################################################################
+%package -n dbus-send-receive-test
+Summary: dbus send and receive test.
+
+%description -n dbus-send-receive-test
+This package provices the test code of dbus send and receive.
+
+
###############################################################################
%prep
%setup -q
install -m 644 units/dbus-activation-stop-test.service %{buildroot}%{_unitdir}/
install -m 644 units/dbus-activation-stop-test.conf %{buildroot}%{_sysconfdir}/dbus-1/system.d/
+mkdir -p %{buildroot}%{_sysconfdir}/dbus-1/system.d
+install -m 644 units/dbus-send-receive-test.conf %{buildroot}%{_sysconfdir}/dbus-1/system.d/
+
###############################################################################
%files
%{_unitdir}/dbus-activation-stop-test.service
+###############################################################################
+%files -n dbus-send-receive-test
+%license LICENSE.Apache-2.0
+%manifest session-utils.manifest
+%config %{_sysconfdir}/dbus-1/system.d/dbus-send-receive-test.conf
+%{_bindir}/dbus-send-receive-test
+
+
###############################################################################
%files -n g-debug-fatal-warnings
%license LICENSE.Apache-2.0
%manifest session-utils.manifest
/etc/systemd/user.conf.d/g-debug-fatal-warnings.conf
/etc/systemd/system.conf.d/g-debug-fatal-warnings.conf
-
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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 <stdio.h>
+#include <signal.h>
+#include <unistd.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+#include <glib-unix.h>
+
+#include <systemd/sd-daemon.h>
+
+#define NAME "org.tizen.dbus-send-receive-test"
+#define PATH "/org/tizen/dbustest"
+#define INTERFACE "org.tizen.dbustest"
+#define METHOD "send"
+
+static void name_acquire(GDBusConnection *connection, const gchar *name, gpointer user_data)
+{
+ fprintf (stderr, "name acquire : %s\n", name);
+}
+
+static void name_lost(GDBusConnection *connection, const gchar *name, gpointer user_data)
+{
+ fprintf (stderr, "name lost : %s\n", name);
+}
+
+static void method_call_handler (GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *method_name,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
+{
+ gint input;
+
+ g_variant_get(parameters, "(i)", &input);
+ printf ("%s:%d\n", method_name, input);
+
+ g_dbus_method_invocation_return_value (invocation, g_variant_new("(i)", input));
+}
+
+static const GDBusInterfaceVTable vtable =
+{
+ method_call_handler
+};
+
+static int dbus_server()
+{
+ int owner_id;
+ GError *error = NULL;
+ GMainLoop *mainloop;
+ guint registration_id;
+ GDBusConnection *conn = NULL;
+ GDBusNodeInfo *introspection_data;
+
+ gchar *xml = "<node>"
+ " <interface name= 'org.tizen.dbustest'>"
+ " <method name= 'send'>"
+ " <arg type= 'i' name= 'input' direction= 'in'/>"
+ " <arg type= 'i' name= 'result' direction= 'out'/>"
+ " </method>"
+ " </interface>"
+ "</node>";
+
+ conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+ if (!conn || error) {
+ fprintf (stderr, "failed to get system bus\n");
+ return -1;
+ }
+
+ introspection_data = g_dbus_node_info_new_for_xml (xml, NULL);
+ if (!introspection_data) {
+ fprintf (stderr, "g_dbus_node_info_new_for_xml fails\n");
+ return -1;
+ }
+
+ registration_id = g_dbus_connection_register_object (conn, PATH, introspection_data->interfaces[0], &vtable, NULL, NULL, NULL);
+ if (registration_id == 0) {
+ fprintf (stderr, "g_dbus_connection_register_object fails\n");
+ return -1;
+ }
+
+ owner_id = g_bus_own_name_on_connection(conn, "org.tizen.dbus-send-receive-test", G_BUS_NAME_OWNER_FLAGS_NONE, name_acquire, name_lost, NULL, NULL);
+ if (owner_id == 0) {
+ fprintf (stderr, "g_bus_own_name_on_connection fails\n");
+ return -1;
+ }
+
+ mainloop = g_main_loop_new(NULL, FALSE);
+ g_main_loop_run(mainloop);
+
+ g_bus_unown_name (owner_id);
+ g_dbus_node_info_unref (introspection_data);
+ g_main_loop_unref(mainloop);
+
+ return 0;
+}
+
+static int dbus_client()
+{
+ gint result;
+ GError *error = NULL;
+ GVariant *reply;
+ GDBusConnection *conn;
+
+ conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+ if (!conn || error) {
+ fprintf (stderr, "failed to get system bus\n");
+ return -1;
+ }
+
+ reply = g_dbus_connection_call_sync(conn, NAME, PATH, INTERFACE, METHOD, g_variant_new("(i)", 1), NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+ if (!reply || error) {
+ fprintf (stderr, "g_dbus_connection_call_sync fails\n");
+ return -1;
+ }
+
+ g_variant_get (reply, "(i)", &result);
+ printf ("reply %d\n", result);
+
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+
+ if (argc != 2) {
+ printf ("Usage %s [server|client]\n", argv[0]);
+ exit (0);
+ }
+
+ if (strcmp(argv[1], "server") == 0)
+ return dbus_server();
+
+ if (strcmp(argv[1], "client") == 0)
+ return dbus_client();
+
+ return 0;
+}