mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-05 21:04:14 -04: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
12 changed files with 57 additions and 25 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue