obexd: Add set read status function

This function will inform MAP server to modify the
read status of a given message.
This commit is contained in:
Sunil Kumar Behera 2012-09-13 19:13:28 +05:30 committed by Marcel Holtmann
parent 91b11b2841
commit 31ef868be5
4 changed files with 50 additions and 0 deletions

View File

@ -46,6 +46,8 @@
#include "messages.h"
#define READ_STATUS_REQ 0
/* Channel number according to bluez doc/assigned-numbers.txt */
#define MAS_CHANNEL 16
@ -499,6 +501,20 @@ static void update_inbox_cb(void *session, int err, void *user_data)
obex_object_set_io_flags(mas, G_IO_OUT, 0);
}
static void set_status_cb(void *session, int err, void *user_data)
{
struct mas_session *mas = user_data;
DBG("");
mas->finished = TRUE;
if (err < 0)
obex_object_set_io_flags(mas, G_IO_ERR, err);
else
obex_object_set_io_flags(mas, G_IO_OUT, 0);
}
static int mas_setpath(struct obex_session *os, void *user_data)
{
const char *name;
@ -677,6 +693,15 @@ static void *message_set_status_open(const char *name, int oflag, mode_t mode,
return NULL;
}
if (indicator == READ_STATUS_REQ)
*err = messages_set_read(mas->backend_data, name, value,
set_status_cb, mas);
else
*err = -EBADR;
if (*err < 0)
return NULL;
return mas;
}

View File

@ -353,6 +353,12 @@ int messages_update_inbox(void *session, messages_update_inbox_cb callback,
return -ENOSYS;
}
int messages_set_read(void *session, const char *handle, uint8_t value,
messages_set_read_cb callback, void *user_data)
{
return -ENOSYS;
}
void messages_abort(void *s)
{
struct session *session = s;

View File

@ -327,6 +327,12 @@ int messages_update_inbox(void *session, messages_update_inbox_cb callback,
return -ENOSYS;
}
int messages_set_read(void *session, const char *handle, uint8_t value,
messages_set_read_cb callback, void *user_data)
{
return -ENOSYS;
}
void messages_abort(void *session)
{
}

View File

@ -279,6 +279,19 @@ typedef void (*messages_update_inbox_cb)(void *session, int err,
int messages_update_inbox(void *session, messages_update_inbox_cb callback,
void *user_data);
/* Informs Message Server to modify read status of a given message.
*
* session: Backend session.
* handle: Unique identifier to the message.
* value: Indicates the new value of the read status for a given message.
* Callback shall be called for every read status update request
* recieved from MCE.
* user_data: User data if any to be sent.
*/
typedef void (*messages_set_read_cb)(void *session, int err, void *user_data);
int messages_set_read(void *session, const char *handle, uint8_t value,
messages_set_read_cb callback, void *user_data);
/* Aborts currently pending request.
*