Changeset 4774 in orxonox.OLD for orxonox/trunk/src/lib/gui
- Timestamp:
- Jul 2, 2005, 6:28:26 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/gui/gui_update.cc
r4746 r4774 1 /* 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 Copyright (C) 2004 orx … … 15 15 You should have received a copy of the GNU General Public License 16 16 along with this program; if not, write to the Free Software Foundation, 17 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 18 19 19 … … 40 40 Button* dataDirButton; //!< A Button for the selection of the DataRepos 41 41 OptionLabel* dataDirLabel; //!< A Label fot the selection of the DataRepos 42 42 43 43 44 44 this->tmpDir = NULL; … … 61 61 dataDirDialog->setDefaultFileName("data"); 62 62 dataDirDialog->setMask(DATA_IDENTIFIER); 63 this->checkDataDir( "../data/"DATA_IDENTIFIER, dataDirLabel);63 this->checkDataDir(DEFAULT_DATA_DIR DATA_IDENTIFIER, dataDirLabel); 64 64 dataDirDialog->disableFileOpts(); 65 65 dataDirDialog->setOpenUpButton(dataDirButton); … … 78 78 this->autoUpdate->saveability(); 79 79 80 80 81 81 82 82 … … 89 89 #else /* HAVE_CURL */ 90 90 Label* noCurlLabel = new Label("since you do not have cURL-support,\nupdate options are not availible"); 91 this->updateBox->fill(noCurlLabel); 91 this->updateBox->fill(noCurlLabel); 92 92 #endif /* HAVE_CURL */ 93 93 this->updateFrame->fill(this->updateBox); … … 107 107 /** 108 108 \brief checks if the Folder containing selected File is data.oxd, and if so sets it. 109 \param 109 \param 110 110 */ 111 111 bool GuiUpdate::checkDataDir(const char* fileName, void* object) … … 115 115 char* tmpName = new char[strlen(fileName)-strlen(DATA_IDENTIFIER)+1]; 116 116 strncpy(tmpName, fileName, strlen(fileName)-strlen(DATA_IDENTIFIER)); 117 tmpName[strlen(fileName)-strlen(DATA_IDENTIFIER)] = '\0'; 117 tmpName[strlen(fileName)-strlen(DATA_IDENTIFIER)] = '\0'; 118 118 static_cast<OptionLabel*>(object)->setValue(tmpName); 119 119 delete tmpName; … … 125 125 126 126 127 /** 127 /** 128 128 \brief Look what info we can get from this system 129 129 */ … … 162 162 updateFileInfo.webRoot = "http://www.orxonox.ethz.ch/files/data"; 163 163 updateFileInfo.localRoot = this->tmpDir; 164 164 165 165 download(&updateFileInfo); 166 166 } … … 171 171 void GuiUpdate::updateDataWindowCreate() 172 172 { 173 this->updateDataWindow = new Window("update orxonox::Data"); 173 this->updateDataWindow = new Window("update orxonox::Data"); 174 174 this->updateDataBox = new Box('v'); 175 175 … … 230 230 test = new Button("increment"); 231 231 232 #ifdef HAVE_GTK2 232 #ifdef HAVE_GTK2 233 233 test->connectSignal("button_press_event", updateSourceBar, updateSourceFunc); 234 234 #endif /* HAVE_GTK2 */ 235 235 236 236 this->updateSourceBox->fill(test); 237 this->updateSourceWindow->fill(updateSourceBox); 238 #ifdef HAVE_GTK2 237 this->updateSourceWindow->fill(updateSourceBox); 238 #ifdef HAVE_GTK2 239 239 this->updateSourceWindowButton->connectSignal("button_press_event", this->updateSourceWindow, Window::windowOpen); 240 240 this->updateSourceWindow->connectSignal("destroy", this->updateSourceWindow, Window::windowClose); … … 253 253 254 254 255 #ifdef HAVE_GTK2 255 #ifdef HAVE_GTK2 256 256 /** 257 257 \brief updates the Data of orxonox. … … 367 367 strcat(fileOnDisk, "/"); 368 368 strcat(fileOnDisk, info->fileName); 369 369 370 370 if(localCurl) 371 371 { 372 372 373 373 info->fileHandle = fopen(fileOnDisk, "w"); 374 374 375 375 curl_easy_setopt(localCurl, CURLOPT_URL, fileOnNet); 376 376 curl_easy_setopt(localCurl, CURLOPT_WRITEDATA, info->fileHandle); … … 378 378 curl_easy_setopt(localCurl, CURLOPT_READFUNCTION, curlReadFunc); 379 379 curl_easy_setopt(localCurl, CURLOPT_NOPROGRESS, true); 380 380 381 381 curl_easy_perform(localCurl); 382 382 … … 413 413 if(curlHandle) 414 414 { 415 415 416 416 info->fileHandle = fopen(fileOnDisk, "w"); 417 417 418 418 curl_easy_setopt(curlHandle, CURLOPT_URL, fileOnNet); 419 419 curl_easy_setopt(curlHandle, CURLOPT_WRITEDATA, info->fileHandle); … … 425 425 426 426 if(!isDownloading) 427 428 #ifdef HAVE_GTK2 429 430 431 #endif /* HAVE_GTK2 */ 432 433 434 435 436 437 438 439 440 441 else 442 427 { 428 #ifdef HAVE_GTK2 429 info->stateButton->disconnectSignal(info->buttonSignal); 430 info->buttonSignal = info->stateButton->connectSignal("button_press_event", info, cancelDownload); 431 #endif /* HAVE_GTK2 */ 432 info->stateButton->setTitle("please wait"); 433 434 downloadThread(info); 435 downloadThreadFinished(info); 436 437 // res = curl_easy_perform(curlHandle); 438 439 // fclose(outfile); 440 } 441 else 442 PRINTF(1)("thread already in use\n"); 443 443 444 444 } … … 459 459 460 460 /** 461 \brief Finishes a downloading process. 461 \brief Finishes a downloading process. 462 462 \param fileInfo the FileInfo. 463 463 */ 464 464 void* GuiUpdate::downloadThreadFinished(void* fileInfo) 465 { 465 { 466 466 FileInfo* info =(FileInfo*)fileInfo; 467 467 if(curlHandle) 468 468 curl_easy_cleanup(curlHandle); 469 469 470 470 PRINTF(4)("Closing the downloaded file.\n"); 471 471 fclose(info->fileHandle); … … 475 475 // else 476 476 // info->stateButton->setTitle("done"); 477 #ifdef HAVE_GTK2 477 #ifdef HAVE_GTK2 478 478 info->stateButton->disconnectSignal(info->buttonSignal); 479 479 info->buttonSignal = info->stateButton->connectSignal("button_press_event", info, updateDataFunc);
Note: See TracChangeset
for help on using the changeset viewer.