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