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

yapet/passwordrecord.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 //
00003 // $Id: passwordrecord.h 3342 2010-09-17 18:32:00Z 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 _PASSWORDRECORD_H
00024 #define _PASSWORDRECORD_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 #include "key.h"
00046 #include "partdec.h"
00047 
00048 #include "basewindow.h"
00049 #include "button.h"
00050 #include "passwordwidget.h"
00051 #ifdef ENABLE_PWGEN
00052 # include "pwgendialog.h"
00053 #endif
00054 
00076 class PasswordRecord : protected YAPET::UI::BaseWindow {
00077     private:
00078         enum {
00079             HEIGHT = 14
00080         };
00081 
00082         WINDOW* window;
00083         YAPET::UI::InputWidget* name;
00084         YAPET::UI::InputWidget* host;
00085         YAPET::UI::InputWidget* username;
00086         YAPET::UI::InputWidget* password;
00087         YAPET::UI::InputWidget* comment;
00088         YAPET::UI::Button* okbutton;
00089         YAPET::UI::Button* cancelbutton;
00090 #ifdef ENABLE_PWGEN
00091         YAPET::UI::Button* pwgenbutton;
00092 #endif
00093         YAPET::Key* key;
00094         YAPET::PartDec* encentry;
00095         YAPET::UI::secstring s_name;
00096         YAPET::UI::secstring s_host;
00097         YAPET::UI::secstring s_username;
00098         YAPET::UI::secstring s_password;
00099         YAPET::UI::secstring s_comment;
00100         bool namechanged;
00101         bool hostchanged;
00102         bool usernamechanged;
00103         bool passwordchanged;
00104         bool commentchanged;
00105     bool readonly;
00106 
00107         inline PasswordRecord (const PasswordRecord&) {}
00108         inline const PasswordRecord& operator= (const PasswordRecord&) {
00109             return *this;
00110         }
00111 
00112     protected:
00113 
00114         inline int getWidth() const {
00115             return maxX() - 8;
00116         }
00117 
00118         inline int getHeight() const {
00119             return HEIGHT;
00120         }
00121 
00122         inline int getStartX() const {
00123             return maxX() / 2 - getWidth() / 2;
00124         }
00125 
00126         inline int getStartY() const {
00127             return maxY() / 2 - getHeight() / 2;
00128         }
00129 
00130         void createWindow() throw (YAPET::UI::UIException);
00131 
00133         bool sureToCancel() throw (YAPET::UI::UIException);
00134 
00135     public:
00148         PasswordRecord (YAPET::Key& k, YAPET::PartDec* pe, bool ro = false) throw (YAPET::UI::UIException);
00149         ~PasswordRecord();
00150 
00158         void run() throw (YAPET::UI::UIException);
00159         void resize() throw (YAPET::UI::UIException);
00160         void refresh() throw (YAPET::UI::UIException);
00173         inline YAPET::PartDec* getEncEntry() const {
00174             return encentry;
00175         }
00176 
00184         bool entryChanged() const;
00185 
00186     void setReadonly(bool ro);
00187 
00188     inline bool getReadonly() const { return readonly; }
00189 };
00190 
00191 #endif // _PASSWORDRECORD_H

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