Example #1
0
status_t
write_read_attr(BNode& node, read_flags flag)
{
	if (node.WriteAttr(B_MAIL_ATTR_READ, B_INT32_TYPE, 0, &flag, sizeof(int32))
		< 0)
		return B_ERROR;

#if R5_COMPATIBLE
	// manage the status string only if it currently has a "read" status
	BString currentStatus;
	if (node.ReadAttrString(B_MAIL_ATTR_STATUS, &currentStatus) == B_OK) {
		if (currentStatus.ICompare("New") != 0
			&& currentStatus.ICompare("Read") != 0
			&& currentStatus.ICompare("Seen") != 0)
			return B_OK;
	}

	const char* statusString = (flag == B_READ) ? "Read"
		: (flag  == B_SEEN) ? "Seen" : "New";
	if (node.WriteAttr(B_MAIL_ATTR_STATUS, B_STRING_TYPE, 0, statusString,
		strlen(statusString)) < 0)
		return B_ERROR;
#endif
	return B_OK;
}
Example #2
0
entry_ref
SourceTypeC::CreateSourceFile(const char *dir, const char *name, uint32 options)
{
	if (!dir || !name)
		return entry_ref();
	
	BString folderstr(dir);
	if (folderstr.ByteAt(folderstr.CountChars() - 1) != '/')
		folderstr << "/";
	
	DPath folder(folderstr.String()), filename(name);
	
	bool is_cpp = false;
	bool is_header = false;
	bool create_pair = ((options & SOURCEFILE_PAIR) != 0);
	
	BString ext = filename.GetExtension();
	if ( (ext.ICompare("cpp") == 0) || (ext.ICompare("c") == 0) ||
		(ext.ICompare("cxx") == 0) || (ext.ICompare("cc") == 0) )
		is_cpp = true;
	else if ((ext.ICompare("h") == 0) || (ext.ICompare("hxx") == 0) ||
			(ext.ICompare("hpp") == 0) || (ext.ICompare("h++") == 0))
		is_header = true;
	
	if (!is_cpp && !is_header)
		return entry_ref();
	
	BString sourceName, headerName;
	if (is_cpp)
	{
		sourceName = filename.GetFileName();
		headerName = filename.GetBaseName();
		headerName << ".h";
	}
	else
	{
		sourceName = filename.GetBaseName();
		sourceName << ".cpp";
		headerName = filename.GetFileName();
	}
		
	
	entry_ref sourceRef, headerRef;
	BString data;
	if (is_cpp || create_pair)
	{
		if (create_pair)
			data << "#include \"" << headerName << "\"\n\n";
		
		sourceRef = MakeProjectFile(folder.GetFullPath(),sourceName.String(),data.String());
	}
	
	if (is_header || create_pair)
	{
		data = MakeHeaderGuard(headerName.String());
		headerRef = MakeProjectFile(folder.GetFullPath(),headerName.String(),data.String());
	}
	
	return is_cpp ? sourceRef : headerRef;
}
Example #3
0
bool
StringCompare(const BString &from, const BString &to, const char *mode,
			const bool &match_case)
{
	if (!mode)
	{
		debugger("NULL mode in StringCompare");
		return false;
	}
	
	if (strcmp(mode,"is") == 0)
		if (match_case)
			return from.Compare(to) == 0;
		else
			return from.ICompare(to) == 0;
	else if (strcmp(mode,"is not") == 0)
		if (match_case)
			return from.Compare(to) != 0;
		else
			return from.ICompare(to) != 0;
	else if (strcmp(mode,"contains") == 0)
		if (match_case)
			return to.FindFirst(from) >= 0;
		else
			return to.IFindFirst(from) >= 0;
	else if (strcmp(mode,"does not contain") == 0)
		if (match_case)
			return to.FindFirst(from) < 0;
		else
			return to.IFindFirst(from) < 0;
	else if (strcmp(mode,"starts with") == 0)
		if (match_case)
			return to.FindFirst(from) == 0;
		else
			return to.IFindFirst(from) == 0;
	else if (strcmp(mode,"ends with") == 0)
	{
		int32 pos;
		if (match_case)
			pos = to.FindLast(from);
		else
			pos = to.IFindLast(from);
		
		return (to.CountChars() - from.CountChars() == pos);
	}	
	
	return false;
}
entry_ref
SourceTypeShell::CreateSourceFile(const char *dir, const char *name, uint32 options)
{
	if (!dir || !name)
		return entry_ref();
	
	BString folderstr(dir);
	if (folderstr.ByteAt(folderstr.CountChars() - 1) != '/')
		folderstr << "/";
	
	DPath folder(folderstr.String()), filename(name);
	
	BString ext = filename.GetExtension();
	if (ext.ICompare("sh") != 0)
		return entry_ref();
	
	BString fileData = "#!/bin/sh\n\n";
	entry_ref outRef = MakeProjectFile(folder, filename.GetFileName(),
							fileData.String(), "text/x-source-code");
	BFile file(&outRef, B_READ_WRITE);
	if (file.InitCheck() == B_OK)
	{
		mode_t perms;
		file.GetPermissions(&perms);
		file.SetPermissions(perms | S_IXUSR | S_IXGRP);
	}
	
	return outRef;
}
Example #5
0
void
AppWindowPrefsView::MessageReceived (BMessage *msg)
{
	switch (msg->what)
	{
		case M_APPWINDOWPREFS_ENCODING_CHANGED:
			{
				BMenuItem *source (NULL);
				msg->FindPointer ("source", reinterpret_cast<void **>(&source));
				source->SetMarked(true);
				int32 encoding (msg->FindInt32("encoding"));
				vision_app->SetInt32("encoding", encoding);
			}
			break;
			
		case M_APPWINDOWPREFS_SETTING_CHANGED:
			{
				BControl *source (NULL);
				msg->FindPointer ("source", reinterpret_cast<void **>(&source));
				BString setting;
				msg->FindString ("setting", &setting);
				int32 value (source->Value() == B_CONTROL_ON);
				if ((setting.ICompare ("versionParanoid") == 0))
					value = !value;
				vision_app->SetBool (setting.String(), value);
			}
			break;
		default:
			BView::MessageReceived(msg);
			break;
	}
}
Example #6
0
bool
ListCommand::HandleUntagged(Response& response)
{
	if (response.IsCommand(_Command()) && response.IsStringAt(2)
		&& response.IsStringAt(3)) {
		fSeparator = response.StringAt(2);

		BString folder = response.StringAt(3);
		if (folder == "")
			return true;

		try {
			folder = fEncoding.Decode(folder);
			// The folder INBOX is always case insensitive
			if (folder.ICompare("INBOX") == 0)
				folder = "Inbox";
			fFolders.push_back(folder);
		} catch (ParseException& exception) {
			// Decoding failed, just add the plain text
			fprintf(stderr, "Decoding \"%s\" failed: %s\n", folder.String(),
				exception.Message());
			fFolders.push_back(folder);
		}
		return true;
	}

	return false;
}
Example #7
0
/*!
\internal
Messages received from the BeOS roster concerning application startup and termination are similar to the
one below, which was taken from the launch of the restart_daemon.

BMessage: what = BRAS (0x42524153, or 1112686931)
    entry   be:signature, type='CSTR', c=1, size=37, data[0]: "application/x-vnd.bls-restart_daemon"
    entry        be:team, type='LONG', c=1, size= 4, data[0]: 0xea4 (3748, '')
    entry      be:thread, type='LONG', c=1, size= 4, data[0]: 0x22a9 (8873, '')
    entry       be:flags, type='LONG', c=1, size= 4, data[0]: 0x10000009 (268435465, '')
    entry         be:ref, type='RREF', c=1, size=27, data[0]: device=7, directory=7653630, name="restart_daemon", path="/zanos/programming/restart_daemon/output/restart_daemon"                       
*/
void MicroRestarterApp::MessageReceived(BMessage *msg)
{
	switch(msg->what)
	{
		/*
			BMessage from the roster that some program has quit. We parse the BMessage to see if the
			message contains the application signature of the restart_daemon.
		*/
		case B_SOME_APP_QUIT:
		{
			BString sig;
			msg->FindString("be:signature",&sig);
			if (sig.ICompare(APP1SIG)==0)
			{
				//The restart daemon has quit; launch it again.
				entry_ref ref;
				msg->FindRef("be:ref",&ref);
				team_id team=-1;
				status_t status=B_ERROR;
				status=be_roster->Launch(&ref,(BMessage*)NULL,&team);
				if (team==-1)
				{
					//some error checking and handling should go here... obviously...
					(new BAlert("mr","Couldn't restart restart_daemon...","WTF?"))->Go(NULL);
					
				}
			}
		}break;
		/*
			BMessage from the roster that some program has started. Again we parse the BMessage to see if
			the message contains the application signature of the restart_daemon.
		*/
		case B_SOME_APP_LAUNCHED:
		{
			BString sig;
			msg->FindString("be:signature",&sig);
			if (sig.ICompare(APP1SIG)==0)
			{//our partner (the restart_daemon application) has started; we are no longer needed. commit seppuku.
				be_app_messenger.SendMessage(B_QUIT_REQUESTED);
			}
			
		}break;
		default:
			BApplication::MessageReceived(msg);
	}
}
Example #8
0
bool
DecisionProvider::YesNoDecisionNeeded(const BString& description,
	const BString& question, const BString& yes, const BString& no,
	const BString& defaultChoice)
{
	if (description.Length() > 0)
		printf("%s\n", description.String());

	bool haveDefault = defaultChoice.Length() > 0;

	while (true) {
		printf("%s [%s/%s]%s: ", question.String(), yes.String(), no.String(),
			haveDefault
				? (BString(" (") << defaultChoice << ") ").String() : "");

		if (!fInteractive) {
			printf("%s\n", yes.String());
			return true;
		}

		char buffer[32];
		if (fgets(buffer, 32, stdin)) {
			if (haveDefault &&  (buffer[0] == '\n' || buffer[0] == '\0'))
				return defaultChoice == yes;
			int length = strlen(buffer);
			for (int i = 1; i <= length; ++i) {
				if (yes.ICompare(buffer, i) == 0) {
					if (no.ICompare(buffer, i) != 0)
						return true;
				} else if (no.Compare(buffer, i) == 0) {
					if (yes.ICompare(buffer, i) != 0)
						return false;
				} else
					break;
			}
			fprintf(stderr, "*** please enter '%s' or '%s'\n", yes.String(),
				no.String());
		}
	}
}
Example #9
0
bool
Model::Mimeset(bool force)
{
	BString oldType = MimeType();
	BPath path;
	GetPath(&path);

	update_mime_info(path.Path(), 0, 1, force ? 2 : 0);
	ModelNodeLazyOpener opener(this);
	opener.OpenNode();
	AttrChanged(NULL);

	return !oldType.ICompare(MimeType());
}
bool
FindMessageParameter(const char *name, const BMessage& message, BMessage *save,
	int32 *startIndex)
{
	// XXX: this should be removed when we can replace BMessage with something better
	BString string;
	int32 index = startIndex ? *startIndex : 0;
	for(; message.FindMessage(MDSU_PARAMETERS, index, save) == B_OK; index++) {
		if(save->FindString(MDSU_NAME, &string) == B_OK
				&& string.ICompare(name) == 0) {
			if(startIndex)
				*startIndex = index;
			return true;
		}
	}
	
	return false;
}
Example #11
0
bool
Project::IsProject(const entry_ref &ref)
{
	BNode node(&ref);
	BString type;
	node.ReadAttrString("BEOS:TYPE",&type);
	if (type.CountChars() > 0 && type == PROJECT_MIME_TYPE)
		return true;
	
	BString extension = BPath(&ref).Path();
	int32 pos = extension.FindLast(".");
	if (pos >= 0)
	{
		extension = extension.String() + pos;
		if (extension.ICompare(".pld") == 0)
			return true;
	}
	return false;
}
Example #12
0
status_t
read_read_attr(BNode& node, read_flags& flag)
{
	if (node.ReadAttr(B_MAIL_ATTR_READ, B_INT32_TYPE, 0, &flag, sizeof(int32))
		== sizeof(int32))
		return B_OK;

#if R5_COMPATIBLE
	BString statusString;
	if (node.ReadAttrString(B_MAIL_ATTR_STATUS, &statusString) == B_OK) {
		if (statusString.ICompare("New"))
			flag = B_UNREAD;
		else
			flag = B_READ;

		return B_OK;
	}
#endif
	return B_ERROR;
}
Example #13
0
bool 
Model::Mimeset(bool force)
{
	BString oldType = MimeType();
	ModelNodeLazyOpener opener(this);
	BPath path;
	GetPath(&path);
	if (force) {
		if (opener.OpenNode(true) != B_OK)
			return false;

		Node()->RemoveAttr(kAttrMIMEType);
		update_mime_info(path.Path(), 0, 1, 1);
	} else
		update_mime_info(path.Path(), 0, 1, 0);

	AttrChanged(0);

	return !oldType.ICompare(MimeType());
}
Example #14
0
status_t
BDefaultChoiceList::GetMatch(const char *prefix, int32 startIndex,
	int32 *matchIndex, const char **completionText)
{
	BString *str;
	int32 len = strlen(prefix);
	int32 choices = fList->CountItems();

	for (int32 i = startIndex; i < choices; i++) {
		str = fList->ItemAt(i);
		if (!str->ICompare(prefix, len)) {
			// prefix matches
			*matchIndex = i;
			*completionText = str->String() + len;
			return B_OK;
		}
	}
	*matchIndex = -1;
	*completionText = NULL;
	return B_ERROR;
}
Example #15
0
status_t
Project::Load(const char *path)
{
	BEntry entry(path,true);
	status_t status = entry.InitCheck();
	if (status != B_OK)
		return status;
	
	entry_ref ref;
	entry.GetRef(&ref);
	
	fReadOnly = BVolume(ref.device).IsReadOnly();
	
	TextFile file(ref,B_READ_ONLY);
	status = file.InitCheck();
	if (status != B_OK)
		return status;
	
	fGroupList.MakeEmpty();
	
	fPath = path;
	fName = fPath.GetBaseName();
	
	platform_t actualPlatform = DetectPlatform();
	
	STRACE(2,("Loading project %s\n",path));
	
	// Set this to an out-of-bounds value to detect if
	// there is no SCM entry in the project
	fSCMType = SCM_INIT;
	
	SourceGroup *srcgroup = NULL;
	SourceFile *srcfile = NULL;
	BString line = file.ReadLine();
	while (line.CountChars() > 0)
	{
		int32 pos = line.FindFirst("=");
		if (pos < 0)
		{
			line = file.ReadLine();
			continue;
		}
		
		BString entry = line;
		entry.Truncate(pos);
		
		BString value = line.String() + pos + 1;
		
		STRACE(2,("Load Project: %s=%s\n",entry.String(),value.String()));
		
		if (value.CountChars() > 0)
		{
			if (entry[0] == '#')
				continue;
			else
			if (entry == "SOURCEFILE")
			{
				if (value.String()[0] != '/')
				{
					value.Prepend("/");
					value.Prepend(fPath.GetFolder());
				}
				srcfile = gFileFactory.CreateSourceFileItem(value.String());
				AddFile(srcfile, srcgroup);
			}
			else if (entry == "DEPENDENCY")
			{
				if (srcfile)
					srcfile->fDependencies = value;
			}
			else if (entry == "LOCALINCLUDE")
			{
				ProjectPath include(fPath.GetFolder(), value.String());
				AddLocalInclude(include.Absolute().String());
			}
			else if (entry == "SYSTEMINCLUDE")
				AddSystemInclude(value.String());
			else if (entry == "LIBRARY")
			{
				if (actualPlatform == fPlatform)
					AddLibrary(value.String());
				else
					ImportLibrary(value.String(),actualPlatform);
			}
			else if (entry == "GROUP")
				srcgroup = AddGroup(value.String());
			else if (entry == "EXPANDGROUP")
			{
				if (srcgroup)
					srcgroup->expanded = value == "yes" ? true : false;
			}
			else if (entry == "TARGETNAME")
				fTargetName = value;
			else if (entry == "CCDEBUG")
				fDebug = value == "yes" ? true : false;
			else if (entry == "CCPROFILE")
				fProfile = value == "yes" ? true : false;
			else if (entry == "CCOPSIZE")
				fOpSize = value == "yes" ? true : false;
			else if (entry == "CCOPLEVEL")
				fOpLevel = atoi(value.String());
			else if (entry == "CCTARGETTYPE")
				fTargetType = atoi(value.String());
			else if (entry == "CCEXTRA")
				fExtraCompilerOptions = value;
			else if (entry == "LDEXTRA")
				fExtraLinkerOptions = value;
			else if (entry == "RUNARGS")
				fRunArgs = value;
			else if (entry == "SCM")
			{
				if (value.ICompare("hg") == 0)
					fSCMType = SCM_HG;
				else if (value.ICompare("git") == 0)
					fSCMType = SCM_GIT;
				else if (value.ICompare("svn") == 0)
					fSCMType = SCM_SVN;
				else
					fSCMType = SCM_NONE;
			}
			else if (entry == "PLATFORM")
			{
				if (value.ICompare("Haiku") == 0)
					fPlatform = PLATFORM_HAIKU;
				else if (value.ICompare("HaikuGCC4") == 0)
					fPlatform = PLATFORM_HAIKU_GCC4;
				else if (value.ICompare("Zeta") == 0)
					fPlatform = PLATFORM_ZETA;
				else
					fPlatform = PLATFORM_R5;
			}
				
		}
		
		line = file.ReadLine();
	}
	
	// Fix one of my pet peeves when changing platforms: having to add libsupc++.so whenever
	// I change to Haiku GCC4 or GCC4hybrid from any other platform
	if (actualPlatform == PLATFORM_HAIKU_GCC4 && actualPlatform != fPlatform)
	{
		BPath libpath;
		find_directory(B_USER_DEVELOP_DIRECTORY,&libpath);
		libpath.Append("lib/x86/libsupc++.so");
		AddLibrary(libpath.Path());
	}
	
	fObjectPath = fPath.GetFolder();
	
	BString objfolder("(Objects.");
	objfolder << GetName() << ")";
	fObjectPath.Append(objfolder.String());
	
	UpdateBuildInfo();
	
	// We now set the platform to whatever we're building on. fPlatform is only used
	// in the project loading code to be able to help cover over issues with changing platforms.
	// Most of the time this is just the differences in libraries, but there may be other
	// unforeseen issues that will come to light in the future.
	fPlatform = actualPlatform;
	
	return B_OK;
}
Example #16
0
void
App::OpenFile(entry_ref ref, int32 line)
{
	if (!ref.name)
		return;
	
	BNode node(&ref);
	BString type;
	if (node.ReadAttrString("BEOS:TYPE",&type) != B_OK)
	{
		update_mime_info(BPath(&ref).Path(),0,0,1);
		node.ReadAttrString("BEOS:TYPE",&type);
	}
	
	if (type.CountChars() > 0)
	{
		if (type == PROJECT_MIME_TYPE || type.FindFirst("text/") != 0)
		{
			be_roster->Launch(&ref);
			return;
		}
	}
	else
	{
		BString extension = BPath(&ref).Path();
		int32 pos = extension.FindLast(".");
		if (pos >= 0)
		{
			extension = extension.String() + pos;
			if (extension.ICompare(".cpp") != 0 &&
				extension.ICompare(".h") != 0 &&
				extension.ICompare(".hpp") != 0 &&
				extension.ICompare(".c") != 0)
			{
				return;
			}
		}
	}
	
//	BMessage msg(B_REFS_RECEIVED);
	BMessage msg(PALEDIT_OPEN_FILE);
	msg.AddRef("refs",&ref);
	if (line >= 0)
		msg.AddInt32("line",line);
	
	if (be_roster->IsRunning(EDITOR_SIGNATURE))
	{
		BMessenger msgr(EDITOR_SIGNATURE);
		msgr.SendMessage(&msg);
	}
	else
	{
		DPath path(gAppPath.GetFolder());
		path.Append("PalEdit");
		
		entry_ref launchref;
		BEntry(path.GetFullPath()).GetRef(&launchref);
		
		if (be_roster->Launch(&launchref,&msg) != B_OK &&
			be_roster->Launch(EDITOR_SIGNATURE,&msg) != B_OK)
			be_roster->Launch(&ref);
	}
}
Example #17
0
status_t
LoadRules(const char *path, BObjectList<FilerRule> *ruleList)
{
	BEntry entry("/boot/home/config/settings/FilerRules");
	if (!entry.Exists())
		return B_OK;
	
	CppSQLite3DB db;
	db.open("/boot/home/config/settings/FilerRules");
	
	// Because this particular build of sqlite3 does not support multithreading
	// because of lack of pthreads support, we need to do this in a slightly different order
	
	CppSQLite3Query query;
	query = DBQuery(db,"select name from RuleList order by ruleid;","PrefsWindow::LoadRules");
	
	BString command;
	while (!query.eof())
	{
		BString rulename = query.getStringField((int)0);
		
		FilerRule *rule = new FilerRule;
		rule->SetDescription(DeescapeIllegalCharacters(rulename.String()).String());
		
		ruleList->AddItem(rule);
		
		query.nextRow();
	}
	
	query.finalize();
	
	for (int32 i = 0; i < ruleList->CountItems(); i++)
	{
		FilerRule *rule = ruleList->ItemAt(i);
		
		if (!rule)
			continue;
		
		BString rulename(EscapeIllegalCharacters(rule->GetDescription()));
		
		// Now comes the fun(?) part: loading the tests and actions. Joy. :/
		command = "select * from ";
		command << rulename << " where entrytype = 'test';";
		query = DBQuery(db,command.String(),"PrefsWindow::LoadRules");
		
		while (!query.eof())
		{
			BString classname = DeescapeIllegalCharacters(query.getStringField(1));
			BMessage *test = new BMessage;
			
			test->AddString("name",classname);
			
			if (classname.ICompare("Attribute") == 0)
			{
				test->AddString("mimetype",DeescapeIllegalCharacters(query.getStringField(4)));
				test->AddString("typename",DeescapeIllegalCharacters(query.getStringField(5)));
				test->AddString("attrname",DeescapeIllegalCharacters(query.getStringField(6)));
			}
			
			test->AddString("mode",DeescapeIllegalCharacters(query.getStringField(2)).String());
			test->AddString("value",DeescapeIllegalCharacters(query.getStringField(3)).String());
			
			rule->AddTest(test);
			
			query.nextRow();
		}
		query.finalize();
		
		command = "select * from ";
		command << rulename << " where entrytype = 'action';";
		query = DBQuery(db,command.String(),"PrefsWindow::LoadRules");
		
		while (!query.eof())
		{
			BMessage *action = new BMessage;
			
			action->AddString("name",DeescapeIllegalCharacters(query.getStringField(1)));
			action->AddString("value",DeescapeIllegalCharacters(query.getStringField(3)));
			
			rule->AddAction(action);
			
			query.nextRow();
		}
		query.finalize();
		
	}
	
	db.close();
	return B_OK;
}
Example #18
0
BEmailMessage *
BEmailMessage::ReplyMessage(mail_reply_to_mode replyTo, bool accountFromMail,
	const char *quoteStyle)
{
	BEmailMessage *reply = new BEmailMessage;

	// Set ReplyTo:

	if (replyTo == B_MAIL_REPLY_TO_ALL) {
		reply->SetTo(From());

		BList list;
		get_address_list(list, CC(), extract_address);
		get_address_list(list, To(), extract_address);

		// Filter out the sender
		BMailAccounts accounts;
		BMailAccountSettings* account = accounts.AccountByID(Account());
		BString sender;
		if (account)
			sender = account->ReturnAddress();
		extract_address(sender);

		BString cc;

		for (int32 i = list.CountItems(); i-- > 0;) {
			char *address = (char *)list.RemoveItem((int32)0);

			// add everything which is not the sender and not already in the list
			if (sender.ICompare(address) && cc.FindFirst(address) < 0) {
				if (cc.Length() > 0)
					cc << ", ";

				cc << address;
			}

			free(address);
		}

		if (cc.Length() > 0)
			reply->SetCC(cc.String());
	} else if (replyTo == B_MAIL_REPLY_TO_SENDER || ReplyTo() == NULL)
		reply->SetTo(From());
	else
		reply->SetTo(ReplyTo());

	// Set special "In-Reply-To:" header (used for threading)
	const char *messageID = _body ? _body->HeaderField("Message-Id") : NULL;
	if (messageID != NULL)
		reply->SetHeaderField("In-Reply-To", messageID);

	// quote body text
	reply->SetBodyTextTo(BodyText());
	if (quoteStyle)
		reply->Body()->Quote(quoteStyle);

	// Set the subject (and add a "Re:" if needed)
	BString string = Subject();
	if (string.ICompare("re:", 3) != 0)
		string.Prepend("Re: ");
	reply->SetSubject(string.String());

	// set the matching outbound chain
	if (accountFromMail)
		reply->SendViaAccountFrom(this);

	return reply;
}
Example #19
0
bool CStdErrParser::MatchOne(bool flush)
{
	vector<CErrPatInfo>::iterator ri;
	CMessageItem *item = NULL;
	entry_ref ref;
	int m = fErrBuffer.length();
	for (ri = fPatterns.begin(); item == NULL && ri != fPatterns.end(); ++ri)
	{
		CRegex& rx = *ri->fInfo;
		const char *text = fErrBuffer.c_str();
		int size = fErrBuffer.length();
	
		int r = rx.Match(text, size, 0);
		if (r)
		{
			if (r == krx_NoMatch)
				continue;
			else
				THROW((rx.ErrorStr().String()));
		}
	
		BString file;
		if (text[rx.MatchStart(ri->fFile)] != kDirectorySeparator && fCWD)
			file << fCWD << kDirectorySeparator;
		file << rx.MatchStr(text, ri->fFile);

		if (get_ref_for_path(file.String(), &ref) == B_OK 
			&& BEntry(&ref).Exists())
		{
			int line = strtoul(rx.MatchStr(text, ri->fLine).String(), NULL, 10);
			bool warning = false;
			
			if (ri->fWarning)
			{
				BString wstr = rx.MatchStr(text, ri->fWarning);
				warning = (wstr.ICompare("warning", 7) == 0);
			}
			
			item = new CMessageItem(rx.MatchStr(text, ri->fMsg).String(),
									rx.MatchLen(ri->fMsg),
									warning 
										? CMessageItem::msgWarning 
										: CMessageItem::msgError,
									&ref, line);
			fErrBuffer.erase(rx.MatchStart(), rx.MatchLen());
			m = rx.MatchStart();
		}
	}
	
	int found = false;

	if (item || flush)
	{
		BAutolock lock(fErrList->Window());

		if (lock.IsLocked())
		{
			font_height fi;
			be_plain_font->GetHeight(&fi);
			float h = fi.ascent + fi.descent + 2;
	
			while (m > 0)
			{
				int l = (int)fErrBuffer.find('\n');
				
				CMessageItem *i = new CMessageItem(fErrBuffer.c_str(),
					std::min(m, l), CMessageItem::msgInfo);
				fErrList->AddItem(i);
				i->SetHeight(h);
				
				fErrBuffer.erase(0, std::min(l + 1, m));
				m -= l + 1;
				
				found = true;
			}
			
			if (item)
			{
				fErrList->AddItem(item);
				item->SetHeight(h);
				
				found = true;
			}

			if (found)
			{
				fErrList->Select(fErrList->CountItems() - 1);
				fErrList->ScrollToSelection();
				
				if (fErrList->Window()->IsHidden())
					fErrList->Window()->Show();
			}
		}
	}
	
	return found;
} // CStdErrParser::MatchOne
Example #20
0
void
MainWindow::MessageReceived(BMessage *msg)
{
	switch (msg->what)
	{
		case M_ADD_WINDOW:
		{
			AddWindow();
			break;
		}
		case M_ADD_CONTROL:
		{
			BString type;
			msg->FindString("type",&type);
			if (type.ICompare("PWindow") == 0)
				AddWindow();
			else
				AddControl(type);
			break;
		}
		case M_REMOVE_SELECTED:
		{
			int32 index = fListView->CurrentSelection();
			fListView->Deselect(index);
			UpdateProperties();
			
			ObjectItem *item = (ObjectItem*)fListView->RemoveItem(index);
			if (item)
			{
				PObject *obj = item->GetObject();
				delete item;
				delete obj;
			}
			break;
		}
		case M_TOGGLE_PROPERTY_WIN:
		{
			if (fPropertyWin->IsHidden())
				fPropertyWin->Show();
			else
				fPropertyWin->Hide();
			break;
		}
		case M_OBJECT_SELECTED:
		{
			UpdateFloaters();
			UpdateProperties();
			break;
		}
		case M_ACTIVATE_OBJECT:
		{
			uint64 id;
			if (msg->FindInt64("id",(int64*)&id) != B_OK)
				break;
			
			for (int32 i = 0; i < fListView->CountItems(); i++)
			{
				ObjectItem *item = (ObjectItem*) fListView->ItemAt(i);
				if (item->GetObject()->GetID() == id)
				{
					fListView->Select(i);
					break;
				}
			}
			break;
		}
		case M_UPDATE_PROPERTY_EDITOR:
		{
			fPropertyWin->PostMessage(msg);
			break;
		}
		default:
		{
			BWindow::MessageReceived(msg);
			break;
		}
	}
}
Example #21
0
void
App::OpenFile(entry_ref ref, int32 line, int32 column)
{
	if (!ref.name)
		return;
	
	BNode node(&ref);
	BString type;
	if (node.ReadAttrString("BEOS:TYPE",&type) != B_OK)
	{
		update_mime_info(BPath(&ref).Path(),0,0,1);
		node.ReadAttrString("BEOS:TYPE",&type);
	}
	
	if (type.CountChars() > 0)
	{
		if (type == PROJECT_MIME_TYPE || type.FindFirst("text/") != 0)
		{
			STRACE(2,("Launching text or project file in roster...\n"));
			be_roster->Launch(&ref);
			return;
		}
	}
	else
	{
		BString extension = BPath(&ref).Path();
		int32 pos = extension.FindLast(".");
		if (pos >= 0)
		{
			extension = extension.String() + pos;
			if (extension.ICompare(".cpp") != 0 &&
				extension.ICompare(".h") != 0 &&
				extension.ICompare(".hpp") != 0 &&
				extension.ICompare(".c") != 0)
			{
				return;
			}
		}
	}
	
	
	BMessage* msg = new BMessage(B_REFS_RECEIVED);
	msg->AddRef("refs",&ref);
	if (line >= 0)
		msg->AddInt32("be:line",line);
	if (column >= 0)
		msg->AddInt32("be:column",column);
	STRACE(2,("Paladin Launching File Ref: %s:%i:%i\n",ref.name,line,column));
	
	/*
	  ANTI-PATTERN - this code left here for future developers' reference
	  Using the below method launches the app, and then be_roster sends
	  ANOTHER B_REFS_REVEIVED of its own, causing the file to be opened twice,
	  or once at the wrong location (i.e. without a line number).
	be_roster->Launch(&ref,msg);
	*/
	
	/*
	entry_ref appRef;
	be_roster->FindApp(&ref,&appRef);
	app_info appInfo;
	be_roster->GetAppInfo(&appRef,&appInfo);
	BMessenger messenger(appInfo.signature);
	messenger.SendMessage(msg,(BHandler*)NULL,B_INFINITE_TIMEOUT);
	// The above results in nothing happening unless the app is ALREADY running
	*/
	
	// Final effort - use the text_search tracker messenger mechanism
	BMessenger target("application/x-vnd.Be-TRAK");
	target.SendMessage(msg);
}
bool
PropPointEditor::HandlesType(const BString &type)
{
	return (type.ICompare("PointProperty") == 0);
}
Example #23
0
void
UrlWrapper::RefsReceived(BMessage* msg)
{
	char buff[B_PATH_NAME_LENGTH];
	int32 index = 0;
	entry_ref ref;
	char* args[] = { const_cast<char*>("urlwrapper"), buff, NULL };
	status_t err;

	while (msg->FindRef("refs", index++, &ref) == B_OK) {
		BFile f(&ref, B_READ_ONLY);
		BNodeInfo ni(&f);
		BString mimetype;
		if (f.InitCheck() == B_OK && ni.InitCheck() == B_OK) {
			ni.GetType(mimetype.LockBuffer(B_MIME_TYPE_LENGTH));
			mimetype.UnlockBuffer();

			// Internet Explorer Shortcut
			if (mimetype == "text/x-url") {
				// http://filext.com/file-extension/URL
				// http://www.cyanwerks.com/file-format-url.html
				off_t size;
				if (f.GetSize(&size) < B_OK)
					continue;
				BString contents, url;
				if (f.ReadAt(0LL, contents.LockBuffer(size), size) < B_OK)
					continue;
				while (contents.Length()) {
					BString line;
					int32 cr = contents.FindFirst('\n');
					if (cr < 0)
						cr = contents.Length();
					//contents.MoveInto(line, 0, cr);
					contents.CopyInto(line, 0, cr);
					contents.Remove(0, cr+1);
					line.RemoveAll("\r");
					if (!line.Length())
						continue;
					if (!line.ICompare("URL=", 4)) {
						line.MoveInto(url, 4, line.Length());
						break;
					}
				}
				if (url.Length()) {
					args[1] = (char*)url.String();
					err = be_roster->Launch("application/x-vnd.Be.URL.http", 1,
						args+1);
					continue;
				}
			}

			// NetPositive Bookmark or any file with a META:url attribute
			if (f.ReadAttr("META:url", B_STRING_TYPE, 0LL, buff,
				B_PATH_NAME_LENGTH) > 0) {
				err = be_roster->Launch("application/x-vnd.Be.URL.http", 1,
					args+1);
				continue;
			}
		}
	}
}
Example #24
0
void BudgetWindow::GenerateBudget(const bool &zero)
{
	// Generate a budget based on the last year's transactions
	ReportGrid income(1,0), spending(1,0);

	gDatabase.DBCommand("delete from budgetlist",
						"BudgetWindow::GenerateBudget:empty budget");

	CppSQLite3Query query;
	query = gDatabase.DBQuery("select * from categorylist order by name",
							"BudgetWindow::GenerateBudget:get categories");

	if(query.eof())
		return;

	float maxwidth=fCategoryList->StringWidth(TRANSLATE("Category"));
	while(!query.eof())
	{
		BString catname = DeescapeIllegalCharacters(query.getStringField(0));

		if(catname.ICompare(TRANSLATE("Transfer"))==0)
		{
			query.nextRow();
			continue;
		}

		bool isexpense = !query.getIntField(1);

		if(isexpense)
		{
			spending.AddItem();
			spending.SetRowTitle(spending.CountItems()-1,catname.String());
		}
		else
		{
			income.AddItem();
			income.SetRowTitle(income.CountItems()-1,catname.String());
		}
		float tempwidth = fCategoryList->StringWidth(catname.String());
		maxwidth = MAX(maxwidth,tempwidth);
		query.nextRow();
	}

	query.finalize();

	// Now that we have the list of categories, query for transactions for each
	// account from each category

	BString querystring;
	Fixed cattotal;
	for(int32 i=0; i<income.CountItems(); i++)
	{
		querystring = "";
		cattotal = 0;

		if(!zero)
		{
			for(int32 j=0; j<gDatabase.CountAccounts(); j++)
			{
				Account *acc = gDatabase.AccountAt(j);
				querystring = "select sum(amount) from account_" ;
				querystring << acc->GetID()	<< " where category = '"
							<< EscapeIllegalCharacters(income.RowTitle(i))
							<< "' and date > " << DecrementDateByYear(GetCurrentDate()) << ";";
				query = gDatabase.DBQuery(querystring.String(),
										"BudgetWindow::GenerateBudget:get category");
				cattotal.AddPremultiplied(query.getInt64Field(0));
				query.finalize();
			}
			cattotal /= 12;
			cattotal.Round();
		}
		income.SetValue(0,i,cattotal);
		gDatabase.AddBudgetEntry(BudgetEntry(income.RowTitle(i),cattotal,BUDGET_MONTHLY,false));
	}

	for(int32 i=0; i<spending.CountItems(); i++)
	{
		querystring = "";
		cattotal = 0;

		if(!zero)
		{
			for(int32 j=0; j<gDatabase.CountAccounts(); j++)
			{
				Account *acc = gDatabase.AccountAt(j);
				querystring = "select sum(amount) from account_" ;
				querystring << acc->GetID()	<< " where category = '"
							<< EscapeIllegalCharacters(spending.RowTitle(i))
							<< "';";
				query = gDatabase.DBQuery(querystring.String(),
										"BudgetWindow::GenerateBudget:get category");
				cattotal.AddPremultiplied(query.getInt64Field(0));
				query.finalize();
			}
			cattotal /= 12;
			cattotal.Round();
		}
		spending.SetValue(0,i,cattotal);
		gDatabase.AddBudgetEntry(BudgetEntry(spending.RowTitle(i),cattotal,BUDGET_MONTHLY,true));
	}
}
Example #25
0
status_t
CDDBServer::Read(const BString& category, const BString& cddbID,
	const BString& artist, ReadResponseData& readResponse, bool verbose)
{
	if (_OpenConnection() != B_OK)
		return B_ERROR;

	// Assemble the Read command.
	BString cddbCommand("cddb read ");
	cddbCommand << category << " " << cddbID;

	BString output;
	status_t result = _SendCommand(cddbCommand, output);
	if (result == B_OK) {
		if (verbose)
			puts(output);

		// Remove the header from the reply.
		output.Remove(0, output.FindFirst("\r\n\r\n") + 4);

		// Check status code.
		BString statusCode;
		output.MoveInto(statusCode, 0, 3);
		if (statusCode == "210") {
			// Remove first line and parse the others.
			output.Remove(0, output.FindFirst("\r\n") + 2);
		} else {
			// Something bad happened.
			return B_ERROR;
		}

		// Process all entries.
		bool done = false;
		while (!done) {
			if (output[0] == '#') {
				// Comment. Remove it.
				output.Remove(0, output.FindFirst("\r\n") + 2);
				continue;
			}

			// Extract one line to reduce the scope of processing to it.
			BString line;
			output.MoveInto(line, 0, output.FindFirst("\r\n"));
			output.Remove(0, 2);

			// Obtain prefix.
			BString prefix;
			line.MoveInto(prefix, 0, line.FindFirst("="));
			line.Remove(0, 1);

			if (prefix == "DTITLE") {
				// Disk title.
				BString artist;
				line.MoveInto(artist, 0, line.FindFirst(" / "));
				line.Remove(0, 3);
				readResponse.title = line;
				readResponse.artist = artist;
			} else if (prefix == "DYEAR") {
				// Disk year.
				char* firstInvalid;
				errno = 0;
				uint32 year = strtoul(line.String(), &firstInvalid, 10);
				if ((errno == ERANGE &&
					(year == (uint32)LONG_MAX || year == (uint32)LONG_MIN))
					|| (errno != 0 && year == 0)) {
					// Year out of range.
					printf("Year out of range: %s\n", line.String());
					year = 0;
				}

				if (firstInvalid == line.String()) {
					printf("Invalid year: %s\n", line.String());
					year = 0;
				}

				readResponse.year = year;
			} else if (prefix == "DGENRE") {
				// Disk genre.
				readResponse.genre = line;
			} else if (prefix.FindFirst("TTITLE") == 0) {
				// Track title.
				BString index;
				prefix.MoveInto(index, 6, prefix.Length() - 6);

				char* firstInvalid;
				errno = 0;
				uint32 track = strtoul(index.String(), &firstInvalid, 10);
				if (errno != 0 || track > 99) {
					// Track out of range.
					printf("Track out of range: %s\n", index.String());
					return B_ERROR;
				}

				if (firstInvalid == index.String()) {
					printf("Invalid track: %s\n", index.String());
					return B_ERROR;
				}

				BString trackArtist;
				int32 pos = line.FindFirst(" / ");
				if (pos >= 0 && artist.ICompare("Various") == 0) {
					// Disk is set to have a compilation artist and
					// we have track specific artist information.
					line.MoveInto(trackArtist, 0, pos);
						// Move artist information from line to artist.
					line.Remove(0, 3);
						// Remove " / " from line.
				} else {
					trackArtist = artist;
				}

				TrackData* trackData = _Track(readResponse, track);
				trackData->artist += trackArtist;
				trackData->title += line;
			}

			if (output == "" || output == ".\r\n") {
				// All returned data was processed exit the loop.
				done = true;
			}
		}
	} else {
		printf("Error sending CDDB command : \"%s\".\n", cddbCommand.String());
	}

	_CloseConnection();
	return B_OK;
}
Example #26
0
void
UrlWrapper::RefsReceived(BMessage* msg)
{
	char buff[B_PATH_NAME_LENGTH];
	int32 index = 0;
	entry_ref ref;
	char* args[] = { const_cast<char*>("urlwrapper"), buff, NULL };
	status_t err;

	while (msg->FindRef("refs", index++, &ref) == B_OK) {
		BFile f(&ref, B_READ_ONLY);
		BNodeInfo ni(&f);
		BString mimetype;
		BString extension(ref.name);
		extension.Remove(0, extension.FindLast('.') + 1);
		if (f.InitCheck() == B_OK && ni.InitCheck() == B_OK) {
			ni.GetType(mimetype.LockBuffer(B_MIME_TYPE_LENGTH));
			mimetype.UnlockBuffer();

			// Internet Explorer Shortcut
			if (mimetype == "text/x-url" || extension == "url") {
				// http://filext.com/file-extension/URL
				// http://www.cyanwerks.com/file-format-url.html
				off_t size;
				if (f.GetSize(&size) < B_OK)
					continue;
				BString contents;
				BString url;
				if (f.ReadAt(0LL, contents.LockBuffer(size), size) < B_OK)
					continue;
				contents.UnlockBuffer();
				while (contents.Length()) {
					BString line;
					int32 cr = contents.FindFirst('\n');
					if (cr < 0)
						cr = contents.Length();
					//contents.MoveInto(line, 0, cr);
					contents.CopyInto(line, 0, cr);
					contents.Remove(0, cr+1);
					line.RemoveAll("\r");
					if (!line.Length())
						continue;
					if (!line.ICompare("URL=", 4)) {
						line.MoveInto(url, 4, line.Length());
						break;
					}
				}
				if (url.Length()) {
					BPrivate::Support::BUrl u(url.String());
					args[1] = (char*)u.String();
					mimetype = kURLHandlerSigBase;
					mimetype += u.Proto();
					err = be_roster->Launch(mimetype.String(), 1, args + 1);
					if (err != B_OK && err != B_ALREADY_RUNNING)
						err = be_roster->Launch(kAppSig, 1, args + 1);
					continue;
				}
			}
			if (mimetype == "text/x-webloc" || extension == "webloc") {
				// OSX url shortcuts
				// XML file + resource fork
				off_t size;
				if (f.GetSize(&size) < B_OK)
					continue;
				BString contents;
				BString url;
				if (f.ReadAt(0LL, contents.LockBuffer(size), size) < B_OK)
					continue;
				contents.UnlockBuffer();
				int state = 0;
				while (contents.Length()) {
					BString line;
					int32 cr = contents.FindFirst('\n');
					if (cr < 0)
						cr = contents.Length();
					contents.CopyInto(line, 0, cr);
					contents.Remove(0, cr+1);
					line.RemoveAll("\r");
					if (!line.Length())
						continue;
					int32 s, e;
					switch (state) {
						case 0:
							if (!line.ICompare("<?xml", 5))
								state = 1;
							break;
						case 1:
							if (!line.ICompare("<plist", 6))
								state = 2;
							break;
						case 2:
							if (!line.ICompare("<dict>", 6))
								state = 3;
							break;
						case 3:
							if (line.IFindFirst("<key>URL</key>") > -1)
								state = 4;
							break;
						case 4:
							if ((s = line.IFindFirst("<string>")) > -1
								&& (e = line.IFindFirst("</string>")) > s) {
								state = 5;
								s += 8;
								line.MoveInto(url, s, e - s);
								break;
							} else
								state = 3;
							break;
						default:
							break;
					}
					if (state == 5) {
						break;
					}
				}
				if (url.Length()) {
					BPrivate::Support::BUrl u(url.String());
					args[1] = (char*)u.String();
					mimetype = kURLHandlerSigBase;
					mimetype += u.Proto();
					err = be_roster->Launch(mimetype.String(), 1, args + 1);
					if (err != B_OK && err != B_ALREADY_RUNNING)
						err = be_roster->Launch(kAppSig, 1, args + 1);
					continue;
				}
			}

			// NetPositive Bookmark or any file with a META:url attribute
			if (f.ReadAttr("META:url", B_STRING_TYPE, 0LL, buff,
				B_PATH_NAME_LENGTH) > 0) {
				BPrivate::Support::BUrl u(buff);
				args[1] = (char*)u.String();
				mimetype = kURLHandlerSigBase;
				mimetype += u.Proto();
				err = be_roster->Launch(mimetype.String(), 1, args + 1);
				if (err != B_OK && err != B_ALREADY_RUNNING)
					err = be_roster->Launch(kAppSig, 1, args + 1);
				continue;
			}
		}
	}
}
Example #27
0
status_t
BeIDE2Paladin(const char *path, BString &outpath)
{
	status_t returnVal = BEntry(path).InitCheck();
	if (returnVal != B_OK)
		return returnVal;
	
	BeIDEProject beide(path);
	if (beide.InitCheck() != B_OK)
		return beide.InitCheck();
	
	DPath dpath(path);
	Project proj(dpath.GetBaseName(), beide.TargetName());
	proj.SetPlatform(PLATFORM_R5);

	// NOTE: TARGET_* from Project.h & TARGET_* from BeIDEPRoject.h
	// map perfectly, so no explicit conversion required
	proj.SetTargetType(beide.TargetType());
	
	BString savepath(dpath.GetFolder());
	savepath << "/" << dpath.GetBaseName() << ".pld";
	proj.Save(savepath.String());
	
	for (int32 i = 0; i < beide.CountLocalIncludes(); i++)
	{
		BString include = beide.LocalIncludeAt(i);
		
		if (include.ICompare("{project}") == 0)
			continue;
		
		include.RemoveFirst("{project}/");
		proj.AddLocalInclude(include.String());
	}

	for (int32 i = 0; i < beide.CountSystemIncludes(); i++)
	{
		BString include = beide.SystemIncludeAt(i);
		
		if (include.ICompare("{project}") == 0)
			continue;
		
		include.RemoveFirst("{project}/");
		proj.AddSystemInclude(include.String());
	}
	
	SourceGroup *currentGroup = NULL;
	for (int32 i = 0; i < beide.CountFiles(); i++)
	{
		ProjectFile file = beide.FileAt(i);

		if (file.path.FindFirst("/_KERNEL_") > 0)
			continue;

		SourceFile *srcFile = gFileFactory.CreateSourceFileItem(file.path.String());
		
		if (!srcFile)
			continue;
		
		if (dynamic_cast<SourceFileLib*>(srcFile))
		{
			proj.AddLibrary(srcFile->GetPath().GetFileName());
			delete srcFile;
			continue;
		}
		
		if (!proj.HasGroup(file.group.String()))
			currentGroup = proj.AddGroup(file.group.String());

		BPath newPath;
		if (proj.LocateFile(srcFile->GetPath().GetFullPath(), newPath))
			srcFile->SetPath(newPath.Path());

		proj.AddFile(srcFile, currentGroup);
	}
	
	uint32 codeFlags = beide.CodeGenerationFlags();
	if (codeFlags & CODEGEN_DEBUGGING)
		proj.SetDebug(true);
	
	if (codeFlags & CODEGEN_OPTIMIZE_SIZE)
		proj.SetOpForSize(true);
	
	proj.SetOpLevel(beide.OptimizationMode());
	
	// Because Paladin doesn't currently support the seemingly 50,000 warning
	// types, we'll put them in the compiler options for the ones not commonly
	// used
	BString options;
	
	uint32 warnings = beide.Warnings();
	if (warnings & WARN_STRICT_ANSI)
		options << "-pedantic ";
	
	if (warnings & WARN_LOCAL_SHADOW)
		options << "-Wshadow ";
	
	if (warnings & WARN_INCOMPATIBLE_CAST)
		options << "-Wbad-function-cast ";
	
	if (warnings & WARN_CAST_QUALIFIERS)
		options << "-Wcast-qual ";
	
	if (warnings & WARN_CONFUSING_CAST)
		options << "-Wconversion ";
	
	if (warnings & WARN_CANT_INLINE)
		options << "-Winline ";
	
	if (warnings & WARN_EXTERN_TO_INLINE)
		options << "-Wextern-inline ";
	
	if (warnings & WARN_OVERLOADED_VIRTUALS)
		options << "-Woverloaded-virtual ";
	
	if (warnings & WARN_C_CASTS)
		options << "-Wold-style-cast ";
	
	if (warnings & WARN_EFFECTIVE_CPP)
		options << "-Weffc++ ";
	
	if (warnings & WARN_MISSING_PARENTHESES)
		options << "-Wparentheses ";
	
	if (warnings & WARN_INCONSISTENT_RETURN)
		options << "-Wreturn-type ";
	
	if (warnings & WARN_MISSING_ENUM_CASES)
		options << "-Wswitch ";
	
	if (warnings & WARN_UNUSED_VARS)
		options << "-Wunusued ";
	
	if (warnings & WARN_UNINIT_AUTO_VARS)
		options << "-Wuninitialized ";
	
	if (warnings & WARN_INIT_REORDERING)
		options << "-Wreorder ";
	
	if (warnings & WARN_NONVIRTUAL_DESTRUCTORS)
		options << "-Wnon-virtual-dtor ";
	
	if (warnings & WARN_UNRECOGNIZED_PRAGMAS)
		options << "-Wunknown-pragmas ";
	
	if (warnings & WARN_SIGNED_UNSIGNED_COMP)
		options << "-Wsign-compare ";
	
	if (warnings & WARN_CHAR_SUBSCRIPTS)
		options << "-Wchar-subscripts ";
	
	if (warnings & WARN_PRINTF_FORMATTING)
		options << "-Wformat ";
	
	if (warnings & WARN_TRIGRAPHS_USED)
		options << "-Wtrigraphs ";
	
	uint32 langopts = beide.LanguageOptions();
	if (langopts & LANGOPTS_ANSI_C_MODE)
		options << "-ansi ";
	
	if (langopts & LANGOPTS_SUPPORT_TRIGRAPHS)
		options << "-trigraphs ";
	
	if (langopts & LANGOPTS_SIGNED_CHAR)
		options << "-fsigned-char ";
	
	if (langopts & LANGOPTS_UNSIGNED_BITFIELDS)
		options << "-funsigned-bitfields ";
	
	if (langopts & LANGOPTS_CONST_CHAR_LITERALS)
		options << "-Wwrite-strings ";
	
	options << beide.ExtraCompilerOptions();
	proj.SetExtraCompilerOptions(options.String());
	proj.SetExtraLinkerOptions(beide.ExtraLinkerOptions());
	
	proj.Save();
	
	outpath = savepath;
	
	return B_OK;
}
bool
PropEnumEditor::HandlesType(const BString &type)
{
	return (type.ICompare("EnumProperty") == 0);
}
Example #29
0
bool
ClientWindow::ParseCmd (const char *data)
{
	BString firstWord (GetWord(data, 1).ToUpper());
		


	if (firstWord == "/WALLOPS"	// we need to insert a ':' before parm2
	||  firstWord == "/SQUIT"   // for the user
	||  firstWord == "/PRIVMSG")
	{
		BString theCmd (firstWord.RemoveAll ("/")),
	            theRest (RestOfString (data, 2));
		
		BMessage send (M_SERVER_SEND);
		AddSend (&send, theCmd);
		if (theRest != "-9z99")
		{
			AddSend (&send, " :");
			AddSend (&send, theRest);
		}
		AddSend (&send, endl);	

		return true;
	}

	if (firstWord == "/KILL")	// we need to insert a ':' before parm3
	{                           // for the user
		BString theCmd (firstWord.RemoveAll ("/")),
				theTarget (GetWord (data, 2)),
	            theRest (RestOfString (data, 3));
		
		BMessage send (M_SERVER_SEND);		
		AddSend (&send, theCmd);
		AddSend (&send, " ");
		AddSend (&send, theTarget);
		if (theRest != "-9z99")
		{
			AddSend (&send, " :");
			AddSend (&send, theRest);
		}
		AddSend (&send, endl);	

		return true;
	}


	// some quick aliases for scripts, these will of course be
	// moved to an aliases section eventually
	
	if (firstWord == "/SOUNDPLAY"
	||  firstWord == "/CL-AMP")
	{
		app_info ai;
		be_app->GetAppInfo (&ai);
		
		BEntry entry (&ai.ref);
		BPath path;
		entry.GetPath (&path);
		path.GetParent (&path);
		//path.Append ("data");
		path.Append ("scripts");
		
		if (firstWord == "/SOUNDPLAY")
			path.Append ("soundplay-hey");
		else
			path.Append ("cl-amp-clr");
		
		BMessage *msg (new BMessage);
		msg->AddString ("exec", path.Path());
		msg->AddPointer ("client", this);
		
		thread_id execThread = spawn_thread (
			ExecPipe,
			"exec_thread",
			B_LOW_PRIORITY,
			msg);

		resume_thread (execThread);
	
		return true;
	}
		


	if (firstWord == "/ABOUT")
	{
		be_app_messenger.SendMessage (B_ABOUT_REQUESTED);
		
		return true;
	}
	
	
	if (firstWord == "/AWAY")
	{
		BString theReason (RestOfString (data, 2));
		BString tempString;
	
	
		if (theReason != "-9z99")
		{
			//nothing to do
		}
		else
		{
			theReason = "BRB"; // Todo: make a default away msg option
		}
	
		const char *expansions[1];
		expansions[0] = theReason.String();
		
		tempString = ExpandKeyed (bowser_app->GetCommand (CMD_AWAY).String(), "R",
			expansions);
		tempString.RemoveFirst("\n");
	
		BMessage send (M_SERVER_SEND);
		AddSend (&send, "AWAY");
		AddSend (&send, " :");
		AddSend (&send, theReason.String());
		AddSend (&send, endl);
		
		if (id != serverName)
		{
			ActionMessage (tempString.String(), myNick.String());
		}
		
		return true;	
	}
	
	
	if (firstWord == "/BACK")
	{
		BMessage send (M_SERVER_SEND);
	
		AddSend (&send, "AWAY");
		AddSend (&send, endl);
	
		if (id != serverName)
		{
			ActionMessage (
				bowser_app->GetCommand (CMD_BACK).String(),
				myNick.String());
		}
		
		return true;
	}
	
	
	if (firstWord == "/CHANSERV"
	||  firstWord == "/NICKSERV"
	||  firstWord == "/MEMOSERV")
	{
		BString theCmd (firstWord.RemoveFirst ("/")),
				theRest (RestOfString (data, 2));
		theCmd.ToLower();
	
		if (theRest != "-9z99")
		{
			if (bowser_app->GetMessageOpenState())
			{
				BMessage msg (OPEN_MWINDOW);
				BMessage buffer (M_SUBMIT);
	
				buffer.AddString ("input", theRest.String());
				msg.AddMessage ("msg", &buffer);
				msg.AddString ("nick", theCmd.String());
				sMsgr.SendMessage (&msg);
			}
			else
			{
				BString tempString;
				
				tempString << "[M]-> " << theCmd << " > " << theRest << "\n";
				Display (tempString.String(), 0);
	
				BMessage send (M_SERVER_SEND);
				AddSend (&send, "PRIVMSG ");
				AddSend (&send, theCmd);
				AddSend (&send, " :");
				AddSend (&send, theRest);
				AddSend (&send, endl);
			}
		}
		
		return true;
	}
	
	
	if (firstWord == "/CLEAR")
	{
		text->ClearView (false);
		return true;
	}

	if (firstWord == "/FCLEAR")
	{
		text->ClearView (true);
		return true;
	}
	
	
	if (firstWord == "/CTCP")
	{
		BString theTarget (GetWord (data, 2));
		BString theAction (RestOfString (data, 3));
	
		if (theAction != "-9z99")
		{
			theAction.ToUpper();
	
			if (theAction.ICompare ("PING") == 0)
			{
				time_t now (time (0));
	
				theAction << " " << now;
			}
	
			CTCPAction (theTarget, theAction);
	
			BMessage send (M_SERVER_SEND);
			AddSend (&send, "PRIVMSG ");
			AddSend (&send, theTarget << " :\1" << theAction << "\1");
			AddSend (&send, endl);
		}
		
		return true;
	}
	
	
	if (firstWord == "/DCC")
	{
		BString secondWord (GetWord (data, 2));
		BString theNick (GetWord (data, 3));
		BString theFile (RestOfString(data, 4));
		
		if (secondWord.ICompare ("SEND") == 0
		&&  theNick != "-9z99")
		{
			BMessage *msg (new BMessage (CHOSE_FILE));
			msg->AddString ("nick", theNick.String());
			if (theFile != "-9z99")
			{	
				char filePath[B_PATH_NAME_LENGTH] = "\0";
				if (theFile.ByteAt(0) != '/')
				{
					find_directory(B_USER_DIRECTORY, 0, false, filePath, B_PATH_NAME_LENGTH);
					filePath[strlen(filePath)] = '/';
				}
				strcat(filePath, theFile.LockBuffer(0));
				theFile.UnlockBuffer();
	
				// use BPath to resolve relative pathnames, above code forces it
				// to use /boot/home as a working dir as opposed to the app path
	
				BPath sendPath(filePath, NULL, true);
				
				// the BFile is used to verify if the file exists
				// based off the documentation get_ref_for_path *should*
				// return something other than B_OK if the file doesn't exist
				// but that doesn't seem to be working correctly
				
				BFile sendFile(sendPath.Path(), B_READ_ONLY);
				
				// if the file exists, send, otherwise drop to the file panel
				
				if (sendFile.InitCheck() == B_OK)
				{
					sendFile.Unset();
					entry_ref ref;
					get_ref_for_path(sendPath.Path(), &ref);
					msg->AddRef("refs", &ref);
					sMsgr.SendMessage(msg);	
					return true;	
				}
			}
			BFilePanel *myPanel (new BFilePanel);
			BString myTitle ("Sending a file to ");
	
			myTitle.Append (theNick);
			myPanel->Window()->SetTitle (myTitle.String());
	
			myPanel->SetMessage (msg);
	
			myPanel->SetButtonLabel (B_DEFAULT_BUTTON, "Send");
			myPanel->SetTarget (sMsgr);
			myPanel->Show();
		}
		else if (secondWord.ICompare ("CHAT") == 0
		&&       theNick != "-9z99")
		{
			BMessage msg (CHAT_ACTION);
	
			msg.AddString ("nick", theNick.String());
	
			sMsgr.SendMessage (&msg);
		}
		
		return true;
	}
	
	
	if (firstWord == "/DOP" || firstWord == "/DEOP")
	{
		BString theNick (RestOfString (data, 2));

		if (theNick != "-9z99")
		{
			BMessage send (M_SERVER_SEND);
	
			AddSend (&send, "MODE ");
			AddSend (&send, id);
			AddSend (&send, " -oooo ");
			AddSend (&send, theNick);
			AddSend (&send, endl);
		}
		
		return true;
	}
	
	
	if (firstWord == "/DESCRIBE")
	{
    	BString theTarget (GetWord (data, 2));
		BString theAction (RestOfString (data, 3));
		
		if (theAction != "-9z99") {
		
			BMessage send (M_SERVER_SEND);
	
			AddSend (&send, "PRIVMSG ");
			AddSend (&send, theTarget);
			AddSend (&send, " :\1ACTION ");
			AddSend (&send, theAction);
			AddSend (&send, "\1");
			AddSend (&send, endl);
		
			BString theActionMessage ("[ACTION]-> ");
			theActionMessage << theTarget << " -> " << theAction << "\n";
	
			Display (theActionMessage.String(), 0);
		}
		
		return true;
	}
		
	
	if (firstWord == "/DNS")
	{
		BString parms (GetWord(data, 2));
	
		ChannelWindow *window;
		MessageWindow *message;
		
		if ((window = dynamic_cast<ChannelWindow *>(this)))
		{
				int32 count (window->namesList->CountItems());
				
				for (int32 i = 0; i < count; ++i)
				{
					NameItem *item ((NameItem *)(window->namesList->ItemAt (i)));
					
					if (!item->Name().ICompare (parms.String(), strlen (parms.String()))) //nick
					{
						BMessage send (M_SERVER_SEND);
						AddSend (&send, "USERHOST ");
						AddSend (&send, item->Name().String());
						AddSend (&send, endl);
						PostMessage(&send);	
						return true;				
					}
				}
		}
	
		else if ((message = dynamic_cast<MessageWindow *>(this)))
		{
			BString eid (id);
			eid.RemoveLast (" [DCC]");
			if (!ICompare(eid, parms) || !ICompare(myNick, parms))
			{
				BMessage send (M_SERVER_SEND);
				AddSend (&send, "USERHOST ");
				AddSend (&send, parms.String());
				AddSend (&send, endl);
				PostMessage(&send);
				return true;
			}
		}
			
		if (parms != "-9z99")
		{
			BMessage *msg (new BMessage);
			msg->AddString ("lookup", parms.String());
			msg->AddPointer ("client", this);
			
			thread_id lookupThread = spawn_thread (
				DNSLookup,
				"dns_lookup",
				B_LOW_PRIORITY,
				msg);
	
			resume_thread (lookupThread);
		}
		
		return true;
	}
	
	
	if (firstWord == "/PEXEC") // piped exec
	{
		
		BString theCmd (RestOfString (data, 2));
		
		if (theCmd != "-9z99")
		{
			BMessage *msg (new BMessage);
			msg->AddString ("exec", theCmd.String());
			msg->AddPointer ("client", this);
			
			thread_id execThread = spawn_thread (
				ExecPipe,
				"exec_thread",
				B_LOW_PRIORITY,
				msg);
	
			resume_thread (execThread);
		
		}
		
		return true;
	
	}
	
	
	if (firstWord == "/EXCLUDE")
	{
		BString second (GetWord (data, 2)),
			rest (RestOfString (data, 3));
	
		if (rest != "-9z99" && rest != "-9z99")
		{
			BMessage msg (M_EXCLUDE_COMMAND);
	
			msg.AddString ("second", second.String());
			msg.AddString ("cmd", rest.String());
			msg.AddString ("server", serverName.String());
			msg.AddRect ("frame", Frame());
			bowser_app->PostMessage (&msg);	
		}
		
		return true;
	}
	
	
	if (firstWord == "/IGNORE")
	{
		BString rest (RestOfString (data, 2));
	
		if (rest != "-9z99")
		{
			BMessage msg (M_IGNORE_COMMAND);
	
			msg.AddString ("cmd", rest.String());
			msg.AddString ("server", serverName.String());
			msg.AddRect ("frame", Frame());
			bowser_app->PostMessage (&msg);
		}
		
		return true;
	}	
	
	if (firstWord == "/INVITE" || firstWord == "/I")
	{

		BString theUser (GetWord (data, 2));

		if (theUser != "-9z99")
		{
			BString theChan (GetWord (data, 3));
	
			if (theChan == "-9z99")
				theChan = id;
	
			BMessage send (M_SERVER_SEND);
	
			AddSend (&send, "INVITE ");
			AddSend (&send, theUser << " " << theChan);
			AddSend (&send, endl);
		}
		
		return true;	
	}
	
	
	if (firstWord == "/JOIN" || firstWord == "/J")
	{
		BString channel (GetWord (data, 2));

		if (channel != "-9z99")
		{
			if (channel[0] != '#' && channel[0] != '&')
				channel.Prepend("#");

			BMessage send (M_SERVER_SEND);

			AddSend (&send, "JOIN ");
			AddSend (&send, channel);

			BString key (GetWord (data, 3));
			if (key != "-9z99")
			{
				AddSend (&send, " ");
				AddSend (&send, key);
			}
	
			AddSend (&send, endl);
		}
		
		return true;
	}
	
	if (firstWord == "/KICK" || firstWord == "/K")
	{
		BString theNick (GetWord (data, 2));
	
		if (theNick != "-9z99")
		{
			BString theReason (RestOfString (data, 3));
	
			if (theReason == "-9z99")
			{
				// No expansions
				theReason = bowser_app
					->GetCommand (CMD_KICK);
			}
	
			BMessage send (M_SERVER_SEND);
	
			AddSend (&send, "KICK ");
			AddSend (&send, id);
			AddSend (&send, " ");
			AddSend (&send, theNick);
			AddSend (&send, " :");
			AddSend (&send, theReason);
			AddSend (&send, endl);
		}
		
		return true;
	}
	
	
	if (firstWord == "/LIST")
	{
		BMessage msg (M_LIST_COMMAND);

		msg.AddString ("cmd", data);
		msg.AddString ("server", serverName.String());
		msg.AddRect ("frame", Frame());
		bowser_app->PostMessage (&msg);
	
		return true;
	}
	
	
	if (firstWord == "/M")
	{
		BString theMode (RestOfString (data, 2));
		
		BMessage send (M_SERVER_SEND);
		AddSend (&send, "MODE ");
	
		if (id == serverName)
			AddSend (&send, myNick);
		else if (id[0] == '#' || id[0] == '&')
			AddSend (&send, id);
		else
			AddSend (&send, myNick);
		 
		if (theMode != "-9z99")
		{
				AddSend (&send, " ");
				AddSend (&send, theMode);
		}

		AddSend (&send, endl);
	
		return true;
	}
	
	
	if (firstWord == "/ME")
	{
		BString theAction (RestOfString (data, 2));

		if (theAction != "-9z99")
		{
			ActionMessage (theAction.String(), myNick.String());
		}
		
		return true;
	}

		
	if (firstWord == "/MODE")
	{
		BString theMode (RestOfString (data, 3));
		BString theTarget (GetWord (data, 2));

		if (theTarget != "-9z99")
		{
			BMessage send (M_SERVER_SEND);
	
			AddSend (&send, "MODE ");
	
			if (theMode == "-9z99")
				AddSend (&send, theTarget);
			else
				AddSend (&send, theTarget << " " << theMode);
	
			AddSend (&send, endl);
		}
		
		return true;
	}
	
	
	if (firstWord == "/MSG")
	{
		BString theRest (RestOfString (data, 3));
		BString theNick (GetWord (data, 2));
	
		if (theRest != "-9z99"
		&&  myNick.ICompare (theNick))
		{
			if (bowser_app->GetMessageOpenState())
			{
				BMessage msg (OPEN_MWINDOW);
				BMessage buffer (M_SUBMIT);
	
				buffer.AddString ("input", theRest.String());
				msg.AddMessage ("msg", &buffer);
				msg.AddString ("nick", theNick.String());
				sMsgr.SendMessage (&msg);
			}
			else
			{
				BString tempString;
				
				tempString << "[M]-> " << theNick << " > " << theRest << "\n";
				Display (tempString.String(), 0);
	
				BMessage send (M_SERVER_SEND);
				AddSend (&send, "PRIVMSG ");
				AddSend (&send, theNick);
				AddSend (&send, " :");
				AddSend (&send, theRest);
				AddSend (&send, endl);
			}

		}
		return true;
	}	
		
	if (firstWord == "/NICK")
	{
		BString newNick (GetWord (data, 2));

		if (newNick != "-9z99")
		{
			BString tempString ("*** Trying new nick ");
	
			tempString << newNick << ".\n";
			Display (tempString.String(), 0);
	
			BMessage send (M_SERVER_SEND);
			AddSend (&send, "NICK ");
			AddSend (&send, newNick);
			AddSend (&send, endl);
		}
		
		return true;
	}
	
	
	if (firstWord == "/NOTICE")
	{
		BString theTarget (GetWord (data, 2));
		BString theMsg (RestOfString (data, 3));
	
		if (theMsg != "-9z99")
		{
			BMessage send (M_SERVER_SEND);
	
			AddSend (&send, "NOTICE ");
			AddSend (&send, theTarget);
			AddSend (&send, " :");
			AddSend (&send, theMsg);
			AddSend (&send, endl);
	
			BString tempString ("[N]-> ");
			tempString << theTarget << " -> " << theMsg << '\n';
	
			Display (tempString.String(), 0);
		}
		
		return true;
	}
	
	
	if (firstWord == "/NOTIFY")
	{
		BString rest (RestOfString (data, 2));
	
		if (rest != "-9z99")
		{
			BMessage msg (M_NOTIFY_COMMAND);
	
			msg.AddString ("cmd", rest.String());
			msg.AddBool ("add", true);
			msg.AddString ("server", serverName.String());
			msg.AddRect ("frame", Frame());
			bowser_app->PostMessage (&msg);
		}
		
		return true;
	}

	if (firstWord == "/OP")
	{
		BString theNick (RestOfString (data, 2));
	
		if (theNick != "-9z99")
		{
			// TODO only applies to a channel
	
			BMessage send (M_SERVER_SEND);
	
			AddSend (&send, "MODE ");
			AddSend (&send, id);
			AddSend (&send, " +oooo ");
			AddSend (&send, theNick);
			AddSend (&send, endl);
		}
		
		return true;
	}
	

	if (firstWord == "/PART")
	{
		BMessage msg (B_QUIT_REQUESTED);

		msg.AddBool ("bowser:part", true);
		PostMessage (&msg);

		return true;
	}	
	
	
	if (firstWord == "/PING")
	{
		BString theNick (GetWord (data, 2));
	
		if (theNick != "-9z99")
		{
			long theTime (time (0));
			BString tempString ("/CTCP ");
	
			tempString << theNick << " PING " << theTime;
			SlashParser (tempString.String());
		}
	
		return true;
	}
	
	
	if (firstWord == "/PREFERENCES")
	{
		be_app_messenger.SendMessage (M_PREFS_BUTTON);
		
		return true;
	}
	
	
	if (firstWord == "/QUERY" || firstWord == "/Q")
	{
		BString theNick (GetWord (data, 2));

		if (theNick != "-9z99")
		{
			BMessage msg (OPEN_MWINDOW);
	
			msg.AddString ("nick", theNick.String());
			sMsgr.SendMessage (&msg);
		}
	
		return true;	
	}

	
	if (firstWord == "/QUIT")
	{
		BString theRest (RestOfString (data, 2));
		BString buffer;
	
		if (theRest == "-9z99")
		{
			const char *expansions[1];
			BString version (bowser_app->BowserVersion());
	
			expansions[0] = version.String();
			theRest = ExpandKeyed (bowser_app
				->GetCommand (CMD_QUIT).String(), "V", expansions);
		}
	
		buffer << "QUIT :" << theRest;
	
		BMessage msg (B_QUIT_REQUESTED);
		msg.AddString ("bowser:quit", buffer.String());
		sMsgr.SendMessage (&msg);
	
		return true;
	}
	
	
	if (firstWord == "/RAW" || firstWord == "/QUOTE")
	{

		BString theRaw (RestOfString (data, 2));
	
		if (theRaw != "-9z99")
		{
			BMessage send (M_SERVER_SEND);
	
			AddSend (&send, theRaw);
			AddSend (&send, endl);
	
			BString tempString ("[R]-> ");
			tempString << theRaw << '\n';
	
			Display (tempString.String(), 0);
	
		}
		
		return true;
	}
	
	
	if (firstWord == "/RECONNECT")
	{
		BMessage msg (M_SLASH_RECONNECT);
		msg.AddString ("server", serverName.String());
		bowser_app->PostMessage (&msg);
		return true;
	}
	
	
	if (firstWord == "/SLEEP")
	{
		BString rest (RestOfString (data, 2));
	
		if (rest != "-9z99")
		{
			// this basically locks up the window its run from,
			// but I can't think of a better way with our current
			// commands implementation
			int32 time = atoi(rest.String());
			snooze(time * 1000 * 100); // deciseconds? 10 = one second
		}
		
		return true;
	
	}
	
		
	if (firstWord == "/TOPIC" || firstWord == "/T")
	{
		BString theChan (id);
		BString theTopic (RestOfString (data, 2));
		BMessage send (M_SERVER_SEND);
	
		AddSend (&send, "TOPIC ");
	
		if (theTopic == "-9z99")
			AddSend (&send, theChan);
		else
			AddSend (&send, theChan << " :" << theTopic);
		AddSend (&send, endl);
		
		return true;
	}
	
	
	if (firstWord == "/UNIGNORE")
	{
		BString rest (RestOfString (data, 2));
	
		if (rest != "-9z99")
		{
			BMessage msg (M_UNIGNORE_COMMAND);
	
			msg.AddString ("cmd", rest.String());
			msg.AddString ("server", serverName.String());
			msg.AddRect ("frame", Frame());
			bowser_app->PostMessage (&msg);
		}
	
		return true;
	}
	
	
	if (firstWord == "/UNNOTIFY")
	{
		BString rest (RestOfString (data, 2));
	
		if (rest != "-9z99")
		{
			BMessage msg (M_NOTIFY_COMMAND);
	
			msg.AddString ("cmd", rest.String());
			msg.AddBool ("add", false);
			msg.AddRect ("frame", Frame());
			msg.AddString ("server", serverName.String());
			bowser_app->PostMessage (&msg);
		}
	
		return true;
	}
	
	
	if (firstWord == "/UPTIME")
	{
		BString parms (GetWord(data, 2));
		
		BString uptime (DurationString(system_time()));
		BString expandedString;
		const char *expansions[1];
		expansions[0] = uptime.String();
		expandedString = ExpandKeyed (bowser_app->GetCommand (CMD_UPTIME).String(), "U",
			expansions);
		expandedString.RemoveFirst("\n");
	
		if ((id != serverName) && (parms == "-9z99"))
		{
			BMessage send (M_SERVER_SEND);
			
			AddSend (&send, "PRIVMSG ");
			AddSend (&send, id);
			AddSend (&send, " :");
			AddSend (&send, expandedString.String());
			AddSend (&send, endl);
			
			ChannelMessage (expandedString.String(), myNick.String());
		}
		else if ((parms == "-l") || (id == serverName)) // echo locally
		{
			BString tempString;
				
			tempString << "Uptime: " << expandedString << "\n";
			Display (tempString.String(), &whoisColor);
			
		}
		
		return true;
	}
	
	
	if (firstWord == "/VERSION"
	||  firstWord == "/TIME")
	{
		BString theCmd (firstWord.RemoveFirst ("/")),
				theNick (GetWord (data, 2));
		theCmd.ToUpper();
	
		// the "." check is because the user might specify a server name
		
		if (theNick != "-9z99" && theNick.FindFirst(".") < 0)
		{
			BString tempString ("/CTCP ");
	
			tempString << theNick << " " << theCmd;
			SlashParser (tempString.String());
		}
		else
		{
		  	BMessage send (M_SERVER_SEND);
	
			AddSend (&send, theCmd);
			
			if (theNick != "-9z99")
			{
				AddSend (&send, " ");
				AddSend (&send, theNick);
			}
						
			AddSend (&send, endl);
		}
		
		return true;
	}
	
	
	if (firstWord == "/VISIT")
	{
		BString buffer (data);
		int32 place;
	
		if ((place = buffer.FindFirst (" ")) >= 0)
		{
			buffer.Remove (0, place + 1);
	
			const char *arguments[] = {buffer.String(), 0};
			
			
	
			be_roster->Launch (
				"text/html",
				1,
				const_cast<char **>(arguments));
		}
		
		return true;
	}



	if (firstWord != "" && firstWord[0] == '/')
	// != "" is required to prevent a nasty crash with string[0]
	{
		BString theCmd (firstWord.RemoveAll ("/")),
	            theRest (RestOfString (data, 2));
		
		BMessage send (M_SERVER_SEND);
		
		if (theCmd == "W")
			theCmd = "WHOIS";

		AddSend (&send, theCmd);
	
		if (theRest != "-9z99")
		{
			AddSend (&send, " ");
			AddSend (&send, theRest);
		}
		AddSend (&send, endl);	

		return true;
	}
	
	return false;  // we couldn't handle this message

}