Changeset 3315 in orxonox.OLD for orxonox/branches/updater/src/gui/orxonox_gui_update.cc
- Timestamp:
- Jan 3, 2005, 12:13:38 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/updater/src/gui/orxonox_gui_update.cc
r3303 r3315 1 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 4 3 Copyright (C) 2004 orx 5 4 … … 37 36 \brief Creates an Audio-Frame 38 37 */ 39 OrxonoxGuiUpdate::OrxonoxGuiUpdate ()38 OrxonoxGuiUpdate::OrxonoxGuiUpdate(void) 40 39 { 41 40 this->getSystemInfo(); 42 41 43 this->updateFrame = new Frame 44 this->updateFrame->setGroupName 45 this->updateBox = new Box 42 this->updateFrame = new Frame("Update-Options:"); 43 this->updateFrame->setGroupName("update"); 44 this->updateBox = new Box('v'); 46 45 #ifdef HAVE_CURL 47 46 48 47 // the Button for autoUpdating 49 this->autoUpdate = new CheckButton 48 this->autoUpdate = new CheckButton("auto update"); 50 49 this->updateBox->fill(this->autoUpdate); 51 this->autoUpdate->setFlagName 50 this->autoUpdate->setFlagName("update", "u", 0); 52 51 this->autoUpdate->saveability(); 53 52 54 this->updateSourceWindowCreate 53 this->updateSourceWindowCreate(); 55 54 this->updateBox->fill(this->updateSourceWindowGetButton()); 56 55 57 this->updateDataWindowCreate 56 this->updateDataWindowCreate(); 58 57 this->updateBox->fill(this->updateDataWindowGetButton()); 59 58 … … 70 69 \return Returns the Audio-frame 71 70 */ 72 Widget* OrxonoxGuiUpdate::getWidget ()73 { 74 return updateFrame;71 Widget* OrxonoxGuiUpdate::getWidget(void) 72 { 73 return this->updateFrame; 75 74 } 76 75 … … 81 80 { 82 81 PRINTF(3)("Grabbing system information\n"); 83 t mpDir = getenv("TMPDIR");84 if 85 t mpDir = "/tmp";86 PRINTF(4)("Temporary directory is: %s\n", t mpDir);82 this->tmpDir = getenv("TMPDIR"); 83 if(!tmpDir) 84 this->tmpDir = "/tmp"; 85 PRINTF(4)("Temporary directory is: %s\n", this->tmpDir); 87 86 88 87 #ifdef __WIN32__ 89 homeDir = getenv("USERPROFILE");88 this->homeDir = getenv("USERPROFILE"); 90 89 #else 91 homeDir = getenv("HOME");90 this->homeDir = getenv("HOME"); 92 91 #endif 93 92 PRINTF(4)("Home directory is %s\n", homeDir); 94 93 95 installDataDir = "/usr/share/games/orxonox";96 PRINTF(4)("Installation of orxonox-data will go to this directory: %s\n", installDataDir);97 98 installSourceDir = "/usr/games/bin";99 PRINTF(4)("Installation of orxonox-source will go to this directory: %s\n", installSourceDir);100 101 userName = getenv("USER");102 PRINTF(4)("Logged in username is: %s\n", userName);94 this->installDataDir = "/usr/share/games/orxonox"; 95 PRINTF(4)("Installation of orxonox-data will go to this directory: %s\n", this->installDataDir); 96 97 this->installSourceDir = "/usr/games/bin"; 98 PRINTF(4)("Installation of orxonox-source will go to this directory: %s\n", this->installSourceDir); 99 100 this->userName = getenv("USER"); 101 PRINTF(4)("Logged in username is: %s\n", this->userName); 103 102 } 104 103 … … 119 118 \brief Creates a window, and all it contains for the Data-update. 120 119 */ 121 void OrxonoxGuiUpdate::updateDataWindowCreate 122 { 123 updateDataWindow = new Window("update orxonox::Data");124 updateDataBox = new Box('v');120 void OrxonoxGuiUpdate::updateDataWindowCreate(void) 121 { 122 this->updateDataWindow = new Window("update orxonox::Data"); 123 this->updateDataBox = new Box('v'); 125 124 126 125 // the close-Button of the Update Window. 127 // updateWindowClose = new Button 126 // updateWindowClose = new Button("close"); 128 127 #ifdef HAVE_GTK2 129 128 // updateWindowClose->connectSignal("button_press_event", updateWindow, Window::windowClose); … … 131 130 // updateWindowBox->fill(updateWindowClose); 132 131 133 updateDataBar = new ProgressBar();134 updateDataBox->fill(updateDataBar);132 this->updateDataBar = new ProgressBar(); 133 this->updateDataBox->fill(this->updateDataBar); 135 134 136 135 FileInfo* dataInfo = new FileInfo; 137 dataInfo->bar = updateDataBar;138 139 updateDataBegin = new Button("begin.");140 dataInfo->stateButton = updateDataBegin;141 #ifdef HAVE_GTK2 142 dataInfo->buttonSignal = updateDataBegin->connectSignal 143 #endif /* HAVE_GTK2 */ 144 updateDataBox->fill(updateDataBegin);145 146 updateDataWindow->fill (updateDataBox);147 148 updateDataWindowButton = new Button("update orxonox::Data");149 #ifdef HAVE_GTK2 150 updateDataWindowButton->connectSignal("button_press_event",updateDataWindow, Window::windowOpen);151 updateDataWindow->connectSignal("destroy",updateDataWindow, Window::windowClose);152 updateDataWindow->connectSignal("delete_event",updateDataWindow, Window::windowClose);136 dataInfo->bar = this->updateDataBar; 137 138 this->updateDataBegin = new Button("begin."); 139 dataInfo->stateButton = this->updateDataBegin; 140 #ifdef HAVE_GTK2 141 dataInfo->buttonSignal = updateDataBegin->connectSignal("button_press_event", dataInfo, updateDataFunc); 142 #endif /* HAVE_GTK2 */ 143 this->updateDataBox->fill(this->updateDataBegin); 144 145 this->updateDataWindow->fill(this->updateDataBox); 146 147 this->updateDataWindowButton = new Button("update orxonox::Data"); 148 #ifdef HAVE_GTK2 149 this->updateDataWindowButton->connectSignal("button_press_event", this->updateDataWindow, Window::windowOpen); 150 this->updateDataWindow->connectSignal("destroy", this->updateDataWindow, Window::windowClose); 151 this->updateDataWindow->connectSignal("delete_event", this->updateDataWindow, Window::windowClose); 153 152 #endif /* HAVE_GTK2 */ 154 153 … … 160 159 Button* OrxonoxGuiUpdate::updateDataWindowGetButton(void) 161 160 { 162 return updateDataWindowButton;161 return this->updateDataWindowButton; 163 162 } 164 163 … … 166 165 \brief Creates a window, and all it contains for the Source-update. 167 166 */ 168 void OrxonoxGuiUpdate::updateSourceWindowCreate 167 void OrxonoxGuiUpdate::updateSourceWindowCreate(void) 169 168 { 170 169 // the button, that opens this Window. 171 updateSourceWindowButton = new Button("update orxonox::Source");170 this->updateSourceWindowButton = new Button("update orxonox::Source"); 172 171 173 172 // the Window itself 174 updateSourceWindow = new Window("update orxonox::Source");175 176 updateSourceBox = new Box();177 178 updateSourceBar = new ProgressBar();179 updateSourceBox->fill(updateSourceBar);180 test = new Button 173 this->updateSourceWindow = new Window("update orxonox::Source"); 174 175 this->updateSourceBox = new Box(); 176 177 this->updateSourceBar = new ProgressBar(); 178 this->updateSourceBox->fill(this->updateSourceBar); 179 test = new Button("increment"); 181 180 182 181 #ifdef HAVE_GTK2 … … 184 183 #endif /* HAVE_GTK2 */ 185 184 186 updateSourceBox->fill(test);187 updateSourceWindow->fill(updateSourceBox);188 #ifdef HAVE_GTK2 189 updateSourceWindowButton->connectSignal("button_press_event",updateSourceWindow, Window::windowOpen);190 updateSourceWindow->connectSignal("destroy",updateSourceWindow, Window::windowClose);191 updateSourceWindow->connectSignal("delete_event",updateSourceWindow, Window::windowClose);185 this->updateSourceBox->fill(test); 186 this->updateSourceWindow->fill(updateSourceBox); 187 #ifdef HAVE_GTK2 188 this->updateSourceWindowButton->connectSignal("button_press_event", this->updateSourceWindow, Window::windowOpen); 189 this->updateSourceWindow->connectSignal("destroy", this->updateSourceWindow, Window::windowClose); 190 this->updateSourceWindow->connectSignal("delete_event", this->updateSourceWindow, Window::windowClose); 192 191 #endif /* HAVE_GTK2 */ 193 192 … … 199 198 Button* OrxonoxGuiUpdate::updateSourceWindowGetButton(void) 200 199 { 201 return updateSourceWindowButton;200 return this->updateSourceWindowButton; 202 201 } 203 202 … … 212 211 gint OrxonoxGuiUpdate::updateDataFunc(GtkWidget* w, GdkEventKey* event, void* info) 213 212 { 214 FileInfo* dataInfo = 213 FileInfo* dataInfo =(FileInfo*)info; 215 214 216 215 dataInfo->fileName = "02%20orxonox%203.mp3"; … … 242 241 \param stream Filehandler to write to. 243 242 */ 244 size_t OrxonoxGuiUpdate::curlWriteFunc 243 size_t OrxonoxGuiUpdate::curlWriteFunc(void* ptr, size_t size, size_t nmemb, FILE* stream) 245 244 { 246 245 return fwrite(ptr, size, nmemb, stream); … … 254 253 \param stream Filehandler to get data from. 255 254 */ 256 size_t OrxonoxGuiUpdate::curlReadFunc 255 size_t OrxonoxGuiUpdate::curlReadFunc(void* ptr, size_t size, size_t nmemb, FILE* stream) 257 256 { 258 257 return fread(ptr, size, nmemb, stream); … … 268 267 \param upProgress not needed 269 268 */ 270 int OrxonoxGuiUpdate::curlProgressFunc (ProgressBar* Bar, double totalSize, double progress, double upTotal, double upProgress)271 { 272 Bar->setProgress(progress);273 Bar->setTotalSize(totalSize);269 int OrxonoxGuiUpdate::curlProgressFunc(ProgressBar* bar, double totalSize, double progress, double upTotal, double upProgress) 270 { 271 bar->setProgress(progress); 272 bar->setTotalSize(totalSize); 274 273 #ifdef HAVE_GTK2 275 274 #ifndef HAVE_PTHREAD_H … … 281 280 282 281 /** 283 \brief The Curl handle for only one CURL 282 \brief The Curl handle for only one CURL(static). 284 283 */ 285 284 CURL* OrxonoxGuiUpdate::curlHandle = NULL; … … 305 304 bool OrxonoxGuiUpdate::download(void* fileInfo) 306 305 { 307 if 306 if(isDownloading) 308 307 { 309 308 PRINTF(2)("unable to Download. already getting some file\n"); … … 311 310 } 312 311 PRINTF(3)("Downloading.\n"); 313 FileInfo* info = 312 FileInfo* info =(FileInfo*)fileInfo; 314 313 CURLcode res; 315 314 CURL* localCurl; 316 315 localCurl = curl_easy_init(); 317 316 char* fileOnNet = new char [strlen(info->webRoot)+strlen(info->fileName)+2]; 318 strcpy 319 if 320 strcat 321 strcat 317 strcpy(fileOnNet, info->webRoot); 318 if(fileOnNet[strlen(fileOnNet)] != '/') //!< \todo windows-shit 319 strcat(fileOnNet, "/"); 320 strcat(fileOnNet, info->fileName); 322 321 char* fileOnDisk = new char [strlen(info->localRoot)+strlen(info->fileName)+2]; 323 strcpy 324 if 325 strcat 326 strcat 322 strcpy(fileOnDisk, info->localRoot); 323 if(fileOnDisk[strlen(fileOnDisk)] != '/') //!< \todo windows-shit 324 strcat(fileOnDisk, "/"); 325 strcat(fileOnDisk, info->fileName); 327 326 328 327 if(localCurl) … … 340 339 341 340 curl_easy_cleanup(localCurl); 342 fclose 341 fclose(info->fileHandle); 343 342 } 344 343 } … … 353 352 bool OrxonoxGuiUpdate::downloadWithStyle(void* fileInfo) 354 353 { 355 if 354 if(isDownloading) 356 355 { 357 356 PRINTF(2)("unable to Download. already getting some file\n"); … … 359 358 } 360 359 PRINTF(3)("Downloading.\n"); 361 FileInfo* info = 360 FileInfo* info =(FileInfo*)fileInfo; 362 361 CURLcode res; 363 362 curlHandle = curl_easy_init(); 364 363 char* fileOnNet = new char [strlen(info->webRoot)+strlen(info->fileName)+1]; 365 strcpy 366 strcat 364 strcpy(fileOnNet, info->webRoot); 365 strcat(fileOnNet, info->fileName); 367 366 char* fileOnDisk = new char [strlen(info->localRoot)+strlen(info->fileName)+1]; 368 strcpy 369 strcat 367 strcpy(fileOnDisk, info->localRoot); 368 strcat(fileOnDisk, info->fileName); 370 369 371 370 if(curlHandle) … … 382 381 curl_easy_setopt(curlHandle, CURLOPT_PROGRESSDATA, info->bar); 383 382 384 if 383 if(!isDownloading) 385 384 { 386 385 #ifdef HAVE_PTHREAD_H … … 418 417 419 418 /** 420 \brief The downloading process 419 \brief The downloading process(either threaded or not). 421 420 \param fileInfo the FileInfo. 422 421 … … 435 434 void* OrxonoxGuiUpdate::downloadThreadFinished(void* fileInfo) 436 435 { 437 FileInfo* info = 438 #ifdef HAVE_PTHREAD_H 439 pthread_join 436 FileInfo* info =(FileInfo*)fileInfo; 437 #ifdef HAVE_PTHREAD_H 438 pthread_join(*downloadThreadID, NULL); 440 439 #ifdef HAVE_GTK2 441 440 gdk_threads_enter(); 442 441 #endif /* HAVE_GTK2 */ 443 442 #endif /* HAVE_PTHREAD_H */ 444 if 443 if(curlHandle) 445 444 curl_easy_cleanup(curlHandle); 446 445 … … 448 447 fclose(info->fileHandle); 449 448 450 if 449 if(isDownloading) 451 450 info->stateButton->setTitle("go on"); 452 451 // else
Note: See TracChangeset
for help on using the changeset viewer.