Commit 182bc535 authored by Sébastien Blin's avatar Sébastien Blin Committed by Olivier SOLDANO

interaction: add unjoinable peer status

Change-Id: Iabe3b6d410f108bc47a95bd9bec1f01626e20595
Reviewed-by: default avatarOlivier Soldano <olivier.soldano@savoirfairelinux.com>
parent a48299e3
...@@ -90,6 +90,7 @@ enum class Status { ...@@ -90,6 +90,7 @@ enum class Status {
TRANSFER_ACCEPTED, TRANSFER_ACCEPTED,
TRANSFER_CANCELED, TRANSFER_CANCELED,
TRANSFER_ERROR, TRANSFER_ERROR,
TRANSFER_UNJOINABLE_PEER,
TRANSFER_ONGOING, TRANSFER_ONGOING,
TRANSFER_AWAITING, TRANSFER_AWAITING,
TRANSFER_FINISHED TRANSFER_FINISHED
...@@ -119,6 +120,8 @@ to_string(const Status& status) ...@@ -119,6 +120,8 @@ to_string(const Status& status)
return "TRANSFER_CANCELED"; return "TRANSFER_CANCELED";
case Status::TRANSFER_ERROR: case Status::TRANSFER_ERROR:
return "TRANSFER_ERROR"; return "TRANSFER_ERROR";
case Status::TRANSFER_UNJOINABLE_PEER:
return "TRANSFER_UNJOINABLE_PEER";
case Status::TRANSFER_ONGOING: case Status::TRANSFER_ONGOING:
return "TRANSFER_ONGOING"; return "TRANSFER_ONGOING";
case Status::TRANSFER_AWAITING: case Status::TRANSFER_AWAITING:
...@@ -154,6 +157,8 @@ to_status(const std::string& status) ...@@ -154,6 +157,8 @@ to_status(const std::string& status)
return interaction::Status::TRANSFER_CANCELED; return interaction::Status::TRANSFER_CANCELED;
else if (status == "TRANSFER_ERROR") else if (status == "TRANSFER_ERROR")
return interaction::Status::TRANSFER_ERROR; return interaction::Status::TRANSFER_ERROR;
else if (status == "TRANSFER_UNJOINABLE_PEER")
return interaction::Status::TRANSFER_UNJOINABLE_PEER;
else if (status == "TRANSFER_ONGOING") else if (status == "TRANSFER_ONGOING")
return interaction::Status::TRANSFER_ONGOING; return interaction::Status::TRANSFER_ONGOING;
else if (status == "TRANSFER_AWAITING") else if (status == "TRANSFER_AWAITING")
......
...@@ -313,10 +313,12 @@ CallbacksHandler::slotDataTransferEvent(qulonglong dringId, uint codeStatus) ...@@ -313,10 +313,12 @@ CallbacksHandler::slotDataTransferEvent(qulonglong dringId, uint codeStatus)
emit transferStatusFinished(static_cast<long long>(dringId), info); emit transferStatusFinished(static_cast<long long>(dringId), info);
break; break;
case DRing::DataTransferEventCode::invalid_pathname: case DRing::DataTransferEventCode::invalid_pathname:
case DRing::DataTransferEventCode::unjoinable_peer:
case DRing::DataTransferEventCode::unsupported: case DRing::DataTransferEventCode::unsupported:
emit transferStatusError(static_cast<long long>(dringId), info); emit transferStatusError(static_cast<long long>(dringId), info);
break; break;
case DRing::DataTransferEventCode::unjoinable_peer:
emit transferStatusUnjoinable(static_cast<long long>(dringId), info);
break;
} }
} }
......
...@@ -167,6 +167,7 @@ Q_SIGNALS: ...@@ -167,6 +167,7 @@ Q_SIGNALS:
void transferStatusOngoing(long long dringId, api::datatransfer::Info info); void transferStatusOngoing(long long dringId, api::datatransfer::Info info);
void transferStatusFinished(long long dringId, api::datatransfer::Info info); void transferStatusFinished(long long dringId, api::datatransfer::Info info);
void transferStatusError(long long dringId, api::datatransfer::Info info); void transferStatusError(long long dringId, api::datatransfer::Info info);
void transferStatusUnjoinable(long long dringId, api::datatransfer::Info info);
private Q_SLOTS: private Q_SLOTS:
/** /**
......
...@@ -235,6 +235,7 @@ public Q_SLOTS: ...@@ -235,6 +235,7 @@ public Q_SLOTS:
void slotTransferStatusOngoing(long long dringId, api::datatransfer::Info info); void slotTransferStatusOngoing(long long dringId, api::datatransfer::Info info);
void slotTransferStatusFinished(long long dringId, api::datatransfer::Info info); void slotTransferStatusFinished(long long dringId, api::datatransfer::Info info);
void slotTransferStatusError(long long dringId, api::datatransfer::Info info); void slotTransferStatusError(long long dringId, api::datatransfer::Info info);
void slotTransferStatusUnjoinable(long long dringId, api::datatransfer::Info info);
}; };
ConversationModel::ConversationModel(const account::Info& owner, ConversationModel::ConversationModel(const account::Info& owner,
...@@ -752,6 +753,10 @@ ConversationModelPimpl::ConversationModelPimpl(const ConversationModel& linked, ...@@ -752,6 +753,10 @@ ConversationModelPimpl::ConversationModelPimpl(const ConversationModel& linked,
&CallbacksHandler::transferStatusError, &CallbacksHandler::transferStatusError,
this, this,
&ConversationModelPimpl::slotTransferStatusError); &ConversationModelPimpl::slotTransferStatusError);
connect(&callbacksHandler,
&CallbacksHandler::transferStatusUnjoinable,
this,
&ConversationModelPimpl::slotTransferStatusUnjoinable);
} }
ConversationModelPimpl::~ConversationModelPimpl() ConversationModelPimpl::~ConversationModelPimpl()
...@@ -1538,6 +1543,30 @@ ConversationModelPimpl::slotTransferStatusError(long long dringId, datatransfer: ...@@ -1538,6 +1543,30 @@ ConversationModelPimpl::slotTransferStatusError(long long dringId, datatransfer:
} }
} }
void
ConversationModelPimpl::slotTransferStatusUnjoinable(long long dringId, datatransfer::Info info)
{
int interactionId;
std::string convId;
if (not usefulDataFromDataTransfer(dringId, info, interactionId, convId))
return;
// update information in the db
database::updateInteractionStatus(db, interactionId, interaction::Status::TRANSFER_UNJOINABLE_PEER);
// prepare interaction Info and emit signal for the client
auto conversationIdx = indexOf(convId);
if (conversationIdx != -1) {
auto& interactions = conversations[conversationIdx].interactions;
auto it = interactions.find(interactionId);
if (it != interactions.end()) {
it->second.status = interaction::Status::TRANSFER_UNJOINABLE_PEER;
dirtyConversations = true;
emit linked.interactionStatusUpdated(convId, interactionId, it->second);
}
}
}
void void
ConversationModelPimpl::updateTransfer(QTimer* timer, const std::string& conversation, ConversationModelPimpl::updateTransfer(QTimer* timer, const std::string& conversation,
int conversationIdx, int interactionId) int conversationIdx, int interactionId)
......
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