コード例 #1
0
ファイル: NetFSServer.cpp プロジェクト: luciang/haiku
// _GetServerInfo
status_t
NetFSServer::_GetServerInfo(ServerInfo& serverInfo)
{
	// set the server name and the connection method
	char hostName[1024];
	if (gethostname(hostName, sizeof(hostName)) < 0) {
		ERROR("NetFSServer::_GetServerInfo(): ERROR: Failed to get host "
			"name.");
		return B_ERROR;
	}
	status_t error = serverInfo.SetServerName(hostName);
// TODO: Set the actually used connection method!
	if (error == B_OK)
		error = serverInfo.SetConnectionMethod("insecure");
	if (error != B_OK)
		return error;

	// get the shares from the security context
	BMessage shares;
	error = fSecurityContext->GetShares(&shares);
	if (error != B_OK)
		return error;

	// add the shares
	const char* shareName;
	for (int32 i = 0; shares.FindString("shares", i, &shareName) == B_OK; i++) {
		error = serverInfo.AddShare(shareName);
		if (error != B_OK)
			return error;
	}
	return B_OK;
}