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 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); }
/*! \brief Looks up a localized filename from a catalog. \param localizedFileName A pre-allocated BString object for the result of the lookup. \param ref An entry_ref with an attribute holding data for catalog lookup. \param traverse A boolean to decide if symlinks are to be traversed. \return - \c B_OK: success - \c B_ENTRY_NOT_FOUND: failure. Attribute not found, entry not found in catalog, etc - other error codes: failure Attribute format: "signature:context:string" (no colon in any of signature, context and string) Lookup is done for the top preferred language, only. Lookup fails if a comment is present in the catalog entry. */ status_t BLocaleRoster::GetLocalizedFileName(BString& localizedFileName, const entry_ref& ref, bool traverse) { BString signature; BString context; BString string; status_t status = _PrepareCatalogEntry(ref, signature, context, string, traverse); if (status != B_OK) return status; // Try to get entry_ref for signature from above BRoster roster; entry_ref catalogRef; // The signature is missing application/ signature.Prepend("application/"); status = roster.FindApp(signature, &catalogRef); if (status != B_OK) return status; BCatalog catalog(catalogRef); const char* temp = catalog.GetString(string, context); if (temp == NULL) return B_ENTRY_NOT_FOUND; localizedFileName = temp; return B_OK; }
/* void GetAppList(BList *teamIDList) const @case 1 teamIDList is NULL @results Should do nothing. */ void GetAppListTester::GetAppListTestA1() { // R5: crashes when passing a NULL BList #ifndef TEST_R5 BRoster roster; roster.GetAppList(NULL); #endif }
/* 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 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 }
/*********************************************************** * InstallDeskbarIcon ***********************************************************/ void HDaemonApp::InstallDeskbarIcon() { BDeskbar deskbar; if(deskbar.HasItem( "scooby_daemon" ) == false) { BRoster roster; entry_ref ref; roster.FindApp( APP_SIG , &ref); int32 id; deskbar.AddItem(&ref, &id); } }
bool RecentsMenu::AddRecents(int32 count) { if (fItemIndex == 0) { fRecentList.MakeEmpty(); BRoster roster; switch(fWhich) { case 0: roster.GetRecentDocuments(&fRecentList, count); break; case 1: roster.GetRecentApps(&fRecentList, count); break; case 2: roster.GetRecentFolders(&fRecentList, count); break; default: return false; break; } } for (;;) { entry_ref ref; if (fRecentList.FindRef("refs", fItemIndex++, &ref) != B_OK) break; if (ref.name != NULL && strlen(ref.name) > 0) { Model model(&ref, true); ModelMenuItem* item = BNavMenu::NewModelItem(&model, new BMessage(fMessage.what), Target(), false, NULL, TypesList()); if (item != NULL) { AddItem(item); // return true so that we know to reenter this list return true; } return true; } } // // return false if we are done with this list // return false; }
/* 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); }
void BeGadu::AddDeskbarIcon() { DEBUG_TRACE( "BeGadu::AddDeskbarIcon()\n" ); BDeskbar deskbar; if( !deskbar.HasItem( "BGDeskbar" ) ) { BRoster roster; entry_ref ref; status_t status = roster.FindApp( APP_MIME, &ref ); if( status != B_OK ) { fprintf( stderr, _T("Can't find BeGadu running: %s\n"), strerror( status ) ); return; } status = deskbar.AddItem( &ref ); if( status != B_OK ) { fprintf( stderr, _T("Can't put BeGadu into Deskbar: %s\n"), strerror( status ) ); return; } } }
/* 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); }
char *__PHYSFS_platformCalcBaseDir(const char *argv0) { /* in case there isn't a BApplication yet, we'll construct a roster. */ BRoster roster; app_info info; status_t rc = roster.GetRunningAppInfo(getTeamID(), &info); BAIL_IF_MACRO(rc < B_OK, strerror(rc), NULL); BEntry entry(&(info.ref), true); BPath path; rc = entry.GetPath(&path); /* (path) now has binary's path. */ assert(rc == B_OK); rc = path.GetParent(&path); /* chop filename, keep directory. */ assert(rc == B_OK); const char *str = path.Path(); assert(str != NULL); char *retval = (char *) allocator.Malloc(strlen(str) + 1); BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL); strcpy(retval, str); return(retval); } /* __PHYSFS_platformCalcBaseDir */
bool LgiExecute(const char *File, const char *Args, const char *Dir, GAutoString *ErrorMsg) { if (File) { char f[256]; if (ValidStr(Dir)) { sprintf(f, "%s/%s", Dir, File); } else { strcpy(f, File); } BRoster Roster; BEntry Entry(f); entry_ref Ref; if (Entry.GetRef(&Ref) == B_OK) { status_t s = B_ERROR; if (stricmp(f, "/BeOS") == 0 || stricmp(f, "/") == 0 || Entry.IsDirectory()) { char *DirMimeType = "application/x-vnd.Be-directory"; if (Roster.FindApp(DirMimeType, &Ref) == B_OK) { char *Arg[1] = {File}; s = Roster.Launch(&Ref, 1, Arg); } } else { s = Roster.Launch(&Ref); } return s == B_OK || s == B_ALREADY_RUNNING; } else { if (strnicmp(File, "http://", 7) == 0) { if (Roster.FindApp("text/html", &Ref) == B_OK) { /* char *Arg[2] = {Ref.name, File}; return Roster.Launch(&Ref, 2, Arg) == B_OK; */ char *Arg[1] = {File}; status_t s = Roster.Launch(&Ref, 1, Arg); return s == B_OK || s == B_ALREADY_RUNNING; } } } } return false; }
//------------------------------------------------------------------------------ std::string TInstantiateObjectTester::GetLocalSignature() { BRoster Roster; app_info ai; team_id team; // Get the team_id of this app thread_id tid = find_thread(NULL); thread_info ti; status_t err = get_thread_info(tid, &ti); if (err) { FORMAT_AND_THROW(" failed to get thread_info: ", err); } // Get the app_info via the team_id team = ti.team; team_info info; err = get_team_info(team, &info); if (err) { FORMAT_AND_THROW(" failed to get team_info: ", err); } team = info.team; // It seems that this call to GetRunningAppInfo() is not working because we // don't have an instance of BApplication somewhere -- the roster, therefore, // doesn't know about us. err = Roster.GetRunningAppInfo(team, &ai); if (err) { FORMAT_AND_THROW(" failed to get app_info: ", err); } // Return the signature from the app_info return ai.signature; }
void MailDaemonApp::InstallDeskbarIcon() { BDeskbar deskbar; if (!deskbar.HasItem("mail_daemon")) { BRoster roster; entry_ref ref; status_t status = roster.FindApp(B_MAIL_DAEMON_SIGNATURE, &ref); if (status < B_OK) { fprintf(stderr, "Can't find application to tell deskbar: %s\n", strerror(status)); return; } status = deskbar.AddItem(&ref); if (status < B_OK) { fprintf(stderr, "Can't add deskbar replicant: %s\n", strerror(status)); return; } } }
/* void GetAppList(const char *signature, BList *teamIDList) const @case 1 signature or teamIDList are NULL @results Should do nothing/should not modify teamIDList. */ void GetAppListTester::GetAppListTestB1() { // R5: crashes when passing a NULL signature/BList #ifndef TEST_R5 const char *signature = "application/x-vnd.obos-app-run-testapp1"; // create a list with some dummy entries BList emptyList; BList list; list.AddItem((void*)-7); list.AddItem((void*)-42); // NULL signature and list BRoster roster; roster.GetAppList(NULL, NULL); // NULL signature BList list1(list); roster.GetAppList(NULL, &list1); check_list(list1, list, list, emptyList); // NULL list AppRunner runner(true); CHK(runner.Run("AppRunTestApp1") == B_OK); roster.GetAppList(signature, NULL); runner.WaitFor(true); #endif }
/* void GetAppList(const char *signature, BList *teamIDList) const @case 3 teamIDList is not NULL and not empty, signature is not NULL and app(s) with this signature is (are) running @results Should append the team IDs of all running apps with the supplied signature to teamIDList. */ void GetAppListTester::GetAppListTestB3() { const char *signature = "application/x-vnd.obos-app-run-testapp1"; // create a list with some dummy entries BList list; list.AddItem((void*)-7); list.AddItem((void*)-42); // get a list of running applications for reference BRoster roster; BList list1(list); roster.GetAppList(signature, &list1); check_list(list1, list); // run some apps AppRunner runner1(true); AppRunner runner2(true); AppRunner runner3(true); CHK(runner1.Run("AppRunTestApp1") == B_OK); CHK(runner2.Run("AppRunTestApp2") == B_OK); CHK(runner3.Run("BMessengerTestApp1") == B_OK); BList expectedApps; expectedApps.AddItem((void*)runner1.Team()); expectedApps.AddItem((void*)runner2.Team()); // get a new app list and check it BList list2(list); roster.GetAppList(signature, &list2); check_list(list2, list, expectedApps); // quit app 1 runner1.WaitFor(true); expectedApps.RemoveItem((void*)runner1.Team()); BList list3(list); roster.GetAppList(signature, &list3); check_list(list3, list, expectedApps); // quit app 2 runner2.WaitFor(true); expectedApps.RemoveItem((void*)runner2.Team()); BList list4(list); roster.GetAppList(signature, &list4); check_list(list4, list, expectedApps); // quit app 3 runner3.WaitFor(true); BList list5(list); roster.GetAppList(signature, &list5); check_list(list5, list, expectedApps); }
/*! Message must contain an archivable view for later rehydration. This function takes over ownership of the provided message on success only. Returns the current replicant ID. */ status_t TReplicantTray::AddIcon(BMessage* archive, int32* id, const entry_ref* addOn) { if (archive == NULL || id == NULL) return B_ERROR; // find entry_ref entry_ref ref; if (addOn) { // Use it if we got it ref = *addOn; } else { const char* signature; status_t status = archive->FindString("add_on", &signature); if (status == B_OK) { BRoster roster; status = roster.FindApp(signature, &ref); } if (status < B_OK) return status; } BFile file; status_t status = file.SetTo(&ref, B_READ_ONLY); if (status < B_OK) return status; node_ref nodeRef; status = file.GetNodeRef(&nodeRef); if (status < B_OK) return status; BEntry entry(&ref, true); // TODO: this resolves an eventual link for the item being added - this // is okay for now, but in multi-user environments, one might want to // have links that carry the be:deskbar_item_status attribute status = entry.InitCheck(); if (status != B_OK) return status; *id = 999; if (archive->what == B_ARCHIVED_OBJECT) archive->what = 0; BRect originalBounds = archive->FindRect("_frame"); // this is a work-around for buggy replicants that change their size in // AttachedToWindow() (such as "SVM") // TODO: check for name collisions? status = fShelf->AddReplicant(archive, BPoint(1, 1)); if (status != B_OK) return status; int32 count = fShelf->CountReplicants(); BView* view; fShelf->ReplicantAt(count - 1, &view, (uint32*)id, NULL); if (originalBounds != view->Bounds()) { // The replicant changed its size when added to the window, so we need // to recompute all over again (it's already done once via // BShelf::AddReplicant() and TReplicantShelf::CanAcceptReplicantView()) RealignReplicants(); } float oldWidth = Bounds().Width(); float oldHeight = Bounds().Height(); float width, height; GetPreferredSize(&width, &height); if (oldWidth != width || oldHeight != height) AdjustPlacement(); // add the item to the add-on list AddItem(*id, nodeRef, entry, addOn != NULL); return B_OK; }
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); }
/* 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; }
/* status_t Broadcast(BMessage *message, BMessenger replyTo) const @case 3 valid message, several apps, one is B_ARGV_ONLY, invalid replyTo @results Should return B_OK and send the message to all (including the B_ARGV_ONLY) apps. Replies go to the roster! */ void BroadcastTester::BroadcastTestB3() { LaunchContext context; BRoster roster; // launch app 1 entry_ref ref1(create_app(appFile1, appType1)); SimpleAppLauncher caller1(ref1); team_id team1; CHK(context(caller1, appType1, &team1) == B_OK); // launch app 2 entry_ref ref2(create_app(appFile2, appType2, false, true, B_SINGLE_LAUNCH | B_ARGV_ONLY)); SimpleAppLauncher caller2(ref2); team_id team2; CHK(context(caller2, appType2, &team2) == B_OK); // launch app 3 entry_ref ref3(create_app(appFile3, appType3)); SimpleAppLauncher caller3(ref3); team_id team3; CHK(context(caller3, appType3, &team3) == B_OK); // launch app 4 entry_ref ref4(create_app(appFile4, appType4)); SimpleAppLauncher caller4(ref4); team_id team4; CHK(context(caller4, appType4, &team4) == B_OK); // wait for the apps to run context.WaitForMessage(team1, MSG_READY_TO_RUN); context.WaitForMessage(team2, MSG_READY_TO_RUN); context.WaitForMessage(team3, MSG_READY_TO_RUN); context.WaitForMessage(team4, MSG_READY_TO_RUN); // broadcast a message BMessage message(MSG_1); BMessenger replyTo; CHK(roster.Broadcast(&message, replyTo) == B_OK); // wait for the apps to report the receipt of the message context.WaitForMessage(team1, MSG_MESSAGE_RECEIVED); context.WaitForMessage(team2, MSG_MESSAGE_RECEIVED); context.WaitForMessage(team3, MSG_MESSAGE_RECEIVED); context.WaitForMessage(team4, MSG_MESSAGE_RECEIVED); // check the messages context.Terminate(); // app 1 int32 cookie = 0; CHK(context.CheckNextMessage(caller1, team1, cookie, MSG_STARTED)); CHK(context.CheckMainArgsMessage(caller1, team1, cookie, &ref1, false)); CHK(context.CheckNextMessage(caller1, team1, cookie, MSG_READY_TO_RUN)); CHK(context.CheckMessageMessage(caller1, team1, cookie, &message)); // CHK(context.CheckNextMessage(caller1, team1, cookie, MSG_2)); CHK(context.CheckNextMessage(caller1, team1, cookie, MSG_QUIT_REQUESTED)); CHK(context.CheckNextMessage(caller1, team1, cookie, MSG_TERMINATED)); // app 2 cookie = 0; CHK(context.CheckNextMessage(caller2, team2, cookie, MSG_STARTED)); CHK(context.CheckMainArgsMessage(caller2, team2, cookie, &ref2, false)); CHK(context.CheckNextMessage(caller2, team2, cookie, MSG_READY_TO_RUN)); CHK(context.CheckMessageMessage(caller2, team2, cookie, &message)); // CHK(context.CheckNextMessage(caller2, team2, cookie, MSG_2)); CHK(context.CheckNextMessage(caller2, team2, cookie, MSG_QUIT_REQUESTED)); CHK(context.CheckNextMessage(caller2, team2, cookie, MSG_TERMINATED)); // app 3 cookie = 0; CHK(context.CheckNextMessage(caller3, team3, cookie, MSG_STARTED)); CHK(context.CheckMainArgsMessage(caller3, team3, cookie, &ref3, false)); CHK(context.CheckNextMessage(caller3, team3, cookie, MSG_READY_TO_RUN)); CHK(context.CheckMessageMessage(caller3, team3, cookie, &message)); // CHK(context.CheckNextMessage(caller3, team3, cookie, MSG_2)); CHK(context.CheckNextMessage(caller3, team3, cookie, MSG_QUIT_REQUESTED)); CHK(context.CheckNextMessage(caller3, team3, cookie, MSG_TERMINATED)); // app 4 cookie = 0; CHK(context.CheckNextMessage(caller4, team4, cookie, MSG_STARTED)); CHK(context.CheckMainArgsMessage(caller4, team4, cookie, &ref4, false)); CHK(context.CheckNextMessage(caller4, team4, cookie, MSG_READY_TO_RUN)); CHK(context.CheckMessageMessage(caller4, team4, cookie, &message)); // CHK(context.CheckNextMessage(caller4, team4, cookie, MSG_2)); CHK(context.CheckNextMessage(caller4, team4, cookie, MSG_QUIT_REQUESTED)); CHK(context.CheckNextMessage(caller4, team4, cookie, MSG_TERMINATED)); }
void TBarApp::MessageReceived(BMessage* message) { switch (message->what) { case 'gloc': case 'sloc': case 'gexp': case 'sexp': case 'info': case 'exst': case 'cwnt': case 'icon': case 'remv': case 'adon': // pass any BDeskbar originating messages on to the window fBarWindow->PostMessage(message); break; case kConfigShow: ShowPreferencesWindow(); break; case kStateChanged: fPreferencesWindow->PostMessage(kStateChanged); break; case kShowBeMenu: if (fBarWindow->Lock()) { fBarWindow->ShowBeMenu(); fBarWindow->Unlock(); } break; case kShowTeamMenu: if (fBarWindow->Lock()) { fBarWindow->ShowTeamMenu(); fBarWindow->Unlock(); } break; case kUpdateRecentCounts: int32 count; bool enabled; if (message->FindInt32("applications", &count) == B_OK) fSettings.recentAppsCount = count; if (message->FindBool("applicationsEnabled", &enabled) == B_OK) fSettings.recentAppsEnabled = enabled && count > 0; if (message->FindInt32("folders", &count) == B_OK) fSettings.recentFoldersCount = count; if (message->FindBool("foldersEnabled", &enabled) == B_OK) fSettings.recentFoldersEnabled = enabled && count > 0; if (message->FindInt32("documents", &count) == B_OK) fSettings.recentDocsCount = count; if (message->FindBool("documentsEnabled", &enabled) == B_OK) fSettings.recentDocsEnabled = enabled && count > 0; break; case kConfigClose: fPreferencesWindow = NULL; break; case B_SOME_APP_LAUNCHED: { team_id team = -1; message->FindInt32("be:team", &team); uint32 flags = 0; message->FindInt32("be:flags", (long*)&flags); const char* sig = NULL; message->FindString("be:signature", &sig); entry_ref ref; message->FindRef("be:ref", &ref); AddTeam(team, flags, sig, &ref); break; } case B_SOME_APP_QUIT: { team_id team = -1; message->FindInt32("be:team", &team); RemoveTeam(team); break; } case B_ARCHIVED_OBJECT: // TODO: what's this??? message->AddString("special", "Alex Osadzinski"); fStatusViewMessenger.SendMessage(message); break; case kToggleDraggers: if (BDragger::AreDraggersDrawn()) BDragger::HideAllDraggers(); else BDragger::ShowAllDraggers(); break; case kAlwaysTop: fSettings.alwaysOnTop = !fSettings.alwaysOnTop; fBarWindow->SetFeel(fSettings.alwaysOnTop ? B_FLOATING_ALL_WINDOW_FEEL : B_NORMAL_WINDOW_FEEL); fPreferencesWindow->PostMessage(kStateChanged); break; case kAutoRaise: fSettings.autoRaise = fSettings.alwaysOnTop ? false : !fSettings.autoRaise; fBarWindow->Lock(); BarView()->UpdateEventMask(); fBarWindow->Unlock(); break; case kAutoHide: fSettings.autoHide = !fSettings.autoHide; fBarWindow->Lock(); BarView()->UpdateEventMask(); BarView()->HideDeskbar(fSettings.autoHide); fBarWindow->Unlock(); break; case kTrackerFirst: fSettings.trackerAlwaysFirst = !fSettings.trackerAlwaysFirst; fBarWindow->Lock(); BarView()->UpdatePlacement(); fBarWindow->Unlock(); break; case kSortRunningApps: fSettings.sortRunningApps = !fSettings.sortRunningApps; fBarWindow->Lock(); BarView()->UpdatePlacement(); fBarWindow->Unlock(); break; case kUnsubscribe: { BMessenger messenger; if (message->FindMessenger("messenger", &messenger) == B_OK) Unsubscribe(messenger); break; } case kSuperExpando: fSettings.superExpando = !fSettings.superExpando; fBarWindow->Lock(); BarView()->UpdatePlacement(); fBarWindow->Unlock(); break; case kExpandNewTeams: fSettings.expandNewTeams = !fSettings.expandNewTeams; fBarWindow->Lock(); BarView()->UpdatePlacement(); fBarWindow->Unlock(); break; case 'TASK': fSwitcherMessenger.SendMessage(message); break; case kSuspendSystem: // TODO: Call BRoster? break; case kRebootSystem: case kShutdownSystem: { bool reboot = (message->what == kRebootSystem); bool confirm; message->FindBool("confirm", &confirm); BRoster roster; BRoster::Private rosterPrivate(roster); status_t error = rosterPrivate.ShutDown(reboot, confirm, false); if (error != B_OK) fprintf(stderr, "Shutdown failed: %s\n", strerror(error)); break; } case kShowSplash: run_be_about(); break; case kRestartTracker: { BRoster roster; roster.Launch(kTrackerSignature); break; } case B_LOCALE_CHANGED: { BLocaleRoster::Default()->Refresh(); bool localize; if (message->FindBool("filesys", &localize) == B_OK) gLocalizedNamePreferred = localize; BMessenger(fBarWindow->FindView("_deskbar_tv_")).SendMessage( message); // Notify the TimeView that the format has changed and it should // recompute its size break; } default: BApplication::MessageReceived(message); break; } }
BArchivable* instantiate_object(BMessage* archive, image_id* _id) { status_t statusBuffer; status_t* status = &statusBuffer; if (_id != NULL) status = _id; // Check our params if (archive == NULL) { syslog(LOG_ERR, "instantiate_object failed: NULL BMessage argument"); *status = B_BAD_VALUE; return NULL; } // Get class name from archive const char* className = NULL; status_t err = archive->FindString(B_CLASS_FIELD, &className); if (err) { syslog(LOG_ERR, "instantiate_object failed: Failed to find an entry " "defining the class name (%s).", strerror(err)); *status = B_BAD_VALUE; return NULL; } // Get sig from archive const char* signature = NULL; bool hasSignature = archive->FindString(B_ADD_ON_FIELD, &signature) == B_OK; instantiation_func instantiationFunc = find_instantiation_func(className, signature); // if find_instantiation_func() can't locate Class::Instantiate() // and a signature was specified if (!instantiationFunc && hasSignature) { // use BRoster::FindApp() to locate an app or add-on with the symbol BRoster Roster; entry_ref ref; err = Roster.FindApp(signature, &ref); // if an entry_ref is obtained BEntry entry; if (err == B_OK) err = entry.SetTo(&ref); BPath path; if (err == B_OK) err = entry.GetPath(&path); if (err != B_OK) { syslog(LOG_ERR, "instantiate_object failed: Error finding app " "with signature \"%s\" (%s)", signature, strerror(err)); *status = err; return NULL; } // load the app/add-on image_id addOn = load_add_on(path.Path()); if (addOn < B_OK) { syslog(LOG_ERR, "instantiate_object failed: Could not load " "add-on %s: %s.", path.Path(), strerror(addOn)); *status = addOn; return NULL; } // Save the image_id if (_id != NULL) *_id = addOn; BString name = className; for (int32 pass = 0; pass < 2; pass++) { BString funcName; build_function_name(name, funcName); instantiationFunc = find_function_in_image(funcName, addOn, err); if (instantiationFunc != NULL) break; // Check if we have a private class, and add the BPrivate namespace // (for backwards compatibility) if (!add_private_namespace(name)) break; } if (instantiationFunc == NULL) { syslog(LOG_ERR, "instantiate_object failed: Failed to find exported " "Instantiate static function for class %s.", className); *status = B_NAME_NOT_FOUND; return NULL; } } else if (instantiationFunc == NULL) { syslog(LOG_ERR, "instantiate_object failed: No signature specified " "in archive, looking for class \"%s\".", className); *status = B_NAME_NOT_FOUND; return NULL; } // if Class::Instantiate(BMessage*) was found if (instantiationFunc != NULL) { // use to create and return an object instance return instantiationFunc(archive); } return NULL; }
bool TRecentsMenu::AddRecents(int32 count) { if (fItemIndex == 0) { fRecentList.MakeEmpty(); BRoster roster; switch (fWhich) { case kRecentDocuments: roster.GetRecentDocuments(&fRecentList, count); break; case kRecentApplications: roster.GetRecentApps(&fRecentList, count); break; case kRecentAppDocuments: roster.GetRecentDocuments(&fRecentList, count, NULL, fSignature); break; case kRecentFolders: roster.GetRecentFolders(&fRecentList, count); break; default: return false; } } for (;;) { entry_ref ref; if (fRecentList.FindRef("refs", fItemIndex++, &ref) != B_OK) break; if (ref.name && strlen(ref.name) > 0) { Model model(&ref, true); if (fWhich != kRecentApplications) { BMessage* message = new BMessage(B_REFS_RECEIVED); if (fWhich == kRecentAppDocuments) { // add application as handler message->AddRef("handler", fAppRef); } ModelMenuItem* item = BNavMenu::NewModelItem(&model, message, Target(), false, NULL, TypesList()); if (item) AddItem(item); } else { // The application items expand to a list of recent documents // for that application - so they must be handled extra BFile file(&ref, B_READ_ONLY); char signature[B_MIME_TYPE_LENGTH]; BAppFileInfo appInfo(&file); if (appInfo.InitCheck() != B_OK || appInfo.GetSignature(signature) != B_OK) continue; ModelMenuItem* item = NULL; BMessage doc; be_roster->GetRecentDocuments(&doc, 1, NULL, signature); // ToDo: check if the documents do exist at all to // avoid the creation of the submenu. if (doc.CountNames(B_REF_TYPE) > 0) { // create recents menu that will contain the recent docs of // this app TRecentsMenu* docs = new TRecentsMenu(model.Name(), fBarView, kRecentAppDocuments, signature, &ref); docs->SetTypesList(TypesList()); docs->SetTarget(Target()); item = new ModelMenuItem(&model, docs); } else item = new ModelMenuItem(&model, model.Name(), NULL); if (item) { // add refs-message so that the recent app can be launched BMessage* msg = new BMessage(B_REFS_RECEIVED); msg->AddRef("refs", &ref); item->SetMessage(msg); item->SetTarget(Target()); AddItem(item); } } // return true so that we know to reenter this list return true; } } // return false if we are done with this list return false; }
void TBarApp::MessageReceived(BMessage* message) { switch (message->what) { case 'gloc': case 'sloc': case 'gexp': case 'sexp': case 'info': case 'exst': case 'cwnt': case 'icon': case 'remv': case 'adon': // pass any BDeskbar originating messages on to the window fBarWindow->PostMessage(message); break; case kConfigShow: ShowPreferencesWindow(); break; case kConfigQuit: QuitPreferencesWindow(); break; case kStateChanged: if (fPreferencesWindow != NULL) fPreferencesWindow->PostMessage(kStateChanged); break; case kShowDeskbarMenu: if (fBarWindow->Lock()) { fBarWindow->ShowDeskbarMenu(); fBarWindow->Unlock(); } break; case kShowTeamMenu: if (fBarWindow->Lock()) { fBarWindow->ShowTeamMenu(); fBarWindow->Unlock(); } break; case kUpdateRecentCounts: int32 count; bool enabled; if (message->FindInt32("applications", &count) == B_OK) fSettings.recentAppsCount = count; if (message->FindBool("applicationsEnabled", &enabled) == B_OK) fSettings.recentAppsEnabled = enabled && count > 0; if (message->FindInt32("folders", &count) == B_OK) fSettings.recentFoldersCount = count; if (message->FindBool("foldersEnabled", &enabled) == B_OK) fSettings.recentFoldersEnabled = enabled && count > 0; if (message->FindInt32("documents", &count) == B_OK) fSettings.recentDocsCount = count; if (message->FindBool("documentsEnabled", &enabled) == B_OK) fSettings.recentDocsEnabled = enabled && count > 0; if (fPreferencesWindow != NULL) fPreferencesWindow->PostMessage(kUpdatePreferences); break; case B_SOME_APP_LAUNCHED: { team_id team = -1; message->FindInt32("be:team", &team); uint32 flags = 0; message->FindInt32("be:flags", (int32*)&flags); const char* signature = NULL; message->FindString("be:signature", &signature); entry_ref ref; message->FindRef("be:ref", &ref); AddTeam(team, flags, signature, &ref); break; } case B_SOME_APP_QUIT: { team_id team = -1; message->FindInt32("be:team", &team); RemoveTeam(team); break; } case B_ARCHIVED_OBJECT: // TODO: what's this??? message->AddString("special", "Alex Osadzinski"); fStatusViewMessenger.SendMessage(message); break; case kToggleDraggers: if (BDragger::AreDraggersDrawn()) BDragger::HideAllDraggers(); else BDragger::ShowAllDraggers(); break; case kAlwaysTop: fSettings.alwaysOnTop = !fSettings.alwaysOnTop; if (fPreferencesWindow != NULL) fPreferencesWindow->PostMessage(kUpdatePreferences); fBarWindow->SetFeel(fSettings.alwaysOnTop ? B_FLOATING_ALL_WINDOW_FEEL : B_NORMAL_WINDOW_FEEL); break; case kAutoRaise: fSettings.autoRaise = fSettings.alwaysOnTop ? false : !fSettings.autoRaise; if (fPreferencesWindow != NULL) fPreferencesWindow->PostMessage(kUpdatePreferences); break; case kAutoHide: fSettings.autoHide = !fSettings.autoHide; if (fPreferencesWindow != NULL) fPreferencesWindow->PostMessage(kUpdatePreferences); fBarWindow->Lock(); fBarView->HideDeskbar(fSettings.autoHide); fBarWindow->Unlock(); break; case kTrackerFirst: fSettings.trackerAlwaysFirst = !fSettings.trackerAlwaysFirst; if (fPreferencesWindow != NULL) fPreferencesWindow->PostMessage(kUpdatePreferences); // if mini mode we don't need to update the view if (fBarView->MiniState()) break; fBarWindow->Lock(); fBarView->SaveExpandedItems(); fBarView->PlaceApplicationBar(); fBarWindow->Unlock(); break; case kSortRunningApps: fSettings.sortRunningApps = !fSettings.sortRunningApps; if (fPreferencesWindow != NULL) fPreferencesWindow->PostMessage(kUpdatePreferences); // if mini mode we don't need to update the view if (fBarView->MiniState()) break; fBarWindow->Lock(); fBarView->SaveExpandedItems(); fBarView->PlaceApplicationBar(); fBarWindow->Unlock(); break; case kUnsubscribe: { BMessenger messenger; if (message->FindMessenger("messenger", &messenger) == B_OK) Unsubscribe(messenger); break; } case kSuperExpando: fSettings.superExpando = !fSettings.superExpando; if (fPreferencesWindow != NULL) fPreferencesWindow->PostMessage(kUpdatePreferences); // if mini mode we don't need to update the view if (fBarView->MiniState()) break; fBarWindow->Lock(); fBarView->SaveExpandedItems(); fBarView->PlaceApplicationBar(); fBarWindow->Unlock(); break; case kExpandNewTeams: fSettings.expandNewTeams = !fSettings.expandNewTeams; if (fPreferencesWindow != NULL) fPreferencesWindow->PostMessage(kUpdatePreferences); // if mini mode we don't need to update the view if (fBarView->MiniState()) break; fBarWindow->Lock(); fBarView->SaveExpandedItems(); fBarView->PlaceApplicationBar(); fBarWindow->Unlock(); break; case kHideLabels: fSettings.hideLabels = !fSettings.hideLabels; if (fPreferencesWindow != NULL) fPreferencesWindow->PostMessage(kUpdatePreferences); // if mini mode we don't need to update the view if (fBarView->MiniState()) break; fBarWindow->Lock(); fBarView->SaveExpandedItems(); fBarView->PlaceApplicationBar(); fBarWindow->Unlock(); break; case kResizeTeamIcons: { int32 oldIconSize = fSettings.iconSize; int32 iconSize; if (message->FindInt32("be:value", &iconSize) != B_OK) break; fSettings.iconSize = iconSize * kIconSizeInterval; // pin icon size between min and max values if (fSettings.iconSize < kMinimumIconSize) fSettings.iconSize = kMinimumIconSize; else if (fSettings.iconSize > kMaximumIconSize) fSettings.iconSize = kMaximumIconSize; // don't resize if icon size hasn't changed if (fSettings.iconSize == oldIconSize) break; ResizeTeamIcons(); if (fPreferencesWindow != NULL) fPreferencesWindow->PostMessage(kUpdatePreferences); // if mini mode we don't need to update the view if (fBarView->MiniState()) break; fBarWindow->Lock(); fBarView->SaveExpandedItems(); if (!fBarView->Vertical()) { // Must also resize the Deskbar menu and replicant tray in // horizontal mode fBarView->PlaceDeskbarMenu(); fBarView->PlaceTray(false, false); } fBarView->PlaceApplicationBar(); fBarWindow->Unlock(); break; } case 'TASK': fSwitcherMessenger.SendMessage(message); break; case kSuspendSystem: // TODO: Call BRoster? break; case kRebootSystem: case kShutdownSystem: { bool reboot = (message->what == kRebootSystem); bool confirm; message->FindBool("confirm", &confirm); BRoster roster; BRoster::Private rosterPrivate(roster); status_t error = rosterPrivate.ShutDown(reboot, confirm, false); if (error != B_OK) fprintf(stderr, "Shutdown failed: %s\n", strerror(error)); break; } case kShowSplash: run_be_about(); break; case kRestartTracker: { BRoster roster; roster.Launch(kTrackerSignature); break; } case B_LOCALE_CHANGED: { BLocaleRoster::Default()->Refresh(); bool localize; if (message->FindBool("filesys", &localize) == B_OK) gLocalizedNamePreferred = localize; } // fall-through case kShowHideTime: case kShowSeconds: case kShowDayOfWeek: case kShowTimeZone: case kGetClockSettings: fStatusViewMessenger.SendMessage(message); // Notify the replicant tray (through BarView) that the time // interval has changed and it should update the time view // and reflow the tray icons. break; default: BApplication::MessageReceived(message); break; } }
void BeGadu::MessageReceived( BMessage *aMessage ) { switch( aMessage->what ) { /* sending mesgs from libgadu to network */ case GOT_MESSAGE: case ADD_HANDLER: case DEL_HANDLER: BMessenger( iWindow->GetNetwork() ).SendMessage( aMessage ); break; case ADD_MESSENGER: DEBUG_TRACE( "BeGadu::MessageReceived( ADD_MESSENGER )\n" ); aMessage->FindMessenger( "messenger", &iMessenger ); if( iWindow ) { iWindow->SetMessenger( iMessenger ); BMessenger( iMessenger ).SendMessage( PROFILE_SELECTED ); } break; case SET_AVAIL: case SET_BRB: case SET_INVIS: case SET_NOT_AVAIL: case SET_DESCRIPTION: case BEGG_ABOUT: case SHOW_MAIN_WINDOW: case CHANGE_DESCRIPTION: case PREFERENCES_SWITCH: if( iWindow ) BMessenger( iWindow ).SendMessage( aMessage ); break; case OPEN_PROFILE_WIZARD: { DEBUG_TRACE( "BeGadu::MessageReceived( OPEN_PROFILE_WIZARD )\n" ); // if( iProfileSelector ) // iProfileSelector = NULL; if( iWindow ) { BMessenger( iWindow ).SendMessage( new BMessage( CLOSE_MAIN_WINDOW ) ); if( iWindow->Lock() ) iWindow->Quit(); iWindow = NULL; } ProfileWizard *pw = new ProfileWizard(); pw->Show(); break; } case CONFIG_OK: { DEBUG_TRACE( "BeGadu::MessageReceived( CONFIG_OK )\n" ); iReadyToRun = true; AddDeskbarIcon(); Profile *profile = new Profile(); int ret = profile->Load( iLastProfile ); if( ret != 0 ) { delete profile; BMessenger( be_app ).SendMessage( new BMessage( PROFILE_SELECT ) ); break; } if( strcmp( profile->GetProfilePassword(), "" ) != 0 ) { BResources res; BRoster roster; entry_ref ref; BFile resfile; roster.FindApp( APP_MIME, &ref ); resfile.SetTo( &ref, B_READ_ONLY ); res.SetTo( &resfile ); BScreen *screen = new BScreen( B_MAIN_SCREEN_ID ); display_mode mode; screen->GetMode( &mode ); // int32 width = 250; // int32 height = 110; // 70 // int32 x_wind = mode.timing.h_display / 2 - ( width / 2); // int32 y_wind = mode.timing.v_display / 2 - ( height / 2 ); // int32 new_width = x_wind + width; // x 2 // int32 new_height = y_wind + height; // x 2 BMessenger( iMessenger ).SendMessage( new BMessage( PROFILE_NOT_SELECTED ) ); // iProfileSelector = new ProfileSelector( iLastProfile, BRect( x_wind, y_wind, new_width, new_height ), &res ); // if( iProfileSelector->LockLooper() ) { // iProfileSelector->Show(); // iProfileSelector->UnlockLooper(); // } } else { BMessenger( iMessenger ).SendMessage( new BMessage( PROFILE_SELECTED ) ); iWindow = new MainWindow( iLastProfile ); if( !iHideAtStart ) { if( iWindow->LockLooper() ) { iWindow->Show(); iWindow->UnlockLooper(); } } else { if( iWindow->LockLooper() ) { iWindow->Show(); iWindow->Hide(); iWindow->UnlockLooper(); } } } break; } case PROFILE_CREATED: DEBUG_TRACE( "BeGadu::MessageReceived( PROFILE_CREATED )\n" ); iReadyToRun = true; AddDeskbarIcon(); aMessage->FindString( "ProfileName", iLastProfile ); fprintf( stderr, _T("Setting last profile to %s\n"), iLastProfile->String() ); iFirstRun = false; BMessenger( iMessenger ).SendMessage( new BMessage( PROFILE_SELECTED ) ); iWindow = new MainWindow( iLastProfile ); if( iWindow->LockLooper() ) { if( iWindow->IsHidden() ) iWindow->Show(); else iWindow->Activate(); iWindow->UnlockLooper(); } break; case PROFILE_SELECT: DEBUG_TRACE( "BeGadu::MessageReceived( PROFILE_SELECT )\n" ); // if( iProfileSelector ) // iProfileSelector->Activate(); // else { BResources res; BRoster roster; entry_ref ref; BFile resfile; roster.FindApp( APP_MIME, &ref ); resfile.SetTo( &ref, B_READ_ONLY ); res.SetTo( &resfile ); BScreen *screen = new BScreen( B_MAIN_SCREEN_ID ); display_mode mode; screen->GetMode( &mode ); // int32 width = 250; // int32 height = 110; // 70 // int32 x_wind = mode.timing.h_display / 2 - ( width / 2); // int32 y_wind = mode.timing.v_display / 2 - ( height / 2 ); // int32 new_width = x_wind + width; // x 2 // int32 new_height = y_wind + height; // x 2 BMessenger( iMessenger ).SendMessage( new BMessage( PROFILE_NOT_SELECTED ) ); // iProfileSelector = new ProfileSelector( iLastProfile, BRect( x_wind, y_wind, new_width, new_height ), &res ); // if( iProfileSelector->LockLooper() ) { // iProfileSelector->Show(); // iProfileSelector->UnlockLooper(); // } } break; case PROFILE_SWITCH: { DEBUG_TRACE( "BeGadu::MessageReceived( PROFILE_SWITCH )\n" ); if( iWindow ) { BMessenger( iWindow ).SendMessage( new BMessage( CLOSE_MAIN_WINDOW ) ); if( iWindow->Lock() ) iWindow->Quit(); iWindow = NULL; } Profile* profile = new Profile(); BString* name = new BString( "" ); aMessage->FindString( "iProfileName", name ); int ret = profile->Load( name ); if( ret != 0 ) { delete profile; BMessenger( this ).SendMessage( new BMessage( PROFILE_SELECT ) ); break; } // XXX loaded profile password empty? if( strcmp( profile->GetProfilePassword(), "" ) == 0 ) { BMessenger( iMessenger ).SendMessage( new BMessage( PROFILE_SELECTED ) ); iWindow = new MainWindow( iLastProfile ); // iWindow = new MainWindow( name ); if( iWindow->LockLooper() ) { iWindow->Show(); iWindow->UnlockLooper(); } } else { // XXX what's that for? BResources res; BRoster roster; entry_ref ref; BFile resfile; roster.FindApp( APP_MIME, &ref ); resfile.SetTo( &ref, B_READ_ONLY ); res.SetTo( &resfile ); BScreen *screen = new BScreen( B_MAIN_SCREEN_ID ); display_mode mode; screen->GetMode( &mode ); // int32 width = 250; // int32 height = 110; // 70 // int32 x_wind = mode.timing.h_display / 2 - ( width / 2); // int32 y_wind = mode.timing.v_display / 2 - ( height / 2 ); // int32 new_width = x_wind + width; // x 2 // int32 new_height = y_wind + height; // x 2 BMessenger( iMessenger ).SendMessage( new BMessage( PROFILE_NOT_SELECTED ) ); // iProfileSelector = new ProfileSelector( name, BRect( x_wind, y_wind, new_width, new_height ), &res ); // if( iProfileSelector->LockLooper() ) { // iProfileSelector->Show(); // iProfileSelector->UnlockLooper(); // } } break; } case PROFILE_SELECTED: { DEBUG_TRACE( "BeGadu::MessageReceived( PROFILE_SELECTED )\n" ); // if( iProfileSelector ) // iProfileSelector = NULL; BString *profile = new BString( "" ); aMessage->FindString( "iProfileName", profile ); BMessenger( iMessenger ).SendMessage( new BMessage( PROFILE_SELECTED ) ); iWindow = new MainWindow( profile ); if( !iHideAtStart ) { if( iWindow->LockLooper() ) { iWindow->Show(); iWindow->UnlockLooper(); } } else { if( iWindow->LockLooper() ) { iWindow->Show(); iWindow->Hide(); iWindow->UnlockLooper(); } } break; } case PROFILE_NOT_SELECTED: DEBUG_TRACE( "BeGadu::MessageReceived( PROFILE_NOT_SELECTED )\n" ); // if( iProfileSelector ) // iProfileSelector = NULL; BMessenger( iMessenger ).SendMessage( new BMessage( PROFILE_NOT_SELECTED ) ); break; case BEGG_QUIT: DEBUG_TRACE( "BeGadu::MessageReceived( BEGG_QUIT )\n" ); if( iWindow ) BMessenger( iWindow ).SendMessage( aMessage ); else BMessenger( be_app ).SendMessage( B_QUIT_REQUESTED ); break; default: BApplication::MessageReceived( aMessage ); break; } }