Author: batosai
Date: 2008-06-24 17:49:49 +0000 (Tue, 24 Jun 2008)
New Revision: 20652
Modified:
trunk/apps/WoT/src/plugins/WoT/WoT.java
Log:
Made some room for the actual WoT code.
Modified: trunk/apps/WoT/src/plugins/WoT/WoT.java
===================================================================
--- trunk/apps/WoT/src/plugins/WoT/WoT.java 2008-06-24 16:55:08 UTC (rev
20651)
+++ trunk/apps/WoT/src/plugins/WoT/WoT.java 2008-06-24 17:49:49 UTC (rev
20652)
@@ -37,86 +37,62 @@
1 // Every identity above rank 5 can give 1 point
}; // Identities with negative score have zero
capacity
- private IdentityInserter identityInserter;
- private FcpConnection fcp;
- private ObjectContainer db;
-
-
/**
* Creates a new WoT instance
- *
- * @param host Hostname or address of the Freenet node
- * @param port FCP port of the Freenet node
- * @throws UnknownHostException
- * @throws IOException
- * @throws InterruptedException
*/
- public WoT(String host, int port) throws UnknownHostException,
IOException, InterruptedException {
-
- db = Db4o.openFile("WoT.db4o");
-
- fcp = new FcpConnection(host,port);
- fcp.connect();
- fcp.sendMessage(new ClientHello("WoT"));
-
- //fcp = new FCPHandler(host,port);
-
- //identityInserter = new IdentityInserter(db, fcp);
- //identityInserter.start();
-
+ public WoT() {
+
}
- /**
- * Stops every threads and cleanly close all connections (FCP, database)
- *
- * @throws InterruptedException
- */
- private void close() {
-
- //identityInserter.stop();
- fcp.disconnect();
- db.close();
-
- }
/**
- * Testing code goes here, nevermind what horrors you see below ;)
+ * This code will have to move in the plugin methods.
*/
- public void testDrive() throws Exception {
-
- //Empty the database
- ObjectSet<Object> result = db.queryByExample(new Object());
- while (result.hasNext()) { db.delete(result.next()); }
+ public static void main(String[] args) {
- /*
- OwnIdentity root = new OwnIdentity(fcp);
- db.store(root);
-
- Identity a = new Identity("a", new Date(), true);
- Identity b = new Identity("b", new Date(), true);
+ IdentityInserter identityInserter;
+ FcpConnection fcp;
+ ObjectContainer db;
- db.store(a);
- db.store(b);
-
- root.addTrust(db, a, 80);
- root.addTrust(db, b, 30);
- a.addTrust(db, b, 100);
- */
-
- Identity test = new Identity("USK at
DCOSLbqlCS-~Ly8ZBxvcI9MkrweRl0t7BLLKs2zGj38,J~GQAEk3m5eXI5KagpSXxHX2~3GPC61eJtQGIWn~5Ns,AQACAAE/",
new Date(), 3, true);
-
- IdentityFetcher identityFetcher = new IdentityFetcher(db,fcp);
- identityFetcher.fetch(test);
-
- }
-
- /**
- * Just to allow the code to run outside a Freenet node
- */
- public static void main(String[] args) {
try {
- WoT wot = new WoT("localhost", 9481);
- wot.testDrive();
+ db = Db4o.openFile("WoT.db4o");
+
+ fcp = new FcpConnection("localhost",9481);
+ fcp.connect();
+ fcp.sendMessage(new ClientHello("WoT"));
+
+ //fcp = new FCPHandler(host,port);
+
+ //identityInserter = new IdentityInserter(db, fcp);
+ //identityInserter.start();
+
+ //Empty the database
+ ObjectSet<Object> result = db.queryByExample(new
Object());
+ while (result.hasNext()) { db.delete(result.next()); }
+
+ /*
+ OwnIdentity root = new OwnIdentity(fcp);
+ db.store(root);
+
+ Identity a = new Identity("a", new Date(), true);
+ Identity b = new Identity("b", new Date(), true);
+
+ db.store(a);
+ db.store(b);
+
+ root.addTrust(db, a, 80);
+ root.addTrust(db, b, 30);
+ a.addTrust(db, b, 100);
+ */
+
+ Identity test = new Identity("USK at
DCOSLbqlCS-~Ly8ZBxvcI9MkrweRl0t7BLLKs2zGj38,J~GQAEk3m5eXI5KagpSXxHX2~3GPC61eJtQGIWn~5Ns,AQACAAE/",
new Date(), 3, true);
+
+ IdentityFetcher identityFetcher = new
IdentityFetcher(db,fcp);
+ identityFetcher.fetch(test);
+
+ //identityInserter.stop();
+ fcp.disconnect();
+ db.close();
}
catch (Exception e) {
// We catch everything here as there is not yet an
interface to warn the user of the problems