mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-07-23 17:05:28 +02:00
conversation: add the possibility to answer with a file
Also remove retryInteraction as useless in new versions. Change-Id: I79a016c9fa7b8bc4d5fcdb0aeff51d78aea2f314 GitLab: #1017
This commit is contained in:
parent
bd3ee22c83
commit
0de8f019b2
8 changed files with 40 additions and 90 deletions
|
@ -200,16 +200,6 @@ Rectangle {
|
|||
}
|
||||
|
||||
onSendMessageButtonClicked: {
|
||||
// Send text message
|
||||
if (messageBar.text) {
|
||||
if (MessagesAdapter.editId !== "") {
|
||||
MessagesAdapter.editMessage(CurrentConversation.id, messageBar.text)
|
||||
} else {
|
||||
MessagesAdapter.sendMessage(messageBar.text)
|
||||
}
|
||||
}
|
||||
messageBar.textAreaObj.clearText()
|
||||
|
||||
// Send file messages
|
||||
var fileCounts = dataTransferSendContainer.filesToSendListModel.rowCount()
|
||||
for (var i = 0; i < fileCounts; i++) {
|
||||
|
@ -219,6 +209,16 @@ Rectangle {
|
|||
MessagesAdapter.sendFile(filePath)
|
||||
}
|
||||
dataTransferSendContainer.filesToSendListModel.flush()
|
||||
// Send text message
|
||||
if (messageBar.text) {
|
||||
if (MessagesAdapter.editId !== "") {
|
||||
MessagesAdapter.editMessage(CurrentConversation.id, messageBar.text)
|
||||
} else {
|
||||
MessagesAdapter.sendMessage(messageBar.text)
|
||||
}
|
||||
}
|
||||
messageBar.textAreaObj.clearText()
|
||||
MessagesAdapter.replyToId = ""
|
||||
}
|
||||
onVideoRecordMessageButtonClicked: {
|
||||
JamiQmlUtils.updateMessageBarButtonsPoints()
|
||||
|
|
|
@ -113,6 +113,7 @@ Popup {
|
|||
function sendRecord() {
|
||||
if (pathRecorder !== "") {
|
||||
MessagesAdapter.sendFile(pathRecorder)
|
||||
MessagesAdapter.replyToId = ""
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -173,7 +173,6 @@ MessagesAdapter::sendMessage(const QString& message)
|
|||
try {
|
||||
const auto convUid = lrcInstance_->get_selectedConvUid();
|
||||
lrcInstance_->getCurrentConversationModel()->sendMessage(convUid, message, replyToId_);
|
||||
set_replyToId("");
|
||||
} catch (...) {
|
||||
qDebug() << "Exception during sendMessage:" << message;
|
||||
}
|
||||
|
@ -229,19 +228,15 @@ MessagesAdapter::sendFile(const QString& message)
|
|||
QString fileName = fi.fileName();
|
||||
try {
|
||||
auto convUid = lrcInstance_->get_selectedConvUid();
|
||||
lrcInstance_->getCurrentConversationModel()->sendFile(convUid, message, fileName);
|
||||
lrcInstance_->getCurrentConversationModel()->sendFile(convUid,
|
||||
message,
|
||||
fileName,
|
||||
replyToId_);
|
||||
} catch (...) {
|
||||
qDebug() << "Exception during sendFile";
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MessagesAdapter::retryInteraction(const QString& interactionId)
|
||||
{
|
||||
lrcInstance_->getCurrentConversationModel()
|
||||
->retryInteraction(lrcInstance_->get_selectedConvUid(), interactionId);
|
||||
}
|
||||
|
||||
void
|
||||
MessagesAdapter::joinCall(const QString& uri,
|
||||
const QString& deviceId,
|
||||
|
|
|
@ -109,7 +109,6 @@ protected:
|
|||
Q_INVOKABLE void cancelFile(const QString& arg);
|
||||
Q_INVOKABLE void openUrl(const QString& url);
|
||||
Q_INVOKABLE void openDirectory(const QString& arg);
|
||||
Q_INVOKABLE void retryInteraction(const QString& interactionId);
|
||||
Q_INVOKABLE void deleteInteraction(const QString& interactionId);
|
||||
Q_INVOKABLE void joinCall(const QString& uri,
|
||||
const QString& deviceId,
|
||||
|
|
|
@ -284,12 +284,6 @@ public:
|
|||
* @param convId
|
||||
*/
|
||||
void clearInteractionsCache(const QString& convId);
|
||||
/**
|
||||
* Retry to send a message. In fact, will delete the previous interaction and resend a new one.
|
||||
* @param convId
|
||||
* @param interactionId
|
||||
*/
|
||||
void retryInteraction(const QString& convId, const QString& interactionId);
|
||||
/**
|
||||
* @param convId
|
||||
* @param interactionId
|
||||
|
@ -305,7 +299,10 @@ public:
|
|||
*/
|
||||
void deleteObsoleteHistory(int date);
|
||||
|
||||
void sendFile(const QString& convUid, const QString& path, const QString& filename);
|
||||
void sendFile(const QString& convUid,
|
||||
const QString& path,
|
||||
const QString& filename,
|
||||
const QString& parent);
|
||||
|
||||
void acceptTransfer(const QString& convUid, const QString& interactionId);
|
||||
|
||||
|
|
|
@ -54,7 +54,8 @@ public:
|
|||
void sendFile(const QString& account_id,
|
||||
const QString& conversationId,
|
||||
const QString& file_path,
|
||||
const QString& display_name);
|
||||
const QString& display_name,
|
||||
const QString& parent);
|
||||
|
||||
void fileTransferInfo(const QString& accountId,
|
||||
const QString& conversationId,
|
||||
|
|
|
@ -1285,8 +1285,13 @@ ConversationModel::sendMessage(const QString& uid, const QString& body, const QS
|
|||
}
|
||||
|
||||
// Add interaction to database
|
||||
interaction::Info
|
||||
msg {owner.profileInfo.uri, body, std::time(nullptr), 0, interaction::Type::TEXT, status, true};
|
||||
interaction::Info msg {owner.profileInfo.uri,
|
||||
body,
|
||||
std::time(nullptr),
|
||||
0,
|
||||
interaction::Type::TEXT,
|
||||
status,
|
||||
true};
|
||||
auto msgId = storage::addMessageToConversation(pimpl_->db, convId, msg);
|
||||
|
||||
// Update conversation
|
||||
|
@ -1562,59 +1567,6 @@ ConversationModel::clearInteractionsCache(const QString& convId)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
ConversationModel::retryInteraction(const QString& convId, const QString& interactionId)
|
||||
{
|
||||
auto conversationIdx = pimpl_->indexOf(convId);
|
||||
if (conversationIdx == -1)
|
||||
return;
|
||||
|
||||
auto interactionType = interaction::Type::INVALID;
|
||||
QString body = {};
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(pimpl_->interactionsLocks[convId]);
|
||||
try {
|
||||
auto& conversation = pimpl_->conversations.at(conversationIdx);
|
||||
if (conversation.isSwarm()) {
|
||||
// WARNING: retry interaction is not implemented for swarm
|
||||
return;
|
||||
}
|
||||
|
||||
auto& interactions = conversation.interactions;
|
||||
auto it = interactions->find(interactionId);
|
||||
if (it == interactions->end())
|
||||
return;
|
||||
|
||||
if (!interaction::isOutgoing(it->second))
|
||||
return; // Do not retry non outgoing info
|
||||
|
||||
if (it->second.type == interaction::Type::TEXT
|
||||
|| (it->second.type == interaction::Type::DATA_TRANSFER
|
||||
&& interaction::isOutgoing(it->second))) {
|
||||
body = it->second.body;
|
||||
interactionType = it->second.type;
|
||||
} else
|
||||
return;
|
||||
|
||||
storage::clearInteractionFromConversation(pimpl_->db, convId, interactionId);
|
||||
conversation.interactions->erase(interactionId);
|
||||
} catch (const std::out_of_range& e) {
|
||||
qDebug() << "can't find interaction from conversation: " << e.what();
|
||||
return;
|
||||
}
|
||||
}
|
||||
Q_EMIT interactionRemoved(convId, interactionId);
|
||||
|
||||
// Send a new interaction like the previous one
|
||||
if (interactionType == interaction::Type::TEXT) {
|
||||
sendMessage(convId, body);
|
||||
} else {
|
||||
// send file
|
||||
QFileInfo f(body);
|
||||
sendFile(convId, body, f.fileName());
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
ConversationModel::isLastDisplayed(const QString& convId,
|
||||
const QString& interactionId,
|
||||
|
@ -3488,7 +3440,8 @@ ConversationModelPimpl::slotCallStatusChanged(const QString& callId, int code)
|
|||
if (!conversation.callId.isEmpty()) {
|
||||
// If outgoing and incoming happen at the same time, choose the current one.
|
||||
auto call = linked.owner.callModel->getCall(conversation.callId);
|
||||
qWarning() << "Double call detected" << call::to_string(call.status) << " - " << conversation.callId;
|
||||
qWarning() << "Double call detected" << call::to_string(call.status)
|
||||
<< " - " << conversation.callId;
|
||||
// Ignore new call in favor of existing one
|
||||
if (call.status == call::Status::IN_PROGRESS)
|
||||
return;
|
||||
|
@ -3950,12 +3903,15 @@ ConversationModel::setIsComposing(const QString& convUid, bool isComposing)
|
|||
}
|
||||
|
||||
void
|
||||
ConversationModel::sendFile(const QString& convUid, const QString& path, const QString& filename)
|
||||
ConversationModel::sendFile(const QString& convUid,
|
||||
const QString& path,
|
||||
const QString& filename,
|
||||
const QString& parent)
|
||||
{
|
||||
try {
|
||||
auto& conversation = pimpl_->getConversationForUid(convUid, true).get();
|
||||
if (conversation.isSwarm()) {
|
||||
owner.dataTransferModel->sendFile(owner.id, convUid, path, filename);
|
||||
owner.dataTransferModel->sendFile(owner.id, convUid, path, filename, parent);
|
||||
return;
|
||||
}
|
||||
auto peers = pimpl_->peersForConversation(conversation);
|
||||
|
@ -3979,7 +3935,7 @@ ConversationModel::sendFile(const QString& convUid, const QString& path, const Q
|
|||
|
||||
pimpl_->sendContactRequest(peerId);
|
||||
|
||||
auto cb = ([this, peerId, path, filename](QString conversationId) {
|
||||
auto cb = ([this, peerId, path, filename, parent](QString conversationId) {
|
||||
try {
|
||||
auto conversationOpt = getConversationForUid(conversationId);
|
||||
if (!conversationOpt.has_value()) {
|
||||
|
@ -3991,7 +3947,7 @@ ConversationModel::sendFile(const QString& convUid, const QString& path, const Q
|
|||
qDebug() << "ContactModel::sendFile: denied, contact is banned";
|
||||
return;
|
||||
}
|
||||
owner.dataTransferModel->sendFile(owner.id, conversationId, path, filename);
|
||||
owner.dataTransferModel->sendFile(owner.id, conversationId, path, filename, parent);
|
||||
} catch (...) {
|
||||
}
|
||||
});
|
||||
|
|
|
@ -134,13 +134,14 @@ void
|
|||
DataTransferModel::sendFile(const QString& accountId,
|
||||
const QString& conversationId,
|
||||
const QString& filePath,
|
||||
const QString& displayName)
|
||||
const QString& displayName,
|
||||
const QString& parent)
|
||||
{
|
||||
ConfigurationManager::instance().sendFile(accountId,
|
||||
conversationId,
|
||||
filePath,
|
||||
displayName,
|
||||
{} /* TODO parent */);
|
||||
parent);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Add table
Reference in a new issue