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

yapet/passworddialog.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 //
00003 // $Id: passworddialog.h 3350 2010-09-17 21:54:13Z java $
00004 //
00005 // Copyright (C) 2008-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 _PASSWORDDIALOG_H
00024 #define _PASSWORDDIALOG_H
00025 
00026 #ifdef HAVE_CONFIG_H
00027 # include <config.h>
00028 #endif
00029 
00030 #ifdef HAVE_NCURSES_H
00031 # include <ncurses.h>
00032 #else // HAVE_NCURSES_H
00033 # ifdef HAVE_CURSES_H
00034 #  include <curses.h>
00035 # else
00036 #  error "Neither curses.h nor ncurses.h available"
00037 # endif // HAVE_CURSES_H
00038 #endif // HAVE_NCURSES_H
00039 #include "curswa.h" // Leave this here. It depends on the above includes.
00040 
00041 #ifdef HAVE_STRING
00042 # include <string>
00043 #endif
00044 
00045 #ifdef HAVE_SIGNAL_H
00046 # include <signal.h>
00047 #endif
00048 
00049 #include <key.h>
00050 
00051 #include <basewindow.h>
00052 #include <button.h>
00053 #include <passwordwidget.h>
00054 
00061 enum PWTYPE {
00066     NEW_PW,
00070     EXISTING_PW
00071 };
00072 
00086 class PasswordDialog : protected YAPET::UI::BaseWindow {
00087     private:
00088         enum {
00089             HEIGHT_NEW = 9,
00090             HEIGHT_EX = 7
00091         };
00092 
00093         WINDOW* window;
00094         YAPET::UI::PasswordWidget* pwidget1;
00095         YAPET::UI::PasswordWidget* pwidget2;
00096         YAPET::UI::Button* okbutton;
00097         YAPET::UI::Button* cancelbutton;
00098     YAPET::UI::Button* quitbutton;
00099         PWTYPE pwtype;
00100         YAPET::Key* key;
00101 
00102         std::string filename;
00103     unsigned int input_timeout;
00104     bool has_quitbutton;
00105     bool quit_pressed;
00106 
00107     // For timeout stuff
00108     sigset_t my_sigset;
00109     sigset_t old_sigset;
00110     struct sigaction my_sigaction;
00111     struct sigaction old_sigaction;
00112     
00113         inline PasswordDialog (const PasswordDialog&) {}
00114         inline const PasswordDialog& operator= (const PasswordDialog&) {
00115             return *this;
00116         }
00117 
00118         inline int getWidth() const {
00119             return maxX() - 8;
00120         }
00121 
00122         inline int getHeight() const {
00123             if (pwtype == NEW_PW)
00124                 return HEIGHT_NEW;
00125             else
00126                 return HEIGHT_EX;
00127         }
00128 
00129         inline int getStartX() const {
00130             return maxX() / 2 - getWidth() / 2;
00131         }
00132 
00133         inline int getStartY() const {
00134             return maxY() / 2 - getHeight() / 2;
00135         }
00136 
00137         void createWindow() throw (YAPET::UI::UIException);
00138 
00139     inline void quitPressed(bool b) { quit_pressed = b; }
00140 
00141     public:
00160         PasswordDialog (PWTYPE pt, std::string fn, unsigned int tout = 0, bool qb = false) throw (YAPET::UI::UIException);
00161         ~PasswordDialog();
00162 
00169         void run() throw (YAPET::UI::UIException);
00184         YAPET::Key* getKey() const {
00185             return key;
00186         }
00187         void resize() throw (YAPET::UI::UIException);
00188         void refresh() throw (YAPET::UI::UIException);
00189 
00190     inline bool wantsQuit() const { return quit_pressed; }
00191 };
00192 
00193 #endif // _PASSWORDDIALOG_H

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