diff options
Diffstat (limited to 'libdino/src/entity')
-rw-r--r-- | libdino/src/entity/account.vala | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/libdino/src/entity/account.vala b/libdino/src/entity/account.vala index 51ceb8d1..e9b9f34b 100644 --- a/libdino/src/entity/account.vala +++ b/libdino/src/entity/account.vala @@ -8,7 +8,7 @@ public class Account : Object { public int id { get; set; } public string localpart { get { return full_jid.localpart; } } public string domainpart { get { return full_jid.domainpart; } } - public string resourcepart { get { return full_jid.resourcepart;} } + public string resourcepart { get { return full_jid.resourcepart;} private set {} } public Jid bare_jid { owned get { return full_jid.bare_jid; } } public Jid full_jid { get; private set; } public string? password { get; set; } @@ -31,11 +31,7 @@ public class Account : Object { } } if (this.full_jid == null) { - try { - this.full_jid = bare_jid.with_resource("dino." + Random.next_int().to_string("%x")); - } catch (InvalidJidError e) { - error("Auto-generated resource was invalid (%s)", e.message); - } + set_random_resource(); } this.password = password; this.alias = alias; @@ -76,6 +72,15 @@ public class Account : Object { db = null; } + public void set_random_resource() { + try { + this.full_jid = bare_jid.with_resource("dino." + Random.next_int().to_string("%x")); + this.resourcepart = ""; // trigger a notify on the property + } catch (InvalidJidError e) { + error("Auto-generated resource was invalid (%s)", e.message); + } + } + public bool equals(Account acc) { return equals_func(this, acc); } |