[Release] wrt-setting_0.0.50
[apps/home/wrt-setting.git] / webapp-common / whitelistview.h
1 /*
2   * Copyright 2012  Samsung Electronics Co., Ltd
3   *
4   * Licensed under the Flora License, Version 1.1 (the "License");
5   * you may not use this file except in compliance with the License.
6   * You may obtain a copy of the License at
7   *
8   *     http://floralicense.org/license/
9   *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16
17 #ifndef WEB_SRC_SETTING_WEBAPP_COMMON_WHITELISTVIEW_H_
18 #define WEB_SRC_SETTING_WEBAPP_COMMON_WHITELISTVIEW_H_
19
20 #include <Evas.h>
21
22 #include <dpl/scoped_ptr.h>
23
24 #include "whiteuriview.h"
25 #include "view.h"
26 #include "popup.h"
27
28 namespace WebAppCommonSetting {
29
30 class WhiteListView : public View
31 {
32     Evas_Object *m_naviFrame;
33     Evas_Object *m_bx;
34     Evas_Object *m_gl;
35     Evas_Object *m_selectAll;
36     unsigned int m_selectCnt;
37     unsigned int m_uriCnt;
38     Elm_Object_Item *m_editModeBtn;
39     Elm_Object_Item *m_optBtn;
40     Popup m_popup;
41     DPL::ScopedPtr<WhiteUriView> m_whiteUriView;
42
43     static char *getUriStr(void *data,
44                            Evas_Object *obj,
45                            const char *part);
46     static Evas_Object *getUriChk(void *data,
47                                   Evas_Object *obj,
48                                   const char *part);
49     static void delUriData(void *data, Evas_Object *obj);
50
51     static void onBackBtnClicked(void *data,
52                                  Evas_Object *obj,
53                                  void *event_info);
54     static void onEditModeBtnClicked(void *data,
55                                      Evas_Object *obj,
56                                      void *event_info);
57     static void onOptBtnClicked(void *data,
58                                 Evas_Object *obj,
59                                 void *event_info);
60     static void onUriClicked(void *data,
61                              Evas_Object *obj,
62                              void *event_info);
63     static void onUriChkClicked(void *data,
64                                 Evas_Object *obj,
65                                 void *event_info);
66     static void onSelectAllChkClicked(void *data,
67                                       Evas_Object *obj,
68                                       void *event_info);
69     static void onSelectAllClicked(void *data,
70                                    Evas *e,
71                                    Evas_Object *obj,
72                                    void *event_info);
73     static void onRemoveWhiteUriPopupOk(void *data,
74                                         Evas_Object *obj,
75                                         void *event_info);
76     static void onRemoveWhiteUriPopupCancel(void *data,
77                                             Evas_Object *obj,
78                                             void *event_info);
79     static void onWhiteUriViewUnload(void *data);
80
81     void addUri(DPL::String &uri);
82     Evas_Object *addToolBar(Evas_Object *parent);
83     bool pushToNaviFrame(void);
84     void popFromNaviFrame(void);
85     bool addNoContent(Evas_Object *ly);
86     bool addContents(Evas_Object *ly);
87
88   public:
89     WhiteListView(Evas_Object *naviFrame);
90     ~WhiteListView(void);
91
92     bool loadView(void);
93     void loadWhiteUriView(std::string *uri = NULL);
94     void delWhiteUriView(void);
95     void reloadUri(void);
96     void handleEditModeBtn(void);
97     void handleOptBtn(void);
98     void handleBackBtn(void);
99     void removeWhiteUri(void);
100     void increaseSelectCnt(void);
101     void decreaseSelectCnt(void);
102     void selectAll(Eina_Bool select);
103     bool showPopup(const char *desc,
104                    Evas_Smart_Cb ok_cb,
105                    Evas_Smart_Cb cancel_cb,
106                    void *data);
107     void hidePopup(void);
108 };
109
110 class UriData
111 {
112   public:
113     WhiteListView *m_whiteListView;
114     std::string m_uri;
115     Evas_Object *m_chk;
116     Eina_Bool m_selected;
117
118     UriData(WhiteListView *whiteListView, std::string uri) :
119         m_whiteListView(whiteListView),
120         m_uri(uri),
121         m_chk(NULL),
122         m_selected(EINA_FALSE) { };
123
124     ~UriData(void) { };
125 };
126
127 } /* WebAppCommonSetting */
128
129 #endif /* WEB_SRC_SETTING_WEBAPP_COMMON_WHITELISTVIEW_H_ */