[Refactoring] Created new FbsConnection class to manage connections to FBS and index files. Index files are not used yet.

git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2596 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/java/src/com/tightvnc/rfbplayer/RfbPlayer.java b/java/src/com/tightvnc/rfbplayer/RfbPlayer.java
index d2ae1c8..242ffde 100644
--- a/java/src/com/tightvnc/rfbplayer/RfbPlayer.java
+++ b/java/src/com/tightvnc/rfbplayer/RfbPlayer.java
@@ -130,12 +130,9 @@
     }
 
     try {
-      if (inAnApplet) {
-        url = new URL(getCodeBase(), sessionURL);
-      } else {
-        url = new URL(sessionURL);
-      }
-      newFbsConnection(initialTimeOffset);
+      java.applet.Applet applet = (inAnApplet) ? this : null;
+      FbsConnection conn = new FbsConnection(sessionURL, null, applet);
+      fbs = conn.connect(initialTimeOffset);
       rfb = new RfbProto(fbs);
 
       vc = new VncCanvas(this);
@@ -194,7 +191,7 @@
             autoPlay = false;
           }
           fbs.close();
-          newFbsConnection(newTimeOffset);
+          fbs = conn.connect(newTimeOffset);
           rfb.newSession(fbs);
           vc.updateFramebufferSize();
         } catch (NullPointerException e) {
@@ -212,20 +209,6 @@
 
   }
 
-  /**
-   * Open new connection specified by this.url, save new FbsInputStream in
-   * this.fbs.
-   *
-   * @param timeOffset set this as current time position in the newly created
-   *   FbsInputStream object.
-   * @throws java.io.IOException
-   */
-  void newFbsConnection(long timeOffset) throws IOException {
-    URLConnection connection = url.openConnection();
-    fbs = new FbsInputStream(connection.getInputStream());
-    fbs.setTimeOffset(timeOffset);
-  }
-
   public void setPausedInt(String paused) {
     // default to true (pause)
     int pause = 1;