Пример #1
0
// constructor
Hall::Hall(void):
	List(NULL),
	List1(NULL),
	List2(NULL),
	List3(NULL),
	List4(NULL),
	List5(NULL),
	path(NULL),
	_changed(false),
	_count(0)
{
BFile F;
off_t size;
struct score s;
int i;

	List = new BList(1);
	List1 = new BList(6);	// for 14x6
	List2 = new BList(6);	// for 18x8
	List3 = new BList(6);	// for 24 x 12
	List4 = new BList(6);	// for 28 x 16
	List5 = new BList(6);	// for 32 x 20

	path = new BPath();
	
	/*
	 * Find the scores file, if it exists
	 *
	 */
	/*B_COMMON_SETTINGS_DIRECTORY*/
	if (
		find_directory(B_USER_SETTINGS_DIRECTORY, path) == B_NO_ERROR
		&& path->Append(FILE_NAME, true) == B_NO_ERROR
		&& F.SetTo(path->Path(), B_READ_ONLY) == B_NO_ERROR)
	{
		if ((F.GetSize(&size) == B_NO_ERROR) 
			&& ((size % sizeof (struct score))==0))
		{
			_count = size / sizeof (struct score);
			if (_count && _count <= NUMBER)
				for ( i = 0; i < _count; i++)
				{
					BList *L;
					F.Read(&s, sizeof(struct score));
					HSList *h = new HSList();

					h->SetName((char *)s.Name);
					h->SetGameID(s.gameID);
					h->SetGameTime(s.gameTime);
					h->SetNumberTiles(s.gameTiles);
					h->SetTimeOfGame(s.absTime);

					//List->AddItem(h);
					switch(s.gameTiles)
					{
					case 14 * 6: L = List1; break;
					case 18 * 8: L = List2; break;
					case 24 * 12: L = List3; break;
					case 28 * 16: L = List4; break;
					case 32 * 20: L = List5; break;
					default: L = NULL;
					}
					if (L) L->AddItem(h);
				}
		}
	}
	//else fprintf(stderr, "Couldn't open high scores file\n");

}
void
update_preferred_app_menu(BMenu* menu, BMimeType* type, uint32 what,
	const char* preferredFrom)
{
	// clear menu (but leave the first entry, ie. "None")

	for (int32 i = menu->CountItems(); i-- > 1;) {
		delete menu->RemoveItem(i);
	}

	// fill it again

	menu->ItemAt(0)->SetMarked(true);

	BMessage applications;
	if (type == NULL || type->GetSupportingApps(&applications) != B_OK)
		return;

	char preferred[B_MIME_TYPE_LENGTH];
	if (type->GetPreferredApp(preferred) != B_OK)
		preferred[0] = '\0';

	int32 lastFullSupport;
	if (applications.FindInt32("be:sub", &lastFullSupport) != B_OK)
		lastFullSupport = -1;

	BList subList;
	BList superList;

	const char* signature;
	int32 i = 0;
	while (applications.FindString("applications", i, &signature) == B_OK) {
		BMenuItem* item = create_application_item(signature, what);

		if (i < lastFullSupport)
			subList.AddItem(item);
		else
			superList.AddItem(item);

		i++;
	}

	// sort lists

	subList.SortItems(compare_menu_items);
	superList.SortItems(compare_menu_items);

	// add lists to the menu

	if (subList.CountItems() != 0 || superList.CountItems() != 0)
		menu->AddSeparatorItem();

	for (int32 i = 0; i < subList.CountItems(); i++) {
		menu->AddItem((BMenuItem*)subList.ItemAt(i));
	}

	// Add type separator
	if (superList.CountItems() != 0 && subList.CountItems() != 0)
		menu->AddSeparatorItem();

	for (int32 i = 0; i < superList.CountItems(); i++) {
		menu->AddItem((BMenuItem*)superList.ItemAt(i));
	}

	// make items unique and select current choice

	bool lastItemSame = false;
	const char* lastSignature = NULL;
	BMenuItem* last = NULL;
	BMenuItem* select = NULL;

	for (int32 index = 0; index < menu->CountItems(); index++) {
		BMenuItem* item = menu->ItemAt(index);
		if (item == NULL)
			continue;

		if (item->Message() == NULL
			|| item->Message()->FindString("signature", &signature) != B_OK)
			continue;

		if ((preferredFrom == NULL && !strcasecmp(signature, preferred))
			|| (preferredFrom != NULL
				&& !strcasecmp(signature, preferredFrom))) {
			select = item;
		}

		if (last == NULL || strcmp(last->Label(), item->Label())) {
			if (lastItemSame)
				add_signature(last, lastSignature);

			lastItemSame = false;
			last = item;
			lastSignature = signature;
			continue;
		}

		lastItemSame = true;
		add_signature(last, lastSignature);

		last = item;
		lastSignature = signature;
	}

	if (lastItemSame)
		add_signature(last, lastSignature);

	if (select != NULL) {
		// We don't select the item earlier, so that the menu field can
		// pick up the signature as well as label.
		select->SetMarked(true);
	} else if ((preferredFrom == NULL && preferred[0])
		|| (preferredFrom != NULL && preferredFrom[0])) {
		// The preferred application is not an application that support
		// this file type!
		BMenuItem* item = create_application_item(preferredFrom
			? preferredFrom : preferred, what);

		menu->AddSeparatorItem();
		menu->AddItem(item);
		item->SetMarked(item);
	}
}
Пример #3
0
// returns true if score is destined for greatness
bool Hall::JudgeScore(unsigned long gametime, unsigned long game, int tiles)
{
bool Yes = false;

BList *L;
	
	switch(tiles)
	{
	case 14 * 6: L = List1; break;
	case 18 * 8: L = List2; break;
	case 24 * 12: L = List3; break;
	case 28 * 16: L = List4; break;
	case 32 * 20: L = List5; break;
	default: L = NULL;
	}

	if (!L)
	{
		//printf("No game size!\n");
		return false;
	}

	HSList *h = new HSList();
		

	h->SetGameID(game);
	h->SetGameTime(gametime);
	h->SetNumberTiles(tiles);
	h->SetTimeOfGame(time(NULL));
			

	h->SetName(NULL);

	/* Add the new item
	 */
	L->AddItem(h); 

	L->SortItems(cmpFunc);


	/*
	 * Limit entries to 5
	 */
	if (L->CountItems() > 5)
	{
		HSList *hs;
		hs = (HSList *)L->RemoveItem(5);
		delete hs;
	}

	if (L->HasItem(h))
	{
	AskName *Ask = new AskName();
	char *name;

		name = Ask->Go();
		Ask->Lock();
		Ask->Quit();
		be_app->SetCursor(B_HAND_CURSOR);
		h->SetName(name);
		free(name);
		_changed = true;
		Yes = true;
	}

	return Yes;
}
Пример #4
0
void
GrepWindow::_OnSelectInTracker()
{
	if (fSearchResults->CurrentSelection() < 0) {
		BAlert* alert = new BAlert("Info",
			B_TRANSLATE("Please select the files you wish to have selected for you in "
				"Tracker."),
			B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
		alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
		alert->Go(NULL);
		return;
	}

	BMessage message;
	BString filePath;
	BPath folderPath;
	BList folderList;
	BString lastFolderAddedToList;

	for (int32 index = 0; ; index++) {
		BStringItem* item = dynamic_cast<BStringItem*>(
			fSearchResults->ItemAt(index));
		if (item == NULL)
			break;

		// only open selected and top level (file) items
		if (!item->IsSelected() || item->OutlineLevel() > 0)
			continue;

		// check if this was previously opened
		if (filePath == item->Text())
			continue;

		filePath = item->Text();
		entry_ref file_ref;
		if (get_ref_for_path(filePath.String(), &file_ref) != B_OK)
			continue;

		message.AddRef("refs", &file_ref);

		// add parent folder to list of folders to open
		folderPath.SetTo(filePath.String());
		if (folderPath.GetParent(&folderPath) == B_OK) {
			BPath* path = new BPath(folderPath);
			if (path->Path() != lastFolderAddedToList) {
				// catches some duplicates
				folderList.AddItem(path);
				lastFolderAddedToList = path->Path();
			} else
				delete path;
		}
	}

	_RemoveFolderListDuplicates(&folderList);
	_OpenFoldersInTracker(&folderList);

	int32 aShortWhile = 100000;
	snooze(aShortWhile);

	if (!_AreAllFoldersOpenInTracker(&folderList)) {
		for (int32 x = 0; x < 5; x++) {
			aShortWhile += 100000;
			snooze(aShortWhile);
			_OpenFoldersInTracker(&folderList);
		}
	}

	if (!_AreAllFoldersOpenInTracker(&folderList)) {
		BString str1;
		str1 << B_TRANSLATE("%APP_NAME couldn't open one or more folders.");
		str1.ReplaceFirst("%APP_NAME",APP_NAME);
		BAlert* alert = new BAlert(NULL, str1.String(), B_TRANSLATE("OK"),
			NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT);
		alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
		alert->Go(NULL);
		goto out;
	}

	_SelectFilesInTracker(&folderList, &message);

out:
	// delete folderList contents
	int32 folderCount = folderList.CountItems();
	for (int32 x = 0; x < folderCount; x++)
		delete static_cast<BPath*>(folderList.ItemAt(x));
}
Пример #5
0
bool
ShortcutsSpec::_AttemptTabCompletion()
{
	bool ret = false;

	int32 argc;
	char** argv = ParseArgvFromString(fCommand, argc);
	if (argc > 0) {
		// Try to complete the path partially expressed in the last argument!
		char* arg = argv[argc - 1];
		char* fileFragment = strrchr(arg, '/');
		if (fileFragment) {
			const char* directoryName = (fileFragment == arg) ? "/" : arg;
			*fileFragment = '\0';
			fileFragment++;
			int fragLen = strlen(fileFragment);

			BDirectory dir(directoryName);
			if (dir.InitCheck() == B_NO_ERROR) {
				BEntry nextEnt;
				BPath nextPath;
				BList matchList;
				int maxEntryLen = 0;

				// Read in all the files in the directory whose names start 
				// with our fragment.
				while (dir.GetNextEntry(&nextEnt) == B_NO_ERROR) {
					if (nextEnt.GetPath(&nextPath) == B_NO_ERROR) {
						char* filePath = strrchr(nextPath.Path(), '/') + 1;
						if (strncmp(filePath, fileFragment, fragLen) == 0) {
							int len = strlen(filePath);
							if (len > maxEntryLen)
								maxEntryLen = len;
							char* newStr = new char[len + 1];
							strcpy(newStr, filePath);
							matchList.AddItem(newStr);
						}
					}
				}

				// Now slowly extend our keyword to its full length, counting
				// numbers of matches at each step. If the match list length 
				// is 1, we can use that whole entry. If it's greater than one
				// , we can use just the match length.
				int matchLen = matchList.CountItems();
				if (matchLen > 0) {
					int i;
					BString result(fileFragment);
					for (i = fragLen; i < maxEntryLen; i++) {
						// See if all the matching entries have the same letter
						// in the next position... if so, we can go farther.
						char commonLetter = '\0';
						for (int j = 0; j < matchLen; j++) {
							char nextLetter = GetLetterAt(
								(char*)matchList.ItemAt(j), i);
							if (commonLetter == '\0')
								commonLetter = nextLetter;
						
							if ((commonLetter != '\0') 
								&& (commonLetter != nextLetter)) {
								commonLetter = '\0';// failed;
								beep();
								break;
							}
						}
						if (commonLetter == '\0')
							break;
						else
							result.Append(commonLetter, 1);
					}

					// Free all the strings we allocated
					for (int k = 0; k < matchLen; k++)
						delete [] ((char*)matchList.ItemAt(k));

					DoStandardEscapes(result);

					BString wholeLine;
					for (int l = 0; l < argc - 1; l++) {
						wholeLine += argv[l];
						wholeLine += " ";
					}
				
					BString file(directoryName);
					DoStandardEscapes(file);

					if (directoryName[strlen(directoryName) - 1] != '/')
						file += "/";

					file += result;

					// Remove any trailing slash...
					const char* fileStr = file.String();
					if (fileStr[strlen(fileStr)-1] == '/')
						file.RemoveLast("/");

					// And re-append it iff the file is a dir.
					BDirectory testFileAsDir(file.String());
					if ((strcmp(file.String(), "/") != 0) 
						&& (testFileAsDir.InitCheck() == B_NO_ERROR))
						file.Append("/");

					wholeLine += file;

					SetCommand(wholeLine.String());
					ret = true;
				}
			}
			*(fileFragment - 1) = '/';
		}
	}
	FreeArgv(argv);
	return ret;
}
Пример #6
0
// MessageReceived
void
StyleListView::MessageReceived(BMessage* message)
{
    switch (message->what) {
    case MSG_ADD: {
        Style* style;
        AddStylesCommand* command;
        rgb_color color;
        if (fCurrentColor != NULL)
            color = fCurrentColor->Color();
        else {
            color.red = 0;
            color.green = 0;
            color.blue = 0;
            color.alpha = 255;
        }
        new_style(color, fStyleContainer, &style, &command);
        fCommandStack->Perform(command);
        break;
    }
    case MSG_REMOVE:
        RemoveSelected();
        break;
    case MSG_DUPLICATE: {
        int32 count = CountSelectedItems();
        int32 index = 0;
        BList items;
        for (int32 i = 0; i < count; i++) {
            index = CurrentSelection(i);
            BListItem* item = ItemAt(index);
            if (item)
                items.AddItem((void*)item);
        }
        CopyItems(items, index + 1);
        break;
    }
    case MSG_RESET_TRANSFORMATION: {
        int32 count = CountSelectedItems();
        BList gradients;
        for (int32 i = 0; i < count; i++) {
            StyleListItem* item = dynamic_cast<StyleListItem*>(
                                      ItemAt(CurrentSelection(i)));
            if (item && item->style && item->style->Gradient())
                if (!gradients.AddItem(
                            (void*)item->style->Gradient()))
                    break;
        }
        count = gradients.CountItems();
        if (count < 0)
            break;

        Transformable* transformables[count];
        for (int32 i = 0; i < count; i++) {
            Gradient* gradient = (Gradient*)gradients.ItemAtFast(i);
            transformables[i] = gradient;
        }

        ResetTransformationCommand* command =
            new ResetTransformationCommand(transformables, count);

        fCommandStack->Perform(command);
        break;
    }
    default:
        SimpleListView::MessageReceived(message);
        break;
    }
}
BMessage* Delete::Do(PDocument *doc, BMessage *settings)
{
/*	BMessage	*node				= new BMessage();
	BMessage	*commandMessage		= PCommand::Do(doc,settings);
	BList		*parentGroupList	= NULL;
	BMessage	*connection			= new BMessage();
	int32		i					= 0;
	while (settings->FindPointer("node",i,(void **)&node))
	{
		if (settings->FindPointer("parentGroupList",i,(void **)&parentGroupList))
			parentGroupList->RemoveItem(node);
		else
			(doc->GetAllNodes())->RemoveItem(node);
		i++;
	}
	i = 0;
	while (settings->FindPointer("connection",i,(void **)&connection))
	{
		i++;
		(doc->GetAllConnections())->RemoveItem(connection);
	}
	return commandMessage;*/
	//**Todo
	BMessage		*undoMessage		= new BMessage();
	BList			*selected			= doc->GetSelected();
	BList			*connections		= doc->GetAllConnections();
	BList			*allNodes			= doc->GetAllNodes();
	BList			*changed			= doc->GetChangedNodes();
	BMessage		*node				= NULL;
	BMessage		*connection			= NULL;
	BList			*outgoing			= NULL;
	BList			*incoming			= NULL;
	int32			i					= 0;
	while (	(node = (BMessage *)selected->RemoveItem(i)) != NULL)
	{
		allNodes->RemoveItem(node);
		connections->RemoveItem(node);
		changed->AddItem(node);
		undoMessage->AddPointer("node",node);
		if (node->FindPointer("Node::outgoing",(void **)&outgoing) == B_OK)
		{
			for (int32 i=0;i<outgoing->CountItems();i++)
			{
				connection= (BMessage *)outgoing->ItemAt(i);
				connections->RemoveItem(connection);
//				trash->AddItem(connection);
				changed->AddItem(connection);
				undoMessage->AddPointer("node",connection);
			}
		}
		if (node->FindPointer("Node::incoming",(void **)&incoming) == B_OK)
		{
			for (int32 i=0;i<incoming->CountItems();i++)
			{
				connection= (BMessage *)incoming->ItemAt(i);
				connections->RemoveItem(connection);
//				trash->AddItem(connection);
				changed->AddItem(connection);
				undoMessage->AddPointer("node",connection);
			}
		}
	}
	doc->SetModified();
	settings->RemoveName("Delete::Undo");
	settings->AddMessage("Delete::Undo",undoMessage);
	settings = PCommand::Do(doc,settings);
	return settings;
}
Пример #8
0
void
NotificationView::MouseDown(BPoint point)
{
	int32 buttons;
	Window()->CurrentMessage()->FindInt32("buttons", &buttons);

	switch (buttons) {
		case B_PRIMARY_MOUSE_BUTTON:
		{
			BRect closeRect = Bounds().InsetByCopy(2,2);
			closeRect.left = closeRect.right - kCloseSize;
			closeRect.bottom = closeRect.top + kCloseSize;

			if (!closeRect.Contains(point)) {
				entry_ref launchRef;
				BString launchString;
				BMessage argMsg(B_ARGV_RECEIVED);
				BMessage refMsg(B_REFS_RECEIVED);
				entry_ref appRef;
				bool useArgv = false;
				BList messages;
				entry_ref ref;

				if (fNotification->OnClickApp() != NULL
					&& be_roster->FindApp(fNotification->OnClickApp(), &appRef)
				   		== B_OK) {
					useArgv = true;
				}

				if (fNotification->OnClickFile() != NULL
					&& be_roster->FindApp(
							(entry_ref*)fNotification->OnClickFile(), &appRef)
				   		== B_OK) {
					useArgv = true;
				}

				for (int32 i = 0; i < fNotification->CountOnClickRefs(); i++)
					refMsg.AddRef("refs", fNotification->OnClickRefAt(i));
				messages.AddItem((void*)&refMsg);

				if (useArgv) {
					int32 argc = fNotification->CountOnClickArgs() + 1;
					BString arg;

					BPath p(&appRef);
					argMsg.AddString("argv", p.Path());

					argMsg.AddInt32("argc", argc);

					for (int32 i = 0; i < argc - 1; i++) {
						argMsg.AddString("argv",
							fNotification->OnClickArgAt(i));
					}

					messages.AddItem((void*)&argMsg);
				}

				if (fNotification->OnClickApp() != NULL)
					be_roster->Launch(fNotification->OnClickApp(), &messages);
				else
					be_roster->Launch(fNotification->OnClickFile(), &messages);
			} else {
				fCloseClicked = true;
			}

			// Remove the info view after a click
			BMessage remove_msg(kRemoveView);
			remove_msg.AddPointer("view", this);

			BMessenger msgr(Parent());
			msgr.SendMessage(&remove_msg);
			break;
		}
	}
}
Пример #9
0
void
NotificationView::MouseDown(BPoint point)
{
	int32 buttons;
	Window()->CurrentMessage()->FindInt32("buttons", &buttons);

	switch (buttons) {
		case B_PRIMARY_MOUSE_BUTTON:
		{
			BRect closeRect = Bounds().InsetByCopy(2,2);
			closeRect.left = closeRect.right - kCloseSize;
			closeRect.bottom = closeRect.top + kCloseSize;	

			if (!closeRect.Contains(point)) {
				entry_ref launchRef;
				BString launchString;
				BMessage argMsg(B_ARGV_RECEIVED);
				BMessage refMsg(B_REFS_RECEIVED);
				entry_ref appRef;
				bool useArgv = false;
				BList messages;
				entry_ref ref;

				if (fDetails->FindString("onClickApp", &launchString) == B_OK)
					if (be_roster->FindApp(launchString.String(), &appRef) == B_OK)
						useArgv = true;
				if (fDetails->FindRef("onClickFile", &launchRef) == B_OK) {
					if (be_roster->FindApp(&launchRef, &appRef) == B_OK)
						useArgv = true;
				}

				if (fDetails->FindRef("onClickRef", &ref) == B_OK) {			
					for (int32 i = 0; fDetails->FindRef("onClickRef", i, &ref) == B_OK; i++)
						refMsg.AddRef("refs", &ref);

					messages.AddItem((void*)&refMsg);
				}

				if (useArgv) {
					type_code type;
					int32 argc = 0;
					BString arg;

					BPath p(&appRef);
					argMsg.AddString("argv", p.Path());

					fDetails->GetInfo("onClickArgv", &type, &argc);
					argMsg.AddInt32("argc", argc + 1);

					for (int32 i = 0; fDetails->FindString("onClickArgv", i, &arg) == B_OK; i++)
						argMsg.AddString("argv", arg);

					messages.AddItem((void*)&argMsg);
				}

				BMessage tmp;
				for (int32 i = 0; fDetails->FindMessage("onClickMsg", i, &tmp) == B_OK; i++)
					messages.AddItem((void*)&tmp);

				if (fDetails->FindString("onClickApp", &launchString) == B_OK)
					be_roster->Launch(launchString.String(), &messages);
				else
					be_roster->Launch(&launchRef, &messages);
			}

			// Remove the info view after a click
			BMessage remove_msg(kRemoveView);
			remove_msg.AddPointer("view", this);

			BMessenger msgr(Parent());
			msgr.SendMessage(&remove_msg);
			break;
		}
	}
}
Пример #10
0
BView *
DefaultMediaTheme::MakeViewFor(BParameterGroup& group, const BRect* hintRect)
{
	CALLED();

	if (group.Flags() & B_HIDDEN_PARAMETER)
		return NULL;

	BRect rect;
	if (hintRect != NULL)
		rect = *hintRect;

	GroupView *view = new GroupView(rect, group.Name());

	// Create the parameter views - but don't add them yet

	rect.OffsetTo(B_ORIGIN);
	rect.InsetBySelf(5, 5);

	BList views;
	for (int32 i = 0; i < group.CountParameters(); i++) {
		BParameter *parameter = group.ParameterAt(i);
		if (parameter == NULL)
			continue;

		BView *parameterView = MakeSelfHostingViewFor(*parameter,
			hintRect ? &rect : NULL);
		if (parameterView == NULL)
			continue;

		parameterView->SetViewColor(view->ViewColor());
			// ToDo: dunno why this is needed, but the controls
			// sometimes (!) have a white background without it

		views.AddItem(parameterView);
	}

	// Identify a title view, and add it at the top if present

	TitleView *titleView = dynamic_cast<TitleView *>((BView *)views.ItemAt(0));
	if (titleView != NULL) {
		view->AddChild(titleView);
		rect.OffsetBy(0, titleView->Bounds().Height());
	}

	// Add the sub-group views

	rect.right = rect.left + 20;
	rect.bottom = rect.top + 20;
	float lastHeight = 0;

	for (int32 i = 0; i < group.CountGroups(); i++) {
		BParameterGroup *subGroup = group.GroupAt(i);
		if (subGroup == NULL)
			continue;

		BView *groupView = MakeViewFor(*subGroup, &rect);
		if (groupView == NULL)
			continue;

		if (i > 0) {
			// add separator view
			BRect separatorRect(groupView->Frame());
			separatorRect.left -= 3;
			separatorRect.right = separatorRect.left + 1;
			if (lastHeight > separatorRect.Height())
				separatorRect.bottom = separatorRect.top + lastHeight;

			view->AddChild(new SeparatorView(separatorRect));
		}

		view->AddChild(groupView);

		rect.OffsetBy(groupView->Bounds().Width() + 5, 0);

		lastHeight = groupView->Bounds().Height();
		if (lastHeight > rect.Height())
			rect.bottom = rect.top + lastHeight - 1;
	}

	view->ResizeTo(rect.left + 10, rect.bottom + 5);
	view->SetContentBounds(view->Bounds());

	if (group.CountParameters() == 0)
		return view;

	// add the parameter views part of the group

	if (group.CountGroups() > 0) {
		rect.top = rect.bottom + 10;
		rect.bottom = rect.top + 20;
	}

	bool center = false;

	for (int32 i = 0; i < views.CountItems(); i++) {
		BView *parameterView = static_cast<BView *>(views.ItemAt(i));

		if (parameterView->Bounds().Width() + 5 > rect.Width())
			rect.right = parameterView->Bounds().Width() + rect.left + 5;

		// we don't need to add the title view again
		if (parameterView == titleView)
			continue;

		// if there is a BChannelSlider (ToDo: or any vertical slider?)
		// the views will be centered
		if (dynamic_cast<BChannelSlider *>(parameterView) != NULL)
			center = true;

		parameterView->MoveTo(parameterView->Frame().left, rect.top);
		view->AddChild(parameterView);

		rect.OffsetBy(0, parameterView->Bounds().Height() + 5);
	}

	if (views.CountItems() > (titleView != NULL ? 1 : 0))
		view->ResizeTo(rect.right + 5, rect.top + 5);

	// center the parameter views if needed, and tweak some views

	float width = view->Bounds().Width();

	for (int32 i = 0; i < views.CountItems(); i++) {
		BView *subView = static_cast<BView *>(views.ItemAt(i));
		BRect frame = subView->Frame();

		if (center)
			subView->MoveTo((width - frame.Width()) / 2, frame.top);
		else {
			// tweak the PopUp views to look better
			if (dynamic_cast<BOptionPopUp *>(subView) != NULL)
				subView->ResizeTo(width, frame.Height());
		}
	}

	view->SetContentBounds(view->Bounds());
	return view;
}
Пример #11
0
SDL_bool clipboard_copy_text( struct machine *oric )
{
    unsigned char *vidmem = (&oric->mem[oric->vid_addr]);
    int line, col;
    // TEXT
    BString text;
    BList textruns;

    textruns.AddItem(new_run(0, 0));

    for (line = 0; line < 28; line++) {
        for (col = 0; col < 40; col++) {
            bool inverted = false;
            unsigned char c = vidmem[line * 40 + col];

            if (c > 127) {
                inverted = true;
                c -= 128;
            }

            if (c < 8) {
                textruns.AddItem(new_run(text.Length(), c));
                text << ' ';
            } else if (c < ' ' || c == 127) {
                text << ' ';
            } else if (c == 0x60) {
                text << B_UTF8_COPYRIGHT;
            } else
                text << (char)c;
        }
        text << '\n';
    }
    //printf("%s\n", text.String());


    BMessage *clip = NULL;
    if (be_clipboard->Lock()) {
        be_clipboard->Clear();
        clip = be_clipboard->Data();
        if (clip) {
            clip->AddData("text/plain", B_MIME_TYPE, text.String(), text.Length());

            int arraySize = sizeof(text_run_array)
                            + textruns.CountItems() * sizeof(text_run);
            text_run_array *array = (text_run_array *)malloc(arraySize);
            array->count = textruns.CountItems();
            for (int i = 0; i < array->count; i++) {
                memcpy(&array->runs[i], textruns.ItemAt(i), sizeof(text_run));
            }
            clip->AddData("application/x-vnd.Be-text_run_array", B_MIME_TYPE,
                          array, arraySize);
            free(array);

            be_clipboard->Commit();
        }
        be_clipboard->Unlock();
    }

    for (int i = 0; i < textruns.CountItems(); i++) {
        delete (text_run *)(textruns.ItemAt(i));
    }
    textruns.MakeEmpty();

    return SDL_TRUE;
}
Пример #12
0
void
TBarView::ChangeState(int32 state, bool vertical, bool left, bool top)
{
	bool vertSwap = (fVertical != vertical);
	bool leftSwap = (fLeft != left);

	fState = state;
	fVertical = vertical;
	fLeft = left;
	fTop = top;
	
	BRect screenFrame = (BScreen(Window())).Frame();

	PlaceBeMenu();
	if (fVertical){
#if SA_CLOCK
		PlaceClock();	// tray dependent on clock location
#endif
		PlaceTray(vertSwap, leftSwap, screenFrame);
	} else {
		PlaceTray(vertSwap, leftSwap, screenFrame);
#if SA_CLOCK
		PlaceClock();	// clock is dependent on tray location
#endif
	}

	// We need to keep track of what apps are expanded.
	BList expandedItems;
	BString *signature = NULL;
	if (fVertical && Expando() && static_cast<TBarApp *>(be_app)->Settings()->superExpando) {
		// Get a list of the Signatures of expanded apps - Can't use team_id because
		// there can be more than one team per application
		if (fVertical && Expando() && vertical && fExpando) {
			for (int index = 0; index < fExpando->CountItems(); index++) {
				TTeamMenuItem *item = dynamic_cast<TTeamMenuItem *>(fExpando->ItemAt(index));
				if (item != NULL && item->IsExpanded()) {
					signature = new BString(item->Signature());
					expandedItems.AddItem((void *)signature);
				}
			}
		}
	}

	PlaceApplicationBar(screenFrame);
	SizeWindow(screenFrame);
	PositionWindow(screenFrame);
	Window()->UpdateIfNeeded();
	
	// Re-expand those apps.
	if (expandedItems.CountItems() > 0) {
		for (int sigIndex = expandedItems.CountItems(); sigIndex-- > 0;) {
			signature = static_cast<BString *>(expandedItems.ItemAt(sigIndex));
			if (signature == NULL)
				continue;

			// Start at the 'bottom' of the list working up.
			// Prevents being thrown off by expanding items.
			for (int teamIndex = fExpando->CountItems(); teamIndex-- > 0;) {
				TTeamMenuItem *item = dynamic_cast<TTeamMenuItem *>(fExpando->ItemAt(teamIndex));
				if (item != NULL && !signature->Compare(item->Signature())) {
					item->ToggleExpandState(false);
					break;
				}
			}
		}

		// Clean up expanded signature list.
		while (!expandedItems.IsEmpty()) {
			delete static_cast<BString *>(expandedItems.RemoveItem((int32)0));
		}

		fExpando->SizeWindow();
	}

	Invalidate();
}
Пример #13
0
_EXPORT ssize_t utf8_to_rfc2047 (char **bufp, ssize_t length, uint32 charset, char encoding) {
	struct word {
		BString	originalWord;
		BString	convertedWord;
		bool	needsEncoding;

		// Convert the word from UTF-8 to the desired character set.  The
		// converted version also includes the escape codes to return to ASCII
		// mode, if relevant.  Also note if it uses unprintable characters,
		// which means it will need that special encoding treatment later.
		void ConvertWordToCharset (uint32 charset) {
			int32 state = 0;
			int32 originalLength = originalWord.Length();
			int32 convertedLength = originalLength * 5 + 1;
			char *convertedBuffer = convertedWord.LockBuffer (convertedLength);
			mail_convert_from_utf8 (charset, originalWord.String(),
				&originalLength, convertedBuffer, &convertedLength, &state);
			for (int i = 0; i < convertedLength; i++) {
				if ((convertedBuffer[i] & (1 << 7)) ||
					(convertedBuffer[i] >= 0 && convertedBuffer[i] < 32)) {
					needsEncoding = true;
					break;
				}
			}
			convertedWord.UnlockBuffer (convertedLength);
		};
	};
	struct word *currentWord;
	BList words;

	// Break the header into words.  White space characters (including tabs and
	// newlines) separate the words.  Each word includes any space before it as
	// part of the word.  Actually, quotes and other special characters
	// (",()<>@) are treated as separate words of their own so that they don't
	// get encoded (because MIME headers get the quotes parsed before character
	// set unconversion is done).  The reader is supposed to ignore all white
	// space between encoded words, which can be inserted so that older mail
	// parsers don't have overly long line length problems.

	const char *source = *bufp;
	const char *bufEnd = *bufp + length;
	const char *specialChars = "\"()<>@,";

	while (source < bufEnd) {
		currentWord = new struct word;
		currentWord->needsEncoding = false;

		int wordEnd = 0;

		// Include leading spaces as part of the word.
		while (source + wordEnd < bufEnd && isspace (source[wordEnd]))
			wordEnd++;

		if (source + wordEnd < bufEnd &&
			strchr (specialChars, source[wordEnd]) != NULL) {
			// Got a quote mark or other special character, which is treated as
			// a word in itself since it shouldn't be encoded, which would hide
			// it from the mail system.
			wordEnd++;
		} else {
			// Find the end of the word.  Leave wordEnd pointing just after the
			// last character in the word.
			while (source + wordEnd < bufEnd) {
				if (isspace(source[wordEnd]) ||
					strchr (specialChars, source[wordEnd]) != NULL)
					break;
				if (wordEnd > 51 /* Makes Base64 ISO-2022-JP "word" a multiple of 4 bytes */ &&
					0xC0 == (0xC0 & (unsigned int) source[wordEnd])) {
					// No English words are that long (46 is the longest),
					// break up what is likely Asian text (which has no spaces)
					// at the start of the next non-ASCII UTF-8 character (high
					// two bits are both ones).  Note that two encoded words in
					// a row get joined together, even if there is a space
					// between them in the final output text, according to the
					// standard.  Next word will also be conveniently get
					// encoded due to the 0xC0 test.
					currentWord->needsEncoding = true;
					break;
				}
				wordEnd++;
			}
		}
		currentWord->originalWord.SetTo (source, wordEnd);
		currentWord->ConvertWordToCharset (charset);
		words.AddItem(currentWord);
		source += wordEnd;
	}

	// Combine adjacent words which contain unprintable text so that the
	// overhead of switching back and forth between regular text and specially
	// encoded text is reduced.  However, the combined word must be shorter
	// than the maximum of 75 bytes, including character set specification and
	// all those delimiters (worst case 22 bytes of overhead).

	struct word *run;

	for (int32 i = 0; (currentWord = (struct word *) words.ItemAt (i)) != NULL; i++) {
		if (!currentWord->needsEncoding)
			continue; // No need to combine unencoded words.
		for (int32 g = i+1; (run = (struct word *) words.ItemAt (g)) != NULL; g++) {
			if (!run->needsEncoding)
				break; // Don't want to combine encoded and unencoded words.
			if ((currentWord->convertedWord.Length() + run->convertedWord.Length() <= 53)) {
				currentWord->originalWord.Append (run->originalWord);
				currentWord->ConvertWordToCharset (charset);
				words.RemoveItem(g);
				delete run;
				g--;
			} else // Can't merge this word, result would be too long.
				break;
		}
	}

	// Combine the encoded and unencoded words into one line, doing the
	// quoted-printable or base64 encoding.  Insert an extra space between
	// words which are both encoded to make word wrapping easier, since there
	// is normally none, and you're allowed to insert space (the receiver
	// throws it away if it is between encoded words).

	BString rfc2047;
	bool	previousWordNeededEncoding = false;

	const char *charset_dec = "none-bug";
	for (int32 i = 0; mail_charsets[i].charset != NULL; i++) {
		if (mail_charsets[i].flavor == charset) {
			charset_dec = mail_charsets[i].charset;
			break;
		}
	}

	while ((currentWord = (struct word *)words.RemoveItem(0L)) != NULL) {
		if ((encoding != quoted_printable && encoding != base64) ||
		!currentWord->needsEncoding) {
			rfc2047.Append (currentWord->convertedWord);
		} else {
			// This word needs encoding.  Try to insert a space between it and
			// the previous word.
			if (previousWordNeededEncoding)
				rfc2047 << ' '; // Can insert as many spaces as you want between encoded words.
			else {
				// Previous word is not encoded, spaces are significant.  Try
				// to move a space from the start of this word to be outside of
				// the encoded text, so that there is a bit of space between
				// this word and the previous one to enhance word wrapping
				// chances later on.
				if (currentWord->originalWord.Length() > 1 &&
					isspace (currentWord->originalWord[0])) {
					rfc2047 << currentWord->originalWord[0];
					currentWord->originalWord.Remove (0 /* offset */, 1 /* length */);
					currentWord->ConvertWordToCharset (charset);
				}
			}

			char *encoded = NULL;
			ssize_t encoded_len = 0;
			int32 convertedLength = currentWord->convertedWord.Length ();
			const char *convertedBuffer = currentWord->convertedWord.String ();

			switch (encoding) {
				case quoted_printable:
					encoded = (char *) malloc (convertedLength * 3);
					encoded_len = encode_qp (encoded, convertedBuffer, convertedLength, true /* headerMode */);
					break;
				case base64:
					encoded = (char *) malloc (convertedLength * 2);
					encoded_len = encode_base64 (encoded, convertedBuffer, convertedLength, true /* headerMode */);
					break;
				default: // Unknown encoding type, shouldn't happen.
					encoded = (char *) convertedBuffer;
					encoded_len = convertedLength;
					break;
			}

			rfc2047 << "=?" << charset_dec << '?' << encoding << '?';
			rfc2047.Append (encoded, encoded_len);
			rfc2047 << "?=";

			if (encoding == quoted_printable || encoding == base64)
				free(encoded);
		}
		previousWordNeededEncoding = currentWord->needsEncoding;
		delete currentWord;
	}

	free(*bufp);

	ssize_t finalLength = rfc2047.Length ();
	*bufp = (char *) (malloc (finalLength + 1));
	memcpy (*bufp, rfc2047.String(), finalLength);
	(*bufp)[finalLength] = 0;

	return finalLength;
}
Пример #14
0
MidiMonitorApp::MidiMonitorApp ( void ) 
	: BApplication ("application/x-vnd.tebo-midimonitor")
{
	BRect aRect;
	BList windows;
	const float menuHeight = 20;
	int	initPort = 0; // set this from prefs instead...archive?
	bool isPortOpen = FALSE;
	char str[80], portname[132];
		

	midiPort = new BMidiPort;
	numPorts = midiPort->CountDevices();
	midiPort->GetDeviceName ( initPort, portname );
	if ( midiPort->Open (portname) != B_NO_ERROR ) {
		sprintf ( str, "can't open %s", portname );
		BAlert *b = new BAlert ("", str, "ug" );
		b->Go();
	} else {
//		sprintf ( str, "opened %s", portNames[initPort] );
//		BAlert *b = new BAlert ("", str, "okay!" );
//		b->Go();
		isPortOpen = TRUE;
	}
		
	theMidiMonitor = new M2BMidiMonitor ();
	theMidiMonitor->Start();
	
	midiPort->Connect ( theMidiMonitor );
	if ( isPortOpen )
		midiPort->Start();

	aRect.Set(20, 100, 340, 400);
	BWindow *aWindow = (BWindow *) new M2BWindow(aRect);
	aRect.OffsetTo(B_ORIGIN);
	BView *aView = (BView *) new M2BView(aRect, "M2BView", 
					(M2BMidiMonitor*)theMidiMonitor, menuHeight);
	aWindow->AddChild(aView);
	aWindow->Show();
	windows.AddItem ( aWindow );


	

		aRect.Set ( 0,0,1000,menuHeight);
		BMenuBar	*menubar = new BMenuBar ( aRect, "menubar" );
		menubar->SetBorder ( B_BORDER_FRAME );
	
		BMenuItem *item; 
		BMenu *menu = new BMenu("File"); 
   
		item = new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q'); 
		item->SetTarget(be_app); 
		menu->AddItem(item); 
	
		menubar->AddItem ( menu );
		
		// add the port selection menu
		menu = new BMenu ( "Port" );
		for ( int i = 0; i < numPorts; i++ ) {
			midiPort->GetDeviceName ( i, portname );
			item = new BMenuItem ( portname, 
									new BMessage ( MSG_MIDIMONITOR_MIDI_PORT ) );
			item->Message()->AddString ( "port", portname );
			menu->AddItem ( item );
		}
		menu->SetRadioMode ( TRUE );
		menu->ItemAt(initPort)->SetMarked ( TRUE );
		menu->SetTargetForItems ( be_app );	
		menubar->AddItem ( menu );


		aView->AddChild ( menubar );
	
	
}
Пример #15
0
void
PairsView::_ReadRandomIcons()
{
	// TODO: maybe read the icons only once at startup

	// clean out any previous icons
	for (int i = 0; i < fCardBitmaps.CountItems(); i++)
		delete ((BBitmap*)fCardBitmaps.ItemAt(i));

	fCardBitmaps.MakeEmpty();

	BDirectory appsDirectory;
	BDirectory prefsDirectory;

	BPath path;
	if (find_directory(B_BEOS_APPS_DIRECTORY, &path) == B_OK)
		appsDirectory.SetTo(path.Path());
	if (find_directory(B_BEOS_PREFERENCES_DIRECTORY, &path) == B_OK)
		prefsDirectory.SetTo(path.Path());

	// read vector icons from apps and prefs folder and put them
	// into a BList as BBitmaps
	BList bitmaps;

	BEntry entry;
	while (appsDirectory.GetNextEntry(&entry) == B_OK
		|| prefsDirectory.GetNextEntry(&entry) == B_OK) {

		BNode node(&entry);
		BNodeInfo nodeInfo(&node);

		if (nodeInfo.InitCheck() < B_OK)
			continue;

		uint8* data;
		size_t size;
		type_code type;

		if (nodeInfo.GetIcon(&data, &size, &type) < B_OK)
			continue;

		if (type != B_VECTOR_ICON_TYPE) {
			delete[] data;
			continue;
		}

		BBitmap* bitmap = new BBitmap(
			BRect(0, 0, kBitmapSize - 1, kBitmapSize - 1), 0, B_RGBA32);
		if (BIconUtils::GetVectorIcon(data, size, bitmap) < B_OK) {
			delete[] data;
			delete bitmap;
			continue;
		}

		delete[] data;

		if (_HasBitmap(bitmaps, bitmap) || !bitmaps.AddItem(bitmap))
			delete bitmap;
		else if (bitmaps.CountItems() >= 128) {
			// this is enough to choose from, stop eating memory...
			break;
		}
	}

	// pick random bitmaps from the ones we got in the list
	srand((unsigned)time(0));

	for (int i = 0; i < fNumOfCards / 2; i++) {
		int32 index = rand() % bitmaps.CountItems();
		BBitmap* bitmap = ((BBitmap*)bitmaps.RemoveItem(index));
		if (bitmap == NULL) {
			char buffer[512];
			snprintf(buffer, sizeof(buffer), B_TRANSLATE("Pairs did not find "
				"enough vector icons in the system; it needs at least %d."),
				fNumOfCards / 2);
			BString msgStr(buffer);
			msgStr << "\n";
			BAlert* alert = new BAlert("Fatal", msgStr.String(),
				B_TRANSLATE("OK"), 	NULL, NULL, B_WIDTH_FROM_WIDEST,
				B_STOP_ALERT);
			alert->SetShortcut(0, B_ESCAPE);
			alert->Go();
			exit(1);
		}
		fCardBitmaps.AddItem(bitmap);
	}

	// delete the remaining bitmaps from the list
	while (BBitmap* bitmap = (BBitmap*)bitmaps.RemoveItem(0L))
		delete bitmap;
}
Пример #16
0
void
MainWindow::MessageReceived(BMessage* message)
{
	bool discard = false;

	// Figure out if we need the write lock on the Document. For most
	// messages we do, but exporting takes place in another thread and
	// locking is taken care of there.
	bool requiresWriteLock = true;
	switch (message->what) {
		case MSG_SAVE:
		case MSG_EXPORT:
		case MSG_SAVE_AS:
		case MSG_EXPORT_AS:
			requiresWriteLock = false;
			break;
		default:
			break;
	}
	if (requiresWriteLock && !fDocument->WriteLock()) {
		BWindow::MessageReceived(message);
		return;
	}

	if (message->WasDropped()) {
		const rgb_color* color;
		int32 length;
		// create styles from dropped colors
		for (int32 i = 0; message->FindData("RGBColor", B_RGB_COLOR_TYPE, i, 
			(const void**)&color, &length) == B_OK; i++) {
			if (length != sizeof(rgb_color))
				continue;
			char name[30];
			sprintf(name, 
				B_TRANSLATE_WITH_CONTEXT("Color (#%02x%02x%02x)", 
					"Style name after dropping a color"), 
				color->red, color->green, color->blue);
			Style* style = new (nothrow) Style(*color);
			style->SetName(name);
			Style* styles[1] = { style };
			AddStylesCommand* styleCommand = new (nothrow) AddStylesCommand(
				fDocument->Icon()->Styles(), styles, 1,
				fDocument->Icon()->Styles()->CountStyles());
			fDocument->CommandStack()->Perform(styleCommand);
			// don't handle anything else,
			// or we might paste the clipboard on B_PASTE
			discard = true;
		}
	}

	switch (message->what) {

		case B_REFS_RECEIVED:
		case B_SIMPLE_DATA:
			// If our icon is empty, open the file in this window,
			// otherwise forward to the application which will open
			// it in another window, unless we append.
			message->what = B_REFS_RECEIVED;
			if (fDocument->Icon()->Styles()->CountStyles() == 0
				&& fDocument->Icon()->Paths()->CountPaths() == 0
				&& fDocument->Icon()->Shapes()->CountShapes() == 0) {
				entry_ref ref;
				if (message->FindRef("refs", &ref) == B_OK)
					Open(ref);
				break;
			}
			if (modifiers() & B_SHIFT_KEY) {
				// We want the icon appended to this window.
				message->AddBool("append", true);
				message->AddPointer("window", this);
			}
			be_app->PostMessage(message);
			break;

		case B_PASTE:
		case B_MIME_DATA:
		{
			BMessage* clip = message;
			status_t err;

			if (discard)
				break;

			if (message->what == B_PASTE) {
				if (!be_clipboard->Lock())
					break;
				clip = be_clipboard->Data();
			}

			if (!clip || !clip->HasData("text/plain", B_MIME_TYPE)) {
				if (message->what == B_PASTE)
					be_clipboard->Unlock();
				break;
			}

			Icon* icon = new (std::nothrow) Icon(*fDocument->Icon());
			if (icon != NULL) {
				StyledTextImporter importer;
				err = importer.Import(icon, clip);
				if (err >= B_OK) {
					AutoWriteLocker locker(fDocument);

					SetIcon(NULL);

					// incorporate the loaded icon into the document
					// (either replace it or append to it)
					fDocument->MakeEmpty(false);
						// if append, the document savers are preserved
					fDocument->SetIcon(icon);
					SetIcon(icon);
				}
			}

			if (message->what == B_PASTE)
				be_clipboard->Unlock();
			break;
		}

		case MSG_OPEN:
			// If our icon is empty, we want the icon to open in this
			// window.
			if (fDocument->Icon()->Styles()->CountStyles() == 0
				&& fDocument->Icon()->Paths()->CountPaths() == 0
				&& fDocument->Icon()->Shapes()->CountShapes() == 0) {
				message->AddPointer("window", this);
			}
			be_app->PostMessage(message);
			break;

		case MSG_SAVE:
		case MSG_EXPORT:
		{
			DocumentSaver* saver;
			if (message->what == MSG_SAVE)
				saver = fDocument->NativeSaver();
			else
				saver = fDocument->ExportSaver();
			if (saver != NULL) {
				saver->Save(fDocument);
				_PickUpActionBeforeSave();
				break;
			} // else fall through
		}
		case MSG_SAVE_AS:
		case MSG_EXPORT_AS:
		{
			int32 exportMode;
			if (message->FindInt32("export mode", &exportMode) < B_OK)
				exportMode = EXPORT_MODE_MESSAGE;
			entry_ref ref;
			const char* name;
			if (message->FindRef("directory", &ref) == B_OK
				&& message->FindString("name", &name) == B_OK) {
				// this message comes from the file panel
				BDirectory dir(&ref);
				BEntry entry;
				if (dir.InitCheck() >= B_OK
					&& entry.SetTo(&dir, name, true) >= B_OK
					&& entry.GetRef(&ref) >= B_OK) {

					// create the document saver and remember it for later
					DocumentSaver* saver = _CreateSaver(ref, exportMode);
					if (saver != NULL) {
						if (fDocument->WriteLock()) {
							if (exportMode == EXPORT_MODE_MESSAGE)
								fDocument->SetNativeSaver(saver);
							else
								fDocument->SetExportSaver(saver);
							_UpdateWindowTitle();
							fDocument->WriteUnlock();
						}
						saver->Save(fDocument);
						_PickUpActionBeforeSave();
					}
				}
// TODO: ...
//				_SyncPanels(fSavePanel, fOpenPanel);
			} else {
				// configure the file panel
				uint32 requestRefWhat = MSG_SAVE_AS;
				bool isExportMode = message->what == MSG_EXPORT_AS
					|| message->what == MSG_EXPORT;
				if (isExportMode)
					requestRefWhat = MSG_EXPORT_AS;
				const char* saveText = _FileName(isExportMode);

				BMessage requestRef(requestRefWhat);
				if (saveText != NULL)
					requestRef.AddString("save text", saveText);
				requestRef.AddMessenger("target", BMessenger(this, this));
				be_app->PostMessage(&requestRef);
			}
			break;
		}

		case MSG_UNDO:
			fDocument->CommandStack()->Undo();
			break;
		case MSG_REDO:
			fDocument->CommandStack()->Redo();
			break;
		case MSG_UNDO_STACK_CHANGED:
		{
			// relable Undo item and update enabled status
			BString label(B_TRANSLATE("Undo"));
			fUndoMI->SetEnabled(fDocument->CommandStack()->GetUndoName(label));
			if (fUndoMI->IsEnabled())
				fUndoMI->SetLabel(label.String());
			else {
				fUndoMI->SetLabel(B_TRANSLATE_WITH_CONTEXT("<nothing to undo>",
					"Icon-O-Matic-Menu-Edit"));
			}
	
			// relable Redo item and update enabled status
			label.SetTo(B_TRANSLATE("Redo"));
			fRedoMI->SetEnabled(fDocument->CommandStack()->GetRedoName(label));
			if (fRedoMI->IsEnabled())
				fRedoMI->SetLabel(label.String());
			else {
				fRedoMI->SetLabel(B_TRANSLATE_WITH_CONTEXT("<nothing to redo>",
					"Icon-O-Matic-Menu-Edit"));
			}
			break;
		}

		case MSG_MOUSE_FILTER_MODE:
		{
			uint32 mode;
			if (message->FindInt32("mode", (int32*)&mode) == B_OK)
				fCanvasView->SetMouseFilterMode(mode);
			break;
		}

		case MSG_ADD_SHAPE: {
			AddStylesCommand* styleCommand = NULL;
			Style* style = NULL;
			if (message->HasBool("style")) {
				new_style(fCurrentColor->Color(),
					fDocument->Icon()->Styles(), &style, &styleCommand);
			}
		
			AddPathsCommand* pathCommand = NULL;
			VectorPath* path = NULL;
			if (message->HasBool("path")) {
				new_path(fDocument->Icon()->Paths(), &path, &pathCommand);
			}
		
			if (!style) {
				// use current or first style
				int32 currentStyle = fStyleListView->CurrentSelection(0);
				style = fDocument->Icon()->Styles()->StyleAt(currentStyle);
				if (!style)
					style = fDocument->Icon()->Styles()->StyleAt(0);
			}
		
			Shape* shape = new (nothrow) Shape(style);
			Shape* shapes[1];
			shapes[0] = shape;
			AddShapesCommand* shapeCommand = new (nothrow) AddShapesCommand(
				fDocument->Icon()->Shapes(), shapes, 1,
				fDocument->Icon()->Shapes()->CountShapes(),
				fDocument->Selection());
		
			if (path && shape)
				shape->Paths()->AddPath(path);
		
			::Command* command = NULL;
			if (styleCommand || pathCommand) {
				if (styleCommand && pathCommand) {
					Command** commands = new Command*[3];
					commands[0] = styleCommand;
					commands[1] = pathCommand;
					commands[2] = shapeCommand;
					command = new CompoundCommand(commands, 3,
						B_TRANSLATE_WITH_CONTEXT("Add shape with path & style",
							"Icon-O-Matic-Menu-Shape"),
						0);
				} else if (styleCommand) {
					Command** commands = new Command*[2];
					commands[0] = styleCommand;
					commands[1] = shapeCommand;
					command = new CompoundCommand(commands, 2,
						B_TRANSLATE_WITH_CONTEXT("Add shape with style",
							"Icon-O-Matic-Menu-Shape"), 
						0);
				} else {
					Command** commands = new Command*[2];
					commands[0] = pathCommand;
					commands[1] = shapeCommand;
					command = new CompoundCommand(commands, 2,
						B_TRANSLATE_WITH_CONTEXT("Add shape with path",
							"Icon-O-Matic-Menu-Shape"), 
						0);
				}
			} else {
				command = shapeCommand;
			}
			fDocument->CommandStack()->Perform(command);
			break;
		}

// TODO: listen to selection in CanvasView to add a manipulator
case MSG_PATH_SELECTED: {
	VectorPath* path;
	if (message->FindPointer("path", (void**)&path) < B_OK)
		path = NULL;

	fPathListView->SetCurrentShape(NULL);
	fStyleListView->SetCurrentShape(NULL);
	fTransformerListView->SetShape(NULL);
	
	fState->DeleteManipulators();
	if (fDocument->Icon()->Paths()->HasPath(path)) {
		PathManipulator* pathManipulator = new (nothrow) PathManipulator(path);
		fState->AddManipulator(pathManipulator);
	}
	break;
}
case MSG_STYLE_SELECTED:
case MSG_STYLE_TYPE_CHANGED: {
	Style* style;
	if (message->FindPointer("style", (void**)&style) < B_OK)
		style = NULL;
	if (!fDocument->Icon()->Styles()->HasStyle(style))
		style = NULL;

	fStyleView->SetStyle(style);
	fPathListView->SetCurrentShape(NULL);
	fStyleListView->SetCurrentShape(NULL);
	fTransformerListView->SetShape(NULL);

	fState->DeleteManipulators();
	Gradient* gradient = style ? style->Gradient() : NULL;
	if (gradient != NULL) {
		TransformGradientBox* transformBox
			= new (nothrow) TransformGradientBox(fCanvasView, gradient, NULL);
		fState->AddManipulator(transformBox);
	}
	break;
}
case MSG_SHAPE_SELECTED: {
	Shape* shape;
	if (message->FindPointer("shape", (void**)&shape) < B_OK)
		shape = NULL;
	if (!fIcon || !fIcon->Shapes()->HasShape(shape))
		shape = NULL;

	fPathListView->SetCurrentShape(shape);
	fStyleListView->SetCurrentShape(shape);
	fTransformerListView->SetShape(shape);

	BList selectedShapes;
	ShapeContainer* shapes = fDocument->Icon()->Shapes();
	int32 count = shapes->CountShapes();
	for (int32 i = 0; i < count; i++) {
		shape = shapes->ShapeAtFast(i);
		if (shape->IsSelected()) {
			selectedShapes.AddItem((void*)shape);
		}
	}

	fState->DeleteManipulators();
	if (selectedShapes.CountItems() > 0) {
		TransformShapesBox* transformBox = new (nothrow) TransformShapesBox(
			fCanvasView,
			(const Shape**)selectedShapes.Items(),
			selectedShapes.CountItems());
		fState->AddManipulator(transformBox);
	}
	break;
}
		case MSG_RENAME_OBJECT:
			fPropertyListView->FocusNameProperty();
			break;

		default:
			BWindow::MessageReceived(message);
	}

	if (requiresWriteLock)
		fDocument->WriteUnlock();
}
Пример #17
0
void
AttributeWindow::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case kMsgAttributeUpdated:
		case kMsgAlignmentChosen:
		case kMsgTypeChosen:
			_CheckDisplayAs();
			_CheckAcceptable();
			break;

		case kMsgDisplayAsChosen:
			fSpecialControl->SetEnabled(!_DefaultDisplayAs()->IsMarked());
			_CheckAcceptable();
			break;

		case kMsgVisibilityChanged:
		{
			bool enabled = fVisibleCheckBox->Value() != B_CONTROL_OFF;

			fDisplayAsMenuField->SetEnabled(enabled);
			fWidthControl->SetEnabled(enabled);
			fAlignmentMenuField->SetEnabled(enabled);
			fEditableCheckBox->SetEnabled(enabled);

			_CheckDisplayAs();
			_CheckAcceptable();
			break;
		}

		case kMsgAccept:
		{
			BMessage attributes;
			status_t status = fMimeType.GetAttrInfo(&attributes);
			if (status == B_OK) {
				// replace the entry, and remove any equivalent entries
				BList list;

				const char* newAttribute = fAttributeControl->Text();
				list.AddItem(_NewItemFromCurrent());

				const char* attribute;
				for (int32 i = 0; attributes.FindString("attr:name", i,
						&attribute) == B_OK; i++) {
					if (!strcmp(fAttribute.Name(), attribute)
						|| !strcmp(newAttribute, attribute)) {
						// remove this item
						continue;
					}

					AttributeItem* item = create_attribute_item(attributes, i);
					if (item != NULL)
						list.AddItem(item);
				}

				list.SortItems(compare_attributes);

				// Copy them to a new message (their memory is still part of the
				// original BMessage)
				BMessage newAttributes;
				for (int32 i = 0; i < list.CountItems(); i++) {
					AttributeItem* item = (AttributeItem*)list.ItemAt(i);

					newAttributes.AddString("attr:name", item->Name());
					newAttributes.AddString("attr:public_name", item->PublicName());
					newAttributes.AddInt32("attr:type", (int32)item->Type());
					newAttributes.AddString("attr:display_as", item->DisplayAs());
					newAttributes.AddInt32("attr:alignment", item->Alignment());
					newAttributes.AddInt32("attr:width", item->Width());
					newAttributes.AddBool("attr:viewable", item->Visible());
					newAttributes.AddBool("attr:editable", item->Editable());
					
					delete item;
				}

				status = fMimeType.SetAttrInfo(&newAttributes);
			}

			if (status != B_OK)
				error_alert("Could not change attributes", status);

			PostMessage(B_QUIT_REQUESTED);
			break;
		}

		default:
			BWindow::MessageReceived(message);
			break;
	}
}
Пример #18
0
BList* FSPanel::GetArgumentList()
{
	CheckCB();
	BList* list = new BList();
	if (ISO9660_CB->Value() == B_CONTROL_ON) {
		if (F31_RB->Value() == B_CONTROL_ON) list->AddItem(new BString("-l"));
		if (F37_RB->Value() == B_CONTROL_ON) list->AddItem(new BString("-max-iso9660-filenames"));

		if (Joliet_CB->Value() == B_CONTROL_ON) {
			list->AddItem(new BString("-J"));
			if (JolietUni_RB->Value() == B_CONTROL_ON) list->AddItem(new BString("-joliet-long"));
		}
		if (RockRidge_CB->Value() == B_CONTROL_ON) {
			if (RRDef_RB->Value() == B_CONTROL_ON) list->AddItem(new BString("-R"));
			if (RRRat_RB->Value() == B_CONTROL_ON) list->AddItem(new BString("-r"));
		}
		if (HFS_CB->Value() == B_CONTROL_ON) {
			list->AddItem(new BString("-h"));
			if ((mappingCB->Value() == B_CONTROL_ON) &&
				(strlen(mappingBF->GetTextControl()->Text()) > 0)) {
				list->AddItem(new BString("-map"));
				list->AddItem(new BString(mappingBF->GetTextControl()->Text()));
			}
		}
	}

	if (UDF_CB->Value() == B_CONTROL_ON) {
		list->AddItem(new BString("-udf"));
		if (UDFDVD_RB->Value() == B_CONTROL_ON) list->AddItem(new BString("-dvd-video"));
	}

	if (BFS_CB->Value() == B_CONTROL_ON) {
		list->AddItem(new BString("BFS"));
	}

	return list;
}
Пример #19
0
// MessageReceived
void
DragSortableListView::MessageReceived(BMessage* message)
{
	if (message->what == fDragCommand) {
		DragSortableListView *list = NULL;
		if (message->FindPointer("list", (void **)&list) == B_OK
			 && list == this) {
			int32 count = CountItems();
			if (fDropIndex < 0 || fDropIndex > count)
				fDropIndex = count;
			BList items;
			int32 index;
			for (int32 i = 0; message->FindInt32("index", i, &index) == B_OK; i++)
				if (BListItem* item = ItemAt(index))
					items.AddItem((void*)item);
			if (items.CountItems() > 0) {
				if (modifiers() & B_SHIFT_KEY)
					CopyItems(items, fDropIndex);
				else
					MoveItems(items, fDropIndex);
			}
			fDropIndex = -1;
		}
	} else {
		switch (message->what) {
			case MSG_TICK: {
				float scrollV = 0.0;
				BRect rect(Bounds());
				BPoint point;
				uint32 buttons;
				GetMouse(&point, &buttons, false);
				if (rect.Contains(point)) {
					// calculate the vertical scrolling offset
					float hotDist = rect.Height() * SCROLL_AREA;
					if (point.y > rect.bottom - hotDist)
						scrollV = hotDist - (rect.bottom - point.y);
					else if (point.y < rect.top + hotDist)
						scrollV = (point.y - rect.top) - hotDist;
				}
				// scroll
				if (scrollV != 0.0 && fScrollView) {
					if (BScrollBar* scrollBar = fScrollView->ScrollBar(B_VERTICAL)) {
						float value = scrollBar->Value();
						scrollBar->SetValue(scrollBar->Value() + scrollV);
						if (scrollBar->Value() != value) {
							// update mouse position
							uint32 buttons;
							BPoint point;
							GetMouse(&point, &buttons, false);
							uint32 transit = Bounds().Contains(point) ? B_INSIDE_VIEW : B_OUTSIDE_VIEW;
							MouseMoved(point, transit, &fDragMessageCopy);
						}
					}
				}
				break;
			}
//			case B_MODIFIERS_CHANGED:
//				ModifiersChanged();
//				break;
			case B_MOUSE_WHEEL_CHANGED: {
				BListView::MessageReceived(message);
				BPoint point;
				uint32 buttons;
				GetMouse(&point, &buttons, false);
				uint32 transit = Bounds().Contains(point) ? B_INSIDE_VIEW : B_OUTSIDE_VIEW;
				MouseMoved(point, transit, &fDragMessageCopy);
				break;
			}
			default:
				BListView::MessageReceived(message);
				break;
		}
	}
}
Пример #20
0
int
main(int, char **argv)
{	
	BApplication app(kAppSignature);
	bool atLeastOnePath = false;
	BList titleList;
	BList actionList;
	BDeskbar deskbar;
	status_t err = B_OK;

	for (int32 i = 1; argv[i]!=NULL; i++) {
		if (strcmp(argv[i], "--help") == 0)
			break;
		
		if (strcmp(argv[i], "--list") == 0) {
			int32 count = deskbar.CountItems();
			int32 found = 0;
			int32 j = 0;
			printf("Deskbar items:\n");

			while (found < count) {
				const char *name = NULL;
				if (deskbar.GetItemInfo(j, &name) == B_OK) {
					printf("Item %ld: '%s'\n", j, name);
					free((void *)name);
					found++;
				}
				j++;
			}
			return 0;
		}

		if (strcmp(argv[i], "--add-volume") == 0) {
			entry_ref ref;
			if (get_ref_for_path(argv[0], &ref) == B_OK) {
				deskbar.AddItem(&ref);
			}
			return 0;
		}

		if (strcmp(argv[i], "--volume-control") == 0) {
			BWindow* window = new VolumeWindow(BRect(200, 150, 400, 200));
			window->Show();

			wait_for_thread(window->Thread(), NULL);
			return 0;
		}

		if (strncmp(argv[i], "--remove", 8) == 0) {
			BString replicant = "DeskButton";
			if (strncmp(argv[i] + 8, "=", 1) == 0) {
				if (strlen(argv[i] + 9) > 0) {
					replicant = argv[i] + 9;
				} else {
					printf("desklink: Missing replicant name.\n");
					return 1;
				}
			}
			int32 found = 0;
			int32 found_id;
			while (deskbar.GetItemInfo(replicant.String(), &found_id) == B_OK) {
				err = deskbar.RemoveItem(found_id);
				if (err != B_OK) {
					printf("desklink: Error removing replicant id %ld: %s\n",
						found_id, strerror(err));
					break;
				}
				found++;
			}
			printf("Removed %ld items.\n", found);
			return err;
		}

		if (strncmp(argv[i], "cmd=", 4) == 0) {
			BString *title = new BString(argv[i] + 4);
			int32 index = title->FindFirst(':');
			if (index <= 0) {
				printf("desklink: usage: cmd=title:action\n");
			} else {
				title->Truncate(index);
				BString *action = new BString(argv[i] + 4);
				action->Remove(0, index+1);
				titleList.AddItem(title);
				actionList.AddItem(action);
			}
			continue;
		}

		atLeastOnePath = true;

		BEntry entry(argv[i], true);
		entry_ref ref;
		
		if (entry.Exists()) {
			entry.GetRef(&ref);
		} else if (BMimeType::IsValid(argv[i])) {
			if (be_roster->FindApp(argv[i], &ref) != B_OK) {
				printf("desklink: cannot find '%s'\n", argv[i]);
				return 1;
			}
		} else {
			printf("desklink: cannot find '%s'\n", argv[i]);
			return 1;
		}
		
		err = deskbar.AddItem(&ref);
		if (err != B_OK) {
			err = deskbar.AddItem(new DeskButton(BRect(0, 0, 15, 15),
				&ref, ref.name, titleList, actionList));
			if (err != B_OK) {
				printf("desklink: Deskbar refuses link to '%s': %s\n", argv[i], strerror(err));
				return 1;
			}
		}

		titleList.MakeEmpty();
		actionList.MakeEmpty();
	}

	if (!atLeastOnePath) {
		printf(	"usage: desklink { [ --list|--remove|[cmd=title:action ... ] [ path|signature ] } ...\n"
			"--add-volume: install volume control into Deskbar.\n"
			"--volume-control: show window with global volume control.\n"
			"--list: list all Deskbar addons.\n"
			"--remove: remove all desklink addons.\n"
			"--remove=name: remove all 'name' addons.\n");
		return 1;
	}

	return 0;
}
Пример #21
0
// ResolveDependencies
status_t
CollectingPlaylist::ResolveDependencies(const ServerObjectManager* library)
{
//uint64 oldDuration = Duration();
	MakeEmpty();

	// find the type marker, so we know which collectable playlists
	// we are looking for
	BString typeMarker(TypeMarker());
	if (typeMarker.Length() <= 0) {
		print_error("CollectingPlaylist::ResolveDependencies() - "
			"no \"type marker\" specified!\n");
		return B_ERROR;
	}

	// * find all TemplatePlaylists with a certain type, and which
	//   are valid for "today"
	// * add ClipPlaylistItems for each above created clip and
	//   layout these, separating individual sequences by the
	//   transitionClip
	BList collectables;

	int32 count = library->CountObjects();
	for (int32 i = 0; i < count; i++) {
		ServerObject* object = library->ObjectAtFast(i);
		CollectablePlaylist* collectable = dynamic_cast<CollectablePlaylist*>(
			object);
		if (!collectable)
			continue;

		if (typeMarker != collectable->TypeMarker()) {
//print_info("found Collectable playlist, but type does not match: %s/%s\n",
//	typeMarker.String(), collectable->TypeMarker());
			continue;
		}

		OptionProperty* statusOption = dynamic_cast<OptionProperty*>(
			collectable->FindProperty(PROPERTY_STATUS));
		// in case the object does have this property, check
		// the status and don't collect referenced objects if
		// it is not set to "published"
		if (statusOption
			&& statusOption->Value() != PLAYLIST_STATUS_LIVE) {
			continue;
		}

		if (!collectable->IsValidToday()) {
//print_info("found fitting Collectable playlist, but it is outdated: %s/%ld\n",
//	collectable->StartDate(), collectable->ValidDays());
			continue;
		}

		if (collectables.AddItem(collectable)) {
		} else {
			print_error("CollectingPlaylist::ResolveDependencies() - "
				"no memory to add collectable playlist\n");
			return B_NO_MEMORY;
		}
	}

	if (collectables.CountItems() <= 0)
		return B_OK;

	status_t ret;
	switch (CollectorMode()) {
		case COLLECTOR_MODE_RANDOM:
			ret = _CollectRandom(collectables, library);
			break;
		case COLLECTOR_MODE_SEQUENCE:
		default:
			ret = _CollectSequence(collectables, library);
			break;
	}

	Playlist::_ItemsChanged();

	_LayoutBackgroundSound(library);

//print_info("CollectingPlaylist: collected '%s', new duration: %lld "
//	"(was %lld) frames\n", typeMarker.String(), Duration(), oldDuration);

	return ret;
}
Пример #22
0
status_t
updateTimeLineThread(void *data)
{
	//Could not figure out how to update a BListItem with a child view (BTextView).
	//Could be a bug in Haiku APIs. After hours of investigation without any
	//result, I just don't care anymore. Reallocating all HTGTweetItem on update.
	HTGTimeLineView *super = (HTGTimeLineView*)data;
	
	HTGListView *listView = super->listView;
	bool saveTweets = super->saveTweets;
	
	int32 TYPE = super->TYPE;
	twitCurl *twitObj = super->twitObj;
	HTTimelineParser *timeLineParser;
	std::string replyMsg(" ");
	
	HTGTweetItem *mostRecentItem = NULL;
	HTTweet *mostRecentTweet = NULL;
	HTTweet *currentTweet = NULL;
	
	BList *newList = new BList();
	
	switch(TYPE) {
		case TIMELINE_HOME:
			twitObj->timelineHomeGet();
			break;
		case TIMELINE_FRIENDS:
			twitObj->timelineFriendsGet();
			break;
		case TIMELINE_MENTIONS:
			twitObj->mentionsGet();
			break;
		case TIMELINE_PUBLIC:
			twitObj->timelinePublicGet();
			break;
		case TIMELINE_USER:
			twitObj->timelineUserGet(true, true, 25); // TODO: is this correct?
			break;
		case TIMELINE_SEARCH:
			twitObj->search(htmlFormatedString(super->Name()));
			break;
		case TIMELINE_HDD:
			return B_OK;
			break;
		default:
			twitObj->timelinePublicGet();
	}
	
	twitObj->getLastWebResponse(replyMsg);
	
	#ifdef DEBUG_ENABLED
		std::cout << "HTGTimelineView: web response:" << std::endl;
	 	std::cout << replyMsg << std::endl;
	 #endif

	if(replyMsg.length() < 10) {
		super->errorCount++;
		if(super->errorCount < kMaximumRetries) {
			super->waitingForUpdate = true;
			#ifdef DEBUG_ENABLED
			std::cout << "No connection. Retry " << super->errorCount << "/" << kMaximumRetries << std::endl;
			std::string error; twitObj->getLastCurlError(error);
			std::cout << "Curl error: " << error << std::endl;
			#endif
			usleep(5000 * pow(super->errorCount,2));
			return updateTimeLineThread(super);
		}
		else
			replyMsg= string("error");
	}
	else
		super->errorCount = 0;
	
	if(TYPE == TIMELINE_SEARCH)
		timeLineParser = new HTSearchParser();
	else
		timeLineParser = new HTTimelineParser();

	try {
		timeLineParser->Parse(replyMsg);
	}
	catch( ... ) {
		std::cout << super->Name() << ": Error while parsing data." << std::endl;
		delete timeLineParser;
		timeLineParser = NULL;
		return B_OK;
	}
	
	if(timeLineParser->Tweets()->CountItems() < 1) {//timeLineParser failed, return!
		std::cout << super->Name() << ": Parser didn't find any tweets." << std::endl;
		delete timeLineParser;
		timeLineParser = NULL;
		return B_OK;
	}
	
	bool initialLoad = (listView->FirstItem() == NULL && super->unhandledList->FirstItem() == NULL);
	
	if(!initialLoad && listView->FirstItem() != NULL) {
		mostRecentItem = (HTGTweetItem *)listView->FirstItem();
		mostRecentTweet = mostRecentItem->getTweetPtr();
		currentTweet = (HTTweet *)timeLineParser->Tweets()->ItemAt(0);
	
		/*If we are up to date: redraw, clean up and return - Note this should not be done here,
		rather as a result of some BPulse I guess...*/
		if(!(*mostRecentTweet < *currentTweet)) {
			if(listView->LockLooper()) {
				for(int i = 0; i < listView->CountItems(); i++)
					listView->InvalidateItem(i); //Update date
				listView->UnlockLooper();
			}	
			delete timeLineParser;
			timeLineParser = NULL;
			return B_OK;
		}
	}
	
	/*Check to see if there is some unhandled tweets*/
	if(!super->unhandledList->IsEmpty()) {
		mostRecentItem = (HTGTweetItem *)super->unhandledList->FirstItem();
		mostRecentTweet = mostRecentItem->getTweetPtr();
	}
	
	for (int i = 0; i < timeLineParser->Tweets()->CountItems(); i++) {
		currentTweet = (HTTweet *)timeLineParser->Tweets()->ItemAt(i);
		bool addItem = initialLoad;
		if(!initialLoad) {
			if(mostRecentTweet != NULL)
				addItem = (*mostRecentTweet < *currentTweet);
			else
				addItem = true;
		}
		if(addItem) {
			/*Make a copy, download bitmap and add it to newList*/
			HTTweet *copiedTweet = new HTTweet(currentTweet);
			copiedTweet->downloadBitmap();
			newList->AddItem(new HTGTweetItem(copiedTweet));
			
			if(!initialLoad && super->wantsNotifications) { //New tweet arrived, send notification
				super->sendNotificationFor(copiedTweet);
			}
			if(saveTweets)
				HTStorage::saveTweet(copiedTweet);
		}
		else
			break;
	}
	
	super->unhandledList->AddList(newList, 0);
	
	/*Try to lock listView*/
	if(!listView->LockLooper()) {
		/*Not active view: return*/
		super->waitingForUpdate = true;
		delete timeLineParser;
		timeLineParser = NULL;
		delete newList;
		
		return B_OK;
	}
	
	/*Add the tweets to timeline*/
	super->addUnhandledTweets();
			
	/*Cleanup*/
	super->waitingForUpdate = false;
	listView->UnlockLooper();
	delete timeLineParser;
	timeLineParser = NULL;
	delete newList;

	return B_OK;
}
Пример #23
0
bool
GrepWindow::_AreAllFoldersOpenInTracker(BList* folderList)
{
	// Compare the folders we want open in Tracker to
	// the actual Tracker windows currently open.

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

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

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

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

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

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

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

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

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

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

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

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

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

			if (folderPath == NULL)
				break;

			if (windowRef == NULL)
				break;

			folderString = folderPath->Path();

			BEntry entry;
			BPath path;

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

				windowString = path.Path();

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

	result = found == folderCount;

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

	return result;
}
Пример #24
0
status_t TGenericDirentParser::AddEntries(const char *strDirList, const char *option)
{
	status_t status = B_OK;
	uint32 st = 1;
	BList list;
	BString strdir(strDirList), curdir;
	strdir.ReplaceAll("\r\n", "\n");
	strdir.ReplaceAll("\r", "\n");
	
	// ftpd から得た NLST 文字列 strDirList を各行に分割して list にポインタを記憶する
	char *p = (char *)strdir.String();
	while (*p != 0) {
		list.AddItem(p);
		p = strchr(p, '\n');
	    if (p == NULL) break;
		*p = 0;
		p++;
	}
	
	// 解析
	for(int32 i = 0; i < list.CountItems(); i++) {
		p = (char *)list.ItemAt(i);
		
		// 空白行は無視。但し、次行はディレクトリ名と仮定(再帰モード時)
		if (strlen(p) == 0) {
			st = 0;
			continue;
		}
		if (st == 0) {
			st = 1;
			if (strcmp(option, "R") == 0) {
				curdir.SetTo(p);
				if (curdir.String()[curdir.Length() - 1] == ':') curdir.ReplaceLast(":", "");
				i++;		// ディレクトリ名の次は total または空行なので無視
				continue;
			}
		}
		
		// 先頭文字(即ち permission のファイル属性) が "-", "d", "l", "c" でなければ無視する。
		if (strchr("-dlc", *p) == NULL) continue;
		
		uint32 itemCount;
		char *dlist[10], *permission, *num, *owner, *group, *cparam, *size, *month, *day, *houryear, *name;
		memset(dlist, 0, sizeof(dlist));
		if (*p == 'c') {
			itemCount = 10;
			strparse(p, dlist, &itemCount);
			if (itemCount != 10) continue;
			permission = dlist[0];
			num        = dlist[1];
			owner      = dlist[2];
			group      = dlist[3];
			cparam     = dlist[4];
			size       = dlist[5];
			month      = dlist[6];
			day        = dlist[7];
			houryear   = dlist[8];
			name       = dlist[9];
		} else {
			itemCount = 9;
			strparse(p, dlist, &itemCount);
			if (itemCount != 9) continue;
			permission = dlist[0];
			num        = dlist[1];
			owner      = dlist[2];
			group      = dlist[3];
			size       = dlist[4];
			month      = dlist[5];
			day        = dlist[6];
			houryear   = dlist[7];
			name       = dlist[8];
		}
		
		
		// 日付・時間を変換
		BString strdate, strtime;
		if (atoi(houryear) < 1900) {
			char stryear[5];
			time_t timer;
			struct tm *date;
			time(&timer);
			date = localtime(&timer);
			strftime(stryear, sizeof(stryear), "%Y", date);
			strdate << stryear;
			strtime << " " << houryear;
		} else {
			strdate << houryear;
		}
		strdate << "/";
		if (strcasecmp("Jan", month) == 0) strdate << "01"; else
		if (strcasecmp("Feb", month) == 0) strdate << "02"; else
		if (strcasecmp("Mar", month) == 0) strdate << "03"; else
		if (strcasecmp("Apr", month) == 0) strdate << "04"; else
		if (strcasecmp("May", month) == 0) strdate << "05"; else
		if (strcasecmp("Jun", month) == 0) strdate << "06"; else
		if (strcasecmp("Jul", month) == 0) strdate << "07"; else
		if (strcasecmp("Aug", month) == 0) strdate << "08"; else
		if (strcasecmp("Sep", month) == 0) strdate << "09"; else
		if (strcasecmp("Oct", month) == 0) strdate << "10"; else
		if (strcasecmp("Nov", month) == 0) strdate << "11"; else
		if (strcasecmp("Dec", month) == 0) strdate << "12"; else strdate << month;
		char strday[3];
		sprintf(strday, "%2.2d", atoi(day));
		strdate << "/" << strday << strtime;
		
		// リストに追加
		status = this->AddEntry(curdir.String(), name, atoi(size), strdate.String(), permission, owner, group);
		if (status != B_OK) break;
	}
	return status;
}
Пример #25
0
BView*
AboutView::_CreateCreditsView()
{
	// Begin construction of the credits view
	fCreditsView = new HyperTextView("credits");
	fCreditsView->SetFlags(fCreditsView->Flags() | B_FRAME_EVENTS);
	fCreditsView->SetStylable(true);
	fCreditsView->MakeEditable(false);
	fCreditsView->SetWordWrap(true);
	fCreditsView->SetInsets(5, 5, 5, 5);

	BScrollView* creditsScroller = new BScrollView("creditsScroller",
		fCreditsView, B_WILL_DRAW | B_FRAME_EVENTS, false, true,
		B_PLAIN_BORDER);

	// Haiku copyright
	BFont font(be_bold_font);
	font.SetSize(font.Size() + 4);

	fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuGreen);
	fCreditsView->Insert("Haiku\n");

	char string[1024];
	time_t time = ::time(NULL);
	struct tm* tm = localtime(&time);
	int32 year = tm->tm_year + 1900;
	if (year < 2008)
		year = 2008;
	snprintf(string, sizeof(string),
		COPYRIGHT_STRING "2001-%ld The Haiku project. ", year);

	fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kDarkGrey);
	fCreditsView->Insert(string);

	fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kDarkGrey);
	fCreditsView->Insert(B_TRANSLATE("The copyright to the Haiku code is "
		"property of Haiku, Inc. or of the respective authors where expressly "
		"noted in the source. Haiku and the Haiku logo are trademarks of "
		"Haiku, Inc."
		"\n\n"));

	fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kLinkBlue);
	fCreditsView->InsertHyperText("http://www.haiku-os.org",
		new URLAction("http://www.haiku-os.org"));
	fCreditsView->Insert("\n\n");

	font.SetSize(be_bold_font->Size());
	font.SetFace(B_BOLD_FACE | B_ITALIC_FACE);

	fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuOrange);
	fCreditsView->Insert(B_TRANSLATE("Current maintainers:\n"));

	fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kDarkGrey);
	fCreditsView->Insert(
		"Ithamar R. Adema\n"
		"Bruno G. Albuquerque\n"
		"Stephan Aßmus\n"
		"Salvatore Benedetto\n"
		"Stefano Ceccherini\n"
		"Rudolf Cornelissen\n"
		"Alexandre Deckner\n"
		"Adrien Destugues\n"
		"Oliver Ruiz Dorantes\n"
		"Axel Dörfler\n"
		"Jérôme Duval\n"
		"René Gollent\n"
		"Bryce Groff\n"
		"Colin Günther\n"
		"Karsten Heimrich\n"
		"Fredrik Holmqvist\n"
		"Philippe Houdoin\n"
		"Maurice Kalinowski\n"
		"Euan Kirkhope\n"
		"Ryan Leavengood\n"
		"Michael Lotz\n"
		"Brecht Machiels\n"
		"Matt Madia\n"
		"Scott McCreary\n"
		"David McPaul\n"
		"Wim van der Meer\n"
		"Fredrik Modéen\n"
		"Marcus Overhagen\n"
		"Michael Pfeiffer\n"
		"François Revol\n"
		"Philippe Saint-Pierre\n"
		"Andrej Spielmann\n"
		"Jonas Sundström\n"
		"Oliver Tappe\n"
		"Gerasim Troeglazov\n"
		"Ingo Weinhold\n"
		"Artur Wyszyński\n"
		"Clemens Zeidler\n"
		"Siarzhuk Zharski\n"
		"\n");

	fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuOrange);
	fCreditsView->Insert(B_TRANSLATE("Past maintainers:\n"));

	fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kDarkGrey);
	fCreditsView->Insert(
		"Andrew Bachmann\n"
		"Tyler Dauwalder\n"
		"Daniel Furrer\n"
		"Andre Alves Garzia\n"
		"Erik Jaesler\n"
		"Marcin Konicki\n"
		"Waldemar Kornewald\n"
		"Thomas Kurschel\n"
		"Frans Van Nispen\n"
		"Adi Oanca\n"
		"Michael Phipps\n"
		"Niels Sascha Reedijk\n"
		"David Reid\n"
		"Hugo Santos\n"
		"Alexander G. M. Smith\n"
		"Bryan Varner\n"
		"Nathan Whitehorn\n"
		"Michael Wilber\n"
		"Jonathan Yoder\n"
		"Gabe Yoder\n"
		"\n");

	fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuOrange);
	fCreditsView->Insert(B_TRANSLATE("Website, marketing & documentation:\n"));

	fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kDarkGrey);
	fCreditsView->Insert(
		"Phil Greenway\n"
		"Gavin James\n"
		"Jorge G. Mare (aka Koki)\n"
		"Urias McCullough\n"
		"Niels Sascha Reedijk\n"
		"Joachim Seemer (Humdinger)\n"
		"Jonathan Yoder\n"
		"\n");

	fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuOrange);
	fCreditsView->Insert(B_TRANSLATE("Contributors:\n"));

	fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kDarkGrey);
	fCreditsView->Insert(
		"Andrea Anzani\n"
		"Sean Bartell\n"
		"Andre Braga\n"
		"Bruce Cameron\n"
		"Greg Crain\n"
		"David Dengg\n"
		"John Drinkwater\n"
		"Cian Duffy\n"
		"Vincent Duvert\n"
		"Fredrik Ekdahl\n"
		"Joshua R. Elsasser\n"
		"Atis Elsts\n"
		"Mark Erben\n"
		"Christian Fasshauer\n"
		"Andreas Färber\n"
		"Janito Ferreira Filho\n"
		"Marc Flerackers\n"
		"Michele Frau (zuMi)\n"
		"Pete Goodeve\n"
		"Lucian Adrian Grijincu\n"
		"Matthijs Hollemans\n"
		"Mathew Hounsell\n"
		"Morgan Howe\n"
		"Christophe Huriaux\n"
		"Ma Jie\n"
		"Carwyn Jones\n"
		"Vasilis Kaoutsis\n"
		"James Kim\n"
		"Shintaro Kinugawa\n"
		"Jan Klötzke\n"
		"Kurtis Kopf\n"
		"Tomáš Kučera\n"
		"Luboš Kulič\n"
		"Elad Lahav\n"
		"Anthony Lee\n"
		"Santiago Lema\n"
		"Raynald Lesieur\n"
		"Oscar Lesta\n"
		"Jerome Leveque\n"
		"Christof Lutteroth\n"
		"Graham MacDonald\n"
		"Jan Matějek\n"
		"Brian Matzon\n"
		"Christopher ML Zumwalt May\n"
		"Andrew McCall\n"
		"Nathan Mentley\n"
		"Marius Middelthon\n"
		"Marco Minutoli\n"
		"Misza\n"
		"MrSiggler\n"
		"Alan Murta\n"
		"Raghuram Nagireddy\n"
		"Jeroen Oortwijn (idefix)\n"
		"Pahtz\n"
		"Michael Paine\n"
		"Adrian Panasiuk\n"
		"Romain Picard\n"
		"Francesco Piccinno\n"
		"David Powell\n"
		"Jeremy Rand\n"
		"Hartmut Reh\n"
		"Daniel Reinhold\n"
		"Chris Roberts\n"
		"Samuel Rodríguez Pérez\n"
		"Thomas Roell\n"
		"Rafael Romo\n"
		"Ralf Schülke\n"
		"John Scipione\n"
		"Reznikov Sergei\n"
		"Zousar Shaker\n"
		"Caitlin Shaw\n"
		"Daniel Switkin\n"
		"Atsushi Takamatsu\n"
		"James Urquhart\n"
		"Jason Vandermark\n"
		"Sandor Vroemisse\n"
		"Denis Washington\n"
		"Alex Wilson\n"
		"Ulrich Wimboeck\n"
		"Johannes Wischert\n"
		"James Woodcock\n"
		"Hong Yul Yang\n"
		"Gerald Zajac\n"
		"Łukasz Zemczak\n"
		"JiSheng Zhang\n"
		"Zhao Shuai\n");
	fCreditsView->Insert(
		B_TRANSLATE("\n" B_UTF8_ELLIPSIS
			" and probably some more we forgot to mention (sorry!)"
			"\n\n"));

	fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuOrange);
	fCreditsView->Insert(B_TRANSLATE("Translations:\n"));

	BLanguage* lang;
	BString langName;

	BList sortedTranslations;
	for (uint32 i = 0; i < kNumberOfTranslations; i ++) {
		const Translation* translation = &gTranslations[i];
		sortedTranslations.AddItem((void*)translation);
	}
	sortedTranslations.SortItems(TranslationComparator);

	for (uint32 i = 0; i < kNumberOfTranslations; i ++) {
		const Translation& translation =
			*(const Translation*)sortedTranslations.ItemAt(i);

		be_locale_roster->GetLanguage(translation.languageCode, &lang);
		langName.Truncate(0);
		lang->GetTranslatedName(langName);
		delete lang;

		fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuGreen);
		fCreditsView->Insert("\n");
		fCreditsView->Insert(langName);
		fCreditsView->Insert("\n");
		fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kDarkGrey);
		fCreditsView->Insert(
			translation.names
		);
	}

	fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuOrange);
	fCreditsView->Insert(B_TRANSLATE("\n\nSpecial thanks to:\n"));

	fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kDarkGrey);
	fCreditsView->Insert(
		B_TRANSLATE("Travis Geiselbrecht (and his NewOS kernel)\n"));
	fCreditsView->Insert(
		B_TRANSLATE("Michael Phipps (project founder)\n\n"));
	fCreditsView->Insert(
		B_TRANSLATE("The Haiku-Ports team\n"));
	fCreditsView->Insert(
		B_TRANSLATE("The Haikuware team and their bounty program\n"));
	fCreditsView->Insert(
		B_TRANSLATE("The BeGeistert team\n"));
	fCreditsView->Insert(
		B_TRANSLATE("Google & their Google Summer of Code program\n\n"));
	fCreditsView->Insert(
		B_TRANSLATE("... and the many people making donations!\n\n"));

	// copyrights for various projects we use

	BPath mitPath;
	_GetLicensePath("MIT", mitPath);

	font.SetSize(be_bold_font->Size() + 4);
	font.SetFace(B_BOLD_FACE);
	fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuGreen);
	fCreditsView->Insert(B_TRANSLATE("\nCopyrights\n\n"));

	fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kDarkGrey);
	fCreditsView->Insert(B_TRANSLATE("[Click a license name to read the "
		"respective license.]\n\n"));

	// Haiku license
	fCreditsView->Insert(B_TRANSLATE("The code that is unique to Haiku, "
		"especially the kernel and all code that applications may link "
		"against, is distributed under the terms of the "));
	fCreditsView->InsertHyperText(B_TRANSLATE("MIT license"),
		new OpenFileAction(mitPath.Path()));
	fCreditsView->Insert(B_TRANSLATE(". Some system libraries contain third "
		"party code distributed under the LGPL license. You can find the "
		"copyrights to third party code below.\n\n"));

	// GNU copyrights
	AddCopyrightEntry("The GNU Project",
		"Contains software from the GNU Project, "
		"released under the GPL and LGPL licenses:\n"
		"GNU C Library, "
		"GNU coretools, diffutils, findutils, "
		"sharutils, gawk, bison, m4, make, "
		"gdb, wget, ncurses, termcap, "
		"Bourne Again Shell.\n"
		COPYRIGHT_STRING "The Free Software Foundation.",
		StringVector("GNU LGPL v2.1", "GNU GPL v2", "GNU GPL v3", NULL),
		StringVector(),
		"http://www.gnu.org");

	// FreeBSD copyrights
	AddCopyrightEntry("The FreeBSD Project",
		"Contains software from the FreeBSD Project, "
		"released under the BSD license:\n"
		"cal, ftpd, ping, telnet, "
		"telnetd, traceroute\n"
		COPYRIGHT_STRING "1994-2008 The FreeBSD Project.  "
		"All rights reserved.",
		"http://www.freebsd.org");
			// TODO: License!

	// NetBSD copyrights
	AddCopyrightEntry("The NetBSD Project",
		"Contains software developed by the NetBSD, "
		"Foundation, Inc. and its contributors:\n"
		"ftp, tput\n"
		COPYRIGHT_STRING "1996-2008 The NetBSD Foundation, Inc.  "
		"All rights reserved.",
		"http://www.netbsd.org");
			// TODO: License!

	// FFMpeg copyrights
	_AddPackageCredit(PackageCredit("FFMpeg libavcodec")
		.SetCopyright(COPYRIGHT_STRING "2000-2007 Fabrice Bellard, et al.")
		.SetLicenses("GNU LGPL v2.1", "GNU LGPL v2", NULL)
		.SetURL("http://www.ffmpeg.org"));

	// AGG copyrights
	_AddPackageCredit(PackageCredit("AntiGrain Geometry")
		.SetCopyright(COPYRIGHT_STRING "2002-2006 Maxim Shemanarev (McSeem).")
		.SetLicenses("Anti-Grain Geometry", "BSD (3-clause)", "GPC", NULL)
		.SetURL("http://www.antigrain.com"));

	// PDFLib copyrights
	_AddPackageCredit(PackageCredit("PDFLib")
		.SetCopyright(COPYRIGHT_STRING "1997-2006 PDFlib GmbH and Thomas Merz. "
			"All rights reserved.\n"
			"PDFlib and PDFlib logo are registered trademarks of PDFlib GmbH.")
		.SetLicense("PDFlib Lite")
		.SetURL("http://www.pdflib.com"));

	// FreeType copyrights
	_AddPackageCredit(PackageCredit("FreeType2")
		.SetCopyright("Portions of this software are copyright "
			B_UTF8_COPYRIGHT " 1996-2006 "
			"The FreeType Project.  All rights reserved.")
		.SetLicense("FTL")
		.SetURL("http://www.freetype.org"));

	// Mesa3D (http://www.mesa3d.org) copyrights
	_AddPackageCredit(PackageCredit("Mesa")
		.SetCopyright(COPYRIGHT_STRING "1999-2006 Brian Paul. "
			"Mesa3D Project.  All rights reserved.")
		.SetLicense("MIT")
		.SetURL("http://www.mesa3d.org"));

	// SGI's GLU implementation copyrights
	_AddPackageCredit(PackageCredit("GLU")
		.SetCopyright(COPYRIGHT_STRING
			"1991-2000 Silicon Graphics, Inc. "
			"SGI's Software FreeB license.  All rights reserved.")
		.SetLicense("SGI Free B")
		.SetURL("http://www.sgi.com/products/software/opengl"));

	// GLUT implementation copyrights
	_AddPackageCredit(PackageCredit("GLUT")
		.SetCopyrights(COPYRIGHT_STRING "1994-1997 Mark Kilgard. "
			"All rights reserved.",
			COPYRIGHT_STRING "1997 Be Inc.",
			COPYRIGHT_STRING "1999 Jake Hamby.",
			NULL)
		.SetLicense("GLUT (Mark Kilgard)")
		.SetURL("http://www.opengl.org/resources/libraries/glut"));

	// OpenGroup & DEC (BRegion backend) copyright
	_AddPackageCredit(PackageCredit("BRegion backend (XFree86)")
		.SetCopyrights(COPYRIGHT_STRING "1987, 1988, 1998 The Open Group.",
			COPYRIGHT_STRING "1987, 1988 Digital Equipment "
			"Corporation, Maynard, Massachusetts.\n"
			"All rights reserved.",
			NULL)
		.SetLicenses("OpenGroup", "DEC", NULL));
			// TODO: URL

	// VL-Gothic font
	_AddPackageCredit(PackageCredit("VL-Gothic font")
		.SetCopyrights(COPYRIGHT_STRING "1990-2003 Wada Laboratory,"
			" the University of Tokyo", COPYRIGHT_STRING
			"2003-2004 Electronic Font Open Laboratory (/efont/)",
			COPYRIGHT_STRING "2003-2008 M+ FONTS PROJECT",
			COPYRIGHT_STRING "2006-2009 Daisuke SUZUKI",
			COPYRIGHT_STRING "2006-2009 Project Vine",
			"MIT license. All rights reserved.",
			NULL));
			// TODO: License!

	// expat copyrights
	_AddPackageCredit(PackageCredit("expat")
		.SetCopyrights(COPYRIGHT_STRING
			"1998, 1999, 2000 Thai Open Source "
			"Software Center Ltd and Clark Cooper.",
			COPYRIGHT_STRING "2001, 2002, 2003 Expat maintainers.",
			NULL)
		.SetLicense("Expat")
		.SetURL("http://expat.sourceforge.net"));

	// zlib copyrights
	_AddPackageCredit(PackageCredit("zlib")
		.SetCopyright(COPYRIGHT_STRING
			"1995-2004 Jean-loup Gailly and Mark Adler.")
		.SetLicense("Zlib")
		.SetURL("http://www.zlib.net"));

	// zip copyrights
	_AddPackageCredit(PackageCredit("Info-ZIP")
		.SetCopyright(COPYRIGHT_STRING
			"1990-2002 Info-ZIP. All rights reserved.")
		.SetLicense("Info-ZIP")
		.SetURL("http://www.info-zip.org"));

	// bzip2 copyrights
	_AddPackageCredit(PackageCredit("bzip2")
		.SetCopyright(COPYRIGHT_STRING
			"1996-2005 Julian R Seward. All rights reserved.")
		.SetLicense("BSD (4-clause)")
		.SetURL("http://bzip.org"));

	// lp_solve copyrights
	_AddPackageCredit(PackageCredit("lp_solve")
		.SetCopyright(COPYRIGHT_STRING
			"Michel Berkelaar, Kjell Eikland, Peter Notebaert")
		.SetLicense("GNU LGPL v2.1")
		.SetURL("http://lpsolve.sourceforge.net/"));

	// OpenEXR copyrights
	_AddPackageCredit(PackageCredit("OpenEXR")
		.SetCopyright(COPYRIGHT_STRING "2002-2005 Industrial Light & Magic, "
			"a division of Lucas Digital Ltd. LLC.")
		.SetLicense("BSD (3-clause)")
		.SetURL("http://www.openexr.com"));

	// Bullet copyrights
	_AddPackageCredit(PackageCredit("Bullet")
		.SetCopyright(COPYRIGHT_STRING "2003-2008 Erwin Coumans")
		.SetLicense("Bullet")
		.SetURL("http://www.bulletphysics.com"));

	// atftp copyrights
	_AddPackageCredit(PackageCredit("atftp")
		.SetCopyright(COPYRIGHT_STRING
			"2000 Jean-Pierre ervbefeL and Remi Lefebvre")
		.SetLicense("GNU GPL v2"));
			// TODO: URL!

	// Netcat copyrights
	_AddPackageCredit(PackageCredit("Netcat")
		.SetCopyright(COPYRIGHT_STRING "1996 Hobbit"));
			// TODO: License!

	// acpica copyrights
	_AddPackageCredit(PackageCredit("acpica")
		.SetCopyright(COPYRIGHT_STRING "1999-2006 Intel Corp.")
		.SetLicense("Intel (ACPICA)")
		.SetURL("http://www.acpica.org"));

	// unrar copyrights
	_AddPackageCredit(PackageCredit("unrar")
		.SetCopyright(COPYRIGHT_STRING "2002-2008 Alexander L. Roshal. "
			"All rights reserved.")
		.SetLicense("UnRAR")
		.SetURL("http://www.rarlab.com"));

	// libpng copyrights
	_AddPackageCredit(PackageCredit("libpng")
		.SetCopyright(COPYRIGHT_STRING "2004, 2006-2008 Glenn "
			"Randers-Pehrson.")
		.SetLicense("LibPNG")
		.SetURL("http://www.libpng.org"));

	// libjpeg copyrights
	_AddPackageCredit(PackageCredit("libjpeg")
		.SetCopyright(COPYRIGHT_STRING " 1994-2009, Thomas G. Lane,"
			" Guido Vollbeding. This software is based in part on the "
			"work of the Independent JPEG Group")
		.SetLicense("LibJPEG")
		.SetURL("http://www.ijg.org"));

	// libprint copyrights
	_AddPackageCredit(PackageCredit("libprint")
		.SetCopyright(COPYRIGHT_STRING
			"1999-2000 Y.Takagi. All rights reserved."));
			// TODO: License!

	// cortex copyrights
	_AddPackageCredit(PackageCredit("Cortex")
		.SetCopyright(COPYRIGHT_STRING "1999-2000 Eric Moon.")
		.SetLicense("BSD (3-clause)")
		.SetURL("http://cortex.sourceforge.net/documentation"));

	// FluidSynth copyrights
	_AddPackageCredit(PackageCredit("FluidSynth")
		.SetCopyright(COPYRIGHT_STRING "2003 Peter Hanappe and others.")
		.SetLicense("GNU LGPL v2")
		.SetURL("http://www.fluidsynth.org"));

	// CannaIM copyrights
	_AddPackageCredit(PackageCredit("CannaIM")
		.SetCopyright(COPYRIGHT_STRING "1999 Masao Kawamura."));
			// TODO: License!

	// libxml2, libxslt, libexslt copyrights
	_AddPackageCredit(PackageCredit("libxml2, libxslt")
		.SetCopyright(COPYRIGHT_STRING
			"1998-2003 Daniel Veillard. All rights reserved.")
		.SetLicense("MIT (no promotion)")
		.SetURL("http://xmlsoft.org"));

	_AddPackageCredit(PackageCredit("libexslt")
		.SetCopyright(COPYRIGHT_STRING
			"2001-2002 Thomas Broyer, Charlie "
			"Bozeman and Daniel Veillard.  All rights reserved.")
		.SetLicense("MIT (no promotion)")
		.SetURL("http://xmlsoft.org"));

	// Xiph.org Foundation copyrights
	_AddPackageCredit(PackageCredit("Xiph.org Foundation")
		.SetCopyrights("libvorbis, libogg, libtheora, libspeex",
			COPYRIGHT_STRING "1994-2008 Xiph.Org. "
			"All rights reserved.",
			NULL)
		.SetLicense("BSD (3-clause)")
		.SetURL("http://www.xiph.org"));

	// The Tcpdump Group
	_AddPackageCredit(PackageCredit("The Tcpdump Group")
		.SetCopyright("tcpdump, libpcap")
		.SetLicense("BSD (3-clause)")
		.SetURL("http://www.tcpdump.org"));

	// Matroska
	_AddPackageCredit(PackageCredit("libmatroska")
		.SetCopyright(COPYRIGHT_STRING "2002-2003 Steve Lhomme. "
			"All rights reserved.")
		.SetLicense("GNU LGPL v2.1")
		.SetURL("http://www.matroska.org"));

	// BColorQuantizer (originally CQuantizer code)
	_AddPackageCredit(PackageCredit("CQuantizer")
		.SetCopyright(COPYRIGHT_STRING "1996-1997 Jeff Prosise. "
			"All rights reserved.")
		.SetLicense("CQuantizer")
		.SetURL("http://www.xdp.it"));

	// MAPM (Mike's Arbitrary Precision Math Library) used by DeskCalc
	_AddPackageCredit(PackageCredit("MAPM")
		.SetCopyright(COPYRIGHT_STRING
			"1999-2007 Michael C. Ring. All rights reserved.")
		.SetLicense("MAPM")
		.SetURL("http://tc.umn.edu/~ringx004"));

	// MkDepend 1.7 copyright (Makefile dependency generator)
	_AddPackageCredit(PackageCredit("MkDepend")
		.SetCopyright(COPYRIGHT_STRING "1995-2001 Lars Düning. "
			"All rights reserved.")
		.SetLicense("MkDepend")
		.SetURL("http://bearnip.com/lars/be"));

	// libhttpd copyright (used as Poorman backend)
	_AddPackageCredit(PackageCredit("libhttpd")
		.SetCopyright(COPYRIGHT_STRING
			"1995,1998,1999,2000,2001 by "
			"Jef Poskanzer. All rights reserved.")
		.SetLicense("LibHTTPd")
		.SetURL("http://www.acme.com/software/thttpd/"));

#ifdef __INTEL__
	// Udis86 copyrights
	_AddPackageCredit(PackageCredit("Udis86")
		.SetCopyright(COPYRIGHT_STRING "2002, 2003, 2004 Vivek Mohan. "
			"All rights reserved.")
		.SetURL("http://udis86.sourceforge.net"));
			// TODO: License!
#endif

#ifdef __INTEL__
	// Intel PRO/Wireless 2100 Firmware
	_AddPackageCredit(PackageCredit("Intel PRO/Wireless 2100 Firmware")
		.SetCopyright(COPYRIGHT_STRING
			"2003-2006 by "
			"Intel Corporation. All rights reserved.")
		.SetLicense("Intel (2xxx firmware)")
		.SetURL("http://ipw2100.sourceforge.net/"));
#endif

#ifdef __INTEL__
	// Intel PRO/Wireless 2200BG Firmware
	_AddPackageCredit(PackageCredit("Intel PRO/Wireless 2200BG Firmware")
		.SetCopyright(COPYRIGHT_STRING
			"2004-2005 by "
			"Intel Corporation. All rights reserved.")
		.SetLicense("Intel (2xxx firmware)")
		.SetURL("http://ipw2200.sourceforge.net/"));
#endif

#ifdef __INTEL__
	// Intel PRO/Wireless 3945ABG/BG Network Connection Adapter Firmware
	_AddPackageCredit(
		PackageCredit(
			"Intel PRO/Wireless 3945ABG/BG Network Connection Adapter Firmware")
		.SetCopyright(COPYRIGHT_STRING
			"2006 - 2007 by "
			"Intel Corporation. All rights reserved.")
		.SetLicense("Intel (firmware)")
		.SetURL("http://www.intellinuxwireless.org/"));
#endif
#ifdef __INTEL__
	// Intel Wireless WiFi Link 4965AGN Adapter Firmware
	_AddPackageCredit(
		PackageCredit("Intel Wireless WiFi Link 4965AGN Adapter Firmware")
		.SetCopyright(COPYRIGHT_STRING
			"2006 - 2007 by "
			"Intel Corporation. All rights reserved.")
		.SetLicense("Intel (firmware)")
		.SetURL("http://www.intellinuxwireless.org/"));
#endif

#ifdef __INTEL__
	// Marvell 88w8363
	_AddPackageCredit(PackageCredit("Marvell 88w8363")
		.SetCopyright(COPYRIGHT_STRING
			"2007-2009 by "
			"Marvell Semiconductor, Inc. All rights reserved.")
		.SetLicense("Marvell (firmware)")
		.SetURL("http://www.marvell.com/"));
#endif

#ifdef __INTEL__
	// Ralink Firmware RT2501/RT2561/RT2661
	_AddPackageCredit(PackageCredit("Ralink Firmware RT2501/RT2561/RT2661")
		.SetCopyright(COPYRIGHT_STRING
			"2007 by "
			"Ralink Technology Corporation. All rights reserved.")
		.SetLicense("Ralink (firmware)")
		.SetURL("http://www.ralinktech.com/"));
#endif

	// ICU copyrights
	_AddPackageCredit(PackageCredit(
			"ICU - International Components for Unicode")
		.SetCopyright(COPYRIGHT_STRING
			"1995-2009 International Business Machines Corporation and others")
		.SetLicense("ICU")
		.SetURL("http://www.icu-project.org"));

	_AddCopyrightsFromAttribute();
	_AddPackageCreditEntries();

	return new CropView(creditsScroller, 0, 1, 1, 1);
}
Пример #26
0
void
Win::UrlTypedHandler( bool show_all )
{
//	printf( "Win::UrlTypedHandler()\n" );
	
	// get the stripped list from GlobalHistory
	BList* slist = ( ( App* )be_app )->GetGlobalHistory()->GetStrippedList();
	// create the matching urls list
	BList* list = new BList( 0 );
	
	BString typed_url;					// the typed url
	BString cached_url;					// the cached url
	BString cached_url_proto( "" );		// protocol of the cached url
	
	if( show_all == true )
		typed_url.SetTo( "" );
	else
	{
		typed_url.SetTo( navview->urlview->Text() );
		typed_url.ToLower();
	}
	
//	printf( "  typed_url: %s length: %ld\n", typed_url.String(), typed_url.Length() );
		
	int32 count = slist->CountItems();
	
	for( int32 i = 0; i < count; i++ )
	{
		GlobalHistoryItem* item = ( GlobalHistoryItem* )slist->ItemAt( i );
		if( item != NULL )
		{
			cached_url.SetTo( item->Text() );
//			printf( "  cached_url: %s\n", cached_url.String() );
					
			if( typed_url.Length() != 0 )
			{
				// if the typed url matches beginning of cached url, add it
				if( strncmp( cached_url.String(), typed_url.String(), typed_url.Length() ) == 0 )
				{
					list->AddItem( new BStringItem( cached_url.String() ) );
				}
				else
				{
					// if the urls dont match, take away the protocol of the cached url
					if( cached_url.FindFirst( "://" ) > 0 )
					{
						cached_url.MoveInto( cached_url_proto, 0, cached_url.FindFirst( "://" ) + 3 );
					}
					
					// if the urls fit now
					if( strncmp( cached_url.String(), typed_url.String(), typed_url.Length() ) == 0 )
					{
						// add the missing proto again
						if( cached_url_proto.Length() != 0 )
							cached_url.Prepend( cached_url_proto );
							
						list->AddItem( new BStringItem( cached_url.String() ) );
					}
					else
					{
						// if they still don't fit, remove 'www.' from cached url
						if( cached_url.FindFirst( "www." ) == 0 )
						{
							cached_url.Remove( 0, 4 );
						}
						
						// check if they finally fit
						if( strncmp( cached_url.String(), typed_url.String(), typed_url.Length() ) == 0 )
						{
							// add missing 'www.' and proto
							cached_url.Prepend( "www." );
							
							if( cached_url_proto.Length() != 0 )
								cached_url.Prepend( cached_url_proto );
													
							list->AddItem( new BStringItem( cached_url.String() ) );
						}
					}
					cached_url_proto.SetTo( "" );
				}
			}
			else
			{
				list->AddItem( new BStringItem( cached_url.String() ) );
			}
		} // if( item != NULL )
	}
	
	// delete slist ( not needed anymore )
	for( int32 i = 0; i < count; i++ )
	{
		GlobalHistoryItem* item = ( GlobalHistoryItem* )slist->ItemAt( i );
		if( item != NULL )
		{
			slist->RemoveItem( item );
			delete item;
		}
	}
	delete slist;
	
	// add the urlpopupwindow if needed
	if( list->CountItems() > 0 )
	{
		CreateUrlPopUpWindow();
		// add the list
		urlpopupwindow->Lock();
		urlpopupwindow->ListToDisplay( list );
		urlpopupwindow->Unlock();
	}
	else
	{
		if( urlpopupwindow != NULL )
		{
			urlpopupwindow->Lock();
			urlpopupwindow->Quit();
			urlpopupwindow = NULL;
		}
	}
}