Linux bluetooth development
 help / color / mirror / Atom feed
* [RFC BlueZ 04/22] alert: Add Phone Alert Service
From: Anderson Lizardo @ 2012-08-27 17:11 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Bruna Moreira
In-Reply-To: <1346087526-15107-1-git-send-email-anderson.lizardo@openbossa.org>

From: Bruna Moreira <bruna.moreira@openbossa.org>

---
 profiles/alert/server.c |   22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 3fda23d..cbf751f 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -26,11 +26,33 @@
 #include <config.h>
 #endif
 
+#include <glib.h>
+#include <bluetooth/uuid.h>
+
+#include "att.h"
 #include "adapter.h"
+#include "gatt-service.h"
+#include "gattrib.h"
+#include "gatt.h"
 #include "server.h"
 
+#define PHONE_ALERT_STATUS_SVC_UUID		0x180E
+
+static void register_phone_alert_service(struct btd_adapter *adapter)
+{
+	bt_uuid_t uuid;
+
+	bt_uuid16_create(&uuid, PHONE_ALERT_STATUS_SVC_UUID);
+
+	/* Phone Alert Status Service */
+	gatt_service_add(adapter, GATT_PRIM_SVC_UUID, &uuid,
+			GATT_OPT_INVALID);
+}
+
 static int alert_server_probe(struct btd_adapter *adapter)
 {
+	register_phone_alert_service(adapter);
+
 	return 0;
 }
 
-- 
1.7.9.5


^ permalink raw reply related

* [RFC BlueZ 05/22] alert: Add Ringer Control Point characteristic
From: Anderson Lizardo @ 2012-08-27 17:11 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Bruna Moreira
In-Reply-To: <1346087526-15107-1-git-send-email-anderson.lizardo@openbossa.org>

From: Bruna Moreira <bruna.moreira@openbossa.org>

---
 profiles/alert/server.c |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index cbf751f..0f96c55 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -31,12 +31,25 @@
 
 #include "att.h"
 #include "adapter.h"
+#include "device.h"
+#include "att-database.h"
+#include "log.h"
 #include "gatt-service.h"
 #include "gattrib.h"
 #include "gatt.h"
 #include "server.h"
 
 #define PHONE_ALERT_STATUS_SVC_UUID		0x180E
+#define RINGER_CP_CHR_UUID		0x2A40
+
+static uint8_t ringer_cp_write(struct attribute *a,
+						struct btd_device *device,
+						gpointer user_data)
+{
+	DBG("a = %p", a);
+
+	return 0;
+}
 
 static void register_phone_alert_service(struct btd_adapter *adapter)
 {
@@ -46,6 +59,11 @@ static void register_phone_alert_service(struct btd_adapter *adapter)
 
 	/* Phone Alert Status Service */
 	gatt_service_add(adapter, GATT_PRIM_SVC_UUID, &uuid,
+			/* Ringer Control Point characteristic */
+			GATT_OPT_CHR_UUID, RINGER_CP_CHR_UUID,
+			GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_WRITE_WITHOUT_RESP,
+			GATT_OPT_CHR_VALUE_CB, ATTRIB_WRITE,
+			ringer_cp_write, NULL,
 			GATT_OPT_INVALID);
 }
 
-- 
1.7.9.5


^ permalink raw reply related

* [RFC BlueZ 06/22] alert: Add Ringer Setting characteristic
From: Anderson Lizardo @ 2012-08-27 17:11 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Bruna Moreira
In-Reply-To: <1346087526-15107-1-git-send-email-anderson.lizardo@openbossa.org>

From: Bruna Moreira <bruna.moreira@openbossa.org>

---
 profiles/alert/server.c |   31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 0f96c55..7dca94d 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -36,11 +36,21 @@
 #include "log.h"
 #include "gatt-service.h"
 #include "gattrib.h"
+#include "attrib-server.h"
 #include "gatt.h"
 #include "server.h"
 
 #define PHONE_ALERT_STATUS_SVC_UUID		0x180E
 #define RINGER_CP_CHR_UUID		0x2A40
+#define RINGER_SETTING_CHR_UUID		0x2A41
+
+/* Ringer Setting characteristic values */
+enum {
+	RINGER_SILENT,
+	RINGER_NORMAL,
+};
+
+static uint8_t ringer_setting = RINGER_NORMAL;
 
 static uint8_t ringer_cp_write(struct attribute *a,
 						struct btd_device *device,
@@ -51,6 +61,21 @@ static uint8_t ringer_cp_write(struct attribute *a,
 	return 0;
 }
 
+static uint8_t ringer_setting_read(struct attribute *a,
+						struct btd_device *device,
+						gpointer user_data)
+{
+	struct btd_adapter *adapter = user_data;
+
+	DBG("a = %p", a);
+
+	if (a->data == NULL || a->data[0] != ringer_setting)
+		attrib_db_update(adapter, a->handle, NULL, &ringer_setting,
+						sizeof(ringer_setting), NULL);
+
+	return 0;
+}
+
 static void register_phone_alert_service(struct btd_adapter *adapter)
 {
 	bt_uuid_t uuid;
@@ -64,6 +89,12 @@ static void register_phone_alert_service(struct btd_adapter *adapter)
 			GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_WRITE_WITHOUT_RESP,
 			GATT_OPT_CHR_VALUE_CB, ATTRIB_WRITE,
 			ringer_cp_write, NULL,
+			/* Ringer Setting characteristic */
+			GATT_OPT_CHR_UUID, RINGER_SETTING_CHR_UUID,
+			GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ |
+							ATT_CHAR_PROPER_NOTIFY,
+			GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
+			ringer_setting_read, adapter,
 			GATT_OPT_INVALID);
 }
 
-- 
1.7.9.5


^ permalink raw reply related

* [RFC BlueZ 07/22] alert: Add Alert Status characteristic
From: Anderson Lizardo @ 2012-08-27 17:11 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Bruna Moreira
In-Reply-To: <1346087526-15107-1-git-send-email-anderson.lizardo@openbossa.org>

From: Bruna Moreira <bruna.moreira@openbossa.org>

---
 profiles/alert/server.c |   24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 7dca94d..332ffa0 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -41,6 +41,8 @@
 #include "server.h"
 
 #define PHONE_ALERT_STATUS_SVC_UUID		0x180E
+
+#define ALERT_STATUS_CHR_UUID		0x2A3F
 #define RINGER_CP_CHR_UUID		0x2A40
 #define RINGER_SETTING_CHR_UUID		0x2A41
 
@@ -51,6 +53,7 @@ enum {
 };
 
 static uint8_t ringer_setting = RINGER_NORMAL;
+static uint8_t alert_status = 0;
 
 static uint8_t ringer_cp_write(struct attribute *a,
 						struct btd_device *device,
@@ -61,6 +64,21 @@ static uint8_t ringer_cp_write(struct attribute *a,
 	return 0;
 }
 
+static uint8_t alert_status_read(struct attribute *a,
+						struct btd_device *device,
+						gpointer user_data)
+{
+	struct btd_adapter *adapter = user_data;
+
+	DBG("a = %p", a);
+
+	if (a->data == NULL || a->data[0] != alert_status)
+		attrib_db_update(adapter, a->handle, NULL, &alert_status,
+						sizeof(alert_status), NULL);
+
+	return 0;
+}
+
 static uint8_t ringer_setting_read(struct attribute *a,
 						struct btd_device *device,
 						gpointer user_data)
@@ -84,6 +102,12 @@ static void register_phone_alert_service(struct btd_adapter *adapter)
 
 	/* Phone Alert Status Service */
 	gatt_service_add(adapter, GATT_PRIM_SVC_UUID, &uuid,
+			/* Alert Status characteristic */
+			GATT_OPT_CHR_UUID, ALERT_STATUS_CHR_UUID,
+			GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ |
+							ATT_CHAR_PROPER_NOTIFY,
+			GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
+			alert_status_read, adapter,
 			/* Ringer Control Point characteristic */
 			GATT_OPT_CHR_UUID, RINGER_CP_CHR_UUID,
 			GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_WRITE_WITHOUT_RESP,
-- 
1.7.9.5


^ permalink raw reply related

* [RFC BlueZ 08/22] alert: Initial Alert Notification
From: Anderson Lizardo @ 2012-08-27 17:11 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1346087526-15107-1-git-send-email-anderson.lizardo@openbossa.org>

---
 profiles/alert/server.c |  113 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 113 insertions(+)

diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 332ffa0..419c7fd 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -41,11 +41,27 @@
 #include "server.h"
 
 #define PHONE_ALERT_STATUS_SVC_UUID		0x180E
+#define ALERT_NOTIF_SVC_UUID			0x1811
 
 #define ALERT_STATUS_CHR_UUID		0x2A3F
 #define RINGER_CP_CHR_UUID		0x2A40
 #define RINGER_SETTING_CHR_UUID		0x2A41
 
+#define ALERT_NOTIF_CP_CHR_UUID		0x2A44
+#define UNREAD_ALERT_CHR_UUID		0x2A45
+#define NEW_ALERT_CHR_UUID		0x2A46
+#define SUPP_NEW_ALERT_CAT_CHR_UUID	0x2A47
+#define SUPP_UNREAD_ALERT_CAT_CHR_UUID	0x2A48
+
+enum {
+	ENABLE_NEW_INCOMING,
+	ENABLE_UNREAD_CAT,
+	DISABLE_NEW_INCOMING,
+	DISABLE_UNREAD_CAT,
+	NOTIFY_NEW_INCOMING,
+	NOTIFY_UNREAD_CAT,
+};
+
 /* Ringer Setting characteristic values */
 enum {
 	RINGER_SILENT,
@@ -122,9 +138,106 @@ static void register_phone_alert_service(struct btd_adapter *adapter)
 			GATT_OPT_INVALID);
 }
 
+static uint8_t supp_new_alert_cat_read(struct attribute *a,
+						struct btd_device *device,
+						gpointer user_data)
+{
+	struct btd_adapter *adapter = user_data;
+	uint8_t value[] = {0x00, 0x00};
+
+	DBG("a = %p", a);
+
+	if (a->data == NULL)
+		attrib_db_update(adapter, a->handle, NULL, value, sizeof(value),
+									NULL);
+
+	return 0;
+}
+
+static uint8_t supp_unread_alert_cat_read(struct attribute *a,
+						struct btd_device *device,
+						gpointer user_data)
+{
+	struct btd_adapter *adapter = user_data;
+	uint8_t value[] = {0x00, 0x00};
+
+	DBG("a = %p", a);
+
+	if (a->data == NULL)
+		attrib_db_update(adapter, a->handle, NULL, value, sizeof(value),
+									NULL);
+
+	return 0;
+}
+
+static uint8_t alert_notif_cp_write(struct attribute *a,
+						struct btd_device *device,
+						gpointer user_data)
+{
+	DBG("a = %p", a);
+
+	switch (a->data[0]) {
+	case ENABLE_NEW_INCOMING:
+		DBG("ENABLE_NEW_INCOMING: 0x%02x", a->data[1]);
+		break;
+	case ENABLE_UNREAD_CAT:
+		DBG("ENABLE_UNREAD_CAT: 0x%02x", a->data[1]);
+		break;
+	case DISABLE_NEW_INCOMING:
+		DBG("DISABLE_NEW_INCOMING: 0x%02x", a->data[1]);
+		break;
+	case DISABLE_UNREAD_CAT:
+		DBG("DISABLE_UNREAD_CAT: 0x%02x", a->data[1]);
+		break;
+	case NOTIFY_NEW_INCOMING:
+		DBG("NOTIFY_NEW_INCOMING: 0x%02x", a->data[1]);
+		break;
+	case NOTIFY_UNREAD_CAT:
+		DBG("NOTIFY_UNREAD_CAT: 0x%02x", a->data[1]);
+		break;
+	default:
+		DBG("0x%02x 0x%02x", a->data[0], a->data[1]);
+	}
+
+	return 0;
+}
+
+static void register_alert_notif_service(struct btd_adapter *adapter)
+{
+	bt_uuid_t uuid;
+
+	bt_uuid16_create(&uuid, ALERT_NOTIF_SVC_UUID);
+
+	/* Alert Notification Service */
+	gatt_service_add(adapter, GATT_PRIM_SVC_UUID, &uuid,
+			/* Supported New Alert Category */
+			GATT_OPT_CHR_UUID, SUPP_NEW_ALERT_CAT_CHR_UUID,
+			GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ,
+			GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
+			supp_new_alert_cat_read, adapter,
+			/* New Alert */
+			GATT_OPT_CHR_UUID, NEW_ALERT_CHR_UUID,
+			GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
+			/* Supported Unread Alert Category */
+			GATT_OPT_CHR_UUID, SUPP_UNREAD_ALERT_CAT_CHR_UUID,
+			GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ,
+			GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
+			supp_unread_alert_cat_read, adapter,
+			/* Unread Alert Status */
+			GATT_OPT_CHR_UUID, UNREAD_ALERT_CHR_UUID,
+			GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
+			/* Alert Notification Control Point */
+			GATT_OPT_CHR_UUID, ALERT_NOTIF_CP_CHR_UUID,
+			GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_WRITE,
+			GATT_OPT_CHR_VALUE_CB, ATTRIB_WRITE,
+			alert_notif_cp_write, NULL,
+			GATT_OPT_INVALID);
+}
+
 static int alert_server_probe(struct btd_adapter *adapter)
 {
 	register_phone_alert_service(adapter);
+	register_alert_notif_service(adapter);
 
 	return 0;
 }
-- 
1.7.9.5


^ permalink raw reply related

* [RFC BlueZ 09/22] alert: Add initial support for RegisterAlert D-Bus method
From: Anderson Lizardo @ 2012-08-27 17:11 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Eder Ruiz Maria
In-Reply-To: <1346087526-15107-1-git-send-email-anderson.lizardo@openbossa.org>

From: Eder Ruiz Maria <eder.ruiz@openbossa.org>

---
 profiles/alert/server.c |   45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 419c7fd..78c3e39 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -26,6 +26,8 @@
 #include <config.h>
 #endif
 
+#include <errno.h>
+#include <gdbus.h>
 #include <glib.h>
 #include <bluetooth/uuid.h>
 
@@ -39,6 +41,7 @@
 #include "attrib-server.h"
 #include "gatt.h"
 #include "server.h"
+#include "error.h"
 
 #define PHONE_ALERT_STATUS_SVC_UUID		0x180E
 #define ALERT_NOTIF_SVC_UUID			0x1811
@@ -53,6 +56,9 @@
 #define SUPP_NEW_ALERT_CAT_CHR_UUID	0x2A47
 #define SUPP_UNREAD_ALERT_CAT_CHR_UUID	0x2A48
 
+#define ALERT_OBJECT_PATH "/org/bluez"
+#define ALERT_INTERFACE   "org.bluez.Alert"
+
 enum {
 	ENABLE_NEW_INCOMING,
 	ENABLE_UNREAD_CAT,
@@ -68,9 +74,24 @@ enum {
 	RINGER_NORMAL,
 };
 
+static DBusConnection *connection = NULL;
 static uint8_t ringer_setting = RINGER_NORMAL;
 static uint8_t alert_status = 0;
 
+static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
+								void *data)
+{
+	const char *category;
+
+	if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &category,
+							DBUS_TYPE_INVALID))
+		return btd_error_invalid_args(msg);
+
+	DBG("RegisterAlert: %s", category);
+
+	return dbus_message_new_method_return(msg);
+}
+
 static uint8_t ringer_cp_write(struct attribute *a,
 						struct btd_device *device,
 						gpointer user_data)
@@ -252,8 +273,29 @@ struct btd_adapter_driver alert_server_driver = {
 	.remove = alert_server_remove,
 };
 
+static const GDBusMethodTable alert_methods[] = {
+	{ GDBUS_METHOD("RegisterAlert",
+			GDBUS_ARGS({ "category", "s" },
+				   { "agent", "o" }), NULL,
+			register_alert) },
+	{ }
+};
+
 int alert_server_init(void)
 {
+	connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+	if (connection == NULL)
+		return -EIO;
+
+	if (!g_dbus_register_interface(connection, ALERT_OBJECT_PATH,
+						ALERT_INTERFACE, alert_methods,
+						NULL, NULL, NULL, NULL)) {
+
+		error("D-Bus failed to register %s interface",
+							ALERT_INTERFACE);
+		return -EIO;
+	}
+
 	btd_register_adapter_driver(&alert_server_driver);
 
 	return 0;
@@ -262,4 +304,7 @@ int alert_server_init(void)
 void alert_server_exit(void)
 {
 	btd_unregister_adapter_driver(&alert_server_driver);
+
+	dbus_connection_unref(connection);
+	connection = NULL;
 }
-- 
1.7.9.5


^ permalink raw reply related

* [RFC BlueZ 10/22] alert: Implement category registration in RegisterAlert()
From: Anderson Lizardo @ 2012-08-27 17:11 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Eder Ruiz Maria
In-Reply-To: <1346087526-15107-1-git-send-email-anderson.lizardo@openbossa.org>

From: Eder Ruiz Maria <eder.ruiz@openbossa.org>

The alert category is now properly verified and stored (if
supported).
---
 profiles/alert/server.c |  106 ++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 101 insertions(+), 5 deletions(-)

diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 78c3e39..69069a2 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -74,20 +74,114 @@ enum {
 	RINGER_NORMAL,
 };
 
+struct alert_data {
+	const char *category;
+	char *srv;
+	char *path;
+};
+
 static DBusConnection *connection = NULL;
+static GSList *registered_alerts = NULL;
 static uint8_t ringer_setting = RINGER_NORMAL;
 static uint8_t alert_status = 0;
 
+static const char *anp_categories[] = {
+	"simple",
+	"email",
+	"news",
+	"call",
+	"missed_call",
+	"sms_mms",
+	"voice_mail",
+	"schedule",
+	"high_priority",
+	"instant_message",
+};
+
+static const char *pasp_categories[] = {
+	"ringer",
+	"vibrate",
+	"display",
+};
+
+static void alert_data_destroy(gpointer user_data)
+{
+	struct alert_data *alert = user_data;
+
+	g_free(alert->srv);
+	g_free(alert->path);
+	g_free(alert);
+}
+
+static void alert_destroy(gpointer user_data)
+{
+	g_slist_free_full(registered_alerts, alert_data_destroy);
+	registered_alerts = NULL;
+}
+
+static const char *valid_category(const char *category)
+{
+	unsigned i;
+
+	for (i = 0; i < G_N_ELEMENTS(anp_categories); i++) {
+		if (g_str_equal(anp_categories[i], category))
+			return anp_categories[i];
+	}
+
+	for (i = 0; i < G_N_ELEMENTS(pasp_categories); i++) {
+		if (g_str_equal(pasp_categories[i], category))
+			return pasp_categories[i];
+	}
+
+	return NULL;
+}
+
+static gboolean registered_category(const char *category)
+{
+	GSList *l;
+	struct alert_data *alert;
+
+	for (l = registered_alerts; l; l = g_slist_next(l)) {
+		alert = l->data;
+		if (g_str_equal(alert->category, category))
+			return TRUE;
+	}
+
+	return FALSE;
+}
+
 static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
 								void *data)
 {
+	const char *sender = dbus_message_get_sender(msg);
+	char *path;
 	const char *category;
+	const char *c;
+	struct alert_data *alert;
 
-	if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &category,
-							DBUS_TYPE_INVALID))
+	if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &c,
+			DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID))
 		return btd_error_invalid_args(msg);
 
-	DBG("RegisterAlert: %s", category);
+	category = valid_category(c);
+	if (!category) {
+		DBG("Invalid category: %s", c);
+		return btd_error_invalid_args(msg);
+	}
+
+	if (registered_category(category)) {
+		DBG("Category %s already registered", category);
+		return dbus_message_new_method_return(msg);
+	}
+
+	alert = g_new0(struct alert_data, 1);
+	alert->srv = g_strdup(sender);
+	alert->path = g_strdup(path);
+	alert->category = category;
+
+	registered_alerts = g_slist_append(registered_alerts, alert);
+
+	DBG("RegisterAlert(\"%s\", \"%s\")", alert->category, alert->path);
 
 	return dbus_message_new_method_return(msg);
 }
@@ -288,8 +382,8 @@ int alert_server_init(void)
 		return -EIO;
 
 	if (!g_dbus_register_interface(connection, ALERT_OBJECT_PATH,
-						ALERT_INTERFACE, alert_methods,
-						NULL, NULL, NULL, NULL)) {
+					ALERT_INTERFACE, alert_methods, NULL,
+					NULL, NULL, alert_destroy)) {
 
 		error("D-Bus failed to register %s interface",
 							ALERT_INTERFACE);
@@ -305,6 +399,8 @@ void alert_server_exit(void)
 {
 	btd_unregister_adapter_driver(&alert_server_driver);
 
+	g_dbus_unregister_interface(connection, ALERT_OBJECT_PATH,
+							ALERT_INTERFACE);
 	dbus_connection_unref(connection);
 	connection = NULL;
 }
-- 
1.7.9.5


^ permalink raw reply related

* [RFC BlueZ 11/22] alert: Add initial support for NewAlert D-Bus method
From: Anderson Lizardo @ 2012-08-27 17:11 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Eder Ruiz Maria
In-Reply-To: <1346087526-15107-1-git-send-email-anderson.lizardo@openbossa.org>

From: Eder Ruiz Maria <eder.ruiz@openbossa.org>

---
 profiles/alert/server.c |  106 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 105 insertions(+), 1 deletion(-)

diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 69069a2..e541e64 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -59,6 +59,9 @@
 #define ALERT_OBJECT_PATH "/org/bluez"
 #define ALERT_INTERFACE   "org.bluez.Alert"
 
+/* Maximum length for "Text String Information" */
+#define NEW_ALERT_MAX_INFO_SIZE		18
+
 enum {
 	ENABLE_NEW_INCOMING,
 	ENABLE_UNREAD_CAT,
@@ -136,7 +139,7 @@ static const char *valid_category(const char *category)
 	return NULL;
 }
 
-static gboolean registered_category(const char *category)
+static struct alert_data *get_alert_data_by_category(const char *category)
 {
 	GSList *l;
 	struct alert_data *alert;
@@ -144,9 +147,64 @@ static gboolean registered_category(const char *category)
 	for (l = registered_alerts; l; l = g_slist_next(l)) {
 		alert = l->data;
 		if (g_str_equal(alert->category, category))
+			return alert;
+	}
+
+	return NULL;
+}
+
+static gboolean registered_category(const char *category)
+{
+	struct alert_data *alert;
+
+	alert = get_alert_data_by_category(category);
+	if (alert)
+		return TRUE;
+
+	return FALSE;
+}
+
+static gboolean pasp_category(const char *category)
+{
+	unsigned i;
+
+	for (i = 0; i < G_N_ELEMENTS(pasp_categories); i++)
+		if (g_str_equal(category, pasp_categories[i]))
 			return TRUE;
+
+	return FALSE;
+}
+
+static gboolean valid_description(const char *category,
+							const char *description)
+{
+	if (!pasp_category(category)) {
+		if (strlen(description) >= NEW_ALERT_MAX_INFO_SIZE)
+			return FALSE;
+
+		return TRUE;
 	}
 
+	if (g_str_equal(description, "active") ||
+					g_str_equal(description, "not active"))
+		return TRUE;
+
+	if (g_str_equal(category, "ringer"))
+		if (g_str_equal(description, "enabled") ||
+					g_str_equal(description, "disabled"))
+			return TRUE;
+
+	return FALSE;
+}
+
+static gboolean valid_count(const char *category, uint16_t count)
+{
+	if (!pasp_category(category) && count > 0 && count <= 255)
+		return TRUE;
+
+	if (pasp_category(category) && count == 1)
+		return TRUE;
+
 	return FALSE;
 }
 
@@ -186,6 +244,47 @@ static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
 	return dbus_message_new_method_return(msg);
 }
 
+static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
+								void *data)
+{
+	const char *sender = dbus_message_get_sender(msg);
+	const char *category, *description;
+	struct alert_data *alert;
+	uint16_t count;
+
+	if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &category,
+			DBUS_TYPE_UINT16, &count, DBUS_TYPE_STRING,
+			&description, DBUS_TYPE_INVALID))
+		return btd_error_invalid_args(msg);
+
+	alert = get_alert_data_by_category(category);
+	if (!alert) {
+		DBG("Category %s not registered", category);
+		return btd_error_invalid_args(msg);
+	}
+
+	if (!g_str_equal(alert->srv, sender)) {
+		DBG("Sender %s is not registered in category %s", sender,
+								category);
+		return btd_error_invalid_args(msg);
+	}
+
+	if (!valid_description(category, description)) {
+		DBG("Description %s is invalid for %s category",
+							description, category);
+		return btd_error_invalid_args(msg);
+	}
+
+	if (!valid_count(category, count)) {
+		DBG("Count %d is invalid for %s category", count, category);
+		return btd_error_invalid_args(msg);
+	}
+
+	DBG("NewAlert(\"%s\", %d, \"%s\")", category, count, description);
+
+	return dbus_message_new_method_return(msg);
+}
+
 static uint8_t ringer_cp_write(struct attribute *a,
 						struct btd_device *device,
 						gpointer user_data)
@@ -372,6 +471,11 @@ static const GDBusMethodTable alert_methods[] = {
 			GDBUS_ARGS({ "category", "s" },
 				   { "agent", "o" }), NULL,
 			register_alert) },
+	{ GDBUS_METHOD("NewAlert",
+			GDBUS_ARGS({ "category", "s" },
+				   { "count", "q" },
+				   { "description", "s" }), NULL,
+			new_alert) },
 	{ }
 };
 
-- 
1.7.9.5


^ permalink raw reply related

* [RFC BlueZ 12/22] alert: Add initial support for UnreadAlert D-Bus method
From: Anderson Lizardo @ 2012-08-27 17:11 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1346087526-15107-1-git-send-email-anderson.lizardo@openbossa.org>

---
 profiles/alert/server.c |   33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index e541e64..8bc90f6 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -285,6 +285,36 @@ static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
 	return dbus_message_new_method_return(msg);
 }
 
+static DBusMessage *unread_alert(DBusConnection *conn, DBusMessage *msg,
+								void *data)
+{
+	const char *sender = dbus_message_get_sender(msg);
+	struct alert_data *alert;
+	const char *category;
+	uint16_t count;
+
+	if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &category,
+						DBUS_TYPE_UINT16, &count,
+						DBUS_TYPE_INVALID))
+		return btd_error_invalid_args(msg);
+
+	alert = get_alert_data_by_category(category);
+	if (!alert) {
+		DBG("Category %s not registered", category);
+		return btd_error_invalid_args(msg);
+	}
+
+	if (!g_str_equal(alert->srv, sender)) {
+		DBG("Sender %s is not registered in category %s", sender,
+								category);
+		return btd_error_invalid_args(msg);
+	}
+
+	DBG("category %s, count %d", category, count);
+
+	return dbus_message_new_method_return(msg);
+}
+
 static uint8_t ringer_cp_write(struct attribute *a,
 						struct btd_device *device,
 						gpointer user_data)
@@ -476,6 +506,9 @@ static const GDBusMethodTable alert_methods[] = {
 				   { "count", "q" },
 				   { "description", "s" }), NULL,
 			new_alert) },
+	{ GDBUS_METHOD("UnreadAlert",
+			GDBUS_ARGS({ "category", "s" }, { "count", "q" }), NULL,
+			unread_alert) },
 	{ }
 };
 
-- 
1.7.9.5


^ permalink raw reply related

* [RFC BlueZ 13/22] alert: Add support for automatic unregister when agent leave D-Bus
From: Anderson Lizardo @ 2012-08-27 17:11 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Eder Ruiz Maria
In-Reply-To: <1346087526-15107-1-git-send-email-anderson.lizardo@openbossa.org>

From: Eder Ruiz Maria <eder.ruiz@openbossa.org>

---
 profiles/alert/server.c |   24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 8bc90f6..c77e1f1 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -81,6 +81,7 @@ struct alert_data {
 	const char *category;
 	char *srv;
 	char *path;
+	guint watcher;
 };
 
 static DBusConnection *connection = NULL;
@@ -111,6 +112,9 @@ static void alert_data_destroy(gpointer user_data)
 {
 	struct alert_data *alert = user_data;
 
+	if (alert->watcher)
+		g_dbus_remove_watch(connection, alert->watcher);
+
 	g_free(alert->srv);
 	g_free(alert->path);
 	g_free(alert);
@@ -208,6 +212,17 @@ static gboolean valid_count(const char *category, uint16_t count)
 	return FALSE;
 }
 
+static void watcher_disconnect(DBusConnection *conn, void *user_data)
+{
+	struct alert_data *alert = user_data;
+
+	DBG("Category %s was disconnected", alert->category);
+
+	registered_alerts = g_slist_remove(registered_alerts, alert);
+	g_dbus_remove_watch(connection, alert->watcher);
+	alert_data_destroy(alert);
+}
+
 static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
 								void *data)
 {
@@ -236,6 +251,15 @@ static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
 	alert->srv = g_strdup(sender);
 	alert->path = g_strdup(path);
 	alert->category = category;
+	alert->watcher = g_dbus_add_disconnect_watch(connection, alert->srv,
+					watcher_disconnect, alert, NULL);
+
+	if (alert->watcher == 0) {
+		alert_data_destroy(alert);
+		DBG("Could not register disconnect watcher");
+		return btd_error_failed(msg,
+				"Could not register disconnect watcher");
+	}
 
 	registered_alerts = g_slist_append(registered_alerts, alert);
 
-- 
1.7.9.5


^ permalink raw reply related

* [RFC BlueZ 14/22] alert: Add per adapter attribute handle information
From: Anderson Lizardo @ 2012-08-27 17:11 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1346087526-15107-1-git-send-email-anderson.lizardo@openbossa.org>

Each adapter may have different GATT services running, therefore any
attribute handles (e.g. for updating characteristic values) need to be
saved per adapter.
---
 profiles/alert/server.c |   57 ++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 47 insertions(+), 10 deletions(-)

diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index c77e1f1..b717c51 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -84,8 +84,14 @@ struct alert_data {
 	guint watcher;
 };
 
+struct alert_adapter {
+	struct btd_adapter *adapter;
+	/* TODO: store characteristic value handles */
+};
+
 static DBusConnection *connection = NULL;
 static GSList *registered_alerts = NULL;
+static GSList *alert_adapters = NULL;
 static uint8_t ringer_setting = RINGER_NORMAL;
 static uint8_t alert_status = 0;
 
@@ -108,6 +114,21 @@ static const char *pasp_categories[] = {
 	"display",
 };
 
+static int adapter_cmp(gconstpointer a, gconstpointer b)
+{
+	const struct alert_adapter *al_adapter = a;
+	const struct btd_adapter *adapter = b;
+
+	return (al_adapter->adapter == adapter ? 0 : -1);
+}
+
+static struct alert_adapter *find_alert_adapter(struct btd_adapter *adapter)
+{
+	GSList *l = g_slist_find_custom(alert_adapters, adapter, adapter_cmp);
+
+	return (l ? l->data : NULL);
+}
+
 static void alert_data_destroy(gpointer user_data)
 {
 	struct alert_data *alert = user_data;
@@ -378,20 +399,20 @@ static uint8_t ringer_setting_read(struct attribute *a,
 	return 0;
 }
 
-static void register_phone_alert_service(struct btd_adapter *adapter)
+static void register_phone_alert_service(struct alert_adapter *al_adapter)
 {
 	bt_uuid_t uuid;
 
 	bt_uuid16_create(&uuid, PHONE_ALERT_STATUS_SVC_UUID);
 
 	/* Phone Alert Status Service */
-	gatt_service_add(adapter, GATT_PRIM_SVC_UUID, &uuid,
+	gatt_service_add(al_adapter->adapter, GATT_PRIM_SVC_UUID, &uuid,
 			/* Alert Status characteristic */
 			GATT_OPT_CHR_UUID, ALERT_STATUS_CHR_UUID,
 			GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ |
 							ATT_CHAR_PROPER_NOTIFY,
 			GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
-			alert_status_read, adapter,
+			alert_status_read, al_adapter->adapter,
 			/* Ringer Control Point characteristic */
 			GATT_OPT_CHR_UUID, RINGER_CP_CHR_UUID,
 			GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_WRITE_WITHOUT_RESP,
@@ -402,7 +423,7 @@ static void register_phone_alert_service(struct btd_adapter *adapter)
 			GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ |
 							ATT_CHAR_PROPER_NOTIFY,
 			GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
-			ringer_setting_read, adapter,
+			ringer_setting_read, al_adapter->adapter,
 			GATT_OPT_INVALID);
 }
 
@@ -470,19 +491,19 @@ static uint8_t alert_notif_cp_write(struct attribute *a,
 	return 0;
 }
 
-static void register_alert_notif_service(struct btd_adapter *adapter)
+static void register_alert_notif_service(struct alert_adapter *al_adapter)
 {
 	bt_uuid_t uuid;
 
 	bt_uuid16_create(&uuid, ALERT_NOTIF_SVC_UUID);
 
 	/* Alert Notification Service */
-	gatt_service_add(adapter, GATT_PRIM_SVC_UUID, &uuid,
+	gatt_service_add(al_adapter->adapter, GATT_PRIM_SVC_UUID, &uuid,
 			/* Supported New Alert Category */
 			GATT_OPT_CHR_UUID, SUPP_NEW_ALERT_CAT_CHR_UUID,
 			GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ,
 			GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
-			supp_new_alert_cat_read, adapter,
+			supp_new_alert_cat_read, al_adapter->adapter,
 			/* New Alert */
 			GATT_OPT_CHR_UUID, NEW_ALERT_CHR_UUID,
 			GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
@@ -490,7 +511,7 @@ static void register_alert_notif_service(struct btd_adapter *adapter)
 			GATT_OPT_CHR_UUID, SUPP_UNREAD_ALERT_CAT_CHR_UUID,
 			GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ,
 			GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
-			supp_unread_alert_cat_read, adapter,
+			supp_unread_alert_cat_read, al_adapter->adapter,
 			/* Unread Alert Status */
 			GATT_OPT_CHR_UUID, UNREAD_ALERT_CHR_UUID,
 			GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
@@ -504,14 +525,30 @@ static void register_alert_notif_service(struct btd_adapter *adapter)
 
 static int alert_server_probe(struct btd_adapter *adapter)
 {
-	register_phone_alert_service(adapter);
-	register_alert_notif_service(adapter);
+	struct alert_adapter *al_adapter;
+
+	al_adapter = g_new0(struct alert_adapter, 1);
+	al_adapter->adapter = btd_adapter_ref(adapter);
+
+	alert_adapters = g_slist_append(alert_adapters, al_adapter);
+
+	register_phone_alert_service(al_adapter);
+	register_alert_notif_service(al_adapter);
 
 	return 0;
 }
 
 static void alert_server_remove(struct btd_adapter *adapter)
 {
+	struct alert_adapter *al_adapter;
+
+	al_adapter = find_alert_adapter(adapter);
+	if (!al_adapter)
+		return;
+
+	alert_adapters = g_slist_remove(alert_adapters, al_adapter);
+	btd_adapter_unref(al_adapter->adapter);
+	g_free(al_adapter);
 }
 
 struct btd_adapter_driver alert_server_driver = {
-- 
1.7.9.5


^ permalink raw reply related

* [RFC BlueZ 15/22] alert: Update Supported New/Unread Category characteristic values
From: Anderson Lizardo @ 2012-08-27 17:11 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1346087526-15107-1-git-send-email-anderson.lizardo@openbossa.org>

---
 profiles/alert/server.c |   34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index b717c51..b06ef20 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -86,7 +86,8 @@ struct alert_data {
 
 struct alert_adapter {
 	struct btd_adapter *adapter;
-	/* TODO: store characteristic value handles */
+	uint16_t supp_new_alert_cat_handle;
+	uint16_t supp_unread_alert_cat_handle;
 };
 
 static DBusConnection *connection = NULL;
@@ -233,6 +234,29 @@ static gboolean valid_count(const char *category, uint16_t count)
 	return FALSE;
 }
 
+static void update_supported_categories(gpointer data, gpointer user_data)
+{
+	struct alert_adapter *al_adapter = data;
+	struct btd_adapter *adapter = al_adapter->adapter;
+	uint8_t value[2];
+	unsigned int i;
+
+	memset(value, 0, sizeof(value));
+
+	for (i = 0; i < G_N_ELEMENTS(anp_categories); i++) {
+		if (registered_category(anp_categories[i]))
+			hci_set_bit(i, value);
+	}
+
+	attrib_db_update(adapter, al_adapter->supp_new_alert_cat_handle, NULL,
+						value, sizeof(value), NULL);
+
+	/* FIXME: For now report all registered categories as supporting unread
+	 * status, until it is known which ones should be supported */
+	attrib_db_update(adapter, al_adapter->supp_unread_alert_cat_handle,
+					NULL, value, sizeof(value), NULL);
+}
+
 static void watcher_disconnect(DBusConnection *conn, void *user_data)
 {
 	struct alert_data *alert = user_data;
@@ -242,6 +266,8 @@ static void watcher_disconnect(DBusConnection *conn, void *user_data)
 	registered_alerts = g_slist_remove(registered_alerts, alert);
 	g_dbus_remove_watch(connection, alert->watcher);
 	alert_data_destroy(alert);
+
+	g_slist_foreach(alert_adapters, update_supported_categories, NULL);
 }
 
 static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
@@ -284,6 +310,8 @@ static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
 
 	registered_alerts = g_slist_append(registered_alerts, alert);
 
+	g_slist_foreach(alert_adapters, update_supported_categories, NULL);
+
 	DBG("RegisterAlert(\"%s\", \"%s\")", alert->category, alert->path);
 
 	return dbus_message_new_method_return(msg);
@@ -504,6 +532,8 @@ static void register_alert_notif_service(struct alert_adapter *al_adapter)
 			GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ,
 			GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
 			supp_new_alert_cat_read, al_adapter->adapter,
+			GATT_OPT_CHR_VALUE_GET_HANDLE,
+			&al_adapter->supp_new_alert_cat_handle,
 			/* New Alert */
 			GATT_OPT_CHR_UUID, NEW_ALERT_CHR_UUID,
 			GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
@@ -512,6 +542,8 @@ static void register_alert_notif_service(struct alert_adapter *al_adapter)
 			GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ,
 			GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
 			supp_unread_alert_cat_read, al_adapter->adapter,
+			GATT_OPT_CHR_VALUE_GET_HANDLE,
+			&al_adapter->supp_unread_alert_cat_handle,
 			/* Unread Alert Status */
 			GATT_OPT_CHR_UUID, UNREAD_ALERT_CHR_UUID,
 			GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
-- 
1.7.9.5


^ permalink raw reply related

* [RFC BlueZ 16/22] alert: Update new alert characteristic value
From: Anderson Lizardo @ 2012-08-27 17:12 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1346087526-15107-1-git-send-email-anderson.lizardo@openbossa.org>

---
 profiles/alert/server.c |   39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index b06ef20..a06429c 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -61,6 +61,8 @@
 
 /* Maximum length for "Text String Information" */
 #define NEW_ALERT_MAX_INFO_SIZE		18
+/* Maximum length for New Alert Characteristic Value */
+#define NEW_ALERT_CHR_MAX_VALUE_SIZE	(NEW_ALERT_MAX_INFO_SIZE + 2)
 
 enum {
 	ENABLE_NEW_INCOMING,
@@ -88,6 +90,7 @@ struct alert_adapter {
 	struct btd_adapter *adapter;
 	uint16_t supp_new_alert_cat_handle;
 	uint16_t supp_unread_alert_cat_handle;
+	uint16_t new_alert_handle;
 };
 
 static DBusConnection *connection = NULL;
@@ -317,6 +320,16 @@ static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
 	return dbus_message_new_method_return(msg);
 }
 
+static void update_new_alert(gpointer data, gpointer user_data)
+{
+	struct alert_adapter *al_adapter = data;
+	struct btd_adapter *adapter = al_adapter->adapter;
+	uint8_t *value = user_data;
+
+	attrib_db_update(adapter, al_adapter->new_alert_handle, NULL, &value[1],
+								value[0], NULL);
+}
+
 static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
 								void *data)
 {
@@ -324,6 +337,7 @@ static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
 	const char *category, *description;
 	struct alert_data *alert;
 	uint16_t count;
+	unsigned int i;
 
 	if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &category,
 			DBUS_TYPE_UINT16, &count, DBUS_TYPE_STRING,
@@ -353,6 +367,29 @@ static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
 		return btd_error_invalid_args(msg);
 	}
 
+	for (i = 0; i < G_N_ELEMENTS(anp_categories); i++) {
+		if (g_str_equal(anp_categories[i], category)) {
+			uint8_t value[NEW_ALERT_CHR_MAX_VALUE_SIZE + 1];
+			size_t dlen = strlen(description);
+			uint8_t *ptr = value;
+
+			memset(value, 0, sizeof(value));
+
+			*ptr++ = 2; /* Attribute value size */
+			*ptr++ = i; /* Category ID (mandatory) */
+			*ptr++ = count; /* Number of New Alert (mandatory) */
+			/* Text String Information (optional) */
+			strncpy((char *) ptr, description,
+						NEW_ALERT_MAX_INFO_SIZE - 1);
+
+			if (dlen > 0)
+				*value += dlen + 1;
+
+			g_slist_foreach(alert_adapters, update_new_alert,
+									value);
+		}
+	}
+
 	DBG("NewAlert(\"%s\", %d, \"%s\")", category, count, description);
 
 	return dbus_message_new_method_return(msg);
@@ -537,6 +574,8 @@ static void register_alert_notif_service(struct alert_adapter *al_adapter)
 			/* New Alert */
 			GATT_OPT_CHR_UUID, NEW_ALERT_CHR_UUID,
 			GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
+			GATT_OPT_CHR_VALUE_GET_HANDLE,
+			&al_adapter->new_alert_handle,
 			/* Supported Unread Alert Category */
 			GATT_OPT_CHR_UUID, SUPP_UNREAD_ALERT_CAT_CHR_UUID,
 			GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ,
-- 
1.7.9.5


^ permalink raw reply related

* [RFC BlueZ 17/22] alert: Update unread alert characteristic value
From: Anderson Lizardo @ 2012-08-27 17:12 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1346087526-15107-1-git-send-email-anderson.lizardo@openbossa.org>

---
 profiles/alert/server.c |   31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index a06429c..bdf13ee 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -91,6 +91,7 @@ struct alert_adapter {
 	uint16_t supp_new_alert_cat_handle;
 	uint16_t supp_unread_alert_cat_handle;
 	uint16_t new_alert_handle;
+	uint16_t unread_alert_handle;
 };
 
 static DBusConnection *connection = NULL;
@@ -395,12 +396,23 @@ static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
 	return dbus_message_new_method_return(msg);
 }
 
+static void update_unread_alert(gpointer data, gpointer user_data)
+{
+	struct alert_adapter *al_adapter = data;
+	struct btd_adapter *adapter = al_adapter->adapter;
+	uint8_t *value = user_data;
+
+	attrib_db_update(adapter, al_adapter->unread_alert_handle, NULL, value,
+								2, NULL);
+}
+
 static DBusMessage *unread_alert(DBusConnection *conn, DBusMessage *msg,
 								void *data)
 {
 	const char *sender = dbus_message_get_sender(msg);
 	struct alert_data *alert;
 	const char *category;
+	unsigned int i;
 	uint16_t count;
 
 	if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &category,
@@ -414,12 +426,29 @@ static DBusMessage *unread_alert(DBusConnection *conn, DBusMessage *msg,
 		return btd_error_invalid_args(msg);
 	}
 
+	if (!valid_count(category, count)) {
+		DBG("Count %d is invalid for %s category", count, category);
+		return btd_error_invalid_args(msg);
+	}
+
 	if (!g_str_equal(alert->srv, sender)) {
 		DBG("Sender %s is not registered in category %s", sender,
 								category);
 		return btd_error_invalid_args(msg);
 	}
 
+	for (i = 0; i < G_N_ELEMENTS(anp_categories); i++) {
+		if (g_str_equal(anp_categories[i], category)) {
+			uint8_t value[2];
+
+			value[0] = i; /* Category ID */
+			value[1] = count; /* Unread count */
+
+			g_slist_foreach(alert_adapters, update_unread_alert,
+									value);
+		}
+	}
+
 	DBG("category %s, count %d", category, count);
 
 	return dbus_message_new_method_return(msg);
@@ -586,6 +615,8 @@ static void register_alert_notif_service(struct alert_adapter *al_adapter)
 			/* Unread Alert Status */
 			GATT_OPT_CHR_UUID, UNREAD_ALERT_CHR_UUID,
 			GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
+			GATT_OPT_CHR_VALUE_GET_HANDLE,
+			&al_adapter->unread_alert_handle,
 			/* Alert Notification Control Point */
 			GATT_OPT_CHR_UUID, ALERT_NOTIF_CP_CHR_UUID,
 			GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_WRITE,
-- 
1.7.9.5


^ permalink raw reply related

* [RFC BlueZ 18/22] alert: Implement MuteOnce command
From: Anderson Lizardo @ 2012-08-27 17:12 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1346087526-15107-1-git-send-email-anderson.lizardo@openbossa.org>

---
 profiles/alert/server.c |   25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index bdf13ee..fcbd5aa 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -73,6 +73,12 @@ enum {
 	NOTIFY_UNREAD_CAT,
 };
 
+enum {
+	RINGER_SILENT_MODE = 1,
+	RINGER_MUTE_ONCE,
+	RINGER_CANCEL_SILENT_MODE,
+};
+
 /* Ringer Setting characteristic values */
 enum {
 	RINGER_SILENT,
@@ -460,6 +466,25 @@ static uint8_t ringer_cp_write(struct attribute *a,
 {
 	DBG("a = %p", a);
 
+	if (a->len > 1) {
+		DBG("Invalid command size (%zu)", a->len);
+		return 0;
+	}
+
+	switch (a->data[0]) {
+	case RINGER_SILENT_MODE:
+		DBG("Silent Mode");
+		break;
+	case RINGER_MUTE_ONCE:
+		DBG("Mute Once");
+		break;
+	case RINGER_CANCEL_SILENT_MODE:
+		DBG("Cancel Silent Mode");
+		break;
+	default:
+		DBG("Invalid command (0x%02x)", a->data[0]);
+	}
+
 	return 0;
 }
 
-- 
1.7.9.5


^ permalink raw reply related

* [RFC BlueZ 19/22] alert: Add support to call MuteOnce()
From: Anderson Lizardo @ 2012-08-27 17:12 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Eder Ruiz Maria
In-Reply-To: <1346087526-15107-1-git-send-email-anderson.lizardo@openbossa.org>

From: Eder Ruiz Maria <eder.ruiz@openbossa.org>

When BlueZ want call MuteOnce() method from org.bluez.AlertAgent
interface for a registered agent, the function
agent_ringer_mute_once() must be called.
---
 profiles/alert/server.c |   24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index fcbd5aa..b7660b0 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -58,6 +58,7 @@
 
 #define ALERT_OBJECT_PATH "/org/bluez"
 #define ALERT_INTERFACE   "org.bluez.Alert"
+#define ALERT_AGENT_INTERFACE "org.bluez.AlertAgent"
 
 /* Maximum length for "Text String Information" */
 #define NEW_ALERT_MAX_INFO_SIZE		18
@@ -402,6 +403,28 @@ static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
 	return dbus_message_new_method_return(msg);
 }
 
+static int agent_ringer_mute_once(void)
+{
+	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, "MuteOnce");
+	if (!msg)
+		return -ENOMEM;
+
+	dbus_message_set_no_reply(msg, TRUE);
+	g_dbus_send_message(connection, msg);
+
+	return 0;
+}
+
 static void update_unread_alert(gpointer data, gpointer user_data)
 {
 	struct alert_adapter *al_adapter = data;
@@ -477,6 +500,7 @@ static uint8_t ringer_cp_write(struct attribute *a,
 		break;
 	case RINGER_MUTE_ONCE:
 		DBG("Mute Once");
+		agent_ringer_mute_once();
 		break;
 	case RINGER_CANCEL_SILENT_MODE:
 		DBG("Cancel Silent Mode");
-- 
1.7.9.5


^ permalink raw reply related

* [RFC BlueZ 20/22] alert: Add support to call SetRinger()
From: Anderson Lizardo @ 2012-08-27 17:12 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Eder Ruiz Maria
In-Reply-To: <1346087526-15107-1-git-send-email-anderson.lizardo@openbossa.org>

From: Eder Ruiz Maria <eder.ruiz@openbossa.org>

When BlueZ want call SetRinger() method from org.bluez.AlertAgent
interface for a registered agent, the function
agent_ringer_set_ringer() must be called.
---
 profiles/alert/server.c |   27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index b7660b0..794189a 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -425,6 +425,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(connection, msg);
+
+	return 0;
+}
+
 static void update_unread_alert(gpointer data, gpointer user_data)
 {
 	struct alert_adapter *al_adapter = data;
@@ -497,6 +522,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");
@@ -504,6 +530,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]);
-- 
1.7.9.5


^ permalink raw reply related

* [RFC BlueZ 21/22] alert: Add test script
From: Anderson Lizardo @ 2012-08-27 17:12 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Eder Ruiz Maria
In-Reply-To: <1346087526-15107-1-git-send-email-anderson.lizardo@openbossa.org>

From: Eder Ruiz Maria <eder.ruiz@openbossa.org>

---
 test/test-alert |  167 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 167 insertions(+)
 create mode 100755 test/test-alert

diff --git a/test/test-alert b/test/test-alert
new file mode 100755
index 0000000..ccc272c
--- /dev/null
+++ b/test/test-alert
@@ -0,0 +1,167 @@
+#!/usr/bin/python
+from __future__ import absolute_import, print_function, unicode_literals
+import dbus
+import dbus.service
+import dbus.mainloop.glib
+import gobject
+import optparse
+import sys
+import os
+
+BUS_NAME = 'org.bluez'
+ALERT_INTERFACE = 'org.bluez.Alert'
+ALERT_AGENT_INTERFACE = 'org.bluez.AlertAgent'
+BLUEZ_OBJECT_PATH = '/org/bluez'
+TEST_OBJECT_PATH = '/org/bluez/test'
+
+class AlertAgent(dbus.service.Object):
+	@dbus.service.method(ALERT_AGENT_INTERFACE, in_signature='',
+							out_signature='')
+	def MuteOnce(self):
+		print('method MuteOnce() was called')
+
+	@dbus.service.method(ALERT_AGENT_INTERFACE, in_signature='s',
+							out_signature='')
+	def SetRinger(self, mode):
+		print('method SetRinger(%s) was called' % mode)
+
+def print_command_line(options):
+	if not options.verbose:
+		return False
+
+	print('-w: ' + str(options.wait))
+
+	if options.times:
+		print('-t: ' + str(options.times))
+
+	if options.register:
+		print('-r: ' + options.register)
+	else:
+		print('-r: ' + str(None))
+
+	if options.new_alert:
+		print('-n:')
+		for i in options.new_alert:
+			print('    ' + i[0] + ', ' + i[1] + ', ' + i[2])
+	else:
+		print('-n: ' + str(None))
+
+	if options.unread_alert:
+		print('-u:')
+		for i in options.unread_alert:
+			print('    ' + i[0] + ', ' + i[1])
+	else:
+		print('-u: ' + str(None))
+
+	print()
+
+	return True
+
+def read_count(param):
+	try:
+		return int(param)
+	except ValueError:
+		print('<count> must be integer, not \"%s\"' % param)
+		sys.exit(1)
+
+def new_alert(alert, params):
+	if not params:
+		return False
+
+	for param in params:
+		category = param[0]
+		count = read_count(param[1])
+		description = param[2]
+
+		alert.NewAlert(category, count, description)
+
+def unread_alert(alert, params):
+	if not params:
+		return False
+
+	for param in params:
+		category = param[0]
+		count = read_count(param[1])
+
+		alert.UnreadAlert(category, count)
+
+option_list = [
+	optparse.make_option('-v', None,
+			action = 'store_true',
+			default = False,
+			dest = 'verbose',
+			help = 'verbose'),
+
+	optparse.make_option('-w', None,
+			action = 'store_true',
+			default = False,
+			dest = 'wait',
+			help = 'wait for dbus events'),
+
+	optparse.make_option('-t', None,
+			action = 'store',
+			default = 1,
+			type = "int",
+			dest = 'times',
+			help = 'repeat UnreadAlert/NewAlert <times> times',
+			metavar = '<times>'),
+
+	optparse.make_option('-r', None,
+			action = 'store',
+			dest = 'register',
+			type = 'string',
+			metavar = '<category>',
+			help = 'register alert'),
+
+	optparse.make_option('-n', None,
+			action = 'append',
+			dest = 'new_alert',
+			type = 'string',
+			nargs = 3,
+			metavar = '<category> <count> <description>',
+			help = 'send new alert'),
+
+	optparse.make_option('-u', None,
+			action = 'append',
+			dest = 'unread_alert',
+			type = 'string',
+			nargs = 2,
+			metavar = '<category> <count>',
+			help = 'send unread alert'),
+]
+
+parser = optparse.OptionParser(option_list=option_list)
+parser.disable_interspersed_args()
+(options, args) = parser.parse_args()
+
+dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+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)
+
+print_command_line(options)
+
+if not (options.register or options.new_alert or options.unread_alert or
+								options.wait):
+	parser.print_usage()
+	sys.exit(1)
+
+if options.register:
+	alert.RegisterAlert(options.register, TEST_OBJECT_PATH)
+
+times = 0
+while times < options.times:
+	times += 1
+
+	new_alert(alert, options.new_alert)
+	unread_alert(alert, options.unread_alert)
+
+if not options.wait:
+	sys.exit(0)
+
+try:
+	mainloop.run()
+except:
+	pass
-- 
1.7.9.5


^ permalink raw reply related

* [RFC BlueZ 22/22] alert: Update Alert Status and Ringer Setting characteristic values
From: Anderson Lizardo @ 2012-08-27 17:12 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1346087526-15107-1-git-send-email-anderson.lizardo@openbossa.org>

---
 profiles/alert/server.c |   24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 794189a..040fde7 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -338,6 +338,27 @@ static void update_new_alert(gpointer data, gpointer user_data)
 								value[0], NULL);
 }
 
+static void update_phone_alerts(const char *category, const char *description)
+{
+	unsigned int i;
+
+	if (g_str_equal(category, "ringer")) {
+		if (g_str_equal(description, "enabled"))
+			ringer_setting = RINGER_NORMAL;
+		else if (g_str_equal(description, "disabled"))
+			ringer_setting = RINGER_SILENT;
+	}
+
+	for (i = 0; i < G_N_ELEMENTS(pasp_categories); i++) {
+		if (g_str_equal(pasp_categories[i], category)) {
+			if (g_str_equal(description, "active"))
+				alert_status |= (1 << i);
+			else if (g_str_equal(description, "not active"))
+				alert_status &= ~(1 << i);
+		}
+	}
+}
+
 static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
 								void *data)
 {
@@ -398,6 +419,9 @@ static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
 		}
 	}
 
+	if (pasp_category(category))
+		update_phone_alerts(category, description);
+
 	DBG("NewAlert(\"%s\", %d, \"%s\")", category, count, description);
 
 	return dbus_message_new_method_return(msg);
-- 
1.7.9.5


^ permalink raw reply related

* Re: [PATCH] Bluetooth: Add support for BCM20702A0 [0489:e031]
From: thilo @ 2012-08-27 19:56 UTC (permalink / raw)
  To: linux-bluetooth

Hey,

> based on the trace and the .hex files I extracted from the Windows 
> driver
> package I wrote a simple python rampatch downloader script. I also 
> started
> writing a downloader kernel module. I have two questions though.
>
> Is there a need for a driver module at all?

> If the module is needed for whatever reason, is there a way to 
> implement it
> using btusb HCI interface functions?


Could someone please answers David's questions? As this would be very 
interessting for me too.

@David: Could you possible share anything about the udev stuff or 
kernel module you implemented?
Your python script is working fine here ;).

Regards
Thilo


^ permalink raw reply

* Re: [PATCH] bluetooth.h: fix compile issue when using in C++
From: Johan Hedberg @ 2012-08-27 23:40 UTC (permalink / raw)
  To: W. Trevor King; +Cc: linux-bluetooth, Patrick Ohly, Pacho Ramos
In-Reply-To: <20120817051852.GA32453@odin.tremily.us>

Hi,

On Fri, Aug 17, 2012, W. Trevor King wrote:
> On Wed, Aug 01, 2012 at 04:41:33PM +0200, Pacho Ramos wrote:
> > El dom, 29-07-2012 a las 09:52 +0200, Pacho Ramos escribió:
> > > Today I got a report downstream showing that old problem:
> > > http://permalink.gmane.org/gmane.linux.bluez.kernel/22306
> > > 
> > > is still not fixed. 
> > > 
> > > Could you please commit debian patch to fix this?
> > > http://patch-tracker.debian.org/patch/series/view/bluez/4.101-1/09_fix_ftbfs_with_c99.patch
> > 
> > Any news about this? Thanks
> 
> Bump :)

The patch would need to be sent as a proper git patch to this mailing
list. Particularly, we need proper author information for the patch as
well as a commit message explaining the background to the patch and why
it is correct (including a reference to the C++ standard and/or gcc
documentation).

Johan

^ permalink raw reply

* Re: [PATCH v4 01/10] Battery: Add Battery Service Gatt Client
From: Johan Hedberg @ 2012-08-28  1:04 UTC (permalink / raw)
  To: Chen Ganir; +Cc: Luiz Augusto von Dentz, linux-bluetooth, marcel
In-Reply-To: <5039CA72.6090906@ti.com>

Hi Chen,

On Sun, Aug 26, 2012, Chen Ganir wrote:
> So what do you suggest here ? Calculating an average ? How shoudl it
> be done ? If 2 batteries are available, first is 100% and the second
> is 50%, we should simply set the value as 75%? I'm not so sure that we
> should make such decisions for the end user.
> 
> >Another thing that worth adding is that there are other profiles that
> >do support battery status such as HFP and AVRCP, so I think this
> >should be made generic enough so other sources could be supported.
> 
> The internal device API uses the device_add_battery(...) and
> device_remove_battery(...) to allow adding/removing batteries to the
> device battery list, but it is the responsibility of the profile to
> register a D-Bus interface, and update.
> 
> I could redesign this, to add a generic battery API, which will
> expose a new API, such as battery_add(battery_struct* batt),
> battery_remove(battery_struct* batt) and
> battery_update(battery_struct* batt) which will allow a more generic
> approach. This Battery module will be responsible for
> registering/unregistering the D-Bus API, and profiles which need to
> use it will simply use the exposed API to add/remove/update. The
> batt_structure will also include some callback functions to be
> called when a value is queried for example, or if a device is
> removed. The LE Battery plugin will use the GATT to
> read/write/receive notification, and use the Generic Battery
> interface to interface with the external world. What do you think
> about it ?

I had a brief chat with Marcel about this and the following were the
main conclusions:

1. It'd be nice to have support for this added to UPower so that it can
enumerate Bluetooth batteries.

2. The easiest way to do 1. would be to have this one D-Bus object per
battery.

3. Use uint16 instead of byte to keep our D-BUs API consistent wrt.
unsigned integers (byte is signed).

4. No Adapter property or interface needed once we've merged the object
manager patches.

5. (as you proposed) we'll probably want/need a src/device.c API for
device drivers to register batteries. Other profiles supporting battery
info (AVRCP, HFP, etc) could use the same API.

Johan

^ permalink raw reply

* Re: [PATCH obexd 7/7] client-doc: Update documentation of PhonebookAccess interface
From: Johan Hedberg @ 2012-08-28  1:17 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1345816795-14092-7-git-send-email-luiz.dentz@gmail.com>

Hi Luiz,

On Fri, Aug 24, 2012, Luiz Augusto von Dentz wrote:
> ---
>  doc/client-api.txt | 180 ++++++++++++++++++++++++++++++++++++++++++-----------
>  1 file changed, 145 insertions(+), 35 deletions(-)

I had a chat with Marcel about this API which resulted with the
following change proposals:

> +				string Order:
> +
> +					Items order
> +
> +					Possible values: "indexed" (default),
> +					"alphanumeric" or "phonetic"
> +
> +				uint16 Offset:
> +
> +					Offset of the first item, default is 0
> +
> +				uint16 Items:
> +
> +					Maximum number of items, default is
> +					unlimited (65535)

Call this MaxCount or Count to make it clearer.

> +
> +				array{string} Fields:
> +
> +					Item vcard fields, default is all
> +					values.
> +
> +					Possible values:
> +
> +						"VERSION",
> +						"FN",
> +						"N",
> +						"PHOTO",
> +						"BDAY",
> +						"ADR",
> +						"LABEL",
> +						"TEL",
> +						"EMAIL",
> +						"MAILER",
> +						"TZ",
> +						"GEO",
> +						"TITLE",
> +						"ROLE",
> +						"LOGO",
> +						"AGENT",
> +						"ORG",
> +						"NOTE",
> +						"REV",
> +						"SOUND",
> +						"URL",
> +						"UID",
> +						"KEY",
> +						"NICKNAME",
> +						"CATEGORIES",
> +						"PROID",
> +						"CLASS",
> +						"SORT-STRING",
> +						"X-IRMC-CALL-DATETIME"

Make these lower case (I know it's upper case in the spec. but let's
keep the consistency with the rest of the D-Bus API).

> @@ -244,8 +325,54 @@ Methods		void Select(string location, string phonebook)
>  			The properties of this transfer are also returned along
>  			with the object path, to avoid a call to GetProperties.
>  
> +			filters:
> +
> +				string Format:
> +
> +					Items vcard format
> +
> +					Possible values: "vcard21" (default) or
> +					"vcard30"
> +
> +				array{string} Fields:
> +
> +					Item vcard fields, default is all
> +					values.
> +
> +					Possible values:
> +
> +						"VERSION",
> +						"FN",
> +						"N",
> +						"PHOTO",
> +						"BDAY",
> +						"ADR",
> +						"LABEL",
> +						"TEL",
> +						"EMAIL",
> +						"MAILER",
> +						"TZ",
> +						"GEO",
> +						"TITLE",
> +						"ROLE",
> +						"LOGO",
> +						"AGENT",
> +						"ORG",
> +						"NOTE",
> +						"REV",
> +						"SOUND",
> +						"URL",
> +						"UID",
> +						"KEY",
> +						"NICKNAME",
> +						"CATEGORIES",
> +						"PROID",
> +						"CLASS",
> +						"SORT-STRING",
> +						"X-IRMC-CALL-DATETIME"

Is this a duplicate of the previous section. Maybe just move this out to
a common section and the refer to it from the places that need it.

Johan

^ permalink raw reply

* Re: [PATCH obexd 7/7] client-doc: Update documentation of PhonebookAccess interface
From: Patrick Ohly @ 2012-08-28  6:56 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1345816795-14092-7-git-send-email-luiz.dentz@gmail.com>

On Fri, 2012-08-24 at 16:59 +0300, Luiz Augusto von Dentz wrote:
> +				array{string} Fields:
> +
> +					Item vcard fields, default is all
> +					values.
> +
> +					Possible values:
> +
> +						"VERSION",
> +						"FN",
> +						"N",
> +						"PHOTO",
> +						"BDAY",
> +						"ADR",
> +						"LABEL",
> +						"TEL",
> +						"EMAIL",
> +						"MAILER",
> +						"TZ",
> +						"GEO",
> +						"TITLE",
> +						"ROLE",
> +						"LOGO",
> +						"AGENT",
> +						"ORG",
> +						"NOTE",
> +						"REV",
> +						"SOUND",
> +						"URL",
> +						"UID",
> +						"KEY",
> +						"NICKNAME",
> +						"CATEGORIES",
> +						"PROID",
> +						"CLASS",
> +						"SORT-STRING",
> +						"X-IRMC-CALL-DATETIME"

What about selecting the bits which don't have a named property
associated with them? They are reported by ListFilterFields() and thus
seem to be supported.

Should the API spec really specify the full list? IMHO the documentation
should make it clear that the list is not exhaustive - more fields might
be added in future releases of the PBAP standard and obexd, without
changing the obexd API.

In SyncEvolution, I use ListFilterFields() to a) do sanity checks on
user input and to b) build a list of all fields from which the user can
exclude specific fields. Because the field list is not hard-coded, that
will work for fields which are not defined yet.

-- 
Best Regards, Patrick Ohly

The content of this message is my personal opinion only and although
I am an employee of Intel, the statements I make here in no way
represent Intel's position on the issue, nor am I authorized to speak
on behalf of Intel on this matter.



^ permalink raw reply

* Re: [PATCH obexd 7/7] client-doc: Update documentation of PhonebookAccess interface
From: Luiz Augusto von Dentz @ 2012-08-28  7:00 UTC (permalink / raw)
  To: Luiz Augusto von Dentz, linux-bluetooth
In-Reply-To: <20120828011708.GA11305@x220.sheraton.com>

Hi Johan,

On Tue, Aug 28, 2012 at 4:17 AM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
> Hi Luiz,
>
> On Fri, Aug 24, 2012, Luiz Augusto von Dentz wrote:
>> ---
>>  doc/client-api.txt | 180 ++++++++++++++++++++++++++++++++++++++++++-----------
>>  1 file changed, 145 insertions(+), 35 deletions(-)
>
> I had a chat with Marcel about this API which resulted with the
> following change proposals:
>
>> +                             string Order:
>> +
>> +                                     Items order
>> +
>> +                                     Possible values: "indexed" (default),
>> +                                     "alphanumeric" or "phonetic"
>> +
>> +                             uint16 Offset:
>> +
>> +                                     Offset of the first item, default is 0
>> +
>> +                             uint16 Items:
>> +
>> +                                     Maximum number of items, default is
>> +                                     unlimited (65535)
>
> Call this MaxCount or Count to make it clearer.

Will do it.

>> +
>> +                             array{string} Fields:
>> +
>> +                                     Item vcard fields, default is all
>> +                                     values.
>> +
>> +                                     Possible values:
>> +
>> +                                             "VERSION",
>> +                                             "FN",
>> +                                             "N",
>> +                                             "PHOTO",
>> +                                             "BDAY",
>> +                                             "ADR",
>> +                                             "LABEL",
>> +                                             "TEL",
>> +                                             "EMAIL",
>> +                                             "MAILER",
>> +                                             "TZ",
>> +                                             "GEO",
>> +                                             "TITLE",
>> +                                             "ROLE",
>> +                                             "LOGO",
>> +                                             "AGENT",
>> +                                             "ORG",
>> +                                             "NOTE",
>> +                                             "REV",
>> +                                             "SOUND",
>> +                                             "URL",
>> +                                             "UID",
>> +                                             "KEY",
>> +                                             "NICKNAME",
>> +                                             "CATEGORIES",
>> +                                             "PROID",
>> +                                             "CLASS",
>> +                                             "SORT-STRING",
>> +                                             "X-IRMC-CALL-DATETIME"
>
> Make these lower case (I know it's upper case in the spec. but let's
> keep the consistency with the rest of the D-Bus API).

Sure

>> @@ -244,8 +325,54 @@ Methods          void Select(string location, string phonebook)
>>                       The properties of this transfer are also returned along
>>                       with the object path, to avoid a call to GetProperties.
>>
>> +                     filters:
>> +
>> +                             string Format:
>> +
>> +                                     Items vcard format
>> +
>> +                                     Possible values: "vcard21" (default) or
>> +                                     "vcard30"
>> +
>> +                             array{string} Fields:
>> +
>> +                                     Item vcard fields, default is all
>> +                                     values.
>> +
>> +                                     Possible values:
>> +
>> +                                             "VERSION",
>> +                                             "FN",
>> +                                             "N",
>> +                                             "PHOTO",
>> +                                             "BDAY",
>> +                                             "ADR",
>> +                                             "LABEL",
>> +                                             "TEL",
>> +                                             "EMAIL",
>> +                                             "MAILER",
>> +                                             "TZ",
>> +                                             "GEO",
>> +                                             "TITLE",
>> +                                             "ROLE",
>> +                                             "LOGO",
>> +                                             "AGENT",
>> +                                             "ORG",
>> +                                             "NOTE",
>> +                                             "REV",
>> +                                             "SOUND",
>> +                                             "URL",
>> +                                             "UID",
>> +                                             "KEY",
>> +                                             "NICKNAME",
>> +                                             "CATEGORIES",
>> +                                             "PROID",
>> +                                             "CLASS",
>> +                                             "SORT-STRING",
>> +                                             "X-IRMC-CALL-DATETIME"
>
> Is this a duplicate of the previous section. Maybe just move this out to
> a common section and the refer to it from the places that need it.

Depending on the method some parameters may not be valid, but maybe we
can have a section explaining the filters parameter then in each of
method we just enumerate what are the possible parameters for its
filter.

-- 
Luiz Augusto von Dentz

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox