NABI issues N_SE-50115, N_SE-50067, N_SE-49946, N_SE-49897, N_SE-49884, N_SE-48837...
[apps/osp/Settings.git] / src / StCertificateForm.cpp
1 //
2 // Copyright (c) 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 /**
18  * @file                StCertificateForm.cpp
19  * @brief               This is the implementation file for CertificateForm class.
20  */
21
22 #include "StCertificateForm.h"
23 #include "StResourceManager.h"
24 #include "StSettingScenesList.h"
25 #include "StTypes.h"
26
27 using namespace Tizen::Base;
28 using namespace Tizen::Graphics;
29 using namespace Tizen::Ui;
30 using namespace Tizen::Ui::Controls;
31 using namespace Tizen::Ui::Scenes;
32
33 static const int ID_GROUP_CERTIFICATES_MAIN = 0;
34 static const int ID_GROUP_CERTIFICATES_MAIN_ITEM_COUNT = 2;
35 static const int ID_ITEM_TRUSTED_ROOT_CERTIFICATES = 0;
36 static const int ID_ITEM_USER_CERTIFICATES = 1;
37
38 static const int ID_GROUP_COUNT = 1;
39 static const int ID_GROUP_MAX_ITEM_COUNT = ID_GROUP_CERTIFICATES_MAIN_ITEM_COUNT;
40
41 CertificateForm::CertificateForm(void)
42 {
43 }
44
45 CertificateForm::~CertificateForm(void)
46 {
47 }
48
49 void
50 CertificateForm::CreateFooter(void)
51 {
52         Footer* pFooter = GetFooter();
53         AppAssert(pFooter);
54
55         pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
56         pFooter->AddActionEventListener(*this);
57
58         SetFormBackEventListener(this);
59 }
60
61 result
62 CertificateForm::OnInitializing(void)
63 {
64         CreateHeader(ResourceManager::GetString(L"IDS_ST_BODY_CERTIFICATES"));
65         CreateTableView();
66
67         AppLogDebug("ENTER");
68
69         return E_SUCCESS;
70 }
71
72 void
73 CertificateForm::CreateTableView(void)
74 {
75         Rectangle tableViewBounds = GetClientAreaBounds();
76         tableViewBounds.y = Y_GROUP_DEFAULT;
77
78         __pTableView = new (std::nothrow) GroupedTableView();
79
80         __pTableView->Construct(tableViewBounds, true, TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT);
81         __pTableView->SetItemProvider(this);
82
83         AddControl(__pTableView);
84         __pTableView->SetGroupedLookEnabled(true);
85         __pTableView->AddGroupedTableViewItemEventListener(*this);
86         RelativeLayout* pRelativeLayout = dynamic_cast<RelativeLayout*>(this->GetLayoutN());
87         if (pRelativeLayout != null)
88         {
89                 pRelativeLayout->SetHorizontalFitPolicy(*__pTableView, FIT_POLICY_PARENT);
90                 pRelativeLayout->SetVerticalFitPolicy(*__pTableView, FIT_POLICY_PARENT);
91                 delete pRelativeLayout;
92         }
93 }
94
95 result
96 CertificateForm::OnTerminating(void)
97 {
98         __pTableView = null;
99
100         SetFormBackEventListener(null);
101         return E_SUCCESS;
102 }
103
104 void
105 CertificateForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
106 {
107         
108 }
109
110 void
111 CertificateForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
112 {
113 }
114
115 void
116 CertificateForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
117 {
118         SceneManager* pSceneManager = SceneManager::GetInstance();
119         AppAssert(pSceneManager);
120
121         pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
122 }
123
124 int
125 CertificateForm::GetGroupCount(void)
126 {
127         AppLogDebug("ENTER");
128         return ID_GROUP_COUNT;
129 }
130
131 int
132 CertificateForm::GetItemCount(int groupIndex)
133 {
134         int itemCount = ID_GROUP_MAX_ITEM_COUNT;
135         return itemCount;
136 }
137
138 TableViewGroupItem*
139 CertificateForm::CreateGroupItem(int groupIndex, int itemWidth)
140 {
141         AppLogDebug("ENTER");
142
143         int itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
144         int yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
145         LabelTextStyle style = LABEL_TEXT_STYLE_BOLD;
146         Rectangle itemMainRectangle;
147         String groupText;
148         Label* pLabel = null;
149
150         TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
151
152         yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
153         itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
154
155         itemMainRectangle.x = X_GROUP_ITEM_DEFAULT_LABEL;
156         itemMainRectangle.y = yItemOffset;
157         itemMainRectangle.width = itemWidth;
158         itemMainRectangle.height = itemHeight;
159
160         RelativeLayout relativeLayout;
161         relativeLayout.Construct();
162
163         pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
164         pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
165
166         pLabel = new (std::nothrow) Label();
167         pLabel->Construct(itemMainRectangle, groupText);
168         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
169         pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
170         pLabel->SetTextConfig(FONT_SIZE_GROUP_TITLE_TEXT, style);
171         pLabel->SetTextColor(COLOR_GROUP_TITLE_TEXT);
172
173         pItem->AddControl(pLabel);
174         relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
175         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
176         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
177         pItem->SetEnabled(false);
178
179         return pItem;
180 }
181
182 TableViewItem*
183 CertificateForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
184 {
185         AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
186
187         Rectangle itemMainRectangle;
188         TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
189         String itemMainText;
190         Label* pLabel = null;
191         int fontSize = GetFontSize();
192
193         switch (itemIndex)
194         {
195         case ID_ITEM_TRUSTED_ROOT_CERTIFICATES:
196                 {
197                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_TRUSTED_ROOT_CERTIFICATES");
198                 }
199                 break;
200
201         case ID_ITEM_USER_CERTIFICATES:
202                 {
203                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_USER_CERTIFICATES");
204                 }
205                 break;
206
207         default:
208                 break;
209         }
210         TableViewItem* pItem = new (std::nothrow) TableViewItem();
211
212         ItemTypeOneLine(itemMainRectangle);
213
214         RelativeLayout relativeLayout;
215         relativeLayout.Construct();
216
217         pItem->Construct(relativeLayout, Dimension(itemWidth, H_GROUP_ITEM_DEFAULT), style);
218         pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
219
220         pLabel = new (std::nothrow) Label();
221         pLabel->Construct(itemMainRectangle, itemMainText);
222         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
223         pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
224         pLabel->SetTextColor(COLOR_MAIN_TEXT);
225
226         pItem->AddControl(pLabel);
227         relativeLayout.SetMargin(*pLabel, 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
228         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
229         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
230
231         return pItem;
232 }
233
234 bool
235 CertificateForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
236 {
237         AppLogDebug("ENTER");
238
239         delete pItem;
240         pItem = null;
241
242         return true;
243 }
244
245 bool
246 CertificateForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
247 {
248         AppLogDebug("ENTER");
249
250         delete pItem;
251         pItem = null;
252
253         return true;
254 }
255
256 void
257 CertificateForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
258 {
259         SceneManager* pSceneManager = SceneManager::GetInstance();
260         AppAssert(pSceneManager);
261
262         switch (itemIndex)
263         {
264         case ID_ITEM_USER_CERTIFICATES:
265                 {
266                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CERTIFICATE_USER, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), null);
267                 }
268                 break;
269
270         default:
271                 {
272                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CERTIFICATE_LIST, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), null);
273                 }
274                 break;
275         }
276         AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
277 }
278
279 int
280 CertificateForm::GetDefaultGroupItemHeight(void)
281 {
282         return H_GROUP_INDEX_NO_TITLE_DEFAULT;
283 }
284
285 int
286 CertificateForm::GetDefaultItemHeight(void)
287 {
288         return H_GROUP_ITEM_DEFAULT;
289 }
290
291 void
292 CertificateForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
293 {
294 }
295
296 void
297 CertificateForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
298 {
299 }
300
301 void
302 CertificateForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
303 {
304 }
305
306 void
307 CertificateForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
308 {
309 }