diff options
Diffstat (limited to 'src/conversation/gnunet-conversation-gtk.h')
-rw-r--r-- | src/conversation/gnunet-conversation-gtk.h | 507 |
1 files changed, 507 insertions, 0 deletions
diff --git a/src/conversation/gnunet-conversation-gtk.h b/src/conversation/gnunet-conversation-gtk.h new file mode 100644 index 00000000..98a29900 --- /dev/null +++ b/src/conversation/gnunet-conversation-gtk.h | |||
@@ -0,0 +1,507 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | (C) 2013 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 3, 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/identity/gnunet-identity-gtk.h | ||
23 | * @author Christian Grothoff | ||
24 | */ | ||
25 | #include <gnunet/gnunet_util_lib.h> | ||
26 | |||
27 | |||
28 | #ifndef GNUNET_CONVERSATION_GTK_H | ||
29 | #define GNUNET_CONVERSATION_GTK_H | ||
30 | |||
31 | /* | ||
32 | * macro's | ||
33 | */ | ||
34 | |||
35 | #define UPDATE_STATUS(format, ...) update_status(g_strdup_printf (format, ## __VA_ARGS__)) | ||
36 | |||
37 | #define UPDATE_INFOBAR(format, ...) set_infobar_text(g_strdup_printf (format, ## __VA_ARGS__)) | ||
38 | |||
39 | #define LOG(format, ...) log_message(g_strdup_printf (format, ## __VA_ARGS__)) | ||
40 | |||
41 | |||
42 | |||
43 | |||
44 | /** | ||
45 | * Get our configuration. | ||
46 | * | ||
47 | * @return configuration handle | ||
48 | */ | ||
49 | const struct GNUNET_CONFIGURATION_Handle * | ||
50 | GIG_get_configuration (void); | ||
51 | |||
52 | |||
53 | /** | ||
54 | * Handle to our main loop. | ||
55 | */ | ||
56 | static struct GNUNET_GTK_MainLoop *ml; | ||
57 | |||
58 | /** | ||
59 | * Should gnunet-identity-gtk start in tray mode? | ||
60 | */ | ||
61 | static int tray_only; | ||
62 | |||
63 | /** | ||
64 | * Head of operations. | ||
65 | */ | ||
66 | static struct OperationContext *oc_head; | ||
67 | |||
68 | /** | ||
69 | * Tail of operations. | ||
70 | */ | ||
71 | static struct OperationContext *oc_tail; | ||
72 | |||
73 | /** | ||
74 | * Possible states of the phone. | ||
75 | */ | ||
76 | enum PhoneState | ||
77 | { | ||
78 | /** | ||
79 | * We're waiting for our own idenitty. | ||
80 | */ | ||
81 | PS_LOOKUP_EGO, | ||
82 | |||
83 | /** | ||
84 | * We're listening for calls | ||
85 | */ | ||
86 | PS_LISTEN, | ||
87 | |||
88 | /** | ||
89 | * We accepted an incoming phone call. | ||
90 | */ | ||
91 | PS_ACCEPTED, | ||
92 | |||
93 | /** | ||
94 | * Internal error | ||
95 | */ | ||
96 | PS_ERROR | ||
97 | }; | ||
98 | |||
99 | /** | ||
100 | * States for current outgoing call. | ||
101 | */ | ||
102 | enum CallState | ||
103 | { | ||
104 | /** | ||
105 | * We are looking up some other participant. | ||
106 | */ | ||
107 | CS_RESOLVING, | ||
108 | |||
109 | /** | ||
110 | * We are now ringing the other participant. | ||
111 | */ | ||
112 | CS_RINGING, | ||
113 | |||
114 | /** | ||
115 | * The other party accepted our call and we are now connected. | ||
116 | */ | ||
117 | CS_CONNECTED, | ||
118 | |||
119 | /** | ||
120 | * The call is currently suspended (by us). | ||
121 | */ | ||
122 | CS_SUSPENDED | ||
123 | }; | ||
124 | |||
125 | |||
126 | |||
127 | /** | ||
128 | * List of incoming calls | ||
129 | */ | ||
130 | struct CallList | ||
131 | { | ||
132 | |||
133 | /** | ||
134 | * A DLL. | ||
135 | */ | ||
136 | struct CallList *prev; | ||
137 | |||
138 | /** | ||
139 | * A DLL. | ||
140 | */ | ||
141 | struct CallList *next; | ||
142 | |||
143 | /** | ||
144 | * Handle to hang up or activate. | ||
145 | */ | ||
146 | struct GNUNET_CONVERSATION_Caller *caller; | ||
147 | |||
148 | /** | ||
149 | * String identifying the caller. | ||
150 | */ | ||
151 | char *caller_id; | ||
152 | |||
153 | /** | ||
154 | * Unique number of the call. | ||
155 | */ | ||
156 | unsigned int caller_num; | ||
157 | |||
158 | }; | ||
159 | |||
160 | |||
161 | |||
162 | /** | ||
163 | * Phone handle | ||
164 | */ | ||
165 | static struct GNUNET_CONVERSATION_Phone *phone; | ||
166 | |||
167 | /** | ||
168 | * Call handle (for active outgoing call). | ||
169 | */ | ||
170 | static struct GNUNET_CONVERSATION_Call *call; | ||
171 | |||
172 | /** | ||
173 | * Caller handle (for active incoming call). | ||
174 | */ | ||
175 | static struct CallList *cl_active; | ||
176 | |||
177 | /** | ||
178 | * Head of calls waiting to be accepted. | ||
179 | */ | ||
180 | static struct CallList *cl_head; | ||
181 | |||
182 | /** | ||
183 | * Tail of calls waiting to be accepted. | ||
184 | */ | ||
185 | static struct CallList *cl_tail; | ||
186 | |||
187 | /** | ||
188 | * Desired phone line. | ||
189 | */ | ||
190 | static unsigned int line; | ||
191 | static unsigned int line1; | ||
192 | |||
193 | /** | ||
194 | * Our speaker. | ||
195 | */ | ||
196 | static struct GNUNET_SPEAKER_Handle *speaker; | ||
197 | |||
198 | /** | ||
199 | * Our microphone. | ||
200 | */ | ||
201 | static struct GNUNET_MICROPHONE_Handle *mic; | ||
202 | |||
203 | /** | ||
204 | * Our configurations. | ||
205 | */ | ||
206 | static struct GNUNET_CONFIGURATION_Handle *cfg; | ||
207 | static struct GNUNET_CONFIGURATION_Handle *cfg1; | ||
208 | static struct GNUNET_CONFIGURATION_Handle *cfg2; | ||
209 | |||
210 | |||
211 | /** | ||
212 | * Our ego. | ||
213 | */ | ||
214 | static struct GNUNET_IDENTITY_Ego *caller_id; | ||
215 | |||
216 | /** | ||
217 | * Handle to identity service. | ||
218 | */ | ||
219 | static struct GNUNET_IDENTITY_Handle *id; | ||
220 | |||
221 | /** | ||
222 | * Name of our ego. | ||
223 | */ | ||
224 | static char *ego_name; | ||
225 | |||
226 | /** | ||
227 | * Name of conversation partner (if any). | ||
228 | */ | ||
229 | static char *peer_name; | ||
230 | |||
231 | /** | ||
232 | * Our phone's current state. | ||
233 | */ | ||
234 | static enum PhoneState phone_state; | ||
235 | |||
236 | /** | ||
237 | * Our call's current state. | ||
238 | */ | ||
239 | static enum CallState call_state; | ||
240 | |||
241 | /** | ||
242 | * Counts the number of incoming calls we have had so far. | ||
243 | */ | ||
244 | static unsigned int caller_num_gen; | ||
245 | |||
246 | /** | ||
247 | * GNS address for this phone. | ||
248 | */ | ||
249 | static char *address; | ||
250 | |||
251 | /** | ||
252 | * Be verbose. | ||
253 | */ | ||
254 | static int verbose = 1; | ||
255 | |||
256 | /** | ||
257 | * Handle to the namestore. | ||
258 | */ | ||
259 | static struct GNUNET_NAMESTORE_Handle *ns; | ||
260 | |||
261 | /** | ||
262 | * Private key for the our zone. | ||
263 | */ | ||
264 | struct GNUNET_CRYPTO_EcdsaPrivateKey zone_pkey; | ||
265 | |||
266 | /** | ||
267 | * Public key of the zone we are currently editing. | ||
268 | */ | ||
269 | struct GNUNET_CRYPTO_EcdsaPublicKey pubkey; | ||
270 | |||
271 | |||
272 | |||
273 | /** | ||
274 | * gui stuff | ||
275 | */ | ||
276 | |||
277 | /* | ||
278 | void update_state(); | ||
279 | void update_status (const gchar *message); | ||
280 | void set_button_text (const char *button_name, const char *label); | ||
281 | void disable_button (const char *button_name); | ||
282 | void enable_button (const char *button_name); | ||
283 | void show_infobar ( ); | ||
284 | void hide_infobar ( ); | ||
285 | void set_infobar_text (const gchar *text); | ||
286 | void log_message (const char *message); | ||
287 | void GNUNET_CONVERSATION_GTK_on_call_clicked (); | ||
288 | void GNUNET_CONVERSATION_GTK_on_hangup_clicked (); | ||
289 | void GNUNET_CONVERSATION_GTK_on_accept_clicked (); | ||
290 | void GNUNET_CONVERSATION_GTK_on_reject_clicked (); | ||
291 | void GNUNET_CONVERSATION_GTK_on_pause_clicked (); | ||
292 | void GNUNET_CONVERSATION_GTK_on_resume_clicked (); | ||
293 | void GNUNET_CONVERSATION_GTK_on_status_clicked (); | ||
294 | */ | ||
295 | /** | ||
296 | * phone stuff | ||
297 | */ | ||
298 | /* | ||
299 | static void do_call (const char *); | ||
300 | static void do_accept (const char *); | ||
301 | static void do_status (const char *); | ||
302 | static void do_suspend (const char *); | ||
303 | static void do_resume (const char *); | ||
304 | static void do_reject (const char *); | ||
305 | */ | ||
306 | |||
307 | /* | ||
308 | * List iterator for the 'list' operation. | ||
309 | */ | ||
310 | static struct GNUNET_NAMESTORE_ZoneIterator *list_it; | ||
311 | |||
312 | |||
313 | /** | ||
314 | * Name of the records to add/list/remove. | ||
315 | */ | ||
316 | static char *name; | ||
317 | |||
318 | static void | ||
319 | identity_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, | ||
320 | const char *name); | ||
321 | |||
322 | |||
323 | enum CONVERSATION_ModelColumns | ||
324 | { | ||
325 | // gchar array | ||
326 | CONVERSATION_CONTACT_NAME = 0 | ||
327 | }; | ||
328 | |||
329 | /** | ||
330 | * List of all known zones/egos. | ||
331 | */ | ||
332 | static GtkListStore *contacts_liststore; | ||
333 | |||
334 | /** | ||
335 | * List of contacts. | ||
336 | */ | ||
337 | static GtkTreeStore *contacts_treestore; | ||
338 | |||
339 | /** | ||
340 | * The main tree view for 'gns' that shows the records. | ||
341 | */ | ||
342 | static GtkTreeView *contacts_treeview; | ||
343 | |||
344 | /** | ||
345 | * Tree model (same object as 'contacts_treestore', just different type). | ||
346 | */ | ||
347 | static GtkTreeModel *contacts_treemodel; | ||
348 | |||
349 | |||
350 | /** | ||
351 | * call history liststore | ||
352 | */ | ||
353 | static GtkListStore *history_liststore; | ||
354 | |||
355 | /** | ||
356 | * call history treestore | ||
357 | */ | ||
358 | static GtkTreeStore *history_treestore; | ||
359 | |||
360 | /** | ||
361 | * call histore treeview | ||
362 | */ | ||
363 | static GtkTreeView *history_treeview; | ||
364 | |||
365 | /** | ||
366 | * call history tree model | ||
367 | */ | ||
368 | static GtkTreeModel *history_treemodel; | ||
369 | |||
370 | |||
371 | /** | ||
372 | * Current state of iterating elements for the client. | ||
373 | * NULL if we are not currently iterating. | ||
374 | */ | ||
375 | struct GNUNET_CONTAINER_MultiHashMapIterator *iter; | ||
376 | |||
377 | /** | ||
378 | *name of the incomming caller pkey or record name if known | ||
379 | */ | ||
380 | char *callerName; | ||
381 | |||
382 | /** | ||
383 | * peer id of a contact | ||
384 | */ | ||
385 | char *peer_id; | ||
386 | |||
387 | /** | ||
388 | * Queue entry for the 'add' operation. | ||
389 | */ | ||
390 | static struct GNUNET_NAMESTORE_QueueEntry *add_qe; | ||
391 | |||
392 | /** | ||
393 | * Global return value | ||
394 | */ | ||
395 | static int ret; | ||
396 | |||
397 | /** | ||
398 | * incoming call popup window, global because must be destroyed when other end hangs up | ||
399 | */ | ||
400 | GtkDialog *dialog; | ||
401 | |||
402 | |||
403 | |||
404 | /** | ||
405 | * Context for edit operations and environment for plugins. | ||
406 | * Typical plugins will only use the @e check_validity callback. | ||
407 | */ | ||
408 | //struct GNUNET_GTK_NAMESTORE_PluginEnvironment | ||
409 | //{ | ||
410 | // | ||
411 | // /** | ||
412 | // * Function that should be called by the plugin whenever values in | ||
413 | // * the dialog were edited. It will check the validity of the dialog | ||
414 | // * and update the "save" button accordingly. | ||
415 | // */ | ||
416 | // void (*check_validity)(struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc); | ||
417 | // | ||
418 | // /** | ||
419 | // * Builder for the dialog. | ||
420 | // */ | ||
421 | // GtkBuilder *builder; | ||
422 | // | ||
423 | // /** | ||
424 | // * Main dialog window. | ||
425 | // */ | ||
426 | // GtkDialog *dialog; | ||
427 | // | ||
428 | // /** | ||
429 | // * Where in the tree view are we editing? | ||
430 | // */ | ||
431 | // struct RecordInfo *ri; | ||
432 | // | ||
433 | // /** | ||
434 | // * Name of the record. | ||
435 | // */ | ||
436 | // gchar *name; | ||
437 | // | ||
438 | // /** | ||
439 | // * Value of the record in string format. | ||
440 | // */ | ||
441 | // gchar *n_value; | ||
442 | // | ||
443 | // /** | ||
444 | // * Name of the zone into which the record should be placed. | ||
445 | // */ | ||
446 | // gchar *new_zone_option; | ||
447 | // | ||
448 | // /** | ||
449 | // * Ego of the zone into which the record should be placed. | ||
450 | // */ | ||
451 | // struct GNUNET_IDENTITY_Ego *ego; | ||
452 | // | ||
453 | // /** | ||
454 | // * List of all zones. | ||
455 | // */ | ||
456 | // GtkListStore *zone_liststore; | ||
457 | // | ||
458 | // /** | ||
459 | // * The plugin we used to edit the value. | ||
460 | // */ | ||
461 | // struct GNUNET_GTK_NAMESTORE_PluginFunctions *plugin; | ||
462 | // | ||
463 | // /** | ||
464 | // * Name of the plugin library. | ||
465 | // */ | ||
466 | // char *liblow; | ||
467 | // | ||
468 | // /** | ||
469 | // * Expiration time value (absolute or relative). | ||
470 | // */ | ||
471 | // guint64 n_exp_time; | ||
472 | // | ||
473 | // /** | ||
474 | // * Offset of the record we are editing in the 'rd' list of 'ri'. | ||
475 | // */ | ||
476 | // unsigned int off; | ||
477 | // | ||
478 | // /** | ||
479 | // * Flag indicating if the old record was in the namestore. | ||
480 | // */ | ||
481 | // int old_record_in_namestore; | ||
482 | // | ||
483 | // /** | ||
484 | // * Type of the record. | ||
485 | // */ | ||
486 | // uint32_t record_type; | ||
487 | // | ||
488 | // /** | ||
489 | // * Is this record 'public'? | ||
490 | // */ | ||
491 | // gboolean n_public; | ||
492 | // | ||
493 | // /** | ||
494 | // * Is the expiration time relative? | ||
495 | // */ | ||
496 | // gboolean n_is_relative; | ||
497 | // | ||
498 | // /** | ||
499 | // * Is this record a shadow record? | ||
500 | // */ | ||
501 | // gboolean n_is_shadow; | ||
502 | // | ||
503 | //}; | ||
504 | // | ||
505 | |||
506 | |||
507 | #endif | ||