[win-linux] add use of provider list

This commit is contained in:
SimplestStudio
2024-05-07 10:41:12 +03:00
parent 1c601a3bc2
commit 873d0332f8
9 changed files with 181 additions and 2 deletions

View File

@ -97,6 +97,7 @@ HEADERS += \
$$PWD/src/clogger.h \
$$PWD/src/clangater.h \
$$PWD/src/cprintdata.h \
$$PWD/src/cproviders.h \
$$PWD/src/cscalingwrapper.h \
$$PWD/src/ctabundockevent.h \
$$PWD/src/ccefeventsgate.h \
@ -135,6 +136,7 @@ SOURCES += \
$$PWD/src/clogger.cpp \
$$PWD/src/clangater.cpp \
$$PWD/src/cprintdata.cpp \
$$PWD/src/cproviders.cpp \
$$PWD/src/cscalingwrapper.cpp \
$$PWD/src/ctabundockevent.cpp \
$$PWD/src/ccefeventsgate.cpp \

View File

@ -27,6 +27,7 @@
#include "ceditortools.h"
#include "cfilechecker.h"
#include "OfficeFileFormats.h"
#include "cproviders.h"
#ifdef _WIN32
# include <io.h>
@ -259,7 +260,7 @@ bool CAscApplicationManagerWrapper::processCommonEvent(NSEditorApi::CAscCefMenuE
return false;
} else
if ( cmd.compare(L"provider:list") == 0 ) {
qDebug() << "provider:list" << pData->get_Param();
CProviders::instance().init(QString::fromStdWString(pData->get_Param()));
} else
if ( cmd.compare(L"portal:login") == 0 ) {
AscAppManager::sendCommandTo(SEND_TO_ALL_START_PAGE, L"portal:login", pData->get_Param());

View File

@ -177,6 +177,7 @@ public:
opts.format = objRoot["type"].toInt();
opts.parent_id = event.m_nSenderId;
opts.name = objRoot["name"].toString();
opts.cloud = objRoot["cloud"].toString();
QRegularExpression re(rePortalName);
QRegularExpressionMatch match = re.match(opts.url);

View File

@ -31,6 +31,7 @@
*/
#include "casctabdata.h"
#include "cproviders.h"
#include <QJsonDocument>
#include <QJsonObject>
@ -129,6 +130,11 @@ void CAscTabData::setUrl(const QString& u)
setUrl(u.toStdWString());
}
void CAscTabData::setCloudName(const QString &cloud)
{
_cloud = cloud;
}
wstring CAscTabData::url() const
{
return _url;
@ -235,7 +241,7 @@ bool CAscTabData::hasFeature(const wstring& f) const
bool CAscTabData::hasFrame() const
{
return hasFeature(L"hasframe\":true");
return CProviders::instance().editorsHasFrame(QString::fromStdWString(_url), _cloud);
}
bool CAscTabData::hasError() const

View File

@ -51,6 +51,7 @@ public:
void setIsLocal(bool);
void setUrl(const std::wstring&);
void setUrl(const QString&);
void setCloudName(const QString&);
void close();
void reuse();
QString title(bool orig = false) const;
@ -85,6 +86,7 @@ private:
bool _event_load_supported = false;
std::wstring _features;
QString _str_readonly;
QString _cloud;
AscEditorType _typeContent;
};

View File

@ -319,6 +319,7 @@ namespace CEditorTools
if ( result ) {
CAscTabData * data = new CAscTabData(opts.name);
data->setUrl(opts.wurl);
data->setCloudName(opts.cloud);
data->setIsLocal( opts.srctype == etLocalFile || opts.srctype == etNewFile || opts.srctype == etTemplateFile ||
(opts.srctype == etRecentFile && !CExistanceController::isFileRemote(opts.url)) );

View File

@ -77,6 +77,7 @@ struct COpenOptions {
enum class eWidgetType {window, tab};
eWidgetType parent_widget = eWidgetType::tab;
QString cloud;
};
class CAscTabWidget : public QStackedWidget, public CScalingWrapper

View File

@ -0,0 +1,108 @@
/*
* (c) Copyright Ascensio System SIA 2010-2019
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "cproviders.h"
#include <QVector>
#include <QRegularExpression>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QJsonParseError>
struct ProviderData {
QString provider, editorPage;
bool hasFrame = false,
useRegex = false;
};
class CProviders::CProvidersPrivate
{
public:
QVector<ProviderData> m_provid_vec;
};
CProviders::CProviders() :
pimpl(new CProvidersPrivate)
{}
CProviders::~CProviders()
{
delete pimpl, pimpl = nullptr;
}
CProviders& CProviders::instance()
{
static CProviders inst;
return inst;
}
void CProviders::init(const QString &prvds_json)
{
QJsonParseError err;
QJsonDocument doc = QJsonDocument::fromJson(prvds_json.toUtf8(), &err);
if (err.error == QJsonParseError::NoError) {
const QJsonArray arr = doc.array();
for (const auto &val : arr) {
QJsonObject obj = val.toObject();
ProviderData pd;
pd.provider = obj["provider"].toString().toLower();
pd.hasFrame = obj["editorFrameSize"].toString() == "finite";
pd.editorPage = obj["editorPage"].toString();
QString reg("regex:");
int ind = pd.editorPage.indexOf(reg);
if (ind != -1) {
pd.useRegex = true;
pd.editorPage = pd.editorPage.mid(ind + reg.length());
}
pimpl->m_provid_vec.push_back(std::move(pd));
}
}
}
bool CProviders::editorsHasFrame(const QString &url, const QString &cloud)
{
foreach (const auto &pd, pimpl->m_provid_vec) {
if (!pd.provider.isEmpty() && pd.provider == cloud)
return pd.hasFrame;
if (!pd.editorPage.isEmpty()) {
if (pd.useRegex) {
QRegularExpression rgx(pd.editorPage, QRegularExpression::CaseInsensitiveOption);
if (rgx.match(url).hasMatch())
return pd.hasFrame;
} else
if (url.indexOf(pd.editorPage) != -1)
return pd.hasFrame;
}
}
return false;
}

View File

@ -0,0 +1,57 @@
/*
* (c) Copyright Ascensio System SIA 2010-2019
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#ifndef CPROVIDERS_H
#define CPROVIDERS_H
#include <QString>
class CProviders
{
public:
CProviders(const CProviders&) = delete;
CProviders& operator=(const CProviders&) = delete;
static CProviders& instance();
void init(const QString &prvds_json);
bool editorsHasFrame(const QString &url, const QString &cloud);
private:
CProviders();
~CProviders();
class CProvidersPrivate;
CProvidersPrivate *pimpl = nullptr;
};
#endif // CPROVIDERS_H