void Config::makeDefault() { setUrl(); version = 0; setOs(); setBits(); makeFile(); }
OStream::OStream( std::ostream & os, int runtimeVersion, int archiveVersion) : mpOs(RCF_DEFAULT_INIT), mRuntimeVersion(runtimeVersion), mSuppressVersionStamp(false), mVersionStampWritten(false) { setOs(os, runtimeVersion, archiveVersion); }
OStream::OStream( std::ostream & os, int runtimeVersion, int archiveVersion) : mpOs(), mRuntimeVersion(runtimeVersion), mSuppressArchiveMetadata(false), mArchiveMetadataWritten(false), mpSerializationProtocolOut(NULL) { setOs(os, runtimeVersion, archiveVersion); }
void Config::loadFile(QFile& f) { QSettings settings(filename.c_str(),QSettings::IniFormat); //website { auto tmp = settings.value("website/url"); if(tmp.isNull()) setUrl(); else url = tmp.toString().toStdString(); } //soft { auto tmp = settings.value("soft/version"); if (tmp.isNull()) version = 0; else version = tmp.toInt(); } //os { auto tmp = settings.value("os/name"); if(tmp.isNull()) setOs(); else os = tmp.toString().toStdString(); } { auto tmp= settings.value("os/bit"); if(tmp.isNull()) setBits(); else bits = tmp.toInt(); } }
void Host::updateHardwareInfo() { SystemMemInfo mi = systemMemoryInfo(); if( mi.caps & SystemMemInfo::TotalMemory ) setMemory( mi.totalMemory / 1024 ); #ifdef Q_OS_LINUX QString cpu = backtick("cat /proc/cpuinfo"); QRegExp cpuRx("physical id\\s+: (\\d+)"); QRegExp bogoRx("bogomips\\s+: (\\d+)"); QRegExp cpuCoresRx("cpu cores\\s+: (\\d+)"); LOG_3( "trying to get CPU info\n"+cpu ); if( bogoRx.indexIn(cpu) != -1 ) setMhz( bogoRx.cap(1).toInt() ); int cores = 1; if( cpuCoresRx.indexIn(cpu) != -1 ) cores = cpuCoresRx.cap(1).toInt(); int cpuId = 0; int pos = 0; while ((pos = cpuRx.indexIn(cpu, pos)) != -1) { int foundCpuId = cpuRx.cap(1).toInt(); LOG_3("found cpu with physical id: " + QString::number(foundCpuId)); if( foundCpuId > cpuId ) cpuId = foundCpuId; pos += cpuRx.matchedLength(); setCpus( (cpuId+1)*cores ); } setCpuName(backtick("uname -p").replace("\n","")); setOs(backtick("uname").replace("\n","")); setOsVersion(backtick("uname -r").replace("\n","")); setArchitecture(backtick("uname -m").replace("\n","")); commit(); #endif #ifdef Q_OS_MAC QString sys_profile = backtick("system_profiler -detailLevel -2"); QRegExp mhzRx("(CPU|Processor) Speed: ([\\d.]+) GHz"); if( mhzRx.indexIn(sys_profile) != -1 ) setMhz( (mhzRx.cap(2).toFloat() * 1000) ); QRegExp cpuNameRx("(CPU|Processor) Name: (.*)\n"); if( cpuNameRx.indexIn(sys_profile) != -1 ) setCpuName( cpuNameRx.cap(2).replace("\n","") ); QRegExp memRx("Memory: (\\d+) GB"); if( memRx.indexIn(sys_profile) != -1 ) setMemory( (memRx.cap(1).toInt() * 1024) ); QRegExp cpuRx("Number Of (CPUs|Cores): (\\d+)"); if( cpuRx.indexIn(sys_profile) != -1 ) setCpus( cpuRx.cap(2).toInt() ); QRegExp osRx("System Version: (Mac OS X) ([\\d.]+)"); if( osRx.indexIn(sys_profile) != -1 ) { setOs( osRx.cap(1) ); setOsVersion( osRx.cap(2) ); } setArchitecture(backtick("uname -m").replace("\n","")); #endif #ifdef Q_OS_WIN bool sysInfoSuccess; SYSTEM_INFO sysInfo = w32_getSystemInfo( &sysInfoSuccess ); if( sysInfoSuccess ) { QString arch; switch( sysInfo.wProcessorArchitecture ) { case PROCESSOR_ARCHITECTURE_AMD64: arch = "x86_64"; break; case PROCESSOR_ARCHITECTURE_IA64: arch = "Itanium"; break; case PROCESSOR_ARCHITECTURE_INTEL: arch = "x86"; break; } #ifndef _WIN64 if( !isWow64() ) setOs( "win32" ); else #endif setOs( "win64" ); setArchitecture( arch ); QString servicePackVersion; int buildNumber; setOsVersion( w32_getOsVersion(&servicePackVersion,&buildNumber) ); setServicePackVersion(servicePackVersion); setBuildNumber(buildNumber); setCpus( sysInfo.dwNumberOfProcessors ); QSettings mhzReg( "HKEY_LOCAL_MACHINE\\Hardware\\Description\\System\\CentralProcessor\\0", QSettings::NativeFormat ); setMhz( mhzReg.value( "~MHz" ).toInt() ); setWindowsDomain( localDomain() ); } #endif commit(); /* * Anything that will change every time this function is run should probably be in HostStatus, not in Host. * All the above will be recalculated but rarely ever change and cause an actual update. */ HostStatus hs = hostStatus(); Interval uptime = systemUpTime(); hs.setSystemStartupTimestamp( uptime == Interval() ? QDateTime() : (uptime * -1.0).adjust(QDateTime::currentDateTime()) ); hs.commit(); }