gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r18430 - in gnunet-java: . src/org/gnunet/construct src/org


From: gnunet
Subject: [GNUnet-SVN] r18430 - in gnunet-java: . src/org/gnunet/construct src/org/gnunet/construct/parsers src/org/gnunet/util
Date: Mon, 5 Dec 2011 22:29:45 +0100

Author: dold
Date: 2011-12-05 22:29:45 +0100 (Mon, 05 Dec 2011)
New Revision: 18430

Removed:
   gnunet-java/src/org/gnunet/util/TransmitReadyNotify.java
Modified:
   gnunet-java/ISSUES
   gnunet-java/src/org/gnunet/construct/ByteFill.java
   gnunet-java/src/org/gnunet/construct/Construct.java
   gnunet-java/src/org/gnunet/construct/FixedSizeArray.java
   gnunet-java/src/org/gnunet/construct/VariableSizeArray.java
   gnunet-java/src/org/gnunet/construct/ZeroTerminatedString.java
   gnunet-java/src/org/gnunet/construct/parsers/ByteFillParser.java
   gnunet-java/src/org/gnunet/construct/parsers/FieldParser.java
   gnunet-java/src/org/gnunet/construct/parsers/FillParser.java
   gnunet-java/src/org/gnunet/construct/parsers/IntegerParser.java
   gnunet-java/src/org/gnunet/construct/parsers/SequenceParser.java
   gnunet-java/src/org/gnunet/construct/parsers/VariableSizeArrayParser.java
   gnunet-java/src/org/gnunet/util/Client.java
Log:
changes to construct, some issues added

Modified: gnunet-java/ISSUES
===================================================================
--- gnunet-java/ISSUES  2011-12-05 15:55:06 UTC (rev 18429)
+++ gnunet-java/ISSUES  2011-12-05 21:29:45 UTC (rev 18430)
@@ -31,7 +31,26 @@
 
 
 
-
 * exception hierarchy in Construct
 
 
+
+
+
+
+* why do we even need transmit_ready_notify? can't we just queue the message?
+* do we need to be able to send stuff that is not a message?
+
+* why do we have tasks *and* callbacks?
+
+
+(* RelativeTime/AbsoluteTime: are wrappers are really necessary? do we need to 
distinguish
+  relative time from absolute time statically? most java APIs just use long)
+
+* should MessageHandler be a runabout?
+
+
+
+
+(* idea: gnunet-java uses a lot of reflection, should we use apt (annotation 
processing tool)
+  to do some basic static checks for runabouts and maybe construct 
annotations?) 
\ No newline at end of file

Modified: gnunet-java/src/org/gnunet/construct/ByteFill.java
===================================================================
--- gnunet-java/src/org/gnunet/construct/ByteFill.java  2011-12-05 15:55:06 UTC 
(rev 18429)
+++ gnunet-java/src/org/gnunet/construct/ByteFill.java  2011-12-05 21:29:45 UTC 
(rev 18430)
@@ -6,13 +6,12 @@
 import java.lang.annotation.Target;
 
 /**
- * Fills a byte array with the remaining data of the current frame.
+ * Fills a byte array with the remaining data in the current frame.
+ * Annotation target must be of type "byte[]"
  * 
  * @author Florian Dold
- * 
  */
 @Retention(RetentionPolicy.RUNTIME)
 @Target(ElementType.FIELD)
 public @interface ByteFill {
 }
-

Modified: gnunet-java/src/org/gnunet/construct/Construct.java
===================================================================
--- gnunet-java/src/org/gnunet/construct/Construct.java 2011-12-05 15:55:06 UTC 
(rev 18429)
+++ gnunet-java/src/org/gnunet/construct/Construct.java 2011-12-05 21:29:45 UTC 
(rev 18430)
@@ -31,6 +31,7 @@
  * @TODO performance evaluation
  */
 public class Construct {
+    
 
     private static HashMap<Class<? extends Message>, Parser> parserCache = new 
HashMap<Class<? extends Message>, Parser>();
 
@@ -51,8 +52,8 @@
      */
     public static <T extends Message> T parseAs(byte[] data, int offset,
             Class<T> c) {
-        Parser p = getParser(c);
         T m;
+
         try {
             m = (T) c.newInstance();
         } catch (InstantiationException e) {
@@ -60,13 +61,15 @@
         } catch (IllegalAccessException e) {
             throw new RuntimeException();
         }
-        p.parse(data, offset, 0, m);
+
+        getParser(c).parse(data, offset, 0, m);
+
         return m;
     }
 
-    
     /**
      * Create a Parser for a sub-class of Message.
+     * The result is always cached.
      * 
      * @param c
      * @return
@@ -87,7 +90,7 @@
     public static Parser getParser(Class<? extends Message> c,
             ParserGenerator pg) {
 
-        SequenceParser parser = new SequenceParser(null);
+        SequenceParser parser = new SequenceParser();
         pg.c = c;
 
         Field[] fs = c.getFields();
@@ -114,7 +117,7 @@
         Field field;
         Annotation[] annotations;
         int annotationsIdx;
-        
+
         Class c;
 
         FieldParser parser;
@@ -143,7 +146,6 @@
 
         }
 
-
         public void visit(UInt8 i) {
             parser = new IntegerParser(1, IntegerParser.UNSIGNED, field);
         }
@@ -219,19 +221,19 @@
 
             parser = new FixedSizeArrayParser(elemNumber, parser, f);
         }
-        
-        
+
         public void visit(VariableSizeArray vsa) {
             Field f = field;
             Class old_c = c;
-            
+
             getParser((Class<? extends Message>) field.getType()
                     .getComponentType(), this);
 
             try {
                 System.out.println(c);
-                parser = new VariableSizeArrayParser(parser, 
old_c.getField(vsa.lengthField()), f);
-                
+                parser = new VariableSizeArrayParser(parser, old_c.getField(vsa
+                        .lengthField()), f);
+
             } catch (SecurityException e) {
                 throw new RuntimeException();
             } catch (NoSuchFieldException e) {
@@ -281,23 +283,70 @@
         Parser p = getParser(m.getClass());
         p.patchSizeFields(m, p.getSize(m));
     }
-    
+
     public enum NumFieldType {
-            BIGNUM, BYTE_PRIM, SHORT_PRIM, INT_PRIM, LONG_PRIM
+        BIGNUM, BYTE_PRIM, SHORT_PRIM, INT_PRIM, LONG_PRIM, CHAR_PRIM
     }
-    
+
     public static NumFieldType getNumFieldType(Field f) {
-        if (f.getType().equals(BigInteger.class)) {
-            return NumFieldType.BIGNUM;
-        } else if (f.getType().equals(Long.TYPE)) {
+        if (f.getType().equals(Long.TYPE)) {
             return NumFieldType.LONG_PRIM;
+        } else if (f.getType().equals(java.lang.Integer.TYPE)) {
+            return NumFieldType.INT_PRIM;
         } else if (f.getType().equals(Short.TYPE)) {
             return NumFieldType.SHORT_PRIM;
-        } else if (f.getType().equals(java.lang.Integer.TYPE)) {
-            return NumFieldType.INT_PRIM;
+        } else if (f.getType().equals(Byte.TYPE)) {
+            return NumFieldType.BYTE_PRIM;
+        } else if (f.getType().equals(Character.TYPE)) {
+            return NumFieldType.CHAR_PRIM;
+        } else if (f.getType().equals(BigInteger.class)) {
+            return NumFieldType.BIGNUM;
         } else {
             throw new RuntimeException("target type not supported");
         }
     }
+    
+    
+    public static Object followFieldPath(List<Field> fl, Object obj, int 
depth) {
+        for (int i = 0; i < depth; ++i) {
+            try {
+                obj = fl.get(i).get(obj);
+            } catch (IllegalArgumentException e) {
+                throw new RuntimeException();
+            } catch (IllegalAccessException e) {
+                throw new RuntimeException();
+            }
+        }
+        return obj;
+    }
+    
+    public static Object followFieldPath(List<Field> fl, Object obj) {
+        return followFieldPath(fl, obj, fl.size());
+    }
+    
 
+    public static void setNumField(Field f, NumFieldType t, Object obj, long 
val) {
+        try {
+            switch (t) {
+            case LONG_PRIM:
+                f.setLong(obj, val);
+                break;
+            case SHORT_PRIM:
+                f.setShort(obj, (short) val);
+                break;
+            case BYTE_PRIM:
+                f.setLong(obj, (byte) val);
+                break;
+            case INT_PRIM:
+                f.setInt(obj, (int) val);
+                break;
+            default:
+                throw new RuntimeException("invalid type");
+            }
+        } catch (IllegalArgumentException e) {
+            throw new RuntimeException(e);
+        } catch (IllegalAccessException e) {
+            throw new RuntimeException();
+        }
+    }
 }

Modified: gnunet-java/src/org/gnunet/construct/FixedSizeArray.java
===================================================================
--- gnunet-java/src/org/gnunet/construct/FixedSizeArray.java    2011-12-05 
15:55:06 UTC (rev 18429)
+++ gnunet-java/src/org/gnunet/construct/FixedSizeArray.java    2011-12-05 
21:29:45 UTC (rev 18430)
@@ -6,7 +6,7 @@
 import java.lang.annotation.Target;
 
 /**
- * Parse an array of messages with fixed size.
+ * Parse an array of messages with its size fixed at the creation time of the 
parser.
  * @author Florian Dold
  *
  */

Modified: gnunet-java/src/org/gnunet/construct/VariableSizeArray.java
===================================================================
--- gnunet-java/src/org/gnunet/construct/VariableSizeArray.java 2011-12-05 
15:55:06 UTC (rev 18429)
+++ gnunet-java/src/org/gnunet/construct/VariableSizeArray.java 2011-12-05 
21:29:45 UTC (rev 18430)
@@ -5,6 +5,13 @@
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
+
+/**
+ * Parse an array of messages, where the length of the array is specified in a 
field of the containing message.
+ * 
+ * @author Florian Dold
+ *
+ */
 @Retention(RetentionPolicy.RUNTIME)
 @Target(ElementType.FIELD)
 public @interface VariableSizeArray {

Modified: gnunet-java/src/org/gnunet/construct/ZeroTerminatedString.java
===================================================================
--- gnunet-java/src/org/gnunet/construct/ZeroTerminatedString.java      
2011-12-05 15:55:06 UTC (rev 18429)
+++ gnunet-java/src/org/gnunet/construct/ZeroTerminatedString.java      
2011-12-05 21:29:45 UTC (rev 18430)
@@ -5,12 +5,12 @@
 
 /**
  * Parse and unparse a zero-terminated string with the specified encoding.
+ * The default encoding is UTF-8.
  * 
  * @author Florian Dold
  * 
  */
 @Retention(RetentionPolicy.RUNTIME)
 public @interface ZeroTerminatedString {
-
     String charset() default "UTF-8";
 }

Modified: gnunet-java/src/org/gnunet/construct/parsers/ByteFillParser.java
===================================================================
--- gnunet-java/src/org/gnunet/construct/parsers/ByteFillParser.java    
2011-12-05 15:55:06 UTC (rev 18429)
+++ gnunet-java/src/org/gnunet/construct/parsers/ByteFillParser.java    
2011-12-05 21:29:45 UTC (rev 18430)
@@ -4,6 +4,8 @@
 import java.lang.reflect.Field;
 import java.util.List;
 
+import org.gnunet.construct.Construct;
+import org.gnunet.construct.Construct.NumFieldType;
 import org.gnunet.messages.Message;
 
 /**
@@ -13,43 +15,29 @@
  * 
  */
 public class ByteFillParser extends FieldParser {
-    private FieldParser p;
-
     private List<Field> totalSizePath;
+    
+    private NumFieldType totalSizeFieldType;
 
     public ByteFillParser(List<Field> totalSizePath, Field field) {
         super(field);
         this.totalSizePath = totalSizePath;
+        totalSizeFieldType = 
Construct.getNumFieldType(totalSizePath.get(totalSizePath.size() -1 ));
     }
 
     @Override
     public int getSize(final Message src) {
         return Array.getLength(getFieldValue(src));
     }
-
+    
     private int getSizeFieldValue(Message m) {
-        Object obj = m;
-        for (Field f : totalSizePath) {
-
-            try {
-                obj = f.get(obj);
-            } catch (IllegalArgumentException e) {
-                throw new RuntimeException();
-            } catch (IllegalAccessException e) {
-                throw new RuntimeException();
-            }
-        }
+        Object obj = Construct.followFieldPath(totalSizePath, m);
         return ((Number) obj).intValue();
     }
 
     @Override
     public int parse(final byte[] srcData, final int offset, int frameOffset,
             final Message dst) {
-        if (frameOffset < 0) {
-            throw new RuntimeException(
-                    "cannot determine remaining message size");
-        }
-
         int remaining = getSizeFieldValue(dst) - frameOffset;
 
         byte[] a = new byte[remaining];
@@ -62,50 +50,23 @@
     }
 
     @Override
-    public int write(final byte[] dst_data, final int offset, final Message 
src) {
+    public int write(final byte[] dstData, final int offset, final Message 
src) {
         byte[] a = (byte[]) getFieldValue(src);
-        System.arraycopy(a, 0, dst_data, offset, a.length);
+        System.arraycopy(a, 0, dstData, offset, a.length);
         return a.length;
     }
 
+    
+    /**
+     * Currently every parser that uses a total size field sets the total size 
field.
+     * This works, but is very redundant.
+     */
     @Override
     public void patchSizeFields(Message m, int frameSize) {
-        Object obj = m;
-
-        for (int i = 0; i < totalSizePath.size() - 1; ++i) {
-
-            try {
-                obj = totalSizePath.get(i).get(obj);
-            } catch (IllegalArgumentException e) {
-                throw new RuntimeException();
-            } catch (IllegalAccessException e) {
-                throw new RuntimeException();
-            }
-
-        }
-
+        Object obj = Construct.followFieldPath(totalSizePath, m, 
totalSizePath.size() - 1);
         Field f = totalSizePath.get(totalSizePath.size() - 1);
 
-        // XXX: is there a better way to do this? => yes, with switch / 
NumFieldType
-        try {
-            if (f.getType().equals(Long.TYPE)) {
-                f.setLong(obj, frameSize);
-            } else if (f.getType().equals(Integer.TYPE)) {
-                f.setInt(obj, frameSize);
-            } else if (f.getType().equals(Short.TYPE)) {
-                f.setShort(obj, (short) frameSize);
-            } else if (f.getType().equals(Long.TYPE)) {
-                f.setLong(obj, frameSize);
-            } else {
-                throw new RuntimeException("unexpected target type");
-            }
-
-        } catch (IllegalArgumentException e) {
-            throw new RuntimeException(e);
-        } catch (IllegalAccessException e) {
-            throw new RuntimeException();
-        }
-
+        Construct.setNumField(f, totalSizeFieldType, obj, frameSize);
     }
 
 }

Modified: gnunet-java/src/org/gnunet/construct/parsers/FieldParser.java
===================================================================
--- gnunet-java/src/org/gnunet/construct/parsers/FieldParser.java       
2011-12-05 15:55:06 UTC (rev 18429)
+++ gnunet-java/src/org/gnunet/construct/parsers/FieldParser.java       
2011-12-05 21:29:45 UTC (rev 18430)
@@ -33,7 +33,6 @@
         }
     }
     
-    
     public void setFieldValue(final Object obj, final Object val) {
         try {
             field.set(obj, val);

Modified: gnunet-java/src/org/gnunet/construct/parsers/FillParser.java
===================================================================
--- gnunet-java/src/org/gnunet/construct/parsers/FillParser.java        
2011-12-05 15:55:06 UTC (rev 18429)
+++ gnunet-java/src/org/gnunet/construct/parsers/FillParser.java        
2011-12-05 21:29:45 UTC (rev 18430)
@@ -1,8 +1,11 @@
 package org.gnunet.construct.parsers;
 
+import java.lang.reflect.Array;
 import java.lang.reflect.Field;
 import java.util.List;
 
+import org.gnunet.construct.Construct;
+import org.gnunet.construct.Construct.NumFieldType;
 import org.gnunet.messages.Message;
 
 /**
@@ -12,37 +15,106 @@
  * 
  */
 public class FillParser extends FieldParser {
-    Parser p;
+    private Parser elemParser;
+    
+    private List<Field> totalSizePath;
 
-    public FillParser(final Parser p, final Field f) {
-        super(f);
-        this.p = p;
+    private NumFieldType totalSizeFieldType;
 
+    public FillParser(Parser p, List<Field> totalSizePath, Field field) {
+        super(field);
+        elemParser = p;
+        this.totalSizePath = totalSizePath;
+        totalSizeFieldType = Construct.getNumFieldType(totalSizePath
+                .get(totalSizePath.size() - 1));
     }
 
     @Override
     public int getSize(final Message src) {
-        // TODO Auto-generated method stub
-        return 0;
+        int size = 0;
+        final Object arr = getFieldValue(src);
+        
+        if (arr == null) {
+            throw new RuntimeException("array not initialized");
+        }
+        
+        for (int i = 0; i < Array.getLength(arr); ++i) {
+            size += elemParser.getSize((Message) Array.get(arr, i));
+        }
+        return size;
     }
 
+    private int getSizeFieldValue(Message m) {
+        Object obj = Construct.followFieldPath(totalSizePath, m);
+        return ((Number) obj).intValue();
+    }
+
     @Override
-    public int parse(final byte[] src_data, final int offset,
-            int frameOffset, final Message dst) {
-        // TODO Auto-generated method stub
-        return 0;
+    public int parse(final byte[] srcData, final int offset, int frameOffset,
+            final Message dstObj) {
+        /*
+        int remaining = getSizeFieldValue(dstObj) - frameOffset;
+
+        int elemNumber;
+        try {
+            elemNumber = ((Number) sizeField.get(dstObj)).intValue();
+        } catch (IllegalArgumentException e1) {
+            throw new RuntimeException();
+        } catch (IllegalAccessException e1) {
+            throw new RuntimeException();
+        }
+        
+        int size = 0;
+
+        final Object arr = Array.newInstance(getFieldType().getComponentType(),
+                elemNumber);
+        setFieldValue(dstObj, arr);
+
+        for (int i = 0; i < elemNumber; ++i) {
+            Message elemObj;
+            try {
+                elemObj = (Message) getFieldType().getComponentType()
+                        .newInstance();
+            } catch (final InstantiationException e) {
+                throw new RuntimeException();
+            } catch (final IllegalAccessException e) {
+                throw new RuntimeException();
+            }
+            
+            Array.set(arr, i, elemObj);
+            
+            size += elemParser.parse(srcData, offset + size,
+                    frameOffset - size, elemObj);
+        }
+
+        return size;
+        */
+        throw new UnsupportedOperationException("not yet implemented");
     }
 
     @Override
-    public int write(final byte[] dst_data, final int offset, final Message 
src) {
-        // TODO Auto-generated method stub
-        return 0;
+    public int write(final byte[] dstData, final int offset, final Message 
src) {
+        int size = 0;
+        final Object arr = getFieldValue(src);
+        for (int i = 0; i < Array.getLength(arr); ++i) {
+            size += elemParser.write(dstData, offset + size,
+                    (Message) Array.get(arr, i));
+        }
+        return size;
     }
 
+    
+    /**
+     * Currently every parser that uses a total size field sets the total size 
field.
+     * This works, but is very redundant.
+     */
     @Override
     public void patchSizeFields(Message m, int frameSize) {
-        // TODO Auto-generated method stub
-        
+        Object obj = Construct.followFieldPath(totalSizePath, m,
+                totalSizePath.size() - 1);
+        Field f = totalSizePath.get(totalSizePath.size() - 1);
+
+        Construct.setNumField(f, totalSizeFieldType, obj, frameSize);
     }
 
 }

Modified: gnunet-java/src/org/gnunet/construct/parsers/IntegerParser.java
===================================================================
--- gnunet-java/src/org/gnunet/construct/parsers/IntegerParser.java     
2011-12-05 15:55:06 UTC (rev 18429)
+++ gnunet-java/src/org/gnunet/construct/parsers/IntegerParser.java     
2011-12-05 21:29:45 UTC (rev 18430)
@@ -107,4 +107,9 @@
     public void patchSizeFields(Message m, int frameSize) {
         return;
     }
+    
+    
+    
+    
+    
 }

Modified: gnunet-java/src/org/gnunet/construct/parsers/SequenceParser.java
===================================================================
--- gnunet-java/src/org/gnunet/construct/parsers/SequenceParser.java    
2011-12-05 15:55:06 UTC (rev 18429)
+++ gnunet-java/src/org/gnunet/construct/parsers/SequenceParser.java    
2011-12-05 21:29:45 UTC (rev 18430)
@@ -11,12 +11,11 @@
  * @author Florian Dold
  *
  */
-public class SequenceParser extends FieldParser {
+public class SequenceParser implements Parser {
 
     private final List<FieldParser> childParsers = new 
LinkedList<FieldParser>();
 
-    public SequenceParser(final Field f) {
-        super(f);
+    public SequenceParser() {
     }
 
     public void add(final FieldParser p) {

Modified: 
gnunet-java/src/org/gnunet/construct/parsers/VariableSizeArrayParser.java
===================================================================
--- gnunet-java/src/org/gnunet/construct/parsers/VariableSizeArrayParser.java   
2011-12-05 15:55:06 UTC (rev 18429)
+++ gnunet-java/src/org/gnunet/construct/parsers/VariableSizeArrayParser.java   
2011-12-05 21:29:45 UTC (rev 18430)
@@ -3,17 +3,21 @@
 import java.lang.reflect.Array;
 import java.lang.reflect.Field;
 
+import org.gnunet.construct.Construct;
+import org.gnunet.construct.Construct.NumFieldType;
 import org.gnunet.messages.Message;
 
 public class VariableSizeArrayParser extends FieldParser {
     private final FieldParser elemParser;
     private Field sizeField;
+    private NumFieldType ft;
 
 
     public VariableSizeArrayParser(final FieldParser elemParser, Field 
sizeField, Field arrayField) {
         super(arrayField);
         this.elemParser = elemParser;
         this.sizeField = sizeField;
+        this.ft = Construct.getNumFieldType(sizeField);
     }
 
     @Override
@@ -82,21 +86,7 @@
     @Override
     public void patchSizeFields(Message m, int frameSize) {
         int size = Array.getLength(getFieldValue(m));
-        try {
-            if (sizeField.getType().equals(Long.TYPE)) {
-                sizeField.setLong(m, size);
-            } else if (sizeField.getType().equals(Integer.TYPE)) {
-                sizeField.setInt(m, size);
-            } else if (sizeField.getType().equals(Short.TYPE)) {
-                sizeField.setShort(m, (short) size);
-            } else {
-                throw new RuntimeException("unexpected target type");
-            }
-        } catch (IllegalArgumentException e) {
-            throw new RuntimeException(e);
-        } catch (IllegalAccessException e) {
-            throw new RuntimeException();
-        }
+        Construct.setNumField(sizeField, ft, m, size);
     }
 
 }

Modified: gnunet-java/src/org/gnunet/util/Client.java
===================================================================
--- gnunet-java/src/org/gnunet/util/Client.java 2011-12-05 15:55:06 UTC (rev 
18429)
+++ gnunet-java/src/org/gnunet/util/Client.java 2011-12-05 21:29:45 UTC (rev 
18430)
@@ -20,6 +20,8 @@
 
 package org.gnunet.util;
 
+import java.nio.channels.SocketChannel;
+
 import org.gnunet.messages.MessageHeader;
 import org.gnunet.util.Scheduler.Task;
 
@@ -27,10 +29,6 @@
  * Represents a connection to a service.
  */
 public class Client {
-    interface MessageHandler {
-
-    }
-
     public static class TransmitHandle {
         /**
          * Cancel a request for notification.
@@ -38,7 +36,6 @@
         void cancel() {
             throw new UnsupportedOperationException();
         }
-
     }
 
     /**
@@ -69,43 +66,22 @@
      * @param cfg
      *            configuration to use
      */
-    public Client(final String service_name, final Configuration c) {
-        throw new UnsupportedOperationException();
+    public Client(final String serviceName, final Configuration cfg) {
+        
+        // XXX: catch exn
+        long port =  cfg.getValueNumer(serviceName, "PORT");
+        if (port > 65535 || port <= 0) {
+            // XXX: throw something else
+            throw new RuntimeException("invalid port");
+        }
+        String hostname = cfg.getValueString(serviceName, "HOSTNAME");
+        
+        // [...]
+        
+        
     }
-
+    
     /**
-     * Ask the client to call us once the specified number of bytes are free in
-     * the transmission buffer. May call the notify method immediately if 
enough
-     * space is available.
-     * 
-     * @param sock
-     *            connection to the service
-     * @param size
-     *            number of bytes to send
-     * @param timeout
-     *            after how long should we give up (and call notify with buf
-     *            NULL and size 0)?
-     * @param auto_retry
-     *            if the connection to the service dies, should we 
automatically
-     *            re-connect and retry (within the timeout period) or should we
-     *            immediately fail in this case? Pass GNUNET_YES if the caller
-     *            does not care about temporary connection errors, for example
-     *            because the protocol is stateless
-     * @param notify
-     *            function to call
-     * @param notify_cls
-     *            closure for notify
-     * @return NULL if someone else is already waiting to be notified non-NULL
-     *         if the notify callback was queued (can be used to cancel using
-     *         GNUNET_CONNECTION_notify_transmit_ready_cancel)
-     */
-    public TransmitHandle notifyTransmitReady(final int size,
-            final RelativeTime timeout, final boolean auto_retry,
-            final TransmitReadyNotify cb) {
-        throw new UnsupportedOperationException();
-    }
-
-    /**
      * Read from the service.
      * 
      * @param handler
@@ -117,37 +93,7 @@
     public void receive(final MessageHandler handler, final RelativeTime 
timeout) {
         throw new UnsupportedOperationException();
     }
-
-    /**
-     * Convenience API that combines sending a request to the service and
-     * waiting for a response. If either operation times out, the callback will
-     * be called with a "NULL" response (in which case the connection should
-     * probably be destroyed).
-     * 
-     * @param sock
-     *            connection to use
-     * @param hdr
-     *            message to transmit
-     * @param timeout
-     *            when to give up (for both transmission and for waiting for a
-     *            response)
-     * @param auto_retry
-     *            if the connection to the service dies, should we 
automatically
-     *            re-connect and retry (within the timeout period) or should we
-     *            immediately fail in this case? Pass GNUNET_YES if the caller
-     *            does not care about temporary connection errors, for example
-     *            because the protocol is stateless
-     * @param rn
-     *            function to call with the response
-     * @param rn_cls
-     *            closure for rn
-     * @return GNUNET_OK on success, GNUNET_SYSERR if a request is already
-     *         pending
-     */
-    // XXX return type bool vs. exceptions
-    public boolean transmitAndGetResponse(final MessageHeader m,
-            final RelativeTime timeout, final boolean autoRetry,
-            final MessageHandler handler) {
-        throw new UnsupportedOperationException();
-    }
+    
+    // public TransmitHandle transmit(Message m, RelativeTime timeout, boolean 
autoRetry, )
+    
 }

Deleted: gnunet-java/src/org/gnunet/util/TransmitReadyNotify.java
===================================================================
--- gnunet-java/src/org/gnunet/util/TransmitReadyNotify.java    2011-12-05 
15:55:06 UTC (rev 18429)
+++ gnunet-java/src/org/gnunet/util/TransmitReadyNotify.java    2011-12-05 
21:29:45 UTC (rev 18430)
@@ -1,37 +0,0 @@
-/*
-     This file is part of GNUnet.
-     (C) 2009 Christian Grothoff (and other contributing authors)
-
-     GNUnet is free software; you can redistribute it and/or modify
-     it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 2, or (at your
-     option) any later version.
-
-     GNUnet is distributed in the hope that it will be useful, but
-     WITHOUT ANY WARRANTY; without even the implied warranty of
-     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-     General Public License for more details.
-
-     You should have received a copy of the GNU General Public License
-     along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-     Boston, MA 02111-1307, USA.
- */
-
-package org.gnunet.util;
-
-import java.nio.ByteBuffer;
-
-public interface TransmitReadyNotify {
-
-    /**
-     * Called when a socket is ready to send more date.
-     * 
-     * @param buf
-     * @return
-     */
-    // (buffer is initially at mark, data up to limit can be send at once,
-    // capacity may not be exceeded
-    public void transmit(ByteBuffer buf);
-
-}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]