summaryrefslogtreecommitdiff
path: root/profiles/alert
diff options
context:
space:
mode:
authorEder Ruiz Maria <eder.ruiz@openbossa.org>2012-10-02 16:24:42 -0400
committerJohan Hedberg <johan.hedberg@intel.com>2012-10-03 22:28:12 +0300
commit01da52289bfd5c288d52979bb7fcb64d23eb06d4 (patch)
tree075a9783248759641cd04152b711c002e4353d5b /profiles/alert
parent19df12d90a61515a70959e12b00fc071cc607914 (diff)
downloadbluez-01da52289bfd5c288d52979bb7fcb64d23eb06d4.tar.gz
alert: Add support for calling SetRinger()
When BlueZ wants to call SetRinger() method from org.bluez.AlertAgent interface for a registered agent, the function agent_ringer_set_ringer() must be called.
Diffstat (limited to 'profiles/alert')
-rw-r--r--profiles/alert/server.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index a96498868..2c124b497 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -426,6 +426,31 @@ static int agent_ringer_mute_once(void)
return 0;
}
+static int agent_ringer_set_ringer(const char *mode)
+{
+ struct alert_data *alert;
+ DBusMessage *msg;
+
+ alert = get_alert_data_by_category("ringer");
+ if (!alert) {
+ DBG("Category ringer is not registered");
+ return -EINVAL;
+ }
+
+ msg = dbus_message_new_method_call(alert->srv, alert->path,
+ ALERT_AGENT_INTERFACE, "SetRinger");
+ if (!msg)
+ return -ENOMEM;
+
+ dbus_message_append_args(msg, DBUS_TYPE_STRING, &mode,
+ DBUS_TYPE_INVALID);
+
+ dbus_message_set_no_reply(msg, TRUE);
+ g_dbus_send_message(btd_get_dbus_connection(), msg);
+
+ return 0;
+}
+
static void update_unread_alert(gpointer data, gpointer user_data)
{
struct alert_adapter *al_adapter = data;
@@ -498,6 +523,7 @@ static uint8_t ringer_cp_write(struct attribute *a,
switch (a->data[0]) {
case RINGER_SILENT_MODE:
DBG("Silent Mode");
+ agent_ringer_set_ringer("disabled");
break;
case RINGER_MUTE_ONCE:
DBG("Mute Once");
@@ -505,6 +531,7 @@ static uint8_t ringer_cp_write(struct attribute *a,
break;
case RINGER_CANCEL_SILENT_MODE:
DBG("Cancel Silent Mode");
+ agent_ringer_set_ringer("enabled");
break;
default:
DBG("Invalid command (0x%02x)", a->data[0]);