static void _gui_show(Evas_Object *o)
{
+ Last_User_Mode *last;
+
+ last = util_get_last_user_mode();
if (o == keypad)
elm_object_signal_emit(main_layout, "show,keypad", "gui");
else if (o == contacts)
elm_object_signal_emit(main_layout, "show,history", "gui");
elm_object_focus_set(o, EINA_TRUE);
current_view = o;
+
+ if (last) {
+ if (current_view == keypad)
+ last->last_view = DIALER_LAST_VIEW_KEYPAD;
+ else if (current_view == contacts)
+ last->last_view = DIALER_LAST_VIEW_CONTACTS;
+ else if (current_view == history)
+ last->last_view = DIALER_LAST_VIEW_HISTORY;
+
+ util_set_last_user_mode(last);
+ }
}
Evas_Object *gui_simple_popup(const char *title, const char *message)
gui_dial(number);
}
+static void _load_last_user_view() {
+ Last_User_Mode *last;
+
+ last = util_get_last_user_mode();
+ if (!last) {
+ DBG("Last user config file not found - create default view");
+ last = calloc(1, sizeof(Last_User_Mode));
+ last->last_view = DIALER_LAST_VIEW_KEYPAD;
+ last->last_history_view = DIALER_LAST_HISTORY_VIEW_ALL;
+ last->last_number = eina_stringshare_add("");
+ util_set_last_user_mode(last);
+ }
+
+ if(last->last_number) {
+ keypad_number_set(keypad, last->last_number, EINA_FALSE);
+ }
+ if (last->last_view == DIALER_LAST_VIEW_KEYPAD) {
+ _gui_show(keypad);
+ } else if (last->last_view == DIALER_LAST_VIEW_CONTACTS) {
+ _gui_show(contacts);
+ } else if (last->last_view == DIALER_LAST_VIEW_HISTORY) {
+ _gui_show(history);
+ if (last->last_history_view != DIALER_LAST_HISTORY_VIEW_ALL) {
+ elm_object_signal_emit(history, "show,missed", "gui");
+ }
+ }
+ eina_stringshare_del(last->last_number);
+ free(last);
+}
+
Eina_Bool gui_init(void)
{
Evas_Object *lay, *obj;
EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
elm_object_part_content_set(lay, "elm.swallow.history", obj);
- _gui_show(keypad);
-
cs = obj = callscreen_add(win);
EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
evas_object_size_hint_weight_set(obj,
elm_object_part_content_set(flip, "back", obj);
evas_object_show(obj);
+ _load_last_user_view();
+
callback_node_modem_changed =
ofono_modem_changed_cb_add(_ofono_changed, NULL);
callback_node_ussd_notify =
const char *emission, const char *source __UNUSED__)
{
History *ctx = data;
+ Last_User_Mode *last;
EINA_SAFETY_ON_NULL_RETURN(emission);
emission += strlen("clicked,");
DBG("ctx=%p, signal: %s", ctx, emission);
+ last = util_get_last_user_mode();
- if (!strcmp(emission, "all"))
+ if (!strcmp(emission, "all")) {
elm_object_signal_emit(obj, "show,all", "gui");
- else if (!strcmp(emission, "missed"))
+ if (last) {
+ last->last_history_view = DIALER_LAST_HISTORY_VIEW_ALL;
+ util_set_last_user_mode(last);
+ }
+ }
+ else if (!strcmp(emission, "missed")) {
elm_object_signal_emit(obj, "show,missed", "gui");
+ if (last) {
+ last->last_history_view = DIALER_LAST_HISTORY_VIEW_MISSED;
+ util_set_last_user_mode(last);
+ }
+ }
else if (!strcmp(emission, "clear"))
_history_clear(ctx);
else if (!strcmp(emission, "edit")) {
const char *number = eina_strbuf_string_get(ctx->number);
char *s = phone_format(number);
const char *type;
+ Last_User_Mode *last;
+
+ last = util_get_last_user_mode();
+ if (last) {
+ eina_stringshare_replace(&(last->last_number), number);
+ util_set_last_user_mode(last);
+ }
+
if (!s) {
elm_object_part_text_set(ctx->self, "elm.text.display", "");
elm_object_part_text_set(ctx->self, "elm.text.contact-and-type",
+* Wed Nov 13 2013 Jimmy Huang <jimmy.huang@intel.com> accepted/tizen/20130920.213555@96e7dfe
+- Implement last user mode
+
* Thu Sep 19 2013 Jimmy Huang <jimmy.huang@intel.com>
- Implement system notification for incoming call
- Fixed compilation warnings
#include "log.h"
static char def_theme[PATH_MAX] = "";
+static char *_last_user_mode_config_path;
+static Eet_Data_Descriptor *_last_user_mode_descriptor;
/* TODO: find a configurable way to format the number.
* Right now it's: 1-234-567-8901 as per
return EINA_TRUE;
}
+Eina_Bool util_set_last_user_mode(Last_User_Mode *mode) {
+ Eina_Bool ret;
+ Eet_File *efile;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(_last_user_mode_config_path, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(_last_user_mode_descriptor, EINA_FALSE);
+
+ efile = eet_open(_last_user_mode_config_path, EET_FILE_MODE_WRITE);
+ if (!efile) {
+ ERR("Cannot open %s for write", _last_user_mode_config_path);
+ return EINA_FALSE;
+ }
+
+ ret = eet_data_write(efile, _last_user_mode_descriptor, LAST_USER_MODE_ENTRY, mode, EINA_TRUE);
+ if (!ret) {
+ ERR("Cannot write to %s", _last_user_mode_config_path);
+ }
+ eet_close(efile);
+ return ret;
+}
+
+Last_User_Mode *util_get_last_user_mode() {
+ Eet_File *efile;
+ Last_User_Mode *mode;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(_last_user_mode_config_path, NULL);
+
+ efile = eet_open(_last_user_mode_config_path, EET_FILE_MODE_READ);
+ if (!efile) {
+ ERR("Cannot open %s for read", _last_user_mode_config_path);
+ return NULL;
+ }
+
+ mode = eet_data_read(efile, _last_user_mode_descriptor, LAST_USER_MODE_ENTRY);
+ eet_close(efile);
+
+ return mode;
+}
+
+static void _last_user_mode_descriptor_init(void) {
+ Eet_Data_Descriptor_Class eddc;
+
+ EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Last_User_Mode);
+ _last_user_mode_descriptor = eet_data_descriptor_stream_new(&eddc);
+
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_last_user_mode_descriptor, Last_User_Mode,
+ "last_view", last_view, EET_T_UINT);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_last_user_mode_descriptor, Last_User_Mode,
+ "last_history_view", last_history_view, EET_T_UINT);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_last_user_mode_descriptor, Last_User_Mode,
+ "last_number", last_number, EET_T_STRING);
+}
+
+
Eina_Bool util_init(const char *theme)
{
+ int ret;
+ const char *config_path;
+ char base_dir[PATH_MAX];
+ Eet_File *efile;
+
+ eet_init();
+ config_path = efreet_config_home_get();
+ snprintf(base_dir, sizeof(base_dir), "%s/%s", config_path, PACKAGE_NAME);
+ ecore_file_mkpath(base_dir);
+ ret = asprintf(&_last_user_mode_config_path, "%s/%s/last_user_mode.eet", config_path, PACKAGE_NAME);
+ if (ret < 0)
+ return EINA_FALSE;
+
+ _last_user_mode_descriptor_init();
elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR);
elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
elm_app_info_set(util_init, "ofono-efl", "themes/default.edj");
void util_shutdown(void)
{
+ if (_last_user_mode_config_path)
+ free(_last_user_mode_config_path);
+ if (_last_user_mode_descriptor)
+ eet_data_descriptor_free(_last_user_mode_descriptor);
+ eet_shutdown();
}
#define MONTH ((DAY) * 30)
#define YEAR ((MONTH) *12)
+enum {
+ DIALER_LAST_VIEW_KEYPAD = 0,
+ DIALER_LAST_VIEW_CONTACTS,
+ DIALER_LAST_VIEW_HISTORY
+};
+
+enum {
+ DIALER_LAST_HISTORY_VIEW_ALL = 0,
+ DIALER_LAST_HISTORY_VIEW_MISSED
+};
+
+#define LAST_USER_MODE_ENTRY "last_user_mode"
+
+typedef struct
+{
+ int last_view;
+ int last_history_view;
+ const char *last_number;
+} Last_User_Mode;
+
char *phone_format(const char *number);
char *date_format(time_t date);
Eina_Bool util_set_night_mode(Eina_Bool night_mode);
+Eina_Bool util_set_last_user_mode(Last_User_Mode *mode);
+
+Last_User_Mode *util_get_last_user_mode();
+
Eina_Bool util_init(const char *theme);
void util_shutdown(void);