コード例 #1
0
ファイル: MiniPulseView.cpp プロジェクト: mariuz/haiku
void MiniPulseView::AttachedToWindow() {
	BMessenger messenger(Window());
	mode1->SetTarget(messenger);
	mode2->SetTarget(messenger);
	preferences->SetTarget(messenger);
	about->SetTarget(messenger);
	quit->SetTarget(messenger);
	
	system_info sys_info;
	get_system_info(&sys_info);
	if (sys_info.cpu_count >= 2) {
		for (int x = 0; x < sys_info.cpu_count; x++) {
			cpu_menu_items[x]->SetTarget(messenger);
		}
	}
}
コード例 #2
0
/*
	BHandler *Target(BLooper **looper) const
	@case 3			this is initialized to local target with specific handler,
					looper is NULL
	@results		should return correct handler.
 */
void TargetTester::TargetTest3()
{
	// create looper and handler
	status_t result = B_OK;
	BLooper *looper = new BLooper;
	looper->Run();
	LooperQuitter quitter(looper);
	BHandler *handler = new BHandler;
	HandlerDeleter deleter(handler);
	CHK(looper->Lock());
	looper->AddHandler(handler);
	looper->Unlock();
	// create the messenger and do the checks
	BMessenger messenger(handler, NULL, &result);
	CHK(messenger.Target(NULL) == handler);
}
コード例 #3
0
ファイル: ResView.cpp プロジェクト: AmirAbrams/haiku
void
ResView::AttachedToWindow(void)
{
	for (int32 i = 0; i < fBar->CountItems(); i++)
		fBar->SubmenuAt(i)->SetTargetForItems(this);
	fListView->SetTarget(this);
	
	BMessenger messenger(this);
	fOpenPanel->SetTarget(messenger);
	fSavePanel->SetTarget(messenger);
	
	Window()->Lock();
	BString title("ResEdit: ");
	title << fFileName;
	Window()->SetTitle(title.String());
	Window()->Unlock();
}
コード例 #4
0
void
FSClipboardRemove(Model *model)
{
	BMessenger messenger(kTrackerSignature);
	if (messenger.IsValid()) {
		BMessage *report = new BMessage(kFSClipboardChanges);
		TClipboardNodeRef tcnode;
		tcnode.node = *model->NodeRef();
		tcnode.moveMode = kDelete;
		const entry_ref *ref = model->EntryRef();
		report->AddInt32("device", ref->device);
		report->AddInt64("directory", ref->directory);
		report->AddBool("clearClipboard", false);
		report->AddData("tcnode", T_CLIPBOARD_NODE, &tcnode, sizeof(tcnode), true);
		messenger.SendMessage(report);
		delete report;
	}
}
コード例 #5
0
ファイル: FSApp.cpp プロジェクト: HaikuArchives/FolderShaper
bool 
FolderShaper::IsFolderOpen(const entry_ref * ref)	const
{
	status_t	status = B_OK;
	int32		index = 0;
	
	BMessenger	messenger(FS_TRACKER_SIGNATURE);
	BMessage	message(B_GET_PROPERTY);
	BMessage	reply;
	entry_ref 	window;

	
	if (! messenger.IsValid())
	{	
		PRINT(("Error: invalid BMessenger.\n"));
		return false; 
	}
	
	for(index = 1; index < 500; index++)
	{
		message.MakeEmpty();
		message.what = B_GET_PROPERTY;
		message.AddSpecifier("Path");
		message.AddSpecifier("Poses");
		message.AddSpecifier("Window", index);
		
		reply.MakeEmpty();
		
		if((status = messenger.SendMessage(&message, &reply)) != B_OK)
		{
			ErrorMessage("Error sending message to Tracker: ", status);
			return false;
		}
	
		if((status = reply.FindRef("result", &window)) != B_OK)
			return false;
		
		if(*ref == window)
			return true;
	}
	
	return false;
}
コード例 #6
0
filter_result
BSCInputFilter::Filter(BMessage* message, BList* outList)
{
	switch (message->what) {
		case B_KEY_DOWN:
		case B_KEY_UP:
		case B_UNMAPPED_KEY_DOWN:
		case B_UNMAPPED_KEY_UP:
		{
			int32 key = message->GetInt32("raw_char", -1);
			int32 modifiers = message->GetInt32("modifiers", -1);
			if ((modifiers & B_CONTROL_KEY)
					&& (modifiers & B_COMMAND_KEY)
					&& (modifiers & B_SHIFT_KEY)) {
				if (key == 'r') {
					int32 repeat;
					if (message->FindInt32("be:key_repeat", &repeat) == B_OK) {
						// Ignore repeat keypresses
						return B_SKIP_MESSAGE;
					}
					if (message->what == B_KEY_UP
						|| message->what == B_UNMAPPED_KEY_UP) {
						// Only toggle record on keydown
						return B_SKIP_MESSAGE;
					}

					BMessage msg(kCmdToggleRecording);
					if (be_roster->IsRunning(kAppSignature)) {
						BMessenger messenger(kAppSignature);
						messenger.SendMessage(&msg);
					} else
						be_roster->Launch(kAppSignature, &msg);

					return B_SKIP_MESSAGE;
				}
			}
			break;
		}
	}

	return B_DISPATCH_MESSAGE;
}
コード例 #7
0
ファイル: Document.cpp プロジェクト: HaikuArchives/MeV
BFilePanel *
CDocument::CreateSavePanel()
{
	BMessage message(B_SAVE_REQUESTED);
	message.AddPointer("Document", this);

	// Create a new save panel
	BMessenger messenger(NULL, MasterWindow());
	BFilePanel *panel = new BFilePanel(B_SAVE_PANEL, &messenger,
									   NULL, B_FILE_NODE, false, &message);

	// Set the save panel to point to the directory from where we loaded.
	BEntry entry;
	if (m_entry.GetParent(&entry) == B_NO_ERROR)
	{
		panel->SetPanelDirectory(&entry);
	}

	return panel;
}
コード例 #8
0
ファイル: FileSelector.cpp プロジェクト: mariuz/haiku
void 
FileSelector::MessageReceived(BMessage * msg)
{
	switch (msg->what) {
		case START_MSG:
		{
			BMessenger messenger(this);
			fSavePanel = new BFilePanel(B_SAVE_PANEL, 
							&messenger, NULL, 0, false);

			fSavePanel->Window()->SetWorkspaces(B_CURRENT_WORKSPACE);
			fSavePanel->Show();
			break;
		}
		case B_SAVE_REQUESTED:
		{
			entry_ref dir;
			
			if (msg->FindRef("directory", &dir) == B_OK) {
				const char* name;

				BDirectory bdir(&dir);
				if (msg->FindString("name", &name) == B_OK) {
					if (name != NULL)
						fResult = fEntry.SetTo(&bdir, name);
				};
			};

			release_sem(fExitSem);
			break;
		};
		
		case B_CANCEL:
			release_sem(fExitSem);
			break;

		default:
			inherited::MessageReceived(msg);
			break;
	};
}
コード例 #9
0
filter_result
ThinInputFilter::Filter(BMessage* message, BList* outList)
{
	switch (message->what) {
		case B_KEY_DOWN:
		case B_KEY_UP:
		case B_UNMAPPED_KEY_DOWN:
		case B_UNMAPPED_KEY_UP:
		{
			int32 key = message->GetInt32("raw_char", -1);
			int32 modifiers = message->GetInt32("modifiers", -1);
			if ((modifiers & B_CONTROL_KEY) && (modifiers & B_COMMAND_KEY)
				&& (modifiers & B_SHIFT_KEY)) {
				if (key == 'r') {
						// That's for ignoring repeat keypresses
					int32 rep;
					if (message->FindInt32("be:key_repeat", &rep) == B_OK) {
						return B_SKIP_MESSAGE;
					}
						// That's for only toggling record on keydown
					if(message->what == B_KEY_UP
						|| message->what == B_UNMAPPED_KEY_UP)
						return B_SKIP_MESSAGE;
						// And that's for starting the app or sending the message
					BMessage msg(kCmdToggleRecording);
					if (!be_roster->IsRunning(kAppSignature)) {
						be_roster->Launch(kAppSignature, &msg);
					} else {
						BMessenger messenger(kAppSignature);
						messenger.SendMessage(&msg);
					}
					return B_SKIP_MESSAGE;
				}
			}
			break;
		}
	}
	
	return B_DISPATCH_MESSAGE;
}
コード例 #10
0
ファイル: GIFView.cpp プロジェクト: ModeenF/haiku
void
GIFView::AllAttached()
{
	BMessenger messenger(this);
	fInterlacedCB->SetTarget(messenger);
	fUseDitheringCB->SetTarget(messenger);
	fUseTransparentCB->SetTarget(messenger);
	fUseTransparentAutoRB->SetTarget(messenger);
	fUseTransparentColorRB->SetTarget(messenger);
	fRedTextControl->SetTarget(messenger);
	fGreenTextControl->SetTarget(messenger);
	fBlueTextControl->SetTarget(messenger);
	fPaletteM->SetTargetForItems(messenger);
	fColorCountM->SetTargetForItems(messenger);

	BView::AllAttached();

	if (Parent() == NULL && Window()->GetLayout() == NULL) {
		Window()->SetLayout(new BGroupLayout(B_VERTICAL));
		Window()->ResizeTo(PreferredSize().Width(), PreferredSize().Height());
	}
}
コード例 #11
0
void DeskbarPulseView::AttachedToWindow() {
	BMessenger messenger(this);
	mode1->SetTarget(messenger);
	mode2->SetTarget(messenger);
	preferences->SetTarget(messenger);
	about->SetTarget(messenger);
	quit->SetTarget(messenger);

	system_info sys_info;
	get_system_info(&sys_info);
	if (sys_info.cpu_count >= 2) {
		for (int x = 0; x < sys_info.cpu_count; x++) {
			cpu_menu_items[x]->SetTarget(messenger);
		}
	}

	// Use a BMessageRunner to deliver periodic messsages instead
	// of Pulse() events from the Deskbar - this is to avoid changing
	// the current pulse rate and affecting other replicants
	messagerunner = new BMessageRunner(messenger, new BMessage(PV_REPLICANT_PULSE),
		200000, -1);
}
コード例 #12
0
ファイル: App.cpp プロジェクト: marmida/QueryWatcher
void 
QueryView::MouseDown(BPoint point)
{
	BPoint cursorpoint;
	uint32 buttonmask;
	GetMouse(&cursorpoint, &buttonmask);
	if( buttonmask & B_PRIMARY_MOUSE_BUTTON )
	{
		//pop-up query results window
		BMessenger messenger(this);
		messenger.SendMessage(OPEN_QUERY_WIN);
		return;	//buttons aren't mutually exclusive, so we favor the primary.
	}
	if( buttonmask & B_SECONDARY_MOUSE_BUTTON )
	{
		//pop-up context menu
		BPopUpMenu* popup = new BPopUpMenu("QueryWatcher");
		
		BMenuItem* headeritem = new BMenuItem( Name(), NULL );
		headeritem->SetEnabled(false);
		popup->AddItem(headeritem);
		popup->AddSeparatorItem();
		
		popup->AddItem(new BMenuItem("Open settings directory", new BMessage(OPEN_SETTINGS_DIR)));
		popup->AddSeparatorItem();
		
		popup->AddItem( new BMenuItem("Open query results", new BMessage(OPEN_QUERY_WIN) ) );
		popup->AddItem( new BMenuItem("Reset query", new BMessage(RESET_QUERY) ) );
		status_t ret;
		ret = popup->SetTargetForItems(this);		
		#ifdef DEBUG
		ASSERT(ret == B_OK);
		#endif

		ConvertToScreen(&point);
		popup->Go(point, true, false, true);		
		delete popup;
	}
}
コード例 #13
0
ファイル: MessengerServer.cpp プロジェクト: CCJY/ATCD
int ACE_TMAIN (int, ACE_TCHAR **)
{
  try {
    // Construct a Messenger object and use it "as if" it's a corba object.
    // Put it into CORBA object reference
    // comparable to activation, narrow, etc.
    Messenger_var messenger(new Messenger_i);

    // Send a message the the Messenger object.
    CORBA::String_var message = CORBA::string_dup ("Hello!");
    messenger->send_message("TAO User", "TAO Test", message.inout());

    // Print the Messenger's reply.
    std::cout << "Reply: " << message.in() << std::endl;
  }
  catch(const CORBA::Exception& ex) {
    std::cerr << "Caught CORBA::Exception : " << ex << std::endl;
    return 1;
  }

  return 0;
}
コード例 #14
0
void
PowerStatusReplicant::MouseDown(BPoint point)
{
	BMessage* msg = Window()->CurrentMessage();
	int32 buttons = msg->GetInt32("buttons", 0);
	if ((buttons & B_TERTIARY_MOUSE_BUTTON) != 0) {
		BMessenger messenger(this);
		messenger.SendMessage(kMsgToggleExtInfo);
	} else {
		BPopUpMenu* menu = new BPopUpMenu(B_EMPTY_STRING, false, false);
		menu->SetFont(be_plain_font);

		BMenuItem* item;
		menu->AddItem(item = new BMenuItem(B_TRANSLATE("Show text label"),
			new BMessage(kMsgToggleLabel)));
		if (fShowLabel)
			item->SetMarked(true);
		menu->AddItem(item = new BMenuItem(B_TRANSLATE("Show status icon"),
			new BMessage(kMsgToggleStatusIcon)));
		if (fShowStatusIcon)
			item->SetMarked(true);
		menu->AddItem(new BMenuItem(!fShowTime ? B_TRANSLATE("Show time") :
			B_TRANSLATE("Show percent"), new BMessage(kMsgToggleTime)));

		menu->AddSeparatorItem();
		menu->AddItem(new BMenuItem(B_TRANSLATE("Battery info" B_UTF8_ELLIPSIS),
			new BMessage(kMsgToggleExtInfo)));

		menu->AddSeparatorItem();
		menu->AddItem(new BMenuItem(B_TRANSLATE("About" B_UTF8_ELLIPSIS),
			new BMessage(B_ABOUT_REQUESTED)));
		menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"),
			new BMessage(B_QUIT_REQUESTED)));
		menu->SetTargetForItems(this);

		ConvertToScreen(&point);
		menu->Go(point, true, false, true);
	}
}
コード例 #15
0
ファイル: GuideWindow.cpp プロジェクト: brennanos/XFile-Haiku
BStringItem * GuideWindow::modifyGuide(BMessage *msg)
{
	int32 point;
	int32 list;
	
	BStringItem *item = getFocusSelectedItem();
	if(item) {
		point = atoi(item->Text());
		msg->AddInt32("point", point);
		list = _tv_gridguides->Selection();
		if(list == 0) {
			msg->AddBool("orientation", true);
		}
		else {
			msg->AddBool("orientation", false);
		}
		BMessenger messenger(main_view);
		messenger.SendMessage(msg);
	}	
	
	return item;
}
コード例 #16
0
void
Controller::EncodeMovie()
{
	BAutolock _(this);
	
	int32 numFrames = fFileList->CountItems();
	if (numFrames <= 0) {
		std::cout << "Aborted" << std::endl;
		_EncodingFinished(B_ERROR);
		return;
	}
	
	_DumpSettings();
			
	BString fileName;
	Settings().GetOutputFileName(fileName);
	BEntry entry(fileName.String());
	if (entry.Exists()) {
		// file exists.
		fileName = GetUniqueFileName(fileName, MediaFileFormat().file_extension);
	}
	
	fEncoder->SetOutputFile(fileName);
	
	SendNotices(kMsgControllerEncodeStarted);
		 
	BMessage message(kMsgControllerEncodeProgress);
	message.AddInt32("num_files", numFrames);
	
	SendNotices(kMsgControllerEncodeProgress, &message);
	
	fEncoder->SetSource(fFileList);
	
	BMessenger messenger(this);
	fEncoder->SetMessenger(messenger);

	fEncoderThread = fEncoder->EncodeThreaded();
}
コード例 #17
0
status_t 
TShowHideMenuItem::TeamShowHideCommon(int32 action, const BList *teamList, 
	BRect zoomRect, bool doZoom)
{
	if (teamList == NULL)
		return B_BAD_VALUE;

	int32 count = teamList->CountItems();
	for (int32 index = 0; index < count; index++) {
		team_id team = (team_id)teamList->ItemAt(index);

		switch (action) {
			case B_MINIMIZE_WINDOW:
				do_minimize_team(zoomRect, team, doZoom && index == 0);
				break;

			case B_BRING_TO_FRONT:
				do_bring_to_front_team(zoomRect, team, doZoom && index == 0);
				break;

			case B_QUIT_REQUESTED:
				{
					BMessenger messenger((char *)NULL, team);
					uint32 command = B_QUIT_REQUESTED;
					app_info aInfo;
					be_roster->GetRunningAppInfo(team, &aInfo);
	
					if (strcasecmp(aInfo.signature, kTrackerSignature) == 0)
						command = 'Tall';
					
					messenger.SendMessage(command);
					break;
				}
		}
	}

	return B_OK;
}
コード例 #18
0
void MediaRoutingView::showErrorMessage(
	BString text,
	status_t error)
{
	D_METHOD(("MediaRoutingView::showErrorMessage()\n"));

	if (error) {
		text << " (" << strerror(error) << ")";
	}

	BMessage message(M_SHOW_ERROR_MESSAGE);
	message.AddString("text", text.String());
	if (error) {
		message.AddBool("error", true);
	}
	BMessenger messenger(0, Window());
	if (!messenger.IsValid()
	 || (messenger.SendMessage(&message) != B_OK)) {
		BAlert *alert = new BAlert("Error", text.String(), "Ok", 0, 0,
								   B_WIDTH_AS_USUAL, B_WARNING_ALERT);
		alert->Go();
	}
}
コード例 #19
0
void *APServerCommunication::ConnectToServer(PString clientName, ClientDataFunc dataFunc, void *userData)
{
	BMessenger messenger(NULL, serverLooper);
	BMessage message(APSERVER_MSG_CONNECT);
	BMessage reply;
	APClient *newClient;

	// Allocate a new client object
	newClient = new APClient(clientName);
	if (newClient == NULL)
		throw PMemoryException();

	// Tell the new client object about the data function
	newClient->SetDataFunction(dataFunc, userData);

	// Connect to the server
	message.AddPointer("ClientLooper", newClient);
	messenger.SendMessage(&message, &reply);

	// Check the reply for error
	if (reply.what == APSERVER_MSG_ERROR)
	{
		// An error occurred!
		delete newClient;
		return (NULL);
	}

	// Store the new client in the list
	clients.LockList();
	clients.AddTail(newClient);
	clients.UnlockList();

	// Start the BLooper
	newClient->Run();

	return (newClient);
}
コード例 #20
0
ファイル: waitfor.cpp プロジェクト: AmirAbrams/haiku
int
main(int argc, char** argv)
{
	if (argc == 2) {
		while (find_thread(argv[1]) < 0) {
			if (snooze(SNOOZE_TIME) != B_OK)
				return 1;
		}
	} else if (argc == 3 && strcmp(argv[1], "-e") == 0) {
		while (find_thread(argv[2]) >= 0) {
			if (snooze(SNOOZE_TIME) != B_OK)
				return 1;
		}
	} else if (argc == 3 && strcmp(argv[1], "-m") == 0) {
		while (true) {
			BMessenger messenger(argv[2]);
			if (messenger.IsValid())
				break;
			if (snooze(SNOOZE_TIME) != B_OK)
				return 1;
		}
	} else {
		fprintf(stderr,
			"Usage:\n"
			"  %s <thread_name>\n"
			"      wait until a thread with 'thread_name' has been started.\n\n"
			"  %s -e <thread_name>\n"
			"      wait until all threads with thread_name have ended.\n\n"
			"  %s -m <app_signature>\n"
			"      wait until the application specified by 'app_signature' is "
			"is ready to receive messages.\n", argv[0], argv[0], argv[0]);
		return 1;
	}

	return 0;
}
コード例 #21
0
ファイル: TeamWindow.cpp プロジェクト: MaddTheSane/haiku
status_t
TeamWindow::_RetrieveMatchingSourceWorker(void* arg)
{
	TeamWindow* window = (TeamWindow*)arg;

	BStringList* entries = new(std::nothrow) BStringList();
	if (entries == NULL)
		return B_NO_MEMORY;
	ObjectDeleter<BStringList> stringListDeleter(entries);

	if (!window->Lock())
		return B_BAD_VALUE;

	BString path;
	window->fActiveFunction->GetFunctionDebugInfo()->SourceFile()
		->GetPath(path);
	window->Unlock();

	status_t error = window->_RetrieveMatchingSourceEntries(path, entries);
	if (error != B_OK)
		return error;

	entries->Sort();
	BMessenger messenger(window);
	if (messenger.IsValid() && messenger.LockTarget()) {
		if (window->fActiveSourceWorker == find_thread(NULL)) {
			BMessage message(MSG_SOURCE_ENTRY_QUERY_COMPLETE);
			message.AddPointer("entries", entries);
			if (messenger.SendMessage(&message) == B_OK)
				stringListDeleter.Detach();
		}
		window->Unlock();
	}

	return B_OK;
}
コード例 #22
0
void APServerCommunication::DisconnectFromServer(void *handle)
{
	BMessenger messenger(NULL, serverLooper);
	BMessage message(APSERVER_MSG_DISCONNECT);
	int32 i, count;

	// Lock client list
	clients.LockList();

	// Find handle in client list
	count = clients.CountItems();
	for (i = 0; i < count; i++)
	{
		// Did we found the handle
		if (clients.GetItem(i) == handle)
		{
			// Yup, disconnect from the server
			message.AddPointer("ClientLooper", handle);
			messenger.SendMessage(&message, &message);

			// Check reply
			ASSERT(message.what == APSERVER_MSG_OK);

			// Remove the item from the list
			clients.RemoveItem(i);

			// Delete the handle
			((APClient *)handle)->Lock();
			((APClient *)handle)->Quit();
			break;
		}
	}

	// Unlock client list again
	clients.UnlockList();
}
コード例 #23
0
void
ConfigWindow::MessageReceived(BMessage *msg)
{
	switch (msg->what) {
		case kMsgAccountSelected:
		{
			int32 index;
			if (msg->FindInt32("index", &index) != B_OK || index < 0) {
				// deselect current item
				((CenterContainer *)fConfigView)->DeleteChildren();
				MakeHowToView();
				break;
			}
			AccountItem *item = (AccountItem *)fAccountsListView->ItemAt(index);
			if (item)
				item->account->Selected(item->type);
			break;
		}
		case kMsgAddAccount:
		{
			Accounts::NewAccount();
			break;
		}
		case kMsgRemoveAccount:
		{
			int32 index = fAccountsListView->CurrentSelection();
			if (index >= 0) {
				AccountItem *item = (AccountItem *)fAccountsListView->ItemAt(index);
				if (item) {
					item->account->Remove(item->type);
					MakeHowToView();
				}
			}
			break;
		}

		case kMsgIntervalUnitChanged:
		{
			int32 index;
			if (msg->FindInt32("index",&index) == B_OK)
				fIntervalControl->SetEnabled(index != 0);
			break;
		}

		case kMsgShowStatusWindowChanged:
		case kMsgStatusLookChanged:
		case kMsgStatusWorkspaceChanged:
		{
			// the status window stuff is the only "live" setting
			BMessenger messenger("application/x-vnd.Be-POST");
			if (messenger.IsValid())
				messenger.SendMessage(msg);
			break;
		}

		case kMsgRevertSettings:
			RevertToLastSettings();
			break;
		case kMsgApplySettings:
			fSaveSettings = true;
			SaveSettings();
			MakeHowToView();
			break;
		case kMsgSaveSettings:
			fSaveSettings = true;
			PostMessage(B_QUIT_REQUESTED);
			break;
		case kMsgCancelSettings:
			fSaveSettings = false;
			PostMessage(B_QUIT_REQUESTED);
			break;

		default:
			BWindow::MessageReceived(msg);
			break;
	}
}
コード例 #24
0
ファイル: Registrar.cpp プロジェクト: Ithamar/cosmoe
/*!	\brief Overrides the super class version to dispatch roster specific
		   messages.
	\param message The message to be handled
*/
void
Registrar::MessageReceived(BMessage *message)
{
//	FUNCTION_START();
	switch (message->what) {
		// general requests
		case B_REG_GET_MIME_MESSENGER:
		{
			PRINT(("B_REG_GET_MIME_MESSENGER\n"));
			BMessenger messenger(NULL, fMIMEManager);
			BMessage reply(B_REG_SUCCESS);
			reply.AddMessenger("messenger", messenger);
			message->SendReply(&reply);
			break;
		}
		case B_REG_GET_CLIPBOARD_MESSENGER:
		{
			PRINT(("B_REG_GET_CLIPBOARD_MESSENGER\n"));
			BMessenger messenger(fClipboardHandler);
			BMessage reply(B_REG_SUCCESS);
			reply.AddMessenger("messenger", messenger);
			message->SendReply(&reply);
			break;
		}
		// roster requests
		case B_REG_ADD_APP:
			fRoster->HandleAddApplication(message);
			break;
		case B_REG_COMPLETE_REGISTRATION:
			fRoster->HandleCompleteRegistration(message);
			break;
		case B_REG_IS_APP_PRE_REGISTERED:
			fRoster->HandleIsAppPreRegistered(message);
			break;
		case B_REG_REMOVE_PRE_REGISTERED_APP:
			fRoster->HandleRemovePreRegApp(message);
			break;
		case B_REG_REMOVE_APP:
			fRoster->HandleRemoveApp(message);
			break;
		case B_REG_SET_THREAD_AND_TEAM:
			fRoster->HandleSetThreadAndTeam(message);
			break;
		case B_REG_SET_SIGNATURE:
			fRoster->HandleSetSignature(message);
			break;
		case B_REG_GET_APP_INFO:
			fRoster->HandleGetAppInfo(message);
			break;
		case B_REG_GET_APP_LIST:
			fRoster->HandleGetAppList(message);
			break;
		case B_REG_ACTIVATE_APP:
			fRoster->HandleActivateApp(message);
			break;
		case B_REG_BROADCAST:
			fRoster->HandleBroadcast(message);
			break;
		case B_REG_START_WATCHING:
			fRoster->HandleStartWatching(message);
			break;
		case B_REG_STOP_WATCHING:
			fRoster->HandleStopWatching(message);
			break;	
		case B_REG_GET_RECENT_DOCUMENTS:
			fRoster->HandleGetRecentDocuments(message);
			break;
		case B_REG_GET_RECENT_FOLDERS:
			fRoster->HandleGetRecentFolders(message);
			break;
		case B_REG_GET_RECENT_APPS:
			fRoster->HandleGetRecentApps(message);
			break;
		case B_REG_ADD_TO_RECENT_DOCUMENTS:
			fRoster->HandleAddToRecentDocuments(message);
			break;
		case B_REG_ADD_TO_RECENT_FOLDERS:
			fRoster->HandleAddToRecentFolders(message);
			break;
		case B_REG_ADD_TO_RECENT_APPS:
			fRoster->HandleAddToRecentApps(message);
			break;
		case B_REG_CLEAR_RECENT_DOCUMENTS:
			fRoster->ClearRecentDocuments();
			break;
		case B_REG_CLEAR_RECENT_FOLDERS:
			fRoster->ClearRecentFolders();
			break;
		case B_REG_CLEAR_RECENT_APPS:
			fRoster->ClearRecentApps();
			break;
		case B_REG_LOAD_RECENT_LISTS:
			fRoster->HandleLoadRecentLists(message);
			break;
		case B_REG_SAVE_RECENT_LISTS:
			fRoster->HandleSaveRecentLists(message);
			break;
		// message runner requests
		case B_REG_REGISTER_MESSAGE_RUNNER:
			fMessageRunnerManager->HandleRegisterRunner(message);
			break;
		case B_REG_UNREGISTER_MESSAGE_RUNNER:
			fMessageRunnerManager->HandleUnregisterRunner(message);
			break;
		case B_REG_SET_MESSAGE_RUNNER_PARAMS:
			fMessageRunnerManager->HandleSetRunnerParams(message);
			break;
		case B_REG_GET_MESSAGE_RUNNER_INFO:
			fMessageRunnerManager->HandleGetRunnerInfo(message);
			break;
		// internal messages
		case B_REG_ROSTER_SANITY_EVENT:
			fRoster->CheckSanity();
			fSanityEvent->SetTime(system_time() + kRosterSanityEventInterval);
			fEventQueue->AddEvent(fSanityEvent);
			break;
		default:
			BApplication::MessageReceived(message);
			break;
	}
//	FUNCTION_END();
}
コード例 #25
0
ファイル: ShortcutsWindow.cpp プロジェクト: mmanley/Antares
void
ShortcutsWindow::MessageReceived(BMessage* msg)
{
	switch(msg->what) {
		case OPEN_KEYSET: 
		case APPEND_KEYSET: 
			fLastOpenWasAppend = (msg->what == APPEND_KEYSET);
			if (fOpenPanel) 
				fOpenPanel->Show();
			else {
				BMessenger m(this);
				fOpenPanel = new BFilePanel(B_OPEN_PANEL, &m, NULL, 0, false);
				fOpenPanel->Show();
			}
			fOpenPanel->SetButtonLabel(B_DEFAULT_BUTTON, fLastOpenWasAppend ? 
				"Append" : "Open");
		break;

		case REVERT_KEYSET:
		{
			// Send a message to myself, to get me to reload the settings file
			fLastOpenWasAppend = false;
			BMessage reload(B_REFS_RECEIVED);
			entry_ref eref;
			_GetSettingsFile(&eref);
			reload.AddRef("refs", &eref);
			reload.AddString("startupRef", "yeah");
			PostMessage(&reload);
		}
		break;

		// Respond to drag-and-drop messages here
		case B_SIMPLE_DATA:
		{
			int i = 0;

			entry_ref ref;
			while (msg->FindRef("refs", i++, &ref) == B_NO_ERROR) {
				BEntry entry(&ref);
				if (entry.InitCheck() == B_NO_ERROR) {
					BPath path(&entry);
					
					if (path.InitCheck() == B_NO_ERROR) {
						// Add a new item with the given path.
						BString str(path.Path());
						DoStandardEscapes(str);
						_AddNewSpec(str.String());
					}
				}
			}
		}
		break;

		// Respond to FileRequester's messages here
		case B_REFS_RECEIVED:
		{
			// Find file ref
			entry_ref ref;
			bool isStartMsg = msg->HasString("startupRef");
			if (msg->FindRef("refs", &ref) == B_NO_ERROR) {
				// load the file into (fileMsg)
				BMessage fileMsg;
				{
					BFile file(&ref, B_READ_ONLY);
					if ((file.InitCheck() != B_NO_ERROR) 
						|| (fileMsg.Unflatten(&file) != B_NO_ERROR)) {
						if (isStartMsg) {
							// use this to save to anyway
							fLastSaved = BEntry(&ref);
							break;
						} else {
							(new BAlert(ERROR, 
								"Shortcuts was couldn't open your KeySet file!"
								, "Okay"))->Go(NULL);
							break;
						}
					}
				}
 
				if (fLastOpenWasAppend == false) {
					// Clear the menu...
					ShortcutsSpec * item;
					do {
						delete (item = ((ShortcutsSpec*)
							fColumnListView->RemoveItem(int32(0))));
					} while (item);
				}

				if (_LoadKeySet(fileMsg)) {
					if (isStartMsg) fLastSaved = BEntry(&ref);
					fSaveButton->SetEnabled(isStartMsg == false);

					// If we just loaded in the Shortcuts settings file, then 
					// no need to tell the user to save on exit.
					entry_ref eref;
					_GetSettingsFile(&eref);
					if (ref == eref) fKeySetModified = false;
				} else {
					(new BAlert(ERROR, 
						"Shortcuts was unable to parse your KeySet file!", 
						"Okay"))->Go(NULL);
					break;
				}
			}
		}
		break;

		// These messages come from the pop-up menu of the Applications column
		case SELECT_APPLICATION:
		{
			int csel = fColumnListView->CurrentSelection();
			if (csel >= 0) {
				entry_ref aref;
				if (msg->FindRef("refs", &aref) == B_NO_ERROR) {
					BEntry ent(&aref);
					if (ent.InitCheck() == B_NO_ERROR) {
						BPath path;
						if ((ent.GetPath(&path) == B_NO_ERROR) 
							&& (((ShortcutsSpec *)
							fColumnListView->ItemAt(csel))->
							ProcessColumnTextString(ShortcutsSpec::
							STRING_COLUMN_INDEX, path.Path()))) {
							
							fColumnListView->InvalidateItem(csel);
							_MarkKeySetModified();
						}
					}
				}
			}
		}
		break;

		case SAVE_KEYSET:
		{
			bool showSaveError = false;

			const char * name;
			entry_ref entry;
			if ((msg->FindString("name", &name) == B_NO_ERROR) 
				&& (msg->FindRef("directory", &entry) == B_NO_ERROR)) {
				BDirectory dir(&entry);
				BEntry saveTo(&dir, name, true);
				showSaveError = ((saveTo.InitCheck() != B_NO_ERROR) 
				|| (_SaveKeySet(saveTo) == false));
			} else if (fLastSaved.InitCheck() == B_NO_ERROR) {
				// We've saved this before, save over previous file.
				showSaveError = (_SaveKeySet(fLastSaved) == false);
			} else PostMessage(SAVE_KEYSET_AS); // open the save requester...

			if (showSaveError) {
				(new BAlert(ERROR, "Shortcuts wasn't able to save your keyset."
				, "Okay"))->Go(NULL);
			}
		}
		break;

		case SAVE_KEYSET_AS:
		{
			if (fSavePanel)
				fSavePanel->Show();
			else {
				BMessage msg(SAVE_KEYSET);
				BMessenger messenger(this);
				fSavePanel = new BFilePanel(B_SAVE_PANEL, &messenger, NULL, 0, 
					false, &msg);
				fSavePanel->Show();
			}
		}
		break;

		case B_ABOUT_REQUESTED:
			be_app_messenger.SendMessage(B_ABOUT_REQUESTED);
		break;

		case ADD_HOTKEY_ITEM:
			_AddNewSpec(NULL);
		break;

		case REMOVE_HOTKEY_ITEM:
		{
			int index = fColumnListView->CurrentSelection();
			if (index >= 0) {
				CLVListItem* item = (CLVListItem*) 
					fColumnListView->ItemAt(index);
				fColumnListView->RemoveItem(index);
				delete item;
				_MarkKeySetModified();

				// Rules for new selection: If there is an item at (index),
				// select it. Otherwise, if there is an item at (index-1), 
				// select it. Otherwise, select nothing.
				int num = fColumnListView->CountItems();
				if (num > 0) {
					if (index < num)
						fColumnListView->Select(index);
					else {
						if (index > 0)
							index--;
						if (index < num) 
							fColumnListView->Select(index);
					}
				}
			}
		}
		break;

		// Received when the user clicks on the ColumnListView
		case HOTKEY_ITEM_SELECTED:
		{
			int32 index = -1;
			msg->FindInt32("index", &index);
			bool validItem = (index >= 0);
			fRemoveButton->SetEnabled(validItem);
		}
		break;

		// Received when an entry is to be modified in response to GUI activity
		case HOTKEY_ITEM_MODIFIED:
		{
			int32 row, column;

			if ((msg->FindInt32("row", &row) == B_NO_ERROR) 
				&& (msg->FindInt32("column", &column) == B_NO_ERROR)) {
				int32 key;
				const char* bytes;

				if (row >= 0) {
					ShortcutsSpec* item = (ShortcutsSpec*)
						fColumnListView->ItemAt(row);
					bool repaintNeeded = false; // default

					if (msg->HasInt32("mouseClick")) {
						repaintNeeded = item->ProcessColumnMouseClick(column);
					} else if ((msg->FindString("bytes", &bytes) == B_NO_ERROR)
						&& (msg->FindInt32("key", &key) == B_NO_ERROR)) {
						repaintNeeded = item->ProcessColumnKeyStroke(column, 
							bytes, key);
					} else if (msg->FindInt32("unmappedkey", &key) == 
						B_NO_ERROR) {
						repaintNeeded = ((column == item->KEY_COLUMN_INDEX) 
							&& ((key > 0xFF) || (GetKeyName(key) != NULL)) 
							&& (item->ProcessColumnKeyStroke(column, NULL, 
							key)));
					} else if (msg->FindString("text", &bytes) == B_NO_ERROR) {
						if ((bytes[0] == '(')&&(bytes[1] == 'C')) {
							if (fSelectPanel)
								fSelectPanel->Show();
							else {
								BMessage msg(SELECT_APPLICATION);
								BMessenger m(this);
								fSelectPanel = new BFilePanel(B_OPEN_PANEL, &m,
									NULL, 0, false, &msg);
								fSelectPanel->Show();
							}
							fSelectPanel->SetButtonLabel(B_DEFAULT_BUTTON, 
								"Select");
						} else 
							repaintNeeded = item->ProcessColumnTextString(
								column, bytes);
					}
					
					if (repaintNeeded) {
						fColumnListView->InvalidateItem(row);
						_MarkKeySetModified();
					}
				}
			}
		}
		break;

		default:
			BWindow::MessageReceived(msg);
		break;
	}
}
コード例 #26
0
ファイル: App.cpp プロジェクト: humdingerb/quicklaunchng
App::~App()
{
	BMessenger messenger(fMainWindow);
	if (messenger.IsValid() && messenger.LockTarget())
		fMainWindow->Quit();
}
コード例 #27
0
ImageWindow::ImageWindow(BRect rect, const char *name)
	: BWindow(rect, name, B_DOCUMENT_WINDOW, 0)
{
	// Setup menu bar
	BRect rctbar(0, 0, 100, 10);
	BMenuBar *pbar = new BMenuBar(rctbar, "MenuBar");

	BMenu *pmnufile = new BMenu(B_TRANSLATE("File"));
	BMenuItem *pitmopen = new BMenuItem(B_TRANSLATE("Open..."),
		new BMessage(M_OPEN_IMAGE), 'O', 0);

	BMenuItem *pitmsave = new BMenuItem(B_TRANSLATE("Save..."),
		new BMessage(M_SAVE_IMAGE), 'S', 0);

	BMenuItem *pitmquit = new BMenuItem(B_TRANSLATE("Quit"),
		new BMessage(B_QUIT_REQUESTED), 'Q', 0);

	pmnufile->AddItem(pitmopen);
	pmnufile->AddItem(pitmsave);
	pmnufile->AddSeparatorItem();
	pmnufile->AddItem(pitmquit);
	pbar->AddItem(pmnufile);

	BMenu *pmnuview = new BMenu(B_TRANSLATE("View"));
	BMenuItem *pitmfirst = new BMenuItem(B_TRANSLATE("First Page"),
		new BMessage(M_VIEW_FIRST_PAGE), 'F', 0);

	BMenuItem *pitmlast = new BMenuItem(B_TRANSLATE("Last Page"),
		new BMessage(M_VIEW_LAST_PAGE), 'L', 0);

	BMenuItem *pitmnext = new BMenuItem(B_TRANSLATE("Next Page"),
		new BMessage(M_VIEW_NEXT_PAGE), 'N', 0);

	BMenuItem *pitmprev = new BMenuItem(B_TRANSLATE("Previous Page"),
		new BMessage(M_VIEW_PREV_PAGE), 'P', 0);

	pmnuview->AddItem(pitmfirst);
	pmnuview->AddItem(pitmlast);
	pmnuview->AddItem(pitmnext);
	pmnuview->AddItem(pitmprev);
	pbar->AddItem(pmnuview);


	BMenu *pmnuwindow = new BMenu(B_TRANSLATE("Window"));
	BMenuItem *pitmactives = new BMenuItem(B_TRANSLATE("Active Translators"),
		new BMessage(M_ACTIVE_TRANSLATORS_WINDOW), 'T', 0);
	pitmactives->SetTarget(be_app);

	BMenuItem *pitminfo = new BMenuItem(B_TRANSLATE("Info"),
		new BMessage(M_INFO_WINDOW), 'I', 0);
	pitminfo->SetTarget(be_app);

	pmnuwindow->AddItem(pitmactives);
	pmnuwindow->AddItem(pitminfo);
	pbar->AddItem(pmnuwindow);

	AddChild(pbar);

	// Setup image view
	BRect rctview = Bounds();
	rctview.top = pbar->Frame().bottom + 1;
	rctview.right -= B_V_SCROLL_BAR_WIDTH;
	rctview.bottom -= B_H_SCROLL_BAR_HEIGHT;

	fpimageView = new ImageView(rctview, "ImageView");
	AddChild(new BScrollView("ImageScroll", fpimageView,
		B_FOLLOW_ALL_SIDES, 0, true, true));

	// Setup file open panel
	BMessenger messenger(this);
	BMessage message(M_OPEN_FILE_PANEL);
	fpopenPanel = new BFilePanel(B_OPEN_PANEL, &messenger, NULL, 0L, false,
		&message, NULL, false, true);

	SetSizeLimits(200, 10000, 150, 10000);
}
コード例 #28
0
filter_result
ShakeTrackingFilter::Filter(BMessage* message, BHandler** /*_target*/)
{
	if (fTargetView == NULL)
		return B_DISPATCH_MESSAGE;

	switch (message->what) {
		case B_MOUSE_MOVED:
		{
			BPoint position;
			message->FindPoint("be:view_where", &position);

			// TODO: allow using BRegion masks
			if (!fTargetView->Bounds().Contains(position))
				return B_DISPATCH_MESSAGE;

			fLowPass.Input(position - fLastPosition);

			BPoint delta = fLowPass.Output();

			// normalized dot product
			float norm = delta.x * delta.x + delta.y * delta.y;
			if (norm > 0.01) {
				delta.x /= norm;
				delta.y /= norm;
			}

			norm = fLastDelta.x * fLastDelta.x + fLastDelta.y * fLastDelta.y;
			if (norm > 0.01) {
				fLastDelta.x /= norm;
				fLastDelta.y /= norm;
			}

			float dot = delta.x * fLastDelta.x + delta.y * fLastDelta.y;

			if (dot < 0.0) {
				if (fCounter == 0) {
					BMessage * cancelMessage = new BMessage(kMsgCancel);
		 			fCancelRunner = new BMessageRunner(BMessenger(fTargetView),
		 				cancelMessage, fTimeThreshold, 1);
				}

				fCounter++;

				if (fCounter >= fCountThreshold) {
					BMessage shakeMessage(fMessageWhat);
					shakeMessage.AddUInt32("count", fCounter);
					BMessenger messenger(fTargetView);
					messenger.SendMessage(&shakeMessage);
				}
			}

			fLastDelta = fLowPass.Output();
			fLastPosition = position;

			return B_DISPATCH_MESSAGE;
		}

		case kMsgCancel:
			delete fCancelRunner;
			fCancelRunner = NULL;
			fCounter = 0;
			return B_SKIP_MESSAGE;

		default:
			break;
	}

	return B_DISPATCH_MESSAGE;
}
コード例 #29
0
void
TargetSettingsWin::Unregister()
{
	BMessenger messenger(ApplicationSignature);
	messenger.SendMessage(new BMessage(WINDOW_REGISTRY_SUB));
}
コード例 #30
0
ファイル: messenger.c プロジェクト: omarmc9203/CyanogenPSP
void newMessage()
{	
	new_message = oslLoadImageFilePNG("system/app/messenger/new_message.png", OSL_IN_RAM, OSL_PF_8888);
	
	if (!new_message)
		debugDisplay();
	
	while (!osl_quit)
	{
		LowMemExit();
		
		oslStartDrawing();
		
		oslClearScreen(RGB(0,0,0));
		
		controls();	

		oslDrawImageXY(new_message, 0, 0);
		
		navbarButtons(2);
		battery(330,2,0);
		digitaltime(381,4,0,hrTime);
		androidQuickSettings();
		volumeController();
		oslDrawImage(cursor);
		
		if (osl_keys->pressed.L)
		{
			oslPlaySound(Lock, 1);  
			lockscreen();
		}
		
		if (osl_keys->pressed.circle)
		{
			oslDeleteImage(new_message);
			messenger();
		}

		if ((cursor->x  >= 444 && cursor->x  <= 480) && (cursor->y >= 157 && cursor->y <= 213) && (osl_keys->pressed.cross))
		{
			oslPlaySound(KeypressStandard, 1);  
			oslDeleteImage(messengerbg);
			messenger();
		}

		if ((cursor->x  >= 444 && cursor->x  <= 480) && (cursor->y >= 76 && cursor->y <= 155) && (osl_keys->pressed.cross))
		{
			oslPlaySound(KeypressStandard, 1);  
			oslDeleteImage(messengerbg);
			home();
		}
		
		if ((cursor->x  >= 444 && cursor->x  <= 480) && (cursor->y >= 19 && cursor->y <= 75) && (osl_keys->pressed.cross))
		{
			oslPlaySound(KeypressStandard, 1);  
			multitask();
		}
		
		captureScreenshot();
		
		if (cursor->x >= 7 && cursor->x <= 435 && cursor->y >= 55 && cursor->y <= 86 && osl_keys->pressed.cross)
		{
			oslPlaySound(KeypressStandard, 1);  
			doServer();
		}
		
		oslIntraFontSetStyle(Roboto, fontSize, BLACK, 0, INTRAFONT_ALIGN_LEFT);
		oslDrawString(14, 245, tempMessage);
		
		if (cursor->x >= 10 && cursor->x <= 362 && cursor->y >= 228 && cursor->y <= 270 && osl_keys->pressed.cross)
		{
			oslPlaySound(KeypressStandard, 1);  
			openOSK("Enter Message", "", 128, -1);
		}
		
		if ((cursor->x >= 10 && cursor->x <= 405 && cursor->y >= 88 && cursor->y <= 118 && osl_keys->pressed.cross) && oslIsWlanPowerOn())
			doClient();
        else if ((cursor->x >= 410 && cursor->x <= 442 && cursor->y >= 92 && cursor->y <= 118 && osl_keys->pressed.cross) && oslIsWlanPowerOn())
			doServer();
		
        oslEndDrawing(); 
		oslEndFrame(); 
        oslSyncFrame();
	}
}