Example #1
0
void
SourceFileRez::Compile(BuildInfo &info, const char *options)
{
	BString abspath = GetPath().GetFullPath();
	if (abspath[0] != '/')
	{
		abspath.Prepend("/");
		abspath.Prepend(info.projectFolder.GetFullPath());
	}
	
	if (BString(GetPath().GetExtension()).ICompare("r") != 0)
		return;
	
	BString pipestr = "rez -t ";
	
	for (int32 i = 0; i < info.includeList.CountItems(); i++)
		pipestr << "'-I" << info.includeList.ItemAt(i)->Absolute() << "' ";
	
	pipestr << "-o '" << GetResourcePath(info).GetFullPath()
			<< "' '" << GetTempFilePath(info).GetFullPath() << "' 2>&1";
	
	FILE *fd = popen(pipestr.String(),"r");
	if (!fd)
		return;
	
	char buffer[1024];
	BString errmsg;
	while (fgets(buffer,1024,fd))
		errmsg += buffer;
	pclose(fd);
	
	STRACE(1,("Compiling %s\nCommand:%s\nOutput:%s\n",
			abspath.String(),pipestr.String(),errmsg.String()));
	
	ParseRezErrors(errmsg.String(),info.errorList);
	
	if (info.errorList.msglist.CountItems() > 0)
	{
		BEntry entry(GetResourcePath(info).GetFullPath());
		entry.Remove();
	}
}
status_t
SVNSourceControl::GetCheckinHeader(BString &out)
{
	GetChangeStatus(out);
	
	out.Prepend("SVN: \nAll lines starting with 'SVN:' will be ignored.\n"
				"----------------------------------------------------\n");
	out.ReplaceAll("\n", "\nSVN: ");
	
	return B_OK;
}
Example #3
0
void
LaunchDaemon::_HandleRegisterLaunchEvent(BMessage* message)
{
	uid_t user = _GetUserID(message);
	if (user < 0)
		return;

	if (user == 0 || fUserMode) {
		status_t status = B_OK;

		const char* name = message->GetString("name");
		const char* ownerName = message->GetString("owner");
		BMessenger source;
		if (name != NULL && ownerName != NULL
			&& message->FindMessenger("source", &source) == B_OK) {
			// Register event
			ownerName = get_leaf(ownerName);

			RegisteredEvent* event = new (std::nothrow) RegisteredEvent(
				source, ownerName, name);
			if (event != NULL) {
				// Use short name, and fully qualified name
				BString eventName = name;
				fEvents.insert(std::make_pair(eventName, event));
				_ResolveRegisteredEvents(event, eventName);

				eventName.Prepend("/");
				eventName.Prepend(ownerName);
				fEvents.insert(std::make_pair(eventName, event));
				_ResolveRegisteredEvents(event, eventName);
			} else
				status = B_NO_MEMORY;
		} else
			status = B_BAD_VALUE;

		BMessage reply((uint32)status);
		message->SendReply(&reply);
	}

	_ForwardEventMessage(user, message);
}
Example #4
0
void ConfigView::UpdateNotifyText()
{
	BMenuField *field;
	if ((field = dynamic_cast<BMenuField *>(FindView("notify"))) == NULL)
		return;

	BString label;
	for (int32 i = field->Menu()->CountItems();i-- > 0;)
	{
		BMenuItem *item = field->Menu()->ItemAt(i);
		if (!item->IsMarked())
			continue;

		if (label != "")
			label.Prepend(" + ");
		label.Prepend(item->Label());
	}
	if (label == "")
		label = "none";
	field->MenuItem()->SetLabel(label.String());
}
Example #5
0
void
SourceFileC::Compile(BuildInfo &info, const char *options)
					
{
	BString abspath = GetPath().GetFullPath();
	if (abspath[0] != '/')
	{
		abspath.Prepend("/");
		abspath.Prepend(info.projectFolder.GetFullPath());
	}
	
	BString compileString = "gcc -c ";
	
	// This will make sure that we can still build if ccache is borked
	if (gUseCCache && gCCacheAvailable)
		compileString.Prepend("ccache ");
	
	if (gPlatform == PLATFORM_ZETA)
		compileString << "-D_ZETA_TS_FIND_DIR_ ";
	
	compileString << " -Wall -Wno-multichar -Wno-unknown-pragmas ";
	
	BString ext(GetPath().GetExtension());
	if (ext.ICompare("c") != 0)
		compileString << "-Wno-ctor-dtor-privacy ";
	
	// We should put extra compiler options so that -W options actually work
	if (options)
		compileString << options;
	
	compileString	<< "'" << abspath
					<< "' -o '" << GetObjectPath(info).GetFullPath() << "' 2>&1";
	
	BString errmsg;
	RunPipedCommand(compileString.String(), errmsg, true);
	STRACE(1,("Compiling %s\nCommand:%s\nOutput:%s\n",
			abspath.String(),compileString.String(),errmsg.String()));
	
	ParseGCCErrors(errmsg.String(),info.errorList);
}
void
SourceFileShell::PostBuild(BuildInfo &info, const char *options)
					
{
	BString abspath = GetPath().GetFullPath();
	if (abspath[0] != '/')
	{
		abspath.Prepend("/");
		abspath.Prepend(info.projectFolder.GetFullPath());
	}
	
	DPath shellFilePath(abspath.String());
	BString command = "cd '";
	command << shellFilePath.GetFolder() << "'; './"
			<< shellFilePath.GetFileName() << "'";
	
	STRACE(1,("Running shell script %s\nCommand:%s\n",
			abspath.String(),command.String()));
	
	FILE *fd = popen(abspath.String(),"r");
	if (!fd)
	{
		STRACE(1,("Bailed out of running %s: NULL pipe descriptor\n",
					GetPath().GetFullPath()));
		return;
	}
	
	char buffer[1024];
	BString errmsg;
	while (fgets(buffer,1024,fd))
		errmsg += buffer;
	pclose(fd);
	
	STRACE(1,("Running shell script %s\nOutput:%s\n", abspath.String(),errmsg.String()));
	
	ParseIntoLines(errmsg.String(),info.errorList);
}
Example #7
0
void encode_html( BString &msg ) {
	// BStrings are slow and sucky, but this is real easy
	msg.ReplaceAll("&","&amp;");
	msg.ReplaceAll("\"","&quot;");
	msg.ReplaceAll("<","&lt;");
	msg.ReplaceAll(">","&gt;");
	
	msg.ReplaceAll("[b]","<b>");
	msg.ReplaceAll("[/b]","</b>");
	msg.ReplaceAll("[i]","<i>");
	msg.ReplaceAll("[/i]","</i>");
	
	msg.Prepend("<html>");
	msg.Append("</html>");
}
Example #8
0
status_t MSNManager::BlockUser(const char *passport) {
	status_t ret = B_ERROR;

	if (fNoticeCon) {
		buddymap::iterator i = fWaitingAuth.find(passport);
		if (i != fWaitingAuth.end()) fWaitingAuth.erase(i);
	
		Command *com = new Command("ADC");
		com->AddParam("BL");	// Disallow to see our presence

		BString passParam = passport;
		passParam.Prepend("N=");
		com->AddParam(passParam.String());// Passport
		
		ret = fNoticeCon->Send(com);
	};
	
	return ret;
};
Example #9
0
status_t AIMProtocol::MessageFromUser(const char *nick, const char *msg,
	bool autoReply = false) {
	
	BMessage im_msg(IM::MESSAGE);
	im_msg.AddInt32("im_what", IM::MESSAGE_RECEIVED);
	im_msg.AddString("protocol", fManager->Protocol());
	im_msg.AddString("id", NormalizeNick(nick));
	
	BString text = msg;
	if (autoReply) text.Prepend("(Auto-response): ");
		
	im_msg.AddString("message", text);
	im_msg.AddBool("autoresponse", autoReply);
	im_msg.AddInt32("charset", fEncoding);
	
	fMsgr.SendMessage(&im_msg);											

	return B_OK;
};
Example #10
0
BString
MSHLanguageMgr::_T(const char * stringTag)
{
	BString translation = stringTag;
	translation.Prepend("*");
	translation.Append("*");

	if (NULL != fTransFiles) {
		const int32 numLanguages = CountLanguages();
		if ((numLanguages > 0)) {
			if (fCurrentLanguage >= 0) {
				MSHLanguageFile* langFile =
						reinterpret_cast<MSHLanguageFile*>(fTransFiles->ItemAt(fCurrentLanguage));
				if (NULL != langFile) {
					langFile->GetStringForTag(stringTag, translation);
				}
			}
		}
	}

	return translation;
}
Example #11
0
void
ICSTXTControl::MessageReceived(BMessage* message)
{
    switch (message->what) {
		case M_SEND_BUTTON:
        {
            AutoLocker<BLocker> autolocker(fLocker);

            BString str(fTxtControl->Text());

            if (str.Length() < 1)
                return;

            BString command = str;
            SendICS(command.Prepend("1000 "), Window());

            str.Prepend("\n").Append("\n");
            fTxtView->Insert(fTxtView->TextLength(), str, str.Length());
            float min, max;
            fScrollBar->GetRange(&min, &max);
            fScrollBar->SetValue(max);
            fTxtControl->SetText("");
            fTxtControl->MakeFocus();
			break;
        }

        case ICS_USER_CMD_RESPONSE:
        {
            BString str = "";
            message->FindString("info", &str);
            AddTxt(str);
            break;
        }

		default:
            BGroupView::MessageReceived(message);
			break;
	}
}
Example #12
0
void
BNetworkCookieJar::UrlIterator::_Initialize()
{
	BString domain = fUrl.Host();

	if (!domain.Length()) {
		if (fUrl.Protocol() == "file")
			domain = "localhost";
		else
			return;
	}

	fIterator = new(std::nothrow) PrivateIterator(
		fCookieJar->fCookieHashMap->GetIterator());

	if (fIterator != NULL) {
		// Prepending a dot since _FindNext is going to call _SupDomain()
		domain.Prepend(".");
		fIterator->fKey.SetTo(domain, domain.Length());
		_FindNext();
	}
}
Example #13
0
status_t 
FolderShaper::ShapeRef	(entry_ref * a_ref, const char * a_template, bool a_do_open)
{
	PRINT(("ShapeRef(%s, %s)\n", a_ref->name, a_template));

	status_t	status;

// store original_name
	
	BEntry	original_entry	(a_ref, true);
	original_entry.	GetRef	(a_ref);
	BString original_name 	= a_ref->name;
	BPath	original_path	(& original_entry);
	
	BString original_path_string = original_path.Path();
	NameSafe(& original_path_string);

	BPath	original_parent_path;
	original_path.GetParent(& original_parent_path);

	BDirectory parent_dir(original_parent_path.Path());

//	temp name
	BString new_name	=	a_ref->name;
	new_name.Prepend("New ");

	int32	counter	=	2;
	while(parent_dir.Contains(new_name.String()))
	{
		new_name = a_ref->name;
		new_name.Append(" (temporary ");
		new_name << counter;
		new_name.Append(")");		
		counter	++;
	}

	PRINT(("original_name: %s\n", original_name.String()));
	PRINT(("new_name: %s\n", new_name.String()));	
	
	PRINT(("original_path: %s\n", original_path.Path()));	
	PRINT(("original_path_string: %s\n", original_path_string.String()));	
	PRINT(("original_parent_path: %s\n", original_parent_path.Path()));	

	
	BPath	template_path	(m_tmpl_dir, a_template);

	BEntry	tmp_entry;		// traverse link to template
	if ((status = tmp_entry.SetTo(template_path.Path(), true)) != B_OK)
	{
		// message
		return status;
	}
	template_path.SetTo(& tmp_entry);
	
	BString	template_path_string 	=	template_path.Path();
	NameSafe(& template_path_string);
	PRINT(("template_path_string: %s\n", template_path_string.String()));		

	BPath	new_path	(original_parent_path.Path(), new_name.String());
	BString	new_path_string	=	new_path.Path();
	NameSafe(& new_path_string);
	PRINT(("new_path_string: %s\n", new_path_string.String()));			

	BString command;

	if(m_do_keep_position)
	{
		//	copy X/Y position attribute from Original Folder

		command = "copyattr -n _trk/pinfo_le ";
		command.Append(original_path_string);
		command.Append(" ");
		command.Append(template_path_string);
		
		PRINT(("copy X/Y position: \n%s\n", command.String()));
	
		system(command.String());
	}
	else
	{
		BNode template_node(& tmp_entry);
		template_node.RemoveAttr("_trk/pinfo_le");
	}
		
	
//	copy template -> "New name" (temp)

	command = "copyattr -d -r ";
	command.Append(template_path_string);
	command.Append(" ");
	command.Append(new_path_string);
	
	PRINT(("copy template -> temp: \n%s\n", command.String()));
	
	system(command.String());
	
//	New folder exists?

	BDirectory	new_directory;
	if((status = new_directory.SetTo(new_path.Path())) != B_OK)
	{
		ErrorMessage("new_directory.SetTo() ", status);	// ... probably want a BAlert
		return status;
	}
	
	BDirectory original_dir;
	if((status = original_dir.SetTo(original_path.Path())) != B_OK)
	{
		ErrorMessage("original_dir.SetTo() ", status);	// ... probably want a BAlert
		return status;
	}
	
//	Move stuff from original folder to new folder	
	BEntry	original_content_entry;
	while(original_dir.GetNextEntry(&original_content_entry) == B_OK)
	{
		if ((status = original_content_entry
			.MoveTo(& new_directory, NULL, ! m_do_clobber))	!= B_OK 
			&& (status != B_FILE_EXISTS || (! m_do_clobber) == true))
		{	
			ErrorMessage("original_content_entry.MoveTo() ", status);
			return status;							// ... definitely needs a fat BAlert
		}
	}

//	Move original folder to Trash
//	alt.
//  Delete

	bool was_open = false;
	
	if (m_do_move)
	{
		//	Is Folder Open ?
		was_open =	IsFolderOpen(a_ref);
		
		//	Close Original Folder	
		status	=	MoveRefToTrash(a_ref);	// This calls Tracker to move the ref.
											// If the folder is open, Tracker will close it.

		for (int j = 0; j < 250; j++)
		{
			PRINT(("loop: %d\n", j));
		
			if (original_entry.Exists() == false)
				break;
			
			snooze(20000);		// give Tracker some Time to Move
			// .... consider using node-monitoring instead to 
			// catch when Tracker has moved the folder to Trash
		}
	}
	else
	{
		status = original_entry.Remove();
		if (status != B_OK)
		{
			ErrorMessage("original_content_entry.MoveTo() ", status);
			// BAlert.. Could not remove original folder
			// return status;
		}
	}	
	
//	Rename New Folder -> Original Name
	BEntry	new_entry(new_path.Path());
	status = new_entry.Rename(original_name.String());
	if (status != B_OK)
		ErrorMessage("new_entry.Rename() ", status);
	
	entry_ref	new_ref;
	status = new_entry.GetRef(& new_ref);
	if (status != B_OK)
		ErrorMessage("new_entry.GetRef() ", status);
	
//	Open New Folder
	if (was_open) PRINT(("was_open == true\n"));
	if (! was_open) PRINT(("was_open == false\n"));
		
	if (((m_do_open == FS_IF_ORIGINAL_OPEN) && was_open) || m_do_open == FS_ALWAYS_OPEN)
	{
		// open folder
		command =	original_path_string;
		command.Prepend("/boot/system/Tracker ");
		command.Append(" &");
		
		system(command.String());
		
		// wait for new folder to open
		WaitForOpeningFolder(& new_ref);
		
		//	Clean Up All	
		if (m_do_clean_up)
			CleanUpWindow(& new_ref);
	}
	
	return B_OK;
}
Example #14
0
void
TMailApp::RefsReceived(BMessage *msg)
{
	bool		have_names = false;
	BString		names;
	char		type[B_FILE_NAME_LENGTH];
	int32		item = 0;
	BFile		file;
	TMailWindow	*window;
	entry_ref	ref;

	//
	// If a tracker window opened me, get a messenger from it.
	//
	BMessenger messenger;
	if (msg->HasMessenger("TrackerViewToken"))
		msg->FindMessenger("TrackerViewToken", &messenger);

	while (msg->HasRef("refs", item)) {
		msg->FindRef("refs", item++, &ref);
		if ((window = FindWindow(ref)) != NULL)
			window->Activate(true);
		else {
			file.SetTo(&ref, O_RDONLY);
			if (file.InitCheck() == B_NO_ERROR) {
				BNodeInfo	node(&file);
				node.GetType(type);
				if (strcmp(type, B_MAIL_TYPE) == 0
					|| strcmp(type, B_PARTIAL_MAIL_TYPE) == 0) {
					window = NewWindow(&ref, NULL, false, &messenger);
					window->Show();
				} else if(strcmp(type, "application/x-person") == 0) {
					/* Got a People contact info file, see if it has an Email address. */
					BString name;
					BString email;
					attr_info	info;
					char *attrib;

					if (file.GetAttrInfo("META:email", &info) == B_NO_ERROR) {
						attrib = (char *) malloc(info.size + 1);
						file.ReadAttr("META:email", B_STRING_TYPE, 0, attrib, info.size);
						attrib[info.size] = 0; // Just in case it wasn't NUL terminated.
						email << attrib;
						free(attrib);

						/* we got something... */
						if (email.Length() > 0) {
							/* see if we can get a username as well */
							if(file.GetAttrInfo("META:name", &info) == B_NO_ERROR) {
								attrib = (char *) malloc(info.size + 1);
								file.ReadAttr("META:name", B_STRING_TYPE, 0, attrib, info.size);
								attrib[info.size] = 0; // Just in case it wasn't NUL terminated.
								name << "\"" << attrib << "\" ";
								email.Prepend("<");
								email.Append(">");
								free(attrib);
							}

							if (names.Length() == 0) {
								names << name << email;
							} else {
								names << ", " << name << email;
							}
							have_names = true;
							email.SetTo("");
							name.SetTo("");
						}
					}
				}
				else if (strcmp(type, kDraftType) == 0) {
					window = NewWindow();

					// If it's a draft message, open it
					window->OpenMessage(&ref);
					window->Show();
				}
			} /* end of else(file.InitCheck() == B_NO_ERROR */
		}
	}

	if (have_names) {
		window = NewWindow(NULL, names.String());
		window->Show();
	}
}
Example #15
0
void
FileTypesWindow::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case B_SIMPLE_DATA:
			type_code type;
			if (message->GetInfo("refs", &type) == B_OK
				&& type == B_REF_TYPE) {
				be_app->PostMessage(message);
			}
			break;

		case kMsgToggleIcons:
		{
			BMenuItem* item;
			if (message->FindPointer("source", (void **)&item) != B_OK)
				break;

			item->SetMarked(!fTypeListView->IsShowingIcons());
			fTypeListView->ShowIcons(item->IsMarked());

			// update settings
			BMessage update(kMsgSettingsChanged);
			update.AddBool("show_icons", item->IsMarked());
			be_app_messenger.SendMessage(&update);
			break;
		}

		case kMsgToggleRule:
		{
			BMenuItem* item;
			if (message->FindPointer("source", (void **)&item) != B_OK)
				break;

			item->SetMarked(fRuleControl->IsHidden());
			_ShowSnifferRule(item->IsMarked());

			// update settings
			BMessage update(kMsgSettingsChanged);
			update.AddBool("show_rule", item->IsMarked());
			be_app_messenger.SendMessage(&update);
			break;
		}

		case kMsgTypeSelected:
		{
			int32 index;
			if (message->FindInt32("index", &index) == B_OK) {
				MimeTypeItem* item = (MimeTypeItem*)fTypeListView->ItemAt(index);
				if (item != NULL) {
					BMimeType type(item->Type());
					_SetType(&type);
				} else
					_SetType(NULL);
			}
			break;
		}

		case kMsgAddType:
		{
			if (fNewTypeWindow == NULL) {
				fNewTypeWindow = new NewFileTypeWindow(this, fCurrentType.Type());
				fNewTypeWindow->Show();
			} else
				fNewTypeWindow->Activate();
			break;
		}
		case kMsgNewTypeWindowClosed:
			fNewTypeWindow = NULL;
			break;

		case kMsgRemoveType:
		{
			if (fCurrentType.Type() == NULL)
				break;

			BAlert* alert;
			if (fCurrentType.IsSupertypeOnly()) {
				alert = new BPrivate::OverrideAlert("FileTypes Request",
					"Removing a super type cannot be reverted.\n"
					"All file types that belong to this super type "
					"will be lost!\n\n"
					"Are you sure you want to do this? To remove the whole "
					"group, hold down the Shift key and press \"Remove\".",
					"Remove", B_SHIFT_KEY, "Cancel", 0, NULL, 0,
					B_WIDTH_AS_USUAL, B_STOP_ALERT);
			} else {
				alert = new BAlert("FileTypes Request",
					"Removing a file type cannot be reverted.\n"
					"Are you sure you want to remove it?",
					"Remove", "Cancel", NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
			}
			if (alert->Go())
				break;

			status_t status = fCurrentType.Delete();
			if (status != B_OK)
				fprintf(stderr, "Could not remove file type: %s\n", strerror(status));
			break;
		}

		case kMsgSelectNewType:
		{
			const char* type;
			if (message->FindString("type", &type) == B_OK)
				fTypeListView->SelectNewType(type);
			break;
		}

		// File Recognition group

		case kMsgExtensionSelected:
		{
			int32 index;
			if (message->FindInt32("index", &index) == B_OK) {
				BStringItem* item = (BStringItem*)fExtensionListView->ItemAt(index);
				fRemoveExtensionButton->SetEnabled(item != NULL);
			}
			break;
		}

		case kMsgExtensionInvoked:
		{
			if (fCurrentType.Type() == NULL)
				break;

			int32 index;
			if (message->FindInt32("index", &index) == B_OK) {
				BStringItem* item = (BStringItem*)fExtensionListView->ItemAt(index);
				if (item == NULL)
					break;

				BWindow* window = new ExtensionWindow(this, fCurrentType, item->Text());
				window->Show();
			}
			break;
		}

		case kMsgAddExtension:
		{
			if (fCurrentType.Type() == NULL)
				break;

			BWindow* window = new ExtensionWindow(this, fCurrentType, NULL);
			window->Show();
			break;
		}

		case kMsgRemoveExtension:
		{
			int32 index = fExtensionListView->CurrentSelection();
			if (index < 0 || fCurrentType.Type() == NULL)
				break;

			BMessage extensions;
			if (fCurrentType.GetFileExtensions(&extensions) == B_OK) {
				extensions.RemoveData("extensions", index);
				fCurrentType.SetFileExtensions(&extensions);
			}
			break;
		}

		case kMsgRuleEntered:
		{
			// check rule
			BString parseError;
			if (BMimeType::CheckSnifferRule(fRuleControl->Text(), &parseError) != B_OK) {
				parseError.Prepend("Recognition rule is not valid:\n\n");
				error_alert(parseError.String());
			} else
				fCurrentType.SetSnifferRule(fRuleControl->Text());
			break;
		}

		// Description group

		case kMsgTypeEntered:
		{
			fCurrentType.SetShortDescription(fTypeNameControl->Text());
			break;
		}

		case kMsgDescriptionEntered:
		{
			fCurrentType.SetLongDescription(fDescriptionControl->Text());
			break;
		}

		// Preferred Application group

		case kMsgPreferredAppChosen:
		{
			const char* signature;
			if (message->FindString("signature", &signature) != B_OK)
				signature = NULL;

			fCurrentType.SetPreferredApp(signature);
			break;
		}

		case kMsgSelectPreferredApp:
		{
			BMessage panel(kMsgOpenFilePanel);
			panel.AddString("title", "Select preferred application");
			panel.AddInt32("message", kMsgPreferredAppOpened);
			panel.AddMessenger("target", this);

			be_app_messenger.SendMessage(&panel);
			break;
		}
		case kMsgPreferredAppOpened:
			_AdoptPreferredApplication(message, false);
			break;

		case kMsgSamePreferredAppAs:
		{
			BMessage panel(kMsgOpenFilePanel);
			panel.AddString("title", "Select same preferred application as");
			panel.AddInt32("message", kMsgSamePreferredAppAsOpened);
			panel.AddMessenger("target", this);

			be_app_messenger.SendMessage(&panel);
			break;
		}
		case kMsgSamePreferredAppAsOpened:
			_AdoptPreferredApplication(message, true);
			break;

		// Extra Attributes group

		case kMsgAttributeSelected:
		{
			int32 index;
			if (message->FindInt32("index", &index) == B_OK) {
				AttributeItem* item = (AttributeItem*)fAttributeListView->ItemAt(index);
				fRemoveAttributeButton->SetEnabled(item != NULL);
			}
			break;
		}

		case kMsgAttributeInvoked:
		{
			if (fCurrentType.Type() == NULL)
				break;

			int32 index;
			if (message->FindInt32("index", &index) == B_OK) {
				AttributeItem* item = (AttributeItem*)fAttributeListView->ItemAt(index);
				if (item == NULL)
					break;

				BWindow* window = new AttributeWindow(this, fCurrentType,
					item);
				window->Show();
			}
			break;
		}

		case kMsgAddAttribute:
		{
			if (fCurrentType.Type() == NULL)
				break;

			BWindow* window = new AttributeWindow(this, fCurrentType, NULL);
			window->Show();
			break;
		}

		case kMsgRemoveAttribute:
		{
			int32 index = fAttributeListView->CurrentSelection();
			if (index < 0 || fCurrentType.Type() == NULL)
				break;

			BMessage attributes;
			if (fCurrentType.GetAttrInfo(&attributes) == B_OK) {
				const char* kAttributeNames[] = {
					"attr:public_name", "attr:name", "attr:type",
					"attr:editable", "attr:viewable", "attr:extra",
					"attr:alignment", "attr:width", "attr:display_as"
				};

				for (uint32 i = 0; i <
						sizeof(kAttributeNames) / sizeof(kAttributeNames[0]); i++) {
					attributes.RemoveData(kAttributeNames[i], index);
				}

				fCurrentType.SetAttrInfo(&attributes);
			}
			break;
		}

		case B_META_MIME_CHANGED:
		{
			const char* type;
			int32 which;
			if (message->FindString("be:type", &type) != B_OK
				|| message->FindInt32("be:which", &which) != B_OK)
				break;

			if (fCurrentType.Type() == NULL)
				break;

			if (!strcasecmp(fCurrentType.Type(), type)) {
				if (which != B_MIME_TYPE_DELETED)
					_SetType(&fCurrentType, which);
				else
					_SetType(NULL);
			} else {
				// this change could still affect our current type

				if (which == B_MIME_TYPE_DELETED
#ifdef __ANTARES__
					|| which == B_SUPPORTED_TYPES_CHANGED
#endif
					|| which == B_PREFERRED_APP_CHANGED)
					_UpdatePreferredApps(&fCurrentType);
			}
			break;
		}

		default:
			BWindow::MessageReceived(message);
	}
}
Example #16
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;
}
// this is used to load a label that explains field usage
const char*
BContactField::ExtendedLabel(field_type type, field_usage usage)
{
	BString label = SimpleLabel(type);

	switch (usage) {
		case CONTACT_DATA_HOME:
			label.Prepend("Home ");
		break;

		case CONTACT_DATA_WORK:
			label.Prepend("Work ");
		break;

		case CONTACT_DATA_CUSTOM:
			label.Prepend("Custom ");
		break;
		case CONTACT_DATA_OTHER:
			label.Prepend("Other ");
		break;

		case CONTACT_NAME_FAMILY:
			label.Prepend("Family ");
		break;

		case CONTACT_NAME_GIVEN:
			label.Prepend("Given ");		
		break;

		case CONTACT_NAME_MIDDLE:
			label.Prepend("Middle ");
		break;

		case CONTACT_NAME_SUFFIX:
			label.SetTo("Name Suffix");
		break;

		case CONTACT_NICKNAME_DEFAULT:
			label.SetTo("Preferred Nickname");
		break;

		case CONTACT_NICKNAME_MAIDEN:
			label.SetTo("Maiden Nickname");
		break;

		case CONTACT_NICKNAME_SHORT_NAME:
			label.SetTo("Short Name Nickname");
		break;

		case CONTACT_NICKNAME_INITIALS:
			label.SetTo("Nickname Initials");
		break;

		case CONTACT_EMAIL_MOBILE:
			label.SetTo("Mobile email");
		break;

		case CONTACT_PHONE_MOBILE:
			label.SetTo("Mobile Phone");
		break;

		case CONTACT_PHONE_FAX_WORK:
			label.SetTo("Work Fax");
		break;

		case CONTACT_PHONE_FAX_HOME:
			label.SetTo("Home Fax");
		break;

		case CONTACT_PHONE_PAGER:
			label.SetTo("Phone (pager)");
		break;

		case CONTACT_PHONE_CALLBACK:
			label.SetTo("Phone (callback)");		
		break;

		case CONTACT_PHONE_CAR:
			label.SetTo("Phone (car)");
		break;

		case CONTACT_PHONE_ORG_MAIN:
			label.SetTo("Main Phone (org)");
		break;

		case CONTACT_PHONE_ISDN:
			label.SetTo("Phone ISDN");
		break;

		case CONTACT_PHONE_MAIN:
			label.SetTo("Main Phone");
		break;

		case CONTACT_PHONE_RADIO:
			label.SetTo("Phone (radio)");
		break;

		case CONTACT_PHONE_TELEX:
			label.SetTo("Phone (telex)");
		break;

		case CONTACT_PHONE_TTY_TDD:
			label.SetTo("Phone (tty/tdd)");
		break;

		case CONTACT_PHONE_WORK_MOBILE:
			label.SetTo("Work Mobile Phone");
		break;

		case CONTACT_PHONE_WORK_PAGER:
			label.SetTo("Work Phone (pager)");
		break;

		case CONTACT_PHONE_ASSISTANT:
			label.SetTo("Phone Assistant");
		break;

		case CONTACT_PHONE_MMS:
			label.SetTo("MMS Phone");
		break;
	}
	return label.String();
}
Example #18
0
ProjectWindow::ProjectWindow(BRect frame, Project *project)
	:	DWindow(frame, "Paladin", B_DOCUMENT_WINDOW, B_NOT_ZOOMABLE |
													B_WILL_ACCEPT_FIRST_CLICK),
		fErrorWindow(NULL),
		fFilePanel(NULL),
		fProject(project),
		fSourceControl(NULL),
		fShowingLibs(false),
		fMenusLocked(false),
		fBuilder(BMessenger(this))
{
	AddCommonFilter(new AltTabFilter());
	SetSizeLimits(200,30000,200,30000);
	RegisterWindow();
	
	// This is for our in-program debug menu which comes in handy now and then.
	// Paladin -d doesn't always get the job done
	AddShortcut('9', B_COMMAND_KEY | B_SHIFT_KEY | B_CONTROL_KEY,
				new BMessage(M_TOGGLE_DEBUG_MENU));
	
	if (fProject)
	{
		fSourceControl = GetSCM(fProject->SourceControl());
		if (fSourceControl)
		{
			if (gPrintDebugMode > 0)
				fSourceControl->SetDebugMode(true);
			
			fSourceControl->SetUpdateCallback(SCMOutputCallback);
			fSourceControl->SetWorkingDirectory(fProject->GetPath().GetFolder());
			
			if (fSourceControl->NeedsInit(fProject->GetPath().GetFolder()))
				fSourceControl->CreateRepository(fProject->GetPath().GetFolder());
		}
	}
	
	BView *top = GetBackgroundView();
	
	BRect bounds(Bounds());
	BRect r(bounds);
	
	r.bottom = 16;
	fMenuBar = new BMenuBar(r,"documentbar");
	top->AddChild(fMenuBar);
	
	r = bounds;
	r.top = fMenuBar->Frame().bottom + 1;
	r.right -= B_V_SCROLL_BAR_WIDTH;
	r.bottom -= B_H_SCROLL_BAR_HEIGHT;
	
	fProjectList = new ProjectList(fProject, r,"filelist",B_FOLLOW_ALL);
	fProjectList->SetInvocationMessage(new BMessage(M_EDIT_FILE));
	
	BScrollView *scrollView = new BScrollView("scrollView",fProjectList,
											B_FOLLOW_ALL,0,false,true);
	top->AddChild(scrollView);
	fProjectList->SetTarget(this);
	
	r.top = r.bottom + 1;
	r.bottom = Bounds().bottom;
	fStatusBar = new BStringView(r,"statusbar", NULL, B_FOLLOW_LEFT_RIGHT |
														B_FOLLOW_BOTTOM);
	top->AddChild(fStatusBar);
	
	fStatusBar->SetViewColor(235,235,235);
	fStatusBar->SetFontSize(10.0);
	
	SetupMenus();
	
	if (project)
	{
		BString title("Paladin: ");
		title << project->GetName();
		SetTitle(title.String());
		
		for (int32 i = 0; i < project->CountGroups(); i++)
		{
			SourceGroup *group = project->GroupAt(i);
			SourceGroupItem *groupitem = new SourceGroupItem(group);
			fProjectList->AddItem(groupitem);
			groupitem->SetExpanded(group->expanded);
			
			for (int32 j = 0; j < group->filelist.CountItems(); j++)
			{
				SourceFile *file = group->filelist.ItemAt(j);
				SourceFileItem *fileitem = new SourceFileItem(file,1);
				
//				fProjectList->AddUnder(fileitem,groupitem);
				fProjectList->AddItem(fileitem);
				
				BString abspath = file->GetPath().GetFullPath();
				if (abspath[0] != '/')
				{
					abspath.Prepend("/");
					abspath.Prepend(project->GetPath().GetFolder());
				}
				BEntry entry(abspath.String());
				if (entry.Exists())
				{
					if (project->CheckNeedsBuild(file,false))
					{
						fileitem->SetDisplayState(SFITEM_NEEDS_BUILD);
						fProjectList->InvalidateItem(fProjectList->IndexOf(fileitem));
					}
					else
						file->SetBuildFlag(BUILD_NO);
				}
				else
				{
					fileitem->SetDisplayState(SFITEM_MISSING);
					fProjectList->InvalidateItem(fProjectList->IndexOf(fileitem));
				}
			}
		}
	}
	
	BNode node(fProject->GetPath().GetFullPath());
	if (node.ReadAttr("project_frame",B_RECT_TYPE,0,&r,sizeof(BRect)) == sizeof(BRect))
	{
		if (r.Width() < 200)
			r.right = r.left + 200;
		if (r.Height() < 200)
			r.top = r.bottom + 200;
		MoveTo(r.left,r.top);
		ResizeTo(r.Width(),r.Height());
	}
	
	fProjectList->MakeFocus(true);
	
	if (gShowFolderOnOpen)
	{
		// Duplicated code from MessageReceived::M_SHOW_PROJECT_FOLDER. Doing
		// it here in combo with snooze() makes it much more likely that the
		// opened project window is frontmost instead of the project folder's window
		entry_ref ref;
		BEntry(fProject->GetPath().GetFolder()).GetRef(&ref);
		BMessenger msgr("application/x-vnd.Be-TRAK");
		
		BMessage reply;
		BMessage openmsg(B_REFS_RECEIVED);
		openmsg.AddRef("refs",&ref);
		msgr.SendMessage(&openmsg);
		snooze(50000);
	}
	
	if (gAutoSyncModules)
		PostMessage(M_SYNC_MODULES);
}
Example #19
0
bool
ServerAgent::ParseENums (const char *data, const char *sWord)
{
	int num (atoi (sWord));

	switch (num)
	{
		case ZERO:								 // 0
			{
				// wasn't a numeric, or the server is playing tricks on us
			}
			return false;

		case ERR_UNKNOWNCOMMAND:	 // 421
			{
				BString tempString (RestOfString (data, 4)),
								badCmd (GetWord (data, 4));

				if (badCmd == "VISION_LAG_CHECK")
				{
					int32 difference (system_time() - fLagCheck);
					if (difference > 0)
					{
						int32 secs (difference / 1000000);
						int32 milli (difference / 1000 - secs * 1000);
						char lag[15] = "";
						sprintf (lag, "%0" B_PRId32 ".%03" B_PRId32, secs, milli);
						fMyLag = lag;
						fLagCount = 0;
						fCheckingLag = false;
						fMsgr.SendMessage (M_LAG_CHANGED);
					}
				}
				else
				{
					tempString.RemoveFirst (":");
					tempString.Append ("\n");
					Display (tempString.String());
				}
			}
			return true;


		case RPL_WELCOME:					// 001
		case RPL_YOURHOST:				 // 002
		case RPL_CREATED:					// 003
		case RPL_MYINFO:					 // 004
			{
				fConnected = true;
				fIsConnecting = false;
				fInitialMotd = true;
				fRetry = 0;

				if (num == RPL_WELCOME)
				{
					BString message = B_TRANSLATE("Established");
					message.Prepend("[@] ").Append("\n");
					Display(message.String(), C_ERROR, C_BACKGROUND, F_SERVER);
				}

				if (fNetworkData.FindBool ("lagCheck"))
				{
					fMyLag = "0.000";
					fMsgr.SendMessage (M_LAG_CHANGED);
				}
				BString theNick (GetWord (data, 3));
				fMyNick = theNick;

				if (!IsHidden())
					vision_app->pClientWin()->pStatusView()->SetItemValue (STATUS_NICK,
						theNick.String());

				BString theMsg (RestOfString (data, 4));
				theMsg.RemoveFirst (":");
				theMsg.Prepend ("* ");
				theMsg.Append ("\n");
				Display (theMsg.String());


				if (num == RPL_MYINFO)
				{
					// set "real" hostname
					fServerHostName = (GetWord (data, 1));
					fServerHostName.RemoveFirst (":");
					BString hostName (fId.String());
					hostName += " - [";
					hostName += fServerHostName.String();
					hostName += "]";
					fAgentWinItem->SetName (hostName.String());

					// detect IRCd
					fIrcdtype = IRCD_STANDARD;

					if (theMsg.FindFirst("hybrid") > 0)
						fIrcdtype = IRCD_HYBRID;
					// ultimate and unreal share the same numerics, so treat them with the same
					// identifier for now
					else if ((theMsg.FindFirst("UltimateIRCd") > 0) || (theMsg.FindFirst("Unreal") > 0))
						fIrcdtype = IRCD_ULTIMATE;
					else if (theMsg.FindFirst("comstud") > 0)
						fIrcdtype = IRCD_COMSTUD;
					else if (theMsg.FindFirst("u2.") > 0)
						fIrcdtype = IRCD_UNDERNET;
					else if (theMsg.FindFirst("PTlink") > 0)
						fIrcdtype = IRCD_PTLINK;
					else if (theMsg.FindFirst ("CR") > 0)
						fIrcdtype = IRCD_CONFERENCEROOM;
					else if (theMsg.FindFirst ("nn-") > 0)
						fIrcdtype = IRCD_NEWNET;
				}
			}
			return true;


		case RPL_PROTOCTL:				 // 005
			{
				// this numeric also serves as RPL_NNMAP on Newnet

				BString theMsg (RestOfString (data, 4));
				theMsg.RemoveFirst (":");
				theMsg.Append ("\n");

				switch (fIrcdtype)
				{
					case IRCD_NEWNET:
						{
							// RPL_NNMAP
							Display (theMsg.String());
						}
						break;

					default:
						{
							// RPL_PROTOCTL
							theMsg.Prepend ("* ");
							Display (theMsg.String());
						}
				}
			}
			return true;



		case RPL_LUSERHIGHESTCONN: // 250
		case RPL_LUSERCLIENT:			// 251
		case RPL_LUSEROP:					// 252
		case RPL_LUSERUNKNOWN:		 // 253
		case RPL_LUSERCHANNELS:		// 254
		case RPL_LUSERME:					// 255
		case RPL_LUSERLOCAL:			 // 265
		case RPL_LUSERGLOBAL:			// 266
			{
				BString theMsg (RestOfString (data, 4));
				theMsg.RemoveFirst (":");
				theMsg.Prepend ("* ");
				theMsg.Append ("\n");
				Display (theMsg.String());
			}
			return true;


		/// strip and send to server agent	///
		case RPL_ULMAP:						 // 006
		case RPL_ULMAPEND:					// 007
		case RPL_U2MAP:						 // 015
		case RPL_U2MAPEND:					// 017
		case RPL_TRACELINK:				 // 200
		case RPL_TRACECONNECTING:	 // 201
		case RPL_TRACEHANDSHAKE:		// 202
		case RPL_TRACEUNKNOWN:			// 203
		case RPL_TRACEOPERATOR:		 // 204
		case RPL_TRACEUSER:				 // 205
		case RPL_TRACESERVER:			 // 206
		case RPL_TRACENEWTYPE:			// 208
		case RPL_TRACECLASS:				// 209
		case RPL_STATSLINKINFO:		 // 211
		case RPL_STATSCOMMANDS:		 // 212
		case RPL_STATSCLINE:				// 213
		case RPL_STATSNLINE:				// 214
		case RPL_STATSILINE:				// 215
		case RPL_STATSKLINE:				// 216
		case RPL_STATSQLINE:				// 217
		case RPL_STATSYLINE:				// 218
		case RPL_ENDOFSTATS:				// 219
		case RPL_STATSBLINE:				// 220
		case RPL_DALSTATSE:				 // 223
		case RPL_DALSTATSF:				 // 224
		case RPL_DALSTATSZ:				 // 225
		case RPL_DALSTATSN:				 // 226
		case RPL_DALSTATSG:				 // 227
		case RPL_STATSLLINE:				// 241
		case RPL_STATSUPTIME:			 // 242
		case RPL_STATSOLINE:				// 243
		case RPL_STATSHLINE:				// 244
		case RPL_STATSSLINE:				// 245
		case RPL_DALSTATSX:				 // 246
		case RPL_STATSXLINE:				// 247
		case RPL_STATSPLINE:				// 249
		case RPL_ADMINME:					 // 256
		case RPL_ADMINLOC1:				 // 257
		case RPL_ADMINLOC2:				 // 258
		case RPL_ADMINEMAIL:				// 259
		case RPL_TRACELOG:					// 261
		case RPL_ENDOFTRACE:				// 262
		case RPL_SILELIST:					// 271
		case RPL_ENDOFSILELIST:		 // 272
		case RPL_ENDOFWHO:					// 315
		case RPL_CHANSERVURL:			 // 328
		case RPL_COMMANDSYNTAX:		 // 334
		case RPL_VERSION:					 // 351
		case RPL_WHOREPLY:					// 352
		case RPL_BANLIST:					 // 367
		case RPL_ENDOFBANLIST:			// 368
		case RPL_INFO:							// 371
		case RPL_ENDOFINFO:				 // 374
		case RPL_YOUREOPER:				 // 381
		case RPL_REHASHING:				 // 382
		case RPL_TIME:							// 391
		case ERR_NOORIGIN:					// 409
		case ERR_NOTEXTTOSEND:			// 412
		case ERR_TOOMANYAWAY:			 // 429
		case ERR_NICKCHANGETOOFAST: // 438
		case ERR_TARGETCHANGETOOFAST: // 439
		case ERR_SUMMONDISABLED:		// 445
		case ERR_USERSDISABLED:		 // 446
		case ERR_NOTREGISTERED:		 // 451
		case ERR_NEEDMOREPARMS:		 // 461
		case ERR_PASSWDMISMATCH:		// 464
		case ERR_YOUREBANNEDCREEP:	// 465
		case ERR_NOPRIVILEGES:			// 481
		case ERR_NOOPERHOST:				// 491
		case ERR_USERSDONTMATCH:		// 502
		case ERR_SILELISTFULL:			// 511
		case ERR_TOOMANYWATCH:			// 512
		case ERR_TOOMANYDCC:				// 514
		case ERR_CANTINVITE:				// 518
		case ERR_LISTSYNTAX:				// 521
		case ERR_WHOSYNTAX:				 // 522
		case ERR_WHOLIMEXCEED:			// 523
		case RPL_LOGON:						 // 600
		case RPL_LOGOFF:						// 601
		case RPL_WATCHOFF:					// 602
		case RPL_WATCHSTAT:				 // 603
		case RPL_NOWON:						 // 604
		case RPL_NOWOFF:						// 605
		case RPL_WATCHLIST:				 // 606
		case RPL_ENDOFWATCHLIST:		// 607
		case RPL_DCCALLOWLIST:			// 618
		case RPL_DCCALLOWEND:			 // 619
		case RPL_DCCALLOW:					// 620
			{
				BString tempString (RestOfString (data, 4));
				tempString.RemoveFirst (":");
				tempString.Append ("\n");
				Display (tempString.String());
			}
			return true;

		case RPL_UMODEIS:					 // 221
			{
				BString theMode (GetWord (data, 4));

				BString tempString = B_TRANSLATE("Your current mode is %1");
				tempString.ReplaceFirst("%1", theMode);
				tempString += '\n';

				BMessage msg (M_DISPLAY);
				PackDisplay (&msg, tempString.String(), C_WHOIS);
				PostActive (&msg);
			}
			return true;

		/// strip and send to active agent	///
		case RPL_TRYAGAIN:					// 263
		case RPL_UNAWAY:						// 305
		case RPL_NOWAWAY:					 // 306
		case ERR_NOSUCHNICK:				// 401
		case ERR_NOSUCHSERVER:			// 402
		case ERR_NOSUCHCHANNEL:		 // 403
		case ERR_CANNOTSENDTOCHAN:	// 404
		case ERR_TOOMANYCHANNELS:	 // 405
		case ERR_WASNOSUCHNICK:		 // 406
		case ERR_TOOMANYTARGETS:		// 407
		case ERR_NOCOLORSONCHAN:		// 408
		case ERR_YOUCANTDOTHAT:		 // 460
		case ERR_CHANOPRIVSNEEDED:	// 482
			{
				BString tempString ("[x] ");
				if (num == ERR_CHANOPRIVSNEEDED)
					tempString += RestOfString (data, 5);
				else
					tempString += RestOfString (data, 4);
				tempString.RemoveFirst (":");
				tempString.Append ("\n");

				BMessage msg (M_DISPLAY);
				PackDisplay (&msg, tempString.String(), C_WHOIS, C_BACKGROUND, F_SERVER);
				PostActive (&msg);
			}
			return true;

		case RPL_AWAY:						 // 301
			{
				BString theNick (GetWord(data, 4));
				BString tempString ("[x] "),
							theReason (RestOfString(data, 5));
				theReason.RemoveFirst(":");
				tempString += "Away: ";
				tempString += theReason;
				tempString += '\n';

				if (fRemoteAwayMessages.find(theNick) != fRemoteAwayMessages.end())
				{
					if (fRemoteAwayMessages[theNick] == theReason)
					{
						return true;
					}
				}
				fRemoteAwayMessages[theNick] = theReason;
				BMessage msg (M_DISPLAY);
				PackDisplay (&msg, tempString.String(), C_WHOIS, C_BACKGROUND, F_SERVER);
				PostActive (&msg);
			}
			return true;

		case RPL_USERHOST:				// 302
			{
				BString theHost (GetWord (data, 4)),
								theHostname (GetAddress (theHost.String()));
				theHost.RemoveFirst (":");

				BString tempString (RestOfString (data, 4));
				tempString.RemoveFirst (":");
				tempString.Append ("\n");
				Display (tempString.String());

				if (fGetLocalIP && (tempString.IFindFirst (fMyNick.String()) == 0))
				{
					fGetLocalIP = false;
					struct addrinfo *info;
					struct addrinfo hints;
					memset(&hints, 0, sizeof(addrinfo));
					hints.ai_family = AF_UNSPEC;
					hints.ai_socktype = SOCK_STREAM;
					hints.ai_protocol = IPPROTO_TCP;
					int result = getaddrinfo(theHostname.String(), NULL, &hints, &info);
					if (result == 0)
					{
						char addr_buf[INET6_ADDRSTRLEN];
						getnameinfo(info->ai_addr, info->ai_addrlen, addr_buf, sizeof(addr_buf),
						NULL, 0, NI_NUMERICHOST);
						fLocalip = addr_buf;
						printf("Got address: %s\n", fLocalip.String());
						freeaddrinfo(info);
						return true;
					}
				}
			}
			return true;

		case RPL_ISON:					 // 303
			{
				BString nicks (RestOfString (data, 4));
				BString onlined, offlined;

				nicks.RemoveFirst (":");

				int hasChanged (0);

				BMessage msg (M_NOTIFYLIST_UPDATE);

				for (int32 i = 0; i < fNotifyNicks.CountItems(); i++)
				{
					NotifyListItem *item (((NotifyListItem *)fNotifyNicks.ItemAt(i)));

					int32 nickidx (nicks.IFindFirst(item->Text()));

					// make sure that the nick isn't a partial match.
					if ((nickidx >= 0) &&
						((nicks[nickidx + strlen(item->Text())] == ' ') || (nicks[nickidx + strlen(item->Text())] == '\0')))
					{
						if (item->GetState() != true)
						{
							item->SetState (true);
							hasChanged = 1;

							if (onlined.Length())
								onlined << ", ";
							onlined << item->Text();
#ifdef USE_INFOPOPPER
							if (be_roster->IsRunning(InfoPopperAppSig) == true) {
								entry_ref ref = vision_app->AppRef();
								BMessage infoMsg(InfoPopper::AddMessage);
								infoMsg.AddString("appTitle", S_INFOPOPPER_TITLE);
								infoMsg.AddString("title", fId.String());
								infoMsg.AddInt8("type", (int8)InfoPopper::Information);

								infoMsg.AddInt32("iconType", InfoPopper::Attribute);
								infoMsg.AddRef("iconRef", &ref);

								BString content;
								content << item->Text() << " is online";
								infoMsg.AddString("content", content);

								BMessenger(InfoPopperAppSig).SendMessage(&infoMsg);
							};
#endif

						}
					}
					else
					{
						if (item->GetState() == true)
						{
							item->SetState (false);
							hasChanged = 2;

							if (offlined.Length())
								offlined << ", ";
							offlined << item->Text();
#ifdef USE_INFOPOPPER
							if (be_roster->IsRunning(InfoPopperAppSig) == true) {
				entry_ref ref = vision_app->AppRef();
								BMessage infoMsg(InfoPopper::AddMessage);
								infoMsg.AddString("appTitle", S_INFOPOPPER_TITLE);
								infoMsg.AddString("title", fId.String());
								infoMsg.AddInt8("type", (int8)InfoPopper::Information);

								infoMsg.AddInt32("iconType", InfoPopper::Attribute);
								infoMsg.AddRef("iconRef", &ref);

								BString content;
								content << item->Text() << " is offline";
								infoMsg.AddString("content", content);

								BMessenger(InfoPopperAppSig).SendMessage(&infoMsg);
							};
#endif

						}
					}
#ifdef __HAIKU__
					if (offlined.Length())
					{
						BNotification notification(B_INFORMATION_NOTIFICATION);
						notification.SetGroup(BString("Vision"));
						entry_ref ref = vision_app->AppRef();
						notification.SetOnClickFile(&ref);
						notification.SetTitle(fServerName.String());
						BString content;
						content << offlined;
						if (offlined.FindFirst(' ') > -1)
							content << " are offline";
						else
							content << " is offline";


						notification.SetContent(content);
						notification.Send();
					}
					if (onlined.Length())
					{
						BNotification notification(B_INFORMATION_NOTIFICATION);
						notification.SetGroup(BString("Vision"));
						entry_ref ref = vision_app->AppRef();
						notification.SetOnClickFile(&ref);
						notification.SetTitle(fServerName.String());
						BString content;
						content << onlined;
						if (onlined.FindFirst(' ') > -1)
							content << " are online";
						else
							content << " is online";


						notification.SetContent(content);
						notification.Send();
					}
#endif
				}
				fNotifyNicks.SortItems(SortNotifyItems);
				msg.AddPointer ("list", &fNotifyNicks);
				msg.AddPointer ("source", this);
				msg.AddInt32 ("change", hasChanged);
				Window()->PostMessage (&msg);
			}
			return true;

		case RPL_WHOISIDENTIFIED:	 // 307
			{
				BString theInfo (RestOfString (data, 5));
				theInfo.RemoveFirst (":");

				if (theInfo == "-9z99")
				{
					// USERIP reply? (RPL_U2USERIP)
					BString tempString (RestOfString (data, 4));
					tempString.RemoveFirst (":");
					tempString.Append ("\n");
					Display (tempString.String());
					return true;
				}

				BMessage display (M_DISPLAY);
				BString buffer;

				buffer += "[x] ";
				buffer += theInfo;
				buffer += "\n";
				PackDisplay (&display, buffer.String(), C_WHOIS, C_BACKGROUND, F_SERVER);
				PostActive (&display);
			}
			return true;

		case RPL_WHOISADMIN:					// 308
		case RPL_WHOISSERVICESADMIN:	// 309
		case RPL_WHOISHELPOP:				 // 310
		case RPL_WHOISOPERATOR:			 // 313
		case RPL_WHOISREGNICK:				// 320
		case RPL_WHOISACTUALLY:			 // 338
		case RPL_WHOISMASK:					 // 550
		case RPL_WHOWASIP:						// 612
		case RPL_WHOISUSERMODESALT:	 // 614
		case RPL_WHOISUSERMODES:			// 615
		case RPL_WHOISREALHOSTNAME:	 // 616
			{
				BString theInfo (RestOfString (data, 5));
				theInfo.RemoveFirst (":");

				BMessage display (M_DISPLAY);
				BString buffer;

				buffer += "[x] ";
				buffer += theInfo;
				buffer += "\n";
				PackDisplay (&display, buffer.String(), C_WHOIS, C_BACKGROUND, F_SERVER);
				PostActive (&display);
			}
			return true;

		case RPL_WHOISUSER:				// 311
			{
				BString theNick (GetWord (data, 4)),
								theIdent (GetWord (data, 5)),
								theAddress (GetWord (data, 6)),
								theName (RestOfString (data, 8));
				theName.RemoveFirst (":");

				BMessage display (M_DISPLAY);
				BString buffer;

				buffer += "[x] ";
				buffer += theNick;
				buffer += " (";
				buffer += theIdent;
				buffer += "@";
				buffer += theAddress;
				buffer += ")\n";
				buffer += "[x] ";
				buffer += theName;
				buffer += "\n";

				PackDisplay (&display, buffer.String(), C_WHOIS, C_BACKGROUND, F_SERVER);
				PostActive (&display);
			}
		return true;

		case RPL_WHOISSERVER:	 // 312
			{
				BString theNick (GetWord (data, 4)),
								theServer (GetWord (data, 5)),
								theInfo (RestOfString (data, 6));
				theInfo.RemoveFirst (":");

				BMessage display (M_DISPLAY);
				BString buffer;

				buffer += "[x] Server: ";
				buffer += theServer;
				buffer += " (";
				buffer += theInfo;
				buffer += ")\n";
				PackDisplay (&display, buffer.String(), C_WHOIS, C_BACKGROUND, F_SERVER);
				PostActive (&display);
			}
			return true;

		case RPL_WHOWASUSER:		 // 314
			{
				BString theNick (GetWord (data, 4)),
								theIdent (GetWord (data, 5)),
								theAddress (GetWord (data, 6)),
								theName (RestOfString (data, 8)),
								tempString ("[x] ");
				theName.RemoveFirst (":");
				tempString += B_TRANSLATE("%1 was (%2)");
				tempString.ReplaceFirst("%1", theNick);
				BString nickString = theIdent << "@" << theAddress;
				tempString.ReplaceFirst("%2", nickString.String());
				tempString += "\n";

				BMessage msg (M_DISPLAY);
				PackDisplay (&msg, tempString.String(), C_WHOIS, C_BACKGROUND, F_SERVER);
				PostActive (&msg);
			}
			return true;

		case RPL_WHOISIDLE:			 // 317
			{
				BString theNick (GetWord (data, 4)),
								tempString ("[x] "),
								tempString2 ("[x] "),
								theTime (GetWord (data, 5)),
								signOnTime (GetWord (data, 6));

				int64 idleTime (strtoul(theTime.String(), NULL, 0));
				tempString += B_TRANSLATE("Idle");
				tempString += ": ";
				tempString += DurationString(idleTime * 1000 * 1000);
				tempString += "\n";

				int32 serverTime = strtoul(signOnTime.String(), NULL, 0);
				struct tm ptr;
				time_t st;
				char str[80];
				st = serverTime;
				localtime_r (&st, &ptr);
				strftime (str,80,"%A %b %d %Y %I:%M %p %Z", &ptr);
				BString signOnTimeParsed (str);
				signOnTimeParsed.RemoveAll ("\n");

				tempString2 += B_TRANSLATE("Signon");
				tempString2 += ": ";
				tempString2 += signOnTimeParsed;
				tempString2 += "\n";

				BMessage msg (M_DISPLAY);
				PackDisplay (&msg, tempString.String(), C_WHOIS, C_BACKGROUND, F_SERVER);
				PostActive (&msg);
				PackDisplay (&msg, tempString2.String(), C_WHOIS, C_BACKGROUND, F_SERVER);
				PostActive (&msg);
			}
			return true;

		case RPL_ENDOFWHOIS:	 // 318
		case RPL_ENDOFNAMES:	 // 366
		case RPL_ENDOFWHOWAS:	// 369
			{
				// nothing
			}
			return true;

		case RPL_WHOISCHANNELS:	 // 319
			{
				BString theChannels (RestOfString (data, 5));
				theChannels.RemoveFirst(":");

				BMessage display (M_DISPLAY);
				BString buffer = "[x] ";

				buffer += B_TRANSLATE("Channels");
				buffer += ": ";
				buffer += theChannels;
				buffer += "\n";
				PackDisplay (&display, buffer.String(), C_WHOIS, C_BACKGROUND, F_SERVER);
				PostActive (&display);
			}
			return true;

		case RPL_LISTSTART:			 // 321
			{
				BMessage msg (M_LIST_BEGIN);
				if (fListAgent)
					vision_app->pClientWin()->DispatchMessage(&msg, (BView *)fListAgent);
			}
			return true;

		case RPL_LIST:						// 322
			{
				BMessage msg (M_LIST_EVENT);
				BString channel (GetWord (data, 4)),
								users (GetWord (data, 5)),
								topic (RestOfString (data, 6));
				topic.RemoveFirst (":");

				msg.AddString ("channel", channel.String());
				msg.AddString ("users", users.String());
				msg.AddString ("topic", topic.String());

				if (fListAgent)
					vision_app->pClientWin()->DispatchMessage(&msg, (BView *)fListAgent);
			}
			return true;

		case RPL_LISTEND:				 // 323
			{
				BMessage msg (M_LIST_DONE);

				if (fListAgent)
					vision_app->pClientWin()->DispatchMessage(&msg, (BView *)fListAgent);
			}
			return true;

		case RPL_CHANNELMODEIS:	 // 324
			{
				BString theChan (GetWord (data, 4)),
								theMode (GetWord (data, 5)),
								tempStuff (RestOfString (data, 6));

				if (tempStuff != "-9z99")
				{
					theMode.Append(" ");
					theMode.Append(tempStuff); // avoid extra space w/o params
				}

				ClientAgent *aClient (ActiveClient()),
										*theClient (Client (theChan.String()));

				BString tempString("*** ");
				tempString += B_TRANSLATE("Channel mode for %1: %2");
				tempString.ReplaceFirst("%1", theChan.String());
				tempString.ReplaceFirst("%2", theMode.String());
				tempString += '\n';

				BMessage msg (M_CHANNEL_MODES);

				msg.AddString ("msgz", tempString.String());
				msg.AddString ("chan", theChan.String());
				msg.AddString ("mode", theMode.String());

				if (theClient)
					theClient->fMsgr.SendMessage (&msg);
				else if (aClient)
					aClient->fMsgr.SendMessage (&msg);
				else
					Display (tempString.String(), C_OP);
			}
			return true;

		case RPL_CHANNELMLOCK:		// 325
			{
				BString theChan (GetWord (data, 4)),
								mLock (GetWord (data, 8)),
								lockMessage ("*** ");
				lockMessage += B_TRANSLATE("Channel mode lock for %1: %2");
				lockMessage.ReplaceFirst("%1", theChan);
				lockMessage.ReplaceFirst("%2", mLock);
				lockMessage += "\n";

				BMessage display (M_DISPLAY);

				PackDisplay (&display, lockMessage.String(), C_OP, C_BACKGROUND, F_TEXT);
				ClientAgent *theClient (Client (theChan.String()));
				if (theClient)
					theClient->fMsgr.SendMessage (&display);
				else
					fMsgr.SendMessage (&display);
			}
			return true;

		case RPL_CHANNELCREATED:			 // 329
			{
				BString theChan (GetWord (data, 4)),
								theTime (GetWord (data, 5)),
								tempString;

				int32 serverTime (strtoul(theTime.String(), NULL, 0));
				struct tm ptr;
				time_t st;
				char str[80];
				st = serverTime;
				localtime_r (&st, &ptr);
				strftime (str,80,"%a %b %d %Y %I:%M %p %Z",&ptr);
				BString theTimeParsed (str);
				theTimeParsed.RemoveAll ("\n");

			tempString = B_TRANSLATE("Channel %1 was created at %2");
			tempString.ReplaceFirst("%1", theChan);
			tempString.ReplaceFirst("%2", theTimeParsed);
				tempString += '\n';
				Display (tempString.String());
			}
			return true;

		case RPL_NOTOPIC:						 // 331
			{
				BString theChan (GetWord (data, 4)),
								tempString ("[x] ");
				tempString += B_TRANSLATE("No topic set in %1");
				tempString.ReplaceFirst("%1", theChan);
				tempString += '\n';

				BMessage msg (M_DISPLAY);
				PackDisplay (&msg, tempString.String(), C_ERROR);
				PostActive (&msg);
			}
			return true;

		case RPL_TOPIC:							 // 332
			{
				BString theChannel (GetWord (data, 4)),
								theTopic (RestOfString (data, 5));
				ClientAgent *client (Client (theChannel.String()));

				theTopic.RemoveFirst (":");

				if (client)
				{
					BMessage display (M_DISPLAY);
					BString buffer;

					buffer += "*** ";
					buffer += B_TRANSLATE("Topic: %1");
					buffer.ReplaceFirst("%1", theTopic);
					buffer += '\n';
					PackDisplay (&display, buffer.String(), C_WHOIS);

					BMessage msg (M_CHANNEL_TOPIC);
					msg.AddString ("topic", theTopic.String());
					msg.AddMessage ("display", &display);

					if (client->fMsgr.IsValid())
						client->fMsgr.SendMessage (&msg);
				}
			}
			return true;

		case RPL_TOPICSET:						// 333
			{
				BString channel (GetWord (data, 4)),
								user (GetWord (data, 5)),
								theTime (GetWord (data, 6));

				int32 serverTime (strtoul(theTime.String(), NULL, 0));
				struct tm ptr;
				time_t st;
				char str[80];
				st = serverTime;
				localtime_r (&st, &ptr);
				strftime (str,80,"%A %b %d %Y %I:%M %p %Z",&ptr);
				BString theTimeParsed (str);
				theTimeParsed.RemoveAll ("\n");

				ClientAgent *client (Client (channel.String()));

				if (client)
				{
					BMessage display (M_DISPLAY);
					BString buffer = "*** ";

					buffer += B_TRANSLATE("Topic set by %1 at %2");
					buffer.ReplaceFirst("%1", user);
					buffer.ReplaceFirst("%2", theTimeParsed);
					buffer += '\n';
					PackDisplay (&display, buffer.String(), C_WHOIS);
					if (client->fMsgr.IsValid())
						client->fMsgr.SendMessage (&display);
				}
			}
			return true;

		case RPL_INVITING:						 // 341
			{
				BString channel (GetWord (data, 5)),
								theNick (GetWord (data, 4)),
								tempString;

				tempString += "*** ";
				tempString += B_TRANSLATE("%1 has been invited to %2.");
				tempString.ReplaceFirst("%1", theNick);
				tempString.ReplaceFirst("%2", channel);
				tempString += "\n";

				BMessage display (M_DISPLAY);

				PackDisplay (&display, tempString.String(), C_WHOIS);
				PostActive (&display);
			}
			return true;


		case RPL_NAMEREPLY:						 // 353
			{
				BString channel (GetWord (data, 5)),
								names (RestOfString (data, 6));
				ClientAgent *client (Client (channel.String()));
				names.RemoveFirst (":");

					BString tempString ("*** ");
					tempString += B_TRANSLATE("Users in %1: %2");
					tempString.ReplaceFirst("%1", channel);
					tempString.ReplaceFirst("%2", names);
					tempString += '\n';
					Display (tempString.String(), C_TEXT);

				if (client) // in the channel
				{
					BMessage msg (M_CHANNEL_NAMES);
					BString nick;
					int32 place (1);

					while ((nick = GetWord (names.String(), place)) != "-9z99")
					{
						const char *sNick (nick.String());
						bool founder (false),
								 protect (false),
								 op (false),
								 voice (false),
								 helper (false),
							 ignored;

						if (nick[0] == '*')
						{
							++sNick;
							founder = true;
						}
						else if (nick[0] == '!')
						{
							++sNick;
							protect = true;
						}
						else if (nick[0] == '@')
						{
							++sNick;
							op = true;
						}
						else if (nick[0] == '+')
						{
							++sNick;
							voice = true;
						}
						else if (nick[0] == '%')
						{
							++sNick;
							helper = true;
						}

						ignored = false;
						// BMessage aMsg (M_IS_IGNORED), reply;
						// aMsg.AddString ("server", fServerName.String());
						// aMsg.AddString ("nick", sNick);

						// be_app_messenger.SendMessage (&aMsg, &reply);
						// reply.FindBool ("ignored", &ignored);

						msg.AddString ("nick", nick.String());
						msg.AddBool ("founder", founder);
						msg.AddBool ("protect", protect);
						msg.AddBool ("op", op);
						msg.AddBool ("voice", voice);
						msg.AddBool ("helper", helper);
						msg.AddBool ("ignored", ignored);
						++place;
					}

					if (client->fMsgr.IsValid())
						client->fMsgr.SendMessage (&msg);
				}
			}
			return true;

		case RPL_MOTD:						// 372
		case RPL_MOTDALT:				 // 378
		case RPL_OPERMOTDSTART:	 // 609
		case RPL_OPERMOTD:				// 610
		case RPL_OPERENDOFMOTD:	 // 611
			{
				BString tempString (RestOfString(data, 4));
				tempString.RemoveFirst (":");
				tempString.Append ("\n");
				Display (tempString.String(), C_SERVER, C_BACKGROUND, F_SERVER);
			}
			return true;

		case RPL_MOTDSTART:				// 375
			{

				BString tempString ("- ");
				tempString += B_TRANSLATE("Server Message Of the Day");
				tempString += ":\n";
				Display (tempString.String(), C_SERVER, C_BACKGROUND, F_SERVER);
			}
			return true;

		case RPL_ENDOFMOTD:				// 376
		case ERR_NOMOTD:					 // 422
			{
				BString tempString (RestOfString (data, 4));
			tempString.RemoveFirst (":");
			tempString.Append ("\n");

				Display (tempString.String(), C_SERVER, C_BACKGROUND, F_SERVER);

				if (fInitialMotd && fCmds.Length())
				{
					BMessage msg (M_SUBMIT_INPUT);
					const char *place (fCmds.String()), *eol;

					msg.AddInt32 ("which", PASTE_MULTI_NODELAY);

					while ((eol = strchr (place, '\n')) != 0)
					{
						BString line;

						line.Append (place, eol - place);
						msg.AddString ("data", line.String());
						ParseAutoexecChans (line);
						place = eol + 1;
					}

					if (*place)
					{
						// check in case this was the only line
						ParseAutoexecChans (BString(place));
						msg.AddString ("data", place);
					}

					msg.AddInt32 ("which", 3);
					msg.AddBool ("autoexec", true);
					fMsgr.SendMessage (&msg);
				}

				BString IPCommand ("/userhost ");
				IPCommand += fMyNick;
				ParseCmd (IPCommand.String());

				if (fReconnecting)
				{
					BString reString = "[@] ";
					reString += B_TRANSLATE("Successful reconnect");
					reString += "\n";
					Display (reString.String(), C_ERROR);
					DisplayAll (reString.String(), C_ERROR, C_BACKGROUND, F_SERVER);
					fMsgr.SendMessage (M_REJOIN_ALL);
					fReconnecting = false;
				}

				fInitialMotd = false;
			}
			return true;

		case RPL_USERSSTART:			 // 392
			{
				// empty for now
		}
			return true;

		case RPL_USERS:						// 393
			{
				// empty for now
			}
			return true;

		case ERR_ERRONEOUSNICKNAME:		// 432
		case ERR_NICKNAMEINUSE:				// 433
		case ERR_RESOURCEUNAVAILABLE:	// 437
			{
				BString theNick (GetWord (data, 4));

				if (fIsConnecting)
				{
					BString nextNick (GetNextNick());
					if (nextNick != "")
					{
						BString tempString = "* ";
						tempString += B_TRANSLATE("Nickname \"%1\" in use or unavailable, trying \"%2\"");
						tempString.ReplaceFirst("%1", theNick.String());
						tempString.ReplaceFirst("%2", nextNick.String());
						tempString += "\n";
						Display (tempString.String());

						tempString = "NICK ";
						tempString += nextNick;
						SendData (tempString.String());
						return true;
					}
					else
					{
						BString tempString = "* ";
						tempString += B_TRANSLATE("All your pre-selected nicknames are in use.");
						tempString += "\n";
						Display (tempString.String());
						tempString = "* ";
						tempString += B_TRANSLATE("Please type /NICK <NEWNICK> to try another.");
						tempString += "\n";
						Display (tempString.String());
						return true;
					}
				}
				BString tempString = "[x] ";
				tempString += B_TRANSLATE("Nickname/Channel \"%1\" is already in use or unavailable.");
				tempString.ReplaceFirst("%1", theNick);
				tempString += "\n";

				BMessage display (M_DISPLAY);
				PackDisplay (&display, tempString.String(), C_NICK);
				PostActive (&display);
			}
			return true;

		case ERR_USERNOTINCHANNEL:		// 441
			{
				BString theChannel (GetWord (data, 5)),
								theNick (GetWord (data, 4)),
								tempString ("[x] ");
				tempString += B_TRANSLATE("%1 not in %2.");
				tempString.ReplaceFirst("%1", theNick);
				tempString.ReplaceFirst("%2", theChannel);
				tempString += "\n";

				BMessage msg (M_DISPLAY);
				PackDisplay (&msg, tempString.String(), C_ERROR);
				PostActive (&msg);
			}
			return true;

		case ERR_NOTONCHANNEL:			 // 442
			{
				BString theChannel (GetWord (data, 4)),
								tempString ("[x] ");
				tempString += B_TRANSLATE("You're not in %1.");
				tempString.ReplaceFirst("%1", theChannel);
				tempString += "\n";

				BMessage msg (M_DISPLAY);
				PackDisplay (&msg, tempString.String(), C_ERROR);
				PostActive (&msg);
			}
			return true;

		case ERR_USERONCHANNEL:		 // 443
			{
				BString theChannel (GetWord (data, 5)),
								theNick (GetWord (data, 4)),
				tempString ("[x] ");
				tempString += B_TRANSLATE("%1 is already in %2.");
				tempString.ReplaceFirst("%1", theNick);
				tempString.ReplaceFirst("%2", theChannel);
				tempString += "\n";

				BMessage msg (M_DISPLAY);
				PackDisplay (&msg, tempString.String(), C_ERROR);
				PostActive (&msg);
			}
			return true;

		case ERR_KEYSET:						// 467
			{
				BString theChannel (GetWord (data, 4)),
								tempString ("[x] ");
				tempString += B_TRANSLATE("Channel key already set in %1.");
				tempString.ReplaceFirst("%1", theChannel);
				tempString += "\n";

				BMessage msg (M_DISPLAY);
				PackDisplay (&msg, tempString.String(), C_ERROR);
				PostActive (&msg);
			}
			return true;

		case ERR_UNKNOWNMODE:				// 472
			{
				BString theMode (GetWord (data, 4)),
								tempString ("[x] ");
				tempString += B_TRANSLATE("Unknown channel mode: '%1'.");
				tempString.ReplaceFirst("%1", theMode);
				tempString += "\n";

				BMessage msg (M_DISPLAY);
				PackDisplay (&msg, tempString.String(), C_QUIT);
				PostActive (&msg);
			}
			return true;

		case ERR_INVITEONLYCHAN:		 // 473
			{
				BString theChan (GetWord (data, 4)),
								tempString ("[x] "),
								theReason (RestOfString (data, 5));
				theReason.RemoveFirst(":");
				theReason.ReplaceLast("channel", theChan.String());
				tempString << theReason < " ";
				tempString += B_TRANSLATE("(invite only)");
				tempString += "\n";

				BMessage msg (M_DISPLAY);
				PackDisplay (&msg, tempString.String(), C_QUIT, C_BACKGROUND, F_SERVER);
				PostActive (&msg);
				RemoveAutoexecChan (theChan);
			}
			return true;

		case ERR_BANNEDFROMCHAN:		 // 474
			{
				BString theChan (GetWord (data, 4)),
								tempString ("[x] "),
								theReason (RestOfString (data, 5));
				theReason.RemoveFirst(":");
				theReason.ReplaceLast("channel", theChan.String());

				tempString << theReason < " ";
				tempString += B_TRANSLATE("(you're banned)");
				tempString += "\n";

				BMessage msg (M_DISPLAY);
				PackDisplay (&msg, tempString.String(), C_QUIT, C_BACKGROUND, F_SERVER);
				PostActive (&msg);
				RemoveAutoexecChan (theChan);
			}
			return true;

		case ERR_BADCHANNELKEY:			// 475
			{
				BString theChan (GetWord(data, 4)),
								theReason (RestOfString(data, 5)),
								tempString("[x] ");
				theReason.RemoveFirst(":");
				theReason.ReplaceLast("channel", theChan.String());
				tempString << theReason << " ";
				tempString += B_TRANSLATE("(bad channel key)");
				tempString += "\n";

				BMessage msg (M_DISPLAY);
				PackDisplay (&msg, tempString.String(), C_QUIT, C_BACKGROUND, F_SERVER);
				PostActive (&msg);
				RemoveAutoexecChan (theChan);
			}
			return true;

		case ERR_UMODEUNKNOWNFLAG:		// 501
			{
				BMessage msg (M_DISPLAY);
				BString buffer = "[x] ";

		buffer += B_TRANSLATE("Unknown mode flag.");
				buffer += "\n";
				PackDisplay (&msg, buffer.String(), C_QUIT);
				PostActive (&msg);
			}
			return true;

		// not sure what these numerics are,
		// but they are usually on-connect messages
		case RPL_290:								 // 290
		case RPL_291:								 // 291
		case RPL_292:								 // 292
			{
				BString tempString (RestOfString(data, 4));
				tempString.RemoveFirst (":");
				tempString.Append ("\n");
				tempString.Prepend ("- ");
				Display (tempString.String());
			}
			return true;

		case RPL_WHOISREGISTEREDBOT:	// 617
			{
				// conflicts with RPL_DCCALLOWCHANGE
				BString theNick (GetWord (data, 4)),
								theMessage (RestOfString (data, 5)),
								tempString;
				theNick.RemoveFirst (":");
				theMessage.RemoveFirst (":");
				theMessage.Append ("\n");

				switch (fIrcdtype)
				{
					case IRCD_ULTIMATE:
						{
							tempString += "[@] ";
							tempString += theMessage;
							BMessage msg (M_DISPLAY);
							PackDisplay (&msg, tempString.String(), C_WHOIS, C_BACKGROUND, F_SERVER);
							PostActive (&msg);
						}
						break;

					default:
						{
							tempString += theNick;
							tempString += " ";
							tempString += theMessage;
							Display (tempString.String());
						}
				}
			}
			return true;

		default:
			break;
	}

	return false;
}
Example #20
0
void
THeaderView::InitGroupCompletion()
{
	// get boot volume
	BVolume volume;
	BVolumeRoster().GetBootVolume(&volume);

	// Build a list of all unique groups and the addresses they expand to.
	BQuery query;
	query.SetVolume(&volume);
	query.SetPredicate("META:group=**");
	query.Fetch();

	map<BString *, BString *, CompareBStrings> groupMap;
	entry_ref ref;
	BNode file;
	while (query.GetNextRef(&ref) == B_OK) {
		if (file.SetTo(&ref) != B_OK)
			continue;

		BString groups;
		if (file.ReadAttrString("META:group", &groups) < B_OK || groups.Length() == 0)
			continue;

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

		// avoid adding an empty address
		if (address.Length() == 0)
			continue;

		char *group = groups.LockBuffer(groups.Length());
		char *next = strchr(group, ',');

		for (;;) {
			if (next)
				*next = 0;

			while (*group && *group == ' ')
				group++;

			BString *groupString = new BString(group);
			BString *addressListString = NULL;

			// nobody is in this group yet, start it off
			if (groupMap[groupString] == NULL) {
				addressListString = new BString(*groupString);
				addressListString->Append(" ");
				groupMap[groupString] = addressListString;
			} else {
				addressListString = groupMap[groupString];
				addressListString->Append(", ");
				delete groupString;
			}

			// Append the user's address to the end of the string with the
			// comma separated list of addresses.  If not present, add the
			// < and > brackets around the address.

			if (address.FindFirst ('<') < 0) {
				address.ReplaceAll ('>', '_');
				address.Prepend ("<");
				address.Append(">");
			}
			addressListString->Append(address);

			if (!next)
				break;

			group = next + 1;
			next = strchr(group, ',');
		}
	}

	map<BString *, BString *, CompareBStrings>::iterator iter;
	for (iter = groupMap.begin(); iter != groupMap.end();) {
		BString *group = iter->first;
		BString *addr = iter->second;
		fEmailList.AddChoice(addr->String());
		++iter;
		groupMap.erase(group);
		delete group;
		delete addr;
	}
}
Example #21
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 #22
0
bool
MSHLanguageMgr::LoadLanguageFiles(const char * pathToFileStub)
{
	if (NULL != fTransFiles) {
		DeleteAllLanguageFilesAndList();
	}

	fTransFiles = new BList();

	// Sanity check.
	if (NULL == fTransFiles) {
		return false;
	}

	bool loadedAtLeastOne = false;

	// Create a list of MSHLanguageFiles, one for each file found at
	// the passed-in location, using the included stub file prefix.
	fFileNameStub = "";
	BString pathAndStub(pathToFileStub);
	BString pathOnly = "";

	// Obtain the path component separately from the file name stub.
	const int32 posOfLastFolderSlash = pathAndStub.FindLast('/');
	if (B_ERROR == posOfLastFolderSlash) {
		// Must be just a filename.
		fFileNameStub = pathAndStub;
	} else {
		pathAndStub.CopyInto(pathOnly, 0 /*sourceOffset*/, posOfLastFolderSlash);
		if (pathAndStub.Length() >= (posOfLastFolderSlash + 1)) {
			pathAndStub.CopyInto(fFileNameStub, (posOfLastFolderSlash + 1), (pathAndStub.Length() - 1));
		}
	}

	if (fFileNameStub.Length() > 0) {

		// Check for a relative path. If relative, then add the app directory to the start.
		if ((pathOnly == "") || (pathOnly.FindFirst('/') > 0)) {
			app_info ai;
			be_app->GetAppInfo(&ai);
			BEntry appEntry(&ai.ref);
			BPath appPathWithLeafName;
			appEntry.GetPath(&appPathWithLeafName);
			BPath appPathOnly;
			appPathWithLeafName.GetParent(&appPathOnly);
			appPathWithLeafName.Unset();

			if (pathOnly.FindLast('/') != (pathOnly.Length() - 1)) {
				pathOnly.Prepend("/");
			}
			pathOnly.Prepend(appPathOnly.Path());
			appPathOnly.Unset();
			appEntry.Unset();			
		}

		if (pathOnly.Length() > 0) {
			// Find all files in the specified directory that have a name beginning
			// with the specified stub.
			char nameBuffer[B_FILE_NAME_LENGTH];
			BDirectory langDir(pathOnly.String());
			BEntry nextEntry;
			while (langDir.GetNextEntry(&nextEntry) == B_OK) {
				if (B_OK == nextEntry.GetName(nameBuffer)) {
					BString nameStr(nameBuffer);
					if (nameStr.FindFirst(fFileNameStub) == 0) {
						// We have a winner! Matching stub on filename (after adding on path)
						nameStr.Prepend("/");
						nameStr.Prepend(pathOnly);
						MSHLanguageFile* newLangFile = new MSHLanguageFile(nameStr.String());
						fTransFiles->AddItem(newLangFile);
						loadedAtLeastOne = true;
					}
				}
				nextEntry.Unset();
			}
		}
	}

	if (!loadedAtLeastOne) {
		DeleteAllLanguageFilesAndList();
	}

	return loadedAtLeastOne;
}
Example #23
0
void
SourceFileC::UpdateDependencies(BuildInfo &info)
{
	BString abspath = GetPath().GetFullPath();
	if (abspath[0] != '/')
	{
		abspath.Prepend("/");
		abspath.Prepend(info.projectFolder.GetFullPath());
	}
	
	BString command;
	
	if (gUseFastDep && gFastDepAvailable)
		command << "fastdep " << info.includeString << " '" << abspath.String() << "'";
	else
		command << "gcc -MM " << info.includeString << " '" << abspath.String() << "'";
	
	BString depstr;
	RunPipedCommand(command.String(), depstr, true);
	
	STRACE(1,("Update Dependencies for %s\nCommand:%s\nOutput:%s\n",
			GetPath().GetFullPath(),command.String(),depstr.String()));
	
	if (gUseFastDep && gFastDepAvailable)
	{
		if (depstr.FindFirst("error ") == 0)
		{
			int32 index, startpos = 0;
			index = depstr.FindFirst("error ", startpos);
			while (index >= 0)
			{
				startpos = index + 6;
				index = depstr.FindFirst("error ", startpos);
			}
			
			index = depstr.FindFirst("\n") + 1;
			depstr = depstr.String() + index;
		}
		
		// The first part of the dependency string should be FileName.o:
		int32 secondlinepos = depstr.FindFirst("\n") + 1;
		
		BString tempstr = depstr;
		depstr = tempstr.String() + secondlinepos;
		
		depstr.ReplaceAll(" \\\n\t","|");
		
		if (depstr.FindLast("\n") == depstr.CountChars() - 1)
			depstr.RemoveLast("\n");
		
		if (depstr.FindFirst(" ") == 0)
			depstr.RemoveFirst(" ");
		
		fDependencies = depstr;
	}
	else
	{
		// The reason that all of this works is because the absolute paths force
		// each file to be on a separate line. Going with relative paths is FAR more
		// of a headache than I want to mess with. Bleah.
		
		if (depstr.FindFirst(" warning: ") >= 0)
		{
			int32 index, startpos = 0;
			index = depstr.FindFirst(" warning: ", startpos);
			while (index >= 0)
			{
				startpos = index + 10;
				index = depstr.FindFirst(" warning: ", startpos);
			}
			
			index = depstr.FindFirst("\n") + 1;
			depstr = depstr.String() + index;
		}
		
		// The first part of the dependency string should be FileName.o:
		BString objfilename = GetPath().GetBaseName();
		objfilename << ".o: ";
		
		int32 filenamepos = depstr.FindFirst(objfilename.String());
		if (filenamepos == 0)
		{
			int32 lineend = depstr.FindFirst("\n",filenamepos);
			if (lineend >= 0)
				fDependencies = depstr.String() + lineend + 2;
		}
		else
			fDependencies = depstr.String();
		
		fDependencies.RemoveSet("\\\n");
		fDependencies.ReplaceAll("  ","|");
		fDependencies.ReplaceAll("| ","|");
		if (fDependencies[0] == ' ')
			fDependencies.RemoveFirst(" ");
	}
}
Example #24
0
status_t
BEmailMessage::RenderTo(BDirectory *dir, BEntry *msg)
{
	time_t currentTime;
	char numericDateString [40];
	struct tm timeFields;
	BString worker;

	// Generate a file name for the outgoing message.  See also
	// FolderFilter::ProcessMailMessage which does something similar for
	// incoming messages.

	BString name = Subject();
	SubjectToThread (name); // Extract the core subject words.
	if (name.Length() <= 0)
		name = "No Subject";
	if (name[0] == '.')
		name.Prepend ("_"); // Avoid hidden files, starting with a dot.

	// Convert the date into a year-month-day fixed digit width format, so that
	// sorting by file name will give all the messages with the same subject in
	// order of date.
	time (&currentTime);
	localtime_r (&currentTime, &timeFields);
	sprintf (numericDateString, "%04d%02d%02d%02d%02d%02d",
		timeFields.tm_year + 1900,
		timeFields.tm_mon + 1,
		timeFields.tm_mday,
		timeFields.tm_hour,
		timeFields.tm_min,
		timeFields.tm_sec);
	name << " " << numericDateString;

	worker = From();
	extract_address_name(worker);
	name << " " << worker;

	name.Truncate(222);	// reserve space for the uniquer

	// Get rid of annoying characters which are hard to use in the shell.
	name.ReplaceAll('/','_');
	name.ReplaceAll('\'','_');
	name.ReplaceAll('"','_');
	name.ReplaceAll('!','_');
	name.ReplaceAll('<','_');
	name.ReplaceAll('>','_');
	while (name.FindFirst("  ") >= 0) // Remove multiple spaces.
		name.Replace("  " /* Old */, " " /* New */, 1024 /* Count */);

	int32 uniquer = time(NULL);
	worker = name;

	int32 tries = 30;
	bool exists;
	while ((exists = dir->Contains(worker.String())) && --tries > 0) {
		srand(rand());
		uniquer += (rand() >> 16) - 16384;

		worker = name;
		worker << ' ' << uniquer;
	}

	if (exists)
		printf("could not create mail! (should be: %s)\n", worker.String());

	BFile file;
	status_t status = dir->CreateFile(worker.String(), &file);
	if (status < B_OK)
		return status;

	if (msg != NULL)
		msg->SetTo(dir,worker.String());

	return RenderToRFC822(&file);
}
Example #25
0
File: smtp.cpp Project: DonCN/haiku
status_t
SMTPProtocol::Send(const char* to, const char* from, BPositionIO *message)
{
	BString cmd = from;
	cmd.Remove(0, cmd.FindFirst("\" <") + 2);
	cmd.Prepend("MAIL FROM: ");
	cmd += CRLF;
	if (SendCommand(cmd.String()) != B_OK)
		return B_ERROR;

	int32 len = strlen(to);
	BString addr("");
	for (int32 i = 0;i < len;i++) {
		char c = to[i];
		if (c != ',')
			addr += (char)c;
		if (c == ','||i == len-1) {
			if(addr.Length() == 0)
				continue;
			cmd = "RCPT TO: ";
			cmd << addr.String() << CRLF;
			if (SendCommand(cmd.String()) != B_OK)
				return B_ERROR;

			addr ="";
		}
	}

	cmd = "DATA";
	cmd += CRLF;
	if (SendCommand(cmd.String()) != B_OK)
		return B_ERROR;

	// Send the message data.  Convert lines starting with a period to start
	// with two periods and so on.  The actual sequence is CR LF Period.  The
	// SMTP server will remove the periods.  Of course, the POP server may then
	// add some of its own, but the POP client should take care of them.

	ssize_t amountRead;
	ssize_t amountToRead;
	ssize_t amountUnread;
	ssize_t bufferLen = 0;
	const int bufferMax = 2000;
	bool foundCRLFPeriod;
	int i;
	bool messageEndedWithCRLF = false;

	message->Seek(0, SEEK_END);
	amountUnread = message->Position();
	message->Seek(0, SEEK_SET);
	char *data = new char[bufferMax];

	while (true) {
		// Fill the buffer if it is getting low, but not every time, to avoid
		// small reads.
		if (bufferLen < bufferMax / 2) {
			amountToRead = bufferMax - bufferLen;
			if (amountToRead > amountUnread)
				amountToRead = amountUnread;
			if (amountToRead > 0) {
				amountRead = message->Read (data + bufferLen, amountToRead);
				if (amountRead <= 0 || amountRead > amountToRead)
					amountUnread = 0; // Just stop reading when an error happens.
				else {
					amountUnread -= amountRead;
					bufferLen += amountRead;
				}
			}
		}

		// Look for the next CRLFPeriod triple.
		foundCRLFPeriod = false;
		for (i = 0; i <= bufferLen - 3; i++) {
			if (data[i] == '\r' && data[i+1] == '\n' && data[i+2] == '.') {
				foundCRLFPeriod = true;
				// Send data up to the CRLF, and include the period too.
#ifdef USE_SSL
				if (use_ssl) {
					if (SSL_write(ssl,data,i + 3) < 0) {
						amountUnread = 0; // Stop when an error happens.
						bufferLen = 0;
						break;
					}
				} else
#endif
				if (send (fSocket,data, i + 3,0) < 0) {
					amountUnread = 0; // Stop when an error happens.
					bufferLen = 0;
					break;
				}
				ReportProgress (i + 2 /* Don't include the double period here */,0);
				// Move the data over in the buffer, but leave the period there
				// so it gets sent a second time.
				memmove(data, data + (i + 2), bufferLen - (i + 2));
				bufferLen -= i + 2;
				break;
			}
		}

		if (!foundCRLFPeriod) {
			if (amountUnread <= 0) { // No more data, all we have is in the buffer.
				if (bufferLen > 0) {
                            #ifdef USE_SSL
                                    if (use_ssl)
                                            SSL_write(ssl,data,bufferLen);
                                    else
                            #endif
					send (fSocket,data, bufferLen,0);
					ReportProgress (bufferLen,0);
					if (bufferLen >= 2)
						messageEndedWithCRLF = (data[bufferLen-2] == '\r' &&
							data[bufferLen-1] == '\n');
				}
				break; // Finished!
			}

			// Send most of the buffer, except a few characters to overlap with
			// the next read, in case the CRLFPeriod is split between reads.
			if (bufferLen > 3) {
                        #ifdef USE_SSL
                            if (use_ssl) {
                                    if (SSL_write(ssl,data,bufferLen - 3) < 0)
                                        break;
                            } else
                        #endif
				if (send (fSocket,data, bufferLen - 3,0) < 0)
					break; // Stop when an error happens.
				ReportProgress (bufferLen - 3,0);
				memmove (data, data + bufferLen - 3, 3);
				bufferLen = 3;
			}
		}
	}
	delete [] data;

	if (messageEndedWithCRLF)
		cmd = "."CRLF; // The standard says don't add extra CRLF.
	else
		cmd = CRLF"."CRLF;

	if (SendCommand(cmd.String()) != B_OK)
		return B_ERROR;

	return B_OK;
}
Example #26
0
void
NotifyList::MouseDown (BPoint myPoint)
{
  BMessage *msg (Window()->CurrentMessage());
  int32 selected (IndexOf (myPoint));
  if (selected >= 0)
  {
    BMessage *inputMsg (Window()->CurrentMessage());
    int32 mousebuttons (0),
          keymodifiers (0);
    
    NotifyListItem *item ((NotifyListItem *)ItemAt(selected));
    if (!item)
      return;
    
    inputMsg->FindInt32 ("buttons", &mousebuttons);
    inputMsg->FindInt32 ("modifiers", &keymodifiers);
    
    bigtime_t sysTime;
    msg->FindInt64 ("when", &sysTime);
    uint16 clicks = CheckClickCount (myPoint, fLastClick, sysTime, fLastClickTime, fClickCount) % 3;
    
    // slight kludge to make sure the expand/collapse triangles behave how they should
    // -- needed since OutlineListView's Expand/Collapse-related functions are not virtual
    if (mousebuttons == B_PRIMARY_MOUSE_BUTTON)
    {
      if (((clicks % 2) == 0) && item->GetState())
      {
        // react to double click by creating a new messageagent or selecting
        // an existing one (use /query logic in parsecmd)
        BString data (item->Text());
        data.Prepend ("/QUERY ");
        BMessage submitMsg (M_SUBMIT);
        submitMsg.AddString ("input", data.String());
        submitMsg.AddBool ("history", false);
        // don't clear in case user has something typed in text control
        submitMsg.AddBool ("clear", false);
        WindowListItem *winItem ((WindowListItem *)vision_app->pClientWin()->pWindowList()->ItemAt(
          vision_app->pClientWin()->pWindowList()->CurrentSelection()));
        if (winItem)
        {
          BMessenger msgr (winItem->pAgent());
          if (msgr.IsValid())
            msgr.SendMessage(&submitMsg);
        }
      }
      else
        Select (selected);
    }
    
    if ((keymodifiers & B_SHIFT_KEY)  == 0
    && (keymodifiers & B_OPTION_KEY)  == 0
    && (keymodifiers & B_COMMAND_KEY) == 0
    && (keymodifiers & B_CONTROL_KEY) == 0)
    {
      if (mousebuttons == B_SECONDARY_MOUSE_BUTTON)
      {
        if (item)
        {
          if(!item->IsSelected())
            Select (IndexOf (myPoint));

          BuildPopUp();

          fMyPopUp->Go (
            ConvertToScreen (myPoint),
            true,
            true,
            ConvertToScreen (ItemFrame (selected)),
            true);
        }
      }
    }
  }

}
Example #27
0
void
AppView::MessageReceived(BMessage* message)
{
	//PRINT(("AppView::MessageReceived(BMessage*)\n"));

	switch(message->what)
	{
		case SELECTION_CHANGED:
			SelectionChanged();
			break;
		case MSG_APPLY:
			Apply();
			break;
		case MSG_RESET:
			Reset();
			break;
		case START_APPLY:
			m_applying = true;
			m_status_card->SetVisibleItem(INDEX_STATUSBAR);
			m_apply_button->SetEnabled(false);
			m_reset_button->SetEnabled(false);
			m_pick_list_view->MessageReceived(message);
			break;
		case END_APPLY:
			m_applying = false;
			m_status_card->SetVisibleItem(INDEX_BARBERPOLE);
			m_apply_button->SetEnabled(true);
			m_reset_button->SetEnabled(true);
			SelectionChanged();
			EnableInterface();
			m_pick_list_view->MessageReceived(message);
			break;
		case STATUS_BAR_SET_MAX_VALUE:
			int32 maxValue;
			message->FindInt32("maxValue",&maxValue);
			m_status_bar->SetMaxValue(maxValue);
			break;
		case STATUS_BAR_FILE:
		{
			BString file;
			if (message->FindString("file", &file) == B_OK)
			{
				file.Prepend("  ");
				m_status_bar->SetText(file.String());
			}
			break;
		}
		case STATUS_BAR_UPDATE:
			m_status_bar->Update(1);
			break;
		case STATUS_BAR_RESET:
			m_status_bar->Reset("0%","100%");
			break;
		case INVALIDATE_LIST:
			m_list_view->Invalidate();
			m_list_view->SortItems(&AppView::SortFunc);
			break;
		case B_REFS_RECEIVED:
			AddRefs(message);
			break;
		case B_SIMPLE_DATA:
			AddRefs(message);
			break;

		default:
			BView::MessageReceived(message);
	}
}
Example #28
0
void
ProjectWindow::MessageReceived(BMessage *msg)
{
	status_t status;
	
	if ( (msg->WasDropped() && msg->what == B_SIMPLE_DATA) || msg->what == M_ADD_FILES)
	{
		fAddFileStruct.refmsg = *msg;
		fAddFileStruct.parent = this;
		
		uint32 buttons;
		fProjectList->GetMouse(&fAddFileStruct.droppt,&buttons);
		
		thread_id addThread = spawn_thread(AddFileThread,"file adding thread",
											B_NORMAL_PRIORITY, &fAddFileStruct);
		if (addThread >= 0)
			resume_thread(addThread);
	}
	switch (msg->what)
	{
		case M_IMPORT_REFS:
		{
			fImportStruct.refmsg = *msg;
			fImportStruct.parent = this;
			
			thread_id importThread = spawn_thread(ImportFileThread,"file import thread",
												B_NORMAL_PRIORITY, &fImportStruct);
			if (importThread >= 0)
				resume_thread(importThread);
			break;
		}
		case M_BACKUP_PROJECT:
		{
			thread_id backupThread = spawn_thread(BackupThread,"project backup thread",
												B_NORMAL_PRIORITY, this);
			if (backupThread >= 0)
			{
				fStatusBar->SetText(TR("Backing up project"));
				UpdateIfNeeded();
				
				SetMenuLock(true);
				resume_thread(backupThread);
			}
			break;
		}
		case M_GET_CHECK_IN_MSG:
		{
			if (!fSourceControl)
			{
				printf("NULL source control\n");
				break;
			}
			
			BString out;
			fSourceControl->GetCheckinHeader(out);
			
			bool select = false;
			if (out.CountChars() > 1)
				out.Prepend("\n\n");
			else
			{
				out = TR("Enter the description for the changes in this revision.");
				select = true;
			}
			
			GetTextWindow *gtw = new GetTextWindow("Paladin", out.String(),
													BMessage(M_CHECK_IN_PROJECT),
													BMessenger(this));
			if (!select)
				gtw->GetTextView()->Select(0,0);
			gtw->Show();
			break;
		}
		case M_CHECK_IN_PROJECT:
		{
			BString commitstr;
			if (msg->FindString("text", &commitstr) == B_OK && fSourceControl)
			{
				SCMOutputWindow *win = new SCMOutputWindow(TR("Commit"));
				win->Show();
				fSourceControl->Commit(commitstr.String());
			}
			break;
		}
		case M_REVERT_PROJECT:
		{
			if (!fSourceControl)
				break;
			
			int32 result = ShowAlert(TR("This will undo all changes since the last commit. "
										"Continue?"), "Don't Revert", "Revert");
			if (result == 1)
			{
				SCMOutputWindow *win = new SCMOutputWindow(TR("Revert"));
				win->Show();
				fSourceControl->Revert(NULL);
			}
			break;
		}
		case M_REBUILD_FILE:
		case M_ADD_SELECTION_TO_REPO:
		case M_REMOVE_SELECTION_FROM_REPO:
		case M_REVERT_SELECTION:
		case M_DIFF_SELECTION:
		{
			ActOnSelectedFiles(msg->what);
			break;
		}
		case M_DIFF_PROJECT:
		{
			if (fSourceControl)
			{
				SCMOutputWindow *win = new SCMOutputWindow(TR("Differences"));
				win->Show();
				fSourceControl->Diff(NULL);
			}
			break;
		}
		case M_PROJECT_SCM_STATUS:
		{
			if (fSourceControl)
			{
				SCMOutputWindow *win = new SCMOutputWindow(TR("Project Status"));
				BString strstatus;
				fSourceControl->GetChangeStatus(strstatus);
				win->GetTextView()->SetText(strstatus.String());
				win->Show();
			}
			break;
		}
		case M_PUSH_PROJECT:
		{
			if (fSourceControl)
			{
				SCMOutputWindow *win = new SCMOutputWindow(TR("Push"));
				win->Show();
				fSourceControl->Push(NULL);
			}
			break;
		}
		case M_PULL_PROJECT:
		{
			if (fSourceControl)
			{
				SCMOutputWindow *win = new SCMOutputWindow(TR("Pull"));
				win->Show();
				status = fSourceControl->Pull(NULL);
				
				if (!status)
					ShowAlert("Unable to pull from the remote repository. If it "
							"uses a secure connection, please set up the appropriate "
							"SSH keys on the remote server.", "OK");
			}
			break;
		}
		case M_CULL_EMPTY_GROUPS:
		{
			CullEmptyGroups();
			break;
		}
		case M_RUN_FILE_TYPES:
		{
			int32 selection = fProjectList->FullListCurrentSelection();
			if (selection < 0)
				break;
			
			SourceFileItem *item = dynamic_cast<SourceFileItem*>(fProjectList->FullListItemAt(selection));
			if (!item)
				break;
			SpawnFileTypes(item->GetData()->GetPath());
			break;
		}
		case M_OPEN_PARENT_FOLDER:
		{
			BMessage openmsg(B_REFS_RECEIVED);
			int32 selindex = 0;
			int32 selection = fProjectList->FullListCurrentSelection();
			selindex++;
			if (selection >= 0)
			{
				while (selection >= 0)
				{
					SourceFileItem *item = dynamic_cast<SourceFileItem*>(fProjectList->FullListItemAt(selection));
					if (!item)
						break;
					
					SourceFile *file = item->GetData();
					BString abspath = file->GetPath().GetFullPath();
					if (abspath[0] != '/')
					{
						abspath.Prepend("/");
						abspath.Prepend(fProject->GetPath().GetFolder());
					}
					DPath filepath(abspath);
					
					entry_ref ref;
					BEntry(filepath.GetFolder()).GetRef(&ref);
					
					openmsg.AddRef("refs",&ref);
					selection = fProjectList->FullListCurrentSelection(selindex++);
				}
				
				BMessenger msgr("application/x-vnd.Be-TRAK");
				msgr.SendMessage(&openmsg);
			}
			
			break;
		}
		case M_SHOW_PROJECT_FOLDER:
		{
			entry_ref ref;
			BEntry(fProject->GetPath().GetFolder()).GetRef(&ref);
			BMessenger msgr("application/x-vnd.Be-TRAK");
			
			BMessage openmsg(B_REFS_RECEIVED);
			openmsg.AddRef("refs",&ref);
			msgr.SendMessage(&openmsg);
			break;
		}
		case M_SHOW_ASCII_TABLE:
		{
			AsciiWindow *ascwin = new AsciiWindow();
			ascwin->Show();
			break;
		}
		case M_SHOW_VREGEX:
		{
			VRegWindow *vregwin = new VRegWindow();
			vregwin->Show();
			break;
		}
		case M_SHOW_LICENSES:
		{
			LicenseManager *man = new LicenseManager(fProject->GetPath().GetFolder());
			man->Show();
			break;
		}
		case M_RUN_TOOL:
		{
			BString sig;
			if (msg->FindString("signature", &sig) == B_OK)
			{
				LaunchHelper launcher(sig.String());
				launcher.Launch();
			}
			break;
		}
		case M_MAKE_MAKE:
		{
			DPath out(fProject->GetPath().GetFolder());
			out.Append("Makefile");
			if (MakeMake(fProject,out) == B_OK);
			{
				BEntry entry(out.GetFullPath());
				entry_ref ref;
				if (entry.InitCheck() == B_OK)
				{
					entry.GetRef(&ref);
					BMessage refmsg(B_REFS_RECEIVED);
					refmsg.AddRef("refs",&ref);
					be_app->PostMessage(&refmsg);
				}
			}
			break;
		}
		case M_SHOW_CODE_LIBRARY:
		{
			#ifdef BUILD_CODE_LIBRARY
			CodeLibWindow *libwin = CodeLibWindow::GetInstance(BRect(100,100,500,350));
			libwin->Show();
			#endif
			
			break;
		}
		case M_OPEN_PARTNER:
		{
			int32 selection = fProjectList->FullListCurrentSelection();
			if (selection < 0)
				break;
			
			SourceFileItem *item = dynamic_cast<SourceFileItem*>(
									fProjectList->FullListItemAt(selection));
			if (!item)
				break;
			entry_ref ref;
			BEntry(fProject->GetPathForFile(item->GetData()).GetFullPath()).GetRef(&ref);
			BMessage refmsg(M_OPEN_PARTNER);
			refmsg.AddRef("refs",&ref);
			be_app->PostMessage(&refmsg);
			break;
		}
		case M_NEW_GROUP:
		{
			MakeGroup(fProjectList->FullListCurrentSelection());
			PostMessage(M_SHOW_RENAME_GROUP);
			break;
		}
		case M_SHOW_RENAME_GROUP:
		{
			int32 selection = fProjectList->FullListCurrentSelection();
			SourceGroupItem *groupItem = NULL;
			if (selection < 0)
			{
				// Don't need a selection if there is only one group in the project
				if (fProject->CountGroups() == 1)
					groupItem = fProjectList->ItemForGroup(fProject->GroupAt(0));
			}
			else
			{
				BStringItem *strItem = (BStringItem*)fProjectList->FullListItemAt(selection);
				groupItem = fProjectList->GroupForItem(strItem);
			}
			
			if (!groupItem)
				break;
			
			GroupRenameWindow *grwin = new GroupRenameWindow(groupItem->GetData(),
															BMessage(M_RENAME_GROUP),
															BMessenger(this));
			grwin->Show();
			break;
		}
		case M_RENAME_GROUP:
		{
			SourceGroup *group;
			BString newname;
			if (msg->FindPointer("group",(void**)&group) != B_OK ||
				msg->FindString("newname",&newname) != B_OK)
				break;
			
			group->name = newname;
			SourceGroupItem *groupItem = fProjectList->ItemForGroup(group);
			if (!groupItem)
				break;
			
			groupItem->SetText(newname.String());
			fProjectList->InvalidateItem(fProjectList->IndexOf(groupItem));
			
			fProject->Save();
			break;
		}
		case M_SORT_GROUP:
		{
			int32 selection = fProjectList->FullListCurrentSelection();
			
			SourceGroupItem *groupItem = NULL;
			if (selection < 0)
			{
				// Don't need a selection if there is only one group in the project
				if (fProject->CountGroups() == 1)
					groupItem = fProjectList->ItemForGroup(fProject->GroupAt(0));
			}
			else
			{
				BStringItem *strItem = (BStringItem*)fProjectList->FullListItemAt(selection);
				groupItem = fProjectList->GroupForItem(strItem);
			}
			
			if (!groupItem)
				break;
			
			fProjectList->SortItemsUnder(groupItem,true,compare_source_file_items);
			groupItem->GetData()->Sort();
			fProject->Save();
			
			break;
		}
		case M_TOGGLE_ERROR_WINDOW:
		{
			ToggleErrorWindow(fProject->GetErrorList());
			break;
		}
		case M_SHOW_ERROR_WINDOW:
		{
			ShowErrorWindow(fProject->GetErrorList());
			break;
		}
		case M_SHOW_PROJECT_SETTINGS:
		{
			BRect r(0,0,350,300);
			BRect screen(BScreen().Frame());
			
			r.OffsetTo((screen.Width() - r.Width()) / 2.0,
						(screen.Height() - r.Height()) / 2.0);
			
			ProjectSettingsWindow *win = new ProjectSettingsWindow(r,fProject);
			win->Show();
			break;
		}
		case M_SHOW_RUN_ARGS:
		{
			RunArgsWindow *argwin = new RunArgsWindow(fProject);
			argwin->Show();
			break;
		}
		case M_JUMP_TO_MSG:
		{
			entry_ref ref;
			if (msg->FindRef("refs",&ref) == B_OK)
			{
				msg->what = B_REFS_RECEIVED;
				be_app->PostMessage(msg);
			}
			break;
		}
		case B_ABOUT_REQUESTED:
		{
			be_app->PostMessage(B_ABOUT_REQUESTED);
			break;
		}
		case M_SHOW_OPEN_PROJECT:
		{
			be_app->PostMessage(msg);
			break;
		}
		case M_NEW_WINDOW:
		{
			be_app->PostMessage(M_NEW_PROJECT);
			break;
		}
		case M_SHOW_PROGRAM_SETTINGS:
		{
			PrefsWindow *prefwin = new PrefsWindow(BRect(0,0,500,400));
			prefwin->Show();
			break;
		}
		case M_SHOW_FIND_AND_OPEN_PANEL:
		{
			BString text;
			msg->FindString("name",&text);
			
			// Passing a NULL string to this is OK
			FindOpenFileWindow *findwin = new FindOpenFileWindow(text.String());
			findwin->Show();
			break;
		}
		case M_FILE_NEEDS_BUILD:
		{
			SourceFile *file;
			if (msg->FindPointer("file",(void**)&file) == B_OK)
			{
				SourceFileItem *item = fProjectList->ItemForFile(file);
				if (item)
				{
					item->SetDisplayState(SFITEM_NEEDS_BUILD);
					fProjectList->InvalidateItem(fProjectList->IndexOf(item));
				}
			}
			break;
		}
		case M_EDIT_FILE:
		{
			int32 i = 0;
			int32 selection = fProjectList->FullListCurrentSelection(i);
			i++;
			
			BMessage refmsg(B_REFS_RECEIVED);
			while (selection >= 0)
			{
				SourceFileItem *item = dynamic_cast<SourceFileItem*>
										(fProjectList->FullListItemAt(selection));
				if (item && item->GetData())
				{
					BString abspath = item->GetData()->GetPath().GetFullPath();
					if (abspath[0] != '/')
					{
						abspath.Prepend("/");
						abspath.Prepend(fProject->GetPath().GetFolder());
					}
					
					BEntry entry(abspath.String());
					if (entry.InitCheck() == B_OK)
					{
						entry_ref ref;
						entry.GetRef(&ref);
						refmsg.AddRef("refs",&ref);
					}
					else
					{
						if (!entry.Exists())
						{
							BString errmsg = TR("Couldn't find XXXXX. It may have been moved or renamed.");
							errmsg.ReplaceFirst("XXXXX",abspath.String());
							ShowAlert(errmsg.String());
						}
					}
				}
				else
				{
					SourceGroupItem *groupItem = dynamic_cast<SourceGroupItem*>
											(fProjectList->FullListItemAt(selection));
					if (groupItem)
					{
						if (groupItem->IsExpanded())
							fProjectList->Collapse(groupItem);
						else
							fProjectList->Expand(groupItem);
						groupItem->GetData()->expanded = groupItem->IsExpanded();
					}
					
				}
				
				selection = fProjectList->CurrentSelection(i);
				i++;
			}
			be_app->PostMessage(&refmsg);
			break;
		}
		case M_LIBWIN_CLOSED:
		{
			fShowingLibs = false;
			break;
		}
		case M_SHOW_LIBRARIES:
		{
			fShowingLibs = true;
			LibraryWindow *libwin = new LibraryWindow(Frame().OffsetByCopy(15,15),
														BMessenger(this), fProject);
			libwin->Show();
			break;
		}
		case M_SHOW_ADD_NEW_PANEL:
		{
			AddNewFileWindow *anfwin = new AddNewFileWindow(BMessage(M_ADD_NEW_FILE),
														BMessenger(this));
			anfwin->Show();
			break;
		}
		case M_SHOW_FIND_IN_PROJECT_FILES:
		{
			if (!gLuaAvailable)
			{
				ShowAlert("Paladin's multi-file Find window depends on Lua. It will "
						"need to be installed if you wish to use this feature.", "OK",
						NULL, NULL, B_STOP_ALERT);
				break;
			}
			
			FindWindow *findwin = new FindWindow();
			findwin->Show();
			break;
		}
		case M_ADD_NEW_FILE:
		{
			BString name;
			bool makepair;
			if (msg->FindString("name",&name) == B_OK && msg->FindBool("makepair",&makepair) == B_OK)
				AddNewFile(name,makepair);
			break;
		}
		case M_SHOW_ADD_PANEL:
		{
			if (!fFilePanel)
			{
				BMessenger msgr(this);
				BEntry entry(fProject->GetPath().GetFolder());
				entry_ref ref;
				entry.GetRef(&ref);
				fFilePanel = new BFilePanel(B_OPEN_PANEL,&msgr,&ref,B_FILE_NODE,true,
											new BMessage(M_ADD_FILES));
			}
			fFilePanel->Show();
			break;
		}
		case M_REMOVE_FILES:
		{
			bool save = false;
			
			for (int32 i = 0; i < fProjectList->CountItems(); i++)
			{
				SourceFileItem *item = dynamic_cast<SourceFileItem*>(fProjectList->ItemAt(i));
				if (item && item->IsSelected())
				{
					fProjectList->RemoveItem(item);
					fProject->RemoveFile(item->GetData());
					delete item;
					save = true;
					i--;
				}
			}
			CullEmptyGroups();
			if (save)
				fProject->Save();
			break;
		}
		case M_EMPTY_CCACHE:
		{
			// We don't do this when forcing a rebuild of the sources because sometimes it
			// can take quite a while
			if (gUseCCache && gCCacheAvailable)
			{
				fStatusBar->SetText(TR("Emptying build cache"));
				UpdateIfNeeded();
				system("ccache -c > /dev/null");
				fStatusBar->SetText("");
				UpdateIfNeeded();
			}
			break;
		}
		case M_FORCE_REBUILD:
		{
			fProject->ForceRebuild();
			
			for (int32 i = 0; i < fProjectList->FullListCountItems(); i++)
			{
				SourceFileItem *item = dynamic_cast<SourceFileItem*>(fProjectList->FullListItemAt(i));
				if (!item)
					continue;
				
				SourceFile *file = item->GetData();
				if (file->UsesBuild())
				{
					item->SetDisplayState(SFITEM_NEEDS_BUILD);
					fProjectList->InvalidateItem(i);
				}
			}
			// This is necessary because InvalidateItem() uses indices from ItemAt(),
			// not FullListItemAt
			fProjectList->Invalidate();
			break;
		}
		case M_UPDATE_DEPENDENCIES:
		{
			UpdateDependencies();
			break;
		}
		case M_MAKE_PROJECT:
		case M_BUILD_PROJECT:
		{
			fBuildingFile = 0;
			DoBuild(POSTBUILD_NOTHING);
			break;
		}
		case M_RUN_PROJECT:
		{
			DoBuild(POSTBUILD_RUN);
			break;
		}
		case M_RUN_IN_TERMINAL:
		{
			DoBuild(POSTBUILD_RUN_IN_TERMINAL);
			break;
		}
		case M_DEBUG_PROJECT:
		{
			if (!fProject->Debug())
			{
				BString errmsg = TR("Your project does not have debugging information compiled ");
				errmsg << TR("in and will need to be rebuilt to debug. Do you wish to rebuild and ")
					<< TR("run the debugger?");
				int32 result = ShowAlert("Debugging information needs to compiled into "
										"your project. This may take some time for large "
										"projects. Do you wish to rebuild and run "
										"the debugger?",
										"Rebuild","Cancel");
				if (result == 1)
					break;
				
				fProject->SetDebug(true);
				fProject->Save();
				fProject->ForceRebuild();
			}
			
			DoBuild(POSTBUILD_DEBUG);
			break;
		}
		case M_EXAMINING_FILE:
		{
			SourceFile *file;
			if (msg->FindPointer("file",(void**)&file) == B_OK)
			{
				BString out;
				out << TR("Examining ") << file->GetPath().GetFileName();
				fStatusBar->SetText(out.String());
			}
			break;
		}
		case M_BUILDING_FILE:
		{
			SourceFile *file;
			if (msg->FindPointer("sourcefile",(void**)&file) == B_OK)
			{
				SourceFileItem *item = fProjectList->ItemForFile(file);
				if (item)
				{
					item->SetDisplayState(SFITEM_BUILDING);
					fProjectList->InvalidateItem(fProjectList->IndexOf(item));
					
					BString out;
					
					int32 count,total;
					if (msg->FindInt32("count",&count) == B_OK &&
						msg->FindInt32("total",&total) == B_OK)
					{
						fBuildingFile = MAX(fBuildingFile, count);
						out << "(" << fBuildingFile << "/" << total << ") ";
					}
					
					out << TR("Building ") << item->Text();
					fStatusBar->SetText(out.String());
				}
			}
			break;
		}
		case M_BUILDING_DONE:
		{
			SourceFile *file;
			if (msg->FindPointer("sourcefile",(void**)&file) == B_OK)
			{
				SourceFileItem *item = fProjectList->ItemForFile(file);
				if (item)
				{
					item->SetDisplayState(SFITEM_NORMAL);
					fProjectList->InvalidateItem(fProjectList->IndexOf(item));
				}
			}
			break;
		}
		case M_LINKING_PROJECT:
		{
			fStatusBar->SetText(TR("Linking"));
			break;
		}
		case M_UPDATING_RESOURCES:
		{
			fStatusBar->SetText(TR("Updating Resources"));
			break;
		}
		case M_DOING_POSTBUILD:
		{
			fStatusBar->SetText(TR("Performing Post-build tasks"));
			break;
		}
		case M_BUILD_FAILURE:
		{
			SetMenuLock(false);
			
			// fall through
		}
		case M_BUILD_MESSAGES:
		case M_BUILD_WARNINGS:
		{
			if (!fErrorWindow)
			{
				BRect screen(BScreen().Frame());
				BRect r(screen);
				r.left = r.right / 4.0;
				r.right *= .75;
				r.top = r.bottom - 200;
				
				BDeskbar deskbar;
				if (deskbar.Location() == B_DESKBAR_BOTTOM)
					r.OffsetBy(0,-deskbar.Frame().Height());
				
				fErrorWindow = new ErrorWindow(r,this);
				fErrorWindow->Show();
			}
			else
			{
				if (!fErrorWindow->IsFront())
					fErrorWindow->Activate();
			}
			fStatusBar->SetText("");
			
			// Should this be an Unflatten or an Append?
			ErrorList *errorList = fProject->GetErrorList();
			errorList->Unflatten(*msg);
			fErrorWindow->PostMessage(msg);
			break;
		}
		case M_BUILD_SUCCESS:
		{
			SetMenuLock(false);
			fStatusBar->SetText("");
			break;
		}
		case M_ERRORWIN_CLOSED:
		{
			fErrorWindow = NULL;
			break;
		}
		case M_SYNC_MODULES:
		{
			#ifdef BUILD_CODE_LIBRARY
			thread_id syncID = spawn_thread(SyncThread,"module update thread",
												B_NORMAL_PRIORITY, this);
			if (syncID >= 0)
				resume_thread(syncID);
			#endif
			break;
		}
		case M_TOGGLE_DEBUG_MENU:
		{
			ToggleDebugMenu();
			break;
		}
		case M_DEBUG_DUMP_DEPENDENCIES:
		{
			DumpDependencies(fProject);
			break;
		}
		case M_DEBUG_DUMP_INCLUDES:
		{
			DumpIncludes(fProject);
			break;
		}
		default:
		{
			DWindow::MessageReceived(msg);
			break;
		}
	}
}
Example #29
0
void ChannelAgent::UpdateMode(char theSign, char theMode)
{
	char modeString[2]; // necessary C-style string
	memset(modeString, 0, sizeof(modeString));
	sprintf(modeString, "%c", theMode);
	BString myTemp;

	if (theSign == '-') {
		switch (theMode) {
		case 'l': {
			myTemp = fChanLimit;
			myTemp.Append(" ");
			fChanMode.RemoveLast(myTemp);
			myTemp = fChanLimit;
			myTemp.Prepend(" ");
			fChanMode.RemoveLast(myTemp);
			fChanMode.RemoveLast(fChanLimit);
		} break;

		case 'k': {
			myTemp = fChanKey;
			myTemp.Append(" ");
			fChanMode.RemoveLast(myTemp);
			myTemp = fChanKey;
			myTemp.Prepend(" ");
			fChanMode.RemoveLast(myTemp);
			fChanMode.RemoveLast(fChanKey);
		} break;
		}

		fChanMode.RemoveFirst(modeString);
	} else {
		BString theReal(GetWord(fChanMode.String(), 1)),
			theRest(RestOfString(fChanMode.String(), 2));
		theReal.RemoveFirst(modeString);
		theReal.Append(modeString);
		BString tempString(theReal);
		if (theRest != "-9z99") {
			tempString += " ";
			tempString += theRest;
		}

		if (theMode == 'l') {
			if (fChanLimitOld != "") {
				BString theOld(" ");
				theOld += fChanLimitOld;
				tempString.RemoveFirst(theOld);
			}

			tempString.Append(" ");
			tempString.Append(fChanLimit);
			fChanLimitOld = fChanLimit;
		} else if (theMode == 'k') {
			if (fChanKeyOld != "") {
				BString theOld(" ");
				theOld += fChanKeyOld;
				tempString.RemoveFirst(theOld);
			}

			tempString.Append(" ");
			tempString.Append(fChanKey);
			fChanKeyOld = fChanKey;
		}

		fChanMode = tempString;
	}

	if (!IsHidden())
		vision_app->pClientWin()->pStatusView()->SetItemValue(STATUS_MODES, fChanMode.String());
}
Example #30
0
status_t
InterfaceHardwareView::Update()
{
	// Populate fields with current settings
	if (fSettings->HasLink()) {
		if (fSettings->IsWireless()) {
			BString network = fSettings->WirelessNetwork();
			network.Prepend(" (");
			network.Prepend(B_TRANSLATE("connected"));
			network.Append(")");
			fStatusField->SetText(network.String());
		} else {
			fStatusField->SetText(B_TRANSLATE("connected"));
		}
	} else
		fStatusField->SetText(B_TRANSLATE("disconnected"));

	fMacAddressField->SetText(fSettings->HardwareAddress());

	// TODO : Find how to get link speed
	fLinkSpeedField->SetText("100 Mb/s");

	// Update Link stats
	ifreq_stats stats;
	char buffer[100];
	fSettings->Stats(&stats);

	string_for_size(stats.send.bytes, buffer, sizeof(buffer));
	fLinkTxField->SetText(buffer);

	string_for_size(stats.receive.bytes, buffer, sizeof(buffer));
	fLinkRxField->SetText(buffer);

	// TODO move the wireless info to a separate tab. We should have a
	// BListView of available networks, rather than a menu, to make them more
	// readable and easier to browse and select.
	if (fNetworkMenuField->IsHidden(fNetworkMenuField)
		&& fSettings->IsWireless()) {
		fNetworkMenuField->Show();
	} else if (!fNetworkMenuField->IsHidden(fNetworkMenuField)
		&& !fSettings->IsWireless()) {
		fNetworkMenuField->Hide();
	}

	if (fSettings->IsWireless()) {
		// Rebuild network menu
		BMenu* menu = fNetworkMenuField->Menu();
		menu->RemoveItems(0, menu->CountItems(), true);

		std::set<BNetworkAddress> associated;
		BNetworkAddress address;
		uint32 cookie = 0;
		while (fSettings->GetNextAssociatedNetwork(cookie, address) == B_OK)
			associated.insert(address);

		wireless_network network;
		int32 count = 0;
		cookie = 0;
		while (fSettings->GetNextNetwork(cookie, network) == B_OK) {
			BMessage* message = new BMessage(kMsgNetwork);

			message->AddString("device", fSettings->Name());
			message->AddString("name", network.name);

			BMenuItem* item = new WirelessNetworkMenuItem(network.name,
				network.signal_strength,
				network.authentication_mode, message);
			if (associated.find(network.address) != associated.end())
				item->SetMarked(true);
			menu->AddItem(item);

			count++;
		}
		if (count == 0) {
			BMenuItem* item = new BMenuItem(
				B_TRANSLATE("<no wireless networks found>"), NULL);
			item->SetEnabled(false);
			menu->AddItem(item);
		} else {
			BMenuItem* item = new BMenuItem(
				B_TRANSLATE("Choose automatically"), NULL);
			if (menu->FindMarked() == NULL)
				item->SetMarked(true);
			menu->AddItem(item, 0);
			menu->AddItem(new BSeparatorItem(), 1);
		}
		menu->SetTargetForItems(this);
	}

	fRenegotiate->SetEnabled(!fSettings->IsDisabled());
	fOnOff->SetLabel(fSettings->IsDisabled() ? "Enable" : "Disable");

	return B_OK;
}