Publishing oobe 1.0.1
authork.stepaniuk <k.stepaniuk@partner.samsung.com>
Mon, 25 Nov 2019 15:43:18 +0000 (16:43 +0100)
committerk.stepaniuk <k.stepaniuk@partner.samsung.com>
Mon, 25 Nov 2019 15:43:18 +0000 (16:43 +0100)
Signed-off-by: k.stepaniuk <k.stepaniuk@partner.samsung.com>
38 files changed:
.gitignore
build_all.sh
oobe-common/inc/alarm.h [new file with mode: 0644]
oobe-common/inc/http-get.h [new file with mode: 0644]
oobe-common/inc/oobe-common.h
oobe-common/inc/oobe.h [new file with mode: 0644]
oobe-common/inc/terms.h [new file with mode: 0644]
oobe-common/inc/terms_data.h [new file with mode: 0644]
oobe-common/project_def.prop
oobe-common/src/alarm.c [new file with mode: 0644]
oobe-common/src/http-get.c [new file with mode: 0644]
oobe-common/src/oobe.c [new file with mode: 0644]
oobe-common/src/terms.c [new file with mode: 0644]
oobe-common/src/terms_data.c [new file with mode: 0644]
oobe-common/src/utils_view.c
oobe-country/project_def.prop
oobe-easy-setup/.cproject
oobe-easy-setup/build_def.prop [new file with mode: 0644]
oobe-easy-setup/project_def.prop
oobe-easy-setup/src/OobeEasySetupApp.cpp
oobe-language/project_def.prop
oobe-setup/inc/oobe-setup.h
oobe-setup/project_def.prop
oobe-setup/res/po/en_US.po [new file with mode: 0644]
oobe-setup/res/po/pl_PL.po [new file with mode: 0644]
oobe-setup/src/done.c
oobe-setup/src/oobe-setup.c
oobe-setup/src/view.c
oobe-setup/tizen-manifest.xml
oobe-terms-service/project_def.prop
oobe-terms/.project
oobe-terms/project_def.prop
oobe-terms/res/data/initial_terms.json
oobe-terms/res/data/terms_server_url [new file with mode: 0644]
oobe-terms/src/oobe-terms.c
oobe-terms/src/view.c
oobe-wifi/project_def.prop
sam_cli.cfg

index dd661c1fd72451a97fae82090991eb4bf9dd7a57..8b2927a6bc573279c2130de901a3c8e0fca446fd 100644 (file)
@@ -10,5 +10,6 @@ SA_Report/
 .log/
 .scap/
 .scra-ir/
+.svace-dir/
 output/
 Build/
index 44e60241524d99710d9f6e1b1d48b5b6f73a3bc2..f9f845d81f7dfc0d7c2891387c3f4ef7407bd941 100644 (file)
@@ -1,22 +1,17 @@
 #!/bin/bash
+set -o errexit
+trap 'echo "Aborting due to errexit on line $LINENO. Exit code: $?" >&2' ERR
+set -o errtrace
+set -e -o pipefail
 
 ARCH=arm
 ROOTSTRAP=iot-headed-5.0-device.core
 ROOTSTRAP_PRIVATE=mobile-5.0-device.core.private
 REL=Debug
 
-exit_on_error()
-{
-       if [ $1 != 0 ]; then
-               echo $2
-               exit 1
-       fi
-}
-
 require_command()
 {
-       command -v $1 &> /dev/null
-       if [ $? != 0 ]; then
+       if [ ! "$(command -v "$1")" ]; then
                echo "Command not found: '$1', please install and add executable to your PATH"
                exit 1
        fi
@@ -24,42 +19,41 @@ require_command()
 
 clean()
 {
-       cd $1
+       cd "$1"
        tizen clean
        cd -
 }
 
 build()
 {
-       exit_on_error $?
-       tizen build-native -C "$REL" -a "$ARCH" -r "$ROOTSTRAP" -- $1
-       exit_on_error $?
+       tizen build-native -C "$REL" -a "$ARCH" -r "$ROOTSTRAP" -- "$1"
 }
 
 build_private()
 {
-       exit_on_error $?
-       tizen build-native -C "$REL" -a "$ARCH" -r "$ROOTSTRAP_PRIVATE" -- $1
-       exit_on_error $?
+       tizen build-native -C "$REL" -a "$ARCH" -r "$ROOTSTRAP_PRIVATE" -- "$1"
 }
 
 package()
 {
-       tizen package -t tpk -- $1/$REL
-       exit_on_error $?
+       tizen package -t tpk -- "$1/$REL"
 }
 
 require_command tizen
-
+clean oobe-common
 clean oobe-language
 clean oobe-country
 clean oobe-terms
 clean oobe-wifi
 clean oobe-setup
+clean oobe-terms-service
+clean oobe-easy-setup
 
+build_private oobe-common
 build_private oobe-language
 build_private oobe-country
-build_private oobe-easy-setup
 build_private oobe-terms
 build_private oobe-wifi
 build_private oobe-setup
+build_private oobe-terms-service
+build_private oobe-easy-setup
diff --git a/oobe-common/inc/alarm.h b/oobe-common/inc/alarm.h
new file mode 100644 (file)
index 0000000..38657b1
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __ALARM_H__
+#define __ALARM_H__
+
+void alarm_schedule(int period_seconds, const char* app_id, const char* extra_data);
+
+#endif /* __ALARM_H__ */
diff --git a/oobe-common/inc/http-get.h b/oobe-common/inc/http-get.h
new file mode 100644 (file)
index 0000000..4b65ac9
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __HTTP_GET_H__
+#define __HTTP_GET_H__
+#include <stdbool.h>
+
+int http_get_text(const char *url, char **response);
+
+#endif /* __HTTP_GET_H__ */
index f629a297c25f3da1d686f5c7e30e5435fc1b919c..3cf946441a95a13b8482f21e023e876cba6b0e71 100644 (file)
 #ifndef __OOBE_COMMON_H__
 #define __OOBE_COMMON_H__
 
-#include "utils.h"
+#include "http-get.h"
+#include "log.h"
+#include "terms_data.h"
+#include "terms.h"
 #include "utils_view.h"
-#include <stdbool.h>
+#include "utils.h"
+
+#ifdef  LOG_TAG
+#undef  LOG_TAG
+#endif
+#define LOG_TAG "oobe-common"
 
 #ifdef __cplusplus
 extern "C" {
@@ -28,4 +36,4 @@ extern "C" {
 #ifdef __cplusplus
 }
 #endif
-#endif // __OOBE_COMMON_H__
\ No newline at end of file
+#endif // __OOBE_COMMON_H__
diff --git a/oobe-common/inc/oobe.h b/oobe-common/inc/oobe.h
new file mode 100644 (file)
index 0000000..fb110ee
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __OOBE_H__
+#define __OOBE_H__
+
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern C {
+#endif
+
+void oobe_set_done();
+bool oobe_get_done();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OOBE_H__ */
diff --git a/oobe-common/inc/terms.h b/oobe-common/inc/terms.h
new file mode 100644 (file)
index 0000000..d6ddca1
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __TERMS_H__
+#define __TERMS_H__
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern C {
+#endif
+
+// moved from oobe-terms
+bool terms_latest_exist(void);
+void terms_latest_init(void);
+
+bool terms_accept(int version);
+
+// common
+int terms_get_latest_version();
+
+// moved from oobe-terms-service
+void terms_read_server_url(void);
+
+int terms_get_accepted_version();
+int terms_get_pooling_interval();
+
+void terms_download_latest(int version);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __TERMS_H__ */
diff --git a/oobe-common/inc/terms_data.h b/oobe-common/inc/terms_data.h
new file mode 100644 (file)
index 0000000..1828e7d
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __TERMS_DATA_H__
+#define __TERMS_DATA_H__
+#include <stdbool.h>
+
+#define LATEST_TERMS_JSON_FILENAME "latest_terms.json"
+#define ACCEPTED_TERMS_JSON_FILENAME "accepted_terms.json"
+
+struct term {
+       const char *title;
+       bool is_required;
+       bool is_accepted;
+       const char *content;
+};
+
+struct terms_data {
+       int latest_version;
+       int check_interval;
+       const char *language;
+       const char *region;
+       int terms_count;
+       struct term *terms;
+};
+
+struct terms_data* terms_data_create_from_file(const char *file_name);
+struct terms_data* terms_data_create_from_text(const char *json);
+void terms_data_destroy(struct terms_data* terms);
+
+#endif /* __DATA_H__ */
index 3b01a8ed5da47d01780446c74ffc23ff95561a58..ac4b8bc0b1f646dc5ce8fb96d821ef3ed8d8234a 100644 (file)
@@ -3,7 +3,7 @@ APPNAME = oobe-common
 type = staticLib
 profile = iot-headed-5.0
 
-USER_SRCS = src/oobe-common.c
+USER_SRCS = src/*.c
 USER_DEFS =
 USER_INC_DIRS = inc
 USER_OBJS =
diff --git a/oobe-common/src/alarm.c b/oobe-common/src/alarm.c
new file mode 100644 (file)
index 0000000..b0da5e3
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "log.h"
+#include "oobe-common.h"
+#include <app_alarm.h>
+
+void alarm_schedule(int period_seconds, const char* app_id, const char* extra_data)
+{
+    struct tm date;
+       app_control_h app_control = NULL;
+       int alarm_id = -1;
+       
+       int ret = app_control_create(&app_control);
+       if (ret != ALARM_ERROR_NONE) {
+               LOGE("app_control_create [%d: %s]", ret, get_error_message(ret));
+               return;
+       }
+
+       ret = app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT);
+       if (ret != ALARM_ERROR_NONE) {
+               LOGE("app_control_set_operation [%d: %s]", ret, get_error_message(ret));
+               return;
+       }
+
+       ret = app_control_set_app_id(app_control, app_id);
+       if (ret != ALARM_ERROR_NONE) {
+               LOGE("app_control_set_app_id [%d: %s]", ret, get_error_message(ret));
+               return;
+       }
+
+       ret = alarm_get_current_time(&date);
+       date.tm_sec += period_seconds;
+       if (ret != ALARM_ERROR_NONE) {
+               LOGE("alarm_get_current_time [%d: %s]", ret, get_error_message(ret));
+               return;
+       }
+
+       ret = alarm_schedule_once_at_date(app_control, &date, &alarm_id);
+       if (ret != ALARM_ERROR_NONE) {
+               LOGE("alarm_schedule_once_at_date [%d: %s]", ret, get_error_message(ret));
+               return;
+       }
+
+       ret = alarm_get_scheduled_date(alarm_id, &date);
+       if (ret != ALARM_ERROR_NONE) {
+               LOGE("alarm_get_scheduled_date [%d: %s]", ret, get_error_message(ret));
+               return;
+       }
+
+       char datetime[100];
+       snprintf(datetime, 100, "%d.%d.%d@%d:%d:%d", (1900+date.tm_year), (1+date.tm_mon), date.tm_mday, date.tm_hour, date.tm_min, date.tm_sec);
+       LOGD("alarm scheduled alarm_id: %d, app_id: %s, date: %s (after %d sec)", alarm_id, app_id, datetime, period_seconds);
+}
diff --git a/oobe-common/src/http-get.c b/oobe-common/src/http-get.c
new file mode 100644 (file)
index 0000000..b722a28
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "http-get.h"
+#include "oobe-common.h"
+#include <log.h>
+#include <stdlib.h>
+#include <curl/curl.h>
+#include <json-glib/json-glib.h>
+
+#define HTTP_GET_TIMEOUT 7L
+
+struct MemoryStruct {
+       char *memory;
+       size_t size;
+};
+
+static size_t _write_cb(void *contents, size_t size, size_t nmemb, void *userp) {
+       size_t realsize = size * nmemb;
+       struct MemoryStruct *mem = (struct MemoryStruct *) userp;
+
+       char *ptr = realloc(mem->memory, mem->size + realsize + 1);
+       if (ptr == NULL) {
+               /* out of memory! */
+               LOGE("not enough memory (realloc returned NULL)\n");
+               return 0;
+       }
+
+       mem->memory = ptr;
+       memcpy(&(mem->memory[mem->size]), contents, realsize);
+       mem->size += realsize;
+       mem->memory[mem->size] = 0;
+
+       return realsize;
+}
+
+int http_get_text(const char *url, char **response) {
+       int result = -1;
+       *response = NULL;
+       CURL *curl;
+       curl_global_init(CURL_GLOBAL_DEFAULT);
+       curl = curl_easy_init();
+       if (curl) {
+               struct MemoryStruct chunk = { malloc(1), 0 };
+               curl_easy_setopt(curl, CURLOPT_URL, url);
+               curl_easy_setopt(curl, CURLOPT_TIMEOUT, HTTP_GET_TIMEOUT);
+               curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, _write_cb);
+               curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void * )&chunk);
+               CURLcode res = curl_easy_perform(curl);
+               if (res == CURLE_OK) {
+                       *response = chunk.memory;
+                       result = chunk.size;
+               } else {
+                       LOGE("curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
+                       free(chunk.memory);
+               }
+               curl_easy_cleanup(curl);
+       }
+       curl_global_cleanup();
+       if(*response==NULL)
+               LOGE("response is null");
+       return result;
+}
diff --git a/oobe-common/src/oobe.c b/oobe-common/src/oobe.c
new file mode 100644 (file)
index 0000000..d87dbe4
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "oobe.h"
+#include "log.h"
+#include "utils.h"
+#include <glib.h>
+
+#define OOBE_DONE_FILEPATH "oobe_done"
+
+void oobe_set_done()
+{
+       GError *error = NULL;
+       char filepath[PATH_MAX];
+       utils_get_app_data_path(OOBE_DONE_FILEPATH, filepath, PATH_MAX);
+
+       if (g_file_set_contents(filepath, "", 0, &error) == false) {
+               LOGE("could not create file [%s] error code: %d", error->code);
+               g_error_free(error);
+       }
+}
+
+bool oobe_get_done()
+{
+       char filepath[PATH_MAX];
+       utils_get_app_data_path(OOBE_DONE_FILEPATH, filepath, PATH_MAX);
+
+       return g_file_test(filepath, G_FILE_TEST_EXISTS);
+}
diff --git a/oobe-common/src/terms.c b/oobe-common/src/terms.c
new file mode 100644 (file)
index 0000000..965cc59
--- /dev/null
@@ -0,0 +1,202 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "terms.h"
+#include "oobe-common.h"
+#include "log.h"
+#include <stdlib.h>
+#include <json-glib/json-glib.h>
+#include <stdio.h>
+#include "utils.h"
+#include "terms_data.h"
+#include "http-get.h"
+#define LOG_TAG "oobe-setup"
+
+// moved from oobe-terms -----
+#define TERMS_INITIAL_PATH "data/initial_terms.json"
+
+bool terms_latest_exist() {
+       bool terms_exist = false;
+       static char file[PATH_MAX] = {0,};
+       if(file[0] == 0) {
+               utils_get_app_data_path(LATEST_TERMS_JSON_FILENAME, file, PATH_MAX);
+       }
+
+       struct terms_data* terms = terms_data_create_from_file(file);
+       if (terms != NULL) {
+               terms_data_destroy(terms);
+               terms_exist = true;
+       }
+       return terms_exist;
+}
+
+void terms_latest_init() {
+       char source[PATH_MAX];
+       utils_get_app_resource_path(TERMS_INITIAL_PATH, source, PATH_MAX);
+       char destination[PATH_MAX];
+       utils_get_app_data_path(LATEST_TERMS_JSON_FILENAME, destination, PATH_MAX);
+
+       if (utils_copy_file(source, destination)) {
+               LOGD("Copied initial terms successfully");
+       } else {
+               LOGW("Could not copy initial terms.");
+       }
+}
+
+static int _get_version(const char* file) {
+       int result = -1;
+       struct terms_data* terms = terms_data_create_from_file(file);
+       if (terms != NULL) {
+               result = terms->latest_version;
+               terms_data_destroy(terms);
+       } else {
+               LOGW("cannot get version from [%s]", file);
+       }
+       return result;
+}
+
+static int _terms_get_accepted_version() {
+       static char file[PATH_MAX] = {0,};
+       if(file[0] == 0)
+               utils_get_app_data_path(ACCEPTED_TERMS_JSON_FILENAME, file, PATH_MAX);
+       return _get_version(file);
+}
+
+int terms_get_latest_version() {
+       static char file[PATH_MAX] = {0,};
+       if(file[0] == 0)
+               utils_get_app_data_path(LATEST_TERMS_JSON_FILENAME, file, PATH_MAX);
+       return _get_version(file);
+}
+
+bool terms_accept(int version) {
+       bool result = false;
+       int latest_version = terms_get_latest_version();
+       int accepted_version = _terms_get_accepted_version();
+
+       if(version == latest_version && accepted_version <= latest_version) {
+               char accepted[PATH_MAX];
+               utils_get_app_data_path(ACCEPTED_TERMS_JSON_FILENAME, accepted, PATH_MAX);
+               char latest[PATH_MAX];
+               utils_get_app_data_path(LATEST_TERMS_JSON_FILENAME, latest, PATH_MAX);
+
+               result = utils_copy_file(latest, accepted);
+       }
+
+       LOGD("accept terms version %d [%s]", version, result ? "success" : "failed");
+       return result;
+}
+
+// moved from oobe-terms-service ----------------------------------------------
+#define DEFAULT_POOLING_INTERVAL 10
+#define REST_API_QUERY_ARGS "?current_version=%d"
+#define REST_API_URL_PATH "data/terms_server_url"
+
+static char* rest_api_url = NULL;
+
+void terms_read_server_url(void) {
+       if(rest_api_url == NULL) {
+               gsize size;
+               GError *error = NULL;
+               static char path[PATH_MAX];
+               utils_get_app_resource_path(REST_API_URL_PATH, path, PATH_MAX);
+               if (g_file_get_contents(path, &rest_api_url, &size, &error) == false) {
+                       LOGW("cannot read terms server url from [%s]", path);
+                       g_error_free(error);
+               }
+       }
+}
+
+int terms_get_accepted_version() {
+       static char file[PATH_MAX] = {0,};
+       if(file[0] == 0)
+               utils_get_app_data_path(ACCEPTED_TERMS_JSON_FILENAME, file, PATH_MAX);
+       return _get_version(file);
+}
+
+int terms_get_pooling_interval() {
+       int result = DEFAULT_POOLING_INTERVAL;
+       static char file[PATH_MAX] = {0,};
+       if(file[0] == 0) {
+               utils_get_app_data_path(LATEST_TERMS_JSON_FILENAME, file, PATH_MAX);
+       }
+
+       struct terms_data* terms = terms_data_create_from_file(file);
+       if (terms != NULL) {
+               result = terms->check_interval;
+               terms_data_destroy(terms);
+       } else {
+               LOGW("default pooling interval [%d] cannot read from [%s]", result, file);
+       }
+       return result;
+}
+
+static int _terms_download(const char* url, char **response, int *total_time_msec)
+{
+       gint64 download_start_time, download_end_time;
+
+       download_start_time = g_get_monotonic_time();
+       int status = http_get_text(url, response);
+       download_end_time = g_get_monotonic_time();
+
+       if (total_time_msec != NULL)
+               *total_time_msec = (download_end_time - download_start_time) / 1000;
+
+       return status;
+}
+
+void terms_download_latest(int version) {
+       static char url[PATH_MAX] = {0,};
+       if(url[0] == 0) {
+               terms_read_server_url();
+               snprintf(url, PATH_MAX, "%s"REST_API_QUERY_ARGS, rest_api_url, version);
+       }
+       static char file[PATH_MAX] = {0,};
+       if(file[0] == 0) {
+               utils_get_app_data_path(LATEST_TERMS_JSON_FILENAME, file, PATH_MAX);
+       }
+       LOGD("terms download started [%s]", url);
+
+       char *http_response;
+       int total_time_msec = -1;
+       int http_result = _terms_download(url, &http_response, &total_time_msec);
+
+       if (http_result > -1)
+       {
+               LOGD("terms download success [%d msec]", total_time_msec);
+
+               struct terms_data* terms = terms_data_create_from_text(http_response);
+               if (terms == NULL)
+               {
+                       LOGW("invalid terms");
+               } else {
+                       LOGD("terms downloaded version: %d, terms count: %d", terms->latest_version, terms->terms_count);
+                       bool new_terms = terms->latest_version > version && terms->terms_count > 0;
+                       if (new_terms) {
+                               if (utils_save_to_file(file, http_response)) {
+                                       LOGD("new terms saved to file");
+                               } else {
+                                       LOGW("new terms not saved to file");
+                               }
+                       }
+                       terms_data_destroy(terms);
+               }
+       } else {
+               LOGW("terms download failed [%d msec]", total_time_msec);
+       }
+
+       free(http_response);
+}
diff --git a/oobe-common/src/terms_data.c b/oobe-common/src/terms_data.c
new file mode 100644 (file)
index 0000000..c727f03
--- /dev/null
@@ -0,0 +1,198 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "terms_data.h"
+#include "oobe-common.h"
+#include "log.h"
+#include <json-glib/json-glib.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <strings.h>
+#include <system_settings.h>
+#include <stdbool.h>
+
+static char* locale = NULL;
+
+static void _update_current_locale();
+static struct terms_data* _deserialize_terms_data(JsonNode *root);
+static void _on_deserialize_terms(JsonArray *array, guint index, JsonNode *element, gpointer user_data);
+static JsonNode *_parse_json_string(JsonParser *parser, const char *json);
+
+struct terms_data* terms_data_create_from_file(const char *file_name) {
+       struct terms_data* result = NULL;
+       char *json = NULL;
+       gsize size;
+       GError *error = NULL;
+
+       if (g_file_test(file_name, G_FILE_TEST_EXISTS)) {
+               if (g_file_get_contents(file_name, &json, &size, &error)) {
+                       result = terms_data_create_from_text(json);
+                       free(json);
+               } else {
+                       LOGE("cannot read file [%s] error code: %d", file_name, error->code);
+                       g_error_free(error);
+               }
+       } else {
+               LOGE("File does not exist (%s).", file_name);
+       }
+
+       return result;
+}
+
+struct terms_data* terms_data_create_from_text(const char *json) {
+       struct terms_data* result = NULL;
+       JsonParser *parser = json_parser_new();
+       JsonNode *root = _parse_json_string(parser, json);
+       JsonArray *root_array = json_node_get_array(root);
+       if (root_array == NULL) {
+               result = _deserialize_terms_data(root);
+       } else {
+               _update_current_locale();
+               json_array_foreach_element(root_array, _on_deserialize_terms, &result);
+               if(result == NULL) {
+                       LOGD("There is no desired language avaliable. Trying to get the first one");
+                       result = _deserialize_terms_data(json_array_get_element(root_array, 0));
+               }
+       }
+       g_object_unref(parser);
+       return result;
+}
+
+void terms_data_destroy(struct terms_data* terms) {
+       if (terms != NULL) {
+               if (terms->region != NULL)
+                       free((void*) terms->region);
+               if (terms->language != NULL)
+                       free((void*) terms->language);
+               if (terms->terms != NULL) {
+                       for (int i = 0; i < terms->terms_count; i++) {
+                               if (terms->terms[i].title != NULL)
+                                       free((void*) terms->terms[i].title);
+                               if (terms->terms[i].content != NULL)
+                                       free((void*) terms->terms[i].content);
+                       }
+                       free(terms->terms);
+               }
+               free(terms);
+       }
+}
+
+static JsonNode *_parse_json_string(JsonParser *parser, const char *json) {
+       GError *err = NULL;
+       if (!json_parser_load_from_data(parser, json, -1, &err)) {
+               LOGE("Function \"json_parser_load_from_data()\" failed with message: %s",
+                               err->message);
+               g_error_free(err);
+               return NULL;
+       }
+       return json_parser_get_root(parser);
+}
+
+static const char *_get_string_by_key(JsonObject *entry, const char *key) {
+       char *result = NULL;
+       if (json_object_has_member(entry, key)) {
+               const char *json_string = (const char *) json_object_get_string_member(
+                               entry, key);
+               int length = 1 + strlen(json_string);
+               result = malloc(length);
+               strncpy(result, json_string, length);
+       } else {
+               LOGD("json has no member: %s", key);
+       }
+       return result;
+}
+
+static bool _get_boolean_by_key(JsonObject *entry, const char *key) {
+       if (json_object_has_member(entry, key))
+               return json_object_get_boolean_member(entry, key);
+       else
+               return FALSE;
+}
+
+static void _on_deserialize_term_detail(JsonArray *array, guint index,
+               JsonNode *element, gpointer user_data) {
+       struct term *details = (struct term *) user_data;
+       JsonObject *entry = json_node_get_object(element);
+
+       details[index].is_required = _get_boolean_by_key(entry, "is_required");
+       details[index].title = _get_string_by_key(entry, "title");
+       details[index].content = _get_string_by_key(entry, "content");
+
+       details[index].is_accepted = false;
+}
+
+static void _deserialize_terms_details(JsonObject *entry, struct terms_data *result) {
+       JsonArray *json_array = json_object_get_array_member(entry, "terms");
+       if (json_array != NULL ) {
+               result->terms_count = json_array_get_length(json_array);
+               if(result->terms_count > 0) {
+                       result->terms = malloc(sizeof(struct term) * result->terms_count);
+                       json_array_foreach_element(json_array, _on_deserialize_term_detail,
+                                       result->terms);
+               } else {
+                       LOGE("json has no terms details");
+               }
+       } else {
+               LOGD("json has no terms details");
+               result->terms_count = 0;
+               result->terms = NULL;
+       }
+}
+
+struct terms_data* _deserialize_terms_data(JsonNode *root) {
+       struct terms_data* result = NULL;
+       JsonObject *entry = json_node_get_object(root);
+       if (entry != NULL ) {
+               if(json_object_has_member(entry, "latest_version")
+                       && json_object_has_member(entry, "check_interval")) {
+                       result = malloc(sizeof(struct terms_data));
+                       result->latest_version = json_object_get_int_member(entry, "latest_version");
+                       result->check_interval = json_object_get_int_member(entry, "check_interval");
+                       result->language = _get_string_by_key(entry, "language");
+                       result->region = _get_string_by_key(entry, "region");
+
+                       _deserialize_terms_details(entry, result);
+               } else {
+                       LOGE("Json has no latest_version or check_interval defined");   
+               }
+       }
+       else {
+               LOGE("Json has no data");
+       }
+       return result;
+}
+
+static void _on_deserialize_terms(JsonArray *array, guint index,
+               JsonNode *element, gpointer user_data) {
+       struct terms_data **terms_data = (struct terms_data **) user_data;
+       if(*terms_data==NULL && locale != NULL) {
+               const char *language = _get_string_by_key(json_node_get_object(element), "language");
+               if(language != NULL) {
+                       if(strcasecmp(language, locale)==0) {
+                               *terms_data = _deserialize_terms_data(element);
+                       }
+                       free((char*)language);
+               } else {
+                       LOGE("Cannot parse language or current locale not set. Json language: %s, locale: %s", language, locale);
+               }
+       }
+}
+
+static void _update_current_locale() {
+       free(locale);
+       system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale);
+       LOGD("current locale %s", locale);
+}
index f2d48911e7a463e256bae3a432ad5c38e80856a5..79655b0ce314d54251a26084bd17b9caa517bced 100644 (file)
@@ -15,6 +15,7 @@
  */
 
 #include "utils_view.h"
+#include "oobe-common.h"
 #include "utils.h"
 #include "log.h"
 #include <app.h>
@@ -30,6 +31,7 @@ Evas_Object *utils_view_create_win(const char *pkg_name)
        elm_win_indicator_mode_set(win, ELM_WIN_INDICATOR_SHOW);
        elm_win_indicator_opacity_set(win, ELM_WIN_INDICATOR_OPAQUE);
        elm_win_autodel_set(win, EINA_TRUE);
+       elm_win_layer_set(win, 6);
 
        evas_object_smart_callback_add(win, "delete,request", _delete_win_request_cb, NULL);
 
index d184bdb40c2c0d84ad248ed9ba395fe5fda72608..f01875d8cb21dbe7cc5c8fe57d83eb8348a09a82 100644 (file)
@@ -29,11 +29,11 @@ USER_CPP_UNDEFS =
 USER_LIBS = 
 
 # User Objects
-USER_OBJS = 
+USER_OBJS = ../oobe-common/Debug/liboobe-common.a
 
 # User Includes
 ## C Compiler
-USER_C_INC_DIRS = inc 
+USER_C_INC_DIRS = inc ../oobe-common/inc
 USER_INC_FILES = 
 ## C++ Compiler
 USER_CPP_INC_DIRS = 
index 4fec2a4a603cca6ae11b37f449aadf1a10d72192..0abad13328cbfde4b0022bf61679b23a9422f8a6 100644 (file)
                                                                        <listOptionValue builtIn="false" value="DEPRECATION_WARNING"/>
                                                                        <listOptionValue builtIn="false" value="_DEBUG"/>
                                                                </option>
-                                                               <option id="gnu.cpp.compiler.option.dialect.std.2027193221" name="Language standard" superClass="gnu.cpp.compiler.option.dialect.std" useByScannerDiscovery="true" value="gnu.cpp.compiler.dialect.c++1y" valueType="enumerated"/>
+                                                               <option id="gnu.cpp.compiler.option.dialect.std.2027193221" name="Language standard" superClass="gnu.cpp.compiler.option.dialect.std" useByScannerDiscovery="true" value="gnu.cpp.compiler.dialect.default" valueType="enumerated"/>
+                                                               <option id="gnu.cpp.compiler.option.dialect.flags.151802037" name="Other dialect flags" superClass="gnu.cpp.compiler.option.dialect.flags" useByScannerDiscovery="true" value="-std=c++14" valueType="string"/>
                                                                <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.402767253" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
                                                        </tool>
                                                        <tool command="clang" id="org.tizen.nativecore.tool.sbi.gnu.c.compiler.1141856070" name="C Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.c.compiler">
                                                                </option>
                                                                <option id="gnu.c.compiler.option.include.paths.1229709013" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="/home/k.wieclaw/workspace/chair-setup/oobe-easy-setup/inc/services/${SDK_ARCH}"/>
                                                                </option>
                                                                <option id="sbi.gnu.c.compiler.option.frameworks.core.1236930439" name="Tizen-Frameworks" superClass="sbi.gnu.c.compiler.option.frameworks.core" useByScannerDiscovery="false" valueType="userObjs">
                                                                        <listOptionValue builtIn="false" value="Native_API"/>
diff --git a/oobe-easy-setup/build_def.prop b/oobe-easy-setup/build_def.prop
new file mode 100644 (file)
index 0000000..6bb5e2f
--- /dev/null
@@ -0,0 +1,6 @@
+
+# Add pre/post build process
+PREBUILD_DESC = 
+PREBUILD_COMMAND = 
+POSTBUILD_DESC = 
+POSTBUILD_COMMAND = 
index 223ce48318c32d314bfd60813aa4d162abc2c525..c7d63ef31b2e33da8e1a802e39ef1c2571182676 100644 (file)
@@ -1,11 +1,63 @@
+
+# Project Name
 APPNAME = oobe-easy-setup
 
+# Project Type
 type = app
+
+# Project Profile
 profile = iot-headed-5.0
 
-USER_SRCS = src/**.cpp ses-cpp/src/**.cpp api-cpp/src/**.cpp
-USER_DEFS =
-USER_INC_DIRS = inc api-cpp/src ses-cpp/src
-USER_OBJS =
-USER_LIBS = st_thing_master_api samsung_account
-USER_EDCS = res/edje/*.edc
\ No newline at end of file
+# C/CPP Sources
+USER_SRCS = api-cpp/src/tizen/network/wifi/SpecificScan.cpp api-cpp/src/tizen/network/softap/Manager.cpp api-cpp/src/tizen/network/bluetooth/AdvertiserLE.cpp api-cpp/src/tizen/network/bluetooth/DeviceInfo.cpp ses-cpp/src/ses/smartthings/thing/SmartThingsThingExceptions.cpp api-cpp/src/tizen/network/softap/Client.cpp api-cpp/src/tizen/application/ServiceApp.cpp src/views/ViewPin.cpp api-cpp/src/tizen/application/UiApp.cpp src/views/ViewError.cpp api-cpp/src/tizen/ThreadUtils.cpp ses-cpp/src/ses/smartthings/thing/Master.cpp src/ViewManager.cpp src/views/ViewAutoConfiguration.cpp src/OobeEasySetupApp.cpp api-cpp/src/tizen/Logger.cpp src/views/ViewAdertisement.cpp api-cpp/src/tizen/application/Resource.cpp src/ViewEventAdapter.cpp api-cpp/src/tizen/network/wifi/Ap.cpp api-cpp/src/tizen/network/bluetooth/DiscoveryInfo.cpp api-cpp/src/tizen/peripheral/gpio/Pin.cpp api-cpp/src/tizen/network/bluetooth/Manager.cpp api-cpp/src/tizen/peripheral/spi/SpiException.cpp ses-cpp/src/ses/smartthings/thing/ApList.cpp ses-cpp/src/ses/smartthings/thing/CloudInfo.cpp src/TestUIViewEventAdapter.cpp src/views/ViewConnectedToSoftAP.cpp src/EasySetupEventAdapter.cpp ses-cpp/src/ses/smartthings/thing/ApInfo.cpp src/AppUtils.cpp api-cpp/src/tizen/application/AppException.cpp api-cpp/src/tizen/network/bluetooth/Adapter.cpp src/connectivity/TizenHomeAP.cpp src/StateManager.cpp api-cpp/src/tizen/network/wifi/Manager.cpp api-cpp/src/tizen/network/bluetooth/Exceptions.cpp api-cpp/src/tizen/network/wifi/Exception.cpp api-cpp/src/tizen/peripheral/gpio/GpioException.cpp api-cpp/src/tizen/timer/TimerException.cpp src/ViewEventObserver.cpp ses-cpp/src/ses/smartthings/thing/DeviceProvInfo.cpp api-cpp/src/tizen/application/AppControl.cpp api-cpp/src/tizen/key_manager/KeyManager.cpp src/views/ViewStart.cpp src/connectivity/TizenSoftAP.cpp api-cpp/src/tizen/Strings.cpp api-cpp/src/tizen/peripheral/spi/Spi.cpp src/OobeEasySetupMain.cpp src/EasySetup.cpp src/popups/PopupSkip.cpp api-cpp/src/tizen/timer/Timer.cpp 
+
+# EDC Sources
+USER_EDCS =  
+
+# PO Sources
+USER_POS = res/po/en_US.po res/po/pl_PL.po 
+
+# User Defines
+USER_DEFS = 
+USER_CPP_DEFS = TIZEN_DEPRECATION DEPRECATION_WARNING 
+
+# User Undefines
+USER_UNDEFS = 
+USER_CPP_UNDEFS = 
+
+# User Libraries
+USER_LIBS = st_thing_master_api 
+
+# User Objects
+USER_OBJS = 
+
+# User Includes
+## C Compiler
+USER_C_INC_DIRS = 
+USER_INC_FILES = 
+## C++ Compiler
+USER_CPP_INC_DIRS = inc api-cpp/src ses-cpp/src inc/services/arm 
+USER_CPP_INC_FILES = 
+
+USER_INC_DIRS = $(USER_C_INC_DIRS) $(USER_CPP_INC_DIRS)
+
+# User Library Path
+USER_LIB_DIRS = lib 
+
+# EDC Resource Path
+USER_EDCS_IMAGE_DIRS = ${OUTPUT_DIR} edje/images 
+USER_EDCS_SOUND_DIRS = ${OUTPUT_DIR} edje/sounds 
+USER_EDCS_FONT_DIRS = ${OUTPUT_DIR} edje/fonts 
+
+# EDC Flags
+USER_EXT_EDC_KEYS = EDC0 
+
+USER_EXT_EDC0_EDCS = res/edje/connected_to_softap.edc res/edje/pin.edc res/edje/advertisement.edc res/edje/error.edc res/edje/oobe_button.edc res/edje/start.edc res/edje/auto_configuration.edc 
+USER_EXT_EDC0_EDCS_IMAGE_DIRS = ${OUTPUT_DIR} edje/images 
+USER_EXT_EDC0_EDCS_SOUND_DIRS = ${OUTPUT_DIR} edje/sounds 
+USER_EXT_EDC0_EDCS_FONT_DIRS = ${OUTPUT_DIR} edje/fonts 
+
+# Resource Filter
+USER_RES_INCLUDE = 
+USER_RES_EXCLUDE = 
+
index 315bd106ea2175cf82ff2bfe2cb5163ae5bedd8f..07821c5abd147683cf6f2c4336be75ae3a40940e 100644 (file)
@@ -38,6 +38,7 @@ void OobeEasySetupApp::_createSkeleton()
        elm_win_conformant_set(_win, EINA_TRUE);
        elm_win_indicator_mode_set(_win, ELM_WIN_INDICATOR_HIDE);
        elm_win_autodel_set(_win, EINA_TRUE);
+       elm_win_layer_set(_win, 6);
 
        evas_object_smart_callback_add(_win, "delete,request", _win_delete_request_cb, NULL);
 
@@ -127,4 +128,4 @@ void OobeEasySetupApp::OnLanguageChanged(app_event_info_h event_info)
         elm_language_set(language);
         free(language);
     }
-}
\ No newline at end of file
+}
index 0463f7bb611a347ae93c4bcc50677c836db24286..d3dd61965f15d4a78850ec598914866695899432 100644 (file)
@@ -29,11 +29,11 @@ USER_CPP_UNDEFS =
 USER_LIBS = 
 
 # User Objects
-USER_OBJS = 
+USER_OBJS = ../oobe-common/Debug/liboobe-common.a
 
 # User Includes
 ## C Compiler
-USER_C_INC_DIRS = inc 
+USER_C_INC_DIRS = inc ../oobe-common/inc
 USER_INC_FILES = 
 ## C++ Compiler
 USER_CPP_INC_DIRS = 
@@ -52,7 +52,7 @@ USER_EDCS_FONT_DIRS = ${OUTPUT_DIR} edje/fonts
 # EDC Flags
 USER_EXT_EDC_KEYS = EDC0 
 
-USER_EXT_EDC0_EDCS = res/edje/*.edc 
+USER_EXT_EDC0_EDCS = res/edje/oobe-language.edc 
 USER_EXT_EDC0_EDCS_IMAGE_DIRS = ${OUTPUT_DIR} edje/images 
 USER_EXT_EDC0_EDCS_SOUND_DIRS = ${OUTPUT_DIR} edje/sounds 
 USER_EXT_EDC0_EDCS_FONT_DIRS = ${OUTPUT_DIR} edje/fonts 
index dd7f5f1e086733cff82c7b316b7b92a9db5b3f26..d881dc62a8093e2d6c41241e5509200c02d04e33 100644 (file)
@@ -21,6 +21,7 @@
 #include <Elementary.h>
 #include <system_settings.h>
 #include <efl_extension.h>
+#include <log.h>
 
 #ifdef  LOG_TAG
 #undef  LOG_TAG
@@ -28,7 +29,7 @@
 #define LOG_TAG "oobe-setup"
 
 #if !defined(PACKAGE)
-#define PACKAGE "org.tizen.oobe-setup"
+#define PACKAGE "org.tizen.oobe"
 #endif
 
 void language_show(void);
index f1bb8e4d2e2ae7bd53d4d3f15322f1800f051a92..0370a6ee380dd786b0f20f0ad781bc77754372bd 100644 (file)
@@ -29,11 +29,11 @@ USER_CPP_UNDEFS =
 USER_LIBS = 
 
 # User Objects
-USER_OBJS = 
+USER_OBJS = ../oobe-common/Debug/liboobe-common.a
 
 # User Includes
 ## C Compiler
-USER_C_INC_DIRS = inc 
+USER_C_INC_DIRS = inc ../oobe-common/inc
 USER_INC_FILES = 
 ## C++ Compiler
 USER_CPP_INC_DIRS = 
diff --git a/oobe-setup/res/po/en_US.po b/oobe-setup/res/po/en_US.po
new file mode 100644 (file)
index 0000000..7045ced
--- /dev/null
@@ -0,0 +1,6 @@
+# This PO file is automatically generated by PO File Editor of Tizen Studio
+# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES CAN BE OVERWRITTEN
+
+msgid "DONE"
+msgstr "DONE"
+
diff --git a/oobe-setup/res/po/pl_PL.po b/oobe-setup/res/po/pl_PL.po
new file mode 100644 (file)
index 0000000..fca4ae1
--- /dev/null
@@ -0,0 +1,6 @@
+# This PO file is automatically generated by PO File Editor of Tizen Studio
+# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES CAN BE OVERWRITTEN
+
+msgid "DONE"
+msgstr "Zamknij"
+
index 1c7339ec4cb0bdc23a6cbb3474640eda4af63b41..d6f724441d5dda0a83b87d94e722cb71c8a6022b 100644 (file)
 #include "view.h"
 #include <app.h>
 #include <app-control.h>
+#include "alarm.h"
 #include "oobe.h"
+#include "log.h"
+
+static void ac_reply_cb(const char *reply) {}
 
 void done_show()
 {
        oobe_set_done();
        view_show_done();
+
+       app_control_launch_app("org.tizen.oobe-terms", ac_reply_cb);
 }
index 3974ff35e9ac2af6728d8856d6e6aa095df5050b..cee3aa05a89fb68ecc4c617a95ace337ad3d69ab 100644 (file)
 #include "oobe-setup.h"
 #include "view.h"
 #include "app-control.h"
+#include <utils_view.h>
 #include <log.h>
-#include <oobe-common.h>
+#include <terms.h>
+#include "oobe.h"
 
 static bool app_create(void *user_data)
 {
@@ -42,7 +44,15 @@ static void app_control(app_control_h app_control, void *user_data)
 
        if (!caller)
        {
-               language_show();
+               if(oobe_get_done())
+               {
+                       terms_show();
+                       ui_app_exit();
+               }
+               else
+               {
+                       language_show();
+               }
        }
        else
        {
@@ -66,6 +76,7 @@ static void app_control(app_control_h app_control, void *user_data)
                {
                        easy_setup_show();
                }
+               free(caller);
        }
 }
 
@@ -97,4 +108,4 @@ int main(int argc, char *argv[])
        }
 
        return ret;
-}
+}
\ No newline at end of file
index b5ecdc87d295e0245515cca4740384a07b2e5a11..68e689f7775f41c8ef9bd4ca1c1b4762de444610 100644 (file)
@@ -100,7 +100,7 @@ Eina_Bool view_show_done(void)
 
     Evas_Object *button_done = elm_button_add(s_info.layout_main);
     elm_object_style_set(button_done, "middle");
-    elm_object_text_set(button_done, "DONE");
+    elm_object_text_set(button_done, _("DONE"));
     evas_object_smart_callback_add(button_done, "clicked", _button_done_clicked_cb, NULL);
     elm_layout_content_set(s_info.layout_main, "done", button_done);
 
index cc5547b5dadf5321bb5cc436ba01202f5a205125..52d7a932053e1459c288cc42f31e83622db83116 100644 (file)
@@ -7,5 +7,7 @@
     </ui-application>
     <privileges>
         <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
+        <privilege>http://tizen.org/privilege/alarm.get</privilege>
+        <privilege>http://tizen.org/privilege/alarm.set</privilege>
     </privileges>
 </manifest>
index 3d893e789b25dd5adff90a38597ffc6c882bed8d..06168195b5a6f4ec31e34e89b34f5f561c059023 100644 (file)
@@ -29,11 +29,11 @@ USER_CPP_UNDEFS =
 USER_LIBS = 
 
 # User Objects
-USER_OBJS = 
+USER_OBJS = ../oobe-common/Debug/liboobe-common.a
 
 # User Includes
 ## C Compiler
-USER_C_INC_DIRS = inc 
+USER_C_INC_DIRS = inc ../oobe-common/inc
 USER_INC_FILES = 
 ## C++ Compiler
 USER_CPP_INC_DIRS = 
index b1cfca802c35422336f3b2bc5b6bd34f6137af6a..613f46a5f4bff2ea49bd605d3c1897b4d645a58e 100644 (file)
@@ -7,6 +7,11 @@
                <project>oobe-terms-service</project>
        </projects>
        <buildSpec>
+               <buildCommand>
+                       <name>org.tizen.nativecore.apichecker.apicheckerbuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
                <buildCommand>
                        <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
                        <arguments>
@@ -24,6 +29,7 @@
                <nature>org.eclipse.cdt.core.ccnature</nature>
                <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
                <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+               <nature>org.tizen.nativecore.apichecker.apicheckernature</nature>
        </natures>
        <filteredResources>
                <filter>
index 8ba73e1df3caaaee042a852822c437fa3ee2f8e1..8feba7718f5acaa75c8929f148d038f086de6c24 100644 (file)
@@ -29,11 +29,11 @@ USER_CPP_UNDEFS =
 USER_LIBS = 
 
 # User Objects
-USER_OBJS = 
+USER_OBJS = ../oobe-common/Debug/liboobe-common.a
 
 # User Includes
 ## C Compiler
-USER_C_INC_DIRS = inc 
+USER_C_INC_DIRS = inc ../oobe-common/inc
 USER_INC_FILES = 
 ## C++ Compiler
 USER_CPP_INC_DIRS = 
index 2441d2f4cc987c62eb4573a7a33528a50e58feb6..de01ce7fec0c546e4bdf766f34c3a16d10413fde 100644 (file)
@@ -1,6 +1,8 @@
+[
 {
   "latest_version": 1,
   "check_interval": 11,
+  "language":"en_US",
   "terms": [
     {
       "title": "Terms and Conditions",
       "content": "pp lorem ipsum"
     }
   ]
+},
+{
+  "latest_version": 1,
+  "check_interval": 11,
+  "language":"pl_PL",
+  "terms": [
+    {
+      "title": "Regulamin",
+      "is_required": true,
+      "content": "tnc lorem ipsum pl"
+    },
+    {
+      "title": "Polityka prywatnoĹ›ci",
+      "is_required": true,
+      "content": "pp lorem ipsum  pl"
+    }
+  ]
 }
+]
\ No newline at end of file
diff --git a/oobe-terms/res/data/terms_server_url b/oobe-terms/res/data/terms_server_url
new file mode 100644 (file)
index 0000000..efa214e
--- /dev/null
@@ -0,0 +1 @@
+http://106.116.47.121:5001/latest_version
\ No newline at end of file
index a92d51b88046e2cb2e6ccfe94b851d04c5fe3fb3..01718076f7ed8a16fbc46100dc56805fc2f75ce0 100644 (file)
 
 #include "oobe-terms.h"
 #include "view.h"
-#include <log.h>
 #include "app-control.h"
-#include "terms.h"
+#include <alarm.h>
+#include <oobe.h>
+#include <log.h>
+#include <terms.h>
 #include <oobe-common.h>
+#include <terms_data.h>
 
 static bool is_foreground = false;
 
+static void _verify_terms();
+static void _schedule_next_check_terms();
 static void _button_clicked_cb(const char* action);
 
 static bool app_create(void *user_data)
@@ -41,13 +46,23 @@ static void app_terminate(void *user_data)
        view_destroy();
 }
 
+static bool _is_caller_oobe_setup(app_control_h app_control) {
+       bool result = 0;
+       char* value = NULL;
+       app_control_get_extra_data(app_control, "caller", &value);
+       if (value && !strcmp(value, "oobe-setup"))
+               result = true;
+       free(value);
+       return result;
+}
+
 static void app_control(app_control_h app_control, void *user_data)
 {
-       // do not show view again if it is already shown
        // TODO check if there is a new version downloaded -> then show popup, and update terms list
        if (is_foreground) {
-               if(terms->latest_version == terms_get_latest_version()) {
+               if (terms->latest_version == terms_get_latest_version()) {
                        LOGD("App already in the foreground");
+                       _schedule_next_check_terms();
                        return;
                } else {
                        LOGD("Recreating view with newer terms");
@@ -59,21 +74,17 @@ static void app_control(app_control_h app_control, void *user_data)
        if (terms_latest_exist() == false)
                terms_latest_init();
 
-       char* value = NULL;
-       app_control_get_extra_data(app_control, "caller", &value);
-
-       if (value) {
-               if(!strcmp(value, "oobe-setup")) {
+       if (oobe_get_done()) {
+               LOGD("Verifying terms");
+               _verify_terms();
+       } else {
+               if (_is_caller_oobe_setup(app_control)) {
                        view_create(Normal, NULL);
-               } else if(!strcmp(value, "oobe-terms-service")) {
-                       // TODO: replace view_create with view_create_settings
-                       view_create(Reagree, NULL);
+               } else {
+                       LOGD("Cannot start without proper caller name");
+                       ui_app_exit();
                }
-       } else {
-               LOGD("Cannot start without proper caller name");
-               return;
        }
-
        app_control_save_reply_handler(app_control);
 }
 
@@ -144,3 +155,51 @@ static void _button_clicked_cb(const char* action)
                ui_app_exit();
        }
 }
+
+static bool _check_for_new_terms() {
+       bool needs_acceptance = false;
+       LOGD("*** CHECK FOR NEW TERMS ***");
+
+       bool oobe_done = oobe_get_done();
+       if (oobe_done) {
+               int accepted_version = terms_get_accepted_version();
+               int latest_version = terms_get_latest_version();
+               LOGI("accepted version: %d, latest version: %d", accepted_version, latest_version);
+
+               if(accepted_version <= 0) {
+                       if (latest_version <= 0)
+                               LOGW("there are neither latest nor accepted terms");
+                       else
+                               needs_acceptance = true;
+               } else {
+                       terms_download_latest(accepted_version);
+
+                       latest_version = terms_get_latest_version();
+                       LOGI("latest version: %d", latest_version);
+                       if (latest_version <= 0 )
+                               LOGW("there is no file with latest terms or access is denied");
+                       else if (accepted_version < latest_version)
+                               needs_acceptance = true;
+               }
+       } else {
+               LOGD("OOBE is not done yet. Skipping terms check.");
+       }
+       return needs_acceptance;
+}
+
+static void _schedule_next_check_terms() {
+       int interval = terms_get_pooling_interval();
+       alarm_schedule(interval, PACKAGE, "reagree");
+       LOGD("scheduled next check for new terms in %d sec", interval);
+}
+
+static void _verify_terms() {
+       LOGD("oobe terms run in verify mode");
+       _schedule_next_check_terms();
+       if(_check_for_new_terms()) {
+               view_create(Reagree, NULL);
+       }
+       else {
+               ui_app_exit();
+       }
+}
index 7243aaa9a75d0c8255a63dd87c6d9ccdbcda9a3c..668b8455f1d3ed7146e39c0458738fdb3fc12737 100644 (file)
  */
 
 #include "view.h"
-#include "terms.h"
 #include "oobe-terms.h"
-#include <log.h>
 #include "view-defines.h"
-#include <glib.h>
-#include <utils.h>
+#include <terms.h>
+#include <terms_data.h>
+#include <log.h>
 #include <oobe-common.h>
+#include <utils.h>
+#include <glib.h>
 
 static struct view_info {
        Evas_Object *win;
@@ -302,37 +303,40 @@ static Eina_Bool _create_terms_layout(enum view_mode view_mode)
 
 static void _terms_list_load(char *terms_path)
 {
-       terms = terms_create_from_file(terms_path);
-
-       Elm_Genlist_Item_Class *agree_all_class = elm_genlist_item_class_new();
-       agree_all_class->item_style = "terms_agree";
-       agree_all_class->func.text_get = _agree_all_text_get;
-       agree_all_class->func.content_get = _agree_all_content_get;
-
-       Elm_Genlist_Item_Class *agree_one_class = elm_genlist_item_class_new();
-       agree_one_class->item_style = "terms_agree";
-       agree_one_class->func.text_get = _agree_one_text_get;
-       agree_one_class->func.content_get = _agree_one_content_get;
-
-       int items_to_accept = 0;
-       for (int i = 0; i < terms->terms_count; ++i)
-       {
-               if (terms->terms[i].is_required)
-                       ++items_to_accept;
-       }
+       terms = terms_data_create_from_file(terms_path);
+       if(terms != NULL) {
+               Elm_Genlist_Item_Class *agree_all_class = elm_genlist_item_class_new();
+               agree_all_class->item_style = "terms_agree";
+               agree_all_class->func.text_get = _agree_all_text_get;
+               agree_all_class->func.content_get = _agree_all_content_get;
+
+               Elm_Genlist_Item_Class *agree_one_class = elm_genlist_item_class_new();
+               agree_one_class->item_style = "terms_agree";
+               agree_one_class->func.text_get = _agree_one_text_get;
+               agree_one_class->func.content_get = _agree_one_content_get;
+
+               int items_to_accept = 0;
+               for (int i = 0; i < terms->terms_count; ++i)
+               {
+                       if (terms->terms[i].is_required)
+                               ++items_to_accept;
+               }
 
-       if (items_to_accept > 1)
-               elm_genlist_item_append(s_info.gen_list, agree_all_class, &terms_all, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
+               if (items_to_accept > 1)
+                       elm_genlist_item_append(s_info.gen_list, agree_all_class, &terms_all, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
 
-       for (int i = 0; i < terms->terms_count; ++i)
-               elm_genlist_item_append(s_info.gen_list, agree_one_class, terms->terms + i, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
+               for (int i = 0; i < terms->terms_count; ++i)
+                       elm_genlist_item_append(s_info.gen_list, agree_one_class, terms->terms + i, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
 
-       elm_genlist_item_class_free(agree_all_class);
-       elm_genlist_item_class_free(agree_one_class);
+               elm_genlist_item_class_free(agree_all_class);
+               elm_genlist_item_class_free(agree_one_class);
 
-       int items_count = elm_genlist_items_count(s_info.gen_list);
-       if (items_count > 3)
-               elm_object_signal_emit(s_info.layout_terms, "show_list_bg", "");
+               int items_count = elm_genlist_items_count(s_info.gen_list);
+               if (items_count > 3)
+                       elm_object_signal_emit(s_info.layout_terms, "show_list_bg", "");
+       } else {
+               LOGE("terms was not loaded correctly");
+       }
 }
 
 static void _button_view_details_clicked_cb(void *data, Evas_Object *obj, void *event_info)
index 11b133d3890ed4409d640cd057e19506c37f0a40..acd75d43fc4b7f4fecc2bb81bfa5c757824c7244 100644 (file)
@@ -29,11 +29,11 @@ USER_CPP_UNDEFS =
 USER_LIBS = 
 
 # User Objects
-USER_OBJS = 
+USER_OBJS = ../oobe-common/Debug/liboobe-common.a
 
 # User Includes
 ## C Compiler
-USER_C_INC_DIRS = inc 
+USER_C_INC_DIRS = inc ../oobe-common/inc
 USER_INC_FILES = 
 ## C++ Compiler
 USER_CPP_INC_DIRS = 
index bcbddf2699a679b4f504b8b0a7a4c868db6e27e0..9ffe7e7ea32268f6021ab31e798d941c6cb5c627 100644 (file)
 # software and documents. This publication and the contents here of are subject
 # to change without notice.
 #
+# run: /pathToSam/sam_cli.sh sam_cli.cfg
 
 ################################
 # Project Name
 ################################
-SAM_PRJ_NAME="OOBE-HEADED"
+SAM_PRJ_NAME="OOBE-Chair"
 
 
 ################################