[HAM] Process API removal change
[platform/core/api/webapi-plugins.git] / src / humanactivitymonitor / humanactivitymonitor_api.js
index 2271e4a..ab22568 100755 (executable)
@@ -62,71 +62,11 @@ var PedometerStepStatus = {
     UNKNOWN: 'UNKNOWN'
 };
 
-var ActivityRecognitionType = {
-    STATIONARY: 'STATIONARY',
-    WALKING: 'WALKING',
-    RUNNING: 'RUNNING',
-    IN_VEHICLE: 'IN_VEHICLE'
-};
-
-var ActivityAccuracy = {
-    LOW: 'LOW',
-    MEDIUM: 'MEDIUM',
-    HIGH: 'HIGH'
-};
-
 var SleepStatus = {
     ASLEEP: 'ASLEEP',
     AWAKE: 'AWAKE'
 };
 
-var GestureType = {
-    GESTURE_DOUBLE_TAP: 'GESTURE_DOUBLE_TAP',
-    GESTURE_MOVE_TO_EAR: 'GESTURE_MOVE_TO_EAR',
-    GESTURE_NO_MOVE: 'GESTURE_NO_MOVE',
-    GESTURE_PICK_UP: 'GESTURE_PICK_UP',
-    GESTURE_SHAKE: 'GESTURE_SHAKE',
-    GESTURE_SNAP: 'GESTURE_SNAP',
-    GESTURE_TILT: 'GESTURE_TILT',
-    GESTURE_TURN_FACE_DOWN: 'GESTURE_TURN_FACE_DOWN',
-    GESTURE_WRIST_UP: 'GESTURE_WRIST_UP'
-};
-
-function convertActivityData(type, data) {
-    switch (type) {
-    case HumanActivityType.PEDOMETER:
-        return new HumanActivityPedometerData(data);
-    case ACCUMULATIVE_PEDOMETER_DATA:
-        return new HumanActivityAccumulativePedometerData(data);
-    case HumanActivityType.HRM:
-        return new HumanActivityHRMData(data);
-    case HumanActivityType.GPS:
-        var gpsInfo = [];
-        for (var i = 0, max = data.gpsInfo.length; i < max; i++) {
-            gpsInfo.push(new HumanActivityGPSInfo(data.gpsInfo[i]));
-        }
-        return new HumanActivityGPSInfoArray(gpsInfo);
-    case HumanActivityType.SLEEP_MONITOR:
-        return new HumanActivitySleepMonitorData(data);
-    case HumanActivityType.SLEEP_DETECTOR:
-        return new HumanActivitySleepDetectorData(data);
-    case HumanActivityType.STRESS_MONITOR:
-        return new HumanActivityStressMonitorData(data);
-    default:
-        utils_.error('Uknown human activity type: ' + type);
-    }
-}
-
-function createRecorderData(func, data) {
-    var array = [];
-
-    data.forEach(function(d) {
-        array.push(new func(d));
-    });
-
-    return array;
-}
-
 function convertActivityRecorderData(type, data) {
     var func = undefined;
     switch (type) {
@@ -195,61 +135,6 @@ function StressMonitorDataRange(label, min, max) {
     });
 }
 
-function ActivityRecognitionListenerManager() {
-    this.listeners = {};
-    this.nextId = 1;
-    this.nativeSet = false;
-    this.native = native_;
-    this.listenerName = 'ActivityRecognitionListener';
-}
-
-ActivityRecognitionListenerManager.prototype.onListener = function(data) {
-    var watchId = data.watchId;
-
-    if (this.listeners[watchId]) {
-        if (native_.isFailure(data)) {
-            native_.callIfPossible(
-                this.listeners[watchId].errorCallback,
-                native_.getErrorObject(data)
-            );
-            return;
-        }
-
-        native_.callIfPossible(
-            this.listeners[watchId].listener,
-            new HumanActivityRecognitionData(native_.getResultObject(data))
-        );
-    }
-};
-
-ActivityRecognitionListenerManager.prototype.addListener = function(
-    watchId,
-    listener,
-    errorCallback
-) {
-    this.listeners[watchId] = {
-        listener: listener,
-        errorCallback: errorCallback
-    };
-
-    if (!this.nativeSet) {
-        this.native.addListener(this.listenerName, this.onListener.bind(this));
-        this.nativeSet = true;
-    }
-};
-
-ActivityRecognitionListenerManager.prototype.removeListener = function(watchId) {
-    if (this.listeners.hasOwnProperty(watchId)) {
-        delete this.listeners[watchId];
-        if (type_.isEmptyObject(this.listeners)) {
-            this.native.removeListener(this.listenerName);
-            this.nativeSet = false;
-        }
-    }
-};
-
-var activityRecognitionListener = new ActivityRecognitionListenerManager();
-
 function HumanActivityMonitorManager() {}
 
 HumanActivityMonitorManager.prototype.getHumanActivityData = function(
@@ -526,51 +411,19 @@ HumanActivityMonitorManager.prototype.unsetAccumulativePedometerListener = funct
     accumulativePedometerListener = null;
 };
 
-HumanActivityMonitorManager.prototype.addActivityRecognitionListener = function() {
-    utils_.printDeprecationWarningFor(
-        'HumanActivityMonitorManager.addActivityRecognitionListener()'
-    );
-    var args = validator_.validateArgs(arguments, [
-        { name: 'type', type: types_.ENUM, values: Object.keys(ActivityRecognitionType) },
-        { name: 'listener', type: types_.FUNCTION },
-        { name: 'errorCallback', type: types_.FUNCTION, optional: true, nullable: true }
-    ]);
-
-    var result = native_.call(
-        'HumanActivityMonitorManagerAddActivityRecognitionListener',
-        { type: args.type, listenerId: activityRecognitionListener.listenerName }
-    );
-    if (native_.isFailure(result)) {
-        throw native_.getErrorObject(result);
-    }
-
-    var watchId = result.watchId;
-    activityRecognitionListener.addListener(watchId, args.listener, args.errorCallback);
-
-    return watchId;
-};
-
-HumanActivityMonitorManager.prototype.removeActivityRecognitionListener = function() {
-    utils_.printDeprecationWarningFor(
-        'HumanActivityMonitorManager.removeActivityRecognitionListener()'
+HumanActivityMonitorManager.prototype.addActivityRecognitionListener = function () {
+    throw new WebAPIException(
+        'NotSupportedError',
+        'addActivityRecognitionListener is not longer supported since Tizen 7.0.'
     );
-    var args = validator_.validateArgs(arguments, [
-        { name: 'watchId', type: types_.LONG },
-        { name: 'errorCallback', type: types_.FUNCTION, optional: true, nullable: true }
-    ]);
+}
 
-    var result = native_.call(
-        'HumanActivityMonitorManagerRemoveActivityRecognitionListener',
-        { watchId: args.watchId }
+HumanActivityMonitorManager.prototype.removeActivityRecognitionListener = function () {
+    throw new WebAPIException(
+        'NotSupportedError',
+        'removeActivityRecognitionListener is not longer supported since Tizen 7.0.'
     );
-    if (native_.isFailure(result)) {
-        setTimeout(function() {
-            native_.callIfPossible(args.errorCallback, native_.getErrorObject(result));
-        }, 0);
-        return;
-    }
-    activityRecognitionListener.removeListener(args.watchId);
-};
+}
 
 HumanActivityMonitorManager.prototype.startRecorder = function() {
     var args = validator_.validateArgs(arguments, [
@@ -685,187 +538,24 @@ HumanActivityMonitorManager.prototype.readRecorderData = function() {
 };
 
 HumanActivityMonitorManager.prototype.isGestureSupported = function() {
-    utils_.printDeprecationWarningFor('HumanActivityMonitorManager.isGestureSupported()');
-    var args = validator_.validateArgs(arguments, [
-        {
-            name: 'type',
-            type: types_.ENUM,
-            values: Object.keys(GestureType)
-        }
-    ]);
-
-    var callArgs = {};
-    callArgs.type = args.type;
-
-    var result = native_.callSync('GestureManagerIsGestureSupported', callArgs);
-    if (native_.isFailure(result)) {
-        throw native_.getErrorObject(result);
-    }
-
-    return native_.getResultObject(result);
-};
-
-function GestureListenerManager(native, listenerName) {
-    this.listeners = {};
-    //below maps keep information about number of registered listeners for the specific
-    //type there are two maps as one keeps information about listeners which should be
-    //always called and one keeps information about number of the listeners which should
-    //be called only if power-saving mode is off
-    this.typeCountMapDefault = {};
-    this.typeCountMapAlwaysOn = {};
-    this.nextId = 1;
-    this.nativeSet = false;
-    this.native = native;
-    this.listenerName = listenerName;
-    for (var type in GestureType) {
-        this.typeCountMapDefault[type] = this.typeCountMapAlwaysOn[type] = 0;
-    }
-}
-
-GestureListenerManager.prototype.onListenerCalled = function(msg) {
-    var d = undefined;
-    var result = undefined;
-    var alwaysOn = msg.alwaysOn;
-    switch (msg.action) {
-    case 'ondetect':
-        d = new GestureData(this.native.getResultObject(msg));
-        break;
-    case 'onerror':
-        d = this.native.getErrorObject(msg);
-        break;
-    default:
-        utils_.log('Unknown mode: ' + msg.action);
-        return;
-    }
-
-    for (var watchId in this.listeners) {
-        if (this.listeners.hasOwnProperty(watchId)) {
-            var listener = this.listeners[watchId];
-            var call = alwaysOn ? listener.alwaysOn : true;
-            if (call && listener[msg.action]) {
-                listener[msg.action](d);
-            }
-        }
-    }
-};
-
-GestureListenerManager.prototype.addListener = function(
-    successCb,
-    errorCb,
-    type,
-    alwaysOn
-) {
-    var listener = {
-        type: type,
-        alwaysOn: converter_.toBoolean(alwaysOn),
-        ondetect: successCb,
-        onerror: errorCb
-    };
-
-    var typeCountMap = alwaysOn ? this.typeCountMapAlwaysOn : this.typeCountMapDefault;
-    if (typeCountMap[type] === 0) {
-        var result = this.native.callSync(
-            'GestureManagerAddGestureRecognitionListener',
-            listener
-        );
-        if (this.native.isFailure(result)) {
-            throw this.native.getErrorObject(result);
-        }
-    }
-
-    typeCountMap[type]++;
-    var id = this.nextId++;
-    this.listeners[id] = listener;
-
-    if (!this.nativeSet) {
-        this.native.addListener(this.listenerName, this.onListenerCalled.bind(this));
-        this.nativeSet = true;
-    }
-
-    return id;
-};
-
-GestureListenerManager.prototype.removeListener = function(watchId) {
-    if (this.listeners.hasOwnProperty(watchId)) {
-        var listener = this.listeners[watchId];
-        var typeCountMap = listener.alwaysOn
-            ? this.typeCountMapAlwaysOn
-            : this.typeCountMapDefault;
-
-        if (typeCountMap[listener.type] === 1) {
-            var result = this.native.callSync(
-                'GestureManagerRemoveGestureRecognitionListener',
-                listener
-            );
-            if (this.native.isFailure(result)) {
-                throw this.native.getErrorObject(result);
-            }
-        }
-
-        delete this.listeners[watchId];
-        typeCountMap[listener.type]--;
-    }
-
-    if (this.nativeSet && type_.isEmptyObject(this.listeners)) {
-        this.native.removeListener(this.listenerName);
-        this.nativeSet = false;
-    }
+    throw new WebAPIException(
+        'NotSupportedError',
+        'isGestureSupported is not longer supported since Tizen 7.0.'
+    );
 };
 
-var GESTURE_RECOGNITION_LISTENER = 'GestureRecognitionListener';
-var gestureRecognitionListener = new GestureListenerManager(
-    native_,
-    GESTURE_RECOGNITION_LISTENER
-);
-
 HumanActivityMonitorManager.prototype.addGestureRecognitionListener = function() {
-    utils_.printDeprecationWarningFor(
-        'HumanActivityMonitorManager.addGestureRecognitionListener()'
-    );
-    var args = validator_.validateArgs(arguments, [
-        {
-            name: 'type',
-            type: types_.ENUM,
-            values: Object.keys(GestureType)
-        },
-        {
-            name: 'eventCallback',
-            type: types_.FUNCTION
-        },
-        {
-            name: 'errorCallback',
-            type: types_.FUNCTION,
-            optional: true,
-            nullable: true
-        },
-        {
-            name: 'alwaysOn',
-            type: types_.BOOLEAN,
-            optional: true,
-            nullable: true
-        }
-    ]);
-
-    return gestureRecognitionListener.addListener(
-        args.eventCallback,
-        args.errorCallback,
-        args.type,
-        args.alwaysOn
+    throw new WebAPIException(
+        'NotSupportedError',
+        'addGestureRecognitionListener is not longer supported since Tizen 7.0.'
     );
 };
 
 HumanActivityMonitorManager.prototype.removeGestureRecognitionListener = function() {
-    utils_.printDeprecationWarningFor(
-        'HumanActivityMonitorManager.removeGestureRecognitionListener()'
+    throw new WebAPIException(
+        'NotSupportedError',
+        'removeGestureRecognitionListener is not longer supported since Tizen 7.0.'
     );
-    var args = validator_.validateArgs(arguments, [
-        {
-            name: 'watchId',
-            type: types_.LONG
-        }
-    ]);
-
-    gestureRecognitionListener.removeListener(args.watchId);
 };
 
 function StressMonitorListenerManager() {
@@ -1034,15 +724,6 @@ function HumanActivityHRMData(data) {
 HumanActivityHRMData.prototype = new HumanActivityData();
 HumanActivityHRMData.prototype.constructor = HumanActivityHRMData;
 
-function HumanActivityRecognitionData(data) {
-    SetReadOnlyProperty(this, 'type', data.type);
-    SetReadOnlyProperty(this, 'timestamp', data.timestamp);
-    SetReadOnlyProperty(this, 'accuracy', data.accuracy);
-}
-
-HumanActivityRecognitionData.prototype = new HumanActivityData();
-HumanActivityRecognitionData.prototype.constructor = HumanActivityRecognitionData;
-
 function HumanActivityGPSInfo(data) {
     SetReadOnlyProperty(this, 'latitude', data.latitude);
     SetReadOnlyProperty(this, 'longitude', data.longitude);
@@ -1129,22 +810,6 @@ function HumanActivityRecorderPressureData(data) {
     SetReadOnlyProperty(this, 'average', data.average);
 }
 
-function GestureData(data) {
-    if (data) {
-        SetReadOnlyProperty(this, 'type', data.type);
-        SetReadOnlyProperty(this, 'event', data.event);
-        SetReadOnlyProperty(this, 'timestamp', data.timestamp);
-
-        if (data.type === 'GESTURE_TILT') {
-            SetReadOnlyProperty(this, 'x', data.x);
-            SetReadOnlyProperty(this, 'y', data.y);
-        } else {
-            SetReadOnlyProperty(this, 'x', null);
-            SetReadOnlyProperty(this, 'y', null);
-        }
-    }
-}
-
 HumanActivityRecorderPressureData.prototype = new HumanActivityRecorderData();
 // prettier-ignore
 HumanActivityRecorderPressureData.prototype.constructor =