yapet/passworddialog.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 //
00003 // $Id: passworddialog.h,v 1.6 2008-02-13 20:47:48 rafi Exp $
00004 //
00005 // YAPET -- Yet Another Password Encryption Tool
00006 // Copyright (C) 2008  Rafael Ostertag
00007 //
00008 // This program is free software: you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation, either version 3 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
00020 //
00021 
00022 #ifndef _PASSWORDDIALOG_H
00023 #define _PASSWORDDIALOG_H
00024 
00025 #ifdef HAVE_CONFIG_H
00026 # include <config.h>
00027 #endif
00028 
00029 #ifdef HAVE_NCURSES_H
00030 # include <ncurses.h>
00031 #else // HAVE_NCURSES_H
00032 # ifdef HAVE_CURSES_H
00033 #  include <curses.h>
00034 # else
00035 #  error "Neither curses.h nor ncurses.h available"
00036 # endif // HAVE_CURSES_H
00037 #endif // HAVE_NCURSES_H
00038 #include "curswa.h" // Leave this here. It depends on the above includes.
00039 
00040 #ifdef HAVE_STRING
00041 # include <string>
00042 #endif
00043 
00044 #include <key.h>
00045 
00046 #include <basewindow.h>
00047 #include <button.h>
00048 #include <passwordwidget.h>
00049 
00056 enum PWTYPE {
00061     NEW_PW,
00065     EXISTING_PW
00066 };
00067 
00081 class PasswordDialog : protected YAPETUI::BaseWindow {
00082     private:
00083     enum {
00084         HEIGHT_NEW = 9,
00085         HEIGHT_EX = 7
00086     };
00087 
00088     WINDOW* window;
00089     YAPETUI::PasswordWidget* pwidget1;
00090     YAPETUI::PasswordWidget* pwidget2;
00091     YAPETUI::Button* okbutton;
00092     YAPETUI::Button* cancelbutton;
00093     PWTYPE pwtype;
00094     YAPET::Key* key;
00095 
00096     std::string filename;
00097 
00098     inline PasswordDialog(const PasswordDialog&) {}
00099     inline const PasswordDialog& operator=(const PasswordDialog&) { return *this; }
00100 
00101     inline int getWidth() const {
00102         return maxX() - 8;
00103     }
00104 
00105     inline int getHeight() const {
00106         if (pwtype == NEW_PW)
00107         return HEIGHT_NEW;
00108         else
00109         return HEIGHT_EX;
00110     }
00111 
00112     inline int getStartX() const {
00113         return maxX()/2 - getWidth()/2;
00114     }
00115 
00116     inline int getStartY() const {
00117         return maxY()/2 - getHeight()/2;
00118     }
00119 
00120     void createWindow() throw(YAPETUI::UIException);
00121 
00122     public:
00135     PasswordDialog(PWTYPE pt, std::string fn) throw(YAPETUI::UIException);
00136     ~PasswordDialog();
00137 
00144     void run() throw(YAPETUI::UIException);
00159     YAPET::Key* getKey() const { return key; }
00160     void resize() throw(YAPETUI::UIException);
00161     void refresh() throw(YAPETUI::UIException);
00162 };
00163 
00164 #endif // _PASSWORDDIALOG_H

Generated on Wed Feb 27 16:15:42 2008 for YAPET by  doxygen 1.5.4