summaryrefslogtreecommitdiffabout
path: root/pwmanager
Unidiff
Diffstat (limited to 'pwmanager') (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/libcrypt/cipher/cipher.pro2
-rw-r--r--pwmanager/libcrypt/error/error.pro4
-rw-r--r--pwmanager/libcrypt/mpi/mpi.pro2
-rw-r--r--pwmanager/libcrypt/zlib/zlib.pro2
-rw-r--r--pwmanager/pwmanager/addentrywnd_emb.cpp19
-rw-r--r--pwmanager/pwmanager/addentrywnd_emb.h17
-rw-r--r--pwmanager/pwmanager/addentrywndimpl.cpp6
-rw-r--r--pwmanager/pwmanager/addentrywndimpl.h10
-rw-r--r--pwmanager/pwmanager/binentrygen.h2
-rw-r--r--pwmanager/pwmanager/commentbox.cpp12
-rw-r--r--pwmanager/pwmanager/commentbox.h8
-rw-r--r--pwmanager/pwmanager/csv.cpp36
-rw-r--r--pwmanager/pwmanager/csv.h6
-rw-r--r--pwmanager/pwmanager/editcategory.cpp8
-rw-r--r--pwmanager/pwmanager/editcategory.h15
-rw-r--r--pwmanager/pwmanager/findwnd_emb.cpp8
-rw-r--r--pwmanager/pwmanager/findwndimpl.cpp4
-rw-r--r--pwmanager/pwmanager/genpasswd.cpp4
-rw-r--r--pwmanager/pwmanager/genpasswd.h4
-rw-r--r--pwmanager/pwmanager/getkeycardwnd.cpp13
-rw-r--r--pwmanager/pwmanager/getkeycardwnd.h12
-rw-r--r--pwmanager/pwmanager/getmasterpwwnd_emb.cpp9
-rw-r--r--pwmanager/pwmanager/getmasterpwwndimpl.cpp4
-rw-r--r--pwmanager/pwmanager/globalstuff.h4
-rw-r--r--pwmanager/pwmanager/htmlgen.cpp2
-rw-r--r--pwmanager/pwmanager/ipc.cpp12
-rw-r--r--pwmanager/pwmanager/ipc.h4
-rw-r--r--pwmanager/pwmanager/kcmconfigs/kcmpwmconfig.cpp4
-rw-r--r--pwmanager/pwmanager/kcmconfigs/pwmconfigwidget.cpp27
-rw-r--r--pwmanager/pwmanager/listobjselectwnd.cpp19
-rw-r--r--pwmanager/pwmanager/listobjselectwnd.h18
-rw-r--r--pwmanager/pwmanager/listviewpwm.cpp17
-rw-r--r--pwmanager/pwmanager/listviewpwm.h7
-rw-r--r--pwmanager/pwmanager/main.cpp1
-rw-r--r--pwmanager/pwmanager/printtext.h4
-rw-r--r--pwmanager/pwmanager/pwgenwnd_emb.cpp15
-rw-r--r--pwmanager/pwmanager/pwgenwndimpl.cpp2
-rw-r--r--pwmanager/pwmanager/pwgenwndimpl.h2
-rw-r--r--pwmanager/pwmanager/pwm.cpp68
-rw-r--r--pwmanager/pwmanager/pwm.h11
-rw-r--r--pwmanager/pwmanager/pwmanager.pro6
-rw-r--r--pwmanager/pwmanager/pwmanagerE.pro4
-rw-r--r--pwmanager/pwmanager/pwmdoc.cpp26
-rw-r--r--pwmanager/pwmanager/pwmdoc.h4
-rw-r--r--pwmanager/pwmanager/pwmdocui.cpp4
-rw-r--r--pwmanager/pwmanager/pwminit.cpp21
-rw-r--r--pwmanager/pwmanager/pwminit.h11
-rw-r--r--pwmanager/pwmanager/pwmprefs.h6
-rw-r--r--pwmanager/pwmanager/pwmtray.cpp23
-rw-r--r--pwmanager/pwmanager/pwmtray.h36
-rw-r--r--pwmanager/pwmanager/pwmview.cpp48
-rw-r--r--pwmanager/pwmanager/pwmview.h18
-rw-r--r--pwmanager/pwmanager/pwmviewstyle.cpp26
-rw-r--r--pwmanager/pwmanager/pwmviewstyle.h16
-rw-r--r--pwmanager/pwmanager/pwmviewstyle_0.cpp15
-rw-r--r--pwmanager/pwmanager/pwmviewstyle_0.h12
-rw-r--r--pwmanager/pwmanager/pwmviewstyle_1.cpp30
-rw-r--r--pwmanager/pwmanager/pwmviewstyle_1.h18
-rw-r--r--pwmanager/pwmanager/randomizer.cpp6
-rw-r--r--pwmanager/pwmanager/rencatwnd.cpp13
-rw-r--r--pwmanager/pwmanager/rencatwnd.h12
-rw-r--r--pwmanager/pwmanager/serializer.cpp18
-rw-r--r--pwmanager/pwmanager/serializer.h8
-rw-r--r--pwmanager/pwmanager/setmasterpwwnd_emb.cpp15
-rw-r--r--pwmanager/pwmanager/setmasterpwwnd_emb.h2
-rw-r--r--pwmanager/pwmanager/setmasterpwwndimpl.cpp4
-rw-r--r--pwmanager/pwmanager/waitwnd.cpp12
-rw-r--r--pwmanager/pwmanager/waitwnd.h9
68 files changed, 483 insertions, 364 deletions
diff --git a/pwmanager/libcrypt/cipher/cipher.pro b/pwmanager/libcrypt/cipher/cipher.pro
index ad96201..7e1a330 100644
--- a/pwmanager/libcrypt/cipher/cipher.pro
+++ b/pwmanager/libcrypt/cipher/cipher.pro
@@ -1,70 +1,72 @@
1###################################################################### 1######################################################################
2# Automatically generated by qmake (1.07a) Tue Oct 19 14:06:16 2004 2# Automatically generated by qmake (1.07a) Tue Oct 19 14:06:16 2004
3###################################################################### 3######################################################################
4 4
5TEMPLATE = lib 5TEMPLATE = lib
6INCLUDEPATH += . .. ../crypt ../error 6INCLUDEPATH += . .. ../crypt ../error
7 7
8CONFIG += staticlib 8CONFIG += staticlib
9OBJECTS_DIR = obj/$(PLATFORM) 9OBJECTS_DIR = obj/$(PLATFORM)
10MOC_DIR = moc/$(PLATFORM) 10MOC_DIR = moc/$(PLATFORM)
11DESTDIR= ../$(PLATFORM) 11DESTDIR= ../$(PLATFORM)
12 TARGET = kpmicrocipher 12 TARGET = kpmicrocipher
13 13
14# Input 14# Input
15HEADERS += bithelp.h rand-internal.h random.h rmd.h 15HEADERS += bithelp.h rand-internal.h random.h rmd.h
16SOURCES += ac.c \ 16SOURCES += ac.c \
17 arcfour.c \ 17 arcfour.c \
18 blowfish.c \ 18 blowfish.c \
19 cast5.c \ 19 cast5.c \
20 cipher.c \ 20 cipher.c \
21 crc.c \ 21 crc.c \
22 des.c \ 22 des.c \
23 dsa.c \ 23 dsa.c \
24 elgamal.c \ 24 elgamal.c \
25 md.c \ 25 md.c \
26 md4.c \ 26 md4.c \
27 md5.c \ 27 md5.c \
28 primegen.c \ 28 primegen.c \
29 pubkey.c \ 29 pubkey.c \
30 random.c \ 30 random.c \
31 rfc2268.c \ 31 rfc2268.c \
32 rijndael.c \ 32 rijndael.c \
33 rmd160.c \ 33 rmd160.c \
34 rndegd.c \ 34 rndegd.c \
35 rndlinux.c \ 35 rndlinux.c \
36 rndunix.c \ 36 rndunix.c \
37 rsa.c \ 37 rsa.c \
38 serpent.c \ 38 serpent.c \
39 sha1.c \ 39 sha1.c \
40 sha256.c \ 40 sha256.c \
41 sha512.c \ 41 sha512.c \
42 tiger.c \ 42 tiger.c \
43 twofish.c 43 twofish.c
44 44
45 # rndw32.c \ 45 # rndw32.c \
46 46
47 47
48HEADERS += ../crypt/ath.h \ 48HEADERS += ../crypt/ath.h \
49 ../crypt/cipher.h \ 49 ../crypt/cipher.h \
50 ../crypt/g10lib.h \ 50 ../crypt/g10lib.h \
51 ../crypt/gcrypt-module.h \ 51 ../crypt/gcrypt-module.h \
52 ../crypt/gcrypt.h \ 52 ../crypt/gcrypt.h \
53 ../crypt/mpi.h \ 53 ../crypt/mpi.h \
54 ../crypt/secmem.h \ 54 ../crypt/secmem.h \
55 ../crypt/stdmem.h \ 55 ../crypt/stdmem.h \
56 ../crypt/types.h 56 ../crypt/types.h
57SOURCES += ../crypt/ath.c \ 57SOURCES += ../crypt/ath.c \
58 ../crypt/global.c \ 58 ../crypt/global.c \
59 ../crypt/misc.c \ 59 ../crypt/misc.c \
60 ../crypt/missing-string.c \ 60 ../crypt/missing-string.c \
61 ../crypt/module.c \ 61 ../crypt/module.c \
62 ../crypt/secmem.c \ 62 ../crypt/secmem.c \
63 ../crypt/sexp.c \ 63 ../crypt/sexp.c \
64 ../crypt/stdmem.c 64 ../crypt/stdmem.c
65 65
66 66
67 67
68 68
69#LIBS += -L../$(PLATFORM) 69#LIBS += -L../$(PLATFORM)
70#LIBS += -lgcrypt -lmpi -lerror 70#LIBS += -lgcrypt -lmpi -lerror
71#The following line was inserted by qt3to4
72QT += xml qt3support
diff --git a/pwmanager/libcrypt/error/error.pro b/pwmanager/libcrypt/error/error.pro
index 8c5f667..e96bcee 100644
--- a/pwmanager/libcrypt/error/error.pro
+++ b/pwmanager/libcrypt/error/error.pro
@@ -1,32 +1,34 @@
1###################################################################### 1######################################################################
2# Automatically generated by qmake (1.07a) Tue Oct 19 15:09:32 2004 2# Automatically generated by qmake (1.07a) Tue Oct 19 15:09:32 2004
3###################################################################### 3######################################################################
4 4
5TEMPLATE = lib 5TEMPLATE = lib
6CONFIG += staticlib 6CONFIG += staticlib
7INCLUDEPATH += . 7INCLUDEPATH += .
8OBJECTS_DIR = obj/$(PLATFORM) 8OBJECTS_DIR = obj/$(PLATFORM)
9MOC_DIR = moc/$(PLATFORM) 9MOC_DIR = moc/$(PLATFORM)
10DESTDIR= ../$(PLATFORM) 10DESTDIR= ../$(PLATFORM)
11 TARGET = kpmicroerror 11 TARGET = kpmicroerror
12# Input 12# Input
13HEADERS += code-from-errno.h \ 13HEADERS += code-from-errno.h \
14 code-to-errno.h \ 14 code-to-errno.h \
15 err-codes-sym.h \ 15 err-codes-sym.h \
16 err-codes.h \ 16 err-codes.h \
17 err-sources-sym.h \ 17 err-sources-sym.h \
18 err-sources.h \ 18 err-sources.h \
19 errnos-sym.h \ 19 errnos-sym.h \
20 gettext.h 20 gettext.h
21 21
22SOURCES += code-from-errno.c \ 22SOURCES += code-from-errno.c \
23 code-to-errno.c \ 23 code-to-errno.c \
24 strerror-sym.c \ 24 strerror-sym.c \
25 strerror.c \ 25 strerror.c \
26 strsource-sym.c \ 26 strsource-sym.c \
27 strsource.c 27 strsource.c
28 28
29 # gpg-error.c \ 29 # gpg-error.c \
30 # gpg-error.h \ 30 # gpg-error.h \
31 # mkerrcodes.h 31 # mkerrcodes.h
32 # mkerrcodes.c \ \ No newline at end of file 32 # mkerrcodes.c \
33#The following line was inserted by qt3to4
34QT += xml qt3support
diff --git a/pwmanager/libcrypt/mpi/mpi.pro b/pwmanager/libcrypt/mpi/mpi.pro
index 4eb6346..d213bc3 100644
--- a/pwmanager/libcrypt/mpi/mpi.pro
+++ b/pwmanager/libcrypt/mpi/mpi.pro
@@ -1,42 +1,44 @@
1###################################################################### 1######################################################################
2# Automatically generated by qmake (1.07a) Tue Oct 19 15:37:52 2004 2# Automatically generated by qmake (1.07a) Tue Oct 19 15:37:52 2004
3###################################################################### 3######################################################################
4 4
5TEMPLATE = lib 5TEMPLATE = lib
6CONFIG += staticlib 6CONFIG += staticlib
7DEPENDPATH += generic 7DEPENDPATH += generic
8INCLUDEPATH += . .. ../crypt ../error 8INCLUDEPATH += . .. ../crypt ../error
9OBJECTS_DIR = obj/$(PLATFORM) 9OBJECTS_DIR = obj/$(PLATFORM)
10MOC_DIR = moc/$(PLATFORM) 10MOC_DIR = moc/$(PLATFORM)
11DESTDIR= ../$(PLATFORM) 11DESTDIR= ../$(PLATFORM)
12 TARGET = kpmicrompi 12 TARGET = kpmicrompi
13# Input 13# Input
14HEADERS += asm-syntax.h \ 14HEADERS += asm-syntax.h \
15 longlong.h \ 15 longlong.h \
16 generic/mpi-asm-defs.h \ 16 generic/mpi-asm-defs.h \
17 mpi-inline.h \ 17 mpi-inline.h \
18 mpi-internal.h \ 18 mpi-internal.h \
19 sysdep.h 19 sysdep.h
20SOURCES += mpi-add.c \ 20SOURCES += mpi-add.c \
21 mpi-bit.c \ 21 mpi-bit.c \
22 mpi-cmp.c \ 22 mpi-cmp.c \
23 mpi-div.c \ 23 mpi-div.c \
24 mpi-gcd.c \ 24 mpi-gcd.c \
25 mpi-inline.c \ 25 mpi-inline.c \
26 mpi-inv.c \ 26 mpi-inv.c \
27 mpi-mpow.c \ 27 mpi-mpow.c \
28 mpi-mul.c \ 28 mpi-mul.c \
29 mpi-pow.c \ 29 mpi-pow.c \
30 mpi-scan.c \ 30 mpi-scan.c \
31 mpicoder.c \ 31 mpicoder.c \
32 mpih-div.c \ 32 mpih-div.c \
33 mpih-mul.c \ 33 mpih-mul.c \
34 mpiutil.c \ 34 mpiutil.c \
35 generic/mpih-add1.c \ 35 generic/mpih-add1.c \
36 generic/mpih-lshift.c \ 36 generic/mpih-lshift.c \
37 generic/mpih-mul1.c \ 37 generic/mpih-mul1.c \
38 generic/mpih-mul2.c \ 38 generic/mpih-mul2.c \
39 generic/mpih-mul3.c \ 39 generic/mpih-mul3.c \
40 generic/mpih-rshift.c \ 40 generic/mpih-rshift.c \
41 generic/mpih-sub1.c \ 41 generic/mpih-sub1.c \
42 generic/udiv-w-sdiv.c 42 generic/udiv-w-sdiv.c
43#The following line was inserted by qt3to4
44QT += xml qt3support
diff --git a/pwmanager/libcrypt/zlib/zlib.pro b/pwmanager/libcrypt/zlib/zlib.pro
index 2841aaf..7ba44e3 100644
--- a/pwmanager/libcrypt/zlib/zlib.pro
+++ b/pwmanager/libcrypt/zlib/zlib.pro
@@ -1,36 +1,38 @@
1###################################################################### 1######################################################################
2# Automatically generated by qmake (1.07a) Tue Oct 19 14:18:17 2004 2# Automatically generated by qmake (1.07a) Tue Oct 19 14:18:17 2004
3###################################################################### 3######################################################################
4 4
5TEMPLATE = lib 5TEMPLATE = lib
6 CONFIG += staticlib 6 CONFIG += staticlib
7INCLUDEPATH += . 7INCLUDEPATH += .
8TARGET = zlib 8TARGET = zlib
9OBJECTS_DIR = obj/$(PLATFORM) 9OBJECTS_DIR = obj/$(PLATFORM)
10MOC_DIR = moc/$(PLATFORM) 10MOC_DIR = moc/$(PLATFORM)
11DESTDIR= ../$(PLATFORM) 11DESTDIR= ../$(PLATFORM)
12# Input 12# Input
13HEADERS += deflate.h \ 13HEADERS += deflate.h \
14 infblock.h \ 14 infblock.h \
15 infcodes.h \ 15 infcodes.h \
16 inffast.h \ 16 inffast.h \
17 inffixed.h \ 17 inffixed.h \
18 inftrees.h \ 18 inftrees.h \
19 infutil.h \ 19 infutil.h \
20 trees.h \ 20 trees.h \
21 zconf.h \ 21 zconf.h \
22 zlib.h \ 22 zlib.h \
23 zutil.h 23 zutil.h
24SOURCES += adler32.c \ 24SOURCES += adler32.c \
25 compress.c \ 25 compress.c \
26 crc32.c \ 26 crc32.c \
27 deflate.c \ 27 deflate.c \
28 infblock.c \ 28 infblock.c \
29 infcodes.c \ 29 infcodes.c \
30 inffast.c \ 30 inffast.c \
31 inflate.c \ 31 inflate.c \
32 inftrees.c \ 32 inftrees.c \
33 infutil.c \ 33 infutil.c \
34 trees.c \ 34 trees.c \
35 uncompr.c \ 35 uncompr.c \
36 zutil.c 36 zutil.c
37#The following line was inserted by qt3to4
38QT += xml qt3support
diff --git a/pwmanager/pwmanager/addentrywnd_emb.cpp b/pwmanager/pwmanager/addentrywnd_emb.cpp
index 2fa9e8a..f76d33b 100644
--- a/pwmanager/pwmanager/addentrywnd_emb.cpp
+++ b/pwmanager/pwmanager/addentrywnd_emb.cpp
@@ -1,233 +1,236 @@
1/* 1/*
2 This file is part of PwManager/Platform independent. 2 This file is part of PwManager/Platform independent.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22 22
23$Id$ 23$Id$
24*/ 24*/
25 25
26#include "addentrywnd_emb.h" 26#include "addentrywnd_emb.h"
27#include "pwmdoc.h" 27#include "pwmdoc.h"
28 28
29#include <qlayout.h> 29#include <qlayout.h>
30#include <qlabel.h> 30#include <qlabel.h>
31#include <qtabwidget.h> 31#include <qtabwidget.h>
32#include <qgroupbox.h> 32#include <q3groupbox.h>
33//Added by qt3to4:
34#include <Q3GridLayout>
35#include <Q3VBoxLayout>
33#include <klocale.h> 36#include <klocale.h>
34#include <kcombobox.h> 37#include <kcombobox.h>
35#include <klineedit.h> 38#include <klineedit.h>
36#include <qpushbutton.h> 39#include <qpushbutton.h>
37#include <qmultilineedit.h> 40#include <q3multilineedit.h>
38 41
39/* 42/*
40 * Constructs a addEntryWnd as a child of 'parent', with the 43 * Constructs a addEntryWnd as a child of 'parent', with the
41 * name 'name' and widget flags set to 'f'. 44 * name 'name' and widget flags set to 'f'.
42 * 45 *
43 * The dialog will by default be modeless, unless you set 'modal' to 46 * The dialog will by default be modeless, unless you set 'modal' to
44 * TRUE to construct a modal dialog. 47 * TRUE to construct a modal dialog.
45 */ 48 */
46addEntryWnd::addEntryWnd( PwMDoc* d, QWidget* parent, const char* name) 49addEntryWnd::addEntryWnd( PwMDoc* d, QWidget* parent, const char* name)
47 : KDialogBase( KDialogBase::Plain, i18n( "edit/add a password entry" ), 50 : KDialogBase( KDialogBase::Plain, i18n( "edit/add a password entry" ),
48 KDialogBase::Ok | KDialogBase::Cancel, 51 KDialogBase::Ok | KDialogBase::Cancel,
49 KDialogBase::Ok, parent, name, true ), doc(d) 52 KDialogBase::Ok, parent, name, true ), doc(d)
50{ 53{
51 QWidget *page = plainPage(); 54 QWidget *page = plainPage();
52 QVBoxLayout *pageLayout = new QVBoxLayout( page ); 55 Q3VBoxLayout *pageLayout = new Q3VBoxLayout( page );
53 56
54 QTabWidget* mTabWidget = new QTabWidget( page ); 57 QTabWidget* mTabWidget = new QTabWidget( page );
55 pageLayout->addWidget( mTabWidget ); 58 pageLayout->addWidget( mTabWidget );
56 59
57 //////////////////////////////////////////////////////////////////// 60 ////////////////////////////////////////////////////////////////////
58 // This is the Password tab 61 // This is the Password tab
59 QWidget *tab1 = new QWidget( mTabWidget ); 62 QWidget *tab1 = new QWidget( mTabWidget );
60 63
61 QGridLayout *layout = new QGridLayout( tab1, 3, 1 ); 64 Q3GridLayout *layout = new Q3GridLayout( tab1, 3, 1 );
62 layout->setMargin( KDialogBase::marginHint() ); 65 layout->setMargin( KDialogBase::marginHint() );
63 layout->setSpacing( KDialogBase::spacingHint() ); 66 layout->setSpacing( KDialogBase::spacingHint() );
64 67
65 68
66 69
67 int i = 0; 70 int i = 0;
68 descLineEdit = new KLineEdit( tab1, "descLineEdit" ); 71 descLineEdit = new KLineEdit( tab1, "descLineEdit" );
69 descLineLabel = new QLabel( descLineEdit, i18n("Description:"), tab1 ); 72 descLineLabel = new QLabel( descLineEdit, i18n("Description:"), tab1 );
70 layout->addWidget( descLineLabel, i, 0 ); 73 layout->addWidget( descLineLabel, i, 0 );
71 layout->addWidget( descLineEdit, i, 1 ); 74 layout->addWidget( descLineEdit, i, 1 );
72 i++; 75 i++;
73 76
74 categoryComboBox = new KComboBox( tab1 ); 77 categoryComboBox = new KComboBox( tab1 );
75 QLabel* label = new QLabel( categoryComboBox, i18n("Category:"), tab1 ); 78 QLabel* label = new QLabel( categoryComboBox, i18n("Category:"), tab1 );
76 layout->addWidget( label, i, 0 ); 79 layout->addWidget( label, i, 0 );
77 layout->addWidget( categoryComboBox, i, 1 ); 80 layout->addWidget( categoryComboBox, i, 1 );
78 i++; 81 i++;
79 categoryComboBox->setEditable( TRUE ); 82 categoryComboBox->setEditable( TRUE );
80 categoryComboBox->setSizeLimit( 8 ); 83 categoryComboBox->setMaxVisibleItems( 8 );
81 categoryComboBox->setAutoCompletion( TRUE ); 84 categoryComboBox->setAutoCompletion( TRUE );
82 categoryComboBox->setDuplicatesEnabled( FALSE ); 85 categoryComboBox->setDuplicatesEnabled( FALSE );
83 connect(categoryComboBox,SIGNAL(activated(const QString&)), SLOT(categorySelected(const QString&))); 86 connect(categoryComboBox,SIGNAL(activated(const QString&)), SLOT(categorySelected(const QString&)));
84 87
85 88
86 usernameLineEdit = new KLineEdit( tab1, "usernameLineEdit" ); 89 usernameLineEdit = new KLineEdit( tab1, "usernameLineEdit" );
87 usernameLineLabel = new QLabel( usernameLineEdit, i18n("Username:"), tab1 ); 90 usernameLineLabel = new QLabel( usernameLineEdit, i18n("Username:"), tab1 );
88 layout->addWidget( usernameLineLabel, i, 0 ); 91 layout->addWidget( usernameLineLabel, i, 0 );
89 layout->addWidget( usernameLineEdit, i, 1 ); 92 layout->addWidget( usernameLineEdit, i, 1 );
90 i++; 93 i++;
91 94
92 pwLineEdit = new KLineEdit( tab1, "pwLineEdit" ); 95 pwLineEdit = new KLineEdit( tab1, "pwLineEdit" );
93 pwLineEdit->setEchoMode( QLineEdit::Password ); 96 pwLineEdit->setEchoMode( QLineEdit::Password );
94 pwLineLabel = new QLabel( pwLineEdit, i18n("Password:"), tab1 ); 97 pwLineLabel = new QLabel( pwLineEdit, i18n("Password:"), tab1 );
95 layout->addWidget( pwLineLabel, i, 0 ); 98 layout->addWidget( pwLineLabel, i, 0 );
96 layout->addWidget( pwLineEdit, i, 1 ); 99 layout->addWidget( pwLineEdit, i, 1 );
97 i++; 100 i++;
98 101
99 revealButton = new QPushButton( i18n("&Reveal"), tab1, "revealButton" ); 102 revealButton = new QPushButton( i18n("&Reveal"), tab1, "revealButton" );
100 revealButton->setToggleButton( TRUE ); 103 revealButton->setToggleButton( TRUE );
101 layout->addWidget( revealButton, i, 0 ); 104 layout->addWidget( revealButton, i, 0 );
102 105
103 generateButton = new QPushButton( i18n("&Generate"), tab1, "generateButton" ); 106 generateButton = new QPushButton( i18n("&Generate"), tab1, "generateButton" );
104 layout->addWidget( generateButton, i, 1 ); 107 layout->addWidget( generateButton, i, 1 );
105 i++; 108 i++;
106 109
107 urlLineEdit = new KLineEdit( tab1, "urlLineEdit" ); 110 urlLineEdit = new KLineEdit( tab1, "urlLineEdit" );
108 label = new QLabel( urlLineEdit, i18n("URL:"), tab1 ); 111 label = new QLabel( urlLineEdit, i18n("URL:"), tab1 );
109 layout->addWidget( label, i, 0 ); 112 layout->addWidget( label, i, 0 );
110 layout->addWidget( urlLineEdit, i, 1 ); 113 layout->addWidget( urlLineEdit, i, 1 );
111 i++; 114 i++;
112 115
113 mTabWidget->addTab( tab1, i18n( "&Password" ) ); 116 mTabWidget->addTab( tab1, i18n( "&Password" ) );
114 117
115 118
116 //////////////////////////////////////////////////////////////////// 119 ////////////////////////////////////////////////////////////////////
117 // This is the Comment tab 120 // This is the Comment tab
118 QWidget *tab2 = new QWidget( mTabWidget ); 121 QWidget *tab2 = new QWidget( mTabWidget );
119 122
120 layout = new QGridLayout( tab2, 3, 1 ); 123 layout = new Q3GridLayout( tab2, 3, 1 );
121 layout->setMargin( KDialogBase::marginHintSmall() ); 124 layout->setMargin( KDialogBase::marginHintSmall() );
122 layout->setSpacing( KDialogBase::spacingHintSmall() ); 125 layout->setSpacing( KDialogBase::spacingHintSmall() );
123 i = 0; 126 i = 0;
124 127
125 commentTextEdit = new QMultiLineEdit(tab2); 128 commentTextEdit = new Q3MultiLineEdit(tab2);
126 layout->addMultiCellWidget( commentTextEdit, i, i, 0, 0 ); 129 layout->addMultiCellWidget( commentTextEdit, i, i, 0, 0 );
127 i++; 130 i++;
128 131
129 132
130 mTabWidget->addTab( tab2, i18n( "&Comments" ) ); 133 mTabWidget->addTab( tab2, i18n( "&Comments" ) );
131 134
132 135
133 //////////////////////////////////////////////////////////////////// 136 ////////////////////////////////////////////////////////////////////
134 // This is the Launcher tab 137 // This is the Launcher tab
135 QWidget *tab3 = new QWidget( mTabWidget ); 138 QWidget *tab3 = new QWidget( mTabWidget );
136 139
137 layout = new QGridLayout( tab3, 3, 1 ); 140 layout = new Q3GridLayout( tab3, 3, 1 );
138 layout->setMargin( KDialogBase::marginHintSmall() ); 141 layout->setMargin( KDialogBase::marginHintSmall() );
139 layout->setSpacing( KDialogBase::spacingHintSmall() ); 142 layout->setSpacing( KDialogBase::spacingHintSmall() );
140 i = 0; 143 i = 0;
141 144
142 launcherLineEdit = new KLineEdit( tab3, "launcherLineEdit" ); 145 launcherLineEdit = new KLineEdit( tab3, "launcherLineEdit" );
143 label = new QLabel( launcherLineEdit, i18n("Launcher:"), tab3 ); 146 label = new QLabel( launcherLineEdit, i18n("Launcher:"), tab3 );
144 147
145 QLabel* label1 = new QLabel( launcherLineEdit, i18n("$d = Description"), tab3 ); 148 QLabel* label1 = new QLabel( launcherLineEdit, i18n("$d = Description"), tab3 );
146 QLabel* label2 = new QLabel( launcherLineEdit, i18n("$n = Username"), tab3 ); 149 QLabel* label2 = new QLabel( launcherLineEdit, i18n("$n = Username"), tab3 );
147 QLabel* label3 = new QLabel( launcherLineEdit, i18n("$c = Comment"), tab3 ); 150 QLabel* label3 = new QLabel( launcherLineEdit, i18n("$c = Comment"), tab3 );
148 QLabel* label4 = new QLabel( launcherLineEdit, i18n("$u = URL"), tab3 ); 151 QLabel* label4 = new QLabel( launcherLineEdit, i18n("$u = URL"), tab3 );
149 QLabel* label5 = new QLabel( launcherLineEdit, i18n("$p = Password"), tab3 ); 152 QLabel* label5 = new QLabel( launcherLineEdit, i18n("$p = Password"), tab3 );
150 153
151 label = new QLabel( launcherLineEdit, i18n("Launcher:"), tab3 ); 154 label = new QLabel( launcherLineEdit, i18n("Launcher:"), tab3 );
152 155
153 layout->addWidget( label1, i, 0 ); 156 layout->addWidget( label1, i, 0 );
154 layout->addWidget( label2, i, 1 ); 157 layout->addWidget( label2, i, 1 );
155 i++; 158 i++;
156 layout->addWidget( label3, i, 0 ); 159 layout->addWidget( label3, i, 0 );
157 layout->addWidget( label4, i, 1 ); 160 layout->addWidget( label4, i, 1 );
158 i++; 161 i++;
159 layout->addWidget( label5, i, 0 ); 162 layout->addWidget( label5, i, 0 );
160 i++; 163 i++;
161 164
162 layout->addWidget( label, i, 0 ); 165 layout->addWidget( label, i, 0 );
163 layout->addWidget( launcherLineEdit, i, 1 ); 166 layout->addWidget( launcherLineEdit, i, 1 );
164 i++; 167 i++;
165 168
166 169
167 mTabWidget->addTab( tab3, i18n( "&Launcher" ) ); 170 mTabWidget->addTab( tab3, i18n( "&Launcher" ) );
168 171
169 // signals and slots connections 172 // signals and slots connections
170 connect( generateButton, SIGNAL( clicked() ), this, SLOT( generateButton_slot() ) ); 173 connect( generateButton, SIGNAL( clicked() ), this, SLOT( generateButton_slot() ) );
171 connect( revealButton, SIGNAL( toggled(bool) ), this, SLOT( revealButton_slot() ) ); 174 connect( revealButton, SIGNAL( toggled(bool) ), this, SLOT( revealButton_slot() ) );
172 175
173#if 0 176#if 0
174 if ( QApplication::desktop()->width() <= 640 && QApplication::desktop()->width() >= 480 ) { 177 if ( QApplication::desktop()->width() <= 640 && QApplication::desktop()->width() >= 480 ) {
175 resize ( 440, 400 ); 178 resize ( 440, 400 );
176 } 179 }
177#endif 180#endif
178 181
179} 182}
180 183
181/* 184/*
182 * Destroys the object and frees any allocated resources 185 * Destroys the object and frees any allocated resources
183 */ 186 */
184addEntryWnd::~addEntryWnd() 187addEntryWnd::~addEntryWnd()
185{ 188{
186 // no need to delete child widgets, Qt does it all for us 189 // no need to delete child widgets, Qt does it all for us
187} 190}
188 191
189void addEntryWnd::slotOk() 192void addEntryWnd::slotOk()
190{ 193{
191 qWarning( "addEntryWnd::slotOk(): Not implemented yet" ); 194 qWarning( "addEntryWnd::slotOk(): Not implemented yet" );
192} 195}
193 196
194void addEntryWnd::revealButton_slot() 197void addEntryWnd::revealButton_slot()
195{ 198{
196 qWarning( "addEntryWnd::revealButton_slot(): Not implemented yet" ); 199 qWarning( "addEntryWnd::revealButton_slot(): Not implemented yet" );
197} 200}
198 201
199void addEntryWnd::generateButton_slot() 202void addEntryWnd::generateButton_slot()
200{ 203{
201 qWarning( "addEntryWnd::generateButton_slot(): Not implemented yet" ); 204 qWarning( "addEntryWnd::generateButton_slot(): Not implemented yet" );
202} 205}
203 206
204void addEntryWnd::advancedCommentButton_slot(bool) 207void addEntryWnd::advancedCommentButton_slot(bool)
205{ 208{
206 qWarning( "addEntryWnd::advancedCommentButton_slot(bool): Not implemented yet" ); 209 qWarning( "addEntryWnd::advancedCommentButton_slot(bool): Not implemented yet" );
207} 210}
208 211
209void addEntryWnd::categorySelected ( const QString & string ) 212void addEntryWnd::categorySelected ( const QString & string )
210{ 213{
211 unsigned int idx; 214 unsigned int idx;
212 bool found = doc->findCategory(string, &idx); 215 bool found = doc->findCategory(string, &idx);
213 216
214 if (found == true) 217 if (found == true)
215 { 218 {
216 qDebug("addEntryWnd::categorySelected found"); 219 qDebug("addEntryWnd::categorySelected found");
217 PwMCategoryItem* catitem = doc->getCategoryEntry(idx); 220 PwMCategoryItem* catitem = doc->getCategoryEntry(idx);
218 221
219 descLineLabel->setText(catitem->desc_text.c_str()); 222 descLineLabel->setText(catitem->desc_text.c_str());
220 usernameLineLabel->setText(catitem->name_text.c_str()); 223 usernameLineLabel->setText(catitem->name_text.c_str());
221 pwLineLabel->setText(catitem->pw_text.c_str()); 224 pwLineLabel->setText(catitem->pw_text.c_str());
222 return; 225 return;
223 } 226 }
224 else 227 else
225 { 228 {
226 qDebug("addEntryWnd::categorySelected NOT found"); 229 qDebug("addEntryWnd::categorySelected NOT found");
227 BUG(); 230 BUG();
228 } 231 }
229 232
230 233
231} 234}
232 235
233 236
diff --git a/pwmanager/pwmanager/addentrywnd_emb.h b/pwmanager/pwmanager/addentrywnd_emb.h
index 966d9d2..ad7d30c 100644
--- a/pwmanager/pwmanager/addentrywnd_emb.h
+++ b/pwmanager/pwmanager/addentrywnd_emb.h
@@ -1,78 +1,83 @@
1/* 1/*
2 This file is part of PwManager/Platform independent. 2 This file is part of PwManager/Platform independent.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22 22
23$Id$ 23$Id$
24*/ 24*/
25 25
26#ifndef ADDENTRYWND_EMB_H 26#ifndef ADDENTRYWND_EMB_H
27#define ADDENTRYWND_EMB_H 27#define ADDENTRYWND_EMB_H
28 28
29#include <qvariant.h> 29#include <qvariant.h>
30//Added by qt3to4:
31#include <Q3VBoxLayout>
32#include <Q3GridLayout>
33#include <Q3HBoxLayout>
34#include <QLabel>
30#include <kdialogbase.h> 35#include <kdialogbase.h>
31 36
32class QVBoxLayout; 37class Q3VBoxLayout;
33class QHBoxLayout; 38class Q3HBoxLayout;
34class QGridLayout; 39class Q3GridLayout;
35class QSpacerItem; 40class QSpacerItem;
36class KLineEdit; 41class KLineEdit;
37class QPushButton; 42class QPushButton;
38class KComboBox; 43class KComboBox;
39class QLabel; 44class QLabel;
40class QGroupBox; 45class Q3GroupBox;
41class QMultiLineEdit; 46class Q3MultiLineEdit;
42class PwMDoc; 47class PwMDoc;
43 48
44class addEntryWnd : public KDialogBase 49class addEntryWnd : public KDialogBase
45{ 50{
46 Q_OBJECT 51 Q_OBJECT
47 52
48public: 53public:
49 addEntryWnd( PwMDoc* doc, QWidget* parent = 0, const char* name = 0); 54 addEntryWnd( PwMDoc* doc, QWidget* parent = 0, const char* name = 0);
50 ~addEntryWnd(); 55 ~addEntryWnd();
51 56
52 KLineEdit* launcherLineEdit; 57 KLineEdit* launcherLineEdit;
53 QPushButton* generateButton; 58 QPushButton* generateButton;
54 KLineEdit* descLineEdit; 59 KLineEdit* descLineEdit;
55 KComboBox* categoryComboBox; 60 KComboBox* categoryComboBox;
56 KLineEdit* usernameLineEdit; 61 KLineEdit* usernameLineEdit;
57 KLineEdit* pwLineEdit; 62 KLineEdit* pwLineEdit;
58 KLineEdit* urlLineEdit; 63 KLineEdit* urlLineEdit;
59 QLabel* descLineLabel; 64 QLabel* descLineLabel;
60 QLabel* usernameLineLabel; 65 QLabel* usernameLineLabel;
61 QLabel* pwLineLabel; 66 QLabel* pwLineLabel;
62 67
63 QPushButton* revealButton; 68 QPushButton* revealButton;
64 QMultiLineEdit* commentTextEdit; 69 Q3MultiLineEdit* commentTextEdit;
65 PwMDoc* doc; 70 PwMDoc* doc;
66 71
67public slots: 72public slots:
68 virtual void revealButton_slot(); 73 virtual void revealButton_slot();
69 virtual void generateButton_slot(); 74 virtual void generateButton_slot();
70 virtual void advancedCommentButton_slot(bool on); 75 virtual void advancedCommentButton_slot(bool on);
71 76
72 protected slots: 77 protected slots:
73 virtual void slotOk(); 78 virtual void slotOk();
74 virtual void categorySelected ( const QString & string ); 79 virtual void categorySelected ( const QString & string );
75 80
76}; 81};
77 82
78#endif // ADDENTRYWND_H 83#endif // ADDENTRYWND_H
diff --git a/pwmanager/pwmanager/addentrywndimpl.cpp b/pwmanager/pwmanager/addentrywndimpl.cpp
index 09efd1c..c952ead 100644
--- a/pwmanager/pwmanager/addentrywndimpl.cpp
+++ b/pwmanager/pwmanager/addentrywndimpl.cpp
@@ -1,221 +1,221 @@
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 * Many very good improvements and the original implementations of * 6 * Many very good improvements and the original implementations of *
7 * them came from Matt Scifo <mscifo@o1.com> * 7 * them came from Matt Scifo <mscifo@o1.com> *
8 * * 8 * *
9 * This program is free software; you can redistribute it and/or modify * 9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License version 2 * 10 * it under the terms of the GNU General Public License version 2 *
11 * as published by the Free Software Foundation. * 11 * as published by the Free Software Foundation. *
12 * * 12 * *
13 ***************************************************************************/ 13 ***************************************************************************/
14 14
15/*************************************************************************** 15/***************************************************************************
16 * copyright (C) 2004 by Ulf Schenk 16 * copyright (C) 2004 by Ulf Schenk
17 * This file is originaly based on version 1.0.1 of pwmanager 17 * This file is originaly based on version 1.0.1 of pwmanager
18 * and was modified to run on embedded devices that run microkde 18 * and was modified to run on embedded devices that run microkde
19 * 19 *
20 * $Id$ 20 * $Id$
21 **************************************************************************/ 21 **************************************************************************/
22 22
23#include "addentrywndimpl.h" 23#include "addentrywndimpl.h"
24#include "pwmexception.h" 24#include "pwmexception.h"
25#include "pwgenwndimpl.h" 25#include "pwgenwndimpl.h"
26#ifndef PWM_EMBEDDED 26#ifndef PWM_EMBEDDED
27#include "advcommeditimpl.h" 27#include "advcommeditimpl.h"
28#endif 28#endif
29#include "htmlgen.h" 29#include "htmlgen.h"
30 30
31#include <kmessagebox.h> 31#include <kmessagebox.h>
32#include <klocale.h> 32#include <klocale.h>
33 33
34#include <qpushbutton.h> 34#include <qpushbutton.h>
35#include <qlabel.h> 35#include <qlabel.h>
36#include <qlayout.h> 36#include <qlayout.h>
37 37
38 38
39#ifndef PWM_EMBEDDED 39#ifndef PWM_EMBEDDED
40AddEntryWndImpl::AddEntryWndImpl() 40AddEntryWndImpl::AddEntryWndImpl()
41 : addEntryWnd( 0, "AddEntryWndImpl", TRUE) 41 : addEntryWnd( 0, "AddEntryWndImpl", TRUE)
42#else 42#else
43AddEntryWndImpl::AddEntryWndImpl( PwMDoc* doc, QWidget* parent, const char* name) 43AddEntryWndImpl::AddEntryWndImpl( PwMDoc* doc, QWidget* parent, const char* name)
44 : addEntryWnd( doc, parent, name) 44 : addEntryWnd( doc, parent, name)
45#endif 45#endif
46{ 46{
47 categoryComboBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding,QSizePolicy::Preferred )); 47 categoryComboBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding,QSizePolicy::Preferred ));
48#ifndef PWM_EMBEDDED 48#ifndef PWM_EMBEDDED
49 editAdvCommentButton = 0; 49 editAdvCommentButton = 0;
50 commentTextEdit = 0; 50 commentTextEdit = 0;
51#endif 51#endif
52 switchComment(false); 52 switchComment(false);
53 pwGen = new PwGenWndImpl(this); 53 pwGen = new PwGenWndImpl(this);
54} 54}
55 55
56AddEntryWndImpl::~AddEntryWndImpl() 56AddEntryWndImpl::~AddEntryWndImpl()
57{ 57{
58#ifndef PWM_EMBEDDED 58#ifndef PWM_EMBEDDED
59 delete_ifnot_null(editAdvCommentButton); 59 delete_ifnot_null(editAdvCommentButton);
60 delete_ifnot_null(commentTextEdit); 60 delete_ifnot_null(commentTextEdit);
61#endif 61#endif
62 delete pwGen; 62 delete pwGen;
63} 63}
64 64
65#ifdef PWM_EMBEDDED 65#ifdef PWM_EMBEDDED
66void AddEntryWndImpl::slotOk() 66void AddEntryWndImpl::slotOk()
67{ 67{
68 slotApply(); 68 slotApply();
69 69
70 if (pwLineEdit->text().isEmpty()) { 70 if (pwLineEdit->text().isEmpty()) {
71 KMessageBox::error(this, 71 KMessageBox::error(this,
72 i18n("Sorry, you haven't set a password."), 72 i18n("Sorry, you haven't set a password."),
73 i18n("no password")); 73 i18n("no password"));
74 return; 74 return;
75 } 75 }
76 76
77 if (descLineEdit->text().isEmpty()) { 77 if (descLineEdit->text().isEmpty()) {
78 KMessageBox::error(this, 78 KMessageBox::error(this,
79 i18n("You haven't set a \"Description\"."), 79 i18n("You haven't set a \"Description\"."),
80 i18n("Description not set")); 80 i18n("Description not set"));
81 return; 81 return;
82 } 82 }
83 83
84 KDialogBase::slotOk(); 84 KDialogBase::slotOk();
85} 85}
86#else 86#else
87 87
88void AddEntryWndImpl::okButton_slot() 88void AddEntryWndImpl::okButton_slot()
89{ 89{
90 if (pwLineEdit->text().isEmpty()) { 90 if (pwLineEdit->text().isEmpty()) {
91 KMessageBox::error(this, 91 KMessageBox::error(this,
92 i18n("Sorry, you haven't set a password."), 92 i18n("Sorry, you haven't set a password."),
93 i18n("no password")); 93 i18n("no password"));
94 return; 94 return;
95 } 95 }
96 if (descLineEdit->text().isEmpty()) { 96 if (descLineEdit->text().isEmpty()) {
97 KMessageBox::error(this, 97 KMessageBox::error(this,
98 i18n 98 i18n
99 ("You haven't set a \"Description\"."), 99 ("You haven't set a \"Description\"."),
100 i18n("Description not set")); 100 i18n("Description not set"));
101 return; 101 return;
102 } 102 }
103 done(1); 103 done(1);
104} 104}
105 105
106void AddEntryWndImpl::cancelButton_slot() 106void AddEntryWndImpl::cancelButton_slot()
107{ 107{
108 done(2); 108 done(2);
109} 109}
110#endif 110#endif
111 111
112void AddEntryWndImpl::setCurrCategory(const QString &cat) 112void AddEntryWndImpl::setCurrCategory(const QString &cat)
113{ 113{
114 int i, count = categoryComboBox->count(); 114 int i, count = categoryComboBox->count();
115 115
116 for (i = 0; i < count; ++i) { 116 for (i = 0; i < count; ++i) {
117 if (categoryComboBox->text(i) == cat) { 117 if (categoryComboBox->text(i) == cat) {
118 categoryComboBox->setCurrentItem(i); 118 categoryComboBox->setCurrentItem(i);
119#ifdef PWM_EMBEDDED 119#ifdef PWM_EMBEDDED
120 categorySelected(cat); 120 categorySelected(cat);
121#endif 121#endif
122 return; 122 return;
123 } 123 }
124 } 124 }
125 BUG(); 125 BUG();
126} 126}
127 127
128void AddEntryWndImpl::revealButton_slot() 128void AddEntryWndImpl::revealButton_slot()
129{ 129{
130 if (revealButton->isOn()) { 130 if (revealButton->isOn()) {
131 pwLineEdit->setEchoMode(QLineEdit::Normal); 131 pwLineEdit->setEchoMode(QLineEdit::Normal);
132 } else { 132 } else {
133 pwLineEdit->setEchoMode(QLineEdit::Password); 133 pwLineEdit->setEchoMode(QLineEdit::Password);
134 } 134 }
135} 135}
136 136
137void AddEntryWndImpl::generateButton_slot() 137void AddEntryWndImpl::generateButton_slot()
138{ 138{
139 if (!pwGen->exec()) 139 if (!pwGen->exec())
140 return; 140 return;
141 setPassword(pwGen->getPassword()); 141 setPassword(pwGen->getPassword());
142} 142}
143 143
144QString AddEntryWndImpl::getComment() 144QString AddEntryWndImpl::getComment()
145{ 145{
146#ifndef PWM_EMBEDDED 146#ifndef PWM_EMBEDDED
147 if (isAdvancedComment()) { 147 if (isAdvancedComment()) {
148 return advCommentDta; 148 return advCommentDta;
149 } 149 }
150#endif 150#endif
151 return commentTextEdit->text(); 151 return commentTextEdit->text();
152} 152}
153 153
154void AddEntryWndImpl::setComment(const QString &comm) 154void AddEntryWndImpl::setComment(const QString &comm)
155{ 155{
156#ifndef PWM_EMBEDDED 156#ifndef PWM_EMBEDDED
157 if (HtmlGen::isHtml(comm)) { 157 if (HtmlGen::isHtml(comm)) {
158 advancedCommentButton->setOn(true); 158 advancedCommentButton->setOn(true);
159 advCommentDta = comm; 159 advCommentDta = comm;
160 } else { 160 } else {
161 advancedCommentButton->setOn(false); 161 advancedCommentButton->setOn(false);
162 commentTextEdit->setText(comm); 162 commentTextEdit->setText(comm);
163 } 163 }
164#else 164#else
165 commentTextEdit->setText(comm); 165 commentTextEdit->setText(comm);
166#endif 166#endif
167} 167}
168 168
169void AddEntryWndImpl::advancedCommentButton_slot(bool on) 169void AddEntryWndImpl::advancedCommentButton_slot(bool on)
170{ 170{
171#ifndef PWM_EMBEDDED 171#ifndef PWM_EMBEDDED
172 switchComment(on); 172 switchComment(on);
173#endif 173#endif
174} 174}
175 175
176void AddEntryWndImpl::switchComment(bool toAdvanced) 176void AddEntryWndImpl::switchComment(bool toAdvanced)
177{ 177{
178#ifndef PWM_EMBEDDED 178#ifndef PWM_EMBEDDED
179 179
180 useAdvComment = toAdvanced; 180 useAdvComment = toAdvanced;
181 if (toAdvanced) { 181 if (toAdvanced) {
182 if (commentTextEdit) { 182 if (commentTextEdit) {
183 savedCommentText = commentTextEdit->text(); 183 savedCommentText = commentTextEdit->text();
184 delete_and_null(commentTextEdit); 184 delete_and_null(commentTextEdit);
185 } 185 }
186 if (editAdvCommentButton) 186 if (editAdvCommentButton)
187 return; 187 return;
188 editAdvCommentButton = new QPushButton(i18n("Edit advanced comment..."), 188 editAdvCommentButton = new QPushButton(i18n("Edit advanced comment..."),
189 commentDummy); 189 commentDummy);
190 editAdvCommentButton->resize(commentDummy->size().width(), 50); 190 editAdvCommentButton->resize(commentDummy->size().width(), 50);
191 connect(editAdvCommentButton, SIGNAL(clicked()), 191 connect(editAdvCommentButton, SIGNAL(clicked()),
192 this, SLOT(editAdvCommentButton_slot())); 192 this, SLOT(editAdvCommentButton_slot()));
193 editAdvCommentButton->show(); 193 editAdvCommentButton->show();
194 } else { 194 } else {
195 delete_ifnot_null(editAdvCommentButton); 195 delete_ifnot_null(editAdvCommentButton);
196 if (commentTextEdit) 196 if (commentTextEdit)
197 return; 197 return;
198 198
199 commentTextEdit = new QTextEdit(commentDummy); 199 commentTextEdit = new Q3TextEdit(commentDummy);
200 commentTextEdit->setTextFormat(Qt::PlainText); 200 commentTextEdit->setTextFormat(Qt::PlainText);
201 commentTextEdit->resize(commentDummy->size()); 201 commentTextEdit->resize(commentDummy->size());
202 commentTextEdit->setText(savedCommentText); 202 commentTextEdit->setText(savedCommentText);
203 commentTextEdit->show(); 203 commentTextEdit->show();
204 } 204 }
205#endif 205#endif
206} 206}
207 207
208void AddEntryWndImpl::editAdvCommentButton_slot() 208void AddEntryWndImpl::editAdvCommentButton_slot()
209{ 209{
210#ifndef PWM_EMBEDDED 210#ifndef PWM_EMBEDDED
211 AdvCommEditImpl editor(this); 211 AdvCommEditImpl editor(this);
212 editor.setHtmlDta(advCommentDta); 212 editor.setHtmlDta(advCommentDta);
213 if (editor.exec()) 213 if (editor.exec())
214 return; 214 return;
215 advCommentDta = editor.getHtmlDta(); 215 advCommentDta = editor.getHtmlDta();
216#endif 216#endif
217} 217}
218 218
219#ifndef PWM_EMBEDDED 219#ifndef PWM_EMBEDDED_
220#include "addentrywndimpl.moc" 220#include "moc_addentrywndimpl.cpp"
221#endif 221#endif
diff --git a/pwmanager/pwmanager/addentrywndimpl.h b/pwmanager/pwmanager/addentrywndimpl.h
index e13eb54..c5f4bb1 100644
--- a/pwmanager/pwmanager/addentrywndimpl.h
+++ b/pwmanager/pwmanager/addentrywndimpl.h
@@ -1,127 +1,127 @@
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 __ADDENTRYWNDIMPL_H 20#ifndef __ADDENTRYWNDIMPL_H
21#define __ADDENTRYWNDIMPL_H 21#define __ADDENTRYWNDIMPL_H
22 22
23 23
24#ifndef PWM_EMBEDDED 24#ifndef PWM_EMBEDDED
25#include <qlineedit.h> 25#include <qlineedit.h>
26#include <qtextedit.h> 26#include <q3textedit.h>
27#include <qcombobox.h> 27#include <qcombobox.h>
28#include "addentrywnd.h" 28#include "addentrywnd.h"
29#else 29#else
30#include <klineedit.h> 30#include <klineedit.h>
31#include <kcombobox.h> 31#include <kcombobox.h>
32#include <qmultilineedit.h> 32#include <q3multilineedit.h>
33#include "addentrywnd_emb.h" 33#include "addentrywnd_emb.h"
34#endif 34#endif
35 35
36#include <qpushbutton.h> 36#include <qpushbutton.h>
37 37
38class PwGenWndImpl; 38class PwGenWndImpl;
39 39
40/** "add/edit" Window */ 40/** "add/edit" Window */
41class AddEntryWndImpl : public addEntryWnd 41class AddEntryWndImpl : public addEntryWnd
42{ 42{
43 Q_OBJECT 43 Q_OBJECT
44public: 44public:
45#ifndef PWM_EMBEDDED 45#ifndef PWM_EMBEDDED
46 AddEntryWndImpl(); 46 AddEntryWndImpl();
47#else 47#else
48 AddEntryWndImpl( PwMDoc* doc, QWidget* parent = 0, const char* name = 0); 48 AddEntryWndImpl( PwMDoc* doc, QWidget* parent = 0, const char* name = 0);
49#endif 49#endif
50 ~AddEntryWndImpl(); 50 ~AddEntryWndImpl();
51 51
52 /* get... functions */ 52 /* get... functions */
53 QString getDescription() 53 QString getDescription()
54 { return descLineEdit->text(); } 54 { return descLineEdit->text(); }
55 QString getCategory() 55 QString getCategory()
56 { return categoryComboBox->currentText(); } 56 { return categoryComboBox->currentText(); }
57 QString getUsername() 57 QString getUsername()
58 { return usernameLineEdit->text(); } 58 { return usernameLineEdit->text(); }
59 QString getPassword() 59 QString getPassword()
60 { return pwLineEdit->text(); } 60 { return pwLineEdit->text(); }
61 QString getUrl() 61 QString getUrl()
62 { return urlLineEdit->text(); } 62 { return urlLineEdit->text(); }
63 QString getLauncher() 63 QString getLauncher()
64 { return launcherLineEdit->text(); } 64 { return launcherLineEdit->text(); }
65 QString getComment(); 65 QString getComment();
66 66
67 /* set... functions */ 67 /* set... functions */
68 void setDescription(const QString &desc) 68 void setDescription(const QString &desc)
69 { descLineEdit->setText(desc); } 69 { descLineEdit->setText(desc); }
70 void setCurrCategory(const QString &cat); 70 void setCurrCategory(const QString &cat);
71 void addCategory(const QString &cat) 71 void addCategory(const QString &cat)
72 { categoryComboBox->insertItem(cat); } 72 { categoryComboBox->insertItem(cat); }
73 void setUsername(const QString &name) 73 void setUsername(const QString &name)
74 { usernameLineEdit->setText(name); } 74 { usernameLineEdit->setText(name); }
75 void setPassword(const QString &pw) 75 void setPassword(const QString &pw)
76 { pwLineEdit->setText(pw); } 76 { pwLineEdit->setText(pw); }
77 void setUrl(const QString &url) 77 void setUrl(const QString &url)
78 { urlLineEdit->setText(url); } 78 { urlLineEdit->setText(url); }
79 void setLauncher(const QString launcher) 79 void setLauncher(const QString launcher)
80 { launcherLineEdit->setText(launcher); } 80 { launcherLineEdit->setText(launcher); }
81 void setComment(const QString &comm); 81 void setComment(const QString &comm);
82 82
83 /** are we using an advanced comment */ 83 /** are we using an advanced comment */
84 bool isAdvancedComment() 84 bool isAdvancedComment()
85 { return useAdvComment; } 85 { return useAdvComment; }
86 86
87public slots: 87public slots:
88#ifndef PWM_EMBEDDED 88#ifndef PWM_EMBEDDED
89//MOC_SKIP_BEGIN 89#ifndef Q_MOC_RUN
90 /** OK button pressed */ 90 /** OK button pressed */
91 void okButton_slot(); 91 void okButton_slot();
92 /** cancel button pressed */ 92 /** cancel button pressed */
93 void cancelButton_slot(); 93 void cancelButton_slot();
94//MOC_SKIP_END 94#endif
95#else 95#else
96 virtual void slotOk(); 96 virtual void slotOk();
97#endif 97#endif
98 /** Reveal button pressed */ 98 /** Reveal button pressed */
99 void revealButton_slot(); 99 void revealButton_slot();
100 /** Generate button pressed */ 100 /** Generate button pressed */
101 void generateButton_slot(); 101 void generateButton_slot();
102 /** advanced comment button pressed */ 102 /** advanced comment button pressed */
103 void advancedCommentButton_slot(bool on); 103 void advancedCommentButton_slot(bool on);
104 /** edit advanced comment button pressed */ 104 /** edit advanced comment button pressed */
105 void editAdvCommentButton_slot(); 105 void editAdvCommentButton_slot();
106 106
107protected: 107protected:
108 void switchComment(bool toAdvanced); 108 void switchComment(bool toAdvanced);
109 109
110protected: 110protected:
111 QPushButton *editAdvCommentButton; 111 QPushButton *editAdvCommentButton;
112#ifndef PWM_EMBEDDED 112#ifndef PWM_EMBEDDED
113 QTextEdit *commentTextEdit; 113 Q3TextEdit *commentTextEdit;
114#else 114#else
115 //nothing here 115 //nothing here
116#endif 116#endif
117 /** saved data from normal comment text edit box */ 117 /** saved data from normal comment text edit box */
118 QString savedCommentText; 118 QString savedCommentText;
119 /** use an advanced comment? */ 119 /** use an advanced comment? */
120 bool useAdvComment; 120 bool useAdvComment;
121 /** data of advanced comment (if available) */ 121 /** data of advanced comment (if available) */
122 QString advCommentDta; 122 QString advCommentDta;
123 /** password generation object */ 123 /** password generation object */
124 PwGenWndImpl *pwGen; 124 PwGenWndImpl *pwGen;
125}; 125};
126 126
127#endif 127#endif
diff --git a/pwmanager/pwmanager/binentrygen.h b/pwmanager/pwmanager/binentrygen.h
index 49288aa..9263cdc 100644
--- a/pwmanager/pwmanager/binentrygen.h
+++ b/pwmanager/pwmanager/binentrygen.h
@@ -1,65 +1,65 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 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 __BINENTRYGEN_H 20#ifndef __BINENTRYGEN_H
21#define __BINENTRYGEN_H 21#define __BINENTRYGEN_H
22 22
23 23
24#include <qcstring.h> 24#include <q3cstring.h>
25 25
26#include "pwmdoc.h" 26#include "pwmdoc.h"
27 27
28/** Binary entry generator. 28/** Binary entry generator.
29 * This generator generates a normal struct PwMDataItem 29 * This generator generates a normal struct PwMDataItem
30 * from binary data (using base64 encoding). 30 * from binary data (using base64 encoding).
31 * This mechanism is used to support the binary interface functions 31 * This mechanism is used to support the binary interface functions
32 * of the KWallet emulation, for example. 32 * of the KWallet emulation, for example.
33 * 33 *
34 * The format of the encoded binary data as a PwMDataItem is as follows: 34 * The format of the encoded binary data as a PwMDataItem is as follows:
35 * 35 *
36 * PwMDataItem::desc contains the normal description string for 36 * PwMDataItem::desc contains the normal description string for
37 * this entry. Nothing surprising. 37 * this entry. Nothing surprising.
38 * PwMDataItem::name contains the "DataType" number in ascii format. 38 * PwMDataItem::name contains the "DataType" number in ascii format.
39 * PwMDataItem::pw contains the base64 encoded data stream. 39 * PwMDataItem::pw contains the base64 encoded data stream.
40 * PwMDataItem::binary is always true for binary entries. 40 * PwMDataItem::binary is always true for binary entries.
41 * All other PwMDataItems are currently unused by BinEntryGen. 41 * All other PwMDataItems are currently unused by BinEntryGen.
42 */ 42 */
43class BinEntryGen 43class BinEntryGen
44{ 44{
45public: 45public:
46 enum DataType 46 enum DataType
47 { 47 {
48 None = 0, 48 None = 0,
49 KWalletMap, 49 KWalletMap,
50 KWalletStream 50 KWalletStream
51 }; 51 };
52 52
53public: 53public:
54 BinEntryGen() { } 54 BinEntryGen() { }
55 55
56 /** Encode the binary "data" and return it in "ret" */ 56 /** Encode the binary "data" and return it in "ret" */
57 void encode(const QByteArray &data, PwMDataItem *ret, DataType type); 57 void encode(const QByteArray &data, PwMDataItem *ret, DataType type);
58 /** Decode the "data" and return it as binary "ret" */ 58 /** Decode the "data" and return it as binary "ret" */
59 void decode(const PwMDataItem &data, QByteArray *ret, DataType *type); 59 void decode(const PwMDataItem &data, QByteArray *ret, DataType *type);
60 60
61 /** Return the data type for this binary data item */ 61 /** Return the data type for this binary data item */
62 DataType binType(const PwMDataItem &data); 62 DataType binType(const PwMDataItem &data);
63}; 63};
64 64
65#endif // __BINENTRYGEN_H 65#endif // __BINENTRYGEN_H
diff --git a/pwmanager/pwmanager/commentbox.cpp b/pwmanager/pwmanager/commentbox.cpp
index 5416856..a60440d 100644
--- a/pwmanager/pwmanager/commentbox.cpp
+++ b/pwmanager/pwmanager/commentbox.cpp
@@ -1,283 +1,283 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 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 "commentbox.h" 20#include "commentbox.h"
21#include "pwmexception.h" 21#include "pwmexception.h"
22#include "htmlgen.h" 22#include "htmlgen.h"
23 23
24#include <klocale.h> 24#include <klocale.h>
25 25
26#ifndef PWM_EMBEDDED 26#ifndef PWM_EMBEDDED
27#include <khtml_part.h> 27#include <khtml_part.h>
28#include <khtmlview.h> 28#include <khtmlview.h>
29#include <qtextedit.h> 29#include <q3textedit.h>
30#else 30#else
31#include <qmultilineedit.h> 31#include <q3multilineedit.h>
32#endif 32#endif
33 33
34 34
35 35
36#ifndef PWM_EMBEDDED 36#ifndef PWM_EMBEDDED
37CommentBox::CommentBox(QWidget *_parentWidget) 37CommentBox::CommentBox(QWidget *_parentWidget)
38{ 38{
39 PWM_ASSERT(_parentWidget); 39 PWM_ASSERT(_parentWidget);
40 parentWidget = _parentWidget; 40 parentWidget = _parentWidget;
41 textDta = 0; 41 textDta = 0;
42 htmlDta = 0; 42 htmlDta = 0;
43 mode = mode_notSet; 43 mode = mode_notSet;
44 setFont( prefs->mViewFont ); 44 setFont( prefs->mViewFont );
45} 45}
46 46
47CommentBox::~CommentBox() 47CommentBox::~CommentBox()
48{ 48{
49 clearText(); 49 clearText();
50 clearHtml(); 50 clearHtml();
51} 51}
52 52
53void CommentBox::clear() 53void CommentBox::clear()
54{ 54{
55 clearText(); 55 clearText();
56 clearHtml(); 56 clearHtml();
57 mode = mode_notSet; 57 mode = mode_notSet;
58 this->hide(); 58 this->hide();
59} 59}
60 60
61void CommentBox::clearText() 61void CommentBox::clearText()
62{ 62{
63 delete_ifnot_null(textDta); 63 delete_ifnot_null(textDta);
64} 64}
65 65
66void CommentBox::clearHtml() 66void CommentBox::clearHtml()
67{ 67{
68 delete_ifnot_null(htmlDta); 68 delete_ifnot_null(htmlDta);
69} 69}
70 70
71void CommentBox::setText(const QString &text) 71void CommentBox::setText(const QString &text)
72{ 72{
73 switchTo(mode_text); 73 switchTo(mode_text);
74 PWM_ASSERT(textDta); 74 PWM_ASSERT(textDta);
75 textDta->setText( text); 75 textDta->setText( text);
76 if (!textDta->isVisible()) 76 if (!textDta->isVisible())
77 textDta->show(); 77 textDta->show();
78} 78}
79 79
80bool CommentBox::getText(QString *text) 80bool CommentBox::getText(QString *text)
81{ 81{
82 if (mode != mode_text) 82 if (mode != mode_text)
83 return false; 83 return false;
84 PWM_ASSERT(text); 84 PWM_ASSERT(text);
85 if (!textDta) { 85 if (!textDta) {
86 *text = ""; 86 *text = "";
87 return true; 87 return true;
88 } 88 }
89 *text = textDta->text(); 89 *text = textDta->text();
90 return true; 90 return true;
91} 91}
92 92
93void CommentBox::setHtml(QString code) 93void CommentBox::setHtml(QString code)
94{ 94{
95 switchTo(mode_html); 95 switchTo(mode_html);
96 PWM_ASSERT(htmlDta); 96 PWM_ASSERT(htmlDta);
97 if (!HtmlGen::replaceSSDummy(&code)) 97 if (!HtmlGen::replaceSSDummy(&code))
98 printWarn("CommentBox::setHtml(): replaceSSDummy() failed!"); 98 printWarn("CommentBox::setHtml(): replaceSSDummy() failed!");
99 htmlDta->begin(); 99 htmlDta->begin();
100 htmlDta->write(code); 100 htmlDta->write(code);
101 htmlDta->end(); 101 htmlDta->end();
102 htmlDta->show(); 102 htmlDta->show();
103} 103}
104 104
105void CommentBox::setContent(const QString &dta) 105void CommentBox::setContent(const QString &dta)
106{ 106{
107 // if there's no data, hide the comment-box 107 // if there's no data, hide the comment-box
108 if (dta.isEmpty()) { 108 if (dta.isEmpty()) {
109 clear(); 109 clear();
110 return; 110 return;
111 } 111 }
112 if (HtmlGen::isHtml(dta)) { 112 if (HtmlGen::isHtml(dta)) {
113 setHtml(dta); 113 setHtml(dta);
114 return; 114 return;
115 } 115 }
116 // we assume it's plain text 116 // we assume it's plain text
117 setText(dta); 117 setText(dta);
118} 118}
119 119
120void CommentBox::switchTo(commentBoxMode newMode) 120void CommentBox::switchTo(commentBoxMode newMode)
121{ 121{
122 if (newMode == mode) 122 if (newMode == mode)
123 return; 123 return;
124 124
125 // cleanup old mode 125 // cleanup old mode
126 switch (mode) { 126 switch (mode) {
127 case mode_text: 127 case mode_text:
128 clearText(); 128 clearText();
129 break; 129 break;
130 case mode_html: 130 case mode_html:
131 clearHtml(); 131 clearHtml();
132 break; 132 break;
133 default: 133 default:
134 break; 134 break;
135 } 135 }
136 136
137 // setup new mode 137 // setup new mode
138 switch (newMode) { 138 switch (newMode) {
139 case mode_text: 139 case mode_text:
140 textDta = new QTextEdit(parentWidget); 140 textDta = new Q3TextEdit(parentWidget);
141 textDta->setTextFormat(Qt::PlainText); 141 textDta->setTextFormat(Qt::PlainText);
142 textDta->setReadOnly(true); 142 textDta->setReadOnly(true);
143 textDta->show(); 143 textDta->show();
144 break; 144 break;
145 case mode_html: 145 case mode_html:
146 htmlDta = new KHTMLPart(parentWidget, 0, 146 htmlDta = new KHTMLPart(parentWidget, 0,
147 parentWidget); 147 parentWidget);
148 htmlDta->show(); 148 htmlDta->show();
149 break; 149 break;
150 default: 150 default:
151 BUG(); 151 BUG();
152 break; 152 break;
153 } 153 }
154 154
155 mode = newMode; 155 mode = newMode;
156} 156}
157 157
158void CommentBox::show() 158void CommentBox::show()
159{ 159{
160 switch (mode) { 160 switch (mode) {
161 case mode_text: 161 case mode_text:
162 PWM_ASSERT(textDta); 162 PWM_ASSERT(textDta);
163 textDta->show(); 163 textDta->show();
164 break; 164 break;
165 case mode_html: 165 case mode_html:
166 PWM_ASSERT(htmlDta); 166 PWM_ASSERT(htmlDta);
167 htmlDta->show(); 167 htmlDta->show();
168 break; 168 break;
169 default: 169 default:
170 break; 170 break;
171 } 171 }
172 172
173} 173}
174 174
175void CommentBox::hide() 175void CommentBox::hide()
176{ 176{
177 switch (mode) { 177 switch (mode) {
178 case mode_text: 178 case mode_text:
179 PWM_ASSERT(textDta); 179 PWM_ASSERT(textDta);
180 textDta->hide(); 180 textDta->hide();
181 break; 181 break;
182 case mode_html: 182 case mode_html:
183 PWM_ASSERT(htmlDta); 183 PWM_ASSERT(htmlDta);
184 htmlDta->hide(); 184 htmlDta->hide();
185 break; 185 break;
186 default: 186 default:
187 break; 187 break;
188 } 188 }
189} 189}
190 190
191void CommentBox::resize(const QSize &size) 191void CommentBox::resize(const QSize &size)
192{ 192{
193 switch (mode) { 193 switch (mode) {
194 case mode_text: 194 case mode_text:
195 PWM_ASSERT(textDta); 195 PWM_ASSERT(textDta);
196 textDta->resize(size); 196 textDta->resize(size);
197 break; 197 break;
198 case mode_html: 198 case mode_html:
199 PWM_ASSERT(htmlDta); 199 PWM_ASSERT(htmlDta);
200 htmlDta->view()->resize(size); 200 htmlDta->view()->resize(size);
201 break; 201 break;
202 default: 202 default:
203 break; 203 break;
204 } 204 }
205 205
206} 206}
207 207
208QSize CommentBox::size() 208QSize CommentBox::size()
209{ 209{
210 switch (mode) { 210 switch (mode) {
211 case mode_text: 211 case mode_text:
212 PWM_ASSERT(textDta); 212 PWM_ASSERT(textDta);
213 return textDta->size(); 213 return textDta->size();
214 break; 214 break;
215 case mode_html: 215 case mode_html:
216 PWM_ASSERT(htmlDta); 216 PWM_ASSERT(htmlDta);
217 return htmlDta->view()->size(); 217 return htmlDta->view()->size();
218 break; 218 break;
219 default: 219 default:
220 break; 220 break;
221 } 221 }
222 222
223 return QSize(); 223 return QSize();
224} 224}
225 225
226 226
227//////////////////////////////////////////////////////////////////////// 227////////////////////////////////////////////////////////////////////////
228 228
229#else 229#else
230 230
231CommentBox::CommentBox(QWidget *_parentWidget) 231CommentBox::CommentBox(QWidget *_parentWidget)
232 : QTextBrowser(_parentWidget) 232 : Q3TextBrowser(_parentWidget)
233 233
234{ 234{
235 //this->setReadOnly(true); 235 //this->setReadOnly(true);
236 setFocusPolicy( QWidget::ClickFocus ); 236 setFocusPolicy( Qt::ClickFocus );
237} 237}
238 238
239CommentBox::~CommentBox() 239CommentBox::~CommentBox()
240{ 240{
241} 241}
242 242
243void CommentBox::clear() 243void CommentBox::clear()
244{ 244{
245 this->hide(); 245 this->hide();
246} 246}
247 247
248 248
249void CommentBox::setText(const QString &text) 249void CommentBox::setText(const QString &text)
250{ 250{
251 QTextBrowser::setText( text); 251 Q3TextBrowser::setText( text);
252 if (!isVisible()) 252 if (!isVisible())
253 show(); 253 show();
254} 254}
255 255
256bool CommentBox::getText(QString *text) 256bool CommentBox::getText(QString *text)
257{ 257{
258 *text = this->text(); 258 *text = this->text();
259 return true; 259 return true;
260} 260}
261 261
262void CommentBox::setContent(const QString &dta) 262void CommentBox::setContent(const QString &dta)
263{ 263{
264 // if there's no data, hide the comment-box 264 // if there's no data, hide the comment-box
265 if (dta.isEmpty()) { 265 if (dta.isEmpty()) {
266 clear(); 266 clear();
267 return; 267 return;
268 } 268 }
269 269
270 // we assume it's plain text 270 // we assume it's plain text
271 setText(dta); 271 setText(dta);
272} 272}
273 273
274#endif 274#endif
275 275
276 276
277 277
278 278
279 279
280 280
281 281
282 282
283 283
diff --git a/pwmanager/pwmanager/commentbox.h b/pwmanager/pwmanager/commentbox.h
index 3103353..d14ba13 100644
--- a/pwmanager/pwmanager/commentbox.h
+++ b/pwmanager/pwmanager/commentbox.h
@@ -1,124 +1,124 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 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 COMMENTBOX_H 20#ifndef COMMENTBOX_H
21#define COMMENTBOX_H 21#define COMMENTBOX_H
22 22
23#include <qstring.h> 23#include <qstring.h>
24#include <qsize.h> 24#include <qsize.h>
25class QWidget; 25class QWidget;
26class QTextEdit; 26class Q3TextEdit;
27class KHTMLPart; 27class KHTMLPart;
28 28
29#ifndef PWM_EMBEDDED 29#ifndef PWM_EMBEDDED
30 30
31class CommentBox 31class CommentBox
32{ 32{
33protected: 33protected:
34 enum commentBoxMode 34 enum commentBoxMode
35 { 35 {
36 mode_notSet = 0, 36 mode_notSet = 0,
37 mode_text, 37 mode_text,
38 mode_html 38 mode_html
39 }; 39 };
40 40
41public: 41public:
42 CommentBox(QWidget *_parentWidget); 42 CommentBox(QWidget *_parentWidget);
43 ~CommentBox(); 43 ~CommentBox();
44 44
45 /** clear all data in the comment box */ 45 /** clear all data in the comment box */
46 void clear(); 46 void clear();
47 /** show the comment box */ 47 /** show the comment box */
48 void show(); 48 void show();
49 /** hide the comment box */ 49 /** hide the comment box */
50 void hide(); 50 void hide();
51 /** resize the comment box */ 51 /** resize the comment box */
52 void resize(const QSize &size); 52 void resize(const QSize &size);
53 void resize(int w, int h) 53 void resize(int w, int h)
54 { resize(QSize(w, h)); } 54 { resize(QSize(w, h)); }
55 /** get the size of the comment box */ 55 /** get the size of the comment box */
56 QSize size(); 56 QSize size();
57 /** if neccessary switch to text-mode and 57 /** if neccessary switch to text-mode and
58 * insert this text into the comment box 58 * insert this text into the comment box
59 */ 59 */
60 void setText(const QString &text); 60 void setText(const QString &text);
61 /** get the text of the comment box. 61 /** get the text of the comment box.
62 * If it's not in text-mode it returns false 62 * If it's not in text-mode it returns false
63 */ 63 */
64 bool getText(QString *text); 64 bool getText(QString *text);
65 /** if neccessary switch to HTML-mode and 65 /** if neccessary switch to HTML-mode and
66 * insert this html code into the comment box 66 * insert this html code into the comment box
67 */ 67 */
68 void setHtml(QString code); 68 void setHtml(QString code);
69 /** checks "dta" for its type, sets the correct 69 /** checks "dta" for its type, sets the correct
70 * mode and writes "dta" to the comment box 70 * mode and writes "dta" to the comment box
71 */ 71 */
72 void setContent(const QString &dta); 72 void setContent(const QString &dta);
73 73
74protected: 74protected:
75 /** switch the current mode */ 75 /** switch the current mode */
76 void switchTo(commentBoxMode newMode); 76 void switchTo(commentBoxMode newMode);
77 /** clear all text data */ 77 /** clear all text data */
78 void clearText(); 78 void clearText();
79 /** clear all HTML data */ 79 /** clear all HTML data */
80 void clearHtml(); 80 void clearHtml();
81 81
82protected: 82protected:
83 /** parent widget for this comment box */ 83 /** parent widget for this comment box */
84 QWidget *parentWidget; 84 QWidget *parentWidget;
85 /** current comment box usage type */ 85 /** current comment box usage type */
86 commentBoxMode mode; 86 commentBoxMode mode;
87 /** if the comment box is a normal textbox, data is stored here */ 87 /** if the comment box is a normal textbox, data is stored here */
88 QTextEdit *textDta; 88 Q3TextEdit *textDta;
89 /** if the comment box is a HTML box, data is stored here */ 89 /** if the comment box is a HTML box, data is stored here */
90 KHTMLPart *htmlDta; 90 KHTMLPart *htmlDta;
91}; 91};
92 92
93#else 93#else
94#include <qtextbrowser.h> 94#include <q3textbrowser.h>
95/** Implementation of the advanced HTML comment box */ 95/** Implementation of the advanced HTML comment box */
96//US ENH: CommentBox must be derived from QWidget, to allow the splitter to set a initial size 96//US ENH: CommentBox must be derived from QWidget, to allow the splitter to set a initial size
97// without conflicting with the two display modes 97// without conflicting with the two display modes
98 98
99class CommentBox : public QTextBrowser 99class CommentBox : public Q3TextBrowser
100{ 100{
101public: 101public:
102 CommentBox(QWidget *_parentWidget); 102 CommentBox(QWidget *_parentWidget);
103 ~CommentBox(); 103 ~CommentBox();
104 104
105 /** clear all data in the comment box */ 105 /** clear all data in the comment box */
106 void clear(); 106 void clear();
107 /** if neccessary switch to text-mode and 107 /** if neccessary switch to text-mode and
108 * insert this text into the comment box 108 * insert this text into the comment box
109 */ 109 */
110 void setText(const QString &text); 110 void setText(const QString &text);
111 /** get the text of the comment box. 111 /** get the text of the comment box.
112 * If it's not in text-mode it returns false 112 * If it's not in text-mode it returns false
113 */ 113 */
114 bool getText(QString *text); 114 bool getText(QString *text);
115 /** if neccessary switch to HTML-mode and 115 /** if neccessary switch to HTML-mode and
116 * insert this html code into the comment box 116 * insert this html code into the comment box
117 */ 117 */
118 void setContent(const QString &dta); 118 void setContent(const QString &dta);
119 119
120}; 120};
121#endif 121#endif
122 122
123 123
124#endif 124#endif
diff --git a/pwmanager/pwmanager/csv.cpp b/pwmanager/pwmanager/csv.cpp
index 194edf2..226cc08 100644
--- a/pwmanager/pwmanager/csv.cpp
+++ b/pwmanager/pwmanager/csv.cpp
@@ -1,428 +1,430 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 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.1 of pwmanager 14 * This file is originaly based on version 1.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 * The original file version was 1.2 16 * The original file version was 1.2
17 * $Id$ 17 * $Id$
18 **************************************************************************/ 18 **************************************************************************/
19 19
20#include "csv.h" 20#include "csv.h"
21#include "pwmdoc.h" 21#include "pwmdoc.h"
22#include "pwmexception.h" 22#include "pwmexception.h"
23 23
24#include <kmessagebox.h> 24#include <kmessagebox.h>
25#include <klocale.h> 25#include <klocale.h>
26//Added by qt3to4:
27#include <Q3CString>
26 28
27 #define MAX_CSV_FILE_SIZE(50 * 1024 * 1024) // bytes 29 #define MAX_CSV_FILE_SIZE(50 * 1024 * 1024) // bytes
28 30
29 31
30Csv::Csv(QWidget *_parent) 32Csv::Csv(QWidget *_parent)
31 : parent (_parent) 33 : parent (_parent)
32{ 34{
33} 35}
34 36
35Csv::~Csv() 37Csv::~Csv()
36{ 38{
37} 39}
38 40
39bool Csv::importData(const QString &filepath, 41bool Csv::importData(const QString &filepath,
40 PwMDoc *doc) 42 PwMDoc *doc)
41{ 43{
42 bool ret = true; 44 bool ret = true;
43 QByteArray d; 45 QByteArray d;
44 QFile f(filepath); 46 QFile f(filepath);
45 if (!f.open(IO_ReadOnly)) { 47 if (!f.open(QIODevice::ReadOnly)) {
46 KMessageBox::error(parent, 48 KMessageBox::error(parent,
47 i18n("Could not open file.\n" 49 i18n("Could not open file.\n"
48 "Does the file exist?"), 50 "Does the file exist?"),
49 i18n("Open error.")); 51 i18n("Open error."));
50 ret = false; 52 ret = false;
51 goto out; 53 goto out;
52 } 54 }
53 if (f.size() > MAX_CSV_FILE_SIZE) { 55 if (f.size() > MAX_CSV_FILE_SIZE) {
54 KMessageBox::error(parent, 56 KMessageBox::error(parent,
55 i18n("File too big.\nMaximum file size is 1 Byte.", "File too big.\nMaximum file size is %n Bytes.", MAX_CSV_FILE_SIZE), 57 i18n("File too big.\nMaximum file size is 1 Byte.", "File too big.\nMaximum file size is %n Bytes.", MAX_CSV_FILE_SIZE),
56 i18n("File too big.")); 58 i18n("File too big."));
57 ret = false; 59 ret = false;
58 goto out_close; 60 goto out_close;
59 } 61 }
60 d = f.readAll(); 62 d = f.readAll();
61 if (d.isEmpty()) { 63 if (d.isEmpty()) {
62 KMessageBox::error(parent, 64 KMessageBox::error(parent,
63 i18n("Could not read file or file empty."), 65 i18n("Could not read file or file empty."),
64 i18n("Reading failed.")); 66 i18n("Reading failed."));
65 ret = false; 67 ret = false;
66 goto out_close; 68 goto out_close;
67 } 69 }
68 if (!doImport(d, doc)) { 70 if (!doImport(d, doc)) {
69 KMessageBox::error(parent, 71 KMessageBox::error(parent,
70 i18n("Import failed.\n" 72 i18n("Import failed.\n"
71 "Corrupt CSV data format."), 73 "Corrupt CSV data format."),
72 i18n("File corrupt.")); 74 i18n("File corrupt."));
73 ret = false; 75 ret = false;
74 goto out_close; 76 goto out_close;
75 } 77 }
76 78
77out_close: 79out_close:
78 f.close(); 80 f.close();
79out: 81out:
80 return ret; 82 return ret;
81} 83}
82 84
83bool Csv::doImport(const QByteArray &d, 85bool Csv::doImport(const QByteArray &d,
84 PwMDoc *doc) 86 PwMDoc *doc)
85{ 87{
86 PwMDataItem di; 88 PwMDataItem di;
87 //US ENH: initialize all members: 89 //US ENH: initialize all members:
88 di.clear(); 90 di.clear();
89 91
90 int refIndex = 0; 92 int refIndex = 0;
91 int ret; 93 int ret;
92 QCString s, curCat; 94 Q3CString s, curCat;
93 int fieldIndex = 0; 95 int fieldIndex = 0;
94 bool inRecord = false; 96 bool inRecord = false;
95 /* fieldIndex is a reference count to see which 97 /* fieldIndex is a reference count to see which
96 * value we are attaching to di. 98 * value we are attaching to di.
97 * Valid counts are: 99 * Valid counts are:
98 * 0 -> category 100 * 0 -> category
99 * 1 -> desc 101 * 1 -> desc
100 * 2 -> name 102 * 2 -> name
101 * 3 -> pw 103 * 3 -> pw
102 * 4 -> url 104 * 4 -> url
103 * 5 -> launcher 105 * 5 -> launcher
104 * 6 -> comment 106 * 6 -> comment
105 */ 107 */
106 108
107 while (1) { 109 while (1) {
108 ret = nextField(&s, d, inRecord, &refIndex); 110 ret = nextField(&s, d, inRecord, &refIndex);
109 switch (ret) { 111 switch (ret) {
110 case 0: 112 case 0:
111 // successfully got next field. 113 // successfully got next field.
112 inRecord = true; 114 inRecord = true;
113 switch (fieldIndex) { 115 switch (fieldIndex) {
114 case 0: // category 116 case 0: // category
115 if (s.isEmpty()) { 117 if (s.isEmpty()) {
116 /* This is special case. It's the category 118 /* This is special case. It's the category
117 * list terminating empty field. 119 * list terminating empty field.
118 */ 120 */
119 ++fieldIndex; 121 ++fieldIndex;
120 } else 122 } else
121 curCat = s; 123 curCat = s;
122 break; 124 break;
123 case 1:// desc 125 case 1:// desc
124 di.desc = s; 126 di.desc = std::string(s);
125 ++fieldIndex; 127 ++fieldIndex;
126 break; 128 break;
127 case 2: // name 129 case 2: // name
128 di.name = s; 130 di.name = std::string(s);
129 ++fieldIndex; 131 ++fieldIndex;
130 break; 132 break;
131 case 3: // pw 133 case 3: // pw
132 di.pw = s; 134 di.pw = std::string(s);
133 ++fieldIndex; 135 ++fieldIndex;
134 break; 136 break;
135 case 4: // url 137 case 4: // url
136 di.url = s; 138 di.url = std::string(s);
137 ++fieldIndex; 139 ++fieldIndex;
138 break; 140 break;
139 case 5: // launcher 141 case 5: // launcher
140 di.launcher = s; 142 di.launcher = std::string(s);
141 ++fieldIndex; 143 ++fieldIndex;
142 break; 144 break;
143 case 6: // comment 145 case 6: // comment
144 di.comment = s; 146 di.comment = std::string(s);
145 ++fieldIndex; 147 ++fieldIndex;
146 break; 148 break;
147 default: 149 default:
148 /* Too many fields in a record. 150 /* Too many fields in a record.
149 * We simply throw it away. 151 * We simply throw it away.
150 */ 152 */
151 break; 153 break;
152 } 154 }
153 break; 155 break;
154 case 1: 156 case 1:
155 // record complete. 157 // record complete.
156 if (fieldIndex == 6) 158 if (fieldIndex == 6)
157 di.comment = s; 159 di.comment = std::string(s);
158 inRecord = false; 160 inRecord = false;
159 fieldIndex = 0; 161 fieldIndex = 0;
160 doc->addEntry(curCat, &di, true); 162 doc->addEntry(curCat, &di, true);
161 //US ENH: clear di for the next row 163 //US ENH: clear di for the next row
162 di.clear(); 164 di.clear();
163 break; 165 break;
164 case 2: 166 case 2:
165 // data completely parsed. 167 // data completely parsed.
166 doc->flagDirty(); 168 doc->flagDirty();
167 return true; 169 return true;
168 case -1: 170 case -1:
169 // parse error 171 // parse error
170 doc->flagDirty(); 172 doc->flagDirty();
171 return false; 173 return false;
172 } 174 }
173 } 175 }
174 BUG(); 176 BUG();
175 return false; 177 return false;
176} 178}
177 179
178int Csv::nextField(QCString *ret, 180int Csv::nextField(Q3CString *ret,
179 const QByteArray &in, 181 const QByteArray &in,
180 bool inRecord, 182 bool inRecord,
181 int *_refIndex) 183 int *_refIndex)
182{ 184{
183 int rv = -2; 185 int rv = -2;
184 char c; 186 char c;
185 bool inField = false; 187 bool inField = false;
186 bool isQuoted = false; 188 bool isQuoted = false;
187 bool searchingTerminator = false; 189 bool searchingTerminator = false;
188 int refIndex; 190 int refIndex;
189 int inSize = static_cast<int>(in.size()); 191 int inSize = static_cast<int>(in.size());
190 ret->truncate(0); 192 ret->truncate(0);
191 193
192 for (refIndex = *_refIndex; refIndex < inSize; ++refIndex) { 194 for (refIndex = *_refIndex; refIndex < inSize; ++refIndex) {
193 c = in.at(refIndex); 195 c = in.at(refIndex);
194 if (!inField) { 196 if (!inField) {
195 // we have to search the field beginning, now. 197 // we have to search the field beginning, now.
196 switch (c) { 198 switch (c) {
197 case ' ': // space 199 case ' ': // space
198 case '': // tab 200 case '': // tab
199 // hm, still not the beginning. Go on.. 201 // hm, still not the beginning. Go on..
200 break; 202 break;
201 case '\r': 203 case '\r':
202 case '\n': 204 case '\n':
203 if (inRecord) { 205 if (inRecord) {
204 /* This is the end of the last field in 206 /* This is the end of the last field in
205 * the record. 207 * the record.
206 */ 208 */
207 PWM_ASSERT(ret->isEmpty()); 209 PWM_ASSERT(ret->isEmpty());
208 rv = 1; // record end 210 rv = 1; // record end
209 goto out; 211 goto out;
210 } else { 212 } else {
211 // hm, still not the beginning. Go on.. 213 // hm, still not the beginning. Go on..
212 break; 214 break;
213 } 215 }
214 case ',': 216 case ',':
215 // Oh, an empty field. How sad. 217 // Oh, an empty field. How sad.
216 PWM_ASSERT(ret->isEmpty()); 218 PWM_ASSERT(ret->isEmpty());
217 rv = 0; // field end 219 rv = 0; // field end
218 goto out; 220 goto out;
219 case '\"': 221 case '\"':
220 // this is the quoted beginning. 222 // this is the quoted beginning.
221 inField = true; 223 inField = true;
222 isQuoted = true; 224 isQuoted = true;
223 if (refIndex + 1 >= inSize) 225 if (refIndex + 1 >= inSize)
224 goto unexp_eof; 226 goto unexp_eof;
225 break; 227 break;
226 default: 228 default:
227 // this is the unquoted beginning. 229 // this is the unquoted beginning.
228 inField = true; 230 inField = true;
229 isQuoted = false; 231 isQuoted = false;
230 *ret += c; 232 *ret += c;
231 break; 233 break;
232 } 234 }
233 } else { 235 } else {
234 // we are in the field now. Search the end. 236 // we are in the field now. Search the end.
235 if (isQuoted) { 237 if (isQuoted) {
236 if (searchingTerminator) { 238 if (searchingTerminator) {
237 switch (c) { 239 switch (c) {
238 case '\r': 240 case '\r':
239 case '\n': 241 case '\n':
240 rv = 1; // record end 242 rv = 1; // record end
241 goto out; 243 goto out;
242 case ',': 244 case ',':
243 // found it. 245 // found it.
244 rv = 0; // field end 246 rv = 0; // field end
245 goto out; 247 goto out;
246 default: 248 default:
247 // go on. 249 // go on.
248 continue; 250 continue;
249 } 251 }
250 } 252 }
251 switch (c) { 253 switch (c) {
252 case '\"': 254 case '\"':
253 /* check if this is the end of the 255 /* check if this is the end of the
254 * entry, or just an inline escaped quote. 256 * entry, or just an inline escaped quote.
255 */ 257 */
256 char next; 258 char next;
257 if (refIndex + 1 >= inSize) { 259 if (refIndex + 1 >= inSize) {
258 // This is the last char, so it's the end. 260 // This is the last char, so it's the end.
259 rv = 2; // data end 261 rv = 2; // data end
260 goto out; 262 goto out;
261 } 263 }
262 next = in.at(refIndex + 1); 264 next = in.at(refIndex + 1);
263 switch (next) { 265 switch (next) {
264 case '\"': 266 case '\"':
265 // This is an escaped double quote. 267 // This is an escaped double quote.
266 // So skip next iteration. 268 // So skip next iteration.
267 refIndex += 1; 269 refIndex += 1;
268 *ret += c; 270 *ret += c;
269 break; 271 break;
270 default: 272 default:
271 /* end of field. 273 /* end of field.
272 * We have to search the comma (or newline...), 274 * We have to search the comma (or newline...),
273 * which officially terminates the entry. 275 * which officially terminates the entry.
274 */ 276 */
275 searchingTerminator = true; 277 searchingTerminator = true;
276 break; 278 break;
277 } 279 }
278 break; 280 break;
279 default: 281 default:
280 // nothing special about the char. Go on! 282 // nothing special about the char. Go on!
281 *ret += c; 283 *ret += c;
282 break; 284 break;
283 } 285 }
284 } else { 286 } else {
285 switch (c) { 287 switch (c) {
286 case '\"': 288 case '\"':
287 // This is not allowed here. 289 // This is not allowed here.
288 return -1; // parser error 290 return -1; // parser error
289 case '\r': 291 case '\r':
290 case '\n': 292 case '\n':
291 rv = 1; // record end 293 rv = 1; // record end
292 goto out; 294 goto out;
293 case ',': 295 case ',':
294 rv = 0; // field end 296 rv = 0; // field end
295 goto out; 297 goto out;
296 default: 298 default:
297 // nothing special about the char. Go on! 299 // nothing special about the char. Go on!
298 *ret += c; 300 *ret += c;
299 break; 301 break;
300 } 302 }
301 } 303 }
302 } 304 }
303 } 305 }
304 // we are at the end of the stream, now! 306 // we are at the end of the stream, now!
305 if (searchingTerminator) { 307 if (searchingTerminator) {
306 /* Ok, there's no terminating comma (or newline...), 308 /* Ok, there's no terminating comma (or newline...),
307 * because we are at the end. That's perfectly fine. 309 * because we are at the end. That's perfectly fine.
308 */ 310 */
309 PWM_ASSERT(inField); 311 PWM_ASSERT(inField);
310 rv = 2; // data end 312 rv = 2; // data end
311 goto out; 313 goto out;
312 } 314 }
313 if (!isQuoted && inField) { 315 if (!isQuoted && inField) {
314 // That's the end of the last unquoted field. 316 // That's the end of the last unquoted field.
315 rv = 2; // data end 317 rv = 2; // data end
316 goto out; 318 goto out;
317 } 319 }
318 if (!inField) { 320 if (!inField) {
319 // This is expected EOF 321 // This is expected EOF
320 rv = 2; // data end 322 rv = 2; // data end
321 goto out; 323 goto out;
322 } 324 }
323 325
324unexp_eof: 326unexp_eof:
325 printDebug("unexpected EOF :("); 327 printDebug("unexpected EOF :(");
326 return -1; // parser error 328 return -1; // parser error
327 329
328out: 330out:
329 if (!isQuoted) 331 if (!isQuoted)
330 *ret = ret->stripWhiteSpace(); 332 *ret = ret->stripWhiteSpace();
331 *_refIndex = refIndex + 1; 333 *_refIndex = refIndex + 1;
332 return rv; 334 return rv;
333} 335}
334 336
335bool Csv::exportData(const QString &filepath, 337bool Csv::exportData(const QString &filepath,
336 PwMDoc *doc) 338 PwMDoc *doc)
337{ 339{
338 PWM_ASSERT(!doc->isDocEmpty()); 340 PWM_ASSERT(!doc->isDocEmpty());
339 bool ret = true; 341 bool ret = true;
340 if (QFile::exists(filepath)) { 342 if (QFile::exists(filepath)) {
341 int ret; 343 int ret;
342 ret = KMessageBox::questionYesNo(parent, 344 ret = KMessageBox::questionYesNo(parent,
343 i18n("This file does already exist.\n" 345 i18n("This file does already exist.\n"
344 "Do you want to overwrite it?"), 346 "Do you want to overwrite it?"),
345 i18n("Overwrite file?")); 347 i18n("Overwrite file?"));
346 if (ret == KMessageBox::No) 348 if (ret == KMessageBox::No)
347 return false; 349 return false;
348 if (!QFile::remove(filepath)) { 350 if (!QFile::remove(filepath)) {
349 KMessageBox::error(parent, 351 KMessageBox::error(parent,
350 i18n("Could not delete the old file."), 352 i18n("Could not delete the old file."),
351 i18n("Delete error.")); 353 i18n("Delete error."));
352 return false; 354 return false;
353 } 355 }
354 } 356 }
355 QFile f(filepath); 357 QFile f(filepath);
356 if (!f.open(IO_ReadWrite)) { 358 if (!f.open(QIODevice::ReadWrite)) {
357 KMessageBox::error(parent, 359 KMessageBox::error(parent,
358 i18n("Could not open file for writing."), 360 i18n("Could not open file for writing."),
359 i18n("Open error.")); 361 i18n("Open error."));
360 ret = false; 362 ret = false;
361 goto out; 363 goto out;
362 } 364 }
363 doc->unlockAll_tempoary(); 365 doc->unlockAll_tempoary();
364 if (!doExport(f, doc)) 366 if (!doExport(f, doc))
365 ret = false; 367 ret = false;
366 doc->unlockAll_tempoary(true); 368 doc->unlockAll_tempoary(true);
367 f.close(); 369 f.close();
368out: 370out:
369 return ret; 371 return ret;
370} 372}
371 373
372bool Csv::doExport(QFile &f, 374bool Csv::doExport(QFile &f,
373 PwMDoc *doc) 375 PwMDoc *doc)
374{ 376{
375 unsigned int numCat = doc->numCategories(); 377 unsigned int numCat = doc->numCategories();
376 unsigned int numEntr; 378 unsigned int numEntr;
377 unsigned int i, j; 379 unsigned int i, j;
378 PwMDataItem d; 380 PwMDataItem d;
379 QCString s, catName; 381 Q3CString s, catName;
380 QByteArray b; 382 QByteArray b;
381 383
382 for (i = 0; i < numCat; ++i) { 384 for (i = 0; i < numCat; ++i) {
383 numEntr = doc->numEntries(i); 385 numEntr = doc->numEntries(i);
384 catName = newField(doc->getCategory(i)->c_str()); 386 catName = newField(doc->getCategory(i)->c_str());
385 for (j = 0; j < numEntr; ++j) { 387 for (j = 0; j < numEntr; ++j) {
386 doc->getEntry(i, j, &d); 388 doc->getEntry(i, j, &d);
387 s = catName; 389 s = catName;
388 s += ",,"; 390 s += ",,";
389 s += newField(d.desc.c_str()); 391 s += newField(d.desc.c_str());
390 s += ","; 392 s += ",";
391 s += newField(d.name.c_str()); 393 s += newField(d.name.c_str());
392 s += ","; 394 s += ",";
393 s += newField(d.pw.c_str()); 395 s += newField(d.pw.c_str());
394 s += ","; 396 s += ",";
395 s += newField(d.url.c_str()); 397 s += newField(d.url.c_str());
396 s += ","; 398 s += ",";
397 s += newField(d.launcher.c_str()); 399 s += newField(d.launcher.c_str());
398 s += ","; 400 s += ",";
399 s += newField(d.comment.c_str()); 401 s += newField(d.comment.c_str());
400 s += "\r\n"; 402 s += "\r\n";
401 b = s; 403 b = s;
402 // remove \0 termination 404 // remove \0 termination
403#ifndef PWM_EMBEDDED 405#ifndef PWM_EMBEDDED
404 b.resize(b.size() - 1, QGArray::SpeedOptim); 406 b.resize(b.size() - 1, Q3GArray::SpeedOptim);
405#else 407#else
406 b.resize(b.size() - 1); 408 b.resize(b.size() - 1);
407#endif 409#endif
408 if (!f.writeBlock(b)) 410 if (!f.writeBlock(b))
409 return false; 411 return false;
410 } 412 }
411 } 413 }
412 return true; 414 return true;
413} 415}
414 416
415QCString Csv::newField(QCString s) 417Q3CString Csv::newField(Q3CString s)
416{ 418{
417 if (s.isEmpty()) 419 if (s.isEmpty())
418 return QCString(); 420 return Q3CString();
419 QCString ret("\""); 421 Q3CString ret("\"");
420#ifndef PWM_EMBEDDED 422#ifndef PWM_EMBEDDED
421 s.replace('\"', "\"\""); 423 s.replace('\"', "\"\"");
422#else 424#else
423 s.replace(QRegExp("\""), "\"\""); 425 s.replace("\"", "\"\"");
424#endif 426#endif
425 ret += s; 427 ret += s;
426 ret += "\""; 428 ret += "\"";
427 return ret; 429 return ret;
428} 430}
diff --git a/pwmanager/pwmanager/csv.h b/pwmanager/pwmanager/csv.h
index 6f3c1e1..8049122 100644
--- a/pwmanager/pwmanager/csv.h
+++ b/pwmanager/pwmanager/csv.h
@@ -1,91 +1,91 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 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.1 of pwmanager 14 * This file is originaly based on version 1.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 * The original file version was 1.2 16 * The original file version was 1.2
17 * $Id$ 17 * $Id$
18 **************************************************************************/ 18 **************************************************************************/
19 19
20 20
21#ifndef __PWMANAGER_CSV_H 21#ifndef __PWMANAGER_CSV_H
22#define __PWMANAGER_CSV_H 22#define __PWMANAGER_CSV_H
23 23
24#include <qcstring.h> 24#include <q3cstring.h>
25#include <qfile.h> 25#include <qfile.h>
26 26
27 27
28class PwMDoc; 28class PwMDoc;
29class QString; 29class QString;
30class QWidget; 30class QWidget;
31 31
32/** class for CSV (Comma Separated Value) export and import. 32/** class for CSV (Comma Separated Value) export and import.
33 * 33 *
34 * http://www.creativyst.com/Doc/Articles/CSV/CSV01.htm 34 * http://www.creativyst.com/Doc/Articles/CSV/CSV01.htm
35 * http://en.wikipedia.org/wiki/Comma-separated_values 35 * http://en.wikipedia.org/wiki/Comma-separated_values
36 * 36 *
37 * There are two types of CSV output we can produce. 37 * There are two types of CSV output we can produce.
38 * One with Category support (recommended): 38 * One with Category support (recommended):
39 * "Category 1",, "Desc 1", "Username 1", "Password 1", "URL 1", "Launcher 1", "Comment 1" 39 * "Category 1",, "Desc 1", "Username 1", "Password 1", "URL 1", "Launcher 1", "Comment 1"
40 * "Category 1",, "Desc 2", "Username 2", "Password 2", "URL 2", "Launcher 2", "Comment 2" 40 * "Category 1",, "Desc 2", "Username 2", "Password 2", "URL 2", "Launcher 2", "Comment 2"
41 * ... 41 * ...
42 * The empty "" is neccessary, because in future versions we will 42 * The empty "" is neccessary, because in future versions we will
43 * support nested Categories. We want to be future compatible, now. 43 * support nested Categories. We want to be future compatible, now.
44 * 44 *
45 * And one without Category support: 45 * And one without Category support:
46 *FIXME: it's not implemented, yet. ;) 46 *FIXME: it's not implemented, yet. ;)
47 * "Desc 1", "Username 1", "Password 1", "URL 1", "Launcher 1", "Comment 1" 47 * "Desc 1", "Username 1", "Password 1", "URL 1", "Launcher 1", "Comment 1"
48 * "Desc 2", "Username 2", "Password 2", "URL 2", "Launcher 2", "Comment 2" 48 * "Desc 2", "Username 2", "Password 2", "URL 2", "Launcher 2", "Comment 2"
49 * ... 49 * ...
50 * 50 *
51 */ 51 */
52class Csv 52class Csv
53{ 53{
54public: 54public:
55 Csv(QWidget *_parent); 55 Csv(QWidget *_parent);
56 ~Csv(); 56 ~Csv();
57 57
58 /** import data from "filepath" into "doc" */ 58 /** import data from "filepath" into "doc" */
59 bool importData(const QString &filepath, 59 bool importData(const QString &filepath,
60 PwMDoc *doc); 60 PwMDoc *doc);
61 /** export data from "doc" to "filepath" */ 61 /** export data from "doc" to "filepath" */
62 bool exportData(const QString &filepath, 62 bool exportData(const QString &filepath,
63 PwMDoc *doc); 63 PwMDoc *doc);
64 64
65protected: 65protected:
66 /** do the import process. */ 66 /** do the import process. */
67 bool doImport(const QByteArray &d, 67 bool doImport(const QByteArray &d,
68 PwMDoc *doc); 68 PwMDoc *doc);
69 /** parse for the next field. 69 /** parse for the next field.
70 * @return Return values are: 70 * @return Return values are:
71 * 0 -> successfully got the next field. 71 * 0 -> successfully got the next field.
72 * 1 -> record end. 72 * 1 -> record end.
73 * 2 -> data end. 73 * 2 -> data end.
74 * -1 -> parser error. 74 * -1 -> parser error.
75 */ 75 */
76 int nextField(QCString *ret, 76 int nextField(Q3CString *ret,
77 const QByteArray &in, 77 const QByteArray &in,
78 bool inRecord, 78 bool inRecord,
79 int *_refIndex); 79 int *_refIndex);
80 /** do the export process. */ 80 /** do the export process. */
81 bool doExport(QFile &f, 81 bool doExport(QFile &f,
82 PwMDoc *doc); 82 PwMDoc *doc);
83 /** generate a new data field string. */ 83 /** generate a new data field string. */
84 QCString newField(QCString s); 84 Q3CString newField(Q3CString s);
85 85
86protected: 86protected:
87 /** current parent widget. */ 87 /** current parent widget. */
88 QWidget *parent; 88 QWidget *parent;
89}; 89};
90 90
91#endif // __PWMANAGER_CSV_H 91#endif // __PWMANAGER_CSV_H
diff --git a/pwmanager/pwmanager/editcategory.cpp b/pwmanager/pwmanager/editcategory.cpp
index 4e2378c..4f19299 100644
--- a/pwmanager/pwmanager/editcategory.cpp
+++ b/pwmanager/pwmanager/editcategory.cpp
@@ -1,189 +1,191 @@
1/* 1/*
2 This file is part of PwManager/Platform independent. 2 This file is part of PwManager/Platform independent.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22 22
23$Id$ 23$Id$
24*/ 24*/
25 25
26#include "editcategory.h" 26#include "editcategory.h"
27#include "pwmdoc.h" 27#include "pwmdoc.h"
28 28
29#include <qlayout.h> 29#include <qlayout.h>
30#include <qlabel.h> 30#include <qlabel.h>
31#include <qgroupbox.h> 31#include <q3groupbox.h>
32//Added by qt3to4:
33#include <Q3GridLayout>
32#include <klocale.h> 34#include <klocale.h>
33#include <kcombobox.h> 35#include <kcombobox.h>
34#include <klineedit.h> 36#include <klineedit.h>
35#include <qpushbutton.h> 37#include <qpushbutton.h>
36 38
37 39
38/* 40/*
39 * Constructs a addEntryWnd as a child of 'parent', with the 41 * Constructs a addEntryWnd as a child of 'parent', with the
40 * name 'name' and widget flags set to 'f'. 42 * name 'name' and widget flags set to 'f'.
41 * 43 *
42 * The dialog will by default be modeless, unless you set 'modal' to 44 * The dialog will by default be modeless, unless you set 'modal' to
43 * TRUE to construct a modal dialog. 45 * TRUE to construct a modal dialog.
44 */ 46 */
45editCategoryWnd::editCategoryWnd( PwMDoc* d, QWidget* parent, const char* name) 47editCategoryWnd::editCategoryWnd( PwMDoc* d, QWidget* parent, const char* name)
46 : KDialogBase( KDialogBase::Plain, i18n( "edit category descriptions" ), 48 : KDialogBase( KDialogBase::Plain, i18n( "edit category descriptions" ),
47 Apply | User2 | Ok, 49 Apply | User2 | Ok,
48 Ok, parent, name, true ), 50 Ok, parent, name, true ),
49 doc(d) 51 doc(d)
50{ 52{
51 findButton( Ok )->setText (i18n("Close" )) ; 53 findButton( Ok )->setText (i18n("Close" )) ;
52 findButton( User2 )->setText (i18n("Cancel" )) ; 54 findButton( User2 )->setText (i18n("Cancel" )) ;
53 connect(this,SIGNAL(user2Clicked()), SLOT(cancel_slot())); 55 connect(this,SIGNAL(user2Clicked()), SLOT(cancel_slot()));
54 enableButton( KDialogBase::Apply, false ); 56 enableButton( KDialogBase::Apply, false );
55 57
56 58
57 QWidget *page = plainPage(); 59 QWidget *page = plainPage();
58 QGridLayout *layout = new QGridLayout( page, 3, 1 ); 60 Q3GridLayout *layout = new Q3GridLayout( page, 3, 1 );
59 layout->setMargin( KDialogBase::marginHint() ); 61 layout->setMargin( KDialogBase::marginHint() );
60 layout->setSpacing( KDialogBase::spacingHint() ); 62 layout->setSpacing( KDialogBase::spacingHint() );
61 63
62 int i = 0; 64 int i = 0;
63 categoryComboBox = new KComboBox( page ); 65 categoryComboBox = new KComboBox( page );
64 QLabel* label = new QLabel( categoryComboBox, i18n("Category:"), page ); 66 QLabel* label = new QLabel( categoryComboBox, i18n("Category:"), page );
65 layout->addWidget( label, i, 0 ); 67 layout->addWidget( label, i, 0 );
66 layout->addWidget( categoryComboBox, i, 1 ); 68 layout->addWidget( categoryComboBox, i, 1 );
67 i++; 69 i++;
68 categoryComboBox->setEditable( FALSE ); 70 categoryComboBox->setEditable( FALSE );
69 categoryComboBox->setSizeLimit( 100 ); 71 categoryComboBox->setMaxVisibleItems( 100 );
70 connect(categoryComboBox,SIGNAL(activated(const QString&)), SLOT(categorySelected(const QString&))); 72 connect(categoryComboBox,SIGNAL(activated(const QString&)), SLOT(categorySelected(const QString&)));
71 73
72 74
73 descLineEdit = new KLineEdit( page, "descLineEdit" ); 75 descLineEdit = new KLineEdit( page, "descLineEdit" );
74 label = new QLabel( descLineEdit, i18n("Text1 (Description):"), page ); 76 label = new QLabel( descLineEdit, i18n("Text1 (Description):"), page );
75 layout->addWidget( label, i, 0 ); 77 layout->addWidget( label, i, 0 );
76 layout->addWidget( descLineEdit, i, 1 ); 78 layout->addWidget( descLineEdit, i, 1 );
77 connect( descLineEdit, SIGNAL( textChanged ( const QString & ) ), SLOT( widgetModified(const QString &) ) ); 79 connect( descLineEdit, SIGNAL( textChanged ( const QString & ) ), SLOT( widgetModified(const QString &) ) );
78 i++; 80 i++;
79 81
80 usernameLineEdit = new KLineEdit( page, "usernameLineEdit" ); 82 usernameLineEdit = new KLineEdit( page, "usernameLineEdit" );
81 label = new QLabel( usernameLineEdit, i18n("Text2 (Username):"), page ); 83 label = new QLabel( usernameLineEdit, i18n("Text2 (Username):"), page );
82 layout->addWidget( label, i, 0 ); 84 layout->addWidget( label, i, 0 );
83 layout->addWidget( usernameLineEdit, i, 1 ); 85 layout->addWidget( usernameLineEdit, i, 1 );
84 connect( usernameLineEdit, SIGNAL( textChanged ( const QString & ) ), SLOT( widgetModified(const QString &) ) ); 86 connect( usernameLineEdit, SIGNAL( textChanged ( const QString & ) ), SLOT( widgetModified(const QString &) ) );
85 i++; 87 i++;
86 88
87 pwLineEdit = new KLineEdit( page, "pwLineEdit" ); 89 pwLineEdit = new KLineEdit( page, "pwLineEdit" );
88 label = new QLabel( pwLineEdit, i18n("Text3 (Password):"), page ); 90 label = new QLabel( pwLineEdit, i18n("Text3 (Password):"), page );
89 layout->addWidget( label, i, 0 ); 91 layout->addWidget( label, i, 0 );
90 layout->addWidget( pwLineEdit, i, 1 ); 92 layout->addWidget( pwLineEdit, i, 1 );
91 connect( pwLineEdit, SIGNAL( textChanged ( const QString & ) ), SLOT( widgetModified(const QString &) ) ); 93 connect( pwLineEdit, SIGNAL( textChanged ( const QString & ) ), SLOT( widgetModified(const QString &) ) );
92 i++; 94 i++;
93 95
94 unsigned int count = doc->numCategories(); 96 unsigned int count = doc->numCategories();
95 97
96 for (unsigned int i = 0; i < count; ++i) { 98 for (unsigned int i = 0; i < count; ++i) {
97 categoryComboBox->insertItem(doc->getCategory(i)->c_str()); 99 categoryComboBox->insertItem(doc->getCategory(i)->c_str());
98 } 100 }
99 101
100 //PwMCategoryItem* getCategoryEntry(unsigned int index) 102 //PwMCategoryItem* getCategoryEntry(unsigned int index)
101 // { return &(dti.dta[index]); } 103 // { return &(dti.dta[index]); }
102 104
103 105
104 106
105} 107}
106 108
107/* 109/*
108 * Destroys the object and frees any allocated resources 110 * Destroys the object and frees any allocated resources
109 */ 111 */
110editCategoryWnd::~editCategoryWnd() 112editCategoryWnd::~editCategoryWnd()
111{ 113{
112 // no need to delete child widgets, Qt does it all for us 114 // no need to delete child widgets, Qt does it all for us
113} 115}
114 116
115void editCategoryWnd::slotOk() 117void editCategoryWnd::slotOk()
116{ 118{
117 // qDebug( "addEntryWnd::slotOk(): Not implemented yet" ); 119 // qDebug( "addEntryWnd::slotOk(): Not implemented yet" );
118 slotApply(); 120 slotApply();
119 accept(); 121 accept();
120} 122}
121 123
122void editCategoryWnd::slotApply() 124void editCategoryWnd::slotApply()
123{ 125{
124 QString cat = categoryComboBox->currentText(); 126 QString cat = categoryComboBox->currentText();
125 127
126 unsigned int idx; 128 unsigned int idx;
127 bool found = doc->findCategory(cat, &idx); 129 bool found = doc->findCategory(cat, &idx);
128 130
129 if (found == true) 131 if (found == true)
130 { 132 {
131 PwMCategoryItem* catitem = doc->getCategoryEntry(idx); 133 PwMCategoryItem* catitem = doc->getCategoryEntry(idx);
132 134
133 catitem->desc_text = descLineEdit->text().latin1(); 135 catitem->desc_text = descLineEdit->text().latin1();
134 catitem->name_text = usernameLineEdit->text().latin1(); 136 catitem->name_text = usernameLineEdit->text().latin1();
135 catitem->pw_text = pwLineEdit->text().latin1(); 137 catitem->pw_text = pwLineEdit->text().latin1();
136 enableButton( KDialogBase::Apply, false ); 138 enableButton( KDialogBase::Apply, false );
137 return; 139 return;
138 } 140 }
139 141
140 BUG(); 142 BUG();
141 143
142} 144}
143 145
144void editCategoryWnd::cancel_slot() 146void editCategoryWnd::cancel_slot()
145{ 147{
146 QString cat = categoryComboBox->currentText(); 148 QString cat = categoryComboBox->currentText();
147 categorySelected ( cat ); 149 categorySelected ( cat );
148 reject(); 150 reject();
149} 151}
150 152
151void editCategoryWnd::setCurrCategory(const QString &cat) 153void editCategoryWnd::setCurrCategory(const QString &cat)
152{ 154{
153 int i, count = categoryComboBox->count(); 155 int i, count = categoryComboBox->count();
154 156
155 for (i = 0; i < count; ++i) { 157 for (i = 0; i < count; ++i) {
156 if (categoryComboBox->text(i) == cat) { 158 if (categoryComboBox->text(i) == cat) {
157 categoryComboBox->setCurrentItem(i); 159 categoryComboBox->setCurrentItem(i);
158 categorySelected ( cat ); 160 categorySelected ( cat );
159 return; 161 return;
160 } 162 }
161 } 163 }
162 BUG(); 164 BUG();
163} 165}
164 166
165void editCategoryWnd::categorySelected ( const QString & string ) 167void editCategoryWnd::categorySelected ( const QString & string )
166{ 168{
167 unsigned int idx; 169 unsigned int idx;
168 bool found = doc->findCategory(string, &idx); 170 bool found = doc->findCategory(string, &idx);
169 171
170 if (found == true) 172 if (found == true)
171 { 173 {
172 PwMCategoryItem* catitem = doc->getCategoryEntry(idx); 174 PwMCategoryItem* catitem = doc->getCategoryEntry(idx);
173 175
174 descLineEdit->setText(catitem->desc_text.c_str()); 176 descLineEdit->setText(catitem->desc_text.c_str());
175 usernameLineEdit->setText(catitem->name_text.c_str()); 177 usernameLineEdit->setText(catitem->name_text.c_str());
176 pwLineEdit->setText(catitem->pw_text.c_str()); 178 pwLineEdit->setText(catitem->pw_text.c_str());
177 enableButton( KDialogBase::Apply, false ); 179 enableButton( KDialogBase::Apply, false );
178 return; 180 return;
179 } 181 }
180 182
181 BUG(); 183 BUG();
182 184
183} 185}
184 186
185void editCategoryWnd::widgetModified(const QString &) 187void editCategoryWnd::widgetModified(const QString &)
186{ 188{
187 enableButton( KDialogBase::Apply, true ); 189 enableButton( KDialogBase::Apply, true );
188} 190}
189 191
diff --git a/pwmanager/pwmanager/editcategory.h b/pwmanager/pwmanager/editcategory.h
index 90b685b..10a012b 100644
--- a/pwmanager/pwmanager/editcategory.h
+++ b/pwmanager/pwmanager/editcategory.h
@@ -1,77 +1,82 @@
1/* 1/*
2 This file is part of PwManager/Platform independent. 2 This file is part of PwManager/Platform independent.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22 22
23$Id$ 23$Id$
24*/ 24*/
25 25
26#ifndef EDITCATEGORY_H 26#ifndef EDITCATEGORY_H
27#define EDITCATEGORY_H 27#define EDITCATEGORY_H
28 28
29#include <qvariant.h> 29#include <qvariant.h>
30//Added by qt3to4:
31#include <Q3VBoxLayout>
32#include <Q3GridLayout>
33#include <Q3HBoxLayout>
34#include <QLabel>
30#include <kdialogbase.h> 35#include <kdialogbase.h>
31 36
32class QVBoxLayout; 37class Q3VBoxLayout;
33class QHBoxLayout; 38class Q3HBoxLayout;
34class QGridLayout; 39class Q3GridLayout;
35class QSpacerItem; 40class QSpacerItem;
36class KLineEdit; 41class KLineEdit;
37class QPushButton; 42class QPushButton;
38class KComboBox; 43class KComboBox;
39class QLabel; 44class QLabel;
40class QGroupBox; 45class Q3GroupBox;
41class QMultiLineEdit; 46class Q3MultiLineEdit;
42class PwMDoc; 47class PwMDoc;
43 48
44class editCategoryWnd : public KDialogBase 49class editCategoryWnd : public KDialogBase
45{ 50{
46 Q_OBJECT 51 Q_OBJECT
47 52
48public: 53public:
49 editCategoryWnd( PwMDoc* doc, QWidget* parent = 0, const char* name = 0); 54 editCategoryWnd( PwMDoc* doc, QWidget* parent = 0, const char* name = 0);
50 ~editCategoryWnd(); 55 ~editCategoryWnd();
51 56
52 void setCurrCategory(const QString &cat); 57 void setCurrCategory(const QString &cat);
53 58
54 KComboBox* categoryComboBox; 59 KComboBox* categoryComboBox;
55 KLineEdit* descLineEdit; 60 KLineEdit* descLineEdit;
56 KLineEdit* usernameLineEdit; 61 KLineEdit* usernameLineEdit;
57 KLineEdit* pwLineEdit; 62 KLineEdit* pwLineEdit;
58 63
59 //public slots: 64 //public slots:
60 // virtual void revealButton_slot(); 65 // virtual void revealButton_slot();
61 // virtual void generateButton_slot(); 66 // virtual void generateButton_slot();
62 // virtual void advancedCommentButton_slot(bool on); 67 // virtual void advancedCommentButton_slot(bool on);
63 68
64 protected slots: 69 protected slots:
65 virtual void slotOk(); 70 virtual void slotOk();
66 virtual void slotApply(); 71 virtual void slotApply();
67 virtual void cancel_slot(); 72 virtual void cancel_slot();
68 73
69 virtual void categorySelected ( const QString & string ); 74 virtual void categorySelected ( const QString & string );
70 virtual void widgetModified(const QString &); 75 virtual void widgetModified(const QString &);
71 76
72 private: 77 private:
73 PwMDoc* doc; 78 PwMDoc* doc;
74 79
75}; 80};
76 81
77#endif // EDITCATEGORY_H 82#endif // EDITCATEGORY_H
diff --git a/pwmanager/pwmanager/findwnd_emb.cpp b/pwmanager/pwmanager/findwnd_emb.cpp
index 6dcabe8..03d4e38 100644
--- a/pwmanager/pwmanager/findwnd_emb.cpp
+++ b/pwmanager/pwmanager/findwnd_emb.cpp
@@ -1,123 +1,125 @@
1/* 1/*
2 This file is part of PwManager/Platform independent. 2 This file is part of PwManager/Platform independent.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22 22
23$Id$ 23$Id$
24*/ 24*/
25 25
26#include "findwnd_emb.h" 26#include "findwnd_emb.h"
27 27
28#include <klocale.h> 28#include <klocale.h>
29 29
30#include <qcheckbox.h> 30#include <qcheckbox.h>
31#include <qbuttongroup.h> 31#include <q3buttongroup.h>
32#include <qradiobutton.h> 32#include <qradiobutton.h>
33#include <qlayout.h> 33#include <qlayout.h>
34//Added by qt3to4:
35#include <Q3VBoxLayout>
34#include <klineedit.h> 36#include <klineedit.h>
35#include <qlabel.h> 37#include <qlabel.h>
36 38
37/* 39/*
38#include <qvariant.h> 40#include <qvariant.h>
39#include <qlabel.h> 41#include <qlabel.h>
40#include <qlineedit.h> 42#include <qlineedit.h>
41#include <qpushbutton.h> 43#include <qpushbutton.h>
42#include <qcheckbox.h> 44#include <qcheckbox.h>
43#include <qbuttongroup.h> 45#include <qbuttongroup.h>
44#include <qradiobutton.h> 46#include <qradiobutton.h>
45#include <qlayout.h> 47#include <qlayout.h>
46#include <qtooltip.h> 48#include <qtooltip.h>
47#include <qwhatsthis.h> 49#include <qwhatsthis.h>
48*/ 50*/
49 51
50/* 52/*
51 * Constructs a findWnd as a child of 'parent', with the 53 * Constructs a findWnd as a child of 'parent', with the
52 * name 'name'. 54 * name 'name'.
53 */ 55 */
54findWnd::findWnd( QWidget* parent, const char* name ) 56findWnd::findWnd( QWidget* parent, const char* name )
55 : KDialogBase( KDialogBase::Plain, i18n( "Find" ), 57 : KDialogBase( KDialogBase::Plain, i18n( "Find" ),
56 KDialogBase::Ok | KDialogBase::Cancel, 58 KDialogBase::Ok | KDialogBase::Cancel,
57 KDialogBase::Ok, parent, name, true ) 59 KDialogBase::Ok, parent, name, true )
58{ 60{
59 QWidget *page = plainPage(); 61 QWidget *page = plainPage();
60 QVBoxLayout *layout = new QVBoxLayout( page ); 62 Q3VBoxLayout *layout = new Q3VBoxLayout( page );
61 layout->setMargin( KDialogBase::marginHint() ); 63 layout->setMargin( KDialogBase::marginHint() );
62 layout->setSpacing( KDialogBase::spacingHint() ); 64 layout->setSpacing( KDialogBase::spacingHint() );
63 65
64 exactCheckBox = new QCheckBox( i18n( "&Exact match" ), page ); 66 exactCheckBox = new QCheckBox( i18n( "&Exact match" ), page );
65 layout->addWidget( exactCheckBox ); 67 layout->addWidget( exactCheckBox );
66 68
67 caseSensCheckBox = new QCheckBox( i18n( "&Case sensitive" ), page ); 69 caseSensCheckBox = new QCheckBox( i18n( "&Case sensitive" ), page );
68 layout->addWidget( caseSensCheckBox ); 70 layout->addWidget( caseSensCheckBox );
69 71
70 72
71 QButtonGroup* buttonGroup1 = new QButtonGroup(1, Qt::Horizontal, i18n( "Search in Column" ), page ); 73 Q3ButtonGroup* buttonGroup1 = new Q3ButtonGroup(1, Qt::Horizontal, i18n( "Search in Column" ), page );
72 layout->addWidget( buttonGroup1 ); 74 layout->addWidget( buttonGroup1 );
73 75
74 descRadioButton = new QRadioButton( i18n( "&Description" ), buttonGroup1 ); 76 descRadioButton = new QRadioButton( i18n( "&Description" ), buttonGroup1 );
75 pwRadioButton = new QRadioButton( i18n( "&Password" ), buttonGroup1 ); 77 pwRadioButton = new QRadioButton( i18n( "&Password" ), buttonGroup1 );
76 commentRadioButton = new QRadioButton( i18n( "C&omment" ), buttonGroup1 ); 78 commentRadioButton = new QRadioButton( i18n( "C&omment" ), buttonGroup1 );
77 nameRadioButton = new QRadioButton( i18n( "&Username" ), buttonGroup1 ); 79 nameRadioButton = new QRadioButton( i18n( "&Username" ), buttonGroup1 );
78 urlRadioButton = new QRadioButton( i18n( "U&RL" ), buttonGroup1 ); 80 urlRadioButton = new QRadioButton( i18n( "U&RL" ), buttonGroup1 );
79 launcherRadioButton = new QRadioButton( i18n( "&Launcher" ), buttonGroup1 ); 81 launcherRadioButton = new QRadioButton( i18n( "&Launcher" ), buttonGroup1 );
80 descRadioButton->setChecked( TRUE ); 82 descRadioButton->setChecked( TRUE );
81 83
82 findLineEdit = new KLineEdit( page ); 84 findLineEdit = new KLineEdit( page );
83 // QLabel* label = new QLabel( findLineEdit, i18n( "Find:" ), page ); 85 // QLabel* label = new QLabel( findLineEdit, i18n( "Find:" ), page );
84 //layout->addWidget( label ); 86 //layout->addWidget( label );
85 layout->addWidget( findLineEdit ); 87 layout->addWidget( findLineEdit );
86 88
87 setButtonText( KDialogBase::Ok, "&Find" ); 89 setButtonText( KDialogBase::Ok, "&Find" );
88 setButtonText( KDialogBase::Cancel, "&Close" ); 90 setButtonText( KDialogBase::Cancel, "&Close" );
89 91
90 92
91 resize( sizeHint() ); 93 resize( sizeHint() );
92 94
93 95
94 connect( buttonGroup1, SIGNAL( clicked(int) ), this, SLOT( selectionChanged_slot() ) ); 96 connect( buttonGroup1, SIGNAL( clicked(int) ), this, SLOT( selectionChanged_slot() ) );
95 connect( findLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( selectionChanged_slot() ) ); 97 connect( findLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( selectionChanged_slot() ) );
96 connect( caseSensCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( selectionChanged_slot() ) ); 98 connect( caseSensCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( selectionChanged_slot() ) );
97 connect( exactCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( selectionChanged_slot() ) ); 99 connect( exactCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( selectionChanged_slot() ) );
98 100
99} 101}
100 102
101/* 103/*
102 * Destroys the object and frees any allocated resources 104 * Destroys the object and frees any allocated resources
103 */ 105 */
104findWnd::~findWnd() 106findWnd::~findWnd()
105{ 107{
106 // no need to delete child widgets, Qt does it all for us 108 // no need to delete child widgets, Qt does it all for us
107} 109}
108 110
109void findWnd::findButton_slot() 111void findWnd::findButton_slot()
110{ 112{
111 qWarning( "findWnd::findButton_slot(): Not implemented yet" ); 113 qWarning( "findWnd::findButton_slot(): Not implemented yet" );
112} 114}
113 115
114void findWnd::selectionChanged_slot() 116void findWnd::selectionChanged_slot()
115{ 117{
116 qWarning( "findWnd::selectionChanged_slot(): Not implemented yet" ); 118 qWarning( "findWnd::selectionChanged_slot(): Not implemented yet" );
117} 119}
118 120
119void findWnd::closeButton_slot() 121void findWnd::closeButton_slot()
120{ 122{
121 qWarning( "findWnd::closeButton_slot(): Not implemented yet" ); 123 qWarning( "findWnd::closeButton_slot(): Not implemented yet" );
122} 124}
123 125
diff --git a/pwmanager/pwmanager/findwndimpl.cpp b/pwmanager/pwmanager/findwndimpl.cpp
index 059219f..d323133 100644
--- a/pwmanager/pwmanager/findwndimpl.cpp
+++ b/pwmanager/pwmanager/findwndimpl.cpp
@@ -1,138 +1,138 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2003 by Michael Buesch * 3 * copyright (C) 2003 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 "findwndimpl.h" 20#include "findwndimpl.h"
21#include "pwmexception.h" 21#include "pwmexception.h"
22#include "pwmdoc.h" 22#include "pwmdoc.h"
23#include "pwmview.h" 23#include "pwmview.h"
24 24
25#include <qradiobutton.h> 25#include <qradiobutton.h>
26#include <qlineedit.h> 26#include <qlineedit.h>
27#include <qcheckbox.h> 27#include <qcheckbox.h>
28 28
29#include <kmessagebox.h> 29#include <kmessagebox.h>
30#include <klocale.h> 30#include <klocale.h>
31 31
32FindWndImpl::FindWndImpl(PwMView * _parent) 32FindWndImpl::FindWndImpl(PwMView * _parent)
33 : findWnd() 33 : findWnd()
34{ 34{
35 parent = _parent; 35 parent = _parent;
36 fAt = 0; 36 fAt = 0;
37 refVal = 0; 37 refVal = 0;
38 currFoundPos = -1; 38 currFoundPos = -1;
39 numEntries = parent->document()->numEntries(parent->getCurrentCategory()); 39 numEntries = parent->document()->numEntries(parent->getCurrentCategory());
40 connect(this, SIGNAL(foundAt(int)), parent, SLOT(selAt(int))); 40 connect(this, SIGNAL(foundAt(int)), parent, SLOT(selAt(int)));
41} 41}
42 42
43FindWndImpl::~FindWndImpl() 43FindWndImpl::~FindWndImpl()
44{ 44{
45} 45}
46 46
47void FindWndImpl::findButton_slot() 47void FindWndImpl::findButton_slot()
48{ 48{
49 if (findLineEdit->text() == "") 49 if (findLineEdit->text() == "")
50 return; 50 return;
51 static vector<unsigned int> foundPositions; 51 static vector<unsigned int> foundPositions;
52 PwMDoc *doc = parent->document(); 52 PwMDoc *doc = parent->document();
53 53
54 if (currFoundPos < 0) { 54 if (currFoundPos < 0) {
55 bool unlockedTempoary = false; 55 bool unlockedTempoary = false;
56 foundPositions.clear(); 56 foundPositions.clear();
57 PwMDataItem findThis; 57 PwMDataItem findThis;
58 unsigned int searchIn = 0; 58 unsigned int searchIn = 0;
59 59
60 if (descRadioButton->isChecked()) { 60 if (descRadioButton->isChecked()) {
61 searchIn = SEARCH_IN_DESC; 61 searchIn = SEARCH_IN_DESC;
62 findThis.desc = findLineEdit->text().latin1(); 62 findThis.desc = findLineEdit->text().latin1();
63 } else if (nameRadioButton->isChecked()) { 63 } else if (nameRadioButton->isChecked()) {
64 searchIn = SEARCH_IN_NAME; 64 searchIn = SEARCH_IN_NAME;
65 findThis.name = findLineEdit->text().latin1(); 65 findThis.name = findLineEdit->text().latin1();
66 } else if (pwRadioButton->isChecked()) { 66 } else if (pwRadioButton->isChecked()) {
67 searchIn = SEARCH_IN_PW; 67 searchIn = SEARCH_IN_PW;
68 findThis.pw = findLineEdit->text().latin1(); 68 findThis.pw = findLineEdit->text().latin1();
69 } else if (commentRadioButton->isChecked()) { 69 } else if (commentRadioButton->isChecked()) {
70 searchIn = SEARCH_IN_COMMENT; 70 searchIn = SEARCH_IN_COMMENT;
71 findThis.comment = findLineEdit->text().latin1(); 71 findThis.comment = findLineEdit->text().latin1();
72 } else if (urlRadioButton->isChecked()) { 72 } else if (urlRadioButton->isChecked()) {
73 searchIn = SEARCH_IN_URL; 73 searchIn = SEARCH_IN_URL;
74 findThis.url = findLineEdit->text().latin1(); 74 findThis.url = findLineEdit->text().latin1();
75 } else if (launcherRadioButton->isChecked()) { 75 } else if (launcherRadioButton->isChecked()) {
76 searchIn = SEARCH_IN_LAUNCHER; 76 searchIn = SEARCH_IN_LAUNCHER;
77 findThis.launcher = findLineEdit->text().latin1(); 77 findThis.launcher = findLineEdit->text().latin1();
78 } 78 }
79 79
80 if (pwRadioButton->isChecked()) { 80 if (pwRadioButton->isChecked()) {
81 if (!doc->unlockAll_tempoary()) 81 if (!doc->unlockAll_tempoary())
82 return; 82 return;
83 unlockedTempoary = true; 83 unlockedTempoary = true;
84 } 84 }
85 doc->findEntry(parent->getCurrentCategory(), findThis, 85 doc->findEntry(parent->getCurrentCategory(), findThis,
86 searchIn, &foundPositions, false, 86 searchIn, &foundPositions, false,
87 caseSensCheckBox->isChecked(), 87 caseSensCheckBox->isChecked(),
88 exactCheckBox->isChecked(), 88 exactCheckBox->isChecked(),
89 true); 89 true);
90 if (unlockedTempoary) { 90 if (unlockedTempoary) {
91 doc->unlockAll_tempoary(true); 91 doc->unlockAll_tempoary(true);
92 } 92 }
93 93
94 if (!foundPositions.size()) { 94 if (!foundPositions.size()) {
95 KMessageBox::information(this, 95 KMessageBox::information(this,
96 i18n("No entry found."), 96 i18n("No entry found."),
97 i18n("not found")); 97 i18n("not found"));
98 return; 98 return;
99 } 99 }
100 currFoundPos = 0; 100 currFoundPos = 0;
101 } 101 }
102 102
103 int lvp = doc->getListViewPos(parent->getCurrentCategory(), 103 int lvp = doc->getListViewPos(parent->getCurrentCategory(),
104 foundPositions[currFoundPos++]); 104 foundPositions[currFoundPos++]);
105 emit foundAt(numEntries - 1 - lvp); 105 emit foundAt(numEntries - 1 - lvp);
106 106
107 if (currFoundPos + 1 > static_cast<int>(foundPositions.size())) 107 if (currFoundPos + 1 > static_cast<int>(foundPositions.size()))
108 currFoundPos = 0; 108 currFoundPos = 0;
109} 109}
110 110
111 111
112#ifdef PWM_EMBEDDED 112#ifdef PWM_EMBEDDED
113void FindWndImpl::slotOk() 113void FindWndImpl::slotOk()
114{ 114{
115 findButton_slot(); 115 findButton_slot();
116 116
117 //do not call KDialogBase::slotOk() here 117 //do not call KDialogBase::slotOk() here
118 // user should press the close button instead 118 // user should press the close button instead
119} 119}
120#endif 120#endif
121 121
122void FindWndImpl::closeButton_slot() 122void FindWndImpl::closeButton_slot()
123{ 123{
124#ifndef PWM_EMBEDDED 124#ifndef PWM_EMBEDDED
125 done(0); 125 done(0);
126#endif 126#endif
127} 127}
128 128
129void FindWndImpl::selectionChanged_slot() 129void FindWndImpl::selectionChanged_slot()
130{ 130{
131 fAt = 0; 131 fAt = 0;
132 refVal = 0; 132 refVal = 0;
133 currFoundPos = -1; 133 currFoundPos = -1;
134} 134}
135 135
136#ifndef PWM_EMBEDDED 136#ifndef PWM_EMBEDDED_
137#include "findwndimpl.moc" 137#include "moc_findwndimpl.cpp"
138#endif 138#endif
diff --git a/pwmanager/pwmanager/genpasswd.cpp b/pwmanager/pwmanager/genpasswd.cpp
index 41078b3..82f0c06 100644
--- a/pwmanager/pwmanager/genpasswd.cpp
+++ b/pwmanager/pwmanager/genpasswd.cpp
@@ -1,193 +1,195 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 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 "genpasswd.h" 20#include "genpasswd.h"
21#include "pwmexception.h" 21#include "pwmexception.h"
22#include "randomizer.h" 22#include "randomizer.h"
23#include "globalstuff.h" 23#include "globalstuff.h"
24//Added by qt3to4:
25#include <Q3PtrList>
24 26
25 27
26/* how often can a char of the same charset be reused in order */ 28/* how often can a char of the same charset be reused in order */
27 #define FILTER_MAX_CHARSET_REUSE3 29 #define FILTER_MAX_CHARSET_REUSE3
28/* re-randomize all charsets on every iteration (0/1) */ 30/* re-randomize all charsets on every iteration (0/1) */
29 #define RERAND_CHARSET 0 31 #define RERAND_CHARSET 0
30 32
31 33
32struct staticCharsetStruct 34struct staticCharsetStruct
33{ 35{
34 const char *lower; 36 const char *lower;
35 const char *upper; 37 const char *upper;
36 const char *num; 38 const char *num;
37 const char *special; 39 const char *special;
38 const char *blank; 40 const char *blank;
39}; 41};
40 42
41static struct staticCharsetStruct staticCharset = { 43static struct staticCharsetStruct staticCharset = {
42 "abcdefghijklmnopqrstuvwxyz", 44 "abcdefghijklmnopqrstuvwxyz",
43 "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 45 "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
44 "0123456789", 46 "0123456789",
45 "!\"§$%&/()=?,.-;:_+", 47 "!\"§$%&/()=?,.-;:_+",
46 " " 48 " "
47}; 49};
48 50
49 51
50GenPasswd::GenPasswd() 52GenPasswd::GenPasswd()
51 : length (8) 53 : length (8)
52 , useFilter (true) 54 , useFilter (true)
53{ 55{
54 dynCharset.setAutoDelete(true); 56 dynCharset.setAutoDelete(true);
55} 57}
56 58
57void GenPasswd::setCharset(bool lower, 59void GenPasswd::setCharset(bool lower,
58 bool upper, 60 bool upper,
59 bool num, 61 bool num,
60 bool special, 62 bool special,
61 bool blank, 63 bool blank,
62 QString user) 64 QString user)
63{ 65{
64 unsigned int sanityCheck = 0; 66 unsigned int sanityCheck = 0;
65 dynCharset_element *tmpElement; 67 dynCharset_element *tmpElement;
66 dynCharset.clear(); 68 dynCharset.clear();
67 if (lower) { 69 if (lower) {
68 tmpElement = new dynCharset_element; 70 tmpElement = new dynCharset_element;
69 tmpElement->refCnt = 0; 71 tmpElement->refCnt = 0;
70 tmpElement->data = staticCharset.lower; 72 tmpElement->data = staticCharset.lower;
71 dynCharset.append(tmpElement); 73 dynCharset.append(tmpElement);
72 ++sanityCheck; 74 ++sanityCheck;
73 } 75 }
74 if (upper) { 76 if (upper) {
75 tmpElement = new dynCharset_element; 77 tmpElement = new dynCharset_element;
76 tmpElement->refCnt = 0; 78 tmpElement->refCnt = 0;
77 tmpElement->data = staticCharset.upper; 79 tmpElement->data = staticCharset.upper;
78 dynCharset.append(tmpElement); 80 dynCharset.append(tmpElement);
79 ++sanityCheck; 81 ++sanityCheck;
80 } 82 }
81 if (num) { 83 if (num) {
82 tmpElement = new dynCharset_element; 84 tmpElement = new dynCharset_element;
83 tmpElement->refCnt = 0; 85 tmpElement->refCnt = 0;
84 tmpElement->data = staticCharset.num; 86 tmpElement->data = staticCharset.num;
85 dynCharset.append(tmpElement); 87 dynCharset.append(tmpElement);
86 ++sanityCheck; 88 ++sanityCheck;
87 } 89 }
88 if (special) { 90 if (special) {
89 tmpElement = new dynCharset_element; 91 tmpElement = new dynCharset_element;
90 tmpElement->refCnt = 0; 92 tmpElement->refCnt = 0;
91 tmpElement->data = staticCharset.special; 93 tmpElement->data = staticCharset.special;
92 dynCharset.append(tmpElement); 94 dynCharset.append(tmpElement);
93 ++sanityCheck; 95 ++sanityCheck;
94 } 96 }
95 if (blank) { 97 if (blank) {
96 tmpElement = new dynCharset_element; 98 tmpElement = new dynCharset_element;
97 tmpElement->refCnt = 0; 99 tmpElement->refCnt = 0;
98 tmpElement->data = staticCharset.blank; 100 tmpElement->data = staticCharset.blank;
99 dynCharset.append(tmpElement); 101 dynCharset.append(tmpElement);
100 } 102 }
101 if (!user.isEmpty()) { 103 if (!user.isEmpty()) {
102 tmpElement = new dynCharset_element; 104 tmpElement = new dynCharset_element;
103 tmpElement->refCnt = 0; 105 tmpElement->refCnt = 0;
104 tmpElement->data = user; 106 tmpElement->data = user;
105 dynCharset.append(tmpElement); 107 dynCharset.append(tmpElement);
106 if (likely(user.length() >= 2)) 108 if (likely(user.length() >= 2))
107 ++sanityCheck; 109 ++sanityCheck;
108 } 110 }
109 BUG_ON(!sanityCheck); 111 BUG_ON(!sanityCheck);
110 rndDynCharset(); 112 rndDynCharset();
111} 113}
112 114
113void GenPasswd::rndDynCharset() 115void GenPasswd::rndDynCharset()
114{ 116{
115 QString tmpData; 117 QString tmpData;
116 int pos; 118 int pos;
117 Randomizer *rnd = Randomizer::obj(); 119 Randomizer *rnd = Randomizer::obj();
118 // QPtrList<dynCharset_element>::iterator is not available in QT-3.1 120 // QPtrList<dynCharset_element>::iterator is not available in QT-3.1
119 unsigned int i, cnt = dynCharset.count(); 121 unsigned int i, cnt = dynCharset.count();
120 dynCharset_element *p; 122 dynCharset_element *p;
121 for (i = 0; i < cnt; ++i) { 123 for (i = 0; i < cnt; ++i) {
122 p = dynCharset.at(i); 124 p = dynCharset.at(i);
123 PWM_ASSERT(p); 125 PWM_ASSERT(p);
124 tmpData = QString::null; 126 tmpData = QString::null;
125 while (p->data.length()) { 127 while (p->data.length()) {
126 pos = rnd->genRndInt() % p->data.length(); 128 pos = rnd->genRndInt() % p->data.length();
127 tmpData.append(p->data.at(pos)); 129 tmpData.append(p->data.at(pos));
128 p->data.remove(pos, 1); 130 p->data.remove(pos, 1);
129 } 131 }
130 p->data = tmpData; 132 p->data = tmpData;
131 } 133 }
132} 134}
133 135
134QString GenPasswd::gen() 136QString GenPasswd::gen()
135{ 137{
136 BUG_ON(dynCharset.count() <= 0); 138 BUG_ON(dynCharset.count() <= 0);
137 BUG_ON(length < 1); 139 BUG_ON(length < 1);
138 dynCharset_element *curCharset; 140 dynCharset_element *curCharset;
139 QString ret; 141 QString ret;
140 int i; 142 int i;
141 for (i = 0; i < length; ++i) { 143 for (i = 0; i < length; ++i) {
142 curCharset = selectNextCharset(); 144 curCharset = selectNextCharset();
143#if RERAND_CHARSET != 0 145#if RERAND_CHARSET != 0
144 rndDynCharset(); 146 rndDynCharset();
145#endif // RERAND_CHARSET 147#endif // RERAND_CHARSET
146 ret += genNewRandom(curCharset); 148 ret += genNewRandom(curCharset);
147 } 149 }
148 return ret; 150 return ret;
149} 151}
150 152
151GenPasswd::dynCharset_element * GenPasswd::selectNextCharset() 153GenPasswd::dynCharset_element * GenPasswd::selectNextCharset()
152{ 154{
153 dynCharset_element *ret; 155 dynCharset_element *ret;
154 int numCharsets = dynCharset.count(); 156 int numCharsets = dynCharset.count();
155 BUG_ON(numCharsets <= 0); 157 BUG_ON(numCharsets <= 0);
156 if (numCharsets == 1) 158 if (numCharsets == 1)
157 return dynCharset.at(0); 159 return dynCharset.at(0);
158 Randomizer *rnd = Randomizer::obj(); 160 Randomizer *rnd = Randomizer::obj();
159 if (useFilter) { 161 if (useFilter) {
160 // find out which charsets are allowed (filtering) 162 // find out which charsets are allowed (filtering)
161 QPtrList<dynCharset_element> allowedCharsets; 163 Q3PtrList<dynCharset_element> allowedCharsets;
162 // QPtrList<dynCharset_element>::iterator is not available in QT-3.1 164 // QPtrList<dynCharset_element>::iterator is not available in QT-3.1
163 unsigned int i, cnt = dynCharset.count(); 165 unsigned int i, cnt = dynCharset.count();
164 dynCharset_element *p; 166 dynCharset_element *p;
165 for (i = 0; i < cnt; ++i) { 167 for (i = 0; i < cnt; ++i) {
166 p = dynCharset.at(i); 168 p = dynCharset.at(i);
167 PWM_ASSERT(p); 169 PWM_ASSERT(p);
168 if (p->refCnt < FILTER_MAX_CHARSET_REUSE) { 170 if (p->refCnt < FILTER_MAX_CHARSET_REUSE) {
169 allowedCharsets.append(p); 171 allowedCharsets.append(p);
170 } else { 172 } else {
171 p->refCnt = 0; 173 p->refCnt = 0;
172 } 174 }
173 } 175 }
174 int numAllowedCharsets = allowedCharsets.count(); 176 int numAllowedCharsets = allowedCharsets.count();
175 BUG_ON(numAllowedCharsets <= 0); 177 BUG_ON(numAllowedCharsets <= 0);
176 // now get a random charset out of the allowed 178 // now get a random charset out of the allowed
177 unsigned int randomPos = rnd->genRndUInt() % numAllowedCharsets; 179 unsigned int randomPos = rnd->genRndUInt() % numAllowedCharsets;
178 ret = allowedCharsets.at(randomPos); 180 ret = allowedCharsets.at(randomPos);
179 ret->refCnt++; 181 ret->refCnt++;
180 return ret; 182 return ret;
181 } 183 }
182 // all charsets are allowed here (no filtering). Get a random. 184 // all charsets are allowed here (no filtering). Get a random.
183 unsigned int randomPos = rnd->genRndUInt() % numCharsets; 185 unsigned int randomPos = rnd->genRndUInt() % numCharsets;
184 ret = dynCharset.at(randomPos); 186 ret = dynCharset.at(randomPos);
185 return ret; 187 return ret;
186} 188}
187 189
188QChar GenPasswd::genNewRandom(const dynCharset_element *charset) 190QChar GenPasswd::genNewRandom(const dynCharset_element *charset)
189{ 191{
190 Randomizer *rnd = Randomizer::obj(); 192 Randomizer *rnd = Randomizer::obj();
191 int pos = rnd->genRndInt() % charset->data.length(); 193 int pos = rnd->genRndInt() % charset->data.length();
192 return charset->data.at(pos); 194 return charset->data.at(pos);
193} 195}
diff --git a/pwmanager/pwmanager/genpasswd.h b/pwmanager/pwmanager/genpasswd.h
index 3fa1607..5493891 100644
--- a/pwmanager/pwmanager/genpasswd.h
+++ b/pwmanager/pwmanager/genpasswd.h
@@ -1,76 +1,76 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 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 __GENPASSWD_H 20#ifndef __GENPASSWD_H
21#define __GENPASSWD_H 21#define __GENPASSWD_H
22 22
23#include <qstring.h> 23#include <qstring.h>
24#include <qptrlist.h> 24#include <q3ptrlist.h>
25 25
26/** internal password generator of PwManager */ 26/** internal password generator of PwManager */
27class GenPasswd 27class GenPasswd
28{ 28{
29protected: 29protected:
30 struct dynCharset_element 30 struct dynCharset_element
31 { 31 {
32 /** charset data */ 32 /** charset data */
33 QString data; 33 QString data;
34 /** reference counter for the filter */ 34 /** reference counter for the filter */
35 unsigned int refCnt; 35 unsigned int refCnt;
36 }; 36 };
37 37
38public: 38public:
39 GenPasswd(); 39 GenPasswd();
40 40
41 /** set the charset to use */ 41 /** set the charset to use */
42 void setCharset(bool lower, 42 void setCharset(bool lower,
43 bool upper, 43 bool upper,
44 bool num, 44 bool num,
45 bool special, 45 bool special,
46 bool blank, 46 bool blank,
47 QString user); 47 QString user);
48 /** set the password length */ 48 /** set the password length */
49 void setLen(int len) 49 void setLen(int len)
50 { length = len; } 50 { length = len; }
51 /** use the filter? */ 51 /** use the filter? */
52 void setUseFilter(bool use) 52 void setUseFilter(bool use)
53 { useFilter = use; } 53 { useFilter = use; }
54 /** start to generate a new password and return it. 54 /** start to generate a new password and return it.
55 * Returns an empty string on error. 55 * Returns an empty string on error.
56 */ 56 */
57 QString gen(); 57 QString gen();
58 58
59protected: 59protected:
60 /** randomize the dynamic charset */ 60 /** randomize the dynamic charset */
61 void rndDynCharset(); 61 void rndDynCharset();
62 /** select the next charset (based on useFilter) */ 62 /** select the next charset (based on useFilter) */
63 dynCharset_element * selectNextCharset(); 63 dynCharset_element * selectNextCharset();
64 /** generate a new random char from the given charset */ 64 /** generate a new random char from the given charset */
65 QChar genNewRandom(const dynCharset_element *charset); 65 QChar genNewRandom(const dynCharset_element *charset);
66 66
67protected: 67protected:
68 /** password length to generate */ 68 /** password length to generate */
69 int length; 69 int length;
70 /** use the filter? */ 70 /** use the filter? */
71 bool useFilter; 71 bool useFilter;
72 /** dynamic charset used for generating the password */ 72 /** dynamic charset used for generating the password */
73 QPtrList<dynCharset_element> dynCharset; 73 Q3PtrList<dynCharset_element> dynCharset;
74}; 74};
75 75
76#endif // __GENPASSWD_H 76#endif // __GENPASSWD_H
diff --git a/pwmanager/pwmanager/getkeycardwnd.cpp b/pwmanager/pwmanager/getkeycardwnd.cpp
index 89dada2..b8e6174 100644
--- a/pwmanager/pwmanager/getkeycardwnd.cpp
+++ b/pwmanager/pwmanager/getkeycardwnd.cpp
@@ -1,67 +1,70 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2003 by Michael Buesch * 3 * copyright (C) 2003 by Michael Buesch *
4 * email: fsdeveloper@yahoo.de * 4 * email: fsdeveloper@yahoo.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 "getkeycardwnd.h" 20#include "getkeycardwnd.h"
21 21
22#include <qmessagebox.h> 22#include <qmessagebox.h>
23//Added by qt3to4:
24#include <QResizeEvent>
25#include <QLabel>
23 26
24#include <klocale.h> 27#include <klocale.h>
25 28
26 29
27GetKeyCardWnd::GetKeyCardWnd(QWidget *parent, 30GetKeyCardWnd::GetKeyCardWnd(QWidget *parent,
28 const char *name, bool modal, WFlags f) 31 const char *name, bool modal, Qt::WFlags f)
29 : QDialog(parent, name, modal, f) 32 : QDialog(parent, name, modal, f)
30{ 33{
31 vbox1 = new QVBox(this); 34 vbox1 = new Q3VBox(this);
32 text_label = new QLabel(vbox1); 35 text_label = new QLabel(vbox1);
33 hbox1 = new QHBox(vbox1); 36 hbox1 = new Q3HBox(vbox1);
34 okButton = new QPushButton(i18n("&Ok"), hbox1); 37 okButton = new QPushButton(i18n("&Ok"), hbox1);
35 cancelButton = new QPushButton(i18n("&Cancel"), hbox1); 38 cancelButton = new QPushButton(i18n("&Cancel"), hbox1);
36 39
37 vbox1->setSpacing(10); 40 vbox1->setSpacing(10);
38 vbox1->setMargin(10); 41 vbox1->setMargin(10);
39 hbox1->setSpacing(10); 42 hbox1->setSpacing(10);
40 43
41 resize(500, 100); 44 resize(500, 100);
42 45
43 setCaption(i18n("Insert key-card")); 46 setCaption(i18n("Insert key-card"));
44 text_label->setText(i18n("Please insert the key-card " 47 text_label->setText(i18n("Please insert the key-card "
45 "and press the OK button.")); 48 "and press the OK button."));
46 49
47 connect(okButton, SIGNAL(clicked()), this, SLOT(okButton_slot())); 50 connect(okButton, SIGNAL(clicked()), this, SLOT(okButton_slot()));
48 connect(cancelButton, SIGNAL(clicked()), this, SLOT(close())); 51 connect(cancelButton, SIGNAL(clicked()), this, SLOT(close()));
49} 52}
50 53
51GetKeyCardWnd::~GetKeyCardWnd() 54GetKeyCardWnd::~GetKeyCardWnd()
52{ 55{
53} 56}
54 57
55void GetKeyCardWnd::resizeEvent(QResizeEvent *) 58void GetKeyCardWnd::resizeEvent(QResizeEvent *)
56{ 59{
57 vbox1->resize(size()); 60 vbox1->resize(size());
58} 61}
59 62
60void GetKeyCardWnd::okButton_slot() 63void GetKeyCardWnd::okButton_slot()
61{ 64{
62 done(1); 65 done(1);
63} 66}
64 67
65#ifndef PWM_EMBEDDED 68#ifndef PWM_EMBEDDED_
66#include "getkeycardwnd.moc" 69#include "moc_getkeycardwnd.cpp"
67#endif 70#endif
diff --git a/pwmanager/pwmanager/getkeycardwnd.h b/pwmanager/pwmanager/getkeycardwnd.h
index fbe46ee..202e920 100644
--- a/pwmanager/pwmanager/getkeycardwnd.h
+++ b/pwmanager/pwmanager/getkeycardwnd.h
@@ -1,53 +1,55 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2003 by Michael Buesch * 3 * copyright (C) 2003 by Michael Buesch *
4 * email: fsdeveloper@yahoo.de * 4 * email: fsdeveloper@yahoo.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 GETKEYCARDWND_H 20#ifndef GETKEYCARDWND_H
21#define GETKEYCARDWND_H 21#define GETKEYCARDWND_H
22 22
23#include <qvbox.h> 23#include <q3vbox.h>
24#include <qhbox.h> 24#include <q3hbox.h>
25#include <qdialog.h> 25#include <qdialog.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qpushbutton.h> 27#include <qpushbutton.h>
28#include <qevent.h> 28#include <qevent.h>
29//Added by qt3to4:
30#include <QResizeEvent>
29 31
30/** The equivalent to GetMasterPwWndImpl for chipcards */ 32/** The equivalent to GetMasterPwWndImpl for chipcards */
31class GetKeyCardWnd : public QDialog 33class GetKeyCardWnd : public QDialog
32{ 34{
33 Q_OBJECT 35 Q_OBJECT
34public: 36public:
35 GetKeyCardWnd(QWidget *parent = 0, const char *name = 0, 37 GetKeyCardWnd(QWidget *parent = 0, const char *name = 0,
36 bool modal = FALSE, WFlags f = 0); 38 bool modal = FALSE, Qt::WFlags f = 0);
37 ~GetKeyCardWnd(); 39 ~GetKeyCardWnd();
38 40
39protected slots: 41protected slots:
40 void okButton_slot(); 42 void okButton_slot();
41 43
42protected: 44protected:
43 QVBox *vbox1; 45 Q3VBox *vbox1;
44 QHBox *hbox1; 46 Q3HBox *hbox1;
45 QLabel *text_label; 47 QLabel *text_label;
46 QPushButton *okButton; 48 QPushButton *okButton;
47 QPushButton *cancelButton; 49 QPushButton *cancelButton;
48 50
49protected: 51protected:
50 void resizeEvent(QResizeEvent *); 52 void resizeEvent(QResizeEvent *);
51}; 53};
52 54
53#endif 55#endif
diff --git a/pwmanager/pwmanager/getmasterpwwnd_emb.cpp b/pwmanager/pwmanager/getmasterpwwnd_emb.cpp
index 678f05f..7e4bbb7 100644
--- a/pwmanager/pwmanager/getmasterpwwnd_emb.cpp
+++ b/pwmanager/pwmanager/getmasterpwwnd_emb.cpp
@@ -1,208 +1,211 @@
1/* 1/*
2 This file is part of PwManager/Platform independent. 2 This file is part of PwManager/Platform independent.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22 22
23$Id$ 23$Id$
24*/ 24*/
25 25
26#include "getmasterpwwnd_emb.h" 26#include "getmasterpwwnd_emb.h"
27 27
28#include "klocale.h" 28#include "klocale.h"
29 29
30/* 30/*
31#include <qvariant.h> 31#include <qvariant.h>
32#include <qpushbutton.h> 32#include <qpushbutton.h>
33#include <qlabel.h> 33#include <qlabel.h>
34#include <qlineedit.h> 34#include <qlineedit.h>
35#include <qlayout.h> 35#include <qlayout.h>
36#include <qtooltip.h> 36#include <qtooltip.h>
37#include <qwhatsthis.h> 37#include <qwhatsthis.h>
38*/ 38*/
39 39
40#include <qwidget.h> 40#include <qwidget.h>
41#include <qlayout.h> 41#include <qlayout.h>
42#include <qlabel.h> 42#include <qlabel.h>
43#include <qlineedit.h> 43#include <qlineedit.h>
44#include <qpushbutton.h> 44#include <qpushbutton.h>
45#include <qapplication.h> 45#include <qapplication.h>
46//Added by qt3to4:
47#include <Q3GridLayout>
48#include <Q3VBoxLayout>
46 49
47/* 50/*
48 * Constructs a getMasterPwWnd as a child of 'parent', with the 51 * Constructs a getMasterPwWnd as a child of 'parent', with the
49 * name 'name' 52 * name 'name'
50 */ 53 */
51getMasterPwWnd::getMasterPwWnd( QWidget* parent, const char* name) 54getMasterPwWnd::getMasterPwWnd( QWidget* parent, const char* name)
52 : KDialogBase( KDialogBase::Plain, i18n( "Master-password" ), 55 : KDialogBase( KDialogBase::Plain, i18n( "Master-password" ),
53 KDialogBase::Ok | KDialogBase::Cancel, 56 KDialogBase::Ok | KDialogBase::Cancel,
54 KDialogBase::Ok, parent, name, true ) 57 KDialogBase::Ok, parent, name, true )
55{ 58{
56 QWidget *page = plainPage(); 59 QWidget *page = plainPage();
57 QVBoxLayout *pageLayout = new QVBoxLayout( page ); 60 Q3VBoxLayout *pageLayout = new Q3VBoxLayout( page );
58 61
59 pwLineEdit = new QLineEdit( page, "pwLineEdit" ); 62 pwLineEdit = new QLineEdit( page, "pwLineEdit" );
60 pwLineEdit->setEchoMode( QLineEdit::Password ); 63 pwLineEdit->setEchoMode( QLineEdit::Password );
61 64
62 QLabel* textLabel1 = new QLabel( pwLineEdit, i18n("Please enter the master-password:"), page, "textLabel1" ); 65 QLabel* textLabel1 = new QLabel( pwLineEdit, i18n("Please enter the master-password:"), page, "textLabel1" );
63 textLabel1->setAlignment( int( QLabel::WordBreak | QLabel::AlignCenter ) ); 66 textLabel1->setAlignment( int( Qt::WordBreak | Qt::AlignCenter ) );
64 pageLayout->addWidget(textLabel1); 67 pageLayout->addWidget(textLabel1);
65 pageLayout->addWidget(pwLineEdit); 68 pageLayout->addWidget(pwLineEdit);
66 69
67 QWidget* numberBox = new QWidget( page ); 70 QWidget* numberBox = new QWidget( page );
68#ifndef DESKTOP_VERSION 71#ifndef DESKTOP_VERSION
69 if ( QApplication::desktop()->width() > 320 ) { 72 if ( QApplication::desktop()->width() > 320 ) {
70 numberBox->setFixedHeight(250); 73 numberBox->setFixedHeight(250);
71 numberBox->setFixedWidth(200); 74 numberBox->setFixedWidth(200);
72 } 75 }
73 else{ 76 else{
74 numberBox->setFixedHeight(150); 77 numberBox->setFixedHeight(150);
75 numberBox->setFixedWidth(150); 78 numberBox->setFixedWidth(150);
76 } 79 }
77#endif 80#endif
78 81
79 QGridLayout* numberLayout = new QGridLayout( numberBox, 4, 3 ); 82 Q3GridLayout* numberLayout = new Q3GridLayout( numberBox, 4, 3 );
80 numberLayout->setMargin( 0 ); 83 numberLayout->setMargin( 0 );
81 numberLayout->setSpacing( 0 ); 84 numberLayout->setSpacing( 0 );
82 85
83 QPushButton* p1 = new QPushButton( i18n("1"), numberBox ); 86 QPushButton* p1 = new QPushButton( i18n("1"), numberBox );
84 numberLayout->addWidget( p1, 0, 0 ); 87 numberLayout->addWidget( p1, 0, 0 );
85 QPushButton* p2 = new QPushButton( i18n("2"), numberBox ); 88 QPushButton* p2 = new QPushButton( i18n("2"), numberBox );
86 numberLayout->addWidget( p2, 0, 1 ); 89 numberLayout->addWidget( p2, 0, 1 );
87 QPushButton* p3 = new QPushButton( i18n("3"), numberBox ); 90 QPushButton* p3 = new QPushButton( i18n("3"), numberBox );
88 numberLayout->addWidget( p3, 0, 2 ); 91 numberLayout->addWidget( p3, 0, 2 );
89 QPushButton* p4 = new QPushButton( i18n("4"), numberBox ); 92 QPushButton* p4 = new QPushButton( i18n("4"), numberBox );
90 numberLayout->addWidget( p4, 1, 0 ); 93 numberLayout->addWidget( p4, 1, 0 );
91 QPushButton* p5 = new QPushButton( i18n("5"), numberBox ); 94 QPushButton* p5 = new QPushButton( i18n("5"), numberBox );
92 numberLayout->addWidget( p5, 1, 1 ); 95 numberLayout->addWidget( p5, 1, 1 );
93 QPushButton* p6 = new QPushButton( i18n("6"), numberBox ); 96 QPushButton* p6 = new QPushButton( i18n("6"), numberBox );
94 numberLayout->addWidget( p6, 1, 2 ); 97 numberLayout->addWidget( p6, 1, 2 );
95 QPushButton* p7 = new QPushButton( i18n("7"), numberBox ); 98 QPushButton* p7 = new QPushButton( i18n("7"), numberBox );
96 numberLayout->addWidget( p7, 2, 0 ); 99 numberLayout->addWidget( p7, 2, 0 );
97 QPushButton* p8 = new QPushButton( i18n("8"), numberBox ); 100 QPushButton* p8 = new QPushButton( i18n("8"), numberBox );
98 numberLayout->addWidget( p8, 2, 1 ); 101 numberLayout->addWidget( p8, 2, 1 );
99 QPushButton* p9 = new QPushButton( i18n("9"), numberBox ); 102 QPushButton* p9 = new QPushButton( i18n("9"), numberBox );
100 numberLayout->addWidget( p9, 2, 2 ); 103 numberLayout->addWidget( p9, 2, 2 );
101 QPushButton* clear = new QPushButton( i18n("x"), numberBox ); 104 QPushButton* clear = new QPushButton( i18n("x"), numberBox );
102 numberLayout->addWidget( clear, 3, 0 ); 105 numberLayout->addWidget( clear, 3, 0 );
103 QPushButton* p0 = new QPushButton( i18n("0"), numberBox ); 106 QPushButton* p0 = new QPushButton( i18n("0"), numberBox );
104 numberLayout->addWidget( p0, 3, 1 ); 107 numberLayout->addWidget( p0, 3, 1 );
105 QPushButton* backspace = new QPushButton( i18n("-"), numberBox ); 108 QPushButton* backspace = new QPushButton( i18n("-"), numberBox );
106 numberLayout->addWidget( backspace, 3, 2 ); 109 numberLayout->addWidget( backspace, 3, 2 );
107 110
108 111
109 pageLayout->addWidget(numberBox); 112 pageLayout->addWidget(numberBox);
110#ifdef DESKTOP_VERSION 113#ifdef DESKTOP_VERSION
111 resize( sizeHint() ); 114 resize( sizeHint() );
112#else 115#else
113 resize( 200,sizeHint().height() ); 116 resize( 200,sizeHint().height() );
114#endif 117#endif
115 118
116 connect( p0, SIGNAL( clicked() ), this, SLOT( add0() ) ); 119 connect( p0, SIGNAL( clicked() ), this, SLOT( add0() ) );
117 connect( p1, SIGNAL( clicked() ), this, SLOT( add1() ) ); 120 connect( p1, SIGNAL( clicked() ), this, SLOT( add1() ) );
118 connect( p2, SIGNAL( clicked() ), this, SLOT( add2() ) ); 121 connect( p2, SIGNAL( clicked() ), this, SLOT( add2() ) );
119 connect( p3, SIGNAL( clicked() ), this, SLOT( add3() ) ); 122 connect( p3, SIGNAL( clicked() ), this, SLOT( add3() ) );
120 connect( p4, SIGNAL( clicked() ), this, SLOT( add4() ) ); 123 connect( p4, SIGNAL( clicked() ), this, SLOT( add4() ) );
121 connect( p5, SIGNAL( clicked() ), this, SLOT( add5() ) ); 124 connect( p5, SIGNAL( clicked() ), this, SLOT( add5() ) );
122 connect( p6, SIGNAL( clicked() ), this, SLOT( add6() ) ); 125 connect( p6, SIGNAL( clicked() ), this, SLOT( add6() ) );
123 connect( p7, SIGNAL( clicked() ), this, SLOT( add7() ) ); 126 connect( p7, SIGNAL( clicked() ), this, SLOT( add7() ) );
124 connect( p8, SIGNAL( clicked() ), this, SLOT( add8() ) ); 127 connect( p8, SIGNAL( clicked() ), this, SLOT( add8() ) );
125 connect( p9, SIGNAL( clicked() ), this, SLOT( add9() ) ); 128 connect( p9, SIGNAL( clicked() ), this, SLOT( add9() ) );
126 connect( backspace, SIGNAL( clicked() ), this, SLOT( backspace() ) ); 129 connect( backspace, SIGNAL( clicked() ), this, SLOT( backspace() ) );
127 connect( clear, SIGNAL( clicked() ), this, SLOT( clear() ) ); 130 connect( clear, SIGNAL( clicked() ), this, SLOT( clear() ) );
128 131
129 pwLineEdit->setFocus(); 132 pwLineEdit->setFocus();
130 133
131} 134}
132 135
133/* 136/*
134 * Destroys the object and frees any allocated resources 137 * Destroys the object and frees any allocated resources
135 */ 138 */
136getMasterPwWnd::~getMasterPwWnd() 139getMasterPwWnd::~getMasterPwWnd()
137{ 140{
138 // no need to delete child widgets, Qt does it all for us 141 // no need to delete child widgets, Qt does it all for us
139} 142}
140 143
141void getMasterPwWnd::okButton_slot() 144void getMasterPwWnd::okButton_slot()
142{ 145{
143 qWarning( "getMasterPwWnd::okButton_slot(): Not implemented yet" ); 146 qWarning( "getMasterPwWnd::okButton_slot(): Not implemented yet" );
144} 147}
145 148
146void getMasterPwWnd::cancelButton_slot() 149void getMasterPwWnd::cancelButton_slot()
147{ 150{
148 qWarning( "getMasterPwWnd::cancelButton_slot(): Not implemented yet" ); 151 qWarning( "getMasterPwWnd::cancelButton_slot(): Not implemented yet" );
149} 152}
150 153
151void getMasterPwWnd::add0() 154void getMasterPwWnd::add0()
152{ 155{
153 addCharacter("0"); 156 addCharacter("0");
154} 157}
155void getMasterPwWnd::add1() 158void getMasterPwWnd::add1()
156{ 159{
157 addCharacter("1"); 160 addCharacter("1");
158} 161}
159void getMasterPwWnd::add2() 162void getMasterPwWnd::add2()
160{ 163{
161 addCharacter("2"); 164 addCharacter("2");
162} 165}
163void getMasterPwWnd::add3() 166void getMasterPwWnd::add3()
164{ 167{
165 addCharacter("3"); 168 addCharacter("3");
166} 169}
167void getMasterPwWnd::add4() 170void getMasterPwWnd::add4()
168{ 171{
169 addCharacter("4"); 172 addCharacter("4");
170} 173}
171void getMasterPwWnd::add5() 174void getMasterPwWnd::add5()
172{ 175{
173 addCharacter("5"); 176 addCharacter("5");
174} 177}
175void getMasterPwWnd::add6() 178void getMasterPwWnd::add6()
176{ 179{
177 addCharacter("6"); 180 addCharacter("6");
178} 181}
179void getMasterPwWnd::add7() 182void getMasterPwWnd::add7()
180{ 183{
181 addCharacter("7"); 184 addCharacter("7");
182} 185}
183void getMasterPwWnd::add8() 186void getMasterPwWnd::add8()
184{ 187{
185 addCharacter("8"); 188 addCharacter("8");
186} 189}
187void getMasterPwWnd::add9() 190void getMasterPwWnd::add9()
188{ 191{
189 addCharacter("9"); 192 addCharacter("9");
190} 193}
191void getMasterPwWnd::backspace() 194void getMasterPwWnd::backspace()
192{ 195{
193 QString old = pwLineEdit->text(); 196 QString old = pwLineEdit->text();
194 old.truncate(old.length()-1); 197 old.truncate(old.length()-1);
195 pwLineEdit->setText(old); 198 pwLineEdit->setText(old);
196} 199}
197 200
198void getMasterPwWnd::clear() 201void getMasterPwWnd::clear()
199{ 202{
200 pwLineEdit->setText(""); 203 pwLineEdit->setText("");
201} 204}
202 205
203void getMasterPwWnd::addCharacter(const QString& s) 206void getMasterPwWnd::addCharacter(const QString& s)
204{ 207{
205 QString old = pwLineEdit->text(); 208 QString old = pwLineEdit->text();
206 pwLineEdit->setText(old + s); 209 pwLineEdit->setText(old + s);
207} 210}
208 211
diff --git a/pwmanager/pwmanager/getmasterpwwndimpl.cpp b/pwmanager/pwmanager/getmasterpwwndimpl.cpp
index 6be9618..f741f72 100644
--- a/pwmanager/pwmanager/getmasterpwwndimpl.cpp
+++ b/pwmanager/pwmanager/getmasterpwwndimpl.cpp
@@ -1,60 +1,60 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2003 by Michael Buesch * 3 * copyright (C) 2003 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 "getmasterpwwndimpl.h" 20#include "getmasterpwwndimpl.h"
21 21
22#include <qlineedit.h> 22#include <qlineedit.h>
23 23
24GetMasterPwWndImpl::GetMasterPwWndImpl(QWidget * parent, const char *name) 24GetMasterPwWndImpl::GetMasterPwWndImpl(QWidget * parent, const char *name)
25: getMasterPwWnd(parent, name) 25: getMasterPwWnd(parent, name)
26{ 26{
27} 27}
28 28
29GetMasterPwWndImpl::~GetMasterPwWndImpl() 29GetMasterPwWndImpl::~GetMasterPwWndImpl()
30{ 30{
31} 31}
32 32
33void GetMasterPwWndImpl::okButton_slot() 33void GetMasterPwWndImpl::okButton_slot()
34{ 34{
35#ifndef PWM_EMBEDDED 35#ifndef PWM_EMBEDDED
36 if (pwLineEdit->text() != "") 36 if (pwLineEdit->text() != "")
37 done(1); 37 done(1);
38#endif 38#endif
39} 39}
40 40
41void GetMasterPwWndImpl::cancelButton_slot() 41void GetMasterPwWndImpl::cancelButton_slot()
42{ 42{
43#ifndef PWM_EMBEDDED 43#ifndef PWM_EMBEDDED
44 done(2); 44 done(2);
45#endif 45#endif
46} 46}
47 47
48#ifdef PWM_EMBEDDED 48#ifdef PWM_EMBEDDED
49void GetMasterPwWndImpl::slotOk() 49void GetMasterPwWndImpl::slotOk()
50{ 50{
51 if (pwLineEdit->text() != "") 51 if (pwLineEdit->text() != "")
52 getMasterPwWnd::slotOk(); 52 getMasterPwWnd::slotOk();
53 else 53 else
54 return; 54 return;
55} 55}
56#endif 56#endif
57 57
58#ifndef PWM_EMBEDDED 58#ifndef PWM_EMBEDDED_
59#include "getmasterpwwndimpl.moc" 59#include "moc_getmasterpwwndimpl.cpp"
60#endif 60#endif
diff --git a/pwmanager/pwmanager/globalstuff.h b/pwmanager/pwmanager/globalstuff.h
index 090fcda..2e8f287 100644
--- a/pwmanager/pwmanager/globalstuff.h
+++ b/pwmanager/pwmanager/globalstuff.h
@@ -1,134 +1,134 @@
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 __GLOBALSTUFF_H 20#ifndef __GLOBALSTUFF_H
21#define __GLOBALSTUFF_H 21#define __GLOBALSTUFF_H
22 22
23#ifndef PWM_EMBEDDED 23#ifndef PWM_EMBEDDED
24#include "config.h" 24#include "config.h"
25#endif 25#endif
26 26
27#include "compiler.h" 27#include "compiler.h"
28 28
29 //US BUG: the following code caused compile errors with certain gcccompilers (2.95). 29 //US BUG: the following code caused compile errors with certain gcccompilers (2.95).
30 // Because of that I replaced it with a Qt version, which should do the same. 30 // Because of that I replaced it with a Qt version, which should do the same.
31#include <string> 31#include <string>
32 32
33#ifndef PWM_EMBEDDED 33#ifndef PWM_EMBEDDED
34#include <sstream> 34#include <sstream>
35#else 35#else
36#include <qstring.h> 36#include <qstring.h>
37#include <qtextstream.h> 37#include <QTextOStream>
38#endif 38#endif
39 39
40#ifndef CONFIG_KEYCARD 40#ifndef CONFIG_KEYCARD
41class QWidget; 41class QWidget;
42void no_keycard_support_msg_box(QWidget *parentWidget); 42void no_keycard_support_msg_box(QWidget *parentWidget);
43#endif // CONFIG_KEYCARD 43#endif // CONFIG_KEYCARD
44 44
45#ifdef PROG_NAME 45#ifdef PROG_NAME
46# undef PROG_NAME 46# undef PROG_NAME
47#endif 47#endif
48 #define PROG_NAME"PwM/Pi" 48 #define PROG_NAME"PwM/Pi"
49 49
50#ifdef PACKAGE_NAME 50#ifdef PACKAGE_NAME
51# undef PACKAGE_NAME 51# undef PACKAGE_NAME
52#endif 52#endif
53 #define PACKAGE_NAME"pwm-pi" 53 #define PACKAGE_NAME"pwm-pi"
54 54
55#ifdef PACKAGE_VER 55#ifdef PACKAGE_VER
56# undef PACKAGE_VER 56# undef PACKAGE_VER
57#endif 57#endif
58 #define PACKAGE_VER"1.0.1" 58 #define PACKAGE_VER"1.0.1"
59 59
60#ifdef CONFIG_DEBUG 60#ifdef CONFIG_DEBUG
61# define PWM_DEBUG 61# define PWM_DEBUG
62#else 62#else
63# undef PWM_DEBUG 63# undef PWM_DEBUG
64#endif 64#endif
65 65
66#ifdef QT_MAKE_VERSION 66#ifdef QT_MAKE_VERSION
67# undef QT_MAKE_VERSION 67# undef QT_MAKE_VERSION
68#endif 68#endif
69 #define QT_MAKE_VERSION(a,b,c)(((a) << 16) | ((b) << 8) | (c)) 69 #define QT_MAKE_VERSION(a,b,c)(((a) << 16) | ((b) << 8) | (c))
70 70
71/** remove "unused parameter" warnings */ 71/** remove "unused parameter" warnings */
72#ifdef PARAM_UNUSED 72#ifdef PARAM_UNUSED
73# undef PARAM_UNUSED 73# undef PARAM_UNUSED
74#endif 74#endif
75 #define PARAM_UNUSED(x)(void)x 75 #define PARAM_UNUSED(x)(void)x
76 76
77/** return the number of elements in an array */ 77/** return the number of elements in an array */
78#ifdef array_size 78#ifdef array_size
79# undef array_size 79# undef array_size
80#endif 80#endif
81 #define array_size(x)(sizeof(x) / sizeof((x)[0])) 81 #define array_size(x)(sizeof(x) / sizeof((x)[0]))
82 82
83//US BUG: the following code caused compile errors with certain gcccompilers (2.95). 83//US BUG: the following code caused compile errors with certain gcccompilers (2.95).
84// Because of that I replaced it with a Qt version, which should do the same. 84// Because of that I replaced it with a Qt version, which should do the same.
85#ifndef PWM_EMBEDDED 85#ifndef PWM_EMBEDDED
86/** convert something to string using ostringstream */ 86/** convert something to string using ostringstream */
87template <class T> inline 87template <class T> inline
88std::string tostr(const T &t) 88std::string tostr(const T &t)
89{ 89{
90 std::ostringstream s; 90 std::ostringstream s;
91 s << t; 91 s << t;
92 return s.str(); 92 return s.str();
93} 93}
94#else 94#else
95/** convert something to string using ostringstream */ 95/** convert something to string using ostringstream */
96template <class T> inline 96template <class T> inline
97std::string tostr(const T &t) 97std::string tostr(const T &t)
98{ 98{
99 QString result; 99 QString result;
100 QTextOStream(&result) << t; 100 QTextOStream tmp(&result); tmp << t;
101 return result.latin1(); 101 return result.latin1();
102} 102}
103#endif 103#endif
104 104
105/** delete the memory and NULL the pointer */ 105/** delete the memory and NULL the pointer */
106template<class T> inline 106template<class T> inline
107void delete_and_null(T *&p) 107void delete_and_null(T *&p)
108{ 108{
109 delete p; 109 delete p;
110 p = 0; 110 p = 0;
111} 111}
112/** delete the memory if the pointer isn't a NULL pointer */ 112/** delete the memory if the pointer isn't a NULL pointer */
113template<class T> inline 113template<class T> inline
114void delete_ifnot_null(T *&p) 114void delete_ifnot_null(T *&p)
115{ 115{
116 if (p) 116 if (p)
117 delete_and_null(p); 117 delete_and_null(p);
118} 118}
119 119
120template<class T> inline 120template<class T> inline
121void delete_and_null_array(T *&p) 121void delete_and_null_array(T *&p)
122{ 122{
123 delete [] p; 123 delete [] p;
124 p = 0; 124 p = 0;
125} 125}
126 126
127template<class T> inline 127template<class T> inline
128void delete_ifnot_null_array(T *&p) 128void delete_ifnot_null_array(T *&p)
129{ 129{
130 if (p) 130 if (p)
131 delete_and_null_array(p); 131 delete_and_null_array(p);
132} 132}
133 133
134#endif // GLOBALSTUFF_H 134#endif // GLOBALSTUFF_H
diff --git a/pwmanager/pwmanager/htmlgen.cpp b/pwmanager/pwmanager/htmlgen.cpp
index bee8198..be3406a 100644
--- a/pwmanager/pwmanager/htmlgen.cpp
+++ b/pwmanager/pwmanager/htmlgen.cpp
@@ -1,248 +1,248 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 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 "htmlgen.h" 20#include "htmlgen.h"
21#include "pwmexception.h" 21#include "pwmexception.h"
22 22
23#include <kstandarddirs.h> 23#include <kstandarddirs.h>
24 24
25/** enable/disable HTML-generator debugging (0/1) */ 25/** enable/disable HTML-generator debugging (0/1) */
26 #define HTMLGEN_DEBUG0 26 #define HTMLGEN_DEBUG0
27 27
28 28
29 #define HTML_DOCTYPE_HDR"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n" 29 #define HTML_DOCTYPE_HDR"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"
30 #define HTML_PWM_HDR "<!-- PwManager generated HTML -->" 30 #define HTML_PWM_HDR "<!-- PwManager generated HTML -->"
31 #define HTML_COMMENT_HDR"<!-- type: comment -->" 31 #define HTML_COMMENT_HDR"<!-- type: comment -->"
32 #define HTML_COMMENTVER_HDR"<!-- ver: 0.1 -->" 32 #define HTML_COMMENTVER_HDR"<!-- ver: 0.1 -->"
33 #define HTML_STYLESHEET_DUMMY"@STYLESHEET@" 33 #define HTML_STYLESHEET_DUMMY"@STYLESHEET@"
34 #define HTML_GLOBTBL_CLASS"\"globtable\"" 34 #define HTML_GLOBTBL_CLASS"\"globtable\""
35 #define HTML_GLOBTITLE_CLASS"\"globtitle\"" 35 #define HTML_GLOBTITLE_CLASS"\"globtitle\""
36 #define HTML_SUBTBL_CLASS"\"subtable\"" 36 #define HTML_SUBTBL_CLASS"\"subtable\""
37 #define HTML_SUBTITLE_CLASS"\"subtitle\"" 37 #define HTML_SUBTITLE_CLASS"\"subtitle\""
38 #define HTML_ENTRY_CLASS"\"entry\"" 38 #define HTML_ENTRY_CLASS"\"entry\""
39 #define HTML_VALUE_CLASS"\"value\"" 39 #define HTML_VALUE_CLASS"\"value\""
40 #define PATH_COMMENTSTYLE_CSS"pwmanager/html/htmlcomment_style.css" 40 #define PATH_COMMENTSTYLE_CSS"pwmanager/html/htmlcomment_style.css"
41#if defined(PWM_DEBUG) && HTMLGEN_DEBUG != 0 41#if defined(PWM_DEBUG) && HTMLGEN_DEBUG != 0
42 #define HTML_ENDL "\n" 42 #define HTML_ENDL "\n"
43#else // defined(PWM_DEBUG) && ... 43#else // defined(PWM_DEBUG) && ...
44 #define HTML_ENDL "" 44 #define HTML_ENDL ""
45#endif // defined(PWM_DEBUG) && ... 45#endif // defined(PWM_DEBUG) && ...
46 46
47 47
48HtmlGen::HtmlGen() 48HtmlGen::HtmlGen()
49{ 49{
50 useSSDummy = true; 50 useSSDummy = true;
51} 51}
52 52
53HtmlGen::~HtmlGen() 53HtmlGen::~HtmlGen()
54{ 54{
55} 55}
56 56
57QString HtmlGen::escapeHtmlText(const QString &str) 57QString HtmlGen::escapeHtmlText(const QString &str)
58{ 58{
59 QString ret; 59 QString ret;
60 unsigned int len = str.length(), i; 60 unsigned int len = str.length(), i;
61 char c; 61 char c;
62 for (i = 0; i < len; ++i) { 62 for (i = 0; i < len; ++i) {
63 c = str.at(i); 63 c = str.at(i).toLatin1();
64 switch (c) { 64 switch (c) {
65 case '<': 65 case '<':
66 ret.append("&lt;"); 66 ret.append("&lt;");
67 break; 67 break;
68 case '>': 68 case '>':
69 ret.append("&gt;"); 69 ret.append("&gt;");
70 break; 70 break;
71 case '&': 71 case '&':
72 ret.append("&amp;"); 72 ret.append("&amp;");
73 break; 73 break;
74 case '\"': 74 case '\"':
75 ret.append("&quot;"); 75 ret.append("&quot;");
76 break; 76 break;
77 case 'ä': 77 case 'ä':
78 ret.append("&auml;"); 78 ret.append("&auml;");
79 break; 79 break;
80 case 'Ä': 80 case 'Ä':
81 ret.append("&Auml;"); 81 ret.append("&Auml;");
82 break; 82 break;
83 case 'ü': 83 case 'ü':
84 ret.append("&uuml;"); 84 ret.append("&uuml;");
85 break; 85 break;
86 case 'Ü': 86 case 'Ü':
87 ret.append("&Uuml;"); 87 ret.append("&Uuml;");
88 break; 88 break;
89 case 'ö': 89 case 'ö':
90 ret.append("&ouml;"); 90 ret.append("&ouml;");
91 break; 91 break;
92 case 'Ö': 92 case 'Ö':
93 ret.append("&Ouml;"); 93 ret.append("&Ouml;");
94 break; 94 break;
95 case 'ß': 95 case 'ß':
96 ret.append("&szlig;"); 96 ret.append("&szlig;");
97 break; 97 break;
98 case '¿': 98 case '¿':
99 ret.append("&euro;"); 99 ret.append("&euro;");
100 break; 100 break;
101 default: 101 default:
102 ret.append(c); 102 ret.append(c);
103 } 103 }
104 } 104 }
105 return ret; 105 return ret;
106} 106}
107 107
108bool HtmlGen::isHtml(const QString &dta) 108bool HtmlGen::isHtml(const QString &dta)
109{ 109{
110 int ret; 110 int ret;
111 ret = dta.find("<html>", 0, false); 111 ret = dta.find("<html>", 0, false);
112 if (ret == -1) 112 if (ret == -1)
113 return false; 113 return false;
114 ret = dta.find("<head>", ret, false); 114 ret = dta.find("<head>", ret, false);
115 if (ret == -1) 115 if (ret == -1)
116 return false; 116 return false;
117 return true; 117 return true;
118} 118}
119 119
120QString HtmlGen::getStyleSheetHtml() 120QString HtmlGen::getStyleSheetHtml()
121{ 121{
122 QString ret; 122 QString ret;
123 ret = "<link rel=\"stylesheet\" href=\""; 123 ret = "<link rel=\"stylesheet\" href=\"";
124 QString cssPath(::locate("data", PATH_COMMENTSTYLE_CSS)); 124 QString cssPath(::locate("data", PATH_COMMENTSTYLE_CSS));
125 if ((cssPath == QString::null) || (cssPath == "")) { 125 if ((cssPath == QString::null) || (cssPath == "")) {
126 printDebug("HtmlGen::getStyleSheetHtml(): not found"); 126 printDebug("HtmlGen::getStyleSheetHtml(): not found");
127 return ""; 127 return "";
128 } 128 }
129 ret += cssPath; 129 ret += cssPath;
130 ret += "\" type=\"text/css\">" HTML_ENDL; 130 ret += "\" type=\"text/css\">" HTML_ENDL;
131 return ret; 131 return ret;
132} 132}
133 133
134bool HtmlGen::replaceSSDummy(QString *doc) 134bool HtmlGen::replaceSSDummy(QString *doc)
135{ 135{
136 int beginPos = doc->find(HTML_STYLESHEET_DUMMY); 136 int beginPos = doc->find(HTML_STYLESHEET_DUMMY);
137 if (beginPos == -1) { 137 if (beginPos == -1) {
138 printDebug("HtmlGen::replaceSSDummy(): not found"); 138 printDebug("HtmlGen::replaceSSDummy(): not found");
139 return false; 139 return false;
140 } 140 }
141 *doc = doc->replace(beginPos, strlen(HTML_STYLESHEET_DUMMY), 141 *doc = doc->replace(beginPos, strlen(HTML_STYLESHEET_DUMMY),
142 getStyleSheetHtml()); 142 getStyleSheetHtml());
143 return true; 143 return true;
144} 144}
145 145
146QString HtmlGen::genHtmlComment(const HtmlComment *dta) 146QString HtmlGen::genHtmlComment(const HtmlComment *dta)
147{ 147{
148 QString ret(HTML_DOCTYPE_HDR 148 QString ret(HTML_DOCTYPE_HDR
149 HTML_PWM_HDRHTML_ENDL 149 HTML_PWM_HDRHTML_ENDL
150 HTML_COMMENT_HDRHTML_ENDL 150 HTML_COMMENT_HDRHTML_ENDL
151 HTML_COMMENTVER_HDRHTML_ENDL); 151 HTML_COMMENTVER_HDRHTML_ENDL);
152 ret += "<html>" HTML_ENDL; 152 ret += "<html>" HTML_ENDL;
153 if (!appendCommentHeader(&ret)) 153 if (!appendCommentHeader(&ret))
154 return ""; 154 return "";
155 if (!appendCommentBody(&ret, dta)) 155 if (!appendCommentBody(&ret, dta))
156 return ""; 156 return "";
157 ret += "</html>" HTML_ENDL; 157 ret += "</html>" HTML_ENDL;
158 158
159#if defined(PWM_DEBUG) && HTMLGEN_DEBUG != 0 159#if defined(PWM_DEBUG) && HTMLGEN_DEBUG != 0
160 printDebug("<BEGIN HtmlGen::genHtmlComment() dump>"); 160 printDebug("<BEGIN HtmlGen::genHtmlComment() dump>");
161 cout << ret << endl; 161 cout << ret << endl;
162 printDebug("<END HtmlGen::genHtmlComment() dump>"); 162 printDebug("<END HtmlGen::genHtmlComment() dump>");
163#endif // DEBUG 163#endif // DEBUG
164 return ret; 164 return ret;
165} 165}
166 166
167bool HtmlGen::appendCommentHeader(QString *str) 167bool HtmlGen::appendCommentHeader(QString *str)
168{ 168{
169 *str += "<head>" HTML_ENDL; 169 *str += "<head>" HTML_ENDL;
170 if (useSSDummy) { 170 if (useSSDummy) {
171 *str += HTML_STYLESHEET_DUMMYHTML_ENDL; 171 *str += HTML_STYLESHEET_DUMMYHTML_ENDL;
172 } else { 172 } else {
173 QString ssLine(getStyleSheetHtml()); 173 QString ssLine(getStyleSheetHtml());
174 if (ssLine.isEmpty()) 174 if (ssLine.isEmpty())
175 return false; 175 return false;
176 *str += ssLine; 176 *str += ssLine;
177 } 177 }
178 *str += "</head>" HTML_ENDL; 178 *str += "</head>" HTML_ENDL;
179 return true; 179 return true;
180} 180}
181 181
182bool HtmlGen::appendCommentBody(QString *str, 182bool HtmlGen::appendCommentBody(QString *str,
183 const HtmlComment *dta) 183 const HtmlComment *dta)
184{ 184{
185 *str += "<body>" HTML_ENDL; 185 *str += "<body>" HTML_ENDL;
186 if (!appendCommentGlobTbl(str, dta)) 186 if (!appendCommentGlobTbl(str, dta))
187 return false; 187 return false;
188 *str += "</body>" HTML_ENDL; 188 *str += "</body>" HTML_ENDL;
189 return true; 189 return true;
190} 190}
191 191
192bool HtmlGen::appendCommentGlobTbl(QString *str, 192bool HtmlGen::appendCommentGlobTbl(QString *str,
193 const HtmlComment *dta) 193 const HtmlComment *dta)
194{ 194{
195 *str += "<table class=" HTML_GLOBTBL_CLASS ">" HTML_ENDL; 195 *str += "<table class=" HTML_GLOBTBL_CLASS ">" HTML_ENDL;
196 *str += "<tr><th class=" HTML_GLOBTITLE_CLASS ">"; 196 *str += "<tr><th class=" HTML_GLOBTITLE_CLASS ">";
197 *str += escapeHtmlText(dta->getTitle()); 197 *str += escapeHtmlText(dta->getTitle());
198 *str += "</th></tr>" HTML_ENDL; 198 *str += "</th></tr>" HTML_ENDL;
199 199
200 const vector<HtmlComment::SubTable> *subTbls = dta->getSubTableList(); 200 const vector<HtmlComment::SubTable> *subTbls = dta->getSubTableList();
201 vector<HtmlComment::SubTable>::const_iterator i = subTbls->begin(), 201 vector<HtmlComment::SubTable>::const_iterator i = subTbls->begin(),
202 end = subTbls->end(); 202 end = subTbls->end();
203 while (i != end) { 203 while (i != end) {
204 *str += "<tr><td>" HTML_ENDL; 204 *str += "<tr><td>" HTML_ENDL;
205 if (!appendCommentSubTbl(str, &(*i))) 205 if (!appendCommentSubTbl(str, &(*i)))
206 return false; 206 return false;
207 ++i; 207 ++i;
208 *str += "</td></tr>" HTML_ENDL; 208 *str += "</td></tr>" HTML_ENDL;
209 } 209 }
210 210
211 *str += "</table>" HTML_ENDL; 211 *str += "</table>" HTML_ENDL;
212 return true; 212 return true;
213} 213}
214 214
215bool HtmlGen::appendCommentSubTbl(QString *str, 215bool HtmlGen::appendCommentSubTbl(QString *str,
216 const HtmlComment::SubTable *dta) 216 const HtmlComment::SubTable *dta)
217{ 217{
218 *str += "<table class=" HTML_SUBTBL_CLASS ">" HTML_ENDL; 218 *str += "<table class=" HTML_SUBTBL_CLASS ">" HTML_ENDL;
219 *str += "<tr><th colspan=\"2\" class=" HTML_SUBTITLE_CLASS ">"; 219 *str += "<tr><th colspan=\"2\" class=" HTML_SUBTITLE_CLASS ">";
220 *str += escapeHtmlText(dta->getTitle()); 220 *str += escapeHtmlText(dta->getTitle());
221 *str += "</th></tr>" HTML_ENDL; 221 *str += "</th></tr>" HTML_ENDL;
222 222
223 const vector< pair<QString, QString> > *entries = dta->getEntryList(); 223 const vector< pair<QString, QString> > *entries = dta->getEntryList();
224 vector< pair<QString, QString> >::const_iterator i = entries->begin(), 224 vector< pair<QString, QString> >::const_iterator i = entries->begin(),
225 end = entries->end(); 225 end = entries->end();
226 while (i != end) { 226 while (i != end) {
227 *str += "<tr>" HTML_ENDL; 227 *str += "<tr>" HTML_ENDL;
228 if (!appendCommentSubTblEntry(str, &(*i))) 228 if (!appendCommentSubTblEntry(str, &(*i)))
229 return false; 229 return false;
230 *str += "</tr>" HTML_ENDL; 230 *str += "</tr>" HTML_ENDL;
231 ++i; 231 ++i;
232 } 232 }
233 233
234 *str += "</table>" HTML_ENDL; 234 *str += "</table>" HTML_ENDL;
235 return true; 235 return true;
236} 236}
237 237
238bool HtmlGen::appendCommentSubTblEntry(QString *str, 238bool HtmlGen::appendCommentSubTblEntry(QString *str,
239 const pair<QString, QString> *dta) 239 const pair<QString, QString> *dta)
240{ 240{
241 *str += "<td class=" HTML_ENTRY_CLASS ">"; 241 *str += "<td class=" HTML_ENTRY_CLASS ">";
242 *str += escapeHtmlText(dta->first); 242 *str += escapeHtmlText(dta->first);
243 *str += "</td>" HTML_ENDL; 243 *str += "</td>" HTML_ENDL;
244 *str += "<td class=" HTML_VALUE_CLASS ">"; 244 *str += "<td class=" HTML_VALUE_CLASS ">";
245 *str += escapeHtmlText(dta->second); 245 *str += escapeHtmlText(dta->second);
246 *str += "</td>" HTML_ENDL; 246 *str += "</td>" HTML_ENDL;
247 return true; 247 return true;
248} 248}
diff --git a/pwmanager/pwmanager/ipc.cpp b/pwmanager/pwmanager/ipc.cpp
index 643b022..4c65f1d 100644
--- a/pwmanager/pwmanager/ipc.cpp
+++ b/pwmanager/pwmanager/ipc.cpp
@@ -1,217 +1,217 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 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 "ipc.h" 20#include "ipc.h"
21#include "pwmexception.h" 21#include "pwmexception.h"
22 22
23#include <qsocketnotifier.h> 23#include <qsocketnotifier.h>
24#ifndef _WIN32_ 24#ifndef _WIN32_
25#include <sys/socket.h> 25#include <sys/socket.h>
26#endif 26#endif
27#ifndef PWM_EMBEDDED 27#ifndef PWM_EMBEDDED
28#include <sys/types.h> 28#include <sys/types.h>
29#include <stdio.h> 29#include <stdio.h>
30#else 30#else
31#include <qsocket.h> 31#include <q3socket.h>
32#endif 32#endif
33 33
34 #define END_OF_LINE '\n' 34 #define END_OF_LINE '\n'
35 #define INIT_LINEBUF_LEN64 /* byte */ 35 #define INIT_LINEBUF_LEN64 /* byte */
36 36
37#ifndef PWM_EMBEDDED 37#ifndef PWM_EMBEDDED
38 38
39Ipc::Ipc() 39Ipc::Ipc()
40 : stream (0) 40 : stream (0)
41 , notifier (0) 41 , notifier (0)
42 , rdBuf (0) 42 , rdBuf (0)
43{ 43{
44 if (socketpair(AF_LOCAL, SOCK_STREAM, 0, sock)) { 44 if (socketpair(AF_LOCAL, SOCK_STREAM, 0, sock)) {
45 throw PwMException(PwMException::EX_GENERIC, 45 throw PwMException(PwMException::EX_GENERIC,
46 "Ipc: socketpair() failed"); 46 "Ipc: socketpair() failed");
47 } 47 }
48 rdBufSize = INIT_LINEBUF_LEN; 48 rdBufSize = INIT_LINEBUF_LEN;
49 rdBuf = static_cast<char *>(malloc(rdBufSize)); 49 rdBuf = static_cast<char *>(malloc(rdBufSize));
50 if (!rdBuf) { 50 if (!rdBuf) {
51 close(sock[0]); 51 close(sock[0]);
52 close(sock[1]); 52 close(sock[1]);
53 throw PwMException(PwMException::EX_GENERIC, 53 throw PwMException(PwMException::EX_GENERIC,
54 "Ipc: OOM"); 54 "Ipc: OOM");
55 } 55 }
56 stream = fdopen(sock[0], "r"); 56 stream = fdopen(sock[0], "r");
57 if (!stream) { 57 if (!stream) {
58 close(sock[0]); 58 close(sock[0]);
59 close(sock[1]); 59 close(sock[1]);
60 free(rdBuf); 60 free(rdBuf);
61 throw PwMException(PwMException::EX_GENERIC, 61 throw PwMException(PwMException::EX_GENERIC,
62 "Ipc: fdopen() failed"); 62 "Ipc: fdopen() failed");
63 } 63 }
64 64
65 notifier = new QSocketNotifier(sock[0], QSocketNotifier::Read); 65 notifier = new QSocketNotifier(sock[0], QSocketNotifier::Read);
66 connect(notifier, SIGNAL(activated(int)), 66 connect(notifier, SIGNAL(activated(int)),
67 this, SLOT(receiveData(int))); 67 this, SLOT(receiveData(int)));
68 host = true; 68 host = true;
69} 69}
70#else 70#else
71Ipc::Ipc() 71Ipc::Ipc()
72 : notifier (0) 72 : notifier (0)
73 , rdBuf (0) 73 , rdBuf (0)
74{ 74{
75#ifndef _WIN32_ 75#ifndef _WIN32_
76 if (socketpair(AF_LOCAL, SOCK_STREAM, 0, sock)) { 76 if (socketpair(AF_LOCAL, SOCK_STREAM, 0, sock)) {
77 qDebug("Ipc: socketpair() failed"); 77 qDebug("Ipc: socketpair() failed");
78 } 78 }
79#endif 79#endif
80 QSocket* qsock = new QSocket(); 80 Q3Socket* qsock = new Q3Socket();
81 qsock->setSocket(sock[0]); 81 qsock->setSocket(sock[0]);
82 82
83 rdBufSize = INIT_LINEBUF_LEN; 83 rdBufSize = INIT_LINEBUF_LEN;
84 rdBuf = (char *)(malloc(rdBufSize)); 84 rdBuf = (char *)(malloc(rdBufSize));
85 if (!rdBuf) { 85 if (!rdBuf) {
86 close(sock[0]); 86 close(sock[0]);
87 close(sock[1]); 87 close(sock[1]);
88 qDebug("Ipc: OOM"); 88 qDebug("Ipc: OOM");
89 } 89 }
90 90
91 qsock = new QSocket(); 91 qsock = new Q3Socket();
92 qsock->setSocket(sock[0]); 92 qsock->setSocket(sock[0]);
93 93
94 /*US 94 /*US
95 stream = fdopen(sock[0], "r"); 95 stream = fdopen(sock[0], "r");
96 if (!stream) { 96 if (!stream) {
97 close(sock[0]); 97 close(sock[0]);
98 close(sock[1]); 98 close(sock[1]);
99 free(rdBuf); 99 free(rdBuf);
100 qDebug("Ipc: fdopen() failed"); 100 qDebug("Ipc: fdopen() failed");
101 } 101 }
102 */ 102 */
103 103
104 notifier = new QSocketNotifier(sock[0], QSocketNotifier::Read); 104 notifier = new QSocketNotifier(sock[0], QSocketNotifier::Read);
105 connect(notifier, SIGNAL(activated(int)), 105 connect(notifier, SIGNAL(activated(int)),
106 this, SLOT(receiveData(int))); 106 this, SLOT(receiveData(int)));
107 host = true; 107 host = true;
108} 108}
109 109
110#endif 110#endif
111 111
112 112
113#ifndef PWM_EMBEDDED 113#ifndef PWM_EMBEDDED
114 114
115Ipc::Ipc(const Ipc *ipc) 115Ipc::Ipc(const Ipc *ipc)
116 : stream (0) 116 : stream (0)
117 , notifier (0) 117 , notifier (0)
118 , rdBuf (0) 118 , rdBuf (0)
119{ 119{
120 rdBufSize = INIT_LINEBUF_LEN; 120 rdBufSize = INIT_LINEBUF_LEN;
121 rdBuf = static_cast<char *>(malloc(rdBufSize)); 121 rdBuf = static_cast<char *>(malloc(rdBufSize));
122 if (!rdBuf) { 122 if (!rdBuf) {
123 throw PwMException(PwMException::EX_GENERIC, 123 throw PwMException(PwMException::EX_GENERIC,
124 "Ipc: OOM"); 124 "Ipc: OOM");
125 } 125 }
126 sock[0] = ipc->sock[1]; 126 sock[0] = ipc->sock[1];
127 sock[1] = ipc->sock[0]; 127 sock[1] = ipc->sock[0];
128 stream = fdopen(sock[0], "r"); 128 stream = fdopen(sock[0], "r");
129 if (!stream) { 129 if (!stream) {
130 free(rdBuf); 130 free(rdBuf);
131 throw PwMException(PwMException::EX_GENERIC, 131 throw PwMException(PwMException::EX_GENERIC,
132 "Ipc: fdopen() failed"); 132 "Ipc: fdopen() failed");
133 } 133 }
134 134
135 notifier = new QSocketNotifier(sock[0], QSocketNotifier::Read); 135 notifier = new QSocketNotifier(sock[0], QSocketNotifier::Read);
136 connect(notifier, SIGNAL(activated(int)), 136 connect(notifier, SIGNAL(activated(int)),
137 this, SLOT(receiveData(int))); 137 this, SLOT(receiveData(int)));
138 host = false; 138 host = false;
139} 139}
140 140
141#else 141#else
142 142
143Ipc::Ipc(const Ipc *ipc) 143Ipc::Ipc(const Ipc *ipc)
144 : notifier (0) 144 : notifier (0)
145 , rdBuf (0) 145 , rdBuf (0)
146{ 146{
147 rdBufSize = INIT_LINEBUF_LEN; 147 rdBufSize = INIT_LINEBUF_LEN;
148 rdBuf = (char *)(malloc(rdBufSize)); 148 rdBuf = (char *)(malloc(rdBufSize));
149 if (!rdBuf) { 149 if (!rdBuf) {
150 qDebug("Ipc: OOM"); 150 qDebug("Ipc: OOM");
151 } 151 }
152 sock[0] = ipc->sock[1]; 152 sock[0] = ipc->sock[1];
153 sock[1] = ipc->sock[0]; 153 sock[1] = ipc->sock[0];
154 154
155 qSock = new QSocket(); 155 qSock = new Q3Socket();
156 qSock->setSocket(sock[0]); 156 qSock->setSocket(sock[0]);
157 157
158 /*US 158 /*US
159 stream = fdopen(sock[0], "r"); 159 stream = fdopen(sock[0], "r");
160 if (!stream) { 160 if (!stream) {
161 free(rdBuf); 161 free(rdBuf);
162 qDebug("Ipc: fdopen() failed"); 162 qDebug("Ipc: fdopen() failed");
163 } 163 }
164 */ 164 */
165 165
166 notifier = new QSocketNotifier(sock[0], QSocketNotifier::Read); 166 notifier = new QSocketNotifier(sock[0], QSocketNotifier::Read);
167 connect(notifier, SIGNAL(activated(int)), 167 connect(notifier, SIGNAL(activated(int)),
168 this, SLOT(receiveData(int))); 168 this, SLOT(receiveData(int)));
169 host = false; 169 host = false;
170} 170}
171 171
172#endif 172#endif
173 173
174Ipc::~Ipc() 174Ipc::~Ipc()
175{ 175{
176#ifdef PWM_EMBEDDED 176#ifdef PWM_EMBEDDED
177 delete qSock; 177 delete qSock;
178#endif 178#endif
179 delete_ifnot_null(notifier); 179 delete_ifnot_null(notifier);
180 if (rdBuf) 180 if (rdBuf)
181 free(rdBuf); 181 free(rdBuf);
182#ifndef PWM_EMBEDDED 182#ifndef PWM_EMBEDDED
183 if (stream) 183 if (stream)
184 fclose(stream); 184 fclose(stream);
185#endif 185#endif
186 if (host) { 186 if (host) {
187 close(sock[0]); 187 close(sock[0]);
188 close(sock[1]); 188 close(sock[1]);
189 } 189 }
190 190
191} 191}
192 192
193void Ipc::receiveData(int s) 193void Ipc::receiveData(int s)
194{ 194{
195 PWM_ASSERT(s == sock[0]); 195 PWM_ASSERT(s == sock[0]);
196 PARAM_UNUSED(s); 196 PARAM_UNUSED(s);
197#ifndef PWM_EMBEDDED 197#ifndef PWM_EMBEDDED
198 ssize_t rd; 198 ssize_t rd;
199 199
200 rd = ::getline(&rdBuf, &rdBufSize, stream); 200 rd = ::getline(&rdBuf, &rdBufSize, stream);
201 if (likely(rd > 0)) { 201 if (likely(rd > 0)) {
202 emit lineAvailable(rdBuf, rd); 202 emit lineAvailable(rdBuf, rd);
203 } 203 }
204#else 204#else
205 int rd; 205 int rd;
206 rd = qSock->readLine(rdBuf, rdBufSize); 206 rd = qSock->readLine(rdBuf, rdBufSize);
207 if (rd > 0) { 207 if (rd > 0) {
208 emit lineAvailable(rdBuf, rd); 208 emit lineAvailable(rdBuf, rd);
209 } 209 }
210#endif 210#endif
211 qDebug("void Ipc::receiveData(int s) has to be implemented."); 211 qDebug("void Ipc::receiveData(int s) has to be implemented.");
212 212
213} 213}
214 214
215#ifndef PWM_EMBEDDED 215#ifndef PWM_EMBEDDED_
216#include "ipc.moc" 216#include "moc_ipc.cpp"
217#endif 217#endif
diff --git a/pwmanager/pwmanager/ipc.h b/pwmanager/pwmanager/ipc.h
index 7bfca02..3248283 100644
--- a/pwmanager/pwmanager/ipc.h
+++ b/pwmanager/pwmanager/ipc.h
@@ -1,92 +1,92 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 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_IPC_H 20#ifndef __PWM_IPC_H
21#define __PWM_IPC_H 21#define __PWM_IPC_H
22 22
23#include <qobject.h> 23#include <qobject.h>
24#ifndef _WIN32_ 24#ifndef _WIN32_
25#include <unistd.h> 25#include <unistd.h>
26#else 26#else
27#include <io.h> 27#include <io.h>
28#endif 28#endif
29#ifndef PWM_EMBEDDED 29#ifndef PWM_EMBEDDED
30#include <stdio.h> 30#include <stdio.h>
31#else 31#else
32#include <qsocket.h> 32#include <q3socket.h>
33#endif 33#endif
34 34
35class QSocketNotifier; 35class QSocketNotifier;
36 36
37/** very simple interprocess communication class */ 37/** very simple interprocess communication class */
38class Ipc : public QObject 38class Ipc : public QObject
39{ 39{
40 Q_OBJECT 40 Q_OBJECT
41public: 41public:
42 /** create a new Ipc communication object */ 42 /** create a new Ipc communication object */
43 Ipc(); 43 Ipc();
44 /** create a new Ipc communication object and 44 /** create a new Ipc communication object and
45 * connect it to "ipc" 45 * connect it to "ipc"
46 */ 46 */
47 Ipc(const Ipc *ipc); 47 Ipc(const Ipc *ipc);
48 /** destructor */ 48 /** destructor */
49 ~Ipc(); 49 ~Ipc();
50 50
51 /** send data to the other socket end 51 /** send data to the other socket end
52 * (To the connected ipc object) 52 * (To the connected ipc object)
53 */ 53 */
54#ifndef PWM_EMBEDDED 54#ifndef PWM_EMBEDDED
55 void send(const char *buf, size_t size) 55 void send(const char *buf, size_t size)
56 { write(sock[0], buf, size); } 56 { write(sock[0], buf, size); }
57#else 57#else
58 void send(const char *buf, size_t size) 58 void send(const char *buf, size_t size)
59 { qSock->writeBlock(buf, size); } 59 { qSock->writeBlock(buf, size); }
60#endif 60#endif
61 61
62signals: 62signals:
63 /** a line is available */ 63 /** a line is available */
64 void lineAvailable(const char *buf, size_t size); 64 void lineAvailable(const char *buf, size_t size);
65 65
66protected slots: 66protected slots:
67 /** received data on socket */ 67 /** received data on socket */
68 void receiveData(int s); 68 void receiveData(int s);
69 69
70protected: 70protected:
71#ifndef PWM_EMBEDDED 71#ifndef PWM_EMBEDDED
72 /** stream on "this" end of the socket (sock[0]) */ 72 /** stream on "this" end of the socket (sock[0]) */
73 FILE *stream; 73 FILE *stream;
74 /** current receive buffer size */ 74 /** current receive buffer size */
75 size_t rdBufSize; 75 size_t rdBufSize;
76#else 76#else
77 QSocket* qSock; 77 Q3Socket* qSock;
78 /** current receive buffer size */ 78 /** current receive buffer size */
79 unsigned int rdBufSize; 79 unsigned int rdBufSize;
80#endif 80#endif
81 81
82 /** full-duplex socket file desciptors */ 82 /** full-duplex socket file desciptors */
83 int sock[2]; 83 int sock[2];
84 /** socket notifier */ 84 /** socket notifier */
85 QSocketNotifier *notifier; 85 QSocketNotifier *notifier;
86 /** are we the host or the client object? */ 86 /** are we the host or the client object? */
87 bool host; 87 bool host;
88 /** receive buffer */ 88 /** receive buffer */
89 char *rdBuf; 89 char *rdBuf;
90}; 90};
91 91
92#endif // __PWM_IPC_H 92#endif // __PWM_IPC_H
diff --git a/pwmanager/pwmanager/kcmconfigs/kcmpwmconfig.cpp b/pwmanager/pwmanager/kcmconfigs/kcmpwmconfig.cpp
index b7944c3..1804e88 100644
--- a/pwmanager/pwmanager/kcmconfigs/kcmpwmconfig.cpp
+++ b/pwmanager/pwmanager/kcmconfigs/kcmpwmconfig.cpp
@@ -1,72 +1,74 @@
1/* 1/*
2 This file is part of PwManager/Pi 2 This file is part of PwManager/Pi
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qlayout.h> 24#include <qlayout.h>
25//Added by qt3to4:
26#include <Q3VBoxLayout>
25 27
26#include <kdebug.h> 28#include <kdebug.h>
27 29
28#include "pwmconfigwidget.h" 30#include "pwmconfigwidget.h"
29 31
30#include "kcmpwmconfig.h" 32#include "kcmpwmconfig.h"
31 33
32#include "pwmprefs.h" 34#include "pwmprefs.h"
33#include "kprefs.h" 35#include "kprefs.h"
34 36
35extern "C" 37extern "C"
36{ 38{
37 KCModule *create_pwmconfig(QWidget *parent, const char * ) { 39 KCModule *create_pwmconfig(QWidget *parent, const char * ) {
38 return new KCMPwmConfig(parent, "kcmpwmconfig" ); 40 return new KCMPwmConfig(parent, "kcmpwmconfig" );
39 } 41 }
40} 42}
41 43
42KCMPwmConfig::KCMPwmConfig(QWidget *parent, const char *name ) 44KCMPwmConfig::KCMPwmConfig(QWidget *parent, const char *name )
43 : KCModule( PWMPrefs::instance(), parent, name ) 45 : KCModule( PWMPrefs::instance(), parent, name )
44{ 46{
45 QVBoxLayout *layout = new QVBoxLayout( this ); 47 Q3VBoxLayout *layout = new Q3VBoxLayout( this );
46 mConfigWidget = new PWMConfigWidget( (PWMPrefs*)getPreferences(), this, "mConfigWidget" ); 48 mConfigWidget = new PWMConfigWidget( (PWMPrefs*)getPreferences(), this, "mConfigWidget" );
47 layout->addWidget( mConfigWidget ); 49 layout->addWidget( mConfigWidget );
48 layout->setSpacing( 0 ); 50 layout->setSpacing( 0 );
49 layout->setMargin( 0 ); 51 layout->setMargin( 0 );
50 52
51 connect( mConfigWidget, SIGNAL( changed( bool ) ), SIGNAL( changed( bool ) ) ); 53 connect( mConfigWidget, SIGNAL( changed( bool ) ), SIGNAL( changed( bool ) ) );
52} 54}
53 55
54void KCMPwmConfig::load() 56void KCMPwmConfig::load()
55{ 57{
56 mConfigWidget->readConfig(); 58 mConfigWidget->readConfig();
57} 59}
58 60
59void KCMPwmConfig::save() 61void KCMPwmConfig::save()
60{ 62{
61 mConfigWidget->writeConfig(); 63 mConfigWidget->writeConfig();
62} 64}
63 65
64void KCMPwmConfig::defaults() 66void KCMPwmConfig::defaults()
65{ 67{
66 mConfigWidget->setDefaults(); 68 mConfigWidget->setDefaults();
67} 69}
68 70
69 71
70#ifndef PWM_EMBEDDED 72#ifndef PWM_EMBEDDED
71#include "kcmkabconfig.moc" 73#include "kcmkabconfig.moc"
72#endif //PWM_EMBEDDED 74#endif //PWM_EMBEDDED
diff --git a/pwmanager/pwmanager/kcmconfigs/pwmconfigwidget.cpp b/pwmanager/pwmanager/kcmconfigs/pwmconfigwidget.cpp
index 2c5189c..04771b3 100644
--- a/pwmanager/pwmanager/kcmconfigs/pwmconfigwidget.cpp
+++ b/pwmanager/pwmanager/kcmconfigs/pwmconfigwidget.cpp
@@ -1,365 +1,368 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qcheckbox.h> 24#include <qcheckbox.h>
25#include <qframe.h> 25#include <q3frame.h>
26#include <qgroupbox.h> 26#include <q3groupbox.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qtabwidget.h> 29#include <qtabwidget.h>
30#include <qcombobox.h> 30#include <qcombobox.h>
31#include <qlineedit.h> 31#include <qlineedit.h>
32#include <qspinbox.h> 32#include <qspinbox.h>
33#include <qlabel.h> 33#include <qlabel.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qvbox.h> 35#include <q3vbox.h>
36//Added by qt3to4:
37#include <Q3GridLayout>
38#include <Q3VBoxLayout>
36 39
37#include <kconfig.h> 40#include <kconfig.h>
38#include <kdebug.h> 41#include <kdebug.h>
39#include <kdialog.h> 42#include <kdialog.h>
40#include <klistview.h> 43#include <klistview.h>
41#include <klocale.h> 44#include <klocale.h>
42#include <kglobal.h> 45#include <kglobal.h>
43#include <kmessagebox.h> 46#include <kmessagebox.h>
44#include <kstandarddirs.h> 47#include <kstandarddirs.h>
45#include <kio/kfile/kurlrequester.h> 48#include <kio/kfile/kurlrequester.h>
46 49
47#include "pwmprefs.h" 50#include "pwmprefs.h"
48 51
49#include "pwmconfigwidget.h" 52#include "pwmconfigwidget.h"
50#include "pwmexception.h" 53#include "pwmexception.h"
51 54
52PWMConfigWidget::PWMConfigWidget(PWMPrefs *prefs, QWidget *parent, const char *name ) 55PWMConfigWidget::PWMConfigWidget(PWMPrefs *prefs, QWidget *parent, const char *name )
53 : KPrefsWidget(prefs, parent, name ) 56 : KPrefsWidget(prefs, parent, name )
54{ 57{
55 QVBoxLayout *topLayout = new QVBoxLayout( this, 0, 58 Q3VBoxLayout *topLayout = new Q3VBoxLayout( this, 0,
56 KDialog::spacingHint() ); 59 KDialog::spacingHint() );
57 60
58 QTabWidget *tabWidget = new QTabWidget( this ); 61 QTabWidget *tabWidget = new QTabWidget( this );
59 topLayout->addWidget( tabWidget ); 62 topLayout->addWidget( tabWidget );
60 63
61 // windowsStyle page 64 // windowsStyle page
62 ////////////////////////////////////////////////////// 65 //////////////////////////////////////////////////////
63 QWidget *windowStylePage = new QWidget( this ); 66 QWidget *windowStylePage = new QWidget( this );
64 QGridLayout *windowStyleLayout = new QGridLayout( windowStylePage, 3, 3); 67 Q3GridLayout *windowStyleLayout = new Q3GridLayout( windowStylePage, 3, 3);
65 68
66 int i = 0; 69 int i = 0;
67 KPrefsWidRadios * windowStyle = addWidRadios(i18n("Window-style:") ,&(prefs->mMainViewStyle), windowStylePage); 70 KPrefsWidRadios * windowStyle = addWidRadios(i18n("Window-style:") ,&(prefs->mMainViewStyle), windowStylePage);
68 windowStyle->addRadio(i18n("Category on top")); 71 windowStyle->addRadio(i18n("Category on top"));
69 windowStyle->addRadio(i18n("Category-list left/top")); 72 windowStyle->addRadio(i18n("Category-list left/top"));
70 windowStyleLayout->addMultiCellWidget( (QWidget*)windowStyle->groupBox(),i,i,0,2); 73 windowStyleLayout->addMultiCellWidget( (QWidget*)windowStyle->groupBox(),i,i,0,2);
71 ++i; 74 ++i;
72 75
73 QLabel* lab = new QLabel(i18n("Font for Password entries:"), windowStylePage); 76 QLabel* lab = new QLabel(i18n("Font for Password entries:"), windowStylePage);
74 windowStyleLayout->addMultiCellWidget( lab,i,i,0,2); 77 windowStyleLayout->addMultiCellWidget( lab,i,i,0,2);
75 ++i; 78 ++i;
76 KPrefsWidFont *selEntrFont = 79 KPrefsWidFont *selEntrFont =
77 addWidFont(i18n("Password"),i18n("Font:"), 80 addWidFont(i18n("Password"),i18n("Font:"),
78 &(prefs->mEntryFont),windowStylePage); 81 &(prefs->mEntryFont),windowStylePage);
79 windowStyleLayout->addWidget(selEntrFont->label(),i,0); 82 windowStyleLayout->addWidget(selEntrFont->label(),i,0);
80 windowStyleLayout->addWidget(selEntrFont->preview(),i,1); 83 windowStyleLayout->addWidget(selEntrFont->preview(),i,1);
81 windowStyleLayout->addWidget(selEntrFont->button(),i,2); 84 windowStyleLayout->addWidget(selEntrFont->button(),i,2);
82 ++i; 85 ++i;
83 86
84 lab = new QLabel(i18n("Font for Password summary:"), windowStylePage); 87 lab = new QLabel(i18n("Font for Password summary:"), windowStylePage);
85 windowStyleLayout->addMultiCellWidget( lab,i,i,0,2); 88 windowStyleLayout->addMultiCellWidget( lab,i,i,0,2);
86 ++i; 89 ++i;
87 selEntrFont = 90 selEntrFont =
88 addWidFont(i18n("Summary"),i18n("Font:"), 91 addWidFont(i18n("Summary"),i18n("Font:"),
89 &(prefs->mViewFont),windowStylePage); 92 &(prefs->mViewFont),windowStylePage);
90 windowStyleLayout->addWidget(selEntrFont->label(),i,0); 93 windowStyleLayout->addWidget(selEntrFont->label(),i,0);
91 windowStyleLayout->addWidget(selEntrFont->preview(),i,1); 94 windowStyleLayout->addWidget(selEntrFont->preview(),i,1);
92 windowStyleLayout->addWidget(selEntrFont->button(),i,2); 95 windowStyleLayout->addWidget(selEntrFont->button(),i,2);
93 ++i; 96 ++i;
94 97
95 lab = new QLabel(i18n(""), windowStylePage); 98 lab = new QLabel(i18n(""), windowStylePage);
96 windowStyleLayout->addMultiCellWidget( lab,i,i,0,2); 99 windowStyleLayout->addMultiCellWidget( lab,i,i,0,2);
97 100
98 // File page 101 // File page
99 ////////////////////////////////////////////////////// 102 //////////////////////////////////////////////////////
100 QWidget *filePage = new QWidget( this ); 103 QWidget *filePage = new QWidget( this );
101 QGridLayout *fileLayout = new QGridLayout( filePage, 3, 2); 104 Q3GridLayout *fileLayout = new Q3GridLayout( filePage, 3, 2);
102 105
103 i = 0; 106 i = 0;
104 QLabel* kcfg_compression_label = new QLabel(i18n("Compression:"), filePage); 107 QLabel* kcfg_compression_label = new QLabel(i18n("Compression:"), filePage);
105 fileLayout->addWidget(kcfg_compression_label,i,0); 108 fileLayout->addWidget(kcfg_compression_label,i,0);
106 kcfg_compression = new QComboBox(filePage, "kcfg_compression"); 109 kcfg_compression = new QComboBox(filePage, "kcfg_compression");
107 kcfg_compression->insertItem(i18n("None")); 110 kcfg_compression->insertItem(i18n("None"));
108 kcfg_compression->insertItem(i18n("gzip")); 111 kcfg_compression->insertItem(i18n("gzip"));
109 //US not yet supported: kcfg_compression->insertItem(i18n("bzip2")); 112 //US not yet supported: kcfg_compression->insertItem(i18n("bzip2"));
110 fileLayout->addWidget( kcfg_compression,i,1); 113 fileLayout->addWidget( kcfg_compression,i,1);
111 ++i; 114 ++i;
112 115
113 QLabel* kcfg_crypt_label = new QLabel(i18n("Encryption:"), filePage); 116 QLabel* kcfg_crypt_label = new QLabel(i18n("Encryption:"), filePage);
114 fileLayout->addWidget(kcfg_crypt_label,i,0); 117 fileLayout->addWidget(kcfg_crypt_label,i,0);
115 kcfg_cryptAlgo = new QComboBox(filePage, "kcfg_cryptAlgo"); 118 kcfg_cryptAlgo = new QComboBox(filePage, "kcfg_cryptAlgo");
116 kcfg_cryptAlgo->insertItem(i18n("Blowfish (128 bit)")); 119 kcfg_cryptAlgo->insertItem(i18n("Blowfish (128 bit)"));
117#ifdef CONFIG_PWMANAGER_GCRY 120#ifdef CONFIG_PWMANAGER_GCRY
118 kcfg_cryptAlgo->insertItem(i18n("AES-128, Rijndael (128 bit)")); 121 kcfg_cryptAlgo->insertItem(i18n("AES-128, Rijndael (128 bit)"));
119 kcfg_cryptAlgo->insertItem(i18n("AES-192, Rijndael (192 bit)")); 122 kcfg_cryptAlgo->insertItem(i18n("AES-192, Rijndael (192 bit)"));
120 kcfg_cryptAlgo->insertItem(i18n("AES-256, Rijndael (256 bit)")); 123 kcfg_cryptAlgo->insertItem(i18n("AES-256, Rijndael (256 bit)"));
121 kcfg_cryptAlgo->insertItem(i18n("Triple-DES (168 bit)")); 124 kcfg_cryptAlgo->insertItem(i18n("Triple-DES (168 bit)"));
122 kcfg_cryptAlgo->insertItem(i18n("Twofish (256 bit)")); 125 kcfg_cryptAlgo->insertItem(i18n("Twofish (256 bit)"));
123 kcfg_cryptAlgo->insertItem(i18n("Twofish-128 (128 bit)")); 126 kcfg_cryptAlgo->insertItem(i18n("Twofish-128 (128 bit)"));
124#endif // CONFIG_PWMANAGER_GCRY 127#endif // CONFIG_PWMANAGER_GCRY
125 fileLayout->addWidget( kcfg_cryptAlgo,i,1); 128 fileLayout->addWidget( kcfg_cryptAlgo,i,1);
126 ++i; 129 ++i;
127 130
128 QLabel* kcfg_hash_label = new QLabel(i18n("Hashing:"), filePage); 131 QLabel* kcfg_hash_label = new QLabel(i18n("Hashing:"), filePage);
129 fileLayout->addWidget(kcfg_hash_label,i,0); 132 fileLayout->addWidget(kcfg_hash_label,i,0);
130 kcfg_hashAlgo = new QComboBox(filePage, "kcfg_hashAlgo"); 133 kcfg_hashAlgo = new QComboBox(filePage, "kcfg_hashAlgo");
131 kcfg_hashAlgo->insertItem(i18n("SHA-160, SHA1 (160 bit)")); 134 kcfg_hashAlgo->insertItem(i18n("SHA-160, SHA1 (160 bit)"));
132#ifdef CONFIG_PWMANAGER_GCRY 135#ifdef CONFIG_PWMANAGER_GCRY
133 kcfg_hashAlgo->insertItem(i18n("SHA-256 (256 bit)")); 136 kcfg_hashAlgo->insertItem(i18n("SHA-256 (256 bit)"));
134 kcfg_hashAlgo->insertItem(i18n("SHA-384 (384 bit)")); 137 kcfg_hashAlgo->insertItem(i18n("SHA-384 (384 bit)"));
135 kcfg_hashAlgo->insertItem(i18n("SHA-512 (512 bit)")); 138 kcfg_hashAlgo->insertItem(i18n("SHA-512 (512 bit)"));
136 kcfg_hashAlgo->insertItem(i18n("MD5 (128 bit)")); 139 kcfg_hashAlgo->insertItem(i18n("MD5 (128 bit)"));
137 kcfg_hashAlgo->insertItem(i18n("RIPE-MD-160 (160 bit)")); 140 kcfg_hashAlgo->insertItem(i18n("RIPE-MD-160 (160 bit)"));
138 kcfg_hashAlgo->insertItem(i18n("Tiger (192 bit)")); 141 kcfg_hashAlgo->insertItem(i18n("Tiger (192 bit)"));
139#endif // CONFIG_PWMANAGER_GCRY 142#endif // CONFIG_PWMANAGER_GCRY
140 fileLayout->addWidget( kcfg_hashAlgo,i,1); 143 fileLayout->addWidget( kcfg_hashAlgo,i,1);
141 ++i; 144 ++i;
142 145
143 permissionLineEdit = new QLineEdit(filePage); 146 permissionLineEdit = new QLineEdit(filePage);
144 QLabel* permissionLineLabel = new QLabel(permissionLineEdit, i18n("Permissions:"), filePage); 147 QLabel* permissionLineLabel = new QLabel(permissionLineEdit, i18n("Permissions:"), filePage);
145 fileLayout->addWidget(permissionLineLabel,i,0); 148 fileLayout->addWidget(permissionLineLabel,i,0);
146 fileLayout->addWidget(permissionLineEdit,i,1); 149 fileLayout->addWidget(permissionLineEdit,i,1);
147 ++i; 150 ++i;
148 151
149 KPrefsWidBool *sb = addWidBool(i18n("Make backup before saving"), 152 KPrefsWidBool *sb = addWidBool(i18n("Make backup before saving"),
150 &(prefs->mMakeFileBackup),filePage); 153 &(prefs->mMakeFileBackup),filePage);
151 fileLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1); 154 fileLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1);
152 ++i; 155 ++i;
153 156
154 // Timeout page 157 // Timeout page
155 ////////////////////////////////////////////////////// 158 //////////////////////////////////////////////////////
156 QWidget *timeoutPage = new QWidget( this ); 159 QWidget *timeoutPage = new QWidget( this );
157 QGridLayout *timeoutLayout = new QGridLayout( timeoutPage, 3, 2); 160 Q3GridLayout *timeoutLayout = new Q3GridLayout( timeoutPage, 3, 2);
158 161
159 i = 0; 162 i = 0;
160 pwTimeoutSpinBox = new QSpinBox( 0,600,10,timeoutPage, "pwTimeoutSpinBox" ); 163 pwTimeoutSpinBox = new QSpinBox( 0,600,10,timeoutPage, "pwTimeoutSpinBox" );
161 QLabel* timeoutLabel = new QLabel(pwTimeoutSpinBox, i18n("<b>Password timeout</b> (timeout to hold password in memory,so you don't have to re-enter it,if you already have entered it) [set to 0 to disable]:"), timeoutPage); 164 QLabel* timeoutLabel = new QLabel(pwTimeoutSpinBox, i18n("<b>Password timeout</b> (timeout to hold password in memory,so you don't have to re-enter it,if you already have entered it) [set to 0 to disable]:"), timeoutPage);
162 timeoutLayout->addMultiCellWidget(timeoutLabel, i, i, 0 ,1); 165 timeoutLayout->addMultiCellWidget(timeoutLabel, i, i, 0 ,1);
163 ++i; 166 ++i;
164 timeoutLayout->addMultiCellWidget(pwTimeoutSpinBox,i,i,0,1); 167 timeoutLayout->addMultiCellWidget(pwTimeoutSpinBox,i,i,0,1);
165 ++i; 168 ++i;
166 pwTimeoutSpinBox->setSuffix ( i18n(" sec") ); 169 pwTimeoutSpinBox->setSuffix ( i18n(" sec") );
167 lockTimeoutSpinBox = new QSpinBox( 0,600,10,timeoutPage, "lockTimeoutSpinBox" ); 170 lockTimeoutSpinBox = new QSpinBox( 0,600,10,timeoutPage, "lockTimeoutSpinBox" );
168 QLabel* lockTimeoutLabel = new QLabel(lockTimeoutSpinBox, i18n("<b>Auto-lock timeout</b> (auto lock document after this\namount of seconds) [set to 0 to disable]:"), timeoutPage); 171 QLabel* lockTimeoutLabel = new QLabel(lockTimeoutSpinBox, i18n("<b>Auto-lock timeout</b> (auto lock document after this\namount of seconds) [set to 0 to disable]:"), timeoutPage);
169 timeoutLayout->addMultiCellWidget(lockTimeoutLabel,i, i, 0 ,1); 172 timeoutLayout->addMultiCellWidget(lockTimeoutLabel,i, i, 0 ,1);
170 ++i; 173 ++i;
171 timeoutLayout->addMultiCellWidget(lockTimeoutSpinBox,i,i,0,1); 174 timeoutLayout->addMultiCellWidget(lockTimeoutSpinBox,i,i,0,1);
172 lockTimeoutSpinBox->setSuffix ( i18n(" sec") ); 175 lockTimeoutSpinBox->setSuffix ( i18n(" sec") );
173 ++i; 176 ++i;
174 177
175 sb = addWidBool(i18n("deep-lock on autolock"), 178 sb = addWidBool(i18n("deep-lock on autolock"),
176 &(prefs->mAutoDeeplock),timeoutPage); 179 &(prefs->mAutoDeeplock),timeoutPage);
177 timeoutLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1); 180 timeoutLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1);
178 ++i; 181 ++i;
179 sb = addWidBool(i18n("Open document with passwords unlocked"),&(prefs->mUnlockOnOpen),timeoutPage); 182 sb = addWidBool(i18n("Open document with passwords unlocked"),&(prefs->mUnlockOnOpen),timeoutPage);
180 timeoutLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1); 183 timeoutLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1);
181 ++i; 184 ++i;
182 185
183 // Autostart page 186 // Autostart page
184 ////////////////////////////////////////////////////// 187 //////////////////////////////////////////////////////
185 QWidget *autostartPage = new QWidget( this ); 188 QWidget *autostartPage = new QWidget( this );
186 QGridLayout *autostartLayout = new QGridLayout( autostartPage, 3, 2); 189 Q3GridLayout *autostartLayout = new Q3GridLayout( autostartPage, 3, 2);
187 190
188 i = 0; 191 i = 0;
189 192
190 autostartLineEdit = new KURLRequester(autostartPage, "autoStartLineEdit"); 193 autostartLineEdit = new KURLRequester(autostartPage, "autoStartLineEdit");
191 QLabel* autostartLineLabel = new QLabel(autostartLineEdit, "Open this file automatically on startup:",autostartPage); 194 QLabel* autostartLineLabel = new QLabel(autostartLineEdit, "Open this file automatically on startup:",autostartPage);
192 autostartLayout->addMultiCellWidget(autostartLineLabel,i,i,0,1); 195 autostartLayout->addMultiCellWidget(autostartLineLabel,i,i,0,1);
193 ++i; 196 ++i;
194 autostartLayout->addMultiCellWidget(autostartLineEdit,i,i,0,1); 197 autostartLayout->addMultiCellWidget(autostartLineEdit,i,i,0,1);
195 ++i; 198 ++i;
196 199
197 sb = addWidBool(i18n("open deeplocked"), 200 sb = addWidBool(i18n("open deeplocked"),
198 &(prefs->mAutostartDeeplocked),autostartPage); 201 &(prefs->mAutostartDeeplocked),autostartPage);
199 autostartLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1); 202 autostartLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1);
200 ++i; 203 ++i;
201 204
202 205
203 // external app page 206 // external app page
204 ////////////////////////////////////////////////////// 207 //////////////////////////////////////////////////////
205 QWidget *externalappPage = new QWidget( this ); 208 QWidget *externalappPage = new QWidget( this );
206 QGridLayout *externalappLayout = new QGridLayout( externalappPage, 3, 2); 209 Q3GridLayout *externalappLayout = new Q3GridLayout( externalappPage, 3, 2);
207 210
208 i = 0; 211 i = 0;
209 212
210 browserLineEdit = new QLineEdit(externalappPage); 213 browserLineEdit = new QLineEdit(externalappPage);
211 QLabel* browserLineLabel = new QLabel(browserLineEdit, i18n("Favourite browser:"), externalappPage); 214 QLabel* browserLineLabel = new QLabel(browserLineEdit, i18n("Favourite browser:"), externalappPage);
212 externalappLayout->addWidget(browserLineLabel,i,0); 215 externalappLayout->addWidget(browserLineLabel,i,0);
213 externalappLayout->addWidget(browserLineEdit,i,1); 216 externalappLayout->addWidget(browserLineEdit,i,1);
214 ++i; 217 ++i;
215 218
216 xtermLineEdit = new QLineEdit(externalappPage); 219 xtermLineEdit = new QLineEdit(externalappPage);
217 QLabel* xtermLineLabel = new QLabel(xtermLineEdit, i18n("Favourite x-terminal:"), externalappPage); 220 QLabel* xtermLineLabel = new QLabel(xtermLineEdit, i18n("Favourite x-terminal:"), externalappPage);
218 externalappLayout->addWidget(xtermLineLabel,i,0); 221 externalappLayout->addWidget(xtermLineLabel,i,0);
219 externalappLayout->addWidget(xtermLineEdit,i,1); 222 externalappLayout->addWidget(xtermLineEdit,i,1);
220 ++i; 223 ++i;
221 224
222#if 0 225#if 0
223 // miscelaneous page 226 // miscelaneous page
224 ////////////////////////////////////////////////////// 227 //////////////////////////////////////////////////////
225 QWidget *miscPage = new QWidget( this ); 228 QWidget *miscPage = new QWidget( this );
226 QGridLayout *miscLayout = new QGridLayout( miscPage, 3, 2); 229 Q3GridLayout *miscLayout = new Q3GridLayout( miscPage, 3, 2);
227 230
228 i = 0; 231 i = 0;
229 232
230 /*US ENH: PWM/Pi has no tray and con be minimized 233 /*US ENH: PWM/Pi has no tray and con be minimized
231 sb = addWidBool(i18n("Show icon in system-tray"),&(prefs->mTray),miscPage); 234 sb = addWidBool(i18n("Show icon in system-tray"),&(prefs->mTray),miscPage);
232 miscLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1); 235 miscLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1);
233 ++i; 236 ++i;
234 */ 237 */
235 238
236 sb = addWidBool(i18n("Open document with passwords unlocked"),&(prefs->mUnlockOnOpen),miscPage); 239 sb = addWidBool(i18n("Open document with passwords unlocked"),&(prefs->mUnlockOnOpen),miscPage);
237 miscLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1); 240 miscLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1);
238 ++i; 241 ++i;
239 242
240 /*US ENH: PWM/Pi has no tray and con be minimized 243 /*US ENH: PWM/Pi has no tray and con be minimized
241 sb = addWidBool(i18n("auto-minimize to tray on startup"),&(prefs->mAutoMinimizeOnStart),miscPage); 244 sb = addWidBool(i18n("auto-minimize to tray on startup"),&(prefs->mAutoMinimizeOnStart),miscPage);
242 miscLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1); 245 miscLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1);
243 ++i; 246 ++i;
244 247
245 KPrefsWidRadios * minimizeRadio = addWidRadios(i18n("auto-lock on minimize:") ,&(prefs->mMinimizeLock), miscPage); 248 KPrefsWidRadios * minimizeRadio = addWidRadios(i18n("auto-lock on minimize:") ,&(prefs->mMinimizeLock), miscPage);
246 minimizeRadio->addRadio(i18n("don't lock")); 249 minimizeRadio->addRadio(i18n("don't lock"));
247 minimizeRadio->addRadio(i18n("normal lock")); 250 minimizeRadio->addRadio(i18n("normal lock"));
248 minimizeRadio->addRadio(i18n("deep-lock")); 251 minimizeRadio->addRadio(i18n("deep-lock"));
249 miscLayout->addMultiCellWidget( (QWidget*)minimizeRadio->groupBox(),i,i,0,2); 252 miscLayout->addMultiCellWidget( (QWidget*)minimizeRadio->groupBox(),i,i,0,2);
250 ++i; 253 ++i;
251 254
252 sb = addWidBool(i18n("KWallet emulation"),&(prefs->mKWalletEmu),miscPage); 255 sb = addWidBool(i18n("KWallet emulation"),&(prefs->mKWalletEmu),miscPage);
253 miscLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1); 256 miscLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1);
254 ++i; 257 ++i;
255 258
256 sb = addWidBool(i18n("Close instead Minimize into tray"),&(prefs->mClose),miscPage); 259 sb = addWidBool(i18n("Close instead Minimize into tray"),&(prefs->mClose),miscPage);
257 miscLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1); 260 miscLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1);
258 ++i; 261 ++i;
259 */ 262 */
260#endif 263#endif
261 264
262 tabWidget->addTab( windowStylePage, i18n( "Look && feel" ) ); 265 tabWidget->addTab( windowStylePage, i18n( "Look && feel" ) );
263 tabWidget->addTab( filePage, i18n( "File" ) ); 266 tabWidget->addTab( filePage, i18n( "File" ) );
264 tabWidget->addTab( timeoutPage, i18n( "Timeout" ) ); 267 tabWidget->addTab( timeoutPage, i18n( "Timeout" ) );
265 tabWidget->addTab( autostartPage, i18n( "Autostart" ) ); 268 tabWidget->addTab( autostartPage, i18n( "Autostart" ) );
266 tabWidget->addTab( externalappPage, i18n( "External apps" ) ); 269 tabWidget->addTab( externalappPage, i18n( "External apps" ) );
267 //tabWidget->addTab( miscPage, i18n( "Miscellaneous" ) ); 270 //tabWidget->addTab( miscPage, i18n( "Miscellaneous" ) );
268 271
269 272
270 connect( permissionLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( modified() ) ); 273 connect( permissionLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( modified() ) );
271 connect( pwTimeoutSpinBox, SIGNAL( valueChanged(int) ), this, SLOT( modified() ) ); 274 connect( pwTimeoutSpinBox, SIGNAL( valueChanged(int) ), this, SLOT( modified() ) );
272 connect( lockTimeoutSpinBox, SIGNAL( valueChanged(int) ), this, SLOT( modified() ) ); 275 connect( lockTimeoutSpinBox, SIGNAL( valueChanged(int) ), this, SLOT( modified() ) );
273 connect( autostartLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( modified() ) ); 276 connect( autostartLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( modified() ) );
274 connect( browserLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( modified() ) ); 277 connect( browserLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( modified() ) );
275 connect( xtermLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( modified() ) ); 278 connect( xtermLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( modified() ) );
276 279
277} 280}
278 281
279 282
280void PWMConfigWidget::usrReadConfig() 283void PWMConfigWidget::usrReadConfig()
281{ 284{
282 PWMPrefs* prefs = PWMPrefs::instance(); 285 PWMPrefs* prefs = PWMPrefs::instance();
283 286
284 287
285 setFilePermissions(prefs->mFilePermissions); 288 setFilePermissions(prefs->mFilePermissions);
286 289
287 pwTimeoutSpinBox->setValue(prefs->mPwTimeout); 290 pwTimeoutSpinBox->setValue(prefs->mPwTimeout);
288 lockTimeoutSpinBox->setValue(prefs->mLockTimeout); 291 lockTimeoutSpinBox->setValue(prefs->mLockTimeout);
289 autostartLineEdit->setURL(prefs->mAutoStart); 292 autostartLineEdit->setURL(prefs->mAutoStart);
290 browserLineEdit->setText(prefs->mBrowserCommand); 293 browserLineEdit->setText(prefs->mBrowserCommand);
291 xtermLineEdit->setText(prefs->mXTermCommand); 294 xtermLineEdit->setText(prefs->mXTermCommand);
292 295
293 kcfg_compression->setCurrentItem(prefs->mCompression); 296 kcfg_compression->setCurrentItem(prefs->mCompression);
294 kcfg_cryptAlgo->setCurrentItem(prefs->mCryptAlgo); 297 kcfg_cryptAlgo->setCurrentItem(prefs->mCryptAlgo);
295 kcfg_hashAlgo->setCurrentItem(prefs->mHashAlgo); 298 kcfg_hashAlgo->setCurrentItem(prefs->mHashAlgo);
296} 299}
297 300
298void PWMConfigWidget::usrWriteConfig() 301void PWMConfigWidget::usrWriteConfig()
299{ 302{
300 PWMPrefs* prefs = PWMPrefs::instance(); 303 PWMPrefs* prefs = PWMPrefs::instance();
301 304
302 prefs->mFilePermissions = getFilePermissions(); 305 prefs->mFilePermissions = getFilePermissions();
303 306
304 prefs->mPwTimeout = pwTimeoutSpinBox->value(); 307 prefs->mPwTimeout = pwTimeoutSpinBox->value();
305 prefs->mLockTimeout = lockTimeoutSpinBox->value(); 308 prefs->mLockTimeout = lockTimeoutSpinBox->value();
306 prefs->mAutoStart = autostartLineEdit->url(); 309 prefs->mAutoStart = autostartLineEdit->url();
307 310
308 prefs->mBrowserCommand = browserLineEdit->text(); 311 prefs->mBrowserCommand = browserLineEdit->text();
309 prefs->mXTermCommand = xtermLineEdit->text(); 312 prefs->mXTermCommand = xtermLineEdit->text();
310 313
311 prefs->mCompression = kcfg_compression->currentItem(); 314 prefs->mCompression = kcfg_compression->currentItem();
312 prefs->mCryptAlgo = kcfg_cryptAlgo->currentItem(); 315 prefs->mCryptAlgo = kcfg_cryptAlgo->currentItem();
313 prefs->mHashAlgo = kcfg_hashAlgo->currentItem(); 316 prefs->mHashAlgo = kcfg_hashAlgo->currentItem();
314 317
315} 318}
316 319
317int PWMConfigWidget::getFilePermissions() 320int PWMConfigWidget::getFilePermissions()
318{ 321{
319 char octalDigits[] = "01234567"; 322 char octalDigits[] = "01234567";
320 bool isOctal; 323 bool isOctal;
321 QString permString(permissionLineEdit->text()); 324 QString permString(permissionLineEdit->text());
322 int i, j, length = permString.length(); 325 int i, j, length = permString.length();
323 if (length != 3) { 326 if (length != 3) {
324 printWarn("Wrong permission string length! Please enter " 327 printWarn("Wrong permission string length! Please enter "
325 "the string like the following example: 600"); 328 "the string like the following example: 600");
326 return CONF_DEFAULT_FILEPERMISSIONS; 329 return CONF_DEFAULT_FILEPERMISSIONS;
327 } 330 }
328 for (i = 0; i < length; ++i) { 331 for (i = 0; i < length; ++i) {
329 isOctal = false; 332 isOctal = false;
330 for (j = 0; j < 8; ++j) { 333 for (j = 0; j < 8; ++j) {
331 if (permString.at(i) == octalDigits[j]) { 334 if (permString.at(i) == octalDigits[j]) {
332 isOctal = true; 335 isOctal = true;
333 break; 336 break;
334 } 337 }
335 } 338 }
336 if (!isOctal) { 339 if (!isOctal) {
337 printWarn("CONFIG: File-permissions: This is " 340 printWarn("CONFIG: File-permissions: This is "
338 "not an octal number "); 341 "not an octal number ");
339 return CONF_DEFAULT_FILEPERMISSIONS; 342 return CONF_DEFAULT_FILEPERMISSIONS;
340 } 343 }
341 } 344 }
342 345
343 int ret = strtol(permString.latin1(), 0, 8); 346 int ret = strtol(permString.latin1(), 0, 8);
344 if (ret == 0) { 347 if (ret == 0) {
345 /* either an error occured, or the user did really type 000 */ 348 /* either an error occured, or the user did really type 000 */
346 printWarn("CONFIG: File-permissions: Hm, either conversion error, " 349 printWarn("CONFIG: File-permissions: Hm, either conversion error, "
347 "or you really typed 000. 8-)"); 350 "or you really typed 000. 8-)");
348 return CONF_DEFAULT_FILEPERMISSIONS; 351 return CONF_DEFAULT_FILEPERMISSIONS;
349 } 352 }
350 return ret; 353 return ret;
351} 354}
352 355
353void PWMConfigWidget::setFilePermissions(int perm) 356void PWMConfigWidget::setFilePermissions(int perm)
354{ 357{
355 char tmpBuf[30]; 358 char tmpBuf[30];
356 sprintf(tmpBuf, "%o", perm); 359 sprintf(tmpBuf, "%o", perm);
357 permissionLineEdit->setText(tmpBuf); 360 permissionLineEdit->setText(tmpBuf);
358} 361}
359 362
360 363
361 364
362#ifndef PWM_EMBEDDED 365#ifndef PWM_EMBEDDED_
363#include "pwmconfigwidget.moc" 366#include "moc_pwmconfigwidget.cpp"
364#endif //PWM_EMBEDDED 367#endif //PWM_EMBEDDED
365 368
diff --git a/pwmanager/pwmanager/listobjselectwnd.cpp b/pwmanager/pwmanager/listobjselectwnd.cpp
index 59729f1..7da7e95 100644
--- a/pwmanager/pwmanager/listobjselectwnd.cpp
+++ b/pwmanager/pwmanager/listobjselectwnd.cpp
@@ -1,131 +1,134 @@
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 "listobjselectwnd.h" 20#include "listobjselectwnd.h"
21 21
22#include <klocale.h> 22#include <klocale.h>
23//Added by qt3to4:
24#include <QResizeEvent>
25#include <QLabel>
23 26
24 27
25ListObjSelectWnd::ListObjSelectWnd(const QString &caption, const QString &titleText, 28ListObjSelectWnd::ListObjSelectWnd(const QString &caption, const QString &titleText,
26 QWidget *parent, bool multiSel, const char *name, 29 QWidget *parent, bool multiSel, const char *name,
27 bool modal, WFlags f) 30 bool modal, Qt::WFlags f)
28 : QDialog(parent, name, modal, f) 31 : QDialog(parent, name, modal, f)
29{ 32{
30 vbox1 = new QVBox(this); 33 vbox1 = new Q3VBox(this);
31 title = new QLabel(vbox1); 34 title = new QLabel(vbox1);
32 list = new QListBox(vbox1); 35 list = new Q3ListBox(vbox1);
33 if (multiSel) { 36 if (multiSel) {
34 hbox2 = new QHBox(vbox1); 37 hbox2 = new Q3HBox(vbox1);
35 selAllButton = new QPushButton(i18n("&Select all"), hbox2); 38 selAllButton = new QPushButton(i18n("&Select all"), hbox2);
36 unselAllButton = new QPushButton(i18n("&Unselect all"), hbox2); 39 unselAllButton = new QPushButton(i18n("&Unselect all"), hbox2);
37 } 40 }
38 hbox1 = new QHBox(vbox1); 41 hbox1 = new Q3HBox(vbox1);
39 okButton = new QPushButton(i18n("&Ok"), hbox1); 42 okButton = new QPushButton(i18n("&Ok"), hbox1);
40 cancelButton = new QPushButton(i18n("&Cancel"), hbox1); 43 cancelButton = new QPushButton(i18n("&Cancel"), hbox1);
41 44
42 vbox1->setSpacing(10); 45 vbox1->setSpacing(10);
43 vbox1->setMargin(10); 46 vbox1->setMargin(10);
44 hbox1->setSpacing(10); 47 hbox1->setSpacing(10);
45 resize(250, 300); 48 resize(250, 300);
46 setCaption(caption); 49 setCaption(caption);
47 if (multiSel) { 50 if (multiSel) {
48 list->setSelectionMode(QListBox::Multi); 51 list->setSelectionMode(Q3ListBox::Multi);
49 } 52 }
50 53
51 title->setAlignment(Qt::AlignHCenter | Qt::WordBreak); 54 title->setAlignment(Qt::AlignHCenter | Qt::WordBreak);
52 title->setText(titleText); 55 title->setText(titleText);
53 56
54 connect(okButton, SIGNAL(clicked()), 57 connect(okButton, SIGNAL(clicked()),
55 this, SLOT(okButton_slot())); 58 this, SLOT(okButton_slot()));
56 connect(cancelButton, SIGNAL(clicked()), 59 connect(cancelButton, SIGNAL(clicked()),
57 this, SLOT(cancelButton_slot())); 60 this, SLOT(cancelButton_slot()));
58 if (multiSel) { 61 if (multiSel) {
59 connect(selAllButton, SIGNAL(clicked()), 62 connect(selAllButton, SIGNAL(clicked()),
60 this, SLOT(selAllButton_slot())); 63 this, SLOT(selAllButton_slot()));
61 connect(unselAllButton, SIGNAL(clicked()), 64 connect(unselAllButton, SIGNAL(clicked()),
62 this, SLOT(unselAllButton_slot())); 65 this, SLOT(unselAllButton_slot()));
63 } 66 }
64} 67}
65 68
66ListObjSelectWnd::~ListObjSelectWnd() 69ListObjSelectWnd::~ListObjSelectWnd()
67{ 70{
68} 71}
69 72
70void ListObjSelectWnd::resizeEvent(QResizeEvent *) 73void ListObjSelectWnd::resizeEvent(QResizeEvent *)
71{ 74{
72 vbox1->resize(size()); 75 vbox1->resize(size());
73} 76}
74 77
75void ListObjSelectWnd::okButton_slot() 78void ListObjSelectWnd::okButton_slot()
76{ 79{
77 unsigned int cnt = list->count(), i; 80 unsigned int cnt = list->count(), i;
78 for (i = 0; i < cnt; ++i) { 81 for (i = 0; i < cnt; ++i) {
79 if (list->isSelected(i)) { 82 if (list->isSelected(i)) {
80 done(1); 83 done(1);
81 return; 84 return;
82 } 85 }
83 } 86 }
84} 87}
85 88
86void ListObjSelectWnd::cancelButton_slot() 89void ListObjSelectWnd::cancelButton_slot()
87{ 90{
88 done(2); 91 done(2);
89} 92}
90 93
91void ListObjSelectWnd::selAllButton_slot() 94void ListObjSelectWnd::selAllButton_slot()
92{ 95{
93 unsigned int cnt = list->count(), i; 96 unsigned int cnt = list->count(), i;
94 for (i = 0; i < cnt; ++i) { 97 for (i = 0; i < cnt; ++i) {
95 list->setSelected(i, true); 98 list->setSelected(i, true);
96 } 99 }
97} 100}
98 101
99void ListObjSelectWnd::unselAllButton_slot() 102void ListObjSelectWnd::unselAllButton_slot()
100{ 103{
101 unsigned int cnt = list->count(), i; 104 unsigned int cnt = list->count(), i;
102 for (i = 0; i < cnt; ++i) { 105 for (i = 0; i < cnt; ++i) {
103 list->setSelected(i, false); 106 list->setSelected(i, false);
104 } 107 }
105} 108}
106 109
107QStringList ListObjSelectWnd::getSelectedList() 110QStringList ListObjSelectWnd::getSelectedList()
108{ 111{
109 QStringList ret; 112 QStringList ret;
110 unsigned int cnt = list->count(), i; 113 unsigned int cnt = list->count(), i;
111 for (i = 0; i < cnt; ++i) { 114 for (i = 0; i < cnt; ++i) {
112 if (list->isSelected(i)) { 115 if (list->isSelected(i)) {
113#ifndef PWM_EMBEDDED 116#ifndef PWM_EMBEDDED
114 ret.push_back(list->text(i)); 117 ret.push_back(list->text(i));
115#else 118#else
116 ret.append(list->text(i)); 119 ret.append(list->text(i));
117#endif 120#endif
118 } 121 }
119 } 122 }
120 return ret; 123 return ret;
121} 124}
122 125
123void ListObjSelectWnd::setList(const QStringList &_list) 126void ListObjSelectWnd::setList(const QStringList &_list)
124{ 127{
125 list->clear(); 128 list->clear();
126 list->insertStringList(_list); 129 list->insertStringList(_list);
127} 130}
128 131
129#ifndef PWM_EMBEDDED 132#ifndef PWM_EMBEDDED_
130#include "listobjselectwnd.moc" 133#include "moc_listobjselectwnd.cpp"
131#endif 134#endif
diff --git a/pwmanager/pwmanager/listobjselectwnd.h b/pwmanager/pwmanager/listobjselectwnd.h
index 3b5f1eb..df3da93 100644
--- a/pwmanager/pwmanager/listobjselectwnd.h
+++ b/pwmanager/pwmanager/listobjselectwnd.h
@@ -1,85 +1,87 @@
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 LISTOBJSELECTWND_H 20#ifndef LISTOBJSELECTWND_H
21#define LISTOBJSELECTWND_H 21#define LISTOBJSELECTWND_H
22 22
23#include <qdialog.h> 23#include <qdialog.h>
24#include <qvbox.h> 24#include <q3vbox.h>
25#include <qhbox.h> 25#include <q3hbox.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qlistbox.h> 27#include <q3listbox.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qstringlist.h> 29#include <qstringlist.h>
30//Added by qt3to4:
31#include <QResizeEvent>
30 32
31 33
32/** Display a list-window for selection of some objects */ 34/** Display a list-window for selection of some objects */
33class ListObjSelectWnd : public QDialog 35class ListObjSelectWnd : public QDialog
34{ 36{
35 Q_OBJECT 37 Q_OBJECT
36public: 38public:
37 ListObjSelectWnd(const QString &caption, const QString &titleText, 39 ListObjSelectWnd(const QString &caption, const QString &titleText,
38 QWidget *parent = 0, bool multiSel = false, 40 QWidget *parent = 0, bool multiSel = false,
39 const char *name = 0, 41 const char *name = 0,
40 bool modal = FALSE, WFlags f = 0); 42 bool modal = FALSE, Qt::WFlags f = 0);
41 ~ListObjSelectWnd(); 43 ~ListObjSelectWnd();
42 44
43 void setList(const QStringList &_list); 45 void setList(const QStringList &_list);
44 void addObj(const QString &name) 46 void addObj(const QString &name)
45 { list->insertItem(name); } 47 { list->insertItem(name); }
46 void selectObj(const QString &name) 48 void selectObj(const QString &name)
47#ifndef PWM_EMBEDDED 49#ifndef PWM_EMBEDDED
48 { list->setCurrentItem(list->findItem(name, Qt::ExactMatch)); } 50 { list->setCurrentItem(list->findItem(name, Qt::ExactMatch)); }
49#else 51#else
50 { list->setCurrentItem(list->findItem(name)); } 52 { list->setCurrentItem(list->findItem(name)); }
51#endif 53#endif
52 QString getSelected() 54 QString getSelected()
53 { return list->currentText(); } 55 { return list->currentText(); }
54 int getSelectedIndex() 56 int getSelectedIndex()
55#ifndef PWM_EMBEDDED 57#ifndef PWM_EMBEDDED
56 { return list->index(list->selectedItem()); } 58 { return list->index(list->selectedItem()); }
57#else 59#else
58 { return list->currentItem(); } 60 { return list->currentItem(); }
59#endif 61#endif
60 QStringList getSelectedList(); 62 QStringList getSelectedList();
61 void clearObjs() 63 void clearObjs()
62 { list->clear(); } 64 { list->clear(); }
63 65
64protected: 66protected:
65 QVBox *vbox1; 67 Q3VBox *vbox1;
66 QHBox *hbox1; 68 Q3HBox *hbox1;
67 QHBox *hbox2; 69 Q3HBox *hbox2;
68 QLabel *title; 70 QLabel *title;
69 QListBox *list; 71 Q3ListBox *list;
70 QPushButton *okButton; 72 QPushButton *okButton;
71 QPushButton *cancelButton; 73 QPushButton *cancelButton;
72 QPushButton *selAllButton; 74 QPushButton *selAllButton;
73 QPushButton *unselAllButton; 75 QPushButton *unselAllButton;
74 76
75protected: 77protected:
76 void resizeEvent(QResizeEvent *); 78 void resizeEvent(QResizeEvent *);
77 79
78protected slots: 80protected slots:
79 void okButton_slot(); 81 void okButton_slot();
80 void cancelButton_slot(); 82 void cancelButton_slot();
81 void selAllButton_slot(); 83 void selAllButton_slot();
82 void unselAllButton_slot(); 84 void unselAllButton_slot();
83}; 85};
84 86
85#endif 87#endif
diff --git a/pwmanager/pwmanager/listviewpwm.cpp b/pwmanager/pwmanager/listviewpwm.cpp
index 0df9431..4253ab1 100644
--- a/pwmanager/pwmanager/listviewpwm.cpp
+++ b/pwmanager/pwmanager/listviewpwm.cpp
@@ -1,129 +1,132 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 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 "listviewpwm.h" 20#include "listviewpwm.h"
21#include "pwmexception.h" 21#include "pwmexception.h"
22#include "pwmview.h" 22#include "pwmview.h"
23 23
24#include <qpainter.h> 24#include <qpainter.h>
25#include <qpixmap.h> 25#include <qpixmap.h>
26//Added by qt3to4:
27#include <QEvent>
28#include <QKeyEvent>
26 29
27#include <kiconloader.h> 30#include <kiconloader.h>
28 31
29#ifdef PWM_EMBEDDED 32#ifdef PWM_EMBEDDED
30#include <kglobal.h> 33#include <kglobal.h>
31#endif 34#endif
32 35
33ListViewPwM::ListViewPwM(QWidget *parent, const char *name) 36ListViewPwM::ListViewPwM(QWidget *parent, const char *name)
34 : KListView(parent, name) 37 : KListView(parent, name)
35{ 38{
36 //setResizeMode(QListView::AllColumns); 39 //setResizeMode(QListView::AllColumns);
37 setAllColumnsShowFocus (true ); 40 setAllColumnsShowFocus (true );
38} 41}
39 42
40bool ListViewPwM::event(QEvent *e) 43bool ListViewPwM::event(QEvent *e)
41{ 44{
42 if (e->type() == QEvent::LayoutHint) 45 if (e->type() == QEvent::LayoutRequest)
43 emit layoutChanged(); 46 emit layoutChanged();
44 if (e->type() == QEvent::KeyPress) { 47 if (e->type() == QEvent::KeyPress) {
45 QKeyEvent* ke = (QKeyEvent*) e; 48 QKeyEvent* ke = (QKeyEvent*) e;
46 if ( ke->key() == Qt::Key_Space) { 49 if ( ke->key() == Qt::Key_Space) {
47 emit toggleOverview(); 50 emit toggleOverview();
48 return true; 51 return true;
49 } 52 }
50 if ( ke->key() == Qt::Key_I || ke->key() == Qt::Key_N || ke->key() == Qt::Key_Insert) { 53 if ( ke->key() == Qt::Key_I || ke->key() == Qt::Key_N || ke->key() == Qt::Key_Insert) {
51 emit insertPW(); 54 emit insertPW();
52 return true; 55 return true;
53 } 56 }
54 if ( ke->key() == Qt::Key_Delete || ke->key() == Qt::Key_Backspace) { 57 if ( ke->key() == Qt::Key_Delete || ke->key() == Qt::Key_Backspace) {
55 emit deletePW(); 58 emit deletePW();
56 return true; 59 return true;
57 } 60 }
58 61
59 } 62 }
60 return KListView::event(e); 63 return KListView::event(e);
61} 64}
62 65
63 66
64QPixmap * ListViewItemPwM::onPix = 0; 67QPixmap * ListViewItemPwM::onPix = 0;
65QPixmap * ListViewItemPwM::offPix = 0; 68QPixmap * ListViewItemPwM::offPix = 0;
66 69
67ListViewItemPwM::ListViewItemPwM(QListView *parent) 70ListViewItemPwM::ListViewItemPwM(Q3ListView *parent)
68 : QCheckListItem(parent, "", QCheckListItem::CheckBox) 71 : Q3CheckListItem(parent, "", Q3CheckListItem::CheckBox)
69{ 72{
70 if (!onPix) { 73 if (!onPix) {
71 PWM_ASSERT(!offPix); 74 PWM_ASSERT(!offPix);
72 KIconLoader* picons; 75 KIconLoader* picons;
73#ifndef PWM_EMBEDDED 76#ifndef PWM_EMBEDDED
74 KIconLoader il; 77 KIconLoader il;
75 picons = &il; 78 picons = &il;
76#else 79#else
77 picons = KGlobal::iconLoader(); 80 picons = KGlobal::iconLoader();
78#endif 81#endif
79 82
80 KIconLoader il; 83 KIconLoader il;
81#ifndef PWM_EMBEDDED 84#ifndef PWM_EMBEDDED
82 static QPixmap onP(picons->loadIcon("button_ok", KIcon::Small)); 85 static QPixmap onP(picons->loadIcon("button_ok", KIcon::Small));
83#else 86#else
84 static QPixmap onP(picons->loadIcon("decrypted", KIcon::Small)); 87 static QPixmap onP(picons->loadIcon("decrypted", KIcon::Small));
85#endif 88#endif
86 onPix = &onP; 89 onPix = &onP;
87 static QPixmap offP(picons->loadIcon("encrypted", KIcon::Small)); 90 static QPixmap offP(picons->loadIcon("encrypted", KIcon::Small));
88 offPix = &offP; 91 offPix = &offP;
89 } 92 }
90} 93}
91 94
92void ListViewItemPwM::paintCell(QPainter *p, const QColorGroup &cg, 95void ListViewItemPwM::paintCell(QPainter *p, const QColorGroup &cg,
93 int column, int width, int align) 96 int column, int width, int align)
94{ 97{
95 // qDebug("ListViewItemPwM::paintCell column=%i", column); 98 // qDebug("ListViewItemPwM::paintCell column=%i", column);
96 if (!p) 99 if (!p)
97 return; 100 return;
98 //US BUG: 101 //US BUG:
99 if (column != COLUMN_DESC) { 102 if (column != COLUMN_DESC) {
100 QCheckListItem::paintCell(p, cg, column, width, align); 103 Q3CheckListItem::paintCell(p, cg, column, width, align);
101 return; 104 return;
102 } 105 }
103 QPixmap *curPix = isOn() ? onPix : offPix; 106 QPixmap *curPix = isOn() ? onPix : offPix;
104 int pixSpace = curPix->width(); 107 int pixSpace = curPix->width();
105 pixSpace += 4; 108 pixSpace += 4;
106#ifndef PWM_EMBEDDED 109#ifndef PWM_EMBEDDED
107 QRect window(p->viewport()); 110 QRect window(p->viewport());
108 // clear the rectangle (we have to clear it first. see QT doc) 111 // clear the rectangle (we have to clear it first. see QT doc)
109 p->eraseRect(0, 0, pixSpace, window.height()); 112 p->eraseRect(0, 0, pixSpace, window.height());
110 // now draw the pixmap 113 // now draw the pixmap
111 int y = (height() - curPix->height()) / 2; 114 int y = (height() - curPix->height()) / 2;
112 p->drawPixmap(1, y, *curPix); 115 p->drawPixmap(1, y, *curPix);
113 window.moveLeft(pixSpace); 116 window.moveLeft(pixSpace);
114 p->setViewport(window); 117 p->setViewport(window);
115#else 118#else
116 p->eraseRect(0, 0, pixSpace, height()); 119 p->eraseRect(0, 0, pixSpace, height());
117 // now draw the pixmap 120 // now draw the pixmap
118 int y = (height() - curPix->height()) / 2; 121 int y = (height() - curPix->height()) / 2;
119 p->drawPixmap(1, y, *curPix); 122 p->drawPixmap(1, y, *curPix);
120 p->translate( pixSpace, 0 ); 123 p->translate( pixSpace, 0 );
121 124
122#endif 125#endif
123 QListViewItem::paintCell(p, cg, column, width - pixSpace, align); 126 Q3ListViewItem::paintCell(p, cg, column, width - pixSpace, align);
124 127
125} 128}
126 129
127#ifndef PWM_EMBEDDED 130#ifndef PWM_EMBEDDED_
128#include "listviewpwm.moc" 131#include "moc_listviewpwm.cpp"
129#endif 132#endif
diff --git a/pwmanager/pwmanager/listviewpwm.h b/pwmanager/pwmanager/listviewpwm.h
index 51008b8..2652939 100644
--- a/pwmanager/pwmanager/listviewpwm.h
+++ b/pwmanager/pwmanager/listviewpwm.h
@@ -1,60 +1,63 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 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 __LISTVIEW_H 20#ifndef __LISTVIEW_H
21#define __LISTVIEW_H 21#define __LISTVIEW_H
22 22
23#include <klistview.h> 23#include <klistview.h>
24//Added by qt3to4:
25#include <QEvent>
26#include <QPixmap>
24 27
25/** PwManager implementation of the list view. 28/** PwManager implementation of the list view.
26 * Derived from KListView. 29 * Derived from KListView.
27 */ 30 */
28class ListViewPwM : public KListView 31class ListViewPwM : public KListView
29{ 32{
30 Q_OBJECT 33 Q_OBJECT
31public: 34public:
32 ListViewPwM(QWidget *parent = 0, const char *name = 0); 35 ListViewPwM(QWidget *parent = 0, const char *name = 0);
33 36
34signals: 37signals:
35 void layoutChanged(); 38 void layoutChanged();
36 void toggleOverview(); 39 void toggleOverview();
37 void insertPW(); 40 void insertPW();
38 void deletePW( ); 41 void deletePW( );
39 42
40protected: 43protected:
41 virtual bool event(QEvent *e); 44 virtual bool event(QEvent *e);
42}; 45};
43 46
44class ListViewItemPwM : public QCheckListItem 47class ListViewItemPwM : public Q3CheckListItem
45{ 48{
46public: 49public:
47 ListViewItemPwM(QListView *parent); 50 ListViewItemPwM(Q3ListView *parent);
48 51
49protected: 52protected:
50 void paintCell(QPainter *p, const QColorGroup &cg, 53 void paintCell(QPainter *p, const QColorGroup &cg,
51 int column, int width, int align); 54 int column, int width, int align);
52 55
53protected: 56protected:
54 /** pixmap to display for an item with state "on" */ 57 /** pixmap to display for an item with state "on" */
55 static QPixmap *onPix; 58 static QPixmap *onPix;
56 /** pixmap to display for an item with state "off" */ 59 /** pixmap to display for an item with state "off" */
57 static QPixmap *offPix; 60 static QPixmap *offPix;
58}; 61};
59 62
60#endif 63#endif
diff --git a/pwmanager/pwmanager/main.cpp b/pwmanager/pwmanager/main.cpp
index ee26082..acb0011 100644
--- a/pwmanager/pwmanager/main.cpp
+++ b/pwmanager/pwmanager/main.cpp
@@ -1,223 +1,224 @@
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"
33void dumpMissing(); 33void dumpMissing();
34 34
35 #define LICENSE_FILE(::locate("data", "pwmanager/pwmanager_license_text")) 35 #define LICENSE_FILE(::locate("data", "pwmanager/pwmanager_license_text"))
36 36
37int PwMApplication::newInstance() 37int PwMApplication::newInstance()
38{ 38{
39 static bool initial = true; 39 static bool initial = true;
40 if (initial) { 40 if (initial) {
41 initial = false; 41 initial = false;
42 init = new PwMInit(this); 42 init = new PwMInit(this);
43 init->initializeApp(); 43 init->initializeApp();
44 } else { 44 } else {
45 BUG_ON(!init); 45 BUG_ON(!init);
46 printInfo("passing parameters to old instance."); 46 printInfo("passing parameters to old instance.");
47 init->handleCmdLineArgs(false); 47 init->handleCmdLineArgs(false);
48 } 48 }
49 return EXIT_SUCCESS; 49 return EXIT_SUCCESS;
50} 50}
51 51
52 52
53static const char *description = I18N_NOOP("PwManager\n" 53static const char *description = I18N_NOOP("PwManager\n"
54 "The convenient way of managing passwords"); 54 "The convenient way of managing passwords");
55 55
56#ifndef PWM_EMBEDDED 56#ifndef PWM_EMBEDDED
57static KCmdLineOptions options[] = 57static KCmdLineOptions options[] =
58{ 58{
59 { "minimized", I18N_NOOP("Windows minimized"), 0 }, 59 { "minimized", I18N_NOOP("Windows minimized"), 0 },
60 { "mintray", I18N_NOOP("Windows minimized to tray"),0 }, 60 { "mintray", I18N_NOOP("Windows minimized to tray"),0 },
61 { "open-deeplocked", I18N_NOOP("Open all \"files\" deeplocked"),0 }, 61 { "open-deeplocked", I18N_NOOP("Open all \"files\" deeplocked"),0 },
62 { "skip-self-test", I18N_NOOP("Don't run a self-test on startup"),0 }, 62 { "skip-self-test", I18N_NOOP("Don't run a self-test on startup"),0 },
63 { "+[files...]", I18N_NOOP("Files to open on startup"), 0 }, 63 { "+[files...]", I18N_NOOP("Files to open on startup"), 0 },
64 { 0, 0, 0 } 64 { 0, 0, 0 }
65}; 65};
66#endif 66#endif
67 67
68#ifdef PWM_DEBUG 68#ifdef PWM_DEBUG
69static void printDebugConfigureInfo() 69static void printDebugConfigureInfo()
70{ 70{
71 cout << "================================" << endl; 71 cout << "================================" << endl;
72 cout << PROG_NAME " version " PACKAGE_VER << endl; 72 cout << PROG_NAME " version " PACKAGE_VER << endl;
73#ifdef CONFIG_KEYCARD 73#ifdef CONFIG_KEYCARD
74 cout << "CONFIG_KEYCARD: enabled" << endl; 74 cout << "CONFIG_KEYCARD: enabled" << endl;
75#else 75#else
76 cout << "CONFIG_KEYCARD: disabled" << endl; 76 cout << "CONFIG_KEYCARD: disabled" << endl;
77#endif 77#endif
78#ifdef CONFIG_KWALLETIF 78#ifdef CONFIG_KWALLETIF
79 cout << "CONFIG_KWALLETIF: enabled" << endl; 79 cout << "CONFIG_KWALLETIF: enabled" << endl;
80#else 80#else
81 cout << "CONFIG_KWALLETIF: disabled" << endl; 81 cout << "CONFIG_KWALLETIF: disabled" << endl;
82#endif 82#endif
83#ifdef BIG_ENDIAN_HOST 83#ifdef BIG_ENDIAN_HOST
84 cout << "Endianess: big-endian" << endl; 84 cout << "Endianess: big-endian" << endl;
85#else 85#else
86 cout << "Endianess: little-endian" << endl; 86 cout << "Endianess: little-endian" << endl;
87#endif 87#endif
88#ifdef WORDS_BIGENDIAN 88#ifdef WORDS_BIGENDIAN
89 cout << "Endianess 2: big-endian" << endl; 89 cout << "Endianess 2: big-endian" << endl;
90#else 90#else
91 cout << "Endianess 2: little-endian" << endl; 91 cout << "Endianess 2: little-endian" << endl;
92#endif 92#endif
93 93
94 cout << "sizeof(long): " << sizeof(long) << endl; 94 cout << "sizeof(long): " << sizeof(long) << endl;
95 cout << "================================" << endl; 95 cout << "================================" << endl;
96} 96}
97#else // PWM_DEBUG 97#else // PWM_DEBUG
98static inline void printDebugConfigureInfo() { /* nothing */ } 98static inline void printDebugConfigureInfo() { /* nothing */ }
99#endif // PWM_DEBUG 99#endif // PWM_DEBUG
100 100
101#ifndef PWM_EMBEDDED 101#ifndef PWM_EMBEDDED
102static void addAuthors(KAboutData *aboutData) 102static void addAuthors(KAboutData *aboutData)
103{ 103{
104 aboutData->addAuthor("Michael Buesch", 104 aboutData->addAuthor("Michael Buesch",
105 I18N_NOOP( 105 I18N_NOOP(
106 "main programming and current maintainer"), 106 "main programming and current maintainer"),
107 "mbuesch@freenet.de"); 107 "mbuesch@freenet.de");
108 aboutData->addAuthor("Matt Scifo", 108 aboutData->addAuthor("Matt Scifo",
109 I18N_NOOP( 109 I18N_NOOP(
110 "original implementaion of \n" 110 "original implementaion of \n"
111 "\"categories\" and the password-tree \n" 111 "\"categories\" and the password-tree \n"
112 "in the system-tray. Original implementations of \n" 112 "in the system-tray. Original implementations of \n"
113 "numerous view-improvements."), 113 "numerous view-improvements."),
114 "mscifo@o1.com"); 114 "mscifo@o1.com");
115 aboutData->addCredit("Elias Probst", 115 aboutData->addCredit("Elias Probst",
116 I18N_NOOP( 116 I18N_NOOP(
117 "Gentoo ebuild maintainer."), 117 "Gentoo ebuild maintainer."),
118 "elias.probst@gmx.de"); 118 "elias.probst@gmx.de");
119 aboutData->addCredit("George Staikos", 119 aboutData->addCredit("George Staikos",
120 I18N_NOOP("KWallet"), 120 I18N_NOOP("KWallet"),
121 "staikos@kde.org"); 121 "staikos@kde.org");
122 aboutData->addCredit("Matthew Palmer", 122 aboutData->addCredit("Matthew Palmer",
123 I18N_NOOP("rc2 code"), 123 I18N_NOOP("rc2 code"),
124 "mjp16@uow.edu.au"); 124 "mjp16@uow.edu.au");
125 aboutData->addCredit("Olivier Sessink", 125 aboutData->addCredit("Olivier Sessink",
126 I18N_NOOP("gpasman"), 126 I18N_NOOP("gpasman"),
127 "gpasman@nl.linux.org"); 127 "gpasman@nl.linux.org");
128 aboutData->addCredit("The libgcrypt developers", 128 aboutData->addCredit("The libgcrypt developers",
129 I18N_NOOP("Blowfish and SHA1 algorithms"), 129 I18N_NOOP("Blowfish and SHA1 algorithms"),
130 0, "ftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/"); 130 0, "ftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/");
131 aboutData->addCredit("Troy Engel", 131 aboutData->addCredit("Troy Engel",
132 I18N_NOOP("kpasman"), 132 I18N_NOOP("kpasman"),
133 "tengel@sonic.net"); 133 "tengel@sonic.net");
134 aboutData->addCredit("Wickey", 134 aboutData->addCredit("Wickey",
135 I18N_NOOP("graphics-design in older versions."), 135 I18N_NOOP("graphics-design in older versions."),
136 "wickey@gmx.at"); 136 "wickey@gmx.at");
137 aboutData->addCredit("Ian MacGregor", 137 aboutData->addCredit("Ian MacGregor",
138 I18N_NOOP( 138 I18N_NOOP(
139 "original documentation author.")); 139 "original documentation author."));
140} 140}
141#endif 141#endif
142 142
143int main(int argc, char *argv[]) 143int main(int argc, char *argv[])
144{ 144{
145 if(!getenv("QPEDIR")) putenv("QPEDIR=/usr/lib/kdepimpi");
145 printDebugConfigureInfo(); 146 printDebugConfigureInfo();
146#ifndef PWM_EMBEDDED 147#ifndef PWM_EMBEDDED
147 KAboutData aboutData(PACKAGE_NAME, PROG_NAME, 148 KAboutData aboutData(PACKAGE_NAME, PROG_NAME,
148 PACKAGE_VER, description, KAboutData::License_File, 149 PACKAGE_VER, description, KAboutData::License_File,
149 "(c) 2003, 2004 Michael Buesch and the PwManager Team", 0, 150 "(c) 2003, 2004 Michael Buesch and the PwManager Team", 0,
150 "http://passwordmanager.sourceforge.net/", 151 "http://passwordmanager.sourceforge.net/",
151 "mbuesch@freenet.de"); 152 "mbuesch@freenet.de");
152 addAuthors(&aboutData); 153 addAuthors(&aboutData);
153 154
154 KCmdLineArgs::init(argc, argv, &aboutData); 155 KCmdLineArgs::init(argc, argv, &aboutData);
155 KCmdLineArgs::addCmdLineOptions(options); 156 KCmdLineArgs::addCmdLineOptions(options);
156 157
157 KUniqueApplication::addCmdLineOptions(); 158 KUniqueApplication::addCmdLineOptions();
158 if (!KUniqueApplication::start()) { 159 if (!KUniqueApplication::start()) {
159 printInfo("already running."); 160 printInfo("already running.");
160 return EXIT_SUCCESS; 161 return EXIT_SUCCESS;
161 } 162 }
162 PwMApplication a; 163 PwMApplication a;
163 aboutData.setLicenseTextFile(LICENSE_FILE); 164 aboutData.setLicenseTextFile(LICENSE_FILE);
164 return a.exec(); 165 return a.exec();
165#else 166#else
166 167
167 bool exitHelp = false; 168 bool exitHelp = false;
168 if ( argc > 1 ) { 169 if ( argc > 1 ) {
169 QString command = argv[1]; 170 QString command = argv[1];
170 if ( command == "-help" ){ 171 if ( command == "-help" ){
171 printf("PWM/PI command line commands:\n"); 172 printf("PWM/PI command line commands:\n");
172 printf(" no command: Start PWM/PI in usual way\n"); 173 printf(" no command: Start PWM/PI in usual way\n");
173 printf(" -help: This output\n"); 174 printf(" -help: This output\n");
174 printf(" PWM/PI is exiting now. Bye!\n"); 175 printf(" PWM/PI is exiting now. Bye!\n");
175 exitHelp = true; 176 exitHelp = true;
176 } 177 }
177 } 178 }
178 if ( ! exitHelp ) { 179 if ( ! exitHelp ) {
179 180
180 PwMApplication a(argc, argv); 181 PwMApplication a(argc, argv);
181 182
182 KGlobal::setAppName( "pwmanager" ); 183 KGlobal::setAppName( "pwmanager" );
183#ifndef DESKTOP_VERSION 184#ifndef DESKTOP_VERSION
184 //qDebug("width %d ",QApplication::desktop()->width() ); 185 //qDebug("width %d ",QApplication::desktop()->width() );
185 if ( QApplication::desktop()->width() > 320 ) 186 if ( QApplication::desktop()->width() > 320 )
186 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons22/"); 187 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons22/");
187 else 188 else
188 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons16/"); 189 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons16/");
189#else 190#else
190 QString fileName ; 191 QString fileName ;
191 fileName = qApp->applicationDirPath () + "/kdepim/pwmanager/icons22/"; 192 fileName = qApp->applicationDirPath () + "/kdepim/pwmanager/icons22/";
192 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); 193 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName));
193 QApplication::addLibraryPath ( qApp->applicationDirPath () ); 194 QApplication::addLibraryPath ( qApp->applicationDirPath () );
194 195
195#endif 196#endif
196 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "pwmanager"))); 197 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "pwmanager")));
197 KPimGlobalPrefs::instance()->setGlobalConfig(); 198 KPimGlobalPrefs::instance()->setGlobalConfig();
198 QApplication::setFont( KPimGlobalPrefs::instance()->mApplicationFont ); 199 QApplication::setFont( KPimGlobalPrefs::instance()->mApplicationFont );
199 200
200 a.newInstance(); 201 a.newInstance();
201 202
202 //US KAddressBookMain m ; 203 //US KAddressBookMain m ;
203 204
204 //US QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 205 //US QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
205 /*US 206 /*US
206#ifndef DESKTOP_VERSION 207#ifndef DESKTOP_VERSION
207 a.showMainWidget( &m ); 208 a.showMainWidget( &m );
208#else 209#else
209 a.setMainWidget( &m ); 210 a.setMainWidget( &m );
210 m.resize (640, 480 ); 211 m.resize (640, 480 );
211 m.show(); 212 m.show();
212#endif 213#endif
213 */ 214 */
214 QObject::connect( &a, SIGNAL( lastWindowClosed()), &a, SLOT (quit())); 215 QObject::connect( &a, SIGNAL( lastWindowClosed()), &a, SLOT (quit()));
215 a.exec(); 216 a.exec();
216 dumpMissing(); 217 dumpMissing();
217 KPimGlobalPrefs::instance()->writeConfig(); 218 KPimGlobalPrefs::instance()->writeConfig();
218 } 219 }
219 qDebug("PWMPI: Bye! "); 220 qDebug("PWMPI: Bye! ");
220 221
221#endif 222#endif
222 223
223} 224}
diff --git a/pwmanager/pwmanager/printtext.h b/pwmanager/pwmanager/printtext.h
index 82e31b0..71bc2e0 100644
--- a/pwmanager/pwmanager/printtext.h
+++ b/pwmanager/pwmanager/printtext.h
@@ -1,68 +1,68 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2003 by Michael Buesch * 3 * copyright (C) 2003 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#ifndef PRINTTEXT_H 12#ifndef PRINTTEXT_H
13#define PRINTTEXT_H 13#define PRINTTEXT_H
14 14
15#include <kprinter.h> 15#include <kprinter.h>
16 16
17#include <qpainter.h> 17#include <qpainter.h>
18#include <qpaintdevicemetrics.h> 18#include <q3paintdevicemetrics.h>
19#include <qrect.h> 19#include <qrect.h>
20#include <qpoint.h> 20#include <qpoint.h>
21 21
22/** prints text "raw" to a printer */ 22/** prints text "raw" to a printer */
23class PrintText : public KPrinter 23class PrintText : public KPrinter
24{ 24{
25public: 25public:
26 PrintText(); 26 PrintText();
27 ~PrintText(); 27 ~PrintText();
28 28
29 /** begin printing. Call this before drawing to the device! */ 29 /** begin printing. Call this before drawing to the device! */
30 void beginPrint(); 30 void beginPrint();
31 /** prints a line */ 31 /** prints a line */
32 void printLine(QString t); 32 void printLine(QString t);
33 /** returns a pointer to the paint object */ 33 /** returns a pointer to the paint object */
34 QPainter* getPaint() 34 QPainter* getPaint()
35 { return paint; } 35 { return paint; }
36 /** sets the header-text */ 36 /** sets the header-text */
37 void setHeader(const QString &left, const QString &middle); 37 void setHeader(const QString &left, const QString &middle);
38 /** returns the header-text */ 38 /** returns the header-text */
39 void getHeader(QString *left, QString *middle); 39 void getHeader(QString *left, QString *middle);
40 40
41protected: 41protected:
42 /** painter object */ 42 /** painter object */
43 QPainter *paint; 43 QPainter *paint;
44 /** metrics */ 44 /** metrics */
45 QPaintDeviceMetrics *metrics; 45 Q3PaintDeviceMetrics *metrics;
46 /** left field of header */ 46 /** left field of header */
47 QString headerLeft; 47 QString headerLeft;
48 /** middle field of header */ 48 /** middle field of header */
49 QString headerMiddle; 49 QString headerMiddle;
50 /** right field of header */ 50 /** right field of header */
51 QString headerRight; 51 QString headerRight;
52 /** current Y-Position */ 52 /** current Y-Position */
53 int curYPos; 53 int curYPos;
54 /** text-body rectangle */ 54 /** text-body rectangle */
55 QRect body; 55 QRect body;
56 /** line-spacing */ 56 /** line-spacing */
57 int ls; 57 int ls;
58 /** top-left point for beginning printing */ 58 /** top-left point for beginning printing */
59 QPoint topLeft; 59 QPoint topLeft;
60 /** current page number */ 60 /** current page number */
61 int page; 61 int page;
62 62
63protected: 63protected:
64 /** prints the header on the page */ 64 /** prints the header on the page */
65 void printHeader(); 65 void printHeader();
66}; 66};
67 67
68#endif 68#endif
diff --git a/pwmanager/pwmanager/pwgenwnd_emb.cpp b/pwmanager/pwmanager/pwgenwnd_emb.cpp
index 429904c..21e0af4 100644
--- a/pwmanager/pwmanager/pwgenwnd_emb.cpp
+++ b/pwmanager/pwmanager/pwgenwnd_emb.cpp
@@ -1,134 +1,137 @@
1/* 1/*
2 This file is part of PwManager/Platform independent. 2 This file is part of PwManager/Platform independent.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22 22
23$Id$ 23$Id$
24*/ 24*/
25 25
26#include "pwgenwnd_emb.h" 26#include "pwgenwnd_emb.h"
27 27
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qgroupbox.h> 29#include <q3groupbox.h>
30#include <qcheckbox.h> 30#include <qcheckbox.h>
31#include <qlabel.h> 31#include <qlabel.h>
32#include <qlineedit.h> 32#include <qlineedit.h>
33#include <qspinbox.h> 33#include <qspinbox.h>
34#include <qlayout.h> 34#include <qlayout.h>
35//Added by qt3to4:
36#include <Q3HBoxLayout>
37#include <Q3VBoxLayout>
35 38
36#include "klocale.h" 39#include "klocale.h"
37 40
38/* 41/*
39 * Constructs a pwGenWnd as a child of 'parent', with the 42 * Constructs a pwGenWnd as a child of 'parent', with the
40 * name 'name'. 43 * name 'name'.
41 * 44 *
42 */ 45 */
43pwGenWnd::pwGenWnd( QWidget* parent, const char* name) 46pwGenWnd::pwGenWnd( QWidget* parent, const char* name)
44 : KDialogBase( KDialogBase::Plain, i18n( "Password generator" ), 47 : KDialogBase( KDialogBase::Plain, i18n( "Password generator" ),
45 KDialogBase::Ok | KDialogBase::Cancel, 48 KDialogBase::Ok | KDialogBase::Cancel,
46 KDialogBase::Ok, parent, name, true ) 49 KDialogBase::Ok, parent, name, true )
47{ 50{
48 QWidget *page = plainPage(); 51 QWidget *page = plainPage();
49 QVBoxLayout* pwGenWndLayout = new QVBoxLayout( page, 11, 6, "pwGenWndLayout"); 52 Q3VBoxLayout* pwGenWndLayout = new Q3VBoxLayout( page, 11, 6, "pwGenWndLayout");
50 53
51 QGroupBox* groupBox1 = new QGroupBox( page, "groupBox1" ); 54 Q3GroupBox* groupBox1 = new Q3GroupBox( page, "groupBox1" );
52 groupBox1->setTitle( i18n( "Character set:" ) ); 55 groupBox1->setTitle( i18n( "Character set:" ) );
53 groupBox1->setColumnLayout(0, Qt::Vertical ); 56 groupBox1->setColumnLayout(0, Qt::Vertical );
54 groupBox1->layout()->setSpacing( 6 ); 57 groupBox1->layout()->setSpacing( 6 );
55 groupBox1->layout()->setMargin( 11 ); 58 groupBox1->layout()->setMargin( 11 );
56 QVBoxLayout* groupBox1Layout = new QVBoxLayout( groupBox1->layout() ); 59 Q3VBoxLayout* groupBox1Layout = new Q3VBoxLayout( groupBox1->layout() );
57 groupBox1Layout->setAlignment( Qt::AlignTop ); 60 groupBox1Layout->setAlignment( Qt::AlignTop );
58 61
59 int_charLowerCheckBox = new QCheckBox( i18n("Lowercase (abc)"), groupBox1, "int_charLowerCheckBox" ); 62 int_charLowerCheckBox = new QCheckBox( i18n("Lowercase (abc)"), groupBox1, "int_charLowerCheckBox" );
60 int_charLowerCheckBox->setChecked( TRUE ); 63 int_charLowerCheckBox->setChecked( TRUE );
61 groupBox1Layout->addWidget( int_charLowerCheckBox ); 64 groupBox1Layout->addWidget( int_charLowerCheckBox );
62 65
63 int_charUpperCheckBox = new QCheckBox( i18n("Uppercase (ABC)"), groupBox1, "int_charUpperCheckBox" ); 66 int_charUpperCheckBox = new QCheckBox( i18n("Uppercase (ABC)"), groupBox1, "int_charUpperCheckBox" );
64 int_charUpperCheckBox->setChecked( TRUE ); 67 int_charUpperCheckBox->setChecked( TRUE );
65 groupBox1Layout->addWidget( int_charUpperCheckBox ); 68 groupBox1Layout->addWidget( int_charUpperCheckBox );
66 69
67 70
68 int_charNumCheckBox = new QCheckBox( i18n("Numbers (123)"), groupBox1, "int_charNumCheckBox" ); 71 int_charNumCheckBox = new QCheckBox( i18n("Numbers (123)"), groupBox1, "int_charNumCheckBox" );
69 int_charNumCheckBox->setChecked( TRUE ); 72 int_charNumCheckBox->setChecked( TRUE );
70 groupBox1Layout->addWidget( int_charNumCheckBox ); 73 groupBox1Layout->addWidget( int_charNumCheckBox );
71 74
72 int_charSpecCheckBox = new QCheckBox( i18n("Special characters:"), groupBox1, "int_charSpecCheckBox" ); 75 int_charSpecCheckBox = new QCheckBox( i18n("Special characters:"), groupBox1, "int_charSpecCheckBox" );
73 groupBox1Layout->addWidget( int_charSpecCheckBox ); 76 groupBox1Layout->addWidget( int_charSpecCheckBox );
74 77
75 QLabel* textLabel7 = new QLabel( groupBox1, "textLabel7" ); 78 QLabel* textLabel7 = new QLabel( groupBox1, "textLabel7" );
76 QString st("\x21\x22\xc2\xa7\x24\x25\x26\x2f\x28\x29\x3d\x3f\x2c\x2e\x2d\x3b\x3a\x5f\x2b"); 79 QString st("\x21\x22\xc2\xa7\x24\x25\x26\x2f\x28\x29\x3d\x3f\x2c\x2e\x2d\x3b\x3a\x5f\x2b");
77 textLabel7->setText( st.utf8() ); 80 textLabel7->setText( st.utf8() );
78 groupBox1Layout->addWidget( textLabel7 ); 81 groupBox1Layout->addWidget( textLabel7 );
79 82
80 int_charBlankCheckBox = new QCheckBox( i18n( "Spaces (blank characters)"), groupBox1, "int_charBlankCheckBox" ); 83 int_charBlankCheckBox = new QCheckBox( i18n( "Spaces (blank characters)"), groupBox1, "int_charBlankCheckBox" );
81 groupBox1Layout->addWidget( int_charBlankCheckBox ); 84 groupBox1Layout->addWidget( int_charBlankCheckBox );
82 85
83 QHBoxLayout* layout7 = new QHBoxLayout( 0, 0, 6, "layout7"); 86 Q3HBoxLayout* layout7 = new Q3HBoxLayout( 0, 0, 6, "layout7");
84 87
85 int_charUserCheckBox = new QCheckBox( i18n("User defined:"), groupBox1, "int_charUserCheckBox" ); 88 int_charUserCheckBox = new QCheckBox( i18n("User defined:"), groupBox1, "int_charUserCheckBox" );
86 layout7->addWidget( int_charUserCheckBox ); 89 layout7->addWidget( int_charUserCheckBox );
87 90
88 int_userDefLineEdit = new QLineEdit( groupBox1, "int_userDefLineEdit" ); 91 int_userDefLineEdit = new QLineEdit( groupBox1, "int_userDefLineEdit" );
89 int_userDefLineEdit->setEnabled( FALSE ); 92 int_userDefLineEdit->setEnabled( FALSE );
90 layout7->addWidget( int_userDefLineEdit ); 93 layout7->addWidget( int_userDefLineEdit );
91 groupBox1Layout->addLayout( layout7 ); 94 groupBox1Layout->addLayout( layout7 );
92 pwGenWndLayout->addWidget( groupBox1 ); 95 pwGenWndLayout->addWidget( groupBox1 );
93 96
94 97
95 QHBoxLayout* layout8 = new QHBoxLayout( 0, 0, 6, "layout8"); 98 Q3HBoxLayout* layout8 = new Q3HBoxLayout( 0, 0, 6, "layout8");
96 99
97 int_lenSpinBox = new QSpinBox( page, "int_lenSpinBox" ); 100 int_lenSpinBox = new QSpinBox( page, "int_lenSpinBox" );
98 QLabel* textLabel2 = new QLabel( int_lenSpinBox, i18n("Password Length:"), page, "textLabel2" ); 101 QLabel* textLabel2 = new QLabel( int_lenSpinBox, i18n("Password Length:"), page, "textLabel2" );
99 layout8->addWidget( textLabel2 ); 102 layout8->addWidget( textLabel2 );
100 103
101 int_lenSpinBox->setMaxValue( 9999 ); 104 int_lenSpinBox->setMaxValue( 9999 );
102 int_lenSpinBox->setMinValue( 1 ); 105 int_lenSpinBox->setMinValue( 1 );
103 int_lenSpinBox->setValue( 8 ); 106 int_lenSpinBox->setValue( 8 );
104 layout8->addWidget( int_lenSpinBox ); 107 layout8->addWidget( int_lenSpinBox );
105 pwGenWndLayout->addLayout( layout8 ); 108 pwGenWndLayout->addLayout( layout8 );
106 109
107 int_filterCheckBox = new QCheckBox( i18n( "Enable Filtering to get better passwords" ), page, "int_filterCheckBox" ); 110 int_filterCheckBox = new QCheckBox( i18n( "Enable Filtering to get better passwords" ), page, "int_filterCheckBox" );
108 int_filterCheckBox->setChecked( TRUE ); 111 int_filterCheckBox->setChecked( TRUE );
109 pwGenWndLayout->addWidget( int_filterCheckBox ); 112 pwGenWndLayout->addWidget( int_filterCheckBox );
110 113
111 setButtonText( KDialogBase::Ok, "&Generate now" ); 114 setButtonText( KDialogBase::Ok, "&Generate now" );
112 115
113 // signals and slots connections 116 // signals and slots connections
114 connect( int_charUserCheckBox, SIGNAL( toggled(bool) ), int_userDefLineEdit, SLOT( setEnabled(bool) ) ); 117 connect( int_charUserCheckBox, SIGNAL( toggled(bool) ), int_userDefLineEdit, SLOT( setEnabled(bool) ) );
115} 118}
116 119
117/* 120/*
118 * Destroys the object and frees any allocated resources 121 * Destroys the object and frees any allocated resources
119 */ 122 */
120pwGenWnd::~pwGenWnd() 123pwGenWnd::~pwGenWnd()
121{ 124{
122 // no need to delete child widgets, Qt does it all for us 125 // no need to delete child widgets, Qt does it all for us
123} 126}
124 127
125void pwGenWnd::cancelButton_slot() 128void pwGenWnd::cancelButton_slot()
126{ 129{
127 qWarning( "pwGenWnd::cancelButton_slot(): Not implemented yet" ); 130 qWarning( "pwGenWnd::cancelButton_slot(): Not implemented yet" );
128} 131}
129 132
130void pwGenWnd::genButton_slot() 133void pwGenWnd::genButton_slot()
131{ 134{
132 qWarning( "pwGenWnd::genButton_slot(): Not implemented yet" ); 135 qWarning( "pwGenWnd::genButton_slot(): Not implemented yet" );
133} 136}
134 137
diff --git a/pwmanager/pwmanager/pwgenwndimpl.cpp b/pwmanager/pwmanager/pwgenwndimpl.cpp
index 5313060..0eb7043 100644
--- a/pwmanager/pwmanager/pwgenwndimpl.cpp
+++ b/pwmanager/pwmanager/pwgenwndimpl.cpp
@@ -1,137 +1,137 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 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 "pwgenwndimpl.h" 20#include "pwgenwndimpl.h"
21#include "pwmexception.h" 21#include "pwmexception.h"
22#include "genpasswd.h" 22#include "genpasswd.h"
23 23
24#include <qtabwidget.h> 24#include <qtabwidget.h>
25#include <qspinbox.h> 25#include <qspinbox.h>
26#include <qcheckbox.h> 26#include <qcheckbox.h>
27#include <qlineedit.h> 27#include <qlineedit.h>
28 28
29#include <klocale.h> 29#include <klocale.h>
30#include <kmessagebox.h> 30#include <kmessagebox.h>
31 31
32 32
33#ifndef PWM_EMBEDDED 33#ifndef PWM_EMBEDDED
34PwGenWndImpl::PwGenWndImpl(QWidget *parent, 34PwGenWndImpl::PwGenWndImpl(QWidget *parent,
35 const char *name, 35 const char *name,
36 bool modal, 36 bool modal,
37 WFlags fl) 37 Qt::WFlags fl)
38 : pwGenWnd(parent, name, modal, fl) 38 : pwGenWnd(parent, name, modal, fl)
39{ 39{
40} 40}
41 41
42#else 42#else
43PwGenWndImpl::PwGenWndImpl( QWidget* parent, const char* name) 43PwGenWndImpl::PwGenWndImpl( QWidget* parent, const char* name)
44 : pwGenWnd( parent, name) 44 : pwGenWnd( parent, name)
45{ 45{
46} 46}
47#endif 47#endif
48 48
49PwGenWndImpl::~PwGenWndImpl() 49PwGenWndImpl::~PwGenWndImpl()
50{ 50{
51} 51}
52 52
53#ifdef PWM_EMBEDDED 53#ifdef PWM_EMBEDDED
54void PwGenWndImpl::slotOk() 54void PwGenWndImpl::slotOk()
55{ 55{
56 // internal generator 56 // internal generator
57 if (!optionsSanityIntGen()) 57 if (!optionsSanityIntGen())
58 return; 58 return;
59 if (!startIntGen()) 59 if (!startIntGen())
60 return; 60 return;
61 61
62 KDialogBase::slotOk(); 62 KDialogBase::slotOk();
63} 63}
64#endif 64#endif
65 65
66void PwGenWndImpl::genButton_slot() 66void PwGenWndImpl::genButton_slot()
67{ 67{
68#ifndef PWM_EMBEDDED 68#ifndef PWM_EMBEDDED
69 // internal generator 69 // internal generator
70 if (!optionsSanityIntGen()) 70 if (!optionsSanityIntGen())
71 return; 71 return;
72 if (startIntGen()) 72 if (startIntGen())
73 goto exit_success; 73 goto exit_success;
74 done(0); 74 done(0);
75exit_success: 75exit_success:
76 done(1); 76 done(1);
77#endif 77#endif
78} 78}
79 79
80void PwGenWndImpl::cancelButton_slot() 80void PwGenWndImpl::cancelButton_slot()
81{ 81{
82#ifndef PWM_EMBEDDED 82#ifndef PWM_EMBEDDED
83 done(0); 83 done(0);
84#endif 84#endif
85} 85}
86 86
87bool PwGenWndImpl::optionsSanityIntGen() 87bool PwGenWndImpl::optionsSanityIntGen()
88{ 88{
89 if (int_charLowerCheckBox->isChecked()) 89 if (int_charLowerCheckBox->isChecked())
90 return true; 90 return true;
91 if (int_charUpperCheckBox->isChecked()) 91 if (int_charUpperCheckBox->isChecked())
92 return true; 92 return true;
93 if (int_charNumCheckBox->isChecked()) 93 if (int_charNumCheckBox->isChecked())
94 return true; 94 return true;
95 if (int_charSpecCheckBox->isChecked()) 95 if (int_charSpecCheckBox->isChecked())
96 return true; 96 return true;
97 if (int_charUserCheckBox->isChecked()) { 97 if (int_charUserCheckBox->isChecked()) {
98 if (int_userDefLineEdit->text().length() >= 2) 98 if (int_userDefLineEdit->text().length() >= 2)
99 return true; 99 return true;
100 if (int_charBlankCheckBox->isChecked()) 100 if (int_charBlankCheckBox->isChecked())
101 return true; 101 return true;
102 } 102 }
103 KMessageBox::error(this, 103 KMessageBox::error(this,
104 i18n("Incorrect Charset selection!\n" 104 i18n("Incorrect Charset selection!\n"
105 "It's impossible to generate a sane " 105 "It's impossible to generate a sane "
106 "password with the selected charset(s).\n" 106 "password with the selected charset(s).\n"
107 "Please select more charsets."), 107 "Please select more charsets."),
108 i18n("Incorrect Charset selection")); 108 i18n("Incorrect Charset selection"));
109 return false; 109 return false;
110} 110}
111 111
112bool PwGenWndImpl::startIntGen() 112bool PwGenWndImpl::startIntGen()
113{ 113{
114 GenPasswd gen; 114 GenPasswd gen;
115 gen.setLen(int_lenSpinBox->value()); 115 gen.setLen(int_lenSpinBox->value());
116 gen.setUseFilter(int_filterCheckBox->isChecked()); 116 gen.setUseFilter(int_filterCheckBox->isChecked());
117 gen.setCharset(int_charLowerCheckBox->isChecked(), 117 gen.setCharset(int_charLowerCheckBox->isChecked(),
118 int_charUpperCheckBox->isChecked(), 118 int_charUpperCheckBox->isChecked(),
119 int_charNumCheckBox->isChecked(), 119 int_charNumCheckBox->isChecked(),
120 int_charSpecCheckBox->isChecked(), 120 int_charSpecCheckBox->isChecked(),
121 int_charBlankCheckBox->isChecked(), 121 int_charBlankCheckBox->isChecked(),
122 int_charUserCheckBox->isChecked() ? 122 int_charUserCheckBox->isChecked() ?
123 int_userDefLineEdit->text() : 123 int_userDefLineEdit->text() :
124 QString::null); 124 QString::null);
125 QString pw(gen.gen()); 125 QString pw(gen.gen());
126 if (pw.isEmpty()) 126 if (pw.isEmpty())
127 return false; 127 return false;
128 password = pw; 128 password = pw;
129 return true; 129 return true;
130} 130}
131 131
132QString PwGenWndImpl::getPassword() 132QString PwGenWndImpl::getPassword()
133{ 133{
134 QString ret(password); 134 QString ret(password);
135 password = QString::null; 135 password = QString::null;
136 return ret; 136 return ret;
137} 137}
diff --git a/pwmanager/pwmanager/pwgenwndimpl.h b/pwmanager/pwmanager/pwgenwndimpl.h
index 994ff2f..1e706a1 100644
--- a/pwmanager/pwmanager/pwgenwndimpl.h
+++ b/pwmanager/pwmanager/pwgenwndimpl.h
@@ -1,66 +1,66 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 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 __PWGENWNDIMPL_H 20#ifndef __PWGENWNDIMPL_H
21#define __PWGENWNDIMPL_H 21#define __PWGENWNDIMPL_H
22 22
23#ifndef PWM_EMBEDDED 23#ifndef PWM_EMBEDDED
24#include "pwgenwnd.h" 24#include "pwgenwnd.h"
25#else 25#else
26#include "pwgenwnd_emb.h" 26#include "pwgenwnd_emb.h"
27#endif 27#endif
28 28
29class PwGenWndImpl : public pwGenWnd 29class PwGenWndImpl : public pwGenWnd
30{ 30{
31public: 31public:
32#ifndef PWM_EMBEDDED 32#ifndef PWM_EMBEDDED
33 PwGenWndImpl(QWidget *parent = 0, 33 PwGenWndImpl(QWidget *parent = 0,
34 const char *name = 0, 34 const char *name = 0,
35 bool modal = FALSE, 35 bool modal = FALSE,
36 WFlags fl = 0); 36 Qt::WFlags fl = 0);
37#else 37#else
38 PwGenWndImpl( QWidget* parent = 0, const char* name = 0); 38 PwGenWndImpl( QWidget* parent = 0, const char* name = 0);
39#endif 39#endif
40 40
41 ~PwGenWndImpl(); 41 ~PwGenWndImpl();
42 42
43 /** returns the generated password */ 43 /** returns the generated password */
44 QString getPassword(); 44 QString getPassword();
45 45
46protected slots: 46protected slots:
47 /** generate button pressed */ 47 /** generate button pressed */
48 void genButton_slot(); 48 void genButton_slot();
49#ifdef PWM_EMBEDDED 49#ifdef PWM_EMBEDDED
50 virtual void slotOk(); 50 virtual void slotOk();
51#endif 51#endif
52 /** cancel button pressed */ 52 /** cancel button pressed */
53 void cancelButton_slot(); 53 void cancelButton_slot();
54 54
55protected: 55protected:
56 /** start the internal generator */ 56 /** start the internal generator */
57 bool startIntGen(); 57 bool startIntGen();
58 /** check all options of the internal generator */ 58 /** check all options of the internal generator */
59 bool optionsSanityIntGen(); 59 bool optionsSanityIntGen();
60 60
61protected: 61protected:
62 /** the generated password */ 62 /** the generated password */
63 QString password; 63 QString password;
64}; 64};
65 65
66#endif // __PWGENWNDIMPL_H 66#endif // __PWGENWNDIMPL_H
diff --git a/pwmanager/pwmanager/pwm.cpp b/pwmanager/pwmanager/pwm.cpp
index 8373850..694fb13 100644
--- a/pwmanager/pwmanager/pwm.cpp
+++ b/pwmanager/pwmanager/pwm.cpp
@@ -1,1599 +1,1605 @@
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#include <QDesktopWidget>
29//Added by qt3to4:
30#include <Q3ValueList>
31#include <QHideEvent>
32#include <QFocusEvent>
33#include <QCloseEvent>
28 34
29#ifndef PWM_EMBEDDED 35#ifndef PWM_EMBEDDED
30#include <kmenubar.h> 36#include <kmenubar.h>
31#include <kstatusbar.h> 37#include <kstatusbar.h>
32#include <dcopclient.h> 38#include <dcopclient.h>
33#include "configwndimpl.h" 39#include "configwndimpl.h"
34#include "configuration.h" 40#include "configuration.h"
35#else 41#else
36#include <qmenubar.h> 42#include <qmenubar.h>
37#include <qmessagebox.h> 43#include <qmessagebox.h>
38#include <pwmprefs.h> 44#include <pwmprefs.h>
39#include <kpimglobalprefs.h> 45#include <kpimglobalprefs.h>
40#include <kprefsdialog.h> 46#include <kprefsdialog.h>
41#include <kcmconfigs/kcmpwmconfig.h> 47#include <kcmconfigs/kcmpwmconfig.h>
42#include <kcmconfigs/kcmkdepimconfig.h> 48#include <kcmconfigs/kcmkdepimconfig.h>
43#include <kcmultidialog.h> 49#include <kcmultidialog.h>
44#include "editcategory.h" 50#include "editcategory.h"
45#endif 51#endif
46 52
47 53
48#ifndef DESKTOP_VERSION 54#ifndef DESKTOP_VERSION
49#include <qpe/global.h> 55#include <qpe/global.h>
50#endif 56#endif
51 57
52#include <qpixmap.h> 58#include <qpixmap.h>
53#include <qcheckbox.h> 59#include <qcheckbox.h>
54#include <qspinbox.h> 60#include <qspinbox.h>
55#include <qlineedit.h> 61#include <qlineedit.h>
56#include <qfileinfo.h> 62#include <qfileinfo.h>
57#include <qclipboard.h> 63#include <qclipboard.h>
58 64
59 65
60#include <stdio.h> 66#include <stdio.h>
61 67
62#include "pwm.h" 68#include "pwm.h"
63#include "pwminit.h" 69#include "pwminit.h"
64#include "pwmprint.h" 70#include "pwmprint.h"
65#include "addentrywndimpl.h" 71#include "addentrywndimpl.h"
66#include "globalstuff.h" 72#include "globalstuff.h"
67#include "findwndimpl.h" 73#include "findwndimpl.h"
68#include "csv.h" 74#include "csv.h"
69 75
70#ifdef CONFIG_KWALLETIF 76#ifdef CONFIG_KWALLETIF
71# include "kwalletif.h" 77# include "kwalletif.h"
72# include "kwalletemu.h" 78# include "kwalletemu.h"
73#endif 79#endif
74#ifdef CONFIG_KEYCARD 80#ifdef CONFIG_KEYCARD
75# include "pwmkeycard.h" 81# include "pwmkeycard.h"
76#endif 82#endif
77 83
78 #define DEFAULT_SIZE (QSize(700, 400)) 84 #define DEFAULT_SIZE (QSize(700, 400))
79 85
80// Button IDs for "file" popup menu 86// Button IDs for "file" popup menu
81enum { 87enum {
82 BUTTON_POPUP_FILE_NEW = 0, 88 BUTTON_POPUP_FILE_NEW = 0,
83 BUTTON_POPUP_FILE_OPEN, 89 BUTTON_POPUP_FILE_OPEN,
84 BUTTON_POPUP_FILE_CLOSE, 90 BUTTON_POPUP_FILE_CLOSE,
85 BUTTON_POPUP_FILE_SAVE, 91 BUTTON_POPUP_FILE_SAVE,
86 BUTTON_POPUP_FILE_SAVEAS, 92 BUTTON_POPUP_FILE_SAVEAS,
87 BUTTON_POPUP_FILE_EXPORT, 93 BUTTON_POPUP_FILE_EXPORT,
88 BUTTON_POPUP_FILE_IMPORT, 94 BUTTON_POPUP_FILE_IMPORT,
89 BUTTON_POPUP_FILE_PRINT, 95 BUTTON_POPUP_FILE_PRINT,
90 BUTTON_POPUP_FILE_QUIT 96 BUTTON_POPUP_FILE_QUIT
91}; 97};
92// Button IDs for "manage" popup menu 98// Button IDs for "manage" popup menu
93enum { 99enum {
94 BUTTON_POPUP_MANAGE_ADD = 0, 100 BUTTON_POPUP_MANAGE_ADD = 0,
95 BUTTON_POPUP_MANAGE_EDIT, 101 BUTTON_POPUP_MANAGE_EDIT,
96 BUTTON_POPUP_MANAGE_DEL, 102 BUTTON_POPUP_MANAGE_DEL,
97 BUTTON_POPUP_MANAGE_CHANGEMP 103 BUTTON_POPUP_MANAGE_CHANGEMP
98}; 104};
99// Button IDs for chipcard popup menu 105// Button IDs for chipcard popup menu
100enum { 106enum {
101#ifdef CONFIG_KEYCARD 107#ifdef CONFIG_KEYCARD
102 BUTTON_POPUP_CHIPCARD_GENNEW = 0, 108 BUTTON_POPUP_CHIPCARD_GENNEW = 0,
103 BUTTON_POPUP_CHIPCARD_DEL, 109 BUTTON_POPUP_CHIPCARD_DEL,
104 BUTTON_POPUP_CHIPCARD_READID, 110 BUTTON_POPUP_CHIPCARD_READID,
105 BUTTON_POPUP_CHIPCARD_SAVEBACKUP, 111 BUTTON_POPUP_CHIPCARD_SAVEBACKUP,
106 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP 112 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP
107#else // CONFIG_KEYCARD 113#else // CONFIG_KEYCARD
108 BUTTON_POPUP_CHIPCARD_NO = 0 114 BUTTON_POPUP_CHIPCARD_NO = 0
109#endif // CONFIG_KEYCARD 115#endif // CONFIG_KEYCARD
110}; 116};
111// Button IDs for "view" popup menu 117// Button IDs for "view" popup menu
112enum { 118enum {
113 BUTTON_POPUP_VIEW_FIND = 0, 119 BUTTON_POPUP_VIEW_FIND = 0,
114 BUTTON_POPUP_VIEW_LOCK, 120 BUTTON_POPUP_VIEW_LOCK,
115 BUTTON_POPUP_VIEW_DEEPLOCK, 121 BUTTON_POPUP_VIEW_DEEPLOCK,
116 BUTTON_POPUP_VIEW_UNLOCK 122 BUTTON_POPUP_VIEW_UNLOCK
117}; 123};
118// Button IDs for "options" popup menu 124// Button IDs for "options" popup menu
119enum { 125enum {
120 BUTTON_POPUP_OPTIONS_CONFIG = 0, 126 BUTTON_POPUP_OPTIONS_CONFIG = 0,
121 BUTTON_POPUP_OPTIONS_GLOBAL_CONFIG 127 BUTTON_POPUP_OPTIONS_GLOBAL_CONFIG
122#ifdef PWM_EMBEDDED 128#ifdef PWM_EMBEDDED
123 ,BUTTON_POPUP_OPTIONS_CATEGORY 129 ,BUTTON_POPUP_OPTIONS_CATEGORY
124#endif 130#endif
125}; 131};
126// Button IDs for "export" popup menu (in "file" popup menu) 132// Button IDs for "export" popup menu (in "file" popup menu)
127enum { 133enum {
128 BUTTON_POPUP_EXPORT_TEXT = 0, 134 BUTTON_POPUP_EXPORT_TEXT = 0,
129 BUTTON_POPUP_EXPORT_GPASMAN, 135 BUTTON_POPUP_EXPORT_GPASMAN,
130 BUTTON_POPUP_EXPORT_CSV 136 BUTTON_POPUP_EXPORT_CSV
131#ifdef CONFIG_KWALLETIF 137#ifdef CONFIG_KWALLETIF
132 ,BUTTON_POPUP_EXPORT_KWALLET 138 ,BUTTON_POPUP_EXPORT_KWALLET
133#endif 139#endif
134}; 140};
135// Button IDs for "import" popup menu (in "file" popup menu) 141// Button IDs for "import" popup menu (in "file" popup menu)
136enum { 142enum {
137 BUTTON_POPUP_IMPORT_TEXT = 0, 143 BUTTON_POPUP_IMPORT_TEXT = 0,
138 BUTTON_POPUP_IMPORT_GPASMAN, 144 BUTTON_POPUP_IMPORT_GPASMAN,
139 BUTTON_POPUP_IMPORT_CSV 145 BUTTON_POPUP_IMPORT_CSV
140#ifdef CONFIG_KWALLETIF 146#ifdef CONFIG_KWALLETIF
141 ,BUTTON_POPUP_IMPORT_KWALLET 147 ,BUTTON_POPUP_IMPORT_KWALLET
142#endif 148#endif
143}; 149};
144 150
145#ifdef PWM_EMBEDDED 151#ifdef PWM_EMBEDDED
146// Button IDs for "help" popup menu 152// Button IDs for "help" popup menu
147enum { 153enum {
148 BUTTON_POPUP_HELP_LICENSE = 0, 154 BUTTON_POPUP_HELP_LICENSE = 0,
149 BUTTON_POPUP_HELP_FAQ, 155 BUTTON_POPUP_HELP_FAQ,
150 BUTTON_POPUP_HELP_ABOUT, 156 BUTTON_POPUP_HELP_ABOUT,
151 BUTTON_POPUP_HELP_SYNC, 157 BUTTON_POPUP_HELP_SYNC,
152 BUTTON_POPUP_HELP_WHATSNEW 158 BUTTON_POPUP_HELP_WHATSNEW
153}; 159};
154#endif 160#endif
155 161
156// Button IDs for toolbar 162// Button IDs for toolbar
157enum { 163enum {
158 BUTTON_TOOL_NEW = 0, 164 BUTTON_TOOL_NEW = 0,
159 BUTTON_TOOL_OPEN, 165 BUTTON_TOOL_OPEN,
160 BUTTON_TOOL_SAVE, 166 BUTTON_TOOL_SAVE,
161 BUTTON_TOOL_SAVEAS, 167 BUTTON_TOOL_SAVEAS,
162 BUTTON_TOOL_PRINT, 168 BUTTON_TOOL_PRINT,
163 BUTTON_TOOL_ADD, 169 BUTTON_TOOL_ADD,
164 BUTTON_TOOL_EDIT, 170 BUTTON_TOOL_EDIT,
165 BUTTON_TOOL_DEL, 171 BUTTON_TOOL_DEL,
166 BUTTON_TOOL_FIND, 172 BUTTON_TOOL_FIND,
167 BUTTON_TOOL_LOCK, 173 BUTTON_TOOL_LOCK,
168 BUTTON_TOOL_DEEPLOCK, 174 BUTTON_TOOL_DEEPLOCK,
169 BUTTON_TOOL_UNLOCK 175 BUTTON_TOOL_UNLOCK
170}; 176};
171 177
172 178
173PwM::PwM(PwMInit *_init, PwMDoc *doc, 179PwM::PwM(PwMInit *_init, PwMDoc *doc,
174 bool virginity, 180 bool virginity,
175 QWidget *parent, const char *name) 181 QWidget *parent, const char *name)
176 : KMainWindow(parent, "HALLO") 182 : KMainWindow(parent, "HALLO")
177 , forceQuit (false) 183 , forceQuit (false)
178 , forceMinimizeToTray (false) 184 , forceMinimizeToTray (false)
179{ 185{
180 syncManager = 0; 186 syncManager = 0;
181 virgin = !virginity; 187 virgin = !virginity;
182 init = _init; 188 init = _init;
183 connect(doc, SIGNAL(docClosed(PwMDoc *)), 189 connect(doc, SIGNAL(docClosed(PwMDoc *)),
184 this, SLOT(docClosed(PwMDoc *))); 190 this, SLOT(docClosed(PwMDoc *)));
185 initMenubar(); 191 initMenubar();
186 initToolbar(); 192 initToolbar();
187 initMetrics(); 193 initMetrics();
188 setVirgin(virginity); 194 setVirgin(virginity);
189 setFocusPolicy(QWidget::WheelFocus); 195 setFocusPolicy(Qt::WheelFocus);
190#ifndef PWM_EMBEDDED 196#ifndef PWM_EMBEDDED
191 statusBar()->show(); 197 statusBar()->show();
192#endif 198#endif
193 view = makeNewListView(doc); 199 view = makeNewListView(doc);
194 setCentralWidget(view); 200 setCentralWidget(view);
195 updateCaption(); 201 updateCaption();
196 showStatMsg(i18n("Ready.")); 202 showStatMsg(i18n("Ready."));
197} 203}
198 204
199PwM::~PwM() 205PwM::~PwM()
200{ 206{
201 //qDebug("PwM::~PwM() %x", this); 207 //qDebug("PwM::~PwM() %x", this);
202 disconnect(curDoc(), SIGNAL(docClosed(PwMDoc *)), 208 disconnect(curDoc(), SIGNAL(docClosed(PwMDoc *)),
203 this, SLOT(docClosed(PwMDoc *))); 209 this, SLOT(docClosed(PwMDoc *)));
204 conf()->confWndMainWndSize(size()); 210 conf()->confWndMainWndSize(size());
205 //LR closing of windows changed 211 //LR closing of windows changed
206 //needed for fastload option on PDA 212 //needed for fastload option on PDA
207 //emit closed(this); 213 //emit closed(this);
208 //qDebug("PwM::~PwM() emited closed(this)"); 214 //qDebug("PwM::~PwM() emited closed(this)");
209 delete view; 215 delete view;
210 delete syncManager; 216 delete syncManager;
211} 217}
212 218
213void PwM::initMenubar() 219void PwM::initMenubar()
214{ 220{
215 KIconLoader* picons; 221 KIconLoader* picons;
216#ifndef PWM_EMBEDDED 222#ifndef PWM_EMBEDDED
217 KIconLoader icons; 223 KIconLoader icons;
218 picons = &icons; 224 picons = &icons;
219#else 225#else
220 picons = KGlobal::iconLoader(); 226 picons = KGlobal::iconLoader();
221 227
222 228
223 syncPopup = new KPopupMenu(this); 229 syncPopup = new KPopupMenu(this);
224 230
225 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::PWMPI, PWMPrefs::instance(), syncPopup); 231 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::PWMPI, PWMPrefs::instance(), syncPopup);
226 syncManager->setBlockSave(false); 232 syncManager->setBlockSave(false);
227 233
228 connect ( syncPopup, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 234 connect ( syncPopup, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
229 syncManager->fillSyncMenu(); 235 syncManager->fillSyncMenu();
230 236
231#endif 237#endif
232 filePopup = new KPopupMenu(this); 238 filePopup = new KPopupMenu(this);
233 importPopup = new KPopupMenu(filePopup); 239 importPopup = new KPopupMenu(filePopup);
234 exportPopup = new KPopupMenu(filePopup); 240 exportPopup = new KPopupMenu(filePopup);
235 managePopup = new KPopupMenu(this); 241 managePopup = new KPopupMenu(this);
236#ifdef CONFIG_KEYCARD 242#ifdef CONFIG_KEYCARD
237 chipcardPopup = new KPopupMenu(this); 243 chipcardPopup = new KPopupMenu(this);
238#endif // CONFIG_KEYCARD 244#endif // CONFIG_KEYCARD
239 viewPopup = new KPopupMenu(this); 245 viewPopup = new KPopupMenu(this);
240 optionsPopup = new KPopupMenu(this); 246 optionsPopup = new KPopupMenu(this);
241 247
242// "file" popup menu 248// "file" popup menu
243 filePopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), 249 filePopup->insertItem(QIcon(picons->loadIcon("filenew", KIcon::Small)),
244 i18n("&New"), this, 250 i18n("&New"), this,
245 SLOT(new_slot()), 0, BUTTON_POPUP_FILE_NEW); 251 SLOT(new_slot()), 0, BUTTON_POPUP_FILE_NEW);
246 filePopup->insertItem(QIconSet(picons->loadIcon("fileopen", KIcon::Small)), 252 filePopup->insertItem(QIcon(picons->loadIcon("fileopen", KIcon::Small)),
247 i18n("&Open"), this, 253 i18n("&Open"), this,
248 SLOT(open_slot()), 0, BUTTON_POPUP_FILE_OPEN); 254 SLOT(open_slot()), 0, BUTTON_POPUP_FILE_OPEN);
249 filePopup->insertItem(QIconSet(picons->loadIcon("fileclose", KIcon::Small)), 255 filePopup->insertItem(QIcon(picons->loadIcon("fileclose", KIcon::Small)),
250 i18n("&Close"), this, 256 i18n("&Close"), this,
251 SLOT(close_slot()), 0, BUTTON_POPUP_FILE_CLOSE); 257 SLOT(close_slot()), 0, BUTTON_POPUP_FILE_CLOSE);
252 filePopup->insertSeparator(); 258 filePopup->insertSeparator();
253 filePopup->insertItem(QIconSet(picons->loadIcon("filesave", KIcon::Small)), 259 filePopup->insertItem(QIcon(picons->loadIcon("filesave", KIcon::Small)),
254 i18n("&Save"), this, 260 i18n("&Save"), this,
255 SLOT(save_slot()), 0, BUTTON_POPUP_FILE_SAVE); 261 SLOT(save_slot()), 0, BUTTON_POPUP_FILE_SAVE);
256 filePopup->insertItem(QIconSet(picons->loadIcon("filesaveas", KIcon::Small)), 262 filePopup->insertItem(QIcon(picons->loadIcon("filesaveas", KIcon::Small)),
257 i18n("Save &as..."), 263 i18n("Save &as..."),
258 this, SLOT(saveAs_slot()), 0, 264 this, SLOT(saveAs_slot()), 0,
259 BUTTON_POPUP_FILE_SAVEAS); 265 BUTTON_POPUP_FILE_SAVEAS);
260 filePopup->insertSeparator(); 266 filePopup->insertSeparator();
261 // "file/export" popup menu 267 // "file/export" popup menu
262 exportPopup->insertItem(i18n("&Text-file..."), this, 268 exportPopup->insertItem(i18n("&Text-file..."), this,
263 SLOT(exportToText()), 0, BUTTON_POPUP_EXPORT_TEXT); 269 SLOT(exportToText()), 0, BUTTON_POPUP_EXPORT_TEXT);
264 exportPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, 270 exportPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this,
265 SLOT(exportToGpasman()), 0, BUTTON_POPUP_EXPORT_GPASMAN); 271 SLOT(exportToGpasman()), 0, BUTTON_POPUP_EXPORT_GPASMAN);
266 exportPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this, 272 exportPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this,
267 SLOT(exportToCsv()), 0, BUTTON_POPUP_EXPORT_CSV); 273 SLOT(exportToCsv()), 0, BUTTON_POPUP_EXPORT_CSV);
268#ifdef CONFIG_KWALLETIF 274#ifdef CONFIG_KWALLETIF
269 exportPopup->insertItem(i18n("&KWallet..."), this, 275 exportPopup->insertItem(i18n("&KWallet..."), this,
270 SLOT(exportToKWallet()), 0, BUTTON_POPUP_EXPORT_KWALLET); 276 SLOT(exportToKWallet()), 0, BUTTON_POPUP_EXPORT_KWALLET);
271#endif 277#endif
272 filePopup->insertItem(QIconSet(picons->loadIcon("fileexport", KIcon::Small)), 278 filePopup->insertItem(QIcon(picons->loadIcon("fileexport", KIcon::Small)),
273 i18n("E&xport"), exportPopup, 279 i18n("E&xport"), exportPopup,
274 BUTTON_POPUP_FILE_EXPORT); 280 BUTTON_POPUP_FILE_EXPORT);
275 // "file/import" popup menu 281 // "file/import" popup menu
276 importPopup->insertItem(i18n("&Text-file..."), this, 282 importPopup->insertItem(i18n("&Text-file..."), this,
277 SLOT(importFromText()), 0, BUTTON_POPUP_IMPORT_TEXT); 283 SLOT(importFromText()), 0, BUTTON_POPUP_IMPORT_TEXT);
278 importPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, 284 importPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this,
279 SLOT(importFromGpasman()), 0, BUTTON_POPUP_IMPORT_GPASMAN); 285 SLOT(importFromGpasman()), 0, BUTTON_POPUP_IMPORT_GPASMAN);
280 importPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this, 286 importPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this,
281 SLOT(importCsv()), 0, BUTTON_POPUP_IMPORT_CSV); 287 SLOT(importCsv()), 0, BUTTON_POPUP_IMPORT_CSV);
282#ifdef CONFIG_KWALLETIF 288#ifdef CONFIG_KWALLETIF
283 importPopup->insertItem(i18n("&KWallet..."), this, 289 importPopup->insertItem(i18n("&KWallet..."), this,
284 SLOT(importKWallet()), 0, BUTTON_POPUP_IMPORT_KWALLET); 290 SLOT(importKWallet()), 0, BUTTON_POPUP_IMPORT_KWALLET);
285#endif 291#endif
286 filePopup->insertItem(QIconSet(picons->loadIcon("fileimport", KIcon::Small)), 292 filePopup->insertItem(QIcon(picons->loadIcon("fileimport", KIcon::Small)),
287 i18n("I&mport"), importPopup, 293 i18n("I&mport"), importPopup,
288 BUTTON_POPUP_FILE_IMPORT); 294 BUTTON_POPUP_FILE_IMPORT);
289 filePopup->insertSeparator(); 295 filePopup->insertSeparator();
290#if 0 296#if 0
291 filePopup->insertItem(QIconSet(picons->loadIcon("fileprint", KIcon::Small)), 297 filePopup->insertItem(QIcon(picons->loadIcon("fileprint", KIcon::Small)),
292 i18n("&Print..."), this, 298 i18n("&Print..."), this,
293 SLOT(print_slot()), 0, BUTTON_POPUP_FILE_PRINT); 299 SLOT(print_slot()), 0, BUTTON_POPUP_FILE_PRINT);
294 filePopup->insertSeparator(); 300 filePopup->insertSeparator();
295#endif 301#endif
296 filePopup->insertItem(QIconSet(picons->loadIcon("exit", KIcon::Small)), 302 filePopup->insertItem(QIcon(picons->loadIcon("exit", KIcon::Small)),
297 i18n("&Quit"), this, 303 i18n("&Quit"), this,
298 SLOT(quitButton_slot()), 0, BUTTON_POPUP_FILE_QUIT); 304 SLOT(quitButton_slot()), 0, BUTTON_POPUP_FILE_QUIT);
299 menuBar()->insertItem(i18n("&File"), filePopup); 305 menuBar()->insertItem(i18n("&File"), filePopup);
300// "manage" popup menu 306// "manage" popup menu
301 managePopup->insertItem(QIconSet(picons->loadIcon("pencil", KIcon::Small)), 307 managePopup->insertItem(QIcon(picons->loadIcon("pencil", KIcon::Small)),
302 i18n("&Add password"), this, 308 i18n("&Add password"), this,
303 SLOT(addPwd_slot()), 0, 309 SLOT(addPwd_slot()), 0,
304 BUTTON_POPUP_MANAGE_ADD); 310 BUTTON_POPUP_MANAGE_ADD);
305 managePopup->insertSeparator(); 311 managePopup->insertSeparator();
306 managePopup->insertItem(QIconSet(picons->loadIcon("edit", KIcon::Small)), 312 managePopup->insertItem(QIcon(picons->loadIcon("edit", KIcon::Small)),
307 i18n("&Edit"), this, SLOT(editPwd_slot()), 0, 313 i18n("&Edit"), this, SLOT(editPwd_slot()), 0,
308 BUTTON_POPUP_MANAGE_EDIT); 314 BUTTON_POPUP_MANAGE_EDIT);
309 managePopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), 315 managePopup->insertItem(QIcon(picons->loadIcon("editdelete", KIcon::Small)),
310 i18n("&Delete"), this, SLOT(deletePwd_slot()), 316 i18n("&Delete"), this, SLOT(deletePwd_slot()),
311 0, BUTTON_POPUP_MANAGE_DEL); 317 0, BUTTON_POPUP_MANAGE_DEL);
312 managePopup->insertSeparator(); 318 managePopup->insertSeparator();
313 managePopup->insertItem(QIconSet(picons->loadIcon("rotate", KIcon::Small)), 319 managePopup->insertItem(QIcon(picons->loadIcon("rotate", KIcon::Small)),
314 i18n("Change &Master Password"), this, 320 i18n("Change &Master Password"), this,
315 SLOT(changeMasterPwd_slot()), 0, 321 SLOT(changeMasterPwd_slot()), 0,
316 BUTTON_POPUP_MANAGE_CHANGEMP); 322 BUTTON_POPUP_MANAGE_CHANGEMP);
317 menuBar()->insertItem(i18n("&Manage"), managePopup); 323 menuBar()->insertItem(i18n("&Manage"), managePopup);
318// "chipcard" popup menu 324// "chipcard" popup menu
319#ifdef CONFIG_KEYCARD 325#ifdef CONFIG_KEYCARD
320 chipcardPopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), 326 chipcardPopup->insertItem(QIcon(picons->loadIcon("filenew", KIcon::Small)),
321 i18n("&Generate new key-card"), this, 327 i18n("&Generate new key-card"), this,
322 SLOT(genNewCard_slot()), 0, 328 SLOT(genNewCard_slot()), 0,
323 BUTTON_POPUP_CHIPCARD_GENNEW); 329 BUTTON_POPUP_CHIPCARD_GENNEW);
324 chipcardPopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), 330 chipcardPopup->insertItem(QIcon(picons->loadIcon("editdelete", KIcon::Small)),
325 i18n("&Erase key-card"), this, 331 i18n("&Erase key-card"), this,
326 SLOT(eraseCard_slot()), 0, 332 SLOT(eraseCard_slot()), 0,
327 BUTTON_POPUP_CHIPCARD_DEL); 333 BUTTON_POPUP_CHIPCARD_DEL);
328 chipcardPopup->insertItem(QIconSet(picons->loadIcon("", KIcon::Small)), 334 chipcardPopup->insertItem(QIcon(picons->loadIcon("", KIcon::Small)),
329 i18n("Read card-&ID"), this, 335 i18n("Read card-&ID"), this,
330 SLOT(readCardId_slot()), 0, 336 SLOT(readCardId_slot()), 0,
331 BUTTON_POPUP_CHIPCARD_READID); 337 BUTTON_POPUP_CHIPCARD_READID);
332 chipcardPopup->insertSeparator(); 338 chipcardPopup->insertSeparator();
333 chipcardPopup->insertItem(QIconSet(picons->loadIcon("2rightarrow", KIcon::Small)), 339 chipcardPopup->insertItem(QIcon(picons->loadIcon("2rightarrow", KIcon::Small)),
334 i18n("&Make card backup-image"), this, 340 i18n("&Make card backup-image"), this,
335 SLOT(makeCardBackup_slot()), 0, 341 SLOT(makeCardBackup_slot()), 0,
336 BUTTON_POPUP_CHIPCARD_SAVEBACKUP); 342 BUTTON_POPUP_CHIPCARD_SAVEBACKUP);
337 chipcardPopup->insertItem(QIconSet(picons->loadIcon("2leftarrow", KIcon::Small)), 343 chipcardPopup->insertItem(QIcon(picons->loadIcon("2leftarrow", KIcon::Small)),
338 i18n("&Replay card backup-image"), this, 344 i18n("&Replay card backup-image"), this,
339 SLOT(replayCardBackup_slot()), 0, 345 SLOT(replayCardBackup_slot()), 0,
340 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP); 346 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP);
341 menuBar()->insertItem(i18n("&Chipcard manager"), chipcardPopup); 347 menuBar()->insertItem(i18n("&Chipcard manager"), chipcardPopup);
342#endif // CONFIG_KEYCARD 348#endif // CONFIG_KEYCARD
343// "view" popup menu 349// "view" popup menu
344 viewPopup->insertItem(QIconSet(picons->loadIcon("find", KIcon::Small)), 350 viewPopup->insertItem(QIcon(picons->loadIcon("find", KIcon::Small)),
345 i18n("&Find"), this, 351 i18n("&Find"), this,
346 SLOT(find_slot()), 0, BUTTON_POPUP_VIEW_FIND); 352 SLOT(find_slot()), 0, BUTTON_POPUP_VIEW_FIND);
347 viewPopup->insertSeparator(); 353 viewPopup->insertSeparator();
348 viewPopup->insertItem(QIconSet(picons->loadIcon("halfencrypted", KIcon::Small)), 354 viewPopup->insertItem(QIcon(picons->loadIcon("halfencrypted", KIcon::Small)),
349 i18n("&Lock all entries"), this, 355 i18n("&Lock all entries"), this,
350 SLOT(lockWnd_slot()), 0, 356 SLOT(lockWnd_slot()), 0,
351 BUTTON_POPUP_VIEW_LOCK); 357 BUTTON_POPUP_VIEW_LOCK);
352 viewPopup->insertItem(QIconSet(picons->loadIcon("encrypted", KIcon::Small)), 358 viewPopup->insertItem(QIcon(picons->loadIcon("encrypted", KIcon::Small)),
353 i18n("&Deep-lock all entries"), this, 359 i18n("&Deep-lock all entries"), this,
354 SLOT(deepLockWnd_slot()), 0, 360 SLOT(deepLockWnd_slot()), 0,
355 BUTTON_POPUP_VIEW_DEEPLOCK); 361 BUTTON_POPUP_VIEW_DEEPLOCK);
356 viewPopup->insertItem(QIconSet(picons->loadIcon("decrypted", KIcon::Small)), 362 viewPopup->insertItem(QIcon(picons->loadIcon("decrypted", KIcon::Small)),
357 i18n("&Unlock all entries"), this, 363 i18n("&Unlock all entries"), this,
358 SLOT(unlockWnd_slot()), 0, 364 SLOT(unlockWnd_slot()), 0,
359 BUTTON_POPUP_VIEW_UNLOCK); 365 BUTTON_POPUP_VIEW_UNLOCK);
360 menuBar()->insertItem(i18n("&View"), viewPopup); 366 menuBar()->insertItem(i18n("&View"), viewPopup);
361// "options" popup menu 367// "options" popup menu
362 optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)), 368 optionsPopup->insertItem(QIcon(picons->loadIcon("configure", KIcon::Small)),
363 i18n("&Configure PwM/Pi..."), this, 369 i18n("&Configure PwM/Pi..."), this,
364 SLOT(config_slot()),0, 370 SLOT(config_slot()),0,
365 BUTTON_POPUP_OPTIONS_CONFIG); 371 BUTTON_POPUP_OPTIONS_CONFIG);
366 optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)), 372 optionsPopup->insertItem(QIcon(picons->loadIcon("configure", KIcon::Small)),
367 i18n("Global Settings..."), this, 373 i18n("Global Settings..."), this,
368 SLOT(config_global_slot()),0, 374 SLOT(config_global_slot()),0,
369 BUTTON_POPUP_OPTIONS_GLOBAL_CONFIG); 375 BUTTON_POPUP_OPTIONS_GLOBAL_CONFIG);
370 if ( QApplication::desktop()->width() <= 240 ) { 376 if ( QApplication::desktop()->width() <= 240 ) {
371 managePopup->insertSeparator(); 377 managePopup->insertSeparator();
372 managePopup->insertItem(i18n("&Options"), optionsPopup); 378 managePopup->insertItem(i18n("&Options"), optionsPopup);
373 } else 379 } else
374 menuBar()->insertItem(i18n("&Options"), optionsPopup); 380 menuBar()->insertItem(i18n("&Options"), optionsPopup);
375// "help" popup menu 381// "help" popup menu
376#ifndef PWM_EMBEDDED 382#ifndef PWM_EMBEDDED
377 helpPopup = helpMenu(QString::null, false); 383 helpPopup = helpMenu(QString::null, false);
378#else 384#else
379 optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)), 385 optionsPopup->insertItem(QIcon(picons->loadIcon("configure", KIcon::Small)),
380 i18n("C&ategories..."), this, 386 i18n("C&ategories..."), this,
381 SLOT(category_slot()),0, 387 SLOT(category_slot()),0,
382 BUTTON_POPUP_OPTIONS_CATEGORY); 388 BUTTON_POPUP_OPTIONS_CATEGORY);
383 389
384 390
385 menuBar()->insertItem(i18n("&Sync"), syncPopup); 391 menuBar()->insertItem(i18n("&Sync"), syncPopup);
386 392
387 393
388 394
389 395
390 396
391 helpPopup = new KPopupMenu(this); 397 helpPopup = new KPopupMenu(this);
392 398
393 399
394 helpPopup->insertItem(i18n("&License"), this, 400 helpPopup->insertItem(i18n("&License"), this,
395 SLOT(showLicense_slot()), 0, 401 SLOT(showLicense_slot()), 0,
396 BUTTON_POPUP_HELP_LICENSE); 402 BUTTON_POPUP_HELP_LICENSE);
397 403
398 helpPopup->insertItem(i18n("&Faq"), this, 404 helpPopup->insertItem(i18n("&Faq"), this,
399 SLOT(faq_slot()), 0, 405 SLOT(faq_slot()), 0,
400 BUTTON_POPUP_HELP_FAQ); 406 BUTTON_POPUP_HELP_FAQ);
401 407
402 helpPopup->insertItem(i18n("&About PwManager"), this, 408 helpPopup->insertItem(i18n("&About PwManager"), this,
403 SLOT(createAboutData_slot()), 0, 409 SLOT(createAboutData_slot()), 0,
404 BUTTON_POPUP_HELP_ABOUT); 410 BUTTON_POPUP_HELP_ABOUT);
405 411
406 helpPopup->insertItem(i18n("&Sync HowTo"), this, 412 helpPopup->insertItem(i18n("&Sync HowTo"), this,
407 SLOT(syncHowTo_slot()), 0, 413 SLOT(syncHowTo_slot()), 0,
408 BUTTON_POPUP_HELP_SYNC); 414 BUTTON_POPUP_HELP_SYNC);
409 415
410 helpPopup->insertItem(i18n("&What's New"), this, 416 helpPopup->insertItem(i18n("&What's New"), this,
411 SLOT(whatsnew_slot()), 0, 417 SLOT(whatsnew_slot()), 0,
412 BUTTON_POPUP_HELP_WHATSNEW); 418 BUTTON_POPUP_HELP_WHATSNEW);
413 419
414#endif 420#endif
415 menuBar()->insertItem(i18n("&Help"), helpPopup); 421 menuBar()->insertItem(i18n("&Help"), helpPopup);
416 422
417} 423}
418 424
419void PwM::initToolbar() 425void PwM::initToolbar()
420{ 426{
421 KIconLoader* picons; 427 KIconLoader* picons;
422#ifndef PWM_EMBEDDED 428#ifndef PWM_EMBEDDED
423 KIconLoader icons; 429 KIconLoader icons;
424 picons = &icons; 430 picons = &icons;
425#else 431#else
426 picons = KGlobal::iconLoader(); 432 picons = KGlobal::iconLoader();
427#endif 433#endif
428 434
429#if 0 435#if 0
430 toolBar()->insertButton(picons->loadIcon("filenew", KIcon::Toolbar), 436 toolBar()->insertButton(picons->loadIcon("filenew", KIcon::Toolbar),
431 BUTTON_TOOL_NEW, SIGNAL(clicked(int)), this, 437 BUTTON_TOOL_NEW, SIGNAL(clicked(int)), this,
432 SLOT(new_slot()), true, i18n("New")); 438 SLOT(new_slot()), true, i18n("New"));
433#endif 439#endif
434 toolBar()->insertButton(picons->loadIcon("fileopen", KIcon::Toolbar), 440 toolBar()->insertButton(picons->loadIcon("fileopen", KIcon::Toolbar),
435 BUTTON_TOOL_OPEN, SIGNAL(clicked(int)), this, 441 BUTTON_TOOL_OPEN, SIGNAL(clicked(int)), this,
436 SLOT(open_slot()), true, i18n("Open")); 442 SLOT(open_slot()), true, i18n("Open"));
437 toolBar()->insertButton(picons->loadIcon("pencil", KIcon::Toolbar), 443 toolBar()->insertButton(picons->loadIcon("pencil", KIcon::Toolbar),
438 BUTTON_TOOL_ADD, SIGNAL(clicked(int)), this, 444 BUTTON_TOOL_ADD, SIGNAL(clicked(int)), this,
439 SLOT(addPwd_slot()), true, 445 SLOT(addPwd_slot()), true,
440 i18n("Add password")); 446 i18n("Add password"));
441 toolBar()->insertSeparator(); 447 toolBar()->insertSeparator();
442 448
443 toolBar()->insertButton(picons->loadIcon("find", KIcon::Toolbar), 449 toolBar()->insertButton(picons->loadIcon("find", KIcon::Toolbar),
444 BUTTON_TOOL_FIND, SIGNAL(clicked(int)), this, 450 BUTTON_TOOL_FIND, SIGNAL(clicked(int)), this,
445 SLOT(find_slot()), true, i18n("Find entry")); 451 SLOT(find_slot()), true, i18n("Find entry"));
446 toolBar()->insertSeparator(); 452 toolBar()->insertSeparator();
447 toolBar()->insertButton(picons->loadIcon("filesave", KIcon::Toolbar), 453 toolBar()->insertButton(picons->loadIcon("filesave", KIcon::Toolbar),
448 BUTTON_TOOL_SAVE, SIGNAL(clicked(int)), this, 454 BUTTON_TOOL_SAVE, SIGNAL(clicked(int)), this,
449 SLOT(save_slot()), true, i18n("Save")); 455 SLOT(save_slot()), true, i18n("Save"));
450#if 0 456#if 0
451 toolBar()->insertButton(picons->loadIcon("filesaveas", KIcon::Toolbar), 457 toolBar()->insertButton(picons->loadIcon("filesaveas", KIcon::Toolbar),
452 BUTTON_TOOL_SAVEAS, SIGNAL(clicked(int)), this, 458 BUTTON_TOOL_SAVEAS, SIGNAL(clicked(int)), this,
453 SLOT(saveAs_slot()), true, i18n("Save as")); 459 SLOT(saveAs_slot()), true, i18n("Save as"));
454#endif 460#endif
455 461
456 462
457#if 0 463#if 0
458 toolBar()->insertButton(picons->loadIcon("fileprint", KIcon::Toolbar), 464 toolBar()->insertButton(picons->loadIcon("fileprint", KIcon::Toolbar),
459 BUTTON_TOOL_PRINT, SIGNAL(clicked(int)), this, 465 BUTTON_TOOL_PRINT, SIGNAL(clicked(int)), this,
460 SLOT(print_slot()), true, i18n("Print...")); 466 SLOT(print_slot()), true, i18n("Print..."));
461#endif 467#endif
462 toolBar()->insertSeparator(); 468 toolBar()->insertSeparator();
463 toolBar()->insertButton(picons->loadIcon("edit", KIcon::Toolbar), 469 toolBar()->insertButton(picons->loadIcon("edit", KIcon::Toolbar),
464 BUTTON_TOOL_EDIT, SIGNAL(clicked(int)), this, 470 BUTTON_TOOL_EDIT, SIGNAL(clicked(int)), this,
465 SLOT(editPwd_slot()), true, 471 SLOT(editPwd_slot()), true,
466 i18n("Edit password")); 472 i18n("Edit password"));
467 toolBar()->insertButton(picons->loadIcon("editdelete", KIcon::Toolbar), 473 toolBar()->insertButton(picons->loadIcon("editdelete", KIcon::Toolbar),
468 BUTTON_TOOL_DEL, SIGNAL(clicked(int)), this, 474 BUTTON_TOOL_DEL, SIGNAL(clicked(int)), this,
469 SLOT(deletePwd_slot()), true, 475 SLOT(deletePwd_slot()), true,
470 i18n("Delete password")); 476 i18n("Delete password"));
471 toolBar()->insertSeparator(); 477 toolBar()->insertSeparator();
472 toolBar()->insertButton(picons->loadIcon("halfencrypted", KIcon::Toolbar), 478 toolBar()->insertButton(picons->loadIcon("halfencrypted", KIcon::Toolbar),
473 BUTTON_TOOL_LOCK, SIGNAL(clicked(int)), this, 479 BUTTON_TOOL_LOCK, SIGNAL(clicked(int)), this,
474 SLOT(lockWnd_slot()), true, 480 SLOT(lockWnd_slot()), true,
475 i18n("Lock all entries")); 481 i18n("Lock all entries"));
476 toolBar()->insertButton(picons->loadIcon("encrypted", KIcon::Toolbar), 482 toolBar()->insertButton(picons->loadIcon("encrypted", KIcon::Toolbar),
477 BUTTON_TOOL_DEEPLOCK, SIGNAL(clicked(int)), this, 483 BUTTON_TOOL_DEEPLOCK, SIGNAL(clicked(int)), this,
478 SLOT(deepLockWnd_slot()), true, 484 SLOT(deepLockWnd_slot()), true,
479 i18n("Deep-Lock all entries")); 485 i18n("Deep-Lock all entries"));
480 toolBar()->insertButton(picons->loadIcon("decrypted", KIcon::Toolbar), 486 toolBar()->insertButton(picons->loadIcon("decrypted", KIcon::Toolbar),
481 BUTTON_TOOL_UNLOCK, SIGNAL(clicked(int)), this, 487 BUTTON_TOOL_UNLOCK, SIGNAL(clicked(int)), this,
482 SLOT(unlockWnd_slot()), true, 488 SLOT(unlockWnd_slot()), true,
483 i18n("Unlock all entries")); 489 i18n("Unlock all entries"));
484} 490}
485 491
486void PwM::initMetrics() 492void PwM::initMetrics()
487{ 493{
488 QSize s = conf()->confWndMainWndSize(); 494 QSize s = conf()->confWndMainWndSize();
489 if (s.isValid()) 495 if (s.isValid())
490 resize(s); 496 resize(s);
491 else 497 else
492 resize(DEFAULT_SIZE); 498 resize(DEFAULT_SIZE);
493} 499}
494 500
495void PwM::updateCaption() 501void PwM::updateCaption()
496{ 502{
497 QString s = curDoc()->getTitle(); 503 QString s = curDoc()->getTitle();
498 int maxlen = 50; 504 int maxlen = 50;
499 if ( QApplication::desktop()->width() < 640 ) { 505 if ( QApplication::desktop()->width() < 640 ) {
500 if ( QApplication::desktop()->width() < 320 ) 506 if ( QApplication::desktop()->width() < 320 )
501 maxlen = 22; 507 maxlen = 22;
502 else 508 else
503 maxlen = 35; 509 maxlen = 35;
504 } 510 }
505 if ( s.length() > maxlen ) { 511 if ( s.length() > maxlen ) {
506 s = "..."+s.right(maxlen -3); 512 s = "..."+s.right(maxlen -3);
507 } 513 }
508 setPlainCaption( s ); 514 setPlainCaption( s );
509} 515}
510 516
511void PwM::hideEvent(QHideEvent *) 517void PwM::hideEvent(QHideEvent *)
512{ 518{
513 if (isMinimized()) { 519 if (isMinimized()) {
514 if (init->tray()) { 520 if (init->tray()) {
515 forceMinimizeToTray = true; 521 forceMinimizeToTray = true;
516 close(); 522 close();
517 } 523 }
518 int mmlock = conf()->confGlobMinimizeLock(); 524 int mmlock = conf()->confGlobMinimizeLock();
519 switch (mmlock) { 525 switch (mmlock) {
520 case 0: // don't lock anything 526 case 0: // don't lock anything
521 break; 527 break;
522 case 1: {// normal lock 528 case 1: {// normal lock
523 curDoc()->lockAll(true); 529 curDoc()->lockAll(true);
524 break; 530 break;
525 } case 2: {// deep-lock 531 } case 2: {// deep-lock
526 curDoc()->deepLock(); 532 curDoc()->deepLock();
527 break; 533 break;
528 } default: 534 } default:
529 WARN(); 535 WARN();
530 } 536 }
531 } 537 }
532} 538}
533 539
534void PwM::setVirgin(bool v) 540void PwM::setVirgin(bool v)
535{ 541{
536 if (virgin == v) 542 if (virgin == v)
537 return; 543 return;
538 virgin = v; 544 virgin = v;
539 filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVE, !v); 545 filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVE, !v);
540 filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVEAS, !v); 546 filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVEAS, !v);
541 filePopup->setItemEnabled(BUTTON_POPUP_FILE_EXPORT, !v); 547 filePopup->setItemEnabled(BUTTON_POPUP_FILE_EXPORT, !v);
542 filePopup->setItemEnabled(BUTTON_POPUP_FILE_PRINT, !v); 548 filePopup->setItemEnabled(BUTTON_POPUP_FILE_PRINT, !v);
543 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_EDIT, !v); 549 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_EDIT, !v);
544 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_DEL, !v); 550 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_DEL, !v);
545 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, !v); 551 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, !v);
546 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_LOCK, !v); 552 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_LOCK, !v);
547 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_DEEPLOCK, !v); 553 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_DEEPLOCK, !v);
548 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_UNLOCK, !v); 554 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_UNLOCK, !v);
549 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_FIND, !v); 555 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_FIND, !v);
550 toolBar()->setItemEnabled(BUTTON_TOOL_SAVE, !v); 556 toolBar()->setItemEnabled(BUTTON_TOOL_SAVE, !v);
551 toolBar()->setItemEnabled(BUTTON_TOOL_SAVEAS, !v); 557 toolBar()->setItemEnabled(BUTTON_TOOL_SAVEAS, !v);
552 toolBar()->setItemEnabled(BUTTON_TOOL_PRINT, !v); 558 toolBar()->setItemEnabled(BUTTON_TOOL_PRINT, !v);
553 toolBar()->setItemEnabled(BUTTON_TOOL_EDIT, !v); 559 toolBar()->setItemEnabled(BUTTON_TOOL_EDIT, !v);
554 toolBar()->setItemEnabled(BUTTON_TOOL_DEL, !v); 560 toolBar()->setItemEnabled(BUTTON_TOOL_DEL, !v);
555 toolBar()->setItemEnabled(BUTTON_TOOL_LOCK, !v); 561 toolBar()->setItemEnabled(BUTTON_TOOL_LOCK, !v);
556 toolBar()->setItemEnabled(BUTTON_TOOL_DEEPLOCK, !v); 562 toolBar()->setItemEnabled(BUTTON_TOOL_DEEPLOCK, !v);
557 toolBar()->setItemEnabled(BUTTON_TOOL_UNLOCK, !v); 563 toolBar()->setItemEnabled(BUTTON_TOOL_UNLOCK, !v);
558 toolBar()->setItemEnabled(BUTTON_TOOL_FIND, !v); 564 toolBar()->setItemEnabled(BUTTON_TOOL_FIND, !v);
559} 565}
560 566
561void PwM::new_slot() 567void PwM::new_slot()
562{ 568{
563 init->createMainWnd(); 569 init->createMainWnd();
564} 570}
565 571
566//US ENH 572//US ENH
567void PwM::open_slot() 573void PwM::open_slot()
568{ 574{
569 open_slot(""); 575 open_slot("");
570} 576}
571 577
572void PwM::open_slot(QString fn) 578void PwM::open_slot(QString fn)
573{ 579{
574 openDoc(fn); 580 openDoc(fn);
575} 581}
576 582
577PwMDoc * PwM::openDoc(QString filename, bool openDeepLocked) 583PwMDoc * PwM::openDoc(QString filename, bool openDeepLocked)
578{ 584{
579 if (!isVirgin()) { 585 if (!isVirgin()) {
580 // open the document in a new window. 586 // open the document in a new window.
581 PwM *newInstance = init->createMainWnd(); 587 PwM *newInstance = init->createMainWnd();
582 PwMDoc *newDoc = newInstance->openDoc(filename, openDeepLocked); 588 PwMDoc *newDoc = newInstance->openDoc(filename, openDeepLocked);
583 if (!newDoc) { 589 if (!newDoc) {
584 newInstance->setForceQuit(true); 590 newInstance->setForceQuit(true);
585 delete_and_null(newInstance); 591 delete_and_null(newInstance);
586 } 592 }
587 return newDoc; 593 return newDoc;
588 } 594 }
589 595
590 if (!curDoc()->openDocUi(curDoc(), filename, openDeepLocked)) 596 if (!curDoc()->openDocUi(curDoc(), filename, openDeepLocked))
591 return 0; 597 return 0;
592 showStatMsg(i18n("Successfully opened file.")); 598 showStatMsg(i18n("Successfully opened file."));
593 updateCaption(); 599 updateCaption();
594 setVirgin(false); 600 setVirgin(false);
595 return curDoc(); 601 return curDoc();
596} 602}
597 603
598PwMView * PwM::makeNewListView(PwMDoc *doc) 604PwMView * PwM::makeNewListView(PwMDoc *doc)
599{ 605{
600 PwMView *ret = new PwMView(this, this, doc); 606 PwMView *ret = new PwMView(this, this, doc);
601 ret->setFont(conf()->confGlobEntryFont()); 607 ret->setFont(conf()->confGlobEntryFont());
602 ret->show(); 608 ret->show();
603 return ret; 609 return ret;
604} 610}
605 611
606void PwM::close_slot() 612void PwM::close_slot()
607{ 613{
608 close(); 614 close();
609} 615}
610 616
611void PwM::quitButton_slot() 617void PwM::quitButton_slot()
612{ 618{
613 init->shutdownApp(0); 619 init->shutdownApp(0);
614} 620}
615 621
616void PwM::save_slot() 622void PwM::save_slot()
617{ 623{
618 save(); 624 save();
619} 625}
620 626
621bool PwM::save() 627bool PwM::save()
622{ 628{
623 if (!curDoc()->saveDocUi(curDoc())) 629 if (!curDoc()->saveDocUi(curDoc()))
624 return false; 630 return false;
625 showStatMsg(i18n("Successfully saved data.")); 631 showStatMsg(i18n("Successfully saved data."));
626 updateCaption(); 632 updateCaption();
627 return true; 633 return true;
628} 634}
629 635
630void PwM::saveAs_slot() 636void PwM::saveAs_slot()
631{ 637{
632 saveAs(); 638 saveAs();
633} 639}
634 640
635bool PwM::saveAs() 641bool PwM::saveAs()
636{ 642{
637 if (!curDoc()->saveAsDocUi(curDoc())) 643 if (!curDoc()->saveAsDocUi(curDoc()))
638 return false; 644 return false;
639 showStatMsg(i18n("Successfully saved data.")); 645 showStatMsg(i18n("Successfully saved data."));
640 updateCaption(); 646 updateCaption();
641 return true; 647 return true;
642} 648}
643 649
644//US ENH : changed code to run with older MOC 650//US ENH : changed code to run with older MOC
645void PwM::addPwd_slot() 651void PwM::addPwd_slot()
646{ 652{
647 addPwd_slot1(0, 0); 653 addPwd_slot1(0, 0);
648} 654}
649 655
650void PwM::addPwd_slot1(QString *pw, PwMDoc *_doc) 656void PwM::addPwd_slot1(QString *pw, PwMDoc *_doc)
651{ 657{
652 PwMDoc *doc; 658 PwMDoc *doc;
653 if (_doc) { 659 if (_doc) {
654 doc = _doc; 660 doc = _doc;
655 } else { 661 } else {
656 doc = curDoc(); 662 doc = curDoc();
657 } 663 }
658 PWM_ASSERT(doc); 664 PWM_ASSERT(doc);
659 doc->timer()->getLock(DocTimer::id_autoLockTimer); 665 doc->timer()->getLock(DocTimer::id_autoLockTimer);
660#ifndef PWM_EMBEDDED 666#ifndef PWM_EMBEDDED
661 AddEntryWndImpl w; 667 AddEntryWndImpl w;
662#else 668#else
663 AddEntryWndImpl w(doc, this, "addentrywndimpl"); 669 AddEntryWndImpl w(doc, this, "addentrywndimpl");
664#endif 670#endif
665 w.setCaption( i18n ("Add new password") ); 671 w.setCaption( i18n ("Add new password") );
666 vector<string> catList; 672 vector<string> catList;
667 doc->getCategoryList(&catList); 673 doc->getCategoryList(&catList);
668 unsigned i, size = catList.size(); 674 unsigned i, size = catList.size();
669 for (i = 0; i < size; ++i) { 675 for (i = 0; i < size; ++i) {
670 w.addCategory(catList[i].c_str()); 676 w.addCategory(catList[i].c_str());
671 } 677 }
672 w.setCurrCategory(view->getCurrentCategory()); 678 w.setCurrCategory(view->getCurrentCategory());
673 if (pw) 679 if (pw)
674 w.pwLineEdit->setText(*pw); 680 w.pwLineEdit->setText(*pw);
675 681
676 tryAgain: 682 tryAgain:
677 w.descLineEdit->setFocus(); 683 w.descLineEdit->setFocus();
678 if (w.exec() == 1) 684 if (w.exec() == 1)
679 { 685 {
680 PwMDataItem d; 686 PwMDataItem d;
681 687
682 //US BUG: to initialize all values of curEntr with meaningfulldata, 688 //US BUG: to initialize all values of curEntr with meaningfulldata,
683 // we call clear on it. Reason: Metadata will be uninitialized otherwise. 689 // we call clear on it. Reason: Metadata will be uninitialized otherwise.
684 // another option would be to create a constructor for PwMDataItem 690 // another option would be to create a constructor for PwMDataItem
685 d.clear(true); 691 d.clear(true);
686 692
687 d.desc = w.getDescription().latin1(); 693 d.desc = w.getDescription().latin1();
688 d.name = w.getUsername().latin1(); 694 d.name = w.getUsername().latin1();
689 d.pw = w.getPassword().latin1(); 695 d.pw = w.getPassword().latin1();
690 d.comment = w.getComment().latin1(); 696 d.comment = w.getComment().latin1();
691 d.url = w.getUrl().latin1(); 697 d.url = w.getUrl().latin1();
692 d.launcher = w.getLauncher().latin1(); 698 d.launcher = w.getLauncher().latin1();
693 PwMerror ret = doc->addEntry(w.getCategory(), &d); 699 PwMerror ret = doc->addEntry(w.getCategory(), &d);
694 if (ret == e_entryExists) { 700 if (ret == e_entryExists) {
695 KMessageBox::error(this, 701 KMessageBox::error(this,
696 i18n 702 i18n
697 ("An entry with this \"Description\",\n" 703 ("An entry with this \"Description\",\n"
698 "does already exist.\n" 704 "does already exist.\n"
699 "Please select another description."), 705 "Please select another description."),
700 i18n("entry already exists.")); 706 i18n("entry already exists."));
701 goto tryAgain; 707 goto tryAgain;
702 } else if (ret == e_maxAllowedEntr) { 708 } else if (ret == e_maxAllowedEntr) {
703 KMessageBox::error(this, i18n("The maximum possible number of\nentries" 709 KMessageBox::error(this, i18n("The maximum possible number of\nentries"
704 "has been reached.\nYou can't add more entries."), 710 "has been reached.\nYou can't add more entries."),
705 i18n("maximum number of entries")); 711 i18n("maximum number of entries"));
706 doc->timer()->putLock(DocTimer::id_autoLockTimer); 712 doc->timer()->putLock(DocTimer::id_autoLockTimer);
707 return; 713 return;
708 } 714 }
709 } 715 }
710 setVirgin(false); 716 setVirgin(false);
711 doc->timer()->putLock(DocTimer::id_autoLockTimer); 717 doc->timer()->putLock(DocTimer::id_autoLockTimer);
712} 718}
713 719
714//US ENH : changed code to run with older MOC 720//US ENH : changed code to run with older MOC
715void PwM::editPwd_slot() 721void PwM::editPwd_slot()
716{ 722{
717 editPwd_slot3(0,0,0); 723 editPwd_slot3(0,0,0);
718} 724}
719 725
720void PwM::editPwd_slot1(const QString *category) 726void PwM::editPwd_slot1(const QString *category)
721{ 727{
722 editPwd_slot3(category, 0, 0); 728 editPwd_slot3(category, 0, 0);
723} 729}
724 730
725void PwM::editPwd_slot3(const QString *category, const int *index, 731void PwM::editPwd_slot3(const QString *category, const int *index,
726 PwMDoc *_doc) 732 PwMDoc *_doc)
727{ 733{
728 PwMDoc *doc; 734 PwMDoc *doc;
729 if (_doc) { 735 if (_doc) {
730 doc = _doc; 736 doc = _doc;
731 } else { 737 } else {
732 doc = curDoc(); 738 doc = curDoc();
733 } 739 }
734 PWM_ASSERT(doc); 740 PWM_ASSERT(doc);
735 if (doc->isDocEmpty()) 741 if (doc->isDocEmpty())
736 return; 742 return;
737 if (doc->isDeepLocked()) 743 if (doc->isDeepLocked())
738 return; 744 return;
739 doc->timer()->getLock(DocTimer::id_autoLockTimer); 745 doc->timer()->getLock(DocTimer::id_autoLockTimer);
740 unsigned int curEntryIndex; 746 unsigned int curEntryIndex;
741 if (index) { 747 if (index) {
742 curEntryIndex = *index; 748 curEntryIndex = *index;
743 } else { 749 } else {
744 if (!(view->getCurEntryIndex(&curEntryIndex))) { 750 if (!(view->getCurEntryIndex(&curEntryIndex))) {
745 qDebug("couldn't get index. Maybe we have a binary entry here. "); 751 qDebug("couldn't get index. Maybe we have a binary entry here. ");
746 printDebug("couldn't get index. Maybe we have a binary entry here."); 752 printDebug("couldn't get index. Maybe we have a binary entry here.");
747 doc->timer()->putLock(DocTimer::id_autoLockTimer); 753 doc->timer()->putLock(DocTimer::id_autoLockTimer);
748 return; 754 return;
749 } 755 }
750 } 756 }
751 QString curCategory; 757 QString curCategory;
752 if (category) { 758 if (category) {
753 curCategory = *category; 759 curCategory = *category;
754 } else { 760 } else {
755 curCategory = view->getCurrentCategory(); 761 curCategory = view->getCurrentCategory();
756 } 762 }
757 PwMDataItem currItem; 763 PwMDataItem currItem;
758 if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) { 764 if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) {
759 doc->timer()->putLock(DocTimer::id_autoLockTimer); 765 doc->timer()->putLock(DocTimer::id_autoLockTimer);
760 return; 766 return;
761 } 767 }
762 BUG_ON(currItem.binary); 768 BUG_ON(currItem.binary);
763 AddEntryWndImpl w(doc); 769 AddEntryWndImpl w(doc);
764 w.setCaption( i18n ("Edit password") ); 770 w.setCaption( i18n ("Edit password") );
765 vector<string> catList; 771 vector<string> catList;
766 doc->getCategoryList(&catList); 772 doc->getCategoryList(&catList);
767 unsigned i, size = catList.size(); 773 unsigned i, size = catList.size();
768 for (i = 0; i < size; ++i) { 774 for (i = 0; i < size; ++i) {
769 w.addCategory(catList[i].c_str()); 775 w.addCategory(catList[i].c_str());
770 } 776 }
771 w.setCurrCategory(curCategory); 777 w.setCurrCategory(curCategory);
772 w.setDescription(currItem.desc.c_str()); 778 w.setDescription(currItem.desc.c_str());
773 w.setUsername(currItem.name.c_str()); 779 w.setUsername(currItem.name.c_str());
774 w.setPassword(currItem.pw.c_str()); 780 w.setPassword(currItem.pw.c_str());
775 w.setUrl(currItem.url.c_str()); 781 w.setUrl(currItem.url.c_str());
776 w.setLauncher(currItem.launcher.c_str()); 782 w.setLauncher(currItem.launcher.c_str());
777 w.setComment(currItem.comment.c_str()); 783 w.setComment(currItem.comment.c_str());
778 w.descLineEdit->setFocus(); 784 w.descLineEdit->setFocus();
779 if (w.exec() == 1) { 785 if (w.exec() == 1) {
780 currItem.desc = w.getDescription().latin1(); 786 currItem.desc = w.getDescription().latin1();
781 currItem.name = w.getUsername().latin1(); 787 currItem.name = w.getUsername().latin1();
782 currItem.pw = w.getPassword().latin1(); 788 currItem.pw = w.getPassword().latin1();
783 currItem.comment = w.getComment().latin1(); 789 currItem.comment = w.getComment().latin1();
784 currItem.url = w.getUrl().latin1(); 790 currItem.url = w.getUrl().latin1();
785 currItem.launcher = w.getLauncher().latin1(); 791 currItem.launcher = w.getLauncher().latin1();
786 if (!doc->editEntry(curCategory, w.getCategory(), 792 if (!doc->editEntry(curCategory, w.getCategory(),
787 curEntryIndex, &currItem)) { 793 curEntryIndex, &currItem)) {
788 KMessageBox::error(this, 794 KMessageBox::error(this,
789 i18n("Couldn't edit the entry.\n" 795 i18n("Couldn't edit the entry.\n"
790 "Maybe you changed the category and\n" 796 "Maybe you changed the category and\n"
791 "this entry is already present\nin the new " 797 "this entry is already present\nin the new "
792 "category?"), 798 "category?"),
793 i18n("couldn't edit entry.")); 799 i18n("couldn't edit entry."));
794 doc->timer()->putLock(DocTimer::id_autoLockTimer); 800 doc->timer()->putLock(DocTimer::id_autoLockTimer);
795 return; 801 return;
796 } 802 }
797 } 803 }
798 doc->timer()->putLock(DocTimer::id_autoLockTimer); 804 doc->timer()->putLock(DocTimer::id_autoLockTimer);
799} 805}
800 806
801void PwM::deletePwd_slot() 807void PwM::deletePwd_slot()
802{ 808{
803 PWM_ASSERT(curDoc()); 809 PWM_ASSERT(curDoc());
804 if (curDoc()->isDocEmpty()) 810 if (curDoc()->isDocEmpty())
805 return; 811 return;
806 if (curDoc()->isDeepLocked()) 812 if (curDoc()->isDeepLocked())
807 return; 813 return;
808 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 814 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
809 unsigned int curEntryIndex = 0; 815 unsigned int curEntryIndex = 0;
810 if (!(view->getCurEntryIndex(&curEntryIndex))) { 816 if (!(view->getCurEntryIndex(&curEntryIndex))) {
811 printDebug("couldn't get index"); 817 printDebug("couldn't get index");
812 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 818 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
813 return; 819 return;
814 } 820 }
815 821
816 PwMDataItem currItem; 822 PwMDataItem currItem;
817 QString curCategory = view->getCurrentCategory(); 823 QString curCategory = view->getCurrentCategory();
818 if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) { 824 if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) {
819 printDebug("couldn't get entry"); 825 printDebug("couldn't get entry");
820 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 826 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
821 return; 827 return;
822 } 828 }
823 if (KMessageBox:: 829 if (KMessageBox::
824 questionYesNo(this, 830 questionYesNo(this,
825 i18n 831 i18n
826 ("Do you really want to delete\nthe selected entry") + 832 ("Do you really want to delete\nthe selected entry") +
827 " \n\"" + QString(currItem.desc.c_str()) 833 " \n\"" + QString(currItem.desc.c_str())
828 + "\" ?", i18n("delete?")) 834 + "\" ?", i18n("delete?"))
829 == KMessageBox::Yes) { 835 == KMessageBox::Yes) {
830 836
831 curDoc()->delEntry(curCategory, curEntryIndex); 837 curDoc()->delEntry(curCategory, curEntryIndex);
832 } 838 }
833 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 839 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
834} 840}
835 841
836void PwM::changeMasterPwd_slot() 842void PwM::changeMasterPwd_slot()
837{ 843{
838 PWM_ASSERT(curDoc()); 844 PWM_ASSERT(curDoc());
839 curDoc()->changeCurrentPw(); 845 curDoc()->changeCurrentPw();
840} 846}
841 847
842void PwM::lockWnd_slot() 848void PwM::lockWnd_slot()
843{ 849{
844 PWM_ASSERT(curDoc()); 850 PWM_ASSERT(curDoc());
845 curDoc()->lockAll(true); 851 curDoc()->lockAll(true);
846} 852}
847 853
848void PwM::deepLockWnd_slot() 854void PwM::deepLockWnd_slot()
849{ 855{
850 PWM_ASSERT(curDoc()); 856 PWM_ASSERT(curDoc());
851 curDoc()->deepLock(); 857 curDoc()->deepLock();
852} 858}
853 859
854void PwM::unlockWnd_slot() 860void PwM::unlockWnd_slot()
855{ 861{
856 PWM_ASSERT(curDoc()); 862 PWM_ASSERT(curDoc());
857 curDoc()->lockAll(false); 863 curDoc()->lockAll(false);
858} 864}
859void PwM::config_global_slot() 865void PwM::config_global_slot()
860{ 866{
861 KPimPrefsGlobalDialog gc ( this ); 867 KPimPrefsGlobalDialog gc ( this );
862 gc.exec(); 868 gc.exec();
863} 869}
864void PwM::config_slot() 870void PwM::config_slot()
865{ 871{
866 int oldStyle = conf()->confWndMainViewStyle(); 872 int oldStyle = conf()->confWndMainViewStyle();
867 873
868#if 0 874#if 0
869 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"pwmconfigdialog", true ); 875 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"pwmconfigdialog", true );
870 876
871 KCMPwmConfig* pwmcfg = new KCMPwmConfig( ConfigureDialog->getNewVBoxPage(i18n( "PwManager")) , "KCMPwmConfig" ); 877 KCMPwmConfig* pwmcfg = new KCMPwmConfig( ConfigureDialog->getNewVBoxPage(i18n( "PwManager")) , "KCMPwmConfig" );
872 ConfigureDialog->addModule(pwmcfg ); 878 ConfigureDialog->addModule(pwmcfg );
873 879
874 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 880 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
875 ConfigureDialog->addModule(kdelibcfg ); 881 ConfigureDialog->addModule(kdelibcfg );
876#endif 882#endif
877 883
878 884
879 885
880 KDialogBase * ConfigureDialog = new KDialogBase ( KDialogBase::Plain , i18n("Configure KA/Pi"), KDialogBase::Default |KDialogBase::Cancel | KDialogBase::Apply | KDialogBase::Ok, KDialogBase::Ok,0, "name", true, true); 886 KDialogBase * ConfigureDialog = new KDialogBase ( KDialogBase::Plain , i18n("Configure KA/Pi"), KDialogBase::Default |KDialogBase::Cancel | KDialogBase::Apply | KDialogBase::Ok, KDialogBase::Ok,0, "name", true, true);
881 887
882 KCMPwmConfig* kabcfg = new KCMPwmConfig( ConfigureDialog , "KCMpwmConfig" ); 888 KCMPwmConfig* kabcfg = new KCMPwmConfig( ConfigureDialog , "KCMpwmConfig" );
883 ConfigureDialog->setMainWidget( kabcfg ); 889 ConfigureDialog->setMainWidget( kabcfg );
884 connect( ConfigureDialog, SIGNAL( applyClicked() ), 890 connect( ConfigureDialog, SIGNAL( applyClicked() ),
885 kabcfg, SLOT( save() ) ); 891 kabcfg, SLOT( save() ) );
886 connect( ConfigureDialog, SIGNAL( acceptClicked() ), 892 connect( ConfigureDialog, SIGNAL( acceptClicked() ),
887 kabcfg, SLOT( save() ) ); 893 kabcfg, SLOT( save() ) );
888 connect( ConfigureDialog, SIGNAL( defaultClicked() ), 894 connect( ConfigureDialog, SIGNAL( defaultClicked() ),
889 kabcfg, SLOT( defaults() ) ); 895 kabcfg, SLOT( defaults() ) );
890 //saveSettings(); 896 //saveSettings();
891 kabcfg->load(); 897 kabcfg->load();
892#ifndef DESKTOP_VERSION 898#ifndef DESKTOP_VERSION
893 if ( QApplication::desktop()->height() <= 480 ) 899 if ( QApplication::desktop()->height() <= 480 )
894 ;// ConfigureDialog->hideButtons(); 900 ;// ConfigureDialog->hideButtons();
895 ConfigureDialog->showMaximized(); 901 ConfigureDialog->showMaximized();
896#endif 902#endif
897 903
898 904
899 if ( ConfigureDialog->exec() ) 905 if ( ConfigureDialog->exec() )
900 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 906 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
901 delete ConfigureDialog; 907 delete ConfigureDialog;
902 908
903 909
904 910
905 int newStyle = conf()->confWndMainViewStyle(); 911 int newStyle = conf()->confWndMainViewStyle();
906 // reinitialize tray 912 // reinitialize tray
907 init->initTray(); 913 init->initTray();
908 // reinitialize KWallet emulation 914 // reinitialize KWallet emulation
909 init->initKWalletEmu(); 915 init->initKWalletEmu();
910 916
911 PwMDocList *_dl = PwMDoc::getOpenDocList(); 917 PwMDocList *_dl = PwMDoc::getOpenDocList();
912 const vector<PwMDocList::listItem> *dl = _dl->getList(); 918 const vector<PwMDocList::listItem> *dl = _dl->getList();
913 vector<PwMDocList::listItem>::const_iterator i = dl->begin(), 919 vector<PwMDocList::listItem>::const_iterator i = dl->begin(),
914 end = dl->end(); 920 end = dl->end();
915 PwMDoc *doc; 921 PwMDoc *doc;
916 while (i != end) { 922 while (i != end) {
917 doc = (*i).doc; 923 doc = (*i).doc;
918 // unlock-without-mpw timeout 924 // unlock-without-mpw timeout
919 doc->timer()->start(DocTimer::id_mpwTimer); 925 doc->timer()->start(DocTimer::id_mpwTimer);
920 // auto-lock timeout 926 // auto-lock timeout
921 doc->timer()->start(DocTimer::id_autoLockTimer); 927 doc->timer()->start(DocTimer::id_autoLockTimer);
922 ++i; 928 ++i;
923 } 929 }
924 930
925 const QValueList<PwM *> *ml = init->mainWndList(); 931 const Q3ValueList<PwM *> *ml = init->mainWndList();
926#ifndef PWM_EMBEDDED 932#ifndef PWM_EMBEDDED
927 QValueList<PwM *>::const_iterator i2 = ml->begin(), 933 Q3ValueList<PwM *>::const_iterator i2 = ml->begin(),
928 end2 = ml->end(); 934 end2 = ml->end();
929#else 935#else
930 QValueList<PwM *>::ConstIterator i2 = ml->begin(), 936 Q3ValueList<PwM *>::ConstIterator i2 = ml->begin(),
931 end2 = ml->end(); 937 end2 = ml->end();
932#endif 938#endif
933 PwM *pwm; 939 PwM *pwm;
934 while (i2 != end2) { 940 while (i2 != end2) {
935 pwm = *i2; 941 pwm = *i2;
936 // reinitialize the window style. 942 // reinitialize the window style.
937 if (oldStyle != newStyle) 943 if (oldStyle != newStyle)
938 pwm->curView()->initStyle(newStyle); 944 pwm->curView()->initStyle(newStyle);
939 // set the new font 945 // set the new font
940 pwm->curView()->setFont(conf()->confGlobEntryFont()); 946 pwm->curView()->setFont(conf()->confGlobEntryFont());
941 ++i2; 947 ++i2;
942 } 948 }
943} 949}
944 950
945void PwM::activateMpButton(bool activate) 951void PwM::activateMpButton(bool activate)
946{ 952{
947 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, activate); 953 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, activate);
948} 954}
949 955
950void PwM::closeEvent(QCloseEvent *e) 956void PwM::closeEvent(QCloseEvent *e)
951{ 957{
952 //qDebug("PwM::closeEvent "); 958 //qDebug("PwM::closeEvent ");
953 emit closed( this ); 959 emit closed( this );
954 return; 960 return;
955 e->accept(); 961 e->accept();
956} 962}
957 963
958void PwM::docClosed(PwMDoc *doc) 964void PwM::docClosed(PwMDoc *doc)
959{ 965{
960 //qDebug("PwM::docClosed "); 966 //qDebug("PwM::docClosed ");
961 PARAM_UNUSED(doc); 967 PARAM_UNUSED(doc);
962 PWM_ASSERT(doc == curDoc()); 968 PWM_ASSERT(doc == curDoc());
963 close(); 969 close();
964} 970}
965 971
966void PwM::find_slot() 972void PwM::find_slot()
967{ 973{
968 PWM_ASSERT(curDoc()); 974 PWM_ASSERT(curDoc());
969 if (curDoc()->isDocEmpty()) 975 if (curDoc()->isDocEmpty())
970 return; 976 return;
971 if (curDoc()->isDeepLocked()) 977 if (curDoc()->isDeepLocked())
972 return; 978 return;
973 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 979 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
974 FindWndImpl findWnd(view); 980 FindWndImpl findWnd(view);
975 findWnd.exec(); 981 findWnd.exec();
976 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 982 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
977} 983}
978 984
979void PwM::exportToText() 985void PwM::exportToText()
980{ 986{
981 PWM_ASSERT(curDoc()); 987 PWM_ASSERT(curDoc());
982 if (curDoc()->isDocEmpty()) { 988 if (curDoc()->isDocEmpty()) {
983 KMessageBox::information(this, 989 KMessageBox::information(this,
984 i18n 990 i18n
985 ("Sorry, there's nothing to export.\n" 991 ("Sorry, there's nothing to export.\n"
986 "Please first add some passwords."), 992 "Please first add some passwords."),
987 i18n("nothing to do")); 993 i18n("nothing to do"));
988 return; 994 return;
989 } 995 }
990 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 996 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
991 QString fn(KFileDialog::getSaveFileName(QString::null, 997 QString fn(KFileDialog::getSaveFileName(QString::null,
992 i18n("*|plain-text file"), 998 i18n("*|plain-text file"),
993 this)); 999 this));
994 if (fn == "") { 1000 if (fn == "") {
995 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1001 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
996 return; 1002 return;
997 } 1003 }
998 1004
999 PwMerror ret = curDoc()->exportToText(&fn); 1005 PwMerror ret = curDoc()->exportToText(&fn);
1000 if (ret != e_success) { 1006 if (ret != e_success) {
1001 KMessageBox::error(this, 1007 KMessageBox::error(this,
1002 i18n("Error: Couldn't write to file.\n" 1008 i18n("Error: Couldn't write to file.\n"
1003 "Please check if you have permission to write\n" 1009 "Please check if you have permission to write\n"
1004 "to the file in that directory."), 1010 "to the file in that directory."),
1005 i18n("error while writing")); 1011 i18n("error while writing"));
1006 } else 1012 } else
1007 showStatMsg(i18n("Successfully exported data.")); 1013 showStatMsg(i18n("Successfully exported data."));
1008 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1014 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1009} 1015}
1010 1016
1011bool PwM::importFromText() 1017bool PwM::importFromText()
1012{ 1018{
1013 if (!isVirgin()) { 1019 if (!isVirgin()) {
1014 if (KMessageBox::questionYesNo(this, 1020 if (KMessageBox::questionYesNo(this,
1015 i18n("Do you want to import the data\n" 1021 i18n("Do you want to import the data\n"
1016 "into the current document? (If you\n" 1022 "into the current document? (If you\n"
1017 "select \"no\", a new document will be\n" 1023 "select \"no\", a new document will be\n"
1018 "opened.)"), 1024 "opened.)"),
1019 i18n("import into this document?")) 1025 i18n("import into this document?"))
1020 == KMessageBox::No) { 1026 == KMessageBox::No) {
1021 // import the data to a new window. 1027 // import the data to a new window.
1022 PwM *newInstance = init->createMainWnd(); 1028 PwM *newInstance = init->createMainWnd();
1023 bool ok = newInstance->importFromText(); 1029 bool ok = newInstance->importFromText();
1024 if (!ok) { 1030 if (!ok) {
1025 newInstance->setForceQuit(true); 1031 newInstance->setForceQuit(true);
1026 delete_and_null(newInstance); 1032 delete_and_null(newInstance);
1027 } 1033 }
1028 return ok; 1034 return ok;
1029 } 1035 }
1030 } 1036 }
1031 1037
1032 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1038 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1033 PwMerror ret; 1039 PwMerror ret;
1034 QString path(KFileDialog::getOpenFileName(QString::null, 1040 QString path(KFileDialog::getOpenFileName(QString::null,
1035 i18n("*|PWM-exported text file"), 1041 i18n("*|PWM-exported text file"),
1036 this)); 1042 this));
1037 if (path == "") 1043 if (path == "")
1038 goto cancelImport; 1044 goto cancelImport;
1039 1045
1040 ret = curDoc()->importFromText(&path, 0); 1046 ret = curDoc()->importFromText(&path, 0);
1041 if (ret == e_fileFormat) { 1047 if (ret == e_fileFormat) {
1042 KMessageBox::error(this, 1048 KMessageBox::error(this,
1043 i18n("Could not read file-format.\n" 1049 i18n("Could not read file-format.\n"
1044 "This seems to be _not_ a valid file\n" 1050 "This seems to be _not_ a valid file\n"
1045 "exported by PwM."), 1051 "exported by PwM."),
1046 i18n("invalid file-format")); 1052 i18n("invalid file-format"));
1047 goto cancelImport; 1053 goto cancelImport;
1048 } else if (ret == e_invalidArg) { 1054 } else if (ret == e_invalidArg) {
1049 BUG(); 1055 BUG();
1050 goto cancelImport; 1056 goto cancelImport;
1051 } else if (ret != e_success) { 1057 } else if (ret != e_success) {
1052 KMessageBox::error(this, 1058 KMessageBox::error(this,
1053 i18n("Could not import file!\n" 1059 i18n("Could not import file!\n"
1054 "Do you have permission to read this file?\n" 1060 "Do you have permission to read this file?\n"
1055 "Do you have enough free memory?"), 1061 "Do you have enough free memory?"),
1056 i18n("import failed")); 1062 i18n("import failed"));
1057 goto cancelImport; 1063 goto cancelImport;
1058 } 1064 }
1059 setVirgin(false); 1065 setVirgin(false);
1060 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1066 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1061 return true; 1067 return true;
1062 1068
1063cancelImport: 1069cancelImport:
1064 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1070 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1065 return false; 1071 return false;
1066} 1072}
1067 1073
1068void PwM::exportToGpasman() 1074void PwM::exportToGpasman()
1069{ 1075{
1070 PWM_ASSERT(curDoc()); 1076 PWM_ASSERT(curDoc());
1071 if (curDoc()->isDocEmpty()) { 1077 if (curDoc()->isDocEmpty()) {
1072 KMessageBox::information(this, 1078 KMessageBox::information(this,
1073 i18n 1079 i18n
1074 ("Sorry, there's nothing to export.\n" 1080 ("Sorry, there's nothing to export.\n"
1075 "Please first add some passwords."), 1081 "Please first add some passwords."),
1076 i18n("nothing to do")); 1082 i18n("nothing to do"));
1077 return; 1083 return;
1078 } 1084 }
1079 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1085 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1080 QString fn(KFileDialog::getSaveFileName(QString::null, 1086 QString fn(KFileDialog::getSaveFileName(QString::null,
1081 i18n("*|Gpasman or Kpasman file"), 1087 i18n("*|Gpasman or Kpasman file"),
1082 this)); 1088 this));
1083 if (fn == "") { 1089 if (fn == "") {
1084 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1090 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1085 return; 1091 return;
1086 } 1092 }
1087 1093
1088 PwMerror ret = curDoc()->exportToGpasman(&fn); 1094 PwMerror ret = curDoc()->exportToGpasman(&fn);
1089 if (ret != e_success) { 1095 if (ret != e_success) {
1090 if (ret == e_noPw) { 1096 if (ret == e_noPw) {
1091 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1097 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1092 return; 1098 return;
1093 } 1099 }
1094 KMessageBox::error(this, 1100 KMessageBox::error(this,
1095 i18n("Error: Couldn't write to file.\n" 1101 i18n("Error: Couldn't write to file.\n"
1096 "Please check if you have permission to write " 1102 "Please check if you have permission to write "
1097 "to the file in that directory."), 1103 "to the file in that directory."),
1098 i18n("error while writing")); 1104 i18n("error while writing"));
1099 } else 1105 } else
1100 showStatMsg(i18n("Successfully exported data.")); 1106 showStatMsg(i18n("Successfully exported data."));
1101 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1107 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1102} 1108}
1103 1109
1104 1110
1105 1111
1106void PwM::exportToCsv() 1112void PwM::exportToCsv()
1107{ 1113{
1108 PWM_ASSERT(curDoc()); 1114 PWM_ASSERT(curDoc());
1109 if (curDoc()->isDocEmpty()) { 1115 if (curDoc()->isDocEmpty()) {
1110 KMessageBox::information(this, 1116 KMessageBox::information(this,
1111 i18n 1117 i18n
1112 ("Sorry, there is nothing to export;\n" 1118 ("Sorry, there is nothing to export;\n"
1113 "please add some passwords first."), 1119 "please add some passwords first."),
1114 i18n("Nothing to Do")); 1120 i18n("Nothing to Do"));
1115 return; 1121 return;
1116 } 1122 }
1117 1123
1118 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1124 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1119 QString fn(KFileDialog::getSaveFileName("*.csv", i18n("*|CSV Text File"), this)); 1125 QString fn(KFileDialog::getSaveFileName("*.csv", i18n("*|CSV Text File"), this));
1120 if (fn.isEmpty()) { 1126 if (fn.isEmpty()) {
1121 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1127 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1122 return; 1128 return;
1123 } 1129 }
1124 1130
1125 Csv csv(this); 1131 Csv csv(this);
1126 if (!csv.exportData(fn, curDoc())) { 1132 if (!csv.exportData(fn, curDoc())) {
1127 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1133 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1128 showStatMsg(i18n("CSV file export failed.")); 1134 showStatMsg(i18n("CSV file export failed."));
1129 return; 1135 return;
1130 } 1136 }
1131 showStatMsg(i18n("Successfully exported data.")); 1137 showStatMsg(i18n("Successfully exported data."));
1132 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1138 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1133} 1139}
1134 1140
1135bool PwM::importCsv() 1141bool PwM::importCsv()
1136{ 1142{
1137 Csv csv(this); 1143 Csv csv(this);
1138 if (!isVirgin()) { 1144 if (!isVirgin()) {
1139 if (KMessageBox::questionYesNo(this, 1145 if (KMessageBox::questionYesNo(this,
1140 i18n("Do you want to import the data\n" 1146 i18n("Do you want to import the data\n"
1141 "into the current document? (If you\n" 1147 "into the current document? (If you\n"
1142 "select \"no\", a new document will be\n" 1148 "select \"no\", a new document will be\n"
1143 "opened.)"), 1149 "opened.)"),
1144 i18n("Import into This Document?")) 1150 i18n("Import into This Document?"))
1145 == KMessageBox::No) { 1151 == KMessageBox::No) {
1146 // import the data to a new window. 1152 // import the data to a new window.
1147 PwM *newInstance = init->createMainWnd(); 1153 PwM *newInstance = init->createMainWnd();
1148 bool ok = newInstance->importCsv(); 1154 bool ok = newInstance->importCsv();
1149 if (!ok) { 1155 if (!ok) {
1150 newInstance->setForceQuit(true); 1156 newInstance->setForceQuit(true);
1151 delete_and_null(newInstance); 1157 delete_and_null(newInstance);
1152 } 1158 }
1153 return ok; 1159 return ok;
1154 } 1160 }
1155 } 1161 }
1156 1162
1157 QString filename = KFileDialog::getOpenFileName("*.csv", i18n("*|CSV Text File"), this); 1163 QString filename = KFileDialog::getOpenFileName("*.csv", i18n("*|CSV Text File"), this);
1158 if (filename.isEmpty()) 1164 if (filename.isEmpty())
1159 return false; 1165 return false;
1160 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1166 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1161 if (!csv.importData(filename, curDoc())) { 1167 if (!csv.importData(filename, curDoc())) {
1162 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1168 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1163 showStatMsg(i18n("CSV file import failed.")); 1169 showStatMsg(i18n("CSV file import failed."));
1164 return false; 1170 return false;
1165 } 1171 }
1166 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1172 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1167 KMessageBox::information(this, 1173 KMessageBox::information(this,
1168 i18n("Successfully imported the CSV data\n" 1174 i18n("Successfully imported the CSV data\n"
1169 "into the current document."), i18n("Successfully Imported")); 1175 "into the current document."), i18n("Successfully Imported"));
1170 showStatMsg(i18n("Successfully imported")); 1176 showStatMsg(i18n("Successfully imported"));
1171 setVirgin(false); 1177 setVirgin(false);
1172 return true; 1178 return true;
1173} 1179}
1174 1180
1175 1181
1176void PwM::exportToKWallet() 1182void PwM::exportToKWallet()
1177{ 1183{
1178#ifdef CONFIG_KWALLETIF 1184#ifdef CONFIG_KWALLETIF
1179 if (!checkAndAskForKWalletEmu()) 1185 if (!checkAndAskForKWalletEmu())
1180 return; 1186 return;
1181 PWM_ASSERT(curDoc()); 1187 PWM_ASSERT(curDoc());
1182 if (curDoc()->isDocEmpty()) { 1188 if (curDoc()->isDocEmpty()) {
1183 KMessageBox::information(this, 1189 KMessageBox::information(this,
1184 i18n 1190 i18n
1185 ("Sorry, there's nothing to export.\n" 1191 ("Sorry, there's nothing to export.\n"
1186 "Please first add some passwords."), 1192 "Please first add some passwords."),
1187 i18n("nothing to do")); 1193 i18n("nothing to do"));
1188 init->initKWalletEmu(); 1194 init->initKWalletEmu();
1189 return; 1195 return;
1190 } 1196 }
1191 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1197 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1192 KWalletIf walletIf(this); 1198 KWalletIf walletIf(this);
1193 if (walletIf.kwalletExport(curDoc())) { 1199 if (walletIf.kwalletExport(curDoc())) {
1194 KMessageBox::information(this, 1200 KMessageBox::information(this,
1195 i18n("Successfully exported the data of the current " 1201 i18n("Successfully exported the data of the current "
1196 "document to KWallet."), 1202 "document to KWallet."),
1197 i18n("Successfully exported data.")); 1203 i18n("Successfully exported data."));
1198 showStatMsg(i18n("Successfully exported data.")); 1204 showStatMsg(i18n("Successfully exported data."));
1199 } 1205 }
1200 init->initKWalletEmu(); 1206 init->initKWalletEmu();
1201 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1207 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1202#endif // CONFIG_KWALLETIF 1208#endif // CONFIG_KWALLETIF
1203} 1209}
1204 1210
1205bool PwM::importFromGpasman() 1211bool PwM::importFromGpasman()
1206{ 1212{
1207 if (!isVirgin()) { 1213 if (!isVirgin()) {
1208 if (KMessageBox::questionYesNo(this, 1214 if (KMessageBox::questionYesNo(this,
1209 i18n("Do you want to import the data\n" 1215 i18n("Do you want to import the data\n"
1210 "into the current document? (If you\n" 1216 "into the current document? (If you\n"
1211 "select \"no\", a new document will be\n" 1217 "select \"no\", a new document will be\n"
1212 "opened.)"), 1218 "opened.)"),
1213 i18n("import into this document?")) 1219 i18n("import into this document?"))
1214 == KMessageBox::No) { 1220 == KMessageBox::No) {
1215 // import the data to a new window. 1221 // import the data to a new window.
1216 PwM *newInstance = init->createMainWnd(); 1222 PwM *newInstance = init->createMainWnd();
1217 bool ok = newInstance->importFromGpasman(); 1223 bool ok = newInstance->importFromGpasman();
1218 if (!ok) { 1224 if (!ok) {
1219 newInstance->setForceQuit(true); 1225 newInstance->setForceQuit(true);
1220 delete_and_null(newInstance); 1226 delete_and_null(newInstance);
1221 } 1227 }
1222 return ok; 1228 return ok;
1223 } 1229 }
1224 } 1230 }
1225 1231
1226 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1232 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1227 PwMerror ret; 1233 PwMerror ret;
1228 QString path(KFileDialog::getOpenFileName(QString::null, 1234 QString path(KFileDialog::getOpenFileName(QString::null,
1229 i18n("*|Gpasman or Kpasman file"), this)); 1235 i18n("*|Gpasman or Kpasman file"), this));
1230 if (path == "") 1236 if (path == "")
1231 goto cancelImport; 1237 goto cancelImport;
1232 ret = curDoc()->importFromGpasman(&path); 1238 ret = curDoc()->importFromGpasman(&path);
1233 if (ret == e_wrongPw) { 1239 if (ret == e_wrongPw) {
1234 if (KMessageBox::questionYesNo(this, 1240 if (KMessageBox::questionYesNo(this,
1235 i18n 1241 i18n
1236 ("This is probably the wrong master-password\n" 1242 ("This is probably the wrong master-password\n"
1237 "you have typed in.\n" 1243 "you have typed in.\n"
1238 "There is no real way to determine the\n" 1244 "There is no real way to determine the\n"
1239 "correctness of the password in the Gpasman\n" 1245 "correctness of the password in the Gpasman\n"
1240 "file-format. But I think this\n" 1246 "file-format. But I think this\n"
1241 "password ist wrong.\n" 1247 "password ist wrong.\n"
1242 "Do you want to continue nevertheless?"), 1248 "Do you want to continue nevertheless?"),
1243 i18n("password error")) 1249 i18n("password error"))
1244 == KMessageBox::No) { 1250 == KMessageBox::No) {
1245 goto cancelImport; 1251 goto cancelImport;
1246 } 1252 }
1247 } else if (ret != e_success) { 1253 } else if (ret != e_success) {
1248 KMessageBox::error(this, 1254 KMessageBox::error(this,
1249 i18n("Could not import file!\n" 1255 i18n("Could not import file!\n"
1250 "Do you have permission to read this file?"), 1256 "Do you have permission to read this file?"),
1251 i18n("import failed")); 1257 i18n("import failed"));
1252 goto cancelImport; 1258 goto cancelImport;
1253 } 1259 }
1254 setVirgin(false); 1260 setVirgin(false);
1255 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1261 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1256 return true; 1262 return true;
1257 1263
1258cancelImport: 1264cancelImport:
1259 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1265 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1260 return false; 1266 return false;
1261} 1267}
1262 1268
1263#ifdef CONFIG_KWALLETIF 1269#ifdef CONFIG_KWALLETIF
1264bool PwM::checkAndAskForKWalletEmu() 1270bool PwM::checkAndAskForKWalletEmu()
1265{ 1271{
1266 if (init->kwalletEmu()) { 1272 if (init->kwalletEmu()) {
1267 /* KWallet emulation is enabled. We can't import/export 1273 /* KWallet emulation is enabled. We can't import/export
1268 * data from/to it, while emulation is active. 1274 * data from/to it, while emulation is active.
1269 */ 1275 */
1270 if (KMessageBox::questionYesNo(this, 1276 if (KMessageBox::questionYesNo(this,
1271 i18n("KWallet emulation is enabled.\n" 1277 i18n("KWallet emulation is enabled.\n"
1272 "You can't import or export data from/to " 1278 "You can't import or export data from/to "
1273 "the original KWallet, while the emulation " 1279 "the original KWallet, while the emulation "
1274 "is active.\n" 1280 "is active.\n"
1275 "Do you want to tempoarly disable the KWallet emulation?"), 1281 "Do you want to tempoarly disable the KWallet emulation?"),
1276 i18n("Tempoarly disable KWallet emulation?")) 1282 i18n("Tempoarly disable KWallet emulation?"))
1277 == KMessageBox::Yes) { 1283 == KMessageBox::Yes) {
1278 init->initKWalletEmu(true); 1284 init->initKWalletEmu(true);
1279 PWM_ASSERT(!init->kwalletEmu()); 1285 PWM_ASSERT(!init->kwalletEmu());
1280 return true; 1286 return true;
1281 } 1287 }
1282 return false; 1288 return false;
1283 } 1289 }
1284 return true; 1290 return true;
1285} 1291}
1286#endif // CONFIG_KWALLETIF 1292#endif // CONFIG_KWALLETIF
1287 1293
1288bool PwM::importKWallet() 1294bool PwM::importKWallet()
1289{ 1295{
1290#ifdef CONFIG_KWALLETIF 1296#ifdef CONFIG_KWALLETIF
1291 if (!checkAndAskForKWalletEmu()) 1297 if (!checkAndAskForKWalletEmu())
1292 return false; 1298 return false;
1293 KWalletIf walletIf(this); 1299 KWalletIf walletIf(this);
1294 if (!isVirgin()) { 1300 if (!isVirgin()) {
1295 if (KMessageBox::questionYesNo(this, 1301 if (KMessageBox::questionYesNo(this,
1296 i18n("Do you want to import the data " 1302 i18n("Do you want to import the data "
1297 "into the current document? (If you " 1303 "into the current document? (If you "
1298 "select \"no\", a new document will be " 1304 "select \"no\", a new document will be "
1299 "opened.)"), 1305 "opened.)"),
1300 i18n("import into this document?")) 1306 i18n("import into this document?"))
1301 == KMessageBox::No) { 1307 == KMessageBox::No) {
1302 // import the data to a new window. 1308 // import the data to a new window.
1303 PwM *newInstance = init->createMainWnd(); 1309 PwM *newInstance = init->createMainWnd();
1304 bool ok = newInstance->importKWallet(); 1310 bool ok = newInstance->importKWallet();
1305 if (!ok) { 1311 if (!ok) {
1306 newInstance->setForceQuit(true); 1312 newInstance->setForceQuit(true);
1307 delete_and_null(newInstance); 1313 delete_and_null(newInstance);
1308 goto exit_fail; 1314 goto exit_fail;
1309 } else { 1315 } else {
1310 goto exit_ok; 1316 goto exit_ok;
1311 } 1317 }
1312 } 1318 }
1313 } 1319 }
1314 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1320 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1315 if (!walletIf.kwalletImport(curDoc())) { 1321 if (!walletIf.kwalletImport(curDoc())) {
1316 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1322 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1317 showStatMsg(i18n("KWallet import failed")); 1323 showStatMsg(i18n("KWallet import failed"));
1318 goto exit_fail; 1324 goto exit_fail;
1319 } 1325 }
1320 KMessageBox::information(this, 1326 KMessageBox::information(this,
1321 i18n("Successfully imported the KWallet data " 1327 i18n("Successfully imported the KWallet data "
1322 "into the current document."), 1328 "into the current document."),
1323 i18n("successfully imported")); 1329 i18n("successfully imported"));
1324 showStatMsg(i18n("successfully imported")); 1330 showStatMsg(i18n("successfully imported"));
1325 setVirgin(false); 1331 setVirgin(false);
1326 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1332 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1327 1333
1328exit_ok: 1334exit_ok:
1329 init->initKWalletEmu(); 1335 init->initKWalletEmu();
1330 return true; 1336 return true;
1331 1337
1332exit_fail: 1338exit_fail:
1333 init->initKWalletEmu(); 1339 init->initKWalletEmu();
1334#endif // CONFIG_KWALLETIF 1340#endif // CONFIG_KWALLETIF
1335 return false; 1341 return false;
1336} 1342}
1337 1343
1338void PwM::print_slot() 1344void PwM::print_slot()
1339{ 1345{
1340 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1346 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1341#ifndef PWM_EMBEDDED 1347#ifndef PWM_EMBEDDED
1342 PwMPrint p(curDoc(), this); 1348 PwMPrint p(curDoc(), this);
1343 p.printNow(); 1349 p.printNow();
1344#else 1350#else
1345 qDebug("PwM::print_slot , PRINTING IS NOT IMPLEMENTED"); 1351 qDebug("PwM::print_slot , PRINTING IS NOT IMPLEMENTED");
1346#endif 1352#endif
1347 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1353 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1348} 1354}
1349 1355
1350void PwM::genNewCard_slot() 1356void PwM::genNewCard_slot()
1351{ 1357{
1352#ifdef CONFIG_KEYCARD 1358#ifdef CONFIG_KEYCARD
1353 init->keycard()->genNewCard(); 1359 init->keycard()->genNewCard();
1354#endif 1360#endif
1355} 1361}
1356 1362
1357void PwM::eraseCard_slot() 1363void PwM::eraseCard_slot()
1358{ 1364{
1359#ifdef CONFIG_KEYCARD 1365#ifdef CONFIG_KEYCARD
1360 init->keycard()->eraseCard(); 1366 init->keycard()->eraseCard();
1361#endif 1367#endif
1362} 1368}
1363 1369
1364void PwM::readCardId_slot() 1370void PwM::readCardId_slot()
1365{ 1371{
1366#ifdef CONFIG_KEYCARD 1372#ifdef CONFIG_KEYCARD
1367 init->keycard()->displayKey(); 1373 init->keycard()->displayKey();
1368#endif 1374#endif
1369} 1375}
1370 1376
1371void PwM::makeCardBackup_slot() 1377void PwM::makeCardBackup_slot()
1372{ 1378{
1373#ifdef CONFIG_KEYCARD 1379#ifdef CONFIG_KEYCARD
1374 init->keycard()->makeBackupImage(); 1380 init->keycard()->makeBackupImage();
1375#endif 1381#endif
1376} 1382}
1377 1383
1378void PwM::replayCardBackup_slot() 1384void PwM::replayCardBackup_slot()
1379{ 1385{
1380#ifdef CONFIG_KEYCARD 1386#ifdef CONFIG_KEYCARD
1381 init->keycard()->replayBackupImage(); 1387 init->keycard()->replayBackupImage();
1382#endif 1388#endif
1383} 1389}
1384 1390
1385void PwM::execLauncher_slot() 1391void PwM::execLauncher_slot()
1386{ 1392{
1387 PWM_ASSERT(curDoc()); 1393 PWM_ASSERT(curDoc());
1388 if (curDoc()->isDeepLocked()) 1394 if (curDoc()->isDeepLocked())
1389 return; 1395 return;
1390 unsigned int curEntryIndex; 1396 unsigned int curEntryIndex;
1391 if (!view->getCurEntryIndex(&curEntryIndex)) 1397 if (!view->getCurEntryIndex(&curEntryIndex))
1392 return; 1398 return;
1393 bool ret = curDoc()->execLauncher(view->getCurrentCategory(), 1399 bool ret = curDoc()->execLauncher(view->getCurrentCategory(),
1394 curEntryIndex); 1400 curEntryIndex);
1395 if (ret) 1401 if (ret)
1396 showStatMsg(i18n("Executed the \"Launcher\".")); 1402 showStatMsg(i18n("Executed the \"Launcher\"."));
1397 else 1403 else
1398 showStatMsg(i18n("ERROR: Couldn't execute the \"Launcher\"!")); 1404 showStatMsg(i18n("ERROR: Couldn't execute the \"Launcher\"!"));
1399} 1405}
1400 1406
1401void PwM::goToURL_slot() 1407void PwM::goToURL_slot()
1402{ 1408{
1403 PWM_ASSERT(curDoc()); 1409 PWM_ASSERT(curDoc());
1404 if (curDoc()->isDeepLocked()) 1410 if (curDoc()->isDeepLocked())
1405 return; 1411 return;
1406 unsigned int curEntryIndex; 1412 unsigned int curEntryIndex;
1407 if (!view->getCurEntryIndex(&curEntryIndex)) 1413 if (!view->getCurEntryIndex(&curEntryIndex))
1408 return; 1414 return;
1409 bool ret = curDoc()->goToURL(view->getCurrentCategory(), 1415 bool ret = curDoc()->goToURL(view->getCurrentCategory(),
1410 curEntryIndex); 1416 curEntryIndex);
1411 if (ret) 1417 if (ret)
1412 showStatMsg(i18n("started browser with current URL.")); 1418 showStatMsg(i18n("started browser with current URL."));
1413 else 1419 else
1414 showStatMsg(i18n("ERROR: Couldn't start browser! Maybe invalid URL?")); 1420 showStatMsg(i18n("ERROR: Couldn't start browser! Maybe invalid URL?"));
1415} 1421}
1416 1422
1417void PwM::copyToClipboard(const QString &s) 1423void PwM::copyToClipboard(const QString &s)
1418{ 1424{
1419 QClipboard *cb = QApplication::clipboard(); 1425 QClipboard *cb = QApplication::clipboard();
1420#ifndef PWM_EMBEDDED 1426#ifndef PWM_EMBEDDED
1421 if (cb->supportsSelection()) 1427 if (cb->supportsSelection())
1422 cb->setText(s, QClipboard::Selection); 1428 cb->setText(s, QClipboard::Selection);
1423 cb->setText(s, QClipboard::Clipboard); 1429 cb->setText(s, QClipboard::Clipboard);
1424#else 1430#else
1425 cb->setText(s); 1431 cb->setText(s);
1426 1432
1427#endif 1433#endif
1428 1434
1429} 1435}
1430 1436
1431 1437
1432void PwM::showStatMsg(const QString &msg) 1438void PwM::showStatMsg(const QString &msg)
1433{ 1439{
1434#ifdef DESKTOP_VERSION 1440#ifdef DESKTOP_VERSION
1435 statusBar()->message(msg, STATUSBAR_MSG_TIMEOUT * 1000); 1441 statusBar()->message(msg, STATUSBAR_MSG_TIMEOUT * 1000);
1436#else 1442#else
1437 //qDebug("Statusbar : %s",msg.latin1()); 1443 //qDebug("Statusbar : %s",msg.latin1());
1438 Global::statusMessage(msg); 1444 Global::statusMessage(msg);
1439#endif 1445#endif
1440} 1446}
1441 1447
1442void PwM::focusInEvent(QFocusEvent *e) 1448void PwM::focusInEvent(QFocusEvent *e)
1443{ 1449{
1444 if (e->gotFocus()) { 1450 if (e->gotFocus()) {
1445 emit gotFocus(this); 1451 emit gotFocus(this);
1446 } else if (e->lostFocus()) { 1452 } else if (e->lostFocus()) {
1447 emit lostFocus(this); 1453 emit lostFocus(this);
1448 } 1454 }
1449} 1455}
1450 1456
1451 1457
1452#ifdef PWM_EMBEDDED 1458#ifdef PWM_EMBEDDED
1453 1459
1454void PwM::category_slot() 1460void PwM::category_slot()
1455{ 1461{
1456 PwMDoc *doc = curDoc(); 1462 PwMDoc *doc = curDoc();
1457 PWM_ASSERT(doc); 1463 PWM_ASSERT(doc);
1458 doc->timer()->getLock(DocTimer::id_autoLockTimer); 1464 doc->timer()->getLock(DocTimer::id_autoLockTimer);
1459 1465
1460 editCategoryWnd w(doc, this, "editcategory"); 1466 editCategoryWnd w(doc, this, "editcategory");
1461/* 1467/*
1462 vector<string> catList; 1468 vector<string> catList;
1463 doc->getCategoryList(&catList); 1469 doc->getCategoryList(&catList);
1464 unsigned i, size = catList.size(); 1470 unsigned i, size = catList.size();
1465 for (i = 0; i < size; ++i) { 1471 for (i = 0; i < size; ++i) {
1466 w.addCategory(catList[i].c_str()); 1472 w.addCategory(catList[i].c_str());
1467 } 1473 }
1468 w.setCurrCategory(view->getCurrentCategory()); 1474 w.setCurrCategory(view->getCurrentCategory());
1469 if (pw) 1475 if (pw)
1470 w.pwLineEdit->setText(*pw); 1476 w.pwLineEdit->setText(*pw);
1471*/ 1477*/
1472 w.setCurrCategory(view->getCurrentCategory()); 1478 w.setCurrCategory(view->getCurrentCategory());
1473 1479
1474 tryAgain: 1480 tryAgain:
1475 if (w.exec() == 1) 1481 if (w.exec() == 1)
1476 { 1482 {
1477 PwMDataItem d; 1483 PwMDataItem d;
1478 1484
1479 //US BUG: to initialize all values of curEntr with meaningfulldata, 1485 //US BUG: to initialize all values of curEntr with meaningfulldata,
1480 // we call clear on it. Reason: Metadata will be uninitialized otherwise. 1486 // we call clear on it. Reason: Metadata will be uninitialized otherwise.
1481 // another option would be to create a constructor for PwMDataItem 1487 // another option would be to create a constructor for PwMDataItem
1482 d.clear(true); 1488 d.clear(true);
1483 /* 1489 /*
1484 d.desc = w.getDescription().latin1(); 1490 d.desc = w.getDescription().latin1();
1485 d.name = w.getUsername().latin1(); 1491 d.name = w.getUsername().latin1();
1486 d.pw = w.getPassword().latin1(); 1492 d.pw = w.getPassword().latin1();
1487 d.comment = w.getComment().latin1(); 1493 d.comment = w.getComment().latin1();
1488 d.url = w.getUrl().latin1(); 1494 d.url = w.getUrl().latin1();
1489 d.launcher = w.getLauncher().latin1(); 1495 d.launcher = w.getLauncher().latin1();
1490 PwMerror ret = doc->addEntry(w.getCategory(), &d); 1496 PwMerror ret = doc->addEntry(w.getCategory(), &d);
1491 if (ret == e_entryExists) { 1497 if (ret == e_entryExists) {
1492 KMessageBox::error(this, 1498 KMessageBox::error(this,
1493 i18n 1499 i18n
1494 ("An entry with this \"Description\",\n" 1500 ("An entry with this \"Description\",\n"
1495 "does already exist.\n" 1501 "does already exist.\n"
1496 "Please select another description."), 1502 "Please select another description."),
1497 i18n("entry already exists.")); 1503 i18n("entry already exists."));
1498 goto tryAgain; 1504 goto tryAgain;
1499 } else if (ret == e_maxAllowedEntr) { 1505 } else if (ret == e_maxAllowedEntr) {
1500 KMessageBox::error(this, i18n("The maximum possible number of\nentries" 1506 KMessageBox::error(this, i18n("The maximum possible number of\nentries"
1501 "has been reached.\nYou can't add more entries."), 1507 "has been reached.\nYou can't add more entries."),
1502 i18n("maximum number of entries")); 1508 i18n("maximum number of entries"));
1503 doc->timer()->putLock(DocTimer::id_autoLockTimer); 1509 doc->timer()->putLock(DocTimer::id_autoLockTimer);
1504 return; 1510 return;
1505 } 1511 }
1506 */ 1512 */
1507 } 1513 }
1508 setVirgin(false); 1514 setVirgin(false);
1509 doc->timer()->putLock(DocTimer::id_autoLockTimer); 1515 doc->timer()->putLock(DocTimer::id_autoLockTimer);
1510} 1516}
1511 1517
1512 1518
1513void PwM::whatsnew_slot() 1519void PwM::whatsnew_slot()
1514{ 1520{
1515 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 1521 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
1516} 1522}
1517 1523
1518void PwM::showLicense_slot() 1524void PwM::showLicense_slot()
1519{ 1525{
1520 KApplication::showLicence(); 1526 KApplication::showLicence();
1521} 1527}
1522 1528
1523void PwM::faq_slot() 1529void PwM::faq_slot()
1524{ 1530{
1525 KApplication::showFile( "PWM/Pi FAQ", "kdepim/pwmanager/pwmanagerFAQ.txt" ); 1531 KApplication::showFile( "PWM/Pi FAQ", "kdepim/pwmanager/pwmanagerFAQ.txt" );
1526} 1532}
1527 1533
1528void PwM::syncHowTo_slot() 1534void PwM::syncHowTo_slot()
1529{ 1535{
1530 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 1536 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
1531} 1537}
1532 1538
1533 1539
1534void PwM::createAboutData_slot() 1540void PwM::createAboutData_slot()
1535{ 1541{
1536 QString version; 1542 QString version;
1537#include <../version> 1543#include <../version>
1538; 1544;
1539 QMessageBox::about( this, "About PwManager/Pi", 1545 QMessageBox::about( this, "About PwManager/Pi",
1540 "PwManager/Platform-independent\n" 1546 "PwManager/Platform-independent\n"
1541 "(PWM/Pi) " +version + " - " + 1547 "(PWM/Pi) " +version + " - " +
1542#ifdef DESKTOP_VERSION 1548#ifdef DESKTOP_VERSION
1543 "Desktop Edition\n" 1549 "Desktop Edition\n"
1544#else 1550#else
1545 "PDA-Edition\n" 1551 "PDA-Edition\n"
1546 "for: Zaurus 5500 / 7x0 / 8x0\n" 1552 "for: Zaurus 5500 / 7x0 / 8x0\n"
1547#endif 1553#endif
1548 1554
1549 "(c) 2004 Ulf Schenk\n" 1555 "(c) 2004 Ulf Schenk\n"
1550 "(c) 2004 Lutz Rogowski\n" 1556 "(c) 2004 Lutz Rogowski\n"
1551 "(c) 1997-2004, The KDE PIM Team\n" 1557 "(c) 1997-2004, The KDE PIM Team\n"
1552 1558
1553 "(c) Michael Buesch - main programming\nand current maintainer\nmbuesch@freenet.de\n" 1559 "(c) Michael Buesch - main programming\nand current maintainer\nmbuesch@freenet.de\n"
1554 "Matt Scifo - mscifo@o1.com\n" 1560 "Matt Scifo - mscifo@o1.com\n"
1555 "Elias Probst - elias.probst@gmx.de\n" 1561 "Elias Probst - elias.probst@gmx.de\n"
1556 "George Staikos - staikos@kde.org\n" 1562 "George Staikos - staikos@kde.org\n"
1557 "Matthew Palmer - mjp16@uow.edu.au\n" 1563 "Matthew Palmer - mjp16@uow.edu.au\n"
1558 "Olivier Sessink - gpasman@nl.linux.org\n" 1564 "Olivier Sessink - gpasman@nl.linux.org\n"
1559 "The libgcrypt developers -\nBlowfish and SHA1 algorithms\nftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/\n" 1565 "The libgcrypt developers -\nBlowfish and SHA1 algorithms\nftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/\n"
1560 "Troy Engel - tengel@sonic.net\n" 1566 "Troy Engel - tengel@sonic.net\n"
1561 "Wickey - wickey@gmx.at\n" 1567 "Wickey - wickey@gmx.at\n"
1562 "Ian MacGregor - original documentation author.\n" 1568 "Ian MacGregor - original documentation author.\n"
1563 ); 1569 );
1564} 1570}
1565 1571
1566 1572
1567//this are the overwritten callbackmethods from the syncinterface 1573//this are the overwritten callbackmethods from the syncinterface
1568bool PwM::sync(KSyncManager* manager, QString filename, int mode,QString resource) 1574bool PwM::sync(KSyncManager* manager, QString filename, int mode,QString resource)
1569{ 1575{
1570 PWM_ASSERT(curDoc()); 1576 PWM_ASSERT(curDoc());
1571 1577
1572 bool ret = curDoc()->sync(manager, filename, mode,resource); 1578 bool ret = curDoc()->sync(manager, filename, mode,resource);
1573 1579
1574 qDebug("PwM::sync save now: ret=%i", ret); 1580 qDebug("PwM::sync save now: ret=%i", ret);
1575 1581
1576 if (ret == true) { 1582 if (ret == true) {
1577 //US BUG: what can we call here to update the view of the current doc? 1583 //US BUG: what can we call here to update the view of the current doc?
1578 //mViewManager->refreshView(); 1584 //mViewManager->refreshView();
1579 1585
1580 //US curDoc()->sync sets the dirtyFlag in case the sync was successfull. 1586 //US curDoc()->sync sets the dirtyFlag in case the sync was successfull.
1581 save(); 1587 save();
1582 } 1588 }
1583 1589
1584 return ret; 1590 return ret;
1585} 1591}
1586 1592
1587void PwM::removeSyncInfo( QString syncProfile) 1593void PwM::removeSyncInfo( QString syncProfile)
1588{ 1594{
1589 qDebug("PWM:removeSyncInfo for profile %s ", syncProfile.latin1()); 1595 qDebug("PWM:removeSyncInfo for profile %s ", syncProfile.latin1());
1590 curDoc()->removeSyncInfo( syncProfile ); 1596 curDoc()->removeSyncInfo( syncProfile );
1591 //US curDoc()->removeSyncInfo sets the dirtyFlag. 1597 //US curDoc()->removeSyncInfo sets the dirtyFlag.
1592} 1598}
1593 1599
1594#endif 1600#endif
1595 1601
1596 1602
1597#ifndef PWM_EMBEDDED 1603#ifndef PWM_EMBEDDED_
1598#include "pwm.moc" 1604#include "moc_pwm.cpp"
1599#endif 1605#endif
diff --git a/pwmanager/pwmanager/pwm.h b/pwmanager/pwmanager/pwm.h
index c4bbb4e..450d13f 100644
--- a/pwmanager/pwmanager/pwm.h
+++ b/pwmanager/pwmanager/pwm.h
@@ -1,300 +1,305 @@
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_H 20#ifndef __PWM_H
21#define __PWM_H 21#define __PWM_H
22 22
23 23
24#include <kpopupmenu.h> 24#include <kpopupmenu.h>
25#include <klistview.h> 25#include <klistview.h>
26#include <kmainwindow.h> 26#include <kmainwindow.h>
27 27
28#ifndef PWM_EMBEDDED 28#ifndef PWM_EMBEDDED
29#include <kwin.h> 29#include <kwin.h>
30#include <kapp.h> 30#include <kapp.h>
31#include <kdeversion.h> 31#include <kdeversion.h>
32#else 32#else
33#include <ksyncmanager.h> 33#include <ksyncmanager.h>
34#endif 34#endif
35 35
36#include <kaction.h> 36#include <kaction.h>
37 37
38#include <qglobal.h> 38#include <qglobal.h>
39//Added by qt3to4:
40#include <QCloseEvent>
41#include <QFocusEvent>
42#include <Q3PopupMenu>
43#include <QHideEvent>
39 44
40#include "pwmview.h" 45#include "pwmview.h"
41#include "pwmexception.h" 46#include "pwmexception.h"
42 47
43 48
44/** timeout for displaying a message on the status-bar (in seconds) */ 49/** timeout for displaying a message on the status-bar (in seconds) */
45 #define STATUSBAR_MSG_TIMEOUT5 50 #define STATUSBAR_MSG_TIMEOUT5
46 51
47 52
48class PwMInit; 53class PwMInit;
49class KSyncManager; 54class KSyncManager;
50 55
51/** PwM is the base class of the project */ 56/** PwM is the base class of the project */
52#ifndef PWM_EMBEDDED 57#ifndef PWM_EMBEDDED
53//MOC_SKIP_BEGIN 58#ifndef Q_MOC_RUN
54class PwM : public KMainWindow 59class PwM : public KMainWindow
55//MOC_SKIP_END 60#endif
56#else 61#else
57class PwM : public KMainWindow, public KSyncInterface 62class PwM : public KMainWindow, public KSyncInterface
58#endif 63#endif
59{ 64{
60 Q_OBJECT 65 Q_OBJECT
61public: 66public:
62 friend class PwMView; 67 friend class PwMView;
63 /** construtor */ 68 /** construtor */
64 PwM(PwMInit *_init, PwMDoc *doc, 69 PwM(PwMInit *_init, PwMDoc *doc,
65 bool virginity = true, 70 bool virginity = true,
66 QWidget* parent = 0, const char *name = 0); 71 QWidget* parent = 0, const char *name = 0);
67 /** destructor */ 72 /** destructor */
68 ~PwM(); 73 ~PwM();
69 74
70 /** copy some text to the global clipboard */ 75 /** copy some text to the global clipboard */
71 static void copyToClipboard(const QString &s); 76 static void copyToClipboard(const QString &s);
72 77
73 /** returns pointer to the view */ 78 /** returns pointer to the view */
74 PwMView * curView() 79 PwMView * curView()
75 { return view; } 80 { return view; }
76 /** returns pointer to the currently using document. */ 81 /** returns pointer to the currently using document. */
77 PwMDoc * curDoc() 82 PwMDoc * curDoc()
78 { return curView()->document(); } 83 { return curView()->document(); }
79 /** open a new doc with the given filename */ 84 /** open a new doc with the given filename */
80 PwMDoc * openDoc(QString filename, bool openDeepLocked = false); 85 PwMDoc * openDoc(QString filename, bool openDeepLocked = false);
81 /** show a message on the global status bar. 86 /** show a message on the global status bar.
82 * The message times out after some seconds. 87 * The message times out after some seconds.
83 */ 88 */
84 void showStatMsg(const QString &msg); 89 void showStatMsg(const QString &msg);
85 /** ask the user where to save the doc (if it has not been saved, yet) 90 /** ask the user where to save the doc (if it has not been saved, yet)
86 * and write the data to disk. 91 * and write the data to disk.
87 */ 92 */
88 bool save(); 93 bool save();
89 /** ask the user where to save the doc 94 /** ask the user where to save the doc
90 * and write the data to disk. 95 * and write the data to disk.
91 */ 96 */
92 bool saveAs(); 97 bool saveAs();
93 /** force quit. Quit this window, always! Don't minimize it */ 98 /** force quit. Quit this window, always! Don't minimize it */
94 bool isForceQuit() 99 bool isForceQuit()
95 { return forceQuit; } 100 { return forceQuit; }
96 /** set forceQuit */ 101 /** set forceQuit */
97 void setForceQuit(bool force) 102 void setForceQuit(bool force)
98 { forceQuit = force; } 103 { forceQuit = force; }
99 /** force minimize this window */ 104 /** force minimize this window */
100 bool isForceMinimizeToTray() 105 bool isForceMinimizeToTray()
101 { return forceMinimizeToTray; } 106 { return forceMinimizeToTray; }
102 /** set forceMinimizeToTray */ 107 /** set forceMinimizeToTray */
103 void setForceMinimizeToTray(bool force) 108 void setForceMinimizeToTray(bool force)
104 { forceMinimizeToTray = force; } 109 { forceMinimizeToTray = force; }
105 110
106public slots: 111public slots:
107 /** file/new triggered */ 112 /** file/new triggered */
108 void new_slot(); 113 void new_slot();
109 /** file/open triggered */ 114 /** file/open triggered */
110//US ENH 115//US ENH
111 void open_slot(); 116 void open_slot();
112 void open_slot(QString fn); 117 void open_slot(QString fn);
113 /** file/close triggered */ 118 /** file/close triggered */
114 void close_slot(); 119 void close_slot();
115 /** file/quit triggered */ 120 /** file/quit triggered */
116 void quitButton_slot(); 121 void quitButton_slot();
117 /** file/save triggered */ 122 /** file/save triggered */
118 void save_slot(); 123 void save_slot();
119 /** file/saveAs triggered */ 124 /** file/saveAs triggered */
120 void saveAs_slot(); 125 void saveAs_slot();
121 /** file/export/text triggered */ 126 /** file/export/text triggered */
122 void exportToText(); 127 void exportToText();
123 /** file/export/gpasman triggered */ 128 /** file/export/gpasman triggered */
124 void exportToGpasman(); 129 void exportToGpasman();
125 /** file/export/kwallet triggered */ 130 /** file/export/kwallet triggered */
126 void exportToKWallet(); 131 void exportToKWallet();
127 /** file/export/csv triggered */ 132 /** file/export/csv triggered */
128 void exportToCsv(); 133 void exportToCsv();
129 /** file/import/text triggered */ 134 /** file/import/text triggered */
130 bool importFromText(); 135 bool importFromText();
131 /** file/import/gpasman triggered */ 136 /** file/import/gpasman triggered */
132 bool importFromGpasman(); 137 bool importFromGpasman();
133 /** file/import/kwallet triggered */ 138 /** file/import/kwallet triggered */
134 bool importKWallet(); 139 bool importKWallet();
135 /** file/import/csv triggered */ 140 /** file/import/csv triggered */
136 bool importCsv(); 141 bool importCsv();
137 /** file/print triggered */ 142 /** file/print triggered */
138 void print_slot(); 143 void print_slot();
139 /** manage/add triggered */ 144 /** manage/add triggered */
140 //US ENH : changed code to run with older MOC 145 //US ENH : changed code to run with older MOC
141 146
142 void addPwd_slot(); 147 void addPwd_slot();
143 void addPwd_slot1(QString *pw, PwMDoc *_doc); 148 void addPwd_slot1(QString *pw, PwMDoc *_doc);
144 /** manage/edit triggered */ 149 /** manage/edit triggered */
145 //US ENH : changed code to run with older MOC 150 //US ENH : changed code to run with older MOC
146 void editPwd_slot(); 151 void editPwd_slot();
147 void editPwd_slot1(const QString *category); 152 void editPwd_slot1(const QString *category);
148 void editPwd_slot3(const QString *category, const int *index ,PwMDoc *_doc ); 153 void editPwd_slot3(const QString *category, const int *index ,PwMDoc *_doc );
149 154
150 /** manage/delete triggered */ 155 /** manage/delete triggered */
151 void deletePwd_slot(); 156 void deletePwd_slot();
152 /** execute the "Launcher" entry */ 157 /** execute the "Launcher" entry */
153 void execLauncher_slot(); 158 void execLauncher_slot();
154 /** open browser with URL entry */ 159 /** open browser with URL entry */
155 void goToURL_slot(); 160 void goToURL_slot();
156 /** manage/changeMasterPwd triggered */ 161 /** manage/changeMasterPwd triggered */
157 void changeMasterPwd_slot(); 162 void changeMasterPwd_slot();
158 /** lock current document */ 163 /** lock current document */
159 void lockWnd_slot(); 164 void lockWnd_slot();
160 /** deeplock current document */ 165 /** deeplock current document */
161 void deepLockWnd_slot(); 166 void deepLockWnd_slot();
162 /** window/unlock triggered */ 167 /** window/unlock triggered */
163 void unlockWnd_slot(); 168 void unlockWnd_slot();
164 /** find item */ 169 /** find item */
165 void find_slot(); 170 void find_slot();
166 /** configure clicked */ 171 /** configure clicked */
167 void config_slot(); 172 void config_slot();
168 void config_global_slot(); 173 void config_global_slot();
169 /** (de)activate the "change master pw" button in the menu-bar */ 174 /** (de)activate the "change master pw" button in the menu-bar */
170 void activateMpButton(bool activate = true); 175 void activateMpButton(bool activate = true);
171 /** generate a new chipcard */ 176 /** generate a new chipcard */
172 void genNewCard_slot(); 177 void genNewCard_slot();
173 /** completely erase the current card */ 178 /** completely erase the current card */
174 void eraseCard_slot(); 179 void eraseCard_slot();
175 /** returns the ID number of the current card */ 180 /** returns the ID number of the current card */
176 void readCardId_slot(); 181 void readCardId_slot();
177 /** make backup image of the current card */ 182 /** make backup image of the current card */
178 void makeCardBackup_slot(); 183 void makeCardBackup_slot();
179 /** write backup image to current card */ 184 /** write backup image to current card */
180 void replayCardBackup_slot(); 185 void replayCardBackup_slot();
181 186
182#ifdef PWM_EMBEDDED 187#ifdef PWM_EMBEDDED
183 void category_slot(); 188 void category_slot();
184 void whatsnew_slot(); 189 void whatsnew_slot();
185 void showLicense_slot(); 190 void showLicense_slot();
186 void faq_slot(); 191 void faq_slot();
187 void createAboutData_slot(); 192 void createAboutData_slot();
188 void syncHowTo_slot(); 193 void syncHowTo_slot();
189#endif 194#endif
190 195
191protected: 196protected:
192 /** is this window virgin? */ 197 /** is this window virgin? */
193 bool isVirgin() 198 bool isVirgin()
194 { return virgin; } 199 { return virgin; }
195 /** add/remove virginity */ 200 /** add/remove virginity */
196 void setVirgin(bool v); 201 void setVirgin(bool v);
197 /** initialize the menubar */ 202 /** initialize the menubar */
198 void initMenubar(); 203 void initMenubar();
199 /** initialize the toolbar */ 204 /** initialize the toolbar */
200 void initToolbar(); 205 void initToolbar();
201 /** initialize the window-metrics */ 206 /** initialize the window-metrics */
202 void initMetrics(); 207 void initMetrics();
203 /** close-event */ 208 /** close-event */
204 void closeEvent(QCloseEvent *e); 209 void closeEvent(QCloseEvent *e);
205 /** creates a new PwM-ListView and returns it */ 210 /** creates a new PwM-ListView and returns it */
206 PwMView * makeNewListView(PwMDoc *doc); 211 PwMView * makeNewListView(PwMDoc *doc);
207 /** Window hide-event */ 212 /** Window hide-event */
208 void hideEvent(QHideEvent *); 213 void hideEvent(QHideEvent *);
209 /** is this window minimized? */ 214 /** is this window minimized? */
210 bool isMinimized() 215 bool isMinimized()
211 { 216 {
212#ifndef PWM_EMBEDDED 217#ifndef PWM_EMBEDDED
213 #if KDE_VERSION >= KDE_MAKE_VERSION(3, 2, 0) 218 #if KDE_VERSION >= KDE_MAKE_VERSION(3, 2, 0)
214 return KWin::windowInfo(winId()).isMinimized(); 219 return KWin::windowInfo(winId()).isMinimized();
215 #else // KDE_VERSION 220 #else // KDE_VERSION
216 return KWin::info(winId()).isIconified(); 221 return KWin::info(winId()).isIconified();
217 #endif // KDE_VERSION 222 #endif // KDE_VERSION
218#else 223#else
219 return false; 224 return false;
220#endif 225#endif
221 } 226 }
222 /** window got the focus */ 227 /** window got the focus */
223 void focusInEvent(QFocusEvent *e); 228 void focusInEvent(QFocusEvent *e);
224 /** update the caption string */ 229 /** update the caption string */
225 void updateCaption(); 230 void updateCaption();
226#ifdef CONFIG_KWALLETIF 231#ifdef CONFIG_KWALLETIF
227 /** check if kwalletemu is enabled and ask the user what to do */ 232 /** check if kwalletemu is enabled and ask the user what to do */
228 bool checkAndAskForKWalletEmu(); 233 bool checkAndAskForKWalletEmu();
229#endif // CONFIG_KWALLETIF 234#endif // CONFIG_KWALLETIF
230 235
231protected slots: 236protected slots:
232 /** doc got closed */ 237 /** doc got closed */
233 void docClosed(PwMDoc *doc); 238 void docClosed(PwMDoc *doc);
234 239
235signals: 240signals:
236 /** window got closed (by user or someone else) */ 241 /** window got closed (by user or someone else) */
237 void closed(PwM *wnd); 242 void closed(PwM *wnd);
238 /** window got the focus (was brought to foreground) */ 243 /** window got the focus (was brought to foreground) */
239 void gotFocus(PwM *wnd); 244 void gotFocus(PwM *wnd);
240 /** window lost the focus */ 245 /** window lost the focus */
241 void lostFocus(PwM *wnd); 246 void lostFocus(PwM *wnd);
242 247
243protected: 248protected:
244 /** pointer to the view active in this KMainWindow */ 249 /** pointer to the view active in this KMainWindow */
245 PwMView *view; 250 PwMView *view;
246 /** pointer to the init class */ 251 /** pointer to the init class */
247 PwMInit *init; 252 PwMInit *init;
248 /** has this window already lost its virginity? 253 /** has this window already lost its virginity?
249 * Means is there an open working document 254 * Means is there an open working document
250 */ 255 */
251 bool virgin; 256 bool virgin;
252 /** "file" popup-menu */ 257 /** "file" popup-menu */
253 KPopupMenu *filePopup; 258 KPopupMenu *filePopup;
254 259
255 /** "manage" popup-menu */ 260 /** "manage" popup-menu */
256 KPopupMenu *managePopup; 261 KPopupMenu *managePopup;
257#ifdef CONFIG_KEYCARD 262#ifdef CONFIG_KEYCARD
258 /** "chipcard" popup-menu */ 263 /** "chipcard" popup-menu */
259 KPopupMenu *chipcardPopup; 264 KPopupMenu *chipcardPopup;
260#endif // CONFIG_KEYCARD 265#endif // CONFIG_KEYCARD
261 /** "view" popup-menu */ 266 /** "view" popup-menu */
262 KPopupMenu *viewPopup; 267 KPopupMenu *viewPopup;
263 /** "options" popup-menu */ 268 /** "options" popup-menu */
264 KPopupMenu *optionsPopup; 269 KPopupMenu *optionsPopup;
265 /** "help" popup-menu */ 270 /** "help" popup-menu */
266 KPopupMenu *helpPopup; 271 KPopupMenu *helpPopup;
267 /** "export" popup-menu */ 272 /** "export" popup-menu */
268 KPopupMenu *exportPopup; 273 KPopupMenu *exportPopup;
269 /** "import" popup-menu */ 274 /** "import" popup-menu */
270 KPopupMenu *importPopup; 275 KPopupMenu *importPopup;
271 /** force quit this window? */ 276 /** force quit this window? */
272 bool forceQuit; 277 bool forceQuit;
273 /** force minimize this window to the tray */ 278 /** force minimize this window to the tray */
274 bool forceMinimizeToTray; 279 bool forceMinimizeToTray;
275 280
276 281
277 282
278 283
279 private: 284 private:
280#ifdef PWM_EMBEDDED 285#ifdef PWM_EMBEDDED
281 //this are the overwritten callbackmethods from the syncinterface 286 //this are the overwritten callbackmethods from the syncinterface
282 virtual bool sync(KSyncManager* manager, QString filename, int mode,QString resource); 287 virtual bool sync(KSyncManager* manager, QString filename, int mode,QString resource);
283 virtual void removeSyncInfo( QString syncProfile); 288 virtual void removeSyncInfo( QString syncProfile);
284 289
285 // LR ******************************* 290 // LR *******************************
286 // sync stuff! 291 // sync stuff!
287 QPopupMenu *syncPopup; 292 Q3PopupMenu *syncPopup;
288 KSyncManager* syncManager; 293 KSyncManager* syncManager;
289#endif 294#endif
290 295
291 296
292 297
293 298
294 299
295 300
296 301
297 302
298}; 303};
299 304
300#endif 305#endif
diff --git a/pwmanager/pwmanager/pwmanager.pro b/pwmanager/pwmanager/pwmanager.pro
index 7efe45c..d6d8dbe 100644
--- a/pwmanager/pwmanager/pwmanager.pro
+++ b/pwmanager/pwmanager/pwmanager.pro
@@ -1,177 +1,179 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG += qt warn_off 2 CONFIG += qt warn_off
3DESTDIR= ../../bin 3DESTDIR= ../../bin
4 TARGET = pwmpi 4 TARGET = pwmpi
5include( ../../variables.pri ) 5include( ../../variables.pri )
6 6
7INCLUDEPATH += . ../../ ../../libkdepim ../../microkde ../../microkde/kdecore ../../microkde/kdeui ../../microkde/kutils ../libcrypt/crypt ../libcrypt/error ../libcrypt/zlib 7INCLUDEPATH += . ../../ ../../libkdepim ../../microkde ../../microkde/kdecore ../../microkde/kdeui ../../microkde/kutils ../libcrypt/crypt ../libcrypt/error ../libcrypt/zlib
8DEFINES += PWM_EMBEDDED CONFIG_PWMANAGER_GCRY DESKTOP_VERSION 8DEFINES += PWM_EMBEDDED CONFIG_PWMANAGER_GCRY DESKTOP_VERSION
9 9
10#enable this setting if you want debugoutput for pwmanager 10#enable this setting if you want debugoutput for pwmanager
11#DEFINES += CONFIG_DEBUG 11#DEFINES += CONFIG_DEBUG
12LIBS += -L../libcrypt/ 12LIBS += -L../libcrypt/
13LIBS += -L../../bin/ 13LIBS += -L../../bin/
14LIBS += -lmicrokde 14LIBS += -lxmicrokde
15LIBS += -lmicrokdepim 15LIBS += -lxmicrokdepim
16LIBS += -lzlib 16LIBS += -lzlib
17LIBS += -lkpmicrocipher 17LIBS += -lkpmicrocipher
18LIBS += -lkpmicroerror 18LIBS += -lkpmicroerror
19LIBS += -lkpmicrompi 19LIBS += -lkpmicrompi
20LIBS += -lstdc++ 20LIBS += -lstdc++
21 21
22unix:{ 22unix:{
23OBJECTS_DIR = obj/unix 23OBJECTS_DIR = obj/unix
24MOC_DIR = moc/unix 24MOC_DIR = moc/unix
25 25
26} 26}
27win32:{ 27win32:{
28 28
29DEFINES += _WIN32_ 29DEFINES += _WIN32_
30OBJECTS_DIR = obj/win 30OBJECTS_DIR = obj/win
31MOC_DIR = moc/win 31MOC_DIR = moc/win
32QMAKE_LINK += /NODEFAULTLIB:LIBC 32QMAKE_LINK += /NODEFAULTLIB:LIBC
33QMAKE_CXXFLAGS += /TP /GX /GR /Ehsc 33QMAKE_CXXFLAGS += /TP /GX /GR /Ehsc
34} 34}
35 35
36#INTERFACES = \ 36#INTERFACES = \
37#addentrywnd.ui \ 37#addentrywnd.ui \
38#configwnd.ui \ 38#configwnd.ui \
39#findwnd.ui \ 39#findwnd.ui \
40#getmasterpwwnd.ui \ 40#getmasterpwwnd.ui \
41#pwgenwnd.ui \ 41#pwgenwnd.ui \
42#setmasterpwwnd.ui \ 42#setmasterpwwnd.ui \
43#subtbledit.ui 43#subtbledit.ui
44 44
45#INTERFACES = \ 45#INTERFACES = \
46#subtbledit.ui \ 46#subtbledit.ui \
47 47
48 48
49 49
50#HEADERS = \ 50#HEADERS = \
51#configuration_31compat.h \ 51#configuration_31compat.h \
52#configuration.h \ 52#configuration.h \
53#configwnd.h \ 53#configwnd.h \
54#configwndimpl.h \ 54#configwndimpl.h \
55#selftest.h 55#selftest.h
56#subtbledit.h \ 56#subtbledit.h \
57#subtbleditimpl.h \ 57#subtbleditimpl.h \
58#compressbzip2.h \ 58#compressbzip2.h \
59 59
60HEADERS = \ 60HEADERS = \
61addentrywnd_emb.h \ 61addentrywnd_emb.h \
62addentrywndimpl.h \ 62addentrywndimpl.h \
63base64.h \ 63base64.h \
64binentrygen.h \ 64binentrygen.h \
65blowfish.h \ 65blowfish.h \
66commentbox.h \ 66commentbox.h \
67compiler.h \ 67compiler.h \
68compressgzip.h \ 68compressgzip.h \
69csv.h \ 69csv.h \
70editcategory.h \ 70editcategory.h \
71findwnd_emb.h \ 71findwnd_emb.h \
72findwndimpl.h \ 72findwndimpl.h \
73genpasswd.h \ 73genpasswd.h \
74getkeycardwnd.h \ 74getkeycardwnd.h \
75getmasterpwwnd_emb.h \ 75getmasterpwwnd_emb.h \
76getmasterpwwndimpl.h \ 76getmasterpwwndimpl.h \
77globalstuff.h \ 77globalstuff.h \
78gpasmanfile.h \ 78gpasmanfile.h \
79htmlgen.h \ 79htmlgen.h \
80htmlparse.h \ 80htmlparse.h \
81ipc.h \ 81ipc.h \
82libgcryptif.h \ 82libgcryptif.h \
83listobjselectwnd.h \ 83listobjselectwnd.h \
84listviewpwm.h \ 84listviewpwm.h \
85printtext.h \ 85printtext.h \
86pwgenwnd_emb.h \ 86pwgenwnd_emb.h \
87pwgenwndimpl.h \ 87pwgenwndimpl.h \
88pwmdoc.h \ 88pwmdoc.h \
89pwmdocui.h \ 89pwmdocui.h \
90pwmexception.h \ 90pwmexception.h \
91pwm.h \ 91pwm.h \
92pwminit.h \ 92pwminit.h \
93pwmprefs.h \ 93pwmprefs.h \
94pwmprint.h \ 94pwmprint.h \
95pwmtray.h \ 95pwmtray.h \
96pwmview.h \ 96pwmview.h \
97pwmviewstyle_0.h \ 97pwmviewstyle_0.h \
98pwmviewstyle_1.h \ 98pwmviewstyle_1.h \
99pwmviewstyle.h \ 99pwmviewstyle.h \
100randomizer.h \ 100randomizer.h \
101rc2.h \ 101rc2.h \
102rencatwnd.h \ 102rencatwnd.h \
103serializer.h \ 103serializer.h \
104setmasterpwwnd_emb.h \ 104setmasterpwwnd_emb.h \
105setmasterpwwndimpl.h \ 105setmasterpwwndimpl.h \
106sha1.h \ 106sha1.h \
107waitwnd.h \ 107waitwnd.h \
108kcmconfigs/kcmpwmconfig.h \ 108kcmconfigs/kcmpwmconfig.h \
109kcmconfigs/pwmconfigwidget.h 109kcmconfigs/pwmconfigwidget.h
110 110
111#sources that need not be build 111#sources that need not be build
112#SOURCES = \ 112#SOURCES = \
113#advcommeditimpl.cpp \ 113#advcommeditimpl.cpp \
114#configuration.cpp \ 114#configuration.cpp \
115#configwnd.cpp \ 115#configwnd.cpp \
116#configwndimpl.cpp \ 116#configwndimpl.cpp \
117#configuration_31compat.cpp \ 117#configuration_31compat.cpp \
118#htmlparse.cpp \ 118#htmlparse.cpp \
119#printtext.cpp \ 119#printtext.cpp \
120#selftest.cpp \ 120#selftest.cpp \
121#pwmprint.cpp \ 121#pwmprint.cpp \
122#spinforsignal.cpp 122#spinforsignal.cpp
123#subtbledit.cpp \ 123#subtbledit.cpp \
124#subtbleditimpl.cpp \ 124#subtbleditimpl.cpp \
125#compressbzip2.cpp 125#compressbzip2.cpp
126 126
127 127
128SOURCES = \ 128SOURCES = \
129addentrywnd_emb.cpp \ 129addentrywnd_emb.cpp \
130addentrywndimpl.cpp \ 130addentrywndimpl.cpp \
131base64.cpp \ 131base64.cpp \
132binentrygen.cpp \ 132binentrygen.cpp \
133blowfish.cpp \ 133blowfish.cpp \
134commentbox.cpp \ 134commentbox.cpp \
135compressgzip.cpp \ 135compressgzip.cpp \
136csv.cpp \ 136csv.cpp \
137editcategory.cpp \ 137editcategory.cpp \
138findwnd_emb.cpp \ 138findwnd_emb.cpp \
139findwndimpl.cpp \ 139findwndimpl.cpp \
140genpasswd.cpp \ 140genpasswd.cpp \
141getkeycardwnd.cpp \ 141getkeycardwnd.cpp \
142getmasterpwwnd_emb.cpp \ 142getmasterpwwnd_emb.cpp \
143getmasterpwwndimpl.cpp \ 143getmasterpwwndimpl.cpp \
144globalstuff.cpp \ 144globalstuff.cpp \
145gpasmanfile.cpp \ 145gpasmanfile.cpp \
146htmlgen.cpp \ 146htmlgen.cpp \
147ipc.cpp \ 147ipc.cpp \
148libgcryptif.cpp \ 148libgcryptif.cpp \
149listobjselectwnd.cpp \ 149listobjselectwnd.cpp \
150listviewpwm.cpp \ 150listviewpwm.cpp \
151main.cpp \ 151main.cpp \
152pwgenwnd_emb.cpp \ 152pwgenwnd_emb.cpp \
153pwgenwndimpl.cpp \ 153pwgenwndimpl.cpp \
154pwm.cpp \ 154pwm.cpp \
155pwmdoc.cpp \ 155pwmdoc.cpp \
156pwmdocui.cpp \ 156pwmdocui.cpp \
157pwmexception.cpp \ 157pwmexception.cpp \
158pwminit.cpp \ 158pwminit.cpp \
159pwmprefs.cpp \ 159pwmprefs.cpp \
160pwmtray.cpp \ 160pwmtray.cpp \
161pwmview.cpp \ 161pwmview.cpp \
162pwmviewstyle_0.cpp \ 162pwmviewstyle_0.cpp \
163pwmviewstyle_1.cpp \ 163pwmviewstyle_1.cpp \
164pwmviewstyle.cpp \ 164pwmviewstyle.cpp \
165randomizer.cpp \ 165randomizer.cpp \
166rc2.cpp \ 166rc2.cpp \
167rencatwnd.cpp \ 167rencatwnd.cpp \
168serializer.cpp \ 168serializer.cpp \
169setmasterpwwnd_emb.cpp \ 169setmasterpwwnd_emb.cpp \
170setmasterpwwndimpl.cpp \ 170setmasterpwwndimpl.cpp \
171sha1.cpp \ 171sha1.cpp \
172waitwnd.cpp \ 172waitwnd.cpp \
173kcmconfigs/kcmpwmconfig.cpp \ 173kcmconfigs/kcmpwmconfig.cpp \
174kcmconfigs/pwmconfigwidget.cpp 174kcmconfigs/pwmconfigwidget.cpp
175 175
176 176
177 177
178#The following line was inserted by qt3to4
179QT += xml qt3support
diff --git a/pwmanager/pwmanager/pwmanagerE.pro b/pwmanager/pwmanager/pwmanagerE.pro
index 6b68514..e80d1ae 100644
--- a/pwmanager/pwmanager/pwmanagerE.pro
+++ b/pwmanager/pwmanager/pwmanagerE.pro
@@ -1,175 +1,175 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG += qt warn_on 2 CONFIG += qt warn_on
3 3
4 4
5 TARGET = pwmpi 5 TARGET = pwmpi
6OBJECTS_DIR = obj/$(PLATFORM) 6OBJECTS_DIR = obj/$(PLATFORM)
7MOC_DIR = moc/$(PLATFORM) 7MOC_DIR = moc/$(PLATFORM)
8DESTDIR=$(QPEDIR)/bin 8DESTDIR=$(QPEDIR)/bin
9 9
10INCLUDEPATH += . ../../ ../../qtcompat ../../qtcompat/xml ../../libkdepim ../../microkde ../../microkde/kdecore ../../microkde/kdeui ../../microkde/kutils ../libcrypt/crypt ../libcrypt/error $(QPEDIR)/include 10INCLUDEPATH += . ../../ ../../qtcompat ../../qtcompat/xml ../../libkdepim ../../microkde ../../microkde/kdecore ../../microkde/kdeui ../../microkde/kutils ../libcrypt/crypt ../libcrypt/error $(QPEDIR)/include
11DEFINES += PWM_EMBEDDED CONFIG_PWMANAGER_GCRY 11DEFINES += PWM_EMBEDDED CONFIG_PWMANAGER_GCRY
12 12
13#enable this setting if you want debugoutput for pwmanager 13#enable this setting if you want debugoutput for pwmanager
14#DEFINES += CONFIG_DEBUG 14#DEFINES += CONFIG_DEBUG
15 15
16LIBS += -L../libcrypt/$(PLATFORM) 16LIBS += -L../libcrypt/$(PLATFORM)
17LIBS += -lmicrokde 17LIBS += -lxmicrokde
18LIBS += -lmicroqtcompat 18LIBS += -lmicroqtcompat
19LIBS += -lmicrokdepim 19LIBS += -lxmicrokdepim
20LIBS += -L$(QPEDIR)/lib 20LIBS += -L$(QPEDIR)/lib
21LIBS += -lqpe 21LIBS += -lqpe
22LIBS += -lzlib 22LIBS += -lzlib
23#LIBS += -lbz2 23#LIBS += -lbz2
24#LIBS += -lkpmicrogcrypt 24#LIBS += -lkpmicrogcrypt
25LIBS += -ljpeg 25LIBS += -ljpeg
26LIBS += $(QTOPIALIB) 26LIBS += $(QTOPIALIB)
27LIBS += -lkpmicrocipher 27LIBS += -lkpmicrocipher
28LIBS += -lkpmicroerror 28LIBS += -lkpmicroerror
29LIBS += -lkpmicrompi 29LIBS += -lkpmicrompi
30LIBS += -lstdc++ 30LIBS += -lstdc++
31LIBS += $(GCC3EXTRALIB1) 31LIBS += $(GCC3EXTRALIB1)
32LIBS += $(GCC3EXTRALIB2) 32LIBS += $(GCC3EXTRALIB2)
33 33
34#INTERFACES = \ 34#INTERFACES = \
35#addentrywnd.ui \ 35#addentrywnd.ui \
36#configwnd.ui \ 36#configwnd.ui \
37#findwnd.ui \ 37#findwnd.ui \
38#getmasterpwwnd.ui \ 38#getmasterpwwnd.ui \
39#pwgenwnd.ui \ 39#pwgenwnd.ui \
40#setmasterpwwnd.ui \ 40#setmasterpwwnd.ui \
41#subtbledit.ui 41#subtbledit.ui
42 42
43#INTERFACES = \ 43#INTERFACES = \
44#subtbledit.ui \ 44#subtbledit.ui \
45 45
46 46
47 47
48#HEADERS = \ 48#HEADERS = \
49#configuration_31compat.h \ 49#configuration_31compat.h \
50#configuration.h \ 50#configuration.h \
51#configwnd.h \ 51#configwnd.h \
52#configwndimpl.h \ 52#configwndimpl.h \
53#selftest.h 53#selftest.h
54#subtbledit.h \ 54#subtbledit.h \
55#subtbleditimpl.h \ 55#subtbleditimpl.h \
56#compressbzip2.h \ 56#compressbzip2.h \
57 57
58HEADERS = \ 58HEADERS = \
59addentrywnd_emb.h \ 59addentrywnd_emb.h \
60addentrywndimpl.h \ 60addentrywndimpl.h \
61base64.h \ 61base64.h \
62binentrygen.h \ 62binentrygen.h \
63blowfish.h \ 63blowfish.h \
64commentbox.h \ 64commentbox.h \
65compiler.h \ 65compiler.h \
66compressgzip.h \ 66compressgzip.h \
67csv.h \ 67csv.h \
68editcategory.h \ 68editcategory.h \
69findwnd_emb.h \ 69findwnd_emb.h \
70findwndimpl.h \ 70findwndimpl.h \
71genpasswd.h \ 71genpasswd.h \
72getkeycardwnd.h \ 72getkeycardwnd.h \
73getmasterpwwnd_emb.h \ 73getmasterpwwnd_emb.h \
74getmasterpwwndimpl.h \ 74getmasterpwwndimpl.h \
75globalstuff.h \ 75globalstuff.h \
76gpasmanfile.h \ 76gpasmanfile.h \
77htmlgen.h \ 77htmlgen.h \
78htmlparse.h \ 78htmlparse.h \
79ipc.h \ 79ipc.h \
80libgcryptif.h \ 80libgcryptif.h \
81listobjselectwnd.h \ 81listobjselectwnd.h \
82listviewpwm.h \ 82listviewpwm.h \
83printtext.h \ 83printtext.h \
84pwgenwnd_emb.h \ 84pwgenwnd_emb.h \
85pwgenwndimpl.h \ 85pwgenwndimpl.h \
86pwmdoc.h \ 86pwmdoc.h \
87pwmdocui.h \ 87pwmdocui.h \
88pwmexception.h \ 88pwmexception.h \
89pwm.h \ 89pwm.h \
90pwminit.h \ 90pwminit.h \
91pwmprefs.h \ 91pwmprefs.h \
92pwmprint.h \ 92pwmprint.h \
93pwmtray.h \ 93pwmtray.h \
94pwmview.h \ 94pwmview.h \
95pwmviewstyle_0.h \ 95pwmviewstyle_0.h \
96pwmviewstyle_1.h \ 96pwmviewstyle_1.h \
97pwmviewstyle.h \ 97pwmviewstyle.h \
98randomizer.h \ 98randomizer.h \
99rc2.h \ 99rc2.h \
100rencatwnd.h \ 100rencatwnd.h \
101serializer.h \ 101serializer.h \
102setmasterpwwnd_emb.h \ 102setmasterpwwnd_emb.h \
103setmasterpwwndimpl.h \ 103setmasterpwwndimpl.h \
104sha1.h \ 104sha1.h \
105waitwnd.h \ 105waitwnd.h \
106kcmconfigs/kcmpwmconfig.h \ 106kcmconfigs/kcmpwmconfig.h \
107kcmconfigs/pwmconfigwidget.h 107kcmconfigs/pwmconfigwidget.h
108 108
109#sources that need not be build 109#sources that need not be build
110#SOURCES = \ 110#SOURCES = \
111#advcommeditimpl.cpp \ 111#advcommeditimpl.cpp \
112#configuration.cpp \ 112#configuration.cpp \
113#configwnd.cpp \ 113#configwnd.cpp \
114#configwndimpl.cpp \ 114#configwndimpl.cpp \
115#configuration_31compat.cpp \ 115#configuration_31compat.cpp \
116#htmlparse.cpp \ 116#htmlparse.cpp \
117#printtext.cpp \ 117#printtext.cpp \
118#selftest.cpp \ 118#selftest.cpp \
119#pwmprint.cpp \ 119#pwmprint.cpp \
120#spinforsignal.cpp 120#spinforsignal.cpp
121#subtbledit.cpp \ 121#subtbledit.cpp \
122#subtbleditimpl.cpp \ 122#subtbleditimpl.cpp \
123#compressbzip2.cpp 123#compressbzip2.cpp
124 124
125 125
126SOURCES = \ 126SOURCES = \
127addentrywnd_emb.cpp \ 127addentrywnd_emb.cpp \
128addentrywndimpl.cpp \ 128addentrywndimpl.cpp \
129base64.cpp \ 129base64.cpp \
130binentrygen.cpp \ 130binentrygen.cpp \
131blowfish.cpp \ 131blowfish.cpp \
132commentbox.cpp \ 132commentbox.cpp \
133compressgzip.cpp \ 133compressgzip.cpp \
134csv.cpp \ 134csv.cpp \
135editcategory.cpp \ 135editcategory.cpp \
136findwnd_emb.cpp \ 136findwnd_emb.cpp \
137findwndimpl.cpp \ 137findwndimpl.cpp \
138genpasswd.cpp \ 138genpasswd.cpp \
139getkeycardwnd.cpp \ 139getkeycardwnd.cpp \
140getmasterpwwnd_emb.cpp \ 140getmasterpwwnd_emb.cpp \
141getmasterpwwndimpl.cpp \ 141getmasterpwwndimpl.cpp \
142globalstuff.cpp \ 142globalstuff.cpp \
143gpasmanfile.cpp \ 143gpasmanfile.cpp \
144htmlgen.cpp \ 144htmlgen.cpp \
145ipc.cpp \ 145ipc.cpp \
146libgcryptif.cpp \ 146libgcryptif.cpp \
147listobjselectwnd.cpp \ 147listobjselectwnd.cpp \
148listviewpwm.cpp \ 148listviewpwm.cpp \
149main.cpp \ 149main.cpp \
150pwgenwnd_emb.cpp \ 150pwgenwnd_emb.cpp \
151pwgenwndimpl.cpp \ 151pwgenwndimpl.cpp \
152pwm.cpp \ 152pwm.cpp \
153pwmdoc.cpp \ 153pwmdoc.cpp \
154pwmdocui.cpp \ 154pwmdocui.cpp \
155pwmexception.cpp \ 155pwmexception.cpp \
156pwminit.cpp \ 156pwminit.cpp \
157pwmprefs.cpp \ 157pwmprefs.cpp \
158pwmtray.cpp \ 158pwmtray.cpp \
159pwmview.cpp \ 159pwmview.cpp \
160pwmviewstyle_0.cpp \ 160pwmviewstyle_0.cpp \
161pwmviewstyle_1.cpp \ 161pwmviewstyle_1.cpp \
162pwmviewstyle.cpp \ 162pwmviewstyle.cpp \
163randomizer.cpp \ 163randomizer.cpp \
164rc2.cpp \ 164rc2.cpp \
165rencatwnd.cpp \ 165rencatwnd.cpp \
166serializer.cpp \ 166serializer.cpp \
167setmasterpwwnd_emb.cpp \ 167setmasterpwwnd_emb.cpp \
168setmasterpwwndimpl.cpp \ 168setmasterpwwndimpl.cpp \
169sha1.cpp \ 169sha1.cpp \
170waitwnd.cpp \ 170waitwnd.cpp \
171kcmconfigs/kcmpwmconfig.cpp \ 171kcmconfigs/kcmpwmconfig.cpp \
172kcmconfigs/pwmconfigwidget.cpp 172kcmconfigs/pwmconfigwidget.cpp
173 173
174 174
175 175
diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp
index b58d7e2..9213360 100644
--- a/pwmanager/pwmanager/pwmdoc.cpp
+++ b/pwmanager/pwmanager/pwmdoc.cpp
@@ -1,1914 +1,1916 @@
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.1 of pwmanager 14 * This file is originaly based on version 1.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 "pwmdoc.h" 20#include "pwmdoc.h"
21#include "pwmview.h" 21#include "pwmview.h"
22#include "blowfish.h" 22#include "blowfish.h"
23#include "sha1.h" 23#include "sha1.h"
24#include "globalstuff.h" 24#include "globalstuff.h"
25#include "gpasmanfile.h" 25#include "gpasmanfile.h"
26#include "serializer.h" 26#include "serializer.h"
27#include "compressgzip.h" 27#include "compressgzip.h"
28//US#include "compressbzip2.h" 28//US#include "compressbzip2.h"
29#include "randomizer.h" 29#include "randomizer.h"
30#include "pwminit.h" 30#include "pwminit.h"
31#include "libgcryptif.h" 31#include "libgcryptif.h"
32#ifdef PWM_EMBEDDED 32#ifdef PWM_EMBEDDED
33#include "pwmprefs.h" 33#include "pwmprefs.h"
34#include "kglobal.h" 34#include "kglobal.h"
35#endif 35#endif
36 36
37#include <kmessagebox.h> 37#include <kmessagebox.h>
38#include <kconfig.h> 38#include <kconfig.h>
39#include <kglobalsettings.h> 39#include <kglobalsettings.h>
40#include <libkcal/syncdefines.h> 40#include <libkcal/syncdefines.h>
41 41
42 42
43#ifdef CONFIG_KWALLETIF 43#ifdef CONFIG_KWALLETIF
44# include "kwalletemu.h" 44# include "kwalletemu.h"
45#endif // CONFIG_KWALLETIF 45#endif // CONFIG_KWALLETIF
46 46
47#include <qdatetime.h> 47#include <qdatetime.h>
48#include <qsize.h> 48#include <qsize.h>
49#include <qfileinfo.h> 49#include <qfileinfo.h>
50#include <qfile.h> 50#include <qfile.h>
51#include <QDesktopWidget>
51 52
52#include <stdio.h> 53#include <stdio.h>
53#include <stdlib.h> 54#include <stdlib.h>
54#include <errno.h> 55#include <errno.h>
55#include <string.h> 56#include <string.h>
56//US#include <iostream> 57//US#include <iostream>
57#include <algorithm> 58#include <algorithm>
58#include <sys/types.h> 59#include <sys/types.h>
59#include <sys/stat.h> 60#include <sys/stat.h>
60#ifndef _WIN32_ 61#ifndef _WIN32_
61#include <unistd.h> 62#include <unistd.h>
62#include <stdint.h> 63#include <stdint.h>
63#endif 64#endif
64 65
65#ifdef PWM_EMBEDDED 66#ifdef PWM_EMBEDDED
66#ifndef Q_LONG 67#ifndef Q_LONG
67#define Q_LONG long 68#define Q_LONG long
68#endif 69#endif
69 70
70#ifndef Q_ULONG 71#ifndef Q_ULONG
71#define Q_ULONG unsigned long 72#define Q_ULONG unsigned long
72#endif 73#endif
73#endif //PWM_EMBEDDED 74#endif //PWM_EMBEDDED
74 75
75 76
76//TODO: reset to its normal value. 77//TODO: reset to its normal value.
77//LR set to 5 min 78//LR set to 5 min
78 #define META_CHECK_TIMER_INTERVAL300 /* 10 300*/ /* sek */ 79 #define META_CHECK_TIMER_INTERVAL300 /* 10 300*/ /* sek */
79 80
80using namespace std; 81using namespace std;
81 82
82 83
83void PwMDocList::add(PwMDoc *doc, const string &id) 84void PwMDocList::add(PwMDoc *doc, const string &id)
84{ 85{
85#ifdef PWM_DEBUG 86#ifdef PWM_DEBUG
86 // check for existance of object in debug mode only. 87 // check for existance of object in debug mode only.
87 vector<listItem>::iterator begin = docList.begin(), 88 vector<listItem>::iterator begin = docList.begin(),
88 end = docList.end(), 89 end = docList.end(),
89 i = begin; 90 i = begin;
90 while (i != end) { 91 while (i != end) {
91 if (i->doc == doc) { 92 if (i->doc == doc) {
92 BUG(); 93 BUG();
93 return; 94 return;
94 } 95 }
95 ++i; 96 ++i;
96 } 97 }
97#endif 98#endif
98 listItem newItem; 99 listItem newItem;
99 newItem.doc = doc; 100 newItem.doc = doc;
100 newItem.docId = id; 101 newItem.docId = id;
101 docList.push_back(newItem); 102 docList.push_back(newItem);
102} 103}
103 104
104void PwMDocList::edit(PwMDoc *doc, const string &newId) 105void PwMDocList::edit(PwMDoc *doc, const string &newId)
105{ 106{
106 vector<listItem>::iterator begin = docList.begin(), 107 vector<listItem>::iterator begin = docList.begin(),
107 end = docList.end(), 108 end = docList.end(),
108 i = begin; 109 i = begin;
109 while (i != end) { 110 while (i != end) {
110 if (i->doc == doc) { 111 if (i->doc == doc) {
111 i->docId = newId; 112 i->docId = newId;
112 return; 113 return;
113 } 114 }
114 ++i; 115 ++i;
115 } 116 }
116} 117}
117 118
118void PwMDocList::del(PwMDoc *doc) 119void PwMDocList::del(PwMDoc *doc)
119{ 120{
120 vector<listItem>::iterator begin = docList.begin(), 121 vector<listItem>::iterator begin = docList.begin(),
121 end = docList.end(), 122 end = docList.end(),
122 i = begin; 123 i = begin;
123 while (i != end) { 124 while (i != end) {
124 if (i->doc == doc) { 125 if (i->doc == doc) {
125 docList.erase(i); 126 docList.erase(i);
126 return; 127 return;
127 } 128 }
128 ++i; 129 ++i;
129 } 130 }
130} 131}
131 132
132bool PwMDocList::find(const string &id, listItem *ret) 133bool PwMDocList::find(const string &id, listItem *ret)
133{ 134{
134 vector<listItem>::iterator begin = docList.begin(), 135 vector<listItem>::iterator begin = docList.begin(),
135 end = docList.end(), 136 end = docList.end(),
136 i = begin; 137 i = begin;
137 while (i != end) { 138 while (i != end) {
138 if (i->docId == id) { 139 if (i->docId == id) {
139 if (ret) 140 if (ret)
140 *ret = *i; 141 *ret = *i;
141 return true; 142 return true;
142 } 143 }
143 ++i; 144 ++i;
144 } 145 }
145 return false; 146 return false;
146} 147}
147 148
148 149
149 150
150DocTimer::DocTimer(PwMDoc *_doc) 151DocTimer::DocTimer(PwMDoc *_doc)
151 : doc (_doc) 152 : doc (_doc)
152 , mpwLock (0) 153 , mpwLock (0)
153 , autoLockLock (0) 154 , autoLockLock (0)
154 , metaCheckLock (0) 155 , metaCheckLock (0)
155{ 156{
156 mpwTimer = new QTimer; 157 mpwTimer = new QTimer;
157 autoLockTimer = new QTimer; 158 autoLockTimer = new QTimer;
158 metaCheckTimer = new QTimer; 159 metaCheckTimer = new QTimer;
159 connect(mpwTimer, SIGNAL(timeout()), 160 connect(mpwTimer, SIGNAL(timeout()),
160 this, SLOT(mpwTimeout())); 161 this, SLOT(mpwTimeout()));
161 connect(autoLockTimer, SIGNAL(timeout()), 162 connect(autoLockTimer, SIGNAL(timeout()),
162 this, SLOT(autoLockTimeout())); 163 this, SLOT(autoLockTimeout()));
163 connect(metaCheckTimer, SIGNAL(timeout()), 164 connect(metaCheckTimer, SIGNAL(timeout()),
164 this, SLOT(metaCheckTimeout())); 165 this, SLOT(metaCheckTimeout()));
165} 166}
166 167
167DocTimer::~DocTimer() 168DocTimer::~DocTimer()
168{ 169{
169 delete mpwTimer; 170 delete mpwTimer;
170 delete autoLockTimer; 171 delete autoLockTimer;
171 delete metaCheckTimer; 172 delete metaCheckTimer;
172} 173}
173 174
174void DocTimer::start(TimerIDs timer) 175void DocTimer::start(TimerIDs timer)
175{ 176{
176 switch (timer) { 177 switch (timer) {
177 case id_mpwTimer: 178 case id_mpwTimer:
178 if (mpwTimer->isActive()) 179 if (mpwTimer->isActive())
179 mpwTimer->stop(); 180 mpwTimer->stop();
180 doc->setDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW); 181 doc->setDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW);
181 mpwTimer->start(conf()->confGlobPwTimeout() * 1000, true); 182 mpwTimer->start(conf()->confGlobPwTimeout() * 1000, true);
182 break; 183 break;
183 case id_autoLockTimer: 184 case id_autoLockTimer:
184 if (autoLockTimer->isActive()) 185 if (autoLockTimer->isActive())
185 autoLockTimer->stop(); 186 autoLockTimer->stop();
186 if (conf()->confGlobLockTimeout() > 0) 187 if (conf()->confGlobLockTimeout() > 0)
187 autoLockTimer->start(conf()->confGlobLockTimeout() * 1000, true); 188 autoLockTimer->start(conf()->confGlobLockTimeout() * 1000, true);
188 break; 189 break;
189 case id_metaCheckTimer: 190 case id_metaCheckTimer:
190 if (metaCheckTimer->isActive()) 191 if (metaCheckTimer->isActive())
191 metaCheckTimer->stop(); 192 metaCheckTimer->stop();
192 metaCheckTimer->start(META_CHECK_TIMER_INTERVAL * 1000, true); 193 metaCheckTimer->start(META_CHECK_TIMER_INTERVAL * 1000, true);
193 break; 194 break;
194 } 195 }
195} 196}
196 197
197void DocTimer::stop(TimerIDs timer) 198void DocTimer::stop(TimerIDs timer)
198{ 199{
199 switch (timer) { 200 switch (timer) {
200 case id_mpwTimer: 201 case id_mpwTimer:
201 mpwTimer->stop(); 202 mpwTimer->stop();
202 break; 203 break;
203 case id_autoLockTimer: 204 case id_autoLockTimer:
204 autoLockTimer->stop(); 205 autoLockTimer->stop();
205 break; 206 break;
206 case id_metaCheckTimer: 207 case id_metaCheckTimer:
207 metaCheckTimer->stop(); 208 metaCheckTimer->stop();
208 break; 209 break;
209 } 210 }
210} 211}
211 212
212void DocTimer::getLock(TimerIDs timer) 213void DocTimer::getLock(TimerIDs timer)
213{ 214{
214 switch (timer) { 215 switch (timer) {
215 case id_mpwTimer: 216 case id_mpwTimer:
216 ++mpwLock; 217 ++mpwLock;
217 break; 218 break;
218 case id_autoLockTimer: 219 case id_autoLockTimer:
219 ++autoLockLock; 220 ++autoLockLock;
220 break; 221 break;
221 case id_metaCheckTimer: 222 case id_metaCheckTimer:
222 ++metaCheckLock; 223 ++metaCheckLock;
223 break; 224 break;
224 } 225 }
225} 226}
226 227
227void DocTimer::putLock(TimerIDs timer) 228void DocTimer::putLock(TimerIDs timer)
228{ 229{
229 switch (timer) { 230 switch (timer) {
230 case id_mpwTimer: 231 case id_mpwTimer:
231 if (mpwLock) 232 if (mpwLock)
232 --mpwLock; 233 --mpwLock;
233 break; 234 break;
234 case id_autoLockTimer: 235 case id_autoLockTimer:
235 if (autoLockLock) 236 if (autoLockLock)
236 --autoLockLock; 237 --autoLockLock;
237 break; 238 break;
238 case id_metaCheckTimer: 239 case id_metaCheckTimer:
239 if (metaCheckLock) 240 if (metaCheckLock)
240 --metaCheckLock; 241 --metaCheckLock;
241 break; 242 break;
242 } 243 }
243} 244}
244 245
245void DocTimer::mpwTimeout() 246void DocTimer::mpwTimeout()
246{ 247{
247 if (mpwLock) { 248 if (mpwLock) {
248 mpwTimer->start(1000, true); 249 mpwTimer->start(1000, true);
249 return; 250 return;
250 } 251 }
251 doc->unsetDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW); 252 doc->unsetDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW);
252} 253}
253 254
254void DocTimer::autoLockTimeout() 255void DocTimer::autoLockTimeout()
255{ 256{
256 if (autoLockLock) { 257 if (autoLockLock) {
257 autoLockTimer->start(1000, true); 258 autoLockTimer->start(1000, true);
258 return; 259 return;
259 } 260 }
260 if (conf()->confGlobAutoDeepLock() && 261 if (conf()->confGlobAutoDeepLock() &&
261 doc->filename != QString::null && 262 doc->filename != QString::null &&
262 doc->filename != "") { 263 doc->filename != "") {
263 doc->deepLock(true); 264 doc->deepLock(true);
264 } else { 265 } else {
265 doc->lockAll(true); 266 doc->lockAll(true);
266 } 267 }
267} 268}
268 269
269void DocTimer::metaCheckTimeout() 270void DocTimer::metaCheckTimeout()
270{ 271{
271 if (metaCheckLock) { 272 if (metaCheckLock) {
272 // check again in one second. 273 // check again in one second.
273 metaCheckTimer->start(1000, true); 274 metaCheckTimer->start(1000, true);
274 return; 275 return;
275 } 276 }
276 if (doc->isDeepLocked()) { 277 if (doc->isDeepLocked()) {
277 metaCheckTimer->start(META_CHECK_TIMER_INTERVAL * 1000, true); 278 metaCheckTimer->start(META_CHECK_TIMER_INTERVAL * 1000, true);
278 return; 279 return;
279 } 280 }
280 if (doc->isDocEmpty()) { 281 if (doc->isDocEmpty()) {
281 metaCheckTimer->start(META_CHECK_TIMER_INTERVAL * 1000, true); 282 metaCheckTimer->start(META_CHECK_TIMER_INTERVAL * 1000, true);
282 return; 283 return;
283 } 284 }
284#ifdef CONFIG_KWALLETIF 285#ifdef CONFIG_KWALLETIF
285 KWalletEmu *kwlEmu = doc->init->kwalletEmu(); 286 KWalletEmu *kwlEmu = doc->init->kwalletEmu();
286 if (kwlEmu) 287 if (kwlEmu)
287 kwlEmu->suspendDocSignals(); 288 kwlEmu->suspendDocSignals();
288#endif // CONFIG_KWALLETIF 289#endif // CONFIG_KWALLETIF
289 /* We simply trigger all views to update their 290 /* We simply trigger all views to update their
290 * displayed values. This way they have a chance 291 * displayed values. This way they have a chance
291 * to get notified when some meta changes over time. 292 * to get notified when some meta changes over time.
292 * (for example an entry expired). 293 * (for example an entry expired).
293 * The _view_ is responsive for not updating its 294 * The _view_ is responsive for not updating its
294 * contents if nothing really changed! 295 * contents if nothing really changed!
295 */ 296 */
296 emit doc->dataChanged(doc); 297 emit doc->dataChanged(doc);
297#ifdef CONFIG_KWALLETIF 298#ifdef CONFIG_KWALLETIF
298 if (kwlEmu) 299 if (kwlEmu)
299 kwlEmu->resumeDocSignals(); 300 kwlEmu->resumeDocSignals();
300#endif // CONFIG_KWALLETIF 301#endif // CONFIG_KWALLETIF
301 metaCheckTimer->start(META_CHECK_TIMER_INTERVAL * 1000, true); 302 metaCheckTimer->start(META_CHECK_TIMER_INTERVAL * 1000, true);
302} 303}
303 304
304 305
305 306
306PwMDocList PwMDoc::openDocList; 307PwMDocList PwMDoc::openDocList;
307unsigned int PwMDocList::unnamedDocCnt = 1; 308unsigned int PwMDocList::unnamedDocCnt = 1;
308 309
309PwMDoc::PwMDoc(QObject *parent, const char *name) 310PwMDoc::PwMDoc(QObject *parent, const char *name)
310 : PwMDocUi(parent, name) 311 : PwMDocUi(parent, name)
311 , dataChangedLock (0) 312 , dataChangedLock (0)
312{ 313{
313 deleted = false; 314 deleted = false;
314 unnamedNum = 0; 315 unnamedNum = 0;
315 getOpenDocList()->add(this, getTitle().latin1()); 316 getOpenDocList()->add(this, getTitle().latin1());
316 curDocStat = 0; 317 curDocStat = 0;
317 setMaxNumEntries(); 318 setMaxNumEntries();
318 _timer = new DocTimer(this); 319 _timer = new DocTimer(this);
319 timer()->start(DocTimer::id_mpwTimer); 320 timer()->start(DocTimer::id_mpwTimer);
320 timer()->start(DocTimer::id_autoLockTimer); 321 timer()->start(DocTimer::id_autoLockTimer);
321 timer()->start(DocTimer::id_metaCheckTimer); 322 timer()->start(DocTimer::id_metaCheckTimer);
322 addCategory(DEFAULT_CATEGORY, 0, false); 323 addCategory(DEFAULT_CATEGORY, 0, false);
323 listView = 0; 324 listView = 0;
324 emit docCreated(this); 325 emit docCreated(this);
325} 326}
326 327
327PwMDoc::~PwMDoc() 328PwMDoc::~PwMDoc()
328{ 329{
329 emit docClosed(this); 330 emit docClosed(this);
330 getOpenDocList()->del(this); 331 getOpenDocList()->del(this);
331 delete _timer; 332 delete _timer;
332} 333}
333 334
334PwMerror PwMDoc::saveDoc(char compress, const QString *file) 335PwMerror PwMDoc::saveDoc(char compress, const QString *file)
335{ 336{
336 PwMerror ret, e; 337 PwMerror ret, e;
337 string serialized; 338 string serialized;
338 QFile f; 339 QFile f;
339 QString tmpFileMoved(QString::null); 340 QString tmpFileMoved(QString::null);
340 bool wasDeepLocked; 341 bool wasDeepLocked;
341 QString savedFilename(filename); 342 QString savedFilename(filename);
342 343
343 if (!file) { 344 if (!file) {
344 if (filename == "") 345 if (filename == "")
345 return e_filename; 346 return e_filename;
346 if (isDeepLocked()) { 347 if (isDeepLocked()) {
347 /* We don't need to save any data. 348 /* We don't need to save any data.
348 * It's already all on disk, because 349 * It's already all on disk, because
349 * we are deeplocked. 350 * we are deeplocked.
350 */ 351 */
351 unsetDocStatFlag(DOC_STAT_DISK_DIRTY); 352 unsetDocStatFlag(DOC_STAT_DISK_DIRTY);
352 ret = e_success; 353 ret = e_success;
353 return ret; 354 return ret;
354 } 355 }
355 } else { 356 } else {
356 if (*file == "" && filename == "") 357 if (*file == "" && filename == "")
357 return e_filename; 358 return e_filename;
358 if (*file != "") 359 if (*file != "")
359 filename = *file; 360 filename = *file;
360 } 361 }
361 362
362 wasDeepLocked = isDeepLocked(); 363 wasDeepLocked = isDeepLocked();
363 if (wasDeepLocked) { 364 if (wasDeepLocked) {
364 /* We are deeplocked. That means all data is already 365 /* We are deeplocked. That means all data is already
365 * on disk. BUT we need to do saving procedure, 366 * on disk. BUT we need to do saving procedure,
366 * because *file != savedFilename. 367 * because *file != savedFilename.
367 * Additionally we need to tempoarly restore 368 * Additionally we need to tempoarly restore
368 * the old "filename", because deepLock() references it. 369 * the old "filename", because deepLock() references it.
369 */ 370 */
370 QString newFilename(filename); 371 QString newFilename(filename);
371 filename = savedFilename; 372 filename = savedFilename;
372 getDataChangedLock(); 373 getDataChangedLock();
373 e = deepLock(false); 374 e = deepLock(false);
374 putDataChangedLock(); 375 putDataChangedLock();
375 filename = newFilename; 376 filename = newFilename;
376 switch (e) { 377 switch (e) {
377 case e_success: 378 case e_success:
378 break; 379 break;
379 case e_wrongPw: 380 case e_wrongPw:
380 case e_noPw: 381 case e_noPw:
381 emitDataChanged(this); 382 emitDataChanged(this);
382 return e; 383 return e;
383 default: 384 default:
384 emitDataChanged(this); 385 emitDataChanged(this);
385 return e_openFile; 386 return e_openFile;
386 } 387 }
387 } 388 }
388 389
389 if (!isPwAvailable()) { 390 if (!isPwAvailable()) {
390 /* password is not available. This means, the 391 /* password is not available. This means, the
391 * document wasn't saved, yet. 392 * document wasn't saved, yet.
392 */ 393 */
393 bool useChipcard = getDocStatFlag(DOC_STAT_USE_CHIPCARD); 394 bool useChipcard = getDocStatFlag(DOC_STAT_USE_CHIPCARD);
394 QString pw(requestNewMpw(&useChipcard)); 395 QString pw(requestNewMpw(&useChipcard));
395 if (pw != "") { 396 if (pw != "") {
396 currentPw = pw; 397 currentPw = pw;
397 } else { 398 } else {
398 return e_noPw; 399 return e_noPw;
399 } 400 }
400 if (useChipcard) { 401 if (useChipcard) {
401 setDocStatFlag(DOC_STAT_USE_CHIPCARD); 402 setDocStatFlag(DOC_STAT_USE_CHIPCARD);
402 } else { 403 } else {
403 unsetDocStatFlag(DOC_STAT_USE_CHIPCARD); 404 unsetDocStatFlag(DOC_STAT_USE_CHIPCARD);
404 } 405 }
405 } 406 }
406 407
407 int _cryptAlgo = conf()->confGlobCryptAlgo(); 408 int _cryptAlgo = conf()->confGlobCryptAlgo();
408 int _hashAlgo = conf()->confGlobHashAlgo(); 409 int _hashAlgo = conf()->confGlobHashAlgo();
409 410
410 // sanity check for the selected algorithms 411 // sanity check for the selected algorithms
411 if (_cryptAlgo < PWM_CRYPT_BLOWFISH || 412 if (_cryptAlgo < PWM_CRYPT_BLOWFISH ||
412 _cryptAlgo > PWM_CRYPT_TWOFISH128) { 413 _cryptAlgo > PWM_CRYPT_TWOFISH128) {
413 printWarn("Invalid Crypto-Algorithm selected! " 414 printWarn("Invalid Crypto-Algorithm selected! "
414 "Config-file seems to be corrupt. " 415 "Config-file seems to be corrupt. "
415 "Falling back to Blowfish."); 416 "Falling back to Blowfish.");
416 _cryptAlgo = PWM_CRYPT_BLOWFISH; 417 _cryptAlgo = PWM_CRYPT_BLOWFISH;
417 } 418 }
418 if (_hashAlgo < PWM_HASH_SHA1 || 419 if (_hashAlgo < PWM_HASH_SHA1 ||
419 _hashAlgo > PWM_HASH_TIGER) { 420 _hashAlgo > PWM_HASH_TIGER) {
420 printWarn("Invalid Hash-Algorithm selected! " 421 printWarn("Invalid Hash-Algorithm selected! "
421 "Config-file seems to be corrupt. " 422 "Config-file seems to be corrupt. "
422 "Falling back to SHA1."); 423 "Falling back to SHA1.");
423 _hashAlgo = PWM_HASH_SHA1; 424 _hashAlgo = PWM_HASH_SHA1;
424 } 425 }
425 char cryptAlgo = static_cast<char>(_cryptAlgo); 426 char cryptAlgo = static_cast<char>(_cryptAlgo);
426 char hashAlgo = static_cast<char>(_hashAlgo); 427 char hashAlgo = static_cast<char>(_hashAlgo);
427 428
428 if (conf()->confGlobMakeFileBackup()) { 429 if (conf()->confGlobMakeFileBackup()) {
429 if (!backupFile(filename)) 430 if (!backupFile(filename))
430 return e_fileBackup; 431 return e_fileBackup;
431 } 432 }
432 int mLastBackupDate = 0; 433 int mLastBackupDate = 0;
433 KConfig configGlobal (locateLocal("config","pwmanagerbuprc")); 434 KConfig configGlobal (locateLocal("config","pwmanagerbuprc"));
434 QFileInfo fileInfo ( filename ); 435 QFileInfo fileInfo ( filename );
435 mLastBackupDate = configGlobal.readNumEntry( "LastBackupDate-"+ fileInfo.fileName (), 0 ); 436 mLastBackupDate = configGlobal.readNumEntry( "LastBackupDate-"+ fileInfo.fileName (), 0 );
436 KConfig config (locateLocal("config","microkdeglobalrc")); 437 KConfig config (locateLocal("config","microkdeglobalrc"));
437 config.setGroup( "BackupSettings" ); 438 config.setGroup( "BackupSettings" );
438 bool b_enabled = config.readBoolEntry( "BackupEnabled" ); 439 bool b_enabled = config.readBoolEntry( "BackupEnabled" );
439 if ( b_enabled && QFile::exists(filename)) { 440 if ( b_enabled && QFile::exists(filename)) {
440 int num = config.readNumEntry( "BackupNumbers" ); 441 int num = config.readNumEntry( "BackupNumbers" );
441 int d_count = config.readNumEntry( "BackupDayCount" ); 442 int d_count = config.readNumEntry( "BackupDayCount" );
442 bool stdDir = config.readBoolEntry( "BackupUseDefaultDir" ); 443 bool stdDir = config.readBoolEntry( "BackupUseDefaultDir" );
443 QString bupDir = config.readEntry( "BackupDatadir" ); 444 QString bupDir = config.readEntry( "BackupDatadir" );
444 QDate reference ( 2000,1,1 ); 445 QDate reference ( 2000,1,1 );
445 int daysTo = reference.daysTo ( QDate::currentDate() ); 446 int daysTo = reference.daysTo ( QDate::currentDate() );
446 bool saveDate = false; 447 bool saveDate = false;
447 if ( daysTo - d_count >= mLastBackupDate ) { 448 if ( daysTo - d_count >= mLastBackupDate ) {
448 qDebug("KA: Last backup was %d days ago ", daysTo - mLastBackupDate ); 449 qDebug("KA: Last backup was %d days ago ", daysTo - mLastBackupDate );
449 if ( stdDir ) 450 if ( stdDir )
450 bupDir = KGlobalSettings::backupDataDir(); 451 bupDir = KGlobalSettings::backupDataDir();
451 int retval = KApplication::createBackup( filename, bupDir, num ); 452 int retval = KApplication::createBackup( filename, bupDir, num );
452 if ( retval == 0 ) { 453 if ( retval == 0 ) {
453 qDebug("KO: Backup cancelled. Will try again tomorrow "); 454 qDebug("KO: Backup cancelled. Will try again tomorrow ");
454 // retval == 0 : backup skipped for today, try again tomorrow 455 // retval == 0 : backup skipped for today, try again tomorrow
455 mLastBackupDate = daysTo - d_count+1; 456 mLastBackupDate = daysTo - d_count+1;
456 saveDate = true; 457 saveDate = true;
457 } else if ( retval == 1 ){ 458 } else if ( retval == 1 ){
458 qDebug("KO: Backup created."); 459 qDebug("KO: Backup created.");
459 // backup ok 460 // backup ok
460 mLastBackupDate = daysTo; 461 mLastBackupDate = daysTo;
461 saveDate = true; 462 saveDate = true;
462 } else if ( retval == 2 ){ 463 } else if ( retval == 2 ){
463 qDebug("KO: Backup globally cancelled."); 464 qDebug("KO: Backup globally cancelled.");
464 // backup globally cancelled 465 // backup globally cancelled
465 b_enabled = false; 466 b_enabled = false;
466 } 467 }
467 if ( !b_enabled ) { 468 if ( !b_enabled ) {
468 config.writeEntry( "mBackupEnabled", false ); 469 config.writeEntry( "mBackupEnabled", false );
469 } 470 }
470 if ( saveDate ) { 471 if ( saveDate ) {
471 configGlobal.writeEntry( "LastBackupDate-"+ fileInfo.fileName (), mLastBackupDate ); 472 configGlobal.writeEntry( "LastBackupDate-"+ fileInfo.fileName (), mLastBackupDate );
472 } 473 }
473 } 474 }
474 } 475 }
475 if (QFile::exists(filename)) { 476 if (QFile::exists(filename)) {
476 /* Move the existing file to some tmp file. 477 /* Move the existing file to some tmp file.
477 * When saving file succeeds, delete tmp file. Otherwise 478 * When saving file succeeds, delete tmp file. Otherwise
478 * move tmp file back. See below. 479 * move tmp file back. See below.
479 */ 480 */
480 Randomizer *rnd = Randomizer::obj(); 481 Randomizer *rnd = Randomizer::obj();
481 char rnd_buf[5]; 482 char rnd_buf[5];
482 sprintf(rnd_buf, "%X%X%X%X", rnd->genRndChar() & 0xFF, rnd->genRndChar() & 0xFF, 483 sprintf(rnd_buf, "%X%X%X%X", rnd->genRndChar() & 0xFF, rnd->genRndChar() & 0xFF,
483 rnd->genRndChar() & 0xFF, rnd->genRndChar() & 0xFF); 484 rnd->genRndChar() & 0xFF, rnd->genRndChar() & 0xFF);
484 tmpFileMoved = filename + "." + rnd_buf + ".mv"; 485 tmpFileMoved = filename; tmpFileMoved += '.';
486 tmpFileMoved += rnd_buf; tmpFileMoved += ".mv";
485 if (!copyFile(filename, tmpFileMoved)) 487 if (!copyFile(filename, tmpFileMoved))
486 return e_openFile; 488 return e_openFile;
487 if (!QFile::remove(filename)) { 489 if (!QFile::remove(filename)) {
488 printWarn(string("removing orig file ") 490 printWarn(string("removing orig file ")
489 + filename.latin1() 491 + filename.latin1()
490 + " failed!"); 492 + " failed!");
491 } 493 }
492 } 494 }
493 f.setName(filename); 495 f.setName(filename);
494 if (!f.open(IO_ReadWrite)) { 496 if (!f.open(QIODevice::ReadWrite)) {
495 ret = e_openFile; 497 ret = e_openFile;
496 goto out_moveback; 498 goto out_moveback;
497 } 499 }
498 e = writeFileHeader(hashAlgo, hashAlgo, 500 e = writeFileHeader(hashAlgo, hashAlgo,
499 cryptAlgo, compress, 501 cryptAlgo, compress,
500 &currentPw, &f); 502 &currentPw, &f);
501 if (e == e_hashNotImpl) { 503 if (e == e_hashNotImpl) {
502 printDebug("PwMDoc::saveDoc(): writeFileHeader() failed: e_hashNotImpl"); 504 printDebug("PwMDoc::saveDoc(): writeFileHeader() failed: e_hashNotImpl");
503 f.close(); 505 f.close();
504 ret = e_hashNotImpl; 506 ret = e_hashNotImpl;
505 goto out_moveback; 507 goto out_moveback;
506 } else if (e != e_success) { 508 } else if (e != e_success) {
507 printDebug("PwMDoc::saveDoc(): writeFileHeader() failed"); 509 printDebug("PwMDoc::saveDoc(): writeFileHeader() failed");
508 f.close(); 510 f.close();
509 ret = e_writeHeader; 511 ret = e_writeHeader;
510 goto out_moveback; 512 goto out_moveback;
511 } 513 }
512 if (!serializeDta(&serialized)) { 514 if (!serializeDta(&serialized)) {
513 printDebug("PwMDoc::saveDoc(): serializeDta() failed"); 515 printDebug("PwMDoc::saveDoc(): serializeDta() failed");
514 f.close(); 516 f.close();
515 ret = e_serializeDta; 517 ret = e_serializeDta;
516 goto out_moveback; 518 goto out_moveback;
517 } 519 }
518 e = writeDataHash(hashAlgo, &serialized, &f); 520 e = writeDataHash(hashAlgo, &serialized, &f);
519 if (e == e_hashNotImpl) { 521 if (e == e_hashNotImpl) {
520 printDebug("PwMDoc::saveDoc(): writeDataHash() failed: e_hashNotImpl"); 522 printDebug("PwMDoc::saveDoc(): writeDataHash() failed: e_hashNotImpl");
521 f.close(); 523 f.close();
522 ret = e_hashNotImpl; 524 ret = e_hashNotImpl;
523 goto out_moveback; 525 goto out_moveback;
524 } else if (e != e_success) { 526 } else if (e != e_success) {
525 printDebug("PwMDoc::saveDoc(): writeDataHash() failed"); 527 printDebug("PwMDoc::saveDoc(): writeDataHash() failed");
526 f.close(); 528 f.close();
527 ret = e_writeHeader; 529 ret = e_writeHeader;
528 goto out_moveback; 530 goto out_moveback;
529 } 531 }
530 if (!compressDta(&serialized, compress)) { 532 if (!compressDta(&serialized, compress)) {
531 printDebug("PwMDoc::saveDoc(): compressDta() failed"); 533 printDebug("PwMDoc::saveDoc(): compressDta() failed");
532 f.close(); 534 f.close();
533 ret = e_enc; 535 ret = e_enc;
534 goto out_moveback; 536 goto out_moveback;
535 } 537 }
536 e = encrypt(&serialized, &currentPw, &f, cryptAlgo, hashAlgo); 538 e = encrypt(&serialized, &currentPw, &f, cryptAlgo, hashAlgo);
537 if (e == e_weakPw) { 539 if (e == e_weakPw) {
538 printDebug("PwMDoc::saveDoc(): encrypt() failed: e_weakPw"); 540 printDebug("PwMDoc::saveDoc(): encrypt() failed: e_weakPw");
539 f.close(); 541 f.close();
540 ret = e_weakPw; 542 ret = e_weakPw;
541 goto out_moveback; 543 goto out_moveback;
542 } else if (e == e_cryptNotImpl) { 544 } else if (e == e_cryptNotImpl) {
543 printDebug("PwMDoc::saveDoc(): encrypt() failed: e_cryptNotImpl"); 545 printDebug("PwMDoc::saveDoc(): encrypt() failed: e_cryptNotImpl");
544 f.close(); 546 f.close();
545 ret = e_cryptNotImpl; 547 ret = e_cryptNotImpl;
546 goto out_moveback; 548 goto out_moveback;
547 } else if (e != e_success) { 549 } else if (e != e_success) {
548 printDebug("PwMDoc::saveDoc(): encrypt() failed"); 550 printDebug("PwMDoc::saveDoc(): encrypt() failed");
549 f.close(); 551 f.close();
550 ret = e_enc; 552 ret = e_enc;
551 goto out_moveback; 553 goto out_moveback;
552 } 554 }
553 unsetDocStatFlag(DOC_STAT_DISK_DIRTY); 555 unsetDocStatFlag(DOC_STAT_DISK_DIRTY);
554 f.close(); 556 f.close();
555#ifndef _WIN32_ 557#ifndef _WIN32_
556 if (chmod(filename.latin1(), 558 if (chmod(filename.latin1(),
557 conf()->confGlobFilePermissions())) { 559 conf()->confGlobFilePermissions())) {
558 printWarn(string("chmod failed: ") + strerror(errno)); 560 printWarn(string("chmod failed: ") + strerror(errno));
559 } 561 }
560#endif 562#endif
561 openDocList.edit(this, getTitle().latin1()); 563 openDocList.edit(this, getTitle().latin1());
562 if (wasDeepLocked) { 564 if (wasDeepLocked) {
563 /* Do _not_ save the data with the deepLock() 565 /* Do _not_ save the data with the deepLock()
564 * call, because this will recurse 566 * call, because this will recurse
565 * into saveDoc() 567 * into saveDoc()
566 */ 568 */
567 deepLock(true, false); 569 deepLock(true, false);
568 /* We don't check return value here, because 570 /* We don't check return value here, because
569 * it won't fail. See NOTE in deepLock() 571 * it won't fail. See NOTE in deepLock()
570 */ 572 */
571 } 573 }
572 if (tmpFileMoved != QString::null) { 574 if (tmpFileMoved != QString::null) {
573 // now remove the moved file. 575 // now remove the moved file.
574 if (!QFile::remove(tmpFileMoved)) { 576 if (!QFile::remove(tmpFileMoved)) {
575 printWarn(string("removing file ") 577 printWarn(string("removing file ")
576 + tmpFileMoved.latin1() 578 + tmpFileMoved.latin1()
577 + " failed!"); 579 + " failed!");
578 } 580 }
579 } 581 }
580 ret = e_success; 582 ret = e_success;
581 printDebug(string("writing file { name: ") 583 printDebug(string("writing file { name: ")
582 + filename.latin1() + " compress: " 584 + filename.latin1() + " compress: "
583 + tostr(static_cast<int>(compress)) + " cryptAlgo: " 585 + tostr(static_cast<int>(compress)) + " cryptAlgo: "
584 + tostr(static_cast<int>(cryptAlgo)) + " hashAlgo: " 586 + tostr(static_cast<int>(cryptAlgo)) + " hashAlgo: "
585 + tostr(static_cast<int>(hashAlgo)) 587 + tostr(static_cast<int>(hashAlgo))
586 + " }"); 588 + " }");
587 goto out; 589 goto out;
588out_moveback: 590out_moveback:
589 if (tmpFileMoved != QString::null) { 591 if (tmpFileMoved != QString::null) {
590 if (copyFile(tmpFileMoved, filename)) { 592 if (copyFile(tmpFileMoved, filename)) {
591 if (!QFile::remove(tmpFileMoved)) { 593 if (!QFile::remove(tmpFileMoved)) {
592 printWarn(string("removing tmp file ") 594 printWarn(string("removing tmp file ")
593 + filename.latin1() 595 + filename.latin1()
594 + " failed!"); 596 + " failed!");
595 } 597 }
596 } else { 598 } else {
597 printWarn(string("couldn't copy file ") 599 printWarn(string("couldn't copy file ")
598 + tmpFileMoved.latin1() 600 + tmpFileMoved.latin1()
599 + " back to " 601 + " back to "
600 + filename.latin1()); 602 + filename.latin1());
601 } 603 }
602 } 604 }
603out: 605out:
604 return ret; 606 return ret;
605} 607}
606 608
607PwMerror PwMDoc::openDoc(const QString *file, int openLocked) 609PwMerror PwMDoc::openDoc(const QString *file, int openLocked)
608{ 610{
609 PWM_ASSERT(file); 611 PWM_ASSERT(file);
610 PWM_ASSERT(openLocked == 0 || openLocked == 1 || openLocked == 2); 612 PWM_ASSERT(openLocked == 0 || openLocked == 1 || openLocked == 2);
611 string decrypted, dataHash; 613 string decrypted, dataHash;
612 PwMerror ret; 614 PwMerror ret;
613 char cryptAlgo, dataHashType, compress; 615 char cryptAlgo, dataHashType, compress;
614 unsigned int headerLen; 616 unsigned int headerLen;
615 617
616 if (*file == "") 618 if (*file == "")
617 return e_readFile; 619 return e_readFile;
618 filename = *file; 620 filename = *file;
619 /* check if this file is already open. 621 /* check if this file is already open.
620 * This does not catch symlinks! 622 * This does not catch symlinks!
621 */ 623 */
622 if (!isDeepLocked()) { 624 if (!isDeepLocked()) {
623 if (getOpenDocList()->find(filename.latin1())) 625 if (getOpenDocList()->find(filename.latin1()))
624 return e_alreadyOpen; 626 return e_alreadyOpen;
625 } 627 }
626 QFile f(filename); 628 QFile f(filename);
627 629
628 if (openLocked == 2) { 630 if (openLocked == 2) {
629 // open deep-locked 631 // open deep-locked
630 if (!QFile::exists(filename)) 632 if (!QFile::exists(filename))
631 return e_openFile; 633 return e_openFile;
632 if (deepLock(true, false) != e_success) 634 if (deepLock(true, false) != e_success)
633 return e_openFile; 635 return e_openFile;
634 goto out_success; 636 goto out_success;
635 } 637 }
636 638
637 if (!f.open(IO_ReadOnly)) 639 if (!f.open(QIODevice::ReadOnly))
638 return e_openFile; 640 return e_openFile;
639 641
640 ret = checkHeader(&cryptAlgo, &currentPw, &compress, &headerLen, 642 ret = checkHeader(&cryptAlgo, &currentPw, &compress, &headerLen,
641 &dataHashType, &dataHash, &f); 643 &dataHashType, &dataHash, &f);
642 if (ret != e_success) { 644 if (ret != e_success) {
643 printDebug("PwMDoc::openDoc(): checkHeader() failed"); 645 printDebug("PwMDoc::openDoc(): checkHeader() failed");
644 f.close(); 646 f.close();
645 if (ret == e_wrongPw) { 647 if (ret == e_wrongPw) {
646 wrongMpwMsgBox(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); 648 wrongMpwMsgBox(getDocStatFlag(DOC_STAT_USE_CHIPCARD));
647 return ret; 649 return ret;
648 } else if (ret == e_noPw || 650 } else if (ret == e_noPw ||
649 ret == e_fileVer || 651 ret == e_fileVer ||
650 ret == e_fileFormat || 652 ret == e_fileFormat ||
651 ret == e_hashNotImpl) { 653 ret == e_hashNotImpl) {
652 return ret; 654 return ret;
653 } else 655 } else
654 return e_readFile; 656 return e_readFile;
655 } 657 }
656 ret = decrypt(&decrypted, headerLen, &currentPw, cryptAlgo, dataHashType, &f); 658 ret = decrypt(&decrypted, headerLen, &currentPw, cryptAlgo, dataHashType, &f);
657 if (ret == e_cryptNotImpl) { 659 if (ret == e_cryptNotImpl) {
658 printDebug("PwMDoc::openDoc(): decrypt() failed: e_cryptNotImpl"); 660 printDebug("PwMDoc::openDoc(): decrypt() failed: e_cryptNotImpl");
659 f.close(); 661 f.close();
660 return e_cryptNotImpl; 662 return e_cryptNotImpl;
661 } else if (ret != e_success) { 663 } else if (ret != e_success) {
662 printDebug("PwMDoc::openDoc(): decrypt() failed"); 664 printDebug("PwMDoc::openDoc(): decrypt() failed");
663 f.close(); 665 f.close();
664 return e_readFile; 666 return e_readFile;
665 } 667 }
666 if (!decompressDta(&decrypted, compress)) { 668 if (!decompressDta(&decrypted, compress)) {
667 printDebug("PwMDoc::openDoc(): decompressDta() failed"); 669 printDebug("PwMDoc::openDoc(): decompressDta() failed");
668 f.close(); 670 f.close();
669 return e_fileCorrupt; 671 return e_fileCorrupt;
670 } 672 }
671 ret = checkDataHash(dataHashType, &dataHash, &decrypted); 673 ret = checkDataHash(dataHashType, &dataHash, &decrypted);
672 if (ret == e_hashNotImpl) { 674 if (ret == e_hashNotImpl) {
673 printDebug("PwMDoc::openDoc(): checkDataHash() failed: e_hashNotImpl"); 675 printDebug("PwMDoc::openDoc(): checkDataHash() failed: e_hashNotImpl");
674 f.close(); 676 f.close();
675 return e_hashNotImpl; 677 return e_hashNotImpl;
676 } else if (ret != e_success) { 678 } else if (ret != e_success) {
677 printDebug("PwMDoc::openDoc(): checkDataHash() failed"); 679 printDebug("PwMDoc::openDoc(): checkDataHash() failed");
678 f.close(); 680 f.close();
679 return e_fileCorrupt; 681 return e_fileCorrupt;
680 } 682 }
681 if (!deSerializeDta(&decrypted, openLocked == 1)) { 683 if (!deSerializeDta(&decrypted, openLocked == 1)) {
682 printDebug("PwMDoc::openDoc(): deSerializeDta() failed"); 684 printDebug("PwMDoc::openDoc(): deSerializeDta() failed");
683 f.close(); 685 f.close();
684 return e_readFile; 686 return e_readFile;
685 } 687 }
686 f.close(); 688 f.close();
687 timer()->start(DocTimer::id_mpwTimer); 689 timer()->start(DocTimer::id_mpwTimer);
688 timer()->start(DocTimer::id_autoLockTimer); 690 timer()->start(DocTimer::id_autoLockTimer);
689out_success: 691out_success:
690 openDocList.edit(this, getTitle().latin1()); 692 openDocList.edit(this, getTitle().latin1());
691 emit docOpened(this); 693 emit docOpened(this);
692 return e_success; 694 return e_success;
693} 695}
694 696
695PwMerror PwMDoc::writeFileHeader(char keyHash, char dataHash, char crypt, char compress, 697PwMerror PwMDoc::writeFileHeader(char keyHash, char dataHash, char crypt, char compress,
696 QString *pw, QFile *f) 698 QString *pw, QFile *f)
697{ 699{
698 PWM_ASSERT(pw); 700 PWM_ASSERT(pw);
699 PWM_ASSERT(f); 701 PWM_ASSERT(f);
700 //US ENH: or maybe a bug: checking here for listView does not make sense because we do not check anywhere else 702 //US ENH: or maybe a bug: checking here for listView does not make sense because we do not check anywhere else
701 //Wenn I sync, I open a doc without a view => listView is 0 => Assertion 703 //Wenn I sync, I open a doc without a view => listView is 0 => Assertion
702 //USPWM_ASSERT(listView); 704 //USPWM_ASSERT(listView);
703 if (f->writeBlock(FILE_ID_HEADER, strlen(FILE_ID_HEADER)) != 705 if (f->writeBlock(FILE_ID_HEADER, strlen(FILE_ID_HEADER)) !=
704 static_cast<Q_LONG>(strlen(FILE_ID_HEADER))) { 706 static_cast<Q_LONG>(strlen(FILE_ID_HEADER))) {
705 return e_writeFile; 707 return e_writeFile;
706 } 708 }
707 if (f->putch(PWM_FILE_VER) == -1 || 709 if (f->putch(PWM_FILE_VER) == -1 ||
708 f->putch(keyHash) == -1 || 710 f->putch(keyHash) == -1 ||
709 f->putch(dataHash) == -1 || 711 f->putch(dataHash) == -1 ||
710 f->putch(crypt) == -1 || 712 f->putch(crypt) == -1 ||
711 f->putch(compress) == -1 || 713 f->putch(compress) == -1 ||
712 f->putch((getDocStatFlag(DOC_STAT_USE_CHIPCARD)) ? 714 f->putch((getDocStatFlag(DOC_STAT_USE_CHIPCARD)) ?
713 (static_cast<char>(0x01)) : (static_cast<char>(0x00))) == -1) { 715 (static_cast<char>(0x01)) : (static_cast<char>(0x00))) == -1) {
714 return e_writeFile; 716 return e_writeFile;
715 } 717 }
716 718
717 // write bytes of NUL-data. These bytes are reserved for future-use. 719 // write bytes of NUL-data. These bytes are reserved for future-use.
718 const int bufSize = 64; 720 const int bufSize = 64;
719 char tmp_buf[bufSize]; 721 char tmp_buf[bufSize];
720 memset(tmp_buf, 0x00, bufSize); 722 memset(tmp_buf, 0x00, bufSize);
721 if (f->writeBlock(tmp_buf, bufSize) != bufSize) 723 if (f->writeBlock(tmp_buf, bufSize) != bufSize)
722 return e_writeFile; 724 return e_writeFile;
723 725
724 switch (keyHash) { 726 switch (keyHash) {
725 case PWM_HASH_SHA1: { 727 case PWM_HASH_SHA1: {
726 const int hashlen = SHA1_HASH_LEN_BYTE; 728 const int hashlen = SHA1_HASH_LEN_BYTE;
727 Sha1 hash; 729 Sha1 hash;
728 hash.sha1_write(reinterpret_cast<const byte *>(pw->latin1()), pw->length()); 730 hash.sha1_write(reinterpret_cast<const byte *>(pw->latin1()), pw->length());
729 string ret = hash.sha1_read(); 731 string ret = hash.sha1_read();
730 if (f->writeBlock(ret.c_str(), hashlen) != hashlen) 732 if (f->writeBlock(ret.c_str(), hashlen) != hashlen)
731 return e_writeFile; 733 return e_writeFile;
732 break; 734 break;
733 } 735 }
734 case PWM_HASH_SHA256: 736 case PWM_HASH_SHA256:
735 /*... fall through */ 737 /*... fall through */
736 case PWM_HASH_SHA384: 738 case PWM_HASH_SHA384:
737 case PWM_HASH_SHA512: 739 case PWM_HASH_SHA512:
738 case PWM_HASH_MD5: 740 case PWM_HASH_MD5:
739 case PWM_HASH_RMD160: 741 case PWM_HASH_RMD160:
740 case PWM_HASH_TIGER: 742 case PWM_HASH_TIGER:
741 { 743 {
742 if (!LibGCryptIf::available()) 744 if (!LibGCryptIf::available())
743 return e_hashNotImpl; 745 return e_hashNotImpl;
744 LibGCryptIf gc; 746 LibGCryptIf gc;
745 PwMerror err; 747 PwMerror err;
746 unsigned char *buf; 748 unsigned char *buf;
747 size_t hashLen; 749 size_t hashLen;
748 err = gc.hash(&buf, 750 err = gc.hash(&buf,
749 &hashLen, 751 &hashLen,
750 reinterpret_cast<const unsigned char *>(pw->latin1()), 752 reinterpret_cast<const unsigned char *>(pw->latin1()),
751 pw->length(), 753 pw->length(),
752 keyHash); 754 keyHash);
753 if (err != e_success) 755 if (err != e_success)
754 return e_hashNotImpl; 756 return e_hashNotImpl;
755 if (f->writeBlock(reinterpret_cast<const char *>(buf), hashLen) 757 if (f->writeBlock(reinterpret_cast<const char *>(buf), hashLen)
756 != static_cast<Q_LONG>(hashLen)) { 758 != static_cast<Q_LONG>(hashLen)) {
757 delete [] buf; 759 delete [] buf;
758 return e_hashNotImpl; 760 return e_hashNotImpl;
759 } 761 }
760 delete [] buf; 762 delete [] buf;
761 break; 763 break;
762 } 764 }
763 default: { 765 default: {
764 return e_hashNotImpl; 766 return e_hashNotImpl;
765 } } 767 } }
766 return e_success; 768 return e_success;
767} 769}
768 770
769PwMerror PwMDoc::checkHeader(char *cryptAlgo, QString *pw, char *compress, 771PwMerror PwMDoc::checkHeader(char *cryptAlgo, QString *pw, char *compress,
770 unsigned int *headerLength, char *dataHashType, 772 unsigned int *headerLength, char *dataHashType,
771 string *dataHash, QFile *f) 773 string *dataHash, QFile *f)
772{ 774{
773 PWM_ASSERT(cryptAlgo); 775 PWM_ASSERT(cryptAlgo);
774 PWM_ASSERT(pw); 776 PWM_ASSERT(pw);
775 PWM_ASSERT(headerLength); 777 PWM_ASSERT(headerLength);
776 PWM_ASSERT(dataHashType); 778 PWM_ASSERT(dataHashType);
777 PWM_ASSERT(dataHash); 779 PWM_ASSERT(dataHash);
778 PWM_ASSERT(f); 780 PWM_ASSERT(f);
779 int tmpRet; 781 int tmpRet;
780 // check "magic" header 782 // check "magic" header
781 const char magicHdr[] = FILE_ID_HEADER; 783 const char magicHdr[] = FILE_ID_HEADER;
782 const int hdrLen = array_size(magicHdr) - 1; 784 const int hdrLen = array_size(magicHdr) - 1;
783 char tmp[hdrLen]; 785 char tmp[hdrLen];
784 if (f->readBlock(tmp, hdrLen) != hdrLen) 786 if (f->readBlock(tmp, hdrLen) != hdrLen)
785 return e_readFile; 787 return e_readFile;
786 if (memcmp(tmp, magicHdr, hdrLen) != 0) 788 if (memcmp(tmp, magicHdr, hdrLen) != 0)
787 return e_fileFormat; 789 return e_fileFormat;
788 // read and check file ver 790 // read and check file ver
789 int fileV = f->getch(); 791 int fileV = f->getch();
790 if (fileV == -1) 792 if (fileV == -1)
791 return e_fileFormat; 793 return e_fileFormat;
792 if (fileV != PWM_FILE_VER) 794 if (fileV != PWM_FILE_VER)
793 return e_fileVer; 795 return e_fileVer;
794 // read hash hash type 796 // read hash hash type
795 int keyHash = f->getch(); 797 int keyHash = f->getch();
796 if (keyHash == -1) 798 if (keyHash == -1)
797 return e_fileFormat; 799 return e_fileFormat;
798 // read data hash type 800 // read data hash type
799 tmpRet = f->getch(); 801 tmpRet = f->getch();
800 if (tmpRet == -1) 802 if (tmpRet == -1)
801 return e_fileFormat; 803 return e_fileFormat;
802 *dataHashType = tmpRet; 804 *dataHashType = tmpRet;
803 // read crypt algo 805 // read crypt algo
804 tmpRet = f->getch(); 806 tmpRet = f->getch();
805 if (tmpRet == -1) 807 if (tmpRet == -1)
806 return e_fileFormat; 808 return e_fileFormat;
807 *cryptAlgo = tmpRet; 809 *cryptAlgo = tmpRet;
808 // get compression-algo 810 // get compression-algo
809 tmpRet = f->getch(); 811 tmpRet = f->getch();
810 if (tmpRet == -1) 812 if (tmpRet == -1)
811 return e_fileFormat; 813 return e_fileFormat;
812 *compress = tmpRet; 814 *compress = tmpRet;
813 // get the MPW-flag 815 // get the MPW-flag
814 int mpw_flag = f->getch(); 816 int mpw_flag = f->getch();
815 if (mpw_flag == -1) 817 if (mpw_flag == -1)
816 return e_fileFormat; 818 return e_fileFormat;
817 if (mpw_flag == 0x01) 819 if (mpw_flag == 0x01)
818 setDocStatFlag(DOC_STAT_USE_CHIPCARD); 820 setDocStatFlag(DOC_STAT_USE_CHIPCARD);
819 else 821 else
820 unsetDocStatFlag(DOC_STAT_USE_CHIPCARD); 822 unsetDocStatFlag(DOC_STAT_USE_CHIPCARD);
821 // skip the "RESERVED"-bytes 823 // skip the "RESERVED"-bytes
822 if (!(f->at(f->at() + 64))) 824 if (!(f->at(f->at() + 64)))
823 return e_fileFormat; 825 return e_fileFormat;
824 826
825 *pw = requestMpw(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); 827 *pw = requestMpw(getDocStatFlag(DOC_STAT_USE_CHIPCARD));
826 if (*pw == "") { 828 if (*pw == "") {
827 /* the user didn't give a master-password 829 /* the user didn't give a master-password
828 * or didn't insert a chipcard 830 * or didn't insert a chipcard
829 */ 831 */
830 return e_noPw; 832 return e_noPw;
831 } 833 }
832 // verify key-hash 834 // verify key-hash
833 switch (keyHash) { 835 switch (keyHash) {
834 case PWM_HASH_SHA1: { 836 case PWM_HASH_SHA1: {
835 // read hash from header 837 // read hash from header
836 const int hashLen = SHA1_HASH_LEN_BYTE; 838 const int hashLen = SHA1_HASH_LEN_BYTE;
837 string readHash; 839 string readHash;
838 int i; 840 int i;
839 for (i = 0; i < hashLen; ++i) 841 for (i = 0; i < hashLen; ++i)
840 readHash.push_back(f->getch()); 842 readHash.push_back(f->getch());
841 Sha1 hash; 843 Sha1 hash;
842 hash.sha1_write(reinterpret_cast<const byte *>(pw->latin1()), pw->length()); 844 hash.sha1_write(reinterpret_cast<const byte *>(pw->latin1()), pw->length());
843 string ret = hash.sha1_read(); 845 string ret = hash.sha1_read();
844 if (ret != readHash) 846 if (ret != readHash)
845 return e_wrongPw;// hash doesn't match (wrong key) 847 return e_wrongPw;// hash doesn't match (wrong key)
846 break; 848 break;
847 } 849 }
848 case PWM_HASH_SHA256: 850 case PWM_HASH_SHA256:
849 /*... fall through */ 851 /*... fall through */
850 case PWM_HASH_SHA384: 852 case PWM_HASH_SHA384:
851 case PWM_HASH_SHA512: 853 case PWM_HASH_SHA512:
852 case PWM_HASH_MD5: 854 case PWM_HASH_MD5:
853 case PWM_HASH_RMD160: 855 case PWM_HASH_RMD160:
854 case PWM_HASH_TIGER: { 856 case PWM_HASH_TIGER: {
855 if (!LibGCryptIf::available()) 857 if (!LibGCryptIf::available())
856 return e_hashNotImpl; 858 return e_hashNotImpl;
857 LibGCryptIf gc; 859 LibGCryptIf gc;
858 PwMerror err; 860 PwMerror err;
859 unsigned char *buf; 861 unsigned char *buf;
860 size_t hashLen; 862 size_t hashLen;
861 err = gc.hash(&buf, 863 err = gc.hash(&buf,
862 &hashLen, 864 &hashLen,
863 reinterpret_cast<const unsigned char *>(pw->latin1()), 865 reinterpret_cast<const unsigned char *>(pw->latin1()),
864 pw->length(), 866 pw->length(),
865 keyHash); 867 keyHash);
866 if (err != e_success) 868 if (err != e_success)
867 return e_hashNotImpl; 869 return e_hashNotImpl;
868 string calcHash(reinterpret_cast<const char *>(buf), 870 string calcHash(reinterpret_cast<const char *>(buf),
869 static_cast<string::size_type>(hashLen)); 871 static_cast<string::size_type>(hashLen));
870 delete [] buf; 872 delete [] buf;
871 // read hash from header 873 // read hash from header
872 string readHash; 874 string readHash;
873 size_t i; 875 size_t i;
874 for (i = 0; i < hashLen; ++i) 876 for (i = 0; i < hashLen; ++i)
875 readHash.push_back(f->getch()); 877 readHash.push_back(f->getch());
876 if (calcHash != readHash) 878 if (calcHash != readHash)
877 return e_wrongPw;// hash doesn't match (wrong key) 879 return e_wrongPw;// hash doesn't match (wrong key)
878 break; 880 break;
879 } 881 }
880 default: { 882 default: {
881 return e_hashNotImpl; 883 return e_hashNotImpl;
882 } } 884 } }
883 // read the data-hash from the file 885 // read the data-hash from the file
884 unsigned int hashLen, i; 886 unsigned int hashLen, i;
885 switch (*dataHashType) { 887 switch (*dataHashType) {
886 case PWM_HASH_SHA1: 888 case PWM_HASH_SHA1:
887 hashLen = SHA1_HASH_LEN_BYTE; 889 hashLen = SHA1_HASH_LEN_BYTE;
888 break; 890 break;
889 case PWM_HASH_SHA256: 891 case PWM_HASH_SHA256:
890 /*... fall through */ 892 /*... fall through */
891 case PWM_HASH_SHA384: 893 case PWM_HASH_SHA384:
892 case PWM_HASH_SHA512: 894 case PWM_HASH_SHA512:
893 case PWM_HASH_MD5: 895 case PWM_HASH_MD5:
894 case PWM_HASH_RMD160: 896 case PWM_HASH_RMD160:
895 case PWM_HASH_TIGER: { 897 case PWM_HASH_TIGER: {
896 if (!LibGCryptIf::available()) 898 if (!LibGCryptIf::available())
897 return e_hashNotImpl; 899 return e_hashNotImpl;
898 LibGCryptIf gc; 900 LibGCryptIf gc;
899 hashLen = gc.hashLength(*dataHashType); 901 hashLen = gc.hashLength(*dataHashType);
900 if (hashLen == 0) 902 if (hashLen == 0)
901 return e_hashNotImpl; 903 return e_hashNotImpl;
902 break; 904 break;
903 } 905 }
904 default: 906 default:
905 return e_hashNotImpl; 907 return e_hashNotImpl;
906 } 908 }
907 *dataHash = ""; 909 *dataHash = "";
908 for (i = 0; i < hashLen; ++i) { 910 for (i = 0; i < hashLen; ++i) {
909 tmpRet = f->getch(); 911 tmpRet = f->getch();
910 if (tmpRet == -1) 912 if (tmpRet == -1)
911 return e_fileFormat; 913 return e_fileFormat;
912 dataHash->push_back(static_cast<char>(tmpRet)); 914 dataHash->push_back(static_cast<char>(tmpRet));
913 } 915 }
914 *headerLength = f->at(); 916 *headerLength = f->at();
915#ifndef PWM_EMBEDDED 917#ifndef PWM_EMBEDDED
916 printDebug(string("opening file { compress: ") 918 printDebug(string("opening file { compress: ")
917 + tostr(static_cast<int>(*compress)) + " cryptAlgo: " 919 + tostr(static_cast<int>(*compress)) + " cryptAlgo: "
918 + tostr(static_cast<int>(*cryptAlgo)) + " keyHashAlgo: " 920 + tostr(static_cast<int>(*cryptAlgo)) + " keyHashAlgo: "
919 + tostr(static_cast<int>(keyHash)) 921 + tostr(static_cast<int>(keyHash))
920 + " }"); 922 + " }");
921#else 923#else
922 printDebug(string("opening file { compress: ") 924 printDebug(string("opening file { compress: ")
923 + tostr((int)(*compress)) + " cryptAlgo: " 925 + tostr((int)(*compress)) + " cryptAlgo: "
924 + tostr((int)(*cryptAlgo)) + " keyHashAlgo: " 926 + tostr((int)(*cryptAlgo)) + " keyHashAlgo: "
925 + tostr((int)(keyHash)) 927 + tostr((int)(keyHash))
926 + " }"); 928 + " }");
927#endif 929#endif
928 930
929 return e_success; 931 return e_success;
930} 932}
931 933
932PwMerror PwMDoc::writeDataHash(char dataHash, string *d, QFile *f) 934PwMerror PwMDoc::writeDataHash(char dataHash, string *d, QFile *f)
933{ 935{
934 PWM_ASSERT(d); 936 PWM_ASSERT(d);
935 PWM_ASSERT(f); 937 PWM_ASSERT(f);
936 938
937 switch (dataHash) { 939 switch (dataHash) {
938 case PWM_HASH_SHA1: { 940 case PWM_HASH_SHA1: {
939 const int hashLen = SHA1_HASH_LEN_BYTE; 941 const int hashLen = SHA1_HASH_LEN_BYTE;
940 Sha1 h; 942 Sha1 h;
941 h.sha1_write(reinterpret_cast<const byte *>(d->c_str()), d->size()); 943 h.sha1_write(reinterpret_cast<const byte *>(d->c_str()), d->size());
942 string hRet = h.sha1_read(); 944 string hRet = h.sha1_read();
943 if (f->writeBlock(hRet.c_str(), hashLen) != hashLen) 945 if (f->writeBlock(hRet.c_str(), hashLen) != hashLen)
944 return e_writeFile; 946 return e_writeFile;
945 break; 947 break;
946 } 948 }
947 case PWM_HASH_SHA256: 949 case PWM_HASH_SHA256:
948 /*... fall through */ 950 /*... fall through */
949 case PWM_HASH_SHA384: 951 case PWM_HASH_SHA384:
950 case PWM_HASH_SHA512: 952 case PWM_HASH_SHA512:
951 case PWM_HASH_MD5: 953 case PWM_HASH_MD5:
952 case PWM_HASH_RMD160: 954 case PWM_HASH_RMD160:
953 case PWM_HASH_TIGER: { 955 case PWM_HASH_TIGER: {
954 if (!LibGCryptIf::available()) 956 if (!LibGCryptIf::available())
955 return e_hashNotImpl; 957 return e_hashNotImpl;
956 LibGCryptIf gc; 958 LibGCryptIf gc;
957 PwMerror err; 959 PwMerror err;
958 unsigned char *buf; 960 unsigned char *buf;
959 size_t hashLen; 961 size_t hashLen;
960 err = gc.hash(&buf, 962 err = gc.hash(&buf,
961 &hashLen, 963 &hashLen,
962 reinterpret_cast<const unsigned char *>(d->c_str()), 964 reinterpret_cast<const unsigned char *>(d->c_str()),
963 d->size(), 965 d->size(),
964 dataHash); 966 dataHash);
965 if (err != e_success) 967 if (err != e_success)
966 return e_hashNotImpl; 968 return e_hashNotImpl;
967 if (f->writeBlock(reinterpret_cast<const char *>(buf), hashLen) 969 if (f->writeBlock(reinterpret_cast<const char *>(buf), hashLen)
968 != static_cast<Q_LONG>(hashLen)) { 970 != static_cast<Q_LONG>(hashLen)) {
969 delete [] buf; 971 delete [] buf;
970 return e_hashNotImpl; 972 return e_hashNotImpl;
971 } 973 }
972 delete [] buf; 974 delete [] buf;
973 break; 975 break;
974 } 976 }
975 default: { 977 default: {
976 return e_hashNotImpl; 978 return e_hashNotImpl;
977 } } 979 } }
978 980
979 return e_success; 981 return e_success;
980} 982}
981 983
982bool PwMDoc::backupFile(const QString &filePath) 984bool PwMDoc::backupFile(const QString &filePath)
983{ 985{
984 QFileInfo fi(filePath); 986 QFileInfo fi(filePath);
985 if (!fi.exists()) 987 if (!fi.exists())
986 return true; // Yes, true is correct. 988 return true; // Yes, true is correct.
987 QString pathOnly(fi.dirPath(true)); 989 QString pathOnly(fi.dirPath(true));
988 QString nameOnly(fi.fileName()); 990 QString nameOnly(fi.fileName());
989 QString backupPath = pathOnly 991 QString backupPath = pathOnly
990 + "/~" 992 + "/~"
991 + nameOnly 993 + nameOnly
992 + ".backup"; 994 + ".backup";
993 return copyFile(filePath, backupPath); 995 return copyFile(filePath, backupPath);
994} 996}
995 997
996bool PwMDoc::copyFile(const QString &src, const QString &dst) 998bool PwMDoc::copyFile(const QString &src, const QString &dst)
997{ 999{
998 QFileInfo fi(src); 1000 QFileInfo fi(src);
999 if (!fi.exists()) 1001 if (!fi.exists())
1000 return false; 1002 return false;
1001 if (QFile::exists(dst)) { 1003 if (QFile::exists(dst)) {
1002 if (!QFile::remove(dst)) 1004 if (!QFile::remove(dst))
1003 return false; 1005 return false;
1004 } 1006 }
1005 QFile srcFd(src); 1007 QFile srcFd(src);
1006 if (!srcFd.open(IO_ReadOnly)) 1008 if (!srcFd.open(QIODevice::ReadOnly))
1007 return false; 1009 return false;
1008 QFile dstFd(dst); 1010 QFile dstFd(dst);
1009 if (!dstFd.open(IO_ReadWrite)) { 1011 if (!dstFd.open(QIODevice::ReadWrite)) {
1010 srcFd.close(); 1012 srcFd.close();
1011 return false; 1013 return false;
1012 } 1014 }
1013 const int tmpBuf_size = 512; 1015 const int tmpBuf_size = 512;
1014 char tmpBuf[tmpBuf_size]; 1016 char tmpBuf[tmpBuf_size];
1015 Q_LONG bytesRead, bytesWritten; 1017 Q_LONG bytesRead, bytesWritten;
1016 1018
1017 while (!srcFd.atEnd()) { 1019 while (!srcFd.atEnd()) {
1018 bytesRead = srcFd.readBlock(tmpBuf, 1020 bytesRead = srcFd.readBlock(tmpBuf,
1019 static_cast<Q_ULONG>(tmpBuf_size)); 1021 static_cast<Q_ULONG>(tmpBuf_size));
1020 if (bytesRead == -1) { 1022 if (bytesRead == -1) {
1021 srcFd.close(); 1023 srcFd.close();
1022 dstFd.close(); 1024 dstFd.close();
1023 return false; 1025 return false;
1024 } 1026 }
1025 bytesWritten = dstFd.writeBlock(tmpBuf, 1027 bytesWritten = dstFd.writeBlock(tmpBuf,
1026 static_cast<Q_ULONG>(bytesRead)); 1028 static_cast<Q_ULONG>(bytesRead));
1027 if (bytesWritten != bytesRead) { 1029 if (bytesWritten != bytesRead) {
1028 srcFd.close(); 1030 srcFd.close();
1029 dstFd.close(); 1031 dstFd.close();
1030 return false; 1032 return false;
1031 } 1033 }
1032 } 1034 }
1033 srcFd.close(); 1035 srcFd.close();
1034 dstFd.close(); 1036 dstFd.close();
1035 return true; 1037 return true;
1036} 1038}
1037 1039
1038PwMerror PwMDoc::addEntry(const QString &category, PwMDataItem *d, 1040PwMerror PwMDoc::addEntry(const QString &category, PwMDataItem *d,
1039 bool dontFlagDirty, bool updateMeta) 1041 bool dontFlagDirty, bool updateMeta)
1040{ 1042{
1041 PWM_ASSERT(d); 1043 PWM_ASSERT(d);
1042 unsigned int cat = 0; 1044 unsigned int cat = 0;
1043 1045
1044 if (isDeepLocked()) { 1046 if (isDeepLocked()) {
1045 PwMerror ret; 1047 PwMerror ret;
1046 ret = deepLock(false); 1048 ret = deepLock(false);
1047 if (ret != e_success) 1049 if (ret != e_success)
1048 return e_lock; 1050 return e_lock;
1049 } 1051 }
1050 1052
1051 addCategory(category, &cat); 1053 addCategory(category, &cat);
1052 1054
1053 if (numEntries(category) >= maxEntries) 1055 if (numEntries(category) >= maxEntries)
1054 return e_maxAllowedEntr; 1056 return e_maxAllowedEntr;
1055 1057
1056 vector<unsigned int> foundPositions; 1058 vector<unsigned int> foundPositions;
1057 /* historically this was: 1059 /* historically this was:
1058 *const int searchIn = SEARCH_IN_DESC | SEARCH_IN_NAME | 1060 *const int searchIn = SEARCH_IN_DESC | SEARCH_IN_NAME |
1059 * SEARCH_IN_URL | SEARCH_IN_LAUNCHER; 1061 * SEARCH_IN_URL | SEARCH_IN_LAUNCHER;
1060 * But for now we only search in desc. 1062 * But for now we only search in desc.
1061 * That's a tweak to be KWallet compatible. But it should not add 1063 * That's a tweak to be KWallet compatible. But it should not add
1062 * usability-drop onto PwManager, does it? 1064 * usability-drop onto PwManager, does it?
1063 * (And yes, "int" was a bug. Correct is "unsigned int") 1065 * (And yes, "int" was a bug. Correct is "unsigned int")
1064 */ 1066 */
1065 const unsigned int searchIn = SEARCH_IN_DESC; 1067 const unsigned int searchIn = SEARCH_IN_DESC;
1066 findEntry(cat, *d, searchIn, &foundPositions, true); 1068 findEntry(cat, *d, searchIn, &foundPositions, true);
1067 if (foundPositions.size()) { 1069 if (foundPositions.size()) {
1068 // DOH! We found this entry. 1070 // DOH! We found this entry.
1069 return e_entryExists; 1071 return e_entryExists;
1070 } 1072 }
1071 1073
1072 d->listViewPos = -1; 1074 d->listViewPos = -1;
1073 d->lockStat = conf()->confGlobNewEntrLockStat(); 1075 d->lockStat = conf()->confGlobNewEntrLockStat();
1074 if (updateMeta) { 1076 if (updateMeta) {
1075 d->meta.create = QDateTime::currentDateTime(); 1077 d->meta.create = QDateTime::currentDateTime();
1076 d->meta.update = d->meta.create; 1078 d->meta.update = d->meta.create;
1077 } 1079 }
1078 dti.dta[cat].d.push_back(*d); 1080 dti.dta[cat].d.push_back(*d);
1079 1081
1080 delAllEmptyCat(true); 1082 delAllEmptyCat(true);
1081 1083
1082 if (!dontFlagDirty) 1084 if (!dontFlagDirty)
1083 flagDirty(); 1085 flagDirty();
1084 return e_success; 1086 return e_success;
1085} 1087}
1086 1088
1087PwMerror PwMDoc::addCategory(const QString &category, unsigned int *categoryIndex, 1089PwMerror PwMDoc::addCategory(const QString &category, unsigned int *categoryIndex,
1088 bool checkIfExist) 1090 bool checkIfExist)
1089{ 1091{
1090 if (isDeepLocked()) { 1092 if (isDeepLocked()) {
1091 PwMerror ret; 1093 PwMerror ret;
1092 ret = deepLock(false); 1094 ret = deepLock(false);
1093 if (ret != e_success) 1095 if (ret != e_success)
1094 return e_lock; 1096 return e_lock;
1095 } 1097 }
1096 if (checkIfExist) { 1098 if (checkIfExist) {
1097 if (findCategory(category, categoryIndex)) 1099 if (findCategory(category, categoryIndex))
1098 return e_categoryExists; 1100 return e_categoryExists;
1099 } 1101 }
1100 PwMCategoryItem item; 1102 PwMCategoryItem item;
1101 //US ENH: clear item to initialize with default values, or create a constructor 1103 //US ENH: clear item to initialize with default values, or create a constructor
1102 item.clear(); 1104 item.clear();
1103 1105
1104 item.name = category.latin1(); 1106 item.name = category.latin1();
1105 dti.dta.push_back(item); 1107 dti.dta.push_back(item);
1106 if (categoryIndex) 1108 if (categoryIndex)
1107 *categoryIndex = dti.dta.size() - 1; 1109 *categoryIndex = dti.dta.size() - 1;
1108 return e_success; 1110 return e_success;
1109} 1111}
1110 1112
1111bool PwMDoc::delEntry(const QString &category, unsigned int index, bool dontFlagDirty) 1113bool PwMDoc::delEntry(const QString &category, unsigned int index, bool dontFlagDirty)
1112{ 1114{
1113 unsigned int cat = 0; 1115 unsigned int cat = 0;
1114 1116
1115 if (!findCategory(category, &cat)) { 1117 if (!findCategory(category, &cat)) {
1116 BUG(); 1118 BUG();
1117 return false; 1119 return false;
1118 } 1120 }
1119 1121
1120 return delEntry(cat, index, dontFlagDirty); 1122 return delEntry(cat, index, dontFlagDirty);
1121} 1123}
1122 1124
1123bool PwMDoc::delEntry(unsigned int category, unsigned int index, bool dontFlagDirty) 1125bool PwMDoc::delEntry(unsigned int category, unsigned int index, bool dontFlagDirty)
1124{ 1126{
1125 if (isDeepLocked()) 1127 if (isDeepLocked())
1126 return false; 1128 return false;
1127 if (index > dti.dta[category].d.size() - 1) 1129 if (index > dti.dta[category].d.size() - 1)
1128 return false; 1130 return false;
1129 getDataChangedLock(); 1131 getDataChangedLock();
1130 if (!lockAt(category, index, false)) { 1132 if (!lockAt(category, index, false)) {
1131 putDataChangedLock(); 1133 putDataChangedLock();
1132 return false; 1134 return false;
1133 } 1135 }
1134 putDataChangedLock(); 1136 putDataChangedLock();
1135 int lvPos = dti.dta[category].d[index].listViewPos; 1137 int lvPos = dti.dta[category].d[index].listViewPos;
1136 1138
1137 // delete entry 1139 // delete entry
1138 dti.dta[category].d.erase(dti.dta[category].d.begin() + index); 1140 dti.dta[category].d.erase(dti.dta[category].d.begin() + index);
1139 1141
1140 unsigned int i, entries = numEntries(category); 1142 unsigned int i, entries = numEntries(category);
1141 if (!entries) { 1143 if (!entries) {
1142 // no more entries in this category, so 1144 // no more entries in this category, so
1143 // we can delete it, too. 1145 // we can delete it, too.
1144 BUG_ON(!delCategory(category)); 1146 BUG_ON(!delCategory(category));
1145 // delCategory() flags it dirty, so we need not to do so. 1147 // delCategory() flags it dirty, so we need not to do so.
1146 return true; 1148 return true;
1147 } 1149 }
1148 for (i = 0; i < entries; ++i) { 1150 for (i = 0; i < entries; ++i) {
1149 // decrement all listViewPositions that are greater than the deleted. 1151 // decrement all listViewPositions that are greater than the deleted.
1150 if (dti.dta[category].d[i].listViewPos > lvPos) 1152 if (dti.dta[category].d[i].listViewPos > lvPos)
1151 --dti.dta[category].d[i].listViewPos; 1153 --dti.dta[category].d[i].listViewPos;
1152 } 1154 }
1153 1155
1154 if (!dontFlagDirty) 1156 if (!dontFlagDirty)
1155 flagDirty(); 1157 flagDirty();
1156 return true; 1158 return true;
1157} 1159}
1158 1160
1159bool PwMDoc::editEntry(const QString &oldCategory, const QString &newCategory, 1161bool PwMDoc::editEntry(const QString &oldCategory, const QString &newCategory,
1160 unsigned int index, PwMDataItem *d, bool updateMeta) 1162 unsigned int index, PwMDataItem *d, bool updateMeta)
1161{ 1163{
1162 PWM_ASSERT(d); 1164 PWM_ASSERT(d);
1163 unsigned int oldCat = 0; 1165 unsigned int oldCat = 0;
1164 1166
1165 if (!findCategory(oldCategory, &oldCat)) { 1167 if (!findCategory(oldCategory, &oldCat)) {
1166 BUG(); 1168 BUG();
1167 return false; 1169 return false;
1168 } 1170 }
1169 1171
1170 return editEntry(oldCat, newCategory, index, d, updateMeta); 1172 return editEntry(oldCat, newCategory, index, d, updateMeta);
1171} 1173}
1172 1174
1173bool PwMDoc::editEntry(unsigned int oldCategory, const QString &newCategory, 1175bool PwMDoc::editEntry(unsigned int oldCategory, const QString &newCategory,
1174 unsigned int index, PwMDataItem *d, bool updateMeta) 1176 unsigned int index, PwMDataItem *d, bool updateMeta)
1175{ 1177{
1176 if (isDeepLocked()) 1178 if (isDeepLocked())
1177 return false; 1179 return false;
1178 if (updateMeta) { 1180 if (updateMeta) {
1179 d->meta.update = QDateTime::currentDateTime(); 1181 d->meta.update = QDateTime::currentDateTime();
1180 if (d->meta.create.isNull()) { 1182 if (d->meta.create.isNull()) {
1181 d->meta.create = d->meta.update; 1183 d->meta.create = d->meta.update;
1182 } 1184 }
1183 } 1185 }
1184 if (dti.dta[oldCategory].name != newCategory.latin1()) { 1186 if (dti.dta[oldCategory].name != newCategory.latin1()) {
1185 // the user changed the category. 1187 // the user changed the category.
1186 PwMerror ret; 1188 PwMerror ret;
1187 d->rev = 0; 1189 d->rev = 0;
1188 ret = addEntry(newCategory, d, true, false); 1190 ret = addEntry(newCategory, d, true, false);
1189 if (ret != e_success) 1191 if (ret != e_success)
1190 return false; 1192 return false;
1191 if (!delEntry(oldCategory, index, true)) 1193 if (!delEntry(oldCategory, index, true))
1192 return false; 1194 return false;
1193 } else { 1195 } else {
1194 d->rev = dti.dta[oldCategory].d[index].rev + 1; // increment revision counter. 1196 d->rev = dti.dta[oldCategory].d[index].rev + 1; // increment revision counter.
1195 dti.dta[oldCategory].d[index] = *d; 1197 dti.dta[oldCategory].d[index] = *d;
1196 } 1198 }
1197 flagDirty(); 1199 flagDirty();
1198 return true; 1200 return true;
1199} 1201}
1200 1202
1201unsigned int PwMDoc::numEntries(const QString &category) 1203unsigned int PwMDoc::numEntries(const QString &category)
1202{ 1204{
1203 unsigned int cat = 0; 1205 unsigned int cat = 0;
1204 1206
1205 if (!findCategory(category, &cat)) { 1207 if (!findCategory(category, &cat)) {
1206 BUG(); 1208 BUG();
1207 return 0; 1209 return 0;
1208 } 1210 }
1209 1211
1210 return numEntries(cat); 1212 return numEntries(cat);
1211} 1213}
1212 1214
1213bool PwMDoc::serializeDta(string *d) 1215bool PwMDoc::serializeDta(string *d)
1214{ 1216{
1215 PWM_ASSERT(d); 1217 PWM_ASSERT(d);
1216 Serializer ser; 1218 Serializer ser;
1217 if (!ser.serialize(dti)) 1219 if (!ser.serialize(dti))
1218 return false; 1220 return false;
1219 d->assign(ser.getXml()); 1221 d->assign(ser.getXml());
1220 if (!d->size()) 1222 if (!d->size())
1221 return false; 1223 return false;
1222 return true; 1224 return true;
1223} 1225}
1224 1226
1225bool PwMDoc::deSerializeDta(const string *d, bool entriesLocked) 1227bool PwMDoc::deSerializeDta(const string *d, bool entriesLocked)
1226{ 1228{
1227 PWM_ASSERT(d); 1229 PWM_ASSERT(d);
1228#ifndef PWM_EMBEDDED 1230#ifndef PWM_EMBEDDED
1229 try { 1231 try {
1230 1232
1231 Serializer ser(d->c_str()); 1233 Serializer ser(d->c_str());
1232 ser.setDefaultLockStat(entriesLocked); 1234 ser.setDefaultLockStat(entriesLocked);
1233 if (!ser.deSerialize(&dti)) 1235 if (!ser.deSerialize(&dti))
1234 return false; 1236 return false;
1235 } catch (PwMException) { 1237 } catch (PwMException) {
1236 return false; 1238 return false;
1237 } 1239 }
1238#else 1240#else
1239 Serializer ser(d->c_str()); 1241 Serializer ser(d->c_str());
1240 ser.setDefaultLockStat(entriesLocked); 1242 ser.setDefaultLockStat(entriesLocked);
1241 if (!ser.deSerialize(&dti)) 1243 if (!ser.deSerialize(&dti))
1242 return false; 1244 return false;
1243#endif 1245#endif
1244 1246
1245 emitDataChanged(this); 1247 emitDataChanged(this);
1246 return true; 1248 return true;
1247} 1249}
1248 1250
1249bool PwMDoc::getEntry(const QString &category, unsigned int index, 1251bool PwMDoc::getEntry(const QString &category, unsigned int index,
1250 PwMDataItem * d, bool unlockIfLocked) 1252 PwMDataItem * d, bool unlockIfLocked)
1251{ 1253{
1252 PWM_ASSERT(d); 1254 PWM_ASSERT(d);
1253 unsigned int cat = 0; 1255 unsigned int cat = 0;
1254 1256
1255 if (!findCategory(category, &cat)) { 1257 if (!findCategory(category, &cat)) {
1256 BUG(); 1258 BUG();
1257 return false; 1259 return false;
1258 } 1260 }
1259 1261
1260 return getEntry(cat, index, d, unlockIfLocked); 1262 return getEntry(cat, index, d, unlockIfLocked);
1261} 1263}
1262 1264
1263bool PwMDoc::getEntry(unsigned int category, unsigned int index, 1265bool PwMDoc::getEntry(unsigned int category, unsigned int index,
1264 PwMDataItem *d, bool unlockIfLocked) 1266 PwMDataItem *d, bool unlockIfLocked)
1265{ 1267{
1266 if (index > dti.dta[category].d.size() - 1) 1268 if (index > dti.dta[category].d.size() - 1)
1267 return false; 1269 return false;
1268 1270
1269 bool locked = isLocked(category, index); 1271 bool locked = isLocked(category, index);
1270 if (locked) { 1272 if (locked) {
1271 /* this entry is locked. We don't return a password, 1273 /* this entry is locked. We don't return a password,
1272 * until it's unlocked by the user by inserting 1274 * until it's unlocked by the user by inserting
1273 * chipcard or entering the mpw 1275 * chipcard or entering the mpw
1274 */ 1276 */
1275 if (unlockIfLocked) { 1277 if (unlockIfLocked) {
1276 if (!lockAt(category, index, false)) { 1278 if (!lockAt(category, index, false)) {
1277 return false; 1279 return false;
1278 } 1280 }
1279 locked = false; 1281 locked = false;
1280 } 1282 }
1281 } 1283 }
1282 1284
1283 *d = dti.dta[category].d[index]; 1285 *d = dti.dta[category].d[index];
1284 if (locked) 1286 if (locked)
1285 d->pw = LOCKED_STRING.latin1(); 1287 d->pw = LOCKED_STRING.latin1();
1286 1288
1287 return true; 1289 return true;
1288} 1290}
1289PwMerror PwMDoc::getCommentByLvp(const QString &category, int listViewPos, 1291PwMerror PwMDoc::getCommentByLvp(const QString &category, int listViewPos,
1290 string *foundComment) 1292 string *foundComment)
1291{ 1293{
1292 PWM_ASSERT(foundComment); 1294 PWM_ASSERT(foundComment);
1293 unsigned int cat = 0; 1295 unsigned int cat = 0;
1294 1296
1295 if (!findCategory(category, &cat)) 1297 if (!findCategory(category, &cat))
1296 return e_invalidArg; 1298 return e_invalidArg;
1297 1299
1298 unsigned int i, entries = numEntries(cat); 1300 unsigned int i, entries = numEntries(cat);
1299 for (i = 0; i < entries; ++i) { 1301 for (i = 0; i < entries; ++i) {
1300 if (dti.dta[cat].d[i].listViewPos == listViewPos) { 1302 if (dti.dta[cat].d[i].listViewPos == listViewPos) {
1301 *foundComment = dti.dta[cat].d[i].comment; 1303 *foundComment = dti.dta[cat].d[i].comment;
1302 if (dti.dta[cat].d[i].binary) 1304 if (dti.dta[cat].d[i].binary)
1303 return e_binEntry; 1305 return e_binEntry;
1304 return e_normalEntry; 1306 return e_normalEntry;
1305 } 1307 }
1306 } 1308 }
1307 BUG(); 1309 BUG();
1308 return e_generic; 1310 return e_generic;
1309} 1311}
1310 1312
1311PwMerror PwMDoc::getCommentByLvp_long(const QString &category, int listViewPos, 1313PwMerror PwMDoc::getCommentByLvp_long(const QString &category, int listViewPos,
1312 string *foundComment) 1314 string *foundComment)
1313{ 1315{
1314 PWM_ASSERT(foundComment); 1316 PWM_ASSERT(foundComment);
1315 unsigned int cat = 0; 1317 unsigned int cat = 0;
1316 1318
1317 if (!findCategory(category, &cat)) 1319 if (!findCategory(category, &cat))
1318 return e_invalidArg; 1320 return e_invalidArg;
1319 1321
1320 unsigned int i, entries = numEntries(cat); 1322 unsigned int i, entries = numEntries(cat);
1321 for (i = 0; i < entries; ++i) { 1323 for (i = 0; i < entries; ++i) {
1322 if (dti.dta[cat].d[i].listViewPos == listViewPos) { 1324 if (dti.dta[cat].d[i].listViewPos == listViewPos) {
1323 if (dti.dta[cat].d[i].binary) 1325 if (dti.dta[cat].d[i].binary)
1324 return e_binEntry; 1326 return e_binEntry;
1325 PwMCategoryItem* catItem = getCategoryEntry(cat); 1327 PwMCategoryItem* catItem = getCategoryEntry(cat);
1326 QString retval; 1328 QString retval;
1327 QString tempval = QString (dti.dta[cat].d[i].desc.c_str()); 1329 QString tempval = QString (dti.dta[cat].d[i].desc.c_str());
1328 if ( !tempval.isEmpty() ) { 1330 if ( !tempval.isEmpty() ) {
1329 retval += "<b>" +QString ( catItem->desc_text.c_str() )+ ":</b> "+ tempval+"<br>" ; 1331 retval += "<b>" +QString ( catItem->desc_text.c_str() )+ ":</b> "+ tempval+"<br>" ;
1330 } 1332 }
1331 tempval = QString (dti.dta[cat].d[i].name.c_str()); 1333 tempval = QString (dti.dta[cat].d[i].name.c_str());
1332 if ( !tempval.isEmpty() ) { 1334 if ( !tempval.isEmpty() ) {
1333 retval += "<b>" +QString ( catItem->name_text.c_str() ) + ":</b> "+ tempval+"<br>" ; 1335 retval += "<b>" +QString ( catItem->name_text.c_str() ) + ":</b> "+ tempval+"<br>" ;
1334 } 1336 }
1335 tempval = QString (dti.dta[cat].d[i].pw.c_str()); 1337 tempval = QString (dti.dta[cat].d[i].pw.c_str());
1336 if ( !tempval.isEmpty() ) { 1338 if ( !tempval.isEmpty() ) {
1337 if ( dti.dta[cat].d[i].lockStat ) 1339 if ( dti.dta[cat].d[i].lockStat )
1338 retval += "<b>" +QString ( catItem->pw_text.c_str() )+ ": " + i18n("LOCKED") +"</b><br>" ; 1340 retval += "<b>" +QString ( catItem->pw_text.c_str() )+ ": " + i18n("LOCKED") +"</b><br>" ;
1339 else 1341 else
1340 retval += "<b>" +QString ( catItem->pw_text.c_str() )+ ":</b> " + tempval+"<br>" ; 1342 retval += "<b>" +QString ( catItem->pw_text.c_str() )+ ":</b> " + tempval+"<br>" ;
1341 } 1343 }
1342 tempval = QString (dti.dta[cat].d[i].url.c_str()); 1344 tempval = QString (dti.dta[cat].d[i].url.c_str());
1343 if ( !tempval.isEmpty() ) { 1345 if ( !tempval.isEmpty() ) {
1344 retval += "<b>" +i18n("URL:")+ "</b> " + tempval+"<br>" ; 1346 retval += "<b>" +i18n("URL:")+ "</b> " + tempval+"<br>" ;
1345 } 1347 }
1346 tempval = QString (dti.dta[cat].d[i].launcher.c_str()); 1348 tempval = QString (dti.dta[cat].d[i].launcher.c_str());
1347 if ( !tempval.isEmpty() ) { 1349 if ( !tempval.isEmpty() ) {
1348 retval += "<b>" +i18n("Launcher:")+ "</b> " + tempval+"<br>" ; 1350 retval += "<b>" +i18n("Launcher:")+ "</b> " + tempval+"<br>" ;
1349 } 1351 }
1350 tempval = QString (dti.dta[cat].d[i].comment.c_str()); 1352 tempval = QString (dti.dta[cat].d[i].comment.c_str());
1351 if ( !tempval.isEmpty() ) { 1353 if ( !tempval.isEmpty() ) {
1352 tempval.replace(QRegExp ( "\n" ), "<br>" ); 1354 tempval.replace(QRegExp ( "\n" ), "<br>" );
1353 retval += "<b>" +i18n("Comment:")+ "</b><br>" + tempval+"<br>" ; 1355 retval += "<b>" +i18n("Comment:")+ "</b><br>" + tempval+"<br>" ;
1354 } 1356 }
1355 1357
1356 string ret ( retval.latin1() ); 1358 string ret ( retval.latin1() );
1357 1359
1358 1360
1359 // *foundComment = dti.dta[cat].d[i].comment; 1361 // *foundComment = dti.dta[cat].d[i].comment;
1360 *foundComment = ret; 1362 *foundComment = ret;
1361 return e_normalEntry; 1363 return e_normalEntry;
1362 } 1364 }
1363 } 1365 }
1364 BUG(); 1366 BUG();
1365 return e_generic; 1367 return e_generic;
1366} 1368}
1367 1369
1368bool PwMDoc::compressDta(string *d, char algo) 1370bool PwMDoc::compressDta(string *d, char algo)
1369{ 1371{
1370 PWM_ASSERT(d); 1372 PWM_ASSERT(d);
1371 switch (algo) { 1373 switch (algo) {
1372 case PWM_COMPRESS_GZIP: { 1374 case PWM_COMPRESS_GZIP: {
1373 CompressGzip comp; 1375 CompressGzip comp;
1374 return comp.compress(d); 1376 return comp.compress(d);
1375 } 1377 }
1376#ifndef PWM_EMBEDDED 1378#ifndef PWM_EMBEDDED
1377 case PWM_COMPRESS_BZIP2: { 1379 case PWM_COMPRESS_BZIP2: {
1378 CompressBzip2 comp; 1380 CompressBzip2 comp;
1379 return comp.compress(d); 1381 return comp.compress(d);
1380 } 1382 }
1381#endif 1383#endif
1382 case PWM_COMPRESS_NONE: { 1384 case PWM_COMPRESS_NONE: {
1383 return true; 1385 return true;
1384 } default: { 1386 } default: {
1385 BUG(); 1387 BUG();
1386 } 1388 }
1387 } 1389 }
1388 return false; 1390 return false;
1389} 1391}
1390 1392
1391bool PwMDoc::decompressDta(string *d, char algo) 1393bool PwMDoc::decompressDta(string *d, char algo)
1392{ 1394{
1393 PWM_ASSERT(d); 1395 PWM_ASSERT(d);
1394 switch (algo) { 1396 switch (algo) {
1395 case PWM_COMPRESS_GZIP: { 1397 case PWM_COMPRESS_GZIP: {
1396 CompressGzip comp; 1398 CompressGzip comp;
1397 return comp.decompress(d); 1399 return comp.decompress(d);
1398 } 1400 }
1399#ifndef PWM_EMBEDDED 1401#ifndef PWM_EMBEDDED
1400 case PWM_COMPRESS_BZIP2: { 1402 case PWM_COMPRESS_BZIP2: {
1401 CompressBzip2 comp; 1403 CompressBzip2 comp;
1402 return comp.decompress(d); 1404 return comp.decompress(d);
1403 } 1405 }
1404#endif 1406#endif
1405 case PWM_COMPRESS_NONE: { 1407 case PWM_COMPRESS_NONE: {
1406 return true; 1408 return true;
1407 } 1409 }
1408 } 1410 }
1409 return false; 1411 return false;
1410} 1412}
1411 1413
1412PwMerror PwMDoc::encrypt(string *d, const QString *pw, QFile *f, char algo, 1414PwMerror PwMDoc::encrypt(string *d, const QString *pw, QFile *f, char algo,
1413 char hashalgo //US BUG: pass _hashalgo because we need it in hashPassphrase 1415 char hashalgo //US BUG: pass _hashalgo because we need it in hashPassphrase
1414) 1416)
1415{ 1417{
1416 PWM_ASSERT(d); 1418 PWM_ASSERT(d);
1417 PWM_ASSERT(pw); 1419 PWM_ASSERT(pw);
1418 PWM_ASSERT(f); 1420 PWM_ASSERT(f);
1419 1421
1420 size_t encSize; 1422 size_t encSize;
1421 byte *encrypted = 0; 1423 byte *encrypted = 0;
1422 1424
1423 switch (algo) { 1425 switch (algo) {
1424 case PWM_CRYPT_BLOWFISH: { 1426 case PWM_CRYPT_BLOWFISH: {
1425 Blowfish::padNull(d); 1427 Blowfish::padNull(d);
1426 encSize = d->length(); 1428 encSize = d->length();
1427 encrypted = new byte[encSize]; 1429 encrypted = new byte[encSize];
1428 Blowfish bf; 1430 Blowfish bf;
1429 if (bf.bf_setkey((byte *) pw->latin1(), pw->length())) { 1431 if (bf.bf_setkey((byte *) pw->latin1(), pw->length())) {
1430 delete [] encrypted; 1432 delete [] encrypted;
1431 return e_weakPw; 1433 return e_weakPw;
1432 } 1434 }
1433 bf.bf_encrypt((byte *) encrypted, (byte *) d->c_str(), encSize); 1435 bf.bf_encrypt((byte *) encrypted, (byte *) d->c_str(), encSize);
1434 break; 1436 break;
1435 } 1437 }
1436 case PWM_CRYPT_AES128: 1438 case PWM_CRYPT_AES128:
1437 /*... fall through */ 1439 /*... fall through */
1438 case PWM_CRYPT_AES192: 1440 case PWM_CRYPT_AES192:
1439 case PWM_CRYPT_AES256: 1441 case PWM_CRYPT_AES256:
1440 case PWM_CRYPT_3DES: 1442 case PWM_CRYPT_3DES:
1441 case PWM_CRYPT_TWOFISH: 1443 case PWM_CRYPT_TWOFISH:
1442 case PWM_CRYPT_TWOFISH128: { 1444 case PWM_CRYPT_TWOFISH128: {
1443 if (!LibGCryptIf::available()) 1445 if (!LibGCryptIf::available())
1444 return e_cryptNotImpl; 1446 return e_cryptNotImpl;
1445 LibGCryptIf gc; 1447 LibGCryptIf gc;
1446 PwMerror err; 1448 PwMerror err;
1447 unsigned char *plain = new unsigned char[d->length() + 1024]; 1449 unsigned char *plain = new unsigned char[d->length() + 1024];
1448 memcpy(plain, d->c_str(), d->length()); 1450 memcpy(plain, d->c_str(), d->length());
1449 err = gc.encrypt(&encrypted, 1451 err = gc.encrypt(&encrypted,
1450 &encSize, 1452 &encSize,
1451 plain, 1453 plain,
1452 d->length(), 1454 d->length(),
1453 reinterpret_cast<const unsigned char *>(pw->latin1()), 1455 reinterpret_cast<const unsigned char *>(pw->latin1()),
1454 pw->length(), 1456 pw->length(),
1455 algo, 1457 algo,
1456 hashalgo //US BUG: pass _hashalgo because we need it in hashPassphrase 1458 hashalgo //US BUG: pass _hashalgo because we need it in hashPassphrase
1457 ); 1459 );
1458 delete [] plain; 1460 delete [] plain;
1459 if (err != e_success) 1461 if (err != e_success)
1460 return e_cryptNotImpl; 1462 return e_cryptNotImpl;
1461 break; 1463 break;
1462 } 1464 }
1463 default: { 1465 default: {
1464 delete_ifnot_null_array(encrypted); 1466 delete_ifnot_null_array(encrypted);
1465 return e_cryptNotImpl; 1467 return e_cryptNotImpl;
1466 } } 1468 } }
1467 1469
1468 // write encrypted data to file 1470 // write encrypted data to file
1469 if (f->writeBlock(reinterpret_cast<const char *>(encrypted), 1471 if (f->writeBlock(reinterpret_cast<const char *>(encrypted),
1470 static_cast<Q_ULONG>(encSize)) 1472 static_cast<Q_ULONG>(encSize))
1471 != static_cast<Q_LONG>(encSize)) { 1473 != static_cast<Q_LONG>(encSize)) {
1472 delete_ifnot_null_array(encrypted); 1474 delete_ifnot_null_array(encrypted);
1473 return e_writeFile; 1475 return e_writeFile;
1474 } 1476 }
1475 delete_ifnot_null_array(encrypted); 1477 delete_ifnot_null_array(encrypted);
1476 return e_success; 1478 return e_success;
1477} 1479}
1478 1480
1479PwMerror PwMDoc::decrypt(string *d, unsigned int pos, const QString *pw, 1481PwMerror PwMDoc::decrypt(string *d, unsigned int pos, const QString *pw,
1480 char algo, 1482 char algo,
1481 char hashalgo, //US BUG: pass _hashalgo because we need it in hashPassphrase 1483 char hashalgo, //US BUG: pass _hashalgo because we need it in hashPassphrase
1482 QFile *f) 1484 QFile *f)
1483{ 1485{
1484 PWM_ASSERT(d); 1486 PWM_ASSERT(d);
1485 PWM_ASSERT(pw); 1487 PWM_ASSERT(pw);
1486 PWM_ASSERT(f); 1488 PWM_ASSERT(f);
1487 1489
1488 unsigned int cryptLen = f->size() - pos; 1490 size_t cryptLen = f->size() - pos;
1489 byte *encrypted = new byte[cryptLen]; 1491 byte *encrypted = new byte[cryptLen];
1490 byte *decrypted = new byte[cryptLen]; 1492 byte *decrypted = new byte[cryptLen];
1491 1493
1492 f->at(pos); 1494 f->at(pos);
1493#ifndef PWM_EMBEDDED 1495#ifndef PWM_EMBEDDED
1494 if (f->readBlock(reinterpret_cast<char *>(encrypted), 1496 if (f->readBlock(reinterpret_cast<char *>(encrypted),
1495 static_cast<Q_ULONG>(cryptLen)) 1497 static_cast<Q_ULONG>(cryptLen))
1496 != static_cast<Q_LONG>(cryptLen)) { 1498 != static_cast<Q_LONG>(cryptLen)) {
1497 delete [] encrypted; 1499 delete [] encrypted;
1498 delete [] decrypted; 1500 delete [] decrypted;
1499 return e_readFile; 1501 return e_readFile;
1500 } 1502 }
1501#else 1503#else
1502 if (f->readBlock((char *)(encrypted), 1504 if (f->readBlock((char *)(encrypted),
1503 (unsigned long)(cryptLen)) 1505 (unsigned long)(cryptLen))
1504 != (long)(cryptLen)) { 1506 != (long)(cryptLen)) {
1505 delete [] encrypted; 1507 delete [] encrypted;
1506 delete [] decrypted; 1508 delete [] decrypted;
1507 return e_readFile; 1509 return e_readFile;
1508 } 1510 }
1509#endif 1511#endif
1510 switch (algo) { 1512 switch (algo) {
1511 case PWM_CRYPT_BLOWFISH: { 1513 case PWM_CRYPT_BLOWFISH: {
1512 Blowfish bf; 1514 Blowfish bf;
1513 bf.bf_setkey((byte *) pw->latin1(), pw->length()); 1515 bf.bf_setkey((byte *) pw->latin1(), pw->length());
1514 bf.bf_decrypt(decrypted, encrypted, cryptLen); 1516 bf.bf_decrypt(decrypted, encrypted, cryptLen);
1515 break; 1517 break;
1516 } 1518 }
1517 case PWM_CRYPT_AES128: 1519 case PWM_CRYPT_AES128:
1518 /*... fall through */ 1520 /*... fall through */
1519 case PWM_CRYPT_AES192: 1521 case PWM_CRYPT_AES192:
1520 case PWM_CRYPT_AES256: 1522 case PWM_CRYPT_AES256:
1521 case PWM_CRYPT_3DES: 1523 case PWM_CRYPT_3DES:
1522 case PWM_CRYPT_TWOFISH: 1524 case PWM_CRYPT_TWOFISH:
1523 case PWM_CRYPT_TWOFISH128: { 1525 case PWM_CRYPT_TWOFISH128: {
1524 if (!LibGCryptIf::available()) 1526 if (!LibGCryptIf::available())
1525 return e_cryptNotImpl; 1527 return e_cryptNotImpl;
1526 LibGCryptIf gc; 1528 LibGCryptIf gc;
1527 PwMerror err; 1529 PwMerror err;
1528 err = gc.decrypt(&decrypted, 1530 err = gc.decrypt((unsigned char **)&decrypted,
1529 &cryptLen, 1531 &cryptLen,
1530 encrypted, 1532 (unsigned char*)encrypted,
1531 cryptLen, 1533 cryptLen,
1532 reinterpret_cast<const unsigned char *>(pw->latin1()), 1534 reinterpret_cast<const unsigned char *>(pw->latin1()),
1533 pw->length(), 1535 pw->length(),
1534 algo, 1536 algo,
1535 hashalgo //US BUG: pass _hashalgo because we need it in hashPassphrase 1537 hashalgo //US BUG: pass _hashalgo because we need it in hashPassphrase
1536); 1538);
1537 if (err != e_success) { 1539 if (err != e_success) {
1538 delete [] encrypted; 1540 delete [] encrypted;
1539 delete [] decrypted; 1541 delete [] decrypted;
1540 return e_cryptNotImpl; 1542 return e_cryptNotImpl;
1541 } 1543 }
1542 break; 1544 break;
1543 } 1545 }
1544 default: { 1546 default: {
1545 delete [] encrypted; 1547 delete [] encrypted;
1546 delete [] decrypted; 1548 delete [] decrypted;
1547 return e_cryptNotImpl; 1549 return e_cryptNotImpl;
1548 } } 1550 } }
1549 delete [] encrypted; 1551 delete [] encrypted;
1550#ifndef PWM_EMBEDDED 1552#ifndef PWM_EMBEDDED
1551 d->assign(reinterpret_cast<const char *>(decrypted), 1553 d->assign(reinterpret_cast<const char *>(decrypted),
1552 static_cast<string::size_type>(cryptLen)); 1554 static_cast<string::size_type>(cryptLen));
1553#else 1555#else
1554 d->assign((const char *)(decrypted), 1556 d->assign((const char *)(decrypted),
1555 (string::size_type)(cryptLen)); 1557 (string::size_type)(cryptLen));
1556#endif 1558#endif
1557 delete [] decrypted; 1559 delete [] decrypted;
1558 if (algo == PWM_CRYPT_BLOWFISH) { 1560 if (algo == PWM_CRYPT_BLOWFISH) {
1559 if (!Blowfish::unpadNull(d)) { 1561 if (!Blowfish::unpadNull(d)) {
1560 BUG(); 1562 BUG();
1561 return e_readFile; 1563 return e_readFile;
1562 } 1564 }
1563 } 1565 }
1564 return e_success; 1566 return e_success;
1565} 1567}
1566 1568
1567PwMerror PwMDoc::checkDataHash(char dataHashType, const string *dataHash, 1569PwMerror PwMDoc::checkDataHash(char dataHashType, const string *dataHash,
1568 const string *dataStream) 1570 const string *dataStream)
1569{ 1571{
1570 PWM_ASSERT(dataHash); 1572 PWM_ASSERT(dataHash);
1571 PWM_ASSERT(dataStream); 1573 PWM_ASSERT(dataStream);
1572 switch(dataHashType) { 1574 switch(dataHashType) {
1573 case PWM_HASH_SHA1: { 1575 case PWM_HASH_SHA1: {
1574 Sha1 hash; 1576 Sha1 hash;
1575 hash.sha1_write((byte*)dataStream->c_str(), dataStream->length()); 1577 hash.sha1_write((byte*)dataStream->c_str(), dataStream->length());
1576 string ret = hash.sha1_read(); 1578 string ret = hash.sha1_read();
1577 if (ret != *dataHash) 1579 if (ret != *dataHash)
1578 return e_fileCorrupt; 1580 return e_fileCorrupt;
1579 break; 1581 break;
1580 } 1582 }
1581 case PWM_HASH_SHA256: 1583 case PWM_HASH_SHA256:
1582 /*... fall through */ 1584 /*... fall through */
1583 case PWM_HASH_SHA384: 1585 case PWM_HASH_SHA384:
1584 case PWM_HASH_SHA512: 1586 case PWM_HASH_SHA512:
1585 case PWM_HASH_MD5: 1587 case PWM_HASH_MD5:
1586 case PWM_HASH_RMD160: 1588 case PWM_HASH_RMD160:
1587 case PWM_HASH_TIGER: { 1589 case PWM_HASH_TIGER: {
1588 if (!LibGCryptIf::available()) 1590 if (!LibGCryptIf::available())
1589 return e_hashNotImpl; 1591 return e_hashNotImpl;
1590 LibGCryptIf gc; 1592 LibGCryptIf gc;
1591 PwMerror err; 1593 PwMerror err;
1592 unsigned char *buf; 1594 unsigned char *buf;
1593 size_t hashLen; 1595 size_t hashLen;
1594 err = gc.hash(&buf, 1596 err = gc.hash(&buf,
1595 &hashLen, 1597 &hashLen,
1596 reinterpret_cast<const unsigned char *>(dataStream->c_str()), 1598 reinterpret_cast<const unsigned char *>(dataStream->c_str()),
1597 dataStream->length(), 1599 dataStream->length(),
1598 dataHashType); 1600 dataHashType);
1599 if (err != e_success) 1601 if (err != e_success)
1600 return e_hashNotImpl; 1602 return e_hashNotImpl;
1601 string calcHash(reinterpret_cast<const char *>(buf), 1603 string calcHash(reinterpret_cast<const char *>(buf),
1602 static_cast<string::size_type>(hashLen)); 1604 static_cast<string::size_type>(hashLen));
1603 delete [] buf; 1605 delete [] buf;
1604 if (calcHash != *dataHash) 1606 if (calcHash != *dataHash)
1605 return e_fileCorrupt; 1607 return e_fileCorrupt;
1606 break; 1608 break;
1607 } 1609 }
1608 default: 1610 default:
1609 return e_hashNotImpl; 1611 return e_hashNotImpl;
1610 } 1612 }
1611 return e_success; 1613 return e_success;
1612} 1614}
1613 1615
1614bool PwMDoc::lockAt(unsigned int category, unsigned int index, 1616bool PwMDoc::lockAt(unsigned int category, unsigned int index,
1615 bool lock) 1617 bool lock)
1616{ 1618{
1617 if (index >= numEntries(category)) { 1619 if (index >= numEntries(category)) {
1618 BUG(); 1620 BUG();
1619 return false; 1621 return false;
1620 } 1622 }
1621 if (lock == dti.dta[category].d[index].lockStat) 1623 if (lock == dti.dta[category].d[index].lockStat)
1622 return true; 1624 return true;
1623 1625
1624 if (!lock && currentPw != "") { 1626 if (!lock && currentPw != "") {
1625 // "unlocking" and "password is already set" 1627 // "unlocking" and "password is already set"
1626 if (!getDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW)) { 1628 if (!getDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW)) {
1627 // unlocking without pw not allowed 1629 // unlocking without pw not allowed
1628 QString pw; 1630 QString pw;
1629 pw = requestMpw(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); 1631 pw = requestMpw(getDocStatFlag(DOC_STAT_USE_CHIPCARD));
1630 if (pw != "") { 1632 if (pw != "") {
1631 if (pw != currentPw) { 1633 if (pw != currentPw) {
1632 wrongMpwMsgBox(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); 1634 wrongMpwMsgBox(getDocStatFlag(DOC_STAT_USE_CHIPCARD));
1633 return false; 1635 return false;
1634 } else { 1636 } else {
1635 timer()->start(DocTimer::id_mpwTimer); 1637 timer()->start(DocTimer::id_mpwTimer);
1636 } 1638 }
1637 } else { 1639 } else {
1638 return false; 1640 return false;
1639 } 1641 }
1640 } else { 1642 } else {
1641 timer()->start(DocTimer::id_mpwTimer); 1643 timer()->start(DocTimer::id_mpwTimer);
1642 } 1644 }
1643 } 1645 }
1644 1646
1645 dti.dta[category].d[index].lockStat = lock; 1647 dti.dta[category].d[index].lockStat = lock;
1646 dti.dta[category].d[index].rev++; // increment revision counter. 1648 dti.dta[category].d[index].rev++; // increment revision counter.
1647 1649
1648 emitDataChanged(this); 1650 emitDataChanged(this);
1649 if (!lock) 1651 if (!lock)
1650 timer()->start(DocTimer::id_autoLockTimer); 1652 timer()->start(DocTimer::id_autoLockTimer);
1651 1653
1652 return true; 1654 return true;
1653 1655
1654} 1656}
1655 1657
1656bool PwMDoc::lockAt(const QString &category,unsigned int index, 1658bool PwMDoc::lockAt(const QString &category,unsigned int index,
1657 bool lock) 1659 bool lock)
1658{ 1660{
1659 unsigned int cat = 0; 1661 unsigned int cat = 0;
1660 1662
1661 if (!findCategory(category, &cat)) { 1663 if (!findCategory(category, &cat)) {
1662 BUG(); 1664 BUG();
1663 return false; 1665 return false;
1664 } 1666 }
1665 1667
1666 return lockAt(cat, index, lock); 1668 return lockAt(cat, index, lock);
1667} 1669}
1668 1670
1669bool PwMDoc::lockAll(bool lock) 1671bool PwMDoc::lockAll(bool lock)
1670{ 1672{
1671 if (!lock && isDeepLocked()) { 1673 if (!lock && isDeepLocked()) {
1672 PwMerror ret; 1674 PwMerror ret;
1673 ret = deepLock(false); 1675 ret = deepLock(false);
1674 if (ret != e_success) 1676 if (ret != e_success)
1675 return false; 1677 return false;
1676 return true; 1678 return true;
1677 } 1679 }
1678 if (isDocEmpty()) { 1680 if (isDocEmpty()) {
1679 return true; 1681 return true;
1680 } 1682 }
1681 if (!lock && currentPw != "") { 1683 if (!lock && currentPw != "") {
1682 // unlocking and password is already set 1684 // unlocking and password is already set
1683 if (!getDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW)) { 1685 if (!getDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW)) {
1684 // unlocking without pw not allowed 1686 // unlocking without pw not allowed
1685 QString pw; 1687 QString pw;
1686 pw = requestMpw(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); 1688 pw = requestMpw(getDocStatFlag(DOC_STAT_USE_CHIPCARD));
1687 if (pw != "") { 1689 if (pw != "") {
1688 if (pw != currentPw) { 1690 if (pw != currentPw) {
1689 wrongMpwMsgBox(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); 1691 wrongMpwMsgBox(getDocStatFlag(DOC_STAT_USE_CHIPCARD));
1690 return false; 1692 return false;
1691 } else { 1693 } else {
1692 timer()->start(DocTimer::id_mpwTimer); 1694 timer()->start(DocTimer::id_mpwTimer);
1693 } 1695 }
1694 } else { 1696 } else {
1695 return false; 1697 return false;
1696 } 1698 }
1697 } else { 1699 } else {
1698 timer()->start(DocTimer::id_mpwTimer); 1700 timer()->start(DocTimer::id_mpwTimer);
1699 } 1701 }
1700 } 1702 }
1701 1703
1702 vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(), 1704 vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(),
1703 catEnd = dti.dta.end(), 1705 catEnd = dti.dta.end(),
1704 catI = catBegin; 1706 catI = catBegin;
1705 vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; 1707 vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI;
1706 while (catI != catEnd) { 1708 while (catI != catEnd) {
1707 entrBegin = catI->d.begin(); 1709 entrBegin = catI->d.begin();
1708 entrEnd = catI->d.end(); 1710 entrEnd = catI->d.end();
1709 entrI = entrBegin; 1711 entrI = entrBegin;
1710 while (entrI != entrEnd) { 1712 while (entrI != entrEnd) {
1711 entrI->lockStat = lock; 1713 entrI->lockStat = lock;
1712 entrI->rev++; // increment revision counter. 1714 entrI->rev++; // increment revision counter.
1713 ++entrI; 1715 ++entrI;
1714 } 1716 }
1715 ++catI; 1717 ++catI;
1716 } 1718 }
1717 1719
1718 emitDataChanged(this); 1720 emitDataChanged(this);
1719 if (lock) 1721 if (lock)
1720 timer()->stop(DocTimer::id_autoLockTimer); 1722 timer()->stop(DocTimer::id_autoLockTimer);
1721 else 1723 else
1722 timer()->start(DocTimer::id_autoLockTimer); 1724 timer()->start(DocTimer::id_autoLockTimer);
1723 1725
1724 return true; 1726 return true;
1725} 1727}
1726 1728
1727bool PwMDoc::isLocked(const QString &category, unsigned int index) 1729bool PwMDoc::isLocked(const QString &category, unsigned int index)
1728{ 1730{
1729 unsigned int cat = 0; 1731 unsigned int cat = 0;
1730 1732
1731 if (!findCategory(category, &cat)) { 1733 if (!findCategory(category, &cat)) {
1732 BUG(); 1734 BUG();
1733 return false; 1735 return false;
1734 } 1736 }
1735 1737
1736 return isLocked(cat, index); 1738 return isLocked(cat, index);
1737} 1739}
1738 1740
1739bool PwMDoc::unlockAll_tempoary(bool revert) 1741bool PwMDoc::unlockAll_tempoary(bool revert)
1740{ 1742{
1741 static vector< vector<bool> > *oldLockStates = 0; 1743 static vector< vector<bool> > *oldLockStates = 0;
1742 static bool wasDeepLocked; 1744 static bool wasDeepLocked;
1743 1745
1744 if (revert) {// revert the unlocking 1746 if (revert) {// revert the unlocking
1745 if (oldLockStates) { 1747 if (oldLockStates) {
1746 /* we actually _have_ unlocked something, because 1748 /* we actually _have_ unlocked something, because
1747 * we have allocated space for the oldLockStates. 1749 * we have allocated space for the oldLockStates.
1748 * So, go on and revert them! 1750 * So, go on and revert them!
1749 */ 1751 */
1750 if (wasDeepLocked) { 1752 if (wasDeepLocked) {
1751 PwMerror ret = deepLock(true); 1753 PwMerror ret = deepLock(true);
1752 if (ret == e_success) { 1754 if (ret == e_success) {
1753 /* deep-lock succeed. We are save. 1755 /* deep-lock succeed. We are save.
1754 * (but if it failed, just go on 1756 * (but if it failed, just go on
1755 * lock them normally) 1757 * lock them normally)
1756 */ 1758 */
1757 delete_and_null(oldLockStates); 1759 delete_and_null(oldLockStates);
1758 timer()->start(DocTimer::id_autoLockTimer); 1760 timer()->start(DocTimer::id_autoLockTimer);
1759 printDebug("tempoary unlocking of dta " 1761 printDebug("tempoary unlocking of dta "
1760 "reverted by deep-locking."); 1762 "reverted by deep-locking.");
1761 return true; 1763 return true;
1762 } 1764 }
1763 printDebug("deep-lock failed while reverting! " 1765 printDebug("deep-lock failed while reverting! "
1764 "Falling back to normal-lock."); 1766 "Falling back to normal-lock.");
1765 } 1767 }
1766 if (unlikely(!wasDeepLocked && 1768 if (unlikely(!wasDeepLocked &&
1767 numCategories() != oldLockStates->size())) { 1769 numCategories() != oldLockStates->size())) {
1768 /* DOH! We have modified "dta" while 1770 /* DOH! We have modified "dta" while
1769 * it was unlocked tempoary. DON'T DO THIS! 1771 * it was unlocked tempoary. DON'T DO THIS!
1770 */ 1772 */
1771 BUG(); 1773 BUG();
1772 delete_and_null(oldLockStates); 1774 delete_and_null(oldLockStates);
1773 timer()->start(DocTimer::id_autoLockTimer); 1775 timer()->start(DocTimer::id_autoLockTimer);
1774 return false; 1776 return false;
1775 } 1777 }
1776 vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(), 1778 vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(),
1777 catEnd = dti.dta.end(), 1779 catEnd = dti.dta.end(),
1778 catI = catBegin; 1780 catI = catBegin;
1779 vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; 1781 vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI;
1780 vector< vector<bool> >::iterator oldCatStatI = oldLockStates->begin(); 1782 vector< vector<bool> >::iterator oldCatStatI = oldLockStates->begin();
1781 vector<bool>::iterator oldEntrStatBegin, 1783 vector<bool>::iterator oldEntrStatBegin,
1782 oldEntrStatEnd, 1784 oldEntrStatEnd,
1783 oldEntrStatI; 1785 oldEntrStatI;
1784 while (catI != catEnd) { 1786 while (catI != catEnd) {
1785 entrBegin = catI->d.begin(); 1787 entrBegin = catI->d.begin();
1786 entrEnd = catI->d.end(); 1788 entrEnd = catI->d.end();
1787 entrI = entrBegin; 1789 entrI = entrBegin;
1788 if (likely(!wasDeepLocked)) { 1790 if (likely(!wasDeepLocked)) {
1789 oldEntrStatBegin = oldCatStatI->begin(); 1791 oldEntrStatBegin = oldCatStatI->begin();
1790 oldEntrStatEnd = oldCatStatI->end(); 1792 oldEntrStatEnd = oldCatStatI->end();
1791 oldEntrStatI = oldEntrStatBegin; 1793 oldEntrStatI = oldEntrStatBegin;
1792 if (unlikely(catI->d.size() != oldCatStatI->size())) { 1794 if (unlikely(catI->d.size() != oldCatStatI->size())) {
1793 /* DOH! We have modified "dta" while 1795 /* DOH! We have modified "dta" while
1794 * it was unlocked tempoary. DON'T DO THIS! 1796 * it was unlocked tempoary. DON'T DO THIS!
1795 */ 1797 */
1796 BUG(); 1798 BUG();
1797 delete_and_null(oldLockStates); 1799 delete_and_null(oldLockStates);
1798 timer()->start(DocTimer::id_autoLockTimer); 1800 timer()->start(DocTimer::id_autoLockTimer);
1799 return false; 1801 return false;
1800 } 1802 }
1801 } 1803 }
1802 while (entrI != entrEnd) { 1804 while (entrI != entrEnd) {
1803 if (wasDeepLocked) { 1805 if (wasDeepLocked) {
1804 /* this is an error-fallback if 1806 /* this is an error-fallback if
1805 * deeplock didn't succeed 1807 * deeplock didn't succeed
1806 */ 1808 */
1807 entrI->lockStat = true; 1809 entrI->lockStat = true;
1808 } else { 1810 } else {
1809 entrI->lockStat = *oldEntrStatI; 1811 entrI->lockStat = *oldEntrStatI;
1810 } 1812 }
1811 ++entrI; 1813 ++entrI;
1812 if (likely(!wasDeepLocked)) 1814 if (likely(!wasDeepLocked))
1813 ++oldEntrStatI; 1815 ++oldEntrStatI;
1814 } 1816 }
1815 ++catI; 1817 ++catI;
1816 if (likely(!wasDeepLocked)) 1818 if (likely(!wasDeepLocked))
1817 ++oldCatStatI; 1819 ++oldCatStatI;
1818 } 1820 }
1819 delete_and_null(oldLockStates); 1821 delete_and_null(oldLockStates);
1820 if (unlikely(wasDeepLocked)) { 1822 if (unlikely(wasDeepLocked)) {
1821 /* error fallback... */ 1823 /* error fallback... */
1822 unsetDocStatFlag(DOC_STAT_DEEPLOCKED); 1824 unsetDocStatFlag(DOC_STAT_DEEPLOCKED);
1823 emitDataChanged(this); 1825 emitDataChanged(this);
1824 printDebug("WARNING: unlockAll_tempoary(true) " 1826 printDebug("WARNING: unlockAll_tempoary(true) "
1825 "deeplock fallback!"); 1827 "deeplock fallback!");
1826 } 1828 }
1827 printDebug("tempoary unlocking of dta reverted."); 1829 printDebug("tempoary unlocking of dta reverted.");
1828 } else { 1830 } else {
1829 printDebug("unlockAll_tempoary(true): nothing to do."); 1831 printDebug("unlockAll_tempoary(true): nothing to do.");
1830 } 1832 }
1831 timer()->start(DocTimer::id_autoLockTimer); 1833 timer()->start(DocTimer::id_autoLockTimer);
1832 } else {// unlock all data tempoary 1834 } else {// unlock all data tempoary
1833 if (unlikely(oldLockStates != 0)) { 1835 if (unlikely(oldLockStates != 0)) {
1834 /* DOH! We have already unlocked the data tempoarly. 1836 /* DOH! We have already unlocked the data tempoarly.
1835 * No need to do it twice. ;) 1837 * No need to do it twice. ;)
1836 */ 1838 */
1837 BUG(); 1839 BUG();
1838 return false; 1840 return false;
1839 } 1841 }
1840 wasDeepLocked = false; 1842 wasDeepLocked = false;
1841 bool mustUnlock = false; 1843 bool mustUnlock = false;
1842 if (isDeepLocked()) { 1844 if (isDeepLocked()) {
1843 PwMerror ret; 1845 PwMerror ret;
1844 while (1) { 1846 while (1) {
1845 ret = deepLock(false); 1847 ret = deepLock(false);
1846 if (ret == e_success) { 1848 if (ret == e_success) {
1847 break; 1849 break;
1848 } else if (ret == e_wrongPw) { 1850 } else if (ret == e_wrongPw) {
1849 wrongMpwMsgBox(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); 1851 wrongMpwMsgBox(getDocStatFlag(DOC_STAT_USE_CHIPCARD));
1850 } else { 1852 } else {
1851 printDebug("deep-unlocking failed while " 1853 printDebug("deep-unlocking failed while "
1852 "tempoary unlocking!"); 1854 "tempoary unlocking!");
1853 return false; 1855 return false;
1854 } 1856 }
1855 } 1857 }
1856 wasDeepLocked = true; 1858 wasDeepLocked = true;
1857 mustUnlock = true; 1859 mustUnlock = true;
1858 } else { 1860 } else {
1859 // first check if it's needed to unlock some entries 1861 // first check if it's needed to unlock some entries
1860 vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(), 1862 vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(),
1861 catEnd = dti.dta.end(), 1863 catEnd = dti.dta.end(),
1862 catI = catBegin; 1864 catI = catBegin;
1863 vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; 1865 vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI;
1864 while (catI != catEnd) { 1866 while (catI != catEnd) {
1865 entrBegin = catI->d.begin(); 1867 entrBegin = catI->d.begin();
1866 entrEnd = catI->d.end(); 1868 entrEnd = catI->d.end();
1867 entrI = entrBegin; 1869 entrI = entrBegin;
1868 while (entrI != entrEnd) { 1870 while (entrI != entrEnd) {
1869 if (entrI->lockStat == true) { 1871 if (entrI->lockStat == true) {
1870 mustUnlock = true; 1872 mustUnlock = true;
1871 break; 1873 break;
1872 } 1874 }
1873 ++entrI; 1875 ++entrI;
1874 } 1876 }
1875 if (mustUnlock) 1877 if (mustUnlock)
1876 break; 1878 break;
1877 ++catI; 1879 ++catI;
1878 } 1880 }
1879 } 1881 }
1880 if (!mustUnlock) { 1882 if (!mustUnlock) {
1881 // nothing to do. 1883 // nothing to do.
1882 timer()->stop(DocTimer::id_autoLockTimer); 1884 timer()->stop(DocTimer::id_autoLockTimer);
1883 printDebug("unlockAll_tempoary(): nothing to do."); 1885 printDebug("unlockAll_tempoary(): nothing to do.");
1884 return true; 1886 return true;
1885 } else if (!wasDeepLocked) { 1887 } else if (!wasDeepLocked) {
1886 if (!getDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW) && 1888 if (!getDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW) &&
1887 currentPw != "") { 1889 currentPw != "") {
1888 /* we can't unlock without mpw, so 1890 /* we can't unlock without mpw, so
1889 * we need to ask for it. 1891 * we need to ask for it.
1890 */ 1892 */
1891 QString pw; 1893 QString pw;
1892 while (1) { 1894 while (1) {
1893 pw = requestMpw(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); 1895 pw = requestMpw(getDocStatFlag(DOC_STAT_USE_CHIPCARD));
1894 if (pw == "") { 1896 if (pw == "") {
1895 return false; 1897 return false;
1896 } else if (pw == currentPw) { 1898 } else if (pw == currentPw) {
1897 break; 1899 break;
1898 } 1900 }
1899 wrongMpwMsgBox(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); 1901 wrongMpwMsgBox(getDocStatFlag(DOC_STAT_USE_CHIPCARD));
1900 } 1902 }
1901 } 1903 }
1902 } 1904 }
1903 timer()->stop(DocTimer::id_autoLockTimer); 1905 timer()->stop(DocTimer::id_autoLockTimer);
1904 oldLockStates = new vector< vector<bool> >; 1906 oldLockStates = new vector< vector<bool> >;
1905 vector<bool> tmp_vec; 1907 vector<bool> tmp_vec;
1906 vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(), 1908 vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(),
1907 catEnd = dti.dta.end(), 1909 catEnd = dti.dta.end(),
1908 catI = catBegin; 1910 catI = catBegin;
1909 vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; 1911 vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI;
1910 while (catI != catEnd) { 1912 while (catI != catEnd) {
1911 entrBegin = catI->d.begin(); 1913 entrBegin = catI->d.begin();
1912 entrEnd = catI->d.end(); 1914 entrEnd = catI->d.end();
1913 entrI = entrBegin; 1915 entrI = entrBegin;
1914 while (entrI != entrEnd) { 1916 while (entrI != entrEnd) {
@@ -2052,1043 +2054,1043 @@ int PwMDoc::getListViewPos(const QString &category, unsigned int index)
2052 } 2054 }
2053 2055
2054 return dti.dta[cat].d[index].listViewPos; 2056 return dti.dta[cat].d[index].listViewPos;
2055} 2057}
2056 2058
2057void PwMDoc::findEntry(unsigned int category, PwMDataItem find, unsigned int searchIn, 2059void PwMDoc::findEntry(unsigned int category, PwMDataItem find, unsigned int searchIn,
2058 vector<unsigned int> *foundPositions, bool breakAfterFound, 2060 vector<unsigned int> *foundPositions, bool breakAfterFound,
2059 bool caseSensitive, bool exactWordMatch, bool sortByLvp) 2061 bool caseSensitive, bool exactWordMatch, bool sortByLvp)
2060{ 2062{
2061 PWM_ASSERT(foundPositions); 2063 PWM_ASSERT(foundPositions);
2062 PWM_ASSERT(searchIn); 2064 PWM_ASSERT(searchIn);
2063 foundPositions->clear(); 2065 foundPositions->clear();
2064 2066
2065 unsigned int i, entries = numEntries(category); 2067 unsigned int i, entries = numEntries(category);
2066 for (i = 0; i < entries; ++i) { 2068 for (i = 0; i < entries; ++i) {
2067 if (searchIn & SEARCH_IN_DESC) { 2069 if (searchIn & SEARCH_IN_DESC) {
2068 if (!compareString(find.desc, dti.dta[category].d[i].desc, 2070 if (!compareString(find.desc, dti.dta[category].d[i].desc,
2069 caseSensitive, exactWordMatch)) { 2071 caseSensitive, exactWordMatch)) {
2070 continue; 2072 continue;
2071 } 2073 }
2072 } 2074 }
2073 if (searchIn & SEARCH_IN_NAME) { 2075 if (searchIn & SEARCH_IN_NAME) {
2074 if (!compareString(find.name, dti.dta[category].d[i].name, 2076 if (!compareString(find.name, dti.dta[category].d[i].name,
2075 caseSensitive, exactWordMatch)) { 2077 caseSensitive, exactWordMatch)) {
2076 continue; 2078 continue;
2077 } 2079 }
2078 } 2080 }
2079 if (searchIn & SEARCH_IN_PW) { 2081 if (searchIn & SEARCH_IN_PW) {
2080 bool wasLocked = isLocked(category, i); 2082 bool wasLocked = isLocked(category, i);
2081 getDataChangedLock(); 2083 getDataChangedLock();
2082 lockAt(category, i, false); 2084 lockAt(category, i, false);
2083 if (!compareString(find.pw, dti.dta[category].d[i].pw, 2085 if (!compareString(find.pw, dti.dta[category].d[i].pw,
2084 caseSensitive, exactWordMatch)) { 2086 caseSensitive, exactWordMatch)) {
2085 lockAt(category, i, wasLocked); 2087 lockAt(category, i, wasLocked);
2086 putDataChangedLock(); 2088 putDataChangedLock();
2087 continue; 2089 continue;
2088 } 2090 }
2089 lockAt(category, i, wasLocked); 2091 lockAt(category, i, wasLocked);
2090 putDataChangedLock(); 2092 putDataChangedLock();
2091 } 2093 }
2092 if (searchIn & SEARCH_IN_COMMENT) { 2094 if (searchIn & SEARCH_IN_COMMENT) {
2093 if (!compareString(find.comment, dti.dta[category].d[i].comment, 2095 if (!compareString(find.comment, dti.dta[category].d[i].comment,
2094 caseSensitive, exactWordMatch)) { 2096 caseSensitive, exactWordMatch)) {
2095 continue; 2097 continue;
2096 } 2098 }
2097 } 2099 }
2098 if (searchIn & SEARCH_IN_URL) { 2100 if (searchIn & SEARCH_IN_URL) {
2099 if (!compareString(find.url, dti.dta[category].d[i].url, 2101 if (!compareString(find.url, dti.dta[category].d[i].url,
2100 caseSensitive, exactWordMatch)) { 2102 caseSensitive, exactWordMatch)) {
2101 continue; 2103 continue;
2102 } 2104 }
2103 } 2105 }
2104 if (searchIn & SEARCH_IN_LAUNCHER) { 2106 if (searchIn & SEARCH_IN_LAUNCHER) {
2105 if (!compareString(find.launcher, dti.dta[category].d[i].launcher, 2107 if (!compareString(find.launcher, dti.dta[category].d[i].launcher,
2106 caseSensitive, exactWordMatch)) { 2108 caseSensitive, exactWordMatch)) {
2107 continue; 2109 continue;
2108 } 2110 }
2109 } 2111 }
2110 2112
2111 // all selected "searchIn" matched. 2113 // all selected "searchIn" matched.
2112 foundPositions->push_back(i); 2114 foundPositions->push_back(i);
2113 if (breakAfterFound) 2115 if (breakAfterFound)
2114 break; 2116 break;
2115 } 2117 }
2116 2118
2117 if (sortByLvp && foundPositions->size() > 1) { 2119 if (sortByLvp && foundPositions->size() > 1) {
2118 vector< pair<unsigned int /* foundPosition (real doc pos) */, 2120 vector< pair<unsigned int /* foundPosition (real doc pos) */,
2119 unsigned int /* lvp-pos */> > tmp_vec; 2121 unsigned int /* lvp-pos */> > tmp_vec;
2120 2122
2121 unsigned int i, items = foundPositions->size(); 2123 unsigned int i, items = foundPositions->size();
2122 pair<unsigned int, unsigned int> tmp_pair; 2124 pair<unsigned int, unsigned int> tmp_pair;
2123 for (i = 0; i < items; ++i) { 2125 for (i = 0; i < items; ++i) {
2124 tmp_pair.first = (*foundPositions)[i]; 2126 tmp_pair.first = (*foundPositions)[i];
2125 tmp_pair.second = dti.dta[category].d[(*foundPositions)[i]].listViewPos; 2127 tmp_pair.second = dti.dta[category].d[(*foundPositions)[i]].listViewPos;
2126 tmp_vec.push_back(tmp_pair); 2128 tmp_vec.push_back(tmp_pair);
2127 } 2129 }
2128 sort(tmp_vec.begin(), tmp_vec.end(), dta_lvp_greater()); 2130 sort(tmp_vec.begin(), tmp_vec.end(), dta_lvp_greater());
2129 foundPositions->clear(); 2131 foundPositions->clear();
2130 for (i = 0; i < items; ++i) { 2132 for (i = 0; i < items; ++i) {
2131 foundPositions->push_back(tmp_vec[i].first); 2133 foundPositions->push_back(tmp_vec[i].first);
2132 } 2134 }
2133 } 2135 }
2134} 2136}
2135 2137
2136void PwMDoc::findEntry(const QString &category, PwMDataItem find, unsigned int searchIn, 2138void PwMDoc::findEntry(const QString &category, PwMDataItem find, unsigned int searchIn,
2137 vector<unsigned int> *foundPositions, bool breakAfterFound, 2139 vector<unsigned int> *foundPositions, bool breakAfterFound,
2138 bool caseSensitive, bool exactWordMatch, bool sortByLvp) 2140 bool caseSensitive, bool exactWordMatch, bool sortByLvp)
2139{ 2141{
2140 PWM_ASSERT(foundPositions); 2142 PWM_ASSERT(foundPositions);
2141 unsigned int cat = 0; 2143 unsigned int cat = 0;
2142 2144
2143 if (!findCategory(category, &cat)) { 2145 if (!findCategory(category, &cat)) {
2144 foundPositions->clear(); 2146 foundPositions->clear();
2145 return; 2147 return;
2146 } 2148 }
2147 2149
2148 findEntry(cat, find, searchIn, foundPositions, breakAfterFound, 2150 findEntry(cat, find, searchIn, foundPositions, breakAfterFound,
2149 caseSensitive, exactWordMatch, sortByLvp); 2151 caseSensitive, exactWordMatch, sortByLvp);
2150} 2152}
2151 2153
2152bool PwMDoc::compareString(const string &s1, const string &s2, bool caseSensitive, 2154bool PwMDoc::compareString(const string &s1, const string &s2, bool caseSensitive,
2153 bool exactWordMatch) 2155 bool exactWordMatch)
2154{ 2156{
2155 QString _s1(s1.c_str()); 2157 QString _s1(s1.c_str());
2156 QString _s2(s2.c_str()); 2158 QString _s2(s2.c_str());
2157 if (!caseSensitive) { 2159 if (!caseSensitive) {
2158 _s1 = _s1.lower(); 2160 _s1 = _s1.lower();
2159 _s2 = _s2.lower(); 2161 _s2 = _s2.lower();
2160 } 2162 }
2161 if (exactWordMatch ? (_s1 == _s2) : (_s2.find(_s1) != -1)) 2163 if (exactWordMatch ? (_s1 == _s2) : (_s2.find(_s1) != -1))
2162 return true; 2164 return true;
2163 return false; 2165 return false;
2164} 2166}
2165 2167
2166bool PwMDoc::findCategory(const QString &name, unsigned int *index) 2168bool PwMDoc::findCategory(const QString &name, unsigned int *index)
2167{ 2169{
2168 vector<PwMCategoryItem>::iterator i = dti.dta.begin(), 2170 vector<PwMCategoryItem>::iterator i = dti.dta.begin(),
2169 end = dti.dta.end(); 2171 end = dti.dta.end();
2170 while (i != end) { 2172 while (i != end) {
2171 if ((*i).name == name.latin1()) { 2173 if ((*i).name == name.latin1()) {
2172 if (index) { 2174 if (index) {
2173 *index = i - dti.dta.begin(); 2175 *index = i - dti.dta.begin();
2174 } 2176 }
2175 return true; 2177 return true;
2176 } 2178 }
2177 ++i; 2179 ++i;
2178 } 2180 }
2179 return false; 2181 return false;
2180} 2182}
2181 2183
2182bool PwMDoc::renameCategory(const QString &category, const QString &newName) 2184bool PwMDoc::renameCategory(const QString &category, const QString &newName)
2183{ 2185{
2184 unsigned int cat = 0; 2186 unsigned int cat = 0;
2185 2187
2186 if (!findCategory(category, &cat)) 2188 if (!findCategory(category, &cat))
2187 return false; 2189 return false;
2188 2190
2189 return renameCategory(cat, newName); 2191 return renameCategory(cat, newName);
2190} 2192}
2191 2193
2192bool PwMDoc::renameCategory(unsigned int category, const QString &newName, 2194bool PwMDoc::renameCategory(unsigned int category, const QString &newName,
2193 bool dontFlagDirty) 2195 bool dontFlagDirty)
2194{ 2196{
2195 if (category > numCategories() - 1) 2197 if (category > numCategories() - 1)
2196 return false; 2198 return false;
2197 2199
2198 dti.dta[category].name = newName.latin1(); 2200 dti.dta[category].name = newName.latin1();
2199 if (!dontFlagDirty) 2201 if (!dontFlagDirty)
2200 flagDirty(); 2202 flagDirty();
2201 2203
2202 return true; 2204 return true;
2203} 2205}
2204 2206
2205bool PwMDoc::delCategory(const QString &category) 2207bool PwMDoc::delCategory(const QString &category)
2206{ 2208{
2207 unsigned int cat = 0; 2209 unsigned int cat = 0;
2208 2210
2209 if (!findCategory(category, &cat)) 2211 if (!findCategory(category, &cat))
2210 return false; 2212 return false;
2211 2213
2212 return delCategory(cat); 2214 return delCategory(cat);
2213} 2215}
2214 2216
2215bool PwMDoc::delCategory(unsigned int category, bool dontFlagDirty) 2217bool PwMDoc::delCategory(unsigned int category, bool dontFlagDirty)
2216{ 2218{
2217 if (category > numCategories() - 1) 2219 if (category > numCategories() - 1)
2218 return false; 2220 return false;
2219 2221
2220 // We don't delete it, if it is the last existing 2222 // We don't delete it, if it is the last existing
2221 // category! Instead we rename it to "Default". 2223 // category! Instead we rename it to "Default".
2222 if (numCategories() > 1) { 2224 if (numCategories() > 1) {
2223 dti.dta.erase(dti.dta.begin() + category); 2225 dti.dta.erase(dti.dta.begin() + category);
2224 } else { 2226 } else {
2225 renameCategory(category, DEFAULT_CATEGORY, dontFlagDirty); 2227 renameCategory(category, DEFAULT_CATEGORY, dontFlagDirty);
2226 return true; 2228 return true;
2227 } 2229 }
2228 if (!dontFlagDirty) 2230 if (!dontFlagDirty)
2229 flagDirty(); 2231 flagDirty();
2230 2232
2231 return true; 2233 return true;
2232} 2234}
2233 2235
2234void PwMDoc::delAllEmptyCat(bool dontFlagDirty) 2236void PwMDoc::delAllEmptyCat(bool dontFlagDirty)
2235{ 2237{
2236 vector<PwMCategoryItem>::iterator begin = dti.dta.begin(), 2238 vector<PwMCategoryItem>::iterator begin = dti.dta.begin(),
2237 end = dti.dta.end(), 2239 end = dti.dta.end(),
2238 i = begin; 2240 i = begin;
2239 while (i != end) { 2241 while (i != end) {
2240 if (i->d.empty()) { 2242 if (i->d.empty()) {
2241 delCategory(begin - i, dontFlagDirty); 2243 delCategory(begin - i, dontFlagDirty);
2242 } 2244 }
2243 ++i; 2245 ++i;
2244 } 2246 }
2245} 2247}
2246 2248
2247void PwMDoc::getCategoryList(vector<string> *list) 2249void PwMDoc::getCategoryList(vector<string> *list)
2248{ 2250{
2249 PWM_ASSERT(list); 2251 PWM_ASSERT(list);
2250 list->clear(); 2252 list->clear();
2251 vector<PwMCategoryItem>::iterator i = dti.dta.begin(), 2253 vector<PwMCategoryItem>::iterator i = dti.dta.begin(),
2252 end = dti.dta.end(); 2254 end = dti.dta.end();
2253 while (i != end) { 2255 while (i != end) {
2254 list->push_back(i->name); 2256 list->push_back(i->name);
2255 ++i; 2257 ++i;
2256 } 2258 }
2257} 2259}
2258 2260
2259void PwMDoc::getCategoryList(QStringList *list) 2261void PwMDoc::getCategoryList(QStringList *list)
2260{ 2262{
2261 PWM_ASSERT(list); 2263 PWM_ASSERT(list);
2262 list->clear(); 2264 list->clear();
2263 vector<PwMCategoryItem>::iterator i = dti.dta.begin(), 2265 vector<PwMCategoryItem>::iterator i = dti.dta.begin(),
2264 end = dti.dta.end(); 2266 end = dti.dta.end();
2265 while (i != end) { 2267 while (i != end) {
2266#ifndef PWM_EMBEDDED 2268#ifndef PWM_EMBEDDED
2267 list->push_back(i->name.c_str()); 2269 list->push_back(i->name.c_str());
2268#else 2270#else
2269 list->append(i->name.c_str()); 2271 list->append(i->name.c_str());
2270#endif 2272#endif
2271 ++i; 2273 ++i;
2272 } 2274 }
2273} 2275}
2274 2276
2275void PwMDoc::getEntryList(const QString &category, QStringList *list) 2277void PwMDoc::getEntryList(const QString &category, QStringList *list)
2276{ 2278{
2277 PWM_ASSERT(list); 2279 PWM_ASSERT(list);
2278 unsigned int cat = 0; 2280 unsigned int cat = 0;
2279 if (!findCategory(category, &cat)) { 2281 if (!findCategory(category, &cat)) {
2280 list->clear(); 2282 list->clear();
2281 return; 2283 return;
2282 } 2284 }
2283 getEntryList(cat, list); 2285 getEntryList(cat, list);
2284} 2286}
2285 2287
2286void PwMDoc::getEntryList(const QString &category, vector<string> *list) 2288void PwMDoc::getEntryList(const QString &category, vector<string> *list)
2287{ 2289{
2288 PWM_ASSERT(list); 2290 PWM_ASSERT(list);
2289 unsigned int cat = 0; 2291 unsigned int cat = 0;
2290 if (!findCategory(category, &cat)) { 2292 if (!findCategory(category, &cat)) {
2291 list->clear(); 2293 list->clear();
2292 return; 2294 return;
2293 } 2295 }
2294 getEntryList(cat, list); 2296 getEntryList(cat, list);
2295} 2297}
2296 2298
2297void PwMDoc::getEntryList(unsigned int category, vector<string> *list) 2299void PwMDoc::getEntryList(unsigned int category, vector<string> *list)
2298{ 2300{
2299 PWM_ASSERT(list); 2301 PWM_ASSERT(list);
2300 list->clear(); 2302 list->clear();
2301 vector<PwMDataItem>::iterator begin = dti.dta[category].d.begin(), 2303 vector<PwMDataItem>::iterator begin = dti.dta[category].d.begin(),
2302 end = dti.dta[category].d.end(), 2304 end = dti.dta[category].d.end(),
2303 i = begin; 2305 i = begin;
2304 while (i != end) { 2306 while (i != end) {
2305 list->push_back(i->desc); 2307 list->push_back(i->desc);
2306 ++i; 2308 ++i;
2307 } 2309 }
2308} 2310}
2309 2311
2310void PwMDoc::getEntryList(unsigned int category, QStringList *list) 2312void PwMDoc::getEntryList(unsigned int category, QStringList *list)
2311{ 2313{
2312 PWM_ASSERT(list); 2314 PWM_ASSERT(list);
2313 list->clear(); 2315 list->clear();
2314 vector<PwMDataItem>::iterator begin = dti.dta[category].d.begin(), 2316 vector<PwMDataItem>::iterator begin = dti.dta[category].d.begin(),
2315 end = dti.dta[category].d.end(), 2317 end = dti.dta[category].d.end(),
2316 i = begin; 2318 i = begin;
2317 while (i != end) { 2319 while (i != end) {
2318#ifndef PWM_EMBEDDED 2320#ifndef PWM_EMBEDDED
2319 list->push_back(i->desc.c_str()); 2321 list->push_back(i->desc.c_str());
2320#else 2322#else
2321 list->append(i->desc.c_str()); 2323 list->append(i->desc.c_str());
2322#endif 2324#endif
2323 ++i; 2325 ++i;
2324 } 2326 }
2325} 2327}
2326 2328
2327bool PwMDoc::execLauncher(const QString &category, unsigned int entryIndex) 2329bool PwMDoc::execLauncher(const QString &category, unsigned int entryIndex)
2328{ 2330{
2329 unsigned int cat = 0; 2331 unsigned int cat = 0;
2330 2332
2331 if (!findCategory(category, &cat)) 2333 if (!findCategory(category, &cat))
2332 return false; 2334 return false;
2333 2335
2334 return execLauncher(cat, entryIndex); 2336 return execLauncher(cat, entryIndex);
2335} 2337}
2336 2338
2337bool PwMDoc::execLauncher(unsigned int category, unsigned int entryIndex) 2339bool PwMDoc::execLauncher(unsigned int category, unsigned int entryIndex)
2338{ 2340{
2339#ifndef _WIN32_ 2341#ifndef _WIN32_
2340 if (geteuid() == 0) { 2342 if (geteuid() == 0) {
2341 rootAlertMsgBox(); 2343 rootAlertMsgBox();
2342 return false; 2344 return false;
2343 } 2345 }
2344#endif 2346#endif
2345 QString command(dti.dta[category].d[entryIndex].launcher.c_str()); 2347 QString command(dti.dta[category].d[entryIndex].launcher.c_str());
2346 bool wasLocked = isLocked(category, entryIndex); 2348 bool wasLocked = isLocked(category, entryIndex);
2347 2349
2348 if (command.find("$p") != -1) { 2350 if (command.find("$p") != -1) {
2349 /* the user requested the password to be included 2351 /* the user requested the password to be included
2350 * into the command. We have to ask for the password, 2352 * into the command. We have to ask for the password,
2351 * if it's locked. We do that by unlocking the entry 2353 * if it's locked. We do that by unlocking the entry
2352 */ 2354 */
2353 if (!lockAt(category, entryIndex, false)) 2355 if (!lockAt(category, entryIndex, false))
2354 return false; 2356 return false;
2355 } 2357 }
2356#ifndef PWM_EMBEDDED 2358#ifndef PWM_EMBEDDED
2357 command.replace("$d", dti.dta[category].d[entryIndex].desc.c_str()); 2359 command.replace("$d", dti.dta[category].d[entryIndex].desc.c_str());
2358 command.replace("$n", dti.dta[category].d[entryIndex].name.c_str()); 2360 command.replace("$n", dti.dta[category].d[entryIndex].name.c_str());
2359 command.replace("$p", dti.dta[category].d[entryIndex].pw.c_str()); 2361 command.replace("$p", dti.dta[category].d[entryIndex].pw.c_str());
2360 command.replace("$u", dti.dta[category].d[entryIndex].url.c_str()); 2362 command.replace("$u", dti.dta[category].d[entryIndex].url.c_str());
2361 command.replace("$c", dti.dta[category].d[entryIndex].comment.c_str()); 2363 command.replace("$c", dti.dta[category].d[entryIndex].comment.c_str());
2362#else 2364#else
2363 command.replace(QRegExp("$d"), dti.dta[category].d[entryIndex].desc.c_str()); 2365 command.replace(QRegExp("$d"), dti.dta[category].d[entryIndex].desc.c_str());
2364 command.replace(QRegExp("$n"), dti.dta[category].d[entryIndex].name.c_str()); 2366 command.replace(QRegExp("$n"), dti.dta[category].d[entryIndex].name.c_str());
2365 command.replace(QRegExp("$p"), dti.dta[category].d[entryIndex].pw.c_str()); 2367 command.replace(QRegExp("$p"), dti.dta[category].d[entryIndex].pw.c_str());
2366 command.replace(QRegExp("$u"), dti.dta[category].d[entryIndex].url.c_str()); 2368 command.replace(QRegExp("$u"), dti.dta[category].d[entryIndex].url.c_str());
2367 command.replace(QRegExp("$c"), dti.dta[category].d[entryIndex].comment.c_str()); 2369 command.replace(QRegExp("$c"), dti.dta[category].d[entryIndex].comment.c_str());
2368#endif 2370#endif
2369 command.append(" &"); 2371 command.append(" &");
2370 2372
2371 QString customXterm(conf()->confGlobXtermCommand()); 2373 QString customXterm(conf()->confGlobXtermCommand());
2372 if (!customXterm.isEmpty()) 2374 if (!customXterm.isEmpty())
2373 command = customXterm + " " + command; 2375 command = customXterm + " " + command;
2374 2376
2375 system(command.latin1()); 2377 system(command.latin1());
2376 2378
2377 lockAt(category, entryIndex, wasLocked); 2379 lockAt(category, entryIndex, wasLocked);
2378 return true; 2380 return true;
2379} 2381}
2380 2382
2381bool PwMDoc::goToURL(const QString &category, unsigned int entryIndex) 2383bool PwMDoc::goToURL(const QString &category, unsigned int entryIndex)
2382{ 2384{
2383 unsigned int cat = 0; 2385 unsigned int cat = 0;
2384 2386
2385 if (!findCategory(category, &cat)) 2387 if (!findCategory(category, &cat))
2386 return false; 2388 return false;
2387 2389
2388 return goToURL(cat, entryIndex); 2390 return goToURL(cat, entryIndex);
2389} 2391}
2390 2392
2391bool PwMDoc::goToURL(unsigned int category, unsigned int entryIndex) 2393bool PwMDoc::goToURL(unsigned int category, unsigned int entryIndex)
2392{ 2394{
2393#ifndef _WIN32_ 2395#ifndef _WIN32_
2394 if (geteuid() == 0) { 2396 if (geteuid() == 0) {
2395 rootAlertMsgBox(); 2397 rootAlertMsgBox();
2396 return false; 2398 return false;
2397 } 2399 }
2398#endif 2400#endif
2399 QString url(dti.dta[category].d[entryIndex].url.c_str()); 2401 QString url(dti.dta[category].d[entryIndex].url.c_str());
2400 if (url.isEmpty()) 2402 if (url.isEmpty())
2401 return false; 2403 return false;
2402 2404
2403 QString customBrowser(conf()->confGlobBrowserCommand()); 2405 QString customBrowser(conf()->confGlobBrowserCommand());
2404 if (!customBrowser.isEmpty()) { 2406 if (!customBrowser.isEmpty()) {
2405 browserProc.clearArguments(); 2407 browserProc.clearArguments();
2406 browserProc << customBrowser << url; 2408 browserProc << customBrowser << url;
2407 if (browserProc.start(KProcess::DontCare)) 2409 if (browserProc.start(KProcess::DontCare))
2408 return true; 2410 return true;
2409 } 2411 }
2410 2412
2411 browserProc.clearArguments(); 2413 browserProc.clearArguments();
2412 browserProc << "konqueror" << url; 2414 browserProc << "konqueror" << url;
2413 if (browserProc.start(KProcess::DontCare)) 2415 if (browserProc.start(KProcess::DontCare))
2414 return true; 2416 return true;
2415 2417
2416 browserProc.clearArguments(); 2418 browserProc.clearArguments();
2417 browserProc << "mozilla" << url; 2419 browserProc << "mozilla" << url;
2418 if (browserProc.start(KProcess::DontCare)) 2420 if (browserProc.start(KProcess::DontCare))
2419 return true; 2421 return true;
2420 2422
2421 browserProc.clearArguments(); 2423 browserProc.clearArguments();
2422 browserProc << "opera" << url; 2424 browserProc << "opera" << url;
2423 if (browserProc.start(KProcess::DontCare)) 2425 if (browserProc.start(KProcess::DontCare))
2424 return true; 2426 return true;
2425 return false; 2427 return false;
2426} 2428}
2427 2429
2428PwMerror PwMDoc::exportToText(const QString *file) 2430PwMerror PwMDoc::exportToText(const QString *file)
2429{ 2431{
2430 PWM_ASSERT(file); 2432 PWM_ASSERT(file);
2431 if (QFile::exists(*file)) { 2433 if (QFile::exists(*file)) {
2432 if (!QFile::remove(*file)) 2434 if (!QFile::remove(*file))
2433 return e_accessFile; 2435 return e_accessFile;
2434 } 2436 }
2435 QFile f(*file); 2437 QFile f(*file);
2436 if (!f.open(IO_ReadWrite)) 2438 if (!f.open(QIODevice::ReadWrite))
2437 return e_openFile; 2439 return e_openFile;
2438 2440
2439 if (!unlockAll_tempoary()) { 2441 if (!unlockAll_tempoary()) {
2440 f.close(); 2442 f.close();
2441 return e_lock; 2443 return e_lock;
2442 } 2444 }
2443 2445
2444 // write header 2446 // write header
2445 string header = i18n("Password table generated by\nPwM v").latin1(); 2447 string header = i18n("Password table generated by\nPwM v").latin1();
2446 header += PACKAGE_VER; 2448 header += PACKAGE_VER;
2447 header += i18n("\non ").latin1(); 2449 header += i18n("\non ").latin1();
2448 QDate currDate = QDate::currentDate(); 2450 QDate currDate = QDate::currentDate();
2449 QTime currTime = QTime::currentTime(); 2451 QTime currTime = QTime::currentTime();
2450 2452
2451#ifndef PWM_EMBEDDED 2453#ifndef PWM_EMBEDDED
2452 header += currDate.toString("ddd MMMM d ").latin1(); 2454 header += currDate.toString("ddd MMMM d ").latin1();
2453 header += currTime.toString("hh:mm:ss ").latin1(); 2455 header += currTime.toString("hh:mm:ss ").latin1();
2454#else 2456#else
2455 QString dfs = KGlobal::locale()->dateFormatShort(); 2457 QString dfs = KGlobal::locale()->dateFormatShort();
2456 bool ampm = KGlobal::locale()->use12Clock(); 2458 bool ampm = KGlobal::locale()->use12Clock();
2457 KGlobal::locale()->setDateFormatShort("%A %B %d"); 2459 KGlobal::locale()->setDateFormatShort("%A %B %d");
2458 KGlobal::locale()->setHore24Format(true); 2460 KGlobal::locale()->setHore24Format(true);
2459 2461
2460 header += KGlobal::locale()->formatDate(currDate, true, KLocale::Userdefined).latin1(); 2462 header += KGlobal::locale()->formatDate(currDate, true, KLocale::Userdefined).latin1();
2461 header += KGlobal::locale()->formatTime(currTime, true).latin1(); 2463 header += KGlobal::locale()->formatTime(currTime, true).latin1();
2462 KGlobal::locale()->setDateFormatShort(dfs); 2464 KGlobal::locale()->setDateFormatShort(dfs);
2463 KGlobal::locale()->setHore24Format(!ampm); 2465 KGlobal::locale()->setHore24Format(!ampm);
2464 2466
2465#endif 2467#endif
2466 header += tostr(currDate.year()); 2468 header += tostr(currDate.year());
2467 header += "\n==============================\n\n"; 2469 header += "\n==============================\n\n";
2468 2470
2469 2471
2470#ifndef PWM_EMBEDDED 2472#ifndef PWM_EMBEDDED
2471 if (f.writeBlock(header.c_str(), header.length()) != (Q_LONG)header.length()) { 2473 if (f.writeBlock(header.c_str(), header.length()) != (Q_LONG)header.length()) {
2472 unlockAll_tempoary(true); 2474 unlockAll_tempoary(true);
2473 f.close(); 2475 f.close();
2474 return e_writeFile; 2476 return e_writeFile;
2475 } 2477 }
2476#else 2478#else
2477 if (f.writeBlock(header.c_str(), header.length()) != (long)header.length()) { 2479 if (f.writeBlock(header.c_str(), header.length()) != (long)header.length()) {
2478 unlockAll_tempoary(true); 2480 unlockAll_tempoary(true);
2479 f.close(); 2481 f.close();
2480 return e_writeFile; 2482 return e_writeFile;
2481 } 2483 }
2482#endif 2484#endif
2483 unsigned int i, numCat = numCategories(); 2485 unsigned int i, numCat = numCategories();
2484 unsigned int j, numEnt; 2486 unsigned int j, numEnt;
2485 string exp; 2487 string exp;
2486 for (i = 0; i < numCat; ++i) { 2488 for (i = 0; i < numCat; ++i) {
2487 numEnt = numEntries(i); 2489 numEnt = numEntries(i);
2488 2490
2489 exp = "\n== Category: "; 2491 exp = "\n== Category: ";
2490 exp += dti.dta[i].name; 2492 exp += dti.dta[i].name;
2491 exp += " ==\n"; 2493 exp += " ==\n";
2492#ifndef PWM_EMBEDDED 2494#ifndef PWM_EMBEDDED
2493 if (f.writeBlock(exp.c_str(), exp.length()) != (Q_LONG)exp.length()) { 2495 if (f.writeBlock(exp.c_str(), exp.length()) != (Q_LONG)exp.length()) {
2494 unlockAll_tempoary(true); 2496 unlockAll_tempoary(true);
2495 f.close(); 2497 f.close();
2496 return e_writeFile; 2498 return e_writeFile;
2497 } 2499 }
2498#else 2500#else
2499 if (f.writeBlock(exp.c_str(), exp.length()) != (long)exp.length()) { 2501 if (f.writeBlock(exp.c_str(), exp.length()) != (long)exp.length()) {
2500 unlockAll_tempoary(true); 2502 unlockAll_tempoary(true);
2501 f.close(); 2503 f.close();
2502 return e_writeFile; 2504 return e_writeFile;
2503 } 2505 }
2504#endif 2506#endif
2505 for (j = 0; j < numEnt; ++j) { 2507 for (j = 0; j < numEnt; ++j) {
2506 exp = "\n-- "; 2508 exp = "\n-- ";
2507 exp += dti.dta[i].d[j].desc; 2509 exp += dti.dta[i].d[j].desc;
2508 exp += " --\n"; 2510 exp += " --\n";
2509 2511
2510 exp += i18n("Username: ").latin1(); 2512 exp += i18n("Username: ").latin1();
2511 exp += dti.dta[i].d[j].name; 2513 exp += dti.dta[i].d[j].name;
2512 exp += "\n"; 2514 exp += "\n";
2513 2515
2514 exp += i18n("Password: ").latin1(); 2516 exp += i18n("Password: ").latin1();
2515 exp += dti.dta[i].d[j].pw; 2517 exp += dti.dta[i].d[j].pw;
2516 exp += "\n"; 2518 exp += "\n";
2517 2519
2518 exp += i18n("Comment: ").latin1(); 2520 exp += i18n("Comment: ").latin1();
2519 exp += dti.dta[i].d[j].comment; 2521 exp += dti.dta[i].d[j].comment;
2520 exp += "\n"; 2522 exp += "\n";
2521 2523
2522 exp += i18n("URL: ").latin1(); 2524 exp += i18n("URL: ").latin1();
2523 exp += dti.dta[i].d[j].url; 2525 exp += dti.dta[i].d[j].url;
2524 exp += "\n"; 2526 exp += "\n";
2525 2527
2526 exp += i18n("Launcher: ").latin1(); 2528 exp += i18n("Launcher: ").latin1();
2527 exp += dti.dta[i].d[j].launcher; 2529 exp += dti.dta[i].d[j].launcher;
2528 exp += "\n"; 2530 exp += "\n";
2529 2531
2530#ifndef PWM_EMBEDDED 2532#ifndef PWM_EMBEDDED
2531 if (f.writeBlock(exp.c_str(), exp.length()) != (Q_LONG)exp.length()) { 2533 if (f.writeBlock(exp.c_str(), exp.length()) != (Q_LONG)exp.length()) {
2532 unlockAll_tempoary(true); 2534 unlockAll_tempoary(true);
2533 f.close(); 2535 f.close();
2534 return e_writeFile; 2536 return e_writeFile;
2535 } 2537 }
2536#else 2538#else
2537 if (f.writeBlock(exp.c_str(), exp.length()) != (long)exp.length()) { 2539 if (f.writeBlock(exp.c_str(), exp.length()) != (long)exp.length()) {
2538 unlockAll_tempoary(true); 2540 unlockAll_tempoary(true);
2539 f.close(); 2541 f.close();
2540 return e_writeFile; 2542 return e_writeFile;
2541 } 2543 }
2542#endif 2544#endif
2543 } 2545 }
2544 } 2546 }
2545 unlockAll_tempoary(true); 2547 unlockAll_tempoary(true);
2546 f.close(); 2548 f.close();
2547 2549
2548 return e_success; 2550 return e_success;
2549} 2551}
2550 2552
2551PwMerror PwMDoc::importFromText(const QString *file, int format) 2553PwMerror PwMDoc::importFromText(const QString *file, int format)
2552{ 2554{
2553 PWM_ASSERT(file); 2555 PWM_ASSERT(file);
2554 if (format == 0) 2556 if (format == 0)
2555 return importText_PwM(file); 2557 return importText_PwM(file);
2556 else if (format == -1) { 2558 else if (format == -1) {
2557 // probe for all formats 2559 // probe for all formats
2558 if (importText_PwM(file) == e_success) 2560 if (importText_PwM(file) == e_success)
2559 return e_success; 2561 return e_success;
2560 dti.clear(); 2562 dti.clear();
2561 emitDataChanged(this); 2563 emitDataChanged(this);
2562 // add next format here... 2564 // add next format here...
2563 return e_fileFormat; 2565 return e_fileFormat;
2564 } 2566 }
2565 return e_invalidArg; 2567 return e_invalidArg;
2566} 2568}
2567 2569
2568PwMerror PwMDoc::importText_PwM(const QString *file) 2570PwMerror PwMDoc::importText_PwM(const QString *file)
2569{ 2571{
2570#ifndef PWM_EMBEDDED 2572#ifndef PWM_EMBEDDED
2571 PWM_ASSERT(file); 2573 PWM_ASSERT(file);
2572 FILE *f; 2574 FILE *f;
2573 int tmp; 2575 int tmp;
2574 ssize_t ret; 2576 ssize_t ret;
2575 string curCat; 2577 string curCat;
2576 unsigned int entriesRead = 0; 2578 unsigned int entriesRead = 0;
2577 PwMDataItem currItem; 2579 PwMDataItem currItem;
2578 f = fopen(file->latin1(), "r"); 2580 f = fopen(file->latin1(), "r");
2579 if (!f) 2581 if (!f)
2580 return e_openFile; 2582 return e_openFile;
2581 size_t ch_tmp_size = 1024; 2583 size_t ch_tmp_size = 1024;
2582 char *ch_tmp = (char*)malloc(ch_tmp_size); 2584 char *ch_tmp = (char*)malloc(ch_tmp_size);
2583 if (!ch_tmp) { 2585 if (!ch_tmp) {
2584 fclose(f); 2586 fclose(f);
2585 return e_outOfMem; 2587 return e_outOfMem;
2586 } 2588 }
2587 2589
2588 // - check header 2590 // - check header
2589 if (getline(&ch_tmp, &ch_tmp_size, f) == -1) // skip first line. 2591 if (getline(&ch_tmp, &ch_tmp_size, f) == -1) // skip first line.
2590 goto formatError; 2592 goto formatError;
2591 // check version-string and return version in "ch_tmp". 2593 // check version-string and return version in "ch_tmp".
2592 if (fscanf(f, "PwM v%s", ch_tmp) != 1) { 2594 if (fscanf(f, "PwM v%s", ch_tmp) != 1) {
2593 // header not recognized as PwM generated header 2595 // header not recognized as PwM generated header
2594 goto formatError; 2596 goto formatError;
2595 } 2597 }
2596 // set filepointer behind version-string-line previously checked 2598 // set filepointer behind version-string-line previously checked
2597 if (getline(&ch_tmp, &ch_tmp_size, f) == -1) 2599 if (getline(&ch_tmp, &ch_tmp_size, f) == -1)
2598 goto formatError; 2600 goto formatError;
2599 // skip next line containing the build-date 2601 // skip next line containing the build-date
2600 if (getline(&ch_tmp, &ch_tmp_size, f) == -1) 2602 if (getline(&ch_tmp, &ch_tmp_size, f) == -1)
2601 goto formatError; 2603 goto formatError;
2602 // read header termination line 2604 // read header termination line
2603 if (getline(&ch_tmp, &ch_tmp_size, f) == -1) 2605 if (getline(&ch_tmp, &ch_tmp_size, f) == -1)
2604 goto formatError; 2606 goto formatError;
2605 if (strcmp(ch_tmp, "==============================\n")) 2607 if (strcmp(ch_tmp, "==============================\n"))
2606 goto formatError; 2608 goto formatError;
2607 2609
2608 // - read entries 2610 // - read entries
2609 do { 2611 do {
2610 // find beginning of next category 2612 // find beginning of next category
2611 do { 2613 do {
2612 tmp = fgetc(f); 2614 tmp = fgetc(f);
2613 } while (tmp == '\n' && tmp != EOF); 2615 } while (tmp == '\n' && tmp != EOF);
2614 if (tmp == EOF) 2616 if (tmp == EOF)
2615 break; 2617 break;
2616 2618
2617 // decrement filepos by one 2619 // decrement filepos by one
2618 fseek(f, -1, SEEK_CUR); 2620 fseek(f, -1, SEEK_CUR);
2619 // read cat-name 2621 // read cat-name
2620 if (getline(&ch_tmp, &ch_tmp_size, f) == -1) 2622 if (getline(&ch_tmp, &ch_tmp_size, f) == -1)
2621 goto formatError; 2623 goto formatError;
2622 // check cat-name format 2624 // check cat-name format
2623 if (memcmp(ch_tmp, "== Category: ", 13) != 0) 2625 if (memcmp(ch_tmp, "== Category: ", 13) != 0)
2624 goto formatError; 2626 goto formatError;
2625 if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " ==", 3) != 0) 2627 if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " ==", 3) != 0)
2626 goto formatError; 2628 goto formatError;
2627 // copy cat-name 2629 // copy cat-name
2628 curCat.assign(ch_tmp + 13, strlen(ch_tmp) - 1 - 16); 2630 curCat.assign(ch_tmp + 13, strlen(ch_tmp) - 1 - 16);
2629 2631
2630 do { 2632 do {
2631 // find beginning of next entry 2633 // find beginning of next entry
2632 do { 2634 do {
2633 tmp = fgetc(f); 2635 tmp = fgetc(f);
2634 } while (tmp == '\n' && tmp != EOF && tmp != '='); 2636 } while (tmp == '\n' && tmp != EOF && tmp != '=');
2635 if (tmp == EOF) 2637 if (tmp == EOF)
2636 break; 2638 break;
2637 if (tmp == '=') { 2639 if (tmp == '=') {
2638 fseek(f, -1, SEEK_CUR); 2640 fseek(f, -1, SEEK_CUR);
2639 break; 2641 break;
2640 } 2642 }
2641 // decrement filepos by one 2643 // decrement filepos by one
2642 fseek(f, -1, SEEK_CUR); 2644 fseek(f, -1, SEEK_CUR);
2643 // read desc-line 2645 // read desc-line
2644 if (getline(&ch_tmp, &ch_tmp_size, f) == -1) 2646 if (getline(&ch_tmp, &ch_tmp_size, f) == -1)
2645 goto formatError; 2647 goto formatError;
2646 // check desc-line format 2648 // check desc-line format
2647 if (memcmp(ch_tmp, "-- ", 3) != 0) 2649 if (memcmp(ch_tmp, "-- ", 3) != 0)
2648 goto formatError; 2650 goto formatError;
2649 if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " --", 3) != 0) 2651 if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " --", 3) != 0)
2650 goto formatError; 2652 goto formatError;
2651 // add desc-line 2653 // add desc-line
2652 currItem.desc.assign(ch_tmp + 3, strlen(ch_tmp) - 1 - 6); 2654 currItem.desc.assign(ch_tmp + 3, strlen(ch_tmp) - 1 - 6);
2653 2655
2654 // read username-line 2656 // read username-line
2655 if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) 2657 if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1)
2656 goto formatError; 2658 goto formatError;
2657 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.name)) 2659 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.name))
2658 goto formatError; 2660 goto formatError;
2659 2661
2660 // read pw-line 2662 // read pw-line
2661 if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) 2663 if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1)
2662 goto formatError; 2664 goto formatError;
2663 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.pw)) 2665 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.pw))
2664 goto formatError; 2666 goto formatError;
2665 2667
2666 // read comment-line 2668 // read comment-line
2667 if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) 2669 if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1)
2668 goto formatError; 2670 goto formatError;
2669 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.comment)) 2671 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.comment))
2670 goto formatError; 2672 goto formatError;
2671 2673
2672 // read URL-line 2674 // read URL-line
2673 if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) 2675 if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1)
2674 goto formatError; 2676 goto formatError;
2675 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.url)) 2677 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.url))
2676 goto formatError; 2678 goto formatError;
2677 2679
2678 // read launcher-line 2680 // read launcher-line
2679 if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) 2681 if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1)
2680 goto formatError; 2682 goto formatError;
2681 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.launcher)) 2683 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.launcher))
2682 goto formatError; 2684 goto formatError;
2683 2685
2684 currItem.lockStat = true; 2686 currItem.lockStat = true;
2685 currItem.listViewPos = -1; 2687 currItem.listViewPos = -1;
2686 addEntry(curCat.c_str(), &currItem, true); 2688 addEntry(curCat.c_str(), &currItem, true);
2687 ++entriesRead; 2689 ++entriesRead;
2688 } while (1); 2690 } while (1);
2689 } while (1); 2691 } while (1);
2690 if (!entriesRead) 2692 if (!entriesRead)
2691 goto formatError; 2693 goto formatError;
2692 2694
2693 free(ch_tmp); 2695 free(ch_tmp);
2694 fclose(f); 2696 fclose(f);
2695 flagDirty(); 2697 flagDirty();
2696 return e_success; 2698 return e_success;
2697 2699
2698 formatError: 2700 formatError:
2699 free(ch_tmp); 2701 free(ch_tmp);
2700 fclose(f); 2702 fclose(f);
2701 return e_fileFormat; 2703 return e_fileFormat;
2702#else 2704#else
2703 PWM_ASSERT(file); 2705 PWM_ASSERT(file);
2704 QFile f(file->latin1()); 2706 QFile f(file->latin1());
2705 int tmp; 2707 int tmp;
2706 ssize_t ret; 2708 ssize_t ret;
2707 string curCat; 2709 string curCat;
2708 unsigned int entriesRead = 0; 2710 unsigned int entriesRead = 0;
2709 PwMDataItem currItem; 2711 PwMDataItem currItem;
2710 bool res = f.open(IO_ReadOnly); 2712 bool res = f.open(QIODevice::ReadOnly);
2711 if (res == false) 2713 if (res == false)
2712 return e_openFile; 2714 return e_openFile;
2713 2715
2714 unsigned int ch_tmp_size = 1024; 2716 unsigned int ch_tmp_size = 1024;
2715 char *ch_tmp = (char*)malloc(ch_tmp_size); 2717 char *ch_tmp = (char*)malloc(ch_tmp_size);
2716 if (!ch_tmp) { 2718 if (!ch_tmp) {
2717 f.close(); 2719 f.close();
2718 return e_outOfMem; 2720 return e_outOfMem;
2719 } 2721 }
2720 2722
2721 // - check header 2723 // - check header
2722 if (f.readLine(ch_tmp, ch_tmp_size) == -1) // skip first line. 2724 if (f.readLine(ch_tmp, ch_tmp_size) == -1) // skip first line.
2723 goto formatError; 2725 goto formatError;
2724 2726
2725 //US read fileversion first, then check if ok. 2727 //US read fileversion first, then check if ok.
2726 if (f.readLine(ch_tmp, ch_tmp_size) == -1) 2728 if (f.readLine(ch_tmp, ch_tmp_size) == -1)
2727 goto formatError; 2729 goto formatError;
2728 2730
2729 // check version-string and return version in "ch_tmp". 2731 // check version-string and return version in "ch_tmp".
2730 //US if (fscanf(f, "PwM v%s", ch_tmp) != 1) { 2732 //US if (fscanf(f, "PwM v%s", ch_tmp) != 1) {
2731 //US // header not recognized as PwM generated header 2733 //US // header not recognized as PwM generated header
2732 //US goto formatError; 2734 //US goto formatError;
2733 //US} 2735 //US}
2734 //US set filepointer behind version-string-line previously checked 2736 //US set filepointer behind version-string-line previously checked
2735 //US if (f.readLine(ch_tmp, ch_tmp_size) == -1) 2737 //US if (f.readLine(ch_tmp, ch_tmp_size) == -1)
2736 //US goto formatError; 2738 //US goto formatError;
2737 // skip next line containing the build-date 2739 // skip next line containing the build-date
2738 if (f.readLine(ch_tmp, ch_tmp_size) == -1) 2740 if (f.readLine(ch_tmp, ch_tmp_size) == -1)
2739 goto formatError; 2741 goto formatError;
2740 // read header termination line 2742 // read header termination line
2741 if (f.readLine(ch_tmp, ch_tmp_size) == -1) 2743 if (f.readLine(ch_tmp, ch_tmp_size) == -1)
2742 goto formatError; 2744 goto formatError;
2743 if (strcmp(ch_tmp, "==============================\n")) 2745 if (strcmp(ch_tmp, "==============================\n"))
2744 goto formatError; 2746 goto formatError;
2745 2747
2746 // - read entries 2748 // - read entries
2747 do { 2749 do {
2748 // find beginning of next category 2750 // find beginning of next category
2749 do { 2751 do {
2750 tmp = f.getch(); 2752 tmp = f.getch();
2751 } while (tmp == '\n' && tmp != EOF); 2753 } while (tmp == '\n' && tmp != EOF);
2752 if (tmp == EOF) 2754 if (tmp == EOF)
2753 break; 2755 break;
2754 2756
2755 // decrement filepos by one 2757 // decrement filepos by one
2756 f.at(f.at()-1); 2758 f.at(f.at()-1);
2757 // read cat-name 2759 // read cat-name
2758 if (f.readLine(ch_tmp, ch_tmp_size) == -1) 2760 if (f.readLine(ch_tmp, ch_tmp_size) == -1)
2759 goto formatError; 2761 goto formatError;
2760 // check cat-name format 2762 // check cat-name format
2761 if (memcmp(ch_tmp, "== Category: ", 13) != 0) 2763 if (memcmp(ch_tmp, "== Category: ", 13) != 0)
2762 goto formatError; 2764 goto formatError;
2763 if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " ==", 3) != 0) 2765 if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " ==", 3) != 0)
2764 goto formatError; 2766 goto formatError;
2765 // copy cat-name 2767 // copy cat-name
2766 curCat.assign(ch_tmp + 13, strlen(ch_tmp) - 1 - 16); 2768 curCat.assign(ch_tmp + 13, strlen(ch_tmp) - 1 - 16);
2767 2769
2768 do { 2770 do {
2769 // find beginning of next entry 2771 // find beginning of next entry
2770 do { 2772 do {
2771 tmp = f.getch(); 2773 tmp = f.getch();
2772 } while (tmp == '\n' && tmp != EOF && tmp != '='); 2774 } while (tmp == '\n' && tmp != EOF && tmp != '=');
2773 if (tmp == EOF) 2775 if (tmp == EOF)
2774 break; 2776 break;
2775 if (tmp == '=') { 2777 if (tmp == '=') {
2776 f.at(f.at()-1); 2778 f.at(f.at()-1);
2777 break; 2779 break;
2778 } 2780 }
2779 // decrement filepos by one 2781 // decrement filepos by one
2780 f.at(f.at()-1); 2782 f.at(f.at()-1);
2781 // read desc-line 2783 // read desc-line
2782 if (f.readLine(ch_tmp, ch_tmp_size) == -1) 2784 if (f.readLine(ch_tmp, ch_tmp_size) == -1)
2783 goto formatError; 2785 goto formatError;
2784 // check desc-line format 2786 // check desc-line format
2785 if (memcmp(ch_tmp, "-- ", 3) != 0) 2787 if (memcmp(ch_tmp, "-- ", 3) != 0)
2786 goto formatError; 2788 goto formatError;
2787 if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " --", 3) != 0) 2789 if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " --", 3) != 0)
2788 goto formatError; 2790 goto formatError;
2789 // add desc-line 2791 // add desc-line
2790 currItem.desc.assign(ch_tmp + 3, strlen(ch_tmp) - 1 - 6); 2792 currItem.desc.assign(ch_tmp + 3, strlen(ch_tmp) - 1 - 6);
2791 2793
2792 // read username-line 2794 // read username-line
2793 if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) 2795 if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1)
2794 goto formatError; 2796 goto formatError;
2795 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.name)) 2797 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.name))
2796 goto formatError; 2798 goto formatError;
2797 2799
2798 // read pw-line 2800 // read pw-line
2799 if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) 2801 if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1)
2800 goto formatError; 2802 goto formatError;
2801 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.pw)) 2803 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.pw))
2802 goto formatError; 2804 goto formatError;
2803 2805
2804 // read comment-line 2806 // read comment-line
2805 if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) 2807 if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1)
2806 goto formatError; 2808 goto formatError;
2807 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.comment)) 2809 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.comment))
2808 goto formatError; 2810 goto formatError;
2809 2811
2810 // read URL-line 2812 // read URL-line
2811 if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) 2813 if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1)
2812 goto formatError; 2814 goto formatError;
2813 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.url)) 2815 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.url))
2814 goto formatError; 2816 goto formatError;
2815 2817
2816 // read launcher-line 2818 // read launcher-line
2817 if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) 2819 if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1)
2818 goto formatError; 2820 goto formatError;
2819 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.launcher)) 2821 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.launcher))
2820 goto formatError; 2822 goto formatError;
2821 2823
2822 currItem.lockStat = true; 2824 currItem.lockStat = true;
2823 currItem.listViewPos = -1; 2825 currItem.listViewPos = -1;
2824 addEntry(curCat.c_str(), &currItem, true); 2826 addEntry(curCat.c_str(), &currItem, true);
2825 ++entriesRead; 2827 ++entriesRead;
2826 } while (1); 2828 } while (1);
2827 } while (1); 2829 } while (1);
2828 if (!entriesRead) 2830 if (!entriesRead)
2829 goto formatError; 2831 goto formatError;
2830 2832
2831 free(ch_tmp); 2833 free(ch_tmp);
2832 f.close(); 2834 f.close();
2833 flagDirty(); 2835 flagDirty();
2834 return e_success; 2836 return e_success;
2835 2837
2836 formatError: 2838 formatError:
2837 free(ch_tmp); 2839 free(ch_tmp);
2838 f.close(); 2840 f.close();
2839 return e_fileFormat; 2841 return e_fileFormat;
2840 2842
2841#endif 2843#endif
2842 2844
2843} 2845}
2844 2846
2845bool PwMDoc::textExtractEntry_PwM(const char *in, ssize_t in_size, string *out) 2847bool PwMDoc::textExtractEntry_PwM(const char *in, ssize_t in_size, string *out)
2846{ 2848{
2847 PWM_ASSERT(in && out); 2849 PWM_ASSERT(in && out);
2848 ssize_t i = 0, len = in_size - 1; 2850 ssize_t i = 0, len = in_size - 1;
2849 while (i < len) { 2851 while (i < len) {
2850 if (in[i] == ':') 2852 if (in[i] == ':')
2851 break; 2853 break;
2852 ++i; 2854 ++i;
2853 } 2855 }
2854 i += 2; 2856 i += 2;
2855 *out = ""; 2857 *out = "";
2856 out->append(in + i, in_size - i - 1); 2858 out->append(in + i, in_size - i - 1);
2857 return true; 2859 return true;
2858} 2860}
2859 2861
2860PwMerror PwMDoc::exportToGpasman(const QString *file) 2862PwMerror PwMDoc::exportToGpasman(const QString *file)
2861{ 2863{
2862 PWM_ASSERT(file); 2864 PWM_ASSERT(file);
2863 GpasmanFile gp; 2865 GpasmanFile gp;
2864 int ret; 2866 int ret;
2865 2867
2866 if (!unlockAll_tempoary()) 2868 if (!unlockAll_tempoary())
2867 return e_lock; 2869 return e_lock;
2868 2870
2869 QString gpmPassword; 2871 QString gpmPassword;
2870 while (1) { 2872 while (1) {
2871 gpmPassword = requestNewMpw(0); 2873 gpmPassword = requestNewMpw(0);
2872 if (gpmPassword == "") { 2874 if (gpmPassword == "") {
2873 unlockAll_tempoary(true); 2875 unlockAll_tempoary(true);
2874 return e_noPw; 2876 return e_noPw;
2875 } 2877 }
2876 if (gpmPassword.length() < 4) { 2878 if (gpmPassword.length() < 4) {
2877 gpmPwLenErrMsgBox(); 2879 gpmPwLenErrMsgBox();
2878 } else { 2880 } else {
2879 break; 2881 break;
2880 } 2882 }
2881 } 2883 }
2882 2884
2883 ret = gp.save_init(file->latin1(), gpmPassword.latin1()); 2885 ret = gp.save_init(file->latin1(), gpmPassword.latin1());
2884 if (ret != 1) { 2886 if (ret != 1) {
2885 unlockAll_tempoary(true); 2887 unlockAll_tempoary(true);
2886 return e_accessFile; 2888 return e_accessFile;
2887 } 2889 }
2888 2890
2889 char *entry[4]; 2891 char *entry[4];
2890 unsigned int numCat = numCategories(), i; 2892 unsigned int numCat = numCategories(), i;
2891 unsigned int numEntr, j; 2893 unsigned int numEntr, j;
2892 int descLen, nameLen, pwLen, commentLen; 2894 int descLen, nameLen, pwLen, commentLen;
2893 for (i = 0; i < numCat; ++i) { 2895 for (i = 0; i < numCat; ++i) {
2894 numEntr = numEntries(i); 2896 numEntr = numEntries(i);
2895 for (j = 0; j < numEntr; ++j) { 2897 for (j = 0; j < numEntr; ++j) {
2896 descLen = dti.dta[i].d[j].desc.length(); 2898 descLen = dti.dta[i].d[j].desc.length();
2897 nameLen = dti.dta[i].d[j].name.length(); 2899 nameLen = dti.dta[i].d[j].name.length();
2898 pwLen = dti.dta[i].d[j].pw.length(); 2900 pwLen = dti.dta[i].d[j].pw.length();
2899 commentLen = dti.dta[i].d[j].comment.length(); 2901 commentLen = dti.dta[i].d[j].comment.length();
2900 entry[0] = new char[descLen + 1]; 2902 entry[0] = new char[descLen + 1];
2901 entry[1] = new char[nameLen + 1]; 2903 entry[1] = new char[nameLen + 1];
2902 entry[2] = new char[pwLen + 1]; 2904 entry[2] = new char[pwLen + 1];
2903 entry[3] = new char[commentLen + 1]; 2905 entry[3] = new char[commentLen + 1];
2904 strcpy(entry[0], descLen == 0 ? " " : dti.dta[i].d[j].desc.c_str()); 2906 strcpy(entry[0], descLen == 0 ? " " : dti.dta[i].d[j].desc.c_str());
2905 strcpy(entry[1], nameLen == 0 ? " " : dti.dta[i].d[j].name.c_str()); 2907 strcpy(entry[1], nameLen == 0 ? " " : dti.dta[i].d[j].name.c_str());
2906 strcpy(entry[2], pwLen == 0 ? " " : dti.dta[i].d[j].pw.c_str()); 2908 strcpy(entry[2], pwLen == 0 ? " " : dti.dta[i].d[j].pw.c_str());
2907 strcpy(entry[3], commentLen == 0 ? " " : dti.dta[i].d[j].comment.c_str()); 2909 strcpy(entry[3], commentLen == 0 ? " " : dti.dta[i].d[j].comment.c_str());
2908 entry[0][descLen == 0 ? descLen + 1 : descLen] = '\0'; 2910 entry[0][descLen == 0 ? descLen + 1 : descLen] = '\0';
2909 entry[1][nameLen == 0 ? nameLen + 1 : nameLen] = '\0'; 2911 entry[1][nameLen == 0 ? nameLen + 1 : nameLen] = '\0';
2910 entry[2][pwLen == 0 ? pwLen + 1 : pwLen] = '\0'; 2912 entry[2][pwLen == 0 ? pwLen + 1 : pwLen] = '\0';
2911 entry[3][commentLen == 0 ? commentLen + 1 : commentLen] = '\0'; 2913 entry[3][commentLen == 0 ? commentLen + 1 : commentLen] = '\0';
2912 2914
2913 ret = gp.save_entry(entry); 2915 ret = gp.save_entry(entry);
2914 if (ret == -1){ 2916 if (ret == -1){
2915 delete [] entry[0]; 2917 delete [] entry[0];
2916 delete [] entry[1]; 2918 delete [] entry[1];
2917 delete [] entry[2]; 2919 delete [] entry[2];
2918 delete [] entry[3]; 2920 delete [] entry[3];
2919 gp.save_finalize(); 2921 gp.save_finalize();
2920 unlockAll_tempoary(true); 2922 unlockAll_tempoary(true);
2921 return e_writeFile; 2923 return e_writeFile;
2922 } 2924 }
2923 2925
2924 delete [] entry[0]; 2926 delete [] entry[0];
2925 delete [] entry[1]; 2927 delete [] entry[1];
2926 delete [] entry[2]; 2928 delete [] entry[2];
2927 delete [] entry[3]; 2929 delete [] entry[3];
2928 } 2930 }
2929 } 2931 }
2930 unlockAll_tempoary(true); 2932 unlockAll_tempoary(true);
2931 if (gp.save_finalize() == -1) 2933 if (gp.save_finalize() == -1)
2932 return e_writeFile; 2934 return e_writeFile;
2933 2935
2934 return e_success; 2936 return e_success;
2935} 2937}
2936 2938
2937PwMerror PwMDoc::importFromGpasman(const QString *file) 2939PwMerror PwMDoc::importFromGpasman(const QString *file)
2938{ 2940{
2939 PWM_ASSERT(file); 2941 PWM_ASSERT(file);
2940 QString pw = requestMpw(false); 2942 QString pw = requestMpw(false);
2941 if (pw == "") 2943 if (pw == "")
2942 return e_noPw; 2944 return e_noPw;
2943 GpasmanFile gp; 2945 GpasmanFile gp;
2944 int ret, i; 2946 int ret, i;
2945 PwMerror ret2; 2947 PwMerror ret2;
2946 char *entry[4]; 2948 char *entry[4];
2947 PwMDataItem tmpData; 2949 PwMDataItem tmpData;
2948 ret = gp.load_init(file->latin1(), pw.latin1()); 2950 ret = gp.load_init(file->latin1(), pw.latin1());
2949 if (ret != 1) 2951 if (ret != 1)
2950 return e_accessFile; 2952 return e_accessFile;
2951 2953
2952 do { 2954 do {
2953 ret = gp.load_entry(entry); 2955 ret = gp.load_entry(entry);
2954 if(ret != 1) 2956 if(ret != 1)
2955 break; 2957 break;
2956 tmpData.desc = entry[0]; 2958 tmpData.desc = entry[0];
2957 tmpData.name = entry[1]; 2959 tmpData.name = entry[1];
2958 tmpData.pw = entry[2]; 2960 tmpData.pw = entry[2];
2959 tmpData.comment = entry[3]; 2961 tmpData.comment = entry[3];
2960 tmpData.lockStat = true; 2962 tmpData.lockStat = true;
2961 tmpData.listViewPos = -1; 2963 tmpData.listViewPos = -1;
2962 ret2 = addEntry(DEFAULT_CATEGORY, &tmpData, true); 2964 ret2 = addEntry(DEFAULT_CATEGORY, &tmpData, true);
2963 for (i = 0; i < 4; ++i) 2965 for (i = 0; i < 4; ++i)
2964 free(entry[i]); 2966 free(entry[i]);
2965 if (ret2 == e_maxAllowedEntr) { 2967 if (ret2 == e_maxAllowedEntr) {
2966 gp.load_finalize(); 2968 gp.load_finalize();
2967 return e_maxAllowedEntr; 2969 return e_maxAllowedEntr;
2968 } 2970 }
2969 } while (1); 2971 } while (1);
2970 gp.load_finalize(); 2972 gp.load_finalize();
2971 if (isDocEmpty()) 2973 if (isDocEmpty())
2972 return e_wrongPw; // we assume this. 2974 return e_wrongPw; // we assume this.
2973 2975
2974 flagDirty(); 2976 flagDirty();
2975 return e_success; 2977 return e_success;
2976} 2978}
2977 2979
2978 2980
2979//US: we use the stl sort algorythm to sort all elements in the order 2981//US: we use the stl sort algorythm to sort all elements in the order
2980//of its listViewPos (in the order 1,2,3,5,...,x,-1, -1, -1 2982//of its listViewPos (in the order 1,2,3,5,...,x,-1, -1, -1
2981struct PwMDataItemListViewPosSort 2983struct PwMDataItemListViewPosSort
2982{ 2984{
2983 bool operator()(PwMDataItem* rpStart, PwMDataItem* rpEnd) 2985 bool operator()(PwMDataItem* rpStart, PwMDataItem* rpEnd)
2984 { 2986 {
2985 //qDebug("pwMDoc::PwMDataItemListViewPosSort()"); 2987 //qDebug("pwMDoc::PwMDataItemListViewPosSort()");
2986 if ((rpEnd)->listViewPos < 0) 2988 if ((rpEnd)->listViewPos < 0)
2987 return false; 2989 return false;
2988 else 2990 else
2989 return (rpStart)->listViewPos < (rpEnd)->listViewPos; 2991 return (rpStart)->listViewPos < (rpEnd)->listViewPos;
2990 } 2992 }
2991}; 2993};
2992 2994
2993void PwMDoc::ensureLvp() 2995void PwMDoc::ensureLvp()
2994{ 2996{
2995 if (isDocEmpty()) 2997 if (isDocEmpty())
2996 return; 2998 return;
2997 2999
2998 //US ENH BUG: when using syncronizing, this way of sorting 3000 //US ENH BUG: when using syncronizing, this way of sorting
2999 //is not sufficient, because there might be empty spaces 3001 //is not sufficient, because there might be empty spaces
3000 // at the beginning. But the old algorythm only can add elements 3002 // at the beginning. But the old algorythm only can add elements
3001 //to the end.The result are crashes because of list overflows 3003 //to the end.The result are crashes because of list overflows
3002 //we need something to fill all gaps. 3004 //we need something to fill all gaps.
3003 vector<PwMDataItem*> sorted; 3005 vector<PwMDataItem*> sorted;
3004 vector< PwMDataItem*>::iterator sortedBegin, 3006 vector< PwMDataItem*>::iterator sortedBegin,
3005 sortedEnd, 3007 sortedEnd,
3006 sortedI; 3008 sortedI;
3007 vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(), 3009 vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(),
3008 catEnd = dti.dta.end(), 3010 catEnd = dti.dta.end(),
3009 catI = catBegin; 3011 catI = catBegin;
3010 vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; 3012 vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI;
3011 int lvpTop, tmpLvp; 3013 int lvpTop, tmpLvp;
3012 3014
3013 //qDebug("collect:"); 3015 //qDebug("collect:");
3014 3016
3015 while (catI != catEnd) { 3017 while (catI != catEnd) {
3016 lvpTop = -1; 3018 lvpTop = -1;
3017 sorted.clear(); 3019 sorted.clear();
3018 3020
3019 entrBegin = catI->d.begin(); 3021 entrBegin = catI->d.begin();
3020 entrEnd = catI->d.end(); 3022 entrEnd = catI->d.end();
3021 entrI = entrBegin; 3023 entrI = entrBegin;
3022 3024
3023 //US: we use the stl sort algorythm to sort all elements in the order 3025 //US: we use the stl sort algorythm to sort all elements in the order
3024 //of its listViewPos (in the order 1,2,2,3,5,...,x,-1, -1, -1 3026 //of its listViewPos (in the order 1,2,2,3,5,...,x,-1, -1, -1
3025 while (entrI != entrEnd) { 3027 while (entrI != entrEnd) {
3026 //qDebug("found: %s, pos=%i", (*entrI).desc.c_str(), (*entrI).listViewPos); 3028 //qDebug("found: %s, pos=%i", (*entrI).desc.c_str(), (*entrI).listViewPos);
3027 sorted.push_back((PwMDataItem*)&(*entrI)); 3029 sorted.push_back((PwMDataItem*)&(*entrI));
3028 ++entrI; 3030 ++entrI;
3029 } 3031 }
3030 3032
3031 sortedBegin = sorted.begin(); 3033 sortedBegin = sorted.begin();
3032 sortedEnd = sorted.end(); 3034 sortedEnd = sorted.end();
3033 3035
3034 sort(sortedBegin, sortedEnd, PwMDataItemListViewPosSort()); 3036 sort(sortedBegin, sortedEnd, PwMDataItemListViewPosSort());
3035 3037
3036 // qDebug("resort:"); 3038 // qDebug("resort:");
3037 //now we have all sorted in a collection 3039 //now we have all sorted in a collection
3038 //Now start with the sorted and reset listviewpos. 3040 //Now start with the sorted and reset listviewpos.
3039 sortedBegin = sorted.begin(); 3041 sortedBegin = sorted.begin();
3040 sortedEnd = sorted.end(); 3042 sortedEnd = sorted.end();
3041 sortedI = sortedBegin; 3043 sortedI = sortedBegin;
3042 3044
3043 while (sortedI != sortedEnd) { 3045 while (sortedI != sortedEnd) {
3044 // qDebug("reset defined: %s, from pos=%i to pos=%i", (*sortedI)->desc.c_str(), (*sortedI)->listViewPos, lvpTop+1); 3046 // qDebug("reset defined: %s, from pos=%i to pos=%i", (*sortedI)->desc.c_str(), (*sortedI)->listViewPos, lvpTop+1);
3045 (*sortedI)->listViewPos = ++lvpTop; 3047 (*sortedI)->listViewPos = ++lvpTop;
3046 ++sortedI; 3048 ++sortedI;
3047 } 3049 }
3048 3050
3049 /*/debug 3051 /*/debug
3050 entrBegin = catI->d.begin(); 3052 entrBegin = catI->d.begin();
3051 entrEnd = catI->d.end(); 3053 entrEnd = catI->d.end();
3052 entrI = entrBegin; 3054 entrI = entrBegin;
3053 3055
3054 while (entrI != entrEnd) { 3056 while (entrI != entrEnd) {
3055 qDebug("check: %s, pos=%i", (*entrI).desc.c_str(), (*entrI).listViewPos); 3057 qDebug("check: %s, pos=%i", (*entrI).desc.c_str(), (*entrI).listViewPos);
3056 ++entrI; 3058 ++entrI;
3057 } 3059 }
3058 */ 3060 */
3059 3061
3060 ++catI; 3062 ++catI;
3061 } 3063 }
3062} 3064}
3063 3065
3064QString PwMDoc::getTitle() 3066QString PwMDoc::getTitle()
3065{ 3067{
3066 /* NOTE: We have to ensure, that the returned title 3068 /* NOTE: We have to ensure, that the returned title
3067 * is unique and not reused somewhere else while 3069 * is unique and not reused somewhere else while
3068 * this document is valid (open). 3070 * this document is valid (open).
3069 */ 3071 */
3070 QString title(getFilename()); 3072 QString title(getFilename());
3071 3073
3072 //US ENH: The whole filename on PDAs is too long. So use only the last characters 3074 //US ENH: The whole filename on PDAs is too long. So use only the last characters
3073 if (QApplication::desktop()->width() < 640) 3075 if (QApplication::desktop()->width() < 640)
3074 { 3076 {
3075 if (title.length() > 30) 3077 if (title.length() > 30)
3076 title = "..." + title.right(30); 3078 title = "..." + title.right(30);
3077 3079
3078 } 3080 }
3079 3081
3080 3082
3081 if (title.isEmpty()) { 3083 if (title.isEmpty()) {
3082 if (unnamedNum == 0) { 3084 if (unnamedNum == 0) {
3083 unnamedNum = PwMDocList::getNewUnnamedNumber(); 3085 unnamedNum = PwMDocList::getNewUnnamedNumber();
3084 PWM_ASSERT(unnamedNum != 0); 3086 PWM_ASSERT(unnamedNum != 0);
3085 } 3087 }
3086 title = DEFAULT_TITLE; 3088 title = DEFAULT_TITLE;
3087 title += " "; 3089 title += " ";
3088 title += tostr(unnamedNum).c_str(); 3090 title += tostr(unnamedNum).c_str();
3089 } 3091 }
3090 return title; 3092 return title;
3091} 3093}
3092 3094
3093bool PwMDoc::tryDelete() 3095bool PwMDoc::tryDelete()
3094{ 3096{
@@ -3248,387 +3250,387 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s
3248 if ( inRemote->meta.update > mLastSync || mode == 5 ) { 3250 if ( inRemote->meta.update > mLastSync || mode == 5 ) {
3249 inRemote->meta.update = modifiedSync; 3251 inRemote->meta.update = modifiedSync;
3250 3252
3251 //first check if we have a matching category in the local file 3253 //first check if we have a matching category in the local file
3252 const string* remotecat = syncRemote->getCategory(catRemote); 3254 const string* remotecat = syncRemote->getCategory(catRemote);
3253 syncLocal->addEntry(remotecat->c_str(), inRemote, true, false); 3255 syncLocal->addEntry(remotecat->c_str(), inRemote, true, false);
3254 3256
3255 ++addedPasswordsLocal; 3257 ++addedPasswordsLocal;
3256 } else { 3258 } else {
3257 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 3259 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
3258 syncRemote->delEntry(catRemote, indexRemote, true); 3260 syncRemote->delEntry(catRemote, indexRemote, true);
3259 ++deletedPasswordsRemote; 3261 ++deletedPasswordsRemote;
3260 } 3262 }
3261 } 3263 }
3262 3264
3263 ++incCounter; 3265 ++incCounter;
3264 } 3266 }
3265 3267
3266 3268
3267 er.clear(); 3269 er.clear();
3268 QStringList el = syncLocal->getIDEntryList(); 3270 QStringList el = syncLocal->getIDEntryList();
3269 modulo = (el.count()/10)+1; 3271 modulo = (el.count()/10)+1;
3270 3272
3271 manager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 3273 manager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
3272 incCounter = 0; 3274 incCounter = 0;
3273 while ( incCounter < el.count()) { 3275 while ( incCounter < el.count()) {
3274 qApp->processEvents(); 3276 qApp->processEvents();
3275 if (manager->isProgressBarCanceled()) 3277 if (manager->isProgressBarCanceled())
3276 return e_syncError; 3278 return e_syncError;
3277 if ( incCounter % modulo == 0 ) 3279 if ( incCounter % modulo == 0 )
3278 manager->showProgressBar(incCounter); 3280 manager->showProgressBar(incCounter);
3279 uid = el[ incCounter ]; 3281 uid = el[ incCounter ];
3280 qDebug("sync uid %s from local file", uid.latin1()); 3282 qDebug("sync uid %s from local file", uid.latin1());
3281 3283
3282 inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal ); 3284 inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal );
3283 inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote ); 3285 inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote );
3284 PWM_ASSERT(inLocal); 3286 PWM_ASSERT(inLocal);
3285 3287
3286 if ( inRemote == 0 ) { 3288 if ( inRemote == 0 ) {
3287 if ( inLocal->meta.update < mLastSync && mode != 4 ) { 3289 if ( inLocal->meta.update < mLastSync && mode != 4 ) {
3288 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3290 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3289 syncLocal->delEntry(catLocal, indexLocal, true); 3291 syncLocal->delEntry(catLocal, indexLocal, true);
3290 ++deletedPasswordsLocal; 3292 ++deletedPasswordsLocal;
3291 } else { 3293 } else {
3292 if ( ! manager->mWriteBackExistingOnly ) { 3294 if ( ! manager->mWriteBackExistingOnly ) {
3293 ++addedPasswordsRemote; 3295 ++addedPasswordsRemote;
3294 inLocal->meta.update = modifiedSync; 3296 inLocal->meta.update = modifiedSync;
3295 3297
3296 //first check if we have a matching category in the remote file 3298 //first check if we have a matching category in the remote file
3297 const string* localcat = syncLocal->getCategory(catLocal); 3299 const string* localcat = syncLocal->getCategory(catLocal);
3298 3300
3299 PwMDataItem newEntry; 3301 PwMDataItem newEntry;
3300 newEntry = *inLocal; 3302 newEntry = *inLocal;
3301 inRemote = &newEntry; 3303 inRemote = &newEntry;
3302 3304
3303 //USsyncRemote->insertAddressee( inRemote, false ); 3305 //USsyncRemote->insertAddressee( inRemote, false );
3304 syncRemote->addEntry(localcat->c_str(), inRemote, true, false); 3306 syncRemote->addEntry(localcat->c_str(), inRemote, true, false);
3305 3307
3306 } 3308 }
3307 } 3309 }
3308 3310
3309 } 3311 }
3310 ++incCounter; 3312 ++incCounter;
3311 } 3313 }
3312 el.clear(); 3314 el.clear();
3313 manager->hideProgressBar(); 3315 manager->hideProgressBar();
3314 3316
3315 // Now write the info back into the sync data space of the files 3317 // Now write the info back into the sync data space of the files
3316 3318
3317 mLastSync = QDateTime::currentDateTime().addSecs( 1 ); 3319 mLastSync = QDateTime::currentDateTime().addSecs( 1 );
3318 // get rid of micro seconds 3320 // get rid of micro seconds
3319 QTime t = mLastSync.time(); 3321 QTime t = mLastSync.time();
3320 mLastSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 3322 mLastSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
3321 3323
3322 3324
3323 syncItemLocal->lastSyncDate = mLastSync; 3325 syncItemLocal->lastSyncDate = mLastSync;
3324 syncItemRemote->lastSyncDate = mLastSync; 3326 syncItemRemote->lastSyncDate = mLastSync;
3325 3327
3326 QString mes; 3328 QString mes;
3327 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedPasswordsLocal, addedPasswordsRemote, changedLocal, changedRemote, deletedPasswordsLocal, deletedPasswordsRemote ); 3329 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedPasswordsLocal, addedPasswordsRemote, changedLocal, changedRemote, deletedPasswordsLocal, deletedPasswordsRemote );
3328 if ( manager->mShowSyncSummary ) { 3330 if ( manager->mShowSyncSummary ) {
3329 KMessageBox::information(0, mes, i18n("PWM/Pi Synchronization") ); 3331 KMessageBox::information(0, mes, i18n("PWM/Pi Synchronization") );
3330 } 3332 }
3331 qDebug( mes ); 3333 qDebug( mes );
3332 return e_success; 3334 return e_success;
3333} 3335}
3334 3336
3335 3337
3336int PwMDoc::takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime lastSync, int mode , bool full ) 3338int PwMDoc::takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime lastSync, int mode , bool full )
3337{ 3339{
3338 // 0 equal 3340 // 0 equal
3339 // 1 take local 3341 // 1 take local
3340 // 2 take remote 3342 // 2 take remote
3341 // 3 cancel 3343 // 3 cancel
3342 QDateTime localMod = local->meta.update; 3344 QDateTime localMod = local->meta.update;
3343 QDateTime remoteMod = remote->meta.update; 3345 QDateTime remoteMod = remote->meta.update;
3344 3346
3345 if ( localMod == remoteMod ) 3347 if ( localMod == remoteMod )
3346 return 0; 3348 return 0;
3347 3349
3348 qDebug(" %d %d conflict on %s %s ", mode, full, local->desc.c_str(), remote->desc.c_str() ); 3350 qDebug(" %d %d conflict on %s %s ", mode, full, local->desc.c_str(), remote->desc.c_str() );
3349 3351
3350 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); 3352 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod);
3351 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 3353 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
3352 //full = true; //debug only 3354 //full = true; //debug only
3353 if ( full ) { 3355 if ( full ) {
3354 bool equ = ( (*local) == (*remote) ); 3356 bool equ = ( (*local) == (*remote) );
3355 if ( equ ) { 3357 if ( equ ) {
3356 //qDebug("equal "); 3358 //qDebug("equal ");
3357 if ( mode < SYNC_PREF_FORCE_LOCAL ) 3359 if ( mode < SYNC_PREF_FORCE_LOCAL )
3358 return 0; 3360 return 0;
3359 3361
3360 }//else //debug only 3362 }//else //debug only
3361 //qDebug("not equal %s %s ", local->desc.c_str(), remote->desc.c_str()); 3363 //qDebug("not equal %s %s ", local->desc.c_str(), remote->desc.c_str());
3362 } 3364 }
3363 3365
3364 int result; 3366 int result;
3365 bool localIsNew; 3367 bool localIsNew;
3366 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); 3368 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
3367 3369
3368 if ( full && mode < SYNC_PREF_NEWEST ) 3370 if ( full && mode < SYNC_PREF_NEWEST )
3369 mode = SYNC_PREF_ASK; 3371 mode = SYNC_PREF_ASK;
3370 3372
3371 switch( mode ) { 3373 switch( mode ) {
3372 case SYNC_PREF_LOCAL: 3374 case SYNC_PREF_LOCAL:
3373 if ( lastSync > remoteMod ) 3375 if ( lastSync > remoteMod )
3374 return 1; 3376 return 1;
3375 if ( lastSync > localMod ) 3377 if ( lastSync > localMod )
3376 return 2; 3378 return 2;
3377 return 1; 3379 return 1;
3378 break; 3380 break;
3379 case SYNC_PREF_REMOTE: 3381 case SYNC_PREF_REMOTE:
3380 if ( lastSync > remoteMod ) 3382 if ( lastSync > remoteMod )
3381 return 1; 3383 return 1;
3382 if ( lastSync > localMod ) 3384 if ( lastSync > localMod )
3383 return 2; 3385 return 2;
3384 return 2; 3386 return 2;
3385 break; 3387 break;
3386 case SYNC_PREF_NEWEST: 3388 case SYNC_PREF_NEWEST:
3387 if ( localMod > remoteMod ) 3389 if ( localMod > remoteMod )
3388 return 1; 3390 return 1;
3389 else 3391 else
3390 return 2; 3392 return 2;
3391 break; 3393 break;
3392 case SYNC_PREF_ASK: 3394 case SYNC_PREF_ASK:
3393 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 3395 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
3394 if ( lastSync > remoteMod ) 3396 if ( lastSync > remoteMod )
3395 return 1; 3397 return 1;
3396 if ( lastSync > localMod ) 3398 if ( lastSync > localMod )
3397 return 2; 3399 return 2;
3398 localIsNew = localMod >= remoteMod; 3400 localIsNew = localMod >= remoteMod;
3399 //qDebug("conflict! ************************************** "); 3401 //qDebug("conflict! ************************************** ");
3400 { 3402 {
3401 PwMDataItemChooser acd ( *local,*remote, localIsNew , 0/*this*/ ); 3403 PwMDataItemChooser acd ( *local,*remote, localIsNew , 0/*this*/ );
3402 result = acd.executeD(localIsNew); 3404 result = acd.executeD(localIsNew);
3403 return result; 3405 return result;
3404 } 3406 }
3405 break; 3407 break;
3406 case SYNC_PREF_FORCE_LOCAL: 3408 case SYNC_PREF_FORCE_LOCAL:
3407 return 1; 3409 return 1;
3408 break; 3410 break;
3409 case SYNC_PREF_FORCE_REMOTE: 3411 case SYNC_PREF_FORCE_REMOTE:
3410 return 2; 3412 return 2;
3411 break; 3413 break;
3412 3414
3413 default: 3415 default:
3414 // SYNC_PREF_TAKE_BOTH not implemented 3416 // SYNC_PREF_TAKE_BOTH not implemented
3415 break; 3417 break;
3416 } 3418 }
3417 return 0; 3419 return 0;
3418} 3420}
3419 3421
3420void PwMDoc::removeSyncInfo( QString syncProfile) 3422void PwMDoc::removeSyncInfo( QString syncProfile)
3421{ 3423{
3422 bool res, found; 3424 bool res, found;
3423 unsigned int count, i; 3425 unsigned int count, i;
3424 if ( syncProfile.isEmpty() ) { 3426 if ( syncProfile.isEmpty() ) {
3425 count = numSyncDataEntries(); 3427 count = numSyncDataEntries();
3426 for (i = count; count > 0; count-- ) { 3428 for (i = count; count > 0; count-- ) {
3427 res = delSyncDataEntry(i-1, false); 3429 res = delSyncDataEntry(i-1, false);
3428 if (res == false) { 3430 if (res == false) {
3429 qDebug("PwMDoc::removeSyncInfo: could not remove syncprofile"); 3431 qDebug("PwMDoc::removeSyncInfo: could not remove syncprofile");
3430 } 3432 }
3431 } 3433 }
3432 } else { 3434 } else {
3433 found = findSyncData(syncProfile, &count); 3435 found = findSyncData(syncProfile, &count);
3434 if (found == true) 3436 if (found == true)
3435 { 3437 {
3436 res = delSyncDataEntry(count, false); 3438 res = delSyncDataEntry(count, false);
3437 if (res == false) { 3439 if (res == false) {
3438 qDebug("PwMDoc::removeSyncInfo: could not remove %s", syncProfile.latin1()); 3440 qDebug("PwMDoc::removeSyncInfo: could not remove %s", syncProfile.latin1());
3439 3441
3440 } 3442 }
3441 } 3443 }
3442 } 3444 }
3443} 3445}
3444 3446
3445 3447
3446//this are the overwritten callbackmethods from the syncinterface 3448//this are the overwritten callbackmethods from the syncinterface
3447bool PwMDoc::sync(KSyncManager* manager, QString filename, int mode, QString resource) 3449bool PwMDoc::sync(KSyncManager* manager, QString filename, int mode, QString resource)
3448{ 3450{
3449 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3451 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3450 3452
3451 //1) unlock local file first if necessary (ask for password) 3453 //1) unlock local file first if necessary (ask for password)
3452 if (this->isDeepLocked()) { 3454 if (this->isDeepLocked()) {
3453 PwMerror ret = this->deepLock(false); 3455 PwMerror ret = this->deepLock(false);
3454 if (ret != e_success) 3456 if (ret != e_success)
3455 return false; 3457 return false;
3456 } 3458 }
3457 3459
3458 //2) construct and open a new doc on the stack(automatic cleanup of remote file). 3460 //2) construct and open a new doc on the stack(automatic cleanup of remote file).
3459 PwMDoc syncTarget(this, "synctarget"); 3461 PwMDoc syncTarget(this, "synctarget");
3460 PwMDoc* pSyncTarget = &syncTarget; 3462 PwMDoc* pSyncTarget = &syncTarget;
3461 3463
3462 3464
3463 PwMerror err = pSyncTarget->openDoc(&filename, 1 /*== open with all entries locked*/); 3465 PwMerror err = pSyncTarget->openDoc(&filename, 1 /*== open with all entries locked*/);
3464 3466
3465 if (err == e_alreadyOpen) { 3467 if (err == e_alreadyOpen) {
3466 PwMDocList::listItem li; 3468 PwMDocList::listItem li;
3467 if (getOpenDocList()->find(filename.latin1(), &li)) 3469 if (getOpenDocList()->find(filename.latin1(), &li))
3468 pSyncTarget = li.doc; 3470 pSyncTarget = li.doc;
3469 else { 3471 else {
3470 qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1()); 3472 qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1());
3471 return false; 3473 return false;
3472 } 3474 }
3473 } 3475 }
3474 else if (err != e_success) { 3476 else if (err != e_success) {
3475 qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1()); 3477 qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1());
3476 return false; 3478 return false;
3477 } 3479 }
3478 3480
3479 qDebug("PWM file loaded %s,sync mode %d",filename.latin1(), mode ); 3481 qDebug("PWM file loaded %s,sync mode %d",filename.latin1(), mode );
3480 3482
3481 3483
3482 //3) unlock remote file first if necessary (ask for password) 3484 //3) unlock remote file first if necessary (ask for password)
3483 if (pSyncTarget->isDeepLocked()) { 3485 if (pSyncTarget->isDeepLocked()) {
3484 PwMerror ret = pSyncTarget->deepLock(false); 3486 PwMerror ret = pSyncTarget->deepLock(false);
3485 if (ret != e_success) 3487 if (ret != e_success)
3486 return false; 3488 return false;
3487 } 3489 }
3488 3490
3489 3491
3490 err = syncronize(manager, this, pSyncTarget, mode ); 3492 err = syncronize(manager, this, pSyncTarget, mode );
3491 3493
3492 if (err == e_success) { 3494 if (err == e_success) {
3493 if ( manager->mWriteBackFile ){ 3495 if ( manager->mWriteBackFile ){
3494 qDebug("Saving remote PWManager file"); 3496 qDebug("Saving remote PWManager file");
3495 err = pSyncTarget->saveDoc(conf()->confGlobCompression()); 3497 err = pSyncTarget->saveDoc(conf()->confGlobCompression());
3496 if (err != e_success) { 3498 if (err != e_success) {
3497 qDebug("PwmDoc::sync: Sync failed. Error %i while storing file %s",err, filename.latin1()); 3499 qDebug("PwmDoc::sync: Sync failed. Error %i while storing file %s",err, filename.latin1());
3498 return false; 3500 return false;
3499 } 3501 }
3500 } 3502 }
3501 3503
3502 flagDirty(); 3504 flagDirty();
3503 return true; 3505 return true;
3504 } 3506 }
3505 else { 3507 else {
3506 return false; 3508 return false;
3507 } 3509 }
3508} 3510}
3509 3511
3510#endif 3512#endif
3511 3513
3512 3514
3513bool PwMDoc::findSyncData(const QString &syncname, unsigned int *index) 3515bool PwMDoc::findSyncData(const QString &syncname, unsigned int *index)
3514{ 3516{
3515 vector<PwMSyncItem>::iterator i = dti.syncDta.begin(), 3517 vector<PwMSyncItem>::iterator i = dti.syncDta.begin(),
3516 end = dti.syncDta.end(); 3518 end = dti.syncDta.end();
3517 3519
3518 while (i != end) { 3520 while (i != end) {
3519 if ((*i).syncName == syncname.latin1()) { 3521 if ((*i).syncName == syncname.latin1()) {
3520 if (index) { 3522 if (index) {
3521 *index = i - dti.syncDta.begin(); 3523 *index = i - dti.syncDta.begin();
3522 } 3524 }
3523 return true; 3525 return true;
3524 } 3526 }
3525 ++i; 3527 ++i;
3526 } 3528 }
3527 return false; 3529 return false;
3528}; 3530};
3529 3531
3530/** add new syncdataentry */ 3532/** add new syncdataentry */
3531PwMerror PwMDoc::addSyncDataEntry(PwMSyncItem *d, bool dontFlagDirty) 3533PwMerror PwMDoc::addSyncDataEntry(PwMSyncItem *d, bool dontFlagDirty)
3532{ 3534{
3533 PWM_ASSERT(d); 3535 PWM_ASSERT(d);
3534 3536
3535 if (isDeepLocked()) { 3537 if (isDeepLocked()) {
3536 PwMerror ret; 3538 PwMerror ret;
3537 ret = deepLock(false); 3539 ret = deepLock(false);
3538 if (ret != e_success) 3540 if (ret != e_success)
3539 return e_lock; 3541 return e_lock;
3540 } 3542 }
3541 unsigned int index; 3543 unsigned int index;
3542 3544
3543 const QString tmp = d->syncName.c_str(); 3545 const QString tmp = d->syncName.c_str();
3544 bool exists = findSyncData(d->syncName.c_str(), &index); 3546 bool exists = findSyncData(d->syncName.c_str(), &index);
3545 3547
3546 if (exists == true) { 3548 if (exists == true) {
3547 // DOH! We found this entry. 3549 // DOH! We found this entry.
3548 return e_entryExists; 3550 return e_entryExists;
3549 } 3551 }
3550 3552
3551 dti.syncDta.push_back(*d); 3553 dti.syncDta.push_back(*d);
3552 3554
3553 if (!dontFlagDirty) 3555 if (!dontFlagDirty)
3554 flagDirty(); 3556 flagDirty();
3555 return e_success; 3557 return e_success;
3556} 3558}
3557 3559
3558 3560
3559 3561
3560/** delete syncdata entry */ 3562/** delete syncdata entry */
3561bool PwMDoc::delSyncDataEntry(unsigned int index, bool dontFlagDirty) 3563bool PwMDoc::delSyncDataEntry(unsigned int index, bool dontFlagDirty)
3562{ 3564{
3563 if (isDeepLocked()) 3565 if (isDeepLocked())
3564 return false; 3566 return false;
3565 if (index > dti.syncDta.size() - 1) 3567 if (index > dti.syncDta.size() - 1)
3566 return false; 3568 return false;
3567 3569
3568 // delete entry 3570 // delete entry
3569 dti.syncDta.erase(dti.syncDta.begin() + index); 3571 dti.syncDta.erase(dti.syncDta.begin() + index);
3570 3572
3571 if (!dontFlagDirty) 3573 if (!dontFlagDirty)
3572 flagDirty(); 3574 flagDirty();
3573 return true; 3575 return true;
3574} 3576}
3575 3577
3576 3578
3577PwMDataItem* PwMDoc::findEntryByID(const QString &uid, unsigned int *category, unsigned int *index) 3579PwMDataItem* PwMDoc::findEntryByID(const QString &uid, unsigned int *category, unsigned int *index)
3578{ 3580{
3579 vector<PwMCategoryItem>::iterator catcounter = dti.dta.begin(), 3581 vector<PwMCategoryItem>::iterator catcounter = dti.dta.begin(),
3580 catend = dti.dta.end(); 3582 catend = dti.dta.end();
3581 3583
3582 vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; 3584 vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI;
3583 3585
3584 while (catcounter != catend) { 3586 while (catcounter != catend) {
3585 entrBegin = catcounter->d.begin(); 3587 entrBegin = catcounter->d.begin();
3586 entrEnd = catcounter->d.end(); 3588 entrEnd = catcounter->d.end();
3587 entrI = entrBegin; 3589 entrI = entrBegin;
3588 while (entrI != entrEnd) { 3590 while (entrI != entrEnd) {
3589 if ((*entrI).meta.uniqueid == uid.latin1()) { 3591 if ((*entrI).meta.uniqueid == uid.latin1()) {
3590 if (category) 3592 if (category)
3591 *category = catcounter - dti.dta.begin(); 3593 *category = catcounter - dti.dta.begin();
3592 if (index) 3594 if (index)
3593 *index = entrI - entrBegin; 3595 *index = entrI - entrBegin;
3594 3596
3595 return &(*entrI); 3597 return &(*entrI);
3596 } 3598 }
3597 ++entrI; 3599 ++entrI;
3598 } 3600 }
3599 ++catcounter; 3601 ++catcounter;
3600 } 3602 }
3601 3603
3602 return 0; 3604 return 0;
3603} 3605}
3604 3606
3605QStringList PwMDoc::getIDEntryList() 3607QStringList PwMDoc::getIDEntryList()
3606{ 3608{
3607 QStringList results; 3609 QStringList results;
3608 3610
3609 vector<PwMCategoryItem>::iterator catcounter = dti.dta.begin(), 3611 vector<PwMCategoryItem>::iterator catcounter = dti.dta.begin(),
3610 catend = dti.dta.end(); 3612 catend = dti.dta.end();
3611 3613
3612 vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; 3614 vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI;
3613 3615
3614 while (catcounter != catend) { 3616 while (catcounter != catend) {
3615 entrBegin = catcounter->d.begin(); 3617 entrBegin = catcounter->d.begin();
3616 entrEnd = catcounter->d.end(); 3618 entrEnd = catcounter->d.end();
3617 entrI = entrBegin; 3619 entrI = entrBegin;
3618 while (entrI != entrEnd) { 3620 while (entrI != entrEnd) {
3619 results.append( (*entrI).meta.uniqueid.c_str() ); 3621 results.append( (*entrI).meta.uniqueid.c_str() );
3620 ++entrI; 3622 ++entrI;
3621 } 3623 }
3622 ++catcounter; 3624 ++catcounter;
3623 } 3625 }
3624 3626
3625 return results; 3627 return results;
3626} 3628}
3627 3629
3628 3630
3629 3631
3630 3632
3631 3633
3632#ifndef PWM_EMBEDDED 3634#ifndef PWM_EMBEDDED_
3633#include "pwmdoc.moc" 3635#include "moc_pwmdoc.cpp"
3634#endif 3636#endif
diff --git a/pwmanager/pwmanager/pwmdoc.h b/pwmanager/pwmanager/pwmdoc.h
index 144831f..07c97a9 100644
--- a/pwmanager/pwmanager/pwmdoc.h
+++ b/pwmanager/pwmanager/pwmdoc.h
@@ -1,614 +1,614 @@
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.1 of pwmanager 14 * This file is originaly based on version 1.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 __PWMDOC_H 20#ifndef __PWMDOC_H
21#define __PWMDOC_H 21#define __PWMDOC_H
22#ifdef _WIN32_ 22#ifdef _WIN32_
23#define ssize_t unsigned int 23#define ssize_t unsigned int
24#endif 24#endif
25 #define PWM_FILE_VER (static_cast<char>(0x05)) 25 #define PWM_FILE_VER (static_cast<char>(0x05))
26 26
27 #define PWM_HASH_SHA1 (static_cast<char>(0x01)) 27 #define PWM_HASH_SHA1 (static_cast<char>(0x01))
28 #define PWM_HASH_SHA256 (static_cast<char>(0x02)) 28 #define PWM_HASH_SHA256 (static_cast<char>(0x02))
29 #define PWM_HASH_SHA384 (static_cast<char>(0x03)) 29 #define PWM_HASH_SHA384 (static_cast<char>(0x03))
30 #define PWM_HASH_SHA512 (static_cast<char>(0x04)) 30 #define PWM_HASH_SHA512 (static_cast<char>(0x04))
31 #define PWM_HASH_MD5 (static_cast<char>(0x05)) 31 #define PWM_HASH_MD5 (static_cast<char>(0x05))
32 #define PWM_HASH_RMD160 (static_cast<char>(0x06)) 32 #define PWM_HASH_RMD160 (static_cast<char>(0x06))
33 #define PWM_HASH_TIGER (static_cast<char>(0x07)) 33 #define PWM_HASH_TIGER (static_cast<char>(0x07))
34 34
35 #define PWM_CRYPT_BLOWFISH(static_cast<char>(0x01)) 35 #define PWM_CRYPT_BLOWFISH(static_cast<char>(0x01))
36 #define PWM_CRYPT_AES128(static_cast<char>(0x02)) 36 #define PWM_CRYPT_AES128(static_cast<char>(0x02))
37 #define PWM_CRYPT_AES192(static_cast<char>(0x03)) 37 #define PWM_CRYPT_AES192(static_cast<char>(0x03))
38 #define PWM_CRYPT_AES256(static_cast<char>(0x04)) 38 #define PWM_CRYPT_AES256(static_cast<char>(0x04))
39 #define PWM_CRYPT_3DES (static_cast<char>(0x05)) 39 #define PWM_CRYPT_3DES (static_cast<char>(0x05))
40 #define PWM_CRYPT_TWOFISH(static_cast<char>(0x06)) 40 #define PWM_CRYPT_TWOFISH(static_cast<char>(0x06))
41 #define PWM_CRYPT_TWOFISH128(static_cast<char>(0x07)) 41 #define PWM_CRYPT_TWOFISH128(static_cast<char>(0x07))
42 42
43 #define PWM_COMPRESS_NONE(static_cast<char>(0x00)) 43 #define PWM_COMPRESS_NONE(static_cast<char>(0x00))
44 #define PWM_COMPRESS_GZIP(static_cast<char>(0x01)) 44 #define PWM_COMPRESS_GZIP(static_cast<char>(0x01))
45 #define PWM_COMPRESS_BZIP2(static_cast<char>(0x02)) 45 #define PWM_COMPRESS_BZIP2(static_cast<char>(0x02))
46 46
47 #define DEFAULT_MAX_ENTRIES(~(static_cast<unsigned int>(0))) 47 #define DEFAULT_MAX_ENTRIES(~(static_cast<unsigned int>(0)))
48 #define FILE_ID_HEADER "PWM_PASSWORD_FILE" 48 #define FILE_ID_HEADER "PWM_PASSWORD_FILE"
49 49
50 50
51#include "pwmexception.h" 51#include "pwmexception.h"
52#include "pwmdocui.h" 52#include "pwmdocui.h"
53 53
54#include <qobject.h> 54#include <qobject.h>
55#include <qtimer.h> 55#include <qtimer.h>
56#include <qdatetime.h> 56#include <qdatetime.h>
57 57
58#include <kprocess.h> 58#include <kprocess.h>
59 59
60#ifndef PWM_EMBEDDED 60#ifndef PWM_EMBEDDED
61#include "configuration.h" 61#include "configuration.h"
62#else 62#else
63#include <kapplication.h> 63#include <kapplication.h>
64#include <ksyncmanager.h> 64#include <ksyncmanager.h>
65#endif 65#endif
66 66
67#include <string> 67#include <string>
68#include <vector> 68#include <vector>
69#include <utility> 69#include <utility>
70 70
71using std::vector; 71using std::vector;
72using std::string; 72using std::string;
73using std::pair; 73using std::pair;
74 74
75/* used in findEntry() function */ 75/* used in findEntry() function */
76 #define SEARCH_IN_DESC (1) 76 #define SEARCH_IN_DESC (1)
77 #define SEARCH_IN_NAME (1 << 1) 77 #define SEARCH_IN_NAME (1 << 1)
78 #define SEARCH_IN_PW (1 << 2) 78 #define SEARCH_IN_PW (1 << 2)
79 #define SEARCH_IN_COMMENT(1 << 3) 79 #define SEARCH_IN_COMMENT(1 << 3)
80 #define SEARCH_IN_URL (1 << 4) 80 #define SEARCH_IN_URL (1 << 4)
81 #define SEARCH_IN_LAUNCHER(1 << 5) 81 #define SEARCH_IN_LAUNCHER(1 << 5)
82 #define SEARCH_IN_ALL (SEARCH_IN_DESC | SEARCH_IN_NAME| \ 82 #define SEARCH_IN_ALL (SEARCH_IN_DESC | SEARCH_IN_NAME| \
83 SEARCH_IN_PW | SEARCH_IN_COMMENT| \ 83 SEARCH_IN_PW | SEARCH_IN_COMMENT| \
84 SEARCH_IN_URL| SEARCH_IN_LAUNCHER) 84 SEARCH_IN_URL| SEARCH_IN_LAUNCHER)
85 85
86/** document deeplocked. Data is out for lunch to disk */ 86/** document deeplocked. Data is out for lunch to disk */
87 #define DOC_STAT_DEEPLOCKED (1) 87 #define DOC_STAT_DEEPLOCKED (1)
88/** encrypted document on disk is dirty. data has to go to disk. */ 88/** encrypted document on disk is dirty. data has to go to disk. */
89 #define DOC_STAT_DISK_DIRTY (1 << 1) 89 #define DOC_STAT_DISK_DIRTY (1 << 1)
90/** we are using a chipcard to encrypt the data */ 90/** we are using a chipcard to encrypt the data */
91 #define DOC_STAT_USE_CHIPCARD (1 << 2) 91 #define DOC_STAT_USE_CHIPCARD (1 << 2)
92/** use "currentPw" to unlock. (This flag is set/unset by a timer) */ 92/** use "currentPw" to unlock. (This flag is set/unset by a timer) */
93 #define DOC_STAT_UNLOCK_WITHOUT_PW(1 << 3) 93 #define DOC_STAT_UNLOCK_WITHOUT_PW(1 << 3)
94 94
95class PwMDoc; 95class PwMDoc;
96class PwMView; 96class PwMView;
97class QFile; 97class QFile;
98 98
99/* meta data for a PwMDataItem */ 99/* meta data for a PwMDataItem */
100struct PwMMetaData 100struct PwMMetaData
101{ 101{
102 PwMMetaData() 102 PwMMetaData()
103 : updateInt (0) 103 : updateInt (0)
104 { } 104 { }
105 /** creation date of the PwMDataItem to which 105 /** creation date of the PwMDataItem to which
106 * this meta data belongs. 106 * this meta data belongs.
107 */ 107 */
108 QDateTimecreate; 108 QDateTimecreate;
109 /** becomes valid on this date */ 109 /** becomes valid on this date */
110 QDateTimevalid; 110 QDateTimevalid;
111 /** expire date */ 111 /** expire date */
112 QDateTimeexpire; 112 QDateTimeexpire;
113 /** update date (last updated at this date) */ 113 /** update date (last updated at this date) */
114 QDateTimeupdate; 114 QDateTimeupdate;
115 /** update interval (in minutes). Time since the 115 /** update interval (in minutes). Time since the
116 * last update to remind the user to update the item. 116 * last update to remind the user to update the item.
117 * 0 disables. 117 * 0 disables.
118 */ 118 */
119 unsigned long updateInt; 119 unsigned long updateInt;
120 120
121 //US ENH: enhancements of the filestructure 121 //US ENH: enhancements of the filestructure
122 /* each entry gets a unique id assigned */ 122 /* each entry gets a unique id assigned */
123 string uniqueid; 123 string uniqueid;
124 124
125 125
126 void clear() 126 void clear()
127 { 127 {
128 create = QDateTime(); 128 create = QDateTime();
129 expire = QDateTime(); 129 expire = QDateTime();
130 update = QDateTime(); 130 update = QDateTime();
131 updateInt = 0; 131 updateInt = 0;
132 uniqueid = KApplication::randomString(8).latin1(); 132 uniqueid = KApplication::randomString(8).latin1();
133 } 133 }
134 134
135 inline bool isValid() const 135 inline bool isValid() const
136 { 136 {
137 if (valid.isNull()) 137 if (valid.isNull())
138 return true; 138 return true;
139 return (valid < QDateTime::currentDateTime()); 139 return (valid < QDateTime::currentDateTime());
140 } 140 }
141 inline bool isExpired() const 141 inline bool isExpired() const
142 { 142 {
143 if (expire.isNull()) 143 if (expire.isNull())
144 return false; 144 return false;
145 return (expire < QDateTime::currentDateTime()); 145 return (expire < QDateTime::currentDateTime());
146 } 146 }
147 inline bool isUpdateIntOver() const 147 inline bool isUpdateIntOver() const
148 { 148 {
149 if (updateInt == 0 || 149 if (updateInt == 0 ||
150 update.isNull()) 150 update.isNull())
151 return false; 151 return false;
152 QDateTime d(update); 152 QDateTime d(update);
153 return (d.addSecs(updateInt * 60) < QDateTime::currentDateTime()); 153 return (d.addSecs(updateInt * 60) < QDateTime::currentDateTime());
154 } 154 }
155}; 155};
156 156
157struct PwMDataItem 157struct PwMDataItem
158{ 158{
159 PwMDataItem() 159 PwMDataItem()
160 : lockStat (true) 160 : lockStat (true)
161 , listViewPos (-1) 161 , listViewPos (-1)
162 , binary (false) 162 , binary (false)
163 , rev (0) 163 , rev (0)
164 { } 164 { }
165 165
166 /** password description */ 166 /** password description */
167 stringdesc; 167 stringdesc;
168 /** user-name */ 168 /** user-name */
169 stringname; 169 stringname;
170 /** the password itself */ 170 /** the password itself */
171 stringpw; 171 stringpw;
172 /** some comment */ 172 /** some comment */
173 stringcomment; 173 stringcomment;
174 /** an URL string */ 174 /** an URL string */
175 stringurl; 175 stringurl;
176 /** launcher. Can be executed as a system() command */ 176 /** launcher. Can be executed as a system() command */
177 stringlauncher; 177 stringlauncher;
178 /** locking status. If locked (true), pw is not emitted through getEntry() */ 178 /** locking status. If locked (true), pw is not emitted through getEntry() */
179 boollockStat; 179 boollockStat;
180 /** position of this item in main "list-view" 180 /** position of this item in main "list-view"
181 * If -1, the position is not yet specified and should be appended to the list 181 * If -1, the position is not yet specified and should be appended to the list
182 */ 182 */
183 intlistViewPos; 183 intlistViewPos;
184 /** does this entry contain binary data? */ 184 /** does this entry contain binary data? */
185 bool binary; 185 bool binary;
186 /** meta data for this data item. */ 186 /** meta data for this data item. */
187 PwMMetaData meta; 187 PwMMetaData meta;
188 /** data revision counter. This counter can be used 188 /** data revision counter. This counter can be used
189 * to easily, efficiently determine if this data item 189 * to easily, efficiently determine if this data item
190 * has changed since some time. 190 * has changed since some time.
191 * This counter is incremented on every update. 191 * This counter is incremented on every update.
192 */ 192 */
193 unsigned int rev; 193 unsigned int rev;
194 194
195 void clear(bool clearMeta = true) 195 void clear(bool clearMeta = true)
196 { 196 {
197 /* NOTE: Don't use .clear() here to be 197 /* NOTE: Don't use .clear() here to be
198 * backward compatible with gcc-2 (Debian Woody) 198 * backward compatible with gcc-2 (Debian Woody)
199 */ 199 */
200 desc = ""; 200 desc = "";
201 name = ""; 201 name = "";
202 pw = ""; 202 pw = "";
203 comment = ""; 203 comment = "";
204 url = ""; 204 url = "";
205 launcher = ""; 205 launcher = "";
206 lockStat = true; 206 lockStat = true;
207 listViewPos = -1; 207 listViewPos = -1;
208 binary = false; 208 binary = false;
209 if (clearMeta) 209 if (clearMeta)
210 meta.clear(); 210 meta.clear();
211 } 211 }
212 //US ENH: we need this operator to compare two items if we have no unique ids 212 //US ENH: we need this operator to compare two items if we have no unique ids
213 //available. Generaly this happens before the first sync 213 //available. Generaly this happens before the first sync
214 214
215 bool PwMDataItem::operator==( const PwMDataItem &a ) const 215 bool operator==( const PwMDataItem &a ) const
216 { 216 {
217 //qDebug("oper==%s", a.desc.c_str()); 217 //qDebug("oper==%s", a.desc.c_str());
218 if ( desc != a.desc ) return false; 218 if ( desc != a.desc ) return false;
219 if ( name != a.name ) return false; 219 if ( name != a.name ) return false;
220 if ( pw != a.pw ) return false; 220 if ( pw != a.pw ) return false;
221 if ( comment != a.comment ) return false; 221 if ( comment != a.comment ) return false;
222 if ( url != a.url ) return false; 222 if ( url != a.url ) return false;
223 if ( launcher != a.launcher ) return false; 223 if ( launcher != a.launcher ) return false;
224 //all other field will not be checked. 224 //all other field will not be checked.
225 return true; 225 return true;
226 } 226 }
227 227
228 //US ENH: this sync method actually copies all values from the parameter like the =operator 228 //US ENH: this sync method actually copies all values from the parameter like the =operator
229 //does with two exceptions: listViewPos will not be changed, and the launcher only if required. 229 //does with two exceptions: listViewPos will not be changed, and the launcher only if required.
230 bool PwMDataItem::syncItem(const PwMDataItem &a, bool syncLauncher=true ) 230 bool syncItem(const PwMDataItem &a, bool syncLauncher=true )
231 { 231 {
232 desc = a.desc; 232 desc = a.desc;
233 name = a.name; 233 name = a.name;
234 pw = a.pw; 234 pw = a.pw;
235 comment = a.comment; 235 comment = a.comment;
236 url = a.url; 236 url = a.url;
237 if (syncLauncher == true) 237 if (syncLauncher == true)
238 launcher = a.launcher; 238 launcher = a.launcher;
239 meta = a.meta; 239 meta = a.meta;
240 binary = a.binary; 240 binary = a.binary;
241 lockStat = a.lockStat; 241 lockStat = a.lockStat;
242 rev = a.rev; 242 rev = a.rev;
243 243
244 return true; 244 return true;
245 } 245 }
246 246
247}; 247};
248 248
249struct PwMCategoryItem 249struct PwMCategoryItem
250{ 250{
251 /** all PwMDataItems (all passwords) within this category */ 251 /** all PwMDataItems (all passwords) within this category */
252 vector<PwMDataItem>d; 252 vector<PwMDataItem>d;
253 /** category name/description */ 253 /** category name/description */
254 string name; 254 string name;
255 255
256 //US ENH: enhancements of the filestructure 256 //US ENH: enhancements of the filestructure
257 /* each category stores the text for description,name and password */ 257 /* each category stores the text for description,name and password */
258 string desc_text; 258 string desc_text;
259 string name_text; 259 string name_text;
260 string pw_text; 260 string pw_text;
261 261
262 void clear() 262 void clear()
263 { 263 {
264 d.clear(); 264 d.clear();
265 name = ""; 265 name = "";
266 desc_text = "Description"; 266 desc_text = "Description";
267 name_text = "Username"; 267 name_text = "Username";
268 pw_text = "Password"; 268 pw_text = "Password";
269 } 269 }
270}; 270};
271 271
272struct PwMSyncItem 272struct PwMSyncItem
273{ 273{
274 string syncName; 274 string syncName;
275 QDateTime lastSyncDate; 275 QDateTime lastSyncDate;
276 276
277 void clear() 277 void clear()
278 { 278 {
279 lastSyncDate = QDateTime(); 279 lastSyncDate = QDateTime();
280 syncName = ""; 280 syncName = "";
281 } 281 }
282}; 282};
283 283
284struct PwMItem 284struct PwMItem
285{ 285{
286 vector<PwMCategoryItem> dta; 286 vector<PwMCategoryItem> dta;
287 vector<PwMSyncItem> syncDta; 287 vector<PwMSyncItem> syncDta;
288 288
289 void clear() 289 void clear()
290 { 290 {
291 dta.clear(); 291 dta.clear();
292 syncDta.clear(); 292 syncDta.clear();
293 } 293 }
294}; 294};
295 295
296 296
297/** "Function Object" for sort()ing PwMDataItem::listViewPos */ 297/** "Function Object" for sort()ing PwMDataItem::listViewPos */
298class dta_lvp_greater 298class dta_lvp_greater
299{ 299{
300public: 300public:
301 bool operator() (const pair<unsigned int, unsigned int> &d1, 301 bool operator() (const pair<unsigned int, unsigned int> &d1,
302 const pair<unsigned int, unsigned int> &d2) 302 const pair<unsigned int, unsigned int> &d2)
303 { 303 {
304 return d1.second > d2.second; 304 return d1.second > d2.second;
305 } 305 }
306}; 306};
307 307
308/** list of PwMDoc documents and it's IDs */ 308/** list of PwMDoc documents and it's IDs */
309class PwMDocList 309class PwMDocList
310{ 310{
311public: 311public:
312 struct listItem 312 struct listItem
313 { 313 {
314 /** document filename (known as ID, here) */ 314 /** document filename (known as ID, here) */
315 string docId; 315 string docId;
316 /** pointer to the document class */ 316 /** pointer to the document class */
317 PwMDoc *doc; 317 PwMDoc *doc;
318 }; 318 };
319 319
320 PwMDocList() {} 320 PwMDocList() {}
321 321
322 /** add a new item to the list */ 322 /** add a new item to the list */
323 void add(PwMDoc *doc, const string &id); 323 void add(PwMDoc *doc, const string &id);
324 /** changes the contents of an existing item */ 324 /** changes the contents of an existing item */
325 void edit(PwMDoc *doc, const string &newId); 325 void edit(PwMDoc *doc, const string &newId);
326 /** remove the given item */ 326 /** remove the given item */
327 void del(PwMDoc *doc); 327 void del(PwMDoc *doc);
328 /** get the item at index */ 328 /** get the item at index */
329 listItem getAt(int index) 329 listItem getAt(int index)
330 { return docList[index]; } 330 { return docList[index]; }
331 /** find an entry with this id */ 331 /** find an entry with this id */
332 bool find(const string &id, listItem *ret = 0); 332 bool find(const string &id, listItem *ret = 0);
333 /** returns a copy of the list */ 333 /** returns a copy of the list */
334 const vector<listItem>* getList() const 334 const vector<listItem>* getList() const
335 { return &docList; } 335 { return &docList; }
336 336
337 337
338 /** returns a new unique number to extend the name of 338 /** returns a new unique number to extend the name of
339 * an unnamed document. 339 * an unnamed document.
340 */ 340 */
341 static unsigned int getNewUnnamedNumber() 341 static unsigned int getNewUnnamedNumber()
342 { return unnamedDocCnt++; } 342 { return unnamedDocCnt++; }
343 343
344protected: 344protected:
345 /* Hm, I think we shouldn't really use a "list" here, should we? 345 /* Hm, I think we shouldn't really use a "list" here, should we?
346 * So I decided to actually use a vector. 346 * So I decided to actually use a vector.
347 */ 347 */
348 vector<listItem> docList; 348 vector<listItem> docList;
349 /** This value is used to get a new number for yet unnamed 349 /** This value is used to get a new number for yet unnamed
350 * documents. It is incremented on every request. So it's 350 * documents. It is incremented on every request. So it's
351 * theoretically possible to overflow it, but... :) 351 * theoretically possible to overflow it, but... :)
352 */ 352 */
353 static unsigned int unnamedDocCnt; 353 static unsigned int unnamedDocCnt;
354}; 354};
355 355
356/** implements timers for the document */ 356/** implements timers for the document */
357class DocTimer : public QObject 357class DocTimer : public QObject
358{ 358{
359 Q_OBJECT 359 Q_OBJECT
360public: 360public:
361 enum TimerIDs 361 enum TimerIDs
362 { 362 {
363 id_mpwTimer, 363 id_mpwTimer,
364 id_autoLockTimer, 364 id_autoLockTimer,
365 id_metaCheckTimer 365 id_metaCheckTimer
366 }; 366 };
367 367
368public: 368public:
369 DocTimer(PwMDoc *_doc); 369 DocTimer(PwMDoc *_doc);
370 ~DocTimer(); 370 ~DocTimer();
371 371
372 /** start the timer */ 372 /** start the timer */
373 void start(TimerIDs timer); 373 void start(TimerIDs timer);
374 /** stop the timer */ 374 /** stop the timer */
375 void stop(TimerIDs timer); 375 void stop(TimerIDs timer);
376 /** get the lock for a timer. 376 /** get the lock for a timer.
377 * This lock is a recursive lock. When a lock is 377 * This lock is a recursive lock. When a lock is
378 * held, the timer will be stopped and timeout is 378 * held, the timer will be stopped and timeout is
379 * guaranteed to not happen 379 * guaranteed to not happen
380 */ 380 */
381 void getLock(TimerIDs timer); 381 void getLock(TimerIDs timer);
382 /** put a recursive timer lock */ 382 /** put a recursive timer lock */
383 void putLock(TimerIDs timer); 383 void putLock(TimerIDs timer);
384 384
385protected slots: 385protected slots:
386 /** timeout slot for the mpw timer */ 386 /** timeout slot for the mpw timer */
387 void mpwTimeout(); 387 void mpwTimeout();
388 /** timeout slot for the autoLock timer */ 388 /** timeout slot for the autoLock timer */
389 void autoLockTimeout(); 389 void autoLockTimeout();
390 /** timeout slot for the metaCheck timer */ 390 /** timeout slot for the metaCheck timer */
391 void metaCheckTimeout(); 391 void metaCheckTimeout();
392 392
393protected: 393protected:
394 /** pointer to the document associated with this timer. */ 394 /** pointer to the document associated with this timer. */
395 PwMDoc *doc; 395 PwMDoc *doc;
396 /** timer object for mpw timer */ 396 /** timer object for mpw timer */
397 QTimer *mpwTimer; 397 QTimer *mpwTimer;
398 /** timer object for the autoLock timer */ 398 /** timer object for the autoLock timer */
399 QTimer *autoLockTimer; 399 QTimer *autoLockTimer;
400 /** timer object for the metaCheck timer */ 400 /** timer object for the metaCheck timer */
401 QTimer *metaCheckTimer; 401 QTimer *metaCheckTimer;
402 /** lock counter for the mpw timer */ 402 /** lock counter for the mpw timer */
403 unsigned int mpwLock; 403 unsigned int mpwLock;
404 /** lock counter for the autoLock timer */ 404 /** lock counter for the autoLock timer */
405 unsigned int autoLockLock; 405 unsigned int autoLockLock;
406 /** lock counter for the metaCheck timer */ 406 /** lock counter for the metaCheck timer */
407 unsigned int metaCheckLock; 407 unsigned int metaCheckLock;
408}; 408};
409 409
410/** Document class for PwM */ 410/** Document class for PwM */
411//US ENH: derived from KSyncInterfaces, to get called by PwM when a sync is required. 411//US ENH: derived from KSyncInterfaces, to get called by PwM when a sync is required.
412// But PwMDoc is handling the sync by itself. 412// But PwMDoc is handling the sync by itself.
413class PwMDoc : public PwMDocUi, public KSyncInterface 413class PwMDoc : public PwMDocUi, public KSyncInterface
414 414
415{ 415{
416 Q_OBJECT 416 Q_OBJECT
417 friend class DocTimer; 417 friend class DocTimer;
418 418
419public: 419public:
420 /** construtor */ 420 /** construtor */
421 PwMDoc(QObject* parent = 0, const char *name = 0); 421 PwMDoc(QObject* parent = 0, const char *name = 0);
422 /** destructor */ 422 /** destructor */
423 ~PwMDoc(); 423 ~PwMDoc();
424 424
425 /** returns a pointer to a list of all open documents */ 425 /** returns a pointer to a list of all open documents */
426 static PwMDocList* getOpenDocList() 426 static PwMDocList* getOpenDocList()
427 { return &openDocList; } 427 { return &openDocList; }
428 428
429 /** flag document dirty. dta changed */ 429 /** flag document dirty. dta changed */
430 void flagDirty() 430 void flagDirty()
431 { 431 {
432 setDocStatFlag(DOC_STAT_DISK_DIRTY); 432 setDocStatFlag(DOC_STAT_DISK_DIRTY);
433 emitDataChanged(this); 433 emitDataChanged(this);
434 } 434 }
435 /** modified? */ 435 /** modified? */
436 bool isDirty() 436 bool isDirty()
437 { return getDocStatFlag(DOC_STAT_DISK_DIRTY); } 437 { return getDocStatFlag(DOC_STAT_DISK_DIRTY); }
438 /** save document to disk */ 438 /** save document to disk */
439 PwMerror saveDoc(char compress, const QString *file = 0); 439 PwMerror saveDoc(char compress, const QString *file = 0);
440 /** read document from file. 440 /** read document from file.
441 * "openLocked is must be set to either of these values: 441 * "openLocked is must be set to either of these values:
442 * 0 == open with all entries unlocked 442 * 0 == open with all entries unlocked
443 * 1 == open with all entries locked 443 * 1 == open with all entries locked
444 * 2 == open deep-locked 444 * 2 == open deep-locked
445 */ 445 */
446 PwMerror openDoc(const QString *file, int openLocked); 446 PwMerror openDoc(const QString *file, int openLocked);
447 /** export document to ascii-textfile */ 447 /** export document to ascii-textfile */
448 PwMerror exportToText(const QString *file); 448 PwMerror exportToText(const QString *file);
449 /** export document to gpasman / kpasman file */ 449 /** export document to gpasman / kpasman file */
450 PwMerror exportToGpasman(const QString *file); 450 PwMerror exportToGpasman(const QString *file);
451 /** import document from ascii-textfile */ 451 /** import document from ascii-textfile */
452 PwMerror importFromText(const QString *file, int format = -1); 452 PwMerror importFromText(const QString *file, int format = -1);
453 /** import document from gpasman / kpasman file */ 453 /** import document from gpasman / kpasman file */
454 PwMerror importFromGpasman(const QString *file); 454 PwMerror importFromGpasman(const QString *file);
455 /** add new entry */ 455 /** add new entry */
456 PwMerror addEntry(const QString &category, PwMDataItem *d, 456 PwMerror addEntry(const QString &category, PwMDataItem *d,
457 bool dontFlagDirty = false, bool updateMeta = true); 457 bool dontFlagDirty = false, bool updateMeta = true);
458 /** add new category. This function doesn't flag the document dirty! */ 458 /** add new category. This function doesn't flag the document dirty! */
459 PwMerror addCategory(const QString &category, unsigned int *categoryIndex, 459 PwMerror addCategory(const QString &category, unsigned int *categoryIndex,
460 bool checkIfExist = true); 460 bool checkIfExist = true);
461 /** rename an existing category */ 461 /** rename an existing category */
462 bool renameCategory(const QString &category, const QString &newName); 462 bool renameCategory(const QString &category, const QString &newName);
463 /** rename an existing category */ 463 /** rename an existing category */
464 bool renameCategory(unsigned int category, const QString &newName, 464 bool renameCategory(unsigned int category, const QString &newName,
465 bool dontFlagDirty = false); 465 bool dontFlagDirty = false);
466 /** delete an existing category */ 466 /** delete an existing category */
467 bool delCategory(const QString &category); 467 bool delCategory(const QString &category);
468 /** delete an existing category */ 468 /** delete an existing category */
469 bool delCategory(unsigned int category, bool dontFlagDirty = false); 469 bool delCategory(unsigned int category, bool dontFlagDirty = false);
470 /** returns a list of all category-names */ 470 /** returns a list of all category-names */
471 void getCategoryList(vector<string> *list); 471 void getCategoryList(vector<string> *list);
472 /** returns a list of all category-names */ 472 /** returns a list of all category-names */
473 void getCategoryList(QStringList *list); 473 void getCategoryList(QStringList *list);
474 /** returns a list of all entry-descs in the given category */ 474 /** returns a list of all entry-descs in the given category */
475 void getEntryList(const QString &category, QStringList *list); 475 void getEntryList(const QString &category, QStringList *list);
476 /** returns a list of all entry-descs in the given category */ 476 /** returns a list of all entry-descs in the given category */
477 void getEntryList(const QString &category, vector<string> *list); 477 void getEntryList(const QString &category, vector<string> *list);
478 /** returns a list of all entry-descs in the given category */ 478 /** returns a list of all entry-descs in the given category */
479 void getEntryList(unsigned int category, vector<string> *list); 479 void getEntryList(unsigned int category, vector<string> *list);
480 /** returns a list of all entry-descs in the given category */ 480 /** returns a list of all entry-descs in the given category */
481 void getEntryList(unsigned int category, QStringList *list); 481 void getEntryList(unsigned int category, QStringList *list);
482 /** delete entry */ 482 /** delete entry */
483 bool delEntry(const QString &category, unsigned int index, bool dontFlagDirty = false); 483 bool delEntry(const QString &category, unsigned int index, bool dontFlagDirty = false);
484 /** delete entry */ 484 /** delete entry */
485 bool delEntry(unsigned int category, unsigned int index, bool dontFlagDirty = false); 485 bool delEntry(unsigned int category, unsigned int index, bool dontFlagDirty = false);
486 /** edit entry */ 486 /** edit entry */
487 bool editEntry(const QString &oldCategory, const QString &newCategory, 487 bool editEntry(const QString &oldCategory, const QString &newCategory,
488 unsigned int index, PwMDataItem *d, bool updateMeta = true); 488 unsigned int index, PwMDataItem *d, bool updateMeta = true);
489 /** edit entry */ 489 /** edit entry */
490 bool editEntry(unsigned int oldCategory, const QString &newCategory, 490 bool editEntry(unsigned int oldCategory, const QString &newCategory,
491 unsigned int index, PwMDataItem *d, bool updateMeta = true); 491 unsigned int index, PwMDataItem *d, bool updateMeta = true);
492 /** finds the category with the "name" and return it's index */ 492 /** finds the category with the "name" and return it's index */
493 bool findCategory(const QString &name, unsigned int *index); 493 bool findCategory(const QString &name, unsigned int *index);
494 /** search for an entry "find" and check while searching only for 494 /** search for an entry "find" and check while searching only for
495 * the data-fields specified by "searchIn". To set the "searchIn" 495 * the data-fields specified by "searchIn". To set the "searchIn"
496 * value, we may use one or more of the SEARCH_IN_* defines at 496 * value, we may use one or more of the SEARCH_IN_* defines at
497 * the top of this header-file. It returns the positions of all 497 * the top of this header-file. It returns the positions of all
498 * matched entries in "foundPositions". If "breakAfterFound" is true, 498 * matched entries in "foundPositions". If "breakAfterFound" is true,
499 * the function terminates after the first occurence of the entry 499 * the function terminates after the first occurence of the entry
500 * and doesn't go on searching. So foundPositions->size() is never 500 * and doesn't go on searching. So foundPositions->size() is never
501 * > 1 if breakAfterFound is true. 501 * > 1 if breakAfterFound is true.
502 */ 502 */
503 void findEntry(unsigned int category, PwMDataItem find, unsigned int searchIn, 503 void findEntry(unsigned int category, PwMDataItem find, unsigned int searchIn,
504 vector<unsigned int> *foundPositions, bool breakAfterFound = false, 504 vector<unsigned int> *foundPositions, bool breakAfterFound = false,
505 bool caseSensitive = true, bool exactWordMatch = true, 505 bool caseSensitive = true, bool exactWordMatch = true,
506 bool sortByLvp = false); 506 bool sortByLvp = false);
507 /** see the above funtion. This function allows to set the category by name. */ 507 /** see the above funtion. This function allows to set the category by name. */
508 void findEntry(const QString &category, PwMDataItem find, unsigned int searchIn, 508 void findEntry(const QString &category, PwMDataItem find, unsigned int searchIn,
509 vector<unsigned int> *foundPositions, bool breakAfterFound = false, 509 vector<unsigned int> *foundPositions, bool breakAfterFound = false,
510 bool caseSensitive = true, bool exactWordMatch = true, 510 bool caseSensitive = true, bool exactWordMatch = true,
511 bool sortByLvp = false); 511 bool sortByLvp = false);
512 /** returns number of entries */ 512 /** returns number of entries */
513 unsigned int numEntries(const QString &category); 513 unsigned int numEntries(const QString &category);
514 unsigned int numEntries(unsigned int category) 514 unsigned int numEntries(unsigned int category)
515 { return dti.dta[category].d.size(); } 515 { return dti.dta[category].d.size(); }
516 /** returns number of categories */ 516 /** returns number of categories */
517 unsigned int numCategories() 517 unsigned int numCategories()
518 { return dti.dta.size(); } 518 { return dti.dta.size(); }
519 /** returns the name of the category at "index" */ 519 /** returns the name of the category at "index" */
520 const string* getCategory(unsigned int index) 520 const string* getCategory(unsigned int index)
521 { return (&(dti.dta[index].name)); } 521 { return (&(dti.dta[index].name)); }
522 522
523 /** returns the data of item at "index". 523 /** returns the data of item at "index".
524 * It unlocks the entry if it's locked and unlockIfLocked is true. 524 * It unlocks the entry if it's locked and unlockIfLocked is true.
525 * If the entry is locked, but unlockIfLocked is false, it'll not return 525 * If the entry is locked, but unlockIfLocked is false, it'll not return
526 * the pw. 526 * the pw.
527 */ 527 */
528 bool getEntry(const QString &category, unsigned int index, 528 bool getEntry(const QString &category, unsigned int index,
529 PwMDataItem *d, bool unlockIfLocked = false); 529 PwMDataItem *d, bool unlockIfLocked = false);
530 bool getEntry(unsigned int category, unsigned int index, 530 bool getEntry(unsigned int category, unsigned int index,
531 PwMDataItem *d, bool unlockIfLocked = false); 531 PwMDataItem *d, bool unlockIfLocked = false);
532 /** returns the comment-string by looking at the category 532 /** returns the comment-string by looking at the category
533 * and the listViewPos 533 * and the listViewPos
534 */ 534 */
535 PwMerror getCommentByLvp(const QString &category, int listViewPos, 535 PwMerror getCommentByLvp(const QString &category, int listViewPos,
536 string *foundComment); 536 string *foundComment);
537 PwMerror getCommentByLvp_long(const QString &category, int listViewPos, 537 PwMerror getCommentByLvp_long(const QString &category, int listViewPos,
538 string *foundComment); 538 string *foundComment);
539 /** checks if a password is already available. (currentPw) */ 539 /** checks if a password is already available. (currentPw) */
540 bool isPwAvailable() 540 bool isPwAvailable()
541 { return (currentPw != ""); } 541 { return (currentPw != ""); }
542 /** un/lock entry at "index". If needed, ask for password. */ 542 /** un/lock entry at "index". If needed, ask for password. */
543 bool lockAt(const QString &category, unsigned int index, 543 bool lockAt(const QString &category, unsigned int index,
544 bool lock = true); 544 bool lock = true);
545 bool lockAt(unsigned int category, unsigned int index, 545 bool lockAt(unsigned int category, unsigned int index,
546 bool lock = true); 546 bool lock = true);
547 /** returns the lock-status at "index" */ 547 /** returns the lock-status at "index" */
548 bool isLocked(const QString &category, unsigned int index); 548 bool isLocked(const QString &category, unsigned int index);
549 bool isLocked(unsigned int category, unsigned int index) 549 bool isLocked(unsigned int category, unsigned int index)
550 { return dti.dta[category].d[index].lockStat; } 550 { return dti.dta[category].d[index].lockStat; }
551 /** returns the deeplock status */ 551 /** returns the deeplock status */
552 bool isDeepLocked() 552 bool isDeepLocked()
553 { return getDocStatFlag(DOC_STAT_DEEPLOCKED); } 553 { return getDocStatFlag(DOC_STAT_DEEPLOCKED); }
554 /** (un)lock all entries */ 554 /** (un)lock all entries */
555 bool lockAll(bool lock); 555 bool lockAll(bool lock);
556 /** unlocks all entries tempoarly. 556 /** unlocks all entries tempoarly.
557 * 1st NOTE: Be very careful with this function! :) 557 * 1st NOTE: Be very careful with this function! :)
558 * 2nd NOTE: After you have called unlockAll_Tempoary(); , 558 * 2nd NOTE: After you have called unlockAll_Tempoary(); ,
559 * please DON'T forget to call unlockAll_Tempoary(true); 559 * please DON'T forget to call unlockAll_Tempoary(true);
560 * _before_ the user (or someone else) is able to change 560 * _before_ the user (or someone else) is able to change
561 * the document! 561 * the document!
562 * 3rd NOTE: Please DON'T change "dta" while the data is tempoary 562 * 3rd NOTE: Please DON'T change "dta" while the data is tempoary
563 * unlocked! This will cause corruption. 563 * unlocked! This will cause corruption.
564 */ 564 */
565 bool unlockAll_tempoary(bool revert = false); 565 bool unlockAll_tempoary(bool revert = false);
566 /** deep-(un)locks the document. 566 /** deep-(un)locks the document.
567 * deep-locking writes all data to the file, deletes all data 567 * deep-locking writes all data to the file, deletes all data
568 * in memory, but doesn't close the document. 568 * in memory, but doesn't close the document.
569 * deep-locking is only available, if the user previously saved 569 * deep-locking is only available, if the user previously saved
570 * the doc to a file (with a password). 570 * the doc to a file (with a password).
571 * If "saveToFile" is false, it does NOT write the data to the file! 571 * If "saveToFile" is false, it does NOT write the data to the file!
572 */ 572 */
573 PwMerror deepLock(bool lock = true, bool saveToFile = true); 573 PwMerror deepLock(bool lock = true, bool saveToFile = true);
574 /** is unlockable without pw? */ 574 /** is unlockable without pw? */
575 bool unlockWoPw() 575 bool unlockWoPw()
576 { return getDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW); } 576 { return getDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW); }
577 /** get the "currentPassword" */ 577 /** get the "currentPassword" */
578 const QString& getCurrentPw() 578 const QString& getCurrentPw()
579 { return currentPw; } 579 { return currentPw; }
580 /** open a window and request the user to change the mpw */ 580 /** open a window and request the user to change the mpw */
581 void changeCurrentPw(); 581 void changeCurrentPw();
582 /** set the "listViewPos" variable of "dta" */ 582 /** set the "listViewPos" variable of "dta" */
583 void setListViewPos(const QString &category, unsigned int index, 583 void setListViewPos(const QString &category, unsigned int index,
584 int pos); 584 int pos);
585 /** set the "listViewPos" variable of "dta" */ 585 /** set the "listViewPos" variable of "dta" */
586 void setListViewPos(unsigned int category, unsigned int index, 586 void setListViewPos(unsigned int category, unsigned int index,
587 int pos); 587 int pos);
588 /** get the "listViewPos" variable of "dta" */ 588 /** get the "listViewPos" variable of "dta" */
589 int getListViewPos(const QString &category, unsigned int index); 589 int getListViewPos(const QString &category, unsigned int index);
590 /** set the maximum number of entries allowed */ 590 /** set the maximum number of entries allowed */
591 void setMaxNumEntries(unsigned int num = DEFAULT_MAX_ENTRIES) 591 void setMaxNumEntries(unsigned int num = DEFAULT_MAX_ENTRIES)
592 { maxEntries = num; } 592 { maxEntries = num; }
593 /** get the maximum number of entries allowed */ 593 /** get the maximum number of entries allowed */
594 unsigned int getMaxNumEntries() 594 unsigned int getMaxNumEntries()
595 { return maxEntries; } 595 { return maxEntries; }
596 /** ensure all listViewPos of all dta items are set. (are ! -1). 596 /** ensure all listViewPos of all dta items are set. (are ! -1).
597 * If there are some undefined entries, add them to the end of 597 * If there are some undefined entries, add them to the end of
598 * the listViewPos(itions). */ 598 * the listViewPos(itions). */
599 void ensureLvp(); 599 void ensureLvp();
600 /** execute the "launcher" of this entry */ 600 /** execute the "launcher" of this entry */
601 bool execLauncher(const QString &category, unsigned int entryIndex); 601 bool execLauncher(const QString &category, unsigned int entryIndex);
602 /** see above */ 602 /** see above */
603 bool execLauncher(unsigned int category, unsigned int entryIndex); 603 bool execLauncher(unsigned int category, unsigned int entryIndex);
604 /** open a browser with the URL-section of the given entry */ 604 /** open a browser with the URL-section of the given entry */
605 bool goToURL(const QString &category, unsigned int entryIndex); 605 bool goToURL(const QString &category, unsigned int entryIndex);
606 /** see above */ 606 /** see above */
607 bool goToURL(unsigned int category, unsigned int entryIndex); 607 bool goToURL(unsigned int category, unsigned int entryIndex);
608 /** returns true if there is no entry present in the document. 608 /** returns true if there is no entry present in the document.
609 * Note: The "default" Category is present everytime, so 609 * Note: The "default" Category is present everytime, so
610 * it's checked for it's entries. 610 * it's checked for it's entries.
611 */ 611 */
612 bool isDocEmpty() 612 bool isDocEmpty()
613 { 613 {
614 if (numCategories() > 1) 614 if (numCategories() > 1)
diff --git a/pwmanager/pwmanager/pwmdocui.cpp b/pwmanager/pwmanager/pwmdocui.cpp
index a9916c2..ea96509 100644
--- a/pwmanager/pwmanager/pwmdocui.cpp
+++ b/pwmanager/pwmanager/pwmdocui.cpp
@@ -84,387 +84,387 @@ QString PwMDocUi::requestMpw(bool chipcard)
84 KWin::setState(pwWnd.winId(), NET::StaysOnTop); 84 KWin::setState(pwWnd.winId(), NET::StaysOnTop);
85#else 85#else
86 GetMasterPwWndImpl pwWnd; 86 GetMasterPwWndImpl pwWnd;
87#endif 87#endif
88 if (pwWnd.exec() != 1) 88 if (pwWnd.exec() != 1)
89 return ""; 89 return "";
90 pw = pwWnd.pwLineEdit->text(); 90 pw = pwWnd.pwLineEdit->text();
91 } 91 }
92 92
93 return pw; 93 return pw;
94} 94}
95 95
96QString PwMDocUi::requestNewMpw(bool *chipcard) 96QString PwMDocUi::requestNewMpw(bool *chipcard)
97{ 97{
98 QString pw; 98 QString pw;
99 SetMasterPwWndImpl pwWnd(currentView); 99 SetMasterPwWndImpl pwWnd(currentView);
100 pwWnd.setPwMKeyCard(keyCard); 100 pwWnd.setPwMKeyCard(keyCard);
101 if (!chipcard) { 101 if (!chipcard) {
102#ifndef PWM_EMBEDDED 102#ifndef PWM_EMBEDDED
103 pwWnd.mainTab->removePage(pwWnd.mainTab->page(1)); 103 pwWnd.mainTab->removePage(pwWnd.mainTab->page(1));
104#else 104#else
105 pwWnd.mainTab->removePage(pwWnd.tab_2); 105 pwWnd.mainTab->removePage(pwWnd.tab_2);
106#endif 106#endif
107 } 107 }
108 108
109 if (pwWnd.exec() != 1) 109 if (pwWnd.exec() != 1)
110 return ""; 110 return "";
111 pw = pwWnd.getPw(chipcard).c_str(); 111 pw = pwWnd.getPw(chipcard).c_str();
112 112
113 return pw; 113 return pw;
114} 114}
115 115
116QString PwMDocUi::requestMpwChange(const QString *currentPw, bool *chipcard) 116QString PwMDocUi::requestMpwChange(const QString *currentPw, bool *chipcard)
117{ 117{
118 QString pw(requestMpw(*chipcard)); 118 QString pw(requestMpw(*chipcard));
119 if (pw == "") 119 if (pw == "")
120 return ""; 120 return "";
121 if (pw != *currentPw) { 121 if (pw != *currentPw) {
122 wrongMpwMsgBox(*chipcard); 122 wrongMpwMsgBox(*chipcard);
123 return ""; 123 return "";
124 } 124 }
125 125
126 pw = requestNewMpw(chipcard); 126 pw = requestNewMpw(chipcard);
127 if (pw == "") 127 if (pw == "")
128 return ""; 128 return "";
129 return pw; 129 return pw;
130} 130}
131 131
132void PwMDocUi::wrongMpwMsgBox(bool chipcard, QString prefix, QString postfix) 132void PwMDocUi::wrongMpwMsgBox(bool chipcard, QString prefix, QString postfix)
133{ 133{
134 QString msg; 134 QString msg;
135 if (prefix != "") { 135 if (prefix != "") {
136 msg += prefix; 136 msg += prefix;
137 msg += "\n"; 137 msg += "\n";
138 } 138 }
139 139
140 if (chipcard) { 140 if (chipcard) {
141 msg += i18n("Wrong key-card!\n" 141 msg += i18n("Wrong key-card!\n"
142 "Please try again with the\n" 142 "Please try again with the\n"
143 "correct key-card."); 143 "correct key-card.");
144 } else { 144 } else {
145 msg += i18n("Wrong master-password!\n" 145 msg += i18n("Wrong master-password!\n"
146 "Please try again."); 146 "Please try again.");
147 } 147 }
148 148
149 if (postfix != "") { 149 if (postfix != "") {
150 msg += "\n"; 150 msg += "\n";
151 msg += postfix; 151 msg += postfix;
152 } 152 }
153 KMessageBox::error(currentView, msg, 153 KMessageBox::error(currentView, msg,
154 (chipcard) ? (i18n("wrong chipcard")) 154 (chipcard) ? (i18n("wrong chipcard"))
155 : (i18n("password error"))); 155 : (i18n("password error")));
156} 156}
157 157
158void PwMDocUi::noMpwMsgBox(bool chipcard, QString prefix, QString postfix) 158void PwMDocUi::noMpwMsgBox(bool chipcard, QString prefix, QString postfix)
159{ 159{
160 QString msg; 160 QString msg;
161 if (prefix != "") { 161 if (prefix != "") {
162 msg += prefix; 162 msg += prefix;
163 msg += "\n"; 163 msg += "\n";
164 } 164 }
165 165
166 if (chipcard) { 166 if (chipcard) {
167 msg += i18n("No key-card found!\n" 167 msg += i18n("No key-card found!\n"
168 "Please insert the\n" 168 "Please insert the\n"
169 "correct key-card."); 169 "correct key-card.");
170 } else { 170 } else {
171 msg += i18n("No master-password given!"); 171 msg += i18n("No master-password given!");
172 } 172 }
173 173
174 if (postfix != "") { 174 if (postfix != "") {
175 msg += "\n"; 175 msg += "\n";
176 msg += postfix; 176 msg += postfix;
177 } 177 }
178 KMessageBox::error(currentView, msg, 178 KMessageBox::error(currentView, msg,
179 (chipcard) ? (i18n("no chipcard")) 179 (chipcard) ? (i18n("no chipcard"))
180 : (i18n("password error"))); 180 : (i18n("password error")));
181} 181}
182 182
183void PwMDocUi::rootAlertMsgBox() 183void PwMDocUi::rootAlertMsgBox()
184{ 184{
185 KMessageBox::error(currentView, 185 KMessageBox::error(currentView,
186 i18n("This feature is not available,n" 186 i18n("This feature is not available,n"
187 "if you execute PwM with \"root\" \n" 187 "if you execute PwM with \"root\" \n"
188 "UID 0 privileges, for security reasons!"), 188 "UID 0 privileges, for security reasons!"),
189 i18n("not allowed as root!")); 189 i18n("not allowed as root!"));
190} 190}
191 191
192void PwMDocUi::cantDeeplock_notSavedMsgBox() 192void PwMDocUi::cantDeeplock_notSavedMsgBox()
193{ 193{
194 KMessageBox::error(currentView, 194 KMessageBox::error(currentView,
195 i18n("Can't deep-lock, because the document\n" 195 i18n("Can't deep-lock, because the document\n"
196 "hasn't been saved, yet. Please save\n" 196 "hasn't been saved, yet. Please save\n"
197 "to a file and try again."), 197 "to a file and try again."),
198 i18n("not saved, yet")); 198 i18n("not saved, yet"));
199} 199}
200 200
201void PwMDocUi::gpmPwLenErrMsgBox() 201void PwMDocUi::gpmPwLenErrMsgBox()
202{ 202{
203 KMessageBox::error(currentView, 203 KMessageBox::error(currentView,
204 i18n("GPasman does not support passwords\n" 204 i18n("GPasman does not support passwords\n"
205 "shorter than 4 characters! Please try\n" 205 "shorter than 4 characters! Please try\n"
206 "again with a longer password."), 206 "again with a longer password."),
207 i18n("Password too short")); 207 i18n("Password too short"));
208} 208}
209 209
210int PwMDocUi::dirtyAskSave(const QString &docTitle) 210int PwMDocUi::dirtyAskSave(const QString &docTitle)
211{ 211{
212 int ret; 212 int ret;
213#ifndef PWM_EMBEDDED 213#ifndef PWM_EMBEDDED
214 ret = KMessageBox::questionYesNoCancel(currentView, 214 ret = KMessageBox::questionYesNoCancel(currentView,
215 i18n("The list\n\"") + 215 i18n("The list\n\"") +
216 docTitle + 216 docTitle +
217 i18n 217 i18n
218 ("\" has been modified.\n" 218 ("\" has been modified.\n"
219 "Do you want to save it?"), 219 "Do you want to save it?"),
220 i18n("Save?")); 220 i18n("Save?"));
221 if (ret == KMessageBox::Yes) { 221 if (ret == KMessageBox::Yes) {
222 return 0; 222 return 0;
223 } else if (ret == KMessageBox::No) { 223 } else if (ret == KMessageBox::No) {
224 return 1; 224 return 1;
225 } 225 }
226#else 226#else
227 QString doc = docTitle; 227 QString doc = docTitle;
228 if ( doc.length() > 33 ) 228 if ( doc.length() > 33 )
229 doc = "..." + doc.right(30); 229 doc = "..." + doc.right(30);
230 ret = KMessageBox::warningYesNoCancel(currentView, 230 ret = KMessageBox::warningYesNoCancel(currentView,
231 i18n("The list\n \"") + 231 i18n("The list\n \"") +
232 doc + 232 doc +
233 i18n 233 i18n
234 ("\"\nhas been modified.\n" 234 ("\"\nhas been modified.\n"
235 "Do you want to save it?"), 235 "Do you want to save it?"),
236 i18n("Save?")); 236 i18n("Save?"));
237 if (ret == KMessageBox::Yes) { 237 if (ret == KMessageBox::Yes) {
238 return 0; 238 return 0;
239 } else if (ret == KMessageBox::No) { 239 } else if (ret == KMessageBox::No) {
240 return 1; 240 return 1;
241 } 241 }
242 242
243#endif 243#endif
244 244
245 // cancel 245 // cancel
246 return -1; 246 return -1;
247} 247}
248 248
249bool PwMDocUi::saveDocUi(PwMDoc *doc) 249bool PwMDocUi::saveDocUi(PwMDoc *doc)
250{ 250{
251 PWM_ASSERT(doc); 251 PWM_ASSERT(doc);
252 doc->timer()->getLock(DocTimer::id_autoLockTimer); 252 doc->timer()->getLock(DocTimer::id_autoLockTimer);
253 if (doc->isDocEmpty()) { 253 if (doc->isDocEmpty()) {
254 KMessageBox::information(currentView, 254 KMessageBox::information(currentView,
255 i18n 255 i18n
256 ("Sorry, there's nothing to save.\n" 256 ("Sorry, there's nothing to save.\n"
257 "Please first add some passwords."), 257 "Please first add some passwords."),
258 i18n("nothing to do")); 258 i18n("nothing to do"));
259 doc->timer()->putLock(DocTimer::id_autoLockTimer); 259 doc->timer()->putLock(DocTimer::id_autoLockTimer);
260 return true; 260 return true;
261 } 261 }
262 PwMerror ret = doc->saveDoc(conf()->confGlobCompression()); 262 PwMerror ret = doc->saveDoc(conf()->confGlobCompression());
263 if (ret == e_filename) { 263 if (ret == e_filename) {
264 doc->timer()->putLock(DocTimer::id_autoLockTimer); 264 doc->timer()->putLock(DocTimer::id_autoLockTimer);
265 return saveAsDocUi(doc); 265 return saveAsDocUi(doc);
266 } else if (ret == e_weakPw) { 266 } else if (ret == e_weakPw) {
267 KMessageBox::error(currentView, 267 KMessageBox::error(currentView,
268 i18n("Error: This is a weak password.\n" 268 i18n("Error: This is a weak password.\n"
269 "Please select another password."), 269 "Please select another password."),
270 i18n("weak password")); 270 i18n("weak password"));
271 doc->timer()->putLock(DocTimer::id_autoLockTimer); 271 doc->timer()->putLock(DocTimer::id_autoLockTimer);
272 return false; 272 return false;
273 } else if (ret == e_fileBackup) { 273 } else if (ret == e_fileBackup) {
274 KMessageBox::error(currentView, 274 KMessageBox::error(currentView,
275 i18n("Error: Couldn't make backup-file!"), 275 i18n("Error: Couldn't make backup-file!"),
276 i18n("backup failed")); 276 i18n("backup failed"));
277 doc->timer()->putLock(DocTimer::id_autoLockTimer); 277 doc->timer()->putLock(DocTimer::id_autoLockTimer);
278 return false; 278 return false;
279 } else if (ret == e_noPw || 279 } else if (ret == e_noPw ||
280 ret == e_wrongPw || 280 ret == e_wrongPw ||
281 ret == e_openFile) { 281 ret == e_openFile) {
282 doc->timer()->putLock(DocTimer::id_autoLockTimer); 282 doc->timer()->putLock(DocTimer::id_autoLockTimer);
283 return false; 283 return false;
284 } else if (ret != e_success) { 284 } else if (ret != e_success) {
285 KMessageBox::error(currentView, 285 KMessageBox::error(currentView,
286 i18n("Error: Couldn't write to file.\n" 286 i18n("Error: Couldn't write to file.\n"
287 "Please check if you have permission to\n" 287 "Please check if you have permission to\n"
288 "write to the file in that directory."), 288 "write to the file in that directory."),
289 i18n("error while writing")); 289 i18n("error while writing"));
290 doc->timer()->putLock(DocTimer::id_autoLockTimer); 290 doc->timer()->putLock(DocTimer::id_autoLockTimer);
291 return false; 291 return false;
292 } 292 }
293 doc->timer()->putLock(DocTimer::id_autoLockTimer); 293 doc->timer()->putLock(DocTimer::id_autoLockTimer);
294 return true; 294 return true;
295} 295}
296 296
297bool PwMDocUi::saveAsDocUi(PwMDoc *doc) 297bool PwMDocUi::saveAsDocUi(PwMDoc *doc)
298{ 298{
299 PWM_ASSERT(doc); 299 PWM_ASSERT(doc);
300 doc->timer()->getLock(DocTimer::id_autoLockTimer); 300 doc->timer()->getLock(DocTimer::id_autoLockTimer);
301 if (doc->isDocEmpty()) { 301 if (doc->isDocEmpty()) {
302 KMessageBox::information(currentView, 302 KMessageBox::information(currentView,
303 i18n 303 i18n
304 ("Sorry, there's nothing to save.\n" 304 ("Sorry, there's nothing to save.\n"
305 "Please first add some passwords."), 305 "Please first add some passwords."),
306 i18n("nothing to do")); 306 i18n("nothing to do"));
307 doc->timer()->putLock(DocTimer::id_autoLockTimer); 307 doc->timer()->putLock(DocTimer::id_autoLockTimer);
308 return true; 308 return true;
309 } 309 }
310#ifndef PWM_EMBEDDED 310#ifndef PWM_EMBEDDED
311 QString fn(KFileDialog::getSaveFileName(QString::null, 311 QString fn(KFileDialog::getSaveFileName(QString::null,
312 i18n("*.pwm|PwManager Password file"), 312 i18n("*.pwm|PwManager Password file"),
313 currentView)); 313 currentView));
314#else 314#else
315 QString fn = locateLocal( "data", KGlobal::getAppName() + "/*.pwm" ); 315 QString fn = locateLocal( "data", KGlobal::getAppName() + "/*.pwm" );
316 fn = KFileDialog::getSaveFileName(fn, 316 fn = KFileDialog::getSaveFileName(fn,
317 i18n("password filename(*.pwm)"), 317 i18n("password filename(*.pwm)"),
318 currentView); 318 currentView);
319 319
320#endif 320#endif
321 if (fn == "") { 321 if (fn == "") {
322 doc->timer()->putLock(DocTimer::id_autoLockTimer); 322 doc->timer()->putLock(DocTimer::id_autoLockTimer);
323 return false; 323 return false;
324 } 324 }
325 if (fn.right(4) != ".pwm") 325 if (fn.right(4) != ".pwm")
326 fn += ".pwm"; 326 fn += ".pwm";
327 327
328 PwMerror ret = doc->saveDoc(conf()->confGlobCompression(), &fn); 328 PwMerror ret = doc->saveDoc(conf()->confGlobCompression(), &fn);
329 if (ret == e_noPw || 329 if (ret == e_noPw ||
330 ret == e_wrongPw || 330 ret == e_wrongPw ||
331 ret == e_openFile) { 331 ret == e_openFile) {
332 doc->timer()->putLock(DocTimer::id_autoLockTimer); 332 doc->timer()->putLock(DocTimer::id_autoLockTimer);
333 return false; 333 return false;
334 } else if (ret != e_success) { 334 } else if (ret != e_success) {
335 KMessageBox::error(currentView, 335 KMessageBox::error(currentView,
336 i18n("Error: Couldn't write to file.\n" 336 i18n("Error: Couldn't write to file.\n"
337 "Please check if you have permission to\n" 337 "Please check if you have permission to\n"
338 "write to the file in that directory."), 338 "write to the file in that directory."),
339 i18n("error while writing")); 339 i18n("error while writing"));
340 doc->timer()->putLock(DocTimer::id_autoLockTimer); 340 doc->timer()->putLock(DocTimer::id_autoLockTimer);
341 return false; 341 return false;
342 } 342 }
343 doc->timer()->putLock(DocTimer::id_autoLockTimer); 343 doc->timer()->putLock(DocTimer::id_autoLockTimer);
344 return true; 344 return true;
345} 345}
346 346
347bool PwMDocUi::openDocUi(PwMDoc *doc, 347bool PwMDocUi::openDocUi(PwMDoc *doc,
348 QString filename, 348 QString filename,
349 bool openDeepLocked) 349 bool openDeepLocked)
350{ 350{
351 if (filename.isEmpty()) 351 if (filename.isEmpty())
352 { 352 {
353#ifndef PWM_EMBEDDED 353#ifndef PWM_EMBEDDED
354 filename = KFileDialog::getOpenFileName(QString::null, 354 filename = KFileDialog::getOpenFileName(QString::null,
355 i18n("*.pwm|PwManager Password file\n" 355 i18n("*.pwm|PwManager Password file\n"
356 "*|All files"), getCurrentView()); 356 "*|All files"), getCurrentView());
357#else 357#else
358 filename = locateLocal( "data", KGlobal::getAppName() + "/*.pwm"); 358 filename = locateLocal( "data", KGlobal::getAppName() + "/*.pwm");
359 filename = KFileDialog::getOpenFileName(filename, 359 filename = KFileDialog::getOpenFileName(filename,
360 i18n("password filename(*.pwm)"), getCurrentView()); 360 i18n("password filename(*.pwm)"), getCurrentView());
361#endif 361#endif
362 } 362 }
363 if (filename.isEmpty()) 363 if (filename.isEmpty())
364 goto cancelOpen; 364 goto cancelOpen;
365 PwMerror ret; 365 PwMerror ret;
366 while (true) { 366 while (true) {
367 int lockStat = -1; 367 int lockStat = -1;
368 if (openDeepLocked) { 368 if (openDeepLocked) {
369 lockStat = 2; 369 lockStat = 2;
370 } else { 370 } else {
371 if (conf()->confGlobUnlockOnOpen()) { 371 if (conf()->confGlobUnlockOnOpen()) {
372 lockStat = 0; 372 lockStat = 0;
373 } else { 373 } else {
374 lockStat = 1; 374 lockStat = 1;
375 } 375 }
376 } 376 }
377 ret = doc->openDoc(&filename, lockStat); 377 ret = doc->openDoc(&filename, lockStat);
378 //qDebug("pwmdocui::OpenDocui %i", ret); 378 //qDebug("pwmdocui::OpenDocui %i", ret);
379 if (ret != e_success) { 379 if (ret != e_success) {
380 if (ret == e_readFile || ret == e_openFile) { 380 if (ret == e_readFile || ret == e_openFile) {
381 KMessageBox::error(getCurrentView(), 381 KMessageBox::error(getCurrentView(),
382 i18n("Could not read file!") 382 i18n("Could not read file!")
383 + "\n" 383 + "\n"
384 + filename, 384 + filename,
385 i18n("File error")); 385 i18n("File error"));
386 goto cancelOpen; 386 goto cancelOpen;
387 } 387 }
388 if (ret == e_alreadyOpen) { 388 if (ret == e_alreadyOpen) {
389 KMessageBox::error(getCurrentView(), 389 KMessageBox::error(getCurrentView(),
390 i18n("This file is already open."), 390 i18n("This file is already open."),
391 i18n("Already open")); 391 i18n("Already open"));
392 goto cancelOpen; 392 goto cancelOpen;
393 } 393 }
394 if (ret == e_fileVer) { 394 if (ret == e_fileVer) {
395 KMessageBox::error(getCurrentView(), 395 KMessageBox::error(getCurrentView(),
396 i18n 396 i18n
397 ("File-version is not supported!\n" 397 ("File-version is not supported!\n"
398 "Did you create this file with an\nolder or newer version of PwM?"), 398 "Did you create this file with an\nolder or newer version of PwM?"),
399 i18n 399 i18n
400 ("Incompatible version")); 400 ("Incompatible version"));
401 goto cancelOpen; 401 goto cancelOpen;
402 } 402 }
403 if (ret == e_wrongPw) { 403 if (ret == e_wrongPw) {
404 continue; 404 continue;
405 } 405 }
406 if (ret == e_noPw) { 406 if (ret == e_noPw) {
407 goto cancelOpen; 407 goto cancelOpen;
408 } 408 }
409 if (ret == e_fileFormat) { 409 if (ret == e_fileFormat) {
410 KMessageBox::error(getCurrentView(), 410 KMessageBox::error(getCurrentView(),
411 i18n 411 i18n
412 ("Sorry, this file has not been recognized\n" 412 ("Sorry, this file has not been recognized\n"
413 "as a PwM Password file.\n" 413 "as a PwM Password file.\n"
414 "Probably you have selected the wrong file."), 414 "Probably you have selected the wrong file."),
415 i18n 415 i18n
416 ("No PwM password-file")); 416 ("No PwM password-file"));
417 goto cancelOpen; 417 goto cancelOpen;
418 } 418 }
419 if (ret == e_fileCorrupt) { 419 if (ret == e_fileCorrupt) {
420 KMessageBox::error(getCurrentView(), 420 KMessageBox::error(getCurrentView(),
421 i18n 421 i18n
422 ("File corrupt!\n" 422 ("File corrupt!\n"
423 "Maybe the media, you stored this file on,\n" 423 "Maybe the media, you stored this file on,\n"
424 "had bad sectors?"), 424 "had bad sectors?"),
425 i18n 425 i18n
426 ("Checksum error")); 426 ("Checksum error"));
427 goto cancelOpen; 427 goto cancelOpen;
428 } 428 }
429 } 429 }
430 break; 430 break;
431 } 431 }
432 return true; 432 return true;
433 433
434 cancelOpen: 434 cancelOpen:
435 return false; 435 return false;
436} 436}
437 437
438QString PwMDocUi::string_defaultCategory() 438QString PwMDocUi::string_defaultCategory()
439{ 439{
440 return i18n("Default"); 440 return i18n("Default");
441} 441}
442 442
443QString PwMDocUi::string_locked() 443QString PwMDocUi::string_locked()
444{ 444{
445 return i18n("<LOCKED>"); 445 return i18n("<LOCKED>");
446} 446}
447 447
448QString PwMDocUi::string_deepLockedShort() 448QString PwMDocUi::string_deepLockedShort()
449{ 449{
450 return i18n("DEEP-LOCKED"); 450 return i18n("DEEP-LOCKED");
451} 451}
452 452
453QString PwMDocUi::string_deepLockedLong() 453QString PwMDocUi::string_deepLockedLong()
454{ 454{
455 return i18n("This file is DEEP-LOCKED!\n" 455 return i18n("This file is DEEP-LOCKED!\n"
456 "That means all data has been encrypted\n" 456 "That means all data has been encrypted\n"
457 "and written out to the file. If you want\n" 457 "and written out to the file. If you want\n"
458 "to see the entries, please UNLOCK the file.\n" 458 "to see the entries, please UNLOCK the file.\n"
459 "While unlocking, you will be prompted for the\n" 459 "While unlocking, you will be prompted for the\n"
460 "master-password or the key-card."); 460 "master-password or the key-card.");
461} 461}
462 462
463QString PwMDocUi::string_defaultTitle() 463QString PwMDocUi::string_defaultTitle()
464{ 464{
465 return i18n("Untitled"); 465 return i18n("Untitled");
466} 466}
467 467
468#ifndef PWM_EMBEDDED 468#ifndef PWM_EMBEDDED_
469#include "pwmdocui.moc" 469#include "moc_pwmdocui.cpp"
470#endif 470#endif
diff --git a/pwmanager/pwmanager/pwminit.cpp b/pwmanager/pwmanager/pwminit.cpp
index d59d4d8..15e21ee 100644
--- a/pwmanager/pwmanager/pwminit.cpp
+++ b/pwmanager/pwmanager/pwminit.cpp
@@ -1,661 +1,662 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 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 "pwminit.h" 20#include "pwminit.h"
21#include "randomizer.h" 21#include "randomizer.h"
22#include <qdir.h> 22#include <qdir.h>
23//Added by qt3to4:
24#include <Q3ValueList>
23 25
24#ifndef PWM_EMBEDDED 26#ifndef PWM_EMBEDDED
25#include "selftest.h" 27#include "selftest.h"
26#include "configuration.h" 28#include "configuration.h"
27#else 29#else
28#include "pwmprefs.h" 30#include "pwmprefs.h"
29#endif 31#endif
30 32
31#include "pwm.h" 33#include "pwm.h"
32#include "pwmexception.h" 34#include "pwmexception.h"
33#include "pwmtray.h" 35#include "pwmtray.h"
34#include "pwmdoc.h" 36#include "pwmdoc.h"
35 37
36#ifdef CONFIG_KWALLETIF 38#ifdef CONFIG_KWALLETIF
37# include "kwalletemu.h" 39# include "kwalletemu.h"
38#endif // CONFIG_KWALLETIF 40#endif // CONFIG_KWALLETIF
39#ifdef CONFIG_KEYCARD 41#ifdef CONFIG_KEYCARD
40# include "pwmkeycard.h" 42# include "pwmkeycard.h"
41#endif // CONFIG_KEYCARD 43#endif // CONFIG_KEYCARD
42 44
43#include <qmessagebox.h> 45#include <qmessagebox.h>
44 46
45#include <kmessagebox.h> 47#include <kmessagebox.h>
46#ifndef PWM_EMBEDDED 48#ifndef PWM_EMBEDDED
47#include <kcmdlineargs.h> 49#include <kcmdlineargs.h>
48#include <kwin.h> 50#include <kwin.h>
49#include <dcopclient.h> 51#include <dcopclient.h>
50#endif 52#endif
51 53
52#include <kapplication.h> 54#include <kapplication.h>
53#include <kiconloader.h> 55#include <kiconloader.h>
54 56
55#include <signal.h> 57#include <signal.h>
56 58
57static PwMInit *sig_init_pointer; 59static PwMInit *sig_init_pointer;
58#ifdef _WIN32_ 60#ifdef _WIN32_
59static void sig_handler(int signum) 61static void sig_handler(int signum)
60#else 62#else
61static NOREGPARM void sig_handler(int signum) 63static NOREGPARM void sig_handler(int signum)
62#endif 64#endif
63{ 65{
64 switch (signum) { 66 switch (signum) {
65 case SIGINT: 67 case SIGINT:
66 case SIGTERM: 68 case SIGTERM:
67 sig_init_pointer->shutdownApp(20 + signum); 69 sig_init_pointer->shutdownApp(20 + signum);
68 break; 70 break;
69 default: 71 default:
70 printDebug(string("unhandled signal ") 72 printDebug(string("unhandled signal ")
71 + tostr(signum)); 73 + tostr(signum));
72 } 74 }
73} 75}
74 76
75 77
76 78
77PwMInit::PwMInit(PwMApplication *_app) 79PwMInit::PwMInit(PwMApplication *_app)
78 : runStatus (unknown) 80 : runStatus (unknown)
79 , _curWidget (0) 81 , _curWidget (0)
80 , _dcopClient (0) 82 , _dcopClient (0)
81 , _kwalletEmu (0) 83 , _kwalletEmu (0)
82 , _keycard (0) 84 , _keycard (0)
83 , _tray (0) 85 , _tray (0)
84{ 86{
85 sig_init_pointer = this; 87 sig_init_pointer = this;
86 app = _app; 88 app = _app;
87} 89}
88 90
89PwMInit::~PwMInit() 91PwMInit::~PwMInit()
90{ 92{
91 //qDebug("PwMInit::~PwMInit() "); 93 //qDebug("PwMInit::~PwMInit() ");
92#ifndef PWM_EMBEDDED 94#ifndef PWM_EMBEDDED
93 SelfTest::cancel(); 95 SelfTest::cancel();
94 // close all open mainwnds 96 // close all open mainwnds
95 QValueList<PwM *>::iterator i = _mainWndList.begin(), 97 Q3ValueList<PwM *>::iterator i = _mainWndList.begin(),
96 end = _mainWndList.end(); 98 end = _mainWndList.end();
97 99
98#else 100#else
99 // close all open mainwnds 101 // close all open mainwnds
100 QValueList<PwM *>::Iterator i = _mainWndList.begin(), 102 Q3ValueList<PwM *>::Iterator i = _mainWndList.begin(),
101 end = _mainWndList.end(); 103 end = _mainWndList.end();
102#endif 104#endif
103 while (i != end) { 105 while (i != end) {
104 disconnect(*i, SIGNAL(closed(PwM *)), 106 disconnect(*i, SIGNAL(closed(PwM *)),
105 this, SLOT(mainWndClosed(PwM *))); 107 this, SLOT(mainWndClosed(PwM *)));
106 delete *i; 108 delete *i;
107 ++i; 109 ++i;
108 } 110 }
109 _mainWndList.clear(); 111 _mainWndList.clear();
110 // close all remaining open documents 112 // close all remaining open documents
111 PwMDocList *_dl = PwMDoc::getOpenDocList(); 113 PwMDocList *_dl = PwMDoc::getOpenDocList();
112 vector<PwMDocList::listItem> dl = *(_dl->getList()); 114 vector<PwMDocList::listItem> dl = *(_dl->getList());
113 vector<PwMDocList::listItem>::iterator i2 = dl.begin(), 115 vector<PwMDocList::listItem>::iterator i2 = dl.begin(),
114 end2 = dl.end(); 116 end2 = dl.end();
115 while (i2 != end2) { 117 while (i2 != end2) {
116 delete (*i2).doc; 118 delete (*i2).doc;
117 ++i2; 119 ++i2;
118 } 120 }
119 121
120#ifdef CONFIG_KWALLETIF 122#ifdef CONFIG_KWALLETIF
121 delete_ifnot_null(_kwalletEmu); 123 delete_ifnot_null(_kwalletEmu);
122#endif // CONFIG_KWALLETIF 124#endif // CONFIG_KWALLETIF
123#ifdef CONFIG_KEYCARD 125#ifdef CONFIG_KEYCARD
124 delete_ifnot_null(_keycard); 126 delete_ifnot_null(_keycard);
125#endif // CONFIG_KEYCARD 127#endif // CONFIG_KEYCARD
126 delete_ifnot_null(_tray); 128 delete_ifnot_null(_tray);
127 129
128 Randomizer::cleanup(); 130 Randomizer::cleanup();
129#ifndef PWM_EMBEDDED 131#ifndef PWM_EMBEDDED
130 Configuration::cleanup(); 132 Configuration::cleanup();
131#endif 133#endif
132} 134}
133 135
134void PwMInit::initializeApp() 136void PwMInit::initializeApp()
135{ 137{
136 //qDebug("PwMInit::initializeApp() "); 138 //qDebug("PwMInit::initializeApp() ");
137 PWM_ASSERT(runStatus == unknown); 139 PWM_ASSERT(runStatus == unknown);
138 runStatus = init; 140 runStatus = init;
139 initPosixSignalHandler(); 141 initPosixSignalHandler();
140 Randomizer::init(); 142 Randomizer::init();
141#ifndef PWM_EMBEDDED 143#ifndef PWM_EMBEDDED
142 Configuration::init(); 144 Configuration::init();
143#endif 145#endif
144 initDCOP(); 146 initDCOP();
145 initKWalletEmu(); 147 initKWalletEmu();
146 initKeycard(); 148 initKeycard();
147 initTray(); 149 initTray();
148 handleCmdLineArgs(); 150 handleCmdLineArgs();
149 bool openDeeplocked = false; 151 bool openDeeplocked = false;
150 if (conf()->confGlobAutostartDeepLocked() || 152 if (conf()->confGlobAutostartDeepLocked() ||
151 savedCmd.open_deeplocked) 153 savedCmd.open_deeplocked)
152 openDeeplocked = true; 154 openDeeplocked = true;
153 if ( false ){ 155 if ( false ){
154 // LR is not working 156 // LR is not working
155 //if (conf()->confWndAutoMinimizeOnStart() || 157 //if (conf()->confWndAutoMinimizeOnStart() ||
156 // savedCmd.minToTray) { 158 // savedCmd.minToTray) {
157 PwMDoc *newDoc = createDoc(); 159 PwMDoc *newDoc = createDoc();
158 //qDebug(" createDoc()"); 160 //qDebug(" createDoc()");
159 if (!newDoc->openDocUi(newDoc, 161 if (!newDoc->openDocUi(newDoc,
160 conf()->confGlobAutoStart(), 162 conf()->confGlobAutoStart(),
161 openDeeplocked)) { 163 openDeeplocked)) {
162 delete newDoc; 164 delete newDoc;
163 } 165 }
164 166
165 //US ENH for embedded devices: in the case of failure, open a document the default way 167 //US ENH for embedded devices: in the case of failure, open a document the default way
166 createMainWnd(conf()->confGlobAutoStart(), 168 createMainWnd(conf()->confGlobAutoStart(),
167 openDeeplocked, 169 openDeeplocked,
168 true, 170 true,
169 0, 171 0,
170 savedCmd.minimized); 172 savedCmd.minimized);
171 173
172 174
173 175
174 176
175 //} 177 //}
176 } else { 178 } else {
177 createMainWnd(conf()->confGlobAutoStart(), 179 createMainWnd(conf()->confGlobAutoStart(),
178 openDeeplocked, 180 openDeeplocked,
179 true, 181 true,
180 0, 182 0,
181 savedCmd.minimized); 183 savedCmd.minimized);
182 } 184 }
183 runStatus = running; 185 runStatus = running;
184} 186}
185 187
186void PwMInit::shutdownApp(int exitStatus) 188void PwMInit::shutdownApp(int exitStatus)
187{ 189{
188 190
189 191
190 PwM * iii;; 192 PwM * iii;;
191 while ( _mainWndList.count() ) { 193 while ( _mainWndList.count() ) {
192 iii = _mainWndList.first(); 194 iii = _mainWndList.first();
193 disconnect(iii, SIGNAL(closed(PwM *)), 195 disconnect(iii, SIGNAL(closed(PwM *)),
194 this, SLOT(mainWndClosed(PwM *))); 196 this, SLOT(mainWndClosed(PwM *)));
195 mainWndClosed((iii)); 197 mainWndClosed((iii));
196 } 198 }
197 199
198 printDebug(string("PwMInit::shutdownApp(") 200 printDebug(string("PwMInit::shutdownApp(")
199 + tostr(exitStatus) + ") called."); 201 + tostr(exitStatus) + ") called.");
200 PWM_ASSERT((runStatus == running) || (runStatus == init)); 202 PWM_ASSERT((runStatus == running) || (runStatus == init));
201 runStatus = shutdown; 203 runStatus = shutdown;
202 QApplication::exit(exitStatus); 204 QApplication::exit(exitStatus);
203 /* The destructor of PwMInit is called when control 205 /* The destructor of PwMInit is called when control
204 * leaves main() 206 * leaves main()
205 */ 207 */
206} 208}
207 209
208void PwMInit::initPosixSignalHandler() 210void PwMInit::initPosixSignalHandler()
209{ 211{
210 signal(SIGINT, sig_handler); 212 signal(SIGINT, sig_handler);
211 signal(SIGTERM, sig_handler); 213 signal(SIGTERM, sig_handler);
212} 214}
213 215
214void PwMInit::initDCOP() 216void PwMInit::initDCOP()
215{ 217{
216#ifndef PWM_EMBEDDED 218#ifndef PWM_EMBEDDED
217 _dcopClient = app->dcopClient(); 219 _dcopClient = app->dcopClient();
218 _dcopClient->setNotifications(true); 220 _dcopClient->setNotifications(true);
219#endif 221#endif
220 222
221} 223}
222 224
223void PwMInit::initKWalletEmu(bool forceDisable, bool forceReload) 225void PwMInit::initKWalletEmu(bool forceDisable, bool forceReload)
224{ 226{
225#ifdef CONFIG_KWALLETIF 227#ifdef CONFIG_KWALLETIF
226 if (!conf()->confGlobKwalletEmu() || 228 if (!conf()->confGlobKwalletEmu() ||
227 forceDisable) { 229 forceDisable) {
228 delete_ifnot_null(_kwalletEmu); 230 delete_ifnot_null(_kwalletEmu);
229 return; 231 return;
230 } 232 }
231 try { 233 try {
232 if (_kwalletEmu && forceReload) 234 if (_kwalletEmu && forceReload)
233 delete_and_null(_kwalletEmu); 235 delete_and_null(_kwalletEmu);
234 if (!_kwalletEmu) 236 if (!_kwalletEmu)
235 _kwalletEmu = new KWalletEmu(this); 237 _kwalletEmu = new KWalletEmu(this);
236 } catch (PwMException e) { 238 } catch (PwMException e) {
237 string errMsg("initializing KWallet emulation failed. ID: "); 239 string errMsg("initializing KWallet emulation failed. ID: ");
238 errMsg += tostr(static_cast<int>(e.getId())); 240 errMsg += tostr(static_cast<int>(e.getId()));
239 errMsg += " err-message: "; 241 errMsg += " err-message: ";
240 errMsg += e.getMessage(); 242 errMsg += e.getMessage();
241 printWarn(errMsg); 243 printWarn(errMsg);
242 return; 244 return;
243 } 245 }
244#else // CONFIG_KWALLETIF 246#else // CONFIG_KWALLETIF
245 PARAM_UNUSED(forceDisable); 247 PARAM_UNUSED(forceDisable);
246 PARAM_UNUSED(forceReload); 248 PARAM_UNUSED(forceReload);
247#endif // CONFIG_KWALLETIF 249#endif // CONFIG_KWALLETIF
248} 250}
249 251
250void PwMInit::initKeycard() 252void PwMInit::initKeycard()
251{ 253{
252#ifdef CONFIG_KEYCARD 254#ifdef CONFIG_KEYCARD
253 PWM_ASSERT(!_keycard); 255 PWM_ASSERT(!_keycard);
254 _keycard = new PwMKeyCard(this); 256 _keycard = new PwMKeyCard(this);
255#endif // CONFIG_KEYCARD 257#endif // CONFIG_KEYCARD
256} 258}
257 259
258void PwMInit::initTray() 260void PwMInit::initTray()
259{ 261{
260#ifdef PWM_EMBEDDED 262#ifdef PWM_EMBEDDED
261 //US ENH : embedded version does not support a tray 263 //US ENH : embedded version does not support a tray
262 return; 264 return;
263#endif 265#endif
264 266
265 if (!conf()->confGlobTray()) { 267 if (!conf()->confGlobTray()) {
266 if (!_tray) 268 if (!_tray)
267 return; 269 return;
268 _tray->hide(); 270 _tray->hide();
269 delete_and_null(_tray); 271 delete_and_null(_tray);
270 return; 272 return;
271 } 273 }
272 if (_tray) 274 if (_tray)
273 return; 275 return;
274 _tray = new PwMTray(this); 276 _tray = new PwMTray(this);
275 connect(_tray, SIGNAL(quitSelected()), 277 connect(_tray, SIGNAL(quitSelected()),
276 this, SLOT(removeTrayAndQuit())); 278 this, SLOT(removeTrayAndQuit()));
277 connect(_tray, SIGNAL(closed(PwMTray *)), 279 connect(_tray, SIGNAL(closed(PwMTray *)),
278 this, SLOT(trayIconClosed(PwMTray *))); 280 this, SLOT(trayIconClosed(PwMTray *)));
279 KIconLoader icons; 281 KIconLoader icons;
280#ifndef PWM_EMBEDDED 282#ifndef PWM_EMBEDDED
281 _tray->setPixmap(icons.loadIcon(PACKAGE_NAME, KIcon::Small)); 283 _tray->setPixmap(icons.loadIcon(PACKAGE_NAME, KIcon::Small));
282#endif 284#endif
283 _tray->show(); 285 _tray->show();
284 // connect the signals of all open documents. 286 // connect the signals of all open documents.
285 const vector<PwMDocList::listItem> *dl = PwMDoc::getOpenDocList()->getList(); 287 const vector<PwMDocList::listItem> *dl = PwMDoc::getOpenDocList()->getList();
286 vector<PwMDocList::listItem>::const_iterator i = dl->begin(), 288 vector<PwMDocList::listItem>::const_iterator i = dl->begin(),
287 end = dl->end(); 289 end = dl->end();
288 while (i != end) { 290 while (i != end) {
289 _tray->connectDocToTray((*i).doc); 291 _tray->connectDocToTray((*i).doc);
290 ++i; 292 ++i;
291 } 293 }
292} 294}
293 295
294void PwMInit::removeTrayAndQuit() 296void PwMInit::removeTrayAndQuit()
295{ 297{
296 PWM_ASSERT(_tray); 298 PWM_ASSERT(_tray);
297 // _tray is deleted in ~PwMInit 299 // _tray is deleted in ~PwMInit
298 shutdownApp(0); 300 shutdownApp(0);
299} 301}
300 302
301PwM * PwMInit::createMainWnd(const QString &loadFile, 303PwM * PwMInit::createMainWnd(const QString &loadFile,
302 bool loadFileDeepLocked, 304 bool loadFileDeepLocked,
303 bool virginity, 305 bool virginity,
304 PwMDoc *doc, 306 PwMDoc *doc,
305 bool minimized) 307 bool minimized)
306{ 308{
307 PwM *newWnd; 309 PwM *newWnd;
308 if (!doc) 310 if (!doc)
309 doc = createDoc(); 311 doc = createDoc();
310 newWnd = new PwM(this, doc, virginity); 312 newWnd = new PwM(this, doc, virginity);
311#ifndef PWM_EMBEDDED 313#ifndef PWM_EMBEDDED
312 _mainWndList.push_back(newWnd); 314 _mainWndList.push_back(newWnd);
313#else 315#else
314 _mainWndList.append(newWnd); 316 _mainWndList.append(newWnd);
315#endif 317#endif
316 connect(newWnd, SIGNAL(closed(PwM *)), 318 connect(newWnd, SIGNAL(closed(PwM *)),
317 this, SLOT(mainWndClosed(PwM *))); 319 this, SLOT(mainWndClosed(PwM *)));
318 connect(newWnd, SIGNAL(gotFocus(PwM *)), 320 connect(newWnd, SIGNAL(gotFocus(PwM *)),
319 this, SLOT(setCurWidget(PwM *))); 321 this, SLOT(setCurWidget(PwM *)));
320 connect(newWnd, SIGNAL(lostFocus(PwM *)), 322 connect(newWnd, SIGNAL(lostFocus(PwM *)),
321 this, SLOT(resetCurWidget())); 323 this, SLOT(resetCurWidget()));
322 324
323 //US ENH 325 //US ENH
324#ifndef PWM_EMBEDDED 326#ifndef PWM_EMBEDDED
325 if (minimized) 327 if (minimized)
326 newWnd->showMinimized(); 328 newWnd->showMinimized();
327 else 329 else
328 newWnd->show(); 330 newWnd->show();
329 331
330#else //PWM_EMBEDDED 332#else //PWM_EMBEDDED
331 333
332#ifndef DESKTOP_VERSION 334#ifndef DESKTOP_VERSION
333 app->showMainWidget( newWnd ); 335 app->showMainWidget( newWnd );
334#else //DESKTOP_VERSION 336#else //DESKTOP_VERSION
335 newWnd->resize (640, 480 ); 337 newWnd->resize (640, 480 );
336 newWnd->show(); 338 newWnd->show();
337#endif //DESKTOP_VERSION 339#endif //DESKTOP_VERSION
338 340
339#endif //PWM_EMBEDDED 341#endif //PWM_EMBEDDED
340 342
341 if (loadFile != QString::null && 343 if (loadFile != QString::null &&
342 loadFile != "") { 344 loadFile != "") {
343 newWnd->openDoc(loadFile, loadFileDeepLocked); 345 newWnd->openDoc(loadFile, loadFileDeepLocked);
344 } 346 }
345 return newWnd; 347 return newWnd;
346} 348}
347 349
348PwMDoc * PwMInit::createDoc() 350PwMDoc * PwMInit::createDoc()
349{ 351{
350 PwMDoc *doc = new PwMDoc(this); 352 PwMDoc *doc = new PwMDoc(this);
351#ifdef CONFIG_KEYCARD 353#ifdef CONFIG_KEYCARD
352 doc->setPwMKeyCard(keycard()); 354 doc->setPwMKeyCard(keycard());
353#endif 355#endif
354#ifdef CONFIG_KWALLETIF 356#ifdef CONFIG_KWALLETIF
355 if (kwalletEmu()) 357 if (kwalletEmu())
356 kwalletEmu()->connectDocSignals(doc); 358 kwalletEmu()->connectDocSignals(doc);
357#endif 359#endif
358 360
359 if (_tray) 361 if (_tray)
360 _tray->connectDocToTray(doc); 362 _tray->connectDocToTray(doc);
361 363
362 return doc; 364 return doc;
363 365
364} 366}
365 367
366void PwMInit::mainWndClosed(PwM *wnd) 368void PwMInit::mainWndClosed(PwM *wnd)
367{ 369{
368 bool doMinimizeToTray = false; 370 bool doMinimizeToTray = false;
369 bool doDeleteDoc = false; 371 bool doDeleteDoc = false;
370#ifndef PWM_EMBEDDED 372#ifndef PWM_EMBEDDED
371 dcopClient()->suspend(); 373 dcopClient()->suspend();
372 dcopClient()->setAcceptCalls(false); 374 dcopClient()->setAcceptCalls(false);
373#endif 375#endif
374again: 376again:
375 377
376 if (wnd->isForceMinimizeToTray()) { 378 if (wnd->isForceMinimizeToTray()) {
377 if (unlikely(!_tray)) { 379 if (unlikely(!_tray)) {
378 /* This should not happen! If we set forceMinimizeToTray , 380 /* This should not happen! If we set forceMinimizeToTray ,
379 * we must be sure that _tray exists. 381 * we must be sure that _tray exists.
380 */ 382 */
381 BUG(); 383 BUG();
382 wnd->setForceMinimizeToTray(false); 384 wnd->setForceMinimizeToTray(false);
383 goto again; 385 goto again;
384 } 386 }
385 doMinimizeToTray = true; 387 doMinimizeToTray = true;
386 } else { 388 } else {
387 // Ask to minimize to tray. If not, delete doc. 389 // Ask to minimize to tray. If not, delete doc.
388 if (_tray && 390 if (_tray &&
389 runStatus != shutdown && 391 runStatus != shutdown &&
390 !wnd->isForceQuit() && 392 !wnd->isForceQuit() &&
391 !wnd->curDoc()->isDeleted()) { 393 !wnd->curDoc()->isDeleted()) {
392 if (conf()->confWndClose()) 394 if (conf()->confWndClose())
393 doDeleteDoc = true; 395 doDeleteDoc = true;
394 else 396 else
395 doMinimizeToTray = true; 397 doMinimizeToTray = true;
396 } else { 398 } else {
397 doDeleteDoc = true; 399 doDeleteDoc = true;
398 } 400 }
399 } 401 }
400 402
401 if (doMinimizeToTray) { 403 if (doMinimizeToTray) {
402 //qDebug("doMinimizeToTray "); 404 //qDebug("doMinimizeToTray ");
403 PWM_ASSERT(_tray); 405 PWM_ASSERT(_tray);
404 int mmlock = conf()->confGlobMinimizeLock(); 406 int mmlock = conf()->confGlobMinimizeLock();
405 switch (mmlock) { 407 switch (mmlock) {
406 case 0: // don't lock anything 408 case 0: // don't lock anything
407 break; 409 break;
408 case 1: // normal lock 410 case 1: // normal lock
409 wnd->curDoc()->lockAll(true); 411 wnd->curDoc()->lockAll(true);
410 break; 412 break;
411 case 2: // deep-lock 413 case 2: // deep-lock
412 wnd->curDoc()->deepLock(); 414 wnd->curDoc()->deepLock();
413 break; 415 break;
414 default: 416 default:
415 WARN(); 417 WARN();
416 } 418 }
417 } else if (doDeleteDoc) { 419 } else if (doDeleteDoc) {
418 //qDebug("doDeleteDoc "); 420 //qDebug("doDeleteDoc ");
419 if (!wnd->curDoc()->tryDelete()) { 421 if (!wnd->curDoc()->tryDelete()) {
420 /* We failed deleting the doc, 422 /* We failed deleting the doc,
421 * so open a new window with it, again. 423 * so open a new window with it, again.
422 */ 424 */
423 createMainWnd(QString::null, false, 425 createMainWnd(QString::null, false,
424 false, wnd->curDoc()); 426 false, wnd->curDoc());
425 } 427 }
426 } 428 }
427#ifndef PWM_EMBEDDED 429#ifndef PWM_EMBEDDED
428 // find the closed window in the "mainWndList" and delete it. 430 // find the closed window in the "mainWndList" and delete it.
429 QValueList<PwM *>::iterator i = _mainWndList.begin(), 431 Q3ValueList<PwM *>::iterator i = _mainWndList.begin(),
430 end = _mainWndList.end(); 432 end = _mainWndList.end();
431#else 433#else
432 // find the closed window in the "mainWndList" and delete it. 434 // find the closed window in the "mainWndList" and delete it.
433 QValueList<PwM *>::Iterator i = _mainWndList.begin(), 435 Q3ValueList<PwM *>::Iterator i = _mainWndList.begin(),
434 end = _mainWndList.end(); 436 end = _mainWndList.end();
435#endif 437#endif
436 while (i != end) { 438 while (i != end) {
437 //qDebug("iii %x end %x wnd %x", (*i), (*end), wnd); 439 //qDebug("iii %x end %x wnd %x", (*i), (*end), wnd);
438 if (*i == wnd) { 440 if (*i == wnd) {
439#ifndef PWM_EMBEDDED 441#ifndef PWM_EMBEDDED
440 _mainWndList.erase(i); 442 _mainWndList.erase(i);
441#else 443#else
442 _mainWndList.remove(i); 444 _mainWndList.remove(i);
443#endif 445#endif
444 446
445 if ( app->mainWidget() == wnd ) { 447 if ( app->mainWidget() == wnd ) {
446 if ( _mainWndList.count() ) { 448 if ( _mainWndList.count() ) {
447#ifndef DESKTOP_VERSION 449#ifndef DESKTOP_VERSION
448 app->showMainWidget(_mainWndList.first() ); 450 app->showMainWidget(_mainWndList.first() );
449#endif //DESKTOP_VERSION 451#endif //DESKTOP_VERSION
450 452
451 } 453 }
452 } 454 }
453 delete wnd; 455 delete wnd;
454 goto out_success; 456 goto out_success;
455 } 457 }
456 ++i; 458 ++i;
457 } 459 }
458 BUG(); 460 BUG();
459out_success: 461out_success:
460#ifndef PWM_EMBEDDED 462#ifndef PWM_EMBEDDED
461 if (!_mainWndList.size()) 463 if (!_mainWndList.size())
462#else 464#else
463 if (!_mainWndList.count()) 465 if (!_mainWndList.count())
464#endif 466#endif
465 467
466 { 468 {
467 /* If there's no main window and no tray icon 469 /* If there's no main window and no tray icon
468 * left, we have no user interface, so we can 470 * left, we have no user interface, so we can
469 * shut down the application. 471 * shut down the application.
470 */ 472 */
471 if (!_tray) { 473 if (!_tray) {
472#ifndef PWM_EMBEDDED 474#ifndef PWM_EMBEDDED
473 dcopClient()->setAcceptCalls(true); 475 dcopClient()->setAcceptCalls(true);
474 dcopClient()->resume(); 476 dcopClient()->resume();
475#endif 477#endif
476 shutdownApp(0); 478 shutdownApp(0);
477 return; 479 return;
478 } 480 }
479 /* There is no widget left, so set 481 /* There is no widget left, so set
480 * _curWidget to 0 482 * _curWidget to 0
481 */ 483 */
482 resetCurWidget(); 484 resetCurWidget();
483 } 485 }
484#ifndef PWM_EMBEDDED 486#ifndef PWM_EMBEDDED
485 dcopClient()->setAcceptCalls(true); 487 dcopClient()->setAcceptCalls(true);
486 dcopClient()->resume(); 488 dcopClient()->resume();
487#endif 489#endif
488} 490}
489 491
490void PwMInit::trayIconClosed(PwMTray *tray) 492void PwMInit::trayIconClosed(PwMTray *tray)
491{ 493{
492 if (runStatus != running) 494 if (runStatus != running)
493 return; 495 return;
494 PARAM_UNUSED(tray); 496 PARAM_UNUSED(tray);
495 PWM_ASSERT(tray == _tray); 497 PWM_ASSERT(tray == _tray);
496 /* If there's no main wnd left we have to 498 /* If there's no main wnd left we have to
497 * shutdown the app (same as in mainWndClosed()) 499 * shutdown the app (same as in mainWndClosed())
498 */ 500 */
499#ifndef PWM_EMBEDDED 501#ifndef PWM_EMBEDDED
500 if (!_mainWndList.size()) 502 if (!_mainWndList.size())
501 shutdownApp(0); 503 shutdownApp(0);
502#else 504#else
503 if (!_mainWndList.count()) 505 if (!_mainWndList.count())
504 shutdownApp(0); 506 shutdownApp(0);
505#endif 507#endif
506} 508}
507 509
508void PwMInit::handleCmdLineArgs(bool initial) 510void PwMInit::handleCmdLineArgs(bool initial)
509{ 511{
510#ifndef PWM_EMBEDDED 512#ifndef PWM_EMBEDDED
511 KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); 513 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
512 PWM_ASSERT(args); 514 PWM_ASSERT(args);
513 int i, numArgs = args->count(); 515 int i, numArgs = args->count();
514 const char *curArg; 516 const char *curArg;
515 517
516 // read all cmdline options 518 // read all cmdline options
517 savedCmd.open_deeplocked = args->isSet("open-deeplocked"); 519 savedCmd.open_deeplocked = args->isSet("open-deeplocked");
518 savedCmd.minimized = args->isSet("minimized"); 520 savedCmd.minimized = args->isSet("minimized");
519 savedCmd.minToTray = args->isSet("mintray"); 521 savedCmd.minToTray = args->isSet("mintray");
520 savedCmd.skipSelfTest = args->isSet("skip-self-test"); 522 savedCmd.skipSelfTest = args->isSet("skip-self-test");
521 if (savedCmd.minimized && 523 if (savedCmd.minimized &&
522 savedCmd.minToTray) { 524 savedCmd.minToTray) {
523 printInfo(i18n("Commandline option \"--minimized\" and " 525 printInfo(i18n("Commandline option \"--minimized\" and "
524 "\"--mintray\" selected. These are incompatible. " 526 "\"--mintray\" selected. These are incompatible. "
525 "\"--mintray\" will be selected.").latin1()); 527 "\"--mintray\" will be selected.").latin1());
526 } 528 }
527 /* Iterate through all non-option arguments. 529 /* Iterate through all non-option arguments.
528 * Every non-option arg is a filename to open. 530 * Every non-option arg is a filename to open.
529 */ 531 */
530 for (i = 0; i < numArgs; ++i) { 532 for (i = 0; i < numArgs; ++i) {
531 curArg = args->arg(i); 533 curArg = args->arg(i);
532 PWM_ASSERT(curArg); 534 PWM_ASSERT(curArg);
533 if (savedCmd.minToTray) { 535 if (savedCmd.minToTray) {
534 PwMDoc *newDoc = createDoc(); 536 PwMDoc *newDoc = createDoc();
535 if (!newDoc->openDocUi(newDoc, 537 if (!newDoc->openDocUi(newDoc,
536 curArg, 538 curArg,
537 savedCmd.open_deeplocked)) { 539 savedCmd.open_deeplocked)) {
538 delete newDoc; 540 delete newDoc;
539 } 541 }
540 } else { 542 } else {
541 PwM *newInstance = createMainWnd(QString::null, 543 PwM *newInstance = createMainWnd(QString::null,
542 false, 544 false,
543 true, 545 true,
544 0, 546 0,
545 savedCmd.minimized); 547 savedCmd.minimized);
546 PwMDoc *newDoc = newInstance->openDoc(curArg, 548 PwMDoc *newDoc = newInstance->openDoc(curArg,
547 savedCmd.open_deeplocked); 549 savedCmd.open_deeplocked);
548 if (!newDoc) { 550 if (!newDoc) {
549 newInstance->setForceQuit(true); 551 newInstance->setForceQuit(true);
550 delete_and_null(newInstance); 552 delete_and_null(newInstance);
551 } 553 }
552 } 554 }
553 } 555 }
554 556
555 if (savedCmd.minToTray) { 557 if (savedCmd.minToTray) {
556 minimizeAllMainWnd(true); 558 minimizeAllMainWnd(true);
557 } else if (savedCmd.minimized) { 559 } else if (savedCmd.minimized) {
558 minimizeAllMainWnd(false); 560 minimizeAllMainWnd(false);
559 } 561 }
560 if (!savedCmd.skipSelfTest && initial) { 562 if (!savedCmd.skipSelfTest && initial) {
561 SelfTest::schedule(); 563 SelfTest::schedule();
562 } 564 }
563 args->clear(); 565 args->clear();
564#endif 566#endif
565} 567}
566 568
567void PwMInit::minimizeAllMainWnd(bool toTray) 569void PwMInit::minimizeAllMainWnd(bool toTray)
568{ 570{
569#ifndef PWM_EMBEDDED 571#ifndef PWM_EMBEDDED
570 if (!_mainWndList.size()) 572 if (!_mainWndList.size())
571 return; 573 return;
572#else 574#else
573 if (!_mainWndList.count()) 575 if (!_mainWndList.count())
574 return; 576 return;
575#endif 577#endif
576 const QValueList<PwM *> *ml = mainWndList(); 578 const Q3ValueList<PwM *> *ml = mainWndList();
577#ifndef PWM_EMBEDDED 579#ifndef PWM_EMBEDDED
578 QValueList<PwM *>::const_iterator it = ml->begin(), 580 Q3ValueList<PwM *>::const_iterator it = ml->begin(),
579 end = ml->end(); 581 end = ml->end();
580#else 582#else
581 QValueList<PwM *>::ConstIterator it = ml->begin(), 583 Q3ValueList<PwM *>::ConstIterator it = ml->begin(),
582 end = ml->end(); 584 end = ml->end();
583#endif 585#endif
584 PwM *wnd; 586 PwM *wnd;
585 if (toTray && _tray) { 587 if (toTray && _tray) {
586 /* minimize to tray. 588 /* minimize to tray.
587 * close all mainWnd. 589 * close all mainWnd.
588 */ 590 */
589 while (it != end) { 591 while (it != end) {
590 wnd = *it; 592 wnd = *it;
591 wnd->setForceMinimizeToTray(true); 593 wnd->setForceMinimizeToTray(true);
592 wnd->close_slot(); 594 wnd->close_slot();
593 ++it; 595 ++it;
594 } 596 }
595 } else { 597 } else {
596 // normal minimize 598 // normal minimize
597 while (it != end) { 599 while (it != end) {
598 wnd = *it; 600 wnd = *it;
599 wnd->hide(); 601 wnd->hide();
600 wnd->showMinimized(); 602 wnd->showMinimized();
601 ++it; 603 ++it;
602 } 604 }
603 } 605 }
604} 606}
605 607
606#ifdef PWM_EMBEDDED 608#ifdef PWM_EMBEDDED
607 609
608#ifndef DESKTOP_VERSION 610#ifndef DESKTOP_VERSION
609 611
610PwMApplication::PwMApplication(int & argc, char ** argv) 612PwMApplication::PwMApplication(int & argc, char ** argv)
611 : QPEApplication( argc, argv ) 613 : QPEApplication( argc, argv )
612 , init (0) 614 , init (0)
613{ 615{
614 this->setKeepRunning (); 616 this->setKeepRunning ();
615} 617}
616 618
617PwMApplication::~PwMApplication() 619PwMApplication::~PwMApplication()
618{ 620{
619 delete_ifnot_null(init); 621 delete_ifnot_null(init);
620} 622}
621#else //DESKTOP_VERSION 623#else //DESKTOP_VERSION
622 624
623PwMApplication::PwMApplication(int & argc, char ** argv) 625PwMApplication::PwMApplication(int & argc, char ** argv)
624 : QApplication( argc, argv ) 626 : QApplication( argc, argv )
625 , init (0) 627 , init (0)
626{ 628{
627 setStyle( new QPlatinumStyle ());
628 QString hdir = QDir::homeDirPath(); 629 QString hdir = QDir::homeDirPath();
629 // there is a bug when creating dirs for WIN 98 630 // there is a bug when creating dirs for WIN 98
630 // it is difficult to fix, because we have no WIN 98 runnung 631 // it is difficult to fix, because we have no WIN 98 runnung
631 // such that we try it to create the dirs at startup here 632 // such that we try it to create the dirs at startup here
632 if ( hdir == "C:\\" ) 633 if ( hdir == "C:\\" )
633 { 634 {
634 // win 98 or ME 635 // win 98 or ME
635 QDir app_dir; 636 QDir app_dir;
636 if ( !app_dir.exists("C:\\kdepim") ) 637 if ( !app_dir.exists("C:\\kdepim") )
637 app_dir.mkdir ("C:\\kdepim"); 638 app_dir.mkdir ("C:\\kdepim");
638 if ( !app_dir.exists("C:\\kdepim\\apps") ) 639 if ( !app_dir.exists("C:\\kdepim\\apps") )
639 app_dir.mkdir ("C:\\kdepim\\apps"); 640 app_dir.mkdir ("C:\\kdepim\\apps");
640 if ( !app_dir.exists("C:\\kdepim\\config") ) 641 if ( !app_dir.exists("C:\\kdepim\\config") )
641 app_dir.mkdir ("C:\\kdepim\\config"); 642 app_dir.mkdir ("C:\\kdepim\\config");
642 if ( !app_dir.exists("C:\\kdepim\\apps\\pwmanager") ) 643 if ( !app_dir.exists("C:\\kdepim\\apps\\pwmanager") )
643 app_dir.mkdir ("C:\\kdepim\\apps\\pwmanager"); 644 app_dir.mkdir ("C:\\kdepim\\apps\\pwmanager");
644 } 645 }
645} 646}
646 647
647PwMApplication::~PwMApplication() 648PwMApplication::~PwMApplication()
648{ 649{
649 delete_ifnot_null(init); 650 delete_ifnot_null(init);
650} 651}
651 652
652#endif //DESKTOP_VERSION 653#endif //DESKTOP_VERSION
653 654
654#endif //PWM_EMBEDDED 655#endif //PWM_EMBEDDED
655 656
656 657
657 658
658 659
659#ifndef PWM_EMBEDDED 660#ifndef PWM_EMBEDDED_
660#include "pwminit.moc" 661#include "moc_pwminit.cpp"
661#endif 662#endif
diff --git a/pwmanager/pwmanager/pwminit.h b/pwmanager/pwmanager/pwminit.h
index bf72093..32d1b4f 100644
--- a/pwmanager/pwmanager/pwminit.h
+++ b/pwmanager/pwmanager/pwminit.h
@@ -1,222 +1,221 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 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 __PWMINIT_H 20#ifndef __PWMINIT_H
21#define __PWMINIT_H 21#define __PWMINIT_H
22 22
23#include <qvaluelist.h> 23#include <q3valuelist.h>
24#include <qobject.h> 24#include <qobject.h>
25#ifndef PWM_EMBEDDED 25#ifndef PWM_EMBEDDED
26#include <kuniqueapplication.h> 26#include <kuniqueapplication.h>
27#else //PWM_EMBEDDED 27#else //PWM_EMBEDDED
28 28
29#ifndef DESKTOP_VERSION 29#ifndef DESKTOP_VERSION
30#include <qpe/qpeapplication.h> 30#include <qpe/qpeapplication.h>
31#else //DESKTOP_VERSION 31#else //DESKTOP_VERSION
32#include <qapplication.h> 32#include <qapplication.h>
33#include <qplatinumstyle.h>
34#endif //DESKTOP_VERSION 33#endif //DESKTOP_VERSION
35 34
36#include <kapplication.h> 35#include <kapplication.h>
37#endif //PWM_EMBEDDED 36#endif //PWM_EMBEDDED
38 37
39#include "globalstuff.h" 38#include "globalstuff.h"
40 39
41class DCOPClient; 40class DCOPClient;
42class KWalletEmu; 41class KWalletEmu;
43class PwMKeyCard; 42class PwMKeyCard;
44class KApplication; 43class KApplication;
45class QWidget; 44class QWidget;
46class PwM; 45class PwM;
47class PwMTray; 46class PwMTray;
48class PwMDoc; 47class PwMDoc;
49class PwMInit; 48class PwMInit;
50 49
51/** main application class */ 50/** main application class */
52#ifndef PWM_EMBEDDED 51#ifndef PWM_EMBEDDED
53//MOC_SKIP_BEGIN 52#ifndef Q_MOC_RUN
54class PwMApplication : public KUniqueApplication 53class PwMApplication : public KUniqueApplication
55{ 54{
56public: 55public:
57 PwMApplication(bool allowStyles=true, 56 PwMApplication(bool allowStyles=true,
58 bool GUIenabled=true, 57 bool GUIenabled=true,
59 bool configUnique=false) 58 bool configUnique=false)
60 : KUniqueApplication(allowStyles, GUIenabled, configUnique) 59 : KUniqueApplication(allowStyles, GUIenabled, configUnique)
61 , init (0) 60 , init (0)
62 { } 61 { }
63 ~PwMApplication() 62 ~PwMApplication()
64 { delete_ifnot_null(init); } 63 { delete_ifnot_null(init); }
65 64
66 int newInstance(); 65 int newInstance();
67 66
68protected: 67protected:
69 PwMInit *init; 68 PwMInit *init;
70}; 69};
71//MOC_SKIP_END 70#endif
72#else //PWM_EMBEDDED 71#else //PWM_EMBEDDED
73 72
74#ifndef DESKTOP_VERSION 73#ifndef DESKTOP_VERSION
75class PwMApplication : public QPEApplication 74class PwMApplication : public QPEApplication
76{ 75{
77public: 76public:
78 PwMApplication(int & argc, char ** argv); 77 PwMApplication(int & argc, char ** argv);
79 ~PwMApplication(); 78 ~PwMApplication();
80 79
81 int newInstance(); 80 int newInstance();
82 81
83protected: 82protected:
84 PwMInit *init; 83 PwMInit *init;
85}; 84};
86#else //DESKTOP_VERSION 85#else //DESKTOP_VERSION
87 86
88class PwMApplication : public QApplication 87class PwMApplication : public QApplication
89{ 88{
90public: 89public:
91 PwMApplication(int & argc, char ** argv); 90 PwMApplication(int & argc, char ** argv);
92 ~PwMApplication(); 91 ~PwMApplication();
93 92
94 int newInstance(); 93 int newInstance();
95 94
96protected: 95protected:
97 PwMInit *init; 96 PwMInit *init;
98}; 97};
99 98
100#endif 99#endif
101#endif 100#endif
102 101
103/** PwManager initialisation class. 102/** PwManager initialisation class.
104 * This class sets up a new instance of PwManager and finally 103 * This class sets up a new instance of PwManager and finally
105 * starts the user interface. 104 * starts the user interface.
106 */ 105 */
107class PwMInit : public QObject 106class PwMInit : public QObject
108{ 107{
109 Q_OBJECT 108 Q_OBJECT
110 friend class PwMApplication; 109 friend class PwMApplication;
111 110
112protected: 111protected:
113 enum RunStatus 112 enum RunStatus
114 { 113 {
115 unknown, 114 unknown,
116 init, 115 init,
117 running, 116 running,
118 shutdown, 117 shutdown,
119 }; 118 };
120 119
121 /* saved command line options. */ 120 /* saved command line options. */
122 class savedCmd_t 121 class savedCmd_t
123 { 122 {
124 public: 123 public:
125 bool open_deeplocked; 124 bool open_deeplocked;
126 bool minimized; 125 bool minimized;
127 bool minToTray; 126 bool minToTray;
128 bool skipSelfTest; 127 bool skipSelfTest;
129 // initial open paths are not saved here. 128 // initial open paths are not saved here.
130 }; 129 };
131 130
132public: 131public:
133 PwMInit(PwMApplication *_app); 132 PwMInit(PwMApplication *_app);
134 ~PwMInit(); 133 ~PwMInit();
135 134
136 /** Initialize the application. */ 135 /** Initialize the application. */
137 void initializeApp(); 136 void initializeApp();
138 /** shutdown PwManager */ 137 /** shutdown PwManager */
139 void shutdownApp(int exitStatus); 138 void shutdownApp(int exitStatus);
140 139
141 /** returns a pointer to the current widget */ 140 /** returns a pointer to the current widget */
142 QWidget * curWidget() 141 QWidget * curWidget()
143 { return _curWidget; } 142 { return _curWidget; }
144 /** returns a pointer to the dcop client */ 143 /** returns a pointer to the dcop client */
145 DCOPClient * dcopClient() 144 DCOPClient * dcopClient()
146 { return _dcopClient; } 145 { return _dcopClient; }
147 /** returns a pointer to the KWallet emulation */ 146 /** returns a pointer to the KWallet emulation */
148 KWalletEmu * kwalletEmu() 147 KWalletEmu * kwalletEmu()
149 { return _kwalletEmu; } 148 { return _kwalletEmu; }
150 /** returns a pointer to the keycard interface */ 149 /** returns a pointer to the keycard interface */
151 PwMKeyCard * keycard() 150 PwMKeyCard * keycard()
152 { return _keycard; } 151 { return _keycard; }
153 /** returns a pointer to the tray icon */ 152 /** returns a pointer to the tray icon */
154 PwMTray * tray() 153 PwMTray * tray()
155 { return _tray; } 154 { return _tray; }
156 /** returns a list of all open main windows */ 155 /** returns a list of all open main windows */
157 const QValueList<PwM *> * mainWndList() 156 const Q3ValueList<PwM *> * mainWndList()
158 { return &_mainWndList; } 157 { return &_mainWndList; }
159 /** create a new document */ 158 /** create a new document */
160 PwMDoc * createDoc(); 159 PwMDoc * createDoc();
161 /** create a new PwM main window */ 160 /** create a new PwM main window */
162 PwM * createMainWnd(const QString &loadFile = QString::null, 161 PwM * createMainWnd(const QString &loadFile = QString::null,
163 bool loadFileDeepLocked = false, 162 bool loadFileDeepLocked = false,
164 bool virginity = true, 163 bool virginity = true,
165 PwMDoc *doc = 0, 164 PwMDoc *doc = 0,
166 bool minimized = false); 165 bool minimized = false);
167 166
168 /** (re)initialize the KWallet emulation */ 167 /** (re)initialize the KWallet emulation */
169 void initKWalletEmu(bool forceDisable = false, bool forceReload = false); 168 void initKWalletEmu(bool forceDisable = false, bool forceReload = false);
170 /** (re)initialize the tray icon */ 169 /** (re)initialize the tray icon */
171 void initTray(); 170 void initTray();
172 171
173protected: 172protected:
174 /** initialize the DCOP connection */ 173 /** initialize the DCOP connection */
175 void initDCOP(); 174 void initDCOP();
176 /** initialize the keycard interface */ 175 /** initialize the keycard interface */
177 void initKeycard(); 176 void initKeycard();
178 /** initialize posix signal handling */ 177 /** initialize posix signal handling */
179 void initPosixSignalHandler(); 178 void initPosixSignalHandler();
180 /** handle the commandline args */ 179 /** handle the commandline args */
181 void handleCmdLineArgs(bool initial = true); 180 void handleCmdLineArgs(bool initial = true);
182 /** minimize all open mainWnds to tray (or if 181 /** minimize all open mainWnds to tray (or if
183 * no tray is present, minimize them the normal way) 182 * no tray is present, minimize them the normal way)
184 */ 183 */
185 void minimizeAllMainWnd(bool toTray); 184 void minimizeAllMainWnd(bool toTray);
186 185
187protected slots: 186protected slots:
188 /** a main window got closed */ 187 /** a main window got closed */
189 void mainWndClosed(PwM *wnd); 188 void mainWndClosed(PwM *wnd);
190 /** the tray icon got closed */ 189 /** the tray icon got closed */
191 void trayIconClosed(PwMTray *tray); 190 void trayIconClosed(PwMTray *tray);
192 /** sets _curWidget on behalf of a PwM signal */ 191 /** sets _curWidget on behalf of a PwM signal */
193 void setCurWidget(PwM *w) 192 void setCurWidget(PwM *w)
194 { _curWidget = reinterpret_cast<QWidget *>(w); } 193 { _curWidget = reinterpret_cast<QWidget *>(w); }
195 /** resets _curWidget to nothing */ 194 /** resets _curWidget to nothing */
196 void resetCurWidget() 195 void resetCurWidget()
197 { _curWidget = 0; } 196 { _curWidget = 0; }
198 /** remove the tray and quit the app */ 197 /** remove the tray and quit the app */
199 void removeTrayAndQuit(); 198 void removeTrayAndQuit();
200 199
201protected: 200protected:
202 /** run-status of the app */ 201 /** run-status of the app */
203 RunStatus runStatus; 202 RunStatus runStatus;
204 /** PwMApplication pointer */ 203 /** PwMApplication pointer */
205 PwMApplication *app; 204 PwMApplication *app;
206 /** pointer to the current widget the user is dealing with */ 205 /** pointer to the current widget the user is dealing with */
207 QWidget *_curWidget; 206 QWidget *_curWidget;
208 /** pointer to the dcop client */ 207 /** pointer to the dcop client */
209 DCOPClient *_dcopClient; 208 DCOPClient *_dcopClient;
210 /** pointer to the KWallet emulation */ 209 /** pointer to the KWallet emulation */
211 KWalletEmu *_kwalletEmu; 210 KWalletEmu *_kwalletEmu;
212 /** pointer to the keycard interface */ 211 /** pointer to the keycard interface */
213 PwMKeyCard *_keycard; 212 PwMKeyCard *_keycard;
214 /** pointer to the tray icon */ 213 /** pointer to the tray icon */
215 PwMTray *_tray; 214 PwMTray *_tray;
216 /** list of all open main windows */ 215 /** list of all open main windows */
217 QValueList<PwM *> _mainWndList; 216 Q3ValueList<PwM *> _mainWndList;
218 /** saved command line options. */ 217 /** saved command line options. */
219 savedCmd_t savedCmd; 218 savedCmd_t savedCmd;
220}; 219};
221 220
222#endif // __PWMINIT_H 221#endif // __PWMINIT_H
diff --git a/pwmanager/pwmanager/pwmprefs.h b/pwmanager/pwmanager/pwmprefs.h
index 1f6a35c..42f7c2e 100644
--- a/pwmanager/pwmanager/pwmprefs.h
+++ b/pwmanager/pwmanager/pwmprefs.h
@@ -1,166 +1,168 @@
1/* 1/*
2 This file is part of PwManager/Pi 2 This file is part of PwManager/Pi
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22 22
23 $Id$ 23 $Id$
24*/ 24*/
25 25
26#ifndef PWMPREFS_H 26#ifndef PWMPREFS_H
27#define PWMPREFS_H 27#define PWMPREFS_H
28 28
29#include <qstringlist.h> 29#include <qstringlist.h>
30#include <qsize.h> 30#include <qsize.h>
31//Added by qt3to4:
32#include <Q3ValueList>
31 33
32#include <kpimprefs.h> 34#include <kpimprefs.h>
33 35
34class KConfig; 36class KConfig;
35 37
36#define conf() PWMPrefs::instance() 38#define conf() PWMPrefs::instance()
37 39
38 40
39 41
40 42
41#define CONF_DEFAULT_PWTIMEOUT 10/* 10 sec */ 43#define CONF_DEFAULT_PWTIMEOUT 10/* 10 sec */
42#define CONF_DEFAULT_LOCKTIMEOUT 0/* 0 == disable */ 44#define CONF_DEFAULT_LOCKTIMEOUT 0/* 0 == disable */
43#define CONF_DEFAULT_TRAY false 45#define CONF_DEFAULT_TRAY false
44#define CONF_DEFAULT_UNLOCKONOPEN true 46#define CONF_DEFAULT_UNLOCKONOPEN true
45#define CONF_DEFAULT_MAINVIEWSTYLE 1/* Category List Left */ 47#define CONF_DEFAULT_MAINVIEWSTYLE 1/* Category List Left */
46#define CONF_DEFAULT_COMPRESSION 0x01/* gzip */ 48#define CONF_DEFAULT_COMPRESSION 0x01/* gzip */
47#define CONF_DEFAULT_CRYPTALGO (0x01 - 1)/* blowfish */ 49#define CONF_DEFAULT_CRYPTALGO (0x01 - 1)/* blowfish */
48#define CONF_DEFAULT_HASHALGO (0x01 - 1)/* sha1 */ 50#define CONF_DEFAULT_HASHALGO (0x01 - 1)/* sha1 */
49#define CONF_DEFAULT_AUTOMINIMIZE false 51#define CONF_DEFAULT_AUTOMINIMIZE false
50#define CONF_DEFAULT_BROWSERCOMMAND "" 52#define CONF_DEFAULT_BROWSERCOMMAND ""
51#define CONF_DEFAULT_XTERMCOMMAND "konsole -e" 53#define CONF_DEFAULT_XTERMCOMMAND "konsole -e"
52#define CONF_DEFAULT_FILEPERMISSIONS 0600 54#define CONF_DEFAULT_FILEPERMISSIONS 0600
53#define CONF_DEFAULT_MAKEFILEBACKUP false 55#define CONF_DEFAULT_MAKEFILEBACKUP false
54#define CONF_DEFAULT_AUTOSTART_DEEPL true 56#define CONF_DEFAULT_AUTOSTART_DEEPL true
55#define CONF_DEFAULT_AUTODEEPLOCK true 57#define CONF_DEFAULT_AUTODEEPLOCK true
56#define CONF_DEFAULT_KWALLETEMU false 58#define CONF_DEFAULT_KWALLETEMU false
57#define CONF_DEFAULT_MINIMIZELOCK 2/* deep-lock */ 59#define CONF_DEFAULT_MINIMIZELOCK 2/* deep-lock */
58#define CONF_DEFAULT_NEWENTRLOCKSTAT false/* new entries unlocked */ 60#define CONF_DEFAULT_NEWENTRLOCKSTAT false/* new entries unlocked */
59#define CONF_DEFAULT_WNDCLOSE true/* don't minimize to tray */ 61#define CONF_DEFAULT_WNDCLOSE true/* don't minimize to tray */
60 62
61 63
62class PWMPrefs : public KPimPrefs 64class PWMPrefs : public KPimPrefs
63{ 65{
64 public: 66 public:
65 virtual ~PWMPrefs(); 67 virtual ~PWMPrefs();
66 68
67 static PWMPrefs *instance(); 69 static PWMPrefs *instance();
68 70
69public: 71public:
70 /* functions for reading the configuration settings */ 72 /* functions for reading the configuration settings */
71 /* GLOBAL */ 73 /* GLOBAL */
72 QString confGlobAutoStart(); 74 QString confGlobAutoStart();
73 QString confGlobBrowserCommand(); 75 QString confGlobBrowserCommand();
74 QString confGlobXtermCommand(); 76 QString confGlobXtermCommand();
75 QFont confGlobEntryFont(); 77 QFont confGlobEntryFont();
76 QFont confGlobViewFont(); 78 QFont confGlobViewFont();
77 int confGlobPwTimeout(); 79 int confGlobPwTimeout();
78 int confGlobLockTimeout(); 80 int confGlobLockTimeout();
79 int confGlobCompression(); 81 int confGlobCompression();
80 int confGlobCryptAlgo(); 82 int confGlobCryptAlgo();
81 int confGlobHashAlgo(); 83 int confGlobHashAlgo();
82 int confGlobFilePermissions(); 84 int confGlobFilePermissions();
83 int confGlobMinimizeLock(); 85 int confGlobMinimizeLock();
84 bool confGlobUnlockOnOpen(); 86 bool confGlobUnlockOnOpen();
85 bool confGlobTray(); 87 bool confGlobTray();
86 bool confGlobMakeFileBackup(); 88 bool confGlobMakeFileBackup();
87 bool confGlobAutostartDeepLocked(); 89 bool confGlobAutostartDeepLocked();
88 bool confGlobAutoDeepLock(); 90 bool confGlobAutoDeepLock();
89 bool confGlobKwalletEmu(); 91 bool confGlobKwalletEmu();
90 bool confGlobNewEntrLockStat(); 92 bool confGlobNewEntrLockStat();
91 /* WND */ 93 /* WND */
92 QSize confWndMainWndSize(); 94 QSize confWndMainWndSize();
93 int confWndMainViewStyle(); 95 int confWndMainViewStyle();
94 bool confWndAutoMinimizeOnStart(); 96 bool confWndAutoMinimizeOnStart();
95 bool confWndClose(); 97 bool confWndClose();
96 98
97public: 99public:
98 /* functions for writing the configuration settings */ 100 /* functions for writing the configuration settings */
99 /* GLOBAL */ 101 /* GLOBAL */
100 void confGlobAutoStart(const QString &e); 102 void confGlobAutoStart(const QString &e);
101 void confGlobBrowserCommand(const QString &e); 103 void confGlobBrowserCommand(const QString &e);
102 void confGlobXtermCommand(const QString &e); 104 void confGlobXtermCommand(const QString &e);
103 void confGlobEntryFont(const QFont &e); 105 void confGlobEntryFont(const QFont &e);
104 void confGlobViewFont(const QFont &e); 106 void confGlobViewFont(const QFont &e);
105 void confGlobPwTimeout(int e); 107 void confGlobPwTimeout(int e);
106 void confGlobLockTimeout(int e); 108 void confGlobLockTimeout(int e);
107 void confGlobCompression(int e); 109 void confGlobCompression(int e);
108 void confGlobCryptAlgo(int e); 110 void confGlobCryptAlgo(int e);
109 void confGlobHashAlgo(int e); 111 void confGlobHashAlgo(int e);
110 112
111 void confGlobFilePermissions(int e); 113 void confGlobFilePermissions(int e);
112 void confGlobMinimizeLock(int e); 114 void confGlobMinimizeLock(int e);
113 void confGlobUnlockOnOpen(bool e); 115 void confGlobUnlockOnOpen(bool e);
114 void confGlobTray(bool e); 116 void confGlobTray(bool e);
115 void confGlobMakeFileBackup(bool e); 117 void confGlobMakeFileBackup(bool e);
116 void confGlobAutostartDeepLocked(bool e); 118 void confGlobAutostartDeepLocked(bool e);
117 void confGlobAutoDeepLock(bool e); 119 void confGlobAutoDeepLock(bool e);
118 void confGlobKwalletEmu(bool e); 120 void confGlobKwalletEmu(bool e);
119 void confGlobNewEntrLockStat(bool e); 121 void confGlobNewEntrLockStat(bool e);
120 /* WND */ 122 /* WND */
121 void confWndMainWndSize(const QSize &e); 123 void confWndMainWndSize(const QSize &e);
122 void confWndMainViewStyle(int e); 124 void confWndMainViewStyle(int e);
123 void confWndAutoMinimizeOnStart(bool e); 125 void confWndAutoMinimizeOnStart(bool e);
124 void confWndClose(bool e); 126 void confWndClose(bool e);
125 127
126 128
127 129
128 QString mAutoStart; 130 QString mAutoStart;
129 QString mBrowserCommand; 131 QString mBrowserCommand;
130 QString mXTermCommand; 132 QString mXTermCommand;
131 QFont mEntryFont; 133 QFont mEntryFont;
132 QFont mViewFont; 134 QFont mViewFont;
133 int mPwTimeout; 135 int mPwTimeout;
134 int mLockTimeout; 136 int mLockTimeout;
135 int mCompression; 137 int mCompression;
136 int mCryptAlgo; 138 int mCryptAlgo;
137 int mHashAlgo; 139 int mHashAlgo;
138 int mFilePermissions; 140 int mFilePermissions;
139 int mMinimizeLock; 141 int mMinimizeLock;
140 bool mUnlockOnOpen; 142 bool mUnlockOnOpen;
141 bool mTray; 143 bool mTray;
142 bool mMakeFileBackup; 144 bool mMakeFileBackup;
143 bool mAutostartDeeplocked; 145 bool mAutostartDeeplocked;
144 bool mAutoDeeplock; 146 bool mAutoDeeplock;
145 bool mKWalletEmu; 147 bool mKWalletEmu;
146 bool mNewEntrLockStat; 148 bool mNewEntrLockStat;
147 QSize mMainWndSize; 149 QSize mMainWndSize;
148 int mMainViewStyle; 150 int mMainViewStyle;
149 bool mAutoMinimizeOnStart; 151 bool mAutoMinimizeOnStart;
150 bool mClose; 152 bool mClose;
151 153
152 //US ENH 154 //US ENH
153 QValueList<int> mCommentSplitter; 155 Q3ValueList<int> mCommentSplitter;
154 QValueList<int> mCategorySplitter; 156 Q3ValueList<int> mCategorySplitter;
155 157
156 158
157 // US introduce a nonconst way to return the config object. 159 // US introduce a nonconst way to return the config object.
158 KConfig* getConfig(); 160 KConfig* getConfig();
159 161
160 private: 162 private:
161 PWMPrefs(); 163 PWMPrefs();
162 164
163 static PWMPrefs *sInstance; 165 static PWMPrefs *sInstance;
164}; 166};
165 167
166#endif 168#endif
diff --git a/pwmanager/pwmanager/pwmtray.cpp b/pwmanager/pwmanager/pwmtray.cpp
index fe074ca..478116f 100644
--- a/pwmanager/pwmanager/pwmtray.cpp
+++ b/pwmanager/pwmanager/pwmtray.cpp
@@ -1,486 +1,489 @@
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 * Original implementation of the tray-tree * 6 * Original implementation of the tray-tree *
7 * (c) by Matt Scifo <mscifo@o1.com> * 7 * (c) by Matt Scifo <mscifo@o1.com> *
8 * * 8 * *
9 * This program is free software; you can redistribute it and/or modify * 9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License version 2 * 10 * it under the terms of the GNU General Public License version 2 *
11 * as published by the Free Software Foundation. * 11 * as published by the Free Software Foundation. *
12 * * 12 * *
13 ***************************************************************************/ 13 ***************************************************************************/
14 14
15/*************************************************************************** 15/***************************************************************************
16 * copyright (C) 2004 by Ulf Schenk 16 * copyright (C) 2004 by Ulf Schenk
17 * This file is originaly based on version 1.0.1 of pwmanager 17 * This file is originaly based on version 1.0.1 of pwmanager
18 * and was modified to run on embedded devices that run microkde 18 * and was modified to run on embedded devices that run microkde
19 * 19 *
20 * $Id$ 20 * $Id$
21 **************************************************************************/ 21 **************************************************************************/
22 22
23#include "pwmtray.h" 23#include "pwmtray.h"
24#include "pwmexception.h" 24#include "pwmexception.h"
25#include "pwm.h" 25#include "pwm.h"
26#include "pwmdoc.h" 26#include "pwmdoc.h"
27#include "pwminit.h" 27#include "pwminit.h"
28#ifndef PWM_EMBEDDED 28#ifndef PWM_EMBEDDED
29#include "configuration.h" 29#include "configuration.h"
30#else 30#else
31#include "pwmprefs.h" 31#include "pwmprefs.h"
32#endif 32#endif
33 33
34#include <klocale.h> 34#include <klocale.h>
35//Added by qt3to4:
36#include <Q3ValueList>
37#include <QMouseEvent>
35 38
36 39
37void ActiveTreeItem::execIt() 40void ActiveTreeItem::execIt()
38{ 41{
39#ifndef PWM_EMBEDDED 42#ifndef PWM_EMBEDDED
40 unsigned int entr = static_cast<unsigned int>(entry); 43 unsigned int entr = static_cast<unsigned int>(entry);
41 unsigned int cat = static_cast<unsigned int>(category); 44 unsigned int cat = static_cast<unsigned int>(category);
42#else 45#else
43 unsigned int entr = (unsigned int)(entry); 46 unsigned int entr = (unsigned int)(entry);
44 unsigned int cat = (unsigned int)(category); 47 unsigned int cat = (unsigned int)(category);
45#endif 48#endif
46 switch (task) { 49 switch (task) {
47 case pwToClipboard: { 50 case pwToClipboard: {
48 PwMDataItem d; 51 PwMDataItem d;
49 doc->getDataChangedLock(); 52 doc->getDataChangedLock();
50 bool wasLocked = doc->isLocked(cat, entr); 53 bool wasLocked = doc->isLocked(cat, entr);
51 doc->getEntry(cat, entr, &d, true); 54 doc->getEntry(cat, entr, &d, true);
52 if (wasLocked) 55 if (wasLocked)
53 doc->lockAt(cat, entr, true); 56 doc->lockAt(cat, entr, true);
54 doc->putDataChangedLock(); 57 doc->putDataChangedLock();
55 PwM::copyToClipboard(d.pw.c_str()); 58 PwM::copyToClipboard(d.pw.c_str());
56 break; 59 break;
57 } case nameToClipboard: { 60 } case nameToClipboard: {
58 PwMDataItem d; 61 PwMDataItem d;
59 doc->getEntry(cat, entr, &d); 62 doc->getEntry(cat, entr, &d);
60 PwM::copyToClipboard(d.name.c_str()); 63 PwM::copyToClipboard(d.name.c_str());
61 break; 64 break;
62 } case descToClipboard: { 65 } case descToClipboard: {
63 PwMDataItem d; 66 PwMDataItem d;
64 doc->getEntry(cat, entr, &d); 67 doc->getEntry(cat, entr, &d);
65 PwM::copyToClipboard(d.desc.c_str()); 68 PwM::copyToClipboard(d.desc.c_str());
66 break; 69 break;
67 } case urlToClipboard: { 70 } case urlToClipboard: {
68 PwMDataItem d; 71 PwMDataItem d;
69 doc->getEntry(cat, entr, &d); 72 doc->getEntry(cat, entr, &d);
70 PwM::copyToClipboard(d.url.c_str()); 73 PwM::copyToClipboard(d.url.c_str());
71 break; 74 break;
72 } case launcherToClipboard: { 75 } case launcherToClipboard: {
73 PwMDataItem d; 76 PwMDataItem d;
74 doc->getEntry(cat, entr, &d); 77 doc->getEntry(cat, entr, &d);
75 PwM::copyToClipboard(d.launcher.c_str()); 78 PwM::copyToClipboard(d.launcher.c_str());
76 break; 79 break;
77 } case commentToClipboard: { 80 } case commentToClipboard: {
78 PwMDataItem d; 81 PwMDataItem d;
79 doc->getEntry(cat, entr, &d); 82 doc->getEntry(cat, entr, &d);
80 PwM::copyToClipboard(d.comment.c_str()); 83 PwM::copyToClipboard(d.comment.c_str());
81 break; 84 break;
82 } case execLauncher: { 85 } case execLauncher: {
83 doc->execLauncher(cat, entr); 86 doc->execLauncher(cat, entr);
84 break; 87 break;
85 } case goToURL: { 88 } case goToURL: {
86 doc->goToURL(cat, entr); 89 doc->goToURL(cat, entr);
87 break; 90 break;
88 } case openMainWnd: { 91 } case openMainWnd: {
89 // search if there is already an open window. 92 // search if there is already an open window.
90 const QValueList<PwM *> *wl = tray->init->mainWndList(); 93 const Q3ValueList<PwM *> *wl = tray->init->mainWndList();
91#ifndef PWM_EMBEDDED 94#ifndef PWM_EMBEDDED
92 QValueList<PwM *>::const_iterator i = wl->begin(), 95 Q3ValueList<PwM *>::const_iterator i = wl->begin(),
93 end = wl->end(); 96 end = wl->end();
94#else 97#else
95 QValueList<PwM *>::ConstIterator i = wl->begin(), 98 Q3ValueList<PwM *>::ConstIterator i = wl->begin(),
96 end = wl->end(); 99 end = wl->end();
97#endif 100#endif
98 PwM *wnd; 101 PwM *wnd;
99 while (i != end) { 102 while (i != end) {
100 wnd = *i; 103 wnd = *i;
101 if (wnd->curDoc() == doc) { 104 if (wnd->curDoc() == doc) {
102 // now bring this window to the foreground. 105 // now bring this window to the foreground.
103 if (!wnd->hasFocus()) { 106 if (!wnd->hasFocus()) {
104 wnd->hide(); 107 wnd->hide();
105 wnd->showNormal(); 108 wnd->showNormal();
106 wnd->setFocus(); 109 wnd->setFocus();
107 } 110 }
108 return; 111 return;
109 } 112 }
110 ++i; 113 ++i;
111 } 114 }
112 // there is no open window, so open a new one. 115 // there is no open window, so open a new one.
113 tray->init->createMainWnd(QString::null, false, false, doc); 116 tray->init->createMainWnd(QString::null, false, false, doc);
114 break; 117 break;
115 } case closeDoc: { 118 } case closeDoc: {
116 doc->tryDelete(); 119 doc->tryDelete();
117 break; 120 break;
118 } case lock: { 121 } case lock: {
119 doc->lockAll(true); 122 doc->lockAll(true);
120 break; 123 break;
121 } case deepLock: { 124 } case deepLock: {
122 doc->deepLock(); 125 doc->deepLock();
123 break; 126 break;
124 } case unlock: { 127 } case unlock: {
125 doc->lockAll(false); 128 doc->lockAll(false);
126 break; 129 break;
127 } default: { 130 } default: {
128 BUG(); 131 BUG();
129 } 132 }
130 } 133 }
131} 134}
132 135
133 136
134 137
135#ifndef PWM_EMBEDDED 138#ifndef PWM_EMBEDDED
136PwMTray::PwMTray(PwMInit *_init, QWidget * parent, const char *name) 139PwMTray::PwMTray(PwMInit *_init, QWidget * parent, const char *name)
137 : KSystemTray(parent, name) 140 : KSystemTray(parent, name)
138#else 141#else
139PwMTray::PwMTray(PwMInit *_init, QWidget * parent, const char *name) 142PwMTray::PwMTray(PwMInit *_init, QWidget * parent, const char *name)
140 : QWidget(parent, name) 143 : QWidget(parent, name)
141#endif 144#endif
142{ 145{
143 init = _init; 146 init = _init;
144 buildMain(); 147 buildMain();
145} 148}
146 149
147PwMTray::~PwMTray() 150PwMTray::~PwMTray()
148{ 151{
149 emit closed(this); 152 emit closed(this);
150} 153}
151 154
152//US ENH for embedded tray class 155//US ENH for embedded tray class
153KPopupMenu* PwMTray::contextMenu() 156KPopupMenu* PwMTray::contextMenu()
154{ 157{
155 if (m_ctxMenu == 0) 158 if (m_ctxMenu == 0)
156 { 159 {
157 m_ctxMenu = new KPopupMenu(); 160 m_ctxMenu = new KPopupMenu();
158 } 161 }
159 162
160 return m_ctxMenu; 163 return m_ctxMenu;
161} 164}
162 165
163 166
164void PwMTray::buildMain() 167void PwMTray::buildMain()
165{ 168{
166 KPopupMenu *ctxMenu = contextMenu(); 169 KPopupMenu *ctxMenu = contextMenu();
167 170
168 ctxMenu->insertSeparator(); 171 ctxMenu->insertSeparator();
169 ctxMenu->insertItem(i18n("&New main window..."), this, 172 ctxMenu->insertItem(i18n("&New main window..."), this,
170 SLOT(newMainWnd())); 173 SLOT(newMainWnd()));
171 ctxMenu->insertItem(i18n("&Open file..."), this, 174 ctxMenu->insertItem(i18n("&Open file..."), this,
172 SLOT(openDoc())); 175 SLOT(openDoc()));
173 ctxMenu->insertSeparator(); 176 ctxMenu->insertSeparator();
174 ctxMenu->insertItem(i18n("&Remove from tray"), this, 177 ctxMenu->insertItem(i18n("&Remove from tray"), this,
175 SLOT(undock())); 178 SLOT(undock()));
176} 179}
177 180
178void PwMTray::insertActiveTreeItem(KPopupMenu *insertIn, const QString &text, 181void PwMTray::insertActiveTreeItem(KPopupMenu *insertIn, const QString &text,
179 ActiveTreeItem::Task task, PwMDoc *doc, 182 ActiveTreeItem::Task task, PwMDoc *doc,
180 int docCategory, int docEntry, 183 int docCategory, int docEntry,
181 QValueList<int> *activeItemsList) 184 Q3ValueList<int> *activeItemsList)
182{ 185{
183 ActiveTreeItem *activeItem; 186 ActiveTreeItem *activeItem;
184 int id; 187 int id;
185 188
186 activeItem = new ActiveTreeItem(text, insertIn->font(), task, 189 activeItem = new ActiveTreeItem(text, insertIn->font(), task,
187 doc, docCategory, docEntry, 190 doc, docCategory, docEntry,
188 this); 191 this);
189 id = insertIn->insertItem(activeItem); 192 id = insertIn->insertItem(activeItem);
190 insertIn->connectItem(id, activeItem, SLOT(execIt())); 193 insertIn->connectItem(id, activeItem, SLOT(execIt()));
191#ifndef PWM_EMBEDDED 194#ifndef PWM_EMBEDDED
192 activeItemsList->push_back(id); 195 activeItemsList->push_back(id);
193#else 196#else
194 activeItemsList->append(id); 197 activeItemsList->append(id);
195#endif 198#endif
196} 199}
197 200
198void PwMTray::rebuildTree(KPopupMenu *popup, PwMDoc *doc, 201void PwMTray::rebuildTree(KPopupMenu *popup, PwMDoc *doc,
199 QValueList<int> *activeItems) 202 Q3ValueList<int> *activeItems)
200{ 203{
201 PWM_ASSERT(doc); 204 PWM_ASSERT(doc);
202 PWM_ASSERT(popup); 205 PWM_ASSERT(popup);
203 activeItems->clear(); 206 activeItems->clear();
204 popup->clear(); 207 popup->clear();
205#ifndef PWM_EMBEDDED 208#ifndef PWM_EMBEDDED
206 popup->insertTitle(i18n("Categories:")); 209 popup->insertTitle(i18n("Categories:"));
207#endif 210#endif
208 vector<string> catList; 211 vector<string> catList;
209 vector<string> entrList; 212 vector<string> entrList;
210 doc->getCategoryList(&catList); 213 doc->getCategoryList(&catList);
211 KPopupMenu *newCatMenu; 214 KPopupMenu *newCatMenu;
212 KPopupMenu *newEntrMenu; 215 KPopupMenu *newEntrMenu;
213 int i, size = catList.size(); 216 int i, size = catList.size();
214 int j, entries; 217 int j, entries;
215 for (i = 0; i < size; ++i) { 218 for (i = 0; i < size; ++i) {
216 newCatMenu = new KPopupMenu(popup); 219 newCatMenu = new KPopupMenu(popup);
217 popup->insertItem(catList[i].c_str(), newCatMenu); 220 popup->insertItem(catList[i].c_str(), newCatMenu);
218 doc->getEntryList(i, &entrList); 221 doc->getEntryList(i, &entrList);
219 222
220 entries = entrList.size(); 223 entries = entrList.size();
221 for (j = 0; j < entries; ++j) { 224 for (j = 0; j < entries; ++j) {
222 newEntrMenu = new KPopupMenu(newCatMenu); 225 newEntrMenu = new KPopupMenu(newCatMenu);
223 newCatMenu->insertItem(entrList[j].c_str(), newEntrMenu); 226 newCatMenu->insertItem(entrList[j].c_str(), newEntrMenu);
224 227
225 if (doc->isBinEntry(i, j)) { 228 if (doc->isBinEntry(i, j)) {
226 /* This is a binary entry. Don't insert the usual 229 /* This is a binary entry. Don't insert the usual
227 * menu items. 230 * menu items.
228 */ 231 */
229#ifndef PWM_EMBEDDED 232#ifndef PWM_EMBEDDED
230 newEntrMenu->insertTitle(i18n("This is a binary entry.\n" 233 newEntrMenu->insertTitle(i18n("This is a binary entry.\n"
231 "It is not a normal password-entry, as it contains " 234 "It is not a normal password-entry, as it contains "
232 "binary data, which PwManager can't display here.")); 235 "binary data, which PwManager can't display here."));
233#endif 236#endif
234 continue; 237 continue;
235 } 238 }
236 239
237 insertActiveTreeItem(newEntrMenu, 240 insertActiveTreeItem(newEntrMenu,
238 i18n("copy password to clipboard"), 241 i18n("copy password to clipboard"),
239 ActiveTreeItem::pwToClipboard, doc, i, j, 242 ActiveTreeItem::pwToClipboard, doc, i, j,
240 activeItems); 243 activeItems);
241 244
242 insertActiveTreeItem(newEntrMenu, 245 insertActiveTreeItem(newEntrMenu,
243 i18n("copy username to clipboard"), 246 i18n("copy username to clipboard"),
244 ActiveTreeItem::nameToClipboard, doc, i, j, 247 ActiveTreeItem::nameToClipboard, doc, i, j,
245 activeItems); 248 activeItems);
246 249
247 insertActiveTreeItem(newEntrMenu, 250 insertActiveTreeItem(newEntrMenu,
248 i18n("copy description to clipboard"), 251 i18n("copy description to clipboard"),
249 ActiveTreeItem::descToClipboard, doc, i, j, 252 ActiveTreeItem::descToClipboard, doc, i, j,
250 activeItems); 253 activeItems);
251 254
252 insertActiveTreeItem(newEntrMenu, 255 insertActiveTreeItem(newEntrMenu,
253 i18n("copy url to clipboard"), 256 i18n("copy url to clipboard"),
254 ActiveTreeItem::urlToClipboard, doc, i, j, 257 ActiveTreeItem::urlToClipboard, doc, i, j,
255 activeItems); 258 activeItems);
256 259
257 insertActiveTreeItem(newEntrMenu, 260 insertActiveTreeItem(newEntrMenu,
258 i18n("copy launcher to clipboard"), 261 i18n("copy launcher to clipboard"),
259 ActiveTreeItem::launcherToClipboard, doc, i, j, 262 ActiveTreeItem::launcherToClipboard, doc, i, j,
260 activeItems); 263 activeItems);
261 264
262 insertActiveTreeItem(newEntrMenu, 265 insertActiveTreeItem(newEntrMenu,
263 i18n("copy comment to clipboard"), 266 i18n("copy comment to clipboard"),
264 ActiveTreeItem::commentToClipboard, doc, i, j, 267 ActiveTreeItem::commentToClipboard, doc, i, j,
265 activeItems); 268 activeItems);
266 269
267 newEntrMenu->insertSeparator(); 270 newEntrMenu->insertSeparator();
268 271
269 insertActiveTreeItem(newEntrMenu, 272 insertActiveTreeItem(newEntrMenu,
270 i18n("Execute \"Launcher\""), 273 i18n("Execute \"Launcher\""),
271 ActiveTreeItem::execLauncher, doc, i, j, 274 ActiveTreeItem::execLauncher, doc, i, j,
272 activeItems); 275 activeItems);
273 276
274 insertActiveTreeItem(newEntrMenu, 277 insertActiveTreeItem(newEntrMenu,
275 i18n("Go to \"URL\""), 278 i18n("Go to \"URL\""),
276 ActiveTreeItem::goToURL, doc, i, j, 279 ActiveTreeItem::goToURL, doc, i, j,
277 activeItems); 280 activeItems);
278 } 281 }
279 } 282 }
280 insertMainWndCtrl(popup, doc); 283 insertMainWndCtrl(popup, doc);
281} 284}
282 285
283void PwMTray::insertMainWndCtrl(KPopupMenu *menu, PwMDoc *doc) 286void PwMTray::insertMainWndCtrl(KPopupMenu *menu, PwMDoc *doc)
284{ 287{
285 ActiveTreeItem *activeItem; 288 ActiveTreeItem *activeItem;
286 int id; 289 int id;
287 290
288#ifndef PWM_EMBEDDED 291#ifndef PWM_EMBEDDED
289 menu->insertTitle(i18n("Manager:")); 292 menu->insertTitle(i18n("Manager:"));
290#endif 293#endif
291 activeItem = new ActiveTreeItem(i18n("&Open main manager window ..."), 294 activeItem = new ActiveTreeItem(i18n("&Open main manager window ..."),
292 menu->font(), ActiveTreeItem::openMainWnd, 295 menu->font(), ActiveTreeItem::openMainWnd,
293 doc, 0, 0, this); 296 doc, 0, 0, this);
294 id = menu->insertItem(activeItem); 297 id = menu->insertItem(activeItem);
295 menu->connectItem(id, activeItem, SLOT(execIt())); 298 menu->connectItem(id, activeItem, SLOT(execIt()));
296 299
297 activeItem = new ActiveTreeItem(i18n("&Close this document ..."), 300 activeItem = new ActiveTreeItem(i18n("&Close this document ..."),
298 menu->font(), ActiveTreeItem::closeDoc, 301 menu->font(), ActiveTreeItem::closeDoc,
299 doc, 0, 0, this); 302 doc, 0, 0, this);
300 id = menu->insertItem(activeItem); 303 id = menu->insertItem(activeItem);
301 menu->connectItem(id, activeItem, SLOT(execIt())); 304 menu->connectItem(id, activeItem, SLOT(execIt()));
302 305
303 menu->insertSeparator(); 306 menu->insertSeparator();
304 307
305 activeItem = new ActiveTreeItem(i18n("&Lock all entries"), 308 activeItem = new ActiveTreeItem(i18n("&Lock all entries"),
306 menu->font(), ActiveTreeItem::lock, 309 menu->font(), ActiveTreeItem::lock,
307 doc, 0, 0, this); 310 doc, 0, 0, this);
308 id = menu->insertItem(activeItem); 311 id = menu->insertItem(activeItem);
309 menu->connectItem(id, activeItem, SLOT(execIt())); 312 menu->connectItem(id, activeItem, SLOT(execIt()));
310 313
311 activeItem = new ActiveTreeItem(i18n("&Deep-lock all entries"), 314 activeItem = new ActiveTreeItem(i18n("&Deep-lock all entries"),
312 menu->font(), ActiveTreeItem::deepLock, 315 menu->font(), ActiveTreeItem::deepLock,
313 doc, 0, 0, this); 316 doc, 0, 0, this);
314 id = menu->insertItem(activeItem); 317 id = menu->insertItem(activeItem);
315 menu->connectItem(id, activeItem, SLOT(execIt())); 318 menu->connectItem(id, activeItem, SLOT(execIt()));
316 319
317 activeItem = new ActiveTreeItem(i18n("&Unlock all entries"), 320 activeItem = new ActiveTreeItem(i18n("&Unlock all entries"),
318 menu->font(), ActiveTreeItem::unlock, 321 menu->font(), ActiveTreeItem::unlock,
319 doc, 0, 0, this); 322 doc, 0, 0, this);
320 id = menu->insertItem(activeItem); 323 id = menu->insertItem(activeItem);
321 menu->connectItem(id, activeItem, SLOT(execIt())); 324 menu->connectItem(id, activeItem, SLOT(execIt()));
322} 325}
323 326
324void PwMTray::updateTree(PwMDoc *document) 327void PwMTray::updateTree(PwMDoc *document)
325{ 328{
326 PWM_ASSERT(document); 329 PWM_ASSERT(document);
327 KPopupMenu *treeEntry; 330 KPopupMenu *treeEntry;
328 int treeItemNum = -1; 331 int treeItemNum = -1;
329 int id = findTreeEntry(document, &treeEntry, &treeItemNum); 332 int id = findTreeEntry(document, &treeEntry, &treeItemNum);
330 if (id == -1) { 333 if (id == -1) {
331 // tree-entry doesn't exist, yet. 334 // tree-entry doesn't exist, yet.
332 id = insertTreeEntry(document, &treeEntry); 335 id = insertTreeEntry(document, &treeEntry);
333 } 336 }
334 if (treeItemNum != -1) { 337 if (treeItemNum != -1) {
335 // delete all *old* active items 338 // delete all *old* active items
336 KPopupMenu *ctxMenu = contextMenu(); 339 KPopupMenu *ctxMenu = contextMenu();
337 QValueList<int> *oldItems = &tree[treeItemNum].activeItems; 340 Q3ValueList<int> *oldItems = &tree[treeItemNum].activeItems;
338#ifndef PWM_EMBEDDED 341#ifndef PWM_EMBEDDED
339 QValueList<int>::iterator i = oldItems->begin(); 342 Q3ValueList<int>::iterator i = oldItems->begin();
340#else 343#else
341 QValueList<int>::Iterator i = oldItems->begin(); 344 Q3ValueList<int>::Iterator i = oldItems->begin();
342#endif 345#endif
343 while (i != oldItems->end()) { 346 while (i != oldItems->end()) {
344 ctxMenu->removeItem(*i); 347 ctxMenu->removeItem(*i);
345 ++i; 348 ++i;
346 } 349 }
347 oldItems->clear(); 350 oldItems->clear();
348 ctxMenu->changeItem(id, document->getTitle()); 351 ctxMenu->changeItem(id, document->getTitle());
349 } 352 }
350 353
351 treeItem newTreeItem; 354 treeItem newTreeItem;
352 if (document->isDeepLocked()) { 355 if (document->isDeepLocked()) {
353 treeEntry->clear(); 356 treeEntry->clear();
354 #ifndef PWM_EMBEDDED 357 #ifndef PWM_EMBEDDED
355 treeEntry->insertTitle(i18n("Categories:")); 358 treeEntry->insertTitle(i18n("Categories:"));
356#endif 359#endif
357 QString msg(IS_DEEPLOCKED_SHORTMSG); 360 QString msg(IS_DEEPLOCKED_SHORTMSG);
358 msg += " "; 361 msg += " ";
359 msg += i18n("(Click here to unlock)"); 362 msg += i18n("(Click here to unlock)");
360 treeEntry->insertItem(msg, document, 363 treeEntry->insertItem(msg, document,
361 SLOT(_deepUnlock())); 364 SLOT(_deepUnlock()));
362 insertMainWndCtrl(treeEntry, document); 365 insertMainWndCtrl(treeEntry, document);
363 } else { 366 } else {
364 rebuildTree(treeEntry, document, &newTreeItem.activeItems); 367 rebuildTree(treeEntry, document, &newTreeItem.activeItems);
365 } 368 }
366 newTreeItem.menuId = id; 369 newTreeItem.menuId = id;
367 newTreeItem.doc = document; 370 newTreeItem.doc = document;
368 newTreeItem.menu = treeEntry; 371 newTreeItem.menu = treeEntry;
369 if (treeItemNum == -1) { 372 if (treeItemNum == -1) {
370#ifndef PWM_EMBEDDED 373#ifndef PWM_EMBEDDED
371 tree.push_back(newTreeItem); 374 tree.push_back(newTreeItem);
372#else 375#else
373 tree.append(newTreeItem); 376 tree.append(newTreeItem);
374#endif 377#endif
375 } else { 378 } else {
376 tree[treeItemNum] = newTreeItem; 379 tree[treeItemNum] = newTreeItem;
377 } 380 }
378} 381}
379 382
380void PwMTray::closeTreeEntry(PwMDoc *document) 383void PwMTray::closeTreeEntry(PwMDoc *document)
381{ 384{
382 KPopupMenu *menu; 385 KPopupMenu *menu;
383 int treeItem; 386 int treeItem;
384 int id = findTreeEntry(document, &menu, &treeItem); 387 int id = findTreeEntry(document, &menu, &treeItem);
385 if (id != -1) { 388 if (id != -1) {
386 removeTreeEntry(id, treeItem, &menu); 389 removeTreeEntry(id, treeItem, &menu);
387 } 390 }
388} 391}
389 392
390int PwMTray::findTreeEntry(PwMDoc *doc, KPopupMenu **menu, int *treeItem) 393int PwMTray::findTreeEntry(PwMDoc *doc, KPopupMenu **menu, int *treeItem)
391{ 394{
392 PWM_ASSERT(doc); 395 PWM_ASSERT(doc);
393#ifndef PWM_EMBEDDED 396#ifndef PWM_EMBEDDED
394 int i, count = tree.size(); 397 int i, count = tree.size();
395#else 398#else
396 int i, count = tree.count(); 399 int i, count = tree.count();
397#endif 400#endif
398 for (i = 0; i < count; ++i) { 401 for (i = 0; i < count; ++i) {
399 if (tree[i].doc == doc) { 402 if (tree[i].doc == doc) {
400 if (menu) 403 if (menu)
401 *menu = tree[i].menu; 404 *menu = tree[i].menu;
402 if (treeItem) 405 if (treeItem)
403 *treeItem = i; 406 *treeItem = i;
404 return tree[i].menuId; 407 return tree[i].menuId;
405 } 408 }
406 } 409 }
407 if (menu) 410 if (menu)
408 *menu = 0; 411 *menu = 0;
409 if (treeItem) 412 if (treeItem)
410 *treeItem = -1; 413 *treeItem = -1;
411 return -1; 414 return -1;
412} 415}
413 416
414int PwMTray::insertTreeEntry(PwMDoc *doc, KPopupMenu **popup) 417int PwMTray::insertTreeEntry(PwMDoc *doc, KPopupMenu **popup)
415{ 418{
416 PWM_ASSERT(doc); 419 PWM_ASSERT(doc);
417 PWM_ASSERT(popup); 420 PWM_ASSERT(popup);
418 KPopupMenu *ctxMenu = contextMenu(); 421 KPopupMenu *ctxMenu = contextMenu();
419 *popup = new KPopupMenu(ctxMenu); 422 *popup = new KPopupMenu(ctxMenu);
420 return ctxMenu->insertItem(doc->getTitle(), *popup, -1, 1); 423 return ctxMenu->insertItem(doc->getTitle(), *popup, -1, 1);
421} 424}
422 425
423void PwMTray::removeTreeEntry(int menuId, int treeItem, KPopupMenu **menu) 426void PwMTray::removeTreeEntry(int menuId, int treeItem, KPopupMenu **menu)
424{ 427{
425 PWM_ASSERT(menu); 428 PWM_ASSERT(menu);
426 KPopupMenu *ctxMenu = contextMenu(); 429 KPopupMenu *ctxMenu = contextMenu();
427 ctxMenu->removeItem(menuId); 430 ctxMenu->removeItem(menuId);
428 delete_and_null(*menu); 431 delete_and_null(*menu);
429#ifndef PWM_EMBEDDED 432#ifndef PWM_EMBEDDED
430 tree.erase(tree.at(treeItem)); 433 tree.erase(tree.at(treeItem));
431#else 434#else
432 tree.remove(tree.at(treeItem)); 435 tree.remove(tree.at(treeItem));
433#endif 436#endif
434} 437}
435 438
436void PwMTray::mouseReleaseEvent(QMouseEvent *e) 439void PwMTray::mouseReleaseEvent(QMouseEvent *e)
437{ 440{
438 QWidget *curWnd = init->curWidget(); 441 QWidget *curWnd = init->curWidget();
439 KPopupMenu *ctxMenu = contextMenu(); 442 KPopupMenu *ctxMenu = contextMenu();
440 // give focus to init->curWidget() 443 // give focus to init->curWidget()
441 if (curWnd && !curWnd->hasFocus()) { 444 if (curWnd && !curWnd->hasFocus()) {
442 curWnd->hide(); 445 curWnd->hide();
443 curWnd->showNormal(); 446 curWnd->showNormal();
444 curWnd->setFocus(); 447 curWnd->setFocus();
445 } 448 }
446 // popup the context menu 449 // popup the context menu
447 ctxMenu->popup(e->globalPos()); 450 ctxMenu->popup(e->globalPos());
448 emit clickedIcon(this); 451 emit clickedIcon(this);
449} 452}
450 453
451void PwMTray::connectDocToTray(PwMDoc *doc) 454void PwMTray::connectDocToTray(PwMDoc *doc)
452{ 455{
453 connect(doc, SIGNAL(dataChanged(PwMDoc *)), 456 connect(doc, SIGNAL(dataChanged(PwMDoc *)),
454 this, SLOT(updateTree(PwMDoc *))); 457 this, SLOT(updateTree(PwMDoc *)));
455 connect(doc, SIGNAL(docClosed(PwMDoc *)), 458 connect(doc, SIGNAL(docClosed(PwMDoc *)),
456 this, SLOT(closeTreeEntry(PwMDoc *))); 459 this, SLOT(closeTreeEntry(PwMDoc *)));
457 // fake a dataChanged signal for this doc to update the tray tree. 460 // fake a dataChanged signal for this doc to update the tray tree.
458 updateTree(doc); 461 updateTree(doc);
459} 462}
460 463
461void PwMTray::openDoc() 464void PwMTray::openDoc()
462{ 465{
463 // open the document in a new window. 466 // open the document in a new window.
464 PwM *newInstance = init->createMainWnd(); 467 PwM *newInstance = init->createMainWnd();
465 PwMDoc *newDoc = newInstance->openDoc(""); 468 PwMDoc *newDoc = newInstance->openDoc("");
466 if (!newDoc) { 469 if (!newDoc) {
467 newInstance->setForceQuit(true); 470 newInstance->setForceQuit(true);
468 delete_and_null(newInstance); 471 delete_and_null(newInstance);
469 } 472 }
470} 473}
471 474
472void PwMTray::newMainWnd() 475void PwMTray::newMainWnd()
473{ 476{
474 init->createMainWnd(); 477 init->createMainWnd();
475} 478}
476 479
477void PwMTray::undock() 480void PwMTray::undock()
478{ 481{
479 conf()->confGlobTray(false); 482 conf()->confGlobTray(false);
480 init->initTray(); 483 init->initTray();
481 // Attention! "this" is already deleted here! 484 // Attention! "this" is already deleted here!
482} 485}
483 486
484#ifndef PWM_EMBEDDED 487#ifndef PWM_EMBEDDED_
485#include "pwmtray.moc" 488#include "moc_pwmtray.cpp"
486#endif 489#endif
diff --git a/pwmanager/pwmanager/pwmtray.h b/pwmanager/pwmanager/pwmtray.h
index ffb625e..b1145e0 100644
--- a/pwmanager/pwmanager/pwmtray.h
+++ b/pwmanager/pwmanager/pwmtray.h
@@ -1,292 +1,294 @@
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 __PWMTRAY_H 20#ifndef __PWMTRAY_H
21#define __PWMTRAY_H 21#define __PWMTRAY_H
22 22
23#ifndef PWM_EMBEDDED 23#ifndef PWM_EMBEDDED
24#include <ksystemtray.h> 24#include <ksystemtray.h>
25#endif 25#endif
26 26
27#include <kpopupmenu.h> 27#include <kpopupmenu.h>
28 28
29#include <qpainter.h> 29#include <qpainter.h>
30#include <qvaluelist.h> 30#include <q3valuelist.h>
31//Added by qt3to4:
32#include <QMouseEvent>
33#include <QMenuItem>
31 34
32//#include "pwmexception.h" 35//#include "pwmexception.h"
33 36
34class PwMInit; 37class PwMInit;
35class PwMDoc; 38class PwMDoc;
36class PwMTray; 39class PwMTray;
37 40
38/* wrapper to workaround MOC problems */ 41/* wrapper to workaround MOC problems */
39class __ActiveTreeItem : public QCustomMenuItem 42class __ActiveTreeItem : public QMenuItem
40 , public QObject
41{ 43{
42public: 44public:
43 __ActiveTreeItem() {} 45 __ActiveTreeItem() {}
44}; 46};
45 47
46/** implements the "active" part of the tree */ 48/** implements the "active" part of the tree */
47class ActiveTreeItem : public __ActiveTreeItem 49class ActiveTreeItem : public __ActiveTreeItem
48{ 50{
49 Q_OBJECT 51 Q_OBJECT
50 52
51public: 53public:
52 enum Task 54 enum Task
53 { 55 {
54 pwToClipboard, 56 pwToClipboard,
55 nameToClipboard, 57 nameToClipboard,
56 descToClipboard, 58 descToClipboard,
57 urlToClipboard, 59 urlToClipboard,
58 launcherToClipboard, 60 launcherToClipboard,
59 commentToClipboard, 61 commentToClipboard,
60 execLauncher, 62 execLauncher,
61 goToURL, 63 goToURL,
62 openMainWnd, 64 openMainWnd,
63 closeDoc, 65 closeDoc,
64 lock, 66 lock,
65 deepLock, 67 deepLock,
66 unlock 68 unlock
67 }; 69 };
68 70
69public: 71public:
70 ActiveTreeItem(const QString &_text, const QFont &_font, 72 ActiveTreeItem(const QString &_text, const QFont &_font,
71 Task _task, PwMDoc * _doc, 73 Task _task, PwMDoc * _doc,
72 int _category, int _entry, 74 int _category, int _entry,
73 PwMTray *_tray) 75 PwMTray *_tray)
74 : text (_text) 76 : text (_text)
75 , font (_font) 77 , font (_font)
76 , task (_task) 78 , task (_task)
77 , doc (_doc) 79 , doc (_doc)
78 , category (_category) 80 , category (_category)
79 , entry (_entry) 81 , entry (_entry)
80 , tray (_tray) 82 , tray (_tray)
81 { } 83 { }
82 84
83 /*~ActiveTreeItem() 85 /*~ActiveTreeItem()
84 { cout << "deleted \"" << text << "\"" << endl; } */ 86 { cout << "deleted \"" << text << "\"" << endl; } */
85 87
86 void paint(QPainter *p, const QColorGroup & /*cg*/, bool /*act*/, 88 void paint(QPainter *p, const QColorGroup & /*cg*/, bool /*act*/,
87 bool /*enabled*/, int x, int y, int w, int h) 89 bool /*enabled*/, int x, int y, int w, int h)
88 { 90 {
89 p->setFont(font); 91 p->setFont(font);
90 p->drawText(x, y, w, h, AlignLeft | AlignVCenter | 92 p->drawText(x, y, w, h, Qt::AlignLeft | Qt::AlignVCenter |
91 DontClip | ShowPrefix, text); 93 Qt::DontClip | Qt::ShowPrefix, text);
92 } 94 }
93 95
94 QSize sizeHint() 96 QSize sizeHint()
95 { 97 {
96 return QFontMetrics(font).size(AlignLeft | AlignVCenter | 98 return QFontMetrics(font).size(Qt::AlignLeft | Qt::AlignVCenter |
97 ShowPrefix | DontClip, text); 99 Qt::ShowPrefix | Qt::DontClip, text);
98 } 100 }
99 101
100 bool fullSpan() const 102 bool fullSpan() const
101 { return false; } 103 { return false; }
102 104
103 bool isSeparator() const 105 bool isSeparator() const
104 { return false; } 106 { return false; }
105 107
106 void setFont(const QFont &f) 108 void setFont(const QFont &f)
107 { font = f; } 109 { font = f; }
108 110
109public slots: 111public slots:
110 /** this is the executive part, that is triggered, when the user clicks it */ 112 /** this is the executive part, that is triggered, when the user clicks it */
111 void execIt(); 113 void execIt();
112 114
113protected: 115protected:
114 QString text; 116 QString text;
115 QFont font; 117 QFont font;
116 Task task; 118 Task task;
117 PwMDoc *doc; 119 PwMDoc *doc;
118 int category; 120 int category;
119 int entry; 121 int entry;
120 PwMTray *tray; 122 PwMTray *tray;
121}; 123};
122 124
123/** tray icon implementation */ 125/** tray icon implementation */
124#ifndef PWM_EMBEDDED 126#ifndef PWM_EMBEDDED
125//MOC_SKIP_BEGIN 127#ifndef Q_MOC_RUN
126class PwMTray : public KSystemTray 128class PwMTray : public KSystemTray
127{ 129{
128 Q_OBJECT 130 Q_OBJECT
129 131
130 friend class ActiveTreeItem; 132 friend class ActiveTreeItem;
131 133
132 struct treeItem 134 struct treeItem
133 { 135 {
134 int menuId; 136 int menuId;
135 PwMDoc *doc; 137 PwMDoc *doc;
136 KPopupMenu *menu; 138 KPopupMenu *menu;
137 QValueList<int> activeItems; // ids of all active items 139 Q3ValueList<int> activeItems; // ids of all active items
138 }; 140 };
139 141
140public: 142public:
141 PwMTray(PwMInit *_init, QWidget* parent = 0, const char* name = 0); 143 PwMTray(PwMInit *_init, QWidget* parent = 0, const char* name = 0);
142 ~PwMTray(); 144 ~PwMTray();
143 145
144 /** connect all signals for this document to the tray */ 146 /** connect all signals for this document to the tray */
145 void connectDocToTray(PwMDoc *doc); 147 void connectDocToTray(PwMDoc *doc);
146 148
147public slots: 149public slots:
148 /** for update-notification from all open documents */ 150 /** for update-notification from all open documents */
149 void updateTree(PwMDoc *document); 151 void updateTree(PwMDoc *document);
150 /** when a document has been closed, call this func 152 /** when a document has been closed, call this func
151 * to delete its tray-entry 153 * to delete its tray-entry
152 */ 154 */
153 void closeTreeEntry(PwMDoc *document); 155 void closeTreeEntry(PwMDoc *document);
154 156
155protected slots: 157protected slots:
156 /** open a new document */ 158 /** open a new document */
157 void openDoc(); 159 void openDoc();
158 /** open a new mainwnd */ 160 /** open a new mainwnd */
159 void newMainWnd(); 161 void newMainWnd();
160 /** undock this tray icon */ 162 /** undock this tray icon */
161 void undock(); 163 void undock();
162 164
163signals: 165signals:
164 /** this icon got deleted */ 166 /** this icon got deleted */
165 void closed(PwMTray *); 167 void closed(PwMTray *);
166 /** the user clicked on the tray icon */ 168 /** the user clicked on the tray icon */
167 void clickedIcon(PwMTray *); 169 void clickedIcon(PwMTray *);
168 170
169protected: 171protected:
170 /** holds a list of all open files, its documents and 172 /** holds a list of all open files, its documents and
171 * its menuIDs 173 * its menuIDs
172 */ 174 */
173 QValueList<struct treeItem> tree; 175 Q3ValueList<struct treeItem> tree;
174 /** pointer to init */ 176 /** pointer to init */
175 PwMInit *init; 177 PwMInit *init;
176 178
177protected: 179protected:
178 /** search if an entry with for the given document 180 /** search if an entry with for the given document
179 * exists and resturn its ID and a pointer to the main 181 * exists and resturn its ID and a pointer to the main
180 * KPopupMenu. If no item is found, 182 * KPopupMenu. If no item is found,
181 * it returns -1 as ID and a NULL-pointer. 183 * it returns -1 as ID and a NULL-pointer.
182 */ 184 */
183 int findTreeEntry(PwMDoc *doc, KPopupMenu **menu, int *treeItem); 185 int findTreeEntry(PwMDoc *doc, KPopupMenu **menu, int *treeItem);
184 /** build the main menu-items */ 186 /** build the main menu-items */
185 void buildMain(); 187 void buildMain();
186 /** rebuilds the tree for the given KPopupMenu entry */ 188 /** rebuilds the tree for the given KPopupMenu entry */
187 void rebuildTree(KPopupMenu *popup, PwMDoc *doc, 189 void rebuildTree(KPopupMenu *popup, PwMDoc *doc,
188 QValueList<int> *activeItems); 190 Q3ValueList<int> *activeItems);
189 /** insert a new tree-entry for the given doc and returns the ID.*/ 191 /** insert a new tree-entry for the given doc and returns the ID.*/
190 int insertTreeEntry(PwMDoc *doc, KPopupMenu **popup); 192 int insertTreeEntry(PwMDoc *doc, KPopupMenu **popup);
191 /** removes a tree entry */ 193 /** removes a tree entry */
192 void removeTreeEntry(int menuId, int treeItem, KPopupMenu **menu); 194 void removeTreeEntry(int menuId, int treeItem, KPopupMenu **menu);
193 /** inserts a new active-tree-item into the given tree entry */ 195 /** inserts a new active-tree-item into the given tree entry */
194 void insertActiveTreeItem(KPopupMenu *insertIn, const QString &text, 196 void insertActiveTreeItem(KPopupMenu *insertIn, const QString &text,
195 ActiveTreeItem::Task task, PwMDoc *doc, 197 ActiveTreeItem::Task task, PwMDoc *doc,
196 int docCategory, int docEntry, 198 int docCategory, int docEntry,
197 QValueList<int> *activeItemsList); 199 Q3ValueList<int> *activeItemsList);
198 /** mouse event on icon */ 200 /** mouse event on icon */
199 void mouseReleaseEvent(QMouseEvent *e); 201 void mouseReleaseEvent(QMouseEvent *e);
200 /** inserts the items for the main window control 202 /** inserts the items for the main window control
201 * into the popup menu. 203 * into the popup menu.
202 */ 204 */
203 void insertMainWndCtrl(KPopupMenu *menu, PwMDoc *doc); 205 void insertMainWndCtrl(KPopupMenu *menu, PwMDoc *doc);
204}; 206};
205//MOC_SKIP_END 207#endif
206#else 208#else
207class PwMTray : public QWidget 209class PwMTray : public QWidget
208{ 210{
209 Q_OBJECT 211 Q_OBJECT
210 212
211 friend class ActiveTreeItem; 213 friend class ActiveTreeItem;
212 214
213 struct treeItem 215 struct treeItem
214 { 216 {
215 int menuId; 217 int menuId;
216 PwMDoc *doc; 218 PwMDoc *doc;
217 KPopupMenu *menu; 219 KPopupMenu *menu;
218 QValueList<int> activeItems; // ids of all active items 220 Q3ValueList<int> activeItems; // ids of all active items
219 }; 221 };
220 222
221public: 223public:
222 PwMTray(PwMInit *_init, QWidget* parent = 0, const char* name = 0); 224 PwMTray(PwMInit *_init, QWidget* parent = 0, const char* name = 0);
223 ~PwMTray(); 225 ~PwMTray();
224 226
225 //US ENH needed for embedde version. 227 //US ENH needed for embedde version.
226 KPopupMenu* contextMenu(); 228 KPopupMenu* contextMenu();
227 KPopupMenu* m_ctxMenu; 229 KPopupMenu* m_ctxMenu;
228 230
229 /** connect all signals for this document to the tray */ 231 /** connect all signals for this document to the tray */
230 void connectDocToTray(PwMDoc *doc); 232 void connectDocToTray(PwMDoc *doc);
231 233
232public slots: 234public slots:
233 /** for update-notification from all open documents */ 235 /** for update-notification from all open documents */
234 void updateTree(PwMDoc *document); 236 void updateTree(PwMDoc *document);
235 /** when a document has been closed, call this func 237 /** when a document has been closed, call this func
236 * to delete its tray-entry 238 * to delete its tray-entry
237 */ 239 */
238 void closeTreeEntry(PwMDoc *document); 240 void closeTreeEntry(PwMDoc *document);
239 241
240protected slots: 242protected slots:
241 /** open a new document */ 243 /** open a new document */
242 void openDoc(); 244 void openDoc();
243 /** open a new mainwnd */ 245 /** open a new mainwnd */
244 void newMainWnd(); 246 void newMainWnd();
245 /** undock this tray icon */ 247 /** undock this tray icon */
246 void undock(); 248 void undock();
247 249
248signals: 250signals:
249 /** this icon got deleted */ 251 /** this icon got deleted */
250 void closed(PwMTray *); 252 void closed(PwMTray *);
251 /** the user clicked on the tray icon */ 253 /** the user clicked on the tray icon */
252 void clickedIcon(PwMTray *); 254 void clickedIcon(PwMTray *);
253 255
254protected: 256protected:
255 /** holds a list of all open files, its documents and 257 /** holds a list of all open files, its documents and
256 * its menuIDs 258 * its menuIDs
257 */ 259 */
258 QValueList<struct treeItem> tree; 260 Q3ValueList<struct treeItem> tree;
259 /** pointer to init */ 261 /** pointer to init */
260 PwMInit *init; 262 PwMInit *init;
261 263
262protected: 264protected:
263 /** search if an entry with for the given document 265 /** search if an entry with for the given document
264 * exists and resturn its ID and a pointer to the main 266 * exists and resturn its ID and a pointer to the main
265 * KPopupMenu. If no item is found, 267 * KPopupMenu. If no item is found,
266 * it returns -1 as ID and a NULL-pointer. 268 * it returns -1 as ID and a NULL-pointer.
267 */ 269 */
268 int findTreeEntry(PwMDoc *doc, KPopupMenu **menu, int *treeItem); 270 int findTreeEntry(PwMDoc *doc, KPopupMenu **menu, int *treeItem);
269 /** build the main menu-items */ 271 /** build the main menu-items */
270 void buildMain(); 272 void buildMain();
271 /** rebuilds the tree for the given KPopupMenu entry */ 273 /** rebuilds the tree for the given KPopupMenu entry */
272 void rebuildTree(KPopupMenu *popup, PwMDoc *doc, 274 void rebuildTree(KPopupMenu *popup, PwMDoc *doc,
273 QValueList<int> *activeItems); 275 Q3ValueList<int> *activeItems);
274 /** insert a new tree-entry for the given doc and returns the ID.*/ 276 /** insert a new tree-entry for the given doc and returns the ID.*/
275 int insertTreeEntry(PwMDoc *doc, KPopupMenu **popup); 277 int insertTreeEntry(PwMDoc *doc, KPopupMenu **popup);
276 /** removes a tree entry */ 278 /** removes a tree entry */
277 void removeTreeEntry(int menuId, int treeItem, KPopupMenu **menu); 279 void removeTreeEntry(int menuId, int treeItem, KPopupMenu **menu);
278 /** inserts a new active-tree-item into the given tree entry */ 280 /** inserts a new active-tree-item into the given tree entry */
279 void insertActiveTreeItem(KPopupMenu *insertIn, const QString &text, 281 void insertActiveTreeItem(KPopupMenu *insertIn, const QString &text,
280 ActiveTreeItem::Task task, PwMDoc *doc, 282 ActiveTreeItem::Task task, PwMDoc *doc,
281 int docCategory, int docEntry, 283 int docCategory, int docEntry,
282 QValueList<int> *activeItemsList); 284 Q3ValueList<int> *activeItemsList);
283 /** mouse event on icon */ 285 /** mouse event on icon */
284 void mouseReleaseEvent(QMouseEvent *e); 286 void mouseReleaseEvent(QMouseEvent *e);
285 /** inserts the items for the main window control 287 /** inserts the items for the main window control
286 * into the popup menu. 288 * into the popup menu.
287 */ 289 */
288 void insertMainWndCtrl(KPopupMenu *menu, PwMDoc *doc); 290 void insertMainWndCtrl(KPopupMenu *menu, PwMDoc *doc);
289}; 291};
290#endif 292#endif
291 293
292#endif 294#endif
diff --git a/pwmanager/pwmanager/pwmview.cpp b/pwmanager/pwmanager/pwmview.cpp
index 2533487..68500d0 100644
--- a/pwmanager/pwmanager/pwmview.cpp
+++ b/pwmanager/pwmanager/pwmview.cpp
@@ -1,623 +1,631 @@
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 "pwmview.h" 20#include "pwmview.h"
21#include "pwmexception.h" 21#include "pwmexception.h"
22#include "globalstuff.h" 22#include "globalstuff.h"
23#include "pwm.h" 23#include "pwm.h"
24#include "rencatwnd.h" 24#include "rencatwnd.h"
25#ifndef PWM_EMBEDDED 25#ifndef PWM_EMBEDDED
26#include "configuration.h" 26#include "configuration.h"
27#else 27#else
28#include "pwmprefs.h" 28#include "pwmprefs.h"
29#endif 29#endif
30#include "commentbox.h" 30#include "commentbox.h"
31 31
32#include <kmessagebox.h> 32#include <kmessagebox.h>
33#include <klocale.h> 33#include <klocale.h>
34 34
35#include <qlineedit.h> 35#include <qlineedit.h>
36#include <qpoint.h> 36#include <qpoint.h>
37#include <qapplication.h> 37#include <qapplication.h>
38#include <QDesktopWidget>
38#include <qlayout.h> 39#include <qlayout.h>
40//Added by qt3to4:
41#include <Q3HBoxLayout>
42#include <QKeyEvent>
43#include <QLabel>
44#include <QResizeEvent>
45#include <Q3PopupMenu>
46#include <Q3VBoxLayout>
39 47
40//US ENH: wouldn't it be a good idea if we could use this consts everywhere else. 48//US ENH: wouldn't it be a good idea if we could use this consts everywhere else.
41//US ENH: for examle in listviewpwm.cpp 49//US ENH: for examle in listviewpwm.cpp
42//US ENH: Because of that I transfer them into the headerfile. 50//US ENH: Because of that I transfer them into the headerfile.
43/* 51/*
44 #define COLUMN_DESC 0 52 #define COLUMN_DESC 0
45 #define COLUMN_NAME 1 53 #define COLUMN_NAME 1
46 #define COLUMN_PW 2 54 #define COLUMN_PW 2
47 #define COLUMN_URL 3 55 #define COLUMN_URL 3
48 #define COLUMN_LAUNCHER 4 56 #define COLUMN_LAUNCHER 4
49*/ 57*/
50 58
51PwMView::PwMView(PwM *_mainClass, 59PwMView::PwMView(PwM *_mainClass,
52 QWidget *parent, PwMDoc *_doc, 60 QWidget *parent, PwMDoc *_doc,
53 const char *name) 61 const char *name)
54 : PwMViewStyle(parent, name) 62 : PwMViewStyle(parent, name)
55{ 63{
56 PWM_ASSERT(_mainClass); 64 PWM_ASSERT(_mainClass);
57 PWM_ASSERT(parent); 65 PWM_ASSERT(parent);
58 PWM_ASSERT(_doc); 66 PWM_ASSERT(_doc);
59 setView(this); 67 setView(this);
60 doc = _doc; 68 doc = _doc;
61 doc->setListViewPointer(this); 69 doc->setListViewPointer(this);
62 mainClass = _mainClass; 70 mainClass = _mainClass;
63 resize(_mainClass->size()); 71 resize(_mainClass->size());
64 initStyle(conf()->confWndMainViewStyle()); 72 initStyle(conf()->confWndMainViewStyle());
65 initCtxMenu(); 73 initCtxMenu();
66 doc->setCurrentView(this); 74 doc->setCurrentView(this);
67 connect(doc, SIGNAL(dataChanged(PwMDoc *)), this, SLOT(updateView())); 75 connect(doc, SIGNAL(dataChanged(PwMDoc *)), this, SLOT(updateView()));
68 connect(this, SIGNAL(editPW()), mainClass, SLOT(editPwd_slot())); 76 connect(this, SIGNAL(editPW()), mainClass, SLOT(editPwd_slot()));
69 connect(this, SIGNAL(insertPW()), mainClass, SLOT(addPwd_slot())); 77 connect(this, SIGNAL(insertPW()), mainClass, SLOT(addPwd_slot()));
70 connect(this, SIGNAL(deletePW()), mainClass, SLOT(deletePwd_slot())); 78 connect(this, SIGNAL(deletePW()), mainClass, SLOT(deletePwd_slot()));
71} 79}
72 80
73PwMView::~PwMView() 81PwMView::~PwMView()
74{ 82{
75} 83}
76 84
77void PwMView::initCtxMenu() 85void PwMView::initCtxMenu()
78{ 86{
79 ctxMenu = new QPopupMenu(this); 87 ctxMenu = new Q3PopupMenu(this);
80 ctxMenu->insertItem(i18n("&Add password"), mainClass, SLOT(addPwd_slot())); 88 ctxMenu->insertItem(i18n("&Add password"), mainClass, SLOT(addPwd_slot()));
81 ctxMenu->insertSeparator(); 89 ctxMenu->insertSeparator();
82 ctxMenu->insertItem(i18n("&Edit"), mainClass, SLOT(editPwd_slot())); 90 ctxMenu->insertItem(i18n("&Edit"), mainClass, SLOT(editPwd_slot()));
83 ctxMenu->insertItem(i18n("&Delete"), mainClass, SLOT(deletePwd_slot())); 91 ctxMenu->insertItem(i18n("&Delete"), mainClass, SLOT(deletePwd_slot()));
84 ctxMenu->insertSeparator(); 92 ctxMenu->insertSeparator();
85 ctxMenu->insertItem(i18n("copy password to clipboard"), 93 ctxMenu->insertItem(i18n("copy password to clipboard"),
86 this, SLOT(copyPwToClip())); 94 this, SLOT(copyPwToClip()));
87 ctxMenu->insertItem(i18n("copy username to clipboard"), 95 ctxMenu->insertItem(i18n("copy username to clipboard"),
88 this, SLOT(copyNameToClip())); 96 this, SLOT(copyNameToClip()));
89 ctxMenu->insertItem(i18n("copy description to clipboard"), 97 ctxMenu->insertItem(i18n("copy description to clipboard"),
90 this, SLOT(copyDescToClip())); 98 this, SLOT(copyDescToClip()));
91 ctxMenu->insertItem(i18n("copy url to clipboard"), 99 ctxMenu->insertItem(i18n("copy url to clipboard"),
92 this, SLOT(copyUrlToClip())); 100 this, SLOT(copyUrlToClip()));
93 ctxMenu->insertItem(i18n("copy launcher to clipboard"), 101 ctxMenu->insertItem(i18n("copy launcher to clipboard"),
94 this, SLOT(copyLauncherToClip())); 102 this, SLOT(copyLauncherToClip()));
95 ctxMenu->insertItem(i18n("copy comment to clipboard"), 103 ctxMenu->insertItem(i18n("copy comment to clipboard"),
96 this, SLOT(copyCommentToClip())); 104 this, SLOT(copyCommentToClip()));
97 ctxMenu->insertSeparator(); 105 ctxMenu->insertSeparator();
98 ctxMenu->insertItem(i18n("Execute \"Launcher\""), mainClass, 106 ctxMenu->insertItem(i18n("Execute \"Launcher\""), mainClass,
99 SLOT(execLauncher_slot())); 107 SLOT(execLauncher_slot()));
100 ctxMenu->insertItem(i18n("Go to \"URL\""), mainClass, 108 ctxMenu->insertItem(i18n("Go to \"URL\""), mainClass,
101 SLOT(goToURL_slot())); 109 SLOT(goToURL_slot()));
102} 110}
103 111
104void PwMView::resizeEvent(QResizeEvent *) 112void PwMView::resizeEvent(QResizeEvent *)
105{ 113{
106 resizeView(size()); 114 resizeView(size());
107} 115}
108 116
109void PwMView::refreshCommentTextEdit(QListViewItem *curItem) 117void PwMView::refreshCommentTextEdit(Q3ListViewItem *curItem)
110{ 118{
111 PWM_ASSERT(commentBox); 119 PWM_ASSERT(commentBox);
112 if (!curItem) 120 if (!curItem)
113 return; 121 return;
114 string comment; 122 string comment;
115 PwMerror ret; 123 PwMerror ret;
116 ret = document()->getCommentByLvp_long(getCurrentCategory(), 124 ret = document()->getCommentByLvp_long(getCurrentCategory(),
117 lv->childCount() - lv->itemIndex(curItem) - 1, 125 lv->childCount() - lv->itemIndex(curItem) - 1,
118 &comment); 126 &comment);
119 if (ret == e_binEntry) { 127 if (ret == e_binEntry) {
120 commentBox->setContent(i18n("This is a binary entry.\n" 128 commentBox->setContent(i18n("This is a binary entry.\n"
121 "It is not a normal password-entry, as it contains " 129 "It is not a normal password-entry, as it contains "
122 "binary data, which PwManager can't display here.")); 130 "binary data, which PwManager can't display here."));
123 } else if (ret == e_normalEntry) { 131 } else if (ret == e_normalEntry) {
124 commentBox->setContent(comment.c_str()); 132 commentBox->setContent(comment.c_str());
125 } else { 133 } else {
126 BUG(); 134 BUG();
127 return; 135 return;
128 } 136 }
129 lv->ensureItemVisible(curItem); 137 lv->ensureItemVisible(curItem);
130} 138}
131 139
132void PwMView::keyReleaseEvent(QKeyEvent * /*e*/) 140void PwMView::keyReleaseEvent(QKeyEvent * /*e*/)
133{ 141{
134 refreshCommentTextEdit(lv->currentItem()); 142 refreshCommentTextEdit(lv->currentItem());
135} 143}
136 144
137bool PwMView::getCurEntryIndex(unsigned int *index) 145bool PwMView::getCurEntryIndex(unsigned int *index)
138{ 146{
139 QListViewItem *current = lv->currentItem(); 147 Q3ListViewItem *current = lv->currentItem();
140 if (!current) 148 if (!current)
141 return false; 149 return false;
142 return getDocEntryIndex(index, current); 150 return getDocEntryIndex(index, current);
143} 151}
144 152
145bool PwMView::getDocEntryIndex(unsigned int *index, 153bool PwMView::getDocEntryIndex(unsigned int *index,
146 const QListViewItem *item) 154 const Q3ListViewItem *item)
147{ 155{
148 vector<unsigned int> foundPositions; 156 vector<unsigned int> foundPositions;
149 PwMDataItem curItem; 157 PwMDataItem curItem;
150 curItem.desc = item->text(COLUMN_DESC).latin1(); 158 curItem.desc = item->text(COLUMN_DESC).latin1();
151 curItem.name = item->text(COLUMN_NAME).latin1(); 159 curItem.name = item->text(COLUMN_NAME).latin1();
152 document()->getCommentByLvp(getCurrentCategory(), 160 document()->getCommentByLvp(getCurrentCategory(),
153 lv->childCount() - lv->itemIndex(item) - 1, 161 lv->childCount() - lv->itemIndex(item) - 1,
154 &curItem.comment); 162 &curItem.comment);
155 curItem.url = item->text(COLUMN_URL).latin1(); 163 curItem.url = item->text(COLUMN_URL).latin1();
156 curItem.launcher = item->text(COLUMN_LAUNCHER).latin1(); 164 curItem.launcher = item->text(COLUMN_LAUNCHER).latin1();
157 document()->findEntry(getCurrentCategory(), curItem, SEARCH_IN_DESC | 165 document()->findEntry(getCurrentCategory(), curItem, SEARCH_IN_DESC |
158 SEARCH_IN_NAME | SEARCH_IN_COMMENT | SEARCH_IN_URL | 166 SEARCH_IN_NAME | SEARCH_IN_COMMENT | SEARCH_IN_URL |
159 SEARCH_IN_LAUNCHER, 167 SEARCH_IN_LAUNCHER,
160 &foundPositions, true); 168 &foundPositions, true);
161 if (foundPositions.size()) { 169 if (foundPositions.size()) {
162 *index = foundPositions[0]; 170 *index = foundPositions[0];
163 return true; 171 return true;
164 } 172 }
165 173
166 return false; 174 return false;
167} 175}
168 176
169void PwMView::handleToggle(QListViewItem *item) 177void PwMView::handleToggle(Q3ListViewItem *item)
170{ 178{
171 PWM_ASSERT(doc); 179 PWM_ASSERT(doc);
172 if (!item) 180 if (!item)
173 return; 181 return;
174 QCheckListItem *clItem = (QCheckListItem *)item; 182 Q3CheckListItem *clItem = (Q3CheckListItem *)item;
175 QString curCat(getCurrentCategory()); 183 QString curCat(getCurrentCategory());
176 184
177 // find document position of this entry. 185 // find document position of this entry.
178 unsigned int curEntryDocIndex; 186 unsigned int curEntryDocIndex;
179 if (!getDocEntryIndex(&curEntryDocIndex, item)) 187 if (!getDocEntryIndex(&curEntryDocIndex, item))
180 return; 188 return;
181 189
182 // hack to refresh the comment, if only one item is present 190 // hack to refresh the comment, if only one item is present
183 if (lv->childCount() == 1) 191 if (lv->childCount() == 1)
184 refreshCommentTextEdit(lv->currentItem()); 192 refreshCommentTextEdit(lv->currentItem());
185 193
186 if (doc->isLocked(curCat, curEntryDocIndex) != clItem->isOn()) 194 if (doc->isLocked(curCat, curEntryDocIndex) != clItem->isOn())
187 return; // this is just a click somewhere on the entry 195 return; // this is just a click somewhere on the entry
188 if (doc->isDeepLocked()) { 196 if (doc->isDeepLocked()) {
189 PwMerror ret; 197 PwMerror ret;
190 ret = doc->deepLock(false); 198 ret = doc->deepLock(false);
191 if (ret != e_success) 199 if (ret != e_success)
192 clItem->setOn(false); 200 clItem->setOn(false);
193 return; 201 return;
194 } 202 }
195 doc->lockAt(curCat, curEntryDocIndex, !clItem->isOn()); 203 doc->lockAt(curCat, curEntryDocIndex, !clItem->isOn());
196} 204}
197 205
198void PwMView::handleRightClick(QListViewItem *item, const QPoint &point, int) 206void PwMView::handleRightClick(Q3ListViewItem *item, const QPoint &point, int)
199{ 207{
200 if (!item) 208 if (!item)
201 return; 209 return;
202 ctxMenu->move(point); 210 ctxMenu->move(point);
203 /* don't use ctxMenu->exec() here, as it generates race conditions 211 /* don't use ctxMenu->exec() here, as it generates race conditions
204 * with the card interface code. Believe it or not. :) 212 * with the card interface code. Believe it or not. :)
205 */ 213 */
206 ctxMenu->show(); 214 ctxMenu->show();
207} 215}
208 216
209void PwMView::updateCategories() 217void PwMView::updateCategories()
210{ 218{
211 //qDebug("PwMView::updateCategories() "); 219 //qDebug("PwMView::updateCategories() ");
212 QString oldSel(getCurrentCategory()); 220 QString oldSel(getCurrentCategory());
213 delAllCategories(); 221 delAllCategories();
214 QStringList catList; 222 QStringList catList;
215 document()->getCategoryList(&catList); 223 document()->getCategoryList(&catList);
216 catList.sort(); 224 catList.sort();
217#ifndef PWM_EMBEDDED 225#ifndef PWM_EMBEDDED
218 QStringList::iterator i = catList.begin(), 226 QStringList::iterator i = catList.begin(),
219 end = catList.end(); 227 end = catList.end();
220#else 228#else
221 QStringList::Iterator i = catList.begin(), 229 QStringList::Iterator i = catList.begin(),
222 end = catList.end(); 230 end = catList.end();
223#endif 231#endif
224 while (i != end) { 232 while (i != end) {
225 addCategory(*i); 233 addCategory(*i);
226 ++i; 234 ++i;
227 } 235 }
228 selectCategory(oldSel); 236 selectCategory(oldSel);
229} 237}
230 238
231void PwMView::shiftToView() 239void PwMView::shiftToView()
232{ 240{
233 int cX = lv->contentsX(); 241 int cX = lv->contentsX();
234 int cY = lv->contentsY(); 242 int cY = lv->contentsY();
235 commentBox->clear(); 243 commentBox->clear();
236 244
237 unsigned int catDocIndex; 245 unsigned int catDocIndex;
238 if (unlikely( 246 if (unlikely(
239 !(document()->findCategory(getCurrentCategory(), 247 !(document()->findCategory(getCurrentCategory(),
240 &catDocIndex)))) { 248 &catDocIndex)))) {
241 BUG(); 249 BUG();
242 } 250 }
243 251
244 // ensure all listViewPos are set 252 // ensure all listViewPos are set
245 doc->ensureLvp(); 253 doc->ensureLvp();
246 254
247 // clear all tmp-data vectors 255 // clear all tmp-data vectors
248 unsigned int i, entries = doc->numEntries(catDocIndex); 256 unsigned int i, entries = doc->numEntries(catDocIndex);
249 if (entries) { 257 if (entries) {
250 mainClass->setVirgin(false); 258 mainClass->setVirgin(false);
251 } 259 }
252 vector<PwMDataItem> tmpSorted; 260 vector<PwMDataItem> tmpSorted;
253 PwMDataItem currItem; 261 PwMDataItem currItem;
254 currItem.clear(); 262 currItem.clear();
255 tmpSorted.insert(tmpSorted.begin(), entries, currItem); 263 tmpSorted.insert(tmpSorted.begin(), entries, currItem);
256 264
257 // Sort items and store them in tempoary tmpSorted. 265 // Sort items and store them in tempoary tmpSorted.
258 for (i = 0; i < entries; ++i) { 266 for (i = 0; i < entries; ++i) {
259 doc->getEntry(catDocIndex, i, &currItem); 267 doc->getEntry(catDocIndex, i, &currItem);
260 //qDebug("PwMView::shiftToView: %s, %i", currItem.desc.c_str(), currItem.listViewPos); 268 //qDebug("PwMView::shiftToView: %s, %i", currItem.desc.c_str(), currItem.listViewPos);
261 tmpSorted[currItem.listViewPos] = currItem; 269 tmpSorted[currItem.listViewPos] = currItem;
262 } 270 }
263 271
264 // shift tempoary data to ListView. 272 // shift tempoary data to ListView.
265 tmpDisableSort(); 273 tmpDisableSort();
266 lv->clear(); 274 lv->clear();
267 275
268 //US ENH: adjust the headers of the table according the category texts 276 //US ENH: adjust the headers of the table according the category texts
269 { 277 {
270 PwMCategoryItem* catItem = doc->getCategoryEntry(catDocIndex); 278 PwMCategoryItem* catItem = doc->getCategoryEntry(catDocIndex);
271 // qDebug("PwMView::ShiftToView CAT: %i, %s", catDocIndex, catItem->name.c_str()); 279 // qDebug("PwMView::ShiftToView CAT: %i, %s", catDocIndex, catItem->name.c_str());
272 lv->setColumnText(COLUMN_DESC, catItem->desc_text.c_str()); 280 lv->setColumnText(COLUMN_DESC, catItem->desc_text.c_str());
273 lv->setColumnText(COLUMN_NAME, catItem->name_text.c_str()); 281 lv->setColumnText(COLUMN_NAME, catItem->name_text.c_str());
274 lv->setColumnText(COLUMN_PW, catItem->pw_text.c_str()); 282 lv->setColumnText(COLUMN_PW, catItem->pw_text.c_str());
275 } 283 }
276 284
277 QCheckListItem *newItem; 285 Q3CheckListItem *newItem;
278 vector<PwMDataItem>::iterator it = tmpSorted.begin(), 286 vector<PwMDataItem>::iterator it = tmpSorted.begin(),
279 end = tmpSorted.end(); 287 end = tmpSorted.end();
280 while (it != end) { 288 while (it != end) {
281 newItem = new ListViewItemPwM(lv); 289 newItem = new ListViewItemPwM(lv);
282 newItem->setText(COLUMN_DESC, (*it).desc.c_str()); 290 newItem->setText(COLUMN_DESC, (*it).desc.c_str());
283 if ((*it).binary) { 291 if ((*it).binary) {
284 newItem->setText(COLUMN_NAME, ""); 292 newItem->setText(COLUMN_NAME, "");
285 newItem->setText(COLUMN_PW, i18n("<BINARY ENTRY>")); 293 newItem->setText(COLUMN_PW, i18n("<BINARY ENTRY>"));
286 newItem->setText(COLUMN_URL, ""); 294 newItem->setText(COLUMN_URL, "");
287 newItem->setText(COLUMN_LAUNCHER, (*it).launcher.c_str()); 295 newItem->setText(COLUMN_LAUNCHER, (*it).launcher.c_str());
288 } else { 296 } else {
289 newItem->setText(COLUMN_NAME, (*it).name.c_str()); 297 newItem->setText(COLUMN_NAME, (*it).name.c_str());
290 if ((*it).lockStat) { 298 if ((*it).lockStat) {
291 newItem->setText(COLUMN_PW, QString((*it).pw.c_str()) 299 newItem->setText(COLUMN_PW, QString((*it).pw.c_str())
292 + " " 300 + " "
293 + i18n("To unlock click the icon on the left.")); 301 + i18n("To unlock click the icon on the left."));
294 } else { 302 } else {
295 newItem->setText(COLUMN_PW, (*it).pw.c_str()); 303 newItem->setText(COLUMN_PW, (*it).pw.c_str());
296 } 304 }
297 newItem->setText(COLUMN_URL, (*it).url.c_str()); 305 newItem->setText(COLUMN_URL, (*it).url.c_str());
298 newItem->setText(COLUMN_LAUNCHER, (*it).launcher.c_str()); 306 newItem->setText(COLUMN_LAUNCHER, (*it).launcher.c_str());
299 } 307 }
300 newItem->setOn(!((*it).lockStat)); 308 newItem->setOn(!((*it).lockStat));
301 lv->insertItem(newItem); 309 lv->insertItem(newItem);
302 ++it; 310 ++it;
303 } 311 }
304 tmpReEnableSort(); 312 tmpReEnableSort();
305 313
306 if (cY || cX) 314 if (cY || cX)
307 lv->setContentsPos(cX, cY); 315 lv->setContentsPos(cX, cY);
308} 316}
309 317
310void PwMView::reorgLp() 318void PwMView::reorgLp()
311{ 319{
312 if (!lv->childCount()) 320 if (!lv->childCount())
313 return; 321 return;
314 PWM_ASSERT(doc); 322 PWM_ASSERT(doc);
315 PWM_ASSERT(!doc->isDocEmpty()); 323 PWM_ASSERT(!doc->isDocEmpty());
316 QListViewItem *currItem; 324 Q3ListViewItem *currItem;
317 vector<unsigned int> foundPos; 325 vector<unsigned int> foundPos;
318 /* This searchIn _should_ be: 326 /* This searchIn _should_ be:
319 *const unsigned int searchIn = SEARCH_IN_DESC; 327 *const unsigned int searchIn = SEARCH_IN_DESC;
320 * But we want backward compatibility (see comment in PwMDoc::addEntry()). 328 * But we want backward compatibility (see comment in PwMDoc::addEntry()).
321 * So we need to search again, if we don't find the entry. (see below) 329 * So we need to search again, if we don't find the entry. (see below)
322 */ 330 */
323 const unsigned int searchIn = SEARCH_IN_DESC | SEARCH_IN_NAME | 331 const unsigned int searchIn = SEARCH_IN_DESC | SEARCH_IN_NAME |
324 SEARCH_IN_URL | SEARCH_IN_LAUNCHER; 332 SEARCH_IN_URL | SEARCH_IN_LAUNCHER;
325 QString curCat(getCurrentCategory()); 333 QString curCat(getCurrentCategory());
326 PwMDataItem findThis; 334 PwMDataItem findThis;
327 unsigned int i, cnt = lv->childCount(); 335 unsigned int i, cnt = lv->childCount();
328 for (i = 0; i < cnt; ++i) { 336 for (i = 0; i < cnt; ++i) {
329 currItem = lv->itemAtIndex(i); 337 currItem = lv->itemAtIndex(i);
330 findThis.desc = currItem->text(COLUMN_DESC).latin1(); 338 findThis.desc = currItem->text(COLUMN_DESC).latin1();
331 findThis.name = currItem->text(COLUMN_NAME).latin1(); 339 findThis.name = currItem->text(COLUMN_NAME).latin1();
332 findThis.url = currItem->text(COLUMN_URL).latin1(); 340 findThis.url = currItem->text(COLUMN_URL).latin1();
333 findThis.launcher = currItem->text(COLUMN_LAUNCHER).latin1(); 341 findThis.launcher = currItem->text(COLUMN_LAUNCHER).latin1();
334 doc->findEntry(curCat, findThis, searchIn, 342 doc->findEntry(curCat, findThis, searchIn,
335 &foundPos, true); 343 &foundPos, true);
336 if (!foundPos.size()) { 344 if (!foundPos.size()) {
337 /* Did not find the entry. We seem to have a binary 345 /* Did not find the entry. We seem to have a binary
338 * entry here (pray for it!). So search again with 346 * entry here (pray for it!). So search again with
339 * the "correct" searchIn flags. 347 * the "correct" searchIn flags.
340 */ 348 */
341 const unsigned int searchIn2 = SEARCH_IN_DESC; 349 const unsigned int searchIn2 = SEARCH_IN_DESC;
342 doc->findEntry(curCat, findThis, searchIn2, 350 doc->findEntry(curCat, findThis, searchIn2,
343 &foundPos, true); 351 &foundPos, true);
344 if (unlikely(!foundPos.size())) { 352 if (unlikely(!foundPos.size())) {
345 BUG(); 353 BUG();
346 continue; 354 continue;
347 } 355 }
348 /* We assert that it's a binary entry, now. 356 /* We assert that it's a binary entry, now.
349 * No chance to efficiently verify it here. 357 * No chance to efficiently verify it here.
350 */ 358 */
351 } 359 }
352 doc->setListViewPos(curCat, foundPos[0], cnt - i - 1); 360 doc->setListViewPos(curCat, foundPos[0], cnt - i - 1);
353 } 361 }
354} 362}
355 363
356void PwMView::selAt(int index) 364void PwMView::selAt(int index)
357{ 365{
358 QListViewItem *item = lv->itemAtIndex(index); 366 Q3ListViewItem *item = lv->itemAtIndex(index);
359 if (!item) 367 if (!item)
360 return; 368 return;
361 lv->setCurrentItem(item); 369 lv->setCurrentItem(item);
362 lv->ensureItemVisible(item); 370 lv->ensureItemVisible(item);
363} 371}
364 372
365void PwMView::renCatButton_slot() 373void PwMView::renCatButton_slot()
366{ 374{
367 if (doc->isDeepLocked()) 375 if (doc->isDeepLocked())
368 return; 376 return;
369 RenCatWnd wnd(this); 377 RenCatWnd wnd(this);
370 if (wnd.exec() == 1) { 378 if (wnd.exec() == 1) {
371 QString newName(wnd.getNewName()); 379 QString newName(wnd.getNewName());
372 if (newName == "") 380 if (newName == "")
373 return; 381 return;
374 document()->renameCategory(getCurrentCategory(), 382 document()->renameCategory(getCurrentCategory(),
375 newName); 383 newName);
376 } 384 }
377} 385}
378 386
379void PwMView::delCatButton_slot() 387void PwMView::delCatButton_slot()
380{ 388{
381 if (doc->isDeepLocked()) 389 if (doc->isDeepLocked())
382 return; 390 return;
383 if (numCategories() <= 1) { 391 if (numCategories() <= 1) {
384 mainClass->showStatMsg(i18n("Can't remove the last category.")); 392 mainClass->showStatMsg(i18n("Can't remove the last category."));
385 return; 393 return;
386 } 394 }
387 if (KMessageBox::questionYesNo(this, 395 if (KMessageBox::questionYesNo(this,
388 i18n("Do you really want to\n" 396 i18n("Do you really want to\n"
389 "delete the selected\n" 397 "delete the selected\n"
390 "category? All password-\n" 398 "category? All password-\n"
391 "entries will be lost in\n" 399 "entries will be lost in\n"
392 "this category!\n"), 400 "this category!\n"),
393 i18n("Delete category?")) 401 i18n("Delete category?"))
394 == KMessageBox::No) { 402 == KMessageBox::No) {
395 return; 403 return;
396 } 404 }
397 document()->delCategory(getCurrentCategory()); 405 document()->delCategory(getCurrentCategory());
398} 406}
399 407
400void PwMView::copyPwToClip() 408void PwMView::copyPwToClip()
401{ 409{
402 if (doc->isDeepLocked()) 410 if (doc->isDeepLocked())
403 return; 411 return;
404 unsigned int curIndex = 0; 412 unsigned int curIndex = 0;
405 if (!getCurEntryIndex(&curIndex)) 413 if (!getCurEntryIndex(&curIndex))
406 return; 414 return;
407 PwMDataItem d; 415 PwMDataItem d;
408 document()->getDataChangedLock(); 416 document()->getDataChangedLock();
409 document()->getEntry(getCurrentCategory(), curIndex, &d, true); 417 document()->getEntry(getCurrentCategory(), curIndex, &d, true);
410 document()->putDataChangedLock(); 418 document()->putDataChangedLock();
411 PwM::copyToClipboard(d.pw.c_str()); 419 PwM::copyToClipboard(d.pw.c_str());
412} 420}
413 421
414void PwMView::copyNameToClip() 422void PwMView::copyNameToClip()
415{ 423{
416 if (doc->isDeepLocked()) 424 if (doc->isDeepLocked())
417 return; 425 return;
418 unsigned int curIndex = 0; 426 unsigned int curIndex = 0;
419 if (!getCurEntryIndex(&curIndex)) 427 if (!getCurEntryIndex(&curIndex))
420 return; 428 return;
421 PwMDataItem d; 429 PwMDataItem d;
422 document()->getEntry(getCurrentCategory(), curIndex, &d); 430 document()->getEntry(getCurrentCategory(), curIndex, &d);
423 PwM::copyToClipboard(d.name.c_str()); 431 PwM::copyToClipboard(d.name.c_str());
424} 432}
425 433
426void PwMView::copyDescToClip() 434void PwMView::copyDescToClip()
427{ 435{
428 if (doc->isDeepLocked()) 436 if (doc->isDeepLocked())
429 return; 437 return;
430 unsigned int curIndex = 0; 438 unsigned int curIndex = 0;
431 if (!getCurEntryIndex(&curIndex)) 439 if (!getCurEntryIndex(&curIndex))
432 return; 440 return;
433 PwMDataItem d; 441 PwMDataItem d;
434 document()->getEntry(getCurrentCategory(), curIndex, &d); 442 document()->getEntry(getCurrentCategory(), curIndex, &d);
435 PwM::copyToClipboard(d.desc.c_str()); 443 PwM::copyToClipboard(d.desc.c_str());
436} 444}
437 445
438void PwMView::copyUrlToClip() 446void PwMView::copyUrlToClip()
439{ 447{
440 if (doc->isDeepLocked()) 448 if (doc->isDeepLocked())
441 return; 449 return;
442 unsigned int curIndex = 0; 450 unsigned int curIndex = 0;
443 if (!getCurEntryIndex(&curIndex)) 451 if (!getCurEntryIndex(&curIndex))
444 return; 452 return;
445 PwMDataItem d; 453 PwMDataItem d;
446 document()->getEntry(getCurrentCategory(), curIndex, &d); 454 document()->getEntry(getCurrentCategory(), curIndex, &d);
447 PwM::copyToClipboard(d.url.c_str()); 455 PwM::copyToClipboard(d.url.c_str());
448} 456}
449 457
450void PwMView::copyLauncherToClip() 458void PwMView::copyLauncherToClip()
451{ 459{
452 if (doc->isDeepLocked()) 460 if (doc->isDeepLocked())
453 return; 461 return;
454 unsigned int curIndex = 0; 462 unsigned int curIndex = 0;
455 if (!getCurEntryIndex(&curIndex)) 463 if (!getCurEntryIndex(&curIndex))
456 return; 464 return;
457 PwMDataItem d; 465 PwMDataItem d;
458 document()->getEntry(getCurrentCategory(), curIndex, &d); 466 document()->getEntry(getCurrentCategory(), curIndex, &d);
459 PwM::copyToClipboard(d.launcher.c_str()); 467 PwM::copyToClipboard(d.launcher.c_str());
460} 468}
461 469
462void PwMView::copyCommentToClip() 470void PwMView::copyCommentToClip()
463{ 471{
464 if (doc->isDeepLocked()) 472 if (doc->isDeepLocked())
465 return; 473 return;
466 unsigned int curIndex = 0; 474 unsigned int curIndex = 0;
467 if (!getCurEntryIndex(&curIndex)) 475 if (!getCurEntryIndex(&curIndex))
468 return; 476 return;
469 PwMDataItem d; 477 PwMDataItem d;
470 document()->getEntry(getCurrentCategory(), curIndex, &d); 478 document()->getEntry(getCurrentCategory(), curIndex, &d);
471 PwM::copyToClipboard(d.comment.c_str()); 479 PwM::copyToClipboard(d.comment.c_str());
472} 480}
473 481
474/************************************************************************ 482/************************************************************************
475 * 483 *
476 * 484 *
477 * 485 *
478 ************************************************************************/ 486 ************************************************************************/
479 487
480 488
481PwMDataItemView::PwMDataItemView( QWidget *parent, const char *name ) 489PwMDataItemView::PwMDataItemView( QWidget *parent, const char *name )
482 : QTextBrowser( parent, name ) 490 : Q3TextBrowser( parent, name )
483 491
484 492
485{ 493{
486//US setWrapPolicy( QTextEdit::AtWordBoundary ); 494//US setWrapPolicy( QTextEdit::AtWordBoundary );
487 setLinkUnderline( false ); 495 setLinkUnderline( false );
488 // setVScrollBarMode( QScrollView::AlwaysOff ); 496 // setVScrollBarMode( QScrollView::AlwaysOff );
489 //setHScrollBarMode( QScrollView::AlwaysOff ); 497 //setHScrollBarMode( QScrollView::AlwaysOff );
490 498
491//US QStyleSheet *sheet = styleSheet(); 499//US QStyleSheet *sheet = styleSheet();
492//US QStyleSheetItem *link = sheet->item( "a" ); 500//US QStyleSheetItem *link = sheet->item( "a" );
493//US link->setColor( KGlobalSettings::linkColor() ); 501//US link->setColor( KGlobalSettings::linkColor() );
494 502
495} 503}
496 504
497void PwMDataItemView::setPwMDataItem( const PwMDataItem& a ) 505void PwMDataItemView::setPwMDataItem( const PwMDataItem& a )
498 506
499{ 507{
500 mItem = a; 508 mItem = a;
501 // clear view 509 // clear view
502 setText( QString::null ); 510 setText( QString::null );
503 511
504 512
505 QString dynamicPart; 513 QString dynamicPart;
506 QString format = "<tr><td align=\"right\"><b>%1</b></td>" 514 QString format = "<tr><td align=\"right\"><b>%1</b></td>"
507 "<td align=\"left\">%2</td></tr>"; 515 "<td align=\"left\">%2</td></tr>";
508 516
509 dynamicPart += format 517 dynamicPart += format
510 .arg( i18n("LastUpdate") ) 518 .arg( i18n("LastUpdate") )
511 .arg( mItem.meta.update.toString().latin1() ); 519 .arg( mItem.meta.update.toString().latin1() );
512 520
513 dynamicPart += format 521 dynamicPart += format
514 .arg( i18n("Description") ) 522 .arg( i18n("Description") )
515 .arg( mItem.desc.c_str() ); 523 .arg( mItem.desc.c_str() );
516 524
517 dynamicPart += format 525 dynamicPart += format
518 .arg( i18n("Name") ) 526 .arg( i18n("Name") )
519 .arg( mItem.name.c_str() ); 527 .arg( mItem.name.c_str() );
520 528
521 dynamicPart += format 529 dynamicPart += format
522 .arg( i18n("Password") ) 530 .arg( i18n("Password") )
523 .arg( mItem.pw.c_str() ); 531 .arg( mItem.pw.c_str() );
524 532
525 QString comment(mItem.pw.c_str()); 533 QString comment(mItem.pw.c_str());
526 dynamicPart += format 534 dynamicPart += format
527 .arg( i18n("Comment") ) 535 .arg( i18n("Comment") )
528 .arg( comment.replace( QRegExp("\n"), "<br>" ) ); 536 .arg( comment.replace( QRegExp("\n"), "<br>" ) );
529 537
530 dynamicPart += format 538 dynamicPart += format
531 .arg( i18n("URL") ) 539 .arg( i18n("URL") )
532 .arg( mItem.url.c_str() ); 540 .arg( mItem.url.c_str() );
533 541
534 dynamicPart += format 542 dynamicPart += format
535 .arg( i18n("Launcher") ) 543 .arg( i18n("Launcher") )
536 .arg( mItem.launcher.c_str() ); 544 .arg( mItem.launcher.c_str() );
537 545
538 QString mText = "<table><td colspan=\"2\">&nbsp;</td>"; 546 QString mText = "<table><td colspan=\"2\">&nbsp;</td>";
539 547
540 mText += dynamicPart; 548 mText += dynamicPart;
541 mText += "</table>"; 549 mText += "</table>";
542 550
543 // at last display it... 551 // at last display it...
544 setText( mText ); 552 setText( mText );
545 553
546} 554}
547 555
548PwMDataItem PwMDataItemView::pwmdataitem() const 556PwMDataItem PwMDataItemView::pwmdataitem() const
549{ 557{
550 return mItem; 558 return mItem;
551} 559}
552 560
553/************************************************************************ 561/************************************************************************
554 * 562 *
555 * 563 *
556 * 564 *
557 ************************************************************************/ 565 ************************************************************************/
558 566
559 567
560PwMDataItemChooser::PwMDataItemChooser( PwMDataItem loc, PwMDataItem rem, bool takeloc, QWidget *parent, const char *name ) 568PwMDataItemChooser::PwMDataItemChooser( PwMDataItem loc, PwMDataItem rem, bool takeloc, QWidget *parent, const char *name )
561 : KDialogBase(parent, name, true , 569 : KDialogBase(parent, name, true ,
562 i18n("Conflict! Please choose Entry!"),Ok|User1|Close,Close, false) 570 i18n("Conflict! Please choose Entry!"),Ok|User1|Close,Close, false)
563{ 571{
564 findButton( Close )->setText( i18n("Cancel Sync")); 572 findButton( Close )->setText( i18n("Cancel Sync"));
565 findButton( Ok )->setText( i18n("Remote")); 573 findButton( Ok )->setText( i18n("Remote"));
566 findButton( User1 )->setText( i18n("Local")); 574 findButton( User1 )->setText( i18n("Local"));
567 QWidget* topframe = new QWidget( this ); 575 QWidget* topframe = new QWidget( this );
568 setMainWidget( topframe ); 576 setMainWidget( topframe );
569 QBoxLayout* bl; 577 Q3BoxLayout* bl;
570 if ( QApplication::desktop()->width() < 640 ) { 578 if ( QApplication::desktop()->width() < 640 ) {
571 bl = new QVBoxLayout( topframe ); 579 bl = new Q3VBoxLayout( topframe );
572 } else { 580 } else {
573 bl = new QHBoxLayout( topframe ); 581 bl = new Q3HBoxLayout( topframe );
574 } 582 }
575 QVBox* subframe = new QVBox( topframe ); 583 Q3VBox* subframe = new Q3VBox( topframe );
576 bl->addWidget(subframe ); 584 bl->addWidget(subframe );
577 QLabel* lab = new QLabel( i18n("Local Entry"), subframe ); 585 QLabel* lab = new QLabel( i18n("Local Entry"), subframe );
578 if ( takeloc ) 586 if ( takeloc )
579 lab->setBackgroundColor(Qt::green.light() ); 587 lab->setBackgroundColor(QColor(Qt::green).light() );
580 PwMDataItemView * av = new PwMDataItemView( subframe ); 588 PwMDataItemView * av = new PwMDataItemView( subframe );
581 av->setPwMDataItem( loc ); 589 av->setPwMDataItem( loc );
582 subframe = new QVBox( topframe ); 590 subframe = new Q3VBox( topframe );
583 bl->addWidget(subframe ); 591 bl->addWidget(subframe );
584 lab = new QLabel( i18n("Remote Entry"), subframe ); 592 lab = new QLabel( i18n("Remote Entry"), subframe );
585 if ( !takeloc ) 593 if ( !takeloc )
586 lab->setBackgroundColor(Qt::green.light() ); 594 lab->setBackgroundColor(QColor(Qt::green).light() );
587 av = new PwMDataItemView( subframe ); 595 av = new PwMDataItemView( subframe );
588 av->setPwMDataItem( rem ); 596 av->setPwMDataItem( rem );
589 QObject::connect(findButton( Ok ),SIGNAL(clicked()),this, SLOT(slot_remote())); 597 QObject::connect(findButton( Ok ),SIGNAL(clicked()),this, SLOT(slot_remote()));
590 QObject::connect(this,SIGNAL(user1Clicked()),this, SLOT(slot_local())); 598 QObject::connect(this,SIGNAL(user1Clicked()),this, SLOT(slot_local()));
591#ifndef DESKTOP_VERSION 599#ifndef DESKTOP_VERSION
592 showMaximized(); 600 showMaximized();
593#else 601#else
594 resize ( 640, 400 ); 602 resize ( 640, 400 );
595#endif 603#endif
596} 604}
597 605
598int PwMDataItemChooser::executeD( bool local ) 606int PwMDataItemChooser::executeD( bool local )
599{ 607{
600 mSyncResult = 3; 608 mSyncResult = 3;
601 if ( local ) 609 if ( local )
602 findButton( User1 )->setFocus(); 610 findButton( User1 )->setFocus();
603 else 611 else
604 findButton( Ok )->setFocus(); 612 findButton( Ok )->setFocus();
605 exec(); 613 exec();
606 return mSyncResult; 614 return mSyncResult;
607} 615}
608void PwMDataItemChooser::slot_remote() 616void PwMDataItemChooser::slot_remote()
609{ 617{
610 mSyncResult = 2; 618 mSyncResult = 2;
611 accept(); 619 accept();
612} 620}
613void PwMDataItemChooser::slot_local() 621void PwMDataItemChooser::slot_local()
614{ 622{
615 mSyncResult = 1; 623 mSyncResult = 1;
616 accept(); 624 accept();
617} 625}
618 626
619 627
620 628
621#ifndef PWM_EMBEDDED 629#ifndef PWM_EMBEDDED_
622#include "pwmview.moc" 630#include "moc_pwmview.cpp"
623#endif 631#endif
diff --git a/pwmanager/pwmanager/pwmview.h b/pwmanager/pwmanager/pwmview.h
index e42b17a..8f60063 100644
--- a/pwmanager/pwmanager/pwmview.h
+++ b/pwmanager/pwmanager/pwmview.h
@@ -1,197 +1,201 @@
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 PWMVIEW_H 20#ifndef PWMVIEW_H
21#define PWMVIEW_H 21#define PWMVIEW_H
22 22
23//US ENH: wouldn't it be a good idea if we could use this consts everywhere else. 23//US ENH: wouldn't it be a good idea if we could use this consts everywhere else.
24//US ENH: for examle in listviewpwm.cpp 24//US ENH: for examle in listviewpwm.cpp
25//US ENH: Because of that I transfer them into the headerfile. 25//US ENH: Because of that I transfer them into the headerfile.
26 #define COLUMN_DESC 0 26 #define COLUMN_DESC 0
27 #define COLUMN_NAME 1 27 #define COLUMN_NAME 1
28 #define COLUMN_PW 2 28 #define COLUMN_PW 2
29 #define COLUMN_URL 3 29 #define COLUMN_URL 3
30 #define COLUMN_LAUNCHER 4 30 #define COLUMN_LAUNCHER 4
31 31
32 32
33#include "listviewpwm.h" 33#include "listviewpwm.h"
34#include "pwmdoc.h" 34#include "pwmdoc.h"
35#include "pwmviewstyle.h" 35#include "pwmviewstyle.h"
36 36
37#include <kconfig.h> 37#include <kconfig.h>
38#include <klocale.h> 38#include <klocale.h>
39#include <kdialogbase.h> 39#include <kdialogbase.h>
40 40
41#include <qevent.h> 41#include <qevent.h>
42#include <qfont.h> 42#include <qfont.h>
43#include <qobject.h> 43#include <qobject.h>
44#include <qtextbrowser.h> 44#include <q3textbrowser.h>
45//Added by qt3to4:
46#include <QResizeEvent>
47#include <QKeyEvent>
48#include <Q3PopupMenu>
45 49
46#include <vector> 50#include <vector>
47#include <string> 51#include <string>
48 52
49using std::string; 53using std::string;
50using std::vector; 54using std::vector;
51 55
52class PwM; 56class PwM;
53class ConfFile; 57class ConfFile;
54class PwMStatusBar; 58class PwMStatusBar;
55 59
56 60
57/** View class for PwM */ 61/** View class for PwM */
58class PwMView : public PwMViewStyle 62class PwMView : public PwMViewStyle
59{ 63{
60 Q_OBJECT 64 Q_OBJECT
61 friend class PwMViewStyle; 65 friend class PwMViewStyle;
62public: 66public:
63 /** construtor */ 67 /** construtor */
64 PwMView(PwM *_mainClass, QWidget* parent, PwMDoc *_doc, 68 PwMView(PwM *_mainClass, QWidget* parent, PwMDoc *_doc,
65 const char *name = 0); 69 const char *name = 0);
66 /** destructor */ 70 /** destructor */
67 ~PwMView(); 71 ~PwMView();
68 72
69 /** returns pointer to the document */ 73 /** returns pointer to the document */
70 PwMDoc* document() 74 PwMDoc* document()
71 { return doc; } 75 { return doc; }
72 /** returns the index of the currently selected entry. 76 /** returns the index of the currently selected entry.
73 * (index as represented in PwMDoc !) 77 * (index as represented in PwMDoc !)
74 */ 78 */
75 bool getCurEntryIndex(unsigned int *index); 79 bool getCurEntryIndex(unsigned int *index);
76 /** returns the position of the given item in the document 80 /** returns the position of the given item in the document
77 * Note: This func only serches in the current category. 81 * Note: This func only serches in the current category.
78 */ 82 */
79 bool getDocEntryIndex(unsigned int *index, 83 bool getDocEntryIndex(unsigned int *index,
80 const QListViewItem *item); 84 const Q3ListViewItem *item);
81 85
82public slots: 86public slots:
83 /** update the view (call if dirty) */ 87 /** update the view (call if dirty) */
84 void updateView() 88 void updateView()
85 { 89 {
86 updateCategories(); 90 updateCategories();
87 shiftToView(); 91 shiftToView();
88 } 92 }
89 /** (re)sort all items and (re)shift them to listView. */ 93 /** (re)sort all items and (re)shift them to listView. */
90 void shiftToView(); 94 void shiftToView();
91 /** handle clicking on an item */ 95 /** handle clicking on an item */
92 void handleToggle(QListViewItem *item); 96 void handleToggle(Q3ListViewItem *item);
93 /** handle right-clicking on an item */ 97 /** handle right-clicking on an item */
94 void handleRightClick(QListViewItem *item, const QPoint &point, int); 98 void handleRightClick(Q3ListViewItem *item, const QPoint &point, int);
95 /** selects the item at "index" */ 99 /** selects the item at "index" */
96 void selAt(int index); 100 void selAt(int index);
97 /** rename category button pressed */ 101 /** rename category button pressed */
98 void renCatButton_slot(); 102 void renCatButton_slot();
99 /** delete category button pressed */ 103 /** delete category button pressed */
100 void delCatButton_slot(); 104 void delCatButton_slot();
101 105
102protected: 106protected:
103 /** right-click context-menu */ 107 /** right-click context-menu */
104 QPopupMenu *ctxMenu; 108 Q3PopupMenu *ctxMenu;
105 109
106protected: 110protected:
107 /** update the categories from document */ 111 /** update the categories from document */
108 void updateCategories(); 112 void updateCategories();
109 /** widget resize event */ 113 /** widget resize event */
110 void resizeEvent(QResizeEvent *); 114 void resizeEvent(QResizeEvent *);
111 /** initialize context-menu */ 115 /** initialize context-menu */
112 void initCtxMenu(); 116 void initCtxMenu();
113 /** tempoarly disable auto-sorting and user-sorting */ 117 /** tempoarly disable auto-sorting and user-sorting */
114 void tmpDisableSort() 118 void tmpDisableSort()
115 { lv->setSorting(-1); } 119 { lv->setSorting(-1); }
116 /** re-enable tempoarly disabled sorting */ 120 /** re-enable tempoarly disabled sorting */
117 void tmpReEnableSort() 121 void tmpReEnableSort()
118 { 122 {
119 lv->setSorting(lv->columns() + 1, 123 lv->setSorting(lv->columns() + 1,
120 true/*lv->sortOrder() == Qt::Ascending*/); 124 true/*lv->sortOrder() == Qt::Ascending*/);
121 } 125 }
122 /** The user pressed and released a key. */ 126 /** The user pressed and released a key. */
123 void keyReleaseEvent(QKeyEvent *e); 127 void keyReleaseEvent(QKeyEvent *e);
124 128
125protected slots: 129protected slots:
126 /** changes the comment text-edit, because a new item has been selected */ 130 /** changes the comment text-edit, because a new item has been selected */
127 void refreshCommentTextEdit(QListViewItem *curItem); 131 void refreshCommentTextEdit(Q3ListViewItem *curItem);
128 /** copy pw to clipboard */ 132 /** copy pw to clipboard */
129 void copyPwToClip(); 133 void copyPwToClip();
130 /** copy name to clipboard */ 134 /** copy name to clipboard */
131 void copyNameToClip(); 135 void copyNameToClip();
132 /** copy desc to clipboard */ 136 /** copy desc to clipboard */
133 void copyDescToClip(); 137 void copyDescToClip();
134 /** copy url to clipboard */ 138 /** copy url to clipboard */
135 void copyUrlToClip(); 139 void copyUrlToClip();
136 /** copy launcher to clipboard */ 140 /** copy launcher to clipboard */
137 void copyLauncherToClip(); 141 void copyLauncherToClip();
138 /** copy comment to clipboard */ 142 /** copy comment to clipboard */
139 void copyCommentToClip(); 143 void copyCommentToClip();
140 /** reorganize the "listViewPos" positions in the document 144 /** reorganize the "listViewPos" positions in the document
141 * (for the current category only!) 145 * (for the current category only!)
142 */ 146 */
143 void reorgLp(); 147 void reorgLp();
144 148
145private: 149private:
146 /** document */ 150 /** document */
147 PwMDoc *doc; 151 PwMDoc *doc;
148 /** pointer to the main class "PwM" */ 152 /** pointer to the main class "PwM" */
149 PwM *mainClass; 153 PwM *mainClass;
150}; 154};
151 155
152 156
153//US ENH basic widget to view an password entry. We need it for the sync stuff. 157//US ENH basic widget to view an password entry. We need it for the sync stuff.
154//But might be oif interest for other functionalities as well. 158//But might be oif interest for other functionalities as well.
155class PwMDataItemView : public QTextBrowser 159class PwMDataItemView : public Q3TextBrowser
156{ 160{
157 public: 161 public:
158 PwMDataItemView( QWidget *parent = 0, const char *name = 0 ); 162 PwMDataItemView( QWidget *parent = 0, const char *name = 0 );
159 163
160 /** 164 /**
161 Sets the PwMDataItem object. It is displayed immediately. 165 Sets the PwMDataItem object. It is displayed immediately.
162 166
163 @param a The PwMDataItem object. 167 @param a The PwMDataItem object.
164 */ 168 */
165 void setPwMDataItem( const PwMDataItem& a ); 169 void setPwMDataItem( const PwMDataItem& a );
166 170
167 /** 171 /**
168 Returns the current PwMDataItem object. 172 Returns the current PwMDataItem object.
169 */ 173 */
170 PwMDataItem pwmdataitem() const; 174 PwMDataItem pwmdataitem() const;
171 175
172 private: 176 private:
173 PwMDataItem mItem; 177 PwMDataItem mItem;
174}; 178};
175 179
176 180
177//US ENH we need this chooser when syncing results in a conflict 181//US ENH we need this chooser when syncing results in a conflict
178class PwMDataItemChooser : public KDialogBase 182class PwMDataItemChooser : public KDialogBase
179{ 183{
180 Q_OBJECT 184 Q_OBJECT
181 185
182 public: 186 public:
183 PwMDataItemChooser( PwMDataItem loc, PwMDataItem rem, bool takeloc, QWidget *parent = 0, const char *name = 0 ); 187 PwMDataItemChooser( PwMDataItem loc, PwMDataItem rem, bool takeloc, QWidget *parent = 0, const char *name = 0 );
184 188
185 int executeD( bool local ); 189 int executeD( bool local );
186 190
187 private: 191 private:
188 int mSyncResult; 192 int mSyncResult;
189 193
190 private slots: 194 private slots:
191 void slot_remote(); 195 void slot_remote();
192 void slot_local(); 196 void slot_local();
193 197
194}; 198};
195 199
196 200
197#endif 201#endif
diff --git a/pwmanager/pwmanager/pwmviewstyle.cpp b/pwmanager/pwmanager/pwmviewstyle.cpp
index ee35472..b6d930f 100644
--- a/pwmanager/pwmanager/pwmviewstyle.cpp
+++ b/pwmanager/pwmanager/pwmviewstyle.cpp
@@ -1,254 +1,254 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 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/*************************************************************************** 13/***************************************************************************
14 * copyright (C) 2004 by Ulf Schenk 14 * copyright (C) 2004 by Ulf Schenk
15 * This file is originaly based on version 1.0.1 of pwmanager 15 * This file is originaly based on version 1.0.1 of pwmanager
16 * and was modified to run on embedded devices that run microkde 16 * and was modified to run on embedded devices that run microkde
17 * 17 *
18 * $Id$ 18 * $Id$
19 **************************************************************************/ 19 **************************************************************************/
20 20
21#include "pwmviewstyle.h" 21#include "pwmviewstyle.h"
22#include "pwmexception.h" 22#include "pwmexception.h"
23#include "pwmviewstyle_0.h" 23#include "pwmviewstyle_0.h"
24#include "pwmviewstyle_1.h" 24#include "pwmviewstyle_1.h"
25#include "listviewpwm.h" 25#include "listviewpwm.h"
26#include "pwmview.h" 26#include "pwmview.h"
27#include "commentbox.h" 27#include "commentbox.h"
28#ifndef PWM_EMBEDDED 28#ifndef PWM_EMBEDDED
29#include "configuration.h" 29#include "configuration.h"
30#else 30#else
31#include "pwmprefs.h" 31#include "pwmprefs.h"
32#endif 32#endif
33 33
34PwMViewStyle::PwMViewStyle(QWidget *parent, const char *name) 34PwMViewStyle::PwMViewStyle(QWidget *parent, const char *name)
35 : QWidget(parent, name) 35 : QWidget(parent, name)
36{ 36{
37 curStyle = style_notset; 37 curStyle = style_notset;
38 s0 = 0; 38 s0 = 0;
39 s1 = 0; 39 s1 = 0;
40} 40}
41 41
42PwMViewStyle::~PwMViewStyle() 42PwMViewStyle::~PwMViewStyle()
43{ 43{
44 //US ENH : store the size of the listviewcolumns 44 //US ENH : store the size of the listviewcolumns
45 switch (curStyle) 45 switch (curStyle)
46 { 46 {
47 case style_0: 47 case style_0:
48 s0->saveSettings(PWMPrefs::instance()); 48 s0->saveSettings(PWMPrefs::instance());
49 break; 49 break;
50 case style_1: 50 case style_1:
51 s1->saveSettings(PWMPrefs::instance()); 51 s1->saveSettings(PWMPrefs::instance());
52 break; 52 break;
53 default: 53 default:
54 BUG(); 54 BUG();
55 } 55 }
56 56
57 57
58 PWMPrefs::instance()->writeConfig(); 58 PWMPrefs::instance()->writeConfig();
59 59
60 delete_ifnot_null(s0); 60 delete_ifnot_null(s0);
61 delete_ifnot_null(s1); 61 delete_ifnot_null(s1);
62} 62}
63 63
64void PwMViewStyle::editPassWord( QListViewItem * i ) 64void PwMViewStyle::editPassWord( Q3ListViewItem * i )
65{ 65{
66 if ( !i ) 66 if ( !i )
67 return; 67 return;
68 emit editPW(); 68 emit editPW();
69} 69}
70void PwMViewStyle::initStyle(style_t style) 70void PwMViewStyle::initStyle(style_t style)
71{ 71{
72 printDebug(string("initializing style ") + tostr(style)); 72 printDebug(string("initializing style ") + tostr(style));
73 bool wasMaximized = v->isMaximized(); 73 bool wasMaximized = v->isMaximized();
74 if (v->isVisible()) 74 if (v->isVisible())
75 v->hide(); 75 v->hide();
76 switch (style) { 76 switch (style) {
77 case style_0: 77 case style_0:
78 delete_ifnot_null(s0); 78 delete_ifnot_null(s0);
79 delete_ifnot_null(s1); 79 delete_ifnot_null(s1);
80 s0 = new PwMViewStyle_0(v); 80 s0 = new PwMViewStyle_0(v);
81 lv = s0->getLv(); 81 lv = s0->getLv();
82 commentBox = s0->getCommentBox(); 82 commentBox = s0->getCommentBox();
83 break; 83 break;
84 case style_1: 84 case style_1:
85 delete_ifnot_null(s0); 85 delete_ifnot_null(s0);
86 delete_ifnot_null(s1); 86 delete_ifnot_null(s1);
87 s1 = new PwMViewStyle_1(v); 87 s1 = new PwMViewStyle_1(v);
88 lv = s1->getLv(); 88 lv = s1->getLv();
89 commentBox = s1->getCommentBox(); 89 commentBox = s1->getCommentBox();
90 break; 90 break;
91 default: 91 default:
92 BUG(); 92 BUG();
93 return; 93 return;
94 } 94 }
95 curStyle = style; 95 curStyle = style;
96 connect(lv, SIGNAL(pressed(QListViewItem *)), 96 connect(lv, SIGNAL(pressed(Q3ListViewItem *)),
97 v, SLOT(handleToggle(QListViewItem *))); 97 v, SLOT(handleToggle(Q3ListViewItem *)));
98 connect(lv, SIGNAL(rightButtonClicked(QListViewItem *, const QPoint &, int)), 98 connect(lv, SIGNAL(rightButtonClicked(Q3ListViewItem *, const QPoint &, int)),
99 v, SLOT(handleRightClick(QListViewItem *, const QPoint &, int))); 99 v, SLOT(handleRightClick(Q3ListViewItem *, const QPoint &, int)));
100 connect(lv, SIGNAL(clicked(QListViewItem *)), 100 connect(lv, SIGNAL(clicked(Q3ListViewItem *)),
101 v, SLOT(refreshCommentTextEdit(QListViewItem *))); 101 v, SLOT(refreshCommentTextEdit(Q3ListViewItem *)));
102 connect(lv, SIGNAL(returnPressed(QListViewItem *)), 102 connect(lv, SIGNAL(returnPressed(Q3ListViewItem *)),
103 this, SLOT(editPassWord(QListViewItem *))); 103 this, SLOT(editPassWord(Q3ListViewItem *)));
104 connect(lv, SIGNAL(doubleClicked(QListViewItem *)), 104 connect(lv, SIGNAL(doubleClicked(Q3ListViewItem *)),
105 this, SLOT(editPassWord(QListViewItem *))); 105 this, SLOT(editPassWord(Q3ListViewItem *)));
106 connect(lv, SIGNAL(insertPW()), 106 connect(lv, SIGNAL(insertPW()),
107 this, SIGNAL( insertPW() )); 107 this, SIGNAL( insertPW() ));
108 connect(lv, SIGNAL(deletePW()), 108 connect(lv, SIGNAL(deletePW()),
109 this, SIGNAL( deletePW() )); 109 this, SIGNAL( deletePW() ));
110 110
111 lv->addColumn(i18n("Description"), 180); 111 lv->addColumn(i18n("Description"), 180);
112 lv->addColumn(i18n("Username"), 150); 112 lv->addColumn(i18n("Username"), 150);
113 lv->addColumn(i18n("Password"), 150); 113 lv->addColumn(i18n("Password"), 150);
114 lv->addColumn(i18n("URL"), 180); 114 lv->addColumn(i18n("URL"), 180);
115 lv->addColumn(i18n("Launcher"), 120); 115 lv->addColumn(i18n("Launcher"), 120);
116 v->tmpReEnableSort(); 116 v->tmpReEnableSort();
117 117
118 //US ENH : load the size of the listviewcolumns 118 //US ENH : load the size of the listviewcolumns
119 switch (curStyle) 119 switch (curStyle)
120 { 120 {
121 case style_0: 121 case style_0:
122 s0->restoreSettings(PWMPrefs::instance()); 122 s0->restoreSettings(PWMPrefs::instance());
123 break; 123 break;
124 case style_1: 124 case style_1:
125 s1->restoreSettings(PWMPrefs::instance()); 125 s1->restoreSettings(PWMPrefs::instance());
126 break; 126 break;
127 default: 127 default:
128 BUG(); 128 BUG();
129 } 129 }
130 130
131 resizeView(v->size()); 131 resizeView(v->size());
132 v->updateView(); 132 v->updateView();
133 if (wasMaximized) { 133 if (wasMaximized) {
134 v->showMaximized(); 134 v->showMaximized();
135 } else { 135 } else {
136 v->show(); 136 v->show();
137 } 137 }
138 connect(lv, SIGNAL(layoutChanged()), 138 connect(lv, SIGNAL(layoutChanged()),
139 v, SLOT(reorgLp())); 139 v, SLOT(reorgLp()));
140} 140}
141 141
142void PwMViewStyle::resizeView(const QSize &size) 142void PwMViewStyle::resizeView(const QSize &size)
143{ 143{
144 switch (curStyle) { 144 switch (curStyle) {
145 case style_0: 145 case style_0:
146 PWM_ASSERT(s0); 146 PWM_ASSERT(s0);
147 s0->resize(size); 147 s0->resize(size);
148 return; 148 return;
149 case style_1: 149 case style_1:
150 PWM_ASSERT(s1); 150 PWM_ASSERT(s1);
151 s1->resize(size); 151 s1->resize(size);
152 return; 152 return;
153 default: 153 default:
154 BUG(); 154 BUG();
155 } 155 }
156} 156}
157 157
158QString PwMViewStyle::getCurrentCategory() 158QString PwMViewStyle::getCurrentCategory()
159{ 159{
160 switch (curStyle) { 160 switch (curStyle) {
161 case style_0: 161 case style_0:
162 PWM_ASSERT(s0); 162 PWM_ASSERT(s0);
163 return s0->getCurrentCategory(); 163 return s0->getCurrentCategory();
164 case style_1: 164 case style_1:
165 PWM_ASSERT(s1); 165 PWM_ASSERT(s1);
166 return s1->getCurrentCategory(); 166 return s1->getCurrentCategory();
167 default: 167 default:
168 BUG(); 168 BUG();
169 } 169 }
170 return ""; 170 return "";
171} 171}
172 172
173void PwMViewStyle::addCategory(const QString &cat) 173void PwMViewStyle::addCategory(const QString &cat)
174{ 174{
175 switch (curStyle) { 175 switch (curStyle) {
176 case style_0: 176 case style_0:
177 PWM_ASSERT(s0); 177 PWM_ASSERT(s0);
178 s0->addCategory(cat); 178 s0->addCategory(cat);
179 return; 179 return;
180 case style_1: 180 case style_1:
181 PWM_ASSERT(s1); 181 PWM_ASSERT(s1);
182 s1->addCategory(cat); 182 s1->addCategory(cat);
183 return; 183 return;
184 default: 184 default:
185 BUG(); 185 BUG();
186 } 186 }
187} 187}
188 188
189void PwMViewStyle::delCategory(const QString &cat) 189void PwMViewStyle::delCategory(const QString &cat)
190{ 190{
191 switch (curStyle) { 191 switch (curStyle) {
192 case style_0: 192 case style_0:
193 PWM_ASSERT(s0); 193 PWM_ASSERT(s0);
194 s0->delCategory(cat); 194 s0->delCategory(cat);
195 return; 195 return;
196 case style_1: 196 case style_1:
197 PWM_ASSERT(s1); 197 PWM_ASSERT(s1);
198 s1->delCategory(cat); 198 s1->delCategory(cat);
199 return; 199 return;
200 default: 200 default:
201 BUG(); 201 BUG();
202 } 202 }
203} 203}
204 204
205void PwMViewStyle::delAllCategories() 205void PwMViewStyle::delAllCategories()
206{ 206{
207 switch (curStyle) { 207 switch (curStyle) {
208 case style_0: 208 case style_0:
209 PWM_ASSERT(s0); 209 PWM_ASSERT(s0);
210 s0->delAllCategories(); 210 s0->delAllCategories();
211 return; 211 return;
212 case style_1: 212 case style_1:
213 PWM_ASSERT(s1); 213 PWM_ASSERT(s1);
214 s1->delAllCategories(); 214 s1->delAllCategories();
215 return; 215 return;
216 default: 216 default:
217 BUG(); 217 BUG();
218 } 218 }
219} 219}
220 220
221void PwMViewStyle::selectCategory(const QString &cat) 221void PwMViewStyle::selectCategory(const QString &cat)
222{ 222{
223 switch (curStyle) { 223 switch (curStyle) {
224 case style_0: 224 case style_0:
225 PWM_ASSERT(s0); 225 PWM_ASSERT(s0);
226 s0->selectCategory(cat); 226 s0->selectCategory(cat);
227 return; 227 return;
228 case style_1: 228 case style_1:
229 PWM_ASSERT(s1); 229 PWM_ASSERT(s1);
230 s1->selectCategory(cat); 230 s1->selectCategory(cat);
231 return; 231 return;
232 default: 232 default:
233 BUG(); 233 BUG();
234 } 234 }
235} 235}
236 236
237int PwMViewStyle::numCategories() 237int PwMViewStyle::numCategories()
238{ 238{
239 switch (curStyle) { 239 switch (curStyle) {
240 case style_0: 240 case style_0:
241 PWM_ASSERT(s0); 241 PWM_ASSERT(s0);
242 return s0->numCategories(); 242 return s0->numCategories();
243 case style_1: 243 case style_1:
244 PWM_ASSERT(s1); 244 PWM_ASSERT(s1);
245 return s1->numCategories(); 245 return s1->numCategories();
246 default: 246 default:
247 BUG(); 247 BUG();
248 } 248 }
249 return 0; 249 return 0;
250} 250}
251 251
252#ifndef PWM_EMBEDDED 252#ifndef PWM_EMBEDDED_
253#include "pwmviewstyle.moc" 253#include "moc_pwmviewstyle.cpp"
254#endif 254#endif
diff --git a/pwmanager/pwmanager/pwmviewstyle.h b/pwmanager/pwmanager/pwmviewstyle.h
index 6c2d81c..a7dccbe 100644
--- a/pwmanager/pwmanager/pwmviewstyle.h
+++ b/pwmanager/pwmanager/pwmviewstyle.h
@@ -1,115 +1,115 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 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/*************************************************************************** 13/***************************************************************************
14 * copyright (C) 2004 by Ulf Schenk 14 * copyright (C) 2004 by Ulf Schenk
15 * This file is originaly based on version 1.0.1 of pwmanager 15 * This file is originaly based on version 1.0.1 of pwmanager
16 * and was modified to run on embedded devices that run microkde 16 * and was modified to run on embedded devices that run microkde
17 * 17 *
18 * $Id$ 18 * $Id$
19 **************************************************************************/ 19 **************************************************************************/
20 20
21#ifndef PWMVIEWSTYLE_H 21#ifndef PWMVIEWSTYLE_H
22#define PWMVIEWSTYLE_H 22#define PWMVIEWSTYLE_H
23 23
24#include <qwidget.h> 24#include <qwidget.h>
25#include <qsplitter.h> 25#include <qsplitter.h>
26#include <qhbox.h> 26#include <q3hbox.h>
27#include <qvbox.h> 27#include <q3vbox.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qpopupmenu.h> 29#include <q3popupmenu.h>
30#ifndef PWM_EMBEDDED 30#ifndef PWM_EMBEDDED
31#include <qtextedit.h> 31#include <q3textedit.h>
32#else 32#else
33#include <qmultilineedit.h> 33#include <q3multilineedit.h>
34#endif 34#endif
35 35
36#include <qlabel.h> 36#include <qlabel.h>
37#include <qlistbox.h> 37#include <q3listbox.h>
38#include <qcombobox.h> 38#include <qcombobox.h>
39#include <qsize.h> 39#include <qsize.h>
40 40
41class ListViewPwM; 41class ListViewPwM;
42class PwMViewStyle_0; 42class PwMViewStyle_0;
43class PwMViewStyle_1; 43class PwMViewStyle_1;
44class PwMView; 44class PwMView;
45class QListViewItem; 45class Q3ListViewItem;
46class CommentBox; 46class CommentBox;
47 47
48class PwMViewStyle : public QWidget 48class PwMViewStyle : public QWidget
49{ 49{
50 Q_OBJECT 50 Q_OBJECT
51 51
52public: 52public:
53 enum style_t 53 enum style_t
54 { 54 {
55 style_notset= -1, 55 style_notset= -1,
56 style_0 = 0, 56 style_0 = 0,
57 style_1 = 1 57 style_1 = 1
58 }; 58 };
59 59
60public: 60public:
61 PwMViewStyle(QWidget *parent = 0, const char *name = 0); 61 PwMViewStyle(QWidget *parent = 0, const char *name = 0);
62 ~PwMViewStyle(); 62 ~PwMViewStyle();
63 63
64 /** initialize a new style */ 64 /** initialize a new style */
65 void initStyle(style_t style); 65 void initStyle(style_t style);
66 void initStyle(int style) 66 void initStyle(int style)
67 { initStyle(static_cast<style_t>(style)); } 67 { initStyle(static_cast<style_t>(style)); }
68 /** returns the currently used style */ 68 /** returns the currently used style */
69 style_t getCurStyle() 69 style_t getCurStyle()
70 { return curStyle; } 70 { return curStyle; }
71 void setView(PwMView *view) 71 void setView(PwMView *view)
72 { v = view; } 72 { v = view; }
73 73
74 /** returns the currently selected category */ 74 /** returns the currently selected category */
75 QString getCurrentCategory(); 75 QString getCurrentCategory();
76 76
77protected: 77protected:
78 /** add Category to the view */ 78 /** add Category to the view */
79 void addCategory(const QString &cat); 79 void addCategory(const QString &cat);
80 /** delete Category from view */ 80 /** delete Category from view */
81 void delCategory(const QString &cat); 81 void delCategory(const QString &cat);
82 /** delete all categories from view */ 82 /** delete all categories from view */
83 void delAllCategories(); 83 void delAllCategories();
84 /** select the specified category */ 84 /** select the specified category */
85 void selectCategory(const QString &cat); 85 void selectCategory(const QString &cat);
86 /** returns the number of categories in this view. 86 /** returns the number of categories in this view.
87 * This value dosn't say anything about the number of 87 * This value dosn't say anything about the number of
88 * categories in the document. 88 * categories in the document.
89 */ 89 */
90 int numCategories(); 90 int numCategories();
91 /** resize the view */ 91 /** resize the view */
92 void resizeView(const QSize &size); 92 void resizeView(const QSize &size);
93 ListViewPwM *lv; 93 ListViewPwM *lv;
94 CommentBox *commentBox; 94 CommentBox *commentBox;
95 95
96protected slots: 96protected slots:
97 void editPassWord( QListViewItem * ); 97 void editPassWord( Q3ListViewItem * );
98 98
99private: 99private:
100 /** which style has the view? 100 /** which style has the view?
101 * KListBox on the left, 101 * KListBox on the left,
102 * or QComboBox on the top? 102 * or QComboBox on the top?
103 */ 103 */
104 style_t curStyle; 104 style_t curStyle;
105 105
106 PwMViewStyle_0 *s0; 106 PwMViewStyle_0 *s0;
107 PwMViewStyle_1 *s1; 107 PwMViewStyle_1 *s1;
108 PwMView *v; 108 PwMView *v;
109 signals: 109 signals:
110 void editPW(); 110 void editPW();
111 void insertPW(); 111 void insertPW();
112 void deletePW(); 112 void deletePW();
113 113
114}; 114};
115#endif 115#endif
diff --git a/pwmanager/pwmanager/pwmviewstyle_0.cpp b/pwmanager/pwmanager/pwmviewstyle_0.cpp
index 1d88a34..3d1f41f 100644
--- a/pwmanager/pwmanager/pwmviewstyle_0.cpp
+++ b/pwmanager/pwmanager/pwmviewstyle_0.cpp
@@ -1,144 +1,147 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 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 "pwmviewstyle_0.h" 20#include "pwmviewstyle_0.h"
21#include "pwmview.h" 21#include "pwmview.h"
22#include "listviewpwm.h" 22#include "listviewpwm.h"
23#include "commentbox.h" 23#include "commentbox.h"
24 24
25#include <klocale.h> 25#include <klocale.h>
26#include <kglobal.h> 26#include <kglobal.h>
27#include <kiconloader.h> 27#include <kiconloader.h>
28#include "pwmprefs.h" 28#include "pwmprefs.h"
29//Added by qt3to4:
30#include <QLabel>
31#include <Q3ValueList>
29 32
30PwMViewStyle_0::PwMViewStyle_0(PwMView *view) 33PwMViewStyle_0::PwMViewStyle_0(PwMView *view)
31 : QObject() 34 : QObject()
32{ 35{
33 vbox1 = new QVBox(view); 36 vbox1 = new Q3VBox(view);
34 vbox1->setSpacing(0); 37 vbox1->setSpacing(0);
35 hbox1 = new QHBox(vbox1); 38 hbox1 = new Q3HBox(vbox1);
36 hbox1->setSpacing(0); 39 hbox1->setSpacing(0);
37 categoriesTitle = new QLabel(hbox1); 40 categoriesTitle = new QLabel(hbox1);
38 categoriesTitle->setText(i18n("Category:")); 41 categoriesTitle->setText(i18n("Category:"));
39 categoriesCombo = new QComboBox(hbox1); 42 categoriesCombo = new QComboBox(hbox1);
40 categoriesCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding,QSizePolicy::Preferred )); 43 categoriesCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding,QSizePolicy::Preferred ));
41 renCatButton = new QPushButton( hbox1); 44 renCatButton = new QPushButton( hbox1);
42 renCatButton->setPixmap (KGlobal::iconLoader()->loadIcon("edit", KIcon::Small) ); 45 renCatButton->setPixmap (KGlobal::iconLoader()->loadIcon("edit", KIcon::Small) );
43 int maxsi = renCatButton->sizeHint().height()+4; 46 int maxsi = renCatButton->sizeHint().height()+4;
44 renCatButton->setMinimumSize( maxsi, maxsi ); 47 renCatButton->setMinimumSize( maxsi, maxsi );
45 delCatButton = new QPushButton( hbox1); 48 delCatButton = new QPushButton( hbox1);
46 delCatButton->setPixmap (KGlobal::iconLoader()->loadIcon("editdelete", KIcon::Small) ); 49 delCatButton->setPixmap (KGlobal::iconLoader()->loadIcon("editdelete", KIcon::Small) );
47 maxsi = delCatButton->sizeHint().height()+4; 50 maxsi = delCatButton->sizeHint().height()+4;
48 delCatButton->setMinimumSize( maxsi, maxsi ); 51 delCatButton->setMinimumSize( maxsi, maxsi );
49 delCatButton->setFocusPolicy( QWidget::NoFocus ); 52 delCatButton->setFocusPolicy( Qt::NoFocus );
50 renCatButton->setFocusPolicy( QWidget::NoFocus ); 53 renCatButton->setFocusPolicy( Qt::NoFocus );
51 54
52#ifndef PWM_EMBEDDED 55#ifndef PWM_EMBEDDED
53 splitter1 = new QSplitter(vbox1); 56 splitter1 = new QSplitter(vbox1);
54 splitter1->setOrientation(Qt::Vertical); 57 splitter1->setOrientation(Qt::Vertical);
55#else 58#else
56 splitter1 = new KDGanttMinimizeSplitter( Qt::Vertical, vbox1); 59 splitter1 = new KDGanttMinimizeSplitter( Qt::Vertical, vbox1);
57 splitter1->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 60 splitter1->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
58 61
59 //US topLayout->addWidget(mMiniSplitter ); 62 //US topLayout->addWidget(mMiniSplitter );
60#endif 63#endif
61 lv = new ListViewPwM(splitter1); 64 lv = new ListViewPwM(splitter1);
62 commentBox = new CommentBox(splitter1); 65 commentBox = new CommentBox(splitter1);
63 // set sizes and styles 66 // set sizes and styles
64 commentBox->resize(commentBox->size().width(), 60); 67 commentBox->resize(commentBox->size().width(), 60);
65 categoriesTitle->setAlignment(Qt::AlignVCenter | Qt::AlignRight); 68 categoriesTitle->setAlignment(Qt::AlignVCenter | Qt::AlignRight);
66 // connections 69 // connections
67 connect(categoriesCombo, SIGNAL(activated(int)), 70 connect(categoriesCombo, SIGNAL(activated(int)),
68 view, SLOT(shiftToView())); 71 view, SLOT(shiftToView()));
69 connect(renCatButton, SIGNAL(clicked()), 72 connect(renCatButton, SIGNAL(clicked()),
70 view, SLOT(renCatButton_slot())); 73 view, SLOT(renCatButton_slot()));
71 connect(delCatButton, SIGNAL(clicked()), 74 connect(delCatButton, SIGNAL(clicked()),
72 view, SLOT(delCatButton_slot())); 75 view, SLOT(delCatButton_slot()));
73 connect(lv, SIGNAL(toggleOverview()), 76 connect(lv, SIGNAL(toggleOverview()),
74 this, SLOT(toggleSplitter())); 77 this, SLOT(toggleSplitter()));
75} 78}
76 79
77PwMViewStyle_0::~PwMViewStyle_0() 80PwMViewStyle_0::~PwMViewStyle_0()
78{ 81{
79 delete vbox1; 82 delete vbox1;
80} 83}
81void PwMViewStyle_0::toggleSplitter() 84void PwMViewStyle_0::toggleSplitter()
82{ 85{
83 86
84 QValueList<int> si = splitter1->sizes(); 87 Q3ValueList<int> si = splitter1->sizes();
85 splitter1->toggle(); 88 splitter1->toggle();
86 QValueList<int> si2 = splitter1->sizes(); 89 Q3ValueList<int> si2 = splitter1->sizes();
87 //qDebug("PwMViewStyle_0::toggleSplitter() %d %d %d %d", si[0],si[1],si2[0],si2[1] ); 90 //qDebug("PwMViewStyle_0::toggleSplitter() %d %d %d %d", si[0],si[1],si2[0],si2[1] );
88 if ( si[0] == si2[0] && si[1] == si2[1] && si2[1] == 1 ) { 91 if ( si[0] == si2[0] && si[1] == si2[1] && si2[1] == 1 ) {
89 int diff = si[0]/2; 92 int diff = si[0]/2;
90 if ( diff > 200 ) 93 if ( diff > 200 )
91 diff = 200; 94 diff = 200;
92 si[0] -= diff; 95 si[0] -= diff;
93 si[1] += diff; 96 si[1] += diff;
94 splitter1->toggle(); 97 splitter1->toggle();
95 splitter1->setSizes( si ); 98 splitter1->setSizes( si );
96 } 99 }
97 100
98} 101}
99 102
100void PwMViewStyle_0::delCategory(const QString &cat) 103void PwMViewStyle_0::delCategory(const QString &cat)
101{ 104{
102 PWM_ASSERT(categoriesCombo); 105 PWM_ASSERT(categoriesCombo);
103 int i, count = categoriesCombo->count(); 106 int i, count = categoriesCombo->count();
104 for (i = 0; i < count; ++i) { 107 for (i = 0; i < count; ++i) {
105 if (categoriesCombo->text(i) == cat) { 108 if (categoriesCombo->text(i) == cat) {
106 categoriesCombo->removeItem(i); 109 categoriesCombo->removeItem(i);
107 return; 110 return;
108 } 111 }
109 } 112 }
110 BUG(); 113 BUG();
111} 114}
112 115
113void PwMViewStyle_0::selectCategory(const QString &cat) 116void PwMViewStyle_0::selectCategory(const QString &cat)
114{ 117{
115 PWM_ASSERT(categoriesCombo); 118 PWM_ASSERT(categoriesCombo);
116 int i, count = categoriesCombo->count(); 119 int i, count = categoriesCombo->count();
117 for (i = 0; i < count; ++i) { 120 for (i = 0; i < count; ++i) {
118 if (categoriesCombo->text(i) == cat) { 121 if (categoriesCombo->text(i) == cat) {
119 categoriesCombo->setCurrentItem(i); 122 categoriesCombo->setCurrentItem(i);
120 return; 123 return;
121 } 124 }
122 } 125 }
123 // fall back to 0 126 // fall back to 0
124 categoriesCombo->setCurrentItem(0); 127 categoriesCombo->setCurrentItem(0);
125} 128}
126 129
127 130
128//US ENH: I need a place to load the view dependend settings. Eg. splittersize 131//US ENH: I need a place to load the view dependend settings. Eg. splittersize
129void PwMViewStyle_0::restoreSettings(PWMPrefs* prefs) 132void PwMViewStyle_0::restoreSettings(PWMPrefs* prefs)
130{ 133{
131 //load and store the size of the listviewcolumns 134 //load and store the size of the listviewcolumns
132 lv->restoreLayout(prefs->getConfig(), "listview"); 135 lv->restoreLayout(prefs->getConfig(), "listview");
133 splitter1->setSizes( prefs->mCommentSplitter ); 136 splitter1->setSizes( prefs->mCommentSplitter );
134 commentBox->setFont( prefs->mViewFont ); 137 commentBox->setFont( prefs->mViewFont );
135} 138}
136 139
137//US ENH: I need a place to load the view dependend settings. Eg. splittersize 140//US ENH: I need a place to load the view dependend settings. Eg. splittersize
138void PwMViewStyle_0::saveSettings(PWMPrefs* prefs) 141void PwMViewStyle_0::saveSettings(PWMPrefs* prefs)
139{ 142{
140 //store the size of the listviewcolumns 143 //store the size of the listviewcolumns
141 lv->saveLayout(prefs->getConfig(), "listview"); 144 lv->saveLayout(prefs->getConfig(), "listview");
142 prefs->mCommentSplitter = splitter1->sizes(); 145 prefs->mCommentSplitter = splitter1->sizes();
143 146
144} 147}
diff --git a/pwmanager/pwmanager/pwmviewstyle_0.h b/pwmanager/pwmanager/pwmviewstyle_0.h
index 6d3c1d1..f144eec 100644
--- a/pwmanager/pwmanager/pwmviewstyle_0.h
+++ b/pwmanager/pwmanager/pwmviewstyle_0.h
@@ -1,107 +1,107 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 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 PWMVIEWSTYLE_0_H 20#ifndef PWMVIEWSTYLE_0_H
21#define PWMVIEWSTYLE_0_H 21#define PWMVIEWSTYLE_0_H
22 22
23#include <qhbox.h> 23#include <q3hbox.h>
24#include <qvbox.h> 24#include <q3vbox.h>
25#include <qpushbutton.h> 25#include <qpushbutton.h>
26#ifndef PWM_EMBEDDED 26#ifndef PWM_EMBEDDED
27#include <qtextedit.h> 27#include <q3textedit.h>
28#include <qsplitter.h> 28#include <qsplitter.h>
29#else 29#else
30#include <qmultilineedit.h> 30#include <q3multilineedit.h>
31#include <KDGanttMinimizeSplitter.h> 31#include <KDGanttMinimizeSplitter.h>
32#endif 32#endif
33#include <qlabel.h> 33#include <qlabel.h>
34#include <qcombobox.h> 34#include <qcombobox.h>
35 35
36class PwMView; 36class PwMView;
37class ListViewPwM; 37class ListViewPwM;
38class CommentBox; 38class CommentBox;
39class PWMPrefs; 39class PWMPrefs;
40 40
41class PwMViewStyle_0 : public QObject 41class PwMViewStyle_0 : public QObject
42{ 42{
43 Q_OBJECT 43 Q_OBJECT
44public: 44public:
45 PwMViewStyle_0(PwMView *view); 45 PwMViewStyle_0(PwMView *view);
46 ~PwMViewStyle_0(); 46 ~PwMViewStyle_0();
47 47
48 ListViewPwM * getLv() 48 ListViewPwM * getLv()
49 { return lv; } 49 { return lv; }
50 CommentBox * getCommentBox() 50 CommentBox * getCommentBox()
51 { return commentBox; } 51 { return commentBox; }
52 52
53 /** returns the currently selected category */ 53 /** returns the currently selected category */
54 QString getCurrentCategory() 54 QString getCurrentCategory()
55 { return categoriesCombo->currentText(); } 55 { return categoriesCombo->currentText(); }
56 /** add Category to the view */ 56 /** add Category to the view */
57 void addCategory(const QString &cat) 57 void addCategory(const QString &cat)
58 { categoriesCombo->insertItem(cat); } 58 { categoriesCombo->insertItem(cat); }
59 /** delete Category from view */ 59 /** delete Category from view */
60 void delCategory(const QString &cat); 60 void delCategory(const QString &cat);
61 /** delete all categories from view */ 61 /** delete all categories from view */
62 void delAllCategories() 62 void delAllCategories()
63 { categoriesCombo->clear(); } 63 { categoriesCombo->clear(); }
64 /** select the specified category */ 64 /** select the specified category */
65 void selectCategory(const QString &cat); 65 void selectCategory(const QString &cat);
66 /** returns the number of categories in this view. 66 /** returns the number of categories in this view.
67 * This value dosn't say anything about the number of 67 * This value dosn't say anything about the number of
68 * categories in the document. 68 * categories in the document.
69 */ 69 */
70 int numCategories() 70 int numCategories()
71 { return categoriesCombo->count(); } 71 { return categoriesCombo->count(); }
72 /** resize the view */ 72 /** resize the view */
73 void resize(const QSize &size) 73 void resize(const QSize &size)
74 { vbox1->resize(size); } 74 { vbox1->resize(size); }
75 75
76 //US ENH: I need a place to load the view dependend settings. Eg. splittersize 76 //US ENH: I need a place to load the view dependend settings. Eg. splittersize
77 void restoreSettings(PWMPrefs* prefs); 77 void restoreSettings(PWMPrefs* prefs);
78 void saveSettings(PWMPrefs* prefs); 78 void saveSettings(PWMPrefs* prefs);
79 79
80public slots: 80public slots:
81 void toggleSplitter(); 81 void toggleSplitter();
82protected: 82protected:
83 /** main list view */ 83 /** main list view */
84 ListViewPwM *lv; 84 ListViewPwM *lv;
85 /** categories combo-box */ 85 /** categories combo-box */
86 QComboBox *categoriesCombo; 86 QComboBox *categoriesCombo;
87 /** title string for the categories combo or list box */ 87 /** title string for the categories combo or list box */
88 QLabel *categoriesTitle; 88 QLabel *categoriesTitle;
89 /** hbox1 for widget style */ 89 /** hbox1 for widget style */
90 QHBox *hbox1; 90 Q3HBox *hbox1;
91 /** vbox1 for widget style */ 91 /** vbox1 for widget style */
92 QVBox *vbox1; 92 Q3VBox *vbox1;
93 /** splitter for commentTextEdit */ 93 /** splitter for commentTextEdit */
94 #ifndef PWM_EMBEDDED 94 #ifndef PWM_EMBEDDED
95 QSplitter *splitter1; 95 QSplitter *splitter1;
96#else 96#else
97 KDGanttMinimizeSplitter * splitter1; 97 KDGanttMinimizeSplitter * splitter1;
98#endif 98#endif
99 /** push button to change the category name */ 99 /** push button to change the category name */
100 QPushButton *renCatButton; 100 QPushButton *renCatButton;
101 /** push button to delete the category */ 101 /** push button to delete the category */
102 QPushButton *delCatButton; 102 QPushButton *delCatButton;
103 /** comment box */ 103 /** comment box */
104 CommentBox *commentBox; 104 CommentBox *commentBox;
105}; 105};
106 106
107#endif 107#endif
diff --git a/pwmanager/pwmanager/pwmviewstyle_1.cpp b/pwmanager/pwmanager/pwmviewstyle_1.cpp
index e335a3f..83eed97 100644
--- a/pwmanager/pwmanager/pwmviewstyle_1.cpp
+++ b/pwmanager/pwmanager/pwmviewstyle_1.cpp
@@ -1,192 +1,198 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 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 "pwmviewstyle_1.h" 20#include "pwmviewstyle_1.h"
21#include "pwmview.h" 21#include "pwmview.h"
22#include "listviewpwm.h" 22#include "listviewpwm.h"
23#include "commentbox.h" 23#include "commentbox.h"
24 24
25#include <klocale.h> 25#include <klocale.h>
26#include "pwmprefs.h" 26#include "pwmprefs.h"
27 27
28#ifndef DESKTOP_VERSION 28#ifndef DESKTOP_VERSION
29#include <qpe/qpeapplication.h> 29#include <qpe/qpeapplication.h>
30#else 30#else
31#include <qapplication.h> 31#include <qapplication.h>
32#include <QDesktopWidget>
33//Added by qt3to4:
34#include <QLabel>
35#include <Q3ValueList>
36#include <Q3Frame>
37#include <Q3PopupMenu>
32#endif 38#endif
33 #define INITIAL_CATEGORIES_WIDTH100 39 #define INITIAL_CATEGORIES_WIDTH100
34 40
35PwMViewStyle_1::PwMViewStyle_1(PwMView *view) 41PwMViewStyle_1::PwMViewStyle_1(PwMView *view)
36 : QObject() 42 : QObject()
37{ 43{
38#ifndef PWM_EMBEDDED 44#ifndef PWM_EMBEDDED
39 splitter = new QSplitter(view); 45 splitter = new QSplitter(view);
40#else 46#else
41 if ( QApplication::desktop()->width() > 240 ) { 47 if ( QApplication::desktop()->width() > 240 ) {
42 splitter = new KDGanttMinimizeSplitter( Qt::Horizontal, view); 48 splitter = new KDGanttMinimizeSplitter( Qt::Horizontal, view);
43 splitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Left ); 49 splitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Left );
44 // topLayout = new QHBoxLayout( this ); 50 // topLayout = new QHBoxLayout( this );
45 // mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 51 // mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
46 // mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 52 // mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
47 } else { 53 } else {
48 splitter = new KDGanttMinimizeSplitter( Qt::Vertical, view); 54 splitter = new KDGanttMinimizeSplitter( Qt::Vertical, view);
49 splitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 55 splitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
50 // topLayout = new QHBoxLayout( this ); 56 // topLayout = new QHBoxLayout( this );
51 // mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 57 // mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
52 // mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 58 // mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
53 } 59 }
54 //US topLayout->addWidget(mMiniSplitter ); 60 //US topLayout->addWidget(mMiniSplitter );
55#endif 61#endif
56 62
57 vbox1 = new QVBox(splitter); 63 vbox1 = new Q3VBox(splitter);
58 categoriesTitle = new QLabel(vbox1); 64 categoriesTitle = new QLabel(vbox1);
59 categoriesList = new QListBox(vbox1); 65 categoriesList = new Q3ListBox(vbox1);
60#ifndef PWM_EMBEDDED 66#ifndef PWM_EMBEDDED
61 splitter2 = new QSplitter(splitter); 67 splitter2 = new QSplitter(splitter);
62 splitter2->setOrientation(Qt::Vertical); 68 splitter2->setOrientation(Qt::Vertical);
63#else 69#else
64 splitter2 = new KDGanttMinimizeSplitter( Qt::Vertical, splitter); 70 splitter2 = new KDGanttMinimizeSplitter( Qt::Vertical, splitter);
65 splitter2->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 71 splitter2->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
66 72
67 //US topLayout->addWidget(mMiniSplitter ); 73 //US topLayout->addWidget(mMiniSplitter );
68#endif 74#endif
69 lv = new ListViewPwM(splitter2); 75 lv = new ListViewPwM(splitter2);
70 commentBox = new CommentBox(splitter2); 76 commentBox = new CommentBox(splitter2);
71 // set sizes and styles 77 // set sizes and styles
72 //UScommentBox->resize(commentBox->size().width(), 60); 78 //UScommentBox->resize(commentBox->size().width(), 60);
73 QValueList<int> sizes; 79 Q3ValueList<int> sizes;
74#ifndef PWM_EMBEDDED 80#ifndef PWM_EMBEDDED
75 sizes.push_back(INITIAL_CATEGORIES_WIDTH); 81 sizes.push_back(INITIAL_CATEGORIES_WIDTH);
76 sizes.push_back(view->height() - INITIAL_CATEGORIES_WIDTH); 82 sizes.push_back(view->height() - INITIAL_CATEGORIES_WIDTH);
77#else 83#else
78 sizes.append(INITIAL_CATEGORIES_WIDTH); 84 sizes.append(INITIAL_CATEGORIES_WIDTH);
79 sizes.append(view->height() - INITIAL_CATEGORIES_WIDTH); 85 sizes.append(view->height() - INITIAL_CATEGORIES_WIDTH);
80#endif 86#endif
81 //USsplitter->setSizes(sizes); 87 //USsplitter->setSizes(sizes);
82 categoriesTitle->setAlignment(Qt::AlignHCenter); 88 categoriesTitle->setAlignment(Qt::AlignHCenter);
83#ifndef PWM_EMBEDDED 89#ifndef PWM_EMBEDDED
84 categoriesTitle->setFrameShape(QFrame::MenuBarPanel); 90 categoriesTitle->setFrameShape(Q3Frame::MenuBarPanel);
85#else 91#else
86 //categoriesTitle->setFrameShape(QFrame::StyledPanel); 92 //categoriesTitle->setFrameShape(QFrame::StyledPanel);
87#endif 93#endif
88 categoriesTitle->setText(i18n("Category:")); 94 categoriesTitle->setText(i18n("Category:"));
89 catCtxMenu = new QPopupMenu(view); 95 catCtxMenu = new Q3PopupMenu(view);
90 catCtxMenu->insertItem(i18n("&Rename"), 96 catCtxMenu->insertItem(i18n("&Rename"),
91 view, SLOT(renCatButton_slot())); 97 view, SLOT(renCatButton_slot()));
92 catCtxMenu->insertItem(i18n("&Delete"), 98 catCtxMenu->insertItem(i18n("&Delete"),
93 view, SLOT(delCatButton_slot())); 99 view, SLOT(delCatButton_slot()));
94 100
95#ifndef DESKTOP_VERSION 101#ifndef DESKTOP_VERSION
96 QPEApplication::setStylusOperation( categoriesList->viewport(), QPEApplication::RightOnHold ); 102 QPEApplication::setStylusOperation( categoriesList->viewport(), QPEApplication::RightOnHold );
97#endif 103#endif
98 104
99 // connections 105 // connections
100 connect(categoriesList, SIGNAL(highlighted(int)), 106 connect(categoriesList, SIGNAL(highlighted(int)),
101 view, SLOT(shiftToView())); 107 view, SLOT(shiftToView()));
102 connect(categoriesList, 108 connect(categoriesList,
103 SIGNAL(rightButtonClicked(QListBoxItem *, const QPoint &)), 109 SIGNAL(rightButtonClicked(Q3ListBoxItem *, const QPoint &)),
104 this, 110 this,
105 SLOT(catRightClick(QListBoxItem *, const QPoint &))); 111 SLOT(catRightClick(Q3ListBoxItem *, const QPoint &)));
106 112
107 connect(lv, SIGNAL(toggleOverview()), 113 connect(lv, SIGNAL(toggleOverview()),
108 this, SLOT(toggleSplitter())); 114 this, SLOT(toggleSplitter()));
109} 115}
110 116
111PwMViewStyle_1::~PwMViewStyle_1() 117PwMViewStyle_1::~PwMViewStyle_1()
112{ 118{
113 delete catCtxMenu; 119 delete catCtxMenu;
114 delete splitter; 120 delete splitter;
115} 121}
116void PwMViewStyle_1::toggleSplitter() 122void PwMViewStyle_1::toggleSplitter()
117{ 123{
118 QValueList<int> si = splitter2->sizes(); 124 Q3ValueList<int> si = splitter2->sizes();
119 splitter2->toggle(); 125 splitter2->toggle();
120 QValueList<int> si2 = splitter2->sizes(); 126 Q3ValueList<int> si2 = splitter2->sizes();
121 //qDebug("PwMViewStyle_1::toggleSplitter() %d %d %d %d", si[0],si[1],si2[0],si2[1] ); 127 //qDebug("PwMViewStyle_1::toggleSplitter() %d %d %d %d", si[0],si[1],si2[0],si2[1] );
122 if ( si[0] == si2[0] && si[1] == si2[1] && si2[1] == 1 ) { 128 if ( si[0] == si2[0] && si[1] == si2[1] && si2[1] == 1 ) {
123 int diff = si[0]/2; 129 int diff = si[0]/2;
124 if ( diff > 200 ) 130 if ( diff > 200 )
125 diff = 200; 131 diff = 200;
126 si[0] -= diff; 132 si[0] -= diff;
127 si[1] += diff; 133 si[1] += diff;
128 splitter2->toggle(); 134 splitter2->toggle();
129 splitter2->setSizes( si ); 135 splitter2->setSizes( si );
130 } 136 }
131} 137}
132 138
133void PwMViewStyle_1::catRightClick(QListBoxItem *item, const QPoint &point) 139void PwMViewStyle_1::catRightClick(Q3ListBoxItem *item, const QPoint &point)
134{ 140{
135 if (!item) 141 if (!item)
136 return; 142 return;
137 catCtxMenu->move(point); 143 catCtxMenu->move(point);
138 catCtxMenu->show(); 144 catCtxMenu->show();
139} 145}
140 146
141void PwMViewStyle_1::delCategory(const QString &cat) 147void PwMViewStyle_1::delCategory(const QString &cat)
142{ 148{
143 PWM_ASSERT(categoriesList); 149 PWM_ASSERT(categoriesList);
144 int i, count = categoriesList->count(); 150 int i, count = categoriesList->count();
145 for (i = 0; i < count; ++i) { 151 for (i = 0; i < count; ++i) {
146 if (categoriesList->text(i) == cat) { 152 if (categoriesList->text(i) == cat) {
147 categoriesList->removeItem(i); 153 categoriesList->removeItem(i);
148 return; 154 return;
149 } 155 }
150 } 156 }
151 BUG(); 157 BUG();
152} 158}
153 159
154void PwMViewStyle_1::selectCategory(const QString &cat) 160void PwMViewStyle_1::selectCategory(const QString &cat)
155{ 161{
156 PWM_ASSERT(categoriesList); 162 PWM_ASSERT(categoriesList);
157 int i, count = categoriesList->count(); 163 int i, count = categoriesList->count();
158 for (i = 0; i < count; ++i) { 164 for (i = 0; i < count; ++i) {
159 if (categoriesList->text(i) == cat) { 165 if (categoriesList->text(i) == cat) {
160 categoriesList->setCurrentItem(i); 166 categoriesList->setCurrentItem(i);
161 return; 167 return;
162 } 168 }
163 } 169 }
164 // fall back to 0 170 // fall back to 0
165 categoriesList->setCurrentItem(0); 171 categoriesList->setCurrentItem(0);
166} 172}
167 173
168//US ENH: I need a place to load the view dependend settings. Eg. splittersize 174//US ENH: I need a place to load the view dependend settings. Eg. splittersize
169void PwMViewStyle_1::restoreSettings(PWMPrefs* prefs) 175void PwMViewStyle_1::restoreSettings(PWMPrefs* prefs)
170{ 176{
171 //load and store the size of the listviewcolumns 177 //load and store the size of the listviewcolumns
172 lv->restoreLayout(prefs->getConfig(), "listview"); 178 lv->restoreLayout(prefs->getConfig(), "listview");
173 splitter->setSizes( prefs->mCategorySplitter ); 179 splitter->setSizes( prefs->mCategorySplitter );
174 splitter2->setSizes( prefs->mCommentSplitter ); 180 splitter2->setSizes( prefs->mCommentSplitter );
175 commentBox->setFont( prefs->mViewFont ); 181 commentBox->setFont( prefs->mViewFont );
176 182
177} 183}
178 184
179//US ENH: I need a place to load the view dependend settings. Eg. splittersize 185//US ENH: I need a place to load the view dependend settings. Eg. splittersize
180void PwMViewStyle_1::saveSettings(PWMPrefs* prefs) 186void PwMViewStyle_1::saveSettings(PWMPrefs* prefs)
181{ 187{
182 //store the size of the listviewcolumns 188 //store the size of the listviewcolumns
183 lv->saveLayout(prefs->getConfig(), "listview"); 189 lv->saveLayout(prefs->getConfig(), "listview");
184 prefs->mCategorySplitter = splitter->sizes(); 190 prefs->mCategorySplitter = splitter->sizes();
185 prefs->mCommentSplitter = splitter2->sizes(); 191 prefs->mCommentSplitter = splitter2->sizes();
186 192
187} 193}
188 194
189 195
190#ifndef PWM_EMBEDDED 196#ifndef PWM_EMBEDDED_
191#include "pwmviewstyle_1.moc" 197#include "moc_pwmviewstyle_1.cpp"
192#endif 198#endif
diff --git a/pwmanager/pwmanager/pwmviewstyle_1.h b/pwmanager/pwmanager/pwmviewstyle_1.h
index 4f7a256..66cba03 100644
--- a/pwmanager/pwmanager/pwmviewstyle_1.h
+++ b/pwmanager/pwmanager/pwmviewstyle_1.h
@@ -1,114 +1,114 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 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 PWMVIEWSTYLE_1_H 20#ifndef PWMVIEWSTYLE_1_H
21#define PWMVIEWSTYLE_1_H 21#define PWMVIEWSTYLE_1_H
22 22
23#include <qvbox.h> 23#include <q3vbox.h>
24 24
25#ifndef PWM_EMBEDDED 25#ifndef PWM_EMBEDDED
26#include <qtextedit.h> 26#include <q3textedit.h>
27#include <qsplitter.h> 27#include <qsplitter.h>
28#else 28#else
29#include <qmultilineedit.h> 29#include <q3multilineedit.h>
30#include <KDGanttMinimizeSplitter.h> 30#include <KDGanttMinimizeSplitter.h>
31#endif 31#endif
32 32
33#include <qlabel.h> 33#include <qlabel.h>
34#include <qlistbox.h> 34#include <q3listbox.h>
35#include <qpopupmenu.h> 35#include <q3popupmenu.h>
36 36
37class PwMView; 37class PwMView;
38class ListViewPwM; 38class ListViewPwM;
39class CommentBox; 39class CommentBox;
40class PWMPrefs; 40class PWMPrefs;
41 41
42class PwMViewStyle_1 : public QObject 42class PwMViewStyle_1 : public QObject
43{ 43{
44 Q_OBJECT 44 Q_OBJECT
45public: 45public:
46 PwMViewStyle_1(PwMView *view); 46 PwMViewStyle_1(PwMView *view);
47 ~PwMViewStyle_1(); 47 ~PwMViewStyle_1();
48 48
49 ListViewPwM * getLv() 49 ListViewPwM * getLv()
50 { return lv; } 50 { return lv; }
51 CommentBox * getCommentBox() 51 CommentBox * getCommentBox()
52 { return commentBox; } 52 { return commentBox; }
53 53
54 /** returns the currently selected category */ 54 /** returns the currently selected category */
55 QString getCurrentCategory() 55 QString getCurrentCategory()
56 { return categoriesList->currentText(); } 56 { return categoriesList->currentText(); }
57 /** add Category to the view */ 57 /** add Category to the view */
58 void addCategory(const QString &cat) 58 void addCategory(const QString &cat)
59 { categoriesList->insertItem(cat); } 59 { categoriesList->insertItem(cat); }
60 /** delete Category from view */ 60 /** delete Category from view */
61 void delCategory(const QString &cat); 61 void delCategory(const QString &cat);
62 /** delete all categories from view */ 62 /** delete all categories from view */
63 void delAllCategories() 63 void delAllCategories()
64 { categoriesList->clear(); } 64 { categoriesList->clear(); }
65 /** select the specified category */ 65 /** select the specified category */
66 void selectCategory(const QString &cat); 66 void selectCategory(const QString &cat);
67 /** returns the number of categories in this view. 67 /** returns the number of categories in this view.
68 * This value dosn't say anything about the number of 68 * This value dosn't say anything about the number of
69 * categories in the document. 69 * categories in the document.
70 */ 70 */
71 int numCategories() 71 int numCategories()
72 { return categoriesList->count(); } 72 { return categoriesList->count(); }
73 /** resize the view */ 73 /** resize the view */
74 void resize(const QSize &size) 74 void resize(const QSize &size)
75 { splitter->resize(size); } 75 { splitter->resize(size); }
76 76
77 //US ENH: I need a place to load the view dependend settings. Eg. splittersize 77 //US ENH: I need a place to load the view dependend settings. Eg. splittersize
78 void restoreSettings(PWMPrefs* prefs); 78 void restoreSettings(PWMPrefs* prefs);
79 void saveSettings(PWMPrefs* prefs); 79 void saveSettings(PWMPrefs* prefs);
80 80
81public slots: 81public slots:
82 void toggleSplitter(); 82 void toggleSplitter();
83protected slots: 83protected slots:
84 /** user clicked right button in category list */ 84 /** user clicked right button in category list */
85 void catRightClick(QListBoxItem *item, const QPoint &point); 85 void catRightClick(Q3ListBoxItem *item, const QPoint &point);
86 86
87protected: 87protected:
88 /** main list view */ 88 /** main list view */
89 ListViewPwM *lv; 89 ListViewPwM *lv;
90#ifndef PWM_EMBEDDED 90#ifndef PWM_EMBEDDED
91 /** main splitter widget */ 91 /** main splitter widget */
92 QSplitter *splitter; 92 QSplitter *splitter;
93 /** commentTextEdit splitter */ 93 /** commentTextEdit splitter */
94 QSplitter *splitter2; 94 QSplitter *splitter2;
95#else 95#else
96 /** main splitter widget */ 96 /** main splitter widget */
97 KDGanttMinimizeSplitter *splitter; 97 KDGanttMinimizeSplitter *splitter;
98 /** commentTextEdit splitter */ 98 /** commentTextEdit splitter */
99 KDGanttMinimizeSplitter *splitter2; 99 KDGanttMinimizeSplitter *splitter2;
100#endif 100#endif
101 101
102 /** categories list-box */ 102 /** categories list-box */
103 QListBox *categoriesList; 103 Q3ListBox *categoriesList;
104 /** title string for the categories combo or list box */ 104 /** title string for the categories combo or list box */
105 QLabel *categoriesTitle; 105 QLabel *categoriesTitle;
106 /** hbox1 for widget style */ 106 /** hbox1 for widget style */
107 QVBox *vbox1; 107 Q3VBox *vbox1;
108 /** text-edit to display the comment */ 108 /** text-edit to display the comment */
109 CommentBox *commentBox; 109 CommentBox *commentBox;
110 /** category list context menu */ 110 /** category list context menu */
111 QPopupMenu *catCtxMenu; 111 Q3PopupMenu *catCtxMenu;
112}; 112};
113 113
114#endif 114#endif
diff --git a/pwmanager/pwmanager/randomizer.cpp b/pwmanager/pwmanager/randomizer.cpp
index da4df78..24f9926 100644
--- a/pwmanager/pwmanager/randomizer.cpp
+++ b/pwmanager/pwmanager/randomizer.cpp
@@ -1,225 +1,225 @@
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.1 of pwmanager 14 * This file is originaly based on version 1.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 "randomizer.h" 20#include "randomizer.h"
21#include "pwmexception.h" 21#include "pwmexception.h"
22 22
23#include <qfile.h> 23#include <qfile.h>
24 24
25#include <kapplication.h> 25#include <kapplication.h>
26 26
27#include <stdlib.h> 27#include <stdlib.h>
28#include <time.h> 28#include <time.h>
29 29
30 30
31#ifdef PWM_EMBEDDED 31#ifdef PWM_EMBEDDED
32 32
33#ifndef Q_LONG 33#ifndef Q_LONG
34#define Q_LONG long 34#define Q_LONG long
35#endif 35#endif
36 36
37#endif //PWM_EMBEDDED 37#endif //PWM_EMBEDDED
38#ifdef _WIN32_ 38#ifdef _WIN32_
39int rand_r( uint * seed ) { 39int rand_r( uint * seed ) {
40 srand(*seed); 40 srand(*seed);
41 return rand(); 41 return rand();
42} 42}
43#endif 43#endif
44Randomizer * Randomizer::rndObj (0); 44Randomizer * Randomizer::rndObj (0);
45 45
46Randomizer::Randomizer() 46Randomizer::Randomizer()
47{ 47{
48 rndDev = new QFile; 48 rndDev = new QFile;
49 seed = time(0); 49 seed = time(0);
50 50
51#if 1 // set to 0 to test rand_r() fallback 51#if 1 // set to 0 to test rand_r() fallback
52 52
53 // probe for /dev/urandom 53 // probe for /dev/urandom
54 rndDev->setName("/dev/urandom"); 54 rndDev->setName("/dev/urandom");
55 if (rndDev->exists() && 55 if (rndDev->exists() &&
56 rndDev->open(IO_ReadOnly)) { 56 rndDev->open(QIODevice::ReadOnly)) {
57 printDebug("Randomizer: using /dev/urandom"); 57 printDebug("Randomizer: using /dev/urandom");
58 return; 58 return;
59 } 59 }
60 60
61 // probe for /dev/random 61 // probe for /dev/random
62 rndDev->setName("/dev/random"); 62 rndDev->setName("/dev/random");
63 if (rndDev->exists() && 63 if (rndDev->exists() &&
64 rndDev->open(IO_ReadOnly)) { 64 rndDev->open(QIODevice::ReadOnly)) {
65 printDebug("Randomizer: using /dev/random"); 65 printDebug("Randomizer: using /dev/random");
66 return; 66 return;
67 } 67 }
68 68
69 // probe for EGD 69 // probe for EGD
70 char *fn = getenv("RANDFILE"); 70 char *fn = getenv("RANDFILE");
71 if (fn) { 71 if (fn) {
72 rndDev->setName(fn); 72 rndDev->setName(fn);
73 if (rndDev->exists() && 73 if (rndDev->exists() &&
74 rndDev->open(IO_ReadOnly)) { 74 rndDev->open(QIODevice::ReadOnly)) {
75 printDebug(string("Randomizer: using $RANDFILE \"") 75 printDebug(string("Randomizer: using $RANDFILE \"")
76 + fn 76 + fn
77 + "\" (aka EGD)"); 77 + "\" (aka EGD)");
78 return; 78 return;
79 } 79 }
80 } 80 }
81#endif 81#endif
82 82
83 /* no secure randomizer found. 83 /* no secure randomizer found.
84 * Fall back to stdlib randomizer. 84 * Fall back to stdlib randomizer.
85 */ 85 */
86 delete_and_null(rndDev); 86 delete_and_null(rndDev);
87 printWarn("neither /dev/*random nor EGD found! " 87 printWarn("neither /dev/*random nor EGD found! "
88 "Falling back to insecure rand_r()!"); 88 "Falling back to insecure rand_r()!");
89} 89}
90 90
91Randomizer::~Randomizer() 91Randomizer::~Randomizer()
92{ 92{
93#ifndef PWM_EMBEDDED 93#ifndef PWM_EMBEDDED
94 while (mutex.locked()) { 94 while (mutex.locked()) {
95 /* wait for the mutex to unlock. 95 /* wait for the mutex to unlock.
96 * Don't block the GUI here, so processEvents() 96 * Don't block the GUI here, so processEvents()
97 */ 97 */
98 kapp->processEvents(); 98 kapp->processEvents();
99 } 99 }
100#endif 100#endif
101 if (rndDev) { 101 if (rndDev) {
102 rndDev->close(); 102 rndDev->close();
103 delete rndDev; 103 delete rndDev;
104 } 104 }
105} 105}
106 106
107char Randomizer::genRndChar() 107char Randomizer::genRndChar()
108{ 108{
109 char ret; 109 char ret;
110#ifndef PWM_EMBEDDED 110#ifndef PWM_EMBEDDED
111 mutex.lock(); 111 mutex.lock();
112#endif 112#endif
113 if (rndDev) { 113 if (rndDev) {
114 /* we have a file which provides random data. 114 /* we have a file which provides random data.
115 * Simply read it. 115 * Simply read it.
116 */ 116 */
117 ret = rndDev->getch(); 117 ret = rndDev->getch();
118 } else { 118 } else {
119 /* fall back to rand_r() */ 119 /* fall back to rand_r() */
120 ret = rand_r(&seed) % 0xFF; 120 ret = rand_r(&seed) % 0xFF;
121 } 121 }
122#ifndef PWM_EMBEDDED 122#ifndef PWM_EMBEDDED
123 mutex->unlock(); 123 mutex->unlock();
124#endif 124#endif
125 return ret; 125 return ret;
126} 126}
127 127
128int Randomizer::genRndInt() 128int Randomizer::genRndInt()
129{ 129{
130 int ret; 130 int ret;
131#ifndef PWM_EMBEDDED 131#ifndef PWM_EMBEDDED
132 mutex->lock(); 132 mutex->lock();
133#endif 133#endif
134 if (rndDev) { 134 if (rndDev) {
135 if (sizeof(int) == 4) { 135 if (sizeof(int) == 4) {
136 (reinterpret_cast<char *>(&ret))[0] = rndDev->getch(); 136 (reinterpret_cast<char *>(&ret))[0] = rndDev->getch();
137 (reinterpret_cast<char *>(&ret))[1] = rndDev->getch(); 137 (reinterpret_cast<char *>(&ret))[1] = rndDev->getch();
138 (reinterpret_cast<char *>(&ret))[2] = rndDev->getch(); 138 (reinterpret_cast<char *>(&ret))[2] = rndDev->getch();
139 (reinterpret_cast<char *>(&ret))[3] = rndDev->getch(); 139 (reinterpret_cast<char *>(&ret))[3] = rndDev->getch();
140 } else if (sizeof(int) == 8) { 140 } else if (sizeof(int) == 8) {
141 (reinterpret_cast<char *>(&ret))[0] = rndDev->getch(); 141 (reinterpret_cast<char *>(&ret))[0] = rndDev->getch();
142 (reinterpret_cast<char *>(&ret))[1] = rndDev->getch(); 142 (reinterpret_cast<char *>(&ret))[1] = rndDev->getch();
143 (reinterpret_cast<char *>(&ret))[2] = rndDev->getch(); 143 (reinterpret_cast<char *>(&ret))[2] = rndDev->getch();
144 (reinterpret_cast<char *>(&ret))[3] = rndDev->getch(); 144 (reinterpret_cast<char *>(&ret))[3] = rndDev->getch();
145 (reinterpret_cast<char *>(&ret))[4] = rndDev->getch(); 145 (reinterpret_cast<char *>(&ret))[4] = rndDev->getch();
146 (reinterpret_cast<char *>(&ret))[5] = rndDev->getch(); 146 (reinterpret_cast<char *>(&ret))[5] = rndDev->getch();
147 (reinterpret_cast<char *>(&ret))[6] = rndDev->getch(); 147 (reinterpret_cast<char *>(&ret))[6] = rndDev->getch();
148 (reinterpret_cast<char *>(&ret))[7] = rndDev->getch(); 148 (reinterpret_cast<char *>(&ret))[7] = rndDev->getch();
149 } else { 149 } else {
150 printWarn(string(__FILE__) + ":" + tostr(__LINE__) 150 printWarn(string(__FILE__) + ":" + tostr(__LINE__)
151 + ": sizeof(int) != 4 && sizeof(int) != 8"); 151 + ": sizeof(int) != 4 && sizeof(int) != 8");
152 ret = rand_r(&seed); 152 ret = rand_r(&seed);
153 } 153 }
154 } else { 154 } else {
155 ret = rand_r(&seed); 155 ret = rand_r(&seed);
156 } 156 }
157#ifndef PWM_EMBEDDED 157#ifndef PWM_EMBEDDED
158 mutex->unlock(); 158 mutex->unlock();
159#endif 159#endif
160 return ret; 160 return ret;
161} 161}
162 162
163unsigned int Randomizer::genRndUInt() 163unsigned int Randomizer::genRndUInt()
164{ 164{
165 unsigned int ret; 165 unsigned int ret;
166#ifndef PWM_EMBEDDED 166#ifndef PWM_EMBEDDED
167 mutex->lock(); 167 mutex->lock();
168#endif 168#endif
169 if (rndDev) { 169 if (rndDev) {
170 if (sizeof(unsigned int) == 4) { 170 if (sizeof(unsigned int) == 4) {
171 (reinterpret_cast<char *>(&ret))[0] = rndDev->getch(); 171 (reinterpret_cast<char *>(&ret))[0] = rndDev->getch();
172 (reinterpret_cast<char *>(&ret))[1] = rndDev->getch(); 172 (reinterpret_cast<char *>(&ret))[1] = rndDev->getch();
173 (reinterpret_cast<char *>(&ret))[2] = rndDev->getch(); 173 (reinterpret_cast<char *>(&ret))[2] = rndDev->getch();
174 (reinterpret_cast<char *>(&ret))[3] = rndDev->getch(); 174 (reinterpret_cast<char *>(&ret))[3] = rndDev->getch();
175 } else if (sizeof(unsigned int) == 8) { 175 } else if (sizeof(unsigned int) == 8) {
176 (reinterpret_cast<char *>(&ret))[0] = rndDev->getch(); 176 (reinterpret_cast<char *>(&ret))[0] = rndDev->getch();
177 (reinterpret_cast<char *>(&ret))[1] = rndDev->getch(); 177 (reinterpret_cast<char *>(&ret))[1] = rndDev->getch();
178 (reinterpret_cast<char *>(&ret))[2] = rndDev->getch(); 178 (reinterpret_cast<char *>(&ret))[2] = rndDev->getch();
179 (reinterpret_cast<char *>(&ret))[3] = rndDev->getch(); 179 (reinterpret_cast<char *>(&ret))[3] = rndDev->getch();
180 (reinterpret_cast<char *>(&ret))[4] = rndDev->getch(); 180 (reinterpret_cast<char *>(&ret))[4] = rndDev->getch();
181 (reinterpret_cast<char *>(&ret))[5] = rndDev->getch(); 181 (reinterpret_cast<char *>(&ret))[5] = rndDev->getch();
182 (reinterpret_cast<char *>(&ret))[6] = rndDev->getch(); 182 (reinterpret_cast<char *>(&ret))[6] = rndDev->getch();
183 (reinterpret_cast<char *>(&ret))[7] = rndDev->getch(); 183 (reinterpret_cast<char *>(&ret))[7] = rndDev->getch();
184 } else { 184 } else {
185 printWarn(string(__FILE__) + ":" + tostr(__LINE__) 185 printWarn(string(__FILE__) + ":" + tostr(__LINE__)
186 + ": sizeof(unsigned int) != 4 && sizeof(unsigned int) != 8"); 186 + ": sizeof(unsigned int) != 4 && sizeof(unsigned int) != 8");
187 ret = rand_r(&seed); 187 ret = rand_r(&seed);
188 } 188 }
189 } else { 189 } else {
190 ret = rand_r(&seed); 190 ret = rand_r(&seed);
191 } 191 }
192#ifndef PWM_EMBEDDED 192#ifndef PWM_EMBEDDED
193 mutex->unlock(); 193 mutex->unlock();
194#endif 194#endif
195 return ret; 195 return ret;
196} 196}
197 197
198void Randomizer::genRndBuf(unsigned char *buf, size_t len) 198void Randomizer::genRndBuf(unsigned char *buf, size_t len)
199{ 199{
200#ifndef PWM_EMBEDDED 200#ifndef PWM_EMBEDDED
201 mutex->lock(); 201 mutex->lock();
202#endif 202#endif
203 if (rndDev) { 203 if (rndDev) {
204 Q_LONG n; 204 Q_LONG n;
205 n = rndDev->readBlock(reinterpret_cast<char *>(buf), len); 205 n = rndDev->readBlock(reinterpret_cast<char *>(buf), len);
206 WARN_ON(n != static_cast<Q_LONG>(len)); 206 WARN_ON(n != static_cast<Q_LONG>(len));
207 } else { 207 } else {
208 size_t i; 208 size_t i;
209 for (i = 0; i < len; ++i) 209 for (i = 0; i < len; ++i)
210 buf[i] = rand_r(&seed) % 0xFF; 210 buf[i] = rand_r(&seed) % 0xFF;
211 } 211 }
212#ifndef PWM_EMBEDDED 212#ifndef PWM_EMBEDDED
213 mutex->unlock(); 213 mutex->unlock();
214#endif 214#endif
215} 215}
216 216
217string Randomizer::genRndBuf(size_t len) 217string Randomizer::genRndBuf(size_t len)
218{ 218{
219 string ret; 219 string ret;
220 unsigned char *buf; 220 unsigned char *buf;
221 buf = new unsigned char[len]; 221 buf = new unsigned char[len];
222 genRndBuf(buf, len); 222 genRndBuf(buf, len);
223 ret.assign(reinterpret_cast<const char *>(buf), len); 223 ret.assign(reinterpret_cast<const char *>(buf), len);
224 return ret; 224 return ret;
225} 225}
diff --git a/pwmanager/pwmanager/rencatwnd.cpp b/pwmanager/pwmanager/rencatwnd.cpp
index 3c4de27..3ca758c 100644
--- a/pwmanager/pwmanager/rencatwnd.cpp
+++ b/pwmanager/pwmanager/rencatwnd.cpp
@@ -1,70 +1,73 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2003 by Michael Buesch * 3 * copyright (C) 2003 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 "rencatwnd.h" 20#include "rencatwnd.h"
21 21
22#include <klocale.h> 22#include <klocale.h>
23//Added by qt3to4:
24#include <QResizeEvent>
25#include <QLabel>
23 26
24 27
25RenCatWnd::RenCatWnd(QWidget *parent, 28RenCatWnd::RenCatWnd(QWidget *parent,
26 const char *name, bool modal, WFlags f) 29 const char *name, bool modal, Qt::WFlags f)
27 : QDialog(parent, name, true, f) 30 : QDialog(parent, name, true, f)
28{ 31{
29 vbox1 = new QVBox(this); 32 vbox1 = new Q3VBox(this);
30 label = new QLabel(vbox1); 33 label = new QLabel(vbox1);
31 newName = new QLineEdit(vbox1); 34 newName = new QLineEdit(vbox1);
32 hbox1 = new QHBox(vbox1); 35 hbox1 = new Q3HBox(vbox1);
33 okButton = new QPushButton(i18n("&Ok"), hbox1); 36 okButton = new QPushButton(i18n("&Ok"), hbox1);
34 cancelButton = new QPushButton(i18n("&Cancel"), hbox1); 37 cancelButton = new QPushButton(i18n("&Cancel"), hbox1);
35 38
36 vbox1->setSpacing(10); 39 vbox1->setSpacing(10);
37 vbox1->setMargin(10); 40 vbox1->setMargin(10);
38 hbox1->setSpacing(10); 41 hbox1->setSpacing(10);
39 42
40 resize(220, 100); 43 resize(220, 100);
41 44
42 setCaption(i18n("Rename category")); 45 setCaption(i18n("Rename category"));
43 label->setText(i18n("New category name:")); 46 label->setText(i18n("New category name:"));
44 47
45 connect(okButton, SIGNAL(clicked()), this, SLOT(okButton_slot())); 48 connect(okButton, SIGNAL(clicked()), this, SLOT(okButton_slot()));
46 connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancelButton_slot())); 49 connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancelButton_slot()));
47} 50}
48 51
49RenCatWnd::~RenCatWnd() 52RenCatWnd::~RenCatWnd()
50{ 53{
51} 54}
52 55
53void RenCatWnd::resizeEvent(QResizeEvent *) 56void RenCatWnd::resizeEvent(QResizeEvent *)
54{ 57{
55 vbox1->resize(size()); 58 vbox1->resize(size());
56} 59}
57 60
58void RenCatWnd::okButton_slot() 61void RenCatWnd::okButton_slot()
59{ 62{
60 done(1); 63 done(1);
61} 64}
62 65
63void RenCatWnd::cancelButton_slot() 66void RenCatWnd::cancelButton_slot()
64{ 67{
65 done(2); 68 done(2);
66} 69}
67 70
68#ifndef PWM_EMBEDDED 71#ifndef PWM_EMBEDDED_
69#include "rencatwnd.moc" 72#include "moc_rencatwnd.cpp"
70#endif 73#endif
diff --git a/pwmanager/pwmanager/rencatwnd.h b/pwmanager/pwmanager/rencatwnd.h
index 37b6725..1773136 100644
--- a/pwmanager/pwmanager/rencatwnd.h
+++ b/pwmanager/pwmanager/rencatwnd.h
@@ -1,60 +1,62 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2003 by Michael Buesch * 3 * copyright (C) 2003 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 RENCATWND_H 20#ifndef RENCATWND_H
21#define RENCATWND_H 21#define RENCATWND_H
22 22
23#include <qvbox.h> 23#include <q3vbox.h>
24#include <qhbox.h> 24#include <q3hbox.h>
25#include <qdialog.h> 25#include <qdialog.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qlineedit.h> 27#include <qlineedit.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qevent.h> 29#include <qevent.h>
30//Added by qt3to4:
31#include <QResizeEvent>
30 32
31 33
32/** rename category window */ 34/** rename category window */
33class RenCatWnd : public QDialog 35class RenCatWnd : public QDialog
34{ 36{
35 Q_OBJECT 37 Q_OBJECT
36public: 38public:
37 RenCatWnd(QWidget *parent = 0, const char *name = 0, 39 RenCatWnd(QWidget *parent = 0, const char *name = 0,
38 bool modal = FALSE, WFlags f = 0); 40 bool modal = FALSE, Qt::WFlags f = 0);
39 ~RenCatWnd(); 41 ~RenCatWnd();
40 42
41 QString getNewName() 43 QString getNewName()
42 { return newName->text(); } 44 { return newName->text(); }
43 45
44protected slots: 46protected slots:
45 void okButton_slot(); 47 void okButton_slot();
46 void cancelButton_slot(); 48 void cancelButton_slot();
47 49
48protected: 50protected:
49 QVBox *vbox1; 51 Q3VBox *vbox1;
50 QHBox *hbox1; 52 Q3HBox *hbox1;
51 QLabel *label; 53 QLabel *label;
52 QLineEdit *newName; 54 QLineEdit *newName;
53 QPushButton *okButton; 55 QPushButton *okButton;
54 QPushButton *cancelButton; 56 QPushButton *cancelButton;
55 57
56protected: 58protected:
57 void resizeEvent(QResizeEvent *); 59 void resizeEvent(QResizeEvent *);
58}; 60};
59 61
60#endif 62#endif
diff --git a/pwmanager/pwmanager/serializer.cpp b/pwmanager/pwmanager/serializer.cpp
index 507fa30..6c6512e 100644
--- a/pwmanager/pwmanager/serializer.cpp
+++ b/pwmanager/pwmanager/serializer.cpp
@@ -1,611 +1,613 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 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/*************************************************************************** 13/***************************************************************************
14 * copyright (C) 2004 by Ulf Schenk 14 * copyright (C) 2004 by Ulf Schenk
15 * This file is originaly based on version 1.1 of pwmanager 15 * This file is originaly based on version 1.1 of pwmanager
16 * and was modified to run on embedded devices that run microkde 16 * and was modified to run on embedded devices that run microkde
17 * 17 *
18 * $Id$ 18 * $Id$
19 **************************************************************************/ 19 **************************************************************************/
20 20
21#include "serializer.h" 21#include "serializer.h"
22#include "pwmexception.h" 22#include "pwmexception.h"
23 23
24#ifdef PWM_EMBEDDED 24#ifdef PWM_EMBEDDED
25#include <kglobal.h> 25#include <kglobal.h>
26#include <klocale.h> 26#include <klocale.h>
27//Added by qt3to4:
28#include <Q3CString>
27#endif 29#endif
28 30
29/* enable/disable serializer debugging (0/1) */ 31/* enable/disable serializer debugging (0/1) */
30 #define SERIALIZER_DEBUG0 32 #define SERIALIZER_DEBUG0
31/* use the old xml tags for writing (0/1) */ 33/* use the old xml tags for writing (0/1) */
32 #define USE_OLD_TAGS 0 34 #define USE_OLD_TAGS 0
33/* write a CDATA section (0/1) */ 35/* write a CDATA section (0/1) */
34 #define WRITE_CDATA_SEC 0 36 #define WRITE_CDATA_SEC 0
35 37
36 38
37 #define META_CREATE_DATE"c" 39 #define META_CREATE_DATE"c"
38 #define META_VALID_DATE "v" 40 #define META_VALID_DATE "v"
39 #define META_EXPIRE_DATE"e" 41 #define META_EXPIRE_DATE"e"
40 #define META_UPDATE_DATE"u" 42 #define META_UPDATE_DATE"u"
41 #define META_UPDATE_INT "i" 43 #define META_UPDATE_INT "i"
42//US ENH : uniqueid and sync information 44//US ENH : uniqueid and sync information
43#define META_UNIQUEID "n" 45#define META_UNIQUEID "n"
44#define SYNC_ROOT "s" 46#define SYNC_ROOT "s"
45#define SYNC_TARGET_PREFIX "t" 47#define SYNC_TARGET_PREFIX "t"
46#define SYNC_TARGET_NAME "n" 48#define SYNC_TARGET_NAME "n"
47 49
48 50
49/* This is compatibility stuff. 51/* This is compatibility stuff.
50 * The names of the entries have changed and here are the 52 * The names of the entries have changed and here are the
51 * new and old ones 53 * new and old ones
52 */ 54 */
53 #define ROOT_MAGIC_OLD "PwM-xml-dat" 55 #define ROOT_MAGIC_OLD "PwM-xml-dat"
54 #define VER_STR_OLD "ver" 56 #define VER_STR_OLD "ver"
55 #define COMPAT_VER_OLD "0x02" 57 #define COMPAT_VER_OLD "0x02"
56 #define CAT_ROOT_OLD "categories" 58 #define CAT_ROOT_OLD "categories"
57 #define CAT_PREFIX_OLD "cat_" 59 #define CAT_PREFIX_OLD "cat_"
58 #define CAT_NAME_OLD "name" 60 #define CAT_NAME_OLD "name"
59//US ENH : optional text for categories 61//US ENH : optional text for categories
60 #define CAT_TEXT_OLD "text" 62 #define CAT_TEXT_OLD "text"
61 63
62 #define ENTRY_PREFIX_OLD"entry_" 64 #define ENTRY_PREFIX_OLD"entry_"
63 #define ENTRY_DESC_OLD "desc" 65 #define ENTRY_DESC_OLD "desc"
64 #define ENTRY_NAME_OLD "name" 66 #define ENTRY_NAME_OLD "name"
65 #define ENTRY_PW_OLD "pw" 67 #define ENTRY_PW_OLD "pw"
66 #define ENTRY_COMMENT_OLD"comment" 68 #define ENTRY_COMMENT_OLD"comment"
67 #define ENTRY_URL_OLD "url" 69 #define ENTRY_URL_OLD "url"
68 #define ENTRY_LAUNCHER_OLD"launcher" 70 #define ENTRY_LAUNCHER_OLD"launcher"
69 #define ENTRY_LVP_OLD "listViewPos" 71 #define ENTRY_LVP_OLD "listViewPos"
70 #define ENTRY_BIN_OLD "b" 72 #define ENTRY_BIN_OLD "b"
71 #define ENTRY_META_OLD "m" 73 #define ENTRY_META_OLD "m"
72 74
73 #define ROOT_MAGIC_NEW "P" 75 #define ROOT_MAGIC_NEW "P"
74 #define VER_STR_NEW "v" 76 #define VER_STR_NEW "v"
75 #define COMPAT_VER_NEW "2" 77 #define COMPAT_VER_NEW "2"
76 #define CAT_ROOT_NEW "c" 78 #define CAT_ROOT_NEW "c"
77 #define CAT_PREFIX_NEW "c" 79 #define CAT_PREFIX_NEW "c"
78 #define CAT_NAME_NEW "n" 80 #define CAT_NAME_NEW "n"
79//US ENH : optional text for categories 81//US ENH : optional text for categories
80 #define CAT_TEXT_NEW "t" 82 #define CAT_TEXT_NEW "t"
81 83
82 #define ENTRY_PREFIX_NEW"e" 84 #define ENTRY_PREFIX_NEW"e"
83 #define ENTRY_DESC_NEW "d" 85 #define ENTRY_DESC_NEW "d"
84 #define ENTRY_NAME_NEW "n" 86 #define ENTRY_NAME_NEW "n"
85 #define ENTRY_PW_NEW "p" 87 #define ENTRY_PW_NEW "p"
86 #define ENTRY_COMMENT_NEW"c" 88 #define ENTRY_COMMENT_NEW"c"
87 #define ENTRY_URL_NEW "u" 89 #define ENTRY_URL_NEW "u"
88 #define ENTRY_LAUNCHER_NEW"l" 90 #define ENTRY_LAUNCHER_NEW"l"
89 #define ENTRY_LVP_NEW "v" 91 #define ENTRY_LVP_NEW "v"
90 #define ENTRY_BIN_NEW ENTRY_BIN_OLD 92 #define ENTRY_BIN_NEW ENTRY_BIN_OLD
91 #define ENTRY_META_NEW ENTRY_META_OLD 93 #define ENTRY_META_NEW ENTRY_META_OLD
92 94
93#if USE_OLD_TAGS != 0 95#if USE_OLD_TAGS != 0
94 # define ROOT_MAGIC_WR ROOT_MAGIC_OLD 96 # define ROOT_MAGIC_WR ROOT_MAGIC_OLD
95 # define VER_STR_WR VER_STR_OLD 97 # define VER_STR_WR VER_STR_OLD
96 # define COMPAT_VER_WR COMPAT_VER_OLD 98 # define COMPAT_VER_WR COMPAT_VER_OLD
97 # define CAT_ROOT_WR CAT_ROOT_OLD 99 # define CAT_ROOT_WR CAT_ROOT_OLD
98 # define CAT_PREFIX_WR CAT_PREFIX_OLD 100 # define CAT_PREFIX_WR CAT_PREFIX_OLD
99 # define CAT_NAME_WR CAT_NAME_OLD 101 # define CAT_NAME_WR CAT_NAME_OLD
100 102
101//US ENH : optional text for categories 103//US ENH : optional text for categories
102 # define CAT_TEXT_WR CAT_TEXT_OLD 104 # define CAT_TEXT_WR CAT_TEXT_OLD
103 105
104 # define ENTRY_PREFIX_WRENTRY_PREFIX_OLD 106 # define ENTRY_PREFIX_WRENTRY_PREFIX_OLD
105 # define ENTRY_DESC_WR ENTRY_DESC_OLD 107 # define ENTRY_DESC_WR ENTRY_DESC_OLD
106 # define ENTRY_NAME_WR ENTRY_NAME_OLD 108 # define ENTRY_NAME_WR ENTRY_NAME_OLD
107 # define ENTRY_PW_WR ENTRY_PW_OLD 109 # define ENTRY_PW_WR ENTRY_PW_OLD
108 # define ENTRY_COMMENT_WRENTRY_COMMENT_OLD 110 # define ENTRY_COMMENT_WRENTRY_COMMENT_OLD
109 # define ENTRY_URL_WR ENTRY_URL_OLD 111 # define ENTRY_URL_WR ENTRY_URL_OLD
110 # define ENTRY_LAUNCHER_WRENTRY_LAUNCHER_OLD 112 # define ENTRY_LAUNCHER_WRENTRY_LAUNCHER_OLD
111 # define ENTRY_LVP_WR ENTRY_LVP_OLD 113 # define ENTRY_LVP_WR ENTRY_LVP_OLD
112 # define ENTRY_BIN_WR ENTRY_BIN_OLD 114 # define ENTRY_BIN_WR ENTRY_BIN_OLD
113 # define ENTRY_META_WR ENTRY_META_OLD 115 # define ENTRY_META_WR ENTRY_META_OLD
114#else 116#else
115 # define ROOT_MAGIC_WR ROOT_MAGIC_NEW 117 # define ROOT_MAGIC_WR ROOT_MAGIC_NEW
116 # define VER_STR_WR VER_STR_NEW 118 # define VER_STR_WR VER_STR_NEW
117 # define COMPAT_VER_WR COMPAT_VER_NEW 119 # define COMPAT_VER_WR COMPAT_VER_NEW
118 # define CAT_ROOT_WR CAT_ROOT_NEW 120 # define CAT_ROOT_WR CAT_ROOT_NEW
119 # define CAT_PREFIX_WR CAT_PREFIX_NEW 121 # define CAT_PREFIX_WR CAT_PREFIX_NEW
120 # define CAT_NAME_WR CAT_NAME_NEW 122 # define CAT_NAME_WR CAT_NAME_NEW
121 123
122//US ENH : optional text for categories 124//US ENH : optional text for categories
123 # define CAT_TEXT_WR CAT_TEXT_NEW 125 # define CAT_TEXT_WR CAT_TEXT_NEW
124 126
125 # define ENTRY_PREFIX_WRENTRY_PREFIX_NEW 127 # define ENTRY_PREFIX_WRENTRY_PREFIX_NEW
126 # define ENTRY_DESC_WR ENTRY_DESC_NEW 128 # define ENTRY_DESC_WR ENTRY_DESC_NEW
127 # define ENTRY_NAME_WR ENTRY_NAME_NEW 129 # define ENTRY_NAME_WR ENTRY_NAME_NEW
128 # define ENTRY_PW_WR ENTRY_PW_NEW 130 # define ENTRY_PW_WR ENTRY_PW_NEW
129 # define ENTRY_COMMENT_WRENTRY_COMMENT_NEW 131 # define ENTRY_COMMENT_WRENTRY_COMMENT_NEW
130 # define ENTRY_URL_WR ENTRY_URL_NEW 132 # define ENTRY_URL_WR ENTRY_URL_NEW
131 # define ENTRY_LAUNCHER_WRENTRY_LAUNCHER_NEW 133 # define ENTRY_LAUNCHER_WRENTRY_LAUNCHER_NEW
132 # define ENTRY_LVP_WR ENTRY_LVP_NEW 134 # define ENTRY_LVP_WR ENTRY_LVP_NEW
133 # define ENTRY_BIN_WR ENTRY_BIN_NEW 135 # define ENTRY_BIN_WR ENTRY_BIN_NEW
134 # define ENTRY_META_WR ENTRY_META_NEW 136 # define ENTRY_META_WR ENTRY_META_NEW
135#endif 137#endif
136 138
137 139
138Serializer::Serializer() 140Serializer::Serializer()
139{ 141{
140 defaultLockStat = true; 142 defaultLockStat = true;
141//US BUG: I needed to specify a document name. Otherwise impl will not be created for serializing 143//US BUG: I needed to specify a document name. Otherwise impl will not be created for serializing
142#ifndef PWM_EMBEDDED 144#ifndef PWM_EMBEDDED
143 domDoc = new QDomDocument; 145 domDoc = new QDomDocument;
144#else 146#else
145 domDoc = new QDomDocument("mydoc"); 147 domDoc = new QDomDocument("mydoc");
146#endif 148#endif
147} 149}
148 150
149Serializer::Serializer(const QCString &buffer) 151Serializer::Serializer(const Q3CString &buffer)
150{ 152{
151 defaultLockStat = true; 153 defaultLockStat = true;
152//US BUG: I needed to specify a document name. Otherwise impl will not be created for serializing 154//US BUG: I needed to specify a document name. Otherwise impl will not be created for serializing
153#ifndef PWM_EMBEDDED 155#ifndef PWM_EMBEDDED
154 domDoc = new QDomDocument; 156 domDoc = new QDomDocument;
155#else 157#else
156 domDoc = new QDomDocument("mydoc"); 158 domDoc = new QDomDocument("mydoc");
157#endif 159#endif
158 160
159 if (!parseXml(buffer)) { 161 if (!parseXml(buffer)) {
160 delete domDoc; 162 delete domDoc;
161#ifndef PWM_EMBEDDED 163#ifndef PWM_EMBEDDED
162 throw PwMException(PwMException::EX_PARSE); 164 throw PwMException(PwMException::EX_PARSE);
163#else 165#else
164 qDebug("Serializer::Serializer : Parse Exception "); 166 qDebug("Serializer::Serializer : Parse Exception ");
165#endif 167#endif
166 } 168 }
167} 169}
168 170
169Serializer::~Serializer() 171Serializer::~Serializer()
170{ 172{
171 delete_ifnot_null(domDoc); 173 delete_ifnot_null(domDoc);
172} 174}
173 175
174void Serializer::clear() 176void Serializer::clear()
175{ 177{
176 delete_ifnot_null(domDoc); 178 delete_ifnot_null(domDoc);
177 domDoc = new QDomDocument; 179 domDoc = new QDomDocument;
178} 180}
179 181
180bool Serializer::parseXml(const QCString &buffer) 182bool Serializer::parseXml(const Q3CString &buffer)
181{ 183{
182 //abort(); 184 //abort();
183 //qDebug("parse %s ", buffer.data()); 185 //qDebug("parse %s ", buffer.data());
184 PWM_ASSERT(domDoc); 186 PWM_ASSERT(domDoc);
185#ifndef PWM_EMBEDDED 187#ifndef PWM_EMBEDDED
186 if (!domDoc->setContent(buffer, true)) 188 if (!domDoc->setContent(buffer, true))
187 return false; 189 return false;
188#else 190#else
189#ifdef DESKTOP_VERSION 191#ifdef DESKTOP_VERSION
190 if (!domDoc->setContent(buffer, true)) 192 if (!domDoc->setContent(buffer, true))
191#else 193#else
192 if (!domDoc->setContent(buffer)) 194 if (!domDoc->setContent(buffer))
193#endif 195#endif
194 return false; 196 return false;
195#endif 197#endif
196 if (!checkValid()) 198 if (!checkValid())
197 return false; 199 return false;
198 return true; 200 return true;
199} 201}
200 202
201QCString Serializer::getXml() 203Q3CString Serializer::getXml()
202{ 204{
203 PWM_ASSERT(domDoc); 205 PWM_ASSERT(domDoc);
204 206
205#ifndef PWM_EMBEDDED 207#ifndef PWM_EMBEDDED
206#if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0 208#if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0
207 QCString tmp(domDoc->toCString(8)); 209 Q3CString tmp(domDoc->toCString(8));
208 printDebug("<BEGIN Serializer::getXml() dump>\n"); 210 printDebug("<BEGIN Serializer::getXml() dump>\n");
209 cout << tmp << endl; 211 cout << tmp << endl;
210 printDebug("<END Serializer::getXml() dump>"); 212 printDebug("<END Serializer::getXml() dump>");
211#endif // DEBUG 213#endif // DEBUG
212 214
213 QCString ret(domDoc->toCString(0)); 215 Q3CString ret(domDoc->toCString(0));
214 ret.replace('\n', ""); 216 ret.replace('\n', "");
215 return ret; 217 return ret;
216#else 218#else
217 219
218#if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0 220#if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0
219 QCString tmp(" " + domDoc->toCString()); 221 Q3CString tmp(" " + domDoc->toCString());
220 printDebug("<BEGIN Serializer::getXml() dump>\n"); 222 printDebug("<BEGIN Serializer::getXml() dump>\n");
221 qDebug(tmp); 223 qDebug(tmp);
222 cout << tmp << endl; 224 cout << tmp << endl;
223 printDebug("<END Serializer::getXml() dump>"); 225 printDebug("<END Serializer::getXml() dump>");
224#endif // DEBUG 226#endif // DEBUG
225 227
226 QCString ret(domDoc->toCString()); 228 Q3CString ret(domDoc->toByteArray());
227 ret.replace(QRegExp("\n"), ""); 229 ret.replace("\n", "");
228 return ret; 230 return ret;
229 231
230#endif 232#endif
231} 233}
232 234
233bool Serializer::serialize(PwMItem &dta) 235bool Serializer::serialize(PwMItem &dta)
234{ 236{
235 PWM_ASSERT(domDoc); 237 PWM_ASSERT(domDoc);
236 QDomElement root(genNewRoot()); 238 QDomElement root(genNewRoot());
237 QDomElement catNode(domDoc->createElement(CAT_ROOT_WR)); 239 QDomElement catNode(domDoc->createElement(CAT_ROOT_WR));
238 QDomElement syncNode(domDoc->createElement(SYNC_ROOT)); 240 QDomElement syncNode(domDoc->createElement(SYNC_ROOT));
239 if (!addSyncData(&syncNode, dta.syncDta)) 241 if (!addSyncData(&syncNode, dta.syncDta))
240 return false; 242 return false;
241 root.appendChild(syncNode); 243 root.appendChild(syncNode);
242 if (!addCategories(&catNode, dta.dta)) 244 if (!addCategories(&catNode, dta.dta))
243 return false; 245 return false;
244 root.appendChild(catNode); 246 root.appendChild(catNode);
245 return true; 247 return true;
246} 248}
247 249
248bool Serializer::deSerialize(PwMItem *dta) 250bool Serializer::deSerialize(PwMItem *dta)
249{ 251{
250 PWM_ASSERT(domDoc); 252 PWM_ASSERT(domDoc);
251 PWM_ASSERT(dta); 253 PWM_ASSERT(dta);
252 QDomElement root(domDoc->documentElement()); 254 QDomElement root(domDoc->documentElement());
253 QDomNode n; 255 QDomNode n;
254 256
255 dta->clear(); 257 dta->clear();
256 for (n = root.firstChild(); !n.isNull(); n = n.nextSibling()) { 258 for (n = root.firstChild(); !n.isNull(); n = n.nextSibling()) {
257 // find <categories> ... </categories> 259 // find <categories> ... </categories>
258 // <c> ... </c> 260 // <c> ... </c>
259 if (n.nodeName() == CAT_ROOT_NEW || 261 if (n.nodeName() == CAT_ROOT_NEW ||
260 n.nodeName() == CAT_ROOT_OLD) { 262 n.nodeName() == CAT_ROOT_OLD) {
261 if (!readCategories(n, &(dta->dta))) { 263 if (!readCategories(n, &(dta->dta))) {
262 return false; 264 return false;
263 } 265 }
264 continue; 266 continue;
265 } 267 }
266 else if (n.nodeName() == SYNC_ROOT) { 268 else if (n.nodeName() == SYNC_ROOT) {
267 if (!readSyncData(n, &(dta->syncDta))) { 269 if (!readSyncData(n, &(dta->syncDta))) {
268 return false; 270 return false;
269 } 271 }
270 continue; 272 continue;
271 } 273 }
272 274
273 /* NOTE: We can stop processing here, as we 275 /* NOTE: We can stop processing here, as we
274 * don't have more nodes in root, yet. 276 * don't have more nodes in root, yet.
275 */ 277 */
276 return false; 278 return false;
277 279
278 } 280 }
279 return true; 281 return true;
280} 282}
281 283
282bool Serializer::readCategories(const QDomNode &n, 284bool Serializer::readCategories(const QDomNode &n,
283 vector<PwMCategoryItem> *dta) 285 vector<PwMCategoryItem> *dta)
284{ 286{
285 QDomNodeList nl(n.childNodes()); 287 QDomNodeList nl(n.childNodes());
286 QDomNode cur; 288 QDomNode cur;
287 QString name; 289 QString name;
288 QString text; 290 QString text;
289 unsigned int numCat = nl.count(), i; 291 unsigned int numCat = nl.count(), i;
290 PwMCategoryItem curCat; 292 PwMCategoryItem curCat;
291 vector<PwMDataItem> curEntr; 293 vector<PwMDataItem> curEntr;
292 294
293 if (!numCat) { 295 if (!numCat) {
294 printDebug("Serializer::readCategories(): empty"); 296 printDebug("Serializer::readCategories(): empty");
295 return false; 297 return false;
296 } 298 }
297 for (i = 0; i < numCat; ++i) { 299 for (i = 0; i < numCat; ++i) {
298 cur = nl.item(i); 300 cur = nl.item(i);
299 if (cur.nodeName().left(1) == CAT_PREFIX_NEW || 301 if (cur.nodeName().left(1) == CAT_PREFIX_NEW ||
300 cur.nodeName().left(4) == CAT_PREFIX_OLD) { 302 cur.nodeName().left(4) == CAT_PREFIX_OLD) {
301 name = cur.toElement().attribute(CAT_NAME_NEW); 303 name = cur.toElement().attribute(CAT_NAME_NEW);
302 if (name == QString::null) 304 if (name == QString::null)
303 name = cur.toElement().attribute(CAT_NAME_OLD); 305 name = cur.toElement().attribute(CAT_NAME_OLD);
304 PWM_ASSERT(name != QString::null); 306 PWM_ASSERT(name != QString::null);
305 PWM_ASSERT(name != ""); 307 PWM_ASSERT(name != "");
306 curCat.clear(); 308 curCat.clear();
307 curCat.name = name.latin1(); 309 curCat.name = name.latin1();
308 310
309 //US ENH: new version might include text for description, name and pw 311 //US ENH: new version might include text for description, name and pw
310 text = cur.toElement().attribute(CAT_TEXT_NEW); 312 text = cur.toElement().attribute(CAT_TEXT_NEW);
311 if (text == QString::null) 313 if (text == QString::null)
312 text = cur.toElement().attribute(CAT_TEXT_OLD); 314 text = cur.toElement().attribute(CAT_TEXT_OLD);
313 if (text != QString::null) 315 if (text != QString::null)
314 { 316 {
315 QStringList textlist = QStringList::split(";", text, true); 317 QStringList textlist = QStringList::split(";", text, true);
316 unsigned int num = textlist.count(); 318 unsigned int num = textlist.count();
317 if (num > 0) 319 if (num > 0)
318 curCat.desc_text = textlist[0].latin1(); 320 curCat.desc_text = textlist[0].latin1();
319 if (num > 1) 321 if (num > 1)
320 curCat.name_text = textlist[1].latin1(); 322 curCat.name_text = textlist[1].latin1();
321 if (num > 2) 323 if (num > 2)
322 curCat.pw_text = textlist[2].latin1(); 324 curCat.pw_text = textlist[2].latin1();
323 } 325 }
324 326
325 if (!readEntries(cur, &curEntr)) { 327 if (!readEntries(cur, &curEntr)) {
326 dta->clear(); 328 dta->clear();
327 return false; 329 return false;
328 } 330 }
329 curCat.d = curEntr; 331 curCat.d = curEntr;
330 dta->push_back(curCat); 332 dta->push_back(curCat);
331 } else { 333 } else {
332 printDebug("Serializer::readCategories(): uh? not a category?"); 334 printDebug("Serializer::readCategories(): uh? not a category?");
333 } 335 }
334 } 336 }
335 return true; 337 return true;
336} 338}
337 339
338bool Serializer::readEntries(const QDomNode &n, 340bool Serializer::readEntries(const QDomNode &n,
339 vector<PwMDataItem> *dta) 341 vector<PwMDataItem> *dta)
340{ 342{
341 QDomNodeList nl(n.childNodes()); 343 QDomNodeList nl(n.childNodes());
342 QDomNode cur; 344 QDomNode cur;
343 unsigned int numEntr = nl.count(), i; 345 unsigned int numEntr = nl.count(), i;
344 PwMDataItem curEntr; 346 PwMDataItem curEntr;
345 //US BUG: to initialize all values of curEntr with meaningfulldata, 347 //US BUG: to initialize all values of curEntr with meaningfulldata,
346 // we call clear on it. Reason: Information in the file we will read might be incomplete. 348 // we call clear on it. Reason: Information in the file we will read might be incomplete.
347 // e.g. the metadata is missing. 349 // e.g. the metadata is missing.
348 curEntr.clear(true); 350 curEntr.clear(true);
349 351
350 dta->clear(); 352 dta->clear();
351 for (i = 0; i < numEntr; ++i) { 353 for (i = 0; i < numEntr; ++i) {
352 cur = nl.item(i); 354 cur = nl.item(i);
353 if (cur.nodeName().left(1) == ENTRY_PREFIX_NEW || 355 if (cur.nodeName().left(1) == ENTRY_PREFIX_NEW ||
354 cur.nodeName().left(6) == ENTRY_PREFIX_OLD) { 356 cur.nodeName().left(6) == ENTRY_PREFIX_OLD) {
355 if (!extractEntry(cur, &curEntr)) { 357 if (!extractEntry(cur, &curEntr)) {
356 return false; 358 return false;
357 } 359 }
358 dta->push_back(curEntr); 360 dta->push_back(curEntr);
359 } else { 361 } else {
360 printDebug("Serializer::readEntries(): hm? not an entry?"); 362 printDebug("Serializer::readEntries(): hm? not an entry?");
361 } 363 }
362 } 364 }
363 return true; 365 return true;
364} 366}
365 367
366bool Serializer::extractEntry(const QDomNode &n, 368bool Serializer::extractEntry(const QDomNode &n,
367 PwMDataItem *dta) 369 PwMDataItem *dta)
368{ 370{
369 QDomNodeList nl(n.childNodes()); 371 QDomNodeList nl(n.childNodes());
370 QDomNode cur, cdata; 372 QDomNode cur, cdata;
371 unsigned int cnt = nl.count(), i; 373 unsigned int cnt = nl.count(), i;
372 QString name, text; 374 QString name, text;
373 375
374 if (!cnt) { 376 if (!cnt) {
375 printDebug("Serializer::extractEntry(): empty"); 377 printDebug("Serializer::extractEntry(): empty");
376 return false; 378 return false;
377 } 379 }
378 dta->clear(); 380 dta->clear();
379 for (i = 0; i < cnt; ++i) { 381 for (i = 0; i < cnt; ++i) {
380 cur = nl.item(i); 382 cur = nl.item(i);
381 name = cur.nodeName(); 383 name = cur.nodeName();
382 cdata = cur.firstChild(); 384 cdata = cur.firstChild();
383 if (unlikely(cdata.isCDATASection())) { 385 if (unlikely(cdata.isCDATASection())) {
384 text = cdata.toCDATASection().data(); 386 text = cdata.toCDATASection().data();
385 } else if (likely(cur.isElement())) { 387 } else if (likely(cur.isElement())) {
386 text = cur.toElement().text(); 388 text = cur.toElement().text();
387 } else { 389 } else {
388 printDebug("Serializer::extractEntry(): neither CDATA nor element."); 390 printDebug("Serializer::extractEntry(): neither CDATA nor element.");
389 return false; 391 return false;
390 } 392 }
391 if (text == " ") 393 if (text == " ")
392 text = ""; // for backward compatibility. 394 text = ""; // for backward compatibility.
393 //qDebug("entry %s ",unescapeEntryData(text).latin1()); 395 //qDebug("entry %s ",unescapeEntryData(text).latin1());
394 if (name == ENTRY_DESC_NEW || 396 if (name == ENTRY_DESC_NEW ||
395 name == ENTRY_DESC_OLD) { 397 name == ENTRY_DESC_OLD) {
396 dta->desc = unescapeEntryData(text).latin1(); 398 dta->desc = unescapeEntryData(text).latin1();
397 } else if (name == ENTRY_NAME_NEW || 399 } else if (name == ENTRY_NAME_NEW ||
398 name == ENTRY_NAME_OLD) { 400 name == ENTRY_NAME_OLD) {
399 dta->name = unescapeEntryData(text).latin1(); 401 dta->name = unescapeEntryData(text).latin1();
400 } else if (name == ENTRY_PW_NEW || 402 } else if (name == ENTRY_PW_NEW ||
401 name == ENTRY_PW_OLD) { 403 name == ENTRY_PW_OLD) {
402 dta->pw = unescapeEntryData(text).latin1(); 404 dta->pw = unescapeEntryData(text).latin1();
403 } else if (name == ENTRY_COMMENT_NEW || 405 } else if (name == ENTRY_COMMENT_NEW ||
404 name == ENTRY_COMMENT_OLD) { 406 name == ENTRY_COMMENT_OLD) {
405 dta->comment = unescapeEntryData(text).latin1(); 407 dta->comment = unescapeEntryData(text).latin1();
406 } else if (name == ENTRY_URL_NEW || 408 } else if (name == ENTRY_URL_NEW ||
407 name == ENTRY_URL_OLD) { 409 name == ENTRY_URL_OLD) {
408 dta->url = unescapeEntryData(text).latin1(); 410 dta->url = unescapeEntryData(text).latin1();
409 } else if (name == ENTRY_LAUNCHER_NEW || 411 } else if (name == ENTRY_LAUNCHER_NEW ||
410 name == ENTRY_LAUNCHER_OLD) { 412 name == ENTRY_LAUNCHER_OLD) {
411 dta->launcher = unescapeEntryData(text).latin1(); 413 dta->launcher = unescapeEntryData(text).latin1();
412 } else if (name == ENTRY_LVP_NEW || 414 } else if (name == ENTRY_LVP_NEW ||
413 name == ENTRY_LVP_OLD) { 415 name == ENTRY_LVP_OLD) {
414 dta->listViewPos = strtol(text.latin1(), 0, 10); 416 dta->listViewPos = strtol(text.latin1(), 0, 10);
415 } else if (name == ENTRY_BIN_NEW) { 417 } else if (name == ENTRY_BIN_NEW) {
416 // ENTRY_BIN_NEW == ENTRY_BIN_OLD 418 // ENTRY_BIN_NEW == ENTRY_BIN_OLD
417 if (text == "0") { 419 if (text == "0") {
418 dta->binary = false; 420 dta->binary = false;
419 } else { 421 } else {
420 dta->binary = true; 422 dta->binary = true;
421 } 423 }
422 } else if (name == ENTRY_META_NEW) { 424 } else if (name == ENTRY_META_NEW) {
423 // ENTRY_META_NEW == ENTRY_META_OLD 425 // ENTRY_META_NEW == ENTRY_META_OLD
424 if (!extractMeta(cur, &dta->meta)) 426 if (!extractMeta(cur, &dta->meta))
425 return false; 427 return false;
426 } else { 428 } else {
427 printDebug(string("Serializer::extractEntry(): invalid: ") 429 printDebug(string("Serializer::extractEntry(): invalid: ")
428 + name.latin1()); 430 + name.latin1());
429 } 431 }
430 } 432 }
431 dta->lockStat = defaultLockStat; 433 dta->lockStat = defaultLockStat;
432 return true; 434 return true;
433} 435}
434 436
435bool Serializer::extractMeta(const QDomNode &n, 437bool Serializer::extractMeta(const QDomNode &n,
436 PwMMetaData *dta) 438 PwMMetaData *dta)
437{ 439{
438 QDomNode cur(n.firstChild()); 440 QDomNode cur(n.firstChild());
439 QString name, val; 441 QString name, val;
440 while (!cur.isNull()) { 442 while (!cur.isNull()) {
441 name = cur.nodeName(); 443 name = cur.nodeName();
442 val = cur.toElement().text(); 444 val = cur.toElement().text();
443 if (val == "") { 445 if (val == "") {
444 cur = cur.nextSibling(); 446 cur = cur.nextSibling();
445 continue; 447 continue;
446 } 448 }
447 449
448 //US BUG: The transformation of an empty date into an ISO date and back is different on different systems/compilers. 450 //US BUG: The transformation of an empty date into an ISO date and back is different on different systems/compilers.
449 //because of that it is possible that here some values are not set, which means they are null. 451 //because of that it is possible that here some values are not set, which means they are null.
450 //US ENH: at the same moment we need backwardcompatibility. So older versions might have stored invalid dates. 452 //US ENH: at the same moment we need backwardcompatibility. So older versions might have stored invalid dates.
451 453
452 QDateTime dtval; //dtval should be invalid by definition. 454 QDateTime dtval; //dtval should be invalid by definition.
453 455
454 if ((name == META_CREATE_DATE) || 456 if ((name == META_CREATE_DATE) ||
455 (name == META_VALID_DATE) || 457 (name == META_VALID_DATE) ||
456 (name == META_EXPIRE_DATE) || 458 (name == META_EXPIRE_DATE) ||
457 (name == META_UPDATE_DATE)) 459 (name == META_UPDATE_DATE))
458 { 460 {
459 //qDebug("Serializer::extractMeta:: val:%s, empty:%i, length:%i",val.utf8(), val.isEmpty(), val.length()); 461 //qDebug("Serializer::extractMeta:: val:%s, empty:%i, length:%i",val.utf8(), val.isEmpty(), val.length());
460 462
461#ifndef PWM_EMBEDDED 463#ifndef PWM_EMBEDDED
462 dtval = QDateTime::fromString(val, Qt::ISODate); 464 dtval = QDateTime::fromString(val, Qt::ISODate);
463#else 465#else
464 bool ok; 466 bool ok;
465 dtval = KGlobal::locale()->readDateTime(val, KLocale::ISODate, &ok); 467 dtval = KGlobal::locale()->readDateTime(val, KLocale::ISODate, &ok);
466 468
467 if (ok == false) 469 if (ok == false)
468 qDebug("Serializer::extractMeta invalid date or time !!!!!!!!!!!!!"); 470 qDebug("Serializer::extractMeta invalid date or time !!!!!!!!!!!!!");
469#endif 471#endif
470 472
471 //if the parsed data is wrong, dtval should be invalid at this time. 473 //if the parsed data is wrong, dtval should be invalid at this time.
472 474
473 } 475 }
474 476
475 if (name == META_CREATE_DATE) { 477 if (name == META_CREATE_DATE) {
476 dta->create = dtval; 478 dta->create = dtval;
477 } else if (name == META_VALID_DATE) { 479 } else if (name == META_VALID_DATE) {
478 dta->valid = dtval; 480 dta->valid = dtval;
479 } else if (name == META_EXPIRE_DATE) { 481 } else if (name == META_EXPIRE_DATE) {
480 dta->expire = dtval; 482 dta->expire = dtval;
481 } else if (name == META_UPDATE_DATE) { 483 } else if (name == META_UPDATE_DATE) {
482 dta->update = dtval; 484 dta->update = dtval;
483 } else if (name == META_UPDATE_INT) { 485 } else if (name == META_UPDATE_INT) {
484 dta->updateInt = strtoul(val.latin1(), 0, 10); 486 dta->updateInt = strtoul(val.latin1(), 0, 10);
485 } else if (name == META_UNIQUEID) { 487 } else if (name == META_UNIQUEID) {
486 dta->uniqueid = unescapeEntryData(val).latin1(); 488 dta->uniqueid = unescapeEntryData(val).latin1();
487 } else { 489 } else {
488 printDebug(string("extractMeta(): invalid: ") 490 printDebug(string("extractMeta(): invalid: ")
489 + name.latin1()); 491 + name.latin1());
490 } 492 }
491 493
492 cur = cur.nextSibling(); 494 cur = cur.nextSibling();
493 } 495 }
494 return true; 496 return true;
495} 497}
496 498
497bool Serializer::checkValid() 499bool Serializer::checkValid()
498{ 500{
499 PWM_ASSERT(domDoc); 501 PWM_ASSERT(domDoc);
500 QDomElement root(domDoc->documentElement()); 502 QDomElement root(domDoc->documentElement());
501 if (root.nodeName() != ROOT_MAGIC_NEW && 503 if (root.nodeName() != ROOT_MAGIC_NEW &&
502 root.nodeName() != ROOT_MAGIC_OLD) { 504 root.nodeName() != ROOT_MAGIC_OLD) {
503 printDebug("Serializer: wrong magic"); 505 printDebug("Serializer: wrong magic");
504 return false; 506 return false;
505 } 507 }
506 if (root.attribute(VER_STR_NEW) != COMPAT_VER_NEW && 508 if (root.attribute(VER_STR_NEW) != COMPAT_VER_NEW &&
507 root.attribute(VER_STR_OLD) != COMPAT_VER_OLD) { 509 root.attribute(VER_STR_OLD) != COMPAT_VER_OLD) {
508 printDebug("Serializer: wrong version"); 510 printDebug("Serializer: wrong version");
509 return false; 511 return false;
510 } 512 }
511 return true; 513 return true;
512} 514}
513 515
514QDomElement Serializer::genNewRoot() 516QDomElement Serializer::genNewRoot()
515{ 517{
516 PWM_ASSERT(domDoc); 518 PWM_ASSERT(domDoc);
517 QDomElement root(domDoc->createElement(ROOT_MAGIC_WR)); 519 QDomElement root(domDoc->createElement(ROOT_MAGIC_WR));
518 root.setAttribute(VER_STR_WR, COMPAT_VER_WR); 520 root.setAttribute(VER_STR_WR, COMPAT_VER_WR);
519 domDoc->appendChild(root); 521 domDoc->appendChild(root);
520 return root; 522 return root;
521} 523}
522 524
523bool Serializer::addCategories(QDomElement *e, 525bool Serializer::addCategories(QDomElement *e,
524 const vector<PwMCategoryItem> &dta) 526 const vector<PwMCategoryItem> &dta)
525{ 527{
526 unsigned int numCat = dta.size(), i; 528 unsigned int numCat = dta.size(), i;
527 QString curId, curName; 529 QString curId, curName;
528 QDomElement curCat; 530 QDomElement curCat;
529 531
530 for (i = 0; i < numCat; ++i) { 532 for (i = 0; i < numCat; ++i) {
531 curId = CAT_PREFIX_WR; 533 curId = CAT_PREFIX_WR;
532 curId += tostr(i).c_str(); 534 curId += tostr(i).c_str();
533 curName = dta[i].name.c_str(); 535 curName = dta[i].name.c_str();
534 curCat = domDoc->createElement(curId); 536 curCat = domDoc->createElement(curId);
535 curCat.setAttribute(CAT_NAME_WR, curName); 537 curCat.setAttribute(CAT_NAME_WR, curName);
536 538
537 //US ENH: new version includes text for description, name and pw 539 //US ENH: new version includes text for description, name and pw
538 QStringList curTextList; 540 QStringList curTextList;
539 curTextList << dta[i].desc_text.c_str(); 541 curTextList << dta[i].desc_text.c_str();
540 curTextList << dta[i].name_text.c_str(); 542 curTextList << dta[i].name_text.c_str();
541 curTextList << dta[i].pw_text.c_str(); 543 curTextList << dta[i].pw_text.c_str();
542 QString text = curTextList.join(";"); 544 QString text = curTextList.join(";");
543 curCat.setAttribute(CAT_TEXT_WR, text); 545 curCat.setAttribute(CAT_TEXT_WR, text);
544 546
545 547
546 if (!addEntries(&curCat, dta[i].d)) { 548 if (!addEntries(&curCat, dta[i].d)) {
547 return false; 549 return false;
548 } 550 }
549 e->appendChild(curCat); 551 e->appendChild(curCat);
550 } 552 }
551 return true; 553 return true;
552} 554}
553 555
554bool Serializer::addEntries(QDomElement *e, 556bool Serializer::addEntries(QDomElement *e,
555 const vector<PwMDataItem> &dta) 557 const vector<PwMDataItem> &dta)
556{ 558{
557 unsigned int numEntr = dta.size(), i; 559 unsigned int numEntr = dta.size(), i;
558 QString curId; 560 QString curId;
559 QDomElement curEntr; 561 QDomElement curEntr;
560 562
561 for (i = 0; i < numEntr; ++i) { 563 for (i = 0; i < numEntr; ++i) {
562 curId = ENTRY_PREFIX_WR; 564 curId = ENTRY_PREFIX_WR;
563 curId += tostr(i).c_str(); 565 curId += tostr(i).c_str();
564 curEntr = domDoc->createElement(curId); 566 curEntr = domDoc->createElement(curId);
565 if (!writeEntry(&curEntr, dta[i])) { 567 if (!writeEntry(&curEntr, dta[i])) {
566 return false; 568 return false;
567 } 569 }
568 e->appendChild(curEntr); 570 e->appendChild(curEntr);
569 } 571 }
570 return true; 572 return true;
571} 573}
572 574
573bool Serializer::writeEntry(QDomElement *e, 575bool Serializer::writeEntry(QDomElement *e,
574 const PwMDataItem &_dta) 576 const PwMDataItem &_dta)
575{ 577{
576#if WRITE_CDATA_SEC != 0 578#if WRITE_CDATA_SEC != 0
577 # define new_text(x)domDoc->createCDATASection(x) 579 # define new_text(x)domDoc->createCDATASection(x)
578 QDomCDATASection curText; 580 QDomCDATASection curText;
579#else 581#else
580 # define new_text(x)domDoc->createTextNode(x) 582 # define new_text(x)domDoc->createTextNode(x)
581 QDomText curText; 583 QDomText curText;
582#endif 584#endif
583 585
584 QDomText plainText; 586 QDomText plainText;
585 QDomElement tag; 587 QDomElement tag;
586 588
587 // begin -- This is for compatibility with the old serializer 589 // begin -- This is for compatibility with the old serializer
588 PwMDataItem dta = _dta; 590 PwMDataItem dta = _dta;
589 if (!dta.desc.size()) 591 if (!dta.desc.size())
590 dta.desc = " "; 592 dta.desc = " ";
591 if (!dta.name.size()) 593 if (!dta.name.size())
592 dta.name = " "; 594 dta.name = " ";
593 if (!dta.pw.size()) 595 if (!dta.pw.size())
594 dta.pw = " "; 596 dta.pw = " ";
595 if (!dta.comment.size()) 597 if (!dta.comment.size())
596 dta.comment = " "; 598 dta.comment = " ";
597 if (!dta.url.size()) 599 if (!dta.url.size())
598 dta.url = " "; 600 dta.url = " ";
599 if (!dta.launcher.size()) 601 if (!dta.launcher.size())
600 dta.launcher = " "; 602 dta.launcher = " ";
601 // end -- This is for compatibility with the old serializer 603 // end -- This is for compatibility with the old serializer
602 604
603 tag = domDoc->createElement(ENTRY_DESC_WR); 605 tag = domDoc->createElement(ENTRY_DESC_WR);
604 curText = new_text(escapeEntryData(dta.desc.c_str())); 606 curText = new_text(escapeEntryData(dta.desc.c_str()));
605 tag.appendChild(curText); 607 tag.appendChild(curText);
606 e->appendChild(tag); 608 e->appendChild(tag);
607 609
608 tag = domDoc->createElement(ENTRY_NAME_WR); 610 tag = domDoc->createElement(ENTRY_NAME_WR);
609 curText = new_text(escapeEntryData(dta.name.c_str())); 611 curText = new_text(escapeEntryData(dta.name.c_str()));
610 tag.appendChild(curText); 612 tag.appendChild(curText);
611 e->appendChild(tag); 613 e->appendChild(tag);
diff --git a/pwmanager/pwmanager/serializer.h b/pwmanager/pwmanager/serializer.h
index df50e42..e085ade 100644
--- a/pwmanager/pwmanager/serializer.h
+++ b/pwmanager/pwmanager/serializer.h
@@ -1,115 +1,115 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 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/*************************************************************************** 13/***************************************************************************
14 * copyright (C) 2004 by Ulf Schenk 14 * copyright (C) 2004 by Ulf Schenk
15 * This file is originaly based on version 1.1 of pwmanager 15 * This file is originaly based on version 1.1 of pwmanager
16 * and was modified to run on embedded devices that run microkde 16 * and was modified to run on embedded devices that run microkde
17 * 17 *
18 * $Id$ 18 * $Id$
19 **************************************************************************/ 19 **************************************************************************/
20 20
21#ifndef __SERIALIZER_H 21#ifndef __SERIALIZER_H
22#define __SERIALIZER_H 22#define __SERIALIZER_H
23 23
24#include "pwmdoc.h" 24#include "pwmdoc.h"
25 25
26#include <qcstring.h> 26#include <q3cstring.h>
27#include <qdom.h> 27#include <qdom.h>
28 28
29#include <vector> 29#include <vector>
30 30
31using std::vector; 31using std::vector;
32 32
33/** This serializes its input data into 33/** This serializes its input data into
34 * the PwManager-XML-datastream, that becomes 34 * the PwManager-XML-datastream, that becomes
35 * encrypted and maybe compressed 35 * encrypted and maybe compressed
36 */ 36 */
37class Serializer 37class Serializer
38{ 38{
39public: 39public:
40 /** construct an empty serializer document */ 40 /** construct an empty serializer document */
41 Serializer(); 41 Serializer();
42 /** construct a serializer document and parse "buffer" */ 42 /** construct a serializer document and parse "buffer" */
43 Serializer(const QCString &buffer); 43 Serializer(const Q3CString &buffer);
44 /** destructor */ 44 /** destructor */
45 virtual ~Serializer(); 45 virtual ~Serializer();
46 46
47 /** clears all data */ 47 /** clears all data */
48 void clear(); 48 void clear();
49 /** parse the given data buffer */ 49 /** parse the given data buffer */
50 bool parseXml(const QCString &buffer); 50 bool parseXml(const Q3CString &buffer);
51 /** returns the current XML data */ 51 /** returns the current XML data */
52 QCString getXml(); 52 Q3CString getXml();
53 /** serialize "dta" and store it as XML data */ 53 /** serialize "dta" and store it as XML data */
54 //US ENH: we need to serialize and deserialize not only categories, but also synctargets 54 //US ENH: we need to serialize and deserialize not only categories, but also synctargets
55 bool serialize(PwMItem &dta); 55 bool serialize(PwMItem &dta);
56 /** deserialize the (parsed) XML data and store it in "dta" */ 56 /** deserialize the (parsed) XML data and store it in "dta" */
57 bool deSerialize(PwMItem *dta); 57 bool deSerialize(PwMItem *dta);
58 /** sets the initial default lockStat we should assign */ 58 /** sets the initial default lockStat we should assign */
59 void setDefaultLockStat(bool stat) 59 void setDefaultLockStat(bool stat)
60 { defaultLockStat = stat; } 60 { defaultLockStat = stat; }
61 61
62protected: 62protected:
63 /** main data holder */ 63 /** main data holder */
64 QDomDocument *domDoc; 64 QDomDocument *domDoc;
65 /** default lockStat to assign */ 65 /** default lockStat to assign */
66 bool defaultLockStat; 66 bool defaultLockStat;
67 67
68protected: 68protected:
69 /** check if this is valid PwManager XML data */ 69 /** check if this is valid PwManager XML data */
70 bool checkValid(); 70 bool checkValid();
71 /** read the categories in the node "n" */ 71 /** read the categories in the node "n" */
72 bool readCategories(const QDomNode &n, 72 bool readCategories(const QDomNode &n,
73 vector<PwMCategoryItem> *dta); 73 vector<PwMCategoryItem> *dta);
74 /** read the entries in the node "n" */ 74 /** read the entries in the node "n" */
75 bool readEntries(const QDomNode &n, 75 bool readEntries(const QDomNode &n,
76 vector<PwMDataItem> *dta); 76 vector<PwMDataItem> *dta);
77 /** extract the data out of the given item at "n" */ 77 /** extract the data out of the given item at "n" */
78 bool extractEntry(const QDomNode &n, 78 bool extractEntry(const QDomNode &n,
79 PwMDataItem *dta); 79 PwMDataItem *dta);
80 /** extract the meta-data */ 80 /** extract the meta-data */
81 bool extractMeta(const QDomNode &n, 81 bool extractMeta(const QDomNode &n,
82 PwMMetaData *dta); 82 PwMMetaData *dta);
83 /** generates a new root node and sets all initial parameters */ 83 /** generates a new root node and sets all initial parameters */
84 QDomElement genNewRoot(); 84 QDomElement genNewRoot();
85 /** add new categories to the XML data stream in e */ 85 /** add new categories to the XML data stream in e */
86 bool addCategories(QDomElement *e, 86 bool addCategories(QDomElement *e,
87 const vector<PwMCategoryItem> &dta); 87 const vector<PwMCategoryItem> &dta);
88 /** add the given new entries to the XML data stream in e */ 88 /** add the given new entries to the XML data stream in e */
89 bool addEntries(QDomElement *e, 89 bool addEntries(QDomElement *e,
90 const vector<PwMDataItem> &dta); 90 const vector<PwMDataItem> &dta);
91 /** do serialize and write the given entry to the XML stream */ 91 /** do serialize and write the given entry to the XML stream */
92 bool writeEntry(QDomElement *e, 92 bool writeEntry(QDomElement *e,
93 const PwMDataItem &_dta); 93 const PwMDataItem &_dta);
94 /** write the entry meta data to the xml stream */ 94 /** write the entry meta data to the xml stream */
95 bool writeMeta(QDomElement *e, 95 bool writeMeta(QDomElement *e,
96 const PwMMetaData &dta); 96 const PwMMetaData &dta);
97 /** escape illegal characters out of the given entry data string */ 97 /** escape illegal characters out of the given entry data string */
98 QString escapeEntryData(QString dta); 98 QString escapeEntryData(QString dta);
99 /** un-escape illegal characters out of the given entry data string */ 99 /** un-escape illegal characters out of the given entry data string */
100 QString unescapeEntryData(QString dta); 100 QString unescapeEntryData(QString dta);
101 101
102 102
103 103
104 //US ENH: the following methods are getting used to write/read sync entries 104 //US ENH: the following methods are getting used to write/read sync entries
105 /** read the syncentries in the node "n" */ 105 /** read the syncentries in the node "n" */
106 bool readSyncData(const QDomNode &n, 106 bool readSyncData(const QDomNode &n,
107 vector<PwMSyncItem> *dta); 107 vector<PwMSyncItem> *dta);
108 108
109 /** add new syncentries to the XML data stream in e */ 109 /** add new syncentries to the XML data stream in e */
110 bool addSyncData(QDomElement *e, 110 bool addSyncData(QDomElement *e,
111 const vector<PwMSyncItem> &dta); 111 const vector<PwMSyncItem> &dta);
112 112
113}; 113};
114 114
115#endif // __SERIALIZER_H 115#endif // __SERIALIZER_H
diff --git a/pwmanager/pwmanager/setmasterpwwnd_emb.cpp b/pwmanager/pwmanager/setmasterpwwnd_emb.cpp
index e6471e6..c5fd4e4 100644
--- a/pwmanager/pwmanager/setmasterpwwnd_emb.cpp
+++ b/pwmanager/pwmanager/setmasterpwwnd_emb.cpp
@@ -1,163 +1,166 @@
1/* 1/*
2 This file is part of PwManager/Platform independent. 2 This file is part of PwManager/Platform independent.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22 22
23$Id$ 23$Id$
24*/ 24*/
25 25
26#include "setmasterpwwnd_emb.h" 26#include "setmasterpwwnd_emb.h"
27 27
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qtabwidget.h> 29#include <qtabwidget.h>
30#include <qwidget.h> 30#include <qwidget.h>
31#include <qlabel.h> 31#include <qlabel.h>
32#include <qlineedit.h> 32#include <qlineedit.h>
33#include <qlayout.h> 33#include <qlayout.h>
34//Added by qt3to4:
35#include <Q3VBoxLayout>
36#include <Q3GridLayout>
34 37
35#include <klocale.h> 38#include <klocale.h>
36 39
37/*US 40/*US
38#include <qvariant.h> 41#include <qvariant.h>
39#include <qpushbutton.h> 42#include <qpushbutton.h>
40#include <qtabwidget.h> 43#include <qtabwidget.h>
41#include <qwidget.h> 44#include <qwidget.h>
42#include <qlabel.h> 45#include <qlabel.h>
43#include <qlineedit.h> 46#include <qlineedit.h>
44#include <qlayout.h> 47#include <qlayout.h>
45#include <qtooltip.h> 48#include <qtooltip.h>
46#include <qwhatsthis.h> 49#include <qwhatsthis.h>
47*/ 50*/
48 51
49/* 52/*
50 * Constructs a setMasterPwWnd as a child of 'parent', with the 53 * Constructs a setMasterPwWnd as a child of 'parent', with the
51 * name 'name' 54 * name 'name'
52 * 55 *
53 */ 56 */
54setMasterPwWnd::setMasterPwWnd( QWidget* parent, const char* name ) 57setMasterPwWnd::setMasterPwWnd( QWidget* parent, const char* name )
55 : KDialogBase( KDialogBase::Plain, i18n( "Set master-password" ), 58 : KDialogBase( KDialogBase::Plain, i18n( "Set master-password" ),
56 KDialogBase::Ok | KDialogBase::Cancel, 59 KDialogBase::Ok | KDialogBase::Cancel,
57 KDialogBase::Ok, parent, name, true ) 60 KDialogBase::Ok, parent, name, true )
58{ 61{
59 QWidget *page = plainPage(); 62 QWidget *page = plainPage();
60 QVBoxLayout *pageLayout = new QVBoxLayout( page ); 63 Q3VBoxLayout *pageLayout = new Q3VBoxLayout( page );
61 64
62 mainTab = new QTabWidget( page ); 65 mainTab = new QTabWidget( page );
63 pageLayout->addWidget( mainTab ); 66 pageLayout->addWidget( mainTab );
64 67
65 68
66 if ( !name ) 69 if ( !name )
67 setName( "setMasterPwWnd" ); 70 setName( "setMasterPwWnd" );
68 71
69 //////////////////////////////////////////////////////////////////// 72 ////////////////////////////////////////////////////////////////////
70 // This is the Password tab1 73 // This is the Password tab1
71 tab = new QWidget( mainTab ); 74 tab = new QWidget( mainTab );
72 75
73 QGridLayout *layout = new QGridLayout( tab, 5, 1 ); 76 Q3GridLayout *layout = new Q3GridLayout( tab, 5, 1 );
74 layout->setMargin( KDialogBase::marginHint() ); 77 layout->setMargin( KDialogBase::marginHint() );
75 layout->setSpacing( KDialogBase::spacingHint() ); 78 layout->setSpacing( KDialogBase::spacingHint() );
76 79
77 QLabel* label = new QLabel( i18n( "Using a normal password-string to encrypt the data." ), tab ); 80 QLabel* label = new QLabel( i18n( "Using a normal password-string to encrypt the data." ), tab );
78 label->setAlignment( int( QLabel::WordBreak | QLabel::AlignCenter ) ); 81 label->setAlignment( int( Qt::WordBreak | Qt::AlignCenter ) );
79 layout->addWidget(label, 0, 0); 82 layout->addWidget(label, 0, 0);
80 83
81 pwEdit_1 = new QLineEdit( tab, "pwEdit_1" ); 84 pwEdit_1 = new QLineEdit( tab, "pwEdit_1" );
82 pwEdit_1->setEchoMode( QLineEdit::Password ); 85 pwEdit_1->setEchoMode( QLineEdit::Password );
83 86
84 label = new QLabel( pwEdit_1, i18n( "Please enter the new master-password:" ), tab ); 87 label = new QLabel( pwEdit_1, i18n( "Please enter the new master-password:" ), tab );
85 layout->addWidget(label, 1, 0); 88 layout->addWidget(label, 1, 0);
86 layout->addWidget(pwEdit_1, 2, 0); 89 layout->addWidget(pwEdit_1, 2, 0);
87 90
88 pwEdit_2 = new QLineEdit( tab, "pwEdit_2" ); 91 pwEdit_2 = new QLineEdit( tab, "pwEdit_2" );
89 pwEdit_2->setEchoMode( QLineEdit::Password ); 92 pwEdit_2->setEchoMode( QLineEdit::Password );
90 93
91 label = new QLabel( pwEdit_2, i18n( "Please enter the password again:" ), tab ); 94 label = new QLabel( pwEdit_2, i18n( "Please enter the password again:" ), tab );
92 layout->addWidget(label, 3, 0); 95 layout->addWidget(label, 3, 0);
93 layout->addWidget(pwEdit_2, 4, 0); 96 layout->addWidget(pwEdit_2, 4, 0);
94 97
95 mainTab->insertTab( tab, i18n("Normal password") ); 98 mainTab->insertTab( tab, i18n("Normal password") );
96 99
97 100
98 //////////////////////////////////////////////////////////////////// 101 ////////////////////////////////////////////////////////////////////
99 // This is the Password tab2 102 // This is the Password tab2
100 tab_2 = new QWidget( mainTab ); 103 tab_2 = new QWidget( mainTab );
101 104
102 layout = new QGridLayout( tab_2, 5, 1 ); 105 layout = new Q3GridLayout( tab_2, 5, 1 );
103 layout->setMargin( KDialogBase::marginHint() ); 106 layout->setMargin( KDialogBase::marginHint() );
104 layout->setSpacing( KDialogBase::spacingHint() ); 107 layout->setSpacing( KDialogBase::spacingHint() );
105 108
106 label = new QLabel( i18n( "Using a PwM key-card to encrypt the data." ), tab_2 ); 109 label = new QLabel( i18n( "Using a PwM key-card to encrypt the data." ), tab_2 );
107 label->setAlignment( int( QLabel::WordBreak | QLabel::AlignCenter ) ); 110 label->setAlignment( int( Qt::WordBreak | Qt::AlignCenter ) );
108 layout->addWidget(label, 0, 0); 111 layout->addWidget(label, 0, 0);
109 112
110 label = new QLabel( i18n( "selected card:" ), tab_2 ); 113 label = new QLabel( i18n( "selected card:" ), tab_2 );
111 label->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); 114 label->setAlignment( int( Qt::AlignVCenter | Qt::AlignRight ) );
112 layout->addWidget(label, 1, 0); 115 layout->addWidget(label, 1, 0);
113 116
114 selCardButton = new QPushButton( i18n( "&Select the currently inserted card as key-card" ), tab_2 ); 117 selCardButton = new QPushButton( i18n( "&Select the currently inserted card as key-card" ), tab_2 );
115 layout->addWidget(selCardButton, 2, 0); 118 layout->addWidget(selCardButton, 2, 0);
116 119
117 genCardButton = new QPushButton( i18n( "&generate new key-card") , tab_2 ); 120 genCardButton = new QPushButton( i18n( "&generate new key-card") , tab_2 );
118 layout->addWidget(genCardButton, 3, 0); 121 layout->addWidget(genCardButton, 3, 0);
119 122
120 curCardIdLabel = new QLabel( QString("") , tab_2 ); 123 curCardIdLabel = new QLabel( QString("") , tab_2 );
121 layout->addWidget(curCardIdLabel, 4, 0); 124 layout->addWidget(curCardIdLabel, 4, 0);
122 125
123 mainTab->insertTab( tab_2, i18n("Key-card (chipcard)" ) ); 126 mainTab->insertTab( tab_2, i18n("Key-card (chipcard)" ) );
124 127
125 128
126 // resize( QSize(411, 313).expandedTo(minimumSizeHint()) ); 129 // resize( QSize(411, 313).expandedTo(minimumSizeHint()) );
127 130
128 // signals and slots connections 131 // signals and slots connections
129 // connect( okButton, SIGNAL( clicked() ), this, SLOT( okButton_slot() ) ); 132 // connect( okButton, SIGNAL( clicked() ), this, SLOT( okButton_slot() ) );
130 // connect( cancelButton, SIGNAL( clicked() ), this, SLOT( cancelButton_slot() ) ); 133 // connect( cancelButton, SIGNAL( clicked() ), this, SLOT( cancelButton_slot() ) );
131 connect( genCardButton, SIGNAL( clicked() ), this, SLOT( genCardButton_slot() ) ); 134 connect( genCardButton, SIGNAL( clicked() ), this, SLOT( genCardButton_slot() ) );
132 connect( selCardButton, SIGNAL( clicked() ), this, SLOT( selCardButton_slot() ) ); 135 connect( selCardButton, SIGNAL( clicked() ), this, SLOT( selCardButton_slot() ) );
133 136
134} 137}
135 138
136/* 139/*
137 * Destroys the object and frees any allocated resources 140 * Destroys the object and frees any allocated resources
138 */ 141 */
139setMasterPwWnd::~setMasterPwWnd() 142setMasterPwWnd::~setMasterPwWnd()
140{ 143{
141 // no need to delete child widgets, Qt does it all for us 144 // no need to delete child widgets, Qt does it all for us
142} 145}
143 146
144void setMasterPwWnd::okButton_slot() 147void setMasterPwWnd::okButton_slot()
145{ 148{
146 qWarning( "setMasterPwWnd::okButton_slot(): Not implemented yet" ); 149 qWarning( "setMasterPwWnd::okButton_slot(): Not implemented yet" );
147} 150}
148 151
149void setMasterPwWnd::cancelButton_slot() 152void setMasterPwWnd::cancelButton_slot()
150{ 153{
151 qWarning( "setMasterPwWnd::cancelButton_slot(): Not implemented yet" ); 154 qWarning( "setMasterPwWnd::cancelButton_slot(): Not implemented yet" );
152} 155}
153 156
154void setMasterPwWnd::genCardButton_slot() 157void setMasterPwWnd::genCardButton_slot()
155{ 158{
156 qWarning( "setMasterPwWnd::genCardButton_slot(): Not implemented yet" ); 159 qWarning( "setMasterPwWnd::genCardButton_slot(): Not implemented yet" );
157} 160}
158 161
159void setMasterPwWnd::selCardButton_slot() 162void setMasterPwWnd::selCardButton_slot()
160{ 163{
161 qWarning( "setMasterPwWnd::selCardButton_slot(): Not implemented yet" ); 164 qWarning( "setMasterPwWnd::selCardButton_slot(): Not implemented yet" );
162} 165}
163 166
diff --git a/pwmanager/pwmanager/setmasterpwwnd_emb.h b/pwmanager/pwmanager/setmasterpwwnd_emb.h
index c8ddec6..a070fea 100644
--- a/pwmanager/pwmanager/setmasterpwwnd_emb.h
+++ b/pwmanager/pwmanager/setmasterpwwnd_emb.h
@@ -1,62 +1,64 @@
1/* 1/*
2 This file is part of PwManager/Platform independent. 2 This file is part of PwManager/Platform independent.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22 22
23$Id$ 23$Id$
24*/ 24*/
25 25
26#ifndef SETMASTERPWWND_EMB_H 26#ifndef SETMASTERPWWND_EMB_H
27#define SETMASTERPWWND_EMB_H 27#define SETMASTERPWWND_EMB_H
28 28
29#include <kdialogbase.h> 29#include <kdialogbase.h>
30//Added by qt3to4:
31#include <QLabel>
30 32
31class QLineEdit; 33class QLineEdit;
32class QPushButton; 34class QPushButton;
33class QLabel; 35class QLabel;
34class QTabWidget; 36class QTabWidget;
35class QWidget; 37class QWidget;
36 38
37class setMasterPwWnd : public KDialogBase 39class setMasterPwWnd : public KDialogBase
38{ 40{
39 Q_OBJECT 41 Q_OBJECT
40 42
41public: 43public:
42 setMasterPwWnd( QWidget* parent = 0, const char* name = 0 ); 44 setMasterPwWnd( QWidget* parent = 0, const char* name = 0 );
43 ~setMasterPwWnd(); 45 ~setMasterPwWnd();
44 46
45 QTabWidget* mainTab; 47 QTabWidget* mainTab;
46 QWidget* tab; 48 QWidget* tab;
47 QWidget* tab_2; 49 QWidget* tab_2;
48 QLineEdit* pwEdit_1; 50 QLineEdit* pwEdit_1;
49 QLineEdit* pwEdit_2; 51 QLineEdit* pwEdit_2;
50 QPushButton* selCardButton; 52 QPushButton* selCardButton;
51 QPushButton* genCardButton; 53 QPushButton* genCardButton;
52 QLabel* curCardIdLabel; 54 QLabel* curCardIdLabel;
53 55
54public slots: 56public slots:
55 virtual void okButton_slot(); 57 virtual void okButton_slot();
56 virtual void cancelButton_slot(); 58 virtual void cancelButton_slot();
57 virtual void genCardButton_slot(); 59 virtual void genCardButton_slot();
58 virtual void selCardButton_slot(); 60 virtual void selCardButton_slot();
59 61
60}; 62};
61 63
62#endif // SETMASTERPWWND_H 64#endif // SETMASTERPWWND_H
diff --git a/pwmanager/pwmanager/setmasterpwwndimpl.cpp b/pwmanager/pwmanager/setmasterpwwndimpl.cpp
index 3482643..7041d2e 100644
--- a/pwmanager/pwmanager/setmasterpwwndimpl.cpp
+++ b/pwmanager/pwmanager/setmasterpwwndimpl.cpp
@@ -1,193 +1,193 @@
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/*************************************************************************** 13/***************************************************************************
14 * copyright (C) 2004 by Ulf Schenk 14 * copyright (C) 2004 by Ulf Schenk
15 * This file is originaly based on version 1.0.1 of pwmanager 15 * This file is originaly based on version 1.0.1 of pwmanager
16 * and was modified to run on embedded devices that run microkde 16 * and was modified to run on embedded devices that run microkde
17 * 17 *
18 * $Id$ 18 * $Id$
19 **************************************************************************/ 19 **************************************************************************/
20 20
21#include "setmasterpwwndimpl.h" 21#include "setmasterpwwndimpl.h"
22#include "pwm.h" 22#include "pwm.h"
23#include "globalstuff.h" 23#include "globalstuff.h"
24 24
25#include <kmessagebox.h> 25#include <kmessagebox.h>
26 26
27#include <qlineedit.h> 27#include <qlineedit.h>
28#include <qlabel.h> 28#include <qlabel.h>
29#include <qtabwidget.h> 29#include <qtabwidget.h>
30 30
31#include <stdio.h> 31#include <stdio.h>
32 32
33#ifdef CONFIG_KEYCARD 33#ifdef CONFIG_KEYCARD
34# include "pwmkeycard.h" 34# include "pwmkeycard.h"
35#endif 35#endif
36 36
37 #define STRING_CARD_NONE(SetMasterPwWndImpl::string_cardNone()) 37 #define STRING_CARD_NONE(SetMasterPwWndImpl::string_cardNone())
38 38
39 39
40SetMasterPwWndImpl::SetMasterPwWndImpl(QWidget * parent, const char *name) 40SetMasterPwWndImpl::SetMasterPwWndImpl(QWidget * parent, const char *name)
41: setMasterPwWnd(parent, name) 41: setMasterPwWnd(parent, name)
42{ 42{
43#ifdef CONFIG_KEYCARD 43#ifdef CONFIG_KEYCARD
44 curCardIdLabel->setText(STRING_CARD_NONE); 44 curCardIdLabel->setText(STRING_CARD_NONE);
45#else // CONFIG_KEYCARD 45#else // CONFIG_KEYCARD
46#ifndef PWM_EMBEDDED 46#ifndef PWM_EMBEDDED
47 mainTab->removePage(mainTab->page(1)); 47 mainTab->removePage(mainTab->page(1));
48#else 48#else
49 mainTab->removePage(tab_2); 49 mainTab->removePage(tab_2);
50#endif 50#endif
51 51
52#endif // CONFIG_KEYCARD 52#endif // CONFIG_KEYCARD
53 keyCard = 0; 53 keyCard = 0;
54} 54}
55 55
56SetMasterPwWndImpl::~SetMasterPwWndImpl() 56SetMasterPwWndImpl::~SetMasterPwWndImpl()
57{ 57{
58} 58}
59 59
60void SetMasterPwWndImpl::okButton_slot() 60void SetMasterPwWndImpl::okButton_slot()
61{ 61{
62#ifndef PWM_EMBEDDED 62#ifndef PWM_EMBEDDED
63 int index = mainTab->currentPageIndex(); 63 int index = mainTab->currentPageIndex();
64 if (index == 0) { 64 if (index == 0) {
65 // normal password 65 // normal password
66 if (pwEdit_1->text() != pwEdit_2->text()) { 66 if (pwEdit_1->text() != pwEdit_2->text()) {
67 KMessageBox::error(this, 67 KMessageBox::error(this,
68 i18n 68 i18n
69 ("The two passwords you have entered don't match.\n" 69 ("The two passwords you have entered don't match.\n"
70 "Please try entering them again."), 70 "Please try entering them again."),
71 i18n("Different passwords")); 71 i18n("Different passwords"));
72 return; 72 return;
73 } 73 }
74 if (pwEdit_1->text() == "") { 74 if (pwEdit_1->text() == "") {
75 KMessageBox::error(this, 75 KMessageBox::error(this,
76 i18n("No password entered. " 76 i18n("No password entered. "
77 "Please type in a password, that " 77 "Please type in a password, that "
78 "you want to use for the encryption."), 78 "you want to use for the encryption."),
79 i18n("no password")); 79 i18n("no password"));
80 return; 80 return;
81 } 81 }
82 } else { 82 } else {
83 // key-card 83 // key-card
84 if (curCardIdLabel->text() == STRING_CARD_NONE) { 84 if (curCardIdLabel->text() == STRING_CARD_NONE) {
85 KMessageBox::error(this, 85 KMessageBox::error(this,
86 i18n("You didn't select a card as " 86 i18n("You didn't select a card as "
87 "PwM-key-card."), 87 "PwM-key-card."),
88 i18n("no card")); 88 i18n("no card"));
89 return; 89 return;
90 } 90 }
91 } 91 }
92 done(1); 92 done(1);
93#endif 93#endif
94} 94}
95 95
96void SetMasterPwWndImpl::cancelButton_slot() 96void SetMasterPwWndImpl::cancelButton_slot()
97{ 97{
98#ifndef PWM_EMBEDDED 98#ifndef PWM_EMBEDDED
99 done(2); 99 done(2);
100#endif 100#endif
101} 101}
102 102
103void SetMasterPwWndImpl::slotOk() 103void SetMasterPwWndImpl::slotOk()
104{ 104{
105 int index = mainTab->currentPageIndex(); 105 int index = mainTab->currentPageIndex();
106 if (index == 0) { 106 if (index == 0) {
107 // normal password 107 // normal password
108 if (pwEdit_1->text() != pwEdit_2->text()) { 108 if (pwEdit_1->text() != pwEdit_2->text()) {
109 KMessageBox::error(this, 109 KMessageBox::error(this,
110 i18n 110 i18n
111 ("The two passwords you have entered\ndon't match.\n" 111 ("The two passwords you have entered\ndon't match.\n"
112 "Please try entering them again."), 112 "Please try entering them again."),
113 i18n("Different passwords")); 113 i18n("Different passwords"));
114 return; 114 return;
115 } 115 }
116 if (pwEdit_1->text() == "") { 116 if (pwEdit_1->text() == "") {
117 KMessageBox::error(this, 117 KMessageBox::error(this,
118 i18n("No password entered.\n" 118 i18n("No password entered.\n"
119 "Please type in a password,\nthat " 119 "Please type in a password,\nthat "
120 "you want to use for\nthe encryption."), 120 "you want to use for\nthe encryption."),
121 i18n("no password")); 121 i18n("no password"));
122 return; 122 return;
123 } 123 }
124 } else { 124 } else {
125 // key-card 125 // key-card
126 if (curCardIdLabel->text() == STRING_CARD_NONE) { 126 if (curCardIdLabel->text() == STRING_CARD_NONE) {
127 KMessageBox::error(this, 127 KMessageBox::error(this,
128 i18n("You didn't select a card as\n" 128 i18n("You didn't select a card as\n"
129 "PwM-key-card."), 129 "PwM-key-card."),
130 i18n("no card")); 130 i18n("no card"));
131 return; 131 return;
132 } 132 }
133 } 133 }
134 134
135 setMasterPwWnd::slotOk(); 135 setMasterPwWnd::slotOk();
136} 136}
137 137
138 138
139void SetMasterPwWndImpl::genCardButton_slot() 139void SetMasterPwWndImpl::genCardButton_slot()
140{ 140{
141#ifdef CONFIG_KEYCARD 141#ifdef CONFIG_KEYCARD
142 PWM_ASSERT(keyCard); 142 PWM_ASSERT(keyCard);
143 keyCard->genNewCard(); 143 keyCard->genNewCard();
144#endif // CONFIG_KEYCARD 144#endif // CONFIG_KEYCARD
145} 145}
146 146
147void SetMasterPwWndImpl::selCardButton_slot() 147void SetMasterPwWndImpl::selCardButton_slot()
148{ 148{
149#ifdef CONFIG_KEYCARD 149#ifdef CONFIG_KEYCARD
150 PWM_ASSERT(keyCard); 150 PWM_ASSERT(keyCard);
151 connect(keyCard, SIGNAL(keyAvailable(uint32_t, const string &)), 151 connect(keyCard, SIGNAL(keyAvailable(uint32_t, const string &)),
152 this, SLOT(keyAvailable_slot(uint32_t, const string &))); 152 this, SLOT(keyAvailable_slot(uint32_t, const string &)));
153 keyCard->getKey(); 153 keyCard->getKey();
154#endif // CONFIG_KEYCARD 154#endif // CONFIG_KEYCARD
155} 155}
156 156
157void SetMasterPwWndImpl::keyAvailable_slot(uint32_t cardId, 157void SetMasterPwWndImpl::keyAvailable_slot(uint32_t cardId,
158 const string &key) 158 const string &key)
159{ 159{
160 if (key == "") 160 if (key == "")
161 return; 161 return;
162 curCardKey = key; 162 curCardKey = key;
163 char id_buf[(sizeof(cardId) * 2) + 2 /* "0x" */ + 1 /* NULL */]; 163 char id_buf[(sizeof(cardId) * 2) + 2 /* "0x" */ + 1 /* NULL */];
164 memcpy(id_buf, "0x", 2); 164 memcpy(id_buf, "0x", 2);
165 sprintf(id_buf + 2, "%X", cardId); 165 sprintf(id_buf + 2, "%X", cardId);
166 curCardIdLabel->setText(id_buf); 166 curCardIdLabel->setText(id_buf);
167} 167}
168 168
169string SetMasterPwWndImpl::getPw(bool *useCard) 169string SetMasterPwWndImpl::getPw(bool *useCard)
170{ 170{
171 int index = mainTab->currentPageIndex(); 171 int index = mainTab->currentPageIndex();
172 if (index == 0) { 172 if (index == 0) {
173 // normal password 173 // normal password
174 if (useCard) 174 if (useCard)
175 *useCard = false; 175 *useCard = false;
176 PWM_ASSERT(pwEdit_1->text() == pwEdit_2->text()); 176 PWM_ASSERT(pwEdit_1->text() == pwEdit_2->text());
177 return pwEdit_1->text().latin1(); 177 return pwEdit_1->text().latin1();
178 } else { 178 } else {
179#ifdef CONFIG_KEYCARD 179#ifdef CONFIG_KEYCARD
180 // key-card 180 // key-card
181 if (useCard) 181 if (useCard)
182 *useCard = true; 182 *useCard = true;
183 PWM_ASSERT(curCardKey != ""); 183 PWM_ASSERT(curCardKey != "");
184 PWM_ASSERT(curCardIdLabel->text() != STRING_CARD_NONE); 184 PWM_ASSERT(curCardIdLabel->text() != STRING_CARD_NONE);
185 return curCardKey; 185 return curCardKey;
186#endif // CONFIG_KEYCARD 186#endif // CONFIG_KEYCARD
187 } 187 }
188 return ""; 188 return "";
189} 189}
190 190
191#ifndef PWM_EMBEDDED 191#ifndef PWM_EMBEDDED_
192#include "setmasterpwwndimpl.moc" 192#include "moc_setmasterpwwndimpl.cpp"
193#endif 193#endif
diff --git a/pwmanager/pwmanager/waitwnd.cpp b/pwmanager/pwmanager/waitwnd.cpp
index a3f25cc..d4676a9 100644
--- a/pwmanager/pwmanager/waitwnd.cpp
+++ b/pwmanager/pwmanager/waitwnd.cpp
@@ -1,94 +1,98 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2003 by Michael Buesch * 3 * copyright (C) 2003 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 "waitwnd.h" 20#include "waitwnd.h"
21#include "globalstuff.h" 21#include "globalstuff.h"
22#include "pwmexception.h" 22#include "pwmexception.h"
23 23
24#include <qmessagebox.h> 24#include <qmessagebox.h>
25//Added by qt3to4:
26#include <QResizeEvent>
27#include <QCloseEvent>
28#include <QLabel>
25 29
26#include <klocale.h> 30#include <klocale.h>
27 31
28 32
29WaitWnd::WaitWnd(QString caption, QString _staticText, 33WaitWnd::WaitWnd(QString caption, QString _staticText,
30 bool showCancelButton, bool showGenericText, 34 bool showCancelButton, bool showGenericText,
31 QWidget *parent, 35 QWidget *parent,
32 const char *name, bool modal, WFlags f) 36 const char *name, bool modal, Qt::WFlags f)
33 : QDialog(parent, name, modal, f) 37 : QDialog(parent, name, modal, f)
34{ 38{
35 canClose = false; 39 canClose = false;
36 vbox1 = new QVBox(this); 40 vbox1 = new Q3VBox(this);
37 staticText = new QLabel(vbox1); 41 staticText = new QLabel(vbox1);
38 if (showGenericText) { 42 if (showGenericText) {
39 genericText = new QLabel(vbox1); 43 genericText = new QLabel(vbox1);
40 genericText->setAlignment(Qt::AlignHCenter | Qt::WordBreak); 44 genericText->setAlignment(Qt::AlignHCenter | Qt::WordBreak);
41 } else { 45 } else {
42 genericText = 0; 46 genericText = 0;
43 } 47 }
44 if (showCancelButton) { 48 if (showCancelButton) {
45 cancelButton = new QPushButton(vbox1); 49 cancelButton = new QPushButton(vbox1);
46 connect(cancelButton, SIGNAL(clicked()), 50 connect(cancelButton, SIGNAL(clicked()),
47 this, SLOT(cancel_slot())); 51 this, SLOT(cancel_slot()));
48 cancelButton->setText(i18n("&Cancel")); 52 cancelButton->setText(i18n("&Cancel"));
49 } else { 53 } else {
50 cancelButton = 0; 54 cancelButton = 0;
51 } 55 }
52 56
53 vbox1->setSpacing(10); 57 vbox1->setSpacing(10);
54 vbox1->setMargin(10); 58 vbox1->setMargin(10);
55 resize(300, 150); 59 resize(300, 150);
56 setCaption(caption); 60 setCaption(caption);
57 staticText->setText(_staticText); 61 staticText->setText(_staticText);
58 staticText->setAlignment(Qt::AlignHCenter | Qt::WordBreak); 62 staticText->setAlignment(Qt::AlignHCenter | Qt::WordBreak);
59} 63}
60 64
61WaitWnd::~WaitWnd() 65WaitWnd::~WaitWnd()
62{ 66{
63} 67}
64 68
65void WaitWnd::resizeEvent(QResizeEvent *) 69void WaitWnd::resizeEvent(QResizeEvent *)
66{ 70{
67 vbox1->resize(size()); 71 vbox1->resize(size());
68} 72}
69 73
70void WaitWnd::closeEvent(QCloseEvent *e) 74void WaitWnd::closeEvent(QCloseEvent *e)
71{ 75{
72 if (canClose) { 76 if (canClose) {
73 emit goingToClose(); 77 emit goingToClose();
74 e->accept(); 78 e->accept();
75 } else { 79 } else {
76 e->ignore(); 80 e->ignore();
77 } 81 }
78} 82}
79 83
80void WaitWnd::cancel_slot() 84void WaitWnd::cancel_slot()
81{ 85{
82 canClose = true; 86 canClose = true;
83 close(); 87 close();
84} 88}
85 89
86void WaitWnd::updateGenericText(const QString &text) 90void WaitWnd::updateGenericText(const QString &text)
87{ 91{
88 if (genericText) 92 if (genericText)
89 genericText->setText(text); 93 genericText->setText(text);
90} 94}
91 95
92#ifndef PWM_EMBEDDED 96#ifndef PWM_EMBEDDED_
93#include "waitwnd.moc" 97#include "moc_waitwnd.cpp"
94#endif 98#endif
diff --git a/pwmanager/pwmanager/waitwnd.h b/pwmanager/pwmanager/waitwnd.h
index ae86c8b..6a619b9 100644
--- a/pwmanager/pwmanager/waitwnd.h
+++ b/pwmanager/pwmanager/waitwnd.h
@@ -1,61 +1,64 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2003 by Michael Buesch * 3 * copyright (C) 2003 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 WAITWND_H 20#ifndef WAITWND_H
21#define WAITWND_H 21#define WAITWND_H
22 22
23#include <qvbox.h> 23#include <q3vbox.h>
24#include <qdialog.h> 24#include <qdialog.h>
25#include <qlabel.h> 25#include <qlabel.h>
26#include <qpushbutton.h> 26#include <qpushbutton.h>
27#include <qevent.h> 27#include <qevent.h>
28//Added by qt3to4:
29#include <QResizeEvent>
30#include <QCloseEvent>
28 31
29/** window to ask the user to wait */ 32/** window to ask the user to wait */
30class WaitWnd : public QDialog 33class WaitWnd : public QDialog
31{ 34{
32 Q_OBJECT 35 Q_OBJECT
33public: 36public:
34 WaitWnd(QString caption, QString _staticText, 37 WaitWnd(QString caption, QString _staticText,
35 bool showCancelButton, bool showGenericText, 38 bool showCancelButton, bool showGenericText,
36 QWidget *parent = 0, const char *name = 0, 39 QWidget *parent = 0, const char *name = 0,
37 bool modal = FALSE, WFlags f = 0); 40 bool modal = FALSE, Qt::WFlags f = 0);
38 ~WaitWnd(); 41 ~WaitWnd();
39 42
40 void updateGenericText(const QString &text); 43 void updateGenericText(const QString &text);
41 44
42signals: 45signals:
43 void goingToClose(); 46 void goingToClose();
44 47
45protected slots: 48protected slots:
46 void cancel_slot(); 49 void cancel_slot();
47 50
48protected: 51protected:
49 QVBox *vbox1; 52 Q3VBox *vbox1;
50 QLabel *staticText; 53 QLabel *staticText;
51 QLabel *genericText; 54 QLabel *genericText;
52 QPushButton *cancelButton; 55 QPushButton *cancelButton;
53 /** can we safely close the widget? */ 56 /** can we safely close the widget? */
54 bool canClose; 57 bool canClose;
55 58
56protected: 59protected:
57 void resizeEvent(QResizeEvent *); 60 void resizeEvent(QResizeEvent *);
58 void closeEvent(QCloseEvent *e); 61 void closeEvent(QCloseEvent *e);
59}; 62};
60 63
61#endif 64#endif