status_t NotificationView::LoadAppUsage(void) { SettingsFile settings("appsettings", "BeClan/InfoPopper", B_USER_SETTINGS_DIRECTORY); status_t error = settings.InitCheck(); if (settings.InitCheck() != B_OK) return B_ERROR; error = settings.Load(); if (error != B_OK) return B_ERROR; appview_t::iterator avIt; appusage_t::iterator auIt; for (avIt = fAppView.begin(); avIt != fAppView.end(); avIt++) { avIt->second->RemoveSelf(); delete avIt->second; }; fAppView.clear(); fCurrentAppView = NULL; for (auIt = fAppUsage.begin(); auIt != fAppUsage.end(); auIt++) delete auIt->second; fAppUsage.clear(); type_code type; int32 count = 0; error = settings.GetInfo("app_usage", &type, &count); if (error != B_OK) return B_ERROR; for (int32 i = 0; i < count; i++) { AppUsage *app = new AppUsage(); settings.FindFlat("app_usage", i, app); fAppUsage[app->Name()] = app; }; return B_OK; };
status_t NotificationsView::Load(BMessage& settings) { type_code type; int32 count = 0; if (settings.GetInfo("app_usage", &type, &count) != B_OK) return B_ERROR; // Clean filters appusage_t::iterator auIt; for (auIt = fAppFilters.begin(); auIt != fAppFilters.end(); auIt++) delete auIt->second; fAppFilters.clear(); // Add new filters for (int32 i = 0; i < count; i++) { AppUsage* app = new AppUsage(); settings.FindFlat("app_usage", i, app); fAppFilters[app->Name()] = app; } // Load the applications list _PopulateApplications(); return B_OK; }
void NotificationWindow::_LoadAppFilters(BMessage& settings) { type_code type; int32 count = 0; if (settings.GetInfo("app_usage", &type, &count) != B_OK) return; for (int32 i = 0; i < count; i++) { AppUsage* app = new AppUsage(); settings.FindFlat("app_usage", i, app); fAppFilters[app->Name()] = app; } }
void NotificationWindow::LoadAppFilters(bool startMonitor) { BPath path; if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK) return; path.Append(kSettingsDirectory); if (create_directory(path.Path(), 0755) != B_OK) return; path.Append(kFiltersSettings); BFile file(path.Path(), B_READ_ONLY); BMessage settings; if (settings.Unflatten(&file) != B_OK) return; type_code type; int32 count = 0; if (settings.GetInfo("app_usage", &type, &count) != B_OK) return; for (int32 i = 0; i < count; i++) { AppUsage* app = new AppUsage(); settings.FindFlat("app_usage", i, app); fAppFilters[app->Name()] = app; } if (startMonitor) { node_ref nref; BEntry entry(path.Path()); entry.GetNodeRef(&nref); if (watch_node(&nref, B_WATCH_ALL, BMessenger(this)) != B_OK) { BAlert* alert = new BAlert(B_TRANSLATE("Warning"), B_TRANSLATE("Couldn't start filter monitor." " Live filter changes disabled."), B_TRANSLATE("Darn.")); alert->Go(); } } }