summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-12-04 22:43:14 (UTC)
committer zautrix <zautrix>2004-12-04 22:43:14 (UTC)
commite4e75984b6cb581d87d436cb6c5140eb57dbdc51 (patch) (unidiff)
treebd3a1ddf191fd16d24dad9910c0b806cee23000e
parentac994c86c3037dbe2273e62c46115b942b09fdcc (diff)
downloadkdepimpi-e4e75984b6cb581d87d436cb6c5140eb57dbdc51.zip
kdepimpi-e4e75984b6cb581d87d436cb6c5140eb57dbdc51.tar.gz
kdepimpi-e4e75984b6cb581d87d436cb6c5140eb57dbdc51.tar.bz2
set pwmpi update timer from 10 sec to 5 min
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/pwmdoc.cpp3
-rw-r--r--pwmanager/pwmanager/pwmview.cpp1
2 files changed, 3 insertions, 1 deletions
diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp
index a740d6d..1f15ffd 100644
--- a/pwmanager/pwmanager/pwmdoc.cpp
+++ b/pwmanager/pwmanager/pwmdoc.cpp
@@ -1,203 +1,204 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2003, 2004 by Michael Buesch * 3 * copyright (C) 2003, 2004 by Michael Buesch *
4 * email: mbuesch@freenet.de * 4 * email: mbuesch@freenet.de *
5 * * 5 * *
6 * This program is free software; you can redistribute it and/or modify * 6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License version 2 * 7 * it under the terms of the GNU General Public License version 2 *
8 * as published by the Free Software Foundation. * 8 * as published by the Free Software Foundation. *
9 * * 9 * *
10 ***************************************************************************/ 10 ***************************************************************************/
11 11
12/*************************************************************************** 12/***************************************************************************
13 * copyright (C) 2004 by Ulf Schenk 13 * copyright (C) 2004 by Ulf Schenk
14 * This file is originaly based on version 1.1 of pwmanager 14 * This file is originaly based on version 1.1 of pwmanager
15 * and was modified to run on embedded devices that run microkde 15 * and was modified to run on embedded devices that run microkde
16 * 16 *
17 * $Id$ 17 * $Id$
18 **************************************************************************/ 18 **************************************************************************/
19 19
20#include "pwmdoc.h" 20#include "pwmdoc.h"
21#include "pwmview.h" 21#include "pwmview.h"
22#include "blowfish.h" 22#include "blowfish.h"
23#include "sha1.h" 23#include "sha1.h"
24#include "globalstuff.h" 24#include "globalstuff.h"
25#include "gpasmanfile.h" 25#include "gpasmanfile.h"
26#include "serializer.h" 26#include "serializer.h"
27#include "compressgzip.h" 27#include "compressgzip.h"
28//US#include "compressbzip2.h" 28//US#include "compressbzip2.h"
29#include "randomizer.h" 29#include "randomizer.h"
30#include "pwminit.h" 30#include "pwminit.h"
31#include "libgcryptif.h" 31#include "libgcryptif.h"
32#ifdef PWM_EMBEDDED 32#ifdef PWM_EMBEDDED
33#include "pwmprefs.h" 33#include "pwmprefs.h"
34#include "kglobal.h" 34#include "kglobal.h"
35#endif 35#endif
36 36
37#include <kmessagebox.h> 37#include <kmessagebox.h>
38#include <libkcal/syncdefines.h> 38#include <libkcal/syncdefines.h>
39 39
40 40
41#ifdef CONFIG_KWALLETIF 41#ifdef CONFIG_KWALLETIF
42# include "kwalletemu.h" 42# include "kwalletemu.h"
43#endif // CONFIG_KWALLETIF 43#endif // CONFIG_KWALLETIF
44 44
45#include <qdatetime.h> 45#include <qdatetime.h>
46#include <qsize.h> 46#include <qsize.h>
47#include <qfileinfo.h> 47#include <qfileinfo.h>
48#include <qfile.h> 48#include <qfile.h>
49 49
50#include <stdio.h> 50#include <stdio.h>
51#include <stdlib.h> 51#include <stdlib.h>
52#include <errno.h> 52#include <errno.h>
53#include <string.h> 53#include <string.h>
54//US#include <iostream> 54//US#include <iostream>
55#include <algorithm> 55#include <algorithm>
56#include <sys/types.h> 56#include <sys/types.h>
57#include <sys/stat.h> 57#include <sys/stat.h>
58#ifndef _WIN32_ 58#ifndef _WIN32_
59#include <unistd.h> 59#include <unistd.h>
60#include <stdint.h> 60#include <stdint.h>
61#endif 61#endif
62 62
63#ifdef PWM_EMBEDDED 63#ifdef PWM_EMBEDDED
64#ifndef Q_LONG 64#ifndef Q_LONG
65#define Q_LONG long 65#define Q_LONG long
66#endif 66#endif
67 67
68#ifndef Q_ULONG 68#ifndef Q_ULONG
69#define Q_ULONG unsigned long 69#define Q_ULONG unsigned long
70#endif 70#endif
71#endif //PWM_EMBEDDED 71#endif //PWM_EMBEDDED
72 72
73 73
74//TODO: reset to its normal value. 74//TODO: reset to its normal value.
75 #define META_CHECK_TIMER_INTERVAL10/*300*/ /* sek */ 75//LR set to 5 min
76 #define META_CHECK_TIMER_INTERVAL300 /* 10 300*/ /* sek */
76 77
77using namespace std; 78using namespace std;
78 79
79 80
80void PwMDocList::add(PwMDoc *doc, const string &id) 81void PwMDocList::add(PwMDoc *doc, const string &id)
81{ 82{
82#ifdef PWM_DEBUG 83#ifdef PWM_DEBUG
83 // check for existance of object in debug mode only. 84 // check for existance of object in debug mode only.
84 vector<listItem>::iterator begin = docList.begin(), 85 vector<listItem>::iterator begin = docList.begin(),
85 end = docList.end(), 86 end = docList.end(),
86 i = begin; 87 i = begin;
87 while (i != end) { 88 while (i != end) {
88 if (i->doc == doc) { 89 if (i->doc == doc) {
89 BUG(); 90 BUG();
90 return; 91 return;
91 } 92 }
92 ++i; 93 ++i;
93 } 94 }
94#endif 95#endif
95 listItem newItem; 96 listItem newItem;
96 newItem.doc = doc; 97 newItem.doc = doc;
97 newItem.docId = id; 98 newItem.docId = id;
98 docList.push_back(newItem); 99 docList.push_back(newItem);
99} 100}
100 101
101void PwMDocList::edit(PwMDoc *doc, const string &newId) 102void PwMDocList::edit(PwMDoc *doc, const string &newId)
102{ 103{
103 vector<listItem>::iterator begin = docList.begin(), 104 vector<listItem>::iterator begin = docList.begin(),
104 end = docList.end(), 105 end = docList.end(),
105 i = begin; 106 i = begin;
106 while (i != end) { 107 while (i != end) {
107 if (i->doc == doc) { 108 if (i->doc == doc) {
108 i->docId = newId; 109 i->docId = newId;
109 return; 110 return;
110 } 111 }
111 ++i; 112 ++i;
112 } 113 }
113} 114}
114 115
115void PwMDocList::del(PwMDoc *doc) 116void PwMDocList::del(PwMDoc *doc)
116{ 117{
117 vector<listItem>::iterator begin = docList.begin(), 118 vector<listItem>::iterator begin = docList.begin(),
118 end = docList.end(), 119 end = docList.end(),
119 i = begin; 120 i = begin;
120 while (i != end) { 121 while (i != end) {
121 if (i->doc == doc) { 122 if (i->doc == doc) {
122 docList.erase(i); 123 docList.erase(i);
123 return; 124 return;
124 } 125 }
125 ++i; 126 ++i;
126 } 127 }
127} 128}
128 129
129bool PwMDocList::find(const string &id, listItem *ret) 130bool PwMDocList::find(const string &id, listItem *ret)
130{ 131{
131 vector<listItem>::iterator begin = docList.begin(), 132 vector<listItem>::iterator begin = docList.begin(),
132 end = docList.end(), 133 end = docList.end(),
133 i = begin; 134 i = begin;
134 while (i != end) { 135 while (i != end) {
135 if (i->docId == id) { 136 if (i->docId == id) {
136 if (ret) 137 if (ret)
137 *ret = *i; 138 *ret = *i;
138 return true; 139 return true;
139 } 140 }
140 ++i; 141 ++i;
141 } 142 }
142 return false; 143 return false;
143} 144}
144 145
145 146
146 147
147DocTimer::DocTimer(PwMDoc *_doc) 148DocTimer::DocTimer(PwMDoc *_doc)
148 : doc (_doc) 149 : doc (_doc)
149 , mpwLock (0) 150 , mpwLock (0)
150 , autoLockLock (0) 151 , autoLockLock (0)
151 , metaCheckLock (0) 152 , metaCheckLock (0)
152{ 153{
153 mpwTimer = new QTimer; 154 mpwTimer = new QTimer;
154 autoLockTimer = new QTimer; 155 autoLockTimer = new QTimer;
155 metaCheckTimer = new QTimer; 156 metaCheckTimer = new QTimer;
156 connect(mpwTimer, SIGNAL(timeout()), 157 connect(mpwTimer, SIGNAL(timeout()),
157 this, SLOT(mpwTimeout())); 158 this, SLOT(mpwTimeout()));
158 connect(autoLockTimer, SIGNAL(timeout()), 159 connect(autoLockTimer, SIGNAL(timeout()),
159 this, SLOT(autoLockTimeout())); 160 this, SLOT(autoLockTimeout()));
160 connect(metaCheckTimer, SIGNAL(timeout()), 161 connect(metaCheckTimer, SIGNAL(timeout()),
161 this, SLOT(metaCheckTimeout())); 162 this, SLOT(metaCheckTimeout()));
162} 163}
163 164
164DocTimer::~DocTimer() 165DocTimer::~DocTimer()
165{ 166{
166 delete mpwTimer; 167 delete mpwTimer;
167 delete autoLockTimer; 168 delete autoLockTimer;
168 delete metaCheckTimer; 169 delete metaCheckTimer;
169} 170}
170 171
171void DocTimer::start(TimerIDs timer) 172void DocTimer::start(TimerIDs timer)
172{ 173{
173 switch (timer) { 174 switch (timer) {
174 case id_mpwTimer: 175 case id_mpwTimer:
175 if (mpwTimer->isActive()) 176 if (mpwTimer->isActive())
176 mpwTimer->stop(); 177 mpwTimer->stop();
177 doc->setDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW); 178 doc->setDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW);
178 mpwTimer->start(conf()->confGlobPwTimeout() * 1000, true); 179 mpwTimer->start(conf()->confGlobPwTimeout() * 1000, true);
179 break; 180 break;
180 case id_autoLockTimer: 181 case id_autoLockTimer:
181 if (autoLockTimer->isActive()) 182 if (autoLockTimer->isActive())
182 autoLockTimer->stop(); 183 autoLockTimer->stop();
183 if (conf()->confGlobLockTimeout() > 0) 184 if (conf()->confGlobLockTimeout() > 0)
184 autoLockTimer->start(conf()->confGlobLockTimeout() * 1000, true); 185 autoLockTimer->start(conf()->confGlobLockTimeout() * 1000, true);
185 break; 186 break;
186 case id_metaCheckTimer: 187 case id_metaCheckTimer:
187 if (metaCheckTimer->isActive()) 188 if (metaCheckTimer->isActive())
188 metaCheckTimer->stop(); 189 metaCheckTimer->stop();
189 metaCheckTimer->start(META_CHECK_TIMER_INTERVAL * 1000, true); 190 metaCheckTimer->start(META_CHECK_TIMER_INTERVAL * 1000, true);
190 break; 191 break;
191 } 192 }
192} 193}
193 194
194void DocTimer::stop(TimerIDs timer) 195void DocTimer::stop(TimerIDs timer)
195{ 196{
196 switch (timer) { 197 switch (timer) {
197 case id_mpwTimer: 198 case id_mpwTimer:
198 mpwTimer->stop(); 199 mpwTimer->stop();
199 break; 200 break;
200 case id_autoLockTimer: 201 case id_autoLockTimer:
201 autoLockTimer->stop(); 202 autoLockTimer->stop();
202 break; 203 break;
203 case id_metaCheckTimer: 204 case id_metaCheckTimer:
diff --git a/pwmanager/pwmanager/pwmview.cpp b/pwmanager/pwmanager/pwmview.cpp
index 7733028..cd816e5 100644
--- a/pwmanager/pwmanager/pwmview.cpp
+++ b/pwmanager/pwmanager/pwmview.cpp
@@ -80,256 +80,257 @@ void PwMView::initCtxMenu()
80 ctxMenu->insertItem(i18n("&Delete"), mainClass, SLOT(deletePwd_slot())); 80 ctxMenu->insertItem(i18n("&Delete"), mainClass, SLOT(deletePwd_slot()));
81 ctxMenu->insertSeparator(); 81 ctxMenu->insertSeparator();
82 ctxMenu->insertItem(i18n("copy password to clipboard"), 82 ctxMenu->insertItem(i18n("copy password to clipboard"),
83 this, SLOT(copyPwToClip())); 83 this, SLOT(copyPwToClip()));
84 ctxMenu->insertItem(i18n("copy username to clipboard"), 84 ctxMenu->insertItem(i18n("copy username to clipboard"),
85 this, SLOT(copyNameToClip())); 85 this, SLOT(copyNameToClip()));
86 ctxMenu->insertItem(i18n("copy description to clipboard"), 86 ctxMenu->insertItem(i18n("copy description to clipboard"),
87 this, SLOT(copyDescToClip())); 87 this, SLOT(copyDescToClip()));
88 ctxMenu->insertItem(i18n("copy url to clipboard"), 88 ctxMenu->insertItem(i18n("copy url to clipboard"),
89 this, SLOT(copyUrlToClip())); 89 this, SLOT(copyUrlToClip()));
90 ctxMenu->insertItem(i18n("copy launcher to clipboard"), 90 ctxMenu->insertItem(i18n("copy launcher to clipboard"),
91 this, SLOT(copyLauncherToClip())); 91 this, SLOT(copyLauncherToClip()));
92 ctxMenu->insertItem(i18n("copy comment to clipboard"), 92 ctxMenu->insertItem(i18n("copy comment to clipboard"),
93 this, SLOT(copyCommentToClip())); 93 this, SLOT(copyCommentToClip()));
94 ctxMenu->insertSeparator(); 94 ctxMenu->insertSeparator();
95 ctxMenu->insertItem(i18n("Execute \"Launcher\""), mainClass, 95 ctxMenu->insertItem(i18n("Execute \"Launcher\""), mainClass,
96 SLOT(execLauncher_slot())); 96 SLOT(execLauncher_slot()));
97 ctxMenu->insertItem(i18n("Go to \"URL\""), mainClass, 97 ctxMenu->insertItem(i18n("Go to \"URL\""), mainClass,
98 SLOT(goToURL_slot())); 98 SLOT(goToURL_slot()));
99} 99}
100 100
101void PwMView::resizeEvent(QResizeEvent *) 101void PwMView::resizeEvent(QResizeEvent *)
102{ 102{
103 resizeView(size()); 103 resizeView(size());
104} 104}
105 105
106void PwMView::refreshCommentTextEdit(QListViewItem *curItem) 106void PwMView::refreshCommentTextEdit(QListViewItem *curItem)
107{ 107{
108 PWM_ASSERT(commentBox); 108 PWM_ASSERT(commentBox);
109 if (!curItem) 109 if (!curItem)
110 return; 110 return;
111 string comment; 111 string comment;
112 PwMerror ret; 112 PwMerror ret;
113 ret = document()->getCommentByLvp(getCurrentCategory(), 113 ret = document()->getCommentByLvp(getCurrentCategory(),
114 lv->childCount() - lv->itemIndex(curItem) - 1, 114 lv->childCount() - lv->itemIndex(curItem) - 1,
115 &comment); 115 &comment);
116 if (ret == e_binEntry) { 116 if (ret == e_binEntry) {
117 commentBox->setContent(i18n("This is a binary entry.\n" 117 commentBox->setContent(i18n("This is a binary entry.\n"
118 "It is not a normal password-entry, as it contains " 118 "It is not a normal password-entry, as it contains "
119 "binary data, which PwManager can't display here.")); 119 "binary data, which PwManager can't display here."));
120 } else if (ret == e_normalEntry) { 120 } else if (ret == e_normalEntry) {
121 commentBox->setContent(comment.c_str()); 121 commentBox->setContent(comment.c_str());
122 } else { 122 } else {
123 BUG(); 123 BUG();
124 return; 124 return;
125 } 125 }
126 lv->ensureItemVisible(curItem); 126 lv->ensureItemVisible(curItem);
127} 127}
128 128
129void PwMView::keyReleaseEvent(QKeyEvent * /*e*/) 129void PwMView::keyReleaseEvent(QKeyEvent * /*e*/)
130{ 130{
131 refreshCommentTextEdit(lv->currentItem()); 131 refreshCommentTextEdit(lv->currentItem());
132} 132}
133 133
134bool PwMView::getCurEntryIndex(unsigned int *index) 134bool PwMView::getCurEntryIndex(unsigned int *index)
135{ 135{
136 QListViewItem *current = lv->currentItem(); 136 QListViewItem *current = lv->currentItem();
137 if (!current) 137 if (!current)
138 return false; 138 return false;
139 return getDocEntryIndex(index, current); 139 return getDocEntryIndex(index, current);
140} 140}
141 141
142bool PwMView::getDocEntryIndex(unsigned int *index, 142bool PwMView::getDocEntryIndex(unsigned int *index,
143 const QListViewItem *item) 143 const QListViewItem *item)
144{ 144{
145 vector<unsigned int> foundPositions; 145 vector<unsigned int> foundPositions;
146 PwMDataItem curItem; 146 PwMDataItem curItem;
147 curItem.desc = item->text(COLUMN_DESC).latin1(); 147 curItem.desc = item->text(COLUMN_DESC).latin1();
148 curItem.name = item->text(COLUMN_NAME).latin1(); 148 curItem.name = item->text(COLUMN_NAME).latin1();
149 document()->getCommentByLvp(getCurrentCategory(), 149 document()->getCommentByLvp(getCurrentCategory(),
150 lv->childCount() - lv->itemIndex(item) - 1, 150 lv->childCount() - lv->itemIndex(item) - 1,
151 &curItem.comment); 151 &curItem.comment);
152 curItem.url = item->text(COLUMN_URL).latin1(); 152 curItem.url = item->text(COLUMN_URL).latin1();
153 curItem.launcher = item->text(COLUMN_LAUNCHER).latin1(); 153 curItem.launcher = item->text(COLUMN_LAUNCHER).latin1();
154 document()->findEntry(getCurrentCategory(), curItem, SEARCH_IN_DESC | 154 document()->findEntry(getCurrentCategory(), curItem, SEARCH_IN_DESC |
155 SEARCH_IN_NAME | SEARCH_IN_COMMENT | SEARCH_IN_URL | 155 SEARCH_IN_NAME | SEARCH_IN_COMMENT | SEARCH_IN_URL |
156 SEARCH_IN_LAUNCHER, 156 SEARCH_IN_LAUNCHER,
157 &foundPositions, true); 157 &foundPositions, true);
158 if (foundPositions.size()) { 158 if (foundPositions.size()) {
159 *index = foundPositions[0]; 159 *index = foundPositions[0];
160 return true; 160 return true;
161 } 161 }
162 162
163 return false; 163 return false;
164} 164}
165 165
166void PwMView::handleToggle(QListViewItem *item) 166void PwMView::handleToggle(QListViewItem *item)
167{ 167{
168 PWM_ASSERT(doc); 168 PWM_ASSERT(doc);
169 if (!item) 169 if (!item)
170 return; 170 return;
171 QCheckListItem *clItem = (QCheckListItem *)item; 171 QCheckListItem *clItem = (QCheckListItem *)item;
172 QString curCat(getCurrentCategory()); 172 QString curCat(getCurrentCategory());
173 173
174 // find document position of this entry. 174 // find document position of this entry.
175 unsigned int curEntryDocIndex; 175 unsigned int curEntryDocIndex;
176 if (!getDocEntryIndex(&curEntryDocIndex, item)) 176 if (!getDocEntryIndex(&curEntryDocIndex, item))
177 return; 177 return;
178 178
179 // hack to refresh the comment, if only one item is present 179 // hack to refresh the comment, if only one item is present
180 if (lv->childCount() == 1) 180 if (lv->childCount() == 1)
181 refreshCommentTextEdit(lv->currentItem()); 181 refreshCommentTextEdit(lv->currentItem());
182 182
183 if (doc->isLocked(curCat, curEntryDocIndex) != clItem->isOn()) 183 if (doc->isLocked(curCat, curEntryDocIndex) != clItem->isOn())
184 return; // this is just a click somewhere on the entry 184 return; // this is just a click somewhere on the entry
185 if (doc->isDeepLocked()) { 185 if (doc->isDeepLocked()) {
186 PwMerror ret; 186 PwMerror ret;
187 ret = doc->deepLock(false); 187 ret = doc->deepLock(false);
188 if (ret != e_success) 188 if (ret != e_success)
189 clItem->setOn(false); 189 clItem->setOn(false);
190 return; 190 return;
191 } 191 }
192 doc->lockAt(curCat, curEntryDocIndex, !clItem->isOn()); 192 doc->lockAt(curCat, curEntryDocIndex, !clItem->isOn());
193} 193}
194 194
195void PwMView::handleRightClick(QListViewItem *item, const QPoint &point, int) 195void PwMView::handleRightClick(QListViewItem *item, const QPoint &point, int)
196{ 196{
197 if (!item) 197 if (!item)
198 return; 198 return;
199 ctxMenu->move(point); 199 ctxMenu->move(point);
200 /* don't use ctxMenu->exec() here, as it generates race conditions 200 /* don't use ctxMenu->exec() here, as it generates race conditions
201 * with the card interface code. Believe it or not. :) 201 * with the card interface code. Believe it or not. :)
202 */ 202 */
203 ctxMenu->show(); 203 ctxMenu->show();
204} 204}
205 205
206void PwMView::updateCategories() 206void PwMView::updateCategories()
207{ 207{
208 qDebug("PwMView::updateCategories() ");
208 QString oldSel(getCurrentCategory()); 209 QString oldSel(getCurrentCategory());
209 delAllCategories(); 210 delAllCategories();
210 QStringList catList; 211 QStringList catList;
211 document()->getCategoryList(&catList); 212 document()->getCategoryList(&catList);
212 catList.sort(); 213 catList.sort();
213#ifndef PWM_EMBEDDED 214#ifndef PWM_EMBEDDED
214 QStringList::iterator i = catList.begin(), 215 QStringList::iterator i = catList.begin(),
215 end = catList.end(); 216 end = catList.end();
216#else 217#else
217 QStringList::Iterator i = catList.begin(), 218 QStringList::Iterator i = catList.begin(),
218 end = catList.end(); 219 end = catList.end();
219#endif 220#endif
220 while (i != end) { 221 while (i != end) {
221 addCategory(*i); 222 addCategory(*i);
222 ++i; 223 ++i;
223 } 224 }
224 selectCategory(oldSel); 225 selectCategory(oldSel);
225} 226}
226 227
227void PwMView::shiftToView() 228void PwMView::shiftToView()
228{ 229{
229 int cX = lv->contentsX(); 230 int cX = lv->contentsX();
230 int cY = lv->contentsY(); 231 int cY = lv->contentsY();
231 commentBox->clear(); 232 commentBox->clear();
232 233
233 unsigned int catDocIndex; 234 unsigned int catDocIndex;
234 if (unlikely( 235 if (unlikely(
235 !(document()->findCategory(getCurrentCategory(), 236 !(document()->findCategory(getCurrentCategory(),
236 &catDocIndex)))) { 237 &catDocIndex)))) {
237 BUG(); 238 BUG();
238 } 239 }
239 240
240 // ensure all listViewPos are set 241 // ensure all listViewPos are set
241 doc->ensureLvp(); 242 doc->ensureLvp();
242 243
243 // clear all tmp-data vectors 244 // clear all tmp-data vectors
244 unsigned int i, entries = doc->numEntries(catDocIndex); 245 unsigned int i, entries = doc->numEntries(catDocIndex);
245 if (entries) { 246 if (entries) {
246 mainClass->setVirgin(false); 247 mainClass->setVirgin(false);
247 } 248 }
248 vector<PwMDataItem> tmpSorted; 249 vector<PwMDataItem> tmpSorted;
249 PwMDataItem currItem; 250 PwMDataItem currItem;
250 currItem.clear(); 251 currItem.clear();
251 tmpSorted.insert(tmpSorted.begin(), entries, currItem); 252 tmpSorted.insert(tmpSorted.begin(), entries, currItem);
252 253
253 // Sort items and store them in tempoary tmpSorted. 254 // Sort items and store them in tempoary tmpSorted.
254 for (i = 0; i < entries; ++i) { 255 for (i = 0; i < entries; ++i) {
255 doc->getEntry(catDocIndex, i, &currItem); 256 doc->getEntry(catDocIndex, i, &currItem);
256 //qDebug("PwMView::shiftToView: %s, %i", currItem.desc.c_str(), currItem.listViewPos); 257 //qDebug("PwMView::shiftToView: %s, %i", currItem.desc.c_str(), currItem.listViewPos);
257 tmpSorted[currItem.listViewPos] = currItem; 258 tmpSorted[currItem.listViewPos] = currItem;
258 } 259 }
259 260
260 // shift tempoary data to ListView. 261 // shift tempoary data to ListView.
261 tmpDisableSort(); 262 tmpDisableSort();
262 lv->clear(); 263 lv->clear();
263 264
264 //US ENH: adjust the headers of the table according the category texts 265 //US ENH: adjust the headers of the table according the category texts
265 { 266 {
266 PwMCategoryItem* catItem = doc->getCategoryEntry(catDocIndex); 267 PwMCategoryItem* catItem = doc->getCategoryEntry(catDocIndex);
267 // qDebug("PwMView::ShiftToView CAT: %i, %s", catDocIndex, catItem->name.c_str()); 268 // qDebug("PwMView::ShiftToView CAT: %i, %s", catDocIndex, catItem->name.c_str());
268 lv->setColumnText(COLUMN_DESC, catItem->desc_text.c_str()); 269 lv->setColumnText(COLUMN_DESC, catItem->desc_text.c_str());
269 lv->setColumnText(COLUMN_NAME, catItem->name_text.c_str()); 270 lv->setColumnText(COLUMN_NAME, catItem->name_text.c_str());
270 lv->setColumnText(COLUMN_PW, catItem->pw_text.c_str()); 271 lv->setColumnText(COLUMN_PW, catItem->pw_text.c_str());
271 } 272 }
272 273
273 QCheckListItem *newItem; 274 QCheckListItem *newItem;
274 vector<PwMDataItem>::iterator it = tmpSorted.begin(), 275 vector<PwMDataItem>::iterator it = tmpSorted.begin(),
275 end = tmpSorted.end(); 276 end = tmpSorted.end();
276 while (it != end) { 277 while (it != end) {
277 newItem = new ListViewItemPwM(lv); 278 newItem = new ListViewItemPwM(lv);
278 newItem->setText(COLUMN_DESC, (*it).desc.c_str()); 279 newItem->setText(COLUMN_DESC, (*it).desc.c_str());
279 if ((*it).binary) { 280 if ((*it).binary) {
280 newItem->setText(COLUMN_NAME, ""); 281 newItem->setText(COLUMN_NAME, "");
281 newItem->setText(COLUMN_PW, i18n("<BINARY ENTRY>")); 282 newItem->setText(COLUMN_PW, i18n("<BINARY ENTRY>"));
282 newItem->setText(COLUMN_URL, ""); 283 newItem->setText(COLUMN_URL, "");
283 newItem->setText(COLUMN_LAUNCHER, (*it).launcher.c_str()); 284 newItem->setText(COLUMN_LAUNCHER, (*it).launcher.c_str());
284 } else { 285 } else {
285 newItem->setText(COLUMN_NAME, (*it).name.c_str()); 286 newItem->setText(COLUMN_NAME, (*it).name.c_str());
286 if ((*it).lockStat) { 287 if ((*it).lockStat) {
287 newItem->setText(COLUMN_PW, QString((*it).pw.c_str()) 288 newItem->setText(COLUMN_PW, QString((*it).pw.c_str())
288 + " " 289 + " "
289 + i18n("To unlock click the icon on the left.")); 290 + i18n("To unlock click the icon on the left."));
290 } else { 291 } else {
291 newItem->setText(COLUMN_PW, (*it).pw.c_str()); 292 newItem->setText(COLUMN_PW, (*it).pw.c_str());
292 } 293 }
293 newItem->setText(COLUMN_URL, (*it).url.c_str()); 294 newItem->setText(COLUMN_URL, (*it).url.c_str());
294 newItem->setText(COLUMN_LAUNCHER, (*it).launcher.c_str()); 295 newItem->setText(COLUMN_LAUNCHER, (*it).launcher.c_str());
295 } 296 }
296 newItem->setOn(!((*it).lockStat)); 297 newItem->setOn(!((*it).lockStat));
297 lv->insertItem(newItem); 298 lv->insertItem(newItem);
298 ++it; 299 ++it;
299 } 300 }
300 tmpReEnableSort(); 301 tmpReEnableSort();
301 302
302 if (cY || cX) 303 if (cY || cX)
303 lv->setContentsPos(cX, cY); 304 lv->setContentsPos(cX, cY);
304} 305}
305 306
306void PwMView::reorgLp() 307void PwMView::reorgLp()
307{ 308{
308 if (!lv->childCount()) 309 if (!lv->childCount())
309 return; 310 return;
310 PWM_ASSERT(doc); 311 PWM_ASSERT(doc);
311 PWM_ASSERT(!doc->isDocEmpty()); 312 PWM_ASSERT(!doc->isDocEmpty());
312 QListViewItem *currItem; 313 QListViewItem *currItem;
313 vector<unsigned int> foundPos; 314 vector<unsigned int> foundPos;
314 /* This searchIn _should_ be: 315 /* This searchIn _should_ be:
315 *const unsigned int searchIn = SEARCH_IN_DESC; 316 *const unsigned int searchIn = SEARCH_IN_DESC;
316 * But we want backward compatibility (see comment in PwMDoc::addEntry()). 317 * But we want backward compatibility (see comment in PwMDoc::addEntry()).
317 * So we need to search again, if we don't find the entry. (see below) 318 * So we need to search again, if we don't find the entry. (see below)
318 */ 319 */
319 const unsigned int searchIn = SEARCH_IN_DESC | SEARCH_IN_NAME | 320 const unsigned int searchIn = SEARCH_IN_DESC | SEARCH_IN_NAME |
320 SEARCH_IN_URL | SEARCH_IN_LAUNCHER; 321 SEARCH_IN_URL | SEARCH_IN_LAUNCHER;
321 QString curCat(getCurrentCategory()); 322 QString curCat(getCurrentCategory());
322 PwMDataItem findThis; 323 PwMDataItem findThis;
323 unsigned int i, cnt = lv->childCount(); 324 unsigned int i, cnt = lv->childCount();
324 for (i = 0; i < cnt; ++i) { 325 for (i = 0; i < cnt; ++i) {
325 currItem = lv->itemAtIndex(i); 326 currItem = lv->itemAtIndex(i);
326 findThis.desc = currItem->text(COLUMN_DESC).latin1(); 327 findThis.desc = currItem->text(COLUMN_DESC).latin1();
327 findThis.name = currItem->text(COLUMN_NAME).latin1(); 328 findThis.name = currItem->text(COLUMN_NAME).latin1();
328 findThis.url = currItem->text(COLUMN_URL).latin1(); 329 findThis.url = currItem->text(COLUMN_URL).latin1();
329 findThis.launcher = currItem->text(COLUMN_LAUNCHER).latin1(); 330 findThis.launcher = currItem->text(COLUMN_LAUNCHER).latin1();
330 doc->findEntry(curCat, findThis, searchIn, 331 doc->findEntry(curCat, findThis, searchIn,
331 &foundPos, true); 332 &foundPos, true);
332 if (!foundPos.size()) { 333 if (!foundPos.size()) {
333 /* Did not find the entry. We seem to have a binary 334 /* Did not find the entry. We seem to have a binary
334 * entry here (pray for it!). So search again with 335 * entry here (pray for it!). So search again with
335 * the "correct" searchIn flags. 336 * the "correct" searchIn flags.