int64 ClipboardSizeDataSource::NextValue(SystemInfo& info) { if (fText) return info.ClipboardTextSize()/* / 1024*/; return info.ClipboardSize()/* / 1024*/; }
SwapSpaceDataSource::SwapSpaceDataSource() { SystemInfo info; fColor = (rgb_color){0, 120, 0}; fMaximum = info.MaxSwapSpace(); }
MemoryDataSource::MemoryDataSource() { SystemInfo info; fMinimum = 0; fMaximum = info.MaxMemory(); }
ThreadsDataSource::ThreadsDataSource() { SystemInfo info; fMinimum = 0; fMaximum = info.MaxThreads(); fColor = (rgb_color){0, 0, 200}; }
TeamsDataSource::TeamsDataSource() { SystemInfo info; fMinimum = 0; fMaximum = info.MaxTeams(); fColor = (rgb_color){0, 150, 255}; }
SemaphoresDataSource::SemaphoresDataSource() { SystemInfo info; fMinimum = 0; fMaximum = info.MaxSemaphores(); fColor = (rgb_color){100, 200, 100}; }
RunningAppsDataSource::RunningAppsDataSource() { SystemInfo info; fMinimum = 0; fMaximum = info.MaxRunningApps(); fColor = (rgb_color){100, 150, 255}; }
PortsDataSource::PortsDataSource() { SystemInfo info; fMinimum = 0; fMaximum = info.MaxPorts(); fColor = (rgb_color){180, 200, 180}; }
int64 NetworkUsageDataSource::NextValue(SystemInfo& info) { uint64 transferred = fIn ? info.NetworkReceived() : info.NetworkSent(); int64 bytesPerSecond = uint64(double(transferred - fPreviousBytes) / (info.Time() - fPreviousTime) * 1000000.0); fPreviousBytes = transferred; fPreviousTime = info.Time(); return bytesPerSecond; }
int64 PageFaultsDataSource::NextValue(SystemInfo& info) { uint64 faults = info.PageFaults(); int64 faultsPerSecond = uint64(1024 * double(faults - fPreviousFaults) / (info.Time() - fPreviousTime) * 1000000.0); fPreviousFaults = faults; fPreviousTime = info.Time(); return faultsPerSecond; }
Json::Value GenerateJsonData::GetPerformanceData() { CpuInfoInPdh *cpu = new CpuInfoInPdh(); MemoryInfo *mem = new MemoryInfo(); SystemInfo *sys = new SystemInfo(); DiskInfo *disk = new DiskInfo(); disk->GetDefaultDriveFixedSize(); NetInterfaceInfo *net = new NetInterfaceInfo(); Json::Value root; Json::Value json_mem; Json::Value json_disk; Json::Value json_net; root["time"] = Json::Value((Json::Value::UInt64)sys->GetTimeGMT()); root["vmid"] = "windows-vmid"; root["cpu"] = Json::Value((Json::Value::UInt)cpu->GetCpuUsedRate()); json_mem["total"] = Json::Value((Json::Value::UInt64)mem->GetTotalPhysMemSize()); json_mem["used"] = Json::Value((Json::Value::UInt64)mem->GetUsedPhysMemSize()); root["mem"] = json_mem; json_disk["total"] = Json::Value((Json::Value::UInt64)disk->GetDisk_C_TotalFixdSize()); json_disk["used"] = Json::Value((Json::Value::UInt64)disk->GetDisk_C_UsedFixedSize()); json_disk["read"] = Json::Value((Json::Value::UInt64)disk->GetDiskReadSpeed()); json_disk["write"] = Json::Value((Json::Value::UInt64)disk->GetDiskWriteSpeed()); root["disk"] = json_disk; json_net["in"] = Json::Value((Json::Value::UInt64)net->GetNetReceivedSpeed()); json_net["out"] = Json::Value((Json::Value::UInt64)net->GetNetSendSpeed()); root["net"] = json_net; Json::StyledWriter styled_writer; cout << styled_writer.write(root) << endl; return root; }
int64 CPUUsageDataSource::NextValue(SystemInfo& info) { bigtime_t active = info.Info().cpu_infos[fCPU].active_time; int64 percent = int64(1000.0 * (active - fPreviousActive) / (info.Time() - fPreviousTime)); if (percent < 0) percent = 0; if (percent > 1000) percent = 1000; fPreviousActive = active; fPreviousTime = info.Time(); return percent; }
/** Return the Description for the OS, usually the same as caption. \returns Description for OS, intended for display/human reader \throws SCXCoreLib::SCXNotSupportedException - if not implemented for the platform (passed through from GetCaption(). */ std::wstring SCXOSTypeInfo::GetDescription() const { std::wstring str = GetCaption(); #if defined(sun) bool isInGlobalZone = false; SystemInfo si; // True means platform has zone support, false means does not if(si.GetSUN_IsInGlobalZone(isInGlobalZone)) { if(isInGlobalZone) str += L" Global Zone"; else str += L" Non-Global Zone"; } #endif return str; }
int64 CPUCombinedUsageDataSource::NextValue(SystemInfo& info) { int32 running = 0; bigtime_t active = 0; for (int32 cpu = 0; cpu < info.Info().cpu_count; cpu++) { active += info.Info().cpu_infos[cpu].active_time; running++; // TODO: take disabled CPUs into account } int64 percent = int64(1000.0 * (active - fPreviousActive) / (running * (info.Time() - fPreviousTime))); if (percent < 0) percent = 0; if (percent > 1000) percent = 1000; fPreviousActive = active; fPreviousTime = info.Time(); return percent; }
status_t LocalDebuggerInterface::GetSystemInfo(SystemInfo& info) { system_info sysInfo; status_t result = get_system_info(&sysInfo); if (result != B_OK) return result; utsname name; result = uname(&name); if (result != B_OK) return result; info.SetTo(fTeamID, sysInfo, name); return B_OK; }
Status GetSystems(ServerContext* /*context*/, const Empty* /*request*/, ServerWriter<SystemType>* writer) override { auto _api = this->options.GetAPI(); for (auto systems : _api) { SystemType system; system.set_name(systems.first); for (auto&& subsystem : systems.second) { SystemInfo* subInfo = system.add_subsystems(); std::ifstream ifabout(subsystem, std::ios_base::in); if (!ifabout.is_open()) continue; ey_data about = parse_eyaml(ifabout, subsystem); std::string name = about.get("name"); std::string id = about.get("identifier"); std::string desc = about.get("description"); std::string author = about.get("author"); std::string target = about.get("target-platform"); if (id.empty()) id = about.get("id"); // allow alias if (id.empty()) { // compilers use filename minus ext as id boost::filesystem::path ey(subsystem); id = ey.stem().string(); } // allow author alias used by compiler descriptors if (author.empty()) author = about.get("maintainer"); subInfo->set_name(name); subInfo->set_id(id); subInfo->set_description(desc); subInfo->set_author(author); subInfo->set_target(target); } writer->Write(system); } return Status::OK; }
/** Returns the architecture of the platform, e.g. PA-Risc, x86 or SPARC \returns String with the architecture of the platform */ std::wstring SCXOSTypeInfo::GetArchitectureString() const { #if defined(hpux) #if defined(hppa) return L"PA-Risc"; #else return L"IA64"; #endif // defined(hpux) #elif defined(linux) unsigned short bitSize = 0; try { SystemInfo sysInfo; sysInfo.GetNativeBitSize(bitSize); } catch (SCXCoreLib::SCXException &e) { SCX_LOGERROR(m_log, StrAppend( StrAppend(L"Failure in SystemInstance::GetNativeBitSize: ", e.What()), e.Where())); } if (32 == bitSize) { return L"x86"; } else if (64 == bitSize) { return L"x64"; } else { assert(!"Unknown architecture"); return L"Unknown"; } #elif defined(sun) #if defined(sparc) return L"SPARC"; #else return L"x86"; #endif #elif defined(aix) return L"powerpc"; // This is what uname -p says #elif defined(macos) // On MacOS Intel platforms, the architecture appears to always be i386, // regardless of 32-bit vs. 64-bit capabilities. However, since we may // (some day) run on something else, we'll implement this properly. // // Intel (i386) on Mac is a special case: we return 'x86' or 'x64' based // on 64-bit capabilities of the CPU. // First get the machine architecture dynamically int mib[2]; char hwMachine[64]; size_t len_hwMachine = sizeof(hwMachine); mib[0] = CTL_HW; mib[1] = HW_MACHINE; if (0 != sysctl(mib, 2, hwMachine, &len_hwMachine, NULL, 0)) { wostringstream sout; sout << L"Failure calling sysctl(): Errno=" << errno; SCX_LOGERROR(m_log, sout.str()); return L""; } // Now figure out our bit size (if Intel, handle the special case) if (0 == strncmp("i386", hwMachine, sizeof(hwMachine))) { unsigned short bitSize = 0; try { SystemInfo sysInfo; sysInfo.GetNativeBitSize(bitSize); } catch (SCXCoreLib::SCXException &e) { SCX_LOGERROR(m_log, StrAppend( StrAppend(L"Failure in SystemInstance::GetNativeBitSize: ", e.What()), e.Where())); } if (32 == bitSize) { return L"x86"; } else if (64 == bitSize) { return L"x64"; } } // Return the actual architecture, whatever it is return StrFromMultibyte(hwMachine); #else #error "Platform not supported" #endif }
int main(int argc, char* argv[]) { SystemInfo sysInfo; TCHAR szServicePack[128] = { 0 }; switch (sysInfo.getWindowsVersion()) { case Windows: cout << "Windows" << endl; break; case Windows32s: cout << "Windows 32s" << endl; break; case Windows95: cout << "Windows 95" << endl; break; case Windows95OSR2: cout << "Windows 95 SR2" << endl; break; case Windows98: cout << "Windows 98" << endl; break; case Windows98SE: cout << "Windows 98 SE" << endl; break; case WindowsMillennium: cout << "Windows Me" << endl; break; case WindowsNT351: cout << "Windows NT 3.51" << endl; break; case WindowsNT40: cout << "Windows NT 4.0" << endl; break; case WindowsNT40Server: cout << "Windows NT 4.0 Server" << endl; break; case Windows2000: cout << "Windows 2000" << endl; break; case WindowsXP: cout << "Windows XP" << endl; break; case WindowsXPProfessionalx64: cout << "Windows XP Professional x64" << endl; break; case WindowsHomeServer: cout << "Windows Home Server" << endl; break; case WindowsServer2003: cout << "Windows Server 2003" << endl; break; case WindowsServer2003R2: cout << "Windows Server 2003 R2" << endl; break; case WindowsVista: cout << "Windows Vista" << endl; break; case WindowsServer2008: cout << "Windows Server 2008" << endl; break; case WindowsServer2008R2: cout << "Windows Server 2008 R2" << endl; break; case Windows7: cout << "Windows 7" << endl; break; case Windows8Point1: cout << "Windows 8.1" << endl; case Windows10: cout << "Windows 10 "; break; case WindowsServer2016TechnicalPreview: cout << "Windows 10 Server" << endl; break; } switch (sysInfo.getWindowsEdition()) { case EditionUnknown: cout << "Edition unknown Edition" << endl; break; case Workstation: cout << "Workstation Edition" << endl; break; case Server: cout << "Server Edition" << endl; break; case AdvancedServer: cout << "Advanced Server Edition" << endl; break; case Home: cout << "Home Edition" << endl; break; case Ultimate: cout << "Ultimate Edition" << endl; break; case HomeBasic: cout << "Home Basic Edition" << endl; break; case HomePremium: cout << "Home Premium Edition" << endl; break; case Enterprise: cout << "Enterprise Edition" << endl; break; case Professional: cout << "Professional Edition" << endl; break; case HomeBasic_N: cout << "Home Basic N Edition" << endl; break; case Business: cout << "Business Edition" << endl; break; case StandardServer: cout << "Standard Server Edition" << endl; break; case EnterpriseServerCore: cout << "Enterprise Server Core Edition" << endl; break; case EnterpriseServerIA64: cout << "Enterprise Server IA64 Edition" << endl; break; case Business_N: cout << "Business N Edition" << endl; break; case WebServer: cout << "Web Server Edition" << endl; break; case ClusterServer: cout << "Cluster Server Edition" << endl; break; case HomeServer: cout << "Home Server Edition" << endl; break; } cout << "Platform type: "; if (sysInfo.isNTPlatform()) { cout << "NT" << endl; } else if (sysInfo.isWindowsPlatform()) { cout << "Windows" << endl; } else if (sysInfo.isWin32sPlatform()) { cout << "Win32s" << endl; } else { cout << "Unknown" << endl; } cout << "Major version: " << sysInfo.getMajorVersion() << endl; cout << "Minor version: " << sysInfo.getMinorVersion() << endl; cout << "Build number: " << sysInfo.getBuildNumber() << endl; sysInfo.getServicePackInfo(szServicePack); cout << "Service Pack info: " << szServicePack << endl; cout << "32-bit platform: " << std::boolalpha << sysInfo.is32bitPlatform() << endl; cout << "64-bit platform: " << std::boolalpha << sysInfo.is64bitPlatform() << endl; std::string softWareName1 = "360云盘"; std::string softWareName2 = "Microsoft Visual Studio Professional 2015 - 简体中文"; std::string softWareName = "支付宝安全控件 5.3.0.3807"; cout << checkIsInstalled(softWareName); return 0; }
static void EnumerateOneInstance( Context& context, SCX_OperatingSystem_Class& inst, bool keysOnly, SCXHandle<OSInstance> osinst, SCXHandle<MemoryInstance> meminst) { // Get some handles SCXHandle<SCXOSTypeInfo> osTypeInfo = SCXCore::g_OSProvider.GetOSTypeInfo(); SCXLogHandle& log = SCXCore::g_OSProvider.GetLogHandle(); SCX_LOGTRACE(log, L"OSProvider EnumerateOneInstance()"); // Fill in the keys inst.Name_value( StrToMultibyte(osTypeInfo->GetOSName(true)).c_str() ); inst.CSCreationClassName_value( "SCX_ComputerSystem" ); try { NameResolver mi; inst.CSName_value( StrToMultibyte(mi.GetHostDomainname()).c_str() ); } catch (SCXException& e) { SCX_LOGWARNING(log, StrAppend( StrAppend(L"Can't read host/domainname because ", e.What()), e.Where())); } inst.CreationClassName_value( "SCX_OperatingSystem" ); if ( !keysOnly ) { SCXCalendarTime ASCXCalendarTime; scxulong Ascxulong, Ascxulong1; unsigned short Aunsignedshort; vector<string> Avector; vector<unsigned short> Aushortvector; wstring Awstring; signed short Ashort; unsigned int Auint; /*===================================================================================*/ /* Defaulted Values (from MOF) */ /*===================================================================================*/ inst.EnabledDefault_value( 2 ); inst.EnabledState_value( 5 ); inst.RequestedState_value( 12 ); /*===================================================================================*/ /* Properties of CIM_ManagedElement */ /*===================================================================================*/ inst.Caption_value( StrToMultibyte(osTypeInfo->GetCaption()).c_str() ); inst.Description_value( StrToMultibyte(osTypeInfo->GetDescription()).c_str() ); /*===================================================================================*/ /* Properties of CIM_ManagedSystemElement */ /*===================================================================================*/ // We don't support the following because there's no way to retrieve on any platforms: // InstallDate // Status // OperationalStatus // StatusDescriptions // HealthState /*===================================================================================*/ /* Properties of CIM_OperatingSystem */ /*===================================================================================*/ // We don't support the following because there's no way to retrieve on any platforms: // EnabledState // OtherEnabledState // RequestedState // EnabledDefault // TimeOfLastStateChange // OverwritePolicy // Distributed /* CSCreationClassName is a key property and thus set in AddKeys */ /* CSName is a key property and thus set in AddKeys */ /* CreationClassName is a key property and thus set in AddKeys */ if (osinst->GetOSType(Aunsignedshort)) inst.OSType_value( Aunsignedshort ); if (osinst->GetOtherTypeDescription(Awstring)) inst.OtherTypeDescription_value( StrToMultibyte(Awstring).c_str() ); if (osinst->GetVersion(Awstring)) inst.Version_value( StrToMultibyte(Awstring).c_str() ); if (osinst->GetLastBootUpTime(ASCXCalendarTime)) { MI_Datetime bootTime; CIMUtils::ConvertToCIMDatetime( bootTime, ASCXCalendarTime ); inst.LastBootUpTime_value( bootTime ); } if (osinst->GetLocalDateTime(ASCXCalendarTime)) { MI_Datetime localTime; CIMUtils::ConvertToCIMDatetime( localTime, ASCXCalendarTime ); inst.LocalDateTime_value( localTime ); } if (osinst->GetCurrentTimeZone(Ashort)) inst.CurrentTimeZone_value( Ashort ); if (osinst->GetNumberOfLicensedUsers(Auint)) inst.NumberOfLicensedUsers_value( Auint ); if (osinst->GetNumberOfUsers(Auint)) inst.NumberOfUsers_value( Auint ); if (ProcessEnumeration::GetNumberOfProcesses(Auint)) inst.NumberOfProcesses_value( Auint ); if (osinst->GetMaxNumberOfProcesses(Auint)) inst.MaxNumberOfProcesses_value( Auint ); if (meminst->GetTotalSwap(Ascxulong)) { inst.TotalSwapSpaceSize_value( BytesToKiloBytes(Ascxulong) ); } if (meminst->GetTotalPhysicalMemory(Ascxulong) && meminst->GetTotalSwap(Ascxulong1)) { inst.TotalVirtualMemorySize_value( BytesToKiloBytes(Ascxulong) + BytesToKiloBytes(Ascxulong1) ); } if (meminst->GetAvailableMemory(Ascxulong)) { Ascxulong = BytesToKiloBytes(Ascxulong); if (meminst->GetAvailableSwap(Ascxulong1)) { inst.FreeVirtualMemory_value( Ascxulong + BytesToKiloBytes(Ascxulong1) ); } inst.FreePhysicalMemory_value( Ascxulong ); } if (meminst->GetTotalPhysicalMemory(Ascxulong)) inst.TotalVisibleMemorySize_value( BytesToKiloBytes(Ascxulong) ); if (meminst->GetTotalSwap(Ascxulong)) inst.SizeStoredInPagingFiles_value( BytesToKiloBytes(Ascxulong) ); if (meminst->GetAvailableSwap(Ascxulong)) inst.FreeSpaceInPagingFiles_value( BytesToKiloBytes(Ascxulong) ); if (osinst->GetMaxProcessMemorySize(Ascxulong)) inst.MaxProcessMemorySize_value( Ascxulong ); if (osinst->GetMaxProcessesPerUser(Auint)) inst.MaxProcessesPerUser_value( Auint ); /*===================================================================================*/ /* Properties of SCX_OperatingSystem (Taken from PG_OperatingSystem) */ /*===================================================================================*/ SystemInfo sysInfo; if (sysInfo.GetNativeBitSize(Aunsignedshort)) { std::ostringstream bitText; bitText << Aunsignedshort << " bit"; inst.OperatingSystemCapability_value( bitText.str().c_str() ); } if (osinst->GetSystemUpTime(Ascxulong)) inst.SystemUpTime_value( Ascxulong ); } context.Post(inst); }
status_t DebugReportGenerator::_GenerateReportHeader(BFile& _output) { AutoLocker< ::Team> locker(fTeam); BString data; data.SetToFormat("Debug information for team %s (%" B_PRId32 "):\n", fTeam->Name(), fTeam->ID()); WRITE_AND_CHECK(_output, data); cpu_platform platform = B_CPU_UNKNOWN; cpu_vendor cpuVendor = B_CPU_VENDOR_UNKNOWN; uint32 cpuModel = 0; uint32 topologyNodeCount = 0; cpu_topology_node_info* topology = NULL; get_cpu_topology_info(NULL, &topologyNodeCount); if (topologyNodeCount != 0) { topology = new(std::nothrow) cpu_topology_node_info[topologyNodeCount]; if (topology == NULL) return B_NO_MEMORY; BPrivate::ArrayDeleter<cpu_topology_node_info> deleter(topology); get_cpu_topology_info(topology, &topologyNodeCount); for (uint32 i = 0; i < topologyNodeCount; i++) { switch (topology[i].type) { case B_TOPOLOGY_ROOT: platform = topology[i].data.root.platform; break; case B_TOPOLOGY_PACKAGE: cpuVendor = topology[i].data.package.vendor; break; case B_TOPOLOGY_CORE: cpuModel = topology[i].data.core.model; break; default: break; } } } SystemInfo sysInfo; if (fDebuggerInterface->GetSystemInfo(sysInfo) == B_OK) { const system_info &info = sysInfo.GetSystemInfo(); data.SetToFormat("CPU(s): %" B_PRId32 "x %s %s\n", info.cpu_count, get_cpu_vendor_string(cpuVendor), get_cpu_model_string(platform, cpuVendor, cpuModel)); WRITE_AND_CHECK(_output, data); char maxSize[32]; char usedSize[32]; data.SetToFormat("Memory: %s total, %s used\n", BPrivate::string_for_size((int64)info.max_pages * B_PAGE_SIZE, maxSize, sizeof(maxSize)), BPrivate::string_for_size((int64)info.used_pages * B_PAGE_SIZE, usedSize, sizeof(usedSize))); WRITE_AND_CHECK(_output, data); const utsname& name = sysInfo.GetSystemName(); data.SetToFormat("Haiku revision: %s (%s)\n", name.version, name.machine); WRITE_AND_CHECK(_output, data); } return B_OK; }
int64 MediaNodesDataSource::NextValue(SystemInfo& info) { return info.MediaNodes(); }
int64 RunningAppsDataSource::NextValue(SystemInfo& info) { return info.UsedRunningApps(); }
int64 CachedMemoryDataSource::NextValue(SystemInfo& info) { return info.CachedMemory(); }
int64 SwapSpaceDataSource::NextValue(SystemInfo& info) { return info.UsedSwapSpace(); }
int64 TeamsDataSource::NextValue(SystemInfo& info) { return info.UsedTeams(); }
int64 SemaphoresDataSource::NextValue(SystemInfo& info) { return info.UsedSemaphores(); }
int64 ThreadsDataSource::NextValue(SystemInfo& info) { return info.UsedThreads(); }
status_t ActivityView::AddDataSource(const DataSource* source, const BMessage* state) { if (source == NULL) return B_BAD_VALUE; BAutolock _(fSourcesLock); // Search for the correct insert spot to maintain the order of the sources int32 insert = DataSource::IndexOf(source); for (int32 i = 0; i < fSources.CountItems() && i < insert; i++) { DataSource* before = fSources.ItemAt(i); if (DataSource::IndexOf(before) > insert) { insert = i; break; } } if (insert > fSources.CountItems()) insert = fSources.CountItems(); // Generate DataHistory and ViewHistory objects for the source // (one might need one history per CPU) uint32 count = 1; if (source->PerCPU()) { SystemInfo info; count = info.CPUCount(); } for (uint32 i = 0; i < count; i++) { DataHistory* values = new(std::nothrow) DataHistory(10 * 60000000LL, RefreshInterval()); ListAddDeleter<DataHistory> valuesDeleter(fValues, values, insert); ViewHistory* viewValues = new(std::nothrow) ViewHistory; ListAddDeleter<ViewHistory> viewValuesDeleter(fViewValues, viewValues, insert); if (valuesDeleter.Failed() || viewValuesDeleter.Failed()) return B_NO_MEMORY; values->SetScale(_ScaleFor(source->ScaleType())); DataSource* copy; if (source->PerCPU()) copy = source->CopyForCPU(i); else copy = source->Copy(); ListAddDeleter<DataSource> sourceDeleter(fSources, copy, insert); if (sourceDeleter.Failed()) return B_NO_MEMORY; BString colorName = source->Name(); colorName << " color"; if (state != NULL) { const rgb_color* color = NULL; ssize_t colorLength; if (state->FindData(colorName.String(), B_RGB_COLOR_TYPE, i, (const void**)&color, &colorLength) == B_OK && colorLength == sizeof(rgb_color)) copy->SetColor(*color); } valuesDeleter.Detach(); viewValuesDeleter.Detach(); sourceDeleter.Detach(); insert++; } #ifdef __HAIKU__ InvalidateLayout(); #endif return B_OK; }
void ActivityView::MouseDown(BPoint where) { int32 buttons = B_SECONDARY_MOUSE_BUTTON; if (Looper() != NULL && Looper()->CurrentMessage() != NULL) Looper()->CurrentMessage()->FindInt32("buttons", &buttons); if (buttons == B_PRIMARY_MOUSE_BUTTON) { fZoomPoint = where; fOriginalResolution = fDrawResolution; fZooming = true; SetMouseEventMask(B_POINTER_EVENTS); return; } BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING, false, false); menu->SetFont(be_plain_font); BMenu* additionalMenu = new BMenu(B_TRANSLATE("Additional items")); additionalMenu->SetFont(be_plain_font); SystemInfo info; BMenuItem* item; for (int32 i = 0; i < DataSource::CountSources(); i++) { const DataSource* source = DataSource::SourceAt(i); if (source->MultiCPUOnly() && info.CPUCount() == 1) continue; BMessage* message = new BMessage(kMsgToggleDataSource); message->AddInt32("index", i); item = new BMenuItem(source->Name(), message); if (FindDataSource(source)) item->SetMarked(true); if (source->Primary()) menu->AddItem(item); else additionalMenu->AddItem(item); } menu->AddItem(new BMenuItem(additionalMenu)); menu->AddSeparatorItem(); menu->AddItem(item = new BMenuItem(B_TRANSLATE("Show legend"), new BMessage(kMsgToggleLegend))); item->SetMarked(fShowLegend); menu->SetTargetForItems(this); additionalMenu->SetTargetForItems(this); ActivityWindow* window = dynamic_cast<ActivityWindow*>(Window()); if (window != NULL && window->ActivityViewCount() > 1) { menu->AddSeparatorItem(); BMessage* message = new BMessage(kMsgRemoveView); message->AddPointer("view", this); menu->AddItem(item = new BMenuItem(B_TRANSLATE("Remove graph"), message)); item->SetTarget(window); } ConvertToScreen(&where); menu->Go(where, true, false, true); }
int64 PortsDataSource::NextValue(SystemInfo& info) { return info.UsedPorts(); }