bool ATVersion::GetAppVersion(const char *appName, std::string &version) { std::list<unsigned long> pids; version = ""; if (IsAppRunning(appName, pids)) { for (std::list<unsigned long>::iterator iter = pids.begin(); iter != pids.end(); iter++) { std::string path = GetAppPathByPid(*iter); if (!path.empty()) { version = GetProcessVersion(path); return true; } } } version = GetProcessVersion(ATVersion::appSearchPath + appName); if (version.empty()) { version = GetProcessVersion(appName); } return false; }
void MainDialog::Notify() { if (mpAppProfilePanel->GetEnabled()) { if (mpAppProfilePanel->GetActiveProfile().IsEmpty()) { ProfileList AppProfiles = mpAppProfilePanel->GetProfiles(); ProfileList::iterator it; int index = 0; for (it = AppProfiles.begin(); it != AppProfiles.end(); ++it) { if (IsAppRunning((*it).AppName)) { if (LoadXML((*it).ProfileName)) { ACT_LOG("Profile: " << (*it).AppName.ToUTF8() << ", " << (*it).ProfileName.ToUTF8() << " activated"); mpAppProfilePanel->SetActiveProfile((*it).AppName); mpAppProfilePanel->SetActiveProfileIndex(index); mpAppProfilePanel->UpdateDisplay(); Stop(); Start(5*TIMER_INTERVAL); } else { ERR_LOG("Failed to load profile " << (*it).AppName.ToUTF8()); } } ++index; } } else { if (!IsAppRunning(mpAppProfilePanel->GetActiveProfile())) { ACT_LOG(mpAppProfilePanel->GetActiveProfile().ToUTF8() << " closed."); if (mpAppProfilePanel->GetDefaultProfile().IsEmpty()) { mpFanSpeedPanel->SetDefaultFanSpeed(); mpAppProfilePanel->SetActiveProfile(wxT("")); mpAppProfilePanel->SetActiveProfileIndex(-1); mpAppProfilePanel->UpdateDisplay(); } else { ACT_LOG("Default Profile activated"); if (LoadXML(mpAppProfilePanel->GetDefaultProfile())) { mpAppProfilePanel->SetActiveProfile(wxT("")); mpAppProfilePanel->SetActiveProfileIndex(-1); mpAppProfilePanel->UpdateDisplay(); } else { ERR_LOG("Failed to load default profile " << mpAppProfilePanel->GetDefaultProfile().ToUTF8()); } } mpAppProfilePanel->SetActiveProfile(wxT("")); Stop(); Start(TIMER_INTERVAL); } } } else if (!mpAppProfilePanel->GetManualProfile().IsEmpty()) { ACT_LOG("Profile: " << mpAppProfilePanel->GetManualProfile().ToUTF8() << " activated."); if (LoadXML(mpAppProfilePanel->GetManualProfile())) { mpAppProfilePanel->SetManualProfile(wxT("")); } else { ERR_LOG("Failed to load manual selected profile " << mpAppProfilePanel->GetManualProfile().ToUTF8()); } Stop(); Start(TIMER_INTERVAL); } }