diff --git a/libretroshare/src/ft/ftextralist.cc b/libretroshare/src/ft/ftextralist.cc index 93e353f5c..e5de013d3 100644 --- a/libretroshare/src/ft/ftextralist.cc +++ b/libretroshare/src/ft/ftextralist.cc @@ -27,6 +27,8 @@ #include "util/rswin.h" #endif +#include +#include #include "ft/ftextralist.h" #include "serialiser/rsconfigitems.h" #include "util/rsdir.h" @@ -167,7 +169,7 @@ bool ftExtraList::addExtraFile(std::string path, std::string hash, details.info.hash = hash; details.info.size = size; details.info.age = time(NULL) + period; /* if time > this... cleanup */ - details.flags = flags; + details.info.transfer_info_flags = flags ; /* stick it in the available queue */ mFiles[details.info.hash] = details; @@ -263,7 +265,7 @@ bool ftExtraList::cleanupOldFiles() { if (mFiles.end() != (it = mFiles.find(*rit))) { - cleanupEntry(it->second.info.path, it->second.flags); + cleanupEntry(it->second.info.path, it->second.info.transfer_info_flags); mFiles.erase(it); } } @@ -349,6 +351,13 @@ bool ftExtraList::search(const std::string &hash, FileSearchFlags /*hintflags } info = fit->second.info; + + // Now setup the file storage flags so that the client can know how to handle permissions + // + info.storage_permission_flags = DIR_FLAGS_BROWSABLE_OTHERS ; + + if(info.transfer_info_flags & RS_FILE_REQ_ANONYMOUS_ROUTING) info.storage_permission_flags |= DIR_FLAGS_NETWORK_WIDE_OTHERS ; + return true; } @@ -396,7 +405,7 @@ bool ftExtraList::saveList(bool &cleanup, std::list& sList) fi->file.hash = (it->second).info.hash; fi->file.filesize = (it->second).info.size; fi->file.age = (it->second).info.age; - fi->flags = (it->second).flags.toUInt32(); + fi->flags = (it->second).info.transfer_info_flags.toUInt32(); sList.push_back(fi); } @@ -461,7 +470,7 @@ bool ftExtraList::loadList(std::list& load) details.info.hash = fi->file.hash; details.info.size = fi->file.filesize; details.info.age = fi->file.age; /* time that we remove it. */ - details.flags = TransferRequestFlags(fi->flags); + details.info.transfer_info_flags = TransferRequestFlags(fi->flags); /* stick it in the available queue */ mFiles[details.info.hash] = details; diff --git a/libretroshare/src/ft/ftextralist.h b/libretroshare/src/ft/ftextralist.h index c34c90399..ac2a28e30 100644 --- a/libretroshare/src/ft/ftextralist.h +++ b/libretroshare/src/ft/ftextralist.h @@ -74,14 +74,14 @@ class FileDetails { info.path = path; period = p; - flags = f; + info.transfer_info_flags = f; } FileDetails(FileInfo &i, uint32_t p, TransferRequestFlags f) { info = i; period = p; - flags = f; + info.transfer_info_flags = f; } FileInfo info; @@ -96,7 +96,7 @@ class FileDetails uint32_t start; uint32_t period; - TransferRequestFlags flags; + //TransferRequestFlags flags; }; const uint32_t FT_DETAILS_CLEANUP = 0x0100; /* remove when it expires */ diff --git a/retroshare-gui/src/gui/FriendsDialog.cpp b/retroshare-gui/src/gui/FriendsDialog.cpp index 989fac580..821986b07 100644 --- a/retroshare-gui/src/gui/FriendsDialog.cpp +++ b/retroshare-gui/src/gui/FriendsDialog.cpp @@ -761,7 +761,7 @@ void FriendsDialog::addExtraFile() { QStringList files; if (misc::getOpenFileNames(this, RshareSettings::LASTDIR_EXTRAFILE, tr("Add Extra File"), "", files)) { - ui.hashBox->addAttachments(files); + ui.hashBox->addAttachments(files,TransferRequestFlags(0u)); // no anonymous routing, because it is for friends only! } } @@ -775,9 +775,10 @@ void FriendsDialog::fileHashingFinished(QList hashedFiles) for (it = hashedFiles.begin(); it != hashedFiles.end(); ++it) { HashedFile& hashedFile = *it; RetroShareLink link; - if (!link.createFile(hashedFile.filename, hashedFile.size, QString::fromStdString(hashedFile.hash))) { + + if (!link.createExtraFile(hashedFile.filename, hashedFile.size, QString::fromStdString(hashedFile.hash),QString::fromStdString(rsPeers->getOwnId()))) continue; - } + mesgString += link.toHtmlSize(); if (it!= hashedFiles.end()) { mesgString += "
"; diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp index 8973afaf7..676993393 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp @@ -78,6 +78,7 @@ void ChatLobbyDialog::init(const std::string &peerId, const QString &title) ui.chatWidget->setName(QString::fromUtf8(nickName.c_str())); ui.chatWidget->addToolsAction(ui.actionChangeNickname); + ui.chatWidget->setDefaultExtraFileFlags(RS_FILE_REQ_ANONYMOUS_ROUTING); lastUpdateListTime = 0; diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index 72446b521..91e6fba96 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -133,6 +133,12 @@ ChatWidget::~ChatWidget() delete ui; } +void ChatWidget::setDefaultExtraFileFlags(TransferRequestFlags fl) +{ + mDefaultExtraFileFlags = fl ; + ui->hashBox->setDefaultTransferRequestFlags(fl) ; +} + void ChatWidget::addChatButton(QPushButton *button) { ui->toolBarFrame->layout()->addWidget(button) ; @@ -600,7 +606,7 @@ void ChatWidget::addExtraFile() { QStringList files; if (misc::getOpenFileNames(this, RshareSettings::LASTDIR_EXTRAFILE, tr("Add Extra File"), "", files)) { - ui->hashBox->addAttachments(files/*, 0*/); + ui->hashBox->addAttachments(files,mDefaultExtraFileFlags /*, 0*/); } } @@ -629,7 +635,11 @@ void ChatWidget::fileHashingFinished(QList hashedFiles) QString ext = QFileInfo(hashedFile.filename).suffix(); RetroShareLink link; - link.createExtraFile(hashedFile.filename, hashedFile.size, QString::fromStdString(hashedFile.hash),QString::fromStdString(rsPeers->getOwnId())); + + if(mDefaultExtraFileFlags & RS_FILE_REQ_ANONYMOUS_ROUTING) + link.createFile(hashedFile.filename, hashedFile.size, QString::fromStdString(hashedFile.hash)); + else + link.createExtraFile(hashedFile.filename, hashedFile.size, QString::fromStdString(hashedFile.hash),QString::fromStdString(rsPeers->getOwnId())); if (hashedFile.flag & HashedFile::Picture) { message += QString("").arg(hashedFile.filepath); diff --git a/retroshare-gui/src/gui/chat/ChatWidget.h b/retroshare-gui/src/gui/chat/ChatWidget.h index 4bcdff43d..f20c1c1f8 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.h +++ b/retroshare-gui/src/gui/chat/ChatWidget.h @@ -30,6 +30,7 @@ #include "gui/style/RSStyle.h" #include +#include class QAction; class QTextEdit; @@ -76,6 +77,7 @@ public: void addChatButton(QPushButton *button) ; bool isActive(); + void setDefaultExtraFileFlags(TransferRequestFlags f) ; private slots: void clearChatHistory(); @@ -154,6 +156,8 @@ private: bool firstShow; bool inChatCharFormatChanged; + TransferRequestFlags mDefaultExtraFileFlags ; // flags for extra files shared in this chat. Will be 0 by default, but might be ANONYMOUS for chat lobbies. + Ui::ChatWidget *ui; }; diff --git a/retroshare-gui/src/gui/common/HashBox.cpp b/retroshare-gui/src/gui/common/HashBox.cpp index 96f7197c7..8e4c39a8b 100644 --- a/retroshare-gui/src/gui/common/HashBox.cpp +++ b/retroshare-gui/src/gui/common/HashBox.cpp @@ -45,6 +45,7 @@ HashBox::HashBox(QWidget *parent) : { dropWidget = NULL; mAutoHide = false; + mDefaultTransferFlags = TransferRequestFlags(0u) ; ui->setupUi(this); } @@ -136,7 +137,7 @@ bool HashBox::eventFilter(QObject* object, QEvent* event) } } - addAttachments(files); + addAttachments(files,mDefaultTransferFlags); dropEvent->setDropAction(Qt::CopyAction); dropEvent->accept(); @@ -150,7 +151,7 @@ bool HashBox::eventFilter(QObject* object, QEvent* event) return QScrollArea::eventFilter(object, event); } -void HashBox::addAttachments(const QStringList& files, HashedFile::Flags flag) +void HashBox::addAttachments(const QStringList& files,TransferRequestFlags tfl, HashedFile::Flags flag) { /* add a AttachFileItem to the attachment section */ std::cerr << "HashBox::addExtraFile() hashing file." << std::endl; @@ -166,7 +167,7 @@ void HashBox::addAttachments(const QStringList& files, HashedFile::Flags flag) QStringList::ConstIterator it; for (it = files.constBegin(); it != files.constEnd(); ++it) { /* add widget in for new destination */ - AttachFileItem* file = new AttachFileItem(*it); + AttachFileItem* file = new AttachFileItem(*it,tfl); QObject::connect(file, SIGNAL(fileFinished(AttachFileItem*)), this, SLOT(fileFinished(AttachFileItem*))); HashingInfo hashingInfo; diff --git a/retroshare-gui/src/gui/common/HashBox.h b/retroshare-gui/src/gui/common/HashBox.h index dae09b348..d92a356a9 100644 --- a/retroshare-gui/src/gui/common/HashBox.h +++ b/retroshare-gui/src/gui/common/HashBox.h @@ -24,6 +24,7 @@ #include #include +#include namespace Ui { class HashBox; @@ -60,9 +61,10 @@ public: ~HashBox(); void setAutoHide(bool autoHide); - void addAttachments(const QStringList& files, HashedFile::Flags flag = HashedFile::NoFlag); + void addAttachments(const QStringList& files,TransferRequestFlags tfl, HashedFile::Flags flag = HashedFile::NoFlag); void setDropWidget(QWidget* widget); + void setDefaultTransferRequestFlags(TransferRequestFlags flags) { mDefaultTransferFlags = flags ; } protected: bool eventFilter(QObject *object, QEvent *event); @@ -87,6 +89,7 @@ private: bool mAutoHide; QWidget* dropWidget; Ui::HashBox *ui; + TransferRequestFlags mDefaultTransferFlags ; }; #endif // HASHBOX_H diff --git a/retroshare-gui/src/gui/feeds/AttachFileItem.cpp b/retroshare-gui/src/gui/feeds/AttachFileItem.cpp index 706efa960..2364907ef 100644 --- a/retroshare-gui/src/gui/feeds/AttachFileItem.cpp +++ b/retroshare-gui/src/gui/feeds/AttachFileItem.cpp @@ -61,8 +61,8 @@ const uint32_t AFI_DEFAULT_PERIOD = (30 * 3600 * 24); /* 30 Days */ /** Constructor */ -AttachFileItem::AttachFileItem(const std::string& hash, const QString& name, uint64_t size, uint32_t flags, const std::string& srcId) -:QWidget(NULL), mFileHash(hash), mFileName(name), mFileSize(size), mSrcId(srcId) +AttachFileItem::AttachFileItem(const std::string& hash, const QString& name, uint64_t size, uint32_t flags,TransferRequestFlags tflags, const std::string& srcId) +:QWidget(NULL), mFileHash(hash), mFileName(name), mFileSize(size), mSrcId(srcId),mFlags(tflags) { /* Invoke the Qt Designer generated object setup routine */ setupUi(this); @@ -90,8 +90,8 @@ AttachFileItem::AttachFileItem(const std::string& hash, const QString& name, uin } /** Constructor */ -AttachFileItem::AttachFileItem(const QString& path) -:QWidget(NULL), mPath(path), mFileSize(0) +AttachFileItem::AttachFileItem(const QString& path,TransferRequestFlags flags) +:QWidget(NULL), mPath(path), mFileSize(0),mFlags(flags) { /* Invoke the Qt Designer generated object setup routine */ setupUi(this); @@ -100,7 +100,7 @@ AttachFileItem::AttachFileItem(const QString& path) mType = AFI_TYPE_ATTACH; /* ask for Files to hash/prepare it for us */ - if ((!rsFiles) || (!rsFiles->ExtraFileHash(path.toUtf8().constData(), AFI_DEFAULT_PERIOD, TransferRequestFlags(0u)))) + if ((!rsFiles) || (!rsFiles->ExtraFileHash(path.toUtf8().constData(), AFI_DEFAULT_PERIOD, flags))) { mMode = AFI_STATE_ERROR; } diff --git a/retroshare-gui/src/gui/feeds/AttachFileItem.h b/retroshare-gui/src/gui/feeds/AttachFileItem.h index f15305a71..198a60da6 100644 --- a/retroshare-gui/src/gui/feeds/AttachFileItem.h +++ b/retroshare-gui/src/gui/feeds/AttachFileItem.h @@ -22,6 +22,7 @@ #ifndef _ATTACH_FILE_ITEM_DIALOG_H #define _ATTACH_FILE_ITEM_DIALOG_H +#include #include "ui_AttachFileItem.h" #include @@ -45,8 +46,8 @@ class AttachFileItem : public QWidget, private Ui::AttachFileItem public: /** Default Constructor */ - AttachFileItem(const QString& localpath); - AttachFileItem(const std::string& hash, const QString& name, uint64_t size, uint32_t flags, const std::string& srcId); + AttachFileItem(const QString& localpath,TransferRequestFlags flags); + AttachFileItem(const std::string& hash, const QString& name, uint64_t size, uint32_t flags,TransferRequestFlags tflags, const std::string& srcId); const std::string& FileHash() { return mFileHash; } const QString& FileName() { return mFileName; } @@ -75,6 +76,7 @@ private: uint32_t mMode; uint32_t mType; uint64_t mDivisor; + TransferRequestFlags mFlags ; /* for display purposes */ float amountDone; diff --git a/retroshare-gui/src/gui/forums/CreateForumMsg.cpp b/retroshare-gui/src/gui/forums/CreateForumMsg.cpp index 4cb605c80..a222daaff 100644 --- a/retroshare-gui/src/gui/forums/CreateForumMsg.cpp +++ b/retroshare-gui/src/gui/forums/CreateForumMsg.cpp @@ -209,7 +209,7 @@ void CreateForumMsg::addFile() { QStringList files; if (misc::getOpenFileNames(this, RshareSettings::LASTDIR_EXTRAFILE, tr("Add Extra File"), "", files)) { - ui.hashBox->addAttachments(files); + ui.hashBox->addAttachments(files,RS_FILE_REQ_ANONYMOUS_ROUTING); } } diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.cpp b/retroshare-gui/src/gui/msgs/MessageComposer.cpp index 156eeea09..7b393e81b 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.cpp +++ b/retroshare-gui/src/gui/msgs/MessageComposer.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include "gui/notifyqt.h" #include "gui/common/RSTreeWidgetItem.h" @@ -2196,7 +2197,7 @@ void MessageComposer::attachFile() // select a file QStringList files; if (misc::getOpenFileNames(this, RshareSettings::LASTDIR_EXTRAFILE, tr("Add Extra File"), "", files)) { - ui.hashBox->addAttachments(files); + ui.hashBox->addAttachments(files,TransferRequestFlags(0u)); } }