/* bool IsRunning(entry_ref *ref) const @case 2 ref is not NULL, but no app with this ref is running @results Should return false. */ void IsRunningTester::IsRunningTestB2() { BRoster roster; entry_ref ref; CHK(find_test_app("AppRunTestApp1", &ref) == B_OK); CHK(roster.IsRunning(&ref) == false); }
status_t TBarView::SendDragMessage(const char* signature, entry_ref* ref) { status_t err = B_ERROR; if (fDragMessage) { if (fRefsRcvdOnly) { // current message sent to apps is only B_REFS_RECEIVED fDragMessage->what = B_REFS_RECEIVED; } BRoster roster; if (signature && strlen(signature) > 0 && roster.IsRunning(signature)) { BMessenger mess(signature); // drag message is still owned by DB, copy is sent // can toss it after send err = mess.SendMessage(fDragMessage); } else if (ref) { FSLaunchItem((const entry_ref*)ref, (const BMessage*)fDragMessage, true, true); } else if (signature && strlen(signature) > 0) { roster.Launch(signature, fDragMessage); } } return err; }
/* bool IsRunning(entry_ref *ref) const @case 1 ref is NULL @results Should return false. */ void IsRunningTester::IsRunningTestB1() { // R5: crashes when passing a NULL ref #ifndef TEST_R5 BRoster roster; CHK(roster.IsRunning((entry_ref*)NULL) == false); #endif }
/* bool IsRunning(const char *signature) const @case 3 signature is not NULL and an (two) app(s) with this signature is (are) running; quit one; quit the second one @results Should return true; true; false. */ void IsRunningTester::IsRunningTestA3() { // run the remote apps AppRunner runner1(true); AppRunner runner2(true); CHK(runner1.Run("AppRunTestApp1") == B_OK); CHK(runner2.Run("AppRunTestApp1") == B_OK); // create the BRoster and perform the tests BRoster roster; CHK(roster.IsRunning("application/x-vnd.obos-app-run-testapp1") == true); // quit app 1 runner1.WaitFor(true); CHK(roster.IsRunning("application/x-vnd.obos-app-run-testapp1") == true); // quit app 2 runner2.WaitFor(true); CHK(roster.IsRunning("application/x-vnd.obos-app-run-testapp1") == false); }
/* bool IsRunning(const char *signature) const @case 1 signature is NULL @results Should return false. */ void IsRunningTester::IsRunningTestA1() { // R5: crashes when passing a NULL signature #ifndef TEST_R5 BRoster roster; CHK(roster.IsRunning((const char*)NULL) == false); #endif }
/* bool IsRunning(entry_ref *ref) const @case 3 ref is not NULL and an (two) app(s) with this ref is (are) running; quit one; quit the second one @results Should return true; true; false. */ void IsRunningTester::IsRunningTestB3() { entry_ref ref; CHK(find_test_app("AppRunTestApp1", &ref) == B_OK); // run the remote apps AppRunner runner1(true); AppRunner runner2(true); CHK(runner1.Run("AppRunTestApp1") == B_OK); CHK(runner2.Run("AppRunTestApp1") == B_OK); // create the BRoster and perform the tests BRoster roster; CHK(roster.IsRunning(&ref) == true); // quit app 1 runner1.WaitFor(true); CHK(roster.IsRunning(&ref) == true); // quit app 2 runner2.WaitFor(true); CHK(roster.IsRunning(&ref) == false); }
/* bool IsRunning(const char *signature) const @case 2 signature is not NULL, but no app with this signature is running @results Should return false. */ void IsRunningTester::IsRunningTestA2() { BRoster roster; CHK(roster.IsRunning("application/x-vnd.obos-app-run-testapp1") == false); }
bool TDeskbarMenu::AddStandardDeskbarMenuItems() { bool dragging = false; if (fBarView) dragging = fBarView->Dragging(); BMenuItem* item; BRoster roster; if (!roster.IsRunning(kTrackerSignature)) { item = new BMenuItem(B_TRANSLATE("Restart Tracker"), new BMessage(kRestartTracker)); AddItem(item); AddSeparatorItem(); } // One of them is used if HAIKU_DISTRO_COMPATIBILITY_OFFICIAL, and the other if // not. However, we want both of them to end up in the catalog, so we have to // make them visible to collectcatkeys in either case. B_TRANSLATE_MARK_VOID("About Haiku") B_TRANSLATE_MARK_VOID("About this system") item = new BMenuItem( #ifdef HAIKU_DISTRO_COMPATIBILITY_OFFICIAL B_TRANSLATE_NOCOLLECT("About Haiku") #else B_TRANSLATE_NOCOLLECT("About this system") #endif , new BMessage(kShowSplash)); item->SetEnabled(!dragging); AddItem(item); static const char* kFindMenuItemStr = B_TRANSLATE_MARK("Find" B_UTF8_ELLIPSIS); #ifdef SHOW_RECENT_FIND_ITEMS item = new BMenuItem( TrackerBuildRecentFindItemsMenu(kFindMenuItemStr), new BMessage(kFindButton)); #else item = new BMenuItem(B_TRANSLATE_NOCOLLECT(kFindMenuItemStr), new BMessage(kFindButton)); #endif item->SetEnabled(!dragging); AddItem(item); item = new BMenuItem(B_TRANSLATE("Show replicants"), new BMessage(kToggleDraggers)); item->SetEnabled(!dragging); item->SetMarked(BDragger::AreDraggersDrawn()); AddItem(item); static const char* kMountMenuStr = B_TRANSLATE_MARK("Mount"); #ifdef MOUNT_MENU_IN_DESKBAR DeskbarMountMenu* mountMenu = new DeskbarMountMenu( B_TRANSLATE_NOCOLLECT(kMountMenuStr)); mountMenu->SetEnabled(!dragging); AddItem(mountMenu); #endif item = new BMenuItem(B_TRANSLATE("Deskbar preferences" B_UTF8_ELLIPSIS), new BMessage(kConfigShow)); item->SetTarget(be_app); AddItem(item); AddSeparatorItem(); BMenu* shutdownMenu = new BMenu(B_TRANSLATE("Shutdown" B_UTF8_ELLIPSIS)); item = new BMenuItem(B_TRANSLATE("Restart system"), new BMessage(kRebootSystem)); item->SetEnabled(!dragging); shutdownMenu->AddItem(item); B_TRANSLATE_MARK_VOID("Suspend"); #ifdef APM_SUPPORT if (_kapm_control_(APM_CHECK_ENABLED) == B_OK) { item = new BMenuItem(B_TRANSLATE_NOCOLLECT("Suspend"), new BMessage(kSuspendSystem)); item->SetEnabled(!dragging); shutdownMenu->AddItem(item); } #endif item = new BMenuItem(B_TRANSLATE("Power off"), new BMessage(kShutdownSystem)); item->SetEnabled(!dragging); shutdownMenu->AddItem(item); shutdownMenu->SetFont(be_plain_font); shutdownMenu->SetTargetForItems(be_app); BMessage* message = new BMessage(kShutdownSystem); message->AddBool("confirm", true); AddItem(new BMenuItem(shutdownMenu, message)); fAddState = kAddingRecents; return true; }
bool TBeMenu::AddStandardBeMenuItems() { bool dragging = false; if (fBarView) dragging = fBarView->Dragging(); BMenuItem* item; BRoster roster; if (!roster.IsRunning(kTrackerSignature)) { item = new BMenuItem(B_TRANSLATE("Restart Tracker"), new BMessage(kRestartTracker)); AddItem(item); AddSeparatorItem(); } static const char* kAboutHaikuMenuItemStr = B_TRANSLATE_MARK( "About Haiku" B_UTF8_ELLIPSIS); static const char* kAboutThisSystemMenuItemStr = B_TRANSLATE_MARK( "About this system" B_UTF8_ELLIPSIS); item = new BMenuItem( #ifdef HAIKU_DISTRO_COMPATIBILITY_OFFICIAL B_TRANSLATE(kAboutHaikuMenuItemStr) #else B_TRANSLATE(kAboutThisSystemMenuItemStr) #endif , new BMessage(kShowSplash)); item->SetEnabled(!dragging); AddItem(item); static const char* kFindMenuItemStr = B_TRANSLATE_MARK("Find" B_UTF8_ELLIPSIS); #ifdef SHOW_RECENT_FIND_ITEMS item = new BMenuItem( TrackerBuildRecentFindItemsMenu(kFindMenuItemStr), new BMessage(kFindButton)); #else item = new BMenuItem(B_TRANSLATE(kFindMenuItemStr), new BMessage(kFindButton)); #endif item->SetEnabled(!dragging); AddItem(item); item = new BMenuItem(B_TRANSLATE("Show replicants"), new BMessage(kToggleDraggers)); item->SetEnabled(!dragging); item->SetMarked(BDragger::AreDraggersDrawn()); AddItem(item); static const char* kMountMenuStr = B_TRANSLATE_MARK("Mount"); #ifdef MOUNT_MENU_IN_DESKBAR DeskbarMountMenu* mountMenu = new DeskbarMountMenu( B_TRANSLATE(kMountMenuStr)); mountMenu->SetEnabled(!dragging); AddItem(mountMenu); #endif item = new BMenuItem(B_TRANSLATE("Deskbar preferences" B_UTF8_ELLIPSIS), new BMessage(kConfigShow)); item->SetTarget(be_app); AddItem(item); AddSeparatorItem(); BMenu* shutdownMenu = new BMenu(B_TRANSLATE("Shutdown" B_UTF8_ELLIPSIS)); item = new BMenuItem(B_TRANSLATE("Restart system"), new BMessage(kRebootSystem)); item->SetEnabled(!dragging); shutdownMenu->AddItem(item); static const char* kSuspendMenuItemStr = B_TRANSLATE_MARK("Suspend"); #ifdef APM_SUPPORT if (_kapm_control_(APM_CHECK_ENABLED) == B_OK) { item = new BMenuItem(kSuspendMenuItemStr), new BMessage(kSuspendSystem)); item->SetEnabled(!dragging); shutdownMenu->AddItem(item); }