Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/guiMerge/src/lib/gui/gui/gui_update.h @ 4049

Last change on this file since 4049 was 4049, checked in by bensch, 19 years ago

orxonox/branches/guiMerge: minor

File size: 4.0 KB
Line 
1/*!
2  \file gui_update.h
3  \brief File that holds the class that creates the update-menu.
4*/
5
6#ifndef _GUI_UPDATE_H
7#define _GUI_UPDATE_H
8
9#include "gui.h"
10#include "gui_element.h"
11#include "gui_gtk.h"
12
13#include <stdio.h>
14#ifdef HAVE_CURL
15#include <curl/curl.h>
16#include <curl/types.h>
17#include <curl/easy.h>
18#endif /* HAVE_CURL */
19#ifdef HAVE_PTHREAD_H
20#define _MULTI_THREADED
21#include <pthread.h>
22#endif /* HAVE_PTHREAD_H */
23using namespace std;
24
25//! Class that creates the execute-Options.
26class OrxonoxGuiUpdate : public OrxonoxGuiElement
27{
28 private:
29  // Defining Variables
30  char* tmpDir;                         //!< The Temporary directory.
31  char* homeDir;                        //!< The Home directory.
32  char* installDataDir;                 //!< Where to install the Data to.
33  char* installSourceDir;               //!< Where to install the Source to.
34  char* userName;                       //!< The user logged in.
35
36  bool getSystemInfo(void);
37 
38  // Window creation.
39  Frame* updateFrame;                   //!< The Frame that holds the updateOptions.
40  Box* updateBox;                       //!< The Box that holds the updateOptions.
41  CheckButton* autoUpdate;              //!< A Checkbutton to enable the automatic Updating.
42
43 
44  Button* updateDataWindowButton;       //!< A Button to update the Data of orxonox.
45  Window* updateDataWindow;             //!< A Window for the data-update.
46  Box* updateDataBox;                   //!< A Box for the Window for the Data-update.
47  ProgressBar* updateDataBar;           //!< A Bar to display the progress of the download.
48  Button* updateDataBegin;              //!< A Button to start the process.
49
50  Button* updateSourceWindowButton;     //!< A Button to update the Source of orxonox. \todo tricky
51  Window* updateSourceWindow;           //!< A Window for the Source-update.
52  Box* updateSourceBox;                 //!< A Box for the Window for the Source-update.
53  ProgressBar* updateSourceBar;         //!< A Bar to display the progress of the download.
54
55  Button* test;                         //!< will be deleted soon.
56
57#ifdef HAVE_GTK2
58  static gint updateDataFunc(GtkWidget* w, GdkEventKey* event, void* info);
59  static gint updateSourceFunc(GtkWidget* w, GdkEventKey* event, void* info);
60#endif /* HAVE_GTK2 */
61
62#ifdef HAVE_CURL
63  //! A Struct to hold information about one File to download.
64  struct FileInfo
65  {
66    char* fileName;                     //!< The Name of the file we want to get.
67    char* webRoot;                      //!< The Root of the File on The Web
68    char* localRoot;                    //!< The Root directory to put the files on the local disk.
69    FILE* fileHandle;                   //!< A fileHandler.
70
71    Button* stateButton;                //!< A button that shows either start or cancel;
72    long int buttonSignal;              //!< The Signal of the stateButton.
73    ProgressBar* bar;                   //!< The ProgressBar, that sould be updated.
74  };
75
76  static size_t curlWriteFunc(void* ptr, size_t size, size_t nmemb, FILE* stream);
77  static size_t curlReadFunc(void* ptr, size_t size, size_t nmemb, FILE* stream);
78  static int curlProgressFunc(ProgressBar* bar, double totalSize, double progress, double upTotal, double upProgress);
79
80  static CURL* curlHandle;
81#ifdef HAVE_GTK2
82  static gint cancelDownload(GtkWidget* w, GdkEventKey* event, void* bar);
83#endif /* HAVE_GTK2 */ 
84#ifdef HAVE_PTHREAD_H
85  static pthread_t* downloadThreadID;
86  static pthread_t* downloadThreadFinishID;
87#endif /* HAVE_PTHREAD_H */
88  static bool isDownloading;
89
90  static bool download(void* fileInfo);
91  static bool downloadWithStyle(void* fileInfo);
92  static void* downloadThread(void* fileInfo);
93  static void* downloadThreadFinished(void* fileInfo);
94
95 
96#endif /* HAVE_CURL */
97
98 public:
99  OrxonoxGuiUpdate(void);
100  ~OrxonoxGuiUpdate(void);
101 
102#ifdef HAVE_CURL   
103  void updateDataWindowCreate(void);
104  Button* updateDataWindowGetButton(void);
105
106  void updateSourceWindowCreate(void);
107  Button* updateSourceWindowGetButton(void);
108
109  bool* checkForUpdates(void);
110 
111#endif /* HAVE_CURL */
112
113};
114
115#endif /* _GUI_UPDATE_H */
Note: See TracBrowser for help on using the repository browser.