MailTransport

xoauthpasswordrequester.cpp
1/*
2 SPDX-FileCopyrightText: 2024 g10 Code GmbH
3 SPDX-FileContributor: Daniel Vrátil <dvratil@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#include "xoauthpasswordrequester.h"
9#include "gmailpasswordrequester.h"
10#include "outlookpasswordrequester.h"
11#include "transport.h"
12#include "transportbase.h"
13
14using namespace MailTransport;
15
16namespace
17{
18
19bool isGmail(const QString &server)
20{
21 return server.endsWith(u".gmail.com") || server.endsWith(u".googlemail.com");
22}
23
24bool isOutlook(const QString &server)
25{
26 return server.endsWith(u".outlook.com") || server.endsWith(u".office365.com") || server.endsWith(u".hotmail.com");
27}
28
29} // namespace
30
31XOAuthPasswordRequester::XOAuthPasswordRequester(Transport *transport, QObject *parent)
32 : QObject(parent)
33 , mTransport(transport)
34{
35}
36
37XOAuthPasswordRequester::~XOAuthPasswordRequester() = default;
38
39Transport *XOAuthPasswordRequester::transport() const
40{
41 return mTransport;
42}
43
44namespace MailTransport
45{
46
47XOAuthPasswordRequester *createXOAuthPasswordRequester(Transport *transport, QObject *parent)
48{
49 if (transport->authenticationType() == Transport::EnumAuthenticationType::XOAUTH2) {
50 if (isGmail(transport->host())) {
51 return new GmailPasswordRequester(transport, parent);
52 }
53 if (isOutlook(transport->host())) {
54 return new OutlookPasswordRequester(transport, parent);
55 }
56 }
57
58 return nullptr;
59}
60
61}
62
63#include "moc_xoauthpasswordrequester.cpp"
Represents the settings of a specific mail transport.
Definition transport.h:33
bool endsWith(QChar c, Qt::CaseSensitivity cs) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:07:33 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.