Removed white "Establishing debug connection" page.
authorEugene Ostroukhov <eugeneo@symbian.org>
Wed, 14 Apr 2010 14:54:13 -0700
changeset 305 be8783adb3a8
parent 304 d92630dec325
child 306 42f09aa2b24a
child 308 c521df56b15d
Removed white "Establishing debug connection" page.
org.symbian.tools.wrttools.previewer/http-content/wrtdebugger/connectionTest.jsp
org.symbian.tools.wrttools.previewer/http-content/wrtdebugger/debugger.htm
org.symbian.tools.wrttools.previewer/http-content/wrtdebugger/debugger.jsp
org.symbian.tools.wrttools.previewer/preview/script/nokia.js
org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/HttpPreviewer.java
org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/WebAppInterface.java
org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/WebappManager.java
org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/WorkspaceResourcesServlet.java
org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/handlers/CommandResourceProvider.java
org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/handlers/DebuggerResourceProvider.java
org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/handlers/IResourceProvider.java
org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/handlers/PreferencesResourceProvider.java
org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/handlers/PreviewerStaticResourceProvider.java
org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/handlers/ProjectIndexResourceProvider.java
org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/handlers/Providers.java
org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/handlers/ResourceProvider.java
org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/handlers/WorkspaceResourceProvider.java
--- a/org.symbian.tools.wrttools.previewer/http-content/wrtdebugger/connectionTest.jsp	Wed Apr 14 11:17:26 2010 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-<%@ page import="org.symbian.tools.wrttools.previewer.http.WebAppInterface, javax.servlet.http.HttpServletResponse" %>
-<%
-	String widget = WebAppInterface.decode(request.getParameter("widget"));
-	String id = request.getParameter("session");
-	
-	if (WebAppInterface.isConnected(widget, id)) {
-		response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
-	}
-%>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools.previewer/http-content/wrtdebugger/debugger.htm	Wed Apr 14 14:54:13 2010 -0700
@@ -0,0 +1,26 @@
+<html>
+<head>
+	<script type="text/javascript">
+		var req;
+		
+		function connect() {
+			req = new XMLHttpRequest();
+			req.onreadystatechange = testconnection;
+			req.open("GET", "testConnection" + window.location.search, true);
+			req.send(null);
+		}
+		
+		function testconnection() {
+			if (req.readyState == 4) {
+				if (req.status != 200) {
+					window.setTimeout(connect, 200);
+				} else {
+					window.location = '../wrt_preview_main.html';
+				}
+			}
+		}
+	</script>
+</head>
+<body onload="connect()" style="color: silver;">
+
+</body>
\ No newline at end of file
--- a/org.symbian.tools.wrttools.previewer/http-content/wrtdebugger/debugger.jsp	Wed Apr 14 11:17:26 2010 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-<%@ page import="org.symbian.tools.wrttools.previewer.http.WebAppInterface" %>
-<%
-	String widget = WebAppInterface.decode(request.getParameter("widget"));
-	String id = request.getParameter("session");
-%>
-<html>
-<head>
-	<title><%=widget %></title>
-	<% WebAppInterface.connectDebugger(widget, id); %>
-	<script type="text/javascript">
-		var req;
-		
-		function connect() {
-			req = new XMLHttpRequest();
-			req.onreadystatechange = testconnection;
-			req.open("GET", "<%=WebAppInterface.getAjaxUri(widget, id) %>", true);
-			req.send(null);
-		}
-		
-		function testconnection() {
-			if (req.readyState == 4) {
-				if (req.status == 200) {
-					window.setTimeout(connect, 200);
-				} else {
-					window.location = '<%=WebAppInterface.getUrl(widget, id) %>';
-				}
-			}
-		}
-	</script>
-</head>
-<body onload="connect()">
-Establishing debug connection...
-</body>
\ No newline at end of file
--- a/org.symbian.tools.wrttools.previewer/preview/script/nokia.js	Wed Apr 14 11:17:26 2010 -0700
+++ b/org.symbian.tools.wrttools.previewer/preview/script/nokia.js	Wed Apr 14 14:54:13 2010 -0700
@@ -82,7 +82,12 @@
 			}
 		}
 	
-		$('iframe')[0].src = "wrt_preview_main.html";
+		var src = "wrt_preview_main.html";
+		if (window.location.href.match(/debug\-frame\.html/gi)) {
+			src = "__sym-debug/index.html" + window.location.search;
+		}
+			
+		$('iframe')[0].src = src;
 
 		NOKIA.data.load(deviceResolutionList);
 		
--- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/HttpPreviewer.java	Wed Apr 14 11:17:26 2010 -0700
+++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/HttpPreviewer.java	Wed Apr 14 14:54:13 2010 -0700
@@ -26,6 +26,9 @@
 import org.eclipse.core.resources.IResource;
 
 public class HttpPreviewer {
+    public static final String PREVIEW_STARTING_PAGE = "preview-frame.html";
+    public static final String DEBUG_STARTING_PAGE = "debug-frame.html";
+
     public IFile getFileFromUrl(String name) {
         return WorkspaceResourcesServlet.getFileFromUrl(name);
     }
--- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/WebAppInterface.java	Wed Apr 14 11:17:26 2010 -0700
+++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/WebAppInterface.java	Wed Apr 14 14:54:13 2010 -0700
@@ -30,125 +30,119 @@
 import org.symbian.tools.wrttools.previewer.PreviewerPlugin;
 
 public class WebAppInterface {
-	private static WebAppInterface INSTANCE;
+    private static WebAppInterface INSTANCE;
 
-	public static void connectDebugger(String widget, String id) {
-		if (PreviewerPlugin.TRACE_WEBAPP) {
-			System.out.println("Connecting debugger");
-		}
-		getInstance().connect(widget, id);
-	}
+    public static void connectDebugger(String widget, String id) {
+        if (PreviewerPlugin.TRACE_WEBAPP) {
+            System.out.println("Connecting debugger");
+        }
+        getInstance().connect(widget, id);
+    }
 
-	public static String decode(String value) {
-		try {
-			return URLDecoder.decode(value, "UTF-8");
-		} catch (UnsupportedEncodingException e) {
-			throw new RuntimeException(e);
-		}
-	}
+    public static String decode(String value) {
+        try {
+            return URLDecoder.decode(value, "UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            throw new RuntimeException(e);
+        }
+    }
 
-	public static String encode(String project) {
-		try {
-			return URLEncoder.encode(project, "UTF-8");
-		} catch (UnsupportedEncodingException e) {
-			throw new RuntimeException(e);
-		}
-	}
+    public static String encode(String project) {
+        try {
+            return URLEncoder.encode(project, "UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            throw new RuntimeException(e);
+        }
+    }
 
-	public static String getAjaxUri(String widget, String id) {
-		if (PreviewerPlugin.TRACE_WEBAPP) {
-			System.out.println("getAjaxUri");
-		}
-		return getInstance().createAjaxUri(widget, id).toASCIIString();
-	}
+    public static String getAjaxUri(String widget, String id) {
+        if (PreviewerPlugin.TRACE_WEBAPP) {
+            System.out.println("getAjaxUri");
+        }
+        return getInstance().createAjaxUri(widget, id).toASCIIString();
+    }
 
-	public synchronized static WebAppInterface getInstance() {
-		if (INSTANCE == null) {
-			INSTANCE = new WebAppInterface();
-		}
-		return INSTANCE;
-	}
+    public synchronized static WebAppInterface getInstance() {
+        if (INSTANCE == null) {
+            INSTANCE = new WebAppInterface();
+        }
+        return INSTANCE;
+    }
 
-	public static String getUrl(String widget, String id) {
+    public static String getUrl(String widget, String id) {
         return getInstance().complete(widget, id).toASCIIString();
-	}
+    }
 
-	public static boolean isConnected(String widget, String id) {
-		if (PreviewerPlugin.TRACE_WEBAPP) {
-			System.out.println("isConnected");
-		}
-		return getInstance().isJobComplete(widget, id);
-	}
+    public static boolean isConnected(String widget, String id) {
+        if (PreviewerPlugin.TRACE_WEBAPP) {
+            System.out.println("isConnected");
+        }
+        return getInstance().isJobComplete(widget, id);
+    }
 
-	public static boolean isSuccessful(String widget, String id) {
-		if (PreviewerPlugin.TRACE_WEBAPP) {
-			System.out.println("isSuccessful");
-		}
-		return getInstance().isConnectionSuccessful(widget, id);
-	}
+    public static boolean isSuccessful(String widget, String id) {
+        if (PreviewerPlugin.TRACE_WEBAPP) {
+            System.out.println("isSuccessful");
+        }
+        return getInstance().isConnectionSuccessful(widget, id);
+    }
 
-	private final Map<String, BrowserConnectionJob> debuggerJobs = new TreeMap<String, BrowserConnectionJob>();
+    private final Map<String, BrowserConnectionJob> debuggerJobs = new TreeMap<String, BrowserConnectionJob>();
 
-	private WebAppInterface() {
-		try {
-			WebappManager.start("wrtbrowser");
-		} catch (Exception e) {
-			PreviewerPlugin.log(e);
-		}
-	}
+    private WebAppInterface() {
+        try {
+            WebappManager.start("wrtbrowser");
+        } catch (Exception e) {
+            PreviewerPlugin.log(e);
+        }
+    }
 
     private synchronized URI complete(String widget, String id) {
-		return WorkspaceResourcesServlet.getPreviewerStartingPage(widget);
-	}
-
-	private synchronized void connect(String widget, String id) {
-		BrowserConnectionJob listener = debuggerJobs.get(getId(widget, id));
-		listener.schedule();
-	}
+        return WorkspaceResourcesServlet.getPreviewerStartingPage(widget);
+    }
 
-	private URI createAjaxUri(String widget, String id) {
-		try {
-			return createUri("connectionTest.jsp", widget, id);
-		} catch (URISyntaxException e) {
-			PreviewerPlugin.log(e);
-			return null;
-		}
-	}
+    private synchronized void connect(String widget, String id) {
+        if (!isConnected(widget, id)) {
+            BrowserConnectionJob listener = debuggerJobs.get(getId(widget, id));
+            listener.schedule(50);
+        }
+    }
 
-	private URI createUri(String page, String project, String session)
-			throws URISyntaxException {
-		URI uri = new URI("http", null, WebappManager.getHost(), WebappManager
-				.getPort(), "/wrtdebugger/" + page, "widget=" + encode(project)
-				+ "&session=" + session, null);
-		return uri;
-	}
+    private URI createAjaxUri(String widget, String id) {
+        try {
+            return createUri("connectionTest.jsp", widget, id);
+        } catch (URISyntaxException e) {
+            PreviewerPlugin.log(e);
+            return null;
+        }
+    }
 
-	private String getId(String name, String session) {
-		return name + "$" + session;
-	}
+    private URI createUri(String page, String project, String session) throws URISyntaxException {
+        URI uri = new URI("http", null, WebappManager.getHost(), WebappManager.getPort(), "/wrtdebugger/" + page,
+                "widget=" + encode(project) + "&session=" + session, null);
+        return uri;
+    }
 
-	private boolean isJobComplete(String widget, String id) {
-		BrowserConnectionJob job = debuggerJobs.get(getId(widget, id));
-		return job.isReady();
-	}
-	
-	private boolean isConnectionSuccessful(String widget, String id) {
-		BrowserConnectionJob job = debuggerJobs.get(getId(widget, id));
-		return job.isSuccess();
-	}
+    private String getId(String name, String session) {
+        return name + "$" + session;
+    }
+
+    private boolean isJobComplete(String widget, String id) {
+        BrowserConnectionJob job = debuggerJobs.get(getId(widget, id));
+        return job.isReady();
+    }
 
-	public synchronized URI prepareDebugger(IProject project,
-			IPreviewStartupListener listener) {
-		try {
-			String session = Long.toHexString(System.currentTimeMillis());
-			URI uri = createUri("debugger.jsp", project.getName(), session);
-			if (listener != null) {
-				debuggerJobs.put(getId(project.getName(), session), new BrowserConnectionJob(listener, uri));
-			}
-			return uri;
-		} catch (URISyntaxException e) {
-			PreviewerPlugin.log(e);
-		}
-		return null;
-	}
+    private boolean isConnectionSuccessful(String widget, String id) {
+        BrowserConnectionJob job = debuggerJobs.get(getId(widget, id));
+        return job.isSuccess();
+    }
+
+    public synchronized URI prepareDebugger(IProject project, IPreviewStartupListener listener) {
+        String session = Long.toHexString(System.currentTimeMillis());
+        URI uri = WorkspaceResourcesServlet.getDebugStartingPage(project.getName(), session);
+        if (listener != null) {
+            debuggerJobs.put(getId(project.getName(), session), new BrowserConnectionJob(listener, uri));
+        }
+        return uri;
+    }
 }
--- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/WebappManager.java	Wed Apr 14 11:17:26 2010 -0700
+++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/WebappManager.java	Wed Apr 14 14:54:13 2010 -0700
@@ -26,7 +26,6 @@
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.Platform;
 import org.eclipse.equinox.http.jetty.JettyConfigurator;
-import org.eclipse.equinox.jsp.jasper.JspServlet;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.InvalidSyntaxException;
@@ -57,7 +56,6 @@
 		d.put("http.port", new Integer(getPortParameter())); //$NON-NLS-1$
 
 		// set the base URL
-//		d.put("context.path", "/wrtdebugger"); //$NON-NLS-1$ //$NON-NLS-2$
 		d.put("other.info", "org.symbian.wst.debugger"); //$NON-NLS-1$ //$NON-NLS-2$
 		
 		// suppress Jetty INFO/DEBUG messages to stderr
@@ -68,9 +66,7 @@
 		Bundle bundle = PreviewerPlugin.getDefault().getBundle();
 		HttpService service = (HttpService) bundle.getBundleContext().getService(getServiceReference());
 		HttpContext httpContext = service.createDefaultHttpContext();
-		service.registerResources(STATIC_RESOURCES_CONTEXT, WEB_CONTENT_ROOT, httpContext);
 		service.registerServlet(WORKSPACE_RESOURCES_CONTEXT, new WorkspaceResourcesServlet(), new Hashtable(), httpContext);
-		service.registerServlet(STATIC_RESOURCES_CONTEXT + "/*.jsp", new JspServlet(bundle, WEB_CONTENT_ROOT, STATIC_RESOURCES_CONTEXT + "*.jsp"), new Hashtable(), httpContext);
 	}
 	
 	/*
--- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/WorkspaceResourcesServlet.java	Wed Apr 14 11:17:26 2010 -0700
+++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/WorkspaceResourcesServlet.java	Wed Apr 14 14:54:13 2010 -0700
@@ -53,6 +53,7 @@
 import org.json.simple.parser.ParseException;
 import org.symbian.tools.wrttools.previewer.PreviewerException;
 import org.symbian.tools.wrttools.previewer.PreviewerPlugin;
+import org.symbian.tools.wrttools.previewer.http.handlers.DebuggerResourceProvider;
 import org.symbian.tools.wrttools.previewer.http.handlers.PreviewerStaticResourceProvider;
 import org.symbian.tools.wrttools.previewer.http.handlers.ProjectIndexResourceProvider;
 import org.symbian.tools.wrttools.previewer.http.handlers.Providers;
@@ -109,7 +110,7 @@
     }
 
     public static String getHttpUrl(IResource file) {
-        String uri = getServerURIForResource(file != null ? file.getFullPath().toString() : "/").toASCIIString();
+        String uri = getServerURIForResource(file != null ? file.getFullPath().toString() : "/", null).toASCIIString();
         if (uri != null) {
             return uri;
         } else {
@@ -129,8 +130,7 @@
         try {
             IPath path = getProjectRelativePath(name);
             if (path != null) {
-                if (path.segmentCount() == 2
-                        && PreviewerStaticResourceProvider.PREVIEW_STARTING_PAGE.equals(path.segment(1))) {
+                if (path.segmentCount() == 2 && HttpPreviewer.PREVIEW_STARTING_PAGE.equals(path.segment(1))) {
                     path = new Path(PreviewerStaticResourceProvider.PREVIEW_START);
                 } else if (path.segmentCount() > 2
                         && PreviewerStaticResourceProvider.PREVIEW_PATH.equals(path.segment(1))) {
@@ -153,8 +153,8 @@
     }
 
     public static URI getPreviewerStartingPage(String widget) {
-        return getServerURIForResource(new Path(widget).append(PreviewerStaticResourceProvider.PREVIEW_STARTING_PAGE)
-                .makeAbsolute().toString());
+        return getServerURIForResource(new Path(widget).append(HttpPreviewer.PREVIEW_STARTING_PAGE).makeAbsolute()
+                .toString(), null);
     }
 
     private static IPath getProjectRelativePath(String uri) {
@@ -188,32 +188,31 @@
         }
     }
 
-    private static URI getServerURIForResource(String resourcePath) {
+    private static URI getServerURIForResource(String resourcePath, String debugSessionId) {
         Path p = new Path(resourcePath);
         if (p.segmentCount() > 1) {
             IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(p.segment(0));
             try {
                 if (p.removeFirstSegments(1).toString().equals(CoreUtil.getIndexFile(project))) {
                     return getServerURIForResource(new Path(p.segment(0)).append(ProjectIndexResourceProvider.INDEX)
-                            .makeAbsolute().toString());
+                            .makeAbsolute().toString(), debugSessionId);
                 }
             } catch (Exception e1) {
                 PreviewerPlugin.log(e1);
             }
         }
-        String uri = null;
         try {
-            String path = WebappManager.WORKSPACE_RESOURCES_CONTEXT + resourcePath;
-            URL url = new URL("http", WebappManager.getHost(), WebappManager.getPort(), encode(path));
-            uri = url.toString();
+            String path = encode(WebappManager.WORKSPACE_RESOURCES_CONTEXT + resourcePath);
+            path += debugSessionId == null ? "" : (String.format("?%s=%s",
+                    DebuggerResourceProvider.DEBUG_SESSION_ID_PARAMETER, debugSessionId));
+            URL url = new URL("http", WebappManager.getHost(), WebappManager.getPort(), path);
+            return url.toURI();
         } catch (MalformedURLException e) {
-            uri = null;
+            PreviewerPlugin.log(e);
+        } catch (URISyntaxException e) {
+            PreviewerPlugin.log(e);
         }
-        try {
-            return new URI(uri);
-        } catch (URISyntaxException e) {
-            throw new RuntimeException(e);
-        }
+        return null;
     }
 
     private final Providers providers = new Providers();
@@ -285,4 +284,9 @@
         }
         resp.setStatus(HttpServletResponse.SC_OK);
     }
+
+    public static URI getDebugStartingPage(String project, String session) {
+        return getServerURIForResource(new Path(project).append(HttpPreviewer.DEBUG_STARTING_PAGE).makeAbsolute()
+                .toString(), session);
+    }
 }
--- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/handlers/CommandResourceProvider.java	Wed Apr 14 11:17:26 2010 -0700
+++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/handlers/CommandResourceProvider.java	Wed Apr 14 14:54:13 2010 -0700
@@ -28,13 +28,13 @@
 import org.json.simple.JSONObject;
 import org.symbian.tools.wrttools.previewer.PreviewerPlugin;
 
-public class CommandResourceProvider implements ResourceProvider {
+public class CommandResourceProvider implements IResourceProvider {
 
     public String[] getPaths() {
         return new String[] { "__sym_command" };
     }
 
-    public InputStream getResourceStream(IProject project, IPath resource, Map<String, String> parameters)
+    public InputStream getResourceStream(IProject project, IPath resource, Map<String, String[]> parameters)
             throws IOException, CoreException {
         if (resource.segmentCount() == 2) {
             PreviewerPlugin.getDefault().getCommandHandlerManager().handle(resource.segment(1), project.getName(),
@@ -43,7 +43,7 @@
         return null;
     }
 
-    public void post(IProject project, IPath resource, Map<String, String> parameterMap, JSONObject object)
+    public void post(IProject project, IPath resource, Map<String, String[]> parameterMap, JSONObject object)
             throws IOException, CoreException {
         // Do nothing
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/handlers/DebuggerResourceProvider.java	Wed Apr 14 14:54:13 2010 -0700
@@ -0,0 +1,82 @@
+/**
+ * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Symbian Foundation - initial contribution.
+ * Contributors:
+ * Description:
+ * Overview:
+ * Details:
+ * Platforms/Drives/Compatibility:
+ * Assumptions/Requirement/Pre-requisites:
+ * Failures and causes:
+ */
+package org.symbian.tools.wrttools.previewer.http.handlers;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Map;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.json.simple.JSONObject;
+import org.symbian.tools.wrttools.previewer.PreviewerPlugin;
+import org.symbian.tools.wrttools.previewer.http.HttpPreviewer;
+import org.symbian.tools.wrttools.previewer.http.WebAppInterface;
+
+public class DebuggerResourceProvider implements IResourceProvider {
+    public static final String DEBUG_SESSION_ID_PARAMETER = "debugSessionId";
+
+    public String[] getPaths() {
+        return new String[] { HttpPreviewer.DEBUG_STARTING_PAGE, "__sym-debug" };
+    }
+
+    public InputStream getResourceStream(IProject project, IPath resource, Map<String, String[]> parameters)
+            throws IOException, CoreException {
+        if (resource.toString().equals(HttpPreviewer.DEBUG_STARTING_PAGE)) {
+            URL url = FileLocator.find(PreviewerPlugin.getDefault().getBundle(), new Path(
+                    PreviewerStaticResourceProvider.PREVIEW_START), null);
+            if (url != null) {
+                return url.openStream();
+            }
+        } else if (resource.segmentCount() == 2) {
+            if ("index.html".equals(resource.segment(1))) {
+                String[] sessionId = parameters.get(DEBUG_SESSION_ID_PARAMETER);
+                if (sessionId != null && sessionId.length == 1) {
+                    WebAppInterface.connectDebugger(project.getName(), sessionId[0]);
+                }
+                URL url = FileLocator.find(PreviewerPlugin.getDefault().getBundle(), new Path(
+                        "http-content/wrtdebugger/debugger.htm"), null);
+                if (url != null) {
+                    return url.openStream();
+                }
+            } else if ("testConnection".equals(resource.segment(1))) {
+                String[] sessionId = parameters.get(DEBUG_SESSION_ID_PARAMETER);
+                if (sessionId != null & sessionId.length == 1) {
+                    if (!WebAppInterface.isConnected(project.getName(), sessionId[0])) {
+                        return null;
+                    }
+                }
+                return new ByteArrayInputStream("Ok".getBytes());
+            }
+        }
+        return null;
+    }
+
+    public void post(IProject project, IPath resource, Map<String, String[]> parameterMap, JSONObject object)
+            throws IOException, CoreException {
+        // TODO Auto-generated method stub
+
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/handlers/IResourceProvider.java	Wed Apr 14 14:54:13 2010 -0700
@@ -0,0 +1,37 @@
+/**
+ * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Symbian Foundation - initial contribution.
+ * Contributors:
+ * Description:
+ * Overview:
+ * Details:
+ * Platforms/Drives/Compatibility:
+ * Assumptions/Requirement/Pre-requisites:
+ * Failures and causes:
+ */
+package org.symbian.tools.wrttools.previewer.http.handlers;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.json.simple.JSONObject;
+
+public interface IResourceProvider {
+    String[] getPaths();
+    InputStream getResourceStream(IProject project, IPath resource, Map<String, String[]> parameters)
+            throws IOException,
+            CoreException;
+    void post(IProject project, IPath resource, Map<String, String[]> parameterMap, JSONObject object)
+            throws IOException, CoreException;
+}
--- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/handlers/PreferencesResourceProvider.java	Wed Apr 14 11:17:26 2010 -0700
+++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/handlers/PreferencesResourceProvider.java	Wed Apr 14 14:54:13 2010 -0700
@@ -32,12 +32,12 @@
 import org.symbian.tools.wrttools.previewer.PreviewerPlugin;
 import org.symbian.tools.wrttools.previewer.preview.ProjectPreferencesManager;
 
-public class PreferencesResourceProvider implements ResourceProvider {
+public class PreferencesResourceProvider implements IResourceProvider {
     public String[] getPaths() {
         return new String[] { "preview/preferences.js" };
     }
 
-    public InputStream getResourceStream(IProject project, IPath resource, Map<String, String> parameters)
+    public InputStream getResourceStream(IProject project, IPath resource, Map<String, String[]> parameters)
             throws IOException, CoreException {
         Properties projectPreferences = ProjectPreferencesManager.getProjectProperties(project);
         String js = getJS(projectPreferences);
@@ -58,7 +58,7 @@
         return builder.toString();
     }
 
-    public void post(IProject project, IPath resource, Map<String, String> parameterMap, JSONObject object)
+    public void post(IProject project, IPath resource, Map<String, String[]> parameterMap, JSONObject object)
             throws IOException, CoreException {
         String key = (String) object.get("key");
         String value = (String) object.get("value");
--- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/handlers/PreviewerStaticResourceProvider.java	Wed Apr 14 11:17:26 2010 -0700
+++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/handlers/PreviewerStaticResourceProvider.java	Wed Apr 14 14:54:13 2010 -0700
@@ -30,20 +30,20 @@
 import org.eclipse.core.runtime.Path;
 import org.json.simple.JSONObject;
 import org.symbian.tools.wrttools.previewer.PreviewerPlugin;
+import org.symbian.tools.wrttools.previewer.http.HttpPreviewer;
 
-public class PreviewerStaticResourceProvider implements ResourceProvider {
-    public static final String PREVIEW_STARTING_PAGE = "preview-frame.html";
-    public static final String DEBUG_STARTING_PAGE = "debug-frame.html";
+public class PreviewerStaticResourceProvider implements IResourceProvider {
     public static final String PREVIEW_PATH = "preview";
     public static final String PREVIEW_START = "/preview/wrt_preview.html";
 
     public String[] getPaths() {
-        return new String[] { PREVIEW_STARTING_PAGE, PREVIEW_PATH, DEBUG_STARTING_PAGE };
+        return new String[] { HttpPreviewer.PREVIEW_STARTING_PAGE, PREVIEW_PATH };
     }
 
-    public InputStream getResourceStream(IProject project, IPath resource, Map<String, String> parameters)
+    public InputStream getResourceStream(IProject project, IPath resource, Map<String, String[]> parameters)
             throws IOException {
-        if (PREVIEW_STARTING_PAGE.equals(resource.toString()) || DEBUG_STARTING_PAGE.equals(resource.toString())) {
+        if (HttpPreviewer.PREVIEW_STARTING_PAGE.equals(resource.toString())
+                || HttpPreviewer.DEBUG_STARTING_PAGE.equals(resource.toString())) {
             resource = new Path(PREVIEW_START);
         }
         URL url = FileLocator.find(PreviewerPlugin.getDefault().getBundle(), resource, null);
@@ -54,7 +54,7 @@
         }
     }
 
-    public void post(IProject project, IPath resource, Map<String, String> parameterMap, JSONObject object)
+    public void post(IProject project, IPath resource, Map<String, String[]> parameterMap, JSONObject object)
             throws IOException, CoreException {
         // Do nothing
     }
--- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/handlers/ProjectIndexResourceProvider.java	Wed Apr 14 11:17:26 2010 -0700
+++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/handlers/ProjectIndexResourceProvider.java	Wed Apr 14 14:54:13 2010 -0700
@@ -32,7 +32,7 @@
 import org.json.simple.JSONObject;
 import org.symbian.tools.wrttools.util.CoreUtil;
 
-public class ProjectIndexResourceProvider implements ResourceProvider {
+public class ProjectIndexResourceProvider implements IResourceProvider {
     public static final String INDEX = "wrt_preview_main.html";
     private static final Pattern HEAD_TAG_PATTERN = Pattern.compile("<head(\\s*\\w*=\"(^\")*\")*\\s*>",
             Pattern.CASE_INSENSITIVE);
@@ -42,7 +42,7 @@
         return new String[] { INDEX };
     }
 
-    public InputStream getResourceStream(IProject project, IPath resource, Map<String, String> parameters)
+    public InputStream getResourceStream(IProject project, IPath resource, Map<String, String[]> parameters)
             throws IOException, CoreException {
         return getProjectIndexPage(project.getName());
     }
@@ -65,7 +65,7 @@
         return null;
     }
 
-    public void post(IProject project, IPath resource, Map<String, String> parameterMap, JSONObject object)
+    public void post(IProject project, IPath resource, Map<String, String[]> parameterMap, JSONObject object)
             throws IOException, CoreException {
         // Do nothing
     }
--- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/handlers/Providers.java	Wed Apr 14 11:17:26 2010 -0700
+++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/handlers/Providers.java	Wed Apr 14 14:54:13 2010 -0700
@@ -44,25 +44,26 @@
  * All other URLs return workspace resources.
  */
 public class Providers {
-    private final Map<String, ResourceProvider> HANDLERS = new TreeMap<String, ResourceProvider>();
-    private final ResourceProvider defaultHandler = new WorkspaceResourceProvider();
+    private final Map<String, IResourceProvider> HANDLERS = new TreeMap<String, IResourceProvider>();
+    private final IResourceProvider defaultHandler = new WorkspaceResourceProvider();
     public Providers() {
         addPaths(new PreviewerStaticResourceProvider());
         addPaths(new PreferencesResourceProvider());
         addPaths(new ProjectIndexResourceProvider());
         addPaths(new CommandResourceProvider());
+        addPaths(new DebuggerResourceProvider());
     }
 
-    private void addPaths(ResourceProvider handler) {
+    private void addPaths(IResourceProvider handler) {
         for (String path : handler.getPaths()) {
             HANDLERS.put(path, handler);
         }
     }
 
-    public InputStream get(String url, Map<String, String> parameters) throws PreviewerException {
+    public InputStream get(String url, Map<String, String[]> parameters) throws PreviewerException {
         final IProject project = getProject(url);
         final IPath resource = new Path(url).removeFirstSegments(1);
-        final ResourceProvider provider = getHandlerForPath(resource);
+        final IResourceProvider provider = getHandlerForPath(resource);
         try {
             return provider.getResourceStream(project, resource, parameters);
         } catch (IOException e) {
@@ -72,8 +73,8 @@
         }
     }
 
-    private ResourceProvider getHandlerForPath(IPath resource) {
-        ResourceProvider provider = null;
+    private IResourceProvider getHandlerForPath(IPath resource) {
+        IResourceProvider provider = null;
         IPath mapping = resource;
         while (mapping.segmentCount() > 0) {
             provider = HANDLERS.get(mapping.toString());
@@ -100,14 +101,14 @@
         return project;
     }
 
-    public ResourceProvider getHandlerForPostPath(String url) {
+    public IResourceProvider getHandlerForPostPath(String url) {
         return null;
     }
 
-    public void post(String url, Map<String, String> parameterMap, JSONObject object) throws PreviewerException {
+    public void post(String url, Map<String, String[]> parameterMap, JSONObject object) throws PreviewerException {
         final IProject project = getProject(url);
         final IPath resource = new Path(url).removeFirstSegments(1);
-        final ResourceProvider provider = getHandlerForPath(resource);
+        final IResourceProvider provider = getHandlerForPath(resource);
         try {
             provider.post(project, resource, parameterMap, object);
         } catch (IOException e) {
--- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/handlers/ResourceProvider.java	Wed Apr 14 11:17:26 2010 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-/**
- * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
- * All rights reserved.
- * This component and the accompanying materials are made available
- * under the terms of the License "Eclipse Public License v1.0"
- * which accompanies this distribution, and is available
- * at the URL "http://www.eclipse.org/legal/epl-v10.html".
- *
- * Initial Contributors:
- * Symbian Foundation - initial contribution.
- * Contributors:
- * Description:
- * Overview:
- * Details:
- * Platforms/Drives/Compatibility:
- * Assumptions/Requirement/Pre-requisites:
- * Failures and causes:
- */
-package org.symbian.tools.wrttools.previewer.http.handlers;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Map;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.json.simple.JSONObject;
-
-public interface ResourceProvider {
-    String[] getPaths();
-    InputStream getResourceStream(IProject project, IPath resource, Map<String, String> parameters) throws IOException,
-            CoreException;
-    void post(IProject project, IPath resource, Map<String, String> parameterMap, JSONObject object)
-            throws IOException, CoreException;
-}
--- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/handlers/WorkspaceResourceProvider.java	Wed Apr 14 11:17:26 2010 -0700
+++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/handlers/WorkspaceResourceProvider.java	Wed Apr 14 14:54:13 2010 -0700
@@ -28,12 +28,12 @@
 import org.eclipse.core.runtime.IPath;
 import org.json.simple.JSONObject;
 
-public class WorkspaceResourceProvider implements ResourceProvider {
+public class WorkspaceResourceProvider implements IResourceProvider {
     public String[] getPaths() {
         return null;
     }
 
-    public InputStream getResourceStream(IProject project, IPath resource, Map<String, String> parameters)
+    public InputStream getResourceStream(IProject project, IPath resource, Map<String, String[]> parameters)
             throws IOException, CoreException {
         IFile file = project.getFile(resource);
         if (file.isAccessible()) {
@@ -43,7 +43,7 @@
         }
     }
 
-    public void post(IProject project, IPath resource, Map<String, String> parameterMap, JSONObject object)
+    public void post(IProject project, IPath resource, Map<String, String[]> parameterMap, JSONObject object)
             throws IOException, CoreException {
         // Do nothing
     }