So I'm trying to execute javascript code from native app (in C) and below is the function that keeps failing:
static Evas_Object* load_html_file(Evas_Object* parent)
{
Evas *e_webview = evas_object_evas_get(parent);
Evas_Object *browser = ewk_view_add(e_webview);
Ewk_Settings *settings = ewk_view_settings_get(browser);
ewk_settings_javascript_enabled_set(settings, EINA_TRUE);
char* javaScript =
"function setWallpaperSuccess() {}"
"function setWallpaperError() {}"
"function test() {"
"try"
" {"
" tizen.systemsetting.setProperty(\"HOME_SCREEN\", \"file:\/\/opt\/usr\/media\/Downloads\/2017-03-20_RiverofLife_1080x1920_no.jpg\", setWallpaperSuccess, setWallpaperError);"
" }"
" catch (error)"
" {"
" console.log(\"Error: \" + error); return 'exceptionhappened';"
" } return 'thisworkedorwhat';"
"}"
"test();";
ewk_view_script_execute(browser, javaScript, JScallback, NULL);
elm_win_resize_object_add(parent, browser);
evas_object_show(parent);
evas_object_show(browser);
return browser;
}
static void JScallback(Evas_Object* o, const char* result_value, void* user_data) {
dlog_print(DLOG_INFO, LOG_TAG, "[scriptCallback] return value: %s\n", result_value);
}
sdb dlog always prints:
I/ My-Experiment-App (31448): [scriptCallback] return value: exceptionhappened
And these are privileges declared for native app (TizenManifest file):
<privileges>
<privilege>http://tizen.org/privilege/mediastorage</privilege>
<privilege>http://tizen.org/privilege/network.get</privilege>
<privilege>http://tizen.org/privilege/systemsettings</privilege>
<privilege>http://tizen.org/privilege/internet</privilege>
<privilege>http://tizen.org/privilege/appmanager.launch</privilege>
<privilege>http://tizen.org/privilege/externalstorage</privilege>
</privileges>
Could anyone please help me know why is it failing?
Thanks a much and kind regards,
~Viren