ManaPlus
Public Member Functions | Protected Attributes
PincodeManager Class Reference

#include <pincodemanager.h>

Public Member Functions

 PincodeManager ()
 
 ~PincodeManager ()
 
void init ()
 
void updateState ()
 
void pinOk ()
 
void wrongPin ()
 
void lockedPin ()
 
void setSeed (const uint32_t seed)
 
void setAccountId (const BeingId id)
 
void setState (const PincodeStateT state)
 
void setPincodeLockFlag (const bool flag)
 
void changePincode (const std::string &pincode)
 
void clearDialog (const PincodeDialog *const PincodeDialog)
 
void setNewPincode (const std::string &pincode)
 
void sendPincode (const std::string &pincode)
 
void closeDialogs ()
 
bool isBlocked ()
 
bool processPincodeStatus (const uint16_t state)
 

Protected Attributes

std::string mOldPincode
 
std::string mNewPincode
 
uint32_t mSeed
 
BeingId mAccountId
 
WindowmDialog
 
PincodeStateT mState
 
bool mLockFlag
 

Detailed Description

Definition at line 36 of file pincodemanager.h.

Constructor & Destructor Documentation

◆ PincodeManager()

PincodeManager::PincodeManager ( )

Definition at line 44 of file pincodemanager.cpp.

44  :
45  mOldPincode(),
46  mNewPincode(),
47  mSeed(0U),
49  mDialog(nullptr),
51  mLockFlag(false)
52 {
53 }
const BeingId BeingId_zero
Definition: beingid.h:30
std::string mNewPincode
std::string mOldPincode
Window * mDialog
PincodeStateT mState
BeingId mAccountId

◆ ~PincodeManager()

PincodeManager::~PincodeManager ( )

Definition at line 55 of file pincodemanager.cpp.

56 {
57 }

Member Function Documentation

◆ changePincode()

void PincodeManager::changePincode ( const std::string &  pincode)

Definition at line 166 of file pincodemanager.cpp.

167 {
168  if (mOldPincode.empty())
169  { // set old pincode
170  mOldPincode = pincode;
172  // TRANSLATORS: dialog caption
173  _("Change pincode"),
174  // TRANSLATORS: dialog label
175  _("Enter new pincode"),
176  mSeed,
177  nullptr);
179  mDialog->setActionEventId("ok");
181  }
182  else if (mNewPincode.empty())
183  { // set first new pincode
184  mNewPincode = pincode;
186  // TRANSLATORS: dialog caption
187  _("Change pincode"),
188  // TRANSLATORS: dialog label
189  _("Confirm new pincode"),
190  mSeed,
191  nullptr);
193  mDialog->setActionEventId("ok");
195  }
196  else
197  { // new pincode confirmation
198  if (mNewPincode != pincode)
199  {
200  mOldPincode.clear();
201  mNewPincode.clear();
203  // TRANSLATORS: error header
204  _("Pincode"),
205  // TRANSLATORS: error message
206  _("Wrong pincode confirmation!"),
207  // TRANSLATORS: ok dialog button
208  _("OK"),
210  Modal_true,
212  nullptr,
213  260);
215  }
216  else
217  {
219  mOldPincode,
220  mNewPincode);
221  mOldPincode.clear();
222  mNewPincode.clear();
223  }
224  }
225 }
ChangePincodeListener changePincodeListener
Net::CharServerHandler * charServerHandler
Definition: net.cpp:85
virtual void changePincode(const BeingId accountId, const std::string &oldPin, const std::string &newPin) const =0
void setActionEventId(const std::string &actionEventId)
Definition: widget.h:596
virtual void requestFocus()
Definition: widget.cpp:204
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:252
#define CREATEWIDGETV(var, type,...)
Definition: createwidget.h:25
#define _(s)
Definition: gettext.h:35
const bool Modal_true
Definition: modal.h:30
NewPincodeRetryListener newPincodeRetryListener
const bool ShowCenter_true
Definition: showcenter.h:30

References _, Widget::addActionListener(), Net::CharServerHandler::changePincode(), changePincodeListener, charServerHandler, CREATEWIDGETV, DialogType::ERROR, mAccountId, mDialog, mNewPincode, Modal_true, mOldPincode, mSeed, newPincodeRetryListener, Widget::requestFocus(), Widget::setActionEventId(), and ShowCenter_true.

Referenced by ChangePincodeListener::action().

◆ clearDialog()

void PincodeManager::clearDialog ( const PincodeDialog *const  PincodeDialog)

Definition at line 67 of file pincodemanager.cpp.

68 {
69  if (mDialog == PincodeDialog)
70  mDialog = nullptr;
71 }

References mDialog.

Referenced by PincodeDialog::close(), and PincodeDialog::~PincodeDialog().

◆ closeDialogs()

void PincodeManager::closeDialogs ( )

Definition at line 254 of file pincodemanager.cpp.

255 {
256  if (mDialog)
257  {
259  mDialog = nullptr;
260  }
261 }
virtual void scheduleDelete()
Definition: window.cpp:831

References mDialog, and Window::scheduleDelete().

◆ init()

void PincodeManager::init ( )

Definition at line 59 of file pincodemanager.cpp.

60 {
61  mSeed = 0;
64  mNewPincode.clear();
65 }

References BeingId_zero, mAccountId, mNewPincode, mSeed, mState, and PincodeState::None.

◆ isBlocked()

bool PincodeManager::isBlocked ( )

Definition at line 263 of file pincodemanager.cpp.

264 {
265  return mState != PincodeState::None;
266 }

References mState, and PincodeState::None.

Referenced by CharSelectDialog::action(), and CharSelectDialog::keyPressed().

◆ lockedPin()

void PincodeManager::lockedPin ( )

Definition at line 240 of file pincodemanager.cpp.

241 {
242  // +++ here can be handled locked account by pin code.
243  // but hercules for now not have this feature
245  updateState();
246 }

References PincodeState::Ask, mState, and updateState().

Referenced by processPincodeStatus().

◆ pinOk()

void PincodeManager::pinOk ( )

Definition at line 233 of file pincodemanager.cpp.

234 {
236  if (client)
237  client->focusWindow();
238 }
void focusWindow()
Definition: client.cpp:809
Client * client
Definition: client.cpp:118

References client, Client::focusWindow(), mState, and PincodeState::None.

Referenced by processPincodeStatus().

◆ processPincodeStatus()

bool PincodeManager::processPincodeStatus ( const uint16_t  state)

Definition at line 268 of file pincodemanager.cpp.

269 {
270  switch (state)
271  {
272  case 0: // pin ok
274  break;
275  case 1: // ask for pin
277  break;
278  case 2: // create new pin
279  case 4: // create new pin?
280  {
282  break;
283  }
284  case 3: // pin must be changed
286  break;
287  case 8: // pincode was incorrect
288  case 5: // client show error?
289  if (mLockFlag)
291  else
293  return true;
294  case 6: // Unable to use your KSSN number
295  case 7: // char select window shows a button
296  break;
297  default:
298  if (client)
300  return false;
301  }
302  if (client)
304  return true;
305 }
void updatePinState()
Definition: client.cpp:817
void setState(const PincodeStateT state)
PincodeManager pincodeManager

References PincodeState::Ask, PincodeState::Change, client, PincodeState::Create, lockedPin(), mLockFlag, pincodeManager, pinOk(), setState(), Client::updatePinState(), and wrongPin().

Referenced by EAthena::CharServerRecv::processPincodeStatus(), and EAthena::CharServerRecv::processPincodeStatus2().

◆ sendPincode()

void PincodeManager::sendPincode ( const std::string &  pincode)

Definition at line 227 of file pincodemanager.cpp.

228 {
230  pincode);
231 }
virtual void sendCheckPincode(const BeingId accountId, const std::string &pin) const =0

References charServerHandler, mAccountId, and Net::CharServerHandler::sendCheckPincode().

Referenced by PincodeListener::action().

◆ setAccountId()

void PincodeManager::setAccountId ( const BeingId  id)
inline

◆ setNewPincode()

void PincodeManager::setNewPincode ( const std::string &  pincode)

Definition at line 122 of file pincodemanager.cpp.

123 {
124  if (mNewPincode.empty())
125  { // first pincode
126  mNewPincode = pincode;
128  // TRANSLATORS: dialog caption
129  _("New pincode"),
130  // TRANSLATORS: dialog label
131  _("Confirm new pincode"),
132  mSeed,
133  nullptr);
135  mDialog->setActionEventId("ok");
137  }
138  else
139  { // pincode confirmation
140  if (mNewPincode != pincode)
141  {
142  mNewPincode.clear();
144  // TRANSLATORS: error header
145  _("Pincode"),
146  // TRANSLATORS: error message
147  _("Wrong pincode confirmation!"),
148  // TRANSLATORS: ok dialog button
149  _("OK"),
151  Modal_true,
153  nullptr,
154  260);
156  }
157  else
158  {
160  mNewPincode);
161  mNewPincode.clear();
162  }
163  }
164 }
virtual void setNewPincode(const BeingId accountId, const std::string &pin) const =0
NewPincodeListener newPincodeListener

References _, Widget::addActionListener(), charServerHandler, CREATEWIDGETV, DialogType::ERROR, mAccountId, mDialog, mNewPincode, Modal_true, mSeed, newPincodeListener, newPincodeRetryListener, Widget::requestFocus(), Widget::setActionEventId(), Net::CharServerHandler::setNewPincode(), and ShowCenter_true.

Referenced by NewPincodeListener::action().

◆ setPincodeLockFlag()

void PincodeManager::setPincodeLockFlag ( const bool  flag)
inline

◆ setSeed()

void PincodeManager::setSeed ( const uint32_t  seed)
inline

Definition at line 55 of file pincodemanager.h.

56  { mSeed = seed; }

References mSeed.

Referenced by EAthena::CharServerRecv::processPincodeStatus(), and EAthena::CharServerRecv::processPincodeStatus2().

◆ setState()

void PincodeManager::setState ( const PincodeStateT  state)
inline

Definition at line 61 of file pincodemanager.h.

62  { mState = state; }

References mState.

Referenced by CharSelectDialog::action(), and processPincodeStatus().

◆ updateState()

void PincodeManager::updateState ( )

Definition at line 73 of file pincodemanager.cpp.

74 {
75  switch (mState)
76  {
77  case PincodeState::Ask:
79  // TRANSLATORS: dialog caption
80  _("Pincode"),
81  // TRANSLATORS: dialog label
82  _("Enter pincode"),
83  mSeed,
84  nullptr);
88  break;
90  mNewPincode.clear();
92  // TRANSLATORS: dialog caption
93  _("New pincode"),
94  // TRANSLATORS: dialog label
95  _("Enter new pincode"),
96  mSeed,
97  nullptr);
101  break;
103  mOldPincode.clear();
104  mNewPincode.clear();
106  // TRANSLATORS: dialog caption
107  _("Change pincode"),
108  // TRANSLATORS: dialog label
109  _("Enter old pincode"),
110  mSeed,
111  nullptr);
113  mDialog->setActionEventId("ok");
115  break;
116  case PincodeState::None:
117  default:
118  break;
119  }
120 }
PincodeListener pincodeListener

References _, Widget::addActionListener(), PincodeState::Ask, PincodeState::Change, changePincodeListener, PincodeState::Create, CREATEWIDGETV, mDialog, mNewPincode, mOldPincode, mSeed, mState, newPincodeListener, PincodeState::None, pincodeListener, Widget::requestFocus(), and Widget::setActionEventId().

Referenced by CharSelectDialog::action(), NewPincodeRetryListener::action(), lockedPin(), and wrongPin().

◆ wrongPin()

void PincodeManager::wrongPin ( )

Definition at line 248 of file pincodemanager.cpp.

249 {
251  updateState();
252 }

References PincodeState::Ask, mState, and updateState().

Referenced by processPincodeStatus().

Field Documentation

◆ mAccountId

BeingId PincodeManager::mAccountId
protected

Definition at line 85 of file pincodemanager.h.

Referenced by changePincode(), init(), sendPincode(), setAccountId(), and setNewPincode().

◆ mDialog

Window* PincodeManager::mDialog
protected

Definition at line 86 of file pincodemanager.h.

Referenced by changePincode(), clearDialog(), closeDialogs(), setNewPincode(), and updateState().

◆ mLockFlag

bool PincodeManager::mLockFlag
protected

Definition at line 88 of file pincodemanager.h.

Referenced by processPincodeStatus(), and setPincodeLockFlag().

◆ mNewPincode

std::string PincodeManager::mNewPincode
protected

Definition at line 83 of file pincodemanager.h.

Referenced by changePincode(), init(), setNewPincode(), and updateState().

◆ mOldPincode

std::string PincodeManager::mOldPincode
protected

Definition at line 82 of file pincodemanager.h.

Referenced by changePincode(), and updateState().

◆ mSeed

uint32_t PincodeManager::mSeed
protected

Definition at line 84 of file pincodemanager.h.

Referenced by changePincode(), init(), setNewPincode(), setSeed(), and updateState().

◆ mState

PincodeStateT PincodeManager::mState
protected

Definition at line 87 of file pincodemanager.h.

Referenced by init(), isBlocked(), lockedPin(), pinOk(), setState(), updateState(), and wrongPin().


The documentation for this class was generated from the following files: