angular.module('app.services')
// =========================================================================
// Utils Service
// =========================================================================
  .factory('Util', ['$log', '$timeout', '$q', '$http', 'dataPersistenceService', 'sparkDataService', 'eventProtocol', '$rootScope', 'propertyCache', function ($log, $timeout, $q, $http, dataPersistenceService, sparkDataService, eventProtocol, $rootScope, propertyCache) {

    var undoAvailable = false;

    return {
      //save to server
      setIpAddress: function (data) {

        return $q(function (resolve, reject) {
          networkinterface.getIPAddress(function (response) {
            console.log("Sync Configuration Response----> ", response);
            propertyCache.setIpAddress(response);
            resolve(response);
          }, function (err) {
            console.log('ERR in gettting configuration data for the factory !', err);
            reject(err);
          })
        });
      },

      setMacAdress: function (data) {
        return $q(function (resolve, reject) {
          window.MacAddress.getMacAddress(
            function (response) {
              console.log("Sync Configuration Response----> ", response);
              propertyCache.setMacAddress(response);
              resolve(response);
            }, function (err) {
              console.log('ERR in gettting configuration data for the factory !', err);
              reject(err);
            }
          );
        });
      },

      setNetworkStatus: function (data) {
        propertyCache.setNetworkStatus(data)
      }


    };
  }]);
