本文整理汇总了C++中dbus_connection_set_exit_on_disconnect函数的典型用法代码示例。如果您正苦于以下问题:C++ dbus_connection_set_exit_on_disconnect函数的具体用法?C++ dbus_connection_set_exit_on_disconnect怎么用?C++ dbus_connection_set_exit_on_disconnect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dbus_connection_set_exit_on_disconnect函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: avahi_dbus_bus_get
/* This function acts like dbus_bus_get but creates a private
* connection instead. */
static DBusConnection* avahi_dbus_bus_get(DBusError *error) {
DBusConnection *c;
#ifdef HAVE_DBUS_BUS_GET_PRIVATE
if (!(c = dbus_bus_get_private(DBUS_BUS_SYSTEM, error)))
return NULL;
dbus_connection_set_exit_on_disconnect(c, FALSE);
#else
const char *a;
if (!(a = getenv("DBUS_SYSTEM_BUS_ADDRESS")) || !*a)
a = DBUS_SYSTEM_BUS_DEFAULT_ADDRESS;
if (!(c = dbus_connection_open_private(a, error)))
return NULL;
dbus_connection_set_exit_on_disconnect(c, FALSE);
if (!dbus_bus_register(c, error)) {
#ifdef HAVE_DBUS_CONNECTION_CLOSE
dbus_connection_close(c);
#else
dbus_connection_disconnect(c);
#endif
dbus_connection_unref(c);
return NULL;
}
#endif
return c;
}
开发者ID:EBone,项目名称:Faust,代码行数:34,代码来源:client.c
示例2: _asdbus_get_session_connection
static DBusConnection *
_asdbus_get_session_connection()
{
DBusError error;
int res;
DBusConnection *session_conn;
dbus_error_init (&error);
session_conn = dbus_bus_get (DBUS_BUS_SESSION, &error);
if (dbus_error_is_set (&error)) {
show_error ("Failed to connect to Session DBus: %s", error.message);
} else {
dbus_connection_set_exit_on_disconnect (session_conn, FALSE);
res = dbus_bus_request_name (session_conn,
AFTERSTEP_DBUS_SERVICE_NAME,
DBUS_NAME_FLAG_REPLACE_EXISTING |
DBUS_NAME_FLAG_ALLOW_REPLACEMENT,
&error);
if (dbus_error_is_set (&error)) {
show_error ("Failed to request name from DBus: %s", error.message);
} else if (res != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
show_error ("Failed to request name from DBus - not a primary owner.");
} else {
dbus_connection_register_object_path (session_conn,
AFTERSTEP_DBUS_ROOT_PATH,
&ASDBusMessagesVTable, 0);
}
}
if (dbus_error_is_set (&error))
dbus_error_free (&error);
return session_conn;
}
开发者ID:afterstep,项目名称:afterstep,代码行数:34,代码来源:dbus.c
示例3: dbus_error_init
int Keyboard::dbus_connect()
{
DBusError error;
dbus_error_init(&error);
if (!(conn = dbus_bus_get_private(DBUS_BUS_SESSION, &error)))
{
CLog::Log(LOGWARNING, "dbus_bus_get_private(): %s", error.message);
goto fail;
}
dbus_connection_set_exit_on_disconnect(conn, FALSE);
return 0;
fail:
if (dbus_error_is_set(&error))
dbus_error_free(&error);
if (conn)
{
dbus_connection_close(conn);
dbus_connection_unref(conn);
conn = NULL;
}
return -1;
}
开发者ID:CheckLiu,项目名称:pi,代码行数:29,代码来源:Keyboard.cpp
示例4: initNative
/* Returns true on success (even if adapter is present but disabled).
* Return false if dbus is down, or another serious error (out of memory)
*/
static bool initNative(JNIEnv* env, jobject object) {
LOGV(__FUNCTION__);
#ifdef HAVE_BLUETOOTH
nat = (native_data_t *)calloc(1, sizeof(native_data_t));
if (NULL == nat) {
LOGE("%s: out of memory!", __FUNCTION__);
return false;
}
env->GetJavaVM( &(nat->vm) );
nat->envVer = env->GetVersion();
nat->me = env->NewGlobalRef(object);
DBusError err;
dbus_error_init(&err);
dbus_threads_init_default();
nat->conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
if (dbus_error_is_set(&err)) {
LOGE("Could not get onto the system bus: %s", err.message);
dbus_error_free(&err);
return false;
}
dbus_connection_set_exit_on_disconnect(nat->conn, FALSE);
#endif /*HAVE_BLUETOOTH*/
return true;
}
开发者ID:SciAps,项目名称:android-frameworks-base,代码行数:28,代码来源:android_server_BluetoothHidService.cpp
示例5: get_session_bus
static DBusGConnection *
get_session_bus (void)
{
GError *error;
DBusGConnection *bus;
DBusConnection *connection;
error = NULL;
bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
if (bus == NULL) {
g_warning ("Couldn't connect to session bus: %s",
error->message);
g_error_free (error);
goto out;
}
connection = dbus_g_connection_get_connection (bus);
dbus_connection_add_filter (connection,
(DBusHandleMessageFunction)
bus_message_handler,
NULL, NULL);
dbus_connection_set_exit_on_disconnect (connection, FALSE);
out:
return bus;
}
开发者ID:TheCoffeMaker,项目名称:Mate-Desktop-Environment,代码行数:27,代码来源:main.c
示例6: cgm_dbus_connect
static bool cgm_dbus_connect(void)
{
DBusError dbus_error;
dbus_error_init(&dbus_error);
connection = dbus_connection_open_private(CGMANAGER_DBUS_SOCK, &dbus_error);
if (!connection) {
dbus_error_free(&dbus_error);
return false;
}
dbus_connection_set_exit_on_disconnect(connection, FALSE);
dbus_error_free(&dbus_error);
cgroup_manager = nih_dbus_proxy_new(NULL, connection,
NULL /* p2p */,
"/org/linuxcontainers/cgmanager", NULL, NULL);
if (!cgroup_manager) {
NihError *nerr;
nerr = nih_error_get();
nih_free(nerr);
cgm_dbus_disconnect();
return false;
}
// force fd passing negotiation
if (cgmanager_ping_sync(NULL, cgroup_manager, 0) != 0) {
NihError *nerr;
nerr = nih_error_get();
nih_free(nerr);
cgm_dbus_disconnect();
return false;
}
return true;
}
开发者ID:ar45,项目名称:cgmanager,代码行数:34,代码来源:cgm-concurrent.c
示例7: _new_connection
static void
_new_connection (DBusServer *server,
DBusConnection *connection,
void *data)
{
ServiceData *svc = (ServiceData *)data;
DBusObjectPathVTable vt = {
_unregister_handler,
_handle_message,
NULL, NULL, NULL, NULL
};
rb_debug ("new connection to metadata service");
/* don't allow more than one connection at a time */
if (svc->connection) {
rb_debug ("metadata service already has a client. go away.");
return;
}
dbus_connection_register_object_path (connection,
RB_METADATA_DBUS_OBJECT_PATH,
&vt,
svc);
dbus_connection_ref (connection);
dbus_connection_setup_with_g_main (connection,
g_main_loop_get_context (svc->loop));
if (!svc->external)
dbus_connection_set_exit_on_disconnect (connection, TRUE);
}
开发者ID:AdamZ,项目名称:rhythmbox-magnatune,代码行数:30,代码来源:rb-metadata-dbus-service.c
示例8: init_dbus
void init_dbus()
{
GError *error = NULL;
DBusConnection *local_conn;
main_thread = g_thread_self();
info_mutex = g_mutex_new();
info_cond = g_cond_new();
AUDDBG ("Trying to initialize D-Bus.\n");
dbus_conn = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
if (dbus_conn == NULL)
{
g_warning("Unable to connect to dbus: %s", error->message);
g_error_free(error);
return;
}
g_type_init();
g_object_new(audacious_rc_get_type(), NULL);
g_object_new(mpris_root_get_type(), NULL);
mpris = g_object_new(mpris_player_get_type(), NULL);
g_object_new(mpris_tracklist_get_type(), NULL);
local_conn = dbus_g_connection_get_connection(dbus_conn);
dbus_connection_set_exit_on_disconnect(local_conn, FALSE);
}
开发者ID:gnu-andrew,项目名称:audacious.old,代码行数:27,代码来源:dbus.c
示例9: hd_status_plugin_item_get_dbus_connection
/**
* hd_status_plugin_item_get_dbus_connection:
* @item: A #HDStatusPluginItem
* @type: The #DBusBusType %DBUS_BUS_SESSION or %DBUS_BUS_SYSTEM
* @error: A #DBusError to return error messages
*
* Creates a new private #DBusConnection to the D-Bus session or system bus.
*
* It is similar to the dbus_bus_get_private() function but in contrast to the
* dbus_bus_get_private() function the application will not exit if the connection
* closes. Additionally this function is used to map the unique D-Bus name to the
* plugin.
*
* So this function should be used by plugins to create D-Bus connections.
*
* Returns: A new private connection to bus %type. The connection must be unrefed with dbus_connection_unref() when it is not longer needed.
**/
DBusConnection *
hd_status_plugin_item_get_dbus_connection (HDStatusPluginItem *item,
DBusBusType type,
DBusError *error)
{
DBusConnection *connection;
g_return_val_if_fail (HD_IS_STATUS_PLUGIN_ITEM (item), NULL);
/* Create a private connection */
connection = dbus_bus_get_private (type, error);
if (!connection || (error != NULL && dbus_error_is_set (error)))
return NULL;
/* Do not exit on disconnect */
dbus_connection_set_exit_on_disconnect (connection, FALSE);
/* Log the connection name for debug purposes */
g_debug ("Plugin '%s' opened D-Bus connection '%s'.",
hd_status_plugin_item_get_dl_filename (item),
dbus_bus_get_unique_name (connection));
return connection;
}
开发者ID:Cordia,项目名称:libhildondesktop,代码行数:42,代码来源:hd-status-plugin-item.c
示例10: weston_dbus_open
int weston_dbus_open(struct wl_event_loop *loop, DBusBusType bus,
DBusConnection **out, struct wl_event_source **ctx_out)
{
DBusConnection *c;
int r;
/* Ihhh, global state.. stupid dbus. */
dbus_connection_set_change_sigpipe(FALSE);
/* This is actually synchronous. It blocks for some authentication and
* setup. We just trust the dbus-server here and accept this blocking
* call. There is no real reason to complicate things further and make
* this asynchronous/non-blocking. A context should be created during
* thead/process/app setup, so blocking calls should be fine. */
c = dbus_bus_get_private(bus, NULL);
if (!c)
return -EIO;
dbus_connection_set_exit_on_disconnect(c, FALSE);
r = weston_dbus_bind(loop, c, ctx_out);
if (r < 0)
goto error;
*out = c;
return r;
error:
dbus_connection_close(c);
dbus_connection_unref(c);
return r;
}
开发者ID:ChristophHaag,项目名称:weston,代码行数:32,代码来源:dbus.c
示例11: dbus_connection_set_exit_on_disconnect
CUPowerSyscall::CUPowerSyscall()
{
CLog::Log(LOGINFO, "Selected UPower as PowerSyscall");
m_lowBattery = false;
//! @todo do not use dbus_connection_pop_message() that requires the use of a
//! private connection
if (m_connection.Connect(DBUS_BUS_SYSTEM, true))
{
dbus_connection_set_exit_on_disconnect(m_connection, false);
CDBusError error;
dbus_bus_add_match(m_connection, "type='signal',interface='org.freedesktop.UPower'", error);
dbus_connection_flush(m_connection);
if (error)
{
error.Log("UPower: Failed to attach to signal");
m_connection.Destroy();
}
}
m_CanPowerdown = false;
m_CanReboot = false;
UpdateCapabilities();
EnumeratePowerSources();
}
开发者ID:FernetMenta,项目名称:xbmc,代码行数:30,代码来源:UPowerSyscall.cpp
示例12: dbus_error_init
CConsoleUPowerSyscall::CConsoleUPowerSyscall()
{
CLog::Log(LOGINFO, "Selected UPower and ConsoleKit as PowerSyscall");
m_lowBattery = false;
dbus_error_init (&m_error);
// TODO: do not use dbus_connection_pop_message() that requires the use of a
// private connection
m_connection = dbus_bus_get_private(DBUS_BUS_SYSTEM, &m_error);
if (m_connection)
{
dbus_connection_set_exit_on_disconnect(m_connection, false);
dbus_bus_add_match(m_connection, "type='signal',interface='org.freedesktop.UPower'", &m_error);
dbus_connection_flush(m_connection);
}
if (dbus_error_is_set(&m_error))
{
CLog::Log(LOGERROR, "UPower: Failed to attach to signal %s", m_error.message);
dbus_connection_close(m_connection);
dbus_connection_unref(m_connection);
m_connection = NULL;
}
m_CanPowerdown = ConsoleKitMethodCall("CanStop");
m_CanReboot = ConsoleKitMethodCall("CanRestart");
UpdateUPower();
EnumeratePowerSources();
}
开发者ID:A600,项目名称:xbmc,代码行数:34,代码来源:ConsoleUPowerSyscall.cpp
示例13: upstart_open
/**
* upstart_open:
* @parent: parent object for new proxy.
*
* Opens a connection to the Upstart init daemon and returns a proxy
* to the manager object. If @dest_name is not NULL, a connection is
* instead opened to the system bus and the proxy linked to the
* well-known name given.
*
* If @parent is not NULL, it should be a pointer to another object
* which will be used as a parent for the returned proxy. When all
* parents of the returned proxy are freed, the returned proxy will
* also be freed.
*
* Returns: newly allocated D-Bus proxy or NULL on raised error.
**/
NihDBusProxy *
upstart_open (const void *parent)
{
DBusError dbus_error;
DBusConnection *connection;
NihDBusProxy * upstart;
dbus_error_init (&dbus_error);
connection = dbus_bus_get (DBUS_BUS_SYSTEM, &dbus_error);
if (! connection) {
nih_dbus_error_raise (dbus_error.name, dbus_error.message);
dbus_error_free (&dbus_error);
return NULL;
}
dbus_connection_set_exit_on_disconnect (connection, FALSE);
dbus_error_free (&dbus_error);
upstart = nih_dbus_proxy_new (parent, connection,
DBUS_SERVICE_UPSTART,
DBUS_PATH_UPSTART,
NULL, NULL);
if (! upstart) {
dbus_connection_unref (connection);
return NULL;
}
upstart->auto_start = FALSE;
/* Drop initial reference now the proxy holds one */
dbus_connection_unref (connection);
return upstart;
}
开发者ID:cmjonze,项目名称:upstart,代码行数:51,代码来源:test_libupstart.c
示例14: pa_dbus_wrap_connection_new
pa_dbus_wrap_connection* pa_dbus_wrap_connection_new(pa_mainloop_api *m, pa_bool_t use_rtclock, DBusBusType type, DBusError *error) {
DBusConnection *conn;
pa_dbus_wrap_connection *pconn;
char *id;
pa_assert(type == DBUS_BUS_SYSTEM || type == DBUS_BUS_SESSION || type == DBUS_BUS_STARTER);
if (!(conn = dbus_bus_get_private(type, error)))
return NULL;
pconn = pa_xnew(pa_dbus_wrap_connection, 1);
pconn->mainloop = m;
pconn->connection = conn;
pconn->use_rtclock = use_rtclock;
dbus_connection_set_exit_on_disconnect(conn, FALSE);
dbus_connection_set_dispatch_status_function(conn, dispatch_status, pconn, NULL);
dbus_connection_set_watch_functions(conn, add_watch, remove_watch, toggle_watch, pconn, NULL);
dbus_connection_set_timeout_functions(conn, add_timeout, remove_timeout, toggle_timeout, pconn, NULL);
dbus_connection_set_wakeup_main_function(conn, wakeup_main, pconn, NULL);
pconn->dispatch_event = pconn->mainloop->defer_new(pconn->mainloop, dispatch_cb, conn);
pa_log_debug("Successfully connected to D-Bus %s bus %s as %s",
type == DBUS_BUS_SYSTEM ? "system" : (type == DBUS_BUS_SESSION ? "session" : "starter"),
pa_strnull((id = dbus_connection_get_server_id(conn))),
pa_strnull(dbus_bus_get_unique_name(conn)));
dbus_free(id);
return pconn;
}
开发者ID:Klayv,项目名称:pulseaudio,代码行数:32,代码来源:dbus-util.c
示例15: dbus_connection_set_change_sigpipe
static DBusConnection *virDBusBusInit(DBusBusType type, DBusError *dbuserr)
{
DBusConnection *bus;
/* Allocate and initialize a new HAL context */
dbus_connection_set_change_sigpipe(FALSE);
dbus_threads_init_default();
dbus_error_init(dbuserr);
bus = sharedBus ?
dbus_bus_get(type, dbuserr) :
dbus_bus_get_private(type, dbuserr);
if (!bus)
return NULL;
dbus_connection_set_exit_on_disconnect(bus, FALSE);
/* Register dbus watch callbacks */
if (!dbus_connection_set_watch_functions(bus,
virDBusAddWatch,
virDBusRemoveWatch,
virDBusToggleWatch,
bus, NULL)) {
return NULL;
}
return bus;
}
开发者ID:cbosdo,项目名称:libvirt,代码行数:27,代码来源:virdbus.c
示例16: gconfd_dbus_init
gboolean
gconfd_dbus_init (void)
{
DBusError error;
gint ret;
dbus_error_init (&error);
bus_conn = dbus_bus_get (DBUS_BUS_SESSION, &error);
if (!bus_conn)
{
gconf_log (GCL_ERR, _("Daemon failed to connect to the D-BUS daemon:\n%s"),
error.message);
dbus_error_free (&error);
return FALSE;
}
/* We handle exiting ourselves on disconnect. */
dbus_connection_set_exit_on_disconnect (bus_conn, FALSE);
/* Add message filter to handle Disconnected. */
dbus_connection_add_filter (bus_conn,
(DBusHandleMessageFunction) server_filter_func,
NULL, NULL);
ret = dbus_bus_request_name (bus_conn,
GCONF_DBUS_SERVICE,
0,
&error);
if (ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)
{
gconf_log (GCL_ERR, "Daemon could not become primary owner");
return FALSE;
}
if (dbus_error_is_set (&error))
{
gconf_log (GCL_ERR, _("Daemon failed to acquire gconf service:\n%s"),
error.message);
dbus_error_free (&error);
return FALSE;
}
if (!dbus_connection_register_object_path (bus_conn,
server_path,
&server_vtable,
NULL))
{
gconf_log (GCL_ERR, _("Failed to register server object with the D-BUS bus daemon"));
return FALSE;
}
nr_of_connections = 1;
dbus_connection_setup_with_g_main (bus_conn, NULL);
return TRUE;
}
开发者ID:BARGAN,项目名称:gconf,代码行数:60,代码来源:gconfd-dbus.c
示例17: _cs_dbus_init
static void
_cs_dbus_init(void)
{
DBusConnection *dbc = NULL;
DBusError err;
dbus_error_init(&err);
dbc = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
if (!dbc) {
snprintf(_err, sizeof(_err),
"dbus_bus_get: %s", err.message);
err_set = 1;
dbus_error_free(&err);
return;
}
dbus_connection_set_exit_on_disconnect(dbc, FALSE);
db = dbc;
notifiers[num_notifiers].node_membership_fn =
_cs_dbus_node_membership_event;
notifiers[num_notifiers].node_quorum_fn =
_cs_dbus_node_quorum_event;
notifiers[num_notifiers].application_connection_fn =
_cs_dbus_application_connection_event;
notifiers[num_notifiers].rrp_faulty_fn =
_cs_dbus_rrp_faulty_event;
num_notifiers++;
}
开发者ID:ClusterLabs,项目名称:corosync,代码行数:32,代码来源:corosync-notifyd.c
示例18: dbus_error_init
/* returns NULL or error message, may fail silently if dbus daemon not yet up. */
char *dbus_init(void)
{
DBusConnection *connection = NULL;
DBusObjectPathVTable dnsmasq_vtable = {NULL, &message_handler, NULL, NULL, NULL, NULL };
DBusError dbus_error;
DBusMessage *message;
dbus_error_init (&dbus_error);
if (!(connection = dbus_bus_get (DBUS_BUS_SYSTEM, &dbus_error)))
return NULL;
dbus_connection_set_exit_on_disconnect(connection, FALSE);
dbus_connection_set_watch_functions(connection, add_watch, remove_watch,
NULL, NULL, NULL);
dbus_error_init (&dbus_error);
dbus_bus_request_name (connection, daemon->dbus_name, 0, &dbus_error);
if (dbus_error_is_set (&dbus_error))
return (char *)dbus_error.message;
if (!dbus_connection_register_object_path(connection, DNSMASQ_PATH,
&dnsmasq_vtable, NULL))
return _("could not register a DBus message handler");
daemon->dbus = connection;
if ((message = dbus_message_new_signal(DNSMASQ_PATH, daemon->dbus_name, "Up")))
{
dbus_connection_send(connection, message, NULL);
dbus_message_unref(message);
}
return NULL;
}
开发者ID:afdnlw,项目名称:dnsmasq-chinadns,代码行数:34,代码来源:dbus.c
示例19: elektraDbusSendMessage
int elektraDbusSendMessage (DBusBusType type, const char * keyName, const char * signalName)
{
DBusConnection * connection;
DBusError error;
DBusMessage * message;
const char * dest = NULL; // to all receivers
const char * interface = "org.libelektra";
const char * path = "/org/libelektra/configuration";
dbus_error_init (&error);
connection = dbus_bus_get (type, &error);
if (connection == NULL)
{
ELEKTRA_LOG_WARNING ("Failed to open connection to %s message bus: %s", (type == DBUS_BUS_SYSTEM) ? "system" : "session",
error.message);
dbus_connection_unref (connection);
dbus_error_free (&error);
return -1;
}
dbus_connection_set_exit_on_disconnect (connection, FALSE);
message = dbus_message_new_signal (path, interface, signalName);
if (message == NULL)
{
ELEKTRA_LOG_WARNING ("Couldn't allocate D-Bus message");
dbus_connection_unref (connection);
dbus_error_free (&error);
return -1;
}
if (dest && !dbus_message_set_destination (message, dest))
{
ELEKTRA_LOG_WARNING ("Not enough memory");
dbus_message_unref (message);
dbus_connection_unref (connection);
dbus_error_free (&error);
return -1;
}
if (!dbus_message_append_args (message, DBUS_TYPE_STRING, &keyName, DBUS_TYPE_INVALID))
{
ELEKTRA_LOG_WARNING ("Couldn't add message argument");
dbus_message_unref (message);
dbus_connection_unref (connection);
dbus_error_free (&error);
return -1;
}
dbus_connection_send (connection, message, NULL);
dbus_connection_flush (connection);
dbus_message_unref (message);
dbus_connection_unref (connection);
dbus_error_free (&error);
return 1;
}
开发者ID:reox,项目名称:libelektra,代码行数:59,代码来源:sendmessage.c
示例20: createConnection
::DBusConnection* createConnection() {
const ::DBusBusType libdbusType = ::DBusBusType::DBUS_BUS_SESSION;
::DBusConnection* libdbusConnection = dbus_bus_get_private(libdbusType, NULL);
dbus_connection_ref(libdbusConnection);
dbus_connection_set_exit_on_disconnect(libdbusConnection, false);
return libdbusConnection;
}
开发者ID:Pelagicore,项目名称:common-api-dbus-runtime,代码行数:8,代码来源:DBusConnectionTest.cpp
注:本文中的dbus_connection_set_exit_on_disconnect函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论