merge from hotfix/v5.4.2

This commit is contained in:
Alexey Bannov
2019-11-29 15:25:10 +03:00
11 changed files with 198 additions and 50 deletions

View File

@ -253,6 +253,7 @@ protected:
friend class CCefViewEditor;
friend class CAscClientHandler;
friend class CASCFileConverterFromEditor;
friend class CASCFileConverterToEditor;
friend class CApplicationCEF;
};

View File

@ -396,6 +396,9 @@ public:
// дополнения к редактору (для внешних подключений)
CApplicationManagerAdditionalBase* m_pAdditional;
// логи конвертера
bool m_bIsEnableConvertLogs;
public:
IMPLEMENT_REFCOUNTING(CAscApplicationManager_Private)
@ -427,6 +430,8 @@ public:
m_pKeyChain = NULL;
m_bIsEnableConvertLogs = false;
m_bCryptoDisableForLocal = false;
m_bCryptoDisableForInternalCloud = false;
m_bCryptoDisableForExternalCloud = false;
@ -575,6 +580,10 @@ public:
std::map<std::string, std::string>::iterator pairCryptoMode = m_mapSettings.find("crypto-mode");
if (pairCryptoMode != m_mapSettings.end())
m_nCurrentCryptoMode = (NSAscCrypto::AscCryptoType)std::stoi(pairCryptoMode->second);
std::map<std::string, std::string>::iterator pairConvertLogs = m_mapSettings.find("converter-logging");
if (pairConvertLogs != m_mapSettings.end())
m_bIsEnableConvertLogs = ("1" == pairConvertLogs->second) ? true : false;
}
void CheckSetting(const std::string& sName, const std::string& sValue)
{

View File

@ -643,7 +643,7 @@ public:
// вся работа закончена
CefRefPtr<CefFrame> pFrame = GetFrame();
if (pFrame)
pFrame->ExecuteJavaScript("window.onSystemMessage({ type : \"upload_end\" });", pFrame->GetURL(), 0);
pFrame->ExecuteJavaScript("window.on_cloud_crypto_upload = undefined;window.onSystemMessage({ type : \"upload_end\" });", pFrame->GetURL(), 0);
View->m_pUploadFiles = NULL;
delete this;
}
@ -2850,6 +2850,14 @@ public:
bIsEditorPresent = true;
break;
}
else
{
if (tmp->m_pInternal->m_pUploadFiles)
{
bIsEditorPresent = true;
break;
}
}
}
if (!bIsEditorPresent)
@ -5135,7 +5143,7 @@ void CCefView::Apply(NSEditorApi::CAscMenuEvent* pEvent)
m_pInternal->m_oSimpleX2tConverter.m_sRecoverFolder = m_pInternal->m_oLocalInfo.m_oInfo.m_sRecoveryDir;
m_pInternal->m_oSimpleX2tConverter.m_pEvents = m_pInternal;
m_pInternal->m_oSimpleX2tConverter.m_pManager = m_pInternal->m_pManager;
m_pInternal->m_oSimpleX2tConverter.Convert();
m_pInternal->m_oSimpleX2tConverter.Convert(m_pInternal->m_pManager->m_pInternal->m_bIsEnableConvertLogs);
}
break;
}

View File

@ -1076,8 +1076,10 @@ DE.controllers.Main.DisableVersionHistory(); \
if (!bIsNoHeader)
{
BYTE pData[IMAGE_CHECKER_SIZE];
memset(pData, 0, IMAGE_CHECKER_SIZE);
DWORD dwSize = 0;
NSFile::CFileBinary oFile;
oFile.OpenFile(sFileUrl);
oFile.ReadFile(pData, IMAGE_CHECKER_SIZE, dwSize);
oFile.CloseFile();
@ -1438,6 +1440,7 @@ window.AscDesktopEditor.OpenFileCrypt = function(name, url, callback) {\n\
window.AscDesktopEditor._OpenFileCrypt(name, url);\n\
};\n\
window.AscDesktopEditor.OpenFilenameDialog = function(filter, ismulti, callback) {\n\
if (window.on_native_open_filename_dialog) return;\n\
window.on_native_open_filename_dialog = callback;\n\
window.AscDesktopEditor._OpenFilenameDialog(filter, ismulti);\n\
};\n\
@ -1461,17 +1464,18 @@ window.AscDesktopEditor.SetAdvancedEncryptedData = function(password, data, call
window.on_set_advanced_encrypted_data = callback;\n\
window.AscDesktopEditor._SetAdvancedEncryptedData(password, data);\n\
};\n\
window.AscDesktopEditor.ImportAdvancedEncryptedData = function() {\n\
window.AscDesktopEditor.OpenFilenameDialog('key', false, function(files) {\n\
window.AscDesktopEditor.ImportAdvancedEncryptedData = function(callback) {\n\
window.AscDesktopEditor.OpenFilenameDialog('Key File (*docx);;All files (*.*)', false, function(files) {\n\
var file = Array.isArray(files) ? files[0] : files;\n\
if (file)\n\
{\n\
window.AscDesktopEditor._ImportAdvancedEncryptedData(file);\n\
var ret = window.AscDesktopEditor._ImportAdvancedEncryptedData(file);\n\
if (callback) callback(ret);\n\
}\n\
});\n\
};\n\
window.AscDesktopEditor.ExportAdvancedEncryptedData = function() {\n\
window.AscDesktopEditor.SaveFilenameDialog('encrypted.key', function(file) {\n\
window.AscDesktopEditor.SaveFilenameDialog('privateKey.docx', function(file) {\n\
if (file)\n\
{\n\
window.AscDesktopEditor._ExportAdvancedEncryptedData(file);\n\
@ -1479,10 +1483,12 @@ window.AscDesktopEditor.ExportAdvancedEncryptedData = function() {\n\
});\n\
};\n\
window.AscDesktopEditor.CloudCryptFile = function(url, callback) {\n\
if (window.on_cloud_crypto_upload) { console.log('CloudCryptFile: waiting...'); return; }\n\
window.AscDesktopEditor.DownloadFiles([url], [], function(files) {\n\
var _files = [];\n\
for (var elem in files)\n\
_files.push(files[elem]);\n\
window.on_cloud_crypto_upload = undefined;\n\
if (_files && 1 == _files.length)\n\
{\n\
window.on_cloud_crypto_upload = callback;\n\
@ -1491,8 +1497,10 @@ window.AscDesktopEditor.CloudCryptFile = function(url, callback) {\n\
}, 1);\n\
};\n\
window.AscDesktopEditor.CloudCryptUpload = function(filter, callback) {\n\
if (window.on_cloud_crypto_upload) { console.log('CloudCryptUpload: waiting...'); return; }\n\
var filterOut = filter || \"\"; if (filterOut == \"\") filterOut = \"any\";\n\
window.AscDesktopEditor.OpenFilenameDialog(filterOut, true, function(files) {\n\
window.on_cloud_crypto_upload = undefined;\n\
if (files && 0 < files.length)\n\
{\n\
window.on_cloud_crypto_upload = callback;\n\
@ -2603,7 +2611,18 @@ if (window.onSystemMessage2) window.onSystemMessage2(e);\n\
else if (name == "_ImportAdvancedEncryptedData")
{
std::wstring sFile = arguments[0]->GetStringValue().ToWString();
NSFile::CFileBinary::Copy(sFile, m_sUserPlugins + L"/advanced_crypto_data.docx");
COfficeFileFormatChecker oChecker;
bool bIsOfficeFile = oChecker.isOfficeFile(sFile);
if (bIsOfficeFile && oChecker.nFileType == AVS_OFFICESTUDIO_FILE_OTHER_MS_OFFCRYPTO)
{
NSFile::CFileBinary::Copy(sFile, m_sUserPlugins + L"/advanced_crypto_data.docx");
retval = CefV8Value::CreateBool(true);
}
else
{
retval = CefV8Value::CreateBool(false);
}
return true;
}
else if (name == "_ExportAdvancedEncryptedData")

View File

@ -334,13 +334,18 @@ int NSMonitor::GetRawMonitorDpi(WindowHandleId handle)
return 1;
}
HMONITOR hMonitor = MonitorFromWindow(handle, MONITOR_DEFAULTTONEAREST);
UINT iuW = 0;
UINT iuH = 0;
g_monitor_info.m_func_GetDpiForMonitor(hMonitor, MDT_RAW_DPI, &iuW, &iuH);
if (g_monitor_info.m_func_GetDpiForMonitor)
{
HMONITOR hMonitor = MonitorFromWindow(handle, MONITOR_DEFAULTTONEAREST);
UINT iuW = 0;
UINT iuH = 0;
g_monitor_info.m_func_GetDpiForMonitor(hMonitor, MDT_RAW_DPI, &iuW, &iuH);
if (iuW > 180 && iuH > 180)
return 2;
return 1;
}
if (iuW > 180 && iuH > 180)
return 2;
return 1;
}
@ -380,8 +385,6 @@ int Core_GetMonitorRawDpi(WindowHandleId handle, unsigned int* uiX, unsigned int
*uiY = iuH;
return 0;
}
return -1;
}
if (g_monitor_info.m_func_GetDpiForWindow)
@ -394,9 +397,13 @@ int Core_GetMonitorRawDpi(WindowHandleId handle, unsigned int* uiX, unsigned int
return 0;
}
HMONITOR hMonitor = MonitorFromWindow(handle, MONITOR_DEFAULTTONEAREST);
g_monitor_info.m_func_GetDpiForMonitor(hMonitor, MDT_RAW_DPI, uiX, uiY);
return 0;
if (g_monitor_info.m_func_GetDpiForMonitor)
{
HMONITOR hMonitor = MonitorFromWindow(handle, MONITOR_DEFAULTTONEAREST);
g_monitor_info.m_func_GetDpiForMonitor(hMonitor, MDT_RAW_DPI, uiX, uiY);
return 0;
}
return -1;
}
struct sEnumInfo

View File

@ -149,7 +149,7 @@ public:
namespace NSX2T
{
int Convert(const std::wstring& sConverterPath, const std::wstring sXmlPath, CAscApplicationManager* pManager)
int Convert(const std::wstring& sConverterPath, const std::wstring sXmlPath, CAscApplicationManager* pManager, bool bIsLoggingErrors = false)
{
int nReturnCode = 0;
std::wstring sConverterExe = sConverterPath;
@ -288,6 +288,22 @@ namespace NSX2T
}
#endif
if (bIsLoggingErrors && nReturnCode != 0)
{
std::string sXmlContent;
NSFile::CFileBinary::ReadAllTextUtf8A(sXmlPath, sXmlContent);
NSCommon::string_replaceA(sXmlContent, "%", "%%");
std::wstring sLogFile = NSFile::GetDirectoryName(sXmlPath) + L"/errors.log";
std::string sLogFileA = U_TO_UTF8(sLogFile);
FILE* f = fopen(sLogFileA.c_str(), "a+");
fprintf(f, "--------------------------------------------------------\n");
fprintf(f, "error: %d\nxml:\n", nReturnCode);
fprintf(f, sXmlContent.c_str());
fprintf(f, "\n\n");
fclose(f);
}
return nReturnCode;
}
}
@ -666,7 +682,7 @@ public:
std::wstring sTempFileForParams = m_oInfo.m_sRecoveryDir + L"/params_from.xml";
NSFile::CFileBinary::SaveToFile(sTempFileForParams, sXmlConvert, true);
int nReturnCode = NSX2T::Convert(sConverterExe, sTempFileForParams, m_pManager);
int nReturnCode = NSX2T::Convert(sConverterExe, sTempFileForParams, m_pManager, m_pManager->m_pInternal->m_bIsEnableConvertLogs);
NSFile::CFileBinary::Remove(sTempFileForParams);
@ -1004,7 +1020,7 @@ public:
if (m_pManager->m_pInternal->m_pAdditional)
m_pManager->m_pInternal->m_pAdditional->CheckSaveStart(m_oInfo.m_sRecoveryDir, m_nTypeEditorFormat);
int nReturnCode = NSX2T::Convert(sConverterExe, sTempFileForParams, m_pManager);
int nReturnCode = NSX2T::Convert(sConverterExe, sTempFileForParams, m_pManager, m_pManager->m_pInternal->m_bIsEnableConvertLogs);
if (bIsUseTmpFileDst)
{
@ -1204,16 +1220,20 @@ public:
IASCFileConverterEvents* m_pEvents;
CAscApplicationManager* m_pManager;
bool m_bIsLogs;
public:
CSimpleConverter()
{
m_nOutputFormat = -1;
m_pEvents = NULL;
m_pManager = NULL;
m_bIsLogs = false;
}
void Convert()
void Convert(bool bIsLogs = false)
{
m_bIsLogs = bIsLogs;
Start(0);
}
@ -1245,7 +1265,7 @@ public:
std::wstring sTempFileForParams = m_sRecoverFolder + L"/params_simple_converter.xml";
NSFile::CFileBinary::SaveToFile(sTempFileForParams, oBuilder.GetData(), true);
nReturnCode = NSX2T::Convert(m_pManager->m_oSettings.file_converter_path + L"/x2t", sTempFileForParams, m_pManager);
nReturnCode = NSX2T::Convert(m_pManager->m_oSettings.file_converter_path + L"/x2t", sTempFileForParams, m_pManager, m_bIsLogs);
NSFile::CFileBinary::Remove(sTempFileForParams);
}

View File

@ -1,8 +1,60 @@
* {
box-sizing: border-box;
}
@font-face {
font-family: 'Open Sans';
src: url(../../../../fonts/OpenSans-Bold.ttf);
font-weight: 700
}
@font-face {
font-family: 'Open Sans';
src: url(../../../../fonts/OpenSans-BoldItalic.ttf);
font-weight: 400;
font-style: italic
}
@font-face {
font-family: 'Open Sans';
src: url(../../../../fonts/OpenSans-ExtraBold.ttf);
font-weight: bolder
}
@font-face {
font-family: 'Open Sans';
src: url(../../../../fonts/OpenSans-ExtraBoldItalic.ttf);
font-weight: bolder;
font-style: italic
}
@font-face {
font-family: 'Open Sans';
src: url(../../../../fonts/OpenSans-Italic.ttf);
font-style: italic
}
@font-face {
font-family: 'Open Sans';
src: url(../../../../fonts/OpenSans-Light.ttf);
font-weight: 100
}
@font-face {
font-family: 'Open Sans';
src: url(../../../../fonts/OpenSans-LightItalic.ttf);
font-weight: lighter;
font-style: italic
}
@font-face {
font-family: 'Open Sans';
src: url(../../../../fonts/OpenSans-Regular.ttf);
font-weight: 400
}
body {
font-family:'Open Sans',sans-serif;
font-family: 'Open Sans',sans-serif;
font-size: 14px;
margin:0px;
color: #444;
@ -78,12 +130,8 @@ h4 {
margin: 0 15px;
}
#enc-box-caption span {
position: relative;
top: -9px;
left: 5px;
#enc-box-infobox {
color: #fff;
font-size: 10px;
padding: 2px 5px;
border-radius: 0px;
background-color: #ed7309;
@ -318,7 +366,7 @@ dialog .tool.close {
}
#box-blockchain-connect, #box-blockchain-info {
width: 700px;
max-width: 700px;
min-width:585px;
}

View File

@ -46,9 +46,9 @@
<div class="info-box excl" style="display: none;" data-t="info-box-off">
<strong>The end-to-end encryption mode is OFF.</strong> To switch it on, you must close all active edition sessions.
</div>
<section id="enc-box-caption">
<span data-t="title-pop" id="enc-box-infobox">Developer Preview</span>
<section id="enc-box-caption">
<h3 class="table-caption" data-t="title">End-to-end encryption</h3>
<span data-t="title-pop">Developer Preview</span>
<div class="onoffswitch">
<input type="checkbox" name="onoffswitch" class="onoffswitch__checkbox" id="enc-mode-switch"/>
<label class="onoffswitch__label" for="enc-mode-switch"></label>
@ -73,6 +73,9 @@
<button data-t="box-database-connect-btn-create" class="btn primary">Generate new credentials</button>
<a data-t="box-database-connect-btn-cancel" class="text-sub link" href="javascript:void(0)">Use the existing credentials</a>
</p>
<p data-t="box-database-connect-description-warning">
Warning! This network was created for demonstration purposes only. Please, do NOT use it to encrypt your sensitive documents.
</p>
<p data-t="box-database-connect-description-line4" style="color: #888">
ONLYOFFICE will generate your individual pair of the encryption keys: public and private. Your private key (used for decrypting the documents) will be stored on this machine. For the correct work of the application, do not remove this file. You may keep a copy in some other location as a backup.
</p>
@ -102,7 +105,7 @@
<tfoot>
<tr>
<td colspan="3">
<a data-t="tbl-acount-info-btn-export-private-key" href="javascript:void(0)" class="link-gray">Export private key</a>
<a data-t="tbl-acount-info-btn-export-private-key" href="javascript:void(0);" class="link-gray">Export private key</a>
</td>
</tr>
</tfoot>
@ -123,7 +126,10 @@
<input type="password" name="" class="tbox" value="" placeholder="enter password" />
<div style="height:10px;"></div>
<div class="lr-flex">
<a class="text-sub link" data-t="dlg-onoffswitch-btn-import" href="javascript: window.AscDesktopEditor.ImportAdvancedEncryptedData();">Import private key</a>
<div>
<span id="dlg-onoffswitch-btn-import-label" data-t="dlg-onoffswitch-btn-import-completed">Key is imported.</span>
<a class="text-sub link" data-t="dlg-onoffswitch-btn-import" href="javascript:void(0);">Import private key</a>
</div>
<span></span>
<div>
<img class="img-loader">

View File

@ -106,6 +106,11 @@ return {
setPublicKey: function(publicKey) {
_publicKey = publicKey;
},
setPublicKeyFromPrivateKey: function(privateKey) {
let keyPair = nacl.box.keyPair.fromSecretKey(_hexStringToByte(privateKey));
_publicKey = _byteToHexString(keyPair.publicKey);
},
getPublicKey: function() {
return _publicKey;
},
@ -114,10 +119,7 @@ return {
},
getPrivateKey: function() {
return _privateKey;
},
getPublicKeyFromPrivateKey: function(privateKey) {
return nacl.box.keyPair.fromSecretKey(_hexStringToByte(privateKey));
},
},
generateKeyPair: function() {
let result = nacl.box.keyPair();

View File

@ -23,7 +23,9 @@ ONLYONET.UI = (function() {
$("#dlg-onoffswitch input:password").val("");
$("#dlg-onoffswitch input:password").attr("placeholder", ONLYONET.Resources["dlg-onoffswitch-password"]);
$("#dlg-onoffswitch input:text").removeClass("error");
$("#dlg-onoffswitch button.primary").removeAttr("disabled");
$("#dlg-onoffswitch button.primary").removeAttr("disabled");
$("#dlg-onoffswitch a.link").text(ONLYONET.Resources["dlg-onoffswitch-btn-import"]);
$("#dlg-onoffswitch-btn-import-label").hide();
}
function _renderBlockChainInfo() {
@ -198,6 +200,27 @@ ONLYONET.UI = (function() {
_renderBlockChainInfo();
});
$("#dlg-onoffswitch a.link").click(function() {
window.AscDesktopEditor.ImportAdvancedEncryptedData(function(isSuccess) {
if (isSuccess) {
$("#dlg-onoffswitch .error-box p").hide();
$("#dlg-onoffswitch input:text").removeClass("error");
// $("#dlg-onoffswitch-btn-import-label").removeClass("msg-error");
$("#dlg-onoffswitch a.link").text(ONLYONET.Resources["dlg-onoffswitch-btn-import-change"]);
$("#dlg-onoffswitch-btn-import-label").text(ONLYONET.Resources["dlg-onoffswitch-btn-import-complete"]);
$("#dlg-onoffswitch-btn-import-label").show();
}
else {
$("#dlg-onoffswitch a.link").text(ONLYONET.Resources["dlg-onoffswitch-btn-import"]);
$("#dlg-onoffswitch-btn-import-label").text(ONLYONET.Resources["dlg-onoffswitch-btn-import-error"]);
// $("#dlg-onoffswitch-btn-import-label").addClass("msg-error");
$("#dlg-onoffswitch-btn-import-label").show();
}
});
});
$("#dlg-onoffswitch button.primary").click(function () {
$("#dlg-onoffswitch button.primary").attr("disabled","disabled");
$("#dlg-onoffswitch img.img-loader").show();
@ -208,11 +231,10 @@ ONLYONET.UI = (function() {
try {
if (privateKey == "") throw "Error read data";
let publicKey = ONLYONET.getPublicKeyFromPrivateKey(privateKey);
ONLYONET.setPublicKey(publicKey);
ONLYONET.setPrivateKey(privateKey);
ONLYONET.setPublicKeyFromPrivateKey(privateKey);
_switchOn("#dlg-onoffswitch .tool.close");
}
catch(error) {
@ -228,6 +250,8 @@ ONLYONET.UI = (function() {
});
});
// $("#dlg-onoffswitch a.text-sub").click(function () {
// $("#dlg-onoffswitch .tool.close").trigger("click");

View File

@ -1,6 +1,6 @@
ONLYONET.Resources = {
"title":"End-to-end encryption",
"title-pop":"Developer Preview",
"title-pop":"Developer Preview 2",
"info-box-off":"<strong>The end-to-end encryption mode is OFF.</strong> To switch it on, you must close all active edition sessions.",
"info-box-on":"<strong>The end-to-end encryption mode is ON.</strong> To switch it off, you must close all active edition sessions.",
"box-blockchain-connect-description-line1": "Keep your DOCX, XLSX, PPTX, ODT, ODS, ODP and PDF files always encrypted and private. Edit and collaborate on your docs securely.",
@ -23,7 +23,7 @@ ONLYONET.Resources = {
"box-network-info-current-block":"Current Block",
"box-network-info-gas-price":"GAS Price",
"box-network-info-gas-limit":"Gas Limit",
"dlg-onoffswitch-caption":"Secure Login",
"dlg-onoffswitch-caption":"Secure login",
"dlg-onoffswitch-btn-cancel":"Forgot password?",
"dlg-onoffswitch-btn":"Log in",
"dlg-onoffswitch-msg-error":"Check the password",
@ -33,8 +33,8 @@ ONLYONET.Resources = {
"dlg-vault-mnemonic-restore-placeholder":"Enter your mnemonic phrase and create new password to restore access.",
"dlg-vault-mnemonic-caption":"Create your account with mnemonic phrase",
"dlg-vault-mnemonic-restore-caption":"Forgot password",
"dlg-vault-new-password":"New Password (min 8 chars) **",
"dlg-vault-confirm-password": "Confirm Password",
"dlg-vault-new-password":"New password (min 8 chars) **",
"dlg-vault-confirm-password": "Confirm password",
"dlg-vault-new-password-msg-error":"Don't Match",
"dlg-vault-new-password-msg-error-1":"Your password is less than 8 characters",
"dlg-vault-description-line1":"* WARNING: This combination of 12 words is the only way to unlock your blockchain account. Keep it in the safe location in virtual or written form.",
@ -46,6 +46,7 @@ ONLYONET.Resources = {
"dlg-private-key-btn":"Copy to clipboard",
"system-message-save-to-blockchain": "Saving encryption data to blockchain...",
"box-database-connect-description-warning": "Warning! This network was created for demonstration purposes only. Please, do NOT use it to encrypt your sensitive documents.",
"tbl-acount-info-btn-copy-address1":"Copy public key",
"system-message-save-to-database": "Saving encryption data to database...",
"box-database-info-description-line2": "ONLYOFFICE uses AES-256 to encrypt your files, and asymmetric encryption algorithm to securely store the encryption data in the private database on your portal.",
@ -58,8 +59,11 @@ ONLYONET.Resources = {
"box-database-connect-btn-create": "Generate new credentials",
"box-database-connect-btn-cancel": "Use the existing credentials",
"dlg-vault-mnemonic-caption1":"Generate new credentials",
"dlg-vault-new-password1":"New Password (min 8 chars) *",
"dlg-vault-description-line22":"* This password encrypts the DOCX file with your generate a key pair. Use it to enable the Encryption mode.",
"dlg-vault-new-password1":"New password (min 8 chars) *",
"dlg-vault-description-line22":"* This password encrypts the DOCX file with your generated key pair. Use it to enable the encryption mode.",
"dlg-vault-description-btn1": "Generate",
"dlg-onoffswitch-btn-import": "Import private key"
"dlg-onoffswitch-btn-import": "Import private key",
"dlg-onoffswitch-btn-import-complete": "Key is imported.",
"dlg-onoffswitch-btn-import-error": "Key import failed.",
"dlg-onoffswitch-btn-import-change": "Change"
};