Esempio n. 1
0
// ClearNodePermissions
void
SecurityContext::ClearNodePermissions(const node_ref& ref, User* user)
{
	ContextLocker _(this);
	HashString path;
	status_t error = _AddNodePath(ref, &path);
	if (error != B_OK)
		return;

	if (user) {
		fPermissions->Remove(UserPath(path.GetString(), user));
	} else {
		for (UserMap::Iterator it = fUsers->GetIterator(); it.HasNext();)
			fPermissions->Remove(UserPath(path.GetString(), it.Next().value));
	}
}
Esempio n. 2
0
// SetTo
status_t
ExtendedServerInfo::SetTo(ServerInfo* serverInfo)
{
	if (!serverInfo)
		return B_BAD_VALUE;
	// set name and connection method
	const char* name = serverInfo->GetServerName();
	HashString addressString;
	if (!name || strlen(name) == 0) {
		status_t error = fAddress.GetString(&addressString, false);
		if (error != B_OK)
			return error;
		name = addressString.GetString();
	}
	if (!fServerName.SetTo(name)
		|| !fConnectionMethod.SetTo(serverInfo->GetConnectionMethod())) {
		return B_NO_MEMORY;
	}
	// add the shares
	int32 shareCount = serverInfo->CountShares();
	for (int32 i = 0; i < shareCount; i++) {
		const ShareInfo& shareInfo = serverInfo->ShareInfoAt(i);
		status_t error = _AddShare(&shareInfo);
		if (error != B_OK)
			return error;
	}
	return B_OK;
}
Esempio n. 3
0
// GetNodePermissions
Permissions
SecurityContext::GetNodePermissions(const node_ref& ref, User* user)
{
	if (!user)
		return Permissions();

	ContextLocker _(this);
	HashString path;
	status_t error = _AddNodePath(ref, &path);
	if (error != B_OK)
		return Permissions();

	return fPermissions->Get(UserPath(path.GetString(), user));
}
Esempio n. 4
0
// SetNodePermissions
status_t
SecurityContext::SetNodePermissions(const node_ref& ref, User* user,
	Permissions permissions)
{
	if (!user)
		return B_BAD_VALUE;

	ContextLocker _(this);
	// check, whether we know the user
	if (fUsers->Get(user->GetName()) != user)
		return B_BAD_VALUE;

	HashString path;
	status_t error = _AddNodePath(ref, &path);
	if (error != B_OK)
		return error;
	return fPermissions->Put(UserPath(path.GetString(), user), permissions);
}
Esempio n. 5
0
//---------------------------------------
// Sprite
//---------------------------------------
Sprite::Sprite( SpriteAnimationSet& animation, const HashString& initialAnimName )
	: mAnimationSet( animation )
	, DrawColor( Color::WHITE)
	, RelativeToCamera( true )
	, FixedSize( false )
	, Scale( Vec2f::ONE )
{
	HashMap< SpriteAnimation >::const_iterator anim = animation.Animations.find( initialAnimName );
	if ( anim != animation.Animations.end() )
	{
		mSprAnimInfo.CurrentAnimationName = anim->first;
	}
	else
	{
		WarnInfo( "Sprite() initial animation not found: %s\n", initialAnimName.GetString().c_str() );
		if ( !mAnimationSet.Animations.empty() )
		{
			mSprAnimInfo.CurrentAnimationName = mAnimationSet.Animations.begin()->first;
		}
	}
	mSprAnimInfo.CurrentAnimationFrame = 0;
	mSprAnimInfo.CurrentAnimationFrameTime = 0.0f;
}
Esempio n. 6
0
// Init
status_t
ServerConnection::Init(vnode_id connectionBrokenTarget)
{
	if (!fServerInfo)
		RETURN_ERROR(B_BAD_VALUE);

	// create a connection broken event
	fConnectionBrokenEvent
		= new(std::nothrow) ConnectionBrokenEvent(connectionBrokenTarget);
	if (!fConnectionBrokenEvent)
		return B_NO_MEMORY;

	// get the server address
	const char* connectionMethod = fServerInfo->GetConnectionMethod();
	HashString server;
	status_t error = fServerInfo->GetAddress().GetString(&server, false);
	if (error != B_OK)
		RETURN_ERROR(error);

	// create the volume map
	fVolumes = new(std::nothrow) VolumeMap;
	if (!fVolumes)
		RETURN_ERROR(B_NO_MEMORY);
	error = fVolumes->InitCheck();
	if (error != B_OK)
		RETURN_ERROR(error);

	// establish the connection
	Connection* connection;
	ConnectionFactory factory;
	error = factory.CreateConnection(connectionMethod, server.GetString(),
		&connection);
	if (error != B_OK)
		RETURN_ERROR(error);

	// create a request connection
	fConnection = new(std::nothrow) RequestConnection(connection, this);
	if (!fConnection) {
		delete connection;
		RETURN_ERROR(B_NO_MEMORY);
	}
	error = fConnection->Init();
	if (error != B_OK)
		return error;

	// send an `init connection request'

	// prepare the request
	InitConnectionRequest request;
	request.bigEndian = B_HOST_IS_BENDIAN;

	// send the request
	Request* _reply;
	error = fConnection->SendRequest(&request, &_reply);
	if (error != B_OK)
		return error;
	ObjectDeleter<Request> replyDeleter(_reply);

	// everything OK?
	InitConnectionReply* reply = dynamic_cast<InitConnectionReply*>(_reply);
	if (!reply)
		return B_BAD_DATA;
	if (reply->error != B_OK)
		return reply->error;

	fConnected = true;
	return B_OK;
}