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.
20 #include "dbus_util.h"
28 static GDBusConnection *connection;
38 #ifndef GLIB_VERSION_2_36
42 gaddr = g_dbus_address_get_for_bus_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
45 _E("Failed to get dbus address : %s\n", error->message);
51 connection = g_dbus_connection_new_for_address_sync(gaddr,
52 (GDBusConnectionFlags)(G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT
53 | G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION),
58 _E("Failed to get dbus connection : %s\n", error->message);
64 _I("G-DBUS connected[%s]\n",
65 g_dbus_connection_get_unique_name(connection));
74 g_dbus_connection_close_sync(connection, NULL, NULL);
75 g_object_unref(connection);
81 bool dbus_emit_signal(gchar *dest_bus_name, gchar *object_path,
82 gchar *interface_name, gchar *signal_name,
83 GVariant *variant, GError **error)
85 g_dbus_connection_emit_signal(connection,
95 GVariant *make_variant_int(int count, char *options[])
99 return g_variant_new("(i)", atoi(options[0]));
101 return g_variant_new("(ii)", atoi(options[0]), atoi(options[1]));
103 return g_variant_new("(iii)", atoi(options[0]), atoi(options[1]), atoi(options[2]));