--- /dev/null
+# VS settings
+ut
+Doxyfile
+dbus.c
+dbus.h
+tags
+
+# VS settings
+.vs
+*.vcxproj*
+*.sln
+*.tlog
+cpp.hint
+*.cd
+
+# project config
+.cproject
+.project
+.settings/*
+
+# Prerequisites
+*.d
+
+# Compiled Object files
+*.slo
+*.lo
+*.o
+*.obj
+
+# Precompiled Headers
+*.gch
+*.pch
+
+# Compiled Dynamic libraries
+*.so
+*.dylib
+*.dll
+
+# Fortran module files
+*.mod
+*.smod
+
+# Compiled Static libraries
+*.lai
+*.la
+*.a
+*.lib
+
+# Executables
+*.exe
+*.out
+*.app
+
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}\"")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GC_SECTIONS_FLAGS} -std=c++11")
+SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
+INCLUDE(Definitions.cmake)
#setting main view build start
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
--- /dev/null
+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}\"")
if (arg) { \
/*cast any argument to (void*) to avoid build warring*/\
del((void *)(arg)); \
- arg = NULL; \
+ arg = nullptr; \
} \
} while (0)
#define FREE(arg) __FREE(free, arg)
%ifarch %{arm}
export CFLAGS="$CFLAGS -DTIZEN_BUILD_TARGET"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_BUILD_TARGET"
%else
export CFLAGS="$CFLAGS -DTIZEN_BUILD_EMULATOR"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_BUILD_EMULATOR"
%endif
%ifarch %{arm}
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
INCLUDE(FindPkgConfig)
pkg_check_modules(pkgs_main REQUIRED
elementary
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}")
+ SET(EXTRA_CXXFLAGS "${EXTRA_CXXFLAGS} ${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(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXXFLAGS}")
+SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
+
SET(BUILD_ARCH "${ARCH}")
IF("${BUILD_ARCH}" STREQUAL "arm")
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
+ ./SettingMenu.cpp
+ ./GenSettingMenu.cpp
+ ./setting_cmd.cpp
+ ./sc_common.cpp
+ ./sc_aboutdevice.cpp
+ ./sc_sound.cpp
+ ./sc_display.cpp
+ ./sc_apps.cpp
+ ./sc_datetime.cpp
+ ./sc_wifi.cpp
+ ./sc_bluetooth.cpp
+ ./sc_airplane.cpp
+ ./sc_storage.cpp
+ ./sc_battery.cpp
+ ./sc_datausage.cpp
)
# dmalloc
--- /dev/null
+#include "GenSettingMenu.h"\r
+#include "sc_common.h"\r
+\r
+using namespace std;\r
+\r
+GenSettingMenu::GenSettingMenu(const char * optstr, const char * namestr, MenuFunc funcptr, MenuCreate precreateptr)
+ :strOpt(optstr), strName(namestr), ptrFunc(funcptr), ptrPrecreate(precreateptr)
+{
+}
+
+bool GenSettingMenu::create()
+{
+ eprintf("entered in GenSettingMenu::create() of %s\n", name());
+ if(ptrPrecreate)
+ (*ptrPrecreate)(this);
+
+ return SettingMenu::create();
+}
+
+
+MENURUN_ERROR GenSettingMenu::func(string &title, int argc, char *argv[])
+{
+ eprintf("func() of %s, %p, %p\n", name(), ptrFunc, ptrPrecreate);
+ if (ptrFunc) {
+ printf("%s\n\n", title.c_str());
+ return (*ptrFunc)(argc, argv, this);
+ }
+
+ return MEMUFUNC_ERR_NONE;
+}
+bool GenSettingMenu::isImplemented()
+{
+ if (ptrFunc == nullptr && subMenus.empty()) return false;
+ return true;
+}
+
+const char *GenSettingMenu::opt()
+{
+ return strOpt;
+}
+
+const char *GenSettingMenu::name()
+{
+ return strName;
+}\r
+\r
+void GenSettingMenu::addSubmenu(const char * optstr, const char * namestr, MenuFunc funcptr, MenuCreate precreateptr)\r
+{\r
+ subMenus.push_back(new GenSettingMenu(optstr, namestr, funcptr, precreateptr));\r
+}\r
+\r
+void GenSettingMenu::addSubmenu(MenuItem item)\r
+{\r
+ addSubmenu(item.optstr, item.namestr, item.funcptr, item.precreateptr);\r
+}\r
+\r
+void GenSettingMenu::addSubmenus(MenuItem *items, int count)\r
+{\r
+ if (items == nullptr || count < 1)\r
+ return;\r
+\r
+ for (int i = 0; i < count; i++)\r
+ addSubmenu(items[i]);\r
+}
--- /dev/null
+#ifndef __GENSETTINGMENU_H_
+#define __GENSETTINGMENU_H_
+
+#include "SettingMenu.h"
+
+#include <list>
+
+class GenSettingMenu;
+
+typedef MENURUN_ERROR (*MenuFunc)(int argc, char *argv[], GenSettingMenu *menu);
+typedef void (*MenuCreate)(GenSettingMenu *menu);
+
+typedef struct {\r
+ const char *optstr;\r
+ const char *namestr;\r
+ MenuFunc funcptr;\r
+ MenuCreate precreateptr;\r
+} MenuItem;
+
+
+class GenSettingMenu : public SettingMenu
+{
+public:
+ GenSettingMenu(const char * optstr, const char * namestr, MenuFunc funcptr = nullptr, MenuCreate precreateptr = nullptr);
+
+public:
+ bool create();
+
+ MENURUN_ERROR func(std::string &title, int argc, char *argv[]);
+ bool isImplemented();
+
+ const char *opt();
+ const char *name();
+
+ void addSubmenu(const char * optstr, const char * namestr, MenuFunc funcptr = nullptr, MenuCreate precreateptr = nullptr);
+ void addSubmenu(MenuItem item);
+ void addSubmenus(MenuItem *items, int count);
+
+private:
+ const char * strOpt;
+ const char * strName;
+
+ MenuFunc ptrFunc;
+ MenuCreate ptrPrecreate;
+};
+
+#endif //__GENSETTINGMENU_H_
--- /dev/null
+#include "SettingMenu.h"
+#include "sc_common.h"
+
+#include <algorithm>
+#include <list>
+#include <stdio.h>
+#include <string.h>
+
+using namespace std;
+
+
+bool SettingMenu::create()
+{
+ eprintf("entered in SettingMenu::create() of %s\n", name());
+ for (auto it = subMenus.begin(); it != subMenus.end(); ++it) {
+ if (!(*it)->create()) {
+ destroy();
+ return false;
+ }
+ }
+ return true;
+}
+
+void SettingMenu::destroy()
+{
+ while (!subMenus.empty())\r
+ {\r
+ SettingMenu *menu = subMenus.back();\r
+ menu->destroy();\r
+ delete menu;\r
+ subMenus.pop_back();\r
+ }
+}
+
+MENURUN_ERROR SettingMenu::run(string &title, int argc, char *argv[])
+{
+ eprintf("run() of %s\n", name());
+
+ title += string(" - ") + name();
+
+ MENURUN_ERROR result = func(title, argc, argv);
+ if (result != MEMUFUNC_ERR_NONE) return result;
+
+ if (subMenus.empty()) return MEMUFUNC_ERR_NONE;
+
+ if (argc < 2) {
+ printUsage();
+ return MEMUFUNC_ERR_ARG_SHORT;
+ }
+ auto it = find_if(subMenus.begin(), subMenus.end(),
+ [=](SettingMenu *menu) -> bool {
+ if (!strcmp(argv[1], menu->opt())) return true;
+ return false;
+ }
+ );
+ if (it == subMenus.end()) {
+ eprintf("%s is not a valid command.\n\n", argv[1]);
+ printUsage();
+ return MEMUFUNC_ERR_ARG_INVAILD;
+ }
+ eprintf("command %s is founded.\n", argv[1]);
+
+ return ((*it)->run)(title, argc - 1, &argv[1]);
+}
+
+MENURUN_ERROR SettingMenu::func(string &title, int argc, char *argv[])
+{
+ eprintf("func() of %s\n", name());
+ return MEMUFUNC_ERR_NONE;
+}
+
+void SettingMenu::printUsage()
+{
+ const char *notimplemented_str = "[Not implemented]";
+
+ printf("Usage : %s [opt]\n", opt());
+ printf("\t[opt] : [Menu]\n");
+
+ for_each(subMenus.begin(), subMenus.end(),
+ [=](SettingMenu *menu) {
+ if (menu->isImplemented())
+ printf("\t %s : %s\n", menu->opt(), menu->name());
+ else
+ printf("\t %s : %s - %s\n", menu->opt(), menu->name(), notimplemented_str);
+ }
+ );
+ printf("\n");
+}
+
+void SettingMenu::printError(MENURUN_ERROR 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;
+ }
+}
--- /dev/null
+#ifndef __SETTINGMENU_H_
+#define __SETTINGMENU_H_
+
+#include <string>
+#include <list>
+
+enum MENURUN_ERROR {
+ MEMUFUNC_ERR_NONE = 0,
+ MEMUFUNC_ERR_NORMAL = -1,
+ MEMUFUNC_ERR_ARG_SHORT = -2,
+ MEMUFUNC_ERR_ARG_INVAILD = -3,
+ MEMUFUNC_ERR_NOTIMPL = -4
+};
+
+class SettingMenu
+{
+public:
+ SettingMenu() {}
+ virtual ~SettingMenu() { destroy(); }
+
+public:
+ virtual bool create();
+ virtual void destroy();
+ virtual MENURUN_ERROR run(std::string &title, int argc, char *argv[]);
+
+ virtual MENURUN_ERROR func(std::string &title, int argc, char *argv[]);
+
+ virtual bool isImplemented() { return false; }
+
+ virtual const char *name() = 0;
+ virtual const char *opt() = 0;
+
+public:
+ void printUsage();
+ static void printError(MENURUN_ERROR error);
+
+public:
+ std::list<SettingMenu *> subMenus;
+};
+
+#endif //__SETTINGMENU_H_
if (arg) { \
/*cast any argument to (void*) to avoid build warring*/\
del((void *)(arg)); \
- arg = NULL; \
+ arg = nullptr; \
} \
} while (0)
#define FREE(arg) __FREE(free, arg)
*/
static void __get_phone_model_name(char *szStr, int nSize)
{
- if (szStr == NULL)
- eprintf("szStr parameter is NULL\n");
+ if (szStr == nullptr)
+ eprintf("szStr parameter is nullptr\n");
- char *value = NULL;
+ char *value = nullptr;
int ret = system_info_get_platform_string(
"http://tizen.org/system/model_name", &value);
SETTING_TRACE("value : %s", value);
*/
static void __get_sw_version(char *szStr, int nSize)
{
- if (szStr == NULL)
- eprintf("szStr parameter is NULL\n");
+ if (szStr == nullptr)
+ eprintf("szStr parameter is nullptr\n");
- char *version = NULL;
+ char *version = nullptr;
int ret = system_info_get_platform_string(
"http://tizen.org/feature/platform.version", &version);
if (ret != SYSTEM_INFO_ERROR_NONE) {
int ret = 0;
- char *cpu_name = NULL;
+ char *cpu_name = nullptr;
ret = system_info_get_platform_string(
"http://tizen.org/system/platform.processor", &cpu_name);
/*---------------------------------------------------------------------------------------------------------------------------*/
#define MAX_DISPLAY_STR_LEN_ON_PHONE_INFO 256
-static int menufunc_ad_name(int argc, char *argv[])
+static MENURUN_ERROR menufunc_ad_name(int argc, char *argv[], GenSettingMenu *menu)
{
char *name_value = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR);
printf("\tName : ");
return MEMUFUNC_ERR_NONE;
}
-static int menufunc_ad_mn(int argc, char *argv[])
+static MENURUN_ERROR menufunc_ad_mn(int argc, char *argv[], GenSettingMenu *menu)
{
char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO];
return MEMUFUNC_ERR_NONE;
}
-static int menufunc_ad_ver(int argc, char *argv[])
+static MENURUN_ERROR menufunc_ad_ver(int argc, char *argv[], GenSettingMenu *menu)
{
char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO];
return MEMUFUNC_ERR_NONE;
}
-static int menufunc_ad_cpu(int argc, char *argv[])
+static MENURUN_ERROR menufunc_ad_cpu(int argc, char *argv[], GenSettingMenu *menu)
{
char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO];
return MEMUFUNC_ERR_NONE;
}
-static int menufunc_ad_ram(int argc, char *argv[])
+static MENURUN_ERROR menufunc_ad_ram(int argc, char *argv[], GenSettingMenu *menu)
{
char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO];
return MEMUFUNC_ERR_NONE;
}
-static int menufunc_ad_res(int argc, char *argv[])
+static MENURUN_ERROR menufunc_ad_res(int argc, char *argv[], GenSettingMenu *menu)
{
char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO];
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)
+static MENURUN_ERROR _get_sim_phone_number(int sim_number, char * str, int str_size)
{
telephony_handle_list_s tel_h_list;
- char *phone_num = NULL;
+ char *phone_num = nullptr;
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) {
+ if ((int)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");
}
ret = telephony_sim_get_subscriber_number(tel_h_list.handle[sim_number-1], &phone_num);
- if (!ret && (phone_num != NULL)) {
+ if (!ret && (phone_num != nullptr)) {
snprintf(str, str_size, "%s", phone_num);
free(phone_num);
} else {
}
-static int menufunc_ad_sim1(int argc, char *argv[])
+static MENURUN_ERROR menufunc_ad_sim1(int argc, char *argv[], GenSettingMenu *menu)
{
char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO];
- int ret = _get_sim_phone_number(1, str, sizeof(str));
+ MENURUN_ERROR ret = _get_sim_phone_number(1, str, sizeof(str));
if (ret != MEMUFUNC_ERR_NONE)
return ret;
printf("\tSIM1 Phone Number : ");
return ret;
}
-static int menufunc_ad_sim2(int argc, char *argv[])
+static MENURUN_ERROR menufunc_ad_sim2(int argc, char *argv[], GenSettingMenu *menu)
{
char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO];
- int ret = _get_sim_phone_number(2, str, sizeof(str));
+ MENURUN_ERROR ret = _get_sim_phone_number(2, str, sizeof(str));
if (ret != MEMUFUNC_ERR_NONE)
return ret;
printf("\tSIM2 Phone Number : ");
}
/* sim_number is started from 1, ex) SIM1, SIM2, SIM3 ... */
-static int _get_sim_ime(int sim_number, char * str, int str_size)
+static MENURUN_ERROR _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;
+ char *ime_buffer = nullptr;
+
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) {
+ if ((int)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;
}
- ret = telephony_modem_get_imei(tel_h_list.handle[sim_number-1], &ime_buffer);
- if (!ret && (ime_buffer != NULL)) {
+ int ret = telephony_modem_get_imei(tel_h_list.handle[sim_number-1], &ime_buffer);
+ if (!ret && (ime_buffer != nullptr)) {
snprintf(str, str_size, "%s", ime_buffer);
free(ime_buffer);
} else {
return MEMUFUNC_ERR_NONE;
}
-static int menufunc_ad_ime1(int argc, char *argv[])
+static MENURUN_ERROR menufunc_ad_ime1(int argc, char *argv[], GenSettingMenu *menu)
{
char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO];
- int ret = _get_sim_ime(1, str, sizeof(str));
+ MENURUN_ERROR ret = _get_sim_ime(1, str, sizeof(str));
if (ret != MEMUFUNC_ERR_NONE)
return ret;
printf("\tIME1 : ");
return ret;
}
-static int menufunc_ad_ime2(int argc, char *argv[])
+static MENURUN_ERROR menufunc_ad_ime2(int argc, char *argv[], GenSettingMenu *menu)
{
char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO];
- int ret = _get_sim_ime(2, str, sizeof(str));
+ MENURUN_ERROR ret = _get_sim_ime(2, str, sizeof(str));
if (ret != MEMUFUNC_ERR_NONE)
return ret;
printf("\tIME2 : ");
return ret;
}
-static int menufunc_ad_bta(int argc, char *argv[])
+static MENURUN_ERROR menufunc_ad_bta(int argc, char *argv[], GenSettingMenu *menu)
{
char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO];
int ret = bt_initialize();
- char *local_address = NULL;
+ char *local_address = nullptr;
ret = bt_adapter_get_address(&local_address);
bt_deinitialize();
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",
+ eprintf("Fail to get BT address, error code: %d\n",
ret);
} else {
snprintf(str, sizeof(str), "%s", local_address);
return MEMUFUNC_ERR_NONE;
}
-static int menufunc_ad_wfa(int argc, char *argv[])
+static MENURUN_ERROR menufunc_ad_wfa(int argc, char *argv[], GenSettingMenu *menu)
{
char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO];
- wifi_manager_h wifi_handle = NULL;
- char *mac_addr = NULL;
- int ret;
+ wifi_manager_h wifi_handle = nullptr;
+ char *mac_addr = nullptr;
/* get wifi handle */
- ret = wifi_manager_initialize(&wifi_handle);
+ int ret = wifi_manager_initialize(&wifi_handle);
if (ret != WIFI_MANAGER_ERROR_NONE)
return MEMUFUNC_ERR_NORMAL;
free(mac_addr);
} else {
snprintf(str, sizeof(str), "WIFI is unavailable!\n");
- eprintf("failed to get WIFI address, error code: %d\n",
+ eprintf("Fail to get WIFI address, error code: %d\n",
ret);
}
return MEMUFUNC_ERR_NONE;
}
-static int menufunc_ad_sto(int argc, char *argv[])
+static MENURUN_ERROR menufunc_ad_sto(int argc, char *argv[], GenSettingMenu *menu)
{
char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO];
long long int total = 0;
return MEMUFUNC_ERR_NONE;
}
-static int menufunc_ad_batt(int argc, char *argv[])
+static MENURUN_ERROR menufunc_ad_batt(int argc, char *argv[], GenSettingMenu *menu)
{
int val = -1;
char file[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO] = { 0, };
unsigned long long elapsed_tick;
long tick_per_sec;
long cpu_num;
- FILE *fp = NULL;
+ FILE *fp = nullptr;
int ret = 0;
tick_per_sec = sysconf(_SC_CLK_TCK);
if (cpu_num < 1)
cpu_num = 1;
- gettimeofday(&cur_tv, NULL);
+ gettimeofday(&cur_tv, nullptr);
fp = fopen(SETTING_ABOUT_STAT_PATH, "r");
- if (fp == NULL) {
- eprintf("fp == NULL\n");
+ if (fp == nullptr) {
+ eprintf("fp == nullptr\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) {
+ if (cpu_info_p == nullptr) {
eprintf("fgets failed\n");
fclose(fp); /* free - code */
return -ENOENT;
}
- char *substr = NULL;
+ char *substr = nullptr;
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;
+ while ((substr = strsep(&cpu_info_p, " \t")) != nullptr) {
+ char *endptr = nullptr;
tmp_long = strtoull(substr, &endptr, 10);
if (tmp_long != 0 && tmp_long != ULLONG_MAX) {
switch (i) {
}
fclose(fp);
- fp = NULL;
+ fp = nullptr;
if (old_usr == 0) {
ret = -EAGAIN;
//eprintf("old_usr == 0\n");
return ret;
}
-static int menufunc_ad_cpuu(int argc, char *argv[])
+static MENURUN_ERROR menufunc_ad_cpuu(int argc, char *argv[], GenSettingMenu *menu)
{
float usr = 0.0;
float sys = 0.0;
- int ret = 0;
+ MENURUN_ERROR ret = MEMUFUNC_ERR_NONE;
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)
+ int result = __stat_get_cpu_usage(&usr, &sys);
+ if (result != 0)
continue;
printf("\tCPU usage : ");
printf("%.0f%%\n", usr + sys);
{"cpuu", "CPU usage", menufunc_ad_cpuu}
};
-
-
-int menufunc_ad(int argc, char *argv[])
+void precreate_ad(GenSettingMenu *menu)
{
- 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;
+ eprintf("entered precreate_du\n");
+ menu->destroy();
+ menu->addSubmenus(ad_menulist, sizeof(ad_menulist) / sizeof(MenuItem));
}
#define __SC_ABOUTDEVICE_H_\r
\r
#include "settingcmd_def.h"\r
+#include "GenSettingMenu.h"\r
\r
-\r
-int menufunc_ad(int argc, char *argv[]);\r
+void precreate_ad(GenSettingMenu *menu);\r
\r
#endif /* __SC_ABOUTDEVICE_H_ */\r
+++ /dev/null
-#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;
-}
-
--- /dev/null
+#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 MENURUN_ERROR menufunc_am_st(int argc, char *argv[], GenSettingMenu *menu)
+{
+ bool ret_state = false;
+
+ int 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");
+ return MEMUFUNC_ERR_NORMAL;
+ }
+
+ printf("\tFlight mode : %s\n", ret_state? "On" : "Off");
+ return MEMUFUNC_ERR_NONE;
+}
+
+MenuItem am_menulist[] ={
+ {"st", "State", menufunc_am_st}
+};
+
+void precreate_am(GenSettingMenu *menu)
+{
+ eprintf("entered precreate_am\n");
+ menu->destroy();
+ menu->addSubmenus(am_menulist, sizeof(am_menulist) / sizeof(MenuItem));
+}
#define __SC_AIRPLANE_H_
#include "settingcmd_def.h"
-
-
-int menufunc_am(int argc, char *argv[]);
+#include "GenSettingMenu.h"\r
+\r
+void precreate_am(GenSettingMenu *menu);
#endif /* __SC_AIRPLANE_H_ */
static int _apps_sort_by_size(const void *a, const void *b)
{
- const app_node *info1 = a;
- const app_node *info2 = b;
+ const app_node *info1 = (const app_node *)a;
+ const app_node *info2 = (const app_node *)b;
- if (NULL == a) return 0;
- if (NULL == b) return 0;
+ if (nullptr == a) return 0;
+ if (nullptr == 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;
+ const package_node *info1 = (const package_node *)a;
+ const package_node *info2 = (const package_node *)b;
- if (NULL == a) return 0;
- if (NULL == b) return 0;
+ if (nullptr == a) return 0;
+ if (nullptr == 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;
+ const app_node *info1 = (const app_node *)a;
+ const app_node *info2 = (const app_node *)b;
- if (NULL == a) return 0;
- if (NULL == b) return 0;
- if (NULL == info1->label) return -1;
- if (NULL == info2->label) return 1;
+ if (nullptr == a) return 0;
+ if (nullptr == b) return 0;
+ if (nullptr == info1->label) return -1;
+ if (nullptr == info2->label) return 1;
if (strlen(info1->label) < strlen(info2->label))
len = strlen(info1->label);
static int _packages_sort_ztoa(const void *a, const void *b)
{
int len;
- const package_node *info1 = a;
- const package_node *info2 = b;
+ const package_node *info1 = (const package_node *)a;
+ const package_node *info2 = (const package_node *)b;
- if (NULL == a) return 0;
- if (NULL == b) return 0;
- if (NULL == info1->label) return -1;
- if (NULL == info2->label) return 1;
+ if (nullptr == a) return 0;
+ if (nullptr == b) return 0;
+ if (nullptr == info1->label) return -1;
+ if (nullptr == info2->label) return 1;
if (strlen(info1->label) < strlen(info2->label))
len = strlen(info1->label);
void appmgr_utils_update_app_node(app_node *node, app_info_h app_info)
{
- char *label = NULL;
+ char *label = nullptr;
if(!node) return;
(void)app_info_get_app_id(app_info, &node->appid);
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));
+ Eina_List **list = (Eina_List **)user_data;
+ app_node *node = (app_node *)calloc(1, sizeof(app_node));
if (!node) return false;
}
-static int menufunc_apps_lall(int argc, char *argv[])
+static MENURUN_ERROR menufunc_apps_lall(int argc, char *argv[], GenSettingMenu *menu)
{
int ret;
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}
+ {"ldn", "List Apps - Downloads", nullptr},
+ {"lrun", "List Apps - Running", nullptr},
+ {"loff", "List Apps - Turned off", nullptr},
+ {"ainfo", "Application Info", nullptr},
+ {"astor", "App - Storage", nullptr},
+ {"afc", "App - Force close", nullptr},
+ {"aoff", "App - Turn off", nullptr},
+ {"astop", "App - Stop", nullptr},
+ {"aclc", "App - Clear cache", nullptr},
+ {"lhome", "List Homes", nullptr},
+ {"home", "Home", nullptr},
+ {"ldef", "List Defaults", nullptr},
+ {"cldef", "Clear Defaults", nullptr},
+ {"setdef", "Set Defaults", nullptr},
+ {"usetdef", "Unset Defaults", nullptr}
};
-int menufunc_apps(int argc, char *argv[])
+void precreate_apps(GenSettingMenu *menu)
{
- 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;
+ eprintf("entered precreate_apps\n");
+ menu->destroy();
+ menu->addSubmenus(apps_menulist, sizeof(apps_menulist) / sizeof(MenuItem));
}
-
#define __SC_APPS_H_\r
\r
#include "settingcmd_def.h"\r
+#include "GenSettingMenu.h"\r
\r
-\r
-int menufunc_apps(int argc, char *argv[]);\r
+void precreate_apps(GenSettingMenu *menu);\r
\r
#endif /* __SC_APPS_H_ */\r
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;
+ char *appid = nullptr;
+ context_history_h handle = nullptr;
+ context_history_filter_h filter = nullptr;
+ context_history_list_h list = nullptr;
+ context_history_record_h record = nullptr;
double percent = 0.0;
ret = context_history_create(&handle);
printf("\t%s : %.2f %% \n", appid, percent);
(void)context_history_record_destroy(record);
- record = NULL;
+ record = nullptr;
(void)context_history_list_move_next(list);
if (appid) {
free(appid);
- appid = NULL;
+ appid = nullptr;
}
}
#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[])
+
+MENURUN_ERROR menufunc_ba(int argc, char *argv[], GenSettingMenu *menu)
{
printf("\n");
- int result = MEMUFUNC_ERR_NONE;
printf("Seting Command - Battery\n\n");
int val = -1;
_get_battery_usage_details_list();
- return result;
+ return MEMUFUNC_ERR_NONE;
}
#define __SC_BATTERY_H_\r
\r
#include "settingcmd_def.h"\r
+#include "GenSettingMenu.h"\r
\r
-\r
-int menufunc_ba(int argc, char *argv[]);\r
+MENURUN_ERROR menufunc_ba(int argc, char *argv[], GenSettingMenu *menu);\r
\r
#endif /* __SC_BATTERY_H_ */\r
#include <system_settings.h>
#include <bluetooth.h>
-static int menufunc_bt_st(int argc, char *argv[])
+static MENURUN_ERROR menufunc_bt_st(int argc, char *argv[], GenSettingMenu *menu)
{
- int ret = MEMUFUNC_ERR_NONE;
-
+ if (bt_initialize() != BT_ERROR_NONE) {
+ eprintf("bt_initialize() failed\n");
+ return MEMUFUNC_ERR_NORMAL;
+ }
bt_adapter_state_e bt_state;
if (bt_adapter_get_state(&bt_state) != BT_ERROR_NONE) {
eprintf("bt_adapter_get_state() failed\n");
+ bt_deinitialize();
return MEMUFUNC_ERR_NORMAL;
}
+ bt_deinitialize();\r
printf("\tState : %s\n", (bt_state == BT_ADAPTER_ENABLED) ? "On" : "Off");
-
- return ret;
+ return MEMUFUNC_ERR_NONE;
}
MenuItem bt_menulist[] ={
{"st", "State", menufunc_bt_st}
};
-int menufunc_bt(int argc, char *argv[])
+void precreate_bt(GenSettingMenu *menu)
{
- 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;
+ eprintf("entered precreate_bt\n");
+ menu->destroy();
+ menu->addSubmenus(bt_menulist, sizeof(bt_menulist) / sizeof(MenuItem));
}
-
#define __SC_BLUETOOTH_H_
#include "settingcmd_def.h"
-
-
-int menufunc_bt(int argc, char *argv[]);
+#include "GenSettingMenu.h"
+\r
+void precreate_bt(GenSettingMenu *menu);
#endif /* __SC_BLUETOOTH_H_ */
+++ /dev/null
-#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;
-}
--- /dev/null
+#include "sc_common.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <system_info.h>
+
+int getProfile() {
+ int profile = 0;
+ char *profile_str = nullptr;
+ 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 == nullptr)
+ 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;
+}
#ifndef __SC_COMMON_H_
#define __SC_COMMON_H_
-#include <stdbool.h>
+#include <stdio.h>
#include "settingcmd_def.h"
-
+#ifdef __SC_DEBUG__
#define eprintf(...) fprintf (stderr, __VA_ARGS__)
-void printUsage(char * title, MenuItem *menulist, int menucount);
+#else
+#define eprintf(...) do {} while (0)
+#endif
-/*
- 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_ */
if (arg) { \
/*cast any argument to (void*) to avoid build warring*/\
del((void *)(arg)); \
- arg = NULL; \
+ arg = nullptr; \
} \
} while (0)
#define FREE(arg) __FREE(free, arg)
-static GMainLoop* multi_main_loop = NULL;
+static GMainLoop* multi_main_loop = nullptr;
typedef enum {
MV_UPDATE_APPEND_NONE = 0,
MV_UPDATE_SIM_STATE_CHANGED,
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);
+ return _get_total_stats(stc, STC_IFACE_WIFI, stats_cb, nullptr, t_from, t_to);
}
bool get_sim_apps_list(stc_h stc, stc_stats_info_cb stats_cb,
time_t t_to)
{
return _create_stats_list(stc, STC_IFACE_WIFI, stats_cb,
- NULL, t_from, t_to);
+ nullptr, 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);
+ return _get_restrictions(stc, STC_IFACE_DATACALL, restrictions_cb, nullptr);
}
bool get_wifi_restrictions(stc_h stc, stc_restriction_rule_cb restrictions_cb)
{
- return _get_restrictions(stc, STC_IFACE_WIFI, restrictions_cb, NULL);
+ return _get_restrictions(stc, STC_IFACE_WIFI, restrictions_cb, nullptr);
}
static bool _create_stats_list(stc_h stc, stc_iface_type_e iface,
void *cb_data, time_t t_from,
time_t t_to)
{
- stc_stats_rule_h rule = NULL;
+ stc_stats_rule_h rule = nullptr;
int ret = stc_stats_rule_create(stc, &rule);
if (ret != STC_ERROR_NONE) {
stc_stats_info_cb stats_cb, void *cb_data,
time_t t_from, time_t t_to)
{
- stc_stats_rule_h rule = NULL;
+ stc_stats_rule_h rule = nullptr;
int ret = STC_ERROR_NONE;
ret = stc_stats_rule_create(stc, &rule);
void *restriction_info_cb_data)
{
int ret = STC_ERROR_NONE;
- stc_restriction_rule_h rule = NULL;
+ stc_restriction_rule_h rule = nullptr;
ret = stc_restriction_rule_create(stc, &rule);
if (STC_ERROR_NONE != ret) {
static bool isEmptyStr(const char *str)
{
- if (NULL == str || '\0' == str[0])
+ if (nullptr == str || '\0' == str[0])
return true;
return false;
}
static int safeStrNCmp(const char *s1, const char *s2, int len)
{
- /* Check NULL value first */
+ /* Check nullptr value first */
if (isEmptyStr(s1) && isEmptyStr(s2))
return 0;
else if (isEmptyStr(s1))
{
SETTING_TRACE_BEGIN;
int ret = STC_ERROR_NONE;
- stc_restriction_rule_h rule = NULL;
+ stc_restriction_rule_h rule = nullptr;
restrictions_result result = RESTRICTIONS_OK;
ret = stc_restriction_rule_create(stc_handle, &rule);
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;
+ char *app_id = nullptr;
+ char *subscriber_id = nullptr;
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;
+ stc_restriction_rule_h mobile_rule = nullptr;
restrictions_result restrictions_res = RESTRICTIONS_ERROR;
if (!user_data) {
- SETTING_TRACE_ERROR("_get_restrictions_to_unset_cb error: user_data == NULL");
+ SETTING_TRACE_ERROR("_get_restrictions_to_unset_cb error: user_data == nullptr");
g_main_loop_quit(multi_main_loop);
return STC_CALLBACK_CONTINUE;
}
{
int64_t incoming = 0;
int64_t outgoing = 0;
- char *subscriber_id = NULL;
- const char *subscriber_id_to_look_for = user_data;
+ char *subscriber_id = nullptr;
+ const char *subscriber_id_to_look_for = (const char *)user_data;
int ret = STC_ERROR_NONE;
stc_iface_type_e iface_type = STC_IFACE_UNKNOWN;
return STC_CALLBACK_CONTINUE;
}
-static int menufunc_du_mo(int argc, char *argv[])
+static MENURUN_ERROR menufunc_du_mo(int argc, char *argv[], GenSettingMenu *menu)
{
telephony_handle_list_s tel_h_list;
telephony_sim_state_e sim_state = TELEPHONY_SIM_STATE_UNKNOWN;
for (int i = 0; i<2; i++) {
_initialize_cycle(&sim_limits[i]);
- sim_limits[i].cycle_mode = cycle;
+ sim_limits[i].cycle_mode = (Cycle_Mode_E) cycle;
if (cycle != CYCLE_MODE_CUSTOM) {
sim_limits[i].cycle_start = start_interval;
} else {
continue;
}
- multi_main_loop = g_main_loop_new(NULL, FALSE);
+ multi_main_loop = g_main_loop_new(nullptr, FALSE);
sim_limits[i].total_data_used = 0;
get_sim_total_stats(stc,
_total_stats_cb, subscriber_id[i],
stc_restriction_rule_h rule, void *user_data)
{
int ret = STC_ERROR_NONE;
- char *app_id = NULL;
- char *subscriber_id = NULL;
+ char *app_id = nullptr;
+ char *subscriber_id = nullptr;
static int SIM = 0;
stc_iface_type_e iface_type = STC_IFACE_UNKNOWN;
stc_restriction_type_e type = STC_RSTN_TYPE_UNKNOWN;
}
-static int menufunc_du_gmwl(int argc, char *argv[])
+static MENURUN_ERROR menufunc_du_gmwl(int argc, char *argv[], GenSettingMenu *menu)
{
stc_h stc;
int ret = 0;
return MEMUFUNC_ERR_NORMAL;
}
- multi_main_loop = g_main_loop_new(NULL, FALSE);
+ multi_main_loop = g_main_loop_new(nullptr, FALSE);
get_sim_restrictions(stc, _get_restrictions_cb);
g_main_loop_run(multi_main_loop);
return MEMUFUNC_ERR_NONE;
}
-static int menufunc_du_smwl(int argc, char *argv[])
+static MENURUN_ERROR menufunc_du_smwl(int argc, char *argv[], GenSettingMenu *menu)
{
telephony_handle_list_s tel_h_list;
telephony_sim_state_e sim_state = TELEPHONY_SIM_STATE_UNKNOWN;
continue;
}
if (!limit && !warning) {
- multi_main_loop = g_main_loop_new(NULL, FALSE);
+ multi_main_loop = g_main_loop_new(nullptr, FALSE);
unset_mobile_limit_restrictions(stc,
_get_and_unset_limit_restrictions_cb, &stc);
g_main_loop_run(multi_main_loop);
return MEMUFUNC_ERR_NONE;
}
-static int menufunc_du_wi(int argc, char *argv[])
+static MENURUN_ERROR menufunc_du_wi(int argc, char *argv[], GenSettingMenu *menu)
{
stc_h stc;
int ret = 0;
_initialize_cycle(&wifi_limits);
- wifi_limits.cycle_mode = cycle;
+ wifi_limits.cycle_mode = (Cycle_Mode_E)cycle;
if (cycle != CYCLE_MODE_CUSTOM) {
wifi_limits.cycle_start = start_interval;
} else {
return MEMUFUNC_ERR_NORMAL;
}
- multi_main_loop = g_main_loop_new(NULL, FALSE);
+ multi_main_loop = g_main_loop_new(nullptr, FALSE);
wifi_limits.total_data_used = 0;
get_wifi_total_stats(stc, _total_stats_cb,
wifi_limits.interval_from,
}
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},
+ {"smwl", "Set mobile data usage limit, warning level", menufunc_du_smwl, nullptr},
+ {"gmwl", "Get mobile data usage limit, warning level", menufunc_du_gmwl, nullptr},
+ {"mo", "Mobile data usage", menufunc_du_mo, nullptr},
+ {"wi", "Wifi data usage", menufunc_du_wi, nullptr},
};
-
-
-int menufunc_du(int argc, char *argv[])
+void precreate_du(GenSettingMenu *menu)
{
- 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;
+ eprintf("entered precreate_du\n");
+ menu->destroy();
+ menu->addSubmenus(du_menulist, sizeof(du_menulist) / sizeof(MenuItem));
}
-
-
#define __SC_DATEUSAGE_H_
#include "settingcmd_def.h"
-
-
-int menufunc_du(int argc, char *argv[]);
+#include "GenSettingMenu.h"
+\r
+void precreate_du(GenSettingMenu *menu);
#endif /* __SC_DATEUSAGE_H_ */
+++ /dev/null
-#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;
-}
-
--- /dev/null
+#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 MENURUN_ERROR menufunc_dt_au(int argc, char *argv[], GenSettingMenu *menu)
+{
+ int auto_update = 0;
+
+ int ret = vconf_get_bool(VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL, &auto_update);
+ if (ret != 0) {
+ eprintf("\tFail to get Auto update!\n");
+ return MEMUFUNC_ERR_NORMAL;
+ }
+
+ printf("\tAuto update : ");
+ printf("%s\n", auto_update? "On" : "Off");
+
+ return MEMUFUNC_ERR_NONE;
+}
+
+
+MenuItem dt_menulist[] ={
+ {"au", "Auto update", menufunc_dt_au, nullptr},
+ {"date", "Date", nullptr, nullptr},
+ {"time", "Time", nullptr, nullptr},
+ {"tz", "Time zone", nullptr, nullptr},
+ {"24h", "24 hour", nullptr, nullptr}
+};
+
+void precreate_dt(GenSettingMenu *menu)
+{
+ eprintf("entered precreate_dt\n");
+ menu->destroy();
+ menu->addSubmenus(dt_menulist, sizeof(dt_menulist) / sizeof(MenuItem));
+}
#define __SC_DATETIME_H_\r
\r
#include "settingcmd_def.h"\r
+#include "GenSettingMenu.h"
\r
-\r
-int menufunc_dt(int argc, char *argv[]);\r
+void precreate_dt(GenSettingMenu *menu);\r
\r
#endif /* __SC_DATETIME_H_ */\r
+++ /dev/null
-#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;
-}
-
--- /dev/null
+#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 MENURUN_ERROR menufunc_di_ab(int argc, char *argv[], GenSettingMenu *menu)
+{
+ int auto_bright = 0;
+ // TODO : I can't find BRIGHTNESS_AUTOMATIC value at device_display apis
+ int ret = vconf_get_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, &auto_bright);
+ if( ret != 0 ) {
+ eprintf("\tAuto Bright get fail!\n");
+ return MEMUFUNC_ERR_NORMAL;
+ }
+
+ printf("\tAuto Bright : %s\n", auto_bright? "On" : "Off");
+ return MEMUFUNC_ERR_NONE;
+}
+
+static MENURUN_ERROR menufunc_di_br(int argc, char *argv[], GenSettingMenu *menu)
+{
+ int brightness = 0;
+
+ // TODO : Checking use with device_display_get api
+ // device_display_get( int display_index, int* brightness );
+ int ret = vconf_get_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, &brightness);
+ if(ret != 0) {
+ eprintf("\tbrightness get fail!\n");
+ return MEMUFUNC_ERR_NORMAL;
+ }
+
+ printf("\tBrightness : %d\n", brightness);
+ return MEMUFUNC_ERR_NONE;
+}
+
+static MENURUN_ERROR menufunc_di_fs(int argc, char *argv[], GenSettingMenu *menu)
+{
+ int fontsize = 0;
+
+ int ret = system_settings_get_value_int(SYSTEM_SETTINGS_KEY_FONT_SIZE, &fontsize);
+ if( ret != 0) {
+ eprintf("\tFont get fail!\n");
+ return MEMUFUNC_ERR_NORMAL;
+ }
+
+ printf("\tFont Size: %d\n", fontsize );
+ return MEMUFUNC_ERR_NONE;
+}
+
+static MENURUN_ERROR menufunc_di_to(int argc, char *argv[], GenSettingMenu *menu)
+{
+
+ 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}
+};
+
+void precreate_di(GenSettingMenu *menu)
+{
+ eprintf("entered precreate_di\n");
+ menu->destroy();
+ menu->addSubmenus(di_menulist, sizeof(di_menulist) / sizeof(MenuItem));
+}
#define __SC_DISPLAY_H_\r
\r
#include "settingcmd_def.h"\r
+#include "GenSettingMenu.h"\r
\r
-\r
-int menufunc_di(int argc, char *argv[]);\r
+void precreate_di(GenSettingMenu *menu);\r
\r
#endif /* __SC_DISPLAY_H_ */\r
+++ /dev/null
-#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;
-}
-
-
--- /dev/null
+#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>
+
+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, nullptr,
+ &info->ringtone_sound_stream_info)
+ != SOUND_MANAGER_ERROR_NONE) ||
+ (sound_manager_create_stream_information(
+ SOUND_STREAM_TYPE_MEDIA,
+ __sound_stream_focus_state_changed_cb, nullptr,
+ &info->media_sound_stream_info)
+ != SOUND_MANAGER_ERROR_NONE) ||
+ (sound_manager_create_stream_information(
+ SOUND_STREAM_TYPE_NOTIFICATION,
+ __sound_stream_focus_state_changed_cb, nullptr,
+ &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);
+}
+
+///////////////////////////////////////////////////////////////////////
+
+static MENURUN_ERROR menufunc_so_rvol(int argc, char *argv[], GenSettingMenu *menu)
+{
+ sound_stream_info_t sound_stream_info;
+ if (!_sound_manager_init(&sound_stream_info)) {
+ eprintf("_sound_manager_init() failed!");
+ return MEMUFUNC_ERR_NORMAL;
+ }
+ int vol = 0;
+ if (sound_manager_get_volume(SOUND_TYPE_RINGTONE, &vol) != SOUND_MANAGER_ERROR_NONE) {
+ _sound_manager_deinit(&sound_stream_info);
+ return MEMUFUNC_ERR_NORMAL;
+ }
+ _sound_manager_deinit(&sound_stream_info);
+
+ printf("\tRingtone Volume : ");
+ printf("%d\n", vol);
+ return MEMUFUNC_ERR_NONE;
+}
+
+static MENURUN_ERROR menufunc_so_nvol(int argc, char *argv[], GenSettingMenu *menu)
+{
+ sound_stream_info_t sound_stream_info;
+ if (!_sound_manager_init(&sound_stream_info)) {
+ eprintf("_sound_manager_init() failed!");
+ return MEMUFUNC_ERR_NORMAL;
+ }
+ int vol = 0;
+ if (sound_manager_get_volume(SOUND_TYPE_NOTIFICATION, &vol) != SOUND_MANAGER_ERROR_NONE) {
+ _sound_manager_deinit(&sound_stream_info);
+ return MEMUFUNC_ERR_NORMAL;
+ }
+ _sound_manager_deinit(&sound_stream_info);
+
+ printf("\tNotification Volume : ");
+ printf("%d\n", vol);
+ return MEMUFUNC_ERR_NONE;
+}
+
+static MENURUN_ERROR menufunc_so_mvol(int argc, char *argv[], GenSettingMenu *menu)
+{
+ sound_stream_info_t sound_stream_info;
+ if (!_sound_manager_init(&sound_stream_info)) {
+ eprintf("_sound_manager_init() failed!");
+ return MEMUFUNC_ERR_NORMAL;
+ }
+ int vol = 0;
+ if (sound_manager_get_volume(SOUND_TYPE_MEDIA, &vol) != SOUND_MANAGER_ERROR_NONE) {
+ _sound_manager_deinit(&sound_stream_info);
+ return MEMUFUNC_ERR_NORMAL;
+ }
+ _sound_manager_deinit(&sound_stream_info);
+
+ printf("\tMedia Volume : ");
+ printf("%d\n", vol);
+ return MEMUFUNC_ERR_NONE;
+}
+
+static MENURUN_ERROR menufunc_so_svol(int argc, char *argv[], GenSettingMenu *menu)
+{
+ sound_stream_info_t sound_stream_info;
+ if (!_sound_manager_init(&sound_stream_info)) {
+ eprintf("_sound_manager_init() failed!");
+ return MEMUFUNC_ERR_NORMAL;
+ }
+
+ int vol = 0;
+ if (sound_manager_get_volume(SOUND_TYPE_SYSTEM, &vol) != SOUND_MANAGER_ERROR_NONE) {
+ _sound_manager_deinit(&sound_stream_info);
+ return MEMUFUNC_ERR_NORMAL;
+ }
+ _sound_manager_deinit(&sound_stream_info);
+
+ printf("\tSystem Volume : ");
+ printf("%d\n", vol);
+ return MEMUFUNC_ERR_NONE;
+}
+
+
+
+
+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}
+};
+
+void precreate_so(GenSettingMenu *menu)
+{
+ eprintf("entered precreate_so\n");
+ menu->destroy();
+ menu->addSubmenus(so_menulist, sizeof(so_menulist) / sizeof(MenuItem));
+}
#define __SC_SOUND_H_\r
\r
#include "settingcmd_def.h"\r
+#include "GenSettingMenu.h"\r
\r
-\r
-int menufunc_so(int argc, char *argv[]);\r
+void precreate_so(GenSettingMenu *menu);\r
\r
#endif /* __SC_SOUND_H_ */\r
if (arg) { \
/*cast any argument to (void*) to avoid build warring*/\
del((void *)(arg)); \
- arg = NULL; \
+ arg = nullptr; \
} \
} while (0)
#define FREE(arg) __FREE(free, arg)
-#define SAFE_STRDUP(src) (src) ? strdup(src) : NULL
+#define SAFE_STRDUP(src) (src) ? strdup(src) : nullptr
#ifndef ret_if
#define ret_if(expr) do { \
struct _calculated_sizes *sizes)
{
int ret;
- filter_h filter = NULL;
+ filter_h filter = nullptr;
/*Set Filter*/
ret = media_filter_create(&filter);
{
media_content_type_e type;
unsigned long long size = 0;
- struct _calculated_sizes *sizes = data;
+ struct _calculated_sizes *sizes = (struct _calculated_sizes *)data;
media_info_get_size(media, &size);
media_info_get_media_type(media, &type);
static bool storage_get_misces_item(media_info_h media, void *data)
{
unsigned long long size = 0;
- struct _calculated_sizes *sizes = data;
+ struct _calculated_sizes *sizes = (struct _calculated_sizes *)data;
- char *file_path = NULL;
+ char *file_path = nullptr;
media_info_get_file_path(media, &file_path);
#if 0
if (!ecore_file_exists(file_path)) {
return true;
}
-static GMainLoop* multi_main_loop = NULL;
+static GMainLoop* multi_main_loop = nullptr;
static void storage_get_app_cache_size_cb(const package_size_info_h size_info,
void *user_data)
{
long long ext_cache_size = 0;
long long ext_app_size = 0;
- struct _calculated_sizes *ad = user_data;
+ struct _calculated_sizes *ad = (struct _calculated_sizes *)user_data;
package_size_info_get_app_size(size_info, &app_size);
package_size_info_get_external_app_size(size_info, &ext_app_size);
ad->app_total = (double)(app_size + ext_app_size);
ad->caches_total = (double)(cache_size + ext_cache_size);
- pc_total_size = NULL;
+ pc_total_size = nullptr;
g_main_loop_quit(multi_main_loop);
}
{
int ret;
- multi_main_loop = g_main_loop_new(NULL, FALSE);
+ multi_main_loop = g_main_loop_new(nullptr, FALSE);
pc_total_size = pkgmgr_client_new(PC_REQUEST);
- if (NULL == pc_total_size) {
+ if (nullptr == pc_total_size) {
eprintf("pkgmgr_client_new() Fail");
return;
}
{
int ret;
- ret_if(NULL == type);
- ret_if(NULL == path);
- ret_if(NULL == data);
+ ret_if(nullptr == type);
+ ret_if(nullptr == path);
+ ret_if(nullptr == data);
eprintf("path:%s type:%s", path, type);
if (ret < 0)
eprintf("init_usbhost_signal() Fail(%d)\n", ret);
- ret = register_usb_storage_change_handler(storage_USB_cb, NULL);
+ ret = register_usb_storage_change_handler(storage_USB_cb, nullptr);
if (ret < 0) {
eprintf(
"register_usb_storage_change_handler() Fail(%d)\n",
return 0;
}
-static int menufunc_st_me(int argc, char *argv[]){
- int ret = MEMUFUNC_ERR_NONE;
+static MENURUN_ERROR menufunc_st_me(int argc, char *argv[], GenSettingMenu *menu){
+
char buf[SETTING_CMD_MAX_STR_LEN];
int media_ret = media_content_connect();
printf("%s", buf);
media_content_disconnect();
- return ret;
+ return MEMUFUNC_ERR_NONE;
}
-static int menufunc_st_sd(int argc, char *argv[]){
- int ret = MEMUFUNC_ERR_NONE;
+static MENURUN_ERROR menufunc_st_sd(int argc, char *argv[], GenSettingMenu *menu){
int sd_status = 0;
double total = 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);
+ int 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;
printf("avail : %s\n", avail_str);
- return ret;
+ return MEMUFUNC_ERR_NONE;
}
-static int menufunc_st_ms(int argc, char *argv[]){
+static MENURUN_ERROR menufunc_st_ms(int argc, char *argv[], GenSettingMenu *menu)
+{
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);
+ int 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;
return MEMUFUNC_ERR_NONE;
}
-static int menufunc_st_mss(int argc, char *argv[]){
- int ret = MEMUFUNC_ERR_NONE;
+static MENURUN_ERROR menufunc_st_mss(int argc, char *argv[], GenSettingMenu *menu)
+{
int sd_status = 0;
- ret = vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &sd_status);
+ int 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;
return MEMUFUNC_ERR_NONE;
}
-static int menufunc_st_us(int argc, char *argv[]){
+static MENURUN_ERROR menufunc_st_us(int argc, char *argv[], GenSettingMenu *menu){
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);
+ int 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;
}
-static int menufunc_st_fs(int argc, char *argv[]){
- int ret = MEMUFUNC_ERR_NONE;
+static MENURUN_ERROR menufunc_st_fs(int argc, char *argv[], GenSettingMenu *menu){
struct mmc_contents mmc_content = {0};
- ret = storage_request_format_mmc(&mmc_content);
+ int ret = storage_request_format_mmc(&mmc_content);
if (ret == -1) {
eprintf("failed to call storage_request_format_mmc\n");
+ return MEMUFUNC_ERR_NORMAL;
}
printf("sd card format complete\n");
- return ret;
+ return MEMUFUNC_ERR_NONE;
}
-static int menufunc_st_ids(int argc, char *argv[]){
- int ret = MEMUFUNC_ERR_NONE;
-
+static MENURUN_ERROR menufunc_st_ids(int argc, char *argv[], GenSettingMenu *menu)
+{
int val = 0;
- ret = vconf_set_int(VCONFKEY_SETAPPL_DEFAULT_MEM_WIFI_DIRECT_INT, val);
+ int 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;
return MEMUFUNC_ERR_NORMAL;
}
printf("Set internal memory for default storage shared content\n");
- return ret;
+ return MEMUFUNC_ERR_NONE;
}
-static int menufunc_st_sds(int argc, char *argv[]){
- int ret = MEMUFUNC_ERR_NONE;
-
+static MENURUN_ERROR menufunc_st_sds(int argc, char *argv[], GenSettingMenu *menu)
+{
int val = 1;
- ret = vconf_set_int(VCONFKEY_SETAPPL_DEFAULT_MEM_WIFI_DIRECT_INT, val);
+ int 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;
return MEMUFUNC_ERR_NORMAL;
}
printf("Set SD card for default storage shared content\n");
- return ret;
+ return MEMUFUNC_ERR_NONE;
}
-static int menufunc_st_ida(int argc, char *argv[]){
- int ret = MEMUFUNC_ERR_NONE;
-
+static MENURUN_ERROR menufunc_st_ida(int argc, char *argv[], GenSettingMenu *menu)
+{
int val = 0;
- ret = vconf_set_int(VCONFKEY_SETAPPL_DEFAULT_MEM_INSTALL_APPLICATIONS_INT, val);
+ int 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;
+ return MEMUFUNC_ERR_NONE;
}
-static int menufunc_st_sda(int argc, char *argv[]){
- int ret = MEMUFUNC_ERR_NONE;
-
+static MENURUN_ERROR menufunc_st_sda(int argc, char *argv[], GenSettingMenu *menu)
+{
int val = 1;
- ret = vconf_set_int(VCONFKEY_SETAPPL_DEFAULT_MEM_INSTALL_APPLICATIONS_INT, val);
+ int 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;
+ return MEMUFUNC_ERR_NONE;
}
-static int menufunc_st_da(int argc, char *argv[]){
- int ret = MEMUFUNC_ERR_NONE;
-
+static MENURUN_ERROR menufunc_st_da(int argc, char *argv[], GenSettingMenu *menu)
+{
int val = 0;
- ret = vconf_get_int(VCONFKEY_SETAPPL_DEFAULT_MEM_INSTALL_APPLICATIONS_INT, &val);
+ int 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;
+ return MEMUFUNC_ERR_NONE;
}
-static int menufunc_st_ds(int argc, char *argv[]){
- int ret = MEMUFUNC_ERR_NONE;
-
+static MENURUN_ERROR menufunc_st_ds(int argc, char *argv[], GenSettingMenu *menu)
+{
int val = 0;
- ret = vconf_get_int(VCONFKEY_SETAPPL_DEFAULT_MEM_WIFI_DIRECT_INT, &val);
+ int 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 bluetooth : %s\n", (val)?"Internal memory":"SD Card");
- return ret;
+ return MEMUFUNC_ERR_NONE;
}
MenuItem st_menulist[] ={
{"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}
+ {"fsp", "Format SD card as device storage", nullptr}
};
-int menufunc_st(int argc, char *argv[])
+void precreate_st(GenSettingMenu *menu)
{
- 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;
+ eprintf("entered precreate_st\n");
+ menu->destroy();
+ menu->addSubmenus(st_menulist, sizeof(st_menulist) / sizeof(MenuItem));
}
-
-
#define __SC_STORAGE_H_
#include "settingcmd_def.h"
-
-
-int menufunc_st(int argc, char *argv[]);
+#include "GenSettingMenu.h"\r
+\r
+void precreate_st(GenSettingMenu *menu);
#endif /* __SC_STORAGE_H_ */
+++ /dev/null
-#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;
-}
-
-
--- /dev/null
+#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 MENURUN_ERROR menufunc_wf_st(int argc, char *argv[], GenSettingMenu *menu)
+{
+ int state = 0;
+ int ret = vconf_get_int(VCONFKEY_WIFI_STATE, &state);
+ if (ret != MEMUFUNC_ERR_NONE) {
+ eprintf("\twifi state get fail!\n");
+ return MEMUFUNC_ERR_NORMAL;
+ }
+
+ printf("\tState : %s\n", state ? "On" : "Off");
+ return MEMUFUNC_ERR_NONE;
+}
+
+static MENURUN_ERROR menufunc_wf_nf(int argc, char *argv[], GenSettingMenu *menu)
+{
+ bool state = false;
+ int ret = system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, &state);
+ if (ret != MEMUFUNC_ERR_NONE) {
+ eprintf("\twifi notification get fail!\n");
+ return MEMUFUNC_ERR_NORMAL;
+ }
+
+ printf("\tNodification : %s\n", state ? "On" : "Off");
+ return MEMUFUNC_ERR_NONE;
+}
+
+MenuItem wf_menulist[] = {
+ {"st", "State", menufunc_wf_st, nullptr},
+ {"nf", "Notification", menufunc_wf_nf, nullptr}
+};
+
+
+void precreate_wf(GenSettingMenu *menu)
+{
+ eprintf("entered precreate_wf\n");
+ menu->destroy();
+ menu->addSubmenus(wf_menulist, sizeof(wf_menulist)/ sizeof(MenuItem));
+}
+
#define __SC_WIFI_H_
#include "settingcmd_def.h"
+#include "GenSettingMenu.h"
-
-int menufunc_wf(int argc, char *argv[]);
+void precreate_wf(GenSettingMenu *menu);
#endif /* __SC_WIFI_H_ */
+++ /dev/null
-#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;
-}
-
--- /dev/null
+#include "settingcmd_def.h"
+#include "GenSettingMenu.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>
+
+
+using namespace std;
+
+#if 0
+void setMainMenu_mobile(SettingMenu &mainmenu)
+{
+ mainmenu.destroy();
+
+ mainmenu.subMenus.push_back(new MMWiFi);
+ mainmenu.subMenus.push_back(new MMBluetooth);
+ mainmenu.subMenus.push_back(new MMAirplaneMode);
+ mainmenu.subMenus.push_back(new MMMobileNetwork);
+ mainmenu.subMenus.push_back(new MMSound);
+ mainmenu.subMenus.push_back(new MMDisplay);
+ mainmenu.subMenus.push_back(new MMApps);
+ mainmenu.subMenus.push_back(new MMWallpaper);
+ mainmenu.subMenus.push_back(new MMLockScreen);
+ mainmenu.subMenus.push_back(new MMAccessibility);
+ mainmenu.subMenus.push_back(new MMPrivacySecurity);
+ mainmenu.subMenus.push_back(new MMAccounts);
+ mainmenu.subMenus.push_back(new MMBackupReset);
+ mainmenu.subMenus.push_back(new MMLanguageInput);
+ mainmenu.subMenus.push_back(new MMBattery);
+ mainmenu.subMenus.push_back(new MMData);
+ mainmenu.subMenus.push_back(new MMStorage);
+ mainmenu.subMenus.push_back(new MMDateTime);
+ mainmenu.subMenus.push_back(new MMDataUsage);
+ mainmenu.subMenus.push_back(new MMAboutDevice);
+}
+#else
+
+MenuItem mobile_mainmenulist[] = {
+ {"wf", "Wi-Fi", nullptr, precreate_wf},
+ {"bt", "BlueTooth", nullptr, precreate_bt},
+ {"am", "Airplane Mode", nullptr, precreate_am},
+ {"te", "Tethering", nullptr, nullptr},
+ {"mn", "Mobile networks", nullptr, nullptr},
+ {"so", "Sound", nullptr, precreate_so},
+ {"di", "Display", nullptr, precreate_di},
+ {"ap", "Apps", nullptr, precreate_apps},
+ {"wp", "Wallpaper", nullptr, nullptr},
+ {"ls", "LockScreen", nullptr, nullptr},
+ {"ac", "Accessibility", nullptr, nullptr},
+ {"ps", "Privacy and security", nullptr, nullptr},
+ {"ac", "Accounts", nullptr, nullptr},
+ {"br", "Backup and reset", nullptr, nullptr},
+ {"li", "Language and input", nullptr, nullptr},
+ {"ba", "Battery", menufunc_ba, nullptr},
+ {"da", "Data", nullptr, nullptr},
+ {"st", "Storage", nullptr, precreate_st},
+ {"dt", "Date and time", nullptr, precreate_dt},
+ {"du", "Data Usage", nullptr, precreate_du},
+ {"ad", "About device", nullptr, precreate_ad}
+};
+
+#endif
+
+
+#if 0
+void setMainMenu_wearable(SettingMenu &mainmenu)
+{
+ mainmenu.destroy();
+
+ mainmenu.subMenus.push_back(new MWWiFi);
+ mainmenu.subMenus.push_back(new MWBluetooth);
+ mainmenu.subMenus.push_back(new MWAirplaneMode);
+ mainmenu.subMenus.push_back(new MWMobileNetwork);
+ mainmenu.subMenus.push_back(new MWSound);
+ mainmenu.subMenus.push_back(new MWDisplay);
+ mainmenu.subMenus.push_back(new MWAccessibility);
+ mainmenu.subMenus.push_back(new MWAccounts);
+ mainmenu.subMenus.push_back(new MWLanguageInput);
+ mainmenu.subMenus.push_back(new MWDataUsage);
+ mainmenu.subMenus.push_back(new MWAboutDevice);
+
+ mainmenu.create();
+}
+#else
+
+MenuItem wearable_main_menulist[] = {
+ {"wf", "Wi-Fi", nullptr, precreate_wf},
+ {"bt", "BlueTooth", nullptr, precreate_bt},
+ {"am", "Airplane Mode", nullptr, precreate_am},
+ {"mn", "Mobile networks", nullptr, nullptr},
+ {"so", "Sound", nullptr, precreate_so},
+ {"di", "Display", nullptr, precreate_di},
+ {"ac", "Accessibility", nullptr, nullptr},
+ {"ac", "Accounts", nullptr, nullptr},
+ {"li", "Language and input", nullptr, nullptr},
+ {"du", "Data Usage", nullptr, precreate_du},
+ {"ad", "About device", nullptr, precreate_ad},
+};
+#endif
+
+void MainMemu_Precreate(GenSettingMenu *menu)
+{
+ int profile = getProfile();
+ if (profile < 0) {
+ SettingMenu::printError(MEMUFUNC_ERR_NORMAL);
+ return;
+ }
+
+ if (profile == MOBILE_PROFILE) {
+ menu->destroy();
+ menu->addSubmenus(mobile_mainmenulist, sizeof(mobile_mainmenulist) / sizeof(MenuItem));
+ }
+ else if (profile == WEARABLE_PROFILE) {
+ menu->destroy();
+ menu->addSubmenus(wearable_main_menulist, sizeof(wearable_main_menulist) / sizeof(MenuItem));
+
+ }
+ else {
+ SettingMenu::printError(MEMUFUNC_ERR_NORMAL);
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ GenSettingMenu mainMenu("setting-cmd", "Main Menu", nullptr, MainMemu_Precreate);
+
+ if (mainMenu.create()) {
+ string title = "\nSeting Command\n";
+ MENURUN_ERROR result = mainMenu.run(title, argc, argv);
+ if (result != MEMUFUNC_ERR_NONE)
+ SettingMenu::printError(result);
+ mainMenu.destroy();
+ }
+ else {
+ eprintf("Main Menu failed to create\n");
+ }
+ return 0;
+}
#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,