#include <wx/wx.h>
#include <wx/image.h>
#include <wx/hyperlink.h>
#include <wx/spinctrl.h>
#include <wx/statline.h>
#include <wx/listctrl.h>
#include <vector>
#ifndef WPASSGEN_H
#define WPASSGEN_H
class WPassGen : public wxDialog
{
public:
enum {
myID_PRESET = wxID_HIGHEST + 1000,
myID_PRESET_ADD = wxID_HIGHEST + 1002,
myID_PRESET_REMOVE = wxID_HIGHEST + 1004,
myID_TYPE = wxID_HIGHEST + 1006,
myID_SKIPSIMILARCHAR = wxID_HIGHEST + 1008,
myID_SKIPSWAPPEDCHAR = wxID_HIGHEST + 1010,
myID_TEXT_EXTRACHAR = wxID_HIGHEST + 1012,
myID_LENGTH = wxID_HIGHEST + 1014,
myID_NUMBER = wxID_HIGHEST + 1016,
myID_ENUMERATE = wxID_HIGHEST + 1018,
myID_GENERATE = wxID_HIGHEST + 1020,
myID_PASSLIST = wxID_HIGHEST + 1022
};
WPassGen(wxWindow* parent, bool standalone, int id=wxID_ANY, const wxString& title=wxEmptyString, const wxPoint& pos=wxDefaultPosition, const wxSize& size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE);
bool standalone;
enum pass_type {
PT_ALPHANUMERICSYMBOL,
PT_ALPHANUMERIC,
PT_ALPHA,
PT_ALPHALOWER,
PT_PRONOUNCEABLE,
PT_ALPHAUPPER,
PT_HEXADECIMAL,
PT_NUMERIC,
PT_PORTNUMBER,
PT_LAST = PT_PORTNUMBER
};
struct Preset
{
wxString name;
pass_type type;
bool skip_similar;
bool skip_swapped;
wxString extrachar;
int length;
Preset() {}
Preset(const wxString& _name, pass_type _type,
bool _skip_similar, bool _skip_swapped,
const wxString& _extrachar, int _length)
: name(_name), type(_type),
skip_similar(_skip_similar), skip_swapped(_skip_swapped),
extrachar(_extrachar),
length(_length)
{}
bool operator==(const Preset& o) const
{
return (name == o.name)
&& (type == o.type)
&& (skip_similar == o.skip_similar)
&& (skip_swapped == o.skip_swapped)
&& (extrachar == o.extrachar)
&& (length == o.length);
}
};
typedef std::vector<Preset> presetlist_type;
std::vector<Preset> presetlist;
public:
wxArrayString GetSelectedPassword() const;
static const std::vector<Preset>& GetDefaultPresets();
void LoadDefaultSettings();
void LoadSettings(class wxConfigBase* cfg);
void SaveSettings(class wxConfigBase* cfg);
protected:
void ResetPresetChoice();
void UpdateKeyStrength();
void UpdateCheckboxes();
void GenerateList();
bool IsAllowedSimilar() const;
bool IsAllowedSwapped() const;
bool IsAllowedExtraChar() const;
bool IsAllowedLength() const;
public:
static const wxChar* GetTypeName(pass_type pt);
static const wxChar* GetType0Letters(pass_type pt, bool skip_similar, bool skip_swapped);
static wxString GetType0LettersExtra(const Preset& preset);
static wxString MakePasswordType0(unsigned int len, const wxString& letters);
static float GetTypeKeybits(const Preset& preset);
static wxString MakePassword(const Preset& preset);
private:
void set_properties();
void do_layout();
protected:
wxStaticBox* sizer2_staticbox;
wxChoice* choicePreset;
wxBitmapButton* buttonPresetAdd;
wxBitmapButton* buttonPresetRemove;
wxChoice* choiceType;
wxCheckBox* checkboxSkipSimilarChar;
wxCheckBox* checkboxSkipSwappedChar;
wxTextCtrl* textctrlExtraChar;
wxSpinCtrl* spinctrlLength;
wxTextCtrl* textctrlStrength;
wxSpinCtrl* spinctrlNumber;
wxCheckBox* checkboxEnumerate;
wxButton* buttonGenerate;
wxListCtrl* listctrlPasslist;
wxTextCtrl* textctrlPasslist;
wxButton* buttonOK;
wxButton* buttonCancel;
wxButton* buttonAbout;
wxButton* buttonClose;
DECLARE_EVENT_TABLE();
public:
void OnClose(wxCloseEvent& event);
void OnChoicePreset(wxCommandEvent &event);
void OnChoiceType(wxCommandEvent &event);
void OnCheckSkipSimilarChar(wxCommandEvent &event);
void OnCheckSkipSwappedChar(wxCommandEvent &event);
void OnTextExtraCharChange(wxCommandEvent &event);
void OnSpinLength(wxSpinEvent &event);
void OnSpinNumber(wxSpinEvent &event);
void OnCheckEnumerate(wxCommandEvent &event);
void OnButtonGenerate(wxCommandEvent &event);
void OnPasslistSelected(wxListEvent &event);
void OnPasslistActivated(wxListEvent &event);
void OnButtonOK(wxCommandEvent &event);
void OnButtonCancel(wxCommandEvent &event);
void OnButtonClose(wxCommandEvent &event);
void OnButtonAbout(wxCommandEvent &event);
void OnButtonPresetAdd(wxCommandEvent &event);
void OnButtonPresetRemove(wxCommandEvent &event);
};
class PGWAbout : public wxDialog
{
public:
PGWAbout(wxWindow* parent, int id=wxID_ANY, const wxString& title=wxEmptyString, const wxPoint& pos=wxDefaultPosition, const wxSize& size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE);
private:
void set_properties();
void do_layout();
protected:
wxStaticBitmap* bitmapIcon;
wxStaticBitmap* bitmapWeb;
wxHyperlinkCtrl* hyperlink1;
wxButton* buttonOK;
};
#endif