• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

yapet/pwgendialog.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 //
00003 // $Id: pwgendialog.h 3343 2010-09-17 18:36:31Z java $
00004 //
00005 // Copyright (C) 2009-2010  Rafael Ostertag
00006 //
00007 // This file is part of YAPET.
00008 //
00009 // YAPET is free software: you can redistribute it and/or modify it under the
00010 // terms of the GNU General Public License as published by the Free Software
00011 // Foundation, either version 3 of the License, or (at your option) any later
00012 // version.
00013 //
00014 // YAPET is distributed in the hope that it will be useful, but WITHOUT ANY
00015 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00016 // FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
00017 // details.
00018 //
00019 // You should have received a copy of the GNU General Public License along with
00020 // YAPET.  If not, see <http://www.gnu.org/licenses/>.
00021 //
00022 
00023 #ifndef _PWGENDIALOG_H
00024 #define _PWGENDIALOG_H
00025 
00026 #ifdef HAVE_CONFIG_H
00027 # include <config.h>
00028 #endif
00029 
00030 #ifndef ENABLE_PWGEN
00031 # error "This file must only be included with ENABLE_PWGEN defined in config.h"
00032 #endif
00033 
00034 #ifdef HAVE_NCURSES_H
00035 # include <ncurses.h>
00036 #else // HAVE_NCURSES_H
00037 # ifdef HAVE_CURSES_H
00038 #  include <curses.h>
00039 # else
00040 #  error "Neither curses.h nor ncurses.h available"
00041 # endif // HAVE_CURSES_H
00042 #endif // HAVE_NCURSES_H
00043 #include "curswa.h" // Leave this here. It depends on the above includes.
00044 
00045 #ifdef HAVE_SYS_TYPES_H
00046 # include <sys/types.h>
00047 #endif
00048 
00049 #ifdef HAVE_VECTOR
00050 # include <vector>
00051 #endif
00052 
00053 #ifdef HAVE_STRING
00054 # include <string>
00055 #endif
00056 
00057 #include "secstring.h"
00058 #include "basewindow.h"
00059 #include "button.h"
00060 #include "checkboxgroup.h"
00061 #include "intinwidget.h"
00062 #include "pwgen/pwgen.h"
00063 
00070 class PWGenDialog : protected YAPET::UI::BaseWindow {
00071     private:
00072         WINDOW* window;
00073         YAPET::UI::CheckBoxGroup* ckbxgroup;
00074         YAPET::UI::InputWidget* pwdisplay;
00075         YAPET::UI::IntInWidget* pwleninput;
00076         YAPET::UI::Button* regenbutton;
00077         YAPET::UI::Button* okbutton;
00078         YAPET::UI::Button* cancelbutton;
00079         YAPET::UI::secstring password;
00080         YAPET::PWGEN::PWGen pwgen;
00081         size_t pwlen;
00082         int ckbox_options;
00083         bool canceled;
00084 
00085         std::vector<std::string> ckbxitems;
00086 
00087         inline PWGenDialog (const PWGenDialog& bla) : pwgen (bla.ckbox_options) {
00088             assert (0);
00089         }
00090         inline const PWGenDialog& operator= (const PWGenDialog&) {
00091             return *this;
00092         }
00093 
00094         inline int windowWidth() {
00095             return maxX() - 8;
00096         }
00097 
00098         inline int windowHeight() {
00099             // This window is static. Since we do not let the mainwindow be
00100             // smaller than 80x24, we can use a hardcoded value
00101             return 14;
00102             // return maxY() - 4;
00103         }
00104 
00105         inline int startX() {
00106             return minX() + 4;
00107         }
00108 
00109         inline int startY() {
00110             return (maxY() - windowHeight() ) / 2;
00111         }
00112 
00113         std::string getNameOfRNG() const;
00114         int CheckBoxOptions2Charpools (uint16_t o) const;
00115 
00116         void initCheckBoxItems();
00117 
00118         void createWindow() throw (YAPET::UI::UIException);
00119 
00120         void printTitles() throw (YAPET::UI::UIException);
00121 
00122     public:
00127         PWGenDialog() throw (YAPET::UI::UIException);
00128         virtual ~PWGenDialog();
00129 
00130         void run() throw (YAPET::UI::UIException);
00131         void refresh() throw (YAPET::UI::UIException);
00132 
00133         void resize() throw (YAPET::UI::UIException);
00134 
00135         inline const YAPET::UI::secstring& getPassword() {
00136             return password;
00137         }
00138 
00139         inline bool isCanceled() const {
00140             return canceled;
00141         }
00142 };
00143 
00144 #endif // _PWGENDIALOG_H

Generated on Sun Sep 19 2010 15:37:14 for YAPET by  doxygen 1.7.1