aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-15 14:13:21 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-15 14:13:21 +0000
commitfa1f4288bf52f66c46c6bf8611111cde0e4b6d44 (patch)
treed54dffba878db29bf7a870996dd8768f15806936
parentfb9d1f34844655a8ac65b325561ddb0430653a47 (diff)
downloadgnunet-gtk-fa1f4288bf52f66c46c6bf8611111cde0e4b6d44.tar.gz
gnunet-gtk-fa1f4288bf52f66c46c6bf8611111cde0e4b6d44.zip
draft
-rw-r--r--src/peerinfo/Makefile.am17
-rw-r--r--src/peerinfo/gnunet-peerinfo-gtk.c11
-rw-r--r--src/peerinfo/peerinfo.c90
-rw-r--r--src/peerinfo/peerinfo.h47
4 files changed, 165 insertions, 0 deletions
diff --git a/src/peerinfo/Makefile.am b/src/peerinfo/Makefile.am
new file mode 100644
index 00000000..c5fc79de
--- /dev/null
+++ b/src/peerinfo/Makefile.am
@@ -0,0 +1,17 @@
1SUBDIRS = .
2
3INCLUDES = \
4 -I$(top_srcdir)/ \
5 @GTK_CFLAGS@ \
6 @GNUNETGTK_CFLAGS@
7
8bin_PROGRAMS = gnunet-peerinfo-gtk
9
10gnunet_peerinfo_gtk_SOURCES = \
11 peerinfo.c peerinfo.h
12gnunet_peerinfo_gtk_LDADD = \
13 @GTK_LIBS@ \
14 -lgnunetutil -lgnunetpeerinfo \
15 $(INTLLIBS)
16gnunet_peerinfo_gtk_LDFLAGS = \
17 -export-dynamic \ No newline at end of file
diff --git a/src/peerinfo/gnunet-peerinfo-gtk.c b/src/peerinfo/gnunet-peerinfo-gtk.c
new file mode 100644
index 00000000..75c664fc
--- /dev/null
+++ b/src/peerinfo/gnunet-peerinfo-gtk.c
@@ -0,0 +1,11 @@
1 mc->pnc = GNUNET_PEERINFO_notify (cfg,
2 &GNUNET_GTK_peerinfo_processor,
3 NULL);
4 if (mc->pnc == NULL)
5 {
6 gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (mc->builder,
7 "GNUNET_GTK_main_window_peerinfo_treeview")));
8 gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (mc->builder,
9 "GNUNET_GTK_main_menu_view_neighbours")));
10 /* FIXME: set warning in status bar... */
11 }
diff --git a/src/peerinfo/peerinfo.c b/src/peerinfo/peerinfo.c
new file mode 100644
index 00000000..192f0458
--- /dev/null
+++ b/src/peerinfo/peerinfo.c
@@ -0,0 +1,90 @@
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/peerinfo/peerinfo.c
23 * @brief Updates the peerinfo view
24 * @author Christian Grothoff
25 */
26#include "peerinfo.h"
27
28/**
29 * Function called for peers that we know about.
30 *
31 * @param cls closure
32 * @param peer id of the peer, NULL for last call
33 * @param hello hello message for the peer (can be NULL)
34 * @param err_msg NULL if successful, otherwise contains error message
35 */
36void
37GNUNET_GTK_peerinfo_processor (void *cls,
38 const struct GNUNET_PeerIdentity * peer,
39 const struct GNUNET_HELLO_Message * hello,
40 const char * err_msg)
41{
42 GtkListStore *ls;
43 GtkTreeModel *tm;
44 GtkTreeIter iter;
45 int found;
46 gchar *pid;
47 const char *npid;
48 struct GNUNET_CRYPTO_HashAsciiEncoded enc;
49
50 GNUNET_CRYPTO_hash_to_enc (&peer->hashPubKey,
51 &enc);
52 npid = (const char*) &enc;
53 ls = GTK_LIST_STORE (GNUNET_GTK_get_main_window_object ("GNUNET_GTK_peer_info_list_store"));
54 tm = GTK_TREE_MODEL (ls);
55 found = GNUNET_NO;
56 if (TRUE == gtk_tree_model_get_iter_first (tm, &iter))
57 {
58 do
59 {
60 pid = NULL;
61 gtk_tree_model_get (tm,
62 &iter,
63 0, &pid, -1);
64 if (pid != NULL)
65 {
66 if (0 == strcmp (pid, npid))
67 {
68 found = GNUNET_YES;
69 g_free (pid);
70 break;
71 }
72 }
73 g_free (pid);
74 }
75 while ( (found == GNUNET_NO) &&
76 (TRUE == gtk_tree_model_iter_next (tm,
77 &iter)));
78 }
79 if (found == GNUNET_NO)
80 gtk_list_store_append (ls, &iter);
81 gtk_list_store_set (ls,
82 &iter,
83 0, npid,
84 1, 0 /* number of known addresses */,
85 2, "" /* country name */,
86 3, NULL /* country flag */,
87 -1);
88}
89
90/* end of peerinfo.c */
diff --git a/src/peerinfo/peerinfo.h b/src/peerinfo/peerinfo.h
new file mode 100644
index 00000000..4d0c7303
--- /dev/null
+++ b/src/peerinfo/peerinfo.h
@@ -0,0 +1,47 @@
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/peerinfo/peerinfo.h
23 * @brief Updates the peerinfo view
24 * @author Christian Grothoff
25 */
26#ifndef PEERINFO_H
27#define PEERINFO_H
28
29#include "gnunet_gtk.h"
30#include <gnunet/gnunet_peerinfo_service.h>
31
32/**
33 * Function called for peers that we know about.
34 *
35 * @param cls closure
36 * @param peer id of the peer, NULL for last call
37 * @param hello hello message for the peer (can be NULL)
38 * @param err_msg NULL if successful, otherwise contains error message
39 */
40void
41GNUNET_GTK_peerinfo_processor (void *cls,
42 const struct GNUNET_PeerIdentity * peer,
43 const struct GNUNET_HELLO_Message * hello,
44 const char * err_msg);
45
46/* end of peerinfo.h */
47#endif