Remove possibility of NULL for properties with fundamental types
It is not supported by GObject.
This commit is contained in:
parent
34b0bea889
commit
5254776d4f
@ -464,39 +464,30 @@ namespace Matrix {
|
||||
}
|
||||
|
||||
public class EventContext : JsonCompact {
|
||||
public int? before_limit { get; set; default = null; }
|
||||
public int? after_limit { get; set; default = null; }
|
||||
public bool? include_profile { get; set; default = null; }
|
||||
public int before_limit { get; set; default = -1; }
|
||||
public int after_limit { get; set; default = -1; }
|
||||
public bool include_profile { get; set; default = false; }
|
||||
|
||||
public override Json.Node?
|
||||
get_json_node()
|
||||
throws Matrix.Error
|
||||
{
|
||||
if ((before_limit == null)
|
||||
&& (after_limit == null)
|
||||
&& (include_profile == null))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var builder = new Json.Builder();
|
||||
|
||||
builder.begin_object();
|
||||
|
||||
if (before_limit != null) {
|
||||
if (before_limit >= 0) {
|
||||
builder.set_member_name("before_limit");
|
||||
builder.add_int_value(before_limit);
|
||||
}
|
||||
|
||||
if (after_limit != null) {
|
||||
if (after_limit >= 0) {
|
||||
builder.set_member_name("after_limit");
|
||||
builder.add_int_value(after_limit);
|
||||
}
|
||||
|
||||
if (include_profile != null) {
|
||||
builder.set_member_name("include_profile");
|
||||
builder.add_boolean_value(include_profile);
|
||||
}
|
||||
|
||||
builder.end_object();
|
||||
|
||||
@ -505,14 +496,15 @@ namespace Matrix {
|
||||
}
|
||||
|
||||
public class SearchGrouping : JsonCompact {
|
||||
public SearchGroupBy? key { get; set; default = null; }
|
||||
public SearchGroupBy key { get; set; default = SearchGroupBy.UNKNOWN; }
|
||||
|
||||
public override Json.Node?
|
||||
get_json_node()
|
||||
throws Matrix.Error
|
||||
{
|
||||
if (key == null) {
|
||||
return null;
|
||||
if (key == SearchGroupBy.UNKNOWN) {
|
||||
throw new Matrix.Error.INCOMPLETE(
|
||||
"Won't generate SearchGrouping without a valid key");
|
||||
}
|
||||
|
||||
var builder = new Json.Builder();
|
||||
@ -567,7 +559,7 @@ namespace Matrix {
|
||||
public SearchOrder order_by { get; set; default = SearchOrder.RECENT; }
|
||||
public SearchKey[] keys { get; set; }
|
||||
public EventContext? event_context { get; set; default = null; }
|
||||
public bool? include_state { get; set; default = false; }
|
||||
public bool include_state { get; set; default = false; }
|
||||
public string? filter_id { get; set; default = null; }
|
||||
public Filter? filter { get; set; default = null; }
|
||||
public string search_term { get; set; }
|
||||
@ -620,10 +612,8 @@ namespace Matrix {
|
||||
builder.add_value(node);
|
||||
}
|
||||
|
||||
if (include_state != null) {
|
||||
builder.set_member_name("include_state");
|
||||
builder.add_boolean_value(include_state);
|
||||
}
|
||||
|
||||
if ((filter != null)
|
||||
&& ((node = filter.get_json_node()) != null)) {
|
||||
|
@ -23,7 +23,7 @@ public class Matrix.Event.CallAnswer : Matrix.Event.Call {
|
||||
/**
|
||||
* The type of session description.
|
||||
*/
|
||||
public CallAnswerType? answer_type { get; set; default = null; }
|
||||
public CallAnswerType answer_type { get; set; default = CallAnswerType.UNKNOWN; }
|
||||
|
||||
/**
|
||||
* The SDP text of the session description.
|
||||
@ -70,9 +70,9 @@ public class Matrix.Event.CallAnswer : Matrix.Event.Call {
|
||||
to_json(Json.Node json_data)
|
||||
throws Matrix.Error
|
||||
{
|
||||
if (_answer_type == null) {
|
||||
if (_answer_type == CallAnswerType.UNKNOWN) {
|
||||
throw new Matrix.Error.INCOMPLETE(
|
||||
"Won't generate a m.call.answer event without answer.type");
|
||||
"Won't generate a m.call.answer event without a valid answer.type");
|
||||
}
|
||||
|
||||
if (_answer_sdp == null) {
|
||||
|
@ -28,7 +28,7 @@ public abstract class Matrix.Event.Call : Matrix.Event.Room {
|
||||
/**
|
||||
* The version of the VoIP specification this message adheres to.
|
||||
*/
|
||||
public int? version { get; set; default = null; }
|
||||
public int version { get; set; default = -1; }
|
||||
|
||||
protected override void
|
||||
from_json(Json.Node json_data)
|
||||
@ -62,7 +62,7 @@ public abstract class Matrix.Event.Call : Matrix.Event.Room {
|
||||
"Won't generate a m.call.hangup event without call_id");
|
||||
}
|
||||
|
||||
if (_version == null) {
|
||||
if (_version < 0) {
|
||||
throw new Matrix.Error.INCOMPLETE(
|
||||
"Won't generate a m.call.hangup event without version");
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ public class Matrix.Event.CallInvite : Matrix.Event.Call {
|
||||
/**
|
||||
* The type of session description.
|
||||
*/
|
||||
public CallOfferType? offer_type { get; set; default = null; }
|
||||
public CallOfferType offer_type { get; set; default = CallOfferType.UNKNOWN; }
|
||||
/**
|
||||
* The SDP text of the session description.
|
||||
*/
|
||||
@ -36,7 +36,7 @@ public class Matrix.Event.CallInvite : Matrix.Event.Call {
|
||||
* should also no longer show the call as awaiting an answer in
|
||||
* the UI.
|
||||
*/
|
||||
public int? lifetime { get; set; default = null; }
|
||||
public int lifetime { get; set; default = -1; }
|
||||
|
||||
protected override void
|
||||
from_json(Json.Node json_data)
|
||||
@ -84,9 +84,9 @@ public class Matrix.Event.CallInvite : Matrix.Event.Call {
|
||||
to_json(Json.Node json_data)
|
||||
throws Matrix.Error
|
||||
{
|
||||
if (_offer_type == null) {
|
||||
if (_offer_type == CallOfferType.UNKNOWN) {
|
||||
throw new Matrix.Error.INCOMPLETE(
|
||||
"Won't generate a m.call.invite without offer.type");
|
||||
"Won't generate a m.call.invite without a valid offer.type");
|
||||
}
|
||||
|
||||
if (_sdp == null) {
|
||||
@ -94,7 +94,7 @@ public class Matrix.Event.CallInvite : Matrix.Event.Call {
|
||||
"Won't generate a m.call.invite without offer.sdp");
|
||||
}
|
||||
|
||||
if (_lifetime == null) {
|
||||
if (_lifetime < 0) {
|
||||
throw new Matrix.Error.INCOMPLETE(
|
||||
"Won't generate a m.call.invite without lifetime");
|
||||
}
|
||||
|
@ -35,8 +35,10 @@ public class Matrix.Event.Presence : Matrix.Event.Base {
|
||||
/**
|
||||
* The last time since this used performed some action, in
|
||||
* milliseconds.
|
||||
*
|
||||
* This won’t get into the generated event JSON if negative.
|
||||
*/
|
||||
public ulong? last_active_ago { get; set; }
|
||||
public long last_active_ago { get; set; default = -1; }
|
||||
|
||||
/**
|
||||
* The user's ID.
|
||||
@ -81,7 +83,7 @@ public class Matrix.Event.Presence : Matrix.Event.Base {
|
||||
}
|
||||
|
||||
if ((node = content_root.get_member("last_active_ago")) != null) {
|
||||
_last_active_ago = (ulong)node.get_int();
|
||||
_last_active_ago = (long)node.get_int();
|
||||
}
|
||||
|
||||
if ((node = content_root.get_member("avatar_url")) != null) {
|
||||
@ -142,7 +144,7 @@ public class Matrix.Event.Presence : Matrix.Event.Base {
|
||||
_g_enum_value_to_nick(typeof(Presence),
|
||||
_presence));
|
||||
|
||||
if (last_active_ago != null) {
|
||||
if (last_active_ago >= 0) {
|
||||
content_root.set_int_member("last_active_ago", last_active_ago);
|
||||
}
|
||||
|
||||
|
@ -41,8 +41,11 @@ public abstract class Matrix.Event.Room : Matrix.Event.Base {
|
||||
/**
|
||||
* The time, in milliseconds, that has elapsed since the event was
|
||||
* sent. This is part of the unsigned event data.
|
||||
*
|
||||
* This value will be omitted from the generated event JSON if
|
||||
* less than zero.
|
||||
*/
|
||||
public ulong? age { get; set; default = null; }
|
||||
public long age { get; set; default = 0; }
|
||||
|
||||
/**
|
||||
* The reason this event was redacted, if it was redacted.
|
||||
@ -119,7 +122,7 @@ public abstract class Matrix.Event.Room : Matrix.Event.Base {
|
||||
|
||||
var unsigned_obj = new Json.Object();
|
||||
|
||||
if (age != null) {
|
||||
if (age >= 0) {
|
||||
unsigned_obj.set_int_member("age", _age);
|
||||
}
|
||||
|
||||
|
@ -267,8 +267,9 @@ namespace Matrix {
|
||||
}
|
||||
|
||||
public enum SearchGroupBy {
|
||||
UNKNOWN,
|
||||
ROOM_ID,
|
||||
SENDER
|
||||
SENDER;
|
||||
}
|
||||
|
||||
public enum HistoryVisibility {
|
||||
|
Loading…
Reference in New Issue
Block a user