diff options
Diffstat (limited to 'www/js')
| -rw-r--r-- | www/js/DataModel.js | 52 | ||||
| -rw-r--r-- | www/js/ModalCtrl.js | 28 | ||||
| -rw-r--r-- | www/js/MontageCtrl.js | 32 | ||||
| -rw-r--r-- | www/js/app.js | 20 |
4 files changed, 132 insertions, 0 deletions
diff --git a/www/js/DataModel.js b/www/js/DataModel.js index 44992a3f..48a09b52 100644 --- a/www/js/DataModel.js +++ b/www/js/DataModel.js @@ -280,6 +280,56 @@ angular.module('zmApp.controllers').service('ZMDataModel', ['$http', '$q', '$ion { displayBanner (mytype, mytext, myinterval, mytimer); }, + + //----------------------------------------------------------------------------- + // Grabs the computed auth key for streaming + // FIXME: Currently a hack - does a screen parse - convert to API based support + //----------------------------------------------------------------------------- + + getAuthKey: function () + { + var d=$q.defer(); + // Skipping monitor number as I only need an auth key + // so no need to generate an image + var myurl =loginData.url+"/index.php?view=watch"; + console.log ("Getting auth from " + myurl); + $http.get (myurl) + .then (function (success) { + // console.log ("**** RESULT IS " + JSON.stringify(success)); + // Look for auth= + var auth = success.data.match ("auth=(.*?)&"); + if (auth && (auth[1] != null)) + { + zmLog ("DataModel: Extracted a stream authentication key of: " + auth[1]); + d.resolve("&auth="+auth[1]); + } + else + { + zmLog ("DataModel: Did not find a stream auth key, looking for user="); + auth = success.data.match ("user=(.*?)&"); + if (auth && (auth[1] != null)) + { + zmLog ("DataModel: Found simple stream auth mode (user=)"); + d.resolve("&user="+loginData.username+"&pass="+loginData.password); + } + else + { + zmLog ("Data Model: Did not find any stream mode of auth"); + d.resolve(""); + } + return (d.promise); + } + + }, + function (error) { + zmLog ("DataModel: Error resolving auth key " + JSON.stringify(error)); + d.resolve (""); + return (d.promise); + }); + return (d.promise); + + }, + //----------------------------------------------------------------------------- // This function returns the numdigits for padding capture images //----------------------------------------------------------------------------- @@ -298,6 +348,7 @@ angular.module('zmApp.controllers').service('ZMDataModel', ['$http', '$q', '$ion zmLog ("ZM_EVENT_IMAGE_DIGITS is " + data.config.Value); configParams.ZM_EVENT_IMAGE_DIGITS = data.config.Value; d.resolve(configParams.ZM_EVENT_IMAGE_DIGITS); + return (d.promise); }) .error (function(err) { @@ -306,6 +357,7 @@ angular.module('zmApp.controllers').service('ZMDataModel', ['$http', '$q', '$ion // FIXME: take a plunge and keep it at 5? configParams.ZM_EVENT_IMAGE_DIGITS = 5; d.resolve(configParams.ZM_EVENT_IMAGE_DIGITS); + return (d.promise); }); } else diff --git a/www/js/ModalCtrl.js b/www/js/ModalCtrl.js index 24926641..3cb2787d 100644 --- a/www/js/ModalCtrl.js +++ b/www/js/ModalCtrl.js @@ -34,6 +34,34 @@ angular.module('zmApp.controllers').controller('ModalCtrl', ['$scope', '$rootSco document.addEventListener("pause", onPause, false); document.addEventListener("resume", onResume, false); + $rootScope.authSession = "undefined"; + $ionicLoading.show({ + template: 'negotiating stream authentication...', + animation: 'fade-in', + showBackdrop: true, + duration: zm.loadingTimeout, + maxWidth: 300, + showDelay: 0 + }); + var ld = ZMDataModel.getLogin(); + ZMDataModel.getAuthKey() + .then(function(success) + { + $ionicLoading.hide(); + $rootScope.authSession = success; + ZMDataModel.zmLog ("Modal: Stream authentication construction: " + $rootScope.authSession); + + }, + function (error) + { + + $ionicLoading.hide(); + console.log (error); + //$rootScope.authSession=""; + ZMDataModel.zmLog ("Modal: Error returned Stream authentication construction. Retaining old value of: " + $rootScope.authSession); + }); + + $scope.radialMenuOptions = { content: '', diff --git a/www/js/MontageCtrl.js b/www/js/MontageCtrl.js index e7941ccf..26e5af6b 100644 --- a/www/js/MontageCtrl.js +++ b/www/js/MontageCtrl.js @@ -158,6 +158,38 @@ angular.module('zmApp.controllers').controller('zmApp.MontageCtrl', ['$scope', ' $scope.LoginData = ZMDataModel.getLogin(); $scope.monLimit = $scope.LoginData.maxMontage; console.log("********* Inside Montage Ctrl, MAX LIMIT=" + $scope.monLimit); + + + $rootScope.authSession = "undefined"; + $ionicLoading.show({ + template: 'negotiating stream authentication...', + animation: 'fade-in', + showBackdrop: true, + duration: zm.loadingTimeout, + maxWidth: 300, + showDelay: 0 + }); + + + var ld = ZMDataModel.getLogin(); + ZMDataModel.getAuthKey() + .then(function(success) + { + $ionicLoading.hide(); + console.log (success); + $rootScope.authSession =success; + ZMDataModel.zmLog ("Stream authentication construction: " + + $rootScope.authSession); + + }, + function (error) + { + + $ionicLoading.hide(); + console.log (error); + //$rootScope.authSession=""; + ZMDataModel.zmLog ("Modal: Error returned Stream authentication construction. Retaining old value of: " + $rootScope.authSession); + }); // I was facing a lot of problems with Chrome/crosswalk getting stuck with diff --git a/www/js/app.js b/www/js/app.js index bbcc50a8..20066d2d 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -370,6 +370,26 @@ angular.module('zmApp', [ d.reject("Login Error"); } + + // Now go ahead and re-get auth key + $rootScope.authSession="undefined"; + var ld = ZMDataModel.getLogin(); + ZMDataModel.getAuthKey() + .then(function(success) + { + + console.log (success); + $rootScope.authSession = success; + ZMDataModel.zmLog ("Stream authentication construction: " + + $rootScope.authSession); + + }, + function (error) + { + console.log (error); + //$rootScope.authSession=""; + ZMDataModel.zmLog ("Modal: Error returned Stream authentication construction. Retaining old value of: " + $rootScope.authSession); + }); return (d.promise); |
