summaryrefslogtreecommitdiff
path: root/obexd/plugins
diff options
context:
space:
mode:
authorBharat Panda <bharat.panda@samsung.com>2014-10-21 18:38:19 +0530
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2014-10-22 16:49:37 +0300
commit60071dd2a161cbf17b6fbe260e2b4c00a60bd3f8 (patch)
treedb66f03dcd2a21daec1d5818ddde6f55f8492fb2 /obexd/plugins
parent06322e01b1722b7ebc558fc2b0eb2b42142a25e7 (diff)
downloadbluez-60071dd2a161cbf17b6fbe260e2b4c00a60bd3f8.tar.gz
obexd/mas: Add Support for MSETime filter
Changes made to add support for MSE local time and timezone offset parameter along with GetMessageListing response.
Diffstat (limited to 'obexd/plugins')
-rw-r--r--obexd/plugins/mas.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/obexd/plugins/mas.c b/obexd/plugins/mas.c
index fb97fe31f..db4050974 100644
--- a/obexd/plugins/mas.c
+++ b/obexd/plugins/mas.c
@@ -30,6 +30,7 @@
#include <glib.h>
#include <fcntl.h>
#include <inttypes.h>
+#include <sys/time.h>
#include <gobex/gobex.h>
#include <gobex/gobex-apparam.h>
@@ -228,6 +229,35 @@ static void g_string_append_escaped_printf(GString *string,
va_end(ap);
}
+static gchar *get_mse_timestamp(void)
+{
+ struct timeval time_val;
+ struct tm ltime;
+ gchar *local_ts;
+ char sign;
+
+ if (gettimeofday(&time_val, NULL) < 0)
+ return NULL;
+
+ if (!localtime_r(&time_val.tv_sec, &ltime))
+ return NULL;
+
+ if (difftime(mktime(localtime(&time_val.tv_sec)),
+ mktime(gmtime(&time_val.tv_sec))) < 0)
+ sign = '+';
+ else
+ sign = '-';
+
+ local_ts = g_strdup_printf("%04d%02d%02dT%02d%02d%02d%c%2ld%2ld",
+ ltime.tm_year + 1900, ltime.tm_mon + 1,
+ ltime.tm_mday, ltime.tm_hour,
+ ltime.tm_min, ltime.tm_sec, sign,
+ ltime.tm_gmtoff/3600,
+ (ltime.tm_gmtoff%3600)/60);
+
+ return local_ts;
+}
+
static const char *yesorno(gboolean a)
{
if (a)
@@ -243,6 +273,7 @@ static void get_messages_listing_cb(void *session, int err, uint16_t size,
{
struct mas_session *mas = user_data;
uint16_t max = 1024;
+ gchar *mse_time;
if (err < 0 && err != -EAGAIN) {
obex_object_set_io_flags(mas, G_IO_ERR, err);
@@ -358,6 +389,13 @@ proceed:
mas->outparams = g_obex_apparam_set_uint8(mas->outparams,
MAP_AP_NEWMESSAGE,
newmsg ? 1 : 0);
+ /* Response to report the local time of MSE */
+ mse_time = get_mse_timestamp();
+ if (mse_time) {
+ g_obex_apparam_set_string(mas->outparams,
+ MAP_AP_MSETIME, mse_time);
+ g_free(mse_time);
+ }
}
if (err != -EAGAIN)