diff --git a/CMakeLists.txt b/CMakeLists.txt index fe45f23..26ebac5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,9 +17,12 @@ include_directories(${PROJECT_SOURCE_DIR}/src) # Source files - we will add them later set(SRC_FILES + src/main.cpp src/core/translator.cpp - src/services/synchronizer.cpp - # placeholder + src/core/mailitem.cpp + src/core/models/account.cpp + src/core/models/folder.cpp + # src/services/synchronizer.cpp # placeholder ) # Executable diff --git a/src/core/mailitem.cpp b/src/core/mailitem.cpp new file mode 100644 index 0000000..08ac80a --- /dev/null +++ b/src/core/mailitem.cpp @@ -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& 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) +{ +} \ No newline at end of file diff --git a/src/core/models/account.cpp b/src/core/models/account.cpp new file mode 100644 index 0000000..5841fa0 --- /dev/null +++ b/src/core/models/account.cpp @@ -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) +{ +} \ No newline at end of file diff --git a/src/core/models/account.h b/src/core/models/account.h new file mode 100644 index 0000000..5ad6548 --- /dev/null +++ b/src/core/models/account.h @@ -0,0 +1,55 @@ +#pragma once + +#include +#include + +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; +}; \ No newline at end of file diff --git a/src/core/models/folder.cpp b/src/core/models/folder.cpp new file mode 100644 index 0000000..67ba392 --- /dev/null +++ b/src/core/models/folder.cpp @@ -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) +{ +} \ No newline at end of file diff --git a/src/core/models/folder.h b/src/core/models/folder.h new file mode 100644 index 0000000..9bf622d --- /dev/null +++ b/src/core/models/folder.h @@ -0,0 +1,55 @@ +#pragma once + +#include +#include + +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; +}; \ No newline at end of file