Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/kmymoney.cpp
Context not available. | |||||
470 | // add new levels above. Don't forget to increase currentFixVersion() for all | 470 | // add new levels above. Don't forget to increase currentFixVersion() for all | ||
---|---|---|---|---|---|
471 | // the storage backends this fix applies to | 471 | // the storage backends this fix applies to | ||
472 | default: | 472 | default: | ||
473 | throw MYMONEYEXCEPTION(i18n("Unknown fix level in input file")); | 473 | throw MYMONEYEXCEPTION(QString::fromLatin1("Unknown fix level in input file")); | ||
474 | } | 474 | } | ||
475 | } | 475 | } | ||
476 | ft.commit(); | 476 | ft.commit(); | ||
Context not available. | |||||
684 | try { | 684 | try { | ||
685 | if (!(*it).currencyId().isEmpty() || (*it).currencyId().length() != 0) | 685 | if (!(*it).currencyId().isEmpty() || (*it).currencyId().length() != 0) | ||
686 | cid = MyMoneyFile::instance()->currency((*it).currencyId()).id(); | 686 | cid = MyMoneyFile::instance()->currency((*it).currencyId()).id(); | ||
687 | } catch (const MyMoneyException& e) { | 687 | } catch (const MyMoneyException &e) { | ||
688 | qDebug() << QLatin1String("Account") << (*it).id() << (*it).name() << e.what(); | 688 | qDebug() << QLatin1String("Account") << (*it).id() << (*it).name() << e.what(); | ||
689 | } | 689 | } | ||
690 | 690 | | |||
Context not available. | |||||
766 | haveAt = false; | 766 | haveAt = false; | ||
767 | isEncrypted = true; | 767 | isEncrypted = true; | ||
768 | } else { | 768 | } else { | ||
769 | throw MYMONEYEXCEPTION(QString::fromLatin1("%1").arg(i18n("GPG is not available for decryption of file <b>%1</b>", fileName))); | 769 | throw MYMONEYEXCEPTION(QString::fromLatin1("GPG is not available for decryption of file <b>%1</b>").arg(fileName)); | ||
770 | } | 770 | } | ||
771 | } else { | 771 | } else { | ||
772 | // we can't use file directly, as we delete qfile later on | 772 | // we can't use file directly, as we delete qfile later on | ||
Context not available. | |||||
808 | if ((magic0 == MAGIC_0_50 && magic1 == MAGIC_0_51) || | 808 | if ((magic0 == MAGIC_0_50 && magic1 == MAGIC_0_51) || | ||
809 | magic0 < 30) { | 809 | magic0 < 30) { | ||
810 | // we do not support this file format anymore | 810 | // we do not support this file format anymore | ||
811 | throw MYMONEYEXCEPTION(QString::fromLatin1("<qt>%1</qt>").arg(i18n("File <b>%1</b> contains the old binary format used by KMyMoney. Please use an older version of KMyMoney (0.8.x) that still supports this format to convert it to the new XML based format.", fileName))); | 811 | throw MYMONEYEXCEPTION(QString::fromLatin1("<qt>File <b>%1</b> contains the old binary format used by KMyMoney. Please use an older version of KMyMoney (0.8.x) that still supports this format to convert it to the new XML based format.</qt>").arg(fileName)); | ||
812 | } | 812 | } | ||
813 | 813 | | |||
814 | // Scan the first 70 bytes to see if we find something | 814 | // Scan the first 70 bytes to see if we find something | ||
Context not available. | |||||
973 | auto rc = true; | 973 | auto rc = true; | ||
974 | try { | 974 | try { | ||
975 | if (! url.isValid()) { | 975 | if (! url.isValid()) { | ||
976 | throw MYMONEYEXCEPTION(i18n("Malformed URL '%1'", url.url())); | 976 | throw MYMONEYEXCEPTION(QString::fromLatin1("Malformed URL '%1'").arg(url.url())); | ||
977 | } | 977 | } | ||
978 | 978 | | |||
979 | if (url.scheme() == QLatin1String("sql")) { | 979 | if (url.scheme() == QLatin1String("sql")) { | ||
Context not available. | |||||
988 | } | 988 | } | ||
989 | 989 | | |||
990 | if(!pluginFound) | 990 | if(!pluginFound) | ||
991 | throw MYMONEYEXCEPTION(i18n("Couldn't find suitable plugin to save your storage.")); | 991 | throw MYMONEYEXCEPTION(QString::fromLatin1("Couldn't find suitable plugin to save your storage.")); | ||
992 | 992 | | |||
993 | } else if (url.isLocalFile()) { | 993 | } else if (url.isLocalFile()) { | ||
994 | filename = url.toLocalFile(); | 994 | filename = url.toLocalFile(); | ||
Context not available. | |||||
999 | } | 999 | } | ||
1000 | saveToLocalFile(filename, storageWriter.get(), plaintext, keyList); | 1000 | saveToLocalFile(filename, storageWriter.get(), plaintext, keyList); | ||
1001 | } catch (const MyMoneyException &) { | 1001 | } catch (const MyMoneyException &) { | ||
1002 | throw MYMONEYEXCEPTION(i18n("Unable to write changes to '%1'", filename)); | 1002 | throw MYMONEYEXCEPTION(QString::fromLatin1("Unable to write changes to '%1'").arg(filename)); | ||
1003 | } | 1003 | } | ||
1004 | } else { | 1004 | } else { | ||
1005 | 1005 | | |||
Context not available. | |||||
1013 | file.open(QIODevice::ReadOnly); | 1013 | file.open(QIODevice::ReadOnly); | ||
1014 | KIO::StoredTransferJob *putjob = KIO::storedPut(file.readAll(), url, permission, KIO::JobFlag::Overwrite); | 1014 | KIO::StoredTransferJob *putjob = KIO::storedPut(file.readAll(), url, permission, KIO::JobFlag::Overwrite); | ||
1015 | if (!putjob->exec()) { | 1015 | if (!putjob->exec()) { | ||
1016 | throw MYMONEYEXCEPTION(i18n("Unable to upload to '%1'.<br />%2", url.toDisplayString(), putjob->errorString())); | 1016 | throw MYMONEYEXCEPTION(QString::fromLatin1("Unable to upload to '%1'.<br />%2").arg(url.toDisplayString(), putjob->errorString())); | ||
1017 | } | 1017 | } | ||
1018 | file.close(); | 1018 | file.close(); | ||
1019 | } | 1019 | } | ||
Context not available. | |||||
1130 | ft.commit(); | 1130 | ft.commit(); | ||
1131 | 1131 | | |||
1132 | if (!device || !device->open(QIODevice::WriteOnly)) { | 1132 | if (!device || !device->open(QIODevice::WriteOnly)) { | ||
1133 | throw MYMONEYEXCEPTION(i18n("Unable to open file '%1' for writing.", localFile)); | 1133 | throw MYMONEYEXCEPTION(QString::fromLatin1("Unable to open file '%1' for writing.").arg(localFile)); | ||
1134 | } | 1134 | } | ||
1135 | 1135 | | |||
1136 | pWriter->setProgressCallback(&KMyMoneyApp::progressCallback); | 1136 | pWriter->setProgressCallback(&KMyMoneyApp::progressCallback); | ||
Context not available. | |||||
1140 | // Check for errors if possible, only possible for KGPGFile | 1140 | // Check for errors if possible, only possible for KGPGFile | ||
1141 | QFileDevice *fileDevice = qobject_cast<QFileDevice*>(device.get()); | 1141 | QFileDevice *fileDevice = qobject_cast<QFileDevice*>(device.get()); | ||
1142 | if (fileDevice && fileDevice->error() != QFileDevice::NoError) { | 1142 | if (fileDevice && fileDevice->error() != QFileDevice::NoError) { | ||
1143 | throw MYMONEYEXCEPTION(i18n("Failure while writing to '%1'", localFile)); | 1143 | throw MYMONEYEXCEPTION(QString::fromLatin1("Failure while writing to '%1'").arg(localFile)); | ||
1144 | } | 1144 | } | ||
1145 | 1145 | | |||
1146 | if (writeFile != localFile) { | 1146 | if (writeFile != localFile) { | ||
Context not available. | |||||
1148 | // If a temporary file was created, it is made in a way that the name is definitely different. So no | 1148 | // If a temporary file was created, it is made in a way that the name is definitely different. So no | ||
1149 | // symlinks etc. have to be evaluated. | 1149 | // symlinks etc. have to be evaluated. | ||
1150 | if (!QFile::remove(localFile) || !QFile::rename(writeFile, localFile)) | 1150 | if (!QFile::remove(localFile) || !QFile::rename(writeFile, localFile)) | ||
1151 | throw MYMONEYEXCEPTION(i18n("Failure while writing to '%1'", localFile)); | 1151 | throw MYMONEYEXCEPTION(QString::fromLatin1("Failure while writing to '%1'").arg(localFile)); | ||
1152 | } | 1152 | } | ||
1153 | QFile::setPermissions(localFile, m_fmode); | 1153 | QFile::setPermissions(localFile, m_fmode); | ||
1154 | pWriter->setProgressCallback(0); | 1154 | pWriter->setProgressCallback(0); | ||
Context not available. | |||||
1412 | , acc.name()), | 1412 | , acc.name()), | ||
1413 | i18n("Account problem")); | 1413 | i18n("Account problem")); | ||
1414 | 1414 | | |||
1415 | throw MYMONEYEXCEPTION("Fix LoanAccount0 not supported anymore"); | 1415 | throw MYMONEYEXCEPTION_CSTRING("Fix LoanAccount0 not supported anymore"); | ||
1416 | } | 1416 | } | ||
1417 | } | 1417 | } | ||
1418 | 1418 | | |||
Context not available. | |||||
2995 | } | 2995 | } | ||
2996 | ft.commit(); | 2996 | ft.commit(); | ||
2997 | } catch (const MyMoneyException &e) { | 2997 | } catch (const MyMoneyException &e) { | ||
2998 | KMessageBox::detailedSorry(0, i18n("Error"), i18n("Unable to import template(s): %1, thrown in %2:%3", e.what(), e.file(), e.line())); | 2998 | KMessageBox::detailedSorry(this, i18n("Unable to import template(s)"), e.what()); | ||
2999 | } | 2999 | } | ||
3000 | } | 3000 | } | ||
3001 | delete dlg; | 3001 | delete dlg; | ||
Context not available. | |||||
3438 | // We assume at least 2 splits in the transaction | 3438 | // We assume at least 2 splits in the transaction | ||
3439 | MyMoneyTransaction t = newSchedule.transaction(); | 3439 | MyMoneyTransaction t = newSchedule.transaction(); | ||
3440 | if (t.splitCount() < 2) { | 3440 | if (t.splitCount() < 2) { | ||
3441 | throw MYMONEYEXCEPTION("Transaction for schedule has less than 2 splits!"); | 3441 | throw MYMONEYEXCEPTION_CSTRING("Transaction for schedule has less than 2 splits!"); | ||
3442 | } | 3442 | } | ||
3443 | 3443 | | |||
3444 | MyMoneyFileTransaction ft; | 3444 | MyMoneyFileTransaction ft; | ||
Context not available. |