00001 // -*- c++ -*- 00002 // 00003 // $Id: passwordrecord.h 1203 2008-02-13 20:47:49Z rafi $ 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 _PASSWORDRECORD_H 00023 #define _PASSWORDRECORD_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 #include <partdec.h> 00046 00047 #include <basewindow.h> 00048 #include <button.h> 00049 #include <passwordwidget.h> 00050 00072 class PasswordRecord : protected YAPETUI::BaseWindow { 00073 private: 00074 enum { 00075 HEIGHT = 14 00076 }; 00077 00078 WINDOW* window; 00079 YAPETUI::InputWidget* name; 00080 YAPETUI::InputWidget* host; 00081 YAPETUI::InputWidget* username; 00082 YAPETUI::InputWidget* password; 00083 YAPETUI::InputWidget* comment; 00084 YAPETUI::Button* okbutton; 00085 YAPETUI::Button* cancelbutton; 00086 YAPET::Key* key; 00087 YAPET::PartDec* encentry; 00088 00089 inline PasswordRecord(const PasswordRecord&) {} 00090 inline const PasswordRecord& operator=(const PasswordRecord&) { return *this; } 00091 00092 inline int getWidth() const { 00093 return maxX() - 8; 00094 } 00095 00096 inline int getHeight() const { 00097 return HEIGHT; 00098 } 00099 00100 inline int getStartX() const { 00101 return maxX()/2 - getWidth()/2; 00102 } 00103 00104 inline int getStartY() const { 00105 return maxY()/2 - getHeight()/2; 00106 } 00107 00108 void createWindow() throw(YAPETUI::UIException); 00109 00110 public: 00123 PasswordRecord(YAPET::Key& k, YAPET::PartDec* pe) throw(YAPETUI::UIException); 00124 ~PasswordRecord(); 00125 00133 void run() throw(YAPETUI::UIException); 00134 void resize() throw(YAPETUI::UIException); 00135 void refresh() throw(YAPETUI::UIException); 00148 inline YAPET::PartDec* getEncEntry() const { return encentry; } 00149 00157 inline bool entryChanged() const { 00158 return name->isTextChanged() || 00159 host->isTextChanged() || 00160 username->isTextChanged() || 00161 password->isTextChanged() || 00162 comment->isTextChanged(); 00163 } 00164 00165 }; 00166 00167 #endif // _PASSWORDRECORD_H