slotAccountStateAdded(ai);
}
- connect(FolderMan::instance()->socketApi(), SIGNAL(shareCommandReceived(QString, QString)),
- _gui, SLOT(slotShowShareDialog(QString, QString)));
+ connect(FolderMan::instance()->socketApi(), SIGNAL(shareCommandReceived(QString, QString, bool)),
+ _gui, SLOT(slotShowShareDialog(QString, QString, bool)));
// startup procedure.
connect(&_checkConnectionTimer, SIGNAL(timeout()), this, SLOT(slotCheckConnection()));
}
-void ownCloudGui::slotShowShareDialog(const QString &sharePath, const QString &localPath)
+void ownCloudGui::slotShowShareDialog(const QString &sharePath, const QString &localPath, bool resharingAllowed)
{
AccountPtr account = AccountManager::instance()->account();
if (!account) {
}
qDebug() << Q_FUNC_INFO << "Opening share dialog";
- ShareDialog *w = new ShareDialog(account, sharePath, localPath);
+ ShareDialog *w = new ShareDialog(account, sharePath, localPath, resharingAllowed);
w->getShares();
w->setAttribute( Qt::WA_DeleteOnClose, true );
raiseDialog(w);
void slotHelp();
void slotOpenPath(const QString& path);
void slotAccountStateChanged();
- void slotShowShareDialog(const QString &sharePath, const QString &localPath);
+ void slotShowShareDialog(const QString &sharePath, const QString &localPath, bool resharingAllowed);
private slots:
void slotDisplayIdle();
namespace OCC {
-ShareDialog::ShareDialog(AccountPtr account, const QString &sharePath, const QString &localPath, QWidget *parent) :
+ShareDialog::ShareDialog(AccountPtr account, const QString &sharePath, const QString &localPath, bool resharingAllowed, QWidget *parent) :
QDialog(parent),
_ui(new Ui::ShareDialog),
_account(account),
_sharePath(sharePath),
_localPath(localPath),
_passwordJobRunning(false),
- _public_share_id(0)
+ _public_share_id(0),
+ _resharingAllowed(resharingAllowed)
{
setAttribute(Qt::WA_DeleteOnClose);
_ui->setupUi(this);
if( _shares.count()>0 ) {
setShareCheckBoxTitle(true);
} else {
- // check the checkbox to create a link.
- _ui->checkBox_shareLink->setChecked(true);
- slotCheckBoxShareLinkClicked();
+ // If there are no shares yet, check the checkbox to create a link automatically.
+ // If its clear that resharing is not allowed, display an error
+ if( !_resharingAllowed ) {
+ displayError(tr("The file can not be shared because it was shared without sharing permission."));
+ _ui->checkBox_shareLink->setEnabled(false);
+ } else {
+ _ui->checkBox_shareLink->setChecked(true);
+ slotCheckBoxShareLinkClicked();
+ }
}
}
}
-void ShareDialog::displayError(int code)
+void ShareDialog::displayError(const QString& errMsg)
{
- const QString errMsg = tr("OCS API error code: %1").arg(code);
_ui->errorLabel->setText( errMsg );
_ui->errorLabel->show();
}
+void ShareDialog::displayError(int code)
+{
+ const QString errMsg = tr("OCS API error code: %1").arg(code);
+ displayError(errMsg);
+}
+
+#if 0
void ShareDialog::displayInfo( const QString& msg )
{
_ui->label_sharePath->setText(msg);
}
-#if 0
/*
* This code is disabled for now as we do not have answers for all the questions involved
* here, see https://github.com/owncloud/client/issues/2732
Q_OBJECT
public:
- explicit ShareDialog(AccountPtr account, const QString &sharePath, const QString &localPath, QWidget *parent = 0);
+ explicit ShareDialog(AccountPtr account, const QString &sharePath, const QString &localPath,
+ bool resharingAllowed, QWidget *parent = 0);
~ShareDialog();
void getShares();
private:
void setShareCheckBoxTitle(bool haveShares);
void displayError(int code);
- void displayInfo( const QString& msg );
+ void displayError(const QString& errMsg);
void setShareLink( const QString& url );
Ui::ShareDialog *_ui;
QProgressIndicator *_pi_password;
QProgressIndicator *_pi_date;
+ bool _resharingAllowed;
};
}
// files that are not within a sync folder are not synced.
sendMessage(socket, message);
} else {
+ const QString folderForPath = shareFolder->path();
+ const QString remotePath = shareFolder->remotePath() + localFile.right(localFile.count()-folderForPath.count()+1);
+
+ SyncJournalFileRecord rec = dbFileRecord_capi(shareFolder, localFile);
+
+ bool allowReshare = true; // lets assume the good
+ if( rec.isValid() ) {
+ // check the permission: Is resharing allowed?
+ if( !rec._remotePerm.contains('R') ) {
+ allowReshare = false;
+ }
+ }
const QString message = QLatin1String("SHARE:OK:")+QDir::toNativeSeparators(localFile);
sendMessage(socket, message);
- const QString folderForPath = shareFolder->path();
- const QString remotePath = shareFolder->remotePath() + localFile.right(localFile.count()-folderForPath.count()+1);
- emit shareCommandReceived(remotePath, localFile);
+ emit shareCommandReceived(remotePath, localFile, allowReshare);
}
}
void slotClearExcludesList();
signals:
- void shareCommandReceived(const QString &sharePath, const QString &localPath);
+ void shareCommandReceived(const QString &sharePath, const QString &localPath, bool resharingAllowed);
private slots:
void slotNewConnection();