vbox-dbus.cpp revision 18456bfb9f30d08e5347aa108a2fef0c49c0ab0b
/** @file
*
* Module to dynamically load libdbus and load all symbols
* which are needed by VirtualBox.
*/
/*
* Copyright (C) 2008 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
#include "vbox-dbus.h"
/**
* Whether we have tried to load libdbus-1 yet. This flag should only be set
* to "true" after we have either loaded the library and all symbols which we
* need, or failed to load something and unloaded and set back to zero
* pLibDBus.
*/
static bool gCheckedForLibDBus = false;
/**
* Pointer to the libdbus-1 shared object. This should only be set once all
* needed libraries and symbols have been successfully loaded.
*/
/** The following are the symbols which we need from libdbus. */
void (*dbus_error_init)(DBusError *);
void (*dbus_error_free)(DBusError *);
void (*dbus_connection_unref)(DBusConnection *);
void (*dbus_connection_close)(DBusConnection *);
DBusError *);
void (*dbus_message_unref)(DBusMessage *);
DBusMessage* (*dbus_message_new_method_call)(const char *, const char *,
const char *, const char *);
const void *);
DBusMessage *, int,
int (*dbus_message_iter_get_arg_type) (DBusMessageIter *);
int (*dbus_message_iter_get_element_type) (DBusMessageIter *);
void (*dbus_message_iter_get_basic) (DBusMessageIter *, void *);
void *, DBusFreeFunction);
void *);
bool VBoxDBusCheckPresence(void)
{
if (ghLibDBus != 0 && gCheckedForLibDBus == true)
return true;
if (gCheckedForLibDBus == true)
return false;
{
return false;
}
(void **) &dbus_error_init))
(void **) &dbus_bus_get))
(void **) &dbus_bus_get_private))
(void **) &dbus_error_free))
(void **) &dbus_connection_unref))
(void **) &dbus_connection_close))
(void **) &dbus_connection_set_exit_on_disconnect))
(void **) &dbus_bus_name_has_owner))
(void **) &dbus_bus_add_match))
(void **) &dbus_bus_remove_match))
(void **) &dbus_message_unref))
(void **) &dbus_message_new_method_call))
(void **) &dbus_message_iter_init_append))
(void **) &dbus_message_iter_append_basic))
(void **) &dbus_connection_send_with_reply_and_block))
(void **) &dbus_message_iter_init))
(void **) &dbus_message_iter_get_arg_type))
(void **) &dbus_message_iter_get_element_type))
(void **) &dbus_message_iter_recurse))
(void **) &dbus_message_iter_get_basic))
(void **) &dbus_message_iter_next))
(void **) &dbus_connection_add_filter))
(void **) &dbus_connection_remove_filter))
(void **) &dbus_connection_read_write_dispatch))
(void **) &dbus_message_is_signal))
(void **) &dbus_connection_pop_message))
)
{
gCheckedForLibDBus = true;
return true;
}
else
{
gCheckedForLibDBus = true;
return false;
}
}
{
}
{
}