示例#1
0
void
AGMSBayesianSpamFilterConfig::ShowSpamServerConfigurationWindow () {
	status_t    errorCode = B_OK;
	BMessage    maximizeCommand;
	BMessenger	messengerToServer;
	BMessage    replyMessage;

	// Make sure the server is running.
	if (!be_roster->IsRunning (kServerSignature)) {
			errorCode = be_roster->Launch (kServerSignature);
			if (errorCode != B_OK) {
				BPath path;
				entry_ref ref;
				directory_which places[] = {
					B_SYSTEM_NONPACKAGED_BIN_DIRECTORY,
					B_SYSTEM_BIN_DIRECTORY
				};
				for (int32 i = 0; i < 2; i++) {
					find_directory(places[i],&path);
					path.Append("spamdbm");
					if (!BEntry(path.Path()).Exists())
						continue;
					get_ref_for_path(path.Path(),&ref);
					if ((errorCode =  be_roster->Launch (&ref)) == B_OK)
						break;
				}
				if (errorCode != B_OK)
					goto ErrorExit;
			}
		}
	
	// Set up the messenger to the database server.
	messengerToServer =
		BMessenger (kServerSignature);
	if (!messengerToServer.IsValid ())
		goto ErrorExit;

	// Wait for the server to finish starting up, and for it to create the window.
	snooze (2000000);

	// Tell it to show its main window, in case it is hidden in server mode.
	maximizeCommand.what = B_SET_PROPERTY;
	maximizeCommand.AddBool ("data", false);
	maximizeCommand.AddSpecifier ("Minimize");
	maximizeCommand.AddSpecifier ("Window", (int32)0);
	errorCode = messengerToServer.SendMessage (&maximizeCommand, &replyMessage);
	if (errorCode != B_OK)
		goto ErrorExit;
	return; // Successful.

ErrorExit:
	BAlert* alert = new BAlert ("SpamFilterConfig Error", B_TRANSLATE("Sorry, "
		"unable to launch the spamdbm program to let you edit the server "
		"settings."), B_TRANSLATE("Close"));
	alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
	alert->Go ();
	return;
}
示例#2
0
void 
FolderShaper::CleanUpWindow(entry_ref * a_dir_ref)
{
	PRINT(("CleanUpWindow()\n"));
	
	status_t	status;
	int32		count = 0;
	
	BMessenger tracker(FS_TRACKER_SIGNATURE);

	BMessage get_win_msg(B_GET_PROPERTY);
	BMessage reply;
	
	entry_ref windowRef;
	BDirectory dir;
	
	for(count = 1; count < 1000; count++)
	{
		get_win_msg.MakeEmpty();
		get_win_msg.what = B_GET_PROPERTY;
		get_win_msg.AddSpecifier("Path");
		get_win_msg.AddSpecifier("Poses");
		get_win_msg.AddSpecifier("Window", count);
		
		reply.MakeEmpty();
		if((status = tracker.SendMessage(&get_win_msg, &reply)) != B_OK)
		{	ErrorMessage("Error: Invalid Reply From Tracker!\n", status);	return; }
	
		if((status = reply.FindRef("result", &windowRef)) != B_OK)
		{	ErrorMessage("Error -- no windowRef ", status);	}		
		
		if(*a_dir_ref == windowRef)
		{
			//PRINT(("That's the window!\n"));
			dir.SetTo(&windowRef);
			break;
		}
	}
	
// Clean up
	reply.MakeEmpty();
	BMessage editor;
	editor.what = 'Tcla';
	editor.AddSpecifier("Poses");
	editor.AddSpecifier("Window", count);

	if ((status = tracker.SendMessage(&editor, &reply)) != B_OK)
		PRINT(("Error: Invalid Reply From Tracker!\n"));
}
示例#3
0
int
main(int argc, char **argv)
{
	B_TRANSLATE_MARK_SYSTEM_NAME_VOID("Tracker");
	BApplication app("application/x-vnd.Haiku-TrackerPreferences");

	// launch Tracker if it's not running
	be_roster->Launch("application/x-vnd.Be-TRAK");

	BMessage message;
	message.what = B_EXECUTE_PROPERTY;
	message.AddSpecifier("Preferences");

	BMessenger("application/x-vnd.Be-TRAK").SendMessage(&message);

	return 0;
}
示例#4
0
status_t
GrepWindow::_SelectFilesInTracker(BList* folderList, BMessage* refsMessage)
{
	// loops over Tracker windows, find each windowRef,
	// extract the refs that are children of windowRef,
	// add refs to selection-message

	status_t status = B_OK;
	BMessenger trackerMessenger(TRACKER_SIGNATURE);
	BMessage windowSendMessage;
	BMessage windowReplyMessage;
	BMessage selectionSendMessage;
	BMessage selectionReplyMessage;

	if (!trackerMessenger.IsValid())
		return status;

	// loop over Tracker windows
	for (int32 windowCount = 1; ; windowCount++) {

		windowSendMessage.MakeEmpty();
		windowReplyMessage.MakeEmpty();

		windowSendMessage.what = B_GET_PROPERTY;
		windowSendMessage.AddSpecifier("Path");
		windowSendMessage.AddSpecifier("Poses");
		windowSendMessage.AddSpecifier("Window", windowCount);

		status = trackerMessenger.SendMessage(&windowSendMessage,
			&windowReplyMessage);

		if (status != B_OK)
			return status;

		entry_ref windowRef;
		status = windowReplyMessage.FindRef("result", &windowRef);
		if (status != B_OK)
			break;

		int32 folderCount = folderList->CountItems();

		// loop over folders in folderList
		for (int32 x = 0; x < folderCount; x++) {
			BPath* folderPath = static_cast<BPath*>(folderList->ItemAt(x));
			if (folderPath == NULL)
				break;

			BString folderString = folderPath->Path();

			BEntry windowEntry;
			BPath windowPath;
			BString windowString;

			status = windowEntry.SetTo(&windowRef);
			if (status != B_OK)
				break;

			status = windowPath.SetTo(&windowEntry);
			if (status != B_OK)
				break;

			windowString = windowPath.Path();

			// if match, loop over items in refsMessage
			// and add those that live in window/folder
			// to a selection message

			if (windowString == folderString) {
				selectionSendMessage.MakeEmpty();
				selectionSendMessage.what = B_SET_PROPERTY;
				selectionReplyMessage.MakeEmpty();

				// loop over refs and add to message
				entry_ref ref;
				for (int32 index = 0; ; index++) {
					status = refsMessage->FindRef("refs", index, &ref);
					if (status != B_OK)
						break;

					BDirectory directory(&windowRef);
					BEntry entry(&ref);
					if (directory.Contains(&entry))
						selectionSendMessage.AddRef("data", &ref);
				}

				// finish selection message
				selectionSendMessage.AddSpecifier("Selection");
				selectionSendMessage.AddSpecifier("Poses");
				selectionSendMessage.AddSpecifier("Window", windowCount);

				trackerMessenger.SendMessage(&selectionSendMessage,
					&selectionReplyMessage);
			}
		}
	}

	return B_OK;
}
示例#5
0
bool
GrepWindow::_AreAllFoldersOpenInTracker(BList* folderList)
{
	// Compare the folders we want open in Tracker to
	// the actual Tracker windows currently open.

	// We build a list of open Tracker windows, and compare
	// it to the list of folders we want open in Tracker.

	// If all folders exists in the list of Tracker windows
	// return true

	status_t status = B_OK;
	BMessenger trackerMessenger(TRACKER_SIGNATURE);
	BMessage sendMessage;
	BMessage replyMessage;
	BList windowList;

	if (!trackerMessenger.IsValid())
		return false;

	for (int32 count = 1; ; count++) {
		sendMessage.MakeEmpty();
		replyMessage.MakeEmpty();

		sendMessage.what = B_GET_PROPERTY;
		sendMessage.AddSpecifier("Path");
		sendMessage.AddSpecifier("Poses");
		sendMessage.AddSpecifier("Window", count);

		status = trackerMessenger.SendMessage(&sendMessage, &replyMessage);
		if (status != B_OK)
			return false;

		entry_ref* trackerRef = new (nothrow) entry_ref;
		status = replyMessage.FindRef("result", trackerRef);
		if (status != B_OK || !windowList.AddItem(trackerRef)) {
			delete trackerRef;
			break;
		}
	}

	int32 folderCount = folderList->CountItems();
	int32 windowCount = windowList.CountItems();

	int32 found = 0;
	BPath* folderPath;
	entry_ref* windowRef;
	BString folderString;
	BString windowString;
	bool result = false;

	if (folderCount > windowCount) {
		// at least one folder is not open in Tracker
		goto out;
	}

	// Loop over the two lists and see if all folders exist as window
	for (int32 x = 0; x < folderCount; x++) {
		for (int32 y = 0; y < windowCount; y++) {

			folderPath = static_cast<BPath*>(folderList->ItemAt(x));
			windowRef = static_cast<entry_ref*>(windowList.ItemAt(y));

			if (folderPath == NULL)
				break;

			if (windowRef == NULL)
				break;

			folderString = folderPath->Path();

			BEntry entry;
			BPath path;

			if (entry.SetTo(windowRef) == B_OK && path.SetTo(&entry) == B_OK) {

				windowString = path.Path();

				if (folderString == windowString) {
					found++;
					break;
				}
			}
		}
	}

	result = found == folderCount;

out:
	// delete list of window entry_refs
	for (int32 x = 0; x < windowCount; x++)
		delete static_cast<entry_ref*>(windowList.ItemAt(x));

	return result;
}
示例#6
0
status_t
AGMSBayesianSpamFilter::ProcessMailMessage (
	BPositionIO** io_message,
	BEntry* io_entry,
	BMessage* io_headers,
	BPath* io_folder,
	const char* io_uid)
{
	ssize_t		 amountRead;
	attr_info	 attributeInfo;
	const char	*classificationString;
	off_t		 dataSize;
	BPositionIO	*dataStreamPntr = *io_message;
	status_t	 errorCode = B_OK;
	int32        headerLength;
	BString      headerString;
	BString		 newSubjectString;
	BNode        nodeForOutputFile;
	bool		 nodeForOutputFileInitialised = false;
	const char	*oldSubjectStringPntr;
	char         percentageString [30];
	BMessage	 replyMessage;
	BMessage	 scriptingMessage;
	team_id		 serverTeam;
	float		 spamRatio;
	char		*stringBuffer = NULL;
	char         tempChar;
	status_t     tempErrorCode;
	const char  *tokenizeModeStringPntr;

	// Set up a BNode to the final output file so that we can write custom
	// attributes to it.  Non-custom attributes are stored separately in
	// io_headers.

	if (io_entry != NULL && B_OK == nodeForOutputFile.SetTo (io_entry))
		nodeForOutputFileInitialised = true;

	// Get a connection to the spam database server.  Launch if needed, should
	// only need it once, unless another e-mail thread shuts down the server
	// inbetween messages.  This code used to be in InitCheck, but apparently
	// that isn't called.

	printf("Checking for Spam Server.\n");
	if (fLaunchAttemptCount == 0 || !fMessengerToServer.IsValid ()) {
		if (fLaunchAttemptCount > 3)
			goto ErrorExit; // Don't try to start the server too many times.
		fLaunchAttemptCount++;

		// Make sure the server is running.
		if (!be_roster->IsRunning (kServerSignature)) {
			errorCode = be_roster->Launch (kServerSignature);
			if (errorCode != B_OK) {
				BPath path;
				entry_ref ref;
				directory_which places[] = {B_COMMON_BIN_DIRECTORY,B_BEOS_BIN_DIRECTORY};
				for (int32 i = 0; i < 2; i++) {
					find_directory(places[i],&path);
					path.Append("spamdbm");
					if (!BEntry(path.Path()).Exists())
						continue;
					get_ref_for_path(path.Path(),&ref);
					if ((errorCode =  be_roster->Launch (&ref)) == B_OK)
						break;
				}
				if (errorCode != B_OK)
					goto ErrorExit;
			}
		}

		// Set up the messenger to the database server.
		serverTeam = be_roster->TeamFor (kServerSignature);
		if (serverTeam < 0)
			goto ErrorExit;
		fMessengerToServer =
			BMessenger (kServerSignature, serverTeam, &errorCode);
		if (!fMessengerToServer.IsValid ())
			goto ErrorExit;

		// Check if the server is running in headers only mode.  If so, we only
		// need to download the header rather than the entire message.
		scriptingMessage.MakeEmpty ();
		scriptingMessage.what = B_GET_PROPERTY;
		scriptingMessage.AddSpecifier ("TokenizeMode");
		replyMessage.MakeEmpty ();
		if ((errorCode = fMessengerToServer.SendMessage (&scriptingMessage,
			&replyMessage)) != B_OK)
			goto ErrorExit;
		if ((errorCode = replyMessage.FindInt32 ("error", &tempErrorCode))
			!= B_OK)
			goto ErrorExit;
		if ((errorCode = tempErrorCode) != B_OK)
			goto ErrorExit;
		if ((errorCode = replyMessage.FindString ("result",
			&tokenizeModeStringPntr)) != B_OK)
			goto ErrorExit;
		fHeaderOnly = (tokenizeModeStringPntr != NULL
			&& strcmp (tokenizeModeStringPntr, "JustHeader") == 0);
	}

	// See if the message has already been classified.  Happens for messages
	// which are partially downloaded when you have auto-training on.  Could
	// untrain the partial part before training on the complete message, but we
	// don't know how big it was, so instead just ignore the message.

	if (nodeForOutputFileInitialised) {
		if (nodeForOutputFile.GetAttrInfo ("MAIL:classification",
			&attributeInfo) == B_OK)
			return B_OK;
	}

	// Copy the message to a string so that we can pass it to the spam database
	// (the even messier alternative is a temporary file).  Do it in a fashion
	// which allows NUL bytes in the string.  This method of course limits the
	// message size to a few hundred megabytes.  If we're using header mode,
	// only read the header rather than the full message.

	if (fHeaderOnly) {
		// Read just the header, it ends with an empty CRLF line.
		dataStreamPntr->Seek (0, SEEK_SET);
		while ((errorCode = dataStreamPntr->Read (&tempChar, 1)) == 1) {
			headerString.Append (tempChar, 1);
			headerLength = headerString.Length();
			if (headerLength >= 4 && strcmp (headerString.String() +
				headerLength - 4, "\r\n\r\n") == 0)
				break;
		}
		if (errorCode < 0)
			goto ErrorExit;

		dataSize = headerString.Length();
		stringBuffer = new char [dataSize + 1];
		memcpy (stringBuffer, headerString.String(), dataSize);
		stringBuffer[dataSize] = 0;
	} else {
		// Read the whole file.  The seek to the end may take a while since
		// that triggers downloading of the entire message (and caching in a
		// slave file - see the MessageIO class).
		dataSize = dataStreamPntr->Seek (0, SEEK_END);
		if (dataSize <= 0)
			goto ErrorExit;

		try {
			stringBuffer = new char [dataSize + 1];
		} catch (...) {
			errorCode = ENOMEM;
			goto ErrorExit;
		}

		dataStreamPntr->Seek (0, SEEK_SET);
		amountRead = dataStreamPntr->Read (stringBuffer, dataSize);
		if (amountRead != dataSize)
			goto ErrorExit;
		stringBuffer[dataSize] = 0; // Add an end of string NUL, just in case.
	}

	// Send off a scripting command to the database server, asking it to
	// evaluate the string for spaminess.  Note that it can return ENOMSG
	// when there are no words (a good indicator of spam which is pure HTML
	// if you are using plain text only tokenization), so we could use that
	// as a spam marker too.  Code copied for the reevaluate stuff below.

	scriptingMessage.MakeEmpty ();
	scriptingMessage.what = B_SET_PROPERTY;
	scriptingMessage.AddSpecifier ("EvaluateString");
	errorCode = scriptingMessage.AddData ("data", B_STRING_TYPE,
		stringBuffer, dataSize + 1, false /* fixed size */);
	if (errorCode != B_OK)
		goto ErrorExit;
	replyMessage.MakeEmpty ();
	errorCode = fMessengerToServer.SendMessage (&scriptingMessage,
		&replyMessage);
	if (errorCode != B_OK
		|| replyMessage.FindInt32 ("error", &errorCode) != B_OK)
		goto ErrorExit; // Unable to read the return code.
	if (errorCode == ENOMSG && fNoWordsMeansSpam)
		spamRatio = fSpamCutoffRatio; // Yes, no words and that means spam.
	else if (errorCode != B_OK
		|| replyMessage.FindFloat ("result", &spamRatio) != B_OK)
		goto ErrorExit; // Classification failed in one of many ways.

	// If we are auto-training, feed back the message to the server as a
	// training example (don't train if it is uncertain).  Also redo the
	// evaluation after training.

	if (fAutoTraining) {
		if (spamRatio >= fSpamCutoffRatio || spamRatio < fGenuineCutoffRatio) {
			scriptingMessage.MakeEmpty ();
			scriptingMessage.what = B_SET_PROPERTY;
			scriptingMessage.AddSpecifier ((spamRatio >= fSpamCutoffRatio)
				? "SpamString" : "GenuineString");
			errorCode = scriptingMessage.AddData ("data", B_STRING_TYPE,
				stringBuffer, dataSize + 1, false /* fixed size */);
			if (errorCode != B_OK)
				goto ErrorExit;
			replyMessage.MakeEmpty ();
			errorCode = fMessengerToServer.SendMessage (&scriptingMessage,
				&replyMessage);
			if (errorCode != B_OK
				|| replyMessage.FindInt32 ("error", &errorCode) != B_OK)
				goto ErrorExit; // Unable to read the return code.
			if (errorCode != B_OK)
				goto ErrorExit; // Failed to set a good example.
		}

		// Note the kind of example made so that the user doesn't reclassify
		// the message twice (the spam server looks for this attribute).

		classificationString =
			(spamRatio >= fSpamCutoffRatio)
			? "Spam"
			: ((spamRatio < fGenuineCutoffRatio) ? "Genuine" : "Uncertain");
		if (nodeForOutputFileInitialised)
			nodeForOutputFile.WriteAttr ("MAIL:classification", B_STRING_TYPE,
				0 /* offset */, classificationString,
				strlen (classificationString) + 1);

		// Now that the database has changed due to training, recompute the
		// spam ratio.  Hopefully it will have become more extreme in the
		// correct direction (not switched from being spam to being genuine).
		// Code copied from above.

		scriptingMessage.MakeEmpty ();
		scriptingMessage.what = B_SET_PROPERTY;
		scriptingMessage.AddSpecifier ("EvaluateString");
		errorCode = scriptingMessage.AddData ("data", B_STRING_TYPE,
			stringBuffer, dataSize + 1, false /* fixed size */);
		if (errorCode != B_OK)
			goto ErrorExit;
		replyMessage.MakeEmpty ();
		errorCode = fMessengerToServer.SendMessage (&scriptingMessage,
			&replyMessage);
		if (errorCode != B_OK
			|| replyMessage.FindInt32 ("error", &errorCode) != B_OK)
			goto ErrorExit; // Unable to read the return code.
		if (errorCode == ENOMSG && fNoWordsMeansSpam)
			spamRatio = fSpamCutoffRatio; // Yes, no words and that means spam.
		else if (errorCode != B_OK
			|| replyMessage.FindFloat ("result", &spamRatio) != B_OK)
			goto ErrorExit; // Classification failed in one of many ways.
	}

	// Store the spam ratio in an attribute called MAIL:ratio_spam,
	// attached to the eventual output file.

	if (nodeForOutputFileInitialised)
		nodeForOutputFile.WriteAttr ("MAIL:ratio_spam",
			B_FLOAT_TYPE, 0 /* offset */, &spamRatio, sizeof (spamRatio));

	// Also add it to the subject, if requested.

	if (fAddSpamToSubject
		&& spamRatio >= fSpamCutoffRatio
		&& io_headers->FindString ("Subject", &oldSubjectStringPntr) == B_OK) {
		newSubjectString.SetTo ("[Spam ");
		sprintf (percentageString, "%05.2f", spamRatio * 100.0);
		newSubjectString << percentageString << "%] ";
		newSubjectString << oldSubjectStringPntr;
		io_headers->ReplaceString ("Subject", newSubjectString);
	}

	// Beep using different sounds for spam and genuine, as Jeremy Friesner
	// nudged me to get around to implementing.  And add uncertain to that, as
	// "BiPolar" suggested.  If the user doesn't want to hear the sound, they
	// can turn it off in the system sound preferences.

	if (spamRatio >= fSpamCutoffRatio) {
		system_beep (kAGMSBayesBeepSpamName);
	} else if (spamRatio < fGenuineCutoffRatio) {
		system_beep (kAGMSBayesBeepGenuineName);
	} else {
		system_beep (kAGMSBayesBeepUncertainName);
	}

	return B_OK;

ErrorExit:
	fprintf (stderr, "Error exit from "
		"SpamFilter::ProcessMailMessage, code maybe %ld (%s).\n",
		errorCode, strerror (errorCode));
	delete [] stringBuffer;
	return B_OK; // Not MD_ERROR so the message doesn't get left on server.
}
示例#7
0
int setNPprefs_byscript(int enableproxies)
{
	BMessage reply; 
	const char *s;
	status_t r;

	// open the prefs window
	{
		BMessage message;
		
		// set the command constant 
		message.what = B_EXECUTE_PROPERTY; 
		
		// construct the specifier stack 
		message.AddSpecifier("MenuItem","Preferences…");
		message.AddSpecifier("Menu","Edit");
		message.AddSpecifier("MenuBar");
		message.AddSpecifier("Window", _0);
		
		// send the message and fetch the result 
		r=BMessenger(appsig).SendMessage(&message, &reply); 
		if(r) return r;
		if(reply.what!='RPLY') return reply.what;
	}
	
	snooze(10000);
		
	// select the "Proxies" tab
	{
		BMessage message;
		
		// set the command constant 
		message.what = B_MOUSE_DOWN; 
		
		message.AddInt32("modifiers",0);
		message.AddInt32("buttons",B_PRIMARY_MOUSE_BUTTON);
		message.AddInt32("clicks",1);
		message.AddPoint("be:view_where",BPoint(150,16));

		// construct the specifier stack 
		message.AddSpecifier("View",_0);
		message.AddSpecifier("View",_0);
		message.AddSpecifier("Window","Preferences");
		
		// send the message and fetch the result 
		r=BMessenger(appsig).SendMessage(&message, &reply); 
		if(r) return r;
		if(reply.what!='NONE') return reply.what;
	}

	// check that "Enable Proxies" is where we expect it
	{
		BMessage message;
		
		// set the command constant 
		message.what = B_GET_PROPERTY; 
		
		// construct the specifier stack 
		message.AddSpecifier("Label");
		message.AddSpecifier("View",_0);
		message.AddSpecifier("View",_0);
		message.AddSpecifier("View",_0);
		message.AddSpecifier("View",_0);
		message.AddSpecifier("View",_0);
		message.AddSpecifier("View",_0);
		message.AddSpecifier("Window", "Preferences");
		
		// send the message and fetch the result 
		r=BMessenger(appsig).SendMessage(&message, &reply); 
		if(r) return r;
		if(reply.what!='RPLY') return reply.what;

		// check the result
		if(reply.FindString("result",&s)
		|| strcmp(s,"Enable Proxies"))
			return -1;
	}
	
	// set "Enable Proxies"
	{
		BMessage message;
		
		// set the command constant 
		message.what = B_SET_PROPERTY; 
		
		// construct the specifier stack 
		message.AddSpecifier("Value");
		message.AddSpecifier("View",_0);
		message.AddSpecifier("View",_0);
		message.AddSpecifier("View",_0);
		message.AddSpecifier("View",_0);
		message.AddSpecifier("View",_0);
		message.AddSpecifier("View",_0);
		message.AddSpecifier("Window", "Preferences");
		
		// specify the data
		message.AddInt32("data", enableproxies);
	
		// send the message and fetch the result 
		r=BMessenger(appsig).SendMessage(&message, &reply); 
		if(r) return r;
		if(reply.what!='RPLY') return reply.what;
	}

	// check that "HTTP" is where we expect it
	{
		BMessage message;
		
		// set the command constant 
		message.what = B_GET_PROPERTY; 
		
		// construct the specifier stack 
		message.AddSpecifier("Label");
		message.AddSpecifier("View",1);
		message.AddSpecifier("View",_0);
		message.AddSpecifier("View",_0);
		message.AddSpecifier("View",_0);
		message.AddSpecifier("View",_0);
		message.AddSpecifier("View",_0);
		message.AddSpecifier("Window", "Preferences");
		
		// send the message and fetch the result 
		r=BMessenger(appsig).SendMessage(&message, &reply); 
		if(r) return r;
		if(reply.what!='RPLY') return reply.what;

		// check the result
		if(reply.FindString("result",&s)
		|| strcmp(s,"HTTP:"))
			return -1;
	}
	
	// set "HTTP"
	{
		BMessage message;
		
		// set the command constant 
		message.what = B_SET_PROPERTY; 
		
		// construct the specifier stack 
		message.AddSpecifier("Value");
		message.AddSpecifier("View",1);
		message.AddSpecifier("View",_0);
		message.AddSpecifier("View",_0);
		message.AddSpecifier("View",_0);
		message.AddSpecifier("View",_0);
		message.AddSpecifier("View",_0);
		message.AddSpecifier("Window", "Preferences");
		
		// specify the data
		message.AddString("data", "127.0.0.1");
	
		// send the message and fetch the result 
		r=BMessenger(appsig).SendMessage(&message, &reply); 
		if(r) return r;
		if(reply.what!='RPLY') return reply.what;
	}
		
	// check that "Port" is where we expect it
	{
		BMessage message;
		
		// set the command constant 
		message.what = B_GET_PROPERTY; 
		
		// construct the specifier stack 
		message.AddSpecifier("Label");
		message.AddSpecifier("View",2);
		message.AddSpecifier("View",_0);
		message.AddSpecifier("View",_0);
		message.AddSpecifier("View",_0);
		message.AddSpecifier("View",_0);
		message.AddSpecifier("View",_0);
		message.AddSpecifier("Window", "Preferences");
		
		// send the message and fetch the result 
		r=BMessenger(appsig).SendMessage(&message, &reply); 
		if(r) return r;
		if(reply.what!='RPLY') return reply.what;

		// check the result
		if(reply.FindString("result",&s)
		|| strcmp(s,"Port:"))
			return -1;
	}
	
	// set "Port"
	{
		BMessage message;
		
		// set the command constant 
		message.what = B_SET_PROPERTY; 
		
		// construct the specifier stack 
		message.AddSpecifier("Value");
		message.AddSpecifier("View",2);
		message.AddSpecifier("View",_0);
		message.AddSpecifier("View",_0);
		message.AddSpecifier("View",_0);
		message.AddSpecifier("View",_0);
		message.AddSpecifier("View",_0);
		message.AddSpecifier("Window", "Preferences");
		
		// specify the data
		message.AddString("data", "8080");
	
		// send the message and fetch the result 
		r=BMessenger(appsig).SendMessage(&message, &reply); 
		if(r) return r;
		if(reply.what!='RPLY') return reply.what;
	}
		
	// check that "OK" is where we expect it
	{
		BMessage message;
		
		// set the command constant 
		message.what = B_GET_PROPERTY; 
		
		// construct the specifier stack 
		message.AddSpecifier("Label");
		message.AddSpecifier("View",2);
		message.AddSpecifier("View",_0);
		message.AddSpecifier("Window", "Preferences");
		
		// send the message and fetch the result 
		r=BMessenger(appsig).SendMessage(&message, &reply); 
		if(r) return r;
		if(reply.what!='RPLY') return reply.what;

		// check the result
		if(reply.FindString("result",&s)
		|| strcmp(s,"OK"))
			return -1;
	}
	
	// click "OK"
	{
		BMessage message;
		
		// set the command constant 
		message.what = B_SET_PROPERTY;
		
		// construct the specifier stack 
		message.AddSpecifier("Value");
		message.AddSpecifier("View",2);
		message.AddSpecifier("View",_0);
		message.AddSpecifier("Window", "Preferences");
		
		// specify the data
		message.AddInt32("data", 1);
	
		// send the message and fetch the result 
		r=BMessenger(appsig).SendMessage(&message, &reply); 
		if(r) return r;
		if(reply.what!='RPLY') return reply.what;
	}

	return 0;
}