summaryrefslogtreecommitdiffabout
path: root/pwmanager
Unidiff
Diffstat (limited to 'pwmanager') (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/main.cpp2
-rw-r--r--pwmanager/pwmanager/pwm.cpp2
2 files changed, 3 insertions, 1 deletions
diff --git a/pwmanager/pwmanager/main.cpp b/pwmanager/pwmanager/main.cpp
index 3f2d055..81e257f 100644
--- a/pwmanager/pwmanager/main.cpp
+++ b/pwmanager/pwmanager/main.cpp
@@ -1,213 +1,213 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2003, 2004 by Michael Buesch * 3 * copyright (C) 2003, 2004 by Michael Buesch *
4 * email: mbuesch@freenet.de * 4 * email: mbuesch@freenet.de *
5 * * 5 * *
6 * This program is free software; you can redistribute it and/or modify * 6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License version 2 * 7 * it under the terms of the GNU General Public License version 2 *
8 * as published by the Free Software Foundation. * 8 * as published by the Free Software Foundation. *
9 * * 9 * *
10 ***************************************************************************/ 10 ***************************************************************************/
11 11
12/*************************************************************************** 12/***************************************************************************
13 * copyright (C) 2004 by Ulf Schenk 13 * copyright (C) 2004 by Ulf Schenk
14 * This file is originaly based on version 1.0.1 of pwmanager 14 * This file is originaly based on version 1.0.1 of pwmanager
15 * and was modified to run on embedded devices that run microkde 15 * and was modified to run on embedded devices that run microkde
16 * 16 *
17 * $Id$ 17 * $Id$
18 **************************************************************************/ 18 **************************************************************************/
19 19
20#ifndef PWM_EMBEDDED 20#ifndef PWM_EMBEDDED
21#include <kcmdlineargs.h> 21#include <kcmdlineargs.h>
22#include <kaboutdata.h> 22#include <kaboutdata.h>
23#else 23#else
24#include <qdir.h> 24#include <qdir.h>
25#include <kpimglobalprefs.h> 25#include <kpimglobalprefs.h>
26#endif 26#endif
27 27
28#include <klocale.h> 28#include <klocale.h>
29#include <kstandarddirs.h> 29#include <kstandarddirs.h>
30 30
31#include "pwmexception.h" 31#include "pwmexception.h"
32#include "pwminit.h" 32#include "pwminit.h"
33 33
34 #define LICENSE_FILE(::locate("data", "pwmanager/pwmanager_license_text")) 34 #define LICENSE_FILE(::locate("data", "pwmanager/pwmanager_license_text"))
35 35
36int PwMApplication::newInstance() 36int PwMApplication::newInstance()
37{ 37{
38 static bool initial = true; 38 static bool initial = true;
39 if (initial) { 39 if (initial) {
40 initial = false; 40 initial = false;
41 init = new PwMInit(this); 41 init = new PwMInit(this);
42 init->initializeApp(); 42 init->initializeApp();
43 } else { 43 } else {
44 BUG_ON(!init); 44 BUG_ON(!init);
45 printInfo("passing parameters to old instance."); 45 printInfo("passing parameters to old instance.");
46 init->handleCmdLineArgs(false); 46 init->handleCmdLineArgs(false);
47 } 47 }
48 return EXIT_SUCCESS; 48 return EXIT_SUCCESS;
49} 49}
50 50
51 51
52static const char *description = I18N_NOOP("PwManager\n" 52static const char *description = I18N_NOOP("PwManager\n"
53 "The convenient way of managing passwords"); 53 "The convenient way of managing passwords");
54 54
55#ifndef PWM_EMBEDDED 55#ifndef PWM_EMBEDDED
56static KCmdLineOptions options[] = 56static KCmdLineOptions options[] =
57{ 57{
58 { "minimized", I18N_NOOP("Windows minimized"), 0 }, 58 { "minimized", I18N_NOOP("Windows minimized"), 0 },
59 { "mintray", I18N_NOOP("Windows minimized to tray"),0 }, 59 { "mintray", I18N_NOOP("Windows minimized to tray"),0 },
60 { "open-deeplocked", I18N_NOOP("Open all \"files\" deeplocked"),0 }, 60 { "open-deeplocked", I18N_NOOP("Open all \"files\" deeplocked"),0 },
61 { "skip-self-test", I18N_NOOP("Don't run a self-test on startup"),0 }, 61 { "skip-self-test", I18N_NOOP("Don't run a self-test on startup"),0 },
62 { "+[files...]", I18N_NOOP("Files to open on startup"), 0 }, 62 { "+[files...]", I18N_NOOP("Files to open on startup"), 0 },
63 { 0, 0, 0 } 63 { 0, 0, 0 }
64}; 64};
65#endif 65#endif
66 66
67#ifdef PWM_DEBUG 67#ifdef PWM_DEBUG
68static void printDebugConfigureInfo() 68static void printDebugConfigureInfo()
69{ 69{
70 cout << "================================" << endl; 70 cout << "================================" << endl;
71 cout << PROG_NAME " version " PACKAGE_VER << endl; 71 cout << PROG_NAME " version " PACKAGE_VER << endl;
72#ifdef CONFIG_KEYCARD 72#ifdef CONFIG_KEYCARD
73 cout << "CONFIG_KEYCARD: enabled" << endl; 73 cout << "CONFIG_KEYCARD: enabled" << endl;
74#else 74#else
75 cout << "CONFIG_KEYCARD: disabled" << endl; 75 cout << "CONFIG_KEYCARD: disabled" << endl;
76#endif 76#endif
77#ifdef CONFIG_KWALLETIF 77#ifdef CONFIG_KWALLETIF
78 cout << "CONFIG_KWALLETIF: enabled" << endl; 78 cout << "CONFIG_KWALLETIF: enabled" << endl;
79#else 79#else
80 cout << "CONFIG_KWALLETIF: disabled" << endl; 80 cout << "CONFIG_KWALLETIF: disabled" << endl;
81#endif 81#endif
82#ifdef BIG_ENDIAN_HOST 82#ifdef BIG_ENDIAN_HOST
83 cout << "Endianess: big-endian" << endl; 83 cout << "Endianess: big-endian" << endl;
84#else 84#else
85 cout << "Endianess: little-endian" << endl; 85 cout << "Endianess: little-endian" << endl;
86#endif 86#endif
87 cout << "sizeof(long): " << sizeof(long) << endl; 87 cout << "sizeof(long): " << sizeof(long) << endl;
88 cout << "================================" << endl; 88 cout << "================================" << endl;
89} 89}
90#else // PWM_DEBUG 90#else // PWM_DEBUG
91static inline void printDebugConfigureInfo() { /* nothing */ } 91static inline void printDebugConfigureInfo() { /* nothing */ }
92#endif // PWM_DEBUG 92#endif // PWM_DEBUG
93 93
94#ifndef PWM_EMBEDDED 94#ifndef PWM_EMBEDDED
95static void addAuthors(KAboutData *aboutData) 95static void addAuthors(KAboutData *aboutData)
96{ 96{
97 aboutData->addAuthor("Michael Buesch", 97 aboutData->addAuthor("Michael Buesch",
98 I18N_NOOP( 98 I18N_NOOP(
99 "main programming and current maintainer"), 99 "main programming and current maintainer"),
100 "mbuesch@freenet.de"); 100 "mbuesch@freenet.de");
101 aboutData->addAuthor("Matt Scifo", 101 aboutData->addAuthor("Matt Scifo",
102 I18N_NOOP( 102 I18N_NOOP(
103 "original implementaion of \n" 103 "original implementaion of \n"
104 "\"categories\" and the password-tree \n" 104 "\"categories\" and the password-tree \n"
105 "in the system-tray. Original implementations of \n" 105 "in the system-tray. Original implementations of \n"
106 "numerous view-improvements."), 106 "numerous view-improvements."),
107 "mscifo@o1.com"); 107 "mscifo@o1.com");
108 aboutData->addCredit("Elias Probst", 108 aboutData->addCredit("Elias Probst",
109 I18N_NOOP( 109 I18N_NOOP(
110 "Gentoo ebuild maintainer."), 110 "Gentoo ebuild maintainer."),
111 "elias.probst@gmx.de"); 111 "elias.probst@gmx.de");
112 aboutData->addCredit("George Staikos", 112 aboutData->addCredit("George Staikos",
113 I18N_NOOP("KWallet"), 113 I18N_NOOP("KWallet"),
114 "staikos@kde.org"); 114 "staikos@kde.org");
115 aboutData->addCredit("Matthew Palmer", 115 aboutData->addCredit("Matthew Palmer",
116 I18N_NOOP("rc2 code"), 116 I18N_NOOP("rc2 code"),
117 "mjp16@uow.edu.au"); 117 "mjp16@uow.edu.au");
118 aboutData->addCredit("Olivier Sessink", 118 aboutData->addCredit("Olivier Sessink",
119 I18N_NOOP("gpasman"), 119 I18N_NOOP("gpasman"),
120 "gpasman@nl.linux.org"); 120 "gpasman@nl.linux.org");
121 aboutData->addCredit("The libgcrypt developers", 121 aboutData->addCredit("The libgcrypt developers",
122 I18N_NOOP("Blowfish and SHA1 algorithms"), 122 I18N_NOOP("Blowfish and SHA1 algorithms"),
123 0, "ftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/"); 123 0, "ftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/");
124 aboutData->addCredit("Troy Engel", 124 aboutData->addCredit("Troy Engel",
125 I18N_NOOP("kpasman"), 125 I18N_NOOP("kpasman"),
126 "tengel@sonic.net"); 126 "tengel@sonic.net");
127 aboutData->addCredit("Wickey", 127 aboutData->addCredit("Wickey",
128 I18N_NOOP("graphics-design in older versions."), 128 I18N_NOOP("graphics-design in older versions."),
129 "wickey@gmx.at"); 129 "wickey@gmx.at");
130 aboutData->addCredit("Ian MacGregor", 130 aboutData->addCredit("Ian MacGregor",
131 I18N_NOOP( 131 I18N_NOOP(
132 "original documentation author.")); 132 "original documentation author."));
133} 133}
134#endif 134#endif
135 135
136int main(int argc, char *argv[]) 136int main(int argc, char *argv[])
137{ 137{
138 printDebugConfigureInfo(); 138 printDebugConfigureInfo();
139#ifndef PWM_EMBEDDED 139#ifndef PWM_EMBEDDED
140 KAboutData aboutData(PACKAGE_NAME, PROG_NAME, 140 KAboutData aboutData(PACKAGE_NAME, PROG_NAME,
141 PACKAGE_VER, description, KAboutData::License_File, 141 PACKAGE_VER, description, KAboutData::License_File,
142 "(c) 2003, 2004 Michael Buesch and the PwManager Team", 0, 142 "(c) 2003, 2004 Michael Buesch and the PwManager Team", 0,
143 "http://passwordmanager.sourceforge.net/", 143 "http://passwordmanager.sourceforge.net/",
144 "mbuesch@freenet.de"); 144 "mbuesch@freenet.de");
145 addAuthors(&aboutData); 145 addAuthors(&aboutData);
146 146
147 KCmdLineArgs::init(argc, argv, &aboutData); 147 KCmdLineArgs::init(argc, argv, &aboutData);
148 KCmdLineArgs::addCmdLineOptions(options); 148 KCmdLineArgs::addCmdLineOptions(options);
149 149
150 KUniqueApplication::addCmdLineOptions(); 150 KUniqueApplication::addCmdLineOptions();
151 if (!KUniqueApplication::start()) { 151 if (!KUniqueApplication::start()) {
152 printInfo("already running."); 152 printInfo("already running.");
153 return EXIT_SUCCESS; 153 return EXIT_SUCCESS;
154 } 154 }
155 PwMApplication a; 155 PwMApplication a;
156 aboutData.setLicenseTextFile(LICENSE_FILE); 156 aboutData.setLicenseTextFile(LICENSE_FILE);
157 return a.exec(); 157 return a.exec();
158#else 158#else
159 159
160 bool exitHelp = false; 160 bool exitHelp = false;
161 if ( argc > 1 ) { 161 if ( argc > 1 ) {
162 QString command = argv[1]; 162 QString command = argv[1];
163 if ( command == "-help" ){ 163 if ( command == "-help" ){
164 printf("PWM/PI command line commands:\n"); 164 printf("PWM/PI command line commands:\n");
165 printf(" no command: Start PWM/PI in usual way\n"); 165 printf(" no command: Start PWM/PI in usual way\n");
166 printf(" -help: This output\n"); 166 printf(" -help: This output\n");
167 printf(" PWM/PI is exiting now. Bye!\n"); 167 printf(" PWM/PI is exiting now. Bye!\n");
168 exitHelp = true; 168 exitHelp = true;
169 } 169 }
170 } 170 }
171 if ( ! exitHelp ) { 171 if ( ! exitHelp ) {
172 172
173 PwMApplication a(argc, argv); 173 PwMApplication a(argc, argv);
174 174
175 KGlobal::setAppName( "pwmanager" ); 175 KGlobal::setAppName( "pwmanager" );
176#ifndef DESKTOP_VERSION 176#ifndef DESKTOP_VERSION
177 //qDebug("width %d ",QApplication::desktop()->width() ); 177 //qDebug("width %d ",QApplication::desktop()->width() );
178 if ( QApplication::desktop()->width() > 320 ) 178 if ( QApplication::desktop()->width() > 320 )
179 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons22/"); 179 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons22/");
180 else 180 else
181 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons16/"); 181 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons16/");
182#else 182#else
183 QString fileName ; 183 QString fileName ;
184 fileName = qApp->applicationDirPath () + "/kdepim/pwmanager/icons22/"; 184 fileName = qApp->applicationDirPath () + "/kdepim/pwmanager/icons22/";
185 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); 185 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName));
186 QApplication::addLibraryPath ( qApp->applicationDirPath () ); 186 QApplication::addLibraryPath ( qApp->applicationDirPath () );
187 187
188#endif 188#endif
189 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "pwmanager"))); 189 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "pwmanager")));
190 KPimGlobalPrefs::instance()->setGlobalConfig(); 190 KPimGlobalPrefs::instance()->setGlobalConfig();
191 191
192 a.newInstance(); 192 a.newInstance();
193 193
194 //US KAddressBookMain m ; 194 //US KAddressBookMain m ;
195 195
196 //US QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 196 //US QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
197 /*US 197 /*US
198#ifndef DESKTOP_VERSION 198#ifndef DESKTOP_VERSION
199 a.showMainWidget( &m ); 199 a.showMainWidget( &m );
200#else 200#else
201 a.setMainWidget( &m ); 201 a.setMainWidget( &m );
202 m.resize (640, 480 ); 202 m.resize (640, 480 );
203 m.show(); 203 m.show();
204#endif 204#endif
205 */ 205 */
206 a.exec(); 206 a.exec();
207 207 KPimGlobalPrefs::instance()->writeConfig();
208 } 208 }
209 qDebug("PWMPI: Bye! "); 209 qDebug("PWMPI: Bye! ");
210 210
211#endif 211#endif
212 212
213} 213}
diff --git a/pwmanager/pwmanager/pwm.cpp b/pwmanager/pwmanager/pwm.cpp
index b7b5307..d92c90d 100644
--- a/pwmanager/pwmanager/pwm.cpp
+++ b/pwmanager/pwmanager/pwm.cpp
@@ -1,1225 +1,1227 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2003, 2004 by Michael Buesch * 3 * copyright (C) 2003, 2004 by Michael Buesch *
4 * email: mbuesch@freenet.de * 4 * email: mbuesch@freenet.de *
5 * * 5 * *
6 * This program is free software; you can redistribute it and/or modify * 6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License version 2 * 7 * it under the terms of the GNU General Public License version 2 *
8 * as published by the Free Software Foundation. * 8 * as published by the Free Software Foundation. *
9 * * 9 * *
10 ***************************************************************************/ 10 ***************************************************************************/
11 11
12/*************************************************************************** 12/***************************************************************************
13 * copyright (C) 2004 by Ulf Schenk 13 * copyright (C) 2004 by Ulf Schenk
14 * This file is originaly based on version 1.0.1 of pwmanager 14 * This file is originaly based on version 1.0.1 of pwmanager
15 * and was modified to run on embedded devices that run microkde 15 * and was modified to run on embedded devices that run microkde
16 * 16 *
17 * $Id$ 17 * $Id$
18 **************************************************************************/ 18 **************************************************************************/
19 19
20#include <klocale.h> 20#include <klocale.h>
21#include <klistview.h> 21#include <klistview.h>
22#include <ktoolbar.h> 22#include <ktoolbar.h>
23#include <kfiledialog.h> 23#include <kfiledialog.h>
24#include <kiconloader.h> 24#include <kiconloader.h>
25#include <kmessagebox.h> 25#include <kmessagebox.h>
26 26
27#include <qstatusbar.h> 27#include <qstatusbar.h>
28 28
29#ifndef PWM_EMBEDDED 29#ifndef PWM_EMBEDDED
30#include <kmenubar.h> 30#include <kmenubar.h>
31#include <kstatusbar.h> 31#include <kstatusbar.h>
32#include <dcopclient.h> 32#include <dcopclient.h>
33#include "configwndimpl.h" 33#include "configwndimpl.h"
34#include "configuration.h" 34#include "configuration.h"
35#else 35#else
36#include <qmenubar.h> 36#include <qmenubar.h>
37#include <qmessagebox.h> 37#include <qmessagebox.h>
38#include <pwmprefs.h> 38#include <pwmprefs.h>
39#include <kpimglobalprefs.h> 39#include <kpimglobalprefs.h>
40#include <kcmconfigs/kcmpwmconfig.h> 40#include <kcmconfigs/kcmpwmconfig.h>
41#include <kcmconfigs/kcmkdepimconfig.h> 41#include <kcmconfigs/kcmkdepimconfig.h>
42#include <kcmultidialog.h> 42#include <kcmultidialog.h>
43#endif 43#endif
44 44
45 45
46#ifndef DESKTOP_VERSION 46#ifndef DESKTOP_VERSION
47#include <qpe/global.h> 47#include <qpe/global.h>
48#endif 48#endif
49 49
50#include <qpixmap.h> 50#include <qpixmap.h>
51#include <qcheckbox.h> 51#include <qcheckbox.h>
52#include <qspinbox.h> 52#include <qspinbox.h>
53#include <qlineedit.h> 53#include <qlineedit.h>
54#include <qfileinfo.h> 54#include <qfileinfo.h>
55#include <qclipboard.h> 55#include <qclipboard.h>
56 56
57 57
58#include <stdio.h> 58#include <stdio.h>
59 59
60#include "pwm.h" 60#include "pwm.h"
61#include "pwminit.h" 61#include "pwminit.h"
62#include "pwmprint.h" 62#include "pwmprint.h"
63#include "addentrywndimpl.h" 63#include "addentrywndimpl.h"
64#include "globalstuff.h" 64#include "globalstuff.h"
65#include "findwndimpl.h" 65#include "findwndimpl.h"
66#include "csv.h" 66#include "csv.h"
67 67
68#ifdef CONFIG_KWALLETIF 68#ifdef CONFIG_KWALLETIF
69# include "kwalletif.h" 69# include "kwalletif.h"
70# include "kwalletemu.h" 70# include "kwalletemu.h"
71#endif 71#endif
72#ifdef CONFIG_KEYCARD 72#ifdef CONFIG_KEYCARD
73# include "pwmkeycard.h" 73# include "pwmkeycard.h"
74#endif 74#endif
75 75
76 76
77 #define DEFAULT_SIZE (QSize(700, 400)) 77 #define DEFAULT_SIZE (QSize(700, 400))
78 78
79// Button IDs for "file" popup menu 79// Button IDs for "file" popup menu
80enum { 80enum {
81 BUTTON_POPUP_FILE_NEW = 0, 81 BUTTON_POPUP_FILE_NEW = 0,
82 BUTTON_POPUP_FILE_OPEN, 82 BUTTON_POPUP_FILE_OPEN,
83 BUTTON_POPUP_FILE_CLOSE, 83 BUTTON_POPUP_FILE_CLOSE,
84 BUTTON_POPUP_FILE_SAVE, 84 BUTTON_POPUP_FILE_SAVE,
85 BUTTON_POPUP_FILE_SAVEAS, 85 BUTTON_POPUP_FILE_SAVEAS,
86 BUTTON_POPUP_FILE_EXPORT, 86 BUTTON_POPUP_FILE_EXPORT,
87 BUTTON_POPUP_FILE_IMPORT, 87 BUTTON_POPUP_FILE_IMPORT,
88 BUTTON_POPUP_FILE_PRINT, 88 BUTTON_POPUP_FILE_PRINT,
89 BUTTON_POPUP_FILE_QUIT 89 BUTTON_POPUP_FILE_QUIT
90}; 90};
91// Button IDs for "manage" popup menu 91// Button IDs for "manage" popup menu
92enum { 92enum {
93 BUTTON_POPUP_MANAGE_ADD = 0, 93 BUTTON_POPUP_MANAGE_ADD = 0,
94 BUTTON_POPUP_MANAGE_EDIT, 94 BUTTON_POPUP_MANAGE_EDIT,
95 BUTTON_POPUP_MANAGE_DEL, 95 BUTTON_POPUP_MANAGE_DEL,
96 BUTTON_POPUP_MANAGE_CHANGEMP 96 BUTTON_POPUP_MANAGE_CHANGEMP
97}; 97};
98// Button IDs for chipcard popup menu 98// Button IDs for chipcard popup menu
99enum { 99enum {
100#ifdef CONFIG_KEYCARD 100#ifdef CONFIG_KEYCARD
101 BUTTON_POPUP_CHIPCARD_GENNEW = 0, 101 BUTTON_POPUP_CHIPCARD_GENNEW = 0,
102 BUTTON_POPUP_CHIPCARD_DEL, 102 BUTTON_POPUP_CHIPCARD_DEL,
103 BUTTON_POPUP_CHIPCARD_READID, 103 BUTTON_POPUP_CHIPCARD_READID,
104 BUTTON_POPUP_CHIPCARD_SAVEBACKUP, 104 BUTTON_POPUP_CHIPCARD_SAVEBACKUP,
105 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP 105 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP
106#else // CONFIG_KEYCARD 106#else // CONFIG_KEYCARD
107 BUTTON_POPUP_CHIPCARD_NO = 0 107 BUTTON_POPUP_CHIPCARD_NO = 0
108#endif // CONFIG_KEYCARD 108#endif // CONFIG_KEYCARD
109}; 109};
110// Button IDs for "view" popup menu 110// Button IDs for "view" popup menu
111enum { 111enum {
112 BUTTON_POPUP_VIEW_FIND = 0, 112 BUTTON_POPUP_VIEW_FIND = 0,
113 BUTTON_POPUP_VIEW_LOCK, 113 BUTTON_POPUP_VIEW_LOCK,
114 BUTTON_POPUP_VIEW_DEEPLOCK, 114 BUTTON_POPUP_VIEW_DEEPLOCK,
115 BUTTON_POPUP_VIEW_UNLOCK 115 BUTTON_POPUP_VIEW_UNLOCK
116}; 116};
117// Button IDs for "options" popup menu 117// Button IDs for "options" popup menu
118enum { 118enum {
119 BUTTON_POPUP_OPTIONS_CONFIG = 0 119 BUTTON_POPUP_OPTIONS_CONFIG = 0
120}; 120};
121// Button IDs for "export" popup menu (in "file" popup menu) 121// Button IDs for "export" popup menu (in "file" popup menu)
122enum { 122enum {
123 BUTTON_POPUP_EXPORT_TEXT = 0, 123 BUTTON_POPUP_EXPORT_TEXT = 0,
124 BUTTON_POPUP_EXPORT_GPASMAN, 124 BUTTON_POPUP_EXPORT_GPASMAN,
125 BUTTON_POPUP_EXPORT_CSV 125 BUTTON_POPUP_EXPORT_CSV
126#ifdef CONFIG_KWALLETIF 126#ifdef CONFIG_KWALLETIF
127 ,BUTTON_POPUP_EXPORT_KWALLET 127 ,BUTTON_POPUP_EXPORT_KWALLET
128#endif 128#endif
129}; 129};
130// Button IDs for "import" popup menu (in "file" popup menu) 130// Button IDs for "import" popup menu (in "file" popup menu)
131enum { 131enum {
132 BUTTON_POPUP_IMPORT_TEXT = 0, 132 BUTTON_POPUP_IMPORT_TEXT = 0,
133 BUTTON_POPUP_IMPORT_GPASMAN, 133 BUTTON_POPUP_IMPORT_GPASMAN,
134 BUTTON_POPUP_IMPORT_CSV 134 BUTTON_POPUP_IMPORT_CSV
135#ifdef CONFIG_KWALLETIF 135#ifdef CONFIG_KWALLETIF
136 ,BUTTON_POPUP_IMPORT_KWALLET 136 ,BUTTON_POPUP_IMPORT_KWALLET
137#endif 137#endif
138}; 138};
139 139
140#ifdef PWM_EMBEDDED 140#ifdef PWM_EMBEDDED
141// Button IDs for "help" popup menu 141// Button IDs for "help" popup menu
142enum { 142enum {
143 BUTTON_POPUP_HELP_LICENSE = 0, 143 BUTTON_POPUP_HELP_LICENSE = 0,
144 BUTTON_POPUP_HELP_FAQ, 144 BUTTON_POPUP_HELP_FAQ,
145 BUTTON_POPUP_HELP_ABOUT, 145 BUTTON_POPUP_HELP_ABOUT,
146 BUTTON_POPUP_HELP_SYNC, 146 BUTTON_POPUP_HELP_SYNC,
147 BUTTON_POPUP_HELP_WHATSNEW 147 BUTTON_POPUP_HELP_WHATSNEW
148}; 148};
149#endif 149#endif
150 150
151// Button IDs for toolbar 151// Button IDs for toolbar
152enum { 152enum {
153 BUTTON_TOOL_NEW = 0, 153 BUTTON_TOOL_NEW = 0,
154 BUTTON_TOOL_OPEN, 154 BUTTON_TOOL_OPEN,
155 BUTTON_TOOL_SAVE, 155 BUTTON_TOOL_SAVE,
156 BUTTON_TOOL_SAVEAS, 156 BUTTON_TOOL_SAVEAS,
157 BUTTON_TOOL_PRINT, 157 BUTTON_TOOL_PRINT,
158 BUTTON_TOOL_ADD, 158 BUTTON_TOOL_ADD,
159 BUTTON_TOOL_EDIT, 159 BUTTON_TOOL_EDIT,
160 BUTTON_TOOL_DEL, 160 BUTTON_TOOL_DEL,
161 BUTTON_TOOL_FIND, 161 BUTTON_TOOL_FIND,
162 BUTTON_TOOL_LOCK, 162 BUTTON_TOOL_LOCK,
163 BUTTON_TOOL_DEEPLOCK, 163 BUTTON_TOOL_DEEPLOCK,
164 BUTTON_TOOL_UNLOCK 164 BUTTON_TOOL_UNLOCK
165}; 165};
166 166
167 167
168PwM::PwM(PwMInit *_init, PwMDoc *doc, 168PwM::PwM(PwMInit *_init, PwMDoc *doc,
169 bool virginity, 169 bool virginity,
170 QWidget *parent, const char *name) 170 QWidget *parent, const char *name)
171 : KMainWindow(parent, "HALLO") 171 : KMainWindow(parent, "HALLO")
172 , forceQuit (false) 172 , forceQuit (false)
173 , forceMinimizeToTray (false) 173 , forceMinimizeToTray (false)
174{ 174{
175 syncManager = 0;
175 virgin = !virginity; 176 virgin = !virginity;
176 init = _init; 177 init = _init;
177 connect(doc, SIGNAL(docClosed(PwMDoc *)), 178 connect(doc, SIGNAL(docClosed(PwMDoc *)),
178 this, SLOT(docClosed(PwMDoc *))); 179 this, SLOT(docClosed(PwMDoc *)));
179 initMenubar(); 180 initMenubar();
180 initToolbar(); 181 initToolbar();
181 initMetrics(); 182 initMetrics();
182 setVirgin(virginity); 183 setVirgin(virginity);
183 setFocusPolicy(QWidget::WheelFocus); 184 setFocusPolicy(QWidget::WheelFocus);
184#ifndef PWM_EMBEDDED 185#ifndef PWM_EMBEDDED
185 statusBar()->show(); 186 statusBar()->show();
186#endif 187#endif
187 view = makeNewListView(doc); 188 view = makeNewListView(doc);
188 setCentralWidget(view); 189 setCentralWidget(view);
189 updateCaption(); 190 updateCaption();
190 showStatMsg(i18n("Ready.")); 191 showStatMsg(i18n("Ready."));
191} 192}
192 193
193PwM::~PwM() 194PwM::~PwM()
194{ 195{
195 //qDebug("PwM::~PwM()"); 196 //qDebug("PwM::~PwM()");
196 disconnect(curDoc(), SIGNAL(docClosed(PwMDoc *)), 197 disconnect(curDoc(), SIGNAL(docClosed(PwMDoc *)),
197 this, SLOT(docClosed(PwMDoc *))); 198 this, SLOT(docClosed(PwMDoc *)));
198 conf()->confWndMainWndSize(size()); 199 conf()->confWndMainWndSize(size());
199 emit closed(this); 200 emit closed(this);
200 //qDebug("PwM::~PwM() emited closed(this)"); 201 //qDebug("PwM::~PwM() emited closed(this)");
201 delete view; 202 delete view;
203 delete syncManager;
202} 204}
203 205
204void PwM::initMenubar() 206void PwM::initMenubar()
205{ 207{
206 KIconLoader* picons; 208 KIconLoader* picons;
207#ifndef PWM_EMBEDDED 209#ifndef PWM_EMBEDDED
208 KIconLoader icons; 210 KIconLoader icons;
209 picons = &icons; 211 picons = &icons;
210#else 212#else
211 picons = KGlobal::iconLoader(); 213 picons = KGlobal::iconLoader();
212 214
213 215
214 syncPopup = new KPopupMenu(this); 216 syncPopup = new KPopupMenu(this);
215 217
216 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::PWMPI, PWMPrefs::instance(), syncPopup); 218 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::PWMPI, PWMPrefs::instance(), syncPopup);
217 syncManager->setBlockSave(false); 219 syncManager->setBlockSave(false);
218 220
219 connect ( syncPopup, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 221 connect ( syncPopup, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
220 syncManager->fillSyncMenu(); 222 syncManager->fillSyncMenu();
221 223
222#endif 224#endif
223 filePopup = new KPopupMenu(this); 225 filePopup = new KPopupMenu(this);
224 importPopup = new KPopupMenu(filePopup); 226 importPopup = new KPopupMenu(filePopup);
225 exportPopup = new KPopupMenu(filePopup); 227 exportPopup = new KPopupMenu(filePopup);
226 managePopup = new KPopupMenu(this); 228 managePopup = new KPopupMenu(this);
227#ifdef CONFIG_KEYCARD 229#ifdef CONFIG_KEYCARD
228 chipcardPopup = new KPopupMenu(this); 230 chipcardPopup = new KPopupMenu(this);
229#endif // CONFIG_KEYCARD 231#endif // CONFIG_KEYCARD
230 viewPopup = new KPopupMenu(this); 232 viewPopup = new KPopupMenu(this);
231 optionsPopup = new KPopupMenu(this); 233 optionsPopup = new KPopupMenu(this);
232 234
233// "file" popup menu 235// "file" popup menu
234 filePopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), 236 filePopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)),
235 i18n("&New"), this, 237 i18n("&New"), this,
236 SLOT(new_slot()), 0, BUTTON_POPUP_FILE_NEW); 238 SLOT(new_slot()), 0, BUTTON_POPUP_FILE_NEW);
237 filePopup->insertItem(QIconSet(picons->loadIcon("fileopen", KIcon::Small)), 239 filePopup->insertItem(QIconSet(picons->loadIcon("fileopen", KIcon::Small)),
238 i18n("&Open"), this, 240 i18n("&Open"), this,
239 SLOT(open_slot()), 0, BUTTON_POPUP_FILE_OPEN); 241 SLOT(open_slot()), 0, BUTTON_POPUP_FILE_OPEN);
240 filePopup->insertItem(QIconSet(picons->loadIcon("fileclose", KIcon::Small)), 242 filePopup->insertItem(QIconSet(picons->loadIcon("fileclose", KIcon::Small)),
241 i18n("&Close"), this, 243 i18n("&Close"), this,
242 SLOT(close_slot()), 0, BUTTON_POPUP_FILE_CLOSE); 244 SLOT(close_slot()), 0, BUTTON_POPUP_FILE_CLOSE);
243 filePopup->insertSeparator(); 245 filePopup->insertSeparator();
244 filePopup->insertItem(QIconSet(picons->loadIcon("filesave", KIcon::Small)), 246 filePopup->insertItem(QIconSet(picons->loadIcon("filesave", KIcon::Small)),
245 i18n("&Save"), this, 247 i18n("&Save"), this,
246 SLOT(save_slot()), 0, BUTTON_POPUP_FILE_SAVE); 248 SLOT(save_slot()), 0, BUTTON_POPUP_FILE_SAVE);
247 filePopup->insertItem(QIconSet(picons->loadIcon("filesaveas", KIcon::Small)), 249 filePopup->insertItem(QIconSet(picons->loadIcon("filesaveas", KIcon::Small)),
248 i18n("Save &as..."), 250 i18n("Save &as..."),
249 this, SLOT(saveAs_slot()), 0, 251 this, SLOT(saveAs_slot()), 0,
250 BUTTON_POPUP_FILE_SAVEAS); 252 BUTTON_POPUP_FILE_SAVEAS);
251 filePopup->insertSeparator(); 253 filePopup->insertSeparator();
252 // "file/export" popup menu 254 // "file/export" popup menu
253 exportPopup->insertItem(i18n("&Text-file..."), this, 255 exportPopup->insertItem(i18n("&Text-file..."), this,
254 SLOT(exportToText()), 0, BUTTON_POPUP_EXPORT_TEXT); 256 SLOT(exportToText()), 0, BUTTON_POPUP_EXPORT_TEXT);
255 exportPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, 257 exportPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this,
256 SLOT(exportToGpasman()), 0, BUTTON_POPUP_EXPORT_GPASMAN); 258 SLOT(exportToGpasman()), 0, BUTTON_POPUP_EXPORT_GPASMAN);
257 exportPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this, 259 exportPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this,
258 SLOT(exportToCsv()), 0, BUTTON_POPUP_EXPORT_CSV); 260 SLOT(exportToCsv()), 0, BUTTON_POPUP_EXPORT_CSV);
259#ifdef CONFIG_KWALLETIF 261#ifdef CONFIG_KWALLETIF
260 exportPopup->insertItem(i18n("&KWallet..."), this, 262 exportPopup->insertItem(i18n("&KWallet..."), this,
261 SLOT(exportToKWallet()), 0, BUTTON_POPUP_EXPORT_KWALLET); 263 SLOT(exportToKWallet()), 0, BUTTON_POPUP_EXPORT_KWALLET);
262#endif 264#endif
263 filePopup->insertItem(QIconSet(picons->loadIcon("fileexport", KIcon::Small)), 265 filePopup->insertItem(QIconSet(picons->loadIcon("fileexport", KIcon::Small)),
264 i18n("E&xport"), exportPopup, 266 i18n("E&xport"), exportPopup,
265 BUTTON_POPUP_FILE_EXPORT); 267 BUTTON_POPUP_FILE_EXPORT);
266 // "file/import" popup menu 268 // "file/import" popup menu
267 importPopup->insertItem(i18n("&Text-file..."), this, 269 importPopup->insertItem(i18n("&Text-file..."), this,
268 SLOT(importFromText()), 0, BUTTON_POPUP_IMPORT_TEXT); 270 SLOT(importFromText()), 0, BUTTON_POPUP_IMPORT_TEXT);
269 importPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, 271 importPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this,
270 SLOT(importFromGpasman()), 0, BUTTON_POPUP_IMPORT_GPASMAN); 272 SLOT(importFromGpasman()), 0, BUTTON_POPUP_IMPORT_GPASMAN);
271 importPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this, 273 importPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this,
272 SLOT(importCsv()), 0, BUTTON_POPUP_IMPORT_CSV); 274 SLOT(importCsv()), 0, BUTTON_POPUP_IMPORT_CSV);
273#ifdef CONFIG_KWALLETIF 275#ifdef CONFIG_KWALLETIF
274 importPopup->insertItem(i18n("&KWallet..."), this, 276 importPopup->insertItem(i18n("&KWallet..."), this,
275 SLOT(importKWallet()), 0, BUTTON_POPUP_IMPORT_KWALLET); 277 SLOT(importKWallet()), 0, BUTTON_POPUP_IMPORT_KWALLET);
276#endif 278#endif
277 filePopup->insertItem(QIconSet(picons->loadIcon("fileimport", KIcon::Small)), 279 filePopup->insertItem(QIconSet(picons->loadIcon("fileimport", KIcon::Small)),
278 i18n("I&mport"), importPopup, 280 i18n("I&mport"), importPopup,
279 BUTTON_POPUP_FILE_IMPORT); 281 BUTTON_POPUP_FILE_IMPORT);
280 filePopup->insertSeparator(); 282 filePopup->insertSeparator();
281 filePopup->insertItem(QIconSet(picons->loadIcon("fileprint", KIcon::Small)), 283 filePopup->insertItem(QIconSet(picons->loadIcon("fileprint", KIcon::Small)),
282 i18n("&Print..."), this, 284 i18n("&Print..."), this,
283 SLOT(print_slot()), 0, BUTTON_POPUP_FILE_PRINT); 285 SLOT(print_slot()), 0, BUTTON_POPUP_FILE_PRINT);
284 filePopup->insertSeparator(); 286 filePopup->insertSeparator();
285 filePopup->insertItem(QIconSet(picons->loadIcon("exit", KIcon::Small)), 287 filePopup->insertItem(QIconSet(picons->loadIcon("exit", KIcon::Small)),
286 i18n("&Quit"), this, 288 i18n("&Quit"), this,
287 SLOT(quitButton_slot()), 0, BUTTON_POPUP_FILE_QUIT); 289 SLOT(quitButton_slot()), 0, BUTTON_POPUP_FILE_QUIT);
288 menuBar()->insertItem(i18n("&File"), filePopup); 290 menuBar()->insertItem(i18n("&File"), filePopup);
289// "manage" popup menu 291// "manage" popup menu
290 managePopup->insertItem(QIconSet(picons->loadIcon("pencil", KIcon::Small)), 292 managePopup->insertItem(QIconSet(picons->loadIcon("pencil", KIcon::Small)),
291 i18n("&Add password"), this, 293 i18n("&Add password"), this,
292 SLOT(addPwd_slot()), 0, 294 SLOT(addPwd_slot()), 0,
293 BUTTON_POPUP_MANAGE_ADD); 295 BUTTON_POPUP_MANAGE_ADD);
294 managePopup->insertItem(QIconSet(picons->loadIcon("edit", KIcon::Small)), 296 managePopup->insertItem(QIconSet(picons->loadIcon("edit", KIcon::Small)),
295 i18n("&Edit"), this, SLOT(editPwd_slot()), 0, 297 i18n("&Edit"), this, SLOT(editPwd_slot()), 0,
296 BUTTON_POPUP_MANAGE_EDIT); 298 BUTTON_POPUP_MANAGE_EDIT);
297 managePopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), 299 managePopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)),
298 i18n("&Delete"), this, SLOT(deletePwd_slot()), 300 i18n("&Delete"), this, SLOT(deletePwd_slot()),
299 0, BUTTON_POPUP_MANAGE_DEL); 301 0, BUTTON_POPUP_MANAGE_DEL);
300 managePopup->insertSeparator(); 302 managePopup->insertSeparator();
301 managePopup->insertItem(QIconSet(picons->loadIcon("rotate", KIcon::Small)), 303 managePopup->insertItem(QIconSet(picons->loadIcon("rotate", KIcon::Small)),
302 i18n("Change &Master Password"), this, 304 i18n("Change &Master Password"), this,
303 SLOT(changeMasterPwd_slot()), 0, 305 SLOT(changeMasterPwd_slot()), 0,
304 BUTTON_POPUP_MANAGE_CHANGEMP); 306 BUTTON_POPUP_MANAGE_CHANGEMP);
305 menuBar()->insertItem(i18n("&Manage"), managePopup); 307 menuBar()->insertItem(i18n("&Manage"), managePopup);
306// "chipcard" popup menu 308// "chipcard" popup menu
307#ifdef CONFIG_KEYCARD 309#ifdef CONFIG_KEYCARD
308 chipcardPopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), 310 chipcardPopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)),
309 i18n("&Generate new key-card"), this, 311 i18n("&Generate new key-card"), this,
310 SLOT(genNewCard_slot()), 0, 312 SLOT(genNewCard_slot()), 0,
311 BUTTON_POPUP_CHIPCARD_GENNEW); 313 BUTTON_POPUP_CHIPCARD_GENNEW);
312 chipcardPopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), 314 chipcardPopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)),
313 i18n("&Erase key-card"), this, 315 i18n("&Erase key-card"), this,
314 SLOT(eraseCard_slot()), 0, 316 SLOT(eraseCard_slot()), 0,
315 BUTTON_POPUP_CHIPCARD_DEL); 317 BUTTON_POPUP_CHIPCARD_DEL);
316 chipcardPopup->insertItem(QIconSet(picons->loadIcon("", KIcon::Small)), 318 chipcardPopup->insertItem(QIconSet(picons->loadIcon("", KIcon::Small)),
317 i18n("Read card-&ID"), this, 319 i18n("Read card-&ID"), this,
318 SLOT(readCardId_slot()), 0, 320 SLOT(readCardId_slot()), 0,
319 BUTTON_POPUP_CHIPCARD_READID); 321 BUTTON_POPUP_CHIPCARD_READID);
320 chipcardPopup->insertSeparator(); 322 chipcardPopup->insertSeparator();
321 chipcardPopup->insertItem(QIconSet(picons->loadIcon("2rightarrow", KIcon::Small)), 323 chipcardPopup->insertItem(QIconSet(picons->loadIcon("2rightarrow", KIcon::Small)),
322 i18n("&Make card backup-image"), this, 324 i18n("&Make card backup-image"), this,
323 SLOT(makeCardBackup_slot()), 0, 325 SLOT(makeCardBackup_slot()), 0,
324 BUTTON_POPUP_CHIPCARD_SAVEBACKUP); 326 BUTTON_POPUP_CHIPCARD_SAVEBACKUP);
325 chipcardPopup->insertItem(QIconSet(picons->loadIcon("2leftarrow", KIcon::Small)), 327 chipcardPopup->insertItem(QIconSet(picons->loadIcon("2leftarrow", KIcon::Small)),
326 i18n("&Replay card backup-image"), this, 328 i18n("&Replay card backup-image"), this,
327 SLOT(replayCardBackup_slot()), 0, 329 SLOT(replayCardBackup_slot()), 0,
328 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP); 330 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP);
329 menuBar()->insertItem(i18n("&Chipcard manager"), chipcardPopup); 331 menuBar()->insertItem(i18n("&Chipcard manager"), chipcardPopup);
330#endif // CONFIG_KEYCARD 332#endif // CONFIG_KEYCARD
331// "view" popup menu 333// "view" popup menu
332 viewPopup->insertItem(QIconSet(picons->loadIcon("find", KIcon::Small)), 334 viewPopup->insertItem(QIconSet(picons->loadIcon("find", KIcon::Small)),
333 i18n("&Find"), this, 335 i18n("&Find"), this,
334 SLOT(find_slot()), 0, BUTTON_POPUP_VIEW_FIND); 336 SLOT(find_slot()), 0, BUTTON_POPUP_VIEW_FIND);
335 viewPopup->insertSeparator(); 337 viewPopup->insertSeparator();
336 viewPopup->insertItem(QIconSet(picons->loadIcon("halfencrypted", KIcon::Small)), 338 viewPopup->insertItem(QIconSet(picons->loadIcon("halfencrypted", KIcon::Small)),
337 i18n("&Lock all entries"), this, 339 i18n("&Lock all entries"), this,
338 SLOT(lockWnd_slot()), 0, 340 SLOT(lockWnd_slot()), 0,
339 BUTTON_POPUP_VIEW_LOCK); 341 BUTTON_POPUP_VIEW_LOCK);
340 viewPopup->insertItem(QIconSet(picons->loadIcon("encrypted", KIcon::Small)), 342 viewPopup->insertItem(QIconSet(picons->loadIcon("encrypted", KIcon::Small)),
341 i18n("&Deep-lock all entries"), this, 343 i18n("&Deep-lock all entries"), this,
342 SLOT(deepLockWnd_slot()), 0, 344 SLOT(deepLockWnd_slot()), 0,
343 BUTTON_POPUP_VIEW_DEEPLOCK); 345 BUTTON_POPUP_VIEW_DEEPLOCK);
344 viewPopup->insertItem(QIconSet(picons->loadIcon("decrypted", KIcon::Small)), 346 viewPopup->insertItem(QIconSet(picons->loadIcon("decrypted", KIcon::Small)),
345 i18n("&Unlock all entries"), this, 347 i18n("&Unlock all entries"), this,
346 SLOT(unlockWnd_slot()), 0, 348 SLOT(unlockWnd_slot()), 0,
347 BUTTON_POPUP_VIEW_UNLOCK); 349 BUTTON_POPUP_VIEW_UNLOCK);
348 menuBar()->insertItem(i18n("&View"), viewPopup); 350 menuBar()->insertItem(i18n("&View"), viewPopup);
349// "options" popup menu 351// "options" popup menu
350 optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)), 352 optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)),
351 i18n("&Configure..."), this, 353 i18n("&Configure..."), this,
352 SLOT(config_slot()), 354 SLOT(config_slot()),
353 BUTTON_POPUP_OPTIONS_CONFIG); 355 BUTTON_POPUP_OPTIONS_CONFIG);
354 menuBar()->insertItem(i18n("&Options"), optionsPopup); 356 menuBar()->insertItem(i18n("&Options"), optionsPopup);
355// "help" popup menu 357// "help" popup menu
356#ifndef PWM_EMBEDDED 358#ifndef PWM_EMBEDDED
357 helpPopup = helpMenu(QString::null, false); 359 helpPopup = helpMenu(QString::null, false);
358#else 360#else
359 menuBar()->insertItem(i18n("&Sync"), syncPopup); 361 menuBar()->insertItem(i18n("&Sync"), syncPopup);
360 362
361 363
362 364
363 365
364 366
365 helpPopup = new KPopupMenu(this); 367 helpPopup = new KPopupMenu(this);
366 368
367 369
368 helpPopup->insertItem(i18n("&License"), this, 370 helpPopup->insertItem(i18n("&License"), this,
369 SLOT(showLicense_slot()), 0, 371 SLOT(showLicense_slot()), 0,
370 BUTTON_POPUP_HELP_LICENSE); 372 BUTTON_POPUP_HELP_LICENSE);
371 373
372 helpPopup->insertItem(i18n("&Faq"), this, 374 helpPopup->insertItem(i18n("&Faq"), this,
373 SLOT(faq_slot()), 0, 375 SLOT(faq_slot()), 0,
374 BUTTON_POPUP_HELP_FAQ); 376 BUTTON_POPUP_HELP_FAQ);
375 377
376 helpPopup->insertItem(i18n("&About PwManager"), this, 378 helpPopup->insertItem(i18n("&About PwManager"), this,
377 SLOT(createAboutData_slot()), 0, 379 SLOT(createAboutData_slot()), 0,
378 BUTTON_POPUP_HELP_ABOUT); 380 BUTTON_POPUP_HELP_ABOUT);
379 381
380 helpPopup->insertItem(i18n("&Sync HowTo"), this, 382 helpPopup->insertItem(i18n("&Sync HowTo"), this,
381 SLOT(syncHowTo_slot()), 0, 383 SLOT(syncHowTo_slot()), 0,
382 BUTTON_POPUP_HELP_SYNC); 384 BUTTON_POPUP_HELP_SYNC);
383 385
384 helpPopup->insertItem(i18n("&What's New"), this, 386 helpPopup->insertItem(i18n("&What's New"), this,
385 SLOT(whatsnew_slot()), 0, 387 SLOT(whatsnew_slot()), 0,
386 BUTTON_POPUP_HELP_WHATSNEW); 388 BUTTON_POPUP_HELP_WHATSNEW);
387 389
388#endif 390#endif
389 menuBar()->insertItem(i18n("&Help"), helpPopup); 391 menuBar()->insertItem(i18n("&Help"), helpPopup);
390 392
391} 393}
392 394
393void PwM::initToolbar() 395void PwM::initToolbar()
394{ 396{
395 KIconLoader* picons; 397 KIconLoader* picons;
396#ifndef PWM_EMBEDDED 398#ifndef PWM_EMBEDDED
397 KIconLoader icons; 399 KIconLoader icons;
398 picons = &icons; 400 picons = &icons;
399#else 401#else
400 picons = KGlobal::iconLoader(); 402 picons = KGlobal::iconLoader();
401#endif 403#endif
402 404
403#ifdef PWM_EMBEDDED 405#ifdef PWM_EMBEDDED
404 if ( QApplication::desktop()->width() > 320 ) 406 if ( QApplication::desktop()->width() > 320 )
405#endif 407#endif
406 { 408 {
407 toolBar()->insertButton(picons->loadIcon("filenew", KIcon::Toolbar), 409 toolBar()->insertButton(picons->loadIcon("filenew", KIcon::Toolbar),
408 BUTTON_TOOL_NEW, SIGNAL(clicked(int)), this, 410 BUTTON_TOOL_NEW, SIGNAL(clicked(int)), this,
409 SLOT(new_slot()), true, i18n("New")); 411 SLOT(new_slot()), true, i18n("New"));
410 toolBar()->insertButton(picons->loadIcon("fileopen", KIcon::Toolbar), 412 toolBar()->insertButton(picons->loadIcon("fileopen", KIcon::Toolbar),
411 BUTTON_TOOL_OPEN, SIGNAL(clicked(int)), this, 413 BUTTON_TOOL_OPEN, SIGNAL(clicked(int)), this,
412 SLOT(open_slot()), true, i18n("Open")); 414 SLOT(open_slot()), true, i18n("Open"));
413 toolBar()->insertSeparator(); 415 toolBar()->insertSeparator();
414 } 416 }
415 toolBar()->insertButton(picons->loadIcon("filesave", KIcon::Toolbar), 417 toolBar()->insertButton(picons->loadIcon("filesave", KIcon::Toolbar),
416 BUTTON_TOOL_SAVE, SIGNAL(clicked(int)), this, 418 BUTTON_TOOL_SAVE, SIGNAL(clicked(int)), this,
417 SLOT(save_slot()), true, i18n("Save")); 419 SLOT(save_slot()), true, i18n("Save"));
418 toolBar()->insertButton(picons->loadIcon("filesaveas", KIcon::Toolbar), 420 toolBar()->insertButton(picons->loadIcon("filesaveas", KIcon::Toolbar),
419 BUTTON_TOOL_SAVEAS, SIGNAL(clicked(int)), this, 421 BUTTON_TOOL_SAVEAS, SIGNAL(clicked(int)), this,
420 SLOT(saveAs_slot()), true, i18n("Save as")); 422 SLOT(saveAs_slot()), true, i18n("Save as"));
421 toolBar()->insertButton(picons->loadIcon("fileprint", KIcon::Toolbar), 423 toolBar()->insertButton(picons->loadIcon("fileprint", KIcon::Toolbar),
422 BUTTON_TOOL_PRINT, SIGNAL(clicked(int)), this, 424 BUTTON_TOOL_PRINT, SIGNAL(clicked(int)), this,
423 SLOT(print_slot()), true, i18n("Print...")); 425 SLOT(print_slot()), true, i18n("Print..."));
424 toolBar()->insertSeparator(); 426 toolBar()->insertSeparator();
425 toolBar()->insertButton(picons->loadIcon("pencil", KIcon::Toolbar), 427 toolBar()->insertButton(picons->loadIcon("pencil", KIcon::Toolbar),
426 BUTTON_TOOL_ADD, SIGNAL(clicked(int)), this, 428 BUTTON_TOOL_ADD, SIGNAL(clicked(int)), this,
427 SLOT(addPwd_slot()), true, 429 SLOT(addPwd_slot()), true,
428 i18n("Add password")); 430 i18n("Add password"));
429 toolBar()->insertButton(picons->loadIcon("edit", KIcon::Toolbar), 431 toolBar()->insertButton(picons->loadIcon("edit", KIcon::Toolbar),
430 BUTTON_TOOL_EDIT, SIGNAL(clicked(int)), this, 432 BUTTON_TOOL_EDIT, SIGNAL(clicked(int)), this,
431 SLOT(editPwd_slot()), true, 433 SLOT(editPwd_slot()), true,
432 i18n("Edit password")); 434 i18n("Edit password"));
433 toolBar()->insertButton(picons->loadIcon("editdelete", KIcon::Toolbar), 435 toolBar()->insertButton(picons->loadIcon("editdelete", KIcon::Toolbar),
434 BUTTON_TOOL_DEL, SIGNAL(clicked(int)), this, 436 BUTTON_TOOL_DEL, SIGNAL(clicked(int)), this,
435 SLOT(deletePwd_slot()), true, 437 SLOT(deletePwd_slot()), true,
436 i18n("Delete password")); 438 i18n("Delete password"));
437 toolBar()->insertSeparator(); 439 toolBar()->insertSeparator();
438 toolBar()->insertButton(picons->loadIcon("find", KIcon::Toolbar), 440 toolBar()->insertButton(picons->loadIcon("find", KIcon::Toolbar),
439 BUTTON_TOOL_FIND, SIGNAL(clicked(int)), this, 441 BUTTON_TOOL_FIND, SIGNAL(clicked(int)), this,
440 SLOT(find_slot()), true, i18n("Find entry")); 442 SLOT(find_slot()), true, i18n("Find entry"));
441 toolBar()->insertSeparator(); 443 toolBar()->insertSeparator();
442 toolBar()->insertButton(picons->loadIcon("halfencrypted", KIcon::Toolbar), 444 toolBar()->insertButton(picons->loadIcon("halfencrypted", KIcon::Toolbar),
443 BUTTON_TOOL_LOCK, SIGNAL(clicked(int)), this, 445 BUTTON_TOOL_LOCK, SIGNAL(clicked(int)), this,
444 SLOT(lockWnd_slot()), true, 446 SLOT(lockWnd_slot()), true,
445 i18n("Lock all entries")); 447 i18n("Lock all entries"));
446 toolBar()->insertButton(picons->loadIcon("encrypted", KIcon::Toolbar), 448 toolBar()->insertButton(picons->loadIcon("encrypted", KIcon::Toolbar),
447 BUTTON_TOOL_DEEPLOCK, SIGNAL(clicked(int)), this, 449 BUTTON_TOOL_DEEPLOCK, SIGNAL(clicked(int)), this,
448 SLOT(deepLockWnd_slot()), true, 450 SLOT(deepLockWnd_slot()), true,
449 i18n("Deep-Lock all entries")); 451 i18n("Deep-Lock all entries"));
450 toolBar()->insertButton(picons->loadIcon("decrypted", KIcon::Toolbar), 452 toolBar()->insertButton(picons->loadIcon("decrypted", KIcon::Toolbar),
451 BUTTON_TOOL_UNLOCK, SIGNAL(clicked(int)), this, 453 BUTTON_TOOL_UNLOCK, SIGNAL(clicked(int)), this,
452 SLOT(unlockWnd_slot()), true, 454 SLOT(unlockWnd_slot()), true,
453 i18n("Unlock all entries")); 455 i18n("Unlock all entries"));
454} 456}
455 457
456void PwM::initMetrics() 458void PwM::initMetrics()
457{ 459{
458 QSize s = conf()->confWndMainWndSize(); 460 QSize s = conf()->confWndMainWndSize();
459 if (s.isValid()) 461 if (s.isValid())
460 resize(s); 462 resize(s);
461 else 463 else
462 resize(DEFAULT_SIZE); 464 resize(DEFAULT_SIZE);
463} 465}
464 466
465void PwM::updateCaption() 467void PwM::updateCaption()
466{ 468{
467 setPlainCaption(curDoc()->getTitle() + " - " PROG_NAME " " PACKAGE_VER); 469 setPlainCaption(curDoc()->getTitle() + " - " PROG_NAME " " PACKAGE_VER);
468} 470}
469 471
470void PwM::hideEvent(QHideEvent *) 472void PwM::hideEvent(QHideEvent *)
471{ 473{
472 if (isMinimized()) { 474 if (isMinimized()) {
473 if (init->tray()) { 475 if (init->tray()) {
474 forceMinimizeToTray = true; 476 forceMinimizeToTray = true;
475 close(); 477 close();
476 } 478 }
477 int mmlock = conf()->confGlobMinimizeLock(); 479 int mmlock = conf()->confGlobMinimizeLock();
478 switch (mmlock) { 480 switch (mmlock) {
479 case 0: // don't lock anything 481 case 0: // don't lock anything
480 break; 482 break;
481 case 1: {// normal lock 483 case 1: {// normal lock
482 curDoc()->lockAll(true); 484 curDoc()->lockAll(true);
483 break; 485 break;
484 } case 2: {// deep-lock 486 } case 2: {// deep-lock
485 curDoc()->deepLock(); 487 curDoc()->deepLock();
486 break; 488 break;
487 } default: 489 } default:
488 WARN(); 490 WARN();
489 } 491 }
490 } 492 }
491} 493}
492 494
493void PwM::setVirgin(bool v) 495void PwM::setVirgin(bool v)
494{ 496{
495 if (virgin == v) 497 if (virgin == v)
496 return; 498 return;
497 virgin = v; 499 virgin = v;
498 filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVE, !v); 500 filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVE, !v);
499 filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVEAS, !v); 501 filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVEAS, !v);
500 filePopup->setItemEnabled(BUTTON_POPUP_FILE_EXPORT, !v); 502 filePopup->setItemEnabled(BUTTON_POPUP_FILE_EXPORT, !v);
501 filePopup->setItemEnabled(BUTTON_POPUP_FILE_PRINT, !v); 503 filePopup->setItemEnabled(BUTTON_POPUP_FILE_PRINT, !v);
502 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_EDIT, !v); 504 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_EDIT, !v);
503 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_DEL, !v); 505 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_DEL, !v);
504 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, !v); 506 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, !v);
505 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_LOCK, !v); 507 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_LOCK, !v);
506 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_DEEPLOCK, !v); 508 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_DEEPLOCK, !v);
507 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_UNLOCK, !v); 509 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_UNLOCK, !v);
508 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_FIND, !v); 510 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_FIND, !v);
509 toolBar()->setItemEnabled(BUTTON_TOOL_SAVE, !v); 511 toolBar()->setItemEnabled(BUTTON_TOOL_SAVE, !v);
510 toolBar()->setItemEnabled(BUTTON_TOOL_SAVEAS, !v); 512 toolBar()->setItemEnabled(BUTTON_TOOL_SAVEAS, !v);
511 toolBar()->setItemEnabled(BUTTON_TOOL_PRINT, !v); 513 toolBar()->setItemEnabled(BUTTON_TOOL_PRINT, !v);
512 toolBar()->setItemEnabled(BUTTON_TOOL_EDIT, !v); 514 toolBar()->setItemEnabled(BUTTON_TOOL_EDIT, !v);
513 toolBar()->setItemEnabled(BUTTON_TOOL_DEL, !v); 515 toolBar()->setItemEnabled(BUTTON_TOOL_DEL, !v);
514 toolBar()->setItemEnabled(BUTTON_TOOL_LOCK, !v); 516 toolBar()->setItemEnabled(BUTTON_TOOL_LOCK, !v);
515 toolBar()->setItemEnabled(BUTTON_TOOL_DEEPLOCK, !v); 517 toolBar()->setItemEnabled(BUTTON_TOOL_DEEPLOCK, !v);
516 toolBar()->setItemEnabled(BUTTON_TOOL_UNLOCK, !v); 518 toolBar()->setItemEnabled(BUTTON_TOOL_UNLOCK, !v);
517 toolBar()->setItemEnabled(BUTTON_TOOL_FIND, !v); 519 toolBar()->setItemEnabled(BUTTON_TOOL_FIND, !v);
518} 520}
519 521
520void PwM::new_slot() 522void PwM::new_slot()
521{ 523{
522 init->createMainWnd(); 524 init->createMainWnd();
523} 525}
524 526
525//US ENH 527//US ENH
526void PwM::open_slot() 528void PwM::open_slot()
527{ 529{
528 open_slot(""); 530 open_slot("");
529} 531}
530 532
531void PwM::open_slot(QString fn) 533void PwM::open_slot(QString fn)
532{ 534{
533 openDoc(fn); 535 openDoc(fn);
534} 536}
535 537
536PwMDoc * PwM::openDoc(QString filename, bool openDeepLocked) 538PwMDoc * PwM::openDoc(QString filename, bool openDeepLocked)
537{ 539{
538 if (!isVirgin()) { 540 if (!isVirgin()) {
539 // open the document in a new window. 541 // open the document in a new window.
540 PwM *newInstance = init->createMainWnd(); 542 PwM *newInstance = init->createMainWnd();
541 PwMDoc *newDoc = newInstance->openDoc(filename, openDeepLocked); 543 PwMDoc *newDoc = newInstance->openDoc(filename, openDeepLocked);
542 if (!newDoc) { 544 if (!newDoc) {
543 newInstance->setForceQuit(true); 545 newInstance->setForceQuit(true);
544 delete_and_null(newInstance); 546 delete_and_null(newInstance);
545 } 547 }
546 return newDoc; 548 return newDoc;
547 } 549 }
548 550
549 if (!curDoc()->openDocUi(curDoc(), filename, openDeepLocked)) 551 if (!curDoc()->openDocUi(curDoc(), filename, openDeepLocked))
550 return 0; 552 return 0;
551 showStatMsg(i18n("Successfully opened file.")); 553 showStatMsg(i18n("Successfully opened file."));
552 updateCaption(); 554 updateCaption();
553 setVirgin(false); 555 setVirgin(false);
554 return curDoc(); 556 return curDoc();
555} 557}
556 558
557PwMView * PwM::makeNewListView(PwMDoc *doc) 559PwMView * PwM::makeNewListView(PwMDoc *doc)
558{ 560{
559 PwMView *ret = new PwMView(this, this, doc); 561 PwMView *ret = new PwMView(this, this, doc);
560 ret->setFont(conf()->confGlobEntryFont()); 562 ret->setFont(conf()->confGlobEntryFont());
561 ret->show(); 563 ret->show();
562 return ret; 564 return ret;
563} 565}
564 566
565void PwM::close_slot() 567void PwM::close_slot()
566{ 568{
567 close(); 569 close();
568} 570}
569 571
570void PwM::quitButton_slot() 572void PwM::quitButton_slot()
571{ 573{
572 init->shutdownApp(0); 574 init->shutdownApp(0);
573} 575}
574 576
575void PwM::save_slot() 577void PwM::save_slot()
576{ 578{
577 save(); 579 save();
578} 580}
579 581
580bool PwM::save() 582bool PwM::save()
581{ 583{
582 if (!curDoc()->saveDocUi(curDoc())) 584 if (!curDoc()->saveDocUi(curDoc()))
583 return false; 585 return false;
584 showStatMsg(i18n("Successfully saved data.")); 586 showStatMsg(i18n("Successfully saved data."));
585 updateCaption(); 587 updateCaption();
586 return true; 588 return true;
587} 589}
588 590
589void PwM::saveAs_slot() 591void PwM::saveAs_slot()
590{ 592{
591 saveAs(); 593 saveAs();
592} 594}
593 595
594bool PwM::saveAs() 596bool PwM::saveAs()
595{ 597{
596 if (!curDoc()->saveAsDocUi(curDoc())) 598 if (!curDoc()->saveAsDocUi(curDoc()))
597 return false; 599 return false;
598 showStatMsg(i18n("Successfully saved data.")); 600 showStatMsg(i18n("Successfully saved data."));
599 updateCaption(); 601 updateCaption();
600 return true; 602 return true;
601} 603}
602 604
603//US ENH : changed code to run with older MOC 605//US ENH : changed code to run with older MOC
604void PwM::addPwd_slot() 606void PwM::addPwd_slot()
605{ 607{
606 addPwd_slot1(0, 0); 608 addPwd_slot1(0, 0);
607} 609}
608 610
609void PwM::addPwd_slot1(QString *pw, PwMDoc *_doc) 611void PwM::addPwd_slot1(QString *pw, PwMDoc *_doc)
610{ 612{
611 PwMDoc *doc; 613 PwMDoc *doc;
612 if (_doc) { 614 if (_doc) {
613 doc = _doc; 615 doc = _doc;
614 } else { 616 } else {
615 doc = curDoc(); 617 doc = curDoc();
616 } 618 }
617 PWM_ASSERT(doc); 619 PWM_ASSERT(doc);
618 doc->timer()->getLock(DocTimer::id_autoLockTimer); 620 doc->timer()->getLock(DocTimer::id_autoLockTimer);
619#ifndef PWM_EMBEDDED 621#ifndef PWM_EMBEDDED
620 AddEntryWndImpl w; 622 AddEntryWndImpl w;
621#else 623#else
622 AddEntryWndImpl w(this, "addentrywndimpl"); 624 AddEntryWndImpl w(this, "addentrywndimpl");
623#endif 625#endif
624 626
625 vector<string> catList; 627 vector<string> catList;
626 doc->getCategoryList(&catList); 628 doc->getCategoryList(&catList);
627 unsigned i, size = catList.size(); 629 unsigned i, size = catList.size();
628 for (i = 0; i < size; ++i) { 630 for (i = 0; i < size; ++i) {
629 w.addCategory(catList[i].c_str()); 631 w.addCategory(catList[i].c_str());
630 } 632 }
631 w.setCurrCategory(view->getCurrentCategory()); 633 w.setCurrCategory(view->getCurrentCategory());
632 if (pw) 634 if (pw)
633 w.pwLineEdit->setText(*pw); 635 w.pwLineEdit->setText(*pw);
634 636
635 tryAgain: 637 tryAgain:
636 if (w.exec() == 1) 638 if (w.exec() == 1)
637 { 639 {
638 PwMDataItem d; 640 PwMDataItem d;
639 641
640 //US BUG: to initialize all values of curEntr with meaningfulldata, 642 //US BUG: to initialize all values of curEntr with meaningfulldata,
641 // we call clear on it. Reason: Metadata will be uninitialized otherwise. 643 // we call clear on it. Reason: Metadata will be uninitialized otherwise.
642 // another option would be to create a constructor for PwMDataItem 644 // another option would be to create a constructor for PwMDataItem
643 d.clear(true); 645 d.clear(true);
644 646
645 d.desc = w.getDescription().latin1(); 647 d.desc = w.getDescription().latin1();
646 d.name = w.getUsername().latin1(); 648 d.name = w.getUsername().latin1();
647 d.pw = w.getPassword().latin1(); 649 d.pw = w.getPassword().latin1();
648 d.comment = w.getComment().latin1(); 650 d.comment = w.getComment().latin1();
649 d.url = w.getUrl().latin1(); 651 d.url = w.getUrl().latin1();
650 d.launcher = w.getLauncher().latin1(); 652 d.launcher = w.getLauncher().latin1();
651 PwMerror ret = doc->addEntry(w.getCategory(), &d); 653 PwMerror ret = doc->addEntry(w.getCategory(), &d);
652 if (ret == e_entryExists) { 654 if (ret == e_entryExists) {
653 KMessageBox::error(this, 655 KMessageBox::error(this,
654 i18n 656 i18n
655 ("An entry with this \"Description\",\n" 657 ("An entry with this \"Description\",\n"
656 "does already exist.\n" 658 "does already exist.\n"
657 "Please select another description."), 659 "Please select another description."),
658 i18n("entry already exists.")); 660 i18n("entry already exists."));
659 goto tryAgain; 661 goto tryAgain;
660 } else if (ret == e_maxAllowedEntr) { 662 } else if (ret == e_maxAllowedEntr) {
661 KMessageBox::error(this, i18n("The maximum possible number of\nentries" 663 KMessageBox::error(this, i18n("The maximum possible number of\nentries"
662 "has been reached.\nYou can't add more entries."), 664 "has been reached.\nYou can't add more entries."),
663 i18n("maximum number of entries")); 665 i18n("maximum number of entries"));
664 doc->timer()->putLock(DocTimer::id_autoLockTimer); 666 doc->timer()->putLock(DocTimer::id_autoLockTimer);
665 return; 667 return;
666 } 668 }
667 } 669 }
668 setVirgin(false); 670 setVirgin(false);
669 doc->timer()->putLock(DocTimer::id_autoLockTimer); 671 doc->timer()->putLock(DocTimer::id_autoLockTimer);
670} 672}
671 673
672//US ENH : changed code to run with older MOC 674//US ENH : changed code to run with older MOC
673void PwM::editPwd_slot() 675void PwM::editPwd_slot()
674{ 676{
675 editPwd_slot3(0,0,0); 677 editPwd_slot3(0,0,0);
676} 678}
677 679
678void PwM::editPwd_slot1(const QString *category) 680void PwM::editPwd_slot1(const QString *category)
679{ 681{
680 editPwd_slot3(category, 0, 0); 682 editPwd_slot3(category, 0, 0);
681} 683}
682 684
683void PwM::editPwd_slot3(const QString *category, const int *index, 685void PwM::editPwd_slot3(const QString *category, const int *index,
684 PwMDoc *_doc) 686 PwMDoc *_doc)
685{ 687{
686 PwMDoc *doc; 688 PwMDoc *doc;
687 if (_doc) { 689 if (_doc) {
688 doc = _doc; 690 doc = _doc;
689 } else { 691 } else {
690 doc = curDoc(); 692 doc = curDoc();
691 } 693 }
692 PWM_ASSERT(doc); 694 PWM_ASSERT(doc);
693 if (doc->isDocEmpty()) 695 if (doc->isDocEmpty())
694 return; 696 return;
695 if (doc->isDeepLocked()) 697 if (doc->isDeepLocked())
696 return; 698 return;
697 doc->timer()->getLock(DocTimer::id_autoLockTimer); 699 doc->timer()->getLock(DocTimer::id_autoLockTimer);
698 unsigned int curEntryIndex; 700 unsigned int curEntryIndex;
699 if (index) { 701 if (index) {
700 curEntryIndex = *index; 702 curEntryIndex = *index;
701 } else { 703 } else {
702 if (!(view->getCurEntryIndex(&curEntryIndex))) { 704 if (!(view->getCurEntryIndex(&curEntryIndex))) {
703 printDebug("couldn't get index. Maybe we have a binary entry here."); 705 printDebug("couldn't get index. Maybe we have a binary entry here.");
704 doc->timer()->putLock(DocTimer::id_autoLockTimer); 706 doc->timer()->putLock(DocTimer::id_autoLockTimer);
705 return; 707 return;
706 } 708 }
707 } 709 }
708 QString curCategory; 710 QString curCategory;
709 if (category) { 711 if (category) {
710 curCategory = *category; 712 curCategory = *category;
711 } else { 713 } else {
712 curCategory = view->getCurrentCategory(); 714 curCategory = view->getCurrentCategory();
713 } 715 }
714 PwMDataItem currItem; 716 PwMDataItem currItem;
715 if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) { 717 if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) {
716 doc->timer()->putLock(DocTimer::id_autoLockTimer); 718 doc->timer()->putLock(DocTimer::id_autoLockTimer);
717 return; 719 return;
718 } 720 }
719 BUG_ON(currItem.binary); 721 BUG_ON(currItem.binary);
720 722
721 AddEntryWndImpl w; 723 AddEntryWndImpl w;
722 vector<string> catList; 724 vector<string> catList;
723 doc->getCategoryList(&catList); 725 doc->getCategoryList(&catList);
724 unsigned i, size = catList.size(); 726 unsigned i, size = catList.size();
725 for (i = 0; i < size; ++i) { 727 for (i = 0; i < size; ++i) {
726 w.addCategory(catList[i].c_str()); 728 w.addCategory(catList[i].c_str());
727 } 729 }
728 w.setCurrCategory(curCategory); 730 w.setCurrCategory(curCategory);
729 w.setDescription(currItem.desc.c_str()); 731 w.setDescription(currItem.desc.c_str());
730 w.setUsername(currItem.name.c_str()); 732 w.setUsername(currItem.name.c_str());
731 w.setPassword(currItem.pw.c_str()); 733 w.setPassword(currItem.pw.c_str());
732 w.setUrl(currItem.url.c_str()); 734 w.setUrl(currItem.url.c_str());
733 w.setLauncher(currItem.launcher.c_str()); 735 w.setLauncher(currItem.launcher.c_str());
734 w.setComment(currItem.comment.c_str()); 736 w.setComment(currItem.comment.c_str());
735 if (w.exec() == 1) { 737 if (w.exec() == 1) {
736 currItem.desc = w.getDescription().latin1(); 738 currItem.desc = w.getDescription().latin1();
737 currItem.name = w.getUsername().latin1(); 739 currItem.name = w.getUsername().latin1();
738 currItem.pw = w.getPassword().latin1(); 740 currItem.pw = w.getPassword().latin1();
739 currItem.comment = w.getComment().latin1(); 741 currItem.comment = w.getComment().latin1();
740 currItem.url = w.getUrl().latin1(); 742 currItem.url = w.getUrl().latin1();
741 currItem.launcher = w.getLauncher().latin1(); 743 currItem.launcher = w.getLauncher().latin1();
742 if (!doc->editEntry(curCategory, w.getCategory(), 744 if (!doc->editEntry(curCategory, w.getCategory(),
743 curEntryIndex, &currItem)) { 745 curEntryIndex, &currItem)) {
744 KMessageBox::error(this, 746 KMessageBox::error(this,
745 i18n("Couldn't edit the entry.\n" 747 i18n("Couldn't edit the entry.\n"
746 "Maybe you changed the category and\n" 748 "Maybe you changed the category and\n"
747 "this entry is already present\nin the new " 749 "this entry is already present\nin the new "
748 "category?"), 750 "category?"),
749 i18n("couldn't edit entry.")); 751 i18n("couldn't edit entry."));
750 doc->timer()->putLock(DocTimer::id_autoLockTimer); 752 doc->timer()->putLock(DocTimer::id_autoLockTimer);
751 return; 753 return;
752 } 754 }
753 } 755 }
754 doc->timer()->putLock(DocTimer::id_autoLockTimer); 756 doc->timer()->putLock(DocTimer::id_autoLockTimer);
755} 757}
756 758
757void PwM::deletePwd_slot() 759void PwM::deletePwd_slot()
758{ 760{
759 PWM_ASSERT(curDoc()); 761 PWM_ASSERT(curDoc());
760 if (curDoc()->isDocEmpty()) 762 if (curDoc()->isDocEmpty())
761 return; 763 return;
762 if (curDoc()->isDeepLocked()) 764 if (curDoc()->isDeepLocked())
763 return; 765 return;
764 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 766 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
765 unsigned int curEntryIndex = 0; 767 unsigned int curEntryIndex = 0;
766 if (!(view->getCurEntryIndex(&curEntryIndex))) { 768 if (!(view->getCurEntryIndex(&curEntryIndex))) {
767 printDebug("couldn't get index"); 769 printDebug("couldn't get index");
768 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 770 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
769 return; 771 return;
770 } 772 }
771 773
772 PwMDataItem currItem; 774 PwMDataItem currItem;
773 QString curCategory = view->getCurrentCategory(); 775 QString curCategory = view->getCurrentCategory();
774 if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) { 776 if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) {
775 printDebug("couldn't get entry"); 777 printDebug("couldn't get entry");
776 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 778 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
777 return; 779 return;
778 } 780 }
779 if (KMessageBox:: 781 if (KMessageBox::
780 questionYesNo(this, 782 questionYesNo(this,
781 i18n 783 i18n
782 ("Do you really want to delete\nthe selected entry") + 784 ("Do you really want to delete\nthe selected entry") +
783 " \n\"" + QString(currItem.desc.c_str()) 785 " \n\"" + QString(currItem.desc.c_str())
784 + "\" ?", i18n("delete?")) 786 + "\" ?", i18n("delete?"))
785 == KMessageBox::Yes) { 787 == KMessageBox::Yes) {
786 788
787 curDoc()->delEntry(curCategory, curEntryIndex); 789 curDoc()->delEntry(curCategory, curEntryIndex);
788 } 790 }
789 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 791 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
790} 792}
791 793
792void PwM::changeMasterPwd_slot() 794void PwM::changeMasterPwd_slot()
793{ 795{
794 PWM_ASSERT(curDoc()); 796 PWM_ASSERT(curDoc());
795 curDoc()->changeCurrentPw(); 797 curDoc()->changeCurrentPw();
796} 798}
797 799
798void PwM::lockWnd_slot() 800void PwM::lockWnd_slot()
799{ 801{
800 PWM_ASSERT(curDoc()); 802 PWM_ASSERT(curDoc());
801 curDoc()->lockAll(true); 803 curDoc()->lockAll(true);
802} 804}
803 805
804void PwM::deepLockWnd_slot() 806void PwM::deepLockWnd_slot()
805{ 807{
806 PWM_ASSERT(curDoc()); 808 PWM_ASSERT(curDoc());
807 curDoc()->deepLock(); 809 curDoc()->deepLock();
808} 810}
809 811
810void PwM::unlockWnd_slot() 812void PwM::unlockWnd_slot()
811{ 813{
812 PWM_ASSERT(curDoc()); 814 PWM_ASSERT(curDoc());
813 curDoc()->lockAll(false); 815 curDoc()->lockAll(false);
814} 816}
815 817
816void PwM::config_slot() 818void PwM::config_slot()
817{ 819{
818 int oldStyle = conf()->confWndMainViewStyle(); 820 int oldStyle = conf()->confWndMainViewStyle();
819#ifdef PWM_EMBEDDED 821#ifdef PWM_EMBEDDED
820 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"pwmconfigdialog", true ); 822 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"pwmconfigdialog", true );
821 823
822 KCMPwmConfig* pwmcfg = new KCMPwmConfig( ConfigureDialog->getNewVBoxPage(i18n( "PwManager")) , "KCMPwmConfig" ); 824 KCMPwmConfig* pwmcfg = new KCMPwmConfig( ConfigureDialog->getNewVBoxPage(i18n( "PwManager")) , "KCMPwmConfig" );
823 ConfigureDialog->addModule(pwmcfg ); 825 ConfigureDialog->addModule(pwmcfg );
824 826
825 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 827 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
826 ConfigureDialog->addModule(kdelibcfg ); 828 ConfigureDialog->addModule(kdelibcfg );
827 829
828#ifndef DESKTOP_VERSION 830#ifndef DESKTOP_VERSION
829 ConfigureDialog->showMaximized(); 831 ConfigureDialog->showMaximized();
830#endif 832#endif
831 if ( ConfigureDialog->exec() ) 833 if ( ConfigureDialog->exec() )
832 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 834 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
833 delete ConfigureDialog; 835 delete ConfigureDialog;
834 836
835#else //PWM_EMBEDDED 837#else //PWM_EMBEDDED
836 // display the configuration window (modal mode) 838 // display the configuration window (modal mode)
837 if (!conf()->showConfWnd(this)) 839 if (!conf()->showConfWnd(this))
838 return; 840 return;
839#endif 841#endif
840 842
841 int newStyle = conf()->confWndMainViewStyle(); 843 int newStyle = conf()->confWndMainViewStyle();
842 // reinitialize tray 844 // reinitialize tray
843 init->initTray(); 845 init->initTray();
844 // reinitialize KWallet emulation 846 // reinitialize KWallet emulation
845 init->initKWalletEmu(); 847 init->initKWalletEmu();
846 848
847 PwMDocList *_dl = PwMDoc::getOpenDocList(); 849 PwMDocList *_dl = PwMDoc::getOpenDocList();
848 const vector<PwMDocList::listItem> *dl = _dl->getList(); 850 const vector<PwMDocList::listItem> *dl = _dl->getList();
849 vector<PwMDocList::listItem>::const_iterator i = dl->begin(), 851 vector<PwMDocList::listItem>::const_iterator i = dl->begin(),
850 end = dl->end(); 852 end = dl->end();
851 PwMDoc *doc; 853 PwMDoc *doc;
852 while (i != end) { 854 while (i != end) {
853 doc = (*i).doc; 855 doc = (*i).doc;
854 // unlock-without-mpw timeout 856 // unlock-without-mpw timeout
855 doc->timer()->start(DocTimer::id_mpwTimer); 857 doc->timer()->start(DocTimer::id_mpwTimer);
856 // auto-lock timeout 858 // auto-lock timeout
857 doc->timer()->start(DocTimer::id_autoLockTimer); 859 doc->timer()->start(DocTimer::id_autoLockTimer);
858 ++i; 860 ++i;
859 } 861 }
860 862
861 const QValueList<PwM *> *ml = init->mainWndList(); 863 const QValueList<PwM *> *ml = init->mainWndList();
862#ifndef PWM_EMBEDDED 864#ifndef PWM_EMBEDDED
863 QValueList<PwM *>::const_iterator i2 = ml->begin(), 865 QValueList<PwM *>::const_iterator i2 = ml->begin(),
864 end2 = ml->end(); 866 end2 = ml->end();
865#else 867#else
866 QValueList<PwM *>::ConstIterator i2 = ml->begin(), 868 QValueList<PwM *>::ConstIterator i2 = ml->begin(),
867 end2 = ml->end(); 869 end2 = ml->end();
868#endif 870#endif
869 PwM *pwm; 871 PwM *pwm;
870 while (i2 != end2) { 872 while (i2 != end2) {
871 pwm = *i2; 873 pwm = *i2;
872 // reinitialize the window style. 874 // reinitialize the window style.
873 if (oldStyle != newStyle) 875 if (oldStyle != newStyle)
874 pwm->curView()->initStyle(newStyle); 876 pwm->curView()->initStyle(newStyle);
875 // set the new font 877 // set the new font
876 pwm->curView()->setFont(conf()->confGlobEntryFont()); 878 pwm->curView()->setFont(conf()->confGlobEntryFont());
877 ++i2; 879 ++i2;
878 } 880 }
879} 881}
880 882
881void PwM::activateMpButton(bool activate) 883void PwM::activateMpButton(bool activate)
882{ 884{
883 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, activate); 885 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, activate);
884} 886}
885 887
886void PwM::closeEvent(QCloseEvent *e) 888void PwM::closeEvent(QCloseEvent *e)
887{ 889{
888 e->accept(); 890 e->accept();
889} 891}
890 892
891void PwM::docClosed(PwMDoc *doc) 893void PwM::docClosed(PwMDoc *doc)
892{ 894{
893 PARAM_UNUSED(doc); 895 PARAM_UNUSED(doc);
894 PWM_ASSERT(doc == curDoc()); 896 PWM_ASSERT(doc == curDoc());
895 close(); 897 close();
896} 898}
897 899
898void PwM::find_slot() 900void PwM::find_slot()
899{ 901{
900 PWM_ASSERT(curDoc()); 902 PWM_ASSERT(curDoc());
901 if (curDoc()->isDocEmpty()) 903 if (curDoc()->isDocEmpty())
902 return; 904 return;
903 if (curDoc()->isDeepLocked()) 905 if (curDoc()->isDeepLocked())
904 return; 906 return;
905 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 907 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
906 FindWndImpl findWnd(view); 908 FindWndImpl findWnd(view);
907 findWnd.exec(); 909 findWnd.exec();
908 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 910 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
909} 911}
910 912
911void PwM::exportToText() 913void PwM::exportToText()
912{ 914{
913 PWM_ASSERT(curDoc()); 915 PWM_ASSERT(curDoc());
914 if (curDoc()->isDocEmpty()) { 916 if (curDoc()->isDocEmpty()) {
915 KMessageBox::information(this, 917 KMessageBox::information(this,
916 i18n 918 i18n
917 ("Sorry, there's nothing to export.\n" 919 ("Sorry, there's nothing to export.\n"
918 "Please first add some passwords."), 920 "Please first add some passwords."),
919 i18n("nothing to do")); 921 i18n("nothing to do"));
920 return; 922 return;
921 } 923 }
922 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 924 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
923 QString fn(KFileDialog::getSaveFileName(QString::null, 925 QString fn(KFileDialog::getSaveFileName(QString::null,
924 i18n("*|plain-text file"), 926 i18n("*|plain-text file"),
925 this)); 927 this));
926 if (fn == "") { 928 if (fn == "") {
927 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 929 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
928 return; 930 return;
929 } 931 }
930 932
931 PwMerror ret = curDoc()->exportToText(&fn); 933 PwMerror ret = curDoc()->exportToText(&fn);
932 if (ret != e_success) { 934 if (ret != e_success) {
933 KMessageBox::error(this, 935 KMessageBox::error(this,
934 i18n("Error: Couldn't write to file.\n" 936 i18n("Error: Couldn't write to file.\n"
935 "Please check if you have permission to write\n" 937 "Please check if you have permission to write\n"
936 "to the file in that directory."), 938 "to the file in that directory."),
937 i18n("error while writing")); 939 i18n("error while writing"));
938 } else 940 } else
939 showStatMsg(i18n("Successfully exported data.")); 941 showStatMsg(i18n("Successfully exported data."));
940 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 942 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
941} 943}
942 944
943bool PwM::importFromText() 945bool PwM::importFromText()
944{ 946{
945 if (!isVirgin()) { 947 if (!isVirgin()) {
946 if (KMessageBox::questionYesNo(this, 948 if (KMessageBox::questionYesNo(this,
947 i18n("Do you want to import the data\n" 949 i18n("Do you want to import the data\n"
948 "into the current document? (If you\n" 950 "into the current document? (If you\n"
949 "select \"no\", a new document will be\n" 951 "select \"no\", a new document will be\n"
950 "opened.)"), 952 "opened.)"),
951 i18n("import into this document?")) 953 i18n("import into this document?"))
952 == KMessageBox::No) { 954 == KMessageBox::No) {
953 // import the data to a new window. 955 // import the data to a new window.
954 PwM *newInstance = init->createMainWnd(); 956 PwM *newInstance = init->createMainWnd();
955 bool ok = newInstance->importFromText(); 957 bool ok = newInstance->importFromText();
956 if (!ok) { 958 if (!ok) {
957 newInstance->setForceQuit(true); 959 newInstance->setForceQuit(true);
958 delete_and_null(newInstance); 960 delete_and_null(newInstance);
959 } 961 }
960 return ok; 962 return ok;
961 } 963 }
962 } 964 }
963 965
964 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 966 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
965 PwMerror ret; 967 PwMerror ret;
966 QString path(KFileDialog::getOpenFileName(QString::null, 968 QString path(KFileDialog::getOpenFileName(QString::null,
967 i18n("*|PWM-exported text file"), 969 i18n("*|PWM-exported text file"),
968 this)); 970 this));
969 if (path == "") 971 if (path == "")
970 goto cancelImport; 972 goto cancelImport;
971 973
972 ret = curDoc()->importFromText(&path, 0); 974 ret = curDoc()->importFromText(&path, 0);
973 if (ret == e_fileFormat) { 975 if (ret == e_fileFormat) {
974 KMessageBox::error(this, 976 KMessageBox::error(this,
975 i18n("Could not read file-format.\n" 977 i18n("Could not read file-format.\n"
976 "This seems to be _not_ a valid file\n" 978 "This seems to be _not_ a valid file\n"
977 "exported by PwM."), 979 "exported by PwM."),
978 i18n("invalid file-format")); 980 i18n("invalid file-format"));
979 goto cancelImport; 981 goto cancelImport;
980 } else if (ret == e_invalidArg) { 982 } else if (ret == e_invalidArg) {
981 BUG(); 983 BUG();
982 goto cancelImport; 984 goto cancelImport;
983 } else if (ret != e_success) { 985 } else if (ret != e_success) {
984 KMessageBox::error(this, 986 KMessageBox::error(this,
985 i18n("Could not import file!\n" 987 i18n("Could not import file!\n"
986 "Do you have permission to read this file?\n" 988 "Do you have permission to read this file?\n"
987 "Do you have enough free memory?"), 989 "Do you have enough free memory?"),
988 i18n("import failed")); 990 i18n("import failed"));
989 goto cancelImport; 991 goto cancelImport;
990 } 992 }
991 setVirgin(false); 993 setVirgin(false);
992 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 994 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
993 return true; 995 return true;
994 996
995cancelImport: 997cancelImport:
996 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 998 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
997 return false; 999 return false;
998} 1000}
999 1001
1000void PwM::exportToGpasman() 1002void PwM::exportToGpasman()
1001{ 1003{
1002 PWM_ASSERT(curDoc()); 1004 PWM_ASSERT(curDoc());
1003 if (curDoc()->isDocEmpty()) { 1005 if (curDoc()->isDocEmpty()) {
1004 KMessageBox::information(this, 1006 KMessageBox::information(this,
1005 i18n 1007 i18n
1006 ("Sorry, there's nothing to export.\n" 1008 ("Sorry, there's nothing to export.\n"
1007 "Please first add some passwords."), 1009 "Please first add some passwords."),
1008 i18n("nothing to do")); 1010 i18n("nothing to do"));
1009 return; 1011 return;
1010 } 1012 }
1011 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1013 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1012 QString fn(KFileDialog::getSaveFileName(QString::null, 1014 QString fn(KFileDialog::getSaveFileName(QString::null,
1013 i18n("*|Gpasman or Kpasman file"), 1015 i18n("*|Gpasman or Kpasman file"),
1014 this)); 1016 this));
1015 if (fn == "") { 1017 if (fn == "") {
1016 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1018 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1017 return; 1019 return;
1018 } 1020 }
1019 1021
1020 PwMerror ret = curDoc()->exportToGpasman(&fn); 1022 PwMerror ret = curDoc()->exportToGpasman(&fn);
1021 if (ret != e_success) { 1023 if (ret != e_success) {
1022 if (ret == e_noPw) { 1024 if (ret == e_noPw) {
1023 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1025 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1024 return; 1026 return;
1025 } 1027 }
1026 KMessageBox::error(this, 1028 KMessageBox::error(this,
1027 i18n("Error: Couldn't write to file.\n" 1029 i18n("Error: Couldn't write to file.\n"
1028 "Please check if you have permission to write " 1030 "Please check if you have permission to write "
1029 "to the file in that directory."), 1031 "to the file in that directory."),
1030 i18n("error while writing")); 1032 i18n("error while writing"));
1031 } else 1033 } else
1032 showStatMsg(i18n("Successfully exported data.")); 1034 showStatMsg(i18n("Successfully exported data."));
1033 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1035 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1034} 1036}
1035 1037
1036 1038
1037 1039
1038void PwM::exportToCsv() 1040void PwM::exportToCsv()
1039{ 1041{
1040 PWM_ASSERT(curDoc()); 1042 PWM_ASSERT(curDoc());
1041 if (curDoc()->isDocEmpty()) { 1043 if (curDoc()->isDocEmpty()) {
1042 KMessageBox::information(this, 1044 KMessageBox::information(this,
1043 i18n 1045 i18n
1044 ("Sorry, there is nothing to export;\n" 1046 ("Sorry, there is nothing to export;\n"
1045 "please add some passwords first."), 1047 "please add some passwords first."),
1046 i18n("Nothing to Do")); 1048 i18n("Nothing to Do"));
1047 return; 1049 return;
1048 } 1050 }
1049 1051
1050 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1052 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1051 QString fn(KFileDialog::getSaveFileName("*.csv", i18n("*|CSV Text File"), this)); 1053 QString fn(KFileDialog::getSaveFileName("*.csv", i18n("*|CSV Text File"), this));
1052 if (fn.isEmpty()) { 1054 if (fn.isEmpty()) {
1053 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1055 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1054 return; 1056 return;
1055 } 1057 }
1056 1058
1057 Csv csv(this); 1059 Csv csv(this);
1058 if (!csv.exportData(fn, curDoc())) { 1060 if (!csv.exportData(fn, curDoc())) {
1059 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1061 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1060 showStatMsg(i18n("CSV file export failed.")); 1062 showStatMsg(i18n("CSV file export failed."));
1061 return; 1063 return;
1062 } 1064 }
1063 showStatMsg(i18n("Successfully exported data.")); 1065 showStatMsg(i18n("Successfully exported data."));
1064 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1066 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1065} 1067}
1066 1068
1067bool PwM::importCsv() 1069bool PwM::importCsv()
1068{ 1070{
1069 Csv csv(this); 1071 Csv csv(this);
1070 if (!isVirgin()) { 1072 if (!isVirgin()) {
1071 if (KMessageBox::questionYesNo(this, 1073 if (KMessageBox::questionYesNo(this,
1072 i18n("Do you want to import the data\n" 1074 i18n("Do you want to import the data\n"
1073 "into the current document? (If you\n" 1075 "into the current document? (If you\n"
1074 "select \"no\", a new document will be\n" 1076 "select \"no\", a new document will be\n"
1075 "opened.)"), 1077 "opened.)"),
1076 i18n("Import into This Document?")) 1078 i18n("Import into This Document?"))
1077 == KMessageBox::No) { 1079 == KMessageBox::No) {
1078 // import the data to a new window. 1080 // import the data to a new window.
1079 PwM *newInstance = init->createMainWnd(); 1081 PwM *newInstance = init->createMainWnd();
1080 bool ok = newInstance->importCsv(); 1082 bool ok = newInstance->importCsv();
1081 if (!ok) { 1083 if (!ok) {
1082 newInstance->setForceQuit(true); 1084 newInstance->setForceQuit(true);
1083 delete_and_null(newInstance); 1085 delete_and_null(newInstance);
1084 } 1086 }
1085 return ok; 1087 return ok;
1086 } 1088 }
1087 } 1089 }
1088 1090
1089 QString filename = KFileDialog::getOpenFileName("*.csv", i18n("*|CSV Text File"), this); 1091 QString filename = KFileDialog::getOpenFileName("*.csv", i18n("*|CSV Text File"), this);
1090 if (filename.isEmpty()) 1092 if (filename.isEmpty())
1091 return false; 1093 return false;
1092 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1094 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1093 if (!csv.importData(filename, curDoc())) { 1095 if (!csv.importData(filename, curDoc())) {
1094 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1096 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1095 showStatMsg(i18n("CSV file import failed.")); 1097 showStatMsg(i18n("CSV file import failed."));
1096 return false; 1098 return false;
1097 } 1099 }
1098 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1100 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1099 KMessageBox::information(this, 1101 KMessageBox::information(this,
1100 i18n("Successfully imported the CSV data\n" 1102 i18n("Successfully imported the CSV data\n"
1101 "into the current document."), i18n("Successfully Imported")); 1103 "into the current document."), i18n("Successfully Imported"));
1102 showStatMsg(i18n("Successfully imported")); 1104 showStatMsg(i18n("Successfully imported"));
1103 setVirgin(false); 1105 setVirgin(false);
1104 return true; 1106 return true;
1105} 1107}
1106 1108
1107 1109
1108void PwM::exportToKWallet() 1110void PwM::exportToKWallet()
1109{ 1111{
1110#ifdef CONFIG_KWALLETIF 1112#ifdef CONFIG_KWALLETIF
1111 if (!checkAndAskForKWalletEmu()) 1113 if (!checkAndAskForKWalletEmu())
1112 return; 1114 return;
1113 PWM_ASSERT(curDoc()); 1115 PWM_ASSERT(curDoc());
1114 if (curDoc()->isDocEmpty()) { 1116 if (curDoc()->isDocEmpty()) {
1115 KMessageBox::information(this, 1117 KMessageBox::information(this,
1116 i18n 1118 i18n
1117 ("Sorry, there's nothing to export.\n" 1119 ("Sorry, there's nothing to export.\n"
1118 "Please first add some passwords."), 1120 "Please first add some passwords."),
1119 i18n("nothing to do")); 1121 i18n("nothing to do"));
1120 init->initKWalletEmu(); 1122 init->initKWalletEmu();
1121 return; 1123 return;
1122 } 1124 }
1123 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1125 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1124 KWalletIf walletIf(this); 1126 KWalletIf walletIf(this);
1125 if (walletIf.kwalletExport(curDoc())) { 1127 if (walletIf.kwalletExport(curDoc())) {
1126 KMessageBox::information(this, 1128 KMessageBox::information(this,
1127 i18n("Successfully exported the data of the current " 1129 i18n("Successfully exported the data of the current "
1128 "document to KWallet."), 1130 "document to KWallet."),
1129 i18n("Successfully exported data.")); 1131 i18n("Successfully exported data."));
1130 showStatMsg(i18n("Successfully exported data.")); 1132 showStatMsg(i18n("Successfully exported data."));
1131 } 1133 }
1132 init->initKWalletEmu(); 1134 init->initKWalletEmu();
1133 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1135 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1134#endif // CONFIG_KWALLETIF 1136#endif // CONFIG_KWALLETIF
1135} 1137}
1136 1138
1137bool PwM::importFromGpasman() 1139bool PwM::importFromGpasman()
1138{ 1140{
1139 if (!isVirgin()) { 1141 if (!isVirgin()) {
1140 if (KMessageBox::questionYesNo(this, 1142 if (KMessageBox::questionYesNo(this,
1141 i18n("Do you want to import the data\n" 1143 i18n("Do you want to import the data\n"
1142 "into the current document? (If you\n" 1144 "into the current document? (If you\n"
1143 "select \"no\", a new document will be\n" 1145 "select \"no\", a new document will be\n"
1144 "opened.)"), 1146 "opened.)"),
1145 i18n("import into this document?")) 1147 i18n("import into this document?"))
1146 == KMessageBox::No) { 1148 == KMessageBox::No) {
1147 // import the data to a new window. 1149 // import the data to a new window.
1148 PwM *newInstance = init->createMainWnd(); 1150 PwM *newInstance = init->createMainWnd();
1149 bool ok = newInstance->importFromGpasman(); 1151 bool ok = newInstance->importFromGpasman();
1150 if (!ok) { 1152 if (!ok) {
1151 newInstance->setForceQuit(true); 1153 newInstance->setForceQuit(true);
1152 delete_and_null(newInstance); 1154 delete_and_null(newInstance);
1153 } 1155 }
1154 return ok; 1156 return ok;
1155 } 1157 }
1156 } 1158 }
1157 1159
1158 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1160 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1159 PwMerror ret; 1161 PwMerror ret;
1160 QString path(KFileDialog::getOpenFileName(QString::null, 1162 QString path(KFileDialog::getOpenFileName(QString::null,
1161 i18n("*|Gpasman or Kpasman file"), this)); 1163 i18n("*|Gpasman or Kpasman file"), this));
1162 if (path == "") 1164 if (path == "")
1163 goto cancelImport; 1165 goto cancelImport;
1164 ret = curDoc()->importFromGpasman(&path); 1166 ret = curDoc()->importFromGpasman(&path);
1165 if (ret == e_wrongPw) { 1167 if (ret == e_wrongPw) {
1166 if (KMessageBox::questionYesNo(this, 1168 if (KMessageBox::questionYesNo(this,
1167 i18n 1169 i18n
1168 ("This is probably the wrong master-password\n" 1170 ("This is probably the wrong master-password\n"
1169 "you have typed in.\n" 1171 "you have typed in.\n"
1170 "There is no real way to determine the\n" 1172 "There is no real way to determine the\n"
1171 "correctness of the password in the Gpasman\n" 1173 "correctness of the password in the Gpasman\n"
1172 "file-format. But I think this\n" 1174 "file-format. But I think this\n"
1173 "password ist wrong.\n" 1175 "password ist wrong.\n"
1174 "Do you want to continue nevertheless?"), 1176 "Do you want to continue nevertheless?"),
1175 i18n("password error")) 1177 i18n("password error"))
1176 == KMessageBox::No) { 1178 == KMessageBox::No) {
1177 goto cancelImport; 1179 goto cancelImport;
1178 } 1180 }
1179 } else if (ret != e_success) { 1181 } else if (ret != e_success) {
1180 KMessageBox::error(this, 1182 KMessageBox::error(this,
1181 i18n("Could not import file!\n" 1183 i18n("Could not import file!\n"
1182 "Do you have permission to read this file?"), 1184 "Do you have permission to read this file?"),
1183 i18n("import failed")); 1185 i18n("import failed"));
1184 goto cancelImport; 1186 goto cancelImport;
1185 } 1187 }
1186 setVirgin(false); 1188 setVirgin(false);
1187 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1189 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1188 return true; 1190 return true;
1189 1191
1190cancelImport: 1192cancelImport:
1191 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1193 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1192 return false; 1194 return false;
1193} 1195}
1194 1196
1195#ifdef CONFIG_KWALLETIF 1197#ifdef CONFIG_KWALLETIF
1196bool PwM::checkAndAskForKWalletEmu() 1198bool PwM::checkAndAskForKWalletEmu()
1197{ 1199{
1198 if (init->kwalletEmu()) { 1200 if (init->kwalletEmu()) {
1199 /* KWallet emulation is enabled. We can't import/export 1201 /* KWallet emulation is enabled. We can't import/export
1200 * data from/to it, while emulation is active. 1202 * data from/to it, while emulation is active.
1201 */ 1203 */
1202 if (KMessageBox::questionYesNo(this, 1204 if (KMessageBox::questionYesNo(this,
1203 i18n("KWallet emulation is enabled.\n" 1205 i18n("KWallet emulation is enabled.\n"
1204 "You can't import or export data from/to " 1206 "You can't import or export data from/to "
1205 "the original KWallet, while the emulation " 1207 "the original KWallet, while the emulation "
1206 "is active.\n" 1208 "is active.\n"
1207 "Do you want to tempoarly disable the KWallet emulation?"), 1209 "Do you want to tempoarly disable the KWallet emulation?"),
1208 i18n("Tempoarly disable KWallet emulation?")) 1210 i18n("Tempoarly disable KWallet emulation?"))
1209 == KMessageBox::Yes) { 1211 == KMessageBox::Yes) {
1210 init->initKWalletEmu(true); 1212 init->initKWalletEmu(true);
1211 PWM_ASSERT(!init->kwalletEmu()); 1213 PWM_ASSERT(!init->kwalletEmu());
1212 return true; 1214 return true;
1213 } 1215 }
1214 return false; 1216 return false;
1215 } 1217 }
1216 return true; 1218 return true;
1217} 1219}
1218#endif // CONFIG_KWALLETIF 1220#endif // CONFIG_KWALLETIF
1219 1221
1220bool PwM::importKWallet() 1222bool PwM::importKWallet()
1221{ 1223{
1222#ifdef CONFIG_KWALLETIF 1224#ifdef CONFIG_KWALLETIF
1223 if (!checkAndAskForKWalletEmu()) 1225 if (!checkAndAskForKWalletEmu())
1224 return false; 1226 return false;
1225 KWalletIf walletIf(this); 1227 KWalletIf walletIf(this);