mailnotification: Add Qt6 support
This commit is contained in:
parent
9e5b735e14
commit
202e726df4
@ -1,6 +1,6 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
*
|
*
|
||||||
* Copyright 2013 - 2020, nymea GmbH
|
* Copyright 2013 - 2025, nymea GmbH
|
||||||
* Contact: contact@nymea.io
|
* Contact: contact@nymea.io
|
||||||
*
|
*
|
||||||
* This file is part of nymea.
|
* This file is part of nymea.
|
||||||
@ -29,10 +29,10 @@
|
|||||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
|
|
||||||
#include "integrationpluginmailnotification.h"
|
#include "integrationpluginmailnotification.h"
|
||||||
|
|
||||||
#include "integrations/thing.h"
|
|
||||||
#include "plugininfo.h"
|
#include "plugininfo.h"
|
||||||
|
|
||||||
|
#include <integrations/thing.h>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
*
|
*
|
||||||
* Copyright 2013 - 2020, nymea GmbH
|
* Copyright 2013 - 2025, nymea GmbH
|
||||||
* Contact: contact@nymea.io
|
* Contact: contact@nymea.io
|
||||||
*
|
*
|
||||||
* This file is part of nymea.
|
* This file is part of nymea.
|
||||||
@ -31,7 +31,8 @@
|
|||||||
#ifndef INTEGRATIONPLUGINMAILNOTIFICATION_H
|
#ifndef INTEGRATIONPLUGINMAILNOTIFICATION_H
|
||||||
#define INTEGRATIONPLUGINMAILNOTIFICATION_H
|
#define INTEGRATIONPLUGINMAILNOTIFICATION_H
|
||||||
|
|
||||||
#include "integrations/integrationplugin.h"
|
#include <integrations/integrationplugin.h>
|
||||||
|
|
||||||
#include "smtpclient.h"
|
#include "smtpclient.h"
|
||||||
|
|
||||||
class IntegrationPluginMailNotification : public IntegrationPlugin
|
class IntegrationPluginMailNotification : public IntegrationPlugin
|
||||||
@ -52,7 +53,7 @@ public:
|
|||||||
void thingRemoved(Thing *thing) override;
|
void thingRemoved(Thing *thing) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QHash <SmtpClient*, Thing*> m_clients;
|
QHash <SmtpClient *, Thing *> m_clients;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
include(../plugins.pri)
|
include(../plugins.pri)
|
||||||
|
|
||||||
TARGET = $$qtLibraryTarget(nymea_integrationpluginmailnotification)
|
QT *= network
|
||||||
|
|
||||||
QT+= network
|
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
integrationpluginmailnotification.cpp \
|
integrationpluginmailnotification.cpp \
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
*
|
*
|
||||||
* Copyright 2013 - 2020, nymea GmbH
|
* Copyright 2013 - 2025, nymea GmbH
|
||||||
* Contact: contact@nymea.io
|
* Contact: contact@nymea.io
|
||||||
*
|
*
|
||||||
* This file is part of nymea.
|
* This file is part of nymea.
|
||||||
@ -42,7 +42,11 @@ SmtpClient::SmtpClient(QObject *parent):
|
|||||||
connect(m_socket, &QSslSocket::readyRead, this, &SmtpClient::readData);
|
connect(m_socket, &QSslSocket::readyRead, this, &SmtpClient::readData);
|
||||||
connect(m_socket, &QSslSocket::disconnected, this, &SmtpClient::disconnected);
|
connect(m_socket, &QSslSocket::disconnected, this, &SmtpClient::disconnected);
|
||||||
connect(m_socket, &QSslSocket::encrypted, this, &SmtpClient::onEncrypted);
|
connect(m_socket, &QSslSocket::encrypted, this, &SmtpClient::onEncrypted);
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
|
||||||
|
connect(m_socket, &QTcpSocket::errorOccurred, this, &SmtpClient::onSocketError);
|
||||||
|
#else
|
||||||
connect(m_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(onSocketError(QAbstractSocket::SocketError)));
|
connect(m_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(onSocketError(QAbstractSocket::SocketError)));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void SmtpClient::connectToHost()
|
void SmtpClient::connectToHost()
|
||||||
@ -247,9 +251,9 @@ void SmtpClient::processServerResponse(int responseCode, const QString &response
|
|||||||
|
|
||||||
if (m_authenticationMethod == AuthenticationMethodPlain) {
|
if (m_authenticationMethod == AuthenticationMethodPlain) {
|
||||||
send("AUTH PLAIN " + QByteArray().append(static_cast<char>(0))
|
send("AUTH PLAIN " + QByteArray().append(static_cast<char>(0))
|
||||||
.append(m_user)
|
.append(m_user.toUtf8())
|
||||||
.append(static_cast<char>(0))
|
.append(static_cast<char>(0))
|
||||||
.append(m_password)
|
.append(m_password.toUtf8())
|
||||||
.toBase64());
|
.toBase64());
|
||||||
|
|
||||||
// If we just want to test the Login, we are almost done here
|
// If we just want to test the Login, we are almost done here
|
||||||
@ -266,7 +270,7 @@ void SmtpClient::processServerResponse(int responseCode, const QString &response
|
|||||||
break;
|
break;
|
||||||
case StateUser:
|
case StateUser:
|
||||||
if (responseCode == 334) {
|
if (responseCode == 334) {
|
||||||
send(QByteArray().append(m_user).toBase64());
|
send(QByteArray().append(m_user.toUtf8()).toBase64());
|
||||||
setState(StatePassword);
|
setState(StatePassword);
|
||||||
} else {
|
} else {
|
||||||
handleUnexpectedSmtpCode(responseCode, response);
|
handleUnexpectedSmtpCode(responseCode, response);
|
||||||
@ -274,7 +278,7 @@ void SmtpClient::processServerResponse(int responseCode, const QString &response
|
|||||||
break;
|
break;
|
||||||
case StatePassword:
|
case StatePassword:
|
||||||
if (responseCode == 334) {
|
if (responseCode == 334) {
|
||||||
send(QByteArray().append(m_password).toBase64());
|
send(QByteArray().append(m_password.toUtf8()).toBase64());
|
||||||
// if we just want to test the Login, we are almost done here
|
// if we just want to test the Login, we are almost done here
|
||||||
if (!m_testLogin) {
|
if (!m_testLogin) {
|
||||||
setState(StateMail);
|
setState(StateMail);
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
*
|
*
|
||||||
* Copyright 2013 - 2020, nymea GmbH
|
* Copyright 2013 - 2025, nymea GmbH
|
||||||
* Contact: contact@nymea.io
|
* Contact: contact@nymea.io
|
||||||
*
|
*
|
||||||
* This file is part of nymea.
|
* This file is part of nymea.
|
||||||
@ -39,8 +39,6 @@
|
|||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
//#include "integrations/integrationplugin.h"
|
|
||||||
|
|
||||||
Q_DECLARE_LOGGING_CATEGORY(dcSmtpClient)
|
Q_DECLARE_LOGGING_CATEGORY(dcSmtpClient)
|
||||||
|
|
||||||
struct Message {
|
struct Message {
|
||||||
@ -49,7 +47,6 @@ struct Message {
|
|||||||
int id;
|
int id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class SmtpClient : public QObject
|
class SmtpClient : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user