Implement Fase 5 lectura de correos y Fase 6 notificaciones: ReaderPage muestra correos reales vía EmailManager, añadido NotificationManager con QSystemTrayIcon y suscripción al Event Bus; actualizados EmailManager y DbChangeProcessor; creado estructura de notificaciones básica
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
#include "EmailManager.h"
|
||||
#include "emailmanager.h"
|
||||
#include <QDir>
|
||||
#include <QStandardPaths>
|
||||
#include "../db/dao/mailitemdao.h"
|
||||
#include <QFile>
|
||||
|
||||
EmailManager::EmailManager(QObject *parent)
|
||||
: QObject(parent)
|
||||
@@ -11,7 +12,7 @@ EmailManager::EmailManager(QObject *parent)
|
||||
MailItem EmailManager::getMailItemById(qint64 id) const
|
||||
{
|
||||
// Use the DAO to fetch the MailItem by id
|
||||
auto optItem = MailItemDao::instance().findById(id);
|
||||
auto optItem = MailItemDao::findById(id);
|
||||
if (optItem.has_value()) {
|
||||
return optItem.value();
|
||||
}
|
||||
@@ -29,4 +30,24 @@ QString EmailManager::getStorageDirectory() const
|
||||
}
|
||||
// Assuming .eml files are stored directly in this directory
|
||||
return storagePath;
|
||||
}
|
||||
|
||||
QString EmailManager::convertEmlToHtml(const QString& emlFilePath) const
|
||||
{
|
||||
// TODO: Implement actual MIME to HTML conversion using gmime or similar
|
||||
// For now, return a placeholder indicating the feature is not yet implemented
|
||||
QFile file(emlFilePath);
|
||||
if (!file.exists()) {
|
||||
return "<html><body><h2>Error: Email file not found</h2></body></html>";
|
||||
}
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
return "<html><body><h2>Error: Cannot open email file</h2></body></html>";
|
||||
}
|
||||
QByteArray data = file.readAll();
|
||||
file.close();
|
||||
// Very basic conversion: just show raw content in a pre tag for now
|
||||
QString content = QString::fromUtf8(data);
|
||||
content.replace("&", "&").replace("<", "<").replace(">", ">");
|
||||
return QString("<html><body style='font-family: monospace;'><h2>Email Content (raw)</h2><pre>%1</pre></body></html>")
|
||||
.arg(content);
|
||||
}
|
||||
@@ -19,8 +19,16 @@ public:
|
||||
// Returns the storage directory for .eml files
|
||||
Q_INVOKABLE QString getStorageDirectory() const;
|
||||
|
||||
// Returns the HTML content of an email by its ID
|
||||
Q_INVOKABLE QString getEmailHtmlById(qint64 id) 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);
|
||||
|
||||
private:
|
||||
// We'll use the DAO directly
|
||||
// TODO: We might need access to synchronizer or request processor in the future
|
||||
};
|
||||
|
||||
#endif // EMAILMANAGER_H
|
||||
@@ -0,0 +1,7 @@
|
||||
#include "eventbus.h"
|
||||
|
||||
EventBus& EventBus::instance()
|
||||
{
|
||||
static EventBus instance;
|
||||
return instance;
|
||||
}
|
||||
Reference in New Issue
Block a user