tcMenu
SecuredMenuPopup.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 https://www.thecoderscorner.com (Dave Cherry).
3  * This product is licensed under an Apache license, see the LICENSE file in the top-level directory.
4  */
5 
6 #ifndef _SECURED_MENU_POPUP_H_
7 #define _SECURED_MENU_POPUP_H_
8 
14 #include <RuntimeMenuItem.h>
15 #include <RemoteAuthentication.h>
16 
17 int secPopupActionRenderFn(RuntimeMenuItem* item, uint8_t row, RenderFnMode mode, char* buffer, int bufferSize);
18 
20 private:
21  SubMenuItem* securedItem;
22 public:
23  ActivateSubMenuItem(RuntimeRenderingFn customRenderFn, int activeStatus, MenuItem* next = NULL)
24  : RuntimeMenuItem(MENUTYPE_ACTIVATE_SUBMENU, nextRandomId(), customRenderFn, activeStatus, 1, next) {
25  }
26 
27  void setSecuredItem(SubMenuItem *secured) {
28  securedItem = secured;
29  }
30 
31  SubMenuItem* getSecuredItem() { return securedItem; }
32 };
33 
41 private:
42  BackMenuItem backMenuItem;
43  TextMenuItem pinEntryItem;
44  ActivateSubMenuItem actionProceedItem;
45  ActivateSubMenuItem actionCancelItem;
46  AuthenticationManager* authentication;
47 public:
48  SecuredMenuPopup(AuthenticationManager *authentication);
49 
50  MenuItem* getItemToActivate() { return &pinEntryItem; }
51 
52  MenuItem* start(SubMenuItem* securedMenu);
53 
54  MenuItem* getRootItem() {
55  return &backMenuItem;
56  }
57 
58  bool doesPinMatch() {
59  return authentication->doesPinMatch(pinEntryItem.getTextValue());
60  }
61 };
62 
63 #endif // _SECURED_MENU_POPUP_H_
RenderFnMode
Definition: MenuItems.h:283
int(* RuntimeRenderingFn)(RuntimeMenuItem *item, uint8_t row, RenderFnMode mode, char *buffer, int bufferSize)
Definition: MenuItems.h:318
@ MENUTYPE_ACTIVATE_SUBMENU
Definition: MenuItems.h:256
Contains the base functionality for communication between the menu library and remote APIs.
Contains definitions of menu items that can be fully defined at runtime with no need for prog mem str...
menuid_t nextRandomId()
Definition: RuntimeMenuItem.cpp:15
Definition: SecuredMenuPopup.h:19
Definition: RemoteAuthentication.h:38
virtual bool doesPinMatch(const char *pinAttempt)=0
Definition: RuntimeMenuItem.h:116
Definition: MenuItems.h:329
Definition: RuntimeMenuItem.h:75
Definition: SecuredMenuPopup.h:40
Definition: RuntimeMenuItem.h:149
Definition: RuntimeMenuItem.h:268
const char * getTextValue() const
Definition: RuntimeMenuItem.h:337