gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r20430 - gnunet-gtk/src/peerinfo
Date: Sat, 10 Mar 2012 23:09:08 +0100

Author: grothoff
Date: 2012-03-10 23:09:08 +0100 (Sat, 10 Mar 2012)
New Revision: 20430

Modified:
   gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk-flags.c
   gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk.c
Log:
-fix loading of flags


Modified: gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk-flags.c
===================================================================
--- gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk-flags.c 2012-03-10 21:58:48 UTC 
(rev 20429)
+++ gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk-flags.c 2012-03-10 22:09:08 UTC 
(rev 20430)
@@ -100,7 +100,7 @@
   for (i = 0; i < strlen (mcc); i++)
     mcc[i] = tolower (mcc[i]);
   dir = GNUNET_GTK_installation_get_path (GNUNET_OS_IPK_DATADIR);
-  GNUNET_asprintf (&fn, "%sgnunet-gtk%sflags%s%s.png", dir, DIR_SEPARATOR_STR,
+  GNUNET_asprintf (&fn, "%sflags%s%s.png", dir, 
                    DIR_SEPARATOR_STR, mcc);
   GNUNET_free (dir);
   flagBuf = gdk_pixbuf_new_from_file (fn, NULL);

Modified: gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk.c
===================================================================
--- gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk.c       2012-03-10 21:58:48 UTC 
(rev 20429)
+++ gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk.c       2012-03-10 22:09:08 UTC 
(rev 20430)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2010 Christian Grothoff (and other contributing authors)
+     (C) 2010, 2012 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
@@ -92,6 +92,10 @@
    */
   struct GNUNET_TRANSPORT_AddressToStringContext *tos;
 
+  /**
+   * Did we get any address?
+   */
+  int got_address;
 };
 
 
@@ -216,7 +220,6 @@
   const char *colon;
   const char *dot;
 
-  info->tos = NULL;
   ls = GTK_LIST_STORE (get_object ("GNUNET_PEERINFO_GTK_list_store"));
   tm = GTK_TREE_MODEL (ls);
   path = gtk_tree_row_reference_get_path (info->rr);
@@ -226,34 +229,35 @@
   if (NULL == address)
   {
     /* error */
-    gtk_list_store_set (ls, &iter, 
-                       PEERINFO_MC_NUMBER_OF_ADDRESSES, (guint) 1, 
-                       PEERINFO_MC_COUNTRY_NAME, NULL, 
-                       PEERINFO_MC_COUNTRY_FLAG, NULL, 
-                       PEERINFO_MC_ADDRESS_AS_STRING, "<error>", 
-                       -1);
+    if (GNUNET_NO == info->got_address)
+      gtk_list_store_set (ls, &iter, 
+                         PEERINFO_MC_NUMBER_OF_ADDRESSES, (guint) 1, 
+                         PEERINFO_MC_COUNTRY_NAME, NULL, 
+                         PEERINFO_MC_COUNTRY_FLAG, NULL, 
+                         PEERINFO_MC_ADDRESS_AS_STRING, "<no address>", 
+                         -1);
+    info->tos = NULL;
+    return;
   }
-  else
+  /* last address, store information in model */
+  country = NULL;
+  colon = strstr (address, ":");
+  if (NULL != colon)
   {
-    /* last address, store information in model */
-    country = NULL;
-    colon = strstr (address, ":");
-    if (NULL != colon)
-    {
-      for (dot = colon - 1; dot != address; dot--)
-        if ('.' == *dot)
-          break;
+    for (dot = colon - 1; dot != address; dot--)
       if ('.' == *dot)
-        country = GNUNET_strndup (&dot[1], (colon - dot) - 1);
-    }
-    gtk_list_store_set (ls, &iter, 
-                       PEERINFO_MC_NUMBER_OF_ADDRESSES, 1,
-                       PEERINFO_MC_COUNTRY_NAME, country, 
-                       PEERINFO_MC_COUNTRY_FLAG, GNUNET_PEERINFO_GTK_get_flag 
(country), 
-                       PEERINFO_MC_ADDRESS_AS_STRING, address, 
-                       -1);
-    GNUNET_free (country);
+       break;
+    if ('.' == *dot)
+      country = GNUNET_strndup (&dot[1], (colon - dot) - 1);
   }
+  gtk_list_store_set (ls, &iter, 
+                     PEERINFO_MC_NUMBER_OF_ADDRESSES, 1,
+                     PEERINFO_MC_COUNTRY_NAME, country, 
+                     PEERINFO_MC_COUNTRY_FLAG, GNUNET_PEERINFO_GTK_get_flag 
(country), 
+                     PEERINFO_MC_ADDRESS_AS_STRING, address, 
+                     -1);
+  GNUNET_free (country);
+  info->got_address = GNUNET_YES;
 }
 
 
@@ -293,6 +297,7 @@
   }
   if (NULL != info->tos)
     GNUNET_TRANSPORT_address_to_string_cancel (info->tos);
+  info->got_address = GNUNET_NO;
   info->tos =
       GNUNET_TRANSPORT_address_to_string (get_configuration (), address,
                                           GNUNET_NO,
@@ -343,7 +348,7 @@
                         PEERINFO_MC_COUNTRY_FLAG, NULL,
                         PEERINFO_MC_BANDWIDTH_IN, (guint64) 0,
                         PEERINFO_MC_BANDWIDTH_OUT, (guint64) 0,
-                        PEERINFO_MC_ADDRESS_AS_STRING, "",
+                       PEERINFO_MC_ADDRESS_AS_STRING, "<disconnected>",
                         -1);
     path = gtk_tree_model_get_path (tm, &iter);
     info = GNUNET_malloc (sizeof (struct PeerInfo));
@@ -406,6 +411,9 @@
 
 /**
  * Callback invoked if the application is supposed to exit.
+ *
+ * @param object 
+ * @param user_data unused
  */
 void
 GNUNET_PEERINFO_GTK_quit_cb (GObject * object, gpointer user_data)
@@ -419,6 +427,9 @@
 /**
  * Actual main function run right after GNUnet's scheduler
  * is initialized.  Initializes up GTK and Glade.
+ *
+ * @param cls NULL
+ * @param tc schedule context
  */
 static void
 run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
@@ -460,6 +471,13 @@
 }
 
 
+/**
+ * Main function of gnunet-peerinfo-gtk.
+ *
+ * @param argc number of arguments
+ * @param argv arguments
+ * @return 0 on success
+ */
 int
 main (int argc, char *const *argv)
 {




reply via email to

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