[3250] | 1 | /*! |
---|
| 2 | \file orxonox_gui_update.h |
---|
| 3 | \brief File that holds the class that creates the update-menu. |
---|
| 4 | */ |
---|
| 5 | |
---|
| 6 | #ifndef _ORXONOX_GUI_UPDATE_H |
---|
| 7 | #define _ORXONOX_GUI_UPDATE_H |
---|
| 8 | |
---|
| 9 | #include "orxonox_gui.h" |
---|
| 10 | #include <stdio.h> |
---|
[3270] | 11 | #ifdef HAVE_CURL |
---|
| 12 | #include <curl/curl.h> |
---|
| 13 | #include <curl/types.h> |
---|
| 14 | #include <curl/easy.h> |
---|
| 15 | #endif /* HAVE_CURL */ |
---|
[3273] | 16 | #ifdef HAVE_PTHREAD_H |
---|
[3275] | 17 | #define _MULTI_THREADED |
---|
[3272] | 18 | #include <pthread.h> |
---|
[3273] | 19 | #endif /* HAVE_PTHREAD_H */ |
---|
[3250] | 20 | using namespace std; |
---|
| 21 | |
---|
| 22 | //! Class that creates the execute-Options. |
---|
| 23 | class OrxonoxGuiUpdate |
---|
| 24 | { |
---|
| 25 | private: |
---|
[3285] | 26 | // Defining Variables |
---|
| 27 | char* tmpDir; //!< The Temporary directory. |
---|
| 28 | char* homeDir; //!< The Home directory. |
---|
| 29 | char* installDataDir; //!< Where to install the Data to. |
---|
| 30 | char* installSourceDir; //!< Where to install the Source to. |
---|
| 31 | char* userName; //!< The user logged in. |
---|
| 32 | |
---|
| 33 | bool getSystemInfo(); |
---|
[3286] | 34 | #ifdef HAVE_CURL |
---|
| 35 | bool* checkForUpdates(); |
---|
| 36 | #endif /* HAVE_CURL */ |
---|
[3285] | 37 | |
---|
| 38 | // Window creation. |
---|
[3284] | 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. |
---|
[3261] | 42 | |
---|
[3259] | 43 | |
---|
[3284] | 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. |
---|
[3257] | 49 | |
---|
[3284] | 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. |
---|
[3259] | 54 | |
---|
[3284] | 55 | Button* test; //!< will be deleted soon. |
---|
[3285] | 56 | |
---|
| 57 | #ifdef HAVE_GTK2 |
---|
[3274] | 58 | static gint updateDataFunc (GtkWidget* w, GdkEventKey* event, void* info); |
---|
| 59 | static gint updateSourceFunc (GtkWidget* w, GdkEventKey* event, void* info); |
---|
[3256] | 60 | #endif /* HAVE_GTK2 */ |
---|
[3254] | 61 | |
---|
[3263] | 62 | #ifdef HAVE_CURL |
---|
[3267] | 63 | //! A Struct to hold information about one File to download. |
---|
[3263] | 64 | struct FileInfo |
---|
| 65 | { |
---|
[3284] | 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. |
---|
[3267] | 70 | |
---|
[3284] | 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. |
---|
[3263] | 74 | }; |
---|
[3254] | 75 | |
---|
[3263] | 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 | |
---|
[3270] | 80 | static CURL* curlHandle; |
---|
[3268] | 81 | #ifdef HAVE_GTK2 |
---|
| 82 | static gint cancelDownload(GtkWidget* w, GdkEventKey* event, void* bar); |
---|
| 83 | #endif /* HAVE_GTK2 */ |
---|
[3273] | 84 | #ifdef HAVE_PTHREAD_H |
---|
[3272] | 85 | static pthread_t* downloadThreadID; |
---|
[3275] | 86 | static pthread_t* downloadThreadFinishID; |
---|
[3273] | 87 | #endif /* HAVE_PTHREAD_H */ |
---|
[3272] | 88 | static bool isDownloading; |
---|
| 89 | |
---|
[3274] | 90 | static bool download (void* fileInfo); |
---|
[3286] | 91 | static bool downloadWithStyle (void* fileInfo); |
---|
[3271] | 92 | static void* downloadThread (void* fileInfo); |
---|
[3274] | 93 | static void* downloadThreadFinished(void* fileInfo); |
---|
[3271] | 94 | |
---|
| 95 | |
---|
[3263] | 96 | #endif /* HAVE_CURL */ |
---|
| 97 | |
---|
[3250] | 98 | public: |
---|
| 99 | OrxonoxGuiUpdate (); |
---|
| 100 | ~OrxonoxGuiUpdate (); |
---|
| 101 | |
---|
| 102 | Widget* getWidget (); |
---|
[3285] | 103 | #ifdef HAVE_CURL |
---|
[3259] | 104 | void updateDataWindowCreate (void); |
---|
| 105 | Button* updateDataWindowGetButton(void); |
---|
| 106 | |
---|
| 107 | void updateSourceWindowCreate (void); |
---|
| 108 | Button* updateSourceWindowGetButton(void); |
---|
[3285] | 109 | #endif /* HAVE_CURL */ |
---|
| 110 | |
---|
[3250] | 111 | }; |
---|
| 112 | |
---|
| 113 | #endif /* _ORXONOX_GUI_UPDATE_H */ |
---|