SET(SETTING_RINGTONE setting-ringtone)
SET(SETTING_APPMGR setting-appmgr)
SET(SETTING_PRIVACY setting-privacy)
+SET(SETTING_RESET setting-reset)
SET(LIB_SETTING_COMMON setting-common)
ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/${SETTING_STORAGE})
ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/${SETTING_TIME})
ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/${SETTING_PRIVACY})
+ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/${SETTING_RESET})
<label xml:lang="ko-kr">날짜 및 시간</label>
<datacontrol access="ReadOnly" providerid="http://org.tizen.setting-time/datacontrol/provider/uiapp" type="bin"/>
</ui-application>
+ <ui-application appid="org.tizen.setting-reset" exec="@TZ_SYS_RO_APP@/org.tizen.setting/bin/setting-reset" nodisplay="true" multiple="false" type="capp" taskmanage="false" hw-acceleration="on" launch_mode="caller">
+ <label>Reset</label>
+ </ui-application>
<privileges>
<privilege>http://tizen.org/privilege/appmanager.launch</privilege>
<privilege>http://tizen.org/privilege/appmanager.kill</privilege>
BuildRequires: edje-tools
BuildRequires: gettext-tools
BuildRequires: hash-signer
+BuildRequires: dbus
Requires(post): attr
%description
Cfg_Item_AppLauncher_Node,
NULL
},
+ { KeyStr_Reset,
+ NULL,
+ "org.tizen.setting-reset",
+ Cfg_Item_Pos_Level0,
+ Cfg_Item_AppLauncher_Node,
+ NULL
+ },
{ KeyStr_AboutDevice,
IMG_AboutDevice,
"org.tizen.setting-about",
--- /dev/null
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/${SETTING_COMMON}/include)
+
+SET(PROJECT_SETTING_RESET "setting-reset")
+SET(SETTING_PKG_RESET "org.tizen.setting-reset")
+
+INCLUDE(FindPkgConfig)
+
+pkg_check_modules(pkgs_profile REQUIRED
+ capi-appfw-application
+ elementary
+ dlog
+ dbus-1
+)
+
+FOREACH(flag ${pkgs_profile_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE -Werror-implicit-function-declaration")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib")
+
+ADD_EXECUTABLE(${PROJECT_SETTING_RESET}
+ ./src/setting-reset.c
+ ./src/setting-reset-main.c
+ ./src/setting-reset-initial-config.c
+ ./src/setting-reset-factory-reset.c
+ ./src/setting-reset-network.c
+ ./src/setting-reset-settings.c
+ ./src/controls/confirm-popup.c
+ )
+
+TARGET_LINK_LIBRARIES(${PROJECT_SETTING_RESET} -L${CMAKE_BINARY_DIR}/${SETTING_COMMON} -lsetting-common)
+TARGET_LINK_LIBRARIES(${PROJECT_SETTING_RESET} ${pkgs_profile_LDFLAGS} -pie)
+INSTALL(PROGRAMS ${PROJECT_SETTING_RESET} DESTINATION ${TZ_SYS_RO_APP}/${SETTING_PKG_NAME}/bin)
--- /dev/null
+/*
+ * Copyright (c) 2020 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 CONFIRM_POPUP_H
+#define CONFIRM_POPUP_H
+
+#include <Elementary.h>
+
+/**
+ * @brief Creates new confirm popup widget, with title, content text
+ * and two buttons: "confirm", "reject"
+ *
+ * --------------------------------
+ * | Title |
+ * |------------------------------|
+ * | |
+ * | Text |
+ * | |
+ * |-------------- ---------------|
+ * ||Reject button||Confirm button|
+ * --------------------------------
+ *
+ * Usage:
+ *
+ * Evas_Object *cp = confirm_popup_create(window);
+ *
+ * confirm_popup_title_set(cp, "Confirmation");
+ * confirm_popup_text_set(cp, "Remove all files?");
+ * confirm_popup_accept_text_set(cp, "Remove");
+ * confirm_popup_reject_text_set(cp, "Cancel");
+ *
+ * evas_object_smart_callback_add(cp, "confirmed", accepted_cb, NULL);
+ * evas_object_smart_callback_add(cp, "rejected", rejected_cb, NULL);
+ *
+ * evas_object_show(cp);
+ */
+Evas_Object *confirm_popup_create(Evas_Object *parent);
+
+void confirm_popup_title_set(Evas_Object *confirm_popup, const char *title);
+
+void confirm_popup_text_set(Evas_Object *confirm_popup, const char *text);
+
+void confirm_popup_confirm_text_set(Evas_Object *confirm_popup, const char *text);
+
+void confirm_popup_reject_text_set(Evas_Object *confirm_popup, const char *text);
+
+#endif /* end of include guard: CONFIRM_POPUP_H */
--- /dev/null
+/*
+ * Copyright (c) 2020 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 ___SETTING_RESET_H___
+#define ___SETTING_RESET_H__
+
+#include "setting-common-init.h"
+#include "setting-common-general-func.h"
+#include "setting-common-draw-widget.h"
+#include "setting-common-view.h"
+
+#define RESET_APP_NAME "org.tizen.setting-reset"
+#define ARRAY_SIZE(x) sizeof(x)/sizeof(x[0])
+
+extern setting_view setting_view_reset;
+
+void setting_reset_settings();
+void setting_reset_network();
+void setting_reset_initial_config();
+void setting_reset_factory_reset();
+
+#endif /* end of include guard: ___SETTING_RESET_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2020 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 "controls/confirm-popup.h"
+
+static void _on_reject_clicked(void *data, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *popup = data;
+ evas_object_smart_callback_call(popup, "rejected", NULL);
+}
+
+static void _on_confirm_clicked(void *data, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *popup = data;
+ evas_object_smart_callback_call(popup, "confirmed", NULL);
+}
+
+Evas_Object *confirm_popup_create(Evas_Object *parent)
+{
+ Evas_Object *popup = elm_popup_add(parent);
+
+ elm_popup_align_set(popup, 0.5, 1.0);
+ evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+ Evas_Object *btn = elm_button_add(popup);
+ elm_object_style_set(btn, "popup");
+ evas_object_smart_callback_add(btn, "clicked", _on_reject_clicked, popup);
+ elm_object_part_content_set(popup, "button1", btn);
+
+ Evas_Object *btn2 = elm_button_add(popup);
+ elm_object_style_set(btn2, "popup");
+ evas_object_smart_callback_add(btn2, "clicked", _on_confirm_clicked, popup);
+ elm_object_part_content_set(popup, "button2", btn2);
+
+ return popup;
+}
+
+void confirm_popup_title_set(Evas_Object *confirm_popup, const char *title)
+{
+ elm_object_part_text_set(confirm_popup, "title,text", title);
+}
+
+void confirm_popup_text_set(Evas_Object *confirm_popup, const char *text)
+{
+ elm_object_text_set(confirm_popup, text);
+}
+
+void confirm_popup_confirm_text_set(Evas_Object *confirm_popup, const char *text)
+{
+ Evas_Object *btn = elm_object_part_content_get(confirm_popup, "button2");
+ elm_object_text_set(btn, text);
+}
+
+void confirm_popup_reject_text_set(Evas_Object *confirm_popup, const char *text)
+{
+ Evas_Object *btn = elm_object_part_content_get(confirm_popup, "button1");
+ elm_object_text_set(btn, text);
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 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 "setting-common-general-func.h"
+
+#include <dbus/dbus.h>
+
+static void _dbus_call_notify_cb(DBusPendingCall *pending, void *data)
+{
+ SETTING_TRACE("dbus call end %p %d", pending,
+ dbus_pending_call_get_completed(pending));
+ if (TRUE == dbus_pending_call_get_completed(pending)) {
+ SETTING_TRACE_DEBUG("Dbus call completed");
+ }
+}
+
+void setting_reset_factory_reset()
+{
+ DBusMessage *message = NULL;
+ DBusConnection *conn = NULL;
+ DBusPendingCall *pending_call = NULL;
+
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ if (!conn) {
+ SETTING_TRACE_WARNING("dbus_bus_get() error");
+ return;
+ }
+ message = dbus_message_new_signal("/org/tizen/factoryreset",
+ "org.tizen.factoryreset.start",
+ "setting");
+ if (!message) {
+ SETTING_TRACE_WARNING("dbus_message_new_signal() error");
+ dbus_connection_unref(conn);
+ return;
+ }
+ dbus_message_set_destination(message, "org.tizen.factoryreset");
+
+ if (FALSE ==
+ dbus_connection_send_with_reply(conn, message, &pending_call, 100)) {
+ SETTING_TRACE_WARNING("dbus_connection_send_with_reply() error");
+ dbus_message_unref(message);
+ dbus_connection_unref(conn);
+ return;
+ }
+
+ if (FALSE == dbus_pending_call_set_notify(pending_call,
+ _dbus_call_notify_cb, NULL, NULL)) {
+ SETTING_TRACE("dbus_pending_call_set_notify() error");
+ }
+
+ dbus_pending_call_block(pending_call);
+ dbus_message_unref(message);
+ dbus_connection_unref(conn);
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 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.
+ */
+
+void setting_reset_initial_config()
+{
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 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 "setting-reset.h"
+#include "controls/confirm-popup.h"
+
+struct item {
+ const char *display_title;
+ setting_call_back_func select;
+ const char *icon;
+};
+
+static int setting_reset_create(void *ad);
+static void setting_reset_settings_clicked(void *data, Evas_Object *obj, void *event_info);
+static void setting_reset_network_clicked(void *data, Evas_Object *obj, void *event_info);
+static void setting_reset_initial_config_clicked(void *data, Evas_Object *obj, void *event_info);
+static void setting_reset_factory_reset_clicked(void *data, Evas_Object *obj, void *event_info);
+
+setting_view setting_view_reset = {
+ .create = setting_reset_create,
+ .update = NULL,
+ .destroy = NULL,
+ .cleanup = NULL
+};
+
+static Elm_Genlist_Item_Class itc;
+
+const static struct item items[] = {
+ //TODO add i18n to display_title fields
+ { "Reset settings", setting_reset_settings_clicked, NULL},
+ { "Reset network settings", setting_reset_network_clicked, NULL},
+ { "Reset initial configuration", setting_reset_initial_config_clicked, NULL},
+ { "Factory data reset", setting_reset_factory_reset_clicked, NULL},
+};
+
+static void _dismiss_popup(void *data, Evas_Object *obj, void *event_info)
+{
+ evas_object_del(obj);
+}
+
+static void _on_confirmed_reset_settings(void *data, Evas_Object *obj, void *event_info)
+{
+ setting_reset_settings();
+ evas_object_del(obj);
+}
+
+static Evas_Object *_reset_confirm_popup_create(Evas_Object *parent)
+{
+ Evas_Object *confirm_popup = confirm_popup_create(parent);
+ confirm_popup_title_set(confirm_popup, "Confirm Reset");
+ confirm_popup_confirm_text_set(confirm_popup, "Reset");
+ confirm_popup_reject_text_set(confirm_popup, "Cancel");
+ return confirm_popup;
+}
+
+static void setting_reset_settings_clicked(void *data, Evas_Object *obj, void *event_info)
+{
+ MainData *md = data;
+ Evas_Object *confirm_popup = _reset_confirm_popup_create(md->window);
+ confirm_popup_text_set(confirm_popup, "<align=center>All settings will be reset.<br>This action cannot be undone.</align>");
+ evas_object_smart_callback_add(confirm_popup, "confirmed", _on_confirmed_reset_settings, NULL);
+ evas_object_smart_callback_add(confirm_popup, "rejected", _dismiss_popup, NULL);
+ elm_genlist_item_selected_set(event_info, EINA_FALSE);
+ evas_object_show(confirm_popup);
+}
+
+static void _on_confirmed_reset_network(void *data, Evas_Object *obj, void *event_info)
+{
+ setting_reset_network();
+ evas_object_del(obj);
+}
+
+static void setting_reset_network_clicked(void *data, Evas_Object *obj, void *event_info)
+{
+ MainData *md = data;
+ Evas_Object *confirm_popup = _reset_confirm_popup_create(md->window);
+ confirm_popup_text_set(confirm_popup, "<align=center>All network settings will be reset.<br>This action cannot be undone.</align>");
+ evas_object_smart_callback_add(confirm_popup, "confirmed", _on_confirmed_reset_network, NULL);
+ evas_object_smart_callback_add(confirm_popup, "rejected", _dismiss_popup, NULL);
+ elm_genlist_item_selected_set(event_info, EINA_FALSE);
+ evas_object_show(confirm_popup);
+}
+
+static void _on_confirmed_reset_initial_config(void *data, Evas_Object *obj, void *event_info)
+{
+ setting_reset_initial_config();
+ evas_object_del(obj);
+}
+
+static void setting_reset_initial_config_clicked(void *data, Evas_Object *obj, void *event_info)
+{
+ MainData *md = data;
+ Evas_Object *confirm_popup = _reset_confirm_popup_create(md->window);
+ confirm_popup_text_set(confirm_popup, "<align=center>Initial configuration will be reset.<br>This action cannot be undone.</align>");
+ evas_object_smart_callback_add(confirm_popup, "confirmed", _on_confirmed_reset_initial_config, NULL);
+ evas_object_smart_callback_add(confirm_popup, "rejected", _dismiss_popup, NULL);
+ elm_genlist_item_selected_set(event_info, EINA_FALSE);
+ evas_object_show(confirm_popup);
+}
+
+static void _on_confirmed_factory_reset(void *data, Evas_Object *obj, void *event_info)
+{
+ setting_reset_factory_reset();
+ evas_object_del(obj);
+}
+
+static void setting_reset_factory_reset_clicked(void *data, Evas_Object *obj, void *event_info)
+{
+ MainData *md = data;
+ Evas_Object *confirm_popup = _reset_confirm_popup_create(md->window);
+ confirm_popup_text_set(confirm_popup, "<align=center>Factory reset will be performed.<br>This action cannot be undone.</align>");
+ evas_object_smart_callback_add(confirm_popup, "confirmed", _on_confirmed_factory_reset, NULL);
+ evas_object_smart_callback_add(confirm_popup, "rejected", _dismiss_popup, NULL);
+ elm_genlist_item_selected_set(event_info, EINA_FALSE);
+ evas_object_show(confirm_popup);
+}
+
+static Eina_Bool _cancel_cb(void *data, Elm_Object_Item *it)
+{
+ ui_app_exit();
+ return EINA_TRUE;
+}
+
+static int setting_reset_create(void *ad)
+{
+ SETTING_TRACE_BEGIN;
+
+ MainData *md = ad;
+ retv_if(!md, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
+
+ int ret = view_init(md, _("IDS_ST_HEADER_RESET"));
+ if (ret != SETTING_RETURN_SUCCESS)
+ return ret;
+
+ setting_create_Gendial_itc(SETTING_GENLIST_ICON_1LINE_STYLE, &itc);
+ setting_add_back_button(md, _cancel_cb, NULL);
+
+ for (int i = 0; i < ARRAY_SIZE(items); ++i) {
+ const struct item *it = &items[i];
+
+ setting_create_Gendial_field_def(
+ md->genlist,
+ &itc,
+ it->select,
+ md,
+ SWALLOW_Type_INVALID,
+ (char*)it->icon,
+ NULL,
+ 0,
+ it->display_title,
+ NULL,
+ NULL);
+ }
+
+ setting_view_reset.is_create = 1;
+ evas_object_show(md->window);
+ SETTING_TRACE_END;
+ return SETTING_RETURN_SUCCESS;
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 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.
+ */
+
+void setting_reset_network()
+{
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 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.
+ */
+
+void setting_reset_settings()
+{
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 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 "setting-reset.h"
+
+static bool _setting_reset_app_create(void *priv)
+{
+ SETTING_TRACE_BEGIN;
+ MainData *ad = priv;
+ retv_if(!ad, NULL);
+
+ if (app_init(ad, RESET_APP_NAME) != SETTING_RETURN_SUCCESS) {
+ SETTING_TRACE_ERROR("Cannot initialize application");
+ return false;
+ }
+
+ setting_view_node_table_intialize();
+ setting_view_node_table_register(&setting_view_reset, NULL);
+ setting_view_node_set_cur_view(&setting_view_reset);
+ setting_view_create(&setting_view_reset, ad);
+
+ return true;
+}
+
+static void _setting_reset_app_pause(void *priv)
+{
+ SETTING_TRACE_BEGIN;
+}
+
+static void _setting_reset_app_resume(void *priv)
+{
+ SETTING_TRACE_BEGIN;
+}
+
+static void _setting_reset_app_terminate(void *priv)
+{
+ SETTING_TRACE_BEGIN;
+}
+
+static void _setting_sound_lang_changed(app_event_info_h event_info, void *data)
+{
+ char *lang = NULL;
+ if (app_event_get_language(event_info, &lang) == APP_ERROR_NONE) {
+ SETTING_TRACE_DEBUG("Setting - language is changed : %s", lang);
+ elm_language_set(lang);
+ elm_config_all_flush();
+ free(lang);
+ } else {
+ SETTING_TRACE_ERROR("Cannot get language from event_info");
+ }
+}
+
+EXPORT_PUBLIC
+int main(int argc, char *argv[])
+{
+ app_event_handler_h handlers[5] = {NULL, };
+ ui_app_lifecycle_callback_s ops = {
+ .create = _setting_reset_app_create,
+ .pause = _setting_reset_app_pause,
+ .resume = _setting_reset_app_resume,
+ .terminate = _setting_reset_app_terminate,
+ .app_control = NULL
+ };
+
+ MainData app_data;
+ memset(&app_data, 0, sizeof(MainData));
+
+ ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED],
+ APP_EVENT_LANGUAGE_CHANGED, _setting_sound_lang_changed,
+ &app_data);
+
+ return ui_app_main(argc, argv, &ops, &app_data);
+}