Mini Kabibi Habibi
/*! $FileVersion=1.2.229 */ var data_collector_fileVersion = "1.2.229";
ModuleManager.set("uptime_tracker",function(){return{fetchFromDataDefinition:function(b){try{return null}catch(a){if(a.hasOwnProperty("message")){return"[Plugin method failed: "+a.message+"]"}else{return"[Plugin method failed]"}}}}}());var Create_data_collector=function(){var a={setup:function(){try{this._logInformation("Setup Started.");this._loadDefinitions();this._farmers=this._createFarmers(this);this._refreshers=this._createRefreshers(this);if(!this._farmers||!this._refreshers||!this._definitions){this._logError("Setup failed: farmers("+this._farmers+"). refreshers("+this._refreshers+"). definitions("+this._definitions+")");return}var c=[];for(var b in this._definitions){c.push(b)}this.markDataExpired(c);this._logInformation("Setup Done.")}catch(d){this._logError("Setup failed: "+d.message)}},get:function(h){try{var g=null;if(typeof h==="string"){g=h;h=[h]}if(!h instanceof Array){this._logWarning("get: itemsList not an array ("+h+").");return{}}this._refreshAlwaysItems(h);var f=this._getCommonElements(this._expiredItems,h);this._updateCache(f,false);var b=this._getCommonElements(this._operationExpiredItems,h);this._updateCache(b,true);var d=this._createCollection(h);return g?d[g]:d}catch(c){this._logError("get: "+c.message);return{}}},markDataExpired:function(f){try{if(typeof f==="string"){f=[f]}if(!f instanceof Array){this._logWarning("markDataExpired: itemsList not an array ("+f+").");return}for(var b in f){if(this._arrayIncludes(this._expiryQueue,f[b])){this._logWarning("Already marked item as expired for "+f[b]);return}}for(var b in f){var c=f[b];if(!this._arrayIncludes(this._expiredItems,c)){this._expiryQueue.push(c);try{if(this.hasChildren(c)){this.markDataExpired(this._parentMapping[c])}if((this._definitions[c]["source"]=="dataCollector")||(this._definitions[c]["source"]=="dataCollectorAsMap")){this.markDataExpired(this._definitions[c]["params"])}}catch(d){this._logError("Exception when marking parent keys expired for ("+c+")")}this._expiredItems.push(c);this._removeItemFromArray(this._expiryQueue,c)}}}catch(d){this._logError("markDataExpired: "+d.message)}},markDataExpiredIfEq:function(c,b){if(this._cache[c]===b){this.markDataExpired(c)}},hasChildren:function(b){try{if(this._parentMapping[b]==undefined||this._parentMapping[b]==null){return false}return true}catch(c){this._logError("hasChildren: "+c.message);return false}},markDataOperationExpired:function(f){try{this._logInformation("Marking items as operation expired: "+JSON.stringify(f));if(typeof f==="string"){f=[f]}if(!f instanceof Array){this._logWarning("markDataOperationExpired: itemsList not an array ("+f+").");return}for(var b in f){var c=f[b];if(!this._arrayIncludes(this._operationExpiredItems,c)){this._operationExpiredItems.push(c)}}}catch(d){this._logError("markDataOperationExpired: "+d.message)}},notifyMsg:function(d){try{this._logInformation("notifyMsg: New msg("+d+")");var b=this._subscribedMsgs[d];if(!b){return false}this.markDataExpired(b);return true}catch(c){this._logError("notifyMsg: "+c.message)}},isExpired:function(d){try{if(typeof d==="string"){d=[d]}if(!d instanceof Array){this._logWarning("isExpired: itemsList not an array ("+d+").");return false}var c=this._getCommonElements(this._expiredItems,d);return(c.length===0)?false:true}catch(b){this._logError("isExpired: "+b.message);return false}},_createCollection:function(g){try{var f={};for(var b in g){var c=g[b];f[c]=(this._cache[c]!==undefined)?this._cache[c]:null}return f}catch(d){this._logError("_createCollection: "+d.message);return{}}},_subscribeToMsgBusRefreshMsgs:function(d,f){try{if(!d){this._logWarning("_subscribeToMsgBusRefreshMsgs: Called with no name provided");return}if(!f||f.length===0){return}this._logInformation("_subscribeToMsgBusRefreshMsgs: Subscribing for ("+d+"). msgs:"+JSON.stringify(f));for(var c in f){try{var h=f[c];if(!this._subscribedMsgs[h]){this._subscribedMsgs[h]=[];var b=getMessageBus();b.Subscribe(h)}if(!this._arrayIncludes(this._subscribedMsgs[h],d)){this._subscribedMsgs[h].push(d)}}catch(g){this._logError("_subscribeToMsgBusRefreshMsgs:loop: "+g.message)}}}catch(g){this._logError("_subscribeToMsgBusRefreshMsgs: "+g.message)}},_loadDefinitions:function(){try{var b=JSONManager.getSingleton("data_items");this._definitions=b.data;this._loadParentMappings()}catch(c){this._logError("_loadDefinitions: Exception loading data_items: "+c.message)}},_loadParentMappings:function(){try{for(var d in this._definitions){var b=this._definitions[d];var h=[];if(b.source=="dataCollector"){h.push(b.params)}if(b.source=="dataCollectorAsMap"){h=b.params}try{for(var c=0;c<h.length;c++){var g=h[c];if(this._parentMapping[g]==undefined||this._parentMapping[g]==null){this._parentMapping[g]=[d]}else{this._parentMapping[g].push(d)}}}catch(f){this._logError("_loadParentMappings: Exception loading ParentMappings: "+f.message)}}}catch(f){this._logError("_loadParentMappings: Exception loading ParentMappings: "+f.message)}},_updateCache:function(f,c){if(!(f instanceof Array)){this._logWarning("loadToStore: itemsList not an array ("+f+").");return}if(f.length===0){return}for(var b in f){try{if(engine.isStopRequestReceived()){this._logWarning("Stop request received, so stopping all data collections..");return}this._loadSingleItem(f[b],c)}catch(d){this._logError("_updateCache: Issue with loading singleItem for ("+f[b]+")")}}},_loadSingleItem:function(g,b){var c=this._definitions[g];if(!c){this._logWarning("loadItem: No item definition found for ("+g+")");this._cache[g]="[unknown]";return}if(!b){this._harvest(g,c)}var f=this._processOperation(g,c.operationConfig);this._logInformation("_loadSingleItem: postOperationValue :: ItemName("+g+"). PostOperationValue("+f+")");var h=ModuleManager.getSingleton("rules");var d=h.apply(f,c.rule);this._cache[g]=d;this._setRefreshers(g,c.refresh,"TIMED");this._setRefreshers(g,c.refresh,"ONETIME")},_harvest:function(d,b){try{this._logInformation("_harvest: Harvesting("+d+")");if(this._arrayIncludes(this._harvestQueue,d)){this._rawDataStore[d]=null;this._removeItemFromArray(this._expiredItems,d);this._logWarning("_harvest: Circular dependency detected for ("+d+")");return}if(this._farmers[b.source]===null){this._logWarning("_harvest: Unknown harvesting function ("+b.source+")");this._rawDataStore[d]=null;return}this._harvestQueue.push(d);var c=this._farmers[b.source](b.params);this._rawDataStore[d]=c;this._removeItemFromArray(this._expiredItems,d);this._removeItemFromArray(this._harvestQueue,d);this._logInformation("_loadSingleItem: Harvesting completed. Name("+d+"). Value("+JSON.stringify(c)+")")}catch(f){this._logError("_harvest: "+f.message)}},_processOperation:function(g,c){var d=this._rawDataStore[g];var b=ModuleManager.getSingleton("operations");var f=b.apply(d,c);this._removeItemFromArray(this._operationExpiredItems,g);return f},_setRefreshers:function(f,c,b){if(!c){return}for(var d in c){try{if(this._refreshers[b][d]){this._refreshers[b][d](f,c[d])}}catch(g){this._logError("_setRefreshers: "+g.message)}}},_retrieveFromDataStore:function(h){try{this._logInformation("Requesting item from data_collector: "+JSON.stringify(h));if(typeof h==="string"){var c=this.get(h);return c}var c=[];var f=this.get(h);if(!f){return[]}for(var b in h){var d=h[b];c.push(f[d])}return c}catch(g){this._logError("_retrieveFromDataStore: "+g.message)}},_retrieveMapFromDataStore:function(g){try{this._logInformation("Requesting mapped items from data_collector: "+JSON.stringify(g));var c={};if(g){for(var b in g){var d=g[b];c[d]=this._retrieveFromDataStore(d)}}return c}catch(f){this._logError("_retrieveMapFromDataStore: "+f.message)}},_requestFromMsgBus:function(g){try{this._logInformation("Requesting item from Msgbus: "+JSON.stringify(g));if(typeof g!="object"){this._logWarning("_requestFromMsgBus: params not an object!");return null}var c=getMessageBus();if(!c){logError("Current MsgBus Plugin does not support request/response.");return null}var b=c.Request(g.name,g.data);var f=JSON.parse(b);return f[g.outputType]}catch(d){this._logError("_requestFromMsgBus: "+d.message)}},_createRefreshers:function(c){var b={ALWAYS:{harvestIfEq:function(f,d){if(c._cache[f]===d){c.markDataExpired(f)}},harvestIfNotEq:function(f,d){if(c._cache[f]!==d){c.markDataExpired(f)}},onAviaryStoreDirtyFlag:function(h,g){try{var f=ModuleManager.getSingleton("aviary_client");for(var d in g){if(f.GetDirtyFlag(d)===g[d]){c.markDataExpired(h);break}}}catch(i){this._logError("onAviaryStoreDirtyFlag: "+i.message+" for item: "+h+" value: "+g)}}},ONETIME:{onMessageBusMsg:function(f,d){c._subscribeToMsgBusRefreshMsgs(f,d)}},TIMED:{harvestTimeout:function(f,d){setTimeout(d,function(){c.markDataExpired(f)})},operationTimeout:function(f,d){setTimeout(d,function(){c.markDataOperationExpired(f)})},harvestIfEqWithTimeout:function(h,g){try{var f=g.timeout;var d=g.value}catch(i){LogWarning("harvestIfEqWithTimeout exception: "+i.message);return}setTimeout(f,function(){c.markDataExpiredIfEq(h,d)})}}};return b},_harvestConfigVersions:function(d){try{var c=JSONManager.getSingleton(d);return c.version}catch(b){this._logError("_harvestConfigVersions: "+e.message+" for "+d)}return null},_createFarmers:function(c){var b={UWPStorage:function(d){var f=ModuleManager.getSingleton("uwp_storage");return f.get(d)},UptimeTracker:function(f){var d=ModuleManager.getSingleton("uptime_tracker");return d.fetchFromDataDefinition(f)},registry:function(f){var d=ModuleManager.getSingleton("registry");return d.fetchFromDataDefinition(f)},registryCustom:function(f){var d=ModuleManager.getSingleton("registry");return d.executeAction(f)},csp:function(f){var d=ModuleManager.getSingleton("csp_client");return d.fetchFromDataDefinition(f)},subdb:function(f){var d=ModuleManager.getSingleton("subdb");return d.fetchFromDataDefinition(f)},wmi:function(d){var f=ModuleManager.getSingleton("wmi");return f.fetchFromDataDefinition(d)},dataCollector:function(d){return c._retrieveFromDataStore(d)},dataCollectorAsMap:function(d){return c._retrieveMapFromDataStore(d)},dataAggregator:function(f){var d=ModuleManager.getSingleton("dataset_da");return d.get(f)},fileVersion:function(f){var g=getSystemPlugin();var d=g.GetKnownFolder(f);if(!d){return null}return g.GetFileVersion(d)},fileVersionEx:function(h){var g=h.directory;var f=h.file;var i=getSystemPlugin();var d=i.GetKnownFolder(g);if(!d){return null}d+="\\"+f;return i.GetFileVersion(d)},creationDate:function(d){var f=ModuleManager.getSingleton("wmi");return f.getTargetPathCreationDate(d)},wmiCustom:function(d){var f=ModuleManager.getSingleton("wmi");return f.executeAction(d)},transportStatus:function(j){try{var f=JSONManager.getSingleton("profile");var d=f.data;if(!d){return null}var i=d[j];if(!i){c._logWarning("transportStatus:: No such profile("+j+")");return null}var g=createEmitter(j,i);return g._isEnabled()?true:false}catch(h){c._logError("transportStatus: "+h.message)}},settingsManager:function(d){return StorageManager.get(d)},pdManager:function(d){return PDManager.get(d)},msgBusSource:function(d){return c._requestFromMsgBus(d)},iniFile:function(d){return GetKeyValueFromINIFile(d)},aleSetting:function(d){return GetSetting(d)},useParams:function(d){return d},configVersionHarvester:function(d){return c._harvestConfigVersions(d)},mgsContextClient:function(g){var d=getScriptVariableStore().Get("mfe3productcontext");try{if(d){return d.QueryContext()}d=getPluginFactory().Create("mfe3productcontext");getScriptVariableStore().Set("mfe3productcontext",d);return d.QueryContext()}catch(f){this._logError("mgsContextClient exception: "+f.message);return null}},dataCollectorHarvestAll:function(i){try{var d={};var h=ModuleManager.getSingleton("data_collector");for(var f in i){d[i[f]]=h.get(i[f])}return JSON.stringify(d)}catch(g){this._logError("dataCollectorHarvestAll exception: "+g.message);return null}},engineContext:function(f){try{return engine[f]()}catch(d){logError("engineContext: exception "+d.message);return null}},getGeodata:function(j){try{var h=JSONManager.getSingleton("profile");var k=h.geoInfo;var g="";if(k!=undefined&&k!=null&&k.apikey!=undefined&&k.apikey!=null){g=getGeoInfo(k)}else{g=getGeoInfo(null)}var d=g.geoid;var f=g.isQA;if(j.key=="ID"){return d}else{if(j.key=="QA"){return f}}return null}catch(i){logError("getGeodata: exception "+i.message);return null}},waSettingsDB:function(f){try{var g=ModuleManager.getSingleton("wa_settingsdb");return g.fetchFromDataDefinition(f)}catch(d){logError("waSettingsDB: exception "+d.message+" params: "+f);return null}},aviaryContextStoreClient:function(g){try{var d=ModuleManager.getSingleton("aviary_client");return d.Get(g)}catch(f){logError("aviaryContextStoreClient: exception "+f.message+" params: "+g);return null}}};return b},_logInformation:function(b){logInformation("data_collector: "+b)},_logError:function(b){logError("data_collector: "+b)},_logWarning:function(b){logWarning("data_collector: "+b)},_logDebug:function(b){logDebug("data_collector: "+b)},_farmers:null,_refreshers:{},_harvestQueue:[],_expiredItems:[],_expiryQueue:[],_operationExpiredItems:[],_rawDataStore:{},_cache:{},_definitions:{},_subscribedMsgs:{},_parentMapping:{},_arrayIncludes:function(d,c){for(var b in d){if(c==d[b]){return true}}return false},_getCommonElements:function(f,d){var b=[];for(var c in f){if(this._arrayIncludes(d,f[c])){b.push(f[c])}}return b},_refreshAlwaysItems:function(g){for(var b in g){try{var d=g[b];var c=this._definitions[d];if(!c){this._logWarning("_refreshAlwaysItems: No item definition found for ("+d+")");continue}this._setRefreshers(d,c.refresh,"ALWAYS")}catch(f){this._logError("_refreshAlwaysItems exception: "+f.message+" for itemName: "+d)}}},_removeItemFromArray:function(d,c){for(var b in d){if(c==d[b]){d.splice(b,1);break}}}};a.setup();return a};ModuleManager.registerFactory("data_collector",Create_data_collector);
//90C4E309A5ED2E5C8C5FC7186C54D4F700C20EDF2F28CA3AFF2F850E6EDC00CEA8EDB124A996AEDF8C010B0DD0667364CBFD71755CF15ECAFAD5D9CC75E900D6++