/*! \brief Checks whether the (pre-)registered applications are still running. This is necessary, since killed applications don't unregister properly. */ void TRoster::CheckSanity() { BAutolock _(fLock); // not early (pre-)registered applications AppInfoList obsoleteApps; for (AppInfoList::Iterator it = fRegisteredApps.It(); it.IsValid(); ++it) { if (!(*it)->IsRunning()) obsoleteApps.AddInfo(*it); } // remove the apps for (AppInfoList::Iterator it = obsoleteApps.It(); it.IsValid(); ++it) { RemoveApp(*it); delete *it; } obsoleteApps.MakeEmpty(false); // don't delete infos a second time // early pre-registered applications bigtime_t timeLimit = system_time() - kMaximalEarlyPreRegistrationPeriod; for (AppInfoList::Iterator it = fEarlyPreRegisteredApps.It(); it.IsValid(); ++it) { if ((*it)->registration_time < timeLimit) obsoleteApps.AddInfo(*it); } // remove the apps for (AppInfoList::Iterator it = obsoleteApps.It(); it.IsValid(); ++it) { fEarlyPreRegisteredApps.RemoveInfo(*it); delete *it; } obsoleteApps.MakeEmpty(false); // don't delete infos a second time }
void ShutdownProcess::_AddShutdownWindowApps(AppInfoList& infos) { if (!fHasGUI) return; for (AppInfoList::Iterator it = infos.It(); it.IsValid(); ++it) { RosterAppInfo* info = *it; // init an app file info BFile file; status_t error = file.SetTo(&info->ref, B_READ_ONLY); if (error != B_OK) { WARNING(("ShutdownProcess::_AddShutdownWindowApps(): Failed to " "open file for app %s: %s\n", info->signature, strerror(error))); continue; } BAppFileInfo appFileInfo; error = appFileInfo.SetTo(&file); if (error != B_OK) { WARNING(("ShutdownProcess::_AddShutdownWindowApps(): Failed to " "init app file info for app %s: %s\n", info->signature, strerror(error))); } // get the application icons #ifdef __HAIKU__ color_space format = B_RGBA32; #else color_space format = B_CMAP8; #endif // mini icon BBitmap* miniIcon = new(nothrow) BBitmap(BRect(0, 0, 15, 15), format); if (miniIcon != NULL) { error = miniIcon->InitCheck(); if (error == B_OK) error = appFileInfo.GetTrackerIcon(miniIcon, B_MINI_ICON); if (error != B_OK) { delete miniIcon; miniIcon = NULL; } } // mini icon BBitmap* largeIcon = new(nothrow) BBitmap(BRect(0, 0, 31, 31), format); if (largeIcon != NULL) { error = largeIcon->InitCheck(); if (error == B_OK) error = appFileInfo.GetTrackerIcon(largeIcon, B_LARGE_ICON); if (error != B_OK) { delete largeIcon; largeIcon = NULL; } } // add the app error = fWindow->AddApp(info->team, miniIcon, largeIcon); if (error != B_OK) { WARNING(("ShutdownProcess::_AddShutdownWindowApps(): Failed to " "add app to the shutdown window: %s\n", strerror(error))); } } }