Diff of /src/ui/wxWidgets/safecombinationsetup.cpp [28f2ff] .. [6af072]  Maximize  Restore

Switch to side-by-side view

--- a/src/ui/wxWidgets/safecombinationsetup.cpp
+++ b/src/ui/wxWidgets/safecombinationsetup.cpp
@@ -35,6 +35,7 @@
 #endif
 
 ////@begin XPM images
+#include "graphics/Yubikey-button.xpm"
 ////@end XPM images
 
 
@@ -52,12 +53,14 @@
 BEGIN_EVENT_TABLE( CSafeCombinationSetup, wxDialog )
 
 ////@begin CSafeCombinationSetup event table entries
+  EVT_BUTTON( ID_YUBIBTN, CSafeCombinationSetup::OnYubibtnClick )
+
   EVT_BUTTON( wxID_OK, CSafeCombinationSetup::OnOkClick )
 
   EVT_BUTTON( wxID_CANCEL, CSafeCombinationSetup::OnCancelClick )
 
 ////@end CSafeCombinationSetup event table entries
-
+EVT_TIMER(POLLING_TIMER_ID, CSafeCombinationSetup::OnPollingTimer)
 END_EVENT_TABLE()
 
 
@@ -94,6 +97,9 @@
   }
   Centre();
 ////@end CSafeCombinationSetup creation
+  SetupMixin(FindWindow(ID_YUBIBTN), FindWindow(ID_YUBISTATUS));
+  m_pollingTimer = new wxTimer(this, POLLING_TIMER_ID);
+  m_pollingTimer->Start(250); // check for Yubikey every 250ms.
   return true;
 }
 
@@ -106,6 +112,7 @@
 {
 ////@begin CSafeCombinationSetup destruction
 ////@end CSafeCombinationSetup destruction
+  delete m_pollingTimer;
 }
 
 
@@ -116,6 +123,8 @@
 void CSafeCombinationSetup::Init()
 {
 ////@begin CSafeCombinationSetup member initialisation
+  m_YubiBtn = NULL;
+  m_yubiStatusCtrl = NULL;
 ////@end CSafeCombinationSetup member initialisation
 }
 
@@ -130,6 +139,7 @@
   CSafeCombinationSetup* itemDialog1 = this;
 
   wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
+  itemDialog1->SetSizer(itemBoxSizer2);
 
   wxStaticText* itemStaticText3 = new wxStaticText( itemDialog1, wxID_STATIC, _("A new password database will be created.\nThe safe combination will be used to encrypt the password database file.\nYou can use any keyboard character. The combination is case-sensitive."), wxDefaultPosition, wxDefaultSize, 0 );
   itemBoxSizer2->Add(itemStaticText3, 0, wxALIGN_LEFT|wxALL, 5);
@@ -149,14 +159,26 @@
   wxTextCtrl* itemTextCtrl8 = new wxTextCtrl( itemDialog1, ID_VERIFY, wxEmptyString, wxDefaultPosition, wxSize(itemDialog1->ConvertDialogToPixels(wxSize(120, -1)).x, -1), wxTE_PASSWORD );
   itemGridSizer4->Add(itemTextCtrl8, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
 
-  wxStdDialogButtonSizer* sizer = CreateStdDialogButtonSizer(wxOK|wxCANCEL|wxHELP);
-  sizer->Add(new ExternalKeyboardButton(itemDialog1), wxSizerFlags().Border(wxLEFT));
-  itemBoxSizer2->Add(sizer, wxSizerFlags().Border().Expand().Proportion(0));
-
-  SetSizerAndFit(itemBoxSizer2);
-
-  FindWindowById(ID_PASSWORD)->SetFocus();
-  
+  m_YubiBtn = new wxBitmapButton( itemDialog1, ID_YUBIBTN, itemDialog1->GetBitmapResource(wxT("graphics/Yubikey-button.xpm")), wxDefaultPosition, itemDialog1->ConvertDialogToPixels(wxSize(40, 15)), wxBU_AUTODRAW );
+  itemGridSizer4->Add(m_YubiBtn, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM|wxSHAPED, 5);
+
+  m_yubiStatusCtrl = new wxStaticText( itemDialog1, ID_YUBISTATUS, _("Please insert your YubiKey"), wxDefaultPosition, wxDefaultSize, 0 );
+  itemGridSizer4->Add(m_yubiStatusCtrl, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
+
+  wxStdDialogButtonSizer* itemStdDialogButtonSizer11 = new wxStdDialogButtonSizer;
+
+  itemBoxSizer2->Add(itemStdDialogButtonSizer11, 0, wxALIGN_LEFT|wxALL, 5);
+  wxButton* itemButton12 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
+  itemStdDialogButtonSizer11->AddButton(itemButton12);
+
+  wxButton* itemButton13 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
+  itemStdDialogButtonSizer11->AddButton(itemButton13);
+
+  wxButton* itemButton14 = new wxButton( itemDialog1, wxID_HELP, _("&Help"), wxDefaultPosition, wxDefaultSize, 0 );
+  itemStdDialogButtonSizer11->AddButton(itemButton14);
+
+  itemStdDialogButtonSizer11->Realize();
+
   // Set validators
   itemTextCtrl6->SetValidator( wxGenericValidator(& m_password) );
   itemTextCtrl8->SetValidator( wxGenericValidator(& m_verify) );
@@ -182,6 +204,11 @@
   // Bitmap retrieval
 ////@begin CSafeCombinationSetup bitmap retrieval
   wxUnusedVar(name);
+  if (name == _T("graphics/Yubikey-button.xpm"))
+  {
+    wxBitmap bitmap(Yubikey_button_xpm);
+    return bitmap;
+  }
   return wxNullBitmap;
 ////@end CSafeCombinationSetup bitmap retrieval
 }
@@ -265,3 +292,32 @@
   event.Skip();
 ////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in CSafeCombinationSetup.
 }
+
+void CSafeCombinationSetup::OnPollingTimer(wxTimerEvent &evt)
+{
+  if (evt.GetId() == POLLING_TIMER_ID) {
+    HandlePollingTimer(); // in CYubiMixin
+  }
+}
+
+
+/*!
+ * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_YUBIBTN
+ */
+
+void CSafeCombinationSetup::OnYubibtnClick( wxCommandEvent& /* event */ )
+{
+  if (Validate() && TransferDataFromWindow()) {
+    if (m_password != m_verify) {
+      wxMessageDialog err(this, _("The two entries do not match."),
+                          _("Error"), wxOK | wxICON_EXCLAMATION);
+      err.ShowModal();
+      return;
+    }
+    StringX response;
+    if (PerformChallengeResponse(m_password.c_str(), response)) {
+      m_password = response.c_str();
+      EndModal(wxID_OK);
+    }
+  }
+}

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks