[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:01:22 +0000 (UTC)
commit 4e45203d07a0ac75d41d9b62b37829c34845b023
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 | 32 ++++++++++++++++++++++++++++----
1 file changed, 28 insertions(+), 4 deletions(-)
---
diff --git a/gkr/gkr-item-info.vala b/gkr/gkr-item-info.vala
index 9d9331c2..4f34219f 100644
--- a/gkr/gkr-item-info.vala
+++ b/gkr/gkr-item-info.vala
@@ -44,10 +44,34 @@ 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. 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]