Commit 152c36e6 authored by Martin Straka's avatar Martin Straka

Added message box, minor code refactoring

parent c55bd35f
......@@ -260,7 +260,7 @@ void Files::sendMsgFilesWithEmail(const QString &userName, qint64 msgId,
QString body;
QString subject;
/* Fill email subject and body */
/* Fill email subject and email body */
MessageDb *msgDb = GlobInstcs::messageDbsPtr->accessMessageDb(
GlobInstcs::setPtr->dbsLocation, userName,
(*GlobInstcs::acntMapPtr)[userName].storeToDisk());
......@@ -277,7 +277,7 @@ void Files::sendMsgFilesWithEmail(const QString &userName, qint64 msgId,
/* Get attachment files from database if needed */
if (Files::SEND_EMAIL_ZFO_ATTACHMENT == attachType
|| Files::SEND_EMAIL_ATTACHMENT_ONLY == attachType ) {
|| Files::SEND_EMAIL_ATTACHMENT_ONLY == attachType ) {
FileDb *fDb = GlobInstcs::fileDbsPtr->accessFileDb(
GlobInstcs::setPtr->dbsLocation, userName,
(*GlobInstcs::acntMapPtr)[userName].storeToDisk());
......@@ -295,13 +295,16 @@ void Files::sendMsgFilesWithEmail(const QString &userName, qint64 msgId,
/* Get zfo file from database if needed */
if (Files::SEND_EMAIL_ZFO_ATTACHMENT == attachType
|| Files::SEND_EMAIL_ZFO_ONLY == attachType ) {
|| Files::SEND_EMAIL_ZFO_ONLY == attachType ) {
FileDb::FileData msgData;
msgData.content = GlobInstcs::zfoDbPtr->getZfoContentFromDb(msgId,
(*GlobInstcs::acntMapPtr)[userName].isTestAccount());
if (msgData.content.isEmpty()) {
/* TODO - show error dialogue */
qCritical() << "ERROR: ZFO message data missing!";
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("ZFO missing"),
tr("ZFO message is not present in local database."),
tr("Download complete message again to obtain it."));
Q_ASSERT(0);
return;
}
......@@ -309,13 +312,14 @@ void Files::sendMsgFilesWithEmail(const QString &userName, qint64 msgId,
filelist.append(msgData);
}
/* Create email content, email attachment and send email */
/* Create email content, email attachment path, email eml content */
removeDirFromDocLoc(DATOVKA_MAIL_DIR_NAME);
QString targetPath(appEmailDirPath(QString::number(msgId)));
QStringList fileListPath;
const QString boundary = generateBoundaryString();
QString emailMessage = createEmailMessage(body, subject, boundary);
QStringList filePathList;
/* Write attachment files to email directory */
foreach (const FileDb::FileData &file, filelist) {
QString fileName = file.filename;
if (fileName.isEmpty()) {
......@@ -324,14 +328,15 @@ void Files::sendMsgFilesWithEmail(const QString &userName, qint64 msgId,
}
fileName = writeFile(targetPath, fileName,
base64ToRaw(file.content.toUtf8()));
fileListPath.append(fileName);
filePathList.append(fileName);
addAttachmentToEmailMessage(emailMessage, file.filename,
file.content.toUtf8(), boundary);
}
finishEmailMessage(emailMessage, boundary);
sendEmail(emailMessage, fileListPath, subject, body, msgId);
/* Send email */
sendEmail(emailMessage, filePathList, subject, body, msgId);
}
void Files::deleteFileDb(const QString &userName)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment