Index: orxonox/branches/updater/configure
===================================================================
--- orxonox/branches/updater/configure	(revision 3273)
+++ orxonox/branches/updater/configure	(revision 3274)
@@ -6970,4 +6970,5 @@
 
 ##checking for pthread
+if test x$have_gthread = xyes ; then
 
 for ac_header in pthread.h
@@ -7122,5 +7123,5 @@
 done
 
-echo "$as_me:$LINENO: checking for main in -lpthread" >&5
+  echo "$as_me:$LINENO: checking for main in -lpthread" >&5
 echo $ECHO_N "checking for main in -lpthread... $ECHO_C" >&6
 if test "${ac_cv_lib_pthread_main+set}" = set; then
@@ -7184,8 +7185,8 @@
 fi
 
- if test "$FOUND_pthread" = "yes" ; then
-    LIBS="$LIBS -lpthread"
- fi
-
+   if test "$FOUND_pthread" = "yes" ; then
+      LIBS="$LIBS -lpthread"
+   fi
+fi
 
 # FIXME: Replace `main' with a function in `-lm':
Index: orxonox/branches/updater/configure.ac
===================================================================
--- orxonox/branches/updater/configure.ac	(revision 3273)
+++ orxonox/branches/updater/configure.ac	(revision 3274)
@@ -404,10 +404,11 @@
 
 ##checking for pthread
-AC_CHECK_HEADERS([pthread.h], pthreadHeader="yes", pthreadHeader="no")
-AC_CHECK_LIB([pthread], [main], FOUND_pthread=yes)
- if test "$FOUND_pthread" = "yes" ; then
-    LIBS="$LIBS -lpthread"
- fi
-
+if test x$have_gthread = xyes ; then
+  AC_CHECK_HEADERS([pthread.h], pthreadHeader="yes", pthreadHeader="no")
+  AC_CHECK_LIB([pthread], [main], FOUND_pthread=yes)
+   if test "$FOUND_pthread" = "yes" ; then
+      LIBS="$LIBS -lpthread"
+   fi
+fi
 
 # FIXME: Replace `main' with a function in `-lm':
Index: orxonox/branches/updater/src/Makefile.in
===================================================================
--- orxonox/branches/updater/src/Makefile.in	(revision 3273)
+++ orxonox/branches/updater/src/Makefile.in	(revision 3274)
@@ -282,7 +282,7 @@
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/Makefile'; \
 	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --gnu  src/Makefile
+	  $(AUTOMAKE) --foreign  src/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
Index: orxonox/branches/updater/src/console/Makefile.in
===================================================================
--- orxonox/branches/updater/src/console/Makefile.in	(revision 3273)
+++ orxonox/branches/updater/src/console/Makefile.in	(revision 3274)
@@ -201,7 +201,7 @@
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/console/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/console/Makefile'; \
 	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --gnu  src/console/Makefile
+	  $(AUTOMAKE) --foreign  src/console/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
Index: orxonox/branches/updater/src/gui/Makefile.in
===================================================================
--- orxonox/branches/updater/src/gui/Makefile.in	(revision 3273)
+++ orxonox/branches/updater/src/gui/Makefile.in	(revision 3274)
@@ -232,7 +232,7 @@
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/gui/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/gui/Makefile'; \
 	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --gnu  src/gui/Makefile
+	  $(AUTOMAKE) --foreign  src/gui/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
Index: orxonox/branches/updater/src/gui/orxonox_gui_update.cc
===================================================================
--- orxonox/branches/updater/src/gui/orxonox_gui_update.cc	(revision 3273)
+++ orxonox/branches/updater/src/gui/orxonox_gui_update.cc	(revision 3274)
@@ -81,6 +81,10 @@
   updateDataBox->fill(updateDataBar);
 
-  updateDataBegin = new Button ("begin Download");
-  updateDataBegin->connectSignal ("button_press_event", updateDataBar, updateDataFunc);
+  FileInfo* dataInfo = new FileInfo;
+  dataInfo->bar = updateDataBar;
+
+  updateDataBegin = new Button ("begin.");
+  dataInfo->stateButton = updateDataBegin;
+  dataInfo->buttonSignal = updateDataBegin->connectSignal ("button_press_event", dataInfo, updateDataFunc);
   updateDataBox->fill(updateDataBegin);
 
@@ -145,23 +149,13 @@
    \param button The Button, that triggered this event.
 */
-gint OrxonoxGuiUpdate::updateDataFunc(GtkWidget* w, GdkEventKey* event, void* bar)
-{
-  FileInfo* info = new FileInfo;
-
-  info->fileName = "02%20orxonox%203.mp3";
-  info->webRoot  = "http://www.orxonox.ethz.ch/files/";
-  info->localRoot = "./";
-  info->Bar = (ProgressBar*)bar;
-  PRINTF(3)("Preparing to download file %s.\n", info->fileName);
-  download (info);
-  /*
-  if (downloadThreadID == NULL)
-    {
-      if ( (downloadThreadID =g_thread_create(&downloadThread, info, TRUE, NULL)) == 0 )
-	PRINTF(1)("can't create the thread");
-    }
-  else 
-  PRINTF(1)("thread already in use\n");
-  */
+gint OrxonoxGuiUpdate::updateDataFunc(GtkWidget* w, GdkEventKey* event, void* info)
+{
+  FileInfo* dataInfo = (FileInfo*)info;
+
+  dataInfo->fileName = "02%20orxonox%203.mp3";
+  dataInfo->webRoot  = "http://www.orxonox.ethz.ch/files/";
+  dataInfo->localRoot = "./";
+  PRINTF(3)("Preparing to download file %s.\n", dataInfo->fileName);
+  download (dataInfo);
 }
 
@@ -196,11 +190,13 @@
   Bar->setProgress(progress);
   Bar->setTotalSize(totalSize);
+#ifdef HAVE_GTK2
+#ifndef HAVE_PTHREAD_H
+  while(gtk_events_pending()) gtk_main_iteration();
+#endif
+#endif
   return 0;
-
-}
-
-#ifdef HAVE_CURL
+}
+
 CURL* OrxonoxGuiUpdate::curlHandle = NULL;
-#endif /* HAVE_CURL */
 
 #ifdef HAVE_PTHREAD_H
@@ -209,7 +205,11 @@
 bool OrxonoxGuiUpdate::isDownloading = false;
 
-void* OrxonoxGuiUpdate::download (void* fileInfo)
-{
-  
+bool OrxonoxGuiUpdate::download (void* fileInfo)
+{
+  if (isDownloading)
+    {
+      PRINTF(2)("unable to Download. already getting some file\n");
+      return false;
+    }
   PRINTF(3)("Downloading.\n");
   FileInfo* info = (FileInfo*)fileInfo;
@@ -227,5 +227,5 @@
       
       info->fileHandle = fopen(fileOnDisk, "w");
-
+      
       curl_easy_setopt(curlHandle, CURLOPT_URL, fileOnNet);
       curl_easy_setopt(curlHandle, CURLOPT_WRITEDATA, info->fileHandle);
@@ -234,5 +234,5 @@
       curl_easy_setopt(curlHandle, CURLOPT_NOPROGRESS, FALSE);
       curl_easy_setopt(curlHandle, CURLOPT_PROGRESSFUNCTION, curlProgressFunc);
-      curl_easy_setopt(curlHandle, CURLOPT_PROGRESSDATA, info->Bar);
+      curl_easy_setopt(curlHandle, CURLOPT_PROGRESSDATA, info->bar);
 
       if (!isDownloading)
@@ -241,40 +241,70 @@
 #ifdef HAVE_PTHREAD_H
 	  pthread_create(downloadThreadID, NULL, downloadThread, info);
+
+	  pthread_t finish;
+	  pthread_create(&finish, NULL, downloadThreadFinished, info);  
 #else
 	  downloadThread(info);
+	  downloadThreadFinished(info);
 #endif /* HAVE_PTHREAD_H */
 	 
-	  //      else 
-	  //	PRINTF(1)("thread already in use\n");
 	  //      res = curl_easy_perform(curlHandle);
 	  
 	  //      fclose(outfile);
 	}
+      else 
+	PRINTF(1)("thread already in use\n");
+
     }
-  return NULL;
+  return true;
 }
 void* OrxonoxGuiUpdate::downloadThread(void* fileInfo)
 {
+  pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
+  gdk_threads_enter();
   isDownloading = true;
-
   FileInfo* info = (FileInfo*)fileInfo;
+  info->stateButton->disconnectSignal(info->buttonSignal);
+  info->buttonSignal = info->stateButton->connectSignal("button_press_event", info, cancelDownload);
+  info->stateButton->setTitle("cancel");
+  gdk_threads_leave();
+  pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
+
   curl_easy_perform(curlHandle);
+ 
+}
+
+void* OrxonoxGuiUpdate::downloadThreadFinished(void* fileInfo)
+{ 
+  FileInfo* info = (FileInfo*)fileInfo;
+#ifdef HAVE_PTHREAD_H
+  pthread_join (*downloadThreadID, NULL);
+#endif /* HAVE_PTHREAD_H */
+  gdk_threads_enter();
   if (curlHandle)
     curl_easy_cleanup(curlHandle);
-#ifdef HAVE_PTHREAD_H
-  pthread_join(*downloadThreadID, NULL);
-#endif /* HAVE_PTHREAD_H */
+ 
   PRINTF(3)("Closing the downloaded file.\n");
   fclose(info->fileHandle);
 
+  if (isDownloading)
+    info->stateButton->setTitle("go on");
+  //  else
+  //    info->stateButton->setTitle("done");
+  info->stateButton->disconnectSignal(info->buttonSignal);
+  info->buttonSignal = info->stateButton->connectSignal("button_press_event", info, updateDataFunc);
   isDownloading = false;
-}
-
+  gdk_threads_leave();
+
+}
 
 #ifdef HAVE_GTK2
 gint OrxonoxGuiUpdate::cancelDownload(GtkWidget* w, GdkEventKey* event, void* bar)
 {
-  //  curl_easy_cleanup(curlHandle);
-  //  curlHandle = NULL;
+#ifdef HAVE_PTHREAD_H
+  pthread_cancel(*downloadThreadID);
+#else
+  PRINTF(2)("Cannot cancle the Downloading process until after this File, because no threading was enabled");
+#endif /* HAVE_PTHREAD_H*/
 }
 #endif /* HAVE_GTK2 */
Index: orxonox/branches/updater/src/gui/orxonox_gui_update.h
===================================================================
--- orxonox/branches/updater/src/gui/orxonox_gui_update.h	(revision 3273)
+++ orxonox/branches/updater/src/gui/orxonox_gui_update.h	(revision 3274)
@@ -42,6 +42,6 @@
   
 #ifdef HAVE_GTK2 
-  static gint updateDataFunc (GtkWidget* w, GdkEventKey* event, void* bar);
-  static gint updateSourceFunc (GtkWidget* w, GdkEventKey* event, void* bar);
+  static gint updateDataFunc (GtkWidget* w, GdkEventKey* event, void* info);
+  static gint updateSourceFunc (GtkWidget* w, GdkEventKey* event, void* info);
 #endif /* HAVE_GTK2 */
 
@@ -55,5 +55,7 @@
     FILE* fileHandle;     //!< A fileHandler.
 
-    ProgressBar* Bar;     //!< The ProgressBar, that sould be updated.
+    Button* stateButton;  //!< A button that shows either start or cancel;
+    long int buttonSignal;//!< The Signal of the stateButton.
+    ProgressBar* bar;     //!< The ProgressBar, that sould be updated.
   };
 
@@ -71,7 +73,7 @@
   static bool isDownloading;
 
-  static void* download (void* fileInfo);
+  static bool download (void* fileInfo);
   static void* downloadThread (void* fileInfo);
-  static void* downloadThreadFinished(void* outfile);
+  static void* downloadThreadFinished(void* fileInfo);
 
   
Index: orxonox/branches/updater/src/importer/Makefile.in
===================================================================
--- orxonox/branches/updater/src/importer/Makefile.in	(revision 3273)
+++ orxonox/branches/updater/src/importer/Makefile.in	(revision 3274)
@@ -208,7 +208,7 @@
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/importer/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/importer/Makefile'; \
 	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --gnu  src/importer/Makefile
+	  $(AUTOMAKE) --foreign  src/importer/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
