-rw-r--r-- | noncore/apps/zsafe/zsafe.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp index 824b841..0864293 100644 --- a/noncore/apps/zsafe/zsafe.cpp +++ b/noncore/apps/zsafe/zsafe.cpp | |||
@@ -1740,385 +1740,385 @@ void ZSafe::readAllEntries() | |||
1740 | int len=s.length()+1; | 1740 | int len=s.length()+1; |
1741 | #ifdef WIN32 | 1741 | #ifdef WIN32 |
1742 | char buffer[512]; | 1742 | char buffer[512]; |
1743 | #else | 1743 | #else |
1744 | char buffer[len]; | 1744 | char buffer[len]; |
1745 | #endif | 1745 | #endif |
1746 | strcpy (buffer, s); | 1746 | strcpy (buffer, s); |
1747 | 1747 | ||
1748 | QString name; | 1748 | QString name; |
1749 | QString user; | 1749 | QString user; |
1750 | QString password; | 1750 | QString password; |
1751 | QString comment; | 1751 | QString comment; |
1752 | 1752 | ||
1753 | // separete the entries | 1753 | // separete the entries |
1754 | char *i = strtok (buffer, "|"); | 1754 | char *i = strtok (buffer, "|"); |
1755 | QString category(&i[1]); | 1755 | QString category(&i[1]); |
1756 | category.truncate(category.length() -1); | 1756 | category.truncate(category.length() -1); |
1757 | 1757 | ||
1758 | int idx=0; | 1758 | int idx=0; |
1759 | while (i = strtok (NULL, "|")) | 1759 | while (i = strtok (NULL, "|")) |
1760 | { | 1760 | { |
1761 | switch (idx) | 1761 | switch (idx) |
1762 | { | 1762 | { |
1763 | case 0: | 1763 | case 0: |
1764 | name = &i[1]; | 1764 | name = &i[1]; |
1765 | name.truncate(name.length() -1); | 1765 | name.truncate(name.length() -1); |
1766 | // name | 1766 | // name |
1767 | break; | 1767 | break; |
1768 | case 1: | 1768 | case 1: |
1769 | // user | 1769 | // user |
1770 | user = &i[1]; | 1770 | user = &i[1]; |
1771 | user.truncate(user.length() -1); | 1771 | user.truncate(user.length() -1); |
1772 | break; | 1772 | break; |
1773 | case 2: | 1773 | case 2: |
1774 | // password | 1774 | // password |
1775 | password = &i[1]; | 1775 | password = &i[1]; |
1776 | password.truncate(password.length() -1); | 1776 | password.truncate(password.length() -1); |
1777 | break; | 1777 | break; |
1778 | case 3: | 1778 | case 3: |
1779 | // comment | 1779 | // comment |
1780 | comment = &i[1]; | 1780 | comment = &i[1]; |
1781 | comment.truncate(comment.length() -1); | 1781 | comment.truncate(comment.length() -1); |
1782 | break; | 1782 | break; |
1783 | } | 1783 | } |
1784 | idx++; | 1784 | idx++; |
1785 | } | 1785 | } |
1786 | 1786 | ||
1787 | Category *cat= categories.find (category); | 1787 | Category *cat= categories.find (category); |
1788 | if (cat) | 1788 | if (cat) |
1789 | { | 1789 | { |
1790 | // use the existend item | 1790 | // use the existend item |
1791 | QListViewItem *catItem = cat->getListItem(); | 1791 | QListViewItem *catItem = cat->getListItem(); |
1792 | if (catItem) | 1792 | if (catItem) |
1793 | { | 1793 | { |
1794 | QListViewItem * item = new ShadedListItem( 0, catItem ); | 1794 | QListViewItem * item = new ShadedListItem( 0, catItem ); |
1795 | item->setText( 0, tr( name ) ); | 1795 | item->setText( 0, tr( name ) ); |
1796 | item->setText( 1, tr( user ) ); | 1796 | item->setText( 1, tr( user ) ); |
1797 | item->setText( 2, tr( password ) ); | 1797 | item->setText( 2, tr( password ) ); |
1798 | item->setText( 3, tr( comment ) ); | 1798 | item->setText( 3, tr( comment ) ); |
1799 | 1799 | ||
1800 | catItem->setOpen( TRUE ); | 1800 | catItem->setOpen( TRUE ); |
1801 | } | 1801 | } |
1802 | } | 1802 | } |
1803 | else | 1803 | else |
1804 | { | 1804 | { |
1805 | QListViewItem *catI = new ShadedListItem( 1, ListView ); | 1805 | QListViewItem *catI = new ShadedListItem( 1, ListView ); |
1806 | // create and insert a new item | 1806 | // create and insert a new item |
1807 | QListViewItem * item = new ShadedListItem( 0, catI ); | 1807 | QListViewItem * item = new ShadedListItem( 0, catI ); |
1808 | item->setText( 0, tr( name ) ); | 1808 | item->setText( 0, tr( name ) ); |
1809 | item->setText( 1, tr( user ) ); | 1809 | item->setText( 1, tr( user ) ); |
1810 | item->setText( 2, tr( password ) ); | 1810 | item->setText( 2, tr( password ) ); |
1811 | item->setText( 3, tr( comment ) ); | 1811 | item->setText( 3, tr( comment ) ); |
1812 | 1812 | ||
1813 | catI->setOpen( TRUE ); | 1813 | catI->setOpen( TRUE ); |
1814 | 1814 | ||
1815 | Category *c1 = new Category(); | 1815 | Category *c1 = new Category(); |
1816 | c1->setCategoryName(category); | 1816 | c1->setCategoryName(category); |
1817 | 1817 | ||
1818 | QString icon; | 1818 | QString icon; |
1819 | QString fullIconPath; | 1819 | QString fullIconPath; |
1820 | QPixmap *pix; | 1820 | QPixmap *pix; |
1821 | // #ifndef WIN32 | 1821 | // #ifndef WIN32 |
1822 | icon = conf->readEntry(APP_KEY+category); | 1822 | icon = conf->readEntry(APP_KEY+category); |
1823 | // #endif | 1823 | // #endif |
1824 | bool isIconAv = false; | 1824 | bool isIconAv = false; |
1825 | if (!icon.isEmpty() && !icon.isNull()) | 1825 | if (!icon.isEmpty() && !icon.isNull()) |
1826 | { | 1826 | { |
1827 | // build the full path | 1827 | // build the full path |
1828 | fullIconPath = iconPath + icon; | 1828 | fullIconPath = iconPath + icon; |
1829 | pix = new QPixmap (fullIconPath); | 1829 | pix = new QPixmap (fullIconPath); |
1830 | if (!pix->isNull()) | 1830 | if (!pix->isNull()) |
1831 | { | 1831 | { |
1832 | QImage img = pix->convertToImage(); | 1832 | QImage img = pix->convertToImage(); |
1833 | pix->convertFromImage(img.smoothScale(14,14)); | 1833 | pix->convertFromImage(img.smoothScale(14,14)); |
1834 | c1->setIconName (icon); | 1834 | c1->setIconName (icon); |
1835 | c1->setIcon (*pix); | 1835 | c1->setIcon (*pix); |
1836 | isIconAv = true; | 1836 | isIconAv = true; |
1837 | } | 1837 | } |
1838 | } | 1838 | } |
1839 | if (!isIconAv) | 1839 | if (!isIconAv) |
1840 | { | 1840 | { |
1841 | c1->setIcon (*getPredefinedIcon(category)); | 1841 | c1->setIcon (*getPredefinedIcon(category)); |
1842 | } | 1842 | } |
1843 | c1->setListItem (catI); | 1843 | c1->setListItem (catI); |
1844 | c1->initListItem(); | 1844 | c1->initListItem(); |
1845 | categories.insert (c1->getCategoryName(), c1); | 1845 | categories.insert (c1->getCategoryName(), c1); |
1846 | } | 1846 | } |
1847 | 1847 | ||
1848 | } | 1848 | } |
1849 | f.close(); | 1849 | f.close(); |
1850 | 1850 | ||
1851 | } | 1851 | } |
1852 | #endif // UNUSED | 1852 | #endif // UNUSED |
1853 | 1853 | ||
1854 | void ZSafe::resume(int) | 1854 | void ZSafe::resume(int) |
1855 | { | 1855 | { |
1856 | #ifndef NO_OPIE | 1856 | #ifndef NO_OPIE |
1857 | owarn << "Resume" << oendl; | 1857 | owarn << "Resume" << oendl; |
1858 | #endif | 1858 | #endif |
1859 | // hide the main window | 1859 | // hide the main window |
1860 | 1860 | ||
1861 | if ( !showpwd ) | 1861 | if ( !showpwd ) |
1862 | { | 1862 | { |
1863 | infoForm->hide(); | 1863 | infoForm->hide(); |
1864 | // open zsafe again | 1864 | // open zsafe again |
1865 | m_password = ""; | 1865 | m_password = ""; |
1866 | selectedItem = NULL; | 1866 | selectedItem = NULL; |
1867 | 1867 | ||
1868 | // clear the password list | 1868 | // clear the password list |
1869 | QListViewItem *i; | 1869 | QListViewItem *i; |
1870 | // step through all categories | 1870 | // step through all categories |
1871 | for (i = ListView->firstChild(); | 1871 | for (i = ListView->firstChild(); |
1872 | i != NULL; | 1872 | i != NULL; |
1873 | i = i->nextSibling()) | 1873 | i = i->nextSibling()) |
1874 | { | 1874 | { |
1875 | // step through all subitems | 1875 | // step through all subitems |
1876 | QListViewItem *si; | 1876 | QListViewItem *si; |
1877 | for (si = i->firstChild(); | 1877 | for (si = i->firstChild(); |
1878 | si != NULL; ) | 1878 | si != NULL; ) |
1879 | { | 1879 | { |
1880 | QListViewItem *_si = si; | 1880 | QListViewItem *_si = si; |
1881 | si = si->nextSibling(); | 1881 | si = si->nextSibling(); |
1882 | i->takeItem(_si); // remove from view list | 1882 | i->takeItem(_si); // remove from view list |
1883 | if (_si) delete _si; | 1883 | if (_si) delete _si; |
1884 | } | 1884 | } |
1885 | } | 1885 | } |
1886 | 1886 | ||
1887 | // ask for password and read again | 1887 | // ask for password and read again |
1888 | openDocument(filename); | 1888 | openDocument(filename); |
1889 | } | 1889 | } |
1890 | } | 1890 | } |
1891 | 1891 | ||
1892 | //--------------------------------------------- | 1892 | //--------------------------------------------- |
1893 | 1893 | ||
1894 | 1894 | ||
1895 | bool ZSafe::openDocument(const char* _filename, const char* ) | 1895 | bool ZSafe::openDocument(const char* _filename, const char* ) |
1896 | { | 1896 | { |
1897 | int retval; | 1897 | int retval; |
1898 | char* entry[FIELD_SIZE]; | 1898 | char* entry[FIELD_SIZE]; |
1899 | // #ifndef WIN32 | 1899 | // #ifndef WIN32 |
1900 | int validationFlag = conf->readNumEntry(APP_KEY+"valzsafe", 1); | 1900 | int validationFlag = conf->readNumEntry(APP_KEY+"valzsafe", 1); |
1901 | // #else | 1901 | // #else |
1902 | // int validationFlag = 1; | 1902 | // int validationFlag = 1; |
1903 | // #endif | 1903 | // #endif |
1904 | 1904 | ||
1905 | int pwdOk = 0; | 1905 | int pwdOk = 0; |
1906 | int numberOfTries = 3; | 1906 | int numberOfTries = 3; |
1907 | for (int i=0; i < numberOfTries; i++) | 1907 | for (int i=0; i < numberOfTries; i++) |
1908 | { | 1908 | { |
1909 | QFile f(_filename); | 1909 | QFile f(_filename); |
1910 | if (f.exists()) | 1910 | if (f.exists()) |
1911 | { | 1911 | { |
1912 | // ask with a dialog for the password | 1912 | // ask with a dialog for the password |
1913 | if (m_password.isEmpty()) | 1913 | if (m_password.isEmpty()) |
1914 | getDocPassword(tr("Enter Password")); | 1914 | getDocPassword(tr("Enter Password")); |
1915 | if (m_password.isEmpty() && validationFlag == 0) | 1915 | if (m_password.isEmpty() && validationFlag == 0) |
1916 | { | 1916 | { |
1917 | #ifndef NO_OPIE | 1917 | #ifndef NO_OPIE |
1918 | owarn << "Wrong password" << oendl; | 1918 | owarn << "Wrong password" << oendl; |
1919 | #else | 1919 | #else |
1920 | qWarning ("Wrong password"); | 1920 | qWarning ("Wrong password"); |
1921 | #endif | 1921 | #endif |
1922 | QMessageBox::critical( 0, tr("ZSafe"), | 1922 | QMessageBox::critical( 0, tr("ZSafe"), |
1923 | tr("Wrong password.\n\nZSafe will now exit.") ); | 1923 | tr("Wrong password.\n\nZSafe will now exit.") ); |
1924 | exitZs (1); | 1924 | exitZs (1); |
1925 | } | 1925 | } |
1926 | 1926 | ||
1927 | retval = loadInit(_filename, m_password); | 1927 | retval = loadInit(_filename, m_password); |
1928 | if (retval != PWERR_GOOD) | 1928 | if (retval != PWERR_GOOD) |
1929 | { | 1929 | { |
1930 | #ifndef NO_OPIE | 1930 | #ifndef NO_OPIE |
1931 | owarn << "Error loading Document" << oendl; | 1931 | owarn << "Error loading Document" << oendl; |
1932 | #lese | 1932 | #else |
1933 | qWarning ("Error loading Document"); | 1933 | qWarning ("Error loading Document"); |
1934 | #endif | 1934 | #endif |
1935 | return false; | 1935 | return false; |
1936 | } | 1936 | } |
1937 | } | 1937 | } |
1938 | else | 1938 | else |
1939 | { | 1939 | { |
1940 | #ifdef WIN32 | 1940 | #ifdef WIN32 |
1941 | this->setCaption("Qt ZSafe"); | 1941 | this->setCaption("Qt ZSafe"); |
1942 | #else | 1942 | #else |
1943 | this->setCaption("ZSafe"); | 1943 | this->setCaption("ZSafe"); |
1944 | #endif | 1944 | #endif |
1945 | filename = ""; | 1945 | filename = ""; |
1946 | return false; | 1946 | return false; |
1947 | } | 1947 | } |
1948 | 1948 | ||
1949 | 1949 | ||
1950 | // load the validation entry | 1950 | // load the validation entry |
1951 | if (validationFlag == 0) | 1951 | if (validationFlag == 0) |
1952 | { | 1952 | { |
1953 | pwdOk = 1; | 1953 | pwdOk = 1; |
1954 | break; | 1954 | break; |
1955 | } | 1955 | } |
1956 | 1956 | ||
1957 | retval = loadEntry(entry); | 1957 | retval = loadEntry(entry); |
1958 | if (retval == 1 && | 1958 | if (retval == 1 && |
1959 | !strcmp (entry[0], "ZSAFECATEGORY") && | 1959 | !strcmp (entry[0], "ZSAFECATEGORY") && |
1960 | !strcmp (entry[1], "name") && | 1960 | !strcmp (entry[1], "name") && |
1961 | !strcmp (entry[2], "username") && | 1961 | !strcmp (entry[2], "username") && |
1962 | !strcmp (entry[3], "password") && | 1962 | !strcmp (entry[3], "password") && |
1963 | !strcmp (entry[4], "comment") ) | 1963 | !strcmp (entry[4], "comment") ) |
1964 | { | 1964 | { |
1965 | for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]); | 1965 | for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]); |
1966 | pwdOk = 1; | 1966 | pwdOk = 1; |
1967 | break; | 1967 | break; |
1968 | } | 1968 | } |
1969 | else | 1969 | else |
1970 | // for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]); | 1970 | // for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]); |
1971 | fclose (fd); | 1971 | fclose (fd); |
1972 | m_password = ""; | 1972 | m_password = ""; |
1973 | 1973 | ||
1974 | if (i < numberOfTries - 1) | 1974 | if (i < numberOfTries - 1) |
1975 | { | 1975 | { |
1976 | switch( QMessageBox::warning( this, tr("ZSafe"), | 1976 | switch( QMessageBox::warning( this, tr("ZSafe"), |
1977 | tr("Wrong password.\nEnter again?"), | 1977 | tr("Wrong password.\nEnter again?"), |
1978 | tr("&Yes"), tr("&No."), | 1978 | tr("&Yes"), tr("&No."), |
1979 | 0 | 1979 | 0 |
1980 | ) ) | 1980 | ) ) |
1981 | { | 1981 | { |
1982 | case 1: // No | 1982 | case 1: // No |
1983 | exitZs (1); | 1983 | exitZs (1); |
1984 | break; | 1984 | break; |
1985 | case 0: // Yes | 1985 | case 0: // Yes |
1986 | continue; | 1986 | continue; |
1987 | } | 1987 | } |
1988 | } | 1988 | } |
1989 | } | 1989 | } |
1990 | if (pwdOk == 0) | 1990 | if (pwdOk == 0) |
1991 | { | 1991 | { |
1992 | // unset the document entry | 1992 | // unset the document entry |
1993 | conf->writeEntry(APP_KEY+"document", "INVALIDPWD"); | 1993 | conf->writeEntry(APP_KEY+"document", "INVALIDPWD"); |
1994 | if (conf) | 1994 | if (conf) |
1995 | delete conf; | 1995 | delete conf; |
1996 | 1996 | ||
1997 | exitZs (1); | 1997 | exitZs (1); |
1998 | } | 1998 | } |
1999 | 1999 | ||
2000 | 2000 | ||
2001 | retval = loadEntry(entry); | 2001 | retval = loadEntry(entry); |
2002 | 2002 | ||
2003 | int numberOfEntries=0; | 2003 | int numberOfEntries=0; |
2004 | while (retval == 1) { | 2004 | while (retval == 1) { |
2005 | 2005 | ||
2006 | QString category( QString::fromUtf8(entry[0]) ); | 2006 | QString category( QString::fromUtf8(entry[0]) ); |
2007 | QString name( QString::fromUtf8(entry[1]) ); | 2007 | QString name( QString::fromUtf8(entry[1]) ); |
2008 | QString user( QString::fromUtf8(entry[2]) ); | 2008 | QString user( QString::fromUtf8(entry[2]) ); |
2009 | QString password( QString::fromUtf8(entry[3]) ); | 2009 | QString password( QString::fromUtf8(entry[3]) ); |
2010 | QString comment( QString::fromUtf8(entry[4]) ); | 2010 | QString comment( QString::fromUtf8(entry[4]) ); |
2011 | QString field5( QString::fromUtf8(entry[5]) ); | 2011 | QString field5( QString::fromUtf8(entry[5]) ); |
2012 | QString field6( QString::fromUtf8(entry[6]) ); | 2012 | QString field6( QString::fromUtf8(entry[6]) ); |
2013 | // add the subitems to the categories | 2013 | // add the subitems to the categories |
2014 | 2014 | ||
2015 | Category *cat= categories.find (category); | 2015 | Category *cat= categories.find (category); |
2016 | if (cat) | 2016 | if (cat) |
2017 | { | 2017 | { |
2018 | // use the existend item | 2018 | // use the existend item |
2019 | QListViewItem *catItem = cat->getListItem(); | 2019 | QListViewItem *catItem = cat->getListItem(); |
2020 | if (catItem) | 2020 | if (catItem) |
2021 | { | 2021 | { |
2022 | QListViewItem * item = new ShadedListItem( 0, catItem ); | 2022 | QListViewItem * item = new ShadedListItem( 0, catItem ); |
2023 | item->setText( 0, tr( name ) ); | 2023 | item->setText( 0, tr( name ) ); |
2024 | item->setText( 1, tr( user ) ); | 2024 | item->setText( 1, tr( user ) ); |
2025 | item->setText( 2, tr( password ) ); | 2025 | item->setText( 2, tr( password ) ); |
2026 | item->setText( 3, tr( comment ) ); | 2026 | item->setText( 3, tr( comment ) ); |
2027 | item->setText( 4, tr( field5 ) ); | 2027 | item->setText( 4, tr( field5 ) ); |
2028 | item->setText( 5, tr( field6 ) ); | 2028 | item->setText( 5, tr( field6 ) ); |
2029 | 2029 | ||
2030 | if (expandTree) | 2030 | if (expandTree) |
2031 | catItem->setOpen( TRUE ); | 2031 | catItem->setOpen( TRUE ); |
2032 | numberOfEntries++; | 2032 | numberOfEntries++; |
2033 | } | 2033 | } |
2034 | } | 2034 | } |
2035 | else | 2035 | else |
2036 | { | 2036 | { |
2037 | QListViewItem *catI = new ShadedListItem( 1, ListView ); | 2037 | QListViewItem *catI = new ShadedListItem( 1, ListView ); |
2038 | // create and insert a new item | 2038 | // create and insert a new item |
2039 | QListViewItem * item = new ShadedListItem( 0, catI ); | 2039 | QListViewItem * item = new ShadedListItem( 0, catI ); |
2040 | 2040 | ||
2041 | item->setText( 0, tr( name ) ); | 2041 | item->setText( 0, tr( name ) ); |
2042 | item->setText( 1, tr( user ) ); | 2042 | item->setText( 1, tr( user ) ); |
2043 | item->setText( 2, tr( password ) ); | 2043 | item->setText( 2, tr( password ) ); |
2044 | item->setText( 3, tr( comment ) ); | 2044 | item->setText( 3, tr( comment ) ); |
2045 | item->setText( 4, tr( field5 ) ); | 2045 | item->setText( 4, tr( field5 ) ); |
2046 | item->setText( 5, tr( field6 ) ); | 2046 | item->setText( 5, tr( field6 ) ); |
2047 | 2047 | ||
2048 | if (expandTree) | 2048 | if (expandTree) |
2049 | catI->setOpen( TRUE ); | 2049 | catI->setOpen( TRUE ); |
2050 | 2050 | ||
2051 | Category *c1 = new Category(); | 2051 | Category *c1 = new Category(); |
2052 | c1->setCategoryName(category); | 2052 | c1->setCategoryName(category); |
2053 | 2053 | ||
2054 | QString icon; | 2054 | QString icon; |
2055 | QString fullIconPath; | 2055 | QString fullIconPath; |
2056 | QPixmap *pix; | 2056 | QPixmap *pix; |
2057 | // #ifndef WIN32 | 2057 | // #ifndef WIN32 |
2058 | icon = conf->readEntry(APP_KEY+category); | 2058 | icon = conf->readEntry(APP_KEY+category); |
2059 | // #endif | 2059 | // #endif |
2060 | bool isIconAv = false; | 2060 | bool isIconAv = false; |
2061 | if (!icon.isEmpty() && !icon.isNull()) | 2061 | if (!icon.isEmpty() && !icon.isNull()) |
2062 | { | 2062 | { |
2063 | // build the full path | 2063 | // build the full path |
2064 | fullIconPath = iconPath + icon; | 2064 | fullIconPath = iconPath + icon; |
2065 | pix = new QPixmap (fullIconPath); | 2065 | pix = new QPixmap (fullIconPath); |
2066 | if (!pix->isNull()) | 2066 | if (!pix->isNull()) |
2067 | { | 2067 | { |
2068 | QImage img = pix->convertToImage(); | 2068 | QImage img = pix->convertToImage(); |
2069 | pix->convertFromImage(img.smoothScale(14,14)); | 2069 | pix->convertFromImage(img.smoothScale(14,14)); |
2070 | c1->setIconName (icon); | 2070 | c1->setIconName (icon); |
2071 | c1->setIcon (*pix); | 2071 | c1->setIcon (*pix); |
2072 | isIconAv = true; | 2072 | isIconAv = true; |
2073 | } | 2073 | } |
2074 | } | 2074 | } |
2075 | if (!isIconAv) | 2075 | if (!isIconAv) |
2076 | { | 2076 | { |
2077 | c1->setIcon (*getPredefinedIcon(category)); | 2077 | c1->setIcon (*getPredefinedIcon(category)); |
2078 | } | 2078 | } |
2079 | 2079 | ||
2080 | c1->setListItem (catI); | 2080 | c1->setListItem (catI); |
2081 | c1->initListItem(); | 2081 | c1->initListItem(); |
2082 | categories.insert (c1->getCategoryName(), c1); | 2082 | categories.insert (c1->getCategoryName(), c1); |
2083 | numberOfEntries++; | 2083 | numberOfEntries++; |
2084 | } | 2084 | } |
2085 | 2085 | ||
2086 | for (int count = 0; count < FIELD_SIZE; count++) { | 2086 | for (int count = 0; count < FIELD_SIZE; count++) { |
2087 | free(entry[count]); | 2087 | free(entry[count]); |
2088 | } | 2088 | } |
2089 | retval = loadEntry(entry); | 2089 | retval = loadEntry(entry); |
2090 | if (retval == 2) { | 2090 | if (retval == 2) { |
2091 | // m_parent->slotStatusHelpMsg("Last entry loaded"); | 2091 | // m_parent->slotStatusHelpMsg("Last entry loaded"); |
2092 | } | 2092 | } |
2093 | } // end while | 2093 | } // end while |
2094 | 2094 | ||
2095 | if (numberOfEntries == 0) | 2095 | if (numberOfEntries == 0) |
2096 | { | 2096 | { |
2097 | 2097 | ||
2098 | switch( QMessageBox::warning( this, tr("ZSafe"), | 2098 | switch( QMessageBox::warning( this, tr("ZSafe"), |
2099 | tr("Empty document or\nwrong password.\nContinue?"), | 2099 | tr("Empty document or\nwrong password.\nContinue?"), |
2100 | tr("&No"), tr("&Yes."), | 2100 | tr("&No"), tr("&Yes."), |
2101 | 0 | 2101 | 0 |
2102 | ) ) { | 2102 | ) ) { |
2103 | case 0: // No | 2103 | case 0: // No |
2104 | retval = loadFinalize(); | 2104 | retval = loadFinalize(); |
2105 | exitZs (1); | 2105 | exitZs (1); |
2106 | break; | 2106 | break; |
2107 | case 1: // Yes | 2107 | case 1: // Yes |
2108 | break; | 2108 | break; |
2109 | } | 2109 | } |
2110 | } | 2110 | } |
2111 | 2111 | ||
2112 | retval = loadFinalize(); | 2112 | retval = loadFinalize(); |
2113 | 2113 | ||
2114 | return true; | 2114 | return true; |
2115 | } | 2115 | } |
2116 | 2116 | ||
2117 | int ZSafe::loadInit(const char* _filename, const char *password) | 2117 | int ZSafe::loadInit(const char* _filename, const char *password) |
2118 | { | 2118 | { |
2119 | unsigned int j = 0; | 2119 | unsigned int j = 0; |
2120 | unsigned int keylength=0; | 2120 | unsigned int keylength=0; |
2121 | int count=0, count2=0, count3=0; | 2121 | int count=0, count2=0, count3=0; |
2122 | unsigned char charbuf[8]; | 2122 | unsigned char charbuf[8]; |
2123 | unsigned short ciphertext[4]; | 2123 | unsigned short ciphertext[4]; |
2124 | char key[128]; | 2124 | char key[128]; |