Example #1
0
void
BUrl::_ExtractRequestAndFragment(const BString& urlString, int16* origin)
{
	// Extract request field from URL
	if (urlString.ByteAt(*origin) == '?') {
		(*origin)++;
		int16 requestEnd = urlString.FindFirst('#', *origin);

		fHasRequest = true;

		if (requestEnd == -1) {
			urlString.CopyInto(fRequest, *origin, urlString.Length() - *origin);
			return;
		} else {
			urlString.CopyInto(fRequest, *origin, requestEnd - *origin);
			*origin = requestEnd;
		}
	}

	// Extract fragment field if needed
	if (urlString.ByteAt(*origin) == '#') {
		(*origin)++;
		urlString.CopyInto(fFragment, *origin, urlString.Length() - *origin);

		fHasFragment = true;
	}
}
PlatformKeyboardEvent::PlatformKeyboardEvent(BMessage* message)
    : m_autoRepeat(false)
    , m_isKeypad(false)
    , m_shiftKey(false)
    , m_ctrlKey(false)
    , m_altKey(false)
    , m_metaKey(false)
{
    BString bytes = message->FindString("bytes");

    m_nativeVirtualKeyCode = message->FindInt32("key");

    m_text = String::fromUTF8(bytes.String(), bytes.Length());
    m_unmodifiedText = String(bytes.String(), bytes.Length());
    m_keyIdentifier = keyIdentifierForHaikuKeyCode(bytes.ByteAt(0), m_nativeVirtualKeyCode);

    m_windowsVirtualKeyCode = windowsKeyCodeForKeyEvent(bytes.ByteAt(0), m_nativeVirtualKeyCode);

    if (message->what == B_KEY_UP)
        m_type = KeyUp;
    else if (message->what == B_KEY_DOWN)
        m_type = KeyDown;

    int32 modifiers = message->FindInt32("modifiers");
    m_shiftKey = modifiers & B_SHIFT_KEY;
    m_ctrlKey = modifiers & B_COMMAND_KEY;
    m_altKey = modifiers & B_CONTROL_KEY;
    m_metaKey = modifiers & B_OPTION_KEY;
}
	bool operator()(const BString& first, const BString& second)
	{
		// sort anything starting with '<' behind anything else
		if (first.ByteAt(0) == '<') {
			if (second.ByteAt(0) != '<')
				return false;
		} else if (second.ByteAt(0) == '<')
			return true;
		return fCollator.Compare(first.String(), second.String()) < 0;
	}
Example #4
0
_EXPORT status_t
extract_from_header(const BString& header, const BString& field,
	BString& target)
{
	int32 headerLength = header.Length();
	int32 fieldEndPos = 0;
	while (true) {
		int32 pos = header.IFindFirst(field, fieldEndPos);
		if (pos < 0)
			return B_BAD_VALUE;
		fieldEndPos = pos + field.Length();
		
		if (pos != 0 && header.ByteAt(pos - 1) != '\n')
			continue;
		if (header.ByteAt(fieldEndPos) == ':')
			break;
	}
	fieldEndPos++;

	int32 crPos = fieldEndPos;
	while (true) {
		fieldEndPos = crPos;
		crPos = header.FindFirst('\n', crPos);
		if (crPos < 0)
			crPos = headerLength;
		BString temp;
		header.CopyInto(temp, fieldEndPos, crPos - fieldEndPos);
		if (header.ByteAt(crPos - 1) == '\r') {
			temp.Truncate(temp.Length() - 1);
			temp += " ";
		}
		target += temp;
		crPos++;
		if (crPos >= headerLength)
			break;
		char nextByte = header.ByteAt(crPos);
		if (nextByte != ' ' && nextByte != '\t')
			break;
		crPos++;
	}

	size_t bufferSize = target.Length();
	char* buffer = target.LockBuffer(bufferSize);
	size_t length = rfc2047_to_utf8(&buffer, &bufferSize, bufferSize);
	target.UnlockBuffer(length);

	return B_OK;
}
Example #5
0
int32_t
PTextViewDisallowChars(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;
	
	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BTextView *backend = (BTextView*)parent->GetView();
	
	PArgs *inArgs = static_cast<PArgs*>(in);
	BString string;
	if (inArgs->FindString("chars", &string) != B_OK)
		return B_ERROR;
	
	if (backend->Window())
		backend->Window()->Lock();
	
	for (int32 i = 0; i < string.CountChars(); i++)
	{
		char c = string.ByteAt(i);
		if (c)
			backend->DisallowChar(c);
	}
	
	if (backend->Window())
		backend->Window()->Unlock();
	
	return B_OK;
}
void
ShortcutsSpec::_UpdateIconBitmap()
{
	BString firstWord = ParseArgvZeroFromString(fCommand);

	// Only need to change if the first word has changed...
	if (fLastBitmapName == NULL || firstWord.Length() == 0
		|| firstWord.Compare(fLastBitmapName)) {
		if (firstWord.ByteAt(0) == '*')
			fBitmapValid = IsValidActuatorName(&firstWord.String()[1]);
		else {
			fBitmapValid = false; // default till we prove otherwise!

			if (firstWord.Length() > 0) {
				delete [] fLastBitmapName;
				fLastBitmapName = new char[firstWord.Length() + 1];
				strcpy(fLastBitmapName, firstWord.String());

				BEntry progEntry(fLastBitmapName, true);
				if ((progEntry.InitCheck() == B_NO_ERROR)
					&& (progEntry.Exists())) {
					BNode progNode(&progEntry);
					if (progNode.InitCheck() == B_NO_ERROR) {
						BNodeInfo progNodeInfo(&progNode);
						if ((progNodeInfo.InitCheck() == B_NO_ERROR)
						&& (progNodeInfo.GetTrackerIcon(&fBitmap, B_MINI_ICON)
							== B_NO_ERROR)) {
							fBitmapValid = fBitmap.IsValid();
						}
					}
				}
			}
		}
	}
}
Example #7
0
void
BUrl::_ExtractPath(const BString& urlString, int16* origin)
{
	// Extract path from URL
	if (urlString.ByteAt(*origin) == '/' || !HasAuthority()) {
		int16 pathEnd = *origin;

		while (pathEnd < urlString.Length()
				&& !_IsPathTerminator(urlString.ByteAt(pathEnd))) {
				pathEnd++;
		}

		urlString.CopyInto(fPath, *origin, pathEnd - *origin);

		*origin = pathEnd;
		fHasPath = true;
	}
}
void
HaikuMailFormatFilter::_RemoveLeadingDots(BString& name)
{
	int dots = 0;
	while (dots < name.Length() && name.ByteAt(dots) == '.')
		dots++;

	if (dots > 0)
		name.Remove(0, dots);
}
Example #9
0
status_t
POP3Protocol::_RetrieveUniqueIDs()
{
	fUniqueIDs.MakeEmpty();
	fSizes.clear();
	fTotalSize = 0;

	status_t status = SendCommand("UIDL" CRLF);
	if (status != B_OK)
		return status;

	BString result;
	int32 uidOffset;
	while (ReceiveLine(result) > 0) {
		if (result.ByteAt(0) == '.')
			break;

		uidOffset = result.FindFirst(' ') + 1;
		result.Remove(0, uidOffset);
		fUniqueIDs.Add(result);
	}

	if (SendCommand("LIST" CRLF) != B_OK)
		return B_ERROR;

	while (ReceiveLine(result) > 0) {
		if (result.ByteAt(0) == '.')
			break;

		int32 index = result.FindLast(" ");
		int32 size;
		if (index >= 0)
			size = atol(&result.String()[index]);
		else
			size = 0;

		fTotalSize += size;
		fSizes.push_back(size);
	}

	return B_OK;
}
Example #10
0
unsigned char DataFile::GetHash(BString text)
////////////////////////////////////////////////////////////////////////
{
	unsigned char result = 0;
	
	text.ToUpper();
	for (int i=0; i<text.Length(); i++)
		result ^= text.ByteAt(i);
		
	return result;
}
Example #11
0
void DataFile::Trim(BString &result)
////////////////////////////////////////////////////////////////////////
{
	if (result.Length() == 0)
		return;

	// Elejen a space-ek...	
	while (result.ByteAt(0) == ' ')
	{
		result.Remove(0, 1);
	}
	
	if (result.Length() == 0)
		return;

	// Vegen a space-ek...
	while (result.ByteAt(result.Length()-1) == ' ')
	{
		result.Remove(result.Length()-1, 1);
	}
}
Example #12
0
status_t
POP3Protocol::UniqueIDs()
{
	status_t ret = B_OK;
	runner->ReportProgress(0, 0, MDR_DIALECT_CHOICE("Getting UniqueIDs...",
		"固有のIDを取得中..."));

	ret = SendCommand("UIDL" CRLF);
	if (ret != B_OK)
		return ret;

	BString result;
	int32 uid_offset;
	while (ReceiveLine(result) > 0) {
		if (result.ByteAt(0) == '.')
			break;

		uid_offset = result.FindFirst(' ') + 1;
		result.Remove(0,uid_offset);
		unique_ids->AddItem(result.String());
	}

	if (SendCommand("LIST" CRLF) != B_OK)
		return B_ERROR;

	int32 b;
	while (ReceiveLine(result) > 0) {
		if (result.ByteAt(0) == '.')
			break;

		b = result.FindLast(" ");
		if (b >= 0)
			b = atol(&(result.String()[b]));
		else
			b = 0;
		fSizes.AddItem((void *)(b));
	}

	return ret;
}
Example #13
0
status_t
POP3Protocol::_UniqueIDs()
{
	fUniqueIDs.MakeEmpty();

	status_t ret = B_OK;

	ret = SendCommand("UIDL" CRLF);
	if (ret != B_OK)
		return ret;

	BString result;
	int32 uid_offset;
	while (ReceiveLine(result) > 0) {
		if (result.ByteAt(0) == '.')
			break;

		uid_offset = result.FindFirst(' ') + 1;
		result.Remove(0,uid_offset);
		fUniqueIDs.AddItem(result.String());
	}

	if (SendCommand("LIST" CRLF) != B_OK)
		return B_ERROR;

	int32 b;
	while (ReceiveLine(result) > 0) {
		if (result.ByteAt(0) == '.')
			break;

		b = result.FindLast(" ");
		if (b >= 0)
			b = atol(&(result.String()[b]));
		else
			b = 0;
		fSizes.AddItem((void *)(b));
	}

	return ret;
}
Example #14
0
void BWebPage::handleKeyEvent(BMessage* message)
{
    WebCore::Frame* frame = fPage->focusController()->focusedOrMainFrame();
    if (!frame->view() || !frame->document())
        return;

    PlatformKeyboardEvent event(message);
	// Try to let WebCore handle this event
	if (!frame->eventHandler()->keyEvent(event) && message->what == B_KEY_DOWN) {
		// Handle keyboard scrolling (probably should be extracted to a method.)
		ScrollDirection direction;
		ScrollGranularity granularity;
		BString bytes = message->FindString("bytes");
		switch (bytes.ByteAt(0)) {
			case B_UP_ARROW:
				granularity = ScrollByLine;
				direction = ScrollUp;
				break;
			case B_DOWN_ARROW:
				granularity = ScrollByLine;
				direction = ScrollDown;
				break;
			case B_LEFT_ARROW:
				granularity = ScrollByLine;
				direction = ScrollLeft;
				break;
			case B_RIGHT_ARROW:
				granularity = ScrollByLine;
				direction = ScrollRight;
				break;
			case B_HOME:
				granularity = ScrollByDocument;
				direction = ScrollUp;
				break;
			case B_END:
				granularity = ScrollByDocument;
				direction = ScrollDown;
				break;
			case B_PAGE_UP:
				granularity = ScrollByPage;
				direction = ScrollUp;
				break;
			case B_PAGE_DOWN:
				granularity = ScrollByPage;
				direction = ScrollDown;
				break;
			default:
				return;
		}
		frame->eventHandler()->scrollRecursively(direction, granularity);
	}
}
static bool
strip_port(BString& host, BString& port)
{
	int32 first = host.FindFirst(':');
	int32 separator = host.FindLast(':');
	if (separator != first
			&& (separator == 0 || host.ByteAt(separator - 1) != ']')) {
		return false;
	}

	if (separator != -1) {
		// looks like there is a port
		host.CopyInto(port, separator + 1, -1);
		host.Truncate(separator);

		return true;
	}

	return false;
}
void
HaikuMailFormatFilter::_RemoveExtraWhitespace(BString& name)
{
	int spaces = 0;
	for (int i = 0; i <= name.Length();) {
		if (i < name.Length() && isspace(name.ByteAt(i))) {
			spaces++;
			i++;
		} else if (spaces > 0) {
			int remove = spaces - 1;
			// Also remove leading and trailing spaces
			if (i == remove + 1 || i == name.Length())
				remove++;
			else
				name[i - spaces] = ' ';
			name.Remove(i - remove, remove);
			i -= remove;
			spaces = 0;
		} else
			i++;
	}
}
/*	isCue
*	checks if selected file is a cue file (checks by file extension)
*	if yes, returns true
*/
bool
ProjectTypeSelector::isCue()
{
	BString *SelectedFile = (BString*)FileList->FirstItem();
	BString SelectedFileTMP;
	BString FileExtension;
	BString tmp;
	
	//get file extension
	SelectedFile->CopyInto(SelectedFileTMP, 0, (int)SelectedFile->Length());
	SelectedFileTMP.RemoveAll("/");
	for(int i = 3; i > 0; i--) {
		tmp.SetTo(SelectedFileTMP.ByteAt((SelectedFileTMP.Length() - i)), 1);
		FileExtension.Insert(tmp.String(), FileExtension.Length());
	}
	
	FileExtension.ToUpper();
	if(FileExtension.Compare("CUE") == 0)
		return true;
	
	return false;
}
Example #18
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

}
Example #19
0
void
QPopupMenu::EntryCreated(const entry_ref &ref, ino_t node)
{
	BNode file;
	if (file.SetTo(&ref) < B_OK)
		return;

	// Make sure the pop-up menu is ready for additions.  Need a bunch of
	// groups at the top, a divider line, and miscellaneous people added below
	// the line.

	int32 items = CountItems();
	if (!items)
		AddSeparatorItem();

	// Does the file have a group attribute?  OK to have none.
	BString groups;
	const char *kNoGroup = "NoGroup!";
	file.ReadAttrString("META:group", &groups);
	if (groups.Length() <= 0)
		groups = kNoGroup;

	// Add the e-mail address to the all people group.  Then add it to all the
	// group menus that it exists in (based on the comma separated list of
	// groups from the People file), optionally making the group menu if it
	// doesn't exist.  If it's in the special NoGroup!  list, then add it below
	// the groups.

	bool allPeopleGroupDone = false;
	BMenu *groupMenu;
	do {
		BString group;

		if (!allPeopleGroupDone) {
			// Create the default group for all people, if it doesn't exist yet.
			group = "All People";
			allPeopleGroupDone = true;
		} else {
			// Break out the next group from the comma separated string.
			int32 comma;
			if ((comma = groups.FindFirst(',')) > 0) {
				groups.MoveInto(group, 0, comma);
				groups.Remove(0, 1);
			} else
				group.Adopt(groups);
		}

		// trim white spaces
		int32 i = 0;
		for (i = 0; isspace(group.ByteAt(i)); i++) {}
		if (i)
			group.Remove(0, i);
		for (i = group.Length() - 1; isspace(group.ByteAt(i)); i--) {}
		group.Truncate(i + 1);

		groupMenu = NULL;
		BMenuItem *superItem = NULL; // Corresponding item for group menu.

		if (group.Length() > 0 && group != kNoGroup) {
			BMenu *sub;

			// Look for submenu with label == group name
			for (int32 i = 0; i < items; i++) {
				if ((sub = SubmenuAt(i)) != NULL) {
					superItem = sub->Superitem();
					if (!strcmp(superItem->Label(), group.String())) {
						groupMenu = sub;
						i++;
						break;
					}
				}
			}

			// If no submenu, create one
			if (!groupMenu) {
				// Find where it should go (alphabetical)
				int32 mindex = 0;
				for (; mindex < fGroups; mindex++) {
					if (strcmp(ItemAt(mindex)->Label(), group.String()) > 0)
						break;
				}

				groupMenu = new BMenu(group.String());
				groupMenu->SetFont(be_plain_font);
				AddItem(groupMenu, mindex);

				superItem = groupMenu->Superitem();
				superItem->SetMessage(new BMessage(B_SIMPLE_DATA));
				if (fTargetHandler)
					superItem->SetTarget(fTargetHandler);

				fGroups++;
			}
		}

		BString	name;
		file.ReadAttrString("META:name", &name);

		BString email;
		file.ReadAttrString("META:email", &email);

		if (email.Length() != 0 || name.Length() != 0)
			AddPersonItem(&ref, node, name, email, NULL, groupMenu, superItem);

		// support for 3rd-party People apps
		for (int16 i = 2; i < 6; i++) {
			char attr[16];
			sprintf(attr, "META:email%d", i);
			if (file.ReadAttrString(attr, &email) >= B_OK && email.Length() > 0)
				AddPersonItem(&ref, node, name, email, attr, groupMenu, superItem);
		}
	} while (groups.Length() > 0);
}
Example #20
0
void
BUrl::_ExtractAuthority(const BString& urlString, int16* origin)
{
	// URI doesn't contain an authority field
	if (urlString.FindFirst("//", *origin) != *origin)
		return;

	fHasAuthority = true;

//	while (urlString.ByteAt(*origin) == '/')
//		(*origin)++;

	(*origin) += 2;


	int16 userInfoEnd = urlString.FindFirst('@', *origin);

	// URL contains userinfo field
	if (userInfoEnd != -1) {
		BString userInfo;
		urlString.CopyInto(userInfo, *origin, userInfoEnd - *origin);

		int16 colonDelimiter = userInfo.FindFirst(':', 0);

		if (colonDelimiter == *origin) {
			fHasPassword = true;
			fPassword = userInfo;
		} else if (colonDelimiter != -1) {
			fHasUserName = true;
			fHasPassword = true;

			userInfo.CopyInto(fUser, 0, colonDelimiter);
			userInfo.CopyInto(fPassword, colonDelimiter + 1,
				userInfo.Length() - colonDelimiter);
		} else {
			fHasUserName = true;
			fUser = userInfo;
		}

		fHasUserInfo = true;
		*origin = userInfoEnd + 1;
	}


	// Extract the host part
	int16 hostEnd = *origin;

	while (hostEnd < urlString.Length()
		&& !_IsAuthorityTerminator(urlString.ByteAt(hostEnd))
		&& urlString.ByteAt(hostEnd) != ':') {
		hostEnd++;
	}

	// The host is likely to be present if an authority is
	// defined, but in some weird cases, it's not.
	if (hostEnd != *origin) {
		urlString.CopyInto(fHost, *origin, hostEnd - *origin);

		*origin = hostEnd;
		fHasHost = true;
	}

	// Extract the port part
	fPort = 0;
	if (urlString.ByteAt(*origin) == ':') {
		int16 portEnd = ++(*origin);

		while (portEnd < urlString.Length()
			&& !_IsAuthorityTerminator(urlString.ByteAt(portEnd)))
			portEnd++;

		BString portString;
		urlString.CopyInto(portString, *origin, portEnd - *origin);
		fPort = atoi(portString.String());

		//  Even if the port is invalid, the URL is considered to
		// have a port.
		fHasPort = portString.Length() > 0;
		*origin = portEnd;
	}
}
nsresult nsOSHelperAppService::SetMIMEInfoForType(const char *aMIMEType, nsMIMEInfoBeOS**_retval) {

	LOG(("-- nsOSHelperAppService::SetMIMEInfoForType: %s\n",aMIMEType));

	nsresult rv = NS_ERROR_FAILURE;

	nsMIMEInfoBeOS* mimeInfo = new nsMIMEInfoBeOS(aMIMEType);
	if (mimeInfo) {
		NS_ADDREF(mimeInfo);
		BMimeType mimeType(aMIMEType);
		BMessage data;
		int32 index = 0;
		BString strData;
		LOG(("   Adding extensions:\n"));
		if (mimeType.GetFileExtensions(&data) == B_OK) {
			while (data.FindString("extensions",index,&strData) == B_OK) {
				// if the file extension includes the '.' then we don't want to include that when we append
				// it to the mime info object.
				if (strData.ByteAt(0) == '.')
					strData.RemoveFirst(".");
				mimeInfo->AppendExtension(nsDependentCString(strData.String()));
				LOG(("      %s\n",strData.String()));
				index++;
			}
		}

		char desc[B_MIME_TYPE_LENGTH + 1];
		if (mimeType.GetShortDescription(desc) == B_OK) {
			mimeInfo->SetDescription(NS_ConvertUTF8toUCS2(desc));
		} else {
			if (mimeType.GetLongDescription(desc) == B_OK) {
				mimeInfo->SetDescription(NS_ConvertUTF8toUCS2(desc));
			} else {
				mimeInfo->SetDescription(NS_ConvertUTF8toUCS2(aMIMEType));
			}
		}
		
		LOG(("    Description: %s\n",desc));

		//set preferred app and app description
		char appSig[B_MIME_TYPE_LENGTH + 1];
		bool doSave = true;
		if (mimeType.GetPreferredApp(appSig) == B_OK) {
			LOG(("    Got preferred ap\n"));
			BMimeType app(appSig);
			entry_ref ref;
			BEntry entry;
			BPath path;
			if ((app.GetAppHint(&ref) == B_OK) &&
			        (entry.SetTo(&ref, false) == B_OK) &&
			        (entry.GetPath(&path) == B_OK)) {

				LOG(("    Got our path!\n"));
				nsCOMPtr<nsIFile> handlerFile;
				rv = GetFileTokenForPath(NS_ConvertUTF8toUCS2(path.Path()).get(), getter_AddRefs(handlerFile));

				if (NS_SUCCEEDED(rv)) {
					mimeInfo->SetDefaultApplication(handlerFile);
					mimeInfo->SetPreferredAction(nsIMIMEInfo::useSystemDefault);
					mimeInfo->SetDefaultDescription(NS_ConvertUTF8toUCS2(path.Leaf()));
					LOG(("    Preferred App: %s\n",path.Leaf()));
					doSave = false;
				}
			}
		}
		if (doSave) {
			mimeInfo->SetPreferredAction(nsIMIMEInfo::saveToDisk);
			LOG(("    No Preferred App\n"));
		}

		*_retval = mimeInfo;
		rv = NS_OK;
	}
	else
		rv = NS_ERROR_FAILURE;

	return rv;
}
Example #22
0
status_t
CDDBQuery::_ReadFromServer(BString &data)
{
	// This function queries the given CDDB server for the existence of the disc's data and
	// saves the data to file once obtained.

	// Query for the existence of the disc in the database
	char idString[10];
	sprintf(idString, "%08lx", fCDData.DiscID());
	BString query;

	int32 trackCount = GetTrackCount(&fSCSIData);
	BString offsetString = OffsetsToString(&fSCSIData);	
	int32 discLength = (fCDData.DiscTime()->GetMinutes() * 60) + fCDData.DiscTime()->GetSeconds();

	query << "cddb query " << idString << ' ' << trackCount << ' ' 
			<< offsetString << ' ' << discLength << '\n';

	STRACE((">%s", query.String()));

	if (fSocket.Send(query.String(), query.Length()) == -1) {
		_Disconnect();
		return B_ERROR;
	}

	BString tmp;
	_ReadLine(tmp);
	STRACE(("<%s", tmp.String()));

	BString category;
	BString queryDiscID(idString);

	if (tmp.FindFirst("200") != 0) {
		if (tmp.FindFirst("211") == 0) {
			// A 211 means that the query was not exact. To make sure that we don't
			// have a problem with this in the future, we will choose the first entry that
			// the server returns. This may or may not be wise, but in my experience, the first
			// one has been the right one.

			_ReadLine(tmp);

			// Get the category from the what the server returned
			_GetToken(tmp.String(), category);

			// Now we will get the disc ID for the CD. We will need this when we query for
			// the track name list. If we send the track name query with the real discID, nothing
			// will be returned. However, if we send the one from the entry, we'll get the names
			// and we can take these names attach them to the disc that we have.
			_GetToken(tmp.String() + category.CountChars(), queryDiscID);

			// This is to suck up any more search results that the server sends us.
			BString throwaway;
			_ReadLine(throwaway);
			while (throwaway.ByteAt(0) != '.')
				_ReadLine(throwaway);
		} else {
			// We get here for any time the CDDB server does not recognize the CD, amongst other things
			STRACE(("CDDB lookup error: %s\n", tmp.String()));
			fCDData.SetGenre("misc");
			return B_NAME_NOT_FOUND;
		}
	} else {
		_GetToken(tmp.String() + 3, category);
	}
	STRACE(("CDDBQuery::_ReadFromServer: Genre: %s\n", category.String()));
	if (!category.Length()) {
		STRACE(("Set genre to 'misc'\n"));
		category = "misc";
	}

	// Query for the disc's data - artist, album, tracks, etc.
	query = "";
	query << "cddb read " << category << ' ' << queryDiscID << '\n' ;
	if (fSocket.Send(query.String(), query.Length()) == -1) {
		_Disconnect();
		return B_ERROR;
	}

	while (true) {
		_ReadLine(tmp);

		if (tmp == "." || tmp == ".\n")
			break;

		data << tmp << '\n';
	}

	return B_OK;
}