From ed7a1fbf61d7879fd33896f36effd2f154753438 Mon Sep 17 00:00:00 2001 From: Tobias Markmann Date: Mon, 22 Jun 2015 11:06:58 +0200 Subject: Show collecting of file transfer candidates in UI Show the user the collection of possible file transfer candidates after pressing the 'Start' button for a file transfer. Previously the buttons remained in the UI giving no feedback to the user at all. If no UPnP/NAT-PMP device is present, it this stage can take a couple seconds to timeout and move on to the next stage. Furthermore this commit adds documentation for the different states in the ChatWindow::FileTransferState enum. Test-Information: Tested this in a network environment with no UPnP/NAT-PMP device between two Swift instances. Change-Id: I76ec6e641a2acd683938fe2d8f542d023a244145 diff --git a/Swift/Controllers/FileTransfer/FileTransferController.cpp b/Swift/Controllers/FileTransfer/FileTransferController.cpp index 076d3c0..f7ce8e6 100644 --- a/Swift/Controllers/FileTransfer/FileTransferController.cpp +++ b/Swift/Controllers/FileTransfer/FileTransferController.cpp @@ -148,6 +148,7 @@ void FileTransferController::handleFileTransferStateChange(FileTransfer::State s chatWindow->setFileTransferStatus(uiID, ChatWindow::WaitingForAccept); return; case FileTransfer::State::WaitingForStart: + chatWindow->setFileTransferStatus(uiID, ChatWindow::Initialisation); return; } assert(false); diff --git a/Swift/Controllers/UIInterfaces/ChatWindow.h b/Swift/Controllers/UIInterfaces/ChatWindow.h index b1e2a11..0fa734c 100644 --- a/Swift/Controllers/UIInterfaces/ChatWindow.h +++ b/Swift/Controllers/UIInterfaces/ChatWindow.h @@ -89,7 +89,15 @@ namespace Swift { enum ReceiptState {ReceiptRequested, ReceiptReceived, ReceiptFailed}; enum OccupantAction {Kick, Ban, MakeModerator, MakeParticipant, MakeVisitor, AddContact, ShowProfile}; enum RoomAction {ChangeSubject, Configure, Affiliations, Destroy, Invite}; - enum FileTransferState {WaitingForAccept, Negotiating, Transferring, Canceled, Finished, FTFailed}; + enum FileTransferState { + Initialisation, ///< Collecting information required for sending the request out. + WaitingForAccept, ///< The file transfer request was send out. + Negotiating, ///< The other party accepted the file transfer request and a suitable transfer method is negotiated. + Transferring, ///< The negotiation was successful and the file is currently transferred. + Canceled, ///< Someone actively canceled the transfer. + Finished, ///< The file was transferred successfully. + FTFailed ///< The negotiation, the transfer itself or the verification failed. + }; enum WhiteboardSessionState {WhiteboardAccepted, WhiteboardTerminated, WhiteboardRejected}; enum BlockingState {BlockingUnsupported, IsBlocked, IsUnblocked}; enum Direction { UnknownDirection, DefaultDirection }; diff --git a/Swift/QtUI/QtPlainChatView.cpp b/Swift/QtUI/QtPlainChatView.cpp index 031a41d..eabf35f 100644 --- a/Swift/QtUI/QtPlainChatView.cpp +++ b/Swift/QtUI/QtPlainChatView.cpp @@ -6,22 +6,22 @@ #include -#include -#include -#include -#include -#include #include -#include #include #include +#include #include +#include +#include +#include +#include +#include -#include #include +#include -#include #include +#include #include #include @@ -360,6 +360,13 @@ QtPlainChatView::FileTransfer::FileTransfer(QtPlainChatView* parent, bool sender std::string status = msg; switch (state) { + case ChatWindow::Initialisation: { + status = "Preparing to send "+ filename + "..."; + FileTransfer::Action* cancel = new FileTransfer::Action("Cancel", ftId); + parent->connect(cancel, SIGNAL(clicked()), SLOT(fileTransferReject())); + layout_->addWidget(cancel); + break; + } case ChatWindow::WaitingForAccept: { status = "Waiting for user to accept " + filename + "..."; FileTransfer::Action* cancel = new FileTransfer::Action("Cancel", ftId); diff --git a/Swift/QtUI/QtWebKitChatView.cpp b/Swift/QtUI/QtWebKitChatView.cpp index d6dc6f5..b7f96f6 100644 --- a/Swift/QtUI/QtWebKitChatView.cpp +++ b/Swift/QtUI/QtWebKitChatView.cpp @@ -438,18 +438,22 @@ void QtWebKitChatView::setFileTransferStatus(QString id, const ChatWindow::FileT } QString newInnerHTML = ""; - if (state == ChatWindow::WaitingForAccept) { - newInnerHTML = tr("Waiting for other side to accept the transfer.") + "
" + + if (state == ChatWindow::Initialisation) { + newInnerHTML = tr("Preparing to send.") + "
" + buildChatWindowButton(tr("Cancel"), ButtonFileTransferCancel, id); } - if (state == ChatWindow::Negotiating) { + else if (state == ChatWindow::WaitingForAccept) { + newInnerHTML = tr("Waiting for other side to accept the transfer.") + "
" + + buildChatWindowButton(tr("Cancel"), ButtonFileTransferCancel, id); + } + else if (state == ChatWindow::Negotiating) { // replace with text "Negotiaging" + Cancel button - newInnerHTML = tr("Negotiating...") + "
" + + newInnerHTML = tr("Negotiating...") + "
" + buildChatWindowButton(tr("Cancel"), ButtonFileTransferCancel, id); } else if (state == ChatWindow::Transferring) { // progress bar + Cancel Button - newInnerHTML = "
" + newInnerHTML = "
" "
" "
" "0%" -- cgit v0.10.2-6-g49f6