gui: remove unused and duplicate dbus helper code
This commit is contained in:
parent
b5565fd398
commit
8ba8c8412b
|
@ -1,161 +0,0 @@
|
|||
/* -*- Mode: C ; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* LADI Session Handler (ladish)
|
||||
*
|
||||
* Copyright (C) 2008, 2009 Nedko Arnaudov <nedko@arnaudov.name>
|
||||
*
|
||||
**************************************************************************
|
||||
* 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 <http://www.gnu.org/licenses/>
|
||||
* or write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <dbus/dbus.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
#include <dbus/dbus-glib-lowlevel.h>
|
||||
|
||||
#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);
|
||||
}
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
/* -*- Mode: C ; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* LADI Session Handler (ladish)
|
||||
*
|
||||
* Copyright (C) 2008, 2009 Nedko Arnaudov <nedko@arnaudov.name>
|
||||
*
|
||||
**************************************************************************
|
||||
* 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 <http://www.gnu.org/licenses/>
|
||||
* 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 <dbus/dbus.h>
|
||||
|
||||
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
|
36
gui/main.c
36
gui/main.c
|
@ -27,6 +27,9 @@
|
|||
|
||||
#include "common.h"
|
||||
|
||||
#include <dbus/dbus-glib.h>
|
||||
#include <dbus/dbus-glib-lowlevel.h>
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#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;
|
||||
|
|
Loading…
Reference in New Issue