Fixes extension version parsing. Increases extension version.
This commit is contained in:
parent
002c984415
commit
e50be0e3b9
|
@ -11,5 +11,5 @@ var config = {
|
||||||
bosh: '//lambada.jitsi.net/http-bind', // FIXME: use xep-0156 for that
|
bosh: '//lambada.jitsi.net/http-bind', // FIXME: use xep-0156 for that
|
||||||
desktopSharing: 'ext', // Desktop sharing method. Can be set to 'ext', 'webrtc' or false to disable.
|
desktopSharing: 'ext', // Desktop sharing method. Can be set to 'ext', 'webrtc' or false to disable.
|
||||||
chromeExtensionId: 'diibjkoicjeejcmhdnailmkgecihlobk', // Id of desktop streamer Chrome extension
|
chromeExtensionId: 'diibjkoicjeejcmhdnailmkgecihlobk', // Id of desktop streamer Chrome extension
|
||||||
minChromeExtVersion: '0.0.10' // Required version of Chrome extension
|
minChromeExtVersion: '0.1' // Required version of Chrome extension
|
||||||
};
|
};
|
|
@ -202,7 +202,7 @@ function checkExtInstalled(isInstalledCallback) {
|
||||||
// Check installed extension version
|
// Check installed extension version
|
||||||
var extVersion = response.version;
|
var extVersion = response.version;
|
||||||
console.log('Extension version is: '+extVersion);
|
console.log('Extension version is: '+extVersion);
|
||||||
var updateRequired = extVersion < config.minChromeExtVersion;
|
var updateRequired = isUpdateRequired(config.minChromeExtVersion, extVersion);
|
||||||
if(updateRequired) {
|
if(updateRequired) {
|
||||||
alert(
|
alert(
|
||||||
'Jitsi Desktop Streamer requires update. ' +
|
'Jitsi Desktop Streamer requires update. ' +
|
||||||
|
@ -214,6 +214,50 @@ function checkExtInstalled(isInstalledCallback) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether extension update is required.
|
||||||
|
* @param minVersion minimal required version
|
||||||
|
* @param extVersion current extension version
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
function isUpdateRequired(minVersion, extVersion)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var s1 = minVersion.split('.');
|
||||||
|
var s2 = extVersion.split('.');
|
||||||
|
|
||||||
|
var len = Math.max(s1.length, s2.length);
|
||||||
|
for(var i = 0; i < len; i++)
|
||||||
|
{
|
||||||
|
var n1=0,n2=0;
|
||||||
|
|
||||||
|
if(i < s1.length)
|
||||||
|
n1 = parseInt(s1[i]);
|
||||||
|
if(i < s2.length)
|
||||||
|
n2 = parseInt(s2[i]);
|
||||||
|
|
||||||
|
if(isNaN(n1) || isNaN(n2))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if(n1 !== n2)
|
||||||
|
{
|
||||||
|
return n1 > n2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// will happen if boths version has identical numbers in
|
||||||
|
// their components (even if one of them is longer, has more components)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch(e)
|
||||||
|
{
|
||||||
|
console.error("Failed to parse extension version", e);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function doGetStreamFromExtension(streamCallback, failCallback) {
|
function doGetStreamFromExtension(streamCallback, failCallback) {
|
||||||
// Sends 'getStream' msg to the extension. Extension id must be defined in the config.
|
// Sends 'getStream' msg to the extension. Extension id must be defined in the config.
|
||||||
chrome.runtime.sendMessage(
|
chrome.runtime.sendMessage(
|
||||||
|
|
Loading…
Reference in New Issue