本文整理汇总了C++中BMessenger::IsValid方法的典型用法代码示例。如果您正苦于以下问题:C++ BMessenger::IsValid方法的具体用法?C++ BMessenger::IsValid怎么用?C++ BMessenger::IsValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BMessenger
的用法示例。
在下文中一共展示了BMessenger::IsValid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: signal_app
void PrefWindow::signal_app()
{
//signal pref save to app if running...
BMessenger *msgr = new BMessenger("application/x-vnd.StrokeIt.ME");
if (msgr->IsValid())
msgr->SendMessage( new BMessage('srlD') );
delete msgr;
}
示例2: helper
void
MainWindow::Open(const BMessenger& externalObserver, const uint8* data,
size_t size)
{
if (!_CheckSaveIcon(CurrentMessage()))
return;
if (!externalObserver.IsValid())
return;
Icon* icon = new (nothrow) Icon();
if (!icon)
return;
if (data && size > 0) {
// try to open the icon from the provided data
FlatIconImporter flatImporter;
status_t ret = flatImporter.Import(icon, const_cast<uint8*>(data),
size);
// NOTE: the const_cast is a bit ugly, but no harm is done
// the reason is that the LittleEndianBuffer knows read and write
// mode, in this case it is used read-only, and it does not assume
// ownership of the buffer
if (ret < B_OK) {
// inform user of failure at this point
BString helper(B_TRANSLATE("Opening the icon failed!"));
helper << "\n\n" << B_TRANSLATE("Error: ") << strerror(ret);
BAlert* alert = new BAlert(
B_TRANSLATE_CONTEXT("bad news", "Title of error alert"),
helper.String(),
B_TRANSLATE_CONTEXT("Bummer",
"Cancel button - error alert"),
NULL, NULL);
// launch alert asynchronously
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
alert->Go(NULL);
delete icon;
return;
}
}
AutoWriteLocker locker(fDocument);
SetIcon(NULL);
// incorporate the loaded icon into the document
// (either replace it or append to it)
fDocument->MakeEmpty();
fDocument->SetIcon(icon);
fDocument->SetNativeSaver(new MessengerSaver(externalObserver));
locker.Unlock();
SetIcon(icon);
}
示例3: BAlert
void
AGMSBayesianSpamFilterConfig::ShowSpamServerConfigurationWindow () {
status_t errorCode = B_OK;
BMessage maximizeCommand;
BMessenger messengerToServer;
BMessage replyMessage;
// Make sure the server is running.
if (!be_roster->IsRunning (kServerSignature)) {
errorCode = be_roster->Launch (kServerSignature);
if (errorCode != B_OK) {
BPath path;
entry_ref ref;
directory_which places[] = {
B_SYSTEM_NONPACKAGED_BIN_DIRECTORY,
B_SYSTEM_BIN_DIRECTORY
};
for (int32 i = 0; i < 2; i++) {
find_directory(places[i],&path);
path.Append("spamdbm");
if (!BEntry(path.Path()).Exists())
continue;
get_ref_for_path(path.Path(),&ref);
if ((errorCode = be_roster->Launch (&ref)) == B_OK)
break;
}
if (errorCode != B_OK)
goto ErrorExit;
}
}
// Set up the messenger to the database server.
messengerToServer =
BMessenger (kServerSignature);
if (!messengerToServer.IsValid ())
goto ErrorExit;
// Wait for the server to finish starting up, and for it to create the window.
snooze (2000000);
// Tell it to show its main window, in case it is hidden in server mode.
maximizeCommand.what = B_SET_PROPERTY;
maximizeCommand.AddBool ("data", false);
maximizeCommand.AddSpecifier ("Minimize");
maximizeCommand.AddSpecifier ("Window", (int32)0);
errorCode = messengerToServer.SendMessage (&maximizeCommand, &replyMessage);
if (errorCode != B_OK)
goto ErrorExit;
return; // Successful.
ErrorExit:
BAlert* alert = new BAlert ("SpamFilterConfig Error", B_TRANSLATE("Sorry, "
"unable to launch the spamdbm program to let you edit the server "
"settings."), B_TRANSLATE("Close"));
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
alert->Go ();
return;
}
示例4: BMessenger
status_t
GetPrinterServerMessenger(BMessenger& msgr)
{
// If print server is not yet running, start it
if (!be_roster->IsRunning(PSRV_SIGNATURE_TYPE))
be_roster->Launch(PSRV_SIGNATURE_TYPE);
msgr = BMessenger(PSRV_SIGNATURE_TYPE);
return msgr.IsValid() ? B_OK : B_ERROR;
}
示例5: setLogTarget
status_t RouteAppNodeManager::setLogTarget(
const BMessenger& target) {
BAutolock _l(this);
if(!target.IsValid())
return B_BAD_VALUE;
m_logTarget = target;
return B_OK;
}
示例6:
/*! \brief Subscribes a target to node and/or mount watching, or unsubscribes
it from node watching.
Depending of \a flags the action performed by this function varies:
- \a flags is \c 0: The target is unsubscribed from watching the node.
\a node must not be \c NULL in this case.
- \a flags contains \c B_WATCH_MOUNT: The target is subscribed to mount
watching.
- \a flags contains at least one of \c B_WATCH_NAME, \c B_WATCH_STAT,
\c B_WATCH_ATTR, or \c B_WATCH_DIRECTORY: The target is subscribed to
watching the specified aspects of the node. \a node must not be \c NULL
in this case.
Note, that the latter two cases are not mutual exlusive, i.e. mount and
node watching can be requested with a single call.
\param node node_ref referring to the node to be watched. May be \c NULL,
if only mount watching is requested.
\param flags Flags indicating the actions to be performed.
\param target Messenger referring to the target. Must be valid.
\return \c B_OK, if everything went fine, another error code otherwise.
*/
status_t
watch_node(const node_ref *node, uint32 flags, BMessenger target)
{
status_t error = (target.IsValid() ? B_OK : B_BAD_VALUE);
if (error == B_OK) {
BLooper *looper = NULL;
BHandler *handler = target.Target(&looper);
error = watch_node(node, flags, handler, looper);
}
return error;
}
示例7: MessageReceived
void ArpFontControl::MessageReceived(BMessage* msg)
{
/* Redirect any messages I receive from my font ctrl to
* whomever I'm supposed to deliver to.
*/
if (msg->what == FONT_IMSG || msg->what == SIZE_IMSG) {
BMessenger messenger = Messenger();
if (messenger.IsValid()) messenger.SendMessage(mMsgWhat);
return;
}
inherited::MessageReceived(msg);
}
示例8: messengerPrivate
/*! \brief Unsubscribes a target from node and mount monitoring.
\param target Messenger referring to the target. Must be valid.
\return \c B_OK, if everything went fine, another error code otherwise.
*/
status_t
stop_watching(BMessenger target)
{
if (!target.IsValid())
return B_BAD_VALUE;
BMessenger::Private messengerPrivate(target);
port_id port = messengerPrivate.Port();
int32 token = messengerPrivate.Token();
return _kern_stop_notifying(port, token);
}
示例9: moved
void
EventDispatcher::_SendFakeMouseMoved(BMessage* message)
{
BMessenger target;
int32 viewToken;
if (message->FindInt32("view_token", &viewToken) != B_OK
|| message->FindMessenger("target", &target) != B_OK)
return;
if (fDesktop == NULL)
return;
// Check if the target is still valid
::EventTarget* eventTarget = NULL;
fDesktop->LockSingleWindow();
if (target.IsValid())
eventTarget = fDesktop->FindTarget(target);
fDesktop->UnlockSingleWindow();
if (eventTarget == NULL)
return;
BMessage moved(B_MOUSE_MOVED);
moved.AddPoint("screen_where", fLastCursorPosition);
moved.AddInt32("buttons", fLastButtons);
if (fDraggingMessage)
moved.AddMessage("be:drag_message", &fDragMessage);
if (fPreviousMouseTarget != NULL
&& fPreviousMouseTarget->Messenger() != target) {
_AddTokens(&moved, fPreviousMouseTarget, B_POINTER_EVENTS);
_SendMessage(fPreviousMouseTarget->Messenger(), &moved,
kMouseTransitImportance);
_RemoveTokens(&moved);
}
moved.AddInt32("_view_token", viewToken);
// this only belongs to the new target
moved.AddBool("be:transit_only", true);
// let the view know this what not user generated
_SendMessage(target, &moved, kMouseTransitImportance);
fPreviousMouseTarget = eventTarget;
}
示例10: messengerPrivate
/*! \brief Sets the BQuery's target and makes the query live.
The query update messages are sent to the specified target. They might
roll in immediately after calling Fetch().
This methods fails, if called after Fetch(). To reuse a BQuery object it
has to be reset via Clear().
\return
- \c B_OK: Everything went fine.
- \c B_BAD_VALUE: \a messenger was not properly initialized.
- \c B_NOT_ALLOWED: SetTarget() was called after Fetch().
*/
status_t
BQuery::SetTarget(BMessenger messenger)
{
status_t error = (messenger.IsValid() ? B_OK : B_BAD_VALUE);
if (error == B_OK && _HasFetched())
error = B_NOT_ALLOWED;
if (error == B_OK) {
BMessenger::Private messengerPrivate(messenger);
fPort = messengerPrivate.Port();
fToken = (messengerPrivate.IsPreferredTarget()
? -1 : messengerPrivate.Token());
fLive = true;
}
return error;
}
示例11: watch_node
status_t
BPrinter::StartWatching(const BMessenger& listener)
{
StopWatching();
if (!listener.IsValid())
return B_BAD_VALUE;
fListener = new(std::nothrow) BMessenger(listener);
if (!fListener)
return B_NO_MEMORY;
node_ref nodeRef;
nodeRef.device = fPrinterEntryRef.device;
nodeRef.node = fPrinterEntryRef.directory;
return watch_node(&nodeRef, B_WATCH_DIRECTORY, *fListener);
}
示例12: MessageReceived
void TScrollViewComponent::MessageReceived(BMessage *message)
{
// char *name;
// char **data;
// float largeur,hauteur;
// uint32 type;
// int32 count;
// int32 ResizingMode,TheFlags;
// BRect ANewFrame;
// string truc1,truc2;
BMessenger *AMes;
switch(message->what)
{
case MSG_PROPERTY_UPDATE :
printf("TScrollViewComponent::Message Received. Message d'update recu!\n");
AMes = new BMessenger(FInternalComponent->FHandler);
if (AMes->IsValid())
{
AMes->SendMessage(message); // Send the message to the real ListView!
}
delete AMes;
/*
for (int32 i = 0;
message->GetInfo(B_STRING_TYPE, i, &name, &type, &count) == B_OK;
i++ )
{
if (message->FindString(name,data)==B_OK)
{
truc1 = name;
truc2 = *data;
FPropertyList->SetPropertyValue(truc1,truc2);
SetStandardProperties(name,*data);
SetFrameProperties(name,*data,this);
SetSizingProperties(name,*data,this);
SetFlagsProperties(name,*data,this);
// if (strcmp(name,PROP_LABEL)==0) SetLabel(*data);
// if (strcmp(name,PROP_MESSAGE)==0) SetLabel(*data); rien!
}
}
*/
break;
default: BView::MessageReceived(message);
}
}
示例13: WorkspaceChanged
void TPanelWindowView::WorkspaceChanged()
{
BList to_remove;
int i;
for ( i=0; i<fWorkspaceChangeNotifyList.CountItems(); i++ )
{
BMessenger *mess = static_cast<BMessenger*>(fWorkspaceChangeNotifyList.ItemAt(i));
if ( !mess->IsValid() )
to_remove.AddItem(mess);
else
mess->SendMessage( B_WORKSPACE_ACTIVATED );
}
for ( i=0; i<to_remove.CountItems(); i++ )
{
fWorkspaceChangeNotifyList.RemoveItem( to_remove.ItemAt(i) );
}
}
示例14: AvatarLooper
MSNP::MSNP()
:
fUsername(""),
fServer("messenger.hotmail.com"),
fPassword(""),
fMainConnection(NULL),
fSettings(false),
fCachePath(""),
fRunnerTime(40000000)
{
AvatarLooper* fAvatarLooper = new AvatarLooper(this);
BMessenger* mess = new BMessenger(NULL, fAvatarLooper);
if (!mess->IsValid()) {
printf("Avatar BMessenger error\n");
}
fAvatarLooper->Run();
fAvatarRunner = new BMessageRunner(*mess, new BMessage(kAvatarCheckMessage), fRunnerTime);
if (fAvatarRunner->InitCheck() != B_OK) {
printf("Avatar MessageRunner error %s\n",
strerror(fAvatarRunner->InitCheck()));
}
}
示例15: msgr
void
AgentDockHeaderString::MouseUp (BPoint where)
{
SetViewColor (tint_color (ui_color (B_MENU_BACKGROUND_COLOR), B_DARKEN_1_TINT));
Parent()->SetViewColor (tint_color (ui_color (B_MENU_BACKGROUND_COLOR), B_DARKEN_1_TINT));
Invalidate();
Parent()->Invalidate();
// check if this header string belongs to notify list and send resize message if so
BView *notifyList (Parent());
if (notifyList && dynamic_cast<AgentDockHeader *>(notifyList) != NULL)
{
notifyList = notifyList->Parent();
if (notifyList && dynamic_cast<AgentDockNotifyList *>(notifyList) != NULL)
{
BMessenger msgr (((AgentDockNotifyList *)notifyList)->pNotifyList());
if (msgr.IsValid())
msgr.SendMessage (M_NOTIFYLIST_RESIZE);
}
}
BStringView::MouseUp (where);
}