4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Yong Yeon Kim <yy9875.kim@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
23 #include <dbus/dbus-glib.h>
24 #include <dbus/dbus.h>
25 #include <dbus/dbus-glib-lowlevel.h>
27 #include "media-server-dbg.h"
28 #include "media-server-types.h"
29 #include "media-server-dbus.h"
31 void ms_dbus_init(void)
36 /* Get a connection to the session bus */
37 dbus_error_init (&error);
38 bus = dbus_bus_get (DBUS_BUS_SESSION, &error);
40 MS_DBG ("Failed to connect to the D-BUS daemon: %s", error.message);
41 dbus_error_free (&error);
45 /* Set up this connection to work in a GLib event loop */
46 dbus_connection_setup_with_g_main (bus, NULL);
49 gboolean ms_dbus_send_noti(ms_dbus_noti_type_t data)
55 dbus_uint16_t noti_type = data;
57 /* Get a connection to the session bus */
58 dbus_error_init (&error);
59 bus = dbus_bus_get (DBUS_BUS_SESSION, &error);
61 MS_DBG ("Failed to connect to the D-BUS daemon: %s", error.message);
62 dbus_error_free (&error);
66 /* Create a new signal on the "MS_DBUS_INTERFACE" interface,
67 * from the object "MS_DBUS_PATH". */
68 message = dbus_message_new_signal (MS_DBUS_PATH, MS_DBUS_INTERFACE, MS_DBUS_NAME);
70 /* Append the notification type to the signal */
71 dbus_message_append_args (message, DBUS_TYPE_UINT16, ¬i_type, DBUS_TYPE_INVALID);
74 dbus_connection_send (bus, message, NULL);
76 /* Free the signal now we have finished with it */
77 dbus_message_unref (message);
79 /* Return TRUE to tell the event loop we want to be called again */