本文整理汇总了C++中BMessenger::SendMessage方法的典型用法代码示例。如果您正苦于以下问题:C++ BMessenger::SendMessage方法的具体用法?C++ BMessenger::SendMessage怎么用?C++ BMessenger::SendMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BMessenger
的用法示例。
在下文中一共展示了BMessenger::SendMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: msg
void
AddPrinterDialog::_FillTransportMenu(BMenu* menu)
{
BMessenger msgr;
if (GetPrinterServerMessenger(msgr) != B_OK)
return;
for (long idx = 0; ; idx++) {
BMessage reply, msg(B_GET_PROPERTY);
msg.AddSpecifier("Transport", idx);
if (msgr.SendMessage(&msg, &reply) != B_OK)
break;
BMessenger transport;
if (reply.FindMessenger("result", &transport) != B_OK)
break;
// Got messenger to transport now
msg.MakeEmpty();
msg.what = B_GET_PROPERTY;
msg.AddSpecifier("Name");
if (transport.SendMessage(&msg, &reply) != B_OK)
continue;
BString transportName;
if (reply.FindString("result", &transportName) != B_OK)
continue;
// Now get ports...
BString portId, portName;
int32 error;
msg.MakeEmpty();
msg.what = B_GET_PROPERTY;
msg.AddSpecifier("Ports");
if (transport.SendMessage(&msg, &reply) != B_OK
|| reply.FindInt32("error", &error) != B_OK
|| error != B_OK
|| (transportName == "IPP"
&& reply.FindString("port_id", &portId) != B_OK)) {
// Transport does not provide list of ports
BMessage* menuMsg = new BMessage(kTransportSelectedMsg);
menuMsg->AddString("name", transportName);
menu->AddItem(new BMenuItem(transportName.String(), menuMsg));
continue;
}
// Create submenu
BMenu* transportMenu = new TransportMenu(transportName.String(),
kTransportSelectedMsg, transport, transportName);
menu->AddItem(transportMenu);
transportMenu->SetRadioMode(true);
menu->ItemAt(menu->IndexOf(transportMenu))->
SetMessage(new BMessage(kTransportSelectedMsg));
}
}
示例2: message
// main
int
main(int argc, char **argv)
{
// find app file and get signature from resources
char path[B_PATH_NAME_LENGTH];
status_t error = get_app_path(path);
char signature[B_MIME_TYPE_LENGTH];
if (error == B_OK) {
// init app file
BFile file;
error = file.SetTo(path, B_READ_ONLY);
// get signature
BString signatureString;
if (error == B_OK) {
if (file.ReadAttrString("signature", &signatureString) == B_OK
&& signatureString.Length() > 0) {
strcpy(signature, signatureString.String());
} else
strcpy(signature, kDefaultTestAppSignature);
} else
printf("ERROR: Couldn't init app file: %s\n", strerror(error));
} else
printf("ERROR: Couldn't get app ref: %s\n", strerror(error));
// create the app
TestApp *app = NULL;
if (error == B_OK) {
app = new TestApp(signature);
// unitTesterMessenger = BMessenger(kUnitTesterSignature);
error = init_unit_tester_messenger();
if (error != B_OK)
printf("ERROR: Couldn't init messenger: %s\n", strerror(error));
// send started message
BMessage message(MSG_STARTED);
message.AddString("path", path);
unitTesterMessenger.SendMessage(&message);
// send main() args message
BMessage argsMessage(MSG_MAIN_ARGS);
argsMessage.AddInt32("argc", argc);
for (int i = 0; i < argc; i++)
argsMessage.AddString("argv", argv[i]);
unitTesterMessenger.SendMessage(&argsMessage);
// run the app
app->Run();
delete app;
// send terminated message
unitTesterMessenger.SendMessage(MSG_TERMINATED);
}
return 0;
}
示例3: ThreadFunc
int32 CAsynchronousPopUpMenu::ThreadFunc(void *data)
{
wait_thread_info *info = reinterpret_cast<wait_thread_info *>(data);
BMessenger *messenger = info->popupMenu->notifyTarget;
// send notification message, before menu is displayed.
if(messenger) {
BMessage openNotify(MSG_MENU_BEGINNING);
AddTime(&openNotify, "when", system_time());
openNotify.AddPointer("source", info->popupMenu);
messenger->SendMessage(&openNotify);
}
BMenuItem *item = NULL;
// call SYNCHRONOUS version of Go() and wait until the
// the function returns.
if(info->clickToOpenRect == BRect(-1,-1,-1,-1)) {
// No clickToOpenRect supplied.
item = info->popupMenu->Go(info->screenPoint, true,
info->openAnyway, false);
} else {
item = info->popupMenu->Go(info->screenPoint, true,
info->openAnyway, info->clickToOpenRect, false);
}
// Menu was closed. Send notification message.
if(messenger) {
BMessage closeNotify(MSG_MENU_ENDED);
AddTime(&closeNotify, "when", system_time());
closeNotify.AddPointer("source", info->popupMenu);
closeNotify.AddPointer("sel_item", item);
messenger->SendMessage(&closeNotify);
}
// If autoDelete flag is set delete popup menu.
if(info->autoDelete) {
delete info->popupMenu;
}
delete info;
return 0;
}
示例4: BMessage
status_t
PrintServerMessenger::MessengerThread(void* data)
{
PrintServerMessenger* messenger = static_cast<PrintServerMessenger*>(data);
BMessenger printServer;
if (messenger->GetPrintServerMessenger(printServer) != B_OK) {
ShowError("Print Server is not responding.");
messenger->SetResult(NULL);
return B_ERROR;
}
BMessage* request = messenger->Request();
if (request == NULL) {
messenger->SetResult(NULL);
return B_ERROR;
}
BMessage reply;
if (printServer.SendMessage(request, &reply) != B_OK
|| reply.what != 'okok' ) {
messenger->SetResult(NULL);
return B_ERROR;
}
messenger->SetResult(new BMessage(reply));
return B_OK;
}
示例5: Bounds
void
Win::CreateTabView()
{
//cout << "Win::CreateTabView()" << endl;
BRect rect = Bounds();
tabview = new ThemisTabView(
BRect(
rect.left,
rect.top + menubar->Bounds().Height() + 1 + navview->Bounds().Height() + 1,
rect.right,
rect.bottom - statusview->Bounds().Height() - 1 ),
"THEMISTABVIEW", B_WIDTH_AS_USUAL, B_FOLLOW_ALL,
B_FULL_UPDATE_ON_RESIZE |
B_WILL_DRAW |
B_NAVIGABLE_JUMP |
B_FRAME_EVENTS |
B_NAVIGABLE );
AddChild( tabview );
// add the first tab
BMessenger* target = new BMessenger( this );
target->SendMessage( TAB_ADD );
delete target;
}
示例6: movedOut
void
CaptureView::_SendMovedOutNotification()
{
BMessage movedOut(fMovedOutWhat);
fMovedOutMessenger.SendMessage(&movedOut);
fMovedOutWhat = 0;
}
示例7: observerAdded
// sends M_OBSERVER_ADDED to the newly-added observer
void ObservableHandler::observerAdded(
const BMessenger& observer) {
BMessage m(M_OBSERVER_ADDED);
m.AddMessenger("target", BMessenger(this));
observer.SendMessage(&m);
}
示例8: MessageReceived
void MonthWindow::MessageReceived(BMessage *msg)
{
if(msg->what=='MVME')
{
// Is date correct?
int32 day, month, year;
if(msg->FindInt32("day",&day)!=B_OK) return;
if(msg->FindInt32("month",&month)!=B_OK) return;
if(msg->FindInt32("year",&year)!=B_OK) return;
if(year<first_year || year>last_year) return;
if(month<1 || month>12) return;
int32 tmp;
tmp=31;
if(month==4 || month==6 || month==9 || month==11) tmp=30;
else if(month==2)
{
if(year%4==0)
{
if(year%100==0 && year%400!=0) tmp=28;
else tmp=29;
}
else tmp=28;
}
if(day<1 || day>tmp) return;
msng->SendMessage(msg);
Quit();
}
else BWindow::MessageReceived(msg);
}
示例9: message
void
AutomountSettingsPanel::_SendSettings(bool rescan)
{
BMessage message(kSetAutomounterParams);
message.AddBool("autoMountAll", (bool)fAutoMountAllCheck->Value());
message.AddBool("autoMountAllBFS", (bool)fAutoMountAllBFSCheck->Value());
if (fAutoMountAllBFSCheck->Value())
message.AddBool("autoMountAllHFS", false);
message.AddBool("suspended", (bool)fScanningDisabledCheck->Value());
message.AddBool("rescanNow", rescan);
message.AddBool("initialMountAll", (bool)fInitialMountAllCheck->Value());
message.AddBool("initialMountAllBFS",
(bool)fInitialMountAllBFSCheck->Value());
message.AddBool("initialMountRestore",
(bool)fInitialMountRestoreCheck->Value());
if (fInitialDontMountCheck->Value())
message.AddBool("initialMountAllHFS", false);
message.AddBool("ejectWhenUnmounting",
(bool)fEjectWhenUnmountingCheckBox->Value());
fTarget.SendMessage(&message);
}
示例10: output
static void
listener_output(syslog_message &message)
{
// compose the message to be sent to all listeners; just convert
// the syslog_message into a BMessage
BMessage output(SYSLOG_MESSAGE);
output.AddInt32("from", message.from);
output.AddInt32("when", message.when);
output.AddString("ident", message.ident);
output.AddString("message", message.message);
output.AddInt32("options", message.options);
output.AddInt32("priority", message.priority);
sLocker.Lock();
for (int32 i = sListeners.CountItems(); i-- > 0;) {
BMessenger *target = (BMessenger *)sListeners.ItemAt(i);
status_t status = target->SendMessage(&output);
if (status < B_OK) {
// remove targets once they can't be reached anymore
sListeners.RemoveItem(target);
}
}
sLocker.Unlock();
}
示例11: UpdateStatus
void DCCConnect::UpdateStatus(const BMessenger& msgr, const char* text)
{
BMessage msg(M_DCC_UPDATE_STATUS);
msg.AddString("text", text);
msgr.SendMessage(&msg);
}
示例12: MessageReceived
virtual void MessageReceived(BMessage *_message)
{
BMessage message(MSG_MESSAGE_RECEIVED);
message.AddMessage("message", _message);
message.AddInt32("sender", _message->ReturnAddress().Team());
unitTesterMessenger.SendMessage(&message);
}
示例13: request
status_t
AddOnManager::_GetReplicantView(BMessenger target, int32 uid,
BMessage* reply) const
{
// We send a message to the target shelf, asking it for the Name of the
// replicant with the given unique id.
BMessage request(B_GET_PROPERTY);
BMessage uid_specifier(B_ID_SPECIFIER);
// specifying via ID
status_t err;
status_t e;
request.AddSpecifier("View");
// ask for the Name of the replicant
// IDs are specified using code like the following 3 lines:
uid_specifier.AddInt32("id", uid);
uid_specifier.AddString("property", "Replicant");
request.AddSpecifier(&uid_specifier);
if ((err = target.SendMessage(&request, reply)) != B_OK)
return err;
if (((err = reply->FindInt32("error", &e)) != B_OK) || (e != B_OK))
return err ? err : e;
return B_OK;
}
示例14: seld_notes
pointer seld_notes() {
amc_found=tst_alive_amc();
if (!amc_found && !find_amc())
return Error_0("STOP! amc not running");
BMessage mes(STORE_SEL),
reply;
StoredNote *notes;
Settings *settings;
ssize_t bytes=0;
int n,
items=0;
amc_application.SendMessage(&mes,&reply);
puts("amc did reply");
switch (reply.what) {
case CONTENTS_SEL:
reply.FindData(SELD_NOTES,B_OBJECT_TYPE,(const void**)(¬es),&bytes);
items=bytes/sizeof(StoredNote);
reply.FindData(SETTINGS,B_OBJECT_TYPE,(const void**)(&settings),&bytes);
break;
default: return Error_0("seld notes: unknown reply");
}
pointer ptr,
out=nil_pointer();
for (n=0;n<items;++n) {
ptr=cons(mk_integer(notes[n].lnr),
cons(mk_integer(notes[n].snr),
cons(mk_integer(notes[n].sign),
cons(mk_integer(notes[n].dur),nil_pointer()))));
out=cons(ptr,out);
}
ptr=cons(mk_integer(settings->meter),nil_pointer());
ptr=cons(mk_symbol("meter"),ptr);
ptr=cons(ptr,nil_pointer());
return cons(ptr,out);
}
示例15: request
void
LaunchDaemon::_StopJob(Job* job, bool force)
{
// TODO: find out which jobs require this job, and don't stop if any,
// unless force, and then stop them all.
job->SetEnabled(false);
if (!job->IsRunning())
return;
// Be nice first, and send a simple quit message
BMessenger messenger;
if (job->GetMessenger(messenger) == B_OK) {
BMessage request(B_QUIT_REQUESTED);
messenger.SendMessage(&request);
// TODO: wait a bit before going further
return;
}
// TODO: allow custom shutdown
send_signal(-job->Team(), SIGINT);
// TODO: this would be the next step, again, after a delay
//send_signal(job->Team(), SIGKILL);
}