Fix build: synchronize Request API, fix GmailSynchronizer, and migrate UI to Qt6 Widgets
This commit is contained in:
@@ -358,11 +358,32 @@ void GmailSynchronizer::setHistoryId(const QString& folderId, qint64 historyId)
|
||||
|
||||
MailItem GmailSynchronizer::parseMailItemFromGmail(const QJsonObject& mailJson) const
|
||||
{
|
||||
// Esta función convertiría un objeto JSON de Gmail API
|
||||
// a nuestro objeto MailItem
|
||||
MailItem item;
|
||||
|
||||
// Por ahora, devolvemos un objeto vacío como stub
|
||||
return MailItem();
|
||||
// ID de Gmail es la clave primaria
|
||||
item.setId(mailJson["id"].toString().toLongLong());
|
||||
|
||||
// El snippet sirve como cuerpo preliminar
|
||||
item.setBodyHtml(mailJson["snippet"].toString());
|
||||
|
||||
// Parsear headers
|
||||
QJsonArray headers = mailJson["payload"].toObject()["headers"].toArray();
|
||||
|
||||
QString from = extractHeaderValue(headers, "From").value(0);
|
||||
QString subject = extractHeaderValue(headers, "Subject").value(0);
|
||||
QString dateStr = extractHeaderValue(headers, "Date").value(0);
|
||||
|
||||
item.setSender(from.isEmpty() ? "Unknown" : from);
|
||||
item.setSubject(subject.isEmpty() ? "(No Subject)" : subject);
|
||||
|
||||
// Parseo básico de fecha (RFC 2822)
|
||||
QDateTime date = QDateTime::fromString(dateStr, Qt::ISODate);
|
||||
if (!date.isValid()) {
|
||||
date = QDateTime::currentDateTime();
|
||||
}
|
||||
item.setDate(date);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
Folder GmailSynchronizer::parseFolderFromGmail(const QJsonObject& labelJson) const
|
||||
@@ -386,4 +407,4 @@ QStringList GmailSynchronizer::extractHeaderValue(const QJsonArray& headers, con
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user