Remove the WAC code
[apps/home/wrt-setting.git] / webapp-common / listview.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_LISTVIEW_H_
18 #define WEB_SRC_SETTING_WEBAPP_COMMON_LISTVIEW_H_
19
20 #include <Elementary.h>
21
22 #include <dpl/wrt-dao-ro/global_dao_read_only.h>
23 #include <dpl/scoped_ptr.h>
24 #include <string>
25
26 #include "whitelistview.h"
27 #include "popup.h"
28 #include "view.h"
29
30 namespace WebAppCommonSetting {
31
32 typedef bool (*GetOnOffVal)(void);
33
34 class ListView : public View
35 {
36     Evas_Object *m_naviFrame;
37     Evas_Object *m_gl;
38     Popup m_popup;
39     DPL::ScopedPtr<WhiteListView> m_whiteListView;
40
41     /* Genlist Item Callbacks */
42     static char *getWacTitle(void *data,
43                              Evas_Object *obj,
44                              const char *part);
45     static char *getWhiteListTitle(void *data,
46                                    Evas_Object *obj,
47                                    const char *part);
48     static char *getText(void *data,
49                                Evas_Object *obj,
50                                const char *part);
51     static Evas_Object *getOnOffIcon(void *data,
52                                      Evas_Object *obj,
53                                      const char *part);
54     static void delOnOffData(void *data, Evas_Object *obj);
55     static char *getRoamingLabel(void *data,
56                                  Evas_Object *obj,
57                                  const char *part);
58     static void delRoamingData(void *data, Evas_Object *obj);
59     static char *getRoamingOptLabel(void *data,
60                                     Evas_Object *obj,
61                                     const char *part);
62     static Evas_Object *getRoamingOptRadio(void *data,
63                                            Evas_Object *obj,
64                                            const char *part);
65     static void delRoamingExpandData(void *data, Evas_Object *obj);
66
67     /* Smart Callbacks */
68     static void onBackBtnClicked(void *data,
69                                  Evas_Object *obj,
70                                  void *event_info);
71     static void onOnOffItemClicked(void *data,
72                                    Evas_Object *obj,
73                                    void *event_info);
74     static void onCookieSharingPopupOk(void *data,
75                                        Evas_Object *obj,
76                                        void *event_info);
77     static void onCookieSharingPopupCancel(void *data,
78                                            Evas_Object *obj,
79                                            void *event_info);
80     static void onCookieSharingChanged(void *data,
81                                        Evas_Object *obj,
82                                        void *event_info);
83     static void onUntrustedAppApprovalPopupOk(void *data,
84                                               Evas_Object *obj,
85                                               void *event_info);
86     static void onUntrustedAppApprovalPopupCancel(void *data,
87                                                   Evas_Object *obj,
88                                                   void *event_info);
89     static void onUntrustedAppApprovalChanged(void *data,
90                                               Evas_Object *obj,
91                                               void *event_info);
92     static void onRoamingClicked(void *data,
93                                  Evas_Object *obj,
94                                  void *event_info);
95     static void onRoamingOptClicked(void *data,
96                                     Evas_Object *obj,
97                                     void *event_info);
98     static void onWhiteListClicked(void *data,
99                                    Evas_Object *obj,
100                                    void *event_info);
101
102         /* Subview Unload callback */
103     static void onWhiteListViewUnload(void *data);
104
105     /* Utility methods */
106     static bool getCookieSharingVal(void);
107     static bool getUntrustedAppApprovalVal(void);
108
109     void addWacTitle(Evas_Object *gl);
110     void addWhiteList(Evas_Object *gl);
111     void addOnOffItem(Evas_Object *gl,
112                       const char *title,
113                       GetOnOffVal getOnOffVal,
114                       Evas_Smart_Cb cb);
115     void addDesc(Evas_Object *gl, const char *title);
116     void addDepth(Evas_Object *gl);
117     void addRoamingItem(Evas_Object *gl);
118     void addRoamingOpts(Evas_Object *obj, Elm_Object_Item *it);
119
120   public:
121     ListView(Evas_Object *naviFrame);
122     ~ListView(void);
123
124     bool loadView(void);
125     bool pushToNaviFrame(void);
126     void loadWhiteListView(void);
127     void delWhiteListView(void) { m_whiteListView.Reset(); }
128     bool showPopup(const char *desc,
129                    Evas_Smart_Cb ok_cb,
130                    Evas_Smart_Cb cancel_cb,
131                    void *data);
132     void hidePopup(void);
133 };
134
135 class OnOffData
136 {
137   public:
138     ListView *m_listView;
139     std::string m_title;
140     Evas_Object *m_chk;
141     GetOnOffVal m_getOnOffVal;
142     Evas_Smart_Cb m_changedCb;
143
144     OnOffData(ListView *listView,
145               const char *title,
146               GetOnOffVal getOnOffVal,
147               Evas_Smart_Cb changedCb) :
148         m_listView(listView),
149         m_title(title),
150         m_chk(NULL),
151         m_getOnOffVal(getOnOffVal),
152         m_changedCb(changedCb) { };
153
154     ~OnOffData(void) { };
155 };
156
157 class RoamingData
158 {
159   public:
160     Evas_Object *m_rg;
161     ListView *m_listView;
162
163     RoamingData(Evas_Object *rg, ListView *listView) :
164         m_rg(rg),
165         m_listView(listView) { };
166
167     ~RoamingData(void)
168     {
169         if (m_rg)
170             evas_object_del(m_rg);
171     };
172 };
173
174 class RoamingExpandData
175 {
176   public:
177     WrtDB::GlobalDAOReadOnly::NetworkAccessMode m_mode;
178     Evas_Object *m_rg;
179
180     RoamingExpandData(WrtDB::GlobalDAOReadOnly::NetworkAccessMode mode,
181                       Evas_Object *rg) :
182         m_mode(mode),
183         m_rg(rg) { };
184     ~RoamingExpandData(void) { };
185 };
186
187 class ComplianceModeData
188 {
189   public:
190     ListView *m_listView;
191     Evas_Object *m_gl;
192     Evas_Object *m_chk;
193     Elm_Object_Item *m_it;
194
195     ComplianceModeData(ListView *listView, Evas_Object *gl) :
196         m_listView(listView),
197         m_gl(gl),
198         m_chk(NULL),
199         m_it(NULL) { };
200     ~ComplianceModeData(void) { };
201 };
202
203 } /* WebAppCommonSetting */
204
205 #endif /* WEB_SRC_SETTING_WEBAPP_COMMON_LISTVIEW_H_ */