diff -cr freemind/freemind/main/FreeMind.java freemind.mid/freemind/main/FreeMind.java
*** freemind/freemind/main/FreeMind.java	2007-06-15 21:09:50.000000000 +0200
--- freemind.mid/freemind/main/FreeMind.java	2007-06-16 16:03:59.000000000 +0200
***************
*** 39,44 ****
--- 39,45 ----
  import java.io.InputStream;
  import java.io.OutputStream;
  import java.net.URL;
+ import java.net.URLConnection;
  import java.text.MessageFormat;
  import java.util.HashMap;
  import java.util.Map;
***************
*** 619,624 ****
--- 620,637 ----
  			// and due to a java bug:
  			// http://forum.java.sun.com/thread.jsp?forum=31&thread=363990
  		}
+ 
+ 		// <tobbe at tobbe.nu> 2007-06-16
+ 		// This enables RFC2111 mid:// URL handling to Thunderbird
+ 		// via tbremote plugin: http://www.tobbe.nu/blog/tags/RFC2111/
+ 		// Message-Id URLs are not currently handled in any browser but
+ 		// are very useful.
+ 		if (url.getProtocol().equals("mid")) {
+         URLConnection uc = url.openConnection();
+         uc.connect();
+ 				return;
+ 		}
+ 		// </tobbe at tobbe.nu>
  		// Originally, this method determined external application, with which
  		// the document
  		// should be opened. Which application should open which document type
diff -cr freemind/freemind.bat freemind.mid/freemind.bat
*** freemind/freemind.bat	2006-07-21 07:28:12.000000000 +0200
--- freemind.mid/freemind.bat	2007-06-16 15:56:46.000000000 +0200
***************
*** 1,2 ****
  @echo off
! java -cp lib\freemind.jar;lib\commons-lang-2.0.jar;lib\forms-1.0.5.jar;lib\jibx\jibx-run.jar;lib\jibx\xpp3.jar;lib\bindings.jar freemind.main.FreeMindStarter
--- 1,2 ----
  @echo off
! java -Djava.protocol.handler.pkgs=freemind.protocols -cp lib\freemind.jar;lib\commons-lang-2.0.jar;lib\forms-1.0.5.jar;lib\jibx\jibx-run.jar;lib\jibx\xpp3.jar;lib\bindings.jar freemind.main.FreeMindStarter
diff -cr freemind/freemind.sh freemind.mid/freemind.sh
*** freemind/freemind.sh	2006-10-29 21:31:53.000000000 +0100
--- freemind.mid/freemind.sh	2007-06-15 23:29:53.000000000 +0200
***************
*** 175,179 ****
  ${freedir}/lib/commons-lang-2.0.jar:\
  ${freedir}/lib/forms-1.0.5.jar:\
  ${freedir}"
! _debug "Calling: '${JAVACMD} -Dfreemind.base.dir=${freedir} -cp ${CLASSPATH} freemind.main.FreeMindStarter  $@'."
! "${JAVACMD}" -Dfreemind.base.dir="${freedir}" -cp "${CLASSPATH}" freemind.main.FreeMindStarter "$@"
--- 175,179 ----
  ${freedir}/lib/commons-lang-2.0.jar:\
  ${freedir}/lib/forms-1.0.5.jar:\
  ${freedir}"
! _debug "Calling: '${JAVACMD} -Djava.protocol.handler.pkgs=freemind.protocols -Dfreemind.base.dir=${freedir} -cp ${CLASSPATH} freemind.main.FreeMindStarter  $@'."
! "${JAVACMD}" -Djava.protocol.handler.pkgs=freemind.protocols -Dfreemind.base.dir="${freedir}" -cp "${CLASSPATH}" freemind.main.FreeMindStarter "$@"
diff -Ncr freemind/freemind/protocols/mid/Handler.java freemind.mid/freemind/protocols/mid/Handler.java
*** freemind/freemind/protocols/mid/Handler.java	1970-01-01 01:00:00.000000000 +0100
--- freemind.mid/freemind/protocols/mid/Handler.java	2007-06-01 16:48:12.000000000 +0200
***************
*** 0 ****
--- 1,35 ----
+ package freemind.protocols.mid;
+ 
+ import java.net.*;
+ import java.io.*;
+ 
+ public class Handler extends java.net.URLStreamHandler
+ {
+   protected URLConnection openConnection(URL u) throws IOException {
+     return new MIDURLConnection(u);
+   }
+   public static void main(String[] argv) {
+     String mid;
+     if (argv.length != 1) {
+       mid = "mid://465ECD9B.4030706@tobbe.nu";
+     } else {
+       mid = argv[0];
+     }
+   
+     try {
+       URL url;
+       url = new URL(mid);
+       if(url.getProtocol().equals("mid")) {
+         URLConnection uc = url.openConnection();
+         uc.connect();
+       } else {
+         System.err.println("This client only support RFC2111 mid:// URLs");
+       }
+     } catch (MalformedURLException e) {
+       e.printStackTrace();
+     } catch (IOException e) {
+       e.printStackTrace();
+     }
+  }
+ }
+ 
diff -Ncr freemind/freemind/protocols/mid/MIDURLConnection.java freemind.mid/freemind/protocols/mid/MIDURLConnection.java
*** freemind/freemind/protocols/mid/MIDURLConnection.java	1970-01-01 01:00:00.000000000 +0100
--- freemind.mid/freemind/protocols/mid/MIDURLConnection.java	2007-06-01 16:48:13.000000000 +0200
***************
*** 0 ****
--- 1,50 ----
+ package freemind.protocols.mid;
+ 
+ import java.net.*;
+ import java.io.*;
+ 
+ public class MIDURLConnection extends java.net.URLConnection
+ {
+   public final static int DEFAULT_PORT = 7055;
+   public String hostname;
+ 
+   public MIDURLConnection(URL url) throws IOException {
+     super(url);
+     hostname = "localhost";
+   }
+ /*  public MIDURLConnection getConnection(URL url) {
+     con = new MIDURLConnection(url);
+     return con;
+   }*/
+   public void setRequestHeader(String name, String value) { }
+ 
+ /*  public synchronized OutputStream getOutputStream()  throws IOException {
+     if (connected)
+       throw new ProtocolException("Already connected!");
+   }*/
+   public void connect() { 
+     Socket connection = null;
+     try {
+       connection = new Socket(hostname, DEFAULT_PORT);
+       Writer out = new OutputStreamWriter(
+        connection.getOutputStream(), "ascii"
+       );
+       out.write(url.toString());
+       out.write("\r\n");
+       out.flush();
+     } catch (IOException e) {
+       System.err.println(e);
+     }
+     finally {
+       try {
+         if (connection != null) connection.close();
+       }
+       catch (IOException e) {}
+     }
+   }
+ 
+   public String toString() {
+     return getClass().getName() + "[" + url + "]";
+   }
+ }
+ 

