#include "accountsetupdialoglauncher.h" #include #include "services/accountservice.h" AccountSetupDialogLauncher::AccountSetupDialogLauncher(QObject *parent) : QObject(parent) { } void AccountSetupDialogLauncher::launchSetupDialog() { emit accountSetupStarted(); qDebug() << "[AccountSetupDialogLauncher] Dialog would launch here (Fase 3)"; } void AccountSetupDialogLauncher::setupAccountManually(const Account &account) { qDebug() << "[AccountSetupDialogLauncher] Setting up account:" << account.email(); // Save to database and retain the generated id for the synchronizer/event. const qint64 id = AccountDao::insert(account); if (id < 0) { qWarning() << "[AccountSetupDialogLauncher] Failed to save account to DB"; emit accountSetupFailed("Failed to save account"); return; } Account storedAccount = account; storedAccount.setId(static_cast(id)); // Initialize synchronizer initializeSynchronizer(storedAccount); // Publish event WinoMail::Events::AccountAddedEvent event; event.account = storedAccount; EVENT_BUS.publish(event); qDebug() << "[AccountSetupDialogLauncher] Account created successfully:" << account.email(); emit accountSetupCompleted(storedAccount); } void AccountSetupDialogLauncher::initializeSynchronizer(const Account &account) { QString accountId = QString::number(account.id()); // Determine provider type from Account's access token or type QString providerType; switch (account.type()) { case AccountType::Gmail: providerType = "gmail"; break; case AccountType::Outlook: providerType = "outlook"; break; case AccountType::IMAP: providerType = "imap"; break; case AccountType::POP3: providerType = "pop3"; break; default: providerType = "imap"; break; } Synchronizer *sync = SynchronizerProvider::instance().createSynchronizer(accountId, providerType); if (sync) { sync->initialize(account); qDebug() << "[AccountSetupDialogLauncher] Synchronizer initialized for account:" << accountId; } else { qWarning() << "[AccountSetupDialogLauncher] Could not create synchronizer for:" << providerType; } } #include "accountsetupdialoglauncher.moc"