**/
#include <stdio.h>
+#include <unistd.h>
#include <assert.h>
#include <glib.h>
#include <gconf/gconf-client.h>
gboolean initial;
} Headphoned;
+static
+GMainLoop* loop = NULL;
+
+static void
+sig_handler (int sig G_GNUC_UNUSED)
+{
+ if (loop && g_main_loop_is_running (loop)) {
+ g_main_loop_quit (loop);
+ }
+}
+
void
on_volume_changed(GConfClient* client, guint gnxn_id, GConfEntry* entry,
gpointer data)
headphoned_new()
{
Headphoned* this = g_new0(Headphoned, 1);
- assert(this != NULL);
this->osso = osso_initialize("headphoned", "1.0", FALSE, NULL);
assert(this->osso != NULL);
on_volume_changed, this, NULL, NULL);
#endif
- this->session_bus = dbus_bus_get(DBUS_BUS_SESSION, NULL);
+ this->session_bus = (DBusConnection*)osso_get_dbus_connection(this->osso);
this->initial = TRUE;
return this;
int
main(int argc, char* argv[])
{
+ Headphoned *headphoned;
g_type_init();
- GMainLoop* loop = g_main_loop_new(NULL, FALSE);
+
+ signal(SIGINT, sig_handler);
+ signal(SIGQUIT, sig_handler);
+ signal(SIGTERM, sig_handler);
+
+ loop = g_main_loop_new(NULL, FALSE);
+ headphoned = headphoned_new();
GIOChannel* state = g_io_channel_new_file(STATE_FILE, "r", NULL);
- g_io_add_watch(state, G_IO_PRI, on_file_changed, headphoned_new());
+ g_io_add_watch(state, G_IO_PRI, on_file_changed, headphoned);
g_main_loop_run(loop);
+
+#ifdef ENABLE_VOLUME_CONTROL
+ if (headphoned->client) {
+ gconf_client_remove_dir(headphoned->client, GCONF_VOLUME_CONTROL, NULL);
+ g_object_unref(headphoned->client);
+ }
+#endif
+
+ if (state) {
+ g_io_channel_unref(state);
+ }
+
+ osso_deinitialize(headphoned->osso);
+ g_free(headphoned);
return 0;
}