Fix the crash when SET_PATH command is recieved 67/69067/2
authorDoHyun Pyun <dh79.pyun@samsung.com>
Wed, 11 May 2016 09:57:16 +0000 (18:57 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Wed, 11 May 2016 10:55:57 +0000 (19:55 +0900)
This patchset is related with TC_MSE_MMB_BV_09_I PTS testcase.

Change-Id: I96cbea2d315182bc934e9684e6be447c2bdaf351
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
obexd/client/mns-tizen.c
obexd/plugins/mas.c
obexd/plugins/messages-tizen.c
obexd/plugins/pbap.c
obexd/src/obex.c [changed mode: 0755->0644]

index 4952225..c6da1eb 100644 (file)
@@ -36,6 +36,7 @@
 #include "driver.h"
 #include "map_ap.h"
 #include "mns-tizen.h"
+#include "gobex/gobex-apparam.h"
 
 #define OBEX_MNS_UUID \
        "\xBB\x58\x2B\x41\x42\x0C\x11\xDB\xB0\xDE\x08\x00\x20\x0C\x9A\x66"
@@ -58,12 +59,6 @@ enum msg_event_type {
        EVENT_TYPE_UNKNOWN,
 };
 
-struct sendevent_apparam {
-       uint8_t     masinstanceid_tag;
-       uint8_t     masinstanceid_len;
-       uint8_t     masinstanceid;
-} __attribute__ ((packed));
-
 struct mns_data {
        struct obc_session *session;
        DBusMessage *msg;
@@ -135,7 +130,7 @@ static DBusMessage *send_event(DBusConnection *connection,
 {
        struct mns_data *mns = user_data;
        struct obc_transfer *transfer;
-       struct sendevent_apparam apparam;
+       GObexApparam *apparam;
        gchar *event_type;
        gchar *folder;
        gchar *old_folder;
@@ -170,12 +165,10 @@ static DBusMessage *send_event(DBusConnection *connection,
        if (transfer == NULL)
                goto fail;
 
-       apparam.masinstanceid_tag = MAP_AP_MASINSTANCEID;
-       apparam.masinstanceid_len = 1;
        /* Obexd currently supports single SDP for MAS */
-       apparam.masinstanceid = 0;
+       apparam = g_obex_apparam_set_uint8(NULL, MAP_AP_MASINSTANCEID, 0);
 
-       obc_transfer_set_apparam(transfer, &apparam);
+       obc_transfer_set_apparam(transfer, apparam);
 
        if (obc_session_queue(mns->session, transfer, NULL, NULL, &err))
                return dbus_message_new_method_return(message);
index 8d0531a..7036497 100644 (file)
@@ -178,14 +178,9 @@ static void mas_disconnect(struct obex_session *os, void *user_data)
        DBG("");
 
        manager_unregister_session(os);
-#ifdef __TIZEN_PATCH__
-       if (mas)
-#endif
-       {
-               messages_disconnect(mas->backend_data);
+       messages_disconnect(mas->backend_data);
 
-               mas_clean(mas);
-       }
+       mas_clean(mas);
 }
 
 static int mas_get(struct obex_session *os, void *user_data)
index 690237a..7613484 100644 (file)
@@ -1,23 +1,22 @@
 /*
  *
- * OBEX Server
- *
- * Copyright (c) 2000-2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *  OBEX Server
  *
+ *  Copyright (C) 2012 Samsung Electronics Co., Ltd.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 2 of the License, or
  *  (at your option) any later version.
  *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  *
  */
 
@@ -1013,6 +1012,28 @@ int messages_get_folder_listing(void *s, const char *name,
        return 0;
 }
 
+
+static void append_variant(DBusMessageIter *iter, int type, void *val)
+{
+       DBusMessageIter value;
+       char sig[2] = { type, '\0' };
+
+       dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, sig, &value);
+       dbus_message_iter_append_basic(&value, type, val);
+       dbus_message_iter_close_container(iter, &value);
+}
+
+static void dict_append_entry(DBusMessageIter *dict, const char *key,
+                                       int type, void *val)
+{
+       DBusMessageIter entry;
+
+       dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
+       dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
+       append_variant(&entry, type, val);
+       dbus_message_iter_close_container(dict, &entry);
+}
+
 int messages_get_messages_listing(void *session, const char *name,
                                uint16_t max, uint16_t offset,
                                uint8_t subject_len,
@@ -1023,6 +1044,8 @@ int messages_get_messages_listing(void *session, const char *name,
        DBusPendingCall *call;
        DBusMessage *message;
        struct session *s = session;
+       DBusMessageIter iter;
+       DBusMessageIter dict;
 
        if (name != NULL && strlen(name))
                s->name = g_strdup(name);
@@ -1058,8 +1081,44 @@ int messages_get_messages_listing(void *session, const char *name,
 
        dbus_message_append_args(message, DBUS_TYPE_STRING, &s->name,
                                                DBUS_TYPE_UINT16, &s->max,
+                                               DBUS_TYPE_UINT16, &s->offset,
+                                               DBUS_TYPE_BYTE, &subject_len,
                                                DBUS_TYPE_INVALID);
 
+       dbus_message_iter_init_append(message, &iter);
+       dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+                       DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+                       DBUS_TYPE_STRING_AS_STRING
+                       DBUS_TYPE_VARIANT_AS_STRING
+                       DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
+
+       if (filter->parameter_mask)
+               dict_append_entry(&dict, "ParameterMask", DBUS_TYPE_UINT32,
+                                       &filter->parameter_mask);
+       if (filter->type)
+               dict_append_entry(&dict, "FilterMessageType", DBUS_TYPE_BYTE,
+                                       &filter->type);
+       if (filter->period_begin)
+               dict_append_entry(&dict, "FilterPeriodBegin", DBUS_TYPE_STRING,
+                                       &filter->period_begin);
+       if (filter->period_end)
+               dict_append_entry(&dict, "FilterPeriodEnd", DBUS_TYPE_STRING,
+                                       &filter->period_end);
+       if (filter->read_status)
+               dict_append_entry(&dict, "FilterReadStatus", DBUS_TYPE_BYTE,
+                                       &filter->read_status);
+       if (filter->recipient)
+               dict_append_entry(&dict, "FilterRecipient", DBUS_TYPE_STRING,
+                                       &filter->recipient);
+       if (filter->originator)
+               dict_append_entry(&dict, "FilterOriginator", DBUS_TYPE_STRING,
+                                       &filter->originator);
+       if (filter->priority)
+               dict_append_entry(&dict, "FilterPriority", DBUS_TYPE_BYTE,
+                                       &filter->priority);
+
+       dbus_message_iter_close_container(&iter, &dict);
+
        if (dbus_connection_send_with_reply(g_conn, message, &call,
                                        DBUS_TIMEOUT_INFINITE) == FALSE) {
                error("Could not send dbus message");
index e21231c..68520b8 100644 (file)
@@ -969,8 +969,15 @@ static ssize_t vobject_pull_get_next_header(void *object, void *buf, size_t mtu,
 
        if (obj->firstpacket) {
                obj->firstpacket = FALSE;
-
+#ifdef __TIZEN_PATCH__
+               gsize count = 0;
+               count = g_obex_apparam_encode(obj->apparam, buf, mtu);
+               DBG("APPARAM Processed remove tags");
+               g_obex_apparam_remove_all(obj->apparam);
+               return count;
+#else
                return g_obex_apparam_encode(obj->apparam, buf, mtu);
+#endif
        }
 
        return 0;
@@ -1025,8 +1032,13 @@ static ssize_t vobject_list_get_next_header(void *object, void *buf, size_t mtu,
 
        return 0;
 #else
-       if (obj->apparam != NULL)
-               return g_obex_apparam_encode(obj->apparam, buf, mtu);
+       if (obj->apparam != NULL) {
+               gsize count = 0;
+               count = g_obex_apparam_encode(obj->apparam, buf, mtu);
+               DBG("APPARAM Processed remove tags");
+               g_obex_apparam_remove_all(obj->apparam);
+               return count;
+       }
        else
                return 0;
 #endif /* __TIZEN_PATCH__ */
old mode 100755 (executable)
new mode 100644 (file)
index d62839f..580b12e
@@ -643,8 +643,8 @@ static void parse_name(struct obex_session *os, GObexPacket *req)
        if (!g_obex_header_get_unicode(hdr, &name))
                return;
 #ifdef __TIZEN_PATCH__
-       DBG("TYPE===>: %s", os->type);
-       if (name && strcmp(os->type, "x-bt/phonebook")) {
+       DBG("Obex Session For: %s", os->service->name);
+       if (name && g_strcmp0(os->service->name, "Object Push server") == 0) {
                char *new_name;
                new_name = strrchr(name, '/');
                if (new_name) {