mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-29 01:16:20 -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"
|
#include "util/rswin.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <retroshare/rstypes.h>
|
||||||
|
#include <retroshare/rsfiles.h>
|
||||||
#include "ft/ftextralist.h"
|
#include "ft/ftextralist.h"
|
||||||
#include "serialiser/rsconfigitems.h"
|
#include "serialiser/rsconfigitems.h"
|
||||||
#include "util/rsdir.h"
|
#include "util/rsdir.h"
|
||||||
@ -167,7 +169,7 @@ bool ftExtraList::addExtraFile(std::string path, std::string hash,
|
|||||||
details.info.hash = hash;
|
details.info.hash = hash;
|
||||||
details.info.size = size;
|
details.info.size = size;
|
||||||
details.info.age = time(NULL) + period; /* if time > this... cleanup */
|
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 */
|
/* stick it in the available queue */
|
||||||
mFiles[details.info.hash] = details;
|
mFiles[details.info.hash] = details;
|
||||||
@ -263,7 +265,7 @@ bool ftExtraList::cleanupOldFiles()
|
|||||||
{
|
{
|
||||||
if (mFiles.end() != (it = mFiles.find(*rit)))
|
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);
|
mFiles.erase(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -349,6 +351,13 @@ bool ftExtraList::search(const std::string &hash, FileSearchFlags /*hintflags
|
|||||||
}
|
}
|
||||||
|
|
||||||
info = fit->second.info;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -396,7 +405,7 @@ bool ftExtraList::saveList(bool &cleanup, std::list<RsItem *>& sList)
|
|||||||
fi->file.hash = (it->second).info.hash;
|
fi->file.hash = (it->second).info.hash;
|
||||||
fi->file.filesize = (it->second).info.size;
|
fi->file.filesize = (it->second).info.size;
|
||||||
fi->file.age = (it->second).info.age;
|
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);
|
sList.push_back(fi);
|
||||||
}
|
}
|
||||||
@ -461,7 +470,7 @@ bool ftExtraList::loadList(std::list<RsItem *>& load)
|
|||||||
details.info.hash = fi->file.hash;
|
details.info.hash = fi->file.hash;
|
||||||
details.info.size = fi->file.filesize;
|
details.info.size = fi->file.filesize;
|
||||||
details.info.age = fi->file.age; /* time that we remove it. */
|
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 */
|
/* stick it in the available queue */
|
||||||
mFiles[details.info.hash] = details;
|
mFiles[details.info.hash] = details;
|
||||||
|
@ -74,14 +74,14 @@ class FileDetails
|
|||||||
{
|
{
|
||||||
info.path = path;
|
info.path = path;
|
||||||
period = p;
|
period = p;
|
||||||
flags = f;
|
info.transfer_info_flags = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileDetails(FileInfo &i, uint32_t p, TransferRequestFlags f)
|
FileDetails(FileInfo &i, uint32_t p, TransferRequestFlags f)
|
||||||
{
|
{
|
||||||
info = i;
|
info = i;
|
||||||
period = p;
|
period = p;
|
||||||
flags = f;
|
info.transfer_info_flags = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileInfo info;
|
FileInfo info;
|
||||||
@ -96,7 +96,7 @@ class FileDetails
|
|||||||
|
|
||||||
uint32_t start;
|
uint32_t start;
|
||||||
uint32_t period;
|
uint32_t period;
|
||||||
TransferRequestFlags flags;
|
//TransferRequestFlags flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
const uint32_t FT_DETAILS_CLEANUP = 0x0100; /* remove when it expires */
|
const uint32_t FT_DETAILS_CLEANUP = 0x0100; /* remove when it expires */
|
||||||
|
@ -761,7 +761,7 @@ void FriendsDialog::addExtraFile()
|
|||||||
{
|
{
|
||||||
QStringList files;
|
QStringList files;
|
||||||
if (misc::getOpenFileNames(this, RshareSettings::LASTDIR_EXTRAFILE, tr("Add Extra File"), "", 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) {
|
for (it = hashedFiles.begin(); it != hashedFiles.end(); ++it) {
|
||||||
HashedFile& hashedFile = *it;
|
HashedFile& hashedFile = *it;
|
||||||
RetroShareLink link;
|
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;
|
continue;
|
||||||
}
|
|
||||||
mesgString += link.toHtmlSize();
|
mesgString += link.toHtmlSize();
|
||||||
if (it!= hashedFiles.end()) {
|
if (it!= hashedFiles.end()) {
|
||||||
mesgString += "<BR>";
|
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->setName(QString::fromUtf8(nickName.c_str()));
|
||||||
|
|
||||||
ui.chatWidget->addToolsAction(ui.actionChangeNickname);
|
ui.chatWidget->addToolsAction(ui.actionChangeNickname);
|
||||||
|
ui.chatWidget->setDefaultExtraFileFlags(RS_FILE_REQ_ANONYMOUS_ROUTING);
|
||||||
|
|
||||||
lastUpdateListTime = 0;
|
lastUpdateListTime = 0;
|
||||||
|
|
||||||
|
@ -133,6 +133,12 @@ ChatWidget::~ChatWidget()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChatWidget::setDefaultExtraFileFlags(TransferRequestFlags fl)
|
||||||
|
{
|
||||||
|
mDefaultExtraFileFlags = fl ;
|
||||||
|
ui->hashBox->setDefaultTransferRequestFlags(fl) ;
|
||||||
|
}
|
||||||
|
|
||||||
void ChatWidget::addChatButton(QPushButton *button)
|
void ChatWidget::addChatButton(QPushButton *button)
|
||||||
{
|
{
|
||||||
ui->toolBarFrame->layout()->addWidget(button) ;
|
ui->toolBarFrame->layout()->addWidget(button) ;
|
||||||
@ -600,7 +606,7 @@ void ChatWidget::addExtraFile()
|
|||||||
{
|
{
|
||||||
QStringList files;
|
QStringList files;
|
||||||
if (misc::getOpenFileNames(this, RshareSettings::LASTDIR_EXTRAFILE, tr("Add Extra File"), "", 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();
|
QString ext = QFileInfo(hashedFile.filename).suffix();
|
||||||
|
|
||||||
RetroShareLink link;
|
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) {
|
if (hashedFile.flag & HashedFile::Picture) {
|
||||||
message += QString("<img src=\"file:///%1\" width=\"100\" height=\"100\">").arg(hashedFile.filepath);
|
message += QString("<img src=\"file:///%1\" width=\"100\" height=\"100\">").arg(hashedFile.filepath);
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include "gui/style/RSStyle.h"
|
#include "gui/style/RSStyle.h"
|
||||||
|
|
||||||
#include <retroshare/rsmsgs.h>
|
#include <retroshare/rsmsgs.h>
|
||||||
|
#include <retroshare/rsfiles.h>
|
||||||
|
|
||||||
class QAction;
|
class QAction;
|
||||||
class QTextEdit;
|
class QTextEdit;
|
||||||
@ -76,6 +77,7 @@ public:
|
|||||||
void addChatButton(QPushButton *button) ;
|
void addChatButton(QPushButton *button) ;
|
||||||
|
|
||||||
bool isActive();
|
bool isActive();
|
||||||
|
void setDefaultExtraFileFlags(TransferRequestFlags f) ;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void clearChatHistory();
|
void clearChatHistory();
|
||||||
@ -154,6 +156,8 @@ private:
|
|||||||
bool firstShow;
|
bool firstShow;
|
||||||
bool inChatCharFormatChanged;
|
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;
|
Ui::ChatWidget *ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -45,6 +45,7 @@ HashBox::HashBox(QWidget *parent) :
|
|||||||
{
|
{
|
||||||
dropWidget = NULL;
|
dropWidget = NULL;
|
||||||
mAutoHide = false;
|
mAutoHide = false;
|
||||||
|
mDefaultTransferFlags = TransferRequestFlags(0u) ;
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
}
|
}
|
||||||
@ -136,7 +137,7 @@ bool HashBox::eventFilter(QObject* object, QEvent* event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addAttachments(files);
|
addAttachments(files,mDefaultTransferFlags);
|
||||||
|
|
||||||
dropEvent->setDropAction(Qt::CopyAction);
|
dropEvent->setDropAction(Qt::CopyAction);
|
||||||
dropEvent->accept();
|
dropEvent->accept();
|
||||||
@ -150,7 +151,7 @@ bool HashBox::eventFilter(QObject* object, QEvent* event)
|
|||||||
return QScrollArea::eventFilter(object, 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 */
|
/* add a AttachFileItem to the attachment section */
|
||||||
std::cerr << "HashBox::addExtraFile() hashing file." << std::endl;
|
std::cerr << "HashBox::addExtraFile() hashing file." << std::endl;
|
||||||
@ -166,7 +167,7 @@ void HashBox::addAttachments(const QStringList& files, HashedFile::Flags flag)
|
|||||||
QStringList::ConstIterator it;
|
QStringList::ConstIterator it;
|
||||||
for (it = files.constBegin(); it != files.constEnd(); ++it) {
|
for (it = files.constBegin(); it != files.constEnd(); ++it) {
|
||||||
/* add widget in for new destination */
|
/* 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*)));
|
QObject::connect(file, SIGNAL(fileFinished(AttachFileItem*)), this, SLOT(fileFinished(AttachFileItem*)));
|
||||||
|
|
||||||
HashingInfo hashingInfo;
|
HashingInfo hashingInfo;
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include <QScrollArea>
|
#include <QScrollArea>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <retroshare/rsfiles.h>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class HashBox;
|
class HashBox;
|
||||||
@ -60,9 +61,10 @@ public:
|
|||||||
~HashBox();
|
~HashBox();
|
||||||
|
|
||||||
void setAutoHide(bool autoHide);
|
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 setDropWidget(QWidget* widget);
|
||||||
|
void setDefaultTransferRequestFlags(TransferRequestFlags flags) { mDefaultTransferFlags = flags ; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *object, QEvent *event);
|
bool eventFilter(QObject *object, QEvent *event);
|
||||||
@ -87,6 +89,7 @@ private:
|
|||||||
bool mAutoHide;
|
bool mAutoHide;
|
||||||
QWidget* dropWidget;
|
QWidget* dropWidget;
|
||||||
Ui::HashBox *ui;
|
Ui::HashBox *ui;
|
||||||
|
TransferRequestFlags mDefaultTransferFlags ;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // HASHBOX_H
|
#endif // HASHBOX_H
|
||||||
|
@ -61,8 +61,8 @@
|
|||||||
const uint32_t AFI_DEFAULT_PERIOD = (30 * 3600 * 24); /* 30 Days */
|
const uint32_t AFI_DEFAULT_PERIOD = (30 * 3600 * 24); /* 30 Days */
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
AttachFileItem::AttachFileItem(const std::string& hash, const QString& name, uint64_t size, uint32_t flags, const std::string& 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)
|
:QWidget(NULL), mFileHash(hash), mFileName(name), mFileSize(size), mSrcId(srcId),mFlags(tflags)
|
||||||
{
|
{
|
||||||
/* Invoke the Qt Designer generated object setup routine */
|
/* Invoke the Qt Designer generated object setup routine */
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
@ -90,8 +90,8 @@ AttachFileItem::AttachFileItem(const std::string& hash, const QString& name, uin
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
AttachFileItem::AttachFileItem(const QString& path)
|
AttachFileItem::AttachFileItem(const QString& path,TransferRequestFlags flags)
|
||||||
:QWidget(NULL), mPath(path), mFileSize(0)
|
:QWidget(NULL), mPath(path), mFileSize(0),mFlags(flags)
|
||||||
{
|
{
|
||||||
/* Invoke the Qt Designer generated object setup routine */
|
/* Invoke the Qt Designer generated object setup routine */
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
@ -100,7 +100,7 @@ AttachFileItem::AttachFileItem(const QString& path)
|
|||||||
mType = AFI_TYPE_ATTACH;
|
mType = AFI_TYPE_ATTACH;
|
||||||
|
|
||||||
/* ask for Files to hash/prepare it for us */
|
/* 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;
|
mMode = AFI_STATE_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#ifndef _ATTACH_FILE_ITEM_DIALOG_H
|
#ifndef _ATTACH_FILE_ITEM_DIALOG_H
|
||||||
#define _ATTACH_FILE_ITEM_DIALOG_H
|
#define _ATTACH_FILE_ITEM_DIALOG_H
|
||||||
|
|
||||||
|
#include <retroshare/rsfiles.h>
|
||||||
#include "ui_AttachFileItem.h"
|
#include "ui_AttachFileItem.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
@ -45,8 +46,8 @@ class AttachFileItem : public QWidget, private Ui::AttachFileItem
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
/** Default Constructor */
|
/** Default Constructor */
|
||||||
AttachFileItem(const QString& localpath);
|
AttachFileItem(const QString& localpath,TransferRequestFlags flags);
|
||||||
AttachFileItem(const std::string& hash, const QString& name, uint64_t size, uint32_t flags, const std::string& srcId);
|
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 std::string& FileHash() { return mFileHash; }
|
||||||
const QString& FileName() { return mFileName; }
|
const QString& FileName() { return mFileName; }
|
||||||
@ -75,6 +76,7 @@ private:
|
|||||||
uint32_t mMode;
|
uint32_t mMode;
|
||||||
uint32_t mType;
|
uint32_t mType;
|
||||||
uint64_t mDivisor;
|
uint64_t mDivisor;
|
||||||
|
TransferRequestFlags mFlags ;
|
||||||
|
|
||||||
/* for display purposes */
|
/* for display purposes */
|
||||||
float amountDone;
|
float amountDone;
|
||||||
|
@ -209,7 +209,7 @@ void CreateForumMsg::addFile()
|
|||||||
{
|
{
|
||||||
QStringList files;
|
QStringList files;
|
||||||
if (misc::getOpenFileNames(this, RshareSettings::LASTDIR_EXTRAFILE, tr("Add Extra File"), "", 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/rspeers.h>
|
||||||
#include <retroshare/rsmsgs.h>
|
#include <retroshare/rsmsgs.h>
|
||||||
#include <retroshare/rsstatus.h>
|
#include <retroshare/rsstatus.h>
|
||||||
|
#include <retroshare/rsfiles.h>
|
||||||
|
|
||||||
#include "gui/notifyqt.h"
|
#include "gui/notifyqt.h"
|
||||||
#include "gui/common/RSTreeWidgetItem.h"
|
#include "gui/common/RSTreeWidgetItem.h"
|
||||||
@ -2196,7 +2197,7 @@ void MessageComposer::attachFile()
|
|||||||
// select a file
|
// select a file
|
||||||
QStringList files;
|
QStringList files;
|
||||||
if (misc::getOpenFileNames(this, RshareSettings::LASTDIR_EXTRAFILE, tr("Add Extra File"), "", 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