Diffstat (limited to 'pwmanager/pwmanager/pwmdoc.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | pwmanager/pwmanager/pwmdoc.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp index b58d7e2..9213360 100644 --- a/pwmanager/pwmanager/pwmdoc.cpp +++ b/pwmanager/pwmanager/pwmdoc.cpp | |||
@@ -48,6 +48,7 @@ | |||
48 | #include <qsize.h> | 48 | #include <qsize.h> |
49 | #include <qfileinfo.h> | 49 | #include <qfileinfo.h> |
50 | #include <qfile.h> | 50 | #include <qfile.h> |
51 | #include <QDesktopWidget> | ||
51 | 52 | ||
52 | #include <stdio.h> | 53 | #include <stdio.h> |
53 | #include <stdlib.h> | 54 | #include <stdlib.h> |
@@ -481,7 +482,8 @@ PwMerror PwMDoc::saveDoc(char compress, const QString *file) | |||
481 | char rnd_buf[5]; | 482 | char rnd_buf[5]; |
482 | sprintf(rnd_buf, "%X%X%X%X", rnd->genRndChar() & 0xFF, rnd->genRndChar() & 0xFF, | 483 | sprintf(rnd_buf, "%X%X%X%X", rnd->genRndChar() & 0xFF, rnd->genRndChar() & 0xFF, |
483 | rnd->genRndChar() & 0xFF, rnd->genRndChar() & 0xFF); | 484 | rnd->genRndChar() & 0xFF, rnd->genRndChar() & 0xFF); |
484 | tmpFileMoved = filename + "." + rnd_buf + ".mv"; | 485 | tmpFileMoved = filename; tmpFileMoved += '.'; |
486 | tmpFileMoved += rnd_buf; tmpFileMoved += ".mv"; | ||
485 | if (!copyFile(filename, tmpFileMoved)) | 487 | if (!copyFile(filename, tmpFileMoved)) |
486 | return e_openFile; | 488 | return e_openFile; |
487 | if (!QFile::remove(filename)) { | 489 | if (!QFile::remove(filename)) { |
@@ -491,7 +493,7 @@ PwMerror PwMDoc::saveDoc(char compress, const QString *file) | |||
491 | } | 493 | } |
492 | } | 494 | } |
493 | f.setName(filename); | 495 | f.setName(filename); |
494 | if (!f.open(IO_ReadWrite)) { | 496 | if (!f.open(QIODevice::ReadWrite)) { |
495 | ret = e_openFile; | 497 | ret = e_openFile; |
496 | goto out_moveback; | 498 | goto out_moveback; |
497 | } | 499 | } |
@@ -634,7 +636,7 @@ PwMerror PwMDoc::openDoc(const QString *file, int openLocked) | |||
634 | goto out_success; | 636 | goto out_success; |
635 | } | 637 | } |
636 | 638 | ||
637 | if (!f.open(IO_ReadOnly)) | 639 | if (!f.open(QIODevice::ReadOnly)) |
638 | return e_openFile; | 640 | return e_openFile; |
639 | 641 | ||
640 | ret = checkHeader(&cryptAlgo, ¤tPw, &compress, &headerLen, | 642 | ret = checkHeader(&cryptAlgo, ¤tPw, &compress, &headerLen, |
@@ -1003,10 +1005,10 @@ bool PwMDoc::copyFile(const QString &src, const QString &dst) | |||
1003 | return false; | 1005 | return false; |
1004 | } | 1006 | } |
1005 | QFile srcFd(src); | 1007 | QFile srcFd(src); |
1006 | if (!srcFd.open(IO_ReadOnly)) | 1008 | if (!srcFd.open(QIODevice::ReadOnly)) |
1007 | return false; | 1009 | return false; |
1008 | QFile dstFd(dst); | 1010 | QFile dstFd(dst); |
1009 | if (!dstFd.open(IO_ReadWrite)) { | 1011 | if (!dstFd.open(QIODevice::ReadWrite)) { |
1010 | srcFd.close(); | 1012 | srcFd.close(); |
1011 | return false; | 1013 | return false; |
1012 | } | 1014 | } |
@@ -1485,7 +1487,7 @@ PwMerror PwMDoc::decrypt(string *d, unsigned int pos, const QString *pw, | |||
1485 | PWM_ASSERT(pw); | 1487 | PWM_ASSERT(pw); |
1486 | PWM_ASSERT(f); | 1488 | PWM_ASSERT(f); |
1487 | 1489 | ||
1488 | unsigned int cryptLen = f->size() - pos; | 1490 | size_t cryptLen = f->size() - pos; |
1489 | byte *encrypted = new byte[cryptLen]; | 1491 | byte *encrypted = new byte[cryptLen]; |
1490 | byte *decrypted = new byte[cryptLen]; | 1492 | byte *decrypted = new byte[cryptLen]; |
1491 | 1493 | ||
@@ -1525,9 +1527,9 @@ PwMerror PwMDoc::decrypt(string *d, unsigned int pos, const QString *pw, | |||
1525 | return e_cryptNotImpl; | 1527 | return e_cryptNotImpl; |
1526 | LibGCryptIf gc; | 1528 | LibGCryptIf gc; |
1527 | PwMerror err; | 1529 | PwMerror err; |
1528 | err = gc.decrypt(&decrypted, | 1530 | err = gc.decrypt((unsigned char **)&decrypted, |
1529 | &cryptLen, | 1531 | &cryptLen, |
1530 | encrypted, | 1532 | (unsigned char*)encrypted, |
1531 | cryptLen, | 1533 | cryptLen, |
1532 | reinterpret_cast<const unsigned char *>(pw->latin1()), | 1534 | reinterpret_cast<const unsigned char *>(pw->latin1()), |
1533 | pw->length(), | 1535 | pw->length(), |
@@ -2433,7 +2435,7 @@ PwMerror PwMDoc::exportToText(const QString *file) | |||
2433 | return e_accessFile; | 2435 | return e_accessFile; |
2434 | } | 2436 | } |
2435 | QFile f(*file); | 2437 | QFile f(*file); |
2436 | if (!f.open(IO_ReadWrite)) | 2438 | if (!f.open(QIODevice::ReadWrite)) |
2437 | return e_openFile; | 2439 | return e_openFile; |
2438 | 2440 | ||
2439 | if (!unlockAll_tempoary()) { | 2441 | if (!unlockAll_tempoary()) { |
@@ -2707,7 +2709,7 @@ PwMerror PwMDoc::importText_PwM(const QString *file) | |||
2707 | string curCat; | 2709 | string curCat; |
2708 | unsigned int entriesRead = 0; | 2710 | unsigned int entriesRead = 0; |
2709 | PwMDataItem currItem; | 2711 | PwMDataItem currItem; |
2710 | bool res = f.open(IO_ReadOnly); | 2712 | bool res = f.open(QIODevice::ReadOnly); |
2711 | if (res == false) | 2713 | if (res == false) |
2712 | return e_openFile; | 2714 | return e_openFile; |
2713 | 2715 | ||
@@ -3629,6 +3631,6 @@ QStringList PwMDoc::getIDEntryList() | |||
3629 | 3631 | ||
3630 | 3632 | ||
3631 | 3633 | ||
3632 | #ifndef PWM_EMBEDDED | 3634 | #ifndef PWM_EMBEDDED_ |
3633 | #include "pwmdoc.moc" | 3635 | #include "moc_pwmdoc.cpp" |
3634 | #endif | 3636 | #endif |