From 84e588b7e03eab4bb7b0aabff7624ac2f92d3568 Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 15 May 2017 21:37:22 +0200 Subject: [PATCH] switch file to REMOTE state in subfileitem if the attachment has already been checked in the past but the file is not here anymore --- retroshare-gui/src/gui/feeds/SubFileItem.cpp | 8 ++++++-- retroshare-gui/src/gui/feeds/SubFileItem.h | 6 +++--- .../src/gui/gxschannels/CreateGxsChannelMsg.cpp | 16 ++++++---------- .../src/gui/gxschannels/CreateGxsChannelMsg.h | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/retroshare-gui/src/gui/feeds/SubFileItem.cpp b/retroshare-gui/src/gui/feeds/SubFileItem.cpp index 209bffa28..acaf76299 100644 --- a/retroshare-gui/src/gui/feeds/SubFileItem.cpp +++ b/retroshare-gui/src/gui/feeds/SubFileItem.cpp @@ -186,7 +186,7 @@ void SubFileItem::updateItemStatic() } /* get full path for local file */ - if ((mMode == SFI_STATE_LOCAL) || (mMode == SFI_STATE_UPLOAD)) + if (((mMode == SFI_STATE_LOCAL) || (mMode == SFI_STATE_UPLOAD))) { #ifdef DEBUG_ITEM std::cerr << "SubFileItem::updateItemStatic() STATE=Local/Upload checking path"; @@ -200,7 +200,10 @@ void SubFileItem::updateItemStatic() /* look up path */ if (!rsFiles->FileDetails(mFileHash, hintflags, fi)) { - mMode = SFI_STATE_ERROR; + if(mFlag & SFI_FLAG_ASSUME_FILE_READY) + mMode = SFI_STATE_REMOTE; + else + mMode = SFI_STATE_ERROR; #ifdef DEBUG_ITEM std::cerr << "SubFileItem::updateItemStatic() STATE=>Error No Details"; std::cerr << std::endl; @@ -251,6 +254,7 @@ void SubFileItem::updateItemStatic() case SFI_STATE_REMOTE: playButton->setEnabled(false); downloadButton->setEnabled(true); + downloadButton->setVisible(true); cancelButton->setEnabled(false); progressBar->setValue(0); diff --git a/retroshare-gui/src/gui/feeds/SubFileItem.h b/retroshare-gui/src/gui/feeds/SubFileItem.h index 330725a4c..1228c9b88 100644 --- a/retroshare-gui/src/gui/feeds/SubFileItem.h +++ b/retroshare-gui/src/gui/feeds/SubFileItem.h @@ -40,9 +40,9 @@ const uint32_t SFI_STATE_UPLOAD = 0x0006; const uint32_t SFI_TYPE_CHANNEL = 0x0010; const uint32_t SFI_TYPE_ATTACH = 0x0020; -const uint32_t SFI_FLAG_CREATE = 0x1000; -const uint32_t SFI_FLAG_ALLOW_DELETE = 0x2000; -const uint32_t SFI_FLAG_NO_DOWNLOAD = 0x4000; +const uint32_t SFI_FLAG_CREATE = 0x1000; +const uint32_t SFI_FLAG_ALLOW_DELETE = 0x2000; +const uint32_t SFI_FLAG_ASSUME_FILE_READY = 0x4000; //! This create a gui widget that allows users to access files shared by user diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp index ed8fb6f07..bc2b5a2d7 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp @@ -343,7 +343,7 @@ void CreateGxsChannelMsg::parseRsFileListAttachments(const std::string &attachLi } -void CreateGxsChannelMsg::addAttachment(const RsFileHash &hash, const std::string &fname, uint64_t size, bool local, const RsPeerId &srcId) +void CreateGxsChannelMsg::addAttachment(const RsFileHash &hash, const std::string &fname, uint64_t size, bool local, const RsPeerId &srcId, bool assume_file_ready) { /* add a SubFileItem to the attachment section */ std::cerr << "CreateGxsChannelMsg::addAttachment()"; @@ -352,14 +352,14 @@ void CreateGxsChannelMsg::addAttachment(const RsFileHash &hash, const std::strin /* add widget in for new destination */ uint32_t flags = SFI_TYPE_CHANNEL | SFI_FLAG_ALLOW_DELETE ; + + if(assume_file_ready) + flags |= SFI_FLAG_ASSUME_FILE_READY; + if (local) - { flags |= SFI_STATE_LOCAL; - } else - { flags |= SFI_STATE_REMOTE; - } SubFileItem *file = new SubFileItem(hash, fname, "", size, flags, srcId); // destroyed when fileFrame (this subfileitem) is destroyed @@ -370,11 +370,7 @@ void CreateGxsChannelMsg::addAttachment(const RsFileHash &hash, const std::strin layout->addWidget(file); if (mCheckAttachment) - { checkAttachmentReady(); - } - - return; } void CreateGxsChannelMsg::deleteAttachment() @@ -749,7 +745,7 @@ void CreateGxsChannelMsg::loadChannelPostInfo(const uint32_t &token) msgEdit->setText(QString::fromUtf8(post.mMsg.c_str())) ; for(std::list::const_iterator it(post.mFiles.begin());it!=post.mFiles.end();++it) - addAttachment(it->mHash,it->mName,it->mSize,true,RsPeerId()); + addAttachment(it->mHash,it->mName,it->mSize,true,RsPeerId(),true); picture.loadFromData(post.mThumbnail.mData,post.mThumbnail.mSize,"PNG"); thumbnail_label->setPixmap(picture); diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h index 37404a23a..4a99ad9aa 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h @@ -44,7 +44,7 @@ public: ~CreateGxsChannelMsg(); void addAttachment(const std::string &path); - void addAttachment(const RsFileHash &hash, const std::string &fname, uint64_t size, bool local, const RsPeerId &srcId); + void addAttachment(const RsFileHash &hash, const std::string &fname, uint64_t size, bool local, const RsPeerId &srcId,bool assume_file_ready = false); void newChannelMsg();