void TFilePanel::OpenSelectionCommon(BMessage* openMessage) { if (!openMessage->HasRef("refs")) return; for (int32 index = 0; ; index++) { entry_ref ref; if (openMessage->FindRef("refs", index, &ref) != B_OK) break; BEntry entry(&ref, true); if (entry.InitCheck() == B_OK) { if (entry.IsDirectory()) BRoster().AddToRecentFolders(&ref); else BRoster().AddToRecentDocuments(&ref); } } BRoster().AddToRecentFolders(TargetModel()->EntryRef()); if (fClientObject) fClientObject->SendMessage(&fTarget, openMessage); else fTarget.SendMessage(openMessage); // close window if we're dealing with standard message if (fHideWhenDone) PostMessage(B_QUIT_REQUESTED); }
status_t BRecentAppsList::GetNextRef(entry_ref* ref) { if (fIndex == 0) { // Lazy roster Get BRoster().GetRecentApps(&fItems, fMaxItems); } return BRecentItemsList::GetNextRef(ref); }
status_t BRecentFilesList::GetNextRef(entry_ref* ref) { if (fIndex == 0) { // Lazy roster Get if (fTypes != NULL) { BRoster().GetRecentDocuments(&fItems, fMaxItems, const_cast<const char**>(fTypes), fTypeCount, fAppSig.Length() ? fAppSig.String() : NULL); } else { BRoster().GetRecentDocuments(&fItems, fMaxItems, fType.Length() ? fType.String() : NULL, fAppSig.Length() ? fAppSig.String() : NULL); } } return BRecentItemsList::GetNextRef(ref); }
status_t BRecentFoldersList::GetNextRef(entry_ref* ref) { if (fIndex == 0) { // Lazy roster Get BRoster().GetRecentFolders(&fItems, fMaxItems, fAppSig.Length() ? fAppSig.String() : NULL); } return BRecentItemsList::GetNextRef(ref); }
// init_unit_tester_messenger static status_t init_unit_tester_messenger() { // Unfortunately BeOS R5 doesn't update the roster-side information about // the app looper's port ID once a BApplication has been created, and // thus we can't construct a BMessenger targeting a BApplication created // after the first one using the signature/team ID constructor. // We need to do some hacking. struct fake_messenger { port_id fPort; int32 fHandlerToken; team_id fTeam; int32 extra0; int32 extra1; bool fPreferredTarget; bool extra2; bool extra3; bool extra4; } &fake = *(fake_messenger*)&unitTesterMessenger; // get team status_t error = B_OK; fake.fTeam = BRoster().TeamFor(kUnitTesterSignature); if (fake.fTeam < 0) error = fake.fTeam; // find app looper port bool found = false; int32 cookie = 0; port_info info; while (error == B_OK && !found) { error = get_next_port_info(fake.fTeam, &cookie, &info); found = (error == B_OK && !strcmp("AppLooperPort", info.name)); } // init messenger if (error == B_OK) { fake.fPort = info.port; fake.fHandlerToken = 0; fake.fPreferredTarget = true; } return error; }
bool FavoritesMenu::AddNextItem() { // run the next chunk of code for a given item adding state if (fState == kStart) { fState = kAddingFavorites; fSectionItemCount = 0; fAddedSeparatorForSection = false; // set up adding the GoTo menu items try { BPath path; ThrowOnError(find_directory(B_USER_SETTINGS_DIRECTORY, &path, true)); path.Append(kGoDirectory); mkdir(path.Path(), 0777); BEntry entry(path.Path()); Model startModel(&entry, true); ThrowOnInitCheckError(&startModel); if (!startModel.IsContainer()) throw B_ERROR; if (startModel.IsQuery()) fContainer = new QueryEntryListCollection(&startModel); else fContainer = new DirectoryEntryList(*dynamic_cast<BDirectory*> (startModel.Node())); ThrowOnInitCheckError(fContainer); ThrowOnError( fContainer->Rewind() ); } catch (...) { delete fContainer; fContainer = NULL; } } if (fState == kAddingFavorites) { entry_ref ref; if (fContainer && fContainer->GetNextRef(&ref) == B_OK) { Model model(&ref, true); if (model.InitCheck() != B_OK) return true; if (!ShouldShowModel(&model)) return true; BMenuItem* item = BNavMenu::NewModelItem(&model, model.IsDirectory() ? fOpenFolderMessage : fOpenFileMessage, fTarget); if (item == NULL) return true; item->SetLabel(ref.name); // this is the name of the link in the Go dir if (!fAddedSeparatorForSection) { fAddedSeparatorForSection = true; AddItem(new TitledSeparatorItem(B_TRANSLATE("Favorites"))); } fUniqueRefCheck.push_back(*model.EntryRef()); AddItem(item); fSectionItemCount++; return true; } // done with favorites, set up for adding recent files fState = kAddingFiles; fAddedSeparatorForSection = false; app_info info; be_app->GetAppInfo(&info); fItems.MakeEmpty(); int32 apps, docs, folders; TrackerSettings().RecentCounts(&apps, &docs, &folders); BRoster().GetRecentDocuments(&fItems, docs, NULL, info.signature); fIndex = 0; fSectionItemCount = 0; } if (fState == kAddingFiles) { // if this is a Save panel, not an Open panel // then don't add the recent documents if (!fIsSavePanel) { for (;;) { entry_ref ref; if (fItems.FindRef("refs", fIndex++, &ref) != B_OK) break; Model model(&ref, true); if (model.InitCheck() != B_OK) return true; if (!ShouldShowModel(&model)) return true; BMenuItem* item = BNavMenu::NewModelItem(&model, fOpenFileMessage, fTarget); if (item) { if (!fAddedSeparatorForSection) { fAddedSeparatorForSection = true; AddItem(new TitledSeparatorItem( B_TRANSLATE("Recent documents"))); } AddItem(item); fSectionItemCount++; return true; } } } // done with recent files, set up for adding recent folders fState = kAddingFolders; fAddedSeparatorForSection = false; app_info info; be_app->GetAppInfo(&info); fItems.MakeEmpty(); int32 apps, docs, folders; TrackerSettings().RecentCounts(&apps, &docs, &folders); BRoster().GetRecentFolders(&fItems, folders, info.signature); fIndex = 0; } if (fState == kAddingFolders) { for (;;) { entry_ref ref; if (fItems.FindRef("refs", fIndex++, &ref) != B_OK) break; // don't add folders that are already in the GoTo section if (find_if(fUniqueRefCheck.begin(), fUniqueRefCheck.end(), bind2nd(std::equal_to<entry_ref>(), ref)) != fUniqueRefCheck.end()) { continue; } Model model(&ref, true); if (model.InitCheck() != B_OK) return true; if (!ShouldShowModel(&model)) return true; BMenuItem* item = BNavMenu::NewModelItem(&model, fOpenFolderMessage, fTarget, true); if (item) { if (!fAddedSeparatorForSection) { fAddedSeparatorForSection = true; AddItem(new TitledSeparatorItem( B_TRANSLATE("Recent folders"))); } AddItem(item); item->SetEnabled(true); // BNavMenu::NewModelItem returns a disabled item here - // need to fix this in BNavMenu::NewModelItem return true; } } } return false; }