}
/* Higher level functions */
-
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+void g_obex_io_shutdown(GObex *obex)
+{
+ GError *err = NULL;
+ if (obex->io != NULL)
+ g_io_channel_shutdown(obex->io, FALSE, &err);
+}
+#endif
guint g_obex_connect(GObex *obex, GObexResponseFunc func, gpointer user_data,
GError **err, guint8 first_hdr_id, ...)
{
const char *g_obex_strerror(guint8 err_code);
guint8 g_obex_errno_to_rsp(int err);
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+void g_obex_io_shutdown(GObex *obex);
+#endif
#endif /* __GOBEX_H */
static DBusMessage *profile_request_disconnection(DBusConnection *conn,
DBusMessage *msg, void *data)
{
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+ const char *device;
+ const char *path;
+ path = dbus_message_get_path(msg);
+ DBG("Path %s", path);
+
+ dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &device,
+ DBUS_TYPE_INVALID);
+ DBG("Device %s", device);
+
+ obex_session_disconnect(path, device);
+#endif
return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
}
#include <glib.h>
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+#include "lib/uuid.h"
+#endif
+
#include "gobex/gobex.h"
#include "btio/btio.h"
obex_session_destroy(os);
}
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+#define BLUETOOTH_MAC_ADDRESS_LEN 18
+void obex_convert_device_path_to_address(const char *device_path,
+ char *device_address)
+{
+ char address[BLUETOOTH_MAC_ADDRESS_LEN] = { 0 };
+ char *dev_addr;
+
+ if (device_path == NULL || device_address == NULL)
+ return;
+
+ dev_addr = strstr(device_path, "dev_");
+ if (dev_addr != NULL) {
+ char *pos = NULL;
+ dev_addr += 4;
+ g_strlcpy(address, dev_addr, sizeof(address));
+
+ while ((pos = strchr(address, '_')) != NULL)
+ *pos = ':';
+
+ g_strlcpy(device_address, address, BLUETOOTH_MAC_ADDRESS_LEN);
+ }
+}
+
+int obex_object_path_to_uuid(const char *path)
+{
+ char uuid[MAX_LEN_UUID_STR] = { 0 };
+ const char *uuidptr;
+
+ if (path == NULL)
+ return -1;
+ /* /org/bluez/obex/0000112f_0000_1000_8000_00805f9b34fb */
+ uuidptr = path;
+
+ char *pos = NULL;
+ uuidptr += 16;
+ g_strlcpy(uuid, uuidptr, sizeof(uuid));
+
+ while ((pos = strchr(uuid, '_')) != NULL)
+ *pos = '-';
+
+ if (g_strcmp0(uuid, OBEX_PSE_UUID) == 0)
+ return OBEX_PBAP;
+ else if (g_strcmp0(uuid, OBEX_FTP_UUID) == 0)
+ return OBEX_FTP;
+ else if (g_strcmp0(uuid, OBEX_OPP_UUID) == 0)
+ return OBEX_OPP;
+ else if (g_strcmp0(uuid, OBEX_MAS_UUID) == 0)
+ return OBEX_MAS;
+ else if (g_strcmp0(uuid, OBEX_MNS_UUID) == 0)
+ return OBEX_MNS;
+ else
+ return -1;
+}
+
+void obex_session_disconnect(const char *uuid_path, const char *device_path)
+{
+ GSList *l = sessions;
+ char device_address[BLUETOOTH_MAC_ADDRESS_LEN];
+ int service;
+
+ obex_convert_device_path_to_address(device_path, device_address);
+ service = obex_object_path_to_uuid(uuid_path);
+
+ if (service == -1)
+ return;
+
+ while (l) {
+ struct obex_session *os = l->data;
+ if (g_strcmp0(os->dst, device_address) == 0 &&
+ os->service->service == service) {
+ /* Need to check for address? */
+ g_obex_io_shutdown(os->obex);
+ obex_session_destroy(os);
+ break;
+ }
+ l = l->next;
+ }
+}
+#endif
+
int obex_session_start(GIOChannel *io, uint16_t tx_mtu, uint16_t rx_mtu,
gboolean stream, struct obex_server *server)
{
void btd_device_set_trusted_profiles(struct btd_device *device,
uint32_t pbap, uint32_t map, uint32_t sap)
{
+ char *uuid = NULL;
if (!device)
return;
DBG("TrustedProfiles Parameters: [PBAP %d] [MAP %d] [SAP %d]", pbap, map, sap);
device->trusted_profiles.sap == sap)
return;
- device->trusted_profiles.pbap = pbap;
- device->trusted_profiles.map = map;
- device->trusted_profiles.sap = sap;
+ /* If any of the profile is Blocked than only assign uuid */
+ if (device->trusted_profiles.pbap != pbap) {
+ device->trusted_profiles.pbap = pbap;
+ if (pbap == SUPPORTED_BLOCKED)
+ uuid = OBEX_PSE_UUID;
+ } else if (device->trusted_profiles.map != map) {
+ device->trusted_profiles.map = map;
+ if (map == SUPPORTED_BLOCKED)
+ uuid = OBEX_MAP_UUID;
+ } else {
+ device->trusted_profiles.sap = sap;
+ if (sap == SUPPORTED_BLOCKED)
+ uuid = SAP_UUID;
+ }
store_device_info(device);
+ /* If uuid is set than only disconnect */
+ if (uuid) {
+ GSList *l;
+ l = find_service_with_uuid(device->services, uuid);
+ if (l == NULL)
+ goto emit;
+ struct btd_service *service = l->data;
+ if (btd_service_get_state(service) ==
+ BTD_SERVICE_STATE_CONNECTED) {
+ int err;
+ err = btd_service_disconnect(service);
+ if (err)
+ error("error: %s", strerror(-err));
+ }
+ }
+emit:
+
g_dbus_emit_property_changed(dbus_conn, device->path,
DEVICE_INTERFACE, "TrustedProfiles");
}