/*
	BHandler *Target(BLooper **looper) const
	@case 1			this is uninitialized, looper is NULL
	@results		should return NULL.
 */
void TargetTester::TargetTest1()
{
	BMessenger messenger;
	CHK(messenger.Target(NULL) == NULL);
}
/*
	bool IsTargetLocal() const
	@case 1			this is uninitialized
	@results		should return false.
 */
void TargetTester::IsTargetLocalTest1()
{
	BMessenger messenger;
	CHK(messenger.IsTargetLocal() == false);
}
Exemple #3
0
void
NetworkPrefsView::MessageReceived (BMessage * msg)
{
	switch (msg->what)
	{
		case M_NETWORK_DEFAULTS:
			if (fActiveNetwork.HasString ("name"))
				vision_app->SetNetwork (fActiveNetwork.FindString ("name"), &fActiveNetwork);
			fActiveNetwork = vision_app->GetNetwork ("defaults");
			fNetworkMenu->MenuItem ()->SetLabel ("Defaults");
			SetupDefaults (fActiveNetwork);
			fDupeItem->SetEnabled (false);
			fRemoveItem->SetEnabled (false);
			break;

		case M_CHOOSE_NETWORK:
			{
				BMenuItem *item (NULL);
				msg->FindPointer ("source", reinterpret_cast < void **>(&item));
				SaveCurrentNetwork ();
				fActiveNetwork = vision_app->GetNetwork (item->Label ());
				fNetworkMenu->MenuItem ()->SetLabel (item->Label ());
				UpdatePersonalData (fActiveNetwork);
				UpdateNetworkData (fActiveNetwork);
				if (BMessenger (fServerPrefs).IsValid ())
					fServerPrefs->SetNetworkData (&fActiveNetwork);
				fDupeItem->SetEnabled (true);
				fRemoveItem->SetEnabled (true);
			}
			break;

		case M_ADD_NEW_NETWORK:
			{
				if (msg->HasString ("text"))
				{
					fNetPrompt = NULL;
					BString network (msg->FindString ("text"));
					network.RemoveAll (" ");
					BMenu *menu (fNetworkMenu->Menu ());
					for (int32 i = 0; i < menu->CountItems (); i++)
				{
						BMenuItem *item (menu->ItemAt (i));
						if (item && network == item->Label ())
						{
							dynamic_cast < BInvoker * >(item)->Invoke ();
							return;
						}
					}
					BMessage newNet (VIS_NETWORK_DATA);
					newNet.AddString ("name", network.String ());
					vision_app->SetNetwork (network.String (), &newNet);
					BMenuItem *item (new BMenuItem (network.String (), new BMessage (M_CHOOSE_NETWORK)));
					menu->AddItem (item, 0);
					item->SetTarget (this);
					dynamic_cast < BInvoker * >(item)->Invoke ();
			}
				else
				{
					BString promptText = B_TRANSLATE("Network Name");
					promptText += ": ";
					fNetPrompt = new PromptWindow (BPoint (Window ()->Frame ().left + Window ()->Frame ().Width () / 2, Window ()->Frame ().top + Window ()->Frame ().Height () / 2),
						promptText.String(), B_TRANSLATE("Add Network"), NULL, this, new BMessage (M_ADD_NEW_NETWORK), NULL, false);
					fNetPrompt->Show ();
				}
			}
			break;

		case M_REMOVE_CURRENT_NETWORK:
			{
				const char *name (fActiveNetwork.FindString ("name"));
				vision_app->RemoveNetwork (name);
				BMenu *menu (fNetworkMenu->Menu ());
				for (int32 i = 0; i < menu->CountItems (); i++)
				{
					BMenuItem *item (menu->ItemAt (i));
					if (!strcmp (item->Label (), name))
					{
						delete menu->RemoveItem (i);
						fActiveNetwork.MakeEmpty ();
						dynamic_cast < BInvoker * >(menu->ItemAt (0))->Invoke ();
						break;
					}
				}
			}
			break;

		case M_DUPE_CURRENT_NETWORK:
			{
				if (msg->HasString ("text"))
				{
					fDupePrompt = NULL;
					BString network (msg->FindString ("text"));
					network.RemoveAll (" ");
					BMenu *menu (fNetworkMenu->Menu ());
					for (int32 i = 0; i < menu->CountItems (); i++)
					{
						BMenuItem *item (menu->ItemAt (i));
						if (item && network == item->Label ())
						{
							dynamic_cast < BInvoker * >(item)->Invoke ();
							return;
						}
					}
					BMessage newNet = fActiveNetwork;
					newNet.ReplaceString ("name", network.String ());
					vision_app->SetNetwork (network.String (), &newNet);
					BMenuItem *item (new BMenuItem (network.String (), new BMessage (M_CHOOSE_NETWORK)));
					menu->AddItem (item, 0);
					item->SetTarget (this);
					dynamic_cast < BInvoker * >(item)->Invoke ();
				}
				else
				{
					BString promptText = B_TRANSLATE("Network Name");
					promptText += ": ";
					fDupePrompt = new PromptWindow (BPoint (Window ()->Frame ().left + Window ()->Frame ().Width () / 2, Window ()->Frame ().top + Window ()->Frame ().Height () / 2),
						promptText.String(), B_TRANSLATE("Duplicate Current Network"), NULL, this, new BMessage (M_DUPE_CURRENT_NETWORK), NULL, false);
					fDupePrompt->Show ();
				}
			}
			break;

		case M_SERVER_DATA_CHANGED:
			{
				UpdateNetworkData (fActiveNetwork);
			}
			break;

		case M_SERVER_DIALOG:
			{
				BMessenger msgr (fServerPrefs);
				if (msgr.IsValid ())
					fServerPrefs->Activate ();
				else
				{
					fServerPrefs = new NetPrefServerWindow (this);
					fServerPrefs->SetNetworkData (&fActiveNetwork);
					fServerPrefs->Show ();
				}
			}
			break;

		case M_NET_CHECK_LAG:
			{
				bool value = msg->FindInt32 ("be:value");
				if (fActiveNetwork.HasBool ("lagCheck"))
					fActiveNetwork.ReplaceBool ("lagCheck", value);
				else
					fActiveNetwork.AddBool ("lagCheck", value);
			}
			break;

		case M_CONNECT_ON_STARTUP:
			{
				bool value = msg->FindInt32 ("be:value");
				if (fActiveNetwork.HasBool ("connectOnStartup"))
					fActiveNetwork.ReplaceBool ("connectOnStartup", value);
				else
					fActiveNetwork.AddBool ("connectOnStartup", value);
			}
			break;

		case M_USE_NICK_DEFAULTS:
			{
				bool value = msg->FindInt32 ("be:value");
				if (fActiveNetwork.HasBool ("useDefaults"))
					fActiveNetwork.ReplaceBool ("useDefaults", value);
				else
					fActiveNetwork.AddBool ("useDefaults", value);
				UpdatePersonalData (fActiveNetwork);
			}
			break;

		case M_NETPREFS_TEXT_INVOKE:
			{
				if (fActiveNetwork.HasString("autoexec"))
					fActiveNetwork.ReplaceString("autoexec", fTextView->Text());
				else
					fActiveNetwork.AddString("autoexec", fTextView->Text());
			}
			break;

		case M_ADD_NICK:
			if (msg->HasString ("text"))
			{
				fNickPrompt = NULL;
				BString nick (msg->FindString ("text"));
				nick.RemoveAll (" ");
				for (int32 i = 0; i < fListView->CountItems (); i++)
				{
					BStringItem *item ((BStringItem *) fListView->ItemAt (i));
					if (item && nick == item->Text ())
						return;
				}
			fActiveNetwork.AddString ("nick", nick.String ());
			fListView->AddItem (new BStringItem (nick.String ()));
			}
			else
			{
				BString promptString = B_TRANSLATE("Nickname");
				promptString += ": ";
				fNickPrompt = new PromptWindow (BPoint (Window ()->Frame ().left + Window ()->Frame ().Width () / 2, Window ()->Frame ().top + Window ()->Frame ().Height () / 2),
					promptString.String(), B_TRANSLATE("Add Nickname"), NULL, this, new BMessage (M_ADD_NICK), NULL, false);
				fNickPrompt->Show ();
			}
			break;

		case M_REMOVE_NICK:
			{
				int32 current (fListView->CurrentSelection ());
				if (current >= 0)
			{
					delete fListView->RemoveItem (current);
					fActiveNetwork.RemoveData ("nick", current);
				}
			}
			break;

		case M_NICK_UP:
			{
				int32 current (fListView->CurrentSelection ());
				BString nick1, nick2;
				nick1 = fActiveNetwork.FindString ("nick", current);
				nick2 = fActiveNetwork.FindString ("nick", current - 1);
				fListView->SwapItems (current, current - 1);
				fActiveNetwork.ReplaceString ("nick", current - 1, nick1.String ());
				fActiveNetwork.ReplaceString ("nick", current, nick2.String ());
				current = fListView->CurrentSelection ();
				Window ()->DisableUpdates ();
				fListView->DeselectAll ();
				fListView->Select (current);
				Window ()->EnableUpdates ();
			}
			break;

		case M_NICK_DOWN:
			{
				int32 current (fListView->CurrentSelection ());
				BString nick1, nick2;
				nick1 = fActiveNetwork.FindString ("nick", current);
				nick2 = fActiveNetwork.FindString ("nick", current + 1);
				fListView->SwapItems (current, current + 1);
				fActiveNetwork.ReplaceString ("nick", current + 1, nick1.String ());
				fActiveNetwork.ReplaceString ("nick", current, nick2.String ());
				current = fListView->CurrentSelection ();
				Window ()->DisableUpdates ();
				fListView->DeselectAll ();
				fListView->Select (current);
				Window ()->EnableUpdates ();
			}
			break;

		case M_NICK_SELECTED:
			{
				int32 index (msg->FindInt32 ("index"));
				if (index >= 0 && !fNickDefaultsBox->Value ())
				{
					fNickUpButton->SetEnabled (index > 0);
					fNickDnButton->SetEnabled (index != (fListView->CountItems () - 1));
					fNickRemoveButton->SetEnabled (true);
				}
				else
				{
					fNickUpButton->SetEnabled (false);
					fNickDnButton->SetEnabled (false);
					fNickRemoveButton->SetEnabled (false);
				}
			}
			break;

		default:
			BView::MessageReceived (msg);
			break;
	}
}
Exemple #4
0
void
TBarApp::AddTeam(team_id team, uint32 flags, const char* sig, entry_ref* ref)
{
	BAutolock autolock(sSubscriberLock);
	if (!autolock.IsLocked())
		return;

	// have we already seen this team, is this another instance of
	// a known app?
	BarTeamInfo* multiLaunchTeam = NULL;
	int32 teamCount = sBarTeamInfoList.CountItems();
	for (int32 i = 0; i < teamCount; i++) {
		BarTeamInfo* barInfo = (BarTeamInfo*)sBarTeamInfoList.ItemAt(i);
		if (barInfo->teams->HasItem((void*)team))
			return;
		if (strcasecmp(barInfo->sig, sig) == 0)
			multiLaunchTeam = barInfo;
	}

	if (multiLaunchTeam != NULL) {
		multiLaunchTeam->teams->AddItem((void*)team);

		int32 subsCount = sSubscribers.CountItems();
		if (subsCount > 0) {
			BMessage message(kAddTeam);
			message.AddInt32("team", team);
			message.AddString("sig", multiLaunchTeam->sig);

			for (int32 i = 0; i < subsCount; i++)
				((BMessenger*)sSubscribers.ItemAt(i))->SendMessage(&message);
		}
		return;
	}

	BFile file(ref, B_READ_ONLY);
	BAppFileInfo appMime(&file);

	BString name;
	if (!gLocalizedNamePreferred
		|| BLocaleRoster::Default()->GetLocalizedFileName(name, *ref)
			!= B_OK) {
		name = ref->name;
	}

	BarTeamInfo* barInfo = new BarTeamInfo(new BList(), flags, strdup(sig),
		new BBitmap(IconRect(), kIconColorSpace), strdup(ref->name));

	if ((barInfo->flags & B_BACKGROUND_APP) == 0
		&& strcasecmp(barInfo->sig, kDeskbarSignature) != 0) {
		FetchAppIcon(barInfo->sig, barInfo->icon);
	}

	barInfo->teams->AddItem((void*)team);

	sBarTeamInfoList.AddItem(barInfo);

	if (fSettings.expandNewTeams)
		fBarView->AddExpandedItem(sig);

	int32 subsCount = sSubscribers.CountItems();
	if (subsCount > 0) {
		for (int32 i = 0; i < subsCount; i++) {
			BMessenger* messenger = (BMessenger*)sSubscribers.ItemAt(i);
			BMessage message(B_SOME_APP_LAUNCHED);

			BList* tList = new BList(*(barInfo->teams));
			message.AddPointer("teams", tList);

			BBitmap* icon = new BBitmap(barInfo->icon);
			ASSERT(icon);

			message.AddPointer("icon", icon);

			message.AddInt32("flags", static_cast<int32>(barInfo->flags));
			message.AddString("name", barInfo->name);
			message.AddString("sig", barInfo->sig);

			messenger->SendMessage(&message);
		}
	}
}
Exemple #5
0
status_t
TeamDebugHandler::_HandlerThread()
{
	TRACE(("debug_server: TeamDebugHandler::_HandlerThread(): team %" B_PRId32
		"\n", fTeam));

	// get initial message
	TRACE(("debug_server: TeamDebugHandler::_HandlerThread(): team %" B_PRId32
		": getting message...\n", fTeam));

	DebugMessage *message;
	status_t error = _PopMessage(message);
	int32 debugAction = kActionKillTeam;
	if (error == B_OK) {
		// handle the message
		debugAction = _HandleMessage(message);
		delete message;
	} else {
		debug_printf("TeamDebugHandler::_HandlerThread(): Failed to pop "
			"initial message: %s", strerror(error));
	}

	bool isGuiServer = _IsGUIServer();

	// kill the team or hand it over to the debugger
	thread_id debuggerThread = -1;
	if (debugAction == kActionKillTeam) {
		// The team shall be killed. Since that is also the handling in case
		// an error occurs while handing over the team to the debugger, we do
		// nothing here.
	} else if ((debuggerThread = _EnterDebugger(
			debugAction == kActionSaveReportTeam)) >= 0) {
		// wait for the "handed over" or a "team deleted" message
		bool terminate = false;
		do {
			error = _PopMessage(message);
			if (error != B_OK) {
				debug_printf("TeamDebugHandler::_HandlerThread(): Failed to "
					"pop message: %s", strerror(error));
				debugAction = kActionKillTeam;
				break;
			}

			if (message->Code() == B_DEBUGGER_MESSAGE_HANDED_OVER) {
				// The team has successfully been handed over to the debugger.
				// Nothing to do.
				terminate = true;
			} else if (message->Code() == B_DEBUGGER_MESSAGE_TEAM_DELETED) {
				// The team died. Nothing to do.
				terminate = true;
			} else {
				// Some message we can ignore. The debugger will take care of
				// it.

				// check whether the debugger thread still lives
				thread_info threadInfo;
				if (get_thread_info(debuggerThread, &threadInfo) != B_OK) {
					// the debugger is gone
					debug_printf("debug_server: The debugger for team %"
						B_PRId32 " seems to be gone.", fTeam);

					debugAction = kActionKillTeam;
					terminate = true;
				}
			}

			delete message;
		} while (!terminate);
	} else
		debugAction = kActionKillTeam;

	if (debugAction == kActionKillTeam) {
		// kill the team
		_KillTeam();
	}

	// remove this handler from the roster and delete it
	TeamDebugHandlerRoster::Default()->RemoveHandler(fTeam);

	if (isGuiServer) {
		// wait till debugging is done
		status_t dummy;
		wait_for_thread(debuggerThread, &dummy);

		// find the registrar port
		port_id rosterPort = find_port(BPrivate::get_roster_port_name());
		port_info info;
		BMessenger messenger;
		if (rosterPort >= 0 && get_port_info(rosterPort, &info) == B_OK) {
			BMessenger::Private(messenger).SetTo(info.team, rosterPort,
				B_PREFERRED_TOKEN);
		}
		messenger.SendMessage(kMsgRestartAppServer);
	}

	delete this;

	return B_OK;
}
Exemple #6
0
void
NotificationWindow::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case B_NODE_MONITOR:
		{
			_LoadSettings();
			break;
		}
		case B_COUNT_PROPERTIES:
		{
			BMessage reply(B_REPLY);
			BMessage specifier;
			const char* property = NULL;
			bool messageOkay = true;

			if (message->FindMessage("specifiers", 0, &specifier) != B_OK)
				messageOkay = false;
			if (specifier.FindString("property", &property) != B_OK)
				messageOkay = false;
			if (strcmp(property, "message") != 0)
				messageOkay = false;

			if (messageOkay)
				reply.AddInt32("result", fViews.size());
			else {
				reply.what = B_MESSAGE_NOT_UNDERSTOOD;
				reply.AddInt32("error", B_ERROR);
			}

			message->SendReply(&reply);
			break;
		}
		case B_CREATE_PROPERTY:
		case kNotificationMessage:
		{
			BMessage reply(B_REPLY);
			BNotification* notification = new BNotification(message);

			if (notification->InitCheck() == B_OK) {
				bigtime_t timeout;
				if (message->FindInt64("timeout", &timeout) != B_OK)
					timeout = -1;
				BMessenger messenger = message->ReturnAddress();
				app_info info;

				if (messenger.IsValid())
					be_roster->GetRunningAppInfo(messenger.Team(), &info);
				else
					be_roster->GetAppInfo("application/x-vnd.Be-SHEL", &info);

				bool allow = false;
				appfilter_t::iterator it = fAppFilters.find(info.signature);

				if (it == fAppFilters.end()) {
					AppUsage* appUsage = new AppUsage(notification->Group(),
						true);

					appUsage->Allowed(notification->Title(),
							notification->Type());
					fAppFilters[info.signature] = appUsage;
					allow = true;
				} else {
					allow = it->second->Allowed(notification->Title(),
						notification->Type());
				}

				if (allow) {
					BString groupName(notification->Group());
					appview_t::iterator aIt = fAppViews.find(groupName);
					AppGroupView* group = NULL;
					if (aIt == fAppViews.end()) {
						group = new AppGroupView(this,
							groupName == "" ? NULL : groupName.String());
						fAppViews[groupName] = group;
						GetLayout()->AddView(group);
					} else
						group = aIt->second;

					NotificationView* view = new NotificationView(this,
						notification, timeout);

					group->AddInfo(view);

					_ShowHide();

					reply.AddInt32("error", B_OK);
				} else
					reply.AddInt32("error", B_NOT_ALLOWED);
			} else {
				reply.what = B_MESSAGE_NOT_UNDERSTOOD;
				reply.AddInt32("error", B_ERROR);
			}

			message->SendReply(&reply);
			break;
		}
		case kRemoveView:
		{
			NotificationView* view = NULL;
			if (message->FindPointer("view", (void**)&view) != B_OK)
				return;

			views_t::iterator it = find(fViews.begin(), fViews.end(), view);

			if (it != fViews.end())
				fViews.erase(it);
			break;
		}
		case kRemoveGroupView:
		{
			AppGroupView* view = NULL;
			if (message->FindPointer("view", (void**)&view) != B_OK)
				return;

			// It's possible that between sending this message, and us receiving
			// it, the view has become used again, in which case we shouldn't
			// delete it.
			if (view->HasChildren())
				return;

			// this shouldn't happen
			if (fAppViews.erase(view->Group()) < 1)
				break;

			view->RemoveSelf();
			delete view;

			_ShowHide();
			break;
		}
		default:
			BWindow::MessageReceived(message);
	}
}
/*!
	\brief Tracker add-on entry
*/
extern "C" void
process_refs(entry_ref dir, BMessage* refs, void* /*reserved*/)
{
	status_t status;
	BAlert *alert;
	BMessenger msgr;
	BPoseView *view = NULL;
	BMessage poseViewBackup;
	BMessage poseViewColumnBackup;
	uint32 poseViewModeBackup;
	BString windowTitleBackup;

	refs->PrintToStream();
	
	status = refs->FindMessenger("TrackerViewToken", &msgr);
	if (status < B_OK) {
		Error(view, status);
		return;
	}

	status = B_ERROR;
	if (!msgr.LockTarget()) {
		Error(view, status);
		return;
	}

	status = B_BAD_HANDLER;
	view = dynamic_cast<BPoseView *>(msgr.Target(NULL));
	if (!view) {
		Error(view, status);
		return;
	}
	if (dynamic_cast<BWindow *>(view->Looper()) == NULL) {
		Error(view, status, true);
		return;
	}

	windowTitleBackup = view->Window()->Title();

	view->SaveColumnState(poseViewColumnBackup);
	view->SaveState(poseViewBackup);
	view->SetDragEnabled(false);
	view->SetSelectionRectEnabled(false);
	view->SetPoseEditing(false);
	poseViewModeBackup = view->ViewMode();
	

	view->SetViewMode(kIconMode);

	view->ShowBarberPole();


	view->UnlockLooper();



	alert = new BAlert("Error", "IconVader:\nClick on the icons to get points."
		"\nAvoid symlinks!", "OK");
	alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
	alert->Go();


	int32 score = 0;
	int32 count = 300;
	while (count--) {
		status = B_ERROR;
		if (!msgr.LockTarget()) {
			Error(view, status);
			return;
		}

		BPose *pose;
		for (int32 i = 0; (pose = view->PoseAtIndex(i)); i++) {
			if (pose->IsSelected()) {
				if (pose->TargetModel()->IsFile())
					score++;
				if (pose->TargetModel()->IsDirectory())
					score+=2;
				if (pose->TargetModel()->IsSymLink())
					score-=10;
				pose->Select(false);
			}
#ifdef __HAIKU__
			BPoint location = pose->Location(view);
#else
			BPoint location = pose->Location();
#endif
			location.x += ((rand() % 20) - 10);
			location.y += ((rand() % 20) - 10);
#ifdef __HAIKU__
			pose->SetLocation(location, view);
#else
			pose->SetLocation(location);
#endif
		}

		view->CheckPoseVisibility();

		view->Invalidate();

		BString str("Score: ");
		str << score;
		view->Window()->SetTitle(str.String());
		
		view->UnlockLooper();
		snooze(100000);
	}

	BString scoreStr("You scored ");
	scoreStr << score << " points!";
	alert = new BAlert("Error", scoreStr.String(), "Cool!");
	alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
	alert->Go();


	status = B_ERROR;
	if (!msgr.LockTarget()) {
		Error(view, status);
		return;
	}

	/*
	status = B_BAD_HANDLER;
	view = dynamic_cast<BPoseView *>(msgr.Target(NULL));
	if (!view)
		goto err1;
	*/

	view->HideBarberPole();
	view->SetViewMode(poseViewModeBackup);
	view->RestoreState(poseViewBackup);
	view->RestoreColumnState(poseViewColumnBackup);

	view->Window()->SetTitle(windowTitleBackup.String());
	
/*
	BMessage('_RRC') {
        TrackerViewToken = BMessenger(port=32004, team=591, target=direct:0x131)
} */


	//be_roster->Launch("application/x-vnd.haiku-filetypes", refs);
	
	view->UnlockLooper();
	return;

}
PeepsWindow::PeepsWindow(BMessenger target)
	: BWindow(BRect(50,50,600,470), "Mr. Peeps!", B_DOCUMENT_WINDOW, B_NOT_ZOOMABLE | B_NOT_H_RESIZABLE)
{
	float wmin,wmax,hmin,hmax;
	
	GetSizeLimits(&wmin,&wmax,&hmin,&hmax);
	wmin=500;
	hmin=400;
	
	SetSizeLimits(wmin,wmax,hmin,hmax);
		
	ReadLocaleSettings();
	if(fLocale.CountChars()>0)
	{
		locale_roster->SetLocale(fLocale.String());
		gCurrentLocale=locale_roster->GetLocale();
	}
	
	BRect r(Bounds());
	BMessage *msg;
	
	r.bottom=20;
	BMenuBar *mb=new BMenuBar(r,"menubar");
	AddChild(mb);
	
	fPeopleMenu=new BMenu(TRANSLATE("Person"));
	fPeopleMenu->AddItem(new BMenuItem(TRANSLATE("New"),new BMessage(M_ADD_PERSON),'N'));
	fPeopleMenu->AddSeparatorItem();
	fPeopleMenu->AddItem(new BMenuItem(TRANSLATE("Previous"),new BMessage(M_PREV_ITEM),B_UP_ARROW));
	fPeopleMenu->AddItem(new BMenuItem(TRANSLATE("Next"),new BMessage(M_NEXT_ITEM),B_DOWN_ARROW));
	fPeopleMenu->AddSeparatorItem();
	
	fActionsMenu=new BMenu(TRANSLATE("Actions"));
		
	// Submenu for sending e-mail
	BMenu *emailmenu=new BMenu(TRANSLATE("Send E-Mail to"));
	
	fEmailPersonalItem=new BMenuItem(TRANSLATE("Personal Address"),new BMessage(M_SEND_PERSONAL_EMAIL));
	emailmenu->AddItem(fEmailPersonalItem);
	
	fEmailWorkItem=new BMenuItem(TRANSLATE("Work Address"),new BMessage(M_SEND_WORK_EMAIL));
	emailmenu->AddItem(fEmailWorkItem);
	
	fEmailAltItem=new BMenuItem(TRANSLATE("Alternate Address"),new BMessage(M_SEND_ALT_EMAIL));
	emailmenu->AddItem(fEmailAltItem);
	fActionsMenu->AddItem(emailmenu);
	
	// Submenu for sending e-mail
	BMenu *browsermenu=new BMenu(TRANSLATE("Go to Web Page"));
	
	fBrowseHomeItem=new BMenuItem(TRANSLATE("Personal Web Address"),new BMessage(M_BROWSE_WWW_HOME));
	browsermenu->AddItem(fBrowseHomeItem);
	
	fBrowseWorkItem=new BMenuItem(TRANSLATE("Work Web Address"),new BMessage(M_BROWSE_WWW_WORK));
	browsermenu->AddItem(fBrowseWorkItem);
	
	fBrowseAltItem=new BMenuItem(TRANSLATE("Alternate Web Address"),new BMessage(M_BROWSE_WWW_ALT));
	browsermenu->AddItem(fBrowseAltItem);
	fActionsMenu->AddItem(browsermenu);
	
	fActionsMenu->AddSeparatorItem();
	fPastePhotoItem=new BMenuItem(TRANSLATE("Paste Photo from Clipboard"),new BMessage(M_PASTE_IMAGE));
	fActionsMenu->AddItem(fPastePhotoItem);
	fRemovePhotoItem=new BMenuItem(TRANSLATE("Remove Photo"),new BMessage(M_REMOVE_IMAGE));
	fActionsMenu->AddItem(fRemovePhotoItem);
	fActionsMenu->AddSeparatorItem();
	fActionsMenu->AddItem(new BMenuItem(TRANSLATE("Move To Trash"),new BMessage(M_DELETE_PERSON),'T'));
	fPeopleMenu->AddItem(fActionsMenu);
	fActionsMenu->SetEnabled(false);
	
	
	fPeopleMenu->AddSeparatorItem();
	fPeopleMenu->AddItem(new BMenuItem(TRANSLATE("About..."),new BMessage(B_ABOUT_REQUESTED)));
	mb->AddItem(fPeopleMenu);

	fEditMenu=new BMenu(TRANSLATE("Edit"));
	fEditMenu->AddItem(new BMenuItem(TRANSLATE("Undo"),new BMessage(M_UNDO),'Z'));
	fEditMenu->AddSeparatorItem();
	fEditMenu->AddItem(new BMenuItem(TRANSLATE("Cut"),new BMessage(M_CUT),'X'));
	fEditMenu->AddItem(new BMenuItem(TRANSLATE("Copy"),new BMessage(M_COPY),'C'));
	fEditMenu->AddItem(new BMenuItem(TRANSLATE("Paste"),new BMessage(M_PASTE),'V'));
	mb->AddItem(fEditMenu);
	fEditMenu->SetEnabled(false);
	
	fTabMenu=new BMenu(TRANSLATE("Tab"));
	fTabMenu->AddItem(new BMenuItem(TRANSLATE("Main"),new BMessage(M_TAB_1),'1'));
	fTabMenu->AddItem(new BMenuItem(TRANSLATE("Personal"),new BMessage(M_TAB_2),'2'));
	fTabMenu->AddItem(new BMenuItem(TRANSLATE("Work"),new BMessage(M_TAB_3),'3'));
	fTabMenu->AddItem(new BMenuItem(TRANSLATE("Instant Message"),new BMessage(M_TAB_4),'4'));
	fTabMenu->AddItem(new BMenuItem(TRANSLATE("Notes"),new BMessage(M_TAB_5),'5'));
	mb->AddItem(fTabMenu);
	fTabMenu->SetEnabled(false);
	
	BMessage *menumsg;
	BEntry toolentry;
	
	// Note that I don't just simply have a way to iterate over whatever's in a folder
	// because I want to control what tools are officially supported by Mr. Peeps!
	// It's not that I don't want anyone helping -- I just want quality control with
	// tool usability.
	
	fToolMenu=new BMenu(TRANSLATE("Tools"));
	
	toolentry.SetTo("/boot/home/config/settings/MrPeeps/PeopleMover");
	if(toolentry.Exists())
	{
		menumsg=new BMessage(M_RUN_TOOL);
		menumsg->AddString("signature","application/x-vnd.wgp-PeopleMover");
		fToolPeopleMover=new BMenuItem(TRANSLATE("People Mover"),menumsg);
		fToolMenu->AddItem(fToolPeopleMover);
	}
	else
		fToolPeopleMover=NULL;
	
	toolentry.SetTo("/boot/home/config/settings/MrPeeps/PersonAtAGlance");
	if(toolentry.Exists())
	{
		menumsg=new BMessage(M_RUN_TOOL);
		menumsg->AddString("signature","application/x-vnd.wgp-PersonAtAGlance");
		fToolPeopleAtAGlance=new BMenuItem(TRANSLATE("Person at a Glance"),menumsg);
		fToolPeopleAtAGlance->SetEnabled(false);
		fToolMenu->AddItem(fToolPeopleAtAGlance);
	}
	else
		fToolPeopleAtAGlance=NULL;
	
	toolentry.SetTo("/boot/home/config/settings/MrPeeps/VCardExport");
	if(toolentry.Exists())
	{
		menumsg=new BMessage(M_RUN_TOOL);
		menumsg->AddString("signature","application/x-vnd.wgp-VCardExport");
		fToolVCardExport=new BMenuItem(TRANSLATE("Export Person to VCard"),menumsg);
		fToolVCardExport->SetEnabled(false);
		fToolMenu->AddItem(fToolVCardExport);
	}
	else
		fToolVCardExport=NULL;
	
	if(fToolMenu->CountItems()>0)
	{
		// PeopleMover does not require a selection, so if it is installed, allow the
		// user to select it.
		if(!fToolPeopleMover)
			fToolMenu->SetEnabled(false);
		mb->AddItem(fToolMenu);
	}
	else
	{
		delete fToolMenu;
		fToolMenu=NULL;
	}
	
	if(locale_roster->CountLocales()>1)
	{
		fLanguageMenu=new BMenu(TRANSLATE("Language"));
		fLanguageMenu->SetRadioMode(true);
		for(int32 i=0; i<locale_roster->CountLocales(); i++)
		{
			Locale *locale=locale_roster->LocaleAt(i);
			BMessage *langmsg=new BMessage(M_SET_LANGUAGE);
			langmsg->AddInt32("index",i);
			fLanguageMenu->AddItem(new BMenuItem(locale->Name(),langmsg));
		}
		mb->AddItem(fLanguageMenu);
		
		BMenuItem *markeditem=fLanguageMenu->FindItem(fLocale.String());
		if(markeditem)
			markeditem->SetMarked(true);
	}
	else
		fLanguageMenu=NULL;
	
	// set up left frame
	r.top+=mb->Bounds().bottom+1;
	r.bottom=Bounds().bottom;
	r.right=200;
	left_view=new BView(r, "left_view", B_FOLLOW_TOP_BOTTOM, B_WILL_DRAW);
	AddChild(left_view);
	
	// Check to see that all of the tabs will fit
	float tabwidth=left_view->StringWidth(TRANSLATE("Main"))+
		left_view->StringWidth(TRANSLATE("Personal"))+
		left_view->StringWidth(TRANSLATE("Work"))+
		left_view->StringWidth(TRANSLATE("Instant Message"))+
		left_view->StringWidth(TRANSLATE("Notes"))+120;
	
	r.left=201;

	if(tabwidth+r.left>Bounds().right)
		ResizeTo(tabwidth+r.left, Bounds().Height());
	
	r.right=Bounds().right;
	
	fIntroView=new IntroView(r);
	AddChild(fIntroView);
	
	
	dataview=new DataView(fIntroView->Bounds());
	fIntroView->AddChild(dataview);
	dataview->Hide();
	
	
	// create list for left frame
	BRect tmp_rect=left_view->Bounds();
	tmp_rect.right -= B_V_SCROLL_BAR_WIDTH;
	fPeopleList=new PeopleList(tmp_rect, "fPeopleList",dataview);
	
	// put scrolled list in left_view
	BScrollView *my_scroll=new BScrollView("scroll_people", fPeopleList,
			B_FOLLOW_TOP_BOTTOM, 0, false, true);
	left_view->AddChild(my_scroll);


	// open directory of people
	BDirectory people_dir(PEOPLE_FOLDER);
	
	msg=new BMessage(M_SET_STATUS);
	int32 refcount=people_dir.CountEntries();
	msg->AddInt32("refcount",refcount);
	target.SendMessage(msg);
	
	if(refcount==0)
		fIntroView->SetNoPeopleMsg(true);
	
	// our variables for instantiation and garbage collection later
	entry_ref tmp_ref;
	BFile tmp_file;
	BString filename;
		
	while (people_dir.GetNextRef(&tmp_ref)==B_OK)
	{
		// variables for use here
		tmp_file.SetTo(&tmp_ref, B_READ_WRITE);
		
		if(tmp_file.ReadAttrString(PERSON_NAME,&filename)==B_OK)
			AddPerson(tmp_ref, false);
		
		target.SendMessage(new BMessage(M_UPDATE_STATUS));
	}

	SortList();
	fPeopleList->MakeFocus(true);

	node_ref nref;
	people_dir.GetNodeRef(&nref);
	watch_node(&nref, B_WATCH_NAME | B_WATCH_ATTR | B_WATCH_DIRECTORY,this);
}
//--------------------------------------------------------------------
void PrefWindow::MessageReceived(BMessage *message)
{
	int32 lang = ENGLISH;
	BMenuItem* item;
	
	switch ( message->what )
	{
		case MSG_PREF_COLOR: {
			rgb_color color = colSelector->ValueAsColor();
			BMessage* msg = new BMessage(MSG_UPDATE_VIEW_COLOR);
			msg->AddData("color", B_RGB_COLOR_TYPE, &color, sizeof(rgb_color));
					
			BMessenger *msng = new BMessenger(mainWin);
			msng->SendMessage(msg);			
			delete msng;
			}
			break;
			
		case MSG_PREF_OK:
			((InterApp*)be_app)->prefs->SetInfobarColor(colSelector->Value());

			if (radFollow->Value() != 0)
				((InterApp*)be_app)->prefs->SetMouseMode(PIC_FOLLOW_MOUSE);
			else
				((InterApp*)be_app)->prefs->SetMouseMode(PIC_FLEE_MOUSE);

			item = languageMenu->Menu()->FindMarked();
			if (item != NULL) {
				if (strstr(item->Label(), "[EN]")) {
					lang = ENGLISH;
				} else if (strstr(item->Label(), "[FR]")) {
					lang = FRENCH;
				} else if (strstr(item->Label(), "[RU]")) {
					lang = RUSSIAN;
				} else if (strstr(item->Label(), "[BR]")) {
					lang = PORTUGUES;
				} else if (strstr(item->Label(), "[IT]")) {
					lang = ITALIAN;
				} else if (strstr(item->Label(), "[ES]")) {
					lang = SPANISH;
				} else if (strstr(item->Label(), "[EU]")) {
					lang = BASQUE;
				} else if (strstr(item->Label(), "[DE]")) {
					lang = GERMAN;
				}
			}
			
			if (lang != ((InterApp*)be_app)->prefs->GetLanguage()) {
				((InterApp*)be_app)->prefs->SetLanguage(lang);
					                               
				BAlert *theAlert = new BAlert("", StringsRsrc[STR_LANG_CHANGED_WARNING],
				                              StringsRsrc[STR_OK]);
				theAlert->Go();
			}

			SetAndWriteAttributes();
			Hide();
			break;

		case MSG_PREF_CANCEL: {
			// restore color
			rgb_color color = ((InterApp*)be_app)->prefs->GetInfobarColor();
			BMessage* msg = new BMessage(MSG_UPDATE_VIEW_COLOR);
			msg->AddData("color", B_RGB_COLOR_TYPE, &color, sizeof(rgb_color));
					
			BMessenger *msng = new BMessenger(mainWin);
			msng->SendMessage(msg);			
			delete msng;
			}
			Hide();
			break;

		default:
			BWindow::MessageReceived(message);
			break;
	}
}
Exemple #10
0
status_t
PrintServerMessenger::GetPrintServerMessenger(BMessenger& messenger)
{
	messenger = BMessenger(PSRV_SIGNATURE_TYPE);
	return messenger.IsValid() ? B_OK : B_ERROR;
}
Exemple #11
0
void Win::MessageReceived(BMessage *msg) {
	switch(msg->what) {
		case B_ABOUT_REQUESTED: {
			be_app_messenger.SendMessage(B_ABOUT_REQUESTED);
		}break;
		case B_QUIT_REQUESTED: {
			PostMessage(B_QUIT_REQUESTED);
		}break;
		case PlugInLoaded: {
//			printf("WIN: PlugInLoaded\n");		
			protocol_plugin *pobj=NULL;
//			msg->PrintToStream();
			msg->FindPointer("plugin",(void**)&pobj);
//			printf("pobj: %p\n",pobj);
			if (pobj!=NULL) {
//				printf("Window: plugin loaded %c%c%c%c\n",(int)pobj->PlugID()>>24,(int)pobj->PlugID()>>16,(int)pobj->PlugID()>>8,(int)pobj->PlugID());
				pobj->Window=this;
				pobj->AddMenuItems(optionsmenu);
			} else {
				;//printf("Win: pobj was null\n");
				
			}
			
		}break;
		case B_MOUSE_WHEEL_CHANGED :
		{
			//cout << "B_MOUSE_WHEEL_CHANGED" << endl;
			
			// need to do the scrolling of the urlpopup here
			// as the urlpopupwindow never gets focus and thus
			// never get the mouse wheel messages
			if( urlpopupwindow != NULL )
			{
				if( urlpopupwindow->vscroll != NULL )
				{
					float value = msg->FindFloat( "be:wheel_delta_y" );
					value *= 10;
					
					urlpopupwindow->Lock();
					urlpopupwindow->urlpopupview->ulv->ScrollBy( 0, value );
					urlpopupwindow->Unlock();
				}
			}
			// i dunno where the scroll-recognition of the rendered site shall
			// happen.. if here, then it should go into here later :D
			
		}break;
		case BUTTON_BACK :
		{
//			printf( "WIN: BUTTON_BACK\n" );
			
			const char* previous = NULL;
			previous = ( ( ThemisTab* )tabview->TabAt( tabview->Selection() ) )->GetHistory()->GetPreviousEntry();
			if( previous != NULL )
			{
//				printf( "previous != NULL [ %s ]\n", previous );
				BMessage* backmsg = new BMessage( URL_OPEN );
				backmsg->AddString( "url_to_open", previous );
				backmsg->AddBool( "no_history_add", true );
				BMessenger* msgr = new BMessenger( this );
				msgr->SendMessage( backmsg );
				delete backmsg;
				delete msgr;
			}
			
			break;
		};
		case BUTTON_FORWARD :
		{
//			printf( "WIN: BUTTON_FORWARD\n" );
			
			const char* next = NULL;
			next = ( ( ThemisTab* )tabview->TabAt( tabview->Selection() ) )->GetHistory()->GetNextEntry();
			if( next != NULL )
			{
//				printf( "next != NULL [ %s ]\n", next );
				BMessage* fwdmsg = new BMessage( URL_OPEN );
				fwdmsg->AddString( "url_to_open", next );
				fwdmsg->AddBool( "no_history_add", true );
				BMessenger* msgr = new BMessenger( this );
				msgr->SendMessage( fwdmsg );
				delete fwdmsg;
				delete msgr;
			}
			else
			{
				tabview->SetNavButtonsByTabHistory();	// needed to disable the fwd button
			}
						
			break;
		}
		case BUTTON_STOP :
		{
			break;
		}
		case BUTTON_HOME :
		{
//			printf( "WIN: BUTTON_HOME\n" );
			
			BString homepage;
			AppSettings->FindString( kPrefsHomePage, &homepage );
			
			BMessage* homemsg = new BMessage( URL_OPEN );
			homemsg->AddString( "url_to_open", homepage.String() );
			BMessenger* msgr = new BMessenger( this );
			msgr->SendMessage( homemsg );
			delete homemsg;
			delete msgr;
			
			break;
		}
		case CLOSE_OTHER_TABS :
		{
			// this function is used for the tab-pop-up-menu function
			// "Close other Tabs" and also for the closetabview_button
//			cout << "WIN: CLOSE_OTHER_TABS" << endl;
			
			Lock();
			
			// if the newtab button is disabled, enable it again
			navview->buttons[4]->SetMode( 0 );
						
			uint32 current_tab = 0;
			uint32 count = tabview->CountTabs();
			
			if( msg->HasInt32( "tabindex" ) )
				current_tab = msg->FindInt32( "tabindex" );
			else
				current_tab = tabview->Selection();
			
			while( count > 1 )
			{
				if( count - 1 > current_tab )
				{
					tabview->RemoveTab( count - 1 );
				}
				else
				{
					current_tab = current_tab - 1;
					tabview->RemoveTab( current_tab );
				}
				
				tabview->DynamicTabs( false );
				
				count = tabview->CountTabs();
			}
			
			// used by the closetabview button
			if( msg->HasBool( "close_last_tab" ) )
				if( msg->FindBool( "close_last_tab" ) == true )
					tabview->SetFakeSingleView();
			
			Unlock();
			
			
		}break;
		case CLOSE_URLPOPUP :
		{
//			cout << "WIN: CLOSE_URLPOPUP" << endl;
			if( urlpopupwindow )
			{
				urlpopupwindow->Lock();
				urlpopupwindow->Quit();
				urlpopupwindow = NULL;
			}			
				
		}break;
		case RE_INIT_TABHISTORY :
		{
			ReInitTabHistory();
			break;
		}
		case TAB_ADD :
		{
//			cout << "WIN: TAB_ADD received" << endl;
			
			// dissallow adding of new tabs, if they wouldnt fit in the
			// window anymore, and disable newtab button
			if( tabview->tab_width <= 30 )
			{
				// calculate if still one tab would fit and not cover
				// the closetabview button partially
				float width = ( tabview->CountTabs() + 1 ) * 25;
				
				if( Bounds().right - width <= 22 )
				{
					// disable the newtab button
					navview->buttons[4]->SetMode( 3);
					break;
				}
				// if we won't cover the button, go on...
			}
						
			// if the prefs are not set to sth like "open new tabs hidden"
			// we pass hidden = false to AddNewTab
			// this selects the last tab ( the new one )
			bool hidden = true;
			AppSettings->FindBool( "OpenTabsInBackground", &hidden );
			// OPTION+T shortcut for new tab should open tabs non hidden
			bool force_non_hidden = false;
			msg->FindBool( "force_non_hidden", &force_non_hidden );
			if( force_non_hidden == true )
				hidden = false;
			AddNewTab( hidden );
			
			if( msg->HasString( "url_to_open" ) )
			{
				BMessage* urlopenmsg = new BMessage( URL_OPEN );
				urlopenmsg->AddString( "url_to_open", msg->FindString( "url_to_open" ) );
				urlopenmsg->AddInt32( "tab_to_open_in", tabview->CountTabs() - 1 );
				urlopenmsg->AddBool( "hidden", hidden );
				
				BMessenger* target = new BMessenger( this );
				target->SendMessage( urlopenmsg );
				
				delete urlopenmsg;
				delete target;				
			}				
			break;
		}
		case BUTTON_RELOAD :
		case URL_OPEN :
		{
//			if( msg->what == URL_OPEN )
//				printf( "WIN: URL_OPEN\n" );
//			else
//				printf( "WIN: BUTTON_RELOAD\n" );
			
			// close urlpopup if needed
			if( urlpopupwindow  )
			{	
				urlpopupwindow->Lock();
				urlpopupwindow->Quit();
				urlpopupwindow = NULL;
			}			
						
			// get the url
			BString url;
			if( msg->HasString( "url_to_open" ) )
				url = msg->FindString( "url_to_open" );
			else
				url = navview->urlview->Text();
			
//			cout << "  requested url: " << url.String() << endl;
			
			// stop, if there is no url, or about:blank
			if( url.Length() == 0 )
				break;
			if( strcmp( url.String(), kAboutBlankPage ) == 0 )
				break;
			
			uint32 selection = tabview->Selection();
			int32 site_id = ( ( App* )be_app )->GetNewID();
						
			if( msg->HasInt32( "tab_to_open_in" ) )
			{
				int32 tab_index = msg->FindInt32( "tab_to_open_in" );
				
				( ( ThemisTab* )tabview->TabAt( tab_index ) )->SetSiteID( site_id );
				
				// add history entry for tab
				if( msg->HasBool( "no_history_add" ) == false )
					( ( ThemisTab* )tabview->TabAt( tab_index ) )->GetHistory()->AddEntry( url.String() );
			}
			else
			{
				( ( ThemisTab* )tabview->TabAt( selection ) )->SetSiteID( site_id );
				
				// add history entry for tab
				if( msg->HasBool( "no_history_add" ) == false )
					( ( ThemisTab* )tabview->TabAt( selection ) )->GetHistory()->AddEntry( url.String() );
			}
			
			/* add url to global history
			 * ( You ask, why I am also adding the url on RELOAD, and not only on URL_OPEN?
			 *   Simple. Imagine a browser being open for longer then GlobalHistoryDepthInDays.
			 *   The url would be deleted after this period of days. If the user would then reload
			 *   the page, it would not be saved in the history. If he closes the browser, his url
			 *   would be lost. Ok, this is somewhat unlikely, but could happen. ) 
			*/
			( ( App* )be_app )->GetGlobalHistory()->AddEntry( url.String() );
			
			/* get this out of here */
			
//			char *usepass=NULL;
//			char *workurl=NULL;
//			BString urlS=url.String();
//			int len=strlen(url.String());
//			char *url_=new char[len+1];
//			workurl=new char[len+1];
//			memset(url_,0,len+1);
//			memset(workurl,0,len+1);
//			strcpy(url_,url.String());
//			strcpy(workurl,url_);
//			protocol=HTTPPlugin;
//			urlS=url;
//			
//			if (urlS.Length()>0) {
//				int32 pos=urlS.FindFirst("://");
//				int32 atpos=urlS.FindFirst('@');
//				int32 firstslash=urlS.FindFirst('/',7);
//				printf("pos: %ld\tat: %ld\tfs: %ld\n",pos,atpos,firstslash);
//				
//				if (atpos>0) {
//					int32 secondat=urlS.FindFirst('@',atpos+1);
//					if (((secondat!=B_ERROR) && (firstslash!=B_ERROR) && (secondat<firstslash)) 
//						||  ((firstslash==B_ERROR) && (secondat!=B_ERROR))) {
//							
//						atpos=secondat;
//					}			
//					printf("second at: %ld\n",secondat);
//					if (atpos<firstslash) {
//						if (pos!=B_ERROR) {
//							int32 plen=atpos-(pos+3);
//							usepass=new char[plen+1];
//							memset(usepass,0,plen+1);
//							urlS.MoveInto(usepass,pos+3,plen);
//							printf("usepass: %s\tlen: %ld\n",usepass,plen);
//							
//						} else {
//							usepass=new char[atpos+1];
//							memset(usepass,0,atpos+1);
//							urlS.MoveInto(usepass,0,atpos);
//							printf("usepass: %s\tlen: %ld\n",usepass,atpos);
//							
//						}
//						urlS.RemoveFirst("@");
//						
//					} else {
//						if (firstslash==B_ERROR) {
//							usepass=new char[atpos+1];
//							memset(usepass,0,atpos+1);
//							urlS.MoveInto(usepass,0,atpos);
//							urlS.RemoveFirst("@");
//						}
//					}
//				}
//				
//				printf("urlS: %s\n",urlS.String());
//				if (pos!=B_ERROR) {
//					char *protostr=new char[pos+1];
//					memset(protostr,0,pos+1);
//					strncpy(protostr,url_,pos);
//					for (int i=0; i<pos;i++)
//						protostr[i]=tolower(protostr[i]);
//					protocol=strtoval(protostr);
//					delete protostr;
//				}
//			}
//			delete url_;
//			ProtocolPlugClass *pobj=(ProtocolPlugClass*)PluginManager->FindPlugin(protocol);
//			printf("protocol: %ld\npobj: %p\n",protocol,pobj);
//			if (urlS.Length()==0) {
//				return;
//			}
//			if ((urlS.FindFirst("://")==B_ERROR) || (urlS.FindFirst("://")>=6)) {
//				urlS.Prepend("http://");
//				printf("url: %s\n",urlS.String());
//				printf("workurl: %s\n",workurl);
//				delete workurl;
//				workurl=new char[urlS.Length()+1];
//				memset(workurl,0,urlS.Length()+1);
//				urlS.CopyInto(workurl,0,urlS.Length());
//			} else {
//				memset(workurl,0,strlen(workurl)+1);
//				delete workurl;
//				workurl=new char[urlS.Length()+1];
//				memset(workurl,0,urlS.Length()+1);
//				urlS.CopyInto(workurl,0,urlS.Length());
//				
//			}
//			
//			// ok, lets make a copy of url.
//			BString target_url( url );
			
//			url=workurl;


//			printf( "Win: creating info message\n" );			
//
//			BMessage *info=new BMessage;
//			info->AddInt32( "view_id", view_id );
//			info->AddPointer("plug_manager",PluginManager);
//			info->AddPointer("main_menu_bar",menubar);
//			info->AddPointer("file_menu",filemenu);
//			info->AddPointer("options_menu",optionsmenu);
//			info->AddString("target_url",workurl);
//			
//			if( msg->what == URL_OPEN )
//				info->AddInt32("action",LoadingNewPage);
//			else
//				info->AddInt32("action",ReloadData);
//
//			delete workurl;
//			
//			if (usepass!=NULL) {
//					info->AddString("username:password",usepass);
//					memset(usepass,0,strlen(usepass)+1);
//					delete usepass;
//			}
				
//			if( msg->what == URL_OPEN )
//			{
//				printf("WIN: telling MS_TARGET_ALL that a new page is being loaded.\n");
//		
//				BMessage *lnp=new BMessage(LoadingNewPage);
//				lnp->AddInt32("command",COMMAND_INFO);
//				Broadcast(MS_TARGET_ALL,lnp);
//				delete lnp;
//			}
//
//			info->AddInt32("command",COMMAND_RETRIEVE);
//			info->AddInt32("targets",TARGET_PROTOCOL);
//			info->AddInt32("source",TARGET_VIEW);
			
//			info->PrintToStream();
			
//			printf("WIN: Sending request broadcast to MS_TARGET_PROTOCOL.\n");
//			Broadcast(MS_TARGET_PROTOCOL,info);
//			delete info;
//			printf("WIN: Done with request broadcast.\n");
			
			/*********/
			
			
			// I don't want to destroy anything working right now. So let's just
			// get something new in.
			
			BMessage* load = NULL;
			if( msg->what == URL_OPEN )
				load = new BMessage( SH_LOAD_NEW_PAGE );
			else
				load = new BMessage( SH_RELOAD_PAGE );
			
			load->AddInt32( "command", COMMAND_INFO );
			load->AddInt32( "site_id", site_id );
			load->AddString( "url", url.String() );
			
			/* We need to directly trigger the SiteHandler. Yap, bad. */
			( ( App* )be_app )->GetSiteHandler()->ReceiveBroadcast( load );
			
			delete load;

			/*
			 * Trigger this after the UrlHandler knows about the URL.
			 * Otherwise we wouldn't see any URL in UrlView during load.
			 * Sad, but true.
			 */
						
			if( msg->FindBool( "hidden" ) == true )
				tabview->DrawTabs();
			else
				tabview->Select( selection );
			
		}break;
		case URL_TYPED :
		{
//			cout << "URL_TYPED received" << endl;
			
			bool show_all = false;
			msg->FindBool( "show_all", &show_all );
			
			bool prefs_show_type_ahead = false;
			AppSettings->FindBool( kPrefsShowTypeAheadWindow, &prefs_show_type_ahead );
									
			if( ( prefs_show_type_ahead == true ) || ( show_all == true ) )
			{
				if( show_all == true )
					UrlTypedHandler( true );
				else
					UrlTypedHandler( false );
			}
			
			
		}break;
		case WINDOW_NEW :
		{
			// resend the message to the app
			be_app_messenger.SendMessage( msg );
			break;
		}
		default:
		{
			BWindow::MessageReceived(msg);
			break;
		}
	}
}
int32 MouseWatcher(void* data)
{
	BMessenger	*TheMessenger = (BMessenger*)data;
	BPoint 		PreviousPos;
	uint32 		PreviousButtons = 0;
	bool 		FirstCheck = true;
	BMessage 	MessageToSend;
	
	MessageToSend.AddPoint("where",BPoint(0,0));
	MessageToSend.AddInt32("buttons",0);
	
	while(true)
	{
		if (!TheMessenger->LockTarget())
		{
			delete TheMessenger;
			return 0;			// window is dead so exit
		}
		
		BLooper *TheLooper;
		BView	*TheView = (BView*)TheMessenger->Target(&TheLooper);
		BPoint 	Where;
		uint32 	Buttons;
		TheView->GetMouse(&Where,&Buttons,false);
		
		if(FirstCheck)
		{
			PreviousPos = Where;
			PreviousButtons = Buttons;
			FirstCheck = false;
		}
		
		bool Send = false;
		if(Buttons != PreviousButtons || Buttons == 0 || Where != PreviousPos)
		{
			if(Buttons == 0)
				MessageToSend.what = MW_MOUSE_UP;
			else if(Buttons != PreviousButtons)
				MessageToSend.what = MW_MOUSE_DOWN;
			else
				MessageToSend.what = MW_MOUSE_MOVED;
			
			MessageToSend.ReplacePoint("where",Where);
			MessageToSend.ReplaceInt32("buttons",Buttons);
			Send = true;
		}
		
		TheLooper->Unlock();
		
		if(Send)
			TheMessenger->SendMessage(&MessageToSend);
		
		if(Buttons == 0)
		{
			//Button was released
			delete TheMessenger;
			return 0;
		}
		
		snooze(50 * 1000);
	}
}
	virtual void ReadyToRun()
	{
		unitTesterMessenger.SendMessage(MSG_READY_TO_RUN);
	}
	virtual bool QuitRequested()
	{
		unitTesterMessenger.SendMessage(MSG_QUIT_REQUESTED);
		return true;
	}
	virtual void RefsReceived(BMessage *_message)
	{
		BMessage message(*_message);
		message.what = MSG_REFS_RECEIVED;
		unitTesterMessenger.SendMessage(&message);
	}