mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Add support license
This commit is contained in:
@ -33,6 +33,7 @@
|
|||||||
#define DOC_BUILDER_ADDON_PRIVATE
|
#define DOC_BUILDER_ADDON_PRIVATE
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include "../docbuilder.h"
|
||||||
|
|
||||||
namespace NSDoctRenderer
|
namespace NSDoctRenderer
|
||||||
{
|
{
|
||||||
@ -46,11 +47,11 @@ namespace NSDoctRenderer
|
|||||||
m_sWorkDirectory = sWorkDir;
|
m_sWorkDirectory = sWorkDir;
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
std::wstring GetX2tSaveAddon()
|
std::wstring GetX2tSaveAddon(NSDoctRenderer::CDocBuilder* builder, const int& filetype)
|
||||||
{
|
{
|
||||||
return L"";
|
return L"";
|
||||||
}
|
}
|
||||||
int GetX2tPreSaveError()
|
int GetX2tPreSaveError(NSDoctRenderer::CDocBuilder* builder, const int& filetype)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,6 +33,7 @@
|
|||||||
#include "./../common_deploy.h"
|
#include "./../common_deploy.h"
|
||||||
#include "../docbuilder.h"
|
#include "../docbuilder.h"
|
||||||
#include "../../common/File.h"
|
#include "../../common/File.h"
|
||||||
|
#include "../../common/SystemUtils.h"
|
||||||
|
|
||||||
#ifdef LINUX
|
#ifdef LINUX
|
||||||
#include "../../../DesktopEditor/common/File.h"
|
#include "../../../DesktopEditor/common/File.h"
|
||||||
@ -78,6 +79,13 @@ void parse_args(NSDoctRenderer::CDocBuilder* builder, int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CheckLicense(const std::wstring& sSrc, const std::wstring& sDst)
|
||||||
|
{
|
||||||
|
NSFile::CFileBinary::Remove(sDst);
|
||||||
|
NSFile::CFileBinary::Copy(sSrc, sDst);
|
||||||
|
return NSFile::CFileBinary::Exists(sDst);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
int wmain(int argc, wchar_t *argv[])
|
int wmain(int argc, wchar_t *argv[])
|
||||||
#else
|
#else
|
||||||
@ -89,6 +97,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
bool bIsHelp = false;
|
bool bIsHelp = false;
|
||||||
bool bIsFonts = false;
|
bool bIsFonts = false;
|
||||||
|
bool bIsLicense = false;
|
||||||
for (int i = 0; i < argc; ++i)
|
for (int i = 0; i < argc; ++i)
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
@ -121,6 +130,33 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
bIsFonts = true;
|
bIsFonts = true;
|
||||||
}
|
}
|
||||||
|
else if (sParam == "-register")
|
||||||
|
{
|
||||||
|
bIsLicense = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (bIsLicense)
|
||||||
|
{
|
||||||
|
std::wstring sLicensePathSrc = UTF8_TO_U(sParam);
|
||||||
|
if (!NSFile::CFileBinary::Exists(sLicensePathSrc))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
std::wstring sLicensePath = NSSystemUtils::GetEnvVariable(L"ONLYOFFICE_BUILDER_LICENSE");
|
||||||
|
if (CheckLicense(sLicensePathSrc, sLicensePath))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
sLicensePath = NSFile::GetProcessDirectory() + L"/license.xml";
|
||||||
|
if (CheckLicense(sLicensePathSrc, sLicensePath))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
sLicensePath = NSSystemUtils::GetAppDataDir() + L"/docbuilder/license.xml";
|
||||||
|
if (CheckLicense(sLicensePathSrc, sLicensePath))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bIsFonts)
|
if (bIsFonts)
|
||||||
|
|||||||
@ -612,4 +612,10 @@ builder_path = os.path.dirname(os.path.realpath(__file__))
|
|||||||
_loadLibrary(builder_path)
|
_loadLibrary(builder_path)
|
||||||
CDocBuilder.Initialize(builder_path)
|
CDocBuilder.Initialize(builder_path)
|
||||||
|
|
||||||
|
def registerLibrary(license_path):
|
||||||
|
docbuilder_bin = os.path.dirname(os.path.realpath(__file__)) + os.pathsep + "docbuilder"
|
||||||
|
if ("windows" == platform.system().lower()):
|
||||||
|
docbuilder_bin += ".exe"
|
||||||
|
return subprocess.call([docbuilder_bin, license_path], stderr=subprocess.STDOUT, shell=True)
|
||||||
|
|
||||||
atexit.register(CDocBuilder.Dispose)
|
atexit.register(CDocBuilder.Dispose)
|
||||||
|
|||||||
@ -1003,7 +1003,7 @@ namespace NSDoctRenderer
|
|||||||
|
|
||||||
CDocBuilderAddon oSaveAddon(m_sX2tPath);
|
CDocBuilderAddon oSaveAddon(m_sX2tPath);
|
||||||
|
|
||||||
int nPreSaveError = oSaveAddon.GetX2tPreSaveError();
|
int nPreSaveError = oSaveAddon.GetX2tPreSaveError(m_pParent, m_nFileType);
|
||||||
if (0 != nPreSaveError)
|
if (0 != nPreSaveError)
|
||||||
return nPreSaveError;
|
return nPreSaveError;
|
||||||
|
|
||||||
@ -1090,7 +1090,7 @@ namespace NSDoctRenderer
|
|||||||
if (!sOptions.empty())
|
if (!sOptions.empty())
|
||||||
oBuilder.WriteString(UTF8_TO_U(sOptions));
|
oBuilder.WriteString(UTF8_TO_U(sOptions));
|
||||||
|
|
||||||
oBuilder.WriteString(oSaveAddon.GetX2tSaveAddon());
|
oBuilder.WriteString(oSaveAddon.GetX2tSaveAddon(m_pParent, m_nFileType));
|
||||||
|
|
||||||
oBuilder.WriteString(L"</TaskQueueDataConvert>");
|
oBuilder.WriteString(L"</TaskQueueDataConvert>");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user