コード例 #1
0
void SnowView::MessageReceived(BMessage *msg)
{
	BAlert *info;
	//msg->PrintToStream();
	switch (msg->what) {
	case MSG_PULSE_ME:
		if (Parent()) {
			Calc();
			InvalFlakes();
		}
		break;
	case B_ABOUT_REQUESTED:
		info = new BAlert("BSnow info", 
			"BSnow, just in case you don't have real one...\n"
			"" B_UTF8_COPYRIGHT " 2003, François Revol.", 
			"Where is Santa ??");
		info->SetFeel(B_NORMAL_WINDOW_FEEL);
		info->SetLook(B_FLOATING_WINDOW_LOOK);
		info->SetFlags(info->Flags()|B_NOT_ZOOMABLE);
		info->Go(NULL);
		break;
	default:
//#ifdef FORWARD_TO_PARENT
/*
		if (fAttached && Parent())
			Parent()->MessageReceived(msg);
		else
*/
//#endif
			BView::MessageReceived(msg);
	}
}
コード例 #2
0
void
NotifyFilter::MailboxSynced(status_t status)
{
	if (fNNewMessages == 0)
		return;

	if (fStrategy & do_beep)
		system_beep("New E-mail");

	if (fStrategy & alert) {
		BString text, numString;
		if (fNNewMessages != 1)
			text << B_TRANSLATE("You have %num new messages for %name.");
		else
			text << B_TRANSLATE("You have %num new message for %name.");

		numString << fNNewMessages;
		text.ReplaceFirst("%num", numString);
		text.ReplaceFirst("%name", fMailProtocol.AccountSettings().Name());

		BAlert *alert = new BAlert(B_TRANSLATE("New messages"), text.String(),
			B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL);
		alert->SetFeel(B_NORMAL_WINDOW_FEEL);
		alert->Go(NULL);
	}

	if (fStrategy & blink_leds)
		be_app->PostMessage('mblk');

	if (fStrategy & one_central_beep)
		be_app->PostMessage('mcbp');

	if (fStrategy & big_doozy_alert) {
		BMessage msg('numg');
		msg.AddInt32("num_messages", fNNewMessages);
		msg.AddString("name", fMailProtocol.AccountSettings().Name());

		be_app->PostMessage(&msg);
	}

	if (fStrategy & log_window) {
		BString message, numString;
		if (fNNewMessages != 1)
			message << B_TRANSLATE("%num new messages");
		else
			message << B_TRANSLATE("%num new message");

		numString << fNNewMessages;
		message.ReplaceFirst("%num", numString);

		fMailProtocol.ShowMessage(message.String());
	}

	fNNewMessages = 0;
}
コード例 #3
0
ファイル: DCCHandler.cpp プロジェクト: xray7224/Vision
void
ServerAgent::DCCChatDialog(BString theNick, BString theIP, BString thePort)
{
  BString theText(theNick);
  theText << S_SERVER_DCC_CHAT_PROMPT;
  BAlert *myAlert = new BAlert("DCC request", theText.String(), "Accept",
    "Refuse");
  myAlert->SetFeel (B_FLOATING_APP_WINDOW_FEEL);
  BMessage *myMessage = new BMessage(M_CHAT_ACCEPT);
  myMessage->AddString("nick", theNick.String());
  myMessage->AddString("ip", theIP.String());
  myMessage->AddString("port", thePort.String());
  BInvoker *myInvoker = new BInvoker(myMessage, this);
  myAlert->Go(myInvoker);
}
コード例 #4
0
ファイル: alert.cpp プロジェクト: AmirAbrams/haiku
/*!
	Is called when the app receives a B_READY_TO_RUN message. The message
	is sent automatically during the Run() function, and is sent after the
	initial B_REFS_RECEIVED and B_ARGV_RECEIVED messages (if any) have been
	handled.
*/
void
AlertApplication::ReadyToRun()
{
	if (GoodArguments()) {
		BAlert* alert = new BAlert("alert", fArgumentText,
			fArgumentButton0, fArgumentButton1, fArgumentButton2,
			B_WIDTH_AS_USUAL, fIcon);

		if (fModal)
			alert->SetFeel(B_MODAL_ALL_WINDOW_FEEL);

		_SetChoice(alert->Go());
	} else
		_Usage();

	Quit();
}
コード例 #5
0
ファイル: filter.cpp プロジェクト: luciang/haiku
void NotifyCallback::Callback(status_t result) {
	parent->callback = NULL;

	if (num_messages == 0)
		return;

	if (strategy & do_beep)
		system_beep("New E-mail");

	if (strategy & alert) {
		BString text;
		MDR_DIALECT_CHOICE (
		text << "You have " << num_messages << " new message" << ((num_messages != 1) ? "s" : "")
		<< " for " << chainrunner->Chain()->Name() << ".",

		text << chainrunner->Chain()->Name() << "より\n" << num_messages << " 通のメッセージが届きました");

		BAlert *alert = new BAlert(MDR_DIALECT_CHOICE ("New messages","新着メッセージ"), text.String(), "OK", NULL, NULL, B_WIDTH_AS_USUAL);
		alert->SetFeel(B_NORMAL_WINDOW_FEEL);
		alert->Go(NULL);
	}

	if (strategy & blink_leds)
		be_app->PostMessage('mblk');

	if (strategy & one_central_beep)
		be_app->PostMessage('mcbp');

	if (strategy & big_doozy_alert) {
		BMessage msg('numg');
		msg.AddInt32("num_messages",num_messages);
		msg.AddString("chain_name",chainrunner->Chain()->Name());
		msg.AddInt32("chain_id",chainrunner->Chain()->ID());

		be_app->PostMessage(&msg);
	}

	if (strategy & log_window) {
		BString message;
		message << num_messages << " new message" << ((num_messages != 1) ? "s" : "");
		chainrunner->ShowMessage(message.String());
	}
}
コード例 #6
0
void LeftList::KeyDown(const char* bytes, int32 numBytes)
{
	BPath temp_path;
	int32 result;
	switch (bytes[0]) {
		case B_DELETE: {
				int32 selection = CurrentSelection();
				if (selection >= 0) {
					BAlert* MyAlert = new BAlert("BurnItNow", "Are you sure you want to delete this selection", "Yes", "No", NULL, B_WIDTH_AS_USUAL, B_INFO_ALERT);
					MyAlert->SetFeel(B_MODAL_ALL_WINDOW_FEEL);
					result = MyAlert->Go();
					if (result == 0) {
						LeftListItem* item = (LeftListItem*)RemoveItem(selection);
						if (!item->fIsAudio) {
							VRCD = false;
							ISOFILE = false;
							jpWindow* win = dynamic_cast<jpWindow*>(Window());
							if (win != NULL) {
								win->fMakeDirButton->SetEnabled(false);
								win->fParentDirButton->SetEnabled(false);
								win->fNewVRCDButton->SetEnabled(true);
								win->fAddISOButton->SetEnabled(true);
								win->fDataView->fBootableCDCheckBox->SetEnabled(false);
								win->fDataView->fChooseBootImageButton->SetEnabled(false);
							}

						}
						if (item != NULL)
							delete item;
					}
				}
				break;
			}
		default:
			BListView::KeyDown(bytes, numBytes);
	}
}
コード例 #7
0
ファイル: about.cpp プロジェクト: ashmew2/netsurf-kolibri
/**
 * Creates the about alert
 */
void nsbeos_about(struct gui_window *gui)
{
	BString text;
	text << "Netsurf  : " << user_agent_string() << "\n";
	text << "Version  : " << netsurf_version << "\n";
	text << "Build ID : " << WT_REVID << "\n";
	text << "Date     : " << WT_COMPILEDATE << "\n";
	text << "cURL     : " << LIBCURL_VERSION << "\n";

	BAlert *alert = new BAlert("about", text.String(), "Credits", "Licence", "Ok");

	BHandler *target = be_app;
	BMessage *message = new BMessage(ABOUT_BUTTON);
	BInvoker *invoker = NULL;
	if (gui) {
		nsbeos_scaffolding *s = nsbeos_get_scaffold(gui);
		if (s) {
			NSBrowserWindow *w = nsbeos_get_bwindow_for_scaffolding(s);
			if (w) {
				alert->SetFeel(B_MODAL_SUBSET_WINDOW_FEEL);
				alert->AddToSubset(w);
			}
			NSBaseView *v = nsbeos_get_baseview_for_scaffolding(s);
			if (v) {
				if (w)
					message->AddPointer("Window", w);
				target = v;
			}
		}
	}
	invoker = new BInvoker(message, target);

	//TODO: i18n-ize

	alert->Go(invoker);
}
コード例 #8
0
void
ShutdownProcess::_WorkerDoShutdown()
{
	PRINT(("ShutdownProcess::_WorkerDoShutdown()\n"));

	// If we are here, the shutdown process has been initiated successfully,
	// that is, if an asynchronous BRoster::Shutdown() was requested, we
	// notify the caller at this point.
	bool synchronous;
	if (fRequest->FindBool("synchronous", &synchronous) == B_OK && !synchronous)
		_SendReply(B_OK);

	// ask the user to confirm the shutdown, if desired
	bool askUser;
	if (fHasGUI && fRequest->FindBool("confirm", &askUser) == B_OK && askUser) {
		const char* restart = B_TRANSLATE("Restart");
		const char* shutdown = B_TRANSLATE("Shut down");
		BString title = B_TRANSLATE("%action%?");
		title.ReplaceFirst("%action%", fReboot ? restart : shutdown);
		const char* text = fReboot
			? B_TRANSLATE("Do you really want to restart the system?")
			: B_TRANSLATE("Do you really want to shut down the system?");
		const char* defaultText = fReboot ? restart : shutdown;
		const char* otherText = fReboot ? shutdown : restart;
		BAlert* alert = new BAlert(title.String(), text,
			B_TRANSLATE("Cancel"), otherText, defaultText,
			B_WIDTH_AS_USUAL, B_WARNING_ALERT);
		alert->SetShortcut(0, B_ESCAPE);
		// We want the alert to behave more like a regular window...
		alert->SetFeel(B_NORMAL_WINDOW_FEEL);
		// ...but not quit. Minimizing the alert would prevent the user from
		// finding it again, since registrar does not have an entry in the
		// Deskbar.
		alert->SetFlags(alert->Flags() | B_NOT_MINIMIZABLE);
		alert->SetWorkspaces(B_ALL_WORKSPACES);
		int32 result = alert->Go();

		if (result == 1) {
			// Toggle shutdown method
			fReboot = !fReboot;
		} else if (result < 1)
			throw_error(B_SHUTDOWN_CANCELLED);
	}

	// tell TRoster not to accept new applications anymore
	fRoster->SetShuttingDown(true);

	fWorkerLock.Lock();

	// get a list of all applications to shut down and sort them
	status_t status = fRoster->GetShutdownApps(fUserApps, fSystemApps,
		fBackgroundApps, fVitalSystemApps);
	if (status  != B_OK) {
		fWorkerLock.Unlock();
		fRoster->RemoveWatcher(this);
		fRoster->SetShuttingDown(false);
		return;
	}

	fUserApps.Sort(&inverse_compare_by_registration_time);
	fSystemApps.Sort(&inverse_compare_by_registration_time);

	fWorkerLock.Unlock();

	// make the shutdown window ready and show it
	_InitShutdownWindow();
	_SetShutdownWindowCurrentApp(-1);
	_SetShutdownWindowText(B_TRANSLATE("Tidying things up a bit."));
	_SetShutdownWindowCancelButtonEnabled(true);
	_SetShutdownWindowKillButtonEnabled(false);
	_SetShowShutdownWindow(true);

	// sync
	sync();

	// phase 1: terminate the user apps
	_SetPhase(USER_APP_TERMINATION_PHASE);
	_QuitApps(fUserApps, false);
	_WaitForDebuggedTeams();

	// phase 2: terminate the system apps
	_SetPhase(SYSTEM_APP_TERMINATION_PHASE);
	_QuitApps(fSystemApps, true);
	_WaitForDebuggedTeams();

	// phase 3: terminate the background apps
	_SetPhase(BACKGROUND_APP_TERMINATION_PHASE);
	_QuitBackgroundApps();
	_WaitForDebuggedTeams();

	// phase 4: terminate the other processes
	_SetPhase(OTHER_PROCESSES_TERMINATION_PHASE);
	_QuitNonApps();
	_ScheduleTimeoutEvent(kBackgroundAppQuitTimeout, -1);
	_WaitForBackgroundApps();
	_KillBackgroundApps();
	_WaitForDebuggedTeams();

	// we're through: do the shutdown
	_SetPhase(DONE_PHASE);
	if (fReboot)
		_SetShutdownWindowText(B_TRANSLATE("Restarting" B_UTF8_ELLIPSIS));
	else
		_SetShutdownWindowText(B_TRANSLATE("Shutting down" B_UTF8_ELLIPSIS));
	_ShutDown();
	_SetShutdownWindowWaitForShutdown();

	PRINT(("  _kern_shutdown() failed\n"));

	// shutdown failed: This can happen for power off mode -- reboot should
	// always work.
	if (fHasGUI) {
		// wait for the reboot event
		uint32 event;
		do {
			team_id team;
			int32 phase;
			status = _GetNextEvent(event, team, phase, true);
			if (status != B_OK)
				break;
		} while (event != REBOOT_SYSTEM_EVENT);

		_kern_shutdown(true);
	}

	// either there's no GUI or reboot failed: we enter the kernel debugger
	// instead
#ifdef __HAIKU__
// TODO: Introduce the syscall.
//	while (true) {
//		_kern_kernel_debugger("The system is shut down. It's now safe to turn "
//			"off the computer.");
//	}
#endif
}
コード例 #9
0
void
MailDaemonApp::MessageReceived(BMessage* msg)
{
	switch (msg->what) {
		case 'moto':
			if (fSettingsFile.CheckOnlyIfPPPUp()) {
				// TODO: check whether internet is up and running!
			}
			// supposed to fall through
		case kMsgCheckAndSend:	// check & send messages
			msg->what = kMsgSendMessages;
			PostMessage(msg);
			// supposed to fall trough
		case kMsgCheckMessage:	// check messages
			GetNewMessages(msg);
			break;

		case kMsgSendMessages:	// send messages
			SendPendingMessages(msg);
			break;

		case kMsgSettingsUpdated:
			fSettingsFile.Reload();
			_UpdateAutoCheck(fSettingsFile.AutoCheckInterval());
			break;

		case kMsgAccountsChanged:
			_ReloadAccounts(msg);
			break;

		case kMsgSetStatusWindowMode:	// when to show the status window
		{
			int32 mode;
			if (msg->FindInt32("ShowStatusWindow", &mode) == B_OK)
				fNotifyMode = mode;
			break;
		}

		case kMsgMarkMessageAsRead:
		{
			int32 account = msg->FindInt32("account");
			entry_ref ref;
			if (msg->FindRef("ref", &ref) != B_OK)
				break;
			read_flags read = (read_flags)msg->FindInt32("read");
			AccountMap::iterator it = fAccounts.find(account);
			if (it == fAccounts.end())
				break;
			InboundProtocolThread* inboundThread = it->second.inboundThread;
			inboundThread->MarkMessageAsRead(ref, read);
			break;
		}

		case kMsgFetchBody:
			RefsReceived(msg);
			break;

		case 'stwg':	// Status window gone
		{
			BMessage reply('mnuc');
			reply.AddInt32("num_new_messages", fNewMessages);

			while ((msg = fFetchDoneRespondents.RemoveItemAt(0))) {
				msg->SendReply(&reply);
				delete msg;
			}

			if (fAlertString != B_EMPTY_STRING) {
				fAlertString.Truncate(fAlertString.Length() - 1);
				BAlert* alert = new BAlert(B_TRANSLATE("New Messages"),
					fAlertString.String(), "OK", NULL, NULL, B_WIDTH_AS_USUAL);
				alert->SetFeel(B_NORMAL_WINDOW_FEEL);
				alert->Go(NULL);
				fAlertString = B_EMPTY_STRING;
			}

			if (fCentralBeep) {
				system_beep("New E-mail");
				fCentralBeep = false;
			}
			break;
		}

		case 'mcbp':
			if (fNewMessages > 0)
				fCentralBeep = true;
			break;

		case kMsgCountNewMessages:	// Number of new messages
		{
			BMessage reply('mnuc');	// Mail New message Count
			if (msg->FindBool("wait_for_fetch_done")) {
				fFetchDoneRespondents.AddItem(DetachCurrentMessage());
				break;
			}

			reply.AddInt32("num_new_messages", fNewMessages);
			msg->SendReply(&reply);
			break;
		}

		case 'mblk':	// Mail Blink
			if (fNewMessages > 0)
				fLEDAnimation->Start();
			break;

		case 'enda':	// End Auto Check
			delete fAutoCheckRunner;
			fAutoCheckRunner = NULL;
			break;

		case 'numg':
		{
			int32 numMessages = msg->FindInt32("num_messages");
			BString numString;

			if (numMessages > 1)
				fAlertString << B_TRANSLATE("%num new messages for %name\n");
			else
				fAlertString << B_TRANSLATE("%num new message for %name\n");

			numString << numMessages;
			fAlertString.ReplaceFirst("%num", numString);
			fAlertString.ReplaceFirst("%name", msg->FindString("name"));
			break;
		}

		case B_QUERY_UPDATE:
		{
			int32 what;
			msg->FindInt32("opcode", &what);
			switch (what) {
				case B_ENTRY_CREATED:
					fNewMessages++;
					break;
				case B_ENTRY_REMOVED:
					fNewMessages--;
					break;
			}

			BString string, numString;

			if (fNewMessages > 0) {
				if (fNewMessages != 1)
					string << B_TRANSLATE("%num new messages.");
				else
					string << B_TRANSLATE("%num new message.");

			numString << fNewMessages;
			string.ReplaceFirst("%num", numString);
			}
			else
				string << B_TRANSLATE("No new messages.");

			fNotification->SetTitle(string.String());
			if (fNotifyMode != B_MAIL_SHOW_STATUS_WINDOW_NEVER)
				fNotification->Send();
			break;
		}

		default:
			BApplication::MessageReceived(msg);
			break;
	}
}
コード例 #10
0
void LeftList::MouseDown(BPoint point)
{
	char temp1[150];
	char temp2[150];
	char temp3[150];
	char temp4[150];
	char temp5[150];
	BMessage* msg = Window()->CurrentMessage();
	uint32 clicks = msg->FindInt32("clicks");
	uint32 button = msg->FindInt32("buttons");


	if ((button == fLastButton) && (clicks > 1))
		fClickCount++;
	else
		fClickCount = 1;

	fLastButton = button;

	if ((button == B_SECONDARY_MOUSE_BUTTON)) {
		int32 itemn = IndexOf(point);
		if (itemn >= 0) {
			BMenuItem* selected;
			BPoint p = point;
			ConvertToScreen(&p);
			Select(itemn);
			selected = fTrackPopUpMenu->Go(p);
			if (selected) {
				int32 selection = CurrentSelection();
				if (!strcmp(selected->Label(), "Move Up")) {
					LeftListItem* item = (LeftListItem*)ItemAt(selection - 1);
					LeftListItem* item2 = (LeftListItem*)ItemAt(selection);
					if ((selection - 1 > 0) && (item->fIsAudio) && (item2->fIsAudio))
						SwapItems(selection, selection - 1);

				} else if (!strcmp(selected->Label(), "Move Down")) {
					LeftListItem* item = (LeftListItem*)ItemAt(selection);
					if ((selection + 1 <= CountItems()) && (item->fIconBitmap == fAudioBitmap))
						SwapItems(selection, selection + 1);

				} else if (!strcmp(selected->Label(), "Play")) {
					LeftListItem* item = (LeftListItem*)ItemAt(selection);
					if (item->fIconBitmap == fAudioBitmap)
						be_roster->Launch(&item->fRef);
				} else if (!strcmp(selected->Label(), "Remove")) {
					int32 result;
					BAlert* MyAlert = new BAlert("BurnItNow", "Are you sure you want to delete this selection", "Yes", "No", NULL, B_WIDTH_AS_USUAL, B_INFO_ALERT);
					MyAlert->SetFeel(B_MODAL_ALL_WINDOW_FEEL);
					result = MyAlert->Go();
					if (result == 0) {
						LeftListItem* item = (LeftListItem*)RemoveItem(itemn);
						if (!item->fIsAudio) {
							VRCD = false;
							ISOFILE = false;
							jpWindow* win = dynamic_cast<jpWindow*>(Window());
							if (win != NULL) {
								win->fMakeDirButton->SetEnabled(false);
								win->fParentDirButton->SetEnabled(false);
								win->fNewVRCDButton->SetEnabled(true);
								win->fAddISOButton->SetEnabled(true);
							}
						}
						if (item != NULL)
							delete item;
					}
				}
			}
			return;
		}
	}
	if ((button == B_PRIMARY_MOUSE_BUTTON) && (fClickCount == 2)) {
		int32 selection = CurrentSelection();
		if (selection >= 0) {
			LeftListItem* item = (LeftListItem*)ItemAt(selection);
			if (item->fIsAudio) {
				sprintf(temp1, "%s", item->fAudioInfo.pretty_name);
				sprintf(temp2, "%d Channels", (int)item->fAudioInfo.channels);
				sprintf(temp3, "%.1f kHz", ((float)item->fAudioInfo.frame_rate / (float)1000));
				sprintf(temp4, "%d bits", (int)item->fAudioInfo.bps * 8);
				sprintf(temp5, "Info on AudioFile");
				jpWindow* win = dynamic_cast<jpWindow*>(Window());
				if (win != NULL)
					win->fRightList->UpdateInfo(temp5, temp1, temp2, temp3, temp4);
			}
			if (item->fIconBitmap == fVRCDBitmap) {
				jpWindow* win = dynamic_cast<jpWindow*>(Window());
				if (win != NULL)
					win->fRightList->UpdateDir();
			}
			if (item->fIconBitmap == fISOBitmap) {
				sprintf(temp1, "Info on ISOFile");
				sprintf(temp2, "%s", item->fName);
				sprintf(temp3, "X Mb");
				jpWindow* win = dynamic_cast<jpWindow*>(Window());
				if (win != NULL)
					win->fRightList->UpdateInfo(temp1, temp2, temp3, NULL, NULL);
			}
		}
		fClickCount = 0;

	} else {
		BListView::MouseDown(point);
	}
}