summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-10-20 18:38:39 (UTC)
committer ulf69 <ulf69>2004-10-20 18:38:39 (UTC)
commit8e00329a4a5f0b66d26d20f067ab6aefca17f17a (patch) (side-by-side diff)
tree9fa40d29baece91dc854b7e124c3bbc2962a0729
parent13243e1fb1855d306d45a84365f55e20efeff69d (diff)
downloadkdepimpi-8e00329a4a5f0b66d26d20f067ab6aefca17f17a.zip
kdepimpi-8e00329a4a5f0b66d26d20f067ab6aefca17f17a.tar.gz
kdepimpi-8e00329a4a5f0b66d26d20f067ab6aefca17f17a.tar.bz2
removed dead code
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--pwmanager/pwmanager/pwm.cpp30
-rw-r--r--pwmanager/pwmanager/pwmdoc.cpp25
2 files changed, 27 insertions, 28 deletions
diff --git a/pwmanager/pwmanager/pwm.cpp b/pwmanager/pwmanager/pwm.cpp
index c511661..66d26d6 100644
--- a/pwmanager/pwmanager/pwm.cpp
+++ b/pwmanager/pwmanager/pwm.cpp
@@ -697,66 +697,66 @@ void PwM::editPwd_slot3(const QString *category, const int *index,
PwMDataItem currItem;
if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) {
doc->timer()->putLock(DocTimer::id_autoLockTimer);
return;
}
BUG_ON(currItem.binary);
AddEntryWndImpl w;
vector<string> catList;
doc->getCategoryList(&catList);
unsigned i, size = catList.size();
for (i = 0; i < size; ++i) {
w.addCategory(catList[i].c_str());
}
w.setCurrCategory(curCategory);
w.setDescription(currItem.desc.c_str());
w.setUsername(currItem.name.c_str());
w.setPassword(currItem.pw.c_str());
w.setUrl(currItem.url.c_str());
w.setLauncher(currItem.launcher.c_str());
w.setComment(currItem.comment.c_str());
if (w.exec() == 1) {
currItem.desc = w.getDescription().latin1();
currItem.name = w.getUsername().latin1();
currItem.pw = w.getPassword().latin1();
currItem.comment = w.getComment().latin1();
currItem.url = w.getUrl().latin1();
currItem.launcher = w.getLauncher().latin1();
if (!doc->editEntry(curCategory, w.getCategory(),
curEntryIndex, &currItem)) {
KMessageBox::error(this,
i18n("Couldn't edit the entry.\n"
- "Maybe you changed the category and "
- "this entry is already present in the new "
+ "Maybe you changed the category and\n"
+ "this entry is already present\nin the new "
"category?"),
i18n("couldn't edit entry."));
doc->timer()->putLock(DocTimer::id_autoLockTimer);
return;
}
}
doc->timer()->putLock(DocTimer::id_autoLockTimer);
}
void PwM::deletePwd_slot()
{
PWM_ASSERT(curDoc());
if (curDoc()->isDocEmpty())
return;
if (curDoc()->isDeepLocked())
return;
curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
unsigned int curEntryIndex = 0;
if (!(view->getCurEntryIndex(&curEntryIndex))) {
printDebug("couldn't get index");
curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
return;
}
PwMDataItem currItem;
QString curCategory = view->getCurrentCategory();
if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) {
printDebug("couldn't get entry");
curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
return;
}
if (KMessageBox::
@@ -886,116 +886,116 @@ void PwM::find_slot()
if (curDoc()->isDeepLocked())
return;
curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
FindWndImpl findWnd(view);
findWnd.exec();
curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
}
void PwM::exportToText()
{
PWM_ASSERT(curDoc());
if (curDoc()->isDocEmpty()) {
KMessageBox::information(this,
i18n
("Sorry, there's nothing to export.\n"
"Please first add some passwords."),
i18n("nothing to do"));
return;
}
curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
QString fn(KFileDialog::getSaveFileName(QString::null,
i18n("*|plain-text file"),
this));
if (fn == "") {
curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
return;
}
PwMerror ret = curDoc()->exportToText(&fn);
if (ret != e_success) {
KMessageBox::error(this,
i18n("Error: Couldn't write to file.\n"
- "Please check if you have permission to write "
+ "Please check if you have permission to write\n"
"to the file in that directory."),
i18n("error while writing"));
} else
showStatMsg(i18n("Successfully exported data."));
curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
}
bool PwM::importFromText()
{
if (!isVirgin()) {
if (KMessageBox::questionYesNo(this,
- i18n("Do you want to import the data "
- "into the current document? (If you "
- "select \"no\", a new document will be "
+ i18n("Do you want to import the data\n"
+ "into the current document? (If you\n"
+ "select \"no\", a new document will be\n"
"opened.)"),
i18n("import into this document?"))
== KMessageBox::No) {
// import the data to a new window.
PwM *newInstance = init->createMainWnd();
bool ok = newInstance->importFromText();
if (!ok) {
newInstance->setForceQuit(true);
delete_and_null(newInstance);
}
return ok;
}
}
curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
PwMerror ret;
QString path(KFileDialog::getOpenFileName(QString::null,
i18n("*|PWM-exported text file"),
this));
if (path == "")
goto cancelImport;
ret = curDoc()->importFromText(&path, 0);
if (ret == e_fileFormat) {
KMessageBox::error(this,
i18n("Could not read file-format.\n"
- "This seems to be _not_ a valid file "
+ "This seems to be _not_ a valid file\n"
"exported by PwM."),
i18n("invalid file-format"));
goto cancelImport;
} else if (ret == e_invalidArg) {
BUG();
goto cancelImport;
} else if (ret != e_success) {
KMessageBox::error(this,
i18n("Could not import file!\n"
- "Do you have permission to read this file? "
+ "Do you have permission to read this file?\n"
"Do you have enough free memory?"),
i18n("import failed"));
goto cancelImport;
}
setVirgin(false);
curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
return true;
cancelImport:
curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
return false;
}
void PwM::exportToGpasman()
{
PWM_ASSERT(curDoc());
if (curDoc()->isDocEmpty()) {
KMessageBox::information(this,
i18n
("Sorry, there's nothing to export.\n"
"Please first add some passwords."),
i18n("nothing to do"));
return;
}
curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
QString fn(KFileDialog::getSaveFileName(QString::null,
i18n("*|Gpasman or Kpasman file"),
this));
if (fn == "") {
curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
return;
}
@@ -1020,96 +1020,96 @@ void PwM::exportToKWallet()
{
#ifdef CONFIG_KWALLETIF
if (!checkAndAskForKWalletEmu())
return;
PWM_ASSERT(curDoc());
if (curDoc()->isDocEmpty()) {
KMessageBox::information(this,
i18n
("Sorry, there's nothing to export.\n"
"Please first add some passwords."),
i18n("nothing to do"));
init->initKWalletEmu();
return;
}
curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
KWalletIf walletIf(this);
if (walletIf.kwalletExport(curDoc())) {
KMessageBox::information(this,
i18n("Successfully exported the data of the current "
"document to KWallet."),
i18n("Successfully exported data."));
showStatMsg(i18n("Successfully exported data."));
}
init->initKWalletEmu();
curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
#endif // CONFIG_KWALLETIF
}
bool PwM::importFromGpasman()
{
if (!isVirgin()) {
if (KMessageBox::questionYesNo(this,
- i18n("Do you want to import the data "
- "into the current document? (If you "
- "select \"no\", a new document will be "
+ i18n("Do you want to import the data\n"
+ "into the current document? (If you\n"
+ "select \"no\", a new document will be\n"
"opened.)"),
i18n("import into this document?"))
== KMessageBox::No) {
// import the data to a new window.
PwM *newInstance = init->createMainWnd();
bool ok = newInstance->importFromGpasman();
if (!ok) {
newInstance->setForceQuit(true);
delete_and_null(newInstance);
}
return ok;
}
}
curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
PwMerror ret;
QString path(KFileDialog::getOpenFileName(QString::null,
i18n("*|Gpasman or Kpasman file"), this));
if (path == "")
goto cancelImport;
ret = curDoc()->importFromGpasman(&path);
if (ret == e_wrongPw) {
if (KMessageBox::questionYesNo(this,
i18n
- ("This is probably the wrong master-password"
+ ("This is probably the wrong master-password\n"
"you have typed in.\n"
- "There is no real way to determine the "
- "correctness of the password in the Gpasman "
- "file-format. But I think this "
+ "There is no real way to determine the\n"
+ "correctness of the password in the Gpasman\n"
+ "file-format. But I think this\n"
"password ist wrong.\n"
"Do you want to continue nevertheless?"),
i18n("password error"))
== KMessageBox::No) {
goto cancelImport;
}
} else if (ret != e_success) {
KMessageBox::error(this,
i18n("Could not import file!\n"
"Do you have permission to read this file?"),
i18n("import failed"));
goto cancelImport;
}
setVirgin(false);
curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
return true;
cancelImport:
curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
return false;
}
#ifdef CONFIG_KWALLETIF
bool PwM::checkAndAskForKWalletEmu()
{
if (init->kwalletEmu()) {
/* KWallet emulation is enabled. We can't import/export
* data from/to it, while emulation is active.
*/
if (KMessageBox::questionYesNo(this,
i18n("KWallet emulation is enabled.\n"
"You can't import or export data from/to "
diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp
index 8869f3a..86b6273 100644
--- a/pwmanager/pwmanager/pwmdoc.cpp
+++ b/pwmanager/pwmanager/pwmdoc.cpp
@@ -1235,89 +1235,95 @@ bool PwMDoc::getEntry(unsigned int category, unsigned int index,
return true;
}
PwMerror PwMDoc::getCommentByLvp(const QString &category, int listViewPos,
string *foundComment)
{
PWM_ASSERT(foundComment);
unsigned int cat = 0;
if (!findCategory(category, &cat))
return e_invalidArg;
unsigned int i, entries = numEntries(cat);
for (i = 0; i < entries; ++i) {
if (dti.dta[cat].d[i].listViewPos == listViewPos) {
*foundComment = dti.dta[cat].d[i].comment;
if (dti.dta[cat].d[i].binary)
return e_binEntry;
return e_normalEntry;
}
}
BUG();
return e_generic;
}
bool PwMDoc::compressDta(string *d, char algo)
{
PWM_ASSERT(d);
switch (algo) {
case PWM_COMPRESS_GZIP: {
CompressGzip comp;
return comp.compress(d);
- /*US } case PWM_COMPRESS_BZIP2: {
+ }
+#ifndef PWM_EMBEDDED
+ case PWM_COMPRESS_BZIP2: {
CompressBzip2 comp;
return comp.compress(d);
-*/
- } case PWM_COMPRESS_NONE: {
+ }
+#endif
+ case PWM_COMPRESS_NONE: {
return true;
} default: {
BUG();
}
}
return false;
}
bool PwMDoc::decompressDta(string *d, char algo)
{
PWM_ASSERT(d);
switch (algo) {
case PWM_COMPRESS_GZIP: {
CompressGzip comp;
return comp.decompress(d);
- /*US } case PWM_COMPRESS_BZIP2: {
+ }
+#ifndef PWM_EMBEDDED
+ case PWM_COMPRESS_BZIP2: {
CompressBzip2 comp;
return comp.decompress(d);
- */
- } case PWM_COMPRESS_NONE: {
+ }
+#endif
+ case PWM_COMPRESS_NONE: {
return true;
}
}
return false;
}
PwMerror PwMDoc::encrypt(string *d, const QString *pw, QFile *f, char algo)
{
PWM_ASSERT(d);
PWM_ASSERT(pw);
PWM_ASSERT(f);
size_t encSize;
byte *encrypted = 0;
switch (algo) {
case PWM_CRYPT_BLOWFISH: {
Blowfish::padNull(d);
encSize = d->length();
encrypted = new byte[encSize];
Blowfish bf;
if (bf.bf_setkey((byte *) pw->latin1(), pw->length())) {
delete [] encrypted;
return e_weakPw;
}
bf.bf_encrypt((byte *) encrypted, (byte *) d->c_str(), encSize);
break;
}
case PWM_CRYPT_AES128:
/*... fall through */
case PWM_CRYPT_AES192:
case PWM_CRYPT_AES256:
@@ -3094,163 +3100,156 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s
uid = er[ incCounter ];
qDebug("sync uid %s from remote file", uid.latin1());
qApp->processEvents();
inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal );
inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote );
PWM_ASSERT(inRemote);
if ( inLocal != 0 ) { // maybe conflict - same uid in both files
if ( (take = takePwMDataItem( inLocal, inRemote, mLastSync, mode, fullDateRange) ) ) {
qDebug("take %d %s ", take, inLocal->desc.c_str());
if ( take == 3 )
return e_syncError;
if ( take == 1 ) {// take local
int oldlistpos = inRemote->listViewPos;
(*inRemote) = (*inLocal);
inRemote->listViewPos = oldlistpos;
++changedRemote;
} else { // take == 2 take remote
int oldlistpos = inLocal->listViewPos;
(*inLocal) = (*inRemote);
inLocal->listViewPos = oldlistpos;
++changedLocal;
}
}
} else { // no conflict
if ( inRemote->meta.update > mLastSync || mode == 5 ) {
inRemote->meta.update = modifiedSync;
//first check if we have a matching category in the local file
const string* remotecat = syncRemote->getCategory(catRemote);
- //US syncRemote->insertAddressee( inRemote, false );
- //US syncLocal->insertAddressee( inRemote, false );
syncLocal->addEntry(remotecat->c_str(), inRemote, true, false);
++addedPasswordsLocal;
} else {
// pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
syncRemote->delEntry(catRemote, indexRemote, true);
- //USsyncRemote->removeAddressee( inRemote );
++deletedPasswordsRemote;
}
}
++incCounter;
}
er.clear();
QStringList el = syncLocal->getIDEntryList();
modulo = (el.count()/10)+1;
manager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
incCounter = 0;
while ( incCounter < el.count()) {
qApp->processEvents();
if (manager->isProgressBarCanceled())
return e_syncError;
if ( incCounter % modulo == 0 )
manager->showProgressBar(incCounter);
uid = el[ incCounter ];
qDebug("sync uid %s from local file", uid.latin1());
inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal );
inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote );
PWM_ASSERT(inLocal);
if ( inRemote == 0 ) {
if ( inLocal->meta.update < mLastSync && mode != 4 ) {
// pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
syncLocal->delEntry(catLocal, indexLocal, true);
- //USsyncLocal->removeAddressee( inLocal );
++deletedPasswordsLocal;
} else {
if ( ! manager->mWriteBackExistingOnly ) {
++addedPasswordsRemote;
inLocal->meta.update = modifiedSync;
//first check if we have a matching category in the remote file
const string* localcat = syncLocal->getCategory(catLocal);
- //USsyncLocal->insertAddressee( inLocal, false );
PwMDataItem newEntry;
newEntry = *inLocal;
inRemote = &newEntry;
//USsyncRemote->insertAddressee( inRemote, false );
syncRemote->addEntry(localcat->c_str(), inRemote, true, false);
}
}
}
++incCounter;
}
el.clear();
manager->hideProgressBar();
// Now write the info back into the sync data space of the files
mLastSync = QDateTime::currentDateTime().addSecs( 1 );
// get rid of micro seconds
QTime t = mLastSync.time();
mLastSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
syncItemLocal->lastSyncDate = mLastSync;
syncItemRemote->lastSyncDate = mLastSync;
QString mes;
mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedPasswordsLocal, addedPasswordsRemote, changedLocal, changedRemote, deletedPasswordsLocal, deletedPasswordsRemote );
if ( manager->mShowSyncSummary ) {
KMessageBox::information(0, mes, i18n("PWM/Pi Synchronization") );
}
qDebug( mes );
return e_success;
}
int PwMDoc::takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime lastSync, int mode , bool full )
{
// 0 equal
// 1 take local
// 2 take remote
// 3 cancel
QDateTime localMod = local->meta.update;
QDateTime remoteMod = remote->meta.update;
- //US QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
-
if ( localMod == remoteMod )
return 0;
qDebug(" %d %d conflict on %s %s ", mode, full, local->desc.c_str(), remote->desc.c_str() );
//qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod);
//qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
//full = true; //debug only
if ( full ) {
bool equ = ( (*local) == (*remote) );
if ( equ ) {
//qDebug("equal ");
if ( mode < SYNC_PREF_FORCE_LOCAL )
return 0;
}//else //debug only
//qDebug("not equal %s %s ", local->desc.c_str(), remote->desc.c_str());
}
int result;
bool localIsNew;
//qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
if ( full && mode < SYNC_PREF_NEWEST )
mode = SYNC_PREF_ASK;
switch( mode ) {
case SYNC_PREF_LOCAL:
if ( lastSync > remoteMod )
return 1;
if ( lastSync > localMod )
return 2;