gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r32505 - gnunet-gtk/src/peerinfo


From: gnunet
Subject: [GNUnet-SVN] r32505 - gnunet-gtk/src/peerinfo
Date: Tue, 4 Mar 2014 23:34:19 +0100

Author: grothoff
Date: 2014-03-04 23:34:19 +0100 (Tue, 04 Mar 2014)
New Revision: 32505

Modified:
   gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk.c
Log:
fix #3327: only edit friends if we have permissions to do so; also fix compiler 
warning due to minor transport API change

Modified: gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk.c
===================================================================
--- gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk.c       2014-03-04 22:16:09 UTC 
(rev 32504)
+++ gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk.c       2014-03-04 22:34:19 UTC 
(rev 32505)
@@ -677,10 +677,17 @@
   info = GNUNET_new (struct PeerInfo);
   info->pid = *peer;
   gtk_tree_store_append (ts, &iter, NULL);
+
+  if (NULL != friends)
+  {
+    gtk_tree_store_set (ts, &iter,
+                        PEERINFO_MC_IS_FRIEND,
+                        GNUNET_CONTAINER_multipeermap_contains (friends,
+                                                                peer),
+                        -1);
+  }
   gtk_tree_store_set (ts, &iter,
                       PEERINFO_MC_PEER_IDENTITY_STRING, GNUNET_i2s (peer),
-                      PEERINFO_MC_IS_FRIEND, 
GNUNET_CONTAINER_multipeermap_contains (friends,
-                                                                               
      peer),
                       PEERINFO_MC_PEERINFO, info,
                       PEERINFO_MC_SHOW_FRIEND, TRUE,
                       PEERINFO_MC_CORE_CONNECTIVITY_LED, led_red,
@@ -863,16 +870,19 @@
  * @param peer peer this update is about,
  *      NULL if this is the final last callback for a iteration operation
  * @param address address, NULL for disconnect notification in monitor mode
+ * @param last_validation when was this address last validated
  * @param valid_until when does this address expire
  * @param next_validation time of the next validation operation
- *
+ * @param state state in the validation state machine (FIXME: not used yet)
  */
 static void
 validation_monitor_cb (void *cts,
                       const struct GNUNET_PeerIdentity *peer,
                       const struct GNUNET_HELLO_Address *address,
+                       struct GNUNET_TIME_Absolute last_validation,
                       struct GNUNET_TIME_Absolute valid_until,
-                      struct GNUNET_TIME_Absolute next_validation)
+                      struct GNUNET_TIME_Absolute next_validation,
+                       enum GNUNET_TRANSPORT_ValidationState state)
 {
   struct PeerInfo *info;
   struct PeerAddress *pa;
@@ -1014,6 +1024,11 @@
   struct PeerInfo *info;
   gboolean oldvalue;
 
+  if (NULL == friends)
+  {
+    GNUNET_break (0);
+    return;
+  }
   if (! gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (ts), &old, path))
   {
     GNUNET_break (0);
@@ -1091,6 +1106,11 @@
 add_friend (void *cts,
             const struct GNUNET_PeerIdentity *friend)
 {
+  if (NULL == friends)
+  {
+    GNUNET_break (0);
+    return;
+  }
   GNUNET_break (GNUNET_YES ==
                 GNUNET_CONTAINER_multipeermap_put (friends,
                                                    friend,
@@ -1180,24 +1200,46 @@
 {
   GtkWidget *main_window;
   GtkTreeView *tv;
+  const struct GNUNET_CONFIGURATION_Handle *cfg;
+  int can_edit_friends;
 
   ml = cts;
   if (GNUNET_OK !=
       GNUNET_GTK_main_loop_build_window (ml, NULL))
     return;
+  cfg = get_configuration ();
   led_green = load_led ("green");
   led_red = load_led ("red");
   GNUNET_GTK_set_icon_search_path ();
   GNUNET_GTK_setup_nls ();
-  friends = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO);
-  if (GNUNET_OK !=
-      GNUNET_FRIENDS_parse (get_configuration (),
-                            &add_friend,
-                            NULL))
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                _("Failed to parse list of friends\n"));
+  can_edit_friends =
+    (GNUNET_NO ==
+     GNUNET_CONFIGURATION_have_value (cfg,
+                                      "ARM",
+                                      "SYSTEM_ONLY")) ||
+    (GNUNET_YES ==
+     GNUNET_CONFIGURATION_get_value_yesno (cfg,
+                                           "ARM",
+                                           "SYSTEM_ONLY"));
+  if (can_edit_friends)
+  {
+    friends = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO);
+    if (GNUNET_OK !=
+        GNUNET_FRIENDS_parse (cfg,
+                              &add_friend,
+                              NULL))
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                  _("Failed to parse list of friends\n"));
+  }
+  else
+  {
+    gtk_tree_view_column_set_visible
+      (GTK_TREE_VIEW_COLUMN
+       (get_object ("GNUNET_PEERINFO_GTK_main_window_friends_treeviewcolumn")),
+       FALSE);
+  }
   peer2info = GNUNET_CONTAINER_multipeermap_create (256, GNUNET_NO);
-  core = GNUNET_CORE_connect (get_configuration (),
+  core = GNUNET_CORE_connect (cfg,
                              NULL,
                              NULL,
                              &handle_core_connect,
@@ -1205,22 +1247,22 @@
                              NULL, GNUNET_NO,
                              NULL, GNUNET_NO,
                              NULL);
-  pnc = GNUNET_PEERINFO_notify (get_configuration (),
+  pnc = GNUNET_PEERINFO_notify (cfg,
                                GNUNET_NO,
                                &peerinfo_processor, NULL);
-  pmc = GNUNET_TRANSPORT_monitor_peers (get_configuration (),
+  pmc = GNUNET_TRANSPORT_monitor_peers (cfg,
                                        NULL,
                                        GNUNET_NO,
                                        GNUNET_TIME_UNIT_FOREVER_REL,
                                        &transport_peer_cb,
                                        NULL);
-  vmc = GNUNET_TRANSPORT_monitor_validation_entries (get_configuration (),
+  vmc = GNUNET_TRANSPORT_monitor_validation_entries (cfg,
                                                     NULL,
                                                     GNUNET_NO,
                                                     
GNUNET_TIME_UNIT_FOREVER_REL,
                                                     &validation_monitor_cb,
                                                     NULL);
-  ats = GNUNET_ATS_performance_init (get_configuration (),
+  ats = GNUNET_ATS_performance_init (cfg,
                                      &status_cb, NULL);
   tvc_core_connectivity = GTK_TREE_VIEW_COLUMN (get_object 
("GNUNET_PEERINFO_GTK_main_window_core_connectivity_treeviewcolumn"));
   tvc_ats_connectivity = GTK_TREE_VIEW_COLUMN (get_object 
("GNUNET_PEERINFO_GTK_main_window_ats_connectivity_treeviewcolumn"));




reply via email to

[Prev in Thread] Current Thread [Next in Thread]