From 8ba8c8412bb9b91f488922e5a75d479affa67432 Mon Sep 17 00:00:00 2001 From: Nedko Arnaudov Date: Sun, 13 Dec 2009 18:19:29 +0200 Subject: [PATCH] gui: remove unused and duplicate dbus helper code --- gui/dbus_helpers.c | 161 ----------------------------------------------------- gui/dbus_helpers.h | 71 ----------------------- gui/main.c | 36 +++++++++++- wscript | 1 - 4 files changed, 34 insertions(+), 235 deletions(-) delete mode 100644 gui/dbus_helpers.c delete mode 100644 gui/dbus_helpers.h diff --git a/gui/dbus_helpers.c b/gui/dbus_helpers.c deleted file mode 100644 index 0fe30661..00000000 --- a/gui/dbus_helpers.c +++ /dev/null @@ -1,161 +0,0 @@ -/* -*- Mode: C ; c-basic-offset: 2 -*- */ -/* - * LADI Session Handler (ladish) - * - * Copyright (C) 2008, 2009 Nedko Arnaudov - * - ************************************************************************** - * This file contains D-Bus helpers - ************************************************************************** - * - * LADI Session Handler is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * LADI Session Handler is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with LADI Session Handler. If not, see - * or write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include -#include -#include -#include - -#include "dbus_helpers.h" -#include "../dbus/helpers.h" - -void -patchage_dbus_init() -{ - dbus_error_init(&g_dbus_error); - - // Connect to the bus - g_dbus_connection = dbus_bus_get(DBUS_BUS_SESSION, &g_dbus_error); - if (dbus_error_is_set(&g_dbus_error)) - { - //error_msg("dbus_bus_get() failed"); - //error_msg(g_dbus_error.message); - dbus_error_free(&g_dbus_error); - } - - dbus_connection_setup_with_g_main(g_dbus_connection, NULL); -} - -bool -patchage_dbus_call_valist( - bool response_expected, - const char * service, - const char * object, - const char * iface, - const char * method, - DBusMessage ** reply_ptr_ptr, - int in_type, - va_list ap) -{ - DBusMessage * request_ptr; - DBusMessage * reply_ptr; - - request_ptr = dbus_message_new_method_call( - service, - object, - iface, - method); - if (!request_ptr) - { - //throw std::runtime_error("dbus_message_new_method_call() returned 0"); - } - - dbus_message_append_args_valist(request_ptr, in_type, ap); - - // send message and get a handle for a reply - reply_ptr = dbus_connection_send_with_reply_and_block( - g_dbus_connection, - request_ptr, - DBUS_CALL_DEFAULT_TIMEOUT, - &g_dbus_error); - - dbus_message_unref(request_ptr); - - if (!reply_ptr) - { - if (response_expected) - { - //error_msg("no reply from server when calling method '%s', error is '%s'", method, _error.message); - } - dbus_error_free(&g_dbus_error); - } - else - { - *reply_ptr_ptr = reply_ptr; - } - - return reply_ptr; -} - -bool -patchage_dbus_call( - bool response_expected, - const char * service, - const char * object, - const char * iface, - const char * method, - DBusMessage ** reply_ptr_ptr, - int in_type, - ...) -{ - bool ret; - va_list ap; - - va_start(ap, in_type); - - ret = patchage_dbus_call_valist( - response_expected, - service, - object, - iface, - method, - reply_ptr_ptr, - in_type, - ap); - - va_end(ap); - - return (ap != NULL); -} - -void -patchage_dbus_add_match( - const char * rule) -{ - dbus_bus_add_match(g_dbus_connection, rule, NULL); -} - -void -patchage_dbus_add_filter( - DBusHandleMessageFunction function, - void * user_data) -{ - dbus_connection_add_filter(g_dbus_connection, function, user_data, NULL); -} - -void -patchage_dbus_uninit() -{ - if (g_dbus_connection) - { - dbus_connection_flush(g_dbus_connection); - } - - if (dbus_error_is_set(&g_dbus_error)) - { - dbus_error_free(&g_dbus_error); - } -} diff --git a/gui/dbus_helpers.h b/gui/dbus_helpers.h deleted file mode 100644 index ef0f4231..00000000 --- a/gui/dbus_helpers.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C ; c-basic-offset: 2 -*- */ -/* - * LADI Session Handler (ladish) - * - * Copyright (C) 2008, 2009 Nedko Arnaudov - * - ************************************************************************** - * This file contains interface to D-Bus helpers - ************************************************************************** - * - * LADI Session Handler is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * LADI Session Handler is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with LADI Session Handler. If not, see - * or write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef DBUS_HELPERS_H__4078F17D_E387_4F96_8CAB_FF0BFF83A295__INCLUDED -#define DBUS_HELPERS_H__4078F17D_E387_4F96_8CAB_FF0BFF83A295__INCLUDED - -#include - -void -patchage_dbus_init(); - -bool -patchage_dbus_call_valist( - bool response_expected, - const char* service, - const char* object, - const char* iface, - const char* method, - DBusMessage** reply_ptr, - int in_type, - va_list ap); - -bool -patchage_dbus_call( - bool response_expected, - const char* service, - const char* object, - const char* iface, - const char* method, - DBusMessage** reply_ptr, - int in_type, - ...); - -void -patchage_dbus_add_match( - const char * rule); - -void -patchage_dbus_add_filter( - DBusHandleMessageFunction function, - void * user_data); - -void -patchage_dbus_uninit(); - -extern DBusError g_dbus_error; - -#endif // #ifndef DBUS_HELPERS_H__4078F17D_E387_4F96_8CAB_FF0BFF83A295__INCLUDED diff --git a/gui/main.c b/gui/main.c index 48ab5143..c58f7800 100644 --- a/gui/main.c +++ b/gui/main.c @@ -27,6 +27,9 @@ #include "common.h" +#include +#include + #include #include "glade.h" @@ -41,7 +44,6 @@ #include "../proxies/studio_proxy.h" #include "ask_dialog.h" #include "../proxies/app_supervisor_proxy.h" -#include "dbus_helpers.h" GtkWidget * g_main_win; @@ -673,6 +675,35 @@ static void show_about(void) gtk_widget_hide(dialog); } +static void dbus_init(void) +{ + dbus_error_init(&g_dbus_error); + + // Connect to the bus + g_dbus_connection = dbus_bus_get(DBUS_BUS_SESSION, &g_dbus_error); + if (dbus_error_is_set(&g_dbus_error)) + { + //error_msg("dbus_bus_get() failed"); + //error_msg(g_dbus_error.message); + dbus_error_free(&g_dbus_error); + } + + dbus_connection_setup_with_g_main(g_dbus_connection, NULL); +} + +void dbus_uninit(void) +{ + if (g_dbus_connection) + { + dbus_connection_flush(g_dbus_connection); + } + + if (dbus_error_is_set(&g_dbus_error)) + { + dbus_error_free(&g_dbus_error); + } +} + int main(int argc, char** argv) { gtk_init(&argc, &argv); @@ -717,7 +748,7 @@ int main(int argc, char** argv) world_tree_init(); view_init(); - patchage_dbus_init(); + dbus_init(); if (!jack_proxy_init(jack_started, jack_stopped, jack_appeared, jack_disappeared)) { @@ -763,6 +794,7 @@ int main(int argc, char** argv) studio_proxy_uninit(); control_proxy_uninit(); + dbus_uninit(); uninit_glade(); return 0; diff --git a/wscript b/wscript index 8262968a..69b10e71 100644 --- a/wscript +++ b/wscript @@ -306,7 +306,6 @@ def build(bld): 'graph_view.c', #'project_properties.cpp', #'session.cpp', - 'dbus_helpers.c', 'canvas.cpp', 'graph_canvas.c', 'glade.c', -- 2.11.4.GIT