Read the instance settings

@returns {Q.promise} The instance settings
485390
function () {
      var innerSelf = this;

      return self._readFile()
        .then(function (fileContent) {
          return defaults((fileContent.instances || {})[innerSelf._id], self._options.instanceDefaults);
        });
    }
1320739
function readKeys(force) {
    if (!force && options.cacheKeys) {
      return Promise.resolve(cachedKeys);
    }

    return readData().then(function(data) {
      try {
        return Promise.resolve(Object.keys(data));
      } catch(err) {
        return Promise.reject(err);
      }
    });
  }
296966
function () {
    var deferred = Q.defer();

    // store desired capabilities of this session
    this.desiredCapabilities = this.browserData.getDesiredCapabilities(this.browserName, this.config);
    this.browserDefaults = this.browserData.driverDefaults;
    this.browserDefaults.status = this.browserData.getStatusDefaults(this.desiredCapabilities);

    // start a browser session
    this._startBrowserSession(deferred, this.desiredCapabilities, this.browserDefaults);

    return deferred.promise;
  }
841964
function() {
                    if(_loopingInstances[_strLength] > 0 && _loopIsActive) {
                        _loopID = COMPATIBILITY.rAF()(function () {
                            loop();
                        });
                        var timeNew = COMPATIBILITY.now();
                        var timeDelta = timeNew - _loopTimeOld;
                        var lowestInterval;
                        var instance;
                        var instanceOptions;
                        var instanceAutoUpdateAllowed;
                        var instanceAutoUpdateInterval;
                        var now;

                        if (timeDelta > _loopInterval) {
                            _loopTimeOld = timeNew - (timeDelta % _loopInterval);
                            lowestInterval = _loopIntervalDefault;
                            for(var i = 0; i < _loopingInstances[_strLength]; i++) {
                                instance = _loopingInstances[i];
                                if (instance !== undefined) {
                                    instanceOptions = instance.options();
                                    instanceAutoUpdateAllowed = instanceOptions[_strAutoUpdate];
                                    instanceAutoUpdateInterval = MATH.max(1, instanceOptions[_strAutoUpdateInterval]);
                                    now = COMPATIBILITY.now();

                                    if ((instanceAutoUpdateAllowed === true || instanceAutoUpdateAllowed === null) && (now - _loopingInstancesIntervalCache[i]) > instanceAutoUpdateInterval) {
                                        instance.update('auto');
                                        _loopingInstancesIntervalCache[i] = new Date(now += instanceAutoUpdateInterval);
                                    }

                                    lowestInterval = MATH.max(1, MATH.min(lowestInterval, instanceAutoUpdateInterval));
                                }
                            }
                            _loopInterval = lowestInterval;
                        }
                    } else {
                        _loopInterval = _loopIntervalDefault;
                    }
                }
244119
function(success) {
				if (this.ended())
					throw new Error("promise already resolved or rejected");
				this._resolved = true;
				this._paused = false;
				this._initialised = true;
				if (typeof success !== "undefined")
					this._state.success = success;
				var instanceOfError = this._state.success instanceof Error;
				this._state.error = instanceOfError ? this._state.success : this._state.error;
				this._state.success = instanceOfError ? null : this._state.success;
				this._next();
				return this;
			}
340777
function readRequireConfig( file ) {
   'use strict';
   var config = fs.readFileSync( file );
   /*jshint -W054*/
   var evaluate = new Function( 'var window = this;' + config + '; return require || window.require;' );
   return evaluate.call( {} );
}
1084002
function(opt) {
        if ( typeof(Logger.initialized) != "undefined" ) {
            console.debug("Logger instance already exists. Loading it.");
            return getInstance(opt)
        } else {
            Logger.initialized = true;
            Logger.instance = self;
            setDefaultLevels();
        }
    }
1265334
function() {
        try {
            this.set(fs.existsSync(this._stateFile) ? JSON.parse(fs.readFileSync(this._stateFile)) : {});
        } catch (e) {}
    }
760620
function(key, readOptions) {
		var keyReads = stacheKey.reads(key);
		return stacheKey.read(this.templateContext, keyReads, readOptions);
	}
877655
function readINISettings()
    {
        $this->readImageHandlersFromINI();
        $this->readSupportedFormatsFromINI();
        $this->readImageAliasesFromINI();
        $this->readMIMETypeSettingsFromINI();
        $this->readMIMETypeQualitySettingFromINI();
        $this->readConversionRuleSettingsFromINI();
    }
1197176
function () {
  var deferred = Q.defer();
  var parser = new xml2js.Parser();
  fs.readFile(settings.CONFIG_FILE, function (err, data) {
    if (err) {
      deferred.reject(err);
    }
    parser.parseString(data, function (err, result) {
      if (err) {
        deferred.reject(err);
      }
      var projectName = result.widget.name[0];
      deferred.resolve(projectName);
    });
  });
  return deferred.promise;
}
425248
function getSettings (def) {
  var settings = {}
  for (var s in def) {
    if (def.hasOwnProperty(s)) {
      if (s !== 'name' || s !== 'properties') {
        settings[ s ] = def[ s ]
      }
    }
  }
  return settings
}
541101
async function onUIGetSettingsSchema(schemaJson, curSettings) {
    const readJSON = (basename) => {
        return JSON.parse(pi.pluginfs.readFileSync(basename).toString());
    };
    const schemaDefaultJson = readJSON('settings_schema_default.json');
    const schemaWlanJson = readJSON('settings_schema_wlan.json');
    if (!curSettings) curSettings
        = {webapi:{api_filter:{}},mqtt:{},network:{}};

    let setProp = {};// schema_json.properties;
    // API Filters settings are not implemented yet
    let filters = localStorage.getItem('API_FILTERS'
        ,{clientA:{filter:''},clientB:{filter:''},clientC:{filter:''}}); // Sample clients
    for( let clname in filters ){
        setProp[clname] = {
            title: clname+' client allowed path in regexp',
            type: 'string',
        };
        let filter = filters[clname].filter;

        if (filter != null) {
            setProp[clname].default = filter;
        }

        curSettings.webapi.api_filter[clname] = filter;
    }
    schemaJson.properties.webapi.properties.api_filter.properties = setProp;


    return listNetInterfaces().then(([interfaces, bWlanExist]) => {
        let curInterf;
        let curAp;
        if (typeof curSettings.network.interfaces == 'object') {
            for (let k of Object.keys(curSettings.network.interfaces)) {
                curInterf = k;
                if (k.indexOf('wlan')==0) {
                    curAp = curSettings.network.interfaces[k].apname;
                }
            }
        }

        // Previously set interface does not exist any more..
        if (curInterf != undefined && interfaces.indexOf(curInterf)<0) {
            log(`Previously set interface ${curInterf} does not exist now`);
            interfaces.unshift(curInterf);
        }

        interfaces.forEach((interf)=>{
            let prop = {};

            prop[interf] = (interf.indexOf('wlan')==0 ?
                schemaWlanJson : schemaDefaultJson);

            schemaJson.properties.network.properties.interfaces.oneOf.push({
                title: interf,
                type: 'object',
                additionalProperties: false,
                properties: prop,
            });
        });

        if (schemaJson.properties.network.properties.interfaces.oneOf.length==0) {
            throw new Error({error: 'No network available.'});
        }

        if (!bWlanExist) {
            return schemaJson;
        }

        return scanWiFi().then((aps) => {
            const enumap = schemaWlanJson.properties.apname.enum;
            for (const ap of aps) {
                enumap.push(ap);
            }
            if (enumap.length == 0) {
                log('No valid Wifi IP found.');
            }
            if (curAp !=undefined && enumap.indexOf(curAp)<0) {
                log(`Previously set AP ${curAp} is invisible now`);
                enumap.unshift(curAp);
            }
            return schemaJson;
        });
    }).catch((err) => {
        //console.error('err:'+JSON.stringify(err));
        delete schemaJson.properties.network.properties.interfaces;
        delete schemaJson.properties.network.properties.detail;
        delete schemaJson.properties.network.properties.root_passwd;
        /* eslint-disable max-len */
        schemaJson.properties.network.properties.network_settings = {
            type: 'object',
            description:
`nmcli should be installed to setup network configuration. Execute

"$ sudo apt-get install network-manager"

or

"$ sudo yum install NetworkManager"

Also, you need to free your network devices from existing framework by, for example, edit /etc/network/interfaces to contain only two lines:

"auto lo",
"iface lo inet loopback"

and reboot. In addition, you may want to uninstall dhcpcd5 (if exist) by

"$ sudo apt-get purge dhcpcd5"`,
        };
        /* eslint-enable max-len */
        return schemaJson;
    });
}
139096
function() {
        var a  = storage.getItem(this.key)
        if (a) {
          a = JSON.parse(a)
        }
        if (a === null) storage.setItem(this.key, JSON.stringify([])) // lazy init
        return JSON.parse(storage.getItem(this.key))
      }
931829
function() {
    var deferred = $q.defer();

    var current = $state.current();

    // Evaluate
    if(current) {
      var sources = (typeof current.load === 'string' ? [current.load] : current.load) || [];
      
      // Get promises
      $q.all(sources
        .map(function(src) {
          return _createLoadable(src);
        })
        .filter(function(loadable) {
          return !loadable.isComplete;
        })
        .map(function(loadable) {
          return loadable.promise;
        })
      )
          .then(function() {
            deferred.resolve();

          }, function(err) {
            $rootScope.$broadcast('$loadableError', err);
            deferred.reject(err);
          });

    // No state
    } else {
      deferred.resolve();
    }

    return deferred.promise;
  }
279780
function instance_getters () {
        var _parseArguments = parseArguments$1(arguments),
            getters = _parseArguments.getters,
            options = _parseArguments.options;

        return Object.keys(getters).reduce(function (instanceGetters, name) {
            instanceGetters[name] = function (state, otherGetters) {
                return function (instanceKey) {
                    var instance = state[options.stateKey || 'instances'].find(function (obj) {
                        return obj[options.instanceKey || 'id'] === instanceKey;
                    });

                    if (instance) {
                        return getters[name](instance, otherGetters, state, instanceKey);
                    }
                };
            };

            return instanceGetters;
        }, {});
    }
1130994
function simple_instance_setters (setters) {
        var stateKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'instances';
        var instanceKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'id';

        // loop over the setter keys and make a mutation for each
        return Object.keys(setters).reduce(function (mutations, name) {

            // attach our new mutation to result
            return Object.assign({}, mutations, defineProperty({}, name, function (state, payload) {
                // find the instance that we're mutating
                var instance = findInstance(state, stateKey, instanceKey, payload);

                if (instance) {
                    var value = findValue(payload, instanceKey);

                    // if the setter name has a dot, then resolve the
                    // state path before feeding our value into it.
                    if (setters[name].indexOf('.') > -1) {
                        var obj = setters[name].split('.');
                        var key = obj.pop();

                        resolveObjectPath(instance, obj)[key] = value;
                    } else {
                        // otherwise, just set the instance state to our value
                        instance[setters[name]] = value;
                    }
                } else {
                    // if the instance wasn't found, let the dev know with a warning
                    console.warn('An instance with an identifier of ' + instanceKey + ' was not found.');
                }
            }));
        }, {});
    }