From 75043d4d2d90c56ad5d8ef16d69073144238f81c Mon Sep 17 00:00:00 2001 From: Miquel Lionel Date: Thu, 14 Oct 2021 22:59:57 +0100 Subject: Make attachment button functional --- context.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'context.cpp') diff --git a/context.cpp b/context.cpp index 53cdd82..a138dd7 100644 --- a/context.cpp +++ b/context.cpp @@ -1,4 +1,7 @@ #include "context.h" +#include +#include +#include Context::Context(QObject *parent) : QObject(parent) @@ -264,8 +267,20 @@ Context::newMessage(int viewtype) } uint32_t -Context::sendMessage(uint32_t chatId, DcMessage *message) +Context::sendMessage(uint32_t chatId, DcMessage *message, QString attachment) { + QByteArray utf8attachFilename = attachment.toUtf8(); + if(strlen(utf8attachFilename.constData()) > 0){ + dc_msg_set_file(message->m_message, utf8attachFilename.constData(), NULL); + + QString ImgBlobPath; + QTextStream (&ImgBlobPath) << dc_get_blobdir(m_context) << "/" << dc_msg_get_filename(message->m_message); + + printf("\nPush it into blob dir :%s\n", ImgBlobPath.toUtf8().constData()); + QFile::copy(attachment, ImgBlobPath.toUtf8().constData()); + dc_msg_set_file(message->m_message, ImgBlobPath.toUtf8().constData(), NULL); + } + dc_prepare_msg(m_context, chatId, message->m_message); return dc_send_msg(m_context, chatId, message->m_message); } -- cgit v1.2.3-70-g09d2