Comparar commits

...

1 Commits

Autor SHA1 Mensagem Data
Roeland Jago Douma b6dd13f353 First step in getting share by email to work 2016-06-01 15:02:13 +02:00
8 arquivos alterados com 194 adições e 0 exclusões
+1
Ver Arquivo
@@ -72,6 +72,7 @@ set(client_SRCS
settingsdialog.cpp
share.cpp
sharedialog.cpp
shareemailwidget.cpp
sharelinkwidget.cpp
shareusergroupwidget.cpp
sharee.cpp
+2
Ver Arquivo
@@ -179,6 +179,8 @@ Application::Application(int &argc, char **argv) :
connect(FolderMan::instance()->socketApi(), SIGNAL(shareCommandReceived(QString, QString, bool)),
_gui, SLOT(slotShowShareDialog(QString, QString, bool)));
connect(FolderMan::instance()->socketApi(), SIGNAL(shareEmailCommandReceived(QString,QString,bool)),
_gui, SLOT(slowSendShareLink(QString, QString, bool)));
// startup procedure.
connect(&_checkConnectionTimer, SIGNAL(timeout()), this, SLOT(slotCheckConnection()));
+23
Ver Arquivo
@@ -20,6 +20,7 @@
#include "progressdispatcher.h"
#include "owncloudsetupwizard.h"
#include "sharedialog.h"
#include "shareemailwidget.h"
#if defined(Q_OS_MAC)
# include "settingsdialogmac.h"
# include "macwindow.h" // qtmacgoodies
@@ -911,5 +912,27 @@ void ownCloudGui::slotRemoveDestroyedShareDialogs()
}
}
void ownCloudGui::slowSendShareLink(const QString &sharePath, const QString &localPath, bool resharingAllowed)
{
const auto folder = FolderMan::instance()->folderForPath(localPath);
if (!folder) {
qDebug() << "Could not open share email widget for" << localPath << "no responsible folder found";
return;
}
// For https://github.com/owncloud/client/issues/3783
_settingsDialog->hide();
if (!resharingAllowed) {
qDebug() << "Could not open share email widget for" << localPath << "no reshare permissions";
return;
}
qDebug() << Q_FUNC_INFO << "Opening share email widget" << sharePath << localPath;
ShareEmailWidget *w = new ShareEmailWidget(folder->accountState()->account(), sharePath);
w->setAttribute( Qt::WA_DeleteOnClose, true );
raiseDialog(w);
}
} // end namespace
+1
Ver Arquivo
@@ -79,6 +79,7 @@ public slots:
void slotTrayMessageIfServerUnsupported(Account *account);
void slotShowShareDialog(const QString &sharePath, const QString &localPath, bool resharingAllowed);
void slotRemoveDestroyedShareDialogs();
void slowSendShareLink(const QString &sharePath, const QString &localPath, bool resharingAllowed);
private slots:
void slotDisplayIdle();
+59
Ver Arquivo
@@ -0,0 +1,59 @@
#include "shareemailwidget.h"
#include "share.h"
#include <QDesktopServices>
#include <QSharedPointer>
#include <QUrl>
namespace OCC {
ShareEmailWidget::ShareEmailWidget(AccountPtr account,
const QString &sharePath,
QWidget *parent)
: QWidget(parent),
_account(account),
_sharePath(sharePath)
{
resize(200,200);
_layout.addWidget(&_spinner);
_layout.addWidget(&_label);
_label.setText(tr("Fetching share link"));
_spinner.startAnimation();
setLayout(&_layout);
/*
* Create the share manager and connect it properly
*/
_manager = new ShareManager(_account, this);
connect(_manager, SIGNAL(linkShareCreated(QSharedPointer<LinkShare>)), this, SLOT(slotLinkShareCreated(QSharedPointer<LinkShare>)));
_manager->createLinkShare(_sharePath);
}
ShareEmailWidget::~ShareEmailWidget()
{
}
void ShareEmailWidget::slotLinkShareCreated(const QSharedPointer<LinkShare> share)
{
QUrl mailto("mailto:");
QString body = tr("I shared a file with you at %1.").arg(share->getLink().toString());
if (share->getExpireDate().isValid()) {
body += tr("\nThis share expires at %1.").arg(share->getExpireDate().toString());
}
mailto.setQuery("body?"+body);
// Open app
QDesktopServices::openUrl(mailto);
close();
}
}
+46
Ver Arquivo
@@ -0,0 +1,46 @@
#ifndef SHAREEMAILDIALOG_H
#define SHAREEMAILDIALOG_H
#include "accountfwd.h"
#include "QProgressIndicator.h"
#include "share.h"
#include <QHBoxLayout>
#include <QLabel>
#include <QSharedPointer>
#include <QString>
#include <QWidget>
namespace OCC {
class ShareManager;
class ShareEmailWidget : public QWidget
{
public:
explicit ShareEmailWidget(AccountPtr account,
const QString &sharePath,
QWidget *parent = 0);
~ShareEmailWidget();
private slots:
void slotLinkShareCreated(const QSharedPointer<LinkShare> share);
void slotPasswordEnterd();
void slotPasswordRequired();
private:
void share(const QString &sharePath, const QString &password);
AccountPtr _account;
QString _sharePath;
QHBoxLayout _layout;
QLabel _label;
QProgressIndicator _spinner;
ShareManager *_manager;
};
}
#endif // SHAREEMAILDIALOG_H
+60
Ver Arquivo
@@ -453,6 +453,66 @@ void SocketApi::command_SHARE_MENU_TITLE(const QString &, QIODevice* socket)
sendMessage(socket, QLatin1String("SHARE_MENU_TITLE:") + tr("Share with %1", "parameter is ownCloud").arg(Theme::instance()->appNameGUI()));
}
void SocketApi::command_SHARE_EMAIL(const QString& localFile, QIODevice* socket)
{
if (!socket) {
qDebug() << Q_FUNC_INFO << "No valid socket object.";
return;
}
qDebug() << Q_FUNC_INFO << localFile;
auto theme = Theme::instance();
Folder *shareFolder = FolderMan::instance()->folderForPath(localFile);
if (!shareFolder) {
const QString message = QLatin1String("SHARE_EMAIL:NOP:")+QDir::toNativeSeparators(localFile);
// files that are not within a sync folder are not synced.
sendMessage(socket, message);
} else if (!shareFolder->accountState()->isConnected()) {
const QString message = QLatin1String("SHARE_EMAIL:NOTCONNECTED:")+QDir::toNativeSeparators(localFile);
// if the folder isn't connected, don't open the share dialog
sendMessage(socket, message);
} else if (!theme->linkSharing()) {
const QString message = QLatin1String("SHARE_EMAIL:NOP:")+QDir::toNativeSeparators(localFile);
sendMessage(socket, message);
} else {
const QString localFileClean = QDir::cleanPath(localFile);
const QString file = localFileClean.mid(shareFolder->cleanPath().length()+1);
SyncFileStatus fileStatus = shareFolder->syncEngine().syncFileStatusTracker().fileStatus(file);
// Verify the file is on the server (to our knowledge of course)
if (fileStatus.tag() != SyncFileStatus::StatusUpToDate) {
const QString message = QLatin1String("SHARE:NOTSYNCED:")+QDir::toNativeSeparators(localFile);
sendMessage(socket, message);
return;
}
const QString remotePath = QDir(shareFolder->remotePath()).filePath(file);
// Can't share root folder
if (remotePath == "/") {
const QString message = QLatin1String("SHARE_EMAIL:CANNOTSHAREROOT:")+QDir::toNativeSeparators(localFile);
sendMessage(socket, message);
return;
}
SyncJournalFileRecord rec = shareFolder->journalDb()->getFileRecord(localFileClean);
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_EMAIL:OK:")+QDir::toNativeSeparators(localFile);
sendMessage(socket, message);
emit shareEmailCommandReceived(remotePath, localFileClean, allowReshare);
}
}
QString SocketApi::buildRegisterPathMessage(const QString& path)
{
QFileInfo fi(path);
+2
Ver Arquivo
@@ -56,6 +56,7 @@ public slots:
signals:
void shareCommandReceived(const QString &sharePath, const QString &localPath, bool resharingAllowed);
void shareUserGroupCommandReceived(const QString &sharePath, const QString &localPath, bool resharingAllowed);
void shareEmailCommandReceived(const QString &sharePath, const QString &localPath, bool resharingAllowed);
private slots:
void slotNewConnection();
@@ -70,6 +71,7 @@ private:
Q_INVOKABLE void command_RETRIEVE_FOLDER_STATUS(const QString& argument, QIODevice* socket);
Q_INVOKABLE void command_RETRIEVE_FILE_STATUS(const QString& argument, QIODevice* socket);
Q_INVOKABLE void command_SHARE(const QString& localFile, QIODevice* socket);
Q_INVOKABLE void command_SHARE_EMAIL(const QString& localFile, QIODevice* socket);
Q_INVOKABLE void command_VERSION(const QString& argument, QIODevice* socket);