本文整理汇总了C++中BRoster类的典型用法代码示例。如果您正苦于以下问题:C++ BRoster类的具体用法?C++ BRoster怎么用?C++ BRoster使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BRoster类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mess
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;
}
示例2: IsRunning
/*
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);
}
示例3: GetAppList
/*
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
}
示例4:
/***********************************************************
* 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);
}
}
示例5: model
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;
}
示例6: DEBUG_TRACE
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;
}
}
}
示例7: entry
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 */
示例8: LgiExecute
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;
}
示例9: GetLocalSignature
//------------------------------------------------------------------------------
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;
}
示例10: entry
/*! 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;
}
示例11: BMessage
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);
}
示例12: BMessage
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;
//.........这里部分代码省略.........
示例13: Broadcast
/*
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));
}
示例14: instantiate_object
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
//.........这里部分代码省略.........
示例15: model
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;
}