Diff between cd9370f87454dcb1cb0512786b086cea63e6489c and 2983d07c6d96d255b7c49c59046270e61357bb7d

Changed Files

File Additions Deletions Status
profiles/alert/server.c +17 -1 modified
test/test-alert +9 -2 modified

Full Patch

diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 7e4c379..35f5004 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -179,9 +179,25 @@ static void alert_data_destroy(gpointer user_data)
 	g_free(alert);
 }
 
+static void alert_release(gpointer user_data)
+{
+	struct alert_data *alert = user_data;
+	DBusMessage *msg;
+
+	msg = dbus_message_new_method_call(alert->srv, alert->path,
+							ALERT_AGENT_INTERFACE,
+							"Release");
+	if (msg)
+		g_dbus_send_message(btd_get_dbus_connection(), msg);
+
+	alert_data_destroy(alert);
+}
+
 static void alert_destroy(gpointer user_data)
 {
-	g_slist_free_full(registered_alerts, alert_data_destroy);
+	DBG("");
+
+	g_slist_free_full(registered_alerts, alert_release);
 	registered_alerts = NULL;
 }
 
diff --git a/test/test-alert b/test/test-alert
index c92a719..1e241a3 100755
--- a/test/test-alert
+++ b/test/test-alert
@@ -15,9 +15,10 @@ BLUEZ_OBJECT_PATH = '/org/bluez'
 TEST_OBJECT_PATH = '/org/bluez/test'
 
 class AlertAgent(dbus.service.Object):
-	def __init__(self, bus, object_path, alert):
+	def __init__(self, bus, object_path, alert, mainloop):
 		dbus.service.Object.__init__(self, bus, object_path)
 		self.alert = alert
+		self.mainloop = mainloop
 
 	@dbus.service.method(ALERT_AGENT_INTERFACE, in_signature='',
 							out_signature='')
@@ -31,6 +32,12 @@ class AlertAgent(dbus.service.Object):
 		print('method SetRinger(%s) was called' % mode)
 		self.alert.NewAlert('ringer', 1, mode)
 
+	@dbus.service.method(ALERT_AGENT_INTERFACE, in_signature='',
+							out_signature='')
+	def Release(self):
+		print('method Release() was called')
+		self.mainloop.quit()
+
 def print_command_line(options):
 	if not options.verbose:
 		return False
@@ -145,7 +152,7 @@ bus = dbus.SystemBus()
 mainloop = gobject.MainLoop()
 alert = dbus.Interface(bus.get_object(BUS_NAME, BLUEZ_OBJECT_PATH),
 								ALERT_INTERFACE)
-alert_agent = AlertAgent(bus, TEST_OBJECT_PATH, alert)
+alert_agent = AlertAgent(bus, TEST_OBJECT_PATH, alert, mainloop)
 
 print_command_line(options)