*/
#include <stdio.h>
+#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <syspopup_caller.h>
#include <bundle.h>
#include <bundle_internal.h>
+#include <tethering.h>
+#include <mime_type.h>
+#include <app_control.h>
#include "plugin.h"
#include "bluetooth-api.h"
#define BT_MAX_EVENT_STR_LENGTH 50
#define BT_AGENT_SYSPOPUP_TIMEOUT_FOR_MULTIPLE_POPUPS 200
-#ifdef TIZEN_FEATURE_BT_DPM
int bt_launch_dpm_popup(char *mode)
{
int ret = 0;
return ret;
}
-#endif
static gboolean _bt_syspopup_timer_cb(gpointer user_data)
{
int bt_launch_system_popup(bt_agent_event_type_t event_type,
const char *device_name,
+ const char *remote_address,
const unsigned char *auth_info,
char *passkey,
const char *filename,
}
bundle_add(b, "device-name", device_name);
+ bundle_add(b, "address", remote_address);
bundle_add(b, "auth-info", (const char *)auth_info);
bundle_add(b, "passkey", passkey);
bundle_add(b, "file", filename);
return 0;
}
-gboolean bt_launch_unable_to_pairing_syspopup(int result)
+bool bt_launch_unable_to_pairing_syspopup(int result)
{
BT_DBG("+");
int ret = 0;
b = bundle_create();
if (b == NULL)
- return FALSE;
+ return false;
bundle_add(b, "event-type", "unable-to-pairing");
}
BT_DBG("-");
- return TRUE;
+ return true;
}
-void bt_destroy_popup_all(void)
+bool bt_is_tethering_enabled(void)
{
- syspopup_destroy_all();
+ BT_DBG("+");
+
+ tethering_h tethering = NULL;
+ bool enabled = FALSE;
+ int ret;
+
+ ret = tethering_create(&tethering);
+
+ if (ret != TETHERING_ERROR_NONE) {
+ BT_ERR("Fail to create tethering: %d", ret);
+ return FALSE;
+ }
+
+ enabled = tethering_is_enabled(tethering, TETHERING_TYPE_BT);
+
+ if (enabled != true)
+ BT_ERR("BT tethering is not enabled");
+
+ ret = tethering_destroy(tethering);
+
+ if (ret != TETHERING_ERROR_NONE)
+ BT_ERR("Fail to destroy tethering: %d", ret);
+
+ return enabled;
}
+int bt_get_mime_type(char *file_name, char **mime_type)
+{
+ BT_DBG("+");
-extern struct bluetooth_headed_plugin_t headed_plugin
-__attribute__ ((visibility("default")));
-struct bluetooth_headed_plugin_t headed_plugin = {
-#ifdef TIZEN_FEATURE_BT_DPM
- bt_launch_dpm_popup,
-#else
- NULL,
-#endif
- bt_launch_system_popup,
- bt_destroy_popup_all,
- bt_launch_unable_to_pairing_syspopup
-};
+ int ret = MIME_TYPE_ERROR_NONE;
+ if (file_name == NULL)
+ return BLUETOOTH_ERROR_INVALID_PARAM;
+ ret = mime_type_get_mime_type(file_name, (gchar **)mime_type);
+ if (ret != MIME_TYPE_ERROR_NONE) {
+ BT_ERR("Fail to get mime type: %d", ret);
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
+ return BLUETOOTH_ERROR_NONE;
+}
+void bt_destroy_popup_all(void)
+{
+ syspopup_destroy_all();
+}
+int bt_app_control_send_launch_request(char *absolute_path)
+{
+ BT_DBG("+");
+ app_control_h app_control;
+ int ret;
+ app_control_create(&app_control);
+ app_control_set_operation(app_control, APP_CONTROL_OPERATION_VIEW);
+ app_control_set_uri(app_control, absolute_path);
+ app_control_set_mime(app_control, "*/*");
+ if (app_control_send_launch_request(app_control, NULL, NULL) == APP_CONTROL_ERROR_NONE)
+ ret = BLUETOOTH_ERROR_NONE;
+ else
+ ret = BLUETOOTH_ERROR_INTERNAL;
+ app_control_destroy(app_control);
+ return ret;
+}
+extern struct bluetooth_headed_plugin_t headed_plugin
+__attribute__ ((visibility("default")));
+struct bluetooth_headed_plugin_t headed_plugin = {
+ bt_launch_dpm_popup,
+ bt_launch_system_popup,
+ bt_destroy_popup_all,
+ bt_launch_unable_to_pairing_syspopup,
+ bt_is_tethering_enabled,
+ bt_get_mime_type
+};