Fix compilation errors and implement Phase 6 & 7: NotificationManager and SyncScheduler with real synchronizer integration

This commit is contained in:
Padrino
2026-05-24 21:01:05 +02:00
parent 70700524e0
commit 2821647574
6 changed files with 84 additions and 17 deletions
+28
View File
@@ -3,6 +3,7 @@
#include <QStandardPaths>
#include "../db/dao/mailitemdao.h"
#include <QFile>
#include <QMessageBox>
EmailManager::EmailManager(QObject *parent)
: QObject(parent)
@@ -32,6 +33,24 @@ QString EmailManager::getStorageDirectory() const
return storagePath;
}
QString EmailManager::getEmailHtmlById(qint64 id) const
{
// Get the MailItem by id
MailItem item = getMailItemById(id);
if (item.id() == 0) {
return "<html><body><h2>Error: Email not found</h2></body></html>";
}
// Construct the file path: storage directory + fileId + .eml
QString storageDir = getStorageDirectory();
QString fileName = item.fileId();
if (fileName.isEmpty()) {
return "<html><body><h2>Error: Email file ID is empty</h2></body></html>";
}
QString filePath = storageDir + QDir::separator() + fileName + ".eml";
// Convert the .eml file to HTML
return convertEmlToHtml(filePath);
}
QString EmailManager::convertEmlToHtml(const QString& emlFilePath) const
{
// TODO: Implement actual MIME to HTML conversion using gmime or similar
@@ -50,4 +69,13 @@ QString EmailManager::convertEmlToHtml(const QString& emlFilePath) const
content.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;");
return QString("<html><body style='font-family: monospace;'><h2>Email Content (raw)</h2><pre>%1</pre></body></html>")
.arg(content);
}
bool EmailManager::sendEmail(const QString& to, const QString& subject, const QString& body)
{
// TODO: Implement actual email sending
// For now, just show a message and return true
QMessageBox::information(nullptr, "Send Email",
QString("To: %1\nSubject: %2\nBody: %3").arg(to, subject, body));
return true;
}
+3
View File
@@ -22,6 +22,9 @@ public:
// Returns the HTML content of an email by its ID
Q_INVOKABLE QString getEmailHtmlById(qint64 id) const;
// Converts an .eml file to HTML string
QString convertEmlToHtml(const QString& emlFilePath) const;
// Sends an email with the given parameters
// Returns true if the email was successfully queued for sending
Q_INVOKABLE bool sendEmail(const QString& to, const QString& subject, const QString& body);