Fix build: synchronize Request API, fix GmailSynchronizer, and migrate UI to Qt6 Widgets
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
// accountservice.h
|
||||
#ifndef ACCOUNTSERVICE_H
|
||||
#define ACCOUNTSERVICE_H
|
||||
|
||||
#include "authenticator.h"
|
||||
#include "eventbus.h"
|
||||
#include <QString>
|
||||
|
||||
class AccountService {
|
||||
public:
|
||||
AccountService(EventBus* bus);
|
||||
|
||||
// Interface for managing user accounts
|
||||
bool registerAccount(const QString& type, const QString& identifier, const QString& credentials);
|
||||
bool syncAccount(const QString& accountId, const QString& type);
|
||||
|
||||
private:
|
||||
EventBus* m_eventBus;
|
||||
// Placeholder for DAO layer (Data Access Objects)
|
||||
// In a full implementation, these would handle DB/file operations.
|
||||
bool saveAccountToDB(const QString& accountId, const QString& type, const QString& details);
|
||||
};
|
||||
|
||||
#endif // ACCOUNTSERVICE_H
|
||||
@@ -0,0 +1,40 @@
|
||||
// changetype.h
|
||||
#ifndef CHANGETYPE_H
|
||||
#define CHANGETYPE_H
|
||||
|
||||
#include "eventbus.h"
|
||||
#include <QString>
|
||||
#include <QDateTime>
|
||||
|
||||
enum ChangeType {
|
||||
ADD,
|
||||
DELETE,
|
||||
UPDATE
|
||||
};
|
||||
|
||||
struct MailChange {
|
||||
QString mailItemId;
|
||||
QString type; // ADD, DELETE, UPDATE
|
||||
QString subject;
|
||||
QString body;
|
||||
QDateTime timestamp;
|
||||
QString changeSource; // e.g., "IMAP_SYNC", "SMTP_SYNC"
|
||||
};
|
||||
|
||||
class ChangeProcessor : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ChangeProcessor(EventBus* bus, QObject *parent = nullptr);
|
||||
|
||||
void processChange(const MailChange& change);
|
||||
|
||||
signals:
|
||||
void mailChangeDetected(const MailChange& change);
|
||||
|
||||
private:
|
||||
EventBus* m_eventBus;
|
||||
// In a real system, this would interface with the database/DAO layer.
|
||||
void applyChangeToModel(const MailChange& change);
|
||||
};
|
||||
|
||||
#endif // CHANGETYPE_H
|
||||
@@ -0,0 +1,27 @@
|
||||
// concreterequests.h
|
||||
#ifndef CONCRETEREQUESTS_H
|
||||
#define CONCRETEREQUESTS_H
|
||||
|
||||
#include "request.h"
|
||||
#include <QString>
|
||||
|
||||
class Concreterequests {
|
||||
public:
|
||||
// Interface for defining specific request types (e.g., IMAP GET, SMTP AUTH)
|
||||
virtual Request* createRequest(const QString& type, const QString& target) = 0;
|
||||
virtual ~Concreterequests() = default;
|
||||
};
|
||||
|
||||
class ImapRequest : public Concreterequests {
|
||||
public:
|
||||
ImapRequest(Request* req);
|
||||
Request* createRequest(const QString& type, const QString& target) override;
|
||||
};
|
||||
|
||||
class SmtpRequest : public Concreterequests {
|
||||
public:
|
||||
SmtpRequest(Request* req);
|
||||
Request* createRequest(const QString& type, const QString& target) override;
|
||||
};
|
||||
|
||||
#endif // CONCRETEREQUESTS_H
|
||||
@@ -0,0 +1,40 @@
|
||||
// /mnt/c/Users/javie/wino-mail-dtkqt/include/emaillistmodel.h
|
||||
#ifndef EMAILLISTMODEL_H
|
||||
#define EMAILLISTMODEL_H
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QStringList>
|
||||
#include <QModelIndex>
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
struct EmailItem {
|
||||
int id;
|
||||
QString subject;
|
||||
QString sender;
|
||||
};
|
||||
|
||||
class EmailListModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EmailListModel(QObject *parent = nullptr);
|
||||
|
||||
// QAbstractItemModel interface
|
||||
QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const override;
|
||||
QModelIndex parent(int row, const QModelIndex &parent = QModelIndex()) const override;
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
// Public interface for setting data
|
||||
void setEmails(const QList<EmailItem>& emails);
|
||||
|
||||
// Helper to get data (for demonstration)
|
||||
QList<EmailItem> getEmails() const { return m_emails; }
|
||||
|
||||
private:
|
||||
QList<EmailItem> m_emails;
|
||||
};
|
||||
|
||||
#endif // EMAILLISTMODEL_H
|
||||
@@ -0,0 +1,34 @@
|
||||
// /mnt/c/Users/javie/wino-mail-dtkqt/include/folderlistmodel.h
|
||||
#ifndef FOLDERLISTMODEL_H
|
||||
#define FOLDERLISTMODEL_H
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QStringList>
|
||||
#include <QModelIndex>
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
class FolderListModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FolderListModel(QObject *parent = nullptr);
|
||||
|
||||
// QAbstractItemModel interface
|
||||
QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const override;
|
||||
QModelIndex parent(int row, const QModelIndex &parent = QModelIndex()) const override;
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
// Public interface for setting data
|
||||
void setFolders(const QStringList& folders);
|
||||
|
||||
// Helper to get data (for demonstration)
|
||||
QStringList getFolders() const { return m_folders; }
|
||||
|
||||
private:
|
||||
QStringList m_folders;
|
||||
};
|
||||
|
||||
#endif // FOLDERLISTMODEL_H
|
||||
@@ -0,0 +1,20 @@
|
||||
// gmailauthenticator.h
|
||||
#ifndef GMAILAUTHENTICATOR_H
|
||||
#define GMAILAUTHENTICATOR_H
|
||||
|
||||
#include "authenticator.h"
|
||||
#include "request.h"
|
||||
#include <QString>
|
||||
|
||||
class GmailAuthenticator : public IAuthenticator {
|
||||
public:
|
||||
GmailAuthenticator(EventBus* bus);
|
||||
bool authenticate(const QString& username, const QString& password, const QString& scope = "email");
|
||||
|
||||
private:
|
||||
EventBus* m_eventBus;
|
||||
// Placeholder for actual OAuth flow management
|
||||
bool performOAuth2Flow(const QString& authCode);
|
||||
};
|
||||
|
||||
#endif // GMAILAUTHENTICATOR_H
|
||||
@@ -0,0 +1,13 @@
|
||||
// imaprequest.h
|
||||
#ifndef IMAPREQUEST_H
|
||||
#define IMAPREQUEST_H
|
||||
|
||||
#include "concreterequests.h"
|
||||
|
||||
class ImapRequest : public Concreterequests {
|
||||
public:
|
||||
ImapRequest(Request* req);
|
||||
Request* createRequest(const QString& type, const QString& target) override;
|
||||
};
|
||||
|
||||
#endif // IMAPREQUEST_H
|
||||
@@ -0,0 +1,20 @@
|
||||
// outlookauthenticator.h
|
||||
#ifndef OUTLOOKAUTHENTICATOR_H
|
||||
#define OUTLOOKAUTHENTICATOR_H
|
||||
|
||||
#include "authenticator.h"
|
||||
#include "request.h"
|
||||
#include <QString>
|
||||
|
||||
class OutlookAuthenticator : public IAuthenticator {
|
||||
public:
|
||||
OutlookAuthenticator(EventBus* bus);
|
||||
bool authenticate(const QString& username, const QString& password, const QString& scope = "email");
|
||||
|
||||
private:
|
||||
EventBus* m_eventBus;
|
||||
// Placeholder for actual OAuth flow management
|
||||
bool performOAuth2Flow(const QString& authCode);
|
||||
};
|
||||
|
||||
#endif // OUTLOOKAUTHENTICATOR_H
|
||||
@@ -0,0 +1,62 @@
|
||||
#ifndef REQUEST_H
|
||||
#define REQUEST_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QUrl>
|
||||
#include <QMap>
|
||||
#include <QByteArray>
|
||||
#include <QNetworkRequest>
|
||||
|
||||
enum class RequestType {
|
||||
GmailApi,
|
||||
GraphApi,
|
||||
Imap,
|
||||
Custom
|
||||
};
|
||||
|
||||
class Request : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum class Method {
|
||||
GET,
|
||||
POST,
|
||||
PUT,
|
||||
DELETE,
|
||||
PATCH
|
||||
};
|
||||
|
||||
explicit Request(QObject *parent = nullptr);
|
||||
Request(Method method, const QUrl &url, const QByteArray &body = QByteArray());
|
||||
~Request() override = default;
|
||||
|
||||
void setMethod(Method method);
|
||||
Method method() const;
|
||||
|
||||
void setUrl(const QUrl &url);
|
||||
QUrl url() const;
|
||||
|
||||
void setHeader(const QString &key, const QString &value);
|
||||
QMap<QString, QString> headers() const;
|
||||
|
||||
void setBody(const QByteArray &body);
|
||||
QByteArray body() const;
|
||||
|
||||
void setType(RequestType type);
|
||||
RequestType type() const;
|
||||
|
||||
void setAccountId(const QString &accountId);
|
||||
QString accountId() const;
|
||||
|
||||
QNetworkRequest toNetworkRequest() const;
|
||||
|
||||
private:
|
||||
Method m_method = Method::GET;
|
||||
QUrl m_url;
|
||||
QMap<QString, QString> m_headers;
|
||||
QByteArray m_body;
|
||||
RequestType m_requestType = RequestType::Custom;
|
||||
QString m_accountId;
|
||||
};
|
||||
|
||||
#endif // REQUEST_H
|
||||
@@ -0,0 +1,13 @@
|
||||
// smtprequest.h
|
||||
#ifndef SMTPREQUEST_H
|
||||
#define SMTPREQUEST_H
|
||||
|
||||
#include "concreterequests.h"
|
||||
|
||||
class SmtpRequest : public Concreterequests {
|
||||
public:
|
||||
SmtpRequest(Request* req);
|
||||
Request* createRequest(const QString& type, const QString& target) override;
|
||||
};
|
||||
|
||||
#endif // SMTPREQUEST_H
|
||||
@@ -0,0 +1,36 @@
|
||||
// /mnt/c/Users/javie/wino-mail-dtkqt/include/synchronizerprovider.h
|
||||
#ifndef SYNCHRONIZERPROVIDER_H
|
||||
#define SYNCHRONIZERPROVIDER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
|
||||
// Forward declarations for models (assuming they are defined elsewhere)
|
||||
class FolderListModel;
|
||||
class EmailListModel;
|
||||
|
||||
class SynchronizerProvider : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SynchronizerProvider(QObject *parent = nullptr);
|
||||
|
||||
// Primary method to fetch all necessary data
|
||||
void syncAllData();
|
||||
|
||||
signals:
|
||||
// Signals emitted upon successful synchronization
|
||||
void dataSynchronized(const QList<QString>& folders, const QList<EmailItem>& emails);
|
||||
|
||||
public slots:
|
||||
// This slot will be called by the main window to initiate the load
|
||||
void requestSync();
|
||||
|
||||
private:
|
||||
// Simulated backend interaction methods
|
||||
QList<QString> fetchFoldersFromBackend() const;
|
||||
QList<EmailItem> fetchEmailsFromBackend(const QString& folder) const;
|
||||
};
|
||||
|
||||
#endif // SYNCHRONIZERPROVIDER_H
|
||||
Reference in New Issue
Block a user