Add Initial codes master
authorKiseok Chang <kiso.chang@samsung.com>
Tue, 11 Jun 2019 08:38:02 +0000 (17:38 +0900)
committerKiseok Chang <kiso.chang@samsung.com>
Tue, 11 Jun 2019 08:41:17 +0000 (17:41 +0900)
Signed-off-by: Kiseok Chang <kiso.chang@samsung.com>
33 files changed:
CMakeLists.txt [new file with mode: 0755]
LICENSE [new file with mode: 0755]
include/settingcmd-debug.h [new file with mode: 0755]
packaging/org.tizen.setting-cmd.manifest [new file with mode: 0755]
packaging/org.tizen.setting-cmd.spec [new file with mode: 0755]
src/CMakeLists.txt [new file with mode: 0755]
src/sc_aboutdevice.c [new file with mode: 0755]
src/sc_aboutdevice.h [new file with mode: 0755]
src/sc_airplane.c [new file with mode: 0755]
src/sc_airplane.h [new file with mode: 0755]
src/sc_apps.c [new file with mode: 0755]
src/sc_apps.h [new file with mode: 0755]
src/sc_battery.c [new file with mode: 0755]
src/sc_battery.h [new file with mode: 0755]
src/sc_bluetooth.c [new file with mode: 0755]
src/sc_bluetooth.h [new file with mode: 0755]
src/sc_common.c [new file with mode: 0755]
src/sc_common.h [new file with mode: 0755]
src/sc_datausage.c [new file with mode: 0755]
src/sc_datausage.h [new file with mode: 0755]
src/sc_datetime.c [new file with mode: 0755]
src/sc_datetime.h [new file with mode: 0755]
src/sc_display.c [new file with mode: 0755]
src/sc_display.h [new file with mode: 0755]
src/sc_sound.c [new file with mode: 0755]
src/sc_sound.h [new file with mode: 0755]
src/sc_storage.c [new file with mode: 0755]
src/sc_storage.h [new file with mode: 0755]
src/sc_wifi.c [new file with mode: 0755]
src/sc_wifi.h [new file with mode: 0755]
src/setting_cmd.c [new file with mode: 0755]
src/setting_cmd.h [new file with mode: 0755]
src/settingcmd_def.h [new file with mode: 0755]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..cc248c0
--- /dev/null
@@ -0,0 +1,42 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(setting-cmd)
+
+SET(SETTING_PKG_NAME org.tizen.setting-cmd)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+#SET(BINDIR "${PREFIX}/bin")
+SET(BIN_DIR "${BIN_DIR}")
+SET(RESDIR "${PREFIX}/res")
+SET(DATADIR "${PREFIX}/data")
+SET(CONFICDIR "${PREFIX}/def_config")
+SET(LOCALEDIR "${RESDIR}/locale")
+SET(ICONDIR "${TZ_SYS_RO_ICONS}/default/small")
+SET(EDJDIR "${RESDIR}/edje")
+SET(IMAGEDIR "${RESDIR}/images")
+SET(CMAKE_SKIP_BUILD_RPATH true)
+
+#set variable
+
+SET(GC_SECTIONS_FLAGS "-fdata-sections -ffunction-sections -Wl,--gc-sections -Werror-implicit-function-declaration")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GC_SECTIONS_FLAGS}")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GC_SECTIONS_FLAGS}")
+
+ADD_DEFINITIONS("-D_TZ_SYS_RO_APP=\"${TZ_SYS_RO_APP}\"")
+ADD_DEFINITIONS("-D_TZ_SYS_DATA=\"${TZ_SYS_DATA}\"")
+ADD_DEFINITIONS("-D_TZ_SYS_ETC=\"${TZ_SYS_ETC}\"")
+ADD_DEFINITIONS("-D_TZ_SYS_SHARE=\"${TZ_SYS_SHARE}\"")
+ADD_DEFINITIONS("-D_TZ_SYS_RW_APP=\"${TZ_SYS_RW_APP}\"")
+ADD_DEFINITIONS("-D_TZ_SYS_RO_UG=\"${TZ_SYS_RO_UG}\"")
+ADD_DEFINITIONS("-D_TZ_SYS_RO_ICONS=\"${TZ_SYS_RO_ICONS}\"")
+ADD_DEFINITIONS("-D_TZ_SYS_MEDIA=\"${TZ_SYS_MEDIA}\"")
+ADD_DEFINITIONS("-D_TZ_SYS_DB=\"${TZ_SYS_DB}\"")
+ADD_DEFINITIONS("-D_TZ_SYS_GLOBALUSER_DATA=\"${TZ_SYS_GLOBALUSER_DATA}\"")
+
+
+#setting main view build start
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+#INSTALL(FILES ${CMAKE_SOURCE_DIR}/org.tizen.setting-cmd.xml DESTINATION /usr/share/packages/)
+
+# setting bin
+# setting plugin
+ADD_SUBDIRECTORY(src)
diff --git a/LICENSE b/LICENSE
new file mode 100755 (executable)
index 0000000..9c13a9b
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,204 @@
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+\r
+                                 Apache License\r
+                           Version 2.0, January 2004\r
+                        http://www.apache.org/licenses/\r
+\r
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
+\r
+   1. Definitions.\r
+\r
+      "License" shall mean the terms and conditions for use, reproduction,\r
+      and distribution as defined by Sections 1 through 9 of this document.\r
+\r
+      "Licensor" shall mean the copyright owner or entity authorized by\r
+      the copyright owner that is granting the License.\r
+\r
+      "Legal Entity" shall mean the union of the acting entity and all\r
+      other entities that control, are controlled by, or are under common\r
+      control with that entity. For the purposes of this definition,\r
+      "control" means (i) the power, direct or indirect, to cause the\r
+      direction or management of such entity, whether by contract or\r
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
+      outstanding shares, or (iii) beneficial ownership of such entity.\r
+\r
+      "You" (or "Your") shall mean an individual or Legal Entity\r
+      exercising permissions granted by this License.\r
+\r
+      "Source" form shall mean the preferred form for making modifications,\r
+      including but not limited to software source code, documentation\r
+      source, and configuration files.\r
+\r
+      "Object" form shall mean any form resulting from mechanical\r
+      transformation or translation of a Source form, including but\r
+      not limited to compiled object code, generated documentation,\r
+      and conversions to other media types.\r
+\r
+      "Work" shall mean the work of authorship, whether in Source or\r
+      Object form, made available under the License, as indicated by a\r
+      copyright notice that is included in or attached to the work\r
+      (an example is provided in the Appendix below).\r
+\r
+      "Derivative Works" shall mean any work, whether in Source or Object\r
+      form, that is based on (or derived from) the Work and for which the\r
+      editorial revisions, annotations, elaborations, or other modifications\r
+      represent, as a whole, an original work of authorship. For the purposes\r
+      of this License, Derivative Works shall not include works that remain\r
+      separable from, or merely link (or bind by name) to the interfaces of,\r
+      the Work and Derivative Works thereof.\r
+\r
+      "Contribution" shall mean any work of authorship, including\r
+      the original version of the Work and any modifications or additions\r
+      to that Work or Derivative Works thereof, that is intentionally\r
+      submitted to Licensor for inclusion in the Work by the copyright owner\r
+      or by an individual or Legal Entity authorized to submit on behalf of\r
+      the copyright owner. For the purposes of this definition, "submitted"\r
+      means any form of electronic, verbal, or written communication sent\r
+      to the Licensor or its representatives, including but not limited to\r
+      communication on electronic mailing lists, source code control systems,\r
+      and issue tracking systems that are managed by, or on behalf of, the\r
+      Licensor for the purpose of discussing and improving the Work, but\r
+      excluding communication that is conspicuously marked or otherwise\r
+      designated in writing by the copyright owner as "Not a Contribution."\r
+\r
+      "Contributor" shall mean Licensor and any individual or Legal Entity\r
+      on behalf of whom a Contribution has been received by Licensor and\r
+      subsequently incorporated within the Work.\r
+\r
+   2. Grant of Copyright License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      copyright license to reproduce, prepare Derivative Works of,\r
+      publicly display, publicly perform, sublicense, and distribute the\r
+      Work and such Derivative Works in Source or Object form.\r
+\r
+   3. Grant of Patent License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      (except as stated in this section) patent license to make, have made,\r
+      use, offer to sell, sell, import, and otherwise transfer the Work,\r
+      where such license applies only to those patent claims licensable\r
+      by such Contributor that are necessarily infringed by their\r
+      Contribution(s) alone or by combination of their Contribution(s)\r
+      with the Work to which such Contribution(s) was submitted. If You\r
+      institute patent litigation against any entity (including a\r
+      cross-claim or counterclaim in a lawsuit) alleging that the Work\r
+      or a Contribution incorporated within the Work constitutes direct\r
+      or contributory patent infringement, then any patent licenses\r
+      granted to You under this License for that Work shall terminate\r
+      as of the date such litigation is filed.\r
+\r
+   4. Redistribution. You may reproduce and distribute copies of the\r
+      Work or Derivative Works thereof in any medium, with or without\r
+      modifications, and in Source or Object form, provided that You\r
+      meet the following conditions:\r
+\r
+      (a) You must give any other recipients of the Work or\r
+          Derivative Works a copy of this License; and\r
+\r
+      (b) You must cause any modified files to carry prominent notices\r
+          stating that You changed the files; and\r
+\r
+      (c) You must retain, in the Source form of any Derivative Works\r
+          that You distribute, all copyright, patent, trademark, and\r
+          attribution notices from the Source form of the Work,\r
+          excluding those notices that do not pertain to any part of\r
+          the Derivative Works; and\r
+\r
+      (d) If the Work includes a "NOTICE" text file as part of its\r
+          distribution, then any Derivative Works that You distribute must\r
+          include a readable copy of the attribution notices contained\r
+          within such NOTICE file, excluding those notices that do not\r
+          pertain to any part of the Derivative Works, in at least one\r
+          of the following places: within a NOTICE text file distributed\r
+          as part of the Derivative Works; within the Source form or\r
+          documentation, if provided along with the Derivative Works; or,\r
+          within a display generated by the Derivative Works, if and\r
+          wherever such third-party notices normally appear. The contents\r
+          of the NOTICE file are for informational purposes only and\r
+          do not modify the License. You may add Your own attribution\r
+          notices within Derivative Works that You distribute, alongside\r
+          or as an addendum to the NOTICE text from the Work, provided\r
+          that such additional attribution notices cannot be construed\r
+          as modifying the License.\r
+\r
+      You may add Your own copyright statement to Your modifications and\r
+      may provide additional or different license terms and conditions\r
+      for use, reproduction, or distribution of Your modifications, or\r
+      for any such Derivative Works as a whole, provided Your use,\r
+      reproduction, and distribution of the Work otherwise complies with\r
+      the conditions stated in this License.\r
+\r
+   5. Submission of Contributions. Unless You explicitly state otherwise,\r
+      any Contribution intentionally submitted for inclusion in the Work\r
+      by You to the Licensor shall be under the terms and conditions of\r
+      this License, without any additional terms or conditions.\r
+      Notwithstanding the above, nothing herein shall supersede or modify\r
+      the terms of any separate license agreement you may have executed\r
+      with Licensor regarding such Contributions.\r
+\r
+   6. Trademarks. This License does not grant permission to use the trade\r
+      names, trademarks, service marks, or product names of the Licensor,\r
+      except as required for reasonable and customary use in describing the\r
+      origin of the Work and reproducing the content of the NOTICE file.\r
+\r
+   7. Disclaimer of Warranty. Unless required by applicable law or\r
+      agreed to in writing, Licensor provides the Work (and each\r
+      Contributor provides its Contributions) on an "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
+      implied, including, without limitation, any warranties or conditions\r
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
+      PARTICULAR PURPOSE. You are solely responsible for determining the\r
+      appropriateness of using or redistributing the Work and assume any\r
+      risks associated with Your exercise of permissions under this License.\r
+\r
+   8. Limitation of Liability. In no event and under no legal theory,\r
+      whether in tort (including negligence), contract, or otherwise,\r
+      unless required by applicable law (such as deliberate and grossly\r
+      negligent acts) or agreed to in writing, shall any Contributor be\r
+      liable to You for damages, including any direct, indirect, special,\r
+      incidental, or consequential damages of any character arising as a\r
+      result of this License or out of the use or inability to use the\r
+      Work (including but not limited to damages for loss of goodwill,\r
+      work stoppage, computer failure or malfunction, or any and all\r
+      other commercial damages or losses), even if such Contributor\r
+      has been advised of the possibility of such damages.\r
+\r
+   9. Accepting Warranty or Additional Liability. While redistributing\r
+      the Work or Derivative Works thereof, You may choose to offer,\r
+      and charge a fee for, acceptance of support, warranty, indemnity,\r
+      or other liability obligations and/or rights consistent with this\r
+      License. However, in accepting such obligations, You may act only\r
+      on Your own behalf and on Your sole responsibility, not on behalf\r
+      of any other Contributor, and only if You agree to indemnify,\r
+      defend, and hold each Contributor harmless for any liability\r
+      incurred by, or claims asserted against, such Contributor by reason\r
+      of your accepting any such warranty or additional liability.\r
+\r
+   END OF TERMS AND CONDITIONS\r
+\r
+   APPENDIX: How to apply the Apache License to your work.\r
+\r
+      To apply the Apache License to your work, attach the following\r
+      boilerplate notice, with the fields enclosed by brackets "[]"\r
+      replaced with your own identifying information. (Don't include\r
+      the brackets!)  The text should be enclosed in the appropriate\r
+      comment syntax for the file format. We also recommend that a\r
+      file or class name and description of purpose be included on the\r
+      same "printed page" as the copyright notice for easier\r
+      identification within third-party archives.\r
+\r
+   Copyright [yyyy] [name of copyright owner]\r
+\r
+   Licensed under the Apache License, Version 2.0 (the "License");\r
+   you may not use this file except in compliance with the License.\r
+   You may obtain a copy of the License at\r
+\r
+       http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+\r
diff --git a/include/settingcmd-debug.h b/include/settingcmd-debug.h
new file mode 100755 (executable)
index 0000000..be041a0
--- /dev/null
@@ -0,0 +1,219 @@
+/*
+ * setting
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
+ *
+ * Contact: MyoungJune Park <mj2004.park@samsung.com>
+ *
+ * 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.
+ *
+ */
+/**
+ * @defgroup setting-debug
+ * setting debug utility
+ */
+
+#ifndef _SETTINGCMD_DEBUG_H_
+#define _SETTINGCMD_DEBUG_H_
+
+#include <glib.h>
+
+#define SETTINGCMD_USING_PLATFORM_DBG
+#ifdef SETTINGCMD_USING_PLATFORM_DBG
+#include <dlog.h>
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+
+#define LOG_TAG "SETTING"
+#endif
+
+#define USE_TIMER_UPDATE_TIME_IN_TIME_VIEW
+
+#define SECURITY_SERVER                        1
+
+/* launching */
+#ifdef LAUNCHING_DEBUG_LOG
+#define LAUNCH_SETTINGCMD_IN(fmt, arg...)      LOG(LOG_DEBUG, "LAUNCH", \
+               "[setting:Application:%s:IN]" fmt, __FUNCTION__, ##arg)
+#define LAUNCH_SETTINGCMD_OUT(fmt, arg...) LOG(LOG_DEBUG, "LAUNCH", \
+               "[setting:Application:%s:OUT]" fmt, __FUNCTION__, ##arg)
+#else
+#define LAUNCH_SETTINGCMD_IN(fmt, arg...)
+#define LAUNCH_SETTINGCMD_OUT(fmt, arg...)
+#endif
+
+#if !defined(LOCALEDIR)
+#define LOCALEDIR      _TZ_SYS_RO_APP"/org.tizen.setting/res/locale"
+#endif
+
+#if !defined(EDJDIR)
+#define EDJDIR _TZ_SYS_RO_APP"/org.tizen.setting/res/edje"
+#endif
+
+/*macros to control program flow*/
+
+/* Genlist Update is in progress. */
+#define SETTINGCMD_ENABLE_TRACE
+
+#ifdef SETTINGCMD_ENABLE_TRACE
+
+#ifdef SETTINGCMD_USING_PLATFORM_DBG
+#define SETTINGCMD_TRACE_SECURE_DEBUG(fmt, arg...) do {\
+               SECURE_LOGD("\033[0;32mDEBUG: " fmt "\033[0m\n", ##arg);\
+} while (0)
+
+#define SETTINGCMD_TRACE_DEBUG(fmt, arg...) do {\
+               SECURE_LOGD("\033[0;32mDEBUG: " fmt "\033[0m\n", ##arg);\
+} while (0)
+
+#define SETTINGCMD_TRACE(fmt, arg...) do {\
+               SECURE_LOGI("\033[0;36m" fmt "\033[0m\n", ##arg);\
+} while (0)
+
+#define SETTINGCMD_TRACE_WARNING(fmt, arg...) do {\
+               SECURE_LOGI("\033[0;33mWARRING: " fmt "\033[0m\n", ##arg);\
+} while (0)
+
+#define SETTINGCMD_TRACE_ERROR(fmt, arg...) do {\
+               SECURE_LOGE("\033[0;31mERROR: " fmt "\033[0m\n", ##arg);\
+} while (0)
+
+#define SETTINGCMD_TRACE_BEGIN do {\
+       SECURE_LOGD("\033[0;35mENTER FUNCTION: %s. \033[0m\n", \
+                       __FUNCTION__);\
+} while (0)
+
+#define SETTINGCMD_TRACE_END  do {\
+               SECURE_LOGD("\033[0;35mEXIT FUNCTION: %s. \033[0m\n", \
+                       __FUNCTION__);\
+} while (0)
+
+#else
+
+#define SETTINGCMD_TRACE(fmt, arg...) do {\
+       printf("\n[SETTING]\033[0;36m" fmt "\033[0m\t%s:%d\n", \
+                       ##arg, (char*)(strrchr(__FILE__, '/')+1), __LINE__);\
+} while (0)
+
+#define SETTINGCMD_TRACE_SECURE_DEBUG(fmt, arg...) do {\
+       printf("\n[SETTING]\033[0;32mDEBUG: " fmt "\033[0m\t%s:%d\n", \
+                       ##arg, (char*)(strrchr(__FILE__, '/')+1), __LINE__);\
+} while (0)
+
+
+#define SETTINGCMD_TRACE_DEBUG(fmt, arg...) do {\
+       printf("\n[SETTING]\033[0;32mDEBUG: " fmt "\033[0m\t%s:%d\n", \
+                       ##arg, (char*)(strrchr(__FILE__, '/')+1), __LINE__);\
+} while (0)
+
+#define SETTINGCMD_TRACE_WARNING(fmt, arg...) do {\
+       printf("[SETTING]\033[0;33mWARRING: " fmt \
+                       "\033[0m\t%s:%d\n", ##arg, \
+                       (char*)(strrchr(__FILE__, '/')+1), __LINE__);\
+} while (0)
+
+#define SETTINGCMD_TRACE_ERROR(fmt, arg...) do {\
+       fprintf(stderr, "[SETTING]\033[0;31mERROR: " fmt \
+                       "\033[0m\t%s:%d\n", ##arg, \
+                       (char*)(strrchr(__FILE__, '/')+1), __LINE__);\
+} while (0)
+
+#define SETTINGCMD_TRACE_BEGIN do {\
+       printf("\n[SETTING]\033[0;35mENTER FUNCTION: %s. \033[0m\t%s:%d\n", \
+                               __FUNCTION__, \
+                               (char*)(strrchr(__FILE__, '/')+1), __LINE__);\
+} while (0)
+
+#define SETTINGCMD_TRACE_END  do {\
+       printf("\n[SETTING]\033[0;35mEXIT FUNCTION: %s. \033[0m\t%s:%d\n", \
+                               __FUNCTION__, \
+                               (char*)(strrchr(__FILE__, '/')+1), __LINE__);\
+} while (0)
+
+#endif
+
+#else
+
+#define SETTINGCMD_TRACE(fmt, arg...) do {} while (0)
+#define SETTINGCMD_TRACE_SECURE_DEBUG(fmt, arg...) do {} while (0)
+#define SETTINGCMD_TRACE_DEBUG(fmt, arg...) do {} while (0)
+#define SETTINGCMD_TRACE_WARNING(fmt, arg...) do {} while (0)
+#define SETTINGCMD_TRACE_ERROR(fmt, arg...) do {} while (0)
+#define SETTINGCMD_TRACE_BEGIN do {} while (0)
+#define SETTINGCMD_TRACE_END do {} while (0)
+
+#endif
+
+#define settingcmd_retvm_if(expr, val, fmt, arg...) do { \
+       if (expr) { \
+               SETTINGCMD_TRACE_ERROR(fmt, ##arg); \
+               return (val); \
+       } \
+} while (0)
+
+#define settingcmd_retm_if(expr, fmt, arg...) do { \
+       if (expr) { \
+               SETTINGCMD_TRACE_ERROR(fmt, ##arg); \
+               return; \
+       } \
+} while (0)
+
+#ifndef retm_if
+#define retm_if settingcmd_retm_if
+#endif
+#ifndef retvm_if
+#define retvm_if settingcmd_retvm_if
+#endif
+
+#ifndef retv_if
+#define retv_if(expr, val) do { \
+       if (expr) { \
+               SETTINGCMD_TRACE_ERROR("(%s)", #expr); \
+               return (val); \
+       } \
+} while (0)
+#endif
+
+#ifndef ret_if
+#define ret_if(expr) do { \
+       if (expr) { \
+               SETTINGCMD_TRACE_ERROR("(%s)", #expr); \
+               return ; \
+       } \
+} while (0)
+#endif
+
+#ifndef warn_if
+#define warn_if(expr, fmt, arg...) do { \
+       if (expr) { \
+               SETTINGCMD_TRACE_ERROR(fmt, ##arg); \
+       } \
+} while (0)
+#endif
+
+
+#define __FREE(del, arg) do { \
+       if (arg) { \
+               /*cast any argument to (void*) to avoid build warring*/\
+               del((void *)(arg)); \
+               arg = NULL; \
+       } \
+} while (0)
+#define FREE(arg) __FREE(free, arg)
+#define G_FREE(arg) __FREE(g_free, arg)
+
+
+
+#endif /* _SETTINGCMD_DEBUG_H_ */
diff --git a/packaging/org.tizen.setting-cmd.manifest b/packaging/org.tizen.setting-cmd.manifest
new file mode 100755 (executable)
index 0000000..b4a4109
--- /dev/null
@@ -0,0 +1,8 @@
+<manifest>
+       <request>
+               <domain name="_" />
+       </request>
+    <assign>
+        <filesystem path="/usr/bin/setting-cmd" label="User::Shell" exec_label="User"/>
+    </assign>
+</manifest>
diff --git a/packaging/org.tizen.setting-cmd.spec b/packaging/org.tizen.setting-cmd.spec
new file mode 100755 (executable)
index 0000000..2e6d8cd
--- /dev/null
@@ -0,0 +1,142 @@
+Name:       org.tizen.setting-cmd
+Summary:    Setting application
+Version:    0.0.1
+Release:    0
+Group:      Applications/Core Applications
+License:    Apache-2.0
+Source0:    %{name}-%{version}.tar.gz
+Source1001:    %{name}.manifest
+
+BuildRequires: pkgconfig(app2sd)
+BuildRequires: pkgconfig(capi-media-image-util)
+BuildRequires:  pkgconfig(accounts-svc)
+BuildRequires:  pkgconfig(alarm-service)
+BuildRequires:  pkgconfig(appcore-common)
+BuildRequires:  pkgconfig(appcore-efl)
+BuildRequires:  pkgconfig(appsvc)
+BuildRequires:  pkgconfig(aul)
+BuildRequires:  pkgconfig(auth-fw)
+BuildRequires:  pkgconfig(callmgr_client)
+BuildRequires:  pkgconfig(bundle)
+BuildRequires:  pkgconfig(capi-appfw-event)
+BuildRequires:  pkgconfig(capi-appfw-preference)
+BuildRequires:  pkgconfig(capi-appfw-app-manager)
+BuildRequires:  pkgconfig(capi-appfw-package-manager)
+BuildRequires:  pkgconfig(capi-base-utils-i18n)
+BuildRequires:  pkgconfig(capi-content-media-content)
+BuildRequires:  pkgconfig(capi-media-metadata-extractor)
+BuildRequires:  pkgconfig(capi-media-player)
+BuildRequires:  pkgconfig(capi-media-sound-manager)
+BuildRequires:  pkgconfig(capi-network-bluetooth)
+BuildRequires:  pkgconfig(capi-network-connection)
+BuildRequires:  pkgconfig(capi-network-wifi)
+BuildRequires:  pkgconfig(capi-network-wifi-manager)
+BuildRequires:  pkgconfig(capi-system-device)
+BuildRequires:  pkgconfig(capi-system-info)
+BuildRequires:  pkgconfig(capi-system-runtime-info)
+BuildRequires:  pkgconfig(capi-system-sensor)
+BuildRequires:  pkgconfig(capi-system-system-settings)
+BuildRequires:  pkgconfig(capi-telephony)
+BuildRequires:  pkgconfig(chromium-efl)
+BuildRequires:  pkgconfig(deviced)
+BuildRequires:  pkgconfig(dlog)
+BuildRequires:  pkgconfig(dpm)
+BuildRequires:  pkgconfig(efl-extension)
+BuildRequires:  pkgconfig(edbus)
+BuildRequires:  pkgconfig(elementary)
+BuildRequires:  pkgconfig(feedback)
+BuildRequires:  pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(iniparser)
+BuildRequires:  pkgconfig(json-glib-1.0)
+BuildRequires:  pkgconfig(ode)
+BuildRequires:  pkgconfig(libtzplatform-config)
+BuildRequires:  pkgconfig(libxml-2.0)
+BuildRequires:  pkgconfig(openssl)
+BuildRequires:  pkgconfig(pkgmgr)
+BuildRequires:  pkgconfig(pkgmgr-info)
+BuildRequires:  pkgconfig(privilege-info)
+BuildRequires:  pkgconfig(security-privilege-manager)
+BuildRequires:  pkgconfig(sqlite3)
+BuildRequires:  pkgconfig(storage)
+BuildRequires:  pkgconfig(tapi)
+BuildRequires:  pkgconfig(tts)
+BuildRequires:  pkgconfig(tts-setting)
+BuildRequires:  pkgconfig(ui-gadget-1)
+BuildRequires:  pkgconfig(vconf)
+BuildRequires:  pkgconfig(context)
+BuildRequires:  pkgconfig(minizip)
+BuildRequires:  pkgconfig(capi-network-stc)
+BuildRequires: pkgconfig(network)
+BuildRequires: pkgconfig(capi-network-bluetooth)
+BuildRequires:  libcap-devel
+BuildRequires:  cmake
+BuildRequires:  edje-tools
+BuildRequires:  gettext-tools
+BuildRequires:  hash-signer
+
+%description
+Setting command application
+
+%prep
+%setup -q
+cp %{SOURCE1001} .
+mkdir -p %{_datadir}
+
+
+%build
+%define PREFIX         %{_prefix}/apps/%{name}
+%define OPTPREFIX      %{TZ_SYS_RW_APP}/%{name}
+%define RESDIR         %{PREFIX}/res
+%define CONFIGDIR      %{PREFIX}/def_config
+%define IMAGEDIR       %{RESDIR}/images
+
+CFLAGS+=" -fvisibility=hidden ";export CFLAGS
+CXXFLAGS+=" -fvisibility=hidden ";export CFLAGS
+
+LDFLAGS+="-Wl,--rpath=%{PREFIX}/lib -Wl,--hash-style=both -Wl,--as-needed";export LDFLAGS
+
+%ifarch %{arm}
+export CFLAGS="$CFLAGS -DTIZEN_BUILD_TARGET"
+%else
+export CFLAGS="$CFLAGS -DTIZEN_BUILD_EMULATOR"
+%endif
+
+%ifarch %{arm}
+       #cmake . -DCMAKE_INSTALL_PREFIX=%{PREFIX} -DARCH=arm -DLIBDIR=%{_libdir} -DINCLUDEDIR=%{_includedir} \
+       cmake . -DARCH=arm -DLIBDIR=%{_libdir} -DINCLUDEDIR=%{_includedir} -DBIN_DIR=%{_bindir} \
+%else
+       #cmake . -DCMAKE_INSTALL_PREFIX=%{PREFIX} -DARCH=x86 -DLIBDIR=%{_libdir} -DINCLUDEDIR=%{_includedir} \
+       cmake . -DARCH=x86 -DLIBDIR=%{_libdir} -DINCLUDEDIR=%{_includedir} -DBIN_DIR=%{_bindir} \
+%endif
+               -DTZ_SYS_DATA=%{TZ_SYS_DATA} \
+               -DTZ_SYS_ETC=%{TZ_SYS_ETC} \
+               -DTZ_SYS_SHARE=%{TZ_SYS_SHARE} \
+               -DTZ_SYS_RO_APP=%{TZ_SYS_RO_APP} \
+               -DTZ_SYS_RW_APP=%{TZ_SYS_RW_APP} \
+               -DTZ_SYS_RO_UG=%{TZ_SYS_RO_UG} \
+               -DTZ_SYS_RO_ICONS=%{TZ_SYS_RO_ICONS} \
+               -DTZ_SYS_MEDIA=%{TZ_SYS_MEDIA} \
+               -DTZ_SYS_DB=%{TZ_SYS_DB} \
+               -DTZ_SYS_GLOBALUSER_DATA=%{TZ_SYS_GLOBALUSER_DATA}
+# build all
+make
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+%clean
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%files 
+%defattr(-,root,root,-)
+%manifest %{name}.manifest
+#/usr/local/bin/setting-cmd
+#/usr/bin/setting-cmd
+%{_bindir}/setting-cmd
+#%{_libdir}/lib*.so
+#%{_libdir}/lib*.so.*
+
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..6914b23
--- /dev/null
@@ -0,0 +1,77 @@
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs_main REQUIRED
+                                         elementary
+                                         dlog
+                                         capi-appfw-application
+                                         capi-system-system-settings
+                                         efl-extension
+                                         libtzplatform-config
+                                         vconf
+                                         capi-system-info
+                                         capi-media-sound-manager
+                                         capi-network-bluetooth
+                                         capi-content-media-content
+                                         capi-system-runtime-info
+                                         capi-network-wifi-manager
+                                         storage
+                                         pkgmgr
+                                         capi-appfw-package-manager
+                                         capi-telephony
+                                         deviced
+                                         capi-appfw-application
+                                         capi-appfw-app-manager
+                                         capi-appfw-package-manager
+                                         capi-system-device
+                                         pkgmgr
+                                         capi-context
+                                         capi-network-stc
+                                         capi-appfw-preference
+                                 )
+
+FOREACH(flag ${pkgs_main_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_C_FLAGS_DEBUG "-O0 -g")
+SET(BUILD_ARCH "${ARCH}")
+
+IF("${BUILD_ARCH}" STREQUAL "arm")
+       ADD_DEFINITIONS("-DTARGET")
+       MESSAGE("********************** add -DTARGET")
+ENDIF("${BUILD_ARCH}" STREQUAL "arm")
+
+ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
+ADD_DEFINITIONS("-DRESDIR=\"${RESDIR}\"")
+ADD_DEFINITIONS("-DDATADIR=\"${DATADIR}\"")
+ADD_DEFINITIONS("-DLOCALEDIR=\"${LOCALEDIR}\"")
+ADD_DEFINITIONS("-DICONDIR=\"${ICONDIR}\"")
+ADD_DEFINITIONS("-DEDJEDIR=\"${EDJEDIR}\"")
+ADD_DEFINITIONS("-DSLP_DEBUG")
+ADD_DEFINITIONS("-DSETTING_PLUGIN")
+ADD_DEFINITIONS("-fpie")
+
+ADD_DEFINITIONS("-DXP_UNIX")
+
+SET(BIN_NAME "setting-cmd")
+
+ADD_EXECUTABLE(${BIN_NAME}
+       ./setting_cmd.c
+       ./sc_common.c
+       ./sc_aboutdevice.c
+       ./sc_sound.c
+       ./sc_display.c
+       ./sc_apps.c
+       ./sc_datetime.c
+       ./sc_wifi.c
+       ./sc_bluetooth.c
+       ./sc_airplane.c
+       ./sc_storage.c
+       ./sc_battery.c
+       ./sc_datausage.c
+       )
+
+# dmalloc
+TARGET_LINK_LIBRARIES(${BIN_NAME} ${pkgs_main_LDFLAGS} -pie)
+
+INSTALL(TARGETS ${BIN_NAME} DESTINATION ${BIN_DIR})
+
diff --git a/src/sc_aboutdevice.c b/src/sc_aboutdevice.c
new file mode 100755 (executable)
index 0000000..de66558
--- /dev/null
@@ -0,0 +1,642 @@
+#include "sc_aboutdevice.h"
+#include "sc_common.h"
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/time.h>
+#include <limits.h>
+#include <unistd.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <vconf.h>
+#include <vconf-internal-keys.h>
+
+#include <system_info.h>
+#include <runtime_info.h>
+#include <telephony.h>
+#include <bluetooth.h>
+#include <wifi-manager.h>
+
+#include <storage.h>
+
+/*---------------------------------------------------------------------------------------------------------------------------*/
+/* These codes are from setting app */
+
+#define SETTING_TRACE(fmt, arg...) do {} while (0)
+#define SETTING_TRACE_SECURE_DEBUG(fmt, arg...) do {} while (0)
+#define SETTING_TRACE_DEBUG(fmt, arg...) do {} while (0)
+#define SETTING_TRACE_WARNING(fmt, arg...) do {} while (0)
+#define SETTING_TRACE_BEGIN do {} while (0)
+#define SETTING_TRACE_END do {} while (0)
+
+#define __FREE(del, arg) do { \
+       if (arg) { \
+               /*cast any argument to (void*) to avoid build warring*/\
+               del((void *)(arg)); \
+               arg = NULL; \
+       } \
+} while (0)
+#define FREE(arg) __FREE(free, arg)
+
+#define SETTING_ABOUT_POWER_SUPPLY_PATH "/sys/class/power_supply"
+#define SETTING_ABOUT_STAT_PATH "/proc/stat"
+#define MAX_COMMON_BUFFER_LEN          1024
+
+
+
+/**
+ * @brief get Model Name.
+ *             - No ini: Unavailable
+ *             - I9500 @ target: GT-I9500
+ *             - I9500 @ emul: SDK
+ *             - SLP   @ target: GT-SLP
+ *             - SLP   @ emul: SDK
+ *
+ * @param szStr the buffer for store the model name
+ * @param nSize buffer size
+ */
+static void __get_phone_model_name(char *szStr, int nSize)
+{
+       if (szStr == NULL)
+               eprintf("szStr parameter is NULL\n");
+
+       char *value = NULL;
+       int ret = system_info_get_platform_string(
+                       "http://tizen.org/system/model_name", &value);
+       SETTING_TRACE("value : %s", value);
+       if (ret != SYSTEM_INFO_ERROR_NONE) {
+               eprintf("fail to call system_info_get_platform_string");
+               FREE(value);
+               snprintf(szStr, nSize, "%s", "Unavailable");
+               return;
+       }
+
+       if (value)
+               snprintf(szStr, nSize, "%s", value);
+       else
+               snprintf(szStr, nSize, "%s", "Unavailable");
+
+
+       FREE(value);
+}
+
+/**
+ * @brief get software version.
+ *
+ * @param szStr the buffer for store SW version
+ * @param nSize buffer size
+ */
+static void __get_sw_version(char *szStr, int nSize)
+{
+       if (szStr == NULL)
+               eprintf("szStr parameter is NULL\n");
+
+       char *version = NULL;
+       int ret = system_info_get_platform_string(
+                       "http://tizen.org/feature/platform.version", &version);
+       if (ret != SYSTEM_INFO_ERROR_NONE) {
+               eprintf("fail to call system_info_get_platform_string");
+               FREE(version);
+               snprintf(szStr, nSize, "%s", "Unavailable");
+               return;
+       }
+
+       snprintf(szStr, nSize, "TIZEN %s", version);
+
+       FREE(version);
+}
+
+/**
+ * @brief get CPU info.
+ *
+ * @param szStr the buffer for store CPU info
+ * @param nSize buffer size
+ *
+ * @return -1 if getting CPU info fails, otherwise 0 is returned
+ */
+static int __stat_get_cpuinfo(char *szStr, int nSize)
+{
+
+       int ret = 0;
+
+       char *cpu_name = NULL;
+       ret = system_info_get_platform_string(
+               "http://tizen.org/system/platform.processor", &cpu_name);
+
+       if (0 != ret) {
+               snprintf(szStr, nSize, "%s", "Unavailable");
+               return -1;
+       }
+
+       snprintf(szStr, nSize, "%s", cpu_name);
+       free(cpu_name);
+       return 0;
+}
+/*---------------------------------------------------------------------------------------------------------------------------*/
+#define MAX_DISPLAY_STR_LEN_ON_PHONE_INFO      256
+
+static int menufunc_ad_name(int argc, char *argv[])
+{
+       char *name_value = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR);
+       printf("\tName : ");
+       printf("%s\n", name_value);
+       free(name_value);
+
+       return MEMUFUNC_ERR_NONE;
+}
+
+static int menufunc_ad_mn(int argc, char *argv[])
+{
+
+       char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO];
+       str[0] = '\0';
+       __get_phone_model_name(str, MAX_DISPLAY_STR_LEN_ON_PHONE_INFO);
+       printf("\tModel number : ");
+       printf("%s\n", str);
+
+       return MEMUFUNC_ERR_NONE;
+}
+
+static int menufunc_ad_ver(int argc, char *argv[])
+{
+
+       char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO];
+       str[0] = '\0';
+       __get_sw_version(str, MAX_DISPLAY_STR_LEN_ON_PHONE_INFO);
+       printf("\tModel number : ");
+       printf("%s\n", str);
+
+       return MEMUFUNC_ERR_NONE;
+}
+
+static int menufunc_ad_cpu(int argc, char *argv[])
+{
+
+       char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO];
+       str[0] = '\0';
+       __stat_get_cpuinfo(str, MAX_DISPLAY_STR_LEN_ON_PHONE_INFO);
+       printf("\tModel number : ");
+       printf("%s\n", str);
+
+       return MEMUFUNC_ERR_NONE;
+}
+
+static int menufunc_ad_ram(int argc, char *argv[])
+{
+
+       char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO];
+       str[0] = '\0';
+       runtime_memory_info_s mem_info = {0};
+       int ret_value = runtime_info_get_system_memory_info(&mem_info);
+
+       if (RUNTIME_INFO_ERROR_NONE == ret_value) {
+               float ram_total_gb = mem_info.total / 1000000.0;
+               snprintf(str, sizeof(str), "%0.1fGB", ram_total_gb);
+       }
+       printf("\tRAM : ");
+       printf("%s\n", str);
+
+       return MEMUFUNC_ERR_NONE;
+}
+
+static int menufunc_ad_res(int argc, char *argv[])
+{
+
+       char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO];
+       str[0] = '\0';
+       int dim1, dim2;
+       int ret_value = system_info_get_platform_int(
+                                       "http://tizen.org/feature/screen.width",
+                                       &dim1);
+       if (SYSTEM_INFO_ERROR_NONE == ret_value) {
+               system_info_get_platform_int(
+                               "http://tizen.org/feature/screen.height",
+                               &dim2);
+               if (SYSTEM_INFO_ERROR_NONE == ret_value)
+                       snprintf(str, sizeof(str), "%d x %d", dim1, dim2);
+       }
+       printf("\tResolution : ");
+       printf("%s\n", str);
+
+       return MEMUFUNC_ERR_NONE;
+}
+/* sim_number is started from 1, ex) SIM1, SIM2, SIM3 ... */
+static int _get_sim_phone_number(int sim_number, char * str, int str_size)
+{
+       telephony_handle_list_s tel_h_list;
+       char *phone_num = NULL;
+       int ret = 0;
+       if (telephony_init(&tel_h_list) != TELEPHONY_ERROR_NONE) {
+               eprintf("telephony_init failed");
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       if (tel_h_list.count < sim_number-1) {
+               printf("\tThere is no SIM%d card\n", sim_number);
+               if (telephony_deinit(&tel_h_list) != TELEPHONY_ERROR_NONE) {
+                       eprintf("telephony_deinit failed");
+                       return MEMUFUNC_ERR_NORMAL;
+               }
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       ret = telephony_sim_get_subscriber_number(tel_h_list.handle[sim_number-1], &phone_num);
+       if (!ret && (phone_num != NULL)) {
+               snprintf(str, str_size, "%s", phone_num);
+               free(phone_num);
+       } else {
+               printf("\tThere is no SIM%d card, ret:%d phone_num addr:0x%x\n", sim_number, ret, (unsigned int)phone_num);
+               if (telephony_deinit(&tel_h_list) != TELEPHONY_ERROR_NONE) {
+                       eprintf("telephony_deinit failed");
+                       return MEMUFUNC_ERR_NORMAL;
+               }
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       if (telephony_deinit(&tel_h_list) != TELEPHONY_ERROR_NONE) {
+               eprintf("telephony_deinit failed");
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       return MEMUFUNC_ERR_NONE;
+}
+
+
+static int menufunc_ad_sim1(int argc, char *argv[])
+{
+       char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO];
+       int ret = _get_sim_phone_number(1, str, sizeof(str));
+       if (ret != MEMUFUNC_ERR_NONE)
+               return ret;
+       printf("\tSIM1 Phone Number : ");
+       printf("%s\n", str);
+
+       return ret;
+}
+
+static int menufunc_ad_sim2(int argc, char *argv[])
+{
+       char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO];
+       int ret = _get_sim_phone_number(2, str, sizeof(str));
+       if (ret != MEMUFUNC_ERR_NONE)
+               return ret;
+       printf("\tSIM2 Phone Number : ");
+       printf("%s\n", str);
+       return ret;
+}
+
+/* sim_number is started from 1, ex) SIM1, SIM2, SIM3 ... */
+static int _get_sim_ime(int sim_number, char * str, int str_size)
+{
+       telephony_handle_list_s tel_h_list;
+       char *ime_buffer = NULL;
+       int ret = 0;
+       if (telephony_init(&tel_h_list) != TELEPHONY_ERROR_NONE) {
+               eprintf("telephony_init failed");
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       if (tel_h_list.count < sim_number-1) {
+               printf("\tThere is no SIM%d card\n", sim_number);
+               if (telephony_deinit(&tel_h_list) != TELEPHONY_ERROR_NONE) {
+                       eprintf("telephony_deinit failed");
+                       return MEMUFUNC_ERR_NORMAL;
+               }
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       ret = telephony_modem_get_imei(tel_h_list.handle[sim_number-1], &ime_buffer);
+       if (!ret && (ime_buffer != NULL)) {
+               snprintf(str, str_size, "%s", ime_buffer);
+               free(ime_buffer);
+       } else {
+               printf("\tThere is no SIM%d card, ret:%d ime_buffer addr:0x%x\n", sim_number, ret, (unsigned int)ime_buffer);
+               if (telephony_deinit(&tel_h_list) != TELEPHONY_ERROR_NONE) {
+                       eprintf("telephony_deinit failed");
+                       return MEMUFUNC_ERR_NORMAL;
+               }
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       if (telephony_deinit(&tel_h_list) != TELEPHONY_ERROR_NONE) {
+               eprintf("telephony_deinit failed");
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       return MEMUFUNC_ERR_NONE;
+}
+
+static int menufunc_ad_ime1(int argc, char *argv[])
+{
+       char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO];
+       int ret = _get_sim_ime(1, str, sizeof(str));
+       if (ret != MEMUFUNC_ERR_NONE)
+               return ret;
+       printf("\tIME1 : ");
+       printf("%s\n", str);
+       return ret;
+}
+
+static int menufunc_ad_ime2(int argc, char *argv[])
+{
+       char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO];
+       int ret = _get_sim_ime(2, str, sizeof(str));
+       if (ret != MEMUFUNC_ERR_NONE)
+               return ret;
+       printf("\tIME2 : ");
+       printf("%s\n", str);
+       return ret;
+}
+
+static int menufunc_ad_bta(int argc, char *argv[])
+{
+       char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO];
+
+       int ret = bt_initialize();
+
+       char *local_address = NULL;
+       ret = bt_adapter_get_address(&local_address);
+
+       bt_deinitialize();
+
+       if (ret != BT_ERROR_NONE) {
+               if (ret == BT_ERROR_NOT_ENABLED)
+                       snprintf(str, sizeof(str), "Bluetooth is disabled!\n");
+               else
+                       snprintf(str, sizeof(str), "Bluetooth is unavailable!\n");
+               eprintf("failed to get BT address, error code: %d\n",
+                               ret);
+       } else {
+               snprintf(str, sizeof(str), "%s", local_address);
+               free(local_address);
+       }
+       printf("\tBluetooth address : ");
+       printf("%s\n", str);
+       return MEMUFUNC_ERR_NONE;
+}
+
+static int menufunc_ad_wfa(int argc, char *argv[])
+{
+       char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO];
+
+       wifi_manager_h wifi_handle = NULL;
+       char *mac_addr = NULL;
+       int ret;
+
+       /* get wifi handle */
+       ret = wifi_manager_initialize(&wifi_handle);
+       if (ret != WIFI_MANAGER_ERROR_NONE)
+               return MEMUFUNC_ERR_NORMAL;
+
+       /* get wifi mac address */
+       ret = wifi_manager_get_mac_address(wifi_handle, &mac_addr);
+       if (ret == WIFI_MANAGER_ERROR_NONE && mac_addr) {
+               snprintf(str, sizeof(str), "%s", mac_addr);
+               free(mac_addr);
+       } else {
+               snprintf(str, sizeof(str), "WIFI is unavailable!\n");
+               eprintf("failed to get WIFI address, error code: %d\n",
+                               ret);
+       }
+
+       /* release wifi handle */
+       ret = wifi_manager_deinitialize(wifi_handle);
+       if (ret != WIFI_MANAGER_ERROR_NONE)
+               return MEMUFUNC_ERR_NORMAL;
+       printf("\tWIFI address : ");
+       printf("%s\n", str);
+       return MEMUFUNC_ERR_NONE;
+}
+
+static int menufunc_ad_sto(int argc, char *argv[])
+{
+       char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO];
+       long long int total = 0;
+       long long int avail = 0;
+       struct statvfs internal;
+       struct statvfs external;
+
+       if (storage_get_internal_memory_size(&internal) < 0) {
+               eprintf("Fail to get internal memory size\n");
+               snprintf(str, sizeof(str), "internal storage is unavailable!\n");
+               return MEMUFUNC_ERR_NORMAL;
+       } else {
+               total = (long long int)internal.f_frsize
+                               * (long long int)internal.f_blocks;
+               avail = (long long int)internal.f_bsize
+                               * (long long int)internal.f_bavail;
+       }
+
+       if (storage_get_external_memory_size(&external) < 0) {
+               eprintf("Fail to get external memory size\n");
+       } else {
+               total += (long long int)external.f_frsize
+                               * (long long int)external.f_blocks;
+               avail += (long long int)external.f_bsize
+                               * (long long int)external.f_bavail;
+       }
+
+       /* check if values are appropriate*/
+       if (total < 0 || avail < 0 || total < avail) {
+               eprintf("Fail to get internal memory size\n");
+               snprintf(str, sizeof(str), "external storage is unavailable!\n");
+               return MEMUFUNC_ERR_NORMAL;
+       }
+       snprintf(str, sizeof(str), "%0.1fGB available (Total %0.1fGB)",
+               (double)(avail / 1000000000.0), (double)(total / 1000000000.0));
+       printf("\tStorage Size : ");
+       printf("%s\n", str);
+
+       return MEMUFUNC_ERR_NONE;
+}
+
+static int menufunc_ad_batt(int argc, char *argv[])
+{
+       int val = -1;
+       char file[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO] = { 0, };
+       snprintf(file, MAX_DISPLAY_STR_LEN_ON_PHONE_INFO, "%s/%s/%s",
+                       SETTING_ABOUT_POWER_SUPPLY_PATH, "battery", "capacity");
+
+       char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO];
+       char buf[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO] = { 0, };
+       int fd = 0;
+       int r = 0;
+
+       fd = open(file, O_RDONLY);
+       if (fd != -1) {
+               r = read(fd, buf, MAX_DISPLAY_STR_LEN_ON_PHONE_INFO);
+               if ((r >= 0) && (r < MAX_DISPLAY_STR_LEN_ON_PHONE_INFO)) {
+                       buf[r] = '\0';
+                       val = atoi(buf);
+                       snprintf(str, sizeof(str), "%d%%", val);
+               } else {
+                       eprintf("read file fail\n");
+                       snprintf(str, sizeof(str), "%s unavailable!\n", SETTING_ABOUT_POWER_SUPPLY_PATH);
+               }
+
+               close(fd);
+               printf("\tBattery percentage : ");
+               printf("%s\n", str);
+       } else {
+               eprintf("open file fail\n");
+               snprintf(str, sizeof(str), "%s unavailable!\n", SETTING_ABOUT_POWER_SUPPLY_PATH);
+       }
+       return MEMUFUNC_ERR_NONE;
+}
+
+static int __stat_get_cpu_usage(float *usr_pct, float *sys_pct)
+{
+
+       /*      default value */
+       *usr_pct = 0.0;
+       *sys_pct = 0.0;
+       static unsigned long long usr_time = 0, /*nice_time = 0,*/sys_time = 0;
+       static unsigned long long old_usr = 0, /*old_nice = 0,*/old_sys = 0;
+       static struct timeval old_tv, cur_tv;
+       unsigned long long elapsed_tick;
+       long tick_per_sec;
+       long cpu_num;
+       FILE *fp = NULL;
+       int ret = 0;
+
+       tick_per_sec = sysconf(_SC_CLK_TCK);
+       cpu_num = sysconf(_SC_NPROCESSORS_ONLN);
+
+       if (cpu_num < 1)
+               cpu_num = 1;
+
+       gettimeofday(&cur_tv, NULL);
+       fp = fopen(SETTING_ABOUT_STAT_PATH, "r");
+       if (fp == NULL) {
+               eprintf("fp == NULL\n");
+               return -ENOENT;
+       }
+
+       char cpu_info[MAX_COMMON_BUFFER_LEN] = { 0, };
+       char *cpu_info_p = fgets(cpu_info, MAX_COMMON_BUFFER_LEN, fp);
+
+       if (cpu_info_p == NULL) {
+               eprintf("fgets failed\n");
+               fclose(fp); /* free - code */
+               return -ENOENT;
+       }
+
+       char *substr = NULL;
+       unsigned long long tmp_long = 0;
+       int i = 0;
+       /* split cpu_info, get 3 numbers headmost*/
+       while ((substr = strsep(&cpu_info_p, " \t")) != NULL) {
+               char *endptr = NULL;
+               tmp_long = strtoull(substr, &endptr, 10);
+               if (tmp_long != 0 && tmp_long != ULLONG_MAX) {
+                       switch (i) {
+                       case 0:
+                               usr_time = tmp_long;
+                               break;
+                       case 1:
+                               /*nice_time = tmp_long;*/
+                               break;
+                       case 2:
+                               sys_time = tmp_long;
+                               break;
+                       default:
+                               break;
+                       }
+                       i++;
+               }
+               if (i >= 3)
+                       break;
+       }
+
+       fclose(fp);
+       fp = NULL;
+       if (old_usr == 0) {
+               ret = -EAGAIN;
+               //eprintf("old_usr == 0\n");
+               goto out;
+       }
+
+       elapsed_tick = (unsigned long long)(((long long)cur_tv.tv_sec
+                       - old_tv.tv_sec) * tick_per_sec
+                       + (((long long)cur_tv.tv_usec - old_tv.tv_usec)
+                                       * tick_per_sec) / 1000000);
+
+       /* REMOVE BS */
+       if (elapsed_tick != 0) {
+               *usr_pct = ((float)(usr_time - old_usr) * 100 / elapsed_tick)
+                               / cpu_num;
+       } else {
+               *usr_pct = 0;
+       }
+       /* REMOVE BS */
+       if (elapsed_tick != 0) {
+               *sys_pct = ((float)(sys_time - old_sys) * 100 / elapsed_tick)
+                               / cpu_num;
+       } else {
+               *sys_pct = 0;
+       }
+
+out:
+       old_usr = usr_time;
+       /*old_nice = nice_time; */
+       old_sys = sys_time;
+       old_tv = cur_tv;
+
+       return ret;
+}
+
+static int menufunc_ad_cpuu(int argc, char *argv[])
+{
+       float usr = 0.0;
+       float sys = 0.0;
+       int ret = 0;
+       printf("\tWhen you want to stop checking CPU usage,\n");
+       printf("\tPress Ctrl+C\n\n");
+
+       while(1) {
+               ret = __stat_get_cpu_usage(&usr, &sys);
+               if (ret != 0)
+                       continue;
+               printf("\tCPU usage : ");
+               printf("%.0f%%\n", usr + sys);
+               sleep(1);
+       }
+       return ret;
+}
+
+MenuItem ad_menulist[] ={
+       {"name", "Name", menufunc_ad_name},
+       {"mn", "Model number", menufunc_ad_mn},
+       {"ver", "Tizen version", menufunc_ad_ver},
+       {"cpu", "CPU", menufunc_ad_cpu},
+       {"ram", "RAM", menufunc_ad_ram},
+       {"res", "Resolution", menufunc_ad_res},
+       {"sim1", "SIM1 Phone Number", menufunc_ad_sim1},
+       {"sim2", "SIM2 Phone Number", menufunc_ad_sim2},
+       {"ime1", "IME1", menufunc_ad_ime1},
+       {"ime2", "IME2", menufunc_ad_ime2},
+       {"bta", "Bluetooth address", menufunc_ad_bta},
+       {"wfa", "Wi-Fi MAC Address", menufunc_ad_wfa},
+       {"sto", "Storage", menufunc_ad_sto},
+       {"batt", "Battery percentage", menufunc_ad_batt},
+       {"cpuu", "CPU usage", menufunc_ad_cpuu}
+};
+
+
+
+int menufunc_ad(int argc, char *argv[])
+{
+       printf("\n");
+
+       printf("Seting Command - About device\n\n");
+       int menucount = sizeof(ad_menulist)/sizeof(MenuItem);
+
+       int result = runMenulist(argc, argv, "setting_cmd ad", ad_menulist, menucount);
+       return result;
+}
+
+
diff --git a/src/sc_aboutdevice.h b/src/sc_aboutdevice.h
new file mode 100755 (executable)
index 0000000..f363cd7
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef __SC_ABOUTDEVICE_H_\r
+#define __SC_ABOUTDEVICE_H_\r
+\r
+#include "settingcmd_def.h"\r
+\r
+\r
+int menufunc_ad(int argc, char *argv[]);\r
+\r
+#endif         /* __SC_ABOUTDEVICE_H_ */\r
diff --git a/src/sc_airplane.c b/src/sc_airplane.c
new file mode 100755 (executable)
index 0000000..64d993f
--- /dev/null
@@ -0,0 +1,40 @@
+#include "sc_airplane.h"
+#include "sc_common.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <vconf.h>
+#include <vconf-internal-keys.h>
+#include <system_settings.h>
+
+static int menufunc_am_st(int argc, char *argv[])
+{
+    int ret = MEMUFUNC_ERR_NONE;
+
+    bool ret_state = false;
+    ret = system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, &ret_state);
+    if( ret != MEMUFUNC_ERR_NONE ) {
+        eprintf("\tFlight mode get fail\n");
+    } else {
+        printf("\tFlight mode : %s\n", ret_state? "On" : "Off");
+    }
+
+    return ret;
+}
+
+MenuItem am_menulist[] ={
+       {"st", "State", menufunc_am_st}
+};
+
+int menufunc_am(int argc, char *argv[])
+{
+       printf("\n");
+
+       printf("Seting Command - Airplane mode\n\n");
+       int menucount = sizeof(am_menulist)/sizeof(MenuItem);
+
+       int result = runMenulist(argc, argv, "setting_cmd am", am_menulist, menucount);
+       return result;
+}
+
diff --git a/src/sc_airplane.h b/src/sc_airplane.h
new file mode 100755 (executable)
index 0000000..dfe3c10
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef __SC_AIRPLANE_H_
+#define __SC_AIRPLANE_H_
+
+#include "settingcmd_def.h"
+
+
+int menufunc_am(int argc, char *argv[]);
+
+#endif         /* __SC_AIRPLANE_H_ */
diff --git a/src/sc_apps.c b/src/sc_apps.c
new file mode 100755 (executable)
index 0000000..a2e322c
--- /dev/null
@@ -0,0 +1,225 @@
+#include "sc_apps.h"
+#include "sc_common.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+//#include <system_settings.h>
+//#include <vconf.h>
+//#include <vconf-internal-keys.h>
+
+#include <system_info.h>
+
+#include <package_manager.h>
+#include <app_manager.h>
+#include <package-manager.h>
+
+#include <libgen.h>
+
+#include <aul.h>
+#include <Ecore.h>
+#include <Ecore_File.h>
+#include <Eina.h>
+
+typedef struct {
+       char *appid;
+       char *pkgid;
+       char *label;
+       char *icon_path;
+       bool is_enabled;
+       bool is_running;
+       long long int ram_used; /*kB*/
+} app_node;
+
+typedef struct {
+       char *pkgid;
+       char *label;
+       char *icon_path;
+       long long package_size; /*kB/MB*/
+       bool is_preloaded;
+       bool size_update_in_progress;
+} package_node;
+
+enum {
+       APPMGR_SORT_ATOZ, APPMGR_SORT_ZTOA, APPMGR_SORT_SIZE,
+};
+
+int g_sorttype = APPMGR_SORT_ATOZ;
+
+static int _apps_sort_by_size(const void *a, const void *b)
+{
+       const app_node *info1 = a;
+       const app_node *info2 = b;
+
+       if (NULL == a) return 0;
+       if (NULL == b) return 0;
+
+       return info2->ram_used - info1->ram_used;
+}
+
+static int _packages_sort_by_size(const void *a, const void *b)
+{
+       const package_node *info1 = a;
+       const package_node *info2 = b;
+
+       if (NULL == a) return 0;
+       if (NULL == b) return 0;
+
+       return info2->package_size - info1->package_size;
+}
+
+static int _apps_sort_ztoa(const void *a, const void *b)
+{
+       int len;
+       const app_node *info1 = a;
+       const app_node *info2 = b;
+
+       if (NULL == a) return 0;
+       if (NULL == b) return 0;
+       if (NULL == info1->label) return -1;
+       if (NULL == info2->label) return 1;
+
+       if (strlen(info1->label) < strlen(info2->label))
+               len = strlen(info1->label);
+       else
+               len = strlen(info2->label);
+
+       return strncasecmp(info2->label, info1->label, len);
+}
+
+static int _packages_sort_ztoa(const void *a, const void *b)
+{
+       int len;
+       const package_node *info1 = a;
+       const package_node *info2 = b;
+
+       if (NULL == a) return 0;
+       if (NULL == b) return 0;
+       if (NULL == info1->label) return -1;
+       if (NULL == info2->label) return 1;
+
+       if (strlen(info1->label) < strlen(info2->label))
+               len = strlen(info1->label);
+       else
+               len = strlen(info2->label);
+
+       return strncasecmp(info2->label, info1->label, len);
+}
+
+
+static int _apps_sort_atoz(const void *a, const void *b)
+{
+       return -1 * _apps_sort_ztoa(a, b);
+}
+
+static int _packages_sort_atoz(const void *a, const void *b)
+{
+       return -1 * _packages_sort_ztoa(a, b);
+}
+
+
+
+void appmgr_utils_update_app_node(app_node *node, app_info_h app_info)
+{
+       char *label = NULL;
+       if(!node) return;
+
+       (void)app_info_get_app_id(app_info, &node->appid);
+       (void)app_info_get_package(app_info, &node->pkgid);
+       (void)app_info_get_label(app_info, &node->label);
+
+       if (!node->label) {
+               (void)app_info_get_exec(app_info, &label);
+               if (label) {
+                       node->label = strdup(basename(label));
+                       free(label);
+               }
+       }
+
+       (void)app_info_get_icon(app_info, &node->icon_path);
+       if (EINA_TRUE != ecore_file_exists(node->icon_path)) {
+               free(node->icon_path);
+               node->icon_path = 0; //get_application_default_icon(node->appid);
+       }
+
+       (void)app_info_is_enabled(app_info, &node->is_enabled);
+       (void)app_manager_is_running(node->appid, &node->is_running);
+
+       node->ram_used = 0; //get_process_ram_usage_mb(app_info);
+
+}
+
+static bool _app_info_cb(app_info_h app_info, void *user_data)
+{
+       Eina_List **list = user_data;
+       app_node *node = calloc(1, sizeof(app_node));
+
+       if (!node) return false;
+
+       appmgr_utils_update_app_node(node, app_info);
+
+       *list = eina_list_append(*list, node);
+
+       return true;
+}
+
+Eina_List *appmgr_utils_sort_apps_list(int sorttype, Eina_List *apps_list)
+{
+       if (APPMGR_SORT_SIZE == sorttype)
+               return eina_list_sort(apps_list, eina_list_count(apps_list),
+                                       _apps_sort_by_size);
+       if (APPMGR_SORT_ZTOA == sorttype)
+               return eina_list_sort(apps_list, eina_list_count(apps_list),
+                                       _apps_sort_ztoa);
+       return eina_list_sort(apps_list, eina_list_count(apps_list),
+                                       _apps_sort_atoz);
+}
+
+
+static int menufunc_apps_lall(int argc, char *argv[])
+{
+       int ret;
+
+       Eina_List *apps;
+       ret = app_manager_foreach_app_info(_app_info_cb, &apps);
+       if (APP_MANAGER_ERROR_NONE != ret) {
+               eprintf("app_manager_foreach_app_info() Fail(%s)", get_error_message(ret));
+       }
+
+       apps = appmgr_utils_sort_apps_list(g_sorttype, apps);
+
+       return MEMUFUNC_ERR_NONE;
+}
+
+
+MenuItem apps_menulist[] ={
+       {"lall", "List Apps - All", menufunc_apps_lall},
+       {"ldn", "List Apps - Downloads", NULL},
+       {"lrun", "List Apps - Running", NULL},
+       {"loff", "List Apps - Turned off", NULL},
+       {"ainfo", "Application Info", NULL},
+       {"astor", "App - Storage", NULL},
+       {"afc", "App - Force close", NULL},
+       {"aoff", "App - Turn off", NULL},
+       {"astop", "App - Stop", NULL},
+       {"aclc", "App - Clear cache", NULL},
+       {"lhome", "List Homes", NULL},
+       {"home", "Home", NULL},
+       {"ldef", "List Defaults", NULL},
+       {"cldef", "Clear Defaults", NULL},
+       {"setdef", "Set Defaults", NULL},
+       {"usetdef", "Unset Defaults", NULL}
+};
+
+int menufunc_apps(int argc, char *argv[])
+{
+       printf("\n");
+
+       printf("Seting Command - Apps\n\n");
+       int menucount = sizeof(apps_menulist)/sizeof(MenuItem);
+
+       int result = runMenulist(argc, argv, "setting_cmd apps", apps_menulist, menucount);
+       return result;
+}
+
diff --git a/src/sc_apps.h b/src/sc_apps.h
new file mode 100755 (executable)
index 0000000..8c26f74
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef __SC_APPS_H_\r
+#define __SC_APPS_H_\r
+\r
+#include "settingcmd_def.h"\r
+\r
+\r
+int menufunc_apps(int argc, char *argv[]);\r
+\r
+#endif         /* __SC_APPS_H_ */\r
diff --git a/src/sc_battery.c b/src/sc_battery.c
new file mode 100755 (executable)
index 0000000..b6be914
--- /dev/null
@@ -0,0 +1,125 @@
+#include "sc_battery.h"
+#include "sc_common.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <vconf.h>
+#include <vconf-internal-keys.h>
+
+#include <sound_manager.h>
+#include <app_manager.h>
+
+#include <app.h>
+#include <app_manager.h>
+#include <package_manager.h>
+#include <context_history.h>
+#include <device/battery.h>
+#include <device/callback.h>
+
+static void _get_battery_usage_details_list()
+{
+       int i = 0;
+       int ret = 0;
+       int count = 0;
+       char *appid = NULL;
+       context_history_h handle = NULL;
+       context_history_filter_h filter = NULL;
+       context_history_list_h list = NULL;
+       context_history_record_h record = NULL;
+       double percent = 0.0;
+
+       ret =  context_history_create(&handle);
+       if (ret != CONTEXT_HISTORY_ERROR_NONE) {
+               eprintf("\tcontext_history_create(): %s\n", get_error_message(ret));
+               goto cleanup;
+       }
+
+       ret = context_history_filter_create(&filter);
+       if (ret != CONTEXT_HISTORY_ERROR_NONE) {
+               eprintf("\tcontext_history_filter_create(): %s\n",
+                               get_error_message(ret));
+               goto cleanup;
+       }
+
+       ret = context_history_get_list(handle,
+                       CONTEXT_HISTORY_RECENT_BATTERY_USAGE, filter, &list);
+       if (ret != CONTEXT_HISTORY_ERROR_NONE) {
+               eprintf("\tcontext_history_get_list(): %s\n", get_error_message(ret));
+               goto cleanup;
+       }
+
+       ret = context_history_list_get_count(list, &count);
+       for (i = 0; i < count; ++i) {
+
+               (void)context_history_list_get_current(list, &record);
+               (void)context_history_record_get_string(record,
+                                       CONTEXT_HISTORY_APP_ID, &appid);
+               (void)context_history_record_get_double(record,
+                               CONTEXT_HISTORY_TOTAL_AMOUNT, &percent);
+
+               printf("\t%s : %.2f %% \n", appid, percent);
+               (void)context_history_record_destroy(record);
+               record = NULL;
+               (void)context_history_list_move_next(list);
+               if (appid) {
+                       free(appid);
+                       appid = NULL;
+               }
+       }
+
+cleanup:
+       context_history_list_destroy(list);
+       context_history_filter_destroy(filter);
+       context_history_destroy(handle);
+}
+
+#define SETTING_ABOUT_POWER_SUPPLY_PATH "/sys/class/power_supply"
+#define MAX_DISPLAY_STR_LEN_ON_PHONE_INFO      256
+int menufunc_ba(int argc, char *argv[])
+{
+       printf("\n");
+
+       int result = MEMUFUNC_ERR_NONE;
+       printf("Seting Command - Battery\n\n");
+
+       int val = -1;
+       char file[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO] = { 0, };
+       snprintf(file, MAX_DISPLAY_STR_LEN_ON_PHONE_INFO, "%s/%s/%s",
+                       SETTING_ABOUT_POWER_SUPPLY_PATH, "battery", "capacity");
+
+       char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO];
+       char buf[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO] = { 0, };
+       int fd = 0;
+       int r = 0;
+
+       fd = open(file, O_RDONLY);
+       if (fd != -1) {
+               r = read(fd, buf, MAX_DISPLAY_STR_LEN_ON_PHONE_INFO);
+               if ((r >= 0) && (r < MAX_DISPLAY_STR_LEN_ON_PHONE_INFO)) {
+                       buf[r] = '\0';
+                       val = atoi(buf);
+                       snprintf(str, sizeof(str), "%d%%", val);
+               } else {
+                       eprintf("read file fail\n");
+                       snprintf(str, sizeof(str), "%s unavailable!\n", SETTING_ABOUT_POWER_SUPPLY_PATH);
+               }
+
+               close(fd);
+               printf("\tBattery percentage : ");
+               printf("%s\n\n", str);
+       } else {
+               eprintf("open file fail\n");
+               snprintf(str, sizeof(str), "%s unavailable!\n", SETTING_ABOUT_POWER_SUPPLY_PATH);
+       }
+
+       _get_battery_usage_details_list();
+
+       return result;
+}
+
+
diff --git a/src/sc_battery.h b/src/sc_battery.h
new file mode 100755 (executable)
index 0000000..bc986ba
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef __SC_BATTERY_H_\r
+#define __SC_BATTERY_H_\r
+\r
+#include "settingcmd_def.h"\r
+\r
+\r
+int menufunc_ba(int argc, char *argv[]);\r
+\r
+#endif         /* __SC_BATTERY_H_ */\r
diff --git a/src/sc_bluetooth.c b/src/sc_bluetooth.c
new file mode 100755 (executable)
index 0000000..5504f10
--- /dev/null
@@ -0,0 +1,47 @@
+#include "sc_bluetooth.h"
+#include "sc_common.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <vconf.h>
+#include <vconf-internal-keys.h>
+#include <system_settings.h>
+#include <bluetooth.h>
+
+static int menufunc_bt_st(int argc, char *argv[])
+{
+    int ret = MEMUFUNC_ERR_NONE;
+
+       bt_adapter_state_e bt_state;
+       if (bt_adapter_get_state(&bt_state) != BT_ERROR_NONE) {
+               eprintf("bt_adapter_get_state() failed\n");
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       printf("\tState : %s\n", (bt_state == BT_ADAPTER_ENABLED) ? "On" : "Off");
+
+    return ret;
+}
+
+MenuItem bt_menulist[] ={
+       {"st", "State", menufunc_bt_st}
+};
+
+int menufunc_bt(int argc, char *argv[])
+{
+       printf("\n");
+
+       printf("Seting Command - Bluetooth\n\n");
+       int menucount = sizeof(bt_menulist)/sizeof(MenuItem);
+
+
+       if (bt_initialize() != BT_ERROR_NONE) {
+               eprintf("bt_initialize() failed\n");
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       int result = runMenulist(argc, argv, "setting_cmd bt", bt_menulist, menucount);
+       return result;
+}
+
diff --git a/src/sc_bluetooth.h b/src/sc_bluetooth.h
new file mode 100755 (executable)
index 0000000..3f6e163
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef __SC_BLUETOOTH_H_
+#define __SC_BLUETOOTH_H_
+
+#include "settingcmd_def.h"
+
+
+int menufunc_bt(int argc, char *argv[]);
+
+#endif         /* __SC_BLUETOOTH_H_ */
diff --git a/src/sc_common.c b/src/sc_common.c
new file mode 100755 (executable)
index 0000000..bfc308e
--- /dev/null
@@ -0,0 +1,111 @@
+#include "sc_common.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <system_info.h>
+
+void printUsage(char * title, MenuItem *menulist, int menucount)
+{
+       const char *notimplemented_str="[Not implemented]";
+
+
+       printf("Usage : %s [opt]\n", title);
+       printf("\t[opt] : [Menu]\n");
+
+       for (int i=0;i<menucount;i++){
+               if(menulist[i].menufunc)
+                       printf("\t  %s  : %s\n", menulist[i].opt, menulist[i].menu);
+               else
+                       printf("\t  %s  : %s - %s\n", menulist[i].opt, menulist[i].menu, notimplemented_str);
+
+       }
+       printf("\n");
+}
+
+
+int runMenulist(int argc, char *argv[], char * title, MenuItem *menulist, int menucount)
+{
+       if (argc<2) {
+               printUsage(title, &menulist[0], menucount);
+               return MEMUFUNC_ERR_ARG_SHORT;
+       }
+
+       int selmenu=-1;
+       for (int i=0;i<menucount;i++){
+               if(!strcmp(argv[1], menulist[i].opt)){
+                       selmenu = i;
+                       break;
+               }
+       }
+
+       if (selmenu<0) {
+               eprintf("This is not in the option list.\n\n");
+               printUsage(title, menulist, menucount);
+               return MEMUFUNC_ERR_ARG_INVAILD;
+       }
+
+
+       if (menulist[selmenu].menufunc) {
+               /* printf("\t  %s  : %s\n", menulist[i].opt, menulist[i].menu); */
+               return (*menulist[selmenu].menufunc)(argc-1,&argv[1]);
+       }
+
+       return MEMUFUNC_ERR_NOTIMPL;
+}
+
+
+void printError(int error)
+{
+       switch(error) {
+               case MEMUFUNC_ERR_NORMAL:
+                       eprintf("\tThere's errors during running.\n");
+               break;
+               case MEMUFUNC_ERR_ARG_SHORT:
+                       eprintf("\tThis option is short.\n");
+               break;
+               case MEMUFUNC_ERR_ARG_INVAILD:
+               break;
+               case MEMUFUNC_ERR_NOTIMPL:
+                       eprintf("\tThis option is not implemented yet.\n");
+               break;
+               default:
+               break;
+       }
+}
+
+
+int getProfile() {
+       int profile = 0;
+       char *profile_str = NULL;
+       int ret = system_info_get_platform_string("tizen.org/feature/profile", &profile_str);
+
+       if (ret != SYSTEM_INFO_ERROR_NONE) {
+               eprintf("ERROR!! failed profile info from system info API \n");
+               if (profile_str)
+                       free((void*)profile_str);
+               return MOBILE_PROFILE; /* default value return */
+       }
+
+       if (profile_str == NULL)
+               return MOBILE_PROFILE;
+
+       eprintf("Profile : %s\n", profile_str);
+
+       if (!strcmp(profile_str, "mobile")) {
+               profile = MOBILE_PROFILE;
+       } else if (!strcmp(profile_str, "wearable")) {
+               profile = WEARABLE_PROFILE;
+       } else if (!strcmp(profile_str, "tv")) {
+               profile = TV_PROFILE;
+       } else if (!strcmp(profile_str, "common")) {
+               profile = COMMON_PROFILE;
+       } else {
+               profile = MOBILE_PROFILE; /* default value return */
+       }
+
+       if (profile_str)
+               free((void*)profile_str);
+
+       return profile;
+}
diff --git a/src/sc_common.h b/src/sc_common.h
new file mode 100755 (executable)
index 0000000..269346f
--- /dev/null
@@ -0,0 +1,18 @@
+#ifndef __SC_COMMON_H_
+#define __SC_COMMON_H_
+
+#include <stdbool.h>
+#include "settingcmd_def.h"
+
+
+#define eprintf(...) fprintf (stderr, __VA_ARGS__)
+void printUsage(char * title, MenuItem *menulist, int menucount);
+
+/*
+       runMenulist()
+        - condition : argc >=2
+*/
+int runMenulist(int argc, char *argv[], char * title, MenuItem *menulist, int menucount);
+void printError(int error);
+int getProfile();
+#endif /* __SC_COMMON_H_ */
diff --git a/src/sc_datausage.c b/src/sc_datausage.c
new file mode 100755 (executable)
index 0000000..dcbf768
--- /dev/null
@@ -0,0 +1,1156 @@
+#include "sc_datausage.h"
+#include "sc_common.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stc.h>
+#include <telephony.h>
+
+#include <glib.h>
+#include <app_preference.h>
+#include <stc_internal.h>
+
+#define TH_POSTFIX_IDX 0
+
+/*---------------------------------------------------------------------------------------------------------------------------*/
+/* These codes are from setting app */
+
+#define SETTING_TRACE(fmt, arg...) do {} while (0)
+#define SETTING_TRACE_SECURE_DEBUG(fmt, arg...) do {} while (0)
+#define SETTING_TRACE_DEBUG(fmt, arg...) do {} while (0)
+//#define SETTING_TRACE_DEBUG(fmt, arg...) do { printf(fmt,##arg); printf("\n");} while (0)
+#define SETTING_TRACE_WARNING(fmt, arg...) do {} while (0)
+#define SETTING_TRACE_ERROR(fmt, arg...) do {} while (0)
+//#define SETTING_TRACE_ERROR(fmt, arg...) do { printf(fmt,##arg); printf("\n");} while (0)
+#define SETTING_TRACE_BEGIN do {} while (0)
+#define SETTING_TRACE_END do {} while (0)
+
+#define __FREE(del, arg) do { \
+       if (arg) { \
+               /*cast any argument to (void*) to avoid build warring*/\
+               del((void *)(arg)); \
+               arg = NULL; \
+       } \
+} while (0)
+#define FREE(arg) __FREE(free, arg)
+
+static GMainLoop* multi_main_loop = NULL;
+typedef enum {
+       MV_UPDATE_APPEND_NONE = 0,
+       MV_UPDATE_SIM_STATE_CHANGED,
+       MV_UPDATE_SIM_1_TOTAL_DATA_USAGE,
+       MV_UPDATE_SIM_2_TOTAL_DATA_USAGE,
+       MV_UPDATE_WIFI_TOTAL_DATA_USAGE,
+       MV_UPDATE_SIM_1_WARN_N_LIMIT,
+       MV_UPDATE_SIM_2_WARN_N_LIMIT,
+       MV_UPDATE_WIFI_WARN_N_LIMIT,
+       MV_UPDATE_CLEAR_ALL_SIM_1_APPS,
+       MV_UPDATE_CLEAR_ALL_SIM_2_APPS,
+       MV_UPDATE_CLEAR_ALL_WIFI_APPS,
+       MV_UPDATE_APPEND_SIM_1_APP,
+       MV_UPDATE_APPEND_SIM_2_APP,
+       MV_UPDATE_APPEND_WIFI_APP
+} mv_update_type;
+
+typedef enum {
+       CYCLE_MODE_MONTHLY = 0,
+       CYCLE_MODE_WEEKLY,
+       CYCLE_MODE_DAILY,
+       CYCLE_MODE_CUSTOM
+} Cycle_Mode_E;
+
+typedef struct {
+       int64_t total_data_used;
+       int64_t warning;
+       int64_t limit;
+       Cycle_Mode_E cycle_mode;
+       time_t interval_from;
+       time_t interval_to;
+       int custom_mode_interval;
+       int cycle_start;
+} Data_Limits_T;
+
+typedef enum {
+       DATA_RESTRICTION_LIMIT,
+       DATA_RESTRICTION_WARNING_LIMIT
+} data_restriction_type;
+
+typedef enum {
+       RESTRICTIONS_OK = 0,
+       RESTRICTIONS_ERROR = 1
+} restrictions_result;
+
+static char *number_postfixes[] = {
+       "th", "st", "nd", "rd"
+};
+
+static Data_Limits_T sim_limits[2];
+static Data_Limits_T wifi_limits;
+
+static bool _create_stats_list(stc_h stc, stc_iface_type_e iface,
+                                                               stc_stats_info_cb stats_cb,
+                                                               void *cb_data, time_t t_from,
+                                                               time_t t_to);
+static bool _get_total_stats(stc_h stc, stc_iface_type_e iface_type,
+                                                               stc_stats_info_cb stats_cb, void *cb_data,
+                                                               time_t t_from, time_t t_to);
+static bool _get_restrictions(stc_h stc, stc_iface_type_e iface_type,
+                                                               stc_restriction_rule_cb restrictions_cb,
+                                                               void *restriction_info_cb_data);
+
+int get_days_in_current_month()
+{
+       time_t now = 0;
+       struct tm now_tm = {0};
+       time(&now);
+       now_tm = *localtime(&now);
+       now_tm.tm_mon += 1;
+       now_tm.tm_mday = 0;
+       mktime(&now_tm);
+
+       return now_tm.tm_mday;
+}
+
+void get_data_amount_str(const char *prefix, int64_t num_bytes, char *txt_out,
+       int len_max)
+{
+       float amount = 0.0;
+
+       if (num_bytes < 1024) {
+               snprintf(txt_out, len_max, "%s%lldB", prefix, num_bytes);
+               return;
+       }
+       /*KB:*/
+       amount = ((float)num_bytes) / 1024.0;
+       if (amount >= 1024) {
+               /*MB:*/
+               if ((amount / 1024.0) >= 1024) {
+                       amount = amount / 1024.0;
+                       snprintf(txt_out, len_max, "%s%0.2fGB", prefix, (amount / 1024.0));
+                       return;
+               } else {
+                       snprintf(txt_out, len_max, "%s%0.2fMB", prefix, (amount / 1024.0));
+                       return;
+               }
+       } else {
+               snprintf(txt_out, len_max, "%s%0.2fKB", prefix, amount);
+       }
+}
+
+void get_data_int_amount_str(int64_t num_bytes, char *int_amount_str,
+       int len_max)
+{
+       int amount = 0;
+
+       if (num_bytes < 1024) {
+               snprintf(int_amount_str, len_max, "%lld", num_bytes);
+               return;
+       }
+       /*KB:*/
+       amount = num_bytes / 1024;
+       if (amount >= 1024) {
+               /*MB:*/
+               if ((amount / 1024) >= 1024) {
+                       amount = amount / 1024;
+                       if (amount % 1024 == 0) {
+                               snprintf(int_amount_str, len_max, "%d", (amount / 1024));
+                               return;
+                       } else {
+                               snprintf(int_amount_str, len_max, "%d", (amount));
+                               return;
+                       }
+               } else {
+                       snprintf(int_amount_str, len_max, "%d", (amount / 1024));
+                       return;
+               }
+       } else {
+               snprintf(int_amount_str, len_max, "%d", amount);
+       }
+}
+
+void get_data_unit_str(int64_t num_bytes, char *unit_str, int len_max)
+{
+       int amount = 0;
+
+       if (num_bytes == 0) {
+               snprintf(unit_str, len_max, "MB");
+               return;
+       }
+       if (num_bytes < 1024) {
+               snprintf(unit_str, len_max, "B");
+               return;
+       }
+
+       /*KB:*/
+       amount = num_bytes / 1024;
+       if (amount >= 1024) {
+               /*MB:*/
+               if ((amount / 1024) >= 1024) {
+                       amount = amount / 1024;
+                       if (amount % 1024 == 0) {
+                               snprintf(unit_str, len_max, "GB");
+                               return;
+                       } else {
+                               snprintf(unit_str, len_max, "MB");
+                               return;
+                       }
+               } else {
+                       snprintf(unit_str, len_max, "MB");
+                       return;
+               }
+       } else {
+               snprintf(unit_str, len_max, "KB");
+       }
+}
+
+void create_number_with_postfix(int number, char *output, int max_len)
+{
+       int temp = number % 100;
+
+       if (temp >= 20)
+               temp = temp % 10;
+
+       if (temp < 4) {
+               snprintf(output, max_len, "%d%s", number, number_postfixes[temp]);
+       } else {
+               snprintf(output, max_len, "%d%s", number,
+                       number_postfixes[TH_POSTFIX_IDX]);
+       }
+}
+
+bool get_sim_total_stats(stc_h stc, stc_stats_info_cb stats_cb,
+                                               const char *subscriber_id, time_t t_from, time_t t_to)
+{
+       return _get_total_stats(stc, STC_IFACE_DATACALL, stats_cb,
+                                                       (void *)subscriber_id, t_from, t_to);
+}
+
+bool get_wifi_total_stats(stc_h stc, stc_stats_info_cb stats_cb, time_t t_from,
+                                                       time_t t_to)
+{
+       return _get_total_stats(stc, STC_IFACE_WIFI, stats_cb, NULL, t_from, t_to);
+}
+
+bool get_sim_apps_list(stc_h stc, stc_stats_info_cb stats_cb,
+                                               const char *subscriber_id, time_t t_from, time_t t_to)
+{
+       return _create_stats_list(stc, STC_IFACE_DATACALL, stats_cb,
+                                                               (void *)subscriber_id, t_from, t_to);
+}
+
+bool get_wifi_apps_list(stc_h stc, stc_stats_info_cb stats_cb, time_t t_from,
+                                               time_t t_to)
+{
+       return _create_stats_list(stc, STC_IFACE_WIFI, stats_cb,
+                                                               NULL, t_from, t_to);
+}
+
+bool get_sim_restrictions(stc_h stc, stc_restriction_rule_cb restrictions_cb)
+{
+       return _get_restrictions(stc, STC_IFACE_DATACALL, restrictions_cb, NULL);
+}
+
+bool get_wifi_restrictions(stc_h stc, stc_restriction_rule_cb restrictions_cb)
+{
+       return _get_restrictions(stc, STC_IFACE_WIFI, restrictions_cb, NULL);
+}
+
+static bool _create_stats_list(stc_h stc, stc_iface_type_e iface,
+                                                               stc_stats_info_cb stats_cb,
+                                                               void *cb_data, time_t t_from,
+                                                               time_t t_to)
+{
+       stc_stats_rule_h rule = NULL;
+
+       int ret = stc_stats_rule_create(stc, &rule);
+       if (ret != STC_ERROR_NONE) {
+               SETTING_TRACE_ERROR("stc_stats_rule_create() error: %s",
+                                                       get_error_message(ret));
+               stc_stats_rule_destroy(rule);
+               return true;
+       }
+
+       ret = stc_stats_rule_set_time_interval(rule, t_from, t_to);
+       if (ret != STC_ERROR_NONE) {
+               SETTING_TRACE_ERROR("stc_stats_rule_set_time_interval() error: %s",
+                                                       get_error_message(ret));
+               stc_stats_rule_destroy(rule);
+               return true;
+       }
+
+       ret = stc_stats_rule_set_iface_type(rule, iface);
+       if (ret != STC_ERROR_NONE) {
+               SETTING_TRACE_ERROR("stc_stats_rule_set_iface_type() error: %s",
+                                                       get_error_message(ret));
+               stc_stats_rule_destroy(rule);
+               return true;
+       }
+
+       SETTING_TRACE_DEBUG("\033[1;33mObtaining per app data usage for ifce: %d",
+               iface);
+       ret = stc_foreach_stats(stc, rule, stats_cb, cb_data);
+       if (ret != STC_ERROR_NONE) {
+               SETTING_TRACE_ERROR("stc_get_stats() error: %s",
+                                                       get_error_message(ret));
+               if (STC_ERROR_IN_PROGRESS == ret) {
+                       stc_stats_rule_destroy(rule);
+                       return false;
+               }
+               stc_stats_rule_destroy(rule);
+               return true;
+       }
+
+       stc_stats_rule_destroy(rule);
+
+       return true;
+}
+
+static bool _get_total_stats(stc_h stc, stc_iface_type_e iface_type,
+                                                               stc_stats_info_cb stats_cb, void *cb_data,
+                                                               time_t t_from, time_t t_to)
+{
+       stc_stats_rule_h rule = NULL;
+       int ret = STC_ERROR_NONE;
+
+       ret = stc_stats_rule_create(stc, &rule);
+       if (ret != STC_ERROR_NONE) {
+               SETTING_TRACE_ERROR("stc_stats_rule_create() error: %s",
+                                                       get_error_message(ret));
+               return true;
+       }
+
+       ret = stc_stats_rule_set_time_interval(rule, t_from, t_to);
+       if (ret != STC_ERROR_NONE) {
+               SETTING_TRACE_ERROR("stc_stats_rule_set_time_interval() error: %s",
+                                                       get_error_message(ret));
+               (void)stc_stats_rule_destroy(rule);
+               return true;
+       }
+
+       ret = stc_stats_rule_set_iface_type(rule, iface_type);
+       if (ret != STC_ERROR_NONE) {
+               SETTING_TRACE_ERROR("stc_stats_rule_set_iface_type() error: %s",
+                                                       get_error_message(ret));
+               (void)stc_stats_rule_destroy(rule);
+               return true;
+       }
+
+       SETTING_TRACE_DEBUG("\033[1;34mObtaining total stats for ifce: %d",
+               iface_type);
+       ret = stc_get_total_stats(stc, rule, stats_cb, cb_data);
+       if (ret != STC_ERROR_NONE) {
+               SETTING_TRACE_ERROR("stc_get_total_stats() error: %s",
+                                               get_error_message(ret));
+               (void)stc_stats_rule_destroy(rule);
+               if (STC_ERROR_IN_PROGRESS == ret)
+                       return false;
+               return true;
+       }
+
+       (void)stc_stats_rule_destroy(rule);
+
+       return true;
+}
+
+static bool _get_restrictions(stc_h stc, stc_iface_type_e iface_type,
+                                                               stc_restriction_rule_cb restrictions_cb,
+                                                               void *restriction_info_cb_data)
+{
+       int ret = STC_ERROR_NONE;
+       stc_restriction_rule_h rule = NULL;
+
+       ret = stc_restriction_rule_create(stc, &rule);
+       if (STC_ERROR_NONE != ret) {
+               SETTING_TRACE_ERROR("stc_restriction_rule_create() error: %s",
+                                                       get_error_message(ret));
+               return true;
+       }
+
+       if (STC_IFACE_DATACALL == iface_type)
+               ret = stc_restriction_rule_set_app_id(rule, "TOTAL_DATACALL");
+       if (STC_IFACE_WIFI == iface_type)
+               ret = stc_restriction_rule_set_app_id(rule, "TOTAL_WIFI");
+
+       if (STC_ERROR_NONE != ret) {
+               SETTING_TRACE_ERROR("stc_restriction_rule_set_app_id() error: %s",
+                                                       get_error_message(ret));
+               stc_restriction_rule_destroy(rule);
+               return true;
+       }
+
+       ret = stc_restriction_rule_set_iface_type(rule, iface_type);
+       if (STC_ERROR_NONE != ret) {
+               SETTING_TRACE_ERROR("stc_restriction_rule_get_iface_type() error: %s",
+                                                       get_error_message(ret));
+               stc_restriction_rule_destroy(rule);
+               return true;
+       }
+
+       SETTING_TRACE_DEBUG("\033[1;35mObtaining restrictions for iface: %d",
+               iface_type);
+       ret = stc_foreach_restriction(stc, rule, restrictions_cb,
+                                                                       restriction_info_cb_data);
+       if (STC_ERROR_NONE != ret) {
+               SETTING_TRACE_ERROR("SIM stc_foreach_restriction() error: %s",
+                                                       get_error_message(ret));
+               (void)stc_restriction_rule_destroy(rule);
+               if (STC_ERROR_IN_PROGRESS == ret)
+                       return false;
+               return true;
+       }
+       (void)stc_restriction_rule_destroy(rule);
+
+       return true;
+}
+
+bool get_subscriber_id_from_telephony_handle(telephony_h handle,
+                                                                                       char **subscriber_id)
+{
+       int ret = TELEPHONY_ERROR_NONE;
+
+       ret = telephony_sim_get_subscriber_id(handle, subscriber_id);
+       if (TELEPHONY_ERROR_NONE != ret) {
+               SETTING_TRACE_ERROR("telephony_sim_get_msin(%p) %s",
+                                                       handle, get_error_message(ret));
+               return false;
+       }
+
+       return true;
+}
+
+static bool isEmptyStr(const char *str)
+{
+       if (NULL == str || '\0' == str[0])
+               return true;
+       return false;
+}
+
+static int safeStrNCmp(const char *s1, const char *s2, int len)
+{
+
+       /*      Check NULL value first */
+       if (isEmptyStr(s1) && isEmptyStr(s2))
+               return 0;
+       else if (isEmptyStr(s1))
+               return 1;
+       else if (isEmptyStr(s2))
+               return MEMUFUNC_ERR_NORMAL;
+
+       if (0 == len)
+               return 0;
+
+       return strncmp(s1, s2, len);
+}
+
+bool compare_subscriber_ids(const char *id_a, const char *id_b)
+{
+       return (0 == safeStrNCmp(id_a, id_b, 128));
+}
+
+restrictions_result set_mobile_restriction_rule_parameters(
+                                                                                       stc_restriction_rule_h rule,
+                                                                                       const char *subscriber_id,
+                                                                                       int64_t limit,
+                                                                                       int64_t warning_limit)
+{
+       SETTING_TRACE_BEGIN;
+       int ret = STC_ERROR_NONE;
+
+       ret = stc_restriction_rule_set_app_id(rule, "TOTAL_DATACALL");
+       if (STC_ERROR_NONE != ret) {
+               (void)stc_restriction_rule_destroy(rule);
+               SETTING_TRACE_ERROR("stc_restriction_rule_set_app_id() error: %s",
+                                                                                       get_error_message(ret));
+               return RESTRICTIONS_ERROR;
+       }
+
+       ret = stc_restriction_rule_set_iface_type(rule, STC_IFACE_DATACALL);
+       if (STC_ERROR_NONE != ret) {
+               (void)stc_restriction_rule_destroy(rule);
+               SETTING_TRACE_ERROR("stc_restriction_rule_set_iface_type() error: %s",
+                                                                                       get_error_message(ret));
+               return RESTRICTIONS_ERROR;
+       }
+
+       ret = stc_restriction_rule_set_subscriber_id(rule, subscriber_id);
+       if (STC_ERROR_NONE != ret) {
+               (void)stc_restriction_rule_destroy(rule);
+               SETTING_TRACE_ERROR("stc_restriction_rule_set_subscriber_id() error:"\
+                                                       "%s", get_error_message(ret));
+
+               return RESTRICTIONS_ERROR;
+       }
+
+       ret = stc_restriction_rule_set_limit(rule, limit);
+       if (STC_ERROR_NONE != ret) {
+               (void)stc_restriction_rule_destroy(rule);
+               SETTING_TRACE_ERROR("stc_restriction_rule_set_limit() error: %s",
+                                                                                       get_error_message(ret));
+               return RESTRICTIONS_ERROR;
+       }
+
+       ret = stc_restriction_rule_set_warning_limit(rule, warning_limit);
+       if (STC_ERROR_NONE != ret) {
+               (void)stc_restriction_rule_destroy(rule);
+               SETTING_TRACE_ERROR(
+                       "stc_restriction_rule_set_warning_limit() error: %s",
+                       get_error_message(ret));
+               return RESTRICTIONS_ERROR;
+       }
+
+       SETTING_TRACE_END;
+       return RESTRICTIONS_OK;
+}
+
+restrictions_result set_mobile_limit_restrictions(stc_h stc_handle,
+               const char *subscriber_id, int64_t limit, int64_t warning_limit)
+{
+       SETTING_TRACE_BEGIN;
+       int ret = STC_ERROR_NONE;
+       stc_restriction_rule_h rule = NULL;
+       restrictions_result result = RESTRICTIONS_OK;
+
+       ret = stc_restriction_rule_create(stc_handle, &rule);
+       if (STC_ERROR_NONE != ret) {
+               SETTING_TRACE_ERROR("stc_restriction_rule_create() error: %s",
+                                                                       get_error_message(ret));
+               return RESTRICTIONS_ERROR;
+       }
+
+       result = set_mobile_restriction_rule_parameters(rule, subscriber_id, limit,
+                                                                                                       warning_limit);
+       if (RESTRICTIONS_OK != result) {
+               SETTING_TRACE_ERROR("set_restriction_rule_parameters() error");
+               return result;
+       }
+
+       ret = stc_set_restriction(stc_handle, rule);
+       if (STC_ERROR_NONE != ret) {
+               (void)stc_restriction_rule_destroy(rule);
+               SETTING_TRACE_ERROR("stc_set_restriction() error: %s",
+                                                                                       get_error_message(ret));
+               return RESTRICTIONS_ERROR;
+       }
+
+       (void)stc_restriction_rule_destroy(rule);
+       SETTING_TRACE_END;
+       return RESTRICTIONS_OK;
+}
+
+bool unset_mobile_limit_restrictions(stc_h stc_handle,
+       stc_restriction_rule_cb cb, void *data)
+{
+       return _get_restrictions(stc_handle, STC_IFACE_DATACALL,
+                                                       cb, data);
+}
+
+
+static stc_callback_ret_e _get_and_unset_limit_restrictions_cb(
+       stc_error_e result, stc_restriction_rule_h rule, void *user_data)
+{
+       int ret = STC_ERROR_NONE;
+       char *app_id = NULL;
+       char *subscriber_id = NULL;
+       int64_t limit = 0;
+       int64_t warning_limit = 0;
+       stc_iface_type_e iface_type = STC_IFACE_UNKNOWN;
+       stc_restriction_type_e type = STC_RSTN_TYPE_UNKNOWN;
+       stc_restriction_rule_h mobile_rule = NULL;
+       restrictions_result restrictions_res = RESTRICTIONS_ERROR;
+
+       if (!user_data) {
+               SETTING_TRACE_ERROR("_get_restrictions_to_unset_cb error: user_data == NULL");
+               g_main_loop_quit(multi_main_loop);
+               return STC_CALLBACK_CONTINUE;
+       }
+
+
+       stc_h stc = *((stc_h *)user_data);
+
+       SETTING_TRACE_DEBUG("_get_restrictions_to_unset_cb:");
+       if (STC_ERROR_NONE != result) {
+               SETTING_TRACE_ERROR("_get_restrictions_to_unset_cb error: %s",
+                                                       get_error_message(result));
+               g_main_loop_quit(multi_main_loop);
+               return STC_CALLBACK_CONTINUE;
+       }
+
+       ret = stc_restriction_rule_get_app_id(rule, &app_id);
+       if (STC_ERROR_NONE != ret || !app_id || strcmp("TOTAL_DATACALL", app_id)) {
+               free(app_id);
+               g_main_loop_quit(multi_main_loop);
+               return STC_CALLBACK_CONTINUE;
+       }
+
+       free(app_id);
+
+       ret = stc_restriction_rule_get_type(rule, &type);
+       if (STC_ERROR_NONE != ret) {
+               SETTING_TRACE_ERROR("stc_restriction_rule_get_type error: %s",
+                                                       get_error_message(ret));
+               g_main_loop_quit(multi_main_loop);
+               return STC_CALLBACK_CONTINUE;
+       }
+
+       ret = stc_restriction_rule_get_iface_type(rule, &iface_type);
+       if (STC_ERROR_NONE != ret) {
+               SETTING_TRACE_ERROR("stc_restriction_rule_get_iface_type error: %s",
+                                                       get_error_message(ret));
+               g_main_loop_quit(multi_main_loop);
+               return STC_CALLBACK_CONTINUE;
+       }
+
+       if (iface_type != STC_IFACE_DATACALL) {
+               g_main_loop_quit(multi_main_loop);
+               return STC_CALLBACK_CONTINUE;
+       }
+
+       ret = stc_restriction_rule_get_subscriber_id(rule, &subscriber_id);
+       if (STC_ERROR_NONE != ret) {
+               SETTING_TRACE_ERROR("stc_restriction_rule_get_subscriber_id error: %s",
+                       get_error_message(ret));
+               g_main_loop_quit(multi_main_loop);
+               return STC_CALLBACK_CONTINUE;
+       }
+
+       ret = stc_restriction_rule_get_limit(rule, &limit);
+       if (STC_ERROR_NONE != ret) {
+               SETTING_TRACE_ERROR("stc_restriction_rule_get_limit() error: %s",
+                       get_error_message(ret));
+               free(subscriber_id);
+               g_main_loop_quit(multi_main_loop);
+               return STC_CALLBACK_CONTINUE;
+       }
+
+       ret = stc_restriction_rule_get_warning_limit(rule, &warning_limit);
+       if (STC_ERROR_NONE != ret) {
+               SETTING_TRACE_ERROR(
+                       "stc_restriction_rule_get_warning_limit() error: %s",
+                       get_error_message(ret));
+               free(subscriber_id);
+               g_main_loop_quit(multi_main_loop);
+               return STC_CALLBACK_CONTINUE;
+       }
+
+       ret = stc_restriction_rule_create(stc, &mobile_rule);
+       if (STC_ERROR_NONE != ret) {
+               SETTING_TRACE_ERROR("stc_restriction_rule_create() error: %s",
+                                                                       get_error_message(ret));
+               free(subscriber_id);
+               g_main_loop_quit(multi_main_loop);
+               return STC_CALLBACK_CONTINUE;
+       }
+
+       restrictions_res = set_mobile_restriction_rule_parameters(mobile_rule,
+               subscriber_id, limit, warning_limit);
+       if (restrictions_res != RESTRICTIONS_OK) {
+               SETTING_TRACE_ERROR(
+                       "set_mobile_restriction_rule_parameters() error");
+               free(subscriber_id);
+               g_main_loop_quit(multi_main_loop);
+               return STC_CALLBACK_CONTINUE;
+       }
+
+       ret = stc_unset_restriction(stc, mobile_rule);
+       if (STC_ERROR_NONE != ret) {
+               SETTING_TRACE_ERROR("stc_unset_restriction() error: %s",
+                                                                       get_error_message(ret));
+               free(subscriber_id);
+               g_main_loop_quit(multi_main_loop);
+               return STC_CALLBACK_CONTINUE;
+       }
+       free(subscriber_id);
+
+       SETTING_TRACE_ERROR(
+               "stc_unset_restriction() successful unset restriction");
+       g_main_loop_quit(multi_main_loop);
+       return STC_CALLBACK_CONTINUE;
+}
+
+static void _initialize_cycle(Data_Limits_T *limits)
+{
+       limits->custom_mode_interval = 1;
+       limits->cycle_mode = CYCLE_MODE_MONTHLY;
+       limits->cycle_start = 1;
+}
+
+static void _set_stats_time_frame_from_cycle(Data_Limits_T *limits)
+{
+       time_t now = 0;
+       long long custom_cycles_reminder = 0;
+       struct tm tm_past_delta = {0,};
+       struct tm tm_future_delta = {0,};
+       time(&now);
+       struct tm *tm_now = localtime(&now);
+       tm_now->tm_sec = 1;
+       tm_now->tm_min = 0;
+       tm_now->tm_hour = 0;
+       tm_past_delta = *tm_now;
+       tm_future_delta = *tm_now;
+
+       switch (limits->cycle_mode) {
+       case CYCLE_MODE_MONTHLY:
+               tm_past_delta.tm_mday = limits->cycle_start;
+               if (tm_now->tm_mday >= limits->cycle_start) {
+                       tm_future_delta.tm_mon++;
+                       tm_future_delta.tm_sec = 0;
+                       tm_future_delta.tm_min = 0;
+                       tm_future_delta.tm_hour = 0;
+                       tm_future_delta.tm_mday = limits->cycle_start + 1;
+               } else {
+                       tm_past_delta.tm_mon--;
+                       tm_future_delta.tm_mday = limits->cycle_start;
+               }
+               break;
+       case CYCLE_MODE_WEEKLY:
+               tm_now->tm_wday--;
+               if (tm_now->tm_wday < 0)
+                       tm_now->tm_wday = 6;
+               if (tm_now->tm_wday >= limits->cycle_start) {
+                       tm_past_delta.tm_mday -= (tm_now->tm_wday + 1 - limits->cycle_start);
+                       tm_future_delta.tm_mday += (7 + limits->cycle_start - tm_now->tm_wday);
+               } else {
+                       tm_past_delta.tm_mday -= (7 + tm_now->tm_wday - limits->cycle_start);
+                       tm_future_delta.tm_mday += (limits->cycle_start - tm_now->tm_wday);
+               }
+               break;
+       case CYCLE_MODE_DAILY:
+               tm_future_delta.tm_sec = 0;
+               tm_future_delta.tm_min = 0;
+               tm_future_delta.tm_hour = 0;
+               tm_future_delta.tm_mday++;
+               break;
+       case CYCLE_MODE_CUSTOM:
+               if (limits->custom_mode_interval <= 0) {
+                       SETTING_TRACE_ERROR("Error: custom mode interval is %d",
+                                                               limits->custom_mode_interval);
+                       return;
+               }
+               custom_cycles_reminder = (now - (time_t)limits->cycle_start) %
+               (limits->custom_mode_interval * 24 * 60 * 60);
+               limits->interval_from = now - custom_cycles_reminder;
+               limits->interval_to = limits->interval_from +
+                                                       (((time_t)limits->custom_mode_interval) * 24 * 60 * 60);
+               return;
+       default:
+               return;
+       }
+
+       limits->interval_from = mktime(&tm_past_delta);
+       limits->interval_to = mktime(&tm_future_delta);
+}
+
+static stc_callback_ret_e _total_stats_cb(stc_error_e result,
+                                                               stc_stats_info_h info, void *user_data)
+{
+       int64_t incoming = 0;
+       int64_t outgoing = 0;
+       char *subscriber_id = NULL;
+       const char *subscriber_id_to_look_for = user_data;
+       int ret = STC_ERROR_NONE;
+       stc_iface_type_e iface_type = STC_IFACE_UNKNOWN;
+
+       SETTING_TRACE_DEBUG("total stats cb, looking for subscriber id: %s",
+                                               subscriber_id_to_look_for);
+
+       if (STC_ERROR_NONE != result) {
+               SETTING_TRACE_ERROR("Error in cb: %s", get_error_message(result));
+               g_main_loop_quit(multi_main_loop);
+               return STC_CALLBACK_CANCEL;
+       }
+
+       ret = stc_stats_info_get_iface_type(info, &iface_type);
+       if (STC_ERROR_NONE != ret) {
+               SETTING_TRACE_ERROR("get interface error: %s", get_error_message(ret));
+               eprintf(" There is no data usage.\n");
+               g_main_loop_quit(multi_main_loop);
+               return STC_CALLBACK_CANCEL;
+       }
+       SETTING_TRACE_DEBUG("Obtained iface: %d", iface_type);
+       ret = stc_stats_info_get_counter(info, &incoming, &outgoing);
+
+       if (STC_ERROR_NONE == ret) {
+               if (iface_type == STC_IFACE_DATACALL) {
+                       ret = stc_stats_info_get_subscriber_id(info, &subscriber_id);
+
+                       if (STC_ERROR_NONE == ret &&
+                               compare_subscriber_ids(subscriber_id,
+                                                                               subscriber_id_to_look_for)
+                               ) {
+
+                               SETTING_TRACE_DEBUG("Obtained SUBSCRIBER ID: %s",
+                                                                       subscriber_id);
+                               printf(" total in: %lld byte out: %lld byte\n", incoming, outgoing);
+                       } else {
+                               SETTING_TRACE_ERROR("stc_stats_info_get_subscriber_id() error: %s",
+                                                                                       get_error_message(ret));
+                       }
+                       free(subscriber_id);
+               }
+               if (iface_type == STC_IFACE_WIFI) {
+                       wifi_limits.total_data_used = incoming + outgoing;
+                       printf(" total in: %lld byte out: %lld byte\n", incoming, outgoing);
+               }
+       } else {
+               SETTING_TRACE_ERROR("get counter error: %s", get_error_message(ret));
+               g_main_loop_quit(multi_main_loop);
+               return STC_CALLBACK_CANCEL;
+       }
+       g_main_loop_quit(multi_main_loop);
+       return STC_CALLBACK_CONTINUE;
+}
+
+static int menufunc_du_mo(int argc, char *argv[])
+{
+       telephony_handle_list_s tel_h_list;
+       telephony_sim_state_e sim_state = TELEPHONY_SIM_STATE_UNKNOWN;
+       stc_h stc;
+       int ret = 0;
+       if (telephony_init(&tel_h_list) != TELEPHONY_ERROR_NONE) {
+               eprintf("telephony_init failed");
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       if (tel_h_list.count < 0) {
+               printf("\tThere is no SIM card\n");
+               if (telephony_deinit(&tel_h_list) != TELEPHONY_ERROR_NONE) {
+                       eprintf("telephony_deinit failed");
+                       return MEMUFUNC_ERR_NORMAL;
+               }
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       printf("First argument = cycle mode, below.\n");
+       printf("CYCLE_MODE_MONTHLY = 0\n");
+       printf("CYCLE_MODE_WEEKLY = 1\n");
+       printf("CYCLE_MODE_DAILY = 2\n");
+       printf("CYCLE_MODE_CUSTOM = 3\n\n");
+
+       printf("Second argument = start date (monthly, weekly, daily)\n \t\t\t or interval(custom 1 to 90)\n\n");
+
+       if (argc<2) {
+               eprintf("Too short to execute this function\n");
+               return MEMUFUNC_ERR_ARG_SHORT;
+       }
+
+       int cycle = atoi(argv[1]);
+       int start_interval = atoi(argv[2]);
+
+       for (int i = 0; i<2; i++) {
+               _initialize_cycle(&sim_limits[i]);
+
+               sim_limits[i].cycle_mode = cycle;
+               if (cycle != CYCLE_MODE_CUSTOM) {
+                       sim_limits[i].cycle_start = start_interval;
+               } else {
+                       sim_limits[i].custom_mode_interval = start_interval;
+               }
+               _set_stats_time_frame_from_cycle(&sim_limits[i]);
+       }
+
+       ret = stc_initialize(&stc);
+       if (ret != STC_ERROR_NONE) {
+               eprintf("stc_initialize() error: %s\n", get_error_message(ret));
+               return MEMUFUNC_ERR_NORMAL;
+       }
+       int available_sim = 0;
+       char *subscriber_id[2]; /* Subscriber ID numbers of sim cards*/
+
+
+       for (int i = 0; i < tel_h_list.count ; i++) {
+               ret = telephony_sim_get_state(tel_h_list.handle[i], &sim_state);
+               if (TELEPHONY_ERROR_NONE == ret &&
+                               TELEPHONY_SIM_STATE_AVAILABLE == sim_state) {
+                       available_sim++;
+
+                       ret = get_subscriber_id_from_telephony_handle(
+                                               tel_h_list.handle[i], &subscriber_id[i]);
+
+                       if (ret == 0) {
+                               eprintf("get_subscriber_id_from_telephony_handle error! sim(%d) %d\n", i, ret);
+                               continue;
+                       }
+
+                       multi_main_loop = g_main_loop_new(NULL, FALSE);
+                       sim_limits[i].total_data_used = 0;
+                       get_sim_total_stats(stc,
+                                                               _total_stats_cb, subscriber_id[i],
+                                                                       sim_limits[i].interval_from,
+                                                                       sim_limits[i].interval_to);
+                       printf("SIM %d ", i+1);
+                       g_main_loop_run(multi_main_loop);
+                       if (subscriber_id[i]){
+                               free(subscriber_id[i]);
+                               subscriber_id[i] = 0;
+                       }
+               }
+       }
+
+       stc_deinitialize(stc);
+       if (telephony_deinit(&tel_h_list) != TELEPHONY_ERROR_NONE) {
+               eprintf("telephony_deinit failed");
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       return MEMUFUNC_ERR_NONE;
+}
+
+
+static stc_callback_ret_e _get_restrictions_cb(stc_error_e result,
+                                                               stc_restriction_rule_h rule, void *user_data)
+{
+       int ret = STC_ERROR_NONE;
+       char *app_id = NULL;
+       char *subscriber_id = NULL;
+       static int SIM = 0;
+       stc_iface_type_e iface_type = STC_IFACE_UNKNOWN;
+       stc_restriction_type_e type = STC_RSTN_TYPE_UNKNOWN;
+
+       SETTING_TRACE_DEBUG("restriction cb:");
+       if (STC_ERROR_NONE != result) {
+               SETTING_TRACE_ERROR("_get_restrictions_cb error: %s",
+                                                       get_error_message(result));
+               g_main_loop_quit(multi_main_loop);
+               return STC_CALLBACK_CONTINUE;
+       }
+
+       (void)stc_restriction_rule_get_app_id(rule, &app_id);
+       if (!app_id ||
+               (strcmp("TOTAL_DATACALL", app_id) && strcmp("TOTAL_WIFI", app_id))) {
+               free(app_id);
+               g_main_loop_quit(multi_main_loop);
+               return STC_CALLBACK_CONTINUE;
+       }
+       SETTING_TRACE_DEBUG("Obtaining restrictions for: %s", app_id);
+       free(app_id);
+
+       ret = stc_restriction_rule_get_type(rule, &type);
+       if (STC_ERROR_NONE != ret) {
+               SETTING_TRACE_ERROR("stc_restriction_rule_get_type error: %s",
+                                                       get_error_message(ret));
+               g_main_loop_quit(multi_main_loop);
+               return STC_CALLBACK_CONTINUE;
+       }
+
+       (void)stc_restriction_rule_get_iface_type(rule, &iface_type);
+       SETTING_TRACE_DEBUG("Obtained iface: %d", iface_type);
+       if (iface_type == STC_IFACE_DATACALL) {
+
+               ret = stc_restriction_rule_get_subscriber_id(rule, &subscriber_id);
+
+               if (STC_ERROR_NONE == ret) {
+                       SETTING_TRACE_DEBUG("Obtained Subscriber ID: %s", subscriber_id);
+                       int64_t limit_size = 0;
+                       int64_t warning_size = 0;
+                       stc_restriction_rule_get_limit(rule, &limit_size);
+                       stc_restriction_rule_get_warning_limit(rule, &warning_size);
+                       char buf[128]={0};
+                       char unit_s[16]={0};
+                       printf("\tSIM %d Subscripber ID : %s \n", SIM, subscriber_id);
+                       get_data_int_amount_str(limit_size, buf, 128);
+                       get_data_unit_str(limit_size, unit_s, 16);
+                       printf("\t   limit_size : %s %s\n", buf, unit_s);
+                       get_data_int_amount_str(warning_size, buf, 128);
+                       get_data_unit_str(warning_size, unit_s, 16);
+                       printf("\t   warning_size : %s %s\n", buf, unit_s);
+                       SIM++;
+               } else {
+                       SETTING_TRACE_ERROR("stc_stats_rule_get_subscriber_id() error: %s",
+                                                                               get_error_message(ret));
+               }
+               free(subscriber_id);
+       }
+
+       if (iface_type == STC_IFACE_WIFI) {
+               int64_t limit_size = 0;
+               int64_t warning_size = 0;
+               stc_restriction_rule_get_limit(rule, &limit_size);
+               stc_restriction_rule_get_warning_limit(rule, &warning_size);
+               printf("\tWIFI  \n");
+               printf("\t   limit_size : %lld \n", limit_size);
+               printf("\t   warning_size : %lld \n", warning_size );
+       }
+
+       g_main_loop_quit(multi_main_loop);
+       return STC_CALLBACK_CONTINUE;
+}
+
+
+static int menufunc_du_gmwl(int argc, char *argv[])
+{
+       stc_h stc;
+       int ret = 0;
+
+       ret = stc_initialize(&stc);
+       if (ret != STC_ERROR_NONE) {
+               eprintf("stc_initialize() error: %s\n", get_error_message(ret));
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       multi_main_loop = g_main_loop_new(NULL, FALSE);
+       get_sim_restrictions(stc, _get_restrictions_cb);
+       g_main_loop_run(multi_main_loop);
+
+       stc_deinitialize(stc);
+
+       return MEMUFUNC_ERR_NONE;
+}
+
+static int menufunc_du_smwl(int argc, char *argv[])
+{
+       telephony_handle_list_s tel_h_list;
+       telephony_sim_state_e sim_state = TELEPHONY_SIM_STATE_UNKNOWN;
+       stc_h stc;
+       int ret = 0;
+
+       printf("First argument = warning(MB)\n");
+       printf("Second argument = limit(MB)\n");
+       printf("Zero MB means None\n");
+
+       if (argc<2) {
+               eprintf("Too short to execute this menu\n");
+               return MEMUFUNC_ERR_ARG_SHORT;
+       }
+
+       int64_t warning = atoi(argv[1])*1024*1024;
+       int64_t limit = atoi(argv[2])*1024*1024;
+
+
+       if (telephony_init(&tel_h_list) != TELEPHONY_ERROR_NONE) {
+               eprintf("telephony_init failed");
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       if (tel_h_list.count < 0) {
+               printf("\tThere is no SIM card\n");
+               if (telephony_deinit(&tel_h_list) != TELEPHONY_ERROR_NONE) {
+                       eprintf("telephony_deinit failed");
+                       return MEMUFUNC_ERR_NORMAL;
+               }
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       ret = stc_initialize(&stc);
+       if (ret != STC_ERROR_NONE) {
+               eprintf("stc_initialize() error: %s\n", get_error_message(ret));
+               return MEMUFUNC_ERR_NORMAL;
+       }
+       int available_sim = 0;
+       char *subscriber_id[2]; /* Subscriber ID numbers of sim cards*/
+
+
+       for (int i = 0; i < tel_h_list.count ; i++) {
+               ret = telephony_sim_get_state(tel_h_list.handle[i], &sim_state);
+               if (TELEPHONY_ERROR_NONE == ret &&
+                               TELEPHONY_SIM_STATE_AVAILABLE == sim_state) {
+                       available_sim++;
+
+                       ret = get_subscriber_id_from_telephony_handle(
+                                               tel_h_list.handle[i], &subscriber_id[i]);
+
+                       if (ret == 0) {
+                               eprintf("get_subscriber_id_from_telephony_handle error! sim(%d) %d", i, ret);
+                               continue;
+                       }
+                       if (!limit && !warning) {
+                               multi_main_loop = g_main_loop_new(NULL, FALSE);
+                               unset_mobile_limit_restrictions(stc,
+                                                                                               _get_and_unset_limit_restrictions_cb, &stc);
+                               g_main_loop_run(multi_main_loop);
+                       } else {
+                               set_mobile_limit_restrictions(stc, subscriber_id[i],
+                                                                                                       limit,warning);
+                       }
+
+                       if (subscriber_id[i]){
+                               free(subscriber_id[i]);
+                               subscriber_id[i] = 0;
+                       }
+               }
+
+       }
+
+       stc_deinitialize(stc);
+       if (telephony_deinit(&tel_h_list) != TELEPHONY_ERROR_NONE) {
+               eprintf("telephony_deinit failed");
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       printf("\t\tDone..\n");
+
+       return MEMUFUNC_ERR_NONE;
+}
+
+static int menufunc_du_wi(int argc, char *argv[])
+{
+       stc_h stc;
+       int ret = 0;
+
+       printf("First argument = cycle mode, below.\n");
+       printf("CYCLE_MODE_MONTHLY = 0\n");
+       printf("CYCLE_MODE_WEEKLY = 1\n");
+       printf("CYCLE_MODE_DAILY = 2\n");
+       printf("CYCLE_MODE_CUSTOM = 3\n\n");
+
+       printf("Second argument = start date (monthly, weekly, daily)\n \t\t\t or interval(custom 1 to 90)\n\n");
+
+       if (argc<2) {
+               eprintf("Too short to execute this function\n");
+               return MEMUFUNC_ERR_ARG_SHORT;
+       }
+
+       int cycle = atoi(argv[1]);
+       int start_interval = atoi(argv[2]);
+
+       _initialize_cycle(&wifi_limits);
+
+       wifi_limits.cycle_mode = cycle;
+       if (cycle != CYCLE_MODE_CUSTOM) {
+               wifi_limits.cycle_start = start_interval;
+       } else {
+               wifi_limits.custom_mode_interval = start_interval;
+       }
+
+       _set_stats_time_frame_from_cycle(&wifi_limits);
+
+       ret = stc_initialize(&stc);
+       if (ret != STC_ERROR_NONE) {
+               eprintf("stc_initialize() error: %s\n", get_error_message(ret));
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       multi_main_loop = g_main_loop_new(NULL, FALSE);
+       wifi_limits.total_data_used = 0;
+       get_wifi_total_stats(stc, _total_stats_cb,
+                                                       wifi_limits.interval_from,
+                                                       wifi_limits.interval_to);
+       printf("WIFI ");
+       g_main_loop_run(multi_main_loop);
+
+       stc_deinitialize(stc);
+
+       return MEMUFUNC_ERR_NONE;
+}
+
+MenuItem du_menulist[] ={
+       {"smwl", "Set mobile data usage limit, warning level", menufunc_du_smwl},
+       {"gmwl", "Get mobile data usage limit, warning level", menufunc_du_gmwl},
+       {"mo", "Mobile data usage", menufunc_du_mo},
+       {"wi", "Wifi data usage", menufunc_du_wi},
+};
+
+
+
+int menufunc_du(int argc, char *argv[])
+{
+       printf("\n");
+
+       printf("Seting Command - data usagee\n\n");
+       int menucount = sizeof(du_menulist)/sizeof(MenuItem);
+
+       int result = runMenulist(argc, argv, "setting_cmd du", du_menulist, menucount);
+       return result;
+}
+
+
diff --git a/src/sc_datausage.h b/src/sc_datausage.h
new file mode 100755 (executable)
index 0000000..55ea212
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef __SC_DATEUSAGE_H_
+#define __SC_DATEUSAGE_H_
+
+#include "settingcmd_def.h"
+
+
+int menufunc_du(int argc, char *argv[]);
+
+#endif         /* __SC_DATEUSAGE_H_ */
diff --git a/src/sc_datetime.c b/src/sc_datetime.c
new file mode 100755 (executable)
index 0000000..e5f2474
--- /dev/null
@@ -0,0 +1,45 @@
+#include "sc_datetime.h"
+#include "sc_common.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <vconf.h>
+#include <vconf-internal-keys.h>
+
+#include <system_info.h>
+
+
+
+static int menufunc_dt_au(int argc, char *argv[])
+{
+       int auto_update = 0;
+       vconf_get_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, &auto_update);
+       printf("\tAuto update : ");
+       printf("%s\n", auto_update? "On" : "Off");
+
+       return MEMUFUNC_ERR_NONE;
+}
+
+
+MenuItem dt_menulist[] ={
+       {"au", "Auto update", menufunc_dt_au},
+       {"date", "Date", NULL},
+       {"time", "Time", NULL},
+       {"tz", "Time zone", NULL},
+       {"24h", "24 hour", NULL}
+};
+
+
+
+int menufunc_dt(int argc, char *argv[])
+{
+       printf("\n");
+
+       printf("Seting Command - Date & Time\n\n");
+       int menucount = sizeof(dt_menulist)/sizeof(MenuItem);
+
+       int result = runMenulist(argc, argv, "setting_cmd di", dt_menulist, menucount);
+       return result;
+}
+
diff --git a/src/sc_datetime.h b/src/sc_datetime.h
new file mode 100755 (executable)
index 0000000..3c05145
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef __SC_DATETIME_H_\r
+#define __SC_DATETIME_H_\r
+\r
+#include "settingcmd_def.h"\r
+\r
+\r
+int menufunc_dt(int argc, char *argv[]);\r
+\r
+#endif         /* __SC_DATETIME_H_ */\r
diff --git a/src/sc_display.c b/src/sc_display.c
new file mode 100755 (executable)
index 0000000..b433cb1
--- /dev/null
@@ -0,0 +1,91 @@
+#include "sc_display.h"
+#include "sc_common.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <system_settings.h>
+#include <vconf.h>
+#include <vconf-internal-keys.h>
+
+#include <system_info.h>
+
+
+
+static int menufunc_di_ab(int argc, char *argv[])
+{
+
+    int ret = MEMUFUNC_ERR_NONE;
+       int auto_bright = 0;
+    // TODO : I can't find BRIGHTNESS_AUTOMATIC value at device_display apis 
+       ret = vconf_get_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, &auto_bright);
+    if( ret != MEMUFUNC_ERR_NONE ) {
+        eprintf("\tAuto Bright get fail!\n");
+    } else {
+        printf("\tAuto Bright : %s\n", auto_bright? "On" : "Off");
+    }
+       return MEMUFUNC_ERR_NONE;
+}
+
+static int menufunc_di_br(int argc, char *argv[])
+{
+
+    int ret = MEMUFUNC_ERR_NONE;
+       int brightness = 0;
+    // TODO : Checking use with device_display_get api
+    // device_display_get( int display_index, int* brightness );
+       ret = vconf_get_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, &brightness);
+    if( ret != MEMUFUNC_ERR_NONE ) {
+        eprintf("\tbrightness get fail!\n");
+    } else {
+        printf("\tBrightness : %d\n", brightness);
+    }
+
+       return ret;
+}
+
+static int menufunc_di_fs(int argc, char *argv[])
+{
+
+    int ret = MEMUFUNC_ERR_NONE;
+    int fontsize = 0;
+    ret = system_settings_get_value_int(SYSTEM_SETTINGS_KEY_FONT_SIZE, &fontsize);
+    if( ret != MEMUFUNC_ERR_NONE ) {
+        eprintf("\tFont get fail!\n");
+    } else {
+        printf("\tFont Size: %d\n", fontsize );
+    }
+    return ret;
+}
+
+static int menufunc_di_to(int argc, char *argv[])
+{
+
+       int timeout = 0;
+       vconf_get_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &timeout);
+       printf("\tScreen timeout : ");
+       printf("%d\n", timeout);
+
+       return MEMUFUNC_ERR_NONE;
+}
+
+MenuItem di_menulist[] ={
+       {"ab", "Auto Bright", menufunc_di_ab},
+       {"br", "Brightness", menufunc_di_br},
+       {"fs", "Font Size", menufunc_di_fs},
+       {"to", "Screen timeout", menufunc_di_to}
+};
+
+
+
+int menufunc_di(int argc, char *argv[])
+{
+       printf("\n");
+
+       printf("Seting Command - Display\n\n");
+       int menucount = sizeof(di_menulist)/sizeof(MenuItem);
+
+       int result = runMenulist(argc, argv, "setting_cmd di", di_menulist, menucount);
+       return result;
+}
+
diff --git a/src/sc_display.h b/src/sc_display.h
new file mode 100755 (executable)
index 0000000..e9bd267
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef __SC_DISPLAY_H_\r
+#define __SC_DISPLAY_H_\r
+\r
+#include "settingcmd_def.h"\r
+\r
+\r
+int menufunc_di(int argc, char *argv[]);\r
+\r
+#endif         /* __SC_DISPLAY_H_ */\r
diff --git a/src/sc_sound.c b/src/sc_sound.c
new file mode 100755 (executable)
index 0000000..66ca2bd
--- /dev/null
@@ -0,0 +1,159 @@
+#include "sc_sound.h"
+#include "sc_common.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <vconf.h>
+#include <vconf-internal-keys.h>
+
+#include <sound_manager.h>
+#include <app_manager.h>
+//#include <feedback.h>
+
+static int menufunc_so_rvol(int argc, char *argv[])
+{
+       int vol = 0;
+       if (sound_manager_get_volume(SOUND_TYPE_RINGTONE, &vol)
+                       != SOUND_MANAGER_ERROR_NONE) {
+               printf("\tRingtone Volume : ");
+               printf("%d\n", vol);
+
+               return MEMUFUNC_ERR_NONE;
+       }
+       return MEMUFUNC_ERR_NORMAL;
+}
+
+static int menufunc_so_nvol(int argc, char *argv[])
+{
+       int vol = 0;
+       if (sound_manager_get_volume(SOUND_TYPE_NOTIFICATION, &vol)
+                       != SOUND_MANAGER_ERROR_NONE) {
+               printf("\tNotification Volume : ");
+               printf("%d\n", vol);
+
+               return MEMUFUNC_ERR_NONE;
+       }
+       return MEMUFUNC_ERR_NORMAL;
+}
+
+static int menufunc_so_mvol(int argc, char *argv[])
+{
+       int vol = 0;
+       if (sound_manager_get_volume(SOUND_TYPE_MEDIA, &vol)
+                       != SOUND_MANAGER_ERROR_NONE) {
+               printf("\tMedia Volume : ");
+               printf("%d\n", vol);
+
+               return MEMUFUNC_ERR_NONE;
+       }
+       return MEMUFUNC_ERR_NORMAL;
+}
+
+static int menufunc_so_svol(int argc, char *argv[])
+{
+       int vol = 0;
+       if (sound_manager_get_volume(SOUND_TYPE_SYSTEM, &vol)
+                       != SOUND_MANAGER_ERROR_NONE) {
+               printf("\tSystem Volume : ");
+               printf("%d\n", vol);
+
+               return MEMUFUNC_ERR_NONE;
+       }
+       return MEMUFUNC_ERR_NORMAL;
+}
+
+
+
+
+MenuItem so_menulist[] ={
+       {"rvol", "Ringtone Volume", menufunc_so_rvol},
+       {"nvol", "Notification Volume", menufunc_so_nvol},
+       {"mvol", "Media Volume", menufunc_so_mvol},
+       {"svol", "System Volume", menufunc_so_svol}
+};
+
+
+
+typedef struct {
+       sound_stream_info_h ringtone_sound_stream_info;
+       sound_stream_info_h media_sound_stream_info;
+       sound_stream_info_h noti_sound_stream_info;
+} sound_stream_info_t;
+
+
+
+static void __sound_stream_focus_state_changed_cb(
+               sound_stream_info_h stream_info,
+               sound_stream_focus_mask_e focus_mask,
+               sound_stream_focus_state_e focus_state,
+               sound_stream_focus_change_reason_e reason,
+               int sound_behavior,
+               const char *extra_info,
+               void *user_data)
+{
+}
+
+
+
+static bool _sound_manager_init(sound_stream_info_t *info)
+{
+       if (
+               (sound_manager_create_stream_information(
+                               SOUND_STREAM_TYPE_RINGTONE_VOIP,
+                               __sound_stream_focus_state_changed_cb, NULL,
+                               &info->ringtone_sound_stream_info)
+                       != SOUND_MANAGER_ERROR_NONE) ||
+               (sound_manager_create_stream_information(
+                               SOUND_STREAM_TYPE_MEDIA,
+                               __sound_stream_focus_state_changed_cb, NULL,
+                               &info->media_sound_stream_info)
+                       != SOUND_MANAGER_ERROR_NONE) ||
+               (sound_manager_create_stream_information(
+                               SOUND_STREAM_TYPE_NOTIFICATION,
+                               __sound_stream_focus_state_changed_cb, NULL,
+                               &info->noti_sound_stream_info)
+                       != SOUND_MANAGER_ERROR_NONE)
+       ) {
+               eprintf("Cannot create stream information ");
+               return false;
+       }
+
+//     int err = feedback_initialize();
+//     printf("Feedback init: %s\n", get_error_message(err));
+
+       return true;
+}
+
+static void _sound_manager_deinit(sound_stream_info_t *info)
+{
+//     feedback_deinitialize();
+
+       sound_manager_destroy_stream_information(
+                       info->ringtone_sound_stream_info);
+       sound_manager_destroy_stream_information(info->media_sound_stream_info);
+       sound_manager_destroy_stream_information(info->noti_sound_stream_info);
+}
+
+int menufunc_so(int argc, char *argv[])
+{
+       printf("\n");
+
+       printf("Seting Command - Sound\n\n");
+       int menucount = sizeof(so_menulist)/sizeof(MenuItem);
+
+       sound_stream_info_t sound_stream_info;
+
+       if(!_sound_manager_init(&sound_stream_info)) {
+               eprintf("_sound_manager_init() failed!");
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       int result = runMenulist(argc, argv, "setting_cmd so", so_menulist, menucount);
+
+       _sound_manager_deinit(&sound_stream_info);
+
+       return result;
+}
+
+
diff --git a/src/sc_sound.h b/src/sc_sound.h
new file mode 100755 (executable)
index 0000000..7148faa
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef __SC_SOUND_H_\r
+#define __SC_SOUND_H_\r
+\r
+#include "settingcmd_def.h"\r
+\r
+\r
+int menufunc_so(int argc, char *argv[]);\r
+\r
+#endif         /* __SC_SOUND_H_ */\r
diff --git a/src/sc_storage.c b/src/sc_storage.c
new file mode 100755 (executable)
index 0000000..5333bea
--- /dev/null
@@ -0,0 +1,745 @@
+#include "sc_wifi.h"
+#include "sc_common.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <vconf.h>
+#include <vconf-internal-keys.h>
+#include <system_settings.h>
+
+#include <storage.h>
+#include <media_content.h>
+#include <package-manager.h>
+#include <package_manager.h>
+#include <glib.h>
+
+#include <dd-usbhost.h>
+#include <sys/mount.h>
+#include <storage-internal.h>
+
+struct _calculated_sizes {
+       double app_total;
+       double caches_total;
+       double images_total;
+       double video_total;
+       double audio_total;
+       double misces_total;
+};
+
+pkgmgr_client* pc_total_size;
+static int usb_otg_status = 0;
+static int usb_request = 0;
+static char *usb_otg_path = 0;
+
+#define SETTING_CMD_MAX_STR_LEN 512
+
+#define __FREE(del, arg) do { \
+       if (arg) { \
+               /*cast any argument to (void*) to avoid build warring*/\
+               del((void *)(arg)); \
+               arg = NULL; \
+       } \
+} while (0)
+#define FREE(arg) __FREE(free, arg)
+#define SAFE_STRDUP(src) (src) ? strdup(src) : NULL
+
+#ifndef ret_if
+#define ret_if(expr) do { \
+       if (expr) { \
+               eprintf("(%s)\n", #expr); \
+               return ; \
+       } \
+} while (0)
+#endif
+
+void storage_get_external_storage_status(char *path, double *total,
+               double *avail)
+{
+       struct statvfs s;
+
+
+       if (!storage_get_external_memory_size(&s)) {
+               *total = (double)s.f_frsize * s.f_blocks;
+               *avail = (double)s.f_bfree * s.f_frsize;
+       }
+}
+
+static void __get_storage_capacity(char *str, int size)
+{
+       long long int total = 0;
+       long long int avail = 0;
+       struct statvfs internal;
+       struct statvfs external;
+
+       if (storage_get_internal_memory_size(&internal) < 0) {
+               eprintf("Fail to get internal memory size");
+               snprintf(str, size, "%s", "_unavailable");
+               return;
+       } else {
+               total = (long long int)internal.f_frsize
+                               * (long long int)internal.f_blocks;
+               avail = (long long int)internal.f_bsize
+                               * (long long int)internal.f_bavail;
+//             eprintf("Total mem : %lld, Avail mem : %lld\n",
+//                                     total, avail);
+       }
+
+       if (storage_get_external_memory_size(&external) < 0) {
+               eprintf("Fail to get external memory size");
+       } else {
+               total += (long long int)external.f_frsize
+                               * (long long int)external.f_blocks;
+               avail += (long long int)external.f_bsize
+                               * (long long int)external.f_bavail;
+//             eprintf("Total mem : %lld, Avail mem : %lld\n",
+//                             total, avail);
+       }
+
+       /* check if values are appropriate*/
+       if (total < 0 || avail < 0 || total < avail) {
+               eprintf("Fail to get internal memory size");
+               snprintf(str, size, "%s", "_unavailable");
+               return;
+       }
+       snprintf(str, size, "Device memory\n%0.1fGB available (Total %0.1fGB)\n\n",
+               (double)(avail / 1000000000.0), (double)(total / 1000000000.0));
+}
+
+
+void storage_size_to_str(double size, char *desc, int desc_size)
+{
+       double tmp_size = 0.0;
+       const int KILOBYTE_VALUE = 1024;
+       const int MEGABYTE_VALUE = KILOBYTE_VALUE * 1024;
+       const int GIGABYTE_VALUE = MEGABYTE_VALUE * 1024;
+
+       if (size < MEGABYTE_VALUE) { /* size < 1MB: show x.xKB */
+               tmp_size = size / KILOBYTE_VALUE;
+               snprintf(desc, desc_size, "%4.2lf KB", tmp_size);
+       } else if (size < GIGABYTE_VALUE) { /* size < 1GB: show x.xMB */
+               tmp_size = size / MEGABYTE_VALUE;
+               snprintf(desc, desc_size, "%4.2lf MB", tmp_size);
+       } else { /* 1G <= size: show x.xGB */
+               tmp_size = size / GIGABYTE_VALUE;
+               snprintf(desc, desc_size, "%4.2lf GB", tmp_size);
+       }
+}
+
+static int storage_get_media_info(const char *cond, media_info_cb cb,
+               struct _calculated_sizes *sizes)
+{
+       int ret;
+       filter_h filter = NULL;
+
+       /*Set Filter*/
+       ret = media_filter_create(&filter);
+       if (MEDIA_CONTENT_ERROR_NONE != ret) {
+               eprintf("media_filter_create() Fail(%d)", ret);
+               return ret;
+       }
+
+       ret = media_filter_set_condition(filter, cond,
+                       MEDIA_CONTENT_COLLATE_DEFAULT);
+       if (MEDIA_CONTENT_ERROR_NONE != ret) {
+               media_filter_destroy(filter);
+               eprintf("media_filter_set_condition() Fail(%d)\n",
+                               ret);
+               return ret;
+       }
+
+       ret = media_info_foreach_media_from_db(filter, cb, sizes);
+       if (MEDIA_CONTENT_ERROR_NONE != ret) {
+               media_filter_destroy(filter);
+               eprintf(
+                               "media_info_foreach_media_from_db() Fail(%d)\n",
+                               ret);
+               return ret;
+       }
+
+       ret = media_filter_destroy(filter);
+       if (MEDIA_CONTENT_ERROR_NONE != ret) {
+               eprintf("media_filter_destroy() Fail(%d)\n", ret);
+               return ret;
+       }
+
+       return ret;
+}
+
+static bool storage_get_media_item(media_info_h media, void *data)
+{
+       media_content_type_e type;
+       unsigned long long size = 0;
+       struct _calculated_sizes *sizes = data;
+
+       media_info_get_size(media, &size);
+       media_info_get_media_type(media, &type);
+       switch (type) {
+       case MEDIA_CONTENT_TYPE_IMAGE:
+               sizes->images_total += size;
+               break;
+       case MEDIA_CONTENT_TYPE_VIDEO:
+               sizes->video_total += size;
+               break;
+       case MEDIA_CONTENT_TYPE_SOUND:
+       case MEDIA_CONTENT_TYPE_MUSIC:
+               sizes->audio_total += size;
+               break;
+       default:
+               eprintf("Invalid Type(%d)", type);
+               break;
+       }
+
+       return true;
+}
+
+static bool storage_get_misces_item(media_info_h media, void *data)
+{
+       unsigned long long size = 0;
+       struct _calculated_sizes *sizes = data;
+
+       char *file_path = NULL;
+       media_info_get_file_path(media, &file_path);
+       #if 0
+       if (!ecore_file_exists(file_path)) {
+               SETTING_TRACE_DEBUG("!ecore_file_exists(file_path)");
+               FREE(file_path);
+               return true;
+       }
+       #endif
+       media_info_get_size(media, &size);
+       sizes->misces_total += size;
+       FREE(file_path);
+
+       return true;
+}
+
+static GMainLoop* multi_main_loop = NULL;
+static void storage_get_app_cache_size_cb(const package_size_info_h size_info,
+                                                                                       void *user_data)
+{
+       long long cache_size = 0;
+       long long app_size = 0;
+       long long ext_cache_size = 0;
+       long long ext_app_size = 0;
+
+       struct _calculated_sizes *ad = user_data;
+
+       package_size_info_get_app_size(size_info, &app_size);
+       package_size_info_get_external_app_size(size_info, &ext_app_size);
+       package_size_info_get_cache_size(size_info, &cache_size);
+       package_size_info_get_external_cache_size(size_info, &ext_cache_size);
+
+       ad->app_total = (double)(app_size + ext_app_size);
+       ad->caches_total = (double)(cache_size + ext_cache_size);
+
+       pc_total_size = NULL;
+       g_main_loop_quit(multi_main_loop);
+}
+
+void storage_update_apps_cache_info(struct _calculated_sizes *sizes)
+{
+       int ret;
+
+       multi_main_loop = g_main_loop_new(NULL, FALSE);
+       pc_total_size = pkgmgr_client_new(PC_REQUEST);
+       if (NULL == pc_total_size) {
+               eprintf("pkgmgr_client_new() Fail");
+               return;
+       }
+
+       ret = package_manager_get_total_package_size_info(
+                                                                                       storage_get_app_cache_size_cb, sizes);
+
+       g_main_loop_run(multi_main_loop);
+       if(PACKAGE_MANAGER_ERROR_NONE != ret)
+               eprintf("package_manager_get_total_package_size_info() Fail(%s)\n",
+                               get_error_message(ret));
+}
+
+
+enum {
+       SETTING_STORAGE_USB_OTG_REMOVE = 0,
+       SETTING_STORAGE_USB_OTG_UNMOUNT,
+       SETTING_STORAGE_USB_OTG_MOUNT
+};
+
+enum {
+       STORAGE_USB_REQ_NONE,
+       STORAGE_USB_REQ_MOUNT,
+       STORAGE_USB_REQ_UNMOUNT,
+       STORAGE_USB_REQ_UNMOUNT_BEFORE_FORMAT,
+       STORAGE_USB_REQ_FORMAT
+};
+
+static inline void storage_USB_unmount()
+{
+       int ret;
+       ret = unmount_usb_storage(usb_otg_path);
+       if (ret < 0) {
+               eprintf("unmount_usb_storage(%s) Fail(%d)\n",
+                               usb_otg_path, ret);
+               usb_request = STORAGE_USB_REQ_NONE;
+       }
+}
+
+static inline void storage_USB_mount()
+{
+       int ret;
+
+       ret = mount_usb_storage(usb_otg_path);
+       if (ret < 0) {
+               eprintf("mount_usb_storage(%s) Fail(%d)\n",
+                               usb_otg_path, ret);
+               usb_request = STORAGE_USB_REQ_NONE;
+       } else {
+               printf("USB mount success\n");
+               usb_request = STORAGE_USB_REQ_MOUNT;
+       }
+}
+
+static inline int storage_USB_format()
+{
+       int ret;
+       char buf[128] = {0};
+       printf("Do you want format?[y/n]:");
+       ret = scanf("%s", buf);
+
+       if (buf[0] != 'Y' && buf[0] != 'y')
+               return MEMUFUNC_ERR_NONE;
+
+       ret = format_usb_storage(usb_otg_path);
+       if (ret < 0) {
+               eprintf("format_usb_storage(%s) Fail(%d)\n",
+                               usb_otg_path, ret);
+               return MEMUFUNC_ERR_NORMAL;
+       }
+       return MEMUFUNC_ERR_NONE;
+}
+
+
+static inline void storage_USB_append_mounted_info()
+{
+       double total = 0.0;
+       double avail = 0.0;
+       char total_str[256] = { 0 };
+       char avail_str[256] = { 0 };
+
+       if (!usb_otg_path) {
+               eprintf("There is no usb otg path\n");
+               return;
+       }
+
+       storage_get_external_storage_status(usb_otg_path, &total, &avail);
+       storage_size_to_str(total, total_str, sizeof(total_str));
+       storage_size_to_str(avail, avail_str, sizeof(avail_str));
+
+       printf("USB Total : %s\n", total_str);
+       printf("USB Avail : %s\n", avail_str);
+
+
+}
+static inline void storage_main_append_USB_info()
+{
+
+       if (usb_otg_status == SETTING_STORAGE_USB_OTG_REMOVE)
+               return;
+
+       /* USB OTG storage */
+       if (SETTING_STORAGE_USB_OTG_MOUNT == usb_otg_status) {
+               printf("OTG mounted!!\n");
+               storage_USB_append_mounted_info();
+               storage_USB_unmount();
+       }
+}
+
+static void storage_USB_cb(char *type, char *path, int mount, void *data)
+{
+       int ret;
+
+       ret_if(NULL == type);
+       ret_if(NULL == path);
+       ret_if(NULL == data);
+
+       eprintf("path:%s type:%s", path, type);
+
+       FREE(usb_otg_path);
+       usb_otg_path = SAFE_STRDUP(path);
+
+       if (!strcmp(type, "storage_remove")) {
+               usb_otg_status = SETTING_STORAGE_USB_OTG_REMOVE;
+       } else if (!strcmp(type, "storage_mount")) {
+               usb_otg_status = SETTING_STORAGE_USB_OTG_MOUNT;
+               if (STORAGE_USB_REQ_UNMOUNT == usb_request) {
+                       eprintf("unmount_usb_storage() Fail\n");
+               }
+       } else if (!strcmp(type, "storage_unmount")) {
+               usb_otg_status = SETTING_STORAGE_USB_OTG_UNMOUNT;
+               if (STORAGE_USB_REQ_UNMOUNT_BEFORE_FORMAT == usb_request) {
+                       ret = storage_USB_format();
+                       if (MEMUFUNC_ERR_NONE == ret) {
+                               usb_request = STORAGE_USB_REQ_FORMAT;
+                       } else {
+                               usb_request = STORAGE_USB_REQ_NONE;
+                               storage_USB_mount();
+                       }
+                       return;
+               } else if (STORAGE_USB_REQ_FORMAT == usb_request) {
+                       eprintf("format_usb_storage() Fail\n");
+               } else if (STORAGE_USB_REQ_MOUNT == usb_request) {
+                       eprintf("mount_usb_storage() Fail\n");
+               }
+       } else if (!strcmp(type, "storage_updated")) {
+               if (mount == 0)
+                       usb_otg_status = SETTING_STORAGE_USB_OTG_UNMOUNT;
+               else
+                       usb_otg_status = SETTING_STORAGE_USB_OTG_MOUNT;
+       }
+       usb_request = STORAGE_USB_REQ_NONE;
+       storage_main_append_USB_info();
+}
+
+void storage_init_USB()
+{
+       int ret;
+
+       ret = init_usbhost_signal();
+       if (ret < 0)
+               eprintf("init_usbhost_signal() Fail(%d)\n", ret);
+
+       ret = register_usb_storage_change_handler(storage_USB_cb, NULL);
+       if (ret < 0) {
+               eprintf(
+                               "register_usb_storage_change_handler() Fail(%d)\n",
+                               ret);
+               deinit_usbhost_signal();
+               return;
+       }
+
+       ret = request_usb_storage_info();
+       if(ret < 0)
+               eprintf("request_usb_storage_info() - There is no usb storage, ret = %d\n", ret);
+}
+
+void storage_deinit_USB()
+{
+       deinit_usbhost_signal();
+}
+int storage_get_internal_detail()
+{
+       int ret;
+       const char *cond;
+       const char *cond_misc;
+       struct _calculated_sizes sizes = { 0.0, 0.0, 0.0, 0.0, 0.0 };
+       char desc[SETTING_CMD_MAX_STR_LEN] = { 0 };
+
+       storage_update_apps_cache_info(&sizes);
+
+       /*0-image, 1-video, 2-sound, 3-music, 4-other*/
+       cond = "((MEDIA_TYPE < 4) AND (MEDIA_STORAGE_TYPE=0))";
+       ret = storage_get_media_info(cond, storage_get_media_item, &sizes);
+       if(MEDIA_CONTENT_ERROR_NONE != ret)
+               eprintf("storage_get_media_info() Fail(%d)\n", ret);
+
+
+       cond_misc = "((MEDIA_TYPE=4) AND (MEDIA_STORAGE_TYPE=0))";
+       ret = storage_get_media_info(cond_misc, storage_get_misces_item,
+                       &sizes);
+       if(MEDIA_CONTENT_ERROR_NONE != ret)
+               eprintf("storage_get_media_info() Fail(%d)\n", ret);
+
+
+       storage_size_to_str(sizes.app_total, desc, sizeof(desc));
+       printf(" App size : %s\n",  desc);
+       storage_size_to_str(sizes.caches_total, desc, sizeof(desc));
+       printf(" Caches size : %s\n",  desc);
+       storage_size_to_str(sizes.images_total, desc, sizeof(desc));
+       printf(" Image size : %s\n",  desc);
+       storage_size_to_str(sizes.video_total, desc, sizeof(desc));
+       printf(" Videe size : %s\n",  desc);
+       storage_size_to_str(sizes.audio_total, desc, sizeof(desc));
+       printf(" Audio size : %s\n",  desc);
+       storage_size_to_str(sizes.misces_total, desc, sizeof(desc));
+       printf(" Misces size : %s\n",  desc);
+
+       storage_init_USB();
+       storage_deinit_USB();
+       return 0;
+}
+
+static int menufunc_st_me(int argc, char *argv[]){
+    int ret = MEMUFUNC_ERR_NONE;
+       char buf[SETTING_CMD_MAX_STR_LEN];
+
+       int media_ret = media_content_connect();
+       if (MEDIA_CONTENT_ERROR_NONE != media_ret) {
+               eprintf("media_content_connect() Fail(0x%x)\n Please execute this app with \"owner\" user\n", (-1)*media_ret);
+               return MEMUFUNC_ERR_NORMAL;
+       }
+       __get_storage_capacity(buf, SETTING_CMD_MAX_STR_LEN);
+
+       storage_get_internal_detail();
+       printf("%s", buf);
+
+       media_content_disconnect();
+    return ret;
+}
+
+static int menufunc_st_sd(int argc, char *argv[]){
+    int ret = MEMUFUNC_ERR_NONE;
+       int sd_status = 0;
+
+       double total = 0.0;
+       double avail = 0.0;
+       char total_str[SETTING_CMD_MAX_STR_LEN] = { 0 };
+       char avail_str[SETTING_CMD_MAX_STR_LEN] = { 0 };
+
+       ret = vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &sd_status);
+       if (ret != 0) {
+               eprintf("vconf_get_int(%s) fail!\n", VCONFKEY_SYSMAN_MMC_STATUS);
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       if (sd_status != VCONFKEY_SYSMAN_MMC_MOUNTED){
+                       eprintf("SD card NOT mounted!\n");
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       char *MMC_path = _TZ_SYS_MEDIA"/sdcard";
+
+       storage_get_external_storage_status(MMC_path, &total, &avail);
+       storage_size_to_str(total, total_str, sizeof(total_str));
+       storage_size_to_str(avail, avail_str, sizeof(avail_str));
+
+
+       printf("SD Card info\n");
+       printf("Total : %s\n", total_str);
+       printf("avail : %s\n", avail_str);
+
+
+    return ret;
+}
+
+static int menufunc_st_ms(int argc, char *argv[]){
+       struct mmc_contents mmc_content = {0};
+    int ret = MEMUFUNC_ERR_NONE;
+       int sd_status = 0;
+
+       ret = vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &sd_status);
+       if (ret != 0) {
+               eprintf("vconf_get_int(%s) fail!\n", VCONFKEY_SYSMAN_MMC_STATUS);
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       if (sd_status == VCONFKEY_SYSMAN_MMC_MOUNTED){
+               eprintf("SD card already mounted!\n");
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       ret = storage_request_mount_mmc(&mmc_content);
+       if (ret == -1) {
+               eprintf("storage_request_mount_mmc() Fail\n");
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       printf("SD card mount\n");
+    return MEMUFUNC_ERR_NONE;
+}
+
+static int menufunc_st_mss(int argc, char *argv[]){
+    int ret = MEMUFUNC_ERR_NONE;
+       int sd_status = 0;
+
+       ret = vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &sd_status);
+       if (ret != 0) {
+               eprintf("vconf_get_int(%s) fail!\n", VCONFKEY_SYSMAN_MMC_STATUS);
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       if (sd_status == VCONFKEY_SYSMAN_MMC_MOUNTED ||
+               sd_status == VCONFKEY_SYSMAN_MMC_EXTENDEDINTERNAL_MOUNTED){
+               printf("SD card mounted!\n");
+       } else {
+               printf("SD card NOT mounted!\n");
+       }
+
+    return MEMUFUNC_ERR_NONE;
+}
+
+static int menufunc_st_us(int argc, char *argv[]){
+       struct mmc_contents mmc_content = {0};
+    int ret = MEMUFUNC_ERR_NONE;
+       int sd_status = 0;
+
+       ret = vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &sd_status);
+       if (ret != 0) {
+               eprintf("vconf_get_int(%s) fail!\n", VCONFKEY_SYSMAN_MMC_STATUS);
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       if (sd_status != VCONFKEY_SYSMAN_MMC_MOUNTED){
+                       eprintf("SD card NOT mounted!\n");
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       ret = storage_request_unmount_mmc(&mmc_content, MNT_FORCE);
+       if (ret == -1) {
+               eprintf("storage_request_unmount_mmc() Fail\n");
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       printf("SD card Unmount\n");
+    return MEMUFUNC_ERR_NONE;
+}
+
+
+static int menufunc_st_fs(int argc, char *argv[]){
+    int ret = MEMUFUNC_ERR_NONE;
+
+       struct mmc_contents mmc_content = {0};
+       ret = storage_request_format_mmc(&mmc_content);
+       if (ret == -1) {
+               eprintf("failed to call storage_request_format_mmc\n");
+       }
+
+       printf("sd card format complete\n");
+    return ret;
+}
+
+static int menufunc_st_ids(int argc, char *argv[]){
+    int ret = MEMUFUNC_ERR_NONE;
+
+       int val = 0;
+
+       ret = vconf_set_int(VCONFKEY_SETAPPL_DEFAULT_MEM_WIFI_DIRECT_INT, val);
+       if (ret != 0) {
+               eprintf("vconf_get_int(%s) fail!\n", VCONFKEY_SETAPPL_DEFAULT_MEM_WIFI_DIRECT_INT);
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       ret = vconf_set_int(VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT, val);
+       if (ret != 0) {
+               eprintf("vconf_get_int(%s) fail!\n", VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT);
+               return MEMUFUNC_ERR_NORMAL;
+       }
+       printf("Set internal memory for default storage shared content\n");
+    return ret;
+}
+
+static int menufunc_st_sds(int argc, char *argv[]){
+    int ret = MEMUFUNC_ERR_NONE;
+
+       int val = 1;
+
+       ret = vconf_set_int(VCONFKEY_SETAPPL_DEFAULT_MEM_WIFI_DIRECT_INT, val);
+       if (ret != 0) {
+               eprintf("vconf_get_int(%s) fail!\n", VCONFKEY_SETAPPL_DEFAULT_MEM_WIFI_DIRECT_INT);
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       ret = vconf_set_int(VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT, val);
+       if (ret != 0) {
+               eprintf("vconf_get_int(%s) fail!\n", VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT);
+               return MEMUFUNC_ERR_NORMAL;
+       }
+       printf("Set SD card for default storage shared content\n");
+    return ret;
+}
+
+static int menufunc_st_ida(int argc, char *argv[]){
+    int ret = MEMUFUNC_ERR_NONE;
+
+       int val = 0;
+
+       ret = vconf_set_int(VCONFKEY_SETAPPL_DEFAULT_MEM_INSTALL_APPLICATIONS_INT, val);
+       if (ret != 0) {
+               eprintf("vconf_get_int(%s) fail!\n", VCONFKEY_SETAPPL_DEFAULT_MEM_INSTALL_APPLICATIONS_INT);
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       printf("Set internal memory for default storage app installation\n");
+    return ret;
+}
+
+static int menufunc_st_sda(int argc, char *argv[]){
+    int ret = MEMUFUNC_ERR_NONE;
+
+       int val = 1;
+
+       ret = vconf_set_int(VCONFKEY_SETAPPL_DEFAULT_MEM_INSTALL_APPLICATIONS_INT, val);
+       if (ret != 0) {
+               eprintf("vconf_get_int(%s) fail!\n", VCONFKEY_SETAPPL_DEFAULT_MEM_INSTALL_APPLICATIONS_INT);
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       printf("Set SD card for default storage app installation\n");
+    return ret;
+}
+
+static int menufunc_st_da(int argc, char *argv[]){
+    int ret = MEMUFUNC_ERR_NONE;
+
+       int val = 0;
+
+       ret = vconf_get_int(VCONFKEY_SETAPPL_DEFAULT_MEM_INSTALL_APPLICATIONS_INT, &val);
+       if (ret != 0) {
+               eprintf("vconf_get_int(%s) fail!\n", VCONFKEY_SETAPPL_DEFAULT_MEM_INSTALL_APPLICATIONS_INT);
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       printf("Default storage app installation : %s\n", (val)?"Internal memory":"SD Card");
+    return ret;
+}
+
+static int menufunc_st_ds(int argc, char *argv[]){
+    int ret = MEMUFUNC_ERR_NONE;
+
+       int val = 0;
+
+       ret = vconf_get_int(VCONFKEY_SETAPPL_DEFAULT_MEM_WIFI_DIRECT_INT, &val);
+       if (ret != 0) {
+               eprintf("vconf_get_int(%s) fail!\n", VCONFKEY_SETAPPL_DEFAULT_MEM_WIFI_DIRECT_INT);
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       printf("Default storage shared content with wifi : %s\n", (val)?"Internal memory":"SD Card");
+
+       ret = vconf_get_int(VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT, &val);
+       if (ret != 0) {
+               eprintf("vconf_get_int(%s) fail!\n", VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT);
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       printf("Default storage shared content with bluetooth : %s\n", (val)?"Internal memory":"SD Card");
+    return ret;
+}
+
+MenuItem st_menulist[] ={
+       {"me", "Device memory storage info", menufunc_st_me},
+       {"sd", "SD card storage info", menufunc_st_sd},
+       {"ds", "Get default storage shared content", menufunc_st_ds},
+       {"da", "Get default storage app installation", menufunc_st_da},
+       {"ids", "Internal memory for default storage shared content", menufunc_st_ids},
+       {"sds", "SD Card for default storage shared content", menufunc_st_sds},
+       {"ida", "Internal memory for Default storage app installation", menufunc_st_ida},
+       {"sda", "SD Card for Default storage app installation", menufunc_st_sda},
+       {"mss", "Get Mount SD card status", menufunc_st_mss},
+       {"ms", "Mount SD card", menufunc_st_ms},
+       {"us", "Unmount SD card", menufunc_st_us},
+       {"fs", "Format SD card", menufunc_st_fs},
+       {"fsp", "Format SD card as device storage", NULL}
+};
+
+int menufunc_st(int argc, char *argv[])
+{
+       printf("\n");
+
+       printf("Seting Command - Storage\n\n");
+       int menucount = sizeof(st_menulist)/sizeof(MenuItem);
+
+       int result = runMenulist(argc, argv, "setting_cmd st", st_menulist, menucount);
+       return result;
+}
+
+
diff --git a/src/sc_storage.h b/src/sc_storage.h
new file mode 100755 (executable)
index 0000000..3708d28
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef __SC_STORAGE_H_
+#define __SC_STORAGE_H_
+
+#include "settingcmd_def.h"
+
+
+int menufunc_st(int argc, char *argv[]);
+
+#endif         /* __SC_STORAGE_H_ */
diff --git a/src/sc_wifi.c b/src/sc_wifi.c
new file mode 100755 (executable)
index 0000000..684c77a
--- /dev/null
@@ -0,0 +1,55 @@
+#include "sc_wifi.h"
+#include "sc_common.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <vconf.h>
+#include <vconf-internal-keys.h>
+#include <system_settings.h>
+
+static int menufunc_wf_st(int argc, char *argv[])
+{
+    int ret = MEMUFUNC_ERR_NONE;
+    int state = 0;
+    ret = vconf_get_int(VCONFKEY_WIFI_STATE, &state);
+    if( ret != MEMUFUNC_ERR_NONE ) {
+        eprintf("\twifi state get fail!\n");
+    } else {
+        printf("\tState : %s\n", state? "On" : "Off" );
+    }
+
+    return ret;
+}
+
+static int menufunc_wf_nf(int argc, char *argv[])
+{
+    int ret = MEMUFUNC_ERR_NONE;
+    bool state = false;
+    ret = system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, &state);
+    if( ret != MEMUFUNC_ERR_NONE ) {
+        eprintf("\twifi notification get fail!\n");
+    } else {
+        printf("\tNodification : %s\n", state? "On" : "Off" );
+    }
+
+    return ret;
+}
+
+MenuItem wf_menulist[] ={
+       {"st", "State", menufunc_wf_st},
+       {"nf", "Notification", menufunc_wf_nf}
+};
+
+int menufunc_wf(int argc, char *argv[])
+{
+       printf("\n");
+
+       printf("Seting Command - Wifi\n\n");
+       int menucount = sizeof(wf_menulist)/sizeof(MenuItem);
+
+       int result = runMenulist(argc, argv, "setting_cmd wf", wf_menulist, menucount);
+       return result;
+}
+
+
diff --git a/src/sc_wifi.h b/src/sc_wifi.h
new file mode 100755 (executable)
index 0000000..77cfc0a
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef __SC_WIFI_H_
+#define __SC_WIFI_H_
+
+#include "settingcmd_def.h"
+
+
+int menufunc_wf(int argc, char *argv[]);
+
+#endif         /* __SC_WIFI_H_ */
diff --git a/src/setting_cmd.c b/src/setting_cmd.c
new file mode 100755 (executable)
index 0000000..a6b06ba
--- /dev/null
@@ -0,0 +1,86 @@
+#include "settingcmd_def.h"
+#include "sc_common.h"
+#include "sc_aboutdevice.h"
+#include "sc_sound.h"
+#include "sc_display.h"
+#include "sc_apps.h"
+#include "sc_datetime.h"
+#include "sc_wifi.h"
+#include "sc_bluetooth.h"
+#include "sc_airplane.h"
+#include "sc_storage.h"
+#include "sc_datausage.h"
+#include "sc_battery.h"
+
+#include <stdio.h>
+
+
+MenuItem mobile_main_menulist[] ={
+       {"wf", "Wi-Fi", menufunc_wf},
+       {"bt", "BlueTooth", menufunc_bt},
+       {"am", "Airplane Mode", menufunc_am},
+       {"te", "Tethering", NULL},
+       {"mn", "Mobile networks", NULL},
+       {"so", "Sound", menufunc_so},
+       {"di", "Display", menufunc_di},
+       {"ap", "Apps", menufunc_apps},
+       {"wp", "Wallpaper", NULL},
+       {"ls", "LockScreen", NULL},
+       {"ac", "Accessibility", NULL},
+       {"ps", "Privacy and security", NULL},
+       {"ac", "Accounts", NULL},
+       {"br", "Backup and reset", NULL},
+       {"li", "Language and input", NULL},
+       {"ba", "Battery", menufunc_ba},
+       {"da", "Data", NULL},
+       {"st", "Storage", menufunc_st},
+       {"dt", "Date and time", menufunc_dt},
+       {"du", "Data Usage", menufunc_du},
+       {"ad", "About device", menufunc_ad}
+};
+
+MenuItem wearable_main_menulist[] ={
+       {"wf", "Wi-Fi", NULL},
+       {"bt", "BlueTooth", NULL},
+       {"am", "Airplane Mode", NULL},
+       {"mn", "Mobile networks", NULL},
+       {"so", "Sound", menufunc_so},
+       {"di", "Display", menufunc_di},
+       {"ac", "Accessibility", NULL},
+       {"ac", "Accounts", NULL},
+       {"li", "Language and input", NULL},
+       {"du", "Data Usage", menufunc_du},
+       {"ad", "About device", menufunc_ad},
+};
+
+int main(int argc, char *argv[])
+{
+       printf("Setting Command application is being implemented... \n");
+
+       int menucount = 0;
+       MenuItem *main_menulist = NULL;
+
+       int profile = getProfile();
+       if (profile < 0){
+               printError(MEMUFUNC_ERR_NORMAL);
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       if (profile == MOBILE_PROFILE) {
+               main_menulist = mobile_main_menulist;
+               menucount = sizeof(mobile_main_menulist)/sizeof(MenuItem);
+       } else if (profile == WEARABLE_PROFILE) {
+               main_menulist = wearable_main_menulist;
+               menucount = sizeof(wearable_main_menulist)/sizeof(MenuItem);
+       } else {
+               printError(MEMUFUNC_ERR_NORMAL);
+               return MEMUFUNC_ERR_NORMAL;
+       }
+
+       int result = runMenulist(argc, argv, "setting_cmd", main_menulist, menucount);
+       if (result != MEMUFUNC_ERR_NONE)
+               printError(result);
+
+       return result;
+}
+
diff --git a/src/setting_cmd.h b/src/setting_cmd.h
new file mode 100755 (executable)
index 0000000..ae29648
--- /dev/null
@@ -0,0 +1,7 @@
+#ifndef __SETTING_CMD_
+#define __SETTING_CMD_
+
+#include <system_settings.h>
+
+
+#endif
diff --git a/src/settingcmd_def.h b/src/settingcmd_def.h
new file mode 100755 (executable)
index 0000000..8d52693
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef __SETTINGCMD_DEF_H_
+#define __SETTINGCMD_DEF_H_
+
+#define MEMUFUNC_ERR_NONE 0
+#define MEMUFUNC_ERR_NORMAL (-1)
+#define MEMUFUNC_ERR_ARG_SHORT (-2)
+#define MEMUFUNC_ERR_ARG_INVAILD (-3)
+#define MEMUFUNC_ERR_NOTIMPL (-4)
+
+typedef  int (*MenuFunc)(int argc, char *argv[]);
+
+typedef struct{
+       char *opt;
+       char *menu;
+       MenuFunc menufunc;
+} MenuItem;
+
+
+
+enum profile {
+       MOBILE_PROFILE = 1,
+       WEARABLE_PROFILE,
+       TV_PROFILE,
+       COMMON_PROFILE,
+       MAX_PROFILE
+};
+
+
+#endif /* __SETTINGCMD_DEF_H_ */