Index: orxonox/branches/updater/src/gui/orxonox_gui_update.cc
===================================================================
--- orxonox/branches/updater/src/gui/orxonox_gui_update.cc	(revision 3269)
+++ orxonox/branches/updater/src/gui/orxonox_gui_update.cc	(revision 3270)
@@ -30,9 +30,5 @@
 #include "orxonox_gui.h"
 #include <stdio.h>
-#ifdef HAVE_CURL
-#include <curl/curl.h>
-#include <curl/types.h>
-#include <curl/easy.h>
-#endif /* HAVE_CURL */
+
 using namespace std;
 
@@ -94,6 +90,6 @@
 #ifdef HAVE_GTK2 
   updateDataWindowButton->connectSignal("button_press_event", updateDataWindow, Window::windowOpen);
-  updateDataWindow->connectSignal("destroy", updateDataWindow, Window::windowClose);
-  updateDataWindow->connectSignal("delete_event", updateDataWindow, Window::windowClose);
+  updateDataWindow->connectSignal("destroy", updateDataWindow, cancelDownload);
+  updateDataWindow->connectSignal("delete_event", updateDataWindow, cancelDownload);
 #endif /* HAVE_GTK2 */
 
@@ -194,4 +190,5 @@
 }
 
+CURL* OrxonoxGuiUpdate::curlHandle = NULL;
 
 void* OrxonoxGuiUpdate::download (void* fileInfo)
@@ -200,8 +197,7 @@
   PRINTF(3)("Downloading.\n");
   FileInfo* info = (FileInfo*)fileInfo;
-  CURL* curl;
   CURLcode res;
   FILE* outfile;
-  curl = curl_easy_init();
+  curlHandle = curl_easy_init();
   char* fileOnNet = new char [strlen(info->webRoot)+strlen(info->fileName)+1];
   strcpy (fileOnNet, info->webRoot);
@@ -211,20 +207,21 @@
   strcat (fileOnDisk, info->fileName);
 
-  if(curl)
+  if(curlHandle)
     {
       outfile = fopen(fileOnDisk, "w");
       
-      curl_easy_setopt(curl, CURLOPT_URL, fileOnNet);
-      curl_easy_setopt(curl, CURLOPT_WRITEDATA, outfile);
-      curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curlWriteFunc);
-      curl_easy_setopt(curl, CURLOPT_READFUNCTION, curlReadFunc);
-      curl_easy_setopt(curl, CURLOPT_NOPROGRESS, FALSE);
-      curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, curlProgressFunc);
-      curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, info->Bar);
+      curl_easy_setopt(curlHandle, CURLOPT_URL, fileOnNet);
+      curl_easy_setopt(curlHandle, CURLOPT_WRITEDATA, outfile);
+      curl_easy_setopt(curlHandle, CURLOPT_WRITEFUNCTION, curlWriteFunc);
+      curl_easy_setopt(curlHandle, CURLOPT_READFUNCTION, curlReadFunc);
+      curl_easy_setopt(curlHandle, CURLOPT_NOPROGRESS, FALSE);
+      curl_easy_setopt(curlHandle, CURLOPT_PROGRESSFUNCTION, curlProgressFunc);
+      curl_easy_setopt(curlHandle, CURLOPT_PROGRESSDATA, info->Bar);
       
-      res = curl_easy_perform(curl);
+      res = curl_easy_perform(curlHandle);
       
       fclose(outfile);
-      curl_easy_cleanup(curl);
+      if (curlHandle)
+	curl_easy_cleanup(curlHandle);
     }
   return NULL;
@@ -234,120 +231,8 @@
 gint OrxonoxGuiUpdate::cancelDownload(GtkWidget* w, GdkEventKey* event, void* bar)
 {
+  //  curl_easy_cleanup(curlHandle);
+  //  curlHandle = NULL;
 }
 #endif /* HAVE_GTK2 */
 
 #endif /* HAVE_CURL */
-
-
-/*
- int main(int argc, char **argv)
- {
-   GtkWidget *Window, *Frame, *Frame2;
-   GtkAdjustment *adj;
-   
-   // Init thread 
-   g_thread_init(NULL);
-   gtk_init(&argc, &argv);
-   Window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-   Frame = gtk_frame_new(NULL);
-   gtk_frame_set_shadow_type(GTK_FRAME(Frame), GTK_SHADOW_OUT);
-   gtk_container_add(GTK_CONTAINER(Window), Frame);
-   Frame2 = gtk_frame_new(NULL);
-   gtk_frame_set_shadow_type(GTK_FRAME(Frame2), GTK_SHADOW_IN);
-   gtk_container_add(GTK_CONTAINER(Frame), Frame2);
-   gtk_container_set_border_width(GTK_CONTAINER(Frame2), 5);
-   adj = (GtkAdjustment*)gtk_adjustment_new(0, 0, 100, 0, 0, 0);
-   Bar = gtk_progress_bar_new_with_adjustment(adj);
-   gtk_container_add(GTK_CONTAINER(Frame2), Bar);
-   gtk_widget_show_all(Window);
- 
-   if (!g_thread_create(&my_thread, argv[1], FALSE, NULL) != 0)
-     g_warning("can't create the thread");
- 
- 
-   gdk_threads_enter();
-   gtk_main();
-  gdk_threads_leave();
-   return 0;
- }
-
-
-
-
-
-size_t writeFunc(void *ptr, size_t size, size_t nmemb, FILE *stream)
- {
-   return fwrite(ptr, size, nmemb, stream);
- }
- 
- size_t my_read_func(void *ptr, size_t size, size_t nmemb, FILE *stream)
- {
-   return fread(ptr, size, nmemb, stream);
- }
- 
- int my_progress_func(GtkWidget *Bar,
-                      double t, // dltotal 
-                      double d, // dlnow 
-                      double ultotal,
-                      double ulnow)
- {
-   gdk_threads_enter();
-   gtk_progress_set_value(GTK_PROGRESS(Bar), d*100.0/t);
-   gdk_threads_leave();
-   return 0;
- }
-
- void *my_thread(void *ptr)
- {
-   CURL *curl;
-   CURLcode res;
-   FILE *outfile;
-   gchar *url = ptr;
- 
-   curl = curl_easy_init();
-   if(curl)
-   {
-     outfile = fopen("test.curl", "w");
- 
-     curl_easy_setopt(curl, CURLOPT_URL, url);
-     curl_easy_setopt(curl, CURLOPT_WRITEDATA, outfile);
-     curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_write_func);
-     curl_easy_setopt(curl, CURLOPT_READFUNCTION, my_read_func);
-     curl_easy_setopt(curl, CURLOPT_NOPROGRESS, FALSE);
-     curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, my_progress_func);
-     curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, Bar);
- 
-     res = curl_easy_perform(curl);
- 
-     fclose(outfile);
-     curl_easy_cleanup(curl);
-   }
- 
-   return NULL;
- }
- 
-*/
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Index: orxonox/branches/updater/src/gui/orxonox_gui_update.h
===================================================================
--- orxonox/branches/updater/src/gui/orxonox_gui_update.h	(revision 3269)
+++ orxonox/branches/updater/src/gui/orxonox_gui_update.h	(revision 3270)
@@ -9,4 +9,9 @@
 #include "orxonox_gui.h"
 #include <stdio.h>
+#ifdef HAVE_CURL
+#include <curl/curl.h>
+#include <curl/types.h>
+#include <curl/easy.h>
+#endif /* HAVE_CURL */
 using namespace std;
 
@@ -53,4 +58,5 @@
   static int curlProgressFunc (ProgressBar* Bar, double totalSize, double progress, double upTotal, double upProgress);
 
+  static CURL* curlHandle;
   static void* download (void* fileInfo);
 #ifdef HAVE_GTK2 
