Does this version mean that Freemail can now be used as a plugin? If  
so, would you be so kind as to describe the steps needed to add the  
plugin to freenet.

thanks

regards,

Robert
---
Robert Guerra <rguerra at privaterra.ca>
Managing Director, Privaterra
Tel +1 416 893 0377



On 5-Nov-07, at 6:59 PM, dbkr at freenetproject.org wrote:

> Author: dbkr
> Date: 2007-11-05 23:59:35 +0000 (Mon, 05 Nov 2007)
> New Revision: 15698
>
> Modified:
>   trunk/apps/Freemail/src/freemail/FreemailPlugin.java
> Log:
> Use post for the add account form.
>
>
> Modified: trunk/apps/Freemail/src/freemail/FreemailPlugin.java
> ===================================================================
> --- trunk/apps/Freemail/src/freemail/FreemailPlugin.java      2007-11-05  
> 23:41:48 UTC (rev 15697)
> +++ trunk/apps/Freemail/src/freemail/FreemailPlugin.java      2007-11-05  
> 23:59:35 UTC (rev 15698)
> @@ -194,21 +194,62 @@
>               HTMLNode pageNode = pr.getPageMaker().getPageNode("Freemail  
> plugin", false, null);
>               HTMLNode contentNode = 
> pr.getPageMaker().getContentNode(pageNode);
>
> -             if(request.getParam("add").equals("Add account")) {
> -                     if(!(request.getParam("name").equals("") ||  
> request.getParam("password").equals(""))) {
> +             HTMLNode addBox = contentNode.addChild("div", "class", 
> "infobox");
> +             addBox.addChild("div", "class", "infobox-header", "Add 
> account");
> +             
> +             HTMLNode boxContent = addBox.addChild("div", "class", "infobox- 
> content");
> +             HTMLNode form = pr.addFormChild(boxContent, "", 
> "addAccountForm");
> +             
> +             HTMLNode table = form.addChild("table", "class", "plugintable");
> +             HTMLNode tableRowName = table.addChild("tr");
> +             tableRowName.addChild("td", "Name");
> +             tableRowName.addChild("td").addChild("input", new String[]  
> { "type", "name", "value", "size" }, new String[] { "text", "name",  
> "", "30" });
> +             HTMLNode tableRowPassword = table.addChild("tr");
> +             tableRowPassword.addChild("td", "Password");
> +             tableRowPassword.addChild("td").addChild("input", new String[]  
> { "type", "name", "value", "size" }, new String[] { "password",  
> "password", "", "30" });
> +             HTMLNode tableRowDomain = table.addChild("tr");
> +             tableRowDomain.addChild("td", "Domain");
> +             tableRowDomain.addChild("td").addChild("input", new String[]  
> { "type", "name", "value", "size" }, new String[] { "text",  
> "domain", "", "30" });
> +             HTMLNode tableRowSubmit = table.addChild("tr");
> +             tableRowSubmit.addChild("td");
> +             tableRowSubmit.addChild("td").addChild("input", new String[]  
> { "type", "name", "value" }, new String[] { "submit", "add", "Add  
> account"});
> +             
> +             return pageNode.generate();
> +     }
> +
> +     public String handleHTTPPost(HTTPRequest request) throws  
> PluginHTTPException {
> +             HTMLNode pageNode = pr.getPageMaker().getPageNode("Freemail  
> plugin", false, null);
> +             HTMLNode contentNode = 
> pr.getPageMaker().getContentNode(pageNode);
> +             
> +             String add = request.getPartAsString("add", 100);
> +             String name = request.getPartAsString("name", 100);
> +             String password = request.getPartAsString("password", 100);
> +             String domain = request.getPartAsString("domain", 100);
> +             
> +             if(add.equals("Add account")) {
> +                     if(!(name.equals("") || password.equals(""))) {
>                               try {
> -                                     
> AccountManager.Create(request.getParam("name"));
> -                                     
> AccountManager.ChangePassword(request.getParam("name"),  
> request.getParam("password"));
> -                                     
> if(!request.getParam("domain").equals("")) {
> -                                             
> AccountManager.addShortAddress(request.getParam("name"),  
> request.getParam("domain"));
> +                                     AccountManager.Create(name);
> +                                     AccountManager.ChangePassword(name, 
> password);
> +                                     if(!domain.equals("")) {
> +                                             
> AccountManager.addShortAddress(name, domain);
>                                       }
> -                                     Thread t = new Thread(new 
> SingleAccountWatcher(new  
> File(DATADIR, request.getParam("name"))), "Account Watcher for  
> "+request.getParam("name"));
> +                                     Thread t = new Thread(new 
> SingleAccountWatcher(new  
> File(DATADIR, name)), "Account Watcher for "+name);
>                                       t.setDaemon(true);
>                                       t.start();
> -                                     HTMLNode addedBox = 
> contentNode.addChild("div", "class",  
> "infobox");
> -                                     addedBox.addChild("div", "class", 
> "infobox-header", "Added  
> account");
> -                                     addedBox.addChild("div", "class", 
> "infobox-content", "Account  
> for " + request.getParam("name") + " is created");
> -                                     
> +
> +                                     HTMLNode successBox = 
> contentNode.addChild("div", "class",  
> "infobox infobox-success");
> +                                     successBox.addChild("div", "class", 
> "infobox-header", "Account  
> Created");
> +                                     // TODO: This is not the world's best 
> into message, but it's  
> only temporary (hopefully...)
> +                                     HTMLNode text = 
> successBox.addChild("div", "class", "infobox- 
> content");
> +                                     text.addChild("#", "The account ");
> +                                     text.addChild("i", name);
> +                                     text.addChild("#", " was created 
> successfully.");
> +                                     text.addChild("br");
> +                                     text.addChild("br");
> +                                     text.addChild("#", "You now need to 
> configure your email  
> client to send and receive email through "
> +                                                     + "Freemail using IMAP 
> and SMTP. Freemail uses ports 3143  
> and 3025 for these "
> +                                                     + "respectively by 
> default.");
>                               } catch (IOException ioe) {
>                                       HTMLNode errorBox = 
> contentNode.addChild("div", "class",  
> "infobox infobox-error");
>                                       errorBox.addChild("div", "class", 
> "infobox-header", "IO Error");
> @@ -216,38 +257,23 @@
>                               } catch (Exception e) {
>                                       HTMLNode errorBox = 
> contentNode.addChild("div", "class",  
> "infobox-error");
>                                       errorBox.addChild("div", "class", 
> "infobox-header", "Error");
> -                                     errorBox.addChild("div", "class", 
> "infobox-content", "Couldn't  
> change password for "+request.getParam("name")+". "+e.getMessage());
> +                                     errorBox.addChild("div", "class", 
> "infobox-content", "Couldn't  
> change password for "+name+". "+e.getMessage());
>                               }
> +                             
> +                             // XXX: There doesn't seem to be a way to get 
> (or set) our root  
> in the web interface,
> +                             //      so we'll just have to assume it's this 
> and won't change
> +                             contentNode.addChild("a", "href", "/plugins/ 
> freemail.FreemailPlugin",
> +                                             "Freemail Home");
>                       } else {
>                               HTMLNode errorBox = contentNode.addChild("div", 
> "class",  
> "infobox infobox-error");
>                               errorBox.addChild("div", "class", 
> "infobox-header", "Error");
>                               errorBox.addChild("div", "class", 
> "infobox-content", "Couldn't  
> create account, name or password is missing");
>                       }
>               }
> -
> -             HTMLNode addBox = contentNode.addChild("div", "class", 
> "infobox");
> -             addBox.addChild("div", "class", "infobox-header", "Add 
> account");
> -             HTMLNode table = addBox.addChild("div", "class", "infobox- 
> content").addChild("form").addChild("table", "class", "plugintable");
> -             HTMLNode tableRowName = table.addChild("tr");
> -             tableRowName.addChild("td", "Name");
> -             tableRowName.addChild("td").addChild("input", new String[]  
> { "type", "name", "value", "size" }, new String[] { "text", "name",  
> "", "30" });
> -             HTMLNode tableRowPassword = table.addChild("tr");
> -             tableRowPassword.addChild("td", "Password");
> -             tableRowPassword.addChild("td").addChild("input", new String[]  
> { "type", "name", "value", "size" }, new String[] { "password",  
> "password", "", "30" });
> -             HTMLNode tableRowDomain = table.addChild("tr");
> -             tableRowDomain.addChild("td", "Domain");
> -             tableRowDomain.addChild("td").addChild("input", new String[]  
> { "type", "name", "value", "size" }, new String[] { "text",  
> "domain", "", "30" });
> -             HTMLNode tableRowSubmit = table.addChild("tr");
> -             tableRowSubmit.addChild("td");
> -             tableRowSubmit.addChild("td").addChild("input", new String[]  
> { "type", "name", "value" }, new String[] { "submit", "add", "Add  
> account"});
>               
>               return pageNode.generate();
>       }
>
> -     public String handleHTTPPost(HTTPRequest request) throws  
> PluginHTTPException {
> -             return null;
> -     }
> -
>       public String handleHTTPPut(HTTPRequest request) throws  
> PluginHTTPException {
>               return null;
>       }
>
> _______________________________________________
> Freemail mailing list
> Freemail at freenetproject.org
> http://emu.freenetproject.org/cgi-bin/mailman/listinfo/freemail


Reply via email to