[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r28444 - in gnunet-gtk: contrib src src/fs src/identity
From: |
gnunet |
Subject: |
[GNUnet-SVN] r28444 - in gnunet-gtk: contrib src src/fs src/identity |
Date: |
Wed, 7 Aug 2013 23:28:16 +0200 |
Author: grothoff
Date: 2013-08-07 23:28:16 +0200 (Wed, 07 Aug 2013)
New Revision: 28444
Added:
gnunet-gtk/contrib/gnunet_identity_gtk_create_ego_dialog.glade
gnunet-gtk/contrib/gnunet_identity_gtk_organize_ego_dialog.glade
gnunet-gtk/src/identity/
gnunet-gtk/src/identity/gnunet-identity-gtk_create_ego.c
gnunet-gtk/src/identity/gnunet-identity-gtk_ego_organizer.c
gnunet-gtk/src/identity/gnunet-identity-gtk_ego_organizer.h
Removed:
gnunet-gtk/contrib/gnunet_fs_gtk_create_namespace_dialog.glade
gnunet-gtk/contrib/gnunet_fs_gtk_namespace_organizer.glade
gnunet-gtk/src/fs/gnunet-fs-gtk_create-pseudonym.c
gnunet-gtk/src/fs/gnunet-fs-gtk_namespace_organizer.c
gnunet-gtk/src/fs/gnunet-fs-gtk_namespace_organizer.h
Modified:
gnunet-gtk/contrib/Makefile.am
gnunet-gtk/src/fs/Makefile.am
gnunet-gtk/src/fs/gnunet-fs-gtk.h
gnunet-gtk/src/fs/gnunet-fs-gtk_advertise-pseudonym.c
gnunet-gtk/src/fs/gnunet-fs-gtk_advertise-pseudonym.h
gnunet-gtk/src/fs/gnunet-fs-gtk_common.c
gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c
gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c
gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-search.c
gnunet-gtk/src/fs/gnunet-fs-gtk_namespace_manager.c
gnunet-gtk/src/fs/gnunet-fs-gtk_publish-dialog.c
Log:
-fix build with new fs/namespace/ecc/identity APIs
Modified: gnunet-gtk/contrib/Makefile.am
===================================================================
--- gnunet-gtk/contrib/Makefile.am 2013-08-07 21:27:52 UTC (rev 28443)
+++ gnunet-gtk/contrib/Makefile.am 2013-08-07 21:28:16 UTC (rev 28444)
@@ -28,11 +28,9 @@
green.png \
searching_sources.gif \
gnunet_fs_gtk_about_window.glade \
- gnunet_fs_gtk_create_namespace_dialog.glade \
gnunet_fs_gtk_download_as_dialog.glade \
gnunet_fs_gtk_main_window.glade \
gnunet_fs_gtk_namespace_manager.glade \
- gnunet_fs_gtk_namespace_organizer.glade \
gnunet_fs_gtk_edit_publication.glade \
gnunet_fs_gtk_open_directory_dialog.glade \
gnunet_fs_gtk_open_url_dialog.glade \
@@ -45,6 +43,8 @@
gnunet_fs_gtk_unindex.glade \
gnunet_fs_gtk_progress_dialog.glade \
gnunet_gtk_status_bar_menu.glade \
+ gnunet_identity_gtk_create_ego_dialog.glade \
+ gnunet_identity_gtk_organizer_ego_dialog.glade \
gnunet_peerinfo_gtk_about_window.glade \
gnunet_peerinfo_gtk_main_window.glade \
gnunet_statistics_gtk_about_window.glade \
Deleted: gnunet-gtk/contrib/gnunet_fs_gtk_create_namespace_dialog.glade
===================================================================
--- gnunet-gtk/contrib/gnunet_fs_gtk_create_namespace_dialog.glade
2013-08-07 21:27:52 UTC (rev 28443)
+++ gnunet-gtk/contrib/gnunet_fs_gtk_create_namespace_dialog.glade
2013-08-07 21:28:16 UTC (rev 28444)
@@ -1,119 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<interface>
- <requires lib="gtk+" version="2.20"/>
- <!-- interface-naming-policy project-wide -->
- <object class="GtkDialog" id="GNUNET_GTK_create_namespace_dialog">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="can_default">True</property>
- <property name="border_width">5</property>
- <property name="title" translatable="yes">Create namespace</property>
- <property name="resizable">False</property>
- <property name="modal">True</property>
- <property name="window_position">center</property>
- <property name="icon_name">folder-new</property>
- <property name="type_hint">dialog</property>
- <property name="skip_taskbar_hint">True</property>
- <signal name="response"
handler="GNUNET_GTK_create_namespace_dialog_response_cb" swapped="no"/>
- <child internal-child="vbox">
- <object class="GtkVBox" id="GNUNET_GTK_create_namespace_vbox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">2</property>
- <child>
- <object class="GtkHBox" id="GNUNET_GTK_create_namespace_value_hbox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkLabel"
id="GNUNET_GTK_create_namespace_name_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">_Name:</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="padding">4</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry"
id="GNUNET_GTK_create_namespace_name_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">●</property>
- <property name="activates_default">True</property>
- <property name="primary_icon_activatable">False</property>
- <property name="secondary_icon_activatable">False</property>
- <property name="primary_icon_sensitive">True</property>
- <property name="secondary_icon_sensitive">True</property>
- <signal name="insert-text"
handler="GNUNET_FS_GTK_create_namespace_insert_text_cb" swapped="no"/>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="padding">5</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child internal-child="action_area">
- <object class="GtkHButtonBox"
id="GNUNET_GTK_create_namespace_dialog-action_area">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="layout_style">end</property>
- <child>
- <object class="GtkButton"
id="GNUNET_GTK_create_namespace_cancel_button">
- <property name="label">gtk-cancel</property>
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton"
id="GNUNET_GTK_create_namespace_ok_button">
- <property name="label">gtk-ok</property>
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="has_default">True</property>
- <property name="receives_default">True</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">end</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- </child>
- <action-widgets>
- <action-widget
response="-6">GNUNET_GTK_create_namespace_cancel_button</action-widget>
- <action-widget
response="-5">GNUNET_GTK_create_namespace_ok_button</action-widget>
- </action-widgets>
- </object>
-</interface>
Deleted: gnunet-gtk/contrib/gnunet_fs_gtk_namespace_organizer.glade
===================================================================
--- gnunet-gtk/contrib/gnunet_fs_gtk_namespace_organizer.glade 2013-08-07
21:27:52 UTC (rev 28443)
+++ gnunet-gtk/contrib/gnunet_fs_gtk_namespace_organizer.glade 2013-08-07
21:28:16 UTC (rev 28444)
@@ -1,253 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<interface>
- <requires lib="gtk+" version="2.20"/>
- <!-- interface-naming-policy project-wide -->
- <object class="GtkDialog" id="GNUNET_GTK_namespace_organizer_dialog">
- <property name="can_focus">False</property>
- <property name="border_width">5</property>
- <property name="title" translatable="yes">Namespace selection</property>
- <property name="destroy_with_parent">True</property>
- <property name="type_hint">dialog</property>
- <property name="has_separator">True</property>
- <signal name="response"
handler="GNUNET_GTK_namespace_organizer_dialog_response_cb" swapped="no"/>
- <child internal-child="vbox">
- <object class="GtkVBox" id="GNUNET_GTK_namespace_organizer_vbox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">2</property>
- <child internal-child="action_area">
- <object class="GtkHButtonBox"
id="GNUNET_GTK_namespace_organizer_action_area">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="layout_style">end</property>
- <child>
- <object class="GtkButton"
id="GNUNET_GTK_namespace_organizer_close_button">
- <property name="label">gtk-close</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes">Saves all
changes made in this dialog to disk and closes the dialog.</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">end</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel"
id="GNUNET_GTK_namespace_organizer_namespaces_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="label" translatable="yes">List of the namespaces
you have private key for.
-You can create new namespaces, delete or rename existing ones.
-Select one of the namespaces that will be (optionally) used for
publishing.</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkScrolledWindow"
id="GNUNET_GTK_namespace_organizer_scrolled">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">automatic</property>
- <property name="vscrollbar_policy">automatic</property>
- <child>
- <object class="GtkTreeView"
id="GNUNET_GTK_namespace_organizer_namespaces_treeview">
- <property name="height_request">300</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property
name="model">GNUNET_GTK_namespace_organizer_namespaces_liststore</property>
- <property name="headers_clickable">False</property>
- <property name="rules_hint">True</property>
- <property name="enable_search">False</property>
- <property name="show_expanders">False</property>
- <property name="enable_grid_lines">horizontal</property>
- <property name="tooltip_column">5</property>
- <child>
- <object class="GtkTreeViewColumn"
id="GNUNET_GTK_namespace_organizer_namespaces_treeview_column_usethis">
- <property name="sizing">autosize</property>
- <property name="title" translatable="yes">Use for
publications</property>
- <child>
- <object class="GtkCellRendererToggle"
id="GNUNET_GTK_namespace_organizer_namespaces_treeview_column_usethis_toggle">
- <property name="radio">True</property>
- <signal name="toggled"
handler="GNUNET_GTK_namespace_organizer_namespaces_treeview_column_usethis_toggle_toggled_cb"
swapped="no"/>
- </object>
- <attributes>
- <attribute name="active">3</attribute>
- </attributes>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkTreeViewColumn"
id="GNUNET_GTK_namespace_organizer_namespaces_treeview_column_name">
- <property name="sizing">autosize</property>
- <property name="title" translatable="yes">Name</property>
- <property name="expand">True</property>
- <child>
- <object class="GtkCellRendererText"
id="GNUNET_GTK_namespace_organizer_namespaces_treeview_column_name_text">
- <property name="editable">True</property>
- <signal name="edited"
handler="GNUNET_GTK_namespace_organizer_namespaces_treeview_column_name_text_edited_cb"
swapped="no"/>
- </object>
- <attributes>
- <attribute name="text">0</attribute>
- </attributes>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkTreeViewColumn"
id="GNUNET_GTK_namespace_organizer_namespaces_treeview_column_key">
- <property name="sizing">autosize</property>
- <property name="title" translatable="yes">Hash of the
public key</property>
- <child>
- <object class="GtkCellRendererText"
id="GNUNET_GTK_namespace_organizer_namespaces_treeview_column_key_text"/>
- <attributes>
- <attribute name="text">1</attribute>
- </attributes>
- </child>
- </object>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkHBox"
id="GNUNET_GTK_namespace_organizer_namespaces_extra_buttons_hbox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">5</property>
- <child>
- <object class="GtkButton"
id="GNUNET_GTK_namespace_organizer_namespaces_create_namespace_button">
- <property name="label" translatable="yes">Create</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes">Generate new
namespace.</property>
- <signal name="clicked"
handler="GNUNET_GTK_namespace_organizer_namespaces_create_namespace_button_clicked_cb"
swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton"
id="GNUNET_GTK_namespace_organizer_namespaces_advertise_namespace_button">
- <property name="label" translatable="yes">Advertise</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes">Make
namespace findable with global file-sharing searches.</property>
- <signal name="clicked"
handler="GNUNET_GTK_namespace_organizer_namespaces_advertise_namespace_button_clicked_cb"
swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton"
id="GNUNET_GTK_namespace_organizer_namespaces_delete_namespace_button">
- <property name="label" translatable="yes">Delete</property>
- <property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes">Delete
namespace key.</property>
- <signal name="clicked"
handler="GNUNET_GTK_namespace_organizer_namespaces_delete_namespace_button_clicked_cb"
swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton"
id="GNUNET_GTK_namespace_organizer_namespaces_delete_namespace_confirmation_button">
- <property name="label" translatable="yes">Yes, delete
it!</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <signal name="clicked"
handler="GNUNET_GTK_namespace_organizer_namespaces_delete_namespace_confirmation_button_clicked_cb"
swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">end</property>
- <property name="position">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton"
id="GNUNET_GTK_namespace_organizer_namespaces_delete_namespace_unconfirmation_button">
- <property name="label" translatable="yes">No, keep
it.</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <signal name="clicked"
handler="GNUNET_GTK_namespace_organizer_namespaces_delete_namespace_unconfirmation_button_clicked_cb"
swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">end</property>
- <property name="position">4</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel"
id="GNUNET_GTK_namespace_organizer_namespaces_delete_namespace_confirmation_label">
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Are you sure? Once
you delete the private key of a namespace, it's lost forever!</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">end</property>
- <property name="position">5</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="padding">5</property>
- <property name="position">3</property>
- </packing>
- </child>
- </object>
- </child>
- <action-widgets>
- <action-widget
response="-5">GNUNET_GTK_namespace_organizer_close_button</action-widget>
- </action-widgets>
- </object>
- <object class="GtkListStore"
id="GNUNET_GTK_namespace_organizer_namespaces_liststore">
- <columns>
- <!-- column-name NamespaceName -->
- <column type="gchararray"/>
- <!-- column-name NamespaceKey -->
- <column type="gchararray"/>
- <!-- column-name NamespaceKeyBinary -->
- <column type="gpointer"/>
- <!-- column-name UseThis -->
- <column type="gboolean"/>
- <!-- column-name ActualName -->
- <column type="gchararray"/>
- <!-- column-name ToolTip -->
- <column type="gchararray"/>
- </columns>
- </object>
-</interface>
Copied: gnunet-gtk/contrib/gnunet_identity_gtk_create_ego_dialog.glade (from
rev 28440, gnunet-gtk/contrib/gnunet_fs_gtk_create_namespace_dialog.glade)
===================================================================
--- gnunet-gtk/contrib/gnunet_identity_gtk_create_ego_dialog.glade
(rev 0)
+++ gnunet-gtk/contrib/gnunet_identity_gtk_create_ego_dialog.glade
2013-08-07 21:28:16 UTC (rev 28444)
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk+" version="2.20"/>
+ <!-- interface-naming-policy project-wide -->
+ <object class="GtkDialog" id="GNUNET_GTK_create_namespace_dialog">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="can_default">True</property>
+ <property name="border_width">5</property>
+ <property name="title" translatable="yes">Create namespace</property>
+ <property name="resizable">False</property>
+ <property name="modal">True</property>
+ <property name="window_position">center</property>
+ <property name="icon_name">folder-new</property>
+ <property name="type_hint">dialog</property>
+ <property name="skip_taskbar_hint">True</property>
+ <signal name="response"
handler="GNUNET_GTK_create_namespace_dialog_response_cb" swapped="no"/>
+ <child internal-child="vbox">
+ <object class="GtkVBox" id="GNUNET_GTK_create_namespace_vbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">2</property>
+ <child>
+ <object class="GtkHBox" id="GNUNET_GTK_create_namespace_value_hbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel"
id="GNUNET_GTK_create_namespace_name_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">_Name:</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="padding">4</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry"
id="GNUNET_GTK_create_namespace_name_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ <property name="activates_default">True</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="secondary_icon_activatable">False</property>
+ <property name="primary_icon_sensitive">True</property>
+ <property name="secondary_icon_sensitive">True</property>
+ <signal name="insert-text"
handler="GNUNET_FS_GTK_create_namespace_insert_text_cb" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="padding">5</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <object class="GtkHButtonBox"
id="GNUNET_GTK_create_namespace_dialog-action_area">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton"
id="GNUNET_GTK_create_namespace_cancel_button">
+ <property name="label">gtk-cancel</property>
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton"
id="GNUNET_GTK_create_namespace_ok_button">
+ <property name="label">gtk-ok</property>
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget
response="-6">GNUNET_GTK_create_namespace_cancel_button</action-widget>
+ <action-widget
response="-5">GNUNET_GTK_create_namespace_ok_button</action-widget>
+ </action-widgets>
+ </object>
+</interface>
Copied: gnunet-gtk/contrib/gnunet_identity_gtk_organize_ego_dialog.glade (from
rev 28440, gnunet-gtk/contrib/gnunet_fs_gtk_namespace_organizer.glade)
===================================================================
--- gnunet-gtk/contrib/gnunet_identity_gtk_organize_ego_dialog.glade
(rev 0)
+++ gnunet-gtk/contrib/gnunet_identity_gtk_organize_ego_dialog.glade
2013-08-07 21:28:16 UTC (rev 28444)
@@ -0,0 +1,253 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk+" version="2.20"/>
+ <!-- interface-naming-policy project-wide -->
+ <object class="GtkDialog" id="GNUNET_GTK_namespace_organizer_dialog">
+ <property name="can_focus">False</property>
+ <property name="border_width">5</property>
+ <property name="title" translatable="yes">Namespace selection</property>
+ <property name="destroy_with_parent">True</property>
+ <property name="type_hint">dialog</property>
+ <property name="has_separator">True</property>
+ <signal name="response"
handler="GNUNET_GTK_namespace_organizer_dialog_response_cb" swapped="no"/>
+ <child internal-child="vbox">
+ <object class="GtkVBox" id="GNUNET_GTK_namespace_organizer_vbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">2</property>
+ <child internal-child="action_area">
+ <object class="GtkHButtonBox"
id="GNUNET_GTK_namespace_organizer_action_area">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton"
id="GNUNET_GTK_namespace_organizer_close_button">
+ <property name="label">gtk-close</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Saves all
changes made in this dialog to disk and closes the dialog.</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel"
id="GNUNET_GTK_namespace_organizer_namespaces_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ <property name="label" translatable="yes">List of the namespaces
you have private key for.
+You can create new namespaces, delete or rename existing ones.
+Select one of the namespaces that will be (optionally) used for
publishing.</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow"
id="GNUNET_GTK_namespace_organizer_scrolled">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <child>
+ <object class="GtkTreeView"
id="GNUNET_GTK_namespace_organizer_namespaces_treeview">
+ <property name="height_request">300</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property
name="model">GNUNET_GTK_namespace_organizer_namespaces_liststore</property>
+ <property name="headers_clickable">False</property>
+ <property name="rules_hint">True</property>
+ <property name="enable_search">False</property>
+ <property name="show_expanders">False</property>
+ <property name="enable_grid_lines">horizontal</property>
+ <property name="tooltip_column">5</property>
+ <child>
+ <object class="GtkTreeViewColumn"
id="GNUNET_GTK_namespace_organizer_namespaces_treeview_column_usethis">
+ <property name="sizing">autosize</property>
+ <property name="title" translatable="yes">Use for
publications</property>
+ <child>
+ <object class="GtkCellRendererToggle"
id="GNUNET_GTK_namespace_organizer_namespaces_treeview_column_usethis_toggle">
+ <property name="radio">True</property>
+ <signal name="toggled"
handler="GNUNET_GTK_namespace_organizer_namespaces_treeview_column_usethis_toggle_toggled_cb"
swapped="no"/>
+ </object>
+ <attributes>
+ <attribute name="active">3</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn"
id="GNUNET_GTK_namespace_organizer_namespaces_treeview_column_name">
+ <property name="sizing">autosize</property>
+ <property name="title" translatable="yes">Name</property>
+ <property name="expand">True</property>
+ <child>
+ <object class="GtkCellRendererText"
id="GNUNET_GTK_namespace_organizer_namespaces_treeview_column_name_text">
+ <property name="editable">True</property>
+ <signal name="edited"
handler="GNUNET_GTK_namespace_organizer_namespaces_treeview_column_name_text_edited_cb"
swapped="no"/>
+ </object>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn"
id="GNUNET_GTK_namespace_organizer_namespaces_treeview_column_key">
+ <property name="sizing">autosize</property>
+ <property name="title" translatable="yes">Hash of the
public key</property>
+ <child>
+ <object class="GtkCellRendererText"
id="GNUNET_GTK_namespace_organizer_namespaces_treeview_column_key_text"/>
+ <attributes>
+ <attribute name="text">1</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox"
id="GNUNET_GTK_namespace_organizer_namespaces_extra_buttons_hbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">5</property>
+ <child>
+ <object class="GtkButton"
id="GNUNET_GTK_namespace_organizer_namespaces_create_namespace_button">
+ <property name="label" translatable="yes">Create</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Generate new
namespace.</property>
+ <signal name="clicked"
handler="GNUNET_GTK_namespace_organizer_namespaces_create_namespace_button_clicked_cb"
swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton"
id="GNUNET_GTK_namespace_organizer_namespaces_advertise_namespace_button">
+ <property name="label" translatable="yes">Advertise</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Make
namespace findable with global file-sharing searches.</property>
+ <signal name="clicked"
handler="GNUNET_GTK_namespace_organizer_namespaces_advertise_namespace_button_clicked_cb"
swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton"
id="GNUNET_GTK_namespace_organizer_namespaces_delete_namespace_button">
+ <property name="label" translatable="yes">Delete</property>
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Delete
namespace key.</property>
+ <signal name="clicked"
handler="GNUNET_GTK_namespace_organizer_namespaces_delete_namespace_button_clicked_cb"
swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton"
id="GNUNET_GTK_namespace_organizer_namespaces_delete_namespace_confirmation_button">
+ <property name="label" translatable="yes">Yes, delete
it!</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <signal name="clicked"
handler="GNUNET_GTK_namespace_organizer_namespaces_delete_namespace_confirmation_button_clicked_cb"
swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton"
id="GNUNET_GTK_namespace_organizer_namespaces_delete_namespace_unconfirmation_button">
+ <property name="label" translatable="yes">No, keep
it.</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <signal name="clicked"
handler="GNUNET_GTK_namespace_organizer_namespaces_delete_namespace_unconfirmation_button_clicked_cb"
swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel"
id="GNUNET_GTK_namespace_organizer_namespaces_delete_namespace_confirmation_label">
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Are you sure? Once
you delete the private key of a namespace, it's lost forever!</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">5</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="padding">5</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget
response="-5">GNUNET_GTK_namespace_organizer_close_button</action-widget>
+ </action-widgets>
+ </object>
+ <object class="GtkListStore"
id="GNUNET_GTK_namespace_organizer_namespaces_liststore">
+ <columns>
+ <!-- column-name NamespaceName -->
+ <column type="gchararray"/>
+ <!-- column-name NamespaceKey -->
+ <column type="gchararray"/>
+ <!-- column-name NamespaceKeyBinary -->
+ <column type="gpointer"/>
+ <!-- column-name UseThis -->
+ <column type="gboolean"/>
+ <!-- column-name ActualName -->
+ <column type="gchararray"/>
+ <!-- column-name ToolTip -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
+</interface>
Modified: gnunet-gtk/src/fs/Makefile.am
===================================================================
--- gnunet-gtk/src/fs/Makefile.am 2013-08-07 21:27:52 UTC (rev 28443)
+++ gnunet-gtk/src/fs/Makefile.am 2013-08-07 21:28:16 UTC (rev 28444)
@@ -17,7 +17,6 @@
gnunet-fs-gtk_advertise-pseudonym.h \
gnunet-fs-gtk_anonymity-widgets.c gnunet-fs-gtk_anonymity-widgets.h \
gnunet-fs-gtk_common.c gnunet-fs-gtk_common.h \
- gnunet-fs-gtk_create-pseudonym.c \
gnunet-fs-gtk_download-save-as.c gnunet-fs-gtk_download-save-as.h \
gnunet-fs-gtk_event-handler.c gnunet-fs-gtk_event-handler.h \
gnunet-fs-gtk_main-window-connection.c \
@@ -30,8 +29,6 @@
gnunet-fs-gtk_unindex.c gnunet-fs-gtk_unindex.h \
gnunet-fs-gtk_publish-dialog.c \
gnunet-fs-gtk_publish-edit-dialog.c gnunet-fs-gtk_publish-edit-dialog.h \
- gnunet-fs-gtk_namespace_organizer.c \
- gnunet-fs-gtk_namespace_organizer.h \
gnunet-fs-gtk_namespace_manager.c \
gnunet-fs-gtk_namespace_manager.h
@@ -43,6 +40,7 @@
-lgnunetutil \
-lgnunetarm \
-lgnunetfs \
+ -lgnunetidentity \
$(INTLLIBS)
gnunet_fs_gtk_LDFLAGS = \
-export-dynamic
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk.h
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk.h 2013-08-07 21:27:52 UTC (rev 28443)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk.h 2013-08-07 21:28:16 UTC (rev 28444)
@@ -55,7 +55,7 @@
GtkTreeRowReference *ns_selector_pushed_row;
GtkTreeRowReference *selected_ns_row;
- struct GNUNET_FS_pseudonym_DiscoveryHandle *ns_discovery_handle;
+ struct GNUNET_FS_Pseudonym_DiscoveryHandle *ns_discovery_handle;
GtkWindow *ns_manager;
gulong ns_manager_delete_handler_id;
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_advertise-pseudonym.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_advertise-pseudonym.c 2013-08-07
21:27:52 UTC (rev 28443)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_advertise-pseudonym.c 2013-08-07
21:28:16 UTC (rev 28444)
@@ -1,10 +1,10 @@
/*
This file is part of GNUnet
- (C) 2005, 2006, 2010, 2012 Christian Grothoff (and other contributing
authors)
+ (C) 2005-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 2, or (at your
+ 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
@@ -59,7 +59,7 @@
/**
* Handle to the namespace to advertise.
*/
- struct GNUNET_FS_Namespace *ns;
+ struct GNUNET_CRYPTO_EccPrivateKey ns;
/**
* Root of the namespace is stored here temporarily.
@@ -98,14 +98,14 @@
{
struct NamespaceAdvertisementContext *nds = cls;
struct GNUNET_FS_Uri *sks_uri;
- char *emsg;
+ struct GNUNET_CRYPTO_EccPublicKey pub;
- emsg = NULL;
- sks_uri = GNUNET_FS_uri_sks_create (nds->ns, nds->root, &emsg);
- GNUNET_assert (NULL == emsg);
+ GNUNET_CRYPTO_ecc_key_get_public (&nds->ns, &pub);
+ sks_uri = GNUNET_FS_uri_sks_create (&pub, nds->root);
GNUNET_FS_publish_ksk (GNUNET_FS_GTK_get_fs_handle (),
- *uri, meta, sks_uri,
- bo, GNUNET_FS_PUBLISH_OPTION_NONE, NULL, NULL);
+ *uri, meta, sks_uri,
+ bo, GNUNET_FS_PUBLISH_OPTION_NONE,
+ NULL, NULL);
GNUNET_FS_uri_destroy (sks_uri);
return GNUNET_SYSERR;
}
@@ -132,29 +132,28 @@
GNUNET_FS_file_information_inspect (nds->fip, &advertise_namespace, nds);
nds->root = NULL;
}
- GNUNET_FS_namespace_delete (nds->ns, GNUNET_NO);
GNUNET_FS_file_information_destroy (nds->fip, NULL, NULL);
GNUNET_free (nds);
}
-
/**
* Call the publication editor dialog in namespace advertising mode,
* and publish the namespace when it's OK'ed.
*
- * @param ns namespace to advertise (takes ownership of it)
+ * @param ns namespace to advertise
* @param transient_for parent window for the dialog
*/
void
-GNUNET_FS_GTK_advertise_namespace (struct GNUNET_FS_Namespace *ns, GtkWindow
*transient_for)
+GNUNET_FS_GTK_advertise_namespace (const struct GNUNET_CRYPTO_EccPrivateKey
*ns,
+ GtkWindow *transient_for)
{
struct NamespaceAdvertisementContext *nds;
struct GNUNET_FS_BlockOptions bo;
struct GNUNET_CONTAINER_MetaData *meta;
- nds = GNUNET_malloc (sizeof (struct NamespaceAdvertisementContext));
- nds->ns = ns;
+ nds = GNUNET_new (struct NamespaceAdvertisementContext);
+ nds->ns = *ns;
memset (&bo, 0, sizeof (struct GNUNET_FS_BlockOptions));
bo.expiration_time = GNUNET_FS_year_to_time (GNUNET_FS_get_current_year () +
2);
bo.anonymity_level = 1;
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_advertise-pseudonym.h
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_advertise-pseudonym.h 2013-08-07
21:27:52 UTC (rev 28443)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_advertise-pseudonym.h 2013-08-07
21:28:16 UTC (rev 28444)
@@ -1,10 +1,10 @@
/*
This file is part of GNUnet
- (C) 2005, 2006, 2010, 2012 Christian Grothoff (and other contributing
authors)
+ (C) 2005-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 2, or (at your
+ 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
@@ -17,27 +17,27 @@
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
-
-#ifndef GNUNET_FS_GTK_ADVERTISE_PSEUDONYM_H
-#define GNUNET_FS_GTK_ADVERTISE_PSEUDONYM_H
-
/**
* @file src/fs/gnunet-fs-gtk_advertise-pseudonym.h
* @author Christian Grothoff
* @brief run the advertising dialog (using the edit-publish
* dialog functions) and finally do the advertising
*/
+#ifndef GNUNET_FS_GTK_ADVERTISE_PSEUDONYM_H
+#define GNUNET_FS_GTK_ADVERTISE_PSEUDONYM_H
+
#include "gnunet-fs-gtk_common.h"
/**
* Call the publication editor dialog in namespace advertising mode,
* and publish the namespace when it's OK'ed.
*
- * @param ns namespace to advertise (takes ownership of it)
+ * @param ns namespace to advertise
* @param transient_for parent window for the dialog
*/
void
-GNUNET_FS_GTK_advertise_namespace (struct GNUNET_FS_Namespace *ns, GtkWindow
*transient_for);
+GNUNET_FS_GTK_advertise_namespace (const struct GNUNET_CRYPTO_EccPrivateKey
*ns,
+ GtkWindow *transient_for);
#endif
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_common.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_common.c 2013-08-07 21:27:52 UTC (rev
28443)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_common.c 2013-08-07 21:28:16 UTC (rev
28444)
@@ -322,14 +322,14 @@
GtkLabel *sel_namespace_label;
GtkTreePath *treepath;
GtkEntry *query_entry;
- struct GNUNET_FS_PseudonymIdentifier *nsid;
- struct GNUNET_FS_PseudonymIdentifier want;
+ struct GNUNET_CRYPTO_EccPublicKey *nsid;
+ struct GNUNET_CRYPTO_EccPublicKey want;
if (GNUNET_FS_uri_test_chk (uri) || GNUNET_FS_uri_test_loc (uri))
{
struct DownloadEntry *de;
- de = GNUNET_malloc (sizeof (struct DownloadEntry));
+ de = GNUNET_new (struct DownloadEntry);
de->anonymity = anonymity_level;
de->uri = GNUNET_FS_uri_dup (uri);
GNUNET_FS_GTK_open_download_as_dialog (de);
@@ -366,7 +366,7 @@
while ( ( (NULL == nsid) ||
(0 != memcmp (nsid,
&want,
- sizeof (struct GNUNET_FS_PseudonymIdentifier))) ) &&
+ sizeof (struct GNUNET_CRYPTO_EccPublicKey))) ) &&
(gtk_tree_model_iter_next (namespace_treestore, &iter)) )
gtk_tree_model_get (namespace_treestore, &iter,
GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_KEY,
@@ -375,7 +375,7 @@
if ( (NULL == nsid) ||
(0 != memcmp (nsid,
&want,
- sizeof (struct GNUNET_FS_PseudonymIdentifier))) )
+ sizeof (struct GNUNET_CRYPTO_EccPublicKey))) )
{
/* namespace unknown / not in list!? */
GNUNET_break (0);
@@ -448,16 +448,20 @@
*/
static int
find_largest_namespace_rating_iterator (void *cls,
- const struct GNUNET_FS_PseudonymIdentifier *pseudonym, const char *name,
- const char *unique_name,
- const struct GNUNET_CONTAINER_MetaData *md, int32_t rating)
+ const struct GNUNET_CRYPTO_EccPublicKey
*pseudonym,
+ const char *name,
+ const char *unique_name,
+ const struct GNUNET_CONTAINER_MetaData
*md,
+ int32_t rating)
{
int *largest = cls;
+
if (*largest < rating)
*largest = rating;
return GNUNET_OK;
}
+
/**
* Finds largest namespace rating.
* Used to calculate a rating for newly discovered namespaces.
@@ -472,10 +476,12 @@
if (largest_namespace_rating != INT_MIN)
return largest_namespace_rating;
(void) GNUNET_FS_pseudonym_list_all (GNUNET_FS_GTK_get_configuration (),
- find_largest_namespace_rating_iterator, &largest_namespace_rating);
+ &find_largest_namespace_rating_iterator,
+ &largest_namespace_rating);
return largest_namespace_rating;
}
+
/**
* Sets largest namespace rating.
* Used to change cached largest namespace rating, when namespace list
@@ -491,6 +497,7 @@
largest_namespace_rating = new_value;
}
+
/**
* Converts a GtkTreeRowReference to a GtkTreeIter.
*
Deleted: gnunet-gtk/src/fs/gnunet-fs-gtk_create-pseudonym.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_create-pseudonym.c 2013-08-07 21:27:52 UTC
(rev 28443)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_create-pseudonym.c 2013-08-07 21:28:16 UTC
(rev 28444)
@@ -1,123 +0,0 @@
-/*
- This file is part of GNUnet
- (C) 2005, 2006, 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
- by the Free Software Foundation; either version 2, 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/fs/gnunet-fs-gtk_create-pseudonym.c
- * @author Christian Grothoff
- * @brief code to handle the main menu action to create a pseudonym
- */
-#include "gnunet-fs-gtk_common.h"
-#include "gnunet-fs-gtk.h"
-
-
-/**
- * Function called whenever text is added to the GtkEntry
- * with the name of the namespace. Here, we check that only
- * "valid" characters are used (as the result must be a valid
- * filename on most OSes).
- *
- * @param entry GtkEntry being edited
- * @param text the text
- * @param length length of the text
- * @param position where the text is being inserted
- * @param data the builder of the dialog (unused)
- */
-void
-GNUNET_FS_GTK_create_namespace_insert_text_cb (GtkEntry *entry,
- const gchar *text,
- gint length,
- gint *position,
- gpointer data)
-{
- GtkEditable *editable = GTK_EDITABLE(entry);
- gint i;
-
- for (i=0; i < length; i++)
- if ( (! isalnum((int) text[i])) && (text[i] != '_') && (text[i] != '-') )
- g_signal_stop_emission_by_name (G_OBJECT (editable), "insert_text");
-}
-
-
-/**
- * User completed the 'create pseudonym' dialog. Run the desired action.
- *
- * @param dialog the dialog
- * @param response_id GTK_RESPONSE_OK on "OK"
- * @param user_data the builder of the dialog
- */
-void
-GNUNET_GTK_create_namespace_dialog_response_cb (GtkDialog * dialog,
- gint response_id,
- gpointer user_data)
-{
- GtkBuilder *builder = GTK_BUILDER (user_data);
- const char *name;
- struct GNUNET_FS_Namespace *ns;
-
- if (GTK_RESPONSE_OK != response_id)
- {
- gtk_widget_destroy (GTK_WIDGET (dialog));
- g_object_unref (G_OBJECT (builder));
- return;
- }
- name = gtk_entry_get_text (GTK_ENTRY (gtk_builder_get_object (builder,
-
"GNUNET_GTK_create_namespace_name_entry")));
- if (NULL != name)
- {
- ns = GNUNET_FS_namespace_create (GNUNET_FS_GTK_get_fs_handle (), name);
- GNUNET_break (NULL != ns);
- if (NULL != ns)
- GNUNET_FS_namespace_delete (ns, GNUNET_NO);
- }
- gtk_widget_destroy (GTK_WIDGET (dialog));
- g_object_unref (G_OBJECT (builder));
-}
-
-
-/**
- * User selected "create pseudonym" in the menu of the main window.
- *
- * @param dummy the menu entry
- * @param user_data the main dialog builder, unused
- */
-void
-GNUNET_GTK_main_menu_create_pseudonym_activate_cb (GtkWidget * dummy,
- gpointer user_data)
-{
- GtkWidget *ad;
- GtkWidget *toplevel;
- GtkBuilder *builder;
-
- builder = GNUNET_GTK_get_new_builder
("gnunet_fs_gtk_create_namespace_dialog.glade", NULL);
- if (NULL == builder)
- {
- GNUNET_break (0);
- return;
- }
- ad = GTK_WIDGET (gtk_builder_get_object
- (builder, "GNUNET_GTK_create_namespace_dialog"));
- toplevel = gtk_widget_get_toplevel (dummy);
- if (GTK_IS_WINDOW (toplevel))
- gtk_window_set_transient_for (GTK_WINDOW (ad), GTK_WINDOW (toplevel));
- gtk_window_present (GTK_WINDOW (ad));
-}
-
-
-/* end of gnunet-fs-gtk_create-pseudonym.c */
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c 2013-08-07 21:27:52 UTC
(rev 28443)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c 2013-08-07 21:28:16 UTC
(rev 28444)
@@ -1,10 +1,10 @@
/*
This file is part of GNUnet.
- (C) 2010, 2011, 2012 Christian Grothoff (and other contributing authors)
+ (C) 2010-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 2, or (at your
+ 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
@@ -968,13 +968,21 @@
GNUNET_free (uris);
}
-/* Called for each embedded sks. Return GNUNET_OK to continue iteration */
-typedef int (*embedded_sks_callback) (void *cls, const struct GNUNET_FS_Uri
*sks_uri,
- const char *sks_uri_string, struct GNUNET_FS_PseudonymIdentifier *nsid);
+/**
+ * Called for each embedded sks.
+ *
+ * @return GNUNET_OK to continue iteration
+ */
+typedef int (*EmbeddedSksCallback) (void *cls,
+ const struct GNUNET_FS_Uri *sks_uri,
+ const char *sks_uri_string,
+ const struct GNUNET_CRYPTO_EccPublicKey
*nsid);
+
+
struct sks_scanner_callback_context
{
- embedded_sks_callback cb;
+ EmbeddedSksCallback cb;
void *cls;
};
@@ -1014,7 +1022,8 @@
char *id = GNUNET_FS_uri_sks_get_content_id (sks_uri);
if (NULL != id)
{
- struct GNUNET_FS_PseudonymIdentifier nsid;
+ struct GNUNET_CRYPTO_EccPublicKey nsid;
+
if ((0 == strcmp (id, "/")) &&
(GNUNET_OK == GNUNET_FS_uri_sks_get_namespace (sks_uri, &nsid)))
result = ctx->cb (ctx->cls, sks_uri, data, &nsid);
@@ -1034,7 +1043,7 @@
*/
static void
find_embedded_sks (const struct GNUNET_CONTAINER_MetaData *meta,
- embedded_sks_callback cb, void *cls)
+ EmbeddedSksCallback cb, void *cls)
{
struct sks_scanner_callback_context ctx;
@@ -1045,21 +1054,25 @@
}
-struct sks_population_context
+struct SksPopulationContext
{
GtkMenu *menu;
int counter;
uintptr_t anonymity_level;
};
-/* Called for every SKS URI in metadata. Adds up to 3 menu items
+
+/**
+ * Called for every SKS URI in metadata. Adds up to 3 menu items
* that will initiate downloads for these SKS URIs
*/
static int
-populate_popup_with_sks_items (void *cls, const struct GNUNET_FS_Uri *sks_uri,
- const char *sks_uri_string, struct GNUNET_FS_PseudonymIdentifier *nsid)
+populate_popup_with_sks_items (void *cls,
+ const struct GNUNET_FS_Uri *sks_uri,
+ const char *sks_uri_string,
+ const struct GNUNET_CRYPTO_EccPublicKey *nsid)
{
- struct sks_population_context *ctx = cls;
+ struct SksPopulationContext *ctx = cls;
GtkWidget *child;
char *label;
GtkWidget *ns_association_icon;
@@ -1084,6 +1097,7 @@
return (ctx->counter < 4) ? GNUNET_OK : GNUNET_SYSERR;
}
+
/**
* Context menu was requested for a search result list.
* Compute which menu items are applicable and display
@@ -1110,9 +1124,9 @@
struct SearchListPopupContext *spc;
struct GNUNET_CONTAINER_MetaData *meta;
int is_directory = GNUNET_NO;
- struct sks_population_context sks_pop_ctx;
+ struct SksPopulationContext sks_pop_ctx;
- spc = GNUNET_malloc (sizeof (struct SearchListPopupContext));
+ spc = GNUNET_new (struct SearchListPopupContext);
spc->tab = tab;
path = gtk_tree_model_get_path (tm, iter);
spc->rr = gtk_tree_row_reference_new (tm, path);
@@ -2166,7 +2180,7 @@
see_if_there_are_any_sks_uris (void *cls,
const struct GNUNET_FS_Uri *sks_uri,
const char *sks_uri_string,
- struct GNUNET_FS_PseudonymIdentifier *nsid)
+ const struct GNUNET_CRYPTO_EccPublicKey *nsid)
{
gboolean *gb = cls;
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c
2013-08-07 21:27:52 UTC (rev 28443)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c
2013-08-07 21:28:16 UTC (rev 28444)
@@ -4,7 +4,7 @@
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 2, or (at your
+ 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
@@ -292,14 +292,17 @@
* @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort
*/
static int
-add_namespace_to_ts (void *cls, const struct GNUNET_FS_PseudonymIdentifier
*pseudonym,
- const char *name, const char *unique_name,
- const struct GNUNET_CONTAINER_MetaData *md, int rating)
+add_namespace_to_ts (void *cls,
+ const struct GNUNET_CRYPTO_EccPublicKey *pseudonym,
+ const char *name,
+ const char *unique_name,
+ const struct GNUNET_CONTAINER_MetaData *md,
+ int rating)
{
GtkTreeStore *ts = cls;
char *root;
char *ns_name, *unique_ns_name;
- struct GNUNET_FS_PseudonymIdentifier *nsid;
+ struct GNUNET_CRYPTO_EccPublicKey *nsid;
char *description;
int desc_is_a_dup;
char *uris;
@@ -311,11 +314,12 @@
return GNUNET_OK;
GNUNET_FS_pseudonym_get_info (GNUNET_FS_GTK_get_configuration (),
- pseudonym, NULL, NULL, &ns_name, NULL);
+ pseudonym, NULL, NULL,
+ &ns_name, NULL);
unique_ns_name = GNUNET_FS_pseudonym_name_uniquify (
GNUNET_FS_GTK_get_configuration (), pseudonym, ns_name, NULL);
GNUNET_free (ns_name);
- nsid = GNUNET_malloc (sizeof (struct GNUNET_FS_PseudonymIdentifier));
+ nsid = GNUNET_new (struct GNUNET_CRYPTO_EccPublicKey);
*nsid = *pseudonym;
root = NULL;
uris = GNUNET_CONTAINER_meta_data_get_by_type (md, EXTRACTOR_METATYPE_URI);
@@ -345,12 +349,14 @@
return GNUNET_OK;
}
+
void
GNUNET_GTK_main_window_refresh_ns_list (struct GNUNET_GTK_MainWindowContext
*main_ctx)
{
GtkTreeIter iter;
GtkTreePath *treepath;
- struct GNUNET_FS_PseudonymIdentifier *key = NULL, *selected_ns_id;
+ struct GNUNET_CRYPTO_EccPublicKey *key = NULL;
+ struct GNUNET_CRYPTO_EccPublicKey *selected_ns_id;
gboolean found = FALSE;
gchar *value = NULL;
@@ -375,10 +381,10 @@
main_ctx->selected_ns_row = NULL;
}
selected_ns_id = NULL;
- if (key != NULL)
+ if (NULL != key)
{
- selected_ns_id = GNUNET_malloc (sizeof (struct
GNUNET_FS_PseudonymIdentifier));
- memcpy (selected_ns_id, key, sizeof (struct
GNUNET_FS_PseudonymIdentifier));
+ selected_ns_id = GNUNET_new (struct GNUNET_CRYPTO_EccPublicKey);
+ *selected_ns_id = *key;
}
if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (
@@ -427,7 +433,7 @@
-1);
if (selected_ns_id == NULL)
found = TRUE;
- else if (key != NULL && memcmp (key, selected_ns_id, sizeof (struct
GNUNET_FS_PseudonymIdentifier)) == 0)
+ else if (key != NULL && memcmp (key, selected_ns_id, sizeof (struct
GNUNET_CRYPTO_EccPublicKey)) == 0)
found = TRUE;
if (found || (TRUE != gtk_tree_model_iter_next (GTK_TREE_MODEL (
main_ctx->search_ns_treestore), &iter)))
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-search.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-search.c 2013-08-07
21:27:52 UTC (rev 28443)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-search.c 2013-08-07
21:28:16 UTC (rev 28444)
@@ -39,7 +39,7 @@
guint anonymity_level;
gchar *keywords;
gchar *mime_keyword;
- struct GNUNET_FS_PseudonymIdentifier *nsid;
+ struct GNUNET_CRYPTO_EccPublicKey *nsid;
struct GNUNET_FS_Uri *uri;
/* get anonymity level */
@@ -118,7 +118,7 @@
/* build KSK/SKS URI */
if (NULL != nsid)
{
- uri = GNUNET_FS_uri_sks_create_from_nsid (nsid, keywords);
+ uri = GNUNET_FS_uri_sks_create (nsid, keywords);
GNUNET_assert (uri != NULL);
}
else
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_namespace_manager.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_namespace_manager.c 2013-08-07 21:27:52 UTC
(rev 28443)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_namespace_manager.c 2013-08-07 21:28:16 UTC
(rev 28444)
@@ -1,10 +1,10 @@
/*
This file is part of GNUnet
- (C) 2005, 2006, 2010, 2012 Christian Grothoff (and other contributing
authors)
+ (C) 2005-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 2, or (at your
+ 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
@@ -73,6 +73,7 @@
#define GNUNET_GTK_NAMESPACE_DETAILS_DATA_MIME_COLUMN 4
#define GNUNET_GTK_NAMESPACE_DETAILS_VALUE_COLUMN 5
+
static void
sort_order_list (struct GNUNET_GTK_NamespaceManagerContext *ctx,
int sort_column)
@@ -175,6 +176,7 @@
g_free (row_ints);
}
+
void
GNUNET_GTK_namespace_manager_namespace_order_column_clicked_cb (
GtkTreeViewColumn *treeviewcolumn, gpointer user_data)
@@ -194,6 +196,7 @@
}
}
+
void
GNUNET_GTK_namespace_manager_known_namespaces_delete_button_clicked_cb (
GtkButton *button, gpointer user_data)
@@ -241,13 +244,14 @@
ctx->uneditable_md = NULL;
}
+
void
GNUNET_GTK_namespace_manager_known_namespaces_swap_rank_button_clicked_cb (
GtkButton *button, gpointer user_data)
{
struct GNUNET_GTK_NamespaceManagerContext *ctx = user_data;
GtkTreeIter known_iter, order_iter;
- struct GNUNET_FS_PseudonymIdentifier *nsid;
+ struct GNUNET_CRYPTO_EccPublicKey *nsid;
int32_t old_rank, new_rank;
GtkTreeRowReference *order_row, *known_row;
@@ -315,6 +319,7 @@
}
}
+
void
GNUNET_GTK_namespace_manager_namespace_order_apply_clicked_cb (
GtkButton *button, gpointer user_data)
@@ -358,6 +363,7 @@
}
}
+
void
GNUNET_GTK_namespace_manager_namespace_details_add_button_clicked_cb (
GtkButton *button, gpointer user_data)
@@ -367,6 +373,7 @@
*/
}
+
void
GNUNET_GTK_namespace_manager_namespace_details_delete_button_clicked_cb (
GtkButton *button, gpointer user_data)
@@ -381,6 +388,7 @@
gtk_widget_set_sensitive (ctx->details_apply_button, TRUE);
}
+
void
GNUNET_GTK_namespace_manager_namespace_details_apply_button_clicked_cb (
GtkButton *button, gpointer user_data)
@@ -448,6 +456,7 @@
gtk_widget_set_sensitive (ctx->details_apply_button, FALSE);
}
+
void
GNUNET_GTK_namespace_manager_name_text_editing_started_cb (
GtkCellRenderer *renderer, GtkCellEditable *editable, gchar *path,
@@ -484,6 +493,7 @@
}
}
+
void
GNUNET_GTK_namespace_manager_name_text_edited_cb (
GtkCellRendererText *renderer, gchar *path, gchar *new_text,
@@ -504,7 +514,7 @@
if (gtk_tree_model_get_iter (GTK_TREE_MODEL (ctx->known_ns_store),
&iter, tree_path))
{
- struct GNUNET_FS_PseudonymIdentifier *nsid;
+ struct GNUNET_CRYPTO_EccPublicKey *nsid;
gtk_tree_model_get (GTK_TREE_MODEL (ctx->known_ns_store), &iter,
GNUNET_GTK_KNOWN_NAMESPACES_IDENTIFIER_BIN_COLUMN, &nsid,
GNUNET_GTK_KNOWN_NAMESPACES_ORDER_ROW_REFERENCE_COLUMN, &order_row,
@@ -535,6 +545,7 @@
}
}
+
void
GNUNET_GTK_namespace_manager_namespace_details_type_text_edited_cb (
GtkCellRendererText *renderer, gchar *path, gchar *new_text,
@@ -557,6 +568,7 @@
*/
}
+
void
GNUNET_GTK_namespace_manager_namespace_details_value_text_edited_cb (
GtkCellRendererText *renderer, gchar *path, gchar *new_text,
@@ -588,6 +600,7 @@
}
}
+
/**
* Iterator over all known pseudonyms.
* Populate "known ns" and "ns order" lists.
@@ -599,23 +612,25 @@
* @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort
*/
static int
-populate_known_ns_list (void *cls, const struct GNUNET_FS_PseudonymIdentifier
*pseudonym,
- const char *name, const char *unique_name,
- const struct GNUNET_CONTAINER_MetaData *md, int rating)
+populate_known_ns_list (void *cls,
+ const struct GNUNET_CRYPTO_EccPublicKey *pseudonym,
+ const char *name, const char *unique_name,
+ const struct GNUNET_CONTAINER_MetaData *md,
+ int rating)
{
struct GNUNET_GTK_NamespaceManagerContext *ctx = cls;
- struct GNUNET_FS_PseudonymIdentifier *nsid;
+ struct GNUNET_CRYPTO_EccPublicKey *nsid;
char buf[1024];
char *ret;
GtkTreeIter known_iter, order_iter;
struct GNUNET_CONTAINER_MetaData *md_copy;
char *non_null_name, *non_null_unique_name;
- nsid = GNUNET_malloc (sizeof (struct GNUNET_FS_PseudonymIdentifier));
+ nsid = GNUNET_new (struct GNUNET_CRYPTO_EccPublicKey);
*nsid = *pseudonym;
ret = GNUNET_STRINGS_data_to_string (nsid,
- sizeof (struct
GNUNET_FS_PseudonymIdentifier),
+ sizeof (struct
GNUNET_CRYPTO_EccPublicKey),
buf,
sizeof (buf));
GNUNET_assert (NULL != ret);
@@ -661,13 +676,14 @@
return GNUNET_OK;
}
+
static void
apply_known_ns_changes (struct GNUNET_GTK_NamespaceManagerContext *ctx)
{
GtkTreeIter iter;
gint i;
gint row_count;
- struct GNUNET_FS_PseudonymIdentifier *nsid;
+ struct GNUNET_CRYPTO_EccPublicKey *nsid;
char *name;
int32_t rank;
struct GNUNET_CONTAINER_MetaData *md;
@@ -693,6 +709,7 @@
ctx->known_ns_store), &iter))
break;
}
+#if FIXME_NAMESPACE_REMOVAL
while (NULL != ctx->deleted_namespaces)
{
nsid = ctx->deleted_namespaces->data;
@@ -701,18 +718,19 @@
GNUNET_FS_pseudonym_remove (GNUNET_FS_GTK_get_configuration (), nsid);
GNUNET_free (nsid);
}
-
ctx->deleted_namespaces = g_list_delete_link (ctx->deleted_namespaces,
ctx->deleted_namespaces);
}
+#endif
}
+
static void
free_lists_contents (struct GNUNET_GTK_NamespaceManagerContext *ctx)
{
GtkTreeIter iter;
gint i;
gint row_count;
- struct GNUNET_FS_PseudonymIdentifier *nsid;
+ struct GNUNET_CRYPTO_EccPublicKey *nsid;
GtkTreeRowReference *order_row;
struct GNUNET_CONTAINER_MetaData *md;
@@ -763,6 +781,7 @@
GNUNET_CONTAINER_meta_data_destroy (ctx->uneditable_md);
}
+
void
GNUNET_GTK_namespace_manager_dialog_response_cb (GtkDialog *dialog,
gint response_id, gpointer user_data)
@@ -796,13 +815,13 @@
mark_as_mine (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter,
gpointer data)
{
- const struct GNUNET_FS_PseudonymIdentifier *mine_id = data;
- const struct GNUNET_FS_PseudonymIdentifier *ns_id;
+ const struct GNUNET_CRYPTO_EccPublicKey *mine_id = data;
+ const struct GNUNET_CRYPTO_EccPublicKey *ns_id;
gtk_tree_model_get (model, iter,
GNUNET_GTK_KNOWN_NAMESPACES_IDENTIFIER_BIN_COLUMN, &ns_id, -1);
- if (memcmp (ns_id, mine_id, sizeof (struct GNUNET_FS_PseudonymIdentifier))
!= 0)
+ if (memcmp (ns_id, mine_id, sizeof (struct GNUNET_CRYPTO_EccPublicKey)) != 0)
return FALSE;
gtk_list_store_set (GTK_LIST_STORE (model), iter,
@@ -810,6 +829,7 @@
return TRUE;
}
+
/**
* Callback with information about local (!) namespaces.
* Contains the names of the local namespace and the global
@@ -821,7 +841,7 @@
*/
static void
mark_namespaces_as_mine (void *cls, const char *name,
- const struct GNUNET_FS_PseudonymIdentifier *id)
+ const struct GNUNET_CRYPTO_EccPublicKey *id)
{
struct GNUNET_GTK_NamespaceManagerContext *ctx = cls;
@@ -829,6 +849,7 @@
(gpointer) id);
}
+
/**
* Type of a function that libextractor calls for each
* meta data item found.
@@ -881,6 +902,7 @@
return 0;
}
+
static void
ns_details_selection_changed (GtkTreeSelection *treeselection,
gpointer user_data)
@@ -897,6 +919,7 @@
gtk_widget_set_sensitive (ctx->details_delete_button, TRUE);
}
+
static void
known_ns_selection_changed (GtkTreeSelection *treeselection,
gpointer user_data)
@@ -925,12 +948,13 @@
gtk_widget_set_sensitive (ctx->details_apply_button, FALSE);
}
+
GtkWindow *
GNUNET_GTK_namespace_manager_open (struct GNUNET_GTK_MainWindowContext
*main_ctx)
{
struct GNUNET_GTK_NamespaceManagerContext *ctx;
- ctx = GNUNET_malloc (sizeof (struct GNUNET_GTK_NamespaceManagerContext));
+ ctx = GNUNET_new (struct GNUNET_GTK_NamespaceManagerContext);
ctx->builder = GNUNET_GTK_get_new_builder
("gnunet_fs_gtk_namespace_manager.glade", ctx);
if (ctx->builder == NULL)
{
@@ -980,9 +1004,11 @@
(void) GNUNET_FS_pseudonym_list_all (GNUNET_FS_GTK_get_configuration (),
populate_known_ns_list, ctx);
+#if FIXME_USE_IDENTITY_SERVICE
/* mark our own namespaces as such */
GNUNET_FS_namespace_list (GNUNET_FS_GTK_get_fs_handle (),
- mark_namespaces_as_mine, ctx);
+ &mark_namespaces_as_mine, ctx);
+#endif
/* sort namespace order list by rank (initially) */
sort_order_list (ctx, GNUNET_GTK_NAMESPACE_ORDER_RANK_COLUMN);
@@ -994,7 +1020,8 @@
return ctx->namespace_manager;
}
-void
+
+static void
ns_manager_deleted (GtkWindow *object, gpointer user_data)
{
struct GNUNET_GTK_MainWindowContext *ctx = user_data;
@@ -1005,6 +1032,7 @@
return;
}
+
void
GNUNET_GTK_open_ns_manager (struct GNUNET_GTK_MainWindowContext *ctx)
{
@@ -1022,6 +1050,7 @@
ctx->ns_manager_delete_handler_id = g_signal_connect (G_OBJECT
(ctx->ns_manager), "destroy", G_CALLBACK (ns_manager_deleted), ctx);
}
+
void
GNUNET_GTK_main_menu_file_manage_pseudonyms_activate_cb (GtkMenuItem *menuitem,
gpointer user_data)
@@ -1029,6 +1058,7 @@
GNUNET_GTK_open_ns_manager (user_data);
}
+
void
namespace_selector_manage_namespaces_button_clicked_cb (GtkButton *button,
gpointer user_data)
{
Deleted: gnunet-gtk/src/fs/gnunet-fs-gtk_namespace_organizer.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_namespace_organizer.c 2013-08-07
21:27:52 UTC (rev 28443)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_namespace_organizer.c 2013-08-07
21:28:16 UTC (rev 28444)
@@ -1,781 +0,0 @@
-/*
- This file is part of GNUnet
- (C) 2005, 2006, 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
- by the Free Software Foundation; either version 2, 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/fs/gnunet-fs-gtk_namespace_organizer.c
- * @author LRN
- */
-#include "gnunet-fs-gtk_common.h"
-#include "gnunet-fs-gtk.h"
-#include "gnunet-fs-gtk_advertise-pseudonym.h"
-#include <gnunet/gnunet_util_lib.h>
-#include <gnunet/gnunet_fs_service.h>
-
-struct GNUNET_GTK_NamespaceSelectorContext
-{
- GtkBuilder *builder;
- GtkWidget *my_ns;
- GtkTreeSelection *my_ns_sel;
- GtkListStore *my_ns_store;
- GtkWindow *namespace_organizer;
- GtkWidget *create_button;
- GtkWidget *delete_button;
- GtkWidget *advertise_button;
- GtkWidget *do_delete_button;
- GtkWidget *do_keep_button;
- GtkWidget *progress_spinner;
- GtkWidget *progress_label;
- GtkWidget *confirmation_label;
- char *default_ns;
- GtkTreeRowReference *default_ns_rref;
- struct GNUNET_GTK_MainWindowContext *main_ctx;
-};
-
-#define GNUNET_GTK_MY_NAMESPACES_NAME_COLUMN 0
-#define GNUNET_GTK_MY_NAMESPACES_KEY_COLUMN 1
-#define GNUNET_GTK_MY_NAMESPACES_KEY_BINARY_COLUMN 2
-#define GNUNET_GTK_MY_NAMESPACES_USE_THIS_COLUMN 3
-#define GNUNET_GTK_MY_NAMESPACES_ACTUAL_NAME_COLUMN 4
-
-/**
- * User edited the name of a namespace.
- * Rename the namespace.
- *
- * @param renderer cell renderer
- * @param path path to the cell that was edited (as a string)
- * @param new_text new contents of the cell
- * @param user_data context
- */
-void
-GNUNET_GTK_namespace_organizer_namespaces_treeview_column_name_text_edited_cb (
- GtkCellRendererText *renderer, gchar *path, gchar *new_text,
- gpointer user_data)
-{
- struct GNUNET_GTK_NamespaceSelectorContext *ctx = user_data;
- GtkTreePath *tree_path;
- GtkTreeIter iter;
-
- if (strlen (new_text) == 0)
- return;
-
- tree_path = gtk_tree_path_new_from_string (path);
- if (tree_path != NULL)
- {
- if (gtk_tree_model_get_iter (GTK_TREE_MODEL (ctx->my_ns_store),
- &iter, tree_path))
- {
- struct GNUNET_FS_PseudonymIdentifier *nsid;
- char *old_name;
- gtk_tree_model_get (GTK_TREE_MODEL (ctx->my_ns_store), &iter,
- GNUNET_GTK_MY_NAMESPACES_NAME_COLUMN, &old_name,
- GNUNET_GTK_MY_NAMESPACES_KEY_BINARY_COLUMN, &nsid,
- -1);
-
- if ((NULL == nsid) ||
- (GNUNET_OK == GNUNET_FS_namespace_rename (
- GNUNET_FS_GTK_get_fs_handle (), old_name, new_text)))
- {
- gtk_list_store_set (ctx->my_ns_store, &iter,
- GNUNET_GTK_MY_NAMESPACES_NAME_COLUMN, new_text, -1);
- }
-
- GNUNET_free (old_name);
- }
- gtk_tree_path_free (tree_path);
- }
-}
-
-/**
- * Frees contents of the namespace list (the nsid values that are stored as
- * untyped pointers in the tree).
- *
- * @param ctx NS organizer context
- */
-static void
-free_lists_contents (struct GNUNET_GTK_NamespaceSelectorContext *ctx)
-{
- GtkTreeIter iter;
- gint i;
- gint row_count;
- struct GNUNET_FS_PseudonymIdentifier *nsid;
-
- row_count = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (
- ctx->my_ns_store), NULL);
- if (! gtk_tree_model_get_iter_first (GTK_TREE_MODEL (
- ctx->my_ns_store), &iter))
- return;
-
- for (i = 0; i < row_count; i++)
- {
- gtk_tree_model_get (GTK_TREE_MODEL (ctx->my_ns_store), &iter,
- GNUNET_GTK_MY_NAMESPACES_KEY_BINARY_COLUMN, &nsid,
- -1);
- GNUNET_free (nsid);
- if (TRUE != gtk_tree_model_iter_next (GTK_TREE_MODEL (
- ctx->my_ns_store), &iter))
- break;
- }
-
- gtk_list_store_clear (ctx->my_ns_store);
-}
-
-/**
- * Called when dialog is being closed (for any reason).
- *
- * @param dialog dialog being closed
- * @param response_id identifies the event
- * @param user_data context
- */
-void
-GNUNET_GTK_namespace_organizer_dialog_response_cb (GtkDialog *dialog,
- gint response_id, gpointer user_data)
-{
- struct GNUNET_GTK_NamespaceSelectorContext *ctx = user_data;
- switch (response_id)
- {
- case GTK_RESPONSE_CLOSE:
- default:
- free_lists_contents (ctx);
- gtk_widget_destroy (GTK_WIDGET (ctx->namespace_organizer));
- GNUNET_free (ctx);
- }
-}
-
-/**
- * Store a reference to the default namespace for later use.
- *
- * @param ctx context
- * @param iter points to the default namespace in the list
- */
-static void
-save_default_ns_reference (struct GNUNET_GTK_NamespaceSelectorContext *ctx,
GtkTreeIter *iter)
-{
- GtkTreeRowReference *ref;
- GtkTreePath *rowpath;
-
- rowpath = gtk_tree_model_get_path (GTK_TREE_MODEL (ctx->my_ns_store), iter);
- if (rowpath)
- {
- ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (ctx->my_ns_store),
rowpath);
- if (ref)
- {
- gtk_tree_row_reference_free (ctx->default_ns_rref);
- ctx->default_ns_rref = ref;
- }
- gtk_tree_path_free (rowpath);
- }
-}
-
-
-/**
- * Try to mark an item in the list as the default namespace.
- *
- * @param ctx context
- * @param iter points to the new default namespace in the list
- */
-static void
-try_make_default (struct GNUNET_GTK_NamespaceSelectorContext *ctx, GtkTreeIter
*toggled)
-{
- GtkTreeIter iter;
- gchar *new_default_ns;
- gint i;
- gint row_count;
- GtkTreePath *path;
-
- row_count = gtk_tree_model_iter_n_children (
- GTK_TREE_MODEL (ctx->my_ns_store), NULL);
- if (! gtk_tree_model_get_iter_first (
- GTK_TREE_MODEL (ctx->my_ns_store), &iter))
- return;
-
- path = gtk_tree_row_reference_get_path (ctx->default_ns_rref);
- if (path)
- {
- /* We know where previous default was, only untoggle that item */
- GtkTreeIter old_default;
- if (gtk_tree_model_get_iter (GTK_TREE_MODEL (ctx->my_ns_store),
&old_default, path))
- {
- gtk_list_store_set (ctx->my_ns_store, &old_default,
- GNUNET_GTK_MY_NAMESPACES_USE_THIS_COLUMN, FALSE,
- -1);
- }
- gtk_tree_path_free (path);
- }
- else
- {
- /* Just untoggle all items */
- for (i = 0; i < row_count; i++)
- {
- gtk_list_store_set (ctx->my_ns_store, &iter,
- GNUNET_GTK_MY_NAMESPACES_USE_THIS_COLUMN, FALSE,
- -1);
- if (TRUE != gtk_tree_model_iter_next (
- GTK_TREE_MODEL (ctx->my_ns_store), &iter))
- break;
- }
- }
-
- gtk_list_store_set (ctx->my_ns_store, toggled,
- GNUNET_GTK_MY_NAMESPACES_USE_THIS_COLUMN, TRUE, -1);
- gtk_tree_model_get (GTK_TREE_MODEL (ctx->my_ns_store), toggled,
- GNUNET_GTK_MY_NAMESPACES_NAME_COLUMN, &new_default_ns, -1);
-
- save_default_ns_reference (ctx, toggled);
-
- if (new_default_ns)
- {
- ctx->default_ns = GNUNET_strdup (new_default_ns);
- GNUNET_CONFIGURATION_set_value_string (
- (struct GNUNET_CONFIGURATION_Handle *) GNUNET_FS_GTK_get_configuration
(),
- "gnunet-fs-gtk", "DEFAULT_NAMESPACE", ctx->default_ns);
-
- g_free (new_default_ns);
- }
-}
-
-
-
-/**
- * Callback with information about local (!) namespaces.
- * Contains the names of the local namespace and the global
- * ID.
- *
- * @param cls closure
- * @param name human-readable identifier of the namespace
- * @param id hash identifier for the namespace
- */
-static void
-populate_my_ns_list (void *cls, const char *name,
- const struct GNUNET_FS_PseudonymIdentifier *id)
-{
- struct GNUNET_GTK_NamespaceSelectorContext *ctx = cls;
-
- char buf[1024];
- char *ret;
- GtkTreeIter my_iter;
- struct GNUNET_FS_PseudonymIdentifier *nsid;
- gboolean is_default;
-
- nsid = GNUNET_malloc (sizeof (struct GNUNET_FS_PseudonymIdentifier));
- *nsid = *id;
-
- ret = GNUNET_STRINGS_data_to_string (nsid,
- sizeof (struct GNUNET_FS_PseudonymIdentifier), buf, sizeof (buf));
- GNUNET_assert (NULL != ret);
- ret[0] = '\0';
-
- if (NULL == ctx->default_ns)
- {
- ctx->default_ns = GNUNET_strdup (name);
- GNUNET_CONFIGURATION_set_value_string (
- (struct GNUNET_CONFIGURATION_Handle *) GNUNET_FS_GTK_get_configuration
(),
- "gnunet-fs-gtk", "DEFAULT_NAMESPACE", ctx->default_ns);
- is_default = TRUE;
- }
- else
- is_default = (0 == strcmp (name, ctx->default_ns)) ? TRUE : FALSE;
-
- gtk_list_store_insert_with_values (ctx->my_ns_store, &my_iter, G_MAXINT,
- GNUNET_GTK_MY_NAMESPACES_NAME_COLUMN, name,
- GNUNET_GTK_MY_NAMESPACES_KEY_COLUMN, buf,
- GNUNET_GTK_MY_NAMESPACES_KEY_BINARY_COLUMN, nsid,
- GNUNET_GTK_MY_NAMESPACES_USE_THIS_COLUMN, is_default,
- GNUNET_GTK_MY_NAMESPACES_ACTUAL_NAME_COLUMN, NULL,
- -1);
-
- if (is_default)
- save_default_ns_reference (ctx, &my_iter);
-}
-
-/**
- * Returns button visibility/sensitivity to normal.
- *
- * @param ctx context
- * @param anything_selected TRUE if a namespace is selected in the list,
- * FALSE otherwise
- */
-static void
-set_normal_state (struct GNUNET_GTK_NamespaceSelectorContext *ctx, gboolean
anything_selected)
-{
- gtk_widget_set_visible (ctx->do_delete_button, FALSE);
- gtk_widget_set_visible (ctx->do_keep_button, FALSE);
- gtk_widget_set_visible (ctx->confirmation_label, FALSE);
-
- gtk_widget_set_sensitive (ctx->advertise_button, anything_selected);
- gtk_widget_set_sensitive (ctx->delete_button, anything_selected);
- gtk_widget_set_sensitive (ctx->create_button, TRUE);
-}
-
-/**
- * Handles ns list selection changes.
- *
- * @param treeselection selection object
- * @param user_data context
- */
-static void
-my_ns_selection_changed (GtkTreeSelection *treeselection,
- gpointer user_data)
-{
- struct GNUNET_GTK_NamespaceSelectorContext *ctx = user_data;
- GtkTreeIter iter;
- struct GNUNET_FS_PseudonymIdentifier *nsid;
- gboolean selected;
-
- nsid = NULL;
- selected = gtk_tree_selection_get_selected (ctx->my_ns_sel, NULL, &iter);
- if (selected)
- gtk_tree_model_get (GTK_TREE_MODEL (ctx->my_ns_store), &iter,
- GNUNET_GTK_MY_NAMESPACES_KEY_BINARY_COLUMN, &nsid, -1);
- if (NULL == nsid)
- selected = FALSE;
- set_normal_state (ctx, selected);
-}
-
-/**
- * Opens the organizer dialog. Called from outside (by the main window).
- *
- * @param main_ctx context of the main window
- * @return newly-created dialog window object
- */
-GtkWindow *
-GNUNET_GTK_namespace_organizer_open (struct GNUNET_GTK_MainWindowContext
*main_ctx)
-{
- struct GNUNET_GTK_NamespaceSelectorContext *ctx;
- const struct GNUNET_CONFIGURATION_Handle *cfg;
-
- ctx = GNUNET_malloc (sizeof (struct GNUNET_GTK_NamespaceSelectorContext));
- ctx->builder = GNUNET_GTK_get_new_builder
("gnunet_fs_gtk_namespace_organizer.glade", ctx);
- if (ctx->builder == NULL)
- {
- GNUNET_break (0);
- GNUNET_free (ctx);
- return NULL;
- }
-
- ctx->main_ctx = main_ctx;
-
- /* initialize widget references */
- ctx->my_ns = GTK_WIDGET (gtk_builder_get_object (ctx->builder,
- "GNUNET_GTK_namespace_organizer_namespaces_treeview"));
- ctx->my_ns_sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (
- ctx->my_ns));
- ctx->my_ns_store = GTK_LIST_STORE (gtk_tree_view_get_model (
- GTK_TREE_VIEW (ctx->my_ns)));
- ctx->namespace_organizer = GTK_WINDOW (gtk_builder_get_object (
- ctx->builder, "GNUNET_GTK_namespace_organizer_dialog"));
- ctx->create_button = GTK_WIDGET (gtk_builder_get_object (ctx->builder,
- "GNUNET_GTK_namespace_organizer_namespaces_create_namespace_button"));
- ctx->advertise_button = GTK_WIDGET (gtk_builder_get_object (ctx->builder,
- "GNUNET_GTK_namespace_organizer_namespaces_advertise_namespace_button"));
- ctx->delete_button = GTK_WIDGET (gtk_builder_get_object (ctx->builder,
- "GNUNET_GTK_namespace_organizer_namespaces_delete_namespace_button"));
- ctx->do_delete_button = GTK_WIDGET (gtk_builder_get_object (ctx->builder,
-
"GNUNET_GTK_namespace_organizer_namespaces_delete_namespace_confirmation_button"));
- ctx->do_keep_button = GTK_WIDGET (gtk_builder_get_object (ctx->builder,
-
"GNUNET_GTK_namespace_organizer_namespaces_delete_namespace_unconfirmation_button"));
- ctx->progress_spinner = GTK_WIDGET (gtk_builder_get_object (ctx->builder,
-
"GNUNET_GTK_namespace_organizer_namespaces_create_namespace_progress_spinner"));
- ctx->progress_label = GTK_WIDGET (gtk_builder_get_object (ctx->builder,
-
"GNUNET_GTK_namespace_organizer_namespaces_create_namespace_progress_label"));
- ctx->confirmation_label = GTK_WIDGET (gtk_builder_get_object (ctx->builder,
-
"GNUNET_GTK_namespace_organizer_namespaces_delete_namespace_confirmation_label"));
-
- /* connect signals; FIXME-GTK3: these could be connected with (modern) Glade
*/
- g_signal_connect (G_OBJECT (ctx->my_ns_sel), "changed",
- G_CALLBACK (my_ns_selection_changed), ctx);
-
- cfg = GNUNET_FS_GTK_get_configuration ();
-
- if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg,
- "gnunet-fs-gtk", "DEFAULT_NAMESPACE", &ctx->default_ns))
- ctx->default_ns = NULL;
-
- gtk_widget_set_sensitive (ctx->advertise_button, FALSE);
- gtk_widget_set_sensitive (ctx->delete_button, FALSE);
-
- gtk_widget_set_visible (ctx->do_delete_button, FALSE);
- gtk_widget_set_visible (ctx->do_keep_button, FALSE);
- gtk_widget_set_visible (ctx->progress_spinner, FALSE);
- gtk_widget_set_visible (ctx->progress_label, FALSE);
- gtk_widget_set_visible (ctx->confirmation_label, FALSE);
-
- /* populate namespace model */
- GNUNET_FS_namespace_list (GNUNET_FS_GTK_get_fs_handle (),
- populate_my_ns_list, ctx);
-
- /* show dialog */
- gtk_window_present (ctx->namespace_organizer);
- return ctx->namespace_organizer;
-}
-
-/**
- * Called when the organizer dialog is destoryed
- * (happens at some point after it's closed).
- * Cleans up references to the organizer dialog that main window stores.
- *
- * @param object the object that is being destroyed
- * @param user_data main window context
- */
-void
-GNUNET_GTK_namespace_organizer_dialog_destroy_cb (GtkWindow *object, gpointer
user_data)
-{
- struct GNUNET_GTK_MainWindowContext *ctx = user_data;
- g_signal_handler_disconnect (object, ctx->ns_organizer_delete_handler_id);
- g_object_unref (G_OBJECT (ctx->ns_organizer));
- ctx->ns_organizer = NULL;
- ctx->ns_organizer_delete_handler_id = 0;
- return;
-}
-
-/**
- * Wrapper for GNUNET_GTK_namespace_organizer_open(), ensures that
- * only one instance is opened.
- * @param ctx main window context
- */
-void
-GNUNET_GTK_open_ns_organizer (struct GNUNET_GTK_MainWindowContext *ctx)
-{
- if (ctx->ns_organizer != NULL)
- {
- gtk_window_present (ctx->ns_organizer);
- return;
- }
-
- ctx->ns_organizer = GNUNET_GTK_namespace_organizer_open (ctx);
- if (ctx->ns_organizer == NULL)
- return;
-
- g_object_ref (G_OBJECT (ctx->ns_organizer));
- ctx->ns_organizer_delete_handler_id = g_signal_connect (G_OBJECT
(ctx->ns_organizer), "destroy", G_CALLBACK
(GNUNET_GTK_namespace_organizer_dialog_destroy_cb), ctx);
-}
-
-/**
- * Called when user clicks at 'Advertise namespace' button.
- * Opens the advertising dialog (calls GNUNET_FS_GTK_advertise_namespace()).
- *
- * @param button button that was clicked
- * @param user_data context
- */
-void
-GNUNET_GTK_namespace_organizer_namespaces_advertise_namespace_button_clicked_cb
(
- GtkButton *button, gpointer user_data)
-{
- struct GNUNET_GTK_NamespaceSelectorContext *ctx = user_data;
- GtkTreeIter iter;
- gchar *name;
- struct GNUNET_FS_PseudonymIdentifier *nsid;
-
- nsid = NULL;
- name = NULL;
- if (gtk_tree_selection_get_selected (ctx->my_ns_sel, NULL, &iter))
- gtk_tree_model_get (GTK_TREE_MODEL (ctx->my_ns_store), &iter,
- GNUNET_GTK_MY_NAMESPACES_NAME_COLUMN, &name,
- GNUNET_GTK_MY_NAMESPACES_KEY_BINARY_COLUMN, &nsid,
- -1);
- if (NULL != nsid)
- {
- struct GNUNET_FS_Namespace *ns;
- ns = GNUNET_FS_namespace_open_existing (GNUNET_FS_GTK_get_fs_handle (),
name);
- if (ns)
- GNUNET_FS_GTK_advertise_namespace (ns, ctx->namespace_organizer);
- }
- g_free (name);
-}
-
-/**
- * Called when user clicks at 'Do not delete' button.
- * Returns the state back to normal (hides [un]confirmation buttons
- * and the warning label).
- *
- * @param button button that was clicked
- * @param user_data context
- */
-void
-GNUNET_GTK_namespace_organizer_namespaces_delete_namespace_unconfirmation_button_clicked_cb
(
- GtkButton *button, gpointer user_data)
-{
- set_normal_state (user_data, TRUE);
-}
-
-
-/**
- * Called when user clicks at 'Do delete' button.
- * Deletes selected namespace after double-checking that everything is
- * in order.
- * Returns the state back to normal (hides [un]confirmation buttons
- * and the warning label).
- *
- * @param button button that was clicked
- * @param user_data context
- */
-void
-GNUNET_GTK_namespace_organizer_namespaces_delete_namespace_confirmation_button_clicked_cb
(
- GtkButton *button, gpointer user_data)
-{
- struct GNUNET_GTK_NamespaceSelectorContext *ctx = user_data;
- GtkTreeIter iter;
- gchar *name;
- gboolean selected;
- struct GNUNET_FS_PseudonymIdentifier id;
- struct GNUNET_FS_PseudonymIdentifier *nsid;
-
- nsid = NULL;
- name = NULL;
- selected = gtk_tree_selection_get_selected (ctx->my_ns_sel, NULL, &iter);
- if (selected)
- gtk_tree_model_get (GTK_TREE_MODEL (ctx->my_ns_store), &iter,
- GNUNET_GTK_MY_NAMESPACES_NAME_COLUMN, &name,
- GNUNET_GTK_MY_NAMESPACES_KEY_BINARY_COLUMN, &nsid,
- -1);
- if (NULL == nsid)
- selected = FALSE;
-
- if (selected)
- {
- struct GNUNET_FS_Namespace *ns;
- ns = GNUNET_FS_namespace_open_existing (GNUNET_FS_GTK_get_fs_handle (),
name);
- if (ns)
- {
- if (GNUNET_FS_namespace_get_public_identifier (ns, &id))
- {
- if (0 == memcmp (&id, nsid, sizeof (id)))
- {
- GtkTreeIter first;
-
- GNUNET_free (nsid);
- gtk_list_store_remove (ctx->my_ns_store, &iter);
- GNUNET_FS_namespace_delete (ns, GNUNET_YES);
-
- if (gtk_tree_model_get_iter_first (
- GTK_TREE_MODEL (ctx->my_ns_store), &first))
- try_make_default (ctx, &first);
- }
- else
- {
- /* We were trying to delete namespace FOO with key X
- * but when we opened FOO, we discovered that its key is Y.
- * Clearly this is not the right namespace (something changed
- * the namespace list right under us?).
- */
- /* TODO: display error message */
- GNUNET_FS_namespace_delete (ns, GNUNET_NO);
- }
- }
- else
- {
- /* We were trying to delete namespace FOO,
- * but we can't even get its key
- */
- /* TODO: display error message */
- GNUNET_FS_namespace_delete (ns, GNUNET_NO);
- }
- }
- }
- g_free (name);
- set_normal_state (user_data, selected);
-}
-
-/**
- * Called when user clicks at 'Delete' button.
- * Shows the [un]confirmation buttons, as well as the warning.
- *
- * @param button button that was clicked
- * @param user_data context
- */
-void
-GNUNET_GTK_namespace_organizer_namespaces_delete_namespace_button_clicked_cb (
- GtkButton *button, gpointer user_data)
-{
- struct GNUNET_GTK_NamespaceSelectorContext *ctx = user_data;
- gtk_widget_set_visible (ctx->do_delete_button, TRUE);
- gtk_widget_set_visible (ctx->do_keep_button, TRUE);
- gtk_widget_set_visible (ctx->confirmation_label, TRUE);
- gtk_widget_set_sensitive (ctx->advertise_button, FALSE);
- gtk_widget_set_sensitive (ctx->delete_button, FALSE);
- gtk_widget_set_sensitive (ctx->create_button, FALSE);
-}
-
-/**
- * Generates a random ns name.
- *
- * @return new name (free with GNUNET_free()).
- */
-char *
-generate_local_ns_name ()
-{
- const char *table =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
- size_t tablelen = strlen (table);
- char random_str[9];
- char *result;
- int i;
- for (i = 0; i < 8; i++)
- {
- uint32_t index = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
tablelen);
- GNUNET_assert (index < tablelen);
- random_str[i] = table[index];
- }
- random_str[8] = '\0';
-
- GNUNET_asprintf (&result, _("MyNamespace-%s"), random_str);
- return result;
-}
-
-
-/**
- * Called when key generation for a namespace is finished.
- *
- * @param cls context
- * @param ns newly-created namespace (NULL on failure)
- * @param emsg error message (NULL on success)
- */
-static void
-ns_created (void *cls, struct GNUNET_FS_Namespace *ns, char *name, const char
*emsg)
-{
- struct GNUNET_GTK_NamespaceSelectorContext *ctx = cls;
-
- GtkTreeIter iter;
- struct GNUNET_FS_PseudonymIdentifier *nsid;
- struct GNUNET_FS_PseudonymIdentifier id;
-
- /* If ns was created, get its public key hash */
- nsid = NULL;
- if ((NULL != ns) && (GNUNET_OK == GNUNET_FS_namespace_get_public_identifier
(ns, &id)))
- {
- nsid = GNUNET_malloc (sizeof (struct GNUNET_FS_PseudonymIdentifier));
- memcpy (nsid, &id, sizeof (struct GNUNET_FS_PseudonymIdentifier));
- }
-
- /* If anything of the above went wrong, or ns creation failed, we abort */
- if (NULL == nsid)
- {
- GNUNET_FS_namespace_delete (ns, GNUNET_NO);
- }
- else
- {
- char buf[1024];
- char *ret;
- gint row_count;
-
- ret = GNUNET_STRINGS_data_to_string (nsid,
- sizeof (struct
GNUNET_FS_PseudonymIdentifier),
- buf,
- sizeof (buf));
- GNUNET_assert (NULL != ret);
- ret[0] = '\0';
-
- gtk_list_store_insert_with_values (ctx->my_ns_store, &iter, G_MAXINT,
- GNUNET_GTK_MY_NAMESPACES_KEY_COLUMN, buf,
- GNUNET_GTK_MY_NAMESPACES_KEY_BINARY_COLUMN, nsid,
- GNUNET_GTK_MY_NAMESPACES_NAME_COLUMN, name,
- -1);
-
- row_count = gtk_tree_model_iter_n_children (
- GTK_TREE_MODEL (ctx->my_ns_store), NULL);
- if (row_count == 1)
- try_make_default (ctx, &iter);
- }
-}
-
-
-/**
- * Create a namespace.
- * Adds a dummy to the list, starts the key generation process,
- * shows the progress spinner, disables some buttons.
- *
- * @param ctx context
- */
-static void
-create_namespace (struct GNUNET_GTK_NamespaceSelectorContext *ctx)
-{
- gchar *name;
- struct GNUNET_FS_Namespace *ns;
-
- ns = NULL;
- name = NULL;
- do
- {
- if (ns)
- GNUNET_FS_namespace_delete (ns, GNUNET_NO);
- GNUNET_free_non_null (name);
- name = generate_local_ns_name ();
- ns = GNUNET_FS_namespace_open_existing (GNUNET_FS_GTK_get_fs_handle (),
name);
- } while (NULL != ns);
-
- ns = GNUNET_FS_namespace_create (GNUNET_FS_GTK_get_fs_handle (), name);
-
- if (NULL == ns)
- {
- GNUNET_free (name);
- return;
- }
-
- ns_created (ctx, ns, name, NULL);
-
- GNUNET_free (name);
-}
-
-/**
- * Called when user clicks at 'Create' button.
- * Creates a namespace.
- *
- * @param button button that was clicked
- * @param user_data context
- */
-void
-GNUNET_GTK_namespace_organizer_namespaces_create_namespace_button_clicked_cb (
- GtkButton *button, gpointer user_data)
-{
- create_namespace (user_data);
-}
-
-/**
- * Called when user toggles the radio button at a namespace in the list
- * Tries to make that namespace the new default.
- *
- * @param cell_renderer renderer of the call that was toggled.
- * @param path path to the cell that was toggled
- * @param user_data context
- */
-void
-GNUNET_GTK_namespace_organizer_namespaces_treeview_column_usethis_toggle_toggled_cb
(
- GtkCellRendererToggle *cell_renderer, gchar *path, gpointer user_data)
-{
- struct GNUNET_GTK_NamespaceSelectorContext *ctx = user_data;
- GtkTreeIter iter;
- if (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (ctx->my_ns_store),
- &iter, path))
- try_make_default (ctx, &iter);
-}
-
-/**
- * Called when user activates the appropriate item in main window `File' menu.
- * Opens Namespace organizer dialog.
- *
- * @param menuitem item that was activated
- * @param user_data main window context
- */
-void
-GNUNET_GTK_main_menu_file_organize_namespaces_activate_cb (GtkMenuItem
*menuitem,
- gpointer user_data)
-{
- GNUNET_GTK_open_ns_organizer (user_data);
-}
-
-/* end of gnunet-fs-gtk_namespace_organizer.c */
Deleted: gnunet-gtk/src/fs/gnunet-fs-gtk_namespace_organizer.h
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_namespace_organizer.h 2013-08-07
21:27:52 UTC (rev 28443)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_namespace_organizer.h 2013-08-07
21:28:16 UTC (rev 28444)
@@ -1,36 +0,0 @@
-/*
- This file is part of GNUnet
- (C) 2005, 2006, 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
- by the Free Software Foundation; either version 2, 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/fs/gnunet-fs-gtk_namespace_organizer.h
- * @author LRN
- */
-
-#ifndef GNUNET_FS_GTK_NAMESPACE_ORGANIZER_H
-#define GNUNET_FS_GTK_NAMESPACE_ORGANIZER_H
-
-#include "gnunet-fs-gtk_common.h"
-#include "gnunet-fs-gtk.h"
-
-GtkObject *
-GNUNET_GTK_namespace_organizer_open (struct GNUNET_GTK_MainWindowContext
*main_ctx);
-
-#endif /* GNUNET_FS_GTK_NAMESPACE_ORGANIZER_H */
-/* end of gnunet-fs-gtk_namespace_organizer.c */
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_publish-dialog.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_publish-dialog.c 2013-08-07 21:27:52 UTC
(rev 28443)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_publish-dialog.c 2013-08-07 21:28:16 UTC
(rev 28444)
@@ -1,10 +1,10 @@
/*
This file is part of GNUnet
- (C) 2005, 2006, 2010, 2012 Christian Grothoff (and other contributing
authors)
+ (C) 2005-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 2, or (at your
+ 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
@@ -27,7 +27,9 @@
#include "gnunet-fs-gtk_publish-edit-dialog.h"
#include <gnunet/gnunet_util_lib.h>
#include <gnunet/gnunet_fs_service.h>
+#include <gnunet/gnunet_identity_service.h>
+
#define MARKER_DIR_FILE_SIZE "-"
/**
@@ -246,7 +248,7 @@
/**
* Default namespace. May be NULL.
*/
- struct GNUNET_FS_Namespace *ns;
+ struct GNUNET_IDENTITY_Ego *ns;
/**
* Stores the value that was in identifier_entry previously.
@@ -390,13 +392,13 @@
};
-static void clear_keywords_from_tm (struct MainPublishingDialogContext *ctx);
+static void
+clear_keywords_from_tm (struct MainPublishingDialogContext *ctx);
/* ************************ editing operations inside the master dialog
********************* */
-
/**
* Check if two GtkTreeIters refer to the same element.
*
@@ -406,9 +408,9 @@
* @return GNUNET_YES if they are equal
*/
static int
-gtk_tree_iter_equals (GtkTreeModel * tm,
- GtkTreeIter * i1,
- GtkTreeIter * i2)
+gtk_tree_iter_equals (GtkTreeModel *tm,
+ GtkTreeIter *i1,
+ GtkTreeIter *i2)
{
GtkTreePath *p1;
GtkTreePath *p2;
@@ -2041,8 +2043,6 @@
gtk_widget_destroy (GTK_WIDGET (ctx->master_pubdialog));
g_object_unref (G_OBJECT (ctx->builder));
GNUNET_free_non_null (ctx->ns_name);
- if (ctx->ns)
- GNUNET_FS_namespace_delete (ctx->ns, GNUNET_NO);
g_free (ctx->previous_id);
GNUNET_free (ctx);
return GNUNET_YES;
@@ -2073,17 +2073,12 @@
void **client_info)
{
struct MainPublishingDialogContext *ctx = cls;
-
+ struct GNUNET_CRYPTO_EccPublicKey pub;
struct GNUNET_FS_Uri *sks_uri;
- char *emsg;
char *sks_uri_string;
- emsg = NULL;
- sks_uri = GNUNET_FS_uri_sks_create (ctx->ns, "/", &emsg);
- GNUNET_free_non_null (emsg);
- if (NULL == sks_uri)
- return GNUNET_SYSERR;
-
+ GNUNET_IDENTITY_ego_get_public_key (ctx->ns, &pub);
+ sks_uri = GNUNET_FS_uri_sks_create (&pub, "/");
sks_uri_string = GNUNET_FS_uri_to_string (sks_uri);
GNUNET_FS_uri_destroy (sks_uri);
if (NULL == sks_uri_string)
@@ -2110,7 +2105,7 @@
{
struct MainPublishingDialogContext *ctx = user_data;
gchar *namespace_id;
- struct GNUNET_FS_Namespace *ns;
+ struct GNUNET_IDENTITY_Ego *ns;
const gchar *namespace_uid;
struct GNUNET_FS_FileInformation *fi;
GtkTreeIter iter;
@@ -2144,7 +2139,8 @@
if (NULL != (id_entry_text = gtk_entry_get_text (GTK_ENTRY
(ctx->identifier_entry))))
namespace_id = g_strdup (id_entry_text);
else if (!do_global)
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Global publication is disabled,
but namespace_id is not available\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Global publication is disabled, but namespace_id is not
available\n");
if ((NULL != namespace_id) && ('\0' == namespace_id[0]))
{
g_free (namespace_id);
@@ -2158,10 +2154,12 @@
ns = ctx->ns;
}
else if (!do_global)
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Global publication is disabled,
but namespace_id unavailable or zero-length\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Global publication is disabled, but namespace_id unavailable
or zero-length\n");
}
else if (!do_global)
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Global publication is disabled, ns
is either NULL or disabled, yet 'Execute' was pressed\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Global publication is disabled, ns is either NULL or disabled,
yet 'Execute' was pressed\n");
if ((!do_global) && (NULL == ns))
{
g_free (namespace_id);
@@ -2179,7 +2177,8 @@
GNUNET_FS_file_information_inspect (fi, insert_advertisement, ctx);
/* FIXME-FEATURE-BUG-MINOR: should we convert namespace id and uid from
UTF8? */
GNUNET_FS_publish_start (GNUNET_FS_GTK_get_fs_handle (),
- fi, ns,
+ fi,
+ GNUNET_IDENTITY_ego_get_private_key (ns),
namespace_id, namespace_uid,
GNUNET_FS_PUBLISH_OPTION_NONE);
}
@@ -2384,7 +2383,7 @@
/**
* Handle to the namespace.
*/
- struct GNUNET_FS_Namespace *ns;
+ struct GNUNET_IDENTITY_Ego *ns;
/**
* Hash codes of identifiers already added to tree store.
@@ -2531,7 +2530,10 @@
sc.ns = uc->ns;
sc.seen = uc->seen;
sc.update_called = GNUNET_NO;
- GNUNET_FS_namespace_list_updateable (uc->ns, next_id, &add_updateable_to_ts,
+ GNUNET_FS_namespace_list_updateable (GNUNET_FS_GTK_get_fs_handle (),
+ GNUNET_IDENTITY_ego_get_private_key
(uc->ns),
+ next_id,
+ &add_updateable_to_ts,
&sc);
if ((sc.update_called == GNUNET_NO) && (next_id != NULL) &&
(strlen (next_id) > 0))
@@ -2560,12 +2562,15 @@
* @return GNUNET_YES, always.
*/
static int
-free_seen_paths (void *cls, const struct GNUNET_HashCode * key, void *value)
+free_seen_paths (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
GNUNET_free_non_null (value);
return GNUNET_YES;
}
+
/**
* Add all updateable entries of the current namespace to the
* tree store.
@@ -2575,7 +2580,8 @@
* @param id identity of the namespace to add
*/
static void
-add_namespace_to_ts (GtkTreeStore *ts, struct GNUNET_FS_Namespace *ns)
+add_namespace_to_ts (GtkTreeStore *ts,
+ struct GNUNET_IDENTITY_Ego *ns)
{
struct UpdateableContext uc;
@@ -2584,13 +2590,15 @@
uc.ns = ns;
uc.update_called = GNUNET_NO;
uc.seen = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO);
- GNUNET_FS_namespace_list_updateable (uc.ns, NULL, &add_updateable_to_ts,
&uc);
+ GNUNET_FS_namespace_list_updateable (GNUNET_FS_GTK_get_fs_handle (),
+ GNUNET_IDENTITY_ego_get_private_key
(uc.ns),
+ NULL,
+ &add_updateable_to_ts, &uc);
GNUNET_CONTAINER_multihashmap_iterate (uc.seen, free_seen_paths, NULL);
GNUNET_CONTAINER_multihashmap_destroy (uc.seen);
}
-
/**
* Run the file-publishing operation (by opening the master publishing dialog).
*
@@ -2598,7 +2606,8 @@
* @param user_data builder of the main window
*/
void
-GNUNET_GTK_main_menu_file_publish_activate_cb (GtkWidget * dummy, gpointer
user_data)
+GNUNET_GTK_main_menu_file_publish_activate_cb (GtkWidget * dummy,
+ gpointer user_data)
{
struct MainPublishingDialogContext *ctx;
/* GtkTreeView *pseudonym_treeview;*/
@@ -2608,9 +2617,9 @@
int own_enabled;
int global_enabled;
- ctx = GNUNET_malloc (sizeof (struct MainPublishingDialogContext));
+ ctx = GNUNET_new (struct MainPublishingDialogContext);
ctx->builder = GNUNET_GTK_get_new_builder
("gnunet_fs_gtk_publish_dialog.glade", ctx);
- if (ctx->builder == NULL)
+ if (NULL == ctx->builder)
{
GNUNET_break (0);
GNUNET_free (ctx);
@@ -2678,16 +2687,21 @@
G_CALLBACK (identifiers_selection_changed_cb), ctx);
cfg = GNUNET_FS_GTK_get_configuration ();
- if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg,
- "gnunet-fs-gtk", "DEFAULT_NAMESPACE", &ctx->ns_name))
+#if FIXME_MIGRATE_TO_IDENTITY_SERVICE
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_string (cfg,
+ "gnunet-fs-gtk",
+ "DEFAULT_NAMESPACE",
+ &ctx->ns_name))
ctx->ns_name = NULL;
else
{
- ctx->ns = GNUNET_FS_namespace_open_existing (GNUNET_FS_GTK_get_fs_handle
(), ctx->ns_name);
+ ctx->ns = GNUNET_FS_namespace_open_existing (GNUNET_FS_GTK_get_fs_handle
(),
+ ctx->ns_name);
if (NULL == ctx->ns)
GNUNET_free (ctx->ns_name);
}
-
+#endif
have_ns = (NULL != ctx->ns);
gtk_widget_set_sensitive (ctx->own_checkbox, have_ns);
Copied: gnunet-gtk/src/identity/gnunet-identity-gtk_create_ego.c (from rev
28440, gnunet-gtk/src/fs/gnunet-fs-gtk_create-pseudonym.c)
===================================================================
--- gnunet-gtk/src/identity/gnunet-identity-gtk_create_ego.c
(rev 0)
+++ gnunet-gtk/src/identity/gnunet-identity-gtk_create_ego.c 2013-08-07
21:28:16 UTC (rev 28444)
@@ -0,0 +1,123 @@
+/*
+ This file is part of GNUnet
+ (C) 2005, 2006, 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
+ by the Free Software Foundation; either version 2, 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/fs/gnunet-fs-gtk_create-pseudonym.c
+ * @author Christian Grothoff
+ * @brief code to handle the main menu action to create a pseudonym
+ */
+#include "gnunet-fs-gtk_common.h"
+#include "gnunet-fs-gtk.h"
+
+
+/**
+ * Function called whenever text is added to the GtkEntry
+ * with the name of the namespace. Here, we check that only
+ * "valid" characters are used (as the result must be a valid
+ * filename on most OSes).
+ *
+ * @param entry GtkEntry being edited
+ * @param text the text
+ * @param length length of the text
+ * @param position where the text is being inserted
+ * @param data the builder of the dialog (unused)
+ */
+void
+GNUNET_FS_GTK_create_namespace_insert_text_cb (GtkEntry *entry,
+ const gchar *text,
+ gint length,
+ gint *position,
+ gpointer data)
+{
+ GtkEditable *editable = GTK_EDITABLE(entry);
+ gint i;
+
+ for (i=0; i < length; i++)
+ if ( (! isalnum((int) text[i])) && (text[i] != '_') && (text[i] != '-') )
+ g_signal_stop_emission_by_name (G_OBJECT (editable), "insert_text");
+}
+
+
+/**
+ * User completed the 'create pseudonym' dialog. Run the desired action.
+ *
+ * @param dialog the dialog
+ * @param response_id GTK_RESPONSE_OK on "OK"
+ * @param user_data the builder of the dialog
+ */
+void
+GNUNET_GTK_create_namespace_dialog_response_cb (GtkDialog * dialog,
+ gint response_id,
+ gpointer user_data)
+{
+ GtkBuilder *builder = GTK_BUILDER (user_data);
+ const char *name;
+ struct GNUNET_FS_Namespace *ns;
+
+ if (GTK_RESPONSE_OK != response_id)
+ {
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ g_object_unref (G_OBJECT (builder));
+ return;
+ }
+ name = gtk_entry_get_text (GTK_ENTRY (gtk_builder_get_object (builder,
+
"GNUNET_GTK_create_namespace_name_entry")));
+ if (NULL != name)
+ {
+ ns = GNUNET_FS_namespace_create (GNUNET_FS_GTK_get_fs_handle (), name);
+ GNUNET_break (NULL != ns);
+ if (NULL != ns)
+ GNUNET_FS_namespace_delete (ns, GNUNET_NO);
+ }
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ g_object_unref (G_OBJECT (builder));
+}
+
+
+/**
+ * User selected "create pseudonym" in the menu of the main window.
+ *
+ * @param dummy the menu entry
+ * @param user_data the main dialog builder, unused
+ */
+void
+GNUNET_GTK_main_menu_create_pseudonym_activate_cb (GtkWidget * dummy,
+ gpointer user_data)
+{
+ GtkWidget *ad;
+ GtkWidget *toplevel;
+ GtkBuilder *builder;
+
+ builder = GNUNET_GTK_get_new_builder
("gnunet_fs_gtk_create_namespace_dialog.glade", NULL);
+ if (NULL == builder)
+ {
+ GNUNET_break (0);
+ return;
+ }
+ ad = GTK_WIDGET (gtk_builder_get_object
+ (builder, "GNUNET_GTK_create_namespace_dialog"));
+ toplevel = gtk_widget_get_toplevel (dummy);
+ if (GTK_IS_WINDOW (toplevel))
+ gtk_window_set_transient_for (GTK_WINDOW (ad), GTK_WINDOW (toplevel));
+ gtk_window_present (GTK_WINDOW (ad));
+}
+
+
+/* end of gnunet-fs-gtk_create-pseudonym.c */
Copied: gnunet-gtk/src/identity/gnunet-identity-gtk_ego_organizer.c (from rev
28440, gnunet-gtk/src/fs/gnunet-fs-gtk_namespace_organizer.c)
===================================================================
--- gnunet-gtk/src/identity/gnunet-identity-gtk_ego_organizer.c
(rev 0)
+++ gnunet-gtk/src/identity/gnunet-identity-gtk_ego_organizer.c 2013-08-07
21:28:16 UTC (rev 28444)
@@ -0,0 +1,781 @@
+/*
+ This file is part of GNUnet
+ (C) 2005, 2006, 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
+ by the Free Software Foundation; either version 2, 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/fs/gnunet-fs-gtk_namespace_organizer.c
+ * @author LRN
+ */
+#include "gnunet-fs-gtk_common.h"
+#include "gnunet-fs-gtk.h"
+#include "gnunet-fs-gtk_advertise-pseudonym.h"
+#include <gnunet/gnunet_util_lib.h>
+#include <gnunet/gnunet_fs_service.h>
+
+struct GNUNET_GTK_NamespaceSelectorContext
+{
+ GtkBuilder *builder;
+ GtkWidget *my_ns;
+ GtkTreeSelection *my_ns_sel;
+ GtkListStore *my_ns_store;
+ GtkWindow *namespace_organizer;
+ GtkWidget *create_button;
+ GtkWidget *delete_button;
+ GtkWidget *advertise_button;
+ GtkWidget *do_delete_button;
+ GtkWidget *do_keep_button;
+ GtkWidget *progress_spinner;
+ GtkWidget *progress_label;
+ GtkWidget *confirmation_label;
+ char *default_ns;
+ GtkTreeRowReference *default_ns_rref;
+ struct GNUNET_GTK_MainWindowContext *main_ctx;
+};
+
+#define GNUNET_GTK_MY_NAMESPACES_NAME_COLUMN 0
+#define GNUNET_GTK_MY_NAMESPACES_KEY_COLUMN 1
+#define GNUNET_GTK_MY_NAMESPACES_KEY_BINARY_COLUMN 2
+#define GNUNET_GTK_MY_NAMESPACES_USE_THIS_COLUMN 3
+#define GNUNET_GTK_MY_NAMESPACES_ACTUAL_NAME_COLUMN 4
+
+/**
+ * User edited the name of a namespace.
+ * Rename the namespace.
+ *
+ * @param renderer cell renderer
+ * @param path path to the cell that was edited (as a string)
+ * @param new_text new contents of the cell
+ * @param user_data context
+ */
+void
+GNUNET_GTK_namespace_organizer_namespaces_treeview_column_name_text_edited_cb (
+ GtkCellRendererText *renderer, gchar *path, gchar *new_text,
+ gpointer user_data)
+{
+ struct GNUNET_GTK_NamespaceSelectorContext *ctx = user_data;
+ GtkTreePath *tree_path;
+ GtkTreeIter iter;
+
+ if (strlen (new_text) == 0)
+ return;
+
+ tree_path = gtk_tree_path_new_from_string (path);
+ if (tree_path != NULL)
+ {
+ if (gtk_tree_model_get_iter (GTK_TREE_MODEL (ctx->my_ns_store),
+ &iter, tree_path))
+ {
+ struct GNUNET_FS_PseudonymIdentifier *nsid;
+ char *old_name;
+ gtk_tree_model_get (GTK_TREE_MODEL (ctx->my_ns_store), &iter,
+ GNUNET_GTK_MY_NAMESPACES_NAME_COLUMN, &old_name,
+ GNUNET_GTK_MY_NAMESPACES_KEY_BINARY_COLUMN, &nsid,
+ -1);
+
+ if ((NULL == nsid) ||
+ (GNUNET_OK == GNUNET_FS_namespace_rename (
+ GNUNET_FS_GTK_get_fs_handle (), old_name, new_text)))
+ {
+ gtk_list_store_set (ctx->my_ns_store, &iter,
+ GNUNET_GTK_MY_NAMESPACES_NAME_COLUMN, new_text, -1);
+ }
+
+ GNUNET_free (old_name);
+ }
+ gtk_tree_path_free (tree_path);
+ }
+}
+
+/**
+ * Frees contents of the namespace list (the nsid values that are stored as
+ * untyped pointers in the tree).
+ *
+ * @param ctx NS organizer context
+ */
+static void
+free_lists_contents (struct GNUNET_GTK_NamespaceSelectorContext *ctx)
+{
+ GtkTreeIter iter;
+ gint i;
+ gint row_count;
+ struct GNUNET_FS_PseudonymIdentifier *nsid;
+
+ row_count = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (
+ ctx->my_ns_store), NULL);
+ if (! gtk_tree_model_get_iter_first (GTK_TREE_MODEL (
+ ctx->my_ns_store), &iter))
+ return;
+
+ for (i = 0; i < row_count; i++)
+ {
+ gtk_tree_model_get (GTK_TREE_MODEL (ctx->my_ns_store), &iter,
+ GNUNET_GTK_MY_NAMESPACES_KEY_BINARY_COLUMN, &nsid,
+ -1);
+ GNUNET_free (nsid);
+ if (TRUE != gtk_tree_model_iter_next (GTK_TREE_MODEL (
+ ctx->my_ns_store), &iter))
+ break;
+ }
+
+ gtk_list_store_clear (ctx->my_ns_store);
+}
+
+/**
+ * Called when dialog is being closed (for any reason).
+ *
+ * @param dialog dialog being closed
+ * @param response_id identifies the event
+ * @param user_data context
+ */
+void
+GNUNET_GTK_namespace_organizer_dialog_response_cb (GtkDialog *dialog,
+ gint response_id, gpointer user_data)
+{
+ struct GNUNET_GTK_NamespaceSelectorContext *ctx = user_data;
+ switch (response_id)
+ {
+ case GTK_RESPONSE_CLOSE:
+ default:
+ free_lists_contents (ctx);
+ gtk_widget_destroy (GTK_WIDGET (ctx->namespace_organizer));
+ GNUNET_free (ctx);
+ }
+}
+
+/**
+ * Store a reference to the default namespace for later use.
+ *
+ * @param ctx context
+ * @param iter points to the default namespace in the list
+ */
+static void
+save_default_ns_reference (struct GNUNET_GTK_NamespaceSelectorContext *ctx,
GtkTreeIter *iter)
+{
+ GtkTreeRowReference *ref;
+ GtkTreePath *rowpath;
+
+ rowpath = gtk_tree_model_get_path (GTK_TREE_MODEL (ctx->my_ns_store), iter);
+ if (rowpath)
+ {
+ ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (ctx->my_ns_store),
rowpath);
+ if (ref)
+ {
+ gtk_tree_row_reference_free (ctx->default_ns_rref);
+ ctx->default_ns_rref = ref;
+ }
+ gtk_tree_path_free (rowpath);
+ }
+}
+
+
+/**
+ * Try to mark an item in the list as the default namespace.
+ *
+ * @param ctx context
+ * @param iter points to the new default namespace in the list
+ */
+static void
+try_make_default (struct GNUNET_GTK_NamespaceSelectorContext *ctx, GtkTreeIter
*toggled)
+{
+ GtkTreeIter iter;
+ gchar *new_default_ns;
+ gint i;
+ gint row_count;
+ GtkTreePath *path;
+
+ row_count = gtk_tree_model_iter_n_children (
+ GTK_TREE_MODEL (ctx->my_ns_store), NULL);
+ if (! gtk_tree_model_get_iter_first (
+ GTK_TREE_MODEL (ctx->my_ns_store), &iter))
+ return;
+
+ path = gtk_tree_row_reference_get_path (ctx->default_ns_rref);
+ if (path)
+ {
+ /* We know where previous default was, only untoggle that item */
+ GtkTreeIter old_default;
+ if (gtk_tree_model_get_iter (GTK_TREE_MODEL (ctx->my_ns_store),
&old_default, path))
+ {
+ gtk_list_store_set (ctx->my_ns_store, &old_default,
+ GNUNET_GTK_MY_NAMESPACES_USE_THIS_COLUMN, FALSE,
+ -1);
+ }
+ gtk_tree_path_free (path);
+ }
+ else
+ {
+ /* Just untoggle all items */
+ for (i = 0; i < row_count; i++)
+ {
+ gtk_list_store_set (ctx->my_ns_store, &iter,
+ GNUNET_GTK_MY_NAMESPACES_USE_THIS_COLUMN, FALSE,
+ -1);
+ if (TRUE != gtk_tree_model_iter_next (
+ GTK_TREE_MODEL (ctx->my_ns_store), &iter))
+ break;
+ }
+ }
+
+ gtk_list_store_set (ctx->my_ns_store, toggled,
+ GNUNET_GTK_MY_NAMESPACES_USE_THIS_COLUMN, TRUE, -1);
+ gtk_tree_model_get (GTK_TREE_MODEL (ctx->my_ns_store), toggled,
+ GNUNET_GTK_MY_NAMESPACES_NAME_COLUMN, &new_default_ns, -1);
+
+ save_default_ns_reference (ctx, toggled);
+
+ if (new_default_ns)
+ {
+ ctx->default_ns = GNUNET_strdup (new_default_ns);
+ GNUNET_CONFIGURATION_set_value_string (
+ (struct GNUNET_CONFIGURATION_Handle *) GNUNET_FS_GTK_get_configuration
(),
+ "gnunet-fs-gtk", "DEFAULT_NAMESPACE", ctx->default_ns);
+
+ g_free (new_default_ns);
+ }
+}
+
+
+
+/**
+ * Callback with information about local (!) namespaces.
+ * Contains the names of the local namespace and the global
+ * ID.
+ *
+ * @param cls closure
+ * @param name human-readable identifier of the namespace
+ * @param id hash identifier for the namespace
+ */
+static void
+populate_my_ns_list (void *cls, const char *name,
+ const struct GNUNET_FS_PseudonymIdentifier *id)
+{
+ struct GNUNET_GTK_NamespaceSelectorContext *ctx = cls;
+
+ char buf[1024];
+ char *ret;
+ GtkTreeIter my_iter;
+ struct GNUNET_FS_PseudonymIdentifier *nsid;
+ gboolean is_default;
+
+ nsid = GNUNET_malloc (sizeof (struct GNUNET_FS_PseudonymIdentifier));
+ *nsid = *id;
+
+ ret = GNUNET_STRINGS_data_to_string (nsid,
+ sizeof (struct GNUNET_FS_PseudonymIdentifier), buf, sizeof (buf));
+ GNUNET_assert (NULL != ret);
+ ret[0] = '\0';
+
+ if (NULL == ctx->default_ns)
+ {
+ ctx->default_ns = GNUNET_strdup (name);
+ GNUNET_CONFIGURATION_set_value_string (
+ (struct GNUNET_CONFIGURATION_Handle *) GNUNET_FS_GTK_get_configuration
(),
+ "gnunet-fs-gtk", "DEFAULT_NAMESPACE", ctx->default_ns);
+ is_default = TRUE;
+ }
+ else
+ is_default = (0 == strcmp (name, ctx->default_ns)) ? TRUE : FALSE;
+
+ gtk_list_store_insert_with_values (ctx->my_ns_store, &my_iter, G_MAXINT,
+ GNUNET_GTK_MY_NAMESPACES_NAME_COLUMN, name,
+ GNUNET_GTK_MY_NAMESPACES_KEY_COLUMN, buf,
+ GNUNET_GTK_MY_NAMESPACES_KEY_BINARY_COLUMN, nsid,
+ GNUNET_GTK_MY_NAMESPACES_USE_THIS_COLUMN, is_default,
+ GNUNET_GTK_MY_NAMESPACES_ACTUAL_NAME_COLUMN, NULL,
+ -1);
+
+ if (is_default)
+ save_default_ns_reference (ctx, &my_iter);
+}
+
+/**
+ * Returns button visibility/sensitivity to normal.
+ *
+ * @param ctx context
+ * @param anything_selected TRUE if a namespace is selected in the list,
+ * FALSE otherwise
+ */
+static void
+set_normal_state (struct GNUNET_GTK_NamespaceSelectorContext *ctx, gboolean
anything_selected)
+{
+ gtk_widget_set_visible (ctx->do_delete_button, FALSE);
+ gtk_widget_set_visible (ctx->do_keep_button, FALSE);
+ gtk_widget_set_visible (ctx->confirmation_label, FALSE);
+
+ gtk_widget_set_sensitive (ctx->advertise_button, anything_selected);
+ gtk_widget_set_sensitive (ctx->delete_button, anything_selected);
+ gtk_widget_set_sensitive (ctx->create_button, TRUE);
+}
+
+/**
+ * Handles ns list selection changes.
+ *
+ * @param treeselection selection object
+ * @param user_data context
+ */
+static void
+my_ns_selection_changed (GtkTreeSelection *treeselection,
+ gpointer user_data)
+{
+ struct GNUNET_GTK_NamespaceSelectorContext *ctx = user_data;
+ GtkTreeIter iter;
+ struct GNUNET_FS_PseudonymIdentifier *nsid;
+ gboolean selected;
+
+ nsid = NULL;
+ selected = gtk_tree_selection_get_selected (ctx->my_ns_sel, NULL, &iter);
+ if (selected)
+ gtk_tree_model_get (GTK_TREE_MODEL (ctx->my_ns_store), &iter,
+ GNUNET_GTK_MY_NAMESPACES_KEY_BINARY_COLUMN, &nsid, -1);
+ if (NULL == nsid)
+ selected = FALSE;
+ set_normal_state (ctx, selected);
+}
+
+/**
+ * Opens the organizer dialog. Called from outside (by the main window).
+ *
+ * @param main_ctx context of the main window
+ * @return newly-created dialog window object
+ */
+GtkWindow *
+GNUNET_GTK_namespace_organizer_open (struct GNUNET_GTK_MainWindowContext
*main_ctx)
+{
+ struct GNUNET_GTK_NamespaceSelectorContext *ctx;
+ const struct GNUNET_CONFIGURATION_Handle *cfg;
+
+ ctx = GNUNET_malloc (sizeof (struct GNUNET_GTK_NamespaceSelectorContext));
+ ctx->builder = GNUNET_GTK_get_new_builder
("gnunet_fs_gtk_namespace_organizer.glade", ctx);
+ if (ctx->builder == NULL)
+ {
+ GNUNET_break (0);
+ GNUNET_free (ctx);
+ return NULL;
+ }
+
+ ctx->main_ctx = main_ctx;
+
+ /* initialize widget references */
+ ctx->my_ns = GTK_WIDGET (gtk_builder_get_object (ctx->builder,
+ "GNUNET_GTK_namespace_organizer_namespaces_treeview"));
+ ctx->my_ns_sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (
+ ctx->my_ns));
+ ctx->my_ns_store = GTK_LIST_STORE (gtk_tree_view_get_model (
+ GTK_TREE_VIEW (ctx->my_ns)));
+ ctx->namespace_organizer = GTK_WINDOW (gtk_builder_get_object (
+ ctx->builder, "GNUNET_GTK_namespace_organizer_dialog"));
+ ctx->create_button = GTK_WIDGET (gtk_builder_get_object (ctx->builder,
+ "GNUNET_GTK_namespace_organizer_namespaces_create_namespace_button"));
+ ctx->advertise_button = GTK_WIDGET (gtk_builder_get_object (ctx->builder,
+ "GNUNET_GTK_namespace_organizer_namespaces_advertise_namespace_button"));
+ ctx->delete_button = GTK_WIDGET (gtk_builder_get_object (ctx->builder,
+ "GNUNET_GTK_namespace_organizer_namespaces_delete_namespace_button"));
+ ctx->do_delete_button = GTK_WIDGET (gtk_builder_get_object (ctx->builder,
+
"GNUNET_GTK_namespace_organizer_namespaces_delete_namespace_confirmation_button"));
+ ctx->do_keep_button = GTK_WIDGET (gtk_builder_get_object (ctx->builder,
+
"GNUNET_GTK_namespace_organizer_namespaces_delete_namespace_unconfirmation_button"));
+ ctx->progress_spinner = GTK_WIDGET (gtk_builder_get_object (ctx->builder,
+
"GNUNET_GTK_namespace_organizer_namespaces_create_namespace_progress_spinner"));
+ ctx->progress_label = GTK_WIDGET (gtk_builder_get_object (ctx->builder,
+
"GNUNET_GTK_namespace_organizer_namespaces_create_namespace_progress_label"));
+ ctx->confirmation_label = GTK_WIDGET (gtk_builder_get_object (ctx->builder,
+
"GNUNET_GTK_namespace_organizer_namespaces_delete_namespace_confirmation_label"));
+
+ /* connect signals; FIXME-GTK3: these could be connected with (modern) Glade
*/
+ g_signal_connect (G_OBJECT (ctx->my_ns_sel), "changed",
+ G_CALLBACK (my_ns_selection_changed), ctx);
+
+ cfg = GNUNET_FS_GTK_get_configuration ();
+
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg,
+ "gnunet-fs-gtk", "DEFAULT_NAMESPACE", &ctx->default_ns))
+ ctx->default_ns = NULL;
+
+ gtk_widget_set_sensitive (ctx->advertise_button, FALSE);
+ gtk_widget_set_sensitive (ctx->delete_button, FALSE);
+
+ gtk_widget_set_visible (ctx->do_delete_button, FALSE);
+ gtk_widget_set_visible (ctx->do_keep_button, FALSE);
+ gtk_widget_set_visible (ctx->progress_spinner, FALSE);
+ gtk_widget_set_visible (ctx->progress_label, FALSE);
+ gtk_widget_set_visible (ctx->confirmation_label, FALSE);
+
+ /* populate namespace model */
+ GNUNET_FS_namespace_list (GNUNET_FS_GTK_get_fs_handle (),
+ populate_my_ns_list, ctx);
+
+ /* show dialog */
+ gtk_window_present (ctx->namespace_organizer);
+ return ctx->namespace_organizer;
+}
+
+/**
+ * Called when the organizer dialog is destoryed
+ * (happens at some point after it's closed).
+ * Cleans up references to the organizer dialog that main window stores.
+ *
+ * @param object the object that is being destroyed
+ * @param user_data main window context
+ */
+void
+GNUNET_GTK_namespace_organizer_dialog_destroy_cb (GtkWindow *object, gpointer
user_data)
+{
+ struct GNUNET_GTK_MainWindowContext *ctx = user_data;
+ g_signal_handler_disconnect (object, ctx->ns_organizer_delete_handler_id);
+ g_object_unref (G_OBJECT (ctx->ns_organizer));
+ ctx->ns_organizer = NULL;
+ ctx->ns_organizer_delete_handler_id = 0;
+ return;
+}
+
+/**
+ * Wrapper for GNUNET_GTK_namespace_organizer_open(), ensures that
+ * only one instance is opened.
+ * @param ctx main window context
+ */
+void
+GNUNET_GTK_open_ns_organizer (struct GNUNET_GTK_MainWindowContext *ctx)
+{
+ if (ctx->ns_organizer != NULL)
+ {
+ gtk_window_present (ctx->ns_organizer);
+ return;
+ }
+
+ ctx->ns_organizer = GNUNET_GTK_namespace_organizer_open (ctx);
+ if (ctx->ns_organizer == NULL)
+ return;
+
+ g_object_ref (G_OBJECT (ctx->ns_organizer));
+ ctx->ns_organizer_delete_handler_id = g_signal_connect (G_OBJECT
(ctx->ns_organizer), "destroy", G_CALLBACK
(GNUNET_GTK_namespace_organizer_dialog_destroy_cb), ctx);
+}
+
+/**
+ * Called when user clicks at 'Advertise namespace' button.
+ * Opens the advertising dialog (calls GNUNET_FS_GTK_advertise_namespace()).
+ *
+ * @param button button that was clicked
+ * @param user_data context
+ */
+void
+GNUNET_GTK_namespace_organizer_namespaces_advertise_namespace_button_clicked_cb
(
+ GtkButton *button, gpointer user_data)
+{
+ struct GNUNET_GTK_NamespaceSelectorContext *ctx = user_data;
+ GtkTreeIter iter;
+ gchar *name;
+ struct GNUNET_FS_PseudonymIdentifier *nsid;
+
+ nsid = NULL;
+ name = NULL;
+ if (gtk_tree_selection_get_selected (ctx->my_ns_sel, NULL, &iter))
+ gtk_tree_model_get (GTK_TREE_MODEL (ctx->my_ns_store), &iter,
+ GNUNET_GTK_MY_NAMESPACES_NAME_COLUMN, &name,
+ GNUNET_GTK_MY_NAMESPACES_KEY_BINARY_COLUMN, &nsid,
+ -1);
+ if (NULL != nsid)
+ {
+ struct GNUNET_FS_Namespace *ns;
+ ns = GNUNET_FS_namespace_open_existing (GNUNET_FS_GTK_get_fs_handle (),
name);
+ if (ns)
+ GNUNET_FS_GTK_advertise_namespace (ns, ctx->namespace_organizer);
+ }
+ g_free (name);
+}
+
+/**
+ * Called when user clicks at 'Do not delete' button.
+ * Returns the state back to normal (hides [un]confirmation buttons
+ * and the warning label).
+ *
+ * @param button button that was clicked
+ * @param user_data context
+ */
+void
+GNUNET_GTK_namespace_organizer_namespaces_delete_namespace_unconfirmation_button_clicked_cb
(
+ GtkButton *button, gpointer user_data)
+{
+ set_normal_state (user_data, TRUE);
+}
+
+
+/**
+ * Called when user clicks at 'Do delete' button.
+ * Deletes selected namespace after double-checking that everything is
+ * in order.
+ * Returns the state back to normal (hides [un]confirmation buttons
+ * and the warning label).
+ *
+ * @param button button that was clicked
+ * @param user_data context
+ */
+void
+GNUNET_GTK_namespace_organizer_namespaces_delete_namespace_confirmation_button_clicked_cb
(
+ GtkButton *button, gpointer user_data)
+{
+ struct GNUNET_GTK_NamespaceSelectorContext *ctx = user_data;
+ GtkTreeIter iter;
+ gchar *name;
+ gboolean selected;
+ struct GNUNET_FS_PseudonymIdentifier id;
+ struct GNUNET_FS_PseudonymIdentifier *nsid;
+
+ nsid = NULL;
+ name = NULL;
+ selected = gtk_tree_selection_get_selected (ctx->my_ns_sel, NULL, &iter);
+ if (selected)
+ gtk_tree_model_get (GTK_TREE_MODEL (ctx->my_ns_store), &iter,
+ GNUNET_GTK_MY_NAMESPACES_NAME_COLUMN, &name,
+ GNUNET_GTK_MY_NAMESPACES_KEY_BINARY_COLUMN, &nsid,
+ -1);
+ if (NULL == nsid)
+ selected = FALSE;
+
+ if (selected)
+ {
+ struct GNUNET_FS_Namespace *ns;
+ ns = GNUNET_FS_namespace_open_existing (GNUNET_FS_GTK_get_fs_handle (),
name);
+ if (ns)
+ {
+ if (GNUNET_FS_namespace_get_public_identifier (ns, &id))
+ {
+ if (0 == memcmp (&id, nsid, sizeof (id)))
+ {
+ GtkTreeIter first;
+
+ GNUNET_free (nsid);
+ gtk_list_store_remove (ctx->my_ns_store, &iter);
+ GNUNET_FS_namespace_delete (ns, GNUNET_YES);
+
+ if (gtk_tree_model_get_iter_first (
+ GTK_TREE_MODEL (ctx->my_ns_store), &first))
+ try_make_default (ctx, &first);
+ }
+ else
+ {
+ /* We were trying to delete namespace FOO with key X
+ * but when we opened FOO, we discovered that its key is Y.
+ * Clearly this is not the right namespace (something changed
+ * the namespace list right under us?).
+ */
+ /* TODO: display error message */
+ GNUNET_FS_namespace_delete (ns, GNUNET_NO);
+ }
+ }
+ else
+ {
+ /* We were trying to delete namespace FOO,
+ * but we can't even get its key
+ */
+ /* TODO: display error message */
+ GNUNET_FS_namespace_delete (ns, GNUNET_NO);
+ }
+ }
+ }
+ g_free (name);
+ set_normal_state (user_data, selected);
+}
+
+/**
+ * Called when user clicks at 'Delete' button.
+ * Shows the [un]confirmation buttons, as well as the warning.
+ *
+ * @param button button that was clicked
+ * @param user_data context
+ */
+void
+GNUNET_GTK_namespace_organizer_namespaces_delete_namespace_button_clicked_cb (
+ GtkButton *button, gpointer user_data)
+{
+ struct GNUNET_GTK_NamespaceSelectorContext *ctx = user_data;
+ gtk_widget_set_visible (ctx->do_delete_button, TRUE);
+ gtk_widget_set_visible (ctx->do_keep_button, TRUE);
+ gtk_widget_set_visible (ctx->confirmation_label, TRUE);
+ gtk_widget_set_sensitive (ctx->advertise_button, FALSE);
+ gtk_widget_set_sensitive (ctx->delete_button, FALSE);
+ gtk_widget_set_sensitive (ctx->create_button, FALSE);
+}
+
+/**
+ * Generates a random ns name.
+ *
+ * @return new name (free with GNUNET_free()).
+ */
+char *
+generate_local_ns_name ()
+{
+ const char *table =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
+ size_t tablelen = strlen (table);
+ char random_str[9];
+ char *result;
+ int i;
+ for (i = 0; i < 8; i++)
+ {
+ uint32_t index = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
tablelen);
+ GNUNET_assert (index < tablelen);
+ random_str[i] = table[index];
+ }
+ random_str[8] = '\0';
+
+ GNUNET_asprintf (&result, _("MyNamespace-%s"), random_str);
+ return result;
+}
+
+
+/**
+ * Called when key generation for a namespace is finished.
+ *
+ * @param cls context
+ * @param ns newly-created namespace (NULL on failure)
+ * @param emsg error message (NULL on success)
+ */
+static void
+ns_created (void *cls, struct GNUNET_FS_Namespace *ns, char *name, const char
*emsg)
+{
+ struct GNUNET_GTK_NamespaceSelectorContext *ctx = cls;
+
+ GtkTreeIter iter;
+ struct GNUNET_FS_PseudonymIdentifier *nsid;
+ struct GNUNET_FS_PseudonymIdentifier id;
+
+ /* If ns was created, get its public key hash */
+ nsid = NULL;
+ if ((NULL != ns) && (GNUNET_OK == GNUNET_FS_namespace_get_public_identifier
(ns, &id)))
+ {
+ nsid = GNUNET_malloc (sizeof (struct GNUNET_FS_PseudonymIdentifier));
+ memcpy (nsid, &id, sizeof (struct GNUNET_FS_PseudonymIdentifier));
+ }
+
+ /* If anything of the above went wrong, or ns creation failed, we abort */
+ if (NULL == nsid)
+ {
+ GNUNET_FS_namespace_delete (ns, GNUNET_NO);
+ }
+ else
+ {
+ char buf[1024];
+ char *ret;
+ gint row_count;
+
+ ret = GNUNET_STRINGS_data_to_string (nsid,
+ sizeof (struct
GNUNET_FS_PseudonymIdentifier),
+ buf,
+ sizeof (buf));
+ GNUNET_assert (NULL != ret);
+ ret[0] = '\0';
+
+ gtk_list_store_insert_with_values (ctx->my_ns_store, &iter, G_MAXINT,
+ GNUNET_GTK_MY_NAMESPACES_KEY_COLUMN, buf,
+ GNUNET_GTK_MY_NAMESPACES_KEY_BINARY_COLUMN, nsid,
+ GNUNET_GTK_MY_NAMESPACES_NAME_COLUMN, name,
+ -1);
+
+ row_count = gtk_tree_model_iter_n_children (
+ GTK_TREE_MODEL (ctx->my_ns_store), NULL);
+ if (row_count == 1)
+ try_make_default (ctx, &iter);
+ }
+}
+
+
+/**
+ * Create a namespace.
+ * Adds a dummy to the list, starts the key generation process,
+ * shows the progress spinner, disables some buttons.
+ *
+ * @param ctx context
+ */
+static void
+create_namespace (struct GNUNET_GTK_NamespaceSelectorContext *ctx)
+{
+ gchar *name;
+ struct GNUNET_FS_Namespace *ns;
+
+ ns = NULL;
+ name = NULL;
+ do
+ {
+ if (ns)
+ GNUNET_FS_namespace_delete (ns, GNUNET_NO);
+ GNUNET_free_non_null (name);
+ name = generate_local_ns_name ();
+ ns = GNUNET_FS_namespace_open_existing (GNUNET_FS_GTK_get_fs_handle (),
name);
+ } while (NULL != ns);
+
+ ns = GNUNET_FS_namespace_create (GNUNET_FS_GTK_get_fs_handle (), name);
+
+ if (NULL == ns)
+ {
+ GNUNET_free (name);
+ return;
+ }
+
+ ns_created (ctx, ns, name, NULL);
+
+ GNUNET_free (name);
+}
+
+/**
+ * Called when user clicks at 'Create' button.
+ * Creates a namespace.
+ *
+ * @param button button that was clicked
+ * @param user_data context
+ */
+void
+GNUNET_GTK_namespace_organizer_namespaces_create_namespace_button_clicked_cb (
+ GtkButton *button, gpointer user_data)
+{
+ create_namespace (user_data);
+}
+
+/**
+ * Called when user toggles the radio button at a namespace in the list
+ * Tries to make that namespace the new default.
+ *
+ * @param cell_renderer renderer of the call that was toggled.
+ * @param path path to the cell that was toggled
+ * @param user_data context
+ */
+void
+GNUNET_GTK_namespace_organizer_namespaces_treeview_column_usethis_toggle_toggled_cb
(
+ GtkCellRendererToggle *cell_renderer, gchar *path, gpointer user_data)
+{
+ struct GNUNET_GTK_NamespaceSelectorContext *ctx = user_data;
+ GtkTreeIter iter;
+ if (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (ctx->my_ns_store),
+ &iter, path))
+ try_make_default (ctx, &iter);
+}
+
+/**
+ * Called when user activates the appropriate item in main window `File' menu.
+ * Opens Namespace organizer dialog.
+ *
+ * @param menuitem item that was activated
+ * @param user_data main window context
+ */
+void
+GNUNET_GTK_main_menu_file_organize_namespaces_activate_cb (GtkMenuItem
*menuitem,
+ gpointer user_data)
+{
+ GNUNET_GTK_open_ns_organizer (user_data);
+}
+
+/* end of gnunet-fs-gtk_namespace_organizer.c */
Copied: gnunet-gtk/src/identity/gnunet-identity-gtk_ego_organizer.h (from rev
28440, gnunet-gtk/src/fs/gnunet-fs-gtk_namespace_organizer.h)
===================================================================
--- gnunet-gtk/src/identity/gnunet-identity-gtk_ego_organizer.h
(rev 0)
+++ gnunet-gtk/src/identity/gnunet-identity-gtk_ego_organizer.h 2013-08-07
21:28:16 UTC (rev 28444)
@@ -0,0 +1,36 @@
+/*
+ This file is part of GNUnet
+ (C) 2005, 2006, 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
+ by the Free Software Foundation; either version 2, 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/fs/gnunet-fs-gtk_namespace_organizer.h
+ * @author LRN
+ */
+
+#ifndef GNUNET_FS_GTK_NAMESPACE_ORGANIZER_H
+#define GNUNET_FS_GTK_NAMESPACE_ORGANIZER_H
+
+#include "gnunet-fs-gtk_common.h"
+#include "gnunet-fs-gtk.h"
+
+GtkObject *
+GNUNET_GTK_namespace_organizer_open (struct GNUNET_GTK_MainWindowContext
*main_ctx);
+
+#endif /* GNUNET_FS_GTK_NAMESPACE_ORGANIZER_H */
+/* end of gnunet-fs-gtk_namespace_organizer.c */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r28444 - in gnunet-gtk: contrib src src/fs src/identity,
gnunet <=