Changeset 3286 in orxonox.OLD for orxonox/branches/updater/src
- Timestamp:
- Dec 26, 2004, 2:36:16 AM (20 years ago)
- Location:
- orxonox/branches/updater/src/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/updater/src/gui/orxonox_gui_update.cc
r3285 r3286 40 40 { 41 41 this->getSystemInfo(); 42 #ifdef HAVE_CURL 43 this->checkForUpdates(); 44 #endif /* HAVE_CURL */ 42 45 43 46 this->updateFrame = new Frame ("Update-Options:"); … … 94 97 95 98 installDataDir = "/usr/share/games/orxonox"; 96 PRINTF(4)("Installation of orxonox-data will go to this directory is%s\n", installDataDir);99 PRINTF(4)("Installation of orxonox-data will go to this directory: %s\n", installDataDir); 97 100 98 101 installSourceDir = "/usr/games/bin"; 99 PRINTF(4)("Installation of orxonox-source will go to this directory is%s\n", installSourceDir);102 PRINTF(4)("Installation of orxonox-source will go to this directory: %s\n", installSourceDir); 100 103 101 104 userName = getenv("USER"); … … 103 106 } 104 107 108 #ifdef HAVE_CURL 109 bool* OrxonoxGuiUpdate::checkForUpdates(void) 110 { 111 PRINTF(3)("checking for new version of orxonox\n"); 112 FileInfo updateFileInfo; 113 updateFileInfo.fileName = "update_info"; 114 updateFileInfo.webRoot = "http://www.orxonox.ethz.ch/files/data"; 115 updateFileInfo.localRoot = tmpDir; 116 117 download(&updateFileInfo); 118 } 119 #endif /* HAVE_CURL */ 105 120 #ifdef HAVE_CURL 106 121 /** … … 204 219 dataInfo->localRoot = "./"; 205 220 PRINTF(3)("Preparing to download file %s.\n", dataInfo->fileName); 206 download 221 downloadWithStyle(dataInfo); 207 222 } 208 223 … … 282 297 bool OrxonoxGuiUpdate::isDownloading = false; 283 298 284 /** 285 \brief Initializes a Download 299 300 /** 301 \brief Initializes a Download without displaying it. 286 302 \param fileInfo the FileInfo. 287 */ 288 bool OrxonoxGuiUpdate::download (void* fileInfo) 303 304 !! BE AWARE THIS WILL NOT BE THREADED. !! 305 */ 306 bool OrxonoxGuiUpdate::download(void* fileInfo) 307 { 308 if (isDownloading) 309 { 310 PRINTF(2)("unable to Download. already getting some file\n"); 311 return false; 312 } 313 PRINTF(3)("Downloading.\n"); 314 FileInfo* info = (FileInfo*)fileInfo; 315 CURLcode res; 316 CURL* localCurl; 317 localCurl = curl_easy_init(); 318 char* fileOnNet = new char [strlen(info->webRoot)+strlen(info->fileName)+2]; 319 strcpy (fileOnNet, info->webRoot); 320 if (fileOnNet[strlen(fileOnNet)] != '/') //!< \todo windows-shit 321 strcat (fileOnNet, "/"); 322 strcat (fileOnNet, info->fileName); 323 char* fileOnDisk = new char [strlen(info->localRoot)+strlen(info->fileName)+2]; 324 strcpy (fileOnDisk, info->localRoot); 325 if (fileOnDisk[strlen(fileOnDisk)] != '/') //!< \todo windows-shit 326 strcat (fileOnDisk, "/"); 327 strcat (fileOnDisk, info->fileName); 328 329 if(localCurl) 330 { 331 332 info->fileHandle = fopen(fileOnDisk, "w"); 333 334 curl_easy_setopt(localCurl, CURLOPT_URL, fileOnNet); 335 curl_easy_setopt(localCurl, CURLOPT_WRITEDATA, info->fileHandle); 336 curl_easy_setopt(localCurl, CURLOPT_WRITEFUNCTION, curlWriteFunc); 337 curl_easy_setopt(localCurl, CURLOPT_READFUNCTION, curlReadFunc); 338 curl_easy_setopt(localCurl, CURLOPT_NOPROGRESS, TRUE); 339 340 curl_easy_perform(localCurl); 341 342 curl_easy_cleanup(localCurl); 343 fclose (info->fileHandle); 344 } 345 } 346 347 /** 348 \brief Initializes a Download with some style. 349 \param fileInfo the FileInfo. 350 \todo release thread-lock. 351 352 Downloading with a Button that gets a different Name while downloading, and a Bar, that gets to be updated. More to be followed 353 */ 354 bool OrxonoxGuiUpdate::downloadWithStyle(void* fileInfo) 289 355 { 290 356 if (isDownloading) -
orxonox/branches/updater/src/gui/orxonox_gui_update.h
r3285 r3286 32 32 33 33 bool getSystemInfo(); 34 34 #ifdef HAVE_CURL 35 bool* checkForUpdates(); 36 #endif /* HAVE_CURL */ 35 37 36 38 // Window creation. … … 87 89 88 90 static bool download (void* fileInfo); 91 static bool downloadWithStyle (void* fileInfo); 89 92 static void* downloadThread (void* fileInfo); 90 93 static void* downloadThreadFinished(void* fileInfo);
Note: See TracChangeset
for help on using the changeset viewer.