Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change how save file actually works #120

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 102 additions & 22 deletions protocol/cpp/include/solarxr_protocol/generated/all_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,9 @@ struct ClearMountingResetRequestBuilder;
struct SaveFileNotification;
struct SaveFileNotificationBuilder;

struct SaveFileRequest;
struct SaveFileRequestBuilder;

} // namespace rpc

namespace pub_sub {
Expand Down Expand Up @@ -8171,16 +8174,12 @@ inline flatbuffers::Offset<ClearMountingResetRequest> CreateClearMountingResetRe
struct SaveFileNotification FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
typedef SaveFileNotificationBuilder Builder;
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
VT_DATA = 4,
VT_MIME_TYPE = 6,
VT_FILE_EXTENSION = 8,
VT_EXPECTED_DIR = 10,
VT_EXPECTED_FILENAME = 12
VT_MIME_TYPE = 4,
VT_FILE_EXTENSION = 6,
VT_EXPECTED_DIR = 8,
VT_EXPECTED_FILENAME = 10,
VT_ID = 12
};
/// Binary data of the file
const flatbuffers::Vector<uint8_t> *data() const {
return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_DATA);
}
/// MIME type of file if one exists, use `file_extension` otherwise
const flatbuffers::String *mime_type() const {
return GetPointer<const flatbuffers::String *>(VT_MIME_TYPE);
Expand All @@ -8197,17 +8196,20 @@ struct SaveFileNotification FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table
const flatbuffers::String *expected_filename() const {
return GetPointer<const flatbuffers::String *>(VT_EXPECTED_FILENAME);
}
/// ID of the SaveFile, needs to be returned by the SaveFileRequest
uint32_t id() const {
return GetField<uint32_t>(VT_ID, 0);
}
bool Verify(flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) &&
VerifyOffset(verifier, VT_DATA) &&
verifier.VerifyVector(data()) &&
VerifyOffset(verifier, VT_MIME_TYPE) &&
verifier.VerifyString(mime_type()) &&
VerifyOffset(verifier, VT_FILE_EXTENSION) &&
verifier.VerifyString(file_extension()) &&
VerifyField<uint8_t>(verifier, VT_EXPECTED_DIR, 1) &&
VerifyOffset(verifier, VT_EXPECTED_FILENAME) &&
verifier.VerifyString(expected_filename()) &&
VerifyField<uint32_t>(verifier, VT_ID, 4) &&
verifier.EndTable();
}
};
Expand All @@ -8216,9 +8218,6 @@ struct SaveFileNotificationBuilder {
typedef SaveFileNotification Table;
flatbuffers::FlatBufferBuilder &fbb_;
flatbuffers::uoffset_t start_;
void add_data(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> data) {
fbb_.AddOffset(SaveFileNotification::VT_DATA, data);
}
void add_mime_type(flatbuffers::Offset<flatbuffers::String> mime_type) {
fbb_.AddOffset(SaveFileNotification::VT_MIME_TYPE, mime_type);
}
Expand All @@ -8231,6 +8230,9 @@ struct SaveFileNotificationBuilder {
void add_expected_filename(flatbuffers::Offset<flatbuffers::String> expected_filename) {
fbb_.AddOffset(SaveFileNotification::VT_EXPECTED_FILENAME, expected_filename);
}
void add_id(uint32_t id) {
fbb_.AddElement<uint32_t>(SaveFileNotification::VT_ID, id, 0);
}
explicit SaveFileNotificationBuilder(flatbuffers::FlatBufferBuilder &_fbb)
: fbb_(_fbb) {
start_ = fbb_.StartTable();
Expand All @@ -8244,38 +8246,116 @@ struct SaveFileNotificationBuilder {

inline flatbuffers::Offset<SaveFileNotification> CreateSaveFileNotification(
flatbuffers::FlatBufferBuilder &_fbb,
flatbuffers::Offset<flatbuffers::Vector<uint8_t>> data = 0,
flatbuffers::Offset<flatbuffers::String> mime_type = 0,
flatbuffers::Offset<flatbuffers::String> file_extension = 0,
flatbuffers::Optional<solarxr_protocol::rpc::ComputerDirectory> expected_dir = flatbuffers::nullopt,
flatbuffers::Offset<flatbuffers::String> expected_filename = 0) {
flatbuffers::Offset<flatbuffers::String> expected_filename = 0,
uint32_t id = 0) {
SaveFileNotificationBuilder builder_(_fbb);
builder_.add_id(id);
builder_.add_expected_filename(expected_filename);
builder_.add_file_extension(file_extension);
builder_.add_mime_type(mime_type);
builder_.add_data(data);
if(expected_dir) { builder_.add_expected_dir(*expected_dir); }
return builder_.Finish();
}

inline flatbuffers::Offset<SaveFileNotification> CreateSaveFileNotificationDirect(
flatbuffers::FlatBufferBuilder &_fbb,
const std::vector<uint8_t> *data = nullptr,
const char *mime_type = nullptr,
const char *file_extension = nullptr,
flatbuffers::Optional<solarxr_protocol::rpc::ComputerDirectory> expected_dir = flatbuffers::nullopt,
const char *expected_filename = nullptr) {
auto data__ = data ? _fbb.CreateVector<uint8_t>(*data) : 0;
const char *expected_filename = nullptr,
uint32_t id = 0) {
auto mime_type__ = mime_type ? _fbb.CreateString(mime_type) : 0;
auto file_extension__ = file_extension ? _fbb.CreateString(file_extension) : 0;
auto expected_filename__ = expected_filename ? _fbb.CreateString(expected_filename) : 0;
return solarxr_protocol::rpc::CreateSaveFileNotification(
_fbb,
data__,
mime_type__,
file_extension__,
expected_dir,
expected_filename__);
expected_filename__,
id);
}

/// Response of the SaveFileNotification after the user interacts with the file save request
struct SaveFileRequest FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
typedef SaveFileRequestBuilder Builder;
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
VT_ID = 4,
VT_PATH = 6,
VT_CANCELED = 8
};
/// ID of the SaveFile, given by SaveFileNotification
uint32_t id() const {
return GetField<uint32_t>(VT_ID, 0);
}
/// Where to save the file, if null, server will choose where to save it
const flatbuffers::String *path() const {
return GetPointer<const flatbuffers::String *>(VT_PATH);
}
/// Iff false, the file save will be canceled
flatbuffers::Optional<bool> canceled() const {
return GetOptional<uint8_t, bool>(VT_CANCELED);
}
bool Verify(flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) &&
VerifyField<uint32_t>(verifier, VT_ID, 4) &&
VerifyOffset(verifier, VT_PATH) &&
verifier.VerifyString(path()) &&
VerifyField<uint8_t>(verifier, VT_CANCELED, 1) &&
verifier.EndTable();
}
};

struct SaveFileRequestBuilder {
typedef SaveFileRequest Table;
flatbuffers::FlatBufferBuilder &fbb_;
flatbuffers::uoffset_t start_;
void add_id(uint32_t id) {
fbb_.AddElement<uint32_t>(SaveFileRequest::VT_ID, id, 0);
}
void add_path(flatbuffers::Offset<flatbuffers::String> path) {
fbb_.AddOffset(SaveFileRequest::VT_PATH, path);
}
void add_canceled(bool canceled) {
fbb_.AddElement<uint8_t>(SaveFileRequest::VT_CANCELED, static_cast<uint8_t>(canceled));
}
explicit SaveFileRequestBuilder(flatbuffers::FlatBufferBuilder &_fbb)
: fbb_(_fbb) {
start_ = fbb_.StartTable();
}
flatbuffers::Offset<SaveFileRequest> Finish() {
const auto end = fbb_.EndTable(start_);
auto o = flatbuffers::Offset<SaveFileRequest>(end);
return o;
}
};

inline flatbuffers::Offset<SaveFileRequest> CreateSaveFileRequest(
flatbuffers::FlatBufferBuilder &_fbb,
uint32_t id = 0,
flatbuffers::Offset<flatbuffers::String> path = 0,
flatbuffers::Optional<bool> canceled = flatbuffers::nullopt) {
SaveFileRequestBuilder builder_(_fbb);
builder_.add_path(path);
builder_.add_id(id);
if(canceled) { builder_.add_canceled(*canceled); }
return builder_.Finish();
}

inline flatbuffers::Offset<SaveFileRequest> CreateSaveFileRequestDirect(
flatbuffers::FlatBufferBuilder &_fbb,
uint32_t id = 0,
const char *path = nullptr,
flatbuffers::Optional<bool> canceled = flatbuffers::nullopt) {
auto path__ = path ? _fbb.CreateString(path) : 0;
return solarxr_protocol::rpc::CreateSaveFileRequest(
_fbb,
id,
path__,
canceled);
}

} // namespace rpc
Expand Down
70 changes: 27 additions & 43 deletions protocol/java/src/solarxr_protocol/rpc/SaveFileNotification.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,63 +18,55 @@ public final class SaveFileNotification extends Table {
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
public SaveFileNotification __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }

/**
* Binary data of the file
*/
public int data(int j) { int o = __offset(4); return o != 0 ? bb.get(__vector(o) + j * 1) & 0xFF : 0; }
public int dataLength() { int o = __offset(4); return o != 0 ? __vector_len(o) : 0; }
public ByteVector dataVector() { return dataVector(new ByteVector()); }
public ByteVector dataVector(ByteVector obj) { int o = __offset(4); return o != 0 ? obj.__assign(__vector(o), bb) : null; }
public ByteBuffer dataAsByteBuffer() { return __vector_as_bytebuffer(4, 1); }
public ByteBuffer dataInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); }
/**
* MIME type of file if one exists, use `file_extension` otherwise
*/
public String mimeType() { int o = __offset(6); return o != 0 ? __string(o + bb_pos) : null; }
public ByteBuffer mimeTypeAsByteBuffer() { return __vector_as_bytebuffer(6, 1); }
public ByteBuffer mimeTypeInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 6, 1); }
public String mimeType() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; }
public ByteBuffer mimeTypeAsByteBuffer() { return __vector_as_bytebuffer(4, 1); }
public ByteBuffer mimeTypeInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); }
/**
* Use MIME type preferably if one exists
*/
public String fileExtension() { int o = __offset(8); return o != 0 ? __string(o + bb_pos) : null; }
public ByteBuffer fileExtensionAsByteBuffer() { return __vector_as_bytebuffer(8, 1); }
public ByteBuffer fileExtensionInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 8, 1); }
public String fileExtension() { int o = __offset(6); return o != 0 ? __string(o + bb_pos) : null; }
public ByteBuffer fileExtensionAsByteBuffer() { return __vector_as_bytebuffer(6, 1); }
public ByteBuffer fileExtensionInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 6, 1); }
/**
* Directory recommended to save the file on
*/
public boolean hasExpectedDir() { return 0 != __offset(10); }
public int expectedDir() { int o = __offset(10); return o != 0 ? bb.get(o + bb_pos) & 0xFF : 0; }
public boolean hasExpectedDir() { return 0 != __offset(8); }
public int expectedDir() { int o = __offset(8); return o != 0 ? bb.get(o + bb_pos) & 0xFF : 0; }
/**
* Recommended filename
*/
public String expectedFilename() { int o = __offset(12); return o != 0 ? __string(o + bb_pos) : null; }
public ByteBuffer expectedFilenameAsByteBuffer() { return __vector_as_bytebuffer(12, 1); }
public ByteBuffer expectedFilenameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 12, 1); }
public String expectedFilename() { int o = __offset(10); return o != 0 ? __string(o + bb_pos) : null; }
public ByteBuffer expectedFilenameAsByteBuffer() { return __vector_as_bytebuffer(10, 1); }
public ByteBuffer expectedFilenameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 10, 1); }
/**
* ID of the SaveFile, needs to be returned by the SaveFileRequest
*/
public long id() { int o = __offset(12); return o != 0 ? (long)bb.getInt(o + bb_pos) & 0xFFFFFFFFL : 0L; }

public static int createSaveFileNotification(FlatBufferBuilder builder,
int dataOffset,
int mimeTypeOffset,
int fileExtensionOffset,
int expectedDir,
int expectedFilenameOffset) {
int expectedFilenameOffset,
long id) {
builder.startTable(5);
SaveFileNotification.addId(builder, id);
SaveFileNotification.addExpectedFilename(builder, expectedFilenameOffset);
SaveFileNotification.addFileExtension(builder, fileExtensionOffset);
SaveFileNotification.addMimeType(builder, mimeTypeOffset);
SaveFileNotification.addData(builder, dataOffset);
SaveFileNotification.addExpectedDir(builder, expectedDir);
return SaveFileNotification.endSaveFileNotification(builder);
}

public static void startSaveFileNotification(FlatBufferBuilder builder) { builder.startTable(5); }
public static void addData(FlatBufferBuilder builder, int dataOffset) { builder.addOffset(0, dataOffset, 0); }
public static int createDataVector(FlatBufferBuilder builder, byte[] data) { return builder.createByteVector(data); }
public static int createDataVector(FlatBufferBuilder builder, ByteBuffer data) { return builder.createByteVector(data); }
public static void startDataVector(FlatBufferBuilder builder, int numElems) { builder.startVector(1, numElems, 1); }
public static void addMimeType(FlatBufferBuilder builder, int mimeTypeOffset) { builder.addOffset(1, mimeTypeOffset, 0); }
public static void addFileExtension(FlatBufferBuilder builder, int fileExtensionOffset) { builder.addOffset(2, fileExtensionOffset, 0); }
public static void addExpectedDir(FlatBufferBuilder builder, int expectedDir) { builder.addByte(3, (byte) expectedDir, (byte) 0); }
public static void addExpectedFilename(FlatBufferBuilder builder, int expectedFilenameOffset) { builder.addOffset(4, expectedFilenameOffset, 0); }
public static void addMimeType(FlatBufferBuilder builder, int mimeTypeOffset) { builder.addOffset(0, mimeTypeOffset, 0); }
public static void addFileExtension(FlatBufferBuilder builder, int fileExtensionOffset) { builder.addOffset(1, fileExtensionOffset, 0); }
public static void addExpectedDir(FlatBufferBuilder builder, int expectedDir) { builder.addByte(2, (byte) expectedDir, (byte) 0); }
public static void addExpectedFilename(FlatBufferBuilder builder, int expectedFilenameOffset) { builder.addOffset(3, expectedFilenameOffset, 0); }
public static void addId(FlatBufferBuilder builder, long id) { builder.addInt(4, (int) id, (int) 0L); }
public static int endSaveFileNotification(FlatBufferBuilder builder) {
int o = builder.endTable();
return o;
Expand All @@ -92,9 +84,6 @@ public SaveFileNotificationT unpack() {
return _o;
}
public void unpackTo(SaveFileNotificationT _o) {
int[] _oData = new int[dataLength()];
for (int _j = 0; _j < dataLength(); ++_j) {_oData[_j] = data(_j);}
_o.setData(_oData);
String _oMimeType = mimeType();
_o.setMimeType(_oMimeType);
String _oFileExtension = fileExtension();
Expand All @@ -103,26 +92,21 @@ public void unpackTo(SaveFileNotificationT _o) {
_o.setExpectedDir(_oExpectedDir);
String _oExpectedFilename = expectedFilename();
_o.setExpectedFilename(_oExpectedFilename);
long _oId = id();
_o.setId(_oId);
}
public static int pack(FlatBufferBuilder builder, SaveFileNotificationT _o) {
if (_o == null) return 0;
int _data = 0;
if (_o.getData() != null) {
byte[] __data = new byte[_o.getData().length];
int _j = 0;
for (int _e : _o.getData()) { __data[_j] = (byte) _e; _j++;}
_data = createDataVector(builder, __data);
}
int _mimeType = _o.getMimeType() == null ? 0 : builder.createString(_o.getMimeType());
int _fileExtension = _o.getFileExtension() == null ? 0 : builder.createString(_o.getFileExtension());
int _expectedFilename = _o.getExpectedFilename() == null ? 0 : builder.createString(_o.getExpectedFilename());
return createSaveFileNotification(
builder,
_data,
_mimeType,
_fileExtension,
_o.getExpectedDir(),
_expectedFilename);
_expectedFilename,
_o.getId());
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@
import com.google.flatbuffers.*;

public class SaveFileNotificationT {
private int[] data;
private String mimeType;
private String fileExtension;
private Integer expectedDir;
private String expectedFilename;

public int[] getData() { return data; }

public void setData(int[] data) { this.data = data; }
private long id;

public String getMimeType() { return mimeType; }

Expand All @@ -34,13 +30,17 @@ public class SaveFileNotificationT {

public void setExpectedFilename(String expectedFilename) { this.expectedFilename = expectedFilename; }

public long getId() { return id; }

public void setId(long id) { this.id = id; }


public SaveFileNotificationT() {
this.data = null;
this.mimeType = null;
this.fileExtension = null;
this.expectedDir = null;
this.expectedFilename = null;
this.id = 0L;
}
}

Loading