Applied latest source code
[apps/native/preloaded/Settings.git] / src / StCertificateUserForm.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                StCertificateUserForm.cpp
19  * @brief               This is the implementation file for CertificateUserForm class.
20  */
21
22 #include "StCertificateUserForm.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::Security::Cert;
30 using namespace Tizen::Ui;
31 using namespace Tizen::Ui::Controls;
32 using namespace Tizen::Ui::Scenes;
33
34 static const int IDA_CERTIFICATE_USER_FORM_FOOTER_BASE = 100;
35 static const int IDA_CERTIFICATE_USER_FORM_FOOTER_INSTALL = IDA_CERTIFICATE_USER_FORM_FOOTER_BASE + 1;
36 static const int IDA_CERTIFICATE_USER_FORM_FOOTER_UNINSTALL = IDA_CERTIFICATE_USER_FORM_FOOTER_BASE + 2;
37 static const int ID_CERTIFICATE_USER_FORM_FOOTER_INSTALL = 0;
38 static const int ID_CERTIFICATE_USER_FORM_FOOTER_UNINSTALL = 1;
39
40 static const int ID_GROUP_COUNT = 1;
41
42 static const int IDA_SD_INSTALL_POPUP_OK = 200;
43 static const int IDA_SD_INSTALL_POPUP_CANCEL = 300;
44
45 static const int Y_ALERT_POPUP_CLIENT_RECT_DEFAULT = 50;
46 static const int H_ALERT_POPUP_CLIENT_RECT_RESIZE = 470;
47 static const int W_ALERT_POPUP_CLIENT_RECT_RESIZE = 720;
48 static const int Y_ALERT_POPUP_ITEM_RECT_LABEL_DEFAULT = 20;
49 static const int H_ALERT_POPUP_ITEM_RECT_LABEL_DEFAULT = 340;
50 static const int X_ALERT_POPUP_ITEM_RECT_LHS_BUTTON_DEFAULT = 20;
51 static const int Y_ALERT_POPUP_ITEM_RECT_LHS_BUTTON_DEFAULT = 350;
52 static const int W_ALERT_POPUP_ITEM_RECT_LHS_BUTTON_DEFAULT = 310;
53 static const int H_ALERT_POPUP_ITEM_RECT_LHS_BUTTON_DEFAULT = 80;
54 static const int X_ALERT_POPUP_ITEM_RECT_RHS_BUTTON_RESIZE = 20;
55
56 static const int ALERT_POPUP_LABEL_FONT_SIZE = 40;
57
58 CertificateUserForm::CertificateUserForm(void)
59         : __pCertificatePresentationModelInstance(null)
60         , __installFromSDCardPopup(null)
61         , __isPopupVisible(false)
62 {
63 }
64
65 CertificateUserForm::~CertificateUserForm(void)
66 {
67 }
68
69 void
70 CertificateUserForm::CreateFooter(void)
71 {
72         Footer* pFooter = GetFooter();
73         AppAssert(pFooter);
74
75         pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
76
77         FooterItem footerInstall;
78         FooterItem footerUninstall;
79         footerInstall.Construct(IDA_CERTIFICATE_USER_FORM_FOOTER_INSTALL);
80         footerInstall.SetText(ResourceManager::GetString(L"IDS_ST_BUTTON_INSTALL"));
81         footerUninstall.Construct(IDA_CERTIFICATE_USER_FORM_FOOTER_UNINSTALL);
82         footerUninstall.SetText(ResourceManager::GetString(L"IDS_ST_BUTTON_UNINSTALL"));
83         pFooter->AddItem(footerInstall);
84         pFooter->AddItem(footerUninstall);
85         pFooter->SetItemEnabled(ID_CERTIFICATE_USER_FORM_FOOTER_INSTALL, true);
86         pFooter->SetItemEnabled(ID_CERTIFICATE_USER_FORM_FOOTER_UNINSTALL, false);
87
88         pFooter->AddActionEventListener(*this);
89
90         SetFormBackEventListener(this);
91 }
92
93 result
94 CertificateUserForm::OnInitializing(void)
95 {
96         SetFormStyle(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_HEADER | FORM_STYLE_FOOTER | FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE);
97         CreateHeader(ResourceManager::GetString(L"IDS_ST_BODY_USER_CERTIFICATES"));
98         CreateFooter();
99
100         return InitCertificatePresentationModelInstance();
101 }
102
103 result
104 CertificateUserForm::OnTerminating(void)
105 {
106         delete __installFromSDCardPopup;
107         __installFromSDCardPopup = null;
108         __pTableView = null;
109         __isPopupVisible = false;
110
111         SetFormBackEventListener(null);
112         return E_SUCCESS;
113 }
114
115 void
116 CertificateUserForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
117 {
118         __isPopupVisible = false;
119         if (__pTableView != null)
120         {
121                 int tableViewControlCount = __pTableView->GetControlCount();
122                 for (int i = 0; i < tableViewControlCount; i++)
123                 {
124                         __pTableView->RemoveControl(__pTableView->GetControl(0));
125                 }
126 //              __pTableView->RemoveAllControls();
127                 __pTableView = null;
128         }
129         int controlCount = GetControlCount();
130         for (int i = 0; i < controlCount; i++)
131         {
132                 RemoveControl(GetControl(0));
133         }
134 //      RemoveAllControls();
135         if (GetUserCertificateStoreCount() != 0)
136         {
137                 AppLogDebug("GetUserCertificateStoreCount %d", GetUserCertificateStoreCount());
138                 CreateTableView();
139                 EnableUninstallFooter();
140                 __pTableView->UpdateTableView();
141         }
142         else
143         {
144                 Label* pLabel = static_cast<Label*>(this->GetControl(NO_CONTENTS, false));
145                 if (pLabel == null)
146                 {
147                         Rectangle clientRect = GetClientAreaBounds();
148                         Bitmap* pBitmp = ResourceManager::GetBitmapN(IDB_NO_CONTENTS);
149
150                         int bitmapWidth = pBitmp->GetWidth();
151                         int bitmapHeight = pBitmp->GetHeight();
152                         String labelText = ResourceManager::GetString(L"IDS_ST_BODY_NO_CONTENT");
153                         Color textColor = COLOR_HELP_TEXT_TYPE_03_NORMAL;
154                         int noContentTextHeight = GetHeightForStringArea(labelText, bitmapWidth, 32);
155
156                         int xPos = (clientRect.width / LINE_COUNT_2) - (bitmapWidth / DIVIDE_BY_TWO);
157                         int yPos = (clientRect.height / LINE_COUNT_2) - ((bitmapHeight + noContentTextHeight) / DIVIDE_BY_TWO);
158
159                         Label* pLabel = new (std::nothrow) Label();
160                         pLabel->Construct(Rectangle(xPos, yPos, bitmapWidth, bitmapHeight), L"");
161                         pLabel->SetName(NO_CONTENTS);
162                         pLabel->SetBackgroundBitmap(*pBitmp);
163
164                         yPos = yPos + bitmapHeight;
165
166                         Label* pLabelNoContents = new (std::nothrow) Label();
167                         pLabelNoContents->Construct(Rectangle(0, yPos, clientRect.width, noContentTextHeight), L"");
168                         pLabelNoContents->SetName(NO_CONTENTS_TEXT);
169                         pLabelNoContents->SetTextColor(textColor);
170                         pLabelNoContents->SetText(labelText);
171
172                         AddControl(pLabel);
173                         AddControl(pLabelNoContents);
174                 }
175                 DisableUninstallFooter();
176         }
177 }
178
179 void
180 CertificateUserForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
181 {
182 }
183
184 void
185 CertificateUserForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
186 {
187         SceneManager* pSceneManager = SceneManager::GetInstance();
188         AppAssert(pSceneManager);
189
190         pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
191 }
192
193 int
194 CertificateUserForm::GetGroupCount(void)
195 {
196         AppLogDebug("ENTER");
197         return ID_GROUP_COUNT;
198 }
199
200 int
201 CertificateUserForm::GetItemCount(int groupIndex)
202 {
203         return GetUserCertificateStoreCount();
204 }
205
206 TableViewGroupItem*
207 CertificateUserForm::CreateGroupItem(int groupIndex, int itemWidth)
208 {
209         int itemHeight = 0;
210
211         TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
212
213         pItem->Construct(Dimension(itemWidth, itemHeight));
214         pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
215
216         pItem->SetEnabled(false);
217
218         return pItem;
219 }
220
221 TableViewItem*
222 CertificateUserForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
223 {
224         Rectangle itemMainRectangle;
225         Rectangle itemSubRectangle;
226
227         TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
228         String itemText = CertificatePresentationModelUtility::GetCommonName(
229                                                         __pCertificatePresentationModelInstance->GetSubjectNameFromCertifcateStore(itemIndex));
230         if (IsFailed(GetLastResult()))
231         {
232                 AppLogDebug("GetSubjectNameFromCertifcateStore(%d) failed(%s)", itemIndex, GetErrorMessage(GetLastResult()));
233                 return null;
234         }
235
236         String itemSecondText = CertificatePresentationModelUtility::GetOrganisation(
237                                                         __pCertificatePresentationModelInstance->GetSubjectNameFromCertifcateStore(itemIndex));
238         if (IsFailed(GetLastResult()))
239         {
240                 AppLogDebug("GetSubjectNameFromCertifcateStore(%d) failed(%s)", itemIndex, GetErrorMessage(GetLastResult()));
241                 itemSecondText = ResourceManager::GetString(L"IDS_ST_BODY_NO_DATA");
242         }
243         TableViewItem* pItem = new (std::nothrow) TableViewItem();
244
245         int fontSize = GetFontSize();
246         ItemTypeTwoLine(itemMainRectangle, itemSubRectangle, fontSize);
247         int itemHeight = (itemMainRectangle.height + itemSubRectangle.height);
248
249         RelativeLayout relativeLayout;
250         relativeLayout.Construct();
251
252         pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight), style);
253         pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
254
255         Label* pLabel = new (std::nothrow) Label();
256         pLabel->Construct(itemMainRectangle, itemText);
257         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
258         pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
259         pLabel->SetTextColor(COLOR_MAIN_TEXT);
260
261         pItem->AddControl(pLabel);
262         relativeLayout.SetMargin(*pLabel, 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
263         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
264         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
265
266         Label* pSecondLabel = new (std::nothrow) Label();
267         result r = pSecondLabel->Construct(itemSubRectangle, itemSecondText);
268         if (IsFailed(r))
269         {
270                 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
271                 delete pSecondLabel;
272                 return pItem;
273         }
274
275         pSecondLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
276         pSecondLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
277         pSecondLabel->SetTextColor(COLOR_SUB_TEXT);
278         pSecondLabel->SetTextConfig(H_GROUP_INDEX_TEXT_GAP, LABEL_TEXT_STYLE_NORMAL);
279
280         pItem->AddControl(pSecondLabel);
281         relativeLayout.SetMargin(*pSecondLabel, 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
282         relativeLayout.SetRelation(*pSecondLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
283         relativeLayout.SetRelation(*pSecondLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
284
285         return pItem;
286 }
287
288 bool
289 CertificateUserForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
290 {
291         AppLogDebug("ENTER");
292
293         delete pItem;
294         pItem = null;
295
296         return true;
297 }
298
299 bool
300 CertificateUserForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
301 {
302         AppLogDebug("ENTER");
303
304         delete pItem;
305         pItem = null;
306
307         return true;
308 }
309
310 void
311 CertificateUserForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
312 {
313         SceneManager* pSceneManager = SceneManager::GetInstance();
314         AppAssert(pSceneManager);
315         ICertificate* pICertificate = __pCertificatePresentationModelInstance->GetCertificateFromCertificateStoreN(itemIndex);
316         if (pICertificate == null)
317         {
318                 AppLogDebug("GetCertificateFromCertificateStoreN is null");
319                 return;
320         }
321         __pCertificatePresentationModelInstance->ClearPendingCertificate();
322         bool isPending = __pCertificatePresentationModelInstance->PushPendingCertificate(*pICertificate);
323         if (isPending == false)
324         {
325                 AppLogDebug("PushPendingCertificate failed");
326                 return;
327         }
328         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CERTIFICATE_DETAIL, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), null);
329 }
330
331 int
332 CertificateUserForm::GetDefaultGroupItemHeight(void)
333 {
334         return H_GROUP_INDEX_NO_TITLE_DEFAULT;
335 }
336
337 int
338 CertificateUserForm::GetDefaultItemHeight(void)
339 {
340         return H_GROUP_ITEM_DEFAULT;
341 }
342
343 void
344 CertificateUserForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
345 {
346 }
347
348 void
349 CertificateUserForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
350 {
351 }
352
353 void
354 CertificateUserForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
355 {
356 }
357
358 void
359 CertificateUserForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
360 {
361 }
362
363 void
364 CertificateUserForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
365 {
366         Label* pLabel = static_cast<Label*>(this->GetControl(NO_CONTENTS, false));
367         if (pLabel != null)
368         {
369                 Rectangle clientRect = GetClientAreaBounds();
370                 Rectangle labelBound = pLabel->GetBounds();
371
372                 int xPos = (clientRect.width / LINE_COUNT_2) - (labelBound.width / LINE_COUNT_2);
373                 int yPos = (clientRect.height / LINE_COUNT_2) -(labelBound.height / LINE_COUNT_2);
374
375                 pLabel->SetBounds(Rectangle(xPos, yPos, labelBound.width, labelBound.height));
376                 yPos = yPos + pLabel->GetBounds().height;
377                 Label* pTextLabel = static_cast<Label*>(this->GetControl(NO_CONTENTS_TEXT, false));
378                 if (pTextLabel != null)
379                 {
380                         pTextLabel->SetBounds(Rectangle(0, yPos, clientRect.width, pTextLabel->GetBounds().height));
381                 }
382         }
383         Invalidate(true);
384 }
385
386 void
387 CertificateUserForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
388 {
389         SceneManager* pSceneManager = SceneManager::GetInstance();
390         AppAssert(pSceneManager);
391         
392         switch (actionId)
393         {
394         case IDA_CERTIFICATE_USER_FORM_FOOTER_INSTALL:
395                 {
396                         if (__isPopupVisible == false)
397                         {
398                                 CreateAlertPopup();
399                                 ShowAlertPopup();
400                         }
401                 }
402                 break;
403
404         case IDA_CERTIFICATE_USER_FORM_FOOTER_UNINSTALL:
405                 {
406                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CERTIFICATE_USER_UNINSTALL, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), null);
407                 }
408                 break;
409
410         case IDA_SD_INSTALL_POPUP_OK:
411                 {
412                         HideAlertPopup();
413                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CERTIFICATE_USER_INSTALL, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), null);
414                 }
415                 break;
416
417         case IDA_SD_INSTALL_POPUP_CANCEL:
418                 {
419                         HideAlertPopup();
420                 }
421                 break;
422
423         default:
424                 break;
425         }
426 }
427 result
428 CertificateUserForm::InitCertificatePresentationModelInstance(void)
429 {
430         __pCertificatePresentationModelInstance = CertificatePresentationModel::GetInstance();
431         if (__pCertificatePresentationModelInstance == null)
432         {
433                 return E_FAILURE;
434         }
435         result r = __pCertificatePresentationModelInstance->SetCertificateSelector(USER_CERT);
436         if (IsFailed(r))
437         {
438                 AppLogDebug("SetCertificateSelector failed(%s)", GetErrorMessage(r));
439         }
440         __pCertificatePresentationModelInstance->UpdateCertificateListFromCertificateStore();
441         if (__pCertificatePresentationModelInstance->GetCertificateStoreCount() != 0)
442         {
443                 EnableUninstallFooter();
444         }
445         else
446         {
447                 DisableUninstallFooter();
448         }
449         return r;
450 }
451
452 int
453 CertificateUserForm::GetUserCertificateStoreCount(void)
454 {
455         return __pCertificatePresentationModelInstance->GetCertificateStoreCount();
456 }
457
458 void
459 CertificateUserForm::DisableUninstallFooter(void)
460 {
461         Footer* pFooter = GetFooter();
462         AppAssert(pFooter);
463         pFooter->SetItemEnabled(ID_CERTIFICATE_USER_FORM_FOOTER_UNINSTALL, false);
464         pFooter->Invalidate(false);
465 }
466
467 void
468 CertificateUserForm::EnableUninstallFooter(void)
469 {
470         Footer* pFooter = GetFooter();
471         AppAssert(pFooter);
472         pFooter->SetItemEnabled(ID_CERTIFICATE_USER_FORM_FOOTER_UNINSTALL, true);
473         pFooter->Invalidate(true);
474 }
475
476 result
477 CertificateUserForm::CreateAlertPopup(void)
478 {
479         String buttonText;
480         Label* pLabel = null;
481         Button* pLhsButton = null;
482         Button* pRhslButton = null;
483
484         Rectangle clientRect = GetClientAreaBounds();
485         Rectangle itemRectLabel;
486         Rectangle itemRectLhsButton;
487         Rectangle itemRectRhsButton;
488
489         clientRect.x = 0;
490         clientRect.y = Y_ALERT_POPUP_CLIENT_RECT_DEFAULT;
491         clientRect.width =  W_ALERT_POPUP_CLIENT_RECT_RESIZE;
492         clientRect.height = H_ALERT_POPUP_CLIENT_RECT_RESIZE;
493
494         itemRectLabel.x = X_ALERT_POPUP_ITEM_RECT_LHS_BUTTON_DEFAULT;
495         itemRectLabel.y = Y_ALERT_POPUP_ITEM_RECT_LABEL_DEFAULT;
496         itemRectLabel.width = clientRect.width;
497         itemRectLabel.height = H_ALERT_POPUP_ITEM_RECT_LABEL_DEFAULT;
498
499         itemRectLhsButton.x = X_ALERT_POPUP_ITEM_RECT_LHS_BUTTON_DEFAULT + itemRectLabel.x;
500         itemRectLhsButton.y = Y_ALERT_POPUP_ITEM_RECT_LHS_BUTTON_DEFAULT;
501         itemRectLhsButton.width = W_ALERT_POPUP_ITEM_RECT_LHS_BUTTON_DEFAULT;
502         itemRectLhsButton.height = H_ALERT_POPUP_ITEM_RECT_LHS_BUTTON_DEFAULT;
503
504         itemRectRhsButton = itemRectLhsButton;
505         itemRectRhsButton.x = itemRectLhsButton.x + itemRectLhsButton.width + X_ALERT_POPUP_ITEM_RECT_RHS_BUTTON_RESIZE;
506
507         Dimension bounds = Dimension(clientRect.width, clientRect.height);
508
509         __installFromSDCardPopup = new (std::nothrow) Popup();
510         __installFromSDCardPopup->Construct(false, bounds);
511
512         pLabel = new (std::nothrow) Label();
513         pLabel->Construct(itemRectLabel, ResourceManager::GetString(L"IDS_ST_BODY_INSTALL_CERTIFICATES_FROM_SD_CARD_Q"));
514         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
515         pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
516         pLabel->SetTextConfig(ALERT_POPUP_LABEL_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
517         __installFromSDCardPopup->AddControl(pLabel);
518
519         buttonText = ResourceManager::GetString(L"IDS_COM_SK_NO");
520         pLhsButton = new (std::nothrow) Button();
521         pLhsButton->Construct(itemRectLhsButton, buttonText);
522         pLhsButton->SetActionId(IDA_SD_INSTALL_POPUP_CANCEL);
523
524         __installFromSDCardPopup->AddControl(pLhsButton);
525
526         buttonText = ResourceManager::GetString(L"IDS_ST_BUTTON_YES");
527
528         pRhslButton = new (std::nothrow) Button();
529         pRhslButton->Construct(itemRectRhsButton, buttonText);
530         pRhslButton->SetActionId(IDA_SD_INSTALL_POPUP_OK);
531
532         __installFromSDCardPopup->AddControl(pRhslButton);
533         __installFromSDCardPopup->SetPropagatedKeyEventListener(this);
534
535         pLhsButton->AddActionEventListener(*this);
536         pRhslButton->AddActionEventListener(*this);
537
538         return E_SUCCESS;
539 }
540
541 void
542 CertificateUserForm::ShowAlertPopup(void)
543 {
544         __isPopupVisible = true;
545         __installFromSDCardPopup->SetShowState(true);
546         __installFromSDCardPopup->Show();
547 }
548
549 void
550 CertificateUserForm::HideAlertPopup(void)
551 {
552         __isPopupVisible = false;
553         __installFromSDCardPopup->SetShowState(false);
554         __installFromSDCardPopup->Invalidate(true);
555 }
556
557 bool
558 CertificateUserForm::OnKeyPressed(Control& source, const KeyEventInfo& keyEventInfo)
559 {
560         return false;
561 }
562
563 bool
564 CertificateUserForm::OnKeyReleased(Control& source, const KeyEventInfo& keyEventInfo)
565 {
566         if (__installFromSDCardPopup && __installFromSDCardPopup->GetShowState() == true && (keyEventInfo.GetKeyCode() == KEY_BACK || keyEventInfo.GetKeyCode() == KEY_ESC))
567         {
568                 HideAlertPopup();
569                 return true;
570         }
571         return false;
572 }
573
574 bool
575 CertificateUserForm::OnPreviewKeyPressed(Control& source, const KeyEventInfo& keyEventInfo)
576 {
577         return false;
578 }
579
580 bool
581 CertificateUserForm::OnPreviewKeyReleased(Control& source, const KeyEventInfo& keyEventInfo)
582 {
583         return false;
584 }