diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-07-01 15:50:56 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-07-01 15:50:56 +0000 |
commit | 56671f0edd199c45f14c355c34395b2f352d7f6f (patch) | |
tree | 4ab3f93f20e3d8f5b5fe9319e012fb6a7851ae05 | |
parent | ad6d2a730d7b55915c52f41bfc6b95ddfc42404a (diff) | |
download | gnunet-gtk-56671f0edd199c45f14c355c34395b2f352d7f6f.tar.gz gnunet-gtk-56671f0edd199c45f14c355c34395b2f352d7f6f.zip |
-towards multi-zone editing
-rw-r--r-- | contrib/gnunet_setup_gtk_main_window.glade | 2 | ||||
-rw-r--r-- | src/setup/gnunet-setup-gns.c | 141 |
2 files changed, 82 insertions, 61 deletions
diff --git a/contrib/gnunet_setup_gtk_main_window.glade b/contrib/gnunet_setup_gtk_main_window.glade index 05fc380b..9ee3f0de 100644 --- a/contrib/gnunet_setup_gtk_main_window.glade +++ b/contrib/gnunet_setup_gtk_main_window.glade | |||
@@ -4464,7 +4464,7 @@ | |||
4464 | </packing> | 4464 | </packing> |
4465 | </child> | 4465 | </child> |
4466 | <child> | 4466 | <child> |
4467 | <object class="GtkVSeparator" id="GNUNET_setup_qr_vseparator"> | 4467 | <object class="GtkVSeparator" id="GNUNET_setup_gns_qr_vseparator"> |
4468 | <property name="visible">True</property> | 4468 | <property name="visible">True</property> |
4469 | <property name="can_focus">False</property> | 4469 | <property name="can_focus">False</property> |
4470 | </object> | 4470 | </object> |
diff --git a/src/setup/gnunet-setup-gns.c b/src/setup/gnunet-setup-gns.c index f0ea2f04..6717d563 100644 --- a/src/setup/gnunet-setup-gns.c +++ b/src/setup/gnunet-setup-gns.c | |||
@@ -174,11 +174,6 @@ enum LIST_COLUMNS | |||
174 | static char *zone_as_string; | 174 | static char *zone_as_string; |
175 | 175 | ||
176 | /** | 176 | /** |
177 | * Default directory of zone files as a string. | ||
178 | */ | ||
179 | static char *zonekey_directory; | ||
180 | |||
181 | /** | ||
182 | * Handle to the namestore. | 177 | * Handle to the namestore. |
183 | */ | 178 | */ |
184 | static struct GNUNET_NAMESTORE_Handle *namestore; | 179 | static struct GNUNET_NAMESTORE_Handle *namestore; |
@@ -1562,7 +1557,14 @@ zone_iteration_proc (void *cls, | |||
1562 | GNUNET_free (zc_ctx->label); | 1557 | GNUNET_free (zc_ctx->label); |
1563 | GNUNET_free (zc_ctx); | 1558 | GNUNET_free (zc_ctx); |
1564 | #if HAVE_QRENCODE_H | 1559 | #if HAVE_QRENCODE_H |
1565 | setup_qrcode (); | 1560 | setup_qrcode (); |
1561 | gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_qr_image"))); | ||
1562 | gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_qr_saveas_button"))); | ||
1563 | gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_qr_vseparator"))); | ||
1564 | #else | ||
1565 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_qr_image"))); | ||
1566 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_qr_saveas_button"))); | ||
1567 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_qr_vseparator"))); | ||
1566 | #endif | 1568 | #endif |
1567 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_status_label"))); | 1569 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_status_label"))); |
1568 | gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_main_scrolledwindow"))); | 1570 | gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_main_scrolledwindow"))); |
@@ -1741,44 +1743,41 @@ GNUNET_setup_gns_public_key_copy_button_clicked_cb (GtkButton *button, | |||
1741 | 1743 | ||
1742 | 1744 | ||
1743 | /** | 1745 | /** |
1744 | * Connect to the namestore and initialize the main | 1746 | * Load a particular zone into the main tree view. |
1745 | * GNS tree view. | 1747 | * |
1748 | * @param zonename name of the option in the configuration file | ||
1749 | * with the name of the file with the private key of the | ||
1750 | * zone to load | ||
1746 | */ | 1751 | */ |
1747 | void | 1752 | static void |
1748 | GNUNET_SETUP_gns_init () | 1753 | load_zone (const char *zonename) |
1749 | { | 1754 | { |
1750 | struct GNUNET_CRYPTO_ShortHashAsciiEncoded shenc; | 1755 | struct GNUNET_CRYPTO_ShortHashAsciiEncoded shenc; |
1751 | char *label; | 1756 | char *label; |
1752 | char *keyfile; | 1757 | char *keyfile; |
1753 | char *servicehome; | ||
1754 | struct ZoneIteration_Context *zc_ctx; | 1758 | struct ZoneIteration_Context *zc_ctx; |
1755 | GtkTreeIter toplevel; | 1759 | GtkTreeIter toplevel; |
1756 | GtkLabel *status_label; | ||
1757 | 1760 | ||
1758 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, | 1761 | /* clear previous zone */ |
1759 | "PATHS", | 1762 | gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_status_label"))); |
1760 | "SERVICEHOME", | 1763 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_main_scrolledwindow"))); |
1761 | &servicehome)) | 1764 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_qr_image"))); |
1762 | { | 1765 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_qr_saveas_button"))); |
1763 | GNUNET_asprintf (&zonekey_directory, ""); | 1766 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_qr_vseparator"))); |
1764 | } | 1767 | gtk_tree_store_clear (ts); |
1765 | else | ||
1766 | { | ||
1767 | GNUNET_asprintf (&zonekey_directory, "%s%s%s",servicehome, DIR_SEPARATOR_STR, "gns"); | ||
1768 | GNUNET_free (servicehome); | ||
1769 | } | ||
1770 | 1768 | ||
1771 | /* setup crypto keys */ | 1769 | /* setup crypto keys */ |
1772 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, | 1770 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, |
1773 | "gns", | 1771 | "gns", |
1774 | "ZONEKEY", | 1772 | zonename, |
1775 | &keyfile)) | 1773 | &keyfile)) |
1776 | { | 1774 | { |
1777 | status_label = GTK_LABEL (GNUNET_SETUP_get_object ("GNUNET_setup_gns_status_label")); | 1775 | GNUNET_asprintf (&label, |
1778 | label = g_markup_printf_escaped (_("Option `%s' missing in section `%s'\n"), | 1776 | _("Option `%s' missing in section `%s'\n"), |
1779 | "ZONEKEY", "gns"); | 1777 | zonename, "gns"); |
1780 | gtk_label_set_markup (status_label, label); | 1778 | show_error_message (_("Failed to load zone"), |
1781 | g_free (label); | 1779 | label); |
1780 | GNUNET_free (label); | ||
1782 | return; | 1781 | return; |
1783 | } | 1782 | } |
1784 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using `%s'\n", keyfile); | 1783 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using `%s'\n", keyfile); |
@@ -1787,10 +1786,8 @@ GNUNET_SETUP_gns_init () | |||
1787 | keyfile = NULL; | 1786 | keyfile = NULL; |
1788 | if (NULL == pkey) | 1787 | if (NULL == pkey) |
1789 | { | 1788 | { |
1790 | status_label = GTK_LABEL (GNUNET_SETUP_get_object ("GNUNET_setup_gns_status_label")); | 1789 | show_error_message (_("Failed to load zone"), |
1791 | label = g_markup_printf_escaped (_("Failed to read or create private zone key\n")); | 1790 | _("Failed to read or create private zone key")); |
1792 | gtk_label_set_markup (status_label, label); | ||
1793 | g_free (label); | ||
1794 | return; | 1791 | return; |
1795 | } | 1792 | } |
1796 | GNUNET_CRYPTO_rsa_key_get_public (pkey, &pubkey); | 1793 | GNUNET_CRYPTO_rsa_key_get_public (pkey, &pubkey); |
@@ -1799,33 +1796,12 @@ GNUNET_SETUP_gns_init () | |||
1799 | &zone); | 1796 | &zone); |
1800 | GNUNET_CRYPTO_short_hash_to_enc(&zone, &shenc); | 1797 | GNUNET_CRYPTO_short_hash_to_enc(&zone, &shenc); |
1801 | 1798 | ||
1802 | /* connect to namestore */ | ||
1803 | namestore = GNUNET_NAMESTORE_connect (cfg); | ||
1804 | if (NULL == namestore) | ||
1805 | { | ||
1806 | status_label = GTK_LABEL (GNUNET_SETUP_get_object ("GNUNET_setup_gns_status_label")); | ||
1807 | label = g_markup_printf_escaped (_("<b><big>Failed to connect to namestore</b></big>")); | ||
1808 | gtk_label_set_markup (status_label, label); | ||
1809 | g_free (label); | ||
1810 | return; | ||
1811 | } | ||
1812 | ts = GTK_TREE_STORE (GNUNET_SETUP_get_object ("GNUNET_setup_gns_treestore")); | ||
1813 | tv = GTK_TREE_VIEW (GNUNET_SETUP_get_object ("GNUNET_setup_gns_main_treeview")); | ||
1814 | tm = GTK_TREE_MODEL(ts); | ||
1815 | zone_as_string = GNUNET_strdup ((char *) &shenc); | 1799 | zone_as_string = GNUNET_strdup ((char *) &shenc); |
1816 | #if HAVE_QRENCODE_H | ||
1817 | setup_qrcode (); | ||
1818 | #else | ||
1819 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_qr_image"))); | ||
1820 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_qr_saveas_button"))); | ||
1821 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_qr_vseparator"))); | ||
1822 | #endif | ||
1823 | label = g_markup_printf_escaped (_("<b>Editing zone %s</b>"), | 1800 | label = g_markup_printf_escaped (_("<b>Editing zone %s</b>"), |
1824 | zone_as_string); | 1801 | zone_as_string); |
1825 | gtk_label_set_markup (GTK_LABEL (GNUNET_SETUP_get_object ("GNUNET_setup_gns_zone_label")), | 1802 | gtk_label_set_markup (GTK_LABEL (GNUNET_SETUP_get_object ("GNUNET_setup_gns_zone_label")), |
1826 | label); | 1803 | label); |
1827 | g_free (label); | 1804 | g_free (label); |
1828 | |||
1829 | /* Load zone from namestore! */ | 1805 | /* Load zone from namestore! */ |
1830 | /* Append a top level row and leave it empty */ | 1806 | /* Append a top level row and leave it empty */ |
1831 | gtk_tree_store_insert_with_values (ts, &toplevel, NULL, 0, | 1807 | gtk_tree_store_insert_with_values (ts, &toplevel, NULL, 0, |
@@ -1847,6 +1823,56 @@ GNUNET_SETUP_gns_init () | |||
1847 | } | 1823 | } |
1848 | 1824 | ||
1849 | 1825 | ||
1826 | void | ||
1827 | GNUNET_setup_gns_shorten_zone_selection_radiobutton_toggled_cb (GtkToggleButton *togglebutton, | ||
1828 | gpointer user_data) | ||
1829 | { | ||
1830 | GNUNET_break (0); | ||
1831 | } | ||
1832 | |||
1833 | |||
1834 | void | ||
1835 | GNUNET_setup_gns_private_zone_selection_radiobutton_toggled_cb (GtkToggleButton *togglebutton, | ||
1836 | gpointer user_data) | ||
1837 | { | ||
1838 | GNUNET_break (0); | ||
1839 | } | ||
1840 | |||
1841 | |||
1842 | void | ||
1843 | GNUNET_setup_gns_master_zone_selection_radiobutton_toggled_cb (GtkToggleButton *togglebutton, | ||
1844 | gpointer user_data) | ||
1845 | { | ||
1846 | GNUNET_break (0); | ||
1847 | } | ||
1848 | |||
1849 | |||
1850 | /** | ||
1851 | * Connect to the namestore and initialize the main | ||
1852 | * GNS tree view. | ||
1853 | */ | ||
1854 | void | ||
1855 | GNUNET_SETUP_gns_init () | ||
1856 | { | ||
1857 | gchar *label; | ||
1858 | GtkLabel *status_label; | ||
1859 | |||
1860 | namestore = GNUNET_NAMESTORE_connect (cfg); | ||
1861 | if (NULL == namestore) | ||
1862 | { | ||
1863 | status_label = GTK_LABEL (GNUNET_SETUP_get_object ("GNUNET_setup_gns_status_label")); | ||
1864 | label = g_markup_printf_escaped (_("<b><big>Failed to connect to namestore</b></big>")); | ||
1865 | gtk_label_set_markup (status_label, label); | ||
1866 | g_free (label); | ||
1867 | return; | ||
1868 | } | ||
1869 | ts = GTK_TREE_STORE (GNUNET_SETUP_get_object ("GNUNET_setup_gns_treestore")); | ||
1870 | tv = GTK_TREE_VIEW (GNUNET_SETUP_get_object ("GNUNET_setup_gns_main_treeview")); | ||
1871 | tm = GTK_TREE_MODEL(ts); | ||
1872 | load_zone ("ZONEKEY"); | ||
1873 | } | ||
1874 | |||
1875 | |||
1850 | /** | 1876 | /** |
1851 | * Disconnect from the namestore and clean up the main | 1877 | * Disconnect from the namestore and clean up the main |
1852 | * GNS tree view. | 1878 | * GNS tree view. |
@@ -1869,11 +1895,6 @@ GNUNET_SETUP_gns_done () | |||
1869 | GNUNET_CRYPTO_rsa_key_free (pkey); | 1895 | GNUNET_CRYPTO_rsa_key_free (pkey); |
1870 | pkey = NULL; | 1896 | pkey = NULL; |
1871 | } | 1897 | } |
1872 | if (NULL != zonekey_directory) | ||
1873 | { | ||
1874 | GNUNET_free (zonekey_directory); | ||
1875 | zonekey_directory = NULL; | ||
1876 | } | ||
1877 | } | 1898 | } |
1878 | 1899 | ||
1879 | 1900 | ||