本文整理汇总了C++中BRoster::FindApp方法的典型用法代码示例。如果您正苦于以下问题:C++ BRoster::FindApp方法的具体用法?C++ BRoster::FindApp怎么用?C++ BRoster::FindApp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BRoster
的用法示例。
在下文中一共展示了BRoster::FindApp方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2:
/***********************************************************
* 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);
}
}
示例3: AddDeskbarIcon
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;
}
}
}
示例4: 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;
}
示例5: 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
//.........这里部分代码省略.........
示例6: MessageReceived
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();
//.........这里部分代码省略.........