-rw-r--r-- | pwmanager/pwmanager/configwnd.cpp | 11 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwm.cpp | 35 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmanagerE.pro | 27 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmdoc.cpp | 2 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmdoc.h | 2 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmdocui.cpp | 1 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwminit.cpp | 19 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmtray.cpp | 4 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmview.cpp | 4 | ||||
-rw-r--r-- | pwmanager/pwmanager/serializer.cpp | 1 |
10 files changed, 83 insertions, 23 deletions
diff --git a/pwmanager/pwmanager/configwnd.cpp b/pwmanager/pwmanager/configwnd.cpp index 230ca1b..108c40f 100644 --- a/pwmanager/pwmanager/configwnd.cpp +++ b/pwmanager/pwmanager/configwnd.cpp | |||
@@ -1,264 +1,265 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** Form implementation generated from reading ui file 'configwnd.ui' | 2 | ** Form implementation generated from reading ui file 'configwnd.ui' |
3 | ** | 3 | ** |
4 | ** Created: Tue Sep 14 15:20:58 2004 | 4 | ** Created: Tue Sep 14 15:20:58 2004 |
5 | ** by: The User Interface Compiler ($Id$) | 5 | ** by: The User Interface Compiler ($Id$) |
6 | ** | 6 | ** |
7 | ** WARNING! All changes made in this file will be lost! | 7 | ** WARNING! All changes made in this file will be lost! |
8 | ****************************************************************************/ | 8 | ****************************************************************************/ |
9 | 9 | ||
10 | #include "configwnd.h" | 10 | #include "configwnd.h" |
11 | 11 | ||
12 | #include <qvariant.h> | 12 | #include <qvariant.h> |
13 | #include <qpushbutton.h> | 13 | #include <qpushbutton.h> |
14 | #include <qtabwidget.h> | 14 | #include <qtabwidget.h> |
15 | #include <qwidget.h> | 15 | #include <qwidget.h> |
16 | #include <qcombobox.h> | 16 | #include <qcombobox.h> |
17 | #include <qlabel.h> | 17 | #include <qlabel.h> |
18 | #include <qlineedit.h> | 18 | #include <qlineedit.h> |
19 | #include <qcheckbox.h> | 19 | #include <qcheckbox.h> |
20 | #include <qspinbox.h> | 20 | #include <qspinbox.h> |
21 | #include <qlayout.h> | 21 | #include <qlayout.h> |
22 | #include <qtooltip.h> | 22 | #include <qtooltip.h> |
23 | #include <qwhatsthis.h> | 23 | #include <qwhatsthis.h> |
24 | 24 | ||
25 | /* | 25 | /* |
26 | * Constructs a configWnd as a child of 'parent', with the | 26 | * Constructs a configWnd as a child of 'parent', with the |
27 | * name 'name' and widget flags set to 'f'. | 27 | * name 'name' and widget flags set to 'f'. |
28 | * | 28 | * |
29 | * The dialog will by default be modeless, unless you set 'modal' to | 29 | * The dialog will by default be modeless, unless you set 'modal' to |
30 | * TRUE to construct a modal dialog. | 30 | * TRUE to construct a modal dialog. |
31 | */ | 31 | */ |
32 | configWnd::configWnd( QWidget* parent, const char* name, bool modal, WFlags fl ) | 32 | configWnd::configWnd( QWidget* parent, const char* name, bool modal, WFlags fl ) |
33 | : QDialog( parent, name, modal, fl ) | 33 | : QDialog( parent, name, modal, fl ) |
34 | { | 34 | { |
35 | if ( !name ) | 35 | if ( !name ) |
36 | setName( "configWnd" ); | 36 | setName( "configWnd" ); |
37 | 37 | ||
38 | okButton = new QPushButton( this, "okButton" ); | 38 | okButton = new QPushButton( this, "okButton" ); |
39 | okButton->setGeometry( QRect( 10, 280, 107, 27 ) ); | 39 | okButton->setGeometry( QRect( 10, 280, 107, 27 ) ); |
40 | 40 | ||
41 | cancelButton = new QPushButton( this, "cancelButton" ); | 41 | cancelButton = new QPushButton( this, "cancelButton" ); |
42 | cancelButton->setGeometry( QRect( 370, 280, 107, 27 ) ); | 42 | cancelButton->setGeometry( QRect( 370, 280, 107, 27 ) ); |
43 | 43 | ||
44 | tabWidget2 = new QTabWidget( this, "tabWidget2" ); | 44 | tabWidget2 = new QTabWidget( this, "tabWidget2" ); |
45 | tabWidget2->setGeometry( QRect( 10, 10, 470, 260 ) ); | 45 | tabWidget2->setGeometry( QRect( 10, 10, 470, 260 ) ); |
46 | 46 | ||
47 | ////////////////////////////// | ||
47 | tab = new QWidget( tabWidget2, "tab" ); | 48 | tab = new QWidget( tabWidget2, "tab" ); |
48 | 49 | ||
49 | windowStyleComboBox = new QComboBox( FALSE, tab, "windowStyleComboBox" ); | 50 | windowStyleComboBox = new QComboBox( FALSE, tab, "windowStyleComboBox" ); |
50 | windowStyleComboBox->setGeometry( QRect( 220, 180, 210, 28 ) ); | 51 | windowStyleComboBox->setGeometry( QRect( 220, 180, 210, 28 ) ); |
51 | 52 | ||
52 | textLabel1_5 = new QLabel( tab, "textLabel1_5" ); | 53 | textLabel1_5 = new QLabel( tab, "textLabel1_5" ); |
53 | textLabel1_5->setGeometry( QRect( 30, 180, 180, 20 ) ); | 54 | textLabel1_5->setGeometry( QRect( 30, 180, 180, 20 ) ); |
54 | textLabel1_5->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); | 55 | textLabel1_5->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); |
55 | 56 | ||
56 | textLabel1_4 = new QLabel( tab, "textLabel1_4" ); | 57 | textLabel1_4 = new QLabel( tab, "textLabel1_4" ); |
57 | textLabel1_4->setGeometry( QRect( 30, 40, 400, 20 ) ); | 58 | textLabel1_4->setGeometry( QRect( 30, 40, 400, 20 ) ); |
58 | 59 | ||
59 | selEntrFontButton = new QPushButton( tab, "selEntrFontButton" ); | 60 | selEntrFontButton = new QPushButton( tab, "selEntrFontButton" ); |
60 | selEntrFontButton->setGeometry( QRect( 30, 90, 160, 27 ) ); | 61 | selEntrFontButton->setGeometry( QRect( 30, 90, 160, 27 ) ); |
61 | 62 | ||
62 | currEntrFont = new QLabel( tab, "currEntrFont" ); | 63 | currEntrFont = new QLabel( tab, "currEntrFont" ); |
63 | currEntrFont->setGeometry( QRect( 30, 70, 230, 20 ) ); | 64 | currEntrFont->setGeometry( QRect( 30, 70, 230, 20 ) ); |
64 | tabWidget2->insertTab( tab, QString("") ); | 65 | tabWidget2->insertTab( tab, QString("") ); |
65 | 66 | ////////////////////////////////////// | |
66 | TabPage = new QWidget( tabWidget2, "TabPage" ); | 67 | TabPage = new QWidget( tabWidget2, "TabPage" ); |
67 | 68 | ||
68 | compressionComboBox = new QComboBox( FALSE, TabPage, "compressionComboBox" ); | 69 | compressionComboBox = new QComboBox( FALSE, TabPage, "compressionComboBox" ); |
69 | compressionComboBox->setGeometry( QRect( 290, 50, 150, 28 ) ); | 70 | compressionComboBox->setGeometry( QRect( 290, 50, 150, 28 ) ); |
70 | 71 | ||
71 | textLabel1_6 = new QLabel( TabPage, "textLabel1_6" ); | 72 | textLabel1_6 = new QLabel( TabPage, "textLabel1_6" ); |
72 | textLabel1_6->setGeometry( QRect( 10, 50, 270, 20 ) ); | 73 | textLabel1_6->setGeometry( QRect( 10, 50, 270, 20 ) ); |
73 | textLabel1_6->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); | 74 | textLabel1_6->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); |
74 | 75 | ||
75 | textLabel1_8 = new QLabel( TabPage, "textLabel1_8" ); | 76 | textLabel1_8 = new QLabel( TabPage, "textLabel1_8" ); |
76 | textLabel1_8->setGeometry( QRect( 10, 90, 270, 20 ) ); | 77 | textLabel1_8->setGeometry( QRect( 10, 90, 270, 20 ) ); |
77 | textLabel1_8->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); | 78 | textLabel1_8->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); |
78 | 79 | ||
79 | permissionLineEdit = new QLineEdit( TabPage, "permissionLineEdit" ); | 80 | permissionLineEdit = new QLineEdit( TabPage, "permissionLineEdit" ); |
80 | permissionLineEdit->setGeometry( QRect( 290, 90, 142, 27 ) ); | 81 | permissionLineEdit->setGeometry( QRect( 290, 90, 142, 27 ) ); |
81 | permissionLineEdit->setMaxLength( 3 ); | 82 | permissionLineEdit->setMaxLength( 3 ); |
82 | 83 | ||
83 | fileBackupCheckBox = new QCheckBox( TabPage, "fileBackupCheckBox" ); | 84 | fileBackupCheckBox = new QCheckBox( TabPage, "fileBackupCheckBox" ); |
84 | fileBackupCheckBox->setGeometry( QRect( 80, 140, 360, 23 ) ); | 85 | fileBackupCheckBox->setGeometry( QRect( 80, 140, 360, 23 ) ); |
85 | tabWidget2->insertTab( TabPage, QString("") ); | 86 | tabWidget2->insertTab( TabPage, QString("") ); |
86 | 87 | ////////////////////////////////////// | |
87 | tab_2 = new QWidget( tabWidget2, "tab_2" ); | 88 | tab_2 = new QWidget( tabWidget2, "tab_2" ); |
88 | 89 | ||
89 | pwTimeoutSpinBox = new QSpinBox( tab_2, "pwTimeoutSpinBox" ); | 90 | pwTimeoutSpinBox = new QSpinBox( tab_2, "pwTimeoutSpinBox" ); |
90 | pwTimeoutSpinBox->setGeometry( QRect( 390, 50, 55, 23 ) ); | 91 | pwTimeoutSpinBox->setGeometry( QRect( 390, 50, 55, 23 ) ); |
91 | 92 | ||
92 | textLabel1 = new QLabel( tab_2, "textLabel1" ); | 93 | textLabel1 = new QLabel( tab_2, "textLabel1" ); |
93 | textLabel1->setGeometry( QRect( 10, 20, 370, 80 ) ); | 94 | textLabel1->setGeometry( QRect( 10, 20, 370, 80 ) ); |
94 | textLabel1->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter ) ); | 95 | textLabel1->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter ) ); |
95 | 96 | ||
96 | textLabel1_7 = new QLabel( tab_2, "textLabel1_7" ); | 97 | textLabel1_7 = new QLabel( tab_2, "textLabel1_7" ); |
97 | textLabel1_7->setGeometry( QRect( 10, 110, 370, 80 ) ); | 98 | textLabel1_7->setGeometry( QRect( 10, 110, 370, 80 ) ); |
98 | textLabel1_7->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter ) ); | 99 | textLabel1_7->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter ) ); |
99 | 100 | ||
100 | lockTimeoutSpinBox = new QSpinBox( tab_2, "lockTimeoutSpinBox" ); | 101 | lockTimeoutSpinBox = new QSpinBox( tab_2, "lockTimeoutSpinBox" ); |
101 | lockTimeoutSpinBox->setGeometry( QRect( 390, 140, 55, 23 ) ); | 102 | lockTimeoutSpinBox->setGeometry( QRect( 390, 140, 55, 23 ) ); |
102 | 103 | ||
103 | autoDeepLockCheckBox = new QCheckBox( tab_2, "autoDeepLockCheckBox" ); | 104 | autoDeepLockCheckBox = new QCheckBox( tab_2, "autoDeepLockCheckBox" ); |
104 | autoDeepLockCheckBox->setGeometry( QRect( 60, 180, 380, 25 ) ); | 105 | autoDeepLockCheckBox->setGeometry( QRect( 60, 180, 380, 25 ) ); |
105 | tabWidget2->insertTab( tab_2, QString("") ); | 106 | tabWidget2->insertTab( tab_2, QString("") ); |
106 | 107 | /////////////////////////////////////////// | |
107 | tab_3 = new QWidget( tabWidget2, "tab_3" ); | 108 | tab_3 = new QWidget( tabWidget2, "tab_3" ); |
108 | 109 | ||
109 | textLabel1_3 = new QLabel( tab_3, "textLabel1_3" ); | 110 | textLabel1_3 = new QLabel( tab_3, "textLabel1_3" ); |
110 | textLabel1_3->setGeometry( QRect( 30, 30, 400, 20 ) ); | 111 | textLabel1_3->setGeometry( QRect( 30, 30, 400, 20 ) ); |
111 | 112 | ||
112 | autoStartLineEdit = new QLineEdit( tab_3, "autoStartLineEdit" ); | 113 | autoStartLineEdit = new QLineEdit( tab_3, "autoStartLineEdit" ); |
113 | autoStartLineEdit->setGeometry( QRect( 30, 50, 360, 20 ) ); | 114 | autoStartLineEdit->setGeometry( QRect( 30, 50, 360, 20 ) ); |
114 | 115 | ||
115 | browseAutoStButton = new QPushButton( tab_3, "browseAutoStButton" ); | 116 | browseAutoStButton = new QPushButton( tab_3, "browseAutoStButton" ); |
116 | browseAutoStButton->setGeometry( QRect( 400, 50, 30, 20 ) ); | 117 | browseAutoStButton->setGeometry( QRect( 400, 50, 30, 20 ) ); |
117 | 118 | ||
118 | autostartDeeplockedCheckBox = new QCheckBox( tab_3, "autostartDeeplockedCheckBox" ); | 119 | autostartDeeplockedCheckBox = new QCheckBox( tab_3, "autostartDeeplockedCheckBox" ); |
119 | autostartDeeplockedCheckBox->setGeometry( QRect( 40, 80, 390, 25 ) ); | 120 | autostartDeeplockedCheckBox->setGeometry( QRect( 40, 80, 390, 25 ) ); |
120 | tabWidget2->insertTab( tab_3, QString("") ); | 121 | tabWidget2->insertTab( tab_3, QString("") ); |
121 | 122 | //////////////////////////////////////////// | |
122 | tab_4 = new QWidget( tabWidget2, "tab_4" ); | 123 | tab_4 = new QWidget( tabWidget2, "tab_4" ); |
123 | 124 | ||
124 | textLabel2 = new QLabel( tab_4, "textLabel2" ); | 125 | textLabel2 = new QLabel( tab_4, "textLabel2" ); |
125 | textLabel2->setGeometry( QRect( 20, 40, 280, 20 ) ); | 126 | textLabel2->setGeometry( QRect( 20, 40, 280, 20 ) ); |
126 | textLabel2->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); | 127 | textLabel2->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); |
127 | 128 | ||
128 | browserLineEdit = new QLineEdit( tab_4, "browserLineEdit" ); | 129 | browserLineEdit = new QLineEdit( tab_4, "browserLineEdit" ); |
129 | browserLineEdit->setGeometry( QRect( 310, 40, 130, 27 ) ); | 130 | browserLineEdit->setGeometry( QRect( 310, 40, 130, 27 ) ); |
130 | 131 | ||
131 | xtermLineEdit = new QLineEdit( tab_4, "xtermLineEdit" ); | 132 | xtermLineEdit = new QLineEdit( tab_4, "xtermLineEdit" ); |
132 | xtermLineEdit->setGeometry( QRect( 310, 100, 130, 27 ) ); | 133 | xtermLineEdit->setGeometry( QRect( 310, 100, 130, 27 ) ); |
133 | 134 | ||
134 | textLabel3 = new QLabel( tab_4, "textLabel3" ); | 135 | textLabel3 = new QLabel( tab_4, "textLabel3" ); |
135 | textLabel3->setGeometry( QRect( 20, 100, 280, 20 ) ); | 136 | textLabel3->setGeometry( QRect( 20, 100, 280, 20 ) ); |
136 | textLabel3->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); | 137 | textLabel3->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); |
137 | tabWidget2->insertTab( tab_4, QString("") ); | 138 | tabWidget2->insertTab( tab_4, QString("") ); |
138 | 139 | /////////////////////////////////////////////// | |
139 | tab_5 = new QWidget( tabWidget2, "tab_5" ); | 140 | tab_5 = new QWidget( tabWidget2, "tab_5" ); |
140 | 141 | ||
141 | trayCheckBox = new QCheckBox( tab_5, "trayCheckBox" ); | 142 | trayCheckBox = new QCheckBox( tab_5, "trayCheckBox" ); |
142 | trayCheckBox->setGeometry( QRect( 30, 30, 400, 20 ) ); | 143 | trayCheckBox->setGeometry( QRect( 30, 30, 400, 20 ) ); |
143 | 144 | ||
144 | openUnlockedCheckBox = new QCheckBox( tab_5, "openUnlockedCheckBox" ); | 145 | openUnlockedCheckBox = new QCheckBox( tab_5, "openUnlockedCheckBox" ); |
145 | openUnlockedCheckBox->setGeometry( QRect( 30, 80, 400, 20 ) ); | 146 | openUnlockedCheckBox->setGeometry( QRect( 30, 80, 400, 20 ) ); |
146 | 147 | ||
147 | autoMinimizeCheckBox = new QCheckBox( tab_5, "autoMinimizeCheckBox" ); | 148 | autoMinimizeCheckBox = new QCheckBox( tab_5, "autoMinimizeCheckBox" ); |
148 | autoMinimizeCheckBox->setEnabled( FALSE ); | 149 | autoMinimizeCheckBox->setEnabled( FALSE ); |
149 | autoMinimizeCheckBox->setGeometry( QRect( 50, 50, 380, 25 ) ); | 150 | autoMinimizeCheckBox->setGeometry( QRect( 50, 50, 380, 25 ) ); |
150 | 151 | ||
151 | minimizeLockComboBox = new QComboBox( FALSE, tab_5, "minimizeLockComboBox" ); | 152 | minimizeLockComboBox = new QComboBox( FALSE, tab_5, "minimizeLockComboBox" ); |
152 | minimizeLockComboBox->setGeometry( QRect( 310, 170, 120, 27 ) ); | 153 | minimizeLockComboBox->setGeometry( QRect( 310, 170, 120, 27 ) ); |
153 | 154 | ||
154 | textLabel1_9 = new QLabel( tab_5, "textLabel1_9" ); | 155 | textLabel1_9 = new QLabel( tab_5, "textLabel1_9" ); |
155 | textLabel1_9->setGeometry( QRect( 30, 180, 270, 20 ) ); | 156 | textLabel1_9->setGeometry( QRect( 30, 180, 270, 20 ) ); |
156 | textLabel1_9->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); | 157 | textLabel1_9->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); |
157 | 158 | ||
158 | kwalletEmuCheckBox = new QCheckBox( tab_5, "kwalletEmuCheckBox" ); | 159 | kwalletEmuCheckBox = new QCheckBox( tab_5, "kwalletEmuCheckBox" ); |
159 | kwalletEmuCheckBox->setGeometry( QRect( 30, 110, 400, 25 ) ); | 160 | kwalletEmuCheckBox->setGeometry( QRect( 30, 110, 400, 25 ) ); |
160 | 161 | ||
161 | wndCloseCheckBox = new QCheckBox( tab_5, "wndCloseCheckBox" ); | 162 | wndCloseCheckBox = new QCheckBox( tab_5, "wndCloseCheckBox" ); |
162 | wndCloseCheckBox->setGeometry( QRect( 30, 140, 430, 24 ) ); | 163 | wndCloseCheckBox->setGeometry( QRect( 30, 140, 430, 24 ) ); |
163 | tabWidget2->insertTab( tab_5, QString("") ); | 164 | tabWidget2->insertTab( tab_5, QString("") ); |
164 | languageChange(); | 165 | languageChange(); |
165 | resize( QSize(490, 318).expandedTo(minimumSizeHint()) ); | 166 | resize( QSize(490, 318).expandedTo(minimumSizeHint()) ); |
166 | clearWState( WState_Polished ); | 167 | clearWState( WState_Polished ); |
167 | 168 | ||
168 | // signals and slots connections | 169 | // signals and slots connections |
169 | connect( okButton, SIGNAL( clicked() ), this, SLOT( okButton_slot() ) ); | 170 | connect( okButton, SIGNAL( clicked() ), this, SLOT( okButton_slot() ) ); |
170 | connect( cancelButton, SIGNAL( clicked() ), this, SLOT( cancelButton_slot() ) ); | 171 | connect( cancelButton, SIGNAL( clicked() ), this, SLOT( cancelButton_slot() ) ); |
171 | connect( browseAutoStButton, SIGNAL( clicked() ), this, SLOT( browseAutoStButton_slot() ) ); | 172 | connect( browseAutoStButton, SIGNAL( clicked() ), this, SLOT( browseAutoStButton_slot() ) ); |
172 | connect( selEntrFontButton, SIGNAL( clicked() ), this, SLOT( selEntrFontButton_slot() ) ); | 173 | connect( selEntrFontButton, SIGNAL( clicked() ), this, SLOT( selEntrFontButton_slot() ) ); |
173 | connect( trayCheckBox, SIGNAL( toggled(bool) ), autoMinimizeCheckBox, SLOT( setEnabled(bool) ) ); | 174 | connect( trayCheckBox, SIGNAL( toggled(bool) ), autoMinimizeCheckBox, SLOT( setEnabled(bool) ) ); |
174 | 175 | ||
175 | // tab order | 176 | // tab order |
176 | setTabOrder( pwTimeoutSpinBox, trayCheckBox ); | 177 | setTabOrder( pwTimeoutSpinBox, trayCheckBox ); |
177 | setTabOrder( trayCheckBox, okButton ); | 178 | setTabOrder( trayCheckBox, okButton ); |
178 | setTabOrder( okButton, cancelButton ); | 179 | setTabOrder( okButton, cancelButton ); |
179 | } | 180 | } |
180 | 181 | ||
181 | /* | 182 | /* |
182 | * Destroys the object and frees any allocated resources | 183 | * Destroys the object and frees any allocated resources |
183 | */ | 184 | */ |
184 | configWnd::~configWnd() | 185 | configWnd::~configWnd() |
185 | { | 186 | { |
186 | // no need to delete child widgets, Qt does it all for us | 187 | // no need to delete child widgets, Qt does it all for us |
187 | } | 188 | } |
188 | 189 | ||
189 | /* | 190 | /* |
190 | * Sets the strings of the subwidgets using the current | 191 | * Sets the strings of the subwidgets using the current |
191 | * language. | 192 | * language. |
192 | */ | 193 | */ |
193 | void configWnd::languageChange() | 194 | void configWnd::languageChange() |
194 | { | 195 | { |
195 | setCaption( tr( "PwManager Configuration" ) ); | 196 | setCaption( tr( "PwManager Configuration" ) ); |
196 | okButton->setText( tr( "&OK" ) ); | 197 | okButton->setText( tr( "&OK" ) ); |
197 | //US ENH okButton->setAccel( QKeySequence( tr( "Alt+O" ) ) ); | 198 | //US ENH okButton->setAccel( QKeySequence( tr( "Alt+O" ) ) ); |
198 | cancelButton->setText( tr( "&Cancel" ) ); | 199 | cancelButton->setText( tr( "&Cancel" ) ); |
199 | //US ENH cancelButton->setAccel( QKeySequence( tr( "Alt+C" ) ) ); | 200 | //US ENH cancelButton->setAccel( QKeySequence( tr( "Alt+C" ) ) ); |
200 | windowStyleComboBox->clear(); | 201 | windowStyleComboBox->clear(); |
201 | windowStyleComboBox->insertItem( tr( "Category on top" ) ); | 202 | windowStyleComboBox->insertItem( tr( "Category on top" ) ); |
202 | windowStyleComboBox->insertItem( tr( "Category-list left" ) ); | 203 | windowStyleComboBox->insertItem( tr( "Category-list left" ) ); |
203 | textLabel1_5->setText( tr( "Window-style:" ) ); | 204 | textLabel1_5->setText( tr( "Window-style:" ) ); |
204 | textLabel1_4->setText( tr( "Font for the password entries:" ) ); | 205 | textLabel1_4->setText( tr( "Font for the password entries:" ) ); |
205 | selEntrFontButton->setText( tr( "select Font" ) ); | 206 | selEntrFontButton->setText( tr( "select Font" ) ); |
206 | currEntrFont->setText( QString::null ); | 207 | currEntrFont->setText( QString::null ); |
207 | tabWidget2->changeTab( tab, tr( "Look && feel" ) ); | 208 | tabWidget2->changeTab( tab, tr( "Look && feel" ) ); |
208 | compressionComboBox->clear(); | 209 | compressionComboBox->clear(); |
209 | compressionComboBox->insertItem( tr( "none" ) ); | 210 | compressionComboBox->insertItem( tr( "none" ) ); |
210 | compressionComboBox->insertItem( tr( "gzip" ) ); | 211 | compressionComboBox->insertItem( tr( "gzip" ) ); |
211 | compressionComboBox->insertItem( tr( "bzip2" ) ); | 212 | compressionComboBox->insertItem( tr( "bzip2" ) ); |
212 | textLabel1_6->setText( tr( "*.pwm file compression:" ) ); | 213 | textLabel1_6->setText( tr( "*.pwm file compression:" ) ); |
213 | textLabel1_8->setText( tr( "permissions:" ) ); | 214 | textLabel1_8->setText( tr( "permissions:" ) ); |
214 | fileBackupCheckBox->setText( tr( "Make file backup before saving" ) ); | 215 | fileBackupCheckBox->setText( tr( "Make file backup before saving" ) ); |
215 | tabWidget2->changeTab( TabPage, tr( "File" ) ); | 216 | tabWidget2->changeTab( TabPage, tr( "File" ) ); |
216 | textLabel1->setText( tr( "Password timeout (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]:" ) ); | 217 | textLabel1->setText( tr( "Password timeout (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]:" ) ); |
217 | textLabel1_7->setText( tr( "Auto-lock timeout (auto lock document after this amount of seconds) [set to 0 to disable]:" ) ); | 218 | textLabel1_7->setText( tr( "Auto-lock timeout (auto lock document after this amount of seconds) [set to 0 to disable]:" ) ); |
218 | autoDeepLockCheckBox->setText( tr( "deep-lock on autolock" ) ); | 219 | autoDeepLockCheckBox->setText( tr( "deep-lock on autolock" ) ); |
219 | tabWidget2->changeTab( tab_2, tr( "Timeout" ) ); | 220 | tabWidget2->changeTab( tab_2, tr( "Timeout" ) ); |
220 | textLabel1_3->setText( tr( "Open this file automatically on startup:" ) ); | 221 | textLabel1_3->setText( tr( "Open this file automatically on startup:" ) ); |
221 | browseAutoStButton->setText( tr( "..." ) ); | 222 | browseAutoStButton->setText( tr( "..." ) ); |
222 | autostartDeeplockedCheckBox->setText( tr( "open deeplocked" ) ); | 223 | autostartDeeplockedCheckBox->setText( tr( "open deeplocked" ) ); |
223 | tabWidget2->changeTab( tab_3, tr( "Autostart" ) ); | 224 | tabWidget2->changeTab( tab_3, tr( "Autostart" ) ); |
224 | textLabel2->setText( tr( "Favourite browser:" ) ); | 225 | textLabel2->setText( tr( "Favourite browser:" ) ); |
225 | textLabel3->setText( tr( "Favourite X-terminal:" ) ); | 226 | textLabel3->setText( tr( "Favourite X-terminal:" ) ); |
226 | tabWidget2->changeTab( tab_4, tr( "External apps" ) ); | 227 | tabWidget2->changeTab( tab_4, tr( "External apps" ) ); |
227 | trayCheckBox->setText( tr( "Show icon in system-tray" ) ); | 228 | trayCheckBox->setText( tr( "Show icon in system-tray" ) ); |
228 | openUnlockedCheckBox->setText( tr( "Open document with passwords unlocked" ) ); | 229 | openUnlockedCheckBox->setText( tr( "Open document with passwords unlocked" ) ); |
229 | autoMinimizeCheckBox->setText( tr( "auto-minimize to tray on startup" ) ); | 230 | autoMinimizeCheckBox->setText( tr( "auto-minimize to tray on startup" ) ); |
230 | minimizeLockComboBox->clear(); | 231 | minimizeLockComboBox->clear(); |
231 | minimizeLockComboBox->insertItem( tr( "don't lock" ) ); | 232 | minimizeLockComboBox->insertItem( tr( "don't lock" ) ); |
232 | minimizeLockComboBox->insertItem( tr( "normal lock" ) ); | 233 | minimizeLockComboBox->insertItem( tr( "normal lock" ) ); |
233 | minimizeLockComboBox->insertItem( tr( "deep-lock" ) ); | 234 | minimizeLockComboBox->insertItem( tr( "deep-lock" ) ); |
234 | textLabel1_9->setText( tr( "auto-lock on minimize:" ) ); | 235 | textLabel1_9->setText( tr( "auto-lock on minimize:" ) ); |
235 | kwalletEmuCheckBox->setText( tr( "KWallet emulation" ) ); | 236 | kwalletEmuCheckBox->setText( tr( "KWallet emulation" ) ); |
236 | wndCloseCheckBox->setText( tr( "Do not minimize windows into tray. (Close the window)" ) ); | 237 | wndCloseCheckBox->setText( tr( "Do not minimize windows into tray. (Close the window)" ) ); |
237 | tabWidget2->changeTab( tab_5, tr( "Miscellaneous" ) ); | 238 | tabWidget2->changeTab( tab_5, tr( "Miscellaneous" ) ); |
238 | } | 239 | } |
239 | 240 | ||
240 | void configWnd::okButton_slot() | 241 | void configWnd::okButton_slot() |
241 | { | 242 | { |
242 | qWarning( "configWnd::okButton_slot(): Not implemented yet" ); | 243 | qWarning( "configWnd::okButton_slot(): Not implemented yet" ); |
243 | } | 244 | } |
244 | 245 | ||
245 | void configWnd::cancelButton_slot() | 246 | void configWnd::cancelButton_slot() |
246 | { | 247 | { |
247 | qWarning( "configWnd::cancelButton_slot(): Not implemented yet" ); | 248 | qWarning( "configWnd::cancelButton_slot(): Not implemented yet" ); |
248 | } | 249 | } |
249 | 250 | ||
250 | void configWnd::browseBgButton_slot() | 251 | void configWnd::browseBgButton_slot() |
251 | { | 252 | { |
252 | qWarning( "configWnd::browseBgButton_slot(): Not implemented yet" ); | 253 | qWarning( "configWnd::browseBgButton_slot(): Not implemented yet" ); |
253 | } | 254 | } |
254 | 255 | ||
255 | void configWnd::browseAutoStButton_slot() | 256 | void configWnd::browseAutoStButton_slot() |
256 | { | 257 | { |
257 | qWarning( "configWnd::browseAutoStButton_slot(): Not implemented yet" ); | 258 | qWarning( "configWnd::browseAutoStButton_slot(): Not implemented yet" ); |
258 | } | 259 | } |
259 | 260 | ||
260 | void configWnd::selEntrFontButton_slot() | 261 | void configWnd::selEntrFontButton_slot() |
261 | { | 262 | { |
262 | qWarning( "configWnd::selEntrFontButton_slot(): Not implemented yet" ); | 263 | qWarning( "configWnd::selEntrFontButton_slot(): Not implemented yet" ); |
263 | } | 264 | } |
264 | 265 | ||
diff --git a/pwmanager/pwmanager/pwm.cpp b/pwmanager/pwmanager/pwm.cpp index e5579f8..08fcb25 100644 --- a/pwmanager/pwmanager/pwm.cpp +++ b/pwmanager/pwmanager/pwm.cpp | |||
@@ -1,245 +1,250 @@ | |||
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 | #ifndef PWM_EMBEDDED | 27 | #ifndef PWM_EMBEDDED |
28 | #include <kmenubar.h> | 28 | #include <kmenubar.h> |
29 | #include <kstatusbar.h> | 29 | #include <kstatusbar.h> |
30 | #include <dcopclient.h> | 30 | #include <dcopclient.h> |
31 | #include "configwndimpl.h" | ||
32 | #include "configuration.h" | ||
31 | #else | 33 | #else |
32 | #include <qmenubar.h> | 34 | #include <qmenubar.h> |
33 | #include <qmessagebox.h> | 35 | #include <qmessagebox.h> |
36 | #include <pwmprefs.h> | ||
37 | #include <kpimglobalprefs.h> | ||
38 | #include <kcmconfigs/kcmpwmconfig.h> | ||
39 | #include <kcmconfigs/kcmkdepimconfig.h> | ||
40 | #include <kcmultidialog.h> | ||
34 | #endif | 41 | #endif |
35 | 42 | ||
36 | #include <qpixmap.h> | 43 | #include <qpixmap.h> |
37 | #include <qcheckbox.h> | 44 | #include <qcheckbox.h> |
38 | #include <qspinbox.h> | 45 | #include <qspinbox.h> |
39 | #include <qlineedit.h> | 46 | #include <qlineedit.h> |
40 | #include <qfileinfo.h> | 47 | #include <qfileinfo.h> |
41 | #include <qclipboard.h> | 48 | #include <qclipboard.h> |
42 | 49 | ||
43 | 50 | ||
44 | #include <stdio.h> | 51 | #include <stdio.h> |
45 | 52 | ||
46 | #include "pwm.h" | 53 | #include "pwm.h" |
47 | #include "pwminit.h" | 54 | #include "pwminit.h" |
48 | #include "configwndimpl.h" | ||
49 | #include "pwmprint.h" | 55 | #include "pwmprint.h" |
50 | #include "addentrywndimpl.h" | 56 | #include "addentrywndimpl.h" |
51 | #include "globalstuff.h" | 57 | #include "globalstuff.h" |
52 | #include "findwndimpl.h" | 58 | #include "findwndimpl.h" |
53 | #include "configuration.h" | ||
54 | 59 | ||
55 | #ifdef CONFIG_KWALLETIF | 60 | #ifdef CONFIG_KWALLETIF |
56 | # include "kwalletif.h" | 61 | # include "kwalletif.h" |
57 | # include "kwalletemu.h" | 62 | # include "kwalletemu.h" |
58 | #endif | 63 | #endif |
59 | #ifdef CONFIG_KEYCARD | 64 | #ifdef CONFIG_KEYCARD |
60 | # include "pwmkeycard.h" | 65 | # include "pwmkeycard.h" |
61 | #endif | 66 | #endif |
62 | 67 | ||
63 | 68 | ||
64 | #define DEFAULT_SIZE (QSize(700, 400)) | 69 | #define DEFAULT_SIZE (QSize(700, 400)) |
65 | 70 | ||
66 | // Button IDs for "file" popup menu | 71 | // Button IDs for "file" popup menu |
67 | enum { | 72 | enum { |
68 | BUTTON_POPUP_FILE_NEW = 0, | 73 | BUTTON_POPUP_FILE_NEW = 0, |
69 | BUTTON_POPUP_FILE_OPEN, | 74 | BUTTON_POPUP_FILE_OPEN, |
70 | BUTTON_POPUP_FILE_CLOSE, | 75 | BUTTON_POPUP_FILE_CLOSE, |
71 | BUTTON_POPUP_FILE_SAVE, | 76 | BUTTON_POPUP_FILE_SAVE, |
72 | BUTTON_POPUP_FILE_SAVEAS, | 77 | BUTTON_POPUP_FILE_SAVEAS, |
73 | BUTTON_POPUP_FILE_EXPORT, | 78 | BUTTON_POPUP_FILE_EXPORT, |
74 | BUTTON_POPUP_FILE_IMPORT, | 79 | BUTTON_POPUP_FILE_IMPORT, |
75 | BUTTON_POPUP_FILE_PRINT, | 80 | BUTTON_POPUP_FILE_PRINT, |
76 | BUTTON_POPUP_FILE_QUIT | 81 | BUTTON_POPUP_FILE_QUIT |
77 | }; | 82 | }; |
78 | // Button IDs for "manage" popup menu | 83 | // Button IDs for "manage" popup menu |
79 | enum { | 84 | enum { |
80 | BUTTON_POPUP_MANAGE_ADD = 0, | 85 | BUTTON_POPUP_MANAGE_ADD = 0, |
81 | BUTTON_POPUP_MANAGE_EDIT, | 86 | BUTTON_POPUP_MANAGE_EDIT, |
82 | BUTTON_POPUP_MANAGE_DEL, | 87 | BUTTON_POPUP_MANAGE_DEL, |
83 | BUTTON_POPUP_MANAGE_CHANGEMP | 88 | BUTTON_POPUP_MANAGE_CHANGEMP |
84 | }; | 89 | }; |
85 | // Button IDs for chipcard popup menu | 90 | // Button IDs for chipcard popup menu |
86 | enum { | 91 | enum { |
87 | #ifdef CONFIG_KEYCARD | 92 | #ifdef CONFIG_KEYCARD |
88 | BUTTON_POPUP_CHIPCARD_GENNEW = 0, | 93 | BUTTON_POPUP_CHIPCARD_GENNEW = 0, |
89 | BUTTON_POPUP_CHIPCARD_DEL, | 94 | BUTTON_POPUP_CHIPCARD_DEL, |
90 | BUTTON_POPUP_CHIPCARD_READID, | 95 | BUTTON_POPUP_CHIPCARD_READID, |
91 | BUTTON_POPUP_CHIPCARD_SAVEBACKUP, | 96 | BUTTON_POPUP_CHIPCARD_SAVEBACKUP, |
92 | BUTTON_POPUP_CHIPCARD_REPLAYBACKUP | 97 | BUTTON_POPUP_CHIPCARD_REPLAYBACKUP |
93 | #else // CONFIG_KEYCARD | 98 | #else // CONFIG_KEYCARD |
94 | BUTTON_POPUP_CHIPCARD_NO = 0 | 99 | BUTTON_POPUP_CHIPCARD_NO = 0 |
95 | #endif // CONFIG_KEYCARD | 100 | #endif // CONFIG_KEYCARD |
96 | }; | 101 | }; |
97 | // Button IDs for "view" popup menu | 102 | // Button IDs for "view" popup menu |
98 | enum { | 103 | enum { |
99 | BUTTON_POPUP_VIEW_FIND = 0, | 104 | BUTTON_POPUP_VIEW_FIND = 0, |
100 | BUTTON_POPUP_VIEW_LOCK, | 105 | BUTTON_POPUP_VIEW_LOCK, |
101 | BUTTON_POPUP_VIEW_DEEPLOCK, | 106 | BUTTON_POPUP_VIEW_DEEPLOCK, |
102 | BUTTON_POPUP_VIEW_UNLOCK | 107 | BUTTON_POPUP_VIEW_UNLOCK |
103 | }; | 108 | }; |
104 | // Button IDs for "options" popup menu | 109 | // Button IDs for "options" popup menu |
105 | enum { | 110 | enum { |
106 | BUTTON_POPUP_OPTIONS_CONFIG = 0 | 111 | BUTTON_POPUP_OPTIONS_CONFIG = 0 |
107 | }; | 112 | }; |
108 | // Button IDs for "export" popup menu (in "file" popup menu) | 113 | // Button IDs for "export" popup menu (in "file" popup menu) |
109 | enum { | 114 | enum { |
110 | BUTTON_POPUP_EXPORT_TEXT = 0, | 115 | BUTTON_POPUP_EXPORT_TEXT = 0, |
111 | BUTTON_POPUP_EXPORT_GPASMAN | 116 | BUTTON_POPUP_EXPORT_GPASMAN |
112 | #ifdef CONFIG_KWALLETIF | 117 | #ifdef CONFIG_KWALLETIF |
113 | ,BUTTON_POPUP_EXPORT_KWALLET | 118 | ,BUTTON_POPUP_EXPORT_KWALLET |
114 | #endif | 119 | #endif |
115 | }; | 120 | }; |
116 | // Button IDs for "import" popup menu (in "file" popup menu) | 121 | // Button IDs for "import" popup menu (in "file" popup menu) |
117 | enum { | 122 | enum { |
118 | BUTTON_POPUP_IMPORT_TEXT = 0, | 123 | BUTTON_POPUP_IMPORT_TEXT = 0, |
119 | BUTTON_POPUP_IMPORT_GPASMAN | 124 | BUTTON_POPUP_IMPORT_GPASMAN |
120 | #ifdef CONFIG_KWALLETIF | 125 | #ifdef CONFIG_KWALLETIF |
121 | ,BUTTON_POPUP_IMPORT_KWALLET | 126 | ,BUTTON_POPUP_IMPORT_KWALLET |
122 | #endif | 127 | #endif |
123 | }; | 128 | }; |
124 | 129 | ||
125 | #ifdef PWM_EMBEDDED | 130 | #ifdef PWM_EMBEDDED |
126 | // Button IDs for "help" popup menu | 131 | // Button IDs for "help" popup menu |
127 | enum { | 132 | enum { |
128 | BUTTON_POPUP_HELP_LICENSE = 0, | 133 | BUTTON_POPUP_HELP_LICENSE = 0, |
129 | BUTTON_POPUP_HELP_FAQ, | 134 | BUTTON_POPUP_HELP_FAQ, |
130 | BUTTON_POPUP_HELP_ABOUT | 135 | BUTTON_POPUP_HELP_ABOUT |
131 | }; | 136 | }; |
132 | #endif | 137 | #endif |
133 | 138 | ||
134 | // Button IDs for toolbar | 139 | // Button IDs for toolbar |
135 | enum { | 140 | enum { |
136 | BUTTON_TOOL_NEW = 0, | 141 | BUTTON_TOOL_NEW = 0, |
137 | BUTTON_TOOL_OPEN, | 142 | BUTTON_TOOL_OPEN, |
138 | BUTTON_TOOL_SAVE, | 143 | BUTTON_TOOL_SAVE, |
139 | BUTTON_TOOL_SAVEAS, | 144 | BUTTON_TOOL_SAVEAS, |
140 | BUTTON_TOOL_PRINT, | 145 | BUTTON_TOOL_PRINT, |
141 | BUTTON_TOOL_ADD, | 146 | BUTTON_TOOL_ADD, |
142 | BUTTON_TOOL_EDIT, | 147 | BUTTON_TOOL_EDIT, |
143 | BUTTON_TOOL_DEL, | 148 | BUTTON_TOOL_DEL, |
144 | BUTTON_TOOL_FIND, | 149 | BUTTON_TOOL_FIND, |
145 | BUTTON_TOOL_LOCK, | 150 | BUTTON_TOOL_LOCK, |
146 | BUTTON_TOOL_DEEPLOCK, | 151 | BUTTON_TOOL_DEEPLOCK, |
147 | BUTTON_TOOL_UNLOCK | 152 | BUTTON_TOOL_UNLOCK |
148 | }; | 153 | }; |
149 | 154 | ||
150 | 155 | ||
151 | PwM::PwM(PwMInit *_init, PwMDoc *doc, | 156 | PwM::PwM(PwMInit *_init, PwMDoc *doc, |
152 | bool virginity, | 157 | bool virginity, |
153 | QWidget *parent, const char *name) | 158 | QWidget *parent, const char *name) |
154 | : KMainWindow(parent, name) | 159 | : KMainWindow(parent, name) |
155 | , forceQuit (false) | 160 | , forceQuit (false) |
156 | , forceMinimizeToTray (false) | 161 | , forceMinimizeToTray (false) |
157 | { | 162 | { |
158 | init = _init; | 163 | init = _init; |
159 | connect(doc, SIGNAL(docClosed(PwMDoc *)), | 164 | connect(doc, SIGNAL(docClosed(PwMDoc *)), |
160 | this, SLOT(docClosed(PwMDoc *))); | 165 | this, SLOT(docClosed(PwMDoc *))); |
161 | initMenubar(); | 166 | initMenubar(); |
162 | initToolbar(); | 167 | initToolbar(); |
163 | initMetrics(); | 168 | initMetrics(); |
164 | setVirgin(virginity); | 169 | setVirgin(virginity); |
165 | setFocusPolicy(QWidget::WheelFocus); | 170 | setFocusPolicy(QWidget::WheelFocus); |
166 | #ifndef PWM_EMBEDDED | 171 | #ifndef PWM_EMBEDDED |
167 | statusBar()->show(); | 172 | statusBar()->show(); |
168 | #endif | 173 | #endif |
169 | view = makeNewListView(doc); | 174 | view = makeNewListView(doc); |
170 | setCentralWidget(view); | 175 | setCentralWidget(view); |
171 | updateCaption(); | 176 | updateCaption(); |
172 | showStatMsg(i18n("Ready.")); | 177 | showStatMsg(i18n("Ready.")); |
173 | } | 178 | } |
174 | 179 | ||
175 | PwM::~PwM() | 180 | PwM::~PwM() |
176 | { | 181 | { |
177 | disconnect(curDoc(), SIGNAL(docClosed(PwMDoc *)), | 182 | disconnect(curDoc(), SIGNAL(docClosed(PwMDoc *)), |
178 | this, SLOT(docClosed(PwMDoc *))); | 183 | this, SLOT(docClosed(PwMDoc *))); |
179 | conf()->confWndMainWndSize(size()); | 184 | conf()->confWndMainWndSize(size()); |
180 | emit closed(this); | 185 | emit closed(this); |
181 | delete view; | 186 | delete view; |
182 | } | 187 | } |
183 | 188 | ||
184 | void PwM::initMenubar() | 189 | void PwM::initMenubar() |
185 | { | 190 | { |
186 | KIconLoader* picons; | 191 | KIconLoader* picons; |
187 | #ifndef PWM_EMBEDDED | 192 | #ifndef PWM_EMBEDDED |
188 | KIconLoader icons; | 193 | KIconLoader icons; |
189 | picons = &icons; | 194 | picons = &icons; |
190 | #else | 195 | #else |
191 | picons = KGlobal::iconLoader(); | 196 | picons = KGlobal::iconLoader(); |
192 | #endif | 197 | #endif |
193 | filePopup = new KPopupMenu(this); | 198 | filePopup = new KPopupMenu(this); |
194 | importPopup = new KPopupMenu(filePopup); | 199 | importPopup = new KPopupMenu(filePopup); |
195 | exportPopup = new KPopupMenu(filePopup); | 200 | exportPopup = new KPopupMenu(filePopup); |
196 | managePopup = new KPopupMenu(this); | 201 | managePopup = new KPopupMenu(this); |
197 | #ifdef CONFIG_KEYCARD | 202 | #ifdef CONFIG_KEYCARD |
198 | chipcardPopup = new KPopupMenu(this); | 203 | chipcardPopup = new KPopupMenu(this); |
199 | #endif // CONFIG_KEYCARD | 204 | #endif // CONFIG_KEYCARD |
200 | viewPopup = new KPopupMenu(this); | 205 | viewPopup = new KPopupMenu(this); |
201 | optionsPopup = new KPopupMenu(this); | 206 | optionsPopup = new KPopupMenu(this); |
202 | 207 | ||
203 | // "file" popup menu | 208 | // "file" popup menu |
204 | filePopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), | 209 | filePopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), |
205 | i18n("&New"), this, | 210 | i18n("&New"), this, |
206 | SLOT(new_slot()), 0, BUTTON_POPUP_FILE_NEW); | 211 | SLOT(new_slot()), 0, BUTTON_POPUP_FILE_NEW); |
207 | filePopup->insertItem(QIconSet(picons->loadIcon("fileopen", KIcon::Small)), | 212 | filePopup->insertItem(QIconSet(picons->loadIcon("fileopen", KIcon::Small)), |
208 | i18n("&Open"), this, | 213 | i18n("&Open"), this, |
209 | SLOT(open_slot()), 0, BUTTON_POPUP_FILE_OPEN); | 214 | SLOT(open_slot()), 0, BUTTON_POPUP_FILE_OPEN); |
210 | filePopup->insertItem(QIconSet(picons->loadIcon("fileclose", KIcon::Small)), | 215 | filePopup->insertItem(QIconSet(picons->loadIcon("fileclose", KIcon::Small)), |
211 | i18n("&Close"), this, | 216 | i18n("&Close"), this, |
212 | SLOT(close_slot()), 0, BUTTON_POPUP_FILE_CLOSE); | 217 | SLOT(close_slot()), 0, BUTTON_POPUP_FILE_CLOSE); |
213 | filePopup->insertSeparator(); | 218 | filePopup->insertSeparator(); |
214 | filePopup->insertItem(QIconSet(picons->loadIcon("filesave", KIcon::Small)), | 219 | filePopup->insertItem(QIconSet(picons->loadIcon("filesave", KIcon::Small)), |
215 | i18n("&Save"), this, | 220 | i18n("&Save"), this, |
216 | SLOT(save_slot()), 0, BUTTON_POPUP_FILE_SAVE); | 221 | SLOT(save_slot()), 0, BUTTON_POPUP_FILE_SAVE); |
217 | filePopup->insertItem(QIconSet(picons->loadIcon("filesaveas", KIcon::Small)), | 222 | filePopup->insertItem(QIconSet(picons->loadIcon("filesaveas", KIcon::Small)), |
218 | i18n("Save &as..."), | 223 | i18n("Save &as..."), |
219 | this, SLOT(saveAs_slot()), 0, | 224 | this, SLOT(saveAs_slot()), 0, |
220 | BUTTON_POPUP_FILE_SAVEAS); | 225 | BUTTON_POPUP_FILE_SAVEAS); |
221 | filePopup->insertSeparator(); | 226 | filePopup->insertSeparator(); |
222 | // "file/export" popup menu | 227 | // "file/export" popup menu |
223 | exportPopup->insertItem(i18n("&Text-file..."), this, | 228 | exportPopup->insertItem(i18n("&Text-file..."), this, |
224 | SLOT(exportToText()), 0, BUTTON_POPUP_EXPORT_TEXT); | 229 | SLOT(exportToText()), 0, BUTTON_POPUP_EXPORT_TEXT); |
225 | exportPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, | 230 | exportPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, |
226 | SLOT(exportToGpasman()), 0, BUTTON_POPUP_EXPORT_GPASMAN); | 231 | SLOT(exportToGpasman()), 0, BUTTON_POPUP_EXPORT_GPASMAN); |
227 | #ifdef CONFIG_KWALLETIF | 232 | #ifdef CONFIG_KWALLETIF |
228 | exportPopup->insertItem(i18n("&KWallet..."), this, | 233 | exportPopup->insertItem(i18n("&KWallet..."), this, |
229 | SLOT(exportToKWallet()), 0, BUTTON_POPUP_EXPORT_KWALLET); | 234 | SLOT(exportToKWallet()), 0, BUTTON_POPUP_EXPORT_KWALLET); |
230 | #endif | 235 | #endif |
231 | filePopup->insertItem(QIconSet(picons->loadIcon("fileexport", KIcon::Small)), | 236 | filePopup->insertItem(QIconSet(picons->loadIcon("fileexport", KIcon::Small)), |
232 | i18n("E&xport"), exportPopup, | 237 | i18n("E&xport"), exportPopup, |
233 | BUTTON_POPUP_FILE_EXPORT); | 238 | BUTTON_POPUP_FILE_EXPORT); |
234 | // "file/import" popup menu | 239 | // "file/import" popup menu |
235 | importPopup->insertItem(i18n("&Text-file..."), this, | 240 | importPopup->insertItem(i18n("&Text-file..."), this, |
236 | SLOT(importFromText()), 0, BUTTON_POPUP_IMPORT_TEXT); | 241 | SLOT(importFromText()), 0, BUTTON_POPUP_IMPORT_TEXT); |
237 | importPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, | 242 | importPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, |
238 | SLOT(importFromGpasman()), 0, BUTTON_POPUP_IMPORT_GPASMAN); | 243 | SLOT(importFromGpasman()), 0, BUTTON_POPUP_IMPORT_GPASMAN); |
239 | #ifdef CONFIG_KWALLETIF | 244 | #ifdef CONFIG_KWALLETIF |
240 | importPopup->insertItem(i18n("&KWallet..."), this, | 245 | importPopup->insertItem(i18n("&KWallet..."), this, |
241 | SLOT(importKWallet()), 0, BUTTON_POPUP_IMPORT_KWALLET); | 246 | SLOT(importKWallet()), 0, BUTTON_POPUP_IMPORT_KWALLET); |
242 | #endif | 247 | #endif |
243 | filePopup->insertItem(QIconSet(picons->loadIcon("fileimport", KIcon::Small)), | 248 | filePopup->insertItem(QIconSet(picons->loadIcon("fileimport", KIcon::Small)), |
244 | i18n("I&mport"), importPopup, | 249 | i18n("I&mport"), importPopup, |
245 | BUTTON_POPUP_FILE_IMPORT); | 250 | BUTTON_POPUP_FILE_IMPORT); |
@@ -562,427 +567,443 @@ void PwM::addPwd_slot(QString *pw, PwMDoc *_doc) | |||
562 | doc = curDoc(); | 567 | doc = curDoc(); |
563 | } | 568 | } |
564 | PWM_ASSERT(doc); | 569 | PWM_ASSERT(doc); |
565 | doc->timer()->getLock(DocTimer::id_autoLockTimer); | 570 | doc->timer()->getLock(DocTimer::id_autoLockTimer); |
566 | AddEntryWndImpl w; | 571 | AddEntryWndImpl w; |
567 | vector<string> catList; | 572 | vector<string> catList; |
568 | doc->getCategoryList(&catList); | 573 | doc->getCategoryList(&catList); |
569 | unsigned i, size = catList.size(); | 574 | unsigned i, size = catList.size(); |
570 | for (i = 0; i < size; ++i) { | 575 | for (i = 0; i < size; ++i) { |
571 | w.addCategory(catList[i].c_str()); | 576 | w.addCategory(catList[i].c_str()); |
572 | } | 577 | } |
573 | w.setCurrCategory(view->getCurrentCategory()); | 578 | w.setCurrCategory(view->getCurrentCategory()); |
574 | if (pw) | 579 | if (pw) |
575 | w.pwLineEdit->setText(*pw); | 580 | w.pwLineEdit->setText(*pw); |
576 | 581 | ||
577 | tryAgain: | 582 | tryAgain: |
578 | if (w.exec() == 1) | 583 | if (w.exec() == 1) |
579 | { | 584 | { |
580 | PwMDataItem d; | 585 | PwMDataItem d; |
581 | d.desc = w.getDescription().latin1(); | 586 | d.desc = w.getDescription().latin1(); |
582 | d.name = w.getUsername().latin1(); | 587 | d.name = w.getUsername().latin1(); |
583 | d.pw = w.getPassword().latin1(); | 588 | d.pw = w.getPassword().latin1(); |
584 | d.comment = w.getComment().latin1(); | 589 | d.comment = w.getComment().latin1(); |
585 | d.url = w.getUrl().latin1(); | 590 | d.url = w.getUrl().latin1(); |
586 | d.launcher = w.getLauncher().latin1(); | 591 | d.launcher = w.getLauncher().latin1(); |
587 | PwMerror ret = doc->addEntry(w.getCategory(), &d); | 592 | PwMerror ret = doc->addEntry(w.getCategory(), &d); |
588 | if (ret == e_entryExists) { | 593 | if (ret == e_entryExists) { |
589 | KMessageBox::error(this, | 594 | KMessageBox::error(this, |
590 | i18n | 595 | i18n |
591 | ("An entry with this \"Description\", " | 596 | ("An entry with this \"Description\", " |
592 | "does already exist.\n" | 597 | "does already exist.\n" |
593 | "Please select another description."), | 598 | "Please select another description."), |
594 | i18n("entry already exists.")); | 599 | i18n("entry already exists.")); |
595 | goto tryAgain; | 600 | goto tryAgain; |
596 | } else if (ret == e_maxAllowedEntr) { | 601 | } else if (ret == e_maxAllowedEntr) { |
597 | KMessageBox::error(this, i18n("The maximum possible number of entries " | 602 | KMessageBox::error(this, i18n("The maximum possible number of entries " |
598 | "has been reached. You can't add more entries."), | 603 | "has been reached. You can't add more entries."), |
599 | i18n("maximum number of entries")); | 604 | i18n("maximum number of entries")); |
600 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 605 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
601 | return; | 606 | return; |
602 | } | 607 | } |
603 | } | 608 | } |
604 | setVirgin(false); | 609 | setVirgin(false); |
605 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 610 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
606 | } | 611 | } |
607 | 612 | ||
608 | //US ENH : changed code to run with older MOC | 613 | //US ENH : changed code to run with older MOC |
609 | void PwM::editPwd_slot() | 614 | void PwM::editPwd_slot() |
610 | { | 615 | { |
611 | editPwd_slot(0,0,0); | 616 | editPwd_slot(0,0,0); |
612 | } | 617 | } |
613 | 618 | ||
614 | void PwM::editPwd_slot(const QString *category) | 619 | void PwM::editPwd_slot(const QString *category) |
615 | { | 620 | { |
616 | editPwd_slot(category, 0, 0); | 621 | editPwd_slot(category, 0, 0); |
617 | } | 622 | } |
618 | 623 | ||
619 | void PwM::editPwd_slot(const QString *category, const int *index, | 624 | void PwM::editPwd_slot(const QString *category, const int *index, |
620 | PwMDoc *_doc) | 625 | PwMDoc *_doc) |
621 | { | 626 | { |
622 | PwMDoc *doc; | 627 | PwMDoc *doc; |
623 | if (_doc) { | 628 | if (_doc) { |
624 | doc = _doc; | 629 | doc = _doc; |
625 | } else { | 630 | } else { |
626 | doc = curDoc(); | 631 | doc = curDoc(); |
627 | } | 632 | } |
628 | PWM_ASSERT(doc); | 633 | PWM_ASSERT(doc); |
629 | if (doc->isDocEmpty()) | 634 | if (doc->isDocEmpty()) |
630 | return; | 635 | return; |
631 | if (doc->isDeepLocked()) | 636 | if (doc->isDeepLocked()) |
632 | return; | 637 | return; |
633 | doc->timer()->getLock(DocTimer::id_autoLockTimer); | 638 | doc->timer()->getLock(DocTimer::id_autoLockTimer); |
634 | unsigned int curEntryIndex; | 639 | unsigned int curEntryIndex; |
635 | if (index) { | 640 | if (index) { |
636 | curEntryIndex = *index; | 641 | curEntryIndex = *index; |
637 | } else { | 642 | } else { |
638 | if (!(view->getCurEntryIndex(&curEntryIndex))) { | 643 | if (!(view->getCurEntryIndex(&curEntryIndex))) { |
639 | printDebug("couldn't get index. Maybe we have a binary entry here."); | 644 | printDebug("couldn't get index. Maybe we have a binary entry here."); |
640 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 645 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
641 | return; | 646 | return; |
642 | } | 647 | } |
643 | } | 648 | } |
644 | QString curCategory; | 649 | QString curCategory; |
645 | if (category) { | 650 | if (category) { |
646 | curCategory = *category; | 651 | curCategory = *category; |
647 | } else { | 652 | } else { |
648 | curCategory = view->getCurrentCategory(); | 653 | curCategory = view->getCurrentCategory(); |
649 | } | 654 | } |
650 | PwMDataItem currItem; | 655 | PwMDataItem currItem; |
651 | if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) { | 656 | if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) { |
652 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 657 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
653 | return; | 658 | return; |
654 | } | 659 | } |
655 | BUG_ON(currItem.binary); | 660 | BUG_ON(currItem.binary); |
656 | 661 | ||
657 | AddEntryWndImpl w; | 662 | AddEntryWndImpl w; |
658 | vector<string> catList; | 663 | vector<string> catList; |
659 | doc->getCategoryList(&catList); | 664 | doc->getCategoryList(&catList); |
660 | unsigned i, size = catList.size(); | 665 | unsigned i, size = catList.size(); |
661 | for (i = 0; i < size; ++i) { | 666 | for (i = 0; i < size; ++i) { |
662 | w.addCategory(catList[i].c_str()); | 667 | w.addCategory(catList[i].c_str()); |
663 | } | 668 | } |
664 | w.setCurrCategory(curCategory); | 669 | w.setCurrCategory(curCategory); |
665 | w.setDescription(currItem.desc.c_str()); | 670 | w.setDescription(currItem.desc.c_str()); |
666 | w.setUsername(currItem.name.c_str()); | 671 | w.setUsername(currItem.name.c_str()); |
667 | w.setPassword(currItem.pw.c_str()); | 672 | w.setPassword(currItem.pw.c_str()); |
668 | w.setUrl(currItem.url.c_str()); | 673 | w.setUrl(currItem.url.c_str()); |
669 | w.setLauncher(currItem.launcher.c_str()); | 674 | w.setLauncher(currItem.launcher.c_str()); |
670 | w.setComment(currItem.comment.c_str()); | 675 | w.setComment(currItem.comment.c_str()); |
671 | if (w.exec() == 1) { | 676 | if (w.exec() == 1) { |
672 | currItem.desc = w.getDescription().latin1(); | 677 | currItem.desc = w.getDescription().latin1(); |
673 | currItem.name = w.getUsername().latin1(); | 678 | currItem.name = w.getUsername().latin1(); |
674 | currItem.pw = w.getPassword().latin1(); | 679 | currItem.pw = w.getPassword().latin1(); |
675 | currItem.comment = w.getComment().latin1(); | 680 | currItem.comment = w.getComment().latin1(); |
676 | currItem.url = w.getUrl().latin1(); | 681 | currItem.url = w.getUrl().latin1(); |
677 | currItem.launcher = w.getLauncher().latin1(); | 682 | currItem.launcher = w.getLauncher().latin1(); |
678 | if (!doc->editEntry(curCategory, w.getCategory(), | 683 | if (!doc->editEntry(curCategory, w.getCategory(), |
679 | curEntryIndex, &currItem)) { | 684 | curEntryIndex, &currItem)) { |
680 | KMessageBox::error(this, | 685 | KMessageBox::error(this, |
681 | i18n("Couldn't edit the entry.\n" | 686 | i18n("Couldn't edit the entry.\n" |
682 | "Maybe you changed the category and " | 687 | "Maybe you changed the category and " |
683 | "this entry is already present in the new " | 688 | "this entry is already present in the new " |
684 | "category?"), | 689 | "category?"), |
685 | i18n("couldn't edit entry.")); | 690 | i18n("couldn't edit entry.")); |
686 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 691 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
687 | return; | 692 | return; |
688 | } | 693 | } |
689 | } | 694 | } |
690 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 695 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
691 | } | 696 | } |
692 | 697 | ||
693 | void PwM::deletePwd_slot() | 698 | void PwM::deletePwd_slot() |
694 | { | 699 | { |
695 | PWM_ASSERT(curDoc()); | 700 | PWM_ASSERT(curDoc()); |
696 | if (curDoc()->isDocEmpty()) | 701 | if (curDoc()->isDocEmpty()) |
697 | return; | 702 | return; |
698 | if (curDoc()->isDeepLocked()) | 703 | if (curDoc()->isDeepLocked()) |
699 | return; | 704 | return; |
700 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 705 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
701 | unsigned int curEntryIndex = 0; | 706 | unsigned int curEntryIndex = 0; |
702 | if (!(view->getCurEntryIndex(&curEntryIndex))) { | 707 | if (!(view->getCurEntryIndex(&curEntryIndex))) { |
703 | printDebug("couldn't get index"); | 708 | printDebug("couldn't get index"); |
704 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 709 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
705 | return; | 710 | return; |
706 | } | 711 | } |
707 | 712 | ||
708 | PwMDataItem currItem; | 713 | PwMDataItem currItem; |
709 | QString curCategory = view->getCurrentCategory(); | 714 | QString curCategory = view->getCurrentCategory(); |
710 | if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) { | 715 | if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) { |
711 | printDebug("couldn't get entry"); | 716 | printDebug("couldn't get entry"); |
712 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 717 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
713 | return; | 718 | return; |
714 | } | 719 | } |
715 | if (KMessageBox:: | 720 | if (KMessageBox:: |
716 | questionYesNo(this, | 721 | questionYesNo(this, |
717 | i18n | 722 | i18n |
718 | ("Do you really want to delete the selected entry") + | 723 | ("Do you really want to delete the selected entry") + |
719 | " \"" + QString(currItem.desc.c_str()) | 724 | " \"" + QString(currItem.desc.c_str()) |
720 | + "\" ?", i18n("delete?")) | 725 | + "\" ?", i18n("delete?")) |
721 | == KMessageBox::Yes) { | 726 | == KMessageBox::Yes) { |
722 | 727 | ||
723 | curDoc()->delEntry(curCategory, curEntryIndex); | 728 | curDoc()->delEntry(curCategory, curEntryIndex); |
724 | } | 729 | } |
725 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 730 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
726 | } | 731 | } |
727 | 732 | ||
728 | void PwM::changeMasterPwd_slot() | 733 | void PwM::changeMasterPwd_slot() |
729 | { | 734 | { |
730 | PWM_ASSERT(curDoc()); | 735 | PWM_ASSERT(curDoc()); |
731 | curDoc()->changeCurrentPw(); | 736 | curDoc()->changeCurrentPw(); |
732 | } | 737 | } |
733 | 738 | ||
734 | void PwM::lockWnd_slot() | 739 | void PwM::lockWnd_slot() |
735 | { | 740 | { |
736 | PWM_ASSERT(curDoc()); | 741 | PWM_ASSERT(curDoc()); |
737 | curDoc()->lockAll(true); | 742 | curDoc()->lockAll(true); |
738 | } | 743 | } |
739 | 744 | ||
740 | void PwM::deepLockWnd_slot() | 745 | void PwM::deepLockWnd_slot() |
741 | { | 746 | { |
742 | PWM_ASSERT(curDoc()); | 747 | PWM_ASSERT(curDoc()); |
743 | curDoc()->deepLock(); | 748 | curDoc()->deepLock(); |
744 | } | 749 | } |
745 | 750 | ||
746 | void PwM::unlockWnd_slot() | 751 | void PwM::unlockWnd_slot() |
747 | { | 752 | { |
748 | PWM_ASSERT(curDoc()); | 753 | PWM_ASSERT(curDoc()); |
749 | curDoc()->lockAll(false); | 754 | curDoc()->lockAll(false); |
750 | } | 755 | } |
751 | 756 | ||
752 | void PwM::config_slot() | 757 | void PwM::config_slot() |
753 | { | 758 | { |
754 | Configuration *conf = Configuration::obj(); | 759 | int oldStyle = conf()->confWndMainViewStyle(); |
755 | int oldStyle = conf->confWndMainViewStyle(); | 760 | #ifdef PWM_EMBEDDED |
761 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"pwmconfigdialog", true ); | ||
762 | |||
763 | KCMPwmConfig* pwmcfg = new KCMPwmConfig( ConfigureDialog->getNewVBoxPage(i18n( "PwManager")) , "KCMPwmConfig" ); | ||
764 | ConfigureDialog->addModule(pwmcfg ); | ||
756 | 765 | ||
766 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | ||
767 | ConfigureDialog->addModule(kdelibcfg ); | ||
768 | |||
769 | #ifndef DESKTOP_VERSION | ||
770 | ConfigureDialog->showMaximized(); | ||
771 | #endif | ||
772 | if ( ConfigureDialog->exec() ) | ||
773 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | ||
774 | delete ConfigureDialog; | ||
775 | |||
776 | #else //PWM_EMBEDDED | ||
757 | // display the configuration window (modal mode) | 777 | // display the configuration window (modal mode) |
758 | if (!conf->showConfWnd(this)) | 778 | if (!conf()->showConfWnd(this)) |
759 | return; | 779 | return; |
780 | #endif | ||
760 | 781 | ||
761 | int newStyle = conf->confWndMainViewStyle(); | 782 | int newStyle = conf()->confWndMainViewStyle(); |
762 | // reinitialize tray | 783 | // reinitialize tray |
763 | init->initTray(); | 784 | init->initTray(); |
764 | // reinitialize KWallet emulation | 785 | // reinitialize KWallet emulation |
765 | init->initKWalletEmu(); | 786 | init->initKWalletEmu(); |
766 | 787 | ||
767 | PwMDocList *_dl = PwMDoc::getOpenDocList(); | 788 | PwMDocList *_dl = PwMDoc::getOpenDocList(); |
768 | const vector<PwMDocList::listItem> *dl = _dl->getList(); | 789 | const vector<PwMDocList::listItem> *dl = _dl->getList(); |
769 | vector<PwMDocList::listItem>::const_iterator i = dl->begin(), | 790 | vector<PwMDocList::listItem>::const_iterator i = dl->begin(), |
770 | end = dl->end(); | 791 | end = dl->end(); |
771 | PwMDoc *doc; | 792 | PwMDoc *doc; |
772 | while (i != end) { | 793 | while (i != end) { |
773 | doc = (*i).doc; | 794 | doc = (*i).doc; |
774 | // unlock-without-mpw timeout | 795 | // unlock-without-mpw timeout |
775 | doc->timer()->start(DocTimer::id_mpwTimer); | 796 | doc->timer()->start(DocTimer::id_mpwTimer); |
776 | // auto-lock timeout | 797 | // auto-lock timeout |
777 | doc->timer()->start(DocTimer::id_autoLockTimer); | 798 | doc->timer()->start(DocTimer::id_autoLockTimer); |
778 | ++i; | 799 | ++i; |
779 | } | 800 | } |
780 | 801 | ||
781 | const QValueList<PwM *> *ml = init->mainWndList(); | 802 | const QValueList<PwM *> *ml = init->mainWndList(); |
782 | #ifndef PWM_EMBEDDED | 803 | #ifndef PWM_EMBEDDED |
783 | QValueList<PwM *>::const_iterator i2 = ml->begin(), | 804 | QValueList<PwM *>::const_iterator i2 = ml->begin(), |
784 | end2 = ml->end(); | 805 | end2 = ml->end(); |
785 | #else | 806 | #else |
786 | QValueList<PwM *>::ConstIterator i2 = ml->begin(), | 807 | QValueList<PwM *>::ConstIterator i2 = ml->begin(), |
787 | end2 = ml->end(); | 808 | end2 = ml->end(); |
788 | #endif | 809 | #endif |
789 | PwM *pwm; | 810 | PwM *pwm; |
790 | while (i2 != end2) { | 811 | while (i2 != end2) { |
791 | pwm = *i2; | 812 | pwm = *i2; |
792 | // reinitialize the window style. | 813 | // reinitialize the window style. |
793 | if (oldStyle != newStyle) | 814 | if (oldStyle != newStyle) |
794 | pwm->curView()->initStyle(newStyle); | 815 | pwm->curView()->initStyle(newStyle); |
795 | // set the new font | 816 | // set the new font |
796 | pwm->curView()->setFont(conf->confGlobEntryFont()); | 817 | pwm->curView()->setFont(conf()->confGlobEntryFont()); |
797 | ++i2; | 818 | ++i2; |
798 | } | 819 | } |
799 | } | 820 | } |
800 | 821 | ||
801 | void PwM::activateMpButton(bool activate) | 822 | void PwM::activateMpButton(bool activate) |
802 | { | 823 | { |
803 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, activate); | 824 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, activate); |
804 | } | 825 | } |
805 | 826 | ||
806 | void PwM::closeEvent(QCloseEvent *e) | 827 | void PwM::closeEvent(QCloseEvent *e) |
807 | { | 828 | { |
808 | e->accept(); | 829 | e->accept(); |
809 | } | 830 | } |
810 | 831 | ||
811 | void PwM::docClosed(PwMDoc *doc) | 832 | void PwM::docClosed(PwMDoc *doc) |
812 | { | 833 | { |
813 | PARAM_UNUSED(doc); | 834 | PARAM_UNUSED(doc); |
814 | PWM_ASSERT(doc == curDoc()); | 835 | PWM_ASSERT(doc == curDoc()); |
815 | close(); | 836 | close(); |
816 | } | 837 | } |
817 | 838 | ||
818 | void PwM::find_slot() | 839 | void PwM::find_slot() |
819 | { | 840 | { |
820 | PWM_ASSERT(curDoc()); | 841 | PWM_ASSERT(curDoc()); |
821 | if (curDoc()->isDocEmpty()) | 842 | if (curDoc()->isDocEmpty()) |
822 | return; | 843 | return; |
823 | if (curDoc()->isDeepLocked()) | 844 | if (curDoc()->isDeepLocked()) |
824 | return; | 845 | return; |
825 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 846 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
826 | FindWndImpl findWnd(view); | 847 | FindWndImpl findWnd(view); |
827 | findWnd.exec(); | 848 | findWnd.exec(); |
828 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 849 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
829 | } | 850 | } |
830 | 851 | ||
831 | void PwM::exportToText() | 852 | void PwM::exportToText() |
832 | { | 853 | { |
833 | PWM_ASSERT(curDoc()); | 854 | PWM_ASSERT(curDoc()); |
834 | if (curDoc()->isDocEmpty()) { | 855 | if (curDoc()->isDocEmpty()) { |
835 | KMessageBox::information(this, | 856 | KMessageBox::information(this, |
836 | i18n | 857 | i18n |
837 | ("Sorry, there's nothing to export.\n" | 858 | ("Sorry, there's nothing to export.\n" |
838 | "Please first add some passwords."), | 859 | "Please first add some passwords."), |
839 | i18n("nothing to do")); | 860 | i18n("nothing to do")); |
840 | return; | 861 | return; |
841 | } | 862 | } |
842 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 863 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
843 | QString fn(KFileDialog::getSaveFileName(QString::null, | 864 | QString fn(KFileDialog::getSaveFileName(QString::null, |
844 | i18n("*|plain-text file"), | 865 | i18n("*|plain-text file"), |
845 | this)); | 866 | this)); |
846 | if (fn == "") { | 867 | if (fn == "") { |
847 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 868 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
848 | return; | 869 | return; |
849 | } | 870 | } |
850 | 871 | ||
851 | PwMerror ret = curDoc()->exportToText(&fn); | 872 | PwMerror ret = curDoc()->exportToText(&fn); |
852 | if (ret != e_success) { | 873 | if (ret != e_success) { |
853 | KMessageBox::error(this, | 874 | KMessageBox::error(this, |
854 | i18n("Error: Couldn't write to file.\n" | 875 | i18n("Error: Couldn't write to file.\n" |
855 | "Please check if you have permission to write " | 876 | "Please check if you have permission to write " |
856 | "to the file in that directory."), | 877 | "to the file in that directory."), |
857 | i18n("error while writing")); | 878 | i18n("error while writing")); |
858 | } else | 879 | } else |
859 | showStatMsg(i18n("Successfully exported data.")); | 880 | showStatMsg(i18n("Successfully exported data.")); |
860 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 881 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
861 | } | 882 | } |
862 | 883 | ||
863 | bool PwM::importFromText() | 884 | bool PwM::importFromText() |
864 | { | 885 | { |
865 | if (!isVirgin()) { | 886 | if (!isVirgin()) { |
866 | if (KMessageBox::questionYesNo(this, | 887 | if (KMessageBox::questionYesNo(this, |
867 | i18n("Do you want to import the data " | 888 | i18n("Do you want to import the data " |
868 | "into the current document? (If you " | 889 | "into the current document? (If you " |
869 | "select \"no\", a new document will be " | 890 | "select \"no\", a new document will be " |
870 | "opened.)"), | 891 | "opened.)"), |
871 | i18n("import into this document?")) | 892 | i18n("import into this document?")) |
872 | == KMessageBox::No) { | 893 | == KMessageBox::No) { |
873 | // import the data to a new window. | 894 | // import the data to a new window. |
874 | PwM *newInstance = init->createMainWnd(); | 895 | PwM *newInstance = init->createMainWnd(); |
875 | bool ok = newInstance->importFromText(); | 896 | bool ok = newInstance->importFromText(); |
876 | if (!ok) { | 897 | if (!ok) { |
877 | newInstance->setForceQuit(true); | 898 | newInstance->setForceQuit(true); |
878 | delete_and_null(newInstance); | 899 | delete_and_null(newInstance); |
879 | } | 900 | } |
880 | return ok; | 901 | return ok; |
881 | } | 902 | } |
882 | } | 903 | } |
883 | 904 | ||
884 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 905 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
885 | PwMerror ret; | 906 | PwMerror ret; |
886 | QString path(KFileDialog::getOpenFileName(QString::null, | 907 | QString path(KFileDialog::getOpenFileName(QString::null, |
887 | i18n("*|PWM-exported text file"), | 908 | i18n("*|PWM-exported text file"), |
888 | this)); | 909 | this)); |
889 | if (path == "") | 910 | if (path == "") |
890 | goto cancelImport; | 911 | goto cancelImport; |
891 | 912 | ||
892 | ret = curDoc()->importFromText(&path, 0); | 913 | ret = curDoc()->importFromText(&path, 0); |
893 | if (ret == e_fileFormat) { | 914 | if (ret == e_fileFormat) { |
894 | KMessageBox::error(this, | 915 | KMessageBox::error(this, |
895 | i18n("Could not read file-format.\n" | 916 | i18n("Could not read file-format.\n" |
896 | "This seems to be _not_ a valid file " | 917 | "This seems to be _not_ a valid file " |
897 | "exported by PwM."), | 918 | "exported by PwM."), |
898 | i18n("invalid file-format")); | 919 | i18n("invalid file-format")); |
899 | goto cancelImport; | 920 | goto cancelImport; |
900 | } else if (ret == e_invalidArg) { | 921 | } else if (ret == e_invalidArg) { |
901 | BUG(); | 922 | BUG(); |
902 | goto cancelImport; | 923 | goto cancelImport; |
903 | } else if (ret != e_success) { | 924 | } else if (ret != e_success) { |
904 | KMessageBox::error(this, | 925 | KMessageBox::error(this, |
905 | i18n("Could not import file!\n" | 926 | i18n("Could not import file!\n" |
906 | "Do you have permission to read this file? " | 927 | "Do you have permission to read this file? " |
907 | "Do you have enough free memory?"), | 928 | "Do you have enough free memory?"), |
908 | i18n("import failed")); | 929 | i18n("import failed")); |
909 | goto cancelImport; | 930 | goto cancelImport; |
910 | } | 931 | } |
911 | setVirgin(false); | 932 | setVirgin(false); |
912 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 933 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
913 | return true; | 934 | return true; |
914 | 935 | ||
915 | cancelImport: | 936 | cancelImport: |
916 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 937 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
917 | return false; | 938 | return false; |
918 | } | 939 | } |
919 | 940 | ||
920 | void PwM::exportToGpasman() | 941 | void PwM::exportToGpasman() |
921 | { | 942 | { |
922 | PWM_ASSERT(curDoc()); | 943 | PWM_ASSERT(curDoc()); |
923 | if (curDoc()->isDocEmpty()) { | 944 | if (curDoc()->isDocEmpty()) { |
924 | KMessageBox::information(this, | 945 | KMessageBox::information(this, |
925 | i18n | 946 | i18n |
926 | ("Sorry, there's nothing to export.\n" | 947 | ("Sorry, there's nothing to export.\n" |
927 | "Please first add some passwords."), | 948 | "Please first add some passwords."), |
928 | i18n("nothing to do")); | 949 | i18n("nothing to do")); |
929 | return; | 950 | return; |
930 | } | 951 | } |
931 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 952 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
932 | QString fn(KFileDialog::getSaveFileName(QString::null, | 953 | QString fn(KFileDialog::getSaveFileName(QString::null, |
933 | i18n("*|Gpasman or Kpasman file"), | 954 | i18n("*|Gpasman or Kpasman file"), |
934 | this)); | 955 | this)); |
935 | if (fn == "") { | 956 | if (fn == "") { |
936 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 957 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
937 | return; | 958 | return; |
938 | } | 959 | } |
939 | 960 | ||
940 | PwMerror ret = curDoc()->exportToGpasman(&fn); | 961 | PwMerror ret = curDoc()->exportToGpasman(&fn); |
941 | if (ret != e_success) { | 962 | if (ret != e_success) { |
942 | if (ret == e_noPw) { | 963 | if (ret == e_noPw) { |
943 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 964 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
944 | return; | 965 | return; |
945 | } | 966 | } |
946 | KMessageBox::error(this, | 967 | KMessageBox::error(this, |
947 | i18n("Error: Couldn't write to file.\n" | 968 | i18n("Error: Couldn't write to file.\n" |
948 | "Please check if you have permission to write " | 969 | "Please check if you have permission to write " |
949 | "to the file in that directory."), | 970 | "to the file in that directory."), |
950 | i18n("error while writing")); | 971 | i18n("error while writing")); |
951 | } else | 972 | } else |
952 | showStatMsg(i18n("Successfully exported data.")); | 973 | showStatMsg(i18n("Successfully exported data.")); |
953 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 974 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
954 | } | 975 | } |
955 | 976 | ||
956 | void PwM::exportToKWallet() | 977 | void PwM::exportToKWallet() |
957 | { | 978 | { |
958 | #ifdef CONFIG_KWALLETIF | 979 | #ifdef CONFIG_KWALLETIF |
959 | if (!checkAndAskForKWalletEmu()) | 980 | if (!checkAndAskForKWalletEmu()) |
960 | return; | 981 | return; |
961 | PWM_ASSERT(curDoc()); | 982 | PWM_ASSERT(curDoc()); |
962 | if (curDoc()->isDocEmpty()) { | 983 | if (curDoc()->isDocEmpty()) { |
963 | KMessageBox::information(this, | 984 | KMessageBox::information(this, |
964 | i18n | 985 | i18n |
965 | ("Sorry, there's nothing to export.\n" | 986 | ("Sorry, there's nothing to export.\n" |
966 | "Please first add some passwords."), | 987 | "Please first add some passwords."), |
967 | i18n("nothing to do")); | 988 | i18n("nothing to do")); |
968 | init->initKWalletEmu(); | 989 | init->initKWalletEmu(); |
969 | return; | 990 | return; |
970 | } | 991 | } |
971 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 992 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
972 | KWalletIf walletIf(this); | 993 | KWalletIf walletIf(this); |
973 | if (walletIf.kwalletExport(curDoc())) { | 994 | if (walletIf.kwalletExport(curDoc())) { |
974 | KMessageBox::information(this, | 995 | KMessageBox::information(this, |
975 | i18n("Successfully exported the data of the current " | 996 | i18n("Successfully exported the data of the current " |
976 | "document to KWallet."), | 997 | "document to KWallet."), |
977 | i18n("Successfully exported data.")); | 998 | i18n("Successfully exported data.")); |
978 | showStatMsg(i18n("Successfully exported data.")); | 999 | showStatMsg(i18n("Successfully exported data.")); |
979 | } | 1000 | } |
980 | init->initKWalletEmu(); | 1001 | init->initKWalletEmu(); |
981 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1002 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
982 | #endif // CONFIG_KWALLETIF | 1003 | #endif // CONFIG_KWALLETIF |
983 | } | 1004 | } |
984 | 1005 | ||
985 | bool PwM::importFromGpasman() | 1006 | bool PwM::importFromGpasman() |
986 | { | 1007 | { |
987 | if (!isVirgin()) { | 1008 | if (!isVirgin()) { |
988 | if (KMessageBox::questionYesNo(this, | 1009 | if (KMessageBox::questionYesNo(this, |
diff --git a/pwmanager/pwmanager/pwmanagerE.pro b/pwmanager/pwmanager/pwmanagerE.pro index 2cd69a5..5c29ea4 100644 --- a/pwmanager/pwmanager/pwmanagerE.pro +++ b/pwmanager/pwmanager/pwmanagerE.pro | |||
@@ -1,144 +1,153 @@ | |||
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 |
6 | OBJECTS_DIR = obj/$(PLATFORM) | 6 | OBJECTS_DIR = obj/$(PLATFORM) |
7 | MOC_DIR = moc/$(PLATFORM) | 7 | MOC_DIR = moc/$(PLATFORM) |
8 | DESTDIR=$(QPEDIR)/bin | 8 | DESTDIR=$(QPEDIR)/bin |
9 | 9 | ||
10 | INCLUDEPATH += . ../../qtcompat ../../qtcompat/xml ../../microkde ../../microkde/kdecore ../../microkde/kdeui $(QPEDIR)/include | 10 | INCLUDEPATH += . ../../qtcompat ../../qtcompat/xml ../../libkdepim ../../microkde ../../microkde/kdecore ../../microkde/kdeui ../../microkde/kutils $(QPEDIR)/include |
11 | DEFINES += PWM_EMBEDDED PWM_DEBUG | 11 | DEFINES += PWM_EMBEDDED PWM_DEBUG |
12 | LIBS += -lmicrokde | 12 | LIBS += -lmicrokde |
13 | LIBS += -lmicroqtcompat | 13 | LIBS += -lmicroqtcompat |
14 | LIBS += -lmicrokdepim | ||
14 | LIBS += -L$(QPEDIR)/lib | 15 | LIBS += -L$(QPEDIR)/lib |
15 | LIBS += -lqpe | 16 | LIBS += -lqpe |
16 | LIBS += -lbz2 | 17 | LIBS += -lbz2 |
17 | LIBS += $(QTOPIALIB) | 18 | LIBS += $(QTOPIALIB) |
18 | 19 | ||
19 | #INTERFACES = \ | 20 | #INTERFACES = \ |
20 | #addentrywnd.ui \ | 21 | #addentrywnd.ui \ |
21 | #configwnd.ui \ | 22 | #configwnd.ui \ |
22 | #findwnd.ui \ | 23 | #findwnd.ui \ |
23 | #getmasterpwwnd.ui \ | 24 | #getmasterpwwnd.ui \ |
24 | #pwgenwnd.ui \ | 25 | #pwgenwnd.ui \ |
25 | #setmasterpwwnd.ui \ | 26 | #setmasterpwwnd.ui \ |
26 | #subtbledit.ui | 27 | #subtbledit.ui |
27 | 28 | ||
28 | #INTERFACES = \ | 29 | #INTERFACES = \ |
29 | #subtbledit.ui \ | 30 | #subtbledit.ui \ |
30 | 31 | ||
31 | 32 | ||
32 | 33 | ||
33 | #HEADERS = \ | 34 | #HEADERS = \ |
35 | #configuration_31compat.h \ | ||
36 | #configuration.h \ | ||
37 | #configwnd.h \ | ||
38 | #configwndimpl.h \ | ||
34 | #selftest.h | 39 | #selftest.h |
35 | 40 | ||
36 | HEADERS = \ | 41 | HEADERS = \ |
37 | addentrywnd.h \ | 42 | addentrywnd.h \ |
38 | addentrywndimpl.h \ | 43 | addentrywndimpl.h \ |
39 | base64.h \ | 44 | base64.h \ |
40 | binentrygen.h \ | 45 | binentrygen.h \ |
41 | blowfish.h \ | 46 | blowfish.h \ |
42 | commentbox.h \ | 47 | commentbox.h \ |
43 | compiler.h \ | 48 | compiler.h \ |
44 | compressbzip2.h \ | 49 | compressbzip2.h \ |
45 | compressgzip.h \ | 50 | compressgzip.h \ |
46 | configuration_31compat.h \ | ||
47 | configuration.h \ | ||
48 | configwnd.h \ | ||
49 | configwndimpl.h \ | ||
50 | findwnd.h \ | 51 | findwnd.h \ |
51 | findwndimpl.h \ | 52 | findwndimpl.h \ |
52 | genpasswd.h \ | 53 | genpasswd.h \ |
53 | getkeycardwnd.h \ | 54 | getkeycardwnd.h \ |
54 | getmasterpwwnd.h \ | 55 | getmasterpwwnd.h \ |
55 | getmasterpwwndimpl.h \ | 56 | getmasterpwwndimpl.h \ |
56 | globalstuff.h \ | 57 | globalstuff.h \ |
57 | gpasmanfile.h \ | 58 | gpasmanfile.h \ |
58 | htmlgen.h \ | 59 | htmlgen.h \ |
59 | htmlparse.h \ | 60 | htmlparse.h \ |
60 | ipc.h \ | 61 | ipc.h \ |
61 | listobjselectwnd.h \ | 62 | listobjselectwnd.h \ |
62 | listviewpwm.h \ | 63 | listviewpwm.h \ |
63 | printtext.h \ | 64 | printtext.h \ |
64 | pwgenwnd.h \ | 65 | pwgenwnd.h \ |
65 | pwgenwndimpl.h \ | 66 | pwgenwndimpl.h \ |
66 | pwmdoc.h \ | 67 | pwmdoc.h \ |
67 | pwmdocui.h \ | 68 | pwmdocui.h \ |
68 | pwmexception.h \ | 69 | pwmexception.h \ |
69 | pwm.h \ | 70 | pwm.h \ |
70 | pwminit.h \ | 71 | pwminit.h \ |
72 | pwmprefs.h \ | ||
71 | pwmprint.h \ | 73 | pwmprint.h \ |
72 | pwmtray.h \ | 74 | pwmtray.h \ |
73 | pwmview.h \ | 75 | pwmview.h \ |
74 | pwmviewstyle_0.h \ | 76 | pwmviewstyle_0.h \ |
75 | pwmviewstyle_1.h \ | 77 | pwmviewstyle_1.h \ |
76 | pwmviewstyle.h \ | 78 | pwmviewstyle.h \ |
77 | randomizer.h \ | 79 | randomizer.h \ |
78 | rc2.h \ | 80 | rc2.h \ |
79 | rencatwnd.h \ | 81 | rencatwnd.h \ |
80 | serializer.h \ | 82 | serializer.h \ |
81 | setmasterpwwnd.h \ | 83 | setmasterpwwnd.h \ |
82 | setmasterpwwndimpl.h \ | 84 | setmasterpwwndimpl.h \ |
83 | sha1.h \ | 85 | sha1.h \ |
84 | subtbledit.h \ | 86 | subtbledit.h \ |
85 | subtbleditimpl.h \ | 87 | subtbleditimpl.h \ |
86 | waitwnd.h | 88 | waitwnd.h \ |
89 | kcmconfigs/kcmpwmconfig.h \ | ||
90 | kcmconfigs/pwmconfigwidget.h \ | ||
87 | 91 | ||
92 | #sources that need not be build | ||
88 | #SOURCES = \ | 93 | #SOURCES = \ |
89 | #advcommeditimpl.cpp \ | 94 | #advcommeditimpl.cpp \ |
95 | #configuration.cpp \ | ||
96 | #configwnd.cpp \ | ||
97 | #configwndimpl.cpp \ | ||
90 | #configuration_31compat.cpp \ | 98 | #configuration_31compat.cpp \ |
91 | #htmlparse.cpp \ | 99 | #htmlparse.cpp \ |
92 | #printtext.cpp \ | 100 | #printtext.cpp \ |
93 | #selftest.cpp \ | 101 | #selftest.cpp \ |
94 | #pwmprint.cpp \ | 102 | #pwmprint.cpp \ |
95 | #spinforsignal.cpp | 103 | #spinforsignal.cpp |
96 | 104 | ||
97 | SOURCES = \ | 105 | SOURCES = \ |
98 | addentrywnd.cpp \ | 106 | addentrywnd.cpp \ |
99 | addentrywndimpl.cpp \ | 107 | addentrywndimpl.cpp \ |
100 | base64.cpp \ | 108 | base64.cpp \ |
101 | binentrygen.cpp \ | 109 | binentrygen.cpp \ |
102 | blowfish.cpp \ | 110 | blowfish.cpp \ |
103 | commentbox.cpp \ | 111 | commentbox.cpp \ |
104 | compressbzip2.cpp \ | 112 | compressbzip2.cpp \ |
105 | compressgzip.cpp \ | 113 | compressgzip.cpp \ |
106 | configuration.cpp \ | ||
107 | configwnd.cpp \ | ||
108 | configwndimpl.cpp \ | ||
109 | findwnd.cpp \ | 114 | findwnd.cpp \ |
110 | findwndimpl.cpp \ | 115 | findwndimpl.cpp \ |
111 | genpasswd.cpp \ | 116 | genpasswd.cpp \ |
112 | getkeycardwnd.cpp \ | 117 | getkeycardwnd.cpp \ |
113 | getmasterpwwnd.cpp \ | 118 | getmasterpwwnd.cpp \ |
114 | getmasterpwwndimpl.cpp \ | 119 | getmasterpwwndimpl.cpp \ |
115 | globalstuff.cpp \ | 120 | globalstuff.cpp \ |
116 | gpasmanfile.cpp \ | 121 | gpasmanfile.cpp \ |
117 | htmlgen.cpp \ | 122 | htmlgen.cpp \ |
118 | ipc.cpp \ | 123 | ipc.cpp \ |
119 | listobjselectwnd.cpp \ | 124 | listobjselectwnd.cpp \ |
120 | listviewpwm.cpp \ | 125 | listviewpwm.cpp \ |
121 | main.cpp \ | 126 | main.cpp \ |
122 | pwgenwnd.cpp \ | 127 | pwgenwnd.cpp \ |
123 | pwgenwndimpl.cpp \ | 128 | pwgenwndimpl.cpp \ |
124 | pwm.cpp \ | 129 | pwm.cpp \ |
125 | pwmdoc.cpp \ | 130 | pwmdoc.cpp \ |
126 | pwmdocui.cpp \ | 131 | pwmdocui.cpp \ |
127 | pwmexception.cpp \ | 132 | pwmexception.cpp \ |
128 | pwminit.cpp \ | 133 | pwminit.cpp \ |
134 | pwmprefs.cpp \ | ||
129 | pwmtray.cpp \ | 135 | pwmtray.cpp \ |
130 | pwmview.cpp \ | 136 | pwmview.cpp \ |
131 | pwmviewstyle_0.cpp \ | 137 | pwmviewstyle_0.cpp \ |
132 | pwmviewstyle_1.cpp \ | 138 | pwmviewstyle_1.cpp \ |
133 | pwmviewstyle.cpp \ | 139 | pwmviewstyle.cpp \ |
134 | randomizer.cpp \ | 140 | randomizer.cpp \ |
135 | rc2.cpp \ | 141 | rc2.cpp \ |
136 | rencatwnd.cpp \ | 142 | rencatwnd.cpp \ |
137 | serializer.cpp \ | 143 | serializer.cpp \ |
138 | setmasterpwwnd.cpp \ | 144 | setmasterpwwnd.cpp \ |
139 | setmasterpwwndimpl.cpp \ | 145 | setmasterpwwndimpl.cpp \ |
140 | sha1.cpp \ | 146 | sha1.cpp \ |
141 | subtbledit.cpp \ | 147 | subtbledit.cpp \ |
142 | subtbleditimpl.cpp \ | 148 | subtbleditimpl.cpp \ |
143 | waitwnd.cpp \ | 149 | waitwnd.cpp \ |
150 | kcmconfigs/kcmpwmconfig.cpp \ | ||
151 | kcmconfigs/pwmconfigwidget.cpp \ | ||
152 | |||
144 | 153 | ||
diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp index 04af360..9fe4809 100644 --- a/pwmanager/pwmanager/pwmdoc.cpp +++ b/pwmanager/pwmanager/pwmdoc.cpp | |||
@@ -1,225 +1,227 @@ | |||
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 2.0 of pwmanager | 14 | * This file is originaly based on version 2.0 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 | #include "compressbzip2.h" | 28 | #include "compressbzip2.h" |
29 | #include "randomizer.h" | 29 | #include "randomizer.h" |
30 | #include "pwminit.h" | 30 | #include "pwminit.h" |
31 | #ifndef PWM_EMBEDDED | 31 | #ifndef PWM_EMBEDDED |
32 | //US #include "libgryptif.h" | 32 | //US #include "libgryptif.h" |
33 | #else | 33 | #else |
34 | #include "pwmprefs.h" | ||
35 | #include "kglobal.h" | ||
34 | #endif | 36 | #endif |
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 | 41 | ||
40 | #include <qdatetime.h> | 42 | #include <qdatetime.h> |
41 | #include <qsize.h> | 43 | #include <qsize.h> |
42 | #include <qfileinfo.h> | 44 | #include <qfileinfo.h> |
43 | #include <qfile.h> | 45 | #include <qfile.h> |
44 | 46 | ||
45 | #include <stdio.h> | 47 | #include <stdio.h> |
46 | #include <stdlib.h> | 48 | #include <stdlib.h> |
47 | #include <errno.h> | 49 | #include <errno.h> |
48 | #include <string.h> | 50 | #include <string.h> |
49 | #include <iostream> | 51 | #include <iostream> |
50 | #include <algorithm> | 52 | #include <algorithm> |
51 | #include <sys/types.h> | 53 | #include <sys/types.h> |
52 | #include <sys/stat.h> | 54 | #include <sys/stat.h> |
53 | #include <unistd.h> | 55 | #include <unistd.h> |
54 | #include <stdint.h> | 56 | #include <stdint.h> |
55 | 57 | ||
56 | //TODO: reset to its normal value. | 58 | //TODO: reset to its normal value. |
57 | #define META_CHECK_TIMER_INTERVAL10/*300*/ /* sek */ | 59 | #define META_CHECK_TIMER_INTERVAL10/*300*/ /* sek */ |
58 | 60 | ||
59 | using namespace std; | 61 | using namespace std; |
60 | 62 | ||
61 | 63 | ||
62 | void PwMDocList::add(PwMDoc *doc, const string &id) | 64 | void PwMDocList::add(PwMDoc *doc, const string &id) |
63 | { | 65 | { |
64 | #ifdef PWM_DEBUG | 66 | #ifdef PWM_DEBUG |
65 | // check for existance of object in debug mode only. | 67 | // check for existance of object in debug mode only. |
66 | vector<listItem>::iterator begin = docList.begin(), | 68 | vector<listItem>::iterator begin = docList.begin(), |
67 | end = docList.end(), | 69 | end = docList.end(), |
68 | i = begin; | 70 | i = begin; |
69 | while (i != end) { | 71 | while (i != end) { |
70 | if (i->doc == doc) { | 72 | if (i->doc == doc) { |
71 | BUG(); | 73 | BUG(); |
72 | return; | 74 | return; |
73 | } | 75 | } |
74 | ++i; | 76 | ++i; |
75 | } | 77 | } |
76 | #endif | 78 | #endif |
77 | listItem newItem; | 79 | listItem newItem; |
78 | newItem.doc = doc; | 80 | newItem.doc = doc; |
79 | newItem.docId = id; | 81 | newItem.docId = id; |
80 | docList.push_back(newItem); | 82 | docList.push_back(newItem); |
81 | } | 83 | } |
82 | 84 | ||
83 | void PwMDocList::edit(PwMDoc *doc, const string &newId) | 85 | void PwMDocList::edit(PwMDoc *doc, const string &newId) |
84 | { | 86 | { |
85 | vector<listItem>::iterator begin = docList.begin(), | 87 | vector<listItem>::iterator begin = docList.begin(), |
86 | end = docList.end(), | 88 | end = docList.end(), |
87 | i = begin; | 89 | i = begin; |
88 | while (i != end) { | 90 | while (i != end) { |
89 | if (i->doc == doc) { | 91 | if (i->doc == doc) { |
90 | i->docId = newId; | 92 | i->docId = newId; |
91 | return; | 93 | return; |
92 | } | 94 | } |
93 | ++i; | 95 | ++i; |
94 | } | 96 | } |
95 | } | 97 | } |
96 | 98 | ||
97 | void PwMDocList::del(PwMDoc *doc) | 99 | void PwMDocList::del(PwMDoc *doc) |
98 | { | 100 | { |
99 | vector<listItem>::iterator begin = docList.begin(), | 101 | vector<listItem>::iterator begin = docList.begin(), |
100 | end = docList.end(), | 102 | end = docList.end(), |
101 | i = begin; | 103 | i = begin; |
102 | while (i != end) { | 104 | while (i != end) { |
103 | if (i->doc == doc) { | 105 | if (i->doc == doc) { |
104 | docList.erase(i); | 106 | docList.erase(i); |
105 | return; | 107 | return; |
106 | } | 108 | } |
107 | ++i; | 109 | ++i; |
108 | } | 110 | } |
109 | } | 111 | } |
110 | 112 | ||
111 | bool PwMDocList::find(const string &id, listItem *ret) | 113 | bool PwMDocList::find(const string &id, listItem *ret) |
112 | { | 114 | { |
113 | vector<listItem>::iterator begin = docList.begin(), | 115 | vector<listItem>::iterator begin = docList.begin(), |
114 | end = docList.end(), | 116 | end = docList.end(), |
115 | i = begin; | 117 | i = begin; |
116 | while (i != end) { | 118 | while (i != end) { |
117 | if (i->docId == id) { | 119 | if (i->docId == id) { |
118 | if (ret) | 120 | if (ret) |
119 | *ret = *i; | 121 | *ret = *i; |
120 | return true; | 122 | return true; |
121 | } | 123 | } |
122 | ++i; | 124 | ++i; |
123 | } | 125 | } |
124 | return false; | 126 | return false; |
125 | } | 127 | } |
126 | 128 | ||
127 | 129 | ||
128 | 130 | ||
129 | DocTimer::DocTimer(PwMDoc *_doc) | 131 | DocTimer::DocTimer(PwMDoc *_doc) |
130 | : doc (_doc) | 132 | : doc (_doc) |
131 | , mpwLock (0) | 133 | , mpwLock (0) |
132 | , autoLockLock (0) | 134 | , autoLockLock (0) |
133 | , metaCheckLock (0) | 135 | , metaCheckLock (0) |
134 | { | 136 | { |
135 | mpwTimer = new QTimer; | 137 | mpwTimer = new QTimer; |
136 | autoLockTimer = new QTimer; | 138 | autoLockTimer = new QTimer; |
137 | metaCheckTimer = new QTimer; | 139 | metaCheckTimer = new QTimer; |
138 | connect(mpwTimer, SIGNAL(timeout()), | 140 | connect(mpwTimer, SIGNAL(timeout()), |
139 | this, SLOT(mpwTimeout())); | 141 | this, SLOT(mpwTimeout())); |
140 | connect(autoLockTimer, SIGNAL(timeout()), | 142 | connect(autoLockTimer, SIGNAL(timeout()), |
141 | this, SLOT(autoLockTimeout())); | 143 | this, SLOT(autoLockTimeout())); |
142 | connect(metaCheckTimer, SIGNAL(timeout()), | 144 | connect(metaCheckTimer, SIGNAL(timeout()), |
143 | this, SLOT(metaCheckTimeout())); | 145 | this, SLOT(metaCheckTimeout())); |
144 | } | 146 | } |
145 | 147 | ||
146 | DocTimer::~DocTimer() | 148 | DocTimer::~DocTimer() |
147 | { | 149 | { |
148 | delete mpwTimer; | 150 | delete mpwTimer; |
149 | delete autoLockTimer; | 151 | delete autoLockTimer; |
150 | delete metaCheckTimer; | 152 | delete metaCheckTimer; |
151 | } | 153 | } |
152 | 154 | ||
153 | void DocTimer::start(TimerIDs timer) | 155 | void DocTimer::start(TimerIDs timer) |
154 | { | 156 | { |
155 | switch (timer) { | 157 | switch (timer) { |
156 | case id_mpwTimer: | 158 | case id_mpwTimer: |
157 | if (mpwTimer->isActive()) | 159 | if (mpwTimer->isActive()) |
158 | mpwTimer->stop(); | 160 | mpwTimer->stop(); |
159 | doc->setDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW); | 161 | doc->setDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW); |
160 | mpwTimer->start(conf()->confGlobPwTimeout() * 1000, true); | 162 | mpwTimer->start(conf()->confGlobPwTimeout() * 1000, true); |
161 | break; | 163 | break; |
162 | case id_autoLockTimer: | 164 | case id_autoLockTimer: |
163 | if (autoLockTimer->isActive()) | 165 | if (autoLockTimer->isActive()) |
164 | autoLockTimer->stop(); | 166 | autoLockTimer->stop(); |
165 | if (conf()->confGlobLockTimeout() > 0) | 167 | if (conf()->confGlobLockTimeout() > 0) |
166 | autoLockTimer->start(conf()->confGlobLockTimeout() * 1000, true); | 168 | autoLockTimer->start(conf()->confGlobLockTimeout() * 1000, true); |
167 | break; | 169 | break; |
168 | case id_metaCheckTimer: | 170 | case id_metaCheckTimer: |
169 | if (metaCheckTimer->isActive()) | 171 | if (metaCheckTimer->isActive()) |
170 | metaCheckTimer->stop(); | 172 | metaCheckTimer->stop(); |
171 | metaCheckTimer->start(META_CHECK_TIMER_INTERVAL * 1000, true); | 173 | metaCheckTimer->start(META_CHECK_TIMER_INTERVAL * 1000, true); |
172 | break; | 174 | break; |
173 | } | 175 | } |
174 | } | 176 | } |
175 | 177 | ||
176 | void DocTimer::stop(TimerIDs timer) | 178 | void DocTimer::stop(TimerIDs timer) |
177 | { | 179 | { |
178 | switch (timer) { | 180 | switch (timer) { |
179 | case id_mpwTimer: | 181 | case id_mpwTimer: |
180 | mpwTimer->stop(); | 182 | mpwTimer->stop(); |
181 | break; | 183 | break; |
182 | case id_autoLockTimer: | 184 | case id_autoLockTimer: |
183 | autoLockTimer->stop(); | 185 | autoLockTimer->stop(); |
184 | break; | 186 | break; |
185 | case id_metaCheckTimer: | 187 | case id_metaCheckTimer: |
186 | metaCheckTimer->stop(); | 188 | metaCheckTimer->stop(); |
187 | break; | 189 | break; |
188 | } | 190 | } |
189 | } | 191 | } |
190 | 192 | ||
191 | void DocTimer::getLock(TimerIDs timer) | 193 | void DocTimer::getLock(TimerIDs timer) |
192 | { | 194 | { |
193 | switch (timer) { | 195 | switch (timer) { |
194 | case id_mpwTimer: | 196 | case id_mpwTimer: |
195 | ++mpwLock; | 197 | ++mpwLock; |
196 | break; | 198 | break; |
197 | case id_autoLockTimer: | 199 | case id_autoLockTimer: |
198 | ++autoLockLock; | 200 | ++autoLockLock; |
199 | break; | 201 | break; |
200 | case id_metaCheckTimer: | 202 | case id_metaCheckTimer: |
201 | ++metaCheckLock; | 203 | ++metaCheckLock; |
202 | break; | 204 | break; |
203 | } | 205 | } |
204 | } | 206 | } |
205 | 207 | ||
206 | void DocTimer::putLock(TimerIDs timer) | 208 | void DocTimer::putLock(TimerIDs timer) |
207 | { | 209 | { |
208 | switch (timer) { | 210 | switch (timer) { |
209 | case id_mpwTimer: | 211 | case id_mpwTimer: |
210 | if (mpwLock) | 212 | if (mpwLock) |
211 | --mpwLock; | 213 | --mpwLock; |
212 | break; | 214 | break; |
213 | case id_autoLockTimer: | 215 | case id_autoLockTimer: |
214 | if (autoLockLock) | 216 | if (autoLockLock) |
215 | --autoLockLock; | 217 | --autoLockLock; |
216 | break; | 218 | break; |
217 | case id_metaCheckTimer: | 219 | case id_metaCheckTimer: |
218 | if (metaCheckLock) | 220 | if (metaCheckLock) |
219 | --metaCheckLock; | 221 | --metaCheckLock; |
220 | break; | 222 | break; |
221 | } | 223 | } |
222 | } | 224 | } |
223 | 225 | ||
224 | void DocTimer::mpwTimeout() | 226 | void DocTimer::mpwTimeout() |
225 | { | 227 | { |
diff --git a/pwmanager/pwmanager/pwmdoc.h b/pwmanager/pwmanager/pwmdoc.h index 9650d55..193247e 100644 --- a/pwmanager/pwmanager/pwmdoc.h +++ b/pwmanager/pwmanager/pwmdoc.h | |||
@@ -1,251 +1,251 @@ | |||
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 2.0 of pwmanager | 14 | * This file is originaly based on version 2.0 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 | 22 | ||
23 | #define PWM_FILE_VER (static_cast<char>(0x05)) | 23 | #define PWM_FILE_VER (static_cast<char>(0x05)) |
24 | 24 | ||
25 | #define PWM_HASH_SHA1 (static_cast<char>(0x01)) | 25 | #define PWM_HASH_SHA1 (static_cast<char>(0x01)) |
26 | #define PWM_HASH_SHA256 (static_cast<char>(0x02)) | 26 | #define PWM_HASH_SHA256 (static_cast<char>(0x02)) |
27 | #define PWM_HASH_SHA384 (static_cast<char>(0x03)) | 27 | #define PWM_HASH_SHA384 (static_cast<char>(0x03)) |
28 | #define PWM_HASH_SHA512 (static_cast<char>(0x04)) | 28 | #define PWM_HASH_SHA512 (static_cast<char>(0x04)) |
29 | #define PWM_HASH_MD5 (static_cast<char>(0x05)) | 29 | #define PWM_HASH_MD5 (static_cast<char>(0x05)) |
30 | #define PWM_HASH_RMD160 (static_cast<char>(0x06)) | 30 | #define PWM_HASH_RMD160 (static_cast<char>(0x06)) |
31 | #define PWM_HASH_TIGER (static_cast<char>(0x07)) | 31 | #define PWM_HASH_TIGER (static_cast<char>(0x07)) |
32 | 32 | ||
33 | #define PWM_CRYPT_BLOWFISH(static_cast<char>(0x01)) | 33 | #define PWM_CRYPT_BLOWFISH(static_cast<char>(0x01)) |
34 | #define PWM_CRYPT_AES128(static_cast<char>(0x02)) | 34 | #define PWM_CRYPT_AES128(static_cast<char>(0x02)) |
35 | #define PWM_CRYPT_AES192(static_cast<char>(0x03)) | 35 | #define PWM_CRYPT_AES192(static_cast<char>(0x03)) |
36 | #define PWM_CRYPT_AES256(static_cast<char>(0x04)) | 36 | #define PWM_CRYPT_AES256(static_cast<char>(0x04)) |
37 | #define PWM_CRYPT_3DES (static_cast<char>(0x05)) | 37 | #define PWM_CRYPT_3DES (static_cast<char>(0x05)) |
38 | #define PWM_CRYPT_TWOFISH(static_cast<char>(0x06)) | 38 | #define PWM_CRYPT_TWOFISH(static_cast<char>(0x06)) |
39 | #define PWM_CRYPT_TWOFISH128(static_cast<char>(0x07)) | 39 | #define PWM_CRYPT_TWOFISH128(static_cast<char>(0x07)) |
40 | 40 | ||
41 | #define PWM_COMPRESS_NONE(static_cast<char>(0x00)) | 41 | #define PWM_COMPRESS_NONE(static_cast<char>(0x00)) |
42 | #define PWM_COMPRESS_GZIP(static_cast<char>(0x01)) | 42 | #define PWM_COMPRESS_GZIP(static_cast<char>(0x01)) |
43 | #define PWM_COMPRESS_BZIP2(static_cast<char>(0x02)) | 43 | #define PWM_COMPRESS_BZIP2(static_cast<char>(0x02)) |
44 | 44 | ||
45 | #define DEFAULT_MAX_ENTRIES(~(static_cast<unsigned int>(0))) | 45 | #define DEFAULT_MAX_ENTRIES(~(static_cast<unsigned int>(0))) |
46 | #define FILE_ID_HEADER "PWM_PASSWORD_FILE" | 46 | #define FILE_ID_HEADER "PWM_PASSWORD_FILE" |
47 | 47 | ||
48 | 48 | ||
49 | #include "pwmexception.h" | 49 | #include "pwmexception.h" |
50 | #include "pwmdocui.h" | 50 | #include "pwmdocui.h" |
51 | #include "configuration.h" | ||
52 | 51 | ||
53 | #include <qobject.h> | 52 | #include <qobject.h> |
54 | #include <qtimer.h> | 53 | #include <qtimer.h> |
55 | #include <qdatetime.h> | 54 | #include <qdatetime.h> |
56 | 55 | ||
57 | #include <kprocess.h> | 56 | #include <kprocess.h> |
58 | 57 | ||
59 | #ifndef PWM_EMBEDDED | 58 | #ifndef PWM_EMBEDDED |
59 | #include "configuration.h" | ||
60 | #else | 60 | #else |
61 | #include <kapplication.h> | 61 | #include <kapplication.h> |
62 | #endif | 62 | #endif |
63 | 63 | ||
64 | #include <string> | 64 | #include <string> |
65 | #include <vector> | 65 | #include <vector> |
66 | #include <utility> | 66 | #include <utility> |
67 | 67 | ||
68 | using std::vector; | 68 | using std::vector; |
69 | using std::string; | 69 | using std::string; |
70 | using std::pair; | 70 | using std::pair; |
71 | 71 | ||
72 | /* used in findEntry() function */ | 72 | /* used in findEntry() function */ |
73 | #define SEARCH_IN_DESC (1) | 73 | #define SEARCH_IN_DESC (1) |
74 | #define SEARCH_IN_NAME (1 << 1) | 74 | #define SEARCH_IN_NAME (1 << 1) |
75 | #define SEARCH_IN_PW (1 << 2) | 75 | #define SEARCH_IN_PW (1 << 2) |
76 | #define SEARCH_IN_COMMENT(1 << 3) | 76 | #define SEARCH_IN_COMMENT(1 << 3) |
77 | #define SEARCH_IN_URL (1 << 4) | 77 | #define SEARCH_IN_URL (1 << 4) |
78 | #define SEARCH_IN_LAUNCHER(1 << 5) | 78 | #define SEARCH_IN_LAUNCHER(1 << 5) |
79 | #define SEARCH_IN_ALL (SEARCH_IN_DESC | SEARCH_IN_NAME| \ | 79 | #define SEARCH_IN_ALL (SEARCH_IN_DESC | SEARCH_IN_NAME| \ |
80 | SEARCH_IN_PW | SEARCH_IN_COMMENT| \ | 80 | SEARCH_IN_PW | SEARCH_IN_COMMENT| \ |
81 | SEARCH_IN_URL| SEARCH_IN_LAUNCHER) | 81 | SEARCH_IN_URL| SEARCH_IN_LAUNCHER) |
82 | 82 | ||
83 | /** document deeplocked. Data is out for lunch to disk */ | 83 | /** document deeplocked. Data is out for lunch to disk */ |
84 | #define DOC_STAT_DEEPLOCKED (1) | 84 | #define DOC_STAT_DEEPLOCKED (1) |
85 | /** encrypted document on disk is dirty. data has to go to disk. */ | 85 | /** encrypted document on disk is dirty. data has to go to disk. */ |
86 | #define DOC_STAT_DISK_DIRTY (1 << 1) | 86 | #define DOC_STAT_DISK_DIRTY (1 << 1) |
87 | /** we are using a chipcard to encrypt the data */ | 87 | /** we are using a chipcard to encrypt the data */ |
88 | #define DOC_STAT_USE_CHIPCARD (1 << 2) | 88 | #define DOC_STAT_USE_CHIPCARD (1 << 2) |
89 | /** use "currentPw" to unlock. (This flag is set/unset by a timer) */ | 89 | /** use "currentPw" to unlock. (This flag is set/unset by a timer) */ |
90 | #define DOC_STAT_UNLOCK_WITHOUT_PW(1 << 3) | 90 | #define DOC_STAT_UNLOCK_WITHOUT_PW(1 << 3) |
91 | 91 | ||
92 | class PwMDoc; | 92 | class PwMDoc; |
93 | class PwMView; | 93 | class PwMView; |
94 | class QFile; | 94 | class QFile; |
95 | 95 | ||
96 | /* meta data for a PwMDataItem */ | 96 | /* meta data for a PwMDataItem */ |
97 | struct PwMMetaData | 97 | struct PwMMetaData |
98 | { | 98 | { |
99 | PwMMetaData() | 99 | PwMMetaData() |
100 | : updateInt (0) | 100 | : updateInt (0) |
101 | { } | 101 | { } |
102 | /** creation date of the PwMDataItem to which | 102 | /** creation date of the PwMDataItem to which |
103 | * this meta data belongs. | 103 | * this meta data belongs. |
104 | */ | 104 | */ |
105 | QDateTimecreate; | 105 | QDateTimecreate; |
106 | /** becomes valid on this date */ | 106 | /** becomes valid on this date */ |
107 | QDateTimevalid; | 107 | QDateTimevalid; |
108 | /** expire date */ | 108 | /** expire date */ |
109 | QDateTimeexpire; | 109 | QDateTimeexpire; |
110 | /** update date (last updated at this date) */ | 110 | /** update date (last updated at this date) */ |
111 | QDateTimeupdate; | 111 | QDateTimeupdate; |
112 | /** update interval (in minutes). Time since the | 112 | /** update interval (in minutes). Time since the |
113 | * last update to remind the user to update the item. | 113 | * last update to remind the user to update the item. |
114 | * 0 disables. | 114 | * 0 disables. |
115 | */ | 115 | */ |
116 | unsigned long updateInt; | 116 | unsigned long updateInt; |
117 | 117 | ||
118 | //US ENH: enhancements of the filestructure | 118 | //US ENH: enhancements of the filestructure |
119 | /* each entry gets a unique id assigned */ | 119 | /* each entry gets a unique id assigned */ |
120 | QString uniqueid; | 120 | QString uniqueid; |
121 | 121 | ||
122 | 122 | ||
123 | void clear() | 123 | void clear() |
124 | { | 124 | { |
125 | create = QDateTime(); | 125 | create = QDateTime(); |
126 | expire = QDateTime(); | 126 | expire = QDateTime(); |
127 | update = QDateTime(); | 127 | update = QDateTime(); |
128 | updateInt = 0; | 128 | updateInt = 0; |
129 | uniqueid = KApplication::randomString(8); | 129 | uniqueid = KApplication::randomString(8); |
130 | } | 130 | } |
131 | inline bool isValid() const | 131 | inline bool isValid() const |
132 | { | 132 | { |
133 | if (valid.isNull()) | 133 | if (valid.isNull()) |
134 | return true; | 134 | return true; |
135 | return (valid < QDateTime::currentDateTime()); | 135 | return (valid < QDateTime::currentDateTime()); |
136 | } | 136 | } |
137 | inline bool isExpired() const | 137 | inline bool isExpired() const |
138 | { | 138 | { |
139 | if (expire.isNull()) | 139 | if (expire.isNull()) |
140 | return false; | 140 | return false; |
141 | return (expire < QDateTime::currentDateTime()); | 141 | return (expire < QDateTime::currentDateTime()); |
142 | } | 142 | } |
143 | inline bool isUpdateIntOver() const | 143 | inline bool isUpdateIntOver() const |
144 | { | 144 | { |
145 | if (updateInt == 0 || | 145 | if (updateInt == 0 || |
146 | update.isNull()) | 146 | update.isNull()) |
147 | return false; | 147 | return false; |
148 | QDateTime d(update); | 148 | QDateTime d(update); |
149 | return (d.addSecs(updateInt * 60) < QDateTime::currentDateTime()); | 149 | return (d.addSecs(updateInt * 60) < QDateTime::currentDateTime()); |
150 | } | 150 | } |
151 | }; | 151 | }; |
152 | 152 | ||
153 | struct PwMDataItem | 153 | struct PwMDataItem |
154 | { | 154 | { |
155 | PwMDataItem() | 155 | PwMDataItem() |
156 | : lockStat (true) | 156 | : lockStat (true) |
157 | , listViewPos (-1) | 157 | , listViewPos (-1) |
158 | , binary (false) | 158 | , binary (false) |
159 | , rev (0) | 159 | , rev (0) |
160 | { } | 160 | { } |
161 | 161 | ||
162 | /** password description */ | 162 | /** password description */ |
163 | stringdesc; | 163 | stringdesc; |
164 | /** user-name */ | 164 | /** user-name */ |
165 | stringname; | 165 | stringname; |
166 | /** the password itself */ | 166 | /** the password itself */ |
167 | stringpw; | 167 | stringpw; |
168 | /** some comment */ | 168 | /** some comment */ |
169 | stringcomment; | 169 | stringcomment; |
170 | /** an URL string */ | 170 | /** an URL string */ |
171 | stringurl; | 171 | stringurl; |
172 | /** launcher. Can be executed as a system() command */ | 172 | /** launcher. Can be executed as a system() command */ |
173 | stringlauncher; | 173 | stringlauncher; |
174 | /** locking status. If locked (true), pw is not emitted through getEntry() */ | 174 | /** locking status. If locked (true), pw is not emitted through getEntry() */ |
175 | boollockStat; | 175 | boollockStat; |
176 | /** position of this item in main "list-view" | 176 | /** position of this item in main "list-view" |
177 | * If -1, the position is not yet specified and should be appended to the list | 177 | * If -1, the position is not yet specified and should be appended to the list |
178 | */ | 178 | */ |
179 | intlistViewPos; | 179 | intlistViewPos; |
180 | /** does this entry contain binary data? */ | 180 | /** does this entry contain binary data? */ |
181 | bool binary; | 181 | bool binary; |
182 | /** meta data for this data item. */ | 182 | /** meta data for this data item. */ |
183 | PwMMetaData meta; | 183 | PwMMetaData meta; |
184 | /** data revision counter. This counter can be used | 184 | /** data revision counter. This counter can be used |
185 | * to easily, efficiently determine if this data item | 185 | * to easily, efficiently determine if this data item |
186 | * has changed since some time. | 186 | * has changed since some time. |
187 | * This counter is incremented on every update. | 187 | * This counter is incremented on every update. |
188 | */ | 188 | */ |
189 | unsigned int rev; | 189 | unsigned int rev; |
190 | 190 | ||
191 | void clear(bool clearMeta = true) | 191 | void clear(bool clearMeta = true) |
192 | { | 192 | { |
193 | /* NOTE: Don't use .clear() here to be | 193 | /* NOTE: Don't use .clear() here to be |
194 | * backward compatible with gcc-2 (Debian Woody) | 194 | * backward compatible with gcc-2 (Debian Woody) |
195 | */ | 195 | */ |
196 | desc = ""; | 196 | desc = ""; |
197 | name = ""; | 197 | name = ""; |
198 | pw = ""; | 198 | pw = ""; |
199 | comment = ""; | 199 | comment = ""; |
200 | url = ""; | 200 | url = ""; |
201 | launcher = ""; | 201 | launcher = ""; |
202 | lockStat = true; | 202 | lockStat = true; |
203 | listViewPos = -1; | 203 | listViewPos = -1; |
204 | binary = false; | 204 | binary = false; |
205 | if (clearMeta) | 205 | if (clearMeta) |
206 | meta.clear(); | 206 | meta.clear(); |
207 | } | 207 | } |
208 | }; | 208 | }; |
209 | 209 | ||
210 | struct PwMCategoryItem | 210 | struct PwMCategoryItem |
211 | { | 211 | { |
212 | /** all PwMDataItems (all passwords) within this category */ | 212 | /** all PwMDataItems (all passwords) within this category */ |
213 | vector<PwMDataItem>d; | 213 | vector<PwMDataItem>d; |
214 | /** category name/description */ | 214 | /** category name/description */ |
215 | string name; | 215 | string name; |
216 | 216 | ||
217 | void clear() | 217 | void clear() |
218 | { | 218 | { |
219 | d.clear(); | 219 | d.clear(); |
220 | name = ""; | 220 | name = ""; |
221 | } | 221 | } |
222 | }; | 222 | }; |
223 | 223 | ||
224 | /** "Function Object" for sort()ing PwMDataItem::listViewPos */ | 224 | /** "Function Object" for sort()ing PwMDataItem::listViewPos */ |
225 | class dta_lvp_greater | 225 | class dta_lvp_greater |
226 | { | 226 | { |
227 | public: | 227 | public: |
228 | bool operator() (const pair<unsigned int, unsigned int> &d1, | 228 | bool operator() (const pair<unsigned int, unsigned int> &d1, |
229 | const pair<unsigned int, unsigned int> &d2) | 229 | const pair<unsigned int, unsigned int> &d2) |
230 | { | 230 | { |
231 | return d1.second > d2.second; | 231 | return d1.second > d2.second; |
232 | } | 232 | } |
233 | }; | 233 | }; |
234 | 234 | ||
235 | /** list of PwMDoc documents and it's IDs */ | 235 | /** list of PwMDoc documents and it's IDs */ |
236 | class PwMDocList | 236 | class PwMDocList |
237 | { | 237 | { |
238 | public: | 238 | public: |
239 | struct listItem | 239 | struct listItem |
240 | { | 240 | { |
241 | /** document filename (known as ID, here) */ | 241 | /** document filename (known as ID, here) */ |
242 | string docId; | 242 | string docId; |
243 | /** pointer to the document class */ | 243 | /** pointer to the document class */ |
244 | PwMDoc *doc; | 244 | PwMDoc *doc; |
245 | }; | 245 | }; |
246 | 246 | ||
247 | PwMDocList() {} | 247 | PwMDocList() {} |
248 | 248 | ||
249 | /** add a new item to the list */ | 249 | /** add a new item to the list */ |
250 | void add(PwMDoc *doc, const string &id); | 250 | void add(PwMDoc *doc, const string &id); |
251 | /** changes the contents of an existing item */ | 251 | /** changes the contents of an existing item */ |
diff --git a/pwmanager/pwmanager/pwmdocui.cpp b/pwmanager/pwmanager/pwmdocui.cpp index b308b40..3993fa8 100644 --- a/pwmanager/pwmanager/pwmdocui.cpp +++ b/pwmanager/pwmanager/pwmdocui.cpp | |||
@@ -1,230 +1,231 @@ | |||
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 "pwmdocui.h" | 20 | #include "pwmdocui.h" |
21 | #include "setmasterpwwndimpl.h" | 21 | #include "setmasterpwwndimpl.h" |
22 | #include "getmasterpwwndimpl.h" | 22 | #include "getmasterpwwndimpl.h" |
23 | #include "pwmexception.h" | 23 | #include "pwmexception.h" |
24 | #include "getkeycardwnd.h" | 24 | #include "getkeycardwnd.h" |
25 | #include "pwm.h" | 25 | #include "pwm.h" |
26 | #include "globalstuff.h" | 26 | #include "globalstuff.h" |
27 | #include "spinforsignal.h" | 27 | #include "spinforsignal.h" |
28 | 28 | ||
29 | #include <qlineedit.h> | 29 | #include <qlineedit.h> |
30 | #include <qtabwidget.h> | 30 | #include <qtabwidget.h> |
31 | 31 | ||
32 | #include <kmessagebox.h> | 32 | #include <kmessagebox.h> |
33 | #include <kfiledialog.h> | 33 | #include <kfiledialog.h> |
34 | 34 | ||
35 | #ifndef PWM_EMBEDDED | 35 | #ifndef PWM_EMBEDDED |
36 | #include <kwin.h> | 36 | #include <kwin.h> |
37 | #else | 37 | #else |
38 | #include <qdir.h> | 38 | #include <qdir.h> |
39 | #include "pwmprefs.h" | ||
39 | #endif | 40 | #endif |
40 | 41 | ||
41 | 42 | ||
42 | #ifdef CONFIG_KEYCARD | 43 | #ifdef CONFIG_KEYCARD |
43 | # include "pwmkeycard.h" | 44 | # include "pwmkeycard.h" |
44 | #endif | 45 | #endif |
45 | 46 | ||
46 | 47 | ||
47 | PwMDocUi::PwMDocUi(QObject *parent, const char *name) | 48 | PwMDocUi::PwMDocUi(QObject *parent, const char *name) |
48 | : QObject(parent, name) | 49 | : QObject(parent, name) |
49 | { | 50 | { |
50 | currentView = 0; | 51 | currentView = 0; |
51 | keyCard = 0; | 52 | keyCard = 0; |
52 | } | 53 | } |
53 | 54 | ||
54 | PwMDocUi::~PwMDocUi() | 55 | PwMDocUi::~PwMDocUi() |
55 | { | 56 | { |
56 | } | 57 | } |
57 | 58 | ||
58 | QString PwMDocUi::requestMpw(bool chipcard) | 59 | QString PwMDocUi::requestMpw(bool chipcard) |
59 | { | 60 | { |
60 | QString pw; | 61 | QString pw; |
61 | 62 | ||
62 | if (chipcard) { | 63 | if (chipcard) { |
63 | #ifdef CONFIG_KEYCARD | 64 | #ifdef CONFIG_KEYCARD |
64 | PWM_ASSERT(keyCard); | 65 | PWM_ASSERT(keyCard); |
65 | uint32_t id; | 66 | uint32_t id; |
66 | string ret; | 67 | string ret; |
67 | SpinForSignal *spinner = keyCard->getSpinner(); | 68 | SpinForSignal *spinner = keyCard->getSpinner(); |
68 | connect(keyCard, SIGNAL(keyAvailable(uint32_t, const string &)), | 69 | connect(keyCard, SIGNAL(keyAvailable(uint32_t, const string &)), |
69 | spinner, SLOT(u32_str_slot(uint32_t, const string &))); | 70 | spinner, SLOT(u32_str_slot(uint32_t, const string &))); |
70 | keyCard->getKey(); | 71 | keyCard->getKey(); |
71 | spinner->spin(&id, &ret); | 72 | spinner->spin(&id, &ret); |
72 | disconnect(keyCard, SIGNAL(keyAvailable(uint32_t, const string &)), | 73 | disconnect(keyCard, SIGNAL(keyAvailable(uint32_t, const string &)), |
73 | spinner, SLOT(u32_str_slot(uint32_t, const string &))); | 74 | spinner, SLOT(u32_str_slot(uint32_t, const string &))); |
74 | if (ret == "") | 75 | if (ret == "") |
75 | return ""; | 76 | return ""; |
76 | pw = ret.c_str(); | 77 | pw = ret.c_str(); |
77 | #else // CONFIG_KEYCARD | 78 | #else // CONFIG_KEYCARD |
78 | no_keycard_support_msg_box(currentView); | 79 | no_keycard_support_msg_box(currentView); |
79 | #endif // CONFIG_KEYCARD | 80 | #endif // CONFIG_KEYCARD |
80 | } else { | 81 | } else { |
81 | GetMasterPwWndImpl pwWnd; | 82 | GetMasterPwWndImpl pwWnd; |
82 | #ifndef PWM_EMBEDDED | 83 | #ifndef PWM_EMBEDDED |
83 | KWin::setState(pwWnd.winId(), NET::StaysOnTop); | 84 | KWin::setState(pwWnd.winId(), NET::StaysOnTop); |
84 | #endif | 85 | #endif |
85 | if (pwWnd.exec() != 1) | 86 | if (pwWnd.exec() != 1) |
86 | return ""; | 87 | return ""; |
87 | pw = pwWnd.pwLineEdit->text(); | 88 | pw = pwWnd.pwLineEdit->text(); |
88 | } | 89 | } |
89 | 90 | ||
90 | return pw; | 91 | return pw; |
91 | } | 92 | } |
92 | 93 | ||
93 | QString PwMDocUi::requestNewMpw(bool *chipcard) | 94 | QString PwMDocUi::requestNewMpw(bool *chipcard) |
94 | { | 95 | { |
95 | QString pw; | 96 | QString pw; |
96 | SetMasterPwWndImpl pwWnd(currentView); | 97 | SetMasterPwWndImpl pwWnd(currentView); |
97 | pwWnd.setPwMKeyCard(keyCard); | 98 | pwWnd.setPwMKeyCard(keyCard); |
98 | #ifndef PWM_EMBEDDED | 99 | #ifndef PWM_EMBEDDED |
99 | if (!chipcard) { | 100 | if (!chipcard) { |
100 | pwWnd.mainTab->removePage(pwWnd.mainTab->page(1)); | 101 | pwWnd.mainTab->removePage(pwWnd.mainTab->page(1)); |
101 | } | 102 | } |
102 | #else | 103 | #else |
103 | qDebug("PwMDocUi::requestNewMpw must be implemented"); | 104 | qDebug("PwMDocUi::requestNewMpw must be implemented"); |
104 | #endif | 105 | #endif |
105 | 106 | ||
106 | if (pwWnd.exec() != 1) | 107 | if (pwWnd.exec() != 1) |
107 | return ""; | 108 | return ""; |
108 | pw = pwWnd.getPw(chipcard).c_str(); | 109 | pw = pwWnd.getPw(chipcard).c_str(); |
109 | 110 | ||
110 | return pw; | 111 | return pw; |
111 | } | 112 | } |
112 | 113 | ||
113 | QString PwMDocUi::requestMpwChange(const QString *currentPw, bool *chipcard) | 114 | QString PwMDocUi::requestMpwChange(const QString *currentPw, bool *chipcard) |
114 | { | 115 | { |
115 | QString pw(requestMpw(*chipcard)); | 116 | QString pw(requestMpw(*chipcard)); |
116 | if (pw == "") | 117 | if (pw == "") |
117 | return ""; | 118 | return ""; |
118 | if (pw != *currentPw) { | 119 | if (pw != *currentPw) { |
119 | wrongMpwMsgBox(*chipcard); | 120 | wrongMpwMsgBox(*chipcard); |
120 | return ""; | 121 | return ""; |
121 | } | 122 | } |
122 | 123 | ||
123 | pw = requestNewMpw(chipcard); | 124 | pw = requestNewMpw(chipcard); |
124 | if (pw == "") | 125 | if (pw == "") |
125 | return ""; | 126 | return ""; |
126 | return pw; | 127 | return pw; |
127 | } | 128 | } |
128 | 129 | ||
129 | void PwMDocUi::wrongMpwMsgBox(bool chipcard, QString prefix, QString postfix) | 130 | void PwMDocUi::wrongMpwMsgBox(bool chipcard, QString prefix, QString postfix) |
130 | { | 131 | { |
131 | QString msg; | 132 | QString msg; |
132 | if (prefix != "") { | 133 | if (prefix != "") { |
133 | msg += prefix; | 134 | msg += prefix; |
134 | msg += "\n"; | 135 | msg += "\n"; |
135 | } | 136 | } |
136 | 137 | ||
137 | if (chipcard) { | 138 | if (chipcard) { |
138 | msg += i18n("Wrong key-card!\n" | 139 | msg += i18n("Wrong key-card!\n" |
139 | "Please try again with the " | 140 | "Please try again with the " |
140 | "correct key-card."); | 141 | "correct key-card."); |
141 | } else { | 142 | } else { |
142 | msg += i18n("Wrong master-password!\n" | 143 | msg += i18n("Wrong master-password!\n" |
143 | "Please try again."); | 144 | "Please try again."); |
144 | } | 145 | } |
145 | 146 | ||
146 | if (postfix != "") { | 147 | if (postfix != "") { |
147 | msg += "\n"; | 148 | msg += "\n"; |
148 | msg += postfix; | 149 | msg += postfix; |
149 | } | 150 | } |
150 | KMessageBox::error(currentView, msg, | 151 | KMessageBox::error(currentView, msg, |
151 | (chipcard) ? (i18n("wrong chipcard")) | 152 | (chipcard) ? (i18n("wrong chipcard")) |
152 | : (i18n("password error"))); | 153 | : (i18n("password error"))); |
153 | } | 154 | } |
154 | 155 | ||
155 | void PwMDocUi::noMpwMsgBox(bool chipcard, QString prefix, QString postfix) | 156 | void PwMDocUi::noMpwMsgBox(bool chipcard, QString prefix, QString postfix) |
156 | { | 157 | { |
157 | QString msg; | 158 | QString msg; |
158 | if (prefix != "") { | 159 | if (prefix != "") { |
159 | msg += prefix; | 160 | msg += prefix; |
160 | msg += "\n"; | 161 | msg += "\n"; |
161 | } | 162 | } |
162 | 163 | ||
163 | if (chipcard) { | 164 | if (chipcard) { |
164 | msg += i18n("No key-card found!\n" | 165 | msg += i18n("No key-card found!\n" |
165 | "Please insert the " | 166 | "Please insert the " |
166 | "correct key-card."); | 167 | "correct key-card."); |
167 | } else { | 168 | } else { |
168 | msg += i18n("No master-password given!"); | 169 | msg += i18n("No master-password given!"); |
169 | } | 170 | } |
170 | 171 | ||
171 | if (postfix != "") { | 172 | if (postfix != "") { |
172 | msg += "\n"; | 173 | msg += "\n"; |
173 | msg += postfix; | 174 | msg += postfix; |
174 | } | 175 | } |
175 | KMessageBox::error(currentView, msg, | 176 | KMessageBox::error(currentView, msg, |
176 | (chipcard) ? (i18n("no chipcard")) | 177 | (chipcard) ? (i18n("no chipcard")) |
177 | : (i18n("password error"))); | 178 | : (i18n("password error"))); |
178 | } | 179 | } |
179 | 180 | ||
180 | void PwMDocUi::rootAlertMsgBox() | 181 | void PwMDocUi::rootAlertMsgBox() |
181 | { | 182 | { |
182 | KMessageBox::error(currentView, | 183 | KMessageBox::error(currentView, |
183 | i18n("This feature is not available, " | 184 | i18n("This feature is not available, " |
184 | "if you execute PwM with \"root\" " | 185 | "if you execute PwM with \"root\" " |
185 | "UID 0 privileges, for security reasons!"), | 186 | "UID 0 privileges, for security reasons!"), |
186 | i18n("not allowed as root!")); | 187 | i18n("not allowed as root!")); |
187 | } | 188 | } |
188 | 189 | ||
189 | void PwMDocUi::cantDeeplock_notSavedMsgBox() | 190 | void PwMDocUi::cantDeeplock_notSavedMsgBox() |
190 | { | 191 | { |
191 | KMessageBox::error(currentView, | 192 | KMessageBox::error(currentView, |
192 | i18n("Can't deep-lock, because the document " | 193 | i18n("Can't deep-lock, because the document " |
193 | "hasn't been saved, yet. Please save " | 194 | "hasn't been saved, yet. Please save " |
194 | "to a file and try again."), | 195 | "to a file and try again."), |
195 | i18n("not saved, yet")); | 196 | i18n("not saved, yet")); |
196 | } | 197 | } |
197 | 198 | ||
198 | void PwMDocUi::gpmPwLenErrMsgBox() | 199 | void PwMDocUi::gpmPwLenErrMsgBox() |
199 | { | 200 | { |
200 | KMessageBox::error(currentView, | 201 | KMessageBox::error(currentView, |
201 | i18n("GPasman does not support passwords " | 202 | i18n("GPasman does not support passwords " |
202 | "shorter than 4 characters! Please try " | 203 | "shorter than 4 characters! Please try " |
203 | "again with a longer password."), | 204 | "again with a longer password."), |
204 | i18n("password too short")); | 205 | i18n("password too short")); |
205 | } | 206 | } |
206 | 207 | ||
207 | int PwMDocUi::dirtyAskSave(const QString &docTitle) | 208 | int PwMDocUi::dirtyAskSave(const QString &docTitle) |
208 | { | 209 | { |
209 | int ret; | 210 | int ret; |
210 | #ifndef PWM_EMBEDDED | 211 | #ifndef PWM_EMBEDDED |
211 | ret = KMessageBox::questionYesNoCancel(currentView, | 212 | ret = KMessageBox::questionYesNoCancel(currentView, |
212 | i18n("The list \"") + | 213 | i18n("The list \"") + |
213 | docTitle + | 214 | docTitle + |
214 | i18n | 215 | i18n |
215 | ("\" has been modified.\n" | 216 | ("\" has been modified.\n" |
216 | "Do you want to save it?"), | 217 | "Do you want to save it?"), |
217 | i18n("save?")); | 218 | i18n("save?")); |
218 | if (ret == KMessageBox::Yes) { | 219 | if (ret == KMessageBox::Yes) { |
219 | return 0; | 220 | return 0; |
220 | } else if (ret == KMessageBox::No) { | 221 | } else if (ret == KMessageBox::No) { |
221 | return 1; | 222 | return 1; |
222 | } | 223 | } |
223 | #else | 224 | #else |
224 | ret = KMessageBox::warningYesNoCancel(currentView, | 225 | ret = KMessageBox::warningYesNoCancel(currentView, |
225 | i18n("The list \"") + | 226 | i18n("The list \"") + |
226 | docTitle + | 227 | docTitle + |
227 | i18n | 228 | i18n |
228 | ("\" has been modified.\n" | 229 | ("\" has been modified.\n" |
229 | "Do you want to save it?"), | 230 | "Do you want to save it?"), |
230 | i18n("save?")); | 231 | i18n("save?")); |
diff --git a/pwmanager/pwmanager/pwminit.cpp b/pwmanager/pwmanager/pwminit.cpp index 2f1aa4e..8946443 100644 --- a/pwmanager/pwmanager/pwminit.cpp +++ b/pwmanager/pwmanager/pwminit.cpp | |||
@@ -1,340 +1,357 @@ | |||
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 "configuration.h" | ||
22 | #include "randomizer.h" | 21 | #include "randomizer.h" |
23 | 22 | ||
24 | #ifndef PWM_EMBEDDED | 23 | #ifndef PWM_EMBEDDED |
25 | #include "selftest.h" | 24 | #include "selftest.h" |
25 | #include "configuration.h" | ||
26 | #else | ||
27 | #include "pwmprefs.h" | ||
26 | #endif | 28 | #endif |
27 | 29 | ||
28 | #include "pwm.h" | 30 | #include "pwm.h" |
29 | #include "pwmexception.h" | 31 | #include "pwmexception.h" |
30 | #include "pwmtray.h" | 32 | #include "pwmtray.h" |
31 | #include "pwmdoc.h" | 33 | #include "pwmdoc.h" |
32 | 34 | ||
33 | #ifdef CONFIG_KWALLETIF | 35 | #ifdef CONFIG_KWALLETIF |
34 | # include "kwalletemu.h" | 36 | # include "kwalletemu.h" |
35 | #endif // CONFIG_KWALLETIF | 37 | #endif // CONFIG_KWALLETIF |
36 | #ifdef CONFIG_KEYCARD | 38 | #ifdef CONFIG_KEYCARD |
37 | # include "pwmkeycard.h" | 39 | # include "pwmkeycard.h" |
38 | #endif // CONFIG_KEYCARD | 40 | #endif // CONFIG_KEYCARD |
39 | 41 | ||
40 | #include <qmessagebox.h> | 42 | #include <qmessagebox.h> |
41 | 43 | ||
42 | #include <kmessagebox.h> | 44 | #include <kmessagebox.h> |
43 | #ifndef PWM_EMBEDDED | 45 | #ifndef PWM_EMBEDDED |
44 | #include <kcmdlineargs.h> | 46 | #include <kcmdlineargs.h> |
45 | #include <kwin.h> | 47 | #include <kwin.h> |
46 | #include <dcopclient.h> | 48 | #include <dcopclient.h> |
47 | #endif | 49 | #endif |
48 | 50 | ||
49 | #include <kapplication.h> | 51 | #include <kapplication.h> |
50 | #include <kiconloader.h> | 52 | #include <kiconloader.h> |
51 | 53 | ||
52 | #include <signal.h> | 54 | #include <signal.h> |
53 | 55 | ||
54 | static PwMInit *sig_init_pointer; | 56 | static PwMInit *sig_init_pointer; |
55 | static NOREGPARM void sig_handler(int signum) | 57 | static NOREGPARM void sig_handler(int signum) |
56 | { | 58 | { |
57 | switch (signum) { | 59 | switch (signum) { |
58 | case SIGINT: | 60 | case SIGINT: |
59 | case SIGTERM: | 61 | case SIGTERM: |
60 | sig_init_pointer->shutdownApp(20 + signum); | 62 | sig_init_pointer->shutdownApp(20 + signum); |
61 | break; | 63 | break; |
62 | default: | 64 | default: |
63 | printDebug(string("unhandled signal ") | 65 | printDebug(string("unhandled signal ") |
64 | + tostr(signum)); | 66 | + tostr(signum)); |
65 | } | 67 | } |
66 | } | 68 | } |
67 | 69 | ||
68 | 70 | ||
69 | 71 | ||
70 | 72 | ||
71 | PwMInit::PwMInit(PwMApplication *_app) | 73 | PwMInit::PwMInit(PwMApplication *_app) |
72 | : runStatus (unknown) | 74 | : runStatus (unknown) |
73 | , _curWidget (0) | 75 | , _curWidget (0) |
74 | , _dcopClient (0) | 76 | , _dcopClient (0) |
75 | , _kwalletEmu (0) | 77 | , _kwalletEmu (0) |
76 | , _keycard (0) | 78 | , _keycard (0) |
77 | , _tray (0) | 79 | , _tray (0) |
78 | { | 80 | { |
79 | sig_init_pointer = this; | 81 | sig_init_pointer = this; |
80 | app = _app; | 82 | app = _app; |
81 | } | 83 | } |
82 | 84 | ||
83 | PwMInit::~PwMInit() | 85 | PwMInit::~PwMInit() |
84 | { | 86 | { |
85 | #ifndef PWM_EMBEDDED | 87 | #ifndef PWM_EMBEDDED |
86 | SelfTest::cancel(); | 88 | SelfTest::cancel(); |
87 | // close all open mainwnds | 89 | // close all open mainwnds |
88 | QValueList<PwM *>::iterator i = _mainWndList.begin(), | 90 | QValueList<PwM *>::iterator i = _mainWndList.begin(), |
89 | end = _mainWndList.end(); | 91 | end = _mainWndList.end(); |
90 | 92 | ||
91 | #else | 93 | #else |
92 | // close all open mainwnds | 94 | // close all open mainwnds |
93 | QValueList<PwM *>::Iterator i = _mainWndList.begin(), | 95 | QValueList<PwM *>::Iterator i = _mainWndList.begin(), |
94 | end = _mainWndList.end(); | 96 | end = _mainWndList.end(); |
95 | #endif | 97 | #endif |
96 | while (i != end) { | 98 | while (i != end) { |
97 | disconnect(*i, SIGNAL(closed(PwM *)), | 99 | disconnect(*i, SIGNAL(closed(PwM *)), |
98 | this, SLOT(mainWndClosed(PwM *))); | 100 | this, SLOT(mainWndClosed(PwM *))); |
99 | delete *i; | 101 | delete *i; |
100 | ++i; | 102 | ++i; |
101 | } | 103 | } |
102 | _mainWndList.clear(); | 104 | _mainWndList.clear(); |
103 | // close all remaining open documents | 105 | // close all remaining open documents |
104 | PwMDocList *_dl = PwMDoc::getOpenDocList(); | 106 | PwMDocList *_dl = PwMDoc::getOpenDocList(); |
105 | vector<PwMDocList::listItem> dl = *(_dl->getList()); | 107 | vector<PwMDocList::listItem> dl = *(_dl->getList()); |
106 | vector<PwMDocList::listItem>::iterator i2 = dl.begin(), | 108 | vector<PwMDocList::listItem>::iterator i2 = dl.begin(), |
107 | end2 = dl.end(); | 109 | end2 = dl.end(); |
108 | while (i2 != end2) { | 110 | while (i2 != end2) { |
109 | delete (*i2).doc; | 111 | delete (*i2).doc; |
110 | ++i2; | 112 | ++i2; |
111 | } | 113 | } |
112 | 114 | ||
113 | #ifdef CONFIG_KWALLETIF | 115 | #ifdef CONFIG_KWALLETIF |
114 | delete_ifnot_null(_kwalletEmu); | 116 | delete_ifnot_null(_kwalletEmu); |
115 | #endif // CONFIG_KWALLETIF | 117 | #endif // CONFIG_KWALLETIF |
116 | #ifdef CONFIG_KEYCARD | 118 | #ifdef CONFIG_KEYCARD |
117 | delete_ifnot_null(_keycard); | 119 | delete_ifnot_null(_keycard); |
118 | #endif // CONFIG_KEYCARD | 120 | #endif // CONFIG_KEYCARD |
119 | delete_ifnot_null(_tray); | 121 | delete_ifnot_null(_tray); |
120 | 122 | ||
121 | Randomizer::cleanup(); | 123 | Randomizer::cleanup(); |
124 | #ifndef PWM_EMBEDDED | ||
122 | Configuration::cleanup(); | 125 | Configuration::cleanup(); |
126 | #endif | ||
123 | } | 127 | } |
124 | 128 | ||
125 | void PwMInit::initializeApp() | 129 | void PwMInit::initializeApp() |
126 | { | 130 | { |
127 | PWM_ASSERT(runStatus == unknown); | 131 | PWM_ASSERT(runStatus == unknown); |
128 | runStatus = init; | 132 | runStatus = init; |
129 | initPosixSignalHandler(); | 133 | initPosixSignalHandler(); |
130 | Randomizer::init(); | 134 | Randomizer::init(); |
135 | #ifndef PWM_EMBEDDED | ||
131 | Configuration::init(); | 136 | Configuration::init(); |
137 | #endif | ||
132 | initDCOP(); | 138 | initDCOP(); |
133 | initKWalletEmu(); | 139 | initKWalletEmu(); |
134 | initKeycard(); | 140 | initKeycard(); |
135 | initTray(); | 141 | initTray(); |
136 | handleCmdLineArgs(); | 142 | handleCmdLineArgs(); |
137 | 143 | ||
138 | bool openDeeplocked = false; | 144 | bool openDeeplocked = false; |
139 | if (conf()->confGlobAutostartDeepLocked() || | 145 | if (conf()->confGlobAutostartDeepLocked() || |
140 | savedCmd.open_deeplocked) | 146 | savedCmd.open_deeplocked) |
141 | openDeeplocked = true; | 147 | openDeeplocked = true; |
142 | if (conf()->confWndAutoMinimizeOnStart() || | 148 | if (conf()->confWndAutoMinimizeOnStart() || |
143 | savedCmd.minToTray) { | 149 | savedCmd.minToTray) { |
144 | PwMDoc *newDoc = createDoc(); | 150 | PwMDoc *newDoc = createDoc(); |
145 | if (!newDoc->openDocUi(newDoc, | 151 | if (!newDoc->openDocUi(newDoc, |
146 | conf()->confGlobAutoStart(), | 152 | conf()->confGlobAutoStart(), |
147 | openDeeplocked)) { | 153 | openDeeplocked)) { |
148 | delete newDoc; | 154 | delete newDoc; |
155 | |||
156 | //US ENH for embedded devices: in the case of failure, open a document the default way | ||
157 | createMainWnd(conf()->confGlobAutoStart(), | ||
158 | openDeeplocked, | ||
159 | true, | ||
160 | 0, | ||
161 | savedCmd.minimized); | ||
162 | |||
163 | |||
164 | |||
165 | |||
149 | } | 166 | } |
150 | } else { | 167 | } else { |
151 | createMainWnd(conf()->confGlobAutoStart(), | 168 | createMainWnd(conf()->confGlobAutoStart(), |
152 | openDeeplocked, | 169 | openDeeplocked, |
153 | true, | 170 | true, |
154 | 0, | 171 | 0, |
155 | savedCmd.minimized); | 172 | savedCmd.minimized); |
156 | } | 173 | } |
157 | 174 | ||
158 | runStatus = running; | 175 | runStatus = running; |
159 | } | 176 | } |
160 | 177 | ||
161 | void PwMInit::shutdownApp(int exitStatus) | 178 | void PwMInit::shutdownApp(int exitStatus) |
162 | { | 179 | { |
163 | printDebug(string("PwMInit::shutdownApp(") | 180 | printDebug(string("PwMInit::shutdownApp(") |
164 | + tostr(exitStatus) + ") called."); | 181 | + tostr(exitStatus) + ") called."); |
165 | PWM_ASSERT((runStatus == running) || (runStatus == init)); | 182 | PWM_ASSERT((runStatus == running) || (runStatus == init)); |
166 | runStatus = shutdown; | 183 | runStatus = shutdown; |
167 | QApplication::exit(exitStatus); | 184 | QApplication::exit(exitStatus); |
168 | /* The destructor of PwMInit is called when control | 185 | /* The destructor of PwMInit is called when control |
169 | * leaves main() | 186 | * leaves main() |
170 | */ | 187 | */ |
171 | } | 188 | } |
172 | 189 | ||
173 | void PwMInit::initPosixSignalHandler() | 190 | void PwMInit::initPosixSignalHandler() |
174 | { | 191 | { |
175 | signal(SIGINT, sig_handler); | 192 | signal(SIGINT, sig_handler); |
176 | signal(SIGTERM, sig_handler); | 193 | signal(SIGTERM, sig_handler); |
177 | } | 194 | } |
178 | 195 | ||
179 | void PwMInit::initDCOP() | 196 | void PwMInit::initDCOP() |
180 | { | 197 | { |
181 | #ifndef PWM_EMBEDDED | 198 | #ifndef PWM_EMBEDDED |
182 | _dcopClient = app->dcopClient(); | 199 | _dcopClient = app->dcopClient(); |
183 | _dcopClient->setNotifications(true); | 200 | _dcopClient->setNotifications(true); |
184 | #endif | 201 | #endif |
185 | 202 | ||
186 | } | 203 | } |
187 | 204 | ||
188 | void PwMInit::initKWalletEmu(bool forceDisable, bool forceReload) | 205 | void PwMInit::initKWalletEmu(bool forceDisable, bool forceReload) |
189 | { | 206 | { |
190 | #ifdef CONFIG_KWALLETIF | 207 | #ifdef CONFIG_KWALLETIF |
191 | if (!conf()->confGlobKwalletEmu() || | 208 | if (!conf()->confGlobKwalletEmu() || |
192 | forceDisable) { | 209 | forceDisable) { |
193 | delete_ifnot_null(_kwalletEmu); | 210 | delete_ifnot_null(_kwalletEmu); |
194 | return; | 211 | return; |
195 | } | 212 | } |
196 | try { | 213 | try { |
197 | if (_kwalletEmu && forceReload) | 214 | if (_kwalletEmu && forceReload) |
198 | delete_and_null(_kwalletEmu); | 215 | delete_and_null(_kwalletEmu); |
199 | if (!_kwalletEmu) | 216 | if (!_kwalletEmu) |
200 | _kwalletEmu = new KWalletEmu(this); | 217 | _kwalletEmu = new KWalletEmu(this); |
201 | } catch (PwMException e) { | 218 | } catch (PwMException e) { |
202 | string errMsg("initializing KWallet emulation failed. ID: "); | 219 | string errMsg("initializing KWallet emulation failed. ID: "); |
203 | errMsg += tostr(static_cast<int>(e.getId())); | 220 | errMsg += tostr(static_cast<int>(e.getId())); |
204 | errMsg += " err-message: "; | 221 | errMsg += " err-message: "; |
205 | errMsg += e.getMessage(); | 222 | errMsg += e.getMessage(); |
206 | printWarn(errMsg); | 223 | printWarn(errMsg); |
207 | return; | 224 | return; |
208 | } | 225 | } |
209 | #else // CONFIG_KWALLETIF | 226 | #else // CONFIG_KWALLETIF |
210 | PARAM_UNUSED(forceDisable); | 227 | PARAM_UNUSED(forceDisable); |
211 | PARAM_UNUSED(forceReload); | 228 | PARAM_UNUSED(forceReload); |
212 | #endif // CONFIG_KWALLETIF | 229 | #endif // CONFIG_KWALLETIF |
213 | } | 230 | } |
214 | 231 | ||
215 | void PwMInit::initKeycard() | 232 | void PwMInit::initKeycard() |
216 | { | 233 | { |
217 | #ifdef CONFIG_KEYCARD | 234 | #ifdef CONFIG_KEYCARD |
218 | PWM_ASSERT(!_keycard); | 235 | PWM_ASSERT(!_keycard); |
219 | _keycard = new PwMKeyCard(this); | 236 | _keycard = new PwMKeyCard(this); |
220 | #endif // CONFIG_KEYCARD | 237 | #endif // CONFIG_KEYCARD |
221 | } | 238 | } |
222 | 239 | ||
223 | void PwMInit::initTray() | 240 | void PwMInit::initTray() |
224 | { | 241 | { |
225 | #ifdef PWM_EMBEDDED | 242 | #ifdef PWM_EMBEDDED |
226 | //US ENH : embedded version does not support a tray | 243 | //US ENH : embedded version does not support a tray |
227 | return; | 244 | return; |
228 | #endif | 245 | #endif |
229 | 246 | ||
230 | if (!conf()->confGlobTray()) { | 247 | if (!conf()->confGlobTray()) { |
231 | if (!_tray) | 248 | if (!_tray) |
232 | return; | 249 | return; |
233 | _tray->hide(); | 250 | _tray->hide(); |
234 | delete_and_null(_tray); | 251 | delete_and_null(_tray); |
235 | return; | 252 | return; |
236 | } | 253 | } |
237 | if (_tray) | 254 | if (_tray) |
238 | return; | 255 | return; |
239 | _tray = new PwMTray(this); | 256 | _tray = new PwMTray(this); |
240 | connect(_tray, SIGNAL(quitSelected()), | 257 | connect(_tray, SIGNAL(quitSelected()), |
241 | this, SLOT(removeTrayAndQuit())); | 258 | this, SLOT(removeTrayAndQuit())); |
242 | connect(_tray, SIGNAL(closed(PwMTray *)), | 259 | connect(_tray, SIGNAL(closed(PwMTray *)), |
243 | this, SLOT(trayIconClosed(PwMTray *))); | 260 | this, SLOT(trayIconClosed(PwMTray *))); |
244 | KIconLoader icons; | 261 | KIconLoader icons; |
245 | #ifndef PWM_EMBEDDED | 262 | #ifndef PWM_EMBEDDED |
246 | _tray->setPixmap(icons.loadIcon(PACKAGE_NAME, KIcon::Small)); | 263 | _tray->setPixmap(icons.loadIcon(PACKAGE_NAME, KIcon::Small)); |
247 | #endif | 264 | #endif |
248 | _tray->show(); | 265 | _tray->show(); |
249 | // connect the signals of all open documents. | 266 | // connect the signals of all open documents. |
250 | const vector<PwMDocList::listItem> *dl = PwMDoc::getOpenDocList()->getList(); | 267 | const vector<PwMDocList::listItem> *dl = PwMDoc::getOpenDocList()->getList(); |
251 | vector<PwMDocList::listItem>::const_iterator i = dl->begin(), | 268 | vector<PwMDocList::listItem>::const_iterator i = dl->begin(), |
252 | end = dl->end(); | 269 | end = dl->end(); |
253 | while (i != end) { | 270 | while (i != end) { |
254 | _tray->connectDocToTray((*i).doc); | 271 | _tray->connectDocToTray((*i).doc); |
255 | ++i; | 272 | ++i; |
256 | } | 273 | } |
257 | } | 274 | } |
258 | 275 | ||
259 | void PwMInit::removeTrayAndQuit() | 276 | void PwMInit::removeTrayAndQuit() |
260 | { | 277 | { |
261 | PWM_ASSERT(_tray); | 278 | PWM_ASSERT(_tray); |
262 | // _tray is deleted in ~PwMInit | 279 | // _tray is deleted in ~PwMInit |
263 | shutdownApp(0); | 280 | shutdownApp(0); |
264 | } | 281 | } |
265 | 282 | ||
266 | PwM * PwMInit::createMainWnd(const QString &loadFile, | 283 | PwM * PwMInit::createMainWnd(const QString &loadFile, |
267 | bool loadFileDeepLocked, | 284 | bool loadFileDeepLocked, |
268 | bool virginity, | 285 | bool virginity, |
269 | PwMDoc *doc, | 286 | PwMDoc *doc, |
270 | bool minimized) | 287 | bool minimized) |
271 | { | 288 | { |
272 | PwM *newWnd; | 289 | PwM *newWnd; |
273 | if (!doc) | 290 | if (!doc) |
274 | doc = createDoc(); | 291 | doc = createDoc(); |
275 | newWnd = new PwM(this, doc, virginity); | 292 | newWnd = new PwM(this, doc, virginity); |
276 | #ifndef PWM_EMBEDDED | 293 | #ifndef PWM_EMBEDDED |
277 | _mainWndList.push_back(newWnd); | 294 | _mainWndList.push_back(newWnd); |
278 | #else | 295 | #else |
279 | _mainWndList.append(newWnd); | 296 | _mainWndList.append(newWnd); |
280 | #endif | 297 | #endif |
281 | connect(newWnd, SIGNAL(closed(PwM *)), | 298 | connect(newWnd, SIGNAL(closed(PwM *)), |
282 | this, SLOT(mainWndClosed(PwM *))); | 299 | this, SLOT(mainWndClosed(PwM *))); |
283 | connect(newWnd, SIGNAL(gotFocus(PwM *)), | 300 | connect(newWnd, SIGNAL(gotFocus(PwM *)), |
284 | this, SLOT(setCurWidget(PwM *))); | 301 | this, SLOT(setCurWidget(PwM *))); |
285 | connect(newWnd, SIGNAL(lostFocus(PwM *)), | 302 | connect(newWnd, SIGNAL(lostFocus(PwM *)), |
286 | this, SLOT(resetCurWidget())); | 303 | this, SLOT(resetCurWidget())); |
287 | 304 | ||
288 | //US ENH | 305 | //US ENH |
289 | #ifndef PWM_EMBEDDED | 306 | #ifndef PWM_EMBEDDED |
290 | if (minimized) | 307 | if (minimized) |
291 | newWnd->showMinimized(); | 308 | newWnd->showMinimized(); |
292 | else | 309 | else |
293 | newWnd->show(); | 310 | newWnd->show(); |
294 | 311 | ||
295 | #else //PWM_EMBEDDED | 312 | #else //PWM_EMBEDDED |
296 | 313 | ||
297 | #ifndef DESKTOP_VERSION | 314 | #ifndef DESKTOP_VERSION |
298 | app->showMainWidget( newWnd ); | 315 | app->showMainWidget( newWnd ); |
299 | #else //DESKTOP_VERSION | 316 | #else //DESKTOP_VERSION |
300 | app->setMainWidget( newWnd ); | 317 | app->setMainWidget( newWnd ); |
301 | newWnd->resize (640, 480 ); | 318 | newWnd->resize (640, 480 ); |
302 | newWnd->show(); | 319 | newWnd->show(); |
303 | #endif //DESKTOP_VERSION | 320 | #endif //DESKTOP_VERSION |
304 | 321 | ||
305 | #endif //PWM_EMBEDDED | 322 | #endif //PWM_EMBEDDED |
306 | 323 | ||
307 | if (loadFile != QString::null && | 324 | if (loadFile != QString::null && |
308 | loadFile != "") { | 325 | loadFile != "") { |
309 | newWnd->openDoc(loadFile, loadFileDeepLocked); | 326 | newWnd->openDoc(loadFile, loadFileDeepLocked); |
310 | } | 327 | } |
311 | return newWnd; | 328 | return newWnd; |
312 | } | 329 | } |
313 | 330 | ||
314 | PwMDoc * PwMInit::createDoc() | 331 | PwMDoc * PwMInit::createDoc() |
315 | { | 332 | { |
316 | PwMDoc *doc = new PwMDoc(this); | 333 | PwMDoc *doc = new PwMDoc(this); |
317 | #ifdef CONFIG_KEYCARD | 334 | #ifdef CONFIG_KEYCARD |
318 | doc->setPwMKeyCard(keycard()); | 335 | doc->setPwMKeyCard(keycard()); |
319 | #endif | 336 | #endif |
320 | #ifdef CONFIG_KWALLETIF | 337 | #ifdef CONFIG_KWALLETIF |
321 | if (kwalletEmu()) | 338 | if (kwalletEmu()) |
322 | kwalletEmu()->connectDocSignals(doc); | 339 | kwalletEmu()->connectDocSignals(doc); |
323 | #endif | 340 | #endif |
324 | 341 | ||
325 | if (_tray) | 342 | if (_tray) |
326 | _tray->connectDocToTray(doc); | 343 | _tray->connectDocToTray(doc); |
327 | 344 | ||
328 | return doc; | 345 | return doc; |
329 | 346 | ||
330 | } | 347 | } |
331 | 348 | ||
332 | void PwMInit::mainWndClosed(PwM *wnd) | 349 | void PwMInit::mainWndClosed(PwM *wnd) |
333 | { | 350 | { |
334 | bool doMinimizeToTray = false; | 351 | bool doMinimizeToTray = false; |
335 | bool doDeleteDoc = false; | 352 | bool doDeleteDoc = false; |
336 | #ifndef PWM_EMBEDDED | 353 | #ifndef PWM_EMBEDDED |
337 | dcopClient()->suspend(); | 354 | dcopClient()->suspend(); |
338 | dcopClient()->setAcceptCalls(false); | 355 | dcopClient()->setAcceptCalls(false); |
339 | #endif | 356 | #endif |
340 | again: | 357 | again: |
diff --git a/pwmanager/pwmanager/pwmtray.cpp b/pwmanager/pwmanager/pwmtray.cpp index 0f286c1..fe074ca 100644 --- a/pwmanager/pwmanager/pwmtray.cpp +++ b/pwmanager/pwmanager/pwmtray.cpp | |||
@@ -1,220 +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 | * 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 | #include "configuration.h" | 29 | #include "configuration.h" |
30 | #else | ||
31 | #include "pwmprefs.h" | ||
32 | #endif | ||
29 | 33 | ||
30 | #include <klocale.h> | 34 | #include <klocale.h> |
31 | 35 | ||
32 | 36 | ||
33 | void ActiveTreeItem::execIt() | 37 | void ActiveTreeItem::execIt() |
34 | { | 38 | { |
35 | #ifndef PWM_EMBEDDED | 39 | #ifndef PWM_EMBEDDED |
36 | unsigned int entr = static_cast<unsigned int>(entry); | 40 | unsigned int entr = static_cast<unsigned int>(entry); |
37 | unsigned int cat = static_cast<unsigned int>(category); | 41 | unsigned int cat = static_cast<unsigned int>(category); |
38 | #else | 42 | #else |
39 | unsigned int entr = (unsigned int)(entry); | 43 | unsigned int entr = (unsigned int)(entry); |
40 | unsigned int cat = (unsigned int)(category); | 44 | unsigned int cat = (unsigned int)(category); |
41 | #endif | 45 | #endif |
42 | switch (task) { | 46 | switch (task) { |
43 | case pwToClipboard: { | 47 | case pwToClipboard: { |
44 | PwMDataItem d; | 48 | PwMDataItem d; |
45 | doc->getDataChangedLock(); | 49 | doc->getDataChangedLock(); |
46 | bool wasLocked = doc->isLocked(cat, entr); | 50 | bool wasLocked = doc->isLocked(cat, entr); |
47 | doc->getEntry(cat, entr, &d, true); | 51 | doc->getEntry(cat, entr, &d, true); |
48 | if (wasLocked) | 52 | if (wasLocked) |
49 | doc->lockAt(cat, entr, true); | 53 | doc->lockAt(cat, entr, true); |
50 | doc->putDataChangedLock(); | 54 | doc->putDataChangedLock(); |
51 | PwM::copyToClipboard(d.pw.c_str()); | 55 | PwM::copyToClipboard(d.pw.c_str()); |
52 | break; | 56 | break; |
53 | } case nameToClipboard: { | 57 | } case nameToClipboard: { |
54 | PwMDataItem d; | 58 | PwMDataItem d; |
55 | doc->getEntry(cat, entr, &d); | 59 | doc->getEntry(cat, entr, &d); |
56 | PwM::copyToClipboard(d.name.c_str()); | 60 | PwM::copyToClipboard(d.name.c_str()); |
57 | break; | 61 | break; |
58 | } case descToClipboard: { | 62 | } case descToClipboard: { |
59 | PwMDataItem d; | 63 | PwMDataItem d; |
60 | doc->getEntry(cat, entr, &d); | 64 | doc->getEntry(cat, entr, &d); |
61 | PwM::copyToClipboard(d.desc.c_str()); | 65 | PwM::copyToClipboard(d.desc.c_str()); |
62 | break; | 66 | break; |
63 | } case urlToClipboard: { | 67 | } case urlToClipboard: { |
64 | PwMDataItem d; | 68 | PwMDataItem d; |
65 | doc->getEntry(cat, entr, &d); | 69 | doc->getEntry(cat, entr, &d); |
66 | PwM::copyToClipboard(d.url.c_str()); | 70 | PwM::copyToClipboard(d.url.c_str()); |
67 | break; | 71 | break; |
68 | } case launcherToClipboard: { | 72 | } case launcherToClipboard: { |
69 | PwMDataItem d; | 73 | PwMDataItem d; |
70 | doc->getEntry(cat, entr, &d); | 74 | doc->getEntry(cat, entr, &d); |
71 | PwM::copyToClipboard(d.launcher.c_str()); | 75 | PwM::copyToClipboard(d.launcher.c_str()); |
72 | break; | 76 | break; |
73 | } case commentToClipboard: { | 77 | } case commentToClipboard: { |
74 | PwMDataItem d; | 78 | PwMDataItem d; |
75 | doc->getEntry(cat, entr, &d); | 79 | doc->getEntry(cat, entr, &d); |
76 | PwM::copyToClipboard(d.comment.c_str()); | 80 | PwM::copyToClipboard(d.comment.c_str()); |
77 | break; | 81 | break; |
78 | } case execLauncher: { | 82 | } case execLauncher: { |
79 | doc->execLauncher(cat, entr); | 83 | doc->execLauncher(cat, entr); |
80 | break; | 84 | break; |
81 | } case goToURL: { | 85 | } case goToURL: { |
82 | doc->goToURL(cat, entr); | 86 | doc->goToURL(cat, entr); |
83 | break; | 87 | break; |
84 | } case openMainWnd: { | 88 | } case openMainWnd: { |
85 | // search if there is already an open window. | 89 | // search if there is already an open window. |
86 | const QValueList<PwM *> *wl = tray->init->mainWndList(); | 90 | const QValueList<PwM *> *wl = tray->init->mainWndList(); |
87 | #ifndef PWM_EMBEDDED | 91 | #ifndef PWM_EMBEDDED |
88 | QValueList<PwM *>::const_iterator i = wl->begin(), | 92 | QValueList<PwM *>::const_iterator i = wl->begin(), |
89 | end = wl->end(); | 93 | end = wl->end(); |
90 | #else | 94 | #else |
91 | QValueList<PwM *>::ConstIterator i = wl->begin(), | 95 | QValueList<PwM *>::ConstIterator i = wl->begin(), |
92 | end = wl->end(); | 96 | end = wl->end(); |
93 | #endif | 97 | #endif |
94 | PwM *wnd; | 98 | PwM *wnd; |
95 | while (i != end) { | 99 | while (i != end) { |
96 | wnd = *i; | 100 | wnd = *i; |
97 | if (wnd->curDoc() == doc) { | 101 | if (wnd->curDoc() == doc) { |
98 | // now bring this window to the foreground. | 102 | // now bring this window to the foreground. |
99 | if (!wnd->hasFocus()) { | 103 | if (!wnd->hasFocus()) { |
100 | wnd->hide(); | 104 | wnd->hide(); |
101 | wnd->showNormal(); | 105 | wnd->showNormal(); |
102 | wnd->setFocus(); | 106 | wnd->setFocus(); |
103 | } | 107 | } |
104 | return; | 108 | return; |
105 | } | 109 | } |
106 | ++i; | 110 | ++i; |
107 | } | 111 | } |
108 | // there is no open window, so open a new one. | 112 | // there is no open window, so open a new one. |
109 | tray->init->createMainWnd(QString::null, false, false, doc); | 113 | tray->init->createMainWnd(QString::null, false, false, doc); |
110 | break; | 114 | break; |
111 | } case closeDoc: { | 115 | } case closeDoc: { |
112 | doc->tryDelete(); | 116 | doc->tryDelete(); |
113 | break; | 117 | break; |
114 | } case lock: { | 118 | } case lock: { |
115 | doc->lockAll(true); | 119 | doc->lockAll(true); |
116 | break; | 120 | break; |
117 | } case deepLock: { | 121 | } case deepLock: { |
118 | doc->deepLock(); | 122 | doc->deepLock(); |
119 | break; | 123 | break; |
120 | } case unlock: { | 124 | } case unlock: { |
121 | doc->lockAll(false); | 125 | doc->lockAll(false); |
122 | break; | 126 | break; |
123 | } default: { | 127 | } default: { |
124 | BUG(); | 128 | BUG(); |
125 | } | 129 | } |
126 | } | 130 | } |
127 | } | 131 | } |
128 | 132 | ||
129 | 133 | ||
130 | 134 | ||
131 | #ifndef PWM_EMBEDDED | 135 | #ifndef PWM_EMBEDDED |
132 | PwMTray::PwMTray(PwMInit *_init, QWidget * parent, const char *name) | 136 | PwMTray::PwMTray(PwMInit *_init, QWidget * parent, const char *name) |
133 | : KSystemTray(parent, name) | 137 | : KSystemTray(parent, name) |
134 | #else | 138 | #else |
135 | PwMTray::PwMTray(PwMInit *_init, QWidget * parent, const char *name) | 139 | PwMTray::PwMTray(PwMInit *_init, QWidget * parent, const char *name) |
136 | : QWidget(parent, name) | 140 | : QWidget(parent, name) |
137 | #endif | 141 | #endif |
138 | { | 142 | { |
139 | init = _init; | 143 | init = _init; |
140 | buildMain(); | 144 | buildMain(); |
141 | } | 145 | } |
142 | 146 | ||
143 | PwMTray::~PwMTray() | 147 | PwMTray::~PwMTray() |
144 | { | 148 | { |
145 | emit closed(this); | 149 | emit closed(this); |
146 | } | 150 | } |
147 | 151 | ||
148 | //US ENH for embedded tray class | 152 | //US ENH for embedded tray class |
149 | KPopupMenu* PwMTray::contextMenu() | 153 | KPopupMenu* PwMTray::contextMenu() |
150 | { | 154 | { |
151 | if (m_ctxMenu == 0) | 155 | if (m_ctxMenu == 0) |
152 | { | 156 | { |
153 | m_ctxMenu = new KPopupMenu(); | 157 | m_ctxMenu = new KPopupMenu(); |
154 | } | 158 | } |
155 | 159 | ||
156 | return m_ctxMenu; | 160 | return m_ctxMenu; |
157 | } | 161 | } |
158 | 162 | ||
159 | 163 | ||
160 | void PwMTray::buildMain() | 164 | void PwMTray::buildMain() |
161 | { | 165 | { |
162 | KPopupMenu *ctxMenu = contextMenu(); | 166 | KPopupMenu *ctxMenu = contextMenu(); |
163 | 167 | ||
164 | ctxMenu->insertSeparator(); | 168 | ctxMenu->insertSeparator(); |
165 | ctxMenu->insertItem(i18n("&New main window..."), this, | 169 | ctxMenu->insertItem(i18n("&New main window..."), this, |
166 | SLOT(newMainWnd())); | 170 | SLOT(newMainWnd())); |
167 | ctxMenu->insertItem(i18n("&Open file..."), this, | 171 | ctxMenu->insertItem(i18n("&Open file..."), this, |
168 | SLOT(openDoc())); | 172 | SLOT(openDoc())); |
169 | ctxMenu->insertSeparator(); | 173 | ctxMenu->insertSeparator(); |
170 | ctxMenu->insertItem(i18n("&Remove from tray"), this, | 174 | ctxMenu->insertItem(i18n("&Remove from tray"), this, |
171 | SLOT(undock())); | 175 | SLOT(undock())); |
172 | } | 176 | } |
173 | 177 | ||
174 | void PwMTray::insertActiveTreeItem(KPopupMenu *insertIn, const QString &text, | 178 | void PwMTray::insertActiveTreeItem(KPopupMenu *insertIn, const QString &text, |
175 | ActiveTreeItem::Task task, PwMDoc *doc, | 179 | ActiveTreeItem::Task task, PwMDoc *doc, |
176 | int docCategory, int docEntry, | 180 | int docCategory, int docEntry, |
177 | QValueList<int> *activeItemsList) | 181 | QValueList<int> *activeItemsList) |
178 | { | 182 | { |
179 | ActiveTreeItem *activeItem; | 183 | ActiveTreeItem *activeItem; |
180 | int id; | 184 | int id; |
181 | 185 | ||
182 | activeItem = new ActiveTreeItem(text, insertIn->font(), task, | 186 | activeItem = new ActiveTreeItem(text, insertIn->font(), task, |
183 | doc, docCategory, docEntry, | 187 | doc, docCategory, docEntry, |
184 | this); | 188 | this); |
185 | id = insertIn->insertItem(activeItem); | 189 | id = insertIn->insertItem(activeItem); |
186 | insertIn->connectItem(id, activeItem, SLOT(execIt())); | 190 | insertIn->connectItem(id, activeItem, SLOT(execIt())); |
187 | #ifndef PWM_EMBEDDED | 191 | #ifndef PWM_EMBEDDED |
188 | activeItemsList->push_back(id); | 192 | activeItemsList->push_back(id); |
189 | #else | 193 | #else |
190 | activeItemsList->append(id); | 194 | activeItemsList->append(id); |
191 | #endif | 195 | #endif |
192 | } | 196 | } |
193 | 197 | ||
194 | void PwMTray::rebuildTree(KPopupMenu *popup, PwMDoc *doc, | 198 | void PwMTray::rebuildTree(KPopupMenu *popup, PwMDoc *doc, |
195 | QValueList<int> *activeItems) | 199 | QValueList<int> *activeItems) |
196 | { | 200 | { |
197 | PWM_ASSERT(doc); | 201 | PWM_ASSERT(doc); |
198 | PWM_ASSERT(popup); | 202 | PWM_ASSERT(popup); |
199 | activeItems->clear(); | 203 | activeItems->clear(); |
200 | popup->clear(); | 204 | popup->clear(); |
201 | #ifndef PWM_EMBEDDED | 205 | #ifndef PWM_EMBEDDED |
202 | popup->insertTitle(i18n("Categories:")); | 206 | popup->insertTitle(i18n("Categories:")); |
203 | #endif | 207 | #endif |
204 | vector<string> catList; | 208 | vector<string> catList; |
205 | vector<string> entrList; | 209 | vector<string> entrList; |
206 | doc->getCategoryList(&catList); | 210 | doc->getCategoryList(&catList); |
207 | KPopupMenu *newCatMenu; | 211 | KPopupMenu *newCatMenu; |
208 | KPopupMenu *newEntrMenu; | 212 | KPopupMenu *newEntrMenu; |
209 | int i, size = catList.size(); | 213 | int i, size = catList.size(); |
210 | int j, entries; | 214 | int j, entries; |
211 | for (i = 0; i < size; ++i) { | 215 | for (i = 0; i < size; ++i) { |
212 | newCatMenu = new KPopupMenu(popup); | 216 | newCatMenu = new KPopupMenu(popup); |
213 | popup->insertItem(catList[i].c_str(), newCatMenu); | 217 | popup->insertItem(catList[i].c_str(), newCatMenu); |
214 | doc->getEntryList(i, &entrList); | 218 | doc->getEntryList(i, &entrList); |
215 | 219 | ||
216 | entries = entrList.size(); | 220 | entries = entrList.size(); |
217 | for (j = 0; j < entries; ++j) { | 221 | for (j = 0; j < entries; ++j) { |
218 | newEntrMenu = new KPopupMenu(newCatMenu); | 222 | newEntrMenu = new KPopupMenu(newCatMenu); |
219 | newCatMenu->insertItem(entrList[j].c_str(), newEntrMenu); | 223 | newCatMenu->insertItem(entrList[j].c_str(), newEntrMenu); |
220 | 224 | ||
diff --git a/pwmanager/pwmanager/pwmview.cpp b/pwmanager/pwmanager/pwmview.cpp index c09fbf5..58c2fca 100644 --- a/pwmanager/pwmanager/pwmview.cpp +++ b/pwmanager/pwmanager/pwmview.cpp | |||
@@ -1,217 +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 | * 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 | #include "configuration.h" | 26 | #include "configuration.h" |
27 | #else | ||
28 | #include "pwmprefs.h" | ||
29 | #endif | ||
26 | #include "commentbox.h" | 30 | #include "commentbox.h" |
27 | 31 | ||
28 | #include <kmessagebox.h> | 32 | #include <kmessagebox.h> |
29 | #include <klocale.h> | 33 | #include <klocale.h> |
30 | 34 | ||
31 | #include <qlineedit.h> | 35 | #include <qlineedit.h> |
32 | #include <qpoint.h> | 36 | #include <qpoint.h> |
33 | #include <qapplication.h> | 37 | #include <qapplication.h> |
34 | 38 | ||
35 | #define COLUMN_DESC 0 | 39 | #define COLUMN_DESC 0 |
36 | #define COLUMN_NAME 1 | 40 | #define COLUMN_NAME 1 |
37 | #define COLUMN_PW 2 | 41 | #define COLUMN_PW 2 |
38 | #define COLUMN_URL 3 | 42 | #define COLUMN_URL 3 |
39 | #define COLUMN_LAUNCHER 4 | 43 | #define COLUMN_LAUNCHER 4 |
40 | 44 | ||
41 | 45 | ||
42 | PwMView::PwMView(PwM *_mainClass, | 46 | PwMView::PwMView(PwM *_mainClass, |
43 | QWidget *parent, PwMDoc *_doc, | 47 | QWidget *parent, PwMDoc *_doc, |
44 | const char *name) | 48 | const char *name) |
45 | : PwMViewStyle(parent, name) | 49 | : PwMViewStyle(parent, name) |
46 | { | 50 | { |
47 | PWM_ASSERT(_mainClass); | 51 | PWM_ASSERT(_mainClass); |
48 | PWM_ASSERT(parent); | 52 | PWM_ASSERT(parent); |
49 | PWM_ASSERT(_doc); | 53 | PWM_ASSERT(_doc); |
50 | setView(this); | 54 | setView(this); |
51 | doc = _doc; | 55 | doc = _doc; |
52 | doc->setListViewPointer(this); | 56 | doc->setListViewPointer(this); |
53 | mainClass = _mainClass; | 57 | mainClass = _mainClass; |
54 | resize(_mainClass->size()); | 58 | resize(_mainClass->size()); |
55 | initStyle(conf()->confWndMainViewStyle()); | 59 | initStyle(conf()->confWndMainViewStyle()); |
56 | initCtxMenu(); | 60 | initCtxMenu(); |
57 | doc->setCurrentView(this); | 61 | doc->setCurrentView(this); |
58 | connect(doc, SIGNAL(dataChanged(PwMDoc *)), this, SLOT(updateView())); | 62 | connect(doc, SIGNAL(dataChanged(PwMDoc *)), this, SLOT(updateView())); |
59 | } | 63 | } |
60 | 64 | ||
61 | PwMView::~PwMView() | 65 | PwMView::~PwMView() |
62 | { | 66 | { |
63 | } | 67 | } |
64 | 68 | ||
65 | void PwMView::initCtxMenu() | 69 | void PwMView::initCtxMenu() |
66 | { | 70 | { |
67 | ctxMenu = new QPopupMenu(this); | 71 | ctxMenu = new QPopupMenu(this); |
68 | ctxMenu->insertItem(i18n("&Add password"), mainClass, SLOT(addPwd_slot())); | 72 | ctxMenu->insertItem(i18n("&Add password"), mainClass, SLOT(addPwd_slot())); |
69 | ctxMenu->insertSeparator(); | 73 | ctxMenu->insertSeparator(); |
70 | ctxMenu->insertItem(i18n("&Edit"), mainClass, SLOT(editPwd_slot())); | 74 | ctxMenu->insertItem(i18n("&Edit"), mainClass, SLOT(editPwd_slot())); |
71 | ctxMenu->insertItem(i18n("&Delete"), mainClass, SLOT(deletePwd_slot())); | 75 | ctxMenu->insertItem(i18n("&Delete"), mainClass, SLOT(deletePwd_slot())); |
72 | ctxMenu->insertSeparator(); | 76 | ctxMenu->insertSeparator(); |
73 | ctxMenu->insertItem(i18n("copy password to clipboard"), | 77 | ctxMenu->insertItem(i18n("copy password to clipboard"), |
74 | this, SLOT(copyPwToClip())); | 78 | this, SLOT(copyPwToClip())); |
75 | ctxMenu->insertItem(i18n("copy username to clipboard"), | 79 | ctxMenu->insertItem(i18n("copy username to clipboard"), |
76 | this, SLOT(copyNameToClip())); | 80 | this, SLOT(copyNameToClip())); |
77 | ctxMenu->insertItem(i18n("copy description to clipboard"), | 81 | ctxMenu->insertItem(i18n("copy description to clipboard"), |
78 | this, SLOT(copyDescToClip())); | 82 | this, SLOT(copyDescToClip())); |
79 | ctxMenu->insertItem(i18n("copy url to clipboard"), | 83 | ctxMenu->insertItem(i18n("copy url to clipboard"), |
80 | this, SLOT(copyUrlToClip())); | 84 | this, SLOT(copyUrlToClip())); |
81 | ctxMenu->insertItem(i18n("copy launcher to clipboard"), | 85 | ctxMenu->insertItem(i18n("copy launcher to clipboard"), |
82 | this, SLOT(copyLauncherToClip())); | 86 | this, SLOT(copyLauncherToClip())); |
83 | ctxMenu->insertItem(i18n("copy comment to clipboard"), | 87 | ctxMenu->insertItem(i18n("copy comment to clipboard"), |
84 | this, SLOT(copyCommentToClip())); | 88 | this, SLOT(copyCommentToClip())); |
85 | ctxMenu->insertSeparator(); | 89 | ctxMenu->insertSeparator(); |
86 | ctxMenu->insertItem(i18n("Execute \"Launcher\""), mainClass, | 90 | ctxMenu->insertItem(i18n("Execute \"Launcher\""), mainClass, |
87 | SLOT(execLauncher_slot())); | 91 | SLOT(execLauncher_slot())); |
88 | ctxMenu->insertItem(i18n("Go to \"URL\""), mainClass, | 92 | ctxMenu->insertItem(i18n("Go to \"URL\""), mainClass, |
89 | SLOT(goToURL_slot())); | 93 | SLOT(goToURL_slot())); |
90 | } | 94 | } |
91 | 95 | ||
92 | void PwMView::resizeEvent(QResizeEvent *) | 96 | void PwMView::resizeEvent(QResizeEvent *) |
93 | { | 97 | { |
94 | resizeView(size()); | 98 | resizeView(size()); |
95 | } | 99 | } |
96 | 100 | ||
97 | void PwMView::refreshCommentTextEdit(QListViewItem *curItem) | 101 | void PwMView::refreshCommentTextEdit(QListViewItem *curItem) |
98 | { | 102 | { |
99 | PWM_ASSERT(commentBox); | 103 | PWM_ASSERT(commentBox); |
100 | if (!curItem) | 104 | if (!curItem) |
101 | return; | 105 | return; |
102 | string comment; | 106 | string comment; |
103 | PwMerror ret; | 107 | PwMerror ret; |
104 | ret = document()->getCommentByLvp(getCurrentCategory(), | 108 | ret = document()->getCommentByLvp(getCurrentCategory(), |
105 | lv->childCount() - lv->itemIndex(curItem) - 1, | 109 | lv->childCount() - lv->itemIndex(curItem) - 1, |
106 | &comment); | 110 | &comment); |
107 | if (ret == e_binEntry) { | 111 | if (ret == e_binEntry) { |
108 | commentBox->setContent(i18n("This is a binary entry.\n" | 112 | commentBox->setContent(i18n("This is a binary entry.\n" |
109 | "It is not a normal password-entry, as it contains " | 113 | "It is not a normal password-entry, as it contains " |
110 | "binary data, which PwManager can't display here.")); | 114 | "binary data, which PwManager can't display here.")); |
111 | } else if (ret == e_normalEntry) { | 115 | } else if (ret == e_normalEntry) { |
112 | commentBox->setContent(comment.c_str()); | 116 | commentBox->setContent(comment.c_str()); |
113 | } else { | 117 | } else { |
114 | BUG(); | 118 | BUG(); |
115 | return; | 119 | return; |
116 | } | 120 | } |
117 | lv->ensureItemVisible(curItem); | 121 | lv->ensureItemVisible(curItem); |
118 | } | 122 | } |
119 | 123 | ||
120 | void PwMView::keyReleaseEvent(QKeyEvent * /*e*/) | 124 | void PwMView::keyReleaseEvent(QKeyEvent * /*e*/) |
121 | { | 125 | { |
122 | refreshCommentTextEdit(lv->currentItem()); | 126 | refreshCommentTextEdit(lv->currentItem()); |
123 | } | 127 | } |
124 | 128 | ||
125 | bool PwMView::getCurEntryIndex(unsigned int *index) | 129 | bool PwMView::getCurEntryIndex(unsigned int *index) |
126 | { | 130 | { |
127 | QListViewItem *current = lv->currentItem(); | 131 | QListViewItem *current = lv->currentItem(); |
128 | if (!current) | 132 | if (!current) |
129 | return false; | 133 | return false; |
130 | return getDocEntryIndex(index, current); | 134 | return getDocEntryIndex(index, current); |
131 | } | 135 | } |
132 | 136 | ||
133 | bool PwMView::getDocEntryIndex(unsigned int *index, | 137 | bool PwMView::getDocEntryIndex(unsigned int *index, |
134 | const QListViewItem *item) | 138 | const QListViewItem *item) |
135 | { | 139 | { |
136 | vector<unsigned int> foundPositions; | 140 | vector<unsigned int> foundPositions; |
137 | PwMDataItem curItem; | 141 | PwMDataItem curItem; |
138 | curItem.desc = item->text(COLUMN_DESC).latin1(); | 142 | curItem.desc = item->text(COLUMN_DESC).latin1(); |
139 | curItem.name = item->text(COLUMN_NAME).latin1(); | 143 | curItem.name = item->text(COLUMN_NAME).latin1(); |
140 | document()->getCommentByLvp(getCurrentCategory(), | 144 | document()->getCommentByLvp(getCurrentCategory(), |
141 | lv->childCount() - lv->itemIndex(item) - 1, | 145 | lv->childCount() - lv->itemIndex(item) - 1, |
142 | &curItem.comment); | 146 | &curItem.comment); |
143 | curItem.url = item->text(COLUMN_URL).latin1(); | 147 | curItem.url = item->text(COLUMN_URL).latin1(); |
144 | curItem.launcher = item->text(COLUMN_LAUNCHER).latin1(); | 148 | curItem.launcher = item->text(COLUMN_LAUNCHER).latin1(); |
145 | document()->findEntry(getCurrentCategory(), curItem, SEARCH_IN_DESC | | 149 | document()->findEntry(getCurrentCategory(), curItem, SEARCH_IN_DESC | |
146 | SEARCH_IN_NAME | SEARCH_IN_COMMENT | SEARCH_IN_URL | | 150 | SEARCH_IN_NAME | SEARCH_IN_COMMENT | SEARCH_IN_URL | |
147 | SEARCH_IN_LAUNCHER, | 151 | SEARCH_IN_LAUNCHER, |
148 | &foundPositions, true); | 152 | &foundPositions, true); |
149 | if (foundPositions.size()) { | 153 | if (foundPositions.size()) { |
150 | *index = foundPositions[0]; | 154 | *index = foundPositions[0]; |
151 | return true; | 155 | return true; |
152 | } | 156 | } |
153 | 157 | ||
154 | return false; | 158 | return false; |
155 | } | 159 | } |
156 | 160 | ||
157 | void PwMView::handleToggle(QListViewItem *item) | 161 | void PwMView::handleToggle(QListViewItem *item) |
158 | { | 162 | { |
159 | PWM_ASSERT(doc); | 163 | PWM_ASSERT(doc); |
160 | if (!item) | 164 | if (!item) |
161 | return; | 165 | return; |
162 | QCheckListItem *clItem = (QCheckListItem *)item; | 166 | QCheckListItem *clItem = (QCheckListItem *)item; |
163 | QString curCat(getCurrentCategory()); | 167 | QString curCat(getCurrentCategory()); |
164 | 168 | ||
165 | // find document position of this entry. | 169 | // find document position of this entry. |
166 | unsigned int curEntryDocIndex; | 170 | unsigned int curEntryDocIndex; |
167 | if (!getDocEntryIndex(&curEntryDocIndex, item)) | 171 | if (!getDocEntryIndex(&curEntryDocIndex, item)) |
168 | return; | 172 | return; |
169 | 173 | ||
170 | // hack to refresh the comment, if only one item is present | 174 | // hack to refresh the comment, if only one item is present |
171 | if (lv->childCount() == 1) | 175 | if (lv->childCount() == 1) |
172 | refreshCommentTextEdit(lv->currentItem()); | 176 | refreshCommentTextEdit(lv->currentItem()); |
173 | 177 | ||
174 | if (doc->isLocked(curCat, curEntryDocIndex) != clItem->isOn()) | 178 | if (doc->isLocked(curCat, curEntryDocIndex) != clItem->isOn()) |
175 | return; // this is just a click somewhere on the entry | 179 | return; // this is just a click somewhere on the entry |
176 | if (doc->isDeepLocked()) { | 180 | if (doc->isDeepLocked()) { |
177 | PwMerror ret; | 181 | PwMerror ret; |
178 | ret = doc->deepLock(false); | 182 | ret = doc->deepLock(false); |
179 | if (ret != e_success) | 183 | if (ret != e_success) |
180 | clItem->setOn(false); | 184 | clItem->setOn(false); |
181 | return; | 185 | return; |
182 | } | 186 | } |
183 | doc->lockAt(curCat, curEntryDocIndex, !clItem->isOn()); | 187 | doc->lockAt(curCat, curEntryDocIndex, !clItem->isOn()); |
184 | } | 188 | } |
185 | 189 | ||
186 | void PwMView::handleRightClick(QListViewItem *item, const QPoint &point, int) | 190 | void PwMView::handleRightClick(QListViewItem *item, const QPoint &point, int) |
187 | { | 191 | { |
188 | if (!item) | 192 | if (!item) |
189 | return; | 193 | return; |
190 | ctxMenu->move(point); | 194 | ctxMenu->move(point); |
191 | /* don't use ctxMenu->exec() here, as it generates race conditions | 195 | /* don't use ctxMenu->exec() here, as it generates race conditions |
192 | * with the card interface code. Believe it or not. :) | 196 | * with the card interface code. Believe it or not. :) |
193 | */ | 197 | */ |
194 | ctxMenu->show(); | 198 | ctxMenu->show(); |
195 | } | 199 | } |
196 | 200 | ||
197 | void PwMView::updateCategories() | 201 | void PwMView::updateCategories() |
198 | { | 202 | { |
199 | QString oldSel(getCurrentCategory()); | 203 | QString oldSel(getCurrentCategory()); |
200 | delAllCategories(); | 204 | delAllCategories(); |
201 | QStringList catList; | 205 | QStringList catList; |
202 | document()->getCategoryList(&catList); | 206 | document()->getCategoryList(&catList); |
203 | catList.sort(); | 207 | catList.sort(); |
204 | #ifndef PWM_EMBEDDED | 208 | #ifndef PWM_EMBEDDED |
205 | QStringList::iterator i = catList.begin(), | 209 | QStringList::iterator i = catList.begin(), |
206 | end = catList.end(); | 210 | end = catList.end(); |
207 | #else | 211 | #else |
208 | QStringList::Iterator i = catList.begin(), | 212 | QStringList::Iterator i = catList.begin(), |
209 | end = catList.end(); | 213 | end = catList.end(); |
210 | #endif | 214 | #endif |
211 | while (i != end) { | 215 | while (i != end) { |
212 | addCategory(*i); | 216 | addCategory(*i); |
213 | ++i; | 217 | ++i; |
214 | } | 218 | } |
215 | selectCategory(oldSel); | 219 | selectCategory(oldSel); |
216 | } | 220 | } |
217 | 221 | ||
diff --git a/pwmanager/pwmanager/serializer.cpp b/pwmanager/pwmanager/serializer.cpp index 65e442d..f29ef6c 100644 --- a/pwmanager/pwmanager/serializer.cpp +++ b/pwmanager/pwmanager/serializer.cpp | |||
@@ -1,216 +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 | /*************************************************************************** | 13 | /*************************************************************************** |
14 | * copyright (C) 2004 by Ulf Schenk | 14 | * copyright (C) 2004 by Ulf Schenk |
15 | * This file is originaly based on version 2.0 of pwmanager | 15 | * This file is originaly based on version 2.0 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 <klocale.h> | 26 | #include <klocale.h> |
26 | #endif | 27 | #endif |
27 | 28 | ||
28 | /* enable/disable serializer debugging (0/1) */ | 29 | /* enable/disable serializer debugging (0/1) */ |
29 | #define SERIALIZER_DEBUG0 | 30 | #define SERIALIZER_DEBUG0 |
30 | /* use the old xml tags for writing (0/1) */ | 31 | /* use the old xml tags for writing (0/1) */ |
31 | #define USE_OLD_TAGS 0 | 32 | #define USE_OLD_TAGS 0 |
32 | /* write a CDATA section (0/1) */ | 33 | /* write a CDATA section (0/1) */ |
33 | #define WRITE_CDATA_SEC 0 | 34 | #define WRITE_CDATA_SEC 0 |
34 | 35 | ||
35 | 36 | ||
36 | #define META_CREATE_DATE"c" | 37 | #define META_CREATE_DATE"c" |
37 | #define META_VALID_DATE "v" | 38 | #define META_VALID_DATE "v" |
38 | #define META_EXPIRE_DATE"e" | 39 | #define META_EXPIRE_DATE"e" |
39 | #define META_UPDATE_DATE"u" | 40 | #define META_UPDATE_DATE"u" |
40 | #define META_UPDATE_INT "i" | 41 | #define META_UPDATE_INT "i" |
41 | //US ENH : uniqueid | 42 | //US ENH : uniqueid |
42 | #define META_UNIQUEID "n" | 43 | #define META_UNIQUEID "n" |
43 | 44 | ||
44 | /* This is compatibility stuff. | 45 | /* This is compatibility stuff. |
45 | * The names of the entries have changed and here are the | 46 | * The names of the entries have changed and here are the |
46 | * new and old ones | 47 | * new and old ones |
47 | */ | 48 | */ |
48 | #define ROOT_MAGIC_OLD "PwM-xml-dat" | 49 | #define ROOT_MAGIC_OLD "PwM-xml-dat" |
49 | #define VER_STR_OLD "ver" | 50 | #define VER_STR_OLD "ver" |
50 | #define COMPAT_VER_OLD "0x02" | 51 | #define COMPAT_VER_OLD "0x02" |
51 | #define CAT_ROOT_OLD "categories" | 52 | #define CAT_ROOT_OLD "categories" |
52 | #define CAT_PREFIX_OLD "cat_" | 53 | #define CAT_PREFIX_OLD "cat_" |
53 | #define CAT_NAME_OLD "name" | 54 | #define CAT_NAME_OLD "name" |
54 | #define ENTRY_PREFIX_OLD"entry_" | 55 | #define ENTRY_PREFIX_OLD"entry_" |
55 | #define ENTRY_DESC_OLD "desc" | 56 | #define ENTRY_DESC_OLD "desc" |
56 | #define ENTRY_NAME_OLD "name" | 57 | #define ENTRY_NAME_OLD "name" |
57 | #define ENTRY_PW_OLD "pw" | 58 | #define ENTRY_PW_OLD "pw" |
58 | #define ENTRY_COMMENT_OLD"comment" | 59 | #define ENTRY_COMMENT_OLD"comment" |
59 | #define ENTRY_URL_OLD "url" | 60 | #define ENTRY_URL_OLD "url" |
60 | #define ENTRY_LAUNCHER_OLD"launcher" | 61 | #define ENTRY_LAUNCHER_OLD"launcher" |
61 | #define ENTRY_LVP_OLD "listViewPos" | 62 | #define ENTRY_LVP_OLD "listViewPos" |
62 | #define ENTRY_BIN_OLD "b" | 63 | #define ENTRY_BIN_OLD "b" |
63 | #define ENTRY_META_OLD "m" | 64 | #define ENTRY_META_OLD "m" |
64 | 65 | ||
65 | #define ROOT_MAGIC_NEW "P" | 66 | #define ROOT_MAGIC_NEW "P" |
66 | #define VER_STR_NEW "v" | 67 | #define VER_STR_NEW "v" |
67 | #define COMPAT_VER_NEW "2" | 68 | #define COMPAT_VER_NEW "2" |
68 | #define CAT_ROOT_NEW "c" | 69 | #define CAT_ROOT_NEW "c" |
69 | #define CAT_PREFIX_NEW "c" | 70 | #define CAT_PREFIX_NEW "c" |
70 | #define CAT_NAME_NEW "n" | 71 | #define CAT_NAME_NEW "n" |
71 | #define ENTRY_PREFIX_NEW"e" | 72 | #define ENTRY_PREFIX_NEW"e" |
72 | #define ENTRY_DESC_NEW "d" | 73 | #define ENTRY_DESC_NEW "d" |
73 | #define ENTRY_NAME_NEW "n" | 74 | #define ENTRY_NAME_NEW "n" |
74 | #define ENTRY_PW_NEW "p" | 75 | #define ENTRY_PW_NEW "p" |
75 | #define ENTRY_COMMENT_NEW"c" | 76 | #define ENTRY_COMMENT_NEW"c" |
76 | #define ENTRY_URL_NEW "u" | 77 | #define ENTRY_URL_NEW "u" |
77 | #define ENTRY_LAUNCHER_NEW"l" | 78 | #define ENTRY_LAUNCHER_NEW"l" |
78 | #define ENTRY_LVP_NEW "v" | 79 | #define ENTRY_LVP_NEW "v" |
79 | #define ENTRY_BIN_NEW ENTRY_BIN_OLD | 80 | #define ENTRY_BIN_NEW ENTRY_BIN_OLD |
80 | #define ENTRY_META_NEW ENTRY_META_OLD | 81 | #define ENTRY_META_NEW ENTRY_META_OLD |
81 | 82 | ||
82 | #if USE_OLD_TAGS != 0 | 83 | #if USE_OLD_TAGS != 0 |
83 | # define ROOT_MAGIC_WR ROOT_MAGIC_OLD | 84 | # define ROOT_MAGIC_WR ROOT_MAGIC_OLD |
84 | # define VER_STR_WR VER_STR_OLD | 85 | # define VER_STR_WR VER_STR_OLD |
85 | # define COMPAT_VER_WR COMPAT_VER_OLD | 86 | # define COMPAT_VER_WR COMPAT_VER_OLD |
86 | # define CAT_ROOT_WR CAT_ROOT_OLD | 87 | # define CAT_ROOT_WR CAT_ROOT_OLD |
87 | # define CAT_PREFIX_WR CAT_PREFIX_OLD | 88 | # define CAT_PREFIX_WR CAT_PREFIX_OLD |
88 | # define CAT_NAME_WR CAT_NAME_OLD | 89 | # define CAT_NAME_WR CAT_NAME_OLD |
89 | # define ENTRY_PREFIX_WRENTRY_PREFIX_OLD | 90 | # define ENTRY_PREFIX_WRENTRY_PREFIX_OLD |
90 | # define ENTRY_DESC_WR ENTRY_DESC_OLD | 91 | # define ENTRY_DESC_WR ENTRY_DESC_OLD |
91 | # define ENTRY_NAME_WR ENTRY_NAME_OLD | 92 | # define ENTRY_NAME_WR ENTRY_NAME_OLD |
92 | # define ENTRY_PW_WR ENTRY_PW_OLD | 93 | # define ENTRY_PW_WR ENTRY_PW_OLD |
93 | # define ENTRY_COMMENT_WRENTRY_COMMENT_OLD | 94 | # define ENTRY_COMMENT_WRENTRY_COMMENT_OLD |
94 | # define ENTRY_URL_WR ENTRY_URL_OLD | 95 | # define ENTRY_URL_WR ENTRY_URL_OLD |
95 | # define ENTRY_LAUNCHER_WRENTRY_LAUNCHER_OLD | 96 | # define ENTRY_LAUNCHER_WRENTRY_LAUNCHER_OLD |
96 | # define ENTRY_LVP_WR ENTRY_LVP_OLD | 97 | # define ENTRY_LVP_WR ENTRY_LVP_OLD |
97 | # define ENTRY_BIN_WR ENTRY_BIN_OLD | 98 | # define ENTRY_BIN_WR ENTRY_BIN_OLD |
98 | # define ENTRY_META_WR ENTRY_META_OLD | 99 | # define ENTRY_META_WR ENTRY_META_OLD |
99 | #else | 100 | #else |
100 | # define ROOT_MAGIC_WR ROOT_MAGIC_NEW | 101 | # define ROOT_MAGIC_WR ROOT_MAGIC_NEW |
101 | # define VER_STR_WR VER_STR_NEW | 102 | # define VER_STR_WR VER_STR_NEW |
102 | # define COMPAT_VER_WR COMPAT_VER_NEW | 103 | # define COMPAT_VER_WR COMPAT_VER_NEW |
103 | # define CAT_ROOT_WR CAT_ROOT_NEW | 104 | # define CAT_ROOT_WR CAT_ROOT_NEW |
104 | # define CAT_PREFIX_WR CAT_PREFIX_NEW | 105 | # define CAT_PREFIX_WR CAT_PREFIX_NEW |
105 | # define CAT_NAME_WR CAT_NAME_NEW | 106 | # define CAT_NAME_WR CAT_NAME_NEW |
106 | # define ENTRY_PREFIX_WRENTRY_PREFIX_NEW | 107 | # define ENTRY_PREFIX_WRENTRY_PREFIX_NEW |
107 | # define ENTRY_DESC_WR ENTRY_DESC_NEW | 108 | # define ENTRY_DESC_WR ENTRY_DESC_NEW |
108 | # define ENTRY_NAME_WR ENTRY_NAME_NEW | 109 | # define ENTRY_NAME_WR ENTRY_NAME_NEW |
109 | # define ENTRY_PW_WR ENTRY_PW_NEW | 110 | # define ENTRY_PW_WR ENTRY_PW_NEW |
110 | # define ENTRY_COMMENT_WRENTRY_COMMENT_NEW | 111 | # define ENTRY_COMMENT_WRENTRY_COMMENT_NEW |
111 | # define ENTRY_URL_WR ENTRY_URL_NEW | 112 | # define ENTRY_URL_WR ENTRY_URL_NEW |
112 | # define ENTRY_LAUNCHER_WRENTRY_LAUNCHER_NEW | 113 | # define ENTRY_LAUNCHER_WRENTRY_LAUNCHER_NEW |
113 | # define ENTRY_LVP_WR ENTRY_LVP_NEW | 114 | # define ENTRY_LVP_WR ENTRY_LVP_NEW |
114 | # define ENTRY_BIN_WR ENTRY_BIN_NEW | 115 | # define ENTRY_BIN_WR ENTRY_BIN_NEW |
115 | # define ENTRY_META_WR ENTRY_META_NEW | 116 | # define ENTRY_META_WR ENTRY_META_NEW |
116 | #endif | 117 | #endif |
117 | 118 | ||
118 | 119 | ||
119 | Serializer::Serializer() | 120 | Serializer::Serializer() |
120 | { | 121 | { |
121 | defaultLockStat = true; | 122 | defaultLockStat = true; |
122 | domDoc = new QDomDocument; | 123 | domDoc = new QDomDocument; |
123 | } | 124 | } |
124 | 125 | ||
125 | Serializer::Serializer(const QCString &buffer) | 126 | Serializer::Serializer(const QCString &buffer) |
126 | { | 127 | { |
127 | defaultLockStat = true; | 128 | defaultLockStat = true; |
128 | domDoc = new QDomDocument; | 129 | domDoc = new QDomDocument; |
129 | if (!parseXml(buffer)) { | 130 | if (!parseXml(buffer)) { |
130 | delete domDoc; | 131 | delete domDoc; |
131 | #ifndef PWM_EMBEDDED | 132 | #ifndef PWM_EMBEDDED |
132 | throw PwMException(PwMException::EX_PARSE); | 133 | throw PwMException(PwMException::EX_PARSE); |
133 | #else | 134 | #else |
134 | qDebug("Serializer::Serializer : Parse Exception "); | 135 | qDebug("Serializer::Serializer : Parse Exception "); |
135 | #endif | 136 | #endif |
136 | } | 137 | } |
137 | } | 138 | } |
138 | 139 | ||
139 | Serializer::~Serializer() | 140 | Serializer::~Serializer() |
140 | { | 141 | { |
141 | delete_ifnot_null(domDoc); | 142 | delete_ifnot_null(domDoc); |
142 | } | 143 | } |
143 | 144 | ||
144 | void Serializer::clear() | 145 | void Serializer::clear() |
145 | { | 146 | { |
146 | delete_ifnot_null(domDoc); | 147 | delete_ifnot_null(domDoc); |
147 | domDoc = new QDomDocument; | 148 | domDoc = new QDomDocument; |
148 | } | 149 | } |
149 | 150 | ||
150 | bool Serializer::parseXml(const QCString &buffer) | 151 | bool Serializer::parseXml(const QCString &buffer) |
151 | { | 152 | { |
152 | PWM_ASSERT(domDoc); | 153 | PWM_ASSERT(domDoc); |
153 | #ifndef PWM_EMBEDDED | 154 | #ifndef PWM_EMBEDDED |
154 | if (!domDoc->setContent(buffer, true)) | 155 | if (!domDoc->setContent(buffer, true)) |
155 | return false; | 156 | return false; |
156 | #else | 157 | #else |
157 | if (!domDoc->setContent(buffer)) | 158 | if (!domDoc->setContent(buffer)) |
158 | return false; | 159 | return false; |
159 | #endif | 160 | #endif |
160 | if (!checkValid()) | 161 | if (!checkValid()) |
161 | return false; | 162 | return false; |
162 | return true; | 163 | return true; |
163 | } | 164 | } |
164 | 165 | ||
165 | QCString Serializer::getXml() | 166 | QCString Serializer::getXml() |
166 | { | 167 | { |
167 | PWM_ASSERT(domDoc); | 168 | PWM_ASSERT(domDoc); |
168 | 169 | ||
169 | #ifndef PWM_EMBEDDED | 170 | #ifndef PWM_EMBEDDED |
170 | #if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0 | 171 | #if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0 |
171 | QCString tmp(domDoc->toCString(8)); | 172 | QCString tmp(domDoc->toCString(8)); |
172 | printDebug("<BEGIN Serializer::getXml() dump>\n"); | 173 | printDebug("<BEGIN Serializer::getXml() dump>\n"); |
173 | cout << tmp << endl; | 174 | cout << tmp << endl; |
174 | printDebug("<END Serializer::getXml() dump>"); | 175 | printDebug("<END Serializer::getXml() dump>"); |
175 | #endif // DEBUG | 176 | #endif // DEBUG |
176 | 177 | ||
177 | QCString ret(domDoc->toCString(0)); | 178 | QCString ret(domDoc->toCString(0)); |
178 | ret.replace('\n', ""); | 179 | ret.replace('\n', ""); |
179 | return ret; | 180 | return ret; |
180 | #else | 181 | #else |
181 | 182 | ||
182 | #if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0 | 183 | #if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0 |
183 | QCString tmp(" " + domDoc->toCString()); | 184 | QCString tmp(" " + domDoc->toCString()); |
184 | printDebug("<BEGIN Serializer::getXml() dump>\n"); | 185 | printDebug("<BEGIN Serializer::getXml() dump>\n"); |
185 | cout << tmp << endl; | 186 | cout << tmp << endl; |
186 | printDebug("<END Serializer::getXml() dump>"); | 187 | printDebug("<END Serializer::getXml() dump>"); |
187 | #endif // DEBUG | 188 | #endif // DEBUG |
188 | 189 | ||
189 | QCString ret(domDoc->toCString()); | 190 | QCString ret(domDoc->toCString()); |
190 | ret.replace(QRegExp("\n"), ""); | 191 | ret.replace(QRegExp("\n"), ""); |
191 | return ret; | 192 | return ret; |
192 | 193 | ||
193 | #endif | 194 | #endif |
194 | } | 195 | } |
195 | 196 | ||
196 | bool Serializer::serialize(const vector<PwMCategoryItem> &dta) | 197 | bool Serializer::serialize(const vector<PwMCategoryItem> &dta) |
197 | { | 198 | { |
198 | PWM_ASSERT(domDoc); | 199 | PWM_ASSERT(domDoc); |
199 | QDomElement root(genNewRoot()); | 200 | QDomElement root(genNewRoot()); |
200 | QDomElement catNode(domDoc->createElement(CAT_ROOT_WR)); | 201 | QDomElement catNode(domDoc->createElement(CAT_ROOT_WR)); |
201 | root.appendChild(catNode); | 202 | root.appendChild(catNode); |
202 | if (!addCategories(&catNode, dta)) | 203 | if (!addCategories(&catNode, dta)) |
203 | return false; | 204 | return false; |
204 | return true; | 205 | return true; |
205 | } | 206 | } |
206 | 207 | ||
207 | bool Serializer::deSerialize(vector<PwMCategoryItem> *dta) | 208 | bool Serializer::deSerialize(vector<PwMCategoryItem> *dta) |
208 | { | 209 | { |
209 | PWM_ASSERT(domDoc); | 210 | PWM_ASSERT(domDoc); |
210 | PWM_ASSERT(dta); | 211 | PWM_ASSERT(dta); |
211 | QDomElement root(domDoc->documentElement()); | 212 | QDomElement root(domDoc->documentElement()); |
212 | QDomNode n; | 213 | QDomNode n; |
213 | 214 | ||
214 | dta->clear(); | 215 | dta->clear(); |
215 | for (n = root.firstChild(); !n.isNull(); n = n.nextSibling()) { | 216 | for (n = root.firstChild(); !n.isNull(); n = n.nextSibling()) { |
216 | // find <categories> ... </categories> | 217 | // find <categories> ... </categories> |