|
@@ -15,13 +15,22 @@ namespace Pprf.Messages {
|
|
CHECKSUM = (1 << 7),
|
|
CHECKSUM = (1 << 7),
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public enum ListingRequestFlags {
|
|
|
|
+ TAG = (1 << 0),
|
|
|
|
+ SEARCH = (2 << 0),
|
|
|
|
+ SINCE = (3 << 0),
|
|
|
|
+ INCLUDE_HIDDEN = (4 << 0)
|
|
|
|
+ }
|
|
|
|
+
|
|
public class GetListing : CollectionMessage {
|
|
public class GetListing : CollectionMessage {
|
|
|
|
|
|
|
|
+ public uint16 flags { get; set; }
|
|
public uint16 columns { get; set; }
|
|
public uint16 columns { get; set; }
|
|
public uint32 skip { get; set; }
|
|
public uint32 skip { get; set; }
|
|
public uint8 take { get; set; }
|
|
public uint8 take { get; set; }
|
|
public string? tag { get; set; }
|
|
public string? tag { get; set; }
|
|
public string? query { get; set; }
|
|
public string? query { get; set; }
|
|
|
|
+ public DateTime? since { get; set; }
|
|
|
|
|
|
public GetListing() {
|
|
public GetListing() {
|
|
message_type = MessageType.GET_LISTING;
|
|
message_type = MessageType.GET_LISTING;
|
|
@@ -29,68 +38,96 @@ namespace Pprf.Messages {
|
|
|
|
|
|
public override void deserialise (GLib.DataInputStream stream) throws Error {
|
|
public override void deserialise (GLib.DataInputStream stream) throws Error {
|
|
base.deserialise (stream);
|
|
base.deserialise (stream);
|
|
|
|
+ flags = stream.read_uint16();
|
|
columns = stream.read_uint16();
|
|
columns = stream.read_uint16();
|
|
skip = stream.read_uint32();
|
|
skip = stream.read_uint32();
|
|
take = stream.read_byte();
|
|
take = stream.read_byte();
|
|
|
|
|
|
- var tag_len = stream.read_uint16();
|
|
|
|
- if(tag_len > 0) {
|
|
|
|
- var tag_data = new uint8[tag_len];
|
|
|
|
- stream.read(tag_data);
|
|
|
|
- tag = new BinaryData.from_byte_array(tag_data).to_raw_string();
|
|
|
|
|
|
+ if((flags & ListingRequestFlags.TAG) != 0) {
|
|
|
|
+ var tag_len = stream.read_uint16();
|
|
|
|
+ if(tag_len > 0) {
|
|
|
|
+ var tag_data = new uint8[tag_len];
|
|
|
|
+ stream.read(tag_data);
|
|
|
|
+ tag = new BinaryData.from_byte_array(tag_data).to_raw_string();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
- var query_len = stream.read_uint16();
|
|
|
|
- if(query_len > 0) {
|
|
|
|
- var query_data = new uint8[query_len];
|
|
|
|
- stream.read(query_data);
|
|
|
|
- query = new BinaryData.from_byte_array(query_data).to_raw_string();
|
|
|
|
|
|
+ if((flags & ListingRequestFlags.SEARCH) != 0) {
|
|
|
|
+ var query_len = stream.read_uint16();
|
|
|
|
+ if(query_len > 0) {
|
|
|
|
+ var query_data = new uint8[query_len];
|
|
|
|
+ stream.read(query_data);
|
|
|
|
+ query = new BinaryData.from_byte_array(query_data).to_raw_string();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if((flags & ListingRequestFlags.SINCE) != 0) {
|
|
|
|
+ var date_len = stream.read_byte();
|
|
|
|
+ if(date_len > 0) {
|
|
|
|
+ var date_data = new uint8[date_len];
|
|
|
|
+ stream.read(date_data);
|
|
|
|
+ var date_str = new BinaryData.from_byte_array(date_data).to_raw_string();
|
|
|
|
+ since = new DateTime.from_iso8601(date_str, null);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public override uint64 calculate_size() {
|
|
public override uint64 calculate_size() {
|
|
- var text_size = 0;
|
|
|
|
- if(query != null) {
|
|
|
|
- text_size += query.data.length;
|
|
|
|
- }
|
|
|
|
- if(tag != null) {
|
|
|
|
- text_size += tag.data.length;
|
|
|
|
- }
|
|
|
|
|
|
+ var tag_size = (flags & ListingRequestFlags.TAG) != 0 ? 2 + tag.data.length : 0;
|
|
|
|
+ var query_size = (flags & ListingRequestFlags.SEARCH) != 0 ? 2 + query.data.length : 0;
|
|
|
|
+ var date_size = (flags & ListingRequestFlags.SINCE) != 0 ? 2 + since.format_iso8601().data.length : 0;
|
|
return base.calculate_size() +
|
|
return base.calculate_size() +
|
|
|
|
+ 2 + // Flags
|
|
2 + // Columns
|
|
2 + // Columns
|
|
4 + // Skip
|
|
4 + // Skip
|
|
1 + // Take
|
|
1 + // Take
|
|
- 2 + // Tag size
|
|
|
|
- 2 + // Query size
|
|
|
|
- text_size; // Query + tag
|
|
|
|
|
|
+ tag_size +
|
|
|
|
+ query_size +
|
|
|
|
+ date_size;
|
|
}
|
|
}
|
|
|
|
|
|
public override void serialise(DataOutputStream stream) throws Error {
|
|
public override void serialise(DataOutputStream stream) throws Error {
|
|
base.serialise(stream);
|
|
base.serialise(stream);
|
|
|
|
+ stream.put_uint16(flags);
|
|
stream.put_uint16(columns);
|
|
stream.put_uint16(columns);
|
|
stream.put_uint32(skip);
|
|
stream.put_uint32(skip);
|
|
stream.put_byte(take);
|
|
stream.put_byte(take);
|
|
|
|
|
|
- var tag_size = tag == null ? 0 : tag.data.length;
|
|
|
|
- stream.put_uint16(tag_size);
|
|
|
|
- if(tag_size > 0) {
|
|
|
|
- stream.put_string(tag);
|
|
|
|
|
|
+ if((flags & ListingRequestFlags.TAG) != 0) {
|
|
|
|
+ var tag_size = tag == null ? 0 : tag.data.length;
|
|
|
|
+ stream.put_uint16(tag_size);
|
|
|
|
+ if(tag_size > 0) {
|
|
|
|
+ stream.put_string(tag);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if((flags & ListingRequestFlags.SEARCH) != 0) {
|
|
|
|
+ var query_size = query == null ? 0 : query.data.length;
|
|
|
|
+ stream.put_uint16(query_size);
|
|
|
|
+ if(query_size > 0) {
|
|
|
|
+ stream.put_string(query);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
- var query_size = query == null ? 0 : query.data.length;
|
|
|
|
- stream.put_uint16(query_size);
|
|
|
|
- if(query_size > 0) {
|
|
|
|
- stream.put_string(query);
|
|
|
|
|
|
+ if((flags & ListingRequestFlags.SINCE) != 0) {
|
|
|
|
+ var date_str = since.format_iso8601();
|
|
|
|
+ stream.put_byte((uint8)date_str.data.length);
|
|
|
|
+ stream.put_string(date_str);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public class CollectionListing : CollectionMessage {
|
|
|
|
|
|
+ public class CollectionListing : Message {
|
|
|
|
|
|
public uint16 columns { get; set; }
|
|
public uint16 columns { get; set; }
|
|
public Vector<CollectionListingItem> results { get; set; }
|
|
public Vector<CollectionListingItem> results { get; set; }
|
|
|
|
|
|
|
|
+ public CollectionListing() {
|
|
|
|
+ message_type = MessageType.COLLECTION_LISTING;
|
|
|
|
+ results = new Vector<CollectionListingItem>();
|
|
|
|
+ }
|
|
|
|
+
|
|
public override void deserialise (GLib.DataInputStream stream) throws Error {
|
|
public override void deserialise (GLib.DataInputStream stream) throws Error {
|
|
base.deserialise (stream);
|
|
base.deserialise (stream);
|
|
columns = stream.read_uint16();
|
|
columns = stream.read_uint16();
|
|
@@ -130,7 +167,6 @@ namespace Pprf.Messages {
|
|
public string name { get; set; }
|
|
public string name { get; set; }
|
|
public Metadata metadata { get; set; }
|
|
public Metadata metadata { get; set; }
|
|
public uint8[]? checksum { get; set; }
|
|
public uint8[]? checksum { get; set; }
|
|
- public uint8[]? poster { get; set; }
|
|
|
|
|
|
|
|
public CollectionListingItem.from_stream(DataInputStream stream, uint16 cols) throws Error {
|
|
public CollectionListingItem.from_stream(DataInputStream stream, uint16 cols) throws Error {
|
|
metadata = new Metadata();
|
|
metadata = new Metadata();
|
|
@@ -160,11 +196,8 @@ namespace Pprf.Messages {
|
|
metadata.tags = read_string(stream, size).split(" ");
|
|
metadata.tags = read_string(stream, size).split(" ");
|
|
}
|
|
}
|
|
if((cols & ListingColumn.POSTER) != 0) {
|
|
if((cols & ListingColumn.POSTER) != 0) {
|
|
- var size = stream.read_uint32();
|
|
|
|
- var data = new BinaryData();
|
|
|
|
- var remaining = (size_t)size;
|
|
|
|
- while(data.read_in(stream.read_bytes(remaining), ref remaining));
|
|
|
|
- poster = data.to_array();
|
|
|
|
|
|
+ var size = stream.read_uint16();
|
|
|
|
+ metadata.poster = read_string(stream, size);
|
|
}
|
|
}
|
|
if((cols & ListingColumn.COPYRIGHT) != 0) {
|
|
if((cols & ListingColumn.COPYRIGHT) != 0) {
|
|
var size = stream.read_uint16();
|
|
var size = stream.read_uint16();
|
|
@@ -197,7 +230,7 @@ namespace Pprf.Messages {
|
|
s += 2 + tag_str.data.length;
|
|
s += 2 + tag_str.data.length;
|
|
}
|
|
}
|
|
if((cols & ListingColumn.POSTER) != 0) {
|
|
if((cols & ListingColumn.POSTER) != 0) {
|
|
- s += 4 + poster.length;
|
|
|
|
|
|
+ s += 2 + metadata.poster.data.length;
|
|
}
|
|
}
|
|
if((cols & ListingColumn.COPYRIGHT) != 0) {
|
|
if((cols & ListingColumn.COPYRIGHT) != 0) {
|
|
s += 2 + metadata.copyright.data.length;
|
|
s += 2 + metadata.copyright.data.length;
|
|
@@ -237,10 +270,8 @@ namespace Pprf.Messages {
|
|
stream.put_string(tags);
|
|
stream.put_string(tags);
|
|
}
|
|
}
|
|
if((cols & ListingColumn.POSTER) != 0) {
|
|
if((cols & ListingColumn.POSTER) != 0) {
|
|
- stream.put_uint32(poster.length);
|
|
|
|
- if(poster.length > 0) {
|
|
|
|
- stream.write(poster);
|
|
|
|
- }
|
|
|
|
|
|
+ stream.put_uint16((uint16)metadata.poster.data.length);
|
|
|
|
+ stream.put_string(metadata.poster);
|
|
}
|
|
}
|
|
if((cols & ListingColumn.COPYRIGHT) != 0) {
|
|
if((cols & ListingColumn.COPYRIGHT) != 0) {
|
|
stream.put_uint16((uint16)metadata.copyright.data.length);
|
|
stream.put_uint16((uint16)metadata.copyright.data.length);
|