block to edit and delete user by user authority 49/45049/1
authorSoohye Shin <soohye.shin@samsung.com>
Fri, 31 Jul 2015 01:55:46 +0000 (10:55 +0900)
committerSoohye Shin <soohye.shin@samsung.com>
Fri, 31 Jul 2015 01:55:46 +0000 (10:55 +0900)
- owner is possible to edit and delete all users except for itself
- normal is possible to edit only itself

Change-Id: I332819dc821fdb80f5aa072cb12a1553d5901563
Signed-off-by: Soohye Shin <soohye.shin@samsung.com>
edje/view/user.edc
edje/view/useredit.edc
include/defs.h
include/view.h
src/view/view_user.c
src/view/view_user_edit.c

index 9fc884f..574b5eb 100644 (file)
@@ -349,7 +349,7 @@ group {
        programs {
                program {
                        name, "sig,show,arrow";
-                       signal, SIG_FOCUS;
+                       signal, SIG_SHOW_ARROW;
                        source, SRC_PROG;
                        action, STATE_SET "focus";
                        target, "text";
@@ -357,7 +357,7 @@ group {
                }
                program {
                        name, "sig,hide,arrow";
-                       signal, SIG_UNFOCUS;
+                       signal, SIG_HIDE_ARROW;
                        source, SRC_PROG;
                        action, STATE_SET "default";
                        target, "text";
index 4aa17b7..6e6889e 100644 (file)
@@ -953,11 +953,6 @@ group {
                                inherit, "default" 0.0;
                                color, 0 119 246 255;
                        }
-                       description {
-                               state, "disable" 0.0;
-                               inherit, "default" 0.0;
-                               color, 87 87 87 125;
-                       }
                }
                part {
                        name, "text.delete";
@@ -991,13 +986,6 @@ group {
                        transition, TRANSITION_LINEAR;
                        target, "bg";
                }
-               program {
-                       name, "sig,disable";
-                       signal, SIG_DISABLE;
-                       source, SRC_PROG;
-                       action, STATE_SET "disable" 0.0;
-                       target, "bg";
-               }
        }
 }
 
index ad6dec3..4a57ebb 100644 (file)
 #define SIG_HIDE_DONE "sig.hide.done"
 #define SIG_CLICK_ITEM "sig.click.item"
 #define SIG_CLICK_ARROW "sig.click.arrow"
+#define SIG_SHOW_ARROW "sig.show.arrow"
+#define SIG_HIDE_ARROW "sig.hide.arrow"
 
 #define TITLE_WIDTH "title.width"
 
index a981f18..b4559a5 100644 (file)
@@ -20,7 +20,8 @@
 enum update_type {
        UPDATE_TYPE_EDIT,
        UPDATE_TYPE_PHOTO,
-       UPDATE_TYPE_NOTI
+       UPDATE_TYPE_NOTI,
+       UPDATE_TYPE_USER
 };
 
 view_class *view_home_get_vclass(void);
index 2557852..37f54d2 100644 (file)
@@ -1,5 +1,4 @@
 /*
-
  * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0 (the License);
@@ -34,6 +33,13 @@ enum input_handler_type {
        INPUT_HANDLER_TYPE_BUTTON
 };
 
+enum user_item_type {
+       USER_ITEM_NONE = 0x00,
+       USER_ITEM_ADD = 0x01,
+       USER_ITEM_ADMIN = 0x02,
+       USER_ITEM_NORMAL = 0x08
+};
+
 struct _priv {
        Evas_Object *win;
        Evas_Object *base;
@@ -43,6 +49,8 @@ struct _priv {
 
        struct datamgr *dm;
        struct _bar_item *foc;
+
+       enum user_item_type user_type;
 };
 
 struct _bar_item {
@@ -52,6 +60,27 @@ struct _bar_item {
        struct _priv *priv;
 };
 
+static bool _check_editable_user(struct _priv *priv)
+{
+       struct _bar_item *bi;
+       bool r = false;
+
+       switch (priv->user_type) {
+       case USER_ITEM_NORMAL:
+               bi = eina_list_data_get(priv->list);
+               if (priv->foc == bi)
+                       r = true;
+               break;
+       case USER_ITEM_ADMIN:
+               r = true;
+               break;
+       default:
+               break;
+       }
+
+       return r;
+}
+
 static void _focused(int id, void *data, Evas_Object *obj,
                Elm_Object_Item *item)
 {
@@ -66,6 +95,9 @@ static void _focused(int id, void *data, Evas_Object *obj,
        priv->foc = bi;
 
        elm_object_signal_emit(obj, SIG_FOCUS, SRC_PROG);
+
+       if (_check_editable_user(priv))
+               elm_object_signal_emit(obj, SIG_SHOW_ARROW, SRC_PROG);
 }
 
 static void _unfocused(int id, void *data, Evas_Object *obj,
@@ -75,6 +107,7 @@ static void _unfocused(int id, void *data, Evas_Object *obj,
                return;
 
        elm_object_signal_emit(obj, SIG_UNFOCUS, SRC_PROG);
+       elm_object_signal_emit(obj, SIG_HIDE_ARROW, SRC_PROG);
 }
 
 static void _key_down(int id, void *data, Evas *e, Evas_Object *obj,
@@ -154,9 +187,12 @@ static void _key_down(int id, void *data, Evas *e, Evas_Object *obj,
                                !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
                        elm_object_signal_emit(priv->base, SIG_HIDE, SRC_PROG);
                } else if (!strcmp(ev->keyname, KEY_DOWN)) {
-                       if (priv->foc->di->action == ITEM_SELECT_ACTION_PUSH)
+                       if (priv->foc->di->action == ITEM_SELECT_ACTION_PUSH ||
+                                       !_check_editable_user(priv))
                                return;
 
+                       viewmgr_update_view(VIEW_USER_EDIT, UPDATE_TYPE_USER,
+                                       (void *)priv->user_type);
                        viewmgr_update_view(VIEW_USER_EDIT, UPDATE_TYPE_EDIT,
                                        priv->foc->di);
                        viewmgr_push_view(VIEW_USER_EDIT);
@@ -247,6 +283,7 @@ static void _arrow_clicked(void *data, Evas_Object *obj, const char *emission,
        if (priv->foc->di->action == ITEM_SELECT_ACTION_PUSH)
                return;
 
+       viewmgr_update_view(VIEW_USER_EDIT, UPDATE_TYPE_USER, (void *)priv->user_type);
        viewmgr_update_view(VIEW_USER_EDIT, UPDATE_TYPE_EDIT, priv->foc->di);
        viewmgr_push_view(VIEW_USER_EDIT);
 }
@@ -353,6 +390,7 @@ static void _add_user(struct _priv *priv)
        Evas_Object *scr, *box;
        struct _bar_item *bi;
        struct datamgr_item *di;
+       int i;
 
        scr = utils_add_scroller(priv->base);
        if (!scr) {
@@ -378,11 +416,16 @@ static void _add_user(struct _priv *priv)
                return;
        }
 
+       i = 0;
        EINA_LIST_FOREACH(list, l, di) {
                bi = _pack_bar_item(priv, box, di);
                if (!bi)
                        continue;
 
+               if (i == 0) {
+                       priv->user_type = di->type;
+                       i++;
+               }
                priv->list = eina_list_append(priv->list, bi);
        }
 
index cbdf2fa..4140ef3 100644 (file)
@@ -85,6 +85,8 @@ struct _priv {
 
        struct datamgr *dm;
        struct datamgr_item *di;
+
+       enum user_item_type user_type;
 };
 
 static void _focused(int id, void *data, Evas_Object *obj,
@@ -663,18 +665,6 @@ static void _load_del_btn(struct _priv *priv)
 {
        Evas_Object *btn;
 
-       if (priv->di->type == USER_ITEM_ADMIN) {
-               btn = utils_add_layout(priv->ly, GRP_USER_EDIT_DELETE, false,
-                               PART_USER_EDIT_CONTENTS_DELETE);
-               if (!btn) {
-                       _ERR("failed to add delete button");
-                       return;
-               }
-               elm_object_signal_emit(btn, SIG_DISABLE, SRC_PROG);
-               return;
-       }
-
-
        btn = utils_add_layout(priv->ly, GRP_USER_EDIT_DELETE, true,
                        PART_USER_EDIT_CONTENTS_DELETE);
        if (!btn) {
@@ -711,7 +701,9 @@ static void _show(void *data)
                        focus_photo = utils_get_focus_photo_from_photo(photo);
                        _load_user_icon(priv, photo, focus_photo);
                }
-               _load_del_btn(priv);
+               if (priv->user_type == USER_ITEM_ADMIN &&
+                               priv->di->type !=USER_ITEM_ADMIN)
+                       _load_del_btn(priv);
        } else {
                elm_object_part_text_set(priv->base, PART_USER_EDIT_TITLE,
                                MESSAGE_ADD_USER);
@@ -793,6 +785,9 @@ static void _update(void *view_data, int update_type, void *data)
        case UPDATE_TYPE_PHOTO:
                priv->selected_photo = data;
                break;
+       case UPDATE_TYPE_USER:
+               priv->user_type = (enum user_item_type) data;
+               break;
        default:
                _ERR("Invalid type");
                return;