diff options
Diffstat (limited to 'src/fs/fs_event_handler.h')
-rw-r--r-- | src/fs/fs_event_handler.h | 198 |
1 files changed, 198 insertions, 0 deletions
diff --git a/src/fs/fs_event_handler.h b/src/fs/fs_event_handler.h new file mode 100644 index 00000000..a86ff339 --- /dev/null +++ b/src/fs/fs_event_handler.h | |||
@@ -0,0 +1,198 @@ | |||
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_event_handler.h | ||
23 | * @brief Main event handler for file-sharing | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | #include "common.h" | ||
27 | |||
28 | |||
29 | struct SearchResult; | ||
30 | |||
31 | |||
32 | /** | ||
33 | * Context we keep for a search tab. | ||
34 | */ | ||
35 | struct SearchTab | ||
36 | { | ||
37 | /** | ||
38 | * This is a doubly-linked list. | ||
39 | */ | ||
40 | struct SearchTab *next; | ||
41 | |||
42 | /** | ||
43 | * This is a doubly-linked list. | ||
44 | */ | ||
45 | struct SearchTab *prev; | ||
46 | |||
47 | /** | ||
48 | * Set in case this is an inner search, otherwise NULL. | ||
49 | */ | ||
50 | struct SearchResult *parent; | ||
51 | |||
52 | /** | ||
53 | * Handle for this search with FS library. | ||
54 | */ | ||
55 | struct GNUNET_FS_SearchContext *sc; | ||
56 | |||
57 | char *query_txt; | ||
58 | |||
59 | GtkBuilder *builder; | ||
60 | |||
61 | GtkWidget *frame; | ||
62 | |||
63 | GtkWidget *tab_label; | ||
64 | |||
65 | GtkWidget *close_button; | ||
66 | |||
67 | GtkWidget *clear_button; | ||
68 | |||
69 | GtkWidget *play_button; | ||
70 | |||
71 | GtkWidget *pause_button; | ||
72 | |||
73 | GtkLabel *label; | ||
74 | |||
75 | GtkTreeStore *ts; | ||
76 | |||
77 | unsigned int num_results; | ||
78 | |||
79 | }; | ||
80 | |||
81 | |||
82 | struct DownloadEntry | ||
83 | { | ||
84 | |||
85 | /** | ||
86 | * Download entry of the parent (for recursive downloads), | ||
87 | * NULL if we are either a top-level download (from URI, | ||
88 | * from opened directory, orphaned from search or direct | ||
89 | * search result). | ||
90 | */ | ||
91 | struct DownloadEntry *pde; | ||
92 | |||
93 | /** | ||
94 | * Associated search result, or NULL if we don't belong | ||
95 | * to a search directly (download entry). | ||
96 | */ | ||
97 | struct SearchResult *sr; | ||
98 | |||
99 | /** | ||
100 | * FS handle to control the download. | ||
101 | */ | ||
102 | struct GNUNET_FS_DownloadContext *dc; | ||
103 | |||
104 | /** | ||
105 | * URI for the download. | ||
106 | */ | ||
107 | struct GNUNET_FS_Uri *uri; | ||
108 | |||
109 | /** | ||
110 | * Meta data for the download. | ||
111 | */ | ||
112 | struct GNUNET_CONTAINER_MetaData *meta; | ||
113 | |||
114 | /** | ||
115 | * Where in the tree view is this download being displayed. | ||
116 | */ | ||
117 | GtkTreeRowReference *rr; | ||
118 | |||
119 | /** | ||
120 | * Tree store where we are stored. | ||
121 | */ | ||
122 | GtkTreeStore *ts; | ||
123 | |||
124 | /** | ||
125 | * Tab where this download is currently on display. | ||
126 | */ | ||
127 | struct SearchTab *tab; | ||
128 | |||
129 | /** | ||
130 | * Has the download completed (or errored)? | ||
131 | */ | ||
132 | int is_done; | ||
133 | |||
134 | }; | ||
135 | |||
136 | |||
137 | |||
138 | |||
139 | /** | ||
140 | * Setup a new top-level entry in the URI tab. If necessary, create | ||
141 | * the URI tab first. | ||
142 | * | ||
143 | * @param iter set to the new entry | ||
144 | * @param srp set to search result | ||
145 | * @param meta metadata for the new entry | ||
146 | * @param uri URI for the new entry | ||
147 | * @return NULL on error, otherwise search tab with the new entry | ||
148 | */ | ||
149 | struct SearchTab * | ||
150 | GNUNET_GTK_add_to_uri_tab (GtkTreeIter *iter, | ||
151 | struct SearchResult **sr, | ||
152 | const struct GNUNET_CONTAINER_MetaData *meta, | ||
153 | const struct GNUNET_FS_Uri *uri); | ||
154 | |||
155 | |||
156 | |||
157 | /** | ||
158 | * Add a search result to the given search tab. | ||
159 | * | ||
160 | * @param tab search tab to extend | ||
161 | * @param iter set to position where search result is added | ||
162 | * @param parent_rr reference to parent entry in search tab | ||
163 | * @param uri uri to add | ||
164 | * @param meta metadata of the entry | ||
165 | * @param result associated FS search result (can be NULL) | ||
166 | * @param applicability_rank how relevant is the result | ||
167 | * @return entry for the search result | ||
168 | */ | ||
169 | struct SearchResult * | ||
170 | GNUNET_GTK_add_search_result (struct SearchTab *tab, | ||
171 | GtkTreeIter *iter, | ||
172 | GtkTreeRowReference *parent_rr, | ||
173 | const struct GNUNET_FS_Uri *uri, | ||
174 | const struct GNUNET_CONTAINER_MetaData *meta, | ||
175 | struct GNUNET_FS_SearchResult *result, | ||
176 | uint32_t applicability_rank); | ||
177 | |||
178 | |||
179 | /** | ||
180 | * Notification of FS to a client about the progress of an | ||
181 | * operation. Callbacks of this type will be used for uploads, | ||
182 | * downloads and searches. Some of the arguments depend a bit | ||
183 | * in their meaning on the context in which the callback is used. | ||
184 | * | ||
185 | * @param cls closure | ||
186 | * @param info details about the event, specifying the event type | ||
187 | * and various bits about the event | ||
188 | * @return client-context (for the next progress call | ||
189 | * for this operation; should be set to NULL for | ||
190 | * SUSPEND and STOPPED events). The value returned | ||
191 | * will be passed to future callbacks in the respective | ||
192 | * field in the GNUNET_FS_ProgressInfo struct. | ||
193 | */ | ||
194 | void* GNUNET_GTK_fs_event_handler (void *cls, | ||
195 | const struct GNUNET_FS_ProgressInfo *info); | ||
196 | |||
197 | |||
198 | /* end of fs_event_handler.h */ | ||