Changeset 3274 in orxonox.OLD for orxonox/branches
- Timestamp:
- Dec 24, 2004, 11:46:56 PM (20 years ago)
- Location:
- orxonox/branches/updater
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/updater/configure
r3273 r3274 6970 6970 6971 6971 ##checking for pthread 6972 if test x$have_gthread = xyes ; then 6972 6973 6973 6974 for ac_header in pthread.h … … 7122 7123 done 7123 7124 7124 echo "$as_me:$LINENO: checking for main in -lpthread" >&57125 echo "$as_me:$LINENO: checking for main in -lpthread" >&5 7125 7126 echo $ECHO_N "checking for main in -lpthread... $ECHO_C" >&6 7126 7127 if test "${ac_cv_lib_pthread_main+set}" = set; then … … 7184 7185 fi 7185 7186 7186 if test "$FOUND_pthread" = "yes" ; then7187 LIBS="$LIBS -lpthread"7188 fi7189 7187 if test "$FOUND_pthread" = "yes" ; then 7188 LIBS="$LIBS -lpthread" 7189 fi 7190 fi 7190 7191 7191 7192 # FIXME: Replace `main' with a function in `-lm': -
orxonox/branches/updater/configure.ac
r3273 r3274 404 404 405 405 ##checking for pthread 406 AC_CHECK_HEADERS([pthread.h], pthreadHeader="yes", pthreadHeader="no") 407 AC_CHECK_LIB([pthread], [main], FOUND_pthread=yes) 408 if test "$FOUND_pthread" = "yes" ; then 409 LIBS="$LIBS -lpthread" 410 fi 411 406 if test x$have_gthread = xyes ; then 407 AC_CHECK_HEADERS([pthread.h], pthreadHeader="yes", pthreadHeader="no") 408 AC_CHECK_LIB([pthread], [main], FOUND_pthread=yes) 409 if test "$FOUND_pthread" = "yes" ; then 410 LIBS="$LIBS -lpthread" 411 fi 412 fi 412 413 413 414 # FIXME: Replace `main' with a function in `-lm': -
orxonox/branches/updater/src/Makefile.in
r3273 r3274 282 282 esac; \ 283 283 done; \ 284 echo ' cd $(top_srcdir) && $(AUTOMAKE) -- gnusrc/Makefile'; \284 echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \ 285 285 cd $(top_srcdir) && \ 286 $(AUTOMAKE) -- gnusrc/Makefile286 $(AUTOMAKE) --foreign src/Makefile 287 287 .PRECIOUS: Makefile 288 288 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status -
orxonox/branches/updater/src/console/Makefile.in
r3273 r3274 201 201 esac; \ 202 202 done; \ 203 echo ' cd $(top_srcdir) && $(AUTOMAKE) -- gnusrc/console/Makefile'; \203 echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/console/Makefile'; \ 204 204 cd $(top_srcdir) && \ 205 $(AUTOMAKE) -- gnusrc/console/Makefile205 $(AUTOMAKE) --foreign src/console/Makefile 206 206 .PRECIOUS: Makefile 207 207 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status -
orxonox/branches/updater/src/gui/Makefile.in
r3273 r3274 232 232 esac; \ 233 233 done; \ 234 echo ' cd $(top_srcdir) && $(AUTOMAKE) -- gnusrc/gui/Makefile'; \234 echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/gui/Makefile'; \ 235 235 cd $(top_srcdir) && \ 236 $(AUTOMAKE) -- gnusrc/gui/Makefile236 $(AUTOMAKE) --foreign src/gui/Makefile 237 237 .PRECIOUS: Makefile 238 238 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status -
orxonox/branches/updater/src/gui/orxonox_gui_update.cc
r3273 r3274 81 81 updateDataBox->fill(updateDataBar); 82 82 83 updateDataBegin = new Button ("begin Download"); 84 updateDataBegin->connectSignal ("button_press_event", updateDataBar, updateDataFunc); 83 FileInfo* dataInfo = new FileInfo; 84 dataInfo->bar = updateDataBar; 85 86 updateDataBegin = new Button ("begin."); 87 dataInfo->stateButton = updateDataBegin; 88 dataInfo->buttonSignal = updateDataBegin->connectSignal ("button_press_event", dataInfo, updateDataFunc); 85 89 updateDataBox->fill(updateDataBegin); 86 90 … … 145 149 \param button The Button, that triggered this event. 146 150 */ 147 gint OrxonoxGuiUpdate::updateDataFunc(GtkWidget* w, GdkEventKey* event, void* bar) 148 { 149 FileInfo* info = new FileInfo; 150 151 info->fileName = "02%20orxonox%203.mp3"; 152 info->webRoot = "http://www.orxonox.ethz.ch/files/"; 153 info->localRoot = "./"; 154 info->Bar = (ProgressBar*)bar; 155 PRINTF(3)("Preparing to download file %s.\n", info->fileName); 156 download (info); 157 /* 158 if (downloadThreadID == NULL) 159 { 160 if ( (downloadThreadID =g_thread_create(&downloadThread, info, TRUE, NULL)) == 0 ) 161 PRINTF(1)("can't create the thread"); 162 } 163 else 164 PRINTF(1)("thread already in use\n"); 165 */ 151 gint OrxonoxGuiUpdate::updateDataFunc(GtkWidget* w, GdkEventKey* event, void* info) 152 { 153 FileInfo* dataInfo = (FileInfo*)info; 154 155 dataInfo->fileName = "02%20orxonox%203.mp3"; 156 dataInfo->webRoot = "http://www.orxonox.ethz.ch/files/"; 157 dataInfo->localRoot = "./"; 158 PRINTF(3)("Preparing to download file %s.\n", dataInfo->fileName); 159 download (dataInfo); 166 160 } 167 161 … … 196 190 Bar->setProgress(progress); 197 191 Bar->setTotalSize(totalSize); 192 #ifdef HAVE_GTK2 193 #ifndef HAVE_PTHREAD_H 194 while(gtk_events_pending()) gtk_main_iteration(); 195 #endif 196 #endif 198 197 return 0; 199 200 } 201 202 #ifdef HAVE_CURL 198 } 199 203 200 CURL* OrxonoxGuiUpdate::curlHandle = NULL; 204 #endif /* HAVE_CURL */205 201 206 202 #ifdef HAVE_PTHREAD_H … … 209 205 bool OrxonoxGuiUpdate::isDownloading = false; 210 206 211 void* OrxonoxGuiUpdate::download (void* fileInfo) 212 { 213 207 bool OrxonoxGuiUpdate::download (void* fileInfo) 208 { 209 if (isDownloading) 210 { 211 PRINTF(2)("unable to Download. already getting some file\n"); 212 return false; 213 } 214 214 PRINTF(3)("Downloading.\n"); 215 215 FileInfo* info = (FileInfo*)fileInfo; … … 227 227 228 228 info->fileHandle = fopen(fileOnDisk, "w"); 229 229 230 230 curl_easy_setopt(curlHandle, CURLOPT_URL, fileOnNet); 231 231 curl_easy_setopt(curlHandle, CURLOPT_WRITEDATA, info->fileHandle); … … 234 234 curl_easy_setopt(curlHandle, CURLOPT_NOPROGRESS, FALSE); 235 235 curl_easy_setopt(curlHandle, CURLOPT_PROGRESSFUNCTION, curlProgressFunc); 236 curl_easy_setopt(curlHandle, CURLOPT_PROGRESSDATA, info-> Bar);236 curl_easy_setopt(curlHandle, CURLOPT_PROGRESSDATA, info->bar); 237 237 238 238 if (!isDownloading) … … 241 241 #ifdef HAVE_PTHREAD_H 242 242 pthread_create(downloadThreadID, NULL, downloadThread, info); 243 244 pthread_t finish; 245 pthread_create(&finish, NULL, downloadThreadFinished, info); 243 246 #else 244 247 downloadThread(info); 248 downloadThreadFinished(info); 245 249 #endif /* HAVE_PTHREAD_H */ 246 250 247 // else248 // PRINTF(1)("thread already in use\n");249 251 // res = curl_easy_perform(curlHandle); 250 252 251 253 // fclose(outfile); 252 254 } 255 else 256 PRINTF(1)("thread already in use\n"); 257 253 258 } 254 return NULL;259 return true; 255 260 } 256 261 void* OrxonoxGuiUpdate::downloadThread(void* fileInfo) 257 262 { 263 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); 264 gdk_threads_enter(); 258 265 isDownloading = true; 259 260 266 FileInfo* info = (FileInfo*)fileInfo; 267 info->stateButton->disconnectSignal(info->buttonSignal); 268 info->buttonSignal = info->stateButton->connectSignal("button_press_event", info, cancelDownload); 269 info->stateButton->setTitle("cancel"); 270 gdk_threads_leave(); 271 pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); 272 261 273 curl_easy_perform(curlHandle); 274 275 } 276 277 void* OrxonoxGuiUpdate::downloadThreadFinished(void* fileInfo) 278 { 279 FileInfo* info = (FileInfo*)fileInfo; 280 #ifdef HAVE_PTHREAD_H 281 pthread_join (*downloadThreadID, NULL); 282 #endif /* HAVE_PTHREAD_H */ 283 gdk_threads_enter(); 262 284 if (curlHandle) 263 285 curl_easy_cleanup(curlHandle); 264 #ifdef HAVE_PTHREAD_H 265 pthread_join(*downloadThreadID, NULL); 266 #endif /* HAVE_PTHREAD_H */ 286 267 287 PRINTF(3)("Closing the downloaded file.\n"); 268 288 fclose(info->fileHandle); 269 289 290 if (isDownloading) 291 info->stateButton->setTitle("go on"); 292 // else 293 // info->stateButton->setTitle("done"); 294 info->stateButton->disconnectSignal(info->buttonSignal); 295 info->buttonSignal = info->stateButton->connectSignal("button_press_event", info, updateDataFunc); 270 296 isDownloading = false; 271 } 272 297 gdk_threads_leave(); 298 299 } 273 300 274 301 #ifdef HAVE_GTK2 275 302 gint OrxonoxGuiUpdate::cancelDownload(GtkWidget* w, GdkEventKey* event, void* bar) 276 303 { 277 // curl_easy_cleanup(curlHandle); 278 // curlHandle = NULL; 304 #ifdef HAVE_PTHREAD_H 305 pthread_cancel(*downloadThreadID); 306 #else 307 PRINTF(2)("Cannot cancle the Downloading process until after this File, because no threading was enabled"); 308 #endif /* HAVE_PTHREAD_H*/ 279 309 } 280 310 #endif /* HAVE_GTK2 */ -
orxonox/branches/updater/src/gui/orxonox_gui_update.h
r3273 r3274 42 42 43 43 #ifdef HAVE_GTK2 44 static gint updateDataFunc (GtkWidget* w, GdkEventKey* event, void* bar);45 static gint updateSourceFunc (GtkWidget* w, GdkEventKey* event, void* bar);44 static gint updateDataFunc (GtkWidget* w, GdkEventKey* event, void* info); 45 static gint updateSourceFunc (GtkWidget* w, GdkEventKey* event, void* info); 46 46 #endif /* HAVE_GTK2 */ 47 47 … … 55 55 FILE* fileHandle; //!< A fileHandler. 56 56 57 ProgressBar* Bar; //!< The ProgressBar, that sould be updated. 57 Button* stateButton; //!< A button that shows either start or cancel; 58 long int buttonSignal;//!< The Signal of the stateButton. 59 ProgressBar* bar; //!< The ProgressBar, that sould be updated. 58 60 }; 59 61 … … 71 73 static bool isDownloading; 72 74 73 static void*download (void* fileInfo);75 static bool download (void* fileInfo); 74 76 static void* downloadThread (void* fileInfo); 75 static void* downloadThreadFinished(void* outfile);77 static void* downloadThreadFinished(void* fileInfo); 76 78 77 79 -
orxonox/branches/updater/src/importer/Makefile.in
r3273 r3274 208 208 esac; \ 209 209 done; \ 210 echo ' cd $(top_srcdir) && $(AUTOMAKE) -- gnusrc/importer/Makefile'; \210 echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/importer/Makefile'; \ 211 211 cd $(top_srcdir) && \ 212 $(AUTOMAKE) -- gnusrc/importer/Makefile212 $(AUTOMAKE) --foreign src/importer/Makefile 213 213 .PRECIOUS: Makefile 214 214 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
Note: See TracChangeset
for help on using the changeset viewer.