32 lines
909 B
C++
32 lines
909 B
C++
#include "EmailManager.h"
|
|||
|
|
#include <QDir>
|
||
|
|
#include <QStandardPaths>
|
||
|
|
#include "../db/dao/mailitemdao.h"
|
||
|
|
|
||
|
|
EmailManager::EmailManager(QObject *parent)
|
||
|
|
: QObject(parent)
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
MailItem EmailManager::getMailItemById(qint64 id) const
|
||
|
|
{
|
||
|
|
// Use the DAO to fetch the MailItem by id
|
||
|
|
auto optItem = MailItemDao::instance().findById(id);
|
||
|
|
if (optItem.has_value()) {
|
||
|
|
return optItem.value();
|
||
|
|
}
|
||
|
|
// Return an empty MailItem if not found
|
||
|
|
return MailItem();
|
||
|
|
}
|
||
|
|
|
||
|
|
QString EmailManager::getStorageDirectory() const
|
||
|
|
{
|
||
|
|
// Define where .eml files are stored (e.g., in the application data directory)
|
||
|
|
QString storagePath = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
||
|
|
QDir dir(storagePath);
|
||
|
|
if (!dir.exists()) {
|
||
|
|
dir.mkpath("."); // create if it doesn't exist
|
||
|
|
}
|
||
|
|
// Assuming .eml files are stored directly in this directory
|
||
|
|
return storagePath;
|
||
|
|
}
|