diff options
Diffstat (limited to 'src/fs/gnunet-fs-gtk_event-handler.h')
-rw-r--r-- | src/fs/gnunet-fs-gtk_event-handler.h | 241 |
1 files changed, 241 insertions, 0 deletions
diff --git a/src/fs/gnunet-fs-gtk_event-handler.h b/src/fs/gnunet-fs-gtk_event-handler.h new file mode 100644 index 00000000..064c0542 --- /dev/null +++ b/src/fs/gnunet-fs-gtk_event-handler.h | |||
@@ -0,0 +1,241 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2010 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 2, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file src/fs/gnunet-fs-gtk_event-handler.h | ||
23 | * @brief Main event handler for file-sharing | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | #include "gnunet-fs-gtk-common.h" | ||
27 | |||
28 | |||
29 | /** | ||
30 | * State we keep for each (search) result entry in the | ||
31 | * tree view of a search tab. | ||
32 | */ | ||
33 | struct SearchResult; | ||
34 | |||
35 | |||
36 | /** | ||
37 | * Context we keep for a search tab. | ||
38 | */ | ||
39 | struct SearchTab | ||
40 | { | ||
41 | /** | ||
42 | * This is a doubly-linked list. | ||
43 | */ | ||
44 | struct SearchTab *next; | ||
45 | |||
46 | /** | ||
47 | * This is a doubly-linked list. | ||
48 | */ | ||
49 | struct SearchTab *prev; | ||
50 | |||
51 | /** | ||
52 | * Set in case this is an inner search, otherwise NULL. | ||
53 | */ | ||
54 | struct SearchResult *parent; | ||
55 | |||
56 | /** | ||
57 | * Handle for this search with FS library. | ||
58 | */ | ||
59 | struct GNUNET_FS_SearchContext *sc; | ||
60 | |||
61 | /** | ||
62 | * Text of the search query. | ||
63 | */ | ||
64 | char *query_txt; | ||
65 | |||
66 | /** | ||
67 | * GtkBuilder object for the search tab. | ||
68 | */ | ||
69 | GtkBuilder *builder; | ||
70 | |||
71 | /** | ||
72 | * Frame instance of the search tab. | ||
73 | */ | ||
74 | GtkWidget *frame; | ||
75 | |||
76 | /** | ||
77 | * The widget representing this search in the tab bar (not | ||
78 | * a GtkLabel, contains the actual label and the buttons). | ||
79 | */ | ||
80 | GtkWidget *tab_label; | ||
81 | |||
82 | /** | ||
83 | * Button to stop and close the search. | ||
84 | */ | ||
85 | GtkWidget *close_button; | ||
86 | |||
87 | /** | ||
88 | * Button to clear all entries for downloads that have completed. | ||
89 | */ | ||
90 | GtkWidget *clear_button; | ||
91 | |||
92 | /** | ||
93 | * Button to resume the search. | ||
94 | */ | ||
95 | GtkWidget *play_button; | ||
96 | |||
97 | /** | ||
98 | * Button to pause the search. | ||
99 | */ | ||
100 | GtkWidget *pause_button; | ||
101 | |||
102 | /** | ||
103 | * Textual label in the 'tab_label' | ||
104 | */ | ||
105 | GtkLabel *label; | ||
106 | |||
107 | /** | ||
108 | * Tree store with the search results. | ||
109 | */ | ||
110 | GtkTreeStore *ts; | ||
111 | |||
112 | /** | ||
113 | * Number of results we got for this search. | ||
114 | */ | ||
115 | unsigned int num_results; | ||
116 | |||
117 | }; | ||
118 | |||
119 | |||
120 | /** | ||
121 | * Information we keep for each download. | ||
122 | */ | ||
123 | struct DownloadEntry | ||
124 | { | ||
125 | |||
126 | /** | ||
127 | * Download entry of the parent (for recursive downloads), | ||
128 | * NULL if we are either a top-level download (from URI, | ||
129 | * from opened directory, orphaned from search or direct | ||
130 | * search result). | ||
131 | */ | ||
132 | struct DownloadEntry *pde; | ||
133 | |||
134 | /** | ||
135 | * Associated search result, or NULL if we don't belong | ||
136 | * to a search directly (download entry). | ||
137 | */ | ||
138 | struct SearchResult *sr; | ||
139 | |||
140 | /** | ||
141 | * FS handle to control the download. | ||
142 | */ | ||
143 | struct GNUNET_FS_DownloadContext *dc; | ||
144 | |||
145 | /** | ||
146 | * URI for the download. | ||
147 | */ | ||
148 | struct GNUNET_FS_Uri *uri; | ||
149 | |||
150 | /** | ||
151 | * Meta data for the download. | ||
152 | */ | ||
153 | struct GNUNET_CONTAINER_MetaData *meta; | ||
154 | |||
155 | /** | ||
156 | * Where in the tree view is this download being displayed. | ||
157 | */ | ||
158 | GtkTreeRowReference *rr; | ||
159 | |||
160 | /** | ||
161 | * Tree store where we are stored. | ||
162 | */ | ||
163 | GtkTreeStore *ts; | ||
164 | |||
165 | /** | ||
166 | * Tab where this download is currently on display. | ||
167 | */ | ||
168 | struct SearchTab *tab; | ||
169 | |||
170 | /** | ||
171 | * Has the download completed (or errored)? | ||
172 | */ | ||
173 | int is_done; | ||
174 | |||
175 | }; | ||
176 | |||
177 | |||
178 | /** | ||
179 | * Setup a new top-level entry in the URI/orphan tab. If necessary, create | ||
180 | * the URI tab first. | ||
181 | * | ||
182 | * @param iter set to the new entry (OUT only) | ||
183 | * @param srp set to search result (can be NULL) | ||
184 | * @param meta metadata for the new entry | ||
185 | * @param uri URI for the new entry | ||
186 | * @return the 'uri_tab' the result was added to | ||
187 | */ | ||
188 | struct SearchTab * | ||
189 | GNUNET_GTK_add_to_uri_tab (GtkTreeIter * iter, struct SearchResult **sr, | ||
190 | const struct GNUNET_CONTAINER_MetaData *meta, | ||
191 | const struct GNUNET_FS_Uri *uri); | ||
192 | |||
193 | |||
194 | /** | ||
195 | * Add a search result to the given search tab. | ||
196 | * | ||
197 | * @param tab search tab to extend, never NULL | ||
198 | * @param iter set to position where search result is added (OUT only) | ||
199 | * @param parent_rr reference to parent entry in search tab, NULL for normal | ||
200 | * search results, | ||
201 | * @param uri uri to add, can be NULL for top-level entry of a directory opened from disk | ||
202 | * (in this case, we don't know the URI and should probably not | ||
203 | * bother to calculate it) | ||
204 | * @param meta metadata of the entry | ||
205 | * @param result associated FS search result (can be NULL if this result | ||
206 | * was part of a directory) | ||
207 | * @param applicability_rank how relevant is the result | ||
208 | * @return struct representing the search result (also stored in the tree | ||
209 | * model at 'iter') | ||
210 | */ | ||
211 | struct SearchResult * | ||
212 | GNUNET_GTK_add_search_result (struct SearchTab *tab, | ||
213 | GtkTreeIter *iter, | ||
214 | GtkTreeRowReference *parent_rr, | ||
215 | const struct GNUNET_FS_Uri *uri, | ||
216 | const struct GNUNET_CONTAINER_MetaData *meta, | ||
217 | struct GNUNET_FS_SearchResult *result, | ||
218 | uint32_t applicability_rank); | ||
219 | |||
220 | |||
221 | /** | ||
222 | * Notification of FS to a client about the progress of an | ||
223 | * operation. Callbacks of this type will be used for uploads, | ||
224 | * downloads and searches. Some of the arguments depend a bit | ||
225 | * in their meaning on the context in which the callback is used. | ||
226 | * | ||
227 | * @param cls closure | ||
228 | * @param info details about the event, specifying the event type | ||
229 | * and various bits about the event | ||
230 | * @return client-context (for the next progress call | ||
231 | * for this operation; should be set to NULL for | ||
232 | * SUSPEND and STOPPED events). The value returned | ||
233 | * will be passed to future callbacks in the respective | ||
234 | * field in the GNUNET_FS_ProgressInfo struct. | ||
235 | */ | ||
236 | void * | ||
237 | GNUNET_GTK_fs_event_handler (void *cls, | ||
238 | const struct GNUNET_FS_ProgressInfo *info); | ||
239 | |||
240 | |||
241 | /* end of gnunet-fs-gtk-event_handler.h */ | ||