/** Update the enumeration potentially discovering new instances. \param updateInstances If true, update state of all instances in collection. \throws SCXInternalErrorException If object is of unknown disk enumeration type. */ void StatisticalPhysicalDiskEnumeration::Update(bool updateInstances) { SCXCoreLib::SCXThreadLock lock(m_lock); FindPhysicalDisks(); if (updateInstances) { UpdateInstances(); } }
/** Implementation of the Update method of the entity framework. \param updateInstances - indicates whether only the existing instances shall be updated. The method refreshes the set of known instances in the enumeration. Any newly created instances must have a well-defined state after execution, meaning that instances which update themselves have to init themselves upon creation. */ void NetworkInterfaceConfigurationEnumeration::Update(bool updateInstances) { if (updateInstances) { UpdateInstances(); } else { UpdateEnumeration(); } }
void Update(float dt){ UpdateInstances(dt); //duration -= dt; objAdder -= dt; if (objAdder <= 0){ Pool.AddInstance(TestObject(Point(90,90))); objAdder = 10.0f; } if( InputManager::GetInstance().IsAnyKeyPressed() != -1 || duration <= 0 ) { requestDelete = true; } };
BOOL COptions::ParseOptionsCommand(unsigned char *pData, DWORD dwDataLength, BOOL bFromLocal /*=FALSE*/) { unsigned char *p = pData; int num = *p * 256 + p[1]; p+=2; if (num!=OPTIONS_NUM) return FALSE; int i; for (i = 0; i < num; ++i) { if ((DWORD)(p-pData)>=dwDataLength) return FALSE; int nType = *p++; if (!nType) { if ((DWORD)(p-pData+3) >= dwDataLength) return 2; int len = *p * 256 * 256 + p[1] * 256 + p[2]; p += 3; if ((DWORD)(p - pData + len) > dwDataLength) return FALSE; char *pBuffer = new char[len + 1]; memcpy(pBuffer, p, len); pBuffer[len]=0; if (!m_Options[i].bOnlyLocal || bFromLocal) //Do not change admin interface settings from remote connections SetOption(i+1, ConvFromNetwork(pBuffer), false); delete [] pBuffer; p+=len; } else if (nType == 1) { if ((DWORD)(p-pData+8)>dwDataLength) return FALSE; if (!m_Options[i].bOnlyLocal || bFromLocal) //Do not change admin interface settings from remote connections SetOption(i+1, GET64(p), false); p+=8; } else return FALSE; } SPEEDLIMITSLIST dl; SPEEDLIMITSLIST ul; if ((DWORD)(p-pData+2)>dwDataLength) return FALSE; num = *p++ << 8; num |= *p++; simple_lock lock(m_mutex); for (i=0; i<num; ++i) { CSpeedLimit limit; p = limit.ParseBuffer(p, dwDataLength - (p - pData)); if (!p) { return FALSE; } dl.push_back(limit); } if ((DWORD)(p-pData+2)>dwDataLength) { return FALSE; } num = *p++ << 8; num |= *p++; for (i=0; i<num; i++) { CSpeedLimit limit; p = limit.ParseBuffer(p, dwDataLength - (p - pData)); if (!p) { return FALSE; } ul.push_back(limit); } m_sSpeedLimits[0] = dl; m_sSpeedLimits[1] = ul; SaveOptions(); UpdateInstances(); return TRUE; }
void COptions::Init() { if (m_bInitialized) return; simple_lock lock(m_mutex); m_bInitialized = TRUE; for (int i = 0; i < OPTIONS_NUM; ++i) m_sOptionsCache[i].bCached = FALSE; USES_CONVERSION; CStdString xmlFileName = GetExecutableDirectory() + _T("FileZilla Server.xml"); char* bufferA = T2A(xmlFileName); if (!bufferA) { return; } TiXmlDocument document; WIN32_FILE_ATTRIBUTE_DATA status{}; if (!GetStatus64(xmlFileName, status) ) { document.LinkEndChild(new TiXmlElement("FileZillaServer")); document.SaveFile(bufferA); } else if (status.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { return; } if (!document.LoadFile(bufferA)) { return; } TiXmlElement* pRoot = document.FirstChildElement("FileZillaServer"); if (!pRoot) { return; } TiXmlElement* pSettings = pRoot->FirstChildElement("Settings"); if (!pSettings) pSettings = pRoot->LinkEndChild(new TiXmlElement("Settings"))->ToElement(); TiXmlElement* pItem; for (pItem = pSettings->FirstChildElement("Item"); pItem; pItem = pItem->NextSiblingElement("Item")) { const char* pName = pItem->Attribute("name"); if (!pName) continue; CStdString name(pName); const char* pType = pItem->Attribute("type"); if (!pType) continue; CStdString type(pType); TiXmlNode* textNode = pItem->FirstChild(); CStdString value; if (textNode && textNode->ToText()) value = ConvFromNetwork(textNode->Value()); else if (type == _T("numeric")) continue; for (int i = 0; i < OPTIONS_NUM; ++i) { if (!_tcscmp(name, m_Options[i].name)) { if (m_sOptionsCache[i].bCached) break; if (type == _T("numeric")) { if (m_Options[i].nType != 1) break; _int64 value64 = _ttoi64(value); if (IsNumeric(value)) SetOption(i + 1, value64, false); } else { if (m_Options[i].nType != 0) break; SetOption(i + 1, value, false); } break; } } } ReadSpeedLimits(pSettings); UpdateInstances(); }
/** Update the enumeration. \param updateInstances If true (default) all instances will be updated. Otherwise only the content of the enumeration will be updated. */ void StaticPhysicalDiskEnumeration::Update(bool updateInstances/*=true*/) { for (EntityIterator iter=Begin(); iter!=End(); iter++) { SCXCoreLib::SCXHandle<StaticPhysicalDiskInstance> disk = *iter; disk->m_online = false; } #if defined(linux) // First detect optical devices so later we can just skip the mount points which we determined are optical disks. // Various projects may or may not require optical drive detection. We check if iso9660 file system is to be // ignored to determine if optical drives should be detected. std::vector<std::wstring> drives; if ( ! m_deps->FileSystemIgnored(L"iso9660") ) { // Get CD-ROM and DVD drives directly from the kernel interface in /proc. SCXCoreLib::SCXHandle<std::wistream> cdStrm = m_deps->GetWIStream("/proc/sys/dev/cdrom/info"); std::vector<std::wstring> cdStrmLines; SCXCoreLib::SCXStream::NLFs nlfs; // /proc/sys/dev/cdrom/info format: // CD-ROM information, Id: cdrom.c 3.20 2003/12/17 // // drive name: sr0 hdc // drive speed: 0 0 // drive # of slots: 1 1 // ... SCXCoreLib::SCXStream::ReadAllLines(*cdStrm, cdStrmLines, nlfs); std::wstring lineID(L"drive name:"); size_t i; for (i = 0; i < cdStrmLines.size(); i++) { if (cdStrmLines[i].substr(0, lineID.size()) == lineID) { std::wstring drivesLine = cdStrmLines[i].substr(lineID.size(), std::wstring::npos); SCXCoreLib::StrTokenize(drivesLine, drives, L" \t"); size_t d; for (d = 0; d < drives.size(); d++) { AddDiskInstance(L"/dev/" + drives[d], L"/dev/" + drives[d], true); } break; } } } #endif m_deps->RefreshMNTTab(); for (std::vector<MntTabEntry>::const_iterator it = m_deps->GetMNTTab().begin(); it != m_deps->GetMNTTab().end(); it++) { #if defined(linux) // It this is an optical device just skip it. We already processed it. size_t d; bool found = false; for (d = 0; d < drives.size(); d++) { if ((L"/dev/" + drives[d]) == it->device) { found = true; break; } } if (found) { continue; } #endif if ( ! m_deps->FileSystemIgnored(it->fileSystem) && ! m_deps->DeviceIgnored(it->device) && m_deps->LinkToPhysicalExists(it->fileSystem, it->device, it->mountPoint) ) { std::map<std::wstring, std::wstring> devices = m_deps->GetPhysicalDevices(it->device); if (devices.size() == 0) { static SCXCoreLib::LogSuppressor suppressor(SCXCoreLib::eError, SCXCoreLib::eTrace); std::wstringstream out; out << L"Unable to locate physical devices for: " << it->device; SCX_LOG(m_log, suppressor.GetSeverity(out.str()), out.str()); continue; } for (std::map<std::wstring, std::wstring>::const_iterator dev_it = devices.begin(); dev_it != devices.end(); dev_it++) { SCXCoreLib::SCXHandle<StaticPhysicalDiskInstance> disk = AddDiskInstance(dev_it->first, dev_it->second); } } } #if defined(sun) this->UpdateSolarisHelper(); #endif if (updateInstances) { UpdateInstances(); } }