static void new_connection_cb (DBusServer * server, DBusConnection* connection, gpointer user_data) { dbus_int32_t slot = -1; GObject * object; if (!dbus_connection_allocate_data_slot (&slot)) { g_warning ("error allocating data slot for DBusConnection"); dbus_connection_close (connection); return; } dbus_connection_ref (connection); dbus_connection_set_allow_anonymous (connection, TRUE); dbus_connection_setup_with_g_main (connection, NULL); object = g_object_new (p2p_object_get_type (), NULL); dbus_g_connection_register_g_object (dbus_connection_get_g_connection (connection), "/", object); dbus_connection_set_data (connection, slot, object, g_object_unref); }
static void new_connection(DBusServer *s, DBusConnection *c, void *userdata) { LassiServer *ls = userdata; g_assert(s); g_assert(c); if (ls->n_connections >= CONNECTIONS_MAX) return; dbus_connection_set_allow_anonymous(c, TRUE); connection_add(ls, c, FALSE); }
static void new_connection_callback (DBusServer *server, DBusConnection *new_connection, void *data) { BusContext *context = data; if (!bus_connections_setup_connection (context->connections, new_connection)) { _dbus_verbose ("No memory to setup new connection\n"); /* if we don't do this, it will get unref'd without * being disconnected... kind of strange really * that we have to do this, people won't get it right * in general. */ dbus_connection_close (new_connection); } dbus_connection_set_max_received_size (new_connection, context->limits.max_incoming_bytes); dbus_connection_set_max_message_size (new_connection, context->limits.max_message_size); dbus_connection_set_max_received_unix_fds (new_connection, context->limits.max_incoming_unix_fds); dbus_connection_set_max_message_unix_fds (new_connection, context->limits.max_message_unix_fds); dbus_connection_set_allow_anonymous (new_connection, context->allow_anonymous); /* on OOM, we won't have ref'd the connection so it will die. */ }