Skip to content

Commit d2ea952

Browse files
committed
Add support license
1 parent 06f8099 commit d2ea952

File tree

4 files changed

+47
-4
lines changed

4 files changed

+47
-4
lines changed

DesktopEditor/doctrenderer/addon/docbuilder_addon.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#define DOC_BUILDER_ADDON_PRIVATE
3434

3535
#include <string>
36+
#include "../docbuilder.h"
3637

3738
namespace NSDoctRenderer
3839
{
@@ -46,11 +47,11 @@ namespace NSDoctRenderer
4647
m_sWorkDirectory = sWorkDir;
4748
}
4849
public:
49-
std::wstring GetX2tSaveAddon()
50+
std::wstring GetX2tSaveAddon(NSDoctRenderer::CDocBuilder* builder, const int& filetype)
5051
{
5152
return L"";
5253
}
53-
int GetX2tPreSaveError()
54+
int GetX2tPreSaveError(NSDoctRenderer::CDocBuilder* builder, const int& filetype)
5455
{
5556
return 0;
5657
}

DesktopEditor/doctrenderer/app_builder/main.cpp

+36
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "./../common_deploy.h"
3434
#include "../docbuilder.h"
3535
#include "../../common/File.h"
36+
#include "../../common/SystemUtils.h"
3637

3738
#ifdef LINUX
3839
#include "../../../DesktopEditor/common/File.h"
@@ -78,6 +79,13 @@ void parse_args(NSDoctRenderer::CDocBuilder* builder, int argc, char *argv[])
7879
}
7980
}
8081

82+
bool CheckLicense(const std::wstring& sSrc, const std::wstring& sDst)
83+
{
84+
NSFile::CFileBinary::Remove(sDst);
85+
NSFile::CFileBinary::Copy(sSrc, sDst);
86+
return NSFile::CFileBinary::Exists(sDst);
87+
}
88+
8189
#ifdef WIN32
8290
int wmain(int argc, wchar_t *argv[])
8391
#else
@@ -89,6 +97,7 @@ int main(int argc, char *argv[])
8997

9098
bool bIsHelp = false;
9199
bool bIsFonts = false;
100+
bool bIsLicense = false;
92101
for (int i = 0; i < argc; ++i)
93102
{
94103
#ifdef WIN32
@@ -121,6 +130,33 @@ int main(int argc, char *argv[])
121130
{
122131
bIsFonts = true;
123132
}
133+
else if (sParam == "-register")
134+
{
135+
bIsLicense = true;
136+
}
137+
else
138+
{
139+
if (bIsLicense)
140+
{
141+
std::wstring sLicensePathSrc = UTF8_TO_U(sParam);
142+
if (!NSFile::CFileBinary::Exists(sLicensePathSrc))
143+
return 1;
144+
145+
std::wstring sLicensePath = NSSystemUtils::GetEnvVariable(L"ONLYOFFICE_BUILDER_LICENSE");
146+
if (CheckLicense(sLicensePathSrc, sLicensePath))
147+
return 0;
148+
149+
sLicensePath = NSFile::GetProcessDirectory() + L"/license.xml";
150+
if (CheckLicense(sLicensePathSrc, sLicensePath))
151+
return 0;
152+
153+
sLicensePath = NSSystemUtils::GetAppDataDir() + L"/docbuilder/license.xml";
154+
if (CheckLicense(sLicensePathSrc, sLicensePath))
155+
return 0;
156+
157+
return 1;
158+
}
159+
}
124160
}
125161

126162
if (bIsFonts)

DesktopEditor/doctrenderer/docbuilder.python/src/docbuilder.py

+6
Original file line numberDiff line numberDiff line change
@@ -612,4 +612,10 @@ class Graphics:
612612
_loadLibrary(builder_path)
613613
CDocBuilder.Initialize(builder_path)
614614

615+
def registerLibrary(license_path):
616+
docbuilder_bin = os.path.dirname(os.path.realpath(__file__)) + os.pathsep + "docbuilder"
617+
if ("windows" == platform.system().lower()):
618+
docbuilder_bin += ".exe"
619+
return subprocess.call([docbuilder_bin, license_path], stderr=subprocess.STDOUT, shell=True)
620+
615621
atexit.register(CDocBuilder.Dispose)

DesktopEditor/doctrenderer/docbuilder_p.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ namespace NSDoctRenderer
10031003

10041004
CDocBuilderAddon oSaveAddon(m_sX2tPath);
10051005

1006-
int nPreSaveError = oSaveAddon.GetX2tPreSaveError();
1006+
int nPreSaveError = oSaveAddon.GetX2tPreSaveError(m_pParent, m_nFileType);
10071007
if (0 != nPreSaveError)
10081008
return nPreSaveError;
10091009

@@ -1090,7 +1090,7 @@ namespace NSDoctRenderer
10901090
if (!sOptions.empty())
10911091
oBuilder.WriteString(UTF8_TO_U(sOptions));
10921092

1093-
oBuilder.WriteString(oSaveAddon.GetX2tSaveAddon());
1093+
oBuilder.WriteString(oSaveAddon.GetX2tSaveAddon(m_pParent, m_nFileType));
10941094

10951095
oBuilder.WriteString(L"</TaskQueueDataConvert>");
10961096

0 commit comments

Comments
 (0)