Add Account and Folder models, update CMakeLists.txt with source files, add MailItem implementation
This commit is contained in:
+5
-2
@@ -17,9 +17,12 @@ include_directories(${PROJECT_SOURCE_DIR}/src)
|
|||||||
|
|
||||||
# Source files - we will add them later
|
# Source files - we will add them later
|
||||||
set(SRC_FILES
|
set(SRC_FILES
|
||||||
|
src/main.cpp
|
||||||
src/core/translator.cpp
|
src/core/translator.cpp
|
||||||
src/services/synchronizer.cpp
|
src/core/mailitem.cpp
|
||||||
# placeholder
|
src/core/models/account.cpp
|
||||||
|
src/core/models/folder.cpp
|
||||||
|
# src/services/synchronizer.cpp # placeholder
|
||||||
)
|
)
|
||||||
|
|
||||||
# Executable
|
# Executable
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
#include "mailitem.h"
|
||||||
|
|
||||||
|
MailItem::MailItem(qint64 id, const QString& subject, const QString& sender,
|
||||||
|
const QString& recipient, const QDateTime& date,
|
||||||
|
bool read, bool flagged,
|
||||||
|
const QVector<QString>& attachments)
|
||||||
|
: m_id(id)
|
||||||
|
, m_subject(subject)
|
||||||
|
, m_sender(sender)
|
||||||
|
, m_recipient(recipient)
|
||||||
|
, m_date(date)
|
||||||
|
, m_read(read)
|
||||||
|
, m_flagged(flagged)
|
||||||
|
, m_attachments(attachments)
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#include "account.h"
|
||||||
|
|
||||||
|
Account::Account(int id, const QString& email, const QString& displayName,
|
||||||
|
AccountType type, const QString& accessToken,
|
||||||
|
const QString& refreshToken, const QDateTime& tokenExpires)
|
||||||
|
: m_id(id)
|
||||||
|
, m_email(email)
|
||||||
|
, m_displayName(displayName)
|
||||||
|
, m_type(type)
|
||||||
|
, m_accessToken(accessToken)
|
||||||
|
, m_refreshToken(refreshToken)
|
||||||
|
, m_tokenExpires(tokenExpires)
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QDateTime>
|
||||||
|
|
||||||
|
enum class AccountType {
|
||||||
|
Outlook,
|
||||||
|
Gmail,
|
||||||
|
IMAP
|
||||||
|
};
|
||||||
|
|
||||||
|
class Account
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Account() = default;
|
||||||
|
Account(int id, const QString& email, const QString& displayName,
|
||||||
|
AccountType type, const QString& accessToken = QString(),
|
||||||
|
const QString& refreshToken = QString(),
|
||||||
|
const QDateTime& tokenExpires = QDateTime());
|
||||||
|
|
||||||
|
int id() const { return m_id; }
|
||||||
|
void setId(int id) { m_id = id; }
|
||||||
|
|
||||||
|
QString email() const { return m_email; }
|
||||||
|
void setEmail(const QString& email) { m_email = email; }
|
||||||
|
|
||||||
|
QString displayName() const { return m_displayName; }
|
||||||
|
void setDisplayName(const QString& displayName) { m_displayName = displayName; }
|
||||||
|
|
||||||
|
AccountType type() const { return m_type; }
|
||||||
|
void setType(AccountType type) { m_type = type; }
|
||||||
|
|
||||||
|
QString accessToken() const { return m_accessToken; }
|
||||||
|
void setAccessToken(const QString& token) { m_accessToken = token; }
|
||||||
|
|
||||||
|
QString refreshToken() const { return m_refreshToken; }
|
||||||
|
void setRefreshToken(const QString& token) { m_refreshToken = token; }
|
||||||
|
|
||||||
|
QDateTime tokenExpires() const { return m_tokenExpires; }
|
||||||
|
void setTokenExpires(const QDateTime& expires) { m_tokenExpires = expires; }
|
||||||
|
|
||||||
|
bool isTokenValid() const {
|
||||||
|
return !m_accessToken.isEmpty() && m_tokenExpires.isValid() &&
|
||||||
|
m_tokenExpires > QDateTime::currentDateTimeUtc();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_id{0};
|
||||||
|
QString m_email;
|
||||||
|
QString m_displayName;
|
||||||
|
AccountType m_type{AccountType::IMAP};
|
||||||
|
QString m_accessToken;
|
||||||
|
QString m_refreshToken;
|
||||||
|
QDateTime m_tokenExpires;
|
||||||
|
};
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
#include "folder.h"
|
||||||
|
|
||||||
|
Folder::Folder(int id, int accountId, const QString& name, const QString& parentFolderId,
|
||||||
|
bool isInbox, bool isSent, bool isDrafts, bool isTrash,
|
||||||
|
int unreadCount, const QDateTime& lastSynced)
|
||||||
|
: m_id(id)
|
||||||
|
, m_accountId(accountId)
|
||||||
|
, m_name(name)
|
||||||
|
, m_parentFolderId(parentFolderId)
|
||||||
|
, m_isInbox(isInbox)
|
||||||
|
, m_isSent(isSent)
|
||||||
|
, m_isDrafts(isDrafts)
|
||||||
|
, m_isTrash(isTrash)
|
||||||
|
, m_unreadCount(unreadCount)
|
||||||
|
, m_lastSynced(lastSynced)
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QDateTime>
|
||||||
|
|
||||||
|
class Folder
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Folder() = default;
|
||||||
|
Folder(int id, int accountId, const QString& name, const QString& parentFolderId = QString(),
|
||||||
|
bool isInbox = false, bool isSent = false, bool isDrafts = false, bool isTrash = false,
|
||||||
|
int unreadCount = 0, const QDateTime& lastSynced = QDateTime());
|
||||||
|
|
||||||
|
int id() const { return m_id; }
|
||||||
|
void setId(int id) { m_id = id; }
|
||||||
|
|
||||||
|
int accountId() const { return m_accountId; }
|
||||||
|
void setAccountId(int accountId) { m_accountId = accountId; }
|
||||||
|
|
||||||
|
QString name() const { return m_name; }
|
||||||
|
void setName(const QString& name) { m_name = name; }
|
||||||
|
|
||||||
|
QString parentFolderId() const { return m_parentFolderId; }
|
||||||
|
void setParentFolderId(const QString& parentFolderId) { m_parentFolderId = parentFolderId; }
|
||||||
|
|
||||||
|
bool isInbox() const { return m_isInbox; }
|
||||||
|
void setInbox(bool inbox) { m_isInbox = inbox; }
|
||||||
|
|
||||||
|
bool isSent() const { return m_isSent; }
|
||||||
|
void setSent(bool sent) { m_isSent = sent; }
|
||||||
|
|
||||||
|
bool isDrafts() const { return m_isDrafts; }
|
||||||
|
void setDrafts(bool drafts) { m_isDrafts = drafts; }
|
||||||
|
|
||||||
|
bool isTrash() const { return m_isTrash; }
|
||||||
|
void setTrash(bool trash) { m_isTrash = trash; }
|
||||||
|
|
||||||
|
int unreadCount() const { return m_unreadCount; }
|
||||||
|
void setUnreadCount(int count) { m_unreadCount = count; }
|
||||||
|
|
||||||
|
QDateTime lastSynced() const { return m_lastSynced; }
|
||||||
|
void setLastSynced(const QDateTime& lastSynced) { m_lastSynced = lastSynced; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_id{0};
|
||||||
|
int m_accountId{0};
|
||||||
|
QString m_name;
|
||||||
|
QString m_parentFolderId;
|
||||||
|
bool m_isInbox{false};
|
||||||
|
bool m_isSent{false};
|
||||||
|
bool m_isDrafts{false};
|
||||||
|
bool m_isTrash{false};
|
||||||
|
int m_unreadCount{0};
|
||||||
|
QDateTime m_lastSynced;
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user