From 2eb84f94e067efce28217e73ff5e96c0d8295d5f Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Wed, 26 Nov 2014 11:19:20 +0200 Subject: [PATCH] obexd/client: Add UpdateVersion to PhonebookAccess This adds UpdateVersion method to PhonebookAccess interface. --- doc/obex-api.txt | 8 ++++---- obexd/client/pbap.c | 23 ++++++++++++++++++++--- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/doc/obex-api.txt b/doc/obex-api.txt index 32f9a79eb..0cd359b88 100644 --- a/doc/obex-api.txt +++ b/doc/obex-api.txt @@ -433,12 +433,12 @@ Methods void Select(string location, string phonebook) Possible errors: org.bluez.obex.Error.Forbidden org.bluez.obex.Error.Failed - uint16, uint16 GetVersion() + void UpdateVersion() - Return the primary and secondary folder version counters - for the selected phonebook. + Attempt to update PrimaryCounter and SecondaryCounter. - Possible errors: org.bluez.obex.Error.Forbidden + Possible errors: org.bluez.obex.Error.NotSupported + org.bluez.obex.Error.Forbidden org.bluez.obex.Error.Failed array{string} ListFilterFields() diff --git a/obexd/client/pbap.c b/obexd/client/pbap.c index 23980711b..812a7fba5 100644 --- a/obexd/client/pbap.c +++ b/obexd/client/pbap.c @@ -383,9 +383,11 @@ static void phonebook_size_callback(struct obc_session *session, read_return_apparam(transfer, request->pbap, &phone_book_size, &new_missed_calls); - dbus_message_append_args(reply, - DBUS_TYPE_UINT16, &phone_book_size, - DBUS_TYPE_INVALID); + if (dbus_message_is_method_call(request->msg, PBAP_INTERFACE, + "GetSize")) + dbus_message_append_args(reply, + DBUS_TYPE_UINT16, &phone_book_size, + DBUS_TYPE_INVALID); send: g_dbus_send_message(conn, reply); @@ -1014,6 +1016,19 @@ static DBusMessage *pbap_list_filter_fields(DBusConnection *connection, return reply; } +static DBusMessage *pbap_update_version(DBusConnection *connection, + DBusMessage *message, void *user_data) +{ + struct pbap_data *pbap = user_data; + + if (!(pbap->supported_features & FOLDER_VERSION_FEATURE)) + return g_dbus_create_error(message, + ERROR_INTERFACE ".NotSupported", + "Operation is not supported"); + + return pbap_get_size(connection, message, user_data); +} + static const GDBusMethodTable pbap_methods[] = { { GDBUS_ASYNC_METHOD("Select", GDBUS_ARGS({ "location", "s" }, { "phonebook", "s" }), @@ -1045,6 +1060,8 @@ static const GDBusMethodTable pbap_methods[] = { { GDBUS_METHOD("ListFilterFields", NULL, GDBUS_ARGS({ "fields", "as" }), pbap_list_filter_fields) }, + { GDBUS_ASYNC_METHOD("UpdateVersion", NULL, NULL, + pbap_update_version) }, { } }; -- 2.47.3