Index: branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.DeploymentService.AdminClient/PluginListView.cs
===================================================================
--- branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.DeploymentService.AdminClient/PluginListView.cs	(revision 2804)
+++ branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.DeploymentService.AdminClient/PluginListView.cs	(revision 2816)
@@ -9,10 +9,15 @@
 using HeuristicLab.MainForm;
 using HeuristicLab.PluginInfrastructure;
+using PluginDeploymentService = HeuristicLab.PluginInfrastructure.Advanced.DeploymentService;
+using HeuristicLab.PluginInfrastructure.Manager;
+using System.ServiceModel;
+using ICSharpCode.SharpZipLib.Zip;
+using System.IO;
 
 namespace HeuristicLab.DeploymentService.AdminClient {
   public partial class PluginListView : HeuristicLab.MainForm.WindowsForms.View {
-    private List<ListViewItem> localPlugins;
-    private List<ListViewItem> serverPlugins;
+    private Dictionary<IPluginDescription, PluginDeploymentService.PluginDescription> localAndServerPlugins;
     private BackgroundWorker pluginUploadWorker;
+    private BackgroundWorker updateServerPluginsWorker;
 
     public PluginListView() {
@@ -20,6 +25,9 @@
       Caption = "Plugins";
 
-      localPlugins = new List<ListViewItem>();
-      serverPlugins = new List<ListViewItem>();
+      using (var client = new PluginDeploymentService.UpdateClient()) {
+        serverUrlTextBox.Text = client.Endpoint.Address.ToString();
+      }
+
+      localAndServerPlugins = new Dictionary<IPluginDescription, PluginDeploymentService.PluginDescription>();
 
       pluginUploadWorker = new BackgroundWorker();
@@ -27,5 +35,53 @@
       pluginUploadWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(pluginUploadWorker_RunWorkerCompleted);
 
-      UpdateLocalPlugins();
+      updateServerPluginsWorker = new BackgroundWorker();
+      updateServerPluginsWorker.DoWork += new DoWorkEventHandler(updateServerPluginsWorker_DoWork);
+      updateServerPluginsWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(updateServerPluginsWorker_RunWorkerCompleted);
+    }
+
+    void updateServerPluginsWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) {
+      if (!e.Cancelled && e.Result != null) {
+        UpdateLocalPlugins();
+        var plugins = (PluginDeploymentService.PluginDescription[])e.Result;
+        foreach (var plugin in plugins) {
+          var matchingLocalPlugin = (from localPlugin in localAndServerPlugins.Keys
+                                     where localPlugin.Name == plugin.Name
+                                     where localPlugin.Version == localPlugin.Version
+                                     select localPlugin).SingleOrDefault();
+          if (matchingLocalPlugin != null) {
+            localAndServerPlugins[matchingLocalPlugin] = plugin;
+          }
+        }
+        UpdatePluginList();
+        OnConnected();
+      } else {
+        OnDisconnected();
+      }
+      Cursor = Cursors.Default;
+    }
+
+    private void UpdatePluginList() {
+      listView.Items.Clear();
+      foreach (var pair in localAndServerPlugins) {
+        var item = MakeListViewItem(pair.Key);
+        listView.Items.Add(item);
+      }
+    }
+
+    void updateServerPluginsWorker_DoWork(object sender, DoWorkEventArgs e) {
+      try {
+        using (var client = new PluginDeploymentService.UpdateClient()) {
+          e.Result = client.GetPlugins();
+          e.Cancel = false;
+        }
+      }
+      catch (EndpointNotFoundException ex) {
+        e.Result = null;
+        e.Cancel = true;
+      }
+      catch (FaultException ex) {
+        e.Result = null;
+        e.Cancel = true;
+      }
     }
 
@@ -36,15 +92,31 @@
     void pluginUploadWorker_DoWork(object sender, DoWorkEventArgs e) {
       var selectedPlugins = (IEnumerable<IPluginDescription>)e.Argument;
-      AdminService.AdminClient adminClient = new HeuristicLab.DeploymentService.AdminClient.AdminService.AdminClient();
-
-      foreach (var plugin in IteratePlugins(selectedPlugins)) {
-        adminClient.DeployPlugin(MakePluginDescription(plugin), new byte[0]);
-      }
-    }
-
-    private HeuristicLab.PluginInfrastructure.PluginUpdateService.PluginDescription MakePluginDescription(IPluginDescription plugin) {
+      using (PluginDeploymentService.AdminClient adminClient = new PluginDeploymentService.AdminClient()) {
+
+        foreach (var plugin in IteratePlugins(selectedPlugins)) {
+          adminClient.DeployPlugin(MakePluginDescription(plugin), CreateZipPackage(plugin));
+        }
+      }
+    }
+
+    private byte[] CreateZipPackage(IPluginDescription plugin) {
+      using (MemoryStream stream = new MemoryStream()) {
+        ZipFile zipFile = new ZipFile(stream);
+        zipFile.BeginUpdate();
+        foreach (var file in plugin.Files) {
+          zipFile.Add(file.Name);
+        }
+        zipFile.CommitUpdate();
+        stream.Seek(0, SeekOrigin.Begin);
+        return stream.GetBuffer();
+      }
+    }
+
+    private PluginDeploymentService.PluginDescription MakePluginDescription(IPluginDescription plugin) {
       var dependencies = from dep in plugin.Dependencies
                          select MakePluginDescription(dep);
-      return new HeuristicLab.PluginInfrastructure.PluginUpdateService.PluginDescription(plugin.Name, plugin.Version, dependencies);
+      if (string.IsNullOrEmpty(plugin.ContactName) || string.IsNullOrEmpty(plugin.ContactEmail)) {
+        return new PluginDeploymentService.PluginDescription(plugin.Name, plugin.Version, dependencies);
+      } else return new PluginDeploymentService.PluginDescription(plugin.Name, plugin.Version, dependencies, plugin.ContactName + ", " + plugin.ContactEmail, plugin.LicenseText);
     }
 
@@ -59,70 +131,40 @@
 
     public void UpdateLocalPlugins() {
-      localPlugins.ForEach(x => listView.Items.Remove(x));
-      localPlugins.Clear();
+      localAndServerPlugins.Clear();
+
       foreach (var plugin in ApplicationManager.Manager.Plugins) {
-        var item = MakeListViewItem(plugin);
-        item.Group = listView.Groups["Local plugins"];
-        listView.Items.Add(item);
-        localPlugins.Add(item);
-      }
-    }
-
-    public void UpdateServerPlugins() {
-      serverPlugins.ForEach(x => listView.Items.Remove(x));
-      serverPlugins.Clear();
-      var client = new HeuristicLab.PluginInfrastructure.PluginUpdateService.UpdateClient();
-      foreach (var plugin in client.GetPlugins()) {
-        var item = MakeListViewItem(plugin);
-        item.Group = listView.Groups["Server plugins"];
-        listView.Items.Add(item);
-        localPlugins.Add(item);
-      }
-    }
-
-    private static ListViewItem MakeListViewItem(HeuristicLab.PluginInfrastructure.PluginUpdateService.PluginDescription plugin) {
-      ListViewItem item = new ListViewItem(new string[] { plugin.Name, plugin.Version.ToString() });
+        localAndServerPlugins.Add(plugin, null);
+      }
+    }
+
+
+    private ListViewItem MakeListViewItem(IPluginDescription plugin) {
+      ListViewItem item;
+      if (localAndServerPlugins[plugin] != null) {
+        item = new ListViewItem(new string[] { plugin.Name, plugin.Version.ToString(), localAndServerPlugins[plugin].Version.ToString() });
+      } else {
+        item = new ListViewItem(new string[] { plugin.Name, plugin.Version.ToString(), string.Empty });
+      }
       item.Tag = plugin;
       return item;
     }
 
-    private static ListViewItem MakeListViewItem(IPluginDescription plugin) {
-      ListViewItem item = new ListViewItem(new string[] { plugin.Name, plugin.Version.ToString() });
-      item.Tag = plugin;
-      return item;
-    }
-
     private void listView_SelectedIndexChanged(object sender, EventArgs e) {
+      localPluginDetailsPanel.Controls.Clear();
+      serverPluginDetailsGroupBox.Controls.Clear();
+
       if (listView.SelectedItems.Count > 0) {
-        if (listView.SelectedItems[0].Tag is IPluginDescription) {
-          var plugin = (IPluginDescription)listView.SelectedItems[0].Tag;
-          StringBuilder strBuilder = new StringBuilder();
-
-          strBuilder.Append("Name: ").AppendLine(plugin.Name);
-          strBuilder.Append("Version: ").AppendLine(plugin.Version.ToString());
-          strBuilder.AppendLine("Files:");
-          foreach (var file in plugin.Files) {
-            strBuilder.Append(file.Name + " " + file.Type);
-          }
-          strBuilder.AppendLine("Dependencies:");
-          foreach (var dep in plugin.Dependencies) {
-            strBuilder.Append(dep.Name + " " + dep.Version);
-          }
-          detailsTextBox.Text = strBuilder.ToString();
-        } else if (listView.SelectedItems[0].Tag is HeuristicLab.PluginInfrastructure.PluginUpdateService.PluginDescription) {
-          var plugin = (HeuristicLab.PluginInfrastructure.PluginUpdateService.PluginDescription)listView.SelectedItems[0].Tag;
-          StringBuilder strBuilder = new StringBuilder();
-
-          strBuilder.Append("Name: ").AppendLine(plugin.Name);
-          strBuilder.Append("Version: ").AppendLine(plugin.Version.ToString());
-          strBuilder.AppendLine("Dependencies:");
-          foreach (var dep in plugin.Dependencies) {
-            strBuilder.Append(dep.Name + " " + dep.Version);
-          }
-          detailsTextBox.Text = strBuilder.ToString();
-        }
-      } else {
-        detailsTextBox.Text = string.Empty;
-      }
+        var plugin = (IPluginDescription)listView.SelectedItems[0].Tag;
+        ShowPluginDetails(plugin);
+      }
+    }
+
+    private void ShowPluginDetails(IPluginDescription plugin) {
+      var localView = new LocalPluginView(plugin);
+      var serverView = new ServerPluginView(localAndServerPlugins[plugin]);
+      localView.Dock = DockStyle.Fill;
+      serverView.Dock = DockStyle.Fill;
+      localPluginDetailsPanel.Controls.Add(localView);
+      serverPluginDetailsGroupBox.Controls.Add(serverView);
     }
 
@@ -136,4 +178,32 @@
       }
     }
+
+    private void connectButton_Click(object sender, EventArgs e) {
+      OnDisconnected();
+      Cursor = Cursors.AppStarting;
+      updateServerPluginsWorker.RunWorkerAsync();
+    }
+
+    private void OnConnected() {
+      connectButton.Enabled = false;
+      serverUrlTextBox.Enabled = false;
+      label1.Enabled = false;
+
+      listView.Enabled = true;
+      uploadButton.Enabled = true;
+    }
+
+    private void OnDisconnected() {
+      connectButton.Enabled = true;
+      serverUrlTextBox.Enabled = true;
+      label1.Enabled = true;
+
+      localAndServerPlugins.Clear();
+      listView.Items.Clear();
+      localPluginDetailsPanel.Controls.Clear();
+      serverPluginDetailsGroupBox.Controls.Clear();
+      listView.Enabled = false;
+      uploadButton.Enabled = false;
+    }
   }
 }
