chatview: file transfer support for swarm

Show download buttons for incoming files, react to COPY:'s  action

Change-Id: I811ce5657200cd6538e1acee0aacb4f57f67259a
GitLab: #1268
parent f0876551
......@@ -40,7 +40,9 @@
#include <api/contactmodel.h>
#include <api/conversationmodel.h>
#include <api/contact.h>
#include <api/datatransfermodel.h>
#include <api/lrc.h>
#include <api/newaccountmodel.h>
#include <api/newcallmodel.h>
#include <api/avmodel.h>
#include <api/pluginmodel.h>
......@@ -806,6 +808,20 @@ webkit_chat_container_script_dialog(GtkWidget* webview, gchar *interaction, Chat
} catch (...) {
g_warning("delete interaction failed: can't find %s", order.substr(std::string("DELETE_INTERACTION:").size()).c_str());
}
} else if (order.find("COPY:") == 0) {
try {
auto data = QString::fromStdString(order.substr(std::string("COPY:").size()));
auto interactionId = data.left(data.indexOf(':'));
auto displayName = data.right(data.size() - data.indexOf(':') - 1);
auto downloadDir = (*priv->accountInfo_)->accountModel->downloadDirectory;
(*priv->accountInfo_)->dataTransferModel->copyTo(priv->conversation_->accountId,
priv->conversation_->uid,
interactionId,
downloadDir,
displayName);
} catch (...) {
g_warning("copy file failed: %s", order.substr(std::string("COPY:").size()).c_str());
}
} else if (order.find("RETRY_INTERACTION:") == 0) {
try {
auto interactionId = QString::fromStdString(order.substr(std::string("RETRY_INTERACTION:").size()));
......@@ -1058,6 +1074,7 @@ webkit_chat_container_ready(ChatView* self)
webkit_chat_container_clear(
WEBKIT_CHAT_CONTAINER(priv->webkit_chat_container)
);
webkit_chat_set_is_swarm(WEBKIT_CHAT_CONTAINER(priv->webkit_chat_container), priv->conversation_->isSwarm());
display_links_toggled(self);
print_text_recording(self);
......
......@@ -212,6 +212,7 @@ build_interaction_json(lrc::api::ConversationModel& conversation_model,
interaction_object.insert("totalSize", QJsonValue(qint64(info.totalSize)));
interaction_object.insert("progress", QJsonValue(qint64(info.progress)));
}
interaction_object.insert("displayName", QJsonValue(interaction.commit["displayName"]));
break;
}
case lrc::api::interaction::Type::INVALID:
......@@ -840,6 +841,14 @@ webkit_chat_set_dark_mode(WebKitChatContainer *view, bool darkMode, const std::s
g_free(function_call);
}
void
webkit_chat_set_is_swarm(WebKitChatContainer *view, bool isSwarm)
{
gchar* function_call = g_strdup_printf("set_is_swarm(%s)", isSwarm ? "true" : "false");
webkit_chat_container_execute_js(view, function_call);
g_free(function_call);
}
void
webkit_chat_set_is_composing(WebKitChatContainer *view, const std::string& contactUri, bool isComposing)
{
......
......@@ -58,6 +58,7 @@ void webkit_chat_set_header_visible (WebKitChatContainer *view
void webkit_chat_set_record_visible (WebKitChatContainer *view, bool isVisible);
void webkit_chat_set_plugin_visible (WebKitChatContainer *view, bool isVisible);
void webkit_chat_set_dark_mode (WebKitChatContainer *view, bool darkMode, const std::string& background);
void webkit_chat_set_is_swarm (WebKitChatContainer *view, bool isSwarm);
void webkit_chat_set_is_composing (WebKitChatContainer *view, const std::string& contactUri, bool isComposing);
void webkit_chat_update_chatview_frame (WebKitChatContainer *view, bool accountEnabled, bool isBanned, bool isInvited, const gchar* alias, const gchar* bestId);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment