Esempio n. 1
0
static int bluetooth_init(void)
{
	connection = connman_dbus_get_connection();
	if (!connection)
		goto out;

	if (connman_technology_driver_register(&tech_driver) < 0) {
		connman_warn("Failed to initialize technology for Bluez 5");
		goto out;
	}

	devices = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
			device_free);

	if (connman_device_driver_register(&device_driver) < 0) {
		connman_warn("Failed to initialize device driver for "
				BLUEZ_SERVICE);
		connman_technology_driver_unregister(&tech_driver);
		goto out;
	}

	if (connman_network_driver_register(&network_driver) < 0) {
		connman_technology_driver_unregister(&tech_driver);
		connman_device_driver_unregister(&device_driver);
		goto out;
	}

	networks = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
			pan_free);

	client = g_dbus_client_new(connection, BLUEZ_SERVICE, BLUEZ_PATH);
	if (!client) {
		connman_warn("Failed to initialize D-Bus client for "
				BLUEZ_SERVICE);
		goto out;
	}

	g_dbus_client_set_proxy_handlers(client, object_added, object_removed,
			NULL, NULL);

	return 0;

out:
	if (networks)
		g_hash_table_destroy(networks);

	if (devices)
		g_hash_table_destroy(devices);

	if (client)
		g_dbus_client_unref(client);

	if (connection)
		dbus_connection_unref(connection);

	return -EIO;
}
Esempio n. 2
0
static void ethernet_exit(void)
{
    connman_technology_driver_unregister(&eth_driver);

    connman_technology_driver_unregister(&tech_driver);

    connman_network_driver_unregister(&cable_driver);

    connman_device_driver_unregister(&ethernet_driver);
}
Esempio n. 3
0
static void bluetooth_exit(void)
{
	g_dbus_remove_watch(connection, watch);
	g_dbus_remove_watch(connection, added_watch);
	g_dbus_remove_watch(connection, removed_watch);
	g_dbus_remove_watch(connection, adapter_watch);
	g_dbus_remove_watch(connection, device_removed_watch);
	g_dbus_remove_watch(connection, device_watch);
	g_dbus_remove_watch(connection, network_watch);

	/*
	 * We unset the disabling of the Bluetooth device when shutting down
	 * so that non-PAN BT connections are not affected.
	 */
	bluetooth_driver.disable = NULL;

	bluetooth_disconnect(connection, NULL);

	connman_technology_driver_unregister(&tech_driver);

	connman_device_driver_unregister(&bluetooth_driver);
	connman_network_driver_unregister(&pan_driver);

	dbus_connection_unref(connection);
}
Esempio n. 4
0
static int jolla_gps_init()
{
    DBG("");

    connection = connman_dbus_get_connection();
    if (connection == NULL) {
        connman_warn("Failed to get dbus connection");
        return -EIO;
    }

    watch = g_dbus_add_service_watch(connection, JOLLA_SERVICE, jolla_gps_connect,
                                     jolla_gps_disconnect, NULL, NULL);
    if (watch == 0) {
        connman_warn("Failed to add jolla service watcher");
        dbus_connection_unref(connection);
        return -EIO;
    }

    device_watch = g_dbus_add_signal_watch(connection, JOLLA_SERVICE, JOLLA_DEVICE_PATH,
                                           JOLLA_DEVICE_INTERFACE, PROPERTY_CHANGED,
                                           device_changed, NULL, NULL);
    if (device_watch == 0) {
        connman_warn("Failed to add jolla device property changed signal watcher");
        g_dbus_remove_watch(connection, watch);
        dbus_connection_unref(connection);
        return -EIO;
    }

    if (connman_technology_driver_register(&tech_driver) < 0) {
        connman_warn("Failed to initialize technology for Jolla GPS");
        g_dbus_remove_watch(connection, device_watch);
        g_dbus_remove_watch(connection, watch);
        dbus_connection_unref(connection);
        return -EIO;
    }

    if (connman_device_driver_register(&device_driver) < 0) {
        connman_warn("Failed to initialize device driver for " JOLLA_SERVICE);
        connman_technology_driver_unregister(&tech_driver);
        g_dbus_remove_watch(connection, device_watch);
        g_dbus_remove_watch(connection, watch);
        dbus_connection_unref(connection);
        return -EIO;
    }

    jolla_gps_device = connman_device_create("gps", CONNMAN_DEVICE_TYPE_GPS);
    if (jolla_gps_device == NULL) {
        connman_warn("Failed to creat GPS device");
        return -ENODEV;
    }

    if (connman_device_register(jolla_gps_device) < 0) {
        connman_warn("Failed to register GPS device");
        connman_device_unref(jolla_gps_device);
        jolla_gps_device = NULL;
        return -EIO;
    }

    return 0;
}
Esempio n. 5
0
static void bluetooth_exit(void)
{
	connman_network_driver_unregister(&network_driver);
	g_hash_table_destroy(networks);

	connman_device_driver_unregister(&device_driver);
	g_hash_table_destroy(devices);

	connman_technology_driver_unregister(&tech_driver);
	dbus_connection_unref(connection);
}
Esempio n. 6
0
static void jolla_gps_exit()
{
    DBG("");

    if (jolla_gps_device != NULL) {
        connman_device_unregister(jolla_gps_device);
        connman_device_unref(jolla_gps_device);
        jolla_gps_device = NULL;
    }

    connman_device_driver_unregister(&device_driver);
    connman_technology_driver_unregister(&tech_driver);
}
Esempio n. 7
0
static void bluetooth_exit(void)
{
	/*
	 * We unset the disabling of the Bluetooth device when shutting down
	 * so that non-PAN BT connections are not affected.
	 */
	device_driver.disable = NULL;

	g_dbus_client_unref(client);

	connman_network_driver_unregister(&network_driver);
	g_hash_table_destroy(networks);

	connman_device_driver_unregister(&device_driver);
	g_hash_table_destroy(devices);

	connman_technology_driver_unregister(&tech_driver);
	dbus_connection_unref(connection);
}
Esempio n. 8
0
static void bluetooth_exit(void)
{
	g_dbus_remove_watch(connection, watch);
	g_dbus_remove_watch(connection, added_watch);
	g_dbus_remove_watch(connection, removed_watch);
	g_dbus_remove_watch(connection, adapter_watch);
	g_dbus_remove_watch(connection, device_removed_watch);
	g_dbus_remove_watch(connection, device_watch);
	g_dbus_remove_watch(connection, network_watch);

	bluetooth_disconnect(connection, NULL);

	connman_technology_driver_unregister(&tech_driver);

	connman_device_driver_unregister(&bluetooth_driver);
	connman_network_driver_unregister(&pan_driver);

	dbus_connection_unref(connection);
}
Esempio n. 9
0
static void qmi_exit(void)
{
	DBG("");

	/* Remove all watching signals */
	g_dbus_remove_watch(connection, watch_service);
	g_dbus_remove_watch(connection, watch_property_changed);
	g_dbus_remove_watch(connection, watch_state_changed);
	g_dbus_remove_watch(connection, watch_technology_changed);

	/* Close all opened qmi devices, do this before unref all D-Bus connections */
	if(qmi_hash) {

		g_hash_table_foreach(qmi_hash, close_modem, NULL);

	}

	qmi_service_connected = FALSE;

	/* Unregister all drivers */
	connman_device_driver_unregister(&qmi_driver);
	connman_network_driver_unregister(&network_driver);
	connman_technology_driver_unregister(&tech_driver);

	g_dbus_proxy_unref(qmi_proxy_manager);
	g_dbus_client_unref(qmi_client);
	dbus_connection_unref(connection);

	sem_post(&new_device_sem);
	pthread_join(init_modems_id, NULL);
	sem_destroy(&new_device_sem);

	/* Free all devices and its allocated memory */
	if(qmi_hash) {

		g_hash_table_destroy(qmi_hash);
		qmi_hash = NULL;
	}

}