Author: alexlehm
Date: 2008-03-24 23:30:10 +0000 (Mon, 24 Mar 2008)
New Revision: 18755

Modified:
   trunk/apps/Freemail/src/freemail/AccountManager.java
   trunk/apps/Freemail/src/freemail/SingleAccountWatcher.java
Log:
2178: NPE if the accprops file is empty 
(https://bugs.freenetproject.org/view.php?id=2178)
write more helpful error message if the accprops keys cannot be found (the 
account is broken anyway)


Modified: trunk/apps/Freemail/src/freemail/AccountManager.java
===================================================================
--- trunk/apps/Freemail/src/freemail/AccountManager.java        2008-03-24 
23:17:19 UTC (rev 18754)
+++ trunk/apps/Freemail/src/freemail/AccountManager.java        2008-03-24 
23:30:10 UTC (rev 18755)
@@ -160,7 +160,11 @@
        public static String getFreemailDomain(PropsFile accfile) {
                FreenetURI mailsite;
                try {
-                       mailsite = new 
FreenetURI(accfile.get("mailsite.pubkey"));
+                       String pubkey=accfile.get("mailsite.pubkey");
+                       if(pubkey==null) {
+                               return null;
+                       }
+                       mailsite = new FreenetURI(pubkey);
                } catch (MalformedURLException mfue) {
                        Logger.error(AccountManager.class,"Warning: Couldn't 
fetch mailsite public key from account file! Your account file is probably 
corrupt.");
                        return null;

Modified: trunk/apps/Freemail/src/freemail/SingleAccountWatcher.java
===================================================================
--- trunk/apps/Freemail/src/freemail/SingleAccountWatcher.java  2008-03-24 
23:17:19 UTC (rev 18754)
+++ trunk/apps/Freemail/src/freemail/SingleAccountWatcher.java  2008-03-24 
23:30:10 UTC (rev 18755)
@@ -75,13 +75,23 @@
                        this.nf = null;
                }

+               String rtskey=this.accprops.get("rtskey");
+
+               if(rtskey==null) {
+                       Logger.error(this,"Your accprops file is missing the 
rtskey entry. This means it is broken, you will not be able to receive new 
contact requests.");
+               }
+
+               this.rtsf = new RTSFetcher("KSK@"+rtskey+"-", this.ibctdir, 
accdir);

-               this.rtsf = new 
RTSFetcher("KSK@"+this.accprops.get("rtskey")+"-", this.ibctdir, accdir);
-               
                //this.mf = new MailFetcher(this.mb, inbound_dir, 
Freemail.getFCPConnection());

                // temporary info message until there's a nicer UI :)
-               Logger.normal(this,"Secure Freemail address: 
<anything>@"+AccountManager.getFreemailDomain(accdir));
+               String freemailDomain=AccountManager.getFreemailDomain(accdir);
+               if(freemailDomain!=null) {
+                       Logger.normal(this,"Secure Freemail address: 
<anything>@"+AccountManager.getFreemailDomain(accdir));
+               } else {
+                       Logger.error(this, "You do not have a freemail address 
USK. This account is really broken.");
+               }

                String shortdomain = 
AccountManager.getKSKFreemailDomain(accdir);
                if (shortdomain != null) {


Reply via email to