[seahorse/wip/nieldsg/gkr-item-username] gkr: Try to guess the username
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [seahorse/wip/nieldsg/gkr-item-username] gkr: Try to guess the username
- Date: Wed, 19 Feb 2020 07:03:44 +0000 (UTC)
commit 7cdf2b84c3dea8d536420b394392544e2e7e5bd4
Author: Niels De Graef <nielsdegraef gmail com>
Date: Wed Feb 19 07:59:36 2020 +0100
gkr: Try to guess the username
We try to display the username in the list of passwords in the main
window. Since there is no real convention on what the schema key should
be named, try to do some educated guesses.
gkr/gkr-item-info.vala | 37 +++++++++++++++++++++++++++++++++----
1 file changed, 33 insertions(+), 4 deletions(-)
---
diff --git a/gkr/gkr-item-info.vala b/gkr/gkr-item-info.vala
index 9d9331c2..62cfdcf8 100644
--- a/gkr/gkr-item-info.vala
+++ b/gkr/gkr-item-info.vala
@@ -44,10 +44,39 @@ public class ItemInfo : GLib.Object {
if (description != null)
this.description = description;
- if (this.details == "") {
- // Maybe we can display the username
- this.details = get_attribute_string(attrs, "username") ?? "";
- }
+ this.details = guess_username(attrs);
+ }
+
+ private unowned string? guess_username(HashTable<string, string>? attrs) {
+ unowned string? username;
+
+ if (attrs == null || this.details != "")
+ return this.details;
+
+ username = attrs.lookup("username");
+ if (username != null && username != "")
+ return username;
+
+ username = attrs.lookup("user");
+ if (username != null && username != "")
+ return username;
+
+ // Used by e.g. fractal
+ username = attrs.lookup("uid");
+ if (username != null && username != "")
+ return username;
+
+ // Used by e.g. Geary
+ username = attrs.lookup("login");
+ if (username != null && username != "")
+ return username;
+
+ // Used by e.g. Skype
+ username = attrs.lookup("account");
+ if (username != null && username != "")
+ return username;
+
+ return null;
}
public void query_installed_apps(string item_type) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]