[Xfce4-commits] <postler:master> Use the group as account name and no fallback

Christian Dywan noreply at xfce.org
Sun Dec 26 04:50:02 CET 2010


Updating branch refs/heads/master
         to 1a76355fdbb9c94b689ca15bca2b03bac92d8505 (commit)
       from 8ca0c2c788af2ff2751830e2b90d70b92f7bd6dc (commit)

commit 1a76355fdbb9c94b689ca15bca2b03bac92d8505
Author: Christian Dywan <christian at twotoasts.de>
Date:   Fri Dec 24 23:52:50 2010 +0100

    Use the group as account name and no fallback

 postler/postler-accounts.vala |   24 ++++++++++--------------
 1 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/postler/postler-accounts.vala b/postler/postler-accounts.vala
index 213990e..8fc0760 100644
--- a/postler/postler-accounts.vala
+++ b/postler/postler-accounts.vala
@@ -162,9 +162,8 @@ public class Postler.Accounts : GLib.Object {
     public void update () {
         try {
             foreach (AccountInfo account_info in infos) {
-                string group = account_info.name ?? account_info.address;
-                if (account_info.name != null)
-                    keyfile.set_string (group, "name", account_info.name);
+                string? group = account_info.name;
+                return_if_fail (group != null);
 
                 if (account_info.type == AccountType.MAILDIR) {
                     keyfile.set_string (group, "type", "maildir");
@@ -213,8 +212,7 @@ public class Postler.Accounts : GLib.Object {
                 }
                 else if (account_info.type == AccountType.SEARCH) {
                     keyfile.set_string (group, "type", "search");
-                    if (account_info.path != null)
-                        keyfile.set_string (group, "path", account_info.path);
+                    keyfile.set_string (group, "path", account_info.path);
                 }
                 else
                     assert_not_reached ();
@@ -229,10 +227,10 @@ public class Postler.Accounts : GLib.Object {
         }
     }
 
-    void delete_account (AccountInfo info) {
+    void delete_account (AccountInfo info)
+        requires (info.name != null) {
         try {
-            string group = info.name ?? info.address;
-            keyfile.remove_group (group);
+            keyfile.remove_group (info.name);
             if (DirUtils.create_with_parents (config_path, 0700) != 0)
                 throw new GLib.FileError.FAILED (_("Config folder couldn't be created."));
             FileUtils.set_contents (account_file, keyfile.to_data ());
@@ -254,22 +252,21 @@ public class Postler.Accounts : GLib.Object {
 
         foreach (string group in keyfile.get_groups ()) {
             try {
-                string name = keyfile.get_string (group, "name");
                 string type = keyfile.get_string (group, "type");
                 var info = new AccountInfo ();
-                info.name = name;
+                info.name = group;
                 if (type == "maildir") {
                     info.type = AccountType.MAILDIR;
                     if (keyfile.has_key (group, "path"))
                         info.path = keyfile.get_string (group, "path");
                     else
-                        info.path = data_path + name;
+                        info.path = data_path + info.name;
                     if (keyfile.has_key (group, "hide"))
                         info.hide = keyfile.get_string (group, "hide");
                 }
                 else if (type == "imap") {
                     info.type = AccountType.IMAP;
-                    info.path = data_path + name;
+                    info.path = data_path + info.name;
                     if (keyfile.has_key (group, "realname"))
                         info.realname = keyfile.get_string (group, "realname");
                     if (keyfile.has_key (group, "address"))
@@ -302,8 +299,7 @@ public class Postler.Accounts : GLib.Object {
                 }
                 else if (type == "search") {
                     info.type = AccountType.SEARCH;
-                    if (keyfile.has_key (group, "path"))
-                        info.path = keyfile.get_string (group, "path");
+                    info.path = keyfile.get_string (group, "path");
                 }
                 else
                     throw new GLib.FileError.FAILED (



More information about the Xfce4-commits mailing list