Author: xor
Date: 2008-11-07 23:29:21 +0000 (Fri, 07 Nov 2008)
New Revision: 23397

Modified:
   trunk/plugins/Freetalk/Freetalk.java
Log:
Refactor, remove useless code.

Modified: trunk/plugins/Freetalk/Freetalk.java
===================================================================
--- trunk/plugins/Freetalk/Freetalk.java        2008-11-07 23:28:39 UTC (rev 
23396)
+++ trunk/plugins/Freetalk/Freetalk.java        2008-11-07 23:29:21 UTC (rev 
23397)
@@ -113,9 +113,7 @@
                db.commit();
                Logger.debug(this, "Database wiped.");

-               Logger.debug(this, "Getting TBF...");
                tbf = pr.getNode().clientCore.tempBucketFactory;
-               Logger.debug(this, "Got TBF.");

                Logger.debug(this, "Creating identity manager...");
                mIdentityManager = new FTIdentityManagerWoT(db, 
pr.getNode().executor, (WoT)getWoTPlugin() );
@@ -123,7 +121,6 @@
                Logger.debug(this, "Creating message manager...");
                mMessageManager = new FTMessageManagerWoT(db, 
pr.getNode().executor, mIdentityManager);

-               Logger.debug(this, "Setting up PageMaker...");
                pm = pr.getPageMaker();
                pm.addNavigationLink(PLUGIN_URI + "/", "Home", "Freetalk plugin 
home", false, null);
                pm.addNavigationLink(PLUGIN_URI + "/ownidentities", "Own 
Identities", "Manage your own identities", false, null);
@@ -131,33 +128,30 @@
                pm.addNavigationLink(PLUGIN_URI + "/messages", "Messages", 
"View Messages", false, null);
                pm.addNavigationLink(PLUGIN_URI + "/status", "Dealer status", 
"Show what happens in background", false, null);
                pm.addNavigationLink("/", "Fproxy", "Back to nodes home", 
false, null);
-               Logger.debug(this, "PageMaker is set up.");

                Logger.debug(this, "Plugin loaded.");
        }

        public void terminate() {
-               /* FIXME: Signal the identity manager and message manager to 
shutdown */
+               mMessageManager.terminate();
+               mIdentityManager.terminate();
+               db.commit();
                db.close();
                Logger.debug(this, "Freetalk plugin terminated.");
        }

        public String handleHTTPGet(HTTPRequest request) throws 
PluginHTTPException {

-               if (request.isParameterSet("formPassword")) {
-                       String pass = request.getParam("formPassword");
-                       if ((pass.length() == 0) || 
!pass.equals(pr.getNode().clientCore.formPassword)) {
-                               return Errors.makeErrorPage(this, "Buh! Invalid 
form password");
-                       }
-               }
+               String pass = request.getParam("formPassword");
+               if (pass == null || (pass.length() == 0) || 
!pass.equals(pr.getNode().clientCore.formPassword))
+                       return Errors.makeErrorPage(this, "Buh! Invalid form 
password");

                String page = request.getPath().substring(PLUGIN_URI.length());
                if ((page.length() < 1) || ("/".equals(page)))
                        return Welcome.makeWelcomePage(this);

-               if ("/status".equals(page)) {
+               if ("/status".equals(page))
                        return Status.makeStatusPage(this);
-               }

                if ("/ownidentities".equals(page))
                        return IdentityEditor.makeOwnIdentitiesPage(this, 
request);
@@ -168,7 +162,7 @@
                if ("/messages".equals(page))
                        return Messages.makeMessagesPage(this, request);

-               throw new NotFoundPluginHTTPException("Resource not found in 
FreetalkPlugin", page);
+               throw new NotFoundPluginHTTPException("Resource not found in 
Freetalk plugin", page);
        }

        public void handle(PluginReplySender replysender, SimpleFieldSet 
params, Bucket data, int accesstype) {
@@ -326,27 +320,23 @@
        public String getVersion() {
                return "? r" + Version.svnRevision;
        }
-
+       
        public String getString(String key) {
                // Logger.error(this, "Request translation for "+key);
                return key;
        }
-
        public void setLanguage(LANGUAGE newLanguage) {
                language = newLanguage;
-               Logger.error(this, "Set LANGUAGE to: " + language.isoCode);
+               Logger.debug(this, "Set LANGUAGE to: " + language.isoCode);
        }

        public void setTheme(THEME newTheme) {
-               theme= newTheme;
+               theme = newTheme;
                Logger.error(this, "Set THEME to: " + theme.code);
        }

        public FredPluginFCP getWoTPlugin() {
-               Logger.debug(this, "Getting WoT plugin...");
-               FredPluginFCP wot = 
pr.getNode().pluginManager.getFCPPlugin(Freetalk.WOT_NAME);
-               Logger.debug(this, "Got WoT plugin: " + wot);
-               return wot;
+               return 
pr.getNode().pluginManager.getFCPPlugin(Freetalk.WOT_NAME);
        }

        public long countIdentities() {
@@ -361,5 +351,4 @@
        final public HTMLNode getPageNode() {
                return pm.getPageNode(Freetalk.PLUGIN_TITLE, null);
        }
-
 }


Reply via email to