void
ScreenshotWindow::_ReadSettings()
{
	BMessage settings;

	BPath settingsPath;
	if (find_directory(B_USER_SETTINGS_DIRECTORY, &settingsPath) != B_OK)
		return;

	settingsPath.Append("Screenshot_settings");

	BFile file(settingsPath.Path(), B_READ_ONLY);
	if (file.InitCheck() == B_OK)
		settings.Unflatten(&file);

	if (settings.FindInt32("type", &fImageFileType) != B_OK)
		fImageFileType = B_PNG_FORMAT;
	settings.FindBool("includeBorder", &fIncludeBorder);
	settings.FindBool("includeCursor", &fIncludeCursor);
	settings.FindBool("grabActiveWindow", &fGrabActiveWindow);
	settings.FindInt64("delay", &fDelay);
	settings.FindString("outputFilename", &fOutputFilename);

	_SetupOutputPathMenu(settings);
}
status_t
BMailAccountSettings::Reload()
{
	BFile file(&fAccountFile, B_READ_ONLY);
	status_t status = file.InitCheck();
	if (status != B_OK)
		return status;
	BMessage settings;
	settings.Unflatten(&file);

	int32 id;
	if (settings.FindInt32("id", &id) == B_OK)
		fAccountID = id;
	settings.FindString("name", &fAccountName);
	settings.FindString("real_name", &fRealName);
	settings.FindString("return_address", &fReturnAdress);

	BMessage inboundSettings;
	settings.FindMessage("inbound", &inboundSettings);
	fInboundSettings.Load(inboundSettings);
	BMessage outboundSettings;
	settings.FindMessage("outbound", &outboundSettings);
	fOutboundSettings.Load(outboundSettings);

	if (settings.FindBool("inbound_enabled", &fInboundEnabled) != B_OK)
		fInboundEnabled = true;
	if (settings.FindBool("outbound_enabled", &fOutboundEnabled) != B_OK)
		fOutboundEnabled = true;

	fModified = false;
	return B_OK;
}
BMessage* Copy::Do(PDocument *doc, BMessage *settings)
{
	BMessage 	*clip				= NULL;
	BMessage	*node				= NULL;
	BMessage	*from				= NULL;
	BMessage	*to					= NULL;
	bool		fselect				= false;
	bool		tselect				= false;
	BMessage	*copyMessage		= new BMessage();
	BList		*selected			= doc->GetSelected();
	BList		*allConnections		= doc->GetAllConnections();

	int32		i					= 0;
	Indexer		*indexer			= new Indexer(doc);
	if (doc->Lock())
	{
		for (i=0;i<selected->CountItems();i++)
		{
			if (node=(BMessage *)selected->ItemAt(i))
			{
				if (node->what != P_C_CONNECTION_TYPE)
					copyMessage->AddMessage("node",indexer->IndexNode(node));
			}

		}
		for (i=0;i<allConnections->CountItems();i++ )
		{

			node = (BMessage *)allConnections->ItemAt(i);
			if ( (node->FindPointer("From",(void **)&from) == B_OK) &&
				 (node->FindPointer("To",(void **)&to) == B_OK) )
			{
				if ((from->FindBool("selected",&fselect)==B_OK) && (to->FindBool("selected",&tselect) == B_OK) )
				{
					if (fselect && tselect)
						copyMessage->AddMessage("node",indexer->IndexConnection(node,true));
					else if (fselect || tselect)
						copyMessage->AddMessage("node",indexer->IndexConnection(node));
				}
			}

		}	
		doc->Unlock();
	}
	if (be_clipboard->Lock()) 
	{
		be_clipboard->Clear();
		if (clip = be_clipboard->Data()) 
		{
			clip->AddData("application/x-vnd.projectconceptor-document", B_MIME_TYPE, copyMessage, sizeof(copyMessage));
			clip->AddMessage("test",copyMessage);
			PRINT_OBJECT(*clip);
			be_clipboard->Commit();
		}
		be_clipboard->Unlock();
	} 
	settings = PCommand::Do(doc,settings);
	return settings;
}
Exemple #4
0
WorkspacesSettings::WorkspacesSettings()
	:
	fAutoRaising(false),
	fAlwaysOnTop(false),
	fHasTitle(true),
	fHasBorder(true),
	fSwitchOnWheel(false),
	fLoaded(false)
{
	UpdateScreenFrame();

	BScreen screen;

	BFile file;
	if (_Open(file, B_READ_ONLY) == B_OK) {
		BMessage settings;
		if (settings.Unflatten(&file) == B_OK) {
			if (settings.FindRect("window", &fWindowFrame) == B_OK
				&& settings.FindRect("screen", &fScreenFrame) == B_OK)
				fLoaded = true;

			settings.FindBool("auto-raise", &fAutoRaising);
			settings.FindBool("always on top", &fAlwaysOnTop);

			if (settings.FindBool("has title", &fHasTitle) != B_OK)
				fHasTitle = true;
			if (settings.FindBool("has border", &fHasBorder) != B_OK)
				fHasBorder = true;
			if (settings.FindBool("switch on wheel", &fSwitchOnWheel) != B_OK)
				fSwitchOnWheel = false;
		}
	} else {
		// try reading BeOS compatible settings
		BPath path;
		if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) {
			path.Append(kOldSettingFile);
			BFile file(path.Path(), B_READ_ONLY);
			if (file.InitCheck() == B_OK
				&& file.Read(&fWindowFrame, sizeof(BRect)) == sizeof(BRect)) {
				// we now also store the frame of the screen to know
				// in which context the window frame has been chosen
				BRect frame;
				if (file.Read(&frame, sizeof(BRect)) == sizeof(BRect))
					fScreenFrame = frame;
				else
					fScreenFrame = screen.Frame();

				fLoaded = true;
			}
		}
	}

	if (fLoaded) {
		// if the current screen frame is different from the one
		// just loaded, we need to alter the window frame accordingly
		if (fScreenFrame != screen.Frame())
			UpdateFramesForScreen(screen.Frame());
	}
}
void
BShelf::_InitData(BEntry *entry, BDataIO *stream, BView *view,
	bool allowDrags)
{
	fContainerView = view;
	fStream = NULL;
	fEntry = entry;
	fFilter = NULL;
	fGenCount = 1;
	fAllowDragging = allowDrags;
	fDirty = true;
	fDisplayZombies = false;
	fAllowZombies = true;
	fTypeEnforced = false;

	if (entry)
		fStream = new BFile(entry, B_READ_ONLY);
	else
		fStream = stream;

	fFilter = new ShelfContainerViewFilter(this, fContainerView);

	fContainerView->AddFilter(fFilter);
	fContainerView->_SetShelf(this);

	if (fStream) {
		BMessage archive;

		if (archive.Unflatten(fStream) == B_OK) {
			bool allowZombies;
			if (archive.FindBool("_zom_dsp", &allowZombies) != B_OK)
				allowZombies = false;

			SetDisplaysZombies(allowZombies);

			if (archive.FindBool("_zom_alw", &allowZombies) != B_OK)
				allowZombies = true;

			SetAllowsZombies(allowZombies);

			int32 genCount;
			if (!archive.FindInt32("_sg_cnt", &genCount))
				genCount = 1;

			BMessage replicant;
			BMessage *replmsg = NULL;
			for (int32 i = 0; archive.FindMessage("replicant", i, &replicant) == B_OK; i++) {
				BPoint point;
				replmsg = new BMessage();
				replicant.FindPoint("position", &point);
				replicant.FindMessage("message", replmsg);
				AddReplicant(replmsg, point);
			}
		}
	}
}
Exemple #6
0
MainWindow::MainWindow(BRect frame, const BMessage& settings)
	:
	BWindow(frame, B_TRANSLATE_SYSTEM_NAME("HaikuDepot"),
		B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
		B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS),
	fTerminating(false),
	fModelWorker(B_BAD_THREAD_ID)
{
	BMenuBar* menuBar = new BMenuBar(B_TRANSLATE("Main Menu"));
	_BuildMenu(menuBar);

	fFilterView = new FilterView();
	fPackageListView = new PackageListView(fModel.Lock());
	fPackageInfoView = new PackageInfoView(fModel.Lock(), this);

	fSplitView = new BSplitView(B_VERTICAL, 5.0f);

	BLayoutBuilder::Group<>(this, B_VERTICAL, 0.0f)
		.Add(menuBar)
		.Add(fFilterView)
		.AddSplit(fSplitView)
			.AddGroup(B_VERTICAL)
				.Add(fPackageListView)
				.SetInsets(
					B_USE_DEFAULT_SPACING, 0.0f,
					B_USE_DEFAULT_SPACING, 0.0f)
			.End()
			.Add(fPackageInfoView)
		.End()
	;

	fSplitView->SetCollapsible(0, false);
	fSplitView->SetCollapsible(1, false);

	// Restore settings
	BMessage columnSettings;
	if (settings.FindMessage("column settings", &columnSettings) == B_OK)
		fPackageListView->LoadState(&columnSettings);

	bool showOption;
	if (settings.FindBool("show develop packages", &showOption) == B_OK)
		fModel.SetShowDevelopPackages(showOption);
	if (settings.FindBool("show source packages", &showOption) == B_OK)
		fModel.SetShowSourcePackages(showOption);

	_StartRefreshWorker();

	fPendingActionsSem = create_sem(0, "PendingPackageActions");
	if (fPendingActionsSem >= 0) {
		fPendingActionsWorker = spawn_thread(&_PackageActionWorker,
			"Planet Express", B_NORMAL_PRIORITY, this);
		if (fPendingActionsWorker >= 0)
			resume_thread(fPendingActionsWorker);
	}
}
Exemple #7
0
BColumn::BColumn(const BMessage &message, int32 index)
{
	message.FindString(kColumnTitleName, index, &fTitle);
	message.FindFloat(kColumnOffsetName, index, &fOffset);
	message.FindFloat(kColumnWidthName, index, &fWidth);
	message.FindInt32(kColumnAlignmentName, index, (int32 *)&fAlignment);
	message.FindString(kColumnAttrName, index, &fAttrName);
	message.FindInt32(kColumnAttrHashName, index, (int32 *)&fAttrHash);
	message.FindInt32(kColumnAttrTypeName, index, (int32 *)&fAttrType);
	message.FindBool(kColumnStatFieldName, index, &fStatField);
	message.FindBool(kColumnEditableName, index, &fEditable);
}
Exemple #8
0
static void
LaunchFiler(const entry_ref& ref)
{
	static uint32 launchTime = real_time_clock();

	RefStorage* refholder;
	team_id team;
	entry_ref dirRef;
	BEntry dir, file(&ref);
	BMessage msg(B_REFS_RECEIVED);

	file.GetParent(&dir);
	dir.GetRef(&dirRef);
	msg.AddRef("refs", &ref);

	gRefLock.Lock();

	for (int32 i = 0; i < gRefStructList.CountItems(); i++)
	{
		refholder = (RefStorage*) gRefStructList.ItemAt(i);

		if (refholder->ref == dirRef)
		{
			if (refholder->doAll && real_time_clock() > launchTime)
				refholder->doAll = false;

			msg.AddBool(kDoAll, refholder->doAll);
			msg.AddBool(kReplace, refholder->replace);
			break;
		}
	}

	be_roster->Launch(kFilerSignature, &msg, &team);

	if (!refholder->doAll)
	{
		BMessage reply;
		be_app_messenger.SetTo(NULL, team);

		if (be_app_messenger.SendMessage(MSG_AUTO_FILER, &reply) == B_OK)
		{
			reply.FindBool(kDoAll, &refholder->doAll);
			reply.FindBool(kReplace, &refholder->replace);
		}
	}

	launchTime = real_time_clock();

	gRefLock.Unlock();
}
Exemple #9
0
int32 FileDaemon::WaitOnRequests(void *arg) {
	FileDaemon *us = reinterpret_cast<FileDaemon *>(arg);
	status_t err = B_ERROR;
	BMessenger msgr(us);
	bool work = true;
	thread_id thread = find_thread(NULL);

	while (work) {
		snooze(kSnoozeTime);

		BMessage getRequest(kGetRequest);
		getRequest.AddInt32("threadid", thread);
		BMessage reply;

		if (msgr.SendMessage(&getRequest, &reply) != B_OK) {
			work = false;
			continue;
		};

		RequestInfo *info = NULL;
		reply.FindBool("continue", &work);
		
		if (reply.FindPointer("requestinfo", reinterpret_cast<void **>(&info)) != B_OK) continue;
		if (info == NULL) continue;

		status_t result = info->request->Start();

		// Send the complete/ error message
		if (info->target) {
			fprintf(stderr, "FileDaemon::WaitOnRequests(): %s: %s (%i)\n", info->request->URL(),
				strerror(result), result);
		
			switch (result) {
				case B_OK: {
					if (info->finish) info->target->SendMessage(info->finish);
				} break;
				
				case DownloadCancelled: {
					if (info->cancel) info->target->SendMessage(info->cancel);
				} break;
				
				default: {
					if (info->error) info->target->SendMessage(info->error);
				} break;
			};
		};

		BMessage requestComplete(kRequestComplete);
		requestComplete.AddInt32("threadid", thread);
		requestComplete.AddPointer("requestinfo", &info);
		
		msgr.SendMessage(&requestComplete);
	};

	BMessage threadComplete(kThreadComplete);
	threadComplete.AddInt32("threadid", thread);
	msgr.SendMessage(&threadComplete);
	
	return B_OK;
};
BPopUpMenu*
DefaultPartitionPage::_CreatePopUpMenu()
{
	int32 defaultPartitionIndex;
	fSettings->FindInt32("defaultPartition", &defaultPartitionIndex);

	BMenuItem* selectedItem = NULL;
	int32 selectedItemIndex = 0;

	BPopUpMenu* menu = new BPopUpMenu(B_TRANSLATE_COMMENT("Partitions",
		"Pop up menu title"));
	BMessage message;
	for (int32 i = 0; fSettings->FindMessage("partition", i, &message) == B_OK;
			i++) {
		bool show;
		if (message.FindBool("show", &show) != B_OK || !show)
			continue;

		BString name;
		message.FindString("name", &name);

		BMessage* msg = new BMessage(kMsgPartition);
		msg->AddInt32("index", i);
		BMenuItem* item = new BMenuItem(name.String(), msg);
		menu->AddItem(item);
		if (defaultPartitionIndex == i || selectedItem == NULL) {
			selectedItem = item;
			selectedItemIndex = i;
		}
	}
	fSettings->ReplaceInt32("defaultPartition", selectedItemIndex);
	selectedItem->SetMarked(true);
	return menu;
}
status_t
QuitTeamThreadFunction(void* data)
{
	TeamQuitter* teamQuitter = reinterpret_cast<TeamQuitter*>(data);
	if (teamQuitter == NULL)
		return B_ERROR;

	status_t status;	
	BMessenger messenger(NULL, teamQuitter->team, &status);
	if (status != B_OK)
		return status;

	BMessage message(B_QUIT_REQUESTED);
	BMessage reply;

	messenger.SendMessage(&message, &reply, 3000000, 3000000);

	bool result;
	if (reply.what != B_REPLY
		|| reply.FindBool("result", &result) != B_OK
		|| result == false) {
		message.what = kMsgQuitFailed;
		message.AddPointer("TeamQuitter", teamQuitter);
		message.AddInt32("error", reply.what);
		if (teamQuitter->window != NULL)
			teamQuitter->window->PostMessage(&message);
		return reply.what;
	}

	return B_OK;
}
status_t SeqManageRosterWindow::SetConfiguration(const BMessage* config)
{
	ArpASSERT(config);
	status_t	err = SetDimensions(config, this);
	if (err != B_OK) return err;
	/* Set the columns
	 */
	BColumnListView* table = dynamic_cast<BColumnListView*>( FindView(TABLE_STR) );
	if (table) {
		BMessage	colMsg;
		for (int32 k = 0; config->FindMessage("column", k, &colMsg) == B_OK; k++) {
			const char*		colName;
			float			colW;
			bool			colVis;
			if (colMsg.FindString("name", &colName) == B_OK
					&& colMsg.FindFloat("width", &colW) == B_OK
					&& colMsg.FindBool("visible", &colVis) == B_OK) {
				BColumn*	col = col_named(colName, table);
				if (col) {
					col->SetWidth(colW);
					col->SetVisible(colVis);
				}
			}
		}
	}
	return B_OK;
}
Exemple #13
0
deskbar_location
BDeskbar::Location(bool* _isExpanded) const
{
	deskbar_location location = B_DESKBAR_RIGHT_TOP;
	BMessage request(kMsgLocation);
	BMessage reply;

	if (_isExpanded)
		*_isExpanded = true;

	if (fMessenger->IsTargetLocal()) {
		// ToDo: do something about this!
		// (if we just ask the Deskbar in this case, we would deadlock)
		return location;
	}

	if (fMessenger->SendMessage(&request, &reply) == B_OK) {
		int32 value;
		if (reply.FindInt32("location", &value) == B_OK)
			location = static_cast<deskbar_location>(value);

		if (_isExpanded && reply.FindBool("expanded", _isExpanded) != B_OK)
			*_isExpanded = true;
	}

	return location;
}
Exemple #14
0
// --------------------------------------------------
Fonts::Fonts(BMessage *archive)
{
	BMessage m;
	for (int i = 0; archive->FindMessage("fontfile", i, &m) == B_OK; i++) {
		BArchivable* base = instantiate_object(&m);
		if (base) {
			FontFile* f = dynamic_cast<FontFile*>(base);
			if (f) fFontFiles.AddItem(f);
			else delete f;
		}
	}
	if (archive->FindMessage("cjk_order", &m) == B_OK) {
		for (int i = 0; i < no_of_cjk_encodings; i++) {
			bool active; int32 encoding;
			if (m.FindInt32("encoding", i, &encoding) == B_OK &&
				m.FindBool("active", i, &active) == B_OK &&
				first_cjk_encoding <= encoding &&
				encoding < first_cjk_encoding + no_of_cjk_encodings) {
				SetCJKOrder(i, (font_encoding)encoding, active);
			} else {
				SetDefaultCJKOrder(); return;
			}
		}
		return;
	}		
	SetDefaultCJKOrder();
}
Exemple #15
0
bool
IconEditorApp::QuitRequested()
{
    // Run the QuitRequested() hook in each window's own thread. Otherwise
    // the BAlert which a window shows when an icon is not saved will not
    // repaint the window. (BAlerts check which thread is running Go() and
    // will repaint windows when it's a BWindow.)
    bool quit = true;
    for (int32 i = 0; BWindow* window = WindowAt(i); i++) {
        if (!window->Lock())
            continue;
        // Try to cast the window while the pointer must be valid.
        MainWindow* mainWindow = dynamic_cast<MainWindow*>(window);
        window->Unlock();
        if (mainWindow == NULL)
            continue;
        BMessenger messenger(window, window);
        BMessage reply;
        if (messenger.SendMessage(B_QUIT_REQUESTED, &reply) != B_OK)
            continue;
        bool result;
        if (reply.FindBool("result", &result) == B_OK && !result)
            quit = false;
    }

    if (!quit)
        return false;

    _StoreSettings();

    return true;
}
Exemple #16
0
status_t
AppUsage::Unflatten(type_code code, const void* buffer,
	ssize_t numBytes)
{
	if (code != kTypeCode)
		return B_ERROR;

	BMessage msg;
	status_t status = B_ERROR;

	status = msg.Unflatten((const char*)buffer);

	if (status == B_OK) {
		msg.FindString("signature", &fName);
		msg.FindBool("allow", &fAllow);

		type_code type;
		int32 count = 0;

		status = msg.GetInfo("notification", &type, &count);
		if (status != B_OK)
			return status;

		for (int32 i = 0; i < count; i++) {
			NotificationReceived *notification = new NotificationReceived();
			msg.FindFlat("notification", i, notification);
			fNotifications[notification->Title()] = notification;
		}

		status = B_OK;
	}
	
	return status;
}
Exemple #17
0
void
NetServer::_ConfigureInterfaces(int socket, BMessage* _missingDevice)
{
	BMessage interface;
	uint32 cookie = 0;
	bool missing = false;
	while (fSettings.GetNextInterface(cookie, interface) == B_OK) {
		const char *device;
		if (interface.FindString("device", &device) != B_OK)
			continue;
			
		bool disabled = false;
		if (interface.FindBool("disabled", &disabled) == B_OK && disabled) {
			// disabled by user request
			_DisableInterface(socket, device);
			continue;
		}

		if (!strncmp(device, "/dev/net/", 9)) {
			// it's a kernel device, check if it's present
			BEntry entry(device);
			if (!entry.Exists()) {
				if (!missing && _missingDevice != NULL) {
					*_missingDevice = interface;
					missing = true;
				}
				continue;
			}
		}

		_ConfigureInterface(socket, interface);
	}
}
void					
BF_GUI_SetupDialog_FontDialog::Save(BMessage& o_Message)
{
	BF_GUI_Dialog::Save(o_Message);	
	
	
	int32 iIndex;
	ASSERT(B_OK==o_Message.FindInt32("styles",&iIndex));			
	
	const char *pcStyle=NULL;
	ASSERT(B_OK==o_Message.FindString("styles_code",&pcStyle));			
	const char *pcFamily=NULL;
	ASSERT(B_OK==o_Message.FindString("families_code",&pcFamily));			
	const char *pcSize=NULL;
	ASSERT(B_OK==o_Message.FindString("size",&pcSize) && pcSize);				
	bool bAntialising=false;
	ASSERT(B_OK==o_Message.FindBool("anti_aliasing",&bAntialising));
	
	BL_String s(pcSize);	
	float fSize = s.Float();	

	int32 iStyles=0;	
	s = pcStyle;
	if(s.FindFirst("Bold")>=0) iStyles = iStyles | B_BOLD_FACE;
	if(s.FindFirst("Regular")>=0) iStyles = iStyles | B_REGULAR_FACE;
	if(s.FindFirst("Italic")>=0) iStyles = iStyles | B_ITALIC_FACE;
	
	int32 iFlags = 0;
	if(bAntialising)  
		iFlags = iFlags | B_FORCE_ANTIALIASING;
	else
		iFlags = iFlags | B_DISABLE_ANTIALIASING;
	
	poFontItem->poFont->Set(pcFamily,iStyles,iFlags,fSize);
}
Exemple #19
0
void 
Settings::Load(BFile* file)
{
	BMessage message;
	if (message.Unflatten(file) == B_OK) {
		// restore application settings
		BString mimetype;
		BString printer;
		for (int i = 0; message.FindString("message", i, &mimetype) == B_OK &&
			message.FindString("p", i, &printer ) == B_OK; i ++) {
			AddAppSettings(new AppSettings(mimetype.String(), printer.String()));
		}

		// restore printer settings
		BMessage page;
		BMessage job;
		for (int i = 0; message.FindString("P", i, &printer) == B_OK &&
			message.FindMessage("S", i, &page) == B_OK &&
			message.FindMessage("J", i, &job) == B_OK; i ++) {
			AddPrinterSettings(new PrinterSettings(printer.String(), &page, &job));
		}
		
		if (message.FindBool("UseConfigWindow", &fUseConfigWindow) != B_OK)
			fUseConfigWindow = true;
		
		if (message.FindRect("ConfigWindowFrame", &fConfigWindowFrame) != B_OK)
			fConfigWindowFrame = BRect(kConfigWindowFrame);
			
		if (message.FindString("DefaultPrinter", &fDefaultPrinter) != B_OK)
			fDefaultPrinter = "";
	}
}
Exemple #20
0
WizardPageView*
BootManagerController::_CreateInstallSummaryPage()
{
	BString description;
	BString disk;
	fSettings.FindString("disk", &disk);

	description << B_TRANSLATE_COMMENT("Summary", "Title") << "\n"
		<< B_TRANSLATE("About to write the following boot menu to the boot "
			"disk (%s). Please verify the information below before continuing.")
		<< "\n\n";
	description.ReplaceFirst("%s", disk);

	BMessage message;
	for (int32 i = 0; fSettings.FindMessage("partition", i, &message) == B_OK;
			i++) {
		bool show;
		if (message.FindBool("show", &show) != B_OK || !show)
			continue;

		BString name;
		BString path;
		message.FindString("name", &name);
		message.FindString("path", &path);

		BString displayName;
		if (fBootMenu->GetDisplayText(name.String(), displayName) == B_OK)
			description << displayName << "\t(" << path << ")\n";
		else
			description << name << "\t(" << path << ")\n";
	}

	return new DescriptionPage("summary", description.String(), true);
}
Exemple #21
0
status_t
BreakpointSetting::SetTo(const BMessage& archive)
{
	_Unset();

	fFunctionID = ArchivingUtils::UnarchiveChild<FunctionID>(archive,
		"function");
	if (fFunctionID == NULL)
		return B_BAD_VALUE;

	archive.FindString("sourceFile", &fSourceFile);

	int32 line;
	if (archive.FindInt32("line", &line) != B_OK)
		line = -1;

	int32 column;
	if (archive.FindInt32("column", &column) != B_OK)
		column = -1;

	fSourceLocation = SourceLocation(line, column);

	if (archive.FindUInt64("relativeAddress", &fRelativeAddress) != B_OK)
		fRelativeAddress = 0;

	if (archive.FindBool("enabled", &fEnabled) != B_OK)
		fEnabled = false;

	return B_OK;
}
Exemple #22
0
bool _OwqRow::Matches( const BMessage& prefs ) const
{
	bool		b;
	const char*	str;
	entry_ref	ref;
	if( prefs.FindBool("on", &b) != B_OK ) return false;
	if( b != mOn ) return false;
	if( prefs.FindString("name", &str) != B_OK ) return false;
	if( mName != str ) return false;
	if( prefs.FindBool("skip", &b) != B_OK ) return false;
	if( mSkip != b ) return false;
	status_t	err = prefs.FindRef( "ref", &ref );
	if( err == B_OK && !mRef ) return false;
	if( err != B_OK && mRef ) return false;
	if( err != B_OK && !mRef ) return true;
	return ref == *mRef;
}
Exemple #23
0
status_t
Settings::Load()
{
	SetDefaults();
	
	BPath path;
	status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
	if (status == B_OK)
		status = path.Append("BeScreenCapture");
	
	BFile file;
	if (status == B_OK)
		status = file.SetTo(path.Path(), B_READ_ONLY);
	
	BMessage tempMessage;	
	if (status == B_OK)	
		status = tempMessage.Unflatten(&file);
	
	if (status == B_OK) {
		// Copy the loaded fields to the real settings message
		BRect rect;
		bool boolean;
		int32 integer;
		float decimal;
		const char *string = NULL;
		if (tempMessage.FindRect(kCaptureRect, &rect) == B_OK)
			sSettings.ReplaceRect(kCaptureRect, rect);
		if (tempMessage.FindInt32(kClipDepth, &integer) == B_OK)
			sSettings.ReplaceInt32(kClipDepth, integer);
		if (tempMessage.FindFloat(kClipShrink, &decimal) == B_OK)
			sSettings.ReplaceFloat(kClipShrink, decimal);
		if (tempMessage.FindBool(kUseDirectWindow, &boolean) == B_OK)
			sSettings.ReplaceBool(kUseDirectWindow, boolean);
		if (tempMessage.FindBool(kIncludeCursor, &boolean) == B_OK)
			sSettings.ReplaceBool(kIncludeCursor, boolean);
		if (tempMessage.FindBool(kMinimize, &boolean) == B_OK)
			sSettings.ReplaceBool(kMinimize, boolean);
		if (tempMessage.FindString(kOutputFile, &string) == B_OK)
			sSettings.ReplaceString(kOutputFile, string);
		if (tempMessage.FindInt32(kThreadPriority, &integer) == B_OK)
			sSettings.ReplaceInt32(kThreadPriority, integer);	
	}	
	
	return status;
}
Exemple #24
0
/** We share one global list for all BMediaFormats in the team - since the
 *	format data can change at any time, we have to update the list to ensure
 *	that we are working on the latest data set. The list is always sorted by
 *	description. The formats lock has to be held when you call this function.
 */
static status_t
update_media_formats()
{
	if (!sLock.IsLocked())
		return B_NOT_ALLOWED;

	// We want the add-ons to register themselves with the format manager, so
	// the list is up to date.
	AddOnManager::GetInstance()->RegisterAddOns();

	BMessage reply;
	FormatManager::GetInstance()->GetFormats(sLastFormatsUpdate, reply);

	// do we need an update at all?
	bool needUpdate;
	if (reply.FindBool("need_update", &needUpdate) < B_OK)
		return B_ERROR;
	if (!needUpdate)
		return B_OK;

	// update timestamp and check if the message is okay
	type_code code;
	int32 count;
	if (reply.FindInt64("timestamp", &sLastFormatsUpdate) < B_OK
		|| reply.GetInfo("formats", &code, &count) < B_OK)
		return B_ERROR;

	// overwrite already existing formats

	int32 index = 0;
	for (; index < sFormats.CountItems() && index < count; index++) {
		meta_format* item = sFormats.ItemAt(index);

		const meta_format* newItem;
		ssize_t size;
		if (reply.FindData("formats", MEDIA_META_FORMAT_TYPE, index,
				(const void**)&newItem, &size) == B_OK)
			*item = *newItem;
	}

	// allocate additional formats

	for (; index < count; index++) {
		const meta_format* newItem;
		ssize_t size;
		if (reply.FindData("formats", MEDIA_META_FORMAT_TYPE, index,
				(const void**)&newItem, &size) == B_OK)
			sFormats.AddItem(new meta_format(*newItem));
	}

	// remove no longer used formats

	while (count < sFormats.CountItems())
		delete sFormats.RemoveItemAt(count);

	return B_OK;
}
void
Renamer_Extension::AttachedToWindow()
{
	BMessage msg;
	ReadPreferences("ren_extension", msg);

	bool boolean;
	if (msg.FindBool("replace", &boolean) == B_OK)
		fReplaceOldCheckBox->SetValue(boolean);
	else
		fReplaceOldCheckBox->SetValue(B_CONTROL_OFF); // default

	if (msg.FindBool("upperlower", &boolean) == B_OK) {
		if (boolean)
			fLowerCase->SetValue(B_CONTROL_ON);
		else
			fUpperCase->SetValue(B_CONTROL_ON);
	} else
		fLowerCase->SetValue(B_CONTROL_ON);	// default
}
Exemple #26
0
void
MainWindow::LoadSettings(void)
{
	BFile file("/boot/home/config/settings/BeMines", B_READ_ONLY);
	if (file.InitCheck() != B_OK)
		return;

	BMessage settings;
	if (settings.Unflatten(&file) == B_OK)
	{
		BString s;
		if (settings.FindString("theme",&s) == B_OK)
		{
			gThemeName = s;
			gGameStyle->SetStyle(gThemeName.String());
		}

		int32 diff;
		if (settings.FindInt32("level",&diff) == B_OK)
			gDifficulty = diff;

		bool b;
		if (settings.FindBool("playsounds",&b) == B_OK)
			gPlaySounds = b;

		uint16 seconds;
		if (settings.FindInt16("begbest",(int16*)&seconds) == B_OK)
			gBestTimes[DIFFICULTY_BEGINNER].time = seconds;

		if (settings.FindInt16("intbest",(int16*)&seconds) == B_OK)
			gBestTimes[DIFFICULTY_INTERMEDIATE].time = seconds;

		if (settings.FindInt16("expbest",(int16*)&seconds) == B_OK)
			gBestTimes[DIFFICULTY_EXPERT].time = seconds;

		if (settings.FindString("begname",&s) == B_OK)
			gBestTimes[DIFFICULTY_BEGINNER].name = s;

		if (settings.FindString("intname",&s) == B_OK)
			gBestTimes[DIFFICULTY_INTERMEDIATE].name = s;

		if (settings.FindString("expname",&s) == B_OK)
			gBestTimes[DIFFICULTY_EXPERT].name = s;

		uint16 size;
		if (settings.FindInt16("customwidth",(int16*)&size) == B_OK)
			gCustomWidth = size;
		if (settings.FindInt16("customheight",(int16*)&size) == B_OK)
			gCustomHeight = size;
		if (settings.FindInt16("customcount",(int16*)&size) == B_OK)
			gCustomMines = size;

	}
}
Exemple #27
0
void
JsonToMessageTest::TestObjectB()
{
	BMessage message;
	bool boolValue;
	void *ptrValue; // this is how NULL is represented.

	// ----------------------
	BJson::Parse(JSON_SAMPLE_OBJECT_B_IN, message);
	// ----------------------

	CPPUNIT_ASSERT_EQUAL(B_OK, message.FindBool("testTrue", &boolValue));
	CPPUNIT_ASSERT_EQUAL(true, boolValue);

	CPPUNIT_ASSERT_EQUAL(B_OK, message.FindBool("testFalse", &boolValue));
	CPPUNIT_ASSERT_EQUAL(false, boolValue);

	CPPUNIT_ASSERT_EQUAL(B_OK, message.FindPointer("testNull", &ptrValue));
	CPPUNIT_ASSERT_EQUAL(0, (addr_t)ptrValue);
}
Exemple #28
0
void
FolderShaper::ReadSettings()
{
	status_t	status;
	BMessage	settings;
	status	=	settings.Unflatten(m_settings_file);
	if (status != B_OK)
		ErrorMessage("Unflatten()", status);
	
	BPoint loc;
	if (settings.FindPoint("winloc",&loc) == B_OK)	m_winloc = loc;
	
	bool a;
	int8 b;
	if (settings.FindBool("do_move", &a) == B_OK)			m_do_move = a;
	if (settings.FindInt8("do_open", &b) == B_OK)			m_do_open = b;
	if (settings.FindBool("do_clobber", &a) == B_OK)		m_do_clobber = a;
	if (settings.FindBool("do_keep_position", &a) == B_OK)	m_do_keep_position = a;
	if (settings.FindBool("do_clean_up", &a) == B_OK)		m_do_clean_up = a;
}
Exemple #29
0
void
NetworkPrefsView::UpdateNetworkData (BMessage & msg)
{
	// enable network controls
	fStartupBox->SetEnabled (true);
	fServerButton->SetEnabled (true);
	fTextView->MakeEditable (true);
	fLagCheckBox->SetEnabled (true);
	SetPrimaryServer("<N/A>");
	SetAlternateCount(0);

	bool startup (false),
			 lagcheck (true);
	if (msg.FindBool ("connectOnStartup", &startup) == B_OK)
		fStartupBox->SetValue ((startup) ? B_CONTROL_ON : B_CONTROL_OFF);
	else
		fStartupBox->SetValue (B_CONTROL_OFF);
	if (msg.FindBool ("lagCheck", &lagcheck) == B_OK)
		fLagCheckBox->SetValue ((lagcheck) ? B_CONTROL_ON : B_CONTROL_OFF);
	else
		fLagCheckBox->SetValue (B_CONTROL_OFF);

	const char *autoexec (NULL);
	if ((autoexec = msg.FindString ("autoexec")) != NULL)
		fTextView->SetText (autoexec);
	else
		fTextView->SetText ("");

	uint32 altCount(0);
	ssize_t size;
	const ServerData *data (NULL);
	for (int32 i = 0; msg.FindData("server", B_ANY_TYPE, i,
		reinterpret_cast<const void **>(&data), &size) == B_OK; i++)
	{
		if (data->state == 0)
			SetPrimaryServer(data->serverName);
		else if(data->state == 1)
			++altCount;
	}
	SetAlternateCount(altCount);
}
Exemple #30
0
bool
BDeskbar::HasItem(const char* name) const
{
	BMessage request(kMsgHasItem);
	request.AddString("name", name);

	BMessage reply;
	if (fMessenger->SendMessage(&request, &reply) == B_OK)
		return reply.FindBool("exists");

	return false;
}