Remove QTextCodec usage

We are converting a base64 string here, no reason so convert that with
CP1251 specifically.
This commit is contained in:
Volker Krause 2024-03-07 17:29:29 +01:00
parent 5aed795363
commit 812db0ccde
3 changed files with 1 additions and 11 deletions

View file

@ -20,5 +20,4 @@ target_link_libraries(kdeconnect_sms
KF6::I18n
KF6::Notifications
Qt::Widgets
Qt::Core5Compat # for QTextCodec
)

View file

@ -16,7 +16,6 @@
#include <QFileInfo>
#include <QMimeDatabase>
#include <QProcess>
#include <QTextCodec>
#include <core/daemon.h>
#include <core/device.h>
@ -31,7 +30,6 @@ SmsPlugin::SmsPlugin(QObject *parent, const QVariantList &args)
, m_telepathyInterface(QStringLiteral("org.freedesktop.Telepathy.ConnectionManager.kdeconnect"), QStringLiteral("/kdeconnect"))
, m_conversationInterface(new ConversationsDbusInterface(this))
{
m_codec = QTextCodec::codecForName(CODEC_NAME);
}
SmsPlugin::~SmsPlugin()
@ -217,11 +215,9 @@ Attachment SmsPlugin::createAttachmentFromUrl(const QString &url)
QFileInfo fileInfo(file);
QString fileName(fileInfo.fileName());
QByteArray byteArray = file.readAll().toBase64();
QString base64EncodedFile = QString::fromLatin1(file.readAll().toBase64());
file.close();
QString base64EncodedFile = m_codec->toUnicode(byteArray);
QMimeDatabase mimeDatabase;
QString mimeType = mimeDatabase.mimeTypeForFile(url).name();

View file

@ -133,10 +133,6 @@
Q_DECLARE_LOGGING_CATEGORY(KDECONNECT_PLUGIN_SMS)
#define CODEC_NAME "CP1251"
class QTextCodec;
class SmsPlugin : public KdeConnectPlugin
{
Q_OBJECT
@ -203,5 +199,4 @@ private:
QDBusInterface m_telepathyInterface;
ConversationsDbusInterface *m_conversationInterface;
QTextCodec *m_codec;
};