All pastes #1794957 Raw Edit

Anonymous

public text v1 · immutable
#1794957 ·published 2010-02-13 01:55 UTC
rendered paste body
diff --git a/drivers/hfpmodem/hfpmodem.h b/drivers/hfpmodem/hfpmodem.h
index 6ec8a7c..c95ea3f 100644
--- a/drivers/hfpmodem/hfpmodem.h
+++ b/drivers/hfpmodem/hfpmodem.h
@@ -71,6 +71,7 @@ struct hfp_data {
 	unsigned int hf_features;
 	unsigned char cind_pos[HFP_INDICATOR_LAST];
 	unsigned int cind_val[HFP_INDICATOR_LAST];
+	gboolean agent_registered;
 };
 
 extern void hfp_netreg_init();
diff --git a/plugins/hfp.c b/plugins/hfp.c
index 1349d2d..3365397 100644
--- a/plugins/hfp.c
+++ b/plugins/hfp.c
@@ -544,9 +544,11 @@ static DBusMessage *hfp_agent_release(DBusConnection *conn,
 					DBusMessage *msg, void *data)
 {
 	struct ofono_modem *modem = data;
+	struct hfp_data *hfp_data = ofono_modem_get_data(modem);
 	const char *obj_path = ofono_modem_get_path(modem);
 
 	g_dbus_unregister_interface(connection, obj_path, HFP_AGENT_INTERFACE);
+	hfp_data->agent_registered = FALSE;
 
 	ofono_modem_remove(modem);
 
@@ -931,6 +933,8 @@ static int hfp_probe(struct ofono_modem *modem)
 	g_dbus_register_interface(connection, obj_path, HFP_AGENT_INTERFACE,
 			agent_methods, NULL, NULL, modem, NULL);
 
+	data->agent_registered = TRUE;
+
 	if (hfp_register_ofono_handsfree(modem) != 0)
 		return -EINVAL;
 
@@ -1033,15 +1037,14 @@ done:
 static int hfp_disable(struct ofono_modem *modem)
 {
 	struct hfp_data *data = ofono_modem_get_data(modem);
-	const char *obj_path = ofono_modem_get_path(modem);
+	gboolean send_disconnect = data->agent_registered;
 	int status;
 
 	DBG("%p", modem);
 
 	clear_data(modem);
 
-	if (g_dbus_unregister_interface(connection, obj_path,
-					HFP_AGENT_INTERFACE)) {
+	if (send_disconnect) {
 		status = send_method_call_with_reply(BLUEZ_SERVICE,
 					data->handsfree_path,
 					BLUEZ_GATEWAY_INTERFACE, "Disconnect",