reorg: separate dbus code out of conversation list model and into repository
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
using GLib;
|
||||
|
||||
public class Conversation : Object {
|
||||
public string id { get; set; default = ""; }
|
||||
public string guid { get; set; default = ""; }
|
||||
public string last_message_preview { get; set; default = ""; }
|
||||
public int64 date { get; set; default = 0; }
|
||||
public string[] participants { get; set; default = new string[0]; }
|
||||
@@ -29,45 +29,27 @@ public class Conversation : Object {
|
||||
|
||||
private string? _display_name = null;
|
||||
|
||||
public Conversation.from_variant (Variant dict) {
|
||||
id = "";
|
||||
last_message_preview = "";
|
||||
participants = new string[0];
|
||||
|
||||
if (dict.get_type_string() != "a{sv}") {
|
||||
warning("Expected dictionary variant, got %s", dict.get_type_string());
|
||||
return;
|
||||
}
|
||||
|
||||
// Safe extraction with type checking
|
||||
Variant? id_variant = dict.lookup_value("id", VariantType.STRING);
|
||||
if (id_variant != null) {
|
||||
id = id_variant.get_string();
|
||||
public Conversation.from_hash_table(HashTable<string, Variant> conversation_data) {
|
||||
guid = conversation_data["guid"].get_string();
|
||||
|
||||
if (conversation_data.contains("last_message_preview")) {
|
||||
last_message_preview = conversation_data["last_message_preview"].get_string();
|
||||
}
|
||||
|
||||
Variant? display_name_variant = dict.lookup_value("display_name", VariantType.STRING);
|
||||
if (display_name_variant != null) {
|
||||
_display_name = display_name_variant.get_string();
|
||||
if (conversation_data.contains("participants")) {
|
||||
participants = conversation_data["participants"].dup_strv();
|
||||
}
|
||||
|
||||
Variant? last_message_variant = dict.lookup_value("last_message_preview", VariantType.STRING);
|
||||
if (last_message_variant != null) {
|
||||
last_message_preview = last_message_variant.get_string();
|
||||
if (conversation_data.contains("unread_count")) {
|
||||
unread_count = conversation_data["unread_count"].get_int32();
|
||||
}
|
||||
|
||||
Variant? date_variant = dict.lookup_value("date", VariantType.INT64);
|
||||
if (date_variant != null) {
|
||||
date = date_variant.get_int64();
|
||||
if (conversation_data.contains("date")) {
|
||||
date = conversation_data["date"].get_int64();
|
||||
}
|
||||
|
||||
Variant? participants_variant = dict.lookup_value("participants", new VariantType("as"));
|
||||
if (participants_variant != null) {
|
||||
participants = participants_variant.dup_strv();
|
||||
}
|
||||
|
||||
Variant? unread_count_variant = dict.lookup_value("unread_count", VariantType.INT32);
|
||||
if (unread_count_variant != null) {
|
||||
unread_count = unread_count_variant.get_int32();
|
||||
if (conversation_data.contains("display_name")) {
|
||||
_display_name = conversation_data["display_name"].get_string();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user