Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/branches/guiMerge: more naming issues

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