diff options
author | Miquel Lionel <lionel@les-miquelots.net> | 2021-10-20 12:48:09 +0100 |
---|---|---|
committer | link2xt <link2xt@testrun.org> | 2021-10-27 09:16:28 +0300 |
commit | 1a8b1d4dfb1af936ec68b30af475dcfbeff6453c (patch) | |
tree | 88035de2469c17329bd652b4c35d06bc6cee9e79 /message.cpp | |
parent | 9b329f6eaaa178b74c32b64977f5344d14de3a3e (diff) | |
download | kdeltachat-1a8b1d4dfb1af936ec68b30af475dcfbeff6453c.tar.gz kdeltachat-1a8b1d4dfb1af936ec68b30af475dcfbeff6453c.zip |
Implement saving attachment to filesystem
Diffstat (limited to 'message.cpp')
-rw-r--r-- | message.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/message.cpp b/message.cpp index 4da0fd1..6d02db1 100644 --- a/message.cpp +++ b/message.cpp @@ -52,6 +52,25 @@ DcMessage::getTimestamp() return QDateTime::fromSecsSinceEpoch (dc_msg_get_timestamp(m_message), Qt::UTC); } +bool +DcMessage::saveAttach(QString dest) +{ + if(!dest.isNull()){ + char *file = dc_msg_get_file(m_message); + QString fileUrl{file}; + dc_str_unref(file); + // we need to replace, so we delete file first + if (QFile::exists(dest)){ + if(!QFile::remove(dest)) + return false; + } + return QFile::copy(fileUrl, dest); + } + else{ + return false; + } +} + void DcMessage::setText(QString text) { |