4 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
23 #include <sensorctl_log.h>
25 static GDBusConnection *connection;
35 #ifndef GLIB_VERSION_2_36
39 gaddr = g_dbus_address_get_for_bus_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
42 PRINT("ERROR: Failed to get dbus address : %s", error->message);
48 connection = g_dbus_connection_new_for_address_sync(gaddr,
49 (GDBusConnectionFlags)(G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT
50 | G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION),
55 PRINT("ERROR: Failed to get dbus connection : %s", error->message);
61 PRINT("G-DBUS connected[%s]\n",
62 g_dbus_connection_get_unique_name(connection));
71 g_dbus_connection_close_sync(connection, NULL, NULL);
72 g_object_unref(connection);
78 bool dbus_emit_signal(gchar *dest_bus_name, gchar *object_path,
79 gchar *interface_name, gchar *signal_name,
80 GVariant *variant, GError **error)
82 g_dbus_connection_emit_signal(connection,
92 GVariant *make_variant_int(int count, char *options[])
96 return g_variant_new("(i)", atoi(options[0]));
98 return g_variant_new("(ii)", atoi(options[0]), atoi(options[1]));
100 return g_variant_new("(iii)", atoi(options[0]), atoi(options[1]), atoi(options[2]));