示例#1
0
void
AutoMounter::_WriteSettings()
{
	if (fPrefsFile.InitCheck() != B_OK)
		return;

	BMessage message('stng');
	_GetSettings(&message);

	ssize_t settingsSize = message.FlattenedSize();

	char *buffer = new(std::nothrow) char[settingsSize];
	if (buffer == NULL) {
		PRINT(("error writing automounter settings, out of memory\n"));
		return;
	}

	status_t result = message.Flatten(buffer, settingsSize);

	fPrefsFile.Seek(0, SEEK_SET);
	result = fPrefsFile.Write(buffer, (size_t)settingsSize);
	if (result != settingsSize)
		PRINT(("error writing automounter settings, %s\n", strerror(result)));

	delete [] buffer;
}
示例#2
0
void
PowerStatusReplicant::_SaveSettings()
{
	BFile file;
	if (_GetSettings(file, B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE) != B_OK)
		return;

	BMessage settings('pwst');
	ToMessage(&settings);

	ssize_t size = 0;
	settings.Flatten(&file, &size);
}
示例#3
0
void
PowerStatusReplicant::_LoadSettings()
{
	fShowLabel = false;

	BFile file;
	if (_GetSettings(file, B_READ_ONLY) != B_OK)
		return;

	BMessage settings;
	if (settings.Unflatten(&file) < B_OK)
		return;

	FromMessage(&settings);
}
示例#4
0
status_t
KeymapWindow::_LoadSettings(BRect& windowFrame, BString& keyboardLayout)
{
	BScreen screen(this);

	windowFrame.Set(-1, -1, 799, 329);
	// See if we can use a larger default size
	if (screen.Frame().Width() > 1200) {
		windowFrame.right = 899;
		windowFrame.bottom = 349;
	}

	keyboardLayout = "";

	BFile file;
	status_t status = _GetSettings(file, B_READ_ONLY);
	if (status == B_OK) {
		BMessage settings;
		status = settings.Unflatten(&file);
		if (status == B_OK) {
			BRect frame;
			if (settings.FindRect("window frame", &frame) == B_OK)
				windowFrame = frame;

			settings.FindString("keyboard layout", &keyboardLayout);
		}
	}

	if (!screen.Frame().Contains(windowFrame)) {
		// Make sure the window is not larger than the screen
		if (windowFrame.Width() > screen.Frame().Width())
			windowFrame.right = windowFrame.left + screen.Frame().Width();
		if (windowFrame.Height() > screen.Frame().Height())
			windowFrame.bottom = windowFrame.top + screen.Frame().Height();

		// Make sure the window is on screen (and center if it isn't)
		if (windowFrame.left < screen.Frame().left
			|| windowFrame.right > screen.Frame().right
			|| windowFrame.top < screen.Frame().top
			|| windowFrame.bottom > screen.Frame().bottom) {
			windowFrame.OffsetTo(BAlert::AlertPosition(windowFrame.Width(),
				windowFrame.Height()));
		}
	}

	return status;
}
示例#5
0
status_t
KeymapWindow::_SaveSettings()
{
	BFile file;
	status_t status
		= _GetSettings(file, B_WRITE_ONLY | B_ERASE_FILE | B_CREATE_FILE);
	if (status != B_OK)
		return status;

	BMessage settings('keym');
	settings.AddRect("window frame", Frame());

	BPath path = _GetMarkedKeyboardLayoutPath(fLayoutMenu);
	if (path.InitCheck() == B_OK)
		settings.AddString("keyboard layout", path.Path());

	return settings.Flatten(&file);
}
示例#6
0
status_t
KeymapWindow::_SaveSettings() const
{
	BFile file;
	status_t status
		= _GetSettings(file, B_WRITE_ONLY | B_ERASE_FILE | B_CREATE_FILE);
	if (status != B_OK)
		return status;

	BMessage settings('keym');
	settings.AddRect("window frame", Frame());

	BMenuItem* item = fLayoutMenu->FindMarked();
	entry_ref ref;
	if (item != NULL && item->Message()->FindRef("ref", &ref) == B_OK) {
		BPath path(&ref);
		if (path.InitCheck() == B_OK)
			settings.AddString("keyboard layout", path.Path());
	}

	return settings.Flatten(&file);
}
 bool 
 AntiSpamConfiguration::GetUseGreyListing() 
 {
    return _GetSettings()->GetBool(PROPERTY_USEGREYLISTING);
 }
 void
 AntiSpamConfiguration::SetUseGreyListing(bool newVal)
 {
    _GetSettings()->SetBool(PROPERTY_USEGREYLISTING, newVal);
 }
 int
 AntiSpamConfiguration::GetCheckHostInHeloScore() 
 {
    return _GetSettings()->GetLong(PROPERTY_AS_CHECKHOSTINHELOSCORE);
 }
 void
 AntiSpamConfiguration::SetCheckHostInHeloScore(int newVal)
 {
    _GetSettings()->SetLong(PROPERTY_AS_CHECKHOSTINHELOSCORE, newVal);
 }
 void 
 AntiSpamConfiguration::SetAntiSpamMaxSizeKB(int newVal)
 {
    _GetSettings()->SetLong(PROPERTY_AS_MAX_SIZE, newVal);
 }
示例#12
0
void
AutoMounter::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case kMountVolume:
			_MountVolume(message);
			break;

		case kUnmountVolume:
			_UnmountAndEjectVolume(message);
			break;

		case kSetAutomounterParams:
		{
			bool rescanNow = false;
			message->FindBool("rescanNow", &rescanNow);

			_UpdateSettingsFromMessage(message);
			_GetSettings(&fSettings);
			_WriteSettings();

			if (rescanNow)
				_MountVolumes(fNormalMode, fRemovableMode);
			break;
		}

		case kGetAutomounterParams:
		{
			BMessage reply;
			_GetSettings(&reply);
			message->SendReply(&reply);
			break;
		}

		case kMountAllNow:
			_MountVolumes(kAllVolumes, kAllVolumes);
			break;

		case B_DEVICE_UPDATE:
			int32 event;
			if (message->FindInt32("event", &event) != B_OK
				|| (event != B_DEVICE_MEDIA_CHANGED
					&& event != B_DEVICE_ADDED))
				break;

			partition_id deviceID;
			if (message->FindInt32("id", &deviceID) != B_OK)
				break;

			_MountVolumes(kNoVolumes, fRemovableMode, false, deviceID);
			break;

#if 0
		case B_NODE_MONITOR:
		{
			int32 opcode;
			if (message->FindInt32("opcode", &opcode) != B_OK)
				break;

			switch (opcode) {
				//	The name of a mount point has changed
				case B_ENTRY_MOVED: {
					WRITELOG(("*** Received Mount Point Renamed Notification"));

					const char *newName;
					if (message->FindString("name", &newName) != B_OK) {
						WRITELOG(("ERROR: Couldn't find name field in update "
							"message"));
						PRINT_OBJECT(*message);
						break ;
					}

					//
					// When the node monitor reports a move, it gives the
					// parent device and inode that moved.  The problem is
					// that  the inode is the inode of root *in* the filesystem,
					// which is generally always the same number for every
					// filesystem of a type.
					//
					// What we'd really like is the device that the moved
					// volume is mounted on.  Find this by using the
					// *new* name and directory, and then stat()ing that to
					// find the device.
					//
					dev_t parentDevice;
					if (message->FindInt32("device", &parentDevice) != B_OK) {
						WRITELOG(("ERROR: Couldn't find 'device' field in "
							"update message"));
						PRINT_OBJECT(*message);
						break;
					}

					ino_t toDirectory;
					if (message->FindInt64("to directory", &toDirectory)
						!= B_OK) {
						WRITELOG(("ERROR: Couldn't find 'to directory' field "
							"in update message"));
						PRINT_OBJECT(*message);
						break;
					}

					entry_ref root_entry(parentDevice, toDirectory, newName);

					BNode entryNode(&root_entry);
					if (entryNode.InitCheck() != B_OK) {
						WRITELOG(("ERROR: Couldn't create mount point entry "
							"node: %s/n", strerror(entryNode.InitCheck())));
						break;
					}

					node_ref mountPointNode;
					if (entryNode.GetNodeRef(&mountPointNode) != B_OK) {
						WRITELOG(("ERROR: Couldn't get node ref for new mount "
							"point"));
						break;
					}

					WRITELOG(("Attempt to rename device %li to %s",
						mountPointNode.device, newName));

					Partition *partition = FindPartition(mountPointNode.device);
					if (partition != NULL) {
						WRITELOG(("Found device, changing name."));

						BVolume mountVolume(partition->VolumeDeviceID());
						BDirectory mountDir;
						mountVolume.GetRootDirectory(&mountDir);
						BPath dirPath(&mountDir, 0);

						partition->SetMountedAt(dirPath.Path());
						partition->SetVolumeName(newName);
						break;
					} else {
						WRITELOG(("ERROR: Device %li does not appear to be "
							"present", mountPointNode.device));
					}
				}
			}
			break;
		}
#endif

		default:
			BLooper::MessageReceived(message);
			break;
	}
}
 bool 
 AntiSpamConfiguration::GetBypassGreyListingOnMailFromMX()
 {
    return _GetSettings()->GetBool(PROPERTY_BYPASS_GREYLISTING_ON_MAILFROMMX  );
 }
 void
 AntiSpamConfiguration::SetBypassGreyListingOnSPFSuccess(bool newValue)
 {
    _GetSettings()->SetBool(PROPERTY_BYPASS_GREYLISTING_ON_SPFSUCCESS , newValue);
 }
 bool 
 AntiSpamConfiguration::GetBypassGreyListingOnSPFSuccess()
 {
    return _GetSettings()->GetBool(PROPERTY_BYPASS_GREYLISTING_ON_SPFSUCCESS  );
 }
 void
 AntiSpamConfiguration::SetDKIMVerificationFailureScore(int newValue)
 {
    _GetSettings()->SetLong(PROPERTY_AS_DKIM_VERIFICATION_FAILURE_SCORE, newValue);
 }
 int
 AntiSpamConfiguration::GetDKIMVerificationFailureScore()
 {
    return _GetSettings()->GetLong(PROPERTY_AS_DKIM_VERIFICATION_FAILURE_SCORE);
 }
 void
 AntiSpamConfiguration::SetDKIMVerificationEnabled(bool newValue)
 {
    _GetSettings()->SetBool(PROPERTY_AS_DKIM_VERIFICATION_ENABLE , newValue);
 }
 bool 
 AntiSpamConfiguration::GetDKIMVerificationEnabled()
 {
    return _GetSettings()->GetBool(PROPERTY_AS_DKIM_VERIFICATION_ENABLE  );
 }
 void 
 AntiSpamConfiguration::SetGreyListingInitialDelay(int lNewValue)
 {
    _GetSettings()->SetLong(PROPERTY_GL_INITIALDELAY, lNewValue);
 }
 int
 AntiSpamConfiguration::GetGreyListingInitialDelete()
 {
    return _GetSettings()->GetLong(PROPERTY_GL_INITIALDELETE);
 }
 int 
 AntiSpamConfiguration::GetSpamAssassinPort() 
 {
    return _GetSettings()->GetLong(PROPERTY_SPAMASSASSIN_PORT);
 }
 void
 AntiSpamConfiguration::SetSpamAssassinPort(int newVal)
 {
    _GetSettings()->SetLong(PROPERTY_SPAMASSASSIN_PORT, newVal);
 }
 String 
 AntiSpamConfiguration::GetSpamAssassinHost() 
 {
    return _GetSettings()->GetString(PROPERTY_SPAMASSASSIN_HOST);
 }
 void
 AntiSpamConfiguration::SetBypassGreyListingOnMailFromMX(bool newValue)
 {
    _GetSettings()->SetBool(PROPERTY_BYPASS_GREYLISTING_ON_MAILFROMMX , newValue);
 }
 int 
 AntiSpamConfiguration::GetAntiSpamMaxSizeKB()
 {
    return _GetSettings()->GetLong(PROPERTY_AS_MAX_SIZE);
 }
 void
 AntiSpamConfiguration::SetCheckHostInHelo(bool newVal)
 {
    _GetSettings()->SetBool(PROPERTY_AS_CHECKHOSTINHELO, newVal);
 }
 bool 
 AntiSpamConfiguration::GetCheckHostInHelo() 
 {
    return _GetSettings()->GetBool(PROPERTY_AS_CHECKHOSTINHELO);
 }
示例#29
0
JoyWin::JoyWin(BRect frame, const char *title)
	: BWindow(frame, title, B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
		B_NOT_ZOOMABLE), fSystemUsedSelect(false),
		fJoystick(new BJoystick)
{
	fProbeButton = new BButton(BRect(15.00, 260.00, 115.00, 285.00),
		"ProbeButton", "Probe", new BMessage(PROBE));

	fCalibrateButton = new BButton(BRect(270.00, 260.00, 370.00, 285.00),
		"CalibrateButton", "Calibrate", new BMessage(CALIBRATE));

	fGamePortL = new BListView(BRect(15.00, 30.00, 145.00, 250.00),
		"gamePort");
	fGamePortL->SetSelectionMessage(new BMessage(PORT_SELECTED));
	fGamePortL->SetInvocationMessage(new BMessage(PORT_INVOKE));

	fConControllerL = new BListView(BRect(175.00,30.00,370.00,250.00),
		"conController");
	fConControllerL->SetSelectionMessage(new BMessage(JOY_SELECTED));
	fConControllerL->SetInvocationMessage(new BMessage(JOY_INVOKE));

	fGamePortS = new BStringView(BRect(15, 5, 160, 25), "gpString",
		"Game port");
	fGamePortS->SetFont(be_bold_font);
	fConControllerS = new BStringView(BRect(170, 5, 330, 25), "ccString",
		"Connected controller");

	fConControllerS->SetFont(be_bold_font);

	fCheckbox = new BCheckBox(BRect(131.00, 260.00, 227.00, 280.00),
		"Disabled", "Disabled", new BMessage(DISABLEPORT));
	BBox *box = new BBox( Bounds(),"box", B_FOLLOW_ALL,
		B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE,
		B_PLAIN_BORDER);

	box->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	// Add listViews with their scrolls
	box->AddChild(new BScrollView("PortScroll", fGamePortL,
		B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, B_WILL_DRAW, false, true));

	box->AddChild(new BScrollView("ConScroll", fConControllerL, B_FOLLOW_ALL,
		B_WILL_DRAW, false, true));

	// Adding object
	box->AddChild(fCheckbox);
	box->AddChild(fGamePortS);
	box->AddChild(fConControllerS);
	box->AddChild(fProbeButton);
	box->AddChild(fCalibrateButton);
	AddChild(box);

	SetSizeLimits(400, 600, Bounds().Height(), Bounds().Height());

	/* Add all the devices */
	int32 nr = fJoystick->CountDevices();
	for (int32 i = 0; i < nr;i++) {
		//BString str(path.Path());
		char buf[B_OS_NAME_LENGTH];
		fJoystick->GetDeviceName(i, buf, B_OS_NAME_LENGTH);
		fGamePortL->AddItem(new PortItem(buf));
	}
	fGamePortL->Select(0);

	/* Add the joysticks specifications */
	_AddToList(fConControllerL, JOY_SELECTED, JOYSTICKFILEPATH);

	_GetSettings();
}
 void
 AntiSpamConfiguration::SetSpamAssassinHost(const String &newVal)
 {
    _GetSettings()->SetString(PROPERTY_SPAMASSASSIN_HOST, newVal);
 }