mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-28 08:59:37 -05:00
fixed permission of drap+dropped files. all attached files get added to extra list, but with different permission flags depending on the client. From that, we compute sharing permissions : turtle, or direct transfer only
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5808 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
9000cf9034
commit
f61a50c5a6
@ -27,6 +27,8 @@
|
||||
#include "util/rswin.h"
|
||||
#endif
|
||||
|
||||
#include <retroshare/rstypes.h>
|
||||
#include <retroshare/rsfiles.h>
|
||||
#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<RsItem *>& 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<RsItem *>& 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;
|
||||
|
@ -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 */
|
||||
|
@ -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<HashedFile> 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 += "<BR>";
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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<HashedFile> 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("<img src=\"file:///%1\" width=\"100\" height=\"100\">").arg(hashedFile.filepath);
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "gui/style/RSStyle.h"
|
||||
|
||||
#include <retroshare/rsmsgs.h>
|
||||
#include <retroshare/rsfiles.h>
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include <QScrollArea>
|
||||
#include <stdint.h>
|
||||
#include <retroshare/rsfiles.h>
|
||||
|
||||
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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
#ifndef _ATTACH_FILE_ITEM_DIALOG_H
|
||||
#define _ATTACH_FILE_ITEM_DIALOG_H
|
||||
|
||||
#include <retroshare/rsfiles.h>
|
||||
#include "ui_AttachFileItem.h"
|
||||
#include <stdint.h>
|
||||
|
||||
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <retroshare/rsmsgs.h>
|
||||
#include <retroshare/rsstatus.h>
|
||||
#include <retroshare/rsfiles.h>
|
||||
|
||||
#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));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user