Esempio n. 1
0
static connman_bool_t tethering_create(const char *path,
		struct connman_technology *technology, const char *bridge,
		connman_bool_t enabled)
{
	struct tethering_info *tethering = g_new0(struct tethering_info, 1);
	GDBusProxy *proxy;
	const char *method;
	connman_bool_t result;

	DBG("path %s bridge %s", path, bridge);

	if (bridge == NULL)
		return -EINVAL;

	proxy = g_dbus_proxy_new(client, path, "org.bluez.NetworkServer1");
	if (proxy == NULL)
		return FALSE;

	tethering->technology = technology;
	tethering->bridge = g_strdup(bridge);
	tethering->enable = enabled;

	if (tethering->enable)
		method = "Register";
	else
		method = "Unregister";

	result = g_dbus_proxy_method_call(proxy, method, tethering_append,
			tethering_create_cb, tethering, tethering_free);

	g_dbus_proxy_unref(proxy);

	return result;
}
Esempio n. 2
0
static void pan_free(gpointer data)
{
	struct bluetooth_pan *pan = data;

	if (pan->btnetwork_proxy) {
		g_dbus_proxy_unref(pan->btnetwork_proxy);
		pan->btnetwork_proxy = NULL;
	}

	if (pan->btdevice_proxy) {
		g_dbus_proxy_unref(pan->btdevice_proxy);
		pan->btdevice_proxy = NULL;
	}

	pan_remove_nap(pan);

	g_free(pan);
}
Esempio n. 3
0
static void device_free(gpointer data)
{
	struct connman_device *device = data;
	GDBusProxy *proxy = connman_device_get_data(device);

	connman_device_set_data(device, NULL);
	if (proxy)
		g_dbus_proxy_unref(proxy);

	connman_device_unregister(device);
	connman_device_unref(device);
}
Esempio n. 4
0
static void advertisement_free(void *data)
{
	struct advertisement *ad = data;

	if (ad->client) {
		g_dbus_client_set_disconnect_watch(ad->client, NULL, NULL);
		g_dbus_client_unref(ad->client);
	}

	bt_ad_unref(ad->data);

	g_dbus_proxy_unref(ad->proxy);

	if (ad->owner)
		g_free(ad->owner);

	if (ad->path)
		g_free(ad->path);

	free(ad);
}
Esempio n. 5
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;
	}

}
Esempio n. 6
0
static void proxy_free(gpointer data)
{
	GDBusProxy *proxy = data;

	if (proxy->client) {
		GDBusClient *client = proxy->client;

		if (client->proxy_removed)
			client->proxy_removed(proxy, client->user_data);

		g_dbus_remove_watch(client->dbus_conn, proxy->watch);

		g_hash_table_remove_all(proxy->prop_list);

		proxy->client = NULL;
	}

	if (proxy->removed_func)
		proxy->removed_func(proxy, proxy->removed_data);

	g_dbus_proxy_unref(proxy);
}
Esempio n. 7
0
/**
* @brief Do not call it.
* It will be called automatically after an entry in the hash table was removed
*/
static void free_hash_values(gpointer data) {

	struct qmi_data *qmi = (struct qmi_data *)data;

	DBG();

	if(qmi == NULL)
		return;

	g_free(qmi->apn);
	g_free(qmi->provider);
	g_free(qmi->imsi);
	g_free(qmi->devpath);
	g_free(qmi->devname);
	g_free(qmi->group);
	g_free(qmi->passphrase);
	g_free(qmi->object_path);
	g_free(qmi->username);
	g_dbus_proxy_unref(qmi->qmi_proxy_device);

	g_free(qmi);
}
Esempio n. 8
0
static void connect_handler(DBusConnection *connection, void *user_data)
{
	GDBusClient *client = user_data;
	GDBusProxy *proxy;

	g_print("Bluetooth connected\n");

	proxy = g_dbus_proxy_new(client, "/org/bluez",
					"org.bluez.ProfileManager1");
	if (!proxy)
		return;

	g_dbus_register_interface(connection, IAP_PATH,
					"org.bluez.Profile1",
					methods, NULL, NULL, NULL, NULL);

	g_dbus_proxy_method_call(proxy, "RegisterProfile", 
					register_profile_setup,
					register_profile_reply, NULL, NULL);

	g_dbus_proxy_unref(proxy);
}
Esempio n. 9
0
static int qmi_init(void)
{
	int err = 0;

	DBG("");

	err = sem_init(&new_device_sem, 0, 0);
	if(err == -1) {

		connman_error("Failure init semaphore, error %d", errno);
		return -errno;
	}

	/* Create new hash table to store all connecting devices */
	qmi_hash = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, free_hash_values);
	if(qmi_hash == NULL) {

		connman_error("Hash table could not be created.");
		return -ENOMEM;
	}

	connection = connman_dbus_get_connection();
	if(connection == NULL) {

		connman_error("D-Bus connection failed");
		return -EIO;
	}

	/* Create new D-Bus client to address qmi-dbus server */
	qmi_client = g_dbus_client_new(	connection,
									QMI_SERVICE,
									QMI_PATH);
	if(qmi_client == NULL) {

		connman_error("D-Bus client not created");
		return -EIO;
	}

	/* Create new proxy client to address qmi-dbus manager interface */
	qmi_proxy_manager = g_dbus_proxy_new(	qmi_client,
											QMI_MANAGER_PATH,
											QMI_MANAGER_INTERFACE);

	if(qmi_proxy_manager == NULL) {

		connman_error("QMI proxy manager not created");
		g_dbus_client_unref(qmi_client);
		return -EIO;
	}

	/* Watch appearing qmi-dbus */
	watch_service = g_dbus_add_service_watch(	connection,
												QMI_SERVICE,
												on_handle_qmi_connect,
												on_handle_qmi_disconnect,
												NULL, NULL);

	/* Watching qmi-dbus signals */
	watch_property_changed = g_dbus_add_signal_watch(	connection,
														QMI_SERVICE, NULL,
														QMI_DEVICE_INTERFACE, PROPERTY_CHANGED,
														on_handle_property_changed,
														NULL, NULL);

	watch_state_changed = g_dbus_add_signal_watch(	connection,
													QMI_SERVICE, NULL,
													QMI_DEVICE_INTERFACE, STATE_CHANGED,
													on_handle_state_changed,
													NULL, NULL);

	watch_technology_changed = g_dbus_add_signal_watch(	connection,
														QMI_SERVICE, NULL,
														QMI_DEVICE_INTERFACE, TECHNOLOGY_CHANGED,
														on_handle_technology_changed,
														NULL, NULL);


	if((watch_service == 0) ||
		(watch_property_changed == 0) ||
		(watch_state_changed == 0) ||
		(watch_technology_changed == 0))	{

		connman_error("Adding service or signal watch");
		err = -EIO;
		goto remove;
	}

	err = connman_network_driver_register(&network_driver);
	if(err < 0) {

		connman_error("Register network driver");
		goto remove;
	}

	err = connman_device_driver_register(&qmi_driver);
	if(err < 0) {

		connman_error("Register device driver");
		connman_network_driver_unregister(&network_driver);
		goto remove;
	}

	err = connman_technology_driver_register(&tech_driver);
	if(err < 0) {

		connman_error("Register technology driver");
		connman_network_driver_unregister(&network_driver);
		connman_device_driver_unregister(&qmi_driver);
		goto remove;
	}

	return 0;

remove:

	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);
	g_dbus_proxy_unref(qmi_proxy_manager);
	g_dbus_client_unref(qmi_client);
	dbus_connection_unref(connection);

	return err;
}