33
33
#include " ./../common_deploy.h"
34
34
#include " ../docbuilder.h"
35
35
#include " ../../common/File.h"
36
+ #include " ../../common/SystemUtils.h"
36
37
37
38
#ifdef LINUX
38
39
#include " ../../../DesktopEditor/common/File.h"
@@ -78,6 +79,13 @@ void parse_args(NSDoctRenderer::CDocBuilder* builder, int argc, char *argv[])
78
79
}
79
80
}
80
81
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
+
81
89
#ifdef WIN32
82
90
int wmain (int argc, wchar_t *argv[])
83
91
#else
@@ -89,6 +97,7 @@ int main(int argc, char *argv[])
89
97
90
98
bool bIsHelp = false ;
91
99
bool bIsFonts = false ;
100
+ bool bIsLicense = false ;
92
101
for (int i = 0 ; i < argc; ++i)
93
102
{
94
103
#ifdef WIN32
@@ -121,6 +130,33 @@ int main(int argc, char *argv[])
121
130
{
122
131
bIsFonts = true ;
123
132
}
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
+ }
124
160
}
125
161
126
162
if (bIsFonts)
0 commit comments