コード例 #1
0
static void
dispose (GObject *object)
{
	NmaBtDevicePrivate *priv = NMA_BT_DEVICE_GET_PRIVATE (object);

	dun_cleanup (NMA_BT_DEVICE (object));

	g_free (priv->bdaddr);
	priv->bdaddr = NULL;
	g_free (priv->alias);
	priv->alias = NULL;
	g_free (priv->object_path);
	priv->object_path = NULL;
	g_free (priv->status);
	priv->status = NULL;

	g_clear_object (&priv->window_group);
	g_clear_object (&priv->parent_window);

	if (priv->bdaddr_array) {
		g_byte_array_free (priv->bdaddr_array, TRUE);
		priv->bdaddr_array = NULL;
	}

	G_OBJECT_CLASS (nma_bt_device_parent_class)->dispose (object);
}
コード例 #2
0
ファイル: bt-widget.c プロジェクト: amedee/barcode-utils
static void
default_adapter_powered_changed (GObject *object,
                                 GParamSpec *pspec,
                                 gpointer user_data)
{
	PluginInfo *info = user_data;
	gboolean powered = TRUE;

	g_object_get (G_OBJECT (info->btclient), "default-adapter-powered", &powered, NULL);
	g_message ("Default Bluetooth adapter is %s", powered ? "powered" : "switched off");

	/* If the default adapter isn't powered we can't inspect the device
	 * and create a connection for it.
	 */
	if (powered) {
		gtk_label_set_text (GTK_LABEL (info->label), NULL); 
		if (info->dun)
			gtk_widget_set_sensitive (info->dun_button, TRUE);
	} else {
		/* powered only matters for DUN */
		if (info->dun) {
			dun_cleanup (info, _("The default Bluetooth adapter must be enabled before setting up a Dial-Up-Networking connection."), TRUE);
			/* Can't toggle the DUN button unless the adapter is powered */
			gtk_widget_set_sensitive (info->dun_button, FALSE);
		}
	}
}
コード例 #3
0
static void
dun_error (NmaBtDevice *self, const char *func, GError *error, const char *fallback)
{
	g_warning ("%s: DUN error: %s", func, (error && error->message) ? error->message : fallback);
	_set_status (self, _("Error: %s"), (error && error->message) ? error->message : fallback);

	_set_busy (self, FALSE);
	dun_cleanup (self);
	recheck_services_enabled (self);
}
コード例 #4
0
ファイル: bt-widget.c プロジェクト: amedee/barcode-utils
static void
dun_error (PluginInfo *info, const char *func, GError *error, const char *fallback)
{
	char *message;

	message = g_strdup_printf (_("Error: %s"), (error && error->message) ? error->message : fallback);
	g_warning ("%s: %s", func, message);
	dun_cleanup (info, message, TRUE);
	g_free (message);
}
コード例 #5
0
ファイル: bt-widget.c プロジェクト: amedee/barcode-utils
static void
wizard_done_cb (MobileWizard *self,
                gboolean canceled,
                MobileWizardAccessMethod *method,
                gpointer user_data)
{
	PluginInfo *info = user_data;
	BMConnection *connection = NULL;
	BMAGConfSettings *gconf_settings;
	BMAGConfConnection *exported;
	GByteArray *mac;
	BMSetting *s_bt;

	g_message ("%s: mobile wizard done", __func__);

	if (canceled || !method) {
		dun_error (info, __func__, NULL, _("Mobile wizard was canceled"));
		return;
	}

	if (method->devtype == BM_DEVICE_TYPE_CDMA)
		connection = dun_new_cdma (method);
	else if (method->devtype == BM_DEVICE_TYPE_GSM)
		connection = dun_new_gsm (method);
	else {
		dun_error (info, __func__, NULL, _("Unknown phone device type (not GSM or CDMA)"));
		return;
	}

	mobile_wizard_destroy (info->wizard);
	info->wizard = NULL;

	g_assert (connection);

	/* The Bluetooth settings */
	mac = get_array_from_bdaddr (info->bdaddr);
	g_assert (mac);
	s_bt = bm_setting_bluetooth_new ();
	g_object_set (G_OBJECT (s_bt),
	              BM_SETTING_BLUETOOTH_BDADDR, mac,
	              BM_SETTING_BLUETOOTH_TYPE, BM_SETTING_BLUETOOTH_TYPE_DUN,
	              NULL);
	g_byte_array_free (mac, TRUE);
	bm_connection_add_setting (connection, s_bt);

	g_message ("%s: adding new setting to GConf", __func__);

	gconf_settings = nma_gconf_settings_new (NULL);
	exported = nma_gconf_settings_add_connection (gconf_settings, connection);
	if (exported)
		info->dun_connection = BM_SETTINGS_CONNECTION_INTERFACE (exported);

	g_message ("%s: success!", __func__);
	dun_cleanup (info, _("Your phone is now ready to use!"), FALSE);
}
コード例 #6
0
static void
dun_add_cb (NMRemoteSettings *settings,
            NMRemoteConnection *connection,
            GError *error,
            gpointer user_data)
{
	NmaBtDevice *self = NMA_BT_DEVICE (user_data);

	if (error)
		_set_status (self, _("Failed to create DUN connection: %s"), error->message);
	else
		_set_status (self, _("Your phone is now ready to use!"));

	_set_busy (self, FALSE);
	dun_cleanup (self);
	recheck_services_enabled (self);
}