aboutsummaryrefslogtreecommitdiff
path: root/src/conversation/gnunet-conversation-gtk.h
blob: 8e75a8ae0ca4f2e4d05abb5a3c8ea5f19c7b2b7f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
/*
     This file is part of GNUnet
     (C) 2013 Christian Grothoff (and other contributing authors)

     GNUnet is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published
     by the Free Software Foundation; either version 3, or (at your
     option) any later version.

     GNUnet is distributed in the hope that it will be useful, but
     WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     General Public License for more details.

     You should have received a copy of the GNU General Public License
     along with GNUnet; see the file COPYING.  If not, write to the
     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
     Boston, MA 02111-1307, USA.
*/

/**
 * @file src/identity/gnunet-identity-gtk.h
 * @author Christian Grothoff
 */
#include <gnunet/gnunet_util_lib.h>


#ifndef GNUNET_CONVERSATION_GTK_H
#define GNUNET_CONVERSATION_GTK_H

/*
 * macro's
 */

#define UPDATE_STATUS(format, ...) update_status(g_strdup_printf (format, ## __VA_ARGS__))

#define UPDATE_INFOBAR(format, ...) set_infobar_text(g_strdup_printf (format, ## __VA_ARGS__))

#define LOG(format, ...) log_message(g_strdup_printf (format, ## __VA_ARGS__))




/**
 * Get our configuration.
 *
 * @return configuration handle
 */
const struct GNUNET_CONFIGURATION_Handle *
GIG_get_configuration (void);


/**
 * Handle to our main loop.
 */
static struct GNUNET_GTK_MainLoop *ml;

/**
 * Should gnunet-identity-gtk start in tray mode?
 */
static int tray_only;

/**
 * Head of operations.
 */
static struct OperationContext *oc_head;

/**
 * Tail of operations.
 */
static struct OperationContext *oc_tail;

/**
 * Possible states of the phone.
 */
enum PhoneState
{
  /**
   * We're waiting for our own idenitty.
   */
  PS_LOOKUP_EGO,

  /**
   * We're listening for calls
   */
  PS_LISTEN,

  /**
   * We accepted an incoming phone call.
   */
  PS_ACCEPTED,

  /**
   * Internal error
   */
  PS_ERROR
};

/**
 * States for current outgoing call.
 */
enum CallState
{
  /**
   * We are looking up some other participant.
   */
  CS_RESOLVING,

  /**
   * We are now ringing the other participant.
   */
  CS_RINGING,

  /**
   * The other party accepted our call and we are now connected.
   */
  CS_CONNECTED,

  /**
   * The call is currently suspended (by us).
   */
  CS_SUSPENDED
};



/**
 * List of incoming calls
 */
struct CallList
{

  /**
   * A DLL.
   */
  struct CallList *prev;

  /**
   * A DLL.
   */
  struct CallList *next;

  /**
   * Handle to hang up or activate.
   */
  struct GNUNET_CONVERSATION_Caller *caller;

  /**
   * String identifying the caller.
   */
  char *caller_id;

  /**
   * Unique number of the call.
   */
  unsigned int caller_num;

};



/**
 * Phone handle
 */
static struct GNUNET_CONVERSATION_Phone *phone;

/**
 * Call handle (for active outgoing call).
 */
static struct GNUNET_CONVERSATION_Call *call;

/**
 * Caller handle (for active incoming call).
 */
static struct CallList *cl_active;

/**
 * Head of calls waiting to be accepted.
 */
static struct CallList *cl_head;

/**
 * Tail of calls waiting to be accepted.
 */
static struct CallList *cl_tail;

/**
 * Desired phone line.
 */
static unsigned int line;
static unsigned int line1;

/**
 * Our speaker.
 */
static struct GNUNET_SPEAKER_Handle *speaker;

/**
 * Our microphone.
 */
static struct GNUNET_MICROPHONE_Handle *mic;

/**
 * Our configurations.
 */
static struct GNUNET_CONFIGURATION_Handle *cfg;
static struct GNUNET_CONFIGURATION_Handle *cfg1;
static struct GNUNET_CONFIGURATION_Handle *cfg2;


/**
 * Our ego.
 */
static struct GNUNET_IDENTITY_Ego *caller_id;

/**
 * Handle to identity service.
 */
static struct GNUNET_IDENTITY_Handle *id;

/**
 * Name of our ego.
 */
static char *ego_name;

/**
 * Name of conversation partner (if any).
 */
static char *peer_name;

/**
 * Our phone's current state.
 */
static enum PhoneState phone_state;

/**
 * Our call's current state.
 */
static enum CallState call_state;

/**
 * Counts the number of incoming calls we have had so far.
 */
static unsigned int caller_num_gen;

/**
 * GNS address for this phone.
 */
static char *address;

/**
 * Be verbose.
 */
static int verbose = 1;

/**
 * Handle to the namestore.
 */
static struct GNUNET_NAMESTORE_Handle *ns;

/**
 * Private key for the our zone.
 */
struct GNUNET_CRYPTO_EcdsaPrivateKey zone_pkey;

/**
  * Public key of the zone we are currently editing.
  */
struct GNUNET_CRYPTO_EcdsaPublicKey pubkey;



/*
 * List iterator for the 'list' operation.
 */
static struct GNUNET_NAMESTORE_ZoneIterator *list_it;


/**
 * Name of the records to add/list/remove.
 */
static char *name;

static void
identity_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx,
             const char *name);


enum CONVERSATION_ModelColumns
{
  // gchar array 
  CONVERSATION_CONTACT_NAME = 0
};

/**
 * List of all known zones/egos.
 */
static GtkListStore *contacts_liststore;

/**
 * List of contacts.
 */
static GtkTreeStore *contacts_treestore;

/**
 * The main tree view for 'gns' that shows the records.
 */
static GtkTreeView *contacts_treeview;

/**
 * Tree model (same object as 'contacts_treestore', just different type).
 */
static GtkTreeModel *contacts_treemodel;


/**
 * call history liststore
 */
static GtkListStore *history_liststore;

/**
 * call history treestore
 */
static GtkTreeStore *history_treestore;

/**
 * call histore treeview
 */
static GtkTreeView *history_treeview;

/**
 * call history tree model
 */
static GtkTreeModel *history_treemodel;


/**                      
 * Current state of iterating elements for the client.
 * NULL if we are not currently iterating.
 */
struct GNUNET_CONTAINER_MultiHashMapIterator *iter;

/**
 *name of the incomming caller pkey or record name if known
*/
char *callerName;

/**
* peer id of a contact
*/
char *peer_id;

/**
 * Queue entry for the 'add' operation.
 */
static struct GNUNET_NAMESTORE_QueueEntry *add_qe;

/**
 * Global return value
 */
static int ret;

/**
* incoming call popup window, global because must be destroyed when other end hangs up
*/
GtkDialog *dialog;



/**
 * Context for edit operations and environment for plugins.
 * Typical plugins will only use the @e check_validity callback.
 */
//struct GNUNET_GTK_NAMESTORE_PluginEnvironment
//{
//
//  /**
//   * Function that should be called by the plugin whenever values in
//   * the dialog were edited.  It will check the validity of the dialog
//   * and update the "save" button accordingly.
//   */
//  void (*check_validity)(struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc);
//
//  /**
//   * Builder for the dialog.
//   */
//  GtkBuilder *builder;
//
//  /**
//   * Main dialog window.
//   */
//  GtkDialog *dialog;
//
//  /**
//   * Where in the tree view are we editing?
//   */
//  struct RecordInfo *ri;
//
//  /**
//   * Name of the record.
//   */
//  gchar *name;
//
//  /**
//   * Value of the record in string format.
//   */
//  gchar *n_value;
//
//  /**
//   * Name of the zone into which the record should be placed.
//   */
//  gchar *new_zone_option;
//
//  /**
//   * Ego of the zone into which the record should be placed.
//   */
//  struct GNUNET_IDENTITY_Ego *ego;
//
//  /**
//   * List of all zones.
//   */
//  GtkListStore *zone_liststore;
//
//  /**
//   * The plugin we used to edit the value.
//   */
//  struct GNUNET_GTK_NAMESTORE_PluginFunctions *plugin;
//
//  /**
//   * Name of the plugin library.
//   */
//  char *liblow;
//
//  /**
//   * Expiration time value (absolute or relative).
//   */
//  guint64 n_exp_time;
//
//  /**
//   * Offset of the record we are editing in the 'rd' list of 'ri'.
//   */
//  unsigned int off;
//
//  /**
//   * Flag indicating if the old record was in the namestore.
//   */
//  int old_record_in_namestore;
//
//  /**
//   * Type of the record.
//   */
//  uint32_t record_type;
//
//  /**
//   * Is this record 'public'?
//   */
//  gboolean n_public;
//
//  /**
//   * Is the expiration time relative?
//   */
//  gboolean n_is_relative;
//
//  /**
//   * Is this record a shadow record?
//   */
//  gboolean n_is_shadow;
//
//};
//


#endif