summaryrefslogtreecommitdiff
path: root/ug-nfc-setting-efl
diff options
context:
space:
mode:
authorJunyong Sim <junyong.sim@samsung.com>2012-11-09 17:12:57 +0900
committerJunyong Sim <junyong.sim@samsung.com>2012-11-09 17:12:57 +0900
commit256b20b2eec31359b7259a7499c2a527ea197f8e (patch)
tree67a79606de82d185590be85777699e407b28030d /ug-nfc-setting-efl
parentbe450676c39a0263ab29298e5d045eb2a72d1657 (diff)
downloadug-nfc-efl-256b20b2eec31359b7259a7499c2a527ea197f8e.tar.gz
ug-nfc-efl-256b20b2eec31359b7259a7499c2a527ea197f8e.tar.bz2
ug-nfc-efl-256b20b2eec31359b7259a7499c2a527ea197f8e.zip
sync RSA
Diffstat (limited to 'ug-nfc-setting-efl')
-rw-r--r--ug-nfc-setting-efl/CMakeLists.txt19
-rw-r--r--ug-nfc-setting-efl/data/edc/ug-setting-nfc-efl.edc (renamed from ug-nfc-setting-efl/data/edc/ug-nfc-setting-efl.edc)52
-rw-r--r--ug-nfc-setting-efl/data/icons/nfc.pngbin14669 -> 0 bytes
-rw-r--r--ug-nfc-setting-efl/data/icons/setting-nfc.pngbin0 -> 10309 bytes
-rw-r--r--ug-nfc-setting-efl/include/ug-nfc-setting-main.h19
-rw-r--r--ug-nfc-setting-efl/src/ug-nfc-setting-main.c549
-rw-r--r--ug-nfc-setting-efl/src/ug-nfc-setting-popup.c3
7 files changed, 506 insertions, 136 deletions
diff --git a/ug-nfc-setting-efl/CMakeLists.txt b/ug-nfc-setting-efl/CMakeLists.txt
index be86fea..00cb069 100644
--- a/ug-nfc-setting-efl/CMakeLists.txt
+++ b/ug-nfc-setting-efl/CMakeLists.txt
@@ -11,6 +11,11 @@ SET(LOCALEDIR "${RESDIR}/locale")
SET(EDJDIR "${RESDIR}/edje/${PROJECT_NAME}")
SET(ICONDIR "${RESDIR}/icons/${PROJECT_NAME}")
+ADD_DEFINITIONS("-DPACKAGE=\"ug-setting-nfc-efl\"")
+ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
+ADD_DEFINITIONS("-DLOCALEDIR=\"${LOCALEDIR}\"")
+ADD_DEFINITIONS("-DEDJDIR=\"${EDJDIR}\"")
+
SET(SRCS
src/ug-nfc-setting-main.c
src/ug-nfc-setting-popup.c
@@ -62,16 +67,16 @@ ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION 0.1.0)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_ug_nfc_setting_LDFLAGS})
-ADD_CUSTOM_TARGET(ug-nfc-setting-efl.edj
+ADD_CUSTOM_TARGET(ug-setting-nfc-efl.edj
COMMAND edje_cc
- ${CMAKE_CURRENT_SOURCE_DIR}/data/edc/ug-nfc-setting-efl.edc ${CMAKE_BINARY_DIR}/ug-nfc-setting-efl.edj
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/data/edc/ug-nfc-setting-efl.edc
+ ${CMAKE_CURRENT_SOURCE_DIR}/data/edc/ug-setting-nfc-efl.edc ${CMAKE_BINARY_DIR}/ug-setting-nfc-efl.edj
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/data/edc/ug-setting-nfc-efl.edc
)
-ADD_DEPENDENCIES(${PROJECT_NAME} ug-nfc-setting-efl.edj)
+ADD_DEPENDENCIES(${PROJECT_NAME} ug-setting-nfc-efl.edj)
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /opt/ug/lib)
-INSTALL(FILES ${CMAKE_BINARY_DIR}/ug-nfc-setting-efl.edj DESTINATION ${EDJDIR})
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIBDIR})
+INSTALL(FILES ${CMAKE_BINARY_DIR}/ug-setting-nfc-efl.edj DESTINATION ${EDJDIR})
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/nfc.png DESTINATION ${ICONDIR})
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/setting-nfc.png DESTINATION ${ICONDIR})
ADD_SUBDIRECTORY(po)
diff --git a/ug-nfc-setting-efl/data/edc/ug-nfc-setting-efl.edc b/ug-nfc-setting-efl/data/edc/ug-setting-nfc-efl.edc
index 5077db2..8ce962d 100644
--- a/ug-nfc-setting-efl/data/edc/ug-nfc-setting-efl.edc
+++ b/ug-nfc-setting-efl/data/edc/ug-setting-nfc-efl.edc
@@ -71,8 +71,9 @@
} \
} \
-#define SETTING_LIST_HEIGHT (40+113+113)
-#define SCREEN_HEIGHT 1280
+#define SETTING_LIST_HEIGHT (40+1+112+1+112+1+1)
+#define PREDEFINED_ITEM_HEIGHT (40+1+112+15+1)
+#define SCREEN_HEIGHT 1280
collections {
@@ -111,36 +112,67 @@ collections {
}
}
+ PADDING_LEFT(40)
+ PADDING_RIGHT(40)
+
+ part
+ {
+ name: "sbeam_help";
+ type: SWALLOW;
+ scale:1;
+ description
+ {
+ state: "default" 0.0;
+ rel1{relative: 1 1; to_x:"left_pad"; to_y: "setting_list";}
+ rel2{relative: 0 1; to_x:"right_pad";to_y: "setting_list";}
+ align: 0 0;
+ }
+ }
+
part
{
- name: "setting_list_pad";
+ name: "list_pad_1";
type: RECT;
scale: 1;
description
{
state: "default" 0.0;
color: 0 0 0 0;
- min: 0 36;
+ min: 0 40;
fixed: 0 1;
- rel1 {relative: 0 1; to_y: "setting_list";}
- rel2 {relative: 1 1; to_y: "setting_list";}
+ rel1 {relative: 0 1; to_y: "sbeam_help";}
+ rel2 {relative: 1 1; to_y: "sbeam_help";}
align:0 0;
}
}
- PADDING_LEFT(40)
- PADDING_RIGHT(40)
+ part
+ {
+ name: "predefined_item_list";
+ type: SWALLOW;
+ scale:1;
+ description
+ {
+ state: "default" 0.0;
+ min: 0 PREDEFINED_ITEM_HEIGHT;
+ fixed: 0 1;
+ rel1 {relative: 0 1; to_y: "list_pad_1";}
+ rel2 {relative: 1 1; to_y: "list_pad_1";}
+ align: 0 0;
+ }
+ }
+
PADDING_BOTTOM(40)
part
{
- name: "sbeam_help";
+ name: "predefined_item_help";
type: SWALLOW;
scale:1;
description
{
state: "default" 0.0;
- rel1{relative: 1 1; to_x:"left_pad"; to_y: "setting_list";}
+ rel1{relative: 1 1; to_x:"left_pad"; to_y: "predefined_item_list";}
rel2{relative: 0 0; to_x:"right_pad";to_y: "bottom_pad";}
align: 0 0;
}
diff --git a/ug-nfc-setting-efl/data/icons/nfc.png b/ug-nfc-setting-efl/data/icons/nfc.png
deleted file mode 100644
index 705855b..0000000
--- a/ug-nfc-setting-efl/data/icons/nfc.png
+++ /dev/null
Binary files differ
diff --git a/ug-nfc-setting-efl/data/icons/setting-nfc.png b/ug-nfc-setting-efl/data/icons/setting-nfc.png
new file mode 100644
index 0000000..51145f1
--- /dev/null
+++ b/ug-nfc-setting-efl/data/icons/setting-nfc.png
Binary files differ
diff --git a/ug-nfc-setting-efl/include/ug-nfc-setting-main.h b/ug-nfc-setting-efl/include/ug-nfc-setting-main.h
index 2ac96e2..d96d713 100644
--- a/ug-nfc-setting-efl/include/ug-nfc-setting-main.h
+++ b/ug-nfc-setting-efl/include/ug-nfc-setting-main.h
@@ -28,14 +28,11 @@ extern "C" {
#include <dlog.h>
#include <nfc.h>
-#define PACKAGE "ug-setting-nfc-efl"
-#ifdef PREFIX
-#undef PREFIX
-#endif
-#define PREFIX "/opt/ug/"
-#define EDJ_PATH PREFIX"/res/edje/"PACKAGE
-#define EDJ_FILE EDJ_PATH"/ug-nfc-setting-efl.edj"
-#define LOCALE_PATH PREFIX"/res/locale"
+#define LOCALE_PATH LOCALEDIR
+#define EDJ_PATH EDJDIR
+#define EDJ_FILE EDJ_PATH"/"PACKAGE".edj"
+
+#define PREDEFINED_ITEM_FILE_PATH "/usr/apps/org.tizen.57r43275q7/share"
#ifdef LOG_TAG
#undef LOG_TAG
@@ -53,7 +50,12 @@ extern "C" {
#define IDS_NFC_S_BEAM dgettext(PACKAGE, "IDS_NFC_OPT_S_BEAM")
#define IDS_NFC_S_BEAM_DESCRIPTION_MSG_CHN dgettext(PACKAGE, "IDS_NFC_BODY_S_BEAM_DESCRIPTION_MSG_CHN")
#define IDS_CLOSE dgettext("sys_string", "IDS_COM_POP_CLOSE")
+#define IDS_NONE dgettext("sys_string", "IDS_COM_BODY_NONE")
+
+#define IDS_PREDEFINED_ITEM _("Predefined item")
+#define IDS_PREDEFINED_ITEM_DESCRIPTION_MSG _("You can beam selected item to other NFC device by holding the devices close together in homescreenor main menu.")
+#define IDS_SECURITY_POLICY_RESTRICTS_USE_OF_PS _("Security policy restricts use of %s")
#define IDS_NFC_SERVICE_IS_NOT_SUPPORTED _("NFC service is not supported")
typedef enum _NFCSettingType {
@@ -61,6 +63,7 @@ typedef enum _NFCSettingType {
#ifdef _SBEAM_SUPPORT_
NFC_S_BEAM,
#endif
+ NFC_PREDEFINED_ITEM,
NFC_SETTING_MAX
} NFCSettingType;
diff --git a/ug-nfc-setting-efl/src/ug-nfc-setting-main.c b/ug-nfc-setting-efl/src/ug-nfc-setting-main.c
index a3bee46..cad3b18 100644
--- a/ug-nfc-setting-efl/src/ug-nfc-setting-main.c
+++ b/ug-nfc-setting-efl/src/ug-nfc-setting-main.c
@@ -39,15 +39,55 @@
#define S_BEAM_DESCRIPTION_MSG_WRAP_WIDTH 640
#endif
-static Elm_Genlist_Item_Class itc_seperator;
-static Elm_Genlist_Item_Class itc;
+#define MAX_PREDEFINED_ITEM_COUNT 100
+
+static Elm_Genlist_Item_Class itc_check;
+static Elm_Genlist_Item_Class itc_helptext;
+static Elm_Genlist_Item_Class itc_2text;
+static Elm_Genlist_Item_Class itc_radio;
+
static Elm_Object_Item *on_off_item = NULL;
#ifdef _SBEAM_SUPPORT_
static Elm_Object_Item *sbeam_item = NULL;
+static Elm_Object_Item *sbeam_item_help = NULL;
#endif
+static Elm_Object_Item *predefined_item = NULL;
+static Elm_Object_Item *predefined_item_help = NULL;
+
+Evas_Object *radio_main = NULL;
+char **predefined_item_list = NULL;
+int predefined_item_count = 0;
+static int state_index = 0; //selected radio index
+
static bool pending_status = FALSE;
+static void _mdm_restricted_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ ugdata_t *ug_data = (ugdata_t *)data;
+ if (!ug_data)
+ return;
+
+ LOGD("[%s(): %d] BEGIN >>>>", __FUNCTION__, __LINE__);
+ LOGD("[%s(): %d] END >>>>", __FUNCTION__, __LINE__);
+}
+
+static void _mdm_restricted_popup(void *data)
+{
+ LOGD("[%s(): %d] BEGIN >>>>", __FUNCTION__, __LINE__);
+
+ char popup_str[POPUP_TEXT_SIZE] = { 0, };
+ ugdata_t *ug_data = (ugdata_t *)data;
+ if (!ug_data)
+ return;
+
+ snprintf(popup_str, POPUP_TEXT_SIZE, IDS_SECURITY_POLICY_RESTRICTS_USE_OF_PS, IDS_NFC_NFC);
+ ug_nfc_setting_create_popup(ug_data, ug_data->base_layout, popup_str, NULL, 0, NULL, 0, NULL, 0, true, true, _mdm_restricted_popup_response_cb);
+
+ LOGD("[%s(): %d] END >>>>", __FUNCTION__, __LINE__);
+}
+
+
static void _app_error_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
{
ugdata_t *ug_data = (ugdata_t *)data;
@@ -283,29 +323,28 @@ static void _set_pending_status(bool status)
pending_status = status;
}
-static void _activation_completed_cb(nfc_error_e error, void *user_data)
-{
- LOGD("[%s(): %d] BEGIN >>>>", __FUNCTION__, __LINE__);
-
- nfc_manager_deinitialize();
-
- LOGD("[%s(): %d] END <<<<", __FUNCTION__, __LINE__);
-}
-
-static void _change_nfc_onoff_setting(void)
+static void _change_nfc_onoff_setting(void *data)
{
int status;
int result;
LOGD("[%s(): %d] BEGIN >>>>", __FUNCTION__, __LINE__);
+ ugdata_t *ug_data = (ugdata_t *)data;
+ if (!ug_data)
+ return;
+
if ((result = vconf_get_bool(VCONFKEY_NFC_STATE, &status)) == 0)
{
LOGD("[%s(): %d] vconf_get_bool status [%d]\n", __FUNCTION__, __LINE__, status);
- nfc_manager_initialize(NULL, NULL);
+ result = nfc_manager_set_activation(!status, NULL, NULL);
+ if (result == NFC_ERROR_SECURITY_RESTRICTED)
+ {
+ _mdm_restricted_popup(ug_data);
+ return;
+ }
_set_pending_status(TRUE);
- nfc_manager_set_activation(!status, _activation_completed_cb, NULL);
}
else
{
@@ -318,8 +357,8 @@ static void _change_nfc_onoff_setting(void)
#ifdef _SBEAM_SUPPORT_
static void _change_nfc_sbeam_setting(void)
{
- int status;
- int result;
+ int status = 0;
+ int result = -1;
LOGD("[%s(): %d] BEGIN >>>>", __FUNCTION__, __LINE__);
@@ -329,11 +368,27 @@ static void _change_nfc_sbeam_setting(void)
if (status)
{
- vconf_set_bool(VCONFKEY_NFC_SBEAM, FALSE);
+ result = vconf_set_bool(VCONFKEY_NFC_SBEAM, FALSE);
+ if (!result )
+ {
+ LOGD("[%s(): %d] vconf_set_bool success\n", __FUNCTION__, __LINE__);
+ }
+ else
+ {
+ LOGD("[%s(): %d] vconf_set_bool failed\n", __FUNCTION__, __LINE__);
+ }
}
else
{
- vconf_set_bool(VCONFKEY_NFC_SBEAM, TRUE);
+ result = vconf_set_bool(VCONFKEY_NFC_SBEAM, TRUE);
+ if (!result )
+ {
+ LOGD("[%s(): %d] vconf_set_bool success\n", __FUNCTION__, __LINE__);
+ }
+ else
+ {
+ LOGD("[%s(): %d] vconf_set_bool failed\n", __FUNCTION__, __LINE__);
+ }
}
}
else
@@ -345,28 +400,17 @@ static void _change_nfc_sbeam_setting(void)
}
#endif
-static void _nfc_onoff_vconf_update_cb(keynode_t *key, void *data)
+void _nfc_activation_changed_cb(bool activated , void *user_data)
{
LOGD("[%s(): %d] BEGIN >>>>", __FUNCTION__, __LINE__);
- int nfc_mode = 0;
#ifdef _SBEAM_SUPPORT_
int sbeam_state = 0;
static int sbeam_off_by_nfcOnOff = EINA_FALSE;
#endif
int result;
- if ((result = vconf_get_bool(VCONFKEY_NFC_STATE, &nfc_mode)) == 0)
- {
- LOGD("[%s(): %d] vconf_get_bool status [%d]\n", __FUNCTION__, __LINE__, nfc_mode);
- }
- else
- {
- LOGD("[%s(): %d] vconf_get_bool failed\n", __FUNCTION__, __LINE__);
- return;
- }
-
- LOGD("nfc mode %s \n", nfc_mode > 0 ? "ON" : "OFF");
+ LOGD("nfc mode %s \n", activated ? "ON" : "OFF");
#ifdef _SBEAM_SUPPORT_
if ((result = vconf_get_bool(VCONFKEY_NFC_SBEAM, &sbeam_state)) == 0)
@@ -389,48 +433,56 @@ static void _nfc_onoff_vconf_update_cb(keynode_t *key, void *data)
if (on_off_item != NULL)
elm_genlist_item_update(on_off_item);
-#ifdef _SBEAM_SUPPORT_
- if (nfc_mode == VCONFKEY_NFC_STATE_OFF)
+ if (activated == true)
{
- /* sbeam setting disabled */
- elm_object_item_disabled_set(sbeam_item, EINA_TRUE);
+ /* predefined item setting enabled */
+ elm_object_item_disabled_set(predefined_item, EINA_FALSE);
+ elm_object_item_disabled_set(predefined_item_help, EINA_FALSE);
- if (sbeam_state == VCONFKEY_NFC_SBEAM_OFF)
+#ifdef _SBEAM_SUPPORT_
+ /* sbeam setting enabled */
+ elm_object_item_disabled_set(sbeam_item, EINA_FALSE);
+ elm_object_item_disabled_set(sbeam_item_help, EINA_FALSE);
+
+ if (sbeam_off_by_nfcOnOff != EINA_TRUE)
return;
- LOGD("Turning S Beam off \n");
+ LOGD("Turning S Beam on \n");
_change_nfc_sbeam_setting();
if (sbeam_item != NULL)
elm_genlist_item_update(sbeam_item);
- /* set internal flag */
- sbeam_off_by_nfcOnOff = EINA_TRUE;
+ /* unset internal flag */
+ sbeam_off_by_nfcOnOff = EINA_FALSE;
+#endif
}
- else if (nfc_mode > VCONFKEY_NFC_STATE_OFF)
+ else
{
- /* sbeam setting enabled */
- elm_object_item_disabled_set(sbeam_item, EINA_FALSE);
+ /* predefined item setting disabled */
+ elm_object_item_disabled_set(predefined_item, EINA_TRUE);
+ elm_object_item_disabled_set(predefined_item_help, EINA_TRUE);
- if (sbeam_off_by_nfcOnOff != EINA_TRUE)
+#ifdef _SBEAM_SUPPORT_
+ /* sbeam setting disabled */
+ elm_object_item_disabled_set(sbeam_item, EINA_TRUE);
+ elm_object_item_disabled_set(sbeam_item_help, EINA_TRUE);
+
+ if (sbeam_state == VCONFKEY_NFC_SBEAM_OFF)
return;
- LOGD("Turning S Beam on \n");
+ LOGD("Turning S Beam off \n");
_change_nfc_sbeam_setting();
if (sbeam_item != NULL)
elm_genlist_item_update(sbeam_item);
- /* unset internal flag */
- sbeam_off_by_nfcOnOff = EINA_FALSE;
- }
- else
- {
- LOGD("Invalid Vconf value \n");
- }
+ /* set internal flag */
+ sbeam_off_by_nfcOnOff = EINA_TRUE;
#endif
+ }
LOGD("[%s(): %d] END <<<<", __FUNCTION__, __LINE__);
}
@@ -468,6 +520,194 @@ static Evas_Object *_create_main_layout(Evas_Object *parent)
return layout;
}
+static char *_gl_radio_text_get(void *data, Evas_Object *obj, const char *part)
+{
+ int index = (int) data;
+
+ if (!strcmp(part, "elm.text"))
+ {
+ return strdup(predefined_item_list[index]);
+ }
+
+ return NULL;
+}
+
+static Evas_Object *_gl_radio_content_get(void *data, Evas_Object *obj, const char *part)
+{
+ int index = (int) data;
+ Evas_Object *radio = NULL;
+
+ if (!strcmp(part, "elm.icon") || !strcmp(part, "elm.swallow.icon"))
+ {
+ radio = elm_radio_add(obj);
+ elm_radio_state_value_set(radio, index);
+ elm_radio_group_add(radio, radio_main);
+
+ if (index == state_index)
+ elm_radio_value_set(radio, state_index);
+
+ evas_object_size_hint_weight_set(radio, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(radio, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+ return radio;
+ }
+
+ return NULL;
+}
+
+static Eina_Bool _gl_radio_state_get(void *data, Evas_Object *obj, const char *part)
+{
+ return EINA_FALSE;
+}
+
+static void _gl_radio_sel(void *data, Evas_Object *obj, void *event_info)
+{
+ Elm_Object_Item *item = (Elm_Object_Item *) event_info;
+ int result = -1;
+ int index = 0;
+
+ if (item)
+ {
+ index = (int) elm_object_item_data_get(item);
+
+ LOGD("[Genlist] Selected Text : %s\n", predefined_item_list[index]);
+
+ state_index = index;
+ result = vconf_set_str(VCONFKEY_NFC_PREDEFINED_ITEM, predefined_item_list[index]);
+ if (!result )
+ {
+ LOGD("[%s(): %d] vconf_set_str success\n", __FUNCTION__, __LINE__);
+ }
+ else
+ {
+ LOGD("[%s(): %d] vconf_set_str failed\n", __FUNCTION__, __LINE__);
+ }
+
+ elm_genlist_item_update(item);
+ }
+}
+
+static Evas_Object *_ug_nfc_create_predefined_item_layout(void *data)
+{
+ LOGD("[%s(): %d] BEGIN >>>>", __FUNCTION__, __LINE__);
+
+ ugdata_t *ug_data = (ugdata_t *)data;
+ Evas_Object *layout = NULL;
+ Evas_Object *genlist = NULL;
+ FILE *fp = NULL;
+ int index = 0;
+ char buf[1024] = { 0 , };
+
+ layout = elm_layout_add(ug_data->base_naviframe);
+ if (layout == NULL)
+ {
+ LOGD("[%s(): %d] layout is null", __FUNCTION__, __LINE__);
+ return NULL;
+ }
+ elm_layout_theme_set(layout, "layout", "application", "noindicator");
+ evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_show(layout);
+
+ /* make a list */
+ genlist = elm_genlist_add(layout);
+ if (genlist == NULL)
+ {
+ LOGD("[%s(): %d] genlist is null", __FUNCTION__, __LINE__);
+ return NULL;
+ }
+
+ if (!radio_main)
+ {
+ radio_main = elm_radio_add(genlist);
+ elm_radio_state_value_set(radio_main, 0);
+ elm_radio_value_set(radio_main, 0);
+ }
+
+ itc_radio.item_style = "1text.1icon.2";
+ itc_radio.func.text_get = _gl_radio_text_get;
+ itc_radio.func.content_get = _gl_radio_content_get;
+ itc_radio.func.state_get = _gl_radio_state_get;
+ itc_radio.func.del = NULL;
+
+ /* file open to make a list */
+ if ((fp = fopen(PREDEFINED_ITEM_FILE_PATH, "r")) == NULL)
+ {
+ LOGD("file open error");
+ return NULL;
+ }
+
+ if (fscanf(fp, "%d", &predefined_item_count))
+ {
+ LOGD("count [%d]", predefined_item_count);
+ }
+
+ if ((predefined_item_count < 0) || (predefined_item_count > MAX_PREDEFINED_ITEM_COUNT))
+ {
+ LOGD("The value of item_count is wrong");
+ fclose(fp);
+ return NULL;
+ }
+
+ predefined_item_count++; /* for none menu */
+
+ predefined_item_list = malloc(sizeof(char *) * predefined_item_count);
+
+ for (index = 0; index < predefined_item_count; index++) {
+ if (index == 0)
+ {
+ LOGD("first item");
+
+ predefined_item_list[index] = strdup(IDS_NONE);
+ elm_genlist_item_append(genlist, &itc_radio, (void *)index, NULL, ELM_GENLIST_ITEM_NONE, _gl_radio_sel, NULL);
+ }
+ else
+ {
+ if (fscanf(fp, "%s", buf))
+ {
+ LOGD("buf [%s]", buf);
+ predefined_item_list[index] = strdup(buf);
+
+ elm_genlist_item_append(genlist, &itc_radio, (void *)index, NULL, ELM_GENLIST_ITEM_NONE, _gl_radio_sel, NULL);
+ }
+ }
+ }
+
+ evas_object_show(genlist);
+ elm_object_part_content_set(layout, "elm.swallow.content", genlist);
+
+ fclose(fp);
+
+ LOGD("[%s(): %d] END <<<<", __FUNCTION__, __LINE__);
+
+ return layout;
+}
+
+static void _back_clicked_cb_from_predefined_item(void *data, Evas_Object *obj, void *event_info)
+{
+ LOGD("[%s(): %d] BEGIN >>>>", __FUNCTION__, __LINE__);
+
+ ugdata_t *ug_data = data;
+ int index;
+
+ elm_naviframe_item_pop(ug_data->base_naviframe);
+
+ for (index = 0; index < predefined_item_count; index++)
+ {
+ free(predefined_item_list[index]);
+ }
+ free(predefined_item_list);
+
+ predefined_item_count = 0;
+
+ if (radio_main)
+ {
+ evas_object_del(radio_main);
+ radio_main = NULL;
+ }
+
+ LOGD("[%s(): %d] END <<<<", __FUNCTION__, __LINE__);
+}
+
// get the state of item
static Eina_Bool _gl_state_get(void *data, Evas_Object *obj, const char *part)
{
@@ -524,6 +764,18 @@ static Eina_Bool _gl_state_get(void *data, Evas_Object *obj, const char *part)
}
}
#endif
+ else if (item_data->type == NFC_PREDEFINED_ITEM)
+ {
+ char *selected_item = NULL;
+
+ selected_item = vconf_get_str(VCONFKEY_NFC_PREDEFINED_ITEM);
+
+ if (strcmp(selected_item, "None"))
+ {
+ LOGD("[%s(): %d] vconf_get_str=> is not None", __FUNCTION__, __LINE__);
+ result = EINA_TRUE;
+ }
+ }
else
{
LOGD("[%s(): %d] item_data->type error", __FUNCTION__, __LINE__);
@@ -548,6 +800,8 @@ static void _gl_del(void *data, Evas_Object *obj)
static void _gl_sel_activation(void *data, Evas_Object *obj, void *event_info)
{
+ LOGD("[%s(): %d] BEGIN >>>>", __FUNCTION__, __LINE__);
+
Elm_Object_Item *item = (Elm_Object_Item *)event_info;
gl_item_data *item_data = (gl_item_data *)data;
@@ -561,15 +815,13 @@ static void _gl_sel_activation(void *data, Evas_Object *obj, void *event_info)
if (item_data->type == NFC_ON_OFF)
{
- LOGD("[%s(): %d] BEGIN >>>>", __FUNCTION__, __LINE__);
-
if (_get_pending_status())
{
LOGD("[%s(): %d] pending status \n", __FUNCTION__, __LINE__);
return;
}
- _change_nfc_onoff_setting();
+ _change_nfc_onoff_setting(item_data->data);
elm_genlist_item_update(item);
}
@@ -581,6 +833,26 @@ static void _gl_sel_activation(void *data, Evas_Object *obj, void *event_info)
elm_genlist_item_update(item);
}
#endif
+ else if (item_data->type == NFC_PREDEFINED_ITEM)
+ {
+ Evas_Object *predefined_item_layout = NULL;
+ Evas_Object *l_button = NULL;
+ ugdata_t *ug_data = item_data->data;
+
+ LOGD("[%s(): %d] NFC_PREDEFINED_ITEM", __FUNCTION__, __LINE__);
+
+ /* create setting view */
+ predefined_item_layout = _ug_nfc_create_predefined_item_layout(ug_data);
+ if (predefined_item_layout == NULL)
+ return;
+
+ /* Push navifreme */
+ l_button = elm_button_add(ug_data->base_naviframe);
+ elm_object_style_set(l_button, "naviframe/back_btn/default");
+ evas_object_smart_callback_add(l_button, "clicked", _back_clicked_cb_from_predefined_item, ug_data);
+
+ ug_data->base_navi_it = elm_naviframe_item_push(ug_data->base_naviframe, IDS_PREDEFINED_ITEM, l_button, NULL, predefined_item_layout, NULL);
+ }
else
{
LOGD("[%s(): %d] item_data->type error", __FUNCTION__, __LINE__);
@@ -609,7 +881,7 @@ static void _check_changed_cb(void *data, Evas_Object *obj, void *event_info)
return;
}
- _change_nfc_onoff_setting();
+ _change_nfc_onoff_setting(item_data->data);
if (on_off_item != NULL)
elm_genlist_item_update(on_off_item);
@@ -705,6 +977,10 @@ static Evas_Object *_gl_content_get(void *data, Evas_Object *obj, const char *pa
elm_object_style_set(content, "on&off");
}
#endif
+ else if (item_data->type == NFC_PREDEFINED_ITEM)
+ {
+ LOGD("[%s(): %d] NFC_PREDEFINED_ITEM ", __FUNCTION__, __LINE__);
+ }
else
{
LOGD("[%s(): %d] item_data->type error", __FUNCTION__, __LINE__);
@@ -722,6 +998,9 @@ static char *_gl_text_get_onoff(void *data, Evas_Object *obj, const char *part)
gl_item_data *item_data = (gl_item_data *)data;
char *text = NULL;
+ LOGD("part:%s", part);
+
+ // label for 'elm.text' part
if (item_data == NULL)
{
LOGD("[%s(): %d] item_data is null", __FUNCTION__, __LINE__);
@@ -738,6 +1017,18 @@ static char *_gl_text_get_onoff(void *data, Evas_Object *obj, const char *part)
text = strdup(IDS_NFC_S_BEAM);
}
#endif
+ else if (item_data->type == NFC_PREDEFINED_ITEM)
+ {
+ if (!strcmp(part, "elm.text.1"))
+ {
+ text = strdup(IDS_PREDEFINED_ITEM);
+ }
+ else
+ {
+ text = vconf_get_str(VCONFKEY_NFC_PREDEFINED_ITEM);
+ LOGD("[%s]", text);
+ }
+ }
else
{
LOGD("[%s(): %d] type error", __FUNCTION__, __LINE__);
@@ -748,18 +1039,49 @@ static char *_gl_text_get_onoff(void *data, Evas_Object *obj, const char *part)
return text;
}
+static char *_gl_text_get_help(void *data, Evas_Object *obj, const char *part)
+{
+ LOGD("[%s(): %d] BEGIN >>>>", __FUNCTION__, __LINE__);
+
+ int index = (int) data;
+ char *text = NULL;
+
+ LOGD("index:%d", index);
+
+ if (index == 0)
+ {
+ text = strdup(IDS_NFC_S_BEAM_DESCRIPTION_MSG_CHN);
+
+ }
+ else if (index == 1)
+ {
+ text = strdup(IDS_PREDEFINED_ITEM_DESCRIPTION_MSG);
+ }
+
+ LOGD("[%s(): %d] END <<<<", __FUNCTION__, __LINE__);
+
+ return text;
+}
+
static Evas_Object *_ug_nfc_create_setting_layout(void *data)
{
- ugdata_t *ug_data = (ugdata_t *)data;
+ LOGD("[%s(): %d] BEGIN >>>>", __FUNCTION__, __LINE__);
+ ugdata_t *ug_data = (ugdata_t *)data;
Evas_Object *layout = NULL;
Evas_Object *genlist = NULL;
+ int result = 0;
+ int on = 0;
- /* edj is set to layout */
+ /* Add layout*/
layout = elm_layout_add(ug_data->base_naviframe);
- elm_layout_file_set(layout, EDJ_FILE, "nfc_setting");
+ if (layout == NULL)
+ {
+ LOGD("[%s(): %d] layout is null", __FUNCTION__, __LINE__);
+ return NULL;
+ }
+ elm_layout_theme_set(layout, "layout", "application", "noindicator");
evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(layout);
/* make genlist */
@@ -769,64 +1091,72 @@ static Evas_Object *_ug_nfc_create_setting_layout(void *data)
LOGD("[%s(): %d] genlist is null", __FUNCTION__, __LINE__);
return NULL;
}
- elm_genlist_bounce_set(genlist, EINA_FALSE, EINA_FALSE);
- elm_object_style_set(genlist, "dialogue");
+ elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
- itc_seperator.item_style = "dialogue/separator";
- itc_seperator.func.text_get = NULL;
- itc_seperator.func.content_get = NULL;
- itc_seperator.func.state_get = NULL;
- itc_seperator.func.del = NULL;
+ itc_check.item_style = "dialogue/1text.1icon";
+ itc_check.func.text_get = _gl_text_get_onoff;
+ itc_check.func.content_get = _gl_content_get;
+ itc_check.func.state_get = _gl_state_get;
+ itc_check.func.del = _gl_del;
- itc.item_style = "dialogue/1text.1icon";
- itc.func.text_get = _gl_text_get_onoff;
- itc.func.content_get = _gl_content_get;
- itc.func.state_get = _gl_state_get;
- itc.func.del = NULL;
+ itc_helptext.item_style = "multiline/1text";
+ itc_helptext.func.text_get = _gl_text_get_help;
+ itc_helptext.func.content_get = NULL;
+ itc_helptext.func.state_get = NULL;
+ itc_helptext.func.del = NULL;
- /* seperator */
- Elm_Object_Item* seperator1 = elm_genlist_item_append(genlist, &itc_seperator, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
- elm_genlist_item_select_mode_set(seperator1, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+ itc_2text.item_style = "dialogue/2text.3";
+ itc_2text.func.text_get = _gl_text_get_onoff;
+ itc_2text.func.content_get = _gl_content_get;
+ itc_2text.func.state_get = _gl_state_get;
+ itc_2text.func.del = _gl_del;
- /* NFC setting */
+
+ /* 1. NFC setting */
gl_item_data *on_off_data = NULL;
on_off_data = malloc(sizeof(gl_item_data));
on_off_data->type = NFC_ON_OFF;
on_off_data->data = ug_data;
- on_off_item = elm_genlist_item_append(genlist, &itc, (void *)on_off_data, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel_activation, (void *)on_off_data);
+ on_off_item = elm_genlist_item_append(genlist, &itc_check, (void *)on_off_data, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel_activation, (void *)on_off_data);
#ifdef _SBEAM_SUPPORT_
- /* S beam setting */
+ /* 2. S beam setting */
gl_item_data *sbeam_data = NULL;
sbeam_data = malloc(sizeof(gl_item_data));
sbeam_data->type = NFC_S_BEAM;
sbeam_data->data = ug_data;
- sbeam_item = elm_genlist_item_append(genlist, &itc, (void *)sbeam_data, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel_activation, (void *)sbeam_data);
+ sbeam_item = elm_genlist_item_append(genlist, &itc_check, (void *)sbeam_data, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel_activation, (void *)sbeam_data);
+
+ /* 2. S beam setting Help Text */
+ sbeam_item_help = elm_genlist_item_append(genlist, &itc_helptext, (void *)0, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel_activation, NULL);
- /* S beam setting */
- int result = 0;
- int on = 0;
if (((result = vconf_get_bool(VCONFKEY_NFC_STATE, &on)) == 0) && (on == 0))
{
elm_object_item_disabled_set(sbeam_item, TRUE);
+ elm_object_item_disabled_set(sbeam_item_help, TRUE);
}
#endif
+ /* 3. Predefined item setting */
+ gl_item_data *predefined_item_data = NULL;
+ predefined_item_data = malloc(sizeof(gl_item_data));
+ predefined_item_data->type = NFC_PREDEFINED_ITEM;
+ predefined_item_data->data = ug_data;
+ predefined_item = elm_genlist_item_append(genlist, &itc_2text, (void *)predefined_item_data, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel_activation, (void *)predefined_item_data);
+
+ /* 3. Predefined item setting Help Text*/
+ predefined_item_help = elm_genlist_item_append(genlist, &itc_helptext, (void *)1, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel_activation, NULL);
+
+ if (((result = vconf_get_bool(VCONFKEY_NFC_STATE, &on)) == 0) && (on == 0))
+ {
+ elm_object_item_disabled_set(predefined_item, TRUE);
+ elm_object_item_disabled_set(predefined_item_help, TRUE);
+ }
+
evas_object_show(genlist);
- elm_object_part_content_set(layout, "setting_list", genlist);
+ elm_object_part_content_set(layout, "elm.swallow.content", genlist);
-#ifdef _SBEAM_SUPPORT_
- /* set help text */
- char path[1024] = { 0, };
- Evas_Object *label = NULL;
-
- _get_label_text(UG_FONT_HELP, IDS_NFC_S_BEAM_DESCRIPTION_MSG_CHN, UG_ALIGN_LEFT, path, sizeof(path));
- label = elm_label_add(layout);
- elm_object_part_content_set(layout, "sbeam_help", label);
- elm_label_wrap_width_set(label, S_BEAM_DESCRIPTION_MSG_WRAP_WIDTH);
- elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
- elm_object_text_set(label, path);
-#endif
+ LOGD("[%s(): %d] END <<<<", __FUNCTION__, __LINE__);
return layout;
}
@@ -842,19 +1172,21 @@ static void _back_clicked_cb(void *data, Evas_Object *obj, void *event_info)
static void *__ug_nfc_setting_create(ui_gadget_h ug, enum ug_mode mode, service_h service, void *priv)
{
+ LOGD("[%s(): %d] BEGIN >>>>", __FUNCTION__, __LINE__);
+
ugdata_t *ug_data = (ugdata_t *)priv;
Evas_Object *parent = NULL;
Evas_Object *nfc_setting_layout = NULL;
Evas_Object *l_button = NULL;
- parent = ug_get_parent_layout(ug);
- if (!parent)
- return NULL;
-
/* set text domain */
bindtextdomain(NFCUG_TEXT_DOMAIN, NFCUG_LOCALEDIR);
+ parent = ug_get_parent_layout(ug);
+ if (!parent)
+ return NULL;
ug_data->ug_win_main = parent;
+ evas_object_show(ug_data->ug_win_main);
ug_data->nfc_setting_ug = ug;
ug_data->base_layout = _create_main_layout(ug_data->ug_win_main);
@@ -863,8 +1195,6 @@ static void *__ug_nfc_setting_create(ui_gadget_h ug, enum ug_mode mode, service_
ug_data->base_naviframe = elm_naviframe_add(ug_data->base_layout);
elm_object_part_content_set(ug_data->base_layout, "elm.swallow.content", ug_data->base_naviframe);
-
- evas_object_show(ug_data->base_layout);
evas_object_show(ug_data->base_naviframe);
/* create setting view */
@@ -874,12 +1204,16 @@ static void *__ug_nfc_setting_create(ui_gadget_h ug, enum ug_mode mode, service_
/* Push navifreme */
l_button = elm_button_add(ug_data->base_naviframe);
- evas_object_smart_callback_add(l_button, "clicked", _back_clicked_cb, ug_data->nfc_setting_ug);
- ug_data->base_navi_it = elm_naviframe_item_push(ug_data->base_naviframe, IDS_NFC_NFC, l_button, NULL, nfc_setting_layout, "1line");
elm_object_style_set(l_button, "naviframe/back_btn/default");
+ evas_object_smart_callback_add(l_button, "clicked", _back_clicked_cb, ug_data->nfc_setting_ug);
+
+ ug_data->base_navi_it = elm_naviframe_item_push(ug_data->base_naviframe, IDS_NFC_NFC, l_button, NULL, nfc_setting_layout, NULL);
- /* Register Vconf Noti */
- vconf_notify_key_changed(VCONFKEY_NFC_STATE, _nfc_onoff_vconf_update_cb, NULL);
+ /* Register activation changed callback */
+ nfc_manager_initialize(NULL, NULL);
+ nfc_manager_set_activation_changed_cb(_nfc_activation_changed_cb, ug_data);
+
+ LOGD("[%s(): %d] END <<<<", __FUNCTION__, __LINE__);
return ug_data->base_layout;
}
@@ -888,17 +1222,10 @@ static void __ug_nfc_setting_destroy(ui_gadget_h ug, service_h service, void *pr
{
LOGD("[%s(): %d] BEGIN >>>>", __FUNCTION__, __LINE__);
ugdata_t *ug_data = (ugdata_t *)priv;
- int result;
if (ug_data == NULL)
return;
- /* Unregister Vconf Noti */
- if ((result = vconf_ignore_key_changed(VCONFKEY_NFC_STATE, _nfc_onoff_vconf_update_cb)) == 0)
- {
- LOGD("[%s(): %d] vconf_ignore_key_changed status \n", __FUNCTION__, __LINE__);
- }
-
nfc_manager_unset_activation_changed_cb();
nfc_manager_deinitialize();
diff --git a/ug-nfc-setting-efl/src/ug-nfc-setting-popup.c b/ug-nfc-setting-efl/src/ug-nfc-setting-popup.c
index cbec540..8e918de 100644
--- a/ug-nfc-setting-efl/src/ug-nfc-setting-popup.c
+++ b/ug-nfc-setting-efl/src/ug-nfc-setting-popup.c
@@ -129,7 +129,10 @@ Evas_Object *ug_nfc_setting_create_popup(void *data,
}
if (enable_timeout)
+ {
elm_popup_timeout_set(_popup, NFC_POPUP_AUTO_TIMEOUT_SEC);
+ evas_object_smart_callback_add(_popup, "timeout", _ug_nfc_setting_popup_response_cb, NULL);
+ }
_ug_nfc_setting_popup_show_cb(NULL);