Пример #1
0
int
main(int argc, char **argv)
{
	BApplication* testApp 
		= new BApplication("application/"catSig);

	// change to app-folder:
	app_info appInfo;
	be_app->GetAppInfo(&appInfo);
	BEntry appEntry(&appInfo.ref);
	BEntry appFolder;
	appEntry.GetParent(&appFolder);
	BPath appPath;
	appFolder.GetPath(&appPath);
	chdir(appPath.Path());

	CatalogSpeed catSpeed;
	printf("\t------------------------------------------------\n");
	printf("\tstring-based catalog usage:\n");
	printf("\t------------------------------------------------\n");
	catSpeed.TestCreation();
	catSpeed.TestLookup();
	printf("\t------------------------------------------------\n");
	printf("\tid-based catalog usage:\n");
	printf("\t------------------------------------------------\n");
	catSpeed.TestIdCreation();
	catSpeed.TestIdLookup();

	delete testApp;
	
	return 0;
}
Пример #2
0
AppMenuItem::AppMenuItem(const char* appSig, int category)
	:
	BMenuItem(kEmptyStr, NULL),
	fCategory(category),
	fIcon(NULL),
	fIsValid(false)
{
	if (be_roster->FindApp(appSig, &fAppRef) == B_NO_ERROR) {
		fIcon = new BBitmap(BRect(0.0, 0.0, 15.0, 15.0), B_RGBA32);
		if (BNodeInfo::GetTrackerIcon(&fAppRef, fIcon, B_MINI_ICON) == B_OK) {
			BEntry appEntry(&fAppRef);
			if (appEntry.InitCheck() == B_OK) {
				char name[B_FILE_NAME_LENGTH];
				appEntry.GetName(name);
				SetLabel(name);
				fIsValid = true;
			}
		}
	}
}
Пример #3
0
UAE::UAE() : BApplication(kApplicationSignature)
{
/* Disable this for just now - it screws specifying
 * a config file on the command line. We need to get
 * OS-specific arguments in a different way.
 */
#if 0
	// Find application directory and cwd to it
	app_info appInfo;
	GetAppInfo(&appInfo);

	BEntry appEntry(&appInfo.ref);
	BEntry appDirEntry;
	appEntry.GetParent(&appDirEntry);

	BPath appPath;
	appDirEntry.GetPath(&appPath);
	chdir(appPath.Path());
#endif
	RegisterMimeTypes();

	// Initialize other variables
	fEmulationWindow = NULL;
}
Пример #4
0
void BeHappy::SearchAddOns()
{
	// on vide les listes
	{
		BPath *p;
		while ((p=(BPath*)addOnsPaths.RemoveItem((int32)0))!=NULL)
			delete p;
			
		BString *s;
		while ((s=(BString*)addOnsNames.RemoveItem((int32)0))!=NULL)
			delete s;
	}
		
	// d'abord on cherche le dossier
	app_info myInfo;
	be_app->GetAppInfo(&myInfo);
	BEntry appEntry(&(myInfo.ref));
	BDirectory addOnsDir;
	appEntry.GetParent(&addOnsDir);
	
	// parcours de tous les fichiers du dossier
	if (addOnsDir.SetTo(&addOnsDir,"Add-ons")==B_OK)
	{
		BEntry addOn;
		while (addOnsDir.GetNextEntry(&addOn,true) == B_OK)
		{
			BPath *addOnPath = new BPath;
			addOn.GetPath(addOnPath);
			// extraction du type MIME
			{
				BNode myNode(&addOn);
								
				BNodeInfo myNodeInfo(&myNode);
				char mimeType[256];
				myNodeInfo.GetType(mimeType);
				if (BString("application/x-vnd.Be-elfexecutable") != mimeType)
					continue;
			}
			
			// on est sûrs que c'est un Add-on
			BString *projName = new BString;
			if (CheckAddOn(addOnPath->Path(),true,projName))
			{
				addOnsPaths.AddItem(addOnPath);
				addOnsNames.AddItem(projName);
			}
			else
			{
				delete addOnPath;
				delete projName;
			}
			
			// si c'est la première fois que SearchAddOns est appelé, on doit activer le node monitor
			if (!addOnsSearched)
			{
				addOnsSearched = true;
				
				node_ref myRef;
				addOnsDir.GetNodeRef(&myRef);
				watch_node(&myRef,B_WATCH_DIRECTORY,be_app_messenger);
			}
		}
	}
	else
	{
		BAlert *myAlert = new BAlert("BeHappy",T("Can't find Add-ons folder"),
			"Quit",NULL,NULL,B_WIDTH_AS_USUAL,B_STOP_ALERT);
		
		myAlert->Go();
		PostMessage(B_QUIT_REQUESTED);
	}
}
Пример #5
0
bool
MSHLanguageMgr::LoadLanguageFiles(const char * pathToFileStub)
{
	if (NULL != fTransFiles) {
		DeleteAllLanguageFilesAndList();
	}

	fTransFiles = new BList();

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

	bool loadedAtLeastOne = false;

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

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

	if (fFileNameStub.Length() > 0) {

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

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

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

	if (!loadedAtLeastOne) {
		DeleteAllLanguageFilesAndList();
	}

	return loadedAtLeastOne;
}