Commit 11d24977 authored by Alexander.Trofimov's avatar Alexander.Trofimov

Добавил чтение и расшифровку лицензии на клиенте.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@64937 954022d7-b5bf-4e40-9824-e11837661b57
parent f16d381f
......@@ -91,56 +91,6 @@
prot["asc_getAutosaveMinInterval"] = prot.asc_getAutosaveMinInterval;
prot["asc_getIsAnalyticsEnable"] = prot.asc_getIsAnalyticsEnable;
/**
* Класс asc_CAscLicense для лицензии
* -----------------------------------------------------------------------------
*
* @constructor
* @memberOf Asc
*/
function asc_CAscLicense (settings) {
if ( !(this instanceof asc_CAscLicense) ) {
return new asc_CAscLicense();
}
if(settings) {
this.customer = settings["customer"];
this.customerAddr = settings["customer_addr"];
this.customerWww = settings["customer_www"];
this.customerMail = settings["customer_mail"];
this.customerInfo = settings["customer_info"];
this.customerLogo = settings["customer_logo"];
} else {
this.customer = null;
this.customerAddr = null;
this.customerWww = null;
this.customerMail = null;
this.customerInfo = null;
this.customerLogo = null;
}
return this;
}
asc_CAscLicense.prototype.asc_getCustomer = function () {return this.customer;};
asc_CAscLicense.prototype.asc_getCustomerAddr = function () {return this.customerAddr;};
asc_CAscLicense.prototype.asc_getCustomerWww = function () {return this.customerWww;};
asc_CAscLicense.prototype.asc_getCustomerMail = function () {return this.customerMail;};
asc_CAscLicense.prototype.asc_getCustomerInfo = function () {return this.customerInfo;};
asc_CAscLicense.prototype.asc_getCustomerLogo = function () {return this.customerLogo;};
/*
* Export
* -----------------------------------------------------------------------------
*/
window["Asc"]["asc_CAscLicense"] = window["Asc"].asc_CAscLicense = asc_CAscLicense;
prot = asc_CAscLicense.prototype;
prot["asc_getCustomer"] = prot.asc_getCustomer;
prot["asc_getCustomerAddr"] = prot.asc_getCustomerAddr;
prot["asc_getCustomerWww"] = prot.asc_getCustomerWww;
prot["asc_getCustomerMail"] = prot.asc_getCustomerMail;
prot["asc_getCustomerInfo"] = prot.asc_getCustomerInfo;
prot["asc_getCustomerLogo"] = prot.asc_getCustomerLogo;
/**
* Класс CColor для работы с цветами
* -----------------------------------------------------------------------------
......
......@@ -65,8 +65,7 @@ var c_oAscAdvancedOptionsID = {
var c_oAscAdvancedOptionsAction = {
None: 0,
Open: 1,
Save: 2,
Perm: 3
Save: 2
};
// Режимы отрисовки
......
......@@ -23,6 +23,7 @@
this.onFirstLoadChangesEnd = options.onFirstLoadChangesEnd;
this.onConnectionStateChanged = options.onConnectionStateChanged;
this.onSetIndexUser = options.onSetIndexUser;
this.onSpellCheckInit = options.onSpellCheckInit;
this.onSaveChanges = options.onSaveChanges;
this.onStartCoAuthoring = options.onStartCoAuthoring;
this.onEndCoAuthoring = options.onEndCoAuthoring;
......@@ -69,6 +70,9 @@
this._CoAuthoringApi.onSetIndexUser = function(e) {
t.callback_OnSetIndexUser(e);
};
this._CoAuthoringApi.onSpellCheckInit = function(e) {
t.callback_OnSpellCheckInit(e);
};
this._CoAuthoringApi.onSaveChanges = function(e, userId, bFirstLoad) {
t.callback_OnSaveChanges(e, userId, bFirstLoad);
};
......@@ -108,11 +112,12 @@
};
CDocsCoApi.prototype.auth = function(isViewer) {
// Фиктивные вызовы
if (this._CoAuthoringApi && this._onlineWork) {
this._CoAuthoringApi.auth(isViewer);
} else {
this.callback_OnSetIndexUser("123");
// Фиктивные вызовы
this.callback_OnSpellCheckInit(window['g_cAscSpellCheckUrl'] ? window['g_cAscSpellCheckUrl'] : '');
this.callback_OnSetIndexUser('123');
this.onFirstLoadChangesEnd();
}
};
......@@ -159,18 +164,6 @@
}
};
CDocsCoApi.prototype.setUserAlive = function() {
if (this._CoAuthoringApi && this._onlineWork) {
this._CoAuthoringApi.setUserAlive();
}
};
CDocsCoApi.prototype.setPingSettings = function(inverval, bSendUserAlive) {
if (this._CoAuthoringApi && this._onlineWork) {
this._CoAuthoringApi.setPingSettings(inverval, bSendUserAlive);
}
};
CDocsCoApi.prototype.askLock = function(arrayBlockId, callback) {
if (this._CoAuthoringApi && this._onlineWork) {
this._CoAuthoringApi.askLock(arrayBlockId, callback);
......@@ -331,6 +324,11 @@
this.onSetIndexUser(e);
}
};
CDocsCoApi.prototype.callback_OnSpellCheckInit = function(e) {
if (this.onSpellCheckInit) {
this.onSpellCheckInit(e);
}
};
CDocsCoApi.prototype.callback_OnSaveChanges = function(e, userId, bFirstLoad) {
if (this.onSaveChanges) {
......@@ -386,6 +384,8 @@
this.onRelockFailed = options.onRelockFailed;
this.onDisconnect = options.onDisconnect;
this.onWarning = options.onWarning;
this.onSetIndexUser = options.onSetIndexUser;
this.onSpellCheckInit = options.onSpellCheckInit;
this.onSaveChanges = options.onSaveChanges;
this.onFirstLoadChangesEnd = options.onFirstLoadChangesEnd;
this.onConnectionStateChanged = options.onConnectionStateChanged;
......@@ -691,25 +691,7 @@
};
DocsCoApi.prototype.ping = function() {
// ua - активность пользователя. 0 - неактивный, 1 - активный, -1 - не обновлять
this._send({'type': 'ping', 'ua': this.bSendUserAlive ? (this.bUserAlive >> 0) : -1});
// После отправки сбрасываем активность
this.bUserAlive = false;
};
DocsCoApi.prototype.setUserAlive = function() {
this.bUserAlive = true;
};
DocsCoApi.prototype.setPingSettings = function(inverval, bSendUserAlive) {
if (null !== this.pingIntervalID)
return;
this.bSendUserAlive = bSendUserAlive;
this.pingInterval = inverval * 1000;
var t = this;
this.ping();
this.pingIntervalID = setInterval(function() {t.ping();}, this.pingInterval);
this._send({'type': 'ping'});
};
DocsCoApi.prototype._sendPrebuffered = function() {
......@@ -913,6 +895,11 @@
this.onSetIndexUser(data);
}
};
DocsCoApi.prototype._onSpellCheckInit = function(data) {
if (this.onSpellCheckInit) {
this.onSpellCheckInit(data);
}
};
DocsCoApi.prototype._onSavePartChanges = function(data) {
// Очищаем предыдущий таймер
......@@ -1066,6 +1053,7 @@
this._onAuthParticipantsChanged(data['participants']);
this._onSpellCheckInit(data['g_cAscSpellCheckUrl']);
this._onSetIndexUser(this._indexUser = data['indexUser']);
this._userId = this._user.asc_getId() + this._indexUser;
......@@ -1089,6 +1077,8 @@
//Send prebuffered
this._sendPrebuffered();
this.pingIntervalID = setInterval(function() {t.ping();}, this.pingInterval);
}
//TODO: Add errors
};
......@@ -1106,9 +1096,7 @@
this._isAuth = false;
this._documentFormatSave = documentFormatSave;
this.bUserAlive = false; // Активность пользователя
this.bSendUserAlive = false; // Отправлять ли активность пользователя
this.pingInterval = 300 * 1000;
this.pingInterval = 60 * 1000;
this.pingIntervalID = null;
this._initSocksJs();
......
......@@ -56,6 +56,7 @@ if (typeof String.prototype.repeat !== 'function') {
}
var g_oZipChanges = null;
var g_sLicenseDefaultUrl = "/license";
var g_sDownloadServiceLocalUrl = "/downloadas";
var g_sUploadServiceLocalUrl = "/upload";
var g_sUploadServiceLocalUrlOld = "/uploadold";
......@@ -132,6 +133,39 @@ DocumentUrls.prototype = {
};
var g_oDocumentUrls = new DocumentUrls();
var g_sPublicRSAKey = '-----BEGIN CERTIFICATE-----MIIBvTCCASYCCQD55fNzc0WF7TANBgkqhkiG9w0BAQUFADAjMQswCQYDVQQGEwJKUDEUMBIGA1UEChMLMDAtVEVTVC1SU0EwHhcNMTAwNTI4MDIwODUxWhcNMjAwNTI1MDIwODUxWjAjMQswCQYDVQQGEwJKUDEUMBIGA1UEChMLMDAtVEVTVC1SU0EwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANGEYXtfgDRlWUSDn3haY4NVVQiKI9CzThoua9+DxJuiseyzmBBe7Roh1RPqdvmtOHmEPbJ+kXZYhbozzPRbFGHCJyBfCLzQfVos9/qUQ88u83b0SFA2MGmQWQAlRtLy66EkR4rDRwTj2DzR4EEXgEKpIvo8VBs/3+sHLF3ESgAhAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAEZ6mXFFq3AzfaqWHmCy1ARjlauYAa8ZmUFnLm0emg9dkVBJ63aEqARhtok6bDQDzSJxiLpCEF6G4b/Nv/M/MLyhP+OoOTmETMegAVQMq71choVJyOFE5BtQa6M/lCHEOya5QUfoRF2HF9EjRF44K3OK+u3ivTSj3zwjtpudY5Xo=-----END CERTIFICATE-----';
var g_sAESKey = '7f3d2338390c1e3e154c21005f51010e065b0f1a1e101600202473150c022a11';
function CheckLicense(licenseUrl, callback) {
licenseUrl = licenseUrl ? licenseUrl : g_sLicenseDefaultUrl;
require('jsziputils').getBinaryContent(licenseUrl, function(err, data) {
if (err) {
callback(true, false);
return;
}
try {
var base64TextData = String.fromCharCode.apply(null, new Uint8Array(data));
var decrypted = CryptoJS.AES.decrypt({
ciphertext: CryptoJS.enc.Base64.parse(base64TextData),
salt: ""
}, CryptoJS.enc.Hex.parse(g_sAESKey), {iv: CryptoJS.enc.Hex.parse(g_sAESKey.slice(0, g_sAESKey.length / 2))});
var sJson = decrypted.toString(CryptoJS.enc.Utf8);
var oJson = JSON.parse(sJson);
var hSig = oJson.signature;
delete oJson.signature;
var x509 = new X509();
x509.readCertPEM(g_sPublicRSAKey);
var isValid = x509.subjectPublicKeyRSA.verifyString(JSON.stringify(oJson), hSig);
callback(false, isValid);
} catch(e) {
callback(true, false);
}
});
}
function OpenFileResult () {
this.bSerFormat = false;
this.data = null;
......
......@@ -23,6 +23,7 @@
<script src="../../Common/downloaderfiles.js"></script>
<script type="text/javascript" src="../../Common/3rdparty/Underscore/underscore-min.js"></script>
<script type="text/javascript" src="../../Common/3rdparty/Sockjs/sockjs-0.3.min.js"></script>
<script type="text/javascript" src="../../Common/3rdparty/jsrsasign/jsrsasign-latest-all-min.js"></script>
<script type="text/javascript" src="../../Common/docscoapicommon.js"></script>
<script type="text/javascript" src="../../Common/docscoapi.js"></script>
<script type="text/javascript" src="../../Common/Charts/DrawingArea.js"></script>
......
......@@ -39,6 +39,7 @@
<script src="../Common/downloaderfiles.js"></script>
<script type="text/javascript" src="../Common/3rdparty/Underscore/underscore-min.js"></script>
<script type="text/javascript" src="../Common/3rdparty/Sockjs/sockjs-0.3.min.js"></script>
<script type="text/javascript" src="../Common/3rdparty/jsrsasign/jsrsasign-latest-all-min.js"></script>
<script type="text/javascript" src="../Common/docscoapicommon.js"></script>
<script type="text/javascript" src="../Common/docscoapi.js"></script>
<script type="text/javascript" src="../Common/Charts/DrawingArea.js"></script>
......
......@@ -29,6 +29,7 @@
<script src="../Common/downloaderfiles.js"></script>
<script type="text/javascript" src="../Common/3rdparty/Underscore/underscore-min.js"></script>
<script type="text/javascript" src="../Common/3rdparty/Sockjs/sockjs-0.3.min.js"></script>
<script type="text/javascript" src="../Common/3rdparty/jsrsasign/jsrsasign-latest-all-min.js"></script>
<script type="text/javascript" src="../Common/docscoapicommon.js"></script>
<script type="text/javascript" src="../Common/docscoapi.js"></script>
<script type="text/javascript" src="../Common/Charts/DrawingArea.js"></script>
......
......@@ -16,7 +16,6 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
var asc_CCollaborativeEditing = asc.CCollaborativeEditing;
var asc_CAdjustPrint = asc.asc_CAdjustPrint;
var asc_CAscEditorPermissions = asc.asc_CAscEditorPermissions;
var asc_CAscLicense = asc.asc_CAscLicense;
var prot;
var CDocsCoApi = window["CDocsCoApi"];
......@@ -74,6 +73,11 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
this.asyncMethodCallback = undefined;
// Результат получения лицензии
this.licenseResult = null;
// Подключились ли уже к серверу
this.isOnFirstConnectEnd = false;
// Тип состояния на данный момент (сохранение, открытие или никакое)
this.advancedOptionsAction = c_oAscAdvancedOptionsAction.None;
// Переменная отвечает, загрузились ли фонты
......@@ -531,19 +535,28 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
CHART_STYLE_MANAGER = new CChartStyleManager();
};
spreadsheet_api.prototype.asc_getEditorPermissions = function() {
spreadsheet_api.prototype.asc_getEditorPermissions = function(licenseUrl) {
var t = this;
if (this.DocInfo && this.DocInfo["Id"] && this.DocInfo["Url"]) {
CheckLicense(licenseUrl, function (err, res) {
t._onCheckLicenseEnd(err, res);
});
} else {
// Фиктивный вызов
this._onCheckLicenseEnd(true, false);
}
this._coAuthoringInit();
};
spreadsheet_api.prototype.asc_getLicense = function() {
var t = this;
var rdata = {
"c": "getlicense"
};
//todo
sendCommand2(function(response) {
t._onGetLicense(response);
}, this.fCallbackSendCommand, rdata);
spreadsheet_api.prototype._onCheckLicenseEnd = function(err, res) {
this.licenseResult = {err: err, res: res};
this._sendLicenseInfo();
};
spreadsheet_api.prototype._sendLicenseInfo = function() {
if (null !== this.licenseResult && this.isOnFirstConnectEnd) {
var oResult = asc_CAscEditorPermissions();
oResult.asc_setCanLicense(this.licenseResult.res);
this.handlers.trigger('asc_onGetEditorPermissions', oResult);
}
};
spreadsheet_api.prototype.asc_DownloadAs = function(typeFile) {//передаем число соответствующее своему формату. например c_oAscFileType.XLSX
......@@ -1086,7 +1099,6 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
* asc_onWorkbookLocked (result) - эвент залочена ли работа с листами или нет
* asc_onWorksheetLocked (index, result) - эвент залочен ли лист или нет
* asc_onGetEditorPermissions (permission) - эвент о правах редактора
* asc_onGetLicense (license) - эвент о лицензии
* asc_onStopFormatPainter () - эвент об окончании форматирования по образцу
* asc_onUpdateSheetSettings () - эвент об обновлении свойств листа (закрепленная область, показывать сетку/заголовки)
* asc_onUpdateTabColor (index) - эвент об обновлении цвета иконки листа
......@@ -1270,28 +1282,6 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
}
};
spreadsheet_api.prototype._onGetEditorPermissions = function(response) {
if (null != response && "getsettings" == response["type"]) {
var oSettings = response["data"];
//Set up spellcheker service
this.SpellCheckUrl = oSettings['g_cAscSpellCheckUrl'];
var oEditorPermissions = new asc_CAscEditorPermissions(oSettings);
this.handlers.trigger("asc_onGetEditorPermissions", oEditorPermissions);
this.CoAuthoringApi.setPingSettings(oSettings['TrackingInterval'], oEditorPermissions.asc_getCanLicense());
}
};
spreadsheet_api.prototype._onGetLicense = function(response) {
if (null != response && "getlicense" == response.type) {
var oSettings = JSON.parse(response.data);
var oLicense = (null != oSettings) ? new asc_CAscLicense(oSettings) : null;
this.handlers.trigger("asc_onGetLicense", oLicense);
}
};
// Соединились с сервером
spreadsheet_api.prototype.asyncServerIdEndLoaded = function() {
// С сервером соединились, возможно стоит подождать загрузку шрифтов
......@@ -1551,8 +1541,11 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
this.CoAuthoringApi.onFirstLoadChangesEnd = function() {
t.asyncServerIdEndLoaded();
};
this.CoAuthoringApi.onSpellCheckInit = function(e) {
t.SpellCheckUrl = e;
};
this.CoAuthoringApi.onSetIndexUser = function(e) {
g_oIdCounter.Set_UserId("" + e);
g_oIdCounter.Set_UserId('' + e);
};
this.CoAuthoringApi.onStartCoAuthoring = function(isStartEvent) {
t.startCollaborationEditing();
......@@ -1574,23 +1567,8 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
t.endCollaborationEditing();
};
this.CoAuthoringApi.onFirstConnect = function() {
if (t.DocInfo && t.DocInfo["Id"] && t.DocInfo["Url"]) {
var rdata = {
"c": "getsettings",
"id": t.DocInfo["Id"],
"userid": t.DocInfo["UserId"],
"format": t.DocInfo["Format"],
"vkey": t.DocInfo["VKey"],
"editorid": c_oEditorId.Spreadsheet
};
t.advancedOptionsAction = c_oAscAdvancedOptionsAction.Perm;
sendCommand2(t, null, rdata);
} else {
// Фиктивный режим, фактически без документа
t.handlers.trigger("asc_onGetEditorPermissions", new asc_CAscEditorPermissions());
// Фиктивно инициализируем
t.SpellCheckUrl = window['g_cAscSpellCheckUrl'] ? window['g_cAscSpellCheckUrl'] : '';
}
t.isOnFirstConnectEnd = true;
t._sendLicenseInfo();
};
/**
* Event об отсоединении от сервера
......@@ -1617,12 +1595,6 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
if (inputWrap["data"]) {
var input = inputWrap["data"];
switch (input["type"]) {
case 'getsettings':
{
t.advancedOptionsAction = c_oAscAdvancedOptionsAction.None;
t._onGetEditorPermissions(input);
}
break;
case 'reopen':
case 'open':
{
......@@ -1829,7 +1801,6 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
// Update user alive
spreadsheet_api.prototype.setUserAlive = function() {
this.CoAuthoringApi.setUserAlive();
};
// End Load document
......@@ -3606,7 +3577,6 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
prot["asc_getLocaleExample"] = prot.asc_getLocaleExample;
prot["asc_setLocale"] = prot.asc_setLocale;
prot["asc_getEditorPermissions"] = prot.asc_getEditorPermissions;
prot["asc_getLicense"] = prot.asc_getLicense;
prot["asc_LoadDocument"] = prot.asc_LoadDocument;
prot["asc_LoadEmptyDocument"] = prot.asc_LoadEmptyDocument;
prot["asc_DownloadAs"] = prot.asc_DownloadAs;
......
......@@ -22,6 +22,7 @@ require.config({
jmousewheel : '../vendor/perfect-scrollbar/src/jquery.mousewheel',
xregexp : '../vendor/xregexp/xregexp-all-min',
sockjs : '../vendor/sockjs/sockjs.min',
jsziputils : '../vendor/jszip-utils/jszip-utils.min',
api : 'api/documents/api',
core : 'common/main/lib/core/application',
notification : 'common/main/lib/core/NotificationCenter',
......@@ -86,7 +87,8 @@ require([
'api',
'analytics',
'gateway',
'locale'
'locale',
'jsziputils'
], function (Backbone, Bootstrap, Core) {
Backbone.history.start();
......
......@@ -234,6 +234,7 @@
<link rel="stylesheet" type="text/css" href="../../../vendor/perfect-scrollbar/src/perfect-scrollbar.css" />
<script type="text/javascript" src="../../../vendor/perfect-scrollbar/src/jquery.mousewheel.js"></script>
<script type="text/javascript" src="../../../vendor/perfect-scrollbar/src/perfect-scrollbar.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/3rdparty/jsrsasign/jsrsasign-latest-all-min.js"></script>
<script type="text/javascript">
window.g_debug_mode = true;
......
......@@ -167,6 +167,7 @@
<script type="text/javascript" src="../../../vendor/underscore/underscore-min.js"></script>
<script type="text/javascript" src="../../../vendor/megapixel/src/megapix-image.js"></script>
<script type="text/javascript" src="../../../vendor/xregexp/xregexp-all-min.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/3rdparty/jsrsasign/jsrsasign-latest-all-min.js"></script>
<!-- Application -->
......
......@@ -24,6 +24,7 @@
<script type="text/javascript" src="../Common/3rdparty/Underscore/underscore-min.js"></script>
<script type="text/javascript" src="../Common/3rdparty/Sockjs/sockjs-0.3.min.js"></script>
<script type="text/javascript" src="../Common/3rdparty/XRegExp/xregexp-all.js"></script>
<script type="text/javascript" src="../Common/3rdparty/jsrsasign/jsrsasign-latest-all-min.js"></script>
<script type="text/javascript" src="../Common/docscoapi.js"></script>
<script type="text/javascript" src="../Common/browser.js"></script>
......@@ -48,8 +49,6 @@
<script type="text/javascript" src="../Common/apiCommon.js"></script>
<script type="text/javascript" src="../Common/downloaderfiles.js"></script>
<script type="text/javascript" src="../Common/docscoapicommon.js"></script>
<script type="text/javascript" src="../Common/3rdparty/Underscore/underscore-min.js"></script>
<script type="text/javascript" src="../Common/3rdparty/Sockjs/sockjs-0.3.min.js"></script>
<script type="text/javascript" src="../Common/docscoapi.js"></script>
<script type="text/javascript" src="../Common/wordcopypaste.js"></script>
......
......@@ -130,6 +130,11 @@ function asc_docs_api(name)
// Тип состояния на данный момент (сохранение, открытие или никакое)
this.advancedOptionsAction = c_oAscAdvancedOptionsAction.None;
// Результат получения лицензии
this.licenseResult = null;
// Подключились ли уже к серверу
this.isOnFirstConnectEnd = false;
// CoAuthoring and Chat
this.User = undefined;
this.CoAuthoringApi = new CDocsCoApi();
......@@ -425,57 +430,44 @@ asc_docs_api.prototype._coAuthoringInit = function () {
if (!bFirstLoad && t.bInit_word_control)
t.sync_CollaborativeChanges();
};
this.CoAuthoringApi.onFirstLoadChangesEnd = function () {
t.asyncServerIdEndLoaded ();
};
this.CoAuthoringApi.onSetIndexUser = function (e) {
g_oIdCounter.Set_UserId("" + e);
};
this.CoAuthoringApi.onStartCoAuthoring = function (isStartEvent) {
if (t.ParcedDocument) {
CollaborativeEditing.Start_CollaborationEditing();
t.WordControl.m_oLogicDocument.DrawingDocument.Start_CollaborationEditing();
if (true != History.Is_Clear()) {
CollaborativeEditing.Apply_Changes();
CollaborativeEditing.Send_Changes();
} else {
// Изменений нет, но нужно сбросить lock
t.CoAuthoringApi.unLockDocument(false);
}
} else
t.isStartCoAuthoringOnEndLoad = true;
};
this.CoAuthoringApi.onEndCoAuthoring = function (isStartEvent) {
CollaborativeEditing.End_CollaborationEditing();
if (false != t.WordControl.m_oLogicDocument.DrawingDocument.IsLockObjectsEnable)
{
t.WordControl.m_oLogicDocument.DrawingDocument.IsLockObjectsEnable = false;
t.WordControl.m_oLogicDocument.DrawingDocument.FirePaint();
}
};
this.CoAuthoringApi.onFirstConnect = function() {
if (t.DocInfo && t.DocInfo.get_Id()) {
var rData = {
"c": "getsettings",
"id": t.DocInfo.get_Id(),
"userid": t.DocInfo.get_UserId(),
"format": t.DocInfo.get_Format(),
"vkey": t.DocInfo.get_VKey(),
"editorid": c_oEditorId.Presentation
};
t.advancedOptionsAction = c_oAscAdvancedOptionsAction.Perm;
sendCommand2(t, null, rData);
this.CoAuthoringApi.onFirstLoadChangesEnd = function() {
t.asyncServerIdEndLoaded();
};
this.CoAuthoringApi.onSpellCheckInit = function(e) {
t.SpellCheckUrl = e;
// ToDo Init SpellCheck
};
this.CoAuthoringApi.onSetIndexUser = function(e) {
g_oIdCounter.Set_UserId('' + e);
};
this.CoAuthoringApi.onStartCoAuthoring = function(isStartEvent) {
if (t.ParcedDocument) {
CollaborativeEditing.Start_CollaborationEditing();
t.WordControl.m_oLogicDocument.DrawingDocument.Start_CollaborationEditing();
if (true != History.Is_Clear()) {
CollaborativeEditing.Apply_Changes();
CollaborativeEditing.Send_Changes();
} else {
// Изменений нет, но нужно сбросить lock
t.CoAuthoringApi.unLockDocument(false);
}
} else {
// Фиктивный режим, фактически без документа
var asc_CAscEditorPermissions = window["Asc"].asc_CAscEditorPermissions;
t.asc_fireCallback("asc_onGetEditorPermissions", new asc_CAscEditorPermissions());
// Фиктивно инициализируем
t.SpellCheckUrl = window['g_cAscSpellCheckUrl'] ? window['g_cAscSpellCheckUrl'] : '';
t.isStartCoAuthoringOnEndLoad = true;
}
};
this.CoAuthoringApi.onEndCoAuthoring = function(isStartEvent) {
CollaborativeEditing.End_CollaborationEditing();
if (false != t.WordControl.m_oLogicDocument.DrawingDocument.IsLockObjectsEnable) {
t.WordControl.m_oLogicDocument.DrawingDocument.IsLockObjectsEnable = false;
t.WordControl.m_oLogicDocument.DrawingDocument.FirePaint();
}
};
this.CoAuthoringApi.onFirstConnect = function() {
t.isOnFirstConnectEnd = true;
t._sendLicenseInfo();
};
/**
* Event об отсоединении от сервера
* @param {jQuery} e event об отсоединении с причиной
......@@ -500,12 +492,6 @@ asc_docs_api.prototype._coAuthoringInit = function () {
if (inputWrap["data"]) {
var input = inputWrap["data"];
switch (input["type"]) {
case 'getsettings':
{
t.advancedOptionsAction = c_oAscAdvancedOptionsAction.None;
t.asc_getEditorPermissionsCallback(input);
}
break;
case 'open':
{
switch (input["status"]) {
......@@ -623,7 +609,6 @@ asc_docs_api.prototype._onUpdateDocumentCanSave = function () {
// Update user alive
asc_docs_api.prototype.setUserAlive = function () {
this.CoAuthoringApi.setUserAlive();
};
///////////////////////////////////////////
......@@ -713,40 +698,28 @@ asc_docs_api.prototype.Init = function()
{
this.WordControl.Init();
};
asc_docs_api.prototype.asc_getEditorPermissions = function() {
asc_docs_api.prototype.asc_getEditorPermissions = function(licenseUrl) {
var t = this;
if (this.DocInfo && this.DocInfo.get_Id()) {
CheckLicense(licenseUrl, function (err, res) {
t._onCheckLicenseEnd(err, res);
});
} else {
// Фиктивный вызов
this._onCheckLicenseEnd(true, false);
}
this._coAuthoringInit();
};
asc_docs_api.prototype.asc_getLicense = function () {
var t = this;
var rdata = {
"c" : "getlicense"
};
//todo
sendCommand2(function (response) {t._onGetLicense(response);}, _sendCommandCallback, rdata);
asc_docs_api.prototype._onCheckLicenseEnd = function(err, res) {
this.licenseResult = {err: err, res: res};
this._sendLicenseInfo();
};
asc_docs_api.prototype.asc_getEditorPermissionsCallback = function(response) {
if (null != response && "getsettings" == response["type"]) {
var oSettings = response["data"];
//Set up spellcheker service
this.SpellCheckUrl = oSettings['g_cAscSpellCheckUrl'];
var asc_CAscEditorPermissions = window["Asc"].asc_CAscEditorPermissions;
var oEditorPermissions = new asc_CAscEditorPermissions(oSettings);
this.asc_fireCallback("asc_onGetEditorPermissions", oEditorPermissions);
this.CoAuthoringApi.setPingSettings(oSettings['TrackingInterval'], oEditorPermissions.asc_getCanLicense());
}
};
asc_docs_api.prototype._onGetLicense = function (response) {
if (null != response && "getlicense" == response.type){
var oSettings = JSON.parse(response.data);
var oLicense = (null != oSettings) ? new window["Asc"].asc_CAscLicense(oSettings) : null;
this.asc_fireCallback("asc_onGetLicense", oLicense);
}
asc_docs_api.prototype._sendLicenseInfo = function() {
if (null !== this.licenseResult && this.isOnFirstConnectEnd) {
var oResult = new window['Asc'].asc_CAscEditorPermissions();
oResult.asc_setCanLicense(this.licenseResult.res);
this.asc_fireCallback('asc_onGetEditorPermissions', oResult);
}
};
asc_docs_api.prototype.asc_setDocInfo = function(c_DocInfo)
......
......@@ -27,9 +27,6 @@ asc_docs_api.prototype['getSelectedElements'] = asc_docs_api.prototype.getSelect
asc_docs_api.prototype['sync_ChangeLastSelectedElement'] = asc_docs_api.prototype.sync_ChangeLastSelectedElement;
asc_docs_api.prototype['Init'] = asc_docs_api.prototype.Init;
asc_docs_api.prototype['asc_getEditorPermissions'] = asc_docs_api.prototype.asc_getEditorPermissions;
asc_docs_api.prototype['asc_getLicense'] = asc_docs_api.prototype.asc_getLicense;
asc_docs_api.prototype['asc_getEditorPermissionsCallback'] = asc_docs_api.prototype.asc_getEditorPermissionsCallback;
asc_docs_api.prototype['_onGetLicense'] = asc_docs_api.prototype._onGetLicense;
asc_docs_api.prototype['asc_setDocInfo'] = asc_docs_api.prototype.asc_setDocInfo;
asc_docs_api.prototype['asc_setLocale'] = asc_docs_api.prototype.asc_setLocale;
asc_docs_api.prototype['LoadDocument'] = asc_docs_api.prototype.LoadDocument;
......
......@@ -22,6 +22,7 @@ require.config({
jmousewheel : '../vendor/perfect-scrollbar/src/jquery.mousewheel',
xregexp : '../vendor/xregexp/xregexp-all-min',
sockjs : '../vendor/sockjs/sockjs.min',
jsziputils : '../vendor/jszip-utils/jszip-utils.min',
api : 'api/documents/api',
core : 'common/main/lib/core/application',
notification : 'common/main/lib/core/NotificationCenter',
......@@ -86,7 +87,8 @@ require([
'api',
'analytics',
'gateway',
'locale'
'locale',
'jsziputils'
], function (Backbone, Bootstrap, Core) {
Backbone.history.start();
......
......@@ -231,6 +231,7 @@
<link rel="stylesheet" type="text/css" href="../../../vendor/perfect-scrollbar/src/perfect-scrollbar.css" />
<script type="text/javascript" src="../../../vendor/perfect-scrollbar/src/jquery.mousewheel.js"></script>
<script type="text/javascript" src="../../../vendor/perfect-scrollbar/src/perfect-scrollbar.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/3rdparty/jsrsasign/jsrsasign-latest-all-min.js"></script>
<script type="text/javascript">
window.g_debug_mode = true;
......@@ -251,8 +252,6 @@
<script type="text/javascript" src="../../../../OfficeWeb/Common/apiCommon.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/downloaderfiles.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/docscoapicommon.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/3rdparty/Underscore/underscore-min.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/3rdparty/Sockjs/sockjs-0.3.min.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/docscoapi.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/wordcopypaste.js"></script>
......
......@@ -417,6 +417,11 @@ function asc_docs_api(name)
// Тип состояния на данный момент (сохранение, открытие или никакое)
this.advancedOptionsAction = c_oAscAdvancedOptionsAction.None;
// Результат получения лицензии
this.licenseResult = null;
// Подключились ли уже к серверу
this.isOnFirstConnectEnd = false;
// CoAuthoring and Chat
this.User = undefined;
......@@ -714,43 +719,32 @@ asc_docs_api.prototype.Init = function()
{
this.WordControl.Init();
};
asc_docs_api.prototype.asc_getEditorPermissions = function() {
asc_docs_api.prototype.asc_getEditorPermissions = function(licenseUrl) {
var t = this;
if (this.DocInfo && this.DocInfo.get_Id()) {
CheckLicense(licenseUrl, function (err, res) {
t._onCheckLicenseEnd(err, res);
});
} else {
// Фиктивный вызов
this._onCheckLicenseEnd(true, false);
}
this._coAuthoringInit();
};
asc_docs_api.prototype.asc_getLicense = function ()
{
var t = this;
var rdata = {
"c" : "getlicense"
};
//todo
sendCommand2(function (response) {t._onGetLicense(response);}, _sendCommandCallback, rdata);
asc_docs_api.prototype._onCheckLicenseEnd = function(err, res) {
this.licenseResult = {err: err, res: res};
this._sendLicenseInfo();
};
asc_docs_api.prototype.asc_getEditorPermissionsCallback = function(response) {
if (null != response && "getsettings" == response["type"]) {
var oSettings = response["data"];
//Set up spellcheker service
this.SpellCheckUrl = oSettings['g_cAscSpellCheckUrl'];
this._coSpellCheckInit();
var asc_CAscEditorPermissions = window["Asc"].asc_CAscEditorPermissions;
var oEditorPermissions = new asc_CAscEditorPermissions(oSettings);
this.asc_fireCallback("asc_onGetEditorPermissions", oEditorPermissions);
this.CoAuthoringApi.setPingSettings(oSettings['TrackingInterval'], oEditorPermissions.asc_getCanLicense());
}
asc_docs_api.prototype._sendLicenseInfo = function() {
if (null !== this.licenseResult && this.isOnFirstConnectEnd) {
var oResult = new window['Asc'].asc_CAscEditorPermissions();
oResult.asc_setCanLicense(this.licenseResult.res);
this.asc_fireCallback('asc_onGetEditorPermissions', oResult);
}
};
asc_docs_api.prototype._onGetLicense = function (response) {
if (null != response && "getlicense" == response.type){
var oSettings = JSON.parse(response.data);
var oLicense = (null != oSettings) ? new window["Asc"].asc_CAscLicense(oSettings) : null;
this.asc_fireCallback("asc_onGetLicense", oLicense);
}
};
asc_docs_api.prototype.asc_setDocInfo = function(c_DocInfo) {
if (c_DocInfo) {
this.DocInfo = c_DocInfo;
......@@ -1305,13 +1299,16 @@ asc_docs_api.prototype._coAuthoringInit = function()
if (!bFirstLoad && t.bInit_word_control)
t.sync_CollaborativeChanges();
};
this.CoAuthoringApi.onFirstLoadChangesEnd = function () {
t.asyncServerIdEndLoaded ();
};
this.CoAuthoringApi.onSetIndexUser = function (e)
{
g_oIdCounter.Set_UserId("" + e);
};
this.CoAuthoringApi.onFirstLoadChangesEnd = function() {
t.asyncServerIdEndLoaded();
};
this.CoAuthoringApi.onSpellCheckInit = function(e) {
t.SpellCheckUrl = e;
t._coSpellCheckInit();
};
this.CoAuthoringApi.onSetIndexUser = function(e) {
g_oIdCounter.Set_UserId('' + e);
};
this.CoAuthoringApi.onStartCoAuthoring = function (isStartEvent) {
CollaborativeEditing.Start_CollaborationEditing();
t.asc_setDrawCollaborationMarks(true);
......@@ -1341,26 +1338,8 @@ asc_docs_api.prototype._coAuthoringInit = function()
editor.asc_setDrawCollaborationMarks(false);
};
this.CoAuthoringApi.onFirstConnect = function() {
if (t.DocInfo && t.DocInfo.get_Id()) {
var rData = {
"c": "getsettings",
"id": t.DocInfo.get_Id(),
"userid": t.DocInfo.get_UserId(),
"format": t.DocInfo.get_Format(),
"vkey": t.DocInfo.get_VKey(),
"editorid": c_oEditorId.Word
};
t.advancedOptionsAction = c_oAscAdvancedOptionsAction.Perm;
sendCommand2(t, null, rData);
} else {
// Фиктивный режим, фактически без документа
var asc_CAscEditorPermissions = window["Asc"].asc_CAscEditorPermissions;
t.asc_fireCallback("asc_onGetEditorPermissions", new asc_CAscEditorPermissions());
// Фиктивно инициализируем
t.SpellCheckUrl = window['g_cAscSpellCheckUrl'] ? window['g_cAscSpellCheckUrl'] : '';
t._coSpellCheckInit();
}
t.isOnFirstConnectEnd = true;
t._sendLicenseInfo();
};
/**
* Event об отсоединении от сервера
......@@ -1386,11 +1365,6 @@ asc_docs_api.prototype._coAuthoringInit = function()
if (inputWrap["data"]) {
var input = inputWrap["data"];
switch(input["type"]){
case 'getsettings':{
t.advancedOptionsAction = c_oAscAdvancedOptionsAction.None;
t.asc_getEditorPermissionsCallback(input);
}
break;
case 'reopen':
case 'open': {
switch(input["status"]) {
......@@ -1503,7 +1477,6 @@ asc_docs_api.prototype._onUpdateDocumentCanSave = function () {
// Update user alive
asc_docs_api.prototype.setUserAlive = function () {
this.CoAuthoringApi.setUserAlive();
};
// get functions
......@@ -2934,6 +2907,7 @@ asc_docs_api.prototype.put_TextPrFontSize = function(size)
this.WordControl.m_oLogicDocument.Paragraph_Add( new ParaTextPr( { FontSize : Math.min(size, 100) } ) );
}
};
asc_docs_api.prototype.put_TextPrBold = function(value)
{
if ( false === this.WordControl.m_oLogicDocument.Document_Is_SelectionLocked(changestype_Paragraph_Content) )
......
......@@ -124,9 +124,6 @@ asc_docs_api.prototype['getSelectedElements'] = asc_docs_api.prototype.getSelect
asc_docs_api.prototype['sync_ChangeLastSelectedElement'] = asc_docs_api.prototype.sync_ChangeLastSelectedElement;
asc_docs_api.prototype['Init'] = asc_docs_api.prototype.Init;
asc_docs_api.prototype['asc_getEditorPermissions'] = asc_docs_api.prototype.asc_getEditorPermissions;
asc_docs_api.prototype['asc_getLicense'] = asc_docs_api.prototype.asc_getLicense;
asc_docs_api.prototype['asc_getEditorPermissionsCallback'] = asc_docs_api.prototype.asc_getEditorPermissionsCallback;
asc_docs_api.prototype['_onGetLicense'] = asc_docs_api.prototype._onGetLicense;
asc_docs_api.prototype['asc_setDocInfo'] = asc_docs_api.prototype.asc_setDocInfo;
asc_docs_api.prototype['asc_setLocale'] = asc_docs_api.prototype.asc_setLocale;
asc_docs_api.prototype['LoadDocument'] = asc_docs_api.prototype.LoadDocument;
......
......@@ -238,6 +238,7 @@
<script type="text/javascript" src="../../../../OfficeWeb/Common/3rdparty/sockjs/sockjs-0.3.min.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/3rdparty/xregexp/xregexp-all-min.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/3rdparty/underscore/underscore-min.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/3rdparty/jsrsasign/jsrsasign-latest-all-min.js"></script>
<!-- sdk -->
<script type="text/javascript" src="../../../../OfficeWeb/Common/AllFonts.js"></script>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment