Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3286 in orxonox.OLD for orxonox/branches


Ignore:
Timestamp:
Dec 26, 2004, 2:36:16 AM (20 years ago)
Author:
bensch
Message:

orxonox/branches/updater: it downloads the fileindex into a tempdir.

Location:
orxonox/branches/updater/src/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/updater/src/gui/orxonox_gui_update.cc

    r3285 r3286  
    4040{
    4141  this->getSystemInfo();
     42#ifdef HAVE_CURL
     43  this->checkForUpdates();
     44#endif /* HAVE_CURL */
    4245
    4346  this->updateFrame = new Frame ("Update-Options:");
     
    9497
    9598  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);
    97100
    98101  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);
    100103
    101104  userName = getenv("USER");
     
    103106}
    104107
     108#ifdef HAVE_CURL
     109bool* 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 */
    105120#ifdef HAVE_CURL
    106121/**
     
    204219  dataInfo->localRoot = "./";
    205220  PRINTF(3)("Preparing to download file %s.\n", dataInfo->fileName);
    206   download (dataInfo);
     221  downloadWithStyle(dataInfo);
    207222}
    208223
     
    282297bool OrxonoxGuiUpdate::isDownloading = false;
    283298
    284 /**
    285    \brief Initializes a Download
     299
     300/**
     301   \brief Initializes a Download without displaying it.
    286302   \param fileInfo the FileInfo.
    287 */
    288 bool OrxonoxGuiUpdate::download (void* fileInfo)
     303
     304   !! BE AWARE THIS WILL NOT BE THREADED. !!
     305*/
     306bool 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*/
     354bool OrxonoxGuiUpdate::downloadWithStyle(void* fileInfo)
    289355{
    290356  if (isDownloading)
  • orxonox/branches/updater/src/gui/orxonox_gui_update.h

    r3285 r3286  
    3232
    3333  bool getSystemInfo();
    34 
     34#ifdef HAVE_CURL
     35  bool* checkForUpdates();
     36#endif /* HAVE_CURL */
    3537 
    3638  // Window creation.
     
    8789
    8890  static bool download (void* fileInfo);
     91  static bool downloadWithStyle (void* fileInfo);
    8992  static void* downloadThread (void* fileInfo);
    9093  static void* downloadThreadFinished(void* fileInfo);
Note: See TracChangeset for help on using the changeset viewer.