summaryrefslogtreecommitdiff
path: root/obexd/plugins
diff options
context:
space:
mode:
authorDivya Yadav <divya.yadav@samsung.com>2012-01-06 19:01:56 +0530
committerMarcel Holtmann <marcel@holtmann.org>2012-12-04 22:48:50 +0100
commit4390cc444e43035901a6bdff43ed0c144e76d892 (patch)
treec74b4c592026bb4fc6a49933382fa25fc5abf0ef /obexd/plugins
parent9fb880095ddea518f4b7f9e07189158bd081e212 (diff)
obexd: Add UpdateInbox function
UpdateInbox function allows remote device to initiate an update of the MSE inbox, i.e. the MSE shall contact the network to retrieve new messages if available. If MSE does not support the network update it shall answer with a 'Not implemented' error response.
Diffstat (limited to 'obexd/plugins')
-rw-r--r--obexd/plugins/mas.c36
-rw-r--r--obexd/plugins/messages-dummy.c6
-rw-r--r--obexd/plugins/messages-tracker.c6
-rw-r--r--obexd/plugins/messages.h12
4 files changed, 59 insertions, 1 deletions
diff --git a/obexd/plugins/mas.c b/obexd/plugins/mas.c
index 3c3104c25..17e54d8d9 100644
--- a/obexd/plugins/mas.c
+++ b/obexd/plugins/mas.c
@@ -406,6 +406,20 @@ proceed:
obex_object_set_io_flags(mas, G_IO_IN, err);
}
+static void update_inbox_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;
@@ -503,6 +517,26 @@ static void *message_open(const char *name, int oflag, mode_t mode,
return mas;
}
+static void *message_update_open(const char *name, int oflag, mode_t mode,
+ void *driver_data, size_t *size,
+ int *err)
+{
+ struct mas_session *mas = driver_data;
+
+ DBG("");
+
+ if (oflag != O_WRONLY) {
+ *err = -EBADR;
+ return NULL;
+ }
+
+ *err = messages_update_inbox(mas->backend_data, update_inbox_cb, mas);
+ if (*err < 0)
+ return NULL;
+ else
+ return mas;
+}
+
static void *any_open(const char *name, int oflag, mode_t mode,
void *driver_data, size_t *size, int *err)
{
@@ -628,7 +662,7 @@ static struct obex_mime_type_driver mime_message_update = {
.target = MAS_TARGET,
.target_size = TARGET_SIZE,
.mimetype = "x-bt/MAP-messageUpdate",
- .open = any_open,
+ .open = message_update_open,
.close = any_close,
.read = any_read,
.write = any_write,
diff --git a/obexd/plugins/messages-dummy.c b/obexd/plugins/messages-dummy.c
index e96b13bdd..ef2bbd150 100644
--- a/obexd/plugins/messages-dummy.c
+++ b/obexd/plugins/messages-dummy.c
@@ -170,6 +170,12 @@ int messages_get_message(void *session,
return -EINVAL;
}
+int messages_update_inbox(void *session, messages_update_inbox_cb callback,
+ void *user_data)
+{
+ return -EINVAL;
+}
+
void messages_abort(void *session)
{
}
diff --git a/obexd/plugins/messages-tracker.c b/obexd/plugins/messages-tracker.c
index 9c60f2cb6..31d6949d1 100644
--- a/obexd/plugins/messages-tracker.c
+++ b/obexd/plugins/messages-tracker.c
@@ -322,6 +322,12 @@ int messages_get_message(void *session,
return -EINVAL;
}
+int messages_update_inbox(void *session, messages_update_inbox_cb callback,
+ void *user_data)
+{
+ return -EINVAL;
+}
+
void messages_abort(void *session)
{
}
diff --git a/obexd/plugins/messages.h b/obexd/plugins/messages.h
index 6982eddca..8c014aa16 100644
--- a/obexd/plugins/messages.h
+++ b/obexd/plugins/messages.h
@@ -268,6 +268,18 @@ int messages_get_message(void *session,
messages_get_message_cb callback,
void *user_data);
+/* Informs Message Server to Update Inbox via network.
+ *
+ * session: Backend session.
+ * user_data: User data if any to be sent.
+ * Callback shall be called for every update inbox request recieved from MCE.
+ */
+typedef void (*messages_update_inbox_cb)(void *session, int err,
+ void *user_data);
+
+int messages_update_inbox(void *session, messages_update_inbox_cb callback,
+ void *user_data);
+
/* Aborts currently pending request.
*
* session: Backend session.