*/
#include <stdio.h>
+#include <stdarg.h>
#include <dd-display.h>
#include <app.h>
#include <device/display.h>
static void __popup_terminate(void);
+static char *format_string(const char *format, ...)
+{
+ va_list arg;
+ char* chTemp = NULL;
+ chTemp= (char*)malloc(1024 * sizeof(char));
+ if (!chTemp) {
+ BT_DBG("memory alloc failed");
+ return NULL;
+ }
+
+ va_start(arg,format);
+ vsnprintf(chTemp,1024,format,arg);
+ va_end(arg);
+ return chTemp;
+}
+
+
static int __bluetooth_term(bundle *b, void *data)
{
struct bt_popup_appdata *ad;
{
BT_DBG("bluetooth state changed callback");
int ret;
+ int timeout;
struct bt_popup_appdata *ad = (struct bt_popup_appdata *)user_data;
if (state == BT_ADAPTER_ENABLED) {
BT_DBG("bt enabled");
if (ad->visibility_timeout) {
- ret = bt_adapter_set_visibility(BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE, atoi(ad->visibility_timeout));
- BT_DBG("set visibility, returns:%d", ret);
+ timeout = atoi(ad->visibility_timeout);
+
+ if (timeout <= BT_VISIBILITY_TIMEOUT_MIN) {
+ ret = bt_adapter_set_visibility(BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE, BT_VISIBILITY_TIMEOUT_MIN);
+ BT_DBG("set visibility, returns:%d", ret);
+ } else if (timeout >= BT_VISIBILITY_TIMEOUT_MAX) {
+ ret = bt_adapter_set_visibility(BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE, BT_VISIBILITY_TIMEOUT_MAX);
+ BT_DBG("set visibility, returns:%d", ret);
+ } else {
+ ret = bt_adapter_set_visibility(BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE, timeout);
+ BT_DBG("set visibility, returns:%d", ret);
+ }
+
+ free(ad->visibility_timeout);
+ ad->visibility_timeout = NULL;
} else {
- ret = bt_adapter_set_visibility(BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE, 120);
+ /* default timeout value */
+ ret = bt_adapter_set_visibility(BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE, BT_VISIBILITY_TIMEOUT_DEFAULT);
BT_DBG("set visibility, returns:%d", ret);
}
char *agent_path;
char *conv_str = NULL;
char *stms_str = NULL;
+ char *popup_text = NULL;
+ char *tmp_timeout = NULL;
int ret;
if (!reset_data || !event_type)
} else if (!strcasecmp(event_type, "visibility-request")) {
BT_INFO("visibility request popup");
- __bluetooth_draw_popup(ad, "Bluetooth permission request",
- "Requesting permission to turn on Bluetooth and to set Visibility. Do you want to do this?", BT_STR_CANCEL, BT_STR_CONFIRM,
+ if (ad->visibility_timeout) {
+ timeout = atoi(ad->visibility_timeout);
+
+ if (timeout <= BT_VISIBILITY_TIMEOUT_MIN)
+ tmp_timeout = BT_VISIBILITY_TIMEOUT_MIN_STR;
+ else if (timeout >= BT_VISIBILITY_TIMEOUT_MAX)
+ tmp_timeout = BT_VISIBILITY_TIMEOUT_MAX_STR;
+ else
+ tmp_timeout = ad->visibility_timeout;
+ } else {
+ /* default timeout value */
+ tmp_timeout = BT_VISIBILITY_TIMEOUT_DEFAULT_STR;
+ }
+
+ popup_text = format_string("Requesting permission to turn on Bluetooth and to set Visibility during %s seconds. Do you want to do this?",
+ tmp_timeout);
+
+ __bluetooth_draw_popup(ad, "Bluetooth permission request", popup_text, BT_STR_CANCEL, BT_STR_CONFIRM,
__bluetooth_visibility_confirm_cb);
} else if (!strcasecmp(event_type, "passkey-request")) {
return;
}
+ ad->visibility_timeout = NULL;
ret = app_control_get_extra_data(app_control, "timeout", &timeout);
if (ret < 0) {
BT_ERR("Get data error");
if (app_control_get_operation(app_control, &operation) < 0)
BT_ERR("Get operation error");
- BT_INFO("operation: %s", operation);
- BT_DBG("event-type: %s", event_type);
+ if (operation)
+ BT_INFO("operation: %s", operation);
if (event_type != NULL) {
+ BT_DBG("event-type: %s", event_type);
+
if (!strcasecmp(event_type, "terminate")) {
__bluetooth_win_del(ad);
goto release;