00001 // -*- c++ -*- 00002 // 00003 // $Id: passwordrecord.h 2360 2009-06-11 15:06:24Z rafi $ 00004 // 00005 // Copyright (C) 2008, 2009 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 00073 class PasswordRecord : protected YAPETUI::BaseWindow { 00074 private: 00075 enum { 00076 HEIGHT = 14 00077 }; 00078 00079 WINDOW* window; 00080 YAPETUI::InputWidget* name; 00081 YAPETUI::InputWidget* host; 00082 YAPETUI::InputWidget* username; 00083 YAPETUI::InputWidget* password; 00084 YAPETUI::InputWidget* comment; 00085 YAPETUI::Button* okbutton; 00086 YAPETUI::Button* cancelbutton; 00087 YAPET::Key* key; 00088 YAPET::PartDec* encentry; 00089 00090 inline PasswordRecord(const PasswordRecord&) {} 00091 inline const PasswordRecord& operator=(const PasswordRecord&) { return *this; } 00092 00093 inline int getWidth() const { 00094 return maxX() - 8; 00095 } 00096 00097 inline int getHeight() const { 00098 return HEIGHT; 00099 } 00100 00101 inline int getStartX() const { 00102 return maxX()/2 - getWidth()/2; 00103 } 00104 00105 inline int getStartY() const { 00106 return maxY()/2 - getHeight()/2; 00107 } 00108 00109 void createWindow() throw(YAPETUI::UIException); 00110 00111 public: 00124 PasswordRecord(YAPET::Key& k, YAPET::PartDec* pe) throw(YAPETUI::UIException); 00125 ~PasswordRecord(); 00126 00134 void run() throw(YAPETUI::UIException); 00135 void resize() throw(YAPETUI::UIException); 00136 void refresh() throw(YAPETUI::UIException); 00149 inline YAPET::PartDec* getEncEntry() const { return encentry; } 00150 00158 inline bool entryChanged() const { 00159 return name->isTextChanged() || 00160 host->isTextChanged() || 00161 username->isTextChanged() || 00162 password->isTextChanged() || 00163 comment->isTextChanged(); 00164 } 00165 00166 }; 00167 00168 #endif // _PASSWORDRECORD_H